@matterbridge/frontend 3.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/build/Shelly.svg +1 -0
- package/build/assets/index.css +1 -0
- package/build/assets/index.js +4 -0
- package/build/assets/vendor_emotion.js +1 -0
- package/build/assets/vendor_lodash.js +1 -0
- package/build/assets/vendor_mdi.js +1 -0
- package/build/assets/vendor_mui.js +137 -0
- package/build/assets/vendor_node_modules.js +28 -0
- package/build/assets/vendor_notistack.js +5 -0
- package/build/assets/vendor_qrcode.js +1 -0
- package/build/assets/vendor_rjsf.js +11 -0
- package/build/bmc-button.svg +22 -0
- package/build/discord.svg +5 -0
- package/build/index.html +24 -0
- package/build/matter.png +0 -0
- package/build/matterbridge 1250x1250.png +0 -0
- package/build/matterbridge 32x32.png +0 -0
- package/build/matterbridge 624x624.png +0 -0
- package/build/matterbridge 64x64.png +0 -0
- package/build/matterbridge.svg +50 -0
- package/npm-shrinkwrap.json +1423 -0
- package/package.json +68 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{j as e,r,V as Kr,X as Lt,Y as Yr,Z as Zr,$ as ct,a0 as Xr,a1 as eo,G as to}from"./vendor_node_modules.js";import{u as ro,S as oo}from"./vendor_notistack.js";import{D as Be,a as Qe,b as Ge,B as me,c as Ze,F as lt,C as Xe,d as fe,A as no,I as X,e as io,f as so,T as V,g as lo,H as Fr,h as dr,i as Jt,j as ke,k as pr,l as Ut,S as rt,M as H,m as ao,n as Ae,o as Nr,p as co,q as zt,r as je,K as hr,s as fr,t as ar,L as Wt,u as wt,v as Tt,w as Y,W as kt,x as Ft,y as Nt,z as le,V as mr,E as xr,G as po,J as uo,Q as Rr,R as qt,N as go,U as ho,P as fo,O as qe,X as ur,Y as Or,Z as it,_ as _r,$ as mo,a0 as Hr,a1 as xo,a2 as bo,a3 as vo,a4 as br,a5 as yo,a6 as jo,a7 as wo,a8 as Co,a9 as So,aa as ko,ab as Io,ac as vr,ad as Mo,ae as Do,af as Po,ag as $o,ah as Lo,ai as Wo,aj as To,ak as Fo,al as No,am as Ro,an as Oo,ao as _o,ap as Ho,aq as Eo,ar as Vo,as as $e,at as Er,au as Gt,av as tt,aw as Ao,ax as et,ay as Uo,az as Ct,aA as Ve,aB as Rt,aC as rr,aD as zo,aE as qo}from"./vendor_mui.js";import{I as be,m as Bo,a as yr,b as Qo,c as Go,d as jr,e as Jo,f as Ko,g as Yo,h as Zo,i as Xo,j as en,k as tn,l as rn,n as on,o as nn,p as sn,q as ln,r as wr,s as an,t as cn,u as dn,v as pn,w as un,x as gn,y as hn,z as fn,A as Cr,B as mn,C as xn}from"./vendor_mdi.js";import{Q as bn}from"./vendor_qrcode.js";import{F as vn,v as yn,e as jn,a as wn,g as Cn,b as Sn,c as kn,d as or,A as In}from"./vendor_rjsf.js";import"./vendor_emotion.js";import"./vendor_lodash.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const g of s)if(g.type==="childList")for(const h of g.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&i(h)}).observe(document,{childList:!0,subtree:!0});function l(s){const g={};return s.integrity&&(g.integrity=s.integrity),s.referrerPolicy&&(g.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?g.credentials="include":s.crossOrigin==="anonymous"?g.credentials="omit":g.credentials="same-origin",g}function i(s){if(s.ep)return;s.ep=!0;const g=l(s);fetch(s.href,g)}})();function Mn({open:n,title:a,message:l,onConfirm:i,onCancel:s}){const g=b=>{o&&console.log("Confirmed"),b.preventDefault(),i()},h=b=>{o&&console.log("Canceled"),b.preventDefault(),s()};return e.jsxs(Be,{open:n,children:[e.jsx(Qe,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:a})]})}),e.jsxs(Ge,{children:[e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:"0",marginBottom:"20px",maxHeight:"350px",maxWidth:"350px"},children:e.jsx("p",{style:{flex:1,margin:"0"},children:l})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(me,{onClick:g,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(me,{onClick:h,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const ye="",ee={enableMobile:`${ye}enableMobile`,devicesFilter:`${ye}devicesFilter`,devicesViewMode:`${ye}devicesViewMode`,frontendVersion:`${ye}frontendVersion`,matterbridgeVersion:`${ye}matterbridgeVersion`,homePageMode:`${ye}homePageMode`,logFilterLevel:`${ye}logFilterLevel`,logFilterSearch:`${ye}logFilterSearch`,logAutoScroll:`${ye}logAutoScroll`,logLength:`${ye}logLength`,frontendTheme:`${ye}frontendTheme`,homePagePlugins:`${ye}homePagePlugins`,virtualMode:`${ye}virtualMode`,installAutoExit:`${ye}installAutoExit`,searchPluginsTotal:`${ye}searchPluginsTotal`,searchPluginsMeta:`${ye}searchPluginsMeta`,searchPluginsVersions:`${ye}searchPluginsVersions`},Dn={Devices_table_order_by:`${ye}Devices_table_order_by`,Devices_table_order:`${ye}Devices_table_order`,Devices_column_visibility:`${ye}Devices_column_visibility`,Plugins_table_order_by:`${ye}Plugins_table_order_by`,Plugins_table_order:`${ye}Plugins_table_order`,Plugins_column_visibility:`${ye}Plugins_column_visibility`,"Registered devices_table_order_by":`${ye}Registered devices_table_order_by`,"Registered devices_table_order":`${ye}Registered devices_table_order`,"Registered devices_column_visibility":`${ye}Registered devices_column_visibility`,Clusters_table_order_by:`${ye}Clusters_table_order_by`,Clusters_table_order:`${ye}Clusters_table_order`,Clusters_column_visibility:`${ye}Clusters_column_visibility`};function Pn(){Object.values(ee).forEach(n=>{localStorage.removeItem(n)}),Object.values(Dn).forEach(n=>{localStorage.removeItem(n)})}const $n=({open:n,output:a,title:l,_command:i,_packageName:s,onInstall:g,onClose:h})=>{const{installAutoExit:b,setInstallAutoExit:t}=r.useContext(Re),N=r.useRef(null),I=W=>{t(W.target.checked),localStorage.setItem(ee.installAutoExit,W.target.checked?"true":"false"),o&&console.log("handleInstallAutoExitChange called with value:",W.target.checked)};return r.useEffect(()=>{o&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom: ${N.current}`),setTimeout(()=>{o&&console.log("Scrolling to bottom:",N.current),N.current?.scrollIntoView({behavior:"smooth",block:"end"})},0)},[a]),e.jsxs(Be,{open:n,onClose:(W,k)=>{k==="backdropClick"||k==="escapeKeyDown"||h()},slotProps:{paper:{sx:{width:"70vw",maxWidth:"70vw",height:"70vw",maxHeight:"70vh",overflow:"hidden"}}},children:[e.jsx(Qe,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:l})]})}),e.jsxs(Ge,{dividers:!0,style:{overflow:"hidden",display:"flex",flexDirection:"column",height:400,paddingBottom:0},children:[e.jsx("label",{style:{display:"block",marginBottom:"10px",fontSize:"16px",fontWeight:"bold",color:"var(--primary-color)"},children:"Process log"}),e.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:[a.split(`
|
|
2
|
+
`).map((W,k)=>e.jsx("li",{style:{padding:0,margin:0,wordBreak:"break-all"},children:W},k)),e.jsx("li",{ref:N,style:{padding:0,margin:0}})]})]}),e.jsxs(Ze,{sx:{justifyContent:"space-evenly"},children:[g&&e.jsx(me,{variant:"contained",onClick:g,children:"Install"}),e.jsx(me,{onClick:h,children:"Close"}),e.jsx(lt,{control:e.jsx(Xe,{checked:b,onChange:W=>I(W)}),label:"Close on success",style:{color:"var(--div-text-color)"}})]})]})},Ot=[],Re=r.createContext(null);function Ln({children:n}){const[a,l]=r.useState(!1),[i,s]=r.useState(null),{enqueueSnackbar:g,closeSnackbar:h}=ro(),b=r.useCallback($=>{o&&console.log(`UiProvider closeSnackbarMessage: message ${$}`);const C=Ot.findIndex(L=>L.message===$);C!==-1&&(h(Ot[C].key),Ot.splice(C,1),o&&console.log(`UiProvider closeSnackbarMessage: message ${$} removed from persistMessages`))},[h]),t=r.useCallback(($,C,L)=>{o&&console.log(`UiProvider showSnackbarMessage: message ${$} timeout ${C}`);const U=g($,{variant:"default",autoHideDuration:C==null||C>0?(C??5)*1e3:null,persist:C===0,content:Q=>e.jsx(fe,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(no,{severity:L??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>h(Q),action:e.jsx(X,{size:"small",onClick:()=>h(Q),sx:{color:"#fff"},children:e.jsx(io,{fontSize:"small"})}),children:$},Q)},Q)});C===0&&(o&&console.log(`UiProvider showSnackbarMessage: message ${$} timeout ${C} - persist key ${U}`),Ot.push({message:$,key:U}))},[g,h]),[N,I]=r.useState(!1),[W,k]=r.useState(""),[B,K]=r.useState(""),[Z,q]=r.useState(""),m=r.useRef(null),p=r.useRef(null),u=()=>{o&&console.log(`UiProvider handle confirm action ${Z}`),I(!1),m.current&&m.current(Z)},D=()=>{o&&console.log(`UiProvider handle cancel action ${Z}`),I(!1),p.current&&p.current(Z)},M=r.useCallback(($,C,L,U,Q)=>{o&&console.log(`UiProvider showConfirmCancelDialog for command ${L}`),k($),K(C),q(L),m.current=U,p.current=Q,I(!0)},[]),[T,te]=r.useState(!1),[ce,w]=r.useState(""),[d,c]=r.useState(""),[v,_]=r.useState(""),[E,ae]=r.useState(""),[we,A]=r.useState(localStorage.getItem(ee.installAutoExit)!=="false"),x=r.useCallback(($,C,L)=>{o&&console.log(`UiProvider show install progress for package ${$}`),w($),c(C),_(L),te(!0)},[]),y=r.useCallback($=>{o&&console.log(`UiProvider addInstallProgress: output ${$}`),ae(C=>C+$+`
|
|
3
|
+
`)},[]),P=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressSuccess: package ${v}`),localStorage.getItem(ee.installAutoExit)!=="false"&&te(!1)},[v]),F=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressError: package ${v}`)},[v]),S=r.useCallback(()=>{o&&console.log("UiProvider hide install progress"),te(!1)},[]),re=()=>{o&&console.log("UiProvider handle install close action"),te(!1),_(""),ae("")},Ce=r.useMemo(()=>({mobile:a,setMobile:l,currentPage:i,setCurrentPage:s,showSnackbarMessage:t,closeSnackbarMessage:b,closeSnackbar:h,showConfirmCancelDialog:M,showInstallProgress:x,exitInstallProgressSuccess:P,exitInstallProgressError:F,hideInstallProgress:S,addInstallProgress:y,installAutoExit:we,setInstallAutoExit:A}),[a,i,l,s,t,b,h,M,x,P,F,S,y,we,A]);return e.jsxs(Re.Provider,{value:Ce,children:[e.jsx(Mn,{open:N,title:W,message:B,onConfirm:u,onCancel:D}),e.jsx($n,{open:T,title:ce,_command:d,_packageName:v,output:E,onClose:re}),n]})}const Vr=r.createContext(null),Ie=r.createContext(null);function Wn({children:n}){const[a,l]=r.useState([]),[i,s]=r.useState(localStorage.getItem(ee.logFilterLevel)??"info"),[g,h]=r.useState(localStorage.getItem(ee.logFilterSearch)??"*"),[b,t]=r.useState(!1),{showSnackbarMessage:N,closeSnackbarMessage:I,closeSnackbar:W,showInstallProgress:k,hideInstallProgress:B,exitInstallProgressSuccess:K,exitInstallProgressError:Z,addInstallProgress:q}=r.useContext(Re),m=r.useRef([]),p=r.useRef(null),u=r.useRef(1),D=r.useRef(Math.floor(Math.random()*999e3)+1e3),M=r.useRef(null),T=r.useRef(null),te=r.useRef(null),ce=r.useRef(i),w=r.useRef(g),d=r.useRef(0),c=r.useRef(null),v=r.useRef(Number(localStorage.getItem(ee.logLength)??200)),_=r.useRef(localStorage.getItem(ee.logAutoScroll)!=="false"),E=r.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),ae=100,we=60,A=50,x=300,y=10;r.useEffect(()=>(o&&console.log("WebSocket messages started counter interval"),c.current=setInterval(()=>{d.current>0&&(o&&console.log(`WebSocket messages received in the last ${y} seconds: ${d.current*(60/y)} messages/minute`),d.current=0)},y*1e3),()=>{o&&console.log("WebSocket messages stopped counter interval"),c.current&&clearInterval(c.current),c.current=null}),[]),r.useEffect(()=>{ce.current=i},[i]),r.useEffect(()=>{w.current=g},[g]);const P=r.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),F=r.useCallback((z,f)=>{o&&console.log(`WebSocket filterLogMessages called with level "${z}" and search "${f}"...`),l(ue=>ue.filter(J=>!(["debug","info","notice","warn","error","fatal"].includes(J.level)&&(z==="info"&&J.level==="debug"||z==="notice"&&(J.level==="debug"||J.level==="info")||z==="warn"&&(J.level==="debug"||J.level==="info"||J.level==="notice")||z==="error"&&(J.level==="debug"||J.level==="info"||J.level==="notice"||J.level==="warn")||z==="fatal"&&(J.level==="debug"||J.level==="info"||J.level==="notice"||J.level==="warn"||J.level==="error"))||f!=="*"&&f!==""&&!f.startsWith("/")&&!f.endsWith("/")&&!J.message.toLowerCase().includes(f.toLowerCase())&&!J.name.toLowerCase().includes(f.toLowerCase())||f.startsWith("/")&&f.endsWith("/")&&(()=>{try{const O=new RegExp(f.slice(1,-1),"i");return!O.test(J.message)&&!O.test(J.name)}catch(O){return console.error(`WebSocket log search invalid regex filter "${f}":`,O),!1}})())))},[]),S=r.useCallback(z=>{if(p.current&&p.current.readyState===WebSocket.OPEN)try{o&&console.log(`WebSocket sending message with id ${z.id}:`,z),z.id===void 0&&(z.id=D.current);const f=JSON.stringify(z);p.current.send(f),o&&console.log("WebSocket sent message:",z)}catch(f){o&&console.error(`WebSocket error sending message: ${f}`)}else o&&console.error("WebSocket message not sent, WebSocket not connected:",z)},[]),re=r.useCallback((z,f)=>{l(ue=>[...ue,{level:z,time:"",name:"",message:f}])},[]),Ce=r.useCallback((z,f)=>{o&&console.log(`WebSocket addListener id ${f}:`,z),(f==null||isNaN(f)||f===0)&&console.error("WebSocket addListener called without id, listener not added:",z),m.current=[...m.current,{listener:z,id:f}],o&&console.log("WebSocket addListener total listeners:",m.current.length)},[]),$=r.useCallback(z=>{o&&console.log("WebSocket removeListener:",z),m.current=m.current.filter(f=>f.listener!==z),o&&console.log("WebSocket removeListener total listeners:",m.current.length)},[]),C=r.useCallback(()=>{E===""||E===null||E===void 0||(re("WebSocket",`Connecting ${xt?"with password":""} to WebSocket: ${E}`),o&&console.log(`WebSocket connecting to: ${E}${xt?"?password=[redacted]":""}`),p.current=new WebSocket(E+(xt?`?password=${encodeURIComponent(xt)}`:"")),p.current.onmessage=z=>{b||t(!0),d.current+=1;try{const f=JSON.parse(z.data);if(f.id===void 0||f.src===void 0||f.dst===void 0){o&&console.error("WebSocket undefined message id/src/dst:",f);return}if(f.src!=="Matterbridge"||f.dst!=="Frontend"){o&&console.error("WebSocket invalid message src/dst:",f);return}if(f.error){o&&console.error("WebSocket error message response:",f);return}if(f.id===D.current&&f.method==="pong"&&f.response==="pong"){o&&console.log(`WebSocket pong response message id ${f.id}:`,f),T.current&&clearTimeout(T.current),T.current=null;return}else if(f.method==="snackbar"&&f.response&&f.response.message){o&&console.log(`WebSocket message id ${f.id} method ${f.method}:`,f),N(f.response.message,f.response.timeout,f.response.severity);return}else if(f.method==="close_snackbar"&&f.response&&f.response.message){o&&console.log(`WebSocket message id ${f.id} method ${f.method}:`,f),I(f.response.message);return}else if(f.method==="log"){if(!f.response||!f.response.level||!f.response.time||!f.response.name||!f.response.message||(f.response.level==="spawn"&&(f.response.name==="Matterbridge:spawn-init"?k(f.response.message,"",""):f.response.name==="Matterbridge:spawn-exit-success"?K():f.response.name==="Matterbridge:spawn-exit-error"?Z():q(f.response.message+`
|
|
4
|
+
`)),["debug","info","notice","warn","error","fatal"].includes(f.response.level)&&(ce.current==="info"&&f.response.level==="debug"||ce.current==="notice"&&(f.response.level==="debug"||f.response.level==="info")||ce.current==="warn"&&(f.response.level==="debug"||f.response.level==="info"||f.response.level==="notice")||ce.current==="error"&&(f.response.level==="debug"||f.response.level==="info"||f.response.level==="notice"||f.response.level==="warn")||ce.current==="fatal"&&(f.response.level==="debug"||f.response.level==="info"||f.response.level==="notice"||f.response.level==="warn"||f.response.level==="error")))||w.current!=="*"&&w.current!==""&&!w.current.startsWith("/")&&!w.current.endsWith("/")&&!f.response.message.toLowerCase().includes(w.current.toLowerCase())&&!f.response.name.toLowerCase().includes(w.current.toLowerCase())||w.current.startsWith("/")&&w.current.endsWith("/")&&(()=>{try{const J=new RegExp(w.current.slice(1,-1),"i");return!J.test(f.response.message)&&!J.test(f.response.name)}catch(J){return console.error(`WebSocket log search invalid regex filter "${w.current}":`,J),!1}})()||f.response.name==="Commissioning"&&f.response.message.includes("is uncommissioned"))return;l(J=>{const O=[...J,{level:f.response.level,time:f.response.time,name:f.response.name,message:f.response.message}];return o&&console.log(`WebSocket new log message added (${O.length}/${v.current}):`,O[O.length-1]),O.length>v.current+v.current*10/100?(o&&console.log(`WebSocket sliced log messages to the last ${v.current} entries`),O.slice(O.length-v.current)):O})}else{if(o&&console.log(`WebSocket received message id ${f.id} method ${f.method}:`,f),f.id===0)m.current.forEach(ue=>ue.listener(f));else{const ue=m.current.find(J=>J.id===f.id);ue?ue.listener(f):console.warn(`WebSocket no listener found for message id ${f.id}:`,f)}return}}catch(f){console.error(`WebSocket error parsing message: ${f}`,f instanceof Error?f.stack:null)}},p.current.onopen=()=>{o&&console.log(`WebSocket: Connected to WebSocket: ${E}`),re("WebSocket",`Connected to WebSocket: ${E}`),t(!0),W(),u.current=1,te.current=setTimeout(()=>{M.current=setInterval(()=>{S({id:D.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{o&&console.error(`WebSocketUse: No pong response received from WebSocket: ${E}`),re("WebSocket",`No pong response received from WebSocket: ${E}`),t(!1)},1e3*A)},1e3*we)},1e3*x)},p.current.onclose=()=>{o&&console.error(`WebSocket: Disconnected from WebSocket ${Mt?"with Ingress":""}: ${E}`),re("WebSocket",`Disconnected from WebSocket: ${E}`),t(!1),W(),B(),te.current&&clearTimeout(te.current),T.current&&clearTimeout(T.current),M.current&&clearInterval(M.current),re("WebSocket",`Reconnecting (attempt ${u.current} of ${ae}) to WebSocket${Mt?" (Ingress)":""}: ${E}`),Mt?setTimeout(L,5e3):u.current===1?L():u.current<ae?setTimeout(L,1e3*u.current):re("WebSocket",`Reconnect attempts exceeded limit of ${ae} retries, refresh the page to reconnect to: ${E}`),u.current=u.current+1},p.current.onerror=z=>{o&&console.error(`WebSocket: WebSocket error connecting to ${E}:`,z),re("WebSocket",`WebSocket error connecting to ${E}`)})},[E]),L=r.useCallback(()=>{o&&console.log(`WebSocket attemptReconnect ${u.current}/${ae} to:`,E),C()},[C]);r.useEffect(()=>(C(),()=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.close()}),[C]);const U=r.useMemo(()=>({messages:a,logLength:v,logAutoScroll:_,logFilterLevel:i,logFilterSearch:g,setMessages:l,setLogFilterLevel:s,setLogFilterSearch:h,filterLogMessages:F}),[a,v,_,i,g,l,s,h,F]),Q=r.useMemo(()=>({logLength:v,logAutoScroll:_,logFilterLevel:i,logFilterSearch:g,setMessages:l,setLogFilterLevel:s,setLogFilterSearch:h,filterLogMessages:F,online:b,retry:u.current,getUniqueId:P,addListener:Ce,removeListener:$,sendMessage:S,logMessage:re}),[v,_,l,s,h,b,u.current,Ce,$,S,re]);return e.jsx(Vr.Provider,{value:U,children:e.jsx(Ie.Provider,{value:Q,children:n})})}function Tn(n){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 296.2 296.2",...n,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"lg1",x1:"16.6",y1:"16.6",x2:"279.6",y2:"279.6",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".1",stopColor:"#3faa77"}),e.jsx("stop",{offset:".3",stopColor:"#234148"}),e.jsx("stop",{offset:".7",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#ad2e6e"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg2",x1:"31.1",y1:"31.1",x2:"265.1",y2:"265.1",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".2",stopColor:"#285251"}),e.jsx("stop",{offset:".4",stopColor:"#234148"}),e.jsx("stop",{offset:".8",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#a8316c"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg3",x1:"116.2",y1:"143.9",x2:"139.8",y2:"143.9",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#8bc751"}),e.jsx("stop",{offset:"1",stopColor:"#0db14b"})]}),e.jsx("linearGradient",{id:"lg4",x1:"136.1",y1:"100.8",x2:"159.6",y2:"100.8",xlinkHref:"#lg3"}),e.jsx("linearGradient",{id:"lg5",x1:"155.3",y1:"143.9",x2:"178.9",y2:"143.9",xlinkHref:"#lg3"}),e.jsxs("linearGradient",{id:"lg6",x1:"46.8",y1:"25.7",x2:"89.6",y2:"74.8",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#b1d34a"}),e.jsx("stop",{offset:"1",stopColor:"#50b848"})]})]}),e.jsx("rect",{width:"296.2",height:"296.2",rx:"56.7",ry:"56.7",style:{fill:"url(#lg1)"}}),e.jsx("rect",{x:"16.3",y:"16.3",width:"263.6",height:"263.6",rx:"50.5",ry:"50.5",style:{fill:"url(#lg2)"}}),e.jsx("circle",{cx:"128",cy:"143.9",r:"11.8",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"147.8",cy:"100.8",r:"11.8",style:{fill:"url(#lg4)"}}),e.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)"}}),e.jsx("circle",{cx:"167.1",cy:"143.9",r:"11.8",style:{fill:"url(#lg5)"}}),e.jsx("path",{fill:"#fff",d:"M219 89.3V35.5a10.5 10.5 0 1 0-21 0v33.7l21 20Z"}),e.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)"}}),e.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"}),e.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 Je(){const{retry:n}=r.useContext(Ie),a=()=>{window.location.reload()};return e.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:[e.jsx(Tn,{style:{height:"128px",width:"128px",margin:"10px",marginBottom:"20px"}}),n<100?e.jsxs(e.Fragment,{children:[e.jsx(so,{style:{color:"var(--primary-color)"}}),e.jsx("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:e.jsxs("span",{children:["Reconnecting to Matterbridge ","(attempt "+n+")","..."]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:[e.jsx("span",{children:"Unable to connect to Matterbridge after multiple attempts."}),e.jsx("br",{}),e.jsx("span",{children:"Please check your network connection."}),e.jsx("br",{})]}),e.jsx(me,{variant:"contained",color:"primary",onClick:a,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})}function Ar({value:n,maxChars:a}){let l=n;if(n.length>a&&a>3){const i=a-3,s=n.substring(0,Math.ceil(i/2)),g=n.substring(n.length-Math.floor(i/2),n.length);l=`${s} … ${g}`}return n!==l?e.jsx(V,{title:n,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:l})}):e.jsx("span",{children:l})}function Me({children:n,style:a}){const l={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"};return e.jsx("div",{style:{...l,...a},children:n})}function Fe({children:n,style:a}){const l={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"};return e.jsx("div",{style:{...l,...a},children:n})}function De({children:n,style:a}){const l={color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",fontSize:"16px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...a},children:n})}function It({children:n,style:a}){const l={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"};return e.jsx("div",{style:{...l,...a},children:n})}function mt({children:n,style:a}){const l={color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",fontSize:"14px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...a},children:n})}function St({children:n,style:a}){const l={color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",fontSize:"14px",fontWeight:"normal",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...a},children:n})}function Ue({children:n,style:a,onDragOver:l,onDragLeave:i,onDrop:s}){const g={flex:"0 0 auto",display:"flex",flexDirection:"row",overflow:"hidden",alignItems:"start",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"};return e.jsx("div",{style:{...g,...a},onDragOver:l,onDragLeave:i,onDrop:s,children:n})}function st({children:n,style:a,close:l}){const i={display:"flex",flexDirection:"row",margin:"0px",padding:"0px",paddingRight:"10px",gap:"10px"};return e.jsxs("div",{style:{...i,...a},children:[n,ns]})}function Fn({systemInfo:n,compact:a}){const{mobile:l}=r.useContext(Re),{addListener:i,removeListener:s,getUniqueId:g,sendMessage:h}=r.useContext(Ie),[b,t]=r.useState(n),N=r.useRef(g());if(o&&console.log("SystemInfoTable loading with systemInfo:",b,"compact:",a),n&&a&&b.totalMemory&&b.freeMemory){const m=b.totalMemory,p=b.freeMemory;b.freeMemory=`${p} / ${m}`,b.totalMemory=""}if(n&&a&&b.heapTotal&&b.heapUsed){const m=b.heapTotal,p=b.heapUsed;b.heapUsed=`${p} / ${m}`,b.heapTotal=""}if(n&&a&&b.osRelease&&b.osType){const m=b.osType,p=b.osRelease;b.osType=`${m} (${p})`,b.osRelease=""}if(n&&a&&b.osArch&&b.osPlatform){const m=b.osPlatform,p=b.osArch;b.osPlatform=`${m} (${p})`,b.osArch=""}const I=(m,p,u,D,M)=>{t(T=>({...T,totalMemory:m,freeMemory:p,heapTotal:u,heapUsed:D,rss:M}))},W=m=>{t(p=>({...p,cpuUsage:m.toFixed(2)+" %"}))},k=m=>{t(p=>({...p,processCpuUsage:m.toFixed(2)+" %"}))},B=(m,p)=>{t(u=>({...u,systemUptime:m,processUptime:p}))},K=()=>{o&&console.log("SystemInfoTable handleViewHistory clicked"),h({id:N.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}})};r.useEffect(()=>{const m=p=>{o&&console.log("SystemInfoTable received WebSocket Message:",p),p.method==="memory_update"&&p.response&&p.response.totalMemory&&p.response.freeMemory&&p.response.heapTotal&&p.response.heapUsed&&p.response.rss?(o&&console.log("SystemInfoTable received memory_update",p),I(p.response.totalMemory,p.response.freeMemory,p.response.heapTotal,p.response.heapUsed,p.response.rss)):p.method==="cpu_update"&&p.response&&p.response.cpuUsage?(o&&console.log("SystemInfoTable received cpu_update",p),W(p.response.cpuUsage),k(p.response.processCpuUsage)):p.method==="uptime_update"&&p.response&&p.response.systemUptime&&p.response.processUptime?(o&&console.log("SystemInfoTable received uptime_update",p),B(p.response.systemUptime,p.response.processUptime)):p.method==="/api/viewhistorypage"&&p.id===N.current&&p.success===!0&&(o&&console.log("SystemInfoTable received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer"))};return i(m,N.current),o&&console.log(`SystemInfoTable added WebSocket listener id ${N.current}`),()=>{s(m),o&&console.log("SystemInfoTable removed WebSocket listener")}},[i,s]);const[Z,q]=r.useState(!1);return!b||Z?null:(o&&console.log("SystemInfoTable rendering..."),e.jsxs(Me,{style:Se&&l?{flex:"1 1 300px"}:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Fe,{children:[e.jsx(De,{children:"System info"}),e.jsx(st,{close:()=>q(!0),children:e.jsx(X,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:K,children:e.jsx(V,{title:"Open the cpu and memory usage page",arrow:!0,children:e.jsx(be,{path:Bo,size:"22px"})})})})]}),e.jsx(Ue,{style:Se&&l?{flex:"1 1 auto",margin:"0px",padding:"0px",gap:"0px"}:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsxs("table",{style:{border:"none",borderCollapse:"collapse",tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"40%"}}),e.jsx("col",{style:{width:"60%"}})]}),e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(b).filter(([m,p])=>p!==void 0&&p!=="").map(([m,p],u)=>e.jsxs("tr",{className:u%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap"},children:m.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")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Se&&l?typeof p!="string"?p.toString():p:e.jsx(Ar,{value:typeof p!="string"?p.toString():p,maxChars:22})})]},m))})]})})]}))}const Sr=r.memo(Fn),kr={margin:"0px",padding:"0px",color:"var(--div-text-color)",transition:"color 0.2s ease","& svg":{display:"block"},"& svg path":{fill:"var(--div-text-color)",transition:"fill 0.2s ease"},"&:hover":{color:"var(--primary-color)"},"&:hover svg path":{fill:"var(--primary-color)"},"&:focus-visible":{outline:"2px solid var(--primary-color)",outlineOffset:"2px"}},Nn=n=>{if(!n)return"";const a=n.toString().replace(/[^0-9]/g,"");if(a.length<5)return a;const l=a.slice(0,4),i=a.slice(4,7),s=a.slice(7,11);return[l,i,s].filter(Boolean).join("-")};function Rn({id:n}){const{online:a,sendMessage:l,addListener:i,removeListener:s,getUniqueId:g}=r.useContext(Ie),[h,b]=r.useState(null),t=r.useRef(null),N=r.useRef(null),I=r.useRef(g()),{mobile:W,showConfirmCancelDialog:k}=r.useContext(Re);o&&console.log(`QRDiv loading with id = "${n}" storeId = "${t.current}" timeout = ${N.current} and matter:`,h),r.useEffect(()=>{o&&console.log(`QRDiv id effect "${n}"`),t.current=n,N.current&&clearTimeout(N.current),N.current=null,n?(o&&console.log(`QRDiv id effect sending data request for storeId "${n}"`),l({id:I.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:n,server:!0}})):(o&&console.log("QRDiv id effect setting matter to null"),b(null))},[n,l]),r.useEffect(()=>{const p=u=>{o&&console.log("QRDiv received WebSocket Message:",u),u.method==="refresh_required"&&u.response.changed==="matter"&&u.response.matter&&(o&&console.log(`QRDiv received refresh_required: changed=${u.response.changed} for storeId "${u.response.matter.id}":`,u.response.matter),t.current===u.response.matter.id&&(o&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${u.response.matter.id}":`,u.response.matter),N.current&&clearTimeout(N.current),u.response.matter.advertising&&u.response.matter.advertiseTime&&u.response.matter.advertiseTime+9e5<=Date.now()&&(u.response.matter.advertising=!1),b(u.response.matter),u.response.matter.advertising&&(o&&console.log(`QRDiv setting matter advertise timeout for storeId "${u.response.matter.id}":`,u.response.matter.advertiseTime+9e5-Date.now()),N.current=setTimeout(()=>{N.current&&clearTimeout(N.current),o&&console.log(`QRDiv clearing advertising state for storeId "${t.current}" after 15 minutes`),b(D=>D&&{...D,advertising:!1})},u.response.matter.advertiseTime+9e5-Date.now()))))};return i(p,I.current),o&&console.log("QRDiv webSocket effect mounted"),()=>{s(p),N.current&&clearTimeout(N.current),N.current=null,o&&console.log("QRDiv webSocket effect unmounted")}},[i,s]);const B=()=>{o&&console.log(`QRDiv sent matter startCommission for node "${h?.id}"`),h&&l({id:I.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,startCommission:!0}})},K=()=>{o&&console.log(`QRDiv sent matter stopCommission for node "${h?.id}"`),h&&l({id:I.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,stopCommission:!0}})},Z=()=>{o&&console.log(`QRDiv sent matter advertise for node "${h?.id}"`),h&&l({id:I.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,advertise:!0}})},q=p=>{o&&console.log(`QRDiv sent matter removeFabric for node "${h?.id}" and fabricIndex ${p}`),h&&l({id:I.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,removeFabric:p}})},m=async()=>{if(!h||!h.manualPairingCode)return;const p=h.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(p);else{const u=document.createElement("textarea");u.value=p,u.style.position="fixed",u.style.opacity="0",document.body.appendChild(u),u.focus(),u.select(),document.execCommand("copy"),document.body.removeChild(u)}o&&console.log("Manual pairing code copied to clipboard")}catch(u){console.error("Failed to copy manual pairing code",u)}};return!h||!a?(o&&console.log("QRDiv rendering undefined state"),null):h.online?h.advertising&&h.qrPairingCode&&h.manualPairingCode?(o&&console.log("QRDiv rendering advertising state"),e.jsxs(Me,{style:Se&&W?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsxs(Fe,{children:[e.jsx(De,{children:"QR pairing code"}),e.jsxs(st,{children:[e.jsx(X,{"aria-label":"send advertising",size:"small",onClick:Z,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(V,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(be,{path:yr,size:"22px"})})}),e.jsx(X,{"aria-label":"stop pairing",size:"small",onClick:K,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(V,{title:"Turn off pairing",arrow:!0,children:e.jsx(be,{path:Qo,size:"22px"})})})]})]}),e.jsx(St,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(bn,{value:h.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs(It,{style:{justifyContent:"space-between"},children:[e.jsxs(mt,{style:{fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",Nn(h.manualPairingCode)]}),e.jsx(st,{children:e.jsx(V,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(X,{"aria-label":"copy manual pairing code",size:"small",onClick:m,sx:kr,children:e.jsx(be,{path:Go,size:.85})})})})]})]})):h.commissioned&&h.fabricInformations&&h.sessionInformations?(o&&console.log("QRDiv rendering commissioned state"),e.jsxs(Me,{style:Se&&W?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px",overflow:"hidden"},children:[e.jsxs(Fe,{children:[e.jsx(De,{children:"Paired fabrics"}),e.jsxs(st,{children:[e.jsx(X,{"aria-label":"send advertising",size:"small",onClick:Z,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(V,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(be,{path:yr,size:"22px"})})}),e.jsx(X,{"aria-label":"start pairing",size:"small",onClick:B,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(V,{title:"Turn on pairing",arrow:!0,children:e.jsx(be,{path:jr,size:"22px"})})})]})]}),e.jsx(St,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(Ue,{style:{flexDirection:"column",justifyContent:"flex-start",flex:"1 1 auto",overflow:"auto",padding:"0px 0px 10px 0px",gap:"0px"},children:h.fabricInformations.map((p,u)=>e.jsxs("div",{style:{margin:"0px",padding:"10px",gap:"0px",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",textAlign:"left",fontSize:"14px"},children:[e.jsxs("div",{style:{marginLeft:"20px",marginBottom:"10px",display:"flex",flexDirection:"row",justifyContent:"space-between",gap:"20px",alignItems:"center"},children:[e.jsxs("p",{className:"status-blue",style:{margin:"0px",padding:"3px 10px",width:"200px",fontSize:"14px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},children:["Fabric: ",p.fabricIndex]}),e.jsx(V,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(X,{"aria-label":"remove the fabric",size:"small",onClick:()=>k("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>q(p.fabricIndex),()=>{}),sx:{...kr,padding:"2px"},children:e.jsx(be,{path:Jo,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",p.rootVendorId," ",p.rootVendorName]}),p.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",p.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",h.sessionInformations?h.sessionInformations.filter(D=>D.fabric?.fabricIndex===p.fabricIndex&&D.isPeerActive===!0).length:"0"," ","subscriptions: ",h.sessionInformations?h.sessionInformations.filter(D=>D.fabric?.fabricIndex===p.fabricIndex&&D.isPeerActive===!0&&D.numberOfActiveSubscriptions>0).length:"0"]})]},u))}),e.jsx(It,{style:{justifyContent:"center"},children:e.jsxs(mt,{style:{fontWeight:"normal"},children:["Serial number: ",h.serialNumber]})})]})):!h.commissioned&&!h.advertising?(o&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs(Me,{style:Se&&W?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(Fe,{children:e.jsx(De,{children:"QR pairing code"})}),e.jsx(St,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(me,{onClick:B,endIcon:e.jsx(be,{path:jr,size:1}),style:{margin:"20px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:"Turn on pairing"}),e.jsx(It,{style:{justifyContent:"center"},children:e.jsxs(mt,{style:{fontWeight:"normal"},children:["Serial number: ",h.serialNumber]})})]})):(o&&console.log("QRDiv rendering unknown state"),null):(o&&console.log("QRDiv rendering offline state"),e.jsxs(Me,{style:Se&&W?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(Fe,{style:{height:"30px",justifyContent:"space-between"},children:e.jsx(De,{children:"Server node"})}),e.jsx(St,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(St,{style:{fontWeight:"bold"},children:"Server offline"}),e.jsx(It,{style:{justifyContent:"center"},children:e.jsxs(mt,{style:{fontWeight:"normal"},children:["Serial number: ",h.serialNumber]})})]}))}const Ir=r.memo(Rn);function On({title:n,children:a}){const l=r.useRef(null),[i,s]=r.useState(!1),g=()=>{const t=l.current;if(!t){s(!1);return}s(t.scrollWidth>t.clientWidth)},h=()=>{s(!1)},b={display:"inline-block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};return e.jsx(V,{title:n,open:i,disableHoverListener:!0,disableFocusListener:!0,disableTouchListener:!0,slotProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("span",{ref:l,onMouseEnter:g,onMouseLeave:h,style:b,children:a})})}function _n(n,a,l){const i=n?.[l],s=a?.[l];return i==null&&s==null?0:i==null?-1:s==null?1:typeof i=="boolean"&&typeof s=="boolean"?i===s?0:i?1:-1:typeof i=="number"&&typeof s=="number"?i-s:String(i).localeCompare(String(s))}function Hn({name:n,title:a,columns:l,rows:i,getRowKey:s,footerLeft:g,footerRight:h,onRowClick:b}){const t=r.useRef(new WeakMap),N=r.useRef(1),I=c=>{if(typeof s=="string"&&c&&c[s]!=null)return c[s];if(typeof s=="function"){const E=s(c);if(E!=null)return E}const v=l?.[0]?.id;if(v&&c&&c[v]!=null)return c[v];console.warn(`MbfTable(${n}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let _=t.current.get(c);return _||(_=`rk_${N.current++}`,t.current.set(c,_)),_},[W,k]=r.useState(localStorage.getItem(`${n}_table_order_by`)||null),[B,K]=r.useState(localStorage.getItem(`${n}_table_order`)||null),[Z,q]=r.useState(!1),[m,p]=r.useState(()=>{try{const c=localStorage.getItem(`${n}_column_visibility`);if(c)return JSON.parse(c)}catch{}return{}}),u=r.useMemo(()=>{const c={};for(const v of l)v.hidden||(c[v.id]=v.required?!0:m[v.id]!==!1);return c},[l,m]),D=r.useMemo(()=>{if(!W||!B)return i;const c=l.find(_=>_.id===W);if(!c||c.noSort)return i;const v=i.map((_,E)=>({el:_,index:E}));return v.sort((_,E)=>{let ae;return typeof c.comparator=="function"?ae=c.comparator(_.el,E.el):ae=_n(_.el,E.el,W),ae!==0?B==="asc"?ae:-ae:_.index-E.index}),v.map(_=>_.el)},[i,W,B,l]),M=c=>{if(W!==c||!W){k(c),K("asc"),localStorage.setItem(`${n}_table_order_by`,c),localStorage.setItem(`${n}_table_order`,"asc");return}if(B==="asc"){K("desc"),localStorage.setItem(`${n}_table_order`,"desc");return}k(null),K(null),localStorage.removeItem(`${n}_table_order_by`),localStorage.removeItem(`${n}_table_order`)},T=()=>{q(!Z)},te=c=>{p(v=>{const _=l.find(we=>we.id===c);if(_&&_.required)return v;const E=u[c]!==!1,ae={...v};E?ae[c]=!1:delete ae[c];try{localStorage.setItem(`${n}_column_visibility`,JSON.stringify(ae))}catch{}return ae})},ce=()=>{p({});try{localStorage.removeItem(`${n}_column_visibility`)}catch{}q(!1)},[w,d]=r.useState(!1);return w?null:(o&&console.log(`Rendering table ${n}${W&&B?` ordered by ${W}:${B}`:""}`),e.jsxs("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",height:"100%",overflow:"hidden"},children:[e.jsxs(Be,{open:Z,onClose:(c,v)=>{v==="backdropClick"||v==="escapeKeyDown"||T()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Qe,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:`Configure ${n} columns`})]})}),e.jsx(Ge,{children:e.jsx(lo,{children:l.filter(c=>!c.hidden).map(c=>e.jsx(lt,{control:e.jsx(Xe,{disabled:!!c.required,checked:c.required?!0:u[c.id]!==!1,onChange:()=>te(c.id)}),label:c.label},c.id))})}),e.jsxs(Ze,{children:[e.jsx(me,{onClick:ce,children:"Reset"}),e.jsx(me,{variant:"contained",onClick:c=>{if(c?.currentTarget&&typeof c.currentTarget.blur=="function")try{c.currentTarget.blur()}catch{}const v=document.activeElement;if(v&&v instanceof HTMLElement&&typeof v.blur=="function")try{v.blur()}catch{}T()},children:"Close"})]})]}),e.jsxs(Fe,{style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx(De,{children:n}),a&&e.jsx(De,{children:a}),e.jsx(st,{close:()=>d(!0),children:e.jsx(X,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:c=>{if(c?.currentTarget?.blur)try{c.currentTarget.blur()}catch{}T()},"aria-label":"Configure Columns",children:e.jsx(V,{title:`Configure ${n} columns`,children:e.jsx(be,{path:Ko,size:"20px",color:"var(--header-text-color)"})})})})]}),e.jsx(Ue,{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${n} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:l.map(c=>{if(c.hidden||!c.required&&u[c.id]===!1)return null;const v=!c.noSort,_=v&&W===c.id&&!!B;return e.jsxs("th",{onClick:v?()=>M(c.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:c.minWidth,maxWidth:c.maxWidth,textAlign:c.align||"left",cursor:v?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:c.maxWidth?"nowrap":void 0,overflow:c.maxWidth?"hidden":void 0,textOverflow:c.maxWidth?"ellipsis":void 0},"aria-sort":v?_?B==="asc"?"ascending":"descending":"none":void 0,children:[c.label,_&&e.jsxs("span",{style:{marginLeft:6},children:[B==="asc"&&e.jsx(be,{path:Yo,size:"15px"}),B==="desc"&&e.jsx(be,{path:Zo,size:"15px"})]})]},c.id)})})}),e.jsx("tbody",{children:D.map((c,v)=>{const _=I(c);return e.jsx("tr",{className:v%2===0?"table-content-even":"table-content-odd",onClick:b?E=>b(c,_,E):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:b?"pointer":void 0},children:l.map(E=>{if(E.hidden||!E.required&&u[E.id]===!1)return null;const ae=c[E.id],we=typeof E.render=="function"?E.render(ae,_,c,E):typeof ae=="boolean"?e.jsx(Xe,{checked:ae,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):E.format&&typeof ae=="number"?E.format(ae):ae!=null?String(ae):null,x=!!E.tooltip&&E.maxWidth!==void 0&&E.maxWidth!==null&&ae!==void 0&&ae!==null&&we!==null?e.jsx(On,{title:String(ae),children:we}):we;return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:E.align||"left",padding:"5px 10px",margin:"0",maxWidth:E.maxWidth,whiteSpace:E.maxWidth?"nowrap":void 0,overflow:E.maxWidth?"hidden":void 0,textOverflow:E.maxWidth?"ellipsis":void 0},children:x},E.id)})},_)})})]})}),(g||h)&&e.jsxs(It,{style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx(mt,{style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:g}),e.jsx(mt,{style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:h})]})]}))}function En(n){return r.memo(n)}const Dt=En(Hn),Ur=n=>n.replace("git+","").replace(".git","").trim(),Vn=n=>{let a=Ur(n);return a.startsWith("git://")&&(a=`https://${a.slice(6)}`),a.startsWith("ssh://git@github.com/")&&(a=`https://github.com/${a.slice(21)}`),a.startsWith("git@github.com:")&&(a=`https://github.com/${a.slice(15).replace(":","/")}`),a},An=n=>{if(typeof n=="string")return n.trim()||null;if(!n||typeof n!="object")return null;const a=n.url;return typeof a=="string"&&a.trim()||null},Un=()=>{try{const n=window.localStorage.getItem(ee.searchPluginsTotal);if(!n)return{};const a=JSON.parse(n);if(!a||typeof a!="object")return{};const l={};for(const[i,s]of Object.entries(a)){if(!i||!s||typeof s!="object")continue;const g=s;typeof g.total=="number"&&typeof g.asOf=="string"&&(l[i]={total:g.total,asOf:g.asOf})}return l}catch{return{}}},zn=n=>{try{window.localStorage.setItem(ee.searchPluginsTotal,JSON.stringify(n))}catch{}},qn=()=>{try{const n=window.localStorage.getItem(ee.searchPluginsMeta);if(!n)return{};const a=JSON.parse(n);if(!a||typeof a!="object")return{};const l={};for(const[i,s]of Object.entries(a)){if(!i||!s||typeof s!="object")continue;const g=s;if(typeof g.asOf!="string")continue;const h=typeof g.homepage=="string"?g.homepage:null,b=typeof g.help=="string"?g.help:null,t=typeof g.changelog=="string"?g.changelog:null;l[i]={homepage:h,help:b,changelog:t,asOf:g.asOf}}return l}catch{return{}}},Bn=n=>{try{window.localStorage.setItem(ee.searchPluginsMeta,JSON.stringify(n))}catch{}},Qn=()=>{try{const n=window.localStorage.getItem(ee.searchPluginsVersions);if(!n)return{};const a=JSON.parse(n);if(!a||typeof a!="object")return{};const l={};for(const[i,s]of Object.entries(a)){if(!i||!s||typeof s!="object")continue;const g=s;if(typeof g.asOf!="string"||!Array.isArray(g.versions))continue;const h=g.versions.filter(b=>typeof b=="string");l[i]={versions:h,asOf:g.asOf}}return l}catch{return{}}},Gn=n=>{try{window.localStorage.setItem(ee.searchPluginsVersions,JSON.stringify(n))}catch{}},Jn=({open:n,onClose:a,onSelect:l,onVersions:i})=>{const[s,g]=r.useState(""),h=r.useRef(""),b=r.useRef(!1),t=r.useRef(null),[N,I]=r.useState([]),[W,k]=r.useState(!1),[B,K]=r.useState(!1),[Z,q]=r.useState(!1),[m,p]=r.useState({done:0,total:0}),[u,D]=r.useState(null),M=r.useRef({}),T=()=>{const A=document.activeElement;A&&A instanceof HTMLElement&&A.blur()},te=A=>{const x=A.getFullYear().toString(),y=(A.getMonth()+1).toString().padStart(2,"0"),P=A.getDate().toString().padStart(2,"0");return`${x}-${y}-${P}`},ce=r.useCallback(async(A,x)=>{const y=M.current[A];if(!!y&&y.asOf===x&&Array.isArray(y.versions)&&y.versions.length>0&&y.versions[0]==="latest")return o&&console.log(`[SearchPluginsDialog] versions cache hit for ${A} (${y.versions.length.toString()})`),y.versions;y&&y.asOf===x&&y.versions.length>0&&y.versions[0]!=="latest"&&o&&console.log(`[SearchPluginsDialog] versions cache ignored (old format) for ${A} (asOf=${x})`);const F=`https://registry.npmjs.org/${encodeURIComponent(A)}`;o&&console.log(`[SearchPluginsDialog] fetching versions for ${A} from: ${F}`);const S=await fetch(F,{signal:t.current?.signal});if(!S.ok)return o&&console.log(`[SearchPluginsDialog] versions fetch failed for ${A}: ${S.status.toString()} ${S.statusText}`),[];const re=await S.json(),Ce=Object.keys(re.versions??{}),$=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});Ce.sort((z,f)=>$.compare(z,f)).reverse();const C=re["dist-tags"]??{},L=typeof C?.dev=="string"&&String(C.dev).trim().length>0,U=Ce.slice(0,20),Q=["latest"];return L&&Q.push("dev"),Q.push(...U),o&&console.log(`[SearchPluginsDialog] fetched versions for ${A} (tags: latest${L?", dev":""}; latestVersions=${U.length.toString()}; allVersions=${Ce.length.toString()}):`,Q),M.current[A]={versions:Q,asOf:x},Gn(M.current),Q},[]),w=A=>new Intl.NumberFormat().format(A),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:A=>typeof A=="number"?w(A):""},{label:"Total",id:"total",align:"right",maxWidth:120,render:A=>typeof A=="number"?w(A):""},{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:(A,x,y,P)=>e.jsxs("div",{style:{margin:"0",padding:"0",gap:"4px",display:"flex",flexDirection:"row",justifyContent:"center"},children:[e.jsx(V,{title:y.homepage?"Open the plugin homepage":"No homepage available",children:e.jsx("span",{children:e.jsx(X,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"var(--main-icon-color)"},disabled:!y.homepage,onClick:F=>{if(F.stopPropagation(),!!y.homepage)try{const S=new URL(y.homepage);(S.protocol==="http:"||S.protocol==="https:")&&window.open(S.toString(),"_blank")}catch{}},size:"small",children:e.jsx(Fr,{})})})}),e.jsx(V,{title:y.help?"Open the plugin help":"No help available",children:e.jsx("span",{children:e.jsx(X,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"var(--main-icon-color)"},disabled:!y.help,onClick:F=>{if(F.stopPropagation(),!!y.help)try{const S=new URL(y.help);(S.protocol==="http:"||S.protocol==="https:")&&window.open(S.toString(),"_blank")}catch{}},size:"small",children:e.jsx(dr,{})})})}),e.jsx(V,{title:y.changelog?"Open the plugin changelog":"No changelog available",children:e.jsx("span",{children:e.jsx(X,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"var(--main-icon-color)"},disabled:!y.changelog,onClick:F=>{if(F.stopPropagation(),!!y.changelog)try{const S=new URL(y.changelog);(S.protocol==="http:"||S.protocol==="https:")&&window.open(S.toString(),"_blank")}catch{}},size:"small",children:e.jsx(Jt,{})})})})]})}];r.useEffect(()=>{if(!n){b.current=!1,h.current="",t.current?.abort(),t.current=null,I([]),k(!1),K(!1),q(!1),p({done:0,total:0}),D(null),g("");return}if(b.current)return;b.current=!0;const A=new AbortController;return t.current=A,M.current=Qn(),(async()=>{const x="matterbridge-",P=`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(x)}&size=250`,F=re=>new Promise(Ce=>setTimeout(Ce,re)),S=re=>{if(!Array.isArray(re.downloads))return null;let Ce=0,$=!1;for(const C of re.downloads)typeof C?.downloads=="number"&&(Ce+=C.downloads,$=!0);return $?Ce:null};try{k(!0),D(null);const re=G=>{const R=String(G??"").trim().toLowerCase();return R?!!(R==="github actions"||R==="github-actions"||R==="github-actions[bot]"||R.includes("github-actions")||R.endsWith("[bot]")):!1},Ce=G=>{const R=(G.maintainers??[]).map(se=>(se.username??"").trim()).filter(Boolean),oe=(G.publisher?.username??"").trim(),he=R.find(se=>!re(se));return he||(oe&&!re(oe)?oe:R[0]??oe??"")},$=await fetch(P,{signal:A.signal});if(!$.ok)throw new Error(`npm registry request failed: ${$.status} ${$.statusText}`);const C=await $.json(),L="luligu",U=G=>G.publisher?.username?.toLowerCase()===L||(G.maintainers??[]).some(R=>R.username?.toLowerCase()===L),z=(C.objects??[]).filter(G=>!!G?.package&&typeof G.package.name=="string").filter(G=>G.package?.name?.startsWith(x)).filter(G=>!cr.includes(G.package?.name??"")).sort((G,R)=>{const oe=U(G.package??{}),he=U(R.package??{});return oe!==he?oe?-1:1:(G.package?.name??"").localeCompare(R.package?.name??"")}).map(G=>{const R=G.package,oe=R.name??"",he=Ce(R),se=typeof G.downloads?.monthly=="number"?G.downloads.monthly:null,Ee=(R.links?.npm??"").trim(),yt=((R.links?.homepage??"").trim()||Ee||(oe?`https://www.npmjs.com/package/${encodeURIComponent(oe)}`:"")).trim()||null;return{name:oe,version:R.version??"",downloads:se,total:null,description:R.description??"",author:he,official:U(R),homepage:yt,help:null,changelog:null}}),f=te(new Date),ue=Un(),J=qn(),xe=z.map(G=>{const R=ue[G.name];return!R||typeof R.total!="number"?G:(o&&console.log(`[SearchPluginsDialog] total downloads loaded from cache for ${G.name} (asOf=${R.asOf}):`,R.total),{...G,total:R.total})}).map(G=>{const R=J[G.name];if(!R||R.asOf!==f)return G;const oe=R.homepage??G.homepage,he=R.help,se=R.changelog;return o&&(he||se||oe&&oe!==G.homepage)&&console.log(`[SearchPluginsDialog] metadata loaded from cache for ${G.name} (asOf=${R.asOf}):`,{homepage:oe,help:he,changelog:se}),{...G,homepage:oe,help:he,changelog:se}});I(xe);const de=z.map(G=>G.name).filter(G=>{const R=M.current[G];return!R||R.asOf!==f||R.versions.length===0});o&&console.log(`[SearchPluginsDialog] versions prefetch queue (${de.length.toString()}):`,de);const Le=1,Oe=200;let ve=0;const ge=async()=>{for(;ve<de.length;){if(A.signal.aborted)return;const G=ve;ve+=1;const R=de[G];if(R)try{const oe=await ce(R,f);o&&oe.length>0&&console.log(`[SearchPluginsDialog] versions fetched for ${R} (${oe.length.toString()}):`,oe.slice(0,5))}catch(oe){if(oe instanceof DOMException&&oe.name==="AbortError")return}finally{A.signal.aborted||await F(Oe)}}};Promise.all(Array.from({length:Math.min(Le,z.length)},()=>ge()));const pe=z.map(G=>G.name).filter(G=>{const R=J[G],oe=!!R&&R.asOf===f,he=!!R&&!!R.help&&!!R.changelog,se=!oe||!he;return!se&&o&&console.log(`[SearchPluginsDialog] metadata fetch skipped (cache fresh+complete) for ${G} (asOf=${R.asOf}).`),oe&&!he&&o&&console.log(`[SearchPluginsDialog] metadata fetch forced (cache incomplete) for ${G} (asOf=${R.asOf}).`),se}),_e=new Set(pe),He=async(G,R)=>{const oe=`https://registry.npmjs.org/${encodeURIComponent(G)}/latest`;try{const he=await fetch(oe,{signal:A.signal});if(!he.ok)return null;const se=await he.json(),Ee=typeof se.homepage=="string"&&se.homepage.includes("http")?Ur(se.homepage):null,nt=typeof se.help=="string"&&se.help.startsWith("http")?se.help.trim():null,yt=typeof se.changelog=="string"&&se.changelog.startsWith("http")?se.changelog.trim():null,gr=An(se.repository),er=gr?Vn(gr):null,jt=er&&er.includes("http")?er:null,tr=Ee||jt||R||null,Gr=nt||(jt?`${jt}/blob/main/README.md`:null)||tr||null,Jr=yt||(jt?`${jt}/blob/main/CHANGELOG.md`:null)||tr||null;return{homepage:tr,help:Gr,changelog:Jr}}catch(he){return he instanceof DOMException&&he.name==="AbortError",null}},ot=1,j=250;let ne=0;const We=async()=>{for(;ne<pe.length;){if(A.signal.aborted)return;const G=ne;ne+=1;const R=pe[G];if(!R||!_e.has(R))continue;_e.delete(R);const oe=z.find(se=>se.name===R)?.homepage??null,he=await He(R,oe);if(A.signal.aborted)return;he&&(I(se=>se.map(Ee=>Ee.name===R?{...Ee,homepage:he.homepage??Ee.homepage,help:he.help,changelog:he.changelog}:Ee)),J[R]={homepage:he.homepage,help:he.help,changelog:he.changelog,asOf:f},Bn(J)),A.signal.aborted||await F(j)}};Promise.all(Array.from({length:Math.min(ot,z.length)},()=>We()));const ze="2020-01-01",Ke=z.map(G=>G.name).filter(G=>{const R=ue[G],oe=!R||R.asOf!==f;return oe||o&&console.log(`[SearchPluginsDialog] total downloads fetch skipped (cache fresh) for ${G} (asOf=${R.asOf}).`),oe}),Te=new Set(Ke),at=Ke.length;p({done:0,total:at}),q(at>0);const $t=async G=>{const R=`https://api.npmjs.org/downloads/range/${ze}:${f}/${encodeURIComponent(G)}`;for(let oe=0;oe<3;oe+=1){const he=await fetch(R,{signal:A.signal});if(he.ok){const se=await he.json();return S(se)}if(he.status===404)return null;if(he.status===429){const se=he.headers.get("retry-after"),Ee=se?Number(se):NaN,nt=Number.isFinite(Ee)?Ee*1e3:2e3*(oe+1);await F(nt);continue}return null}return null},Yt=1,Zt=500;let bt=0,vt=0;const Xt=async()=>{for(;bt<Ke.length;){if(A.signal.aborted)return;const G=bt;bt+=1;const R=Ke[G];if(R&&Te.has(R)){Te.delete(R);try{o&&console.log(`[SearchPluginsDialog] fetching total downloads for ${R} (range ${ze}:${f})...`);const oe=await $t(R);if(A.signal.aborted)return;o&&console.log(`[SearchPluginsDialog] total downloads fetched for ${R}:`,oe),I(he=>he.map(se=>se.name===R?{...se,total:oe}:se)),typeof oe=="number"&&(ue[R]={total:oe,asOf:f},zn(ue),o&&console.log(`[SearchPluginsDialog] total downloads saved to localStorage for ${R} (asOf=${f}):`,oe))}catch(oe){if(oe instanceof DOMException&&oe.name==="AbortError")return}finally{vt+=1,p({done:vt,total:at}),A.signal.aborted||await F(Zt)}}}};Promise.all(Array.from({length:Math.min(Yt,z.length)},()=>Xt())).finally(()=>{A.signal.aborted||q(!1)}),o&&console.log(`[SearchPluginsDialog] npm packages starting with "${x}" (filtered/sorted):`,z)}catch(re){if(re instanceof DOMException&&re.name==="AbortError")return;console.error("[SearchPluginsDialog] npm registry fetch error:",re),D(re instanceof Error?re.message:String(re))}finally{k(!1)}})(),()=>A.abort()},[n,ce]);const c=async()=>{T();const A=h.current||s;if(!(!A||B))try{K(!0);const x=te(new Date),y=await ce(A,x);o&&console.log(`[SearchPluginsDialog] passing versions to onVersions() for ${A} (${y.length.toString()}):`,y),i(y),K(!1),l(A)}catch(x){if(x instanceof DOMException&&x.name==="AbortError")return;console.error("[SearchPluginsDialog] npm versions fetch error:",x),i([]),K(!1),l(A)}},v=()=>{T(),a(),i([])},_=N.reduce((A,x)=>A+(typeof x.downloads=="number"?x.downloads:0),0),E=N.reduce((A,x)=>(typeof x.total=="number"&&(A.total+=x.total,A.hasAny=!0),A),{total:0,hasAny:!1}),ae=Z?` Totals: ${m.done.toString()}/${m.total.toString()} fetched`:"",we=E.hasAny?w(E.total):"...";return e.jsxs(Be,{open:n,onClose:()=>{T(),a()},maxWidth:!1,fullWidth:!0,slotProps:{paper:{sx:{width:"75vw",height:"75vh",maxWidth:"75vw",maxHeight:"75vh",display:"flex",flexDirection:"column"}}},children:[e.jsx(Qe,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Search Plugins"})]})}),e.jsx(Ge,{dividers:!0,sx:{padding:0,flex:"1 1 auto",minHeight:0},children:e.jsx("div",{style:{height:"100%",width:"100%",display:"flex",flexDirection:"column",minHeight:0},children:W?e.jsx("div",{style:{padding:"20px"},children:"Loading npm registry..."}):u?e.jsx("div",{style:{padding:"20px"},children:u}):e.jsx(Dt,{name:"Search plugins",rows:N,columns:d,getRowKey:"name",onRowClick:(A,x,y)=>{h.current=A.name,g(A.name),y.detail===2&&c()},footerLeft:`Total packages: ${N.length.toString()} Total downloads: ${w(_)} / ${we}${ae}`,footerRight:s?`Selected: ${s}`:""})})}),e.jsxs(Ze,{sx:{justifyContent:"center",gap:1.5,flexWrap:"wrap"},children:[e.jsx(V,{title:"Select the plugin and close the dialog. Double-click a row to select and close the dialog.",children:e.jsx(me,{variant:"contained",onClick:c,disabled:!(h.current||s)||B,children:"Select"})}),e.jsx(V,{title:"Close the dialog without selecting a plugin.",children:e.jsx(me,{onClick:v,children:"Cancel"})})]})]})},cr=["matterbridge-","matterbridge-plugin-template","matterbridge-dyson","matterbridge-irobot","matterbridge-tuya","matterbridge-mqtt","matterbridge-matter","matterbridge-security","matterbridge-automations","matterbridge-securitysystem","matterbridge-adapter"];function Kn(){const{mobile:n,showSnackbarMessage:a}=r.useContext(Re),{logMessage:l,sendMessage:i,getUniqueId:s}=r.useContext(Ie),[g,h]=r.useState("matterbridge-"),[b,t]=r.useState(["latest","dev"]),[N,I]=r.useState("latest"),[W,k]=r.useState(!1),B=r.useRef(s()),K=x=>{const y=String(x??"").trim();if(!y)return{name:"",specifier:null};if(y.startsWith("@")){const F=y.lastIndexOf("@");if(F>0){const S=y.slice(0,F),re=y.slice(F+1);if(S.includes("/")&&re)return{name:S,specifier:re}}return{name:y,specifier:null}}const P=y.indexOf("@");if(P>0){const F=y.slice(0,P),S=y.slice(P+1);return S?{name:F,specifier:S}:{name:F,specifier:null}}return{name:y,specifier:null}},Z=()=>{const{name:x,specifier:y}=K(g);return x?y?`${x}@${y}`:N?`${x}@${N}`:x:""},q=x=>{x.preventDefault(),k(!0)},m=()=>{k(!1)},p=x=>{x.preventDefault(),k(!1);const y=x.dataTransfer.files[0];if(y){l("Plugins",`Installing package ${y.name}. Please wait...`);const P=new FormData;P.append("file",y),P.append("filename",y.name),fetch("./api/uploadpackage",{method:"POST",body:P}).then(F=>F.text()).then(F=>{l("Plugins",`Server response: ${F}`)}).catch(F=>{console.error("Error uploading plugin file:",F),l("Plugins",`Error installing package ${F}`)})}},u=x=>{const y=x.target.files&&x.target.files[0];if(y){l("Plugins",`Uploading package ${y.name}`);const P=new FormData;P.append("file",y),P.append("filename",y.name),fetch("./api/uploadpackage",{method:"POST",body:P}).then(F=>F.text()).then(F=>{l("Plugins",`Server response: ${F}`)}).catch(F=>{console.error("Error uploading plugin file:",F),l("Plugins",`Error uploading package ${F}`)})}},D=()=>{const x=Z();if(x){if(cr.includes(x.split("@")[0])){a(`Installation of plugin "${x}" is blocked by the ignore list.`);return}i({id:B.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:x,restart:!1}})}},M=()=>{i({id:B.current,sender:"InstallPlugins",method:"/api/uninstall",src:"Frontend",dst:"Matterbridge",params:{packageName:g}})},T=()=>{document.getElementById("file-upload")?.click()},te=()=>{if(cr.includes(g.split("@")[0])){a(`Addition of plugin "${g}" is blocked by the ignore list.`);return}i({id:B.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:g}})},ce=x=>{x.preventDefault(),o&&console.log("Right-clicked Upload button")},w=x=>{x.preventDefault(),o&&console.log("Right-clicked Add button")},[d,c]=r.useState(!1),v=()=>{c(!0),o&&console.log("Dialog opened for selection")},_=()=>{h("matterbridge-"),c(!1),o&&console.log("Dialog closed without selection")},E=x=>{h(x),c(!1),o&&console.log("Select plugin:",x)},ae=x=>{t(x),I(x.includes("latest")?"latest":x[0]??""),o&&console.log("Select plugin versions:",x)},[we,A]=r.useState(!1);return o&&console.log("HomeInstallAddPlugins rendering..."),we?null:e.jsxs(Me,{children:[e.jsxs(Fe,{children:[e.jsx(De,{children:"Install plugins"}),e.jsx(st,{close:()=>A(!0)})]}),e.jsxs(Ue,{onDragOver:q,onDragLeave:m,onDrop:p,style:Se&&n?{flexWrap:"wrap",alignItems:"center",gap:"10px"}:{flexWrap:"wrap",alignItems:"center",gap:"20px"},children:[e.jsx(Jn,{open:d,onClose:_,onSelect:E,onVersions:ae}),e.jsxs("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(V,{title:"Provide the npm name or the local path of the plugin to install, uninstall, or add",children:e.jsx(ke,{value:g,onChange:x=>{const y=x.target.value;t(["latest","dev"]),I("latest"),h(y)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0})}),b.length>0&&e.jsx(V,{title:"Select the npm tag/version to install",children:e.jsx("span",{children:e.jsxs(pr,{size:"small",style:{minWidth:"150px"},children:[e.jsx(Ut,{id:"plugin-version-label",children:"Tag or version"}),e.jsx(rt,{labelId:"plugin-version-label",id:"plugin-version",value:N,label:"Tag or version",onChange:x=>I(String(x.target.value??"")),children:b.map(x=>e.jsx(H,{value:x,children:x},x))})]})})}),e.jsx(V,{title:"Search on npm the plugin to install",children:e.jsx(X,{size:"large",onClick:v,children:e.jsx(ao,{fontSize:"inherit"})})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsx(V,{title:"Install or update a plugin from npm",children:e.jsxs(me,{onClick:D,endIcon:e.jsx(Ae,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Install"]})}),e.jsx(V,{title:"Uninstall and remove a plugin",children:e.jsxs(me,{onClick:M,endIcon:e.jsx(Nr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Uninstall"]})}),e.jsx(V,{title:"Upload and install a plugin from a tarball",children:e.jsxs(me,{onClick:T,onContextMenu:ce,endIcon:e.jsx(co,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Upload"]})}),e.jsx(V,{title:"Add an already installed plugin or a plugin from a local path",children:e.jsxs(me,{onClick:te,onContextMenu:w,endIcon:e.jsx(zt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Add"]})}),e.jsx("input",{id:"file-upload",type:"file",accept:".tgz",style:{display:"none"},onChange:u})]})]})]})}const Yn=r.memo(Kn);function dt({status:n,enabledText:a="Enabled",disabledText:l=void 0,tooltipText:i=void 0,onClick:s}){if(n===void 0)return null;{const g=e.jsx("div",{className:n?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:s,children:n?a:l??a});return i!==void 0?e.jsx(V,{title:i,children:g}):g}}function Mr(n){return n.id!==0&&n.src==="Matterbridge"&&n.dst==="Frontend"}const pt={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},_t={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Dr={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Zn={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},Xn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Ye={padding:"0px",margin:"0px"},ei="5px 10px 5px 10px",Ht={},Pe={},Et={},Vt={};let ut=[],nr=[];function ir(n,a){const l=n?.properties;if(!l||typeof l!="object")return!1;const i=l[a];return!i||typeof i!="object"?!1:typeof i.type=="string"}function gt(n){const a=n.items;return a!==void 0&&typeof a=="object"&&!Array.isArray(a)}const ti=({open:n,onClose:a,plugin:l})=>{const{sendMessage:i,addListener:s,removeListener:g,getUniqueId:h}=r.useContext(Ie),b=r.useRef(h()),t=r.useRef({}),N=r.useRef({}),[I,W]=r.useState(l.configJson),[k,B]=r.useState(l.schemaJson),[K,Z]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[q,m]=r.useState("");let p={};r.useEffect(()=>{const $=C=>{C.src==="Matterbridge"&&C.dst==="Frontend"&&(Mr(C)&&C.id===b.current&&C.method==="/api/select/devices"&&C.response&&(o&&console.log(`ConfigPluginDialog (id: ${C.id}) received ${C.response.length} /api/select/devices:`,C.response),ut=C.response),Mr(C)&&C.id===b.current&&C.method==="/api/select/entities"&&C.response&&(o&&console.log(`ConfigPluginDialog (id: ${C.id}) received ${C.response.length} /api/select/entities:`,C.response),nr=C.response))};if(s($,b.current),o&&console.log("ConfigPluginDialog added WebSocket listener id:",b.current),I&&k&&k.properties){const C=(L,U,Q=[])=>{!L||typeof L!="object"||(L.properties&&Object.keys(L.properties).forEach(z=>{const f=L.properties?.[z],ue=[...Q,z];Object.keys(f).forEach(J=>{if(J.startsWith("ui:")){let O=U;ue.forEach(xe=>{O[xe]||(O[xe]={}),O=O[xe]}),O[J]=f[J],delete f[J]}}),C(f,U,ue)}),["oneOf","anyOf","allOf"].forEach(z=>{Array.isArray(L[z])&&L[z].forEach(f=>{C(f,U,Q)})}),L.items&&typeof L.items=="object"&&C(L.items,U,Q))};C(k,K),Z(K),t.current=k,N.current=K}return l.name&&l.configJson&&l.schemaJson&&(W(l.configJson),B(l.schemaJson),i({id:b.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),i({id:b.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),o&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',l.name)),()=>{g($),o&&console.log("ConfigPluginDialog removed WebSocket listener")}},[s,I,l,g,k,i,K]);const u=($,C)=>{p=$.formData},D=$=>{o&&console.log("ConfigPluginDialog handleSaveChanges:",$.formData),W($.formData),l.configJson=$.formData,l.restartRequired=!0,i({id:b.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:$.formData.name,formData:$.formData}}),a()};function M($){const{id:C,label:L,onKeyChange:U,onDropPropertyClick:Q,disabled:z,schema:f,children:ue,registry:J,readonly:O,required:xe}=$,{templates:de}=J,{RemoveButton:Le}=de.ButtonTemplates;if(!(In in f))return e.jsx(fe,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:ue});const ve=({target:ge})=>U(ge&&ge.value);return e.jsxs(fe,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(ke,{id:`${C}-key`,name:`${C}-key`,required:xe,disabled:z||O,defaultValue:L,onBlur:O?void 0:ve,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(fe,{sx:{flex:1},children:ue}),e.jsx(Le,{disabled:z||O,onClick:Q(L),registry:J})]})}function T($){const{children:C,description:L,displayLabel:U,errors:Q,help:z,hidden:f,registry:ue,uiSchema:J}=$,O=Sn(J),xe=kn("WrapIfAdditionalTemplate",ue,O);return f?e.jsx("div",{style:{display:"none"},children:C}):e.jsx(fe,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(xe,{...$,children:[U===!0&&L,C,Q,z]})})}function te($){const{description:C}=$;return C?e.jsx(je,{sx:_t,children:C}):null}function ce($){const{required:C,title:L}=$;return L?e.jsx(fe,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(je,{sx:pt,children:["Title ",L," ",C&&e.jsx("mark",{children:"***"})]})}):null}function w($){const{help:C}=$;return C?e.jsx(fe,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(je,{sx:Zn,children:C})}):null}function d($){const{errors:C}=$;return C?e.jsxs(fe,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(je,{color:"error",sx:Xn,children:"Please fix the following errors:"}),e.jsx(wt,{children:C.map((L,U)=>e.jsxs(po,{children:[e.jsx(Y,{children:e.jsx(uo,{color:"error"})}),e.jsx(le,{primary:L.stack})]},U))})]}):null}function c($){const{errors:C}=$;return C?e.jsx(fe,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:C.map((L,U)=>e.jsxs(je,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",L]},U))}):null}function v($){const{id:C,name:L,_schema:U,_uiSchema:Q,value:z,options:f,label:ue,type:J,placeholder:O,required:xe,disabled:de,readonly:Le,autofocus:Oe,onChange:ve,onChangeOverride:ge,onBlur:pe,onFocus:_e,_rawErrors:He,_hideError:ot,_registry:j,_formContext:ne}=$,We=({target:{value:Te}})=>ve(Te===""?f.emptyValue:Te),ze=({target:Te})=>pe(C,Te&&Te.value),Ke=({target:Te})=>_e(C,Te&&Te.value);return e.jsx(fe,{sx:{padding:"0px",margin:"0px"},children:e.jsx(ke,{id:C,name:C,label:O&&O!==""?ue:void 0,variant:"outlined",placeholder:O&&O!==""?O:ue,required:xe,disabled:de||Le,autoFocus:Oe,value:z||z===0?z:"",type:J,autoComplete:J==="password"?"current-password":L,onChange:ge||We,onBlur:ze,onFocus:Ke,fullWidth:!0})})}function _($){return console.log("ArrayFieldTitleTemplate:",$),null}function E($){return console.log("ArrayFieldDescriptionTemplate:",$),null}function ae($){return console.log("ArrayFieldItemTemplate:",$),null}function we($){const{canAdd:C,onAddClick:L,schema:U,title:Q}=$,[z,f]=r.useState(!1),[ue,J]=r.useState(!1),[O,xe]=r.useState(!1),[de,Le]=r.useState(""),Oe=j=>{Le(j.target.value)},ve=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",de,"selectDevices:",ut),f(!z)},ge=()=>{o&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",de,"selectEntities:",nr),J(!ue)},pe=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",de,"selectDevices:",ut),xe(!O)},_e=j=>{f(!1),U.selectFrom==="serial"&>(U)?U.items.default=j.serial:U.selectFrom==="name"&>(U)&&(U.items.default=j.name),L()},He=j=>{J(!1),U.selectEntityFrom==="name"&>(U)?U.items.default=j.name:U.selectEntityFrom==="description"&>(U)&&(U.items.default=j.description),L()},ot=j=>{xe(!1),U.selectDeviceEntityFrom==="name"&>(U)?U.items.default=j.name:U.selectDeviceEntityFrom==="description"&>(U)&&(U.items.default=j.description),L()};return e.jsxs(fe,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[Q&&e.jsxs(fe,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Q&&e.jsx(je,{sx:pt,children:Q}),C&&e.jsxs(fe,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[U.selectFrom&&e.jsx(V,{title:"Add a device from the list",children:e.jsx(X,{onClick:ve,size:"small",color:"primary",sx:Ye,children:e.jsx(Wt,{})})}),U.selectEntityFrom&&e.jsx(V,{title:"Add an entity from the list",children:e.jsx(X,{onClick:ge,size:"small",color:"primary",sx:Ye,children:e.jsx(Wt,{})})}),U.selectDeviceEntityFrom&&e.jsx(V,{title:"Add a device entity from the list",children:e.jsx(X,{onClick:pe,size:"small",color:"primary",sx:Ye,children:e.jsx(Wt,{})})}),e.jsx(V,{title:"Add a new item",children:e.jsx(X,{onClick:L,size:"small",color:"primary",sx:Ye,children:e.jsx(zt,{})})})]})]}),U.description&&e.jsx(je,{sx:_t,children:U.description}),$.items.map(j=>e.jsxs(fe,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(fe,{sx:{flexGrow:1,marginRight:"10px"},children:j.children}),e.jsx(X,{disabled:!j.hasMoveUp,onClick:j.onReorderClick(j.index,j.index-1),size:"small",color:"primary",sx:Ye,children:e.jsx(fr,{})}),e.jsx(X,{disabled:!j.hasMoveDown,onClick:j.onReorderClick(j.index,j.index+1),size:"small",color:"primary",sx:Ye,children:e.jsx(hr,{})}),e.jsx(X,{onClick:j.onDropIndexClick(j.index),size:"small",color:"primary",sx:Ye,children:e.jsx(ar,{})})]},j.index)),e.jsxs(Be,{open:z,onClose:ve,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Qe,{children:"Select a device"}),e.jsxs(Ge,{children:[e.jsxs(fe,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(je,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(ke,{fullWidth:!0,variant:"outlined",value:de,onChange:Oe,placeholder:"Enter serial or name"})]}),e.jsx(wt,{dense:!0,children:ut.filter(j=>j.serial.toLowerCase().includes(de.toLowerCase())||j.name.toLowerCase().includes(de.toLowerCase())).map((j,ne)=>e.jsxs(Tt,{onClick:()=>_e(j),sx:Ht,children:[j.icon==="wifi"&&e.jsx(Y,{children:e.jsx(kt,{style:Pe})}),j.icon==="ble"&&e.jsx(Y,{children:e.jsx(Ft,{style:Pe})}),j.icon==="hub"&&e.jsx(Y,{children:e.jsx(Nt,{style:Pe})}),e.jsx(le,{primary:j.name,secondary:j.serial,primaryTypographyProps:{style:Et},secondaryTypographyProps:{style:Vt}})]},ne))})]}),e.jsx(Ze,{children:e.jsx(me,{onClick:ve,children:"Close"})})]}),e.jsxs(Be,{open:ue,onClose:ge,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Qe,{children:"Select an entity"}),e.jsxs(Ge,{children:[e.jsxs(fe,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(je,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(ke,{fullWidth:!0,variant:"outlined",value:de,onChange:Oe,placeholder:"Enter name or description"})]}),e.jsx(wt,{dense:!0,children:nr.filter(j=>j.name.toLowerCase().includes(de.toLowerCase())||j.description.toLowerCase().includes(de.toLowerCase())).map((j,ne)=>e.jsxs(Tt,{onClick:()=>He(j),sx:Ht,children:[j.icon==="wifi"&&e.jsx(Y,{children:e.jsx(kt,{style:Pe})}),j.icon==="ble"&&e.jsx(Y,{children:e.jsx(Ft,{style:Pe})}),j.icon==="hub"&&e.jsx(Y,{children:e.jsx(Nt,{style:Pe})}),j.icon==="component"&&e.jsx(Y,{children:e.jsx(mr,{style:Pe})}),j.icon==="matter"&&e.jsx(Y,{children:e.jsx(xr,{style:Pe})}),e.jsx(le,{primary:j.name,secondary:j.description,primaryTypographyProps:{style:Et},secondaryTypographyProps:{style:Vt}})]},ne))})]}),e.jsx(Ze,{children:e.jsx(me,{onClick:ge,children:"Close"})})]}),e.jsxs(Be,{open:O,onClose:pe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Qe,{children:["Select an entity for ",Q]}),e.jsx(Ge,{children:e.jsx(wt,{dense:!0,children:ut.filter(j=>j.serial===Q||j.name===Q).map(j=>j.entities?.map((ne,We)=>e.jsxs(Tt,{onClick:()=>ot(ne),sx:Ht,children:[ne.icon==="wifi"&&e.jsx(Y,{children:e.jsx(kt,{style:Pe})}),ne.icon==="ble"&&e.jsx(Y,{children:e.jsx(Ft,{style:Pe})}),ne.icon==="hub"&&e.jsx(Y,{children:e.jsx(Nt,{style:Pe})}),ne.icon==="component"&&e.jsx(Y,{children:e.jsx(mr,{style:Pe})}),ne.icon==="matter"&&e.jsx(Y,{children:e.jsx(xr,{style:Pe})}),e.jsx(le,{primary:ne.name,secondary:ne.description,primaryTypographyProps:{style:Et},secondaryTypographyProps:{style:Vt}})]},We)))})}),e.jsx(Ze,{children:e.jsx(me,{onClick:pe,children:"Close"})})]})]})}function A($){const{onAddClick:C,schema:L,properties:U,title:Q,description:z}=$,[f,ue]=r.useState(!1),[J,O]=r.useState(""),xe=ge=>{O(ge.target.value)},de=()=>{ue(!f)},Le=ge=>{o&&console.log(`ObjectFieldTemplate: handleSelectValue value "${ge.serial}" for schema "${L.selectFrom}"`),ue(!1);let pe="";L.selectFrom==="serial"?pe=ge.serial:L.selectFrom==="name"&&(pe=ge.name),m(pe),o&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${pe}"`),C(L)()},Oe=()=>{C(L)()},ve=!L.additionalProperties;return o&&console.log(`ObjectFieldTemplate: isRoot ${ve} newkey "${q}"`),!ve&&q!==""&&(o&&console.log("ObjectFieldTemplate: newkey",q,"properties",U),U.forEach(ge=>{if(ge.name==="newKey"&&ge.content.key==="newKey"&&ge.content.props.name==="newKey"&&ge.content.props.onKeyChange&&q!==""){o&&console.log("ObjectFieldTemplate: newkey onKeyChange",q);const pe=q;m(""),ge.content.props.onKeyChange(pe)}})),e.jsxs(fe,{sx:{margin:"0px",padding:ve?"10px":"5px 10px 0px 10px",border:ve?"none":"1px solid grey"},children:[L.title&&ve&&e.jsx(fe,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(je,{sx:pt,children:L.title})}),Q&&!ve&&e.jsxs(fe,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(je,{sx:pt,children:Q}),e.jsxs(fe,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[L.selectFrom&&e.jsx(V,{title:"Add a device from the list",children:e.jsx(X,{onClick:de,size:"small",color:"primary",sx:Ye,children:e.jsx(Wt,{})})}),e.jsx(V,{title:"Add a new item",children:e.jsx(X,{onClick:Oe,size:"small",color:"primary",sx:Ye,children:e.jsx(zt,{})})})]})]}),L.description&&e.jsx(fe,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(je,{sx:_t,children:L.description})}),U.map(({content:ge,name:pe,hidden:_e})=>!_e&&e.jsxs(fe,{sx:{margin:"0px",marginBottom:"10px",padding:ir(L,pe)&&["object","array"].includes(L.properties[pe].type)?"0px":ei,border:ir(L,pe)&&["object","array"].includes(L.properties[pe].type)?"none":"1px solid grey"},children:[ir(L,pe)&&!["object","array","boolean"].includes(L.properties[pe].type)&&e.jsx(je,{sx:pt,children:L.properties[pe].title||pe}),e.jsx(fe,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:ge})]},pe)),e.jsxs(Be,{open:f,onClose:de,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Qe,{children:"Select a device"}),e.jsxs(Ge,{children:[e.jsxs(fe,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(je,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(ke,{fullWidth:!0,variant:"outlined",value:J,onChange:xe,placeholder:"Enter serial or name"})]}),e.jsx(wt,{dense:!0,children:ut.filter(ge=>ge.serial.toLowerCase().includes(J.toLowerCase())||ge.name.toLowerCase().includes(J.toLowerCase())).map((ge,pe)=>e.jsxs(Tt,{onClick:()=>Le(ge),sx:Ht,children:[ge.icon==="wifi"&&e.jsx(Y,{children:e.jsx(kt,{style:Pe})}),ge.icon==="ble"&&e.jsx(Y,{children:e.jsx(Ft,{style:Pe})}),ge.icon==="hub"&&e.jsx(Y,{children:e.jsx(Nt,{style:Pe})}),e.jsx(le,{primary:ge.name,secondary:ge.serial,primaryTypographyProps:{style:Et},secondaryTypographyProps:{style:Vt}})]},pe))})]}),e.jsx(Ze,{children:e.jsx(me,{onClick:de,children:"Close"})})]})]})}function x($){const{uiSchema:C}=$,{submitText:L,norender:U}=Cn(C);return U?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(me,{type:"submit",variant:"contained",color:"primary",children:L}),e.jsx(me,{variant:"contained",color:"primary",onClick:a,children:"Cancel"})]})}function y($){const{className:C,disabled:L,onClick:U,registry:Q,style:z,uiSchema:f,...ue}=$;return e.jsx(V,{title:"Remove the item",children:e.jsx(X,{disabled:L,size:"small",color:"primary",onClick:U,children:e.jsx(ar,{})})})}function P($){const{className:C,disabled:L,onClick:U,registry:Q,uiSchema:z,...f}=$;return e.jsx(V,{title:"Add an item",children:e.jsx(X,{size:"small",color:"primary",onClick:U,children:e.jsx(zt,{})})})}function F($){const{disabled:C,onClick:L,registry:U,style:Q,uiSchema:z,...f}=$;return e.jsx(V,{title:"Move up the item",children:e.jsx(X,{size:"small",color:"primary",onClick:L,children:e.jsx(fr,{})})})}function S($){const{disabled:C,onClick:L,registry:U,style:Q,uiSchema:z,...f}=$;return e.jsx(V,{title:"Move down the item",children:e.jsx(X,{size:"small",color:"primary",onClick:L,children:e.jsx(hr,{})})})}function re($){const{id:C,name:L,value:U,schema:Q,readonly:z,onChange:f}=$,[ue,J]=r.useState(),O=de=>{o&&console.log(`CheckboxWidget ${L} onChangeField:`,de),J(de&&de!==""?de:void 0)},xe=()=>{o&&console.log(`CheckboxWidget onClick plugin="${l.name}" action="${L}" value="${ue}"`),i({id:b.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name,action:L,value:ue,formData:p,id:C}}),Q.buttonClose===!0?a():Q.buttonSave===!0&&D({formData:I})};return Q.buttonText&&(Q.title||Q.description)?e.jsxs(fe,{sx:{margin:"0px",padding:"5px 0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(je,{sx:Dr,children:Q.title||Q.description}),e.jsx(me,{variant:"contained",color:"primary",onClick:()=>xe(),children:Q.buttonText})]}):Q.buttonField&&(Q.title||Q.description)?e.jsxs(fe,{sx:{margin:"0px",padding:"5px 0px",gap:"20px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(je,{sx:Dr,children:Q.title||Q.description}),e.jsx(ke,{id:L+"-input",name:L,label:Q.textLabel,placeholder:Q.textPlaceholder,onChange:de=>O(de.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(me,{id:L+"-button",variant:"contained",color:"primary",disabled:ue===void 0,onClick:()=>xe(),children:Q.buttonField})]}):e.jsxs(fe,{sx:{margin:"0px",padding:"0px"},children:[L&&e.jsxs(fe,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(je,{sx:pt,children:Q.title||L}),e.jsx(Xe,{checked:U,readOnly:z,onChange:()=>f(!U),sx:{padding:"0px",margin:"0px"}})]}),Q.description&&e.jsx(je,{sx:_t,children:Q.description})]})}function Ce({schema:$,id:C,name:L,options:U,label:Q,hideLabel:z,required:f,disabled:ue,placeholder:J,readonly:O,value:xe,multiple:de,autofocus:Le,onChange:Oe,onBlur:ve,onFocus:ge,errorSchema:pe,rawErrors:_e=[],registry:He,uiSchema:ot,hideError:j,formContext:ne,...We}){const{enumOptions:ze,enumDisabled:Ke,emptyValue:Te}=U;de=typeof de>"u"?!1:!!de;const at=de?[]:"",$t=typeof xe>"u"||de&&xe.length<1||!de&&xe===at,Yt=({target:{value:se}})=>Oe(or(se,ze,Te)),Zt=({target:se})=>ve(C,or(se&&se.value,ze,Te)),bt=({target:se})=>ge(C,or(se&&se.value,ze,Te)),vt=jn(xe,ze,de),{InputLabelProps:Xt,SelectProps:G,autocomplete:R,...oe}=We,he=!de&&$.default===void 0;return e.jsxs(ke,{id:C,name:C,value:!$t&&typeof vt<"u"?vt:at,required:f,disabled:ue||O,autoFocus:Le,autoComplete:R,placeholder:J,error:_e.length>0,onChange:Yt,onBlur:Zt,onFocus:bt,...oe,select:!0,InputLabelProps:{...Xt,shrink:!$t},SelectProps:{...G,multiple:de},"aria-describedby":wn(C),children:[he&&e.jsx(H,{value:"",children:J}),Array.isArray(ze)&&ze.map(({value:se,label:Ee},nt)=>{const yt=Array.isArray(Ke)&&Ke.indexOf(se)!==-1;return e.jsx(H,{value:String(nt),disabled:yt,children:Ee},nt)})]})}return o&&console.log("ConfigPluginDialog rendering..."),!n||!k||!I?null:e.jsxs(Be,{open:n,onClose:a,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(Qe,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h3",{children:"Matterbridge plugin configuration"})]})}),e.jsx(Ge,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(vn,{schema:k,formData:I,uiSchema:K,validator:yn,templates:{FieldTemplate:T,BaseInputTemplate:v,TitleFieldTemplate:ce,DescriptionFieldTemplate:te,FieldHelpTemplate:w,FieldErrorTemplate:c,ErrorListTemplate:d,WrapIfAdditionalTemplate:M,ArrayFieldTitleTemplate:_,ArrayFieldDescriptionTemplate:E,ArrayFieldItemTemplate:ae,ArrayFieldTemplate:we,ObjectFieldTemplate:A,ButtonTemplates:{SubmitButton:x,RemoveButton:y,AddButton:P,MoveUpButton:F,MoveDownButton:S}},widgets:{CheckboxWidget:re,SelectWidget:Ce},onChange:u,onSubmit:D})})]})};function zr(n){if(o&&console.log(`getQRColor (id: ${n?.id}) received matter:`,n??"undefined"),n===void 0||!n.online||!n.qrPairingCode&&!n.manualPairingCode&&!n.fabricInformations&&!n.sessionInformations)return"red";if(n.commissioned===!1&&n.qrPairingCode&&n.manualPairingCode)return"var(--primary-color)";let a=0,l=0;for(const i of n.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&a++,i.numberOfActiveSubscriptions>0&&(l+=i.numberOfActiveSubscriptions);return n.commissioned===!0&&n.fabricInformations&&n.sessionInformations&&(a===0||l===0)?"var(--secondary-color)":"var(--div-text-color)"}function ri({storeId:n,setStoreId:a}){const{online:l,sendMessage:i,addListener:s,removeListener:g,getUniqueId:h}=r.useContext(Ie),{showConfirmCancelDialog:b}=r.useContext(Re),t=r.useRef(h()),[N,I]=r.useState(null),[W,k]=r.useState(null),[B,K]=r.useState([]),Z=[{label:"Name",id:"name",required:!0,render:(P,F,S,re)=>e.jsx(V,{title:`Plugin path ${S.path}`,children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>w(S),children:S.name})})},{label:"Description",id:"description",render:(P,F,S,re)=>e.jsx(V,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>w(S),children:S.description})})},{label:"Version",id:"version",render:(P,F,S,re)=>e.jsx(e.Fragment,{children:e.jsx(V,{title:`Plugin v.${S.version}`,children:e.jsx("span",{children:S.version.split("-")[0]+(S.version.includes("-dev-")?"@dev":"")+(S.version.includes("-git-")?"@git":"")})})})},{label:"Author",id:"author",render:(P,F,S,re)=>e.jsx(e.Fragment,{children:S.author?S.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(P,F,S,re)=>e.jsx(e.Fragment,{children:S.type?S.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(P,F,S,re)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[W&&W.bridgeMode==="childbridge"&&!S.error&&S.enabled&&e.jsx(V,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:zr(S.matter)},onClick:()=>{S.matter?.id&&a(S.matter?.id)},size:"small",children:e.jsx(Rr,{})})}),W&&W.bridgeMode==="childbridge"&&!S.error&&S.enabled&&e.jsx(V,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>te(S),size:"small",children:e.jsx(qt,{})})}),e.jsx(V,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{disabled:S.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>A(S),size:"small",children:e.jsx(go,{})})}),W&&!W.readOnly&&e.jsx(V,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{m("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",S)},size:"small",children:e.jsx(Nr,{})})}),S.enabled?e.jsx(V,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{m("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",S)},size:"small",children:e.jsx(ho,{})})}):e.jsx(e.Fragment,{}),S.enabled?e.jsx(e.Fragment,{}):e.jsx(V,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>ce(S),size:"small",children:e.jsx(fo,{})})}),e.jsx(V,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>c(S),size:"small",children:e.jsx(dr,{})})}),e.jsx(V,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>v(S),size:"small",children:e.jsx(Jt,{})})}),S.latestVersion!==void 0&&S.latestVersion!==S.version&&W&&!W.readOnly&&e.jsx(V,{title:"Update the plugin to the latest version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>D(S),size:"small",children:e.jsx(qe,{})})}),(S.version.includes("-dev-")||S.version.includes("-git-"))&&S.devVersion!==void 0&&S.devVersion!==S.version&&W&&!W.readOnly&&e.jsx(V,{title:"Update the plugin to the latest dev version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{color:"var(--secondary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>M(S),size:"small",children:e.jsx(qe,{})})}),W&&!W.readOnly&&e.jsx(V,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>d(S),size:"small",children:e.jsx(ur,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(P,F,S,re)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:S.error?e.jsx(e.Fragment,{children:e.jsx(dt,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:S.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(dt,{status:S.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:S.loaded&&S.started&&S.configured?e.jsx(e.Fragment,{children:e.jsx(dt,{status:S.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(dt,{status:S.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(dt,{status:S.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(dt,{status:S.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const P=F=>{o&&console.log("HomePlugins received WebSocket Message:",F),F.method==="refresh_required"&&F.response.changed==="plugins"?(o&&console.log(`HomePlugins received refresh_required: changed=${F.response.changed} and sending /api/plugins request`),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):F.method==="refresh_required"&&F.response.changed==="matter"?(o&&console.log(`HomePlugins received refresh_required: changed=${F.response.changed} and setting matter id ${F.response.matter?.id}`),K(S=>{const re=S.findIndex($=>$.matter?.id===F.response.matter?.id);if(re<0)return o&&console.log(`HomePlugins received refresh_required: changed=${F.response.changed} and matter id ${F.response.matter?.id} not found`),S;o&&console.log(`HomePlugins received refresh_required: changed=${F.response.changed} set matter id ${F.response.matter?.id}`);const Ce=[...S];return Ce[re]={...Ce[re],matter:F.response.matter},Ce})):F.method==="refresh_required"&&F.response.changed==="settings"&&(o&&console.log(`HomePlugins received refresh_required: changed=${F.response.changed} and sending /api/settings request`),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),F.id===t.current&&F.method==="/api/settings"?(o&&console.log(`HomePlugins (id: ${F.id}) received settings:`,F.response),I(F.response.systemInformation),k(F.response.matterbridgeInformation)):F.id===t.current&&F.method==="/api/plugins"&&(o&&console.log(`HomePlugins (id: ${F.id}) received ${F.response.length} plugins:`,F.response),K(F.response))};return s(P,t.current),o&&console.log("HomePlugins added WebSocket listener id:",t.current),()=>{g(P),o&&console.log("HomePlugins removed WebSocket listener")}},[s,g,i]),r.useEffect(()=>{l&&(o&&console.log("HomePlugins sending api requests"),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const q=r.useRef(null),m=(P,F,S,re)=>{o&&console.log(`handleActionWithConfirmCancel ${S} ${re.name}`),q.current=re,b(P,F,S,p,u)},p=P=>{o&&console.log(`handleConfirm action confirmed ${P} ${q.current?.name}`),P==="remove"&&q.current?T(q.current):P==="disable"&&q.current&&ce(q.current),q.current=null},u=P=>{o&&console.log(`handleCancel action canceled ${P} ${q.current?.name}`),q.current=null},D=P=>{o&&console.log("handleUpdatePlugin plugin:",P.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:P.name,restart:!1}})},M=P=>{o&&console.log("handleUpdateDevPlugin plugin:",P.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:P.name+"@dev",restart:!1}})},T=P=>{o&&console.log("handleRemovePlugin plugin:",P.name),i({id:t.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:P.name}})},te=P=>{o&&console.log("handleRestartPlugin plugin:",P.name),i({id:t.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:P.name}})},ce=P=>{o&&console.log("handleEnableDisablePlugin plugin:",P.name,"enabled:",P.enabled),P.enabled===!0?(P.enabled=!1,i({id:t.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:P.name}})):(P.enabled=!0,i({id:t.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:P.name}}))},w=P=>{o&&console.log(`handleHomepagePlugin plugin: ${P.name} homepage: ${P.homepage}`),P.homepage&&window.open(P.homepage,"_blank")},d=P=>{o&&console.log("handleSponsorPlugin plugin:",P.name,"funding:",P.funding),P.funding&&window.open(P.funding,"_blank")},c=P=>{o&&console.log("handleHelpPlugin plugin:",P.name,"help:",P.help),P.help&&window.open(P.help,"_blank")},v=P=>{o&&console.log("handleChangelogPlugin plugin:",P.name,"changelog:",P.changelog),P.changelog&&window.open(P.changelog,"_blank")},[_,E]=r.useState(),[ae,we]=r.useState(!1),A=P=>{o&&console.log("handleConfigPlugin plugin:",P.name),i({id:t.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:P.name}}),i({id:t.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:P.name}}),E(P),x()},x=()=>{we(!0)},y=()=>{we(!1)};return o&&console.log("HomePlugins rendering..."),l?e.jsxs(Me,{children:[_&&e.jsx(ti,{open:ae,onClose:y,plugin:_}),e.jsx(Dt,{name:"Plugins",columns:Z,rows:B,footerRight:"",footerLeft:""})]}):e.jsx(Je,{})}const oi=r.memo(ri),ni=n=>`${n.pluginName}::${n.serial}`;function ii({storeId:n,setStoreId:a}){const{online:l,sendMessage:i,addListener:s,removeListener:g,getUniqueId:h}=r.useContext(Ie),[b,t]=r.useState(!1),[N,I]=r.useState(!0),[W,k]=r.useState(null),[B,K]=r.useState([]),[Z,q]=r.useState([]),[m,p]=r.useState([]),[u,D]=r.useState([]),M=r.useRef(h()),T=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(w,d,c,v)=>c.reachable===!0?"Online":c.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(w,d)=>{const c=w.reachable===!0?1:w.reachable===!1?0:-1,v=d.reachable===!0?1:d.reachable===!1?0:-1;return c-v}},{label:"Power",id:"powerSource",render:(w,d,c,v)=>c.powerSource==="ac"||c.powerSource==="dc"?e.jsx(Or,{fontSize:"small",sx:{color:"var(--primary-color)"}}):c.powerSource==="ok"?c.batteryLevel?e.jsx(V,{title:`Battery level: ${c.batteryLevel}%`,children:e.jsx(it,{fontSize:"small",sx:{color:"green"}})}):e.jsx(it,{fontSize:"small",sx:{color:"gray"}}):c.powerSource==="warning"?c.batteryLevel?e.jsx(V,{title:`Battery level: ${c.batteryLevel}%`,children:e.jsx(it,{fontSize:"small",sx:{color:"yellow"}})}):e.jsx(it,{fontSize:"small",sx:{color:"yellow"}}):c.powerSource==="critical"?c.batteryLevel?e.jsx(V,{title:`Battery level: ${c.batteryLevel}%`,children:e.jsx(it,{fontSize:"small",sx:{color:"red"}})}):e.jsx(it,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Actions",id:"selected",required:!0,render:(w,d,c,v)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[c.matter!==void 0?e.jsx(V,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{onClick:()=>a(n===c.matter?.id?W?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:c.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:zr(c.matter)},children:e.jsx(Rr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),c.configUrl?e.jsx(V,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{onClick:()=>window.open(c.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(_r,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),c.selected!==void 0?e.jsx(V,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Xe,{checked:c.selected,onChange:_=>ce(_,c),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],te=r.useCallback(w=>{w.selected=void 0;const d=B.find(_=>_.name===w.pluginName);if(!d)return console.error(`HomeDevices isSelected: plugin ${w.pluginName} not found for device ${w.name} `),w.selected;const c=d.schemaJson?.properties?.whiteList?.selectFrom;let v=d.configJson.postfix;return v===""&&(v=void 0),d.hasWhiteList===!0&&d.hasBlackList===!0&&c&&(w.selected=!0,c==="serial"&&d.configJson.whiteList&&d.configJson.whiteList.length>0&&d.configJson.whiteList.includes(v?w.serial.replace("-"+v,""):w.serial)&&(w.selected=!0),c==="serial"&&d.configJson.whiteList&&d.configJson.whiteList.length>0&&!d.configJson.whiteList.includes(v?w.serial.replace("-"+v,""):w.serial)&&(w.selected=!1),c==="serial"&&d.configJson.blackList&&d.configJson.blackList.length>0&&d.configJson.blackList.includes(v?w.serial.replace("-"+v,""):w.serial)&&(w.selected=!1),c==="name"&&d.configJson.whiteList&&d.configJson.whiteList.length>0&&d.configJson.whiteList.includes(w.name)&&(w.selected=!0),c==="name"&&d.configJson.whiteList&&d.configJson.whiteList.length>0&&!d.configJson.whiteList.includes(w.name)&&(w.selected=!1),c==="name"&&d.configJson.blackList&&d.configJson.blackList.length>0&&d.configJson.blackList.includes(w.name)&&(w.selected=!1)),w.selected},[B]);r.useEffect(()=>{const w=d=>{if(o&&console.log("HomeDevices received WebSocket Message:",d),d.method==="refresh_required"&&d.response.changed!=="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${d.response.changed} and sending /api/plugins request`),i({id:M.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):d.method==="refresh_required"&&d.response.changed==="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${d.response.changed} and setting matter id ${d.response.matter?.id}`),D(c=>{const v=c.findIndex(E=>E.name.replaceAll(" ","")===d.response.matter?.id);if(v<0)return o&&console.debug(`HomeDevices: matter id ${d.response.matter?.id} not found`),c;const _=[...c];return _[v]={..._[v],matter:d.response.matter},o&&console.log(`HomeDevices received refresh_required: changed=${d.response.changed} and set matter id ${d.response.matter?.id}`),_})):d.method==="restart_required"?(o&&console.log("HomeDevices received restart_required"),t(!0)):d.method==="restart_not_required"?(o&&console.log("HomeDevices received restart_not_required"),t(!1)):d.method==="state_update"&&d.response.plugin&&d.response.serialNumber&&d.response.cluster.includes("BasicInformation")&&d.response.attribute==="reachable"&&(o&&console.log(`HomeDevices updating device reachability for plugin ${d.response.plugin} serial ${d.response.serialNumber} value ${d.response.value}`),q(c=>{const v=c.findIndex(_=>_.pluginName===d.response.plugin&&_.serial===d.response.serialNumber);return v<0?(o&&console.warn(`HomeDevices: device to update not found for plugin ${d.response.plugin} serial ${d.response.serialNumber}`),c):(c[v]={...c[v],reachable:d.response.value},[...c])})),d.id===M.current&&d.method==="/api/settings")o&&console.log(`HomeDevices (id: ${d.id}) received settings:`,d.response),k(d.response),t(d.response.matterbridgeInformation.restartRequired||d.response.matterbridgeInformation.fixedRestartRequired);else if(d.id===M.current&&d.method==="/api/plugins"){if(o&&console.log(`HomeDevices (id: ${d.id}) received ${d.response?.length} plugins:`,d.response),d.response){let c=!0;for(const v of d.response)v.enabled===!0&&(v.loaded!==!0||v.started!==!0||v.error===!0)&&(c=!1);if(!c)return;o&&console.log("HomeDevices reset plugins, devices and selectDevices"),I(!1),K(d.response),q([]),p([]),i({id:M.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),o&&console.log("HomeDevices sent /api/devices");for(const v of d.response)v.enabled===!0&&v.loaded===!0&&v.started===!0&&v.error!==!0&&(i({id:M.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:v.name}}),o&&console.log(`HomeDevices sent /api/select/devices for plugin: ${v.name}`))}}else if(d.id===M.current&&d.method==="/api/devices"){if(o&&console.log(`HomeDevices (id: ${d.id}) received ${d.response?.length} devices:`,d.response),d.response){for(const c of d.response)c.selected=te(c);q(d.response)}}else d.id===M.current&&d.method==="/api/select/devices"&&(o&&console.log(`HomeDevices (id: ${d.id}) received ${d.response?.length} selectDevices for plugin ${d.response&&d.response.length>0?d.response[0].pluginName:"without select devices"}:`,d.response),d.response&&d.response.length>0&&p(c=>{const v=c.filter(E=>E.pluginName!==d.response[0].pluginName),_=d.response.map(E=>({...E,selected:te(E)}));return[...v,..._]}))};return s(w,M.current),o&&console.log(`HomeDevices added WebSocket listener id ${M.current}`),()=>{g(w),o&&console.log("HomeDevices removed WebSocket listener")}},[B,s,g,i,te]),r.useEffect(()=>{if(Z.length===0&&m.length===0){D([]);return}o&&console.log(`HomeDevices mixing devices (${Z.length}) and selectDevices (${m.length})`);const w=[];for(const d of Z)w.push(d);for(const d of m)Z.find(c=>c.pluginName===d.pluginName&&c.serial.includes(d.serial))||w.push(d);w.length>0&&(D(w),o&&console.log(`HomeDevices mixed ${w.length} devices and selectDevices`))},[B,Z,m,D]),r.useEffect(()=>{l&&(o&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:M.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:M.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const ce=(w,d)=>{o&&console.log(`handleCheckboxChange: checkbox changed to ${w.target.checked} for device ${d.name} serial ${d.serial}`),Z.findIndex(c=>c.pluginName===d.pluginName&&c.serial===d.serial)<0?(o&&console.warn(`handleCheckboxChange: device ${d.name} serial ${d.serial} not found in devices, trying in mixedDevices`),D(c=>{const v=c.findIndex(_=>_.pluginName===d.pluginName&&_.serial===d.serial);return v<0?(console.error(`handleCheckboxChange: device ${d.name} serial ${d.serial} not found in mixedDevices`),c):(c[v]={...c[v],selected:w.target.checked},[...c])})):q(c=>{const v=c.findIndex(_=>_.pluginName===d.pluginName&&_.serial===d.serial);return v<0?(console.error(`handleCheckboxChange: device ${d.name} serial ${d.serial} not found in devices`),c):(c[v]={...c[v],selected:w.target.checked},[...c])}),w.target.checked?i({id:M.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:d.pluginName,serial:d.serial,name:d.name}}):i({id:M.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:d.pluginName,serial:d.serial,name:d.name}})};return o&&console.log("HomeDevices rendering..."),l?e.jsx(Me,{style:{flex:"1 1 auto"},children:e.jsx(Dt,{name:"Devices",getRowKey:ni,rows:u,columns:T,footerLeft:N?"Waiting for the plugins to fully load...":`Registered devices: ${Z.length.toString()}/${u.length.toString()}`,footerRight:b?"Restart required":""})}):e.jsx(Je,{})}const si=r.memo(ii);function Pt({children:n,style:a,name:l}){const{setCurrentPage:i}=r.useContext(Re);i(l),o&&console.log(`MbfPage: current page set to ${l}`);const s={display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"20px"};return e.jsx("div",{style:{...s,...a},children:n})}const li=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(o&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(o&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function ai(){const{messages:n,logAutoScroll:a}=r.useContext(Vr),[l,i]=r.useState(!1),s=r.useRef(null),g=r.useRef(0),h=r.useRef(null),b=r.useMemo(()=>li(),[]),t=k=>i(!0),N=k=>i(!1);r.useEffect(()=>{if(o&&console.log(`WebSocketLogs logAutoScroll: ${a.current} isHovering: ${l}`),a.current&&!l&&!b){const k=Date.now();k-g.current>=500?(o&&console.log("WebSocketLogs auto-scroll to bottom"),g.current=k,s.current?.scrollIntoView({behavior:"smooth",block:"end"})):(o&&console.log("WebSocketLogs auto-scroll skipped to avoid flicker"),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{s.current?.scrollIntoView({behavior:"smooth"}),g.current=Date.now()},1e3))}},[n,a,l,b]);const I=k=>{switch(k.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"}},W=k=>k.toLowerCase()==="warn"?"black":"white";return e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:t,onMouseLeave:N,children:[n.map((k,B)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:I(k.level),color:W(k.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:k.level}),k.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+k.time+"]"}),k.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+k.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:k.message})]},B)),e.jsx("div",{ref:s})]})})}const qr=r.memo(ai);function ci(){const[n,a]=r.useState(localStorage.getItem(ee.logFilterLevel)??"info"),[l,i]=r.useState(localStorage.getItem(ee.logFilterSearch)??"*"),{online:s,logAutoScroll:g}=r.useContext(Ie);return o&&console.log("HomeLogs rendering..."),s?e.jsxs(Me,{style:{flex:"1 1 auto"},children:[e.jsxs(Fe,{children:[e.jsx(De,{children:"Logs"}),e.jsxs(De,{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',n,'" and search "',l===""?"*":l,'" Scroll: ',g.current?"auto":"manual"]})]}),e.jsx(Ue,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"10px",alignItems:"start"},children:e.jsx(qr,{})})]}):e.jsx(Je,{})}const di=r.memo(ci);function pi(){const{online:n}=r.useContext(Ie);return o&&console.log("HomeBrowserRefresh rendering..."),n?e.jsxs(Me,{children:[e.jsx(Fe,{children:e.jsx(De,{children:"Frontend Update"})}),e.jsxs(Ue,{style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(me,{onClick:()=>window.location.reload(),endIcon:e.jsx(mo,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}):e.jsx(Je,{})}const ui=r.memo(pi);function gi({changelog:n}){const{online:a}=r.useContext(Ie);return o&&console.log("HomeShowChangelog rendering..."),a?e.jsxs(Me,{children:[e.jsx(Fe,{children:e.jsx(De,{children:"Matterbridge Update"})}),e.jsxs(Ue,{style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(me,{onClick:()=>window.open("https://github.com/Luligu/matterbridge","_blank"),endIcon:e.jsx(Hr,{style:{color:"#FFD700"}}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Star"}),e.jsx(me,{onClick:()=>window.open("https://www.buymeacoffee.com/luligugithub","_blank"),endIcon:e.jsx(ur,{style:{color:"#b6409c"}}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Sponsor"}),e.jsx(me,{onClick:()=>window.open(n,"_blank"),endIcon:e.jsx(Jt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(me,{onClick:()=>window.location.reload(),endIcon:e.jsx(xo,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}):e.jsx(Je,{})}const hi=r.memo(gi);function fi({matterbridgeInfo:n}){const{mobile:a}=r.useContext(Re);o&&console.log("MatterbridgeInfoTable:",n);const l=["matterbridgeLatestVersion","matterbridgeDevVersion","--matterFileLogger","--fileLogger","--matterLoggerLevel","--loggerLevel","--virtualMode","--bridgeMode","--restartMode","--restartRequired","fixedRestartRequired","--updateRequired","matterMdnsInterface","matterIpv4Address","matterIpv6Address","readOnly","shellyBoard","shellySysUpdate","shellyMainUpdate","matterPort","matterDiscriminator","matterPasscode"],[i,s]=r.useState(!1);return!n||i?null:(o&&console.log("MatterbridgeInfoTable rendering..."),e.jsxs(Me,{style:Se&&a?{flex:"1 1 300px"}:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Fe,{children:[e.jsx(De,{children:"Matterbridge info"}),e.jsx(st,{close:()=>s(!0)})]}),e.jsx(Ue,{style:Se&&a?{flex:"1 1 auto",margin:"0px",padding:"0px",gap:"0px"}:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsxs("table",{style:{border:"none",borderCollapse:"collapse",tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"40%"}}),e.jsx("col",{style:{width:"60%"}})]}),e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(n).filter(([g,h])=>!l.includes(g)&&h!==null&&h!==void 0&&h!=="").map(([g,h],b)=>e.jsxs("tr",{className:b%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap"},children:g.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")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Se&&a?typeof h!="string"?h.toString():h:e.jsx(Ar,{value:typeof h!="string"?h.toString():h,maxChars:24})})]},g))})]})})]}))}const mi=r.memo(fi);function xi(){const[n,a]=r.useState(null),[l,i]=r.useState(null),[s,g]=r.useState([]),[h]=r.useState(localStorage.getItem(ee.homePagePlugins)!=="false"),[b,t]=r.useState(localStorage.getItem(ee.homePageMode)??"devices"),[N,I]=r.useState("https://matterbridge.io/CHANGELOG.html"),[W,k]=r.useState(!1),[B,K]=r.useState(!1),[Z,q]=r.useState(null),{mobile:m}=r.useContext(Re),{addListener:p,removeListener:u,online:D,sendMessage:M,getUniqueId:T}=r.useContext(Ie),te=r.useRef(T());return r.useEffect(()=>{const ce=w=>{o&&console.log("Home received WebSocket Message:",w),w.method==="refresh_required"&&w.response.changed==="settings"&&(o&&console.log(`Home received refresh_required: changed=${w.response.changed} and sending /api/settings request`),q(null),g([]),M({id:te.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),M({id:te.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),w.method==="/api/settings"&&w.id===te.current&&(o&&console.log("Home received settings:",w.response),a(w.response.systemInformation),i(w.response.matterbridgeInformation),localStorage.getItem(ee.frontendVersion)===null&&w.response.matterbridgeInformation.frontendVersion?localStorage.setItem(ee.frontendVersion,w.response.matterbridgeInformation.frontendVersion):w.response.matterbridgeInformation.frontendVersion!==localStorage.getItem(ee.frontendVersion)&&w.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem(ee.frontendVersion,w.response.matterbridgeInformation.frontendVersion),K(!0)),localStorage.getItem(ee.matterbridgeVersion)===null?localStorage.setItem(ee.matterbridgeVersion,w.response.matterbridgeInformation.matterbridgeVersion):w.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem(ee.matterbridgeVersion)&&(localStorage.setItem(ee.matterbridgeVersion,w.response.matterbridgeInformation.matterbridgeVersion),k(!0)),w.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem(ee.homePageMode)||(localStorage.setItem(ee.homePageMode,"devices"),t("devices")))),w.method==="/api/plugins"&&w.id===te.current&&(o&&console.log("Home received plugins:",w.response),g(w.response))};return p(ce,te.current),o&&console.log(`Home added WebSocket listener id ${te.current}`),()=>{u(ce),o&&console.log("Home removed WebSocket listener")}},[p,u,M]),r.useEffect(()=>{if(o&&console.log(`Home storeId effect with storeId ${Z}`),l?.bridgeMode==="bridge"&&!Z&&(o&&console.log("Home storeId effect set storeId to Matterbridge"),q("Matterbridge")),l?.bridgeMode==="childbridge"&&!Z&&s){for(const ce of s)if(ce.matter?.id){o&&console.log(`Home storeId effect set storeId to ${ce.matter.id}`),q(ce.matter.id);break}}},[l,s,Z]),r.useEffect(()=>{D&&(o&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),M({id:te.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),M({id:te.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[D,M]),o&&console.log("Home rendering..."),!D||!n||!l?e.jsx(Je,{}):e.jsxs(Pt,{name:"Home",style:Se&&m?{alignItems:"center",gap:"10px"}:{flexDirection:"row"},children:[(Se&&!m||!Se)&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(Ir,{id:Z}),e.jsx(Sr,{systemInfo:n,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:Se&&m?"10px":"20px"},children:[B&&e.jsx(ui,{}),W&&e.jsx(hi,{changelog:N}),Se&&m&&e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(Ir,{id:Z}),e.jsx(Sr,{systemInfo:n,compact:!0}),e.jsx(mi,{matterbridgeInfo:l})]}),h&&!l.readOnly&&e.jsx(Yn,{}),h&&e.jsx(oi,{storeId:Z,setStoreId:q}),b==="devices"&&e.jsx(si,{storeId:Z,setStoreId:q}),b==="logs"&&e.jsx(di,{})]})]})}const bi=r.memo(xi),At=!1,Pr={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},vi={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},yi={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},$r={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},ji={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},wi={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},Ci={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Si={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},ki={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},sr={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},Ii=[256,257,268,269],Mi=[266,267],Di=[259,260,261,271,272],Pi=[256,257,268,269,266,267,259,260,261,272];function ie({icon:n,iconColor:a,cluster:l,value:i,unit:s,prefix:g}){return o&&console.log(`Render cluster "${l.clusterName}.${l.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${s}"`),g=g??!1,e.jsxs(fe,{sx:Pr,children:[n&&r.cloneElement(n,{key:`${l.clusterId}-${l.attributeId}-icon`,sx:{...vi,color:a??"var(--primary-color)"}}),e.jsxs(fe,{sx:{...Pr,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[s&&g===!0&&e.jsx(je,{sx:$r,children:s},`${l.clusterId}-${l.attributeId}-unit`),e.jsx(je,{sx:yi,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${l.clusterId}-${l.attributeId}-value`),s&&g===!1&&e.jsx(je,{sx:$r,children:s},`${l.clusterId}-${l.attributeId}-unit`)]},`${l.clusterId}-${l.attributeId}-valueunitbox`)]},`${l.clusterId}-${l.attributeId}-box`)}function $i({device:n,endpoint:a,id:l,deviceType:i,clusters:s}){const g=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let h="";o&&console.log(`Device "${n.name}" endpoint "${a}" id "${l}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${s?.length})`);const b=s.find(t=>t.clusterName==="Descriptor"&&t.attributeName==="tagList")?.attributeLocalValue;if(b){let t="";b.map(N=>{N.label&&(t+=N.label+" ")}),h=t.trim()}if(i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>h=`${t.attributeLocalValue} mV`),Pi.includes(i)&&s.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>h=`Level ${t.attributeValue}`),i===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>h=`Position ${t.attributeLocalValue/100}%`),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>h=`Heat ${t.attributeLocalValue/100}°C `),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>h=h+`Cool ${t.attributeLocalValue/100}°C`),i===118&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>h=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>h=`${t.attributeLocalValue/1e3} V, `),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>h=h+`${t.attributeLocalValue/1e3} A, `),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>h=h+`${t.attributeLocalValue/1e3} W`),i===39){const t=s.find(I=>I.clusterName==="ModeSelect"&&I.attributeName==="currentMode")?.attributeLocalValue;h=s.find(I=>I.clusterName==="ModeSelect"&&I.attributeName==="supportedModes")?.attributeLocalValue?.find(I=>I.mode===t)?.label||"Unknown"}if(i===116){const t=s.find(I=>I.clusterName==="RvcRunMode"&&I.attributeName==="currentMode")?.attributeLocalValue;h=s.find(I=>I.clusterName==="RvcRunMode"&&I.attributeName==="supportedModes")?.attributeLocalValue?.find(I=>I.mode===t)?.label||"Unknown"}return e.jsxs(Me,{style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[i===19&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(ie,{icon:t.attributeLocalValue===!0?e.jsx(kt,{}):e.jsx(bo,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(ie,{icon:e.jsx(it,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(ie,{icon:e.jsx(Or,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&s.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:Xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),Ii.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(ie,{icon:e.jsx(vo,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Mi.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:en,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Di.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:tn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:rn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:on,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:nn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(ie,{icon:e.jsx(br,{}),cluster:t,value:"Oven"})),i===112&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(ie,{icon:e.jsx(yo,{}),cluster:t,value:"Fridge"})),i===113&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:sn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(ie,{icon:e.jsx(br,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:ln,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:wr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:wr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(ie,{icon:e.jsx(jo,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:an,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&s.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(ie,{icon:t.attributeValue==="1"?e.jsx(wo,{}):e.jsx(Co,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(ie,{icon:e.jsx(So,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&s.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:cn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&s.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(ie,{icon:e.jsx(ko,{}),cluster:t,value:t.attributeValue,unit:"Mode",prefix:!0})),i===771&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(ie,{icon:e.jsx(Io,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(ie,{icon:e.jsx(vr,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(ie,{icon:e.jsx(vr,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(ie,{icon:e.jsx(Mo,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(ie,{icon:e.jsx(Do,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(ie,{icon:e.jsx(Po,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===116&&s.filter(t=>t.clusterName==="RvcRunMode"&&t.attributeName==="currentMode").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:dn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"Run mode",prefix:!0})),i===1292&&s.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:pn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&s.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:un,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:gn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:hn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:fn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===118&&s.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:Cr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===118&&s.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:Cr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&s.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(ie,{icon:e.jsx($o,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&s.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:mn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:g[t.attributeLocalValue??0]})),i===770&&s.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(ie,{icon:e.jsx(Lo,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&s.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(ie,{icon:e.jsx(be,{path:xn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&s.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(ie,{icon:e.jsx(Wo,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&s.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(ie,{icon:e.jsx(To,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(ie,{icon:t.attributeValue==="true"?e.jsx(Fo,{}):e.jsx(No,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&s.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(ie,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(Ro,{}):e.jsx(Oo,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&s.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(ie,{icon:e.jsx(_o,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),i===1296&&s.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(ie,{icon:e.jsx(Ho,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(fe,{sx:ji,children:e.jsx(je,{sx:wi,children:h})}),e.jsx(fe,{sx:Ci,children:e.jsx(je,{sx:Si,children:n.name})}),e.jsxs(fe,{sx:ki,children:[o&&e.jsx(je,{sx:sr,children:a}),e.jsx(je,{sx:sr,children:l}),o&&e.jsxs(je,{sx:sr,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function Li({filter:n}){const{online:a,sendMessage:l,addListener:i,removeListener:s,getUniqueId:g}=r.useContext(Ie),[h,b]=r.useState([]),[t,N]=r.useState({}),[I,W]=r.useState({}),[k,B]=r.useState({}),K=r.useRef(g()),Z=r.useCallback(p=>{(o||At)&&console.log(`DevicesIcons received state_update "${p.response.cluster}.${p.response.attribute}" for "${p.response.id}:${p.response.number}": "${p.response.value}"`,p.response);const u=h.find(M=>M.pluginName===p.response.plugin&&M.serial===p.response.serialNumber);if(!u){(o||At)&&console.warn(`DevicesIcons updater device of plugin "${p.response.plugin}" serial "${p.response.serialNumber}" number "${p.response.number}" id "${p.response.id}" not found in devices(${h.length})`);return}const D=k[u.serial]?.find(M=>M.endpoint===p.response.number.toString()&&M.clusterName===p.response.cluster&&M.attributeName===p.response.attribute);if(!D){(o||At)&&console.warn(`DevicesIcons updater device "${u.name}" serial "${u.serial}" cluster "${p.response.cluster}" attribute "${p.response.attribute}" not found in clusters(${k[u.serial]?.length})`);return}D.attributeValue=String(p.response.value),D.attributeLocalValue=p.response.value,B({...k}),(o||At)&&console.log(`DevicesIcons updated "${D.clusterName}.${D.attributeName}" for device "${u.name}" serial "${u.serial}" to "${D.attributeValue}"`)},[k,h]),q=r.useCallback(p=>{if(o&&console.log(`DevicesIcons received for device "${p.response.deviceName}" serial "${p.response.serialNumber}" deviceTypes (${p.response.deviceTypes.length}) "${p.response.deviceTypes.join(",")}" clusters (${p.response.clusters.length}):`,p.response),p.response.clusters.length===0)return;const u=p.response.serialNumber;t[u]=[],I[u]=p.response.deviceTypes,k[u]=[];for(const D of p.response.clusters)t[u].find(M=>M.endpoint===D.endpoint)||t[u].push({endpoint:D.endpoint,id:D.id,deviceTypes:D.deviceTypes}),!["FixedLabel","Identify","Groups","PowerTopology"].includes(D.clusterName)&&k[u].push(D);N({...t}),W({...I}),B({...k}),o&&console.log(`DevicesIcons endpoints for "${u}":`,t[u]),o&&console.log(`DevicesIcons deviceTypes for "${u}":`,I[u]),o&&console.log(`DevicesIcons clusters for "${u}":`,k[u])},[k,I,t]);r.useEffect(()=>{const p=u=>{if(o&&console.log("DevicesIcons received WebSocket Message:",u),u.method==="refresh_required")o&&console.log(`DevicesIcons received refresh_required: changed=${u.response.changed} and sending api requests`),l({id:K.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(u.method==="state_update"&&u.response)Z(u);else if(u.method==="/api/devices"&&u.response){o&&console.log(`DevicesIcons received ${u.response.length} devices:`,u.response),b(u.response),N({}),W({}),B({});for(const D of u.response)o&&console.log("DevicesIcons sending /api/clusters"),l({id:K.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:D.pluginName,endpoint:D.endpoint||0}})}else u.method==="/api/clusters"&&u.response&&q(u)};return i(p,K.current),o&&console.log("DevicesIcons WebSocket effect mounted"),()=>{s(p),o&&console.log("DevicesIcons WebSocket effect unmounted")}},[h]),r.useEffect(()=>(o&&console.log("DevicesIcons useEffect online mounting"),a&&(o&&console.log("DevicesIcons useEffect online sending api requests"),l({id:K.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),o&&console.log("DevicesIcons useEffect online mounted"),()=>{o&&console.log("DevicesIcons useEffect online unmounted")}),[a,l]);const m=r.memo($i);return o&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:h.filter(p=>p.name.toLowerCase().includes(n)||p.serial.toLowerCase().includes(n)).map(p=>t[p.serial]&&t[p.serial].map(u=>u.deviceTypes.map(D=>e.jsx(m,{device:p,endpoint:u.endpoint,id:u.id,deviceType:D,clusters:k[p.serial].filter(M=>M.endpoint===u.endpoint)},`${p.pluginName}-${p.uniqueId}-${u.endpoint}-${u.id}-${D.toString()}`))))})}const Wi=r.memo(Li),Ti=[{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:(n,a,l,i)=>l.configUrl?e.jsx(X,{onClick:()=>window.open(l.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(_r,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],Fi=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(n,a,l,i)=>Array.isArray(n)?e.jsx(e.Fragment,{children:n.map(s=>`0x${s.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:n})},{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}],Ni=n=>`${n.pluginName}::${n.uniqueId}`,Ri=n=>`${n.endpoint}::${n.clusterName}::${n.attributeName}`;function Oi({filter:n}){const{online:a,sendMessage:l,addListener:i,removeListener:s,getUniqueId:g}=r.useContext(Ie),[h,b]=r.useState([]),[t,N]=r.useState(h),[I,W]=r.useState([]),[k,B]=r.useState(0),[K,Z]=r.useState(null),[q,m]=r.useState(null),[p,u]=r.useState(null),[D,M]=r.useState(null),T=r.useRef(g()),te=r.useRef(t),ce=r.useCallback(d=>{o&&console.log(`DevicesTable received state_update "${d.response.cluster}.${d.response.attribute}" for "${d.response.id}:${d.response.number}": "${d.response.value}"`,d.response);const c=te.current.find(v=>v.pluginName===d.response.plugin&&v.uniqueId===d.response.uniqueId);if(!c){o&&console.warn(`DevicesTable updater device of plugin "${d.response.plugin}" serial "${d.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(K&&q&&c.pluginName===K&&c.uniqueId===D&&d.response.number.toString()===q){const v=I.find(_=>_.endpoint===d.response.number.toString()&&_.clusterName===d.response.cluster&&_.attributeName===d.response.attribute);if(!v){o&&console.warn(`DevicesTable updater cluster ${d.response.cluster}.${d.response.attribute} for device "${c.name}" serial "${c.serial}" not found in clusters`);return}v.attributeValue=typeof d.response.value=="object"?JSON.stringify(d.response.value,void 0,1).replaceAll('"',""):String(d.response.value),v.attributeLocalValue=d.response.value,W([...I]),o&&console.log(`DevicesTable updated attribute ${v.clusterName}.${v.attributeName} for device "${c.name}" serial "${c.serial}" to "${v.attributeValue}"`)}},[I,q,K,D]);r.useEffect(()=>{const d=c=>{if(o&&console.log("DevicesTable received WebSocket Message:",c),c.method==="refresh_required"&&c.response.changed==="devices")o&&console.log(`DevicesTable received refresh_required: changed=${c.response.changed} and sending /api/devices request`),l({id:T.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(c.method==="state_update"&&c.response)ce(c);else if(c.method==="/api/devices")o&&console.log(`DevicesTable received ${c.response.length} devices:`,c.response),b(c.response);else if(c.method==="/api/clusters"){o&&console.log(`DevicesTable received ${c.response.clusters.length} clusters for plugin ${c.response.plugin}:`,c.response),W(c.response.clusters);const v={};for(const _ of c.response.clusters)o&&console.log("Cluster:",_.endpoint),v[_.endpoint]?v[_.endpoint]++:v[_.endpoint]=1;B(Object.keys(v).length)}};return i(d,T.current),o&&console.log("DevicesTable added WebSocket listener"),()=>{s(d),o&&console.log("DevicesTable removed WebSocket listener")}},[l,i,s,ce]),r.useEffect(()=>{a&&(o&&console.log("DevicesTable sending api requests with id ",T.current),l({id:T.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:T.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:T.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,l]),r.useEffect(()=>{K&&q&&(o&&console.log("DevicesTable sending /api/clusters"),l({id:T.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:K,endpoint:Number(q)}}))},[K,q,l]),r.useEffect(()=>{if(n===""){N(h),te.current=h;return}const d=h.filter(c=>c.name.toLowerCase().includes(n)||c.serial.toLowerCase().includes(n));N(d),te.current=d},[h,n]);const w=d=>{if(d.uniqueId===D){M(null),Z(null),m(null),u(null);return}M(d.uniqueId),Z(d.pluginName),m(d.endpoint?d.endpoint.toString():null),u(d.name)};return o&&console.log("DevicesTable rendering..."),a?e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0px",padding:"0px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx(Me,{style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",maxHeight:`${K&&q?"30%":"100%"}`,flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Dt,{name:"Registered devices",getRowKey:Ni,onRowClick:w,rows:t,columns:Ti,footerLeft:`Total devices: ${t.length.toString()}`})}),K&&q&&e.jsx(Me,{style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",height:"70%",maxHeight:"70%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Dt,{name:"Clusters",title:p||"",getRowKey:Ri,rows:I,columns:Fi,footerLeft:`Total child endpoints: ${k-1}`})})]}):e.jsx(Je,{})}const _i=r.memo(Oi);function Hi(){const{online:n}=r.useContext(Ie),[a,l]=r.useState(""),[i,s]=r.useState("icon");r.useEffect(()=>{const b=localStorage.getItem(ee.devicesFilter);b&&l(b)},[]),r.useEffect(()=>{const b=localStorage.getItem(ee.devicesViewMode);b&&s(b)},[]);const g=b=>{l(b.target.value.toLowerCase()),localStorage.setItem(ee.devicesFilter,b.target.value.toLowerCase())},h=b=>{s(b),localStorage.setItem(ee.devicesViewMode,b)};return o&&console.log("Devices rendering..."),n?e.jsxs(Pt,{name:"Devices",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",padding:0,margin:0,gap:"20px",width:"100%"},children:[e.jsxs(fe,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(je,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(ke,{variant:"outlined",value:a,onChange:g,placeholder:"Enter the device name or serial",sx:{width:"260px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(fe,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(je,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(X,{onClick:()=>h("table"),"aria-label":"Table View",disabled:i==="table",children:e.jsx(V,{title:"Table View",children:e.jsx(Eo,{style:{color:i==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(X,{onClick:()=>h("icon"),"aria-label":"Icon View",disabled:i==="icon",children:e.jsx(V,{title:"Icon View (beta)",children:e.jsx(Vo,{style:{color:i==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),i==="table"&&e.jsx(_i,{filter:a}),i==="icon"&&e.jsx(Wi,{filter:a})]}):e.jsx(Je,{})}const Ei=r.memo(Hi);function Vi(){const{logLength:n,logAutoScroll:a,setMessages:l,setLogFilterLevel:i,setLogFilterSearch:s,online:g,filterLogMessages:h}=r.useContext(Ie),[b,t]=r.useState(localStorage.getItem(ee.logFilterLevel)??"info"),[N,I]=r.useState(localStorage.getItem(ee.logFilterSearch)??"*"),[W,k]=r.useState(n.current.toString()),[B,K]=r.useState(a.current),Z=D=>{const M=D.target.value;t(M),i(M),h(M,N),localStorage.setItem(ee.logFilterLevel,M),o&&console.log("handleLogFilterLevelChange called with value:",M)},q=D=>{const M=D.target.value;I(M),s(M),h(b,M),localStorage.setItem(ee.logFilterSearch,M),o&&console.log("handleLogFilterSearchChange called with value:",M)},m=D=>{const M=D.target.checked;K(M),a.current=M,h(b,N),localStorage.setItem(ee.logAutoScroll,M?"true":"false"),o&&console.log("handleAutoScrollChange called with value:",M)},p=D=>{const M=D.target.value;k(M),n.current=Number(M),localStorage.setItem(ee.logLength,M),o&&console.log("handleLogLengthChange called with value:",M)},u=()=>{o&&console.log("handleClearLogsClick called"),l([])};return o&&console.log("Logs rendering..."),g?e.jsxs(Pt,{name:"Logs",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(Ut,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(rt,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:b,onChange:Z,children:[e.jsx(H,{value:"debug",children:"Debug"}),e.jsx(H,{value:"info",children:"Info"}),e.jsx(H,{value:"notice",children:"Notice"}),e.jsx(H,{value:"warn",children:"Warn"}),e.jsx(H,{value:"error",children:"Error"}),e.jsx(H,{value:"fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"5px"},children:[e.jsx(Ut,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(V,{title:"Use /text/ for case-insensitive regex search",children:e.jsx(ke,{style:{width:"210px"},size:"small",id:"logsearch",variant:"outlined",value:N,onChange:q,slotProps:{input:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}})})]}),e.jsx(lt,{control:e.jsx(Xe,{checked:B,onChange:m}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsx(Ut,{id:"select-size-label",style:{color:"var(--div-text-color)"},children:"Log length:"}),e.jsxs(rt,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-size-label",id:"select-size",value:W,onChange:p,children:[e.jsx(H,{value:100,children:"100"}),e.jsx(H,{value:200,children:"200"}),e.jsx(H,{value:500,children:"500"}),e.jsx(H,{value:1e3,children:"1000"})]}),e.jsx(V,{title:"Clear the logs",children:e.jsx(me,{onClick:u,endIcon:e.jsx(ar,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Clear"})})]})]}),e.jsx("div",{style:{flex:"1",overflow:"auto",margin:"0px",padding:"0px"},children:e.jsx(qr,{})})]}):e.jsx(Je,{})}const Ai=r.memo(Vi),Ui=({open:n,ip:a,onClose:l,onSave:i})=>{const s=a?a.split(".").slice(0,3).join(".")+".1":"",[g,h]=r.useState("dhcp"),[b,t]=r.useState({ip:a??"",subnet:"255.255.255.0",gateway:s,dns:s}),N=k=>B=>{t({...b,[k]:B.target.value})},I=()=>{l()},W=()=>{i({type:g,...b}),l()};return e.jsxs(Be,{open:n,onClose:(k,B)=>{B==="backdropClick"||B==="escapeKeyDown"||l()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Qe,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Network Configuration"})]})}),e.jsxs(Ge,{dividers:!0,children:[e.jsxs(pr,{component:"fieldset",fullWidth:!0,children:[e.jsx($e,{component:"legend",children:"Select IP Configuration"}),e.jsxs(Er,{row:!0,value:g,onChange:k=>h(k.target.value),children:[e.jsx(lt,{value:"dhcp",control:e.jsx(Gt,{}),label:"DHCP"}),e.jsx(lt,{value:"static",control:e.jsx(Gt,{}),label:"Static"})]})]}),g==="static"&&e.jsxs(tt,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(tt,{size:6,children:e.jsx(ke,{label:"IP Address",fullWidth:!0,value:b.ip,onChange:N("ip")})}),e.jsx(tt,{size:6,children:e.jsx(ke,{label:"Subnet Mask",fullWidth:!0,value:b.subnet,onChange:N("subnet")})}),e.jsx(tt,{size:6,children:e.jsx(ke,{label:"Gateway",fullWidth:!0,value:b.gateway,onChange:N("gateway")})}),e.jsx(tt,{size:6,children:e.jsx(ke,{label:"DNS Server",fullWidth:!0,value:b.dns,onChange:N("dns")})})]})]}),e.jsxs(Ze,{children:[e.jsx(me,{onClick:I,children:"Cancel"}),e.jsx(me,{variant:"contained",onClick:W,children:"Save"})]})]})},zi=({open:n,onClose:a,onSave:l})=>{const[i,s]=r.useState(""),[g,h]=r.useState(""),b=B=>{s(B.target.value)},t=B=>{h(B.target.value)},N=i.length>0&&i===g,I=()=>{a()},W=()=>{N&&(l(i),a())},k=()=>{l(""),a()};return e.jsxs(Be,{open:n,onClose:(B,K)=>{K==="backdropClick"||K==="escapeKeyDown"||a()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Qe,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Change Password"})]})}),e.jsx(Ge,{dividers:!0,children:e.jsx(pr,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(tt,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(tt,{size:12,children:e.jsx(ke,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:i,onChange:b})}),e.jsx(tt,{size:12,children:e.jsx(ke,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:g,onChange:t,error:g!==""&&i!==g,helperText:g!==""&&i!==g?"Passwords do not match":""})})]})})}),e.jsxs(Ze,{children:[e.jsx(me,{onClick:I,children:"Cancel"}),e.jsx(me,{variant:"contained",onClick:W,disabled:!N,children:"Change"}),e.jsx(me,{variant:"contained",onClick:k,children:"Reset"})]})]})};function ht(n=1e3){let a=null;const l=(i=>{a!==null&&window.clearTimeout(a),a=window.setTimeout(()=>{i(),a=null},n)});return l.cancel=()=>{a!==null&&(window.clearTimeout(a),a=null)},l}const Kt=330;function qi(){const{mobile:n}=r.useContext(Re),{online:a,addListener:l,removeListener:i,sendMessage:s,getUniqueId:g}=r.useContext(Ie),[h,b]=r.useState(null),[t,N]=r.useState(null),I=r.useRef(g());return r.useEffect(()=>{const W=k=>{o&&console.log("Settings received WebSocket Message:",k),k.method==="refresh_required"&&k.response.changed==="settings"?(o&&console.log(`Settings received refresh_required: changed=${k.response.changed} and sending /api/settings request`),s({id:I.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):k.method==="/api/settings"&&(o&&console.log("Settings received /api/settings:",k.response),b(k.response.matterbridgeInformation),N(k.response.systemInformation))};return l(W,I.current),o&&console.log("Settings added WebSocket listener"),()=>{i(W),o&&console.log("Settings removed WebSocket listener")}},[l,i,s]),r.useEffect(()=>{a&&(o&&console.log("Settings received online"),s({id:I.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,s]),o&&console.log("Settings rendering..."),!a||!h||!t?e.jsx(Je,{}):e.jsx(Pt,{name:"Settings",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:Se&&n?"10px":"20px"},children:[e.jsx(Bi,{matterbridgeInfo:h,systemInfo:t}),e.jsx(Qi,{matterbridgeInfo:h}),e.jsx(Gi,{matterbridgeInfo:h}),e.jsx(Ji,{systemInfo:t})]})})}function Bi({matterbridgeInfo:n,systemInfo:a}){const{sendMessage:l,getUniqueId:i}=r.useContext(Ie),[s,g]=r.useState("bridge"),[h,b]=r.useState("Info"),[t,N]=r.useState(!1),[I,W]=r.useState("dark"),[k,B]=r.useState(localStorage.getItem(ee.homePagePlugins)!=="false"),[K,Z]=r.useState(localStorage.getItem(ee.homePageMode)??"devices"),[q,m]=r.useState(localStorage.getItem(ee.virtualMode)??"outlet"),p=r.useRef(i()),[u,D]=r.useState(!1),M=()=>D(!1),T=x=>{o&&console.log("handleSaveNetConfig called with config:",x),l({id:p.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:x})},[te,ce]=r.useState(!1),w=()=>ce(!1),d=x=>{o&&console.log("handleSaveChangePassword called with password:",x),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:x}}),ls(x)};r.useEffect(()=>{n&&(g(n.bridgeMode==="bridge"?"bridge":"childbridge"),b(n.loggerLevel.charAt(0).toUpperCase()+n.loggerLevel.slice(1)),N(n.fileLogger),m(n.virtualMode))},[n]),r.useEffect(()=>{const x=localStorage.getItem(ee.frontendTheme);x&&W(x)},[]);const c=x=>{o&&console.log("handleChangeBridgeMode called with value:",x.target.value),g(x.target.value),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:x.target.value}})},v=x=>{o&&console.log("handleChangeMbLoggerLevel called with value:",x.target.value),b(x.target.value),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:x.target.value}})},_=x=>{o&&console.log("handleLogOnFileMbChange called with value:",x.target.checked),N(x.target.checked),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:x.target.checked}})},E=x=>{const y=x.target.value;o&&console.log("handleChangeTheme called with value:",y),W(y),localStorage.setItem(ee.frontendTheme,y),document.body.setAttribute("frontend-theme",y)},ae=x=>{const y=x.target.checked;o&&console.log("handleChangeHomePagePlugins called with value:",y),B(y),localStorage.setItem(ee.homePagePlugins,y?"true":"false")},we=x=>{const y=x.target.value;o&&console.log("handleChangeHomePageMode called with value:",y),Z(y),localStorage.setItem(ee.homePageMode,y)},A=x=>{const y=x.target.value;o&&console.log("handleChangeVirtualMode called with value:",y),m(y),localStorage.setItem(ee.virtualMode,y),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:y}})};return!n||!a?null:e.jsxs(Me,{style:{flex:`1 1 ${Kt}px`},children:[e.jsx(Fe,{children:e.jsx(De,{children:"Matterbridge settings"})}),e.jsx(Ui,{open:u,ip:a.ipv4Address,onClose:M,onSave:T}),e.jsx(zi,{open:te,onClose:w,onSave:d}),e.jsxs(Ue,{style:{flexDirection:"column",padding:"10px",gap:"0px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx($e,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Mode:"}),e.jsxs(Er,{row:!0,name:"mode-buttons-group",value:s,onChange:c,children:[e.jsx(lt,{value:"bridge",control:e.jsx(Gt,{}),label:"Bridge",disabled:n.readOnly===!0}),e.jsx(lt,{value:"childbridge",control:e.jsx(Gt,{}),label:"Childbridge",disabled:n.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx($e,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(rt,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:h,onChange:v,children:[e.jsx(H,{value:"Debug",children:"Debug"}),e.jsx(H,{value:"Info",children:"Info"}),e.jsx(H,{value:"Notice",children:"Notice"}),e.jsx(H,{value:"Warn",children:"Warn"}),e.jsx(H,{value:"Error",children:"Error"}),e.jsx(H,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx($e,{style:{padding:"0px",margin:"0px"},id:"mblogger-file-label",children:"Log on file:"}),e.jsx(Xe,{checked:t,onChange:_,id:"mblogger-file",name:"logOnFileMb"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx($e,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(rt,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:I,onChange:E,children:[e.jsx(H,{value:"classic",children:"Classic"}),e.jsx(H,{value:"light",children:"Light"}),e.jsx(H,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx($e,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Xe,{checked:k,onChange:ae,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx($e,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(rt,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:K,onChange:we,children:[e.jsx(H,{value:"logs",children:"Logs"}),e.jsx(H,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx($e,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(rt,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:q,onChange:A,children:[e.jsx(H,{value:"disabled",children:"Disabled"}),e.jsx(H,{value:"outlet",children:"Outlet"}),e.jsx(H,{value:"light",children:"Light"}),e.jsx(H,{value:"switch",children:"Switch"}),e.jsx(H,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(me,{variant:"contained",color:"primary",onClick:()=>ce(!0),children:"Change password"})}),n.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(me,{variant:"contained",color:"primary",onClick:()=>D(!0),children:"Configure IP"})})]})]})}function Qi({matterbridgeInfo:n}){const{sendMessage:a,getUniqueId:l}=r.useContext(Ie),[i,s]=r.useState("Info"),[g,h]=r.useState(!1),[b,t]=r.useState(""),[N,I]=r.useState(""),[W,k]=r.useState(""),[B,K]=r.useState(""),[Z,q]=r.useState(""),[m,p]=r.useState(""),u=r.useRef(l()),D=r.useMemo(()=>ht(1e3),[]),M=r.useMemo(()=>ht(1e3),[]),T=r.useMemo(()=>ht(1e3),[]),te=r.useMemo(()=>ht(1e3),[]),ce=r.useMemo(()=>ht(1e3),[]),w=r.useMemo(()=>ht(1e3),[]);r.useEffect(()=>{n&&(s(["Debug","Info","Notice","Warn","Error","Fatal"][n.matterLoggerLevel]),h(n.matterFileLogger),t(n.matterMdnsInterface||""),I(n.matterIpv4Address||""),k(n.matterIpv6Address||""),K(n.matterPort?n.matterPort.toString():""),q(n.matterDiscriminator?n.matterDiscriminator.toString():""),p(n.matterPasscode?n.matterPasscode.toString():""))},[n]),r.useEffect(()=>()=>D.cancel(),[D]),r.useEffect(()=>()=>M.cancel(),[M]),r.useEffect(()=>()=>T.cancel(),[T]),r.useEffect(()=>()=>te.cancel(),[te]),r.useEffect(()=>()=>ce.cancel(),[ce]),r.useEffect(()=>()=>w.cancel(),[w]);const d=x=>{o&&console.log("handleChangeMjLoggerLevel called with value:",x.target.value),s(x.target.value),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:x.target.value}})},c=x=>{o&&console.log("handleLogOnFileMjChange called with value:",x.target.checked),h(x.target.checked),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:x.target.checked}})},v=x=>{o&&console.log("handleChangeMdnsInterface called with value:",x.target.value);const y=x.target.value;t(y),D(()=>{o&&console.log("debounced sendMessage setmdnsinterface with value:",y),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:y}})})},_=x=>{o&&console.log("handleChangeIpv4Address called with value:",x.target.value);const y=x.target.value;I(y),M(()=>{o&&console.log("debounced sendMessage setipv4address with value:",y),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:y}})})},E=x=>{o&&console.log("handleChangeIpv6Address called with value:",x.target.value);const y=x.target.value;k(y),T(()=>{o&&console.log("debounced sendMessage setipv6address with value:",y),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:y}})})},ae=x=>{o&&console.log("handleChangeMatterPort called with value:",x.target.value);const y=x.target.value;K(y),te(()=>{o&&console.log("debounced sendMessage setmatterport with value:",y),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:y}})})},we=x=>{o&&console.log("handleChangeMatterDiscriminator called with value:",x.target.value);const y=x.target.value;q(y),ce(()=>{o&&console.log("debounced sendMessage setmatterdiscriminator with value:",y),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:y}})})},A=x=>{o&&console.log("handleChangemMatterPasscode called with value:",x.target.value);const y=x.target.value;p(y),w(()=>{o&&console.log("debounced sendMessage setmatterpasscode with value:",y),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:y}})})};return n?e.jsxs(Me,{style:{flex:`1 1 ${Kt}px`},children:[e.jsx(Fe,{children:e.jsx(De,{children:"Matter settings"})}),e.jsxs(Ue,{style:{flexDirection:"column",padding:"10px",gap:"0px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx($e,{style:{padding:"0px",margin:"0px"},id:"mjlogger-level-label",children:"Logger level:"}),e.jsxs(rt,{style:{height:"30px"},labelId:"mjlogger-level-label",id:"mjlogger-level",value:i,onChange:d,children:[e.jsx(H,{value:"Debug",children:"Debug"}),e.jsx(H,{value:"Info",children:"Info"}),e.jsx(H,{value:"Notice",children:"Notice"}),e.jsx(H,{value:"Warn",children:"Warn"}),e.jsx(H,{value:"Error",children:"Error"}),e.jsx(H,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"10px"},children:[e.jsx($e,{style:{padding:"0px",margin:"0px"},id:"mjlogger-file-label",children:"Log on file:"}),e.jsx(Xe,{checked:g,onChange:c,id:"mjlogger-file",name:"logOnFileMj"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx($e,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Mdns interface:"}),e.jsx(ke,{value:b,onChange:v,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx($e,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv4 address:"}),e.jsx(ke,{value:N,onChange:_,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx($e,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv6 address:"}),e.jsx(ke,{value:W,onChange:E,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx($e,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning port:"}),e.jsx(ke,{value:B,onChange:ae,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx($e,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning discriminator:"}),e.jsx(ke,{value:Z,onChange:we,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx($e,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning passcode:"}),e.jsx(ke,{value:m,onChange:A,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})]}):null}function Gi({matterbridgeInfo:n}){return n?e.jsxs(Me,{style:{flex:`1 1 ${Kt}px`},children:[e.jsx(Fe,{children:e.jsx(De,{children:"Matterbridge info"})}),e.jsxs(Ue,{style:{flexDirection:"column",padding:"10px",gap:"5px"},children:[e.jsx(Ne,{value:n.matterbridgeVersion,label:"Current Version"}),e.jsx(Ne,{value:n.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(Ne,{value:n.rootDirectory,label:"Root Directory"}),e.jsx(Ne,{value:n.homeDirectory,label:"Home Directory"}),e.jsx(Ne,{value:n.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(Ne,{value:n.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(Ne,{value:n.globalModulesDirectory,label:"Global Module Directory"})]})]}):null}function Ji({systemInfo:n}){return n?e.jsxs(Me,{style:{flex:`1 1 ${Kt}px`},children:[e.jsx(Fe,{children:e.jsx(De,{children:"System info"})}),e.jsxs(Ue,{style:{flexDirection:"column",padding:"10px",gap:"5px"},children:[e.jsx(Ne,{value:n.interfaceName,label:"Interface name"}),e.jsx(Ne,{value:n.macAddress,label:"MAC Address"}),e.jsx(Ne,{value:n.ipv4Address,label:"IPv4 Address"}),e.jsx(Ne,{value:n.ipv6Address,label:"IPv6 Address"}),e.jsx(Ne,{value:n.nodeVersion,label:"Node Version"}),e.jsx(Ne,{value:n.hostname,label:"Hostname"}),e.jsx(Ne,{value:n.user,label:"User"})]})]}):null}function Ne({value:n,label:a,width:l}){return e.jsx(ke,{focused:!0,value:n,size:"small",label:a,variant:"standard",sx:{width:l?`${l-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)"}}}}})}const Ki=r.memo(qi);function Yi(){const{online:n,sendMessage:a,addListener:l,removeListener:i,getUniqueId:s}=r.useContext(Ie),{showSnackbarMessage:g}=r.useContext(Re),[h,b]=r.useState(null),[t,N]=r.useState([]),[I,W]=r.useState([]),[k,B]=r.useState(null),[K,Z]=r.useState({cpuUsage:0}),[q,m]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[p,u]=r.useState({systemUptime:"",processUptime:""}),D=r.useRef(s());return o&&console.log("Test uniqueId:",D),r.useEffect(()=>{o&&console.log("Test useEffect WebSocketMessage mounting");const M=T=>{if(T.method==="restart_required")o&&console.log("Test received restart_required"),g("Restart required",0);else if(T.method==="refresh_required")o&&console.log(`Test received refresh_required: changed=${T.response.changed} and sending api requests`),g("Refresh required",0),a({id:D.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:D.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:D.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(T.method==="memory_update")o&&console.log("Test received memory_update",T),m(T.response);else if(T.method==="cpu_update")o&&console.log("Test received cpu_update",T),Z(T.response);else if(T.method==="uptime_update")o&&console.log("Test received uptime_update",T),u(T.response);else if(T.method==="/api/settings"&&T.response)o&&console.log("Test received /api/settings:",T.response),g("Test received /api/settings",0),b(T.response);else if(T.method==="/api/plugins"&&T.response)o&&console.log(`Test received ${T.response.length} plugins:`,T.response),g("Test received /api/plugins",0),N(T.response);else if(T.method==="/api/devices"&&T.response){o&&console.log(`Test received ${T.response.length} devices:`,T.response),g("Test received /api/devices",0),W(T.response);for(const te of T.response)o&&console.log("Test sending /api/clusters for device:",te.pluginName,te.name,te.endpoint),a({id:D.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:te.pluginName,endpoint:te.endpoint||0}})}else T.method==="/api/clusters"&&T.response&&(o&&console.log(`Test received ${T.response.clusters.length} clusters for device ${T.response.deviceName} endpoint ${T.response.id}:${T.response.number}:`,T),g(`Test received /api/clusters for ${T.response.plugin}::${T.response.deviceName}`,0),B(T.response))};return l(M,D.current),o&&console.log("Test useEffect WebSocketMessage mounted"),()=>{o&&console.log("Test useEffect WebSocketMessage unmounting"),i(M),o&&console.log("Test useEffect WebSocketMessage unmounted")}},[l,i,a,g]),r.useEffect(()=>(o&&console.log("Test useEffect online mounting"),n&&o&&console.log("Test useEffect online received online"),o&&console.log("Test useEffect online mounted"),()=>{o&&console.log("Test useEffect online unmounted")}),[n,a,g]),o&&console.log("Test rendering..."),n?e.jsx(Pt,{name:"Test",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",gap:"20px",height:"100vh",width:"100vw"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px"}}),e.jsx("p",{children:"Welcome to the Test page of the Matterbridge frontend"})]})}):e.jsx(Je,{})}const Zi=r.memo(Yi);function Xi(n,a){o&&console.log("getCssVariable:",n,"defaultValue",a);const l=getComputedStyle(document.body).getPropertyValue(n).trim();return l||console.error("getCssVariable: undefined",l),l||a}function es(n){return Ao({palette:{primary:{main:n},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 ts(){const{mobile:n,showSnackbarMessage:a,showConfirmCancelDialog:l}=r.useContext(Re),{online:i,sendMessage:s,logMessage:g,addListener:h,removeListener:b,getUniqueId:t}=r.useContext(Ie),[N,I]=r.useState(!1),[W,k]=r.useState(!1),[B,K]=r.useState(!1),[Z,q]=r.useState(!1),[m,p]=r.useState(null),u=r.useRef(t()),[D,M]=r.useState(null),[T,te]=r.useState(null),[ce,w]=r.useState(null),[d,c]=r.useState(null),[v,_]=r.useState(null),E=Kr(),ae=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},we=()=>{window.open("https://matterbridge.io/")},A=()=>{window.open("https://matterbridge.io/README.html")},x=()=>{window.open("https://matterbridge.io/CHANGELOG.html")},y=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},P=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},F=()=>{s({id:u.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}}),K(!1)},S=()=>{s({id:u.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}}),q(!1)},re=()=>{s({id:u.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},Ce=()=>{o&&console.log("Header: handleShellySystemUpdateClick"),g("Matterbridge","Installing system updates..."),s({id:u.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},$=()=>{o&&console.log("Header: handleShellyMainUpdateClick"),g("Matterbridge","Installing software updates..."),s({id:u.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},C=()=>{o&&console.log("Header: handleShellyCreateSystemLog"),s({id:u.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},L=()=>{o&&console.log("Header: handleShellyDownloadSystemLog"),g("Matterbridge","Downloading Shelly system log..."),a("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},U=()=>{m?.matterbridgeInformation.restartMode===""?s({id:u.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):s({id:u.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},Q=()=>{s({id:u.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},z=()=>{s({id:u.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},f=()=>{s({id:u.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ue=()=>{s({id:u.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},J=j=>{M(j.currentTarget)},O=j=>{o&&console.log("Header: handleMenuClose",j),M(null),j==="/"||j==="/devices"||j==="/log"||j==="/settings"?E(j):j==="reset_frontend"?(g("Matterbridge","Resetting frontend UI..."),a("Resetting frontend UI...",5),Pn(),window.location.reload()):j==="download-mblog"?(g("Matterbridge","Downloading matterbridge log..."),a("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):j==="download-mjlog"?(g("Matterbridge","Downloading matter log..."),a("Downloading matter log...",5),window.location.href="./api/download-mjlog"):j==="view-mblog"?(g("Matterbridge","Loading matterbridge log..."),a("Loading matterbridge log...",5),window.open("./api/view-mblog","_blank","noopener,noreferrer")):j==="view-mjlog"?(g("Matterbridge","Loading matter log..."),a("Loading matter log...",5),window.open("./api/view-mjlog","_blank","noopener,noreferrer")):j==="view-diagnostic"?(g("Matterbridge","Loading diagnostic log..."),a("Loading diagnostic log...",5),window.open("./api/view-diagnostic","_blank","noopener,noreferrer")):j==="download-diagnostic"?(g("Matterbridge","Downloading diagnostic log..."),a("Downloading diagnostic log...",5),window.location.href="./api/download-diagnostic"):j==="view-history"?s({id:u.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):j==="download-history"?s({id:u.current,sender:"Header",method:"/api/downloadhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):j==="view-shellylog"?(g("Matterbridge","Loading shelly system log..."),a("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):j==="download-mbstorage"?(g("Matterbridge","Downloading matterbridge storage..."),a("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):j==="download-pluginstorage"?(g("Matterbridge","Downloading matterbridge plugins storage..."),a("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):j==="download-pluginconfig"?(g("Matterbridge","Downloading matterbridge plugins config..."),a("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):j==="download-mjstorage"?(g("Matterbridge","Downloading matter storage..."),a("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):j==="download-backup"?(g("Matterbridge","Downloading backup..."),a("Downloading backup...",10),window.location.href="./api/download-backup"):j==="update"?F():j==="updatedev"?S():j==="updatecheck"?re():j==="shelly-sys-update"?Ce():j==="shelly-main-update"?$():j==="shelly-create-system-log"?C():j==="shelly-download-system-log"?L():j==="softreset"?f():j==="hardreset"?ue():j==="restart"?U():j==="shutdown"?Q():j==="reboot"?z():j==="create-backup"?s({id:u.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):j==="unregister"?s({id:u.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):j==="reset"?s({id:u.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):j==="factoryreset"&&s({id:u.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},xe=j=>{o&&console.log("Header: handleMenuCloseCancel:",j),M(null)},de=j=>{te(j.currentTarget)},Le=()=>{te(null)},Oe=j=>{w(j.currentTarget)},ve=()=>{w(null)},ge=j=>{c(j.currentTarget)},pe=()=>{c(null)},_e=j=>{_(j.currentTarget)},He=()=>{_(null)},ot=()=>{os(),o&&console.log("Matterbridge logo clicked: debug is now",o)};return r.useEffect(()=>{const j=ne=>{o&&console.log("Header received WebSocket Message:",ne),ne.method==="/api/settings"&&ne.id===u.current?(o&&console.log("Header received settings:",ne.response),p(ne.response),I(ne.response.matterbridgeInformation.restartRequired||ne.response.matterbridgeInformation.fixedRestartRequired),k(ne.response.matterbridgeInformation.fixedRestartRequired),K(ne.response.matterbridgeInformation.updateRequired)):ne.method==="refresh_required"&&ne.response.changed==="settings"?(o&&console.log(`Header received refresh_required: changed=${ne.response.changed} and sending /api/settings request`),s({id:u.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):ne.method==="restart_required"?(o&&console.log(`Header received restart_required with fixed: ${ne.response.fixed}`),I(!0),ne.response.fixed===!0&&k(!0)):ne.method==="restart_not_required"?(o&&console.log("Header received restart_not_required"),I(!1)):ne.method==="update_required"?(o&&console.log("Header received update_required"),ne.response.devVersion===!0?q(!0):K(!0),s({id:u.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):ne.method==="shelly_sys_update"?(o&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),p(We=>We?{matterbridgeInformation:{...We.matterbridgeInformation,shellySysUpdate:ne.response.available},systemInformation:We.systemInformation}:null)):ne.method==="shelly_main_update"?(o&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),p(We=>We?{matterbridgeInformation:{...We.matterbridgeInformation,shellyMainUpdate:ne.response.available},systemInformation:We.systemInformation}:null)):ne.method==="/api/viewhistorypage"&&ne.id===u.current&&ne.success===!0?(o&&console.log("Header received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer")):ne.method==="/api/downloadhistorypage"&&ne.id===u.current&&ne.success===!0&&(o&&console.log("Header received /api/downloadhistorypage success"),window.location.href="./api/downloadhistory")};return h(j,u.current),o&&console.log(`Header added WebSocket listener id ${u.current}`),()=>{b(j),o&&console.log("Header removed WebSocket listener")}},[h,b,s,a]),r.useEffect(()=>{i&&(o&&console.log("Header sending /api/settings and /api/checkupdates requests"),s({id:u.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),s({id:u.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,s]),o&&console.log("Header rendering... mobile %s",n),!i||!m?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",width:"100%",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:ot}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:e.jsxs("nav",{children:[e.jsx(Lt,{to:"/",className:"nav-link",children:"Home"}),e.jsx(Lt,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(Lt,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(Lt,{to:"/settings",className:"nav-link",children:"Settings"})]})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[!m.matterbridgeInformation.readOnly&&e.jsx(V,{title:`Matterbridge v.${m.matterbridgeInformation.matterbridgeVersion}`,children:e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:["v.",m.matterbridgeInformation.matterbridgeVersion.split("-")[0]+(m.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"@dev":"")+(m.matterbridgeInformation.matterbridgeVersion.includes("-edge-")?"@edge":"")+(m.matterbridgeInformation.matterbridgeVersion.includes("-local-")?"@local":"")+(m.matterbridgeInformation.matterbridgeVersion.includes("-git-")?"@git":"")]})}),m.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),m.matterbridgeInformation.bridgeMode!==""&&m.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:m.matterbridgeInformation.bridgeMode})}):null,m.matterbridgeInformation.restartMode!==""&&m.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:m.matterbridgeInformation.restartMode})}):null,m.matterbridgeInformation.profile&&m.matterbridgeInformation.profile!==""&&m.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:m.matterbridgeInformation.profile})}):null,o&&e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:[n?"Mobile ":"Desktop ",`${Bt}x${Qt}`,` enabled ${localStorage.getItem(ee.enableMobile)!=="false"}`]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"5px"},children:[m.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:y})}):null,m.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Give a star to Matterbridge",children:e.jsx(X,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:P,children:e.jsx(Hr,{})})}):null,m.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Sponsor Matterbridge",children:e.jsx(X,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:ae,children:e.jsx(ur,{})})}):null,e.jsx(V,{title:"Matterbridge homepage",children:e.jsx(X,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:we,children:e.jsx(Fr,{})})}),e.jsx(V,{title:"Matterbridge help",children:e.jsx(X,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:A,children:e.jsx(dr,{})})}),e.jsx(V,{title:"Matterbridge changelog",children:e.jsx(X,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:x,children:e.jsx(Jt,{})})}),m.matterbridgeInformation&&!m.matterbridgeInformation.readOnly&&B&&e.jsx(V,{title:`Update matterbridge to latest version v.${m.matterbridgeInformation.matterbridgeLatestVersion}`,children:e.jsx(X,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:F,children:e.jsx(qe,{})})}),m.matterbridgeInformation&&!m.matterbridgeInformation.readOnly&&Z&&e.jsx(V,{title:`Update matterbridge to latest dev version v.${m.matterbridgeInformation.matterbridgeDevVersion}`,children:e.jsx(X,{style:{color:"var(--secondary-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:S,children:e.jsx(qe,{})})}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&m.matterbridgeInformation.shellySysUpdate&&e.jsx(V,{title:"Shelly system update",children:e.jsx(X,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:Ce,children:e.jsx(qe,{})})}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&m.matterbridgeInformation.shellyMainUpdate&&e.jsx(V,{title:"Shelly software update",children:e.jsx(X,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:$,children:e.jsx(qe,{})})}),e.jsx(V,{title:"Restart matterbridge",children:e.jsx(X,{style:{color:N||W?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:U,children:e.jsx(qt,{})})}),m.matterbridgeInformation.restartMode===""?e.jsx(V,{title:"Shut down matterbridge",children:e.jsx(X,{style:{color:N||W?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:Q,children:e.jsx(et,{})})}):null,e.jsx(V,{title:"Download, backup and more",children:e.jsx(X,{onClick:J,children:e.jsx(Uo,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(Ct,{id:"command-menu",anchorEl:D,keepMounted:!0,open:!!D,onClose:()=>O(""),children:[Se&&n&&e.jsxs(H,{onClick:()=>O("/"),children:[e.jsx(Y,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Home page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),Se&&n&&e.jsxs(H,{onClick:()=>O("/devices"),children:[e.jsx(Y,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Devices page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),Se&&n&&e.jsxs(H,{onClick:()=>O("/log"),children:[e.jsx(Y,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Logs page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),Se&&n&&e.jsxs(H,{onClick:()=>O("/settings"),children:[e.jsx(Y,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Settings page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&!m.matterbridgeInformation.readOnly&&e.jsxs(H,{onClick:()=>O("update"),children:[e.jsx(Y,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&!m.matterbridgeInformation.readOnly&&e.jsxs(H,{onClick:()=>O("updatedev"),children:[e.jsx(Y,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&!m.matterbridgeInformation.readOnly&&e.jsxs(H,{onClick:()=>O("updatecheck"),children:[e.jsx(Y,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&m.matterbridgeInformation.shellySysUpdate&&e.jsxs(H,{onClick:()=>O("shelly-sys-update"),children:[e.jsx(Y,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&m.matterbridgeInformation.shellyMainUpdate&&e.jsxs(H,{onClick:()=>O("shelly-main-update"),children:[e.jsx(Y,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(H,{onClick:()=>O("restart"),children:[e.jsx(Y,{children:e.jsx(qt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation.restartMode===""?e.jsxs(H,{onClick:()=>O("shutdown"),children:[e.jsx(Y,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&e.jsxs(H,{onClick:()=>{l("Reboot","Are you sure you want to reboot the Shelly board?","reboot",O,xe)},children:[e.jsx(Y,{children:e.jsx(qt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(Rt,{}),e.jsxs(H,{onClick:Oe,children:[e.jsx(Y,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ct,{id:"sub-menu-view",anchorEl:ce,keepMounted:!0,open:!!ce,onClose:ve,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(H,{onClick:()=>{ss(),ve(),xe(""),window.open("/home","_self")},children:[e.jsx(Y,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Desktop site",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(H,{onClick:()=>{is(),ve(),xe(""),window.open("/home","_self")},children:[e.jsx(Y,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Mobile site",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(H,{onClick:()=>{O("view-mblog"),ve()},children:[e.jsx(Y,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(H,{onClick:()=>{O("view-mjlog"),ve()},children:[e.jsx(Y,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(H,{onClick:()=>{O("view-diagnostic"),ve()},children:[e.jsx(Y,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(H,{onClick:()=>{O("view-history"),ve()},children:[e.jsx(Y,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&e.jsxs(H,{onClick:()=>{O("view-shellylog"),ve()},children:[e.jsx(Y,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Rt,{}),e.jsxs(H,{onClick:ge,children:[e.jsx(Y,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ct,{id:"sub-menu-download",anchorEl:d,keepMounted:!0,open:!!d,onClose:pe,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(H,{onClick:()=>{O("download-mbstorage"),pe()},children:[e.jsx(Y,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(H,{onClick:()=>{O("download-pluginstorage"),pe()},children:[e.jsx(Y,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(H,{onClick:()=>{O("download-pluginconfig"),pe()},children:[e.jsx(Y,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(H,{onClick:()=>{O("download-mblog"),pe()},children:[e.jsx(Y,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(H,{onClick:()=>{O("download-mjstorage"),pe()},children:[e.jsx(Y,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(H,{onClick:()=>{O("download-mjlog"),pe()},children:[e.jsx(Y,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(H,{onClick:()=>{O("download-diagnostic"),pe()},children:[e.jsx(Y,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(H,{onClick:()=>{O("download-history"),pe()},children:[e.jsx(Y,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&e.jsxs(H,{onClick:()=>{O("shelly-create-system-log"),pe()},children:[e.jsx(Y,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&e.jsxs(H,{onClick:()=>{O("shelly-download-system-log"),pe()},children:[e.jsx(Y,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Rt,{}),e.jsxs(H,{onClick:de,children:[e.jsx(Y,{children:e.jsx(rr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ct,{id:"sub-menu-backup",anchorEl:T,keepMounted:!0,open:!!T,onClose:Le,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(H,{onClick:()=>{O("create-backup"),Le()},children:[e.jsx(Y,{children:e.jsx(rr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(H,{onClick:()=>{O("download-backup"),Le()},children:[e.jsx(Y,{children:e.jsx(rr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Rt,{}),e.jsxs(H,{onClick:_e,children:[e.jsx(Y,{children:e.jsx(zo,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ct,{id:"sub-menu-reset",anchorEl:v,keepMounted:!0,open:!!v,onClose:He,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(H,{onClick:()=>{He(),l("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",O,xe)},children:[e.jsx(Y,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Reset the frontend UI...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(H,{onClick:()=>{He(),l("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",O,xe)},children:[e.jsx(Y,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(H,{onClick:()=>{He(),l("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",O,xe)},children:[e.jsx(Y,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!m.matterbridgeInformation.readOnly&&e.jsxs(H,{onClick:()=>{He(),l("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",O,xe)},children:[e.jsx(Y,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&e.jsxs(H,{onClick:()=>{He(),l("Network reset","Are you sure you want to factory reset the network parameters?","softreset",O,xe)},children:[e.jsx(Y,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&e.jsxs(H,{onClick:()=>{He(),l("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",O,xe)},children:[e.jsx(Y,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(le,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const Lr=r.memo(ts),Br=1200,Qr=900;let Bt,Qt;function Wr(){if(typeof window<"u"){Bt=Math.floor(window.visualViewport?.width??window.innerWidth),Qt=Math.floor(window.visualViewport?.height??window.innerHeight);const n=Bt<Br||Qt<Qr;return o&&console.log("Visual viewport (%s) width %i height %i mobile %s",window.visualViewport!==void 0,Bt,Qt,n),n}return!1}function rs({children:n}){const{mobile:a,setMobile:l}=r.useContext(Re),{logAutoScroll:i}=r.useContext(Ie);return r.useEffect(()=>{function s(){const g=Wr();g&&(i.current=!1,localStorage.setItem(ee.logAutoScroll,"false")),l(g)}return window.addEventListener("resize",s),l(Wr()),()=>window.removeEventListener("resize",s)},[i,l]),o&&console.log("MbfScreen rendering... mobile %s",a),Se&&a?e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"visible",margin:"0px",padding:"10px",gap:"10px"},children:[e.jsx(Lr,{}),e.jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"10px"},children:n})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",width:a?`${Br}px`:"calc(100vw - 40px)",height:a?`${Qr}px`:"calc(100vh - 40px)",margin:"0px",padding:"20px",gap:"20px"},children:[e.jsx(Lr,{}),e.jsx("div",{style:{display:"flex",flexDirection:"row",width:"100%",height:"calc(100% - 60px)",margin:"0px",padding:"0px",gap:"20px"},children:n})]})}let o=!1;const os=()=>{o=!o},ns=!1;let Se=localStorage.getItem(ee.enableMobile)!=="false";const is=()=>{Se=!0,localStorage.setItem(ee.enableMobile,"true")},ss=()=>{Se=!1,localStorage.setItem(ee.enableMobile,"false")};let xt;const ls=n=>{xt=n};let Mt=!1,Tr="/",ft="/",lr="/";function as({setLoggedIn:n}){const[a,l]=r.useState(""),[i,s]=r.useState(""),g={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},h={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)"},b={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)"},t=async I=>{try{const W=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:I})});if(W.ok){const{valid:k}=await W.json();k?(n(!0),I!==""&&(xt=I)):I!==""&&s("Incorrect password!")}else console.error("Failed to log in:",W.statusText)}catch(W){console.error("Failed to log in:",W)}},N=I=>{I.preventDefault(),t(a)};return t(""),e.jsx("div",{style:g,children:e.jsxs("form",{onSubmit:N,style:h,children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h3",{style:{color:"var(--div-text-color)"},children:"Welcome to Matterbridge"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:"20px"},children:[e.jsx("input",{type:"text",name:"username",autoComplete:"username",style:{display:"none"},tabIndex:-1}),e.jsx("input",{type:"password",value:a,onChange:I=>l(I.target.value),style:b,placeholder:"password",autoComplete:"current-password"}),e.jsx("button",{type:"submit",style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",borderColor:"var(--div-bg-color)"},children:"Log in"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:0,height:"30px"},children:i&&e.jsx("p",{style:{color:"red"},children:i})})]})})}function cs(){const[n,a]=r.useState(!1),l=localStorage.getItem(ee.frontendTheme)||"dark";o&&console.log('Setting frontend theme "%s"',l),document.body.setAttribute("frontend-theme",l);const i=Xi("--primary-color","#1976d2");o&&console.log('Primary color from CSS "%s"',i);const s=es(i);return Tr=window.location.href,ft=window.location.pathname,lr=ft.includes("/matterbridge/")?"/matterbridge/":ft.includes("/api/hassio_ingress/")?ft:"/",Mt=ft.includes("/api/hassio_ingress/"),console.log("Loading App..."),console.log(`- href = "${Tr}"`),console.log(`- pathname = "${ft}"`),console.log(`- baseName = "${lr}"`),console.log(`- isIngress = "${Mt}"`),n?e.jsx(qo,{theme:s,children:e.jsx(oo,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(Ln,{children:e.jsx(Wn,{children:e.jsx(Yr,{basename:lr,children:e.jsx(rs,{children:e.jsxs(Zr,{children:[e.jsx(ct,{path:"/",element:e.jsx(bi,{})}),e.jsx(ct,{path:"/devices",element:e.jsx(Ei,{})}),e.jsx(ct,{path:"/log",element:e.jsx(Ai,{})}),e.jsx(ct,{path:"/settings",element:e.jsx(Ki,{})}),e.jsx(ct,{path:"/test",element:e.jsx(Zi,{})}),e.jsx(ct,{path:"*",element:e.jsx(Xr,{to:"/"})})]})})})})})})}):e.jsx(as,{setLoggedIn:a})}eo.createRoot(document.getElementById("root")).render(e.jsx(to.StrictMode,{children:e.jsx(cs,{})}));
|