@matterbridge/frontend 3.4.9 → 3.4.10-dev-20260329-5cac980
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 +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/build/assets/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{a as e}from"./rolldown-runtime.js";import{c as t}from"./vendor_emotion.js";import{c as n,d as r,f as i,l as a,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,L as A,Lt as j,M as ee,Mt as M,N,Nt as P,O as te,Ot as ne,P as re,Pt as ie,Q as ae,R as oe,Rt as F,S as se,St as ce,T as le,Tt as ue,U as de,Ut as fe,V as pe,Vt as I,W as me,Wt as L,X as he,Y as ge,Z as _e,_ as ve,_t as R,a as ye,at as be,b as xe,bt as z,c as Se,ct as Ce,d as we,dt as B,et as Te,f as Ee,ft as V,g as De,gt as Oe,h as ke,ht as Ae,i as je,it as Me,j as Ne,jt as Pe,k as Fe,kt as Ie,l as Le,lt as Re,m as ze,mt as Be,n as Ve,nt as He,o as Ue,ot as We,p as Ge,pt as Ke,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 st,y as ct,yt as H,z as lt,zt as U}from"./vendor_mui.js";import{_ as ut,a as dt,h as ft,j as pt,o as mt,r as ht,s as gt,v as _t}from"./vendor_mdi.js";import{n as vt,t as yt}from"./vendor_notistack.js";import{t as bt}from"./vendor_qrcode.js";import{a as xt,c as St,i as Ct,l as wt,n as Tt,o as Et,r as Dt,s as Ot,t as kt}from"./vendor_rjsf.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var At=e(i(),1),W=e(t(),1),G=C();function jt({open:e,title:t,message:n,onConfirm:r,onCancel:i}){return(0,G.jsxs)(x,{open:e,children:[(0,G.jsx)(M,{gap:`20px`,children:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,G.jsx)(`h4`,{style:{margin:0},children:t})]})}),(0,G.jsxs)(P,{children:[(0,G.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`center`,margin:`0`,marginBottom:`20px`,maxHeight:`350px`,maxWidth:`350px`},children:(0,G.jsx)(`p`,{style:{flex:1,margin:`0`},children:n})}),(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-around`},children:[(0,G.jsx)(j,{onClick:e=>{Q&&console.log(`Confirmed`),e.preventDefault(),r()},variant:`contained`,color:`primary`,size:`small`,children:`Confirm`}),(0,G.jsx)(j,{onClick:e=>{Q&&console.log(`Canceled`),e.preventDefault(),i()},variant:`contained`,color:`primary`,size:`small`,children:`Cancel`})]})]})]})}var 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`},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(K).forEach(e=>{localStorage.removeItem(e)}),Object.values(Mt).forEach(e=>{localStorage.removeItem(e)})}var Pt=({open:e,output:t,title:n,_command:r,_packageName:i,onInstall:a,onClose:o})=>{let{installAutoExit:s,setInstallAutoExit:c}=(0,W.useContext)(It),l=(0,W.useRef)(null),u=e=>{c(e.target.checked),localStorage.setItem(K.installAutoExit,e.target.checked?`true`:`false`),Q&&console.log(`handleInstallAutoExitChange called with value:`,e.target.checked)};return(0,W.useEffect)(()=>{Q&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom: ${l.current}`),setTimeout(()=>{Q&&console.log(`Scrolling to bottom:`,l.current),l.current?.scrollIntoView({behavior:`smooth`,block:`end`})},0)},[t]),(0,G.jsxs)(x,{open:e,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||o()},slotProps:{paper:{sx:{width:`70vw`,maxWidth:`70vw`,height:`70vw`,maxHeight:`70vh`,overflow:`hidden`}}},children:[(0,G.jsx)(M,{children:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,G.jsx)(`h4`,{style:{margin:0},children:n})]})}),(0,G.jsxs)(P,{dividers:!0,style:{overflow:`hidden`,display:`flex`,flexDirection:`column`,height:400,paddingBottom:0},children:[(0,G.jsx)(`label`,{style:{display:`block`,marginBottom:`10px`,fontSize:`16px`,fontWeight:`bold`,color:`var(--primary-color)`},children:`Process log`}),(0,G.jsxs)(`ul`,{style:{width:`100%`,height:`100%`,fontFamily:`monospace`,fontSize:`14px`,padding:`10px`,margin:0,marginBottom:`10px`,color:`var(--div-text-color)`,background:`var(--div-bg-color)`,overflow:`auto`,listStyle:`none`,boxSizing:`border-box`,borderRadius:4,border:`4px solid var(--primary-color)`,whiteSpace:`pre-wrap`,display:`block`},children:[t.split(`
|
|
2
2
|
`).map((e,t)=>(0,G.jsx)(`li`,{style:{padding:0,margin:0,wordBreak:`break-all`},children:e},t)),(0,G.jsx)(`li`,{ref:l,style:{padding:0,margin:0}})]})]}),(0,G.jsxs)(ie,{sx:{justifyContent:`space-evenly`},children:[a&&(0,G.jsx)(j,{variant:`contained`,onClick:a,children:`Install`}),(0,G.jsx)(j,{onClick:o,children:`Close`}),(0,G.jsx)(Ie,{control:(0,G.jsx)(D,{checked:s,onChange:e=>u(e)}),label:`Close on success`,style:{color:`var(--div-text-color)`}})]})]})},Ft=[],It=(0,W.createContext)(null);function Lt({children:e}){let[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(null),{enqueueSnackbar:a,closeSnackbar:o}=vt(),s=(0,W.useCallback)(e=>{Q&&console.log(`UiProvider closeSnackbarMessage: message ${e}`);let t=Ft.findIndex(t=>t.message===e);t!==-1&&(o(Ft[t].key),Ft.splice(t,1),Q&&console.log(`UiProvider closeSnackbarMessage: message ${e} removed from persistMessages`))},[o]),c=(0,W.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,G.jsx)(F,{sx:{margin:`0`,padding:`0`,width:`300px`,marginRight:`30px`},children:(0,G.jsx)(p,{severity:n??`info`,variant:`filled`,sx:{color:`#fff`,fontWeight:`normal`,width:`100%`,cursor:`pointer`,padding:`0px 10px`},onClick:()=>o(t),action:(0,G.jsx)(I,{size:`small`,onClick:()=>o(t),sx:{color:`#fff`},children:(0,G.jsx)(tt,{fontSize:`small`})}),children:e},t)},t)});t===0&&(Q&&console.log(`UiProvider showSnackbarMessage: message ${e} timeout ${t} - persist key ${r}`),Ft.push({message:e,key:r}))},[a,o]),[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(``),[m,h]=(0,W.useState)(``),[g,_]=(0,W.useState)(``),v=(0,W.useRef)(null),y=(0,W.useRef)(null),b=()=>{Q&&console.log(`UiProvider handle confirm action ${g}`),u(!1),v.current&&v.current(g)},x=()=>{Q&&console.log(`UiProvider handle cancel action ${g}`),u(!1),y.current&&y.current(g)},S=(0,W.useCallback)((e,t,n,r,i)=>{Q&&console.log(`UiProvider showConfirmCancelDialog for command ${n}`),f(e),h(t),_(n),v.current=r,y.current=i,u(!0)},[]),[C,w]=(0,W.useState)(!1),[T,E]=(0,W.useState)(``),[D,O]=(0,W.useState)(``),[k,A]=(0,W.useState)(``),[j,ee]=(0,W.useState)(``),[M,N]=(0,W.useState)(localStorage.getItem(K.installAutoExit)!==`false`),P=(0,W.useCallback)((e,t,n)=>{Q&&console.log(`UiProvider show install progress for package ${e}`),E(e),O(t),A(n),w(!0)},[]),te=(0,W.useCallback)(e=>{Q&&console.log(`UiProvider addInstallProgress: output ${e}`),ee(t=>t+e+`
|
|
3
3
|
`)},[]),ne=(0,W.useCallback)(()=>{Q&&console.log(`UiProvider exitInstallProgressSuccess: package ${k}`),localStorage.getItem(K.installAutoExit)!==`false`&&w(!1)},[k]),re=(0,W.useCallback)(()=>{Q&&console.log(`UiProvider exitInstallProgressError: package ${k}`)},[k]),ie=(0,W.useCallback)(()=>{Q&&console.log(`UiProvider hide install progress`),w(!1)},[]),ae=()=>{Q&&console.log(`UiProvider handle install close action`),w(!1),A(``),ee(``)},oe=(0,W.useMemo)(()=>({mobile:t,setMobile:n,currentPage:r,setCurrentPage:i,showSnackbarMessage:c,closeSnackbarMessage:s,closeSnackbar:o,showConfirmCancelDialog:S,showInstallProgress:P,exitInstallProgressSuccess:ne,exitInstallProgressError:re,hideInstallProgress:ie,addInstallProgress:te,installAutoExit:M,setInstallAutoExit:N}),[t,r,n,i,c,s,o,S,P,ne,re,ie,te,M,N]);return(0,G.jsxs)(It.Provider,{value:oe,children:[(0,G.jsx)(jt,{open:l,title:d,message:m,onConfirm:b,onCancel:x}),(0,G.jsx)(Pt,{open:C,title:T,_command:D,_packageName:k,output:j,onClose:ae}),e]})}var Rt=(0,W.createContext)(null),q=(0,W.createContext)(null);function zt({children:e}){let[t,n]=(0,W.useState)([]),[r,i]=(0,W.useState)(localStorage.getItem(K.logFilterLevel)??`info`),[a,o]=(0,W.useState)(localStorage.getItem(K.logFilterSearch)??`*`),[s,c]=(0,W.useState)(!1),{showSnackbarMessage:l,closeSnackbarMessage:u,closeSnackbar:d,showInstallProgress:f,hideInstallProgress:p,exitInstallProgressSuccess:m,exitInstallProgressError:h,addInstallProgress:g}=(0,W.useContext)(It),_=(0,W.useRef)([]),v=(0,W.useRef)(null),y=(0,W.useRef)(1),b=(0,W.useRef)(Math.floor(Math.random()*999e3)+1e3),x=(0,W.useRef)(null),S=(0,W.useRef)(null),C=(0,W.useRef)(null),w=(0,W.useRef)(r),T=(0,W.useRef)(a),E=(0,W.useRef)(0),D=(0,W.useRef)(null),O=(0,W.useRef)(Number(localStorage.getItem(K.logLength)??200)),k=(0,W.useRef)(localStorage.getItem(K.logAutoScroll)!==`false`),A=(0,W.useMemo)(()=>window.location.href.replace(/^http/,`ws`),[]);(0,W.useEffect)(()=>(Q&&console.log(`WebSocket messages started counter interval`),D.current=setInterval(()=>{E.current>0&&(Q&&console.log(`WebSocket messages received in the last 10 seconds: ${E.current*(60/10)} messages/minute`),E.current=0)},10*1e3),()=>{Q&&console.log(`WebSocket messages stopped counter interval`),D.current&&clearInterval(D.current),D.current=null}),[]),(0,W.useEffect)(()=>{w.current=r},[r]),(0,W.useEffect)(()=>{T.current=a},[a]);let j=(0,W.useCallback)(()=>Math.floor(Math.random()*999e3)+1e3,[]),ee=(0,W.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}})())))},[]),M=(0,W.useCallback)(e=>{if(v.current&&v.current.readyState===WebSocket.OPEN)try{Q&&console.log(`WebSocket sending message with id ${e.id}:`,e),e.id===void 0&&(e.id=b.current);let t=JSON.stringify(e);v.current.send(t),Q&&console.log(`WebSocket sent message:`,e)}catch(e){Q&&console.error(`WebSocket error sending message: ${e}`)}else Q&&console.error(`WebSocket message not sent, WebSocket not connected:`,e)},[]),N=(0,W.useCallback)((e,t)=>{n(n=>[...n,{level:e,time:``,name:``,message:t}])},[]),P=(0,W.useCallback)((e,t)=>{Q&&console.log(`WebSocket addListener id ${t}:`,e),(t==null||isNaN(t)||t===0)&&console.error(`WebSocket addListener called without id, listener not added:`,e),_.current=[..._.current,{listener:e,id:t}],Q&&console.log(`WebSocket addListener total listeners:`,_.current.length)},[]),te=(0,W.useCallback)(e=>{Q&&console.log(`WebSocket removeListener:`,e),_.current=_.current.filter(t=>t.listener!==e),Q&&console.log(`WebSocket removeListener total listeners:`,_.current.length)},[]),ne=(0,W.useCallback)(()=>{A===``||A==null||(N(`WebSocket`,`Connecting ${ii?`with password`:``} to WebSocket: ${A}`),Q&&console.log(`WebSocket connecting to: ${A}${ii?`?password=[redacted]`:``}`),v.current=new WebSocket(A+(ii?`?password=${encodeURIComponent(ii)}`:``)),v.current.onmessage=e=>{s||c(!0),E.current+=1;try{let t=JSON.parse(e.data);if(t.id===void 0||t.src===void 0||t.dst===void 0){Q&&console.error(`WebSocket undefined message id/src/dst:`,t);return}if(t.src!==`Matterbridge`||t.dst!==`Frontend`){Q&&console.error(`WebSocket invalid message src/dst:`,t);return}if(t.error){Q&&console.error(`WebSocket error message response:`,t);return}if(t.id===b.current&&t.method===`pong`&&t.response===`pong`){Q&&console.log(`WebSocket pong response message id ${t.id}:`,t),S.current&&clearTimeout(S.current),S.current=null;return}else if(t.method===`snackbar`&&t.response&&t.response.message){Q&&console.log(`WebSocket message id ${t.id} method ${t.method}:`,t),l(t.response.message,t.response.timeout,t.response.severity);return}else if(t.method===`close_snackbar`&&t.response&&t.response.message){Q&&console.log(`WebSocket message id ${t.id} method ${t.method}:`,t),u(t.response.message);return}else if(t.method===`log`){if(!t.response||!t.response.level||!t.response.time||!t.response.name||!t.response.message||(t.response.level===`spawn`&&(t.response.name===`Matterbridge:spawn-init`?f(t.response.message,``,``):t.response.name===`Matterbridge:spawn-exit-success`?m():t.response.name===`Matterbridge:spawn-exit-error`?h():g(t.response.message+`
|
|
4
|
-
`)),[`debug`,`info`,`notice`,`warn`,`error`,`fatal`].includes(t.response.level)&&(w.current===`info`&&t.response.level===`debug`||w.current===`notice`&&(t.response.level===`debug`||t.response.level===`info`)||w.current===`warn`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`)||w.current===`error`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`||t.response.level===`warn`)||w.current===`fatal`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`||t.response.level===`warn`||t.response.level===`error`)))||T.current!==`*`&&T.current!==``&&!T.current.startsWith(`/`)&&!T.current.endsWith(`/`)&&!t.response.message.toLowerCase().includes(T.current.toLowerCase())&&!t.response.name.toLowerCase().includes(T.current.toLowerCase())||T.current.startsWith(`/`)&&T.current.endsWith(`/`)&&(()=>{try{let e=new RegExp(T.current.slice(1,-1),`i`);return!e.test(t.response.message)&&!e.test(t.response.name)}catch(e){return console.error(`WebSocket log search invalid regex filter "${T.current}":`,e),!1}})()||t.response.name===`Commissioning`&&t.response.message.includes(`is uncommissioned`))return;n(e=>{let n=[...e,{level:t.response.level,time:t.response.time,name:t.response.name,message:t.response.message}];return Q&&console.log(`WebSocket new log message added (${n.length}/${O.current}):`,n[n.length-1]),n.length>O.current+O.current*10/100?(Q&&console.log(`WebSocket sliced log messages to the last ${O.current} entries`),n.slice(n.length-O.current)):n})}else{if(Q&&console.log(`WebSocket received message id ${t.id} method ${t.method}:`,t),t.id===0)_.current.forEach(e=>e.listener(t));else{let e=_.current.find(e=>e.id===t.id);e?e.listener(t):console.warn(`WebSocket no listener found for message id ${t.id}:`,t)}return}}catch(e){console.error(`WebSocket error parsing message: ${e}`,e instanceof Error?e.stack:null)}},v.current.onopen=()=>{Q&&console.log(`WebSocket: Connected to WebSocket: ${A}`),N(`WebSocket`,`Connected to WebSocket: ${A}`),c(!0),d(),y.current=1,C.current=setTimeout(()=>{x.current=setInterval(()=>{M({id:b.current,method:`ping`,src:`Frontend`,dst:`Matterbridge`,params:{}}),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{Q&&console.error(`WebSocketUse: No pong response received from WebSocket: ${A}`),N(`WebSocket`,`No pong response received from WebSocket: ${A}`),c(!1)},1e3*50)},1e3*60)},1e3*300)},v.current.onclose=()=>{Q&&console.error(`WebSocket: Disconnected from WebSocket ${oi?`with Ingress`:``}: ${A}`),N(`WebSocket`,`Disconnected from WebSocket: ${A}`),c(!1),d(),p(),C.current&&clearTimeout(C.current),S.current&&clearTimeout(S.current),x.current&&clearInterval(x.current),N(`WebSocket`,`Reconnecting (attempt ${y.current} of 100) to WebSocket${oi?` (Ingress)`:``}: ${A}`),oi?setTimeout(re,5e3):y.current===1?re():y.current<100?setTimeout(re,1e3*y.current):N(`WebSocket`,`Reconnect attempts exceeded limit of 100 retries, refresh the page to reconnect to: ${A}`),y.current+=1},v.current.onerror=e=>{Q&&console.error(`WebSocket: WebSocket error connecting to ${A}:`,e),N(`WebSocket`,`WebSocket error connecting to ${A}`)})},[A]),re=(0,W.useCallback)(()=>{Q&&console.log(`WebSocket attemptReconnect ${y.current}/100 to:`,A),ne()},[ne]);(0,W.useEffect)(()=>(ne(),()=>{v.current&&v.current.readyState===WebSocket.OPEN&&v.current.close()}),[ne]);let ie=(0,W.useMemo)(()=>({messages:t,logLength:O,logAutoScroll:k,logFilterLevel:r,logFilterSearch:a,setMessages:n,setLogFilterLevel:i,setLogFilterSearch:o,filterLogMessages:ee}),[t,O,k,r,a,n,i,o,ee]),ae=(0,W.useMemo)(()=>({logLength:O,logAutoScroll:k,logFilterLevel:r,logFilterSearch:a,setMessages:n,setLogFilterLevel:i,setLogFilterSearch:o,filterLogMessages:ee,online:s,retry:y.current,getUniqueId:j,addListener:P,removeListener:te,sendMessage:M,logMessage:N}),[O,k,n,i,o,s,y.current,P,te,M,N]);return(0,G.jsx)(Rt.Provider,{value:ie,children:(0,G.jsx)(q.Provider,{value:ae,children:e})})}function Bt(e){return(0,G.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,G.jsxs)(`defs`,{children:[(0,G.jsxs)(`linearGradient`,{id:`lg1`,x1:`16.6`,y1:`16.6`,x2:`279.6`,y2:`279.6`,gradientUnits:`userSpaceOnUse`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#00b48d`}),(0,G.jsx)(`stop`,{offset:`.1`,stopColor:`#3faa77`}),(0,G.jsx)(`stop`,{offset:`.3`,stopColor:`#234148`}),(0,G.jsx)(`stop`,{offset:`.7`,stopColor:`#203b44`}),(0,G.jsx)(`stop`,{offset:`.9`,stopColor:`#ad2e6e`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#c81b74`})]}),(0,G.jsxs)(`linearGradient`,{id:`lg2`,x1:`31.1`,y1:`31.1`,x2:`265.1`,y2:`265.1`,gradientUnits:`userSpaceOnUse`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#00b48d`}),(0,G.jsx)(`stop`,{offset:`.2`,stopColor:`#285251`}),(0,G.jsx)(`stop`,{offset:`.4`,stopColor:`#234148`}),(0,G.jsx)(`stop`,{offset:`.8`,stopColor:`#203b44`}),(0,G.jsx)(`stop`,{offset:`.9`,stopColor:`#a8316c`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#c81b74`})]}),(0,G.jsxs)(`linearGradient`,{id:`lg3`,x1:`116.2`,y1:`143.9`,x2:`139.8`,y2:`143.9`,gradientUnits:`userSpaceOnUse`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#8bc751`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#0db14b`})]}),(0,G.jsx)(`linearGradient`,{id:`lg4`,x1:`136.1`,y1:`100.8`,x2:`159.6`,y2:`100.8`,xlinkHref:`#lg3`}),(0,G.jsx)(`linearGradient`,{id:`lg5`,x1:`155.3`,y1:`143.9`,x2:`178.9`,y2:`143.9`,xlinkHref:`#lg3`}),(0,G.jsxs)(`linearGradient`,{id:`lg6`,x1:`46.8`,y1:`25.7`,x2:`89.6`,y2:`74.8`,gradientUnits:`userSpaceOnUse`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#b1d34a`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#50b848`})]})]}),(0,G.jsx)(`rect`,{width:`296.2`,height:`296.2`,rx:`56.7`,ry:`56.7`,style:{fill:`url(#lg1)`}}),(0,G.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,G.jsx)(`circle`,{cx:`128`,cy:`143.9`,r:`11.8`,style:{fill:`url(#lg3)`}}),(0,G.jsx)(`circle`,{cx:`147.8`,cy:`100.8`,r:`11.8`,style:{fill:`url(#lg4)`}}),(0,G.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,G.jsx)(`circle`,{cx:`167.1`,cy:`143.9`,r:`11.8`,style:{fill:`url(#lg5)`}}),(0,G.jsx)(`path`,{fill:`#fff`,d:`M219 89.3V35.5a10.5 10.5 0 1 0-21 0v33.7l21 20Z`}),(0,G.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,G.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,G.jsx)(`path`,{fill:`#fff`,d:`M250.5 90.5a17.4 17.4 0 1 1 0-34.8 17.4 17.4 0 0 1 0 34.8Zm0-22.7a5.4 5.4 0 0 0 0 10.7 5.3 5.3 0 0 0 0-10.7ZM258.8 148.2a15.9 15.9 0 0 0-9.6 28.5c-.8 4.2-5.4 4.6-5.4 4.6h-26v-43l13.6-13-1.8-2-82.2-79-81.2 78.3-2.5 2.6 13.7 13v42.9H53a21.5 21.5 0 1 0 11.7 15h12.6v18.8c0 7.8 6.4 14.1 14.1 14.1h29.3v14.8H64a10.6 10.6 0 0 0-17.7 8 10.6 10.6 0 0 0 17.6 8h157.6a16.3 16.3 0 1 0 0-16h-84.8V229h66.8c7.8 0 14.2-6.3 14.2-14.1v-19.2h27.6c14.3 0 17.8-12.8 18.5-16.6a15.9 15.9 0 0 0-5-30.9ZM43.7 210.8a10.3 10.3 0 1 1 0-20.6 10.3 10.3 0 0 1 0 20.6Zm192 36a5 5 0 1 1 0 10 5 5 0 0 1 0-10Zm-77-34.8h-22v-34h22v34Zm8.4-79.8c2.7 0 5.2 1 7.2 2.5v-10.4L188 137s2.6 1.3 4.6 1.3h6.7v68c0 3.2-2.6 5.7-5.7 5.7h-19v-34h1.4a7.5 7.5 0 0 0 0-15H120a7.5 7.5 0 0 0 0 15h.7v34h-19.3a5.7 5.7 0 0 1-5.7-5.6v-68.1h6.7c2 0 4.6-1.3 4.6-1.3l13.7-12.7v10.4a11.7 11.7 0 0 1 16 1.6v-13a14.9 14.9 0 0 0-25-10.8s-.1.2-.1.2l-.5.5-6.9 7H92.5l55-53.2 55.1 53.2h-11.8l-7-7c0-.2-.2-.3-.4-.5l-.2-.2a14.8 14.8 0 0 0-25 10.9v12.9c2.2-2.5 5.3-4.1 8.9-4.1Zm91.7 36.7a4.9 4.9 0 1 1 0-9.7 4.9 4.9 0 0 1 0 9.7Z`})]})}function Vt(){let{retry:e}=(0,W.useContext)(q);return(0,G.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,G.jsx)(Bt,{style:{height:`128px`,width:`128px`,margin:`10px`,marginBottom:`20px`}}),e<100?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(T,{style:{color:`var(--primary-color)`}}),(0,G.jsx)(`div`,{style:{marginTop:`20px`,color:`var(--primary-color)`,textAlign:`center`},children:(0,G.jsxs)(`span`,{children:[`Reconnecting to Matterbridge `,`(attempt `+e+`)`,`...`]})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{style:{marginTop:`20px`,color:`var(--primary-color)`,textAlign:`center`},children:[(0,G.jsx)(`span`,{children:`Unable to connect to Matterbridge after multiple attempts.`}),(0,G.jsx)(`br`,{}),(0,G.jsx)(`span`,{children:`Please check your network connection.`}),(0,G.jsx)(`br`,{})]}),(0,G.jsx)(j,{variant:`contained`,color:`primary`,onClick:()=>{window.location.reload()},style:{marginTop:`20px`},children:`Refresh the Page`})]})]})}var J=pt();function Ht({value:e,maxChars:t}){let n=e;if(e.length>t&&t>3){let r=t-3;n=`${e.substring(0,Math.ceil(r/2))} … ${e.substring(e.length-Math.floor(r/2),e.length)}`}return e===n?(0,G.jsx)(`span`,{children:n}):(0,G.jsx)(V,{title:e,placement:`top`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[0,12]}}]}},children:(0,G.jsx)(`span`,{children:n})})}function Y({children:e,style:t}){return(0,G.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,flex:`0 0 auto`,width:`100%`,overflow:`hidden`,margin:`0px`,padding:`0px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,boxShadow:`5px 5px 10px var(--div-shadow-color)`,border:`1px solid var(--table-border-color)`,borderRadius:`var(--div-border-radius)`,boxSizing:`border-box`,...t},children:e})}function Ut({children:e,style:t}){return(0,G.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 X({children:e,style:t}){return(0,G.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 Wt({children:e,style:t}){return(0,G.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 Gt({children:e,style:t}){return(0,G.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 Kt({children:e,style:t}){return(0,G.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,G.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 Jt({children:e,style:t,close:n}){return(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,margin:`0px`,padding:`0px`,paddingRight:`10px`,gap:`10px`,...t},children:[e,!1]})}function Yt({systemInfo:e,compact:t}){let{mobile:n}=(0,W.useContext)(It),{addListener:r,removeListener:i,getUniqueId:a,sendMessage:o}=(0,W.useContext)(q),[s,c]=(0,W.useState)(e),l=(0,W.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,W.useEffect)(()=>{let e=e=>{Q&&console.log(`SystemInfoTable received WebSocket Message:`,e),e.method===`memory_update`&&e.response&&e.response.totalMemory&&e.response.freeMemory&&e.response.heapTotal&&e.response.heapUsed&&e.response.rss?(Q&&console.log(`SystemInfoTable received memory_update`,e),u(e.response.totalMemory,e.response.freeMemory,e.response.heapTotal,e.response.heapUsed,e.response.rss)):e.method===`cpu_update`&&e.response&&e.response.cpuUsage?(Q&&console.log(`SystemInfoTable received cpu_update`,e),d(e.response.cpuUsage),f(e.response.processCpuUsage)):e.method===`uptime_update`&&e.response&&e.response.systemUptime&&e.response.processUptime?(Q&&console.log(`SystemInfoTable received uptime_update`,e),p(e.response.systemUptime,e.response.processUptime)):e.method===`/api/viewhistorypage`&&e.id===l.current&&e.success===!0&&(Q&&console.log(`SystemInfoTable received /api/viewhistorypage success`),window.open(`./api/viewhistory`,`_blank`,`noopener,noreferrer`))};return r(e,l.current),Q&&console.log(`SystemInfoTable added WebSocket listener id ${l.current}`),()=>{i(e),Q&&console.log(`SystemInfoTable removed WebSocket listener`)}},[r,i]);let[h,g]=(0,W.useState)(!1);return!s||h?null:(Q&&console.log(`SystemInfoTable rendering...`),(0,G.jsxs)(Y,{style:$&&n?{flex:`1 1 300px`}:{flex:`0 1 auto`,width:`302px`,minWidth:`302px`},children:[(0,G.jsxs)(Ut,{children:[(0,G.jsx)(X,{children:`System info`}),(0,G.jsx)(Jt,{close:()=>g(!0),children:(0,G.jsx)(I,{size:`small`,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},onClick:m,children:(0,G.jsx)(V,{title:`Open the cpu and memory usage page`,arrow:!0,children:(0,G.jsx)(J.Icon,{path:ht,size:`22px`})})})})]}),(0,G.jsx)(qt,{style:$&&n?{flex:`1 1 auto`,margin:`0px`,padding:`0px`,gap:`0px`}:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`0px`,gap:`0px`},children:(0,G.jsxs)(`table`,{style:{border:`none`,borderCollapse:`collapse`,tableLayout:`fixed`},children:[(0,G.jsxs)(`colgroup`,{children:[(0,G.jsx)(`col`,{style:{width:`40%`}}),(0,G.jsx)(`col`,{style:{width:`60%`}})]}),(0,G.jsx)(`tbody`,{style:{border:`none`,borderCollapse:`collapse`},children:Object.entries(s).filter(([e,t])=>t!==void 0&&t!==``).map(([e,t],r)=>(0,G.jsxs)(`tr`,{className:r%2==0?`table-content-even`:`table-content-odd`,style:{border:`none`,borderCollapse:`collapse`},children:[(0,G.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`},children:e.replace(`interfaceName`,`Interface name`).replace(`macAddress`,`Mac address`).replace(`ipv4Address`,`IPv4 address`).replace(`ipv6Address`,`IPv6 address`).replace(`nodeVersion`,`Node version`).replace(`hostname`,`Hostname`).replace(`user`,`User`).replace(`osType`,`Os`).replace(`osPlatform`,`Platform`).replace(`freeMemory`,`Memory`).replace(`systemUptime`,`System uptime`).replace(`processUptime`,`Process uptime`).replace(`cpuUsage`,`Host CPU`).replace(`processCpuUsage`,`Process CPU`).replace(`rss`,`Rss`).replace(`heapUsed`,`Heap`)}),(0,G.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:$&&n?typeof t==`string`?t:t.toString():(0,G.jsx)(Ht,{value:typeof t==`string`?t:t.toString(),maxChars:22})})]},e))})]})})]}))}var Xt=(0,W.memo)(Yt),Zt={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`}},Qt=e=>{if(!e)return``;let t=e.toString().replace(/[^0-9]/g,``);return t.length<5?t:[t.slice(0,4),t.slice(4,7),t.slice(7,11)].filter(Boolean).join(`-`)};function $t({id:e}){let{online:t,sendMessage:n,addListener:r,removeListener:i,getUniqueId:a}=(0,W.useContext)(q),[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)(It);Q&&console.log(`QRDiv loading with id = "${e}" storeId = "${c.current}" timeout = ${l.current} and matter:`,o),(0,W.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,W.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}})},_=async()=>{if(!o||!o.manualPairingCode)return;let e=o.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(e);else{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}Q&&console.log(`Manual pairing code copied to clipboard`)}catch(e){console.error(`Failed to copy manual pairing code`,e)}};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,G.jsxs)(Y,{style:$&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,G.jsxs)(Ut,{children:[(0,G.jsx)(X,{children:`QR pairing code`}),(0,G.jsxs)(Jt,{children:[(0,G.jsx)(I,{"aria-label":`send advertising`,size:`small`,onClick:h,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,G.jsx)(V,{title:`Send again the mDNS advertisement`,arrow:!0,children:(0,G.jsx)(J.Icon,{path:ft,size:`22px`})})}),(0,G.jsx)(I,{"aria-label":`stop pairing`,size:`small`,onClick:m,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,G.jsx)(V,{title:`Turn off pairing`,arrow:!0,children:(0,G.jsx)(J.Icon,{path:ut,size:`22px`})})})]})]}),(0,G.jsx)(Kt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,G.jsx)(bt,{value:o.qrPairingCode,size:256,level:`M`,fgColor:`var(--div-text-color)`,bgColor:`var(--div-bg-color)`,style:{margin:`20px`}}),(0,G.jsxs)(Wt,{style:{justifyContent:`space-between`},children:[(0,G.jsxs)(Gt,{style:{fontWeight:`normal`,color:`var(--div-text-color)`},children:[`Manual pairing code: `,Qt(o.manualPairingCode)]}),(0,G.jsx)(Jt,{children:(0,G.jsx)(V,{title:`Copy manual pairing code`,arrow:!0,children:(0,G.jsx)(I,{"aria-label":`copy manual pairing code`,size:`small`,onClick:_,sx:Zt,children:(0,G.jsx)(J.Icon,{path:mt,size:.85})})})})]})]})):o.commissioned&&o.fabricInformations&&o.sessionInformations?(Q&&console.log(`QRDiv rendering commissioned state`),(0,G.jsxs)(Y,{style:$&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`,overflow:`hidden`},children:[(0,G.jsxs)(Ut,{children:[(0,G.jsx)(X,{children:`Paired fabrics`}),(0,G.jsxs)(Jt,{children:[(0,G.jsx)(I,{"aria-label":`send advertising`,size:`small`,onClick:h,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,G.jsx)(V,{title:`Send again the mDNS advertisement`,arrow:!0,children:(0,G.jsx)(J.Icon,{path:ft,size:`22px`})})}),(0,G.jsx)(I,{"aria-label":`start pairing`,size:`small`,onClick:p,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,G.jsx)(V,{title:`Turn on pairing`,arrow:!0,children:(0,G.jsx)(J.Icon,{path:_t,size:`22px`})})})]})]}),(0,G.jsx)(Kt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,G.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,G.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,G.jsxs)(`div`,{style:{marginLeft:`20px`,marginBottom:`10px`,display:`flex`,flexDirection:`row`,justifyContent:`space-between`,gap:`20px`,alignItems:`center`},children:[(0,G.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,G.jsx)(V,{title:`Remove the fabric. You will also need to remove it from the controller.`,arrow:!0,children:(0,G.jsx)(I,{"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:{...Zt,padding:`2px`},children:(0,G.jsx)(J.Icon,{path:gt,size:1})})})]}),(0,G.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Vendor: `,e.rootVendorId,` `,e.rootVendorName]}),e.label!==``&&(0,G.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Label: `,e.label]}),(0,G.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Sessions: `,o.sessionInformations?o.sessionInformations.filter(t=>t.fabric?.fabricIndex===e.fabricIndex&&t.isPeerActive===!0).length:`0`,` `,`subscriptions: `,o.sessionInformations?o.sessionInformations.filter(t=>t.fabric?.fabricIndex===e.fabricIndex&&t.isPeerActive===!0&&t.numberOfActiveSubscriptions>0).length:`0`]})]},t))}),(0,G.jsx)(Wt,{style:{justifyContent:`center`},children:(0,G.jsxs)(Gt,{style:{fontWeight:`normal`},children:[`Serial number: `,o.serialNumber]})})]})):!o.commissioned&&!o.advertising?(Q&&console.log(`QRDiv rendering not commissioned and not advertising state`),(0,G.jsxs)(Y,{style:$&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,G.jsx)(Ut,{children:(0,G.jsx)(X,{children:`QR pairing code`})}),(0,G.jsx)(Kt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,G.jsx)(j,{onClick:p,endIcon:(0,G.jsx)(J.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,G.jsx)(Wt,{style:{justifyContent:`center`},children:(0,G.jsxs)(Gt,{style:{fontWeight:`normal`},children:[`Serial number: `,o.serialNumber]})})]})):(Q&&console.log(`QRDiv rendering unknown state`),null):(Q&&console.log(`QRDiv rendering offline state`),(0,G.jsxs)(Y,{style:$&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,G.jsx)(Ut,{style:{height:`30px`,justifyContent:`space-between`},children:(0,G.jsx)(X,{children:`Server node`})}),(0,G.jsx)(Kt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,G.jsx)(Kt,{style:{fontWeight:`bold`},children:`Server offline`}),(0,G.jsx)(Wt,{style:{justifyContent:`center`},children:(0,G.jsxs)(Gt,{style:{fontWeight:`normal`},children:[`Serial number: `,o.serialNumber]})})]}))}var en=(0,W.memo)($t);function tn(e){return e?e.scrollWidth>e.clientWidth:!1}function nn({title:e,children:t}){let n=(0,W.useRef)(null),[r,i]=(0,W.useState)(!1);return(0,G.jsx)(V,{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,G.jsx)(`span`,{ref:n,onMouseEnter:()=>{i(tn(n.current))},onMouseLeave:()=>{i(!1)},style:{display:`inline-block`,maxWidth:`100%`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t})})}function rn(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 an({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},[d,f]=(0,W.useState)(localStorage.getItem(`${e}_table_order_by`)||null),[p,m]=(0,W.useState)(localStorage.getItem(`${e}_table_order`)||null),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(()=>{try{let t=localStorage.getItem(`${e}_column_visibility`);if(t)return JSON.parse(t)}catch{}return{}}),y=(0,W.useMemo)(()=>{let e={};for(let t of n)t.hidden||(e[t.id]=t.required?!0:_[t.id]!==!1);return e},[n,_]),b=(0,W.useMemo)(()=>{if(!d||!p)return r;let e=n.find(e=>e.id===d);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):rn(t.el,n.el,d),r===0?t.index-n.index:p===`asc`?r:-r}),t.map(e=>e.el)},[r,d,p,n]),S=t=>{if(d!==t||!d){f(t),m(`asc`),localStorage.setItem(`${e}_table_order_by`,t),localStorage.setItem(`${e}_table_order`,`asc`);return}if(p===`asc`){m(`desc`),localStorage.setItem(`${e}_table_order`,`desc`);return}f(null),m(null),localStorage.removeItem(`${e}_table_order_by`),localStorage.removeItem(`${e}_table_order`)},C=()=>{g(!h)},w=t=>{v(r=>{let i=n.find(e=>e.id===t);if(i&&i.required)return r;let a=y[t]!==!1,o={...r};a?o[t]=!1:delete o[t];try{localStorage.setItem(`${e}_column_visibility`,JSON.stringify(o))}catch{}return o})},T=()=>{v({});try{localStorage.removeItem(`${e}_column_visibility`)}catch{}g(!1)},[E,O]=(0,W.useState)(!1);return E?null:(Q&&console.log(`Rendering table ${e}${d&&p?` ordered by ${d}:${p}`:``}`),(0,G.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,G.jsxs)(x,{open:h,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||C()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[(0,G.jsx)(M,{gap:`20px`,children:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,G.jsx)(`h4`,{style:{margin:0},children:`Configure ${e} columns`})]})}),(0,G.jsx)(P,{children:(0,G.jsx)(ne,{children:n.filter(e=>!e.hidden).map(e=>(0,G.jsx)(Ie,{control:(0,G.jsx)(D,{disabled:!!e.required,checked:e.required?!0:y[e.id]!==!1,onChange:()=>w(e.id)}),label:e.label},e.id))})}),(0,G.jsxs)(ie,{children:[(0,G.jsx)(j,{onClick:T,children:`Reset`}),(0,G.jsx)(j,{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{}C()},children:`Close`})]})]}),(0,G.jsxs)(Ut,{style:{height:`30px`,minHeight:`30px`,justifyContent:`space-between`,borderBottom:`none`},children:[(0,G.jsx)(X,{children:e}),t&&(0,G.jsx)(X,{children:t}),(0,G.jsx)(Jt,{close:()=>O(!0),children:(0,G.jsx)(I,{size:`small`,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},onClick:e=>{if(e?.currentTarget?.blur)try{e.currentTarget.blur()}catch{}C()},"aria-label":`Configure Columns`,children:(0,G.jsx)(V,{title:`Configure ${e} columns`,children:(0,G.jsx)(J.Icon,{path:dt,size:`20px`,color:`var(--header-text-color)`})})})})]}),(0,G.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,G.jsxs)(`table`,{"aria-label":`${e} table`,style:{width:`100%`,borderCollapse:`collapse`},children:[(0,G.jsx)(`thead`,{style:{position:`sticky`,top:0,zIndex:10,border:`none`,color:`var(--header-text-color)`,backgroundColor:`var(--header-bg-color`},children:(0,G.jsx)(`tr`,{style:{height:`30px`,minHeight:`30px`},children:n.map(e=>{if(e.hidden||!e.required&&y[e.id]===!1)return null;let t=!e.noSort,n=t&&d===e.id&&!!p;return(0,G.jsxs)(`th`,{onClick:t?()=>S(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?p===`asc`?`ascending`:`descending`:`none`:void 0,children:[e.label,n&&(0,G.jsxs)(`span`,{style:{marginLeft:6},children:[p===`asc`&&(0,G.jsx)(J.Icon,{path:`M19 17H22L18 21L14 17H17V3H19M2 17H12V19H2M6 5V7H2V5M2 11H9V13H2V11Z`,size:`15px`}),p===`desc`&&(0,G.jsx)(J.Icon,{path:`M19 7H22L18 3L14 7H17V21H19M2 17H12V19H2M6 5V7H2V5M2 11H9V13H2V11Z`,size:`15px`})]})]},e.id)})})}),(0,G.jsx)(`tbody`,{children:b.map((e,t)=>{let r=u(e);return(0,G.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&&y[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,G.jsx)(D,{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,G.jsx)(nn,{title:String(n),children:i}):i;return(0,G.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,G.jsxs)(Wt,{style:{height:`30px`,minHeight:`30px`,justifyContent:`space-between`,border:`none`},children:[(0,G.jsx)(Gt,{style:{fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`},children:a}),(0,G.jsx)(Gt,{style:{fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`},children:o})]})]}))}function on(e){return(0,W.memo)(e)}var sn=on(an),cn=e=>e.replace(`git+`,``).replace(`.git`,``).trim(),ln=e=>{let t=cn(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},dn=()=>{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{}}},fn=e=>{try{window.localStorage.setItem(K.searchPluginsTotal,JSON.stringify(e))}catch{}},pn=()=>{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{}}},mn=e=>{try{window.localStorage.setItem(K.searchPluginsMeta,JSON.stringify(e))}catch{}},hn=()=>{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{}}},gn=e=>{try{window.localStorage.setItem(K.searchPluginsVersions,JSON.stringify(e))}catch{}},_n=({open:e,onClose:t,onSelect:n,onVersions:r})=>{let[i,a]=(0,W.useState)(``),o=(0,W.useRef)(``),s=(0,W.useRef)(!1),c=(0,W.useRef)(null),[l,u]=(0,W.useState)([]),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)({done:0,total:0}),[y,b]=(0,W.useState)(null),S=(0,W.useRef)({}),C=()=>{let e=document.activeElement;e&&e instanceof HTMLElement&&e.blur()},w=e=>`${e.getFullYear().toString()}-${(e.getMonth()+1).toString().padStart(2,`0`)}-${e.getDate().toString().padStart(2,`0`)}`,T=(0,W.useCallback)(async(e,t)=>{let n=S.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:c.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 l=a[`dist-tags`]??{},u=typeof l?.dev==`string`&&String(l.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),S.current[e]={versions:f,asOf:t},gn(S.current),f},[]),E=e=>new Intl.NumberFormat().format(e),D=[{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`?E(e):``},{label:`Total`,id:`total`,align:`right`,maxWidth:120,render:e=>typeof e==`number`?E(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,G.jsxs)(`div`,{style:{margin:`0`,padding:`0`,gap:`4px`,display:`flex`,flexDirection:`row`,justifyContent:`center`},children:[(0,G.jsx)(V,{title:n.homepage?`Open the plugin homepage`:`No homepage available`,children:(0,G.jsx)(`span`,{children:(0,G.jsx)(I,{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,G.jsx)(Me,{})})})}),(0,G.jsx)(V,{title:n.help?`Open the plugin help`:`No help available`,children:(0,G.jsx)(`span`,{children:(0,G.jsx)(I,{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,G.jsx)(Ye,{})})})}),(0,G.jsx)(V,{title:n.changelog?`Open the plugin changelog`:`No changelog available`,children:(0,G.jsx)(`span`,{children:(0,G.jsx)(I,{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,G.jsx)(He,{})})})})]})}];(0,W.useEffect)(()=>{if(!e){s.current=!1,o.current=``,c.current?.abort(),c.current=null,u([]),f(!1),m(!1),g(!1),v({done:0,total:0}),b(null),a(``);return}if(s.current)return;s.current=!0;let t=new AbortController;return c.current=t,S.current=hn(),(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{f(!0),b(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),d=(s.objects??[]).filter(e=>!!e?.package&&typeof e.package.name==`string`).filter(t=>t.package?.name?.startsWith(e)).filter(e=>!vn.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}}),p=w(new Date),m=dn(),h=pn();u(d.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!==p)return e;let n=t.homepage??e.homepage,r=t.help,i=t.changelog;return Q&&(r||i||n&&n!==e.homepage)&&console.log(`[SearchPluginsDialog] metadata loaded from cache for ${e.name} (asOf=${t.asOf}):`,{homepage:n,help:r,changelog:i}),{...e,homepage:n,help:r,changelog:i}}));let _=d.map(e=>e.name).filter(e=>{let t=S.current[e];return!t||t.asOf!==p||t.versions.length===0});Q&&console.log(`[SearchPluginsDialog] versions prefetch queue (${_.length.toString()}):`,_);let y=0,x=async()=>{for(;y<_.length;){if(t.signal.aborted)return;let e=y;y+=1;let r=_[e];if(r)try{let e=await T(r,p);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,d.length)},()=>x()));let C=d.map(e=>e.name).filter(e=>{let t=h[e],n=!!t&&t.asOf===p,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}),E=new Set(C),D=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`)?cn(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?ln(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}},O=0,k=async()=>{for(;O<C.length;){if(t.signal.aborted)return;let e=O;O+=1;let r=C[e];if(!r||!E.has(r))continue;E.delete(r);let i=await D(r,d.find(e=>e.name===r)?.homepage??null);if(t.signal.aborted)return;i&&(u(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:p},mn(h)),t.signal.aborted||await n(250)}};Promise.all(Array.from({length:Math.min(1,d.length)},()=>k()));let A=`2020-01-01`,j=d.map(e=>e.name).filter(e=>{let t=m[e],n=!t||t.asOf!==p;return n||Q&&console.log(`[SearchPluginsDialog] total downloads fetch skipped (cache fresh) for ${e} (asOf=${t.asOf}).`),n}),ee=new Set(j),M=j.length;v({done:0,total:M}),g(M>0);let N=async e=>{let i=`https://api.npmjs.org/downloads/range/${A}:${p}/${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},P=0,te=0,ne=async()=>{for(;P<j.length;){if(t.signal.aborted)return;let e=P;P+=1;let r=j[e];if(r&&ee.has(r)){ee.delete(r);try{Q&&console.log(`[SearchPluginsDialog] fetching total downloads for ${r} (range ${A}:${p})...`);let e=await N(r);if(t.signal.aborted)return;Q&&console.log(`[SearchPluginsDialog] total downloads fetched for ${r}:`,e),u(t=>t.map(t=>t.name===r?{...t,total:e}:t)),typeof e==`number`&&(m[r]={total:e,asOf:p},fn(m),Q&&console.log(`[SearchPluginsDialog] total downloads saved to localStorage for ${r} (asOf=${p}):`,e))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return}finally{te+=1,v({done:te,total:M}),t.signal.aborted||await n(500)}}}};Promise.all(Array.from({length:Math.min(1,d.length)},()=>ne())).finally(()=>{t.signal.aborted||g(!1)}),Q&&console.log(`[SearchPluginsDialog] npm packages starting with "${e}" (filtered/sorted):`,d)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;console.error(`[SearchPluginsDialog] npm registry fetch error:`,e),b(e instanceof Error?e.message:String(e))}finally{f(!1)}})(),()=>t.abort()},[e,T]);let O=async()=>{C();let e=o.current||i;if(!(!e||p))try{m(!0);let t=await T(e,w(new Date));Q&&console.log(`[SearchPluginsDialog] passing versions to onVersions() for ${e} (${t.length.toString()}):`,t),r(t),m(!1),n(e)}catch(t){if(t instanceof DOMException&&t.name===`AbortError`)return;console.error(`[SearchPluginsDialog] npm versions fetch error:`,t),r([]),m(!1),n(e)}},k=()=>{C(),t(),r([])},A=l.reduce((e,t)=>e+(typeof t.downloads==`number`?t.downloads:0),0),ee=l.reduce((e,t)=>(typeof t.total==`number`&&(e.total+=t.total,e.hasAny=!0),e),{total:0,hasAny:!1}),N=h?` Totals: ${_.done.toString()}/${_.total.toString()} fetched`:``,te=ee.hasAny?E(ee.total):`...`;return(0,G.jsxs)(x,{open:e,onClose:()=>{C(),t()},maxWidth:!1,fullWidth:!0,slotProps:{paper:{sx:{width:`75vw`,height:`75vh`,maxWidth:`75vw`,maxHeight:`75vh`,display:`flex`,flexDirection:`column`}}},children:[(0,G.jsx)(M,{children:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,G.jsx)(`h4`,{style:{margin:0},children:`Search Plugins`})]})}),(0,G.jsx)(P,{dividers:!0,sx:{padding:`10px`,flex:`1 1 auto`,minHeight:0},children:(0,G.jsx)(`div`,{style:{height:`100%`,width:`100%`,display:`flex`,flexDirection:`column`,minHeight:0},children:d?(0,G.jsx)(`div`,{style:{padding:`20px`},children:`Loading npm registry...`}):y?(0,G.jsx)(`div`,{style:{padding:`20px`},children:y}):(0,G.jsx)(sn,{name:`Search plugins`,rows:l,columns:D,getRowKey:`name`,onRowClick:(e,t,n)=>{o.current=e.name,a(e.name),n.detail===2&&O()},footerLeft:`Total packages: ${l.length.toString()} Total downloads: ${E(A)} / ${te}${N}`,footerRight:i?`Selected: ${i}`:``})})}),(0,G.jsxs)(ie,{sx:{justifyContent:`center`,gap:1.5,flexWrap:`wrap`},children:[(0,G.jsx)(V,{title:`Select the plugin and close the dialog. Double-click a row to select and close the dialog.`,children:(0,G.jsx)(j,{variant:`contained`,onClick:O,disabled:!(o.current||i)||p,children:`Select`})}),(0,G.jsx)(V,{title:`Close the dialog without selecting a plugin.`,children:(0,G.jsx)(j,{onClick:k,children:`Cancel`})})]})]})},vn=[`matterbridge-`,`matterbridge-plugin-template`,`matterbridge-dyson`,`matterbridge-tuya`,`matterbridge-mqtt`,`matterbridge-matter`,`matterbridge-security`,`matterbridge-automations`,`matterbridge-securitysystem`,`matterbridge-adapter`];function yn(){let{mobile:e,showSnackbarMessage:t}=(0,W.useContext)(It),{logMessage:n,sendMessage:r,getUniqueId:i}=(0,W.useContext)(q),[a,o]=(0,W.useState)(`matterbridge-`),[s,c]=(0,W.useState)([`latest`,`dev`]),[l,u]=(0,W.useState)(`latest`),[f,p]=(0,W.useState)(!1),m=(0,W.useRef)(i()),h=e=>{let t=String(e??``).trim();if(!t)return{name:``,specifier:null};if(t.startsWith(`@`)){let e=t.lastIndexOf(`@`);if(e>0){let n=t.slice(0,e),r=t.slice(e+1);if(n.includes(`/`)&&r)return{name:n,specifier:r}}return{name:t,specifier:null}}let n=t.indexOf(`@`);if(n>0){let e=t.slice(0,n),r=t.slice(n+1);return r?{name:e,specifier:r}:{name:e,specifier:null}}return{name:t,specifier:null}},g=()=>{let{name:e,specifier:t}=h(a);return e?t?`${e}@${t}`:l?`${e}@${l}`:e:``},_=e=>{e.preventDefault(),p(!0)},v=()=>{p(!1)},y=e=>{e.preventDefault(),p(!1);let t=e.dataTransfer.files[0];if(t){n(`Plugins`,`Installing package ${t.name}. Please wait...`);let e=new FormData;e.append(`file`,t),e.append(`filename`,t.name),fetch(`./api/uploadpackage`,{method:`POST`,body:e}).then(e=>e.text()).then(e=>{n(`Plugins`,`Server response: ${e}`)}).catch(e=>{console.error(`Error uploading plugin file:`,e),n(`Plugins`,`Error installing package ${e}`)})}},b=e=>{let t=e.target.files&&e.target.files[0];if(t){n(`Plugins`,`Uploading package ${t.name}`);let e=new FormData;e.append(`file`,t),e.append(`filename`,t.name),fetch(`./api/uploadpackage`,{method:`POST`,body:e}).then(e=>e.text()).then(e=>{n(`Plugins`,`Server response: ${e}`)}).catch(e=>{console.error(`Error uploading plugin file:`,e),n(`Plugins`,`Error uploading package ${e}`)})}},x=()=>{let e=g();if(e){if(vn.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(vn.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}})},T=e=>{e.preventDefault(),Q&&console.log(`Right-clicked Upload button`)},E=e=>{e.preventDefault(),Q&&console.log(`Right-clicked Add button`)},[D,O]=(0,W.useState)(!1),k=()=>{O(!0),Q&&console.log(`Dialog opened for selection`)},A=()=>{o(`matterbridge-`),O(!1),Q&&console.log(`Dialog closed without selection`)},ee=e=>{o(e),O(!1),Q&&console.log(`Select plugin:`,e)},M=e=>{c(e),u(e.includes(`latest`)?`latest`:e[0]??``),Q&&console.log(`Select plugin versions:`,e)},[N,P]=(0,W.useState)(!1);return Q&&console.log(`HomeInstallAddPlugins rendering...`),N?null:(0,G.jsxs)(Y,{children:[(0,G.jsxs)(Ut,{children:[(0,G.jsx)(X,{children:`Install plugins`}),(0,G.jsx)(Jt,{close:()=>P(!0)})]}),(0,G.jsxs)(qt,{onDragOver:_,onDragLeave:v,onDrop:y,style:$&&e?{flexWrap:`wrap`,alignItems:`center`,gap:`10px`}:{flexWrap:`wrap`,alignItems:`center`,gap:`20px`},children:[(0,G.jsx)(_n,{open:D,onClose:A,onSelect:ee,onVersions:M}),(0,G.jsxs)(`div`,{style:{flex:`1 1 auto`,display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(V,{title:`Provide the npm name or the local path of the plugin to install, uninstall, or add`,children:(0,G.jsx)(B,{value:a,onChange:e=>{let t=e.target.value;c([`latest`,`dev`]),u(`latest`),o(t)},size:`small`,id:`plugin-name`,label:`Plugin name or plugin path`,variant:`outlined`,fullWidth:!0})}),s.length>0&&(0,G.jsx)(V,{title:`Select the npm tag/version to install`,children:(0,G.jsx)(`span`,{children:(0,G.jsxs)(d,{size:`small`,style:{minWidth:`150px`},children:[(0,G.jsx)(at,{id:`plugin-version-label`,children:`Tag or version`}),(0,G.jsx)(Ke,{labelId:`plugin-version-label`,id:`plugin-version`,value:l,label:`Tag or version`,onChange:e=>u(String(e.target.value??``)),sx:{"& .MuiSelect-icon":{color:`var(--main-label-color)`}},children:s.map(e=>(0,G.jsx)(R,{value:e,children:e},e))})]})})}),(0,G.jsx)(V,{title:`Search on npm the plugin to install`,children:(0,G.jsx)(I,{size:`large`,onClick:k,children:(0,G.jsx)(be,{fontSize:`inherit`})})})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(V,{title:`Install or update a plugin from npm`,children:(0,G.jsxs)(j,{onClick:x,endIcon:(0,G.jsx)(Re,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Install`]})}),(0,G.jsx)(V,{title:`Uninstall and remove a plugin`,children:(0,G.jsxs)(j,{onClick:S,endIcon:(0,G.jsx)(We,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Uninstall`]})}),(0,G.jsx)(V,{title:`Upload and install a plugin from a tarball`,children:(0,G.jsxs)(j,{onClick:C,onContextMenu:T,endIcon:(0,G.jsx)(Ce,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Upload`]})}),(0,G.jsx)(V,{title:`Add an already installed plugin or a plugin from a local path`,children:(0,G.jsxs)(j,{onClick:w,onContextMenu:E,endIcon:(0,G.jsx)(Ze,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Add`]})}),(0,G.jsx)(`input`,{id:`file-upload`,type:`file`,accept:`.tgz`,style:{display:`none`},onChange:b})]})]})]})}var bn=(0,W.memo)(yn);function xn({status:e,enabledText:t=`Enabled`,disabledText:n=void 0,tooltipText:r=void 0,onClick:i}){if(e===void 0)return null;{let a=(0,G.jsx)(`div`,{className:e?`status-enabled`:`status-disabled`,style:{cursor:`default`},onClick:i,children:e?t:n??t});return r===void 0?a:(0,G.jsx)(V,{title:r,children:a})}}function Sn(e){return e.id!==0&&e.src===`Matterbridge`&&e.dst===`Frontend`}var Cn={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},wn={fontSize:`12px`,fontWeight:`normal`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},Tn={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},En={fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`,backgroundColor:`var(--div-bg-color)`},Dn={fontSize:`16px`,fontWeight:`bold`,backgroundColor:`var(--div-bg-color)`},On={padding:`0px`,margin:`0px`},kn=`5px 10px 5px 10px`,An={},jn={},Mn={},Nn={},Pn=[],Fn=[];function In(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 Ln(e){let t=e.items;return t!==void 0&&typeof t==`object`&&!Array.isArray(t)}var Rn=({open:e,onClose:t,plugin:n})=>{let{sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,W.useContext)(q),s=(0,W.useRef)(o()),c=(0,W.useRef)({}),l=(0,W.useRef)({}),[u,d]=(0,W.useState)(n.configJson),[p,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`&&(Sn(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),Pn=e.response),Sn(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),Fn=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:`,p),Q&&console.log(`ConfigPluginDialog mounting with uiSchema:`,g),u&&p&&p.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(p,g),_(g),c.current=p,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,p,r,g]);let b=(e,t)=>{y=e.formData},C=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 T(e){let{id:t,label:n,onKeyRenameBlur:r,onRemoveProperty:i,disabled:a,schema:o,children:s,registry:c,readonly:l,required:u}=e,{templates:d}=c,{RemoveButton:f}=d.ButtonTemplates,p=wt in o,m=(0,W.useRef)(null);return(0,W.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,G.jsxs)(F,{sx:{display:`flex`,flexDirection:`row`,flexGrow:1,padding:0,margin:0,border:`none`},children:[(0,G.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,G.jsx)(F,{sx:{flex:1},children:s}),(0,G.jsx)(f,{disabled:a||l,onClick:i,registry:c})]}):(0,G.jsx)(F,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:s})}function E(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,G.jsx)(`div`,{style:{display:`none`},children:t}):(0,G.jsx)(F,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:(0,G.jsxs)(l,{...e,children:[r===!0&&n,t,i,a]})})}function A(e){let{description:t}=e;return t?(0,G.jsx)(U,{sx:wn,children:t}):null}function ee(e){let{required:t,title:n}=e;return n?(0,G.jsx)(F,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,G.jsxs)(U,{sx:Cn,children:[`Title `,n,` `,t&&(0,G.jsx)(`mark`,{children:`***`})]})}):null}function N(e){let{help:t}=e;return t?(0,G.jsx)(F,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,G.jsx)(U,{sx:En,children:t})}):null}function te(e){let{errors:t}=e;return t?(0,G.jsxs)(F,{sx:{padding:`10px`,margin:`10px`,border:`1px solid grey`},children:[(0,G.jsx)(U,{color:`error`,sx:Dn,children:`Please fix the following errors:`}),(0,G.jsx)(h,{children:t.map((e,t)=>(0,G.jsxs)(st,{children:[(0,G.jsx)(z,{children:(0,G.jsx)(pe,{color:`error`})}),(0,G.jsx)(H,{primary:e.stack})]},t))})]}):null}function ne(e){let{errors:t}=e;return t?(0,G.jsx)(F,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:t.map((e,t)=>(0,G.jsxs)(U,{color:`error`,variant:`body2`,sx:{marginLeft:1},children:[`This field `,e]},t))}):null}function re(e){let{id:t,name:n,_schema:r,_uiSchema:i,value:a,options:o,label:s,type:c,placeholder:l,required:u,disabled:d,readonly:f,autofocus:p,onChange:m,onChangeOverride:h,onBlur:g,onFocus:_,_rawErrors:v,_hideError:y,_registry:b,_formContext:x}=e;return(0,G.jsx)(F,{sx:{padding:`0px`,margin:`0px`},children:(0,G.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 ae(e){return console.log(`ArrayFieldTitleTemplate:`,e),null}function oe(e){return console.log(`ArrayFieldDescriptionTemplate:`,e),null}function se(e){let{buttonsProps:t,children:n}=e;return(0,G.jsxs)(F,{sx:{margin:`2px 0px`,padding:`0px`,display:`flex`,alignItems:`center`},children:[(0,G.jsx)(F,{sx:{flexGrow:1,marginRight:`10px`},children:n}),(0,G.jsx)(I,{disabled:!t.hasMoveUp,onClick:t.onMoveUpItem,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(de,{})}),(0,G.jsx)(I,{disabled:!t.hasMoveDown,onClick:t.onMoveDownItem,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(w,{})}),t.hasRemove&&(0,G.jsx)(I,{onClick:t.onRemoveItem,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(O,{})})]})}function le(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),[p,m]=(0,W.useState)(``),g=e=>{m(e.target.value)},_=()=>{Q&&console.log(`ArrayFieldTemplate: handleDialogDeviceToggle filter:`,p,`selectDevices:`,Pn),s(!o)},v=()=>{Q&&console.log(`ArrayFieldTemplate: handleDialogEntityToggle filter:`,p,`selectEntities:`,Fn),l(!c)},y=()=>{Q&&console.log(`ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:`,p,`selectDevices:`,Pn),d(!u)},b=e=>{s(!1),r.selectFrom===`serial`&&Ln(r)?r.items.default=e.serial:r.selectFrom===`name`&&Ln(r)&&(r.items.default=e.name),n()},C=e=>{l(!1),r.selectEntityFrom===`name`&&Ln(r)?r.items.default=e.name:r.selectEntityFrom===`description`&&Ln(r)&&(r.items.default=e.description),n()},w=e=>{d(!1),r.selectDeviceEntityFrom===`name`&&Ln(r)?r.items.default=e.name:r.selectDeviceEntityFrom===`description`&&Ln(r)&&(r.items.default=e.description),n()};return(0,G.jsxs)(F,{sx:{margin:`0px`,padding:`5px 10px 5px 10px`,border:`1px solid grey`},children:[i&&(0,G.jsxs)(F,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[i&&(0,G.jsx)(U,{sx:Cn,children:i}),t&&(0,G.jsxs)(F,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[r.selectFrom&&(0,G.jsx)(V,{title:`Add a device from the list`,children:(0,G.jsx)(I,{onClick:_,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(qe,{})})}),r.selectEntityFrom&&(0,G.jsx)(V,{title:`Add an entity from the list`,children:(0,G.jsx)(I,{onClick:v,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(qe,{})})}),r.selectDeviceEntityFrom&&(0,G.jsx)(V,{title:`Add a device entity from the list`,children:(0,G.jsx)(I,{onClick:y,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(qe,{})})}),(0,G.jsx)(V,{title:`Add a new item`,children:(0,G.jsx)(I,{onClick:n,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(Ze,{})})})]})]}),r.description&&(0,G.jsx)(U,{sx:wn,children:r.description}),e.items,(0,G.jsxs)(x,{open:o,onClose:_,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,G.jsx)(M,{children:`Select a device`}),(0,G.jsxs)(P,{children:[(0,G.jsxs)(F,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,G.jsx)(U,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,G.jsx)(B,{fullWidth:!0,variant:`outlined`,value:p,onChange:g,placeholder:`Enter serial or name`})]}),(0,G.jsx)(h,{dense:!0,children:Pn.filter(e=>e.serial.toLowerCase().includes(p.toLowerCase())||e.name.toLowerCase().includes(p.toLowerCase())).filter(e=>!r.uniqueItems||!a.includes(r.selectFrom===`serial`?e.serial:e.name)).map((e,t)=>(0,G.jsxs)(ce,{onClick:()=>b(e),sx:An,children:[e.icon===`wifi`&&(0,G.jsx)(z,{children:(0,G.jsx)(k,{style:jn})}),e.icon===`ble`&&(0,G.jsx)(z,{children:(0,G.jsx)(S,{style:jn})}),e.icon===`hub`&&(0,G.jsx)(z,{children:(0,G.jsx)(me,{style:jn})}),(0,G.jsx)(H,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:Mn},secondaryTypographyProps:{style:Nn}})]},t))})]}),(0,G.jsx)(ie,{children:(0,G.jsx)(j,{onClick:_,children:`Close`})})]}),(0,G.jsxs)(x,{open:c,onClose:v,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,G.jsx)(M,{children:`Select an entity`}),(0,G.jsxs)(P,{children:[(0,G.jsxs)(F,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,G.jsx)(U,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,G.jsx)(B,{fullWidth:!0,variant:`outlined`,value:p,onChange:g,placeholder:`Enter name or description`})]}),(0,G.jsx)(h,{dense:!0,children:Fn.filter(e=>e.name.toLowerCase().includes(p.toLowerCase())||e.description.toLowerCase().includes(p.toLowerCase())).filter(e=>!r.uniqueItems||!a.includes(r.selectEntityFrom===`name`?e.name:e.description)).map((e,t)=>(0,G.jsxs)(ce,{onClick:()=>C(e),sx:An,children:[e.icon===`wifi`&&(0,G.jsx)(z,{children:(0,G.jsx)(k,{style:jn})}),e.icon===`ble`&&(0,G.jsx)(z,{children:(0,G.jsx)(S,{style:jn})}),e.icon===`hub`&&(0,G.jsx)(z,{children:(0,G.jsx)(me,{style:jn})}),e.icon===`component`&&(0,G.jsx)(z,{children:(0,G.jsx)(f,{style:jn})}),e.icon===`matter`&&(0,G.jsx)(z,{children:(0,G.jsx)(lt,{style:jn})}),(0,G.jsx)(H,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:Mn},secondaryTypographyProps:{style:Nn}})]},t))})]}),(0,G.jsx)(ie,{children:(0,G.jsx)(j,{onClick:v,children:`Close`})})]}),(0,G.jsxs)(x,{open:u,onClose:y,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,G.jsxs)(M,{children:[`Select an entity for `,i]}),(0,G.jsx)(P,{children:(0,G.jsx)(h,{dense:!0,children:Pn.filter(e=>e.serial===i||e.name===i).map(e=>e.entities?.map((e,t)=>(0,G.jsxs)(ce,{onClick:()=>w(e),sx:An,children:[e.icon===`wifi`&&(0,G.jsx)(z,{children:(0,G.jsx)(k,{style:jn})}),e.icon===`ble`&&(0,G.jsx)(z,{children:(0,G.jsx)(S,{style:jn})}),e.icon===`hub`&&(0,G.jsx)(z,{children:(0,G.jsx)(me,{style:jn})}),e.icon===`component`&&(0,G.jsx)(z,{children:(0,G.jsx)(f,{style:jn})}),e.icon===`matter`&&(0,G.jsx)(z,{children:(0,G.jsx)(lt,{style:jn})}),(0,G.jsx)(H,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:Mn},secondaryTypographyProps:{style:Nn}})]},t)))})}),(0,G.jsx)(ie,{children:(0,G.jsx)(j,{onClick:y,children:`Close`})})]})]})}function ue(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=>{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()},p=()=>{t()},m=!n.additionalProperties;return Q&&console.log(`ObjectFieldTemplate: isRoot ${m} pendingAdditionalPropertyKey "${v.current}"`),(0,G.jsxs)(F,{sx:{margin:`0px`,padding:m?`10px`:`5px 10px 0px 10px`,border:m?`none`:`1px solid grey`},children:[n.title&&m&&(0,G.jsx)(F,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,G.jsx)(U,{sx:Cn,children:n.title})}),i&&!m&&(0,G.jsxs)(F,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[(0,G.jsx)(U,{sx:Cn,children:i}),(0,G.jsxs)(F,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[n.selectFrom&&(0,G.jsx)(V,{title:`Add a device from the list`,children:(0,G.jsx)(I,{onClick:d,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(qe,{})})}),(0,G.jsx)(V,{title:`Add a new item`,children:(0,G.jsx)(I,{onClick:p,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(Ze,{})})})]})]}),n.description&&(0,G.jsx)(F,{sx:{padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,G.jsx)(U,{sx:wn,children:n.description})}),r.map(({content:e,name:t,hidden:r})=>!r&&(0,G.jsxs)(F,{sx:{margin:`0px`,marginBottom:`10px`,padding:In(n,t)&&[`object`,`array`].includes(n.properties[t].type)?`0px`:kn,border:In(n,t)&&[`object`,`array`].includes(n.properties[t].type)?`none`:`1px solid grey`},children:[In(n,t)&&![`object`,`array`,`boolean`].includes(n.properties[t].type)&&(0,G.jsx)(U,{sx:Cn,children:n.properties[t].title||t}),(0,G.jsx)(F,{sx:{flexGrow:1,padding:`0px`,margin:`0px`},children:e})]},t)),(0,G.jsxs)(x,{open:o,onClose:d,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,G.jsx)(M,{children:`Select a device`}),(0,G.jsxs)(P,{children:[(0,G.jsxs)(F,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,G.jsx)(U,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,G.jsx)(B,{fullWidth:!0,variant:`outlined`,value:c,onChange:u,placeholder:`Enter serial or name`})]}),(0,G.jsx)(h,{dense:!0,children:Pn.filter(e=>e.serial.toLowerCase().includes(c.toLowerCase())||e.name.toLowerCase().includes(c.toLowerCase())).map((e,t)=>(0,G.jsxs)(ce,{onClick:()=>f(e),sx:An,children:[e.icon===`wifi`&&(0,G.jsx)(z,{children:(0,G.jsx)(k,{style:jn})}),e.icon===`ble`&&(0,G.jsx)(z,{children:(0,G.jsx)(S,{style:jn})}),e.icon===`hub`&&(0,G.jsx)(z,{children:(0,G.jsx)(me,{style:jn})}),(0,G.jsx)(H,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:Mn},secondaryTypographyProps:{style:Nn}})]},t))})]}),(0,G.jsx)(ie,{children:(0,G.jsx)(j,{onClick:d,children:`Close`})})]})]})}function fe(e){let{uiSchema:n}=e,{submitText:r,norender:i}=xt(n);return i?null:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,margin:`10px`,padding:`0px`,gap:`20px`},children:[(0,G.jsx)(j,{type:`submit`,variant:`contained`,color:`primary`,children:r}),(0,G.jsx)(j,{variant:`contained`,color:`primary`,onClick:t,children:`Cancel`})]})}function L(e){let{className:t,disabled:n,onClick:r,registry:i,style:a,uiSchema:o,...s}=e;return(0,G.jsx)(V,{title:`Remove the item`,children:(0,G.jsx)(I,{disabled:n,size:`small`,color:`primary`,onClick:r,children:(0,G.jsx)(O,{})})})}function he(e){let{className:t,disabled:n,onClick:r,registry:i,uiSchema:a,...o}=e;return(0,G.jsx)(V,{title:`Add an item`,children:(0,G.jsx)(I,{size:`small`,color:`primary`,onClick:r,children:(0,G.jsx)(Ze,{})})})}function ge(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,G.jsx)(V,{title:`Move up the item`,children:(0,G.jsx)(I,{size:`small`,color:`primary`,onClick:n,children:(0,G.jsx)(de,{})})})}function _e(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,G.jsx)(V,{title:`Move down the item`,children:(0,G.jsx)(I,{size:`small`,color:`primary`,onClick:n,children:(0,G.jsx)(w,{})})})}function ve(e){let{id:i,name:a,value:o,schema:c,readonly:l,onChange:d}=e,[f,p]=(0,W.useState)(),m=e=>{Q&&console.log(`CheckboxWidget ${a} onChangeField:`,e),p(e&&e!==``?e:void 0)},h=()=>{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&&C({formData:u})};return c.buttonText&&(c.title||c.description)?(0,G.jsxs)(F,{sx:{margin:`0px`,padding:`5px 0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,G.jsx)(U,{sx:Tn,children:c.title||c.description}),(0,G.jsx)(j,{variant:`contained`,color:`primary`,onClick:()=>h(),children:c.buttonText})]}):c.buttonField&&(c.title||c.description)?(0,G.jsxs)(F,{sx:{margin:`0px`,padding:`5px 0px`,gap:`20px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,G.jsx)(U,{sx:Tn,children:c.title||c.description}),(0,G.jsx)(B,{id:a+`-input`,name:a,label:c.textLabel,placeholder:c.textPlaceholder,onChange:e=>m(e.target.value),sx:{width:`250px`,minWidth:`250px`,maxWidth:`250px`}}),(0,G.jsx)(j,{id:a+`-button`,variant:`contained`,color:`primary`,disabled:f===void 0,onClick:()=>h(),children:c.buttonField})]}):(0,G.jsxs)(F,{sx:{margin:`0px`,padding:`0px`},children:[a&&(0,G.jsxs)(F,{sx:{margin:`0px`,padding:`0px`,gap:`10px`,display:`flex`,justifyContent:`flex-start`,alignItems:`center`},children:[(0,G.jsx)(U,{sx:Cn,children:c.title||a}),(0,G.jsx)(D,{checked:o,readOnly:l,onChange:()=>d(!o),sx:{padding:`0px`,margin:`0px`}})]}),c.description&&(0,G.jsx)(U,{sx:wn,children:c.description})]})}function ye({schema:e,id:t,name:n,options:r,label:i,hideLabel:a,required:o,disabled:s,placeholder:c,readonly:l,value:u,multiple:d,autofocus:f,onChange:p,onBlur:m,onFocus:h,errorSchema:g,rawErrors:_=[],registry:v,uiSchema:y,hideError:b,...x}){let{enumOptions:S,enumDisabled:C,emptyValue:w}=r;d=d===void 0?!1:!!d;let T=d?[]:``,E=u===void 0||d&&u.length<1||!d&&u===T,D=({target:{value:e}})=>p(Ot(e,S,w)),O=({target:e})=>m(t,Ot(e&&e.value,S,w)),k=({target:e})=>h(t,Ot(e&&e.value,S,w)),A=Et(u,S,d),{InputLabelProps:j,SelectProps:ee,autocomplete:M,...N}=x,P=!d&&e.default===void 0;return(0,G.jsxs)(B,{id:t,name:t,value:!E&&A!==void 0?A:T,required:o,disabled:s||l,autoFocus:f,autoComplete:M,placeholder:c,error:_.length>0,onChange:D,onBlur:O,onFocus:k,...N,select:!0,InputLabelProps:{...j,shrink:!E},SelectProps:{...ee,multiple:d},"aria-describedby":Dt(t),children:[P&&(0,G.jsx)(R,{value:``,children:c}),Array.isArray(S)&&S.map(({value:e,label:t},n)=>{let r=Array.isArray(C)&&C.indexOf(e)!==-1;return(0,G.jsx)(R,{value:String(n),disabled:r,children:t},n)})]})}return Q&&console.log(`ConfigPluginDialog rendering...`),!e||!p||!u?null:(0,G.jsxs)(x,{open:e,onClose:t,slotProps:{paper:{sx:{maxWidth:`800px`}}},children:[(0,G.jsx)(M,{gap:`20px`,children:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,G.jsx)(`h3`,{children:`Matterbridge plugin configuration`})]})}),(0,G.jsx)(P,{style:{padding:`0px`,margin:`0px`,width:`800px`,height:`600px`,overflow:`auto`},children:(0,G.jsx)(kt,{schema:p,formData:u,uiSchema:g,validator:Tt,templates:{FieldTemplate:E,BaseInputTemplate:re,TitleFieldTemplate:ee,DescriptionFieldTemplate:A,FieldHelpTemplate:N,FieldErrorTemplate:ne,ErrorListTemplate:te,WrapIfAdditionalTemplate:T,ArrayFieldTitleTemplate:ae,ArrayFieldDescriptionTemplate:oe,ArrayFieldItemTemplate:se,ArrayFieldTemplate:le,ObjectFieldTemplate:ue,ButtonTemplates:{SubmitButton:fe,RemoveButton:L,AddButton:he,MoveUpButton:ge,MoveDownButton:_e}},widgets:{CheckboxWidget:ve,SelectWidget:ye},onChange:b,onSubmit:C})})]})};function zn(e){if(Q&&console.log(`getQRColor (id: ${e?.id}) received matter:`,e??`undefined`),e===void 0||!e.online||!e.qrPairingCode&&!e.manualPairingCode&&!e.fabricInformations&&!e.sessionInformations)return`red`;if(e.commissioned===!1&&e.qrPairingCode&&e.manualPairingCode)return`var(--primary-color)`;let t=0,n=0;for(let r of e.sessionInformations??[])r.fabric&&r.isPeerActive===!0&&t++,r.numberOfActiveSubscriptions>0&&(n+=r.numberOfActiveSubscriptions);return e.commissioned===!0&&e.fabricInformations&&e.sessionInformations&&(t===0||n===0)?`var(--secondary-color)`:`var(--div-text-color)`}function Bn({storeId:e,setStoreId:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,W.useContext)(q),{showConfirmCancelDialog:s}=(0,W.useContext)(It),c=(0,W.useRef)(o()),[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)([]),g=[{label:`Name`,id:`name`,required:!0,render:(e,t,n,r)=>(0,G.jsx)(V,{title:`Plugin path ${n.path}`,children:(0,G.jsx)(`span`,{style:{cursor:`pointer`},onClick:()=>E(n),children:n.name})})},{label:`Description`,id:`description`,render:(e,t,n,r)=>(0,G.jsx)(V,{title:`Open the plugin homepage`,children:(0,G.jsx)(`span`,{style:{cursor:`pointer`},onClick:()=>E(n),children:n.description})})},{label:`Version`,id:`version`,render:(e,t,n,r)=>(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(V,{title:`Plugin v.${n.version}`,children:(0,G.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,G.jsx)(G.Fragment,{children:n.author?n.author.replace(`https://github.com/`,``):`Unknown`})},{label:`Type`,id:`type`,render:(e,t,n,r)=>(0,G.jsx)(G.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,G.jsxs)(`div`,{style:{margin:`0px`,padding:`0px`,gap:`4px`,display:`flex`,flexDirection:`row`},children:[f&&f.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,G.jsx)(V,{title:`Shows the QRCode or the fabrics`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:zn(r.matter)},onClick:()=>{r.matter?.id&&t(r.matter?.id)},size:`small`,children:(0,G.jsx)(ae,{})})}),f&&f.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,G.jsx)(V,{title:`Restart the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`},onClick:()=>w(r),size:`small`,children:(0,G.jsx)(he,{})})}),(0,G.jsx)(V,{title:`Plugin config`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{disabled:r.restartRequired===!0,style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>N(r),size:`small`,children:(0,G.jsx)(_e,{})})}),f&&!f.readOnly&&(0,G.jsx)(V,{title:`Remove the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{v(`Remove plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`remove`,r)},size:`small`,children:(0,G.jsx)(We,{})})}),r.enabled?(0,G.jsx)(V,{title:`Disable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{v(`Disable plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`disable`,r)},size:`small`,children:(0,G.jsx)(l,{})})}):(0,G.jsx)(G.Fragment,{}),r.enabled?(0,G.jsx)(G.Fragment,{}):(0,G.jsx)(V,{title:`Enable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>T(r),size:`small`,children:(0,G.jsx)(Te,{})})}),(0,G.jsx)(V,{title:`Open the plugin help`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>O(r),size:`small`,children:(0,G.jsx)(Ye,{})})}),(0,G.jsx)(V,{title:`Open the plugin version history`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>k(r),size:`small`,children:(0,G.jsx)(He,{})})}),r.latestVersion!==void 0&&r.latestVersion!==r.version&&f&&!f.readOnly&&(0,G.jsx)(V,{title:`Update the plugin to the latest version`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{color:`var(--primary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>x(r),size:`small`,children:(0,G.jsx)(ge,{})})}),(r.version.includes(`-dev-`)||r.version.includes(`-git-`))&&r.devVersion!==void 0&&r.devVersion!==r.version&&f&&!f.readOnly&&(0,G.jsx)(V,{title:`Update the plugin to the latest dev version`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{color:`var(--secondary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>S(r),size:`small`,children:(0,G.jsx)(ge,{})})}),f&&!f.readOnly&&(0,G.jsx)(V,{title:`Sponsor the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`#b6409c`},onClick:()=>D(r),size:`small`,children:(0,G.jsx)($e,{})})})]})},{label:`Status`,id:`status`,required:!0,noSort:!0,render:(e,t,n,r)=>(0,G.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,G.jsx)(G.Fragment,{children:(0,G.jsx)(xn,{status:!1,enabledText:`Error`,disabledText:`Error`,tooltipText:`The plugin is in error state. Check the log!`})}):(0,G.jsx)(G.Fragment,{children:n.enabled===!1?(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(xn,{status:n.enabled,enabledText:`Enabled`,disabledText:`Disabled`,tooltipText:`Whether the plugin is enable or disabled`})}):(0,G.jsx)(G.Fragment,{children:n.loaded&&n.started&&n.configured?(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(xn,{status:n.loaded,enabledText:`Running`,tooltipText:`Whether the plugin is running`})}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(xn,{status:n.loaded,enabledText:`Loaded`,tooltipText:`Whether the plugin has been loaded`}),(0,G.jsx)(xn,{status:n.started,enabledText:`Started`,tooltipText:`Whether the plugin started`}),(0,G.jsx)(xn,{status:n.configured,enabledText:`Configured`,tooltipText:`Whether the plugin has been configured`})]})})})})}];(0,W.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`),h(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:c.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}`),h(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:c.current,sender:`HomePlugins`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})),e.id===c.current&&e.method===`/api/settings`?(Q&&console.log(`HomePlugins (id: ${e.id}) received settings:`,e.response),d(e.response.systemInformation),p(e.response.matterbridgeInformation)):e.id===c.current&&e.method===`/api/plugins`&&(Q&&console.log(`HomePlugins (id: ${e.id}) received ${e.response.length} plugins:`,e.response),h(e.response))};return i(e,c.current),Q&&console.log(`HomePlugins added WebSocket listener id:`,c.current),()=>{a(e),Q&&console.log(`HomePlugins removed WebSocket listener`)}},[i,a,r]),(0,W.useEffect)(()=>{n&&(Q&&console.log(`HomePlugins sending api requests`),r({id:c.current,sender:`HomePlugins`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:c.current,sender:`HomePlugins`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[n,r]);let _=(0,W.useRef)(null),v=(e,t,n,r)=>{Q&&console.log(`handleActionWithConfirmCancel ${n} ${r.name}`),_.current=r,s(e,t,n,y,b)},y=e=>{Q&&console.log(`handleConfirm action confirmed ${e} ${_.current?.name}`),e===`remove`&&_.current?C(_.current):e===`disable`&&_.current&&T(_.current),_.current=null},b=e=>{Q&&console.log(`handleCancel action canceled ${e} ${_.current?.name}`),_.current=null},x=e=>{Q&&console.log(`handleUpdatePlugin plugin:`,e.name),r({id:c.current,sender:`HomePlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e.name,restart:!1}})},S=e=>{Q&&console.log(`handleUpdateDevPlugin plugin:`,e.name),r({id:c.current,sender:`HomePlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e.name+`@dev`,restart:!1}})},C=e=>{Q&&console.log(`handleRemovePlugin plugin:`,e.name),r({id:c.current,sender:`HomePlugins`,method:`/api/removeplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},w=e=>{Q&&console.log(`handleRestartPlugin plugin:`,e.name),r({id:c.current,sender:`HomePlugins`,method:`/api/restartplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},T=e=>{Q&&console.log(`handleEnableDisablePlugin plugin:`,e.name,`enabled:`,e.enabled),e.enabled===!0?(e.enabled=!1,r({id:c.current,sender:`HomePlugins`,method:`/api/disableplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})):(e.enabled=!0,r({id:c.current,sender:`HomePlugins`,method:`/api/enableplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}}))},E=e=>{Q&&console.log(`handleHomepagePlugin plugin: ${e.name} homepage: ${e.homepage}`),e.homepage&&window.open(e.homepage,`_blank`)},D=e=>{Q&&console.log(`handleSponsorPlugin plugin:`,e.name,`funding:`,e.funding),e.funding&&window.open(e.funding,`_blank`)},O=e=>{Q&&console.log(`handleHelpPlugin plugin:`,e.name,`help:`,e.help),e.help&&window.open(e.help,`_blank`)},k=e=>{Q&&console.log(`handleChangelogPlugin plugin:`,e.name,`changelog:`,e.changelog),e.changelog&&window.open(e.changelog,`_blank`)},[A,j]=(0,W.useState)(),[ee,M]=(0,W.useState)(!1),N=e=>{Q&&console.log(`handleConfigPlugin plugin:`,e.name),r({id:c.current,sender:`HomePlugins`,method:`/api/select/devices`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:e.name}}),r({id:c.current,sender:`HomePlugins`,method:`/api/select/entities`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:e.name}}),j(e),P()},P=()=>{M(!0)};return Q&&console.log(`HomePlugins rendering...`),n?(0,G.jsxs)(Y,{children:[A&&(0,G.jsx)(Rn,{open:ee,onClose:()=>{M(!1)},plugin:A}),(0,G.jsx)(sn,{name:`Plugins`,columns:g,rows:m,footerRight:``,footerLeft:``})]}):(0,G.jsx)(Vt,{})}var Vn=(0,W.memo)(Bn),Hn=e=>`${e.pluginName}::${e.serial}`;function Un({storeId:e,setStoreId:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,W.useContext)(q),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(!0),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)([]),[h,g]=(0,W.useState)([]),[_,v]=(0,W.useState)([]),[y,b]=(0,W.useState)([]),x=(0,W.useRef)(o()),S=[{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,G.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,G.jsx)(E,{fontSize:`small`,sx:{color:`var(--primary-color)`}}):n.powerSource===`ok`?n.batteryLevel?(0,G.jsx)(V,{title:`Battery level: ${n.batteryLevel}%`,children:(0,G.jsx)(A,{fontSize:`small`,sx:{color:`green`}})}):(0,G.jsx)(A,{fontSize:`small`,sx:{color:`gray`}}):n.powerSource===`warning`?n.batteryLevel?(0,G.jsx)(V,{title:`Battery level: ${n.batteryLevel}%`,children:(0,G.jsx)(A,{fontSize:`small`,sx:{color:`yellow`}})}):(0,G.jsx)(A,{fontSize:`small`,sx:{color:`yellow`}}):n.powerSource===`critical`?n.batteryLevel?(0,G.jsx)(V,{title:`Battery level: ${n.batteryLevel}%`,children:(0,G.jsx)(A,{fontSize:`small`,sx:{color:`red`}})}):(0,G.jsx)(A,{fontSize:`small`,sx:{color:`red`}}):(0,G.jsx)(`span`,{})},{label:`Actions`,id:`selected`,required:!0,render:(n,r,i,a)=>(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`},children:[i.matter===void 0?(0,G.jsx)(`div`,{style:{width:`20px`,height:`20px`}}):(0,G.jsx)(V,{title:`Show the QRCode or the fabrics`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{onClick:()=>t(e===i.matter?.id?d?.matterbridgeInformation.bridgeMode===`bridge`?`Matterbridge`:null:i.matter?.id||null),"aria-label":`Show the QRCode`,sx:{margin:0,padding:0,color:zn(i.matter)},children:(0,G.jsx)(ae,{fontSize:`small`})})}),i.configUrl?(0,G.jsx)(V,{title:`Open the configuration page`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{onClick:()=>window.open(i.configUrl,`_blank`),"aria-label":`Open config url`,sx:{margin:0,padding:0},children:(0,G.jsx)(oe,{fontSize:`small`})})}):(0,G.jsx)(`div`,{style:{width:`20px`,height:`20px`}}),i.selected===void 0?(0,G.jsx)(`div`,{style:{width:`20px`,height:`20px`}}):(0,G.jsx)(V,{title:`Select/unselect the device`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(D,{checked:i.selected,onChange:e=>w(e,i),sx:{margin:`0`,marginLeft:`8px`,padding:`0`},size:`small`})})]})}],C=(0,W.useCallback)(e=>{e.selected=void 0;let t=p.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},[p]);(0,W.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:x.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}`),b(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`),c(!0)):e.method===`restart_not_required`?(Q&&console.log(`HomeDevices received restart_not_required`),c(!1)):e.method===`state_update`&&e.response.plugin&&e.response.serialNumber&&e.response.cluster.includes(`BasicInformation`)&&e.response.attribute===`reachable`&&(Q&&console.log(`HomeDevices updating device reachability for plugin ${e.response.plugin} serial ${e.response.serialNumber} value ${e.response.value}`),g(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===x.current&&e.method===`/api/settings`)Q&&console.log(`HomeDevices (id: ${e.id}) received settings:`,e.response),f(e.response),c(e.response.matterbridgeInformation.restartRequired||e.response.matterbridgeInformation.fixedRestartRequired);else if(e.id===x.current&&e.method===`/api/plugins`){if(Q&&console.log(`HomeDevices (id: ${e.id}) received ${e.response?.length} plugins:`,e.response),e.response){let t=!0;for(let n of e.response)n.enabled===!0&&(n.loaded!==!0||n.started!==!0||n.error===!0)&&(t=!1);if(!t)return;Q&&console.log(`HomeDevices reset plugins, devices and selectDevices`),u(!1),m(e.response),g([]),v([]),r({id:x.current,sender:`HomeDevices`,method:`/api/devices`,src:`Frontend`,dst:`Matterbridge`,params:{}}),Q&&console.log(`HomeDevices sent /api/devices`);for(let t of e.response)t.enabled===!0&&t.loaded===!0&&t.started===!0&&t.error!==!0&&(r({id:x.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===x.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=C(t);g(e.response)}}else e.id===x.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&&v(t=>{let n=t.filter(t=>t.pluginName!==e.response[0].pluginName),r=e.response.map(e=>({...e,selected:C(e)}));return[...n,...r]}))};return i(e,x.current),Q&&console.log(`HomeDevices added WebSocket listener id ${x.current}`),()=>{a(e),Q&&console.log(`HomeDevices removed WebSocket listener`)}},[p,i,a,r,C]),(0,W.useEffect)(()=>{if(h.length===0&&_.length===0){b([]);return}Q&&console.log(`HomeDevices mixing devices (${h.length}) and selectDevices (${_.length})`);let e=[];for(let t of h)e.push(t);for(let t of _)h.find(e=>e.pluginName===t.pluginName&&e.serial.includes(t.serial))||e.push(t);e.length>0&&(b(e),Q&&console.log(`HomeDevices mixed ${e.length} devices and selectDevices`))},[p,h,_,b]),(0,W.useEffect)(()=>{n&&(Q&&console.log(`HomeDevices sending /api/settings and /api/plugins requests`),r({id:x.current,sender:`HomeDevices`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:x.current,sender:`HomeDevices`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[n,r]);let w=(e,t)=>{Q&&console.log(`handleCheckboxChange: checkbox changed to ${e.target.checked} for device ${t.name} serial ${t.serial}`),h.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`),b(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])})):g(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:x.current,sender:`HomeDevices`,method:`/api/command`,src:`Frontend`,dst:`Matterbridge`,params:{command:`selectdevice`,plugin:t.pluginName,serial:t.serial,name:t.name}}):r({id:x.current,sender:`HomeDevices`,method:`/api/command`,src:`Frontend`,dst:`Matterbridge`,params:{command:`unselectdevice`,plugin:t.pluginName,serial:t.serial,name:t.name}})};return Q&&console.log(`HomeDevices rendering...`),n?(0,G.jsx)(Y,{style:{flex:`1 1 auto`},children:(0,G.jsx)(sn,{name:`Devices`,getRowKey:Hn,rows:y,columns:S,footerLeft:l?`Waiting for the plugins to fully load...`:`Registered devices: ${h.length.toString()}/${y.length.toString()}`,footerRight:s?`Restart required`:``})}):(0,G.jsx)(Vt,{})}var Wn=(0,W.memo)(Un);function Gn({children:e,style:t,name:n}){let{setCurrentPage:r}=(0,W.useContext)(It);return r(n),Q&&console.log(`MbfPage: current page set to ${n}`),(0,G.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,margin:`0px`,padding:`0px`,gap:`20px`,...t},children:e})}var Kn=()=>`ontouchstart`in window||window.DocumentTouch!==void 0&&document instanceof window.DocumentTouch?(Q&&console.log(`WebSocketLogs detectTouchscreen = true`),!0):(Q&&console.log(`WebSocketLogs detectTouchscreen = false`),!1);function qn(){let{messages:e,logAutoScroll:t}=(0,W.useContext)(Rt),[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)(()=>Kn(),[]),c=e=>r(!0),l=e=>r(!1);(0,W.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,G.jsx)(`div`,{style:{margin:`0px`,padding:`0px`},children:(0,G.jsxs)(`ul`,{style:{margin:`0px`,padding:`0px`},onMouseEnter:c,onMouseLeave:l,children:[e.map((e,t)=>(0,G.jsxs)(`li`,{style:{wordWrap:`break-word`,maxHeight:`200px`,overflow:`hidden`},children:[(0,G.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,G.jsx)(`span`,{style:{marginRight:`3px`,color:`#505050`},children:`[`+e.time+`]`}),e.name&&(0,G.jsx)(`span`,{style:{marginRight:`3px`,color:`#09516d`},children:`[`+e.name+`]`}),(0,G.jsx)(`span`,{style:{color:`var(--main-log-color)`},children:e.message})]},t)),(0,G.jsx)(`div`,{ref:i})]})})}var Jn=(0,W.memo)(qn);function Yn(){let[e,t]=(0,W.useState)(localStorage.getItem(K.logFilterLevel)??`info`),[n,r]=(0,W.useState)(localStorage.getItem(K.logFilterSearch)??`*`),{online:i,logAutoScroll:a}=(0,W.useContext)(q);return Q&&console.log(`HomeLogs rendering...`),i?(0,G.jsxs)(Y,{style:{flex:`1 1 auto`},children:[(0,G.jsxs)(Ut,{children:[(0,G.jsx)(X,{children:`Logs`}),(0,G.jsxs)(X,{style:{fontWeight:`normal`,fontSize:`12px`,marginTop:`2px`},children:[`Filter: logger level "`,e,`" and search "`,n===``?`*`:n,`" Scroll: `,a.current?`auto`:`manual`]})]}),(0,G.jsx)(qt,{style:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`10px`,alignItems:`start`},children:(0,G.jsx)(Jn,{})})]}):(0,G.jsx)(Vt,{})}var Xn=(0,W.memo)(Yn);function Zn(){let{online:e}=(0,W.useContext)(q);return Q&&console.log(`HomeBrowserRefresh rendering...`),e?(0,G.jsxs)(Y,{children:[(0,G.jsx)(Ut,{children:(0,G.jsx)(X,{children:`Frontend Update`})}),(0,G.jsxs)(qt,{style:{flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`},children:[(0,G.jsx)(`h4`,{style:{margin:0},children:`The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now.`}),(0,G.jsx)(`div`,{children:(0,G.jsx)(j,{onClick:()=>window.location.reload(),endIcon:(0,G.jsx)(b,{}),style:{marginLeft:`10px`,color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Refresh`})})]})]}):(0,G.jsx)(Vt,{})}var Qn=(0,W.memo)(Zn);function $n({changelog:e}){let{online:t}=(0,W.useContext)(q);return Q&&console.log(`HomeShowChangelog rendering...`),t?(0,G.jsxs)(Y,{children:[(0,G.jsx)(Ut,{children:(0,G.jsx)(X,{children:`Matterbridge Update`})}),(0,G.jsxs)(qt,{style:{flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`},children:[(0,G.jsx)(`h4`,{style:{margin:0},children:`Matterbridge has been updated.`}),(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:`10px`},children:[(0,G.jsx)(j,{onClick:()=>window.open(`https://github.com/Luligu/matterbridge`,`_blank`),endIcon:(0,G.jsx)(N,{style:{color:`#FFD700`}}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Star`}),(0,G.jsx)(j,{onClick:()=>window.open(`https://www.buymeacoffee.com/luligugithub`,`_blank`),endIcon:(0,G.jsx)($e,{style:{color:`#b6409c`}}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Sponsor`}),(0,G.jsx)(j,{onClick:()=>window.open(e,`_blank`),endIcon:(0,G.jsx)(He,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Changelog`}),(0,G.jsx)(j,{onClick:()=>window.location.reload(),endIcon:(0,G.jsx)(re,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Close`})]})]})]}):(0,G.jsx)(Vt,{})}var er=(0,W.memo)($n);function tr({matterbridgeInfo:e}){let{mobile:t}=(0,W.useContext)(It);Q&&console.log(`MatterbridgeInfoTable:`,e);let n=[`matterbridgeLatestVersion`,`matterbridgeDevVersion`,`--matterFileLogger`,`--fileLogger`,`--matterLoggerLevel`,`--loggerLevel`,`--virtualMode`,`--bridgeMode`,`--restartMode`,`--restartRequired`,`fixedRestartRequired`,`--updateRequired`,`matterMdnsInterface`,`matterIpv4Address`,`matterIpv6Address`,`readOnly`,`shellyBoard`,`shellySysUpdate`,`shellyMainUpdate`,`matterPort`,`matterDiscriminator`,`matterPasscode`],[r,i]=(0,W.useState)(!1);return!e||r?null:(Q&&console.log(`MatterbridgeInfoTable rendering...`),(0,G.jsxs)(Y,{style:$&&t?{flex:`1 1 300px`}:{flex:`0 1 auto`,width:`302px`,minWidth:`302px`},children:[(0,G.jsxs)(Ut,{children:[(0,G.jsx)(X,{children:`Matterbridge info`}),(0,G.jsx)(Jt,{close:()=>i(!0)})]}),(0,G.jsx)(qt,{style:$&&t?{flex:`1 1 auto`,margin:`0px`,padding:`0px`,gap:`0px`}:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`0px`,gap:`0px`},children:(0,G.jsxs)(`table`,{style:{border:`none`,borderCollapse:`collapse`,tableLayout:`fixed`},children:[(0,G.jsxs)(`colgroup`,{children:[(0,G.jsx)(`col`,{style:{width:`40%`}}),(0,G.jsx)(`col`,{style:{width:`60%`}})]}),(0,G.jsx)(`tbody`,{style:{border:`none`,borderCollapse:`collapse`},children:Object.entries(e).filter(([e,t])=>!n.includes(e)&&t!=null&&t!==``).map(([e,n],r)=>(0,G.jsxs)(`tr`,{className:r%2==0?`table-content-even`:`table-content-odd`,style:{border:`none`,borderCollapse:`collapse`},children:[(0,G.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`},children:e.replace(`matterbridgeVersion`,`Matterbridge version`).replace(`matterbridgeLatestVersion`,`Matterbridge latest v.`).replace(`matterbridgeDevVersion`,`Matterbridge dev v.`).replace(`frontendVersion`,`Frontend version`).replace(`homeDirectory`,`Home`).replace(`rootDirectory`,`Root`).replace(`matterbridgeDirectory`,`Storage`).replace(`matterbridgeCertDirectory`,`Cert`).replace(`matterbridgePluginDirectory`,`Plugins`).replace(`globalModulesDirectory`,`Modules`).replace(`bridgeMode`,`Bridge mode`).replace(`restartMode`,`Restart mode`).replace(`virtualMode`,`Virtual mode`).replace(`profile`,`Profile`).replace(`loggerLevel`,`Logger level`).replace(`fileLogger`,`File logger`).replace(`loggerLevel`,`Logger level`).replace(`fileLogger`,`File logger`).replace(`matterLoggerLevel`,`Matter logger level`).replace(`matterFileLogger`,`Matter file logger`).replace(`restartRequired`,`Restart required`).replace(`updateRequired`,`Update required`)}),(0,G.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:$&&t?typeof n==`string`?n:n.toString():(0,G.jsx)(Ht,{value:typeof n==`string`?n:n.toString(),maxChars:24})})]},e))})]})})]}))}var nr=(0,W.memo)(tr);function rr(){let[e,t]=(0,W.useState)(null),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)([]),[o]=(0,W.useState)(localStorage.getItem(K.homePagePlugins)!==`false`),[s,c]=(0,W.useState)(localStorage.getItem(K.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)(It),{addListener:v,removeListener:y,online:b,sendMessage:x,getUniqueId:S}=(0,W.useContext)(q),C=(0,W.useRef)(S());return(0,W.useEffect)(()=>{let e=e=>{Q&&console.log(`Home received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`settings`&&(Q&&console.log(`Home received refresh_required: changed=${e.response.changed} and sending /api/settings request`),g(null),a([]),x({id:C.current,sender:`Home`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),x({id:C.current,sender:`Home`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})),e.method===`/api/settings`&&e.id===C.current&&(Q&&console.log(`Home received settings:`,e.response),t(e.response.systemInformation),r(e.response.matterbridgeInformation),localStorage.getItem(K.frontendVersion)===null&&e.response.matterbridgeInformation.frontendVersion?localStorage.setItem(K.frontendVersion,e.response.matterbridgeInformation.frontendVersion):e.response.matterbridgeInformation.frontendVersion!==localStorage.getItem(K.frontendVersion)&&e.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem(K.frontendVersion,e.response.matterbridgeInformation.frontendVersion),m(!0)),localStorage.getItem(K.matterbridgeVersion)===null?localStorage.setItem(K.matterbridgeVersion,e.response.matterbridgeInformation.matterbridgeVersion):e.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem(K.matterbridgeVersion)&&(localStorage.setItem(K.matterbridgeVersion,e.response.matterbridgeInformation.matterbridgeVersion),f(!0)),e.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem(K.homePageMode)||(localStorage.setItem(K.homePageMode,`devices`),c(`devices`)))),e.method===`/api/plugins`&&e.id===C.current&&(Q&&console.log(`Home received plugins:`,e.response),a(e.response))};return v(e,C.current),Q&&console.log(`Home added WebSocket listener id ${C.current}`),()=>{y(e),Q&&console.log(`Home removed WebSocket listener`)}},[v,y,x]),(0,W.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,W.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,G.jsx)(Vt,{}):(0,G.jsxs)(Gn,{name:`Home`,style:$&&_?{alignItems:`center`,gap:`10px`}:{flexDirection:`row`},children:[($&&!_||!$)&&(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,width:`302px`,minWidth:`302px`,gap:`20px`},children:[(0,G.jsx)(en,{id:h}),(0,G.jsx)(Xt,{systemInfo:e,compact:!0})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,width:`100%`,gap:$&&_?`10px`:`20px`},children:[p&&(0,G.jsx)(Qn,{}),d&&(0,G.jsx)(er,{changelog:l}),$&&_&&(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:`10px`},children:[(0,G.jsx)(en,{id:h}),(0,G.jsx)(Xt,{systemInfo:e,compact:!0}),(0,G.jsx)(nr,{matterbridgeInfo:n})]}),o&&!n.readOnly&&(0,G.jsx)(bn,{}),o&&(0,G.jsx)(Vn,{storeId:h,setStoreId:g}),s===`devices`&&(0,G.jsx)(Wn,{storeId:h,setStoreId:g}),s===`logs`&&(0,G.jsx)(Xn,{})]})]})}var ir=(0,W.memo)(rr),ar=!1,or={display:`flex`,gap:`2px`,justifyContent:`space-evenly`,width:`100%`,height:`40px`},sr={margin:`0`,padding:`0`,fontSize:`36px`,fontWeight:`medium`,color:`var(--primary-color)`},cr={margin:`0`,padding:`0`,fontSize:`20px`,fontWeight:`medium`,color:`var(--div-text-color)`,textAlign:`center`},lr={margin:`0`,padding:`0`,paddingBottom:`2px`,fontSize:`16px`,fontWeight:`medium`,color:`var(--div-text-color)`,textAlign:`center`},ur={display:`flex`,gap:`2px`,justifyContent:`center`,width:`100%`,height:`18px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},dr={margin:`0`,padding:`0`,fontSize:`12px`,fontWeight:`normal`,color:`var(--div-text-color)`},fr={display:`flex`,justifyContent:`center`,width:`100%`,height:`52px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},pr={margin:`0`,padding:`0`,fontSize:`14px`,fontWeight:`bold`,color:`var(--div-text-color)`},mr={display:`flex`,gap:`4px`,justifyContent:`center`,width:`100%`,height:`15px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},hr={margin:`0`,padding:`0px 4px`,borderRadius:`5px`,textAlign:`center`,fontSize:`12px`,fontWeight:`normal`,color:`var(--secondary-color)`},gr=[256,257,268,269],_r=[266,267],vr=[259,260,261,271,272],yr=[256,257,268,269,266,267,259,260,261,272];function Z({icon:e,iconColor:t,cluster:n,value:r,unit:i,prefix:a}){return Q&&console.log(`Render cluster "${n.clusterName}.${n.attributeName}" value(${typeof r}-${isNaN(r)}) "${r}" unit "${i}"`),a??=!1,(0,G.jsxs)(F,{sx:or,children:[e&&(0,W.cloneElement)(e,{key:`${n.clusterId}-${n.attributeId}-icon`,sx:{...sr,color:t??`var(--primary-color)`}}),(0,G.jsxs)(F,{sx:{...or,gap:`4px`,alignContent:`center`,alignItems:`end`,justifyContent:`center`},children:[i&&a===!0&&(0,G.jsx)(U,{sx:lr,children:i},`${n.clusterId}-${n.attributeId}-unit`),(0,G.jsx)(U,{sx:cr,children:r==null||typeof r==`number`&&isNaN(r)||r===`NaN`?`---`:r},`${n.clusterId}-${n.attributeId}-value`),i&&a===!1&&(0,G.jsx)(U,{sx:lr,children:i},`${n.clusterId}-${n.attributeId}-unit`)]},`${n.clusterId}-${n.attributeId}-valueunitbox`)]},`${n.clusterId}-${n.attributeId}-box`)}function br({device:e,endpoint:t,id:n,deviceType:r,clusters:i}){let a=[`Unknown`,`Good`,`Fair`,`Moderate`,`Poor`,`VeryPoor`,`Ext.Poor`],o=``;Q&&console.log(`Device "${e.name}" endpoint "${t}" id "${n}" deviceType "0x${r.toString(16).padStart(4,`0`)}" clusters (${i?.length})`);let s=i.find(e=>e.clusterName===`Descriptor`&&e.attributeName===`tagList`)?.attributeLocalValue;if(s){let e=``;s.map(t=>{t.label&&(e+=t.label+` `)}),o=e.trim()}if(r===17&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`batVoltage`).map(e=>o=`${e.attributeLocalValue} mV`),yr.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,G.jsxs)(Y,{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,G.jsx)(Z,{icon:e.attributeLocalValue===!0?(0,G.jsx)(k,{}):(0,G.jsx)(Fe,{}),iconColor:e.attributeLocalValue===!0?`green`:`red`,cluster:e,value:e.attributeLocalValue===!0?`Online`:`Offline`})),r===17&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`batPercentRemaining`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(A,{}),cluster:e,value:e.attributeLocalValue/2,unit:`%`})),r===17&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`wiredCurrentType`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(E,{}),cluster:e,value:e.attributeLocalValue===0?`AC`:`DC`})),r===1293&&i.filter(e=>e.clusterName===`DeviceEnergyManagement`&&e.attributeName===`esaState`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.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`})),gr.includes(r)&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(xe,{}),cluster:e,value:e.attributeLocalValue===!0?`On`:`Off`})),_r.includes(r)&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.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`})),vr.includes(r)&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M8 6V18H16V6H8M14 10H10V8H14V10M19.4 1.6C19 1.2 18.5 1 18 1H6C5.5 1 5 1.2 4.6 1.6C4.2 2 4 2.5 4 3V21C4 21.5 4.2 22 4.6 22.4C5 22.8 5.5 23 6 23H18C18.5 23 19 22.8 19.4 22.4C19.8 22 20 21.5 20 21V3C20 2.5 19.8 2 19.4 1.6M18 21H6V3H18V21Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===!0?`On`:`Off`})),r===115&&i.filter(e=>e.clusterName===`OperationalState`&&e.attributeName===`operationalState`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M14.83,11.17C16.39,12.73 16.39,15.27 14.83,16.83C13.27,18.39 10.73,18.39 9.17,16.83L14.83,11.17M6,2H18A2,2 0 0,1 20,4V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2M7,4A1,1 0 0,0 6,5A1,1 0 0,0 7,6A1,1 0 0,0 8,5A1,1 0 0,0 7,4M10,4A1,1 0 0,0 9,5A1,1 0 0,0 10,6A1,1 0 0,0 11,5A1,1 0 0,0 10,4M12,8A6,6 0 0,0 6,14A6,6 0 0,0 12,20A6,6 0 0,0 18,14A6,6 0 0,0 12,8Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Normal`:`Error`})),r===124&&i.filter(e=>e.clusterName===`OperationalState`&&e.attributeName===`operationalState`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M6,2H18A2,2 0 0,1 20,4V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2M7,4A1,1 0 0,0 6,5A1,1 0 0,0 7,6A1,1 0 0,0 8,5A1,1 0 0,0 7,4M10,4A1,1 0 0,0 9,5A1,1 0 0,0 10,6A1,1 0 0,0 11,5A1,1 0 0,0 10,4M12,8A6,6 0 0,0 6,14A6,6 0 0,0 12,20A6,6 0 0,0 18,14A6,6 0 0,0 12,8M8.11,10.5H10C9.76,11.88 10,12.67 10.58,13.29C11.68,14.36 12.16,15.71 11.89,17.5H10C10.24,16.12 10,15.33 9.42,14.71C8.32,13.64 7.85,12.29 8.11,10.5M12.11,10.5H14C13.76,11.88 14,12.67 14.58,13.29C15.68,14.36 16.16,15.71 15.89,17.5H14C14.24,16.12 14,15.33 13.42,14.71C12.32,13.64 11.85,12.29 12.11,10.5Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Normal`:`Error`})),r===117&&i.filter(e=>e.clusterName===`OperationalState`&&e.attributeName===`operationalState`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M18,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V4A2,2 0 0,0 18,2M10,4A1,1 0 0,1 11,5A1,1 0 0,1 10,6A1,1 0 0,1 9,5A1,1 0 0,1 10,4M7,4A1,1 0 0,1 8,5A1,1 0 0,1 7,6A1,1 0 0,1 6,5A1,1 0 0,1 7,4M18,20H6V8H18V20M14.67,15.33C14.69,16.03 14.41,16.71 13.91,17.21C12.86,18.26 11.15,18.27 10.09,17.21C9.59,16.71 9.31,16.03 9.33,15.33C9.4,14.62 9.63,13.94 10,13.33C10.37,12.5 10.81,11.73 11.33,11L12,10C13.79,12.59 14.67,14.36 14.67,15.33`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Normal`:`Error`})),r===123&&i.filter(e=>e.clusterName===`BridgedDeviceBasicInformation`&&e.attributeName===`reachable`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(Xe,{}),cluster:e,value:`Oven`})),r===112&&i.filter(e=>e.clusterName===`BridgedDeviceBasicInformation`&&e.attributeName===`reachable`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(Ue,{}),cluster:e,value:`Fridge`})),r===113&&i.filter(e=>e.clusterName===`TemperatureControl`&&e.attributeName===`selectedTemperatureLevel`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M5,3A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3H5M12,5C13.57,5 15,5.5 16.19,6.4L14,8.56C13.43,8.21 12.74,8 12,8A4,4 0 0,0 8,12C8,13.1 8.45,14.1 9.17,14.83L7.05,16.95C5.78,15.68 5,13.93 5,12A7,7 0 0,1 12,5M17.6,7.81C18.5,9 19,10.43 19,12C19,13.93 18.22,15.68 16.95,16.95L14.83,14.83C15.55,14.1 16,13.1 16,12C16,11.26 15.79,10.57 15.43,10L17.6,7.81Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue,unit:`mode`,prefix:!0})),r===121&&i.filter(e=>e.clusterName===`OperationalState`&&e.attributeName===`operationalState`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(Xe,{}),cluster:e,value:e.attributeLocalValue===0?`Normal`:`Error`})),r===122&&i.filter(e=>e.clusterName===`FanControl`&&e.attributeName===`fanMode`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M19,18.31V20A2,2 0 0,1 17,22H7A2,2 0 0,1 5,20V16.3C4.54,16.12 3.95,16 3,16A1,1 0 0,1 2,15A1,1 0 0,1 3,14C3.82,14 4.47,14.08 5,14.21V12.3C4.54,12.12 3.95,12 3,12A1,1 0 0,1 2,11A1,1 0 0,1 3,10C3.82,10 4.47,10.08 5,10.21V8.3C4.54,8.12 3.95,8 3,8A1,1 0 0,1 2,7A1,1 0 0,1 3,6C3.82,6 4.47,6.08 5,6.21V4A2,2 0 0,1 7,2H17A2,2 0 0,1 19,4V6.16C20.78,6.47 21.54,7.13 21.71,7.29C22.1,7.68 22.1,8.32 21.71,8.71C21.32,9.1 20.8,9.09 20.29,8.71V8.71C20.29,8.71 19.25,8 17,8C15.74,8 14.91,8.41 13.95,8.9C12.91,9.41 11.74,10 10,10C9.64,10 9.31,10 9,9.96V7.95C9.3,8 9.63,8 10,8C11.26,8 12.09,7.59 13.05,7.11C14.09,6.59 15.27,6 17,6V4H7V20H17V18C18.5,18 18.97,18.29 19,18.31M17,10C15.27,10 14.09,10.59 13.05,11.11C12.09,11.59 11.26,12 10,12C9.63,12 9.3,12 9,11.95V13.96C9.31,14 9.64,14 10,14C11.74,14 12.91,13.41 13.95,12.9C14.91,12.42 15.74,12 17,12C19.25,12 20.29,12.71 20.29,12.71V12.71C20.8,13.1 21.32,13.1 21.71,12.71C22.1,12.32 22.1,11.69 21.71,11.29C21.5,11.08 20.25,10 17,10M17,14C15.27,14 14.09,14.59 13.05,15.11C12.09,15.59 11.26,16 10,16C9.63,16 9.3,16 9,15.95V17.96C9.31,18 9.64,18 10,18C11.74,18 12.91,17.41 13.95,16.9C14.91,16.42 15.74,16 17,16C19.25,16 20.29,16.71 20.29,16.71V16.71C20.8,17.1 21.32,17.1 21.71,16.71C22.1,16.32 22.1,15.69 21.71,15.29C21.5,15.08 20.25,14 17,14Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue,unit:`mode`,prefix:!0})),r===120&&i.filter(e=>e.clusterName===`BridgedDeviceBasicInformation`&&e.attributeName===`reachable`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M6,14H8L11,17H9L6,14M4,4H5V3A1,1 0 0,1 6,2H10A1,1 0 0,1 11,3V4H13V3A1,1 0 0,1 14,2H18A1,1 0 0,1 19,3V4H20A2,2 0 0,1 22,6V19A2,2 0 0,1 20,21V22H17V21H7V22H4V21A2,2 0 0,1 2,19V6A2,2 0 0,1 4,4M18,7A1,1 0 0,1 19,8A1,1 0 0,1 18,9A1,1 0 0,1 17,8A1,1 0 0,1 18,7M14,7A1,1 0 0,1 15,8A1,1 0 0,1 14,9A1,1 0 0,1 13,8A1,1 0 0,1 14,7M20,6H4V10H20V6M4,19H20V12H4V19M6,7A1,1 0 0,1 7,8A1,1 0 0,1 6,9A1,1 0 0,1 5,8A1,1 0 0,1 6,7M13,14H15L18,17H16L13,14Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`Cooktop`})),r===119&&i.filter(e=>e.clusterName===`TemperatureControl`&&e.attributeName===`selectedTemperatureLevel`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M6,14H8L11,17H9L6,14M4,4H5V3A1,1 0 0,1 6,2H10A1,1 0 0,1 11,3V4H13V3A1,1 0 0,1 14,2H18A1,1 0 0,1 19,3V4H20A2,2 0 0,1 22,6V19A2,2 0 0,1 20,21V22H17V21H7V22H4V21A2,2 0 0,1 2,19V6A2,2 0 0,1 4,4M18,7A1,1 0 0,1 19,8A1,1 0 0,1 18,9A1,1 0 0,1 17,8A1,1 0 0,1 18,7M14,7A1,1 0 0,1 15,8A1,1 0 0,1 14,9A1,1 0 0,1 13,8A1,1 0 0,1 14,7M20,6H4V10H20V6M4,19H20V12H4V19M6,7A1,1 0 0,1 7,8A1,1 0 0,1 6,9A1,1 0 0,1 5,8A1,1 0 0,1 6,7M13,14H15L18,17H16L13,14Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue,unit:`mode`,prefix:!0})),r===514&&i.filter(e=>e.clusterName===`WindowCovering`&&e.attributeName===`currentPositionLiftPercent100ths`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(ct,{}),cluster:e,value:e.attributeLocalValue/100,unit:`%`})),r===769&&i.filter(e=>e.clusterName===`Thermostat`&&e.attributeName===`localTemperature`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M16.95,16.95L14.83,14.83C15.55,14.1 16,13.1 16,12C16,11.26 15.79,10.57 15.43,10L17.6,7.81C18.5,9 19,10.43 19,12C19,13.93 18.22,15.68 16.95,16.95M12,5C13.57,5 15,5.5 16.19,6.4L14,8.56C13.43,8.21 12.74,8 12,8A4,4 0 0,0 8,12C8,13.1 8.45,14.1 9.17,14.83L7.05,16.95C5.78,15.68 5,13.93 5,12A7,7 0 0,1 12,5M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:(e.attributeLocalValue??0)/100,unit:`°C`})),r===10&&i.filter(e=>e.clusterName===`DoorLock`&&e.attributeName===`lockState`).map(e=>(0,G.jsx)(Z,{icon:e.attributeValue===`1`?(0,G.jsx)(ve,{}):(0,G.jsx)(De,{}),cluster:e,value:e.attributeValue===`1`?`Locked`:`Unlocked`})),r===43&&i.filter(e=>e.clusterName===`FanControl`&&e.attributeName===`percentCurrent`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(ze,{}),cluster:e,value:e.attributeValue,unit:`%`})),r===15&&i.filter(e=>e.clusterName===`Switch`&&e.attributeName===`currentPosition`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M13 5C15.21 5 17 6.79 17 9C17 10.5 16.2 11.77 15 12.46V11.24C15.61 10.69 16 9.89 16 9C16 7.34 14.66 6 13 6S10 7.34 10 9C10 9.89 10.39 10.69 11 11.24V12.46C9.8 11.77 9 10.5 9 9C9 6.79 10.79 5 13 5M20 20.5C19.97 21.32 19.32 21.97 18.5 22H13C12.62 22 12.26 21.85 12 21.57L8 17.37L8.74 16.6C8.93 16.39 9.2 16.28 9.5 16.28H9.7L12 18V9C12 8.45 12.45 8 13 8S14 8.45 14 9V13.47L15.21 13.6L19.15 15.79C19.68 16.03 20 16.56 20 17.14V20.5M20 2H4C2.9 2 2 2.9 2 4V12C2 13.11 2.9 14 4 14H8V12L4 12L4 4H20L20 12H18V14H20V13.96L20.04 14C21.13 14 22 13.09 22 12V4C22 2.9 21.11 2 20 2Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeValue,unit:`pos`,prefix:!0})),r===39&&i.filter(e=>e.clusterName===`ModeSelect`&&e.attributeName===`currentMode`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(Se,{}),cluster:e,value:e.attributeValue,unit:`Mode`,prefix:!0})),r===771&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(ke,{}),cluster:e,value:e.attributeLocalValue===!0?`On`:`Off`})),r===45&&i.filter(e=>e.clusterName===`FanControl`&&e.attributeName===`percentCurrent`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(Ge,{}),cluster:e,value:e.attributeValue,unit:`%`})),r===114&&i.filter(e=>e.clusterName===`Thermostat`&&e.attributeName===`localTemperature`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(Ge,{}),cluster:e,value:(e.attributeLocalValue??0)/100,unit:`°C`})),r===67&&i.filter(e=>e.clusterName===`BooleanState`&&e.attributeName===`stateValue`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(et,{}),cluster:e,value:e.attributeLocalValue===!0?`Leak`:`No leak`})),r===65&&i.filter(e=>e.clusterName===`BooleanState`&&e.attributeName===`stateValue`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(Ee,{}),cluster:e,value:e.attributeLocalValue===!0?`Freeze`:`No freeze`})),r===68&&i.filter(e=>e.clusterName===`BooleanState`&&e.attributeName===`stateValue`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(we,{}),cluster:e,value:e.attributeLocalValue===!0?`Rain`:`No rain`})),r===116&&i.filter(e=>e.clusterName===`RvcRunMode`&&e.attributeName===`currentMode`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M12,2C14.65,2 17.19,3.06 19.07,4.93L17.65,6.35C16.15,4.85 14.12,4 12,4C9.88,4 7.84,4.84 6.35,6.35L4.93,4.93C6.81,3.06 9.35,2 12,2M3.66,6.5L5.11,7.94C4.39,9.17 4,10.57 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12C20,10.57 19.61,9.17 18.88,7.94L20.34,6.5C21.42,8.12 22,10.04 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12C2,10.04 2.58,8.12 3.66,6.5M12,6A6,6 0 0,1 18,12C18,13.59 17.37,15.12 16.24,16.24L14.83,14.83C14.08,15.58 13.06,16 12,16C10.94,16 9.92,15.58 9.17,14.83L7.76,16.24C6.63,15.12 6,13.59 6,12A6,6 0 0,1 12,6M12,8A1,1 0 0,0 11,9A1,1 0 0,0 12,10A1,1 0 0,0 13,9A1,1 0 0,0 12,8Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeValue,unit:`Run mode`,prefix:!0})),r===1292&&i.filter(e=>e.clusterName===`EnergyEvse`&&e.attributeName===`state`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M19.77,7.23L19.78,7.22L16.06,3.5L15,4.56L17.11,6.67C16.17,7.03 15.5,7.93 15.5,9A2.5,2.5 0 0,0 18,11.5C18.36,11.5 18.69,11.42 19,11.29V18.5A1,1 0 0,1 18,19.5A1,1 0 0,1 17,18.5V14A2,2 0 0,0 15,12H14V5A2,2 0 0,0 12,3H6A2,2 0 0,0 4,5V21H14V13.5H15.5V18.5A2.5,2.5 0 0,0 18,21A2.5,2.5 0 0,0 20.5,18.5V9C20.5,8.31 20.22,7.68 19.77,7.23M18,10A1,1 0 0,1 17,9A1,1 0 0,1 18,8A1,1 0 0,1 19,9A1,1 0 0,1 18,10M8,18V13.5H6L10,6V11H12L8,18Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Free`:`In use`})),r===1295&&i.filter(e=>e.clusterName===`WaterHeaterManagement`&&e.attributeName===`tankPercentage`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M8 2C6.89 2 6 2.89 6 4V16C6 17.11 6.89 18 8 18H9V20H6V22H9C10.11 22 11 21.11 11 20V18H13V20C13 21.11 13.89 22 15 22H18V20H15V18H16C17.11 18 18 17.11 18 16V4C18 2.89 17.11 2 16 2H8M12 4.97A2 2 0 0 1 14 6.97A2 2 0 0 1 12 8.97A2 2 0 0 1 10 6.97A2 2 0 0 1 12 4.97M10 14.5H14V16H10V14.5Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`Tank `+(e.attributeLocalValue??0)+`%`})),r===777&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`featureMap`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3M12.75 7.08C13.57 7.2 14.32 7.5 14.95 8L12.75 10.19V7.08M11.25 7.08V10.19L9.05 8C9.68 7.5 10.43 7.2 11.25 7.08M8 9.05L10.19 11.25H7.08C7.2 10.43 7.5 9.68 8 9.05M7.08 12.75H10.19L8 14.95C7.5 14.32 7.2 13.57 7.08 12.75M11.25 16.92C10.43 16.8 9.68 16.5 9.05 16L11.25 13.81V16.92M12 13C11.45 13 11 12.55 11 12S11.45 11 12 11 13 11.45 13 12 12.55 13 12 13M12.75 16.92V13.81L14.95 16C14.32 16.5 13.57 16.8 12.75 16.92M16 14.95L13.81 12.75H16.92C16.8 13.57 16.5 14.32 16 14.95M13.81 11.25L16 9.05C16.5 9.69 16.8 10.44 16.92 11.25H13.81Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`HeatPump`})),r===23&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`featureMap`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M4,2H20A2,2 0 0,1 22,4V14A2,2 0 0,1 20,16H15V20H18V22H13V16H11V22H6V20H9V16H4A2,2 0 0,1 2,14V4A2,2 0 0,1 4,2M4,4V8H11V4H4M4,14H11V10H4V14M20,14V10H13V14H20M20,4H13V8H20V4Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`Solar`})),r===24&&i.filter(e=>e.clusterName===`ElectricalPowerMeasurement`&&e.attributeName===`featureMap`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M12 20L5 20V12H2L12 3L14.78 5.5H14V7.17C12.84 7.58 12 8.7 12 10V20M15 9H16V7.5H20V9H21C21.55 9 22 9.45 22 10V21C22 21.55 21.55 22 21 22H15C14.45 22 14 21.55 14 21V10C14 9.45 14.45 9 15 9M16 11V14H20V11H16Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`Inverter`})),r===118&&i.find(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`featureMap`&&e.attributeLocalValue.smokeAlarm===!0)&&i.filter(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`smokeState`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M12 4C16.41 4 20 7.59 20 12S16.41 20 12 20 4 16.41 4 12 7.59 4 12 4M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 11C11.45 11 11 11.45 11 12S11.45 13 12 13 13 12.55 13 12 12.55 11 12 11M10.72 9.3C11.11 9.11 11.54 9 12 9S12.89 9.11 13.29 9.3L14 8.57C13.43 8.22 12.74 8 12 8S10.58 8.22 10 8.57L10.72 9.3M15 12C15 12.46 14.89 12.89 14.7 13.29L15.43 14C15.79 13.43 16 12.74 16 12S15.79 10.58 15.43 10L14.7 10.72C14.89 11.11 15 11.54 15 12M9 12C9 11.54 9.11 11.11 9.3 10.72L8.57 10C8.22 10.58 8 11.26 8 12S8.22 13.43 8.57 14L9.3 13.29C9.11 12.89 9 12.46 9 12M13.29 14.7C12.89 14.89 12.46 15 12 15S11.11 14.89 10.72 14.7L10 15.43C10.58 15.79 11.26 16 12 16S13.43 15.79 14 15.43L13.29 14.7M16.89 8.53L16.17 9.25C16.69 10.04 17 11 17 12S16.69 13.96 16.17 14.75L16.89 15.47C17.59 14.5 18 13.3 18 12S17.59 9.5 16.89 8.53M9.25 7.83C10.04 7.31 11 7 12 7S13.96 7.31 14.75 7.83L15.47 7.11C14.5 6.42 13.3 6 12 6S9.5 6.42 8.53 7.11L9.25 7.83M14.75 16.17C13.96 16.69 13 17 12 17S10.04 16.69 9.25 16.17L8.53 16.89C9.5 17.59 10.7 18 12 18S14.5 17.59 15.47 16.89L14.75 16.17M7.83 14.75C7.31 13.96 7 13 7 12S7.31 10.04 7.83 9.25L7.11 8.53C6.42 9.5 6 10.7 6 12S6.42 14.5 7.11 15.47L7.83 14.75Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`No smoke`:`Smoke!`})),r===118&&i.find(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`featureMap`&&e.attributeLocalValue.smokeAlarm===!1)&&i.filter(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`coState`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M12 4C16.41 4 20 7.59 20 12S16.41 20 12 20 4 16.41 4 12 7.59 4 12 4M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 11C11.45 11 11 11.45 11 12S11.45 13 12 13 13 12.55 13 12 12.55 11 12 11M10.72 9.3C11.11 9.11 11.54 9 12 9S12.89 9.11 13.29 9.3L14 8.57C13.43 8.22 12.74 8 12 8S10.58 8.22 10 8.57L10.72 9.3M15 12C15 12.46 14.89 12.89 14.7 13.29L15.43 14C15.79 13.43 16 12.74 16 12S15.79 10.58 15.43 10L14.7 10.72C14.89 11.11 15 11.54 15 12M9 12C9 11.54 9.11 11.11 9.3 10.72L8.57 10C8.22 10.58 8 11.26 8 12S8.22 13.43 8.57 14L9.3 13.29C9.11 12.89 9 12.46 9 12M13.29 14.7C12.89 14.89 12.46 15 12 15S11.11 14.89 10.72 14.7L10 15.43C10.58 15.79 11.26 16 12 16S13.43 15.79 14 15.43L13.29 14.7M16.89 8.53L16.17 9.25C16.69 10.04 17 11 17 12S16.69 13.96 16.17 14.75L16.89 15.47C17.59 14.5 18 13.3 18 12S17.59 9.5 16.89 8.53M9.25 7.83C10.04 7.31 11 7 12 7S13.96 7.31 14.75 7.83L15.47 7.11C14.5 6.42 13.3 6 12 6S9.5 6.42 8.53 7.11L9.25 7.83M14.75 16.17C13.96 16.69 13 17 12 17S10.04 16.69 9.25 16.17L8.53 16.89C9.5 17.59 10.7 18 12 18S14.5 17.59 15.47 16.89L14.75 16.17M7.83 14.75C7.31 13.96 7 13 7 12S7.31 10.04 7.83 9.25L7.11 8.53C6.42 9.5 6 10.7 6 12S6.42 14.5 7.11 15.47L7.83 14.75Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`No Co`:`Co!`})),r===66&&i.filter(e=>e.clusterName===`ValveConfigurationAndControl`&&e.attributeName===`currentState`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(Le,{}),cluster:e,value:e.attributeLocalValue===0?`Closed`:`Opened`})),r===44&&i.filter(e=>e.clusterName===`AirQuality`&&e.attributeName===`airQuality`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M11,9A4,4 0 0,1 15,13A4,4 0 0,1 11,17A4,4 0 0,1 7,13A4,4 0 0,1 11,9M11,11A2,2 0 0,0 9,13A2,2 0 0,0 11,15A2,2 0 0,0 13,13A2,2 0 0,0 11,11M7,4H14A4,4 0 0,1 18,8V9H16V8A2,2 0 0,0 14,6H7A2,2 0 0,0 5,8V20H16V18H18V22H3V8A4,4 0 0,1 7,4M16,11C18.5,11 18.5,9 21,9V11C18.5,11 18.5,13 16,13V11M16,15C18.5,15 18.5,13 21,13V15C18.5,15 18.5,17 16,17V15Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:a[e.attributeLocalValue??0]})),r===770&&i.filter(e=>e.clusterName===`TemperatureMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(se,{}),cluster:e,value:e.attributeLocalValue/100,unit:`°C`})),r===775&&i.filter(e=>e.clusterName===`RelativeHumidityMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M12,3.25C12,3.25 6,10 6,14C6,17.32 8.69,20 12,20A6,6 0 0,0 18,14C18,10 12,3.25 12,3.25M14.47,9.97L15.53,11.03L9.53,17.03L8.47,15.97M9.75,10A1.25,1.25 0 0,1 11,11.25A1.25,1.25 0 0,1 9.75,12.5A1.25,1.25 0 0,1 8.5,11.25A1.25,1.25 0 0,1 9.75,10M14.25,14.5A1.25,1.25 0 0,1 15.5,15.75A1.25,1.25 0 0,1 14.25,17A1.25,1.25 0 0,1 13,15.75A1.25,1.25 0 0,1 14.25,14.5Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue/100,unit:`%`})),r===774&&i.filter(e=>e.clusterName===`FlowMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(ot,{}),cluster:e,value:e.attributeLocalValue,unit:`l/h`})),r===773&&i.filter(e=>e.clusterName===`PressureMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(m,{}),cluster:e,value:e.attributeLocalValue,unit:`hPa`})),r===21&&i.filter(e=>e.clusterName===`BooleanState`&&e.attributeName===`stateValue`).map(e=>(0,G.jsx)(Z,{icon:e.attributeValue===`true`?(0,G.jsx)(g,{}):(0,G.jsx)(te,{}),cluster:e,value:e.attributeValue===`true`?`Closed`:`Opened`})),r===263&&i.filter(e=>e.clusterName===`OccupancySensing`&&e.attributeName===`occupancy`).map(e=>(0,G.jsx)(Z,{icon:e.attributeValue===`{ occupied: true }`?(0,G.jsx)(v,{}):(0,G.jsx)(le,{}),cluster:e,value:e.attributeValue===`{ occupied: true }`?`Occupied`:`Unocc.`})),r===262&&i.filter(e=>e.clusterName===`IlluminanceMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(it,{}),cluster:e,value:Math.round(10**(e.attributeLocalValue/1e4)),unit:`lx`})),r===1296&&i.filter(e=>e.clusterName===`ElectricalEnergyMeasurement`&&e.attributeName===`cumulativeEnergyImported`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(nt,{}),cluster:e,value:Math.round(e.attributeLocalValue?.energy/1e6),unit:`kwh`})),(0,G.jsx)(F,{sx:ur,children:(0,G.jsx)(U,{sx:dr,children:o})}),(0,G.jsx)(F,{sx:fr,children:(0,G.jsx)(U,{sx:pr,children:e.name})}),(0,G.jsxs)(F,{sx:mr,children:[Q&&(0,G.jsx)(U,{sx:hr,children:t}),(0,G.jsx)(U,{sx:hr,children:n}),Q&&(0,G.jsxs)(U,{sx:hr,children:[`0x`,r.toString(16).padStart(4,`0`)]})]})]})}function xr({filterPlugins:e,filterDevices:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,W.useContext)(q),[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=>{(Q||ar)&&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||ar)&&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||ar)&&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||ar)&&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(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,W.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,W.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,W.memo)(br),y=e?.trim().toLowerCase(),b=y&&y!==`all plugins`;return Q&&console.log(`DevicesIcons rendering...`),(0,G.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,G.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 Sr=(0,W.memo)(xr),Cr=[{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,G.jsx)(I,{onClick:()=>window.open(n.configUrl,`_blank`),"aria-label":`Open Config`,sx:{margin:0,padding:0},children:(0,G.jsx)(oe,{fontSize:`small`})}):null},{label:`Cluster`,id:`cluster`}],wr=[{label:`Endpoint`,id:`endpoint`,required:!0},{label:`Id`,id:`id`},{label:`Device Types`,id:`deviceTypes`,render:(e,t,n,r)=>Array.isArray(e)?(0,G.jsx)(G.Fragment,{children:e.map(e=>`0x${e.toString(16).padStart(4,`0`)}`).join(`, `)}):(0,G.jsx)(G.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}],Tr=e=>`${e.pluginName}::${e.uniqueId}`,Er=e=>`${e.endpoint}::${e.clusterName}::${e.attributeName}`;function Dr({filterPlugins:e,filterDevices:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,W.useContext)(q),[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=>{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,W.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,W.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,W.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,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]),Q&&console.log(`DevicesTable rendering...`),n?(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,margin:`0px`,padding:`0px`,gap:`20px`,width:`100%`,overflow:`hidden`},children:[(0,G.jsx)(Y,{style:{margin:`0px`,padding:`0px`,gap:`0px`,width:`100%`,maxHeight:`${h&&_?`30%`:`100%`}`,flex:`1 1 auto`,overflow:`hidden`},children:(0,G.jsx)(sn,{name:`Registered devices`,getRowKey:Tr,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:Cr,footerLeft:`Total devices: ${l.length.toString()}`})}),h&&_&&(0,G.jsx)(Y,{style:{margin:`0px`,padding:`0px`,gap:`0px`,width:`100%`,height:`70%`,maxHeight:`70%`,flex:`1 1 auto`,overflow:`hidden`},children:(0,G.jsx)(sn,{name:`Clusters`,title:y||``,getRowKey:Er,rows:d,columns:wr,footerLeft:`Total child endpoints: ${p-1}`})})]}):(0,G.jsx)(Vt,{})}var Or=(0,W.memo)(Dr);function kr(){let{online:e,sendMessage:t,addListener:n,removeListener:r,getUniqueId:i}=(0,W.useContext)(q),[a,o]=(0,W.useState)([`All plugins`]),[s,c]=(0,W.useState)(`All plugins`),[l,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(`icon`),m=(0,W.useRef)(i());(0,W.useEffect)(()=>{let e=localStorage.getItem(K.devicesFilterPlugins);e&&c(e)},[]),(0,W.useEffect)(()=>{let e=localStorage.getItem(K.devicesFilterDevices);e&&d(e)},[]),(0,W.useEffect)(()=>{let e=localStorage.getItem(K.devicesViewMode);e&&p(e)},[]),(0,W.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,W.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=>{d(e.target.value),localStorage.setItem(K.devicesFilterDevices,e.target.value)},_=()=>{d(``),localStorage.removeItem(K.devicesFilterDevices)},v=e=>{p(e),localStorage.setItem(K.devicesViewMode,e)};return Q&&console.log(`Devices rendering...`),e?(0,G.jsxs)(Gn,{name:`Devices`,children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,padding:0,margin:0,gap:`20px`,width:`100%`},children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,padding:0,margin:0,gap:`20px`},children:[(0,G.jsxs)(F,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(U,{sx:{fontSize:`16px`,fontWeight:`normal`,color:`var(--div-text-color)`,marginLeft:`5px`,whiteSpace:`nowrap`},children:`Plugin:`}),(0,G.jsx)(V,{title:`Filter devices by plugin`,children:(0,G.jsx)(Ke,{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,G.jsx)(Oe,{sx:{backgroundColor:`var(--main-bg-color)`}}),children:a.map(e=>(0,G.jsx)(R,{value:e,children:e},e))})})]}),(0,G.jsxs)(F,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(U,{sx:{fontSize:`16px`,fontWeight:`normal`,color:`var(--div-text-color)`,marginLeft:`5px`,whiteSpace:`nowrap`},children:`Filter by:`}),(0,G.jsx)(V,{title:`Filter devices by name or serial number`,children:(0,G.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,G.jsx)(ue,{position:`end`,children:(0,G.jsx)(I,{"aria-label":`Clear device filter`,size:`small`,onClick:_,edge:`end`,children:(0,G.jsx)(u,{sx:{fontSize:18,color:`var(--main-label-color)`}})})}):null}}})})]})]}),(0,G.jsxs)(F,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(U,{sx:{fontSize:`16px`,fontWeight:`normal`,color:`var(--div-text-color)`,marginLeft:`5px`,whiteSpace:`nowrap`},children:`View mode:`}),(0,G.jsx)(I,{onClick:()=>v(`table`),"aria-label":`Table View`,disabled:f===`table`,children:(0,G.jsx)(V,{title:`Table View`,children:(0,G.jsx)(ee,{style:{color:f===`table`?`var(--main-icon-color)`:`var(--primary-color)`}})})}),(0,G.jsx)(I,{onClick:()=>v(`icon`),"aria-label":`Icon View`,disabled:f===`icon`,children:(0,G.jsx)(V,{title:`Icon View (beta)`,children:(0,G.jsx)(Ne,{style:{color:f===`icon`?`var(--main-icon-color)`:`var(--primary-color)`}})})})]})]}),f===`table`&&(0,G.jsx)(Or,{filterPlugins:s,filterDevices:l}),f===`icon`&&(0,G.jsx)(Sr,{filterPlugins:s,filterDevices:l})]}):(0,G.jsx)(Vt,{})}var Ar=(0,W.memo)(kr);function jr(){let{logLength:e,logAutoScroll:t,setMessages:n,setLogFilterLevel:r,setLogFilterSearch:i,online:a,filterLogMessages:o}=(0,W.useContext)(q),[s,c]=(0,W.useState)(localStorage.getItem(K.logFilterLevel)??`info`),[l,u]=(0,W.useState)(localStorage.getItem(K.logFilterSearch)??`*`),[d,f]=(0,W.useState)(e.current.toString()),[p,m]=(0,W.useState)(t.current);return Q&&console.log(`Logs rendering...`),a?(0,G.jsxs)(Gn,{name:`Logs`,children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`,margin:`0px`,padding:`0px`,gap:`10px`},children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(at,{id:`select-level`,style:{color:`var(--div-text-color)`},children:`Filter log by level:`}),(0,G.jsxs)(Ke,{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,G.jsx)(R,{value:`debug`,children:`Debug`}),(0,G.jsx)(R,{value:`info`,children:`Info`}),(0,G.jsx)(R,{value:`notice`,children:`Notice`}),(0,G.jsx)(R,{value:`warn`,children:`Warn`}),(0,G.jsx)(R,{value:`error`,children:`Error`}),(0,G.jsx)(R,{value:`fatal`,children:`Fatal`})]})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`5px`},children:[(0,G.jsx)(at,{id:`search`,style:{color:`var(--div-text-color)`},children:`Filter log by text:`}),(0,G.jsx)(V,{title:`Use /text/ for case-insensitive regex search`,children:(0,G.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,G.jsx)(Ie,{control:(0,G.jsx)(D,{checked:p,onChange:e=>{let n=e.target.checked;m(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,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(at,{id:`select-size-label`,style:{color:`var(--div-text-color)`},children:`Log length:`}),(0,G.jsxs)(Ke,{style:{height:`30px`,backgroundColor:`var(--main-bg-color)`},labelId:`select-size-label`,id:`select-size`,value:d,onChange:t=>{let n=t.target.value;f(n),e.current=Number(n),localStorage.setItem(K.logLength,n),Q&&console.log(`handleLogLengthChange called with value:`,n)},children:[(0,G.jsx)(R,{value:100,children:`100`}),(0,G.jsx)(R,{value:200,children:`200`}),(0,G.jsx)(R,{value:500,children:`500`}),(0,G.jsx)(R,{value:1e3,children:`1000`})]}),(0,G.jsx)(V,{title:`Clear the logs`,children:(0,G.jsx)(j,{onClick:()=>{Q&&console.log(`handleClearLogsClick called`),n([])},endIcon:(0,G.jsx)(O,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Clear`})})]})]}),(0,G.jsx)(`div`,{style:{flex:`1`,overflow:`auto`,margin:`0px`,padding:`0px`},children:(0,G.jsx)(Jn,{})})]}):(0,G.jsx)(Vt,{})}var Mr=(0,W.memo)(jr),Nr=({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,G.jsxs)(x,{open:e,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||n()},maxWidth:`sm`,style:{maxWidth:`550px`,margin:`auto`},children:[(0,G.jsx)(M,{gap:`20px`,children:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,G.jsx)(`h4`,{style:{margin:0},children:`Network Configuration`})]})}),(0,G.jsxs)(P,{dividers:!0,children:[(0,G.jsxs)(d,{component:`fieldset`,fullWidth:!0,children:[(0,G.jsx)(_,{component:`legend`,children:`Select IP Configuration`}),(0,G.jsxs)(Be,{row:!0,value:a,onChange:e=>o(e.target.value),children:[(0,G.jsx)(Ie,{value:`dhcp`,control:(0,G.jsx)(Ae,{}),label:`DHCP`}),(0,G.jsx)(Ie,{value:`static`,control:(0,G.jsx)(Ae,{}),label:`Static`})]})]}),a===`static`&&(0,G.jsxs)(y,{container:!0,spacing:2,sx:{mt:2},children:[(0,G.jsx)(y,{size:6,children:(0,G.jsx)(B,{label:`IP Address`,fullWidth:!0,value:s.ip,onChange:l(`ip`)})}),(0,G.jsx)(y,{size:6,children:(0,G.jsx)(B,{label:`Subnet Mask`,fullWidth:!0,value:s.subnet,onChange:l(`subnet`)})}),(0,G.jsx)(y,{size:6,children:(0,G.jsx)(B,{label:`Gateway`,fullWidth:!0,value:s.gateway,onChange:l(`gateway`)})}),(0,G.jsx)(y,{size:6,children:(0,G.jsx)(B,{label:`DNS Server`,fullWidth:!0,value:s.dns,onChange:l(`dns`)})})]})]}),(0,G.jsxs)(ie,{children:[(0,G.jsx)(j,{onClick:()=>{n()},children:`Cancel`}),(0,G.jsx)(j,{variant:`contained`,onClick:()=>{r({type:a,...s}),n()},children:`Save`})]})]})},Pr=({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,G.jsxs)(x,{open:e,onClose:(e,n)=>{n===`backdropClick`||n===`escapeKeyDown`||t()},maxWidth:`sm`,style:{maxWidth:`500px`,margin:`auto`},disableEscapeKeyDown:!0,children:[(0,G.jsx)(M,{children:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,G.jsx)(`h4`,{style:{margin:0},children:`Change Password`})]})}),(0,G.jsx)(P,{dividers:!0,children:(0,G.jsx)(d,{component:`fieldset`,fullWidth:!0,sx:{margin:0,padding:0,gap:`20px`},children:(0,G.jsxs)(y,{container:!0,spacing:2,sx:{mt:2},children:[(0,G.jsx)(y,{size:12,children:(0,G.jsx)(B,{type:`password`,autoComplete:`new-password`,label:`New Password`,size:`small`,variant:`outlined`,fullWidth:!0,value:r,onChange:s})}),(0,G.jsx)(y,{size:12,children:(0,G.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,G.jsxs)(ie,{children:[(0,G.jsx)(j,{onClick:()=>{t()},children:`Cancel`}),(0,G.jsx)(j,{variant:`contained`,onClick:()=>{l&&(n(r),t())},disabled:!l,children:`Change`}),(0,G.jsx)(j,{variant:`contained`,onClick:()=>{n(``),t()},children:`Reset`})]})]})};function Fr(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 Ir=330;function Lr(){let{mobile:e}=(0,W.useContext)(It),{online:t,addListener:n,removeListener:r,sendMessage:i,getUniqueId:a}=(0,W.useContext)(q),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(null),u=(0,W.useRef)(a());return(0,W.useEffect)(()=>{let e=e=>{Q&&console.log(`Settings received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`settings`?(Q&&console.log(`Settings received refresh_required: changed=${e.response.changed} and sending /api/settings request`),i({id:u.current,sender:`Settings`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`/api/settings`&&(Q&&console.log(`Settings received /api/settings:`,e.response),s(e.response.matterbridgeInformation),l(e.response.systemInformation))};return n(e,u.current),Q&&console.log(`Settings added WebSocket listener`),()=>{r(e),Q&&console.log(`Settings removed WebSocket listener`)}},[n,r,i]),(0,W.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,G.jsx)(Vt,{}):(0,G.jsx)(Gn,{name:`Settings`,children:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:$&&e?`10px`:`20px`},children:[(0,G.jsx)(Rr,{matterbridgeInfo:o,systemInfo:c}),(0,G.jsx)(zr,{matterbridgeInfo:o}),(0,G.jsx)(Br,{matterbridgeInfo:o}),(0,G.jsx)(Vr,{systemInfo:c})]})})}function Rr({matterbridgeInfo:e,systemInfo:t}){let{sendMessage:n,getUniqueId:r}=(0,W.useContext)(q),[i,a]=(0,W.useState)(`bridge`),[o,s]=(0,W.useState)(`Info`),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(`dark`),[f,p]=(0,W.useState)(localStorage.getItem(K.homePagePlugins)!==`false`),[m,h]=(0,W.useState)(localStorage.getItem(K.homePageMode)??`devices`),[g,v]=(0,W.useState)(localStorage.getItem(K.virtualMode)??`outlet`),y=(0,W.useRef)(r()),[b,x]=(0,W.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,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(K.frontendTheme);e&&d(e)},[]),!e||!t?null:(0,G.jsxs)(Y,{style:{flex:`1 1 ${Ir}px`},children:[(0,G.jsx)(Ut,{children:(0,G.jsx)(X,{children:`Matterbridge settings`})}),(0,G.jsx)(Nr,{open:b,ip:t.ipv4Address,onClose:S,onSave:C}),(0,G.jsx)(Pr,{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}}),ai(e)}}),(0,G.jsxs)(qt,{style:{flexDirection:`column`,padding:`10px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`},children:[(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`matterbridgeInfo-mode`,children:`Mode:`}),(0,G.jsxs)(Be,{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,G.jsx)(Ie,{value:`bridge`,control:(0,G.jsx)(Ae,{}),label:`Bridge`,disabled:e.readOnly===!0}),(0,G.jsx)(Ie,{value:`childbridge`,control:(0,G.jsx)(Ae,{}),label:`Childbridge`,disabled:e.readOnly===!0})]})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`mblogger-level-label`,children:`Logger level:`}),(0,G.jsxs)(Ke,{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,G.jsx)(R,{value:`Debug`,children:`Debug`}),(0,G.jsx)(R,{value:`Info`,children:`Info`}),(0,G.jsx)(R,{value:`Notice`,children:`Notice`}),(0,G.jsx)(R,{value:`Warn`,children:`Warn`}),(0,G.jsx)(R,{value:`Error`,children:`Error`}),(0,G.jsx)(R,{value:`Fatal`,children:`Fatal`})]})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`mblogger-file-label`,children:`Log on file:`}),(0,G.jsx)(D,{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,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`frontend-theme-label`,children:`Frontend theme:`}),(0,G.jsxs)(Ke,{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),d(t),localStorage.setItem(K.frontendTheme,t),document.body.setAttribute(`frontend-theme`,t)},children:[(0,G.jsx)(R,{value:`classic`,children:`Classic`}),(0,G.jsx)(R,{value:`light`,children:`Light`}),(0,G.jsx)(R,{value:`dark`,children:`Dark`})]})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`frontend-home-plugin-label`,children:`Home page plugins:`}),(0,G.jsx)(D,{checked:f,onChange:e=>{let t=e.target.checked;Q&&console.log(`handleChangeHomePagePlugins called with value:`,t),p(t),localStorage.setItem(K.homePagePlugins,t?`true`:`false`)},name:`showPlugins`})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`frontend-home-label`,children:`Home page bottom panel:`}),(0,G.jsxs)(Ke,{style:{height:`30px`},labelId:`frontend-home-label`,id:`frontend-home`,value:m,onChange:e=>{let t=e.target.value;Q&&console.log(`handleChangeHomePageMode called with value:`,t),h(t),localStorage.setItem(K.homePageMode,t)},children:[(0,G.jsx)(R,{value:`logs`,children:`Logs`}),(0,G.jsx)(R,{value:`devices`,children:`Devices`})]})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`10px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`frontend-virtual-label`,children:`Virtual devices:`}),(0,G.jsxs)(Ke,{style:{height:`30px`},labelId:`frontend-virtual-label`,id:`frontend-virtual`,value:g,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,G.jsx)(R,{value:`disabled`,children:`Disabled`}),(0,G.jsx)(R,{value:`outlet`,children:`Outlet`}),(0,G.jsx)(R,{value:`light`,children:`Light`}),(0,G.jsx)(R,{value:`switch`,children:`Switch`}),(0,G.jsx)(R,{value:`mounted_switch`,children:`Mounted Switch`})]})]}),(0,G.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`20px`},children:(0,G.jsx)(j,{variant:`contained`,color:`primary`,onClick:()=>T(!0),children:`Change password`})}),e.shellyBoard&&(0,G.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`20px`},children:(0,G.jsx)(j,{variant:`contained`,color:`primary`,onClick:()=>x(!0),children:`Configure IP`})})]})]})}function zr({matterbridgeInfo:e}){let{sendMessage:t,getUniqueId:n}=(0,W.useContext)(q),[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,y]=(0,W.useState)(``),b=(0,W.useRef)(n()),x=(0,W.useMemo)(()=>Fr(1e3),[]),S=(0,W.useMemo)(()=>Fr(1e3),[]),C=(0,W.useMemo)(()=>Fr(1e3),[]),w=(0,W.useMemo)(()=>Fr(1e3),[]),T=(0,W.useMemo)(()=>Fr(1e3),[]),E=(0,W.useMemo)(()=>Fr(1e3),[]);return(0,W.useEffect)(()=>{e&&(i([`Debug`,`Info`,`Notice`,`Warn`,`Error`,`Fatal`][e.matterLoggerLevel]),o(e.matterFileLogger),c(e.matterMdnsInterface||``),u(e.matterIpv4Address||``),f(e.matterIpv6Address||``),m(e.matterPort?e.matterPort.toString():``),g(e.matterDiscriminator?e.matterDiscriminator.toString():``),y(e.matterPasscode?e.matterPasscode.toString():``))},[e]),(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]),(0,W.useEffect)(()=>()=>E.cancel(),[E]),e?(0,G.jsxs)(Y,{style:{flex:`1 1 ${Ir}px`},children:[(0,G.jsx)(Ut,{children:(0,G.jsx)(X,{children:`Matter settings`})}),(0,G.jsxs)(qt,{style:{flexDirection:`column`,padding:`10px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`},children:[(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`mjlogger-level-label`,children:`Logger level:`}),(0,G.jsxs)(Ke,{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:b.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmjloglevel`,value:e.target.value}})},children:[(0,G.jsx)(R,{value:`Debug`,children:`Debug`}),(0,G.jsx)(R,{value:`Info`,children:`Info`}),(0,G.jsx)(R,{value:`Notice`,children:`Notice`}),(0,G.jsx)(R,{value:`Warn`,children:`Warn`}),(0,G.jsx)(R,{value:`Error`,children:`Error`}),(0,G.jsx)(R,{value:`Fatal`,children:`Fatal`})]})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`10px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`mjlogger-file-label`,children:`Log on file:`}),(0,G.jsx)(D,{checked:a,onChange:e=>{Q&&console.log(`handleLogOnFileMjChange called with value:`,e.target.checked),o(e.target.checked),t({id:b.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmjlogfile`,value:e.target.checked}})},id:`mjlogger-file`,name:`logOnFileMj`})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Mdns interface:`}),(0,G.jsx)(B,{value:s,onChange:e=>{Q&&console.log(`handleChangeMdnsInterface called with value:`,e.target.value);let n=e.target.value;c(n),x(()=>{Q&&console.log(`debounced sendMessage setmdnsinterface with value:`,n),t({id:b.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmdnsinterface`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Ipv4 address:`}),(0,G.jsx)(B,{value:l,onChange:e=>{Q&&console.log(`handleChangeIpv4Address called with value:`,e.target.value);let n=e.target.value;u(n),S(()=>{Q&&console.log(`debounced sendMessage setipv4address with value:`,n),t({id:b.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setipv4address`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Ipv6 address:`}),(0,G.jsx)(B,{value:d,onChange:e=>{Q&&console.log(`handleChangeIpv6Address called with value:`,e.target.value);let n=e.target.value;f(n),C(()=>{Q&&console.log(`debounced sendMessage setipv6address with value:`,n),t({id:b.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setipv6address`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning port:`}),(0,G.jsx)(B,{value:p,onChange:e=>{Q&&console.log(`handleChangeMatterPort called with value:`,e.target.value);let n=e.target.value;m(n),w(()=>{Q&&console.log(`debounced sendMessage setmatterport with value:`,n),t({id:b.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterport`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning discriminator:`}),(0,G.jsx)(B,{value:h,onChange:e=>{Q&&console.log(`handleChangeMatterDiscriminator called with value:`,e.target.value);let n=e.target.value;g(n),T(()=>{Q&&console.log(`debounced sendMessage setmatterdiscriminator with value:`,n),t({id:b.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterdiscriminator`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning passcode:`}),(0,G.jsx)(B,{value:v,onChange:e=>{Q&&console.log(`handleChangemMatterPasscode called with value:`,e.target.value);let n=e.target.value;y(n),E(()=>{Q&&console.log(`debounced sendMessage setmatterpasscode with value:`,n),t({id:b.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterpasscode`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]})]})]}):null}function Br({matterbridgeInfo:e}){return e?(0,G.jsxs)(Y,{style:{flex:`1 1 ${Ir}px`},children:[(0,G.jsx)(Ut,{children:(0,G.jsx)(X,{children:`Matterbridge info`})}),(0,G.jsxs)(qt,{style:{flexDirection:`column`,padding:`10px`,gap:`5px`},children:[(0,G.jsx)(Hr,{value:e.matterbridgeVersion,label:`Current Version`}),(0,G.jsx)(Hr,{value:e.matterbridgeLatestVersion,label:`Latest Version`}),(0,G.jsx)(Hr,{value:e.rootDirectory,label:`Root Directory`}),(0,G.jsx)(Hr,{value:e.homeDirectory,label:`Home Directory`}),(0,G.jsx)(Hr,{value:e.matterbridgeDirectory,label:`Matterbridge Storage Directory`}),(0,G.jsx)(Hr,{value:e.matterbridgePluginDirectory,label:`Matterbridge Plugin Directory`}),(0,G.jsx)(Hr,{value:e.globalModulesDirectory,label:`Global Module Directory`})]})]}):null}function Vr({systemInfo:e}){return e?(0,G.jsxs)(Y,{style:{flex:`1 1 ${Ir}px`},children:[(0,G.jsx)(Ut,{children:(0,G.jsx)(X,{children:`System info`})}),(0,G.jsxs)(qt,{style:{flexDirection:`column`,padding:`10px`,gap:`5px`},children:[(0,G.jsx)(Hr,{value:e.interfaceName,label:`Interface name`}),(0,G.jsx)(Hr,{value:e.macAddress,label:`MAC Address`}),(0,G.jsx)(Hr,{value:e.ipv4Address,label:`IPv4 Address`}),(0,G.jsx)(Hr,{value:e.ipv6Address,label:`IPv6 Address`}),(0,G.jsx)(Hr,{value:e.nodeVersion,label:`Node Version`}),(0,G.jsx)(Hr,{value:e.hostname,label:`Hostname`}),(0,G.jsx)(Hr,{value:e.user,label:`User`})]})]}):null}function Hr({value:e,label:t,width:n}){return(0,G.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 Ur=(0,W.memo)(Lr);function Wr(){let{online:e,sendMessage:t,addListener:n,removeListener:r,getUniqueId:i}=(0,W.useContext)(q),{showSnackbarMessage:a}=(0,W.useContext)(It),[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 Q&&console.log(`Test uniqueId:`,b),(0,W.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,W.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,G.jsx)(Gn,{name:`Test`,children:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,justifyContent:`center`,alignItems:`center`,alignContent:`center`,gap:`20px`,height:`100vh`,width:`100vw`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`256px`,width:`256px`,margin:`10px`}}),(0,G.jsx)(`p`,{children:`Welcome to the Test page of the Matterbridge frontend`})]})}):(0,G.jsx)(Vt,{})}var Gr=(0,W.memo)(Wr);function Kr(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 qr(e){return L({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 Jr(){let{mobile:e,showSnackbarMessage:t,showConfirmCancelDialog:n}=(0,W.useContext)(It),{online:i,sendMessage:a,logMessage:o,addListener:c,removeListener:l,getUniqueId:u}=(0,W.useContext)(q),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(!1),[y,b]=(0,W.useState)(null),x=(0,W.useRef)(u()),[S,C]=(0,W.useState)(null),[w,T]=(0,W.useState)(null),[E,D]=(0,W.useState)(null),[O,k]=(0,W.useState)(null),A=r(),j=()=>{window.open(`https://www.buymeacoffee.com/luligugithub`,`_blank`)},ee=()=>{window.open(`https://matterbridge.io/`)},M=()=>{window.open(`https://matterbridge.io/README.html`)},P=()=>{window.open(`https://matterbridge.io/CHANGELOG.html`)},te=()=>{window.open(`https://discord.gg/QX58CDe6hd`,`_blank`)},ne=()=>{window.open(`https://github.com/Luligu/matterbridge`,`_blank`)},re=()=>{a({id:x.current,sender:`Header`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:`matterbridge`,restart:!0}}),g(!1)},ie=()=>{a({id:x.current,sender:`Header`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:`matterbridge@dev`,restart:!0}}),v(!1)},ae=()=>{a({id:x.current,sender:`Header`,method:`/api/checkupdates`,src:`Frontend`,dst:`Matterbridge`,params:{}})},oe=()=>{Q&&console.log(`Header: handleShellySystemUpdateClick`),o(`Matterbridge`,`Installing system updates...`),a({id:x.current,sender:`Header`,method:`/api/shellysysupdate`,src:`Frontend`,dst:`Matterbridge`,params:{}})},F=()=>{Q&&console.log(`Header: handleShellyMainUpdateClick`),o(`Matterbridge`,`Installing software updates...`),a({id:x.current,sender:`Header`,method:`/api/shellymainupdate`,src:`Frontend`,dst:`Matterbridge`,params:{}})},se=()=>{Q&&console.log(`Header: handleShellyCreateSystemLog`),a({id:x.current,sender:`Header`,method:`/api/shellycreatesystemlog`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ce=()=>{Q&&console.log(`Header: handleShellyDownloadSystemLog`),o(`Matterbridge`,`Downloading Shelly system log...`),t(`Downloading Shelly system log...`,5),window.location.href=`./api/shellydownloadsystemlog`},le=()=>{y?.matterbridgeInformation.restartMode===``?a({id:x.current,sender:`Header`,method:`/api/restart`,src:`Frontend`,dst:`Matterbridge`,params:{}}):a({id:x.current,sender:`Header`,method:`/api/shutdown`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ue=()=>{a({id:x.current,sender:`Header`,method:`/api/shutdown`,src:`Frontend`,dst:`Matterbridge`,params:{}})},de=()=>{a({id:x.current,sender:`Header`,method:`/api/reboot`,src:`Frontend`,dst:`Matterbridge`,params:{}})},fe=()=>{a({id:x.current,sender:`Header`,method:`/api/softreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},pe=()=>{a({id:x.current,sender:`Header`,method:`/api/hardreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},me=e=>{C(e.currentTarget)},L=e=>{Q&&console.log(`Header: handleMenuClose`,e),C(null),e===`/`||e===`/devices`||e===`/log`||e===`/settings`?A(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:x.current,sender:`Header`,method:`/api/viewhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`download-history`?a({id:x.current,sender:`Header`,method:`/api/downloadhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`view-shellylog`?(o(`Matterbridge`,`Loading shelly system log...`),t(`Loading shelly system log...`,5),window.location.href=`./api/shellyviewsystemlog`):e===`download-mbstorage`?(o(`Matterbridge`,`Downloading matterbridge storage...`),t(`Downloading matterbridge storage...`,5),window.location.href=`./api/download-mbstorage`):e===`download-pluginstorage`?(o(`Matterbridge`,`Downloading matterbridge plugins storage...`),t(`Downloading matterbridge plugins storage...`,5),window.location.href=`./api/download-pluginstorage`):e===`download-pluginconfig`?(o(`Matterbridge`,`Downloading matterbridge plugins config...`),t(`Downloading matterbridge plugins config...`,5),window.location.href=`./api/download-pluginconfig`):e===`download-mjstorage`?(o(`Matterbridge`,`Downloading matter storage...`),t(`Downloading matter storage...`,5),window.location.href=`./api/download-mjstorage`):e===`download-backup`?(o(`Matterbridge`,`Downloading backup...`),t(`Downloading backup...`,10),window.location.href=`./api/download-backup`):e===`update`?re():e===`updatedev`?ie():e===`updatecheck`?ae():e===`shelly-sys-update`?oe():e===`shelly-main-update`?F():e===`shelly-create-system-log`?se():e===`shelly-download-system-log`?ce():e===`softreset`?fe():e===`hardreset`?pe():e===`restart`?le():e===`shutdown`?ue():e===`reboot`?de():e===`create-backup`?a({id:x.current,sender:`Header`,method:`/api/create-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-matterbridge-storage-backup`?a({id:x.current,sender:`Header`,method:`/api/create-matterbridge-storage-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-matter-storage-backup`?a({id:x.current,sender:`Header`,method:`/api/create-matter-storage-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-plugin-backup`?a({id:x.current,sender:`Header`,method:`/api/create-plugin-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-config-backup`?a({id:x.current,sender:`Header`,method:`/api/create-config-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`unregister`?a({id:x.current,sender:`Header`,method:`/api/unregister`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`reset`?a({id:x.current,sender:`Header`,method:`/api/reset`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`factoryreset`&&a({id:x.current,sender:`Header`,method:`/api/factoryreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},_e=e=>{Q&&console.log(`Header: handleMenuCloseCancel:`,e),C(null)},ve=e=>{T(e.currentTarget)},be=()=>{T(null)},xe=e=>{D(e.currentTarget)},Se=()=>{D(null)},Ce=e=>{k(e.currentTarget)},we=()=>{k(null)};return(0,W.useEffect)(()=>{let e=e=>{Q&&console.log(`Header received WebSocket Message:`,e),e.method===`/api/settings`&&e.id===x.current?(Q&&console.log(`Header received settings:`,e.response),b(e.response),f(e.response.matterbridgeInformation.restartRequired||e.response.matterbridgeInformation.fixedRestartRequired),m(e.response.matterbridgeInformation.fixedRestartRequired),g(e.response.matterbridgeInformation.updateRequired)):e.method===`refresh_required`&&e.response.changed===`settings`?(Q&&console.log(`Header received refresh_required: changed=${e.response.changed} and sending /api/settings request`),a({id:x.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`restart_required`?(Q&&console.log(`Header received restart_required with fixed: ${e.response.fixed}`),f(!0),e.response.fixed===!0&&m(!0)):e.method===`restart_not_required`?(Q&&console.log(`Header received restart_not_required`),f(!1)):e.method===`update_required`?(Q&&console.log(`Header received update_required`),e.response.devVersion===!0?v(!0):g(!0),a({id:x.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`shelly_sys_update`?(Q&&console.log(`Header received WS_ID_SHELLY_SYS_UPDATE:`),b(t=>t?{matterbridgeInformation:{...t.matterbridgeInformation,shellySysUpdate:e.response.available},systemInformation:t.systemInformation}:null)):e.method===`shelly_main_update`?(Q&&console.log(`Header received WS_ID_SHELLY_MAIN_UPDATE:`),b(t=>t?{matterbridgeInformation:{...t.matterbridgeInformation,shellyMainUpdate:e.response.available},systemInformation:t.systemInformation}:null)):e.method===`/api/viewhistorypage`&&e.id===x.current&&e.success===!0?(Q&&console.log(`Header received /api/viewhistorypage success`),window.open(`./api/viewhistory`,`_blank`,`noopener,noreferrer`)):e.method===`/api/downloadhistorypage`&&e.id===x.current&&e.success===!0?(Q&&console.log(`Header received /api/downloadhistorypage success`),window.location.href=`./api/downloadhistory`):e.method===`archive`&&e.success===!0&&e.response.command===`zip`&&(Q&&console.log(`Header received archive success response for zip command`,e.response),e.response.archivePath.endsWith(`matterbridge.backup.zip`)?window.location.href=`./api/download-backup`:e.response.archivePath.endsWith(`matterbridge.storage.zip`)?window.location.href=`./api/download-mbstorage`:e.response.archivePath.endsWith(`matterbridge.matterstorage.zip`)?window.location.href=`./api/download-mjstorage`:e.response.archivePath.endsWith(`matterbridge.pluginstorage.zip`)?window.location.href=`./api/download-pluginstorage`:e.response.archivePath.endsWith(`matterbridge.pluginconfig.zip`)&&(window.location.href=`./api/download-pluginconfig`))};return c(e,x.current),Q&&console.log(`Header added WebSocket listener id ${x.current}`),()=>{l(e),Q&&console.log(`Header removed WebSocket listener`)}},[c,l,a,t]),(0,W.useEffect)(()=>{i&&(Q&&console.log(`Header sending /api/settings and /api/checkupdates requests`),a({id:x.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),a({id:x.current,sender:`Header`,method:`/api/checkupdates`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[i,a]),Q&&console.log(`Header rendering... mobile %s`,e),!i||!y?null:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`,width:`100%`,gap:`10px`},children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`30px`},onClick:()=>{ti(),Q&&console.log(`Matterbridge logo clicked: debug is now`,Q)}}),(0,G.jsx)(`h2`,{style:{fontSize:`22px`,color:`var(--main-icon-color)`,margin:`0px`},children:`Matterbridge`})]}),(0,G.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:(0,G.jsxs)(`nav`,{children:[(0,G.jsx)(s,{to:`/`,className:`nav-link`,children:`Home`}),(0,G.jsx)(s,{to:`/devices`,className:`nav-link`,children:`Devices`}),(0,G.jsx)(s,{to:`/log`,className:`nav-link`,children:`Logs`}),(0,G.jsx)(s,{to:`/settings`,className:`nav-link`,children:`Settings`})]})})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[!y.matterbridgeInformation.readOnly&&(0,G.jsx)(V,{title:`Matterbridge v.${y.matterbridgeInformation.matterbridgeVersion}`,children:(0,G.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`},children:[`v.`,y.matterbridgeInformation.matterbridgeVersion.split(`-`)[0]+(y.matterbridgeInformation.matterbridgeVersion.includes(`-dev-`)?`@dev`:``)+(y.matterbridgeInformation.matterbridgeVersion.includes(`-edge-`)?`@edge`:``)+(y.matterbridgeInformation.matterbridgeVersion.includes(`-local-`)?`@local`:``)+(y.matterbridgeInformation.matterbridgeVersion.includes(`-git-`)?`@git`:``)]})}),y.matterbridgeInformation.shellyBoard&&(0,G.jsx)(`img`,{src:`Shelly.svg`,alt:`Shelly Icon`,style:{height:`30px`,padding:`0px`,margin:`0px`,marginRight:`30px`}}),y.matterbridgeInformation.bridgeMode!==``&&y.matterbridgeInformation.readOnly===!1?(0,G.jsx)(V,{title:`Bridge mode`,children:(0,G.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:y.matterbridgeInformation.bridgeMode})}):null,y.matterbridgeInformation.restartMode!==``&&y.matterbridgeInformation.readOnly===!1?(0,G.jsx)(V,{title:`Restart mode`,children:(0,G.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:y.matterbridgeInformation.restartMode})}):null,y.matterbridgeInformation.profile&&y.matterbridgeInformation.profile!==``&&y.matterbridgeInformation.readOnly===!1?(0,G.jsx)(V,{title:`Current profile`,children:(0,G.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:y.matterbridgeInformation.profile})}):null,Q&&(0,G.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`},children:[e?`Mobile `:`Desktop `,`${Zr}x${Qr}`,` enabled ${localStorage.getItem(K.enableMobile)!==`false`}`]})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`5px`},children:[y.matterbridgeInformation.readOnly===!1?(0,G.jsx)(V,{title:`Matterbridge discord group`,children:(0,G.jsx)(`img`,{src:`discord.svg`,alt:`Discord Logo`,style:{cursor:`pointer`,height:`25px`},onClick:te})}):null,y.matterbridgeInformation.readOnly===!1?(0,G.jsx)(V,{title:`Give a star to Matterbridge`,children:(0,G.jsx)(I,{style:{color:`#FFD700`,margin:`0`,padding:`0`},onClick:ne,children:(0,G.jsx)(N,{})})}):null,y.matterbridgeInformation.readOnly===!1?(0,G.jsx)(V,{title:`Sponsor Matterbridge`,children:(0,G.jsx)(I,{style:{color:`#b6409c`,margin:`0`,padding:`0`},onClick:j,children:(0,G.jsx)($e,{})})}):null,(0,G.jsx)(V,{title:`Matterbridge homepage`,children:(0,G.jsx)(I,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:ee,children:(0,G.jsx)(Me,{})})}),(0,G.jsx)(V,{title:`Matterbridge help`,children:(0,G.jsx)(I,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:M,children:(0,G.jsx)(Ye,{})})}),(0,G.jsx)(V,{title:`Matterbridge changelog`,children:(0,G.jsx)(I,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:P,children:(0,G.jsx)(He,{})})}),y.matterbridgeInformation&&!y.matterbridgeInformation.readOnly&&h&&(0,G.jsx)(V,{title:`Update matterbridge to latest version v.${y.matterbridgeInformation.matterbridgeLatestVersion}`,children:(0,G.jsx)(I,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:re,children:(0,G.jsx)(ge,{})})}),y.matterbridgeInformation&&!y.matterbridgeInformation.readOnly&&_&&(0,G.jsx)(V,{title:`Update matterbridge to latest dev version v.${y.matterbridgeInformation.matterbridgeDevVersion}`,children:(0,G.jsx)(I,{style:{color:`var(--secondary-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:ie,children:(0,G.jsx)(ge,{})})}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&y.matterbridgeInformation.shellySysUpdate&&(0,G.jsx)(V,{title:`Shelly system update`,children:(0,G.jsx)(I,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:oe,children:(0,G.jsx)(ge,{})})}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&y.matterbridgeInformation.shellyMainUpdate&&(0,G.jsx)(V,{title:`Shelly software update`,children:(0,G.jsx)(I,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:F,children:(0,G.jsx)(ge,{})})}),(0,G.jsx)(V,{title:`Restart matterbridge`,children:(0,G.jsx)(I,{style:{color:d||p?`var(--primary-color)`:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:le,children:(0,G.jsx)(he,{})})}),y.matterbridgeInformation.restartMode===``?(0,G.jsx)(V,{title:`Shut down matterbridge`,children:(0,G.jsx)(I,{style:{color:d||p?`var(--primary-color)`:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:ue,children:(0,G.jsx)(ye,{})})}):null,(0,G.jsx)(V,{title:`Download, backup and more`,children:(0,G.jsx)(I,{onClick:me,children:(0,G.jsx)(je,{style:{color:`var(--main-icon-color)`}})})}),(0,G.jsxs)(rt,{id:`command-menu`,anchorEl:S,keepMounted:!0,open:!!S,onClose:()=>L(``),children:[$&&e&&(0,G.jsxs)(R,{onClick:()=>L(`/`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Home page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),$&&e&&(0,G.jsxs)(R,{onClick:()=>L(`/devices`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Devices page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),$&&e&&(0,G.jsxs)(R,{onClick:()=>L(`/log`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Logs page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),$&&e&&(0,G.jsxs)(R,{onClick:()=>L(`/settings`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Settings page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&!y.matterbridgeInformation.readOnly&&(0,G.jsxs)(R,{onClick:()=>L(`update`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(ge,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Install latest stable`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&!y.matterbridgeInformation.readOnly&&(0,G.jsxs)(R,{onClick:()=>L(`updatedev`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(ge,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Install latest dev`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&!y.matterbridgeInformation.readOnly&&(0,G.jsxs)(R,{onClick:()=>L(`updatecheck`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(ge,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Check for updates`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&y.matterbridgeInformation.shellySysUpdate&&(0,G.jsxs)(R,{onClick:()=>L(`shelly-sys-update`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(ge,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Shelly system update`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&y.matterbridgeInformation.shellyMainUpdate&&(0,G.jsxs)(R,{onClick:()=>L(`shelly-main-update`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(ge,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Shelly software update`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>L(`restart`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(he,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Restart`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation.restartMode===``?(0,G.jsxs)(R,{onClick:()=>L(`shutdown`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(ye,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Shutdown`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}):null,y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,G.jsxs)(R,{onClick:()=>{n(`Reboot`,`Are you sure you want to reboot the Shelly board?`,`reboot`,L,_e)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(he,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Reboot...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsx)(Pe,{}),(0,G.jsxs)(R,{onClick:ve,children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`View`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(rt,{id:`sub-menu-view`,anchorEl:w,keepMounted:!0,open:!!w,onClose:be,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,G.jsxs)(R,{onClick:()=>{ri(),be(),_e(``),window.open(`/home`,`_self`)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Desktop site`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{ni(),be(),_e(``),window.open(`/home`,`_self`)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Mobile site`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`view-mblog`),be()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`view-mjlog`),be()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matter log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`view-diagnostic`),be()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge diagnostic log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`view-history`),be()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge system history`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,G.jsxs)(R,{onClick:()=>{L(`view-shellylog`),be()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]}),(0,G.jsx)(Pe,{}),(0,G.jsxs)(R,{onClick:xe,children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Download`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(rt,{id:`sub-menu-download`,anchorEl:E,keepMounted:!0,open:!!E,onClose:Se,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,G.jsxs)(R,{onClick:()=>{L(`create-matterbridge-storage-backup`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`create-plugin-backup`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge plugins storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`create-config-backup`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge plugins config`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`download-mblog`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`create-matter-storage-backup`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matter storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`download-mjlog`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matter log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`download-diagnostic`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge diagnostic log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`download-history`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge system history`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,G.jsxs)(R,{onClick:()=>{L(`shelly-create-system-log`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Create Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,G.jsxs)(R,{onClick:()=>{L(`shelly-download-system-log`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Download Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]}),(0,G.jsx)(Pe,{}),(0,G.jsxs)(R,{onClick:()=>{L(`create-backup`)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Je,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Backup`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsx)(Pe,{}),(0,G.jsxs)(R,{onClick:Ce,children:[(0,G.jsx)(z,{children:(0,G.jsx)(Ve,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Reset`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(rt,{id:`sub-menu-reset`,anchorEl:O,keepMounted:!0,open:!!O,onClose:we,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,G.jsxs)(R,{onClick:()=>{we(),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,_e)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(ye,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Reset the frontend UI...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{we(),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,_e)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(ye,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Reset all devices...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{we(),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,_e)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(ye,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Reset commissioning...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),!y.matterbridgeInformation.readOnly&&(0,G.jsxs)(R,{onClick:()=>{we(),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,_e)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(ye,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Factory reset...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,G.jsxs)(R,{onClick:()=>{we(),n(`Network reset`,`Are you sure you want to factory reset the network parameters?`,`softreset`,L,_e)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(ye,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Reset network...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,G.jsxs)(R,{onClick:()=>{we(),n(`Factory reset`,`Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.`,`hardreset`,L,_e)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(ye,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Factory reset...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]})]})]})]})}var Yr=(0,W.memo)(Jr),Xr=1200,Zr,Qr;function $r(){if(typeof window<`u`){Zr=Math.floor(window.visualViewport?.width??window.innerWidth),Qr=Math.floor(window.visualViewport?.height??window.innerHeight);let e=Zr<1200||Qr<900;return Q&&console.log(`Visual viewport (%s) width %i height %i mobile %s`,window.visualViewport!==void 0,Zr,Qr,e),e}return!1}function ei({children:e}){let{mobile:t,setMobile:n}=(0,W.useContext)(It),{logAutoScroll:r}=(0,W.useContext)(q);return(0,W.useEffect)(()=>{function e(){let e=$r();e&&(r.current=!1,localStorage.setItem(K.logAutoScroll,`false`)),n(e)}return window.addEventListener(`resize`,e),n($r()),()=>window.removeEventListener(`resize`,e)},[r,n]),Q&&console.log(`MbfScreen rendering... mobile %s`,t),$&&t?(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,overflow:`visible`,margin:`0px`,padding:`10px`,gap:`10px`},children:[(0,G.jsx)(Yr,{}),(0,G.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,margin:`0px`,padding:`0px`,gap:`10px`},children:e})]}):(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,overflow:`hidden`,width:t?`${Xr}px`:`calc(100vw - 40px)`,height:t?`900px`:`calc(100vh - 40px)`,margin:`0px`,padding:`20px`,gap:`20px`},children:[(0,G.jsx)(Yr,{}),(0,G.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,width:`100%`,height:`calc(100% - 60px)`,margin:`0px`,padding:`0px`,gap:`20px`},children:e})]})}var Q=!1,ti=()=>{Q=!Q},$=localStorage.getItem(K.enableMobile)!==`false`,ni=()=>{$=!0,localStorage.setItem(K.enableMobile,`true`)},ri=()=>{$=!1,localStorage.setItem(K.enableMobile,`false`)},ii=void 0,ai=e=>{ii=e},oi=!1,si=`/`,ci=`/`,li=`/`;function ui({setLoggedIn:e}){let[t,n]=(0,W.useState)(``),[r,i]=(0,W.useState)(``),a={display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100vh`,backgroundColor:`var(--main-bg-color)`},o={display:`flex`,flexDirection:`column`,maxWidth:`400px`,margin:`0 auto`,padding:`20px`,gap:`20px`,border:`1px solid var(--div-border-color)`,borderRadius:`var(--div-border-radius)`,boxShadow:`2px 2px 5px var(--div-shadow-color)`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},s={margin:`10px 0`,padding:`3px 3px`,fontSize:`14px`,width:`230px`,border:`1px solid var(--main-label-color)`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},c=async t=>{try{let n=await fetch(`./api/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:t})});if(n.ok){let{valid:r}=await n.json();r?(e(!0),t!==``&&(ii=t)):t!==``&&i(`Incorrect password!`)}else console.error(`Failed to log in:`,n.statusText)}catch(e){console.error(`Failed to log in:`,e)}};return c(``),(0,G.jsx)(`div`,{style:a,children:(0,G.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),c(t)},style:o,children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,G.jsx)(`h3`,{style:{color:`var(--div-text-color)`},children:`Welcome to Matterbridge`})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-between`,gap:`20px`},children:[(0,G.jsx)(`input`,{type:`text`,name:`username`,autoComplete:`username`,style:{display:`none`},tabIndex:-1}),(0,G.jsx)(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),style:s,placeholder:`password`,autoComplete:`current-password`}),(0,G.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,G.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`center`,margin:0,height:`30px`},children:r&&(0,G.jsx)(`p`,{style:{color:`red`},children:r})})]})})}function di(){let[e,t]=(0,W.useState)(!1),r=localStorage.getItem(K.frontendTheme)||`dark`;Q&&console.log(`Setting frontend theme "%s"`,r),document.body.setAttribute(`frontend-theme`,r);let i=Kr(`--primary-color`,`#1976d2`);Q&&console.log(`Primary color from CSS "%s"`,i);let s=qr(i);return si=window.location.href,ci=window.location.pathname,(ci.endsWith(`/devices`)||ci.endsWith(`/log`)||ci.endsWith(`/settings`)||ci.endsWith(`/test`))&&(ci=ci.substring(0,ci.lastIndexOf(`/`))),li=ci.endsWith(`/`)?ci:ci+`/`,oi=ci.includes(`/api/hassio_ingress/`),Q&&(console.log(`Loading App...`),console.log(`- href = "${si}"`),console.log(`- pathname = "${window.location.pathname}" >>> "${ci}"`),console.log(`- baseName = "${li}"`),console.log(`- isIngress = "${oi}"`)),e?(0,G.jsx)(fe,{theme:s,children:(0,G.jsx)(yt,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:`bottom`,horizontal:`right`},children:(0,G.jsx)(Lt,{children:(0,G.jsx)(zt,{children:(0,G.jsx)(o,{basename:li,children:(0,G.jsx)(ei,{children:(0,G.jsxs)(c,{children:[(0,G.jsx)(a,{path:`/`,element:(0,G.jsx)(ir,{})}),(0,G.jsx)(a,{path:`/devices`,element:(0,G.jsx)(Ar,{})}),(0,G.jsx)(a,{path:`/log`,element:(0,G.jsx)(Mr,{})}),(0,G.jsx)(a,{path:`/settings`,element:(0,G.jsx)(Ur,{})}),(0,G.jsx)(a,{path:`/test`,element:(0,G.jsx)(Gr,{})}),(0,G.jsx)(a,{path:`*`,element:(0,G.jsx)(n,{to:`/`})})]})})})})})})}):(0,G.jsx)(ui,{setLoggedIn:t})}At.createRoot(document.getElementById(`root`)).render((0,G.jsx)(W.StrictMode,{children:(0,G.jsx)(di,{})}));
|
|
4
|
+
`)),[`debug`,`info`,`notice`,`warn`,`error`,`fatal`].includes(t.response.level)&&(w.current===`info`&&t.response.level===`debug`||w.current===`notice`&&(t.response.level===`debug`||t.response.level===`info`)||w.current===`warn`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`)||w.current===`error`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`||t.response.level===`warn`)||w.current===`fatal`&&(t.response.level===`debug`||t.response.level===`info`||t.response.level===`notice`||t.response.level===`warn`||t.response.level===`error`)))||T.current!==`*`&&T.current!==``&&!T.current.startsWith(`/`)&&!T.current.endsWith(`/`)&&!t.response.message.toLowerCase().includes(T.current.toLowerCase())&&!t.response.name.toLowerCase().includes(T.current.toLowerCase())||T.current.startsWith(`/`)&&T.current.endsWith(`/`)&&(()=>{try{let e=new RegExp(T.current.slice(1,-1),`i`);return!e.test(t.response.message)&&!e.test(t.response.name)}catch(e){return console.error(`WebSocket log search invalid regex filter "${T.current}":`,e),!1}})()||t.response.name===`Commissioning`&&t.response.message.includes(`is uncommissioned`))return;n(e=>{let n=[...e,{level:t.response.level,time:t.response.time,name:t.response.name,message:t.response.message}];return Q&&console.log(`WebSocket new log message added (${n.length}/${O.current}):`,n[n.length-1]),n.length>O.current+O.current*10/100?(Q&&console.log(`WebSocket sliced log messages to the last ${O.current} entries`),n.slice(n.length-O.current)):n})}else{if(Q&&console.log(`WebSocket received message id ${t.id} method ${t.method}:`,t),t.id===0)_.current.forEach(e=>e.listener(t));else{let e=_.current.find(e=>e.id===t.id);e?e.listener(t):console.warn(`WebSocket no listener found for message id ${t.id}:`,t)}return}}catch(e){console.error(`WebSocket error parsing message: ${e}`,e instanceof Error?e.stack:null)}},v.current.onopen=()=>{Q&&console.log(`WebSocket: Connected to WebSocket: ${A}`),N(`WebSocket`,`Connected to WebSocket: ${A}`),c(!0),d(),y.current=1,C.current=setTimeout(()=>{x.current=setInterval(()=>{M({id:b.current,method:`ping`,src:`Frontend`,dst:`Matterbridge`,params:{}}),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{Q&&console.error(`WebSocketUse: No pong response received from WebSocket: ${A}`),N(`WebSocket`,`No pong response received from WebSocket: ${A}`),c(!1)},1e3*50)},1e3*60)},1e3*300)},v.current.onclose=()=>{Q&&console.error(`WebSocket: Disconnected from WebSocket ${oi?`with Ingress`:``}: ${A}`),N(`WebSocket`,`Disconnected from WebSocket: ${A}`),c(!1),d(),p(),C.current&&clearTimeout(C.current),S.current&&clearTimeout(S.current),x.current&&clearInterval(x.current),N(`WebSocket`,`Reconnecting (attempt ${y.current} of 100) to WebSocket${oi?` (Ingress)`:``}: ${A}`),oi?setTimeout(re,5e3):y.current===1?re():y.current<100?setTimeout(re,1e3*y.current):N(`WebSocket`,`Reconnect attempts exceeded limit of 100 retries, refresh the page to reconnect to: ${A}`),y.current+=1},v.current.onerror=e=>{Q&&console.error(`WebSocket: WebSocket error connecting to ${A}:`,e),N(`WebSocket`,`WebSocket error connecting to ${A}`)})},[A]),re=(0,W.useCallback)(()=>{Q&&console.log(`WebSocket attemptReconnect ${y.current}/100 to:`,A),ne()},[ne]);(0,W.useEffect)(()=>(ne(),()=>{v.current&&v.current.readyState===WebSocket.OPEN&&v.current.close()}),[ne]);let ie=(0,W.useMemo)(()=>({messages:t,logLength:O,logAutoScroll:k,logFilterLevel:r,logFilterSearch:a,setMessages:n,setLogFilterLevel:i,setLogFilterSearch:o,filterLogMessages:ee}),[t,O,k,r,a,n,i,o,ee]),ae=(0,W.useMemo)(()=>({logLength:O,logAutoScroll:k,logFilterLevel:r,logFilterSearch:a,setMessages:n,setLogFilterLevel:i,setLogFilterSearch:o,filterLogMessages:ee,online:s,retry:y.current,getUniqueId:j,addListener:P,removeListener:te,sendMessage:M,logMessage:N}),[O,k,n,i,o,s,y.current,P,te,M,N]);return(0,G.jsx)(Rt.Provider,{value:ie,children:(0,G.jsx)(q.Provider,{value:ae,children:e})})}function Bt(e){return(0,G.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,G.jsxs)(`defs`,{children:[(0,G.jsxs)(`linearGradient`,{id:`lg1`,x1:`16.6`,y1:`16.6`,x2:`279.6`,y2:`279.6`,gradientUnits:`userSpaceOnUse`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#00b48d`}),(0,G.jsx)(`stop`,{offset:`.1`,stopColor:`#3faa77`}),(0,G.jsx)(`stop`,{offset:`.3`,stopColor:`#234148`}),(0,G.jsx)(`stop`,{offset:`.7`,stopColor:`#203b44`}),(0,G.jsx)(`stop`,{offset:`.9`,stopColor:`#ad2e6e`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#c81b74`})]}),(0,G.jsxs)(`linearGradient`,{id:`lg2`,x1:`31.1`,y1:`31.1`,x2:`265.1`,y2:`265.1`,gradientUnits:`userSpaceOnUse`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#00b48d`}),(0,G.jsx)(`stop`,{offset:`.2`,stopColor:`#285251`}),(0,G.jsx)(`stop`,{offset:`.4`,stopColor:`#234148`}),(0,G.jsx)(`stop`,{offset:`.8`,stopColor:`#203b44`}),(0,G.jsx)(`stop`,{offset:`.9`,stopColor:`#a8316c`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#c81b74`})]}),(0,G.jsxs)(`linearGradient`,{id:`lg3`,x1:`116.2`,y1:`143.9`,x2:`139.8`,y2:`143.9`,gradientUnits:`userSpaceOnUse`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#8bc751`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#0db14b`})]}),(0,G.jsx)(`linearGradient`,{id:`lg4`,x1:`136.1`,y1:`100.8`,x2:`159.6`,y2:`100.8`,xlinkHref:`#lg3`}),(0,G.jsx)(`linearGradient`,{id:`lg5`,x1:`155.3`,y1:`143.9`,x2:`178.9`,y2:`143.9`,xlinkHref:`#lg3`}),(0,G.jsxs)(`linearGradient`,{id:`lg6`,x1:`46.8`,y1:`25.7`,x2:`89.6`,y2:`74.8`,gradientUnits:`userSpaceOnUse`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#b1d34a`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#50b848`})]})]}),(0,G.jsx)(`rect`,{width:`296.2`,height:`296.2`,rx:`56.7`,ry:`56.7`,style:{fill:`url(#lg1)`}}),(0,G.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,G.jsx)(`circle`,{cx:`128`,cy:`143.9`,r:`11.8`,style:{fill:`url(#lg3)`}}),(0,G.jsx)(`circle`,{cx:`147.8`,cy:`100.8`,r:`11.8`,style:{fill:`url(#lg4)`}}),(0,G.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,G.jsx)(`circle`,{cx:`167.1`,cy:`143.9`,r:`11.8`,style:{fill:`url(#lg5)`}}),(0,G.jsx)(`path`,{fill:`#fff`,d:`M219 89.3V35.5a10.5 10.5 0 1 0-21 0v33.7l21 20Z`}),(0,G.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,G.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,G.jsx)(`path`,{fill:`#fff`,d:`M250.5 90.5a17.4 17.4 0 1 1 0-34.8 17.4 17.4 0 0 1 0 34.8Zm0-22.7a5.4 5.4 0 0 0 0 10.7 5.3 5.3 0 0 0 0-10.7ZM258.8 148.2a15.9 15.9 0 0 0-9.6 28.5c-.8 4.2-5.4 4.6-5.4 4.6h-26v-43l13.6-13-1.8-2-82.2-79-81.2 78.3-2.5 2.6 13.7 13v42.9H53a21.5 21.5 0 1 0 11.7 15h12.6v18.8c0 7.8 6.4 14.1 14.1 14.1h29.3v14.8H64a10.6 10.6 0 0 0-17.7 8 10.6 10.6 0 0 0 17.6 8h157.6a16.3 16.3 0 1 0 0-16h-84.8V229h66.8c7.8 0 14.2-6.3 14.2-14.1v-19.2h27.6c14.3 0 17.8-12.8 18.5-16.6a15.9 15.9 0 0 0-5-30.9ZM43.7 210.8a10.3 10.3 0 1 1 0-20.6 10.3 10.3 0 0 1 0 20.6Zm192 36a5 5 0 1 1 0 10 5 5 0 0 1 0-10Zm-77-34.8h-22v-34h22v34Zm8.4-79.8c2.7 0 5.2 1 7.2 2.5v-10.4L188 137s2.6 1.3 4.6 1.3h6.7v68c0 3.2-2.6 5.7-5.7 5.7h-19v-34h1.4a7.5 7.5 0 0 0 0-15H120a7.5 7.5 0 0 0 0 15h.7v34h-19.3a5.7 5.7 0 0 1-5.7-5.6v-68.1h6.7c2 0 4.6-1.3 4.6-1.3l13.7-12.7v10.4a11.7 11.7 0 0 1 16 1.6v-13a14.9 14.9 0 0 0-25-10.8s-.1.2-.1.2l-.5.5-6.9 7H92.5l55-53.2 55.1 53.2h-11.8l-7-7c0-.2-.2-.3-.4-.5l-.2-.2a14.8 14.8 0 0 0-25 10.9v12.9c2.2-2.5 5.3-4.1 8.9-4.1Zm91.7 36.7a4.9 4.9 0 1 1 0-9.7 4.9 4.9 0 0 1 0 9.7Z`})]})}function Vt(){let{retry:e}=(0,W.useContext)(q);return(0,G.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,G.jsx)(Bt,{style:{height:`128px`,width:`128px`,margin:`10px`,marginBottom:`20px`}}),e<100?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(T,{style:{color:`var(--primary-color)`}}),(0,G.jsx)(`div`,{style:{marginTop:`20px`,color:`var(--primary-color)`,textAlign:`center`},children:(0,G.jsxs)(`span`,{children:[`Reconnecting to Matterbridge `,`(attempt `+e+`)`,`...`]})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{style:{marginTop:`20px`,color:`var(--primary-color)`,textAlign:`center`},children:[(0,G.jsx)(`span`,{children:`Unable to connect to Matterbridge after multiple attempts.`}),(0,G.jsx)(`br`,{}),(0,G.jsx)(`span`,{children:`Please check your network connection.`}),(0,G.jsx)(`br`,{})]}),(0,G.jsx)(j,{variant:`contained`,color:`primary`,onClick:()=>{window.location.reload()},style:{marginTop:`20px`},children:`Refresh the Page`})]})]})}var J=pt();function Ht({value:e,maxChars:t}){let n=e;if(e.length>t&&t>3){let r=t-3;n=`${e.substring(0,Math.ceil(r/2))} … ${e.substring(e.length-Math.floor(r/2),e.length)}`}return e===n?(0,G.jsx)(`span`,{children:n}):(0,G.jsx)(V,{title:e,placement:`top`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[0,12]}}]}},children:(0,G.jsx)(`span`,{children:n})})}function Y({children:e,style:t}){return(0,G.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,flex:`0 0 auto`,width:`100%`,overflow:`hidden`,margin:`0px`,padding:`0px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,boxShadow:`5px 5px 10px var(--div-shadow-color)`,border:`1px solid var(--table-border-color)`,borderRadius:`var(--div-border-radius)`,boxSizing:`border-box`,...t},children:e})}function Ut({children:e,style:t}){return(0,G.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 X({children:e,style:t}){return(0,G.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 Wt({children:e,style:t}){return(0,G.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 Gt({children:e,style:t}){return(0,G.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 Kt({children:e,style:t}){return(0,G.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,G.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 Jt({children:e,style:t,close:n}){return(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,margin:`0px`,padding:`0px`,paddingRight:`10px`,gap:`10px`,...t},children:[e,!1]})}function Yt({systemInfo:e,compact:t}){let{mobile:n}=(0,W.useContext)(It),{addListener:r,removeListener:i,getUniqueId:a,sendMessage:o}=(0,W.useContext)(q),[s,c]=(0,W.useState)(e),l=(0,W.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,W.useEffect)(()=>{let e=e=>{Q&&console.log(`SystemInfoTable received WebSocket Message:`,e),e.method===`memory_update`&&e.response&&e.response.totalMemory&&e.response.freeMemory&&e.response.heapTotal&&e.response.heapUsed&&e.response.rss?(Q&&console.log(`SystemInfoTable received memory_update`,e),u(e.response.totalMemory,e.response.freeMemory,e.response.heapTotal,e.response.heapUsed,e.response.rss)):e.method===`cpu_update`&&e.response&&e.response.cpuUsage?(Q&&console.log(`SystemInfoTable received cpu_update`,e),d(e.response.cpuUsage),f(e.response.processCpuUsage)):e.method===`uptime_update`&&e.response&&e.response.systemUptime&&e.response.processUptime?(Q&&console.log(`SystemInfoTable received uptime_update`,e),p(e.response.systemUptime,e.response.processUptime)):e.method===`/api/viewhistorypage`&&e.id===l.current&&e.success===!0&&(Q&&console.log(`SystemInfoTable received /api/viewhistorypage success`),window.open(`./api/viewhistory`,`_blank`,`noopener,noreferrer`))};return r(e,l.current),Q&&console.log(`SystemInfoTable added WebSocket listener id ${l.current}`),()=>{i(e),Q&&console.log(`SystemInfoTable removed WebSocket listener`)}},[r,i]);let[h,g]=(0,W.useState)(!1);return!s||h?null:(Q&&console.log(`SystemInfoTable rendering...`),(0,G.jsxs)(Y,{style:$&&n?{flex:`1 1 300px`}:{flex:`0 1 auto`,width:`302px`,minWidth:`302px`},children:[(0,G.jsxs)(Ut,{children:[(0,G.jsx)(X,{children:`System info`}),(0,G.jsx)(Jt,{close:()=>g(!0),children:(0,G.jsx)(I,{size:`small`,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},onClick:m,children:(0,G.jsx)(V,{title:`Open the cpu and memory usage page`,arrow:!0,children:(0,G.jsx)(J.Icon,{path:ht,size:`22px`})})})})]}),(0,G.jsx)(qt,{style:$&&n?{flex:`1 1 auto`,margin:`0px`,padding:`0px`,gap:`0px`}:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`0px`,gap:`0px`},children:(0,G.jsxs)(`table`,{style:{border:`none`,borderCollapse:`collapse`,tableLayout:`fixed`},children:[(0,G.jsxs)(`colgroup`,{children:[(0,G.jsx)(`col`,{style:{width:`40%`}}),(0,G.jsx)(`col`,{style:{width:`60%`}})]}),(0,G.jsx)(`tbody`,{style:{border:`none`,borderCollapse:`collapse`},children:Object.entries(s).filter(([e,t])=>t!==void 0&&t!==``).map(([e,t],r)=>(0,G.jsxs)(`tr`,{className:r%2==0?`table-content-even`:`table-content-odd`,style:{border:`none`,borderCollapse:`collapse`},children:[(0,G.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`},children:e.replace(`interfaceName`,`Interface name`).replace(`macAddress`,`Mac address`).replace(`ipv4Address`,`IPv4 address`).replace(`ipv6Address`,`IPv6 address`).replace(`nodeVersion`,`Node version`).replace(`hostname`,`Hostname`).replace(`user`,`User`).replace(`osType`,`Os`).replace(`osPlatform`,`Platform`).replace(`freeMemory`,`Memory`).replace(`systemUptime`,`System uptime`).replace(`processUptime`,`Process uptime`).replace(`cpuUsage`,`Host CPU`).replace(`processCpuUsage`,`Process CPU`).replace(`rss`,`Rss`).replace(`heapUsed`,`Heap`)}),(0,G.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:$&&n?typeof t==`string`?t:t.toString():(0,G.jsx)(Ht,{value:typeof t==`string`?t:t.toString(),maxChars:22})})]},e))})]})})]}))}var Xt=(0,W.memo)(Yt),Zt={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`}},Qt=e=>{if(!e)return``;let t=e.toString().replace(/[^0-9]/g,``);return t.length<5?t:[t.slice(0,4),t.slice(4,7),t.slice(7,11)].filter(Boolean).join(`-`)};function $t({id:e}){let{online:t,sendMessage:n,addListener:r,removeListener:i,getUniqueId:a}=(0,W.useContext)(q),[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)(It);Q&&console.log(`QRDiv loading with id = "${e}" storeId = "${c.current}" timeout = ${l.current} and matter:`,o),(0,W.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,W.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}})},_=async()=>{if(!o||!o.manualPairingCode)return;let e=o.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(e);else{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}Q&&console.log(`Manual pairing code copied to clipboard`)}catch(e){console.error(`Failed to copy manual pairing code`,e)}};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,G.jsxs)(Y,{style:$&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,G.jsxs)(Ut,{children:[(0,G.jsx)(X,{children:`QR pairing code`}),(0,G.jsxs)(Jt,{children:[(0,G.jsx)(I,{"aria-label":`send advertising`,size:`small`,onClick:h,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,G.jsx)(V,{title:`Send again the mDNS advertisement`,arrow:!0,children:(0,G.jsx)(J.Icon,{path:ft,size:`22px`})})}),(0,G.jsx)(I,{"aria-label":`stop pairing`,size:`small`,onClick:m,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,G.jsx)(V,{title:`Turn off pairing`,arrow:!0,children:(0,G.jsx)(J.Icon,{path:ut,size:`22px`})})})]})]}),(0,G.jsx)(Kt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,G.jsx)(bt,{value:o.qrPairingCode,size:256,level:`M`,fgColor:`var(--div-text-color)`,bgColor:`var(--div-bg-color)`,style:{margin:`20px`}}),(0,G.jsxs)(Wt,{style:{justifyContent:`space-between`},children:[(0,G.jsxs)(Gt,{style:{fontWeight:`normal`,color:`var(--div-text-color)`},children:[`Manual pairing code: `,Qt(o.manualPairingCode)]}),(0,G.jsx)(Jt,{children:(0,G.jsx)(V,{title:`Copy manual pairing code`,arrow:!0,children:(0,G.jsx)(I,{"aria-label":`copy manual pairing code`,size:`small`,onClick:_,sx:Zt,children:(0,G.jsx)(J.Icon,{path:mt,size:.85})})})})]})]})):o.commissioned&&o.fabricInformations&&o.sessionInformations?(Q&&console.log(`QRDiv rendering commissioned state`),(0,G.jsxs)(Y,{style:$&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`,overflow:`hidden`},children:[(0,G.jsxs)(Ut,{children:[(0,G.jsx)(X,{children:`Paired fabrics`}),(0,G.jsxs)(Jt,{children:[(0,G.jsx)(I,{"aria-label":`send advertising`,size:`small`,onClick:h,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,G.jsx)(V,{title:`Send again the mDNS advertisement`,arrow:!0,children:(0,G.jsx)(J.Icon,{path:ft,size:`22px`})})}),(0,G.jsx)(I,{"aria-label":`start pairing`,size:`small`,onClick:p,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,G.jsx)(V,{title:`Turn on pairing`,arrow:!0,children:(0,G.jsx)(J.Icon,{path:_t,size:`22px`})})})]})]}),(0,G.jsx)(Kt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,G.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,G.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,G.jsxs)(`div`,{style:{marginLeft:`20px`,marginBottom:`10px`,display:`flex`,flexDirection:`row`,justifyContent:`space-between`,gap:`20px`,alignItems:`center`},children:[(0,G.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,G.jsx)(V,{title:`Remove the fabric. You will also need to remove it from the controller.`,arrow:!0,children:(0,G.jsx)(I,{"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:{...Zt,padding:`2px`},children:(0,G.jsx)(J.Icon,{path:gt,size:1})})})]}),(0,G.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Vendor: `,e.rootVendorId,` `,e.rootVendorName]}),e.label!==``&&(0,G.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Label: `,e.label]}),(0,G.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Sessions: `,o.sessionInformations?o.sessionInformations.filter(t=>t.fabric?.fabricIndex===e.fabricIndex&&t.isPeerActive===!0).length:`0`,` `,`subscriptions: `,o.sessionInformations?o.sessionInformations.filter(t=>t.fabric?.fabricIndex===e.fabricIndex&&t.isPeerActive===!0&&t.numberOfActiveSubscriptions>0).length:`0`]})]},t))}),(0,G.jsx)(Wt,{style:{justifyContent:`center`},children:(0,G.jsxs)(Gt,{style:{fontWeight:`normal`},children:[`Serial number: `,o.serialNumber]})})]})):!o.commissioned&&!o.advertising?(Q&&console.log(`QRDiv rendering not commissioned and not advertising state`),(0,G.jsxs)(Y,{style:$&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,G.jsx)(Ut,{children:(0,G.jsx)(X,{children:`QR pairing code`})}),(0,G.jsx)(Kt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,G.jsx)(j,{onClick:p,endIcon:(0,G.jsx)(J.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,G.jsx)(Wt,{style:{justifyContent:`center`},children:(0,G.jsxs)(Gt,{style:{fontWeight:`normal`},children:[`Serial number: `,o.serialNumber]})})]})):(Q&&console.log(`QRDiv rendering unknown state`),null):(Q&&console.log(`QRDiv rendering offline state`),(0,G.jsxs)(Y,{style:$&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,G.jsx)(Ut,{style:{height:`30px`,justifyContent:`space-between`},children:(0,G.jsx)(X,{children:`Server node`})}),(0,G.jsx)(Kt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,G.jsx)(Kt,{style:{fontWeight:`bold`},children:`Server offline`}),(0,G.jsx)(Wt,{style:{justifyContent:`center`},children:(0,G.jsxs)(Gt,{style:{fontWeight:`normal`},children:[`Serial number: `,o.serialNumber]})})]}))}var en=(0,W.memo)($t);function tn(e){return e?e.scrollWidth>e.clientWidth:!1}function nn({title:e,children:t}){let n=(0,W.useRef)(null),[r,i]=(0,W.useState)(!1);return(0,G.jsx)(V,{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,G.jsx)(`span`,{ref:n,onMouseEnter:()=>{i(tn(n.current))},onMouseLeave:()=>{i(!1)},style:{display:`inline-block`,maxWidth:`100%`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t})})}function rn(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 an({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},[d,f]=(0,W.useState)(localStorage.getItem(`${e}_table_order_by`)||null),[p,m]=(0,W.useState)(localStorage.getItem(`${e}_table_order`)||null),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(()=>{try{let t=localStorage.getItem(`${e}_column_visibility`);if(t)return JSON.parse(t)}catch{}return{}}),y=(0,W.useMemo)(()=>{let e={};for(let t of n)t.hidden||(e[t.id]=t.required?!0:_[t.id]!==!1);return e},[n,_]),b=(0,W.useMemo)(()=>{if(!d||!p)return r;let e=n.find(e=>e.id===d);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):rn(t.el,n.el,d),r===0?t.index-n.index:p===`asc`?r:-r}),t.map(e=>e.el)},[r,d,p,n]),S=t=>{if(d!==t||!d){f(t),m(`asc`),localStorage.setItem(`${e}_table_order_by`,t),localStorage.setItem(`${e}_table_order`,`asc`);return}if(p===`asc`){m(`desc`),localStorage.setItem(`${e}_table_order`,`desc`);return}f(null),m(null),localStorage.removeItem(`${e}_table_order_by`),localStorage.removeItem(`${e}_table_order`)},C=()=>{g(!h)},w=t=>{v(r=>{let i=n.find(e=>e.id===t);if(i&&i.required)return r;let a=y[t]!==!1,o={...r};a?o[t]=!1:delete o[t];try{localStorage.setItem(`${e}_column_visibility`,JSON.stringify(o))}catch{}return o})},T=()=>{v({});try{localStorage.removeItem(`${e}_column_visibility`)}catch{}g(!1)},[E,O]=(0,W.useState)(!1);return E?null:(Q&&console.log(`Rendering table ${e}${d&&p?` ordered by ${d}:${p}`:``}`),(0,G.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,G.jsxs)(x,{open:h,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||C()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[(0,G.jsx)(M,{gap:`20px`,children:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,G.jsx)(`h4`,{style:{margin:0},children:`Configure ${e} columns`})]})}),(0,G.jsx)(P,{children:(0,G.jsx)(ne,{children:n.filter(e=>!e.hidden).map(e=>(0,G.jsx)(Ie,{control:(0,G.jsx)(D,{disabled:!!e.required,checked:e.required?!0:y[e.id]!==!1,onChange:()=>w(e.id)}),label:e.label},e.id))})}),(0,G.jsxs)(ie,{children:[(0,G.jsx)(j,{onClick:T,children:`Reset`}),(0,G.jsx)(j,{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{}C()},children:`Close`})]})]}),(0,G.jsxs)(Ut,{style:{height:`30px`,minHeight:`30px`,justifyContent:`space-between`,borderBottom:`none`},children:[(0,G.jsx)(X,{children:e}),t&&(0,G.jsx)(X,{children:t}),(0,G.jsx)(Jt,{close:()=>O(!0),children:(0,G.jsx)(I,{size:`small`,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},onClick:e=>{if(e?.currentTarget?.blur)try{e.currentTarget.blur()}catch{}C()},"aria-label":`Configure Columns`,children:(0,G.jsx)(V,{title:`Configure ${e} columns`,children:(0,G.jsx)(J.Icon,{path:dt,size:`20px`,color:`var(--header-text-color)`})})})})]}),(0,G.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,G.jsxs)(`table`,{"aria-label":`${e} table`,style:{width:`100%`,borderCollapse:`collapse`},children:[(0,G.jsx)(`thead`,{style:{position:`sticky`,top:0,zIndex:10,border:`none`,color:`var(--header-text-color)`,backgroundColor:`var(--header-bg-color`},children:(0,G.jsx)(`tr`,{style:{height:`30px`,minHeight:`30px`},children:n.map(e=>{if(e.hidden||!e.required&&y[e.id]===!1)return null;let t=!e.noSort,n=t&&d===e.id&&!!p;return(0,G.jsxs)(`th`,{onClick:t?()=>S(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?p===`asc`?`ascending`:`descending`:`none`:void 0,children:[e.label,n&&(0,G.jsxs)(`span`,{style:{marginLeft:6},children:[p===`asc`&&(0,G.jsx)(J.Icon,{path:`M19 17H22L18 21L14 17H17V3H19M2 17H12V19H2M6 5V7H2V5M2 11H9V13H2V11Z`,size:`15px`}),p===`desc`&&(0,G.jsx)(J.Icon,{path:`M19 7H22L18 3L14 7H17V21H19M2 17H12V19H2M6 5V7H2V5M2 11H9V13H2V11Z`,size:`15px`})]})]},e.id)})})}),(0,G.jsx)(`tbody`,{children:b.map((e,t)=>{let r=u(e);return(0,G.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&&y[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,G.jsx)(D,{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,G.jsx)(nn,{title:String(n),children:i}):i;return(0,G.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,G.jsxs)(Wt,{style:{height:`30px`,minHeight:`30px`,justifyContent:`space-between`,border:`none`},children:[(0,G.jsx)(Gt,{style:{fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`},children:a}),(0,G.jsx)(Gt,{style:{fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`},children:o})]})]}))}function on(e){return(0,W.memo)(e)}var sn=on(an),cn=e=>e.replace(`git+`,``).replace(`.git`,``).trim(),ln=e=>{let t=cn(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},dn=()=>{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{}}},fn=e=>{try{window.localStorage.setItem(K.searchPluginsTotal,JSON.stringify(e))}catch{}},pn=()=>{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{}}},mn=e=>{try{window.localStorage.setItem(K.searchPluginsMeta,JSON.stringify(e))}catch{}},hn=()=>{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{}}},gn=e=>{try{window.localStorage.setItem(K.searchPluginsVersions,JSON.stringify(e))}catch{}},_n=({open:e,onClose:t,onSelect:n,onVersions:r})=>{let[i,a]=(0,W.useState)(``),o=(0,W.useRef)(``),s=(0,W.useRef)(!1),c=(0,W.useRef)(null),[l,u]=(0,W.useState)([]),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)({done:0,total:0}),[y,b]=(0,W.useState)(null),S=(0,W.useRef)({}),C=()=>{let e=document.activeElement;e&&e instanceof HTMLElement&&e.blur()},w=e=>`${e.getFullYear().toString()}-${(e.getMonth()+1).toString().padStart(2,`0`)}-${e.getDate().toString().padStart(2,`0`)}`,T=(0,W.useCallback)(async(e,t)=>{let n=S.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:c.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 l=a[`dist-tags`]??{},u=typeof l?.dev==`string`&&String(l.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),S.current[e]={versions:f,asOf:t},gn(S.current),f},[]),E=e=>new Intl.NumberFormat().format(e),D=[{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`?E(e):``},{label:`Total`,id:`total`,align:`right`,maxWidth:120,render:e=>typeof e==`number`?E(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,G.jsxs)(`div`,{style:{margin:`0`,padding:`0`,gap:`4px`,display:`flex`,flexDirection:`row`,justifyContent:`center`},children:[(0,G.jsx)(V,{title:n.homepage?`Open the plugin homepage`:`No homepage available`,children:(0,G.jsx)(`span`,{children:(0,G.jsx)(I,{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,G.jsx)(Me,{})})})}),(0,G.jsx)(V,{title:n.help?`Open the plugin help`:`No help available`,children:(0,G.jsx)(`span`,{children:(0,G.jsx)(I,{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,G.jsx)(Ye,{})})})}),(0,G.jsx)(V,{title:n.changelog?`Open the plugin changelog`:`No changelog available`,children:(0,G.jsx)(`span`,{children:(0,G.jsx)(I,{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,G.jsx)(He,{})})})})]})}];(0,W.useEffect)(()=>{if(!e){s.current=!1,o.current=``,c.current?.abort(),c.current=null,u([]),f(!1),m(!1),g(!1),v({done:0,total:0}),b(null),a(``);return}if(s.current)return;s.current=!0;let t=new AbortController;return c.current=t,S.current=hn(),(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{f(!0),b(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),d=(s.objects??[]).filter(e=>!!e?.package&&typeof e.package.name==`string`).filter(t=>t.package?.name?.startsWith(e)).filter(e=>!vn.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}}),p=w(new Date),m=dn(),h=pn();u(d.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!==p)return e;let n=t.homepage??e.homepage,r=t.help,i=t.changelog;return Q&&(r||i||n&&n!==e.homepage)&&console.log(`[SearchPluginsDialog] metadata loaded from cache for ${e.name} (asOf=${t.asOf}):`,{homepage:n,help:r,changelog:i}),{...e,homepage:n,help:r,changelog:i}}));let _=d.map(e=>e.name).filter(e=>{let t=S.current[e];return!t||t.asOf!==p||t.versions.length===0});Q&&console.log(`[SearchPluginsDialog] versions prefetch queue (${_.length.toString()}):`,_);let y=0,x=async()=>{for(;y<_.length;){if(t.signal.aborted)return;let e=y;y+=1;let r=_[e];if(r)try{let e=await T(r,p);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,d.length)},()=>x()));let C=d.map(e=>e.name).filter(e=>{let t=h[e],n=!!t&&t.asOf===p,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}),E=new Set(C),D=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`)?cn(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?ln(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}},O=0,k=async()=>{for(;O<C.length;){if(t.signal.aborted)return;let e=O;O+=1;let r=C[e];if(!r||!E.has(r))continue;E.delete(r);let i=await D(r,d.find(e=>e.name===r)?.homepage??null);if(t.signal.aborted)return;i&&(u(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:p},mn(h)),t.signal.aborted||await n(250)}};Promise.all(Array.from({length:Math.min(1,d.length)},()=>k()));let A=`2020-01-01`,j=d.map(e=>e.name).filter(e=>{let t=m[e],n=!t||t.asOf!==p;return n||Q&&console.log(`[SearchPluginsDialog] total downloads fetch skipped (cache fresh) for ${e} (asOf=${t.asOf}).`),n}),ee=new Set(j),M=j.length;v({done:0,total:M}),g(M>0);let N=async e=>{let i=`https://api.npmjs.org/downloads/range/${A}:${p}/${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},P=0,te=0,ne=async()=>{for(;P<j.length;){if(t.signal.aborted)return;let e=P;P+=1;let r=j[e];if(r&&ee.has(r)){ee.delete(r);try{Q&&console.log(`[SearchPluginsDialog] fetching total downloads for ${r} (range ${A}:${p})...`);let e=await N(r);if(t.signal.aborted)return;Q&&console.log(`[SearchPluginsDialog] total downloads fetched for ${r}:`,e),u(t=>t.map(t=>t.name===r?{...t,total:e}:t)),typeof e==`number`&&(m[r]={total:e,asOf:p},fn(m),Q&&console.log(`[SearchPluginsDialog] total downloads saved to localStorage for ${r} (asOf=${p}):`,e))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return}finally{te+=1,v({done:te,total:M}),t.signal.aborted||await n(500)}}}};Promise.all(Array.from({length:Math.min(1,d.length)},()=>ne())).finally(()=>{t.signal.aborted||g(!1)}),Q&&console.log(`[SearchPluginsDialog] npm packages starting with "${e}" (filtered/sorted):`,d)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;console.error(`[SearchPluginsDialog] npm registry fetch error:`,e),b(e instanceof Error?e.message:String(e))}finally{f(!1)}})(),()=>t.abort()},[e,T]);let O=async()=>{C();let e=o.current||i;if(!(!e||p))try{m(!0);let t=await T(e,w(new Date));Q&&console.log(`[SearchPluginsDialog] passing versions to onVersions() for ${e} (${t.length.toString()}):`,t),r(t),m(!1),n(e)}catch(t){if(t instanceof DOMException&&t.name===`AbortError`)return;console.error(`[SearchPluginsDialog] npm versions fetch error:`,t),r([]),m(!1),n(e)}},k=()=>{C(),t(),r([])},A=l.reduce((e,t)=>e+(typeof t.downloads==`number`?t.downloads:0),0),ee=l.reduce((e,t)=>(typeof t.total==`number`&&(e.total+=t.total,e.hasAny=!0),e),{total:0,hasAny:!1}),N=h?` Totals: ${_.done.toString()}/${_.total.toString()} fetched`:``,te=ee.hasAny?E(ee.total):`...`;return(0,G.jsxs)(x,{open:e,onClose:()=>{C(),t()},maxWidth:!1,fullWidth:!0,slotProps:{paper:{sx:{width:`75vw`,height:`75vh`,maxWidth:`75vw`,maxHeight:`75vh`,display:`flex`,flexDirection:`column`}}},children:[(0,G.jsx)(M,{children:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,G.jsx)(`h4`,{style:{margin:0},children:`Search Plugins`})]})}),(0,G.jsx)(P,{dividers:!0,sx:{padding:`10px`,flex:`1 1 auto`,minHeight:0},children:(0,G.jsx)(`div`,{style:{height:`100%`,width:`100%`,display:`flex`,flexDirection:`column`,minHeight:0},children:d?(0,G.jsx)(`div`,{style:{padding:`20px`},children:`Loading npm registry...`}):y?(0,G.jsx)(`div`,{style:{padding:`20px`},children:y}):(0,G.jsx)(sn,{name:`Search plugins`,rows:l,columns:D,getRowKey:`name`,onRowClick:(e,t,n)=>{o.current=e.name,a(e.name),n.detail===2&&O()},footerLeft:`Total packages: ${l.length.toString()} Total downloads: ${E(A)} / ${te}${N}`,footerRight:i?`Selected: ${i}`:``})})}),(0,G.jsxs)(ie,{sx:{justifyContent:`center`,gap:1.5,flexWrap:`wrap`},children:[(0,G.jsx)(V,{title:`Select the plugin and close the dialog. Double-click a row to select and close the dialog.`,children:(0,G.jsx)(j,{variant:`contained`,onClick:O,disabled:!(o.current||i)||p,children:`Select`})}),(0,G.jsx)(V,{title:`Close the dialog without selecting a plugin.`,children:(0,G.jsx)(j,{onClick:k,children:`Cancel`})})]})]})},vn=[`matterbridge-`,`matterbridge-plugin-template`,`matterbridge-dyson`,`matterbridge-tuya`,`matterbridge-mqtt`,`matterbridge-matter`,`matterbridge-automations`,`matterbridge-securitysystem`,`matterbridge-adapter`];function yn(){let{mobile:e,showSnackbarMessage:t}=(0,W.useContext)(It),{logMessage:n,sendMessage:r,getUniqueId:i}=(0,W.useContext)(q),[a,o]=(0,W.useState)(`matterbridge-`),[s,c]=(0,W.useState)([`latest`,`dev`]),[l,u]=(0,W.useState)(`latest`),[f,p]=(0,W.useState)(!1),m=(0,W.useRef)(i()),h=e=>{let t=String(e??``).trim();if(!t)return{name:``,specifier:null};if(t.startsWith(`@`)){let e=t.lastIndexOf(`@`);if(e>0){let n=t.slice(0,e),r=t.slice(e+1);if(n.includes(`/`)&&r)return{name:n,specifier:r}}return{name:t,specifier:null}}let n=t.indexOf(`@`);if(n>0){let e=t.slice(0,n),r=t.slice(n+1);return r?{name:e,specifier:r}:{name:e,specifier:null}}return{name:t,specifier:null}},g=()=>{let{name:e,specifier:t}=h(a);return e?t?`${e}@${t}`:l?`${e}@${l}`:e:``},_=e=>{e.preventDefault(),p(!0)},v=()=>{p(!1)},y=e=>{e.preventDefault(),p(!1);let t=e.dataTransfer.files[0];if(t){n(`Plugins`,`Installing package ${t.name}. Please wait...`);let e=new FormData;e.append(`file`,t),e.append(`filename`,t.name),fetch(`./api/uploadpackage`,{method:`POST`,body:e}).then(e=>e.text()).then(e=>{n(`Plugins`,`Server response: ${e}`)}).catch(e=>{console.error(`Error uploading plugin file:`,e),n(`Plugins`,`Error installing package ${e}`)})}},b=e=>{let t=e.target.files&&e.target.files[0];if(t){n(`Plugins`,`Uploading package ${t.name}`);let e=new FormData;e.append(`file`,t),e.append(`filename`,t.name),fetch(`./api/uploadpackage`,{method:`POST`,body:e}).then(e=>e.text()).then(e=>{n(`Plugins`,`Server response: ${e}`)}).catch(e=>{console.error(`Error uploading plugin file:`,e),n(`Plugins`,`Error uploading package ${e}`)})}},x=()=>{let e=g();if(e){if(vn.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(vn.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}})},T=e=>{e.preventDefault(),Q&&console.log(`Right-clicked Upload button`)},E=e=>{e.preventDefault(),Q&&console.log(`Right-clicked Add button`)},[D,O]=(0,W.useState)(!1),k=()=>{O(!0),Q&&console.log(`Dialog opened for selection`)},A=()=>{o(`matterbridge-`),O(!1),Q&&console.log(`Dialog closed without selection`)},ee=e=>{o(e),O(!1),Q&&console.log(`Select plugin:`,e)},M=e=>{c(e),u(e.includes(`latest`)?`latest`:e[0]??``),Q&&console.log(`Select plugin versions:`,e)},[N,P]=(0,W.useState)(!1);return Q&&console.log(`HomeInstallAddPlugins rendering...`),N?null:(0,G.jsxs)(Y,{children:[(0,G.jsxs)(Ut,{children:[(0,G.jsx)(X,{children:`Install plugins`}),(0,G.jsx)(Jt,{close:()=>P(!0)})]}),(0,G.jsxs)(qt,{onDragOver:_,onDragLeave:v,onDrop:y,style:$&&e?{flexWrap:`wrap`,alignItems:`center`,gap:`10px`}:{flexWrap:`wrap`,alignItems:`center`,gap:`20px`},children:[(0,G.jsx)(_n,{open:D,onClose:A,onSelect:ee,onVersions:M}),(0,G.jsxs)(`div`,{style:{flex:`1 1 auto`,display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(V,{title:`Provide the npm name or the local path of the plugin to install, uninstall, or add`,children:(0,G.jsx)(B,{value:a,onChange:e=>{let t=e.target.value;c([`latest`,`dev`]),u(`latest`),o(t)},size:`small`,id:`plugin-name`,label:`Plugin name or plugin path`,variant:`outlined`,fullWidth:!0})}),s.length>0&&(0,G.jsx)(V,{title:`Select the npm tag/version to install`,children:(0,G.jsx)(`span`,{children:(0,G.jsxs)(d,{size:`small`,style:{minWidth:`150px`},children:[(0,G.jsx)(at,{id:`plugin-version-label`,children:`Tag or version`}),(0,G.jsx)(Ke,{labelId:`plugin-version-label`,id:`plugin-version`,value:l,label:`Tag or version`,onChange:e=>u(String(e.target.value??``)),sx:{"& .MuiSelect-icon":{color:`var(--main-label-color)`}},children:s.map(e=>(0,G.jsx)(R,{value:e,children:e},e))})]})})}),(0,G.jsx)(V,{title:`Search on npm the plugin to install`,children:(0,G.jsx)(I,{size:`large`,onClick:k,children:(0,G.jsx)(be,{fontSize:`inherit`})})})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(V,{title:`Install or update a plugin from npm`,children:(0,G.jsxs)(j,{onClick:x,endIcon:(0,G.jsx)(Re,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Install`]})}),(0,G.jsx)(V,{title:`Uninstall and remove a plugin`,children:(0,G.jsxs)(j,{onClick:S,endIcon:(0,G.jsx)(We,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Uninstall`]})}),(0,G.jsx)(V,{title:`Upload and install a plugin from a tarball`,children:(0,G.jsxs)(j,{onClick:C,onContextMenu:T,endIcon:(0,G.jsx)(Ce,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Upload`]})}),(0,G.jsx)(V,{title:`Add an already installed plugin or a plugin from a local path`,children:(0,G.jsxs)(j,{onClick:w,onContextMenu:E,endIcon:(0,G.jsx)(Ze,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Add`]})}),(0,G.jsx)(`input`,{id:`file-upload`,type:`file`,accept:`.tgz`,style:{display:`none`},onChange:b})]})]})]})}var bn=(0,W.memo)(yn);function xn({status:e,enabledText:t=`Enabled`,disabledText:n=void 0,tooltipText:r=void 0,onClick:i}){if(e===void 0)return null;{let a=(0,G.jsx)(`div`,{className:e?`status-enabled`:`status-disabled`,style:{cursor:`default`},onClick:i,children:e?t:n??t});return r===void 0?a:(0,G.jsx)(V,{title:r,children:a})}}function Sn(e){return e.id!==0&&e.src===`Matterbridge`&&e.dst===`Frontend`}var Cn={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},wn={fontSize:`12px`,fontWeight:`normal`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},Tn={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},En={fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`,backgroundColor:`var(--div-bg-color)`},Dn={fontSize:`16px`,fontWeight:`bold`,backgroundColor:`var(--div-bg-color)`},On={padding:`0px`,margin:`0px`},kn=`5px 10px 5px 10px`,An={},jn={},Mn={},Nn={},Pn=[],Fn=[];function In(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 Ln(e){let t=e.items;return t!==void 0&&typeof t==`object`&&!Array.isArray(t)}var Rn=({open:e,onClose:t,plugin:n})=>{let{sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,W.useContext)(q),s=(0,W.useRef)(o()),c=(0,W.useRef)({}),l=(0,W.useRef)({}),[u,d]=(0,W.useState)(n.configJson),[p,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`&&(Sn(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),Pn=e.response),Sn(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),Fn=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:`,p),Q&&console.log(`ConfigPluginDialog mounting with uiSchema:`,g),u&&p&&p.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(p,g),_(g),c.current=p,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,p,r,g]);let b=(e,t)=>{y=e.formData},C=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 T(e){let{id:t,label:n,onKeyRenameBlur:r,onRemoveProperty:i,disabled:a,schema:o,children:s,registry:c,readonly:l,required:u}=e,{templates:d}=c,{RemoveButton:f}=d.ButtonTemplates,p=wt in o,m=(0,W.useRef)(null);return(0,W.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,G.jsxs)(F,{sx:{display:`flex`,flexDirection:`row`,flexGrow:1,padding:0,margin:0,border:`none`},children:[(0,G.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,G.jsx)(F,{sx:{flex:1},children:s}),(0,G.jsx)(f,{disabled:a||l,onClick:i,registry:c})]}):(0,G.jsx)(F,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:s})}function E(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,G.jsx)(`div`,{style:{display:`none`},children:t}):(0,G.jsx)(F,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:(0,G.jsxs)(l,{...e,children:[r===!0&&n,t,i,a]})})}function A(e){let{description:t}=e;return t?(0,G.jsx)(U,{sx:wn,children:t}):null}function ee(e){let{required:t,title:n}=e;return n?(0,G.jsx)(F,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,G.jsxs)(U,{sx:Cn,children:[`Title `,n,` `,t&&(0,G.jsx)(`mark`,{children:`***`})]})}):null}function N(e){let{help:t}=e;return t?(0,G.jsx)(F,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,G.jsx)(U,{sx:En,children:t})}):null}function te(e){let{errors:t}=e;return t?(0,G.jsxs)(F,{sx:{padding:`10px`,margin:`10px`,border:`1px solid grey`},children:[(0,G.jsx)(U,{color:`error`,sx:Dn,children:`Please fix the following errors:`}),(0,G.jsx)(h,{children:t.map((e,t)=>(0,G.jsxs)(st,{children:[(0,G.jsx)(z,{children:(0,G.jsx)(pe,{color:`error`})}),(0,G.jsx)(H,{primary:e.stack})]},t))})]}):null}function ne(e){let{errors:t}=e;return t?(0,G.jsx)(F,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:t.map((e,t)=>(0,G.jsxs)(U,{color:`error`,variant:`body2`,sx:{marginLeft:1},children:[`This field `,e]},t))}):null}function re(e){let{id:t,name:n,_schema:r,_uiSchema:i,value:a,options:o,label:s,type:c,placeholder:l,required:u,disabled:d,readonly:f,autofocus:p,onChange:m,onChangeOverride:h,onBlur:g,onFocus:_,_rawErrors:v,_hideError:y,_registry:b,_formContext:x}=e;return(0,G.jsx)(F,{sx:{padding:`0px`,margin:`0px`},children:(0,G.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 ae(e){return console.log(`ArrayFieldTitleTemplate:`,e),null}function oe(e){return console.log(`ArrayFieldDescriptionTemplate:`,e),null}function se(e){let{buttonsProps:t,children:n}=e;return(0,G.jsxs)(F,{sx:{margin:`2px 0px`,padding:`0px`,display:`flex`,alignItems:`center`},children:[(0,G.jsx)(F,{sx:{flexGrow:1,marginRight:`10px`},children:n}),(0,G.jsx)(I,{disabled:!t.hasMoveUp,onClick:t.onMoveUpItem,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(de,{})}),(0,G.jsx)(I,{disabled:!t.hasMoveDown,onClick:t.onMoveDownItem,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(w,{})}),t.hasRemove&&(0,G.jsx)(I,{onClick:t.onRemoveItem,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(O,{})})]})}function le(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),[p,m]=(0,W.useState)(``),g=e=>{m(e.target.value)},_=()=>{Q&&console.log(`ArrayFieldTemplate: handleDialogDeviceToggle filter:`,p,`selectDevices:`,Pn),s(!o)},v=()=>{Q&&console.log(`ArrayFieldTemplate: handleDialogEntityToggle filter:`,p,`selectEntities:`,Fn),l(!c)},y=()=>{Q&&console.log(`ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:`,p,`selectDevices:`,Pn),d(!u)},b=e=>{s(!1),r.selectFrom===`serial`&&Ln(r)?r.items.default=e.serial:r.selectFrom===`name`&&Ln(r)&&(r.items.default=e.name),n()},C=e=>{l(!1),r.selectEntityFrom===`name`&&Ln(r)?r.items.default=e.name:r.selectEntityFrom===`description`&&Ln(r)&&(r.items.default=e.description),n()},w=e=>{d(!1),r.selectDeviceEntityFrom===`name`&&Ln(r)?r.items.default=e.name:r.selectDeviceEntityFrom===`description`&&Ln(r)&&(r.items.default=e.description),n()};return(0,G.jsxs)(F,{sx:{margin:`0px`,padding:`5px 10px 5px 10px`,border:`1px solid grey`},children:[i&&(0,G.jsxs)(F,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[i&&(0,G.jsx)(U,{sx:Cn,children:i}),t&&(0,G.jsxs)(F,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[r.selectFrom&&(0,G.jsx)(V,{title:`Add a device from the list`,children:(0,G.jsx)(I,{onClick:_,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(qe,{})})}),r.selectEntityFrom&&(0,G.jsx)(V,{title:`Add an entity from the list`,children:(0,G.jsx)(I,{onClick:v,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(qe,{})})}),r.selectDeviceEntityFrom&&(0,G.jsx)(V,{title:`Add a device entity from the list`,children:(0,G.jsx)(I,{onClick:y,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(qe,{})})}),(0,G.jsx)(V,{title:`Add a new item`,children:(0,G.jsx)(I,{onClick:n,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(Ze,{})})})]})]}),r.description&&(0,G.jsx)(U,{sx:wn,children:r.description}),e.items,(0,G.jsxs)(x,{open:o,onClose:_,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,G.jsx)(M,{children:`Select a device`}),(0,G.jsxs)(P,{children:[(0,G.jsxs)(F,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,G.jsx)(U,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,G.jsx)(B,{fullWidth:!0,variant:`outlined`,value:p,onChange:g,placeholder:`Enter serial or name`})]}),(0,G.jsx)(h,{dense:!0,children:Pn.filter(e=>e.serial.toLowerCase().includes(p.toLowerCase())||e.name.toLowerCase().includes(p.toLowerCase())).filter(e=>!r.uniqueItems||!a.includes(r.selectFrom===`serial`?e.serial:e.name)).map((e,t)=>(0,G.jsxs)(ce,{onClick:()=>b(e),sx:An,children:[e.icon===`wifi`&&(0,G.jsx)(z,{children:(0,G.jsx)(k,{style:jn})}),e.icon===`ble`&&(0,G.jsx)(z,{children:(0,G.jsx)(S,{style:jn})}),e.icon===`hub`&&(0,G.jsx)(z,{children:(0,G.jsx)(me,{style:jn})}),(0,G.jsx)(H,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:Mn},secondaryTypographyProps:{style:Nn}})]},t))})]}),(0,G.jsx)(ie,{children:(0,G.jsx)(j,{onClick:_,children:`Close`})})]}),(0,G.jsxs)(x,{open:c,onClose:v,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,G.jsx)(M,{children:`Select an entity`}),(0,G.jsxs)(P,{children:[(0,G.jsxs)(F,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,G.jsx)(U,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,G.jsx)(B,{fullWidth:!0,variant:`outlined`,value:p,onChange:g,placeholder:`Enter name or description`})]}),(0,G.jsx)(h,{dense:!0,children:Fn.filter(e=>e.name.toLowerCase().includes(p.toLowerCase())||e.description.toLowerCase().includes(p.toLowerCase())).filter(e=>!r.uniqueItems||!a.includes(r.selectEntityFrom===`name`?e.name:e.description)).map((e,t)=>(0,G.jsxs)(ce,{onClick:()=>C(e),sx:An,children:[e.icon===`wifi`&&(0,G.jsx)(z,{children:(0,G.jsx)(k,{style:jn})}),e.icon===`ble`&&(0,G.jsx)(z,{children:(0,G.jsx)(S,{style:jn})}),e.icon===`hub`&&(0,G.jsx)(z,{children:(0,G.jsx)(me,{style:jn})}),e.icon===`component`&&(0,G.jsx)(z,{children:(0,G.jsx)(f,{style:jn})}),e.icon===`matter`&&(0,G.jsx)(z,{children:(0,G.jsx)(lt,{style:jn})}),(0,G.jsx)(H,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:Mn},secondaryTypographyProps:{style:Nn}})]},t))})]}),(0,G.jsx)(ie,{children:(0,G.jsx)(j,{onClick:v,children:`Close`})})]}),(0,G.jsxs)(x,{open:u,onClose:y,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,G.jsxs)(M,{children:[`Select an entity for `,i]}),(0,G.jsx)(P,{children:(0,G.jsx)(h,{dense:!0,children:Pn.filter(e=>e.serial===i||e.name===i).map(e=>e.entities?.map((e,t)=>(0,G.jsxs)(ce,{onClick:()=>w(e),sx:An,children:[e.icon===`wifi`&&(0,G.jsx)(z,{children:(0,G.jsx)(k,{style:jn})}),e.icon===`ble`&&(0,G.jsx)(z,{children:(0,G.jsx)(S,{style:jn})}),e.icon===`hub`&&(0,G.jsx)(z,{children:(0,G.jsx)(me,{style:jn})}),e.icon===`component`&&(0,G.jsx)(z,{children:(0,G.jsx)(f,{style:jn})}),e.icon===`matter`&&(0,G.jsx)(z,{children:(0,G.jsx)(lt,{style:jn})}),(0,G.jsx)(H,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:Mn},secondaryTypographyProps:{style:Nn}})]},t)))})}),(0,G.jsx)(ie,{children:(0,G.jsx)(j,{onClick:y,children:`Close`})})]})]})}function ue(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=>{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()},p=()=>{t()},m=!n.additionalProperties;return Q&&console.log(`ObjectFieldTemplate: isRoot ${m} pendingAdditionalPropertyKey "${v.current}"`),(0,G.jsxs)(F,{sx:{margin:`0px`,padding:m?`10px`:`5px 10px 0px 10px`,border:m?`none`:`1px solid grey`},children:[n.title&&m&&(0,G.jsx)(F,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,G.jsx)(U,{sx:Cn,children:n.title})}),i&&!m&&(0,G.jsxs)(F,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[(0,G.jsx)(U,{sx:Cn,children:i}),(0,G.jsxs)(F,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[n.selectFrom&&(0,G.jsx)(V,{title:`Add a device from the list`,children:(0,G.jsx)(I,{onClick:d,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(qe,{})})}),(0,G.jsx)(V,{title:`Add a new item`,children:(0,G.jsx)(I,{onClick:p,size:`small`,color:`primary`,sx:On,children:(0,G.jsx)(Ze,{})})})]})]}),n.description&&(0,G.jsx)(F,{sx:{padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,G.jsx)(U,{sx:wn,children:n.description})}),r.map(({content:e,name:t,hidden:r})=>!r&&(0,G.jsxs)(F,{sx:{margin:`0px`,marginBottom:`10px`,padding:In(n,t)&&[`object`,`array`].includes(n.properties[t].type)?`0px`:kn,border:In(n,t)&&[`object`,`array`].includes(n.properties[t].type)?`none`:`1px solid grey`},children:[In(n,t)&&![`object`,`array`,`boolean`].includes(n.properties[t].type)&&(0,G.jsx)(U,{sx:Cn,children:n.properties[t].title||t}),(0,G.jsx)(F,{sx:{flexGrow:1,padding:`0px`,margin:`0px`},children:e})]},t)),(0,G.jsxs)(x,{open:o,onClose:d,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,G.jsx)(M,{children:`Select a device`}),(0,G.jsxs)(P,{children:[(0,G.jsxs)(F,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,G.jsx)(U,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,G.jsx)(B,{fullWidth:!0,variant:`outlined`,value:c,onChange:u,placeholder:`Enter serial or name`})]}),(0,G.jsx)(h,{dense:!0,children:Pn.filter(e=>e.serial.toLowerCase().includes(c.toLowerCase())||e.name.toLowerCase().includes(c.toLowerCase())).map((e,t)=>(0,G.jsxs)(ce,{onClick:()=>f(e),sx:An,children:[e.icon===`wifi`&&(0,G.jsx)(z,{children:(0,G.jsx)(k,{style:jn})}),e.icon===`ble`&&(0,G.jsx)(z,{children:(0,G.jsx)(S,{style:jn})}),e.icon===`hub`&&(0,G.jsx)(z,{children:(0,G.jsx)(me,{style:jn})}),(0,G.jsx)(H,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:Mn},secondaryTypographyProps:{style:Nn}})]},t))})]}),(0,G.jsx)(ie,{children:(0,G.jsx)(j,{onClick:d,children:`Close`})})]})]})}function fe(e){let{uiSchema:n}=e,{submitText:r,norender:i}=xt(n);return i?null:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,margin:`10px`,padding:`0px`,gap:`20px`},children:[(0,G.jsx)(j,{type:`submit`,variant:`contained`,color:`primary`,children:r}),(0,G.jsx)(j,{variant:`contained`,color:`primary`,onClick:t,children:`Cancel`})]})}function L(e){let{className:t,disabled:n,onClick:r,registry:i,style:a,uiSchema:o,...s}=e;return(0,G.jsx)(V,{title:`Remove the item`,children:(0,G.jsx)(I,{disabled:n,size:`small`,color:`primary`,onClick:r,children:(0,G.jsx)(O,{})})})}function he(e){let{className:t,disabled:n,onClick:r,registry:i,uiSchema:a,...o}=e;return(0,G.jsx)(V,{title:`Add an item`,children:(0,G.jsx)(I,{size:`small`,color:`primary`,onClick:r,children:(0,G.jsx)(Ze,{})})})}function ge(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,G.jsx)(V,{title:`Move up the item`,children:(0,G.jsx)(I,{size:`small`,color:`primary`,onClick:n,children:(0,G.jsx)(de,{})})})}function _e(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,G.jsx)(V,{title:`Move down the item`,children:(0,G.jsx)(I,{size:`small`,color:`primary`,onClick:n,children:(0,G.jsx)(w,{})})})}function ve(e){let{id:i,name:a,value:o,schema:c,readonly:l,onChange:d}=e,[f,p]=(0,W.useState)(),m=e=>{Q&&console.log(`CheckboxWidget ${a} onChangeField:`,e),p(e&&e!==``?e:void 0)},h=()=>{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&&C({formData:u})};return c.buttonText&&(c.title||c.description)?(0,G.jsxs)(F,{sx:{margin:`0px`,padding:`5px 0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,G.jsx)(U,{sx:Tn,children:c.title||c.description}),(0,G.jsx)(j,{variant:`contained`,color:`primary`,onClick:()=>h(),children:c.buttonText})]}):c.buttonField&&(c.title||c.description)?(0,G.jsxs)(F,{sx:{margin:`0px`,padding:`5px 0px`,gap:`20px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,G.jsx)(U,{sx:Tn,children:c.title||c.description}),(0,G.jsx)(B,{id:a+`-input`,name:a,label:c.textLabel,placeholder:c.textPlaceholder,onChange:e=>m(e.target.value),sx:{width:`250px`,minWidth:`250px`,maxWidth:`250px`}}),(0,G.jsx)(j,{id:a+`-button`,variant:`contained`,color:`primary`,disabled:f===void 0,onClick:()=>h(),children:c.buttonField})]}):(0,G.jsxs)(F,{sx:{margin:`0px`,padding:`0px`},children:[a&&(0,G.jsxs)(F,{sx:{margin:`0px`,padding:`0px`,gap:`10px`,display:`flex`,justifyContent:`flex-start`,alignItems:`center`},children:[(0,G.jsx)(U,{sx:Cn,children:c.title||a}),(0,G.jsx)(D,{checked:o,readOnly:l,onChange:()=>d(!o),sx:{padding:`0px`,margin:`0px`}})]}),c.description&&(0,G.jsx)(U,{sx:wn,children:c.description})]})}function ye({schema:e,id:t,name:n,options:r,label:i,hideLabel:a,required:o,disabled:s,placeholder:c,readonly:l,value:u,multiple:d,autofocus:f,onChange:p,onBlur:m,onFocus:h,errorSchema:g,rawErrors:_=[],registry:v,uiSchema:y,hideError:b,...x}){let{enumOptions:S,enumDisabled:C,emptyValue:w}=r;d=d===void 0?!1:!!d;let T=d?[]:``,E=u===void 0||d&&u.length<1||!d&&u===T,D=({target:{value:e}})=>p(Ot(e,S,w)),O=({target:e})=>m(t,Ot(e&&e.value,S,w)),k=({target:e})=>h(t,Ot(e&&e.value,S,w)),A=Et(u,S,d),{InputLabelProps:j,SelectProps:ee,autocomplete:M,...N}=x,P=!d&&e.default===void 0;return(0,G.jsxs)(B,{id:t,name:t,value:!E&&A!==void 0?A:T,required:o,disabled:s||l,autoFocus:f,autoComplete:M,placeholder:c,error:_.length>0,onChange:D,onBlur:O,onFocus:k,...N,select:!0,InputLabelProps:{...j,shrink:!E},SelectProps:{...ee,multiple:d},"aria-describedby":Dt(t),children:[P&&(0,G.jsx)(R,{value:``,children:c}),Array.isArray(S)&&S.map(({value:e,label:t},n)=>{let r=Array.isArray(C)&&C.indexOf(e)!==-1;return(0,G.jsx)(R,{value:String(n),disabled:r,children:t},n)})]})}return Q&&console.log(`ConfigPluginDialog rendering...`),!e||!p||!u?null:(0,G.jsxs)(x,{open:e,onClose:t,slotProps:{paper:{sx:{maxWidth:`800px`}}},children:[(0,G.jsx)(M,{gap:`20px`,children:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,G.jsx)(`h3`,{children:`Matterbridge plugin configuration`})]})}),(0,G.jsx)(P,{style:{padding:`0px`,margin:`0px`,width:`800px`,height:`600px`,overflow:`auto`},children:(0,G.jsx)(kt,{schema:p,formData:u,uiSchema:g,validator:Tt,templates:{FieldTemplate:E,BaseInputTemplate:re,TitleFieldTemplate:ee,DescriptionFieldTemplate:A,FieldHelpTemplate:N,FieldErrorTemplate:ne,ErrorListTemplate:te,WrapIfAdditionalTemplate:T,ArrayFieldTitleTemplate:ae,ArrayFieldDescriptionTemplate:oe,ArrayFieldItemTemplate:se,ArrayFieldTemplate:le,ObjectFieldTemplate:ue,ButtonTemplates:{SubmitButton:fe,RemoveButton:L,AddButton:he,MoveUpButton:ge,MoveDownButton:_e}},widgets:{CheckboxWidget:ve,SelectWidget:ye},onChange:b,onSubmit:C})})]})};function zn(e){if(Q&&console.log(`getQRColor (id: ${e?.id}) received matter:`,e??`undefined`),e===void 0||!e.online||!e.qrPairingCode&&!e.manualPairingCode&&!e.fabricInformations&&!e.sessionInformations)return`red`;if(e.commissioned===!1&&e.qrPairingCode&&e.manualPairingCode)return`var(--primary-color)`;let t=0,n=0;for(let r of e.sessionInformations??[])r.fabric&&r.isPeerActive===!0&&t++,r.numberOfActiveSubscriptions>0&&(n+=r.numberOfActiveSubscriptions);return e.commissioned===!0&&e.fabricInformations&&e.sessionInformations&&(t===0||n===0)?`var(--secondary-color)`:`var(--div-text-color)`}function Bn({storeId:e,setStoreId:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,W.useContext)(q),{showConfirmCancelDialog:s}=(0,W.useContext)(It),c=(0,W.useRef)(o()),[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)([]),g=[{label:`Name`,id:`name`,required:!0,render:(e,t,n,r)=>(0,G.jsx)(V,{title:`Plugin path ${n.path}`,children:(0,G.jsx)(`span`,{style:{cursor:`pointer`},onClick:()=>E(n),children:n.name})})},{label:`Description`,id:`description`,render:(e,t,n,r)=>(0,G.jsx)(V,{title:`Open the plugin homepage`,children:(0,G.jsx)(`span`,{style:{cursor:`pointer`},onClick:()=>E(n),children:n.description})})},{label:`Version`,id:`version`,render:(e,t,n,r)=>(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(V,{title:`Plugin v.${n.version}`,children:(0,G.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,G.jsx)(G.Fragment,{children:n.author?n.author.replace(`https://github.com/`,``):`Unknown`})},{label:`Type`,id:`type`,render:(e,t,n,r)=>(0,G.jsx)(G.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,G.jsxs)(`div`,{style:{margin:`0px`,padding:`0px`,gap:`4px`,display:`flex`,flexDirection:`row`},children:[f&&f.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,G.jsx)(V,{title:`Shows the QRCode or the fabrics`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:zn(r.matter)},onClick:()=>{r.matter?.id&&t(r.matter?.id)},size:`small`,children:(0,G.jsx)(ae,{})})}),f&&f.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,G.jsx)(V,{title:`Restart the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`},onClick:()=>w(r),size:`small`,children:(0,G.jsx)(he,{})})}),(0,G.jsx)(V,{title:`Plugin config`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{disabled:r.restartRequired===!0,style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>N(r),size:`small`,children:(0,G.jsx)(_e,{})})}),f&&!f.readOnly&&(0,G.jsx)(V,{title:`Remove the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{v(`Remove plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`remove`,r)},size:`small`,children:(0,G.jsx)(We,{})})}),r.enabled?(0,G.jsx)(V,{title:`Disable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{v(`Disable plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`disable`,r)},size:`small`,children:(0,G.jsx)(l,{})})}):(0,G.jsx)(G.Fragment,{}),r.enabled?(0,G.jsx)(G.Fragment,{}):(0,G.jsx)(V,{title:`Enable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>T(r),size:`small`,children:(0,G.jsx)(Te,{})})}),(0,G.jsx)(V,{title:`Open the plugin help`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>O(r),size:`small`,children:(0,G.jsx)(Ye,{})})}),(0,G.jsx)(V,{title:`Open the plugin version history`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>k(r),size:`small`,children:(0,G.jsx)(He,{})})}),r.latestVersion!==void 0&&r.latestVersion!==r.version&&f&&!f.readOnly&&(0,G.jsx)(V,{title:`Update the plugin to the latest version`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{color:`var(--primary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>x(r),size:`small`,children:(0,G.jsx)(ge,{})})}),(r.version.includes(`-dev-`)||r.version.includes(`-git-`))&&r.devVersion!==void 0&&r.devVersion!==r.version&&f&&!f.readOnly&&(0,G.jsx)(V,{title:`Update the plugin to the latest dev version`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{color:`var(--secondary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>S(r),size:`small`,children:(0,G.jsx)(ge,{})})}),f&&!f.readOnly&&(0,G.jsx)(V,{title:`Sponsor the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`#b6409c`},onClick:()=>D(r),size:`small`,children:(0,G.jsx)($e,{})})})]})},{label:`Status`,id:`status`,required:!0,noSort:!0,render:(e,t,n,r)=>(0,G.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,G.jsx)(G.Fragment,{children:(0,G.jsx)(xn,{status:!1,enabledText:`Error`,disabledText:`Error`,tooltipText:`The plugin is in error state. Check the log!`})}):(0,G.jsx)(G.Fragment,{children:n.enabled===!1?(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(xn,{status:n.enabled,enabledText:`Enabled`,disabledText:`Disabled`,tooltipText:`Whether the plugin is enable or disabled`})}):(0,G.jsx)(G.Fragment,{children:n.loaded&&n.started&&n.configured?(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(xn,{status:n.loaded,enabledText:`Running`,tooltipText:`Whether the plugin is running`})}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(xn,{status:n.loaded,enabledText:`Loaded`,tooltipText:`Whether the plugin has been loaded`}),(0,G.jsx)(xn,{status:n.started,enabledText:`Started`,tooltipText:`Whether the plugin started`}),(0,G.jsx)(xn,{status:n.configured,enabledText:`Configured`,tooltipText:`Whether the plugin has been configured`})]})})})})}];(0,W.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`),h(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:c.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}`),h(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:c.current,sender:`HomePlugins`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})),e.id===c.current&&e.method===`/api/settings`?(Q&&console.log(`HomePlugins (id: ${e.id}) received settings:`,e.response),d(e.response.systemInformation),p(e.response.matterbridgeInformation)):e.id===c.current&&e.method===`/api/plugins`&&(Q&&console.log(`HomePlugins (id: ${e.id}) received ${e.response.length} plugins:`,e.response),h(e.response))};return i(e,c.current),Q&&console.log(`HomePlugins added WebSocket listener id:`,c.current),()=>{a(e),Q&&console.log(`HomePlugins removed WebSocket listener`)}},[i,a,r]),(0,W.useEffect)(()=>{n&&(Q&&console.log(`HomePlugins sending api requests`),r({id:c.current,sender:`HomePlugins`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:c.current,sender:`HomePlugins`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[n,r]);let _=(0,W.useRef)(null),v=(e,t,n,r)=>{Q&&console.log(`handleActionWithConfirmCancel ${n} ${r.name}`),_.current=r,s(e,t,n,y,b)},y=e=>{Q&&console.log(`handleConfirm action confirmed ${e} ${_.current?.name}`),e===`remove`&&_.current?C(_.current):e===`disable`&&_.current&&T(_.current),_.current=null},b=e=>{Q&&console.log(`handleCancel action canceled ${e} ${_.current?.name}`),_.current=null},x=e=>{Q&&console.log(`handleUpdatePlugin plugin:`,e.name),r({id:c.current,sender:`HomePlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e.name,restart:!1}})},S=e=>{Q&&console.log(`handleUpdateDevPlugin plugin:`,e.name),r({id:c.current,sender:`HomePlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e.name+`@dev`,restart:!1}})},C=e=>{Q&&console.log(`handleRemovePlugin plugin:`,e.name),r({id:c.current,sender:`HomePlugins`,method:`/api/removeplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},w=e=>{Q&&console.log(`handleRestartPlugin plugin:`,e.name),r({id:c.current,sender:`HomePlugins`,method:`/api/restartplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},T=e=>{Q&&console.log(`handleEnableDisablePlugin plugin:`,e.name,`enabled:`,e.enabled),e.enabled===!0?(e.enabled=!1,r({id:c.current,sender:`HomePlugins`,method:`/api/disableplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})):(e.enabled=!0,r({id:c.current,sender:`HomePlugins`,method:`/api/enableplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}}))},E=e=>{Q&&console.log(`handleHomepagePlugin plugin: ${e.name} homepage: ${e.homepage}`),e.homepage&&window.open(e.homepage,`_blank`)},D=e=>{Q&&console.log(`handleSponsorPlugin plugin:`,e.name,`funding:`,e.funding),e.funding&&window.open(e.funding,`_blank`)},O=e=>{Q&&console.log(`handleHelpPlugin plugin:`,e.name,`help:`,e.help),e.help&&window.open(e.help,`_blank`)},k=e=>{Q&&console.log(`handleChangelogPlugin plugin:`,e.name,`changelog:`,e.changelog),e.changelog&&window.open(e.changelog,`_blank`)},[A,j]=(0,W.useState)(),[ee,M]=(0,W.useState)(!1),N=e=>{Q&&console.log(`handleConfigPlugin plugin:`,e.name),r({id:c.current,sender:`HomePlugins`,method:`/api/select/devices`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:e.name}}),r({id:c.current,sender:`HomePlugins`,method:`/api/select/entities`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:e.name}}),j(e),P()},P=()=>{M(!0)};return Q&&console.log(`HomePlugins rendering...`),n?(0,G.jsxs)(Y,{children:[A&&(0,G.jsx)(Rn,{open:ee,onClose:()=>{M(!1)},plugin:A}),(0,G.jsx)(sn,{name:`Plugins`,columns:g,rows:m,footerRight:``,footerLeft:``})]}):(0,G.jsx)(Vt,{})}var Vn=(0,W.memo)(Bn),Hn=e=>`${e.pluginName}::${e.serial}`;function Un({storeId:e,setStoreId:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,W.useContext)(q),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(!0),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)([]),[h,g]=(0,W.useState)([]),[_,v]=(0,W.useState)([]),[y,b]=(0,W.useState)([]),x=(0,W.useRef)(o()),S=[{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,G.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,G.jsx)(E,{fontSize:`small`,sx:{color:`var(--primary-color)`}}):n.powerSource===`ok`?n.batteryLevel?(0,G.jsx)(V,{title:`Battery level: ${n.batteryLevel}%`,children:(0,G.jsx)(A,{fontSize:`small`,sx:{color:`green`}})}):(0,G.jsx)(A,{fontSize:`small`,sx:{color:`gray`}}):n.powerSource===`warning`?n.batteryLevel?(0,G.jsx)(V,{title:`Battery level: ${n.batteryLevel}%`,children:(0,G.jsx)(A,{fontSize:`small`,sx:{color:`yellow`}})}):(0,G.jsx)(A,{fontSize:`small`,sx:{color:`yellow`}}):n.powerSource===`critical`?n.batteryLevel?(0,G.jsx)(V,{title:`Battery level: ${n.batteryLevel}%`,children:(0,G.jsx)(A,{fontSize:`small`,sx:{color:`red`}})}):(0,G.jsx)(A,{fontSize:`small`,sx:{color:`red`}}):(0,G.jsx)(`span`,{})},{label:`Actions`,id:`selected`,required:!0,render:(n,r,i,a)=>(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`},children:[i.matter===void 0?(0,G.jsx)(`div`,{style:{width:`20px`,height:`20px`}}):(0,G.jsx)(V,{title:`Show the QRCode or the fabrics`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{onClick:()=>t(e===i.matter?.id?d?.matterbridgeInformation.bridgeMode===`bridge`?`Matterbridge`:null:i.matter?.id||null),"aria-label":`Show the QRCode`,sx:{margin:0,padding:0,color:zn(i.matter)},children:(0,G.jsx)(ae,{fontSize:`small`})})}),i.configUrl?(0,G.jsx)(V,{title:`Open the configuration page`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(I,{onClick:()=>window.open(i.configUrl,`_blank`),"aria-label":`Open config url`,sx:{margin:0,padding:0},children:(0,G.jsx)(oe,{fontSize:`small`})})}):(0,G.jsx)(`div`,{style:{width:`20px`,height:`20px`}}),i.selected===void 0?(0,G.jsx)(`div`,{style:{width:`20px`,height:`20px`}}):(0,G.jsx)(V,{title:`Select/unselect the device`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,G.jsx)(D,{checked:i.selected,onChange:e=>w(e,i),sx:{margin:`0`,marginLeft:`8px`,padding:`0`},size:`small`})})]})}],C=(0,W.useCallback)(e=>{e.selected=void 0;let t=p.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},[p]);(0,W.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:x.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}`),b(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`),c(!0)):e.method===`restart_not_required`?(Q&&console.log(`HomeDevices received restart_not_required`),c(!1)):e.method===`state_update`&&e.response.plugin&&e.response.serialNumber&&e.response.cluster.includes(`BasicInformation`)&&e.response.attribute===`reachable`&&(Q&&console.log(`HomeDevices updating device reachability for plugin ${e.response.plugin} serial ${e.response.serialNumber} value ${e.response.value}`),g(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===x.current&&e.method===`/api/settings`)Q&&console.log(`HomeDevices (id: ${e.id}) received settings:`,e.response),f(e.response),c(e.response.matterbridgeInformation.restartRequired||e.response.matterbridgeInformation.fixedRestartRequired);else if(e.id===x.current&&e.method===`/api/plugins`){if(Q&&console.log(`HomeDevices (id: ${e.id}) received ${e.response?.length} plugins:`,e.response),e.response){let t=!0;for(let n of e.response)n.enabled===!0&&(n.loaded!==!0||n.started!==!0||n.error===!0)&&(t=!1);if(!t)return;Q&&console.log(`HomeDevices reset plugins, devices and selectDevices`),u(!1),m(e.response),g([]),v([]),r({id:x.current,sender:`HomeDevices`,method:`/api/devices`,src:`Frontend`,dst:`Matterbridge`,params:{}}),Q&&console.log(`HomeDevices sent /api/devices`);for(let t of e.response)t.enabled===!0&&t.loaded===!0&&t.started===!0&&t.error!==!0&&(r({id:x.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===x.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=C(t);g(e.response)}}else e.id===x.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&&v(t=>{let n=t.filter(t=>t.pluginName!==e.response[0].pluginName),r=e.response.map(e=>({...e,selected:C(e)}));return[...n,...r]}))};return i(e,x.current),Q&&console.log(`HomeDevices added WebSocket listener id ${x.current}`),()=>{a(e),Q&&console.log(`HomeDevices removed WebSocket listener`)}},[p,i,a,r,C]),(0,W.useEffect)(()=>{if(h.length===0&&_.length===0){b([]);return}Q&&console.log(`HomeDevices mixing devices (${h.length}) and selectDevices (${_.length})`);let e=[];for(let t of h)e.push(t);for(let t of _)h.find(e=>e.pluginName===t.pluginName&&e.serial.includes(t.serial))||e.push(t);e.length>0&&(b(e),Q&&console.log(`HomeDevices mixed ${e.length} devices and selectDevices`))},[p,h,_,b]),(0,W.useEffect)(()=>{n&&(Q&&console.log(`HomeDevices sending /api/settings and /api/plugins requests`),r({id:x.current,sender:`HomeDevices`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:x.current,sender:`HomeDevices`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[n,r]);let w=(e,t)=>{Q&&console.log(`handleCheckboxChange: checkbox changed to ${e.target.checked} for device ${t.name} serial ${t.serial}`),h.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`),b(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])})):g(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:x.current,sender:`HomeDevices`,method:`/api/command`,src:`Frontend`,dst:`Matterbridge`,params:{command:`selectdevice`,plugin:t.pluginName,serial:t.serial,name:t.name}}):r({id:x.current,sender:`HomeDevices`,method:`/api/command`,src:`Frontend`,dst:`Matterbridge`,params:{command:`unselectdevice`,plugin:t.pluginName,serial:t.serial,name:t.name}})};return Q&&console.log(`HomeDevices rendering...`),n?(0,G.jsx)(Y,{style:{flex:`1 1 auto`},children:(0,G.jsx)(sn,{name:`Devices`,getRowKey:Hn,rows:y,columns:S,footerLeft:l?`Waiting for the plugins to fully load...`:`Registered devices: ${h.length.toString()}/${y.length.toString()}`,footerRight:s?`Restart required`:``})}):(0,G.jsx)(Vt,{})}var Wn=(0,W.memo)(Un);function Gn({children:e,style:t,name:n}){let{setCurrentPage:r}=(0,W.useContext)(It);return r(n),Q&&console.log(`MbfPage: current page set to ${n}`),(0,G.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,margin:`0px`,padding:`0px`,gap:`20px`,...t},children:e})}var Kn=()=>`ontouchstart`in window||window.DocumentTouch!==void 0&&document instanceof window.DocumentTouch?(Q&&console.log(`WebSocketLogs detectTouchscreen = true`),!0):(Q&&console.log(`WebSocketLogs detectTouchscreen = false`),!1);function qn(){let{messages:e,logAutoScroll:t}=(0,W.useContext)(Rt),[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)(()=>Kn(),[]),c=e=>r(!0),l=e=>r(!1);(0,W.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,G.jsx)(`div`,{style:{margin:`0px`,padding:`0px`},children:(0,G.jsxs)(`ul`,{style:{margin:`0px`,padding:`0px`},onMouseEnter:c,onMouseLeave:l,children:[e.map((e,t)=>(0,G.jsxs)(`li`,{style:{wordWrap:`break-word`,maxHeight:`200px`,overflow:`hidden`},children:[(0,G.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,G.jsx)(`span`,{style:{marginRight:`3px`,color:`#505050`},children:`[`+e.time+`]`}),e.name&&(0,G.jsx)(`span`,{style:{marginRight:`3px`,color:`#09516d`},children:`[`+e.name+`]`}),(0,G.jsx)(`span`,{style:{color:`var(--main-log-color)`},children:e.message})]},t)),(0,G.jsx)(`div`,{ref:i})]})})}var Jn=(0,W.memo)(qn);function Yn(){let[e,t]=(0,W.useState)(localStorage.getItem(K.logFilterLevel)??`info`),[n,r]=(0,W.useState)(localStorage.getItem(K.logFilterSearch)??`*`),{online:i,logAutoScroll:a}=(0,W.useContext)(q);return Q&&console.log(`HomeLogs rendering...`),i?(0,G.jsxs)(Y,{style:{flex:`1 1 auto`},children:[(0,G.jsxs)(Ut,{children:[(0,G.jsx)(X,{children:`Logs`}),(0,G.jsxs)(X,{style:{fontWeight:`normal`,fontSize:`12px`,marginTop:`2px`},children:[`Filter: logger level "`,e,`" and search "`,n===``?`*`:n,`" Scroll: `,a.current?`auto`:`manual`]})]}),(0,G.jsx)(qt,{style:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`10px`,alignItems:`start`},children:(0,G.jsx)(Jn,{})})]}):(0,G.jsx)(Vt,{})}var Xn=(0,W.memo)(Yn);function Zn(){let{online:e}=(0,W.useContext)(q);return Q&&console.log(`HomeBrowserRefresh rendering...`),e?(0,G.jsxs)(Y,{children:[(0,G.jsx)(Ut,{children:(0,G.jsx)(X,{children:`Frontend Update`})}),(0,G.jsxs)(qt,{style:{flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`},children:[(0,G.jsx)(`h4`,{style:{margin:0},children:`The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now.`}),(0,G.jsx)(`div`,{children:(0,G.jsx)(j,{onClick:()=>window.location.reload(),endIcon:(0,G.jsx)(b,{}),style:{marginLeft:`10px`,color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Refresh`})})]})]}):(0,G.jsx)(Vt,{})}var Qn=(0,W.memo)(Zn);function $n({changelog:e}){let{online:t}=(0,W.useContext)(q);return Q&&console.log(`HomeShowChangelog rendering...`),t?(0,G.jsxs)(Y,{children:[(0,G.jsx)(Ut,{children:(0,G.jsx)(X,{children:`Matterbridge Update`})}),(0,G.jsxs)(qt,{style:{flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`},children:[(0,G.jsx)(`h4`,{style:{margin:0},children:`Matterbridge has been updated.`}),(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:`10px`},children:[(0,G.jsx)(j,{onClick:()=>window.open(`https://github.com/Luligu/matterbridge`,`_blank`),endIcon:(0,G.jsx)(N,{style:{color:`#FFD700`}}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Star`}),(0,G.jsx)(j,{onClick:()=>window.open(`https://www.buymeacoffee.com/luligugithub`,`_blank`),endIcon:(0,G.jsx)($e,{style:{color:`#b6409c`}}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Sponsor`}),(0,G.jsx)(j,{onClick:()=>window.open(e,`_blank`),endIcon:(0,G.jsx)(He,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Changelog`}),(0,G.jsx)(j,{onClick:()=>window.location.reload(),endIcon:(0,G.jsx)(re,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Close`})]})]})]}):(0,G.jsx)(Vt,{})}var er=(0,W.memo)($n);function tr({matterbridgeInfo:e}){let{mobile:t}=(0,W.useContext)(It);Q&&console.log(`MatterbridgeInfoTable:`,e);let n=[`matterbridgeLatestVersion`,`matterbridgeDevVersion`,`--matterFileLogger`,`--fileLogger`,`--matterLoggerLevel`,`--loggerLevel`,`--virtualMode`,`--bridgeMode`,`--restartMode`,`--restartRequired`,`fixedRestartRequired`,`--updateRequired`,`matterMdnsInterface`,`matterIpv4Address`,`matterIpv6Address`,`readOnly`,`shellyBoard`,`shellySysUpdate`,`shellyMainUpdate`,`matterPort`,`matterDiscriminator`,`matterPasscode`],[r,i]=(0,W.useState)(!1);return!e||r?null:(Q&&console.log(`MatterbridgeInfoTable rendering...`),(0,G.jsxs)(Y,{style:$&&t?{flex:`1 1 300px`}:{flex:`0 1 auto`,width:`302px`,minWidth:`302px`},children:[(0,G.jsxs)(Ut,{children:[(0,G.jsx)(X,{children:`Matterbridge info`}),(0,G.jsx)(Jt,{close:()=>i(!0)})]}),(0,G.jsx)(qt,{style:$&&t?{flex:`1 1 auto`,margin:`0px`,padding:`0px`,gap:`0px`}:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`0px`,gap:`0px`},children:(0,G.jsxs)(`table`,{style:{border:`none`,borderCollapse:`collapse`,tableLayout:`fixed`},children:[(0,G.jsxs)(`colgroup`,{children:[(0,G.jsx)(`col`,{style:{width:`40%`}}),(0,G.jsx)(`col`,{style:{width:`60%`}})]}),(0,G.jsx)(`tbody`,{style:{border:`none`,borderCollapse:`collapse`},children:Object.entries(e).filter(([e,t])=>!n.includes(e)&&t!=null&&t!==``).map(([e,n],r)=>(0,G.jsxs)(`tr`,{className:r%2==0?`table-content-even`:`table-content-odd`,style:{border:`none`,borderCollapse:`collapse`},children:[(0,G.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`},children:e.replace(`matterbridgeVersion`,`Matterbridge version`).replace(`matterbridgeLatestVersion`,`Matterbridge latest v.`).replace(`matterbridgeDevVersion`,`Matterbridge dev v.`).replace(`frontendVersion`,`Frontend version`).replace(`homeDirectory`,`Home`).replace(`rootDirectory`,`Root`).replace(`matterbridgeDirectory`,`Storage`).replace(`matterbridgeCertDirectory`,`Cert`).replace(`matterbridgePluginDirectory`,`Plugins`).replace(`globalModulesDirectory`,`Modules`).replace(`bridgeMode`,`Bridge mode`).replace(`restartMode`,`Restart mode`).replace(`virtualMode`,`Virtual mode`).replace(`profile`,`Profile`).replace(`loggerLevel`,`Logger level`).replace(`fileLogger`,`File logger`).replace(`loggerLevel`,`Logger level`).replace(`fileLogger`,`File logger`).replace(`matterLoggerLevel`,`Matter logger level`).replace(`matterFileLogger`,`Matter file logger`).replace(`restartRequired`,`Restart required`).replace(`updateRequired`,`Update required`)}),(0,G.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:$&&t?typeof n==`string`?n:n.toString():(0,G.jsx)(Ht,{value:typeof n==`string`?n:n.toString(),maxChars:24})})]},e))})]})})]}))}var nr=(0,W.memo)(tr);function rr(){let[e,t]=(0,W.useState)(null),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)([]),[o]=(0,W.useState)(localStorage.getItem(K.homePagePlugins)!==`false`),[s,c]=(0,W.useState)(localStorage.getItem(K.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)(It),{addListener:v,removeListener:y,online:b,sendMessage:x,getUniqueId:S}=(0,W.useContext)(q),C=(0,W.useRef)(S());return(0,W.useEffect)(()=>{let e=e=>{Q&&console.log(`Home received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`settings`&&(Q&&console.log(`Home received refresh_required: changed=${e.response.changed} and sending /api/settings request`),g(null),a([]),x({id:C.current,sender:`Home`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),x({id:C.current,sender:`Home`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})),e.method===`/api/settings`&&e.id===C.current&&(Q&&console.log(`Home received settings:`,e.response),t(e.response.systemInformation),r(e.response.matterbridgeInformation),localStorage.getItem(K.frontendVersion)===null&&e.response.matterbridgeInformation.frontendVersion?localStorage.setItem(K.frontendVersion,e.response.matterbridgeInformation.frontendVersion):e.response.matterbridgeInformation.frontendVersion!==localStorage.getItem(K.frontendVersion)&&e.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem(K.frontendVersion,e.response.matterbridgeInformation.frontendVersion),m(!0)),localStorage.getItem(K.matterbridgeVersion)===null?localStorage.setItem(K.matterbridgeVersion,e.response.matterbridgeInformation.matterbridgeVersion):e.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem(K.matterbridgeVersion)&&(localStorage.setItem(K.matterbridgeVersion,e.response.matterbridgeInformation.matterbridgeVersion),f(!0)),e.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem(K.homePageMode)||(localStorage.setItem(K.homePageMode,`devices`),c(`devices`)))),e.method===`/api/plugins`&&e.id===C.current&&(Q&&console.log(`Home received plugins:`,e.response),a(e.response))};return v(e,C.current),Q&&console.log(`Home added WebSocket listener id ${C.current}`),()=>{y(e),Q&&console.log(`Home removed WebSocket listener`)}},[v,y,x]),(0,W.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,W.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,G.jsx)(Vt,{}):(0,G.jsxs)(Gn,{name:`Home`,style:$&&_?{alignItems:`center`,gap:`10px`}:{flexDirection:`row`},children:[($&&!_||!$)&&(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,width:`302px`,minWidth:`302px`,gap:`20px`},children:[(0,G.jsx)(en,{id:h}),(0,G.jsx)(Xt,{systemInfo:e,compact:!0})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,width:`100%`,gap:$&&_?`10px`:`20px`},children:[p&&(0,G.jsx)(Qn,{}),d&&(0,G.jsx)(er,{changelog:l}),$&&_&&(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:`10px`},children:[(0,G.jsx)(en,{id:h}),(0,G.jsx)(Xt,{systemInfo:e,compact:!0}),(0,G.jsx)(nr,{matterbridgeInfo:n})]}),o&&!n.readOnly&&(0,G.jsx)(bn,{}),o&&(0,G.jsx)(Vn,{storeId:h,setStoreId:g}),s===`devices`&&(0,G.jsx)(Wn,{storeId:h,setStoreId:g}),s===`logs`&&(0,G.jsx)(Xn,{})]})]})}var ir=(0,W.memo)(rr),ar=!1,or={display:`flex`,gap:`2px`,justifyContent:`space-evenly`,width:`100%`,height:`40px`},sr={margin:`0`,padding:`0`,fontSize:`36px`,fontWeight:`medium`,color:`var(--primary-color)`},cr={margin:`0`,padding:`0`,fontSize:`20px`,fontWeight:`medium`,color:`var(--div-text-color)`,textAlign:`center`},lr={margin:`0`,padding:`0`,paddingBottom:`2px`,fontSize:`16px`,fontWeight:`medium`,color:`var(--div-text-color)`,textAlign:`center`},ur={display:`flex`,gap:`2px`,justifyContent:`center`,width:`100%`,height:`18px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},dr={margin:`0`,padding:`0`,fontSize:`12px`,fontWeight:`normal`,color:`var(--div-text-color)`},fr={display:`flex`,justifyContent:`center`,width:`100%`,height:`52px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},pr={margin:`0`,padding:`0`,fontSize:`14px`,fontWeight:`bold`,color:`var(--div-text-color)`},mr={display:`flex`,gap:`4px`,justifyContent:`center`,width:`100%`,height:`15px`,margin:`0`,padding:`0`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`normal`},hr={margin:`0`,padding:`0px 4px`,borderRadius:`5px`,textAlign:`center`,fontSize:`12px`,fontWeight:`normal`,color:`var(--secondary-color)`},gr=[256,257,268,269],_r=[266,267],vr=[259,260,261,271,272],yr=[256,257,268,269,266,267,259,260,261,272];function Z({icon:e,iconColor:t,cluster:n,value:r,unit:i,prefix:a}){return Q&&console.log(`Render cluster "${n.clusterName}.${n.attributeName}" value(${typeof r}-${isNaN(r)}) "${r}" unit "${i}"`),a??=!1,(0,G.jsxs)(F,{sx:or,children:[e&&(0,W.cloneElement)(e,{key:`${n.clusterId}-${n.attributeId}-icon`,sx:{...sr,color:t??`var(--primary-color)`}}),(0,G.jsxs)(F,{sx:{...or,gap:`4px`,alignContent:`center`,alignItems:`end`,justifyContent:`center`},children:[i&&a===!0&&(0,G.jsx)(U,{sx:lr,children:i},`${n.clusterId}-${n.attributeId}-unit`),(0,G.jsx)(U,{sx:cr,children:r==null||typeof r==`number`&&isNaN(r)||r===`NaN`?`---`:r},`${n.clusterId}-${n.attributeId}-value`),i&&a===!1&&(0,G.jsx)(U,{sx:lr,children:i},`${n.clusterId}-${n.attributeId}-unit`)]},`${n.clusterId}-${n.attributeId}-valueunitbox`)]},`${n.clusterId}-${n.attributeId}-box`)}function br({device:e,endpoint:t,id:n,deviceType:r,clusters:i}){let a=[`Unknown`,`Good`,`Fair`,`Moderate`,`Poor`,`VeryPoor`,`Ext.Poor`],o=``;Q&&console.log(`Device "${e.name}" endpoint "${t}" id "${n}" deviceType "0x${r.toString(16).padStart(4,`0`)}" clusters (${i?.length})`);let s=i.find(e=>e.clusterName===`Descriptor`&&e.attributeName===`tagList`)?.attributeLocalValue;if(s){let e=``;s.map(t=>{t.label&&(e+=t.label+` `)}),o=e.trim()}if(r===17&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`batVoltage`).map(e=>o=`${e.attributeLocalValue} mV`),yr.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,G.jsxs)(Y,{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,G.jsx)(Z,{icon:e.attributeLocalValue===!0?(0,G.jsx)(k,{}):(0,G.jsx)(Fe,{}),iconColor:e.attributeLocalValue===!0?`green`:`red`,cluster:e,value:e.attributeLocalValue===!0?`Online`:`Offline`})),r===17&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`batPercentRemaining`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(A,{}),cluster:e,value:e.attributeLocalValue/2,unit:`%`})),r===17&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`wiredCurrentType`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(E,{}),cluster:e,value:e.attributeLocalValue===0?`AC`:`DC`})),r===1293&&i.filter(e=>e.clusterName===`DeviceEnergyManagement`&&e.attributeName===`esaState`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.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`})),gr.includes(r)&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(xe,{}),cluster:e,value:e.attributeLocalValue===!0?`On`:`Off`})),_r.includes(r)&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.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`})),vr.includes(r)&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M8 6V18H16V6H8M14 10H10V8H14V10M19.4 1.6C19 1.2 18.5 1 18 1H6C5.5 1 5 1.2 4.6 1.6C4.2 2 4 2.5 4 3V21C4 21.5 4.2 22 4.6 22.4C5 22.8 5.5 23 6 23H18C18.5 23 19 22.8 19.4 22.4C19.8 22 20 21.5 20 21V3C20 2.5 19.8 2 19.4 1.6M18 21H6V3H18V21Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===!0?`On`:`Off`})),r===115&&i.filter(e=>e.clusterName===`OperationalState`&&e.attributeName===`operationalState`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M14.83,11.17C16.39,12.73 16.39,15.27 14.83,16.83C13.27,18.39 10.73,18.39 9.17,16.83L14.83,11.17M6,2H18A2,2 0 0,1 20,4V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2M7,4A1,1 0 0,0 6,5A1,1 0 0,0 7,6A1,1 0 0,0 8,5A1,1 0 0,0 7,4M10,4A1,1 0 0,0 9,5A1,1 0 0,0 10,6A1,1 0 0,0 11,5A1,1 0 0,0 10,4M12,8A6,6 0 0,0 6,14A6,6 0 0,0 12,20A6,6 0 0,0 18,14A6,6 0 0,0 12,8Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Normal`:`Error`})),r===124&&i.filter(e=>e.clusterName===`OperationalState`&&e.attributeName===`operationalState`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M6,2H18A2,2 0 0,1 20,4V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2M7,4A1,1 0 0,0 6,5A1,1 0 0,0 7,6A1,1 0 0,0 8,5A1,1 0 0,0 7,4M10,4A1,1 0 0,0 9,5A1,1 0 0,0 10,6A1,1 0 0,0 11,5A1,1 0 0,0 10,4M12,8A6,6 0 0,0 6,14A6,6 0 0,0 12,20A6,6 0 0,0 18,14A6,6 0 0,0 12,8M8.11,10.5H10C9.76,11.88 10,12.67 10.58,13.29C11.68,14.36 12.16,15.71 11.89,17.5H10C10.24,16.12 10,15.33 9.42,14.71C8.32,13.64 7.85,12.29 8.11,10.5M12.11,10.5H14C13.76,11.88 14,12.67 14.58,13.29C15.68,14.36 16.16,15.71 15.89,17.5H14C14.24,16.12 14,15.33 13.42,14.71C12.32,13.64 11.85,12.29 12.11,10.5Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Normal`:`Error`})),r===117&&i.filter(e=>e.clusterName===`OperationalState`&&e.attributeName===`operationalState`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M18,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V4A2,2 0 0,0 18,2M10,4A1,1 0 0,1 11,5A1,1 0 0,1 10,6A1,1 0 0,1 9,5A1,1 0 0,1 10,4M7,4A1,1 0 0,1 8,5A1,1 0 0,1 7,6A1,1 0 0,1 6,5A1,1 0 0,1 7,4M18,20H6V8H18V20M14.67,15.33C14.69,16.03 14.41,16.71 13.91,17.21C12.86,18.26 11.15,18.27 10.09,17.21C9.59,16.71 9.31,16.03 9.33,15.33C9.4,14.62 9.63,13.94 10,13.33C10.37,12.5 10.81,11.73 11.33,11L12,10C13.79,12.59 14.67,14.36 14.67,15.33`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Normal`:`Error`})),r===123&&i.filter(e=>e.clusterName===`BridgedDeviceBasicInformation`&&e.attributeName===`reachable`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(Xe,{}),cluster:e,value:`Oven`})),r===112&&i.filter(e=>e.clusterName===`BridgedDeviceBasicInformation`&&e.attributeName===`reachable`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(Ue,{}),cluster:e,value:`Fridge`})),r===113&&i.filter(e=>e.clusterName===`TemperatureControl`&&e.attributeName===`selectedTemperatureLevel`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M5,3A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3H5M12,5C13.57,5 15,5.5 16.19,6.4L14,8.56C13.43,8.21 12.74,8 12,8A4,4 0 0,0 8,12C8,13.1 8.45,14.1 9.17,14.83L7.05,16.95C5.78,15.68 5,13.93 5,12A7,7 0 0,1 12,5M17.6,7.81C18.5,9 19,10.43 19,12C19,13.93 18.22,15.68 16.95,16.95L14.83,14.83C15.55,14.1 16,13.1 16,12C16,11.26 15.79,10.57 15.43,10L17.6,7.81Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue,unit:`mode`,prefix:!0})),r===121&&i.filter(e=>e.clusterName===`OperationalState`&&e.attributeName===`operationalState`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(Xe,{}),cluster:e,value:e.attributeLocalValue===0?`Normal`:`Error`})),r===122&&i.filter(e=>e.clusterName===`FanControl`&&e.attributeName===`fanMode`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M19,18.31V20A2,2 0 0,1 17,22H7A2,2 0 0,1 5,20V16.3C4.54,16.12 3.95,16 3,16A1,1 0 0,1 2,15A1,1 0 0,1 3,14C3.82,14 4.47,14.08 5,14.21V12.3C4.54,12.12 3.95,12 3,12A1,1 0 0,1 2,11A1,1 0 0,1 3,10C3.82,10 4.47,10.08 5,10.21V8.3C4.54,8.12 3.95,8 3,8A1,1 0 0,1 2,7A1,1 0 0,1 3,6C3.82,6 4.47,6.08 5,6.21V4A2,2 0 0,1 7,2H17A2,2 0 0,1 19,4V6.16C20.78,6.47 21.54,7.13 21.71,7.29C22.1,7.68 22.1,8.32 21.71,8.71C21.32,9.1 20.8,9.09 20.29,8.71V8.71C20.29,8.71 19.25,8 17,8C15.74,8 14.91,8.41 13.95,8.9C12.91,9.41 11.74,10 10,10C9.64,10 9.31,10 9,9.96V7.95C9.3,8 9.63,8 10,8C11.26,8 12.09,7.59 13.05,7.11C14.09,6.59 15.27,6 17,6V4H7V20H17V18C18.5,18 18.97,18.29 19,18.31M17,10C15.27,10 14.09,10.59 13.05,11.11C12.09,11.59 11.26,12 10,12C9.63,12 9.3,12 9,11.95V13.96C9.31,14 9.64,14 10,14C11.74,14 12.91,13.41 13.95,12.9C14.91,12.42 15.74,12 17,12C19.25,12 20.29,12.71 20.29,12.71V12.71C20.8,13.1 21.32,13.1 21.71,12.71C22.1,12.32 22.1,11.69 21.71,11.29C21.5,11.08 20.25,10 17,10M17,14C15.27,14 14.09,14.59 13.05,15.11C12.09,15.59 11.26,16 10,16C9.63,16 9.3,16 9,15.95V17.96C9.31,18 9.64,18 10,18C11.74,18 12.91,17.41 13.95,16.9C14.91,16.42 15.74,16 17,16C19.25,16 20.29,16.71 20.29,16.71V16.71C20.8,17.1 21.32,17.1 21.71,16.71C22.1,16.32 22.1,15.69 21.71,15.29C21.5,15.08 20.25,14 17,14Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue,unit:`mode`,prefix:!0})),r===120&&i.filter(e=>e.clusterName===`BridgedDeviceBasicInformation`&&e.attributeName===`reachable`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M6,14H8L11,17H9L6,14M4,4H5V3A1,1 0 0,1 6,2H10A1,1 0 0,1 11,3V4H13V3A1,1 0 0,1 14,2H18A1,1 0 0,1 19,3V4H20A2,2 0 0,1 22,6V19A2,2 0 0,1 20,21V22H17V21H7V22H4V21A2,2 0 0,1 2,19V6A2,2 0 0,1 4,4M18,7A1,1 0 0,1 19,8A1,1 0 0,1 18,9A1,1 0 0,1 17,8A1,1 0 0,1 18,7M14,7A1,1 0 0,1 15,8A1,1 0 0,1 14,9A1,1 0 0,1 13,8A1,1 0 0,1 14,7M20,6H4V10H20V6M4,19H20V12H4V19M6,7A1,1 0 0,1 7,8A1,1 0 0,1 6,9A1,1 0 0,1 5,8A1,1 0 0,1 6,7M13,14H15L18,17H16L13,14Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`Cooktop`})),r===119&&i.filter(e=>e.clusterName===`TemperatureControl`&&e.attributeName===`selectedTemperatureLevel`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M6,14H8L11,17H9L6,14M4,4H5V3A1,1 0 0,1 6,2H10A1,1 0 0,1 11,3V4H13V3A1,1 0 0,1 14,2H18A1,1 0 0,1 19,3V4H20A2,2 0 0,1 22,6V19A2,2 0 0,1 20,21V22H17V21H7V22H4V21A2,2 0 0,1 2,19V6A2,2 0 0,1 4,4M18,7A1,1 0 0,1 19,8A1,1 0 0,1 18,9A1,1 0 0,1 17,8A1,1 0 0,1 18,7M14,7A1,1 0 0,1 15,8A1,1 0 0,1 14,9A1,1 0 0,1 13,8A1,1 0 0,1 14,7M20,6H4V10H20V6M4,19H20V12H4V19M6,7A1,1 0 0,1 7,8A1,1 0 0,1 6,9A1,1 0 0,1 5,8A1,1 0 0,1 6,7M13,14H15L18,17H16L13,14Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue,unit:`mode`,prefix:!0})),r===514&&i.filter(e=>e.clusterName===`WindowCovering`&&e.attributeName===`currentPositionLiftPercent100ths`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(ct,{}),cluster:e,value:e.attributeLocalValue/100,unit:`%`})),r===769&&i.filter(e=>e.clusterName===`Thermostat`&&e.attributeName===`localTemperature`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M16.95,16.95L14.83,14.83C15.55,14.1 16,13.1 16,12C16,11.26 15.79,10.57 15.43,10L17.6,7.81C18.5,9 19,10.43 19,12C19,13.93 18.22,15.68 16.95,16.95M12,5C13.57,5 15,5.5 16.19,6.4L14,8.56C13.43,8.21 12.74,8 12,8A4,4 0 0,0 8,12C8,13.1 8.45,14.1 9.17,14.83L7.05,16.95C5.78,15.68 5,13.93 5,12A7,7 0 0,1 12,5M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:(e.attributeLocalValue??0)/100,unit:`°C`})),r===10&&i.filter(e=>e.clusterName===`DoorLock`&&e.attributeName===`lockState`).map(e=>(0,G.jsx)(Z,{icon:e.attributeValue===`1`?(0,G.jsx)(ve,{}):(0,G.jsx)(De,{}),cluster:e,value:e.attributeValue===`1`?`Locked`:`Unlocked`})),r===43&&i.filter(e=>e.clusterName===`FanControl`&&e.attributeName===`percentCurrent`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(ze,{}),cluster:e,value:e.attributeValue,unit:`%`})),r===15&&i.filter(e=>e.clusterName===`Switch`&&e.attributeName===`currentPosition`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M13 5C15.21 5 17 6.79 17 9C17 10.5 16.2 11.77 15 12.46V11.24C15.61 10.69 16 9.89 16 9C16 7.34 14.66 6 13 6S10 7.34 10 9C10 9.89 10.39 10.69 11 11.24V12.46C9.8 11.77 9 10.5 9 9C9 6.79 10.79 5 13 5M20 20.5C19.97 21.32 19.32 21.97 18.5 22H13C12.62 22 12.26 21.85 12 21.57L8 17.37L8.74 16.6C8.93 16.39 9.2 16.28 9.5 16.28H9.7L12 18V9C12 8.45 12.45 8 13 8S14 8.45 14 9V13.47L15.21 13.6L19.15 15.79C19.68 16.03 20 16.56 20 17.14V20.5M20 2H4C2.9 2 2 2.9 2 4V12C2 13.11 2.9 14 4 14H8V12L4 12L4 4H20L20 12H18V14H20V13.96L20.04 14C21.13 14 22 13.09 22 12V4C22 2.9 21.11 2 20 2Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeValue,unit:`pos`,prefix:!0})),r===39&&i.filter(e=>e.clusterName===`ModeSelect`&&e.attributeName===`currentMode`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(Se,{}),cluster:e,value:e.attributeValue,unit:`Mode`,prefix:!0})),r===771&&i.filter(e=>e.clusterName===`OnOff`&&e.attributeName===`onOff`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(ke,{}),cluster:e,value:e.attributeLocalValue===!0?`On`:`Off`})),r===45&&i.filter(e=>e.clusterName===`FanControl`&&e.attributeName===`percentCurrent`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(Ge,{}),cluster:e,value:e.attributeValue,unit:`%`})),r===114&&i.filter(e=>e.clusterName===`Thermostat`&&e.attributeName===`localTemperature`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(Ge,{}),cluster:e,value:(e.attributeLocalValue??0)/100,unit:`°C`})),r===67&&i.filter(e=>e.clusterName===`BooleanState`&&e.attributeName===`stateValue`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(et,{}),cluster:e,value:e.attributeLocalValue===!0?`Leak`:`No leak`})),r===65&&i.filter(e=>e.clusterName===`BooleanState`&&e.attributeName===`stateValue`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(Ee,{}),cluster:e,value:e.attributeLocalValue===!0?`Freeze`:`No freeze`})),r===68&&i.filter(e=>e.clusterName===`BooleanState`&&e.attributeName===`stateValue`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(we,{}),cluster:e,value:e.attributeLocalValue===!0?`Rain`:`No rain`})),r===116&&i.filter(e=>e.clusterName===`RvcRunMode`&&e.attributeName===`currentMode`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M12,2C14.65,2 17.19,3.06 19.07,4.93L17.65,6.35C16.15,4.85 14.12,4 12,4C9.88,4 7.84,4.84 6.35,6.35L4.93,4.93C6.81,3.06 9.35,2 12,2M3.66,6.5L5.11,7.94C4.39,9.17 4,10.57 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12C20,10.57 19.61,9.17 18.88,7.94L20.34,6.5C21.42,8.12 22,10.04 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12C2,10.04 2.58,8.12 3.66,6.5M12,6A6,6 0 0,1 18,12C18,13.59 17.37,15.12 16.24,16.24L14.83,14.83C14.08,15.58 13.06,16 12,16C10.94,16 9.92,15.58 9.17,14.83L7.76,16.24C6.63,15.12 6,13.59 6,12A6,6 0 0,1 12,6M12,8A1,1 0 0,0 11,9A1,1 0 0,0 12,10A1,1 0 0,0 13,9A1,1 0 0,0 12,8Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeValue,unit:`Run mode`,prefix:!0})),r===1292&&i.filter(e=>e.clusterName===`EnergyEvse`&&e.attributeName===`state`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M19.77,7.23L19.78,7.22L16.06,3.5L15,4.56L17.11,6.67C16.17,7.03 15.5,7.93 15.5,9A2.5,2.5 0 0,0 18,11.5C18.36,11.5 18.69,11.42 19,11.29V18.5A1,1 0 0,1 18,19.5A1,1 0 0,1 17,18.5V14A2,2 0 0,0 15,12H14V5A2,2 0 0,0 12,3H6A2,2 0 0,0 4,5V21H14V13.5H15.5V18.5A2.5,2.5 0 0,0 18,21A2.5,2.5 0 0,0 20.5,18.5V9C20.5,8.31 20.22,7.68 19.77,7.23M18,10A1,1 0 0,1 17,9A1,1 0 0,1 18,8A1,1 0 0,1 19,9A1,1 0 0,1 18,10M8,18V13.5H6L10,6V11H12L8,18Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`Free`:`In use`})),r===1295&&i.filter(e=>e.clusterName===`WaterHeaterManagement`&&e.attributeName===`tankPercentage`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M8 2C6.89 2 6 2.89 6 4V16C6 17.11 6.89 18 8 18H9V20H6V22H9C10.11 22 11 21.11 11 20V18H13V20C13 21.11 13.89 22 15 22H18V20H15V18H16C17.11 18 18 17.11 18 16V4C18 2.89 17.11 2 16 2H8M12 4.97A2 2 0 0 1 14 6.97A2 2 0 0 1 12 8.97A2 2 0 0 1 10 6.97A2 2 0 0 1 12 4.97M10 14.5H14V16H10V14.5Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`Tank `+(e.attributeLocalValue??0)+`%`})),r===777&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`featureMap`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3M12.75 7.08C13.57 7.2 14.32 7.5 14.95 8L12.75 10.19V7.08M11.25 7.08V10.19L9.05 8C9.68 7.5 10.43 7.2 11.25 7.08M8 9.05L10.19 11.25H7.08C7.2 10.43 7.5 9.68 8 9.05M7.08 12.75H10.19L8 14.95C7.5 14.32 7.2 13.57 7.08 12.75M11.25 16.92C10.43 16.8 9.68 16.5 9.05 16L11.25 13.81V16.92M12 13C11.45 13 11 12.55 11 12S11.45 11 12 11 13 11.45 13 12 12.55 13 12 13M12.75 16.92V13.81L14.95 16C14.32 16.5 13.57 16.8 12.75 16.92M16 14.95L13.81 12.75H16.92C16.8 13.57 16.5 14.32 16 14.95M13.81 11.25L16 9.05C16.5 9.69 16.8 10.44 16.92 11.25H13.81Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`HeatPump`})),r===23&&i.filter(e=>e.clusterName===`PowerSource`&&e.attributeName===`featureMap`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M4,2H20A2,2 0 0,1 22,4V14A2,2 0 0,1 20,16H15V20H18V22H13V16H11V22H6V20H9V16H4A2,2 0 0,1 2,14V4A2,2 0 0,1 4,2M4,4V8H11V4H4M4,14H11V10H4V14M20,14V10H13V14H20M20,4H13V8H20V4Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`Solar`})),r===24&&i.filter(e=>e.clusterName===`ElectricalPowerMeasurement`&&e.attributeName===`featureMap`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M12 20L5 20V12H2L12 3L14.78 5.5H14V7.17C12.84 7.58 12 8.7 12 10V20M15 9H16V7.5H20V9H21C21.55 9 22 9.45 22 10V21C22 21.55 21.55 22 21 22H15C14.45 22 14 21.55 14 21V10C14 9.45 14.45 9 15 9M16 11V14H20V11H16Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:`Inverter`})),r===118&&i.find(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`featureMap`&&e.attributeLocalValue.smokeAlarm===!0)&&i.filter(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`smokeState`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M12 4C16.41 4 20 7.59 20 12S16.41 20 12 20 4 16.41 4 12 7.59 4 12 4M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 11C11.45 11 11 11.45 11 12S11.45 13 12 13 13 12.55 13 12 12.55 11 12 11M10.72 9.3C11.11 9.11 11.54 9 12 9S12.89 9.11 13.29 9.3L14 8.57C13.43 8.22 12.74 8 12 8S10.58 8.22 10 8.57L10.72 9.3M15 12C15 12.46 14.89 12.89 14.7 13.29L15.43 14C15.79 13.43 16 12.74 16 12S15.79 10.58 15.43 10L14.7 10.72C14.89 11.11 15 11.54 15 12M9 12C9 11.54 9.11 11.11 9.3 10.72L8.57 10C8.22 10.58 8 11.26 8 12S8.22 13.43 8.57 14L9.3 13.29C9.11 12.89 9 12.46 9 12M13.29 14.7C12.89 14.89 12.46 15 12 15S11.11 14.89 10.72 14.7L10 15.43C10.58 15.79 11.26 16 12 16S13.43 15.79 14 15.43L13.29 14.7M16.89 8.53L16.17 9.25C16.69 10.04 17 11 17 12S16.69 13.96 16.17 14.75L16.89 15.47C17.59 14.5 18 13.3 18 12S17.59 9.5 16.89 8.53M9.25 7.83C10.04 7.31 11 7 12 7S13.96 7.31 14.75 7.83L15.47 7.11C14.5 6.42 13.3 6 12 6S9.5 6.42 8.53 7.11L9.25 7.83M14.75 16.17C13.96 16.69 13 17 12 17S10.04 16.69 9.25 16.17L8.53 16.89C9.5 17.59 10.7 18 12 18S14.5 17.59 15.47 16.89L14.75 16.17M7.83 14.75C7.31 13.96 7 13 7 12S7.31 10.04 7.83 9.25L7.11 8.53C6.42 9.5 6 10.7 6 12S6.42 14.5 7.11 15.47L7.83 14.75Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`No smoke`:`Smoke!`})),r===118&&i.find(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`featureMap`&&e.attributeLocalValue.smokeAlarm===!1)&&i.filter(e=>e.clusterName===`SmokeCoAlarm`&&e.attributeName===`coState`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M12 4C16.41 4 20 7.59 20 12S16.41 20 12 20 4 16.41 4 12 7.59 4 12 4M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 11C11.45 11 11 11.45 11 12S11.45 13 12 13 13 12.55 13 12 12.55 11 12 11M10.72 9.3C11.11 9.11 11.54 9 12 9S12.89 9.11 13.29 9.3L14 8.57C13.43 8.22 12.74 8 12 8S10.58 8.22 10 8.57L10.72 9.3M15 12C15 12.46 14.89 12.89 14.7 13.29L15.43 14C15.79 13.43 16 12.74 16 12S15.79 10.58 15.43 10L14.7 10.72C14.89 11.11 15 11.54 15 12M9 12C9 11.54 9.11 11.11 9.3 10.72L8.57 10C8.22 10.58 8 11.26 8 12S8.22 13.43 8.57 14L9.3 13.29C9.11 12.89 9 12.46 9 12M13.29 14.7C12.89 14.89 12.46 15 12 15S11.11 14.89 10.72 14.7L10 15.43C10.58 15.79 11.26 16 12 16S13.43 15.79 14 15.43L13.29 14.7M16.89 8.53L16.17 9.25C16.69 10.04 17 11 17 12S16.69 13.96 16.17 14.75L16.89 15.47C17.59 14.5 18 13.3 18 12S17.59 9.5 16.89 8.53M9.25 7.83C10.04 7.31 11 7 12 7S13.96 7.31 14.75 7.83L15.47 7.11C14.5 6.42 13.3 6 12 6S9.5 6.42 8.53 7.11L9.25 7.83M14.75 16.17C13.96 16.69 13 17 12 17S10.04 16.69 9.25 16.17L8.53 16.89C9.5 17.59 10.7 18 12 18S14.5 17.59 15.47 16.89L14.75 16.17M7.83 14.75C7.31 13.96 7 13 7 12S7.31 10.04 7.83 9.25L7.11 8.53C6.42 9.5 6 10.7 6 12S6.42 14.5 7.11 15.47L7.83 14.75Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue===0?`No Co`:`Co!`})),r===66&&i.filter(e=>e.clusterName===`ValveConfigurationAndControl`&&e.attributeName===`currentState`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(Le,{}),cluster:e,value:e.attributeLocalValue===0?`Closed`:`Opened`})),r===44&&i.filter(e=>e.clusterName===`AirQuality`&&e.attributeName===`airQuality`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M11,9A4,4 0 0,1 15,13A4,4 0 0,1 11,17A4,4 0 0,1 7,13A4,4 0 0,1 11,9M11,11A2,2 0 0,0 9,13A2,2 0 0,0 11,15A2,2 0 0,0 13,13A2,2 0 0,0 11,11M7,4H14A4,4 0 0,1 18,8V9H16V8A2,2 0 0,0 14,6H7A2,2 0 0,0 5,8V20H16V18H18V22H3V8A4,4 0 0,1 7,4M16,11C18.5,11 18.5,9 21,9V11C18.5,11 18.5,13 16,13V11M16,15C18.5,15 18.5,13 21,13V15C18.5,15 18.5,17 16,17V15Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:a[e.attributeLocalValue??0]})),r===770&&i.filter(e=>e.clusterName===`TemperatureMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(se,{}),cluster:e,value:e.attributeLocalValue/100,unit:`°C`})),r===775&&i.filter(e=>e.clusterName===`RelativeHumidityMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(J.Icon,{path:`M12,3.25C12,3.25 6,10 6,14C6,17.32 8.69,20 12,20A6,6 0 0,0 18,14C18,10 12,3.25 12,3.25M14.47,9.97L15.53,11.03L9.53,17.03L8.47,15.97M9.75,10A1.25,1.25 0 0,1 11,11.25A1.25,1.25 0 0,1 9.75,12.5A1.25,1.25 0 0,1 8.5,11.25A1.25,1.25 0 0,1 9.75,10M14.25,14.5A1.25,1.25 0 0,1 15.5,15.75A1.25,1.25 0 0,1 14.25,17A1.25,1.25 0 0,1 13,15.75A1.25,1.25 0 0,1 14.25,14.5Z`,size:`40px`,color:`var(--primary-color)`}),cluster:e,value:e.attributeLocalValue/100,unit:`%`})),r===774&&i.filter(e=>e.clusterName===`FlowMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(ot,{}),cluster:e,value:e.attributeLocalValue,unit:`l/h`})),r===773&&i.filter(e=>e.clusterName===`PressureMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(m,{}),cluster:e,value:e.attributeLocalValue,unit:`hPa`})),r===21&&i.filter(e=>e.clusterName===`BooleanState`&&e.attributeName===`stateValue`).map(e=>(0,G.jsx)(Z,{icon:e.attributeValue===`true`?(0,G.jsx)(g,{}):(0,G.jsx)(te,{}),cluster:e,value:e.attributeValue===`true`?`Closed`:`Opened`})),r===263&&i.filter(e=>e.clusterName===`OccupancySensing`&&e.attributeName===`occupancy`).map(e=>(0,G.jsx)(Z,{icon:e.attributeValue===`{ occupied: true }`?(0,G.jsx)(v,{}):(0,G.jsx)(le,{}),cluster:e,value:e.attributeValue===`{ occupied: true }`?`Occupied`:`Unocc.`})),r===262&&i.filter(e=>e.clusterName===`IlluminanceMeasurement`&&e.attributeName===`measuredValue`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(it,{}),cluster:e,value:Math.round(10**(e.attributeLocalValue/1e4)),unit:`lx`})),r===1296&&i.filter(e=>e.clusterName===`ElectricalEnergyMeasurement`&&e.attributeName===`cumulativeEnergyImported`).map(e=>(0,G.jsx)(Z,{icon:(0,G.jsx)(nt,{}),cluster:e,value:Math.round(e.attributeLocalValue?.energy/1e6),unit:`kwh`})),(0,G.jsx)(F,{sx:ur,children:(0,G.jsx)(U,{sx:dr,children:o})}),(0,G.jsx)(F,{sx:fr,children:(0,G.jsx)(U,{sx:pr,children:e.name})}),(0,G.jsxs)(F,{sx:mr,children:[Q&&(0,G.jsx)(U,{sx:hr,children:t}),(0,G.jsx)(U,{sx:hr,children:n}),Q&&(0,G.jsxs)(U,{sx:hr,children:[`0x`,r.toString(16).padStart(4,`0`)]})]})]})}function xr({filterPlugins:e,filterDevices:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,W.useContext)(q),[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=>{(Q||ar)&&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||ar)&&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||ar)&&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||ar)&&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(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,W.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,W.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,W.memo)(br),y=e?.trim().toLowerCase(),b=y&&y!==`all plugins`;return Q&&console.log(`DevicesIcons rendering...`),(0,G.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,G.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 Sr=(0,W.memo)(xr),Cr=[{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,G.jsx)(I,{onClick:()=>window.open(n.configUrl,`_blank`),"aria-label":`Open Config`,sx:{margin:0,padding:0},children:(0,G.jsx)(oe,{fontSize:`small`})}):null},{label:`Cluster`,id:`cluster`}],wr=[{label:`Endpoint`,id:`endpoint`,required:!0},{label:`Id`,id:`id`},{label:`Device Types`,id:`deviceTypes`,render:(e,t,n,r)=>Array.isArray(e)?(0,G.jsx)(G.Fragment,{children:e.map(e=>`0x${e.toString(16).padStart(4,`0`)}`).join(`, `)}):(0,G.jsx)(G.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}],Tr=e=>`${e.pluginName}::${e.uniqueId}`,Er=e=>`${e.endpoint}::${e.clusterName}::${e.attributeName}`;function Dr({filterPlugins:e,filterDevices:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,W.useContext)(q),[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=>{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,W.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,W.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,W.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,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]),Q&&console.log(`DevicesTable rendering...`),n?(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,margin:`0px`,padding:`0px`,gap:`20px`,width:`100%`,overflow:`hidden`},children:[(0,G.jsx)(Y,{style:{margin:`0px`,padding:`0px`,gap:`0px`,width:`100%`,maxHeight:`${h&&_?`30%`:`100%`}`,flex:`1 1 auto`,overflow:`hidden`},children:(0,G.jsx)(sn,{name:`Registered devices`,getRowKey:Tr,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:Cr,footerLeft:`Total devices: ${l.length.toString()}`})}),h&&_&&(0,G.jsx)(Y,{style:{margin:`0px`,padding:`0px`,gap:`0px`,width:`100%`,height:`70%`,maxHeight:`70%`,flex:`1 1 auto`,overflow:`hidden`},children:(0,G.jsx)(sn,{name:`Clusters`,title:y||``,getRowKey:Er,rows:d,columns:wr,footerLeft:`Total child endpoints: ${p-1}`})})]}):(0,G.jsx)(Vt,{})}var Or=(0,W.memo)(Dr);function kr(){let{online:e,sendMessage:t,addListener:n,removeListener:r,getUniqueId:i}=(0,W.useContext)(q),[a,o]=(0,W.useState)([`All plugins`]),[s,c]=(0,W.useState)(`All plugins`),[l,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(`icon`),m=(0,W.useRef)(i());(0,W.useEffect)(()=>{let e=localStorage.getItem(K.devicesFilterPlugins);e&&c(e)},[]),(0,W.useEffect)(()=>{let e=localStorage.getItem(K.devicesFilterDevices);e&&d(e)},[]),(0,W.useEffect)(()=>{let e=localStorage.getItem(K.devicesViewMode);e&&p(e)},[]),(0,W.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,W.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=>{d(e.target.value),localStorage.setItem(K.devicesFilterDevices,e.target.value)},_=()=>{d(``),localStorage.removeItem(K.devicesFilterDevices)},v=e=>{p(e),localStorage.setItem(K.devicesViewMode,e)};return Q&&console.log(`Devices rendering...`),e?(0,G.jsxs)(Gn,{name:`Devices`,children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,padding:0,margin:0,gap:`20px`,width:`100%`},children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,padding:0,margin:0,gap:`20px`},children:[(0,G.jsxs)(F,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(U,{sx:{fontSize:`16px`,fontWeight:`normal`,color:`var(--div-text-color)`,marginLeft:`5px`,whiteSpace:`nowrap`},children:`Plugin:`}),(0,G.jsx)(V,{title:`Filter devices by plugin`,children:(0,G.jsx)(Ke,{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,G.jsx)(Oe,{sx:{backgroundColor:`var(--main-bg-color)`}}),children:a.map(e=>(0,G.jsx)(R,{value:e,children:e},e))})})]}),(0,G.jsxs)(F,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(U,{sx:{fontSize:`16px`,fontWeight:`normal`,color:`var(--div-text-color)`,marginLeft:`5px`,whiteSpace:`nowrap`},children:`Filter by:`}),(0,G.jsx)(V,{title:`Filter devices by name or serial number`,children:(0,G.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,G.jsx)(ue,{position:`end`,children:(0,G.jsx)(I,{"aria-label":`Clear device filter`,size:`small`,onClick:_,edge:`end`,children:(0,G.jsx)(u,{sx:{fontSize:18,color:`var(--main-label-color)`}})})}):null}}})})]})]}),(0,G.jsxs)(F,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(U,{sx:{fontSize:`16px`,fontWeight:`normal`,color:`var(--div-text-color)`,marginLeft:`5px`,whiteSpace:`nowrap`},children:`View mode:`}),(0,G.jsx)(I,{onClick:()=>v(`table`),"aria-label":`Table View`,disabled:f===`table`,children:(0,G.jsx)(V,{title:`Table View`,children:(0,G.jsx)(ee,{style:{color:f===`table`?`var(--main-icon-color)`:`var(--primary-color)`}})})}),(0,G.jsx)(I,{onClick:()=>v(`icon`),"aria-label":`Icon View`,disabled:f===`icon`,children:(0,G.jsx)(V,{title:`Icon View (beta)`,children:(0,G.jsx)(Ne,{style:{color:f===`icon`?`var(--main-icon-color)`:`var(--primary-color)`}})})})]})]}),f===`table`&&(0,G.jsx)(Or,{filterPlugins:s,filterDevices:l}),f===`icon`&&(0,G.jsx)(Sr,{filterPlugins:s,filterDevices:l})]}):(0,G.jsx)(Vt,{})}var Ar=(0,W.memo)(kr);function jr(){let{logLength:e,logAutoScroll:t,setMessages:n,setLogFilterLevel:r,setLogFilterSearch:i,online:a,filterLogMessages:o}=(0,W.useContext)(q),[s,c]=(0,W.useState)(localStorage.getItem(K.logFilterLevel)??`info`),[l,u]=(0,W.useState)(localStorage.getItem(K.logFilterSearch)??`*`),[d,f]=(0,W.useState)(e.current.toString()),[p,m]=(0,W.useState)(t.current);return Q&&console.log(`Logs rendering...`),a?(0,G.jsxs)(Gn,{name:`Logs`,children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`,margin:`0px`,padding:`0px`,gap:`10px`},children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(at,{id:`select-level`,style:{color:`var(--div-text-color)`},children:`Filter log by level:`}),(0,G.jsxs)(Ke,{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,G.jsx)(R,{value:`debug`,children:`Debug`}),(0,G.jsx)(R,{value:`info`,children:`Info`}),(0,G.jsx)(R,{value:`notice`,children:`Notice`}),(0,G.jsx)(R,{value:`warn`,children:`Warn`}),(0,G.jsx)(R,{value:`error`,children:`Error`}),(0,G.jsx)(R,{value:`fatal`,children:`Fatal`})]})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`5px`},children:[(0,G.jsx)(at,{id:`search`,style:{color:`var(--div-text-color)`},children:`Filter log by text:`}),(0,G.jsx)(V,{title:`Use /text/ for case-insensitive regex search`,children:(0,G.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,G.jsx)(Ie,{control:(0,G.jsx)(D,{checked:p,onChange:e=>{let n=e.target.checked;m(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,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(at,{id:`select-size-label`,style:{color:`var(--div-text-color)`},children:`Log length:`}),(0,G.jsxs)(Ke,{style:{height:`30px`,backgroundColor:`var(--main-bg-color)`},labelId:`select-size-label`,id:`select-size`,value:d,onChange:t=>{let n=t.target.value;f(n),e.current=Number(n),localStorage.setItem(K.logLength,n),Q&&console.log(`handleLogLengthChange called with value:`,n)},children:[(0,G.jsx)(R,{value:100,children:`100`}),(0,G.jsx)(R,{value:200,children:`200`}),(0,G.jsx)(R,{value:500,children:`500`}),(0,G.jsx)(R,{value:1e3,children:`1000`})]}),(0,G.jsx)(V,{title:`Clear the logs`,children:(0,G.jsx)(j,{onClick:()=>{Q&&console.log(`handleClearLogsClick called`),n([])},endIcon:(0,G.jsx)(O,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Clear`})})]})]}),(0,G.jsx)(`div`,{style:{flex:`1`,overflow:`auto`,margin:`0px`,padding:`0px`},children:(0,G.jsx)(Jn,{})})]}):(0,G.jsx)(Vt,{})}var Mr=(0,W.memo)(jr),Nr=({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,G.jsxs)(x,{open:e,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||n()},maxWidth:`sm`,style:{maxWidth:`550px`,margin:`auto`},children:[(0,G.jsx)(M,{gap:`20px`,children:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,G.jsx)(`h4`,{style:{margin:0},children:`Network Configuration`})]})}),(0,G.jsxs)(P,{dividers:!0,children:[(0,G.jsxs)(d,{component:`fieldset`,fullWidth:!0,children:[(0,G.jsx)(_,{component:`legend`,children:`Select IP Configuration`}),(0,G.jsxs)(Be,{row:!0,value:a,onChange:e=>o(e.target.value),children:[(0,G.jsx)(Ie,{value:`dhcp`,control:(0,G.jsx)(Ae,{}),label:`DHCP`}),(0,G.jsx)(Ie,{value:`static`,control:(0,G.jsx)(Ae,{}),label:`Static`})]})]}),a===`static`&&(0,G.jsxs)(y,{container:!0,spacing:2,sx:{mt:2},children:[(0,G.jsx)(y,{size:6,children:(0,G.jsx)(B,{label:`IP Address`,fullWidth:!0,value:s.ip,onChange:l(`ip`)})}),(0,G.jsx)(y,{size:6,children:(0,G.jsx)(B,{label:`Subnet Mask`,fullWidth:!0,value:s.subnet,onChange:l(`subnet`)})}),(0,G.jsx)(y,{size:6,children:(0,G.jsx)(B,{label:`Gateway`,fullWidth:!0,value:s.gateway,onChange:l(`gateway`)})}),(0,G.jsx)(y,{size:6,children:(0,G.jsx)(B,{label:`DNS Server`,fullWidth:!0,value:s.dns,onChange:l(`dns`)})})]})]}),(0,G.jsxs)(ie,{children:[(0,G.jsx)(j,{onClick:()=>{n()},children:`Cancel`}),(0,G.jsx)(j,{variant:`contained`,onClick:()=>{r({type:a,...s}),n()},children:`Save`})]})]})},Pr=({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,G.jsxs)(x,{open:e,onClose:(e,n)=>{n===`backdropClick`||n===`escapeKeyDown`||t()},maxWidth:`sm`,style:{maxWidth:`500px`,margin:`auto`},disableEscapeKeyDown:!0,children:[(0,G.jsx)(M,{children:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,G.jsx)(`h4`,{style:{margin:0},children:`Change Password`})]})}),(0,G.jsx)(P,{dividers:!0,children:(0,G.jsx)(d,{component:`fieldset`,fullWidth:!0,sx:{margin:0,padding:0,gap:`20px`},children:(0,G.jsxs)(y,{container:!0,spacing:2,sx:{mt:2},children:[(0,G.jsx)(y,{size:12,children:(0,G.jsx)(B,{type:`password`,autoComplete:`new-password`,label:`New Password`,size:`small`,variant:`outlined`,fullWidth:!0,value:r,onChange:s})}),(0,G.jsx)(y,{size:12,children:(0,G.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,G.jsxs)(ie,{children:[(0,G.jsx)(j,{onClick:()=>{t()},children:`Cancel`}),(0,G.jsx)(j,{variant:`contained`,onClick:()=>{l&&(n(r),t())},disabled:!l,children:`Change`}),(0,G.jsx)(j,{variant:`contained`,onClick:()=>{n(``),t()},children:`Reset`})]})]})};function Fr(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 Ir=330;function Lr(){let{mobile:e}=(0,W.useContext)(It),{online:t,addListener:n,removeListener:r,sendMessage:i,getUniqueId:a}=(0,W.useContext)(q),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(null),u=(0,W.useRef)(a());return(0,W.useEffect)(()=>{let e=e=>{Q&&console.log(`Settings received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`settings`?(Q&&console.log(`Settings received refresh_required: changed=${e.response.changed} and sending /api/settings request`),i({id:u.current,sender:`Settings`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`/api/settings`&&(Q&&console.log(`Settings received /api/settings:`,e.response),s(e.response.matterbridgeInformation),l(e.response.systemInformation))};return n(e,u.current),Q&&console.log(`Settings added WebSocket listener`),()=>{r(e),Q&&console.log(`Settings removed WebSocket listener`)}},[n,r,i]),(0,W.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,G.jsx)(Vt,{}):(0,G.jsx)(Gn,{name:`Settings`,children:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:$&&e?`10px`:`20px`},children:[(0,G.jsx)(Rr,{matterbridgeInfo:o,systemInfo:c}),(0,G.jsx)(zr,{matterbridgeInfo:o}),(0,G.jsx)(Br,{matterbridgeInfo:o}),(0,G.jsx)(Vr,{systemInfo:c})]})})}function Rr({matterbridgeInfo:e,systemInfo:t}){let{sendMessage:n,getUniqueId:r}=(0,W.useContext)(q),[i,a]=(0,W.useState)(`bridge`),[o,s]=(0,W.useState)(`Info`),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(`dark`),[f,p]=(0,W.useState)(localStorage.getItem(K.homePagePlugins)!==`false`),[m,h]=(0,W.useState)(localStorage.getItem(K.homePageMode)??`devices`),[g,v]=(0,W.useState)(localStorage.getItem(K.virtualMode)??`outlet`),y=(0,W.useRef)(r()),[b,x]=(0,W.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,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(K.frontendTheme);e&&d(e)},[]),!e||!t?null:(0,G.jsxs)(Y,{style:{flex:`1 1 ${Ir}px`},children:[(0,G.jsx)(Ut,{children:(0,G.jsx)(X,{children:`Matterbridge settings`})}),(0,G.jsx)(Nr,{open:b,ip:t.ipv4Address,onClose:S,onSave:C}),(0,G.jsx)(Pr,{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}}),ai(e)}}),(0,G.jsxs)(qt,{style:{flexDirection:`column`,padding:`10px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`},children:[(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`matterbridgeInfo-mode`,children:`Mode:`}),(0,G.jsxs)(Be,{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,G.jsx)(Ie,{value:`bridge`,control:(0,G.jsx)(Ae,{}),label:`Bridge`,disabled:e.readOnly===!0}),(0,G.jsx)(Ie,{value:`childbridge`,control:(0,G.jsx)(Ae,{}),label:`Childbridge`,disabled:e.readOnly===!0})]})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`mblogger-level-label`,children:`Logger level:`}),(0,G.jsxs)(Ke,{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,G.jsx)(R,{value:`Debug`,children:`Debug`}),(0,G.jsx)(R,{value:`Info`,children:`Info`}),(0,G.jsx)(R,{value:`Notice`,children:`Notice`}),(0,G.jsx)(R,{value:`Warn`,children:`Warn`}),(0,G.jsx)(R,{value:`Error`,children:`Error`}),(0,G.jsx)(R,{value:`Fatal`,children:`Fatal`})]})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`mblogger-file-label`,children:`Log on file:`}),(0,G.jsx)(D,{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,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`frontend-theme-label`,children:`Frontend theme:`}),(0,G.jsxs)(Ke,{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),d(t),localStorage.setItem(K.frontendTheme,t),document.body.setAttribute(`frontend-theme`,t)},children:[(0,G.jsx)(R,{value:`classic`,children:`Classic`}),(0,G.jsx)(R,{value:`light`,children:`Light`}),(0,G.jsx)(R,{value:`dark`,children:`Dark`})]})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`frontend-home-plugin-label`,children:`Home page plugins:`}),(0,G.jsx)(D,{checked:f,onChange:e=>{let t=e.target.checked;Q&&console.log(`handleChangeHomePagePlugins called with value:`,t),p(t),localStorage.setItem(K.homePagePlugins,t?`true`:`false`)},name:`showPlugins`})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`frontend-home-label`,children:`Home page bottom panel:`}),(0,G.jsxs)(Ke,{style:{height:`30px`},labelId:`frontend-home-label`,id:`frontend-home`,value:m,onChange:e=>{let t=e.target.value;Q&&console.log(`handleChangeHomePageMode called with value:`,t),h(t),localStorage.setItem(K.homePageMode,t)},children:[(0,G.jsx)(R,{value:`logs`,children:`Logs`}),(0,G.jsx)(R,{value:`devices`,children:`Devices`})]})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`10px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`frontend-virtual-label`,children:`Virtual devices:`}),(0,G.jsxs)(Ke,{style:{height:`30px`},labelId:`frontend-virtual-label`,id:`frontend-virtual`,value:g,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,G.jsx)(R,{value:`disabled`,children:`Disabled`}),(0,G.jsx)(R,{value:`outlet`,children:`Outlet`}),(0,G.jsx)(R,{value:`light`,children:`Light`}),(0,G.jsx)(R,{value:`switch`,children:`Switch`}),(0,G.jsx)(R,{value:`mounted_switch`,children:`Mounted Switch`})]})]}),(0,G.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`20px`},children:(0,G.jsx)(j,{variant:`contained`,color:`primary`,onClick:()=>T(!0),children:`Change password`})}),e.shellyBoard&&(0,G.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`20px`},children:(0,G.jsx)(j,{variant:`contained`,color:`primary`,onClick:()=>x(!0),children:`Configure IP`})})]})]})}function zr({matterbridgeInfo:e}){let{sendMessage:t,getUniqueId:n}=(0,W.useContext)(q),[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,y]=(0,W.useState)(``),b=(0,W.useRef)(n()),x=(0,W.useMemo)(()=>Fr(1e3),[]),S=(0,W.useMemo)(()=>Fr(1e3),[]),C=(0,W.useMemo)(()=>Fr(1e3),[]),w=(0,W.useMemo)(()=>Fr(1e3),[]),T=(0,W.useMemo)(()=>Fr(1e3),[]),E=(0,W.useMemo)(()=>Fr(1e3),[]);return(0,W.useEffect)(()=>{e&&(i([`Debug`,`Info`,`Notice`,`Warn`,`Error`,`Fatal`][e.matterLoggerLevel]),o(e.matterFileLogger),c(e.matterMdnsInterface||``),u(e.matterIpv4Address||``),f(e.matterIpv6Address||``),m(e.matterPort?e.matterPort.toString():``),g(e.matterDiscriminator?e.matterDiscriminator.toString():``),y(e.matterPasscode?e.matterPasscode.toString():``))},[e]),(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]),(0,W.useEffect)(()=>()=>E.cancel(),[E]),e?(0,G.jsxs)(Y,{style:{flex:`1 1 ${Ir}px`},children:[(0,G.jsx)(Ut,{children:(0,G.jsx)(X,{children:`Matter settings`})}),(0,G.jsxs)(qt,{style:{flexDirection:`column`,padding:`10px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`},children:[(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`mjlogger-level-label`,children:`Logger level:`}),(0,G.jsxs)(Ke,{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:b.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmjloglevel`,value:e.target.value}})},children:[(0,G.jsx)(R,{value:`Debug`,children:`Debug`}),(0,G.jsx)(R,{value:`Info`,children:`Info`}),(0,G.jsx)(R,{value:`Notice`,children:`Notice`}),(0,G.jsx)(R,{value:`Warn`,children:`Warn`}),(0,G.jsx)(R,{value:`Error`,children:`Error`}),(0,G.jsx)(R,{value:`Fatal`,children:`Fatal`})]})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`10px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`},id:`mjlogger-file-label`,children:`Log on file:`}),(0,G.jsx)(D,{checked:a,onChange:e=>{Q&&console.log(`handleLogOnFileMjChange called with value:`,e.target.checked),o(e.target.checked),t({id:b.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmjlogfile`,value:e.target.checked}})},id:`mjlogger-file`,name:`logOnFileMj`})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Mdns interface:`}),(0,G.jsx)(B,{value:s,onChange:e=>{Q&&console.log(`handleChangeMdnsInterface called with value:`,e.target.value);let n=e.target.value;c(n),x(()=>{Q&&console.log(`debounced sendMessage setmdnsinterface with value:`,n),t({id:b.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmdnsinterface`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Ipv4 address:`}),(0,G.jsx)(B,{value:l,onChange:e=>{Q&&console.log(`handleChangeIpv4Address called with value:`,e.target.value);let n=e.target.value;u(n),S(()=>{Q&&console.log(`debounced sendMessage setipv4address with value:`,n),t({id:b.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setipv4address`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Ipv6 address:`}),(0,G.jsx)(B,{value:d,onChange:e=>{Q&&console.log(`handleChangeIpv6Address called with value:`,e.target.value);let n=e.target.value;f(n),C(()=>{Q&&console.log(`debounced sendMessage setipv6address with value:`,n),t({id:b.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setipv6address`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning port:`}),(0,G.jsx)(B,{value:p,onChange:e=>{Q&&console.log(`handleChangeMatterPort called with value:`,e.target.value);let n=e.target.value;m(n),w(()=>{Q&&console.log(`debounced sendMessage setmatterport with value:`,n),t({id:b.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterport`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning discriminator:`}),(0,G.jsx)(B,{value:h,onChange:e=>{Q&&console.log(`handleChangeMatterDiscriminator called with value:`,e.target.value);let n=e.target.value;g(n),T(()=>{Q&&console.log(`debounced sendMessage setmatterdiscriminator with value:`,n),t({id:b.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterdiscriminator`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,G.jsx)(_,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning passcode:`}),(0,G.jsx)(B,{value:v,onChange:e=>{Q&&console.log(`handleChangemMatterPasscode called with value:`,e.target.value);let n=e.target.value;y(n),E(()=>{Q&&console.log(`debounced sendMessage setmatterpasscode with value:`,n),t({id:b.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterpasscode`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly===!0,style:{height:`30px`,padding:`0`}}})]})]})]}):null}function Br({matterbridgeInfo:e}){return e?(0,G.jsxs)(Y,{style:{flex:`1 1 ${Ir}px`},children:[(0,G.jsx)(Ut,{children:(0,G.jsx)(X,{children:`Matterbridge info`})}),(0,G.jsxs)(qt,{style:{flexDirection:`column`,padding:`10px`,gap:`5px`},children:[(0,G.jsx)(Hr,{value:e.matterbridgeVersion,label:`Current Version`}),(0,G.jsx)(Hr,{value:e.matterbridgeLatestVersion,label:`Latest Version`}),(0,G.jsx)(Hr,{value:e.rootDirectory,label:`Root Directory`}),(0,G.jsx)(Hr,{value:e.homeDirectory,label:`Home Directory`}),(0,G.jsx)(Hr,{value:e.matterbridgeDirectory,label:`Matterbridge Storage Directory`}),(0,G.jsx)(Hr,{value:e.matterbridgePluginDirectory,label:`Matterbridge Plugin Directory`}),(0,G.jsx)(Hr,{value:e.globalModulesDirectory,label:`Global Module Directory`})]})]}):null}function Vr({systemInfo:e}){return e?(0,G.jsxs)(Y,{style:{flex:`1 1 ${Ir}px`},children:[(0,G.jsx)(Ut,{children:(0,G.jsx)(X,{children:`System info`})}),(0,G.jsxs)(qt,{style:{flexDirection:`column`,padding:`10px`,gap:`5px`},children:[(0,G.jsx)(Hr,{value:e.interfaceName,label:`Interface name`}),(0,G.jsx)(Hr,{value:e.macAddress,label:`MAC Address`}),(0,G.jsx)(Hr,{value:e.ipv4Address,label:`IPv4 Address`}),(0,G.jsx)(Hr,{value:e.ipv6Address,label:`IPv6 Address`}),(0,G.jsx)(Hr,{value:e.nodeVersion,label:`Node Version`}),(0,G.jsx)(Hr,{value:e.hostname,label:`Hostname`}),(0,G.jsx)(Hr,{value:e.user,label:`User`})]})]}):null}function Hr({value:e,label:t,width:n}){return(0,G.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 Ur=(0,W.memo)(Lr);function Wr(){let{online:e,sendMessage:t,addListener:n,removeListener:r,getUniqueId:i}=(0,W.useContext)(q),{showSnackbarMessage:a}=(0,W.useContext)(It),[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 Q&&console.log(`Test uniqueId:`,b),(0,W.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,W.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,G.jsx)(Gn,{name:`Test`,children:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,justifyContent:`center`,alignItems:`center`,alignContent:`center`,gap:`20px`,height:`100vh`,width:`100vw`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`256px`,width:`256px`,margin:`10px`}}),(0,G.jsx)(`p`,{children:`Welcome to the Test page of the Matterbridge frontend`})]})}):(0,G.jsx)(Vt,{})}var Gr=(0,W.memo)(Wr);function Kr(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 qr(e){return L({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 Jr(){let{mobile:e,showSnackbarMessage:t,showConfirmCancelDialog:n}=(0,W.useContext)(It),{online:i,sendMessage:a,logMessage:o,addListener:c,removeListener:l,getUniqueId:u}=(0,W.useContext)(q),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(!1),[y,b]=(0,W.useState)(null),x=(0,W.useRef)(u()),[S,C]=(0,W.useState)(null),[w,T]=(0,W.useState)(null),[E,D]=(0,W.useState)(null),[O,k]=(0,W.useState)(null),A=r(),j=()=>{window.open(`https://www.buymeacoffee.com/luligugithub`,`_blank`)},ee=()=>{window.open(`https://matterbridge.io/`)},M=()=>{window.open(`https://matterbridge.io/README.html`)},P=()=>{window.open(`https://matterbridge.io/CHANGELOG.html`)},te=()=>{window.open(`https://discord.gg/QX58CDe6hd`,`_blank`)},ne=()=>{window.open(`https://github.com/Luligu/matterbridge`,`_blank`)},re=()=>{a({id:x.current,sender:`Header`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:`matterbridge`,restart:!0}}),g(!1)},ie=()=>{a({id:x.current,sender:`Header`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:`matterbridge@dev`,restart:!0}}),v(!1)},ae=()=>{a({id:x.current,sender:`Header`,method:`/api/checkupdates`,src:`Frontend`,dst:`Matterbridge`,params:{}})},oe=()=>{Q&&console.log(`Header: handleShellySystemUpdateClick`),o(`Matterbridge`,`Installing system updates...`),a({id:x.current,sender:`Header`,method:`/api/shellysysupdate`,src:`Frontend`,dst:`Matterbridge`,params:{}})},F=()=>{Q&&console.log(`Header: handleShellyMainUpdateClick`),o(`Matterbridge`,`Installing software updates...`),a({id:x.current,sender:`Header`,method:`/api/shellymainupdate`,src:`Frontend`,dst:`Matterbridge`,params:{}})},se=()=>{Q&&console.log(`Header: handleShellyCreateSystemLog`),a({id:x.current,sender:`Header`,method:`/api/shellycreatesystemlog`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ce=()=>{Q&&console.log(`Header: handleShellyDownloadSystemLog`),o(`Matterbridge`,`Downloading Shelly system log...`),t(`Downloading Shelly system log...`,5),window.location.href=`./api/shellydownloadsystemlog`},le=()=>{y?.matterbridgeInformation.restartMode===``?a({id:x.current,sender:`Header`,method:`/api/restart`,src:`Frontend`,dst:`Matterbridge`,params:{}}):a({id:x.current,sender:`Header`,method:`/api/shutdown`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ue=()=>{a({id:x.current,sender:`Header`,method:`/api/shutdown`,src:`Frontend`,dst:`Matterbridge`,params:{}})},de=()=>{a({id:x.current,sender:`Header`,method:`/api/reboot`,src:`Frontend`,dst:`Matterbridge`,params:{}})},fe=()=>{a({id:x.current,sender:`Header`,method:`/api/softreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},pe=()=>{a({id:x.current,sender:`Header`,method:`/api/hardreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},me=e=>{C(e.currentTarget)},L=e=>{Q&&console.log(`Header: handleMenuClose`,e),C(null),e===`/`||e===`/devices`||e===`/log`||e===`/settings`?A(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:x.current,sender:`Header`,method:`/api/viewhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`download-history`?a({id:x.current,sender:`Header`,method:`/api/downloadhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`view-shellylog`?(o(`Matterbridge`,`Loading shelly system log...`),t(`Loading shelly system log...`,5),window.location.href=`./api/shellyviewsystemlog`):e===`download-mbstorage`?(o(`Matterbridge`,`Downloading matterbridge storage...`),t(`Downloading matterbridge storage...`,5),window.location.href=`./api/download-mbstorage`):e===`download-pluginstorage`?(o(`Matterbridge`,`Downloading matterbridge plugins storage...`),t(`Downloading matterbridge plugins storage...`,5),window.location.href=`./api/download-pluginstorage`):e===`download-pluginconfig`?(o(`Matterbridge`,`Downloading matterbridge plugins config...`),t(`Downloading matterbridge plugins config...`,5),window.location.href=`./api/download-pluginconfig`):e===`download-mjstorage`?(o(`Matterbridge`,`Downloading matter storage...`),t(`Downloading matter storage...`,5),window.location.href=`./api/download-mjstorage`):e===`download-backup`?(o(`Matterbridge`,`Downloading backup...`),t(`Downloading backup...`,10),window.location.href=`./api/download-backup`):e===`update`?re():e===`updatedev`?ie():e===`updatecheck`?ae():e===`shelly-sys-update`?oe():e===`shelly-main-update`?F():e===`shelly-create-system-log`?se():e===`shelly-download-system-log`?ce():e===`softreset`?fe():e===`hardreset`?pe():e===`restart`?le():e===`shutdown`?ue():e===`reboot`?de():e===`create-backup`?a({id:x.current,sender:`Header`,method:`/api/create-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-matterbridge-storage-backup`?a({id:x.current,sender:`Header`,method:`/api/create-matterbridge-storage-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-matter-storage-backup`?a({id:x.current,sender:`Header`,method:`/api/create-matter-storage-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-plugin-backup`?a({id:x.current,sender:`Header`,method:`/api/create-plugin-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-config-backup`?a({id:x.current,sender:`Header`,method:`/api/create-config-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`unregister`?a({id:x.current,sender:`Header`,method:`/api/unregister`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`reset`?a({id:x.current,sender:`Header`,method:`/api/reset`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`factoryreset`&&a({id:x.current,sender:`Header`,method:`/api/factoryreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},_e=e=>{Q&&console.log(`Header: handleMenuCloseCancel:`,e),C(null)},ve=e=>{T(e.currentTarget)},be=()=>{T(null)},xe=e=>{D(e.currentTarget)},Se=()=>{D(null)},Ce=e=>{k(e.currentTarget)},we=()=>{k(null)};return(0,W.useEffect)(()=>{let e=e=>{Q&&console.log(`Header received WebSocket Message:`,e),e.method===`/api/settings`&&e.id===x.current?(Q&&console.log(`Header received settings:`,e.response),b(e.response),f(e.response.matterbridgeInformation.restartRequired||e.response.matterbridgeInformation.fixedRestartRequired),m(e.response.matterbridgeInformation.fixedRestartRequired),g(e.response.matterbridgeInformation.updateRequired)):e.method===`refresh_required`&&e.response.changed===`settings`?(Q&&console.log(`Header received refresh_required: changed=${e.response.changed} and sending /api/settings request`),a({id:x.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`restart_required`?(Q&&console.log(`Header received restart_required with fixed: ${e.response.fixed}`),f(!0),e.response.fixed===!0&&m(!0)):e.method===`restart_not_required`?(Q&&console.log(`Header received restart_not_required`),f(!1)):e.method===`update_required`?(Q&&console.log(`Header received update_required`),e.response.devVersion===!0?v(!0):g(!0),a({id:x.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`shelly_sys_update`?(Q&&console.log(`Header received WS_ID_SHELLY_SYS_UPDATE:`),b(t=>t?{matterbridgeInformation:{...t.matterbridgeInformation,shellySysUpdate:e.response.available},systemInformation:t.systemInformation}:null)):e.method===`shelly_main_update`?(Q&&console.log(`Header received WS_ID_SHELLY_MAIN_UPDATE:`),b(t=>t?{matterbridgeInformation:{...t.matterbridgeInformation,shellyMainUpdate:e.response.available},systemInformation:t.systemInformation}:null)):e.method===`/api/viewhistorypage`&&e.id===x.current&&e.success===!0?(Q&&console.log(`Header received /api/viewhistorypage success`),window.open(`./api/viewhistory`,`_blank`,`noopener,noreferrer`)):e.method===`/api/downloadhistorypage`&&e.id===x.current&&e.success===!0?(Q&&console.log(`Header received /api/downloadhistorypage success`),window.location.href=`./api/downloadhistory`):e.method===`archive`&&e.success===!0&&e.response.command===`zip`&&(Q&&console.log(`Header received archive success response for zip command`,e.response),e.response.archivePath.endsWith(`matterbridge.backup.zip`)?window.location.href=`./api/download-backup`:e.response.archivePath.endsWith(`matterbridge.storage.zip`)?window.location.href=`./api/download-mbstorage`:e.response.archivePath.endsWith(`matterbridge.matterstorage.zip`)?window.location.href=`./api/download-mjstorage`:e.response.archivePath.endsWith(`matterbridge.pluginstorage.zip`)?window.location.href=`./api/download-pluginstorage`:e.response.archivePath.endsWith(`matterbridge.pluginconfig.zip`)&&(window.location.href=`./api/download-pluginconfig`))};return c(e,x.current),Q&&console.log(`Header added WebSocket listener id ${x.current}`),()=>{l(e),Q&&console.log(`Header removed WebSocket listener`)}},[c,l,a,t]),(0,W.useEffect)(()=>{i&&(Q&&console.log(`Header sending /api/settings and /api/checkupdates requests`),a({id:x.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),a({id:x.current,sender:`Header`,method:`/api/checkupdates`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[i,a]),Q&&console.log(`Header rendering... mobile %s`,e),!i||!y?null:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`,width:`100%`,gap:`10px`},children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`30px`},onClick:()=>{ti(),Q&&console.log(`Matterbridge logo clicked: debug is now`,Q)}}),(0,G.jsx)(`h2`,{style:{fontSize:`22px`,color:`var(--main-icon-color)`,margin:`0px`},children:`Matterbridge`})]}),(0,G.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:(0,G.jsxs)(`nav`,{children:[(0,G.jsx)(s,{to:`/`,className:`nav-link`,children:`Home`}),(0,G.jsx)(s,{to:`/devices`,className:`nav-link`,children:`Devices`}),(0,G.jsx)(s,{to:`/log`,className:`nav-link`,children:`Logs`}),(0,G.jsx)(s,{to:`/settings`,className:`nav-link`,children:`Settings`})]})})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[!y.matterbridgeInformation.readOnly&&(0,G.jsx)(V,{title:`Matterbridge v.${y.matterbridgeInformation.matterbridgeVersion}`,children:(0,G.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`},children:[`v.`,y.matterbridgeInformation.matterbridgeVersion.split(`-`)[0]+(y.matterbridgeInformation.matterbridgeVersion.includes(`-dev-`)?`@dev`:``)+(y.matterbridgeInformation.matterbridgeVersion.includes(`-edge-`)?`@edge`:``)+(y.matterbridgeInformation.matterbridgeVersion.includes(`-local-`)?`@local`:``)+(y.matterbridgeInformation.matterbridgeVersion.includes(`-git-`)?`@git`:``)]})}),y.matterbridgeInformation.shellyBoard&&(0,G.jsx)(`img`,{src:`Shelly.svg`,alt:`Shelly Icon`,style:{height:`30px`,padding:`0px`,margin:`0px`,marginRight:`30px`}}),y.matterbridgeInformation.bridgeMode!==``&&y.matterbridgeInformation.readOnly===!1?(0,G.jsx)(V,{title:`Bridge mode`,children:(0,G.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:y.matterbridgeInformation.bridgeMode})}):null,y.matterbridgeInformation.restartMode!==``&&y.matterbridgeInformation.readOnly===!1?(0,G.jsx)(V,{title:`Restart mode`,children:(0,G.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:y.matterbridgeInformation.restartMode})}):null,y.matterbridgeInformation.profile&&y.matterbridgeInformation.profile!==``&&y.matterbridgeInformation.readOnly===!1?(0,G.jsx)(V,{title:`Current profile`,children:(0,G.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:y.matterbridgeInformation.profile})}):null,Q&&(0,G.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`},children:[e?`Mobile `:`Desktop `,`${Zr}x${Qr}`,` enabled ${localStorage.getItem(K.enableMobile)!==`false`}`]})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`5px`},children:[y.matterbridgeInformation.readOnly===!1?(0,G.jsx)(V,{title:`Matterbridge discord group`,children:(0,G.jsx)(`img`,{src:`discord.svg`,alt:`Discord Logo`,style:{cursor:`pointer`,height:`25px`},onClick:te})}):null,y.matterbridgeInformation.readOnly===!1?(0,G.jsx)(V,{title:`Give a star to Matterbridge`,children:(0,G.jsx)(I,{style:{color:`#FFD700`,margin:`0`,padding:`0`},onClick:ne,children:(0,G.jsx)(N,{})})}):null,y.matterbridgeInformation.readOnly===!1?(0,G.jsx)(V,{title:`Sponsor Matterbridge`,children:(0,G.jsx)(I,{style:{color:`#b6409c`,margin:`0`,padding:`0`},onClick:j,children:(0,G.jsx)($e,{})})}):null,(0,G.jsx)(V,{title:`Matterbridge homepage`,children:(0,G.jsx)(I,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:ee,children:(0,G.jsx)(Me,{})})}),(0,G.jsx)(V,{title:`Matterbridge help`,children:(0,G.jsx)(I,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:M,children:(0,G.jsx)(Ye,{})})}),(0,G.jsx)(V,{title:`Matterbridge changelog`,children:(0,G.jsx)(I,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:P,children:(0,G.jsx)(He,{})})}),y.matterbridgeInformation&&!y.matterbridgeInformation.readOnly&&h&&(0,G.jsx)(V,{title:`Update matterbridge to latest version v.${y.matterbridgeInformation.matterbridgeLatestVersion}`,children:(0,G.jsx)(I,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:re,children:(0,G.jsx)(ge,{})})}),y.matterbridgeInformation&&!y.matterbridgeInformation.readOnly&&_&&(0,G.jsx)(V,{title:`Update matterbridge to latest dev version v.${y.matterbridgeInformation.matterbridgeDevVersion}`,children:(0,G.jsx)(I,{style:{color:`var(--secondary-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:ie,children:(0,G.jsx)(ge,{})})}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&y.matterbridgeInformation.shellySysUpdate&&(0,G.jsx)(V,{title:`Shelly system update`,children:(0,G.jsx)(I,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:oe,children:(0,G.jsx)(ge,{})})}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&y.matterbridgeInformation.shellyMainUpdate&&(0,G.jsx)(V,{title:`Shelly software update`,children:(0,G.jsx)(I,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:F,children:(0,G.jsx)(ge,{})})}),(0,G.jsx)(V,{title:`Restart matterbridge`,children:(0,G.jsx)(I,{style:{color:d||p?`var(--primary-color)`:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:le,children:(0,G.jsx)(he,{})})}),y.matterbridgeInformation.restartMode===``?(0,G.jsx)(V,{title:`Shut down matterbridge`,children:(0,G.jsx)(I,{style:{color:d||p?`var(--primary-color)`:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:ue,children:(0,G.jsx)(ye,{})})}):null,(0,G.jsx)(V,{title:`Download, backup and more`,children:(0,G.jsx)(I,{onClick:me,children:(0,G.jsx)(je,{style:{color:`var(--main-icon-color)`}})})}),(0,G.jsxs)(rt,{id:`command-menu`,anchorEl:S,keepMounted:!0,open:!!S,onClose:()=>L(``),children:[$&&e&&(0,G.jsxs)(R,{onClick:()=>L(`/`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Home page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),$&&e&&(0,G.jsxs)(R,{onClick:()=>L(`/devices`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Devices page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),$&&e&&(0,G.jsxs)(R,{onClick:()=>L(`/log`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Logs page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),$&&e&&(0,G.jsxs)(R,{onClick:()=>L(`/settings`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Settings page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&!y.matterbridgeInformation.readOnly&&(0,G.jsxs)(R,{onClick:()=>L(`update`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(ge,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Install latest stable`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&!y.matterbridgeInformation.readOnly&&(0,G.jsxs)(R,{onClick:()=>L(`updatedev`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(ge,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Install latest dev`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&!y.matterbridgeInformation.readOnly&&(0,G.jsxs)(R,{onClick:()=>L(`updatecheck`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(ge,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Check for updates`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&y.matterbridgeInformation.shellySysUpdate&&(0,G.jsxs)(R,{onClick:()=>L(`shelly-sys-update`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(ge,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Shelly system update`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&y.matterbridgeInformation.shellyMainUpdate&&(0,G.jsxs)(R,{onClick:()=>L(`shelly-main-update`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(ge,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Shelly software update`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>L(`restart`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(he,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Restart`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation.restartMode===``?(0,G.jsxs)(R,{onClick:()=>L(`shutdown`),children:[(0,G.jsx)(z,{children:(0,G.jsx)(ye,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Shutdown`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}):null,y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,G.jsxs)(R,{onClick:()=>{n(`Reboot`,`Are you sure you want to reboot the Shelly board?`,`reboot`,L,_e)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(he,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Reboot...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsx)(Pe,{}),(0,G.jsxs)(R,{onClick:ve,children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`View`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(rt,{id:`sub-menu-view`,anchorEl:w,keepMounted:!0,open:!!w,onClose:be,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,G.jsxs)(R,{onClick:()=>{ri(),be(),_e(``),window.open(`/home`,`_self`)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Desktop site`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{ni(),be(),_e(``),window.open(`/home`,`_self`)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Mobile site`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`view-mblog`),be()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`view-mjlog`),be()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matter log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`view-diagnostic`),be()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge diagnostic log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`view-history`),be()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge system history`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,G.jsxs)(R,{onClick:()=>{L(`view-shellylog`),be()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Qe,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]}),(0,G.jsx)(Pe,{}),(0,G.jsxs)(R,{onClick:xe,children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Download`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(rt,{id:`sub-menu-download`,anchorEl:E,keepMounted:!0,open:!!E,onClose:Se,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,G.jsxs)(R,{onClick:()=>{L(`create-matterbridge-storage-backup`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`create-plugin-backup`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge plugins storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`create-config-backup`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge plugins config`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`download-mblog`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`create-matter-storage-backup`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matter storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`download-mjlog`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matter log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`download-diagnostic`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge diagnostic log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{L(`download-history`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Matterbridge system history`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,G.jsxs)(R,{onClick:()=>{L(`shelly-create-system-log`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Create Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,G.jsxs)(R,{onClick:()=>{L(`shelly-download-system-log`),Se()},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Re,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Download Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]}),(0,G.jsx)(Pe,{}),(0,G.jsxs)(R,{onClick:()=>{L(`create-backup`)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(Je,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Backup`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsx)(Pe,{}),(0,G.jsxs)(R,{onClick:Ce,children:[(0,G.jsx)(z,{children:(0,G.jsx)(Ve,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Reset`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(rt,{id:`sub-menu-reset`,anchorEl:O,keepMounted:!0,open:!!O,onClose:we,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,G.jsxs)(R,{onClick:()=>{we(),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,_e)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(ye,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Reset the frontend UI...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{we(),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,_e)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(ye,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Reset all devices...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,G.jsxs)(R,{onClick:()=>{we(),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,_e)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(ye,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Reset commissioning...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),!y.matterbridgeInformation.readOnly&&(0,G.jsxs)(R,{onClick:()=>{we(),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,_e)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(ye,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Factory reset...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,G.jsxs)(R,{onClick:()=>{we(),n(`Network reset`,`Are you sure you want to factory reset the network parameters?`,`softreset`,L,_e)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(ye,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Reset network...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),y.matterbridgeInformation&&y.matterbridgeInformation.shellyBoard&&(0,G.jsxs)(R,{onClick:()=>{we(),n(`Factory reset`,`Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.`,`hardreset`,L,_e)},children:[(0,G.jsx)(z,{children:(0,G.jsx)(ye,{style:{color:`var(--main-icon-color)`}})}),(0,G.jsx)(H,{primary:`Factory reset...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]})]})]})]})}var Yr=(0,W.memo)(Jr),Xr=1200,Zr,Qr;function $r(){if(typeof window<`u`){Zr=Math.floor(window.visualViewport?.width??window.innerWidth),Qr=Math.floor(window.visualViewport?.height??window.innerHeight);let e=Zr<1200||Qr<900;return Q&&console.log(`Visual viewport (%s) width %i height %i mobile %s`,window.visualViewport!==void 0,Zr,Qr,e),e}return!1}function ei({children:e}){let{mobile:t,setMobile:n}=(0,W.useContext)(It),{logAutoScroll:r}=(0,W.useContext)(q);return(0,W.useEffect)(()=>{function e(){let e=$r();e&&(r.current=!1,localStorage.setItem(K.logAutoScroll,`false`)),n(e)}return window.addEventListener(`resize`,e),n($r()),()=>window.removeEventListener(`resize`,e)},[r,n]),Q&&console.log(`MbfScreen rendering... mobile %s`,t),$&&t?(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,overflow:`visible`,margin:`0px`,padding:`10px`,gap:`10px`},children:[(0,G.jsx)(Yr,{}),(0,G.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,margin:`0px`,padding:`0px`,gap:`10px`},children:e})]}):(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,overflow:`hidden`,width:t?`${Xr}px`:`calc(100vw - 40px)`,height:t?`900px`:`calc(100vh - 40px)`,margin:`0px`,padding:`20px`,gap:`20px`},children:[(0,G.jsx)(Yr,{}),(0,G.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,width:`100%`,height:`calc(100% - 60px)`,margin:`0px`,padding:`0px`,gap:`20px`},children:e})]})}var Q=!1,ti=()=>{Q=!Q},$=localStorage.getItem(K.enableMobile)!==`false`,ni=()=>{$=!0,localStorage.setItem(K.enableMobile,`true`)},ri=()=>{$=!1,localStorage.setItem(K.enableMobile,`false`)},ii=void 0,ai=e=>{ii=e},oi=!1,si=`/`,ci=`/`,li=`/`;function ui({setLoggedIn:e}){let[t,n]=(0,W.useState)(``),[r,i]=(0,W.useState)(``),a={display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100vh`,backgroundColor:`var(--main-bg-color)`},o={display:`flex`,flexDirection:`column`,maxWidth:`400px`,margin:`0 auto`,padding:`20px`,gap:`20px`,border:`1px solid var(--div-border-color)`,borderRadius:`var(--div-border-radius)`,boxShadow:`2px 2px 5px var(--div-shadow-color)`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},s={margin:`10px 0`,padding:`3px 3px`,fontSize:`14px`,width:`230px`,border:`1px solid var(--main-label-color)`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},c=async t=>{try{let n=await fetch(`./api/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:t})});if(n.ok){let{valid:r}=await n.json();r?(e(!0),t!==``&&(ii=t)):t!==``&&i(`Incorrect password!`)}else console.error(`Failed to log in:`,n.statusText)}catch(e){console.error(`Failed to log in:`,e)}};return c(``),(0,G.jsx)(`div`,{style:a,children:(0,G.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),c(t)},style:o,children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,G.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,G.jsx)(`h3`,{style:{color:`var(--div-text-color)`},children:`Welcome to Matterbridge`})]}),(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-between`,gap:`20px`},children:[(0,G.jsx)(`input`,{type:`text`,name:`username`,autoComplete:`username`,style:{display:`none`},tabIndex:-1}),(0,G.jsx)(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),style:s,placeholder:`password`,autoComplete:`current-password`}),(0,G.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,G.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`center`,margin:0,height:`30px`},children:r&&(0,G.jsx)(`p`,{style:{color:`red`},children:r})})]})})}function di(){let[e,t]=(0,W.useState)(!1),r=localStorage.getItem(K.frontendTheme)||`dark`;Q&&console.log(`Setting frontend theme "%s"`,r),document.body.setAttribute(`frontend-theme`,r);let i=Kr(`--primary-color`,`#1976d2`);Q&&console.log(`Primary color from CSS "%s"`,i);let s=qr(i);return si=window.location.href,ci=window.location.pathname,(ci.endsWith(`/devices`)||ci.endsWith(`/log`)||ci.endsWith(`/settings`)||ci.endsWith(`/test`))&&(ci=ci.substring(0,ci.lastIndexOf(`/`))),li=ci.endsWith(`/`)?ci:ci+`/`,oi=ci.includes(`/api/hassio_ingress/`),Q&&(console.log(`Loading App...`),console.log(`- href = "${si}"`),console.log(`- pathname = "${window.location.pathname}" >>> "${ci}"`),console.log(`- baseName = "${li}"`),console.log(`- isIngress = "${oi}"`)),e?(0,G.jsx)(fe,{theme:s,children:(0,G.jsx)(yt,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:`bottom`,horizontal:`right`},children:(0,G.jsx)(Lt,{children:(0,G.jsx)(zt,{children:(0,G.jsx)(o,{basename:li,children:(0,G.jsx)(ei,{children:(0,G.jsxs)(c,{children:[(0,G.jsx)(a,{path:`/`,element:(0,G.jsx)(ir,{})}),(0,G.jsx)(a,{path:`/devices`,element:(0,G.jsx)(Ar,{})}),(0,G.jsx)(a,{path:`/log`,element:(0,G.jsx)(Mr,{})}),(0,G.jsx)(a,{path:`/settings`,element:(0,G.jsx)(Ur,{})}),(0,G.jsx)(a,{path:`/test`,element:(0,G.jsx)(Gr,{})}),(0,G.jsx)(a,{path:`*`,element:(0,G.jsx)(n,{to:`/`})})]})})})})})})}):(0,G.jsx)(ui,{setLoggedIn:t})}At.createRoot(document.getElementById(`root`)).render((0,G.jsx)(W.StrictMode,{children:(0,G.jsx)(di,{})}));
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matterbridge/frontend",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.10-dev-20260329-5cac980",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@matterbridge/frontend",
|
|
9
|
-
"version": "3.4.
|
|
9
|
+
"version": "3.4.10-dev-20260329-5cac980",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@emotion/react": "11.14.0",
|