@matterbridge/frontend 3.5.1 → 3.5.2-dev-20260705-b684a91
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/build/assets/index.js
CHANGED
|
@@ -1,5 +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,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 ee,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 oe,S as se,St as ce,T as le,Tt as ue,U as de,Ut as fe,V as pe,Vt as me,W as he,Wt as ge,X as _e,Y as ve,Z as ye,_ as be,_t as L,a as xe,at as Se,b as Ce,bt as R,c as we,ct as Te,d as Ee,dt as De,et as Oe,f as ke,ft as z,g as Ae,gt as B,h as je,ht as Me,i as Ne,it as Pe,j as Fe,jt as Ie,k as Le,kt as Re,l as ze,lt as Be,m as Ve,mt as He,n as Ue,nt as We,o as Ge,ot as Ke,p as qe,pt as V,q as Je,r as Ye,rt as Xe,s as Ze,st as Qe,t as $e,tt as et,u as tt,ut as nt,v as rt,vt as it,w as at,wt as ot,x as st,xt as H,y as ct,yt as lt,z as ut,zt as U}from"./vendor_mui.js";import{c as dt,g as ft,i as pt,o as mt,s as ht,t as gt,v as _t,y as vt}from"./vendor_mdi.js";import{n as yt,t as bt}from"./vendor_notistack.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";import{t as At}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 W=e(t(),1),jt=e(o(),1),G={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(G).forEach(e=>{localStorage.removeItem(e)}),Object.values(Mt).forEach(e=>{localStorage.removeItem(e)})}var K=!1,Pt=()=>{K=!K},q=localStorage.getItem(G.enableMobile)!==`false`,Ft=()=>{q=!0,localStorage.setItem(G.enableMobile,`true`)},It=()=>{q=!1,localStorage.setItem(G.enableMobile,`false`)},Lt=void 0,Rt=e=>{Lt=e},zt=!1,Bt=e=>{zt=e},Vt=`/`,Ht=e=>{Vt=e},J=A();function Ut(e){return(0,J.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,J.jsxs)(`defs`,{children:[(0,J.jsxs)(`linearGradient`,{id:`lg1`,x1:`16.6`,y1:`16.6`,x2:`279.6`,y2:`279.6`,gradientUnits:`userSpaceOnUse`,children:[(0,J.jsx)(`stop`,{offset:`0`,stopColor:`#00b48d`}),(0,J.jsx)(`stop`,{offset:`.1`,stopColor:`#3faa77`}),(0,J.jsx)(`stop`,{offset:`.3`,stopColor:`#234148`}),(0,J.jsx)(`stop`,{offset:`.7`,stopColor:`#203b44`}),(0,J.jsx)(`stop`,{offset:`.9`,stopColor:`#ad2e6e`}),(0,J.jsx)(`stop`,{offset:`1`,stopColor:`#c81b74`})]}),(0,J.jsxs)(`linearGradient`,{id:`lg2`,x1:`31.1`,y1:`31.1`,x2:`265.1`,y2:`265.1`,gradientUnits:`userSpaceOnUse`,children:[(0,J.jsx)(`stop`,{offset:`0`,stopColor:`#00b48d`}),(0,J.jsx)(`stop`,{offset:`.2`,stopColor:`#285251`}),(0,J.jsx)(`stop`,{offset:`.4`,stopColor:`#234148`}),(0,J.jsx)(`stop`,{offset:`.8`,stopColor:`#203b44`}),(0,J.jsx)(`stop`,{offset:`.9`,stopColor:`#a8316c`}),(0,J.jsx)(`stop`,{offset:`1`,stopColor:`#c81b74`})]}),(0,J.jsxs)(`linearGradient`,{id:`lg3`,x1:`116.2`,y1:`143.9`,x2:`139.8`,y2:`143.9`,gradientUnits:`userSpaceOnUse`,children:[(0,J.jsx)(`stop`,{offset:`0`,stopColor:`#8bc751`}),(0,J.jsx)(`stop`,{offset:`1`,stopColor:`#0db14b`})]}),(0,J.jsx)(`linearGradient`,{id:`lg4`,x1:`136.1`,y1:`100.8`,x2:`159.6`,y2:`100.8`,xlinkHref:`#lg3`}),(0,J.jsx)(`linearGradient`,{id:`lg5`,x1:`155.3`,y1:`143.9`,x2:`178.9`,y2:`143.9`,xlinkHref:`#lg3`}),(0,J.jsxs)(`linearGradient`,{id:`lg6`,x1:`46.8`,y1:`25.7`,x2:`89.6`,y2:`74.8`,gradientUnits:`userSpaceOnUse`,children:[(0,J.jsx)(`stop`,{offset:`0`,stopColor:`#b1d34a`}),(0,J.jsx)(`stop`,{offset:`1`,stopColor:`#50b848`})]})]}),(0,J.jsx)(`rect`,{width:`296.2`,height:`296.2`,rx:`56.7`,ry:`56.7`,style:{fill:`url(#lg1)`}}),(0,J.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,J.jsx)(`circle`,{cx:`128`,cy:`143.9`,r:`11.8`,style:{fill:`url(#lg3)`}}),(0,J.jsx)(`circle`,{cx:`147.8`,cy:`100.8`,r:`11.8`,style:{fill:`url(#lg4)`}}),(0,J.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,J.jsx)(`circle`,{cx:`167.1`,cy:`143.9`,r:`11.8`,style:{fill:`url(#lg5)`}}),(0,J.jsx)(`path`,{fill:`#fff`,d:`M219 89.3V35.5a10.5 10.5 0 1 0-21 0v33.7l21 20Z`}),(0,J.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,J.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,J.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 Wt=(0,W.createContext)(null),Gt=(0,W.createContext)(null),Y=(0,W.createContext)(null);function Kt({children:e}){let[t,n]=(0,W.useState)([]),[r,i]=(0,W.useState)(localStorage.getItem(G.logFilterLevel)??`info`),[a,o]=(0,W.useState)(localStorage.getItem(G.logFilterSearch)??`*`),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(1),{showSnackbarMessage:d,closeSnackbarMessage:f,closeSnackbar:p,showInstallProgress:m,hideInstallProgress:h,exitInstallProgressSuccess:g,exitInstallProgressError:_,addInstallProgress:v}=(0,W.useContext)(Wt),y=(0,W.useRef)([]),b=(0,W.useRef)(null),x=(0,W.useRef)(1),S=(0,W.useRef)(Math.floor(Math.random()*999e3)+1e3),C=(0,W.useRef)(null),w=(0,W.useRef)(null),T=(0,W.useRef)(null),E=(0,W.useRef)(r),D=(0,W.useRef)(a),O=(0,W.useRef)(0),k=(0,W.useRef)(null),A=(0,W.useRef)(Number(localStorage.getItem(G.logLength)??200)),j=(0,W.useRef)(localStorage.getItem(G.logAutoScroll)!==`false`),M=(0,W.useMemo)(()=>window.location.href.replace(/^http/,`ws`),[]);(0,W.useEffect)(()=>(K&&console.log(`WebSocket messages started counter interval`),k.current=setInterval(()=>{O.current>0&&(K&&console.log(`WebSocket messages received in the last 10 seconds: ${O.current*(60/10)} messages/minute`),O.current=0)},10*1e3),()=>{K&&console.log(`WebSocket messages stopped counter interval`),k.current&&clearInterval(k.current),k.current=null}),[]),(0,W.useEffect)(()=>{E.current=r},[r]),(0,W.useEffect)(()=>{D.current=a},[a]);let N=(0,W.useCallback)(()=>Math.floor(Math.random()*999e3)+1e3,[]),ee=(0,W.useCallback)((e,t)=>{K&&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}})())))},[]),te=(0,W.useCallback)(e=>{if(b.current&&b.current.readyState===WebSocket.OPEN)try{K&&console.log(`WebSocket sending message with id ${e.id}:`,e),e.id===void 0&&(e.id=S.current);let t=JSON.stringify(e);b.current.send(t),K&&console.log(`WebSocket sent message:`,e)}catch(e){K&&console.error(`WebSocket error sending message: ${String(e)}`)}else K&&console.error(`WebSocket message not sent, WebSocket not connected:`,e)},[]),P=(0,W.useCallback)((e,t)=>{n(n=>[...n,{level:e,time:``,name:``,message:t}])},[]),ne=(0,W.useCallback)((e,t)=>{K&&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),y.current=[...y.current,{listener:e,id:t}],K&&console.log(`WebSocket addListener total listeners:`,y.current.length)},[]),F=(0,W.useCallback)(e=>{K&&console.log(`WebSocket removeListener:`,e),y.current=y.current.filter(t=>t.listener!==e),K&&console.log(`WebSocket removeListener total listeners:`,y.current.length)},[]),re=(0,W.useCallback)(()=>{M===``||M==null||(P(`WebSocket`,`Connecting ${Lt?`with password`:``} to WebSocket: ${M}`),K&&console.log(`WebSocket connecting to: ${M}${Lt?`?password=[redacted]`:``}`),b.current=new WebSocket(M+(Lt?`?password=${encodeURIComponent(Lt)}`:``)),b.current.onmessage=e=>{s||c(!0),O.current+=1;try{let t=JSON.parse(e.data);if(t.id===void 0||t.src===void 0||t.dst===void 0){K&&console.error(`WebSocket undefined message id/src/dst:`,t);return}if(t.src!==`Matterbridge`||t.dst!==`Frontend`){K&&console.error(`WebSocket invalid message src/dst:`,t);return}if(t.error){K&&console.error(`WebSocket error message response:`,t);return}if(t.id===S.current&&t.method===`pong`&&t.response===`pong`){K&&console.log(`WebSocket pong response message id ${t.id}:`,t),w.current&&clearTimeout(w.current),w.current=null;return}else if(t.method===`snackbar`&&t.response&&t.response.message){K&&console.log(`WebSocket message id ${t.id} method ${t.method}:`,t),d(t.response.message,t.response.timeout,t.response.severity);return}else if(t.method===`close_snackbar`&&t.response&&t.response.message){K&&console.log(`WebSocket message id ${t.id} method ${t.method}:`,t),f(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`?m(t.response.message,``,``):t.response.name===`Matterbridge:spawn-exit-success`?g():t.response.name===`Matterbridge:spawn-exit-error`?_():v(t.response.message+`
|
|
2
|
-
`)),[`debug`,`info`,`notice`,`warn`,`error`,`fatal`].includes(t.response.level)&&(E.current===`info`&&t.response.level===`debug`||E.current===`notice`&&(t.response.level===`debug`||t.response.level===`info`)||E.current===`warn`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`)||E.current===`error`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`||t.response.level===`warn`)||E.current===`fatal`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`||t.response.level===`warn`||t.response.level===`error`)))||D.current!==`*`&&D.current!==``&&!D.current.startsWith(`/`)&&!D.current.endsWith(`/`)&&!t.response.message.toLowerCase().includes(D.current.toLowerCase())&&!t.response.name.toLowerCase().includes(D.current.toLowerCase())||D.current.startsWith(`/`)&&D.current.endsWith(`/`)&&(()=>{try{let e=new RegExp(D.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 "${D.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 K&&console.log(`WebSocket new log message added (${n.length}/${A.current}):`,n[n.length-1]),n.length>A.current+A.current*10/100?(K&&console.log(`WebSocket sliced log messages to the last ${A.current} entries`),n.slice(n.length-A.current)):n})}else{if(K&&console.log(`WebSocket received message id ${t.id} method ${t.method}:`,t),t.id===0)y.current.forEach(e=>e.listener(t));else{let e=y.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)}},b.current.onopen=()=>{K&&console.log(`WebSocket: Connected to WebSocket: ${M}`),P(`WebSocket`,`Connected to WebSocket: ${M}`),c(!0),p(),x.current=1,u(1),T.current=setTimeout(()=>{C.current=setInterval(()=>{te({id:S.current,method:`ping`,src:`Frontend`,dst:`Matterbridge`,params:{}}),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{K&&console.error(`WebSocketUse: No pong response received from WebSocket: ${M}`),P(`WebSocket`,`No pong response received from WebSocket: ${M}`),c(!1)},1e3*50)},1e3*60)},1e3*300)},b.current.onclose=()=>{K&&console.error(`WebSocket: Disconnected from WebSocket ${zt?`with Ingress`:``}: ${M}`),P(`WebSocket`,`Disconnected from WebSocket: ${M}`),c(!1),p(),h(),T.current&&clearTimeout(T.current),w.current&&clearTimeout(w.current),C.current&&clearInterval(C.current),P(`WebSocket`,`Reconnecting (attempt ${x.current} of 100) to WebSocket${zt?` (Ingress)`:``}: ${M}`),zt?setTimeout(I,5e3):x.current===1?I():x.current<100?setTimeout(I,1e3*x.current):P(`WebSocket`,`Reconnect attempts exceeded limit of 100 retries, refresh the page to reconnect to: ${M}`),x.current+=1,u(x.current)},b.current.onerror=e=>{K&&console.error(`WebSocket: WebSocket error connecting to ${M}:`,e),P(`WebSocket`,`WebSocket error connecting to ${M}`)})},[M]),I=(0,W.useCallback)(()=>{K&&console.log(`WebSocket attemptReconnect ${x.current}/100 to:`,M),re()},[re]);(0,W.useEffect)(()=>(re(),()=>{b.current&&b.current.readyState===WebSocket.OPEN&&b.current.close()}),[re]);let ie=(0,W.useMemo)(()=>({messages:t,logLength:A,logAutoScroll:j,logFilterLevel:r,logFilterSearch:a,setMessages:n,setLogFilterLevel:i,setLogFilterSearch:o,filterLogMessages:ee}),[t,A,j,r,a,n,i,o,ee]),ae=(0,W.useMemo)(()=>({logLength:A,logAutoScroll:j,logFilterLevel:r,logFilterSearch:a,setMessages:n,setLogFilterLevel:i,setLogFilterSearch:o,filterLogMessages:ee,online:s,retry:l,getUniqueId:N,addListener:ne,removeListener:F,sendMessage:te,logMessage:P}),[A,j,n,i,o,s,l,ne,F,te,P]);return(0,J.jsx)(Gt.Provider,{value:ie,children:(0,J.jsx)(Y.Provider,{value:ae,children:e})})}function qt(){let{retry:e}=(0,W.useContext)(Y);return(0,J.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,J.jsx)(Ut,{style:{height:`128px`,width:`128px`,margin:`10px`,marginBottom:`20px`}}),e<100?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(fe,{style:{color:`var(--primary-color)`}}),(0,J.jsx)(`div`,{style:{marginTop:`20px`,color:`var(--primary-color)`,textAlign:`center`},children:(0,J.jsxs)(`span`,{children:[`Reconnecting to Matterbridge `,`(attempt `+e+`)`,`...`]})})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{style:{marginTop:`20px`,color:`var(--primary-color)`,textAlign:`center`},children:[(0,J.jsx)(`span`,{children:`Unable to connect to Matterbridge after multiple attempts.`}),(0,J.jsx)(`br`,{}),(0,J.jsx)(`span`,{children:`Please check your network connection.`}),(0,J.jsx)(`br`,{})]}),(0,J.jsx)(U,{variant:`contained`,color:`primary`,onClick:()=>{window.location.reload()},style:{marginTop:`20px`},children:`Refresh the Page`})]})]})}var X=gt();function Z({children:e,style:t}){return(0,J.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 Jt({children:e,style:t}){return(0,J.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 Q({children:e,style:t}){return(0,J.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 Yt({children:e,style:t}){return(0,J.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 Xt({children:e,style:t}){return(0,J.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 Zt({children:e,style:t}){return(0,J.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 Qt({children:e,style:t,onDragOver:n,onDragLeave:r,onDrop:i}){return(0,J.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 $t({children:e,style:t,close:n}){return(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,margin:`0px`,padding:`0px`,paddingRight:`10px`,gap:`10px`,...t},children:[e,!1]})}var en=!1,tn={display:`flex`,gap:`2px`,justifyContent:`space-evenly`,width:`100%`,height:`40px`},nn={margin:`0`,padding:`0`,fontSize:`36px`,fontWeight:`medium`,color:`var(--primary-color)`},rn={margin:`0`,padding:`0`,fontSize:`20px`,fontWeight:`medium`,color:`var(--div-text-color)`,textAlign:`center`},an={margin:`0`,padding:`0`,paddingBottom:`2px`,fontSize:`16px`,fontWeight:`medium`,color:`var(--div-text-color)`,textAlign:`center`},on={display:`flex`,gap:`2px`,justifyContent:`center`,width:`100%`,height:`18px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},sn={margin:`0`,padding:`0`,fontSize:`12px`,fontWeight:`normal`,color:`var(--div-text-color)`},cn={display:`flex`,justifyContent:`center`,width:`100%`,height:`52px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},ln={margin:`0`,padding:`0`,fontSize:`14px`,fontWeight:`bold`,color:`var(--div-text-color)`},un={display:`flex`,gap:`4px`,justifyContent:`center`,width:`100%`,height:`15px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},dn={margin:`0`,padding:`0px 4px`,borderRadius:`5px`,textAlign:`center`,fontSize:`12px`,fontWeight:`normal`,color:`var(--secondary-color)`},fn=[256,257,268,269],pn=[266,267],mn=[259,260,261,271,272],hn=[256,257,268,269,266,267,259,260,261,272];function $({icon:e,iconColor:t,cluster:n,value:r,unit:i,prefix:a}){return K&&console.log(`Render cluster "${n.clusterName}.${n.attributeName}" value(${typeof r}-${Number.isNaN(r)}) "${r}" unit "${i}"`),a??=!1,(0,J.jsxs)(p,{sx:tn,children:[e&&(0,W.cloneElement)(e,{key:`${n.clusterId}-${n.attributeId}-icon`,sx:{...nn,color:t??`var(--primary-color)`}}),(0,J.jsxs)(p,{sx:{...tn,gap:`4px`,alignContent:`center`,alignItems:`end`,justifyContent:`center`},children:[i&&a&&(0,J.jsx)(I,{sx:an,children:i},`${n.clusterId}-${n.attributeId}-unit-prefix`),(0,J.jsx)(I,{sx:rn,children:r==null||typeof r==`number`&&Number.isNaN(r)||r===`NaN`?`---`:r},`${n.clusterId}-${n.attributeId}-value`),i&&!a&&(0,J.jsx)(I,{sx:an,children:i},`${n.clusterId}-${n.attributeId}-unit-suffix`)]},`${n.clusterId}-${n.attributeId}-valueunitbox`)]},`${n.clusterId}-${n.attributeId}-box`)}function gn({device:e,endpoint:t,id:n,deviceType:r,clusters:i}){let a=[`Unknown`,`Good`,`Fair`,`Moderate`,`Poor`,`VeryPoor`,`Ext.Poor`],o=``;K&&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`),hn.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,J.jsxs)(Z,{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,J.jsx)($,{icon:e.attributeLocalValue===!0?(0,J.jsx)(j,{}):(0,J.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,J.jsx)($,{icon:(0,J.jsx)(Ke,{}),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,J.jsx)($,{icon:(0,J.jsx)(et,{}),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,J.jsx)($,{icon:(0,J.jsx)(X.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}`)),fn.includes(r)&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,J.jsx)($,{icon:(0,J.jsx)(_e,{}),cluster:e,value:e.attributeLocalValue===!0?`On`:`Off`},`${e.clusterId}-${e.attributeId}`)),pn.includes(r)&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,J.jsx)($,{icon:(0,J.jsx)(X.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}`)),mn.includes(r)&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.jsx)(S,{}),cluster:e,value:`Oven`},`${e.clusterId}-${e.attributeId}`)),r===112&&i.filter(e=>e.clusterName===`BridgedDeviceBasicInformation`&&e.attributeName===`reachable`).map(e=>(0,J.jsx)($,{icon:(0,J.jsx)(ye,{}),cluster:e,value:`Fridge`},`${e.clusterId}-${e.attributeId}`)),r===113&&i.filter(e=>e.clusterName===`TemperatureControl`&&e.attributeName===`selectedTemperatureLevel`).map(e=>(0,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.jsx)(Se,{}),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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:e.attributeValue===`1`?(0,J.jsx)(O,{}):(0,J.jsx)(Je,{}),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,J.jsx)($,{icon:(0,J.jsx)(Qe,{}),cluster:e,value:e.attributeValue,unit:`%`},`${e.clusterId}-${e.attributeId}`)),r===15&&i.filter(e=>e.clusterName===`Switch`&&e.attributeName===`currentPosition`).map(e=>(0,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.jsx)(Pe,{}),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,J.jsx)($,{icon:(0,J.jsx)(Xe,{}),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,J.jsx)($,{icon:(0,J.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,J.jsx)($,{icon:(0,J.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,J.jsx)($,{icon:(0,J.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,J.jsx)($,{icon:(0,J.jsx)(Te,{}),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,J.jsx)($,{icon:(0,J.jsx)(ut,{}),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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.jsx)(he,{}),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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.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,J.jsx)($,{icon:(0,J.jsx)(X.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,J.jsx)($,{icon:(0,J.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,J.jsx)($,{icon:(0,J.jsx)(Oe,{}),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,J.jsx)($,{icon:e.attributeValue===`true`?(0,J.jsx)(We,{}):(0,J.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,J.jsx)($,{icon:e.attributeValue===`{ occupied: true }`?(0,J.jsx)(w,{}):(0,J.jsx)(pe,{}),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,J.jsx)($,{icon:(0,J.jsx)(ve,{}),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,J.jsx)($,{icon:(0,J.jsx)(de,{}),cluster:e,value:Math.round(e.attributeLocalValue?.energy/1e6),unit:`kwh`},`${e.clusterId}-${e.attributeId}`)),(0,J.jsx)(p,{sx:on,children:(0,J.jsx)(I,{sx:sn,children:o})}),(0,J.jsx)(p,{sx:cn,children:(0,J.jsx)(I,{sx:ln,children:e.name})}),(0,J.jsxs)(p,{sx:un,children:[K&&(0,J.jsx)(I,{sx:dn,children:t}),(0,J.jsx)(I,{sx:dn,children:n}),K&&(0,J.jsxs)(I,{sx:dn,children:[`0x`,r.toString(16).padStart(4,`0`)]})]})]})}function _n({filterPlugins:e,filterDevices:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,W.useContext)(Y),[s,c]=(0,W.useState)([]),[l,u]=(0,W.useState)({}),[d,f]=(0,W.useState)({}),[p,m]=(0,W.useState)({}),h=(0,W.useRef)(o()),g=(0,W.useCallback)(e=>{(K||en)&&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){(K||en)&&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){(K||en)&&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}),(K||en)&&console.log(`DevicesIcons updated "${n.clusterName}.${n.attributeName}" for device "${t.name}" serial "${t.serial}" to "${n.attributeValue}"`)},[p,s]),_=(0,W.useCallback)(e=>{if(K&&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}),K&&console.log(`DevicesIcons endpoints for "${t}":`,l[t]),K&&console.log(`DevicesIcons deviceTypes for "${t}":`,d[t]),K&&console.log(`DevicesIcons clusters for "${t}":`,p[t])},[p,d,l]);(0,W.useEffect)(()=>{let e=e=>{if(K&&console.log(`DevicesIcons received WebSocket Message:`,e),e.method===`refresh_required`)K&&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){K&&console.log(`DevicesIcons received ${e.response.length} devices:`,e.response),c(e.response),u({}),f({}),m({});for(let t of e.response)K&&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),K&&console.log(`DevicesIcons WebSocket effect mounted`),()=>{a(e),K&&console.log(`DevicesIcons WebSocket effect unmounted`)}},[s]),(0,W.useEffect)(()=>(K&&console.log(`DevicesIcons useEffect online mounting`),n&&(K&&console.log(`DevicesIcons useEffect online sending api requests`),r({id:h.current,sender:`DevicesIcons`,method:`/api/devices`,src:`Frontend`,dst:`Matterbridge`,params:{}})),K&&console.log(`DevicesIcons useEffect online mounted`),()=>{K&&console.log(`DevicesIcons useEffect online unmounted`)}),[n,r]);let v=(0,W.memo)(gn),y=e?.trim().toLowerCase(),b=y&&y!==`all plugins`;return K&&console.log(`DevicesIcons rendering...`),(0,J.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,J.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 vn=(0,W.memo)(_n);function yn(e){return e?e.scrollWidth>e.clientWidth:!1}function bn({title:e,children:t}){let n=(0,W.useRef)(null),[r,i]=(0,W.useState)(!1);return(0,J.jsx)(z,{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,J.jsx)(`span`,{ref:n,onMouseEnter:()=>{i(yn(n.current))},onMouseLeave:()=>{i(!1)},style:{display:`inline-block`,maxWidth:`100%`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t})})}function xn(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 Sn({name:e,title:t,columns:n,rows:r,getRowKey:i,footerLeft:a,footerRight:o,onRowClick:s}){let c=(0,W.useRef)(new WeakMap),l=(0,W.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,W.useState)(localStorage.getItem(`${e}_table_order_by`)||null),[m,h]=(0,W.useState)(localStorage.getItem(`${e}_table_order`)||null),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(()=>{try{let t=localStorage.getItem(`${e}_column_visibility`);if(t)return JSON.parse(t)}catch{}return{}}),b=(0,W.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,W.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):xn(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,W.useState)(!1);return k?null:(K&&console.log(`Rendering table ${e}${f&&m?` ordered by ${f}:${m}`:``}`),(0,J.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,J.jsxs)(M,{open:g,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||w()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[(0,J.jsx)(P,{gap:`20px`,children:(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,J.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,J.jsx)(`h4`,{style:{margin:0},children:`Configure ${e} columns`})]})}),(0,J.jsx)(x,{children:(0,J.jsx)(Re,{children:n.filter(e=>!e.hidden).map(e=>(0,J.jsx)(d,{control:(0,J.jsx)(oe,{disabled:!!e.required,checked:e.required?!0:b[e.id]!==!1,onChange:()=>E(e.id)}),label:e.label},e.id))})}),(0,J.jsxs)(D,{children:[(0,J.jsx)(U,{onClick:O,children:`Reset`}),(0,J.jsx)(U,{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,J.jsxs)(Jt,{style:{height:`30px`,minHeight:`30px`,justifyContent:`space-between`,borderBottom:`none`},children:[(0,J.jsx)(Q,{children:e}),t&&(0,J.jsx)(Q,{children:t}),(0,J.jsx)($t,{close:()=>A(!0),children:(0,J.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,J.jsx)(z,{title:`Configure ${e} columns`,children:(0,J.jsx)(X.Icon,{path:mt,size:`20px`,color:`var(--header-text-color)`})})})})]}),(0,J.jsx)(Qt,{style:{flex:`1 1 auto`,display:`flex`,flexDirection:`column`,minHeight:0,width:`100%`,overflow:`auto`,margin:`0px`,padding:`0px`,gap:`0`},children:(0,J.jsxs)(`table`,{"aria-label":`${e} table`,style:{width:`100%`,borderCollapse:`collapse`},children:[(0,J.jsx)(`thead`,{style:{position:`sticky`,top:0,zIndex:10,border:`none`,color:`var(--header-text-color)`,backgroundColor:`var(--header-bg-color`},children:(0,J.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,J.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,J.jsxs)(`span`,{style:{marginLeft:6},children:[m===`asc`&&(0,J.jsx)(X.Icon,{path:`M19 17H22L18 21L14 17H17V3H19M2 17H12V19H2M6 5V7H2V5M2 11H9V13H2V11Z`,size:`15px`}),m===`desc`&&(0,J.jsx)(X.Icon,{path:`M19 7H22L18 3L14 7H17V21H19M2 17H12V19H2M6 5V7H2V5M2 11H9V13H2V11Z`,size:`15px`})]})]},e.id)})})}),(0,J.jsx)(`tbody`,{children:S.map((e,t)=>{let r=u(e);return(0,J.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,J.jsx)(oe,{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,J.jsx)(bn,{title:String(n),children:i}):i;return(0,J.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,J.jsxs)(Yt,{style:{height:`30px`,minHeight:`30px`,justifyContent:`space-between`,border:`none`},children:[(0,J.jsx)(Xt,{style:{fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`},children:a}),(0,J.jsx)(Xt,{style:{fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`},children:o})]})]}))}function Cn(e){return(0,W.memo)(e)}var wn=Cn(Sn),Tn=[{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,J.jsx)(T,{onClick:()=>window.open(n.configUrl,`_blank`),"aria-label":`Open Config`,sx:{margin:0,padding:0},children:(0,J.jsx)(b,{fontSize:`small`})}):null},{label:`Cluster`,id:`cluster`}],En=[{label:`Endpoint`,id:`endpoint`,required:!0},{label:`Id`,id:`id`},{label:`Device Types`,id:`deviceTypes`,render:(e,t,n,r)=>Array.isArray(e)?(0,J.jsx)(J.Fragment,{children:e.map(e=>`0x${e.toString(16).padStart(4,`0`)}`).join(`, `)}):(0,J.jsx)(J.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}],Dn=e=>`${e.pluginName}::${e.uniqueId}`,On=e=>`${e.endpoint}::${e.clusterName}::${e.attributeName}`;function kn({filterPlugins:e,filterDevices:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,W.useContext)(Y),[s,c]=(0,W.useState)([]),[l,u]=(0,W.useState)(s),[d,f]=(0,W.useState)([]),[p,m]=(0,W.useState)(0),[h,g]=(0,W.useState)(null),[_,v]=(0,W.useState)(null),[y,b]=(0,W.useState)(null),[x,S]=(0,W.useState)(null),C=(0,W.useRef)(o()),w=(0,W.useRef)(l),T=(0,W.useCallback)(e=>{K&&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){K&&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){K&&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]),K&&console.log(`DevicesTable updated attribute ${n.clusterName}.${n.attributeName} for device "${t.name}" serial "${t.serial}" to "${n.attributeValue}"`)}},[d,_,h,x]);return(0,W.useEffect)(()=>{let e=e=>{if(K&&console.log(`DevicesTable received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`devices`)K&&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`)K&&console.log(`DevicesTable received ${e.response.length} devices:`,e.response),c(e.response);else if(e.method===`/api/clusters`){K&&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)K&&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),K&&console.log(`DevicesTable added WebSocket listener`),()=>{a(e),K&&console.log(`DevicesTable removed WebSocket listener`)}},[r,i,a,T]),(0,W.useEffect)(()=>{n&&(K&&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,W.useEffect)(()=>{h&&_&&x&&(K&&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,W.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]),K&&console.log(`DevicesTable rendering...`),n?(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,margin:`0px`,padding:`0px`,gap:`20px`,width:`100%`,overflow:`hidden`},children:[(0,J.jsx)(Z,{style:{margin:`0px`,padding:`0px`,gap:`0px`,width:`100%`,maxHeight:h&&_?`30%`:`100%`,flex:`1 1 auto`,overflow:`hidden`},children:(0,J.jsx)(wn,{name:`Registered devices`,getRowKey:Dn,onRowClick:e=>{if(e.uniqueId===x){S(null),g(null),v(null),b(null);return}K&&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:Tn,footerLeft:`Total devices: ${l.length.toString()}`})}),h&&_&&(0,J.jsx)(Z,{style:{margin:`0px`,padding:`0px`,gap:`0px`,width:`100%`,height:`70%`,maxHeight:`70%`,flex:`1 1 auto`,overflow:`hidden`},children:(0,J.jsx)(wn,{name:`Clusters`,title:y||``,getRowKey:On,rows:d,columns:En,footerLeft:`Total child endpoints: ${p-1}`})})]}):(0,J.jsx)(qt,{})}var An=(0,W.memo)(kn);function jn({children:e,style:t,name:n}){let{setCurrentPage:r}=(0,W.useContext)(Wt);return r(n),K&&console.log(`MbfPage: current page set to ${n}`),(0,J.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,margin:`0px`,padding:`0px`,gap:`20px`,...t},children:e})}function Mn(){let{online:e,sendMessage:t,addListener:n,removeListener:r,getUniqueId:i}=(0,W.useContext)(Y),[a,o]=(0,W.useState)([`All plugins`]),[s,c]=(0,W.useState)(`All plugins`),[l,u]=(0,W.useState)(``),[d,f]=(0,W.useState)(`icon`),m=(0,W.useRef)(i());(0,W.useEffect)(()=>{let e=localStorage.getItem(G.devicesFilterPlugins);e&&c(e)},[]),(0,W.useEffect)(()=>{let e=localStorage.getItem(G.devicesFilterDevices);e&&u(e)},[]),(0,W.useEffect)(()=>{let e=localStorage.getItem(G.devicesViewMode);e&&f(e)},[]),(0,W.useEffect)(()=>{let e=e=>{K&&e.id&&console.log(`Devices received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`plugins`&&!e.response.lock?(K&&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&&(K&&console.log(`Devices received ${e.response.length} plugins:`,e.response),o([`All plugins`,...e.response.map(e=>e.name)]))};return n(e,m.current),K&&console.log(`Devices added WebSocket listener`),()=>{r(e),K&&console.log(`Devices removed WebSocket listener`)}},[t,n,r]),(0,W.useEffect)(()=>{e&&(K&&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(G.devicesFilterPlugins,t)},g=e=>{u(e.target.value),localStorage.setItem(G.devicesFilterDevices,e.target.value)},_=()=>{u(``),localStorage.removeItem(G.devicesFilterDevices)},v=e=>{f(e),localStorage.setItem(G.devicesViewMode,e)};return K&&console.log(`Devices rendering...`),e?(0,J.jsxs)(jn,{name:`Devices`,children:[(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,padding:0,margin:0,gap:`20px`,width:`100%`},children:[(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,padding:0,margin:0,gap:`20px`},children:[(0,J.jsxs)(p,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,J.jsx)(I,{sx:{fontSize:`16px`,fontWeight:`normal`,color:`var(--div-text-color)`,marginLeft:`5px`,whiteSpace:`nowrap`},children:`Plugin:`}),(0,J.jsx)(z,{title:`Filter devices by plugin`,children:(0,J.jsx)(L,{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,J.jsx)(it,{sx:{backgroundColor:`var(--main-bg-color)`}}),children:a.map(e=>(0,J.jsx)(B,{value:e,children:e},e))})})]}),(0,J.jsxs)(p,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,J.jsx)(I,{sx:{fontSize:`16px`,fontWeight:`normal`,color:`var(--div-text-color)`,marginLeft:`5px`,whiteSpace:`nowrap`},children:`Filter by:`}),(0,J.jsx)(z,{title:`Filter devices by name or serial number`,children:(0,J.jsx)(V,{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,J.jsx)(y,{position:`end`,children:(0,J.jsx)(T,{"aria-label":`Clear device filter`,size:`small`,onClick:_,edge:`end`,children:(0,J.jsx)(De,{sx:{fontSize:18,color:`var(--main-label-color)`}})})}):null}}})})]})]}),(0,J.jsxs)(p,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,J.jsx)(I,{sx:{fontSize:`16px`,fontWeight:`normal`,color:`var(--div-text-color)`,marginLeft:`5px`,whiteSpace:`nowrap`},children:`View mode:`}),(0,J.jsx)(T,{onClick:()=>v(`table`),"aria-label":`Table View`,disabled:d===`table`,children:(0,J.jsx)(z,{title:`Table View`,children:(0,J.jsx)(nt,{style:{color:d===`table`?`var(--main-icon-color)`:`var(--primary-color)`}})})}),(0,J.jsx)(T,{onClick:()=>v(`icon`),"aria-label":`Icon View`,disabled:d===`icon`,children:(0,J.jsx)(z,{title:`Icon View (beta)`,children:(0,J.jsx)(Be,{style:{color:d===`icon`?`var(--main-icon-color)`:`var(--primary-color)`}})})})]})]}),d===`table`&&(0,J.jsx)(An,{filterPlugins:s,filterDevices:l}),d===`icon`&&(0,J.jsx)(vn,{filterPlugins:s,filterDevices:l})]}):(0,J.jsx)(qt,{})}var Nn=(0,W.memo)(Mn);function Pn({version:e}){let{online:t}=(0,W.useContext)(Y);return K&&console.log(`HomeBrowserRefresh rendering...`),t?(0,J.jsxs)(Z,{children:[(0,J.jsx)(Jt,{children:(0,J.jsx)(Q,{children:`Frontend Update`})}),(0,J.jsxs)(Qt,{style:{flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`},children:[(0,J.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,J.jsx)(`div`,{children:(0,J.jsx)(U,{onClick:()=>window.location.reload(),endIcon:(0,J.jsx)(re,{}),style:{marginLeft:`10px`,color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Refresh`})})]})]}):(0,J.jsx)(qt,{})}var Fn=(0,W.memo)(Pn);function In(e){if(K&&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 Ln=e=>`${e.pluginName}::${e.serial}`;function Rn({storeId:e,setStoreId:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,W.useContext)(Y),{mobile:s}=(0,W.useContext)(Wt),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(!0),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)([]),[g,_]=(0,W.useState)([]),[v,y]=(0,W.useState)([]),[S,C]=(0,W.useState)([]),[w,E]=(0,W.useState)(null),[O,k]=(0,W.useState)(`inactive`),A=(0,W.useRef)(o()),j=[{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,J.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,J.jsx)(et,{fontSize:`small`,sx:{color:`var(--primary-color)`}}):n.powerSource===`ok`?n.batteryLevel?(0,J.jsx)(z,{title:`Battery level: ${n.batteryLevel}%`,children:(0,J.jsx)(Ke,{fontSize:`small`,sx:{color:`green`}})}):(0,J.jsx)(Ke,{fontSize:`small`,sx:{color:`gray`}}):n.powerSource===`warning`?n.batteryLevel?(0,J.jsx)(z,{title:`Battery level: ${n.batteryLevel}%`,children:(0,J.jsx)(Ke,{fontSize:`small`,sx:{color:`yellow`}})}):(0,J.jsx)(Ke,{fontSize:`small`,sx:{color:`yellow`}}):n.powerSource===`critical`?n.batteryLevel?(0,J.jsx)(z,{title:`Battery level: ${n.batteryLevel}%`,children:(0,J.jsx)(Ke,{fontSize:`small`,sx:{color:`red`}})}):(0,J.jsx)(Ke,{fontSize:`small`,sx:{color:`red`}}):(0,J.jsx)(`span`,{})},{label:`Actions`,id:`selected`,required:!0,render:(n,r,i,a)=>(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`},children:[i.matter===void 0?(0,J.jsx)(`div`,{style:{width:`20px`,height:`20px`}}):(0,J.jsx)(z,{title:`Show the QRCode or the fabrics`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,J.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:In(i.matter)},children:(0,J.jsx)(te,{fontSize:`small`})})}),i.configUrl?(0,J.jsx)(z,{title:`Open the configuration page`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,J.jsx)(T,{onClick:()=>P(i),"aria-label":`Open config url`,sx:{margin:0,padding:0},children:(0,J.jsx)(b,{fontSize:`small`})})}):(0,J.jsx)(`div`,{style:{width:`20px`,height:`20px`}}),i.selected===void 0?(0,J.jsx)(`div`,{style:{width:`20px`,height:`20px`}}):(0,J.jsx)(z,{title:`Select/unselect the device`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,J.jsx)(oe,{checked:i.selected,onChange:e=>ee(e,i),sx:{margin:`0`,marginLeft:`8px`,padding:`0`},size:`small`})})]})}],N=(0,W.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,W.useEffect)(()=>{let e=e=>{if(K&&console.log(`HomeDevices received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed!==`matter`?e.response.changed===`plugins`&&e.response.lock?K&&console.log(`HomeDevices received refresh_required: changed=${e.response.changed} lock=${e.response.lock} skipping /api/plugins request`):(K&&console.log(`HomeDevices received refresh_required: changed=${e.response.changed} and sending /api/plugins request`),r({id:A.current,sender:`HomeDevices`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`refresh_required`&&e.response.changed===`matter`?(K&&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 K&&console.debug(`HomeDevices: matter id ${e.response.matter?.id} not found`),t;let r=[...t];return r[n]={...r[n],matter:e.response.matter},K&&console.log(`HomeDevices received refresh_required: changed=${e.response.changed} and set matter id ${e.response.matter?.id}`),r})):e.method===`restart_required`?(K&&console.log(`HomeDevices received restart_required`),l(!0)):e.method===`restart_not_required`?(K&&console.log(`HomeDevices received restart_not_required`),l(!1)):e.method===`matterbridge_status_update`?(K&&console.log(`HomeDevices received matterbridge_status_update: ${e.response.status}`),k(e.response.status)):e.method===`state_update`&&e.response.plugin&&e.response.serialNumber&&e.response.cluster.includes(`BasicInformation`)&&e.response.attribute===`reachable`&&(K&&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?(K&&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===A.current&&e.method===`/api/settings`)K&&console.log(`HomeDevices (id: ${e.id}) received settings:`,e.response),p(e.response),l(e.response.matterbridgeInformation.restartRequired||e.response.matterbridgeInformation.fixedRestartRequired),k(e.response.matterbridgeInformation.bridgeStatus);else if(e.id===A.current&&e.method===`/api/plugins`){if(K&&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;K&&console.log(`HomeDevices reset plugins, devices and selectDevices`),d(!1),h(e.response),_([]),y([]),r({id:A.current,sender:`HomeDevices`,method:`/api/devices`,src:`Frontend`,dst:`Matterbridge`,params:{}}),K&&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:A.current,sender:`HomeDevices`,method:`/api/select/devices`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:t.name}}),K&&console.log(`HomeDevices sent /api/select/devices for plugin: ${t.name}`))}}else if(e.id===A.current&&e.method===`/api/devices`){if(K&&console.log(`HomeDevices (id: ${e.id}) received ${e.response?.length} devices:`,e.response),e.response){for(let t of e.response)t.selected=N(t);_(e.response)}}else e.id===A.current&&e.method===`/api/select/devices`&&(K&&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:N(e)}));return[...n,...r]}))};return i(e,A.current),K&&console.log(`HomeDevices added WebSocket listener id ${A.current}`),()=>{a(e),K&&console.log(`HomeDevices removed WebSocket listener`)}},[m,i,a,r,N]),(0,W.useEffect)(()=>{if(g.length===0&&v.length===0){C([]);return}K&&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),K&&console.log(`HomeDevices mixed ${e.length} devices and selectDevices`))},[m,g,v,C]),(0,W.useEffect)(()=>{n&&(K&&console.log(`HomeDevices sending /api/settings and /api/plugins requests`),r({id:A.current,sender:`HomeDevices`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:A.current,sender:`HomeDevices`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[n,r]);let ee=(e,t)=>{K&&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?(K&&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:A.current,sender:`HomeDevices`,method:`/api/command`,src:`Frontend`,dst:`Matterbridge`,params:{command:`selectdevice`,plugin:t.pluginName,serial:t.serial,name:t.name}}):r({id:A.current,sender:`HomeDevices`,method:`/api/command`,src:`Frontend`,dst:`Matterbridge`,params:{command:`unselectdevice`,plugin:t.pluginName,serial:t.serial,name:t.name}})},P=e=>{if(K&&console.log(`handleConfigUrl device:`,e.name,`configUrl:`,e.configUrl),e.configUrl)if(e.configUrl.startsWith(`/plugins/`)||e.configUrl.startsWith(`./plugins/`)){let t=`${Vt}${e.configUrl.replace(/^\.?\//,``)}`,n=t.endsWith(`/`)?t:`${t}/`;console.log(`handleConfigUrl opening plugin frontend for device:`,e.name,`basePath:`,Vt,`configUrl:`,e.configUrl,`computed pluginFrontendPath:`,n),E({name:e.name,path:n})}else window.open(e.configUrl,`_blank`)};return K&&console.log(`HomeDevices rendering...`),n?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{style:{flex:`1 1 auto`},children:(0,J.jsx)(wn,{name:`Devices`,getRowKey:Ln,rows:S,columns:j,footerLeft:u?`Waiting for the plugins to fully load...`:`Registered devices: ${g.length.toString()}/${S.length.toString()}`,footerRight:c?`Restart required`:``})}),(0,J.jsxs)(M,{open:w!==null,onClose:()=>E(null),slotProps:{paper:{sx:{width:q&&s?`100vw`:`75vw`,height:q&&s?`100vh`:`75vh`,maxWidth:q&&s?`100vw`:`75vw`,maxHeight:q&&s?`100vh`:`75vh`,margin:q&&s?`0px`:void 0,display:`flex`,flexDirection:`column`,overflow:`hidden`,backgroundColor:`var(--div-bg-color)`}}},children:[(0,J.jsx)(x,{style:{display:`flex`,flex:`1 1 auto`,minHeight:0,padding:`0px`,margin:`0px`,overflow:`hidden`,backgroundColor:`var(--div-bg-color)`},children:w&&(0,J.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=`
|
|
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 ee,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 he,X as ge,Y as _e,Z as ve,_ as ye,_t as R,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},Bt=`/`,Vt=e=>{Bt=e},Y=A();function Ht(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 Ut=(0,G.createContext)(null),Wt=(0,G.createContext)(null),X=(0,G.createContext)(null);function Gt({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),[l,u]=(0,G.useState)(1),{showSnackbarMessage:d,closeSnackbarMessage:f,closeSnackbar:p,showInstallProgress:m,hideInstallProgress:h,exitInstallProgressSuccess:g,exitInstallProgressError:_,addInstallProgress:v}=(0,G.useContext)(Ut),y=(0,G.useRef)([]),b=(0,G.useRef)(null),x=(0,G.useRef)(1),S=(0,G.useRef)(Math.floor(Math.random()*999e3)+1e3),C=(0,G.useRef)(null),w=(0,G.useRef)(null),T=(0,G.useRef)(null),E=(0,G.useRef)(r),D=(0,G.useRef)(a),O=(0,G.useRef)(0),k=(0,G.useRef)(null),A=(0,G.useRef)(Number(localStorage.getItem(K.logLength)??200)),j=(0,G.useRef)(localStorage.getItem(K.logAutoScroll)!==`false`),M=(0,G.useMemo)(()=>window.location.href.replace(/^http/,`ws`),[]);(0,G.useEffect)(()=>(q&&console.log(`WebSocket messages started counter interval`),k.current=setInterval(()=>{O.current>0&&(q&&console.log(`WebSocket messages received in the last 10 seconds: ${O.current*(60/10)} messages/minute`),O.current=0)},10*1e3),()=>{q&&console.log(`WebSocket messages stopped counter interval`),k.current&&clearInterval(k.current),k.current=null}),[]),(0,G.useEffect)(()=>{E.current=r},[r]),(0,G.useEffect)(()=>{D.current=a},[a]);let N=(0,G.useCallback)(()=>Math.floor(Math.random()*999e3)+1e3,[]),ee=(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}})())))},[]),te=(0,G.useCallback)(e=>{if(b.current&&b.current.readyState===WebSocket.OPEN)try{q&&console.log(`WebSocket sending message with id ${e.id}:`,e),e.id===void 0&&(e.id=S.current);let t=JSON.stringify(e);b.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}])},[]),ne=(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),y.current=[...y.current,{listener:e,id:t}],q&&console.log(`WebSocket addListener total listeners:`,y.current.length)},[]),F=(0,G.useCallback)(e=>{q&&console.log(`WebSocket removeListener:`,e),y.current=y.current.filter(t=>t.listener!==e),q&&console.log(`WebSocket removeListener total listeners:`,y.current.length)},[]),re=(0,G.useCallback)(()=>{M===``||M==null||(P(`WebSocket`,`Connecting ${It?`with password`:``} to WebSocket: ${M}`),q&&console.log(`WebSocket connecting to: ${M}${It?`?password=[redacted]`:``}`),b.current=new WebSocket(M+(It?`?password=${encodeURIComponent(It)}`:``)),b.current.onmessage=e=>{s||c(!0),O.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===S.current&&t.method===`pong`&&t.response===`pong`){q&&console.log(`WebSocket pong response message id ${t.id}:`,t),w.current&&clearTimeout(w.current),w.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),d(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),f(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`?m(t.response.message,``,``):t.response.name===`Matterbridge:spawn-exit-success`?g():t.response.name===`Matterbridge:spawn-exit-error`?_():v(t.response.message+`
|
|
2
|
+
`)),[`debug`,`info`,`notice`,`warn`,`error`,`fatal`].includes(t.response.level)&&(E.current===`info`&&t.response.level===`debug`||E.current===`notice`&&(t.response.level===`debug`||t.response.level===`info`)||E.current===`warn`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`)||E.current===`error`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`||t.response.level===`warn`)||E.current===`fatal`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`||t.response.level===`warn`||t.response.level===`error`)))||D.current!==`*`&&D.current!==``&&!D.current.startsWith(`/`)&&!D.current.endsWith(`/`)&&!t.response.message.toLowerCase().includes(D.current.toLowerCase())&&!t.response.name.toLowerCase().includes(D.current.toLowerCase())||D.current.startsWith(`/`)&&D.current.endsWith(`/`)&&(()=>{try{let e=new RegExp(D.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 "${D.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}/${A.current}):`,n[n.length-1]),n.length>A.current+A.current*10/100?(q&&console.log(`WebSocket sliced log messages to the last ${A.current} entries`),n.slice(n.length-A.current)):n})}else{if(q&&console.log(`WebSocket received message id ${t.id} method ${t.method}:`,t),t.id===0)y.current.forEach(e=>e.listener(t));else{let e=y.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)}},b.current.onopen=()=>{q&&console.log(`WebSocket: Connected to WebSocket: ${M}`),P(`WebSocket`,`Connected to WebSocket: ${M}`),c(!0),p(),x.current=1,u(1),T.current=setTimeout(()=>{C.current=setInterval(()=>{te({id:S.current,method:`ping`,src:`Frontend`,dst:`Matterbridge`,params:{}}),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{q&&console.error(`WebSocketUse: No pong response received from WebSocket: ${M}`),P(`WebSocket`,`No pong response received from WebSocket: ${M}`),c(!1)},1e3*50)},1e3*60)},1e3*300)},b.current.onclose=()=>{q&&console.error(`WebSocket: Disconnected from WebSocket ${Rt?`with Ingress`:``}: ${M}`),P(`WebSocket`,`Disconnected from WebSocket: ${M}`),c(!1),p(),h(),T.current&&clearTimeout(T.current),w.current&&clearTimeout(w.current),C.current&&clearInterval(C.current),P(`WebSocket`,`Reconnecting (attempt ${x.current} of 100) to WebSocket${Rt?` (Ingress)`:``}: ${M}`),Rt?setTimeout(I,5e3):x.current===1?I():x.current<100?setTimeout(I,1e3*x.current):P(`WebSocket`,`Reconnect attempts exceeded limit of 100 retries, refresh the page to reconnect to: ${M}`),x.current+=1,u(x.current)},b.current.onerror=e=>{q&&console.error(`WebSocket: WebSocket error connecting to ${M}:`,e),P(`WebSocket`,`WebSocket error connecting to ${M}`)})},[M]),I=(0,G.useCallback)(()=>{q&&console.log(`WebSocket attemptReconnect ${x.current}/100 to:`,M),re()},[re]);(0,G.useEffect)(()=>(re(),()=>{b.current&&b.current.readyState===WebSocket.OPEN&&b.current.close()}),[re]);let ie=(0,G.useMemo)(()=>({messages:t,logLength:A,logAutoScroll:j,logFilterLevel:r,logFilterSearch:a,setMessages:n,setLogFilterLevel:i,setLogFilterSearch:o,filterLogMessages:ee}),[t,A,j,r,a,n,i,o,ee]),ae=(0,G.useMemo)(()=>({logLength:A,logAutoScroll:j,logFilterLevel:r,logFilterSearch:a,setMessages:n,setLogFilterLevel:i,setLogFilterSearch:o,filterLogMessages:ee,online:s,retry:l,getUniqueId:N,addListener:ne,removeListener:F,sendMessage:te,logMessage:P}),[A,j,n,i,o,s,l,ne,F,te,P]);return(0,Y.jsx)(Wt.Provider,{value:ie,children:(0,Y.jsx)(X.Provider,{value:ae,children:e})})}function Kt(){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)(Ht,{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 qt({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 Jt({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 Yt({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 Xt({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 Zt({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 Qt({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 $t({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 en={display:`flex`,gap:`2px`,justifyContent:`space-evenly`,width:`100%`,height:`40px`},tn={margin:`0`,padding:`0`,fontSize:`36px`,fontWeight:`medium`,color:`var(--primary-color)`},nn={margin:`0`,padding:`0`,fontSize:`20px`,fontWeight:`medium`,color:`var(--div-text-color)`,textAlign:`center`},rn={margin:`0`,padding:`0`,paddingBottom:`2px`,fontSize:`16px`,fontWeight:`medium`,color:`var(--div-text-color)`,textAlign:`center`},an={display:`flex`,gap:`2px`,justifyContent:`center`,width:`100%`,height:`18px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},on={margin:`0`,padding:`0`,fontSize:`12px`,fontWeight:`normal`,color:`var(--div-text-color)`},sn={display:`flex`,justifyContent:`center`,width:`100%`,height:`52px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},cn={margin:`0`,padding:`0`,fontSize:`14px`,fontWeight:`bold`,color:`var(--div-text-color)`},ln={display:`flex`,gap:`4px`,justifyContent:`center`,width:`100%`,height:`15px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},un={margin:`0`,padding:`0px 4px`,borderRadius:`5px`,textAlign:`center`,fontSize:`12px`,fontWeight:`normal`,color:`var(--secondary-color)`},dn=[256,257,268,269],fn=[266,267],pn=[259,260,261,271,272],mn=[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:en,children:[e&&(0,G.cloneElement)(e,{key:`${n.clusterId}-${n.attributeId}-icon`,sx:{...tn,color:t??`var(--primary-color)`}}),(0,Y.jsxs)(W,{sx:{...en,gap:`4px`,alignContent:`center`,alignItems:`end`,justifyContent:`center`},children:[i&&a&&(0,Y.jsx)(p,{sx:rn,children:i},`${n.clusterId}-${n.attributeId}-unit-prefix`),(0,Y.jsx)(p,{sx:nn,children:r==null||typeof r==`number`&&Number.isNaN(r)||r===`NaN`?`---`:r},`${n.clusterId}-${n.attributeId}-value`),i&&!a&&(0,Y.jsx)(p,{sx:rn,children:i},`${n.clusterId}-${n.attributeId}-unit-suffix`)]},`${n.clusterId}-${n.attributeId}-valueunitbox`)]},`${n.clusterId}-${n.attributeId}-box`)}function hn({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`),mn.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}`)),dn.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}`)),fn.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}`)),pn.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)(ve,{}),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:an,children:(0,Y.jsx)(p,{sx:on,children:o})}),(0,Y.jsx)(W,{sx:sn,children:(0,Y.jsx)(p,{sx:cn,children:e.name})}),(0,Y.jsxs)(W,{sx:ln,children:[q&&(0,Y.jsx)(p,{sx:un,children:t}),(0,Y.jsx)(p,{sx:un,children:n}),q&&(0,Y.jsxs)(p,{sx:un,children:[`0x`,r.toString(16).padStart(4,`0`)]})]})]})}function gn({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&&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&&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&&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&&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)(hn),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 _n=(0,G.memo)(gn);function vn(e){return e?e.scrollWidth>e.clientWidth:!1}function yn({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(vn(n.current))},onMouseLeave:()=>{i(!1)},style:{display:`inline-block`,maxWidth:`100%`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t})})}function bn(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 xn({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):bn(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)(P,{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)(I,{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)(qt,{style:{height:`30px`,minHeight:`30px`,justifyContent:`space-between`,borderBottom:`none`},children:[(0,Y.jsx)(Jt,{children:e}),t&&(0,Y.jsx)(Jt,{children:t}),(0,Y.jsx)($t,{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)(Qt,{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)(yn,{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)(Yt,{style:{height:`30px`,minHeight:`30px`,justifyContent:`space-between`,border:`none`},children:[(0,Y.jsx)(Xt,{style:{fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`},children:a}),(0,Y.jsx)(Xt,{style:{fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`},children:o})]})]}))}function Sn(e){return(0,G.memo)(e)}var Cn=Sn(xn),wn=[{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`}],Tn=[{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}],En=e=>`${e.pluginName}::${e.uniqueId}`,Dn=e=>`${e.endpoint}::${e.clusterName}::${e.attributeName}`;function On({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)(Cn,{name:`Registered devices`,getRowKey:En,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:wn,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)(Cn,{name:`Clusters`,title:y||``,getRowKey:Dn,rows:d,columns:Tn,footerLeft:`Total child endpoints: ${p-1}`})})]}):(0,Y.jsx)(Kt,{})}var kn=(0,G.memo)(On);function An({children:e,style:t,name:n}){let{setCurrentPage:r}=(0,G.useContext)(Ut);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 jn(){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)(An,{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)(R,{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)(kn,{filterPlugins:s,filterDevices:l}),d===`icon`&&(0,Y.jsx)(_n,{filterPlugins:s,filterDevices:l})]}):(0,Y.jsx)(Kt,{})}var Mn=(0,G.memo)(jn);function Nn({version:e}){let{online:t}=(0,G.useContext)(X);return q&&console.log(`HomeBrowserRefresh rendering...`),t?(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(qt,{children:(0,Y.jsx)(Jt,{children:`Frontend Update`})}),(0,Y.jsxs)(Qt,{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)(re,{}),style:{marginLeft:`10px`,color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Refresh`})})]})]}):(0,Y.jsx)(Kt,{})}var Pn=(0,G.memo)(Nn);function Fn(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 In=e=>`${e.pluginName}::${e.serial}`;function Ln({storeId:e,setStoreId:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(X),{mobile:s}=(0,G.useContext)(Ut),[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,k]=(0,G.useState)(`inactive`),A=(0,G.useRef)(o()),j=[{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:Fn(i.matter)},children:(0,Y.jsx)(te,{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:()=>P(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=>ee(e,i),sx:{margin:`0`,marginLeft:`8px`,padding:`0`},size:`small`})})]})}],N=(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:A.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===`matterbridge_status_update`?(q&&console.log(`HomeDevices received matterbridge_status_update: ${e.response.status}`),k(e.response.status)):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===A.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),k(e.response.matterbridgeInformation.bridgeStatus);else if(e.id===A.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:A.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:A.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===A.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=N(t);_(e.response)}}else e.id===A.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:N(e)}));return[...n,...r]}))};return i(e,A.current),q&&console.log(`HomeDevices added WebSocket listener id ${A.current}`),()=>{a(e),q&&console.log(`HomeDevices removed WebSocket listener`)}},[m,i,a,r,N]),(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:A.current,sender:`HomeDevices`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:A.current,sender:`HomeDevices`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[n,r]);let ee=(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:A.current,sender:`HomeDevices`,method:`/api/command`,src:`Frontend`,dst:`Matterbridge`,params:{command:`selectdevice`,plugin:t.pluginName,serial:t.serial,name:t.name}}):r({id:A.current,sender:`HomeDevices`,method:`/api/command`,src:`Frontend`,dst:`Matterbridge`,params:{command:`unselectdevice`,plugin:t.pluginName,serial:t.serial,name:t.name}})},P=e=>{if(q&&console.log(`handleConfigUrl device:`,e.name,`configUrl:`,e.configUrl),e.configUrl)if(e.configUrl.startsWith(`/plugins/`)||e.configUrl.startsWith(`./plugins/`)){let t=`${Bt}${e.configUrl.replace(/^\.?\//,``)}`,n=t.endsWith(`/`)?t:`${t}/`;console.log(`handleConfigUrl opening plugin frontend for device:`,e.name,`basePath:`,Bt,`configUrl:`,e.configUrl,`computed pluginFrontendPath:`,n),E({name:e.name,path:n})}else 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)(Cn,{name:`Devices`,getRowKey:In,rows:S,columns:j,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)(I,{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=`
|
|
3
3
|
html,
|
|
4
4
|
body {
|
|
5
5
|
background-color: ${i};
|
|
@@ -19,7 +19,7 @@ import{a as e}from"./rolldown-runtime.js";import{c as t}from"./vendor_emotion.js
|
|
|
19
19
|
::-webkit-scrollbar-track {
|
|
20
20
|
background: ${i};
|
|
21
21
|
}
|
|
22
|
-
`,t.head.appendChild(a)},style:{display:`block`,flex:`1 1 auto`,width:`100%`,height:`100%`,border:`none`,backgroundColor:`var(--div-bg-color)`}})}),(0,J.jsx)(D,{sx:{flex:`0 0 auto`,justifyContent:`center`},children:(0,J.jsx)(U,{onClick:()=>E(null),children:`Close`})})]})]}):(0,J.jsx)(qt,{})}var zn=(0,W.memo)(Rn),Bn=[`matterbridge-`,`matterbridge-plugin-template`,`matterbridge-dyson`,`matterbridge-tuya`,`matterbridge-matter`,`matterbridge-automations`,`matterbridge-securitysystem`,`matterbridge-adapter`],Vn=e=>e.replace(`git+`,``).replace(`.git`,``).trim(),Hn=e=>{let t=Vn(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},Un=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},Wn=()=>{try{let e=window.localStorage.getItem(G.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{}}},Gn=e=>{try{window.localStorage.setItem(G.searchPluginsTotal,JSON.stringify(e))}catch{}},Kn=()=>{try{let e=window.localStorage.getItem(G.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{}}},qn=e=>{try{window.localStorage.setItem(G.searchPluginsMeta,JSON.stringify(e))}catch{}},Jn=()=>{try{let e=window.localStorage.getItem(G.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{}}},Yn=e=>{try{window.localStorage.setItem(G.searchPluginsVersions,JSON.stringify(e))}catch{}},Xn=({open:e,onClose:t,onSelect:n,onVersions:r})=>{let{mobile:i}=(0,W.useContext)(Wt),[a,o]=(0,W.useState)(``),s=(0,W.useRef)(``),c=(0,W.useRef)(!1),l=(0,W.useRef)(null),[u,d]=(0,W.useState)([]),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(!1),[_,y]=(0,W.useState)(!1),[b,S]=(0,W.useState)({done:0,total:0}),[C,w]=(0,W.useState)(null),E=(0,W.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,W.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 K&&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`&&K&&console.log(`[SearchPluginsDialog] versions cache ignored (old format) for ${e} (asOf=${t})`);let r=`https://registry.npmjs.org/${encodeURIComponent(e)}`;K&&console.log(`[SearchPluginsDialog] fetching versions for ${e} from: ${r}`);let i=await fetch(r,{signal:l.current?.signal});if(!i.ok)return K&&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),K&&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},Yn(E.current),f},[]),j=e=>new Intl.NumberFormat().format(e),N=[{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,J.jsxs)(`div`,{style:{margin:`0`,padding:`0`,gap:`4px`,display:`flex`,flexDirection:`row`,justifyContent:`center`},children:[(0,J.jsx)(z,{title:n.homepage?`Open the plugin homepage`:`No homepage available`,children:(0,J.jsx)(`span`,{children:(0,J.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,J.jsx)(le,{})})})}),(0,J.jsx)(z,{title:n.help?`Open the plugin help`:`No help available`,children:(0,J.jsx)(`span`,{children:(0,J.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,J.jsx)(g,{})})})}),(0,J.jsx)(z,{title:n.changelog?`Open the plugin changelog`:`No changelog available`,children:(0,J.jsx)(`span`,{children:(0,J.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,J.jsx)(v,{})})})})]})}];(0,W.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=Jn(),(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=>!Bn.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=Wn(),h=Kn();d(u.map(e=>{let t=m[e.name];return!t||typeof t.total!=`number`?e:(K&&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 K&&(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});K&&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);K&&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&&K&&console.log(`[SearchPluginsDialog] metadata fetch skipped (cache fresh+complete) for ${e} (asOf=${t.asOf}).`),n&&!r&&K&&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`)?Vn(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=Un(i.repository),l=c?Hn(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},qn(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||K&&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 ee=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},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{K&&console.log(`[SearchPluginsDialog] fetching total downloads for ${r} (range ${O}:${f})...`);let e=await ee(r);if(t.signal.aborted)return;K&&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},Gn(m),K&&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,S({done:P,total:N}),t.signal.aborted||await n(500)}}}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>ne())).finally(()=>{t.signal.aborted||y(!1)}),K&&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 ee=async()=>{O();let e=s.current||a;if(!(!e||m))try{h(!0);let t=await A(e,k(new Date));K&&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)}},te=()=>{O(),t(),r([])},ne=u.reduce((e,t)=>e+(typeof t.downloads==`number`?t.downloads:0),0),F=u.reduce((e,t)=>(typeof t.total==`number`&&(e.total+=t.total,e.hasAny=!0),e),{total:0,hasAny:!1}),re=_?` Totals: ${b.done.toString()}/${b.total.toString()} fetched`:``,I=F.hasAny?j(F.total):`...`;return(0,J.jsxs)(M,{open:e,onClose:()=>{O(),t()},maxWidth:!1,fullWidth:!0,slotProps:{paper:{sx:{width:q&&i?`100vw`:`75vw`,height:q&&i?`100vh`:`75vh`,maxWidth:q&&i?`100vw`:`75vw`,maxHeight:q&&i?`100vh`:`75vh`,margin:q&&i?`0px`:void 0,display:`flex`,flexDirection:`column`}}},children:[(0,J.jsx)(P,{children:(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,J.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,J.jsx)(`h4`,{style:{margin:0},children:`Search Plugins`})]})}),(0,J.jsx)(x,{dividers:!0,sx:{padding:`10px`,flex:`1 1 auto`,minHeight:0},children:(0,J.jsx)(`div`,{style:{height:`100%`,width:`100%`,display:`flex`,flexDirection:`column`,minHeight:0},children:f?(0,J.jsx)(`div`,{style:{padding:`20px`},children:`Loading npm registry...`}):C?(0,J.jsx)(`div`,{style:{padding:`20px`},children:C}):(0,J.jsx)(wn,{name:`Search plugins`,rows:u,columns:N,getRowKey:`name`,onRowClick:(e,t,n)=>{s.current=e.name,o(e.name),n.detail===2&&ee()},footerLeft:`Total packages: ${u.length.toString()} Total downloads: ${j(ne)} / ${I}${re}`,footerRight:a?`Selected: ${a}`:``})})}),(0,J.jsxs)(D,{sx:{justifyContent:`center`,gap:1.5,flexWrap:`wrap`},children:[(0,J.jsx)(z,{title:`Select the plugin and close the dialog. Double-click a row to select and close the dialog.`,children:(0,J.jsx)(U,{variant:`contained`,onClick:ee,disabled:!(s.current||a)||m,children:`Select`})}),(0,J.jsx)(z,{title:`Close the dialog without selecting a plugin.`,children:(0,J.jsx)(U,{onClick:te,children:`Cancel`})})]})]})};function Zn(){let{mobile:e,showSnackbarMessage:t}=(0,W.useContext)(Wt),{logMessage:n,sendMessage:r,getUniqueId:i}=(0,W.useContext)(Y),[a,o]=(0,W.useState)(`matterbridge-`),[s,c]=(0,W.useState)([`latest`,`dev`]),[l,d]=(0,W.useState)(`latest`),[f,p]=(0,W.useState)(!1),m=(0,W.useRef)(i()),h=e=>{let t=(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(Bn.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(Bn.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(),K&&console.log(`Right-clicked Upload button`)},D=e=>{e.preventDefault(),K&&console.log(`Right-clicked Add button`)},[O,k]=(0,W.useState)(!1),A=()=>{k(!0),K&&console.log(`Dialog opened for selection`)},j=()=>{o(`matterbridge-`),k(!1),K&&console.log(`Dialog closed without selection`)},M=e=>{o(e),k(!1),K&&console.log(`Select plugin:`,e)},ee=e=>{c(e),d(e.includes(`latest`)?`latest`:e[0]??``),K&&console.log(`Select plugin versions:`,e)},[te,P]=(0,W.useState)(!1);return K&&console.log(`HomeInstallAddPlugins rendering...`),te?null:(0,J.jsxs)(Z,{children:[(0,J.jsxs)(Jt,{children:[(0,J.jsx)(Q,{children:`Install plugins`}),(0,J.jsx)($t,{close:()=>P(!0)})]}),(0,J.jsxs)(Qt,{onDragOver:_,onDragLeave:v,onDrop:y,style:q&&e?{flexWrap:`wrap`,alignItems:`center`,gap:`10px`}:{flexWrap:`wrap`,alignItems:`center`,gap:`20px`},children:[(0,J.jsx)(Xn,{open:O,onClose:j,onSelect:M,onVersions:ee}),(0,J.jsxs)(`div`,{style:{flex:`1 1 auto`,display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,J.jsx)(z,{title:`Provide the npm name or the local path of the plugin to install, uninstall, or add`,children:(0,J.jsx)(V,{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,J.jsx)(z,{title:`Select the npm tag/version to install`,children:(0,J.jsx)(`span`,{children:(0,J.jsxs)(Ie,{size:`small`,style:{minWidth:`150px`},children:[(0,J.jsx)(ue,{id:`plugin-version-label`,children:`Tag or version`}),(0,J.jsx)(L,{labelId:`plugin-version-label`,id:`plugin-version`,value:l,label:`Tag or version`,onChange:e=>d(e.target.value??``),sx:{"& .MuiSelect-icon":{color:`var(--main-label-color)`}},children:s.map(e=>(0,J.jsx)(B,{value:e,children:e},e))})]})})}),(0,J.jsx)(z,{title:`Search on npm the plugin to install`,children:(0,J.jsx)(T,{size:`large`,onClick:A,children:(0,J.jsx)(ne,{fontSize:`inherit`})})})]}),(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,J.jsx)(z,{title:`Install or update a plugin from npm`,children:(0,J.jsxs)(U,{onClick:x,endIcon:(0,J.jsx)(u,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Install`]})}),(0,J.jsx)(z,{title:`Uninstall and remove a plugin`,children:(0,J.jsxs)(U,{onClick:S,endIcon:(0,J.jsx)(Fe,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Uninstall`]})}),(0,J.jsx)(z,{title:`Upload and install a plugin from a tarball`,children:(0,J.jsxs)(U,{onClick:C,onContextMenu:E,endIcon:(0,J.jsx)(Le,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Upload`]})}),(0,J.jsx)(z,{title:`Add an already installed plugin or a plugin from a local path`,children:(0,J.jsxs)(U,{onClick:w,onContextMenu:D,endIcon:(0,J.jsx)(N,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Add`]})}),(0,J.jsx)(`input`,{id:`file-upload`,type:`file`,accept:`.tgz`,style:{display:`none`},onChange:b})]})]})]})}var Qn=(0,W.memo)(Zn),$n=()=>{let e=window;return`ontouchstart`in window||e.DocumentTouch!==void 0&&document instanceof e.DocumentTouch?(K&&console.log(`WebSocketLogs detectTouchscreen = true`),!0):(K&&console.log(`WebSocketLogs detectTouchscreen = false`),!1)};function er(){let{messages:e,logAutoScroll:t}=(0,W.useContext)(Gt),[n,r]=(0,W.useState)(!1),i=(0,W.useRef)(null),a=(0,W.useRef)(0),o=(0,W.useRef)(null),s=(0,W.useMemo)(()=>$n(),[]),c=()=>r(!0),l=()=>r(!1);(0,W.useEffect)(()=>{if(K&&console.log(`WebSocketLogs logAutoScroll: ${t.current} isHovering: ${n}`),t.current&&!n&&!s){let e=Date.now();e-a.current>=500?(K&&console.log(`WebSocketLogs auto-scroll to bottom`),a.current=e,i.current?.scrollIntoView({behavior:`smooth`,block:`end`})):(K&&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,J.jsx)(`div`,{style:{margin:`0px`,padding:`0px`},onMouseEnter:c,onMouseLeave:l,children:(0,J.jsxs)(`ul`,{style:{margin:`0px`,padding:`0px`},children:[e.map((e,t)=>(0,J.jsxs)(`li`,{style:{wordWrap:`break-word`,maxHeight:`200px`,overflow:`hidden`},children:[(0,J.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,J.jsx)(`span`,{style:{marginRight:`3px`,color:`#505050`},children:`[`+e.time+`]`}),e.name&&(0,J.jsx)(`span`,{style:{marginRight:`3px`,color:`#09516d`},children:`[`+e.name+`]`}),(0,J.jsx)(`span`,{style:{color:`var(--main-log-color)`},children:e.message})]},t)),(0,J.jsx)(`div`,{ref:i})]})})}var tr=(0,W.memo)(er);function nr(){let[e,t]=(0,W.useState)(localStorage.getItem(G.logFilterLevel)??`info`),[n,r]=(0,W.useState)(localStorage.getItem(G.logFilterSearch)??`*`),{online:i,logAutoScroll:a}=(0,W.useContext)(Y);return K&&console.log(`HomeLogs rendering...`),i?(0,J.jsxs)(Z,{style:{flex:`1 1 auto`},children:[(0,J.jsxs)(Jt,{children:[(0,J.jsx)(Q,{children:`Logs`}),(0,J.jsxs)(Q,{style:{fontWeight:`normal`,fontSize:`12px`,marginTop:`2px`},children:[`Filter: logger level "`,e,`" and search "`,n===``?`*`:n,`" Scroll: `,a.current?`auto`:`manual`]})]}),(0,J.jsx)(Qt,{style:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`10px`,alignItems:`start`},children:(0,J.jsx)(tr,{})})]}):(0,J.jsx)(qt,{})}var rr=(0,W.memo)(nr);function ir(e){return e.id!==0&&e.src===`Matterbridge`&&e.dst===`Frontend`}var ar={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},or={fontSize:`12px`,fontWeight:`normal`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},sr={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},cr={fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`,backgroundColor:`var(--div-bg-color)`},lr={fontSize:`16px`,fontWeight:`bold`,backgroundColor:`var(--div-bg-color)`},ur={padding:`0px`,margin:`0px`},dr=`5px 10px 5px 10px`,fr={},pr={},mr={},hr={},gr=[],_r=[],vr=[];function yr(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 br(e){let t=e.items;return t!==void 0&&typeof t==`object`&&!Array.isArray(t)}function xr(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 Sr=({open:e,onClose:t,plugin:n})=>{let{sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,W.useContext)(Y),s=(0,W.useRef)(o()),c=(0,W.useRef)({}),l=(0,W.useRef)({}),[u,d]=(0,W.useState)(n.configJson),[f,m]=(0,W.useState)(n.schemaJson),[g,_]=(0,W.useState)({"ui:submitButtonOptions":{submitText:`Confirm`},"ui:globalOptions":{orderable:!0}}),v=(0,W.useRef)(``),y=n.configJson;(0,W.useEffect)(()=>{let e=e=>{e.src===`Matterbridge`&&e.dst===`Frontend`&&(ir(e)&&e.id===s.current&&e.method===`/api/select/devices`&&e.response&&(K&&console.log(`ConfigPluginDialog (id: ${e.id}) received ${e.response.length} /api/select/devices:`,e.response),_r=e.response),ir(e)&&e.id===s.current&&e.method===`/api/select/entities`&&e.response&&(K&&console.log(`ConfigPluginDialog (id: ${e.id}) received ${e.response.length} /api/select/entities:`,e.response),vr=e.response))};if(i(e,s.current),K&&console.log(`ConfigPluginDialog added WebSocket listener id:`,s.current),K&&console.log(`ConfigPluginDialog mounting...`),K&&console.log(`ConfigPluginDialog mounting with form:`,u),K&&console.log(`ConfigPluginDialog mounting with schema:`,f),K&&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}}),K&&console.log(`HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:`,n.name)),()=>{a(e),K&&console.log(`ConfigPluginDialog removed WebSocket listener`)}},[i,u,n,a,f,r,g]);let b=(e,t)=>{y=e.formData},S=e=>{K&&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,m=wt in o,h=(0,W.useRef)(null);return(0,W.useEffect)(()=>{let e=v.current;!m||e===``||!/^newKey(?:-\d+)?$/.test(n)||!h.current||(K&&console.log(`WrapIfAdditionalTemplate: renaming additional property "${n}" to "${e}"`),h.current.value=e,r({target:h.current}),v.current=``)},[m,n,r]),m?(0,J.jsxs)(p,{sx:{display:`flex`,flexDirection:`row`,flexGrow:1,padding:0,margin:0,border:`none`},children:[(0,J.jsx)(V,{id:`${t}-key`,name:`${t}-key`,required:u,disabled:a||l,defaultValue:n,inputRef:h,onBlur:l?void 0:r,type:`text`,variant:`outlined`,sx:{width:`250px`,minWidth:`250px`,maxWidth:`250px`,marginRight:`20px`}}),(0,J.jsx)(p,{sx:{flex:1},children:s}),(0,J.jsx)(f,{disabled:a||l,onClick:i,registry:c})]}):(0,J.jsx)(p,{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=Ct(`WrapIfAdditionalTemplate`,s,St(c));return o?(0,J.jsx)(`div`,{style:{display:`none`},children:t}):(0,J.jsx)(p,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:(0,J.jsxs)(l,{...e,children:[r===!0&&n,t,i,a]})})}function E(e){let{description:t}=e;return t?(0,J.jsx)(I,{sx:or,children:t}):null}function O(e){let{required:t,title:n}=e;return n?(0,J.jsx)(p,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,J.jsxs)(I,{sx:ar,children:[`Title `,n,` `,t&&(0,J.jsx)(`mark`,{children:`***`})]})}):null}function k(e){let{help:t}=e;return t?(0,J.jsx)(p,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,J.jsx)(I,{sx:cr,children:t})}):null}function A(e){let{errors:t}=e;return t?(0,J.jsxs)(p,{sx:{padding:`10px`,margin:`10px`,border:`1px solid grey`},children:[(0,J.jsx)(I,{color:`error`,sx:lr,children:`Please fix the following errors:`}),(0,J.jsx)(ot,{children:t.map((e,t)=>(0,J.jsxs)(ce,{children:[(0,J.jsx)(H,{children:(0,J.jsx)(Ve,{color:`error`})}),(0,J.jsx)(R,{primary:e.stack})]},t))})]}):null}function ee(e){let{errors:t}=e;return t?(0,J.jsx)(p,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:t.map((e,t)=>(0,J.jsxs)(I,{color:`error`,variant:`body2`,sx:{marginLeft:1},children:[`This field `,e]},t))}):null}function te(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:m,onChange:h,onChangeOverride:g,onBlur:_,onFocus:v,_rawErrors:y,_hideError:b,_registry:x,_formContext:S}=e;return(0,J.jsx)(p,{sx:{padding:`0px`,margin:`0px`},children:(0,J.jsx)(V,{id:t,name:t,label:l&&l!==``?s:void 0,variant:`outlined`,placeholder:l&&l!==``?l:s,required:u,disabled:d||f,autoFocus:m,value:a||a===0?a:``,type:c,autoComplete:c===`password`?`current-password`:n,onChange:g||(({target:{value:e}})=>h(e===``?o.emptyValue:e)),onBlur:({target:e})=>_(t,e&&e.value),onFocus:({target:e})=>v(t,e&&e.value),fullWidth:!0})})}function ne(e){return console.log(`ArrayFieldTitleTemplate:`,e),null}function F(e){return console.log(`ArrayFieldDescriptionTemplate:`,e),null}function re(e){let{buttonsProps:t,children:n}=e;return(0,J.jsxs)(p,{sx:{margin:`2px 0px`,padding:`0px`,display:`flex`,alignItems:`center`},children:[(0,J.jsx)(p,{sx:{flexGrow:1,marginRight:`10px`},children:n}),(0,J.jsx)(T,{disabled:!t.hasMoveUp,onClick:t.onMoveUpItem,size:`small`,color:`primary`,sx:ur,children:(0,J.jsx)(Ee,{})}),(0,J.jsx)(T,{disabled:!t.hasMoveDown,onClick:t.onMoveDownItem,size:`small`,color:`primary`,sx:ur,children:(0,J.jsx)(ke,{})}),t.hasRemove&&(0,J.jsx)(T,{onClick:t.onRemoveItem,size:`small`,color:`primary`,sx:ur,children:(0,J.jsx)(Ae,{})})]})}function ie(e){let{canAdd:t,onAddClick:n,schema:r,title:i,formData:a}=e,[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(!1),[f,m]=(0,W.useState)(``),g=e=>{m(e.target.value)},_=()=>{K&&console.log(`ArrayFieldTemplate: handleDialogDeviceToggle filter:`,f,`selectDevices:`,_r),s(!o)},v=()=>{K&&console.log(`ArrayFieldTemplate: handleDialogEntityToggle filter:`,f,`selectEntities:`,vr),l(!c)},y=()=>{K&&console.log(`ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:`,f,`selectDevices:`,_r),d(!u)},b=e=>{s(!1),r.selectFrom===`serial`&&br(r)?r.items.default=e.serial:r.selectFrom===`name`&&br(r)&&(r.items.default=e.name),n()},S=e=>{l(!1),r.selectEntityFrom===`name`&&br(r)?r.items.default=e.name:r.selectEntityFrom===`description`&&br(r)&&(r.items.default=e.description),n()},C=e=>{d(!1),r.selectDeviceEntityFrom===`name`&&br(r)?r.items.default=e.name:r.selectDeviceEntityFrom===`description`&&br(r)&&(r.items.default=e.description),n()};return(0,J.jsxs)(p,{sx:{margin:`0px`,padding:`5px 10px 5px 10px`,border:`1px solid grey`},children:[i&&(0,J.jsxs)(p,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[i&&(0,J.jsx)(I,{sx:ar,children:i}),t&&(0,J.jsxs)(p,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[r.selectFrom&&(0,J.jsx)(z,{title:`Add a device from the list`,children:(0,J.jsx)(T,{onClick:_,size:`small`,color:`primary`,sx:ur,children:(0,J.jsx)(tt,{})})}),r.selectEntityFrom&&(0,J.jsx)(z,{title:`Add an entity from the list`,children:(0,J.jsx)(T,{onClick:v,size:`small`,color:`primary`,sx:ur,children:(0,J.jsx)(tt,{})})}),r.selectDeviceEntityFrom&&(0,J.jsx)(z,{title:`Add a device entity from the list`,children:(0,J.jsx)(T,{onClick:y,size:`small`,color:`primary`,sx:ur,children:(0,J.jsx)(tt,{})})}),(0,J.jsx)(z,{title:`Add a new item`,children:(0,J.jsx)(T,{onClick:n,size:`small`,color:`primary`,sx:ur,children:(0,J.jsx)(N,{})})})]})]}),r.description&&(0,J.jsx)(I,{sx:or,children:r.description}),e.items,(0,J.jsxs)(M,{open:o,onClose:_,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,J.jsx)(P,{children:`Select a device`}),(0,J.jsxs)(x,{children:[(0,J.jsxs)(p,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,J.jsx)(I,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,J.jsx)(V,{fullWidth:!0,variant:`outlined`,value:f,onChange:g,placeholder:`Enter serial or name`})]}),(0,J.jsx)(ot,{dense:!0,children:_r.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,J.jsxs)(h,{onClick:()=>b(e),sx:fr,children:[e.icon===`wifi`&&(0,J.jsx)(H,{children:(0,J.jsx)(j,{style:pr})}),e.icon===`ble`&&(0,J.jsx)(H,{children:(0,J.jsx)(be,{style:pr})}),e.icon===`hub`&&(0,J.jsx)(H,{children:(0,J.jsx)(qe,{style:pr})}),(0,J.jsx)(R,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:mr},secondaryTypographyProps:{style:hr}})]},t))})]}),(0,J.jsx)(D,{children:(0,J.jsx)(U,{onClick:_,children:`Close`})})]}),(0,J.jsxs)(M,{open:c,onClose:v,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,J.jsx)(P,{children:`Select an entity`}),(0,J.jsxs)(x,{children:[(0,J.jsxs)(p,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,J.jsx)(I,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,J.jsx)(V,{fullWidth:!0,variant:`outlined`,value:f,onChange:g,placeholder:`Enter name or description`})]}),(0,J.jsx)(ot,{dense:!0,children:vr.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,J.jsxs)(h,{onClick:()=>S(e),sx:fr,children:[e.icon===`wifi`&&(0,J.jsx)(H,{children:(0,J.jsx)(j,{style:pr})}),e.icon===`ble`&&(0,J.jsx)(H,{children:(0,J.jsx)(be,{style:pr})}),e.icon===`hub`&&(0,J.jsx)(H,{children:(0,J.jsx)(qe,{style:pr})}),e.icon===`component`&&(0,J.jsx)(H,{children:(0,J.jsx)(ze,{style:pr})}),e.icon===`matter`&&(0,J.jsx)(H,{children:(0,J.jsx)(je,{style:pr})}),(0,J.jsx)(R,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:mr},secondaryTypographyProps:{style:hr}})]},t))})]}),(0,J.jsx)(D,{children:(0,J.jsx)(U,{onClick:v,children:`Close`})})]}),(0,J.jsxs)(M,{open:u,onClose:y,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,J.jsxs)(P,{children:[`Select an entity for `,i]}),(0,J.jsx)(x,{children:(0,J.jsx)(ot,{dense:!0,children:_r.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,J.jsxs)(h,{onClick:()=>C(e),sx:fr,children:[e.icon===`wifi`&&(0,J.jsx)(H,{children:(0,J.jsx)(j,{style:pr})}),e.icon===`ble`&&(0,J.jsx)(H,{children:(0,J.jsx)(be,{style:pr})}),e.icon===`hub`&&(0,J.jsx)(H,{children:(0,J.jsx)(qe,{style:pr})}),e.icon===`component`&&(0,J.jsx)(H,{children:(0,J.jsx)(ze,{style:pr})}),e.icon===`matter`&&(0,J.jsx)(H,{children:(0,J.jsx)(je,{style:pr})}),(0,J.jsx)(R,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:mr},secondaryTypographyProps:{style:hr}})]},t)))})}),(0,J.jsx)(D,{children:(0,J.jsx)(U,{onClick:y,children:`Close`})})]})]})}function ae(e){let{onAddProperty:t,schema:n,properties:r,title:i,description:a}=e,[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(``),u=e=>{l(e.target.value)},d=()=>{s(!o)},f=e=>{K&&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,K&&console.log(`ObjectFieldTemplate: handleSelectValue pendingAdditionalPropertyKey "${r}"`),t()},m=()=>{t()},g=!n.additionalProperties;return K&&console.log(`ObjectFieldTemplate: isRoot ${g} pendingAdditionalPropertyKey "${v.current}"`),(0,J.jsxs)(p,{sx:{margin:`0px`,padding:g?`10px`:`5px 10px 0px 10px`,border:g?`none`:`1px solid grey`},children:[n.title&&g&&(0,J.jsx)(p,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,J.jsx)(I,{sx:ar,children:n.title})}),i&&!g&&(0,J.jsxs)(p,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[(0,J.jsx)(I,{sx:ar,children:i}),(0,J.jsxs)(p,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[n.selectFrom&&(0,J.jsx)(z,{title:`Add a device from the list`,children:(0,J.jsx)(T,{onClick:d,size:`small`,color:`primary`,sx:ur,children:(0,J.jsx)(tt,{})})}),(0,J.jsx)(z,{title:`Add a new item`,children:(0,J.jsx)(T,{onClick:m,size:`small`,color:`primary`,sx:ur,children:(0,J.jsx)(N,{})})})]})]}),n.description&&(0,J.jsx)(p,{sx:{padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,J.jsx)(I,{sx:or,children:n.description})}),r.map(({content:e,name:t,hidden:r})=>{if(r)return null;let i=yr(n,t),a=xr(n,t),o=i&&[`object`,`array`].includes(n.properties[t].type);return(0,J.jsxs)(p,{sx:{margin:`0px`,marginBottom:`10px`,padding:o&&!a?`0px`:dr,border:o&&!a?`none`:`1px solid grey`},children:[i&&![`object`,`array`,`boolean`].includes(n.properties[t].type)&&(0,J.jsx)(I,{sx:ar,children:n.properties[t].title||t}),a&&(0,J.jsx)(I,{sx:ar,children:n.properties[t].title||t}),(0,J.jsx)(p,{sx:{flexGrow:1,padding:`0px`,margin:`0px`},children:e})]},t)}),(0,J.jsxs)(M,{open:o,onClose:d,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,J.jsx)(P,{children:`Select a device`}),(0,J.jsxs)(x,{children:[(0,J.jsxs)(p,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,J.jsx)(I,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,J.jsx)(V,{fullWidth:!0,variant:`outlined`,value:c,onChange:u,placeholder:`Enter serial or name`})]}),(0,J.jsx)(ot,{dense:!0,children:_r.filter(e=>e.serial.toLowerCase().includes(c.toLowerCase())||e.name.toLowerCase().includes(c.toLowerCase())).map((e,t)=>(0,J.jsxs)(h,{onClick:()=>f(e),sx:fr,children:[e.icon===`wifi`&&(0,J.jsx)(H,{children:(0,J.jsx)(j,{style:pr})}),e.icon===`ble`&&(0,J.jsx)(H,{children:(0,J.jsx)(be,{style:pr})}),e.icon===`hub`&&(0,J.jsx)(H,{children:(0,J.jsx)(qe,{style:pr})}),(0,J.jsx)(R,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:mr},secondaryTypographyProps:{style:hr}})]},t))})]}),(0,J.jsx)(D,{children:(0,J.jsx)(U,{onClick:d,children:`Close`})})]})]})}function se(e){let{uiSchema:n}=e,{submitText:r,norender:i}=xt(n);return i?null:(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,margin:`10px`,padding:`0px`,gap:`20px`},children:[(0,J.jsx)(U,{type:`submit`,variant:`contained`,color:`primary`,children:r}),(0,J.jsx)(U,{variant:`contained`,color:`primary`,onClick:t,children:`Cancel`})]})}function le(e){let{className:t,disabled:n,onClick:r,registry:i,style:a,uiSchema:o,...s}=e;return(0,J.jsx)(z,{title:`Remove the item`,children:(0,J.jsx)(T,{disabled:n,size:`small`,color:`primary`,onClick:r,children:(0,J.jsx)(Ae,{})})})}function ue(e){let{className:t,disabled:n,onClick:r,registry:i,uiSchema:a,...o}=e;return(0,J.jsx)(z,{title:`Add an item`,children:(0,J.jsx)(T,{size:`small`,color:`primary`,onClick:r,children:(0,J.jsx)(N,{})})})}function de(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,J.jsx)(z,{title:`Move up the item`,children:(0,J.jsx)(T,{size:`small`,color:`primary`,onClick:n,children:(0,J.jsx)(Ee,{})})})}function fe(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,J.jsx)(z,{title:`Move down the item`,children:(0,J.jsx)(T,{size:`small`,color:`primary`,onClick:n,children:(0,J.jsx)(ke,{})})})}function pe(e){let{id:i,name:a,value:o,schema:c,readonly:l,onChange:d}=e,[f,m]=(0,W.useState)(),h=e=>{K&&console.log(`CheckboxWidget ${a} onChangeField:`,e),m(e&&e!==``?e:void 0)},g=()=>{K&&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,J.jsxs)(p,{sx:{margin:`0px`,padding:`5px 0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,J.jsx)(I,{sx:sr,children:c.title||c.description}),(0,J.jsx)(U,{variant:`contained`,color:`primary`,onClick:()=>g(),children:c.buttonText})]}):c.buttonField&&(c.title||c.description)?(0,J.jsxs)(p,{sx:{margin:`0px`,padding:`5px 0px`,gap:`20px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,J.jsx)(I,{sx:sr,children:c.title||c.description}),(0,J.jsx)(V,{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,J.jsx)(U,{id:a+`-button`,variant:`contained`,color:`primary`,disabled:f===void 0,onClick:()=>g(),children:c.buttonField})]}):(0,J.jsxs)(p,{sx:{margin:`0px`,padding:`0px`},children:[a&&(0,J.jsxs)(p,{sx:{margin:`0px`,padding:`0px`,gap:`10px`,display:`flex`,justifyContent:`flex-start`,alignItems:`center`},children:[(0,J.jsx)(I,{sx:ar,children:c.title||a}),(0,J.jsx)(oe,{checked:o,readOnly:l,onChange:()=>d(!o),sx:{padding:`0px`,margin:`0px`}})]}),c.description&&(0,J.jsx)(I,{sx:or,children:c.description})]})}function me({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:_=gr,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(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,J.jsx)(V,{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,J.jsxs)(B,{value:String(n),disabled:r,children:[d&&(0,J.jsx)(H,{sx:{minWidth:`32px`},children:(0,J.jsx)(oe,{checked:i,disableRipple:!0,tabIndex:-1,sx:{padding:`0px`,margin:`0px`}})}),t]},n)})})}return K&&console.log(`ConfigPluginDialog rendering...`),!e||!f||!u?null:(0,J.jsxs)(M,{open:e,onClose:t,slotProps:{paper:{sx:{maxWidth:`800px`}}},children:[(0,J.jsx)(P,{gap:`20px`,children:(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,J.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,J.jsx)(`h3`,{children:`Matterbridge plugin configuration`})]})}),(0,J.jsx)(x,{style:{padding:`0px`,margin:`0px`,width:`800px`,height:`600px`,overflow:`auto`},children:(0,J.jsx)(kt,{schema:f,formData:u,uiSchema:g,validator:Tt,templates:{FieldTemplate:w,BaseInputTemplate:te,TitleFieldTemplate:O,DescriptionFieldTemplate:E,FieldHelpTemplate:k,FieldErrorTemplate:ee,ErrorListTemplate:A,WrapIfAdditionalTemplate:C,ArrayFieldTitleTemplate:ne,ArrayFieldDescriptionTemplate:F,ArrayFieldItemTemplate:re,ArrayFieldTemplate:ie,ObjectFieldTemplate:ae,ButtonTemplates:{SubmitButton:se,RemoveButton:le,AddButton:ue,MoveUpButton:de,MoveDownButton:fe}},widgets:{CheckboxWidget:pe,SelectWidget:me},onChange:b,onSubmit:S})})]})};function Cr({status:e,enabledText:t=`Enabled`,disabledText:n,tooltipText:r}){if(e===void 0)return null;{let i=(0,J.jsx)(`div`,{className:e?`status-enabled`:`status-disabled`,style:{cursor:`default`},children:e?t:n??t});return r===void 0?i:(0,J.jsx)(z,{title:r,children:i})}}function wr({storeId:e,setStoreId:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,W.useContext)(Y),{mobile:s,showConfirmCancelDialog:c}=(0,W.useContext)(Wt),l=(0,W.useRef)(o()),[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(null),[h,_]=(0,W.useState)([]),[y,b]=(0,W.useState)(null),[S,C]=(0,W.useState)(`inactive`),w=[{label:`Name`,id:`name`,required:!0,render:(e,t,n,r)=>(0,J.jsx)(z,{title:`Plugin path ${n.path}`,children:(0,J.jsx)(`button`,{type:`button`,style:{cursor:`pointer`,background:`none`,border:`none`,padding:0,font:`inherit`,color:`inherit`,textAlign:`left`},onClick:()=>F(n),children:n.name})})},{label:`Description`,id:`description`,render:(e,t,n,r)=>(0,J.jsx)(z,{title:`Open the plugin homepage`,children:(0,J.jsx)(`button`,{type:`button`,style:{cursor:`pointer`,background:`none`,border:`none`,padding:0,font:`inherit`,color:`inherit`,textAlign:`left`},onClick:()=>F(n),children:n.description})})},{label:`Version`,id:`version`,render:(e,t,n,r)=>(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(z,{title:`Plugin v.${n.version}`,children:(0,J.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,J.jsx)(J.Fragment,{children:n.author?n.author.replace(`https://github.com/`,``):`Unknown`})},{label:`Type`,id:`type`,render:(e,t,n,r)=>(0,J.jsx)(J.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,J.jsxs)(`div`,{style:{margin:`0px`,padding:`0px`,gap:`4px`,display:`flex`,flexDirection:`row`},children:[f&&f.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,J.jsx)(z,{title:`Shows the QRCode or the fabrics`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,J.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:In(r.matter)},onClick:()=>{r.matter?.id&&t(r.matter?.id)},size:`small`,children:(0,J.jsx)(te,{})})}),f&&f.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,J.jsx)(z,{title:`Restart the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,J.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`},onClick:()=>P(r),size:`small`,children:(0,J.jsx)(st,{})})}),(0,J.jsx)(z,{title:`Plugin config`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,J.jsx)(T,{disabled:r.restartRequired===!0,style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>fe(r),size:`small`,children:(0,J.jsx)(Ce,{})})}),f&&!f.readOnly&&(0,J.jsx)(z,{title:`Remove the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,J.jsx)(T,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{O(`Remove plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`remove`,r)},size:`small`,children:(0,J.jsx)(Fe,{})})}),r.enabled?(0,J.jsx)(z,{title:`Disable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,J.jsx)(T,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{O(`Disable plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`disable`,r)},size:`small`,children:(0,J.jsx)(rt,{})})}):(0,J.jsx)(J.Fragment,{}),r.enabled?(0,J.jsx)(J.Fragment,{}):(0,J.jsx)(z,{title:`Enable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,J.jsx)(T,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>ne(r),size:`small`,children:(0,J.jsx)(se,{})})}),(0,J.jsx)(z,{title:`Open the plugin help`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,J.jsx)(T,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>I(r),size:`small`,children:(0,J.jsx)(g,{})})}),(0,J.jsx)(z,{title:`Open the plugin version history`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,J.jsx)(T,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>ie(r),size:`small`,children:(0,J.jsx)(v,{})})}),r.enabled&&r.frontendPath&&(0,J.jsx)(z,{title:`Open the plugin frontend`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,J.jsx)(T,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>ae(r),size:`small`,children:(0,J.jsx)(m,{})})}),r.latestVersion!==void 0&&r.latestVersion!==r.version&&f&&!f.readOnly&&(0,J.jsx)(z,{title:`Update the plugin to the latest version v.${r.latestVersion}`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,J.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>j(r),size:`small`,children:(0,J.jsx)(ct,{})})}),(r.version.includes(`-dev-`)||r.version.includes(`-git-`))&&r.devVersion!==void 0&&r.devVersion!==r.version&&f&&!f.readOnly&&(0,J.jsx)(z,{title:`Update the plugin to the latest dev version v.${r.devVersion}`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,J.jsx)(T,{style:{color:`var(--secondary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>N(r),size:`small`,children:(0,J.jsx)(ct,{})})}),f&&!f.readOnly&&(0,J.jsx)(z,{title:`Sponsor the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,J.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`#b6409c`},onClick:()=>re(r),size:`small`,children:(0,J.jsx)(at,{})})})]})},{label:`Status`,id:`status`,required:!0,noSort:!0,render:(e,t,n,r)=>(0,J.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,J.jsx)(J.Fragment,{children:(0,J.jsx)(Cr,{status:!1,enabledText:`Error`,disabledText:`Error`,tooltipText:`The plugin is in error state. Check the log!`})}):(0,J.jsx)(J.Fragment,{children:n.enabled?(0,J.jsx)(J.Fragment,{children:n.loaded&&n.started&&n.configured?(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(Cr,{status:n.loaded,enabledText:`Running`,tooltipText:`Whether the plugin is running`})}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Cr,{status:n.loaded,enabledText:`Loaded`,tooltipText:`Whether the plugin has been loaded`}),(0,J.jsx)(Cr,{status:n.started,enabledText:`Started`,tooltipText:`Whether the plugin started`}),(0,J.jsx)(Cr,{status:n.configured,enabledText:`Configured`,tooltipText:`Whether the plugin has been configured`})]})}):(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(Cr,{status:n.enabled,enabledText:`Enabled`,disabledText:`Disabled`,tooltipText:`Whether the plugin is enable or disabled`})})})})}];(0,W.useEffect)(()=>{let e=e=>{K&&console.log(`HomePlugins received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`plugins`?e.response.lock?(K&&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))):(K&&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`?(K&&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 K&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and matter id ${e.response.matter?.id} not found`),t;K&&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`?(K&&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.method===`plugin_update_required`?(K&&console.log(`HomePlugins received plugin_update_required`,e.response),_(t=>t.map(t=>t.name===e.response.plugin?e.response.devVersion?{...t,devVersion:e.response.version}:{...t,latestVersion:e.response.version}:t))):e.method===`plugin_status_update`?(K&&console.log(`HomePlugins received plugin_status_update`,e.response),_(t=>t.map(t=>t.name===e.response.plugin?{...t,...e.response.status}:t))):e.method===`matterbridge_status_update`&&(K&&console.log(`HomePlugins received matterbridge_status_update: ${e.response.status}`),C(e.response.status)),e.id===l.current&&e.method===`/api/settings`?(K&&console.log(`HomePlugins (id: ${e.id}) received settings:`,e.response),d(e.response.systemInformation),p(e.response.matterbridgeInformation),C(e.response.matterbridgeInformation.bridgeStatus)):e.id===l.current&&e.method===`/api/plugins`&&(K&&console.log(`HomePlugins (id: ${e.id}) received ${e.response.length} plugins:`,e.response),_(e.response))};return i(e,l.current),K&&console.log(`HomePlugins added WebSocket listener id:`,l.current),()=>{a(e),K&&console.log(`HomePlugins removed WebSocket listener`)}},[i,a,r]),(0,W.useEffect)(()=>{n&&(K&&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 E=(0,W.useRef)(null),O=(e,t,n,r)=>{K&&console.log(`handleActionWithConfirmCancel ${n} ${r.name}`),E.current=r,c(e,t,n,k,A)},k=e=>{K&&console.log(`handleConfirm action confirmed ${e} ${E.current?.name}`),e===`remove`&&E.current?ee(E.current):e===`disable`&&E.current&&ne(E.current),E.current=null},A=e=>{K&&console.log(`handleCancel action canceled ${e} ${E.current?.name}`),E.current=null},j=e=>{K&&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}})},N=e=>{K&&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}})},ee=e=>{K&&console.log(`handleRemovePlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/removeplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},P=e=>{K&&console.log(`handleRestartPlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/restartplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},ne=e=>{K&&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}}))},F=e=>{K&&console.log(`handleHomepagePlugin plugin: ${e.name} homepage: ${e.homepage}`),e.homepage&&window.open(e.homepage,`_blank`)},re=e=>{K&&console.log(`handleSponsorPlugin plugin:`,e.name,`funding:`,e.funding),e.funding&&window.open(e.funding,`_blank`)},I=e=>{K&&console.log(`handleHelpPlugin plugin:`,e.name,`help:`,e.help),e.help&&window.open(e.help,`_blank`)},ie=e=>{K&&console.log(`handleChangelogPlugin plugin:`,e.name,`changelog:`,e.changelog),e.changelog&&window.open(e.changelog,`_blank`)},ae=e=>{let t=`${Vt}plugins/${e.name}/`;console.log(`handleFrontendPlugin plugin:`,e.name,`basePath:`,Vt,`frontendPath:`,e.frontendPath,`computed pluginFrontendPath:`,t),e.frontendPath&&b({name:e.name,path:t})},oe=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)(Kt,{})}var Rn=(0,G.memo)(Ln),zn=[`matterbridge-`,`matterbridge-plugin-template`,`matterbridge-dyson`,`matterbridge-tuya`,`matterbridge-matter`,`matterbridge-automations`,`matterbridge-securitysystem`,`matterbridge-adapter`],Bn=e=>e.replace(`git+`,``).replace(`.git`,``).trim(),Vn=e=>{let t=Bn(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},Hn=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},Un=()=>{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{}}},Wn=e=>{try{window.localStorage.setItem(K.searchPluginsTotal,JSON.stringify(e))}catch{}},Gn=()=>{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{}}},Kn=e=>{try{window.localStorage.setItem(K.searchPluginsMeta,JSON.stringify(e))}catch{}},qn=()=>{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{}}},Jn=e=>{try{window.localStorage.setItem(K.searchPluginsVersions,JSON.stringify(e))}catch{}},Yn=({open:e,onClose:t,onSelect:n,onVersions:r})=>{let{mobile:i}=(0,G.useContext)(Ut),[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},Jn(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=qn(),(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=>!zn.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=Un(),h=Gn(),g=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}});d(g);let _=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 (${_.length.toString()}):`,_);let v=0,b=async()=>{for(;v<_.length;){if(t.signal.aborted)return;let e=v;v+=1;let r=_[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)},()=>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}),C=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`)?Bn(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=Hn(i.repository),l=c?Vn(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,O=async()=>{for(;D<x.length;){if(t.signal.aborted)return;let e=D;D+=1;let r=x[e];if(!r||!C.has(r))continue;C.delete(r);let i=u.find(e=>e.name===r)?.homepage??null,a=await T(r,i);if(t.signal.aborted)return;a&&(d(e=>e.map(e=>e.name===r?{...e,homepage:a.homepage??e.homepage,help:a.help,changelog:a.changelog}:e)),h[r]={homepage:a.homepage,help:a.help,changelog:a.changelog,asOf:f},Kn(h)),t.signal.aborted||await n(250)}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>O()));let j=`2020-01-01`,M=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}),N=new Set(M),ee=M.length;S({done:0,total:ee}),y(ee>0);let te=async e=>{let i=`https://api.npmjs.org/downloads/range/${j}:${f}/${encodeURIComponent(e)}`;for(let e=0;e<3;e+=1){let a=await fetch(i,{signal:t.signal});if(a.ok){let e=await a.json();return r(e)}if(a.status===404)return null;if(a.status===429){let t=a.headers.get(`retry-after`),r=t?Number(t):NaN,i=Number.isFinite(r)?r*1e3:2e3*(e+1);await n(i);continue}return null}return null},P=0,ne=0,F=async()=>{for(;P<M.length;){if(t.signal.aborted)return;let e=P;P+=1;let r=M[e];if(r&&N.has(r)){N.delete(r);try{q&&console.log(`[SearchPluginsDialog] fetching total downloads for ${r} (range ${j}:${f})...`);let e=await te(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},Wn(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{ne+=1,S({done:ne,total:ee}),t.signal.aborted||await n(500)}}}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>F())).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=k(new Date),i=await A(e,t);q&&console.log(`[SearchPluginsDialog] passing versions to onVersions() for ${e} (${i.length.toString()}):`,i),r(i),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)}},ee=()=>{O(),t(),r([])},te=u.reduce((e,t)=>e+(typeof t.downloads==`number`?t.downloads:0),0),ne=u.reduce((e,t)=>(typeof t.total==`number`&&(e.total+=t.total,e.hasAny=!0),e),{total:0,hasAny:!1}),F=_?` Totals: ${b.done.toString()}/${b.total.toString()} fetched`:``,re=ne.hasAny?j(ne.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)(P,{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)(I,{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)(Cn,{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(te)} / ${re}${F}`,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:ee,children:`Cancel`})})]})]})};function Xn(){let{mobile:e,showSnackbarMessage:t}=(0,G.useContext)(Ut),{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=(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(zn.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(zn.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)},ee=e=>{c(e),d(e.includes(`latest`)?`latest`:e[0]??``),q&&console.log(`Select plugin versions:`,e)},[te,P]=(0,G.useState)(!1);return q&&console.log(`HomeInstallAddPlugins rendering...`),te?null:(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(qt,{children:[(0,Y.jsx)(Jt,{children:`Install plugins`}),(0,Y.jsx)($t,{close:()=>P(!0)})]}),(0,Y.jsxs)(Qt,{onDragOver:_,onDragLeave:v,onDrop:y,style:J&&e?{flexWrap:`wrap`,alignItems:`center`,gap:`10px`}:{flexWrap:`wrap`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(Yn,{open:O,onClose:j,onSelect:M,onVersions:ee}),(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)(R,{labelId:`plugin-version-label`,id:`plugin-version`,value:l,label:`Tag or version`,onChange:e=>d(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)(ne,{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 Zn=(0,G.memo)(Xn),Qn=()=>{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 $n(){let{messages:e,logAutoScroll:t}=(0,G.useContext)(Wt),[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)(()=>Qn(),[]),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 er=(0,G.memo)($n);function tr(){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)(qt,{children:[(0,Y.jsx)(Jt,{children:`Logs`}),(0,Y.jsxs)(Jt,{style:{fontWeight:`normal`,fontSize:`12px`,marginTop:`2px`},children:[`Filter: logger level "`,e,`" and search "`,n===``?`*`:n,`" Scroll: `,a.current?`auto`:`manual`]})]}),(0,Y.jsx)(Qt,{style:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`10px`,alignItems:`start`},children:(0,Y.jsx)(er,{})})]}):(0,Y.jsx)(Kt,{})}var nr=(0,G.memo)(tr);function rr(e){return e.id!==0&&e.src===`Matterbridge`&&e.dst===`Frontend`}var ir={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},ar={fontSize:`12px`,fontWeight:`normal`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},or={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},sr={fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`,backgroundColor:`var(--div-bg-color)`},cr={fontSize:`16px`,fontWeight:`bold`,backgroundColor:`var(--div-bg-color)`},lr={padding:`0px`,margin:`0px`},ur=`5px 10px 5px 10px`,dr={},fr={},pr={},mr={},hr=[],gr=[],_r=[];function vr(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 yr(e){let t=e.items;return t!==void 0&&typeof t==`object`&&!Array.isArray(t)}function br(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 xr=({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`&&(rr(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),gr=e.response),rr(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),_r=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:ar,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:ir,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:sr,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:cr,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 ee(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 te(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 ne(e){return console.log(`ArrayFieldTitleTemplate:`,e),null}function F(e){return console.log(`ArrayFieldDescriptionTemplate:`,e),null}function re(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:lr,children:(0,Y.jsx)(Te,{})}),(0,Y.jsx)(T,{disabled:!t.hasMoveDown,onClick:t.onMoveDownItem,size:`small`,color:`primary`,sx:lr,children:(0,Y.jsx)(Oe,{})}),t.hasRemove&&(0,Y.jsx)(T,{onClick:t.onRemoveItem,size:`small`,color:`primary`,sx:lr,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:`,gr),s(!o)},v=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogEntityToggle filter:`,f,`selectEntities:`,_r),l(!c)},y=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:`,f,`selectDevices:`,gr),d(!u)},b=e=>{s(!1),r.selectFrom===`serial`&&yr(r)?r.items.default=e.serial:r.selectFrom===`name`&&yr(r)&&(r.items.default=e.name),n()},S=e=>{l(!1),r.selectEntityFrom===`name`&&yr(r)?r.items.default=e.name:r.selectEntityFrom===`description`&&yr(r)&&(r.items.default=e.description),n()},C=e=>{d(!1),r.selectDeviceEntityFrom===`name`&&yr(r)?r.items.default=e.name:r.selectDeviceEntityFrom===`description`&&yr(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:ir,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:lr,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:lr,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:lr,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:lr,children:(0,Y.jsx)(N,{})})})]})]}),r.description&&(0,Y.jsx)(p,{sx:ar,children:r.description}),e.items,(0,Y.jsxs)(D,{open:o,onClose:_,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsx)(P,{children:`Select a device`}),(0,Y.jsxs)(I,{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:gr.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:dr,children:[e.icon===`wifi`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(j,{style:fr})}),e.icon===`ble`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(ye,{style:fr})}),e.icon===`hub`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ke,{style:fr})}),(0,Y.jsx)(z,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:pr},secondaryTypographyProps:{style:mr}})]},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)(P,{children:`Select an entity`}),(0,Y.jsxs)(I,{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:_r.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:dr,children:[e.icon===`wifi`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(j,{style:fr})}),e.icon===`ble`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(ye,{style:fr})}),e.icon===`hub`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ke,{style:fr})}),e.icon===`component`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Re,{style:fr})}),e.icon===`matter`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ae,{style:fr})}),(0,Y.jsx)(z,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:pr},secondaryTypographyProps:{style:mr}})]},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)(P,{children:[`Select an entity for `,i]}),(0,Y.jsx)(I,{children:(0,Y.jsx)(at,{dense:!0,children:gr.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:dr,children:[e.icon===`wifi`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(j,{style:fr})}),e.icon===`ble`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(ye,{style:fr})}),e.icon===`hub`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ke,{style:fr})}),e.icon===`component`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Re,{style:fr})}),e.icon===`matter`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ae,{style:fr})}),(0,Y.jsx)(z,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:pr},secondaryTypographyProps:{style:mr}})]},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:ir,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:ir,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:lr,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:lr,children:(0,Y.jsx)(N,{})})})]})]}),n.description&&(0,Y.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,Y.jsx)(p,{sx:ar,children:n.description})}),r.map(({content:e,name:t,hidden:r})=>{if(r)return null;let i=vr(n,t),a=br(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`:ur,border:o&&!a?`none`:`1px solid grey`},children:[i&&![`object`,`array`,`boolean`].includes(n.properties[t].type)&&(0,Y.jsx)(p,{sx:ir,children:n.properties[t].title||t}),a&&(0,Y.jsx)(p,{sx:ir,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)(P,{children:`Select a device`}),(0,Y.jsxs)(I,{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:gr.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:dr,children:[e.icon===`wifi`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(j,{style:fr})}),e.icon===`ble`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(ye,{style:fr})}),e.icon===`hub`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ke,{style:fr})}),(0,Y.jsx)(z,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:pr},secondaryTypographyProps:{style:mr}})]},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:or,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:or,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:ir,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:ar,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:_=hr,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)(P,{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)(I,{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:te,TitleFieldTemplate:O,DescriptionFieldTemplate:E,FieldHelpTemplate:k,FieldErrorTemplate:ee,ErrorListTemplate:A,WrapIfAdditionalTemplate:C,ArrayFieldTitleTemplate:ne,ArrayFieldDescriptionTemplate:F,ArrayFieldItemTemplate:re,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 Sr({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 Cr({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)(Ut),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,C]=(0,G.useState)(`inactive`),w=[{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:()=>ne(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:()=>ne(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:Fn(r.matter)},onClick:()=>{r.matter?.id&&t(r.matter?.id)},size:`small`,children:(0,Y.jsx)(te,{})})}),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:()=>ee(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:()=>fe(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:()=>{O(`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:()=>{O(`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:()=>P(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:()=>re(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:()=>ie(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:()=>ae(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:()=>j(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:()=>M(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)(Sr,{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)(Sr,{status:n.loaded,enabledText:`Running`,tooltipText:`Whether the plugin is running`})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Sr,{status:n.loaded,enabledText:`Loaded`,tooltipText:`Whether the plugin has been loaded`}),(0,Y.jsx)(Sr,{status:n.started,enabledText:`Started`,tooltipText:`Whether the plugin started`}),(0,Y.jsx)(Sr,{status:n.configured,enabledText:`Configured`,tooltipText:`Whether the plugin has been configured`})]})}):(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(Sr,{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.method===`plugin_update_required`?(q&&console.log(`HomePlugins received plugin_update_required`,e.response),_(t=>t.map(t=>t.name===e.response.plugin?e.response.devVersion?{...t,devVersion:e.response.version}:{...t,latestVersion:e.response.version}:t))):e.method===`plugin_status_update`?(q&&console.log(`HomePlugins received plugin_status_update`,e.response),_(t=>t.map(t=>t.name===e.response.plugin?{...t,...e.response.status}:t))):e.method===`matterbridge_status_update`&&(q&&console.log(`HomePlugins received matterbridge_status_update: ${e.response.status}`),C(e.response.status)),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),C(e.response.matterbridgeInformation.bridgeStatus)):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 E=(0,G.useRef)(null),O=(e,t,n,r)=>{q&&console.log(`handleActionWithConfirmCancel ${n} ${r.name}`),E.current=r,c(e,t,n,k,A)},k=e=>{q&&console.log(`handleConfirm action confirmed ${e} ${E.current?.name}`),e===`remove`&&E.current?N(E.current):e===`disable`&&E.current&&P(E.current),E.current=null},A=e=>{q&&console.log(`handleCancel action canceled ${e} ${E.current?.name}`),E.current=null},j=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}})},M=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}})},N=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}})},ee=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}})},P=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}}))},ne=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`)},re=e=>{q&&console.log(`handleHelpPlugin plugin:`,e.name,`help:`,e.help),e.help&&window.open(e.help,`_blank`)},ie=e=>{q&&console.log(`handleChangelogPlugin plugin:`,e.name,`changelog:`,e.changelog),e.changelog&&window.open(e.changelog,`_blank`)},ae=e=>{let t=`${Bt}plugins/${e.name}/`;console.log(`handleFrontendPlugin plugin:`,e.name,`basePath:`,Bt,`frontendPath:`,e.frontendPath,`computed pluginFrontendPath:`,t),e.frontendPath&&b({name:e.name,path:t})},se=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=`
|
|
23
23
|
html,
|
|
24
24
|
body {
|
|
25
25
|
background-color: ${i};
|
|
@@ -39,6 +39,6 @@ import{a as e}from"./rolldown-runtime.js";import{c as t}from"./vendor_emotion.js
|
|
|
39
39
|
::-webkit-scrollbar-track {
|
|
40
40
|
background: ${i};
|
|
41
41
|
}
|
|
42
|
-
`,t.head.appendChild(a)},[ce,le]=(0,W.useState)(),[ue,de]=(0,W.useState)(!1),fe=e=>{K&&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}}),le(e),pe()},pe=()=>{de(!0)};return K&&console.log(`HomePlugins rendering...`),n?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Z,{children:[ce&&(0,J.jsx)(Sr,{open:ue,onClose:()=>{de(!1)},plugin:ce}),(0,J.jsx)(wn,{name:`Plugins`,columns:w,rows:h,footerRight:``,footerLeft:``})]}),(0,J.jsxs)(M,{open:y!==null,onClose:()=>b(null),slotProps:{paper:{sx:{width:q&&s?`100vw`:`75vw`,height:q&&s?`100vh`:`75vh`,maxWidth:q&&s?`100vw`:`75vw`,maxHeight:q&&s?`100vh`:`75vh`,margin:q&&s?`0px`:void 0,display:`flex`,flexDirection:`column`,overflow:`hidden`,backgroundColor:`var(--div-bg-color)`}}},children:[(0,J.jsx)(x,{style:{display:`flex`,flex:`1 1 auto`,minHeight:0,padding:`0px`,margin:`0px`,overflow:`hidden`,backgroundColor:`var(--div-bg-color)`},children:y&&(0,J.jsx)(`iframe`,{title:`${y.name} frontend`,src:y.path,onLoad:oe,style:{display:`block`,flex:`1 1 auto`,width:`100%`,height:`100%`,border:`none`,backgroundColor:`var(--div-bg-color)`}})}),(0,J.jsx)(D,{sx:{flex:`0 0 auto`,justifyContent:`center`},children:(0,J.jsx)(U,{onClick:()=>b(null),children:`Close`})})]})]}):(0,J.jsx)(qt,{})}var Tr=(0,W.memo)(wr);function Er({version:e,changelog:t}){let{online:n}=(0,W.useContext)(Y);return K&&console.log(`HomeShowChangelog rendering...`),n?(0,J.jsxs)(Z,{children:[(0,J.jsx)(Jt,{children:(0,J.jsx)(Q,{children:`Matterbridge Update`})}),(0,J.jsxs)(Qt,{style:{flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`},children:[(0,J.jsxs)(`h4`,{style:{margin:0},children:[`Matterbridge has been updated to version `,e,`.`]}),(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:`10px`},children:[(0,J.jsx)(U,{onClick:()=>window.open(`https://github.com/Luligu/matterbridge`,`_blank`),endIcon:(0,J.jsx)(Ze,{style:{color:`#FFD700`}}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Star`}),(0,J.jsx)(U,{onClick:()=>window.open(`https://www.buymeacoffee.com/luligugithub`,`_blank`),endIcon:(0,J.jsx)(at,{style:{color:`#b6409c`}}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Sponsor`}),(0,J.jsx)(U,{onClick:()=>window.open(t,`_blank`),endIcon:(0,J.jsx)(v,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Changelog`}),(0,J.jsx)(U,{onClick:()=>window.location.reload(),endIcon:(0,J.jsx)(we,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Close`})]})]})]}):(0,J.jsx)(qt,{})}var Dr=(0,W.memo)(Er);function Or({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,J.jsx)(`span`,{children:n}):(0,J.jsx)(z,{title:e,placement:`top`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[0,12]}}]}},children:(0,J.jsx)(`span`,{children:n})})}var kr=new Map([[`matterbridgeVersion`,`Matterbridge version`],[`frontendVersion`,`Frontend version`],[`dockerVersion`,`Docker version`],[`homeDirectory`,`Home`],[`rootDirectory`,`Root`],[`matterbridgeDirectory`,`Storage`],[`matterbridgeCertDirectory`,`Cert`],[`matterbridgePluginDirectory`,`Plugins`],[`globalModulesDirectory`,`Modules`],[`bridgeMode`,`Bridge mode`],[`restartMode`,`Restart mode`],[`virtualMode`,`Virtual mode`],[`bridgeStatus`,`Bridge status`],[`profile`,`Profile`],[`loggerLevel`,`Logger level`],[`fileLogger`,`File logger`],[`matterLoggerLevel`,`Matter logger level`],[`matterFileLogger`,`Matter file logger`],[`restartRequired`,`Restart required`],[`updateRequired`,`Update required`]]),Ar=new Set([`matterbridgeLatestVersion`,`matterbridgeDevVersion`,`dockerDev`,`dockerLatestVersion`,`dockerDevVersion`,`fixedRestartRequired`,`matterMdnsInterface`,`matterIpv4Address`,`matterIpv6Address`,`readOnly`,`shellyBoard`,`shellySysUpdate`,`shellyMainUpdate`,`matterPort`,`matterDiscriminator`,`matterPasscode`]);function jr({matterbridgeInfo:e}){let{mobile:t}=(0,W.useContext)(Wt);K&&console.log(`MatterbridgeInfoTable:`,e);let[n,r]=(0,W.useState)(!1);return!e||n?null:(K&&console.log(`MatterbridgeInfoTable rendering...`),(0,J.jsxs)(Z,{style:q&&t?{flex:`1 1 300px`}:{flex:`0 1 auto`,width:`302px`,minWidth:`302px`},children:[(0,J.jsxs)(Jt,{children:[(0,J.jsx)(Q,{children:`Matterbridge info`}),(0,J.jsx)($t,{close:()=>r(!0)})]}),(0,J.jsx)(Qt,{style:q&&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,J.jsxs)(`table`,{style:{border:`none`,borderCollapse:`collapse`,tableLayout:`fixed`},children:[(0,J.jsxs)(`colgroup`,{children:[(0,J.jsx)(`col`,{style:{width:`40%`}}),(0,J.jsx)(`col`,{style:{width:`60%`}})]}),(0,J.jsx)(`tbody`,{style:{border:`none`,borderCollapse:`collapse`},children:Object.entries(e).filter(([e,t])=>!Ar.has(e)&&t!=null&&t!==``).map(([e,n],r)=>(0,J.jsxs)(`tr`,{className:r%2==0?`table-content-even`:`table-content-odd`,style:{border:`none`,borderCollapse:`collapse`},children:[(0,J.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`},children:kr.get(e)??e}),(0,J.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:q&&t?typeof n==`string`?n:n.toString():(0,J.jsx)(Or,{value:typeof n==`string`?n:n.toString(),maxChars:24})})]},e))})]})})]}))}var Mr=(0,W.memo)(jr),Nr={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`}},Pr=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 Fr({id:e}){let{online:t,sendMessage:n,addListener:r,removeListener:i,getUniqueId:a}=(0,W.useContext)(Y),[o,s]=(0,W.useState)(null),c=(0,W.useRef)(null),l=(0,W.useRef)(null),u=(0,W.useRef)(a()),{mobile:d,showConfirmCancelDialog:f}=(0,W.useContext)(Wt);K&&console.log(`QRDiv loading with id = "${e}" storeId = "${c.current}" timeout = ${l.current?`set`:`none`} and matter:`,o),(0,W.useEffect)(()=>{K&&console.log(`QRDiv id effect "${e}"`),c.current=e,l.current&&clearTimeout(l.current),l.current=null,e?(K&&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}})):(K&&console.log(`QRDiv id effect setting matter to null`),s(null))},[e,n]),(0,W.useEffect)(()=>{let e=e=>{K&&console.log(`QRDiv received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`matter`&&e.response.matter&&(K&&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&&(K&&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),K&&console.log(`QRDiv webSocket effect mounted`),()=>{i(e),l.current&&clearTimeout(l.current),l.current=null,K&&console.log(`QRDiv webSocket effect unmounted`)}},[r,i]);let p=()=>{K&&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=()=>{K&&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=()=>{K&&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=>{K&&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?(K&&console.log(`QRDiv rendering undefined state`),null):o.online?o.advertising&&o.qrPairingCode&&o.manualPairingCode?(K&&console.log(`QRDiv rendering advertising state`),(0,J.jsxs)(Z,{style:q&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,J.jsxs)(Jt,{children:[(0,J.jsx)(Q,{children:`QR pairing code`}),(0,J.jsxs)($t,{children:[(0,J.jsx)(T,{"aria-label":`send advertising`,size:`small`,onClick:h,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,J.jsx)(z,{title:`Send again the mDNS advertisement`,arrow:!0,children:(0,J.jsx)(X.Icon,{path:ft,size:`22px`})})}),(0,J.jsx)(T,{"aria-label":`stop pairing`,size:`small`,onClick:m,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,J.jsx)(z,{title:`Turn off pairing`,arrow:!0,children:(0,J.jsx)(X.Icon,{path:_t,size:`22px`})})})]})]}),(0,J.jsx)(Zt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,J.jsx)(At,{value:o.qrPairingCode,size:256,level:`M`,fgColor:`var(--div-text-color)`,bgColor:`var(--div-bg-color)`,style:{margin:`20px`}}),(0,J.jsxs)(Yt,{style:{justifyContent:`space-between`},children:[(0,J.jsxs)(Xt,{style:{fontWeight:`normal`,color:`var(--div-text-color)`},children:[`Manual pairing code: `,Pr(o.manualPairingCode)]}),(0,J.jsx)($t,{children:(0,J.jsx)(z,{title:`Copy manual pairing code`,arrow:!0,children:(0,J.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)}K&&console.log(`Manual pairing code copied to clipboard`)}catch(e){console.error(`Failed to copy manual pairing code`,e)}},sx:Nr,children:(0,J.jsx)(X.Icon,{path:ht,size:.85})})})})]})]})):o.commissioned&&o.fabricInformations&&o.sessionInformations?(K&&console.log(`QRDiv rendering commissioned state`),(0,J.jsxs)(Z,{style:q&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`,overflow:`hidden`},children:[(0,J.jsxs)(Jt,{children:[(0,J.jsx)(Q,{children:`Paired fabrics`}),(0,J.jsxs)($t,{children:[(0,J.jsx)(T,{"aria-label":`send advertising`,size:`small`,onClick:h,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,J.jsx)(z,{title:`Send again the mDNS advertisement`,arrow:!0,children:(0,J.jsx)(X.Icon,{path:ft,size:`22px`})})}),(0,J.jsx)(T,{"aria-label":`start pairing`,size:`small`,onClick:p,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,J.jsx)(z,{title:`Turn on pairing`,arrow:!0,children:(0,J.jsx)(X.Icon,{path:vt,size:`22px`})})})]})]}),(0,J.jsx)(Zt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,J.jsx)(Qt,{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,J.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,J.jsxs)(`div`,{style:{marginLeft:`20px`,marginBottom:`10px`,display:`flex`,flexDirection:`row`,justifyContent:`space-between`,gap:`20px`,alignItems:`center`},children:[(0,J.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,J.jsx)(z,{title:`Remove the fabric. You will also need to remove it from the controller.`,arrow:!0,children:(0,J.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:{...Nr,padding:`2px`},children:(0,J.jsx)(X.Icon,{path:dt,size:1})})})]}),(0,J.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Vendor: `,e.rootVendorId,` `,e.rootVendorName]}),e.label!==``&&(0,J.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Label: `,e.label]}),(0,J.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,J.jsx)(Yt,{style:{justifyContent:`center`,height:`auto`,minHeight:`30px`},children:(0,J.jsxs)(Xt,{style:{fontWeight:`normal`,overflowWrap:`anywhere`,textAlign:`center`},children:[`Serial number: `,o.serialNumber]})})]})):!o.commissioned&&!o.advertising?(K&&console.log(`QRDiv rendering not commissioned and not advertising state`),(0,J.jsxs)(Z,{style:q&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,J.jsx)(Jt,{children:(0,J.jsx)(Q,{children:`QR pairing code`})}),(0,J.jsx)(Zt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,J.jsx)(U,{onClick:p,endIcon:(0,J.jsx)(X.Icon,{path:vt,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,J.jsx)(Yt,{style:{justifyContent:`center`,height:`auto`,minHeight:`30px`},children:(0,J.jsxs)(Xt,{style:{fontWeight:`normal`,overflowWrap:`anywhere`,textAlign:`center`},children:[`Serial number: `,o.serialNumber]})})]})):(K&&console.log(`QRDiv rendering unknown state`),null):(K&&console.log(`QRDiv rendering offline state`),(0,J.jsxs)(Z,{style:q&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,J.jsx)(Jt,{style:{height:`30px`,justifyContent:`space-between`},children:(0,J.jsx)(Q,{children:`Server node`})}),(0,J.jsx)(Zt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,J.jsx)(Zt,{style:{fontWeight:`bold`},children:`Server offline`}),(0,J.jsx)(Yt,{style:{justifyContent:`center`,height:`auto`,minHeight:`30px`},children:(0,J.jsxs)(Xt,{style:{fontWeight:`normal`,overflowWrap:`anywhere`,textAlign:`center`},children:[`Serial number: `,o.serialNumber]})})]}))}var Ir=(0,W.memo)(Fr),Lr=new Map([[`interfaceName`,`Interface name`],[`macAddress`,`Mac address`],[`ipv4Address`,`IPv4 address`],[`ipv6Address`,`IPv6 address`],[`nodeVersion`,`Node version`],[`bunVersion`,`Bun version`],[`hostname`,`Hostname`],[`user`,`User`],[`osType`,`Os`],[`osPlatform`,`Platform`],[`freeMemory`,`Memory`],[`systemUptime`,`System uptime`],[`processUptime`,`Process uptime`],[`cpuUsage`,`Host CPU`],[`processCpuUsage`,`Process CPU`],[`rss`,`Rss`],[`heapUsed`,`Heap`]]);function Rr({systemInfo:e,compact:t}){let{mobile:n}=(0,W.useContext)(Wt),{addListener:r,removeListener:i,getUniqueId:a,sendMessage:o}=(0,W.useContext)(Y),[s,c]=(0,W.useState)(e),l=(0,W.useRef)(a());if(K&&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=()=>{K&&console.log(`SystemInfoTable handleViewHistory clicked`),o({id:l.current,sender:`Header`,method:`/api/viewhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}})};(0,W.useEffect)(()=>{let e=e=>{K&&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?(K&&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?(K&&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?(K&&console.log(`SystemInfoTable received uptime_update`,e),p(e.response.systemUptime,e.response.processUptime)):e.method===`/api/viewhistorypage`&&e.id===l.current&&e.success&&(K&&console.log(`SystemInfoTable received /api/viewhistorypage success`),window.open(`./api/viewhistory`,`_blank`,`noopener,noreferrer`))};return r(e,l.current),K&&console.log(`SystemInfoTable added WebSocket listener id ${l.current}`),()=>{i(e),K&&console.log(`SystemInfoTable removed WebSocket listener`)}},[r,i]);let[h,g]=(0,W.useState)(!1);return!s||h?null:(K&&console.log(`SystemInfoTable rendering...`),(0,J.jsxs)(Z,{style:q&&n?{flex:`1 1 300px`}:{flex:`0 1 auto`,width:`302px`,minWidth:`302px`},children:[(0,J.jsxs)(Jt,{children:[(0,J.jsx)(Q,{children:`System info`}),(0,J.jsx)($t,{close:()=>g(!0),children:(0,J.jsx)(T,{size:`small`,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},onClick:m,children:(0,J.jsx)(z,{title:`Open the cpu and memory usage page`,arrow:!0,children:(0,J.jsx)(X.Icon,{path:pt,size:`22px`})})})})]}),(0,J.jsx)(Qt,{style:q&&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,J.jsxs)(`table`,{style:{border:`none`,borderCollapse:`collapse`,tableLayout:`fixed`},children:[(0,J.jsxs)(`colgroup`,{children:[(0,J.jsx)(`col`,{style:{width:`40%`}}),(0,J.jsx)(`col`,{style:{width:`60%`}})]}),(0,J.jsx)(`tbody`,{style:{border:`none`,borderCollapse:`collapse`},children:Object.entries(s).filter(([e,t])=>e!==`bunVersion`&&t!==void 0&&t!==``).map(([e,t],r)=>(0,J.jsxs)(`tr`,{className:r%2==0?`table-content-even`:`table-content-odd`,style:{border:`none`,borderCollapse:`collapse`},children:[(0,J.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`},children:Lr.get(e)??e}),(0,J.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:q&&n?typeof t==`string`?t:t.toString():(0,J.jsx)(Or,{value:typeof t==`string`?t:t.toString(),maxChars:22})})]},e))})]})})]}))}var zr=(0,W.memo)(Rr);function Br(){let[e,t]=(0,W.useState)(null),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)([]),[o]=(0,W.useState)(localStorage.getItem(G.homePagePlugins)!==`false`),[s,c]=(0,W.useState)(localStorage.getItem(G.homePageMode)??`devices`),[l,u]=(0,W.useState)(`https://matterbridge.io/CHANGELOG.html`),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(null),{mobile:_}=(0,W.useContext)(Wt),{addListener:v,removeListener:y,online:b,sendMessage:x,getUniqueId:S}=(0,W.useContext)(Y),C=(0,W.useRef)(S());return(0,W.useEffect)(()=>{let e=e=>{K&&console.log(`Home received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`settings`?(K&&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===`update_required`&&(K&&console.log(`Home received update_required`,e.response),e.response.devVersion?r(t=>t?{...t,matterbridgeDevVersion:e.response.version}:null):r(t=>t?{...t,matterbridgeLatestVersion:e.response.version}:null)),e.method===`/api/settings`&&e.id===C.current?(K&&console.log(`Home received settings:`,e.response),t(e.response.systemInformation),r(e.response.matterbridgeInformation),localStorage.getItem(G.frontendVersion)===null&&e.response.matterbridgeInformation.frontendVersion?localStorage.setItem(G.frontendVersion,e.response.matterbridgeInformation.frontendVersion):e.response.matterbridgeInformation.frontendVersion!==localStorage.getItem(G.frontendVersion)&&e.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem(G.frontendVersion,e.response.matterbridgeInformation.frontendVersion),m(!0)),localStorage.getItem(G.matterbridgeVersion)===null?localStorage.setItem(G.matterbridgeVersion,e.response.matterbridgeInformation.matterbridgeVersion):e.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem(G.matterbridgeVersion)&&(localStorage.setItem(G.matterbridgeVersion,e.response.matterbridgeInformation.matterbridgeVersion),f(!0)),e.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem(G.homePageMode)||(localStorage.setItem(G.homePageMode,`devices`),c(`devices`)))):e.method===`/api/plugins`&&e.id===C.current&&(K&&console.log(`Home received plugins:`,e.response),a(e.response))};return v(e,C.current),K&&console.log(`Home added WebSocket listener id ${C.current}`),()=>{y(e),K&&console.log(`Home removed WebSocket listener`)}},[v,y,x]),(0,W.useEffect)(()=>{if(K&&console.log(`Home storeId effect with storeId ${h}`),n?.bridgeMode===`bridge`&&!h&&(K&&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){K&&console.log(`Home storeId effect set storeId to ${e.matter.id}`),g(e.matter.id);break}}},[n,i,h]),(0,W.useEffect)(()=>{b&&(K&&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]),K&&console.log(`Home rendering...`),!b||!e||!n?(0,J.jsx)(qt,{}):(0,J.jsxs)(jn,{name:`Home`,style:q&&_?{alignItems:`center`,gap:`10px`}:{flexDirection:`row`},children:[(q&&!_||!q)&&(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,width:`302px`,minWidth:`302px`,gap:`20px`},children:[(0,J.jsx)(Ir,{id:h}),(0,J.jsx)(zr,{systemInfo:e,compact:!0})]}),(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,width:`100%`,gap:q&&_?`10px`:`20px`},children:[p&&(0,J.jsx)(Fn,{version:n.frontendVersion}),d&&(0,J.jsx)(Dr,{version:n.matterbridgeVersion,changelog:l}),q&&_&&(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:`10px`},children:[(0,J.jsx)(Ir,{id:h}),(0,J.jsx)(zr,{systemInfo:e,compact:!0}),(0,J.jsx)(Mr,{matterbridgeInfo:n})]}),o&&!n.readOnly&&(0,J.jsx)(Qn,{}),o&&(0,J.jsx)(Tr,{storeId:h,setStoreId:g}),s===`devices`&&(0,J.jsx)(zn,{storeId:h,setStoreId:g}),s===`logs`&&(0,J.jsx)(rr,{})]})]})}var Vr=(0,W.memo)(Br);function Hr(){let{logLength:e,logAutoScroll:t,setMessages:n,setLogFilterLevel:r,setLogFilterSearch:i,online:a,filterLogMessages:o}=(0,W.useContext)(Y),[s,c]=(0,W.useState)(localStorage.getItem(G.logFilterLevel)??`info`),[l,u]=(0,W.useState)(localStorage.getItem(G.logFilterSearch)??`*`),[f,p]=(0,W.useState)(e.current.toString()),[m,h]=(0,W.useState)(t.current);return K&&console.log(`Logs rendering...`),a?(0,J.jsxs)(jn,{name:`Logs`,children:[(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`,margin:`0px`,padding:`0px`,gap:`10px`},children:[(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,J.jsx)(ue,{id:`select-level`,style:{color:`var(--div-text-color)`},children:`Filter log by level:`}),(0,J.jsxs)(L,{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(G.logFilterLevel,t),K&&console.log(`handleLogFilterLevelChange called with value:`,t)},children:[(0,J.jsx)(B,{value:`debug`,children:`Debug`}),(0,J.jsx)(B,{value:`info`,children:`Info`}),(0,J.jsx)(B,{value:`notice`,children:`Notice`}),(0,J.jsx)(B,{value:`warn`,children:`Warn`}),(0,J.jsx)(B,{value:`error`,children:`Error`}),(0,J.jsx)(B,{value:`fatal`,children:`Fatal`})]})]}),(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`5px`},children:[(0,J.jsx)(ue,{id:`search`,style:{color:`var(--div-text-color)`},children:`Filter log by text:`}),(0,J.jsx)(z,{title:`Use /text/ for case-insensitive regex search`,children:(0,J.jsx)(V,{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(G.logFilterSearch,t),K&&console.log(`handleLogFilterSearchChange called with value:`,t)},slotProps:{input:{style:{height:`30px`,padding:`0 0px`,backgroundColor:`var(--main-bg-color)`}}}})})]}),(0,J.jsx)(d,{control:(0,J.jsx)(oe,{checked:m,onChange:e=>{let n=e.target.checked;h(n),t.current=n,o(s,l),localStorage.setItem(G.logAutoScroll,n?`true`:`false`),K&&console.log(`handleAutoScrollChange called with value:`,n)}}),label:`Auto scroll`,style:{color:`var(--div-text-color)`}})]}),(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,J.jsx)(ue,{id:`select-size-label`,style:{color:`var(--div-text-color)`},children:`Log length:`}),(0,J.jsxs)(L,{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(G.logLength,n),K&&console.log(`handleLogLengthChange called with value:`,n)},children:[(0,J.jsx)(B,{value:100,children:`100`}),(0,J.jsx)(B,{value:200,children:`200`}),(0,J.jsx)(B,{value:500,children:`500`}),(0,J.jsx)(B,{value:1e3,children:`1000`})]}),(0,J.jsx)(z,{title:`Clear the logs`,children:(0,J.jsx)(U,{onClick:()=>{K&&console.log(`handleClearLogsClick called`),n([])},endIcon:(0,J.jsx)(Ae,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Clear`})})]})]}),(0,J.jsx)(`div`,{style:{flex:`1`,overflow:`auto`,margin:`0px`,padding:`0px`},children:(0,J.jsx)(tr,{})})]}):(0,J.jsx)(qt,{})}var Ur=(0,W.memo)(Hr),Wr=1200,Gr,Kr;function qr(e,t){Gr=e,Kr=t}function Jr(){let{mobile:e,showSnackbarMessage:t,showConfirmCancelDialog:n}=(0,W.useContext)(Wt),{online:i,sendMessage:a,logMessage:o,addListener:c,removeListener:l,getUniqueId:d}=(0,W.useContext)(Y),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(!1),[_,y]=(0,W.useState)(!1),[b,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(null),[w,E]=(0,W.useState)(`inactive`),D=(0,W.useRef)(d()),[O,k]=(0,W.useState)(null),[A,j]=(0,W.useState)(null),[M,N]=(0,W.useState)(null),[te,P]=(0,W.useState)(null),ne=r(),F=()=>{window.open(`https://www.buymeacoffee.com/luligugithub`,`_blank`)},re=()=>{window.open(`https://matterbridge.io/`)},I=()=>{window.open(`https://matterbridge.io/README.html`)},ie=()=>{window.open(`https://matterbridge.io/CHANGELOG.html`)},ae=()=>{window.open(`https://discord.gg/QX58CDe6hd`,`_blank`)},oe=()=>{window.open(`https://github.com/Luligu/matterbridge`,`_blank`)},se=()=>{a({id:D.current,sender:`Header`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:`matterbridge`,restart:!0}}),y(!1)},ce=()=>{a({id:D.current,sender:`Header`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:`matterbridge@dev`,restart:!0}}),x(!1)},ue=()=>{a({id:D.current,sender:`Header`,method:`/api/checkupdates`,src:`Frontend`,dst:`Matterbridge`,params:{}})},de=()=>{K&&console.log(`Header: handleShellySystemUpdateClick`),o(`Matterbridge`,`Installing system updates...`),a({id:D.current,sender:`Header`,method:`/api/shellysysupdate`,src:`Frontend`,dst:`Matterbridge`,params:{}})},fe=()=>{K&&console.log(`Header: handleShellyMainUpdateClick`),o(`Matterbridge`,`Installing software updates...`),a({id:D.current,sender:`Header`,method:`/api/shellymainupdate`,src:`Frontend`,dst:`Matterbridge`,params:{}})},pe=()=>{K&&console.log(`Header: handleShellyCreateSystemLog`),a({id:D.current,sender:`Header`,method:`/api/shellycreatesystemlog`,src:`Frontend`,dst:`Matterbridge`,params:{}})},me=()=>{K&&console.log(`Header: handleShellyDownloadSystemLog`),o(`Matterbridge`,`Downloading Shelly system log...`),t(`Downloading Shelly system log...`,5),window.location.href=`./api/shellydownloadsystemlog`},he=()=>{S?.matterbridgeInformation.restartMode===`none`?a({id:D.current,sender:`Header`,method:`/api/restart`,src:`Frontend`,dst:`Matterbridge`,params:{}}):a({id:D.current,sender:`Header`,method:`/api/shutdown`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ge=()=>{a({id:D.current,sender:`Header`,method:`/api/shutdown`,src:`Frontend`,dst:`Matterbridge`,params:{}})},_e=()=>{a({id:D.current,sender:`Header`,method:`/api/reboot`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ve=()=>{a({id:D.current,sender:`Header`,method:`/api/softreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ye=()=>{a({id:D.current,sender:`Header`,method:`/api/hardreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},be=e=>{k(e.currentTarget)},L=e=>{K&&console.log(`Header: handleMenuClose`,e),k(null),e===`/`||e===`/devices`||e===`/log`||e===`/settings`?ne(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`?a({id:D.current,sender:`Header`,method:`/api/viewhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`download-history`?a({id:D.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`?se():e===`updatedev`?ce():e===`updatecheck`?ue():e===`shelly-sys-update`?de():e===`shelly-main-update`?fe():e===`shelly-create-system-log`?pe():e===`shelly-download-system-log`?me():e===`softreset`?ve():e===`hardreset`?ye():e===`restart`?he():e===`shutdown`?ge():e===`reboot`?_e():e===`create-backup`?a({id:D.current,sender:`Header`,method:`/api/create-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-matterbridge-storage-backup`?a({id:D.current,sender:`Header`,method:`/api/create-matterbridge-storage-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-matter-storage-backup`?a({id:D.current,sender:`Header`,method:`/api/create-matter-storage-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-plugin-backup`?a({id:D.current,sender:`Header`,method:`/api/create-plugin-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-config-backup`?a({id:D.current,sender:`Header`,method:`/api/create-config-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`unregister`?a({id:D.current,sender:`Header`,method:`/api/unregister`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`reset`?a({id:D.current,sender:`Header`,method:`/api/reset`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`factoryreset`&&a({id:D.current,sender:`Header`,method:`/api/factoryreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},Se=e=>{K&&console.log(`Header: handleMenuCloseCancel:`,e),k(null)},Ce=e=>{j(e.currentTarget)},we=()=>{j(null)},Te=e=>{N(e.currentTarget)},Ee=()=>{N(null)},De=e=>{P(e.currentTarget)},Oe=()=>{P(null)};return(0,W.useEffect)(()=>{let e=e=>{K&&console.log(`Header received WebSocket Message:`,e),e.method===`/api/settings`&&e.id===D.current?(K&&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(e.response.matterbridgeInformation.bridgeStatus)):e.method===`refresh_required`&&e.response.changed===`settings`?(K&&console.log(`Header received refresh_required: changed=${e.response.changed} and sending /api/settings request`),a({id:D.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`restart_required`?(K&&console.log(`Header received restart_required with fixed: ${e.response.fixed}`),p(!0),e.response.fixed&&h(!0)):e.method===`restart_not_required`?(K&&console.log(`Header received restart_not_required`),p(!1)):e.method===`matterbridge_status_update`?(K&&console.log(`Header received matterbridge_status_update: ${e.response.status}`),E(e.response.status)):e.method===`update_required`?(K&&console.log(`Header received update_required`),e.response.devVersion?(C(t=>t?{...t,matterbridgeInformation:{...t.matterbridgeInformation,matterbridgeDevVersion:e.response.version}}:null),x(!0)):(C(t=>t?{...t,matterbridgeInformation:{...t.matterbridgeInformation,matterbridgeLatestVersion:e.response.version}}:null),y(!0))):e.method===`shelly_sys_update`?(K&&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`?(K&&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===D.current&&e.success?(K&&console.log(`Header received /api/viewhistorypage success`),window.open(`./api/viewhistory`,`_blank`,`noopener,noreferrer`)):e.method===`/api/downloadhistorypage`&&e.id===D.current&&e.success?(K&&console.log(`Header received /api/downloadhistorypage success`),window.location.href=`./api/downloadhistory`):e.method===`archive`&&e.success&&e.response.command===`zip`&&(K&&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,D.current),K&&console.log(`Header added WebSocket listener id ${D.current}`),()=>{l(e),K&&console.log(`Header removed WebSocket listener`)}},[c,l,a,t]),(0,W.useEffect)(()=>{i&&(K&&console.log(`Header sending /api/settings and /api/checkupdates requests`),a({id:D.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[i,a]),K&&console.log(`Header rendering... mobile %s`,e),!i||!S?null:(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`,width:`100%`,gap:`10px`},children:[(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,J.jsx)(T,{style:{margin:`0`,padding:`0`},onClick:()=>{Pt(),K&&console.log(`Matterbridge logo clicked: debug is now`,K)},children:(0,J.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`30px`}})}),(0,J.jsx)(`h2`,{style:{fontSize:`22px`,color:`var(--main-icon-color)`,margin:`0px`},children:`Matterbridge`})]}),(0,J.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:(0,J.jsxs)(`nav`,{children:[(0,J.jsx)(s,{to:`/`,className:`nav-link`,children:`Home`}),(0,J.jsx)(s,{to:`/devices`,className:`nav-link`,children:`Devices`}),(0,J.jsx)(s,{to:`/log`,className:`nav-link`,children:`Logs`}),(0,J.jsx)(s,{to:`/settings`,className:`nav-link`,children:`Settings`})]})})]}),(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[!S.matterbridgeInformation.readOnly&&(0,J.jsx)(z,{title:`Matterbridge v.${S.matterbridgeInformation.matterbridgeVersion}`,children:(0,J.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`,backgroundColor:_?`var(--primary-color)`:b?`var(--secondary-color)`:`green`},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,J.jsx)(`img`,{src:`Shelly.svg`,alt:`Shelly Icon`,style:{height:`30px`,padding:`0px`,margin:`0px`,marginRight:`30px`}}),S.matterbridgeInformation.bridgeMode!==`none`&&!S.matterbridgeInformation.readOnly?(0,J.jsx)(z,{title:`Bridge mode`,children:(0,J.jsx)(`span`,{className:`status-information`,style:{cursor:`default`,backgroundColor:w===`started`?`green`:w===`error`?`red`:void 0},children:S.matterbridgeInformation.bridgeMode})}):null,S.matterbridgeInformation.restartMode!==`none`&&!S.matterbridgeInformation.readOnly?(0,J.jsx)(z,{title:`Restart mode`,children:(0,J.jsx)(`span`,{className:`status-information`,style:{cursor:`default`,backgroundColor:`green`},children:S.matterbridgeInformation.restartMode})}):null,S.systemInformation.bunVersion?(0,J.jsx)(z,{title:`Bun version`,children:(0,J.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`,backgroundColor:`green`},children:[`bun v.`,S.systemInformation.bunVersion]})}):null,S.matterbridgeInformation.profile&&S.matterbridgeInformation.profile!==``&&!S.matterbridgeInformation.readOnly?(0,J.jsx)(z,{title:`Current profile`,children:(0,J.jsx)(`span`,{className:`status-information`,style:{cursor:`default`,backgroundColor:`green`},children:S.matterbridgeInformation.profile})}):null,K&&(0,J.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`,backgroundColor:`green`},children:[e?`Mobile `:`Desktop `,`${Gr}x${Kr}`,` enabled ${localStorage.getItem(G.enableMobile)!==`false`}`]})]}),(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`5px`},children:[S.matterbridgeInformation.readOnly?null:(0,J.jsx)(z,{title:`Matterbridge discord group`,children:(0,J.jsx)(T,{style:{margin:`0`,padding:`0`},onClick:ae,children:(0,J.jsx)(`img`,{src:`discord.svg`,alt:`Discord Logo`,style:{height:`25px`}})})}),S.matterbridgeInformation.readOnly?null:(0,J.jsx)(z,{title:`Give a star to Matterbridge`,children:(0,J.jsx)(T,{style:{color:`#FFD700`,margin:`0`,padding:`0`},onClick:oe,children:(0,J.jsx)(Ze,{})})}),S.matterbridgeInformation.readOnly?null:(0,J.jsx)(z,{title:`Sponsor Matterbridge`,children:(0,J.jsx)(T,{style:{color:`#b6409c`,margin:`0`,padding:`0`},onClick:F,children:(0,J.jsx)(at,{})})}),(0,J.jsx)(z,{title:`Matterbridge homepage`,children:(0,J.jsx)(T,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:re,children:(0,J.jsx)(le,{})})}),(0,J.jsx)(z,{title:`Matterbridge help`,children:(0,J.jsx)(T,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:I,children:(0,J.jsx)(g,{})})}),(0,J.jsx)(z,{title:`Matterbridge changelog`,children:(0,J.jsx)(T,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:ie,children:(0,J.jsx)(v,{})})}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&_&&(0,J.jsx)(z,{title:`Update matterbridge to latest version v.${S.matterbridgeInformation.matterbridgeLatestVersion}`,children:(0,J.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:se,children:(0,J.jsx)(ct,{})})}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&b&&(0,J.jsx)(z,{title:`Update matterbridge to latest dev version v.${S.matterbridgeInformation.matterbridgeDevVersion}`,children:(0,J.jsx)(T,{style:{color:`var(--secondary-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:ce,children:(0,J.jsx)(ct,{})})}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&S.matterbridgeInformation.shellySysUpdate&&(0,J.jsx)(z,{title:`Shelly system update`,children:(0,J.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:de,children:(0,J.jsx)(ct,{})})}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&S.matterbridgeInformation.shellyMainUpdate&&(0,J.jsx)(z,{title:`Shelly software update`,children:(0,J.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:fe,children:(0,J.jsx)(ct,{})})}),(0,J.jsx)(z,{title:`Restart matterbridge`,children:(0,J.jsx)(T,{style:{color:f||m?`var(--primary-color)`:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:he,children:(0,J.jsx)(st,{})})}),S.matterbridgeInformation.restartMode===`none`?(0,J.jsx)(z,{title:`Shut down matterbridge`,children:(0,J.jsx)(T,{style:{color:f||m?`var(--primary-color)`:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:ge,children:(0,J.jsx)(xe,{})})}):null,(0,J.jsx)(z,{title:`Download, backup and more`,children:(0,J.jsx)(T,{onClick:be,children:(0,J.jsx)(Ge,{style:{color:`var(--main-icon-color)`}})})}),(0,J.jsxs)(lt,{id:`command-menu`,anchorEl:O,keepMounted:!0,open:!!O,onClose:()=>L(``),children:[q&&e&&(0,J.jsxs)(B,{onClick:()=>L(`/`),children:[(0,J.jsx)(H,{children:(0,J.jsx)(Ue,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Home page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),q&&e&&(0,J.jsxs)(B,{onClick:()=>L(`/devices`),children:[(0,J.jsx)(H,{children:(0,J.jsx)(Ue,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Devices page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),q&&e&&(0,J.jsxs)(B,{onClick:()=>L(`/log`),children:[(0,J.jsx)(H,{children:(0,J.jsx)(Ue,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Logs page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),q&&e&&(0,J.jsxs)(B,{onClick:()=>L(`/settings`),children:[(0,J.jsx)(H,{children:(0,J.jsx)(Ue,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Settings page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&(0,J.jsxs)(B,{onClick:()=>L(`update`),children:[(0,J.jsx)(H,{children:(0,J.jsx)(ct,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Install latest stable`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&(0,J.jsxs)(B,{onClick:()=>L(`updatedev`),children:[(0,J.jsx)(H,{children:(0,J.jsx)(ct,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Install latest dev`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&(0,J.jsxs)(B,{onClick:()=>L(`updatecheck`),children:[(0,J.jsx)(H,{children:(0,J.jsx)(ct,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Check for updates`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&S.matterbridgeInformation.shellySysUpdate&&(0,J.jsxs)(B,{onClick:()=>L(`shelly-sys-update`),children:[(0,J.jsx)(H,{children:(0,J.jsx)(ct,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Shelly system update`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&S.matterbridgeInformation.shellyMainUpdate&&(0,J.jsxs)(B,{onClick:()=>L(`shelly-main-update`),children:[(0,J.jsx)(H,{children:(0,J.jsx)(ct,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Shelly software update`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(B,{onClick:()=>L(`restart`),children:[(0,J.jsx)(H,{children:(0,J.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Restart`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation.restartMode===`none`?(0,J.jsxs)(B,{onClick:()=>L(`shutdown`),children:[(0,J.jsx)(H,{children:(0,J.jsx)(xe,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Shutdown`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}):null,S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,J.jsxs)(B,{onClick:()=>{n(`Reboot`,`Are you sure you want to reboot the Shelly board?`,`reboot`,L,Se)},children:[(0,J.jsx)(H,{children:(0,J.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Reboot...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsx)(ee,{}),(0,J.jsxs)(B,{onClick:Ce,children:[(0,J.jsx)(H,{children:(0,J.jsx)(Ue,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`View`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(lt,{id:`sub-menu-view`,anchorEl:A,keepMounted:!0,open:!!A,onClose:we,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,J.jsxs)(B,{onClick:()=>{It(),we(),Se(``),window.open(`/home`,`_self`)},children:[(0,J.jsx)(H,{children:(0,J.jsx)(Ue,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Desktop site`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(B,{onClick:()=>{Ft(),we(),Se(``),window.open(`/home`,`_self`)},children:[(0,J.jsx)(H,{children:(0,J.jsx)(Ue,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Mobile site`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(B,{onClick:()=>{L(`view-mblog`),we()},children:[(0,J.jsx)(H,{children:(0,J.jsx)(Ue,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Matterbridge log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(B,{onClick:()=>{L(`view-mjlog`),we()},children:[(0,J.jsx)(H,{children:(0,J.jsx)(Ue,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Matter log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(B,{onClick:()=>{L(`view-diagnostic`),we()},children:[(0,J.jsx)(H,{children:(0,J.jsx)(Ue,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Matterbridge diagnostic log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(B,{onClick:()=>{L(`view-history`),we()},children:[(0,J.jsx)(H,{children:(0,J.jsx)(Ue,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Matterbridge system history`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,J.jsxs)(B,{onClick:()=>{L(`view-shellylog`),we()},children:[(0,J.jsx)(H,{children:(0,J.jsx)(Ue,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]}),(0,J.jsx)(ee,{}),(0,J.jsxs)(B,{onClick:Te,children:[(0,J.jsx)(H,{children:(0,J.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Download`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(lt,{id:`sub-menu-download`,anchorEl:M,keepMounted:!0,open:!!M,onClose:Ee,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,J.jsxs)(B,{onClick:()=>{L(`create-matterbridge-storage-backup`),Ee()},children:[(0,J.jsx)(H,{children:(0,J.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Matterbridge storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(B,{onClick:()=>{L(`create-plugin-backup`),Ee()},children:[(0,J.jsx)(H,{children:(0,J.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Matterbridge plugins storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(B,{onClick:()=>{L(`create-config-backup`),Ee()},children:[(0,J.jsx)(H,{children:(0,J.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Matterbridge plugins config`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(B,{onClick:()=>{L(`download-mblog`),Ee()},children:[(0,J.jsx)(H,{children:(0,J.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Matterbridge log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(B,{onClick:()=>{L(`create-matter-storage-backup`),Ee()},children:[(0,J.jsx)(H,{children:(0,J.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Matter storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(B,{onClick:()=>{L(`download-mjlog`),Ee()},children:[(0,J.jsx)(H,{children:(0,J.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Matter log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(B,{onClick:()=>{L(`download-diagnostic`),Ee()},children:[(0,J.jsx)(H,{children:(0,J.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Matterbridge diagnostic log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(B,{onClick:()=>{L(`download-history`),Ee()},children:[(0,J.jsx)(H,{children:(0,J.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Matterbridge system history`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,J.jsxs)(B,{onClick:()=>{L(`shelly-create-system-log`),Ee()},children:[(0,J.jsx)(H,{children:(0,J.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Create Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,J.jsxs)(B,{onClick:()=>{L(`shelly-download-system-log`),Ee()},children:[(0,J.jsx)(H,{children:(0,J.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Download Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]}),(0,J.jsx)(ee,{}),(0,J.jsxs)(B,{onClick:()=>{L(`create-backup`)},children:[(0,J.jsx)(H,{children:(0,J.jsx)(Ye,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Backup`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsx)(ee,{}),(0,J.jsxs)(B,{onClick:De,children:[(0,J.jsx)(H,{children:(0,J.jsx)(Ne,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Reset`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(lt,{id:`sub-menu-reset`,anchorEl:te,keepMounted:!0,open:!!te,onClose:Oe,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,J.jsxs)(B,{onClick:()=>{Oe(),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`,L,Se)},children:[(0,J.jsx)(H,{children:(0,J.jsx)(xe,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Reset the frontend UI...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(B,{onClick:()=>{Oe(),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`,L,Se)},children:[(0,J.jsx)(H,{children:(0,J.jsx)(xe,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Reset all devices...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,J.jsxs)(B,{onClick:()=>{Oe(),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`,L,Se)},children:[(0,J.jsx)(H,{children:(0,J.jsx)(xe,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Reset commissioning...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),!S.matterbridgeInformation.readOnly&&(0,J.jsxs)(B,{onClick:()=>{Oe(),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`,L,Se)},children:[(0,J.jsx)(H,{children:(0,J.jsx)(xe,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Factory reset...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,J.jsxs)(B,{onClick:()=>{Oe(),n(`Network reset`,`Are you sure you want to factory reset the network parameters?`,`softreset`,L,Se)},children:[(0,J.jsx)(H,{children:(0,J.jsx)(xe,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Reset network...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,J.jsxs)(B,{onClick:()=>{Oe(),n(`Factory reset`,`Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.`,`hardreset`,L,Se)},children:[(0,J.jsx)(H,{children:(0,J.jsx)(xe,{style:{color:`var(--main-icon-color)`}})}),(0,J.jsx)(R,{primary:`Factory reset...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]})]})]})]})}var Yr=(0,W.memo)(Jr);function Xr(){if(typeof window<`u`){let e=Math.floor(window.visualViewport?.width??window.innerWidth),t=Math.floor(window.visualViewport?.height??window.innerHeight);qr(e,t);let n=e<1200||t<900;return K&&console.log(`Visual viewport (%s) width %i height %i mobile %s`,window.visualViewport!==void 0,e,t,n),n}return!1}function Zr({children:e}){let{mobile:t,setMobile:n}=(0,W.useContext)(Wt),{logAutoScroll:r}=(0,W.useContext)(Y);return(0,W.useEffect)(()=>{function e(){let e=Xr();e&&(r.current=!1,localStorage.setItem(G.logAutoScroll,`false`)),n(e)}return window.addEventListener(`resize`,e),n(Xr()),()=>window.removeEventListener(`resize`,e)},[r,n]),K&&console.log(`MbfScreen rendering... mobile %s`,t),q&&t?(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,overflow:`visible`,margin:`0px`,padding:`10px`,gap:`10px`},children:[(0,J.jsx)(Yr,{}),(0,J.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,margin:`0px`,padding:`0px`,gap:`10px`},children:e})]}):(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,overflow:`hidden`,width:t?`${Wr}px`:`calc(100vw - 40px)`,height:t?`900px`:`calc(100vh - 40px)`,margin:`0px`,padding:`20px`,gap:`20px`},children:[(0,J.jsx)(Yr,{}),(0,J.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 $r=({open:e,onClose:t,onSave:n})=>{let[r,i]=(0,W.useState)(``),[a,o]=(0,W.useState)(``),s=e=>{i(e.target.value)},c=e=>{o(e.target.value)},l=r.length>0&&r===a;return(0,J.jsxs)(M,{open:e,onClose:(e,n)=>{n===`backdropClick`||n===`escapeKeyDown`||t()},maxWidth:`sm`,style:{maxWidth:`500px`,margin:`auto`},disableEscapeKeyDown:!0,children:[(0,J.jsx)(P,{children:(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,J.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,J.jsx)(`h4`,{style:{margin:0},children:`Change Password`})]})}),(0,J.jsx)(x,{dividers:!0,children:(0,J.jsx)(Ie,{component:`fieldset`,fullWidth:!0,sx:{margin:0,padding:0,gap:`20px`},children:(0,J.jsxs)(_,{container:!0,spacing:2,sx:{mt:2},children:[(0,J.jsx)(_,{size:12,children:(0,J.jsx)(V,{type:`password`,autoComplete:`new-password`,label:`New Password`,size:`small`,variant:`outlined`,fullWidth:!0,value:r,onChange:s})}),(0,J.jsx)(_,{size:12,children:(0,J.jsx)(V,{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,J.jsxs)(D,{children:[(0,J.jsx)(U,{onClick:()=>{t()},children:`Cancel`}),(0,J.jsx)(U,{variant:`contained`,onClick:()=>{l&&(n(r),t())},disabled:!l,children:`Change`}),(0,J.jsx)(U,{variant:`contained`,onClick:()=>{n(``),t()},children:`Reset`})]})]})},ei=({open:e,ip:t,onClose:n,onSave:r})=>{let i=t?t.split(`.`).slice(0,3).join(`.`)+`.1`:``,[a,o]=(0,W.useState)(`dhcp`),[s,c]=(0,W.useState)({ip:t??``,subnet:`255.255.255.0`,gateway:i,dns:i}),l=e=>t=>{c({...s,[e]:t.target.value})};return(0,J.jsxs)(M,{open:e,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||n()},maxWidth:`sm`,style:{maxWidth:`550px`,margin:`auto`},children:[(0,J.jsx)(P,{gap:`20px`,children:(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,J.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,J.jsx)(`h4`,{style:{margin:0},children:`Network Configuration`})]})}),(0,J.jsxs)(x,{dividers:!0,children:[(0,J.jsxs)(Ie,{component:`fieldset`,fullWidth:!0,children:[(0,J.jsx)(F,{component:`legend`,children:`Select IP Configuration`}),(0,J.jsxs)(He,{row:!0,value:a,onChange:e=>o(e.target.value),children:[(0,J.jsx)(d,{value:`dhcp`,control:(0,J.jsx)(Me,{}),label:`DHCP`}),(0,J.jsx)(d,{value:`static`,control:(0,J.jsx)(Me,{}),label:`Static`})]})]}),a===`static`&&(0,J.jsxs)(_,{container:!0,spacing:2,sx:{mt:2},children:[(0,J.jsx)(_,{size:6,children:(0,J.jsx)(V,{label:`IP Address`,fullWidth:!0,value:s.ip,onChange:l(`ip`)})}),(0,J.jsx)(_,{size:6,children:(0,J.jsx)(V,{label:`Subnet Mask`,fullWidth:!0,value:s.subnet,onChange:l(`subnet`)})}),(0,J.jsx)(_,{size:6,children:(0,J.jsx)(V,{label:`Gateway`,fullWidth:!0,value:s.gateway,onChange:l(`gateway`)})}),(0,J.jsx)(_,{size:6,children:(0,J.jsx)(V,{label:`DNS Server`,fullWidth:!0,value:s.dns,onChange:l(`dns`)})})]})]}),(0,J.jsxs)(D,{children:[(0,J.jsx)(U,{onClick:()=>{n()},children:`Cancel`}),(0,J.jsx)(U,{variant:`contained`,onClick:()=>{r({type:a,...s}),n()},children:`Save`})]})]})},ti=330;function ni(){let{mobile:e}=(0,W.useContext)(Wt),{online:t,addListener:n,removeListener:r,sendMessage:i,getUniqueId:a}=(0,W.useContext)(Y),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(null),u=(0,W.useRef)(a());return(0,W.useEffect)(()=>{let e=e=>{K&&console.log(`Settings received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`settings`?(K&&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===`update_required`?(K&&console.log(`Settings received update_required`,e.response),e.response.devVersion?s(t=>t?{...t,matterbridgeDevVersion:e.response.version}:null):s(t=>t?{...t,matterbridgeLatestVersion:e.response.version}:null)):e.method===`/api/settings`&&(K&&console.log(`Settings received /api/settings:`,e.response),s(e.response.matterbridgeInformation),l(e.response.systemInformation))};return n(e,u.current),K&&console.log(`Settings added WebSocket listener`),()=>{r(e),K&&console.log(`Settings removed WebSocket listener`)}},[n,r,i]),(0,W.useEffect)(()=>{t&&(K&&console.log(`Settings received online`),i({id:u.current,sender:`Settings`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[t,i]),K&&console.log(`Settings rendering...`),!t||!o||!c?(0,J.jsx)(qt,{}):(0,J.jsx)(jn,{name:`Settings`,children:(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:q&&e?`10px`:`20px`},children:[(0,J.jsx)(ri,{matterbridgeInfo:o,systemInfo:c}),(0,J.jsx)(ii,{matterbridgeInfo:o}),(0,J.jsx)(ai,{matterbridgeInfo:o}),(0,J.jsx)(oi,{systemInfo:c})]})})}function ri({matterbridgeInfo:e,systemInfo:t}){let{sendMessage:n,getUniqueId:r}=(0,W.useContext)(Y),[i,a]=(0,W.useState)(`bridge`),[o,s]=(0,W.useState)(`Info`),[c,l]=(0,W.useState)(!1),[u,f]=(0,W.useState)(`dark`),[p,m]=(0,W.useState)(localStorage.getItem(G.homePagePlugins)!==`false`),[h,g]=(0,W.useState)(localStorage.getItem(G.homePageMode)??`devices`),[_,v]=(0,W.useState)(localStorage.getItem(G.virtualMode)??`outlet`),y=(0,W.useRef)(r()),[b,x]=(0,W.useState)(!1),S=()=>x(!1),C=e=>{K&&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,W.useState)(!1);return(0,W.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,W.useEffect)(()=>{let e=localStorage.getItem(G.frontendTheme);e&&f(e)},[]),!e||!t?null:(0,J.jsxs)(Z,{style:{flex:`1 1 ${ti}px`},children:[(0,J.jsx)(Jt,{children:(0,J.jsx)(Q,{children:`Matterbridge settings`})}),(0,J.jsx)(ei,{open:b,ip:t.ipv4Address,onClose:S,onSave:C}),(0,J.jsx)($r,{open:w,onClose:()=>T(!1),onSave:e=>{K&&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}}),Rt(e)}}),(0,J.jsxs)(Qt,{style:{flexDirection:`column`,padding:`10px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`},children:[(0,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`},children:[(0,J.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`matterbridgeInfo-mode`,children:`Mode:`}),(0,J.jsxs)(He,{row:!0,name:`mode-buttons-group`,value:i,onChange:e=>{K&&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,J.jsx)(d,{value:`bridge`,control:(0,J.jsx)(Me,{}),label:`Bridge`,disabled:e.readOnly}),(0,J.jsx)(d,{value:`childbridge`,control:(0,J.jsx)(Me,{}),label:`Childbridge`,disabled:e.readOnly})]})]}),(0,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`15px`},children:[(0,J.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`mblogger-level-label`,children:`Logger level:`}),(0,J.jsxs)(L,{style:{height:`30px`},labelId:`mblogger-level-label`,id:`mblogger-level`,value:o,onChange:e=>{K&&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,J.jsx)(B,{value:`Debug`,children:`Debug`}),(0,J.jsx)(B,{value:`Info`,children:`Info`}),(0,J.jsx)(B,{value:`Notice`,children:`Notice`}),(0,J.jsx)(B,{value:`Warn`,children:`Warn`}),(0,J.jsx)(B,{value:`Error`,children:`Error`}),(0,J.jsx)(B,{value:`Fatal`,children:`Fatal`})]})]}),(0,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`10px`},children:[(0,J.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`mblogger-file-label`,children:`Log on file:`}),(0,J.jsx)(oe,{checked:c,onChange:e=>{K&&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,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,J.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`frontend-theme-label`,children:`Frontend theme:`}),(0,J.jsxs)(L,{style:{height:`30px`},labelId:`frontend-theme-label`,id:`frontend-theme`,value:u,onChange:e=>{let t=e.target.value;K&&console.log(`handleChangeTheme called with value:`,t),f(t),localStorage.setItem(G.frontendTheme,t),document.body.setAttribute(`frontend-theme`,t)},children:[(0,J.jsx)(B,{value:`classic`,children:`Classic`}),(0,J.jsx)(B,{value:`light`,children:`Light`}),(0,J.jsx)(B,{value:`dark`,children:`Dark`})]})]}),(0,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,J.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`frontend-home-plugin-label`,children:`Home page plugins:`}),(0,J.jsx)(oe,{checked:p,onChange:e=>{let t=e.target.checked;K&&console.log(`handleChangeHomePagePlugins called with value:`,t),m(t),localStorage.setItem(G.homePagePlugins,t?`true`:`false`)},name:`showPlugins`})]}),(0,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,J.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`frontend-home-label`,children:`Home page bottom panel:`}),(0,J.jsxs)(L,{style:{height:`30px`},labelId:`frontend-home-label`,id:`frontend-home`,value:h,onChange:e=>{let t=e.target.value;K&&console.log(`handleChangeHomePageMode called with value:`,t),g(t),localStorage.setItem(G.homePageMode,t)},children:[(0,J.jsx)(B,{value:`logs`,children:`Logs`}),(0,J.jsx)(B,{value:`devices`,children:`Devices`})]})]}),(0,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`10px`},children:[(0,J.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`frontend-virtual-label`,children:`Virtual devices:`}),(0,J.jsxs)(L,{style:{height:`30px`},labelId:`frontend-virtual-label`,id:`frontend-virtual`,value:_,onChange:e=>{let t=e.target.value;K&&console.log(`handleChangeVirtualMode called with value:`,t),v(t),localStorage.setItem(G.virtualMode,t),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setvirtualmode`,value:t}})},children:[(0,J.jsx)(B,{value:`disabled`,children:`Disabled`}),(0,J.jsx)(B,{value:`outlet`,children:`Outlet`}),(0,J.jsx)(B,{value:`light`,children:`Light`}),(0,J.jsx)(B,{value:`switch`,children:`Switch`}),(0,J.jsx)(B,{value:`mounted_switch`,children:`Mounted Switch`})]})]}),(0,J.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`20px`},children:(0,J.jsx)(U,{variant:`contained`,color:`primary`,onClick:()=>T(!0),children:`Change password`})}),e.shellyBoard&&(0,J.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`20px`},children:(0,J.jsx)(U,{variant:`contained`,color:`primary`,onClick:()=>x(!0),children:`Configure IP`})})]})]})}function ii({matterbridgeInfo:e}){let{sendMessage:t,getUniqueId:n}=(0,W.useContext)(Y),[r,i]=(0,W.useState)(`Info`),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(``),[l,u]=(0,W.useState)(``),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(``),[h,g]=(0,W.useState)(``),[_,v]=(0,W.useState)(``),y=(0,W.useRef)(n()),b=(0,W.useMemo)(()=>Qr(1e3),[]),x=(0,W.useMemo)(()=>Qr(1e3),[]),S=(0,W.useMemo)(()=>Qr(1e3),[]),C=(0,W.useMemo)(()=>Qr(1e3),[]),w=(0,W.useMemo)(()=>Qr(1e3),[]),T=(0,W.useMemo)(()=>Qr(1e3),[]);return(0,W.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,W.useEffect)(()=>()=>b.cancel(),[b]),(0,W.useEffect)(()=>()=>x.cancel(),[x]),(0,W.useEffect)(()=>()=>S.cancel(),[S]),(0,W.useEffect)(()=>()=>C.cancel(),[C]),(0,W.useEffect)(()=>()=>w.cancel(),[w]),(0,W.useEffect)(()=>()=>T.cancel(),[T]),e?(0,J.jsxs)(Z,{style:{flex:`1 1 ${ti}px`},children:[(0,J.jsx)(Jt,{children:(0,J.jsx)(Q,{children:`Matter settings`})}),(0,J.jsxs)(Qt,{style:{flexDirection:`column`,padding:`10px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`},children:[(0,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`15px`},children:[(0,J.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`mjlogger-level-label`,children:`Logger level:`}),(0,J.jsxs)(L,{style:{height:`30px`},labelId:`mjlogger-level-label`,id:`mjlogger-level`,value:r,onChange:e=>{K&&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,J.jsx)(B,{value:`Debug`,children:`Debug`}),(0,J.jsx)(B,{value:`Info`,children:`Info`}),(0,J.jsx)(B,{value:`Notice`,children:`Notice`}),(0,J.jsx)(B,{value:`Warn`,children:`Warn`}),(0,J.jsx)(B,{value:`Error`,children:`Error`}),(0,J.jsx)(B,{value:`Fatal`,children:`Fatal`})]})]}),(0,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`10px`},children:[(0,J.jsx)(F,{style:{padding:`0px`,margin:`0px`},id:`mjlogger-file-label`,children:`Log on file:`}),(0,J.jsx)(oe,{checked:a,onChange:e=>{K&&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,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,J.jsx)(F,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Mdns interface:`}),(0,J.jsx)(V,{value:s,onChange:e=>{K&&console.log(`handleChangeMdnsInterface called with value:`,e.target.value);let n=e.target.value;c(n),b(()=>{K&&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,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,J.jsx)(F,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Ipv4 address:`}),(0,J.jsx)(V,{value:l,onChange:e=>{K&&console.log(`handleChangeIpv4Address called with value:`,e.target.value);let n=e.target.value;u(n),x(()=>{K&&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,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,J.jsx)(F,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Ipv6 address:`}),(0,J.jsx)(V,{value:d,onChange:e=>{K&&console.log(`handleChangeIpv6Address called with value:`,e.target.value);let n=e.target.value;f(n),S(()=>{K&&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,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,J.jsx)(F,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning port:`}),(0,J.jsx)(V,{value:p,onChange:e=>{K&&console.log(`handleChangeMatterPort called with value:`,e.target.value);let n=e.target.value;m(n),C(()=>{K&&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,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,J.jsx)(F,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning discriminator:`}),(0,J.jsx)(V,{value:h,onChange:e=>{K&&console.log(`handleChangeMatterDiscriminator called with value:`,e.target.value);let n=e.target.value;g(n),w(()=>{K&&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,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,J.jsx)(F,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning passcode:`}),(0,J.jsx)(V,{value:_,onChange:e=>{K&&console.log(`handleChangemMatterPasscode called with value:`,e.target.value);let n=e.target.value;v(n),T(()=>{K&&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 ai({matterbridgeInfo:e}){return e?(0,J.jsxs)(Z,{style:{flex:`1 1 ${ti}px`},children:[(0,J.jsx)(Jt,{children:(0,J.jsx)(Q,{children:`Matterbridge info`})}),(0,J.jsxs)(Qt,{style:{flexDirection:`column`,padding:`10px`,gap:`5px`},children:[(0,J.jsx)(si,{value:e.matterbridgeVersion,label:`Current Version`}),(0,J.jsx)(si,{value:e.matterbridgeLatestVersion,label:`Latest Version`}),(0,J.jsx)(si,{value:e.rootDirectory,label:`Root Directory`}),(0,J.jsx)(si,{value:e.homeDirectory,label:`Home Directory`}),(0,J.jsx)(si,{value:e.matterbridgeDirectory,label:`Matterbridge Storage Directory`}),(0,J.jsx)(si,{value:e.matterbridgePluginDirectory,label:`Matterbridge Plugin Directory`}),(0,J.jsx)(si,{value:e.globalModulesDirectory,label:`Global Module Directory`})]})]}):null}function oi({systemInfo:e}){return e?(0,J.jsxs)(Z,{style:{flex:`1 1 ${ti}px`},children:[(0,J.jsx)(Jt,{children:(0,J.jsx)(Q,{children:`System info`})}),(0,J.jsxs)(Qt,{style:{flexDirection:`column`,padding:`10px`,gap:`5px`},children:[(0,J.jsx)(si,{value:e.interfaceName,label:`Interface name`}),(0,J.jsx)(si,{value:e.macAddress,label:`MAC Address`}),(0,J.jsx)(si,{value:e.ipv4Address,label:`IPv4 Address`}),(0,J.jsx)(si,{value:e.ipv6Address,label:`IPv6 Address`}),(0,J.jsx)(si,{value:e.nodeVersion,label:`Node Version`}),(0,J.jsx)(si,{value:e.hostname,label:`Hostname`}),(0,J.jsx)(si,{value:e.user,label:`User`})]})]}):null}function si({value:e,label:t,width:n}){return(0,J.jsx)(V,{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 ci=(0,W.memo)(ni);function li(){let{online:e,sendMessage:t,addListener:n,removeListener:r,getUniqueId:i}=(0,W.useContext)(Y),{showSnackbarMessage:a}=(0,W.useContext)(Wt),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)([]),[u,d]=(0,W.useState)([]),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)({cpuUsage:0}),[g,_]=(0,W.useState)({totalMemory:``,freeMemory:``,heapTotal:``,heapUsed:``,external:``,arrayBuffers:``,rss:``}),[v,y]=(0,W.useState)({systemUptime:``,processUptime:``}),b=(0,W.useRef)(i());return K&&console.log(`Test uniqueId:`,b),(0,W.useEffect)(()=>{K&&console.log(`Test useEffect WebSocketMessage mounting`);let e=e=>{if(e.method===`restart_required`)K&&console.log(`Test received restart_required`),a(`Restart required`,0);else if(e.method===`refresh_required`)K&&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`)K&&console.log(`Test received memory_update`,e),_(e.response);else if(e.method===`cpu_update`)K&&console.log(`Test received cpu_update`,e),h(e.response);else if(e.method===`uptime_update`)K&&console.log(`Test received uptime_update`,e),y(e.response);else if(e.method===`/api/settings`&&e.response)K&&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)K&&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){K&&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)K&&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&&(K&&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),K&&console.log(`Test useEffect WebSocketMessage mounted`),()=>{K&&console.log(`Test useEffect WebSocketMessage unmounting`),r(e),K&&console.log(`Test useEffect WebSocketMessage unmounted`)}},[n,r,t,a]),(0,W.useEffect)(()=>(K&&console.log(`Test useEffect online mounting`),e&&K&&console.log(`Test useEffect online received online`),K&&console.log(`Test useEffect online mounted`),()=>{K&&console.log(`Test useEffect online unmounted`)}),[e,t,a]),K&&console.log(`Test rendering...`),e?(0,J.jsx)(jn,{name:`Test`,children:(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,justifyContent:`center`,alignItems:`center`,alignContent:`center`,gap:`20px`,height:`100vh`,width:`100vw`},children:[(0,J.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`256px`,width:`256px`,margin:`10px`}}),(0,J.jsx)(`p`,{children:`Welcome to the Test page of the Matterbridge frontend`})]})}):(0,J.jsx)(qt,{})}var ui=(0,W.memo)(li);function di({open:e,title:t,message:n,onConfirm:r,onCancel:i}){return(0,J.jsxs)(M,{open:e,children:[(0,J.jsx)(P,{gap:`20px`,children:(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,J.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,J.jsx)(`h4`,{style:{margin:0},children:t})]})}),(0,J.jsxs)(x,{children:[(0,J.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`center`,margin:`0`,marginBottom:`20px`,maxHeight:`350px`,maxWidth:`350px`},children:(0,J.jsx)(`p`,{style:{flex:1,margin:`0`},children:n})}),(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-around`},children:[(0,J.jsx)(U,{onClick:e=>{K&&console.log(`Confirmed`),e.preventDefault(),r()},variant:`contained`,color:`primary`,size:`small`,children:`Confirm`}),(0,J.jsx)(U,{onClick:e=>{K&&console.log(`Canceled`),e.preventDefault(),i()},variant:`contained`,color:`primary`,size:`small`,children:`Cancel`})]})]})]})}var fi=({open:e,output:t,title:n,_command:r,_packageName:i,onInstall:a,onClose:o})=>{let{installAutoExit:s,mobile:c,setInstallAutoExit:l}=(0,W.useContext)(Wt),u=(0,W.useRef)(null),f=e=>{l(e.target.checked),localStorage.setItem(G.installAutoExit,e.target.checked?`true`:`false`),K&&console.log(`handleInstallAutoExitChange called with value:`,e.target.checked)};return(0,W.useEffect)(()=>{K&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom:`,u.current),setTimeout(()=>{K&&console.log(`Scrolling to bottom:`,u.current),u.current?.scrollIntoView({behavior:`smooth`,block:`end`})},0)},[t]),(0,J.jsxs)(M,{open:e,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||o()},slotProps:{paper:{sx:{width:q&&c?`100vw`:`75vw`,maxWidth:q&&c?`100vw`:`75vw`,height:q&&c?`100vh`:`75vw`,maxHeight:q&&c?`100vh`:`75vh`,margin:q&&c?`0px`:void 0,overflow:`hidden`}}},children:[(0,J.jsx)(P,{children:(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,J.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,J.jsx)(`h4`,{style:{margin:0},children:n})]})}),(0,J.jsxs)(x,{dividers:!0,style:{overflow:`hidden`,display:`flex`,flexDirection:`column`,height:400,paddingBottom:0},children:[(0,J.jsx)(`div`,{style:{display:`block`,marginBottom:`10px`,fontSize:`16px`,fontWeight:`bold`,color:`var(--primary-color)`},children:`Process log`}),(0,J.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,
|
|
44
|
-
`)},[]),
|
|
42
|
+
`,t.head.appendChild(a)},[ce,le]=(0,G.useState)(),[ue,de]=(0,G.useState)(!1),fe=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}}),le(e),pe()},pe=()=>{de(!0)};return q&&console.log(`HomePlugins rendering...`),n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Q,{children:[ce&&(0,Y.jsx)(xr,{open:ue,onClose:()=>{de(!1)},plugin:ce}),(0,Y.jsx)(Cn,{name:`Plugins`,columns:w,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)(I,{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:se,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)(Kt,{})}var wr=(0,G.memo)(Cr);function Tr({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)(qt,{children:(0,Y.jsx)(Jt,{children:`Matterbridge Update`})}),(0,Y.jsxs)(Qt,{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)(Kt,{})}var Er=(0,G.memo)(Tr);function Dr({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})})}var Or=new Map([[`matterbridgeVersion`,`Matterbridge version`],[`frontendVersion`,`Frontend version`],[`dockerVersion`,`Docker version`],[`homeDirectory`,`Home`],[`rootDirectory`,`Root`],[`matterbridgeDirectory`,`Storage`],[`matterbridgeCertDirectory`,`Cert`],[`matterbridgePluginDirectory`,`Plugins`],[`globalModulesDirectory`,`Modules`],[`bridgeMode`,`Bridge mode`],[`restartMode`,`Restart mode`],[`virtualMode`,`Virtual mode`],[`bridgeStatus`,`Bridge status`],[`profile`,`Profile`],[`loggerLevel`,`Logger level`],[`fileLogger`,`File logger`],[`matterLoggerLevel`,`Matter logger level`],[`matterFileLogger`,`Matter file logger`],[`restartRequired`,`Restart required`],[`updateRequired`,`Update required`]]),kr=new Set([`matterbridgeLatestVersion`,`matterbridgeDevVersion`,`dockerDev`,`dockerLatestVersion`,`dockerDevVersion`,`fixedRestartRequired`,`matterMdnsInterface`,`matterIpv4Address`,`matterIpv6Address`,`readOnly`,`shellyBoard`,`shellySysUpdate`,`shellyMainUpdate`,`matterPort`,`matterDiscriminator`,`matterPasscode`]);function Ar({matterbridgeInfo:e}){let{mobile:t}=(0,G.useContext)(Ut);q&&console.log(`MatterbridgeInfoTable:`,e);let[n,r]=(0,G.useState)(!1);return!e||n?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)(qt,{children:[(0,Y.jsx)(Jt,{children:`Matterbridge info`}),(0,Y.jsx)($t,{close:()=>r(!0)})]}),(0,Y.jsx)(Qt,{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])=>!kr.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:Or.get(e)??e}),(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)(Dr,{value:typeof n==`string`?n:n.toString(),maxChars:24})})]},e))})]})})]}))}var jr=(0,G.memo)(Ar),Mr={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`}},Nr=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 Pr({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)(Ut);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)(qt,{children:[(0,Y.jsx)(Jt,{children:`QR pairing code`}),(0,Y.jsxs)($t,{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)(Zt,{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)(Yt,{style:{justifyContent:`space-between`},children:[(0,Y.jsxs)(Xt,{style:{fontWeight:`normal`,color:`var(--div-text-color)`},children:[`Manual pairing code: `,Nr(o.manualPairingCode)]}),(0,Y.jsx)($t,{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:Mr,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)(qt,{children:[(0,Y.jsx)(Jt,{children:`Paired fabrics`}),(0,Y.jsxs)($t,{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)(Zt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,Y.jsx)(Qt,{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:{...Mr,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)(Yt,{style:{justifyContent:`center`,height:`auto`,minHeight:`30px`},children:(0,Y.jsxs)(Xt,{style:{fontWeight:`normal`,overflowWrap:`anywhere`,textAlign:`center`},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)(qt,{children:(0,Y.jsx)(Jt,{children:`QR pairing code`})}),(0,Y.jsx)(Zt,{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)(Yt,{style:{justifyContent:`center`,height:`auto`,minHeight:`30px`},children:(0,Y.jsxs)(Xt,{style:{fontWeight:`normal`,overflowWrap:`anywhere`,textAlign:`center`},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)(qt,{style:{height:`30px`,justifyContent:`space-between`},children:(0,Y.jsx)(Jt,{children:`Server node`})}),(0,Y.jsx)(Zt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,Y.jsx)(Zt,{style:{fontWeight:`bold`},children:`Server offline`}),(0,Y.jsx)(Yt,{style:{justifyContent:`center`,height:`auto`,minHeight:`30px`},children:(0,Y.jsxs)(Xt,{style:{fontWeight:`normal`,overflowWrap:`anywhere`,textAlign:`center`},children:[`Serial number: `,o.serialNumber]})})]}))}var Fr=(0,G.memo)(Pr),Ir=new Map([[`interfaceName`,`Interface name`],[`macAddress`,`Mac address`],[`ipv4Address`,`IPv4 address`],[`ipv6Address`,`IPv6 address`],[`nodeVersion`,`Node version`],[`bunVersion`,`Bun version`],[`hostname`,`Hostname`],[`user`,`User`],[`osType`,`Os`],[`osPlatform`,`Platform`],[`freeMemory`,`Memory`],[`systemUptime`,`System uptime`],[`processUptime`,`Process uptime`],[`cpuUsage`,`Host CPU`],[`processCpuUsage`,`Process CPU`],[`rss`,`Rss`],[`heapUsed`,`Heap`]]);function Lr({systemInfo:e,compact:t}){let{mobile:n}=(0,G.useContext)(Ut),{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)(qt,{children:[(0,Y.jsx)(Jt,{children:`System info`}),(0,Y.jsx)($t,{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)(Qt,{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])=>e!==`bunVersion`&&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:Ir.get(e)??e}),(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)(Dr,{value:typeof t==`string`?t:t.toString(),maxChars:22})})]},e))})]})})]}))}var Rr=(0,G.memo)(Lr);function zr(){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)(Ut),{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===`update_required`&&(q&&console.log(`Home received update_required`,e.response),e.response.devVersion?r(t=>t?{...t,matterbridgeDevVersion:e.response.version}:null):r(t=>t?{...t,matterbridgeLatestVersion:e.response.version}:null)),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)(Kt,{}):(0,Y.jsxs)(An,{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)(Fr,{id:h}),(0,Y.jsx)(Rr,{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)(Pn,{version:n.frontendVersion}),d&&(0,Y.jsx)(Er,{version:n.matterbridgeVersion,changelog:l}),J&&_&&(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:`10px`},children:[(0,Y.jsx)(Fr,{id:h}),(0,Y.jsx)(Rr,{systemInfo:e,compact:!0}),(0,Y.jsx)(jr,{matterbridgeInfo:n})]}),o&&!n.readOnly&&(0,Y.jsx)(Zn,{}),o&&(0,Y.jsx)(wr,{storeId:h,setStoreId:g}),s===`devices`&&(0,Y.jsx)(Rn,{storeId:h,setStoreId:g}),s===`logs`&&(0,Y.jsx)(nr,{})]})]})}var Br=(0,G.memo)(zr);function Vr(){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)(An,{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)(R,{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)(R,{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)(er,{})})]}):(0,Y.jsx)(Kt,{})}var Hr=(0,G.memo)(Vr),Ur=1200,Wr,Gr;function Kr(e,t){Wr=e,Gr=t}function qr(){let{mobile:e,showSnackbarMessage:t,showConfirmCancelDialog:n}=(0,G.useContext)(Ut),{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,E]=(0,G.useState)(`inactive`),D=(0,G.useRef)(d()),[O,k]=(0,G.useState)(null),[A,j]=(0,G.useState)(null),[M,N]=(0,G.useState)(null),[te,P]=(0,G.useState)(null),ne=r(),F=()=>{window.open(`https://www.buymeacoffee.com/luligugithub`,`_blank`)},re=()=>{window.open(`https://matterbridge.io/`)},I=()=>{window.open(`https://matterbridge.io/README.html`)},ie=()=>{window.open(`https://matterbridge.io/CHANGELOG.html`)},ae=()=>{window.open(`https://discord.gg/QX58CDe6hd`,`_blank`)},L=()=>{window.open(`https://github.com/Luligu/matterbridge`,`_blank`)},oe=()=>{a({id:D.current,sender:`Header`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:`matterbridge`,restart:!0}}),y(!1)},se=()=>{a({id:D.current,sender:`Header`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:`matterbridge@dev`,restart:!0}}),x(!1)},le=()=>{a({id:D.current,sender:`Header`,method:`/api/checkupdates`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ue=()=>{q&&console.log(`Header: handleShellySystemUpdateClick`),o(`Matterbridge`,`Installing system updates...`),a({id:D.current,sender:`Header`,method:`/api/shellysysupdate`,src:`Frontend`,dst:`Matterbridge`,params:{}})},de=()=>{q&&console.log(`Header: handleShellyMainUpdateClick`),o(`Matterbridge`,`Installing software updates...`),a({id:D.current,sender:`Header`,method:`/api/shellymainupdate`,src:`Frontend`,dst:`Matterbridge`,params:{}})},fe=()=>{q&&console.log(`Header: handleShellyCreateSystemLog`),a({id:D.current,sender:`Header`,method:`/api/shellycreatesystemlog`,src:`Frontend`,dst:`Matterbridge`,params:{}})},pe=()=>{q&&console.log(`Header: handleShellyDownloadSystemLog`),o(`Matterbridge`,`Downloading Shelly system log...`),t(`Downloading Shelly system log...`,5),window.location.href=`./api/shellydownloadsystemlog`},me=()=>{S?.matterbridgeInformation.restartMode===`none`?a({id:D.current,sender:`Header`,method:`/api/restart`,src:`Frontend`,dst:`Matterbridge`,params:{}}):a({id:D.current,sender:`Header`,method:`/api/shutdown`,src:`Frontend`,dst:`Matterbridge`,params:{}})},he=()=>{a({id:D.current,sender:`Header`,method:`/api/shutdown`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ge=()=>{a({id:D.current,sender:`Header`,method:`/api/reboot`,src:`Frontend`,dst:`Matterbridge`,params:{}})},_e=()=>{a({id:D.current,sender:`Header`,method:`/api/softreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ve=()=>{a({id:D.current,sender:`Header`,method:`/api/hardreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ye=e=>{k(e.currentTarget)},R=e=>{q&&console.log(`Header: handleMenuClose`,e),k(null),e===`/`||e===`/devices`||e===`/log`||e===`/settings`?ne(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:D.current,sender:`Header`,method:`/api/viewhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`download-history`?a({id:D.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`?oe():e===`updatedev`?se():e===`updatecheck`?le():e===`shelly-sys-update`?ue():e===`shelly-main-update`?de():e===`shelly-create-system-log`?fe():e===`shelly-download-system-log`?pe():e===`softreset`?_e():e===`hardreset`?ve():e===`restart`?me():e===`shutdown`?he():e===`reboot`?ge():e===`create-backup`?a({id:D.current,sender:`Header`,method:`/api/create-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-matterbridge-storage-backup`?a({id:D.current,sender:`Header`,method:`/api/create-matterbridge-storage-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-matter-storage-backup`?a({id:D.current,sender:`Header`,method:`/api/create-matter-storage-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-plugin-backup`?a({id:D.current,sender:`Header`,method:`/api/create-plugin-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-config-backup`?a({id:D.current,sender:`Header`,method:`/api/create-config-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`unregister`?a({id:D.current,sender:`Header`,method:`/api/unregister`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`reset`?a({id:D.current,sender:`Header`,method:`/api/reset`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`factoryreset`&&a({id:D.current,sender:`Header`,method:`/api/factoryreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},xe=e=>{q&&console.log(`Header: handleMenuCloseCancel:`,e),k(null)},Se=e=>{j(e.currentTarget)},Ce=()=>{j(null)},we=e=>{N(e.currentTarget)},Te=()=>{N(null)},Ee=e=>{P(e.currentTarget)},De=()=>{P(null)};return(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`Header received WebSocket Message:`,e),e.method===`/api/settings`&&e.id===D.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(e.response.matterbridgeInformation.bridgeStatus)):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:D.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===`matterbridge_status_update`?(q&&console.log(`Header received matterbridge_status_update: ${e.response.status}`),E(e.response.status)):e.method===`update_required`?(q&&console.log(`Header received update_required`),e.response.devVersion?(C(t=>t?{...t,matterbridgeInformation:{...t.matterbridgeInformation,matterbridgeDevVersion:e.response.version}}:null),x(!0)):(C(t=>t?{...t,matterbridgeInformation:{...t.matterbridgeInformation,matterbridgeLatestVersion:e.response.version}}:null),y(!0))):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===D.current&&e.success?(q&&console.log(`Header received /api/viewhistorypage success`),window.open(`./api/viewhistory`,`_blank`,`noopener,noreferrer`)):e.method===`/api/downloadhistorypage`&&e.id===D.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,D.current),q&&console.log(`Header added WebSocket listener id ${D.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:D.current,sender:`Header`,method:`/api/settings`,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`,backgroundColor:_?`var(--primary-color)`:b?`var(--secondary-color)`:`green`},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!==`none`&&!S.matterbridgeInformation.readOnly?(0,Y.jsx)(H,{title:`Bridge mode`,children:(0,Y.jsx)(`span`,{className:`status-information`,style:{cursor:`default`,backgroundColor:w===`started`?`green`:w===`error`?`red`:void 0},children:S.matterbridgeInformation.bridgeMode})}):null,S.matterbridgeInformation.restartMode!==`none`&&!S.matterbridgeInformation.readOnly?(0,Y.jsx)(H,{title:`Restart mode`,children:(0,Y.jsx)(`span`,{className:`status-information`,style:{cursor:`default`,backgroundColor:`green`},children:S.matterbridgeInformation.restartMode})}):null,S.systemInformation.bunVersion?(0,Y.jsx)(H,{title:`Bun version`,children:(0,Y.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`,backgroundColor:`green`},children:[`bun v.`,S.systemInformation.bunVersion]})}):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`,backgroundColor:`green`},children:S.matterbridgeInformation.profile})}):null,q&&(0,Y.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`,backgroundColor:`green`},children:[e?`Mobile `:`Desktop `,`${Wr}x${Gr}`,` 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:ae,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:L,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:re,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:ie,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:oe,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:se,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:ue,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:de,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:me,children:(0,Y.jsx)(ot,{})})}),S.matterbridgeInformation.restartMode===`none`?(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:he,children:(0,Y.jsx)(be,{})})}):null,(0,Y.jsx)(H,{title:`Download, backup and more`,children:(0,Y.jsx)(T,{onClick:ye,children:(0,Y.jsx)(We,{style:{color:`var(--main-icon-color)`}})})}),(0,Y.jsxs)(ct,{id:`command-menu`,anchorEl:O,keepMounted:!0,open:!!O,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===`none`?(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,xe)},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)(ee,{}),(0,Y.jsxs)(V,{onClick:Se,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:A,keepMounted:!0,open:!!A,onClose:Ce,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,Y.jsxs)(V,{onClick:()=>{Ft(),Ce(),xe(``),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(),Ce(),xe(``),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`),Ce()},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`),Ce()},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`),Ce()},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`),Ce()},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`),Ce()},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)(ee,{}),(0,Y.jsxs)(V,{onClick:we,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:M,keepMounted:!0,open:!!M,onClose:Te,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,Y.jsxs)(V,{onClick:()=>{R(`create-matterbridge-storage-backup`),Te()},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`),Te()},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`),Te()},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`),Te()},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`),Te()},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`),Te()},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`),Te()},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`),Te()},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`),Te()},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`),Te()},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)(ee,{}),(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)(ee,{}),(0,Y.jsxs)(V,{onClick:Ee,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:te,keepMounted:!0,open:!!te,onClose:De,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,Y.jsxs)(V,{onClick:()=>{De(),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,xe)},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:()=>{De(),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,xe)},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:()=>{De(),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,xe)},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:()=>{De(),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,xe)},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:()=>{De(),n(`Network reset`,`Are you sure you want to factory reset the network parameters?`,`softreset`,R,xe)},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:()=>{De(),n(`Factory reset`,`Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.`,`hardreset`,R,xe)},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 Jr=(0,G.memo)(qr);function Yr(){if(typeof window<`u`){let e=Math.floor(window.visualViewport?.width??window.innerWidth),t=Math.floor(window.visualViewport?.height??window.innerHeight);Kr(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 Xr({children:e}){let{mobile:t,setMobile:n}=(0,G.useContext)(Ut),{logAutoScroll:r}=(0,G.useContext)(X);return(0,G.useEffect)(()=>{function e(){let e=Yr();e&&(r.current=!1,localStorage.setItem(K.logAutoScroll,`false`)),n(e)}return window.addEventListener(`resize`,e),n(Yr()),()=>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)(Jr,{}),(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?`${Ur}px`:`calc(100vw - 40px)`,height:t?`900px`:`calc(100vh - 40px)`,margin:`0px`,padding:`20px`,gap:`20px`},children:[(0,Y.jsx)(Jr,{}),(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,width:`100%`,height:`calc(100% - 60px)`,margin:`0px`,padding:`0px`,gap:`20px`},children:e})]})}function Zr(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 Qr=({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)(P,{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)(I,{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`})]})]})},$r=({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)(P,{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)(I,{dividers:!0,children:[(0,Y.jsxs)(Fe,{component:`fieldset`,fullWidth:!0,children:[(0,Y.jsx)(F,{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`})]})]})},ei=330;function ti(){let{mobile:e}=(0,G.useContext)(Ut),{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===`update_required`?(q&&console.log(`Settings received update_required`,e.response),e.response.devVersion?s(t=>t?{...t,matterbridgeDevVersion:e.response.version}:null):s(t=>t?{...t,matterbridgeLatestVersion:e.response.version}:null)):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)(Kt,{}):(0,Y.jsx)(An,{name:`Settings`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:J&&e?`10px`:`20px`},children:[(0,Y.jsx)(ni,{matterbridgeInfo:o,systemInfo:c}),(0,Y.jsx)(ri,{matterbridgeInfo:o}),(0,Y.jsx)(ii,{matterbridgeInfo:o}),(0,Y.jsx)(ai,{systemInfo:c})]})})}function ni({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 ${ei}px`},children:[(0,Y.jsx)(qt,{children:(0,Y.jsx)(Jt,{children:`Matterbridge settings`})}),(0,Y.jsx)($r,{open:b,ip:t.ipv4Address,onClose:S,onSave:C}),(0,Y.jsx)(Qr,{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)(Qt,{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)(F,{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)(F,{style:{padding:`0px`,margin:`0px`},id:`mblogger-level-label`,children:`Logger level:`}),(0,Y.jsxs)(R,{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)(F,{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)(F,{style:{padding:`0px`,margin:`0px`},id:`frontend-theme-label`,children:`Frontend theme:`}),(0,Y.jsxs)(R,{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)(F,{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)(F,{style:{padding:`0px`,margin:`0px`},id:`frontend-home-label`,children:`Home page bottom panel:`}),(0,Y.jsxs)(R,{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)(F,{style:{padding:`0px`,margin:`0px`},id:`frontend-virtual-label`,children:`Virtual devices:`}),(0,Y.jsxs)(R,{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 ri({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)(()=>Zr(1e3),[]),x=(0,G.useMemo)(()=>Zr(1e3),[]),S=(0,G.useMemo)(()=>Zr(1e3),[]),C=(0,G.useMemo)(()=>Zr(1e3),[]),w=(0,G.useMemo)(()=>Zr(1e3),[]),T=(0,G.useMemo)(()=>Zr(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 ${ei}px`},children:[(0,Y.jsx)(qt,{children:(0,Y.jsx)(Jt,{children:`Matter settings`})}),(0,Y.jsxs)(Qt,{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)(F,{style:{padding:`0px`,margin:`0px`},id:`mjlogger-level-label`,children:`Logger level:`}),(0,Y.jsxs)(R,{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)(F,{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)(F,{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)(F,{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)(F,{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)(F,{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)(F,{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)(F,{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 ii({matterbridgeInfo:e}){return e?(0,Y.jsxs)(Q,{style:{flex:`1 1 ${ei}px`},children:[(0,Y.jsx)(qt,{children:(0,Y.jsx)(Jt,{children:`Matterbridge info`})}),(0,Y.jsxs)(Qt,{style:{flexDirection:`column`,padding:`10px`,gap:`5px`},children:[(0,Y.jsx)(oi,{value:e.matterbridgeVersion,label:`Current Version`}),(0,Y.jsx)(oi,{value:e.matterbridgeLatestVersion,label:`Latest Version`}),(0,Y.jsx)(oi,{value:e.rootDirectory,label:`Root Directory`}),(0,Y.jsx)(oi,{value:e.homeDirectory,label:`Home Directory`}),(0,Y.jsx)(oi,{value:e.matterbridgeDirectory,label:`Matterbridge Storage Directory`}),(0,Y.jsx)(oi,{value:e.matterbridgePluginDirectory,label:`Matterbridge Plugin Directory`}),(0,Y.jsx)(oi,{value:e.globalModulesDirectory,label:`Global Module Directory`})]})]}):null}function ai({systemInfo:e}){return e?(0,Y.jsxs)(Q,{style:{flex:`1 1 ${ei}px`},children:[(0,Y.jsx)(qt,{children:(0,Y.jsx)(Jt,{children:`System info`})}),(0,Y.jsxs)(Qt,{style:{flexDirection:`column`,padding:`10px`,gap:`5px`},children:[(0,Y.jsx)(oi,{value:e.interfaceName,label:`Interface name`}),(0,Y.jsx)(oi,{value:e.macAddress,label:`MAC Address`}),(0,Y.jsx)(oi,{value:e.ipv4Address,label:`IPv4 Address`}),(0,Y.jsx)(oi,{value:e.ipv6Address,label:`IPv6 Address`}),(0,Y.jsx)(oi,{value:e.nodeVersion,label:`Node Version`}),(0,Y.jsx)(oi,{value:e.hostname,label:`Hostname`}),(0,Y.jsx)(oi,{value:e.user,label:`User`})]})]}):null}function oi({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 si=(0,G.memo)(ti);function ci(){let{online:e,sendMessage:t,addListener:n,removeListener:r,getUniqueId:i}=(0,G.useContext)(X),{showSnackbarMessage:a}=(0,G.useContext)(Ut),[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)(An,{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)(Kt,{})}var li=(0,G.memo)(ci);function ui({open:e,title:t,message:n,onConfirm:r,onCancel:i}){return(0,Y.jsxs)(D,{open:e,children:[(0,Y.jsx)(P,{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)(I,{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 di=({open:e,output:t,title:n,_command:r,_packageName:i,onInstall:a,onClose:o})=>{let{installAutoExit:s,mobile:c,setInstallAutoExit:l}=(0,G.useContext)(Ut),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)(P,{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)(I,{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)`}})]})]})},fi=[];function pi({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=fi.findIndex(t=>t.message===e);t!==-1&&(o(fi[t].key),fi.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}`),fi.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,ee]=(0,G.useState)(localStorage.getItem(K.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+`
|
|
44
|
+
`)},[]),ne=(0,G.useCallback)(()=>{q&&console.log(`UiProvider exitInstallProgressSuccess: package ${k}`),localStorage.getItem(K.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:N,setInstallAutoExit:ee}),[t,r,n,i,c,s,o,x,te,ne,F,re,P,N,ee]);return(0,Y.jsxs)(Ut.Provider,{value:ie,children:[(0,Y.jsx)(ui,{open:l,title:d,message:p,onConfirm:y,onCancel:b}),(0,Y.jsx)(di,{open:S,title:w,_command:D,_packageName:k,output:j,onClose:I}),e]})}function mi(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 hi(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 gi({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=(0,G.useCallback)(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)}},[e]);return(0,G.useEffect)(()=>{c(``)},[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 _i(){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=mi(`--primary-color`,`#1976d2`);q&&console.log(`Primary color from CSS "%s"`,o);let s=hi(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+`/`;Vt(d);let 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)(pi,{children:(0,Y.jsx)(Gt,{children:(0,Y.jsx)(a,{basename:d,children:(0,Y.jsx)(Xr,{children:(0,Y.jsxs)(c,{children:[(0,Y.jsx)(i,{path:`/`,element:(0,Y.jsx)(Br,{})}),(0,Y.jsx)(i,{path:`/devices`,element:(0,Y.jsx)(Mn,{})}),(0,Y.jsx)(i,{path:`/log`,element:(0,Y.jsx)(Hr,{})}),(0,Y.jsx)(i,{path:`/settings`,element:(0,Y.jsx)(si,{})}),(0,Y.jsx)(i,{path:`/test`,element:(0,Y.jsx)(li,{})}),(0,Y.jsx)(i,{path:`*`,element:(0,Y.jsx)(n,{to:`/`})})]})})})})})})}):(0,Y.jsx)(gi,{setLoggedIn:t})}var vi=document.getElementById(`root`);if(vi===null)throw Error(`Root element not found`);At.createRoot(vi).render((0,Y.jsx)(G.StrictMode,{children:(0,Y.jsx)(_i,{})}));
|