@matterbridge/frontend 3.4.17 → 3.4.18-dev-20260620-9802e5b
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/README.md +5 -4
- package/build/assets/index.css +1 -1
- package/build/assets/index.js +6 -6
- package/build/assets/vendor_mdi.js +1 -1
- package/build/assets/vendor_mui.js +1 -1
- package/build/assets/vendor_node_modules.js +46 -95
- package/build/assets/vendor_notistack.js +1 -1
- package/build/assets/vendor_rjsf.js +6 -6
- package/npm-shrinkwrap.json +27 -41
- package/package.json +5 -10
package/build/assets/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime.js";import{c as t}from"./vendor_emotion.js";import{c as n,d as r,f as i,l as a,m as o,p as s,u as c}from"./vendor_node_modules.js";import{$ as l,A as u,At as d,B as f,Bt as p,C as m,Ct as h,D as g,Dt as _,E as v,Et as y,F as b,Ft as x,G as S,Gt as C,H as w,Ht as T,I as E,It as D,J as O,K as k,Kt as A,L as j,Lt as M,M as ee,Mt as N,N as te,Nt as P,O as ne,Ot as F,P as re,Pt as I,Q as ie,R as ae,Rt as L,S as oe,St as se,T as ce,Tt as le,U as ue,Ut as de,V as fe,Vt as pe,W as me,Wt as R,X as he,Y as ge,Z as _e,_ as ve,_t as ye,a as be,at as xe,b as Se,bt as z,c as Ce,ct as we,d as Te,dt as Ee,et as De,f as Oe,ft as B,g as ke,gt as V,h as Ae,ht as je,i as Me,it as Ne,j as Pe,jt as Fe,k as Ie,kt as Le,l as Re,lt as ze,m as Be,mt as Ve,n as He,nt as Ue,o as We,ot as Ge,p as Ke,pt as H,q as qe,r as Je,rt as Ye,s as Xe,st as Ze,t as Qe,tt as $e,u as et,ut as tt,v as nt,vt as rt,w as it,wt as at,x as ot,xt as U,y as st,yt as ct,z as lt,zt as W}from"./vendor_mui.js";import{_ as ut,a as dt,h as ft,j as pt,o as mt,r as ht,s as gt,v as _t}from"./vendor_mdi.js";import{n as vt,t as yt}from"./vendor_notistack.js";import{t as bt}from"./vendor_qrcode.js";import{a as xt,c as St,i as Ct,l as wt,n as Tt,o as Et,r as Dt,s as Ot,t as kt}from"./vendor_rjsf.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var G=e(t(),1),At=e(o(),1),K=A();function jt({open:e,title:t,message:n,onConfirm:r,onCancel:i}){return(0,K.jsxs)(D,{open:e,children:[(0,K.jsx)(P,{gap:`20px`,children:(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,K.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,K.jsx)(`h4`,{style:{margin:0},children:t})]})}),(0,K.jsxs)(I,{children:[(0,K.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`center`,margin:`0`,marginBottom:`20px`,maxHeight:`350px`,maxWidth:`350px`},children:(0,K.jsx)(`p`,{style:{flex:1,margin:`0`},children:n})}),(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-around`},children:[(0,K.jsx)(L,{onClick:e=>{Q&&console.log(`Confirmed`),e.preventDefault(),r()},variant:`contained`,color:`primary`,size:`small`,children:`Confirm`}),(0,K.jsx)(L,{onClick:e=>{Q&&console.log(`Canceled`),e.preventDefault(),i()},variant:`contained`,color:`primary`,size:`small`,children:`Cancel`})]})]})]})}var q={enableMobile:`enableMobile`,devicesFilterPlugins:`devicesFilterPlugins`,devicesFilterDevices:`devicesFilterDevices`,devicesViewMode:`devicesViewMode`,frontendVersion:`frontendVersion`,matterbridgeVersion:`matterbridgeVersion`,homePageMode:`homePageMode`,logFilterLevel:`logFilterLevel`,logFilterSearch:`logFilterSearch`,logAutoScroll:`logAutoScroll`,logLength:`logLength`,frontendTheme:`frontendTheme`,homePagePlugins:`homePagePlugins`,virtualMode:`virtualMode`,installAutoExit:`installAutoExit`,searchPluginsTotal:`searchPluginsTotal`,searchPluginsMeta:`searchPluginsMeta`,searchPluginsVersions:`searchPluginsVersions`},Mt={Devices_table_order_by:`Devices_table_order_by`,Devices_table_order:`Devices_table_order`,Devices_column_visibility:`Devices_column_visibility`,Plugins_table_order_by:`Plugins_table_order_by`,Plugins_table_order:`Plugins_table_order`,Plugins_column_visibility:`Plugins_column_visibility`,"Registered devices_table_order_by":`Registered devices_table_order_by`,"Registered devices_table_order":`Registered devices_table_order`,"Registered devices_column_visibility":`Registered devices_column_visibility`,Clusters_table_order_by:`Clusters_table_order_by`,Clusters_table_order:`Clusters_table_order`,Clusters_column_visibility:`Clusters_column_visibility`};function Nt(){Object.values(q).forEach(e=>{localStorage.removeItem(e)}),Object.values(Mt).forEach(e=>{localStorage.removeItem(e)})}var Pt=({open:e,output:t,title:n,_command:r,_packageName:i,onInstall:a,onClose:o})=>{let{installAutoExit:s,mobile:c,setInstallAutoExit:l}=(0,G.useContext)(It),u=(0,G.useRef)(null),f=e=>{l(e.target.checked),localStorage.setItem(q.installAutoExit,e.target.checked?`true`:`false`),Q&&console.log(`handleInstallAutoExitChange called with value:`,e.target.checked)};return(0,G.useEffect)(()=>{Q&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom: ${u.current}`),setTimeout(()=>{Q&&console.log(`Scrolling to bottom:`,u.current),u.current?.scrollIntoView({behavior:`smooth`,block:`end`})},0)},[t]),(0,K.jsxs)(D,{open:e,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||o()},slotProps:{paper:{sx:{width:$&&c?`100vw`:`75vw`,maxWidth:$&&c?`100vw`:`75vw`,height:$&&c?`100vh`:`75vw`,maxHeight:$&&c?`100vh`:`75vh`,margin:$&&c?`0px`:void 0,overflow:`hidden`}}},children:[(0,K.jsx)(P,{children:(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,K.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,K.jsx)(`h4`,{style:{margin:0},children:n})]})}),(0,K.jsxs)(I,{dividers:!0,style:{overflow:`hidden`,display:`flex`,flexDirection:`column`,height:400,paddingBottom:0},children:[(0,K.jsx)(`label`,{style:{display:`block`,marginBottom:`10px`,fontSize:`16px`,fontWeight:`bold`,color:`var(--primary-color)`},children:`Process log`}),(0,K.jsxs)(`ul`,{style:{width:`100%`,height:`100%`,fontFamily:`monospace`,fontSize:`14px`,padding:`10px`,margin:0,marginBottom:`10px`,color:`var(--div-text-color)`,background:`var(--div-bg-color)`,overflow:`auto`,listStyle:`none`,boxSizing:`border-box`,borderRadius:4,border:`4px solid var(--primary-color)`,whiteSpace:`pre-wrap`,display:`block`},children:[t.split(`
|
|
2
|
-
`).map((e,t)=>(0,K.jsx)(`li`,{style:{padding:0,margin:0,wordBreak:`break-all`},children:e},t)),(0,K.jsx)(`li`,{ref:u,style:{padding:0,margin:0}})]})]}),(0,K.jsxs)(x,{sx:{justifyContent:`space-evenly`},children:[a&&(0,K.jsx)(L,{variant:`contained`,onClick:a,children:`Install`}),(0,K.jsx)(L,{onClick:o,children:`Close`}),(0,K.jsx)(d,{control:(0,K.jsx)(M,{checked:s,onChange:e=>f(e)}),label:`Close on success`,style:{color:`var(--div-text-color)`}})]})]})},Ft=[],It=(0,G.createContext)(null);function Lt({children:e}){let[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(null),{enqueueSnackbar:a,closeSnackbar:o}=vt(),s=(0,G.useCallback)(e=>{Q&&console.log(`UiProvider closeSnackbarMessage: message ${e}`);let t=Ft.findIndex(t=>t.message===e);t!==-1&&(o(Ft[t].key),Ft.splice(t,1),Q&&console.log(`UiProvider closeSnackbarMessage: message ${e} removed from persistMessages`))},[o]),c=(0,G.useCallback)((e,t,n)=>{Q&&console.log(`UiProvider showSnackbarMessage: message ${e} timeout ${t}`);let r=a(e,{variant:`default`,autoHideDuration:t==null||t>0?(t??5)*1e3:null,persist:t===0,content:t=>(0,K.jsx)(W,{sx:{margin:`0`,padding:`0`,width:`300px`,marginRight:`30px`},children:(0,K.jsx)(pe,{severity:n??`info`,variant:`filled`,sx:{color:`#fff`,fontWeight:`normal`,width:`100%`,cursor:`pointer`,padding:`0px 10px`},onClick:()=>o(t),action:(0,K.jsx)(T,{size:`small`,onClick:()=>o(t),sx:{color:`#fff`},children:(0,K.jsx)(Ee,{fontSize:`small`})}),children:e},t)},t)});t===0&&(Q&&console.log(`UiProvider showSnackbarMessage: message ${e} timeout ${t} - persist key ${r}`),Ft.push({message:e,key:r}))},[a,o]),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(``),_=(0,G.useRef)(null),v=(0,G.useRef)(null),y=()=>{Q&&console.log(`UiProvider handle confirm action ${h}`),u(!1),_.current&&_.current(h)},b=()=>{Q&&console.log(`UiProvider handle cancel action ${h}`),u(!1),v.current&&v.current(h)},x=(0,G.useCallback)((e,t,n,r,i)=>{Q&&console.log(`UiProvider showConfirmCancelDialog for command ${n}`),f(e),m(t),g(n),_.current=r,v.current=i,u(!0)},[]),[S,C]=(0,G.useState)(!1),[w,E]=(0,G.useState)(``),[D,O]=(0,G.useState)(``),[k,A]=(0,G.useState)(``),[j,M]=(0,G.useState)(``),[ee,N]=(0,G.useState)(localStorage.getItem(q.installAutoExit)!==`false`),te=(0,G.useCallback)((e,t,n)=>{Q&&console.log(`UiProvider show install progress for package ${e}`),E(e),O(t),A(n),C(!0)},[]),P=(0,G.useCallback)(e=>{Q&&console.log(`UiProvider addInstallProgress: output ${e}`),M(t=>t+e+`
|
|
3
|
-
`)},[]),ne=(0,G.useCallback)(()=>{Q&&console.log(`UiProvider exitInstallProgressSuccess: package ${k}`),localStorage.getItem(q.installAutoExit)!==`false`&&C(!1)},[k]),F=(0,G.useCallback)(()=>{Q&&console.log(`UiProvider exitInstallProgressError: package ${k}`)},[k]),re=(0,G.useCallback)(()=>{Q&&console.log(`UiProvider hide install progress`),C(!1)},[]),I=()=>{Q&&console.log(`UiProvider handle install close action`),C(!1),A(``),M(``)},ie=(0,G.useMemo)(()=>({mobile:t,setMobile:n,currentPage:r,setCurrentPage:i,showSnackbarMessage:c,closeSnackbarMessage:s,closeSnackbar:o,showConfirmCancelDialog:x,showInstallProgress:te,exitInstallProgressSuccess:ne,exitInstallProgressError:F,hideInstallProgress:re,addInstallProgress:P,installAutoExit:ee,setInstallAutoExit:N}),[t,r,n,i,c,s,o,x,te,ne,F,re,P,ee,N]);return(0,K.jsxs)(It.Provider,{value:ie,children:[(0,K.jsx)(jt,{open:l,title:d,message:p,onConfirm:y,onCancel:b}),(0,K.jsx)(Pt,{open:S,title:w,_command:D,_packageName:k,output:j,onClose:I}),e]})}var Rt=(0,G.createContext)(null),J=(0,G.createContext)(null);function zt({children:e}){let[t,n]=(0,G.useState)([]),[r,i]=(0,G.useState)(localStorage.getItem(q.logFilterLevel)??`info`),[a,o]=(0,G.useState)(localStorage.getItem(q.logFilterSearch)??`*`),[s,c]=(0,G.useState)(!1),{showSnackbarMessage:l,closeSnackbarMessage:u,closeSnackbar:d,showInstallProgress:f,hideInstallProgress:p,exitInstallProgressSuccess:m,exitInstallProgressError:h,addInstallProgress:g}=(0,G.useContext)(It),_=(0,G.useRef)([]),v=(0,G.useRef)(null),y=(0,G.useRef)(1),b=(0,G.useRef)(Math.floor(Math.random()*999e3)+1e3),x=(0,G.useRef)(null),S=(0,G.useRef)(null),C=(0,G.useRef)(null),w=(0,G.useRef)(r),T=(0,G.useRef)(a),E=(0,G.useRef)(0),D=(0,G.useRef)(null),O=(0,G.useRef)(Number(localStorage.getItem(q.logLength)??200)),k=(0,G.useRef)(localStorage.getItem(q.logAutoScroll)!==`false`),A=(0,G.useMemo)(()=>window.location.href.replace(/^http/,`ws`),[]);(0,G.useEffect)(()=>(Q&&console.log(`WebSocket messages started counter interval`),D.current=setInterval(()=>{E.current>0&&(Q&&console.log(`WebSocket messages received in the last 10 seconds: ${E.current*(60/10)} messages/minute`),E.current=0)},10*1e3),()=>{Q&&console.log(`WebSocket messages stopped counter interval`),D.current&&clearInterval(D.current),D.current=null}),[]),(0,G.useEffect)(()=>{w.current=r},[r]),(0,G.useEffect)(()=>{T.current=a},[a]);let j=(0,G.useCallback)(()=>Math.floor(Math.random()*999e3)+1e3,[]),M=(0,G.useCallback)((e,t)=>{Q&&console.log(`WebSocket filterLogMessages called with level "${e}" and search "${t}"...`),n(n=>n.filter(n=>!([`debug`,`info`,`notice`,`warn`,`error`,`fatal`].includes(n.level)&&(e===`info`&&n.level===`debug`||e===`notice`&&(n.level===`debug`||n.level===`info`)||e===`warn`&&(n.level===`debug`||n.level===`info`||n.level===`notice`)||e===`error`&&(n.level===`debug`||n.level===`info`||n.level===`notice`||n.level===`warn`)||e===`fatal`&&(n.level===`debug`||n.level===`info`||n.level===`notice`||n.level===`warn`||n.level===`error`))||t!==`*`&&t!==``&&!t.startsWith(`/`)&&!t.endsWith(`/`)&&!n.message.toLowerCase().includes(t.toLowerCase())&&!n.name.toLowerCase().includes(t.toLowerCase())||t.startsWith(`/`)&&t.endsWith(`/`)&&(()=>{try{let e=new RegExp(t.slice(1,-1),`i`);return!e.test(n.message)&&!e.test(n.name)}catch(e){return console.error(`WebSocket log search invalid regex filter "${t}":`,e),!1}})())))},[]),ee=(0,G.useCallback)(e=>{if(v.current&&v.current.readyState===WebSocket.OPEN)try{Q&&console.log(`WebSocket sending message with id ${e.id}:`,e),e.id===void 0&&(e.id=b.current);let t=JSON.stringify(e);v.current.send(t),Q&&console.log(`WebSocket sent message:`,e)}catch(e){Q&&console.error(`WebSocket error sending message: ${e}`)}else Q&&console.error(`WebSocket message not sent, WebSocket not connected:`,e)},[]),N=(0,G.useCallback)((e,t)=>{n(n=>[...n,{level:e,time:``,name:``,message:t}])},[]),te=(0,G.useCallback)((e,t)=>{Q&&console.log(`WebSocket addListener id ${t}:`,e),(t==null||isNaN(t)||t===0)&&console.error(`WebSocket addListener called without id, listener not added:`,e),_.current=[..._.current,{listener:e,id:t}],Q&&console.log(`WebSocket addListener total listeners:`,_.current.length)},[]),P=(0,G.useCallback)(e=>{Q&&console.log(`WebSocket removeListener:`,e),_.current=_.current.filter(t=>t.listener!==e),Q&&console.log(`WebSocket removeListener total listeners:`,_.current.length)},[]),ne=(0,G.useCallback)(()=>{A===``||A==null||(N(`WebSocket`,`Connecting ${oi?`with password`:``} to WebSocket: ${A}`),Q&&console.log(`WebSocket connecting to: ${A}${oi?`?password=[redacted]`:``}`),v.current=new WebSocket(A+(oi?`?password=${encodeURIComponent(oi)}`:``)),v.current.onmessage=e=>{s||c(!0),E.current+=1;try{let t=JSON.parse(e.data);if(t.id===void 0||t.src===void 0||t.dst===void 0){Q&&console.error(`WebSocket undefined message id/src/dst:`,t);return}if(t.src!==`Matterbridge`||t.dst!==`Frontend`){Q&&console.error(`WebSocket invalid message src/dst:`,t);return}if(t.error){Q&&console.error(`WebSocket error message response:`,t);return}if(t.id===b.current&&t.method===`pong`&&t.response===`pong`){Q&&console.log(`WebSocket pong response message id ${t.id}:`,t),S.current&&clearTimeout(S.current),S.current=null;return}else if(t.method===`snackbar`&&t.response&&t.response.message){Q&&console.log(`WebSocket message id ${t.id} method ${t.method}:`,t),l(t.response.message,t.response.timeout,t.response.severity);return}else if(t.method===`close_snackbar`&&t.response&&t.response.message){Q&&console.log(`WebSocket message id ${t.id} method ${t.method}:`,t),u(t.response.message);return}else if(t.method===`log`){if(!t.response||!t.response.level||!t.response.time||!t.response.name||!t.response.message||(t.response.level===`spawn`&&(t.response.name===`Matterbridge:spawn-init`?f(t.response.message,``,``):t.response.name===`Matterbridge:spawn-exit-success`?m():t.response.name===`Matterbridge:spawn-exit-error`?h():g(t.response.message+`
|
|
4
|
-
`)),[`debug`,`info`,`notice`,`warn`,`error`,`fatal`].includes(t.response.level)&&(w.current===`info`&&t.response.level===`debug`||w.current===`notice`&&(t.response.level===`debug`||t.response.level===`info`)||w.current===`warn`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`)||w.current===`error`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`||t.response.level===`warn`)||w.current===`fatal`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`||t.response.level===`warn`||t.response.level===`error`)))||T.current!==`*`&&T.current!==``&&!T.current.startsWith(`/`)&&!T.current.endsWith(`/`)&&!t.response.message.toLowerCase().includes(T.current.toLowerCase())&&!t.response.name.toLowerCase().includes(T.current.toLowerCase())||T.current.startsWith(`/`)&&T.current.endsWith(`/`)&&(()=>{try{let e=new RegExp(T.current.slice(1,-1),`i`);return!e.test(t.response.message)&&!e.test(t.response.name)}catch(e){return console.error(`WebSocket log search invalid regex filter "${T.current}":`,e),!1}})()||t.response.name===`Commissioning`&&t.response.message.includes(`is uncommissioned`))return;n(e=>{let n=[...e,{level:t.response.level,time:t.response.time,name:t.response.name,message:t.response.message}];return Q&&console.log(`WebSocket new log message added (${n.length}/${O.current}):`,n[n.length-1]),n.length>O.current+O.current*10/100?(Q&&console.log(`WebSocket sliced log messages to the last ${O.current} entries`),n.slice(n.length-O.current)):n})}else{if(Q&&console.log(`WebSocket received message id ${t.id} method ${t.method}:`,t),t.id===0)_.current.forEach(e=>e.listener(t));else{let e=_.current.find(e=>e.id===t.id);e?e.listener(t):console.warn(`WebSocket no listener found for message id ${t.id}:`,t)}return}}catch(e){console.error(`WebSocket error parsing message: ${e}`,e instanceof Error?e.stack:null)}},v.current.onopen=()=>{Q&&console.log(`WebSocket: Connected to WebSocket: ${A}`),N(`WebSocket`,`Connected to WebSocket: ${A}`),c(!0),d(),y.current=1,C.current=setTimeout(()=>{x.current=setInterval(()=>{ee({id:b.current,method:`ping`,src:`Frontend`,dst:`Matterbridge`,params:{}}),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{Q&&console.error(`WebSocketUse: No pong response received from WebSocket: ${A}`),N(`WebSocket`,`No pong response received from WebSocket: ${A}`),c(!1)},1e3*50)},1e3*60)},1e3*300)},v.current.onclose=()=>{Q&&console.error(`WebSocket: Disconnected from WebSocket ${ci?`with Ingress`:``}: ${A}`),N(`WebSocket`,`Disconnected from WebSocket: ${A}`),c(!1),d(),p(),C.current&&clearTimeout(C.current),S.current&&clearTimeout(S.current),x.current&&clearInterval(x.current),N(`WebSocket`,`Reconnecting (attempt ${y.current} of 100) to WebSocket${ci?` (Ingress)`:``}: ${A}`),ci?setTimeout(F,5e3):y.current===1?F():y.current<100?setTimeout(F,1e3*y.current):N(`WebSocket`,`Reconnect attempts exceeded limit of 100 retries, refresh the page to reconnect to: ${A}`),y.current+=1},v.current.onerror=e=>{Q&&console.error(`WebSocket: WebSocket error connecting to ${A}:`,e),N(`WebSocket`,`WebSocket error connecting to ${A}`)})},[A]),F=(0,G.useCallback)(()=>{Q&&console.log(`WebSocket attemptReconnect ${y.current}/100 to:`,A),ne()},[ne]);(0,G.useEffect)(()=>(ne(),()=>{v.current&&v.current.readyState===WebSocket.OPEN&&v.current.close()}),[ne]);let re=(0,G.useMemo)(()=>({messages:t,logLength:O,logAutoScroll:k,logFilterLevel:r,logFilterSearch:a,setMessages:n,setLogFilterLevel:i,setLogFilterSearch:o,filterLogMessages:M}),[t,O,k,r,a,n,i,o,M]),I=(0,G.useMemo)(()=>({logLength:O,logAutoScroll:k,logFilterLevel:r,logFilterSearch:a,setMessages:n,setLogFilterLevel:i,setLogFilterSearch:o,filterLogMessages:M,online:s,retry:y.current,getUniqueId:j,addListener:te,removeListener:P,sendMessage:ee,logMessage:N}),[O,k,n,i,o,s,y.current,te,P,ee,N]);return(0,K.jsx)(Rt.Provider,{value:re,children:(0,K.jsx)(J.Provider,{value:I,children:e})})}function Bt(e){return(0,K.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,viewBox:`0 0 296.2 296.2`,...e,children:[(0,K.jsxs)(`defs`,{children:[(0,K.jsxs)(`linearGradient`,{id:`lg1`,x1:`16.6`,y1:`16.6`,x2:`279.6`,y2:`279.6`,gradientUnits:`userSpaceOnUse`,children:[(0,K.jsx)(`stop`,{offset:`0`,stopColor:`#00b48d`}),(0,K.jsx)(`stop`,{offset:`.1`,stopColor:`#3faa77`}),(0,K.jsx)(`stop`,{offset:`.3`,stopColor:`#234148`}),(0,K.jsx)(`stop`,{offset:`.7`,stopColor:`#203b44`}),(0,K.jsx)(`stop`,{offset:`.9`,stopColor:`#ad2e6e`}),(0,K.jsx)(`stop`,{offset:`1`,stopColor:`#c81b74`})]}),(0,K.jsxs)(`linearGradient`,{id:`lg2`,x1:`31.1`,y1:`31.1`,x2:`265.1`,y2:`265.1`,gradientUnits:`userSpaceOnUse`,children:[(0,K.jsx)(`stop`,{offset:`0`,stopColor:`#00b48d`}),(0,K.jsx)(`stop`,{offset:`.2`,stopColor:`#285251`}),(0,K.jsx)(`stop`,{offset:`.4`,stopColor:`#234148`}),(0,K.jsx)(`stop`,{offset:`.8`,stopColor:`#203b44`}),(0,K.jsx)(`stop`,{offset:`.9`,stopColor:`#a8316c`}),(0,K.jsx)(`stop`,{offset:`1`,stopColor:`#c81b74`})]}),(0,K.jsxs)(`linearGradient`,{id:`lg3`,x1:`116.2`,y1:`143.9`,x2:`139.8`,y2:`143.9`,gradientUnits:`userSpaceOnUse`,children:[(0,K.jsx)(`stop`,{offset:`0`,stopColor:`#8bc751`}),(0,K.jsx)(`stop`,{offset:`1`,stopColor:`#0db14b`})]}),(0,K.jsx)(`linearGradient`,{id:`lg4`,x1:`136.1`,y1:`100.8`,x2:`159.6`,y2:`100.8`,xlinkHref:`#lg3`}),(0,K.jsx)(`linearGradient`,{id:`lg5`,x1:`155.3`,y1:`143.9`,x2:`178.9`,y2:`143.9`,xlinkHref:`#lg3`}),(0,K.jsxs)(`linearGradient`,{id:`lg6`,x1:`46.8`,y1:`25.7`,x2:`89.6`,y2:`74.8`,gradientUnits:`userSpaceOnUse`,children:[(0,K.jsx)(`stop`,{offset:`0`,stopColor:`#b1d34a`}),(0,K.jsx)(`stop`,{offset:`1`,stopColor:`#50b848`})]})]}),(0,K.jsx)(`rect`,{width:`296.2`,height:`296.2`,rx:`56.7`,ry:`56.7`,style:{fill:`url(#lg1)`}}),(0,K.jsx)(`rect`,{x:`16.3`,y:`16.3`,width:`263.6`,height:`263.6`,rx:`50.5`,ry:`50.5`,style:{fill:`url(#lg2)`}}),(0,K.jsx)(`circle`,{cx:`128`,cy:`143.9`,r:`11.8`,style:{fill:`url(#lg3)`}}),(0,K.jsx)(`circle`,{cx:`147.8`,cy:`100.8`,r:`11.8`,style:{fill:`url(#lg4)`}}),(0,K.jsx)(`path`,{d:`m244.6 114.5.4-.5L160 33a17 17 0 0 0-24.7-.5l-86.4 83.3a15 15 0 0 0 9.2 26.9h19.3v-4.7l-13.7-12.7v-.1l83.7-80.8 84.2 81-13.9 12.8v4.5h19.5a15 15 0 0 0 7.4-28.1Z`,style:{fill:`url(#lg3)`}}),(0,K.jsx)(`circle`,{cx:`167.1`,cy:`143.9`,r:`11.8`,style:{fill:`url(#lg5)`}}),(0,K.jsx)(`path`,{fill:`#fff`,d:`M219 89.3V35.5a10.5 10.5 0 1 0-21 0v33.7l21 20Z`}),(0,K.jsx)(`path`,{d:`M91.4 73.3H83a37 37 0 0 0-14.5-28.4L65 50.2c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.8-7.8-16-23.7-11.9-46 8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2Z`,style:{fill:`url(#lg6)`}}),(0,K.jsx)(`path`,{d:`M65.9 80a49.6 49.6 0 0 0 17.8 2.2l16.6-16c1.6-8.3.5-15.7-3.3-22.4C84.6 22 47.8 17.5 46.2 17.4l-3-.4-.6 3c-3.8 18.4-5.9 50.6 23.2 60ZM48.4 24.4c8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2H83a37 37 0 0 0-14.5-28.4l-3.7 5.3c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.9-7.8-16-23.7-11.9-46Z`,fill:`#1e5857`}),(0,K.jsx)(`path`,{fill:`#fff`,d:`M250.5 90.5a17.4 17.4 0 1 1 0-34.8 17.4 17.4 0 0 1 0 34.8Zm0-22.7a5.4 5.4 0 0 0 0 10.7 5.3 5.3 0 0 0 0-10.7ZM258.8 148.2a15.9 15.9 0 0 0-9.6 28.5c-.8 4.2-5.4 4.6-5.4 4.6h-26v-43l13.6-13-1.8-2-82.2-79-81.2 78.3-2.5 2.6 13.7 13v42.9H53a21.5 21.5 0 1 0 11.7 15h12.6v18.8c0 7.8 6.4 14.1 14.1 14.1h29.3v14.8H64a10.6 10.6 0 0 0-17.7 8 10.6 10.6 0 0 0 17.6 8h157.6a16.3 16.3 0 1 0 0-16h-84.8V229h66.8c7.8 0 14.2-6.3 14.2-14.1v-19.2h27.6c14.3 0 17.8-12.8 18.5-16.6a15.9 15.9 0 0 0-5-30.9ZM43.7 210.8a10.3 10.3 0 1 1 0-20.6 10.3 10.3 0 0 1 0 20.6Zm192 36a5 5 0 1 1 0 10 5 5 0 0 1 0-10Zm-77-34.8h-22v-34h22v34Zm8.4-79.8c2.7 0 5.2 1 7.2 2.5v-10.4L188 137s2.6 1.3 4.6 1.3h6.7v68c0 3.2-2.6 5.7-5.7 5.7h-19v-34h1.4a7.5 7.5 0 0 0 0-15H120a7.5 7.5 0 0 0 0 15h.7v34h-19.3a5.7 5.7 0 0 1-5.7-5.6v-68.1h6.7c2 0 4.6-1.3 4.6-1.3l13.7-12.7v10.4a11.7 11.7 0 0 1 16 1.6v-13a14.9 14.9 0 0 0-25-10.8s-.1.2-.1.2l-.5.5-6.9 7H92.5l55-53.2 55.1 53.2h-11.8l-7-7c0-.2-.2-.3-.4-.5l-.2-.2a14.8 14.8 0 0 0-25 10.9v12.9c2.2-2.5 5.3-4.1 8.9-4.1Zm91.7 36.7a4.9 4.9 0 1 1 0-9.7 4.9 4.9 0 0 1 0 9.7Z`})]})}function Vt(){let{retry:e}=(0,G.useContext)(J);return(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,width:`100vw`,height:`100vh`,justifyContent:`center`,alignItems:`center`,fontSize:`20px`,color:`var(--main-text-color)`,backgroundColor:`var(--main-bg-color)`},children:[(0,K.jsx)(Bt,{style:{height:`128px`,width:`128px`,margin:`10px`,marginBottom:`20px`}}),e<100?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(de,{style:{color:`var(--primary-color)`}}),(0,K.jsx)(`div`,{style:{marginTop:`20px`,color:`var(--primary-color)`,textAlign:`center`},children:(0,K.jsxs)(`span`,{children:[`Reconnecting to Matterbridge `,`(attempt `+e+`)`,`...`]})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{style:{marginTop:`20px`,color:`var(--primary-color)`,textAlign:`center`},children:[(0,K.jsx)(`span`,{children:`Unable to connect to Matterbridge after multiple attempts.`}),(0,K.jsx)(`br`,{}),(0,K.jsx)(`span`,{children:`Please check your network connection.`}),(0,K.jsx)(`br`,{})]}),(0,K.jsx)(L,{variant:`contained`,color:`primary`,onClick:()=>{window.location.reload()},style:{marginTop:`20px`},children:`Refresh the Page`})]})]})}var Y=pt();function Ht({value:e,maxChars:t}){let n=e;if(e.length>t&&t>3){let r=t-3;n=`${e.substring(0,Math.ceil(r/2))} … ${e.substring(e.length-Math.floor(r/2),e.length)}`}return e===n?(0,K.jsx)(`span`,{children:n}):(0,K.jsx)(H,{title:e,placement:`top`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[0,12]}}]}},children:(0,K.jsx)(`span`,{children:n})})}function X({children:e,style:t}){return(0,K.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,flex:`0 0 auto`,width:`100%`,overflow:`hidden`,margin:`0px`,padding:`0px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,boxShadow:`5px 5px 10px var(--div-shadow-color)`,border:`1px solid var(--table-border-color)`,borderRadius:`var(--div-border-radius)`,boxSizing:`border-box`,...t},children:e})}function Ut({children:e,style:t}){return(0,K.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:`space-between`,width:`100%`,height:`30px`,borderBottom:`1px solid var(--table-border-color)`,color:`var(--header-text-color)`,backgroundColor:`var(--header-bg-color)`,margin:`0px`,padding:`0px`,boxSizing:`border-box`,...t},children:e})}function Wt({children:e,style:t}){return(0,K.jsx)(`div`,{style:{color:`var(--header-text-color)`,backgroundColor:`var(--header-bg-color)`,fontSize:`16px`,fontWeight:`bold`,margin:`0px`,padding:`5px 10px`,...t},children:e})}function Gt({children:e,style:t}){return(0,K.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:`space-between`,width:`100%`,height:`30px`,color:`var(--footer-text-color)`,backgroundColor:`var(--footer-bg-color)`,margin:`0px`,padding:`0px`,boxSizing:`border-box`,...t},children:e})}function Kt({children:e,style:t}){return(0,K.jsx)(`div`,{style:{color:`var(--footer-text-color)`,backgroundColor:`var(--footer-bg-color)`,fontSize:`14px`,fontWeight:`bold`,margin:`0px`,padding:`5px 10px`,...t},children:e})}function qt({children:e,style:t}){return(0,K.jsx)(`div`,{style:{color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`,fontSize:`14px`,fontWeight:`normal`,margin:`0px`,padding:`5px 10px`,...t},children:e})}function Jt({children:e,style:t,onDragOver:n,onDragLeave:r,onDrop:i}){return(0,K.jsx)(`div`,{style:{flex:`0 0 auto`,display:`flex`,flexDirection:`row`,overflow:`hidden`,alignItems:`start`,justifyContent:`space-between`,margin:`0px`,padding:`10px`,gap:`20px`,...t},onDragOver:n,onDragLeave:r,onDrop:i,children:e})}function Yt({children:e,style:t,close:n}){return(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,margin:`0px`,padding:`0px`,paddingRight:`10px`,gap:`10px`,...t},children:[e,!1]})}function Xt({systemInfo:e,compact:t}){let{mobile:n}=(0,G.useContext)(It),{addListener:r,removeListener:i,getUniqueId:a,sendMessage:o}=(0,G.useContext)(J),[s,c]=(0,G.useState)(e),l=(0,G.useRef)(a());if(Q&&console.log(`SystemInfoTable loading with systemInfo:`,s,`compact:`,t),e&&t&&s.totalMemory&&s.freeMemory){let e=s.totalMemory;s.freeMemory=`${s.freeMemory} / ${e}`,s.totalMemory=``}if(e&&t&&s.heapTotal&&s.heapUsed){let e=s.heapTotal;s.heapUsed=`${s.heapUsed} / ${e}`,s.heapTotal=``}e&&t&&s.osRelease&&s.osType&&(s.osType=`${s.osType} (${s.osRelease})`,s.osRelease=``),e&&t&&s.osArch&&s.osPlatform&&(s.osPlatform=`${s.osPlatform} (${s.osArch})`,s.osArch=``);let u=(e,t,n,r,i)=>{c(a=>({...a,totalMemory:e,freeMemory:t,heapTotal:n,heapUsed:r,rss:i}))},d=e=>{c(t=>({...t,cpuUsage:e.toFixed(2)+` %`}))},f=e=>{c(t=>({...t,processCpuUsage:e.toFixed(2)+` %`}))},p=(e,t)=>{c(n=>({...n,systemUptime:e,processUptime:t}))},m=()=>{Q&&console.log(`SystemInfoTable handleViewHistory clicked`),o({id:l.current,sender:`Header`,method:`/api/viewhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}})};(0,G.useEffect)(()=>{let e=e=>{Q&&console.log(`SystemInfoTable received WebSocket Message:`,e),e.method===`memory_update`&&e.response&&e.response.totalMemory&&e.response.freeMemory&&e.response.heapTotal&&e.response.heapUsed&&e.response.rss?(Q&&console.log(`SystemInfoTable received memory_update`,e),u(e.response.totalMemory,e.response.freeMemory,e.response.heapTotal,e.response.heapUsed,e.response.rss)):e.method===`cpu_update`&&e.response&&e.response.cpuUsage?(Q&&console.log(`SystemInfoTable received cpu_update`,e),d(e.response.cpuUsage),f(e.response.processCpuUsage)):e.method===`uptime_update`&&e.response&&e.response.systemUptime&&e.response.processUptime?(Q&&console.log(`SystemInfoTable received uptime_update`,e),p(e.response.systemUptime,e.response.processUptime)):e.method===`/api/viewhistorypage`&&e.id===l.current&&e.success===!0&&(Q&&console.log(`SystemInfoTable received /api/viewhistorypage success`),window.open(`./api/viewhistory`,`_blank`,`noopener,noreferrer`))};return r(e,l.current),Q&&console.log(`SystemInfoTable added WebSocket listener id ${l.current}`),()=>{i(e),Q&&console.log(`SystemInfoTable removed WebSocket listener`)}},[r,i]);let[h,g]=(0,G.useState)(!1);return!s||h?null:(Q&&console.log(`SystemInfoTable rendering...`),(0,K.jsxs)(X,{style:$&&n?{flex:`1 1 300px`}:{flex:`0 1 auto`,width:`302px`,minWidth:`302px`},children:[(0,K.jsxs)(Ut,{children:[(0,K.jsx)(Wt,{children:`System info`}),(0,K.jsx)(Yt,{close:()=>g(!0),children:(0,K.jsx)(T,{size:`small`,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},onClick:m,children:(0,K.jsx)(H,{title:`Open the cpu and memory usage page`,arrow:!0,children:(0,K.jsx)(Y.Icon,{path:ht,size:`22px`})})})})]}),(0,K.jsx)(Jt,{style:$&&n?{flex:`1 1 auto`,margin:`0px`,padding:`0px`,gap:`0px`}:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`0px`,gap:`0px`},children:(0,K.jsxs)(`table`,{style:{border:`none`,borderCollapse:`collapse`,tableLayout:`fixed`},children:[(0,K.jsxs)(`colgroup`,{children:[(0,K.jsx)(`col`,{style:{width:`40%`}}),(0,K.jsx)(`col`,{style:{width:`60%`}})]}),(0,K.jsx)(`tbody`,{style:{border:`none`,borderCollapse:`collapse`},children:Object.entries(s).filter(([e,t])=>t!==void 0&&t!==``).map(([e,t],r)=>(0,K.jsxs)(`tr`,{className:r%2==0?`table-content-even`:`table-content-odd`,style:{border:`none`,borderCollapse:`collapse`},children:[(0,K.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`},children:e.replace(`interfaceName`,`Interface name`).replace(`macAddress`,`Mac address`).replace(`ipv4Address`,`IPv4 address`).replace(`ipv6Address`,`IPv6 address`).replace(`nodeVersion`,`Node version`).replace(`hostname`,`Hostname`).replace(`user`,`User`).replace(`osType`,`Os`).replace(`osPlatform`,`Platform`).replace(`freeMemory`,`Memory`).replace(`systemUptime`,`System uptime`).replace(`processUptime`,`Process uptime`).replace(`cpuUsage`,`Host CPU`).replace(`processCpuUsage`,`Process CPU`).replace(`rss`,`Rss`).replace(`heapUsed`,`Heap`)}),(0,K.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:$&&n?typeof t==`string`?t:t.toString():(0,K.jsx)(Ht,{value:typeof t==`string`?t:t.toString(),maxChars:22})})]},e))})]})})]}))}var Zt=(0,G.memo)(Xt),Qt={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`}},$t=e=>{if(!e)return``;let t=e.toString().replace(/[^0-9]/g,``);return t.length<5?t:[t.slice(0,4),t.slice(4,7),t.slice(7,11)].filter(Boolean).join(`-`)};function en({id:e}){let{online:t,sendMessage:n,addListener:r,removeListener:i,getUniqueId:a}=(0,G.useContext)(J),[o,s]=(0,G.useState)(null),c=(0,G.useRef)(null),l=(0,G.useRef)(null),u=(0,G.useRef)(a()),{mobile:d,showConfirmCancelDialog:f}=(0,G.useContext)(It);Q&&console.log(`QRDiv loading with id = "${e}" storeId = "${c.current}" timeout = ${l.current} and matter:`,o),(0,G.useEffect)(()=>{Q&&console.log(`QRDiv id effect "${e}"`),c.current=e,l.current&&clearTimeout(l.current),l.current=null,e?(Q&&console.log(`QRDiv id effect sending data request for storeId "${e}"`),n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:e,server:!0}})):(Q&&console.log(`QRDiv id effect setting matter to null`),s(null))},[e,n]),(0,G.useEffect)(()=>{let e=e=>{Q&&console.log(`QRDiv received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`matter`&&e.response.matter&&(Q&&console.log(`QRDiv received refresh_required: changed=${e.response.changed} for storeId "${e.response.matter.id}":`,e.response.matter),c.current===e.response.matter.id&&(Q&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${e.response.matter.id}":`,e.response.matter),l.current&&clearTimeout(l.current),s(e.response.matter)))};return r(e,u.current),Q&&console.log(`QRDiv webSocket effect mounted`),()=>{i(e),l.current&&clearTimeout(l.current),l.current=null,Q&&console.log(`QRDiv webSocket effect unmounted`)}},[r,i]);let p=()=>{Q&&console.log(`QRDiv sent matter startCommission for node "${o?.id}"`),o&&n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:o.id,startCommission:!0}})},m=()=>{Q&&console.log(`QRDiv sent matter stopCommission for node "${o?.id}"`),o&&n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:o.id,stopCommission:!0}})},h=()=>{Q&&console.log(`QRDiv sent matter advertise for node "${o?.id}"`),o&&n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:o.id,advertise:!0}})},g=e=>{Q&&console.log(`QRDiv sent matter removeFabric for node "${o?.id}" and fabricIndex ${e}`),o&&n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:o.id,removeFabric:e}})};return!o||!t?(Q&&console.log(`QRDiv rendering undefined state`),null):o.online?o.advertising&&o.qrPairingCode&&o.manualPairingCode?(Q&&console.log(`QRDiv rendering advertising state`),(0,K.jsxs)(X,{style:$&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,K.jsxs)(Ut,{children:[(0,K.jsx)(Wt,{children:`QR pairing code`}),(0,K.jsxs)(Yt,{children:[(0,K.jsx)(T,{"aria-label":`send advertising`,size:`small`,onClick:h,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,K.jsx)(H,{title:`Send again the mDNS advertisement`,arrow:!0,children:(0,K.jsx)(Y.Icon,{path:ft,size:`22px`})})}),(0,K.jsx)(T,{"aria-label":`stop pairing`,size:`small`,onClick:m,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,K.jsx)(H,{title:`Turn off pairing`,arrow:!0,children:(0,K.jsx)(Y.Icon,{path:ut,size:`22px`})})})]})]}),(0,K.jsx)(qt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,K.jsx)(bt,{value:o.qrPairingCode,size:256,level:`M`,fgColor:`var(--div-text-color)`,bgColor:`var(--div-bg-color)`,style:{margin:`20px`}}),(0,K.jsxs)(Gt,{style:{justifyContent:`space-between`},children:[(0,K.jsxs)(Kt,{style:{fontWeight:`normal`,color:`var(--div-text-color)`},children:[`Manual pairing code: `,$t(o.manualPairingCode)]}),(0,K.jsx)(Yt,{children:(0,K.jsx)(H,{title:`Copy manual pairing code`,arrow:!0,children:(0,K.jsx)(T,{"aria-label":`copy manual pairing code`,size:`small`,onClick:async()=>{if(!o||!o.manualPairingCode)return;let e=o.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(e);else{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}Q&&console.log(`Manual pairing code copied to clipboard`)}catch(e){console.error(`Failed to copy manual pairing code`,e)}},sx:Qt,children:(0,K.jsx)(Y.Icon,{path:mt,size:.85})})})})]})]})):o.commissioned&&o.fabricInformations&&o.sessionInformations?(Q&&console.log(`QRDiv rendering commissioned state`),(0,K.jsxs)(X,{style:$&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`,overflow:`hidden`},children:[(0,K.jsxs)(Ut,{children:[(0,K.jsx)(Wt,{children:`Paired fabrics`}),(0,K.jsxs)(Yt,{children:[(0,K.jsx)(T,{"aria-label":`send advertising`,size:`small`,onClick:h,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,K.jsx)(H,{title:`Send again the mDNS advertisement`,arrow:!0,children:(0,K.jsx)(Y.Icon,{path:ft,size:`22px`})})}),(0,K.jsx)(T,{"aria-label":`start pairing`,size:`small`,onClick:p,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,K.jsx)(H,{title:`Turn on pairing`,arrow:!0,children:(0,K.jsx)(Y.Icon,{path:_t,size:`22px`})})})]})]}),(0,K.jsx)(qt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,K.jsx)(Jt,{style:{flexDirection:`column`,justifyContent:`flex-start`,flex:`1 1 auto`,overflow:`auto`,padding:`0px 0px 10px 0px`,gap:`0px`},children:o.fabricInformations.map((e,t)=>(0,K.jsxs)(`div`,{style:{margin:`0px`,padding:`10px`,gap:`0px`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`,textAlign:`left`,fontSize:`14px`},children:[(0,K.jsxs)(`div`,{style:{marginLeft:`20px`,marginBottom:`10px`,display:`flex`,flexDirection:`row`,justifyContent:`space-between`,gap:`20px`,alignItems:`center`},children:[(0,K.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: `,e.fabricIndex]}),(0,K.jsx)(H,{title:`Remove the fabric. You will also need to remove it from the controller.`,arrow:!0,children:(0,K.jsx)(T,{"aria-label":`remove the fabric`,size:`small`,onClick:()=>f(`Remove fabric`,`Are you sure you want to remove this fabric? You will also need to remove it from the controller.`,`RemoveFabric`,()=>g(e.fabricIndex),()=>{}),sx:{...Qt,padding:`2px`},children:(0,K.jsx)(Y.Icon,{path:gt,size:1})})})]}),(0,K.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Vendor: `,e.rootVendorId,` `,e.rootVendorName]}),e.label!==``&&(0,K.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Label: `,e.label]}),(0,K.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Sessions: `,o.sessionInformations?o.sessionInformations.filter(t=>t.fabric?.fabricIndex===e.fabricIndex&&t.isPeerActive===!0).length:`0`,` `,`subscriptions: `,o.sessionInformations?o.sessionInformations.filter(t=>t.fabric?.fabricIndex===e.fabricIndex&&t.isPeerActive===!0&&t.numberOfActiveSubscriptions>0).length:`0`]})]},t))}),(0,K.jsx)(Gt,{style:{justifyContent:`center`},children:(0,K.jsxs)(Kt,{style:{fontWeight:`normal`},children:[`Serial number: `,o.serialNumber]})})]})):!o.commissioned&&!o.advertising?(Q&&console.log(`QRDiv rendering not commissioned and not advertising state`),(0,K.jsxs)(X,{style:$&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,K.jsx)(Ut,{children:(0,K.jsx)(Wt,{children:`QR pairing code`})}),(0,K.jsx)(qt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,K.jsx)(L,{onClick:p,endIcon:(0,K.jsx)(Y.Icon,{path:_t,size:1}),style:{margin:`20px`,color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:`Turn on pairing`}),(0,K.jsx)(Gt,{style:{justifyContent:`center`},children:(0,K.jsxs)(Kt,{style:{fontWeight:`normal`},children:[`Serial number: `,o.serialNumber]})})]})):(Q&&console.log(`QRDiv rendering unknown state`),null):(Q&&console.log(`QRDiv rendering offline state`),(0,K.jsxs)(X,{style:$&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,K.jsx)(Ut,{style:{height:`30px`,justifyContent:`space-between`},children:(0,K.jsx)(Wt,{children:`Server node`})}),(0,K.jsx)(qt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,K.jsx)(qt,{style:{fontWeight:`bold`},children:`Server offline`}),(0,K.jsx)(Gt,{style:{justifyContent:`center`},children:(0,K.jsxs)(Kt,{style:{fontWeight:`normal`},children:[`Serial number: `,o.serialNumber]})})]}))}var tn=(0,G.memo)(en);function nn(e){return e?e.scrollWidth>e.clientWidth:!1}function rn({title:e,children:t}){let n=(0,G.useRef)(null),[r,i]=(0,G.useState)(!1);return(0,K.jsx)(H,{title:e,open:r,disableHoverListener:!0,disableFocusListener:!0,disableTouchListener:!0,slotProps:{tooltip:{sx:{fontSize:`14px`,fontWeight:`normal`,color:`#ffffff`,backgroundColor:`var(--primary-color)`}}},children:(0,K.jsx)(`span`,{ref:n,onMouseEnter:()=>{i(nn(n.current))},onMouseLeave:()=>{i(!1)},style:{display:`inline-block`,maxWidth:`100%`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t})})}function an(e,t,n){let r=e?.[n],i=t?.[n];return r==null&&i==null?0:r==null?-1:i==null?1:typeof r==`boolean`&&typeof i==`boolean`?r===i?0:r?1:-1:typeof r==`number`&&typeof i==`number`?r-i:String(r).localeCompare(String(i))}function on({name:e,title:t,columns:n,rows:r,getRowKey:i,footerLeft:a,footerRight:o,onRowClick:s}){let c=(0,G.useRef)(new WeakMap),l=(0,G.useRef)(1),u=t=>{if(typeof i==`string`&&t&&t[i]!=null)return t[i];if(typeof i==`function`){let e=i(t);if(e!=null)return e}let r=n?.[0]?.id;if(r&&t&&t[r]!=null)return t[r];console.warn(`MbfTable(${e}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let a=c.current.get(t);return a||(a=`rk_${l.current++}`,c.current.set(t,a)),a},[f,p]=(0,G.useState)(localStorage.getItem(`${e}_table_order_by`)||null),[m,h]=(0,G.useState)(localStorage.getItem(`${e}_table_order`)||null),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(()=>{try{let t=localStorage.getItem(`${e}_column_visibility`);if(t)return JSON.parse(t)}catch{}return{}}),b=(0,G.useMemo)(()=>{let e={};for(let t of n)t.hidden||(e[t.id]=t.required?!0:v[t.id]!==!1);return e},[n,v]),S=(0,G.useMemo)(()=>{if(!f||!m)return r;let e=n.find(e=>e.id===f);if(!e||e.noSort)return r;let t=r.map((e,t)=>({el:e,index:t}));return t.sort((t,n)=>{let r;return r=typeof e.comparator==`function`?e.comparator(t.el,n.el):an(t.el,n.el,f),r===0?t.index-n.index:m===`asc`?r:-r}),t.map(e=>e.el)},[r,f,m,n]),C=t=>{if(f!==t||!f){p(t),h(`asc`),localStorage.setItem(`${e}_table_order_by`,t),localStorage.setItem(`${e}_table_order`,`asc`);return}if(m===`asc`){h(`desc`),localStorage.setItem(`${e}_table_order`,`desc`);return}p(null),h(null),localStorage.removeItem(`${e}_table_order_by`),localStorage.removeItem(`${e}_table_order`)},w=()=>{_(!g)},E=t=>{y(r=>{let i=n.find(e=>e.id===t);if(i&&i.required)return r;let a=b[t]!==!1,o={...r};a?o[t]=!1:delete o[t];try{localStorage.setItem(`${e}_column_visibility`,JSON.stringify(o))}catch{}return o})},O=()=>{y({});try{localStorage.removeItem(`${e}_column_visibility`)}catch{}_(!1)},[k,A]=(0,G.useState)(!1);return k?null:(Q&&console.log(`Rendering table ${e}${f&&m?` ordered by ${f}:${m}`:``}`),(0,K.jsxs)(`div`,{style:{flex:`1 1 auto`,display:`flex`,flexDirection:`column`,margin:`0`,padding:`0`,gap:`0`,width:`100%`,height:`100%`,overflow:`hidden`},children:[(0,K.jsxs)(D,{open:g,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||w()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[(0,K.jsx)(P,{gap:`20px`,children:(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,K.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,K.jsx)(`h4`,{style:{margin:0},children:`Configure ${e} columns`})]})}),(0,K.jsx)(I,{children:(0,K.jsx)(Le,{children:n.filter(e=>!e.hidden).map(e=>(0,K.jsx)(d,{control:(0,K.jsx)(M,{disabled:!!e.required,checked:e.required?!0:b[e.id]!==!1,onChange:()=>E(e.id)}),label:e.label},e.id))})}),(0,K.jsxs)(x,{children:[(0,K.jsx)(L,{onClick:O,children:`Reset`}),(0,K.jsx)(L,{variant:`contained`,onClick:e=>{if(e?.currentTarget&&typeof e.currentTarget.blur==`function`)try{e.currentTarget.blur()}catch{}let t=document.activeElement;if(t&&t instanceof HTMLElement&&typeof t.blur==`function`)try{t.blur()}catch{}w()},children:`Close`})]})]}),(0,K.jsxs)(Ut,{style:{height:`30px`,minHeight:`30px`,justifyContent:`space-between`,borderBottom:`none`},children:[(0,K.jsx)(Wt,{children:e}),t&&(0,K.jsx)(Wt,{children:t}),(0,K.jsx)(Yt,{close:()=>A(!0),children:(0,K.jsx)(T,{size:`small`,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},onClick:e=>{if(e?.currentTarget?.blur)try{e.currentTarget.blur()}catch{}w()},"aria-label":`Configure Columns`,children:(0,K.jsx)(H,{title:`Configure ${e} columns`,children:(0,K.jsx)(Y.Icon,{path:dt,size:`20px`,color:`var(--header-text-color)`})})})})]}),(0,K.jsx)(Jt,{style:{flex:`1 1 auto`,display:`flex`,flexDirection:`column`,minHeight:0,width:`100%`,overflow:`auto`,margin:`0px`,padding:`0px`,gap:`0`},children:(0,K.jsxs)(`table`,{"aria-label":`${e} table`,style:{width:`100%`,borderCollapse:`collapse`},children:[(0,K.jsx)(`thead`,{style:{position:`sticky`,top:0,zIndex:10,border:`none`,color:`var(--header-text-color)`,backgroundColor:`var(--header-bg-color`},children:(0,K.jsx)(`tr`,{style:{height:`30px`,minHeight:`30px`},children:n.map(e=>{if(e.hidden||!e.required&&b[e.id]===!1)return null;let t=!e.noSort,n=t&&f===e.id&&!!m;return(0,K.jsxs)(`th`,{onClick:t?()=>C(e.id):void 0,style:{margin:`0`,padding:`5px 10px`,position:`sticky`,top:0,minWidth:e.minWidth,maxWidth:e.maxWidth,textAlign:e.align||`left`,cursor:t?`pointer`:`default`,border:`none`,color:`var(--header-text-color)`,backgroundColor:`var(--header-bg-color)`,whiteSpace:e.maxWidth?`nowrap`:void 0,overflow:e.maxWidth?`hidden`:void 0,textOverflow:e.maxWidth?`ellipsis`:void 0},"aria-sort":t?n?m===`asc`?`ascending`:`descending`:`none`:void 0,children:[e.label,n&&(0,K.jsxs)(`span`,{style:{marginLeft:6},children:[m===`asc`&&(0,K.jsx)(Y.Icon,{path:`M19 17H22L18 21L14 17H17V3H19M2 17H12V19H2M6 5V7H2V5M2 11H9V13H2V11Z`,size:`15px`}),m===`desc`&&(0,K.jsx)(Y.Icon,{path:`M19 7H22L18 3L14 7H17V21H19M2 17H12V19H2M6 5V7H2V5M2 11H9V13H2V11Z`,size:`15px`})]})]},e.id)})})}),(0,K.jsx)(`tbody`,{children:S.map((e,t)=>{let r=u(e);return(0,K.jsx)(`tr`,{className:t%2==0?`table-content-even`:`table-content-odd`,onClick:s?t=>s(e,r,t):void 0,style:{height:`30px`,minHeight:`30px`,border:`none`,borderCollapse:`collapse`,cursor:s?`pointer`:void 0},children:n.map(t=>{if(t.hidden||!t.required&&b[t.id]===!1)return null;let n=e[t.id],i=typeof t.render==`function`?t.render(n,r,e,t):typeof n==`boolean`?(0,K.jsx)(M,{checked:n,disabled:!0,size:`small`,sx:{m:0,p:0,color:`var(--table-text-color)`,"&.Mui-disabled":{color:`var(--table-text-color)`,opacity:.7}}}):t.format&&typeof n==`number`?t.format(n):n==null?null:String(n),a=t.tooltip&&t.maxWidth!==void 0&&t.maxWidth!==null&&n!=null&&i!==null?(0,K.jsx)(rn,{title:String(n),children:i}):i;return(0,K.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,textAlign:t.align||`left`,padding:`5px 10px`,margin:`0`,maxWidth:t.maxWidth,whiteSpace:t.maxWidth?`nowrap`:void 0,overflow:t.maxWidth?`hidden`:void 0,textOverflow:t.maxWidth?`ellipsis`:void 0},children:a},t.id)})},r)})})]})}),(a||o)&&(0,K.jsxs)(Gt,{style:{height:`30px`,minHeight:`30px`,justifyContent:`space-between`,border:`none`},children:[(0,K.jsx)(Kt,{style:{fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`},children:a}),(0,K.jsx)(Kt,{style:{fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`},children:o})]})]}))}function sn(e){return(0,G.memo)(e)}var cn=sn(on),ln=e=>e.replace(`git+`,``).replace(`.git`,``).trim(),un=e=>{let t=ln(e);return t.startsWith(`git://`)&&(t=`https://${t.slice(6)}`),t.startsWith(`ssh://git@github.com/`)&&(t=`https://github.com/${t.slice(21)}`),t.startsWith(`git@github.com:`)&&(t=`https://github.com/${t.slice(15).replace(`:`,`/`)}`),t},dn=e=>{if(typeof e==`string`)return e.trim()||null;if(!e||typeof e!=`object`)return null;let t=e.url;return typeof t==`string`&&t.trim()||null},fn=()=>{try{let e=window.localStorage.getItem(q.searchPluginsTotal);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.total==`number`&&typeof t.asOf==`string`&&(n[e]={total:t.total,asOf:t.asOf})}return n}catch{return{}}},pn=e=>{try{window.localStorage.setItem(q.searchPluginsTotal,JSON.stringify(e))}catch{}},mn=()=>{try{let e=window.localStorage.getItem(q.searchPluginsMeta);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.asOf==`string`&&(n[e]={homepage:typeof t.homepage==`string`?t.homepage:null,help:typeof t.help==`string`?t.help:null,changelog:typeof t.changelog==`string`?t.changelog:null,asOf:t.asOf})}return n}catch{return{}}},hn=e=>{try{window.localStorage.setItem(q.searchPluginsMeta,JSON.stringify(e))}catch{}},gn=()=>{try{let e=window.localStorage.getItem(q.searchPluginsVersions);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.asOf==`string`&&Array.isArray(t.versions)&&(n[e]={versions:t.versions.filter(e=>typeof e==`string`),asOf:t.asOf})}return n}catch{return{}}},_n=e=>{try{window.localStorage.setItem(q.searchPluginsVersions,JSON.stringify(e))}catch{}},vn=({open:e,onClose:t,onSelect:n,onVersions:r})=>{let{mobile:i}=(0,G.useContext)(It),[a,o]=(0,G.useState)(``),s=(0,G.useRef)(``),c=(0,G.useRef)(!1),l=(0,G.useRef)(null),[u,d]=(0,G.useState)([]),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)({done:0,total:0}),[b,S]=(0,G.useState)(null),C=(0,G.useRef)({}),w=()=>{let e=document.activeElement;e&&e instanceof HTMLElement&&e.blur()},E=e=>`${e.getFullYear().toString()}-${(e.getMonth()+1).toString().padStart(2,`0`)}-${e.getDate().toString().padStart(2,`0`)}`,O=(0,G.useCallback)(async(e,t)=>{let n=C.current[e];if(n&&n.asOf===t&&Array.isArray(n.versions)&&n.versions.length>0&&n.versions[0]===`latest`)return Q&&console.log(`[SearchPluginsDialog] versions cache hit for ${e} (${n.versions.length.toString()})`),n.versions;n&&n.asOf===t&&n.versions.length>0&&n.versions[0]!==`latest`&&Q&&console.log(`[SearchPluginsDialog] versions cache ignored (old format) for ${e} (asOf=${t})`);let r=`https://registry.npmjs.org/${encodeURIComponent(e)}`;Q&&console.log(`[SearchPluginsDialog] fetching versions for ${e} from: ${r}`);let i=await fetch(r,{signal:l.current?.signal});if(!i.ok)return Q&&console.log(`[SearchPluginsDialog] versions fetch failed for ${e}: ${i.status.toString()} ${i.statusText}`),[];let a=await i.json(),o=Object.keys(a.versions??{}),s=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`});o.sort((e,t)=>s.compare(e,t)).reverse();let c=a[`dist-tags`]??{},u=typeof c?.dev==`string`&&String(c.dev).trim().length>0,d=o.slice(0,20),f=[`latest`];return u&&f.push(`dev`),f.push(...d),Q&&console.log(`[SearchPluginsDialog] fetched versions for ${e} (tags: latest${u?`, dev`:``}; latestVersions=${d.length.toString()}; allVersions=${o.length.toString()}):`,f),C.current[e]={versions:f,asOf:t},_n(C.current),f},[]),k=e=>new Intl.NumberFormat().format(e),A=[{label:`Name`,id:`name`,required:!0,maxWidth:230,tooltip:!0},{label:`Version`,id:`version`,required:!0,maxWidth:110,tooltip:!0},{label:`Monthly`,id:`downloads`,align:`right`,maxWidth:120,render:e=>typeof e==`number`?k(e):``},{label:`Total`,id:`total`,align:`right`,maxWidth:120,render:e=>typeof e==`number`?k(e):``},{label:`Description`,id:`description`,required:!0,maxWidth:300,tooltip:!0},{label:`Author`,id:`author`,maxWidth:140,tooltip:!0},{label:`Action`,id:`action`,align:`center`,maxWidth:100,noSort:!0,required:!0,render:(e,t,n,r)=>(0,K.jsxs)(`div`,{style:{margin:`0`,padding:`0`,gap:`4px`,display:`flex`,flexDirection:`row`,justifyContent:`center`},children:[(0,K.jsx)(H,{title:n.homepage?`Open the plugin homepage`:`No homepage available`,children:(0,K.jsx)(`span`,{children:(0,K.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.homepage,onClick:e=>{if(e.stopPropagation(),n.homepage)try{let e=new URL(n.homepage);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,K.jsx)(xe,{})})})}),(0,K.jsx)(H,{title:n.help?`Open the plugin help`:`No help available`,children:(0,K.jsx)(`span`,{children:(0,K.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.help,onClick:e=>{if(e.stopPropagation(),n.help)try{let e=new URL(n.help);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,K.jsx)(Ne,{})})})}),(0,K.jsx)(H,{title:n.changelog?`Open the plugin changelog`:`No changelog available`,children:(0,K.jsx)(`span`,{children:(0,K.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.changelog,onClick:e=>{if(e.stopPropagation(),n.changelog)try{let e=new URL(n.changelog);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,K.jsx)(Ye,{})})})})]})}];(0,G.useEffect)(()=>{if(!e){c.current=!1,s.current=``,l.current?.abort(),l.current=null,d([]),p(!1),h(!1),_(!1),y({done:0,total:0}),S(null),o(``);return}if(c.current)return;c.current=!0;let t=new AbortController;return l.current=t,C.current=gn(),(async()=>{let e=`matterbridge-`,n=e=>new Promise(t=>setTimeout(t,e)),r=e=>{if(!Array.isArray(e.downloads))return null;let t=0,n=!1;for(let r of e.downloads)typeof r?.downloads==`number`&&(t+=r.downloads,n=!0);return n?t:null};try{p(!0),S(null);let i=e=>{let t=String(e??``).trim().toLowerCase();return t?!!(t===`github actions`||t===`github-actions`||t===`github-actions[bot]`||t.includes(`github-actions`)||t.endsWith(`[bot]`)):!1},a=e=>{let t=(e.maintainers??[]).map(e=>(e.username??``).trim()).filter(Boolean),n=(e.publisher?.username??``).trim();return t.find(e=>!i(e))||(n&&!i(n)?n:t[0]??n??``)},o=await fetch(`https://registry.npmjs.org/-/v1/search?text=matterbridge-&size=250`,{signal:t.signal});if(!o.ok)throw Error(`npm registry request failed: ${o.status} ${o.statusText}`);let s=await o.json(),c=`luligu`,l=e=>e.publisher?.username?.toLowerCase()===c||(e.maintainers??[]).some(e=>e.username?.toLowerCase()===c),u=(s.objects??[]).filter(e=>!!e?.package&&typeof e.package.name==`string`).filter(t=>t.package?.name?.startsWith(e)).filter(e=>!yn.includes(e.package?.name??``)).sort((e,t)=>{let n=l(e.package??{});return n===l(t.package??{})?(e.package?.name??``).localeCompare(t.package?.name??``):n?-1:1}).map(e=>{let t=e.package,n=t.name??``,r=a(t),i=typeof e.downloads?.monthly==`number`?e.downloads.monthly:null,o=(t.links?.npm??``).trim(),s=((t.links?.homepage??``).trim()||o||(n?`https://www.npmjs.com/package/${encodeURIComponent(n)}`:``)).trim()||null;return{name:n,version:t.version??``,downloads:i,total:null,description:t.description??``,author:r,official:l(t),homepage:s,help:null,changelog:null}}),f=E(new Date),m=fn(),h=mn();d(u.map(e=>{let t=m[e.name];return!t||typeof t.total!=`number`?e:(Q&&console.log(`[SearchPluginsDialog] total downloads loaded from cache for ${e.name} (asOf=${t.asOf}):`,t.total),{...e,total:t.total})}).map(e=>{let t=h[e.name];if(!t||t.asOf!==f)return e;let n=t.homepage??e.homepage,r=t.help,i=t.changelog;return Q&&(r||i||n&&n!==e.homepage)&&console.log(`[SearchPluginsDialog] metadata loaded from cache for ${e.name} (asOf=${t.asOf}):`,{homepage:n,help:r,changelog:i}),{...e,homepage:n,help:r,changelog:i}}));let g=u.map(e=>e.name).filter(e=>{let t=C.current[e];return!t||t.asOf!==f||t.versions.length===0});Q&&console.log(`[SearchPluginsDialog] versions prefetch queue (${g.length.toString()}):`,g);let v=0,b=async()=>{for(;v<g.length;){if(t.signal.aborted)return;let e=v;v+=1;let r=g[e];if(r)try{let e=await O(r,f);Q&&e.length>0&&console.log(`[SearchPluginsDialog] versions fetched for ${r} (${e.length.toString()}):`,e.slice(0,5))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return}finally{t.signal.aborted||await n(200)}}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>b()));let x=u.map(e=>e.name).filter(e=>{let t=h[e],n=!!t&&t.asOf===f,r=!!t&&!!t.help&&!!t.changelog,i=!n||!r;return!i&&Q&&console.log(`[SearchPluginsDialog] metadata fetch skipped (cache fresh+complete) for ${e} (asOf=${t.asOf}).`),n&&!r&&Q&&console.log(`[SearchPluginsDialog] metadata fetch forced (cache incomplete) for ${e} (asOf=${t.asOf}).`),i}),w=new Set(x),T=async(e,n)=>{let r=`https://registry.npmjs.org/${encodeURIComponent(e)}/latest`;try{let e=await fetch(r,{signal:t.signal});if(!e.ok)return null;let i=await e.json(),a=typeof i.homepage==`string`&&i.homepage.includes(`http`)?ln(i.homepage):null,o=typeof i.help==`string`&&i.help.startsWith(`http`)?i.help.trim():null,s=typeof i.changelog==`string`&&i.changelog.startsWith(`http`)?i.changelog.trim():null,c=dn(i.repository),l=c?un(c):null,u=l&&l.includes(`http`)?l:null,d=a||u||n||null;return{homepage:d,help:o||(u?`${u}/blob/main/README.md`:null)||d||null,changelog:s||(u?`${u}/blob/main/CHANGELOG.md`:null)||d||null}}catch(e){return e instanceof DOMException&&e.name,null}},D=0,k=async()=>{for(;D<x.length;){if(t.signal.aborted)return;let e=D;D+=1;let r=x[e];if(!r||!w.has(r))continue;w.delete(r);let i=await T(r,u.find(e=>e.name===r)?.homepage??null);if(t.signal.aborted)return;i&&(d(e=>e.map(e=>e.name===r?{...e,homepage:i.homepage??e.homepage,help:i.help,changelog:i.changelog}:e)),h[r]={homepage:i.homepage,help:i.help,changelog:i.changelog,asOf:f},hn(h)),t.signal.aborted||await n(250)}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>k()));let A=`2020-01-01`,j=u.map(e=>e.name).filter(e=>{let t=m[e],n=!t||t.asOf!==f;return n||Q&&console.log(`[SearchPluginsDialog] total downloads fetch skipped (cache fresh) for ${e} (asOf=${t.asOf}).`),n}),M=new Set(j),ee=j.length;y({done:0,total:ee}),_(ee>0);let N=async e=>{let i=`https://api.npmjs.org/downloads/range/${A}:${f}/${encodeURIComponent(e)}`;for(let e=0;e<3;e+=1){let a=await fetch(i,{signal:t.signal});if(a.ok)return r(await a.json());if(a.status===404)return null;if(a.status===429){let t=a.headers.get(`retry-after`),r=t?Number(t):NaN;await n(Number.isFinite(r)?r*1e3:2e3*(e+1));continue}return null}return null},te=0,P=0,ne=async()=>{for(;te<j.length;){if(t.signal.aborted)return;let e=te;te+=1;let r=j[e];if(r&&M.has(r)){M.delete(r);try{Q&&console.log(`[SearchPluginsDialog] fetching total downloads for ${r} (range ${A}:${f})...`);let e=await N(r);if(t.signal.aborted)return;Q&&console.log(`[SearchPluginsDialog] total downloads fetched for ${r}:`,e),d(t=>t.map(t=>t.name===r?{...t,total:e}:t)),typeof e==`number`&&(m[r]={total:e,asOf:f},pn(m),Q&&console.log(`[SearchPluginsDialog] total downloads saved to localStorage for ${r} (asOf=${f}):`,e))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return}finally{P+=1,y({done:P,total:ee}),t.signal.aborted||await n(500)}}}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>ne())).finally(()=>{t.signal.aborted||_(!1)}),Q&&console.log(`[SearchPluginsDialog] npm packages starting with "${e}" (filtered/sorted):`,u)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;console.error(`[SearchPluginsDialog] npm registry fetch error:`,e),S(e instanceof Error?e.message:String(e))}finally{p(!1)}})(),()=>t.abort()},[e,O]);let j=async()=>{w();let e=s.current||a;if(!(!e||m))try{h(!0);let t=await O(e,E(new Date));Q&&console.log(`[SearchPluginsDialog] passing versions to onVersions() for ${e} (${t.length.toString()}):`,t),r(t),h(!1),n(e)}catch(t){if(t instanceof DOMException&&t.name===`AbortError`)return;console.error(`[SearchPluginsDialog] npm versions fetch error:`,t),r([]),h(!1),n(e)}},M=()=>{w(),t(),r([])},ee=u.reduce((e,t)=>e+(typeof t.downloads==`number`?t.downloads:0),0),N=u.reduce((e,t)=>(typeof t.total==`number`&&(e.total+=t.total,e.hasAny=!0),e),{total:0,hasAny:!1}),te=g?` Totals: ${v.done.toString()}/${v.total.toString()} fetched`:``,ne=N.hasAny?k(N.total):`...`;return(0,K.jsxs)(D,{open:e,onClose:()=>{w(),t()},maxWidth:!1,fullWidth:!0,slotProps:{paper:{sx:{width:$&&i?`100vw`:`75vw`,height:$&&i?`100vh`:`75vh`,maxWidth:$&&i?`100vw`:`75vw`,maxHeight:$&&i?`100vh`:`75vh`,margin:$&&i?`0px`:void 0,display:`flex`,flexDirection:`column`}}},children:[(0,K.jsx)(P,{children:(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,K.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,K.jsx)(`h4`,{style:{margin:0},children:`Search Plugins`})]})}),(0,K.jsx)(I,{dividers:!0,sx:{padding:`10px`,flex:`1 1 auto`,minHeight:0},children:(0,K.jsx)(`div`,{style:{height:`100%`,width:`100%`,display:`flex`,flexDirection:`column`,minHeight:0},children:f?(0,K.jsx)(`div`,{style:{padding:`20px`},children:`Loading npm registry...`}):b?(0,K.jsx)(`div`,{style:{padding:`20px`},children:b}):(0,K.jsx)(cn,{name:`Search plugins`,rows:u,columns:A,getRowKey:`name`,onRowClick:(e,t,n)=>{s.current=e.name,o(e.name),n.detail===2&&j()},footerLeft:`Total packages: ${u.length.toString()} Total downloads: ${k(ee)} / ${ne}${te}`,footerRight:a?`Selected: ${a}`:``})})}),(0,K.jsxs)(x,{sx:{justifyContent:`center`,gap:1.5,flexWrap:`wrap`},children:[(0,K.jsx)(H,{title:`Select the plugin and close the dialog. Double-click a row to select and close the dialog.`,children:(0,K.jsx)(L,{variant:`contained`,onClick:j,disabled:!(s.current||a)||m,children:`Select`})}),(0,K.jsx)(H,{title:`Close the dialog without selecting a plugin.`,children:(0,K.jsx)(L,{onClick:M,children:`Cancel`})})]})]})},yn=[`matterbridge-`,`matterbridge-plugin-template`,`matterbridge-dyson`,`matterbridge-tuya`,`matterbridge-matter`,`matterbridge-automations`,`matterbridge-securitysystem`,`matterbridge-adapter`];function bn(){let{mobile:e,showSnackbarMessage:t}=(0,G.useContext)(It),{logMessage:n,sendMessage:r,getUniqueId:i}=(0,G.useContext)(J),[a,o]=(0,G.useState)(`matterbridge-`),[s,c]=(0,G.useState)([`latest`,`dev`]),[l,u]=(0,G.useState)(`latest`),[d,f]=(0,G.useState)(!1),p=(0,G.useRef)(i()),m=e=>{let t=String(e??``).trim();if(!t)return{name:``,specifier:null};if(t.startsWith(`@`)){let e=t.lastIndexOf(`@`);if(e>0){let n=t.slice(0,e),r=t.slice(e+1);if(n.includes(`/`)&&r)return{name:n,specifier:r}}return{name:t,specifier:null}}let n=t.indexOf(`@`);if(n>0){let e=t.slice(0,n),r=t.slice(n+1);return r?{name:e,specifier:r}:{name:e,specifier:null}}return{name:t,specifier:null}},h=()=>{let{name:e,specifier:t}=m(a);return e?t?`${e}@${t}`:l?`${e}@${l}`:e:``},g=e=>{e.preventDefault(),f(!0)},_=()=>{f(!1)},v=e=>{e.preventDefault(),f(!1);let t=e.dataTransfer.files[0];if(t){n(`Plugins`,`Installing package ${t.name}. Please wait...`);let e=new FormData;e.append(`file`,t),e.append(`filename`,t.name),fetch(`./api/uploadpackage`,{method:`POST`,body:e}).then(e=>e.text()).then(e=>{n(`Plugins`,`Server response: ${e}`)}).catch(e=>{console.error(`Error uploading plugin file:`,e),n(`Plugins`,`Error installing package ${e}`)})}},y=e=>{let t=e.target.files&&e.target.files[0];if(t){n(`Plugins`,`Uploading package ${t.name}`);let e=new FormData;e.append(`file`,t),e.append(`filename`,t.name),fetch(`./api/uploadpackage`,{method:`POST`,body:e}).then(e=>e.text()).then(e=>{n(`Plugins`,`Server response: ${e}`)}).catch(e=>{console.error(`Error uploading plugin file:`,e),n(`Plugins`,`Error uploading package ${e}`)})}},b=()=>{let e=h();if(e){if(yn.includes(e.split(`@`)[0])){t(`Installation of plugin "${e}" is blocked by the ignore list.`);return}r({id:p.current,sender:`InstallPlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e,restart:!1}})}},x=()=>{r({id:p.current,sender:`InstallPlugins`,method:`/api/uninstall`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:a}})},S=()=>{document.getElementById(`file-upload`)?.click()},C=()=>{if(yn.includes(a.split(`@`)[0])){t(`Addition of plugin "${a}" is blocked by the ignore list.`);return}r({id:p.current,sender:`InstallPlugins`,method:`/api/addplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginNameOrPath:a}})},w=e=>{e.preventDefault(),Q&&console.log(`Right-clicked Upload button`)},E=e=>{e.preventDefault(),Q&&console.log(`Right-clicked Add button`)},[D,O]=(0,G.useState)(!1),k=()=>{O(!0),Q&&console.log(`Dialog opened for selection`)},A=()=>{o(`matterbridge-`),O(!1),Q&&console.log(`Dialog closed without selection`)},j=e=>{o(e),O(!1),Q&&console.log(`Select plugin:`,e)},M=e=>{c(e),u(e.includes(`latest`)?`latest`:e[0]??``),Q&&console.log(`Select plugin versions:`,e)},[ee,N]=(0,G.useState)(!1);return Q&&console.log(`HomeInstallAddPlugins rendering...`),ee?null:(0,K.jsxs)(X,{children:[(0,K.jsxs)(Ut,{children:[(0,K.jsx)(Wt,{children:`Install plugins`}),(0,K.jsx)(Yt,{close:()=>N(!0)})]}),(0,K.jsxs)(Jt,{onDragOver:g,onDragLeave:_,onDrop:v,style:$&&e?{flexWrap:`wrap`,alignItems:`center`,gap:`10px`}:{flexWrap:`wrap`,alignItems:`center`,gap:`20px`},children:[(0,K.jsx)(vn,{open:D,onClose:A,onSelect:j,onVersions:M}),(0,K.jsxs)(`div`,{style:{flex:`1 1 auto`,display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,K.jsx)(H,{title:`Provide the npm name or the local path of the plugin to install, uninstall, or add`,children:(0,K.jsx)(B,{value:a,onChange:e=>{let t=e.target.value;c([`latest`,`dev`]),u(`latest`),o(t)},size:`small`,id:`plugin-name`,label:`Plugin name or plugin path`,variant:`outlined`,fullWidth:!0})}),s.length>0&&(0,K.jsx)(H,{title:`Select the npm tag/version to install`,children:(0,K.jsx)(`span`,{children:(0,K.jsxs)(Fe,{size:`small`,style:{minWidth:`150px`},children:[(0,K.jsx)(le,{id:`plugin-version-label`,children:`Tag or version`}),(0,K.jsx)(ye,{labelId:`plugin-version-label`,id:`plugin-version`,value:l,label:`Tag or version`,onChange:e=>u(String(e.target.value??``)),sx:{"& .MuiSelect-icon":{color:`var(--main-label-color)`}},children:s.map(e=>(0,K.jsx)(V,{value:e,children:e},e))})]})})}),(0,K.jsx)(H,{title:`Search on npm the plugin to install`,children:(0,K.jsx)(T,{size:`large`,onClick:k,children:(0,K.jsx)(Ge,{fontSize:`inherit`})})})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,K.jsx)(H,{title:`Install or update a plugin from npm`,children:(0,K.jsxs)(L,{onClick:b,endIcon:(0,K.jsx)(tt,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Install`]})}),(0,K.jsx)(H,{title:`Uninstall and remove a plugin`,children:(0,K.jsxs)(L,{onClick:x,endIcon:(0,K.jsx)(Ze,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Uninstall`]})}),(0,K.jsx)(H,{title:`Upload and install a plugin from a tarball`,children:(0,K.jsxs)(L,{onClick:S,onContextMenu:w,endIcon:(0,K.jsx)(ze,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Upload`]})}),(0,K.jsx)(H,{title:`Add an already installed plugin or a plugin from a local path`,children:(0,K.jsxs)(L,{onClick:C,onContextMenu:E,endIcon:(0,K.jsx)(we,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Add`]})}),(0,K.jsx)(`input`,{id:`file-upload`,type:`file`,accept:`.tgz`,style:{display:`none`},onChange:y})]})]})]})}var xn=(0,G.memo)(bn);function Sn({status:e,enabledText:t=`Enabled`,disabledText:n=void 0,tooltipText:r=void 0,onClick:i}){if(e===void 0)return null;{let a=(0,K.jsx)(`div`,{className:e?`status-enabled`:`status-disabled`,style:{cursor:`default`},onClick:i,children:e?t:n??t});return r===void 0?a:(0,K.jsx)(H,{title:r,children:a})}}function Cn(e){return e.id!==0&&e.src===`Matterbridge`&&e.dst===`Frontend`}var wn={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},Tn={fontSize:`12px`,fontWeight:`normal`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},En={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},Dn={fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`,backgroundColor:`var(--div-bg-color)`},On={fontSize:`16px`,fontWeight:`bold`,backgroundColor:`var(--div-bg-color)`},kn={padding:`0px`,margin:`0px`},An=`5px 10px 5px 10px`,jn={},Mn={},Nn={},Pn={},Fn=[],In=[];function Ln(e,t){let n=e?.properties;if(!n||typeof n!=`object`)return!1;let r=n[t];return!r||typeof r!=`object`?!1:typeof r.type==`string`}function Rn(e){let t=e.items;return t!==void 0&&typeof t==`object`&&!Array.isArray(t)}function zn(e,t){let n=e?.properties;if(!n||typeof n!=`object`)return!1;let r=n[t];if(!r||typeof r!=`object`||r.type!==`array`||r.uniqueItems!==!0)return!1;let i=r.items;return i!==void 0&&typeof i==`object`&&!Array.isArray(i)&&Array.isArray(i.enum)}var Bn=({open:e,onClose:t,plugin:n})=>{let{sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(J),s=(0,G.useRef)(o()),c=(0,G.useRef)({}),l=(0,G.useRef)({}),[u,d]=(0,G.useState)(n.configJson),[m,g]=(0,G.useState)(n.schemaJson),[_,v]=(0,G.useState)({"ui:submitButtonOptions":{submitText:`Confirm`},"ui:globalOptions":{orderable:!0}}),y=(0,G.useRef)(``),b=n.configJson;(0,G.useEffect)(()=>{let e=e=>{e.src===`Matterbridge`&&e.dst===`Frontend`&&(Cn(e)&&e.id===s.current&&e.method===`/api/select/devices`&&e.response&&(Q&&console.log(`ConfigPluginDialog (id: ${e.id}) received ${e.response.length} /api/select/devices:`,e.response),Fn=e.response),Cn(e)&&e.id===s.current&&e.method===`/api/select/entities`&&e.response&&(Q&&console.log(`ConfigPluginDialog (id: ${e.id}) received ${e.response.length} /api/select/entities:`,e.response),In=e.response))};if(i(e,s.current),Q&&console.log(`ConfigPluginDialog added WebSocket listener id:`,s.current),Q&&console.log(`ConfigPluginDialog mounting...`),Q&&console.log(`ConfigPluginDialog mounting with form:`,u),Q&&console.log(`ConfigPluginDialog mounting with schema:`,m),Q&&console.log(`ConfigPluginDialog mounting with uiSchema:`,_),u&&m&&m.properties){let e=(t,n,r=[])=>{!t||typeof t!=`object`||(t.properties&&Object.keys(t.properties).forEach(i=>{let a=t.properties?.[i],o=[...r,i];Object.keys(a).forEach(e=>{if(e.startsWith(`ui:`)){let t=n;o.forEach(e=>{t[e]||(t[e]={}),t=t[e]}),t[e]=a[e],delete a[e]}}),e(a,n,o)}),[`oneOf`,`anyOf`,`allOf`].forEach(i=>{Array.isArray(t[i])&&t[i].forEach(t=>{e(t,n,r)})}),t.items&&typeof t.items==`object`&&e(t.items,n,r))};e(m,_),v(_),c.current=m,l.current=_}return n.name&&n.configJson&&n.schemaJson&&(d(n.configJson),g(n.schemaJson),r({id:s.current,sender:`ConfigPlugin`,method:`/api/select/devices`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name}}),r({id:s.current,sender:`ConfigPlugin`,method:`/api/select/entities`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name}}),Q&&console.log(`HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:`,n.name)),()=>{a(e),Q&&console.log(`ConfigPluginDialog removed WebSocket listener`)}},[i,u,n,a,m,r,_]);let C=(e,t)=>{b=e.formData},E=e=>{Q&&console.log(`ConfigPluginDialog handleSaveChanges:`,e.formData),d(e.formData),n.configJson=e.formData,n.restartRequired=!0,r({id:s.current,sender:`ConfigPlugin`,method:`/api/savepluginconfig`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.formData.name,formData:e.formData}}),t()};function A(e){let{id:t,label:n,onKeyRenameBlur:r,onRemoveProperty:i,disabled:a,schema:o,children:s,registry:c,readonly:l,required:u}=e,{templates:d}=c,{RemoveButton:f}=d.ButtonTemplates,p=wt in o,m=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let e=y.current;!p||e===``||!/^newKey(?:-\d+)?$/.test(n)||!m.current||(Q&&console.log(`WrapIfAdditionalTemplate: renaming additional property "${n}" to "${e}"`),m.current.value=e,r({target:m.current}),y.current=``)},[p,n,r]),p?(0,K.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,flexGrow:1,padding:0,margin:0,border:`none`},children:[(0,K.jsx)(B,{id:`${t}-key`,name:`${t}-key`,required:u,disabled:a||l,defaultValue:n,inputRef:m,onBlur:l?void 0:r,type:`text`,variant:`outlined`,sx:{width:`250px`,minWidth:`250px`,maxWidth:`250px`,marginRight:`20px`}}),(0,K.jsx)(W,{sx:{flex:1},children:s}),(0,K.jsx)(f,{disabled:a||l,onClick:i,registry:c})]}):(0,K.jsx)(W,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:s})}function j(e){let{children:t,description:n,displayLabel:r,errors:i,help:a,hidden:o,registry:s,uiSchema:c}=e,l=Ct(`WrapIfAdditionalTemplate`,s,St(c));return o?(0,K.jsx)(`div`,{style:{display:`none`},children:t}):(0,K.jsx)(W,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:(0,K.jsxs)(l,{...e,children:[r===!0&&n,t,i,a]})})}function ee(e){let{description:t}=e;return t?(0,K.jsx)(p,{sx:Tn,children:t}):null}function N(e){let{required:t,title:n}=e;return n?(0,K.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,K.jsxs)(p,{sx:wn,children:[`Title `,n,` `,t&&(0,K.jsx)(`mark`,{children:`***`})]})}):null}function te(e){let{help:t}=e;return t?(0,K.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,K.jsx)(p,{sx:Dn,children:t})}):null}function ne(e){let{errors:t}=e;return t?(0,K.jsxs)(W,{sx:{padding:`10px`,margin:`10px`,border:`1px solid grey`},children:[(0,K.jsx)(p,{color:`error`,sx:On,children:`Please fix the following errors:`}),(0,K.jsx)(at,{children:t.map((e,t)=>(0,K.jsxs)(se,{children:[(0,K.jsx)(U,{children:(0,K.jsx)(fe,{color:`error`})}),(0,K.jsx)(z,{primary:e.stack})]},t))})]}):null}function F(e){let{errors:t}=e;return t?(0,K.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:t.map((e,t)=>(0,K.jsxs)(p,{color:`error`,variant:`body2`,sx:{marginLeft:1},children:[`This field `,e]},t))}):null}function re(e){let{id:t,name:n,_schema:r,_uiSchema:i,value:a,options:o,label:s,type:c,placeholder:l,required:u,disabled:d,readonly:f,autofocus:p,onChange:m,onChangeOverride:h,onBlur:g,onFocus:_,_rawErrors:v,_hideError:y,_registry:b,_formContext:x}=e;return(0,K.jsx)(W,{sx:{padding:`0px`,margin:`0px`},children:(0,K.jsx)(B,{id:t,name:t,label:l&&l!==``?s:void 0,variant:`outlined`,placeholder:l&&l!==``?l:s,required:u,disabled:d||f,autoFocus:p,value:a||a===0?a:``,type:c,autoComplete:c===`password`?`current-password`:n,onChange:h||(({target:{value:e}})=>m(e===``?o.emptyValue:e)),onBlur:({target:e})=>g(t,e&&e.value),onFocus:({target:e})=>_(t,e&&e.value),fullWidth:!0})})}function ie(e){return console.log(`ArrayFieldTitleTemplate:`,e),null}function ae(e){return console.log(`ArrayFieldDescriptionTemplate:`,e),null}function oe(e){let{buttonsProps:t,children:n}=e;return(0,K.jsxs)(W,{sx:{margin:`2px 0px`,padding:`0px`,display:`flex`,alignItems:`center`},children:[(0,K.jsx)(W,{sx:{flexGrow:1,marginRight:`10px`},children:n}),(0,K.jsx)(T,{disabled:!t.hasMoveUp,onClick:t.onMoveUpItem,size:`small`,color:`primary`,sx:kn,children:(0,K.jsx)(ue,{})}),(0,K.jsx)(T,{disabled:!t.hasMoveDown,onClick:t.onMoveDownItem,size:`small`,color:`primary`,sx:kn,children:(0,K.jsx)(w,{})}),t.hasRemove&&(0,K.jsx)(T,{onClick:t.onRemoveItem,size:`small`,color:`primary`,sx:kn,children:(0,K.jsx)(O,{})})]})}function ce(e){let{canAdd:t,onAddClick:n,schema:r,title:i,formData:a}=e,[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),[m,g]=(0,G.useState)(``),_=e=>{g(e.target.value)},v=()=>{Q&&console.log(`ArrayFieldTemplate: handleDialogDeviceToggle filter:`,m,`selectDevices:`,Fn),s(!o)},y=()=>{Q&&console.log(`ArrayFieldTemplate: handleDialogEntityToggle filter:`,m,`selectEntities:`,In),l(!c)},b=()=>{Q&&console.log(`ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:`,m,`selectDevices:`,Fn),d(!u)},C=e=>{s(!1),r.selectFrom===`serial`&&Rn(r)?r.items.default=e.serial:r.selectFrom===`name`&&Rn(r)&&(r.items.default=e.name),n()},w=e=>{l(!1),r.selectEntityFrom===`name`&&Rn(r)?r.items.default=e.name:r.selectEntityFrom===`description`&&Rn(r)&&(r.items.default=e.description),n()},E=e=>{d(!1),r.selectDeviceEntityFrom===`name`&&Rn(r)?r.items.default=e.name:r.selectDeviceEntityFrom===`description`&&Rn(r)&&(r.items.default=e.description),n()};return(0,K.jsxs)(W,{sx:{margin:`0px`,padding:`5px 10px 5px 10px`,border:`1px solid grey`},children:[i&&(0,K.jsxs)(W,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[i&&(0,K.jsx)(p,{sx:wn,children:i}),t&&(0,K.jsxs)(W,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[r.selectFrom&&(0,K.jsx)(H,{title:`Add a device from the list`,children:(0,K.jsx)(T,{onClick:v,size:`small`,color:`primary`,sx:kn,children:(0,K.jsx)(qe,{})})}),r.selectEntityFrom&&(0,K.jsx)(H,{title:`Add an entity from the list`,children:(0,K.jsx)(T,{onClick:y,size:`small`,color:`primary`,sx:kn,children:(0,K.jsx)(qe,{})})}),r.selectDeviceEntityFrom&&(0,K.jsx)(H,{title:`Add a device entity from the list`,children:(0,K.jsx)(T,{onClick:b,size:`small`,color:`primary`,sx:kn,children:(0,K.jsx)(qe,{})})}),(0,K.jsx)(H,{title:`Add a new item`,children:(0,K.jsx)(T,{onClick:n,size:`small`,color:`primary`,sx:kn,children:(0,K.jsx)(we,{})})})]})]}),r.description&&(0,K.jsx)(p,{sx:Tn,children:r.description}),e.items,(0,K.jsxs)(D,{open:o,onClose:v,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,K.jsx)(P,{children:`Select a device`}),(0,K.jsxs)(I,{children:[(0,K.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,K.jsx)(p,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,K.jsx)(B,{fullWidth:!0,variant:`outlined`,value:m,onChange:_,placeholder:`Enter serial or name`})]}),(0,K.jsx)(at,{dense:!0,children:Fn.filter(e=>e.serial.toLowerCase().includes(m.toLowerCase())||e.name.toLowerCase().includes(m.toLowerCase())).filter(e=>!r.uniqueItems||!a.includes(r.selectFrom===`serial`?e.serial:e.name)).map((e,t)=>(0,K.jsxs)(h,{onClick:()=>C(e),sx:jn,children:[e.icon===`wifi`&&(0,K.jsx)(U,{children:(0,K.jsx)(k,{style:Mn})}),e.icon===`ble`&&(0,K.jsx)(U,{children:(0,K.jsx)(S,{style:Mn})}),e.icon===`hub`&&(0,K.jsx)(U,{children:(0,K.jsx)(me,{style:Mn})}),(0,K.jsx)(z,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:Nn},secondaryTypographyProps:{style:Pn}})]},t))})]}),(0,K.jsx)(x,{children:(0,K.jsx)(L,{onClick:v,children:`Close`})})]}),(0,K.jsxs)(D,{open:c,onClose:y,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,K.jsx)(P,{children:`Select an entity`}),(0,K.jsxs)(I,{children:[(0,K.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,K.jsx)(p,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,K.jsx)(B,{fullWidth:!0,variant:`outlined`,value:m,onChange:_,placeholder:`Enter name or description`})]}),(0,K.jsx)(at,{dense:!0,children:In.filter(e=>e.name.toLowerCase().includes(m.toLowerCase())||e.description.toLowerCase().includes(m.toLowerCase())).filter(e=>!r.uniqueItems||!a.includes(r.selectEntityFrom===`name`?e.name:e.description)).map((e,t)=>(0,K.jsxs)(h,{onClick:()=>w(e),sx:jn,children:[e.icon===`wifi`&&(0,K.jsx)(U,{children:(0,K.jsx)(k,{style:Mn})}),e.icon===`ble`&&(0,K.jsx)(U,{children:(0,K.jsx)(S,{style:Mn})}),e.icon===`hub`&&(0,K.jsx)(U,{children:(0,K.jsx)(me,{style:Mn})}),e.icon===`component`&&(0,K.jsx)(U,{children:(0,K.jsx)(f,{style:Mn})}),e.icon===`matter`&&(0,K.jsx)(U,{children:(0,K.jsx)(lt,{style:Mn})}),(0,K.jsx)(z,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:Nn},secondaryTypographyProps:{style:Pn}})]},t))})]}),(0,K.jsx)(x,{children:(0,K.jsx)(L,{onClick:y,children:`Close`})})]}),(0,K.jsxs)(D,{open:u,onClose:b,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,K.jsxs)(P,{children:[`Select an entity for `,i]}),(0,K.jsx)(I,{children:(0,K.jsx)(at,{dense:!0,children:Fn.filter(e=>e.serial===i||e.name===i).map(e=>e.entities?.filter(e=>!r.uniqueItems||!Array.isArray(a)||!a.includes(r.selectDeviceEntityFrom===`name`?e.name:e.description)).map((e,t)=>(0,K.jsxs)(h,{onClick:()=>E(e),sx:jn,children:[e.icon===`wifi`&&(0,K.jsx)(U,{children:(0,K.jsx)(k,{style:Mn})}),e.icon===`ble`&&(0,K.jsx)(U,{children:(0,K.jsx)(S,{style:Mn})}),e.icon===`hub`&&(0,K.jsx)(U,{children:(0,K.jsx)(me,{style:Mn})}),e.icon===`component`&&(0,K.jsx)(U,{children:(0,K.jsx)(f,{style:Mn})}),e.icon===`matter`&&(0,K.jsx)(U,{children:(0,K.jsx)(lt,{style:Mn})}),(0,K.jsx)(z,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:Nn},secondaryTypographyProps:{style:Pn}})]},t)))})}),(0,K.jsx)(x,{children:(0,K.jsx)(L,{onClick:b,children:`Close`})})]})]})}function le(e){let{onAddProperty:t,schema:n,properties:r,title:i,description:a}=e,[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(``),u=e=>{l(e.target.value)},d=()=>{s(!o)},f=e=>{Q&&console.log(`ObjectFieldTemplate: handleSelectValue value "${e.serial}" for schema "${n.selectFrom}"`),s(!1);let r=``;n.selectFrom===`serial`?r=e.serial:n.selectFrom===`name`&&(r=e.name),y.current=r,Q&&console.log(`ObjectFieldTemplate: handleSelectValue pendingAdditionalPropertyKey "${r}"`),t()},m=()=>{t()},g=!n.additionalProperties;return Q&&console.log(`ObjectFieldTemplate: isRoot ${g} pendingAdditionalPropertyKey "${y.current}"`),(0,K.jsxs)(W,{sx:{margin:`0px`,padding:g?`10px`:`5px 10px 0px 10px`,border:g?`none`:`1px solid grey`},children:[n.title&&g&&(0,K.jsx)(W,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,K.jsx)(p,{sx:wn,children:n.title})}),i&&!g&&(0,K.jsxs)(W,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[(0,K.jsx)(p,{sx:wn,children:i}),(0,K.jsxs)(W,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[n.selectFrom&&(0,K.jsx)(H,{title:`Add a device from the list`,children:(0,K.jsx)(T,{onClick:d,size:`small`,color:`primary`,sx:kn,children:(0,K.jsx)(qe,{})})}),(0,K.jsx)(H,{title:`Add a new item`,children:(0,K.jsx)(T,{onClick:m,size:`small`,color:`primary`,sx:kn,children:(0,K.jsx)(we,{})})})]})]}),n.description&&(0,K.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,K.jsx)(p,{sx:Tn,children:n.description})}),r.map(({content:e,name:t,hidden:r})=>{if(r)return null;let i=Ln(n,t),a=zn(n,t),o=i&&[`object`,`array`].includes(n.properties[t].type);return(0,K.jsxs)(W,{sx:{margin:`0px`,marginBottom:`10px`,padding:o&&!a?`0px`:An,border:o&&!a?`none`:`1px solid grey`},children:[i&&![`object`,`array`,`boolean`].includes(n.properties[t].type)&&(0,K.jsx)(p,{sx:wn,children:n.properties[t].title||t}),a&&(0,K.jsx)(p,{sx:wn,children:n.properties[t].title||t}),(0,K.jsx)(W,{sx:{flexGrow:1,padding:`0px`,margin:`0px`},children:e})]},t)}),(0,K.jsxs)(D,{open:o,onClose:d,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,K.jsx)(P,{children:`Select a device`}),(0,K.jsxs)(I,{children:[(0,K.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,K.jsx)(p,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,K.jsx)(B,{fullWidth:!0,variant:`outlined`,value:c,onChange:u,placeholder:`Enter serial or name`})]}),(0,K.jsx)(at,{dense:!0,children:Fn.filter(e=>e.serial.toLowerCase().includes(c.toLowerCase())||e.name.toLowerCase().includes(c.toLowerCase())).map((e,t)=>(0,K.jsxs)(h,{onClick:()=>f(e),sx:jn,children:[e.icon===`wifi`&&(0,K.jsx)(U,{children:(0,K.jsx)(k,{style:Mn})}),e.icon===`ble`&&(0,K.jsx)(U,{children:(0,K.jsx)(S,{style:Mn})}),e.icon===`hub`&&(0,K.jsx)(U,{children:(0,K.jsx)(me,{style:Mn})}),(0,K.jsx)(z,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:Nn},secondaryTypographyProps:{style:Pn}})]},t))})]}),(0,K.jsx)(x,{children:(0,K.jsx)(L,{onClick:d,children:`Close`})})]})]})}function de(e){let{uiSchema:n}=e,{submitText:r,norender:i}=xt(n);return i?null:(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,margin:`10px`,padding:`0px`,gap:`20px`},children:[(0,K.jsx)(L,{type:`submit`,variant:`contained`,color:`primary`,children:r}),(0,K.jsx)(L,{variant:`contained`,color:`primary`,onClick:t,children:`Cancel`})]})}function pe(e){let{className:t,disabled:n,onClick:r,registry:i,style:a,uiSchema:o,...s}=e;return(0,K.jsx)(H,{title:`Remove the item`,children:(0,K.jsx)(T,{disabled:n,size:`small`,color:`primary`,onClick:r,children:(0,K.jsx)(O,{})})})}function R(e){let{className:t,disabled:n,onClick:r,registry:i,uiSchema:a,...o}=e;return(0,K.jsx)(H,{title:`Add an item`,children:(0,K.jsx)(T,{size:`small`,color:`primary`,onClick:r,children:(0,K.jsx)(we,{})})})}function he(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,K.jsx)(H,{title:`Move up the item`,children:(0,K.jsx)(T,{size:`small`,color:`primary`,onClick:n,children:(0,K.jsx)(ue,{})})})}function ge(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,K.jsx)(H,{title:`Move down the item`,children:(0,K.jsx)(T,{size:`small`,color:`primary`,onClick:n,children:(0,K.jsx)(w,{})})})}function _e(e){let{id:i,name:a,value:o,schema:c,readonly:l,onChange:d}=e,[f,m]=(0,G.useState)(),h=e=>{Q&&console.log(`CheckboxWidget ${a} onChangeField:`,e),m(e&&e!==``?e:void 0)},g=()=>{Q&&console.log(`CheckboxWidget onClick plugin="${n.name}" action="${a}" value="${f}"`),r({id:s.current,sender:`ConfigPlugin`,method:`/api/action`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name,action:a,value:f,formData:b,id:i}}),c.buttonClose===!0?t():c.buttonSave===!0&&E({formData:u})};return c.buttonText&&(c.title||c.description)?(0,K.jsxs)(W,{sx:{margin:`0px`,padding:`5px 0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,K.jsx)(p,{sx:En,children:c.title||c.description}),(0,K.jsx)(L,{variant:`contained`,color:`primary`,onClick:()=>g(),children:c.buttonText})]}):c.buttonField&&(c.title||c.description)?(0,K.jsxs)(W,{sx:{margin:`0px`,padding:`5px 0px`,gap:`20px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,K.jsx)(p,{sx:En,children:c.title||c.description}),(0,K.jsx)(B,{id:a+`-input`,name:a,label:c.textLabel,placeholder:c.textPlaceholder,onChange:e=>h(e.target.value),sx:{width:`250px`,minWidth:`250px`,maxWidth:`250px`}}),(0,K.jsx)(L,{id:a+`-button`,variant:`contained`,color:`primary`,disabled:f===void 0,onClick:()=>g(),children:c.buttonField})]}):(0,K.jsxs)(W,{sx:{margin:`0px`,padding:`0px`},children:[a&&(0,K.jsxs)(W,{sx:{margin:`0px`,padding:`0px`,gap:`10px`,display:`flex`,justifyContent:`flex-start`,alignItems:`center`},children:[(0,K.jsx)(p,{sx:wn,children:c.title||a}),(0,K.jsx)(M,{checked:o,readOnly:l,onChange:()=>d(!o),sx:{padding:`0px`,margin:`0px`}})]}),c.description&&(0,K.jsx)(p,{sx:Tn,children:c.description})]})}function ve({schema:e,id:t,name:n,options:r,label:i,hideLabel:a,required:o,disabled:s,placeholder:c,readonly:l,value:u,multiple:d,autofocus:f,onChange:p,onBlur:m,onFocus:h,errorSchema:g,rawErrors:_=[],registry:v,uiSchema:y,hideError:b,...x}){let{enumOptions:S,enumDisabled:C,emptyValue:w}=r;d=d===void 0?!1:!!d;let T=d?[]:``,E=u===void 0||d&&u.length<1||!d&&u===T,D=({target:{value:e}})=>p(Ot(e,S,w)),O=({target:e})=>m(t,Ot(e&&e.value,S,w)),k=({target:e})=>h(t,Ot(e&&e.value,S,w)),A=Et(u,S,d);return(0,K.jsx)(B,{id:t,name:n,value:!E&&A!==void 0?A:T,required:o,disabled:s||l,autoFocus:f,error:_.length>0,onChange:D,onBlur:O,onFocus:k,select:!0,slotProps:{select:{multiple:d,...d?{renderValue:e=>!Array.isArray(e)||!Array.isArray(S)?``:e.map(e=>S[Number(e)]?.label).filter(e=>typeof e==`string`).join(`, `)}:{}}},"aria-describedby":Dt(t),children:Array.isArray(S)&&S.map(({value:e,label:t},n)=>{let r=Array.isArray(C)&&C.indexOf(e)!==-1,i=Array.isArray(A)&&A.includes(String(n));return(0,K.jsxs)(V,{value:String(n),disabled:r,children:[d&&(0,K.jsx)(U,{sx:{minWidth:`32px`},children:(0,K.jsx)(M,{checked:i,disableRipple:!0,tabIndex:-1,sx:{padding:`0px`,margin:`0px`}})}),t]},n)})})}return Q&&console.log(`ConfigPluginDialog rendering...`),!e||!m||!u?null:(0,K.jsxs)(D,{open:e,onClose:t,slotProps:{paper:{sx:{maxWidth:`800px`}}},children:[(0,K.jsx)(P,{gap:`20px`,children:(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,K.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,K.jsx)(`h3`,{children:`Matterbridge plugin configuration`})]})}),(0,K.jsx)(I,{style:{padding:`0px`,margin:`0px`,width:`800px`,height:`600px`,overflow:`auto`},children:(0,K.jsx)(kt,{schema:m,formData:u,uiSchema:_,validator:Tt,templates:{FieldTemplate:j,BaseInputTemplate:re,TitleFieldTemplate:N,DescriptionFieldTemplate:ee,FieldHelpTemplate:te,FieldErrorTemplate:F,ErrorListTemplate:ne,WrapIfAdditionalTemplate:A,ArrayFieldTitleTemplate:ie,ArrayFieldDescriptionTemplate:ae,ArrayFieldItemTemplate:oe,ArrayFieldTemplate:ce,ObjectFieldTemplate:le,ButtonTemplates:{SubmitButton:de,RemoveButton:pe,AddButton:R,MoveUpButton:he,MoveDownButton:ge}},widgets:{CheckboxWidget:_e,SelectWidget:ve},onChange:C,onSubmit:E})})]})};function Vn(e){if(Q&&console.log(`getQRColor (id: ${e?.id}) received matter:`,e??`undefined`),e===void 0||!e.online||!e.qrPairingCode&&!e.manualPairingCode&&!e.fabricInformations&&!e.sessionInformations)return`red`;if(e.commissioned===!1&&e.qrPairingCode&&e.manualPairingCode)return`var(--primary-color)`;let t=0,n=0;for(let r of e.sessionInformations??[])r.fabric&&r.isPeerActive===!0&&t++,r.numberOfActiveSubscriptions>0&&(n+=r.numberOfActiveSubscriptions);return e.commissioned===!0&&e.fabricInformations&&e.sessionInformations&&(t===0||n===0)?`var(--secondary-color)`:`var(--div-text-color)`}function Hn({storeId:e,setStoreId:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(J),{mobile:s,showConfirmCancelDialog:c}=(0,G.useContext)(It),u=(0,G.useRef)(o()),[d,f]=(0,G.useState)(null),[p,m]=(0,G.useState)(null),[h,g]=(0,G.useState)([]),[_,v]=(0,G.useState)(null),y=[{label:`Name`,id:`name`,required:!0,render:(e,t,n,r)=>(0,K.jsx)(H,{title:`Plugin path ${n.path}`,children:(0,K.jsx)(`span`,{style:{cursor:`pointer`},onClick:()=>M(n),children:n.name})})},{label:`Description`,id:`description`,render:(e,t,n,r)=>(0,K.jsx)(H,{title:`Open the plugin homepage`,children:(0,K.jsx)(`span`,{style:{cursor:`pointer`},onClick:()=>M(n),children:n.description})})},{label:`Version`,id:`version`,render:(e,t,n,r)=>(0,K.jsx)(K.Fragment,{children:(0,K.jsx)(H,{title:`Plugin v.${n.version}`,children:(0,K.jsx)(`span`,{children:n.version.split(`-`)[0]+(n.version.includes(`-dev-`)?`@dev`:``)+(n.version.includes(`-git-`)?`@git`:``)})})})},{label:`Author`,id:`author`,render:(e,t,n,r)=>(0,K.jsx)(K.Fragment,{children:n.author?n.author.replace(`https://github.com/`,``):`Unknown`})},{label:`Type`,id:`type`,render:(e,t,n,r)=>(0,K.jsx)(K.Fragment,{children:n.type?n.type.replace(`Platform`,``):`Unknown`})},{label:`Devices`,id:`registeredDevices`},{label:`Actions`,id:`actions`,required:!0,noSort:!0,render:(e,n,r,i)=>(0,K.jsxs)(`div`,{style:{margin:`0px`,padding:`0px`,gap:`4px`,display:`flex`,flexDirection:`row`},children:[p&&p.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,K.jsx)(H,{title:`Shows the QRCode or the fabrics`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,K.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:Vn(r.matter)},onClick:()=>{r.matter?.id&&t(r.matter?.id)},size:`small`,children:(0,K.jsx)(l,{})})}),p&&p.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,K.jsx)(H,{title:`Restart the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,K.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`},onClick:()=>A(r),size:`small`,children:(0,K.jsx)(_e,{})})}),(0,K.jsx)(H,{title:`Plugin config`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,K.jsx)(T,{disabled:r.restartRequired===!0,style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>se(r),size:`small`,children:(0,K.jsx)(ie,{})})}),p&&!p.readOnly&&(0,K.jsx)(H,{title:`Remove the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,K.jsx)(T,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{S(`Remove plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`remove`,r)},size:`small`,children:(0,K.jsx)(Ze,{})})}),r.enabled?(0,K.jsx)(H,{title:`Disable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,K.jsx)(T,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{S(`Disable plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`disable`,r)},size:`small`,children:(0,K.jsx)(De,{})})}):(0,K.jsx)(K.Fragment,{}),r.enabled?(0,K.jsx)(K.Fragment,{}):(0,K.jsx)(H,{title:`Enable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,K.jsx)(T,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>j(r),size:`small`,children:(0,K.jsx)($e,{})})}),(0,K.jsx)(H,{title:`Open the plugin help`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,K.jsx)(T,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>N(r),size:`small`,children:(0,K.jsx)(Ne,{})})}),(0,K.jsx)(H,{title:`Open the plugin version history`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,K.jsx)(T,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>te(r),size:`small`,children:(0,K.jsx)(Ye,{})})}),r.enabled&&r.frontendPath&&(0,K.jsx)(H,{title:`Open the plugin frontend`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,K.jsx)(T,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>P(r),size:`small`,children:(0,K.jsx)(ge,{})})}),r.latestVersion!==void 0&&r.latestVersion!==r.version&&p&&!p.readOnly&&(0,K.jsx)(H,{title:`Update the plugin to the latest version v.${r.latestVersion}`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,K.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>E(r),size:`small`,children:(0,K.jsx)(he,{})})}),(r.version.includes(`-dev-`)||r.version.includes(`-git-`))&&r.devVersion!==void 0&&r.devVersion!==r.version&&p&&!p.readOnly&&(0,K.jsx)(H,{title:`Update the plugin to the latest dev version v.${r.devVersion}`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,K.jsx)(T,{style:{color:`var(--secondary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>O(r),size:`small`,children:(0,K.jsx)(he,{})})}),p&&!p.readOnly&&(0,K.jsx)(H,{title:`Sponsor the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,K.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`#b6409c`},onClick:()=>ee(r),size:`small`,children:(0,K.jsx)(Ue,{})})})]})},{label:`Status`,id:`status`,required:!0,noSort:!0,render:(e,t,n,r)=>(0,K.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,flex:`1 1 auto`,margin:`0`,padding:`0`,gap:`5px`,width:`auto`,maxWidth:`max-content`},children:n.error?(0,K.jsx)(K.Fragment,{children:(0,K.jsx)(Sn,{status:!1,enabledText:`Error`,disabledText:`Error`,tooltipText:`The plugin is in error state. Check the log!`})}):(0,K.jsx)(K.Fragment,{children:n.enabled===!1?(0,K.jsx)(K.Fragment,{children:(0,K.jsx)(Sn,{status:n.enabled,enabledText:`Enabled`,disabledText:`Disabled`,tooltipText:`Whether the plugin is enable or disabled`})}):(0,K.jsx)(K.Fragment,{children:n.loaded&&n.started&&n.configured?(0,K.jsx)(K.Fragment,{children:(0,K.jsx)(Sn,{status:n.loaded,enabledText:`Running`,tooltipText:`Whether the plugin is running`})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sn,{status:n.loaded,enabledText:`Loaded`,tooltipText:`Whether the plugin has been loaded`}),(0,K.jsx)(Sn,{status:n.started,enabledText:`Started`,tooltipText:`Whether the plugin started`}),(0,K.jsx)(Sn,{status:n.configured,enabledText:`Configured`,tooltipText:`Whether the plugin has been configured`})]})})})})}];(0,G.useEffect)(()=>{let e=e=>{Q&&console.log(`HomePlugins received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`plugins`?e.response.lock?(Q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} lock=${e.response.lock} and locking plugins list`),g(t=>t.map(t=>t.name===e.response.lock?{...t,restartRequired:!0}:t))):(Q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} lock=${e.response.lock} and sending /api/plugins request`),r({id:u.current,sender:`HomePlugins`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`refresh_required`&&e.response.changed===`matter`?(Q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and setting matter id ${e.response.matter?.id}`),g(t=>{let n=t.findIndex(t=>t.matter?.id===e.response.matter?.id);if(n<0)return Q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and matter id ${e.response.matter?.id} not found`),t;Q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} set matter id ${e.response.matter?.id}`);let r=[...t];return r[n]={...r[n],matter:e.response.matter},r})):e.method===`refresh_required`&&e.response.changed===`settings`&&(Q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and sending /api/settings request`),r({id:u.current,sender:`HomePlugins`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})),e.id===u.current&&e.method===`/api/settings`?(Q&&console.log(`HomePlugins (id: ${e.id}) received settings:`,e.response),f(e.response.systemInformation),m(e.response.matterbridgeInformation)):e.id===u.current&&e.method===`/api/plugins`&&(Q&&console.log(`HomePlugins (id: ${e.id}) received ${e.response.length} plugins:`,e.response),g(e.response))};return i(e,u.current),Q&&console.log(`HomePlugins added WebSocket listener id:`,u.current),()=>{a(e),Q&&console.log(`HomePlugins removed WebSocket listener`)}},[i,a,r]),(0,G.useEffect)(()=>{n&&(Q&&console.log(`HomePlugins sending api requests`),r({id:u.current,sender:`HomePlugins`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:u.current,sender:`HomePlugins`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[n,r]);let b=(0,G.useRef)(null),S=(e,t,n,r)=>{Q&&console.log(`handleActionWithConfirmCancel ${n} ${r.name}`),b.current=r,c(e,t,n,C,w)},C=e=>{Q&&console.log(`handleConfirm action confirmed ${e} ${b.current?.name}`),e===`remove`&&b.current?k(b.current):e===`disable`&&b.current&&j(b.current),b.current=null},w=e=>{Q&&console.log(`handleCancel action canceled ${e} ${b.current?.name}`),b.current=null},E=e=>{Q&&console.log(`handleUpdatePlugin plugin:`,e.name),r({id:u.current,sender:`HomePlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e.name,restart:!1}})},O=e=>{Q&&console.log(`handleUpdateDevPlugin plugin:`,e.name),r({id:u.current,sender:`HomePlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e.name+`@dev`,restart:!1}})},k=e=>{Q&&console.log(`handleRemovePlugin plugin:`,e.name),r({id:u.current,sender:`HomePlugins`,method:`/api/removeplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},A=e=>{Q&&console.log(`handleRestartPlugin plugin:`,e.name),r({id:u.current,sender:`HomePlugins`,method:`/api/restartplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},j=e=>{Q&&console.log(`handleEnableDisablePlugin plugin:`,e.name,`enabled:`,e.enabled),e.enabled===!0?(e.enabled=!1,r({id:u.current,sender:`HomePlugins`,method:`/api/disableplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})):(e.enabled=!0,r({id:u.current,sender:`HomePlugins`,method:`/api/enableplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}}))},M=e=>{Q&&console.log(`handleHomepagePlugin plugin: ${e.name} homepage: ${e.homepage}`),e.homepage&&window.open(e.homepage,`_blank`)},ee=e=>{Q&&console.log(`handleSponsorPlugin plugin:`,e.name,`funding:`,e.funding),e.funding&&window.open(e.funding,`_blank`)},N=e=>{Q&&console.log(`handleHelpPlugin plugin:`,e.name,`help:`,e.help),e.help&&window.open(e.help,`_blank`)},te=e=>{Q&&console.log(`handleChangelogPlugin plugin:`,e.name,`changelog:`,e.changelog),e.changelog&&window.open(e.changelog,`_blank`)},P=e=>{let t=`/plugins/${e.name}`;Q&&console.log(`handleFrontendPlugin plugin:`,e.name,`frontend:`,e.frontendPath,`path:`,t),e.frontendPath&&v({name:e.name,path:t})},ne=e=>{let t=e.currentTarget.contentDocument;if(!t?.head)return;let n=getComputedStyle(document.body),r=n.getPropertyValue(`--primary-color`).trim()||`#0d6efd`,i=n.getPropertyValue(`--div-bg-color`).trim()||`#111111`;t.getElementById(`matterbridge-plugin-scrollbar-style`)?.remove();let a=t.createElement(`style`);a.id=`matterbridge-plugin-scrollbar-style`,a.textContent=`
|
|
1
|
+
import{a as e}from"./rolldown-runtime.js";import{c as t}from"./vendor_emotion.js";import{c as n,d as r,l as i,o as a,p as o,s,u as c}from"./vendor_node_modules.js";import{$ as l,A as u,At as d,B as f,Bt as p,C as m,Ct as h,D as g,Dt as _,E as v,Et as y,F as b,Ft as x,G as S,Gt as C,H as w,Ht as T,I as E,It as D,J as O,K as k,Kt as A,L as j,Lt as M,M as N,Mt as P,N as ee,Nt as F,O as te,Ot as I,P as ne,Pt as re,Q as ie,R as ae,Rt as L,S as oe,St as se,T as ce,Tt as le,U as ue,Ut as de,V as fe,Vt as pe,W as me,Wt as he,X as ge,Y as _e,Z as R,_ as ve,_t as ye,a as be,at as xe,b as Se,bt as z,c as Ce,ct as we,d as Te,dt as Ee,et as De,f as Oe,ft as B,g as ke,gt as V,h as Ae,ht as je,i as Me,it as Ne,j as Pe,jt as Fe,k as Ie,kt as Le,l as Re,lt as ze,m as Be,mt as Ve,n as He,nt as Ue,o as We,ot as Ge,p as Ke,pt as H,q as qe,r as Je,rt as Ye,s as Xe,st as Ze,t as Qe,tt as $e,u as et,ut as tt,v as nt,vt as rt,w as it,wt as at,x as ot,xt as U,y as st,yt as ct,z as lt,zt as W}from"./vendor_mui.js";import{c as ut,g as dt,i as ft,o as pt,s as mt,t as ht,v as gt,y as _t}from"./vendor_mdi.js";import{n as vt,t as yt}from"./vendor_notistack.js";import{a as bt,c as xt,i as St,l as Ct,n as wt,o as Tt,r as Et,s as Dt,t as Ot}from"./vendor_rjsf.js";import{t as kt}from"./vendor_qrcode.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var G=e(t(),1),At=e(o(),1),K={enableMobile:`enableMobile`,devicesFilterPlugins:`devicesFilterPlugins`,devicesFilterDevices:`devicesFilterDevices`,devicesViewMode:`devicesViewMode`,frontendVersion:`frontendVersion`,matterbridgeVersion:`matterbridgeVersion`,homePageMode:`homePageMode`,logFilterLevel:`logFilterLevel`,logFilterSearch:`logFilterSearch`,logAutoScroll:`logAutoScroll`,logLength:`logLength`,frontendTheme:`frontendTheme`,homePagePlugins:`homePagePlugins`,virtualMode:`virtualMode`,installAutoExit:`installAutoExit`,searchPluginsTotal:`searchPluginsTotal`,searchPluginsMeta:`searchPluginsMeta`,searchPluginsVersions:`searchPluginsVersions`},jt={Devices_table_order_by:`Devices_table_order_by`,Devices_table_order:`Devices_table_order`,Devices_column_visibility:`Devices_column_visibility`,Plugins_table_order_by:`Plugins_table_order_by`,Plugins_table_order:`Plugins_table_order`,Plugins_column_visibility:`Plugins_column_visibility`,"Registered devices_table_order_by":`Registered devices_table_order_by`,"Registered devices_table_order":`Registered devices_table_order`,"Registered devices_column_visibility":`Registered devices_column_visibility`,Clusters_table_order_by:`Clusters_table_order_by`,Clusters_table_order:`Clusters_table_order`,Clusters_column_visibility:`Clusters_column_visibility`};function Mt(){Object.values(K).forEach(e=>{localStorage.removeItem(e)}),Object.values(jt).forEach(e=>{localStorage.removeItem(e)})}var q=!1,Nt=()=>{q=!q},J=localStorage.getItem(K.enableMobile)!==`false`,Pt=()=>{J=!0,localStorage.setItem(K.enableMobile,`true`)},Ft=()=>{J=!1,localStorage.setItem(K.enableMobile,`false`)},It=void 0,Lt=e=>{It=e},Rt=!1,zt=e=>{Rt=e},Y=A();function Bt(e){return(0,Y.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,viewBox:`0 0 296.2 296.2`,...e,children:[(0,Y.jsxs)(`defs`,{children:[(0,Y.jsxs)(`linearGradient`,{id:`lg1`,x1:`16.6`,y1:`16.6`,x2:`279.6`,y2:`279.6`,gradientUnits:`userSpaceOnUse`,children:[(0,Y.jsx)(`stop`,{offset:`0`,stopColor:`#00b48d`}),(0,Y.jsx)(`stop`,{offset:`.1`,stopColor:`#3faa77`}),(0,Y.jsx)(`stop`,{offset:`.3`,stopColor:`#234148`}),(0,Y.jsx)(`stop`,{offset:`.7`,stopColor:`#203b44`}),(0,Y.jsx)(`stop`,{offset:`.9`,stopColor:`#ad2e6e`}),(0,Y.jsx)(`stop`,{offset:`1`,stopColor:`#c81b74`})]}),(0,Y.jsxs)(`linearGradient`,{id:`lg2`,x1:`31.1`,y1:`31.1`,x2:`265.1`,y2:`265.1`,gradientUnits:`userSpaceOnUse`,children:[(0,Y.jsx)(`stop`,{offset:`0`,stopColor:`#00b48d`}),(0,Y.jsx)(`stop`,{offset:`.2`,stopColor:`#285251`}),(0,Y.jsx)(`stop`,{offset:`.4`,stopColor:`#234148`}),(0,Y.jsx)(`stop`,{offset:`.8`,stopColor:`#203b44`}),(0,Y.jsx)(`stop`,{offset:`.9`,stopColor:`#a8316c`}),(0,Y.jsx)(`stop`,{offset:`1`,stopColor:`#c81b74`})]}),(0,Y.jsxs)(`linearGradient`,{id:`lg3`,x1:`116.2`,y1:`143.9`,x2:`139.8`,y2:`143.9`,gradientUnits:`userSpaceOnUse`,children:[(0,Y.jsx)(`stop`,{offset:`0`,stopColor:`#8bc751`}),(0,Y.jsx)(`stop`,{offset:`1`,stopColor:`#0db14b`})]}),(0,Y.jsx)(`linearGradient`,{id:`lg4`,x1:`136.1`,y1:`100.8`,x2:`159.6`,y2:`100.8`,xlinkHref:`#lg3`}),(0,Y.jsx)(`linearGradient`,{id:`lg5`,x1:`155.3`,y1:`143.9`,x2:`178.9`,y2:`143.9`,xlinkHref:`#lg3`}),(0,Y.jsxs)(`linearGradient`,{id:`lg6`,x1:`46.8`,y1:`25.7`,x2:`89.6`,y2:`74.8`,gradientUnits:`userSpaceOnUse`,children:[(0,Y.jsx)(`stop`,{offset:`0`,stopColor:`#b1d34a`}),(0,Y.jsx)(`stop`,{offset:`1`,stopColor:`#50b848`})]})]}),(0,Y.jsx)(`rect`,{width:`296.2`,height:`296.2`,rx:`56.7`,ry:`56.7`,style:{fill:`url(#lg1)`}}),(0,Y.jsx)(`rect`,{x:`16.3`,y:`16.3`,width:`263.6`,height:`263.6`,rx:`50.5`,ry:`50.5`,style:{fill:`url(#lg2)`}}),(0,Y.jsx)(`circle`,{cx:`128`,cy:`143.9`,r:`11.8`,style:{fill:`url(#lg3)`}}),(0,Y.jsx)(`circle`,{cx:`147.8`,cy:`100.8`,r:`11.8`,style:{fill:`url(#lg4)`}}),(0,Y.jsx)(`path`,{d:`m244.6 114.5.4-.5L160 33a17 17 0 0 0-24.7-.5l-86.4 83.3a15 15 0 0 0 9.2 26.9h19.3v-4.7l-13.7-12.7v-.1l83.7-80.8 84.2 81-13.9 12.8v4.5h19.5a15 15 0 0 0 7.4-28.1Z`,style:{fill:`url(#lg3)`}}),(0,Y.jsx)(`circle`,{cx:`167.1`,cy:`143.9`,r:`11.8`,style:{fill:`url(#lg5)`}}),(0,Y.jsx)(`path`,{fill:`#fff`,d:`M219 89.3V35.5a10.5 10.5 0 1 0-21 0v33.7l21 20Z`}),(0,Y.jsx)(`path`,{d:`M91.4 73.3H83a37 37 0 0 0-14.5-28.4L65 50.2c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.8-7.8-16-23.7-11.9-46 8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2Z`,style:{fill:`url(#lg6)`}}),(0,Y.jsx)(`path`,{d:`M65.9 80a49.6 49.6 0 0 0 17.8 2.2l16.6-16c1.6-8.3.5-15.7-3.3-22.4C84.6 22 47.8 17.5 46.2 17.4l-3-.4-.6 3c-3.8 18.4-5.9 50.6 23.2 60ZM48.4 24.4c8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2H83a37 37 0 0 0-14.5-28.4l-3.7 5.3c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.9-7.8-16-23.7-11.9-46Z`,fill:`#1e5857`}),(0,Y.jsx)(`path`,{fill:`#fff`,d:`M250.5 90.5a17.4 17.4 0 1 1 0-34.8 17.4 17.4 0 0 1 0 34.8Zm0-22.7a5.4 5.4 0 0 0 0 10.7 5.3 5.3 0 0 0 0-10.7ZM258.8 148.2a15.9 15.9 0 0 0-9.6 28.5c-.8 4.2-5.4 4.6-5.4 4.6h-26v-43l13.6-13-1.8-2-82.2-79-81.2 78.3-2.5 2.6 13.7 13v42.9H53a21.5 21.5 0 1 0 11.7 15h12.6v18.8c0 7.8 6.4 14.1 14.1 14.1h29.3v14.8H64a10.6 10.6 0 0 0-17.7 8 10.6 10.6 0 0 0 17.6 8h157.6a16.3 16.3 0 1 0 0-16h-84.8V229h66.8c7.8 0 14.2-6.3 14.2-14.1v-19.2h27.6c14.3 0 17.8-12.8 18.5-16.6a15.9 15.9 0 0 0-5-30.9ZM43.7 210.8a10.3 10.3 0 1 1 0-20.6 10.3 10.3 0 0 1 0 20.6Zm192 36a5 5 0 1 1 0 10 5 5 0 0 1 0-10Zm-77-34.8h-22v-34h22v34Zm8.4-79.8c2.7 0 5.2 1 7.2 2.5v-10.4L188 137s2.6 1.3 4.6 1.3h6.7v68c0 3.2-2.6 5.7-5.7 5.7h-19v-34h1.4a7.5 7.5 0 0 0 0-15H120a7.5 7.5 0 0 0 0 15h.7v34h-19.3a5.7 5.7 0 0 1-5.7-5.6v-68.1h6.7c2 0 4.6-1.3 4.6-1.3l13.7-12.7v10.4a11.7 11.7 0 0 1 16 1.6v-13a14.9 14.9 0 0 0-25-10.8s-.1.2-.1.2l-.5.5-6.9 7H92.5l55-53.2 55.1 53.2h-11.8l-7-7c0-.2-.2-.3-.4-.5l-.2-.2a14.8 14.8 0 0 0-25 10.9v12.9c2.2-2.5 5.3-4.1 8.9-4.1Zm91.7 36.7a4.9 4.9 0 1 1 0-9.7 4.9 4.9 0 0 1 0 9.7Z`})]})}var Vt=(0,G.createContext)(null),Ht=(0,G.createContext)(null),X=(0,G.createContext)(null);function Ut({children:e}){let[t,n]=(0,G.useState)([]),[r,i]=(0,G.useState)(localStorage.getItem(K.logFilterLevel)??`info`),[a,o]=(0,G.useState)(localStorage.getItem(K.logFilterSearch)??`*`),[s,c]=(0,G.useState)(!1),{showSnackbarMessage:l,closeSnackbarMessage:u,closeSnackbar:d,showInstallProgress:f,hideInstallProgress:p,exitInstallProgressSuccess:m,exitInstallProgressError:h,addInstallProgress:g}=(0,G.useContext)(Vt),_=(0,G.useRef)([]),v=(0,G.useRef)(null),y=(0,G.useRef)(1),b=(0,G.useRef)(Math.floor(Math.random()*999e3)+1e3),x=(0,G.useRef)(null),S=(0,G.useRef)(null),C=(0,G.useRef)(null),w=(0,G.useRef)(r),T=(0,G.useRef)(a),E=(0,G.useRef)(0),D=(0,G.useRef)(null),O=(0,G.useRef)(Number(localStorage.getItem(K.logLength)??200)),k=(0,G.useRef)(localStorage.getItem(K.logAutoScroll)!==`false`),A=(0,G.useMemo)(()=>window.location.href.replace(/^http/,`ws`),[]);(0,G.useEffect)(()=>(q&&console.log(`WebSocket messages started counter interval`),D.current=setInterval(()=>{E.current>0&&(q&&console.log(`WebSocket messages received in the last 10 seconds: ${E.current*(60/10)} messages/minute`),E.current=0)},10*1e3),()=>{q&&console.log(`WebSocket messages stopped counter interval`),D.current&&clearInterval(D.current),D.current=null}),[]),(0,G.useEffect)(()=>{w.current=r},[r]),(0,G.useEffect)(()=>{T.current=a},[a]);let j=(0,G.useCallback)(()=>Math.floor(Math.random()*999e3)+1e3,[]),M=(0,G.useCallback)((e,t)=>{q&&console.log(`WebSocket filterLogMessages called with level "${e}" and search "${t}"...`),n(n=>n.filter(n=>!([`debug`,`info`,`notice`,`warn`,`error`,`fatal`].includes(n.level)&&(e===`info`&&n.level===`debug`||e===`notice`&&(n.level===`debug`||n.level===`info`)||e===`warn`&&(n.level===`debug`||n.level===`info`||n.level===`notice`)||e===`error`&&(n.level===`debug`||n.level===`info`||n.level===`notice`||n.level===`warn`)||e===`fatal`&&(n.level===`debug`||n.level===`info`||n.level===`notice`||n.level===`warn`||n.level===`error`))||t!==`*`&&t!==``&&!t.startsWith(`/`)&&!t.endsWith(`/`)&&!n.message.toLowerCase().includes(t.toLowerCase())&&!n.name.toLowerCase().includes(t.toLowerCase())||t.startsWith(`/`)&&t.endsWith(`/`)&&(()=>{try{let e=new RegExp(t.slice(1,-1),`i`);return!e.test(n.message)&&!e.test(n.name)}catch(e){return console.error(`WebSocket log search invalid regex filter "${t}":`,e),!1}})())))},[]),N=(0,G.useCallback)(e=>{if(v.current&&v.current.readyState===WebSocket.OPEN)try{q&&console.log(`WebSocket sending message with id ${e.id}:`,e),e.id===void 0&&(e.id=b.current);let t=JSON.stringify(e);v.current.send(t),q&&console.log(`WebSocket sent message:`,e)}catch(e){q&&console.error(`WebSocket error sending message: ${String(e)}`)}else q&&console.error(`WebSocket message not sent, WebSocket not connected:`,e)},[]),P=(0,G.useCallback)((e,t)=>{n(n=>[...n,{level:e,time:``,name:``,message:t}])},[]),ee=(0,G.useCallback)((e,t)=>{q&&console.log(`WebSocket addListener id ${t}:`,e),(t==null||Number.isNaN(t)||t===0)&&console.error(`WebSocket addListener called without id, listener not added:`,e),_.current=[..._.current,{listener:e,id:t}],q&&console.log(`WebSocket addListener total listeners:`,_.current.length)},[]),F=(0,G.useCallback)(e=>{q&&console.log(`WebSocket removeListener:`,e),_.current=_.current.filter(t=>t.listener!==e),q&&console.log(`WebSocket removeListener total listeners:`,_.current.length)},[]),te=(0,G.useCallback)(()=>{A===``||A==null||(P(`WebSocket`,`Connecting ${It?`with password`:``} to WebSocket: ${A}`),q&&console.log(`WebSocket connecting to: ${A}${It?`?password=[redacted]`:``}`),v.current=new WebSocket(A+(It?`?password=${encodeURIComponent(It)}`:``)),v.current.onmessage=e=>{s||c(!0),E.current+=1;try{let t=JSON.parse(e.data);if(t.id===void 0||t.src===void 0||t.dst===void 0){q&&console.error(`WebSocket undefined message id/src/dst:`,t);return}if(t.src!==`Matterbridge`||t.dst!==`Frontend`){q&&console.error(`WebSocket invalid message src/dst:`,t);return}if(t.error){q&&console.error(`WebSocket error message response:`,t);return}if(t.id===b.current&&t.method===`pong`&&t.response===`pong`){q&&console.log(`WebSocket pong response message id ${t.id}:`,t),S.current&&clearTimeout(S.current),S.current=null;return}else if(t.method===`snackbar`&&t.response&&t.response.message){q&&console.log(`WebSocket message id ${t.id} method ${t.method}:`,t),l(t.response.message,t.response.timeout,t.response.severity);return}else if(t.method===`close_snackbar`&&t.response&&t.response.message){q&&console.log(`WebSocket message id ${t.id} method ${t.method}:`,t),u(t.response.message);return}else if(t.method===`log`){if(!t.response||!t.response.level||!t.response.time||!t.response.name||!t.response.message||(t.response.level===`spawn`&&(t.response.name===`Matterbridge:spawn-init`?f(t.response.message,``,``):t.response.name===`Matterbridge:spawn-exit-success`?m():t.response.name===`Matterbridge:spawn-exit-error`?h():g(t.response.message+`
|
|
2
|
+
`)),[`debug`,`info`,`notice`,`warn`,`error`,`fatal`].includes(t.response.level)&&(w.current===`info`&&t.response.level===`debug`||w.current===`notice`&&(t.response.level===`debug`||t.response.level===`info`)||w.current===`warn`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`)||w.current===`error`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`||t.response.level===`warn`)||w.current===`fatal`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`||t.response.level===`warn`||t.response.level===`error`)))||T.current!==`*`&&T.current!==``&&!T.current.startsWith(`/`)&&!T.current.endsWith(`/`)&&!t.response.message.toLowerCase().includes(T.current.toLowerCase())&&!t.response.name.toLowerCase().includes(T.current.toLowerCase())||T.current.startsWith(`/`)&&T.current.endsWith(`/`)&&(()=>{try{let e=new RegExp(T.current.slice(1,-1),`i`);return!e.test(t.response.message)&&!e.test(t.response.name)}catch(e){return console.error(`WebSocket log search invalid regex filter "${T.current}":`,e),!1}})()||t.response.name===`Commissioning`&&t.response.message.includes(`is uncommissioned`))return;n(e=>{let n=[...e,{level:t.response.level,time:t.response.time,name:t.response.name,message:t.response.message}];return q&&console.log(`WebSocket new log message added (${n.length}/${O.current}):`,n[n.length-1]),n.length>O.current+O.current*10/100?(q&&console.log(`WebSocket sliced log messages to the last ${O.current} entries`),n.slice(n.length-O.current)):n})}else{if(q&&console.log(`WebSocket received message id ${t.id} method ${t.method}:`,t),t.id===0)_.current.forEach(e=>e.listener(t));else{let e=_.current.find(e=>e.id===t.id);e?e.listener(t):console.warn(`WebSocket no listener found for message id ${t.id}:`,t)}return}}catch(e){console.error(`WebSocket error parsing message: ${String(e)}`,e instanceof Error?e.stack:null)}},v.current.onopen=()=>{q&&console.log(`WebSocket: Connected to WebSocket: ${A}`),P(`WebSocket`,`Connected to WebSocket: ${A}`),c(!0),d(),y.current=1,C.current=setTimeout(()=>{x.current=setInterval(()=>{N({id:b.current,method:`ping`,src:`Frontend`,dst:`Matterbridge`,params:{}}),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{q&&console.error(`WebSocketUse: No pong response received from WebSocket: ${A}`),P(`WebSocket`,`No pong response received from WebSocket: ${A}`),c(!1)},1e3*50)},1e3*60)},1e3*300)},v.current.onclose=()=>{q&&console.error(`WebSocket: Disconnected from WebSocket ${Rt?`with Ingress`:``}: ${A}`),P(`WebSocket`,`Disconnected from WebSocket: ${A}`),c(!1),d(),p(),C.current&&clearTimeout(C.current),S.current&&clearTimeout(S.current),x.current&&clearInterval(x.current),P(`WebSocket`,`Reconnecting (attempt ${y.current} of 100) to WebSocket${Rt?` (Ingress)`:``}: ${A}`),Rt?setTimeout(I,5e3):y.current===1?I():y.current<100?setTimeout(I,1e3*y.current):P(`WebSocket`,`Reconnect attempts exceeded limit of 100 retries, refresh the page to reconnect to: ${A}`),y.current+=1},v.current.onerror=e=>{q&&console.error(`WebSocket: WebSocket error connecting to ${A}:`,e),P(`WebSocket`,`WebSocket error connecting to ${A}`)})},[A]),I=(0,G.useCallback)(()=>{q&&console.log(`WebSocket attemptReconnect ${y.current}/100 to:`,A),te()},[te]);(0,G.useEffect)(()=>(te(),()=>{v.current&&v.current.readyState===WebSocket.OPEN&&v.current.close()}),[te]);let ne=(0,G.useMemo)(()=>({messages:t,logLength:O,logAutoScroll:k,logFilterLevel:r,logFilterSearch:a,setMessages:n,setLogFilterLevel:i,setLogFilterSearch:o,filterLogMessages:M}),[t,O,k,r,a,n,i,o,M]),re=(0,G.useMemo)(()=>({logLength:O,logAutoScroll:k,logFilterLevel:r,logFilterSearch:a,setMessages:n,setLogFilterLevel:i,setLogFilterSearch:o,filterLogMessages:M,online:s,retry:y.current,getUniqueId:j,addListener:ee,removeListener:F,sendMessage:N,logMessage:P}),[O,k,n,i,o,s,ee,F,N,P]);return(0,Y.jsx)(Ht.Provider,{value:ne,children:(0,Y.jsx)(X.Provider,{value:re,children:e})})}function Wt(){let{retry:e}=(0,G.useContext)(X);return(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,width:`100vw`,height:`100vh`,justifyContent:`center`,alignItems:`center`,fontSize:`20px`,color:`var(--main-text-color)`,backgroundColor:`var(--main-bg-color)`},children:[(0,Y.jsx)(Bt,{style:{height:`128px`,width:`128px`,margin:`10px`,marginBottom:`20px`}}),e<100?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(de,{style:{color:`var(--primary-color)`}}),(0,Y.jsx)(`div`,{style:{marginTop:`20px`,color:`var(--primary-color)`,textAlign:`center`},children:(0,Y.jsxs)(`span`,{children:[`Reconnecting to Matterbridge `,`(attempt `+e+`)`,`...`]})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{style:{marginTop:`20px`,color:`var(--primary-color)`,textAlign:`center`},children:[(0,Y.jsx)(`span`,{children:`Unable to connect to Matterbridge after multiple attempts.`}),(0,Y.jsx)(`br`,{}),(0,Y.jsx)(`span`,{children:`Please check your network connection.`}),(0,Y.jsx)(`br`,{})]}),(0,Y.jsx)(L,{variant:`contained`,color:`primary`,onClick:()=>{window.location.reload()},style:{marginTop:`20px`},children:`Refresh the Page`})]})]})}var Z=ht();function Q({children:e,style:t}){return(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,flex:`0 0 auto`,width:`100%`,overflow:`hidden`,margin:`0px`,padding:`0px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,boxShadow:`5px 5px 10px var(--div-shadow-color)`,border:`1px solid var(--table-border-color)`,borderRadius:`var(--div-border-radius)`,boxSizing:`border-box`,...t},children:e})}function Gt({children:e,style:t}){return(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:`space-between`,width:`100%`,height:`30px`,borderBottom:`1px solid var(--table-border-color)`,color:`var(--header-text-color)`,backgroundColor:`var(--header-bg-color)`,margin:`0px`,padding:`0px`,boxSizing:`border-box`,...t},children:e})}function Kt({children:e,style:t}){return(0,Y.jsx)(`div`,{style:{color:`var(--header-text-color)`,backgroundColor:`var(--header-bg-color)`,fontSize:`16px`,fontWeight:`bold`,margin:`0px`,padding:`5px 10px`,...t},children:e})}function qt({children:e,style:t}){return(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:`space-between`,width:`100%`,height:`30px`,color:`var(--footer-text-color)`,backgroundColor:`var(--footer-bg-color)`,margin:`0px`,padding:`0px`,boxSizing:`border-box`,...t},children:e})}function Jt({children:e,style:t}){return(0,Y.jsx)(`div`,{style:{color:`var(--footer-text-color)`,backgroundColor:`var(--footer-bg-color)`,fontSize:`14px`,fontWeight:`bold`,margin:`0px`,padding:`5px 10px`,...t},children:e})}function Yt({children:e,style:t}){return(0,Y.jsx)(`div`,{style:{color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`,fontSize:`14px`,fontWeight:`normal`,margin:`0px`,padding:`5px 10px`,...t},children:e})}function Xt({children:e,style:t,onDragOver:n,onDragLeave:r,onDrop:i}){return(0,Y.jsx)(`div`,{style:{flex:`0 0 auto`,display:`flex`,flexDirection:`row`,overflow:`hidden`,alignItems:`start`,justifyContent:`space-between`,margin:`0px`,padding:`10px`,gap:`20px`,...t},onDragOver:n,onDragLeave:r,onDrop:i,children:e})}function Zt({children:e,style:t,close:n}){return(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,margin:`0px`,padding:`0px`,paddingRight:`10px`,gap:`10px`,...t},children:[e,!1]})}var Qt=!1,$t={display:`flex`,gap:`2px`,justifyContent:`space-evenly`,width:`100%`,height:`40px`},en={margin:`0`,padding:`0`,fontSize:`36px`,fontWeight:`medium`,color:`var(--primary-color)`},tn={margin:`0`,padding:`0`,fontSize:`20px`,fontWeight:`medium`,color:`var(--div-text-color)`,textAlign:`center`},nn={margin:`0`,padding:`0`,paddingBottom:`2px`,fontSize:`16px`,fontWeight:`medium`,color:`var(--div-text-color)`,textAlign:`center`},rn={display:`flex`,gap:`2px`,justifyContent:`center`,width:`100%`,height:`18px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},an={margin:`0`,padding:`0`,fontSize:`12px`,fontWeight:`normal`,color:`var(--div-text-color)`},on={display:`flex`,justifyContent:`center`,width:`100%`,height:`52px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},sn={margin:`0`,padding:`0`,fontSize:`14px`,fontWeight:`bold`,color:`var(--div-text-color)`},cn={display:`flex`,gap:`4px`,justifyContent:`center`,width:`100%`,height:`15px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},ln={margin:`0`,padding:`0px 4px`,borderRadius:`5px`,textAlign:`center`,fontSize:`12px`,fontWeight:`normal`,color:`var(--secondary-color)`},un=[256,257,268,269],dn=[266,267],fn=[259,260,261,271,272],pn=[256,257,268,269,266,267,259,260,261,272];function $({icon:e,iconColor:t,cluster:n,value:r,unit:i,prefix:a}){return q&&console.log(`Render cluster "${n.clusterName}.${n.attributeName}" value(${typeof r}-${Number.isNaN(r)}) "${r}" unit "${i}"`),a??=!1,(0,Y.jsxs)(W,{sx:$t,children:[e&&(0,G.cloneElement)(e,{key:`${n.clusterId}-${n.attributeId}-icon`,sx:{...en,color:t??`var(--primary-color)`}}),(0,Y.jsxs)(W,{sx:{...$t,gap:`4px`,alignContent:`center`,alignItems:`end`,justifyContent:`center`},children:[i&&a&&(0,Y.jsx)(p,{sx:nn,children:i},`${n.clusterId}-${n.attributeId}-unit-prefix`),(0,Y.jsx)(p,{sx:tn,children:r==null||typeof r==`number`&&Number.isNaN(r)||r===`NaN`?`---`:r},`${n.clusterId}-${n.attributeId}-value`),i&&!a&&(0,Y.jsx)(p,{sx:nn,children:i},`${n.clusterId}-${n.attributeId}-unit-suffix`)]},`${n.clusterId}-${n.attributeId}-valueunitbox`)]},`${n.clusterId}-${n.attributeId}-box`)}function mn({device:e,endpoint:t,id:n,deviceType:r,clusters:i}){let a=[`Unknown`,`Good`,`Fair`,`Moderate`,`Poor`,`VeryPoor`,`Ext.Poor`],o=``;q&&console.log(`Device "${e.name}" endpoint "${t}" id "${n}" deviceType "0x${r.toString(16).padStart(4,`0`)}" clusters (${i?.length})`);let s=i.find(e=>e.clusterName===`Descriptor`&&e.attributeName===`tagList`)?.attributeLocalValue;if(s){let e=``;s.map(t=>{t.label&&(e+=t.label+` `)}),o=e.trim()}if(r===17&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`batVoltage`).map(e=>o=`${e.attributeLocalValue??0} mV`),pn.includes(r)&&i.filter(e=>e.clusterName===`LevelControl`&&e.attributeName===`currentLevel`).map(e=>o=`Level ${e.attributeValue}`),r===514&&i.filter(e=>e.clusterName===`WindowCovering`&&e.attributeName===`currentPositionLiftPercent100ths`).map(e=>o=`Position ${e.attributeLocalValue/100}%`),r===769&&i.filter(e=>e.clusterName===`Thermostat`&&e.attributeName===`occupiedHeatingSetpoint`).map(e=>o=`Heat ${e.attributeLocalValue/100}°C `),r===769&&i.filter(e=>e.clusterName===`Thermostat`&&e.attributeName===`occupiedCoolingSetpoint`).map(e=>o+=`Cool ${e.attributeLocalValue/100}°C`),r===118&&i.filter(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`coState`).map(e=>o=e.attributeLocalValue===0?`No CO detected`:`CO alarm!`),r===1296&&i.filter(e=>e.clusterName===`ElectricalPowerMeasurement`&&e.attributeName===`voltage`).map(e=>o=`${e.attributeLocalValue/1e3} V, `),r===1296&&i.filter(e=>e.clusterName===`ElectricalPowerMeasurement`&&e.attributeName===`activeCurrent`).map(e=>o+=`${e.attributeLocalValue/1e3} A, `),r===1296&&i.filter(e=>e.clusterName===`ElectricalPowerMeasurement`&&e.attributeName===`activePower`).map(e=>o+=`${e.attributeLocalValue/1e3} W`),r===39){let e=i.find(e=>e.clusterName===`ModeSelect`&&e.attributeName===`currentMode`)?.attributeLocalValue;o=(i.find(e=>e.clusterName===`ModeSelect`&&e.attributeName===`supportedModes`)?.attributeLocalValue)?.find(t=>t.mode===e)?.label||`Unknown`}if(r===116){let e=i.find(e=>e.clusterName===`RvcRunMode`&&e.attributeName===`currentMode`)?.attributeLocalValue;o=(i.find(e=>e.clusterName===`RvcRunMode`&&e.attributeName===`supportedModes`)?.attributeLocalValue)?.find(t=>t.mode===e)?.label||`Unknown`}return(0,Y.jsxs)(Q,{style:{margin:`0px`,padding:`5px`,width:`150px`,height:`150px`,borderColor:`var(--div-bg-color)`,borderRadius:`5px`,justifyContent:`space-between`},children:[r===19&&i.filter(e=>e.clusterName===`BridgedDeviceBasicInformation`&&e.attributeName===`reachable`).map(e=>(0,Y.jsx)($,{icon:e.attributeLocalValue===!0?(0,Y.jsx)(j,{}):(0,Y.jsx)(E,{}),iconColor:e.attributeLocalValue===!0?`green`:`red`,cluster:e,value:e.attributeLocalValue===!0?`Online`:`Offline`},`${e.clusterId}-${e.attributeId}`)),r===17&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`batPercentRemaining`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Ge,{}),cluster:e,value:e.attributeLocalValue/2,unit:`%`},`${e.clusterId}-${e.attributeId}`)),r===17&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`wiredCurrentType`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)($e,{}),cluster:e,value:e.attributeLocalValue===0?`AC`:`DC`},`${e.clusterId}-${e.attributeId}`)),r===1293&&i.filter(e=>e.clusterName===`DeviceEnergyManagement`&&e.attributeName===`esaState`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M8.28,5.45L6.5,4.55L7.76,2H16.23L17.5,4.55L15.72,5.44L15,4H9L8.28,5.45M18.62,8H14.09L13.3,5H10.7L9.91,8H5.38L4.1,10.55L5.89,11.44L6.62,10H17.38L18.1,11.45L19.89,10.56L18.62,8M17.77,22H15.7L15.46,21.1L12,15.9L8.53,21.1L8.3,22H6.23L9.12,11H11.19L10.83,12.35L12,14.1L13.16,12.35L12.81,11H14.88L17.77,22M11.4,15L10.5,13.65L9.32,18.13L11.4,15M14.68,18.12L13.5,13.64L12.6,15L14.68,18.12Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Offline`:`Online`},`${e.clusterId}-${e.attributeId}`)),un.includes(r)&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(ge,{}),cluster:e,value:e.attributeLocalValue===!0?`On`:`Off`},`${e.clusterId}-${e.attributeId}`)),dn.includes(r)&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M7.5,10.5A1.5,1.5 0 0,1 9,12A1.5,1.5 0 0,1 7.5,13.5C6.66,13.5 6,12.83 6,12A1.5,1.5 0 0,1 7.5,10.5M16.5,10.5A1.5,1.5 0 0,1 18,12A1.5,1.5 0 0,1 16.5,13.5A1.5,1.5 0 0,1 15,12A1.5,1.5 0 0,1 16.5,10.5M4.22,2H19.78C21,2 22,3 22,4.22V19.78A2.22,2.22 0 0,1 19.78,22H4.22C3,22 2,21 2,19.78V4.22A2.22,2.22 0 0,1 4.22,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===!0?`On`:`Off`},`${e.clusterId}-${e.attributeId}`)),fn.includes(r)&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M8 6V18H16V6H8M14 10H10V8H14V10M19.4 1.6C19 1.2 18.5 1 18 1H6C5.5 1 5 1.2 4.6 1.6C4.2 2 4 2.5 4 3V21C4 21.5 4.2 22 4.6 22.4C5 22.8 5.5 23 6 23H18C18.5 23 19 22.8 19.4 22.4C19.8 22 20 21.5 20 21V3C20 2.5 19.8 2 19.4 1.6M18 21H6V3H18V21Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===!0?`On`:`Off`},`${e.clusterId}-${e.attributeId}`)),r===115&&i.filter(e=>e.clusterName===`OperationalState`&&e.attributeName===`operationalState`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M14.83,11.17C16.39,12.73 16.39,15.27 14.83,16.83C13.27,18.39 10.73,18.39 9.17,16.83L14.83,11.17M6,2H18A2,2 0 0,1 20,4V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2M7,4A1,1 0 0,0 6,5A1,1 0 0,0 7,6A1,1 0 0,0 8,5A1,1 0 0,0 7,4M10,4A1,1 0 0,0 9,5A1,1 0 0,0 10,6A1,1 0 0,0 11,5A1,1 0 0,0 10,4M12,8A6,6 0 0,0 6,14A6,6 0 0,0 12,20A6,6 0 0,0 18,14A6,6 0 0,0 12,8Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Normal`:`Error`},`${e.clusterId}-${e.attributeId}`)),r===124&&i.filter(e=>e.clusterName===`OperationalState`&&e.attributeName===`operationalState`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M6,2H18A2,2 0 0,1 20,4V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2M7,4A1,1 0 0,0 6,5A1,1 0 0,0 7,6A1,1 0 0,0 8,5A1,1 0 0,0 7,4M10,4A1,1 0 0,0 9,5A1,1 0 0,0 10,6A1,1 0 0,0 11,5A1,1 0 0,0 10,4M12,8A6,6 0 0,0 6,14A6,6 0 0,0 12,20A6,6 0 0,0 18,14A6,6 0 0,0 12,8M8.11,10.5H10C9.76,11.88 10,12.67 10.58,13.29C11.68,14.36 12.16,15.71 11.89,17.5H10C10.24,16.12 10,15.33 9.42,14.71C8.32,13.64 7.85,12.29 8.11,10.5M12.11,10.5H14C13.76,11.88 14,12.67 14.58,13.29C15.68,14.36 16.16,15.71 15.89,17.5H14C14.24,16.12 14,15.33 13.42,14.71C12.32,13.64 11.85,12.29 12.11,10.5Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Normal`:`Error`},`${e.clusterId}-${e.attributeId}`)),r===117&&i.filter(e=>e.clusterName===`OperationalState`&&e.attributeName===`operationalState`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M18,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V4A2,2 0 0,0 18,2M10,4A1,1 0 0,1 11,5A1,1 0 0,1 10,6A1,1 0 0,1 9,5A1,1 0 0,1 10,4M7,4A1,1 0 0,1 8,5A1,1 0 0,1 7,6A1,1 0 0,1 6,5A1,1 0 0,1 7,4M18,20H6V8H18V20M14.67,15.33C14.69,16.03 14.41,16.71 13.91,17.21C12.86,18.26 11.15,18.27 10.09,17.21C9.59,16.71 9.31,16.03 9.33,15.33C9.4,14.62 9.63,13.94 10,13.33C10.37,12.5 10.81,11.73 11.33,11L12,10C13.79,12.59 14.67,14.36 14.67,15.33`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Normal`:`Error`},`${e.clusterId}-${e.attributeId}`)),r===123&&i.filter(e=>e.clusterName===`BridgedDeviceBasicInformation`&&e.attributeName===`reachable`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(S,{}),cluster:e,value:`Oven`},`${e.clusterId}-${e.attributeId}`)),r===112&&i.filter(e=>e.clusterName===`BridgedDeviceBasicInformation`&&e.attributeName===`reachable`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(R,{}),cluster:e,value:`Fridge`},`${e.clusterId}-${e.attributeId}`)),r===113&&i.filter(e=>e.clusterName===`TemperatureControl`&&e.attributeName===`selectedTemperatureLevel`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M5,3A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3H5M12,5C13.57,5 15,5.5 16.19,6.4L14,8.56C13.43,8.21 12.74,8 12,8A4,4 0 0,0 8,12C8,13.1 8.45,14.1 9.17,14.83L7.05,16.95C5.78,15.68 5,13.93 5,12A7,7 0 0,1 12,5M17.6,7.81C18.5,9 19,10.43 19,12C19,13.93 18.22,15.68 16.95,16.95L14.83,14.83C15.55,14.1 16,13.1 16,12C16,11.26 15.79,10.57 15.43,10L17.6,7.81Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue,unit:`mode`,prefix:!0},`${e.clusterId}-${e.attributeId}`)),r===121&&i.filter(e=>e.clusterName===`OperationalState`&&e.attributeName===`operationalState`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(S,{}),cluster:e,value:e.attributeLocalValue===0?`Normal`:`Error`},`${e.clusterId}-${e.attributeId}`)),r===122&&i.filter(e=>e.clusterName===`FanControl`&&e.attributeName===`fanMode`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M19,18.31V20A2,2 0 0,1 17,22H7A2,2 0 0,1 5,20V16.3C4.54,16.12 3.95,16 3,16A1,1 0 0,1 2,15A1,1 0 0,1 3,14C3.82,14 4.47,14.08 5,14.21V12.3C4.54,12.12 3.95,12 3,12A1,1 0 0,1 2,11A1,1 0 0,1 3,10C3.82,10 4.47,10.08 5,10.21V8.3C4.54,8.12 3.95,8 3,8A1,1 0 0,1 2,7A1,1 0 0,1 3,6C3.82,6 4.47,6.08 5,6.21V4A2,2 0 0,1 7,2H17A2,2 0 0,1 19,4V6.16C20.78,6.47 21.54,7.13 21.71,7.29C22.1,7.68 22.1,8.32 21.71,8.71C21.32,9.1 20.8,9.09 20.29,8.71V8.71C20.29,8.71 19.25,8 17,8C15.74,8 14.91,8.41 13.95,8.9C12.91,9.41 11.74,10 10,10C9.64,10 9.31,10 9,9.96V7.95C9.3,8 9.63,8 10,8C11.26,8 12.09,7.59 13.05,7.11C14.09,6.59 15.27,6 17,6V4H7V20H17V18C18.5,18 18.97,18.29 19,18.31M17,10C15.27,10 14.09,10.59 13.05,11.11C12.09,11.59 11.26,12 10,12C9.63,12 9.3,12 9,11.95V13.96C9.31,14 9.64,14 10,14C11.74,14 12.91,13.41 13.95,12.9C14.91,12.42 15.74,12 17,12C19.25,12 20.29,12.71 20.29,12.71V12.71C20.8,13.1 21.32,13.1 21.71,12.71C22.1,12.32 22.1,11.69 21.71,11.29C21.5,11.08 20.25,10 17,10M17,14C15.27,14 14.09,14.59 13.05,15.11C12.09,15.59 11.26,16 10,16C9.63,16 9.3,16 9,15.95V17.96C9.31,18 9.64,18 10,18C11.74,18 12.91,17.41 13.95,16.9C14.91,16.42 15.74,16 17,16C19.25,16 20.29,16.71 20.29,16.71V16.71C20.8,17.1 21.32,17.1 21.71,16.71C22.1,16.32 22.1,15.69 21.71,15.29C21.5,15.08 20.25,14 17,14Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue,unit:`mode`,prefix:!0},`${e.clusterId}-${e.attributeId}`)),r===120&&i.filter(e=>e.clusterName===`BridgedDeviceBasicInformation`&&e.attributeName===`reachable`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M6,14H8L11,17H9L6,14M4,4H5V3A1,1 0 0,1 6,2H10A1,1 0 0,1 11,3V4H13V3A1,1 0 0,1 14,2H18A1,1 0 0,1 19,3V4H20A2,2 0 0,1 22,6V19A2,2 0 0,1 20,21V22H17V21H7V22H4V21A2,2 0 0,1 2,19V6A2,2 0 0,1 4,4M18,7A1,1 0 0,1 19,8A1,1 0 0,1 18,9A1,1 0 0,1 17,8A1,1 0 0,1 18,7M14,7A1,1 0 0,1 15,8A1,1 0 0,1 14,9A1,1 0 0,1 13,8A1,1 0 0,1 14,7M20,6H4V10H20V6M4,19H20V12H4V19M6,7A1,1 0 0,1 7,8A1,1 0 0,1 6,9A1,1 0 0,1 5,8A1,1 0 0,1 6,7M13,14H15L18,17H16L13,14Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`Cooktop`},`${e.clusterId}-${e.attributeId}`)),r===119&&i.filter(e=>e.clusterName===`TemperatureControl`&&e.attributeName===`selectedTemperatureLevel`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M6,14H8L11,17H9L6,14M4,4H5V3A1,1 0 0,1 6,2H10A1,1 0 0,1 11,3V4H13V3A1,1 0 0,1 14,2H18A1,1 0 0,1 19,3V4H20A2,2 0 0,1 22,6V19A2,2 0 0,1 20,21V22H17V21H7V22H4V21A2,2 0 0,1 2,19V6A2,2 0 0,1 4,4M18,7A1,1 0 0,1 19,8A1,1 0 0,1 18,9A1,1 0 0,1 17,8A1,1 0 0,1 18,7M14,7A1,1 0 0,1 15,8A1,1 0 0,1 14,9A1,1 0 0,1 13,8A1,1 0 0,1 14,7M20,6H4V10H20V6M4,19H20V12H4V19M6,7A1,1 0 0,1 7,8A1,1 0 0,1 6,9A1,1 0 0,1 5,8A1,1 0 0,1 6,7M13,14H15L18,17H16L13,14Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue,unit:`mode`,prefix:!0},`${e.clusterId}-${e.attributeId}`)),r===514&&i.filter(e=>e.clusterName===`WindowCovering`&&e.attributeName===`currentPositionLiftPercent100ths`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(xe,{}),cluster:e,value:e.attributeLocalValue/100,unit:`%`},`${e.clusterId}-${e.attributeId}`)),r===769&&i.filter(e=>e.clusterName===`Thermostat`&&e.attributeName===`localTemperature`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M16.95,16.95L14.83,14.83C15.55,14.1 16,13.1 16,12C16,11.26 15.79,10.57 15.43,10L17.6,7.81C18.5,9 19,10.43 19,12C19,13.93 18.22,15.68 16.95,16.95M12,5C13.57,5 15,5.5 16.19,6.4L14,8.56C13.43,8.21 12.74,8 12,8A4,4 0 0,0 8,12C8,13.1 8.45,14.1 9.17,14.83L7.05,16.95C5.78,15.68 5,13.93 5,12A7,7 0 0,1 12,5M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:(e.attributeLocalValue??0)/100,unit:`°C`},`${e.clusterId}-${e.attributeId}`)),r===10&&i.filter(e=>e.clusterName===`DoorLock`&&e.attributeName===`lockState`).map(e=>(0,Y.jsx)($,{icon:e.attributeValue===`1`?(0,Y.jsx)(O,{}):(0,Y.jsx)(qe,{}),cluster:e,value:e.attributeValue===`1`?`Locked`:`Unlocked`},`${e.clusterId}-${e.attributeId}`)),r===43&&i.filter(e=>e.clusterName===`FanControl`&&e.attributeName===`percentCurrent`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Ze,{}),cluster:e,value:e.attributeValue,unit:`%`},`${e.clusterId}-${e.attributeId}`)),r===15&&i.filter(e=>e.clusterName===`Switch`&&e.attributeName===`currentPosition`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M13 5C15.21 5 17 6.79 17 9C17 10.5 16.2 11.77 15 12.46V11.24C15.61 10.69 16 9.89 16 9C16 7.34 14.66 6 13 6S10 7.34 10 9C10 9.89 10.39 10.69 11 11.24V12.46C9.8 11.77 9 10.5 9 9C9 6.79 10.79 5 13 5M20 20.5C19.97 21.32 19.32 21.97 18.5 22H13C12.62 22 12.26 21.85 12 21.57L8 17.37L8.74 16.6C8.93 16.39 9.2 16.28 9.5 16.28H9.7L12 18V9C12 8.45 12.45 8 13 8S14 8.45 14 9V13.47L15.21 13.6L19.15 15.79C19.68 16.03 20 16.56 20 17.14V20.5M20 2H4C2.9 2 2 2.9 2 4V12C2 13.11 2.9 14 4 14H8V12L4 12L4 4H20L20 12H18V14H20V13.96L20.04 14C21.13 14 22 13.09 22 12V4C22 2.9 21.11 2 20 2Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeValue,unit:`pos`,prefix:!0},`${e.clusterId}-${e.attributeId}`)),r===39&&i.filter(e=>e.clusterName===`ModeSelect`&&e.attributeName===`currentMode`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Ne,{}),cluster:e,value:e.attributeValue,unit:`Mode`,prefix:!0},`${e.clusterId}-${e.attributeId}`)),r===771&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Ye,{}),cluster:e,value:e.attributeLocalValue===!0?`On`:`Off`},`${e.clusterId}-${e.attributeId}`)),r===45&&i.filter(e=>e.clusterName===`FanControl`&&e.attributeName===`percentCurrent`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(ie,{}),cluster:e,value:e.attributeValue,unit:`%`},`${e.clusterId}-${e.attributeId}`)),r===114&&i.filter(e=>e.clusterName===`Thermostat`&&e.attributeName===`localTemperature`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(ie,{}),cluster:e,value:(e.attributeLocalValue??0)/100,unit:`°C`},`${e.clusterId}-${e.attributeId}`)),r===67&&i.filter(e=>e.clusterName===`BooleanState`&&e.attributeName===`stateValue`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(ae,{}),cluster:e,value:e.attributeLocalValue===!0?`Leak`:`No leak`},`${e.clusterId}-${e.attributeId}`)),r===65&&i.filter(e=>e.clusterName===`BooleanState`&&e.attributeName===`stateValue`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(we,{}),cluster:e,value:e.attributeLocalValue===!0?`Freeze`:`No freeze`},`${e.clusterId}-${e.attributeId}`)),r===68&&i.filter(e=>e.clusterName===`BooleanState`&&e.attributeName===`stateValue`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(lt,{}),cluster:e,value:e.attributeLocalValue===!0?`Rain`:`No rain`},`${e.clusterId}-${e.attributeId}`)),r===116&&i.filter(e=>e.clusterName===`RvcRunMode`&&e.attributeName===`currentMode`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M12,2C14.65,2 17.19,3.06 19.07,4.93L17.65,6.35C16.15,4.85 14.12,4 12,4C9.88,4 7.84,4.84 6.35,6.35L4.93,4.93C6.81,3.06 9.35,2 12,2M3.66,6.5L5.11,7.94C4.39,9.17 4,10.57 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12C20,10.57 19.61,9.17 18.88,7.94L20.34,6.5C21.42,8.12 22,10.04 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12C2,10.04 2.58,8.12 3.66,6.5M12,6A6,6 0 0,1 18,12C18,13.59 17.37,15.12 16.24,16.24L14.83,14.83C14.08,15.58 13.06,16 12,16C10.94,16 9.92,15.58 9.17,14.83L7.76,16.24C6.63,15.12 6,13.59 6,12A6,6 0 0,1 12,6M12,8A1,1 0 0,0 11,9A1,1 0 0,0 12,10A1,1 0 0,0 13,9A1,1 0 0,0 12,8Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeValue,unit:`Run mode`,prefix:!0},`${e.clusterId}-${e.attributeId}`)),r===1292&&i.filter(e=>e.clusterName===`EnergyEvse`&&e.attributeName===`state`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M19.77,7.23L19.78,7.22L16.06,3.5L15,4.56L17.11,6.67C16.17,7.03 15.5,7.93 15.5,9A2.5,2.5 0 0,0 18,11.5C18.36,11.5 18.69,11.42 19,11.29V18.5A1,1 0 0,1 18,19.5A1,1 0 0,1 17,18.5V14A2,2 0 0,0 15,12H14V5A2,2 0 0,0 12,3H6A2,2 0 0,0 4,5V21H14V13.5H15.5V18.5A2.5,2.5 0 0,0 18,21A2.5,2.5 0 0,0 20.5,18.5V9C20.5,8.31 20.22,7.68 19.77,7.23M18,10A1,1 0 0,1 17,9A1,1 0 0,1 18,8A1,1 0 0,1 19,9A1,1 0 0,1 18,10M8,18V13.5H6L10,6V11H12L8,18Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Free`:`In use`},`${e.clusterId}-${e.attributeId}`)),r===1295&&i.filter(e=>e.clusterName===`WaterHeaterManagement`&&e.attributeName===`tankPercentage`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M8 2C6.89 2 6 2.89 6 4V16C6 17.11 6.89 18 8 18H9V20H6V22H9C10.11 22 11 21.11 11 20V18H13V20C13 21.11 13.89 22 15 22H18V20H15V18H16C17.11 18 18 17.11 18 16V4C18 2.89 17.11 2 16 2H8M12 4.97A2 2 0 0 1 14 6.97A2 2 0 0 1 12 8.97A2 2 0 0 1 10 6.97A2 2 0 0 1 12 4.97M10 14.5H14V16H10V14.5Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`Tank `+(e.attributeLocalValue??0)+`%`},`${e.clusterId}-${e.attributeId}`)),r===777&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`featureMap`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3M12.75 7.08C13.57 7.2 14.32 7.5 14.95 8L12.75 10.19V7.08M11.25 7.08V10.19L9.05 8C9.68 7.5 10.43 7.2 11.25 7.08M8 9.05L10.19 11.25H7.08C7.2 10.43 7.5 9.68 8 9.05M7.08 12.75H10.19L8 14.95C7.5 14.32 7.2 13.57 7.08 12.75M11.25 16.92C10.43 16.8 9.68 16.5 9.05 16L11.25 13.81V16.92M12 13C11.45 13 11 12.55 11 12S11.45 11 12 11 13 11.45 13 12 12.55 13 12 13M12.75 16.92V13.81L14.95 16C14.32 16.5 13.57 16.8 12.75 16.92M16 14.95L13.81 12.75H16.92C16.8 13.57 16.5 14.32 16 14.95M13.81 11.25L16 9.05C16.5 9.69 16.8 10.44 16.92 11.25H13.81Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`HeatPump`},`${e.clusterId}-${e.attributeId}`)),r===23&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`featureMap`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M4,2H20A2,2 0 0,1 22,4V14A2,2 0 0,1 20,16H15V20H18V22H13V16H11V22H6V20H9V16H4A2,2 0 0,1 2,14V4A2,2 0 0,1 4,2M4,4V8H11V4H4M4,14H11V10H4V14M20,14V10H13V14H20M20,4H13V8H20V4Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`Solar`},`${e.clusterId}-${e.attributeId}`)),r===24&&i.filter(e=>e.clusterName===`ElectricalPowerMeasurement`&&e.attributeName===`featureMap`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M12 20L5 20V12H2L12 3L14.78 5.5H14V7.17C12.84 7.58 12 8.7 12 10V20M15 9H16V7.5H20V9H21C21.55 9 22 9.45 22 10V21C22 21.55 21.55 22 21 22H15C14.45 22 14 21.55 14 21V10C14 9.45 14.45 9 15 9M16 11V14H20V11H16Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`Inverter`},`${e.clusterId}-${e.attributeId}`)),r===118&&i.find(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`featureMap`&&e.attributeLocalValue.smokeAlarm===!0)&&i.filter(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`smokeState`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M12 4C16.41 4 20 7.59 20 12S16.41 20 12 20 4 16.41 4 12 7.59 4 12 4M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 11C11.45 11 11 11.45 11 12S11.45 13 12 13 13 12.55 13 12 12.55 11 12 11M10.72 9.3C11.11 9.11 11.54 9 12 9S12.89 9.11 13.29 9.3L14 8.57C13.43 8.22 12.74 8 12 8S10.58 8.22 10 8.57L10.72 9.3M15 12C15 12.46 14.89 12.89 14.7 13.29L15.43 14C15.79 13.43 16 12.74 16 12S15.79 10.58 15.43 10L14.7 10.72C14.89 11.11 15 11.54 15 12M9 12C9 11.54 9.11 11.11 9.3 10.72L8.57 10C8.22 10.58 8 11.26 8 12S8.22 13.43 8.57 14L9.3 13.29C9.11 12.89 9 12.46 9 12M13.29 14.7C12.89 14.89 12.46 15 12 15S11.11 14.89 10.72 14.7L10 15.43C10.58 15.79 11.26 16 12 16S13.43 15.79 14 15.43L13.29 14.7M16.89 8.53L16.17 9.25C16.69 10.04 17 11 17 12S16.69 13.96 16.17 14.75L16.89 15.47C17.59 14.5 18 13.3 18 12S17.59 9.5 16.89 8.53M9.25 7.83C10.04 7.31 11 7 12 7S13.96 7.31 14.75 7.83L15.47 7.11C14.5 6.42 13.3 6 12 6S9.5 6.42 8.53 7.11L9.25 7.83M14.75 16.17C13.96 16.69 13 17 12 17S10.04 16.69 9.25 16.17L8.53 16.89C9.5 17.59 10.7 18 12 18S14.5 17.59 15.47 16.89L14.75 16.17M7.83 14.75C7.31 13.96 7 13 7 12S7.31 10.04 7.83 9.25L7.11 8.53C6.42 9.5 6 10.7 6 12S6.42 14.5 7.11 15.47L7.83 14.75Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`No smoke`:`Smoke!`},`${e.clusterId}-${e.attributeId}`)),r===118&&i.find(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`featureMap`&&e.attributeLocalValue.smokeAlarm===!1)&&i.filter(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`coState`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M12 4C16.41 4 20 7.59 20 12S16.41 20 12 20 4 16.41 4 12 7.59 4 12 4M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 11C11.45 11 11 11.45 11 12S11.45 13 12 13 13 12.55 13 12 12.55 11 12 11M10.72 9.3C11.11 9.11 11.54 9 12 9S12.89 9.11 13.29 9.3L14 8.57C13.43 8.22 12.74 8 12 8S10.58 8.22 10 8.57L10.72 9.3M15 12C15 12.46 14.89 12.89 14.7 13.29L15.43 14C15.79 13.43 16 12.74 16 12S15.79 10.58 15.43 10L14.7 10.72C14.89 11.11 15 11.54 15 12M9 12C9 11.54 9.11 11.11 9.3 10.72L8.57 10C8.22 10.58 8 11.26 8 12S8.22 13.43 8.57 14L9.3 13.29C9.11 12.89 9 12.46 9 12M13.29 14.7C12.89 14.89 12.46 15 12 15S11.11 14.89 10.72 14.7L10 15.43C10.58 15.79 11.26 16 12 16S13.43 15.79 14 15.43L13.29 14.7M16.89 8.53L16.17 9.25C16.69 10.04 17 11 17 12S16.69 13.96 16.17 14.75L16.89 15.47C17.59 14.5 18 13.3 18 12S17.59 9.5 16.89 8.53M9.25 7.83C10.04 7.31 11 7 12 7S13.96 7.31 14.75 7.83L15.47 7.11C14.5 6.42 13.3 6 12 6S9.5 6.42 8.53 7.11L9.25 7.83M14.75 16.17C13.96 16.69 13 17 12 17S10.04 16.69 9.25 16.17L8.53 16.89C9.5 17.59 10.7 18 12 18S14.5 17.59 15.47 16.89L14.75 16.17M7.83 14.75C7.31 13.96 7 13 7 12S7.31 10.04 7.83 9.25L7.11 8.53C6.42 9.5 6 10.7 6 12S6.42 14.5 7.11 15.47L7.83 14.75Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`No Co`:`Co!`},`${e.clusterId}-${e.attributeId}`)),r===66&&i.filter(e=>e.clusterName===`ValveConfigurationAndControl`&&e.attributeName===`currentState`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(me,{}),cluster:e,value:e.attributeLocalValue===0?`Closed`:`Opened`},`${e.clusterId}-${e.attributeId}`)),r===44&&i.filter(e=>e.clusterName===`AirQuality`&&e.attributeName===`airQuality`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M11,9A4,4 0 0,1 15,13A4,4 0 0,1 11,17A4,4 0 0,1 7,13A4,4 0 0,1 11,9M11,11A2,2 0 0,0 9,13A2,2 0 0,0 11,15A2,2 0 0,0 13,13A2,2 0 0,0 11,11M7,4H14A4,4 0 0,1 18,8V9H16V8A2,2 0 0,0 14,6H7A2,2 0 0,0 5,8V20H16V18H18V22H3V8A4,4 0 0,1 7,4M16,11C18.5,11 18.5,9 21,9V11C18.5,11 18.5,13 16,13V11M16,15C18.5,15 18.5,13 21,13V15C18.5,15 18.5,17 16,17V15Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:a[e.attributeLocalValue??0]},`${e.clusterId}-${e.attributeId}`)),r===770&&i.filter(e=>e.clusterName===`TemperatureMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(f,{}),cluster:e,value:e.attributeLocalValue/100,unit:`°C`},`${e.clusterId}-${e.attributeId}`)),r===775&&i.filter(e=>e.clusterName===`RelativeHumidityMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(Z.Icon,{path:`M12,3.25C12,3.25 6,10 6,14C6,17.32 8.69,20 12,20A6,6 0 0,0 18,14C18,10 12,3.25 12,3.25M14.47,9.97L15.53,11.03L9.53,17.03L8.47,15.97M9.75,10A1.25,1.25 0 0,1 11,11.25A1.25,1.25 0 0,1 9.75,12.5A1.25,1.25 0 0,1 8.5,11.25A1.25,1.25 0 0,1 9.75,10M14.25,14.5A1.25,1.25 0 0,1 15.5,15.75A1.25,1.25 0 0,1 14.25,17A1.25,1.25 0 0,1 13,15.75A1.25,1.25 0 0,1 14.25,14.5Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue/100,unit:`%`},`${e.clusterId}-${e.attributeId}`)),r===774&&i.filter(e=>e.clusterName===`FlowMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(l,{}),cluster:e,value:e.attributeLocalValue,unit:`l/h`},`${e.clusterId}-${e.attributeId}`)),r===773&&i.filter(e=>e.clusterName===`PressureMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(De,{}),cluster:e,value:e.attributeLocalValue,unit:`hPa`},`${e.clusterId}-${e.attributeId}`)),r===21&&i.filter(e=>e.clusterName===`BooleanState`&&e.attributeName===`stateValue`).map(e=>(0,Y.jsx)($,{icon:e.attributeValue===`true`?(0,Y.jsx)(Ue,{}):(0,Y.jsx)(k,{}),cluster:e,value:e.attributeValue===`true`?`Closed`:`Opened`},`${e.clusterId}-${e.attributeId}`)),r===263&&i.filter(e=>e.clusterName===`OccupancySensing`&&e.attributeName===`occupancy`).map(e=>(0,Y.jsx)($,{icon:e.attributeValue===`{ occupied: true }`?(0,Y.jsx)(w,{}):(0,Y.jsx)(fe,{}),cluster:e,value:e.attributeValue===`{ occupied: true }`?`Occupied`:`Unocc.`},`${e.clusterId}-${e.attributeId}`)),r===262&&i.filter(e=>e.clusterName===`IlluminanceMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(_e,{}),cluster:e,value:Math.round(10**(e.attributeLocalValue/1e4)),unit:`lx`},`${e.clusterId}-${e.attributeId}`)),r===1296&&i.filter(e=>e.clusterName===`ElectricalEnergyMeasurement`&&e.attributeName===`cumulativeEnergyImported`).map(e=>(0,Y.jsx)($,{icon:(0,Y.jsx)(ue,{}),cluster:e,value:Math.round(e.attributeLocalValue?.energy/1e6),unit:`kwh`},`${e.clusterId}-${e.attributeId}`)),(0,Y.jsx)(W,{sx:rn,children:(0,Y.jsx)(p,{sx:an,children:o})}),(0,Y.jsx)(W,{sx:on,children:(0,Y.jsx)(p,{sx:sn,children:e.name})}),(0,Y.jsxs)(W,{sx:cn,children:[q&&(0,Y.jsx)(p,{sx:ln,children:t}),(0,Y.jsx)(p,{sx:ln,children:n}),q&&(0,Y.jsxs)(p,{sx:ln,children:[`0x`,r.toString(16).padStart(4,`0`)]})]})]})}function hn({filterPlugins:e,filterDevices:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(X),[s,c]=(0,G.useState)([]),[l,u]=(0,G.useState)({}),[d,f]=(0,G.useState)({}),[p,m]=(0,G.useState)({}),h=(0,G.useRef)(o()),g=(0,G.useCallback)(e=>{(q||Qt)&&console.log(`DevicesIcons received state_update "${e.response.cluster}.${e.response.attribute}" for "${e.response.id}:${e.response.number}": "${e.response.value}"`,e.response);let t=s.find(t=>t.pluginName===e.response.plugin&&t.serial===e.response.serialNumber);if(!t){(q||Qt)&&console.warn(`DevicesIcons updater device of plugin "${e.response.plugin}" serial "${e.response.serialNumber}" number "${e.response.number}" id "${e.response.id}" not found in devices(${s.length})`);return}let n=p[t.serial]?.find(t=>t.endpoint===e.response.number.toString()&&t.clusterName===e.response.cluster&&t.attributeName===e.response.attribute);if(!n){(q||Qt)&&console.warn(`DevicesIcons updater device "${t.name}" serial "${t.serial}" cluster "${e.response.cluster}" attribute "${e.response.attribute}" not found in clusters(${p[t.serial]?.length})`);return}n.attributeValue=String(e.response.value),n.attributeLocalValue=e.response.value,m({...p}),(q||Qt)&&console.log(`DevicesIcons updated "${n.clusterName}.${n.attributeName}" for device "${t.name}" serial "${t.serial}" to "${n.attributeValue}"`)},[p,s]),_=(0,G.useCallback)(e=>{if(q&&console.log(`DevicesIcons received for device "${e.response.deviceName}" serial "${e.response.serialNumber}" deviceTypes (${e.response.deviceTypes.length}) "${e.response.deviceTypes.join(`,`)}" clusters (${e.response.clusters.length}):`,e.response),e.response.clusters.length===0)return;let t=e.response.serialNumber;l[t]=[],d[t]=e.response.deviceTypes,p[t]=[];for(let n of e.response.clusters)l[t].find(e=>e.endpoint===n.endpoint)||l[t].push({endpoint:n.endpoint,id:n.id,deviceTypes:n.deviceTypes}),![`FixedLabel`,`Identify`,`Groups`,`PowerTopology`].includes(n.clusterName)&&p[t].push(n);u({...l}),f({...d}),m({...p}),q&&console.log(`DevicesIcons endpoints for "${t}":`,l[t]),q&&console.log(`DevicesIcons deviceTypes for "${t}":`,d[t]),q&&console.log(`DevicesIcons clusters for "${t}":`,p[t])},[p,d,l]);(0,G.useEffect)(()=>{let e=e=>{if(q&&console.log(`DevicesIcons received WebSocket Message:`,e),e.method===`refresh_required`)q&&console.log(`DevicesIcons received refresh_required: changed=${e.response.changed} and sending api requests`),r({id:h.current,sender:`DevicesIcons`,method:`/api/devices`,src:`Frontend`,dst:`Matterbridge`,params:{}});else if(e.method===`state_update`&&e.response)g(e);else if(e.method===`/api/devices`&&e.response){q&&console.log(`DevicesIcons received ${e.response.length} devices:`,e.response),c(e.response),u({}),f({}),m({});for(let t of e.response)q&&console.log(`DevicesIcons sending /api/clusters`),r({id:h.current,sender:`DevicesIcons`,method:`/api/clusters`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:t.pluginName,endpoint:t.endpoint||0,serialNumber:t.serial}})}else e.method===`/api/clusters`&&e.response&&_(e)};return i(e,h.current),q&&console.log(`DevicesIcons WebSocket effect mounted`),()=>{a(e),q&&console.log(`DevicesIcons WebSocket effect unmounted`)}},[s]),(0,G.useEffect)(()=>(q&&console.log(`DevicesIcons useEffect online mounting`),n&&(q&&console.log(`DevicesIcons useEffect online sending api requests`),r({id:h.current,sender:`DevicesIcons`,method:`/api/devices`,src:`Frontend`,dst:`Matterbridge`,params:{}})),q&&console.log(`DevicesIcons useEffect online mounted`),()=>{q&&console.log(`DevicesIcons useEffect online unmounted`)}),[n,r]);let v=(0,G.memo)(mn),y=e?.trim().toLowerCase(),b=y&&y!==`all plugins`;return q&&console.log(`DevicesIcons rendering...`),(0,Y.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,paddingBottom:`5px`,gap:`20px`,width:`100%`,overflow:`auto`},children:s.filter(e=>b&&e.pluginName.toLowerCase()!==y?!1:t===``?!0:e.name.toLowerCase().includes(t.toLowerCase())||e.serial.toLowerCase().includes(t.toLowerCase())).map(e=>l[e.serial]&&l[e.serial].map(t=>t.deviceTypes.map(n=>(0,Y.jsx)(v,{device:e,endpoint:t.endpoint,id:t.id,deviceType:n,clusters:p[e.serial].filter(e=>e.endpoint===t.endpoint)},`${e.pluginName}-${e.uniqueId}-${t.endpoint}-${t.id}-${n.toString()}`))))})}var gn=(0,G.memo)(hn);function _n(e){return e?e.scrollWidth>e.clientWidth:!1}function vn({title:e,children:t}){let n=(0,G.useRef)(null),[r,i]=(0,G.useState)(!1);return(0,Y.jsx)(H,{title:e,open:r,disableHoverListener:!0,disableFocusListener:!0,disableTouchListener:!0,slotProps:{tooltip:{sx:{fontSize:`14px`,fontWeight:`normal`,color:`#ffffff`,backgroundColor:`var(--primary-color)`}}},children:(0,Y.jsx)(`span`,{ref:n,onMouseEnter:()=>{i(_n(n.current))},onMouseLeave:()=>{i(!1)},style:{display:`inline-block`,maxWidth:`100%`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t})})}function yn(e,t,n){let r=e?.[n],i=t?.[n];return r==null&&i==null?0:r==null?-1:i==null?1:typeof r==`boolean`&&typeof i==`boolean`?r===i?0:r?1:-1:typeof r==`number`&&typeof i==`number`?r-i:String(r).localeCompare(String(i))}function bn({name:e,title:t,columns:n,rows:r,getRowKey:i,footerLeft:a,footerRight:o,onRowClick:s}){let c=(0,G.useRef)(new WeakMap),l=(0,G.useRef)(1),u=t=>{if(typeof i==`string`&&t&&t[i]!=null)return t[i];if(typeof i==`function`){let e=i(t);if(e!=null)return e}let r=n?.[0]?.id;if(r&&t&&t[r]!=null)return t[r];console.warn(`MbfTable(${e}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let a=c.current.get(t);return a||(a=`rk_${l.current++}`,c.current.set(t,a)),a},[f,p]=(0,G.useState)(localStorage.getItem(`${e}_table_order_by`)||null),[m,h]=(0,G.useState)(localStorage.getItem(`${e}_table_order`)||null),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(()=>{try{let t=localStorage.getItem(`${e}_column_visibility`);if(t)return JSON.parse(t)}catch{}return{}}),b=(0,G.useMemo)(()=>{let e={};for(let t of n)t.hidden||(e[t.id]=t.required?!0:v[t.id]!==!1);return e},[n,v]),S=(0,G.useMemo)(()=>{if(!f||!m)return r;let e=n.find(e=>e.id===f);if(!e||e.noSort)return r;let t=r.map((e,t)=>({el:e,index:t}));return t.sort((t,n)=>{let r;return r=typeof e.comparator==`function`?e.comparator(t.el,n.el):yn(t.el,n.el,f),r===0?t.index-n.index:m===`asc`?r:-r}),t.map(e=>e.el)},[r,f,m,n]),C=t=>{if(f!==t||!f){p(t),h(`asc`),localStorage.setItem(`${e}_table_order_by`,t),localStorage.setItem(`${e}_table_order`,`asc`);return}if(m===`asc`){h(`desc`),localStorage.setItem(`${e}_table_order`,`desc`);return}p(null),h(null),localStorage.removeItem(`${e}_table_order_by`),localStorage.removeItem(`${e}_table_order`)},w=()=>{_(!g)},E=t=>{y(r=>{let i=n.find(e=>e.id===t);if(i&&i.required)return r;let a=b[t]!==!1,o={...r};a?o[t]=!1:delete o[t];try{localStorage.setItem(`${e}_column_visibility`,JSON.stringify(o))}catch{}return o})},O=()=>{y({});try{localStorage.removeItem(`${e}_column_visibility`)}catch{}_(!1)},[k,A]=(0,G.useState)(!1);return k?null:(q&&console.log(`Rendering table ${e}${f&&m?` ordered by ${f}:${m}`:``}`),(0,Y.jsxs)(`div`,{style:{flex:`1 1 auto`,display:`flex`,flexDirection:`column`,margin:`0`,padding:`0`,gap:`0`,width:`100%`,height:`100%`,overflow:`hidden`},children:[(0,Y.jsxs)(D,{open:g,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||w()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[(0,Y.jsx)(F,{gap:`20px`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:`Configure ${e} columns`})]})}),(0,Y.jsx)(re,{children:(0,Y.jsx)(Le,{children:n.filter(e=>!e.hidden).map(e=>(0,Y.jsx)(d,{control:(0,Y.jsx)(M,{disabled:!!e.required,checked:e.required?!0:b[e.id]!==!1,onChange:()=>E(e.id)}),label:e.label},e.id))})}),(0,Y.jsxs)(x,{children:[(0,Y.jsx)(L,{onClick:O,children:`Reset`}),(0,Y.jsx)(L,{variant:`contained`,onClick:e=>{if(e?.currentTarget&&typeof e.currentTarget.blur==`function`)try{e.currentTarget.blur()}catch{}let t=document.activeElement;if(t&&t instanceof HTMLElement&&typeof t.blur==`function`)try{t.blur()}catch{}w()},children:`Close`})]})]}),(0,Y.jsxs)(Gt,{style:{height:`30px`,minHeight:`30px`,justifyContent:`space-between`,borderBottom:`none`},children:[(0,Y.jsx)(Kt,{children:e}),t&&(0,Y.jsx)(Kt,{children:t}),(0,Y.jsx)(Zt,{close:()=>A(!0),children:(0,Y.jsx)(T,{size:`small`,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},onClick:e=>{if(e?.currentTarget?.blur)try{e.currentTarget.blur()}catch{}w()},"aria-label":`Configure Columns`,children:(0,Y.jsx)(H,{title:`Configure ${e} columns`,children:(0,Y.jsx)(Z.Icon,{path:pt,size:`20px`,color:`var(--header-text-color)`})})})})]}),(0,Y.jsx)(Xt,{style:{flex:`1 1 auto`,display:`flex`,flexDirection:`column`,minHeight:0,width:`100%`,overflow:`auto`,margin:`0px`,padding:`0px`,gap:`0`},children:(0,Y.jsxs)(`table`,{"aria-label":`${e} table`,style:{width:`100%`,borderCollapse:`collapse`},children:[(0,Y.jsx)(`thead`,{style:{position:`sticky`,top:0,zIndex:10,border:`none`,color:`var(--header-text-color)`,backgroundColor:`var(--header-bg-color`},children:(0,Y.jsx)(`tr`,{style:{height:`30px`,minHeight:`30px`},children:n.map(e=>{if(e.hidden||!e.required&&b[e.id]===!1)return null;let t=!e.noSort,n=t&&f===e.id&&!!m;return(0,Y.jsxs)(`th`,{onClick:t?()=>C(e.id):void 0,style:{margin:`0`,padding:`5px 10px`,position:`sticky`,top:0,minWidth:e.minWidth,maxWidth:e.maxWidth,textAlign:e.align||`left`,cursor:t?`pointer`:`default`,border:`none`,color:`var(--header-text-color)`,backgroundColor:`var(--header-bg-color)`,whiteSpace:e.maxWidth?`nowrap`:void 0,overflow:e.maxWidth?`hidden`:void 0,textOverflow:e.maxWidth?`ellipsis`:void 0},"aria-sort":t?n?m===`asc`?`ascending`:`descending`:`none`:void 0,children:[e.label,n&&(0,Y.jsxs)(`span`,{style:{marginLeft:6},children:[m===`asc`&&(0,Y.jsx)(Z.Icon,{path:`M19 17H22L18 21L14 17H17V3H19M2 17H12V19H2M6 5V7H2V5M2 11H9V13H2V11Z`,size:`15px`}),m===`desc`&&(0,Y.jsx)(Z.Icon,{path:`M19 7H22L18 3L14 7H17V21H19M2 17H12V19H2M6 5V7H2V5M2 11H9V13H2V11Z`,size:`15px`})]})]},e.id)})})}),(0,Y.jsx)(`tbody`,{children:S.map((e,t)=>{let r=u(e);return(0,Y.jsx)(`tr`,{className:t%2==0?`table-content-even`:`table-content-odd`,onClick:s?t=>s(e,r,t):void 0,style:{height:`30px`,minHeight:`30px`,border:`none`,borderCollapse:`collapse`,cursor:s?`pointer`:void 0},children:n.map(t=>{if(t.hidden||!t.required&&b[t.id]===!1)return null;let n=e[t.id],i=typeof t.render==`function`?t.render(n,r,e,t):typeof n==`boolean`?(0,Y.jsx)(M,{checked:n,disabled:!0,size:`small`,sx:{m:0,p:0,color:`var(--table-text-color)`,"&.Mui-disabled":{color:`var(--table-text-color)`,opacity:.7}}}):t.format&&typeof n==`number`?t.format(n):n==null?null:String(n),a=t.tooltip&&t.maxWidth!==void 0&&t.maxWidth!==null&&n!=null&&i!==null?(0,Y.jsx)(vn,{title:String(n),children:i}):i;return(0,Y.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,textAlign:t.align||`left`,padding:`5px 10px`,margin:`0`,maxWidth:t.maxWidth,whiteSpace:t.maxWidth?`nowrap`:void 0,overflow:t.maxWidth?`hidden`:void 0,textOverflow:t.maxWidth?`ellipsis`:void 0},children:a},t.id)})},r)})})]})}),(a||o)&&(0,Y.jsxs)(qt,{style:{height:`30px`,minHeight:`30px`,justifyContent:`space-between`,border:`none`},children:[(0,Y.jsx)(Jt,{style:{fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`},children:a}),(0,Y.jsx)(Jt,{style:{fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`},children:o})]})]}))}function xn(e){return(0,G.memo)(e)}var Sn=xn(bn),Cn=[{label:`Plugin name`,id:`pluginName`,required:!0},{label:`Device type`,id:`type`},{label:`Endpoint`,id:`endpoint`,align:`right`},{label:`Name`,id:`name`,required:!0},{label:`Serial number`,id:`serial`},{label:`Unique ID`,id:`uniqueId`},{label:`Url`,id:`configUrl`},{label:`Config`,id:`configButton`,noSort:!0,render:(e,t,n,r)=>n.configUrl?(0,Y.jsx)(T,{onClick:()=>window.open(n.configUrl,`_blank`),"aria-label":`Open Config`,sx:{margin:0,padding:0},children:(0,Y.jsx)(b,{fontSize:`small`})}):null},{label:`Cluster`,id:`cluster`}],wn=[{label:`Endpoint`,id:`endpoint`,required:!0},{label:`Id`,id:`id`},{label:`Device Types`,id:`deviceTypes`,render:(e,t,n,r)=>Array.isArray(e)?(0,Y.jsx)(Y.Fragment,{children:e.map(e=>`0x${e.toString(16).padStart(4,`0`)}`).join(`, `)}):(0,Y.jsx)(Y.Fragment,{children:e})},{label:`Cluster Name`,id:`clusterName`,required:!0},{label:`Cluster ID`,id:`clusterId`},{label:`Attribute Name`,id:`attributeName`,required:!0},{label:`Attribute ID`,id:`attributeId`},{label:`Attribute Value`,id:`attributeValue`,required:!0,maxWidth:350,tooltip:!0}],Tn=e=>`${e.pluginName}::${e.uniqueId}`,En=e=>`${e.endpoint}::${e.clusterName}::${e.attributeName}`;function Dn({filterPlugins:e,filterDevices:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(X),[s,c]=(0,G.useState)([]),[l,u]=(0,G.useState)(s),[d,f]=(0,G.useState)([]),[p,m]=(0,G.useState)(0),[h,g]=(0,G.useState)(null),[_,v]=(0,G.useState)(null),[y,b]=(0,G.useState)(null),[x,S]=(0,G.useState)(null),C=(0,G.useRef)(o()),w=(0,G.useRef)(l),T=(0,G.useCallback)(e=>{q&&console.log(`DevicesTable received state_update "${e.response.cluster}.${e.response.attribute}" for "${e.response.id}:${e.response.number}": "${e.response.value}"`,e.response);let t=w.current.find(t=>t.pluginName===e.response.plugin&&t.uniqueId===e.response.uniqueId);if(!t){q&&console.warn(`DevicesTable updater device of plugin "${e.response.plugin}" serial "${e.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(h&&_&&t.pluginName===h&&t.uniqueId===x&&e.response.number.toString()===_){let n=d.find(t=>t.endpoint===e.response.number.toString()&&t.clusterName===e.response.cluster&&t.attributeName===e.response.attribute);if(!n){q&&console.warn(`DevicesTable updater cluster ${e.response.cluster}.${e.response.attribute} for device "${t.name}" serial "${t.serial}" not found in clusters`);return}n.attributeValue=typeof e.response.value==`object`?JSON.stringify(e.response.value,void 0,1).replaceAll(`"`,``):String(e.response.value),n.attributeLocalValue=e.response.value,f([...d]),q&&console.log(`DevicesTable updated attribute ${n.clusterName}.${n.attributeName} for device "${t.name}" serial "${t.serial}" to "${n.attributeValue}"`)}},[d,_,h,x]);return(0,G.useEffect)(()=>{let e=e=>{if(q&&console.log(`DevicesTable received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`devices`)q&&console.log(`DevicesTable received refresh_required: changed=${e.response.changed} and sending /api/devices request`),r({id:C.current,sender:`DevicesTable`,method:`/api/devices`,src:`Frontend`,dst:`Matterbridge`,params:{}});else if(e.method===`state_update`&&e.response)T(e);else if(e.method===`/api/devices`)q&&console.log(`DevicesTable received ${e.response.length} devices:`,e.response),c(e.response);else if(e.method===`/api/clusters`){q&&console.log(`DevicesTable received ${e.response.clusters.length} clusters for plugin ${e.response.plugin}:`,e.response),f(e.response.clusters);let t={};for(let n of e.response.clusters)q&&console.log(`Cluster:`,n.endpoint),t[n.endpoint]?t[n.endpoint]++:t[n.endpoint]=1;m(Object.keys(t).length)}};return i(e,C.current),q&&console.log(`DevicesTable added WebSocket listener`),()=>{a(e),q&&console.log(`DevicesTable removed WebSocket listener`)}},[r,i,a,T]),(0,G.useEffect)(()=>{n&&(q&&console.log(`DevicesTable sending api requests with id `,C.current),r({id:C.current,sender:`DevicesTable`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:C.current,sender:`DevicesTable`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:C.current,sender:`DevicesTable`,method:`/api/devices`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[n,r]),(0,G.useEffect)(()=>{h&&_&&x&&(q&&console.log(`DevicesTable sending /api/clusters`),r({id:C.current,sender:`DevicesTable`,method:`/api/clusters`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:h,endpoint:Number(_),uniqueId:x}}))},[h,_,x,r]),(0,G.useEffect)(()=>{let n=e?.trim().toLowerCase(),r=n&&n!==`all plugins`,i=s;r&&(i=i.filter(e=>e.pluginName.toLowerCase()===n)),t!==``&&(i=i.filter(e=>e.name.toLowerCase().includes(t.toLowerCase())||e.serial.toLowerCase().includes(t.toLowerCase()))),u(i),w.current=i},[s,e,t]),q&&console.log(`DevicesTable rendering...`),n?(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,margin:`0px`,padding:`0px`,gap:`20px`,width:`100%`,overflow:`hidden`},children:[(0,Y.jsx)(Q,{style:{margin:`0px`,padding:`0px`,gap:`0px`,width:`100%`,maxHeight:h&&_?`30%`:`100%`,flex:`1 1 auto`,overflow:`hidden`},children:(0,Y.jsx)(Sn,{name:`Registered devices`,getRowKey:Tn,onRowClick:e=>{if(e.uniqueId===x){S(null),g(null),v(null),b(null);return}q&&console.log(`DevicesTable handleDeviceClick: selected device "${e.name}" with uniqueId "${e.uniqueId}", plugin "${e.pluginName}", endpoint "${e.endpoint}"`),S(e.uniqueId),g(e.pluginName),v(e.endpoint?e.endpoint.toString():null),b(e.name)},rows:l,columns:Cn,footerLeft:`Total devices: ${l.length.toString()}`})}),h&&_&&(0,Y.jsx)(Q,{style:{margin:`0px`,padding:`0px`,gap:`0px`,width:`100%`,height:`70%`,maxHeight:`70%`,flex:`1 1 auto`,overflow:`hidden`},children:(0,Y.jsx)(Sn,{name:`Clusters`,title:y||``,getRowKey:En,rows:d,columns:wn,footerLeft:`Total child endpoints: ${p-1}`})})]}):(0,Y.jsx)(Wt,{})}var On=(0,G.memo)(Dn);function kn({children:e,style:t,name:n}){let{setCurrentPage:r}=(0,G.useContext)(Vt);return r(n),q&&console.log(`MbfPage: current page set to ${n}`),(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,margin:`0px`,padding:`0px`,gap:`20px`,...t},children:e})}function An(){let{online:e,sendMessage:t,addListener:n,removeListener:r,getUniqueId:i}=(0,G.useContext)(X),[a,o]=(0,G.useState)([`All plugins`]),[s,c]=(0,G.useState)(`All plugins`),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(`icon`),m=(0,G.useRef)(i());(0,G.useEffect)(()=>{let e=localStorage.getItem(K.devicesFilterPlugins);e&&c(e)},[]),(0,G.useEffect)(()=>{let e=localStorage.getItem(K.devicesFilterDevices);e&&u(e)},[]),(0,G.useEffect)(()=>{let e=localStorage.getItem(K.devicesViewMode);e&&f(e)},[]),(0,G.useEffect)(()=>{let e=e=>{q&&e.id&&console.log(`Devices received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`plugins`&&!e.response.lock?(q&&console.log(`Devices received refresh_required for plugins lock=${e.response.lock}, sending /api/plugins request with id ${m.current}`),t({id:m.current,sender:`Devices`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`/api/plugins`&&e.id===m.current&&e.response&&(q&&console.log(`Devices received ${e.response.length} plugins:`,e.response),o([`All plugins`,...e.response.map(e=>e.name)]))};return n(e,m.current),q&&console.log(`Devices added WebSocket listener`),()=>{r(e),q&&console.log(`Devices removed WebSocket listener`)}},[t,n,r]),(0,G.useEffect)(()=>{e&&(q&&console.log(`Devices sending /api/plugins request with id `,m.current),t({id:m.current,sender:`Devices`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[e,t]);let h=e=>{let t=e.target.value;c(t),localStorage.setItem(K.devicesFilterPlugins,t)},g=e=>{u(e.target.value),localStorage.setItem(K.devicesFilterDevices,e.target.value)},_=()=>{u(``),localStorage.removeItem(K.devicesFilterDevices)},v=e=>{f(e),localStorage.setItem(K.devicesViewMode,e)};return q&&console.log(`Devices rendering...`),e?(0,Y.jsxs)(kn,{name:`Devices`,children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,padding:0,margin:0,gap:`20px`,width:`100%`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,padding:0,margin:0,gap:`20px`},children:[(0,Y.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(p,{sx:{fontSize:`16px`,fontWeight:`normal`,color:`var(--div-text-color)`,marginLeft:`5px`,whiteSpace:`nowrap`},children:`Plugin:`}),(0,Y.jsx)(H,{title:`Filter devices by plugin`,children:(0,Y.jsx)(ye,{variant:`outlined`,value:s,onChange:h,sx:{width:`260px`,backgroundColor:`var(--main-bg-color)`,"& .MuiOutlinedInput-root":{backgroundColor:`var(--main-bg-color)`},"& .MuiSelect-select":{backgroundColor:`var(--main-bg-color)`},"& .MuiSelect-icon":{color:`var(--main-label-color)`}},input:(0,Y.jsx)(rt,{sx:{backgroundColor:`var(--main-bg-color)`}}),children:a.map(e=>(0,Y.jsx)(V,{value:e,children:e},e))})})]}),(0,Y.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(p,{sx:{fontSize:`16px`,fontWeight:`normal`,color:`var(--div-text-color)`,marginLeft:`5px`,whiteSpace:`nowrap`},children:`Filter by:`}),(0,Y.jsx)(H,{title:`Filter devices by name or serial number`,children:(0,Y.jsx)(B,{variant:`outlined`,value:l,onChange:g,placeholder:`Enter the device name or serial`,sx:{width:`260px`,"& .MuiOutlinedInput-root":{backgroundColor:`var(--main-bg-color)`}},slotProps:{input:{endAdornment:l?(0,Y.jsx)(y,{position:`end`,children:(0,Y.jsx)(T,{"aria-label":`Clear device filter`,size:`small`,onClick:_,edge:`end`,children:(0,Y.jsx)(Ee,{sx:{fontSize:18,color:`var(--main-label-color)`}})})}):null}}})})]})]}),(0,Y.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(p,{sx:{fontSize:`16px`,fontWeight:`normal`,color:`var(--div-text-color)`,marginLeft:`5px`,whiteSpace:`nowrap`},children:`View mode:`}),(0,Y.jsx)(T,{onClick:()=>v(`table`),"aria-label":`Table View`,disabled:d===`table`,children:(0,Y.jsx)(H,{title:`Table View`,children:(0,Y.jsx)(tt,{style:{color:d===`table`?`var(--main-icon-color)`:`var(--primary-color)`}})})}),(0,Y.jsx)(T,{onClick:()=>v(`icon`),"aria-label":`Icon View`,disabled:d===`icon`,children:(0,Y.jsx)(H,{title:`Icon View (beta)`,children:(0,Y.jsx)(ze,{style:{color:d===`icon`?`var(--main-icon-color)`:`var(--primary-color)`}})})})]})]}),d===`table`&&(0,Y.jsx)(On,{filterPlugins:s,filterDevices:l}),d===`icon`&&(0,Y.jsx)(gn,{filterPlugins:s,filterDevices:l})]}):(0,Y.jsx)(Wt,{})}var jn=(0,G.memo)(An);function Mn({version:e}){let{online:t}=(0,G.useContext)(X);return q&&console.log(`HomeBrowserRefresh rendering...`),t?(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`Frontend Update`})}),(0,Y.jsxs)(Xt,{style:{flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Y.jsxs)(`h4`,{style:{margin:0},children:[`The frontend has been updated to version `,e,`. You are viewing an outdated web UI. Please refresh the page now.`]}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(L,{onClick:()=>window.location.reload(),endIcon:(0,Y.jsx)(ne,{}),style:{marginLeft:`10px`,color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Refresh`})})]})]}):(0,Y.jsx)(Wt,{})}var Nn=(0,G.memo)(Mn);function Pn(e){if(q&&console.log(`getQRColor (id: ${e?.id}) received matter:`,e??`undefined`),e===void 0||!e.online||!e.qrPairingCode&&!e.manualPairingCode&&!e.fabricInformations&&!e.sessionInformations)return`red`;if(!e.commissioned&&e.qrPairingCode&&e.manualPairingCode)return`var(--primary-color)`;let t=0,n=0;for(let r of e.sessionInformations??[])r.fabric&&r.isPeerActive&&t++,r.numberOfActiveSubscriptions>0&&(n+=r.numberOfActiveSubscriptions);return e.commissioned&&e.fabricInformations&&e.sessionInformations&&(t===0||n===0)?`var(--secondary-color)`:`var(--div-text-color)`}var Fn=e=>`${e.pluginName}::${e.serial}`;function In({storeId:e,setStoreId:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(X),{mobile:s}=(0,G.useContext)(Vt),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!0),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)([]),[g,_]=(0,G.useState)([]),[v,y]=(0,G.useState)([]),[S,C]=(0,G.useState)([]),[w,E]=(0,G.useState)(null),O=(0,G.useRef)(o()),k=[{label:`Plugin`,id:`pluginName`},{label:`Name`,id:`name`,required:!0},{label:`Serial`,id:`serial`},{label:`Availability`,id:`availability`,render:(e,t,n,r)=>n.reachable===!0?`Online`:n.reachable===!1?(0,Y.jsx)(`span`,{style:{color:`red`},children:`Offline`}):``,comparator:(e,t)=>(e.reachable===!0?1:e.reachable===!1?0:-1)-(t.reachable===!0?1:t.reachable===!1?0:-1)},{label:`Power`,id:`powerSource`,render:(e,t,n,r)=>n.powerSource===`ac`||n.powerSource===`dc`?(0,Y.jsx)($e,{fontSize:`small`,sx:{color:`var(--primary-color)`}}):n.powerSource===`ok`?n.batteryLevel?(0,Y.jsx)(H,{title:`Battery level: ${n.batteryLevel}%`,children:(0,Y.jsx)(Ge,{fontSize:`small`,sx:{color:`green`}})}):(0,Y.jsx)(Ge,{fontSize:`small`,sx:{color:`gray`}}):n.powerSource===`warning`?n.batteryLevel?(0,Y.jsx)(H,{title:`Battery level: ${n.batteryLevel}%`,children:(0,Y.jsx)(Ge,{fontSize:`small`,sx:{color:`yellow`}})}):(0,Y.jsx)(Ge,{fontSize:`small`,sx:{color:`yellow`}}):n.powerSource===`critical`?n.batteryLevel?(0,Y.jsx)(H,{title:`Battery level: ${n.batteryLevel}%`,children:(0,Y.jsx)(Ge,{fontSize:`small`,sx:{color:`red`}})}):(0,Y.jsx)(Ge,{fontSize:`small`,sx:{color:`red`}}):(0,Y.jsx)(`span`,{})},{label:`Actions`,id:`selected`,required:!0,render:(n,r,i,a)=>(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`},children:[i.matter===void 0?(0,Y.jsx)(`div`,{style:{width:`20px`,height:`20px`}}):(0,Y.jsx)(H,{title:`Show the QRCode or the fabrics`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{onClick:()=>t(e===i.matter?.id?f?.matterbridgeInformation.bridgeMode===`bridge`?`Matterbridge`:null:i.matter?.id||null),"aria-label":`Show the QRCode`,sx:{margin:0,padding:0,color:Pn(i.matter)},children:(0,Y.jsx)(ee,{fontSize:`small`})})}),i.configUrl?(0,Y.jsx)(H,{title:`Open the configuration page`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{onClick:()=>N(i),"aria-label":`Open config url`,sx:{margin:0,padding:0},children:(0,Y.jsx)(b,{fontSize:`small`})})}):(0,Y.jsx)(`div`,{style:{width:`20px`,height:`20px`}}),i.selected===void 0?(0,Y.jsx)(`div`,{style:{width:`20px`,height:`20px`}}):(0,Y.jsx)(H,{title:`Select/unselect the device`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(M,{checked:i.selected,onChange:e=>j(e,i),sx:{margin:`0`,marginLeft:`8px`,padding:`0`},size:`small`})})]})}],A=(0,G.useCallback)(e=>{e.selected=void 0;let t=m.find(t=>t.name===e.pluginName);if(!t)return console.error(`HomeDevices isSelected: plugin ${e.pluginName} not found for device ${e.name} `),e.selected;let n=t.schemaJson?.properties?.whiteList?.selectFrom,r=t.configJson.postfix;return r===``&&(r=void 0),t.hasWhiteList===!0&&t.hasBlackList===!0&&n&&(e.selected=!0,n===`serial`&&t.configJson.whiteList&&t.configJson.whiteList.length>0&&t.configJson.whiteList.includes(r?e.serial.replace(`-`+r,``):e.serial)&&(e.selected=!0),n===`serial`&&t.configJson.whiteList&&t.configJson.whiteList.length>0&&!t.configJson.whiteList.includes(r?e.serial.replace(`-`+r,``):e.serial)&&(e.selected=!1),n===`serial`&&t.configJson.blackList&&t.configJson.blackList.length>0&&t.configJson.blackList.includes(r?e.serial.replace(`-`+r,``):e.serial)&&(e.selected=!1),n===`name`&&t.configJson.whiteList&&t.configJson.whiteList.length>0&&t.configJson.whiteList.includes(e.name)&&(e.selected=!0),n===`name`&&t.configJson.whiteList&&t.configJson.whiteList.length>0&&!t.configJson.whiteList.includes(e.name)&&(e.selected=!1),n===`name`&&t.configJson.blackList&&t.configJson.blackList.length>0&&t.configJson.blackList.includes(e.name)&&(e.selected=!1)),e.selected},[m]);(0,G.useEffect)(()=>{let e=e=>{if(q&&console.log(`HomeDevices received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed!==`matter`?e.response.changed===`plugins`&&e.response.lock?q&&console.log(`HomeDevices received refresh_required: changed=${e.response.changed} lock=${e.response.lock} skipping /api/plugins request`):(q&&console.log(`HomeDevices received refresh_required: changed=${e.response.changed} and sending /api/plugins request`),r({id:O.current,sender:`HomeDevices`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`refresh_required`&&e.response.changed===`matter`?(q&&console.log(`HomeDevices received refresh_required: changed=${e.response.changed} and setting matter id ${e.response.matter?.id}`),C(t=>{let n=t.findIndex(t=>t.name.replaceAll(` `,``)===e.response.matter?.id);if(n<0)return q&&console.debug(`HomeDevices: matter id ${e.response.matter?.id} not found`),t;let r=[...t];return r[n]={...r[n],matter:e.response.matter},q&&console.log(`HomeDevices received refresh_required: changed=${e.response.changed} and set matter id ${e.response.matter?.id}`),r})):e.method===`restart_required`?(q&&console.log(`HomeDevices received restart_required`),l(!0)):e.method===`restart_not_required`?(q&&console.log(`HomeDevices received restart_not_required`),l(!1)):e.method===`state_update`&&e.response.plugin&&e.response.serialNumber&&e.response.cluster.includes(`BasicInformation`)&&e.response.attribute===`reachable`&&(q&&console.log(`HomeDevices updating device reachability for plugin ${e.response.plugin} serial ${e.response.serialNumber} value ${e.response.value}`),_(t=>{let n=t.findIndex(t=>t.pluginName===e.response.plugin&&t.serial===e.response.serialNumber);return n<0?(q&&console.warn(`HomeDevices: device to update not found for plugin ${e.response.plugin} serial ${e.response.serialNumber}`),t):(t[n]={...t[n],reachable:e.response.value},[...t])})),e.id===O.current&&e.method===`/api/settings`)q&&console.log(`HomeDevices (id: ${e.id}) received settings:`,e.response),p(e.response),l(e.response.matterbridgeInformation.restartRequired||e.response.matterbridgeInformation.fixedRestartRequired);else if(e.id===O.current&&e.method===`/api/plugins`){if(q&&console.log(`HomeDevices (id: ${e.id}) received ${e.response?.length} plugins:`,e.response),e.response){let t=!0;for(let n of e.response)n.enabled&&(n.loaded!==!0||n.started!==!0||n.error===!0)&&(t=!1);if(!t)return;q&&console.log(`HomeDevices reset plugins, devices and selectDevices`),d(!1),h(e.response),_([]),y([]),r({id:O.current,sender:`HomeDevices`,method:`/api/devices`,src:`Frontend`,dst:`Matterbridge`,params:{}}),q&&console.log(`HomeDevices sent /api/devices`);for(let t of e.response)t.enabled&&t.loaded===!0&&t.started===!0&&t.error!==!0&&(r({id:O.current,sender:`HomeDevices`,method:`/api/select/devices`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:t.name}}),q&&console.log(`HomeDevices sent /api/select/devices for plugin: ${t.name}`))}}else if(e.id===O.current&&e.method===`/api/devices`){if(q&&console.log(`HomeDevices (id: ${e.id}) received ${e.response?.length} devices:`,e.response),e.response){for(let t of e.response)t.selected=A(t);_(e.response)}}else e.id===O.current&&e.method===`/api/select/devices`&&(q&&console.log(`HomeDevices (id: ${e.id}) received ${e.response?.length} selectDevices for plugin ${e.response&&e.response.length>0?e.response[0].pluginName:`without select devices`}:`,e.response),e.response&&e.response.length>0&&y(t=>{let n=t.filter(t=>t.pluginName!==e.response[0].pluginName),r=e.response.map(e=>({...e,selected:A(e)}));return[...n,...r]}))};return i(e,O.current),q&&console.log(`HomeDevices added WebSocket listener id ${O.current}`),()=>{a(e),q&&console.log(`HomeDevices removed WebSocket listener`)}},[m,i,a,r,A]),(0,G.useEffect)(()=>{if(g.length===0&&v.length===0){C([]);return}q&&console.log(`HomeDevices mixing devices (${g.length}) and selectDevices (${v.length})`);let e=[];for(let t of g)e.push(t);for(let t of v)g.find(e=>e.pluginName===t.pluginName&&e.serial.includes(t.serial))||e.push(t);e.length>0&&(C(e),q&&console.log(`HomeDevices mixed ${e.length} devices and selectDevices`))},[m,g,v,C]),(0,G.useEffect)(()=>{n&&(q&&console.log(`HomeDevices sending /api/settings and /api/plugins requests`),r({id:O.current,sender:`HomeDevices`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:O.current,sender:`HomeDevices`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[n,r]);let j=(e,t)=>{q&&console.log(`handleCheckboxChange: checkbox changed to ${e.target.checked} for device ${t.name} serial ${t.serial}`),g.findIndex(e=>e.pluginName===t.pluginName&&e.serial===t.serial)<0?(q&&console.warn(`handleCheckboxChange: device ${t.name} serial ${t.serial} not found in devices, trying in mixedDevices`),C(n=>{let r=n.findIndex(e=>e.pluginName===t.pluginName&&e.serial===t.serial);return r<0?(console.error(`handleCheckboxChange: device ${t.name} serial ${t.serial} not found in mixedDevices`),n):(n[r]={...n[r],selected:e.target.checked},[...n])})):_(n=>{let r=n.findIndex(e=>e.pluginName===t.pluginName&&e.serial===t.serial);return r<0?(console.error(`handleCheckboxChange: device ${t.name} serial ${t.serial} not found in devices`),n):(n[r]={...n[r],selected:e.target.checked},[...n])}),e.target.checked?r({id:O.current,sender:`HomeDevices`,method:`/api/command`,src:`Frontend`,dst:`Matterbridge`,params:{command:`selectdevice`,plugin:t.pluginName,serial:t.serial,name:t.name}}):r({id:O.current,sender:`HomeDevices`,method:`/api/command`,src:`Frontend`,dst:`Matterbridge`,params:{command:`unselectdevice`,plugin:t.pluginName,serial:t.serial,name:t.name}})},N=e=>{q&&console.log(`handleConfigUrl device:`,e.name,`configUrl:`,e.configUrl),e.configUrl&&(e.configUrl.startsWith(`/plugins/`)?E({name:e.name,path:e.configUrl}):window.open(e.configUrl,`_blank`))};return q&&console.log(`HomeDevices rendering...`),n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{style:{flex:`1 1 auto`},children:(0,Y.jsx)(Sn,{name:`Devices`,getRowKey:Fn,rows:S,columns:k,footerLeft:u?`Waiting for the plugins to fully load...`:`Registered devices: ${g.length.toString()}/${S.length.toString()}`,footerRight:c?`Restart required`:``})}),(0,Y.jsxs)(D,{open:w!==null,onClose:()=>E(null),slotProps:{paper:{sx:{width:J&&s?`100vw`:`75vw`,height:J&&s?`100vh`:`75vh`,maxWidth:J&&s?`100vw`:`75vw`,maxHeight:J&&s?`100vh`:`75vh`,margin:J&&s?`0px`:void 0,display:`flex`,flexDirection:`column`,overflow:`hidden`,backgroundColor:`var(--div-bg-color)`}}},children:[(0,Y.jsx)(re,{style:{display:`flex`,flex:`1 1 auto`,minHeight:0,padding:`0px`,margin:`0px`,overflow:`hidden`,backgroundColor:`var(--div-bg-color)`},children:w&&(0,Y.jsx)(`iframe`,{title:`${w.name} frontend`,src:w.path,onLoad:e=>{let t=e.currentTarget.contentDocument;if(!t?.head)return;let n=getComputedStyle(document.body),r=n.getPropertyValue(`--primary-color`).trim()||`#0d6efd`,i=n.getPropertyValue(`--div-bg-color`).trim()||`#111111`;t.getElementById(`matterbridge-plugin-scrollbar-style`)?.remove();let a=t.createElement(`style`);a.id=`matterbridge-plugin-scrollbar-style`,a.textContent=`
|
|
5
3
|
html,
|
|
6
4
|
body {
|
|
7
5
|
background-color: ${i};
|
|
@@ -21,7 +19,7 @@ import{a as e}from"./rolldown-runtime.js";import{c as t}from"./vendor_emotion.js
|
|
|
21
19
|
::-webkit-scrollbar-track {
|
|
22
20
|
background: ${i};
|
|
23
21
|
}
|
|
24
|
-
`,t.head.appendChild(a)},[F,re]=(0,G.useState)(),[ae,oe]=(0,G.useState)(!1),se=e=>{Q&&console.log(`handleConfigPlugin plugin:`,e.name),r({id:u.current,sender:`HomePlugins`,method:`/api/select/devices`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:e.name}}),r({id:u.current,sender:`HomePlugins`,method:`/api/select/entities`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:e.name}}),re(e),ce()},ce=()=>{oe(!0)};return Q&&console.log(`HomePlugins rendering...`),n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(X,{children:[F&&(0,K.jsx)(Bn,{open:ae,onClose:()=>{oe(!1)},plugin:F}),(0,K.jsx)(cn,{name:`Plugins`,columns:y,rows:h,footerRight:``,footerLeft:``})]}),(0,K.jsxs)(D,{open:_!==null,onClose:()=>v(null),slotProps:{paper:{sx:{width:$&&s?`100vw`:`75vw`,height:$&&s?`100vh`:`75vh`,maxWidth:$&&s?`100vw`:`75vw`,maxHeight:$&&s?`100vh`:`75vh`,margin:$&&s?`0px`:void 0,display:`flex`,flexDirection:`column`,overflow:`hidden`,backgroundColor:`var(--div-bg-color)`}}},children:[(0,K.jsx)(I,{style:{display:`flex`,flex:`1 1 auto`,minHeight:0,padding:`0px`,margin:`0px`,overflow:`hidden`,backgroundColor:`var(--div-bg-color)`},children:_&&(0,K.jsx)(`iframe`,{title:`${_.name} frontend`,src:_.path,onLoad:ne,style:{display:`block`,flex:`1 1 auto`,width:`100%`,height:`100%`,border:`none`,backgroundColor:`var(--div-bg-color)`}})}),(0,K.jsx)(x,{sx:{flex:`0 0 auto`,justifyContent:`center`},children:(0,K.jsx)(L,{onClick:()=>v(null),children:`Close`})})]})]}):(0,K.jsx)(Vt,{})}var Un=(0,G.memo)(Hn),Wn=e=>`${e.pluginName}::${e.serial}`;function Gn({storeId:e,setStoreId:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(J),{mobile:s}=(0,G.useContext)(It),[c,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(!0),[p,m]=(0,G.useState)(null),[h,g]=(0,G.useState)([]),[_,v]=(0,G.useState)([]),[y,b]=(0,G.useState)([]),[S,C]=(0,G.useState)([]),[w,O]=(0,G.useState)(null),k=(0,G.useRef)(o()),A=[{label:`Plugin`,id:`pluginName`},{label:`Name`,id:`name`,required:!0},{label:`Serial`,id:`serial`},{label:`Availability`,id:`availability`,render:(e,t,n,r)=>n.reachable===!0?`Online`:n.reachable===!1?(0,K.jsx)(`span`,{style:{color:`red`},children:`Offline`}):``,comparator:(e,t)=>(e.reachable===!0?1:e.reachable===!1?0:-1)-(t.reachable===!0?1:t.reachable===!1?0:-1)},{label:`Power`,id:`powerSource`,render:(e,t,n,r)=>n.powerSource===`ac`||n.powerSource===`dc`?(0,K.jsx)(E,{fontSize:`small`,sx:{color:`var(--primary-color)`}}):n.powerSource===`ok`?n.batteryLevel?(0,K.jsx)(H,{title:`Battery level: ${n.batteryLevel}%`,children:(0,K.jsx)(j,{fontSize:`small`,sx:{color:`green`}})}):(0,K.jsx)(j,{fontSize:`small`,sx:{color:`gray`}}):n.powerSource===`warning`?n.batteryLevel?(0,K.jsx)(H,{title:`Battery level: ${n.batteryLevel}%`,children:(0,K.jsx)(j,{fontSize:`small`,sx:{color:`yellow`}})}):(0,K.jsx)(j,{fontSize:`small`,sx:{color:`yellow`}}):n.powerSource===`critical`?n.batteryLevel?(0,K.jsx)(H,{title:`Battery level: ${n.batteryLevel}%`,children:(0,K.jsx)(j,{fontSize:`small`,sx:{color:`red`}})}):(0,K.jsx)(j,{fontSize:`small`,sx:{color:`red`}}):(0,K.jsx)(`span`,{})},{label:`Actions`,id:`selected`,required:!0,render:(n,r,i,a)=>(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`},children:[i.matter===void 0?(0,K.jsx)(`div`,{style:{width:`20px`,height:`20px`}}):(0,K.jsx)(H,{title:`Show the QRCode or the fabrics`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,K.jsx)(T,{onClick:()=>t(e===i.matter?.id?p?.matterbridgeInformation.bridgeMode===`bridge`?`Matterbridge`:null:i.matter?.id||null),"aria-label":`Show the QRCode`,sx:{margin:0,padding:0,color:Vn(i.matter)},children:(0,K.jsx)(l,{fontSize:`small`})})}),i.configUrl?(0,K.jsx)(H,{title:`Open the configuration page`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,K.jsx)(T,{onClick:()=>te(i),"aria-label":`Open config url`,sx:{margin:0,padding:0},children:(0,K.jsx)(ae,{fontSize:`small`})})}):(0,K.jsx)(`div`,{style:{width:`20px`,height:`20px`}}),i.selected===void 0?(0,K.jsx)(`div`,{style:{width:`20px`,height:`20px`}}):(0,K.jsx)(H,{title:`Select/unselect the device`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,K.jsx)(M,{checked:i.selected,onChange:e=>N(e,i),sx:{margin:`0`,marginLeft:`8px`,padding:`0`},size:`small`})})]})}],ee=(0,G.useCallback)(e=>{e.selected=void 0;let t=h.find(t=>t.name===e.pluginName);if(!t)return console.error(`HomeDevices isSelected: plugin ${e.pluginName} not found for device ${e.name} `),e.selected;let n=t.schemaJson?.properties?.whiteList?.selectFrom,r=t.configJson.postfix;return r===``&&(r=void 0),t.hasWhiteList===!0&&t.hasBlackList===!0&&n&&(e.selected=!0,n===`serial`&&t.configJson.whiteList&&t.configJson.whiteList.length>0&&t.configJson.whiteList.includes(r?e.serial.replace(`-`+r,``):e.serial)&&(e.selected=!0),n===`serial`&&t.configJson.whiteList&&t.configJson.whiteList.length>0&&!t.configJson.whiteList.includes(r?e.serial.replace(`-`+r,``):e.serial)&&(e.selected=!1),n===`serial`&&t.configJson.blackList&&t.configJson.blackList.length>0&&t.configJson.blackList.includes(r?e.serial.replace(`-`+r,``):e.serial)&&(e.selected=!1),n===`name`&&t.configJson.whiteList&&t.configJson.whiteList.length>0&&t.configJson.whiteList.includes(e.name)&&(e.selected=!0),n===`name`&&t.configJson.whiteList&&t.configJson.whiteList.length>0&&!t.configJson.whiteList.includes(e.name)&&(e.selected=!1),n===`name`&&t.configJson.blackList&&t.configJson.blackList.length>0&&t.configJson.blackList.includes(e.name)&&(e.selected=!1)),e.selected},[h]);(0,G.useEffect)(()=>{let e=e=>{if(Q&&console.log(`HomeDevices received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed!==`matter`?e.response.changed===`plugins`&&e.response.lock?Q&&console.log(`HomeDevices received refresh_required: changed=${e.response.changed} lock=${e.response.lock} skipping /api/plugins request`):(Q&&console.log(`HomeDevices received refresh_required: changed=${e.response.changed} and sending /api/plugins request`),r({id:k.current,sender:`HomeDevices`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`refresh_required`&&e.response.changed===`matter`?(Q&&console.log(`HomeDevices received refresh_required: changed=${e.response.changed} and setting matter id ${e.response.matter?.id}`),C(t=>{let n=t.findIndex(t=>t.name.replaceAll(` `,``)===e.response.matter?.id);if(n<0)return Q&&console.debug(`HomeDevices: matter id ${e.response.matter?.id} not found`),t;let r=[...t];return r[n]={...r[n],matter:e.response.matter},Q&&console.log(`HomeDevices received refresh_required: changed=${e.response.changed} and set matter id ${e.response.matter?.id}`),r})):e.method===`restart_required`?(Q&&console.log(`HomeDevices received restart_required`),u(!0)):e.method===`restart_not_required`?(Q&&console.log(`HomeDevices received restart_not_required`),u(!1)):e.method===`state_update`&&e.response.plugin&&e.response.serialNumber&&e.response.cluster.includes(`BasicInformation`)&&e.response.attribute===`reachable`&&(Q&&console.log(`HomeDevices updating device reachability for plugin ${e.response.plugin} serial ${e.response.serialNumber} value ${e.response.value}`),v(t=>{let n=t.findIndex(t=>t.pluginName===e.response.plugin&&t.serial===e.response.serialNumber);return n<0?(Q&&console.warn(`HomeDevices: device to update not found for plugin ${e.response.plugin} serial ${e.response.serialNumber}`),t):(t[n]={...t[n],reachable:e.response.value},[...t])})),e.id===k.current&&e.method===`/api/settings`)Q&&console.log(`HomeDevices (id: ${e.id}) received settings:`,e.response),m(e.response),u(e.response.matterbridgeInformation.restartRequired||e.response.matterbridgeInformation.fixedRestartRequired);else if(e.id===k.current&&e.method===`/api/plugins`){if(Q&&console.log(`HomeDevices (id: ${e.id}) received ${e.response?.length} plugins:`,e.response),e.response){let t=!0;for(let n of e.response)n.enabled===!0&&(n.loaded!==!0||n.started!==!0||n.error===!0)&&(t=!1);if(!t)return;Q&&console.log(`HomeDevices reset plugins, devices and selectDevices`),f(!1),g(e.response),v([]),b([]),r({id:k.current,sender:`HomeDevices`,method:`/api/devices`,src:`Frontend`,dst:`Matterbridge`,params:{}}),Q&&console.log(`HomeDevices sent /api/devices`);for(let t of e.response)t.enabled===!0&&t.loaded===!0&&t.started===!0&&t.error!==!0&&(r({id:k.current,sender:`HomeDevices`,method:`/api/select/devices`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:t.name}}),Q&&console.log(`HomeDevices sent /api/select/devices for plugin: ${t.name}`))}}else if(e.id===k.current&&e.method===`/api/devices`){if(Q&&console.log(`HomeDevices (id: ${e.id}) received ${e.response?.length} devices:`,e.response),e.response){for(let t of e.response)t.selected=ee(t);v(e.response)}}else e.id===k.current&&e.method===`/api/select/devices`&&(Q&&console.log(`HomeDevices (id: ${e.id}) received ${e.response?.length} selectDevices for plugin ${e.response&&e.response.length>0?e.response[0].pluginName:`without select devices`}:`,e.response),e.response&&e.response.length>0&&b(t=>{let n=t.filter(t=>t.pluginName!==e.response[0].pluginName),r=e.response.map(e=>({...e,selected:ee(e)}));return[...n,...r]}))};return i(e,k.current),Q&&console.log(`HomeDevices added WebSocket listener id ${k.current}`),()=>{a(e),Q&&console.log(`HomeDevices removed WebSocket listener`)}},[h,i,a,r,ee]),(0,G.useEffect)(()=>{if(_.length===0&&y.length===0){C([]);return}Q&&console.log(`HomeDevices mixing devices (${_.length}) and selectDevices (${y.length})`);let e=[];for(let t of _)e.push(t);for(let t of y)_.find(e=>e.pluginName===t.pluginName&&e.serial.includes(t.serial))||e.push(t);e.length>0&&(C(e),Q&&console.log(`HomeDevices mixed ${e.length} devices and selectDevices`))},[h,_,y,C]),(0,G.useEffect)(()=>{n&&(Q&&console.log(`HomeDevices sending /api/settings and /api/plugins requests`),r({id:k.current,sender:`HomeDevices`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:k.current,sender:`HomeDevices`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[n,r]);let N=(e,t)=>{Q&&console.log(`handleCheckboxChange: checkbox changed to ${e.target.checked} for device ${t.name} serial ${t.serial}`),_.findIndex(e=>e.pluginName===t.pluginName&&e.serial===t.serial)<0?(Q&&console.warn(`handleCheckboxChange: device ${t.name} serial ${t.serial} not found in devices, trying in mixedDevices`),C(n=>{let r=n.findIndex(e=>e.pluginName===t.pluginName&&e.serial===t.serial);return r<0?(console.error(`handleCheckboxChange: device ${t.name} serial ${t.serial} not found in mixedDevices`),n):(n[r]={...n[r],selected:e.target.checked},[...n])})):v(n=>{let r=n.findIndex(e=>e.pluginName===t.pluginName&&e.serial===t.serial);return r<0?(console.error(`handleCheckboxChange: device ${t.name} serial ${t.serial} not found in devices`),n):(n[r]={...n[r],selected:e.target.checked},[...n])}),e.target.checked?r({id:k.current,sender:`HomeDevices`,method:`/api/command`,src:`Frontend`,dst:`Matterbridge`,params:{command:`selectdevice`,plugin:t.pluginName,serial:t.serial,name:t.name}}):r({id:k.current,sender:`HomeDevices`,method:`/api/command`,src:`Frontend`,dst:`Matterbridge`,params:{command:`unselectdevice`,plugin:t.pluginName,serial:t.serial,name:t.name}})},te=e=>{Q&&console.log(`handleConfigUrl device:`,e.name,`configUrl:`,e.configUrl),e.configUrl&&(e.configUrl.startsWith(`/plugins/`)?O({name:e.name,path:e.configUrl}):window.open(e.configUrl,`_blank`))};return Q&&console.log(`HomeDevices rendering...`),n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{style:{flex:`1 1 auto`},children:(0,K.jsx)(cn,{name:`Devices`,getRowKey:Wn,rows:S,columns:A,footerLeft:d?`Waiting for the plugins to fully load...`:`Registered devices: ${_.length.toString()}/${S.length.toString()}`,footerRight:c?`Restart required`:``})}),(0,K.jsxs)(D,{open:w!==null,onClose:()=>O(null),slotProps:{paper:{sx:{width:$&&s?`100vw`:`75vw`,height:$&&s?`100vh`:`75vh`,maxWidth:$&&s?`100vw`:`75vw`,maxHeight:$&&s?`100vh`:`75vh`,margin:$&&s?`0px`:void 0,display:`flex`,flexDirection:`column`,overflow:`hidden`,backgroundColor:`var(--div-bg-color)`}}},children:[(0,K.jsx)(I,{style:{display:`flex`,flex:`1 1 auto`,minHeight:0,padding:`0px`,margin:`0px`,overflow:`hidden`,backgroundColor:`var(--div-bg-color)`},children:w&&(0,K.jsx)(`iframe`,{title:`${w.name} frontend`,src:w.path,onLoad:e=>{let t=e.currentTarget.contentDocument;if(!t?.head)return;let n=getComputedStyle(document.body),r=n.getPropertyValue(`--primary-color`).trim()||`#0d6efd`,i=n.getPropertyValue(`--div-bg-color`).trim()||`#111111`;t.getElementById(`matterbridge-plugin-scrollbar-style`)?.remove();let a=t.createElement(`style`);a.id=`matterbridge-plugin-scrollbar-style`,a.textContent=`
|
|
22
|
+
`,t.head.appendChild(a)},style:{display:`block`,flex:`1 1 auto`,width:`100%`,height:`100%`,border:`none`,backgroundColor:`var(--div-bg-color)`}})}),(0,Y.jsx)(x,{sx:{flex:`0 0 auto`,justifyContent:`center`},children:(0,Y.jsx)(L,{onClick:()=>E(null),children:`Close`})})]})]}):(0,Y.jsx)(Wt,{})}var Ln=(0,G.memo)(In),Rn=[`matterbridge-`,`matterbridge-plugin-template`,`matterbridge-dyson`,`matterbridge-tuya`,`matterbridge-matter`,`matterbridge-automations`,`matterbridge-securitysystem`,`matterbridge-adapter`],zn=e=>e.replace(`git+`,``).replace(`.git`,``).trim(),Bn=e=>{let t=zn(e);return t.startsWith(`git://`)&&(t=`https://${t.slice(6)}`),t.startsWith(`ssh://git@github.com/`)&&(t=`https://github.com/${t.slice(21)}`),t.startsWith(`git@github.com:`)&&(t=`https://github.com/${t.slice(15).replace(`:`,`/`)}`),t},Vn=e=>{if(typeof e==`string`)return e.trim()||null;if(!e||typeof e!=`object`)return null;let t=e.url;return typeof t==`string`&&t.trim()||null},Hn=()=>{try{let e=window.localStorage.getItem(K.searchPluginsTotal);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.total==`number`&&typeof t.asOf==`string`&&(n[e]={total:t.total,asOf:t.asOf})}return n}catch{return{}}},Un=e=>{try{window.localStorage.setItem(K.searchPluginsTotal,JSON.stringify(e))}catch{}},Wn=()=>{try{let e=window.localStorage.getItem(K.searchPluginsMeta);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.asOf==`string`&&(n[e]={homepage:typeof t.homepage==`string`?t.homepage:null,help:typeof t.help==`string`?t.help:null,changelog:typeof t.changelog==`string`?t.changelog:null,asOf:t.asOf})}return n}catch{return{}}},Gn=e=>{try{window.localStorage.setItem(K.searchPluginsMeta,JSON.stringify(e))}catch{}},Kn=()=>{try{let e=window.localStorage.getItem(K.searchPluginsVersions);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.asOf==`string`&&Array.isArray(t.versions)&&(n[e]={versions:t.versions.filter(e=>typeof e==`string`),asOf:t.asOf})}return n}catch{return{}}},qn=e=>{try{window.localStorage.setItem(K.searchPluginsVersions,JSON.stringify(e))}catch{}},Jn=({open:e,onClose:t,onSelect:n,onVersions:r})=>{let{mobile:i}=(0,G.useContext)(Vt),[a,o]=(0,G.useState)(``),s=(0,G.useRef)(``),c=(0,G.useRef)(!1),l=(0,G.useRef)(null),[u,d]=(0,G.useState)([]),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[_,y]=(0,G.useState)(!1),[b,S]=(0,G.useState)({done:0,total:0}),[C,w]=(0,G.useState)(null),E=(0,G.useRef)({}),O=()=>{let e=document.activeElement;e&&e instanceof HTMLElement&&e.blur()},k=e=>`${e.getFullYear().toString()}-${(e.getMonth()+1).toString().padStart(2,`0`)}-${e.getDate().toString().padStart(2,`0`)}`,A=(0,G.useCallback)(async(e,t)=>{let n=E.current[e];if(n&&n.asOf===t&&Array.isArray(n.versions)&&n.versions.length>0&&n.versions[0]===`latest`)return q&&console.log(`[SearchPluginsDialog] versions cache hit for ${e} (${n.versions.length.toString()})`),n.versions;n&&n.asOf===t&&n.versions.length>0&&n.versions[0]!==`latest`&&q&&console.log(`[SearchPluginsDialog] versions cache ignored (old format) for ${e} (asOf=${t})`);let r=`https://registry.npmjs.org/${encodeURIComponent(e)}`;q&&console.log(`[SearchPluginsDialog] fetching versions for ${e} from: ${r}`);let i=await fetch(r,{signal:l.current?.signal});if(!i.ok)return q&&console.log(`[SearchPluginsDialog] versions fetch failed for ${e}: ${i.status.toString()} ${i.statusText}`),[];let a=await i.json(),o=Object.keys(a.versions??{}),s=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`});o.sort((e,t)=>s.compare(e,t)).reverse();let c=a[`dist-tags`]??{},u=typeof c?.dev==`string`&&String(c.dev).trim().length>0,d=o.slice(0,20),f=[`latest`];return u&&f.push(`dev`),f.push(...d),q&&console.log(`[SearchPluginsDialog] fetched versions for ${e} (tags: latest${u?`, dev`:``}; latestVersions=${d.length.toString()}; allVersions=${o.length.toString()}):`,f),E.current[e]={versions:f,asOf:t},qn(E.current),f},[]),j=e=>new Intl.NumberFormat().format(e),M=[{label:`Name`,id:`name`,required:!0,maxWidth:230,tooltip:!0},{label:`Version`,id:`version`,required:!0,maxWidth:110,tooltip:!0},{label:`Monthly`,id:`downloads`,align:`right`,maxWidth:120,render:e=>typeof e==`number`?j(e):``},{label:`Total`,id:`total`,align:`right`,maxWidth:120,render:e=>typeof e==`number`?j(e):``},{label:`Description`,id:`description`,required:!0,maxWidth:300,tooltip:!0},{label:`Author`,id:`author`,maxWidth:140,tooltip:!0},{label:`Action`,id:`action`,align:`center`,maxWidth:100,noSort:!0,required:!0,render:(e,t,n,r)=>(0,Y.jsxs)(`div`,{style:{margin:`0`,padding:`0`,gap:`4px`,display:`flex`,flexDirection:`row`,justifyContent:`center`},children:[(0,Y.jsx)(H,{title:n.homepage?`Open the plugin homepage`:`No homepage available`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.homepage,onClick:e=>{if(e.stopPropagation(),n.homepage)try{let e=new URL(n.homepage);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,Y.jsx)(ce,{})})})}),(0,Y.jsx)(H,{title:n.help?`Open the plugin help`:`No help available`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.help,onClick:e=>{if(e.stopPropagation(),n.help)try{let e=new URL(n.help);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,Y.jsx)(g,{})})})}),(0,Y.jsx)(H,{title:n.changelog?`Open the plugin changelog`:`No changelog available`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.changelog,onClick:e=>{if(e.stopPropagation(),n.changelog)try{let e=new URL(n.changelog);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,Y.jsx)(v,{})})})})]})}];(0,G.useEffect)(()=>{if(!e){c.current=!1,s.current=``,l.current?.abort(),l.current=null,d([]),p(!1),h(!1),y(!1),S({done:0,total:0}),w(null),o(``);return}if(c.current)return;c.current=!0;let t=new AbortController;return l.current=t,E.current=Kn(),(async()=>{let e=`matterbridge-`,n=e=>new Promise(t=>setTimeout(t,e)),r=e=>{if(!Array.isArray(e.downloads))return null;let t=0,n=!1;for(let r of e.downloads)typeof r?.downloads==`number`&&(t+=r.downloads,n=!0);return n?t:null};try{p(!0),w(null);let i=e=>{let t=String(e??``).trim().toLowerCase();return t?!!(t===`github actions`||t===`github-actions`||t===`github-actions[bot]`||t.includes(`github-actions`)||t.endsWith(`[bot]`)):!1},a=e=>{let t=(e.maintainers??[]).map(e=>(e.username??``).trim()).filter(Boolean),n=(e.publisher?.username??``).trim();return t.find(e=>!i(e))||(n&&!i(n)?n:t[0]??n??``)},o=await fetch(`https://registry.npmjs.org/-/v1/search?text=matterbridge-&size=250`,{signal:t.signal});if(!o.ok)throw Error(`npm registry request failed: ${o.status} ${o.statusText}`);let s=await o.json(),c=`luligu`,l=e=>e.publisher?.username?.toLowerCase()===c||(e.maintainers??[]).some(e=>e.username?.toLowerCase()===c),u=(s.objects??[]).filter(e=>!!e?.package&&typeof e.package.name==`string`).filter(t=>t.package?.name?.startsWith(e)).filter(e=>!Rn.includes(e.package?.name??``)).sort((e,t)=>{let n=l(e.package??{});return n===l(t.package??{})?(e.package?.name??``).localeCompare(t.package?.name??``):n?-1:1}).map(e=>{let t=e.package,n=t.name??``,r=a(t),i=typeof e.downloads?.monthly==`number`?e.downloads.monthly:null,o=(t.links?.npm??``).trim(),s=((t.links?.homepage??``).trim()||o||(n?`https://www.npmjs.com/package/${encodeURIComponent(n)}`:``)).trim()||null;return{name:n,version:t.version??``,downloads:i,total:null,description:t.description??``,author:r,official:l(t),homepage:s,help:null,changelog:null}}),f=k(new Date),m=Hn(),h=Wn();d(u.map(e=>{let t=m[e.name];return!t||typeof t.total!=`number`?e:(q&&console.log(`[SearchPluginsDialog] total downloads loaded from cache for ${e.name} (asOf=${t.asOf}):`,t.total),{...e,total:t.total})}).map(e=>{let t=h[e.name];if(!t||t.asOf!==f)return e;let n=t.homepage??e.homepage,r=t.help,i=t.changelog;return q&&(r||i||n&&n!==e.homepage)&&console.log(`[SearchPluginsDialog] metadata loaded from cache for ${e.name} (asOf=${t.asOf}):`,{homepage:n,help:r,changelog:i}),{...e,homepage:n,help:r,changelog:i}}));let g=u.map(e=>e.name).filter(e=>{let t=E.current[e];return!t||t.asOf!==f||t.versions.length===0});q&&console.log(`[SearchPluginsDialog] versions prefetch queue (${g.length.toString()}):`,g);let _=0,v=async()=>{for(;_<g.length;){if(t.signal.aborted)return;let e=_;_+=1;let r=g[e];if(r)try{let e=await A(r,f);q&&e.length>0&&console.log(`[SearchPluginsDialog] versions fetched for ${r} (${e.length.toString()}):`,e.slice(0,5))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return}finally{t.signal.aborted||await n(200)}}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>v()));let b=u.map(e=>e.name).filter(e=>{let t=h[e],n=!!t&&t.asOf===f,r=!!t&&!!t.help&&!!t.changelog,i=!n||!r;return!i&&q&&console.log(`[SearchPluginsDialog] metadata fetch skipped (cache fresh+complete) for ${e} (asOf=${t.asOf}).`),n&&!r&&q&&console.log(`[SearchPluginsDialog] metadata fetch forced (cache incomplete) for ${e} (asOf=${t.asOf}).`),i}),x=new Set(b),C=async(e,n)=>{let r=`https://registry.npmjs.org/${encodeURIComponent(e)}/latest`;try{let e=await fetch(r,{signal:t.signal});if(!e.ok)return null;let i=await e.json(),a=typeof i.homepage==`string`&&i.homepage.includes(`http`)?zn(i.homepage):null,o=typeof i.help==`string`&&i.help.startsWith(`http`)?i.help.trim():null,s=typeof i.changelog==`string`&&i.changelog.startsWith(`http`)?i.changelog.trim():null,c=Vn(i.repository),l=c?Bn(c):null,u=l&&l.includes(`http`)?l:null,d=a||u||n||null;return{homepage:d,help:o||(u?`${u}/blob/main/README.md`:null)||d||null,changelog:s||(u?`${u}/blob/main/CHANGELOG.md`:null)||d||null}}catch(e){return e instanceof DOMException&&e.name,null}},T=0,D=async()=>{for(;T<b.length;){if(t.signal.aborted)return;let e=T;T+=1;let r=b[e];if(!r||!x.has(r))continue;x.delete(r);let i=await C(r,u.find(e=>e.name===r)?.homepage??null);if(t.signal.aborted)return;i&&(d(e=>e.map(e=>e.name===r?{...e,homepage:i.homepage??e.homepage,help:i.help,changelog:i.changelog}:e)),h[r]={homepage:i.homepage,help:i.help,changelog:i.changelog,asOf:f},Gn(h)),t.signal.aborted||await n(250)}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>D()));let O=`2020-01-01`,j=u.map(e=>e.name).filter(e=>{let t=m[e],n=!t||t.asOf!==f;return n||q&&console.log(`[SearchPluginsDialog] total downloads fetch skipped (cache fresh) for ${e} (asOf=${t.asOf}).`),n}),M=new Set(j),N=j.length;S({done:0,total:N}),y(N>0);let P=async e=>{let i=`https://api.npmjs.org/downloads/range/${O}:${f}/${encodeURIComponent(e)}`;for(let e=0;e<3;e+=1){let a=await fetch(i,{signal:t.signal});if(a.ok)return r(await a.json());if(a.status===404)return null;if(a.status===429){let t=a.headers.get(`retry-after`),r=t?Number(t):NaN;await n(Number.isFinite(r)?r*1e3:2e3*(e+1));continue}return null}return null},ee=0,F=0,te=async()=>{for(;ee<j.length;){if(t.signal.aborted)return;let e=ee;ee+=1;let r=j[e];if(r&&M.has(r)){M.delete(r);try{q&&console.log(`[SearchPluginsDialog] fetching total downloads for ${r} (range ${O}:${f})...`);let e=await P(r);if(t.signal.aborted)return;q&&console.log(`[SearchPluginsDialog] total downloads fetched for ${r}:`,e),d(t=>t.map(t=>t.name===r?{...t,total:e}:t)),typeof e==`number`&&(m[r]={total:e,asOf:f},Un(m),q&&console.log(`[SearchPluginsDialog] total downloads saved to localStorage for ${r} (asOf=${f}):`,e))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return}finally{F+=1,S({done:F,total:N}),t.signal.aborted||await n(500)}}}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>te())).finally(()=>{t.signal.aborted||y(!1)}),q&&console.log(`[SearchPluginsDialog] npm packages starting with "${e}" (filtered/sorted):`,u)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;console.error(`[SearchPluginsDialog] npm registry fetch error:`,e),w(e instanceof Error?e.message:String(e))}finally{p(!1)}})(),()=>t.abort()},[e,A]);let N=async()=>{O();let e=s.current||a;if(!(!e||m))try{h(!0);let t=await A(e,k(new Date));q&&console.log(`[SearchPluginsDialog] passing versions to onVersions() for ${e} (${t.length.toString()}):`,t),r(t),h(!1),n(e)}catch(t){if(t instanceof DOMException&&t.name===`AbortError`)return;console.error(`[SearchPluginsDialog] npm versions fetch error:`,t),r([]),h(!1),n(e)}},P=()=>{O(),t(),r([])},ee=u.reduce((e,t)=>e+(typeof t.downloads==`number`?t.downloads:0),0),te=u.reduce((e,t)=>(typeof t.total==`number`&&(e.total+=t.total,e.hasAny=!0),e),{total:0,hasAny:!1}),I=_?` Totals: ${b.done.toString()}/${b.total.toString()} fetched`:``,ne=te.hasAny?j(te.total):`...`;return(0,Y.jsxs)(D,{open:e,onClose:()=>{O(),t()},maxWidth:!1,fullWidth:!0,slotProps:{paper:{sx:{width:J&&i?`100vw`:`75vw`,height:J&&i?`100vh`:`75vh`,maxWidth:J&&i?`100vw`:`75vw`,maxHeight:J&&i?`100vh`:`75vh`,margin:J&&i?`0px`:void 0,display:`flex`,flexDirection:`column`}}},children:[(0,Y.jsx)(F,{children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:`Search Plugins`})]})}),(0,Y.jsx)(re,{dividers:!0,sx:{padding:`10px`,flex:`1 1 auto`,minHeight:0},children:(0,Y.jsx)(`div`,{style:{height:`100%`,width:`100%`,display:`flex`,flexDirection:`column`,minHeight:0},children:f?(0,Y.jsx)(`div`,{style:{padding:`20px`},children:`Loading npm registry...`}):C?(0,Y.jsx)(`div`,{style:{padding:`20px`},children:C}):(0,Y.jsx)(Sn,{name:`Search plugins`,rows:u,columns:M,getRowKey:`name`,onRowClick:(e,t,n)=>{s.current=e.name,o(e.name),n.detail===2&&N()},footerLeft:`Total packages: ${u.length.toString()} Total downloads: ${j(ee)} / ${ne}${I}`,footerRight:a?`Selected: ${a}`:``})})}),(0,Y.jsxs)(x,{sx:{justifyContent:`center`,gap:1.5,flexWrap:`wrap`},children:[(0,Y.jsx)(H,{title:`Select the plugin and close the dialog. Double-click a row to select and close the dialog.`,children:(0,Y.jsx)(L,{variant:`contained`,onClick:N,disabled:!(s.current||a)||m,children:`Select`})}),(0,Y.jsx)(H,{title:`Close the dialog without selecting a plugin.`,children:(0,Y.jsx)(L,{onClick:P,children:`Cancel`})})]})]})};function Yn(){let{mobile:e,showSnackbarMessage:t}=(0,G.useContext)(Vt),{logMessage:n,sendMessage:r,getUniqueId:i}=(0,G.useContext)(X),[a,o]=(0,G.useState)(`matterbridge-`),[s,c]=(0,G.useState)([`latest`,`dev`]),[l,d]=(0,G.useState)(`latest`),[f,p]=(0,G.useState)(!1),m=(0,G.useRef)(i()),h=e=>{let t=String(e??``).trim();if(!t)return{name:``,specifier:null};if(t.startsWith(`@`)){let e=t.lastIndexOf(`@`);if(e>0){let n=t.slice(0,e),r=t.slice(e+1);if(n.includes(`/`)&&r)return{name:n,specifier:r}}return{name:t,specifier:null}}let n=t.indexOf(`@`);if(n>0){let e=t.slice(0,n),r=t.slice(n+1);return r?{name:e,specifier:r}:{name:e,specifier:null}}return{name:t,specifier:null}},g=()=>{let{name:e,specifier:t}=h(a);return e?t?`${e}@${t}`:l?`${e}@${l}`:e:``},_=e=>{e.preventDefault(),p(!0)},v=()=>{p(!1)},y=e=>{e.preventDefault(),p(!1);let t=e.dataTransfer.files[0];if(t){n(`Plugins`,`Installing package ${t.name}. Please wait...`);let e=new FormData;e.append(`file`,t),e.append(`filename`,t.name),fetch(`./api/uploadpackage`,{method:`POST`,body:e}).then(e=>e.text()).then(e=>{n(`Plugins`,`Server response: ${e}`)}).catch(e=>{console.error(`Error uploading plugin file:`,e),n(`Plugins`,`Error installing package ${e}`)})}},b=e=>{let t=e.target.files&&e.target.files[0];if(t){n(`Plugins`,`Uploading package ${t.name}`);let e=new FormData;e.append(`file`,t),e.append(`filename`,t.name),fetch(`./api/uploadpackage`,{method:`POST`,body:e}).then(e=>e.text()).then(e=>{n(`Plugins`,`Server response: ${e}`)}).catch(e=>{console.error(`Error uploading plugin file:`,e),n(`Plugins`,`Error uploading package ${e}`)})}},x=()=>{let e=g();if(e){if(Rn.includes(e.split(`@`)[0])){t(`Installation of plugin "${e}" is blocked by the ignore list.`);return}r({id:m.current,sender:`InstallPlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e,restart:!1}})}},S=()=>{r({id:m.current,sender:`InstallPlugins`,method:`/api/uninstall`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:a}})},C=()=>{document.getElementById(`file-upload`)?.click()},w=()=>{if(Rn.includes(a.split(`@`)[0])){t(`Addition of plugin "${a}" is blocked by the ignore list.`);return}r({id:m.current,sender:`InstallPlugins`,method:`/api/addplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginNameOrPath:a}})},E=e=>{e.preventDefault(),q&&console.log(`Right-clicked Upload button`)},D=e=>{e.preventDefault(),q&&console.log(`Right-clicked Add button`)},[O,k]=(0,G.useState)(!1),A=()=>{k(!0),q&&console.log(`Dialog opened for selection`)},j=()=>{o(`matterbridge-`),k(!1),q&&console.log(`Dialog closed without selection`)},M=e=>{o(e),k(!1),q&&console.log(`Select plugin:`,e)},P=e=>{c(e),d(e.includes(`latest`)?`latest`:e[0]??``),q&&console.log(`Select plugin versions:`,e)},[ee,F]=(0,G.useState)(!1);return q&&console.log(`HomeInstallAddPlugins rendering...`),ee?null:(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`Install plugins`}),(0,Y.jsx)(Zt,{close:()=>F(!0)})]}),(0,Y.jsxs)(Xt,{onDragOver:_,onDragLeave:v,onDrop:y,style:J&&e?{flexWrap:`wrap`,alignItems:`center`,gap:`10px`}:{flexWrap:`wrap`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(Jn,{open:O,onClose:j,onSelect:M,onVersions:P}),(0,Y.jsxs)(`div`,{style:{flex:`1 1 auto`,display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(H,{title:`Provide the npm name or the local path of the plugin to install, uninstall, or add`,children:(0,Y.jsx)(B,{value:a,onChange:e=>{let t=e.target.value;c([`latest`,`dev`]),d(`latest`),o(t)},size:`small`,id:`plugin-name`,label:`Plugin name or plugin path`,variant:`outlined`,fullWidth:!0})}),s.length>0&&(0,Y.jsx)(H,{title:`Select the npm tag/version to install`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsxs)(Fe,{size:`small`,style:{minWidth:`150px`},children:[(0,Y.jsx)(le,{id:`plugin-version-label`,children:`Tag or version`}),(0,Y.jsx)(ye,{labelId:`plugin-version-label`,id:`plugin-version`,value:l,label:`Tag or version`,onChange:e=>d(String(e.target.value??``)),sx:{"& .MuiSelect-icon":{color:`var(--main-label-color)`}},children:s.map(e=>(0,Y.jsx)(V,{value:e,children:e},e))})]})})}),(0,Y.jsx)(H,{title:`Search on npm the plugin to install`,children:(0,Y.jsx)(T,{size:`large`,onClick:A,children:(0,Y.jsx)(te,{fontSize:`inherit`})})})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(H,{title:`Install or update a plugin from npm`,children:(0,Y.jsxs)(L,{onClick:x,endIcon:(0,Y.jsx)(u,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Install`]})}),(0,Y.jsx)(H,{title:`Uninstall and remove a plugin`,children:(0,Y.jsxs)(L,{onClick:S,endIcon:(0,Y.jsx)(Pe,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Uninstall`]})}),(0,Y.jsx)(H,{title:`Upload and install a plugin from a tarball`,children:(0,Y.jsxs)(L,{onClick:C,onContextMenu:E,endIcon:(0,Y.jsx)(Ie,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Upload`]})}),(0,Y.jsx)(H,{title:`Add an already installed plugin or a plugin from a local path`,children:(0,Y.jsxs)(L,{onClick:w,onContextMenu:D,endIcon:(0,Y.jsx)(N,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Add`]})}),(0,Y.jsx)(`input`,{id:`file-upload`,type:`file`,accept:`.tgz`,style:{display:`none`},onChange:b})]})]})]})}var Xn=(0,G.memo)(Yn),Zn=()=>{let e=window;return`ontouchstart`in window||e.DocumentTouch!==void 0&&document instanceof e.DocumentTouch?(q&&console.log(`WebSocketLogs detectTouchscreen = true`),!0):(q&&console.log(`WebSocketLogs detectTouchscreen = false`),!1)};function Qn(){let{messages:e,logAutoScroll:t}=(0,G.useContext)(Ht),[n,r]=(0,G.useState)(!1),i=(0,G.useRef)(null),a=(0,G.useRef)(0),o=(0,G.useRef)(null),s=(0,G.useMemo)(()=>Zn(),[]),c=()=>r(!0),l=()=>r(!1);(0,G.useEffect)(()=>{if(q&&console.log(`WebSocketLogs logAutoScroll: ${t.current} isHovering: ${n}`),t.current&&!n&&!s){let e=Date.now();e-a.current>=500?(q&&console.log(`WebSocketLogs auto-scroll to bottom`),a.current=e,i.current?.scrollIntoView({behavior:`smooth`,block:`end`})):(q&&console.log(`WebSocketLogs auto-scroll skipped to avoid flicker`),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{i.current?.scrollIntoView({behavior:`smooth`}),a.current=Date.now()},1e3))}},[e,t,n,s]);let u=e=>{switch(e.toLowerCase()){case`debug`:return`gray`;case`info`:return`#267fb7`;case`notice`:return`green`;case`warn`:return`#e9db18`;case`error`:return`red`;case`fatal`:return`#ff0000`;case`spawn`:return`#ff00d0`;default:return`#5c0e91`}},d=e=>{switch(e.toLowerCase()){case`warn`:return`black`;default:return`white`}};return(0,Y.jsx)(`div`,{style:{margin:`0px`,padding:`0px`},onMouseEnter:c,onMouseLeave:l,children:(0,Y.jsxs)(`ul`,{style:{margin:`0px`,padding:`0px`},children:[e.map((e,t)=>(0,Y.jsxs)(`li`,{style:{wordWrap:`break-word`,maxHeight:`200px`,overflow:`hidden`},children:[(0,Y.jsx)(`span`,{style:{marginRight:`5px`,padding:`1px 5px`,backgroundColor:u(e.level),color:d(e.level),fontSize:`12px`,borderRadius:`3px`,textAlign:`center`},children:e.level}),e.time&&(0,Y.jsx)(`span`,{style:{marginRight:`3px`,color:`#505050`},children:`[`+e.time+`]`}),e.name&&(0,Y.jsx)(`span`,{style:{marginRight:`3px`,color:`#09516d`},children:`[`+e.name+`]`}),(0,Y.jsx)(`span`,{style:{color:`var(--main-log-color)`},children:e.message})]},t)),(0,Y.jsx)(`div`,{ref:i})]})})}var $n=(0,G.memo)(Qn);function er(){let[e,t]=(0,G.useState)(localStorage.getItem(K.logFilterLevel)??`info`),[n,r]=(0,G.useState)(localStorage.getItem(K.logFilterSearch)??`*`),{online:i,logAutoScroll:a}=(0,G.useContext)(X);return q&&console.log(`HomeLogs rendering...`),i?(0,Y.jsxs)(Q,{style:{flex:`1 1 auto`},children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`Logs`}),(0,Y.jsxs)(Kt,{style:{fontWeight:`normal`,fontSize:`12px`,marginTop:`2px`},children:[`Filter: logger level "`,e,`" and search "`,n===``?`*`:n,`" Scroll: `,a.current?`auto`:`manual`]})]}),(0,Y.jsx)(Xt,{style:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`10px`,alignItems:`start`},children:(0,Y.jsx)($n,{})})]}):(0,Y.jsx)(Wt,{})}var tr=(0,G.memo)(er);function nr(e){return e.id!==0&&e.src===`Matterbridge`&&e.dst===`Frontend`}var rr={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},ir={fontSize:`12px`,fontWeight:`normal`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},ar={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},or={fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`,backgroundColor:`var(--div-bg-color)`},sr={fontSize:`16px`,fontWeight:`bold`,backgroundColor:`var(--div-bg-color)`},cr={padding:`0px`,margin:`0px`},lr=`5px 10px 5px 10px`,ur={},dr={},fr={},pr={},mr=[],hr=[],gr=[];function _r(e,t){let n=e?.properties;if(!n||typeof n!=`object`)return!1;let r=n[t];return!r||typeof r!=`object`?!1:typeof r.type==`string`}function vr(e){let t=e.items;return t!==void 0&&typeof t==`object`&&!Array.isArray(t)}function yr(e,t){let n=e?.properties;if(!n||typeof n!=`object`)return!1;let r=n[t];if(!r||typeof r!=`object`||r.type!==`array`||r.uniqueItems!==!0)return!1;let i=r.items;return i!==void 0&&typeof i==`object`&&!Array.isArray(i)&&Array.isArray(i.enum)}var br=({open:e,onClose:t,plugin:n})=>{let{sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(X),s=(0,G.useRef)(o()),c=(0,G.useRef)({}),l=(0,G.useRef)({}),[u,d]=(0,G.useState)(n.configJson),[f,m]=(0,G.useState)(n.schemaJson),[g,_]=(0,G.useState)({"ui:submitButtonOptions":{submitText:`Confirm`},"ui:globalOptions":{orderable:!0}}),v=(0,G.useRef)(``),y=n.configJson;(0,G.useEffect)(()=>{let e=e=>{e.src===`Matterbridge`&&e.dst===`Frontend`&&(nr(e)&&e.id===s.current&&e.method===`/api/select/devices`&&e.response&&(q&&console.log(`ConfigPluginDialog (id: ${e.id}) received ${e.response.length} /api/select/devices:`,e.response),hr=e.response),nr(e)&&e.id===s.current&&e.method===`/api/select/entities`&&e.response&&(q&&console.log(`ConfigPluginDialog (id: ${e.id}) received ${e.response.length} /api/select/entities:`,e.response),gr=e.response))};if(i(e,s.current),q&&console.log(`ConfigPluginDialog added WebSocket listener id:`,s.current),q&&console.log(`ConfigPluginDialog mounting...`),q&&console.log(`ConfigPluginDialog mounting with form:`,u),q&&console.log(`ConfigPluginDialog mounting with schema:`,f),q&&console.log(`ConfigPluginDialog mounting with uiSchema:`,g),u&&f&&f.properties){let e=(t,n,r=[])=>{!t||typeof t!=`object`||(t.properties&&Object.keys(t.properties).forEach(i=>{let a=t.properties?.[i],o=[...r,i];Object.keys(a).forEach(e=>{if(e.startsWith(`ui:`)){let t=n;o.forEach(e=>{t[e]||(t[e]={}),t=t[e]}),t[e]=a[e],delete a[e]}}),e(a,n,o)}),[`oneOf`,`anyOf`,`allOf`].forEach(i=>{Array.isArray(t[i])&&t[i].forEach(t=>{e(t,n,r)})}),t.items&&typeof t.items==`object`&&e(t.items,n,r))};e(f,g),_(g),c.current=f,l.current=g}return n.name&&n.configJson&&n.schemaJson&&(d(n.configJson),m(n.schemaJson),r({id:s.current,sender:`ConfigPlugin`,method:`/api/select/devices`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name}}),r({id:s.current,sender:`ConfigPlugin`,method:`/api/select/entities`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name}}),q&&console.log(`HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:`,n.name)),()=>{a(e),q&&console.log(`ConfigPluginDialog removed WebSocket listener`)}},[i,u,n,a,f,r,g]);let b=(e,t)=>{y=e.formData},S=e=>{q&&console.log(`ConfigPluginDialog handleSaveChanges:`,e.formData),d(e.formData),n.configJson=e.formData,n.restartRequired=!0,r({id:s.current,sender:`ConfigPlugin`,method:`/api/savepluginconfig`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.formData.name,formData:e.formData}}),t()};function C(e){let{id:t,label:n,onKeyRenameBlur:r,onRemoveProperty:i,disabled:a,schema:o,children:s,registry:c,readonly:l,required:u}=e,{templates:d}=c,{RemoveButton:f}=d.ButtonTemplates,p=Ct in o,m=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let e=v.current;!p||e===``||!/^newKey(?:-\d+)?$/.test(n)||!m.current||(q&&console.log(`WrapIfAdditionalTemplate: renaming additional property "${n}" to "${e}"`),m.current.value=e,r({target:m.current}),v.current=``)},[p,n,r]),p?(0,Y.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,flexGrow:1,padding:0,margin:0,border:`none`},children:[(0,Y.jsx)(B,{id:`${t}-key`,name:`${t}-key`,required:u,disabled:a||l,defaultValue:n,inputRef:m,onBlur:l?void 0:r,type:`text`,variant:`outlined`,sx:{width:`250px`,minWidth:`250px`,maxWidth:`250px`,marginRight:`20px`}}),(0,Y.jsx)(W,{sx:{flex:1},children:s}),(0,Y.jsx)(f,{disabled:a||l,onClick:i,registry:c})]}):(0,Y.jsx)(W,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:s})}function w(e){let{children:t,description:n,displayLabel:r,errors:i,help:a,hidden:o,registry:s,uiSchema:c}=e,l=St(`WrapIfAdditionalTemplate`,s,xt(c));return o?(0,Y.jsx)(`div`,{style:{display:`none`},children:t}):(0,Y.jsx)(W,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:(0,Y.jsxs)(l,{...e,children:[r===!0&&n,t,i,a]})})}function E(e){let{description:t}=e;return t?(0,Y.jsx)(p,{sx:ir,children:t}):null}function O(e){let{required:t,title:n}=e;return n?(0,Y.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,Y.jsxs)(p,{sx:rr,children:[`Title `,n,` `,t&&(0,Y.jsx)(`mark`,{children:`***`})]})}):null}function k(e){let{help:t}=e;return t?(0,Y.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,Y.jsx)(p,{sx:or,children:t})}):null}function A(e){let{errors:t}=e;return t?(0,Y.jsxs)(W,{sx:{padding:`10px`,margin:`10px`,border:`1px solid grey`},children:[(0,Y.jsx)(p,{color:`error`,sx:sr,children:`Please fix the following errors:`}),(0,Y.jsx)(at,{children:t.map((e,t)=>(0,Y.jsxs)(se,{children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(Be,{color:`error`})}),(0,Y.jsx)(z,{primary:e.stack})]},t))})]}):null}function P(e){let{errors:t}=e;return t?(0,Y.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:t.map((e,t)=>(0,Y.jsxs)(p,{color:`error`,variant:`body2`,sx:{marginLeft:1},children:[`This field `,e]},t))}):null}function ee(e){let{id:t,name:n,_schema:r,_uiSchema:i,value:a,options:o,label:s,type:c,placeholder:l,required:u,disabled:d,readonly:f,autofocus:p,onChange:m,onChangeOverride:h,onBlur:g,onFocus:_,_rawErrors:v,_hideError:y,_registry:b,_formContext:x}=e;return(0,Y.jsx)(W,{sx:{padding:`0px`,margin:`0px`},children:(0,Y.jsx)(B,{id:t,name:t,label:l&&l!==``?s:void 0,variant:`outlined`,placeholder:l&&l!==``?l:s,required:u,disabled:d||f,autoFocus:p,value:a||a===0?a:``,type:c,autoComplete:c===`password`?`current-password`:n,onChange:h||(({target:{value:e}})=>m(e===``?o.emptyValue:e)),onBlur:({target:e})=>g(t,e&&e.value),onFocus:({target:e})=>_(t,e&&e.value),fullWidth:!0})})}function te(e){return console.log(`ArrayFieldTitleTemplate:`,e),null}function I(e){return console.log(`ArrayFieldDescriptionTemplate:`,e),null}function ne(e){let{buttonsProps:t,children:n}=e;return(0,Y.jsxs)(W,{sx:{margin:`2px 0px`,padding:`0px`,display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(W,{sx:{flexGrow:1,marginRight:`10px`},children:n}),(0,Y.jsx)(T,{disabled:!t.hasMoveUp,onClick:t.onMoveUpItem,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(Te,{})}),(0,Y.jsx)(T,{disabled:!t.hasMoveDown,onClick:t.onMoveDownItem,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(Oe,{})}),t.hasRemove&&(0,Y.jsx)(T,{onClick:t.onRemoveItem,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(ke,{})})]})}function ie(e){let{canAdd:t,onAddClick:n,schema:r,title:i,formData:a}=e,[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),[f,m]=(0,G.useState)(``),g=e=>{m(e.target.value)},_=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogDeviceToggle filter:`,f,`selectDevices:`,hr),s(!o)},v=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogEntityToggle filter:`,f,`selectEntities:`,gr),l(!c)},y=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:`,f,`selectDevices:`,hr),d(!u)},b=e=>{s(!1),r.selectFrom===`serial`&&vr(r)?r.items.default=e.serial:r.selectFrom===`name`&&vr(r)&&(r.items.default=e.name),n()},S=e=>{l(!1),r.selectEntityFrom===`name`&&vr(r)?r.items.default=e.name:r.selectEntityFrom===`description`&&vr(r)&&(r.items.default=e.description),n()},C=e=>{d(!1),r.selectDeviceEntityFrom===`name`&&vr(r)?r.items.default=e.name:r.selectDeviceEntityFrom===`description`&&vr(r)&&(r.items.default=e.description),n()};return(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`5px 10px 5px 10px`,border:`1px solid grey`},children:[i&&(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[i&&(0,Y.jsx)(p,{sx:rr,children:i}),t&&(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[r.selectFrom&&(0,Y.jsx)(H,{title:`Add a device from the list`,children:(0,Y.jsx)(T,{onClick:_,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(et,{})})}),r.selectEntityFrom&&(0,Y.jsx)(H,{title:`Add an entity from the list`,children:(0,Y.jsx)(T,{onClick:v,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(et,{})})}),r.selectDeviceEntityFrom&&(0,Y.jsx)(H,{title:`Add a device entity from the list`,children:(0,Y.jsx)(T,{onClick:y,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(et,{})})}),(0,Y.jsx)(H,{title:`Add a new item`,children:(0,Y.jsx)(T,{onClick:n,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(N,{})})})]})]}),r.description&&(0,Y.jsx)(p,{sx:ir,children:r.description}),e.items,(0,Y.jsxs)(D,{open:o,onClose:_,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsx)(F,{children:`Select a device`}),(0,Y.jsxs)(re,{children:[(0,Y.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,Y.jsx)(p,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,Y.jsx)(B,{fullWidth:!0,variant:`outlined`,value:f,onChange:g,placeholder:`Enter serial or name`})]}),(0,Y.jsx)(at,{dense:!0,children:hr.filter(e=>e.serial.toLowerCase().includes(f.toLowerCase())||e.name.toLowerCase().includes(f.toLowerCase())).filter(e=>!r.uniqueItems||!a.includes(r.selectFrom===`serial`?e.serial:e.name)).map((e,t)=>(0,Y.jsxs)(h,{onClick:()=>b(e),sx:ur,children:[e.icon===`wifi`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(j,{style:dr})}),e.icon===`ble`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(ve,{style:dr})}),e.icon===`hub`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ke,{style:dr})}),(0,Y.jsx)(z,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:fr},secondaryTypographyProps:{style:pr}})]},t))})]}),(0,Y.jsx)(x,{children:(0,Y.jsx)(L,{onClick:_,children:`Close`})})]}),(0,Y.jsxs)(D,{open:c,onClose:v,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsx)(F,{children:`Select an entity`}),(0,Y.jsxs)(re,{children:[(0,Y.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,Y.jsx)(p,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,Y.jsx)(B,{fullWidth:!0,variant:`outlined`,value:f,onChange:g,placeholder:`Enter name or description`})]}),(0,Y.jsx)(at,{dense:!0,children:gr.filter(e=>e.name.toLowerCase().includes(f.toLowerCase())||e.description.toLowerCase().includes(f.toLowerCase())).filter(e=>!r.uniqueItems||!a.includes(r.selectEntityFrom===`name`?e.name:e.description)).map((e,t)=>(0,Y.jsxs)(h,{onClick:()=>S(e),sx:ur,children:[e.icon===`wifi`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(j,{style:dr})}),e.icon===`ble`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(ve,{style:dr})}),e.icon===`hub`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ke,{style:dr})}),e.icon===`component`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Re,{style:dr})}),e.icon===`matter`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ae,{style:dr})}),(0,Y.jsx)(z,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:fr},secondaryTypographyProps:{style:pr}})]},t))})]}),(0,Y.jsx)(x,{children:(0,Y.jsx)(L,{onClick:v,children:`Close`})})]}),(0,Y.jsxs)(D,{open:u,onClose:y,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsxs)(F,{children:[`Select an entity for `,i]}),(0,Y.jsx)(re,{children:(0,Y.jsx)(at,{dense:!0,children:hr.filter(e=>e.serial===i||e.name===i).map(e=>e.entities?.filter(e=>!r.uniqueItems||!Array.isArray(a)||!a.includes(r.selectDeviceEntityFrom===`name`?e.name:e.description)).map((e,t)=>(0,Y.jsxs)(h,{onClick:()=>C(e),sx:ur,children:[e.icon===`wifi`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(j,{style:dr})}),e.icon===`ble`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(ve,{style:dr})}),e.icon===`hub`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ke,{style:dr})}),e.icon===`component`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Re,{style:dr})}),e.icon===`matter`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ae,{style:dr})}),(0,Y.jsx)(z,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:fr},secondaryTypographyProps:{style:pr}})]},t)))})}),(0,Y.jsx)(x,{children:(0,Y.jsx)(L,{onClick:y,children:`Close`})})]})]})}function ae(e){let{onAddProperty:t,schema:n,properties:r,title:i,description:a}=e,[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(``),u=e=>{l(e.target.value)},d=()=>{s(!o)},f=e=>{q&&console.log(`ObjectFieldTemplate: handleSelectValue value "${e.serial}" for schema "${n.selectFrom}"`),s(!1);let r=``;n.selectFrom===`serial`?r=e.serial:n.selectFrom===`name`&&(r=e.name),v.current=r,q&&console.log(`ObjectFieldTemplate: handleSelectValue pendingAdditionalPropertyKey "${r}"`),t()},m=()=>{t()},g=!n.additionalProperties;return q&&console.log(`ObjectFieldTemplate: isRoot ${g} pendingAdditionalPropertyKey "${v.current}"`),(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:g?`10px`:`5px 10px 0px 10px`,border:g?`none`:`1px solid grey`},children:[n.title&&g&&(0,Y.jsx)(W,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,Y.jsx)(p,{sx:rr,children:n.title})}),i&&!g&&(0,Y.jsxs)(W,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[(0,Y.jsx)(p,{sx:rr,children:i}),(0,Y.jsxs)(W,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[n.selectFrom&&(0,Y.jsx)(H,{title:`Add a device from the list`,children:(0,Y.jsx)(T,{onClick:d,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(et,{})})}),(0,Y.jsx)(H,{title:`Add a new item`,children:(0,Y.jsx)(T,{onClick:m,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(N,{})})})]})]}),n.description&&(0,Y.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,Y.jsx)(p,{sx:ir,children:n.description})}),r.map(({content:e,name:t,hidden:r})=>{if(r)return null;let i=_r(n,t),a=yr(n,t),o=i&&[`object`,`array`].includes(n.properties[t].type);return(0,Y.jsxs)(W,{sx:{margin:`0px`,marginBottom:`10px`,padding:o&&!a?`0px`:lr,border:o&&!a?`none`:`1px solid grey`},children:[i&&![`object`,`array`,`boolean`].includes(n.properties[t].type)&&(0,Y.jsx)(p,{sx:rr,children:n.properties[t].title||t}),a&&(0,Y.jsx)(p,{sx:rr,children:n.properties[t].title||t}),(0,Y.jsx)(W,{sx:{flexGrow:1,padding:`0px`,margin:`0px`},children:e})]},t)}),(0,Y.jsxs)(D,{open:o,onClose:d,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsx)(F,{children:`Select a device`}),(0,Y.jsxs)(re,{children:[(0,Y.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,Y.jsx)(p,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,Y.jsx)(B,{fullWidth:!0,variant:`outlined`,value:c,onChange:u,placeholder:`Enter serial or name`})]}),(0,Y.jsx)(at,{dense:!0,children:hr.filter(e=>e.serial.toLowerCase().includes(c.toLowerCase())||e.name.toLowerCase().includes(c.toLowerCase())).map((e,t)=>(0,Y.jsxs)(h,{onClick:()=>f(e),sx:ur,children:[e.icon===`wifi`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(j,{style:dr})}),e.icon===`ble`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(ve,{style:dr})}),e.icon===`hub`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ke,{style:dr})}),(0,Y.jsx)(z,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:fr},secondaryTypographyProps:{style:pr}})]},t))})]}),(0,Y.jsx)(x,{children:(0,Y.jsx)(L,{onClick:d,children:`Close`})})]})]})}function oe(e){let{uiSchema:n}=e,{submitText:r,norender:i}=bt(n);return i?null:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,margin:`10px`,padding:`0px`,gap:`20px`},children:[(0,Y.jsx)(L,{type:`submit`,variant:`contained`,color:`primary`,children:r}),(0,Y.jsx)(L,{variant:`contained`,color:`primary`,onClick:t,children:`Cancel`})]})}function ce(e){let{className:t,disabled:n,onClick:r,registry:i,style:a,uiSchema:o,...s}=e;return(0,Y.jsx)(H,{title:`Remove the item`,children:(0,Y.jsx)(T,{disabled:n,size:`small`,color:`primary`,onClick:r,children:(0,Y.jsx)(ke,{})})})}function le(e){let{className:t,disabled:n,onClick:r,registry:i,uiSchema:a,...o}=e;return(0,Y.jsx)(H,{title:`Add an item`,children:(0,Y.jsx)(T,{size:`small`,color:`primary`,onClick:r,children:(0,Y.jsx)(N,{})})})}function ue(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,Y.jsx)(H,{title:`Move up the item`,children:(0,Y.jsx)(T,{size:`small`,color:`primary`,onClick:n,children:(0,Y.jsx)(Te,{})})})}function de(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,Y.jsx)(H,{title:`Move down the item`,children:(0,Y.jsx)(T,{size:`small`,color:`primary`,onClick:n,children:(0,Y.jsx)(Oe,{})})})}function fe(e){let{id:i,name:a,value:o,schema:c,readonly:l,onChange:d}=e,[f,m]=(0,G.useState)(),h=e=>{q&&console.log(`CheckboxWidget ${a} onChangeField:`,e),m(e&&e!==``?e:void 0)},g=()=>{q&&console.log(`CheckboxWidget onClick plugin="${n.name}" action="${a}" value="${f}"`),r({id:s.current,sender:`ConfigPlugin`,method:`/api/action`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name,action:a,value:f,formData:y,id:i}}),c.buttonClose===!0?t():c.buttonSave===!0&&S({formData:u})};return c.buttonText&&(c.title||c.description)?(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`5px 0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Y.jsx)(p,{sx:ar,children:c.title||c.description}),(0,Y.jsx)(L,{variant:`contained`,color:`primary`,onClick:()=>g(),children:c.buttonText})]}):c.buttonField&&(c.title||c.description)?(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`5px 0px`,gap:`20px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Y.jsx)(p,{sx:ar,children:c.title||c.description}),(0,Y.jsx)(B,{id:a+`-input`,name:a,label:c.textLabel,placeholder:c.textPlaceholder,onChange:e=>h(e.target.value),sx:{width:`250px`,minWidth:`250px`,maxWidth:`250px`}}),(0,Y.jsx)(L,{id:a+`-button`,variant:`contained`,color:`primary`,disabled:f===void 0,onClick:()=>g(),children:c.buttonField})]}):(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`0px`},children:[a&&(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`0px`,gap:`10px`,display:`flex`,justifyContent:`flex-start`,alignItems:`center`},children:[(0,Y.jsx)(p,{sx:rr,children:c.title||a}),(0,Y.jsx)(M,{checked:o,readOnly:l,onChange:()=>d(!o),sx:{padding:`0px`,margin:`0px`}})]}),c.description&&(0,Y.jsx)(p,{sx:ir,children:c.description})]})}function pe({schema:e,id:t,name:n,options:r,label:i,hideLabel:a,required:o,disabled:s,placeholder:c,readonly:l,value:u,multiple:d,autofocus:f,onChange:p,onBlur:m,onFocus:h,errorSchema:g,rawErrors:_=mr,registry:v,uiSchema:y,hideError:b,...x}){let{enumOptions:S,enumDisabled:C,emptyValue:w}=r,T=d?[]:``,E=u===void 0||d&&u.length<1||!d&&u===T,D=({target:{value:e}})=>p(Dt(e,S,w)),O=({target:e})=>m(t,Dt(e&&e.value,S,w)),k=({target:e})=>h(t,Dt(e&&e.value,S,w)),A=Tt(u,S,d);return(0,Y.jsx)(B,{id:t,name:n,value:!E&&A!==void 0?A:T,required:o,disabled:s||l,autoFocus:f,error:_.length>0,onChange:D,onBlur:O,onFocus:k,select:!0,slotProps:{select:{multiple:d,...d?{renderValue:e=>!Array.isArray(e)||!Array.isArray(S)?``:e.map(e=>S[Number(e)]?.label).filter(e=>typeof e==`string`).join(`, `)}:{}}},"aria-describedby":Et(t),children:Array.isArray(S)&&S.map(({value:e,label:t},n)=>{let r=Array.isArray(C)&&C.indexOf(e)!==-1,i=Array.isArray(A)&&A.includes(String(n));return(0,Y.jsxs)(V,{value:String(n),disabled:r,children:[d&&(0,Y.jsx)(U,{sx:{minWidth:`32px`},children:(0,Y.jsx)(M,{checked:i,disableRipple:!0,tabIndex:-1,sx:{padding:`0px`,margin:`0px`}})}),t]},n)})})}return q&&console.log(`ConfigPluginDialog rendering...`),!e||!f||!u?null:(0,Y.jsxs)(D,{open:e,onClose:t,slotProps:{paper:{sx:{maxWidth:`800px`}}},children:[(0,Y.jsx)(F,{gap:`20px`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h3`,{children:`Matterbridge plugin configuration`})]})}),(0,Y.jsx)(re,{style:{padding:`0px`,margin:`0px`,width:`800px`,height:`600px`,overflow:`auto`},children:(0,Y.jsx)(Ot,{schema:f,formData:u,uiSchema:g,validator:wt,templates:{FieldTemplate:w,BaseInputTemplate:ee,TitleFieldTemplate:O,DescriptionFieldTemplate:E,FieldHelpTemplate:k,FieldErrorTemplate:P,ErrorListTemplate:A,WrapIfAdditionalTemplate:C,ArrayFieldTitleTemplate:te,ArrayFieldDescriptionTemplate:I,ArrayFieldItemTemplate:ne,ArrayFieldTemplate:ie,ObjectFieldTemplate:ae,ButtonTemplates:{SubmitButton:oe,RemoveButton:ce,AddButton:le,MoveUpButton:ue,MoveDownButton:de}},widgets:{CheckboxWidget:fe,SelectWidget:pe},onChange:b,onSubmit:S})})]})};function xr({status:e,enabledText:t=`Enabled`,disabledText:n,tooltipText:r}){if(e===void 0)return null;{let i=(0,Y.jsx)(`div`,{className:e?`status-enabled`:`status-disabled`,style:{cursor:`default`},children:e?t:n??t});return r===void 0?i:(0,Y.jsx)(H,{title:r,children:i})}}function Sr({storeId:e,setStoreId:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(X),{mobile:s,showConfirmCancelDialog:c}=(0,G.useContext)(Vt),l=(0,G.useRef)(o()),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(null),[h,_]=(0,G.useState)([]),[y,b]=(0,G.useState)(null),S=[{label:`Name`,id:`name`,required:!0,render:(e,t,n,r)=>(0,Y.jsx)(H,{title:`Plugin path ${n.path}`,children:(0,Y.jsx)(`button`,{type:`button`,style:{cursor:`pointer`,background:`none`,border:`none`,padding:0,font:`inherit`,color:`inherit`,textAlign:`left`},onClick:()=>P(n),children:n.name})})},{label:`Description`,id:`description`,render:(e,t,n,r)=>(0,Y.jsx)(H,{title:`Open the plugin homepage`,children:(0,Y.jsx)(`button`,{type:`button`,style:{cursor:`pointer`,background:`none`,border:`none`,padding:0,font:`inherit`,color:`inherit`,textAlign:`left`},onClick:()=>P(n),children:n.description})})},{label:`Version`,id:`version`,render:(e,t,n,r)=>(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(H,{title:`Plugin v.${n.version}`,children:(0,Y.jsx)(`span`,{children:n.version.split(`-`)[0]+(n.version.includes(`-dev-`)?`@dev`:``)+(n.version.includes(`-git-`)?`@git`:``)})})})},{label:`Author`,id:`author`,render:(e,t,n,r)=>(0,Y.jsx)(Y.Fragment,{children:n.author?n.author.replace(`https://github.com/`,``):`Unknown`})},{label:`Type`,id:`type`,render:(e,t,n,r)=>(0,Y.jsx)(Y.Fragment,{children:n.type?n.type.replace(`Platform`,``):`Unknown`})},{label:`Devices`,id:`registeredDevices`},{label:`Actions`,id:`actions`,required:!0,noSort:!0,render:(e,n,r,i)=>(0,Y.jsxs)(`div`,{style:{margin:`0px`,padding:`0px`,gap:`4px`,display:`flex`,flexDirection:`row`},children:[f&&f.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,Y.jsx)(H,{title:`Shows the QRCode or the fabrics`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:Pn(r.matter)},onClick:()=>{r.matter?.id&&t(r.matter?.id)},size:`small`,children:(0,Y.jsx)(ee,{})})}),f&&f.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,Y.jsx)(H,{title:`Restart the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`},onClick:()=>M(r),size:`small`,children:(0,Y.jsx)(ot,{})})}),(0,Y.jsx)(H,{title:`Plugin config`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{disabled:r.restartRequired===!0,style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>ue(r),size:`small`,children:(0,Y.jsx)(Se,{})})}),f&&!f.readOnly&&(0,Y.jsx)(H,{title:`Remove the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{w(`Remove plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`remove`,r)},size:`small`,children:(0,Y.jsx)(Pe,{})})}),r.enabled?(0,Y.jsx)(H,{title:`Disable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{w(`Disable plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`disable`,r)},size:`small`,children:(0,Y.jsx)(nt,{})})}):(0,Y.jsx)(Y.Fragment,{}),r.enabled?(0,Y.jsx)(Y.Fragment,{}):(0,Y.jsx)(H,{title:`Enable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>N(r),size:`small`,children:(0,Y.jsx)(oe,{})})}),(0,Y.jsx)(H,{title:`Open the plugin help`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>te(r),size:`small`,children:(0,Y.jsx)(g,{})})}),(0,Y.jsx)(H,{title:`Open the plugin version history`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>I(r),size:`small`,children:(0,Y.jsx)(v,{})})}),r.enabled&&r.frontendPath&&(0,Y.jsx)(H,{title:`Open the plugin frontend`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>ne(r),size:`small`,children:(0,Y.jsx)(m,{})})}),r.latestVersion!==void 0&&r.latestVersion!==r.version&&f&&!f.readOnly&&(0,Y.jsx)(H,{title:`Update the plugin to the latest version v.${r.latestVersion}`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>k(r),size:`small`,children:(0,Y.jsx)(st,{})})}),(r.version.includes(`-dev-`)||r.version.includes(`-git-`))&&r.devVersion!==void 0&&r.devVersion!==r.version&&f&&!f.readOnly&&(0,Y.jsx)(H,{title:`Update the plugin to the latest dev version v.${r.devVersion}`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{color:`var(--secondary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>A(r),size:`small`,children:(0,Y.jsx)(st,{})})}),f&&!f.readOnly&&(0,Y.jsx)(H,{title:`Sponsor the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`#b6409c`},onClick:()=>F(r),size:`small`,children:(0,Y.jsx)(it,{})})})]})},{label:`Status`,id:`status`,required:!0,noSort:!0,render:(e,t,n,r)=>(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,flex:`1 1 auto`,margin:`0`,padding:`0`,gap:`5px`,width:`auto`,maxWidth:`max-content`},children:n.error?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(xr,{status:!1,enabledText:`Error`,disabledText:`Error`,tooltipText:`The plugin is in error state. Check the log!`})}):(0,Y.jsx)(Y.Fragment,{children:n.enabled?(0,Y.jsx)(Y.Fragment,{children:n.loaded&&n.started&&n.configured?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(xr,{status:n.loaded,enabledText:`Running`,tooltipText:`Whether the plugin is running`})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(xr,{status:n.loaded,enabledText:`Loaded`,tooltipText:`Whether the plugin has been loaded`}),(0,Y.jsx)(xr,{status:n.started,enabledText:`Started`,tooltipText:`Whether the plugin started`}),(0,Y.jsx)(xr,{status:n.configured,enabledText:`Configured`,tooltipText:`Whether the plugin has been configured`})]})}):(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(xr,{status:n.enabled,enabledText:`Enabled`,disabledText:`Disabled`,tooltipText:`Whether the plugin is enable or disabled`})})})})}];(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`HomePlugins received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`plugins`?e.response.lock?(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} lock=${e.response.lock} and locking plugins list`),_(t=>t.map(t=>t.name===e.response.lock?{...t,restartRequired:!0}:t))):(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} lock=${e.response.lock} and sending /api/plugins request`),r({id:l.current,sender:`HomePlugins`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`refresh_required`&&e.response.changed===`matter`?(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and setting matter id ${e.response.matter?.id}`),_(t=>{let n=t.findIndex(t=>t.matter?.id===e.response.matter?.id);if(n<0)return q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and matter id ${e.response.matter?.id} not found`),t;q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} set matter id ${e.response.matter?.id}`);let r=[...t];return r[n]={...r[n],matter:e.response.matter},r})):e.method===`refresh_required`&&e.response.changed===`settings`&&(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and sending /api/settings request`),r({id:l.current,sender:`HomePlugins`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})),e.id===l.current&&e.method===`/api/settings`?(q&&console.log(`HomePlugins (id: ${e.id}) received settings:`,e.response),d(e.response.systemInformation),p(e.response.matterbridgeInformation)):e.id===l.current&&e.method===`/api/plugins`&&(q&&console.log(`HomePlugins (id: ${e.id}) received ${e.response.length} plugins:`,e.response),_(e.response))};return i(e,l.current),q&&console.log(`HomePlugins added WebSocket listener id:`,l.current),()=>{a(e),q&&console.log(`HomePlugins removed WebSocket listener`)}},[i,a,r]),(0,G.useEffect)(()=>{n&&(q&&console.log(`HomePlugins sending api requests`),r({id:l.current,sender:`HomePlugins`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:l.current,sender:`HomePlugins`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[n,r]);let C=(0,G.useRef)(null),w=(e,t,n,r)=>{q&&console.log(`handleActionWithConfirmCancel ${n} ${r.name}`),C.current=r,c(e,t,n,E,O)},E=e=>{q&&console.log(`handleConfirm action confirmed ${e} ${C.current?.name}`),e===`remove`&&C.current?j(C.current):e===`disable`&&C.current&&N(C.current),C.current=null},O=e=>{q&&console.log(`handleCancel action canceled ${e} ${C.current?.name}`),C.current=null},k=e=>{q&&console.log(`handleUpdatePlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e.name,restart:!1}})},A=e=>{q&&console.log(`handleUpdateDevPlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e.name+`@dev`,restart:!1}})},j=e=>{q&&console.log(`handleRemovePlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/removeplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},M=e=>{q&&console.log(`handleRestartPlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/restartplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},N=e=>{q&&console.log(`handleEnableDisablePlugin plugin:`,e.name,`enabled:`,e.enabled),e.enabled?(e.enabled=!1,r({id:l.current,sender:`HomePlugins`,method:`/api/disableplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})):(e.enabled=!0,r({id:l.current,sender:`HomePlugins`,method:`/api/enableplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}}))},P=e=>{q&&console.log(`handleHomepagePlugin plugin: ${e.name} homepage: ${e.homepage}`),e.homepage&&window.open(e.homepage,`_blank`)},F=e=>{q&&console.log(`handleSponsorPlugin plugin:`,e.name,`funding:`,e.funding),e.funding&&window.open(e.funding,`_blank`)},te=e=>{q&&console.log(`handleHelpPlugin plugin:`,e.name,`help:`,e.help),e.help&&window.open(e.help,`_blank`)},I=e=>{q&&console.log(`handleChangelogPlugin plugin:`,e.name,`changelog:`,e.changelog),e.changelog&&window.open(e.changelog,`_blank`)},ne=e=>{let t=`/plugins/${e.name}`;q&&console.log(`handleFrontendPlugin plugin:`,e.name,`frontend:`,e.frontendPath,`path:`,t),e.frontendPath&&b({name:e.name,path:t})},ie=e=>{let t=e.currentTarget.contentDocument;if(!t?.head)return;let n=getComputedStyle(document.body),r=n.getPropertyValue(`--primary-color`).trim()||`#0d6efd`,i=n.getPropertyValue(`--div-bg-color`).trim()||`#111111`;t.getElementById(`matterbridge-plugin-scrollbar-style`)?.remove();let a=t.createElement(`style`);a.id=`matterbridge-plugin-scrollbar-style`,a.textContent=`
|
|
25
23
|
html,
|
|
26
24
|
body {
|
|
27
25
|
background-color: ${i};
|
|
@@ -41,4 +39,6 @@ import{a as e}from"./rolldown-runtime.js";import{c as t}from"./vendor_emotion.js
|
|
|
41
39
|
::-webkit-scrollbar-track {
|
|
42
40
|
background: ${i};
|
|
43
41
|
}
|
|
44
|
-
`,t.head.appendChild(a)},style:{display:`block`,flex:`1 1 auto`,width:`100%`,height:`100%`,border:`none`,backgroundColor:`var(--div-bg-color)`}})}),(0,K.jsx)(x,{sx:{flex:`0 0 auto`,justifyContent:`center`},children:(0,K.jsx)(L,{onClick:()=>O(null),children:`Close`})})]})]}):(0,K.jsx)(Vt,{})}var Kn=(0,G.memo)(Gn);function qn({children:e,style:t,name:n}){let{setCurrentPage:r}=(0,G.useContext)(It);return r(n),Q&&console.log(`MbfPage: current page set to ${n}`),(0,K.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,margin:`0px`,padding:`0px`,gap:`20px`,...t},children:e})}var Jn=()=>`ontouchstart`in window||window.DocumentTouch!==void 0&&document instanceof window.DocumentTouch?(Q&&console.log(`WebSocketLogs detectTouchscreen = true`),!0):(Q&&console.log(`WebSocketLogs detectTouchscreen = false`),!1);function Yn(){let{messages:e,logAutoScroll:t}=(0,G.useContext)(Rt),[n,r]=(0,G.useState)(!1),i=(0,G.useRef)(null),a=(0,G.useRef)(0),o=(0,G.useRef)(null),s=(0,G.useMemo)(()=>Jn(),[]),c=e=>r(!0),l=e=>r(!1);(0,G.useEffect)(()=>{if(Q&&console.log(`WebSocketLogs logAutoScroll: ${t.current} isHovering: ${n}`),t.current&&!n&&!s){let e=Date.now();e-a.current>=500?(Q&&console.log(`WebSocketLogs auto-scroll to bottom`),a.current=e,i.current?.scrollIntoView({behavior:`smooth`,block:`end`})):(Q&&console.log(`WebSocketLogs auto-scroll skipped to avoid flicker`),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{i.current?.scrollIntoView({behavior:`smooth`}),a.current=Date.now()},1e3))}},[e,t,n,s]);let u=e=>{switch(e.toLowerCase()){case`debug`:return`gray`;case`info`:return`#267fb7`;case`notice`:return`green`;case`warn`:return`#e9db18`;case`error`:return`red`;case`fatal`:return`#ff0000`;case`spawn`:return`#ff00d0`;default:return`#5c0e91`}},d=e=>{switch(e.toLowerCase()){case`warn`:return`black`;default:return`white`}};return(0,K.jsx)(`div`,{style:{margin:`0px`,padding:`0px`},children:(0,K.jsxs)(`ul`,{style:{margin:`0px`,padding:`0px`},onMouseEnter:c,onMouseLeave:l,children:[e.map((e,t)=>(0,K.jsxs)(`li`,{style:{wordWrap:`break-word`,maxHeight:`200px`,overflow:`hidden`},children:[(0,K.jsx)(`span`,{style:{marginRight:`5px`,padding:`1px 5px`,backgroundColor:u(e.level),color:d(e.level),fontSize:`12px`,borderRadius:`3px`,textAlign:`center`},children:e.level}),e.time&&(0,K.jsx)(`span`,{style:{marginRight:`3px`,color:`#505050`},children:`[`+e.time+`]`}),e.name&&(0,K.jsx)(`span`,{style:{marginRight:`3px`,color:`#09516d`},children:`[`+e.name+`]`}),(0,K.jsx)(`span`,{style:{color:`var(--main-log-color)`},children:e.message})]},t)),(0,K.jsx)(`div`,{ref:i})]})})}var Xn=(0,G.memo)(Yn);function Zn(){let[e,t]=(0,G.useState)(localStorage.getItem(q.logFilterLevel)??`info`),[n,r]=(0,G.useState)(localStorage.getItem(q.logFilterSearch)??`*`),{online:i,logAutoScroll:a}=(0,G.useContext)(J);return Q&&console.log(`HomeLogs rendering...`),i?(0,K.jsxs)(X,{style:{flex:`1 1 auto`},children:[(0,K.jsxs)(Ut,{children:[(0,K.jsx)(Wt,{children:`Logs`}),(0,K.jsxs)(Wt,{style:{fontWeight:`normal`,fontSize:`12px`,marginTop:`2px`},children:[`Filter: logger level "`,e,`" and search "`,n===``?`*`:n,`" Scroll: `,a.current?`auto`:`manual`]})]}),(0,K.jsx)(Jt,{style:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`10px`,alignItems:`start`},children:(0,K.jsx)(Xn,{})})]}):(0,K.jsx)(Vt,{})}var Qn=(0,G.memo)(Zn);function $n({version:e}){let{online:t}=(0,G.useContext)(J);return Q&&console.log(`HomeBrowserRefresh rendering...`),t?(0,K.jsxs)(X,{children:[(0,K.jsx)(Ut,{children:(0,K.jsx)(Wt,{children:`Frontend Update`})}),(0,K.jsxs)(Jt,{style:{flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`},children:[(0,K.jsxs)(`h4`,{style:{margin:0},children:[`The frontend has been updated to version `,e,`. You are viewing an outdated web UI. Please refresh the page now.`]}),(0,K.jsx)(`div`,{children:(0,K.jsx)(L,{onClick:()=>window.location.reload(),endIcon:(0,K.jsx)(b,{}),style:{marginLeft:`10px`,color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Refresh`})})]})]}):(0,K.jsx)(Vt,{})}var er=(0,G.memo)($n);function tr({version:e,changelog:t}){let{online:n}=(0,G.useContext)(J);return Q&&console.log(`HomeShowChangelog rendering...`),n?(0,K.jsxs)(X,{children:[(0,K.jsx)(Ut,{children:(0,K.jsx)(Wt,{children:`Matterbridge Update`})}),(0,K.jsxs)(Jt,{style:{flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`},children:[(0,K.jsxs)(`h4`,{style:{margin:0},children:[`Matterbridge has been updated to version `,e,`.`]}),(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:`10px`},children:[(0,K.jsx)(L,{onClick:()=>window.open(`https://github.com/Luligu/matterbridge`,`_blank`),endIcon:(0,K.jsx)(te,{style:{color:`#FFD700`}}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Star`}),(0,K.jsx)(L,{onClick:()=>window.open(`https://www.buymeacoffee.com/luligugithub`,`_blank`),endIcon:(0,K.jsx)(Ue,{style:{color:`#b6409c`}}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Sponsor`}),(0,K.jsx)(L,{onClick:()=>window.open(t,`_blank`),endIcon:(0,K.jsx)(Ye,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Changelog`}),(0,K.jsx)(L,{onClick:()=>window.location.reload(),endIcon:(0,K.jsx)(re,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Close`})]})]})]}):(0,K.jsx)(Vt,{})}var nr=(0,G.memo)(tr);function rr({matterbridgeInfo:e}){let{mobile:t}=(0,G.useContext)(It);Q&&console.log(`MatterbridgeInfoTable:`,e);let n=[`matterbridgeLatestVersion`,`matterbridgeDevVersion`,`dockerDev`,`dockerLatestVersion`,`dockerDevVersion`,`--matterFileLogger`,`--fileLogger`,`--matterLoggerLevel`,`--loggerLevel`,`--virtualMode`,`--bridgeMode`,`--restartMode`,`--restartRequired`,`fixedRestartRequired`,`--updateRequired`,`matterMdnsInterface`,`matterIpv4Address`,`matterIpv6Address`,`readOnly`,`shellyBoard`,`shellySysUpdate`,`shellyMainUpdate`,`matterPort`,`matterDiscriminator`,`matterPasscode`],[r,i]=(0,G.useState)(!1);return!e||r?null:(Q&&console.log(`MatterbridgeInfoTable rendering...`),(0,K.jsxs)(X,{style:$&&t?{flex:`1 1 300px`}:{flex:`0 1 auto`,width:`302px`,minWidth:`302px`},children:[(0,K.jsxs)(Ut,{children:[(0,K.jsx)(Wt,{children:`Matterbridge info`}),(0,K.jsx)(Yt,{close:()=>i(!0)})]}),(0,K.jsx)(Jt,{style:$&&t?{flex:`1 1 auto`,margin:`0px`,padding:`0px`,gap:`0px`}:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`0px`,gap:`0px`},children:(0,K.jsxs)(`table`,{style:{border:`none`,borderCollapse:`collapse`,tableLayout:`fixed`},children:[(0,K.jsxs)(`colgroup`,{children:[(0,K.jsx)(`col`,{style:{width:`40%`}}),(0,K.jsx)(`col`,{style:{width:`60%`}})]}),(0,K.jsx)(`tbody`,{style:{border:`none`,borderCollapse:`collapse`},children:Object.entries(e).filter(([e,t])=>!n.includes(e)&&t!=null&&t!==``).map(([e,n],r)=>(0,K.jsxs)(`tr`,{className:r%2==0?`table-content-even`:`table-content-odd`,style:{border:`none`,borderCollapse:`collapse`},children:[(0,K.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`},children:e.replace(`matterbridgeVersion`,`Matterbridge version`).replace(`frontendVersion`,`Frontend version`).replace(`dockerVersion`,`Docker version`).replace(`homeDirectory`,`Home`).replace(`rootDirectory`,`Root`).replace(`matterbridgeDirectory`,`Storage`).replace(`matterbridgeCertDirectory`,`Cert`).replace(`matterbridgePluginDirectory`,`Plugins`).replace(`globalModulesDirectory`,`Modules`).replace(`bridgeMode`,`Bridge mode`).replace(`restartMode`,`Restart mode`).replace(`virtualMode`,`Virtual mode`).replace(`profile`,`Profile`).replace(`loggerLevel`,`Logger level`).replace(`fileLogger`,`File logger`).replace(`loggerLevel`,`Logger level`).replace(`fileLogger`,`File logger`).replace(`matterLoggerLevel`,`Matter logger level`).replace(`matterFileLogger`,`Matter file logger`).replace(`restartRequired`,`Restart required`).replace(`updateRequired`,`Update required`)}),(0,K.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:$&&t?typeof n==`string`?n:n.toString():(0,K.jsx)(Ht,{value:typeof n==`string`?n:n.toString(),maxChars:24})})]},e))})]})})]}))}var ir=(0,G.memo)(rr);function ar(){let[e,t]=(0,G.useState)(null),[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)([]),[o]=(0,G.useState)(localStorage.getItem(q.homePagePlugins)!==`false`),[s,c]=(0,G.useState)(localStorage.getItem(q.homePageMode)??`devices`),[l,u]=(0,G.useState)(`https://matterbridge.io/CHANGELOG.html`),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(null),{mobile:_}=(0,G.useContext)(It),{addListener:v,removeListener:y,online:b,sendMessage:x,getUniqueId:S}=(0,G.useContext)(J),C=(0,G.useRef)(S());return(0,G.useEffect)(()=>{let e=e=>{Q&&console.log(`Home received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`settings`&&(Q&&console.log(`Home received refresh_required: changed=${e.response.changed} and sending /api/settings request`),g(null),a([]),x({id:C.current,sender:`Home`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),x({id:C.current,sender:`Home`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})),e.method===`/api/settings`&&e.id===C.current&&(Q&&console.log(`Home received settings:`,e.response),t(e.response.systemInformation),r(e.response.matterbridgeInformation),localStorage.getItem(q.frontendVersion)===null&&e.response.matterbridgeInformation.frontendVersion?localStorage.setItem(q.frontendVersion,e.response.matterbridgeInformation.frontendVersion):e.response.matterbridgeInformation.frontendVersion!==localStorage.getItem(q.frontendVersion)&&e.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem(q.frontendVersion,e.response.matterbridgeInformation.frontendVersion),m(!0)),localStorage.getItem(q.matterbridgeVersion)===null?localStorage.setItem(q.matterbridgeVersion,e.response.matterbridgeInformation.matterbridgeVersion):e.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem(q.matterbridgeVersion)&&(localStorage.setItem(q.matterbridgeVersion,e.response.matterbridgeInformation.matterbridgeVersion),f(!0)),e.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem(q.homePageMode)||(localStorage.setItem(q.homePageMode,`devices`),c(`devices`)))),e.method===`/api/plugins`&&e.id===C.current&&(Q&&console.log(`Home received plugins:`,e.response),a(e.response))};return v(e,C.current),Q&&console.log(`Home added WebSocket listener id ${C.current}`),()=>{y(e),Q&&console.log(`Home removed WebSocket listener`)}},[v,y,x]),(0,G.useEffect)(()=>{if(Q&&console.log(`Home storeId effect with storeId ${h}`),n?.bridgeMode===`bridge`&&!h&&(Q&&console.log(`Home storeId effect set storeId to Matterbridge`),g(`Matterbridge`)),n?.bridgeMode===`childbridge`&&!h&&i){for(let e of i)if(e.matter?.id){Q&&console.log(`Home storeId effect set storeId to ${e.matter.id}`),g(e.matter.id);break}}},[n,i,h]),(0,G.useEffect)(()=>{b&&(Q&&console.log(`Home online effect, sending /api/settings and /api/plugins requests`),x({id:C.current,sender:`Home`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),x({id:C.current,sender:`Home`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[b,x]),Q&&console.log(`Home rendering...`),!b||!e||!n?(0,K.jsx)(Vt,{}):(0,K.jsxs)(qn,{name:`Home`,style:$&&_?{alignItems:`center`,gap:`10px`}:{flexDirection:`row`},children:[($&&!_||!$)&&(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,width:`302px`,minWidth:`302px`,gap:`20px`},children:[(0,K.jsx)(tn,{id:h}),(0,K.jsx)(Zt,{systemInfo:e,compact:!0})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,width:`100%`,gap:$&&_?`10px`:`20px`},children:[p&&(0,K.jsx)(er,{version:n.frontendVersion}),d&&(0,K.jsx)(nr,{version:n.matterbridgeVersion,changelog:l}),$&&_&&(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:`10px`},children:[(0,K.jsx)(tn,{id:h}),(0,K.jsx)(Zt,{systemInfo:e,compact:!0}),(0,K.jsx)(ir,{matterbridgeInfo:n})]}),o&&!n.readOnly&&(0,K.jsx)(xn,{}),o&&(0,K.jsx)(Un,{storeId:h,setStoreId:g}),s===`devices`&&(0,K.jsx)(Kn,{storeId:h,setStoreId:g}),s===`logs`&&(0,K.jsx)(Qn,{})]})]})}var or=(0,G.memo)(ar),sr=!1,cr={display:`flex`,gap:`2px`,justifyContent:`space-evenly`,width:`100%`,height:`40px`},lr={margin:`0`,padding:`0`,fontSize:`36px`,fontWeight:`medium`,color:`var(--primary-color)`},ur={margin:`0`,padding:`0`,fontSize:`20px`,fontWeight:`medium`,color:`var(--div-text-color)`,textAlign:`center`},dr={margin:`0`,padding:`0`,paddingBottom:`2px`,fontSize:`16px`,fontWeight:`medium`,color:`var(--div-text-color)`,textAlign:`center`},fr={display:`flex`,gap:`2px`,justifyContent:`center`,width:`100%`,height:`18px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},pr={margin:`0`,padding:`0`,fontSize:`12px`,fontWeight:`normal`,color:`var(--div-text-color)`},mr={display:`flex`,justifyContent:`center`,width:`100%`,height:`52px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},hr={margin:`0`,padding:`0`,fontSize:`14px`,fontWeight:`bold`,color:`var(--div-text-color)`},gr={display:`flex`,gap:`4px`,justifyContent:`center`,width:`100%`,height:`15px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},_r={margin:`0`,padding:`0px 4px`,borderRadius:`5px`,textAlign:`center`,fontSize:`12px`,fontWeight:`normal`,color:`var(--secondary-color)`},vr=[256,257,268,269],yr=[266,267],br=[259,260,261,271,272],xr=[256,257,268,269,266,267,259,260,261,272];function Z({icon:e,iconColor:t,cluster:n,value:r,unit:i,prefix:a}){return Q&&console.log(`Render cluster "${n.clusterName}.${n.attributeName}" value(${typeof r}-${isNaN(r)}) "${r}" unit "${i}"`),a??=!1,(0,K.jsxs)(W,{sx:cr,children:[e&&(0,G.cloneElement)(e,{key:`${n.clusterId}-${n.attributeId}-icon`,sx:{...lr,color:t??`var(--primary-color)`}}),(0,K.jsxs)(W,{sx:{...cr,gap:`4px`,alignContent:`center`,alignItems:`end`,justifyContent:`center`},children:[i&&a===!0&&(0,K.jsx)(p,{sx:dr,children:i},`${n.clusterId}-${n.attributeId}-unit`),(0,K.jsx)(p,{sx:ur,children:r==null||typeof r==`number`&&isNaN(r)||r===`NaN`?`---`:r},`${n.clusterId}-${n.attributeId}-value`),i&&a===!1&&(0,K.jsx)(p,{sx:dr,children:i},`${n.clusterId}-${n.attributeId}-unit`)]},`${n.clusterId}-${n.attributeId}-valueunitbox`)]},`${n.clusterId}-${n.attributeId}-box`)}function Sr({device:e,endpoint:t,id:n,deviceType:r,clusters:i}){let a=[`Unknown`,`Good`,`Fair`,`Moderate`,`Poor`,`VeryPoor`,`Ext.Poor`],o=``;Q&&console.log(`Device "${e.name}" endpoint "${t}" id "${n}" deviceType "0x${r.toString(16).padStart(4,`0`)}" clusters (${i?.length})`);let s=i.find(e=>e.clusterName===`Descriptor`&&e.attributeName===`tagList`)?.attributeLocalValue;if(s){let e=``;s.map(t=>{t.label&&(e+=t.label+` `)}),o=e.trim()}if(r===17&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`batVoltage`).map(e=>o=`${e.attributeLocalValue} mV`),xr.includes(r)&&i.filter(e=>e.clusterName===`LevelControl`&&e.attributeName===`currentLevel`).map(e=>o=`Level ${e.attributeValue}`),r===514&&i.filter(e=>e.clusterName===`WindowCovering`&&e.attributeName===`currentPositionLiftPercent100ths`).map(e=>o=`Position ${e.attributeLocalValue/100}%`),r===769&&i.filter(e=>e.clusterName===`Thermostat`&&e.attributeName===`occupiedHeatingSetpoint`).map(e=>o=`Heat ${e.attributeLocalValue/100}°C `),r===769&&i.filter(e=>e.clusterName===`Thermostat`&&e.attributeName===`occupiedCoolingSetpoint`).map(e=>o+=`Cool ${e.attributeLocalValue/100}°C`),r===118&&i.filter(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`coState`).map(e=>o=`${e.attributeLocalValue===0?`No CO detected`:`CO alarm!`}`),r===1296&&i.filter(e=>e.clusterName===`ElectricalPowerMeasurement`&&e.attributeName===`voltage`).map(e=>o=`${e.attributeLocalValue/1e3} V, `),r===1296&&i.filter(e=>e.clusterName===`ElectricalPowerMeasurement`&&e.attributeName===`activeCurrent`).map(e=>o+=`${e.attributeLocalValue/1e3} A, `),r===1296&&i.filter(e=>e.clusterName===`ElectricalPowerMeasurement`&&e.attributeName===`activePower`).map(e=>o+=`${e.attributeLocalValue/1e3} W`),r===39){let e=i.find(e=>e.clusterName===`ModeSelect`&&e.attributeName===`currentMode`)?.attributeLocalValue;o=(i.find(e=>e.clusterName===`ModeSelect`&&e.attributeName===`supportedModes`)?.attributeLocalValue)?.find(t=>t.mode===e)?.label||`Unknown`}if(r===116){let e=i.find(e=>e.clusterName===`RvcRunMode`&&e.attributeName===`currentMode`)?.attributeLocalValue;o=(i.find(e=>e.clusterName===`RvcRunMode`&&e.attributeName===`supportedModes`)?.attributeLocalValue)?.find(t=>t.mode===e)?.label||`Unknown`}return(0,K.jsxs)(X,{style:{margin:`0px`,padding:`5px`,width:`150px`,height:`150px`,borderColor:`var(--div-bg-color)`,borderRadius:`5px`,justifyContent:`space-between`},children:[r===19&&i.filter(e=>e.clusterName===`BridgedDeviceBasicInformation`&&e.attributeName===`reachable`).map(e=>(0,K.jsx)(Z,{icon:e.attributeLocalValue===!0?(0,K.jsx)(k,{}):(0,K.jsx)(Ie,{}),iconColor:e.attributeLocalValue===!0?`green`:`red`,cluster:e,value:e.attributeLocalValue===!0?`Online`:`Offline`})),r===17&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`batPercentRemaining`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(j,{}),cluster:e,value:e.attributeLocalValue/2,unit:`%`})),r===17&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`wiredCurrentType`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(E,{}),cluster:e,value:e.attributeLocalValue===0?`AC`:`DC`})),r===1293&&i.filter(e=>e.clusterName===`DeviceEnergyManagement`&&e.attributeName===`esaState`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M8.28,5.45L6.5,4.55L7.76,2H16.23L17.5,4.55L15.72,5.44L15,4H9L8.28,5.45M18.62,8H14.09L13.3,5H10.7L9.91,8H5.38L4.1,10.55L5.89,11.44L6.62,10H17.38L18.1,11.45L19.89,10.56L18.62,8M17.77,22H15.7L15.46,21.1L12,15.9L8.53,21.1L8.3,22H6.23L9.12,11H11.19L10.83,12.35L12,14.1L13.16,12.35L12.81,11H14.88L17.77,22M11.4,15L10.5,13.65L9.32,18.13L11.4,15M14.68,18.12L13.5,13.64L12.6,15L14.68,18.12Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Offline`:`Online`})),vr.includes(r)&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Se,{}),cluster:e,value:e.attributeLocalValue===!0?`On`:`Off`})),yr.includes(r)&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M7.5,10.5A1.5,1.5 0 0,1 9,12A1.5,1.5 0 0,1 7.5,13.5C6.66,13.5 6,12.83 6,12A1.5,1.5 0 0,1 7.5,10.5M16.5,10.5A1.5,1.5 0 0,1 18,12A1.5,1.5 0 0,1 16.5,13.5A1.5,1.5 0 0,1 15,12A1.5,1.5 0 0,1 16.5,10.5M4.22,2H19.78C21,2 22,3 22,4.22V19.78A2.22,2.22 0 0,1 19.78,22H4.22C3,22 2,21 2,19.78V4.22A2.22,2.22 0 0,1 4.22,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===!0?`On`:`Off`})),br.includes(r)&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M8 6V18H16V6H8M14 10H10V8H14V10M19.4 1.6C19 1.2 18.5 1 18 1H6C5.5 1 5 1.2 4.6 1.6C4.2 2 4 2.5 4 3V21C4 21.5 4.2 22 4.6 22.4C5 22.8 5.5 23 6 23H18C18.5 23 19 22.8 19.4 22.4C19.8 22 20 21.5 20 21V3C20 2.5 19.8 2 19.4 1.6M18 21H6V3H18V21Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===!0?`On`:`Off`})),r===115&&i.filter(e=>e.clusterName===`OperationalState`&&e.attributeName===`operationalState`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M14.83,11.17C16.39,12.73 16.39,15.27 14.83,16.83C13.27,18.39 10.73,18.39 9.17,16.83L14.83,11.17M6,2H18A2,2 0 0,1 20,4V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2M7,4A1,1 0 0,0 6,5A1,1 0 0,0 7,6A1,1 0 0,0 8,5A1,1 0 0,0 7,4M10,4A1,1 0 0,0 9,5A1,1 0 0,0 10,6A1,1 0 0,0 11,5A1,1 0 0,0 10,4M12,8A6,6 0 0,0 6,14A6,6 0 0,0 12,20A6,6 0 0,0 18,14A6,6 0 0,0 12,8Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Normal`:`Error`})),r===124&&i.filter(e=>e.clusterName===`OperationalState`&&e.attributeName===`operationalState`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M6,2H18A2,2 0 0,1 20,4V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2M7,4A1,1 0 0,0 6,5A1,1 0 0,0 7,6A1,1 0 0,0 8,5A1,1 0 0,0 7,4M10,4A1,1 0 0,0 9,5A1,1 0 0,0 10,6A1,1 0 0,0 11,5A1,1 0 0,0 10,4M12,8A6,6 0 0,0 6,14A6,6 0 0,0 12,20A6,6 0 0,0 18,14A6,6 0 0,0 12,8M8.11,10.5H10C9.76,11.88 10,12.67 10.58,13.29C11.68,14.36 12.16,15.71 11.89,17.5H10C10.24,16.12 10,15.33 9.42,14.71C8.32,13.64 7.85,12.29 8.11,10.5M12.11,10.5H14C13.76,11.88 14,12.67 14.58,13.29C15.68,14.36 16.16,15.71 15.89,17.5H14C14.24,16.12 14,15.33 13.42,14.71C12.32,13.64 11.85,12.29 12.11,10.5Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Normal`:`Error`})),r===117&&i.filter(e=>e.clusterName===`OperationalState`&&e.attributeName===`operationalState`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M18,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V4A2,2 0 0,0 18,2M10,4A1,1 0 0,1 11,5A1,1 0 0,1 10,6A1,1 0 0,1 9,5A1,1 0 0,1 10,4M7,4A1,1 0 0,1 8,5A1,1 0 0,1 7,6A1,1 0 0,1 6,5A1,1 0 0,1 7,4M18,20H6V8H18V20M14.67,15.33C14.69,16.03 14.41,16.71 13.91,17.21C12.86,18.26 11.15,18.27 10.09,17.21C9.59,16.71 9.31,16.03 9.33,15.33C9.4,14.62 9.63,13.94 10,13.33C10.37,12.5 10.81,11.73 11.33,11L12,10C13.79,12.59 14.67,14.36 14.67,15.33`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Normal`:`Error`})),r===123&&i.filter(e=>e.clusterName===`BridgedDeviceBasicInformation`&&e.attributeName===`reachable`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Xe,{}),cluster:e,value:`Oven`})),r===112&&i.filter(e=>e.clusterName===`BridgedDeviceBasicInformation`&&e.attributeName===`reachable`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(We,{}),cluster:e,value:`Fridge`})),r===113&&i.filter(e=>e.clusterName===`TemperatureControl`&&e.attributeName===`selectedTemperatureLevel`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M5,3A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3H5M12,5C13.57,5 15,5.5 16.19,6.4L14,8.56C13.43,8.21 12.74,8 12,8A4,4 0 0,0 8,12C8,13.1 8.45,14.1 9.17,14.83L7.05,16.95C5.78,15.68 5,13.93 5,12A7,7 0 0,1 12,5M17.6,7.81C18.5,9 19,10.43 19,12C19,13.93 18.22,15.68 16.95,16.95L14.83,14.83C15.55,14.1 16,13.1 16,12C16,11.26 15.79,10.57 15.43,10L17.6,7.81Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue,unit:`mode`,prefix:!0})),r===121&&i.filter(e=>e.clusterName===`OperationalState`&&e.attributeName===`operationalState`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Xe,{}),cluster:e,value:e.attributeLocalValue===0?`Normal`:`Error`})),r===122&&i.filter(e=>e.clusterName===`FanControl`&&e.attributeName===`fanMode`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M19,18.31V20A2,2 0 0,1 17,22H7A2,2 0 0,1 5,20V16.3C4.54,16.12 3.95,16 3,16A1,1 0 0,1 2,15A1,1 0 0,1 3,14C3.82,14 4.47,14.08 5,14.21V12.3C4.54,12.12 3.95,12 3,12A1,1 0 0,1 2,11A1,1 0 0,1 3,10C3.82,10 4.47,10.08 5,10.21V8.3C4.54,8.12 3.95,8 3,8A1,1 0 0,1 2,7A1,1 0 0,1 3,6C3.82,6 4.47,6.08 5,6.21V4A2,2 0 0,1 7,2H17A2,2 0 0,1 19,4V6.16C20.78,6.47 21.54,7.13 21.71,7.29C22.1,7.68 22.1,8.32 21.71,8.71C21.32,9.1 20.8,9.09 20.29,8.71V8.71C20.29,8.71 19.25,8 17,8C15.74,8 14.91,8.41 13.95,8.9C12.91,9.41 11.74,10 10,10C9.64,10 9.31,10 9,9.96V7.95C9.3,8 9.63,8 10,8C11.26,8 12.09,7.59 13.05,7.11C14.09,6.59 15.27,6 17,6V4H7V20H17V18C18.5,18 18.97,18.29 19,18.31M17,10C15.27,10 14.09,10.59 13.05,11.11C12.09,11.59 11.26,12 10,12C9.63,12 9.3,12 9,11.95V13.96C9.31,14 9.64,14 10,14C11.74,14 12.91,13.41 13.95,12.9C14.91,12.42 15.74,12 17,12C19.25,12 20.29,12.71 20.29,12.71V12.71C20.8,13.1 21.32,13.1 21.71,12.71C22.1,12.32 22.1,11.69 21.71,11.29C21.5,11.08 20.25,10 17,10M17,14C15.27,14 14.09,14.59 13.05,15.11C12.09,15.59 11.26,16 10,16C9.63,16 9.3,16 9,15.95V17.96C9.31,18 9.64,18 10,18C11.74,18 12.91,17.41 13.95,16.9C14.91,16.42 15.74,16 17,16C19.25,16 20.29,16.71 20.29,16.71V16.71C20.8,17.1 21.32,17.1 21.71,16.71C22.1,16.32 22.1,15.69 21.71,15.29C21.5,15.08 20.25,14 17,14Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue,unit:`mode`,prefix:!0})),r===120&&i.filter(e=>e.clusterName===`BridgedDeviceBasicInformation`&&e.attributeName===`reachable`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M6,14H8L11,17H9L6,14M4,4H5V3A1,1 0 0,1 6,2H10A1,1 0 0,1 11,3V4H13V3A1,1 0 0,1 14,2H18A1,1 0 0,1 19,3V4H20A2,2 0 0,1 22,6V19A2,2 0 0,1 20,21V22H17V21H7V22H4V21A2,2 0 0,1 2,19V6A2,2 0 0,1 4,4M18,7A1,1 0 0,1 19,8A1,1 0 0,1 18,9A1,1 0 0,1 17,8A1,1 0 0,1 18,7M14,7A1,1 0 0,1 15,8A1,1 0 0,1 14,9A1,1 0 0,1 13,8A1,1 0 0,1 14,7M20,6H4V10H20V6M4,19H20V12H4V19M6,7A1,1 0 0,1 7,8A1,1 0 0,1 6,9A1,1 0 0,1 5,8A1,1 0 0,1 6,7M13,14H15L18,17H16L13,14Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`Cooktop`})),r===119&&i.filter(e=>e.clusterName===`TemperatureControl`&&e.attributeName===`selectedTemperatureLevel`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M6,14H8L11,17H9L6,14M4,4H5V3A1,1 0 0,1 6,2H10A1,1 0 0,1 11,3V4H13V3A1,1 0 0,1 14,2H18A1,1 0 0,1 19,3V4H20A2,2 0 0,1 22,6V19A2,2 0 0,1 20,21V22H17V21H7V22H4V21A2,2 0 0,1 2,19V6A2,2 0 0,1 4,4M18,7A1,1 0 0,1 19,8A1,1 0 0,1 18,9A1,1 0 0,1 17,8A1,1 0 0,1 18,7M14,7A1,1 0 0,1 15,8A1,1 0 0,1 14,9A1,1 0 0,1 13,8A1,1 0 0,1 14,7M20,6H4V10H20V6M4,19H20V12H4V19M6,7A1,1 0 0,1 7,8A1,1 0 0,1 6,9A1,1 0 0,1 5,8A1,1 0 0,1 6,7M13,14H15L18,17H16L13,14Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue,unit:`mode`,prefix:!0})),r===514&&i.filter(e=>e.clusterName===`WindowCovering`&&e.attributeName===`currentPositionLiftPercent100ths`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(st,{}),cluster:e,value:e.attributeLocalValue/100,unit:`%`})),r===769&&i.filter(e=>e.clusterName===`Thermostat`&&e.attributeName===`localTemperature`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M16.95,16.95L14.83,14.83C15.55,14.1 16,13.1 16,12C16,11.26 15.79,10.57 15.43,10L17.6,7.81C18.5,9 19,10.43 19,12C19,13.93 18.22,15.68 16.95,16.95M12,5C13.57,5 15,5.5 16.19,6.4L14,8.56C13.43,8.21 12.74,8 12,8A4,4 0 0,0 8,12C8,13.1 8.45,14.1 9.17,14.83L7.05,16.95C5.78,15.68 5,13.93 5,12A7,7 0 0,1 12,5M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:(e.attributeLocalValue??0)/100,unit:`°C`})),r===10&&i.filter(e=>e.clusterName===`DoorLock`&&e.attributeName===`lockState`).map(e=>(0,K.jsx)(Z,{icon:e.attributeValue===`1`?(0,K.jsx)(ve,{}):(0,K.jsx)(ke,{}),cluster:e,value:e.attributeValue===`1`?`Locked`:`Unlocked`})),r===43&&i.filter(e=>e.clusterName===`FanControl`&&e.attributeName===`percentCurrent`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Be,{}),cluster:e,value:e.attributeValue,unit:`%`})),r===15&&i.filter(e=>e.clusterName===`Switch`&&e.attributeName===`currentPosition`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M13 5C15.21 5 17 6.79 17 9C17 10.5 16.2 11.77 15 12.46V11.24C15.61 10.69 16 9.89 16 9C16 7.34 14.66 6 13 6S10 7.34 10 9C10 9.89 10.39 10.69 11 11.24V12.46C9.8 11.77 9 10.5 9 9C9 6.79 10.79 5 13 5M20 20.5C19.97 21.32 19.32 21.97 18.5 22H13C12.62 22 12.26 21.85 12 21.57L8 17.37L8.74 16.6C8.93 16.39 9.2 16.28 9.5 16.28H9.7L12 18V9C12 8.45 12.45 8 13 8S14 8.45 14 9V13.47L15.21 13.6L19.15 15.79C19.68 16.03 20 16.56 20 17.14V20.5M20 2H4C2.9 2 2 2.9 2 4V12C2 13.11 2.9 14 4 14H8V12L4 12L4 4H20L20 12H18V14H20V13.96L20.04 14C21.13 14 22 13.09 22 12V4C22 2.9 21.11 2 20 2Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeValue,unit:`pos`,prefix:!0})),r===39&&i.filter(e=>e.clusterName===`ModeSelect`&&e.attributeName===`currentMode`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Ce,{}),cluster:e,value:e.attributeValue,unit:`Mode`,prefix:!0})),r===771&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Ae,{}),cluster:e,value:e.attributeLocalValue===!0?`On`:`Off`})),r===45&&i.filter(e=>e.clusterName===`FanControl`&&e.attributeName===`percentCurrent`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Ke,{}),cluster:e,value:e.attributeValue,unit:`%`})),r===114&&i.filter(e=>e.clusterName===`Thermostat`&&e.attributeName===`localTemperature`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Ke,{}),cluster:e,value:(e.attributeLocalValue??0)/100,unit:`°C`})),r===67&&i.filter(e=>e.clusterName===`BooleanState`&&e.attributeName===`stateValue`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(et,{}),cluster:e,value:e.attributeLocalValue===!0?`Leak`:`No leak`})),r===65&&i.filter(e=>e.clusterName===`BooleanState`&&e.attributeName===`stateValue`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Oe,{}),cluster:e,value:e.attributeLocalValue===!0?`Freeze`:`No freeze`})),r===68&&i.filter(e=>e.clusterName===`BooleanState`&&e.attributeName===`stateValue`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Te,{}),cluster:e,value:e.attributeLocalValue===!0?`Rain`:`No rain`})),r===116&&i.filter(e=>e.clusterName===`RvcRunMode`&&e.attributeName===`currentMode`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M12,2C14.65,2 17.19,3.06 19.07,4.93L17.65,6.35C16.15,4.85 14.12,4 12,4C9.88,4 7.84,4.84 6.35,6.35L4.93,4.93C6.81,3.06 9.35,2 12,2M3.66,6.5L5.11,7.94C4.39,9.17 4,10.57 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12C20,10.57 19.61,9.17 18.88,7.94L20.34,6.5C21.42,8.12 22,10.04 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12C2,10.04 2.58,8.12 3.66,6.5M12,6A6,6 0 0,1 18,12C18,13.59 17.37,15.12 16.24,16.24L14.83,14.83C14.08,15.58 13.06,16 12,16C10.94,16 9.92,15.58 9.17,14.83L7.76,16.24C6.63,15.12 6,13.59 6,12A6,6 0 0,1 12,6M12,8A1,1 0 0,0 11,9A1,1 0 0,0 12,10A1,1 0 0,0 13,9A1,1 0 0,0 12,8Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeValue,unit:`Run mode`,prefix:!0})),r===1292&&i.filter(e=>e.clusterName===`EnergyEvse`&&e.attributeName===`state`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M19.77,7.23L19.78,7.22L16.06,3.5L15,4.56L17.11,6.67C16.17,7.03 15.5,7.93 15.5,9A2.5,2.5 0 0,0 18,11.5C18.36,11.5 18.69,11.42 19,11.29V18.5A1,1 0 0,1 18,19.5A1,1 0 0,1 17,18.5V14A2,2 0 0,0 15,12H14V5A2,2 0 0,0 12,3H6A2,2 0 0,0 4,5V21H14V13.5H15.5V18.5A2.5,2.5 0 0,0 18,21A2.5,2.5 0 0,0 20.5,18.5V9C20.5,8.31 20.22,7.68 19.77,7.23M18,10A1,1 0 0,1 17,9A1,1 0 0,1 18,8A1,1 0 0,1 19,9A1,1 0 0,1 18,10M8,18V13.5H6L10,6V11H12L8,18Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Free`:`In use`})),r===1295&&i.filter(e=>e.clusterName===`WaterHeaterManagement`&&e.attributeName===`tankPercentage`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M8 2C6.89 2 6 2.89 6 4V16C6 17.11 6.89 18 8 18H9V20H6V22H9C10.11 22 11 21.11 11 20V18H13V20C13 21.11 13.89 22 15 22H18V20H15V18H16C17.11 18 18 17.11 18 16V4C18 2.89 17.11 2 16 2H8M12 4.97A2 2 0 0 1 14 6.97A2 2 0 0 1 12 8.97A2 2 0 0 1 10 6.97A2 2 0 0 1 12 4.97M10 14.5H14V16H10V14.5Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`Tank `+(e.attributeLocalValue??0)+`%`})),r===777&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`featureMap`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3M12.75 7.08C13.57 7.2 14.32 7.5 14.95 8L12.75 10.19V7.08M11.25 7.08V10.19L9.05 8C9.68 7.5 10.43 7.2 11.25 7.08M8 9.05L10.19 11.25H7.08C7.2 10.43 7.5 9.68 8 9.05M7.08 12.75H10.19L8 14.95C7.5 14.32 7.2 13.57 7.08 12.75M11.25 16.92C10.43 16.8 9.68 16.5 9.05 16L11.25 13.81V16.92M12 13C11.45 13 11 12.55 11 12S11.45 11 12 11 13 11.45 13 12 12.55 13 12 13M12.75 16.92V13.81L14.95 16C14.32 16.5 13.57 16.8 12.75 16.92M16 14.95L13.81 12.75H16.92C16.8 13.57 16.5 14.32 16 14.95M13.81 11.25L16 9.05C16.5 9.69 16.8 10.44 16.92 11.25H13.81Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`HeatPump`})),r===23&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`featureMap`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M4,2H20A2,2 0 0,1 22,4V14A2,2 0 0,1 20,16H15V20H18V22H13V16H11V22H6V20H9V16H4A2,2 0 0,1 2,14V4A2,2 0 0,1 4,2M4,4V8H11V4H4M4,14H11V10H4V14M20,14V10H13V14H20M20,4H13V8H20V4Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`Solar`})),r===24&&i.filter(e=>e.clusterName===`ElectricalPowerMeasurement`&&e.attributeName===`featureMap`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M12 20L5 20V12H2L12 3L14.78 5.5H14V7.17C12.84 7.58 12 8.7 12 10V20M15 9H16V7.5H20V9H21C21.55 9 22 9.45 22 10V21C22 21.55 21.55 22 21 22H15C14.45 22 14 21.55 14 21V10C14 9.45 14.45 9 15 9M16 11V14H20V11H16Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`Inverter`})),r===118&&i.find(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`featureMap`&&e.attributeLocalValue.smokeAlarm===!0)&&i.filter(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`smokeState`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M12 4C16.41 4 20 7.59 20 12S16.41 20 12 20 4 16.41 4 12 7.59 4 12 4M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 11C11.45 11 11 11.45 11 12S11.45 13 12 13 13 12.55 13 12 12.55 11 12 11M10.72 9.3C11.11 9.11 11.54 9 12 9S12.89 9.11 13.29 9.3L14 8.57C13.43 8.22 12.74 8 12 8S10.58 8.22 10 8.57L10.72 9.3M15 12C15 12.46 14.89 12.89 14.7 13.29L15.43 14C15.79 13.43 16 12.74 16 12S15.79 10.58 15.43 10L14.7 10.72C14.89 11.11 15 11.54 15 12M9 12C9 11.54 9.11 11.11 9.3 10.72L8.57 10C8.22 10.58 8 11.26 8 12S8.22 13.43 8.57 14L9.3 13.29C9.11 12.89 9 12.46 9 12M13.29 14.7C12.89 14.89 12.46 15 12 15S11.11 14.89 10.72 14.7L10 15.43C10.58 15.79 11.26 16 12 16S13.43 15.79 14 15.43L13.29 14.7M16.89 8.53L16.17 9.25C16.69 10.04 17 11 17 12S16.69 13.96 16.17 14.75L16.89 15.47C17.59 14.5 18 13.3 18 12S17.59 9.5 16.89 8.53M9.25 7.83C10.04 7.31 11 7 12 7S13.96 7.31 14.75 7.83L15.47 7.11C14.5 6.42 13.3 6 12 6S9.5 6.42 8.53 7.11L9.25 7.83M14.75 16.17C13.96 16.69 13 17 12 17S10.04 16.69 9.25 16.17L8.53 16.89C9.5 17.59 10.7 18 12 18S14.5 17.59 15.47 16.89L14.75 16.17M7.83 14.75C7.31 13.96 7 13 7 12S7.31 10.04 7.83 9.25L7.11 8.53C6.42 9.5 6 10.7 6 12S6.42 14.5 7.11 15.47L7.83 14.75Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`No smoke`:`Smoke!`})),r===118&&i.find(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`featureMap`&&e.attributeLocalValue.smokeAlarm===!1)&&i.filter(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`coState`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M12 4C16.41 4 20 7.59 20 12S16.41 20 12 20 4 16.41 4 12 7.59 4 12 4M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 11C11.45 11 11 11.45 11 12S11.45 13 12 13 13 12.55 13 12 12.55 11 12 11M10.72 9.3C11.11 9.11 11.54 9 12 9S12.89 9.11 13.29 9.3L14 8.57C13.43 8.22 12.74 8 12 8S10.58 8.22 10 8.57L10.72 9.3M15 12C15 12.46 14.89 12.89 14.7 13.29L15.43 14C15.79 13.43 16 12.74 16 12S15.79 10.58 15.43 10L14.7 10.72C14.89 11.11 15 11.54 15 12M9 12C9 11.54 9.11 11.11 9.3 10.72L8.57 10C8.22 10.58 8 11.26 8 12S8.22 13.43 8.57 14L9.3 13.29C9.11 12.89 9 12.46 9 12M13.29 14.7C12.89 14.89 12.46 15 12 15S11.11 14.89 10.72 14.7L10 15.43C10.58 15.79 11.26 16 12 16S13.43 15.79 14 15.43L13.29 14.7M16.89 8.53L16.17 9.25C16.69 10.04 17 11 17 12S16.69 13.96 16.17 14.75L16.89 15.47C17.59 14.5 18 13.3 18 12S17.59 9.5 16.89 8.53M9.25 7.83C10.04 7.31 11 7 12 7S13.96 7.31 14.75 7.83L15.47 7.11C14.5 6.42 13.3 6 12 6S9.5 6.42 8.53 7.11L9.25 7.83M14.75 16.17C13.96 16.69 13 17 12 17S10.04 16.69 9.25 16.17L8.53 16.89C9.5 17.59 10.7 18 12 18S14.5 17.59 15.47 16.89L14.75 16.17M7.83 14.75C7.31 13.96 7 13 7 12S7.31 10.04 7.83 9.25L7.11 8.53C6.42 9.5 6 10.7 6 12S6.42 14.5 7.11 15.47L7.83 14.75Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`No Co`:`Co!`})),r===66&&i.filter(e=>e.clusterName===`ValveConfigurationAndControl`&&e.attributeName===`currentState`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Re,{}),cluster:e,value:e.attributeLocalValue===0?`Closed`:`Opened`})),r===44&&i.filter(e=>e.clusterName===`AirQuality`&&e.attributeName===`airQuality`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M11,9A4,4 0 0,1 15,13A4,4 0 0,1 11,17A4,4 0 0,1 7,13A4,4 0 0,1 11,9M11,11A2,2 0 0,0 9,13A2,2 0 0,0 11,15A2,2 0 0,0 13,13A2,2 0 0,0 11,11M7,4H14A4,4 0 0,1 18,8V9H16V8A2,2 0 0,0 14,6H7A2,2 0 0,0 5,8V20H16V18H18V22H3V8A4,4 0 0,1 7,4M16,11C18.5,11 18.5,9 21,9V11C18.5,11 18.5,13 16,13V11M16,15C18.5,15 18.5,13 21,13V15C18.5,15 18.5,17 16,17V15Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:a[e.attributeLocalValue??0]})),r===770&&i.filter(e=>e.clusterName===`TemperatureMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(oe,{}),cluster:e,value:e.attributeLocalValue/100,unit:`°C`})),r===775&&i.filter(e=>e.clusterName===`RelativeHumidityMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(Y.Icon,{path:`M12,3.25C12,3.25 6,10 6,14C6,17.32 8.69,20 12,20A6,6 0 0,0 18,14C18,10 12,3.25 12,3.25M14.47,9.97L15.53,11.03L9.53,17.03L8.47,15.97M9.75,10A1.25,1.25 0 0,1 11,11.25A1.25,1.25 0 0,1 9.75,12.5A1.25,1.25 0 0,1 8.5,11.25A1.25,1.25 0 0,1 9.75,10M14.25,14.5A1.25,1.25 0 0,1 15.5,15.75A1.25,1.25 0 0,1 14.25,17A1.25,1.25 0 0,1 13,15.75A1.25,1.25 0 0,1 14.25,14.5Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue/100,unit:`%`})),r===774&&i.filter(e=>e.clusterName===`FlowMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(ot,{}),cluster:e,value:e.attributeLocalValue,unit:`l/h`})),r===773&&i.filter(e=>e.clusterName===`PressureMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(m,{}),cluster:e,value:e.attributeLocalValue,unit:`hPa`})),r===21&&i.filter(e=>e.clusterName===`BooleanState`&&e.attributeName===`stateValue`).map(e=>(0,K.jsx)(Z,{icon:e.attributeValue===`true`?(0,K.jsx)(g,{}):(0,K.jsx)(ne,{}),cluster:e,value:e.attributeValue===`true`?`Closed`:`Opened`})),r===263&&i.filter(e=>e.clusterName===`OccupancySensing`&&e.attributeName===`occupancy`).map(e=>(0,K.jsx)(Z,{icon:e.attributeValue===`{ occupied: true }`?(0,K.jsx)(v,{}):(0,K.jsx)(ce,{}),cluster:e,value:e.attributeValue===`{ occupied: true }`?`Occupied`:`Unocc.`})),r===262&&i.filter(e=>e.clusterName===`IlluminanceMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(it,{}),cluster:e,value:Math.round(10**(e.attributeLocalValue/1e4)),unit:`lx`})),r===1296&&i.filter(e=>e.clusterName===`ElectricalEnergyMeasurement`&&e.attributeName===`cumulativeEnergyImported`).map(e=>(0,K.jsx)(Z,{icon:(0,K.jsx)(nt,{}),cluster:e,value:Math.round(e.attributeLocalValue?.energy/1e6),unit:`kwh`})),(0,K.jsx)(W,{sx:fr,children:(0,K.jsx)(p,{sx:pr,children:o})}),(0,K.jsx)(W,{sx:mr,children:(0,K.jsx)(p,{sx:hr,children:e.name})}),(0,K.jsxs)(W,{sx:gr,children:[Q&&(0,K.jsx)(p,{sx:_r,children:t}),(0,K.jsx)(p,{sx:_r,children:n}),Q&&(0,K.jsxs)(p,{sx:_r,children:[`0x`,r.toString(16).padStart(4,`0`)]})]})]})}function Cr({filterPlugins:e,filterDevices:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(J),[s,c]=(0,G.useState)([]),[l,u]=(0,G.useState)({}),[d,f]=(0,G.useState)({}),[p,m]=(0,G.useState)({}),h=(0,G.useRef)(o()),g=(0,G.useCallback)(e=>{(Q||sr)&&console.log(`DevicesIcons received state_update "${e.response.cluster}.${e.response.attribute}" for "${e.response.id}:${e.response.number}": "${e.response.value}"`,e.response);let t=s.find(t=>t.pluginName===e.response.plugin&&t.serial===e.response.serialNumber);if(!t){(Q||sr)&&console.warn(`DevicesIcons updater device of plugin "${e.response.plugin}" serial "${e.response.serialNumber}" number "${e.response.number}" id "${e.response.id}" not found in devices(${s.length})`);return}let n=p[t.serial]?.find(t=>t.endpoint===e.response.number.toString()&&t.clusterName===e.response.cluster&&t.attributeName===e.response.attribute);if(!n){(Q||sr)&&console.warn(`DevicesIcons updater device "${t.name}" serial "${t.serial}" cluster "${e.response.cluster}" attribute "${e.response.attribute}" not found in clusters(${p[t.serial]?.length})`);return}n.attributeValue=String(e.response.value),n.attributeLocalValue=e.response.value,m({...p}),(Q||sr)&&console.log(`DevicesIcons updated "${n.clusterName}.${n.attributeName}" for device "${t.name}" serial "${t.serial}" to "${n.attributeValue}"`)},[p,s]),_=(0,G.useCallback)(e=>{if(Q&&console.log(`DevicesIcons received for device "${e.response.deviceName}" serial "${e.response.serialNumber}" deviceTypes (${e.response.deviceTypes.length}) "${e.response.deviceTypes.join(`,`)}" clusters (${e.response.clusters.length}):`,e.response),e.response.clusters.length===0)return;let t=e.response.serialNumber;l[t]=[],d[t]=e.response.deviceTypes,p[t]=[];for(let n of e.response.clusters)l[t].find(e=>e.endpoint===n.endpoint)||l[t].push({endpoint:n.endpoint,id:n.id,deviceTypes:n.deviceTypes}),![`FixedLabel`,`Identify`,`Groups`,`PowerTopology`].includes(n.clusterName)&&p[t].push(n);u({...l}),f({...d}),m({...p}),Q&&console.log(`DevicesIcons endpoints for "${t}":`,l[t]),Q&&console.log(`DevicesIcons deviceTypes for "${t}":`,d[t]),Q&&console.log(`DevicesIcons clusters for "${t}":`,p[t])},[p,d,l]);(0,G.useEffect)(()=>{let e=e=>{if(Q&&console.log(`DevicesIcons received WebSocket Message:`,e),e.method===`refresh_required`)Q&&console.log(`DevicesIcons received refresh_required: changed=${e.response.changed} and sending api requests`),r({id:h.current,sender:`DevicesIcons`,method:`/api/devices`,src:`Frontend`,dst:`Matterbridge`,params:{}});else if(e.method===`state_update`&&e.response)g(e);else if(e.method===`/api/devices`&&e.response){Q&&console.log(`DevicesIcons received ${e.response.length} devices:`,e.response),c(e.response),u({}),f({}),m({});for(let t of e.response)Q&&console.log(`DevicesIcons sending /api/clusters`),r({id:h.current,sender:`DevicesIcons`,method:`/api/clusters`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:t.pluginName,endpoint:t.endpoint||0,serialNumber:t.serial}})}else e.method===`/api/clusters`&&e.response&&_(e)};return i(e,h.current),Q&&console.log(`DevicesIcons WebSocket effect mounted`),()=>{a(e),Q&&console.log(`DevicesIcons WebSocket effect unmounted`)}},[s]),(0,G.useEffect)(()=>(Q&&console.log(`DevicesIcons useEffect online mounting`),n&&(Q&&console.log(`DevicesIcons useEffect online sending api requests`),r({id:h.current,sender:`DevicesIcons`,method:`/api/devices`,src:`Frontend`,dst:`Matterbridge`,params:{}})),Q&&console.log(`DevicesIcons useEffect online mounted`),()=>{Q&&console.log(`DevicesIcons useEffect online unmounted`)}),[n,r]);let v=(0,G.memo)(Sr),y=e?.trim().toLowerCase(),b=y&&y!==`all plugins`;return Q&&console.log(`DevicesIcons rendering...`),(0,K.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,paddingBottom:`5px`,gap:`20px`,width:`100%`,overflow:`auto`},children:s.filter(e=>b&&e.pluginName.toLowerCase()!==y?!1:t===``?!0:e.name.toLowerCase().includes(t.toLowerCase())||e.serial.toLowerCase().includes(t.toLowerCase())).map(e=>l[e.serial]&&l[e.serial].map(t=>t.deviceTypes.map(n=>(0,K.jsx)(v,{device:e,endpoint:t.endpoint,id:t.id,deviceType:n,clusters:p[e.serial].filter(e=>e.endpoint===t.endpoint)},`${e.pluginName}-${e.uniqueId}-${t.endpoint}-${t.id}-${n.toString()}`))))})}var wr=(0,G.memo)(Cr),Tr=[{label:`Plugin name`,id:`pluginName`,required:!0},{label:`Device type`,id:`type`},{label:`Endpoint`,id:`endpoint`,align:`right`},{label:`Name`,id:`name`,required:!0},{label:`Serial number`,id:`serial`},{label:`Unique ID`,id:`uniqueId`},{label:`Url`,id:`configUrl`},{label:`Config`,id:`configButton`,noSort:!0,render:(e,t,n,r)=>n.configUrl?(0,K.jsx)(T,{onClick:()=>window.open(n.configUrl,`_blank`),"aria-label":`Open Config`,sx:{margin:0,padding:0},children:(0,K.jsx)(ae,{fontSize:`small`})}):null},{label:`Cluster`,id:`cluster`}],Er=[{label:`Endpoint`,id:`endpoint`,required:!0},{label:`Id`,id:`id`},{label:`Device Types`,id:`deviceTypes`,render:(e,t,n,r)=>Array.isArray(e)?(0,K.jsx)(K.Fragment,{children:e.map(e=>`0x${e.toString(16).padStart(4,`0`)}`).join(`, `)}):(0,K.jsx)(K.Fragment,{children:e})},{label:`Cluster Name`,id:`clusterName`,required:!0},{label:`Cluster ID`,id:`clusterId`},{label:`Attribute Name`,id:`attributeName`,required:!0},{label:`Attribute ID`,id:`attributeId`},{label:`Attribute Value`,id:`attributeValue`,required:!0,maxWidth:350,tooltip:!0}],Dr=e=>`${e.pluginName}::${e.uniqueId}`,Or=e=>`${e.endpoint}::${e.clusterName}::${e.attributeName}`;function kr({filterPlugins:e,filterDevices:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(J),[s,c]=(0,G.useState)([]),[l,u]=(0,G.useState)(s),[d,f]=(0,G.useState)([]),[p,m]=(0,G.useState)(0),[h,g]=(0,G.useState)(null),[_,v]=(0,G.useState)(null),[y,b]=(0,G.useState)(null),[x,S]=(0,G.useState)(null),C=(0,G.useRef)(o()),w=(0,G.useRef)(l),T=(0,G.useCallback)(e=>{Q&&console.log(`DevicesTable received state_update "${e.response.cluster}.${e.response.attribute}" for "${e.response.id}:${e.response.number}": "${e.response.value}"`,e.response);let t=w.current.find(t=>t.pluginName===e.response.plugin&&t.uniqueId===e.response.uniqueId);if(!t){Q&&console.warn(`DevicesTable updater device of plugin "${e.response.plugin}" serial "${e.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(h&&_&&t.pluginName===h&&t.uniqueId===x&&e.response.number.toString()===_){let n=d.find(t=>t.endpoint===e.response.number.toString()&&t.clusterName===e.response.cluster&&t.attributeName===e.response.attribute);if(!n){Q&&console.warn(`DevicesTable updater cluster ${e.response.cluster}.${e.response.attribute} for device "${t.name}" serial "${t.serial}" not found in clusters`);return}n.attributeValue=typeof e.response.value==`object`?JSON.stringify(e.response.value,void 0,1).replaceAll(`"`,``):String(e.response.value),n.attributeLocalValue=e.response.value,f([...d]),Q&&console.log(`DevicesTable updated attribute ${n.clusterName}.${n.attributeName} for device "${t.name}" serial "${t.serial}" to "${n.attributeValue}"`)}},[d,_,h,x]);return(0,G.useEffect)(()=>{let e=e=>{if(Q&&console.log(`DevicesTable received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`devices`)Q&&console.log(`DevicesTable received refresh_required: changed=${e.response.changed} and sending /api/devices request`),r({id:C.current,sender:`DevicesTable`,method:`/api/devices`,src:`Frontend`,dst:`Matterbridge`,params:{}});else if(e.method===`state_update`&&e.response)T(e);else if(e.method===`/api/devices`)Q&&console.log(`DevicesTable received ${e.response.length} devices:`,e.response),c(e.response);else if(e.method===`/api/clusters`){Q&&console.log(`DevicesTable received ${e.response.clusters.length} clusters for plugin ${e.response.plugin}:`,e.response),f(e.response.clusters);let t={};for(let n of e.response.clusters)Q&&console.log(`Cluster:`,n.endpoint),t[n.endpoint]?t[n.endpoint]++:t[n.endpoint]=1;m(Object.keys(t).length)}};return i(e,C.current),Q&&console.log(`DevicesTable added WebSocket listener`),()=>{a(e),Q&&console.log(`DevicesTable removed WebSocket listener`)}},[r,i,a,T]),(0,G.useEffect)(()=>{n&&(Q&&console.log(`DevicesTable sending api requests with id `,C.current),r({id:C.current,sender:`DevicesTable`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:C.current,sender:`DevicesTable`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:C.current,sender:`DevicesTable`,method:`/api/devices`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[n,r]),(0,G.useEffect)(()=>{h&&_&&x&&(Q&&console.log(`DevicesTable sending /api/clusters`),r({id:C.current,sender:`DevicesTable`,method:`/api/clusters`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:h,endpoint:Number(_),uniqueId:x}}))},[h,_,x,r]),(0,G.useEffect)(()=>{let n=e?.trim().toLowerCase(),r=n&&n!==`all plugins`,i=s;r&&(i=i.filter(e=>e.pluginName.toLowerCase()===n)),t!==``&&(i=i.filter(e=>e.name.toLowerCase().includes(t.toLowerCase())||e.serial.toLowerCase().includes(t.toLowerCase()))),u(i),w.current=i},[s,e,t]),Q&&console.log(`DevicesTable rendering...`),n?(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,margin:`0px`,padding:`0px`,gap:`20px`,width:`100%`,overflow:`hidden`},children:[(0,K.jsx)(X,{style:{margin:`0px`,padding:`0px`,gap:`0px`,width:`100%`,maxHeight:`${h&&_?`30%`:`100%`}`,flex:`1 1 auto`,overflow:`hidden`},children:(0,K.jsx)(cn,{name:`Registered devices`,getRowKey:Dr,onRowClick:e=>{if(e.uniqueId===x){S(null),g(null),v(null),b(null);return}Q&&console.log(`DevicesTable handleDeviceClick: selected device "${e.name}" with uniqueId "${e.uniqueId}", plugin "${e.pluginName}", endpoint "${e.endpoint}"`),S(e.uniqueId),g(e.pluginName),v(e.endpoint?e.endpoint.toString():null),b(e.name)},rows:l,columns:Tr,footerLeft:`Total devices: ${l.length.toString()}`})}),h&&_&&(0,K.jsx)(X,{style:{margin:`0px`,padding:`0px`,gap:`0px`,width:`100%`,height:`70%`,maxHeight:`70%`,flex:`1 1 auto`,overflow:`hidden`},children:(0,K.jsx)(cn,{name:`Clusters`,title:y||``,getRowKey:Or,rows:d,columns:Er,footerLeft:`Total child endpoints: ${p-1}`})})]}):(0,K.jsx)(Vt,{})}var Ar=(0,G.memo)(kr);function jr(){let{online:e,sendMessage:t,addListener:n,removeListener:r,getUniqueId:i}=(0,G.useContext)(J),[a,o]=(0,G.useState)([`All plugins`]),[s,c]=(0,G.useState)(`All plugins`),[l,d]=(0,G.useState)(``),[f,m]=(0,G.useState)(`icon`),h=(0,G.useRef)(i());(0,G.useEffect)(()=>{let e=localStorage.getItem(q.devicesFilterPlugins);e&&c(e)},[]),(0,G.useEffect)(()=>{let e=localStorage.getItem(q.devicesFilterDevices);e&&d(e)},[]),(0,G.useEffect)(()=>{let e=localStorage.getItem(q.devicesViewMode);e&&m(e)},[]),(0,G.useEffect)(()=>{let e=e=>{Q&&e.id&&console.log(`Devices received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`plugins`&&!e.response.lock?(Q&&console.log(`Devices received refresh_required for plugins lock=${e.response.lock}, sending /api/plugins request with id ${h.current}`),t({id:h.current,sender:`Devices`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`/api/plugins`&&e.id===h.current&&e.response&&(Q&&console.log(`Devices received ${e.response.length} plugins:`,e.response),o([`All plugins`,...e.response.map(e=>e.name)]))};return n(e,h.current),Q&&console.log(`Devices added WebSocket listener`),()=>{r(e),Q&&console.log(`Devices removed WebSocket listener`)}},[t,n,r]),(0,G.useEffect)(()=>{e&&(Q&&console.log(`Devices sending /api/plugins request with id `,h.current),t({id:h.current,sender:`Devices`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[e,t]);let g=e=>{let t=e.target.value;c(t),localStorage.setItem(q.devicesFilterPlugins,t)},_=e=>{d(e.target.value),localStorage.setItem(q.devicesFilterDevices,e.target.value)},v=()=>{d(``),localStorage.removeItem(q.devicesFilterDevices)},b=e=>{m(e),localStorage.setItem(q.devicesViewMode,e)};return Q&&console.log(`Devices rendering...`),e?(0,K.jsxs)(qn,{name:`Devices`,children:[(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,padding:0,margin:0,gap:`20px`,width:`100%`},children:[(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,padding:0,margin:0,gap:`20px`},children:[(0,K.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,K.jsx)(p,{sx:{fontSize:`16px`,fontWeight:`normal`,color:`var(--div-text-color)`,marginLeft:`5px`,whiteSpace:`nowrap`},children:`Plugin:`}),(0,K.jsx)(H,{title:`Filter devices by plugin`,children:(0,K.jsx)(ye,{variant:`outlined`,value:s,onChange:g,sx:{width:`260px`,backgroundColor:`var(--main-bg-color)`,"& .MuiOutlinedInput-root":{backgroundColor:`var(--main-bg-color)`},"& .MuiSelect-select":{backgroundColor:`var(--main-bg-color)`},"& .MuiSelect-icon":{color:`var(--main-label-color)`}},input:(0,K.jsx)(rt,{sx:{backgroundColor:`var(--main-bg-color)`}}),children:a.map(e=>(0,K.jsx)(V,{value:e,children:e},e))})})]}),(0,K.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,K.jsx)(p,{sx:{fontSize:`16px`,fontWeight:`normal`,color:`var(--div-text-color)`,marginLeft:`5px`,whiteSpace:`nowrap`},children:`Filter by:`}),(0,K.jsx)(H,{title:`Filter devices by name or serial number`,children:(0,K.jsx)(B,{variant:`outlined`,value:l,onChange:_,placeholder:`Enter the device name or serial`,sx:{width:`260px`,"& .MuiOutlinedInput-root":{backgroundColor:`var(--main-bg-color)`}},slotProps:{input:{endAdornment:l?(0,K.jsx)(y,{position:`end`,children:(0,K.jsx)(T,{"aria-label":`Clear device filter`,size:`small`,onClick:v,edge:`end`,children:(0,K.jsx)(u,{sx:{fontSize:18,color:`var(--main-label-color)`}})})}):null}}})})]})]}),(0,K.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,K.jsx)(p,{sx:{fontSize:`16px`,fontWeight:`normal`,color:`var(--div-text-color)`,marginLeft:`5px`,whiteSpace:`nowrap`},children:`View mode:`}),(0,K.jsx)(T,{onClick:()=>b(`table`),"aria-label":`Table View`,disabled:f===`table`,children:(0,K.jsx)(H,{title:`Table View`,children:(0,K.jsx)(ee,{style:{color:f===`table`?`var(--main-icon-color)`:`var(--primary-color)`}})})}),(0,K.jsx)(T,{onClick:()=>b(`icon`),"aria-label":`Icon View`,disabled:f===`icon`,children:(0,K.jsx)(H,{title:`Icon View (beta)`,children:(0,K.jsx)(Pe,{style:{color:f===`icon`?`var(--main-icon-color)`:`var(--primary-color)`}})})})]})]}),f===`table`&&(0,K.jsx)(Ar,{filterPlugins:s,filterDevices:l}),f===`icon`&&(0,K.jsx)(wr,{filterPlugins:s,filterDevices:l})]}):(0,K.jsx)(Vt,{})}var Mr=(0,G.memo)(jr);function Nr(){let{logLength:e,logAutoScroll:t,setMessages:n,setLogFilterLevel:r,setLogFilterSearch:i,online:a,filterLogMessages:o}=(0,G.useContext)(J),[s,c]=(0,G.useState)(localStorage.getItem(q.logFilterLevel)??`info`),[l,u]=(0,G.useState)(localStorage.getItem(q.logFilterSearch)??`*`),[f,p]=(0,G.useState)(e.current.toString()),[m,h]=(0,G.useState)(t.current);return Q&&console.log(`Logs rendering...`),a?(0,K.jsxs)(qn,{name:`Logs`,children:[(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`,margin:`0px`,padding:`0px`,gap:`10px`},children:[(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,K.jsx)(le,{id:`select-level`,style:{color:`var(--div-text-color)`},children:`Filter log by level:`}),(0,K.jsxs)(ye,{style:{height:`30px`,backgroundColor:`var(--main-bg-color)`},labelId:`select-level`,id:`debug-level`,value:s,onChange:e=>{let t=e.target.value;c(t),r(t),o(t,l),localStorage.setItem(q.logFilterLevel,t),Q&&console.log(`handleLogFilterLevelChange called with value:`,t)},children:[(0,K.jsx)(V,{value:`debug`,children:`Debug`}),(0,K.jsx)(V,{value:`info`,children:`Info`}),(0,K.jsx)(V,{value:`notice`,children:`Notice`}),(0,K.jsx)(V,{value:`warn`,children:`Warn`}),(0,K.jsx)(V,{value:`error`,children:`Error`}),(0,K.jsx)(V,{value:`fatal`,children:`Fatal`})]})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`5px`},children:[(0,K.jsx)(le,{id:`search`,style:{color:`var(--div-text-color)`},children:`Filter log by text:`}),(0,K.jsx)(H,{title:`Use /text/ for case-insensitive regex search`,children:(0,K.jsx)(B,{style:{width:`210px`},size:`small`,id:`logsearch`,variant:`outlined`,value:l,onChange:e=>{let t=e.target.value;u(t),i(t),o(s,t),localStorage.setItem(q.logFilterSearch,t),Q&&console.log(`handleLogFilterSearchChange called with value:`,t)},slotProps:{input:{style:{height:`30px`,padding:`0 0px`,backgroundColor:`var(--main-bg-color)`}}}})})]}),(0,K.jsx)(d,{control:(0,K.jsx)(M,{checked:m,onChange:e=>{let n=e.target.checked;h(n),t.current=n,o(s,l),localStorage.setItem(q.logAutoScroll,n?`true`:`false`),Q&&console.log(`handleAutoScrollChange called with value:`,n)}}),label:`Auto scroll`,style:{color:`var(--div-text-color)`}})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,K.jsx)(le,{id:`select-size-label`,style:{color:`var(--div-text-color)`},children:`Log length:`}),(0,K.jsxs)(ye,{style:{height:`30px`,backgroundColor:`var(--main-bg-color)`},labelId:`select-size-label`,id:`select-size`,value:f,onChange:t=>{let n=t.target.value;p(n),e.current=Number(n),localStorage.setItem(q.logLength,n),Q&&console.log(`handleLogLengthChange called with value:`,n)},children:[(0,K.jsx)(V,{value:100,children:`100`}),(0,K.jsx)(V,{value:200,children:`200`}),(0,K.jsx)(V,{value:500,children:`500`}),(0,K.jsx)(V,{value:1e3,children:`1000`})]}),(0,K.jsx)(H,{title:`Clear the logs`,children:(0,K.jsx)(L,{onClick:()=>{Q&&console.log(`handleClearLogsClick called`),n([])},endIcon:(0,K.jsx)(O,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Clear`})})]})]}),(0,K.jsx)(`div`,{style:{flex:`1`,overflow:`auto`,margin:`0px`,padding:`0px`},children:(0,K.jsx)(Xn,{})})]}):(0,K.jsx)(Vt,{})}var Pr=(0,G.memo)(Nr),Fr=({open:e,ip:t,onClose:n,onSave:r})=>{let i=t?t.split(`.`).slice(0,3).join(`.`)+`.1`:``,[a,o]=(0,G.useState)(`dhcp`),[s,c]=(0,G.useState)({ip:t??``,subnet:`255.255.255.0`,gateway:i,dns:i}),l=e=>t=>{c({...s,[e]:t.target.value})};return(0,K.jsxs)(D,{open:e,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||n()},maxWidth:`sm`,style:{maxWidth:`550px`,margin:`auto`},children:[(0,K.jsx)(P,{gap:`20px`,children:(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,K.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,K.jsx)(`h4`,{style:{margin:0},children:`Network Configuration`})]})}),(0,K.jsxs)(I,{dividers:!0,children:[(0,K.jsxs)(Fe,{component:`fieldset`,fullWidth:!0,children:[(0,K.jsx)(F,{component:`legend`,children:`Select IP Configuration`}),(0,K.jsxs)(Ve,{row:!0,value:a,onChange:e=>o(e.target.value),children:[(0,K.jsx)(d,{value:`dhcp`,control:(0,K.jsx)(je,{}),label:`DHCP`}),(0,K.jsx)(d,{value:`static`,control:(0,K.jsx)(je,{}),label:`Static`})]})]}),a===`static`&&(0,K.jsxs)(_,{container:!0,spacing:2,sx:{mt:2},children:[(0,K.jsx)(_,{size:6,children:(0,K.jsx)(B,{label:`IP Address`,fullWidth:!0,value:s.ip,onChange:l(`ip`)})}),(0,K.jsx)(_,{size:6,children:(0,K.jsx)(B,{label:`Subnet Mask`,fullWidth:!0,value:s.subnet,onChange:l(`subnet`)})}),(0,K.jsx)(_,{size:6,children:(0,K.jsx)(B,{label:`Gateway`,fullWidth:!0,value:s.gateway,onChange:l(`gateway`)})}),(0,K.jsx)(_,{size:6,children:(0,K.jsx)(B,{label:`DNS Server`,fullWidth:!0,value:s.dns,onChange:l(`dns`)})})]})]}),(0,K.jsxs)(x,{children:[(0,K.jsx)(L,{onClick:()=>{n()},children:`Cancel`}),(0,K.jsx)(L,{variant:`contained`,onClick:()=>{r({type:a,...s}),n()},children:`Save`})]})]})},Ir=({open:e,onClose:t,onSave:n})=>{let[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(``),s=e=>{i(e.target.value)},c=e=>{o(e.target.value)},l=r.length>0&&r===a;return(0,K.jsxs)(D,{open:e,onClose:(e,n)=>{n===`backdropClick`||n===`escapeKeyDown`||t()},maxWidth:`sm`,style:{maxWidth:`500px`,margin:`auto`},disableEscapeKeyDown:!0,children:[(0,K.jsx)(P,{children:(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,K.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,K.jsx)(`h4`,{style:{margin:0},children:`Change Password`})]})}),(0,K.jsx)(I,{dividers:!0,children:(0,K.jsx)(Fe,{component:`fieldset`,fullWidth:!0,sx:{margin:0,padding:0,gap:`20px`},children:(0,K.jsxs)(_,{container:!0,spacing:2,sx:{mt:2},children:[(0,K.jsx)(_,{size:12,children:(0,K.jsx)(B,{type:`password`,autoComplete:`new-password`,label:`New Password`,size:`small`,variant:`outlined`,fullWidth:!0,value:r,onChange:s})}),(0,K.jsx)(_,{size:12,children:(0,K.jsx)(B,{type:`password`,autoComplete:`new-password`,label:`Confirm Password`,size:`small`,variant:`outlined`,fullWidth:!0,value:a,onChange:c,error:a!==``&&r!==a,helperText:a!==``&&r!==a?`Passwords do not match`:``})})]})})}),(0,K.jsxs)(x,{children:[(0,K.jsx)(L,{onClick:()=>{t()},children:`Cancel`}),(0,K.jsx)(L,{variant:`contained`,onClick:()=>{l&&(n(r),t())},disabled:!l,children:`Change`}),(0,K.jsx)(L,{variant:`contained`,onClick:()=>{n(``),t()},children:`Reset`})]})]})};function Lr(e=1e3){let t=null,n=(n=>{t!==null&&window.clearTimeout(t),t=window.setTimeout(()=>{n(),t=null},e)});return n.cancel=()=>{t!==null&&(window.clearTimeout(t),t=null)},n}var Rr=330;function zr(){let{mobile:e}=(0,G.useContext)(It),{online:t,addListener:n,removeListener:r,sendMessage:i,getUniqueId:a}=(0,G.useContext)(J),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(a());return(0,G.useEffect)(()=>{let e=e=>{Q&&console.log(`Settings received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`settings`?(Q&&console.log(`Settings received refresh_required: changed=${e.response.changed} and sending /api/settings request`),i({id:u.current,sender:`Settings`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`/api/settings`&&(Q&&console.log(`Settings received /api/settings:`,e.response),s(e.response.matterbridgeInformation),l(e.response.systemInformation))};return n(e,u.current),Q&&console.log(`Settings added WebSocket listener`),()=>{r(e),Q&&console.log(`Settings removed WebSocket listener`)}},[n,r,i]),(0,G.useEffect)(()=>{t&&(Q&&console.log(`Settings received online`),i({id:u.current,sender:`Settings`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[t,i]),Q&&console.log(`Settings rendering...`),!t||!o||!c?(0,K.jsx)(Vt,{}):(0,K.jsx)(qn,{name:`Settings`,children:(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:$&&e?`10px`:`20px`},children:[(0,K.jsx)(Br,{matterbridgeInfo:o,systemInfo:c}),(0,K.jsx)(Vr,{matterbridgeInfo:o}),(0,K.jsx)(Hr,{matterbridgeInfo:o}),(0,K.jsx)(Ur,{systemInfo:c})]})})}function Br({matterbridgeInfo:e,systemInfo:t}){let{sendMessage:n,getUniqueId:r}=(0,G.useContext)(J),[i,a]=(0,G.useState)(`bridge`),[o,s]=(0,G.useState)(`Info`),[c,l]=(0,G.useState)(!1),[u,f]=(0,G.useState)(`dark`),[p,m]=(0,G.useState)(localStorage.getItem(q.homePagePlugins)!==`false`),[h,g]=(0,G.useState)(localStorage.getItem(q.homePageMode)??`devices`),[_,v]=(0,G.useState)(localStorage.getItem(q.virtualMode)??`outlet`),y=(0,G.useRef)(r()),[b,x]=(0,G.useState)(!1),S=()=>x(!1),C=e=>{Q&&console.log(`handleSaveNetConfig called with config:`,e),n({id:y.current,sender:`Settings`,method:`/api/shellynetconfig`,src:`Frontend`,dst:`Matterbridge`,params:e})},[w,T]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{e&&(a(e.bridgeMode===`bridge`?`bridge`:`childbridge`),s(e.loggerLevel.charAt(0).toUpperCase()+e.loggerLevel.slice(1)),l(e.fileLogger),v(e.virtualMode))},[e]),(0,G.useEffect)(()=>{let e=localStorage.getItem(q.frontendTheme);e&&f(e)},[]),!e||!t?null:(0,K.jsxs)(X,{style:{flex:`1 1 ${Rr}px`},children:[(0,K.jsx)(Ut,{children:(0,K.jsx)(Wt,{children:`Matterbridge settings`})}),(0,K.jsx)(Fr,{open:b,ip:t.ipv4Address,onClose:S,onSave:C}),(0,K.jsx)(Ir,{open:w,onClose:()=>T(!1),onSave:e=>{Q&&console.log(`handleSaveChangePassword called with password:`,e),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setpassword`,value:e}}),si(e)}}),(0,K.jsxs)(Jt,{style:{flexDirection:`column`,padding:`10px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`},children:[(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`},children:[(0,K.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`matterbridgeInfo-mode`,children:`Mode:`}),(0,K.jsxs)(Ve,{row:!0,name:`mode-buttons-group`,value:i,onChange:e=>{Q&&console.log(`handleChangeBridgeMode called with value:`,e.target.value),a(e.target.value),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setbridgemode`,value:e.target.value}})},children:[(0,K.jsx)(d,{value:`bridge`,control:(0,K.jsx)(je,{}),label:`Bridge`,disabled:e.readOnly===!0}),(0,K.jsx)(d,{value:`childbridge`,control:(0,K.jsx)(je,{}),label:`Childbridge`,disabled:e.readOnly===!0})]})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`15px`},children:[(0,K.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`mblogger-level-label`,children:`Logger level:`}),(0,K.jsxs)(ye,{style:{height:`30px`},labelId:`mblogger-level-label`,id:`mblogger-level`,value:o,onChange:e=>{Q&&console.log(`handleChangeMbLoggerLevel called with value:`,e.target.value),s(e.target.value),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmbloglevel`,value:e.target.value}})},children:[(0,K.jsx)(V,{value:`Debug`,children:`Debug`}),(0,K.jsx)(V,{value:`Info`,children:`Info`}),(0,K.jsx)(V,{value:`Notice`,children:`Notice`}),(0,K.jsx)(V,{value:`Warn`,children:`Warn`}),(0,K.jsx)(V,{value:`Error`,children:`Error`}),(0,K.jsx)(V,{value:`Fatal`,children:`Fatal`})]})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`10px`},children:[(0,K.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`mblogger-file-label`,children:`Log on file:`}),(0,K.jsx)(M,{checked:c,onChange:e=>{Q&&console.log(`handleLogOnFileMbChange called with value:`,e.target.checked),l(e.target.checked),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmblogfile`,value:e.target.checked}})},id:`mblogger-file`,name:`logOnFileMb`})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,K.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`frontend-theme-label`,children:`Frontend theme:`}),(0,K.jsxs)(ye,{style:{height:`30px`},labelId:`frontend-theme-label`,id:`frontend-theme`,value:u,onChange:e=>{let t=e.target.value;Q&&console.log(`handleChangeTheme called with value:`,t),f(t),localStorage.setItem(q.frontendTheme,t),document.body.setAttribute(`frontend-theme`,t)},children:[(0,K.jsx)(V,{value:`classic`,children:`Classic`}),(0,K.jsx)(V,{value:`light`,children:`Light`}),(0,K.jsx)(V,{value:`dark`,children:`Dark`})]})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,K.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`frontend-home-plugin-label`,children:`Home page plugins:`}),(0,K.jsx)(M,{checked:p,onChange:e=>{let t=e.target.checked;Q&&console.log(`handleChangeHomePagePlugins called with value:`,t),m(t),localStorage.setItem(q.homePagePlugins,t?`true`:`false`)},name:`showPlugins`})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,K.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`frontend-home-label`,children:`Home page bottom panel:`}),(0,K.jsxs)(ye,{style:{height:`30px`},labelId:`frontend-home-label`,id:`frontend-home`,value:h,onChange:e=>{let t=e.target.value;Q&&console.log(`handleChangeHomePageMode called with value:`,t),g(t),localStorage.setItem(q.homePageMode,t)},children:[(0,K.jsx)(V,{value:`logs`,children:`Logs`}),(0,K.jsx)(V,{value:`devices`,children:`Devices`})]})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`10px`},children:[(0,K.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`frontend-virtual-label`,children:`Virtual devices:`}),(0,K.jsxs)(ye,{style:{height:`30px`},labelId:`frontend-virtual-label`,id:`frontend-virtual`,value:_,onChange:e=>{let t=e.target.value;Q&&console.log(`handleChangeVirtualMode called with value:`,t),v(t),localStorage.setItem(q.virtualMode,t),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setvirtualmode`,value:t}})},children:[(0,K.jsx)(V,{value:`disabled`,children:`Disabled`}),(0,K.jsx)(V,{value:`outlet`,children:`Outlet`}),(0,K.jsx)(V,{value:`light`,children:`Light`}),(0,K.jsx)(V,{value:`switch`,children:`Switch`}),(0,K.jsx)(V,{value:`mounted_switch`,children:`Mounted Switch`})]})]}),(0,K.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`20px`},children:(0,K.jsx)(L,{variant:`contained`,color:`primary`,onClick:()=>T(!0),children:`Change password`})}),e.shellyBoard&&(0,K.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`20px`},children:(0,K.jsx)(L,{variant:`contained`,color:`primary`,onClick:()=>x(!0),children:`Configure IP`})})]})]})}function Vr({matterbridgeInfo:e}){let{sendMessage:t,getUniqueId:n}=(0,G.useContext)(J),[r,i]=(0,G.useState)(`Info`),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(``),y=(0,G.useRef)(n()),b=(0,G.useMemo)(()=>Lr(1e3),[]),x=(0,G.useMemo)(()=>Lr(1e3),[]),S=(0,G.useMemo)(()=>Lr(1e3),[]),C=(0,G.useMemo)(()=>Lr(1e3),[]),w=(0,G.useMemo)(()=>Lr(1e3),[]),T=(0,G.useMemo)(()=>Lr(1e3),[]);return(0,G.useEffect)(()=>{e&&(i(e.matterLoggerLevel.charAt(0).toUpperCase()+e.matterLoggerLevel.slice(1)),o(e.matterFileLogger),c(e.matterMdnsInterface||``),u(e.matterIpv4Address||``),f(e.matterIpv6Address||``),m(e.matterPort?e.matterPort.toString():``),g(e.matterDiscriminator?e.matterDiscriminator.toString():``),v(e.matterPasscode?e.matterPasscode.toString():``))},[e]),(0,G.useEffect)(()=>()=>b.cancel(),[b]),(0,G.useEffect)(()=>()=>x.cancel(),[x]),(0,G.useEffect)(()=>()=>S.cancel(),[S]),(0,G.useEffect)(()=>()=>C.cancel(),[C]),(0,G.useEffect)(()=>()=>w.cancel(),[w]),(0,G.useEffect)(()=>()=>T.cancel(),[T]),e?(0,K.jsxs)(X,{style:{flex:`1 1 ${Rr}px`},children:[(0,K.jsx)(Ut,{children:(0,K.jsx)(Wt,{children:`Matter settings`})}),(0,K.jsxs)(Jt,{style:{flexDirection:`column`,padding:`10px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`},children:[(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`15px`},children:[(0,K.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`mjlogger-level-label`,children:`Logger level:`}),(0,K.jsxs)(ye,{style:{height:`30px`},labelId:`mjlogger-level-label`,id:`mjlogger-level`,value:r,onChange:e=>{Q&&console.log(`handleChangeMjLoggerLevel called with value:`,e.target.value),i(e.target.value),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmjloglevel`,value:e.target.value}})},children:[(0,K.jsx)(V,{value:`Debug`,children:`Debug`}),(0,K.jsx)(V,{value:`Info`,children:`Info`}),(0,K.jsx)(V,{value:`Notice`,children:`Notice`}),(0,K.jsx)(V,{value:`Warn`,children:`Warn`}),(0,K.jsx)(V,{value:`Error`,children:`Error`}),(0,K.jsx)(V,{value:`Fatal`,children:`Fatal`})]})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`10px`},children:[(0,K.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`mjlogger-file-label`,children:`Log on file:`}),(0,K.jsx)(M,{checked:a,onChange:e=>{Q&&console.log(`handleLogOnFileMjChange called with value:`,e.target.checked),o(e.target.checked),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmjlogfile`,value:e.target.checked}})},id:`mjlogger-file`,name:`logOnFileMj`})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,K.jsx)(F,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Mdns interface:`}),(0,K.jsx)(B,{value:s,onChange:e=>{Q&&console.log(`handleChangeMdnsInterface called with value:`,e.target.value);let n=e.target.value;c(n),b(()=>{Q&&console.log(`debounced sendMessage setmdnsinterface with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmdnsinterface`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,K.jsx)(F,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Ipv4 address:`}),(0,K.jsx)(B,{value:l,onChange:e=>{Q&&console.log(`handleChangeIpv4Address called with value:`,e.target.value);let n=e.target.value;u(n),x(()=>{Q&&console.log(`debounced sendMessage setipv4address with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setipv4address`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,K.jsx)(F,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Ipv6 address:`}),(0,K.jsx)(B,{value:d,onChange:e=>{Q&&console.log(`handleChangeIpv6Address called with value:`,e.target.value);let n=e.target.value;f(n),S(()=>{Q&&console.log(`debounced sendMessage setipv6address with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setipv6address`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,K.jsx)(F,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning port:`}),(0,K.jsx)(B,{value:p,onChange:e=>{Q&&console.log(`handleChangeMatterPort called with value:`,e.target.value);let n=e.target.value;m(n),C(()=>{Q&&console.log(`debounced sendMessage setmatterport with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterport`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,K.jsx)(F,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning discriminator:`}),(0,K.jsx)(B,{value:h,onChange:e=>{Q&&console.log(`handleChangeMatterDiscriminator called with value:`,e.target.value);let n=e.target.value;g(n),w(()=>{Q&&console.log(`debounced sendMessage setmatterdiscriminator with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterdiscriminator`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,K.jsx)(F,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning passcode:`}),(0,K.jsx)(B,{value:_,onChange:e=>{Q&&console.log(`handleChangemMatterPasscode called with value:`,e.target.value);let n=e.target.value;v(n),T(()=>{Q&&console.log(`debounced sendMessage setmatterpasscode with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterpasscode`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]})]})]}):null}function Hr({matterbridgeInfo:e}){return e?(0,K.jsxs)(X,{style:{flex:`1 1 ${Rr}px`},children:[(0,K.jsx)(Ut,{children:(0,K.jsx)(Wt,{children:`Matterbridge info`})}),(0,K.jsxs)(Jt,{style:{flexDirection:`column`,padding:`10px`,gap:`5px`},children:[(0,K.jsx)(Wr,{value:e.matterbridgeVersion,label:`Current Version`}),(0,K.jsx)(Wr,{value:e.matterbridgeLatestVersion,label:`Latest Version`}),(0,K.jsx)(Wr,{value:e.rootDirectory,label:`Root Directory`}),(0,K.jsx)(Wr,{value:e.homeDirectory,label:`Home Directory`}),(0,K.jsx)(Wr,{value:e.matterbridgeDirectory,label:`Matterbridge Storage Directory`}),(0,K.jsx)(Wr,{value:e.matterbridgePluginDirectory,label:`Matterbridge Plugin Directory`}),(0,K.jsx)(Wr,{value:e.globalModulesDirectory,label:`Global Module Directory`})]})]}):null}function Ur({systemInfo:e}){return e?(0,K.jsxs)(X,{style:{flex:`1 1 ${Rr}px`},children:[(0,K.jsx)(Ut,{children:(0,K.jsx)(Wt,{children:`System info`})}),(0,K.jsxs)(Jt,{style:{flexDirection:`column`,padding:`10px`,gap:`5px`},children:[(0,K.jsx)(Wr,{value:e.interfaceName,label:`Interface name`}),(0,K.jsx)(Wr,{value:e.macAddress,label:`MAC Address`}),(0,K.jsx)(Wr,{value:e.ipv4Address,label:`IPv4 Address`}),(0,K.jsx)(Wr,{value:e.ipv6Address,label:`IPv6 Address`}),(0,K.jsx)(Wr,{value:e.nodeVersion,label:`Node Version`}),(0,K.jsx)(Wr,{value:e.hostname,label:`Hostname`}),(0,K.jsx)(Wr,{value:e.user,label:`User`})]})]}):null}function Wr({value:e,label:t,width:n}){return(0,K.jsx)(B,{focused:!0,value:e,size:`small`,label:t,variant:`standard`,sx:{width:n?`${n-20}px`:`100%`,"& .MuiInput-underline:before":{borderBottomColor:`var(--main-label-color)`,borderBottomWidth:`1px`,opacity:.5},"& .MuiInput-underline:hover:not(.Mui-disabled):before":{borderBottomColor:`var(--main-label-color)`,borderBottomWidth:`1px`,opacity:.5},"& .MuiInput-underline.Mui-focused:after":{borderBottomColor:`var(--main-label-color)`,borderBottomWidth:`1px`,opacity:.5}},slotProps:{input:{readOnly:!0,sx:{color:`var(--div-text-color)`,"&:before":{borderBottomColor:`var(--main-label-color)`},"&:after":{borderBottomColor:`var(--main-label-color)`}}},inputLabel:{sx:{marginTop:`3px`,color:`var(--main-label-color)`,"&.Mui-focused":{color:`var(--main-label-color)`}}}}})}var Gr=(0,G.memo)(zr);function Kr(){let{online:e,sendMessage:t,addListener:n,removeListener:r,getUniqueId:i}=(0,G.useContext)(J),{showSnackbarMessage:a}=(0,G.useContext)(It),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)([]),[u,d]=(0,G.useState)([]),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)({cpuUsage:0}),[g,_]=(0,G.useState)({totalMemory:``,freeMemory:``,heapTotal:``,heapUsed:``,external:``,arrayBuffers:``,rss:``}),[v,y]=(0,G.useState)({systemUptime:``,processUptime:``}),b=(0,G.useRef)(i());return Q&&console.log(`Test uniqueId:`,b),(0,G.useEffect)(()=>{Q&&console.log(`Test useEffect WebSocketMessage mounting`);let e=e=>{if(e.method===`restart_required`)Q&&console.log(`Test received restart_required`),a(`Restart required`,0);else if(e.method===`refresh_required`)Q&&console.log(`Test received refresh_required: changed=${e.response.changed} and sending api requests`),a(`Refresh required`,0),t({id:b.current,method:`/api/settings`,sender:`Test`,src:`Frontend`,dst:`Matterbridge`,params:{}}),t({id:b.current,method:`/api/plugins`,sender:`Test`,src:`Frontend`,dst:`Matterbridge`,params:{}}),t({id:b.current,method:`/api/devices`,sender:`Test`,src:`Frontend`,dst:`Matterbridge`,params:{}});else if(e.method===`memory_update`)Q&&console.log(`Test received memory_update`,e),_(e.response);else if(e.method===`cpu_update`)Q&&console.log(`Test received cpu_update`,e),h(e.response);else if(e.method===`uptime_update`)Q&&console.log(`Test received uptime_update`,e),y(e.response);else if(e.method===`/api/settings`&&e.response)Q&&console.log(`Test received /api/settings:`,e.response),a(`Test received /api/settings`,0),s(e.response);else if(e.method===`/api/plugins`&&e.response)Q&&console.log(`Test received ${e.response.length} plugins:`,e.response),a(`Test received /api/plugins`,0),l(e.response);else if(e.method===`/api/devices`&&e.response){Q&&console.log(`Test received ${e.response.length} devices:`,e.response),a(`Test received /api/devices`,0),d(e.response);for(let n of e.response)Q&&console.log(`Test sending /api/clusters for device:`,n.pluginName,n.name,n.endpoint),t({id:b.current,method:`/api/clusters`,sender:`Test`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.pluginName,endpoint:n.endpoint||0}})}else e.method===`/api/clusters`&&e.response&&(Q&&console.log(`Test received ${e.response.clusters.length} clusters for device ${e.response.deviceName} endpoint ${e.response.id}:${e.response.number}:`,e),a(`Test received /api/clusters for ${e.response.plugin}::${e.response.deviceName}`,0),p(e.response))};return n(e,b.current),Q&&console.log(`Test useEffect WebSocketMessage mounted`),()=>{Q&&console.log(`Test useEffect WebSocketMessage unmounting`),r(e),Q&&console.log(`Test useEffect WebSocketMessage unmounted`)}},[n,r,t,a]),(0,G.useEffect)(()=>(Q&&console.log(`Test useEffect online mounting`),e&&Q&&console.log(`Test useEffect online received online`),Q&&console.log(`Test useEffect online mounted`),()=>{Q&&console.log(`Test useEffect online unmounted`)}),[e,t,a]),Q&&console.log(`Test rendering...`),e?(0,K.jsx)(qn,{name:`Test`,children:(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,justifyContent:`center`,alignItems:`center`,alignContent:`center`,gap:`20px`,height:`100vh`,width:`100vw`},children:[(0,K.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`256px`,width:`256px`,margin:`10px`}}),(0,K.jsx)(`p`,{children:`Welcome to the Test page of the Matterbridge frontend`})]})}):(0,K.jsx)(Vt,{})}var qr=(0,G.memo)(Kr);function Jr(e,t){Q&&console.log(`getCssVariable:`,e,`defaultValue`,t);let n=getComputedStyle(document.body).getPropertyValue(e).trim();return n||console.error(`getCssVariable: undefined`,n),n||t}function Yr(e){return C({palette:{primary:{main:e},action:{disabled:`var(--main-label-color)`},text:{disabled:`var(--main-label-color)`}},typography:{fontFamily:`Roboto, Helvetica, Arial, sans-serif`},components:{MuiDialog:{styleOverrides:{paper:{color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`,border:`2px solid var(--div-border-color)`,borderRadius:`var(--div-border-radius)`,boxShadow:`2px 2px 5px var(--div-shadow-color)`}}},MuiTooltip:{defaultProps:{placement:`top-start`,arrow:!0}},MuiButton:{styleOverrides:{root:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,"&:hover":{backgroundColor:`var(--main-button-bg-color)`},"&.Mui-disabled":{color:`var(--main-button-color)`,backgroundColor:`var(--main-grey-color)`}},contained:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`},outlined:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`},text:{color:`var(--main-button-color)`}},defaultProps:{variant:`contained`,size:`small`}},MuiIconButton:{styleOverrides:{root:{color:`var(--main-icon-color)`,"&:hover .MuiSvgIcon-root":{color:`var(--primary-color)`}}}},MuiCheckbox:{styleOverrides:{root:{color:`var(--main-label-color)`,"&.Mui-checked":{color:`var(--primary-color)`}}}},MuiTextField:{defaultProps:{size:`small`,variant:`outlined`,fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:`var(--div-bg-color)`,"& .MuiOutlinedInput-notchedOutline":{borderColor:`var(--main-label-color)`},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:`var(--main-text-color)`},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:`var(--primary-color)`},padding:`0px`},input:{color:`var(--div-text-color)`,padding:`4px 8px`}}},MuiInputLabel:{styleOverrides:{root:{color:`var(--main-label-color)`,"&.Mui-focused":{color:`var(--primary-color)`}}}},MuiFormLabel:{styleOverrides:{root:{color:`var(--main-label-color)`,"&.Mui-focused":{color:`var(--main-label-color)`}}}},MuiFormControl:{styleOverrides:{root:{color:`var(--main-grey-color)`}}},MuiRadio:{styleOverrides:{root:{color:`var(--main-label-color)`,"&.Mui-checked":{color:`var(--primary-color)`}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`,height:`30px`,"&:hover":{borderColor:`var(--main-text-color)`},"&.Mui-focused":{borderColor:`var(--primary-color)`}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:`var(--main-menu-bg-color)`,padding:`0px`,margin:`0px`},list:{padding:`0px`}}},MuiMenuItem:{styleOverrides:{root:{color:`var(--main-menu-color)`,backgroundColor:`var(--main-menu-bg-color)`,"&:hover":{backgroundColor:`var(--main-menu-hover-color)`},"&.Mui-selected":{color:`var(--main-menu-color)`,backgroundColor:`var(--main-menu-bg-color)`},"&.Mui-selected:hover":{backgroundColor:`var(--main-menu-hover-color)`}}}},MuiListItemButton:{styleOverrides:{root:{cursor:`pointer`,"&:hover":{backgroundColor:`var(--main-bg-color)`}}}},MuiListItemIcon:{styleOverrides:{root:{color:`var(--div-text-color)`}}},MuiListItemText:{styleOverrides:{primary:{fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`},secondary:{fontSize:`14px`,fontWeight:`normal`,color:`var(--div-text-color)`}}}}})}function Xr(){let{mobile:e,showSnackbarMessage:t,showConfirmCancelDialog:n}=(0,G.useContext)(It),{online:r,sendMessage:i,logMessage:o,addListener:c,removeListener:l,getUniqueId:u}=(0,G.useContext)(J),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(null),x=(0,G.useRef)(u()),[S,C]=(0,G.useState)(null),[w,E]=(0,G.useState)(null),[D,O]=(0,G.useState)(null),[k,A]=(0,G.useState)(null),j=s(),M=()=>{window.open(`https://www.buymeacoffee.com/luligugithub`,`_blank`)},ee=()=>{window.open(`https://matterbridge.io/`)},P=()=>{window.open(`https://matterbridge.io/README.html`)},ne=()=>{window.open(`https://matterbridge.io/CHANGELOG.html`)},F=()=>{window.open(`https://discord.gg/QX58CDe6hd`,`_blank`)},re=()=>{window.open(`https://github.com/Luligu/matterbridge`,`_blank`)},I=()=>{i({id:x.current,sender:`Header`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:`matterbridge`,restart:!0}}),g(!1)},ie=()=>{i({id:x.current,sender:`Header`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:`matterbridge@dev`,restart:!0}}),v(!1)},ae=()=>{i({id:x.current,sender:`Header`,method:`/api/checkupdates`,src:`Frontend`,dst:`Matterbridge`,params:{}})},L=()=>{Q&&console.log(`Header: handleShellySystemUpdateClick`),o(`Matterbridge`,`Installing system updates...`),i({id:x.current,sender:`Header`,method:`/api/shellysysupdate`,src:`Frontend`,dst:`Matterbridge`,params:{}})},oe=()=>{Q&&console.log(`Header: handleShellyMainUpdateClick`),o(`Matterbridge`,`Installing software updates...`),i({id:x.current,sender:`Header`,method:`/api/shellymainupdate`,src:`Frontend`,dst:`Matterbridge`,params:{}})},se=()=>{Q&&console.log(`Header: handleShellyCreateSystemLog`),i({id:x.current,sender:`Header`,method:`/api/shellycreatesystemlog`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ce=()=>{Q&&console.log(`Header: handleShellyDownloadSystemLog`),o(`Matterbridge`,`Downloading Shelly system log...`),t(`Downloading Shelly system log...`,5),window.location.href=`./api/shellydownloadsystemlog`},le=()=>{y?.matterbridgeInformation.restartMode===``?i({id:x.current,sender:`Header`,method:`/api/restart`,src:`Frontend`,dst:`Matterbridge`,params:{}}):i({id:x.current,sender:`Header`,method:`/api/shutdown`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ue=()=>{i({id:x.current,sender:`Header`,method:`/api/shutdown`,src:`Frontend`,dst:`Matterbridge`,params:{}})},de=()=>{i({id:x.current,sender:`Header`,method:`/api/reboot`,src:`Frontend`,dst:`Matterbridge`,params:{}})},fe=()=>{i({id:x.current,sender:`Header`,method:`/api/softreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},pe=()=>{i({id:x.current,sender:`Header`,method:`/api/hardreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},me=e=>{C(e.currentTarget)},R=e=>{Q&&console.log(`Header: handleMenuClose`,e),C(null),e===`/`||e===`/devices`||e===`/log`||e===`/settings`?j(e):e===`reset_frontend`?(o(`Matterbridge`,`Resetting frontend UI...`),t(`Resetting frontend UI...`,5),Nt(),window.location.reload()):e===`download-mblog`?(o(`Matterbridge`,`Downloading matterbridge log...`),t(`Downloading matterbridge log...`,5),window.location.href=`./api/download-mblog`):e===`download-mjlog`?(o(`Matterbridge`,`Downloading matter log...`),t(`Downloading matter log...`,5),window.location.href=`./api/download-mjlog`):e===`view-mblog`?(o(`Matterbridge`,`Loading matterbridge log...`),t(`Loading matterbridge log...`,5),window.open(`./api/view-mblog`,`_blank`,`noopener,noreferrer`)):e===`view-mjlog`?(o(`Matterbridge`,`Loading matter log...`),t(`Loading matter log...`,5),window.open(`./api/view-mjlog`,`_blank`,`noopener,noreferrer`)):e===`view-diagnostic`?(o(`Matterbridge`,`Loading diagnostic log...`),t(`Loading diagnostic log...`,5),window.open(`./api/view-diagnostic`,`_blank`,`noopener,noreferrer`)):e===`download-diagnostic`?(o(`Matterbridge`,`Downloading diagnostic log...`),t(`Downloading diagnostic log...`,5),window.location.href=`./api/download-diagnostic`):e===`view-history`?i({id:x.current,sender:`Header`,method:`/api/viewhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`download-history`?i({id:x.current,sender:`Header`,method:`/api/downloadhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`view-shellylog`?(o(`Matterbridge`,`Loading shelly system log...`),t(`Loading shelly system log...`,5),window.location.href=`./api/shellyviewsystemlog`):e===`download-mbstorage`?(o(`Matterbridge`,`Downloading matterbridge storage...`),t(`Downloading matterbridge storage...`,5),window.location.href=`./api/download-mbstorage`):e===`download-pluginstorage`?(o(`Matterbridge`,`Downloading matterbridge plugins storage...`),t(`Downloading matterbridge plugins storage...`,5),window.location.href=`./api/download-pluginstorage`):e===`download-pluginconfig`?(o(`Matterbridge`,`Downloading matterbridge plugins config...`),t(`Downloading matterbridge plugins config...`,5),window.location.href=`./api/download-pluginconfig`):e===`download-mjstorage`?(o(`Matterbridge`,`Downloading matter storage...`),t(`Downloading matter storage...`,5),window.location.href=`./api/download-mjstorage`):e===`download-backup`?(o(`Matterbridge`,`Downloading backup...`),t(`Downloading backup...`,10),window.location.href=`./api/download-backup`):e===`update`?I():e===`updatedev`?ie():e===`updatecheck`?ae():e===`shelly-sys-update`?L():e===`shelly-main-update`?oe():e===`shelly-create-system-log`?se():e===`shelly-download-system-log`?ce():e===`softreset`?fe():e===`hardreset`?pe():e===`restart`?le():e===`shutdown`?ue():e===`reboot`?de():e===`create-backup`?i({id:x.current,sender:`Header`,method:`/api/create-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-matterbridge-storage-backup`?i({id:x.current,sender:`Header`,method:`/api/create-matterbridge-storage-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-matter-storage-backup`?i({id:x.current,sender:`Header`,method:`/api/create-matter-storage-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-plugin-backup`?i({id:x.current,sender:`Header`,method:`/api/create-plugin-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-config-backup`?i({id:x.current,sender:`Header`,method:`/api/create-config-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`unregister`?i({id:x.current,sender:`Header`,method:`/api/unregister`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`reset`?i({id:x.current,sender:`Header`,method:`/api/reset`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`factoryreset`&&i({id:x.current,sender:`Header`,method:`/api/factoryreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ge=e=>{Q&&console.log(`Header: handleMenuCloseCancel:`,e),C(null)},ve=e=>{E(e.currentTarget)},ye=()=>{E(null)},Se=e=>{O(e.currentTarget)},Ce=()=>{O(null)},we=e=>{A(e.currentTarget)},Te=()=>{A(null)};return(0,G.useEffect)(()=>{let e=e=>{Q&&console.log(`Header received WebSocket Message:`,e),e.method===`/api/settings`&&e.id===x.current?(Q&&console.log(`Header received settings:`,e.response),b(e.response),f(e.response.matterbridgeInformation.restartRequired||e.response.matterbridgeInformation.fixedRestartRequired),m(e.response.matterbridgeInformation.fixedRestartRequired),g(e.response.matterbridgeInformation.updateRequired)):e.method===`refresh_required`&&e.response.changed===`settings`?(Q&&console.log(`Header received refresh_required: changed=${e.response.changed} and sending /api/settings request`),i({id:x.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`restart_required`?(Q&&console.log(`Header received restart_required with fixed: ${e.response.fixed}`),f(!0),e.response.fixed===!0&&m(!0)):e.method===`restart_not_required`?(Q&&console.log(`Header received restart_not_required`),f(!1)):e.method===`update_required`?(Q&&console.log(`Header received update_required`),e.response.devVersion===!0?v(!0):g(!0),i({id:x.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`shelly_sys_update`?(Q&&console.log(`Header received WS_ID_SHELLY_SYS_UPDATE:`),b(t=>t?{matterbridgeInformation:{...t.matterbridgeInformation,shellySysUpdate:e.response.available},systemInformation:t.systemInformation}:null)):e.method===`shelly_main_update`?(Q&&console.log(`Header received WS_ID_SHELLY_MAIN_UPDATE:`),b(t=>t?{matterbridgeInformation:{...t.matterbridgeInformation,shellyMainUpdate:e.response.available},systemInformation:t.systemInformation}:null)):e.method===`/api/viewhistorypage`&&e.id===x.current&&e.success===!0?(Q&&console.log(`Header received /api/viewhistorypage success`),window.open(`./api/viewhistory`,`_blank`,`noopener,noreferrer`)):e.method===`/api/downloadhistorypage`&&e.id===x.current&&e.success===!0?(Q&&console.log(`Header received /api/downloadhistorypage success`),window.location.href=`./api/downloadhistory`):e.method===`archive`&&e.success===!0&&e.response.command===`zip`&&(Q&&console.log(`Header received archive success response for zip command`,e.response),e.response.archivePath.endsWith(`matterbridge.backup.zip`)?window.location.href=`./api/download-backup`:e.response.archivePath.endsWith(`matterbridge.storage.zip`)?window.location.href=`./api/download-mbstorage`:e.response.archivePath.endsWith(`matterbridge.matterstorage.zip`)?window.location.href=`./api/download-mjstorage`:e.response.archivePath.endsWith(`matterbridge.pluginstorage.zip`)?window.location.href=`./api/download-pluginstorage`:e.response.archivePath.endsWith(`matterbridge.pluginconfig.zip`)&&(window.location.href=`./api/download-pluginconfig`))};return c(e,x.current),Q&&console.log(`Header added WebSocket listener id ${x.current}`),()=>{l(e),Q&&console.log(`Header removed WebSocket listener`)}},[c,l,i,t]),(0,G.useEffect)(()=>{r&&(Q&&console.log(`Header sending /api/settings and /api/checkupdates requests`),i({id:x.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),i({id:x.current,sender:`Header`,method:`/api/checkupdates`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[r,i]),Q&&console.log(`Header rendering... mobile %s`,e),!r||!y?null:(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`,width:`100%`,gap:`10px`},children:[(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,K.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`30px`},onClick:()=>{ri(),Q&&console.log(`Matterbridge logo clicked: debug is now`,Q)}}),(0,K.jsx)(`h2`,{style:{fontSize:`22px`,color:`var(--main-icon-color)`,margin:`0px`},children:`Matterbridge`})]}),(0,K.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:(0,K.jsxs)(`nav`,{children:[(0,K.jsx)(a,{to:`/`,className:`nav-link`,children:`Home`}),(0,K.jsx)(a,{to:`/devices`,className:`nav-link`,children:`Devices`}),(0,K.jsx)(a,{to:`/log`,className:`nav-link`,children:`Logs`}),(0,K.jsx)(a,{to:`/settings`,className:`nav-link`,children:`Settings`})]})})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[!y.matterbridgeInformation.readOnly&&(0,K.jsx)(H,{title:`Matterbridge v.${y.matterbridgeInformation.matterbridgeVersion}`,children:(0,K.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`},children:[`v.`,y.matterbridgeInformation.matterbridgeVersion.split(`-`)[0]+(y.matterbridgeInformation.matterbridgeVersion.includes(`-dev-`)?`@dev`:``)+(y.matterbridgeInformation.matterbridgeVersion.includes(`-edge-`)?`@edge`:``)+(y.matterbridgeInformation.matterbridgeVersion.includes(`-local-`)?`@local`:``)+(y.matterbridgeInformation.matterbridgeVersion.includes(`-git-`)?`@git`:``)]})}),y.matterbridgeInformation.shellyBoard&&(0,K.jsx)(`img`,{src:`Shelly.svg`,alt:`Shelly Icon`,style:{height:`30px`,padding:`0px`,margin:`0px`,marginRight:`30px`}}),y.matterbridgeInformation.bridgeMode!==``&&y.matterbridgeInformation.readOnly===!1?(0,K.jsx)(H,{title:`Bridge mode`,children:(0,K.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:y.matterbridgeInformation.bridgeMode})}):null,y.matterbridgeInformation.restartMode!==``&&y.matterbridgeInformation.readOnly===!1?(0,K.jsx)(H,{title:`Restart mode`,children:(0,K.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:y.matterbridgeInformation.restartMode})}):null,y.matterbridgeInformation.profile&&y.matterbridgeInformation.profile!==``&&y.matterbridgeInformation.readOnly===!1?(0,K.jsx)(H,{title:`Current profile`,children:(0,K.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:y.matterbridgeInformation.profile})}):null,Q&&(0,K.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`},children:[e?`Mobile `:`Desktop `,`${$r}x${ei}`,` enabled ${localStorage.getItem(q.enableMobile)!==`false`}`]})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`5px`},children:[y.matterbridgeInformation.readOnly===!1?(0,K.jsx)(H,{title:`Matterbridge discord group`,children:(0,K.jsx)(`img`,{src:`discord.svg`,alt:`Discord Logo`,style:{cursor:`pointer`,height:`25px`},onClick:F})}):null,y.matterbridgeInformation.readOnly===!1?(0,K.jsx)(H,{title:`Give a star to Matterbridge`,children:(0,K.jsx)(T,{style:{color:`#FFD700`,margin:`0`,padding:`0`},onClick:re,children:(0,K.jsx)(te,{})})}):null,y.matterbridgeInformation.readOnly===!1?(0,K.jsx)(H,{title:`Sponsor Matterbridge`,children:(0,K.jsx)(T,{style:{color:`#b6409c`,margin:`0`,padding:`0`},onClick:M,children:(0,K.jsx)(Ue,{})})}):null,(0,K.jsx)(H,{title:`Matterbridge homepage`,children:(0,K.jsx)(T,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:ee,children:(0,K.jsx)(xe,{})})}),(0,K.jsx)(H,{title:`Matterbridge help`,children:(0,K.jsx)(T,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:P,children:(0,K.jsx)(Ne,{})})}),(0,K.jsx)(H,{title:`Matterbridge changelog`,children:(0,K.jsx)(T,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:ne,children:(0,K.jsx)(Ye,{})})}),y.matterbridgeInformation&&!y.matterbridgeInformation.readOnly&&h&&(0,K.jsx)(H,{title:`Update matterbridge to latest version v.${y.matterbridgeInformation.matterbridgeLatestVersion}`,children:(0,K.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:I,children:(0,K.jsx)(he,{})})}),y.matterbridgeInformation&&!y.matterbridgeInformation.readOnly&&_&&(0,K.jsx)(H,{title:`Update matterbridge to latest dev version v.${y.matterbridgeInformation.matterbridgeDevVersion}`,children:(0,K.jsx)(T,{style:{color:`var(--secondary-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:ie,children:(0,K.jsx)(he,{})})}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&y.matterbridgeInformation.shellySysUpdate&&(0,K.jsx)(H,{title:`Shelly system update`,children:(0,K.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:L,children:(0,K.jsx)(he,{})})}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&y.matterbridgeInformation.shellyMainUpdate&&(0,K.jsx)(H,{title:`Shelly software update`,children:(0,K.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:oe,children:(0,K.jsx)(he,{})})}),(0,K.jsx)(H,{title:`Restart matterbridge`,children:(0,K.jsx)(T,{style:{color:d||p?`var(--primary-color)`:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:le,children:(0,K.jsx)(_e,{})})}),y.matterbridgeInformation.restartMode===``?(0,K.jsx)(H,{title:`Shut down matterbridge`,children:(0,K.jsx)(T,{style:{color:d||p?`var(--primary-color)`:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:ue,children:(0,K.jsx)(be,{})})}):null,(0,K.jsx)(H,{title:`Download, backup and more`,children:(0,K.jsx)(T,{onClick:me,children:(0,K.jsx)(Me,{style:{color:`var(--main-icon-color)`}})})}),(0,K.jsxs)(ct,{id:`command-menu`,anchorEl:S,keepMounted:!0,open:!!S,onClose:()=>R(``),children:[$&&e&&(0,K.jsxs)(V,{onClick:()=>R(`/`),children:[(0,K.jsx)(U,{children:(0,K.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Home page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),$&&e&&(0,K.jsxs)(V,{onClick:()=>R(`/devices`),children:[(0,K.jsx)(U,{children:(0,K.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Devices page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),$&&e&&(0,K.jsxs)(V,{onClick:()=>R(`/log`),children:[(0,K.jsx)(U,{children:(0,K.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Logs page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),$&&e&&(0,K.jsxs)(V,{onClick:()=>R(`/settings`),children:[(0,K.jsx)(U,{children:(0,K.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Settings page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&!y.matterbridgeInformation.readOnly&&(0,K.jsxs)(V,{onClick:()=>R(`update`),children:[(0,K.jsx)(U,{children:(0,K.jsx)(he,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Install latest stable`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&!y.matterbridgeInformation.readOnly&&(0,K.jsxs)(V,{onClick:()=>R(`updatedev`),children:[(0,K.jsx)(U,{children:(0,K.jsx)(he,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Install latest dev`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&!y.matterbridgeInformation.readOnly&&(0,K.jsxs)(V,{onClick:()=>R(`updatecheck`),children:[(0,K.jsx)(U,{children:(0,K.jsx)(he,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Check for updates`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&y.matterbridgeInformation.shellySysUpdate&&(0,K.jsxs)(V,{onClick:()=>R(`shelly-sys-update`),children:[(0,K.jsx)(U,{children:(0,K.jsx)(he,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Shelly system update`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&y.matterbridgeInformation.shellyMainUpdate&&(0,K.jsxs)(V,{onClick:()=>R(`shelly-main-update`),children:[(0,K.jsx)(U,{children:(0,K.jsx)(he,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Shelly software update`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(V,{onClick:()=>R(`restart`),children:[(0,K.jsx)(U,{children:(0,K.jsx)(_e,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Restart`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation.restartMode===``?(0,K.jsxs)(V,{onClick:()=>R(`shutdown`),children:[(0,K.jsx)(U,{children:(0,K.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Shutdown`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}):null,y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,K.jsxs)(V,{onClick:()=>{n(`Reboot`,`Are you sure you want to reboot the Shelly board?`,`reboot`,R,ge)},children:[(0,K.jsx)(U,{children:(0,K.jsx)(_e,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Reboot...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsx)(N,{}),(0,K.jsxs)(V,{onClick:ve,children:[(0,K.jsx)(U,{children:(0,K.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`View`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(ct,{id:`sub-menu-view`,anchorEl:w,keepMounted:!0,open:!!w,onClose:ye,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,K.jsxs)(V,{onClick:()=>{ai(),ye(),ge(``),window.open(`/home`,`_self`)},children:[(0,K.jsx)(U,{children:(0,K.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Desktop site`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(V,{onClick:()=>{ii(),ye(),ge(``),window.open(`/home`,`_self`)},children:[(0,K.jsx)(U,{children:(0,K.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Mobile site`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(V,{onClick:()=>{R(`view-mblog`),ye()},children:[(0,K.jsx)(U,{children:(0,K.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Matterbridge log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(V,{onClick:()=>{R(`view-mjlog`),ye()},children:[(0,K.jsx)(U,{children:(0,K.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Matter log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(V,{onClick:()=>{R(`view-diagnostic`),ye()},children:[(0,K.jsx)(U,{children:(0,K.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Matterbridge diagnostic log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(V,{onClick:()=>{R(`view-history`),ye()},children:[(0,K.jsx)(U,{children:(0,K.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Matterbridge system history`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,K.jsxs)(V,{onClick:()=>{R(`view-shellylog`),ye()},children:[(0,K.jsx)(U,{children:(0,K.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]}),(0,K.jsx)(N,{}),(0,K.jsxs)(V,{onClick:Se,children:[(0,K.jsx)(U,{children:(0,K.jsx)(tt,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Download`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(ct,{id:`sub-menu-download`,anchorEl:D,keepMounted:!0,open:!!D,onClose:Ce,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,K.jsxs)(V,{onClick:()=>{R(`create-matterbridge-storage-backup`),Ce()},children:[(0,K.jsx)(U,{children:(0,K.jsx)(tt,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Matterbridge storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(V,{onClick:()=>{R(`create-plugin-backup`),Ce()},children:[(0,K.jsx)(U,{children:(0,K.jsx)(tt,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Matterbridge plugins storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(V,{onClick:()=>{R(`create-config-backup`),Ce()},children:[(0,K.jsx)(U,{children:(0,K.jsx)(tt,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Matterbridge plugins config`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(V,{onClick:()=>{R(`download-mblog`),Ce()},children:[(0,K.jsx)(U,{children:(0,K.jsx)(tt,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Matterbridge log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(V,{onClick:()=>{R(`create-matter-storage-backup`),Ce()},children:[(0,K.jsx)(U,{children:(0,K.jsx)(tt,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Matter storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(V,{onClick:()=>{R(`download-mjlog`),Ce()},children:[(0,K.jsx)(U,{children:(0,K.jsx)(tt,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Matter log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(V,{onClick:()=>{R(`download-diagnostic`),Ce()},children:[(0,K.jsx)(U,{children:(0,K.jsx)(tt,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Matterbridge diagnostic log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(V,{onClick:()=>{R(`download-history`),Ce()},children:[(0,K.jsx)(U,{children:(0,K.jsx)(tt,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Matterbridge system history`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,K.jsxs)(V,{onClick:()=>{R(`shelly-create-system-log`),Ce()},children:[(0,K.jsx)(U,{children:(0,K.jsx)(tt,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Create Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,K.jsxs)(V,{onClick:()=>{R(`shelly-download-system-log`),Ce()},children:[(0,K.jsx)(U,{children:(0,K.jsx)(tt,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Download Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]}),(0,K.jsx)(N,{}),(0,K.jsxs)(V,{onClick:()=>{R(`create-backup`)},children:[(0,K.jsx)(U,{children:(0,K.jsx)(Je,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Backup`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsx)(N,{}),(0,K.jsxs)(V,{onClick:we,children:[(0,K.jsx)(U,{children:(0,K.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Reset`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(ct,{id:`sub-menu-reset`,anchorEl:k,keepMounted:!0,open:!!k,onClose:Te,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,K.jsxs)(V,{onClick:()=>{Te(),n(`Reset the frontend UI`,`Are you sure you want to reset the frontend UI? This will reset all local settings and reload the page.`,`reset_frontend`,R,ge)},children:[(0,K.jsx)(U,{children:(0,K.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Reset the frontend UI...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(V,{onClick:()=>{Te(),n(`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`,R,ge)},children:[(0,K.jsx)(U,{children:(0,K.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Reset all devices...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,K.jsxs)(V,{onClick:()=>{Te(),n(`Reset commissioning and shutdown`,`Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.`,`reset`,R,ge)},children:[(0,K.jsx)(U,{children:(0,K.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Reset commissioning...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),!y.matterbridgeInformation.readOnly&&(0,K.jsxs)(V,{onClick:()=>{Te(),n(`Factory reset and shutdown`,`Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.`,`factoryreset`,R,ge)},children:[(0,K.jsx)(U,{children:(0,K.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Factory reset...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,K.jsxs)(V,{onClick:()=>{Te(),n(`Network reset`,`Are you sure you want to factory reset the network parameters?`,`softreset`,R,ge)},children:[(0,K.jsx)(U,{children:(0,K.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Reset network...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,K.jsxs)(V,{onClick:()=>{Te(),n(`Factory reset`,`Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.`,`hardreset`,R,ge)},children:[(0,K.jsx)(U,{children:(0,K.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,K.jsx)(z,{primary:`Factory reset...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]})]})]})]})}var Zr=(0,G.memo)(Xr),Qr=1200,$r,ei;function ti(){if(typeof window<`u`){$r=Math.floor(window.visualViewport?.width??window.innerWidth),ei=Math.floor(window.visualViewport?.height??window.innerHeight);let e=$r<1200||ei<900;return Q&&console.log(`Visual viewport (%s) width %i height %i mobile %s`,window.visualViewport!==void 0,$r,ei,e),e}return!1}function ni({children:e}){let{mobile:t,setMobile:n}=(0,G.useContext)(It),{logAutoScroll:r}=(0,G.useContext)(J);return(0,G.useEffect)(()=>{function e(){let e=ti();e&&(r.current=!1,localStorage.setItem(q.logAutoScroll,`false`)),n(e)}return window.addEventListener(`resize`,e),n(ti()),()=>window.removeEventListener(`resize`,e)},[r,n]),Q&&console.log(`MbfScreen rendering... mobile %s`,t),$&&t?(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,overflow:`visible`,margin:`0px`,padding:`10px`,gap:`10px`},children:[(0,K.jsx)(Zr,{}),(0,K.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,margin:`0px`,padding:`0px`,gap:`10px`},children:e})]}):(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,overflow:`hidden`,width:t?`${Qr}px`:`calc(100vw - 40px)`,height:t?`900px`:`calc(100vh - 40px)`,margin:`0px`,padding:`20px`,gap:`20px`},children:[(0,K.jsx)(Zr,{}),(0,K.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,width:`100%`,height:`calc(100% - 60px)`,margin:`0px`,padding:`0px`,gap:`20px`},children:e})]})}var Q=!1,ri=()=>{Q=!Q},$=localStorage.getItem(q.enableMobile)!==`false`,ii=()=>{$=!0,localStorage.setItem(q.enableMobile,`true`)},ai=()=>{$=!1,localStorage.setItem(q.enableMobile,`false`)},oi=void 0,si=e=>{oi=e},ci=!1,li=`/`,ui=`/`,di=`/`;function fi({setLoggedIn:e}){let[t,n]=(0,G.useState)(``),[r,i]=(0,G.useState)(``),a={display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100vh`,backgroundColor:`var(--main-bg-color)`},o={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)`},s={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)`},c=async t=>{try{let n=await fetch(`./api/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:t})});if(n.ok){let{valid:r}=await n.json();r?(e(!0),t!==``&&(oi=t)):t!==``&&i(`Incorrect password!`)}else console.error(`Failed to log in:`,n.statusText)}catch(e){console.error(`Failed to log in:`,e)}};return c(``),(0,K.jsx)(`div`,{style:a,children:(0,K.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),c(t)},style:o,children:[(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,K.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,K.jsx)(`h3`,{style:{color:`var(--div-text-color)`},children:`Welcome to Matterbridge`})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-between`,gap:`20px`},children:[(0,K.jsx)(`input`,{type:`text`,name:`username`,autoComplete:`username`,style:{display:`none`},tabIndex:-1}),(0,K.jsx)(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),style:s,placeholder:`password`,autoComplete:`current-password`}),(0,K.jsx)(`button`,{type:`submit`,style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,borderColor:`var(--div-bg-color)`},children:`Log in`})]}),(0,K.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`center`,margin:0,height:`30px`},children:r&&(0,K.jsx)(`p`,{style:{color:`red`},children:r})})]})})}function pi(){let[e,t]=(0,G.useState)(!1),a=localStorage.getItem(q.frontendTheme)||`dark`;Q&&console.log(`Setting frontend theme "%s"`,a),document.body.setAttribute(`frontend-theme`,a);let o=Jr(`--primary-color`,`#1976d2`);Q&&console.log(`Primary color from CSS "%s"`,o);let s=Yr(o);return li=window.location.href,ui=window.location.pathname,(ui.endsWith(`/devices`)||ui.endsWith(`/log`)||ui.endsWith(`/settings`)||ui.endsWith(`/test`))&&(ui=ui.substring(0,ui.lastIndexOf(`/`))),di=ui.endsWith(`/`)?ui:ui+`/`,ci=ui.includes(`/api/hassio_ingress/`),Q&&(console.log(`Loading App...`),console.log(`- href = "${li}"`),console.log(`- pathname = "${window.location.pathname}" >>> "${ui}"`),console.log(`- baseName = "${di}"`),console.log(`- isIngress = "${ci}"`)),e?(0,K.jsx)(R,{theme:s,children:(0,K.jsx)(yt,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:`bottom`,horizontal:`right`},children:(0,K.jsx)(Lt,{children:(0,K.jsx)(zt,{children:(0,K.jsx)(n,{basename:di,children:(0,K.jsx)(ni,{children:(0,K.jsxs)(i,{children:[(0,K.jsx)(r,{path:`/`,element:(0,K.jsx)(or,{})}),(0,K.jsx)(r,{path:`/devices`,element:(0,K.jsx)(Mr,{})}),(0,K.jsx)(r,{path:`/log`,element:(0,K.jsx)(Pr,{})}),(0,K.jsx)(r,{path:`/settings`,element:(0,K.jsx)(Gr,{})}),(0,K.jsx)(r,{path:`/test`,element:(0,K.jsx)(qr,{})}),(0,K.jsx)(r,{path:`*`,element:(0,K.jsx)(c,{to:`/`})})]})})})})})})}):(0,K.jsx)(fi,{setLoggedIn:t})}At.createRoot(document.getElementById(`root`)).render((0,K.jsx)(G.StrictMode,{children:(0,K.jsx)(pi,{})}));
|
|
42
|
+
`,t.head.appendChild(a)},[ae,se]=(0,G.useState)(),[ce,le]=(0,G.useState)(!1),ue=e=>{q&&console.log(`handleConfigPlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/select/devices`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:e.name}}),r({id:l.current,sender:`HomePlugins`,method:`/api/select/entities`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:e.name}}),se(e),de()},de=()=>{le(!0)};return q&&console.log(`HomePlugins rendering...`),n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Q,{children:[ae&&(0,Y.jsx)(br,{open:ce,onClose:()=>{le(!1)},plugin:ae}),(0,Y.jsx)(Sn,{name:`Plugins`,columns:S,rows:h,footerRight:``,footerLeft:``})]}),(0,Y.jsxs)(D,{open:y!==null,onClose:()=>b(null),slotProps:{paper:{sx:{width:J&&s?`100vw`:`75vw`,height:J&&s?`100vh`:`75vh`,maxWidth:J&&s?`100vw`:`75vw`,maxHeight:J&&s?`100vh`:`75vh`,margin:J&&s?`0px`:void 0,display:`flex`,flexDirection:`column`,overflow:`hidden`,backgroundColor:`var(--div-bg-color)`}}},children:[(0,Y.jsx)(re,{style:{display:`flex`,flex:`1 1 auto`,minHeight:0,padding:`0px`,margin:`0px`,overflow:`hidden`,backgroundColor:`var(--div-bg-color)`},children:y&&(0,Y.jsx)(`iframe`,{title:`${y.name} frontend`,src:y.path,onLoad:ie,style:{display:`block`,flex:`1 1 auto`,width:`100%`,height:`100%`,border:`none`,backgroundColor:`var(--div-bg-color)`}})}),(0,Y.jsx)(x,{sx:{flex:`0 0 auto`,justifyContent:`center`},children:(0,Y.jsx)(L,{onClick:()=>b(null),children:`Close`})})]})]}):(0,Y.jsx)(Wt,{})}var Cr=(0,G.memo)(Sr);function wr({version:e,changelog:t}){let{online:n}=(0,G.useContext)(X);return q&&console.log(`HomeShowChangelog rendering...`),n?(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`Matterbridge Update`})}),(0,Y.jsxs)(Xt,{style:{flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Y.jsxs)(`h4`,{style:{margin:0},children:[`Matterbridge has been updated to version `,e,`.`]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:`10px`},children:[(0,Y.jsx)(L,{onClick:()=>window.open(`https://github.com/Luligu/matterbridge`,`_blank`),endIcon:(0,Y.jsx)(Xe,{style:{color:`#FFD700`}}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Star`}),(0,Y.jsx)(L,{onClick:()=>window.open(`https://www.buymeacoffee.com/luligugithub`,`_blank`),endIcon:(0,Y.jsx)(it,{style:{color:`#b6409c`}}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Sponsor`}),(0,Y.jsx)(L,{onClick:()=>window.open(t,`_blank`),endIcon:(0,Y.jsx)(v,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Changelog`}),(0,Y.jsx)(L,{onClick:()=>window.location.reload(),endIcon:(0,Y.jsx)(Ce,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Close`})]})]})]}):(0,Y.jsx)(Wt,{})}var Tr=(0,G.memo)(wr);function Er({value:e,maxChars:t}){let n=e;if(e.length>t&&t>3){let r=t-3;n=`${e.substring(0,Math.ceil(r/2))} … ${e.substring(e.length-Math.floor(r/2),e.length)}`}return e===n?(0,Y.jsx)(`span`,{children:n}):(0,Y.jsx)(H,{title:e,placement:`top`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[0,12]}}]}},children:(0,Y.jsx)(`span`,{children:n})})}function Dr({matterbridgeInfo:e}){let{mobile:t}=(0,G.useContext)(Vt);q&&console.log(`MatterbridgeInfoTable:`,e);let n=new Set([`matterbridgeLatestVersion`,`matterbridgeDevVersion`,`dockerDev`,`dockerLatestVersion`,`dockerDevVersion`,`--matterFileLogger`,`--fileLogger`,`--matterLoggerLevel`,`--loggerLevel`,`--virtualMode`,`--bridgeMode`,`--restartMode`,`--restartRequired`,`fixedRestartRequired`,`--updateRequired`,`matterMdnsInterface`,`matterIpv4Address`,`matterIpv6Address`,`readOnly`,`shellyBoard`,`shellySysUpdate`,`shellyMainUpdate`,`matterPort`,`matterDiscriminator`,`matterPasscode`]),[r,i]=(0,G.useState)(!1);return!e||r?null:(q&&console.log(`MatterbridgeInfoTable rendering...`),(0,Y.jsxs)(Q,{style:J&&t?{flex:`1 1 300px`}:{flex:`0 1 auto`,width:`302px`,minWidth:`302px`},children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`Matterbridge info`}),(0,Y.jsx)(Zt,{close:()=>i(!0)})]}),(0,Y.jsx)(Xt,{style:J&&t?{flex:`1 1 auto`,margin:`0px`,padding:`0px`,gap:`0px`}:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`0px`,gap:`0px`},children:(0,Y.jsxs)(`table`,{style:{border:`none`,borderCollapse:`collapse`,tableLayout:`fixed`},children:[(0,Y.jsxs)(`colgroup`,{children:[(0,Y.jsx)(`col`,{style:{width:`40%`}}),(0,Y.jsx)(`col`,{style:{width:`60%`}})]}),(0,Y.jsx)(`tbody`,{style:{border:`none`,borderCollapse:`collapse`},children:Object.entries(e).filter(([e,t])=>!n.has(e)&&t!=null&&t!==``).map(([e,n],r)=>(0,Y.jsxs)(`tr`,{className:r%2==0?`table-content-even`:`table-content-odd`,style:{border:`none`,borderCollapse:`collapse`},children:[(0,Y.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`},children:e.replace(`matterbridgeVersion`,`Matterbridge version`).replace(`frontendVersion`,`Frontend version`).replace(`dockerVersion`,`Docker version`).replace(`homeDirectory`,`Home`).replace(`rootDirectory`,`Root`).replace(`matterbridgeDirectory`,`Storage`).replace(`matterbridgeCertDirectory`,`Cert`).replace(`matterbridgePluginDirectory`,`Plugins`).replace(`globalModulesDirectory`,`Modules`).replace(`bridgeMode`,`Bridge mode`).replace(`restartMode`,`Restart mode`).replace(`virtualMode`,`Virtual mode`).replace(`profile`,`Profile`).replace(`loggerLevel`,`Logger level`).replace(`fileLogger`,`File logger`).replace(`loggerLevel`,`Logger level`).replace(`fileLogger`,`File logger`).replace(`matterLoggerLevel`,`Matter logger level`).replace(`matterFileLogger`,`Matter file logger`).replace(`restartRequired`,`Restart required`).replace(`updateRequired`,`Update required`)}),(0,Y.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:J&&t?typeof n==`string`?n:n.toString():(0,Y.jsx)(Er,{value:typeof n==`string`?n:n.toString(),maxChars:24})})]},e))})]})})]}))}var Or=(0,G.memo)(Dr),kr={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`}},Ar=e=>{if(!e)return``;let t=e.replace(/[^0-9]/g,``);return t.length<5?t:[t.slice(0,4),t.slice(4,7),t.slice(7,11)].filter(Boolean).join(`-`)};function jr({id:e}){let{online:t,sendMessage:n,addListener:r,removeListener:i,getUniqueId:a}=(0,G.useContext)(X),[o,s]=(0,G.useState)(null),c=(0,G.useRef)(null),l=(0,G.useRef)(null),u=(0,G.useRef)(a()),{mobile:d,showConfirmCancelDialog:f}=(0,G.useContext)(Vt);q&&console.log(`QRDiv loading with id = "${e}" storeId = "${c.current}" timeout = ${l.current?`set`:`none`} and matter:`,o),(0,G.useEffect)(()=>{q&&console.log(`QRDiv id effect "${e}"`),c.current=e,l.current&&clearTimeout(l.current),l.current=null,e?(q&&console.log(`QRDiv id effect sending data request for storeId "${e}"`),n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:e,server:!0}})):(q&&console.log(`QRDiv id effect setting matter to null`),s(null))},[e,n]),(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`QRDiv received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`matter`&&e.response.matter&&(q&&console.log(`QRDiv received refresh_required: changed=${e.response.changed} for storeId "${e.response.matter.id}":`,e.response.matter),c.current===e.response.matter.id&&(q&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${e.response.matter.id}":`,e.response.matter),l.current&&clearTimeout(l.current),s(e.response.matter)))};return r(e,u.current),q&&console.log(`QRDiv webSocket effect mounted`),()=>{i(e),l.current&&clearTimeout(l.current),l.current=null,q&&console.log(`QRDiv webSocket effect unmounted`)}},[r,i]);let p=()=>{q&&console.log(`QRDiv sent matter startCommission for node "${o?.id}"`),o&&n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:o.id,startCommission:!0}})},m=()=>{q&&console.log(`QRDiv sent matter stopCommission for node "${o?.id}"`),o&&n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:o.id,stopCommission:!0}})},h=()=>{q&&console.log(`QRDiv sent matter advertise for node "${o?.id}"`),o&&n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:o.id,advertise:!0}})},g=e=>{q&&console.log(`QRDiv sent matter removeFabric for node "${o?.id}" and fabricIndex ${e}`),o&&n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:o.id,removeFabric:e}})};return!o||!t?(q&&console.log(`QRDiv rendering undefined state`),null):o.online?o.advertising&&o.qrPairingCode&&o.manualPairingCode?(q&&console.log(`QRDiv rendering advertising state`),(0,Y.jsxs)(Q,{style:J&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`QR pairing code`}),(0,Y.jsxs)(Zt,{children:[(0,Y.jsx)(T,{"aria-label":`send advertising`,size:`small`,onClick:h,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,Y.jsx)(H,{title:`Send again the mDNS advertisement`,arrow:!0,children:(0,Y.jsx)(Z.Icon,{path:dt,size:`22px`})})}),(0,Y.jsx)(T,{"aria-label":`stop pairing`,size:`small`,onClick:m,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,Y.jsx)(H,{title:`Turn off pairing`,arrow:!0,children:(0,Y.jsx)(Z.Icon,{path:gt,size:`22px`})})})]})]}),(0,Y.jsx)(Yt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,Y.jsx)(kt,{value:o.qrPairingCode,size:256,level:`M`,fgColor:`var(--div-text-color)`,bgColor:`var(--div-bg-color)`,style:{margin:`20px`}}),(0,Y.jsxs)(qt,{style:{justifyContent:`space-between`},children:[(0,Y.jsxs)(Jt,{style:{fontWeight:`normal`,color:`var(--div-text-color)`},children:[`Manual pairing code: `,Ar(o.manualPairingCode)]}),(0,Y.jsx)(Zt,{children:(0,Y.jsx)(H,{title:`Copy manual pairing code`,arrow:!0,children:(0,Y.jsx)(T,{"aria-label":`copy manual pairing code`,size:`small`,onClick:async()=>{if(!o||!o.manualPairingCode)return;let e=o.manualPairingCode;try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(e);else{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}q&&console.log(`Manual pairing code copied to clipboard`)}catch(e){console.error(`Failed to copy manual pairing code`,e)}},sx:kr,children:(0,Y.jsx)(Z.Icon,{path:mt,size:.85})})})})]})]})):o.commissioned&&o.fabricInformations&&o.sessionInformations?(q&&console.log(`QRDiv rendering commissioned state`),(0,Y.jsxs)(Q,{style:J&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`,overflow:`hidden`},children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`Paired fabrics`}),(0,Y.jsxs)(Zt,{children:[(0,Y.jsx)(T,{"aria-label":`send advertising`,size:`small`,onClick:h,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,Y.jsx)(H,{title:`Send again the mDNS advertisement`,arrow:!0,children:(0,Y.jsx)(Z.Icon,{path:dt,size:`22px`})})}),(0,Y.jsx)(T,{"aria-label":`start pairing`,size:`small`,onClick:p,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,Y.jsx)(H,{title:`Turn on pairing`,arrow:!0,children:(0,Y.jsx)(Z.Icon,{path:_t,size:`22px`})})})]})]}),(0,Y.jsx)(Yt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,Y.jsx)(Xt,{style:{flexDirection:`column`,justifyContent:`flex-start`,flex:`1 1 auto`,overflow:`auto`,padding:`0px 0px 10px 0px`,gap:`0px`},children:o.fabricInformations.map((e,t)=>(0,Y.jsxs)(`div`,{style:{margin:`0px`,padding:`10px`,gap:`0px`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`,textAlign:`left`,fontSize:`14px`},children:[(0,Y.jsxs)(`div`,{style:{marginLeft:`20px`,marginBottom:`10px`,display:`flex`,flexDirection:`row`,justifyContent:`space-between`,gap:`20px`,alignItems:`center`},children:[(0,Y.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: `,e.fabricIndex]}),(0,Y.jsx)(H,{title:`Remove the fabric. You will also need to remove it from the controller.`,arrow:!0,children:(0,Y.jsx)(T,{"aria-label":`remove the fabric`,size:`small`,onClick:()=>f(`Remove fabric`,`Are you sure you want to remove this fabric? You will also need to remove it from the controller.`,`RemoveFabric`,()=>g(e.fabricIndex),()=>{}),sx:{...kr,padding:`2px`},children:(0,Y.jsx)(Z.Icon,{path:ut,size:1})})})]}),(0,Y.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Vendor: `,e.rootVendorId,` `,e.rootVendorName]}),e.label!==``&&(0,Y.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Label: `,e.label]}),(0,Y.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Sessions: `,o.sessionInformations?o.sessionInformations.filter(t=>t.fabric?.fabricIndex===e.fabricIndex&&t.isPeerActive).length:`0`,` `,`subscriptions: `,o.sessionInformations?o.sessionInformations.filter(t=>t.fabric?.fabricIndex===e.fabricIndex&&t.isPeerActive&&t.numberOfActiveSubscriptions>0).length:`0`]})]},t))}),(0,Y.jsx)(qt,{style:{justifyContent:`center`},children:(0,Y.jsxs)(Jt,{style:{fontWeight:`normal`},children:[`Serial number: `,o.serialNumber]})})]})):!o.commissioned&&!o.advertising?(q&&console.log(`QRDiv rendering not commissioned and not advertising state`),(0,Y.jsxs)(Q,{style:J&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`QR pairing code`})}),(0,Y.jsx)(Yt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,Y.jsx)(L,{onClick:p,endIcon:(0,Y.jsx)(Z.Icon,{path:_t,size:1}),style:{margin:`20px`,color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:`Turn on pairing`}),(0,Y.jsx)(qt,{style:{justifyContent:`center`},children:(0,Y.jsxs)(Jt,{style:{fontWeight:`normal`},children:[`Serial number: `,o.serialNumber]})})]})):(q&&console.log(`QRDiv rendering unknown state`),null):(q&&console.log(`QRDiv rendering offline state`),(0,Y.jsxs)(Q,{style:J&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,Y.jsx)(Gt,{style:{height:`30px`,justifyContent:`space-between`},children:(0,Y.jsx)(Kt,{children:`Server node`})}),(0,Y.jsx)(Yt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,Y.jsx)(Yt,{style:{fontWeight:`bold`},children:`Server offline`}),(0,Y.jsx)(qt,{style:{justifyContent:`center`},children:(0,Y.jsxs)(Jt,{style:{fontWeight:`normal`},children:[`Serial number: `,o.serialNumber]})})]}))}var Mr=(0,G.memo)(jr);function Nr({systemInfo:e,compact:t}){let{mobile:n}=(0,G.useContext)(Vt),{addListener:r,removeListener:i,getUniqueId:a,sendMessage:o}=(0,G.useContext)(X),[s,c]=(0,G.useState)(e),l=(0,G.useRef)(a());if(q&&console.log(`SystemInfoTable loading with systemInfo:`,s,`compact:`,t),e&&t&&s.totalMemory&&s.freeMemory){let e=s.totalMemory;s.freeMemory=`${s.freeMemory} / ${e}`,s.totalMemory=``}if(e&&t&&s.heapTotal&&s.heapUsed){let e=s.heapTotal;s.heapUsed=`${s.heapUsed} / ${e}`,s.heapTotal=``}e&&t&&s.osRelease&&s.osType&&(s.osType=`${s.osType} (${s.osRelease})`,s.osRelease=``),e&&t&&s.osArch&&s.osPlatform&&(s.osPlatform=`${s.osPlatform} (${s.osArch})`,s.osArch=``);let u=(e,t,n,r,i)=>{c(a=>({...a,totalMemory:e,freeMemory:t,heapTotal:n,heapUsed:r,rss:i}))},d=e=>{c(t=>({...t,cpuUsage:e.toFixed(2)+` %`}))},f=e=>{c(t=>({...t,processCpuUsage:e.toFixed(2)+` %`}))},p=(e,t)=>{c(n=>({...n,systemUptime:e,processUptime:t}))},m=()=>{q&&console.log(`SystemInfoTable handleViewHistory clicked`),o({id:l.current,sender:`Header`,method:`/api/viewhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}})};(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`SystemInfoTable received WebSocket Message:`,e),e.method===`memory_update`&&e.response&&e.response.totalMemory&&e.response.freeMemory&&e.response.heapTotal&&e.response.heapUsed&&e.response.rss?(q&&console.log(`SystemInfoTable received memory_update`,e),u(e.response.totalMemory,e.response.freeMemory,e.response.heapTotal,e.response.heapUsed,e.response.rss)):e.method===`cpu_update`&&e.response&&e.response.cpuUsage?(q&&console.log(`SystemInfoTable received cpu_update`,e),d(e.response.cpuUsage),f(e.response.processCpuUsage)):e.method===`uptime_update`&&e.response&&e.response.systemUptime&&e.response.processUptime?(q&&console.log(`SystemInfoTable received uptime_update`,e),p(e.response.systemUptime,e.response.processUptime)):e.method===`/api/viewhistorypage`&&e.id===l.current&&e.success&&(q&&console.log(`SystemInfoTable received /api/viewhistorypage success`),window.open(`./api/viewhistory`,`_blank`,`noopener,noreferrer`))};return r(e,l.current),q&&console.log(`SystemInfoTable added WebSocket listener id ${l.current}`),()=>{i(e),q&&console.log(`SystemInfoTable removed WebSocket listener`)}},[r,i]);let[h,g]=(0,G.useState)(!1);return!s||h?null:(q&&console.log(`SystemInfoTable rendering...`),(0,Y.jsxs)(Q,{style:J&&n?{flex:`1 1 300px`}:{flex:`0 1 auto`,width:`302px`,minWidth:`302px`},children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`System info`}),(0,Y.jsx)(Zt,{close:()=>g(!0),children:(0,Y.jsx)(T,{size:`small`,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},onClick:m,children:(0,Y.jsx)(H,{title:`Open the cpu and memory usage page`,arrow:!0,children:(0,Y.jsx)(Z.Icon,{path:ft,size:`22px`})})})})]}),(0,Y.jsx)(Xt,{style:J&&n?{flex:`1 1 auto`,margin:`0px`,padding:`0px`,gap:`0px`}:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`0px`,gap:`0px`},children:(0,Y.jsxs)(`table`,{style:{border:`none`,borderCollapse:`collapse`,tableLayout:`fixed`},children:[(0,Y.jsxs)(`colgroup`,{children:[(0,Y.jsx)(`col`,{style:{width:`40%`}}),(0,Y.jsx)(`col`,{style:{width:`60%`}})]}),(0,Y.jsx)(`tbody`,{style:{border:`none`,borderCollapse:`collapse`},children:Object.entries(s).filter(([e,t])=>t!==void 0&&t!==``).map(([e,t],r)=>(0,Y.jsxs)(`tr`,{className:r%2==0?`table-content-even`:`table-content-odd`,style:{border:`none`,borderCollapse:`collapse`},children:[(0,Y.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`},children:e.replace(`interfaceName`,`Interface name`).replace(`macAddress`,`Mac address`).replace(`ipv4Address`,`IPv4 address`).replace(`ipv6Address`,`IPv6 address`).replace(`nodeVersion`,`Node version`).replace(`hostname`,`Hostname`).replace(`user`,`User`).replace(`osType`,`Os`).replace(`osPlatform`,`Platform`).replace(`freeMemory`,`Memory`).replace(`systemUptime`,`System uptime`).replace(`processUptime`,`Process uptime`).replace(`cpuUsage`,`Host CPU`).replace(`processCpuUsage`,`Process CPU`).replace(`rss`,`Rss`).replace(`heapUsed`,`Heap`)}),(0,Y.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:J&&n?typeof t==`string`?t:t.toString():(0,Y.jsx)(Er,{value:typeof t==`string`?t:t.toString(),maxChars:22})})]},e))})]})})]}))}var Pr=(0,G.memo)(Nr);function Fr(){let[e,t]=(0,G.useState)(null),[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)([]),[o]=(0,G.useState)(localStorage.getItem(K.homePagePlugins)!==`false`),[s,c]=(0,G.useState)(localStorage.getItem(K.homePageMode)??`devices`),[l,u]=(0,G.useState)(`https://matterbridge.io/CHANGELOG.html`),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(null),{mobile:_}=(0,G.useContext)(Vt),{addListener:v,removeListener:y,online:b,sendMessage:x,getUniqueId:S}=(0,G.useContext)(X),C=(0,G.useRef)(S());return(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`Home received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`settings`&&(q&&console.log(`Home received refresh_required: changed=${e.response.changed} and sending /api/settings request`),g(null),a([]),x({id:C.current,sender:`Home`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),x({id:C.current,sender:`Home`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})),e.method===`/api/settings`&&e.id===C.current&&(q&&console.log(`Home received settings:`,e.response),t(e.response.systemInformation),r(e.response.matterbridgeInformation),localStorage.getItem(K.frontendVersion)===null&&e.response.matterbridgeInformation.frontendVersion?localStorage.setItem(K.frontendVersion,e.response.matterbridgeInformation.frontendVersion):e.response.matterbridgeInformation.frontendVersion!==localStorage.getItem(K.frontendVersion)&&e.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem(K.frontendVersion,e.response.matterbridgeInformation.frontendVersion),m(!0)),localStorage.getItem(K.matterbridgeVersion)===null?localStorage.setItem(K.matterbridgeVersion,e.response.matterbridgeInformation.matterbridgeVersion):e.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem(K.matterbridgeVersion)&&(localStorage.setItem(K.matterbridgeVersion,e.response.matterbridgeInformation.matterbridgeVersion),f(!0)),e.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem(K.homePageMode)||(localStorage.setItem(K.homePageMode,`devices`),c(`devices`)))),e.method===`/api/plugins`&&e.id===C.current&&(q&&console.log(`Home received plugins:`,e.response),a(e.response))};return v(e,C.current),q&&console.log(`Home added WebSocket listener id ${C.current}`),()=>{y(e),q&&console.log(`Home removed WebSocket listener`)}},[v,y,x]),(0,G.useEffect)(()=>{if(q&&console.log(`Home storeId effect with storeId ${h}`),n?.bridgeMode===`bridge`&&!h&&(q&&console.log(`Home storeId effect set storeId to Matterbridge`),g(`Matterbridge`)),n?.bridgeMode===`childbridge`&&!h&&i){for(let e of i)if(e.matter?.id){q&&console.log(`Home storeId effect set storeId to ${e.matter.id}`),g(e.matter.id);break}}},[n,i,h]),(0,G.useEffect)(()=>{b&&(q&&console.log(`Home online effect, sending /api/settings and /api/plugins requests`),x({id:C.current,sender:`Home`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),x({id:C.current,sender:`Home`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[b,x]),q&&console.log(`Home rendering...`),!b||!e||!n?(0,Y.jsx)(Wt,{}):(0,Y.jsxs)(kn,{name:`Home`,style:J&&_?{alignItems:`center`,gap:`10px`}:{flexDirection:`row`},children:[(J&&!_||!J)&&(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,width:`302px`,minWidth:`302px`,gap:`20px`},children:[(0,Y.jsx)(Mr,{id:h}),(0,Y.jsx)(Pr,{systemInfo:e,compact:!0})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,width:`100%`,gap:J&&_?`10px`:`20px`},children:[p&&(0,Y.jsx)(Nn,{version:n.frontendVersion}),d&&(0,Y.jsx)(Tr,{version:n.matterbridgeVersion,changelog:l}),J&&_&&(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:`10px`},children:[(0,Y.jsx)(Mr,{id:h}),(0,Y.jsx)(Pr,{systemInfo:e,compact:!0}),(0,Y.jsx)(Or,{matterbridgeInfo:n})]}),o&&!n.readOnly&&(0,Y.jsx)(Xn,{}),o&&(0,Y.jsx)(Cr,{storeId:h,setStoreId:g}),s===`devices`&&(0,Y.jsx)(Ln,{storeId:h,setStoreId:g}),s===`logs`&&(0,Y.jsx)(tr,{})]})]})}var Ir=(0,G.memo)(Fr);function Lr(){let{logLength:e,logAutoScroll:t,setMessages:n,setLogFilterLevel:r,setLogFilterSearch:i,online:a,filterLogMessages:o}=(0,G.useContext)(X),[s,c]=(0,G.useState)(localStorage.getItem(K.logFilterLevel)??`info`),[l,u]=(0,G.useState)(localStorage.getItem(K.logFilterSearch)??`*`),[f,p]=(0,G.useState)(e.current.toString()),[m,h]=(0,G.useState)(t.current);return q&&console.log(`Logs rendering...`),a?(0,Y.jsxs)(kn,{name:`Logs`,children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`,margin:`0px`,padding:`0px`,gap:`10px`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(le,{id:`select-level`,style:{color:`var(--div-text-color)`},children:`Filter log by level:`}),(0,Y.jsxs)(ye,{style:{height:`30px`,backgroundColor:`var(--main-bg-color)`},labelId:`select-level`,id:`debug-level`,value:s,onChange:e=>{let t=e.target.value;c(t),r(t),o(t,l),localStorage.setItem(K.logFilterLevel,t),q&&console.log(`handleLogFilterLevelChange called with value:`,t)},children:[(0,Y.jsx)(V,{value:`debug`,children:`Debug`}),(0,Y.jsx)(V,{value:`info`,children:`Info`}),(0,Y.jsx)(V,{value:`notice`,children:`Notice`}),(0,Y.jsx)(V,{value:`warn`,children:`Warn`}),(0,Y.jsx)(V,{value:`error`,children:`Error`}),(0,Y.jsx)(V,{value:`fatal`,children:`Fatal`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`5px`},children:[(0,Y.jsx)(le,{id:`search`,style:{color:`var(--div-text-color)`},children:`Filter log by text:`}),(0,Y.jsx)(H,{title:`Use /text/ for case-insensitive regex search`,children:(0,Y.jsx)(B,{style:{width:`210px`},size:`small`,id:`logsearch`,variant:`outlined`,value:l,onChange:e=>{let t=e.target.value;u(t),i(t),o(s,t),localStorage.setItem(K.logFilterSearch,t),q&&console.log(`handleLogFilterSearchChange called with value:`,t)},slotProps:{input:{style:{height:`30px`,padding:`0 0px`,backgroundColor:`var(--main-bg-color)`}}}})})]}),(0,Y.jsx)(d,{control:(0,Y.jsx)(M,{checked:m,onChange:e=>{let n=e.target.checked;h(n),t.current=n,o(s,l),localStorage.setItem(K.logAutoScroll,n?`true`:`false`),q&&console.log(`handleAutoScrollChange called with value:`,n)}}),label:`Auto scroll`,style:{color:`var(--div-text-color)`}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(le,{id:`select-size-label`,style:{color:`var(--div-text-color)`},children:`Log length:`}),(0,Y.jsxs)(ye,{style:{height:`30px`,backgroundColor:`var(--main-bg-color)`},labelId:`select-size-label`,id:`select-size`,value:f,onChange:t=>{let n=t.target.value;p(n),e.current=Number(n),localStorage.setItem(K.logLength,n),q&&console.log(`handleLogLengthChange called with value:`,n)},children:[(0,Y.jsx)(V,{value:100,children:`100`}),(0,Y.jsx)(V,{value:200,children:`200`}),(0,Y.jsx)(V,{value:500,children:`500`}),(0,Y.jsx)(V,{value:1e3,children:`1000`})]}),(0,Y.jsx)(H,{title:`Clear the logs`,children:(0,Y.jsx)(L,{onClick:()=>{q&&console.log(`handleClearLogsClick called`),n([])},endIcon:(0,Y.jsx)(ke,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Clear`})})]})]}),(0,Y.jsx)(`div`,{style:{flex:`1`,overflow:`auto`,margin:`0px`,padding:`0px`},children:(0,Y.jsx)($n,{})})]}):(0,Y.jsx)(Wt,{})}var Rr=(0,G.memo)(Lr),zr=1200,Br,Vr;function Hr(e,t){Br=e,Vr=t}function Ur(){let{mobile:e,showSnackbarMessage:t,showConfirmCancelDialog:n}=(0,G.useContext)(Vt),{online:i,sendMessage:a,logMessage:o,addListener:c,removeListener:l,getUniqueId:d}=(0,G.useContext)(X),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[_,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(!1),[S,C]=(0,G.useState)(null),w=(0,G.useRef)(d()),[E,D]=(0,G.useState)(null),[O,k]=(0,G.useState)(null),[A,j]=(0,G.useState)(null),[M,N]=(0,G.useState)(null),ee=r(),F=()=>{window.open(`https://www.buymeacoffee.com/luligugithub`,`_blank`)},te=()=>{window.open(`https://matterbridge.io/`)},I=()=>{window.open(`https://matterbridge.io/README.html`)},ne=()=>{window.open(`https://matterbridge.io/CHANGELOG.html`)},re=()=>{window.open(`https://discord.gg/QX58CDe6hd`,`_blank`)},ie=()=>{window.open(`https://github.com/Luligu/matterbridge`,`_blank`)},ae=()=>{a({id:w.current,sender:`Header`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:`matterbridge`,restart:!0}}),y(!1)},L=()=>{a({id:w.current,sender:`Header`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:`matterbridge@dev`,restart:!0}}),x(!1)},oe=()=>{a({id:w.current,sender:`Header`,method:`/api/checkupdates`,src:`Frontend`,dst:`Matterbridge`,params:{}})},se=()=>{q&&console.log(`Header: handleShellySystemUpdateClick`),o(`Matterbridge`,`Installing system updates...`),a({id:w.current,sender:`Header`,method:`/api/shellysysupdate`,src:`Frontend`,dst:`Matterbridge`,params:{}})},le=()=>{q&&console.log(`Header: handleShellyMainUpdateClick`),o(`Matterbridge`,`Installing software updates...`),a({id:w.current,sender:`Header`,method:`/api/shellymainupdate`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ue=()=>{q&&console.log(`Header: handleShellyCreateSystemLog`),a({id:w.current,sender:`Header`,method:`/api/shellycreatesystemlog`,src:`Frontend`,dst:`Matterbridge`,params:{}})},de=()=>{q&&console.log(`Header: handleShellyDownloadSystemLog`),o(`Matterbridge`,`Downloading Shelly system log...`),t(`Downloading Shelly system log...`,5),window.location.href=`./api/shellydownloadsystemlog`},fe=()=>{S?.matterbridgeInformation.restartMode===``?a({id:w.current,sender:`Header`,method:`/api/restart`,src:`Frontend`,dst:`Matterbridge`,params:{}}):a({id:w.current,sender:`Header`,method:`/api/shutdown`,src:`Frontend`,dst:`Matterbridge`,params:{}})},pe=()=>{a({id:w.current,sender:`Header`,method:`/api/shutdown`,src:`Frontend`,dst:`Matterbridge`,params:{}})},me=()=>{a({id:w.current,sender:`Header`,method:`/api/reboot`,src:`Frontend`,dst:`Matterbridge`,params:{}})},he=()=>{a({id:w.current,sender:`Header`,method:`/api/softreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ge=()=>{a({id:w.current,sender:`Header`,method:`/api/hardreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},_e=e=>{D(e.currentTarget)},R=e=>{q&&console.log(`Header: handleMenuClose`,e),D(null),e===`/`||e===`/devices`||e===`/log`||e===`/settings`?ee(e):e===`reset_frontend`?(o(`Matterbridge`,`Resetting frontend UI...`),t(`Resetting frontend UI...`,5),Mt(),window.location.reload()):e===`download-mblog`?(o(`Matterbridge`,`Downloading matterbridge log...`),t(`Downloading matterbridge log...`,5),window.location.href=`./api/download-mblog`):e===`download-mjlog`?(o(`Matterbridge`,`Downloading matter log...`),t(`Downloading matter log...`,5),window.location.href=`./api/download-mjlog`):e===`view-mblog`?(o(`Matterbridge`,`Loading matterbridge log...`),t(`Loading matterbridge log...`,5),window.open(`./api/view-mblog`,`_blank`,`noopener,noreferrer`)):e===`view-mjlog`?(o(`Matterbridge`,`Loading matter log...`),t(`Loading matter log...`,5),window.open(`./api/view-mjlog`,`_blank`,`noopener,noreferrer`)):e===`view-diagnostic`?(o(`Matterbridge`,`Loading diagnostic log...`),t(`Loading diagnostic log...`,5),window.open(`./api/view-diagnostic`,`_blank`,`noopener,noreferrer`)):e===`download-diagnostic`?(o(`Matterbridge`,`Downloading diagnostic log...`),t(`Downloading diagnostic log...`,5),window.location.href=`./api/download-diagnostic`):e===`view-history`?a({id:w.current,sender:`Header`,method:`/api/viewhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`download-history`?a({id:w.current,sender:`Header`,method:`/api/downloadhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`view-shellylog`?(o(`Matterbridge`,`Loading shelly system log...`),t(`Loading shelly system log...`,5),window.location.href=`./api/shellyviewsystemlog`):e===`download-mbstorage`?(o(`Matterbridge`,`Downloading matterbridge storage...`),t(`Downloading matterbridge storage...`,5),window.location.href=`./api/download-mbstorage`):e===`download-pluginstorage`?(o(`Matterbridge`,`Downloading matterbridge plugins storage...`),t(`Downloading matterbridge plugins storage...`,5),window.location.href=`./api/download-pluginstorage`):e===`download-pluginconfig`?(o(`Matterbridge`,`Downloading matterbridge plugins config...`),t(`Downloading matterbridge plugins config...`,5),window.location.href=`./api/download-pluginconfig`):e===`download-mjstorage`?(o(`Matterbridge`,`Downloading matter storage...`),t(`Downloading matter storage...`,5),window.location.href=`./api/download-mjstorage`):e===`download-backup`?(o(`Matterbridge`,`Downloading backup...`),t(`Downloading backup...`,10),window.location.href=`./api/download-backup`):e===`update`?ae():e===`updatedev`?L():e===`updatecheck`?oe():e===`shelly-sys-update`?se():e===`shelly-main-update`?le():e===`shelly-create-system-log`?ue():e===`shelly-download-system-log`?de():e===`softreset`?he():e===`hardreset`?ge():e===`restart`?fe():e===`shutdown`?pe():e===`reboot`?me():e===`create-backup`?a({id:w.current,sender:`Header`,method:`/api/create-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-matterbridge-storage-backup`?a({id:w.current,sender:`Header`,method:`/api/create-matterbridge-storage-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-matter-storage-backup`?a({id:w.current,sender:`Header`,method:`/api/create-matter-storage-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-plugin-backup`?a({id:w.current,sender:`Header`,method:`/api/create-plugin-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-config-backup`?a({id:w.current,sender:`Header`,method:`/api/create-config-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`unregister`?a({id:w.current,sender:`Header`,method:`/api/unregister`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`reset`?a({id:w.current,sender:`Header`,method:`/api/reset`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`factoryreset`&&a({id:w.current,sender:`Header`,method:`/api/factoryreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ve=e=>{q&&console.log(`Header: handleMenuCloseCancel:`,e),D(null)},ye=e=>{k(e.currentTarget)},xe=()=>{k(null)},Se=e=>{j(e.currentTarget)},Ce=()=>{j(null)},we=e=>{N(e.currentTarget)},Te=()=>{N(null)};return(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`Header received WebSocket Message:`,e),e.method===`/api/settings`&&e.id===w.current?(q&&console.log(`Header received settings:`,e.response),C(e.response),p(e.response.matterbridgeInformation.restartRequired||e.response.matterbridgeInformation.fixedRestartRequired),h(e.response.matterbridgeInformation.fixedRestartRequired),y(e.response.matterbridgeInformation.updateRequired)):e.method===`refresh_required`&&e.response.changed===`settings`?(q&&console.log(`Header received refresh_required: changed=${e.response.changed} and sending /api/settings request`),a({id:w.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`restart_required`?(q&&console.log(`Header received restart_required with fixed: ${e.response.fixed}`),p(!0),e.response.fixed&&h(!0)):e.method===`restart_not_required`?(q&&console.log(`Header received restart_not_required`),p(!1)):e.method===`update_required`?(q&&console.log(`Header received update_required`),e.response.devVersion?x(!0):y(!0),a({id:w.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`shelly_sys_update`?(q&&console.log(`Header received WS_ID_SHELLY_SYS_UPDATE:`),C(t=>t?{matterbridgeInformation:{...t.matterbridgeInformation,shellySysUpdate:e.response.available},systemInformation:t.systemInformation}:null)):e.method===`shelly_main_update`?(q&&console.log(`Header received WS_ID_SHELLY_MAIN_UPDATE:`),C(t=>t?{matterbridgeInformation:{...t.matterbridgeInformation,shellyMainUpdate:e.response.available},systemInformation:t.systemInformation}:null)):e.method===`/api/viewhistorypage`&&e.id===w.current&&e.success?(q&&console.log(`Header received /api/viewhistorypage success`),window.open(`./api/viewhistory`,`_blank`,`noopener,noreferrer`)):e.method===`/api/downloadhistorypage`&&e.id===w.current&&e.success?(q&&console.log(`Header received /api/downloadhistorypage success`),window.location.href=`./api/downloadhistory`):e.method===`archive`&&e.success&&e.response.command===`zip`&&(q&&console.log(`Header received archive success response for zip command`,e.response),e.response.archivePath.endsWith(`matterbridge.backup.zip`)?window.location.href=`./api/download-backup`:e.response.archivePath.endsWith(`matterbridge.storage.zip`)?window.location.href=`./api/download-mbstorage`:e.response.archivePath.endsWith(`matterbridge.matterstorage.zip`)?window.location.href=`./api/download-mjstorage`:e.response.archivePath.endsWith(`matterbridge.pluginstorage.zip`)?window.location.href=`./api/download-pluginstorage`:e.response.archivePath.endsWith(`matterbridge.pluginconfig.zip`)&&(window.location.href=`./api/download-pluginconfig`))};return c(e,w.current),q&&console.log(`Header added WebSocket listener id ${w.current}`),()=>{l(e),q&&console.log(`Header removed WebSocket listener`)}},[c,l,a,t]),(0,G.useEffect)(()=>{i&&(q&&console.log(`Header sending /api/settings and /api/checkupdates requests`),a({id:w.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),a({id:w.current,sender:`Header`,method:`/api/checkupdates`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[i,a]),q&&console.log(`Header rendering... mobile %s`,e),!i||!S?null:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`,width:`100%`,gap:`10px`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`},onClick:()=>{Nt(),q&&console.log(`Matterbridge logo clicked: debug is now`,q)},children:(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`30px`}})}),(0,Y.jsx)(`h2`,{style:{fontSize:`22px`,color:`var(--main-icon-color)`,margin:`0px`},children:`Matterbridge`})]}),(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:(0,Y.jsxs)(`nav`,{children:[(0,Y.jsx)(s,{to:`/`,className:`nav-link`,children:`Home`}),(0,Y.jsx)(s,{to:`/devices`,className:`nav-link`,children:`Devices`}),(0,Y.jsx)(s,{to:`/log`,className:`nav-link`,children:`Logs`}),(0,Y.jsx)(s,{to:`/settings`,className:`nav-link`,children:`Settings`})]})})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[!S.matterbridgeInformation.readOnly&&(0,Y.jsx)(H,{title:`Matterbridge v.${S.matterbridgeInformation.matterbridgeVersion}`,children:(0,Y.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`},children:[`v.`,S.matterbridgeInformation.matterbridgeVersion.split(`-`)[0]+(S.matterbridgeInformation.matterbridgeVersion.includes(`-dev-`)?`@dev`:``)+(S.matterbridgeInformation.matterbridgeVersion.includes(`-edge-`)?`@edge`:``)+(S.matterbridgeInformation.matterbridgeVersion.includes(`-local-`)?`@local`:``)+(S.matterbridgeInformation.matterbridgeVersion.includes(`-git-`)?`@git`:``)]})}),S.matterbridgeInformation.shellyBoard&&(0,Y.jsx)(`img`,{src:`Shelly.svg`,alt:`Shelly Icon`,style:{height:`30px`,padding:`0px`,margin:`0px`,marginRight:`30px`}}),S.matterbridgeInformation.bridgeMode!==``&&!S.matterbridgeInformation.readOnly?(0,Y.jsx)(H,{title:`Bridge mode`,children:(0,Y.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:S.matterbridgeInformation.bridgeMode})}):null,S.matterbridgeInformation.restartMode!==``&&!S.matterbridgeInformation.readOnly?(0,Y.jsx)(H,{title:`Restart mode`,children:(0,Y.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:S.matterbridgeInformation.restartMode})}):null,S.matterbridgeInformation.profile&&S.matterbridgeInformation.profile!==``&&!S.matterbridgeInformation.readOnly?(0,Y.jsx)(H,{title:`Current profile`,children:(0,Y.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:S.matterbridgeInformation.profile})}):null,q&&(0,Y.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`},children:[e?`Mobile `:`Desktop `,`${Br}x${Vr}`,` enabled ${localStorage.getItem(K.enableMobile)!==`false`}`]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`5px`},children:[S.matterbridgeInformation.readOnly?null:(0,Y.jsx)(H,{title:`Matterbridge discord group`,children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`},onClick:re,children:(0,Y.jsx)(`img`,{src:`discord.svg`,alt:`Discord Logo`,style:{height:`25px`}})})}),S.matterbridgeInformation.readOnly?null:(0,Y.jsx)(H,{title:`Give a star to Matterbridge`,children:(0,Y.jsx)(T,{style:{color:`#FFD700`,margin:`0`,padding:`0`},onClick:ie,children:(0,Y.jsx)(Xe,{})})}),S.matterbridgeInformation.readOnly?null:(0,Y.jsx)(H,{title:`Sponsor Matterbridge`,children:(0,Y.jsx)(T,{style:{color:`#b6409c`,margin:`0`,padding:`0`},onClick:F,children:(0,Y.jsx)(it,{})})}),(0,Y.jsx)(H,{title:`Matterbridge homepage`,children:(0,Y.jsx)(T,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:te,children:(0,Y.jsx)(ce,{})})}),(0,Y.jsx)(H,{title:`Matterbridge help`,children:(0,Y.jsx)(T,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:I,children:(0,Y.jsx)(g,{})})}),(0,Y.jsx)(H,{title:`Matterbridge changelog`,children:(0,Y.jsx)(T,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:ne,children:(0,Y.jsx)(v,{})})}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&_&&(0,Y.jsx)(H,{title:`Update matterbridge to latest version v.${S.matterbridgeInformation.matterbridgeLatestVersion}`,children:(0,Y.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:ae,children:(0,Y.jsx)(st,{})})}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&b&&(0,Y.jsx)(H,{title:`Update matterbridge to latest dev version v.${S.matterbridgeInformation.matterbridgeDevVersion}`,children:(0,Y.jsx)(T,{style:{color:`var(--secondary-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:L,children:(0,Y.jsx)(st,{})})}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&S.matterbridgeInformation.shellySysUpdate&&(0,Y.jsx)(H,{title:`Shelly system update`,children:(0,Y.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:se,children:(0,Y.jsx)(st,{})})}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&S.matterbridgeInformation.shellyMainUpdate&&(0,Y.jsx)(H,{title:`Shelly software update`,children:(0,Y.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:le,children:(0,Y.jsx)(st,{})})}),(0,Y.jsx)(H,{title:`Restart matterbridge`,children:(0,Y.jsx)(T,{style:{color:f||m?`var(--primary-color)`:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:fe,children:(0,Y.jsx)(ot,{})})}),S.matterbridgeInformation.restartMode===``?(0,Y.jsx)(H,{title:`Shut down matterbridge`,children:(0,Y.jsx)(T,{style:{color:f||m?`var(--primary-color)`:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:pe,children:(0,Y.jsx)(be,{})})}):null,(0,Y.jsx)(H,{title:`Download, backup and more`,children:(0,Y.jsx)(T,{onClick:_e,children:(0,Y.jsx)(We,{style:{color:`var(--main-icon-color)`}})})}),(0,Y.jsxs)(ct,{id:`command-menu`,anchorEl:E,keepMounted:!0,open:!!E,onClose:()=>R(``),children:[J&&e&&(0,Y.jsxs)(V,{onClick:()=>R(`/`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Home page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),J&&e&&(0,Y.jsxs)(V,{onClick:()=>R(`/devices`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Devices page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),J&&e&&(0,Y.jsxs)(V,{onClick:()=>R(`/log`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Logs page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),J&&e&&(0,Y.jsxs)(V,{onClick:()=>R(`/settings`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Settings page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&(0,Y.jsxs)(V,{onClick:()=>R(`update`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Install latest stable`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&(0,Y.jsxs)(V,{onClick:()=>R(`updatedev`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Install latest dev`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&(0,Y.jsxs)(V,{onClick:()=>R(`updatecheck`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Check for updates`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&S.matterbridgeInformation.shellySysUpdate&&(0,Y.jsxs)(V,{onClick:()=>R(`shelly-sys-update`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Shelly system update`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&S.matterbridgeInformation.shellyMainUpdate&&(0,Y.jsxs)(V,{onClick:()=>R(`shelly-main-update`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Shelly software update`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>R(`restart`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(ot,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Restart`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation.restartMode===``?(0,Y.jsxs)(V,{onClick:()=>R(`shutdown`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Shutdown`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}):null,S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{n(`Reboot`,`Are you sure you want to reboot the Shelly board?`,`reboot`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(ot,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reboot...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsx)(P,{}),(0,Y.jsxs)(V,{onClick:ye,children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`View`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(ct,{id:`sub-menu-view`,anchorEl:O,keepMounted:!0,open:!!O,onClose:xe,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,Y.jsxs)(V,{onClick:()=>{Ft(),xe(),ve(``),window.open(`/home`,`_self`)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Desktop site`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{Pt(),xe(),ve(``),window.open(`/home`,`_self`)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Mobile site`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`view-mblog`),xe()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`view-mjlog`),xe()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matter log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`view-diagnostic`),xe()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge diagnostic log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`view-history`),xe()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge system history`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{R(`view-shellylog`),xe()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]}),(0,Y.jsx)(P,{}),(0,Y.jsxs)(V,{onClick:Se,children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Download`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(ct,{id:`sub-menu-download`,anchorEl:A,keepMounted:!0,open:!!A,onClose:Ce,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,Y.jsxs)(V,{onClick:()=>{R(`create-matterbridge-storage-backup`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`create-plugin-backup`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge plugins storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`create-config-backup`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge plugins config`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`download-mblog`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`create-matter-storage-backup`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matter storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`download-mjlog`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matter log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`download-diagnostic`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge diagnostic log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`download-history`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge system history`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{R(`shelly-create-system-log`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Create Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{R(`shelly-download-system-log`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Download Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]}),(0,Y.jsx)(P,{}),(0,Y.jsxs)(V,{onClick:()=>{R(`create-backup`)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(Je,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Backup`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsx)(P,{}),(0,Y.jsxs)(V,{onClick:we,children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(Me,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reset`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(ct,{id:`sub-menu-reset`,anchorEl:M,keepMounted:!0,open:!!M,onClose:Te,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`Reset the frontend UI`,`Are you sure you want to reset the frontend UI? This will reset all local settings and reload the page.`,`reset_frontend`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reset the frontend UI...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`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`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reset all devices...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`Reset commissioning and shutdown`,`Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.`,`reset`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reset commissioning...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),!S.matterbridgeInformation.readOnly&&(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`Factory reset and shutdown`,`Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.`,`factoryreset`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Factory reset...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`Network reset`,`Are you sure you want to factory reset the network parameters?`,`softreset`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reset network...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`Factory reset`,`Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.`,`hardreset`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Factory reset...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]})]})]})]})}var Wr=(0,G.memo)(Ur);function Gr(){if(typeof window<`u`){let e=Math.floor(window.visualViewport?.width??window.innerWidth),t=Math.floor(window.visualViewport?.height??window.innerHeight);Hr(e,t);let n=e<1200||t<900;return q&&console.log(`Visual viewport (%s) width %i height %i mobile %s`,window.visualViewport!==void 0,e,t,n),n}return!1}function Kr({children:e}){let{mobile:t,setMobile:n}=(0,G.useContext)(Vt),{logAutoScroll:r}=(0,G.useContext)(X);return(0,G.useEffect)(()=>{function e(){let e=Gr();e&&(r.current=!1,localStorage.setItem(K.logAutoScroll,`false`)),n(e)}return window.addEventListener(`resize`,e),n(Gr()),()=>window.removeEventListener(`resize`,e)},[r,n]),q&&console.log(`MbfScreen rendering... mobile %s`,t),J&&t?(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,overflow:`visible`,margin:`0px`,padding:`10px`,gap:`10px`},children:[(0,Y.jsx)(Wr,{}),(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,margin:`0px`,padding:`0px`,gap:`10px`},children:e})]}):(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,overflow:`hidden`,width:t?`${zr}px`:`calc(100vw - 40px)`,height:t?`900px`:`calc(100vh - 40px)`,margin:`0px`,padding:`20px`,gap:`20px`},children:[(0,Y.jsx)(Wr,{}),(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,width:`100%`,height:`calc(100% - 60px)`,margin:`0px`,padding:`0px`,gap:`20px`},children:e})]})}function qr(e=1e3){let t=null,n=(n=>{t!==null&&window.clearTimeout(t),t=window.setTimeout(()=>{n(),t=null},e)});return n.cancel=()=>{t!==null&&(window.clearTimeout(t),t=null)},n}var Jr=({open:e,onClose:t,onSave:n})=>{let[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(``),s=e=>{i(e.target.value)},c=e=>{o(e.target.value)},l=r.length>0&&r===a;return(0,Y.jsxs)(D,{open:e,onClose:(e,n)=>{n===`backdropClick`||n===`escapeKeyDown`||t()},maxWidth:`sm`,style:{maxWidth:`500px`,margin:`auto`},disableEscapeKeyDown:!0,children:[(0,Y.jsx)(F,{children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:`Change Password`})]})}),(0,Y.jsx)(re,{dividers:!0,children:(0,Y.jsx)(Fe,{component:`fieldset`,fullWidth:!0,sx:{margin:0,padding:0,gap:`20px`},children:(0,Y.jsxs)(_,{container:!0,spacing:2,sx:{mt:2},children:[(0,Y.jsx)(_,{size:12,children:(0,Y.jsx)(B,{type:`password`,autoComplete:`new-password`,label:`New Password`,size:`small`,variant:`outlined`,fullWidth:!0,value:r,onChange:s})}),(0,Y.jsx)(_,{size:12,children:(0,Y.jsx)(B,{type:`password`,autoComplete:`new-password`,label:`Confirm Password`,size:`small`,variant:`outlined`,fullWidth:!0,value:a,onChange:c,error:a!==``&&r!==a,helperText:a!==``&&r!==a?`Passwords do not match`:``})})]})})}),(0,Y.jsxs)(x,{children:[(0,Y.jsx)(L,{onClick:()=>{t()},children:`Cancel`}),(0,Y.jsx)(L,{variant:`contained`,onClick:()=>{l&&(n(r),t())},disabled:!l,children:`Change`}),(0,Y.jsx)(L,{variant:`contained`,onClick:()=>{n(``),t()},children:`Reset`})]})]})},Yr=({open:e,ip:t,onClose:n,onSave:r})=>{let i=t?t.split(`.`).slice(0,3).join(`.`)+`.1`:``,[a,o]=(0,G.useState)(`dhcp`),[s,c]=(0,G.useState)({ip:t??``,subnet:`255.255.255.0`,gateway:i,dns:i}),l=e=>t=>{c({...s,[e]:t.target.value})};return(0,Y.jsxs)(D,{open:e,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||n()},maxWidth:`sm`,style:{maxWidth:`550px`,margin:`auto`},children:[(0,Y.jsx)(F,{gap:`20px`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:`Network Configuration`})]})}),(0,Y.jsxs)(re,{dividers:!0,children:[(0,Y.jsxs)(Fe,{component:`fieldset`,fullWidth:!0,children:[(0,Y.jsx)(I,{component:`legend`,children:`Select IP Configuration`}),(0,Y.jsxs)(Ve,{row:!0,value:a,onChange:e=>o(e.target.value),children:[(0,Y.jsx)(d,{value:`dhcp`,control:(0,Y.jsx)(je,{}),label:`DHCP`}),(0,Y.jsx)(d,{value:`static`,control:(0,Y.jsx)(je,{}),label:`Static`})]})]}),a===`static`&&(0,Y.jsxs)(_,{container:!0,spacing:2,sx:{mt:2},children:[(0,Y.jsx)(_,{size:6,children:(0,Y.jsx)(B,{label:`IP Address`,fullWidth:!0,value:s.ip,onChange:l(`ip`)})}),(0,Y.jsx)(_,{size:6,children:(0,Y.jsx)(B,{label:`Subnet Mask`,fullWidth:!0,value:s.subnet,onChange:l(`subnet`)})}),(0,Y.jsx)(_,{size:6,children:(0,Y.jsx)(B,{label:`Gateway`,fullWidth:!0,value:s.gateway,onChange:l(`gateway`)})}),(0,Y.jsx)(_,{size:6,children:(0,Y.jsx)(B,{label:`DNS Server`,fullWidth:!0,value:s.dns,onChange:l(`dns`)})})]})]}),(0,Y.jsxs)(x,{children:[(0,Y.jsx)(L,{onClick:()=>{n()},children:`Cancel`}),(0,Y.jsx)(L,{variant:`contained`,onClick:()=>{r({type:a,...s}),n()},children:`Save`})]})]})},Xr=330;function Zr(){let{mobile:e}=(0,G.useContext)(Vt),{online:t,addListener:n,removeListener:r,sendMessage:i,getUniqueId:a}=(0,G.useContext)(X),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(a());return(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`Settings received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`settings`?(q&&console.log(`Settings received refresh_required: changed=${e.response.changed} and sending /api/settings request`),i({id:u.current,sender:`Settings`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`/api/settings`&&(q&&console.log(`Settings received /api/settings:`,e.response),s(e.response.matterbridgeInformation),l(e.response.systemInformation))};return n(e,u.current),q&&console.log(`Settings added WebSocket listener`),()=>{r(e),q&&console.log(`Settings removed WebSocket listener`)}},[n,r,i]),(0,G.useEffect)(()=>{t&&(q&&console.log(`Settings received online`),i({id:u.current,sender:`Settings`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[t,i]),q&&console.log(`Settings rendering...`),!t||!o||!c?(0,Y.jsx)(Wt,{}):(0,Y.jsx)(kn,{name:`Settings`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:J&&e?`10px`:`20px`},children:[(0,Y.jsx)(Qr,{matterbridgeInfo:o,systemInfo:c}),(0,Y.jsx)($r,{matterbridgeInfo:o}),(0,Y.jsx)(ei,{matterbridgeInfo:o}),(0,Y.jsx)(ti,{systemInfo:c})]})})}function Qr({matterbridgeInfo:e,systemInfo:t}){let{sendMessage:n,getUniqueId:r}=(0,G.useContext)(X),[i,a]=(0,G.useState)(`bridge`),[o,s]=(0,G.useState)(`Info`),[c,l]=(0,G.useState)(!1),[u,f]=(0,G.useState)(`dark`),[p,m]=(0,G.useState)(localStorage.getItem(K.homePagePlugins)!==`false`),[h,g]=(0,G.useState)(localStorage.getItem(K.homePageMode)??`devices`),[_,v]=(0,G.useState)(localStorage.getItem(K.virtualMode)??`outlet`),y=(0,G.useRef)(r()),[b,x]=(0,G.useState)(!1),S=()=>x(!1),C=e=>{q&&console.log(`handleSaveNetConfig called with config:`,e),n({id:y.current,sender:`Settings`,method:`/api/shellynetconfig`,src:`Frontend`,dst:`Matterbridge`,params:e})},[w,T]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{e&&(a(e.bridgeMode===`bridge`?`bridge`:`childbridge`),s(e.loggerLevel.charAt(0).toUpperCase()+e.loggerLevel.slice(1)),l(e.fileLogger),v(e.virtualMode))},[e]),(0,G.useEffect)(()=>{let e=localStorage.getItem(K.frontendTheme);e&&f(e)},[]),!e||!t?null:(0,Y.jsxs)(Q,{style:{flex:`1 1 ${Xr}px`},children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`Matterbridge settings`})}),(0,Y.jsx)(Yr,{open:b,ip:t.ipv4Address,onClose:S,onSave:C}),(0,Y.jsx)(Jr,{open:w,onClose:()=>T(!1),onSave:e=>{q&&console.log(`handleSaveChangePassword called with password:`,e),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setpassword`,value:e}}),Lt(e)}}),(0,Y.jsxs)(Xt,{style:{flexDirection:`column`,padding:`10px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`matterbridgeInfo-mode`,children:`Mode:`}),(0,Y.jsxs)(Ve,{row:!0,name:`mode-buttons-group`,value:i,onChange:e=>{q&&console.log(`handleChangeBridgeMode called with value:`,e.target.value),a(e.target.value),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setbridgemode`,value:e.target.value}})},children:[(0,Y.jsx)(d,{value:`bridge`,control:(0,Y.jsx)(je,{}),label:`Bridge`,disabled:e.readOnly}),(0,Y.jsx)(d,{value:`childbridge`,control:(0,Y.jsx)(je,{}),label:`Childbridge`,disabled:e.readOnly})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`mblogger-level-label`,children:`Logger level:`}),(0,Y.jsxs)(ye,{style:{height:`30px`},labelId:`mblogger-level-label`,id:`mblogger-level`,value:o,onChange:e=>{q&&console.log(`handleChangeMbLoggerLevel called with value:`,e.target.value),s(e.target.value),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmbloglevel`,value:e.target.value}})},children:[(0,Y.jsx)(V,{value:`Debug`,children:`Debug`}),(0,Y.jsx)(V,{value:`Info`,children:`Info`}),(0,Y.jsx)(V,{value:`Notice`,children:`Notice`}),(0,Y.jsx)(V,{value:`Warn`,children:`Warn`}),(0,Y.jsx)(V,{value:`Error`,children:`Error`}),(0,Y.jsx)(V,{value:`Fatal`,children:`Fatal`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`mblogger-file-label`,children:`Log on file:`}),(0,Y.jsx)(M,{checked:c,onChange:e=>{q&&console.log(`handleLogOnFileMbChange called with value:`,e.target.checked),l(e.target.checked),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmblogfile`,value:e.target.checked}})},id:`mblogger-file`,name:`logOnFileMb`})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`frontend-theme-label`,children:`Frontend theme:`}),(0,Y.jsxs)(ye,{style:{height:`30px`},labelId:`frontend-theme-label`,id:`frontend-theme`,value:u,onChange:e=>{let t=e.target.value;q&&console.log(`handleChangeTheme called with value:`,t),f(t),localStorage.setItem(K.frontendTheme,t),document.body.setAttribute(`frontend-theme`,t)},children:[(0,Y.jsx)(V,{value:`classic`,children:`Classic`}),(0,Y.jsx)(V,{value:`light`,children:`Light`}),(0,Y.jsx)(V,{value:`dark`,children:`Dark`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`frontend-home-plugin-label`,children:`Home page plugins:`}),(0,Y.jsx)(M,{checked:p,onChange:e=>{let t=e.target.checked;q&&console.log(`handleChangeHomePagePlugins called with value:`,t),m(t),localStorage.setItem(K.homePagePlugins,t?`true`:`false`)},name:`showPlugins`})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`frontend-home-label`,children:`Home page bottom panel:`}),(0,Y.jsxs)(ye,{style:{height:`30px`},labelId:`frontend-home-label`,id:`frontend-home`,value:h,onChange:e=>{let t=e.target.value;q&&console.log(`handleChangeHomePageMode called with value:`,t),g(t),localStorage.setItem(K.homePageMode,t)},children:[(0,Y.jsx)(V,{value:`logs`,children:`Logs`}),(0,Y.jsx)(V,{value:`devices`,children:`Devices`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`10px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`frontend-virtual-label`,children:`Virtual devices:`}),(0,Y.jsxs)(ye,{style:{height:`30px`},labelId:`frontend-virtual-label`,id:`frontend-virtual`,value:_,onChange:e=>{let t=e.target.value;q&&console.log(`handleChangeVirtualMode called with value:`,t),v(t),localStorage.setItem(K.virtualMode,t),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setvirtualmode`,value:t}})},children:[(0,Y.jsx)(V,{value:`disabled`,children:`Disabled`}),(0,Y.jsx)(V,{value:`outlet`,children:`Outlet`}),(0,Y.jsx)(V,{value:`light`,children:`Light`}),(0,Y.jsx)(V,{value:`switch`,children:`Switch`}),(0,Y.jsx)(V,{value:`mounted_switch`,children:`Mounted Switch`})]})]}),(0,Y.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`20px`},children:(0,Y.jsx)(L,{variant:`contained`,color:`primary`,onClick:()=>T(!0),children:`Change password`})}),e.shellyBoard&&(0,Y.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`20px`},children:(0,Y.jsx)(L,{variant:`contained`,color:`primary`,onClick:()=>x(!0),children:`Configure IP`})})]})]})}function $r({matterbridgeInfo:e}){let{sendMessage:t,getUniqueId:n}=(0,G.useContext)(X),[r,i]=(0,G.useState)(`Info`),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(``),y=(0,G.useRef)(n()),b=(0,G.useMemo)(()=>qr(1e3),[]),x=(0,G.useMemo)(()=>qr(1e3),[]),S=(0,G.useMemo)(()=>qr(1e3),[]),C=(0,G.useMemo)(()=>qr(1e3),[]),w=(0,G.useMemo)(()=>qr(1e3),[]),T=(0,G.useMemo)(()=>qr(1e3),[]);return(0,G.useEffect)(()=>{e&&(i(e.matterLoggerLevel.charAt(0).toUpperCase()+e.matterLoggerLevel.slice(1)),o(e.matterFileLogger),c(e.matterMdnsInterface||``),u(e.matterIpv4Address||``),f(e.matterIpv6Address||``),m(e.matterPort?e.matterPort.toString():``),g(e.matterDiscriminator?e.matterDiscriminator.toString():``),v(e.matterPasscode?e.matterPasscode.toString():``))},[e]),(0,G.useEffect)(()=>()=>b.cancel(),[b]),(0,G.useEffect)(()=>()=>x.cancel(),[x]),(0,G.useEffect)(()=>()=>S.cancel(),[S]),(0,G.useEffect)(()=>()=>C.cancel(),[C]),(0,G.useEffect)(()=>()=>w.cancel(),[w]),(0,G.useEffect)(()=>()=>T.cancel(),[T]),e?(0,Y.jsxs)(Q,{style:{flex:`1 1 ${Xr}px`},children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`Matter settings`})}),(0,Y.jsxs)(Xt,{style:{flexDirection:`column`,padding:`10px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`mjlogger-level-label`,children:`Logger level:`}),(0,Y.jsxs)(ye,{style:{height:`30px`},labelId:`mjlogger-level-label`,id:`mjlogger-level`,value:r,onChange:e=>{q&&console.log(`handleChangeMjLoggerLevel called with value:`,e.target.value),i(e.target.value),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmjloglevel`,value:e.target.value}})},children:[(0,Y.jsx)(V,{value:`Debug`,children:`Debug`}),(0,Y.jsx)(V,{value:`Info`,children:`Info`}),(0,Y.jsx)(V,{value:`Notice`,children:`Notice`}),(0,Y.jsx)(V,{value:`Warn`,children:`Warn`}),(0,Y.jsx)(V,{value:`Error`,children:`Error`}),(0,Y.jsx)(V,{value:`Fatal`,children:`Fatal`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`10px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`mjlogger-file-label`,children:`Log on file:`}),(0,Y.jsx)(M,{checked:a,onChange:e=>{q&&console.log(`handleLogOnFileMjChange called with value:`,e.target.checked),o(e.target.checked),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmjlogfile`,value:e.target.checked}})},id:`mjlogger-file`,name:`logOnFileMj`})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Mdns interface:`}),(0,Y.jsx)(B,{value:s,onChange:e=>{q&&console.log(`handleChangeMdnsInterface called with value:`,e.target.value);let n=e.target.value;c(n),b(()=>{q&&console.log(`debounced sendMessage setmdnsinterface with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmdnsinterface`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Ipv4 address:`}),(0,Y.jsx)(B,{value:l,onChange:e=>{q&&console.log(`handleChangeIpv4Address called with value:`,e.target.value);let n=e.target.value;u(n),x(()=>{q&&console.log(`debounced sendMessage setipv4address with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setipv4address`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Ipv6 address:`}),(0,Y.jsx)(B,{value:d,onChange:e=>{q&&console.log(`handleChangeIpv6Address called with value:`,e.target.value);let n=e.target.value;f(n),S(()=>{q&&console.log(`debounced sendMessage setipv6address with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setipv6address`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning port:`}),(0,Y.jsx)(B,{value:p,onChange:e=>{q&&console.log(`handleChangeMatterPort called with value:`,e.target.value);let n=e.target.value;m(n),C(()=>{q&&console.log(`debounced sendMessage setmatterport with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterport`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning discriminator:`}),(0,Y.jsx)(B,{value:h,onChange:e=>{q&&console.log(`handleChangeMatterDiscriminator called with value:`,e.target.value);let n=e.target.value;g(n),w(()=>{q&&console.log(`debounced sendMessage setmatterdiscriminator with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterdiscriminator`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning passcode:`}),(0,Y.jsx)(B,{value:_,onChange:e=>{q&&console.log(`handleChangemMatterPasscode called with value:`,e.target.value);let n=e.target.value;v(n),T(()=>{q&&console.log(`debounced sendMessage setmatterpasscode with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterpasscode`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]})]})]}):null}function ei({matterbridgeInfo:e}){return e?(0,Y.jsxs)(Q,{style:{flex:`1 1 ${Xr}px`},children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`Matterbridge info`})}),(0,Y.jsxs)(Xt,{style:{flexDirection:`column`,padding:`10px`,gap:`5px`},children:[(0,Y.jsx)(ni,{value:e.matterbridgeVersion,label:`Current Version`}),(0,Y.jsx)(ni,{value:e.matterbridgeLatestVersion,label:`Latest Version`}),(0,Y.jsx)(ni,{value:e.rootDirectory,label:`Root Directory`}),(0,Y.jsx)(ni,{value:e.homeDirectory,label:`Home Directory`}),(0,Y.jsx)(ni,{value:e.matterbridgeDirectory,label:`Matterbridge Storage Directory`}),(0,Y.jsx)(ni,{value:e.matterbridgePluginDirectory,label:`Matterbridge Plugin Directory`}),(0,Y.jsx)(ni,{value:e.globalModulesDirectory,label:`Global Module Directory`})]})]}):null}function ti({systemInfo:e}){return e?(0,Y.jsxs)(Q,{style:{flex:`1 1 ${Xr}px`},children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`System info`})}),(0,Y.jsxs)(Xt,{style:{flexDirection:`column`,padding:`10px`,gap:`5px`},children:[(0,Y.jsx)(ni,{value:e.interfaceName,label:`Interface name`}),(0,Y.jsx)(ni,{value:e.macAddress,label:`MAC Address`}),(0,Y.jsx)(ni,{value:e.ipv4Address,label:`IPv4 Address`}),(0,Y.jsx)(ni,{value:e.ipv6Address,label:`IPv6 Address`}),(0,Y.jsx)(ni,{value:e.nodeVersion,label:`Node Version`}),(0,Y.jsx)(ni,{value:e.hostname,label:`Hostname`}),(0,Y.jsx)(ni,{value:e.user,label:`User`})]})]}):null}function ni({value:e,label:t,width:n}){return(0,Y.jsx)(B,{focused:!0,value:e,size:`small`,label:t,variant:`standard`,sx:{width:n?`${n-20}px`:`100%`,"& .MuiInput-underline:before":{borderBottomColor:`var(--main-label-color)`,borderBottomWidth:`1px`,opacity:.5},"& .MuiInput-underline:hover:not(.Mui-disabled):before":{borderBottomColor:`var(--main-label-color)`,borderBottomWidth:`1px`,opacity:.5},"& .MuiInput-underline.Mui-focused:after":{borderBottomColor:`var(--main-label-color)`,borderBottomWidth:`1px`,opacity:.5}},slotProps:{input:{readOnly:!0,sx:{color:`var(--div-text-color)`,"&:before":{borderBottomColor:`var(--main-label-color)`},"&:after":{borderBottomColor:`var(--main-label-color)`}}},inputLabel:{sx:{marginTop:`3px`,color:`var(--main-label-color)`,"&.Mui-focused":{color:`var(--main-label-color)`}}}}})}var ri=(0,G.memo)(Zr);function ii(){let{online:e,sendMessage:t,addListener:n,removeListener:r,getUniqueId:i}=(0,G.useContext)(X),{showSnackbarMessage:a}=(0,G.useContext)(Vt),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)([]),[u,d]=(0,G.useState)([]),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)({cpuUsage:0}),[g,_]=(0,G.useState)({totalMemory:``,freeMemory:``,heapTotal:``,heapUsed:``,external:``,arrayBuffers:``,rss:``}),[v,y]=(0,G.useState)({systemUptime:``,processUptime:``}),b=(0,G.useRef)(i());return q&&console.log(`Test uniqueId:`,b),(0,G.useEffect)(()=>{q&&console.log(`Test useEffect WebSocketMessage mounting`);let e=e=>{if(e.method===`restart_required`)q&&console.log(`Test received restart_required`),a(`Restart required`,0);else if(e.method===`refresh_required`)q&&console.log(`Test received refresh_required: changed=${e.response.changed} and sending api requests`),a(`Refresh required`,0),t({id:b.current,method:`/api/settings`,sender:`Test`,src:`Frontend`,dst:`Matterbridge`,params:{}}),t({id:b.current,method:`/api/plugins`,sender:`Test`,src:`Frontend`,dst:`Matterbridge`,params:{}}),t({id:b.current,method:`/api/devices`,sender:`Test`,src:`Frontend`,dst:`Matterbridge`,params:{}});else if(e.method===`memory_update`)q&&console.log(`Test received memory_update`,e),_(e.response);else if(e.method===`cpu_update`)q&&console.log(`Test received cpu_update`,e),h(e.response);else if(e.method===`uptime_update`)q&&console.log(`Test received uptime_update`,e),y(e.response);else if(e.method===`/api/settings`&&e.response)q&&console.log(`Test received /api/settings:`,e.response),a(`Test received /api/settings`,0),s(e.response);else if(e.method===`/api/plugins`&&e.response)q&&console.log(`Test received ${e.response.length} plugins:`,e.response),a(`Test received /api/plugins`,0),l(e.response);else if(e.method===`/api/devices`&&e.response){q&&console.log(`Test received ${e.response.length} devices:`,e.response),a(`Test received /api/devices`,0),d(e.response);for(let n of e.response)q&&console.log(`Test sending /api/clusters for device:`,n.pluginName,n.name,n.endpoint),t({id:b.current,method:`/api/clusters`,sender:`Test`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.pluginName,endpoint:n.endpoint||0}})}else e.method===`/api/clusters`&&e.response&&(q&&console.log(`Test received ${e.response.clusters.length} clusters for device ${e.response.deviceName} endpoint ${e.response.id}:${e.response.number}:`,e),a(`Test received /api/clusters for ${e.response.plugin}::${e.response.deviceName}`,0),p(e.response))};return n(e,b.current),q&&console.log(`Test useEffect WebSocketMessage mounted`),()=>{q&&console.log(`Test useEffect WebSocketMessage unmounting`),r(e),q&&console.log(`Test useEffect WebSocketMessage unmounted`)}},[n,r,t,a]),(0,G.useEffect)(()=>(q&&console.log(`Test useEffect online mounting`),e&&q&&console.log(`Test useEffect online received online`),q&&console.log(`Test useEffect online mounted`),()=>{q&&console.log(`Test useEffect online unmounted`)}),[e,t,a]),q&&console.log(`Test rendering...`),e?(0,Y.jsx)(kn,{name:`Test`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,justifyContent:`center`,alignItems:`center`,alignContent:`center`,gap:`20px`,height:`100vh`,width:`100vw`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`256px`,width:`256px`,margin:`10px`}}),(0,Y.jsx)(`p`,{children:`Welcome to the Test page of the Matterbridge frontend`})]})}):(0,Y.jsx)(Wt,{})}var ai=(0,G.memo)(ii);function oi({open:e,title:t,message:n,onConfirm:r,onCancel:i}){return(0,Y.jsxs)(D,{open:e,children:[(0,Y.jsx)(F,{gap:`20px`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:t})]})}),(0,Y.jsxs)(re,{children:[(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`center`,margin:`0`,marginBottom:`20px`,maxHeight:`350px`,maxWidth:`350px`},children:(0,Y.jsx)(`p`,{style:{flex:1,margin:`0`},children:n})}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-around`},children:[(0,Y.jsx)(L,{onClick:e=>{q&&console.log(`Confirmed`),e.preventDefault(),r()},variant:`contained`,color:`primary`,size:`small`,children:`Confirm`}),(0,Y.jsx)(L,{onClick:e=>{q&&console.log(`Canceled`),e.preventDefault(),i()},variant:`contained`,color:`primary`,size:`small`,children:`Cancel`})]})]})]})}var si=({open:e,output:t,title:n,_command:r,_packageName:i,onInstall:a,onClose:o})=>{let{installAutoExit:s,mobile:c,setInstallAutoExit:l}=(0,G.useContext)(Vt),u=(0,G.useRef)(null),f=e=>{l(e.target.checked),localStorage.setItem(K.installAutoExit,e.target.checked?`true`:`false`),q&&console.log(`handleInstallAutoExitChange called with value:`,e.target.checked)};return(0,G.useEffect)(()=>{q&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom:`,u.current),setTimeout(()=>{q&&console.log(`Scrolling to bottom:`,u.current),u.current?.scrollIntoView({behavior:`smooth`,block:`end`})},0)},[t]),(0,Y.jsxs)(D,{open:e,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||o()},slotProps:{paper:{sx:{width:J&&c?`100vw`:`75vw`,maxWidth:J&&c?`100vw`:`75vw`,height:J&&c?`100vh`:`75vw`,maxHeight:J&&c?`100vh`:`75vh`,margin:J&&c?`0px`:void 0,overflow:`hidden`}}},children:[(0,Y.jsx)(F,{children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:n})]})}),(0,Y.jsxs)(re,{dividers:!0,style:{overflow:`hidden`,display:`flex`,flexDirection:`column`,height:400,paddingBottom:0},children:[(0,Y.jsx)(`div`,{style:{display:`block`,marginBottom:`10px`,fontSize:`16px`,fontWeight:`bold`,color:`var(--primary-color)`},children:`Process log`}),(0,Y.jsxs)(`ul`,{style:{width:`100%`,height:`100%`,fontFamily:`monospace`,fontSize:`14px`,padding:`10px`,margin:0,marginBottom:`10px`,color:`var(--div-text-color)`,background:`var(--div-bg-color)`,overflow:`auto`,listStyle:`none`,boxSizing:`border-box`,borderRadius:4,border:`4px solid var(--primary-color)`,whiteSpace:`pre-wrap`,display:`block`},children:[t.split(`
|
|
43
|
+
`).map((e,t)=>(0,Y.jsx)(`li`,{style:{padding:0,margin:0,wordBreak:`break-all`},children:e},t)),(0,Y.jsx)(`li`,{ref:u,style:{padding:0,margin:0}})]})]}),(0,Y.jsxs)(x,{sx:{justifyContent:`space-evenly`},children:[a&&(0,Y.jsx)(L,{variant:`contained`,onClick:a,children:`Install`}),(0,Y.jsx)(L,{onClick:o,children:`Close`}),(0,Y.jsx)(d,{control:(0,Y.jsx)(M,{checked:s,onChange:e=>f(e)}),label:`Close on success`,style:{color:`var(--div-text-color)`}})]})]})},ci=[];function li({children:e}){let[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(null),{enqueueSnackbar:a,closeSnackbar:o}=vt(),s=(0,G.useCallback)(e=>{q&&console.log(`UiProvider closeSnackbarMessage: message ${e}`);let t=ci.findIndex(t=>t.message===e);t!==-1&&(o(ci[t].key),ci.splice(t,1),q&&console.log(`UiProvider closeSnackbarMessage: message ${e} removed from persistMessages`))},[o]),c=(0,G.useCallback)((e,t,n)=>{q&&console.log(`UiProvider showSnackbarMessage: message ${e} timeout ${t}`);let r=a(e,{variant:`default`,autoHideDuration:t==null||t>0?(t??5)*1e3:null,persist:t===0,content:t=>(0,Y.jsx)(W,{sx:{margin:`0`,padding:`0`,width:`300px`,marginRight:`30px`},children:(0,Y.jsx)(pe,{severity:n??`info`,variant:`filled`,sx:{color:`#fff`,fontWeight:`normal`,width:`100%`,cursor:`pointer`,padding:`0px 10px`},onClick:()=>o(t),action:(0,Y.jsx)(T,{size:`small`,onClick:()=>o(t),sx:{color:`#fff`},children:(0,Y.jsx)(Qe,{fontSize:`small`})}),children:e},t)},t)});t===0&&(q&&console.log(`UiProvider showSnackbarMessage: message ${e} timeout ${t} - persist key ${r}`),ci.push({message:e,key:r}))},[a,o]),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(``),_=(0,G.useRef)(null),v=(0,G.useRef)(null),y=()=>{q&&console.log(`UiProvider handle confirm action ${h}`),u(!1),_.current&&_.current(h)},b=()=>{q&&console.log(`UiProvider handle cancel action ${h}`),u(!1),v.current&&v.current(h)},x=(0,G.useCallback)((e,t,n,r,i)=>{q&&console.log(`UiProvider showConfirmCancelDialog for command ${n}`),f(e),m(t),g(n),_.current=r,v.current=i,u(!0)},[]),[S,C]=(0,G.useState)(!1),[w,E]=(0,G.useState)(``),[D,O]=(0,G.useState)(``),[k,A]=(0,G.useState)(``),[j,M]=(0,G.useState)(``),[N,P]=(0,G.useState)(localStorage.getItem(K.installAutoExit)!==`false`),ee=(0,G.useCallback)((e,t,n)=>{q&&console.log(`UiProvider show install progress for package ${e}`),E(e),O(t),A(n),C(!0)},[]),F=(0,G.useCallback)(e=>{q&&console.log(`UiProvider addInstallProgress: output ${e}`),M(t=>t+e+`
|
|
44
|
+
`)},[]),te=(0,G.useCallback)(()=>{q&&console.log(`UiProvider exitInstallProgressSuccess: package ${k}`),localStorage.getItem(K.installAutoExit)!==`false`&&C(!1)},[k]),I=(0,G.useCallback)(()=>{q&&console.log(`UiProvider exitInstallProgressError: package ${k}`)},[k]),ne=(0,G.useCallback)(()=>{q&&console.log(`UiProvider hide install progress`),C(!1)},[]),re=()=>{q&&console.log(`UiProvider handle install close action`),C(!1),A(``),M(``)},ie=(0,G.useMemo)(()=>({mobile:t,setMobile:n,currentPage:r,setCurrentPage:i,showSnackbarMessage:c,closeSnackbarMessage:s,closeSnackbar:o,showConfirmCancelDialog:x,showInstallProgress:ee,exitInstallProgressSuccess:te,exitInstallProgressError:I,hideInstallProgress:ne,addInstallProgress:F,installAutoExit:N,setInstallAutoExit:P}),[t,r,n,i,c,s,o,x,ee,te,I,ne,F,N,P]);return(0,Y.jsxs)(Vt.Provider,{value:ie,children:[(0,Y.jsx)(oi,{open:l,title:d,message:p,onConfirm:y,onCancel:b}),(0,Y.jsx)(si,{open:S,title:w,_command:D,_packageName:k,output:j,onClose:re}),e]})}function ui(e,t){q&&console.log(`getCssVariable:`,e,`defaultValue`,t);let n=getComputedStyle(document.body).getPropertyValue(e).trim();return n||console.error(`getCssVariable: undefined`,n),n||t}function di(e){return C({palette:{primary:{main:e},action:{disabled:`var(--main-label-color)`},text:{disabled:`var(--main-label-color)`}},typography:{fontFamily:`Roboto, Helvetica, Arial, sans-serif`},components:{MuiDialog:{styleOverrides:{paper:{color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`,border:`2px solid var(--div-border-color)`,borderRadius:`var(--div-border-radius)`,boxShadow:`2px 2px 5px var(--div-shadow-color)`}}},MuiTooltip:{defaultProps:{placement:`top-start`,arrow:!0}},MuiButton:{styleOverrides:{root:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,"&:hover":{backgroundColor:`var(--main-button-bg-color)`},"&.Mui-disabled":{color:`var(--main-button-color)`,backgroundColor:`var(--main-grey-color)`}},contained:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`},outlined:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`},text:{color:`var(--main-button-color)`}},defaultProps:{variant:`contained`,size:`small`}},MuiIconButton:{styleOverrides:{root:{color:`var(--main-icon-color)`,"&:hover .MuiSvgIcon-root":{color:`var(--primary-color)`}}}},MuiCheckbox:{styleOverrides:{root:{color:`var(--main-label-color)`,"&.Mui-checked":{color:`var(--primary-color)`}}}},MuiTextField:{defaultProps:{size:`small`,variant:`outlined`,fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:`var(--div-bg-color)`,"& .MuiOutlinedInput-notchedOutline":{borderColor:`var(--main-label-color)`},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:`var(--main-text-color)`},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:`var(--primary-color)`},padding:`0px`},input:{color:`var(--div-text-color)`,padding:`4px 8px`}}},MuiInputLabel:{styleOverrides:{root:{color:`var(--main-label-color)`,"&.Mui-focused":{color:`var(--primary-color)`}}}},MuiFormLabel:{styleOverrides:{root:{color:`var(--main-label-color)`,"&.Mui-focused":{color:`var(--main-label-color)`}}}},MuiFormControl:{styleOverrides:{root:{color:`var(--main-grey-color)`}}},MuiRadio:{styleOverrides:{root:{color:`var(--main-label-color)`,"&.Mui-checked":{color:`var(--primary-color)`}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`,height:`30px`,"&:hover":{borderColor:`var(--main-text-color)`},"&.Mui-focused":{borderColor:`var(--primary-color)`}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:`var(--main-menu-bg-color)`,padding:`0px`,margin:`0px`},list:{padding:`0px`}}},MuiMenuItem:{styleOverrides:{root:{color:`var(--main-menu-color)`,backgroundColor:`var(--main-menu-bg-color)`,"&:hover":{backgroundColor:`var(--main-menu-hover-color)`},"&.Mui-selected":{color:`var(--main-menu-color)`,backgroundColor:`var(--main-menu-bg-color)`},"&.Mui-selected:hover":{backgroundColor:`var(--main-menu-hover-color)`}}}},MuiListItemButton:{styleOverrides:{root:{cursor:`pointer`,"&:hover":{backgroundColor:`var(--main-bg-color)`}}}},MuiListItemIcon:{styleOverrides:{root:{color:`var(--div-text-color)`}}},MuiListItemText:{styleOverrides:{primary:{fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`},secondary:{fontSize:`14px`,fontWeight:`normal`,color:`var(--div-text-color)`}}}}})}function fi({setLoggedIn:e}){let[t,n]=(0,G.useState)(``),[r,i]=(0,G.useState)(``),a={display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100vh`,backgroundColor:`var(--main-bg-color)`},o={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)`},s={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)`},c=async t=>{try{let n=await fetch(`./api/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:t})});if(n.ok){let{valid:r}=await n.json();r?(e(!0),t!==``&&Lt(t)):t!==``&&i(`Incorrect password!`)}else console.error(`Failed to log in:`,n.statusText)}catch(e){console.error(`Failed to log in:`,e)}};return c(``),(0,Y.jsx)(`div`,{style:a,children:(0,Y.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),c(t)},style:o,children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h3`,{style:{color:`var(--div-text-color)`},children:`Welcome to Matterbridge`})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-between`,gap:`20px`},children:[(0,Y.jsx)(`input`,{type:`text`,name:`username`,autoComplete:`username`,style:{display:`none`},tabIndex:-1}),(0,Y.jsx)(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),style:s,placeholder:`password`,autoComplete:`current-password`}),(0,Y.jsx)(`button`,{type:`submit`,style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,borderColor:`var(--div-bg-color)`},children:`Log in`})]}),(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`center`,margin:0,height:`30px`},children:r&&(0,Y.jsx)(`p`,{style:{color:`red`},children:r})})]})})}function pi(){let[e,t]=(0,G.useState)(!1),r=localStorage.getItem(K.frontendTheme)||`dark`;q&&console.log(`Setting frontend theme "%s"`,r),document.body.setAttribute(`frontend-theme`,r);let o=ui(`--primary-color`,`#1976d2`);q&&console.log(`Primary color from CSS "%s"`,o);let s=di(o),l=window.location.href,u=window.location.pathname;(u.endsWith(`/devices`)||u.endsWith(`/log`)||u.endsWith(`/settings`)||u.endsWith(`/test`))&&(u=u.substring(0,u.lastIndexOf(`/`)));let d=u.endsWith(`/`)?u:u+`/`,f=u.includes(`/api/hassio_ingress/`);return zt(f),q&&(console.log(`Loading App...`),console.log(`- href = "${l}"`),console.log(`- pathname = "${window.location.pathname}" >>> "${u}"`),console.log(`- baseName = "${d}"`),console.log(`- isIngress = "${f}"`)),e?(0,Y.jsx)(he,{theme:s,children:(0,Y.jsx)(yt,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:`bottom`,horizontal:`right`},children:(0,Y.jsx)(li,{children:(0,Y.jsx)(Ut,{children:(0,Y.jsx)(a,{basename:d,children:(0,Y.jsx)(Kr,{children:(0,Y.jsxs)(c,{children:[(0,Y.jsx)(i,{path:`/`,element:(0,Y.jsx)(Ir,{})}),(0,Y.jsx)(i,{path:`/devices`,element:(0,Y.jsx)(jn,{})}),(0,Y.jsx)(i,{path:`/log`,element:(0,Y.jsx)(Rr,{})}),(0,Y.jsx)(i,{path:`/settings`,element:(0,Y.jsx)(ri,{})}),(0,Y.jsx)(i,{path:`/test`,element:(0,Y.jsx)(ai,{})}),(0,Y.jsx)(i,{path:`*`,element:(0,Y.jsx)(n,{to:`/`})})]})})})})})})}):(0,Y.jsx)(fi,{setLoggedIn:t})}At.createRoot(document.getElementById(`root`)).render((0,Y.jsx)(G.StrictMode,{children:(0,Y.jsx)(pi,{})}));
|