matterbridge 3.3.0-dev-20250930-6b65506 → 3.3.0-dev-20251001-9518e1d

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.
@@ -1,7 +1,7 @@
1
- import{B as e,y as r,S as nt,U as xr,V as br,X as qe,Y as vr,Z as yr,I as jr}from"./vendor_node_modules.js";import{u as Cr,S as wr}from"./vendor_notistack.js";import{D as $e,a as Ne,b as Le,B as ie,c as Oe,d as Y,A as Sr,I as K,C as kr,e as Ir,T as R,f as me,M as Mr,g as Ge,h as N,i as Pe,F as Dr,j as xt,k as se,l as Ee,K as Tt,m as Rt,n as yt,L as it,o as Xe,p as st,q as G,W as tt,r as at,H as lt,s as te,V as Ht,t as Ot,u as Pr,E as $r,v as Nr,w as Ve,Q as Jt,R as bt,S as $t,U as Lr,P as Wr,x as Fr,y as Tr,z as Zt,G as Yt,J as vt,N as Rr,O as Xt,X as Hr,Y as Or,Z as Vr,_ as Vt,$ as Er,a0 as _r,a1 as Ar,a2 as qr,a3 as zr,a4 as Br,a5 as Ur,a6 as Et,a7 as Qr,a8 as Gr,a9 as Kr,aa as Jr,ab as Zr,ac as Yr,ad as Xr,ae as eo,af as to,ag as ro,ah as oo,ai as no,aj as io,ak as so,al as ao,am as _t,an as Ke,ao as er,ap as ye,aq as tr,ar as jt,as as He,at as lo,au as co,av as po,aw as Re,ax as Ae,ay as uo,az as dt,aA as ct,aB as St,aC as go,aD as mo}from"./vendor_mui.js";import{Q as ho}from"./vendor_qrcode.js";import{I as re,m as At,a as fo,b as xo,c as qt,d as bo,e as vo,f as yo,g as jo,h as Co,i as wo,j as So,k as ko,l as Io,n as Mo,o as Do,p as Po,q as zt,r as $o,s as No,t as Lo,u as Wo,v as Fo,w as To,x as Ro,y as Ho,z as Bt,A as Oo,B as Vo}from"./vendor_mdi.js";import{F as Eo,v as _o,e as Ao,a as qo,g as zo,b as Bo,c as Uo,d as kt,A as Qo}from"./vendor_rjsf.js";import"./vendor_lodash.js";import"./vendor_emotion.js";(function(){const c=document.createElement("link").relList;if(c&&c.supports&&c.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const h of u.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&s(h)}).observe(document,{childList:!0,subtree:!0});function l(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=l(a);fetch(a.href,u)}})();function Go({open:n,title:c,message:l,onConfirm:s,onCancel:a}){const u=t=>{o&&console.log("Confirmed"),t.preventDefault(),s()},h=t=>{o&&console.log("Canceled"),t.preventDefault(),a()};return e.jsxs($e,{open:n,children:[e.jsx(Ne,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:c})]})}),e.jsxs(Le,{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(ie,{onClick:u,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(ie,{onClick:h,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const Ko=({open:n,output:c,packageName:l,onInstall:s,onClose:a})=>{const u=r.useRef(null);return r.useEffect(()=>{o&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom: ${u.current}`),setTimeout(()=>{o&&console.log("Scrolling to bottom:",u.current),u.current?.scrollIntoView({behavior:"smooth"})},0)},[c]),e.jsxs($e,{open:n,onClose:(h,t)=>{t==="backdropClick"||t==="escapeKeyDown"||a()},slotProps:{paper:{sx:{width:"70vw",maxWidth:"70vw",height:"70vw",maxHeight:"70vh",overflow:"hidden"}}},children:[e.jsx(Ne,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsxs("h4",{style:{margin:0},children:["Install",s?"":"ing"," package ",l]})]})}),e.jsxs(Le,{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:"Install 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:[c.split(`
2
- `).map((h,t)=>e.jsx("li",{style:{padding:0,margin:0,wordBreak:"break-all"},children:h},t)),e.jsx("li",{ref:u,style:{padding:0,margin:0}})]})]}),e.jsxs(Oe,{children:[s&&e.jsx(ie,{variant:"contained",onClick:s,children:"Install"}),e.jsx(ie,{onClick:a,children:"Close"})]})]})},pt=[],_e=r.createContext(null);function Jo({children:n}){const[c,l]=r.useState(!1),[s,a]=r.useState(null),{enqueueSnackbar:u,closeSnackbar:h}=Cr(),t=r.useCallback(z=>{o&&console.log(`UiProvider closeSnackbarMessage: message ${z}`);const w=pt.findIndex(A=>A.message===z);w!==-1&&(h(pt[w].key),pt.splice(w,1),o&&console.log(`UiProvider closeSnackbarMessage: message ${z} removed from persistMessages`))},[h]),I=r.useCallback((z,w,A)=>{o&&console.log(`UiProvider showSnackbarMessage: message ${z} timeout ${w}`);const P=u(z,{variant:"default",autoHideDuration:w==null||w>0?(w??5)*1e3:null,persist:w===0,content:M=>e.jsx(Y,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(Sr,{severity:A??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>h(M),action:e.jsx(K,{size:"small",onClick:()=>h(M),sx:{color:"#fff"},children:e.jsx(kr,{fontSize:"small"})}),children:z},M)},M)});w===0&&(o&&console.log(`UiProvider showSnackbarMessage: message ${z} timeout ${w} - persist key ${P}`),pt.push({message:z,key:P}))},[u,h]),[W,C]=r.useState(!1),[S,E]=r.useState(""),[D,f]=r.useState(""),[V,O]=r.useState(""),x=r.useRef(null),j=r.useRef(null),$=()=>{o&&console.log(`UiProvider handle confirm action ${V}`),C(!1),x.current&&x.current(V)},_=()=>{o&&console.log(`UiProvider handle cancel action ${V}`),C(!1),j.current&&j.current(V)},F=r.useCallback((z,w,A,P,M)=>{o&&console.log(`UiProvider showConfirmCancelDialog for command ${A}`),E(z),f(w),O(A),x.current=P,j.current=M,C(!0)},[]),[v,H]=r.useState(!1),[b,d]=r.useState(""),[i,p]=r.useState(""),g=r.useCallback(z=>{o&&console.log(`UiProvider show install progress for package ${z}`),d(z),p(`Starting installation of ${z}...
3
- `),H(!0)},[]),T=r.useCallback(z=>{o&&console.log(`UiProvider addInstallProgress: output ${z}`),p(w=>w+z+`
4
- `)},[]),ce=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressSuccess: package ${b}`),p(z=>z+`Successfully installed ${b}
5
- `)},[b]),be=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressError: package ${b}`),p(z=>z+`Failed to install ${b}
6
- `)},[b]),ne=r.useCallback(()=>{o&&console.log("UiProvider hide install progress"),H(!1)},[]),Ce=()=>{o&&console.log("UiProvider handle install close action"),H(!1),d(""),p("")},J=r.useMemo(()=>({mobile:c,setMobile:l,currentPage:s,setCurrentPage:a,showSnackbarMessage:I,closeSnackbarMessage:t,closeSnackbar:h,showConfirmCancelDialog:F,showInstallProgress:g,exitInstallProgressSuccess:ce,exitInstallProgressError:be,hideInstallProgress:ne,addInstallProgress:T}),[c,s,l,a,I,t,h,F,g,ce,be,ne,T]);return e.jsxs(_e.Provider,{value:J,children:[e.jsx(Go,{open:W,title:S,message:D,onConfirm:$,onCancel:_}),e.jsx(Ko,{open:v,packageName:b,output:i,onClose:Ce}),n]})}const rr=r.createContext(null),fe=r.createContext(null);function Zo({children:n}){const[c,l]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[s,a]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[u,h]=r.useState([]),[t,I]=r.useState(1e3),[W,C]=r.useState(!0),[S,E]=r.useState(!1),{showSnackbarMessage:D,closeSnackbarMessage:f,closeSnackbar:V,showInstallProgress:O,hideInstallProgress:x,exitInstallProgressSuccess:j,exitInstallProgressError:$,addInstallProgress:_}=r.useContext(_e),F=r.useRef([]),v=r.useRef(null),H=r.useRef(1),b=r.useRef(Math.floor(Math.random()*999e3)+1e3),d=r.useRef(null),i=r.useRef(null),p=r.useRef(null),g=r.useRef(c),T=r.useRef(s),ce=r.useRef(0),be=r.useRef(null),ne=r.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),Ce=r.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),J=100,z=60,w=50,A=300,P=10;r.useEffect(()=>(o&&console.log("WebSocket messages started counter interval"),be.current=setInterval(()=>{ce.current>0&&(o&&console.log(`WebSocket messages received in the last ${P} seconds: ${ce.current*(60/P)} messages/minute`),ce.current=0)},P*1e3),()=>{o&&console.log("WebSocket messages stopped counter interval"),be.current&&clearInterval(be.current),be.current=null}),[]),r.useEffect(()=>{g.current=c},[c]),r.useEffect(()=>{T.current=s},[s]);const M=r.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),k=r.useCallback(U=>{if(v.current&&v.current.readyState===WebSocket.OPEN)try{o&&console.log(`WebSocket sending message with id ${U.id}:`,U),U.id===void 0&&(U.id=b.current);const m=JSON.stringify(U);v.current.send(m),o&&console.log("WebSocket sent message:",U)}catch(m){o&&console.error(`WebSocket error sending message: ${m}`)}else o&&console.error("WebSocket message not sent, WebSocket not connected:",U)},[]),L=r.useCallback((U,m)=>{h(he=>[...he,{level:U,time:"",name:"",message:m}])},[]),q=r.useCallback((U,m)=>{l(U),a(m),L("WebSocket",`Filtering by log level "${U}" and log search "${m}"`)},[L]),Z=r.useCallback((U,m)=>{o&&console.log(`WebSocket addListener id ${m}:`,U),(m==null||isNaN(m)||m===0)&&console.error("WebSocket addListener called without id, listener not added:",U),F.current=[...F.current,{listener:U,id:m}],o&&console.log("WebSocket addListener total listeners:",F.current.length)},[]),pe=r.useCallback(U=>{o&&console.log("WebSocket removeListener:",U),F.current=F.current.filter(m=>m.listener!==U),o&&console.log("WebSocket removeListener total listeners:",F.current.length)},[]),ae=r.useCallback(()=>{ne===""||ne===null||ne===void 0||(L("WebSocket",`Connecting to WebSocket: ${ne}`),v.current=new WebSocket(ne),v.current.onmessage=U=>{S||E(!0),ce.current+=1;try{const m=JSON.parse(U.data);if(m.id===void 0||m.src===void 0||m.dst===void 0){o&&console.error("WebSocket undefined message id/src/dst:",m);return}if(m.src!=="Matterbridge"||m.dst!=="Frontend"){o&&console.error("WebSocket invalid message src/dst:",m);return}if(m.error){o&&console.error("WebSocket error message response:",m);return}if(m.id===b.current&&m.method==="pong"&&m.response==="pong"){o&&console.log(`WebSocket pong response message id ${m.id}:`,m),i.current&&clearTimeout(i.current),i.current=null;return}else if(m.method==="snackbar"&&m.response&&m.response.message){o&&console.log(`WebSocket message id ${m.id} method ${m.method}:`,m),D(m.response.message,m.response.timeout,m.response.severity);return}else if(m.method==="close_snackbar"&&m.response&&m.response.message){o&&console.log(`WebSocket message id ${m.id} method ${m.method}:`,m),f(m.response.message);return}else if(m.method==="log"){if(!m.response||!m.response.level||!m.response.time||!m.response.name||!m.response.message||(m.response.level==="spawn"&&(m.response.name==="Matterbridge:spawn-init"?O(m.response.message):m.response.name==="Matterbridge:spawn-exit-success"?j():m.response.name==="Matterbridge:spawn-exit-error"?$():_(m.response.message+`
7
- `)),["debug","info","notice","warn","error","fatal"].includes(m.response.level)&&(g.current==="info"&&m.response.level==="debug"||g.current==="notice"&&(m.response.level==="debug"||m.response.level==="info")||g.current==="warn"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice")||g.current==="error"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn")||g.current==="fatal"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn"||m.response.level==="error")))||T.current!=="*"&&T.current!==""&&!m.response.message.toLowerCase().includes(T.current.toLowerCase())&&!m.response.name.toLowerCase().includes(T.current.toLowerCase())||m.response.name==="Commissioning"&&m.response.message.includes("is uncommissioned"))return;h(ve=>{const de=[...ve,{level:m.response.level,time:m.response.time,name:m.response.name,message:m.response.message}];return de.length>t*2?de.slice(t):de})}else{if(o&&console.log(`WebSocket received message id ${m.id} method ${m.method}:`,m),m.id===0)F.current.forEach(he=>he.listener(m));else{const he=F.current.find(ve=>ve.id===m.id);he?he.listener(m):o&&console.debug(`WebSocket no listener found for message id ${m.id}:`,m)}return}}catch(m){console.error(`WebSocketUse error parsing message: ${m}`)}},v.current.onopen=()=>{o&&console.log(`WebSocket: Connected to WebSocket: ${ne}`),L("WebSocket",`Connected to WebSocket: ${ne}`),E(!0),V(),H.current=1,p.current=setTimeout(()=>{d.current=setInterval(()=>{k({id:b.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{o&&console.error(`WebSocketUse: No pong response received from WebSocket: ${ne}`),L("WebSocket",`No pong response received from WebSocket: ${ne}`),E(!1)},1e3*w)},1e3*z)},1e3*A)},v.current.onclose=()=>{o&&console.error(`WebSocket: Disconnected from WebSocket ${Ce?"with Ingress":""}: ${ne}`),L("WebSocket",`Disconnected from WebSocket: ${ne}`),E(!1),V(),x(),p.current&&clearTimeout(p.current),i.current&&clearTimeout(i.current),d.current&&clearInterval(d.current),L("WebSocket",`Reconnecting (attempt ${H.current} of ${J}) to WebSocket${Ce?" (Ingress)":""}: ${ne}`),Ce?setTimeout(le,5e3):H.current===1?le():H.current<J?setTimeout(le,1e3*H.current):L("WebSocket",`Reconnect attempts exceeded limit of ${J} retries, refresh the page to reconnect to: ${ne}`),H.current=H.current+1},v.current.onerror=U=>{o&&console.error(`WebSocket: WebSocket error connecting to ${ne}:`,U),L("WebSocket",`WebSocket error connecting to ${ne}`)})},[ne]),le=r.useCallback(()=>{o&&console.log(`WebSocket attemptReconnect ${H.current}/${J} to:`,ne),ae()},[ae]);r.useEffect(()=>(ae(),()=>{v.current&&v.current.readyState===WebSocket.OPEN&&v.current.close()}),[ae]);const ge=r.useMemo(()=>({messages:u,maxMessages:t,autoScroll:W,setMessages:h,setLogFilters:q,setMaxMessages:I,setAutoScroll:C}),[u,h,q]),B=r.useMemo(()=>({maxMessages:t,autoScroll:W,logFilterLevel:c,logFilterSearch:s,setMessages:h,setLogFilters:q,setMaxMessages:I,setAutoScroll:C,online:S,retry:H.current,getUniqueId:M,addListener:Z,removeListener:pe,sendMessage:k,logMessage:L}),[t,W,h,q,I,C,S,H.current,Z,pe,k,L]);return e.jsx(rr.Provider,{value:ge,children:e.jsx(fe.Provider,{value:B,children:n})})}function Yo(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 Ie(){const{retry:n}=r.useContext(fe),c=()=>{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(Yo,{style:{height:"128px",width:"128px",margin:"10px",marginBottom:"20px"}}),n<100?e.jsxs(e.Fragment,{children:[e.jsx(Ir,{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(ie,{variant:"contained",color:"primary",onClick:c,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})}function Xo({value:n,maxChars:c}){let l=n;if(n.length>c&&c>3){const s=c-3,a=n.substring(0,Math.ceil(s/2)),u=n.substring(n.length-Math.floor(s/2),n.length);l=`${a} … ${u}`}return n!==l?e.jsx(R,{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 ke({children:n,style:c}){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,...c},children:n})}function Je({children:n,style:c}){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,...c},children:n})}function Ze({children:n,style:c}){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,...c},children:n})}function ut({children:n,style:c}){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,...c},children:n})}function gt({children:n,style:c}){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,...c},children:n})}function et({children:n,style:c}){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,...c},children:n})}function rt({children:n,style:c,onClose:l}){const s={display:"flex",flexDirection:"row",margin:"0px",padding:"0px",paddingRight:"10px",gap:"10px"};return e.jsx("div",{style:{...s,...c},children:n})}function en({systemInfo:n,compact:c}){const{addListener:l,removeListener:s,getUniqueId:a}=r.useContext(fe),[u,h]=r.useState(n),t=r.useRef(a());if(o&&console.log("SystemInfoTable loading with systemInfo:",u,"compact:",c),n&&c&&u.totalMemory&&u.freeMemory){const D=u.totalMemory,f=u.freeMemory;u.freeMemory=`${f} / ${D}`,u.totalMemory=""}if(n&&c&&u.heapTotal&&u.heapUsed){const D=u.heapTotal,f=u.heapUsed;u.heapUsed=`${f} / ${D}`,u.heapTotal=""}if(n&&c&&u.osRelease&&u.osType){const D=u.osType,f=u.osRelease;u.osType=`${D} (${f})`,u.osRelease=""}if(n&&c&&u.osArch&&u.osPlatform){const D=u.osPlatform,f=u.osArch;u.osPlatform=`${D} (${f})`,u.osArch=""}const I=(D,f,V,O,x)=>{h(j=>({...j,totalMemory:D,freeMemory:f,heapTotal:V,heapUsed:O,rss:x}))},W=D=>{h(f=>({...f,cpuUsage:D.toFixed(2)+" %"}))},C=(D,f)=>{h(V=>({...V,systemUptime:D,processUptime:f}))};r.useEffect(()=>{const D=f=>{f.method==="memory_update"&&f.response&&f.response.totalMemory&&f.response.freeMemory&&f.response.heapTotal&&f.response.heapUsed&&f.response.rss?(o&&console.log("SystemInfoTable received memory_update",f),I(f.response.totalMemory,f.response.freeMemory,f.response.heapTotal,f.response.heapUsed,f.response.rss)):f.method==="cpu_update"&&f.response&&f.response.cpuUsage?(o&&console.log("SystemInfoTable received cpu_update",f),W(f.response.cpuUsage)):f.method==="uptime_update"&&f.response&&f.response.systemUptime&&f.response.processUptime&&(o&&console.log("SystemInfoTable received uptime_update",f),C(f.response.systemUptime,f.response.processUptime))};return l(D,t.current),o&&console.log(`SystemInfoTable added WebSocket listener id ${t.current}`),()=>{s(D),o&&console.log("SystemInfoTable removed WebSocket listener")}},[l,s]);const[S,E]=r.useState(!1);return!u||S?null:(o&&console.log("SystemInfoTable rendering..."),e.jsxs(ke,{style:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Je,{children:[e.jsx(Ze,{children:"System Information"}),e.jsx(rt,{onClose:()=>E(!0)})]}),e.jsx("div",{className:"MbfWindowDivTable",children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(u).filter(([D,f])=>f!==void 0&&f!=="").map(([D,f],V)=>e.jsxs("tr",{className:V%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:D}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(Xo,{value:typeof f!="string"?f.toString():f,maxChars:24})})]},D))})})})]}))}const tn=r.memo(en),Ut={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"}},rn=n=>{if(!n)return"";const c=n.toString().replace(/[^0-9]/g,"");if(c.length<5)return c;const l=c.slice(0,4),s=c.slice(4,7),a=c.slice(7,11);return[l,s,a].filter(Boolean).join("-")};function on({id:n}){const{online:c,sendMessage:l,addListener:s,removeListener:a,getUniqueId:u}=r.useContext(fe),[h,t]=r.useState(null),I=r.useRef(null),W=r.useRef(null),C=r.useRef(u()),{showConfirmCancelDialog:S}=r.useContext(_e);o&&console.log(`QRDiv loading with id = "${n}" storeId = "${I.current}" timeout = ${W.current} and matter:`,h),r.useEffect(()=>{o&&console.log(`QRDiv id effect "${n}"`),I.current=n,W.current&&clearTimeout(W.current),W.current=null,n?(o&&console.log(`QRDiv id effect sending data request for storeId "${n}"`),l({id:C.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"),t(null))},[n,l]),r.useEffect(()=>{const x=j=>{j.method==="refresh_required"&&j.response.changed==="matter"&&j.response.matter&&(o&&console.log(`QRDiv received refresh_required: changed=${j.response.changed} for storeId "${j.response.matter.id}":`,j.response.matter),I.current===j.response.matter.id&&(o&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${j.response.matter.id}":`,j.response.matter),W.current&&clearTimeout(W.current),j.response.matter.advertising&&j.response.matter.advertiseTime&&j.response.matter.advertiseTime+9e5<=Date.now()&&(j.response.matter.advertising=!1),t(j.response.matter),j.response.matter.advertising&&(o&&console.log(`QRDiv setting matter advertise timeout for storeId "${j.response.matter.id}":`,j.response.matter.advertiseTime+9e5-Date.now()),W.current=setTimeout(()=>{W.current&&clearTimeout(W.current),o&&console.log(`QRDiv clearing advertising state for storeId "${I.current}" after 15 minutes`),t($=>$&&{...$,advertising:!1})},j.response.matter.advertiseTime+9e5-Date.now()))))};return s(x,C.current),o&&console.log("QRDiv webSocket effect mounted"),()=>{a(x),W.current&&clearTimeout(W.current),W.current=null,o&&console.log("QRDiv webSocket effect unmounted")}},[s,a]);const E=()=>{o&&console.log(`QRDiv sent matter startCommission for node "${h?.id}"`),h&&l({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,startCommission:!0}})},D=()=>{o&&console.log(`QRDiv sent matter stopCommission for node "${h?.id}"`),h&&l({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,stopCommission:!0}})},f=()=>{o&&console.log(`QRDiv sent matter advertise for node "${h?.id}"`),h&&l({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,advertise:!0}})},V=x=>{o&&console.log(`QRDiv sent matter removeFabric for node "${h?.id}" and fabricIndex ${x}`),h&&l({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,removeFabric:x}})},O=async()=>{if(!h||!h.manualPairingCode)return;const x=h.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(x);else{const j=document.createElement("textarea");j.value=x,j.style.position="fixed",j.style.opacity="0",document.body.appendChild(j),j.focus(),j.select(),document.execCommand("copy"),document.body.removeChild(j)}o&&console.log("Manual pairing code copied to clipboard")}catch(j){console.error("Failed to copy manual pairing code",j)}};return!h||!c?(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(ke,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs(Je,{children:[e.jsx(Ze,{children:"QR pairing code"}),e.jsxs(rt,{children:[e.jsx(K,{"aria-label":"send advertising",size:"small",onClick:f,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(R,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(re,{path:At,size:"22px"})})}),e.jsx(K,{"aria-label":"stop pairing",size:"small",onClick:D,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(R,{title:"Turn off pairing",arrow:!0,children:e.jsx(re,{path:fo,size:"22px"})})})]})]}),e.jsx(et,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:I.current}),e.jsx(ho,{value:h.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs(ut,{style:{justifyContent:"space-between"},children:[e.jsxs(gt,{style:{fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",rn(h.manualPairingCode)]}),e.jsx(rt,{children:e.jsx(R,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(K,{"aria-label":"copy manual pairing code",size:"small",onClick:O,sx:Ut,children:e.jsx(re,{path:xo,size:.85})})})})]})]})):h.commissioned&&h.fabricInformations&&h.sessionInformations?(o&&console.log("QRDiv rendering commissioned state"),e.jsxs(ke,{style:{alignItems:"center",minWidth:"302px",overflow:"hidden"},children:[e.jsxs(Je,{children:[e.jsx(Ze,{children:"Paired fabrics"}),e.jsxs(rt,{children:[e.jsx(K,{"aria-label":"send advertising",size:"small",onClick:f,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(R,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(re,{path:At,size:"22px"})})}),e.jsx(K,{"aria-label":"start pairing",size:"small",onClick:E,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(R,{title:"Turn on pairing",arrow:!0,children:e.jsx(re,{path:qt,size:"22px"})})})]})]}),e.jsx(et,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:I.current}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{paddingTop:"0px"},children:h.fabricInformations.map((x,j)=>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: ",x.fabricIndex]}),e.jsx(R,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(K,{"aria-label":"remove the fabric",size:"small",onClick:()=>S("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>V(x.fabricIndex),()=>{}),sx:{...Ut,padding:"2px"},children:e.jsx(re,{path:bo,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",x.rootVendorId," ",x.rootVendorName]}),x.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",x.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",h.sessionInformations?h.sessionInformations.filter($=>$.fabric?.fabricIndex===x.fabricIndex&&$.isPeerActive===!0).length:"0"," ","subscriptions: ",h.sessionInformations?h.sessionInformations.filter($=>$.fabric?.fabricIndex===x.fabricIndex&&$.isPeerActive===!0&&$.numberOfActiveSubscriptions>0).length:"0"]})]},j))}),e.jsx(ut,{style:{justifyContent:"center"},children:e.jsxs(gt,{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(ke,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsx(Je,{children:e.jsx(Ze,{children:"QR pairing code"})}),e.jsx(et,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:I.current}),e.jsx(ie,{onClick:E,endIcon:e.jsx(re,{path:qt,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(ut,{style:{justifyContent:"center"},children:e.jsxs(gt,{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(ke,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsx(Je,{style:{height:"30px",justifyContent:"space-between"},children:e.jsx(Ze,{children:"Server node"})}),e.jsx(et,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:I.current}),e.jsx(et,{style:{fontWeight:"bold"},children:"Server offline"}),e.jsx(ut,{style:{justifyContent:"center"},children:e.jsxs(gt,{style:{fontWeight:"normal"},children:["Serial number: ",h.serialNumber]})})]}))}const nn=r.memo(on);function sn(){const{logMessage:n,sendMessage:c,getUniqueId:l}=r.useContext(fe),[s,a]=r.useState("matterbridge-"),[u,h]=r.useState(!1),[t,I]=r.useState(null),W=r.useRef(l()),C=F=>{F.preventDefault(),h(!0)},S=()=>{h(!1)},E=F=>{F.preventDefault(),h(!1);const v=F.dataTransfer.files[0];if(v){n("Plugins",`Installing package ${v.name}. Please wait...`);const H=new FormData;H.append("file",v),H.append("filename",v.name),fetch("./api/uploadpackage",{method:"POST",body:H}).then(b=>b.text()).then(b=>{n("Plugins",`Server response: ${b}`)}).catch(b=>{console.error("Error uploading plugin file:",b),n("Plugins",`Error installing package ${b}`)})}},D=F=>{const v=F.target.files&&F.target.files[0];if(v){n("Plugins",`Uploading package ${v.name}`);const H=new FormData;H.append("file",v),H.append("filename",v.name),fetch("./api/uploadpackage",{method:"POST",body:H}).then(b=>b.text()).then(b=>{n("Plugins",`Server response: ${b}`)}).catch(b=>{console.error("Error uploading plugin file:",b),n("Plugins",`Error uploading package ${b}`)})}},f=()=>{c({id:W.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:s,restart:!1}})},V=()=>{document.getElementById("file-upload")?.click()},O=()=>{c({id:W.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:s}})},x=F=>{I(F.currentTarget)},j=F=>{F!==""&&a(F),I(null)},[$,_]=r.useState(!1);return o&&console.log("HomeInstallAddPlugins rendering..."),$?null:e.jsxs(ke,{children:[e.jsxs(Je,{children:[e.jsx(Ze,{children:"Install plugins"}),e.jsx(rt,{onClose:()=>_(!0)})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",alignItems:"center",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"},onDragOver:C,onDragLeave:S,onDrop:E,children:[e.jsx(me,{value:s,onChange:F=>{a(F.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(K,{onClick:x,children:e.jsx(Mr,{})}),e.jsxs(Ge,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>j(""),children:[e.jsx(N,{onClick:()=>j("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(N,{onClick:()=>j("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(N,{onClick:()=>j("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(N,{onClick:()=>j("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(N,{onClick:()=>j("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(N,{onClick:()=>j("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(N,{onClick:()=>j("matterbridge-test"),children:"matterbridge-test"}),e.jsx(N,{onClick:()=>j("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(N,{onClick:()=>j("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(N,{onClick:()=>j("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(N,{onClick:()=>j("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(N,{onClick:()=>j("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(N,{onClick:()=>j("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(N,{onClick:()=>j("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx(R,{title:"Install or update a plugin from npm",children:e.jsx(ie,{onClick:f,endIcon:e.jsx(Pe,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Install"})}),e.jsx(R,{title:"Upload and install a plugin from a tarball",children:e.jsx(ie,{onClick:V,endIcon:e.jsx(Dr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Upload"})}),e.jsx(R,{title:"Add an installed plugin",children:e.jsx(ie,{onClick:O,endIcon:e.jsx(xt,{}),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:D})]})]})}const an=r.memo(sn);function ze({status:n,enabledText:c="Enabled",disabledText:l=void 0,tooltipText:s=void 0,onClick:a}){if(n===void 0)return null;{const u=e.jsx("div",{className:n?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:a,children:n?c:l??c});return s!==void 0?e.jsx(R,{title:s,children:u}):u}}function Qt(n){return n.id!==0&&n.src==="Matterbridge"&&n.dst==="Frontend"}const Be={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Ue={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},ln={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},dn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Fe={padding:"0px",margin:"0px"},cn="5px 10px 5px 10px",mt={},xe={},ht={},ft={};let Qe=[],It=[];const pn=({open:n,onClose:c,plugin:l})=>{const{sendMessage:s,addListener:a,removeListener:u,getUniqueId:h}=r.useContext(fe),t=r.useRef(h()),[I,W]=r.useState(l.configJson),[C,S]=r.useState(null),[E,D]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[f,V]=r.useState("");let O={};r.useEffect(()=>{const M=k=>{k.src==="Matterbridge"&&k.dst==="Frontend"&&(Qt(k)&&k.id===t.current&&k.method==="/api/select/devices"&&k.response&&(o&&console.log(`ConfigPluginDialog (id: ${k.id}) received ${k.response.length} /api/select/devices:`,k.response),Qe=k.response),Qt(k)&&k.id===t.current&&k.method==="/api/select/entities"&&k.response&&(o&&console.log(`ConfigPluginDialog (id: ${k.id}) received ${k.response.length} /api/select/entities:`,k.response),It=k.response))};return a(M,t.current),o&&console.log("ConfigPluginDialog added WebSocket listener id:",t.current),I&&C&&C.properties&&(Object.keys(C.properties).forEach(k=>{Object.keys(C.properties[k]).forEach(L=>{L.startsWith("ui:")&&(E[k]={},E[k][L]=C.properties[k][L],delete C.properties[k][L])})}),D(E)),l.name&&l.configJson&&l.schemaJson&&(W(l.configJson),S(l.schemaJson),s({id:t.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),s({id:t.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)),()=>{u(M),o&&console.log("ConfigPluginDialog removed WebSocket listener")}},[a,I,l,u,C,s,E]);const x=(M,k)=>{O=M.formData},j=M=>{o&&console.log("ConfigPluginDialog handleSaveChanges:",M.formData),W(M.formData),l.configJson=M.formData,l.restartRequired=!0,s({id:t.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:M.formData.name,formData:M.formData}}),c()};function $(M){const{id:k,label:L,onKeyChange:q,onDropPropertyClick:Z,disabled:pe,schema:ae,children:le,registry:ge,readonly:B,required:U}=M,{templates:m}=ge,{RemoveButton:he}=m.ButtonTemplates;if(!(Qo in ae))return e.jsx(Y,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:le});const de=({target:X})=>q(X&&X.value);return e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(me,{id:`${k}-key`,name:`${k}-key`,required:U,disabled:pe||B,defaultValue:L,onBlur:B?void 0:de,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(Y,{sx:{flex:1},children:le}),e.jsx(he,{disabled:pe||B,onClick:Z(L),registry:ge})]})}function _(M){const{children:k,description:L,displayLabel:q,errors:Z,help:pe,hidden:ae,registry:le,uiSchema:ge}=M,B=Bo(ge),U=Uo("WrapIfAdditionalTemplate",le,B);return ae?e.jsx("div",{style:{display:"none"},children:k}):e.jsx(Y,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(U,{...M,children:[q===!0&&L,k,Z,pe]})})}function F(M){const{description:k}=M;return k?e.jsx(se,{sx:Ue,children:k}):null}function v(M){const{required:k,title:L}=M;return L?e.jsx(Y,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(se,{sx:Be,children:["Title ",L," ",k&&e.jsx("mark",{children:"***"})]})}):null}function H(M){const{help:k}=M;return k?e.jsx(Y,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(se,{sx:ln,children:k})}):null}function b(M){const{errors:k}=M;return k?e.jsxs(Y,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(se,{color:"error",sx:dn,children:"Please fix the following errors:"}),e.jsx(Xe,{children:k.map((L,q)=>e.jsxs(Pr,{children:[e.jsx(G,{children:e.jsx($r,{color:"error"})}),e.jsx(te,{primary:L.stack})]},q))})]}):null}function d(M){const{errors:k}=M;return k?e.jsx(Y,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:k.map((L,q)=>e.jsxs(se,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",L]},q))}):null}function i(M){const{id:k,name:L,_schema:q,_uiSchema:Z,value:pe,options:ae,label:le,type:ge,placeholder:B,required:U,disabled:m,readonly:he,autofocus:ve,onChange:de,onChangeOverride:X,onBlur:oe,onFocus:Me,_rawErrors:De,_hideError:Ye,_registry:y,_formContext:ee}=M,we=({target:{value:Se}})=>de(Se===""?ae.emptyValue:Se),Te=({target:Se})=>oe(k,Se&&Se.value),ot=({target:Se})=>Me(k,Se&&Se.value);return e.jsx(Y,{sx:{padding:"0px",margin:"0px"},children:e.jsx(me,{id:k,name:k,label:B&&B!==""?le:void 0,variant:"outlined",placeholder:B&&B!==""?B:le,required:U,disabled:m||he,autoFocus:ve,value:pe||pe===0?pe:"",type:ge,autoComplete:ge==="password"?"current-password":L,onChange:X||we,onBlur:Te,onFocus:ot,fullWidth:!0})})}function p(M){return console.log("ArrayFieldTitleTemplate:",M),null}function g(M){return console.log("ArrayFieldDescriptionTemplate:",M),null}function T(M){return console.log("ArrayFieldItemTemplate:",M),null}function ce(M){const{canAdd:k,onAddClick:L,schema:q,title:Z}=M,[pe,ae]=r.useState(!1),[le,ge]=r.useState(!1),[B,U]=r.useState(!1),[m,he]=r.useState(""),ve=y=>{he(y.target.value)},de=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",m,"selectDevices:",Qe),ae(!pe)},X=()=>{o&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",m,"selectEntities:",It),ge(!le)},oe=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",m,"selectDevices:",Qe),U(!B)},Me=y=>{ae(!1),q.selectFrom==="serial"?q.items.default=y.serial:q.selectFrom==="name"&&(q.items.default=y.name),L()},De=y=>{ge(!1),q.selectEntityFrom==="name"?q.items.default=y.name:q.selectEntityFrom==="description"&&(q.items.default=y.description),L()},Ye=y=>{U(!1),q.selectDeviceEntityFrom==="name"?q.items.default=y.name:q.selectDeviceEntityFrom==="description"&&(q.items.default=y.description),L()};return e.jsxs(Y,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[Z&&e.jsxs(Y,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Z&&e.jsx(se,{sx:Be,children:Z}),k&&e.jsxs(Y,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[q.selectFrom&&e.jsx(R,{title:"Add a device from the list",children:e.jsx(K,{onClick:de,size:"small",color:"primary",sx:Fe,children:e.jsx(it,{})})}),q.selectEntityFrom&&e.jsx(R,{title:"Add an entity from the list",children:e.jsx(K,{onClick:X,size:"small",color:"primary",sx:Fe,children:e.jsx(it,{})})}),q.selectDeviceEntityFrom&&e.jsx(R,{title:"Add a device entity from the list",children:e.jsx(K,{onClick:oe,size:"small",color:"primary",sx:Fe,children:e.jsx(it,{})})}),e.jsx(R,{title:"Add a new item",children:e.jsx(K,{onClick:L,size:"small",color:"primary",sx:Fe,children:e.jsx(xt,{})})})]})]}),q.description&&e.jsx(se,{sx:Ue,children:q.description}),M.items.map(y=>e.jsxs(Y,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(Y,{sx:{flexGrow:1,marginRight:"10px"},children:y.children}),e.jsx(K,{disabled:!y.hasMoveUp,onClick:y.onReorderClick(y.index,y.index-1),size:"small",color:"primary",sx:Fe,children:e.jsx(Rt,{})}),e.jsx(K,{disabled:!y.hasMoveDown,onClick:y.onReorderClick(y.index,y.index+1),size:"small",color:"primary",sx:Fe,children:e.jsx(Tt,{})}),e.jsx(K,{onClick:y.onDropIndexClick(y.index),size:"small",color:"primary",sx:Fe,children:e.jsx(yt,{})})]},y.index)),e.jsxs($e,{open:pe,onClose:de,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select a device"}),e.jsxs(Le,{children:[e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(me,{fullWidth:!0,variant:"outlined",value:m,onChange:ve,placeholder:"Enter serial or name"})]}),e.jsx(Xe,{dense:!0,children:Qe.filter(y=>y.serial.toLowerCase().includes(m.toLowerCase())||y.name.toLowerCase().includes(m.toLowerCase())).map((y,ee)=>e.jsxs(st,{onClick:()=>Me(y),sx:mt,children:[y.icon==="wifi"&&e.jsx(G,{children:e.jsx(tt,{style:xe})}),y.icon==="ble"&&e.jsx(G,{children:e.jsx(at,{style:xe})}),y.icon==="hub"&&e.jsx(G,{children:e.jsx(lt,{style:xe})}),e.jsx(te,{primary:y.name,secondary:y.serial,primaryTypographyProps:{style:ht},secondaryTypographyProps:{style:ft}})]},ee))})]}),e.jsx(Oe,{children:e.jsx(ie,{onClick:de,children:"Close"})})]}),e.jsxs($e,{open:le,onClose:X,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select an entity"}),e.jsxs(Le,{children:[e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(me,{fullWidth:!0,variant:"outlined",value:m,onChange:ve,placeholder:"Enter name or description"})]}),e.jsx(Xe,{dense:!0,children:It.filter(y=>y.name.toLowerCase().includes(m.toLowerCase())||y.description.toLowerCase().includes(m.toLowerCase())).map((y,ee)=>e.jsxs(st,{onClick:()=>De(y),sx:mt,children:[y.icon==="wifi"&&e.jsx(G,{children:e.jsx(tt,{style:xe})}),y.icon==="ble"&&e.jsx(G,{children:e.jsx(at,{style:xe})}),y.icon==="hub"&&e.jsx(G,{children:e.jsx(lt,{style:xe})}),y.icon==="component"&&e.jsx(G,{children:e.jsx(Ht,{style:xe})}),y.icon==="matter"&&e.jsx(G,{children:e.jsx(Ot,{style:xe})}),e.jsx(te,{primary:y.name,secondary:y.description,primaryTypographyProps:{style:ht},secondaryTypographyProps:{style:ft}})]},ee))})]}),e.jsx(Oe,{children:e.jsx(ie,{onClick:X,children:"Close"})})]}),e.jsxs($e,{open:B,onClose:oe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Ne,{children:["Select an entity for ",Z]}),e.jsx(Le,{children:e.jsx(Xe,{dense:!0,children:Qe.filter(y=>y.serial===Z||y.name===Z).map(y=>y.entities?.map((ee,we)=>e.jsxs(st,{onClick:()=>Ye(ee),sx:mt,children:[ee.icon==="wifi"&&e.jsx(G,{children:e.jsx(tt,{style:xe})}),ee.icon==="ble"&&e.jsx(G,{children:e.jsx(at,{style:xe})}),ee.icon==="hub"&&e.jsx(G,{children:e.jsx(lt,{style:xe})}),ee.icon==="component"&&e.jsx(G,{children:e.jsx(Ht,{style:xe})}),ee.icon==="matter"&&e.jsx(G,{children:e.jsx(Ot,{style:xe})}),e.jsx(te,{primary:ee.name,secondary:ee.description,primaryTypographyProps:{style:ht},secondaryTypographyProps:{style:ft}})]},we)))})}),e.jsx(Oe,{children:e.jsx(ie,{onClick:oe,children:"Close"})})]})]})}function be(M){const{onAddClick:k,schema:L,properties:q,title:Z,description:pe}=M,[ae,le]=r.useState(!1),[ge,B]=r.useState(""),U=X=>{B(X.target.value)},m=()=>{le(!ae)},he=X=>{o&&console.log(`ObjectFieldTemplate: handleSelectValue value "${X.serial}" for schema "${L.selectFrom}"`),le(!1);let oe="";L.selectFrom==="serial"?oe=X.serial:L.selectFrom==="name"&&(oe=X.name),V(oe),o&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${oe}"`),k(L)()},ve=()=>{k(L)()},de=!L.additionalProperties;return o&&console.log(`ObjectFieldTemplate: isRoot ${de} newkey "${f}"`),!de&&f!==""&&(o&&console.log("ObjectFieldTemplate: newkey",f,"properties",q),q.forEach(X=>{if(X.name==="newKey"&&X.content.key==="newKey"&&X.content.props.name==="newKey"&&X.content.props.onKeyChange&&f!==""){o&&console.log("ObjectFieldTemplate: newkey onKeyChange",f);const oe=f;V(""),X.content.props.onKeyChange(oe)}})),e.jsxs(Y,{sx:{margin:"0px",padding:de?"10px":"5px 10px 0px 10px",border:de?"none":"1px solid grey"},children:[L.title&&de&&e.jsx(Y,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(se,{sx:Be,children:L.title})}),Z&&!de&&e.jsxs(Y,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(se,{sx:Be,children:Z}),e.jsxs(Y,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[L.selectFrom&&e.jsx(R,{title:"Add a device from the list",children:e.jsx(K,{onClick:m,size:"small",color:"primary",sx:Fe,children:e.jsx(it,{})})}),e.jsx(R,{title:"Add a new item",children:e.jsx(K,{onClick:ve,size:"small",color:"primary",sx:Fe,children:e.jsx(xt,{})})})]})]}),L.description&&e.jsx(Y,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(se,{sx:Ue,children:L.description})}),q.map(({content:X,name:oe,hidden:Me})=>!Me&&e.jsxs(Y,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(L.properties[oe].type)?"0px":cn,border:["object","array","boolean"].includes(L.properties[oe].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(L.properties[oe].type)&&e.jsx(se,{sx:Be,children:oe}),e.jsx(Y,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:X})]},oe)),e.jsxs($e,{open:ae,onClose:m,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select a device"}),e.jsxs(Le,{children:[e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(me,{fullWidth:!0,variant:"outlined",value:ge,onChange:U,placeholder:"Enter serial or name"})]}),e.jsx(Xe,{dense:!0,children:Qe.filter(X=>X.serial.toLowerCase().includes(ge.toLowerCase())||X.name.toLowerCase().includes(ge.toLowerCase())).map((X,oe)=>e.jsxs(st,{onClick:()=>he(X),sx:mt,children:[X.icon==="wifi"&&e.jsx(G,{children:e.jsx(tt,{style:xe})}),X.icon==="ble"&&e.jsx(G,{children:e.jsx(at,{style:xe})}),X.icon==="hub"&&e.jsx(G,{children:e.jsx(lt,{style:xe})}),e.jsx(te,{primary:X.name,secondary:X.serial,primaryTypographyProps:{style:ht},secondaryTypographyProps:{style:ft}})]},oe))})]}),e.jsx(Oe,{children:e.jsx(ie,{onClick:m,children:"Close"})})]})]})}function ne(M){const{uiSchema:k}=M,{submitText:L,norender:q}=zo(k);return q?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(ie,{type:"submit",variant:"contained",color:"primary",children:L}),e.jsx(ie,{variant:"contained",color:"primary",onClick:c,children:"Cancel"})]})}function Ce(M){const{className:k,disabled:L,onClick:q,registry:Z,style:pe,uiSchema:ae,...le}=M;return e.jsx(R,{title:"Remove the item",children:e.jsx(K,{disabled:L,size:"small",color:"primary",onClick:q,children:e.jsx(yt,{})})})}function J(M){const{className:k,disabled:L,onClick:q,registry:Z,uiSchema:pe,...ae}=M;return e.jsx(R,{title:"Add an item",children:e.jsx(K,{size:"small",color:"primary",onClick:q,children:e.jsx(xt,{})})})}function z(M){const{disabled:k,onClick:L,registry:q,style:Z,uiSchema:pe,...ae}=M;return e.jsx(R,{title:"Move up the item",children:e.jsx(K,{size:"small",color:"primary",onClick:L,children:e.jsx(Rt,{})})})}function w(M){const{disabled:k,onClick:L,registry:q,style:Z,uiSchema:pe,...ae}=M;return e.jsx(R,{title:"Move down the item",children:e.jsx(K,{size:"small",color:"primary",onClick:L,children:e.jsx(Tt,{})})})}function A(M){const{id:k,name:L,value:q,schema:Z,readonly:pe,onChange:ae}=M,[le,ge]=r.useState(),B=m=>{o&&console.log(`CheckboxWidget ${L} onChangeField:`,m),ge(m&&m!==""?m:void 0)},U=()=>{o&&console.log(`CheckboxWidget onClick plugin="${l.name}" action="${L}" value="${le}"`),s({id:t.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name,action:L,value:le,formData:O,id:k}}),Z.buttonClose===!0?c():Z.buttonSave===!0&&j({formData:I})};return Z.buttonText&&Z.description?e.jsxs(Y,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(se,{sx:Ue,children:Z.description}),e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>U(),children:Z.buttonText})]}):Z.buttonField&&Z.description?e.jsxs(Y,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(se,{sx:Ue,children:Z.description}),e.jsx(me,{id:L+"-input",name:L,label:Z.textLabel,placeholder:Z.textPlaceholder,onChange:m=>B(m.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(ie,{id:L+"-button",variant:"contained",color:"primary",disabled:le===void 0,onClick:()=>U(),children:Z.buttonField})]}):e.jsxs(Y,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[L&&e.jsxs(Y,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(se,{sx:Be,children:L}),e.jsx(Ee,{checked:q,readOnly:pe,onChange:()=>ae(!q),sx:{padding:"0px",margin:"0px"}})]}),Z.description&&e.jsx(se,{sx:Ue,children:Z.description})]})}function P({schema:M,id:k,name:L,options:q,label:Z,hideLabel:pe,required:ae,disabled:le,placeholder:ge,readonly:B,value:U,multiple:m,autofocus:he,onChange:ve,onBlur:de,onFocus:X,errorSchema:oe,rawErrors:Me=[],registry:De,uiSchema:Ye,hideError:y,formContext:ee,...we}){const{enumOptions:Te,enumDisabled:ot,emptyValue:Se}=q;m=typeof m>"u"?!1:!!m;const Nt=m?[]:"",Lt=typeof U>"u"||m&&U.length<1||!m&&U===Nt,ar=({target:{value:We}})=>ve(kt(We,Te,Se)),lr=({target:We})=>de(k,kt(We&&We.value,Te,Se)),dr=({target:We})=>X(k,kt(We&&We.value,Te,Se)),Wt=Ao(U,Te,m),{InputLabelProps:cr,SelectProps:pr,autocomplete:ur,...gr}=we,mr=!m&&M.default===void 0;return e.jsxs(me,{id:k,name:k,value:!Lt&&typeof Wt<"u"?Wt:Nt,required:ae,disabled:le||B,autoFocus:he,autoComplete:ur,placeholder:ge,error:Me.length>0,onChange:ar,onBlur:lr,onFocus:dr,...gr,select:!0,InputLabelProps:{...cr,shrink:!Lt},SelectProps:{...pr,multiple:m},"aria-describedby":qo(k),children:[mr&&e.jsx(N,{value:"",children:ge}),Array.isArray(Te)&&Te.map(({value:We,label:hr},Ft)=>{const fr=Array.isArray(ot)&&ot.indexOf(We)!==-1;return e.jsx(N,{value:String(Ft),disabled:fr,children:hr},Ft)})]})}return o&&console.log("ConfigPluginDialog rendering..."),!n||!C||!I?null:e.jsxs($e,{open:n,onClose:c,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(Ne,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h3",{children:"Matterbridge plugin configuration"})]})}),e.jsx(Le,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Eo,{schema:C,formData:I,uiSchema:E,validator:_o,templates:{FieldTemplate:_,BaseInputTemplate:i,TitleFieldTemplate:v,DescriptionFieldTemplate:F,FieldHelpTemplate:H,FieldErrorTemplate:d,ErrorListTemplate:b,WrapIfAdditionalTemplate:$,ArrayFieldTitleTemplate:p,ArrayFieldDescriptionTemplate:g,ArrayFieldItemTemplate:T,ArrayFieldTemplate:ce,ObjectFieldTemplate:be,ButtonTemplates:{SubmitButton:ne,RemoveButton:Ce,AddButton:J,MoveUpButton:z,MoveDownButton:w}},widgets:{CheckboxWidget:A,SelectWidget:P},onChange:x,onSubmit:j})})]})};function or(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 c=0,l=0;for(const s of n.sessionInformations??[])s.fabric&&s.isPeerActive===!0&&c++,s.numberOfActiveSubscriptions>0&&(l+=s.numberOfActiveSubscriptions);return n.commissioned===!0&&n.fabricInformations&&n.sessionInformations&&(c===0||l===0)?"var(--secondary-color)":"var(--div-text-color)"}function un(n,c,l){const s=n?.[l],a=c?.[l];return s==null&&a==null?0:s==null?-1:a==null?1:typeof s=="boolean"&&typeof a=="boolean"?s===a?0:s?1:-1:typeof s=="number"&&typeof a=="number"?s-a:String(s).localeCompare(String(a))}function gn({name:n,title:c,columns:l,rows:s,getRowKey:a,footerLeft:u,footerRight:h,onRowClick:t}){const I=r.useRef(new WeakMap),W=r.useRef(1),C=d=>{if(typeof a=="string"&&d&&d[a]!=null)return d[a];if(typeof a=="function"){const g=a(d);if(g!=null)return g}const i=l?.[0]?.id;if(i&&d&&d[i]!=null)return d[i];console.warn(`MbfTable(${n}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let p=I.current.get(d);return p||(p=`rk_${W.current++}`,I.current.set(d,p)),p},[S,E]=r.useState(localStorage.getItem(`${n}_table_order_by`)||null),[D,f]=r.useState(localStorage.getItem(`${n}_table_order`)||null),[V,O]=r.useState(!1),[x,j]=r.useState(()=>{try{const d=localStorage.getItem(`${n}_column_visibility`);if(d)return JSON.parse(d)}catch{}return{}}),$=r.useMemo(()=>{const d={};for(const i of l)i.hidden||(d[i.id]=i.required?!0:x[i.id]!==!1);return d},[l,x]),_=r.useMemo(()=>{if(!S||!D)return s;const d=l.find(p=>p.id===S);if(!d||d.noSort)return s;const i=s.map((p,g)=>({el:p,index:g}));return i.sort((p,g)=>{let T;return typeof d.comparator=="function"?T=d.comparator(p.el,g.el):T=un(p.el,g.el,S),T!==0?D==="asc"?T:-T:p.index-g.index}),i.map(p=>p.el)},[s,S,D,l]),F=d=>{if(S!==d||!S){E(d),f("asc"),localStorage.setItem(`${n}_table_order_by`,d),localStorage.setItem(`${n}_table_order`,"asc");return}if(D==="asc"){f("desc"),localStorage.setItem(`${n}_table_order`,"desc");return}E(null),f(null),localStorage.removeItem(`${n}_table_order_by`),localStorage.removeItem(`${n}_table_order`)},v=()=>{O(!V)},H=d=>{j(i=>{const p=l.find(ce=>ce.id===d);if(p&&p.required)return i;const g=$[d]!==!1,T={...i};g?T[d]=!1:delete T[d];try{localStorage.setItem(`${n}_column_visibility`,JSON.stringify(T))}catch{}return T})},b=()=>{j({});try{localStorage.removeItem(`${n}_column_visibility`)}catch{}O(!1)};return o&&console.log(`Rendering table ${n}${S&&D?` ordered by ${S}:${D}`:""}`),e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",height:"100%",minHeight:0,overflow:"hidden"},children:[e.jsxs($e,{open:V,onClose:(d,i)=>{i==="backdropClick"||i==="escapeKeyDown"||v()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Ne,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:`Configure ${n} columns`})]})}),e.jsx(Le,{children:e.jsx(Nr,{children:l.filter(d=>!d.hidden).map(d=>e.jsx(Ve,{control:e.jsx(Ee,{disabled:!!d.required,checked:d.required?!0:$[d.id]!==!1,onChange:()=>H(d.id)}),label:d.label},d.id))})}),e.jsxs(Oe,{children:[e.jsx(ie,{onClick:b,children:"Reset"}),e.jsx(ie,{variant:"contained",onClick:d=>{if(d?.currentTarget&&typeof d.currentTarget.blur=="function")try{d.currentTarget.blur()}catch{}const i=document.activeElement;if(i&&i instanceof HTMLElement&&typeof i.blur=="function")try{i.blur()}catch{}v()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:n}),c&&e.jsx("p",{className:"MbfWindowHeaderText",children:c}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(K,{onClick:d=>{if(d?.currentTarget?.blur)try{d.currentTarget.blur()}catch{}v()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(R,{title:`Configure ${n} columns`,children:e.jsx(re,{path:vo,size:"20px",color:"var(--header-text-color)"})})})})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${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(d=>{if(d.hidden||!d.required&&$[d.id]===!1)return null;const i=!d.noSort,p=i&&S===d.id&&!!D;return e.jsxs("th",{onClick:i?()=>F(d.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:d.minWidth,maxWidth:d.maxWidth,textAlign:d.align||"left",cursor:i?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:d.maxWidth?"nowrap":void 0,overflow:d.maxWidth?"hidden":void 0,textOverflow:d.maxWidth?"ellipsis":void 0},"aria-sort":i?p?D==="asc"?"ascending":"descending":"none":void 0,children:[d.label,p&&e.jsxs("span",{style:{marginLeft:6},children:[D==="asc"&&e.jsx(re,{path:yo,size:"15px"}),D==="desc"&&e.jsx(re,{path:jo,size:"15px"})]})]},d.id)})})}),e.jsx("tbody",{children:_.map((d,i)=>{const p=C(d);return e.jsx("tr",{className:i%2===0?"table-content-even":"table-content-odd",onClick:t?g=>t(d,p,g):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:t?"pointer":void 0},children:l.map(g=>{if(g.hidden||!g.required&&$[g.id]===!1)return null;const T=d[g.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:g.align||"left",padding:"5px 10px",margin:"0",maxWidth:g.maxWidth,whiteSpace:g.maxWidth?"nowrap":void 0,overflow:g.maxWidth?"hidden":void 0,textOverflow:g.maxWidth?"ellipsis":void 0},children:typeof g.render=="function"?g.render(T,p,d,g):typeof T=="boolean"?e.jsx(Ee,{checked:T,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):g.format&&typeof T=="number"?g.format(T):T!=null?String(T):null},g.id)})},p)})})]})}),(u||h)&&e.jsxs("div",{className:"MbfWindowFooter",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:u}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:h})]})]})}function mn(n){return r.memo(n)}const Ct=mn(gn);function hn({storeId:n,setStoreId:c}){const{online:l,sendMessage:s,addListener:a,removeListener:u,getUniqueId:h}=r.useContext(fe),{showConfirmCancelDialog:t}=r.useContext(_e),I=r.useRef(h()),[W,C]=r.useState(null),[S,E]=r.useState(null),[D,f]=r.useState([]),V=[{label:"Name",id:"name",required:!0,render:(w,A,P,M)=>e.jsx(R,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>d(P),children:P.name})})},{label:"Description",id:"description",render:(w,A,P,M)=>e.jsx(R,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>d(P),children:P.description})})},{label:"Version",id:"version",render:(w,A,P,M)=>e.jsxs(e.Fragment,{children:[P.latestVersion!==void 0&&P.latestVersion!==P.version&&S&&!S.readOnly&&e.jsx(R,{title:"New plugin stable version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>_(P),children:["Update to v.",P.latestVersion]})}),P.version.includes("-dev-")&&P.devVersion!==void 0&&P.devVersion!==P.version&&S&&!S.readOnly&&e.jsx(R,{title:"New plugin dev version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>F(P),children:["Update to new dev v.",P.devVersion.split("-dev-")[0]]})}),e.jsx(R,{title:"Plugin version",children:e.jsx("span",{children:P.version})})]})},{label:"Author",id:"author",render:(w,A,P,M)=>e.jsx(e.Fragment,{children:P.author?P.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(w,A,P,M)=>e.jsx(e.Fragment,{children:P.type?P.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(w,A,P,M)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[S&&S.bridgeMode==="childbridge"&&!P.error&&P.enabled&&e.jsx(R,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:or(P.matter)},onClick:()=>{P.matter?.id&&c(P.matter?.id)},size:"small",children:e.jsx(Jt,{})})}),S&&S.bridgeMode==="childbridge"&&!P.error&&P.enabled&&e.jsx(R,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>H(P),size:"small",children:e.jsx(bt,{})})}),e.jsx(R,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{disabled:P.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>Ce(P),size:"small",children:e.jsx($t,{})})}),S&&!S.readOnly&&e.jsx(R,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{x("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",P)},size:"small",children:e.jsx(yt,{})})}),P.enabled?e.jsx(R,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{x("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",P)},size:"small",children:e.jsx(Lr,{})})}):e.jsx(e.Fragment,{}),P.enabled?e.jsx(e.Fragment,{}):e.jsx(R,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>b(P),size:"small",children:e.jsx(Wr,{})})}),e.jsx(R,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>p(P),size:"small",children:e.jsx(Fr,{})})}),e.jsx(R,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>g(P),size:"small",children:e.jsx(Tr,{})})}),S&&!S.readOnly&&e.jsx(R,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>i(P),size:"small",children:e.jsx(Zt,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(w,A,P,M)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:P.error?e.jsx(e.Fragment,{children:e.jsx(ze,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:P.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(ze,{status:P.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:P.loaded&&P.started&&P.configured?e.jsx(e.Fragment,{children:e.jsx(ze,{status:P.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(ze,{status:P.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(ze,{status:P.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(ze,{status:P.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const w=A=>{A.src==="Matterbridge"&&A.dst==="Frontend"&&(A.method==="refresh_required"&&A.response.changed==="plugins"&&(o&&console.log(`HomePlugins received refresh_required: changed=${A.response.changed} and sending /api/plugins request`),s({id:I.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),A.method==="refresh_required"&&A.response.changed==="matter"&&(o&&console.log(`HomePlugins received refresh_required: changed=${A.response.changed} and setting matter id ${A.response.matter?.id}`),f(P=>{const M=P.findIndex(L=>L.matter?.id===A.response.matter?.id);if(M<0)return o&&console.log(`HomePlugins received refresh_required: changed=${A.response.changed} and matter id ${A.response.matter?.id} not found`),P;o&&console.log(`HomePlugins received refresh_required: changed=${A.response.changed} set matter id ${A.response.matter?.id}`);const k=[...P];return k[M]={...k[M],matter:A.response.matter},k})),A.method==="refresh_required"&&A.response.changed==="settings"&&(o&&console.log(`HomePlugins received refresh_required: changed=${A.response.changed} and sending /api/settings request`),s({id:I.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),A.id===I.current&&A.method==="/api/settings"&&(o&&console.log(`HomePlugins (id: ${A.id}) received settings:`,A.response),C(A.response.systemInformation),E(A.response.matterbridgeInformation)),A.id===I.current&&A.method==="/api/plugins"&&(o&&console.log(`HomePlugins (id: ${A.id}) received ${A.response.length} plugins:`,A.response),f(A.response)))};return a(w,I.current),o&&console.log("HomePlugins added WebSocket listener id:",I.current),()=>{u(w),o&&console.log("HomePlugins removed WebSocket listener")}},[a,u,s]),r.useEffect(()=>{l&&(o&&console.log("HomePlugins sending api requests"),s({id:I.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),s({id:I.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,s]);const O=r.useRef(null),x=(w,A,P,M)=>{o&&console.log(`handleActionWithConfirmCancel ${P} ${M.name}`),O.current=M,t(w,A,P,j,$)},j=w=>{o&&console.log(`handleConfirm action confirmed ${w} ${O.current?.name}`),w==="remove"&&O.current?v(O.current):w==="disable"&&O.current&&b(O.current),O.current=null},$=w=>{o&&console.log(`handleCancel action canceled ${w} ${O.current?.name}`),O.current=null},_=w=>{o&&console.log("handleUpdatePlugin plugin:",w.name),s({id:I.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:w.name,restart:!1}})},F=w=>{o&&console.log("handleUpdateDevPlugin plugin:",w.name),s({id:I.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:w.name+"@dev",restart:!1}})},v=w=>{o&&console.log("handleRemovePlugin plugin:",w.name),s({id:I.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:w.name}})},H=w=>{o&&console.log("handleRestartPlugin plugin:",w.name),s({id:I.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:w.name}})},b=w=>{o&&console.log("handleEnableDisablePlugin plugin:",w.name,"enabled:",w.enabled),w.enabled===!0?(w.enabled=!1,s({id:I.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:w.name}})):(w.enabled=!0,s({id:I.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:w.name}}))},d=w=>{o&&console.log(`handleHomepagePlugin plugin: ${w.name} homepage: ${w.homepage}`),w.homepage&&window.open(w.homepage,"_blank")},i=w=>{o&&console.log("handleSponsorPlugin plugin:",w.name,"funding:",w.funding),w.funding&&window.open(w.funding,"_blank")},p=w=>{o&&console.log("handleHelpPlugin plugin:",w.name,"help:",w.help),w.help&&window.open(w.help,"_blank")},g=w=>{o&&console.log("handleChangelogPlugin plugin:",w.name,"changelog:",w.changelog),w.changelog&&window.open(w.changelog,"_blank")},[T,ce]=r.useState(),[be,ne]=r.useState(!1),Ce=w=>{o&&console.log("handleConfigPlugin plugin:",w.name),s({id:I.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:w.name}}),s({id:I.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:w.name}}),ce(w),J()},J=()=>{ne(!0)},z=()=>{ne(!1)};return o&&console.log("HomePlugins rendering..."),l?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"0 0 auto",overflow:"hidden"},children:[T&&e.jsx(pn,{open:be,onClose:z,plugin:T}),e.jsx(Ct,{name:"Plugins",columns:V,rows:D,footerRight:"",footerLeft:""})]}):e.jsx(Ie,{})}const fn=r.memo(hn),xn=n=>`${n.pluginName}::${n.serial}`;function bn({storeId:n,setStoreId:c}){const{online:l,sendMessage:s,addListener:a,removeListener:u,getUniqueId:h}=r.useContext(fe),[t,I]=r.useState(!1),[W,C]=r.useState(!0),[S,E]=r.useState(null),[D,f]=r.useState([]),[V,O]=r.useState([]),[x,j]=r.useState([]),[$,_]=r.useState([]),F=r.useRef(h()),v=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(d,i,p,g)=>p.reachable===!0?"Online":p.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(d,i)=>{const p=d.reachable===!0?1:d.reachable===!1?0:-1,g=i.reachable===!0?1:i.reachable===!1?0:-1;return p-g}},{label:"Power",id:"powerSource",render:(d,i,p,g)=>p.powerSource==="ac"||p.powerSource==="dc"?e.jsx(Yt,{fontSize:"small",sx:{color:"var(--primary-color)"}}):p.powerSource==="ok"?e.jsx(vt,{fontSize:"small",sx:{color:"green"}}):p.powerSource==="warning"?e.jsx(vt,{fontSize:"small",sx:{color:"yellow"}}):p.powerSource==="critical"?e.jsx(vt,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Url",id:"configUrl"},{label:"Actions",id:"selected",required:!0,render:(d,i,p,g)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[p.matter!==void 0?e.jsx(R,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{onClick:()=>c(n===p.matter?.id?S?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:p.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:or(p.matter)},children:e.jsx(Jt,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),p.configUrl?e.jsx(R,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{onClick:()=>window.open(p.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx($t,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),p.selected!==void 0?e.jsx(R,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Ee,{checked:p.selected,onChange:T=>b(T,p),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],H=r.useCallback(d=>{d.selected=void 0;const i=D.find(T=>T.name===d.pluginName);if(!i)return console.error(`HomeDevices isSelected: plugin ${d.pluginName} not found for device ${d.name} `),d.selected;const p=i.schemaJson?.properties?.whiteList?.selectFrom;let g=i.configJson.postfix;return g===""&&(g=void 0),i.hasWhiteList===!0&&i.hasBlackList===!0&&p&&(d.selected=!0,p==="serial"&&i.configJson.whiteList&&i.configJson.whiteList.length>0&&i.configJson.whiteList.includes(g?d.serial.replace("-"+g,""):d.serial)&&(d.selected=!0),p==="serial"&&i.configJson.whiteList&&i.configJson.whiteList.length>0&&!i.configJson.whiteList.includes(g?d.serial.replace("-"+g,""):d.serial)&&(d.selected=!1),p==="serial"&&i.configJson.blackList&&i.configJson.blackList.length>0&&i.configJson.blackList.includes(g?d.serial.replace("-"+g,""):d.serial)&&(d.selected=!1),p==="name"&&i.configJson.whiteList&&i.configJson.whiteList.length>0&&i.configJson.whiteList.includes(d.name)&&(d.selected=!0),p==="name"&&i.configJson.whiteList&&i.configJson.whiteList.length>0&&!i.configJson.whiteList.includes(d.name)&&(d.selected=!1),p==="name"&&i.configJson.blackList&&i.configJson.blackList.length>0&&i.configJson.blackList.includes(d.name)&&(d.selected=!1)),d.selected},[D]);r.useEffect(()=>{const d=i=>{if(i.method==="refresh_required"&&i.response.changed!=="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${i.response.changed} and sending /api/plugins request`),s({id:F.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):i.method==="refresh_required"&&i.response.changed==="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${i.response.changed} and setting matter id ${i.response.matter?.id}`),_(p=>{const g=p.findIndex(ce=>ce.name.replaceAll(" ","")===i.response.matter?.id);if(g<0)return o&&console.debug(`HomeDevices: matter id ${i.response.matter?.id} not found`),p;const T=[...p];return T[g]={...T[g],matter:i.response.matter},o&&console.log(`HomeDevices received refresh_required: changed=${i.response.changed} and set matter id ${i.response.matter?.id}`),T})):i.method==="restart_required"?(o&&console.log("HomeDevices received restart_required"),I(!0)):i.method==="restart_not_required"?(o&&console.log("HomeDevices received restart_not_required"),I(!1)):i.method==="state_update"&&i.response.plugin&&i.response.serialNumber&&i.response.cluster.includes("BasicInformation")&&i.response.attribute==="reachable"&&(o&&console.log(`HomeDevices updating device reachability for plugin ${i.response.plugin} serial ${i.response.serialNumber} value ${i.response.value}`),O(p=>{const g=p.findIndex(T=>T.pluginName===i.response.plugin&&T.serial===i.response.serialNumber);return g<0?(o&&console.warn(`HomeDevices: device to update not found for plugin ${i.response.plugin} serial ${i.response.serialNumber}`),p):(p[g]={...p[g],reachable:i.response.value},[...p])})),i.id===F.current&&i.method==="/api/settings")o&&console.log(`HomeDevices (id: ${i.id}) received settings:`,i.response),E(i.response),I(i.response.matterbridgeInformation.restartRequired||i.response.matterbridgeInformation.fixedRestartRequired);else if(i.id===F.current&&i.method==="/api/plugins"){if(o&&console.log(`HomeDevices (id: ${i.id}) received ${i.response?.length} plugins:`,i.response),i.response){let p=!0;for(const g of i.response)g.enabled===!0&&(g.loaded!==!0||g.started!==!0||g.error===!0)&&(p=!1);if(!p)return;o&&console.log("HomeDevices reset plugins, devices and selectDevices"),C(!1),f(i.response),O([]),j([]),s({id:F.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),o&&console.log("HomeDevices sent /api/devices");for(const g of i.response)g.enabled===!0&&g.loaded===!0&&g.started===!0&&g.error!==!0&&(s({id:F.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:g.name}}),o&&console.log(`HomeDevices sent /api/select/devices for plugin: ${g.name}`))}}else if(i.id===F.current&&i.method==="/api/devices"){if(o&&console.log(`HomeDevices (id: ${i.id}) received ${i.response?.length} devices:`,i.response),i.response){for(const p of i.response)p.selected=H(p);O(i.response)}}else i.id===F.current&&i.method==="/api/select/devices"&&(o&&console.log(`HomeDevices (id: ${i.id}) received ${i.response?.length} selectDevices for plugin ${i.response&&i.response.length>0?i.response[0].pluginName:"without select devices"}:`,i.response),i.response&&i.response.length>0&&j(p=>{const g=p.filter(ce=>ce.pluginName!==i.response[0].pluginName),T=i.response.map(ce=>({...ce,selected:H(ce)}));return[...g,...T]}))};return a(d,F.current),o&&console.log(`HomeDevices added WebSocket listener id ${F.current}`),()=>{u(d),o&&console.log("HomeDevices removed WebSocket listener")}},[D,a,u,s,H]),r.useEffect(()=>{if(V.length===0&&x.length===0){_([]);return}o&&console.log(`HomeDevices mixing devices (${V.length}) and selectDevices (${x.length})`);const d=[];for(const i of V)d.push(i);for(const i of x)V.find(p=>p.pluginName===i.pluginName&&p.serial.includes(i.serial))||d.push(i);d.length>0&&(_(d),o&&console.log(`HomeDevices mixed ${d.length} devices and selectDevices`))},[D,V,x,_]),r.useEffect(()=>{l&&(o&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),s({id:F.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),s({id:F.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,s]);const b=(d,i)=>{o&&console.log(`handleCheckboxChange: checkbox changed to ${d.target.checked} for device ${i.name} serial ${i.serial}`),V.findIndex(p=>p.pluginName===i.pluginName&&p.serial===i.serial)<0?(o&&console.warn(`handleCheckboxChange: device ${i.name} serial ${i.serial} not found in devices, trying in mixedDevices`),_(p=>{const g=p.findIndex(T=>T.pluginName===i.pluginName&&T.serial===i.serial);return g<0?(console.error(`handleCheckboxChange: device ${i.name} serial ${i.serial} not found in mixedDevices`),p):(p[g]={...p[g],selected:d.target.checked},[...p])})):O(p=>{const g=p.findIndex(T=>T.pluginName===i.pluginName&&T.serial===i.serial);return g<0?(console.error(`handleCheckboxChange: device ${i.name} serial ${i.serial} not found in devices`),p):(p[g]={...p[g],selected:d.target.checked},[...p])}),d.target.checked?s({id:F.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:i.pluginName,serial:i.serial,name:i.name}}):s({id:F.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:i.pluginName,serial:i.serial,name:i.name}})};return o&&console.log("HomeDevices rendering..."),l?e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Ct,{name:"Devices",getRowKey:xn,rows:$,columns:v,footerLeft:W?"Waiting for the plugins to fully load...":`Registered devices: ${V.length.toString()}/${$.length.toString()}`,footerRight:t?"Restart required":""})}):e.jsx(Ie,{})}const vn=r.memo(bn);function wt({children:n,style:c,name:l}){const{setCurrentPage:s}=r.useContext(_e);s(l),o&&console.log(`MbfPage: current page set to ${l}`);const a={display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"20px"};return e.jsx("div",{style:{...a,...c},children:n})}const yn=()=>"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 jn(){const{messages:n,autoScroll:c}=r.useContext(rr),[l,s]=r.useState(!1),a=r.useRef(null),u=r.useMemo(()=>yn(),[]),h=C=>s(!0),t=C=>s(!1);r.useEffect(()=>{o&&console.log(`WebSocketLogs autoScroll: ${c} isHovering: ${l}`),c&&!l&&!u&&a.current?.scrollIntoView({behavior:"smooth"})},[n,l,c,u]);const I=C=>{switch(C.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=C=>{switch(C.toLowerCase()){case"warn":return"black";default:return"white"}};return e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:h,onMouseLeave:t,children:[n.map((C,S)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:I(C.level),color:W(C.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:C.level}),C.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+C.time+"]"}),C.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+C.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:C.message})]},S)),e.jsx("div",{ref:a})]})})}const nr=r.memo(jn);function Cn(){const{logFilterLevel:n,logFilterSearch:c,autoScroll:l,online:s}=r.useContext(fe);return o&&console.log("HomeLogs rendering..."),s?e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"1 1 auto",width:"100%",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:"Logs"}),e.jsx("div",{className:"MbfWindowHeaderText",style:{display:"flex",justifyContent:"space-between"},children:e.jsxs("span",{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',n,'" and search "',c,'" Scroll: ',l?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(nr,{})})]}):e.jsx(Ie,{})}const wn=r.memo(Cn);function Sn(){const{online:n}=r.useContext(fe);return o&&console.log("HomeBrowserRefresh rendering..."),n?e.jsxs(ke,{children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Frontend Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(ie,{onClick:()=>window.location.reload(),endIcon:e.jsx(Rr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}):e.jsx(Ie,{})}const kn=r.memo(Sn);function In({changelog:n}){const{online:c}=r.useContext(fe);return o&&console.log("HomeShowChangelog rendering..."),c?e.jsxs(ke,{children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{children:[e.jsx(ie,{onClick:()=>window.open(n,"_blank"),endIcon:e.jsx(Xt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(ie,{onClick:()=>window.location.reload(),endIcon:e.jsx(Hr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}):e.jsx(Ie,{})}const Mn=r.memo(In);function Dn(){const[n,c]=r.useState(null),[l,s]=r.useState(null),[a,u]=r.useState([]),[h]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[t,I]=r.useState(localStorage.getItem("homePageMode")??"devices"),[W,C]=r.useState(""),[S,E]=r.useState(!1),[D,f]=r.useState(!1),[V,O]=r.useState(null),{addListener:x,removeListener:j,online:$,sendMessage:_,getUniqueId:F}=r.useContext(fe),v=r.useRef(F());return r.useEffect(()=>{const H=b=>{b.method==="refresh_required"&&b.response.changed==="settings"&&(o&&console.log(`Home received refresh_required: changed=${b.response.changed} and sending /api/settings request`),O(null),u([]),_({id:v.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),_({id:v.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),b.method==="/api/settings"&&b.id===v.current&&(o&&console.log("Home received settings:",b.response),c(b.response.systemInformation),s(b.response.matterbridgeInformation),b.response.matterbridgeInformation.matterbridgeVersion&&C(`https://github.com/Luligu/matterbridge/blob/${b.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&b.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",b.response.matterbridgeInformation.frontendVersion):b.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&b.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",b.response.matterbridgeInformation.frontendVersion),f(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",b.response.matterbridgeInformation.matterbridgeVersion):b.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",b.response.matterbridgeInformation.matterbridgeVersion),E(!0)),b.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),I("devices")))),b.method==="/api/plugins"&&b.id===v.current&&(o&&console.log("Home received plugins:",b.response),u(b.response))};return x(H,v.current),o&&console.log(`Home added WebSocket listener id ${v.current}`),()=>{j(H),o&&console.log("Home removed WebSocket listener")}},[x,j,_]),r.useEffect(()=>{if(o&&console.log(`Home storeId effect with storeId ${V}`),l?.bridgeMode==="bridge"&&!V&&(o&&console.log("Home storeId effect set storeId to Matterbridge"),O("Matterbridge")),l?.bridgeMode==="childbridge"&&!V&&a){for(const H of a)if(H.matter?.id){o&&console.log(`Home storeId effect set storeId to ${H.matter.id}`),O(H.matter.id);break}}},[l,a,V]),r.useEffect(()=>{$&&(o&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),_({id:v.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),_({id:v.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[$,_]),o&&console.log("Home rendering..."),!$||!n||!l?e.jsx(Ie,{}):e.jsxs(wt,{name:"Home",style:{flexDirection:"row"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(nn,{id:V}),e.jsx(tn,{systemInfo:n,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[D&&e.jsx(kn,{}),S&&e.jsx(Mn,{changelog:W}),h&&!l.readOnly&&e.jsx(an,{}),h&&e.jsx(fn,{storeId:V,setStoreId:O}),t==="devices"&&e.jsx(vn,{storeId:V,setStoreId:O}),t==="logs"&&e.jsx(wn,{})]})]})}const Pn=r.memo(Dn),Gt={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},$n={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},Nn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Kt={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Ln={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Wn={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},Fn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Tn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},Rn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Mt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},Hn=[256,257,268,269],On=[266,267],Vn=[259,260,261,271,272],En=[256,257,268,269,266,267,259,260,261,272];function Q({icon:n,iconColor:c,cluster:l,value:s,unit:a,prefix:u}){return o&&console.log(`Render cluster "${l.clusterName}.${l.attributeName}" value(${typeof s}-${isNaN(s)}) "${s}" unit "${a}"`),u=u??!1,e.jsxs(Y,{sx:Gt,children:[n&&r.cloneElement(n,{key:`${l.clusterId}-${l.attributeId}-icon`,sx:{...$n,color:c??"var(--primary-color)"}}),e.jsxs(Y,{sx:{...Gt,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[a&&u===!0&&e.jsx(se,{sx:Kt,children:a},`${l.clusterId}-${l.attributeId}-unit`),e.jsx(se,{sx:Nn,children:s==null||typeof s=="number"&&isNaN(s)||s==="NaN"?"---":s},`${l.clusterId}-${l.attributeId}-value`),a&&u===!1&&e.jsx(se,{sx:Kt,children:a},`${l.clusterId}-${l.attributeId}-unit`)]},`${l.clusterId}-${l.attributeId}-valueunitbox`)]},`${l.clusterId}-${l.attributeId}-box`)}function _n({device:n,endpoint:c,id:l,deviceType:s,clusters:a}){const u=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let h="";return o&&console.log(`Device "${n.name}" endpoint "${c}" id "${l}" deviceType "0x${s.toString(16).padStart(4,"0")}" clusters (${a?.length}):`,a),s===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>h=`${t.attributeLocalValue} mV`),En.includes(s)&&a.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>h=`Level ${t.attributeValue}`),s===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>h=`Position ${t.attributeLocalValue/100}%`),s===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>h=`Heat ${t.attributeLocalValue/100}°C `),s===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>h=h+`Cool ${t.attributeLocalValue/100}°C`),s===118&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>h=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),s===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>h=`${t.attributeLocalValue/1e3} V, `),s===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>h=h+`${t.attributeLocalValue/1e3} A, `),s===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>h=h+`${t.attributeLocalValue/1e3} W`),e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[s===19&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Q,{icon:t.attributeLocalValue===!0?e.jsx(tt,{}):e.jsx(Or,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),s===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(Q,{icon:e.jsx(vt,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),s===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(Q,{icon:e.jsx(Yt,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),s===1293&&a.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),Hn.includes(s)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Q,{icon:e.jsx(Vr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),On.includes(s)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Vn.includes(s)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:So,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),s===115&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),s===124&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Io,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),s===117&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),s===123&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Q,{icon:e.jsx(Vt,{}),cluster:t,value:"Oven"})),s===112&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Q,{icon:e.jsx(Er,{}),cluster:t,value:"Fridge"})),s===113&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Do,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),s===121&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Q,{icon:e.jsx(Vt,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),s===122&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),s===120&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:zt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),s===119&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:zt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),s===116&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:$o,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Robot"})),s===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(Q,{icon:e.jsx(_r,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),s===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:No,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),s===10&&a.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(Q,{icon:t.attributeValue==="1"?e.jsx(Ar,{}):e.jsx(qr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),s===43&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(Q,{icon:e.jsx(zr,{}),cluster:t,value:t.attributeValue,unit:"%"})),s===15&&a.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Lo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),s===39&&a.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(Q,{icon:e.jsx(Br,{}),cluster:t,value:t.attributeValue,unit:"mode",prefix:!0})),s===771&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Q,{icon:e.jsx(Ur,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),s===45&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(Q,{icon:e.jsx(Et,{}),cluster:t,value:t.attributeValue,unit:"%"})),s===114&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(Q,{icon:e.jsx(Et,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),s===67&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Q,{icon:e.jsx(Qr,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),s===65&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Q,{icon:e.jsx(Gr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),s===68&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Q,{icon:e.jsx(Kr,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),s===1292&&a.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),s===1295&&a.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),s===777&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:To,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),s===23&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Ro,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),s===24&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),s===118&&a.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Bt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),s===118&&a.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Bt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),s===66&&a.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(Q,{icon:e.jsx(Jr,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),s===44&&a.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Oo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:u[t.attributeLocalValue??0]})),s===770&&a.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Q,{icon:e.jsx(Zr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),s===775&&a.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),s===774&&a.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Q,{icon:e.jsx(Yr,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),s===773&&a.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Q,{icon:e.jsx(Xr,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),s===21&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Q,{icon:t.attributeValue==="true"?e.jsx(eo,{}):e.jsx(to,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),s===263&&a.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(Q,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(ro,{}):e.jsx(oo,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),s===262&&a.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Q,{icon:e.jsx(no,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),s===1296&&a.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(Q,{icon:e.jsx(io,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(Y,{sx:Ln,children:e.jsx(se,{sx:Wn,children:h})}),e.jsx(Y,{sx:Fn,children:e.jsx(se,{sx:Tn,children:n.name})}),e.jsxs(Y,{sx:Rn,children:[o&&e.jsx(se,{sx:Mt,children:c}),e.jsx(se,{sx:Mt,children:l}),o&&e.jsxs(se,{sx:Mt,children:["0x",s.toString(16).padStart(4,"0")]})]})]})}function An({filter:n}){const{online:c,sendMessage:l,addListener:s,removeListener:a,getUniqueId:u}=r.useContext(fe),[h,t]=r.useState(null),[I,W]=r.useState([]),[C,S]=r.useState([]),[E,D]=r.useState(C),[f,V]=r.useState({}),[O,x]=r.useState({}),[j,$]=r.useState({}),_=r.useRef(u()),F=r.useRef(E),v=r.useCallback(b=>{o&&console.log(`DevicesIcons received state_update "${b.response.cluster}.${b.response.attribute}" for "${b.response.id}:${b.response.number}": "${b.response.value}"`,b.response);const d=F.current.find(p=>p.pluginName===b.response.plugin&&p.uniqueId===b.response.uniqueId);if(!d){o&&console.warn(`DevicesIcons updater device of plugin "${b.response.plugin}" serial "${b.response.serialNumber}" not found in filteredDevicesRef.current`);return}const i=j[d.serial].find(p=>p.endpoint===b.response.number.toString()&&p.clusterName===b.response.cluster&&p.attributeName===b.response.attribute);if(!i){o&&console.warn(`DevicesIcons updater device "${d.name}" serial "${d.serial}" cluster "${b.response.cluster}" attribute "${b.response.attribute}" not found in clusters`);return}i.attributeValue=String(b.response.value),i.attributeLocalValue=b.response.value,$({...j}),o&&console.log(`DevicesIcons updated "${i.clusterName}.${i.attributeName}" for device "${d.name}" serial "${d.serial}" to "${i.attributeValue}"`)},[j]);r.useEffect(()=>{const b=d=>{if(d.method==="refresh_required")o&&console.log(`DevicesIcons received refresh_required: changed=${d.response.changed} and sending api requests`),l({id:_.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:_.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:_.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(d.method==="state_update"&&d.response)v(d);else if(d.method==="/api/settings"&&d.response)o&&console.log("DevicesIcons received settings:",d.response),t(d.response);else if(d.method==="/api/plugins"&&d.response)o&&console.log("DevicesIcons received plugins:",d.response),W(d.response);else if(d.method==="/api/devices"&&d.response){o&&console.log(`DevicesIcons received ${d.response.length} devices:`,d.response),S(d.response);for(const i of d.response)o&&console.log("DevicesIcons sending /api/clusters"),l({id:_.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:i.pluginName,endpoint:i.endpoint||0}})}else if(d.method==="/api/clusters"&&d.response){if(o&&console.log(`DevicesIcons received for device "${d.response.deviceName}" serial "${d.response.serialNumber}" deviceTypes (${d.response.deviceTypes.length}) "${d.response.deviceTypes.join(",")}" clusters (${d.response.clusters.length}):`,d.response),d.response.clusters.length===0)return;const i=d.response.serialNumber;f[i]=[],O[i]=d.response.deviceTypes,j[i]=[];for(const p of d.response.clusters)f[i].find(g=>g.endpoint===p.endpoint)||f[i].push({endpoint:p.endpoint,id:p.id,deviceTypes:p.deviceTypes}),!["FixedLabel","Descriptor","Identify","Groups","PowerTopology"].includes(p.clusterName)&&j[i].push(p);V({...f}),x({...O}),$({...j}),o&&console.log(`DevicesIcons endpoints for "${i}":`,f[i]),o&&console.log(`DevicesIcons deviceTypes for "${i}":`,O[i]),o&&console.log(`DevicesIcons clusters for "${i}":`,j[i])}};return s(b,_.current),o&&console.log("DevicesIcons useEffect webSocket mounted"),()=>{a(b),o&&console.log("DevicesIcons useEffect webSocket unmounted")}},[]),r.useEffect(()=>(o&&console.log("DevicesIcons useEffect online mounting"),c&&(o&&console.log("DevicesIcons useEffect online sending api requests"),l({id:_.current,sender:"DevicesIcons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:_.current,sender:"DevicesIcons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:_.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")}),[c,l]),r.useEffect(()=>{if(n===""){D(C),F.current=C;return}const b=C.filter(d=>d.name.toLowerCase().includes(n)||d.serial.toLowerCase().includes(n));D(b),F.current=b},[C,n]);const H=r.memo(_n);return o&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:E.map(b=>f[b.serial]&&f[b.serial].map(d=>d.deviceTypes.map(i=>e.jsx(H,{device:b,endpoint:d.endpoint,id:d.id,deviceType:i,clusters:j[b.serial].filter(p=>p.endpoint===d.endpoint)},`${b.pluginName}-${b.uniqueId}-${d.id}-${i.toString()}`))))})}const qn=r.memo(An),zn=[{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,c,l,s)=>l.configUrl?e.jsx(K,{onClick:()=>window.open(l.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx($t,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],Bn=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(n,c,l,s)=>Array.isArray(n)?e.jsx(e.Fragment,{children:n.map(a=>`0x${a.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,render:(n,c,l,s)=>e.jsx(R,{title:String(n),componentsProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("div",{style:{maxWidth:"500px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:String(n)})})}],Un=n=>`${n.pluginName}::${n.uniqueId}`,Qn=n=>`${n.endpoint}::${n.clusterName}::${n.attributeName}`;function Gn({filter:n}){const{online:c,sendMessage:l,addListener:s,removeListener:a,getUniqueId:u}=r.useContext(fe),[h,t]=r.useState([]),[I,W]=r.useState(h),[C,S]=r.useState([]),[E,D]=r.useState(0),[f,V]=r.useState(null),[O,x]=r.useState(null),[j,$]=r.useState(null),[_,F]=r.useState(null),v=r.useRef(u()),H=r.useRef(I),b=r.useCallback(i=>{o&&console.log(`DevicesTable received state_update "${i.response.cluster}.${i.response.attribute}" for "${i.response.id}:${i.response.number}": "${i.response.value}"`,i.response);const p=H.current.find(g=>g.pluginName===i.response.plugin&&g.uniqueId===i.response.uniqueId);if(!p){o&&console.warn(`DevicesTable updater device of plugin "${i.response.plugin}" serial "${i.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(f&&O&&p.pluginName===f&&p.uniqueId===_&&i.response.number.toString()===O){const g=C.find(T=>T.endpoint===i.response.number.toString()&&T.clusterName===i.response.cluster&&T.attributeName===i.response.attribute);if(!g){o&&console.warn(`DevicesTable updater cluster ${i.response.cluster}.${i.response.attribute} for device "${p.name}" serial "${p.serial}" not found in clusters`);return}g.attributeValue=String(i.response.value),g.attributeLocalValue=i.response.value,S([...C]),o&&console.log(`DevicesTable updated attribute ${g.clusterName}.${g.attributeName} for device "${p.name}" serial "${p.serial}" to "${g.attributeValue}"`)}},[C,O,f,_]);r.useEffect(()=>{const i=p=>{if(o&&console.log("DevicesTable received WebSocket Message:",p),p.method==="refresh_required"&&p.response.changed==="devices")o&&console.log(`DevicesTable received refresh_required: changed=${p.response.changed} and sending /api/devices request`),l({id:v.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(p.method==="state_update"&&p.response)b(p);else if(p.method==="/api/devices")o&&console.log(`DevicesTable received ${p.response.length} devices:`,p.response),t(p.response);else if(p.method==="/api/clusters"){o&&console.log(`DevicesTable received ${p.response.clusters.length} clusters for plugin ${p.response.plugin}:`,p.response),S(p.response.clusters);const g={};for(const T of p.response.clusters)o&&console.log("Cluster:",T.endpoint),g[T.endpoint]?g[T.endpoint]++:g[T.endpoint]=1;D(Object.keys(g).length)}};return s(i,v.current),o&&console.log("DevicesTable added WebSocket listener"),()=>{a(i),o&&console.log("DevicesTable removed WebSocket listener")}},[l,s,a,b]),r.useEffect(()=>{c&&(o&&console.log("DevicesTable sending api requests with id ",v.current),l({id:v.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:v.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:v.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,l]),r.useEffect(()=>{f&&O&&(o&&console.log("DevicesTable sending /api/clusters"),l({id:v.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:f,endpoint:Number(O)}}))},[f,O,l]),r.useEffect(()=>{if(n===""){W(h),H.current=h;return}const i=h.filter(p=>p.name.toLowerCase().includes(n)||p.serial.toLowerCase().includes(n));W(i),H.current=i},[h,n]);const d=i=>{if(i.uniqueId===_){F(null),V(null),x(null),$(null);return}F(i.uniqueId),V(i.pluginName),x(i.endpoint?i.endpoint.toString():null),$(i.name)};return o&&console.log("DevicesTable rendering..."),c?e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0px",padding:"0px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",maxHeight:`${f&&O?"30%":"100%"}`,flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Ct,{name:"Registered devices",getRowKey:Un,onRowClick:d,rows:I,columns:zn,footerLeft:`Total devices: ${I.length.toString()}`})}),f&&O&&e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",height:"70%",maxHeight:"70%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Ct,{name:"Clusters",title:j||"",getRowKey:Qn,rows:C,columns:Bn,footerLeft:`Total child endpoints: ${E-1}`})})]}):e.jsx(Ie,{})}const Kn=r.memo(Gn);function Jn(){const{online:n}=r.useContext(fe),[c,l]=r.useState(""),[s,a]=r.useState("icon");r.useEffect(()=>{const t=localStorage.getItem("devicesFilter");t&&l(t)},[]),r.useEffect(()=>{const t=localStorage.getItem("devicesViewMode");t&&a(t)},[]);const u=t=>{l(t.target.value.toLowerCase()),localStorage.setItem("devicesFilter",t.target.value.toLowerCase())},h=t=>{a(t),localStorage.setItem("devicesViewMode",t)};return o&&console.log("Devices rendering..."),n?e.jsxs(wt,{name:"Devices",children:[e.jsxs("div",{className:"MbfWindowBodyRow",style:{justifyContent:"space-between",padding:0,gap:"20px",width:"100%",height:"45px",minHeight:"45px",maxHeight:"45px"},children:[e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(se,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(me,{variant:"outlined",value:c,onChange:u,placeholder:"Enter the device name or serial number",sx:{width:"320px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(se,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(K,{onClick:()=>h("table"),"aria-label":"Table View",disabled:s==="table",children:e.jsx(R,{title:"Table View",children:e.jsx(so,{style:{color:s==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(K,{onClick:()=>h("icon"),"aria-label":"Icon View",disabled:s==="icon",children:e.jsx(R,{title:"Icon View (beta)",children:e.jsx(ao,{style:{color:s==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),s==="table"&&e.jsx(Kn,{filter:c}),s==="icon"&&e.jsx(qn,{filter:c})]}):e.jsx(Ie,{})}const Zn=r.memo(Jn);function Yn(){const[n,c]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[l,s]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[a,u]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:h,setLogFilters:t,online:I,setAutoScroll:W}=r.useContext(fe),C=f=>{c(f.target.value),t(f.target.value,l),localStorage.setItem("logFilterLevel",f.target.value),o&&console.log("handleChangeLevel called with value:",f.target.value)},S=f=>{s(f.target.value),t(n,f.target.value),localStorage.setItem("logFilterSearch",f.target.value),o&&console.log("handleChangeSearch called with value:",f.target.value)},E=f=>{u(f.target.checked),W(f.target.checked),localStorage.setItem("logAutoScroll",f.target.value?"true":"false"),o&&console.log("handleAutoScrollChange called with value:",f.target.checked)},D=()=>{o&&console.log("handleClearLogsClick called"),h([])};return o&&console.log("Logs rendering..."),I?e.jsxs(wt,{name:"Logs",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(_t,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Ke,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:n,onChange:C,children:[e.jsx(N,{value:"debug",children:"Debug"}),e.jsx(N,{value:"info",children:"Info"}),e.jsx(N,{value:"notice",children:"Notice"}),e.jsx(N,{value:"warn",children:"Warn"}),e.jsx(N,{value:"error",children:"Error"}),e.jsx(N,{value:"fatal",children:"Fatal"})]}),e.jsx(_t,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(me,{style:{width:"300px"},size:"small",id:"logsearch",variant:"outlined",value:l,onChange:S,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(Ve,{control:e.jsx(Ee,{checked:a,onChange:E}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx(R,{title:"Clear the logs",children:e.jsx(ie,{onClick:D,endIcon:e.jsx(yt,{}),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(nr,{})})]}):e.jsx(Ie,{})}const Xn=r.memo(Yn),ei=({open:n,ip:c,onClose:l,onSave:s})=>{const a=c?c.split(".").slice(0,3).join(".")+".1":"",[u,h]=r.useState("dhcp"),[t,I]=r.useState({ip:c??"",subnet:"255.255.255.0",gateway:a,dns:a}),W=E=>D=>{I({...t,[E]:D.target.value})},C=()=>{l()},S=()=>{s({type:u,...t}),l()};return e.jsxs($e,{open:n,onClose:(E,D)=>{D==="backdropClick"||D==="escapeKeyDown"||l()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Ne,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Network Configuration"})]})}),e.jsxs(Le,{dividers:!0,children:[e.jsxs(er,{component:"fieldset",fullWidth:!0,children:[e.jsx(ye,{component:"legend",children:"Select IP Configuration"}),e.jsxs(tr,{row:!0,value:u,onChange:E=>h(E.target.value),children:[e.jsx(Ve,{value:"dhcp",control:e.jsx(jt,{}),label:"DHCP"}),e.jsx(Ve,{value:"static",control:e.jsx(jt,{}),label:"Static"})]})]}),u==="static"&&e.jsxs(He,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(He,{size:6,children:e.jsx(me,{label:"IP Address",fullWidth:!0,value:t.ip,onChange:W("ip")})}),e.jsx(He,{size:6,children:e.jsx(me,{label:"Subnet Mask",fullWidth:!0,value:t.subnet,onChange:W("subnet")})}),e.jsx(He,{size:6,children:e.jsx(me,{label:"Gateway",fullWidth:!0,value:t.gateway,onChange:W("gateway")})}),e.jsx(He,{size:6,children:e.jsx(me,{label:"DNS Server",fullWidth:!0,value:t.dns,onChange:W("dns")})})]})]}),e.jsxs(Oe,{children:[e.jsx(ie,{onClick:C,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:S,children:"Save"})]})]})},ti=({open:n,onClose:c,onSave:l})=>{const[s,a]=r.useState(""),[u,h]=r.useState(""),t=D=>{a(D.target.value)},I=D=>{h(D.target.value)},W=s.length>0&&s===u,C=()=>{c()},S=()=>{W&&(l(s),c())},E=()=>{l(""),c()};return e.jsxs($e,{open:n,onClose:(D,f)=>{f==="backdropClick"||f==="escapeKeyDown"||c()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Ne,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Change Password"})]})}),e.jsx(Le,{dividers:!0,children:e.jsx(er,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(He,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(He,{size:12,children:e.jsx(me,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:s,onChange:t})}),e.jsx(He,{size:12,children:e.jsx(me,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:u,onChange:I,error:u!==""&&s!==u,helperText:u!==""&&s!==u?"Passwords do not match":""})})]})})}),e.jsxs(Oe,{children:[e.jsx(ie,{onClick:C,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:S,disabled:!W,children:"Change"}),e.jsx(ie,{variant:"contained",onClick:E,children:"Reset"})]})]})},ue=500;function ri(){const{online:n,addListener:c,removeListener:l,sendMessage:s,getUniqueId:a}=r.useContext(fe),[u,h]=r.useState(null),[t,I]=r.useState(null),W=r.useRef(a());return r.useEffect(()=>{const C=S=>{S.src==="Matterbridge"&&S.dst==="Frontend"&&(S.method==="refresh_required"&&S.response.changed==="settings"&&(o&&console.log(`Settings received refresh_required: changed=${S.response.changed} and sending /api/settings request`),s({id:W.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),S.method==="/api/settings"&&(o&&console.log("Settings received /api/settings:",S.response),h(S.response.matterbridgeInformation),I(S.response.systemInformation)))};return c(C,W.current),o&&console.log("Settings added WebSocket listener"),()=>{l(C),o&&console.log("Settings removed WebSocket listener")}},[c,l,s]),r.useEffect(()=>{n&&(o&&console.log("Settings received online"),s({id:W.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[n,s]),o&&console.log("Settings rendering..."),!n||!u||!t?e.jsx(Ie,{}):e.jsx(wt,{name:"Settings",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(oi,{matterbridgeInfo:u,systemInfo:t}),e.jsx(ni,{matterbridgeInfo:u}),e.jsx(ii,{matterbridgeInfo:u}),e.jsx(si,{systemInfo:t})]})})}function oi({matterbridgeInfo:n,systemInfo:c}){const{sendMessage:l,getUniqueId:s}=r.useContext(fe),[a,u]=r.useState("bridge"),[h,t]=r.useState("Info"),[I,W]=r.useState(!1),[C,S]=r.useState("dark"),[E,D]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[f,V]=r.useState(localStorage.getItem("homePageMode")??"devices"),[O,x]=r.useState(localStorage.getItem("virtualMode")??"outlet"),j=r.useRef(s()),[$,_]=r.useState(!1),F=()=>_(!1),v=J=>{o&&console.log("handleSaveNetConfig called with config:",J),l({id:j.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:J})},[H,b]=r.useState(!1),d=()=>b(!1),i=J=>{o&&console.log("handleSaveChangePassword called with password:",J),l({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:J}})};r.useEffect(()=>{n&&(u(n.bridgeMode==="bridge"?"bridge":"childbridge"),t(n.loggerLevel.charAt(0).toUpperCase()+n.loggerLevel.slice(1)),W(n.fileLogger),x(n.virtualMode))},[n]),r.useEffect(()=>{const J=localStorage.getItem("frontendTheme");J&&S(J)},[]);const p=J=>{o&&console.log("handleChangeBridgeMode called with value:",J.target.value),u(J.target.value),l({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:J.target.value}})},g=J=>{o&&console.log("handleChangeMbLoggerLevel called with value:",J.target.value),t(J.target.value),l({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:J.target.value}})},T=J=>{o&&console.log("handleLogOnFileMbChange called with value:",J.target.checked),W(J.target.checked),l({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:J.target.checked}})},ce=J=>{const z=J.target.value;o&&console.log("handleChangeTheme called with value:",z),S(z),localStorage.setItem("frontendTheme",z),document.body.setAttribute("frontend-theme",z)},be=J=>{const z=J.target.checked;o&&console.log("handleChangeHomePagePlugins called with value:",z),D(z),localStorage.setItem("homePagePlugins",z?"true":"false")},ne=J=>{const z=J.target.value;o&&console.log("handleChangeHomePageMode called with value:",z),V(z),localStorage.setItem("homePageMode",z)},Ce=J=>{const z=J.target.value;o&&console.log("handleChangeVirtualMode called with value:",z),x(z),localStorage.setItem("virtualMode",z),l({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:z}})};return!n||!c?null:e.jsxs(ke,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(ei,{open:$,ip:c.ipv4Address,onClose:F,onSave:v}),e.jsx(ti,{open:H,onClose:d,onSave:i}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Y,{sx:{gap:"10px",margin:"0px",padding:"10px",width:`${ue-20}px`,backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(tr,{row:!0,name:"mode-buttons-group",value:a,onChange:p,children:[e.jsx(Ve,{value:"bridge",control:e.jsx(jt,{}),label:"Bridge",disabled:n.readOnly===!0}),e.jsx(Ve,{value:"childbridge",control:e.jsx(jt,{}),label:"Childbridge",disabled:n.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(Ke,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:h,onChange:g,children:[e.jsx(N,{value:"Debug",children:"Debug"}),e.jsx(N,{value:"Info",children:"Info"}),e.jsx(N,{value:"Notice",children:"Notice"}),e.jsx(N,{value:"Warn",children:"Warn"}),e.jsx(N,{value:"Error",children:"Error"}),e.jsx(N,{value:"Fatal",children:"Fatal"})]}),e.jsx(Ve,{style:{padding:"0px",margin:"0px"},control:e.jsx(Ee,{checked:I,onChange:T,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(Ke,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:C,onChange:ce,children:[e.jsx(N,{value:"classic",children:"Classic"}),e.jsx(N,{value:"light",children:"Light"}),e.jsx(N,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Ee,{checked:E,onChange:be,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(Ke,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:f,onChange:ne,children:[e.jsx(N,{value:"logs",children:"Logs"}),e.jsx(N,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(Ke,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:O,onChange:Ce,children:[e.jsx(N,{value:"disabled",children:"Disabled"}),e.jsx(N,{value:"outlet",children:"Outlet"}),e.jsx(N,{value:"light",children:"Light"}),e.jsx(N,{value:"switch",children:"Switch"}),e.jsx(N,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>b(!0),children:"Change password"})}),n.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>_(!0),children:"Configure IP"})})]})})]})}function ni({matterbridgeInfo:n}){const{sendMessage:c,getUniqueId:l}=r.useContext(fe),[s,a]=r.useState("Info"),[u,h]=r.useState(!1),[t,I]=r.useState(""),[W,C]=r.useState(""),[S,E]=r.useState(""),[D,f]=r.useState(""),[V,O]=r.useState(""),[x,j]=r.useState(""),$=r.useRef(l());r.useEffect(()=>{n&&(a(["Debug","Info","Notice","Warn","Error","Fatal"][n.matterLoggerLevel]),h(n.matterFileLogger),I(n.matterMdnsInterface||""),C(n.matterIpv4Address||""),E(n.matterIpv6Address||""),f(n.matterPort?n.matterPort.toString():""),O(n.matterDiscriminator?n.matterDiscriminator.toString():""),j(n.matterPasscode?n.matterPasscode.toString():""))},[n]);const _=g=>{o&&console.log("handleChangeMjLoggerLevel called with value:",g.target.value),a(g.target.value),c({id:$.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:g.target.value}})},F=g=>{o&&console.log("handleLogOnFileMjChange called with value:",g.target.checked),h(g.target.checked),c({id:$.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:g.target.checked}})},v=g=>{o&&console.log("handleChangeMdnsInterface called with value:",g.target.value),I(g.target.value),c({id:$.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:g.target.value}})},H=g=>{o&&console.log("handleChangeIpv4Address called with value:",g.target.value),C(g.target.value),c({id:$.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:g.target.value}})},b=g=>{o&&console.log("handleChangeIpv6Address called with value:",g.target.value),E(g.target.value),c({id:$.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:g.target.value}})},d=g=>{o&&console.log("handleChangeMatterPort called with value:",g.target.value),f(g.target.value),c({id:$.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:g.target.value}})},i=g=>{o&&console.log("handleChangeMatterDiscriminator called with value:",g.target.value),O(g.target.value),c({id:$.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:g.target.value}})},p=g=>{o&&console.log("handleChangemMatterPasscode called with value:",g.target.value),j(g.target.value),c({id:$.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:g.target.value}})};return n?e.jsxs(ke,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matter settings"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Y,{sx:{gap:"20px",margin:"0px",padding:"10px",width:`${ue-20}px`,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(ye,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(Ke,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:s,onChange:_,children:[e.jsx(N,{value:"Debug",children:"Debug"}),e.jsx(N,{value:"Info",children:"Info"}),e.jsx(N,{value:"Notice",children:"Notice"}),e.jsx(N,{value:"Warn",children:"Warn"}),e.jsx(N,{value:"Error",children:"Error"}),e.jsx(N,{value:"Fatal",children:"Fatal"})]}),e.jsx(Ve,{style:{padding:"0px",margin:"0px"},control:e.jsx(Ee,{checked:u,onChange:F,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Mdns interface:"}),e.jsx(me,{value:t,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",marginBottom:"10px",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv4 address:"}),e.jsx(me,{value:W,onChange:H,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",marginBottom:"10px",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv6 address:"}),e.jsx(me,{value:S,onChange:b,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",marginBottom:"10px",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning port:"}),e.jsx(me,{value:D,onChange:d,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",marginBottom:"10px",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning discriminator:"}),e.jsx(me,{value:V,onChange:i,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",marginBottom:"10px",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning passcode:"}),e.jsx(me,{value:x,onChange:p,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]}):null}function ii({matterbridgeInfo:n}){return n?e.jsxs(ke,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Y,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsx(je,{value:n.matterbridgeVersion,label:"Current Version",width:ue}),e.jsx(je,{value:n.matterbridgeLatestVersion,label:"Latest Version",width:ue}),e.jsx(je,{value:n.homeDirectory,label:"Home Directory",width:ue}),e.jsx(je,{value:n.rootDirectory,label:"Root Directory",width:ue}),e.jsx(je,{value:n.matterbridgeDirectory,label:"Matterbridge Storage Directory",width:ue}),e.jsx(je,{value:n.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory",width:ue}),e.jsx(je,{value:n.globalModulesDirectory,label:"Global Module Directory",width:ue})]})})]}):null}function si({systemInfo:n}){return n?e.jsxs(ke,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"System info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Y,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsx(je,{value:n.interfaceName,label:"Interface name",width:ue}),e.jsx(je,{value:n.macAddress,label:"MAC Address",width:ue}),e.jsx(je,{value:n.ipv4Address,label:"IPv4 Address",width:ue}),e.jsx(je,{value:n.ipv6Address,label:"IPv6 Address",width:ue}),e.jsx(je,{value:n.nodeVersion,label:"Node Version",width:ue}),e.jsx(je,{value:n.hostname,label:"Hostname",width:ue}),e.jsx(je,{value:n.user,label:"User",width:ue})]})})]}):null}function je({value:n,label:c,width:l}){return e.jsx(me,{focused:!0,value:n,size:"small",label:c,variant:"standard",sx:{width:l?`${l-20}px`:"400px"},InputProps:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},InputLabelProps:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}})}const ai=r.memo(ri);function li(){const{online:n,sendMessage:c,addListener:l,removeListener:s,getUniqueId:a}=r.useContext(fe),{showSnackbarMessage:u}=r.useContext(_e),[h,t]=r.useState(null),[I,W]=r.useState([]),[C,S]=r.useState([]),[E,D]=r.useState(null),[f,V]=r.useState({cpuUsage:0}),[O,x]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[j,$]=r.useState({systemUptime:"",processUptime:""}),_=r.useRef(a());return o&&console.log("Test uniqueId:",_),r.useEffect(()=>{o&&console.log("Test useEffect WebSocketMessage mounting");const F=v=>{if(v.method==="restart_required")o&&console.log("Test received restart_required"),u("Restart required",0);else if(v.method==="refresh_required")o&&console.log(`Test received refresh_required: changed=${v.response.changed} and sending api requests`),u("Refresh required",0),c({id:_.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:_.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:_.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(v.method==="memory_update")o&&console.log("Test received memory_update",v),x(v.response);else if(v.method==="cpu_update")o&&console.log("Test received cpu_update",v),V(v.response);else if(v.method==="uptime_update")o&&console.log("Test received uptime_update",v),$(v.response);else if(v.method==="/api/settings"&&v.response)o&&console.log("Test received /api/settings:",v.response),u("Test received /api/settings",0),t(v.response);else if(v.method==="/api/plugins"&&v.response)o&&console.log(`Test received ${v.response.length} plugins:`,v.response),u("Test received /api/plugins",0),W(v.response);else if(v.method==="/api/devices"&&v.response){o&&console.log(`Test received ${v.response.length} devices:`,v.response),u("Test received /api/devices",0),S(v.response);for(const H of v.response)o&&console.log("Test sending /api/clusters for device:",H.pluginName,H.name,H.endpoint),c({id:_.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:H.pluginName,endpoint:H.endpoint||0}})}else v.method==="/api/clusters"&&v.response&&(o&&console.log(`Test received ${v.response.clusters.length} clusters for device ${v.response.deviceName} endpoint ${v.response.id}:${v.response.number}:`,v),u(`Test received /api/clusters for ${v.response.plugin}::${v.response.deviceName}`,0),D(v.response))};return l(F,_.current),o&&console.log("Test useEffect WebSocketMessage mounted"),()=>{o&&console.log("Test useEffect WebSocketMessage unmounting"),s(F),o&&console.log("Test useEffect WebSocketMessage unmounted")}},[l,s,c,u]),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,c,u]),o&&console.log("Test rendering..."),n?e.jsx("div",{className:"MbfPageDiv",style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",height:"100vh"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",width:"100%"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px"}}),e.jsx("p",{children:"Welcome to the Test page of the Matterbridge frontend"})]})}):e.jsx(Ie,{})}const di=r.memo(li);function ci(n,c){o&&console.log("getCssVariable:",n,"defaultValue",c);const l=getComputedStyle(document.body).getPropertyValue(n).trim();return l||console.error("getCssVariable: undefined",l),l||c}function pi(n){return lo({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 ui(){const{mobile:n,showSnackbarMessage:c,showConfirmCancelDialog:l}=r.useContext(_e),{online:s,sendMessage:a,logMessage:u,addListener:h,removeListener:t,getUniqueId:I}=r.useContext(fe),[W,C]=r.useState(!1),[S,E]=r.useState(!1),[D,f]=r.useState(!1),[V,O]=r.useState(!1),[x,j]=r.useState(null),$=r.useRef(I()),[_,F]=r.useState(null),[v,H]=r.useState(null),[b,d]=r.useState(null),[i,p]=r.useState(null),[g,T]=r.useState(null),ce=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},be=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},ne=()=>{x?.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?window.open("https://github.com/Luligu/matterbridge/blob/dev/CHANGELOG.md","_blank"):window.open("https://github.com/Luligu/matterbridge/blob/main/CHANGELOG.md","_blank")},Ce=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},J=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},z=()=>{a({id:$.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},w=()=>{a({id:$.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},A=()=>{a({id:$.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},P=()=>{o&&console.log("Header: handleShellySystemUpdateClick"),u("Matterbridge","Installing system updates..."),a({id:$.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},M=()=>{o&&console.log("Header: handleShellyMainUpdateClick"),u("Matterbridge","Installing software updates..."),a({id:$.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},k=()=>{o&&console.log("Header: handleShellyCreateSystemLog"),a({id:$.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},L=()=>{o&&console.log("Header: handleShellyDownloadSystemLog"),u("Matterbridge","Downloading Shelly system log..."),c("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},q=()=>{x?.matterbridgeInformation.restartMode===""?a({id:$.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):a({id:$.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},Z=()=>{a({id:$.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},pe=()=>{a({id:$.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},ae=()=>{a({id:$.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},le=()=>{a({id:$.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},ge=y=>{F(y.currentTarget)},B=y=>{o&&console.log("Header: handleMenuClose",y),F(null),y==="download-mblog"?(u("Matterbridge","Downloading matterbridge log..."),c("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):y==="download-mjlog"?(u("Matterbridge","Downloading matter log..."),c("Downloading matter log...",5),window.location.href="./api/download-mjlog"):y==="view-mblog"?(u("Matterbridge","Loading matterbridge log..."),c("Loading matterbridge log...",5),window.location.href="./api/view-mblog"):y==="view-mjlog"?(u("Matterbridge","Loading matter log..."),c("Loading matter log...",5),window.location.href="./api/view-mjlog"):y==="view-shellylog"?(u("Matterbridge","Loading shelly system log..."),c("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):y==="download-mbstorage"?(u("Matterbridge","Downloading matterbridge storage..."),c("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):y==="download-pluginstorage"?(u("Matterbridge","Downloading matterbridge plugins storage..."),c("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):y==="download-pluginconfig"?(u("Matterbridge","Downloading matterbridge plugins config..."),c("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):y==="download-mjstorage"?(u("Matterbridge","Downloading matter storage..."),c("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):y==="download-backup"?(u("Matterbridge","Downloading backup..."),c("Downloading backup...",10),window.location.href="./api/download-backup"):y==="update"?z():y==="updatedev"?w():y==="updatecheck"?A():y==="shelly-sys-update"?P():y==="shelly-main-update"?M():y==="shelly-create-system-log"?k():y==="shelly-download-system-log"?L():y==="softreset"?ae():y==="hardreset"?le():y==="restart"?q():y==="shutdown"?Z():y==="reboot"?pe():y==="create-backup"?a({id:$.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):y==="unregister"?a({id:$.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):y==="reset"?a({id:$.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):y==="factoryreset"&&a({id:$.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},U=y=>{o&&console.log("Header: handleMenuCloseCancel:",y),F(null)},m=y=>{H(y.currentTarget)},he=()=>{H(null)},ve=y=>{d(y.currentTarget)},de=()=>{d(null)},X=y=>{p(y.currentTarget)},oe=()=>{p(null)},Me=y=>{T(y.currentTarget)},De=()=>{T(null)},Ye=()=>{fi(),o&&console.log("Matterbridge logo clicked: debug is now",o)};return r.useEffect(()=>{const y=ee=>{o&&console.log("Header received WebSocket Message:",ee),ee.method==="/api/settings"&&ee.id===$.current?(o&&console.log("Header received settings:",ee.response),j(ee.response),C(ee.response.matterbridgeInformation.restartRequired||ee.response.matterbridgeInformation.fixedRestartRequired),E(ee.response.matterbridgeInformation.fixedRestartRequired),f(ee.response.matterbridgeInformation.updateRequired)):ee.method==="refresh_required"&&ee.response.changed==="settings"?(o&&console.log(`Header received refresh_required: changed=${ee.response.changed} and sending /api/settings request`),a({id:$.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):ee.method==="restart_required"?(o&&console.log(`Header received restart_required with fixed: ${ee.response.fixed}`),C(!0),ee.response.fixed===!0&&E(!0)):ee.method==="restart_not_required"?(o&&console.log("Header received restart_not_required"),C(!1)):ee.method==="update_required"?(o&&console.log("Header received update_required"),ee.response.devVersion===!0?O(!0):f(!0),a({id:$.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):ee.method==="shelly_sys_update"?(o&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),j(we=>we?{matterbridgeInformation:{...we.matterbridgeInformation,shellySysUpdate:ee.response.available},systemInformation:we.systemInformation}:null)):ee.method==="shelly_main_update"&&(o&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),j(we=>we?{matterbridgeInformation:{...we.matterbridgeInformation,shellyMainUpdate:ee.response.available},systemInformation:we.systemInformation}:null))};return h(y,$.current),o&&console.log(`Header added WebSocket listener id ${$.current}`),()=>{t(y),o&&console.log("Header removed WebSocket listener")}},[h,t,a,c]),r.useEffect(()=>{s&&(o&&console.log("Header sending /api/settings requests"),a({id:$.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[s,a]),o&&console.log("Header rendering... mobile %s",n),!s||!x?null:e.jsxs("div",{className:"header",children:[e.jsxs("div",{className:"sub-header",children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:Ye}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"}),e.jsxs("nav",{children:[e.jsx(nt,{to:"/",className:"nav-link",children:"Home"}),e.jsx(nt,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(nt,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(nt,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!x.matterbridgeInformation.readOnly&&D&&e.jsx(R,{title:"New Matterbridge version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:z,children:["Update to v.",x.matterbridgeInformation.matterbridgeLatestVersion]})}),!x.matterbridgeInformation.readOnly&&V&&e.jsx(R,{title:"New Matterbridge dev version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:w,children:["Update to new dev v.",x.matterbridgeInformation.matterbridgeDevVersion.split("-dev-")[0]]})}),!x.matterbridgeInformation.readOnly&&e.jsx(R,{title:"Matterbridge version, click to see the changelog",children:e.jsxs("span",{className:"status-information",onClick:ne,children:["v.",x.matterbridgeInformation.matterbridgeVersion]})}),x.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),x.matterbridgeInformation.bridgeMode!==""&&x.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:x.matterbridgeInformation.bridgeMode})}):null,x.matterbridgeInformation.restartMode!==""&&x.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:x.matterbridgeInformation.restartMode})}):null,x.matterbridgeInformation.profile&&x.matterbridgeInformation.profile!==""&&x.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:x.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[x.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:Ce})}):null,x.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Give a star to Matterbridge",children:e.jsx(K,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:J,children:e.jsx(co,{})})}):null,x.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Sponsor Matterbridge",children:e.jsx(K,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:ce,children:e.jsx(Zt,{})})}):null,e.jsx(R,{title:"Matterbridge help",children:e.jsx(K,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:be,children:e.jsx(po,{})})}),e.jsx(R,{title:"Matterbridge changelog",children:e.jsx(K,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:ne,children:e.jsx(Xt,{})})}),x.matterbridgeInformation&&!x.matterbridgeInformation.readOnly&&e.jsx(R,{title:"Update matterbridge to latest version",children:e.jsx(K,{style:{color:D?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:z,children:e.jsx(Re,{})})}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&x.matterbridgeInformation.shellySysUpdate&&e.jsx(R,{title:"Shelly system update",children:e.jsx(K,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:P,children:e.jsx(Re,{})})}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&x.matterbridgeInformation.shellyMainUpdate&&e.jsx(R,{title:"Shelly software update",children:e.jsx(K,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:M,children:e.jsx(Re,{})})}),e.jsx(R,{title:"Restart matterbridge",children:e.jsx(K,{style:{color:W||S?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:q,children:e.jsx(bt,{})})}),x.matterbridgeInformation.restartMode===""?e.jsx(R,{title:"Shut down matterbridge",children:e.jsx(K,{style:{color:W||S?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:Z,children:e.jsx(Ae,{})})}):null,e.jsx(R,{title:"Download, backup and more",children:e.jsx(K,{onClick:ge,children:e.jsx(uo,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(Ge,{id:"command-menu",anchorEl:_,keepMounted:!0,open:!!_,onClose:()=>B(""),children:[x.matterbridgeInformation&&!x.matterbridgeInformation.readOnly&&e.jsxs(N,{onClick:()=>B("update"),children:[e.jsx(G,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&!x.matterbridgeInformation.readOnly&&e.jsxs(N,{onClick:()=>B("updatedev"),children:[e.jsx(G,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&!x.matterbridgeInformation.readOnly&&e.jsxs(N,{onClick:()=>B("updatecheck"),children:[e.jsx(G,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&x.matterbridgeInformation.shellySysUpdate&&e.jsxs(N,{onClick:()=>B("shelly-sys-update"),children:[e.jsx(G,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&x.matterbridgeInformation.shellyMainUpdate&&e.jsxs(N,{onClick:()=>B("shelly-main-update"),children:[e.jsx(G,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(N,{onClick:()=>B("restart"),children:[e.jsx(G,{children:e.jsx(bt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation.restartMode===""?e.jsxs(N,{onClick:()=>B("shutdown"),children:[e.jsx(G,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&e.jsxs(N,{onClick:()=>{l("Reboot","Are you sure you want to reboot the Shelly board?","reboot",B,U)},children:[e.jsx(G,{children:e.jsx(bt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(dt,{}),e.jsxs(N,{onClick:ve,children:[e.jsx(G,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ge,{id:"sub-menu-view",anchorEl:b,keepMounted:!0,open:!!b,onClose:de,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(N,{onClick:()=>{B("view-mblog"),de()},children:[e.jsx(G,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(N,{onClick:()=>{B("view-mjlog"),de()},children:[e.jsx(G,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&e.jsxs(N,{onClick:()=>{B("view-shellylog"),de()},children:[e.jsx(G,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(N,{onClick:X,children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ge,{id:"sub-menu-download",anchorEl:i,keepMounted:!0,open:!!i,onClose:oe,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(N,{onClick:()=>{B("download-mbstorage"),oe()},children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(N,{onClick:()=>{B("download-pluginstorage"),oe()},children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(N,{onClick:()=>{B("download-pluginconfig"),oe()},children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(N,{onClick:()=>{B("download-mblog"),oe()},children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(N,{onClick:()=>{B("download-mjstorage"),oe()},children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(N,{onClick:()=>{B("download-mjlog"),oe()},children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&e.jsxs(N,{onClick:()=>{B("shelly-create-system-log"),oe()},children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&e.jsxs(N,{onClick:()=>{B("shelly-download-system-log"),oe()},children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(N,{onClick:m,children:[e.jsx(G,{children:e.jsx(St,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ge,{id:"sub-menu-backup",anchorEl:v,keepMounted:!0,open:!!v,onClose:he,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(N,{onClick:()=>{B("create-backup"),he()},children:[e.jsx(G,{children:e.jsx(St,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(N,{onClick:()=>{B("download-backup"),he()},children:[e.jsx(G,{children:e.jsx(St,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(N,{onClick:Me,children:[e.jsx(G,{children:e.jsx(go,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ge,{id:"sub-menu-reset",anchorEl:g,keepMounted:!0,open:!!g,onClose:De,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(N,{onClick:()=>{De(),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",B,U)},children:[e.jsx(G,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(N,{onClick:()=>{De(),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",B,U)},children:[e.jsx(G,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!x.matterbridgeInformation.readOnly&&e.jsxs(N,{onClick:()=>{De(),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",B,U)},children:[e.jsx(G,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&e.jsxs(N,{onClick:()=>{De(),l("Network reset","Are you sure you want to factory reset the network parameters?","softreset",B,U)},children:[e.jsx(G,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&e.jsxs(N,{onClick:()=>{De(),l("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",B,U)},children:[e.jsx(G,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const gi=r.memo(ui),ir=1200,sr=800;let Dt,Pt;function mi(){if(typeof window<"u"){Dt=Math.floor(window.visualViewport?.width??window.innerWidth),Pt=Math.floor(window.visualViewport?.height??window.innerHeight);const n=Dt<ir||Pt<sr;return o&&console.log("Visual viewport width %i height %i mobile %s",Dt,Pt,n),n}return!1}function hi({children:n}){const{mobile:c,setMobile:l}=r.useContext(_e);return r.useEffect(()=>{function s(){l(mi())}return window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[l]),o&&console.log("MbfScreen rendering... mobile %s",c),e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",width:c?`${ir}px`:"calc(100vw - 40px)",height:c?`${sr}px`:"calc(100vh - 40px)",margin:"0px",padding:"20px",gap:"20px"},children:[e.jsx(gi,{}),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 fi=()=>{o=!o};function xi({setLoggedIn:n}){const[c,l]=r.useState(""),[s,a]=r.useState(""),u={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)"},t={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)"},I=async C=>{try{const S=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:C})});if(S.ok){const{valid:E}=await S.json();E?n(!0):C!==""&&a("Incorrect password!")}else console.error("Failed to log in:",S.statusText)}catch(S){console.error("Failed to log in:",S)}},W=C=>{C.preventDefault(),I(c)};return I(""),e.jsx("div",{style:u,children:e.jsxs("form",{onSubmit:W,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:"64px",width:"64px"}}),e.jsx("h3",{style:{color:"var(--div-text-color)"},children:"Welcome to Matterbridge"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:"20px"},children:[e.jsx("input",{type:"text",name:"username",autoComplete:"username",style:{display:"none"},tabIndex:-1}),e.jsx("input",{type:"password",value:c,onChange:C=>l(C.target.value),style:t,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:s&&e.jsx("p",{style:{color:"red"},children:s})})]})})}function bi(){const[n,c]=r.useState(!1),l=localStorage.getItem("frontendTheme")||"dark";o&&console.log('Setting frontend theme "%s"',l),document.body.setAttribute("frontend-theme",l);const s=ci("--primary-color","#1976d2");o&&console.log('Primary color from CSS "%s"',s);const a=pi(s),u=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";return o&&(console.log("Loading App..."),console.log(`- with href = "${window.location.href}"`),console.log(`- pathname = "${window.location.pathname}"`),console.log(`- baseName = "${u}"`)),n?e.jsx(mo,{theme:a,children:e.jsx(wr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(Jo,{children:e.jsx(Zo,{children:e.jsx(xr,{basename:u,children:e.jsx(hi,{children:e.jsxs(br,{children:[e.jsx(qe,{path:"/",element:e.jsx(Pn,{})}),e.jsx(qe,{path:"/devices",element:e.jsx(Zn,{})}),e.jsx(qe,{path:"/log",element:e.jsx(Xn,{})}),e.jsx(qe,{path:"/settings",element:e.jsx(ai,{})}),e.jsx(qe,{path:"/test",element:e.jsx(di,{})}),e.jsx(qe,{path:"*",element:e.jsx(vr,{to:"/"})})]})})})})})})}):e.jsx(xi,{setLoggedIn:c})}yr.createRoot(document.getElementById("root")).render(e.jsx(jr.StrictMode,{children:e.jsx(bi,{})}));
1
+ import{B as e,y as r,S as nt,U as xr,V as br,X as qe,Y as vr,Z as yr,I as jr}from"./vendor_node_modules.js";import{u as Cr,S as wr}from"./vendor_notistack.js";import{D as Ne,a as $e,b as Le,B as ie,c as Oe,d as Y,A as Sr,I as K,C as kr,e as Mr,T as R,f as me,M as Ir,g as Ge,h as L,i as Pe,F as Dr,j as xt,k as se,l as Ee,K as Tt,m as Rt,n as yt,L as it,o as Xe,p as st,q as G,W as tt,r as at,H as lt,s as te,V as Ht,t as Ot,u as Pr,E as Nr,v as $r,w as Ve,Q as Jt,R as bt,S as Nt,U as Lr,P as Wr,x as Fr,y as Tr,z as Zt,G as Yt,J as vt,N as Rr,O as Xt,X as Hr,Y as Or,Z as Vr,_ as Vt,$ as Er,a0 as _r,a1 as Ar,a2 as qr,a3 as zr,a4 as Br,a5 as Ur,a6 as Et,a7 as Qr,a8 as Gr,a9 as Kr,aa as Jr,ab as Zr,ac as Yr,ad as Xr,ae as eo,af as to,ag as ro,ah as oo,ai as no,aj as io,ak as so,al as ao,am as _t,an as Ke,ao as er,ap as ye,aq as tr,ar as jt,as as He,at as lo,au as co,av as uo,aw as Re,ax as Ae,ay as po,az as dt,aA as ct,aB as St,aC as go,aD as mo}from"./vendor_mui.js";import{I as re,m as At,a as ho,b as fo,c as qt,d as xo,e as bo,f as vo,g as yo,h as jo,i as Co,j as wo,k as So,l as ko,n as Mo,o as Io,p as Do,q as zt,r as Po,s as No,t as $o,u as Lo,v as Wo,w as Fo,x as To,y as Ro,z as Bt,A as Ho,B as Oo}from"./vendor_mdi.js";import{Q as Vo}from"./vendor_qrcode.js";import{F as Eo,v as _o,e as Ao,a as qo,g as zo,b as Bo,c as Uo,d as kt,A as Qo}from"./vendor_rjsf.js";import"./vendor_lodash.js";import"./vendor_emotion.js";(function(){const c=document.createElement("link").relList;if(c&&c.supports&&c.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const p of a)if(p.type==="childList")for(const h of p.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&s(h)}).observe(document,{childList:!0,subtree:!0});function l(a){const p={};return a.integrity&&(p.integrity=a.integrity),a.referrerPolicy&&(p.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?p.credentials="include":a.crossOrigin==="anonymous"?p.credentials="omit":p.credentials="same-origin",p}function s(a){if(a.ep)return;a.ep=!0;const p=l(a);fetch(a.href,p)}})();function Go({open:n,title:c,message:l,onConfirm:s,onCancel:a}){const p=t=>{o&&console.log("Confirmed"),t.preventDefault(),s()},h=t=>{o&&console.log("Canceled"),t.preventDefault(),a()};return e.jsxs(Ne,{open:n,children:[e.jsx($e,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:c})]})}),e.jsxs(Le,{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(ie,{onClick:p,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(ie,{onClick:h,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const Ko=({open:n,output:c,packageName:l,onInstall:s,onClose:a})=>{const p=r.useRef(null);return r.useEffect(()=>{o&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom: ${p.current}`),setTimeout(()=>{o&&console.log("Scrolling to bottom:",p.current),p.current?.scrollIntoView({behavior:"smooth"})},0)},[c]),e.jsxs(Ne,{open:n,onClose:(h,t)=>{t==="backdropClick"||t==="escapeKeyDown"||a()},slotProps:{paper:{sx:{width:"70vw",maxWidth:"70vw",height:"70vw",maxHeight:"70vh",overflow:"hidden"}}},children:[e.jsx($e,{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.jsxs("h4",{style:{margin:0},children:["Install",s?"":"ing"," package ",l]})]})}),e.jsxs(Le,{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:"Install 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:[c.split(`
2
+ `).map((h,t)=>e.jsx("li",{style:{padding:0,margin:0,wordBreak:"break-all"},children:h},t)),e.jsx("li",{ref:p,style:{padding:0,margin:0}})]})]}),e.jsxs(Oe,{children:[s&&e.jsx(ie,{variant:"contained",onClick:s,children:"Install"}),e.jsx(ie,{onClick:a,children:"Close"})]})]})},ut=[],_e=r.createContext(null);function Jo({children:n}){const[c,l]=r.useState(!1),[s,a]=r.useState(null),{enqueueSnackbar:p,closeSnackbar:h}=Cr(),t=r.useCallback(z=>{o&&console.log(`UiProvider closeSnackbarMessage: message ${z}`);const w=ut.findIndex(A=>A.message===z);w!==-1&&(h(ut[w].key),ut.splice(w,1),o&&console.log(`UiProvider closeSnackbarMessage: message ${z} removed from persistMessages`))},[h]),S=r.useCallback((z,w,A)=>{o&&console.log(`UiProvider showSnackbarMessage: message ${z} timeout ${w}`);const P=p(z,{variant:"default",autoHideDuration:w==null||w>0?(w??5)*1e3:null,persist:w===0,content:I=>e.jsx(Y,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(Sr,{severity:A??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>h(I),action:e.jsx(K,{size:"small",onClick:()=>h(I),sx:{color:"#fff"},children:e.jsx(kr,{fontSize:"small"})}),children:z},I)},I)});w===0&&(o&&console.log(`UiProvider showSnackbarMessage: message ${z} timeout ${w} - persist key ${P}`),ut.push({message:z,key:P}))},[p,h]),[N,C]=r.useState(!1),[k,E]=r.useState(""),[D,f]=r.useState(""),[V,O]=r.useState(""),x=r.useRef(null),j=r.useRef(null),$=()=>{o&&console.log(`UiProvider handle confirm action ${V}`),C(!1),x.current&&x.current(V)},_=()=>{o&&console.log(`UiProvider handle cancel action ${V}`),C(!1),j.current&&j.current(V)},F=r.useCallback((z,w,A,P,I)=>{o&&console.log(`UiProvider showConfirmCancelDialog for command ${A}`),E(z),f(w),O(A),x.current=P,j.current=I,C(!0)},[]),[v,H]=r.useState(!1),[b,d]=r.useState(""),[i,u]=r.useState(""),g=r.useCallback(z=>{o&&console.log(`UiProvider show install progress for package ${z}`),d(z),u(`Starting installation of ${z}...
3
+ `),H(!0)},[]),T=r.useCallback(z=>{o&&console.log(`UiProvider addInstallProgress: output ${z}`),u(w=>w+z+`
4
+ `)},[]),ce=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressSuccess: package ${b}`),u(z=>z+`Successfully installed ${b}
5
+ `)},[b]),be=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressError: package ${b}`),u(z=>z+`Failed to install ${b}
6
+ `)},[b]),ne=r.useCallback(()=>{o&&console.log("UiProvider hide install progress"),H(!1)},[]),Ce=()=>{o&&console.log("UiProvider handle install close action"),H(!1),d(""),u("")},J=r.useMemo(()=>({mobile:c,setMobile:l,currentPage:s,setCurrentPage:a,showSnackbarMessage:S,closeSnackbarMessage:t,closeSnackbar:h,showConfirmCancelDialog:F,showInstallProgress:g,exitInstallProgressSuccess:ce,exitInstallProgressError:be,hideInstallProgress:ne,addInstallProgress:T}),[c,s,l,a,S,t,h,F,g,ce,be,ne,T]);return e.jsxs(_e.Provider,{value:J,children:[e.jsx(Go,{open:N,title:k,message:D,onConfirm:$,onCancel:_}),e.jsx(Ko,{open:v,packageName:b,output:i,onClose:Ce}),n]})}const rr=r.createContext(null),fe=r.createContext(null);function Zo({children:n}){const[c,l]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[s,a]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[p,h]=r.useState([]),[t,S]=r.useState(1e3),[N,C]=r.useState(!0),[k,E]=r.useState(!1),{showSnackbarMessage:D,closeSnackbarMessage:f,closeSnackbar:V,showInstallProgress:O,hideInstallProgress:x,exitInstallProgressSuccess:j,exitInstallProgressError:$,addInstallProgress:_}=r.useContext(_e),F=r.useRef([]),v=r.useRef(null),H=r.useRef(1),b=r.useRef(Math.floor(Math.random()*999e3)+1e3),d=r.useRef(null),i=r.useRef(null),u=r.useRef(null),g=r.useRef(c),T=r.useRef(s),ce=r.useRef(0),be=r.useRef(null),ne=r.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),Ce=r.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),J=100,z=60,w=50,A=300,P=10;r.useEffect(()=>(o&&console.log("WebSocket messages started counter interval"),be.current=setInterval(()=>{ce.current>0&&(o&&console.log(`WebSocket messages received in the last ${P} seconds: ${ce.current*(60/P)} messages/minute`),ce.current=0)},P*1e3),()=>{o&&console.log("WebSocket messages stopped counter interval"),be.current&&clearInterval(be.current),be.current=null}),[]),r.useEffect(()=>{g.current=c},[c]),r.useEffect(()=>{T.current=s},[s]);const I=r.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),M=r.useCallback(U=>{if(v.current&&v.current.readyState===WebSocket.OPEN)try{o&&console.log(`WebSocket sending message with id ${U.id}:`,U),U.id===void 0&&(U.id=b.current);const m=JSON.stringify(U);v.current.send(m),o&&console.log("WebSocket sent message:",U)}catch(m){o&&console.error(`WebSocket error sending message: ${m}`)}else o&&console.error("WebSocket message not sent, WebSocket not connected:",U)},[]),W=r.useCallback((U,m)=>{h(he=>[...he,{level:U,time:"",name:"",message:m}])},[]),q=r.useCallback((U,m)=>{l(U),a(m),W("WebSocket",`Filtering by log level "${U}" and log search "${m}"`)},[W]),Z=r.useCallback((U,m)=>{o&&console.log(`WebSocket addListener id ${m}:`,U),(m==null||isNaN(m)||m===0)&&console.error("WebSocket addListener called without id, listener not added:",U),F.current=[...F.current,{listener:U,id:m}],o&&console.log("WebSocket addListener total listeners:",F.current.length)},[]),ue=r.useCallback(U=>{o&&console.log("WebSocket removeListener:",U),F.current=F.current.filter(m=>m.listener!==U),o&&console.log("WebSocket removeListener total listeners:",F.current.length)},[]),ae=r.useCallback(()=>{ne===""||ne===null||ne===void 0||(W("WebSocket",`Connecting to WebSocket: ${ne}`),v.current=new WebSocket(ne),v.current.onmessage=U=>{k||E(!0),ce.current+=1;try{const m=JSON.parse(U.data);if(m.id===void 0||m.src===void 0||m.dst===void 0){o&&console.error("WebSocket undefined message id/src/dst:",m);return}if(m.src!=="Matterbridge"||m.dst!=="Frontend"){o&&console.error("WebSocket invalid message src/dst:",m);return}if(m.error){o&&console.error("WebSocket error message response:",m);return}if(m.id===b.current&&m.method==="pong"&&m.response==="pong"){o&&console.log(`WebSocket pong response message id ${m.id}:`,m),i.current&&clearTimeout(i.current),i.current=null;return}else if(m.method==="snackbar"&&m.response&&m.response.message){o&&console.log(`WebSocket message id ${m.id} method ${m.method}:`,m),D(m.response.message,m.response.timeout,m.response.severity);return}else if(m.method==="close_snackbar"&&m.response&&m.response.message){o&&console.log(`WebSocket message id ${m.id} method ${m.method}:`,m),f(m.response.message);return}else if(m.method==="log"){if(!m.response||!m.response.level||!m.response.time||!m.response.name||!m.response.message||(m.response.level==="spawn"&&(m.response.name==="Matterbridge:spawn-init"?O(m.response.message):m.response.name==="Matterbridge:spawn-exit-success"?j():m.response.name==="Matterbridge:spawn-exit-error"?$():_(m.response.message+`
7
+ `)),["debug","info","notice","warn","error","fatal"].includes(m.response.level)&&(g.current==="info"&&m.response.level==="debug"||g.current==="notice"&&(m.response.level==="debug"||m.response.level==="info")||g.current==="warn"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice")||g.current==="error"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn")||g.current==="fatal"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn"||m.response.level==="error")))||T.current!=="*"&&T.current!==""&&!m.response.message.toLowerCase().includes(T.current.toLowerCase())&&!m.response.name.toLowerCase().includes(T.current.toLowerCase())||m.response.name==="Commissioning"&&m.response.message.includes("is uncommissioned"))return;h(ve=>{const de=[...ve,{level:m.response.level,time:m.response.time,name:m.response.name,message:m.response.message}];return de.length>t*2?de.slice(t):de})}else{if(o&&console.log(`WebSocket received message id ${m.id} method ${m.method}:`,m),m.id===0)F.current.forEach(he=>he.listener(m));else{const he=F.current.find(ve=>ve.id===m.id);he?he.listener(m):o&&console.debug(`WebSocket no listener found for message id ${m.id}:`,m)}return}}catch(m){console.error(`WebSocketUse error parsing message: ${m}`)}},v.current.onopen=()=>{o&&console.log(`WebSocket: Connected to WebSocket: ${ne}`),W("WebSocket",`Connected to WebSocket: ${ne}`),E(!0),V(),H.current=1,u.current=setTimeout(()=>{d.current=setInterval(()=>{M({id:b.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{o&&console.error(`WebSocketUse: No pong response received from WebSocket: ${ne}`),W("WebSocket",`No pong response received from WebSocket: ${ne}`),E(!1)},1e3*w)},1e3*z)},1e3*A)},v.current.onclose=()=>{o&&console.error(`WebSocket: Disconnected from WebSocket ${Ce?"with Ingress":""}: ${ne}`),W("WebSocket",`Disconnected from WebSocket: ${ne}`),E(!1),V(),x(),u.current&&clearTimeout(u.current),i.current&&clearTimeout(i.current),d.current&&clearInterval(d.current),W("WebSocket",`Reconnecting (attempt ${H.current} of ${J}) to WebSocket${Ce?" (Ingress)":""}: ${ne}`),Ce?setTimeout(le,5e3):H.current===1?le():H.current<J?setTimeout(le,1e3*H.current):W("WebSocket",`Reconnect attempts exceeded limit of ${J} retries, refresh the page to reconnect to: ${ne}`),H.current=H.current+1},v.current.onerror=U=>{o&&console.error(`WebSocket: WebSocket error connecting to ${ne}:`,U),W("WebSocket",`WebSocket error connecting to ${ne}`)})},[ne]),le=r.useCallback(()=>{o&&console.log(`WebSocket attemptReconnect ${H.current}/${J} to:`,ne),ae()},[ae]);r.useEffect(()=>(ae(),()=>{v.current&&v.current.readyState===WebSocket.OPEN&&v.current.close()}),[ae]);const ge=r.useMemo(()=>({messages:p,maxMessages:t,autoScroll:N,setMessages:h,setLogFilters:q,setMaxMessages:S,setAutoScroll:C}),[p,h,q]),B=r.useMemo(()=>({maxMessages:t,autoScroll:N,logFilterLevel:c,logFilterSearch:s,setMessages:h,setLogFilters:q,setMaxMessages:S,setAutoScroll:C,online:k,retry:H.current,getUniqueId:I,addListener:Z,removeListener:ue,sendMessage:M,logMessage:W}),[t,N,h,q,S,C,k,H.current,Z,ue,M,W]);return e.jsx(rr.Provider,{value:ge,children:e.jsx(fe.Provider,{value:B,children:n})})}function Yo(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 Me(){const{retry:n}=r.useContext(fe),c=()=>{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(Yo,{style:{height:"128px",width:"128px",margin:"10px",marginBottom:"20px"}}),n<100?e.jsxs(e.Fragment,{children:[e.jsx(Mr,{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(ie,{variant:"contained",color:"primary",onClick:c,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})}function Xo({value:n,maxChars:c}){let l=n;if(n.length>c&&c>3){const s=c-3,a=n.substring(0,Math.ceil(s/2)),p=n.substring(n.length-Math.floor(s/2),n.length);l=`${a} … ${p}`}return n!==l?e.jsx(R,{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 ke({children:n,style:c}){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,...c},children:n})}function Je({children:n,style:c}){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,...c},children:n})}function Ze({children:n,style:c}){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,...c},children:n})}function pt({children:n,style:c}){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,...c},children:n})}function gt({children:n,style:c}){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,...c},children:n})}function et({children:n,style:c}){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,...c},children:n})}function rt({children:n,style:c,onClose:l}){const s={display:"flex",flexDirection:"row",margin:"0px",padding:"0px",paddingRight:"10px",gap:"10px"};return e.jsxs("div",{style:{...s,...c},children:[n,xi]})}function en({systemInfo:n,compact:c}){const{addListener:l,removeListener:s,getUniqueId:a}=r.useContext(fe),[p,h]=r.useState(n),t=r.useRef(a());if(o&&console.log("SystemInfoTable loading with systemInfo:",p,"compact:",c),n&&c&&p.totalMemory&&p.freeMemory){const D=p.totalMemory,f=p.freeMemory;p.freeMemory=`${f} / ${D}`,p.totalMemory=""}if(n&&c&&p.heapTotal&&p.heapUsed){const D=p.heapTotal,f=p.heapUsed;p.heapUsed=`${f} / ${D}`,p.heapTotal=""}if(n&&c&&p.osRelease&&p.osType){const D=p.osType,f=p.osRelease;p.osType=`${D} (${f})`,p.osRelease=""}if(n&&c&&p.osArch&&p.osPlatform){const D=p.osPlatform,f=p.osArch;p.osPlatform=`${D} (${f})`,p.osArch=""}const S=(D,f,V,O,x)=>{h(j=>({...j,totalMemory:D,freeMemory:f,heapTotal:V,heapUsed:O,rss:x}))},N=D=>{h(f=>({...f,cpuUsage:D.toFixed(2)+" %"}))},C=(D,f)=>{h(V=>({...V,systemUptime:D,processUptime:f}))};r.useEffect(()=>{const D=f=>{f.method==="memory_update"&&f.response&&f.response.totalMemory&&f.response.freeMemory&&f.response.heapTotal&&f.response.heapUsed&&f.response.rss?(o&&console.log("SystemInfoTable received memory_update",f),S(f.response.totalMemory,f.response.freeMemory,f.response.heapTotal,f.response.heapUsed,f.response.rss)):f.method==="cpu_update"&&f.response&&f.response.cpuUsage?(o&&console.log("SystemInfoTable received cpu_update",f),N(f.response.cpuUsage)):f.method==="uptime_update"&&f.response&&f.response.systemUptime&&f.response.processUptime&&(o&&console.log("SystemInfoTable received uptime_update",f),C(f.response.systemUptime,f.response.processUptime))};return l(D,t.current),o&&console.log(`SystemInfoTable added WebSocket listener id ${t.current}`),()=>{s(D),o&&console.log("SystemInfoTable removed WebSocket listener")}},[l,s]);const[k,E]=r.useState(!1);return!p||k?null:(o&&console.log("SystemInfoTable rendering..."),e.jsxs(ke,{style:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Je,{children:[e.jsx(Ze,{children:"System Information"}),e.jsx(rt,{onClose:()=>E(!0)})]}),e.jsx("div",{className:"MbfWindowDivTable",children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(p).filter(([D,f])=>f!==void 0&&f!=="").map(([D,f],V)=>e.jsxs("tr",{className:V%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:D}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(Xo,{value:typeof f!="string"?f.toString():f,maxChars:24})})]},D))})})})]}))}const tn=r.memo(en),Ut={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"}},rn=n=>{if(!n)return"";const c=n.toString().replace(/[^0-9]/g,"");if(c.length<5)return c;const l=c.slice(0,4),s=c.slice(4,7),a=c.slice(7,11);return[l,s,a].filter(Boolean).join("-")};function on({id:n}){const{online:c,sendMessage:l,addListener:s,removeListener:a,getUniqueId:p}=r.useContext(fe),[h,t]=r.useState(null),S=r.useRef(null),N=r.useRef(null),C=r.useRef(p()),{showConfirmCancelDialog:k}=r.useContext(_e);o&&console.log(`QRDiv loading with id = "${n}" storeId = "${S.current}" timeout = ${N.current} and matter:`,h),r.useEffect(()=>{o&&console.log(`QRDiv id effect "${n}"`),S.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:C.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"),t(null))},[n,l]),r.useEffect(()=>{const x=j=>{j.method==="refresh_required"&&j.response.changed==="matter"&&j.response.matter&&(o&&console.log(`QRDiv received refresh_required: changed=${j.response.changed} for storeId "${j.response.matter.id}":`,j.response.matter),S.current===j.response.matter.id&&(o&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${j.response.matter.id}":`,j.response.matter),N.current&&clearTimeout(N.current),j.response.matter.advertising&&j.response.matter.advertiseTime&&j.response.matter.advertiseTime+9e5<=Date.now()&&(j.response.matter.advertising=!1),t(j.response.matter),j.response.matter.advertising&&(o&&console.log(`QRDiv setting matter advertise timeout for storeId "${j.response.matter.id}":`,j.response.matter.advertiseTime+9e5-Date.now()),N.current=setTimeout(()=>{N.current&&clearTimeout(N.current),o&&console.log(`QRDiv clearing advertising state for storeId "${S.current}" after 15 minutes`),t($=>$&&{...$,advertising:!1})},j.response.matter.advertiseTime+9e5-Date.now()))))};return s(x,C.current),o&&console.log("QRDiv webSocket effect mounted"),()=>{a(x),N.current&&clearTimeout(N.current),N.current=null,o&&console.log("QRDiv webSocket effect unmounted")}},[s,a]);const E=()=>{o&&console.log(`QRDiv sent matter startCommission for node "${h?.id}"`),h&&l({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,startCommission:!0}})},D=()=>{o&&console.log(`QRDiv sent matter stopCommission for node "${h?.id}"`),h&&l({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,stopCommission:!0}})},f=()=>{o&&console.log(`QRDiv sent matter advertise for node "${h?.id}"`),h&&l({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,advertise:!0}})},V=x=>{o&&console.log(`QRDiv sent matter removeFabric for node "${h?.id}" and fabricIndex ${x}`),h&&l({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,removeFabric:x}})},O=async()=>{if(!h||!h.manualPairingCode)return;const x=h.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(x);else{const j=document.createElement("textarea");j.value=x,j.style.position="fixed",j.style.opacity="0",document.body.appendChild(j),j.focus(),j.select(),document.execCommand("copy"),document.body.removeChild(j)}o&&console.log("Manual pairing code copied to clipboard")}catch(j){console.error("Failed to copy manual pairing code",j)}};return!h||!c?(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(ke,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs(Je,{children:[e.jsx(Ze,{children:"QR pairing code"}),e.jsxs(rt,{children:[e.jsx(K,{"aria-label":"send advertising",size:"small",onClick:f,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(R,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(re,{path:At,size:"22px"})})}),e.jsx(K,{"aria-label":"stop pairing",size:"small",onClick:D,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(R,{title:"Turn off pairing",arrow:!0,children:e.jsx(re,{path:ho,size:"22px"})})})]})]}),e.jsx(et,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:S.current}),e.jsx(Vo,{value:h.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs(pt,{style:{justifyContent:"space-between"},children:[e.jsxs(gt,{style:{fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",rn(h.manualPairingCode)]}),e.jsx(rt,{children:e.jsx(R,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(K,{"aria-label":"copy manual pairing code",size:"small",onClick:O,sx:Ut,children:e.jsx(re,{path:fo,size:.85})})})})]})]})):h.commissioned&&h.fabricInformations&&h.sessionInformations?(o&&console.log("QRDiv rendering commissioned state"),e.jsxs(ke,{style:{alignItems:"center",minWidth:"302px",overflow:"hidden"},children:[e.jsxs(Je,{children:[e.jsx(Ze,{children:"Paired fabrics"}),e.jsxs(rt,{children:[e.jsx(K,{"aria-label":"send advertising",size:"small",onClick:f,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(R,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(re,{path:At,size:"22px"})})}),e.jsx(K,{"aria-label":"start pairing",size:"small",onClick:E,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(R,{title:"Turn on pairing",arrow:!0,children:e.jsx(re,{path:qt,size:"22px"})})})]})]}),e.jsx(et,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:S.current}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{paddingTop:"0px"},children:h.fabricInformations.map((x,j)=>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: ",x.fabricIndex]}),e.jsx(R,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(K,{"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",()=>V(x.fabricIndex),()=>{}),sx:{...Ut,padding:"2px"},children:e.jsx(re,{path:xo,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",x.rootVendorId," ",x.rootVendorName]}),x.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",x.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",h.sessionInformations?h.sessionInformations.filter($=>$.fabric?.fabricIndex===x.fabricIndex&&$.isPeerActive===!0).length:"0"," ","subscriptions: ",h.sessionInformations?h.sessionInformations.filter($=>$.fabric?.fabricIndex===x.fabricIndex&&$.isPeerActive===!0&&$.numberOfActiveSubscriptions>0).length:"0"]})]},j))}),e.jsx(pt,{style:{justifyContent:"center"},children:e.jsxs(gt,{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(ke,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsx(Je,{children:e.jsx(Ze,{children:"QR pairing code"})}),e.jsx(et,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:S.current}),e.jsx(ie,{onClick:E,endIcon:e.jsx(re,{path:qt,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(pt,{style:{justifyContent:"center"},children:e.jsxs(gt,{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(ke,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsx(Je,{style:{height:"30px",justifyContent:"space-between"},children:e.jsx(Ze,{children:"Server node"})}),e.jsx(et,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:S.current}),e.jsx(et,{style:{fontWeight:"bold"},children:"Server offline"}),e.jsx(pt,{style:{justifyContent:"center"},children:e.jsxs(gt,{style:{fontWeight:"normal"},children:["Serial number: ",h.serialNumber]})})]}))}const nn=r.memo(on);function sn(){const{logMessage:n,sendMessage:c,getUniqueId:l}=r.useContext(fe),[s,a]=r.useState("matterbridge-"),[p,h]=r.useState(!1),[t,S]=r.useState(null),N=r.useRef(l()),C=F=>{F.preventDefault(),h(!0)},k=()=>{h(!1)},E=F=>{F.preventDefault(),h(!1);const v=F.dataTransfer.files[0];if(v){n("Plugins",`Installing package ${v.name}. Please wait...`);const H=new FormData;H.append("file",v),H.append("filename",v.name),fetch("./api/uploadpackage",{method:"POST",body:H}).then(b=>b.text()).then(b=>{n("Plugins",`Server response: ${b}`)}).catch(b=>{console.error("Error uploading plugin file:",b),n("Plugins",`Error installing package ${b}`)})}},D=F=>{const v=F.target.files&&F.target.files[0];if(v){n("Plugins",`Uploading package ${v.name}`);const H=new FormData;H.append("file",v),H.append("filename",v.name),fetch("./api/uploadpackage",{method:"POST",body:H}).then(b=>b.text()).then(b=>{n("Plugins",`Server response: ${b}`)}).catch(b=>{console.error("Error uploading plugin file:",b),n("Plugins",`Error uploading package ${b}`)})}},f=()=>{c({id:N.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:s,restart:!1}})},V=()=>{document.getElementById("file-upload")?.click()},O=()=>{c({id:N.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:s}})},x=F=>{S(F.currentTarget)},j=F=>{F!==""&&a(F),S(null)},[$,_]=r.useState(!1);return o&&console.log("HomeInstallAddPlugins rendering..."),$?null:e.jsxs(ke,{children:[e.jsxs(Je,{children:[e.jsx(Ze,{children:"Install plugins"}),e.jsx(rt,{onClose:()=>_(!0)})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",alignItems:"center",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"},onDragOver:C,onDragLeave:k,onDrop:E,children:[e.jsx(me,{value:s,onChange:F=>{a(F.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(K,{onClick:x,children:e.jsx(Ir,{})}),e.jsxs(Ge,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>j(""),children:[e.jsx(L,{onClick:()=>j("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(L,{onClick:()=>j("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(L,{onClick:()=>j("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(L,{onClick:()=>j("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(L,{onClick:()=>j("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(L,{onClick:()=>j("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(L,{onClick:()=>j("matterbridge-test"),children:"matterbridge-test"}),e.jsx(L,{onClick:()=>j("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(L,{onClick:()=>j("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(L,{onClick:()=>j("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(L,{onClick:()=>j("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(L,{onClick:()=>j("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(L,{onClick:()=>j("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(L,{onClick:()=>j("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx(R,{title:"Install or update a plugin from npm",children:e.jsx(ie,{onClick:f,endIcon:e.jsx(Pe,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Install"})}),e.jsx(R,{title:"Upload and install a plugin from a tarball",children:e.jsx(ie,{onClick:V,endIcon:e.jsx(Dr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Upload"})}),e.jsx(R,{title:"Add an installed plugin",children:e.jsx(ie,{onClick:O,endIcon:e.jsx(xt,{}),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:D})]})]})}const an=r.memo(sn);function ze({status:n,enabledText:c="Enabled",disabledText:l=void 0,tooltipText:s=void 0,onClick:a}){if(n===void 0)return null;{const p=e.jsx("div",{className:n?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:a,children:n?c:l??c});return s!==void 0?e.jsx(R,{title:s,children:p}):p}}function Qt(n){return n.id!==0&&n.src==="Matterbridge"&&n.dst==="Frontend"}const Be={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Ue={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},ln={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},dn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Fe={padding:"0px",margin:"0px"},cn="5px 10px 5px 10px",mt={},xe={},ht={},ft={};let Qe=[],Mt=[];const un=({open:n,onClose:c,plugin:l})=>{const{sendMessage:s,addListener:a,removeListener:p,getUniqueId:h}=r.useContext(fe),t=r.useRef(h()),[S,N]=r.useState(l.configJson),[C,k]=r.useState(null),[E,D]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[f,V]=r.useState("");let O={};r.useEffect(()=>{const I=M=>{M.src==="Matterbridge"&&M.dst==="Frontend"&&(Qt(M)&&M.id===t.current&&M.method==="/api/select/devices"&&M.response&&(o&&console.log(`ConfigPluginDialog (id: ${M.id}) received ${M.response.length} /api/select/devices:`,M.response),Qe=M.response),Qt(M)&&M.id===t.current&&M.method==="/api/select/entities"&&M.response&&(o&&console.log(`ConfigPluginDialog (id: ${M.id}) received ${M.response.length} /api/select/entities:`,M.response),Mt=M.response))};return a(I,t.current),o&&console.log("ConfigPluginDialog added WebSocket listener id:",t.current),S&&C&&C.properties&&(Object.keys(C.properties).forEach(M=>{Object.keys(C.properties[M]).forEach(W=>{W.startsWith("ui:")&&(E[M]={},E[M][W]=C.properties[M][W],delete C.properties[M][W])})}),D(E)),l.name&&l.configJson&&l.schemaJson&&(N(l.configJson),k(l.schemaJson),s({id:t.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),s({id:t.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)),()=>{p(I),o&&console.log("ConfigPluginDialog removed WebSocket listener")}},[a,S,l,p,C,s,E]);const x=(I,M)=>{O=I.formData},j=I=>{o&&console.log("ConfigPluginDialog handleSaveChanges:",I.formData),N(I.formData),l.configJson=I.formData,l.restartRequired=!0,s({id:t.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:I.formData.name,formData:I.formData}}),c()};function $(I){const{id:M,label:W,onKeyChange:q,onDropPropertyClick:Z,disabled:ue,schema:ae,children:le,registry:ge,readonly:B,required:U}=I,{templates:m}=ge,{RemoveButton:he}=m.ButtonTemplates;if(!(Qo in ae))return e.jsx(Y,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:le});const de=({target:X})=>q(X&&X.value);return e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(me,{id:`${M}-key`,name:`${M}-key`,required:U,disabled:ue||B,defaultValue:W,onBlur:B?void 0:de,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(Y,{sx:{flex:1},children:le}),e.jsx(he,{disabled:ue||B,onClick:Z(W),registry:ge})]})}function _(I){const{children:M,description:W,displayLabel:q,errors:Z,help:ue,hidden:ae,registry:le,uiSchema:ge}=I,B=Bo(ge),U=Uo("WrapIfAdditionalTemplate",le,B);return ae?e.jsx("div",{style:{display:"none"},children:M}):e.jsx(Y,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(U,{...I,children:[q===!0&&W,M,Z,ue]})})}function F(I){const{description:M}=I;return M?e.jsx(se,{sx:Ue,children:M}):null}function v(I){const{required:M,title:W}=I;return W?e.jsx(Y,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(se,{sx:Be,children:["Title ",W," ",M&&e.jsx("mark",{children:"***"})]})}):null}function H(I){const{help:M}=I;return M?e.jsx(Y,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(se,{sx:ln,children:M})}):null}function b(I){const{errors:M}=I;return M?e.jsxs(Y,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(se,{color:"error",sx:dn,children:"Please fix the following errors:"}),e.jsx(Xe,{children:M.map((W,q)=>e.jsxs(Pr,{children:[e.jsx(G,{children:e.jsx(Nr,{color:"error"})}),e.jsx(te,{primary:W.stack})]},q))})]}):null}function d(I){const{errors:M}=I;return M?e.jsx(Y,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:M.map((W,q)=>e.jsxs(se,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",W]},q))}):null}function i(I){const{id:M,name:W,_schema:q,_uiSchema:Z,value:ue,options:ae,label:le,type:ge,placeholder:B,required:U,disabled:m,readonly:he,autofocus:ve,onChange:de,onChangeOverride:X,onBlur:oe,onFocus:Ie,_rawErrors:De,_hideError:Ye,_registry:y,_formContext:ee}=I,we=({target:{value:Se}})=>de(Se===""?ae.emptyValue:Se),Te=({target:Se})=>oe(M,Se&&Se.value),ot=({target:Se})=>Ie(M,Se&&Se.value);return e.jsx(Y,{sx:{padding:"0px",margin:"0px"},children:e.jsx(me,{id:M,name:M,label:B&&B!==""?le:void 0,variant:"outlined",placeholder:B&&B!==""?B:le,required:U,disabled:m||he,autoFocus:ve,value:ue||ue===0?ue:"",type:ge,autoComplete:ge==="password"?"current-password":W,onChange:X||we,onBlur:Te,onFocus:ot,fullWidth:!0})})}function u(I){return console.log("ArrayFieldTitleTemplate:",I),null}function g(I){return console.log("ArrayFieldDescriptionTemplate:",I),null}function T(I){return console.log("ArrayFieldItemTemplate:",I),null}function ce(I){const{canAdd:M,onAddClick:W,schema:q,title:Z}=I,[ue,ae]=r.useState(!1),[le,ge]=r.useState(!1),[B,U]=r.useState(!1),[m,he]=r.useState(""),ve=y=>{he(y.target.value)},de=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",m,"selectDevices:",Qe),ae(!ue)},X=()=>{o&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",m,"selectEntities:",Mt),ge(!le)},oe=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",m,"selectDevices:",Qe),U(!B)},Ie=y=>{ae(!1),q.selectFrom==="serial"?q.items.default=y.serial:q.selectFrom==="name"&&(q.items.default=y.name),W()},De=y=>{ge(!1),q.selectEntityFrom==="name"?q.items.default=y.name:q.selectEntityFrom==="description"&&(q.items.default=y.description),W()},Ye=y=>{U(!1),q.selectDeviceEntityFrom==="name"?q.items.default=y.name:q.selectDeviceEntityFrom==="description"&&(q.items.default=y.description),W()};return e.jsxs(Y,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[Z&&e.jsxs(Y,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Z&&e.jsx(se,{sx:Be,children:Z}),M&&e.jsxs(Y,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[q.selectFrom&&e.jsx(R,{title:"Add a device from the list",children:e.jsx(K,{onClick:de,size:"small",color:"primary",sx:Fe,children:e.jsx(it,{})})}),q.selectEntityFrom&&e.jsx(R,{title:"Add an entity from the list",children:e.jsx(K,{onClick:X,size:"small",color:"primary",sx:Fe,children:e.jsx(it,{})})}),q.selectDeviceEntityFrom&&e.jsx(R,{title:"Add a device entity from the list",children:e.jsx(K,{onClick:oe,size:"small",color:"primary",sx:Fe,children:e.jsx(it,{})})}),e.jsx(R,{title:"Add a new item",children:e.jsx(K,{onClick:W,size:"small",color:"primary",sx:Fe,children:e.jsx(xt,{})})})]})]}),q.description&&e.jsx(se,{sx:Ue,children:q.description}),I.items.map(y=>e.jsxs(Y,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(Y,{sx:{flexGrow:1,marginRight:"10px"},children:y.children}),e.jsx(K,{disabled:!y.hasMoveUp,onClick:y.onReorderClick(y.index,y.index-1),size:"small",color:"primary",sx:Fe,children:e.jsx(Rt,{})}),e.jsx(K,{disabled:!y.hasMoveDown,onClick:y.onReorderClick(y.index,y.index+1),size:"small",color:"primary",sx:Fe,children:e.jsx(Tt,{})}),e.jsx(K,{onClick:y.onDropIndexClick(y.index),size:"small",color:"primary",sx:Fe,children:e.jsx(yt,{})})]},y.index)),e.jsxs(Ne,{open:ue,onClose:de,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx($e,{children:"Select a device"}),e.jsxs(Le,{children:[e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(me,{fullWidth:!0,variant:"outlined",value:m,onChange:ve,placeholder:"Enter serial or name"})]}),e.jsx(Xe,{dense:!0,children:Qe.filter(y=>y.serial.toLowerCase().includes(m.toLowerCase())||y.name.toLowerCase().includes(m.toLowerCase())).map((y,ee)=>e.jsxs(st,{onClick:()=>Ie(y),sx:mt,children:[y.icon==="wifi"&&e.jsx(G,{children:e.jsx(tt,{style:xe})}),y.icon==="ble"&&e.jsx(G,{children:e.jsx(at,{style:xe})}),y.icon==="hub"&&e.jsx(G,{children:e.jsx(lt,{style:xe})}),e.jsx(te,{primary:y.name,secondary:y.serial,primaryTypographyProps:{style:ht},secondaryTypographyProps:{style:ft}})]},ee))})]}),e.jsx(Oe,{children:e.jsx(ie,{onClick:de,children:"Close"})})]}),e.jsxs(Ne,{open:le,onClose:X,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx($e,{children:"Select an entity"}),e.jsxs(Le,{children:[e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(me,{fullWidth:!0,variant:"outlined",value:m,onChange:ve,placeholder:"Enter name or description"})]}),e.jsx(Xe,{dense:!0,children:Mt.filter(y=>y.name.toLowerCase().includes(m.toLowerCase())||y.description.toLowerCase().includes(m.toLowerCase())).map((y,ee)=>e.jsxs(st,{onClick:()=>De(y),sx:mt,children:[y.icon==="wifi"&&e.jsx(G,{children:e.jsx(tt,{style:xe})}),y.icon==="ble"&&e.jsx(G,{children:e.jsx(at,{style:xe})}),y.icon==="hub"&&e.jsx(G,{children:e.jsx(lt,{style:xe})}),y.icon==="component"&&e.jsx(G,{children:e.jsx(Ht,{style:xe})}),y.icon==="matter"&&e.jsx(G,{children:e.jsx(Ot,{style:xe})}),e.jsx(te,{primary:y.name,secondary:y.description,primaryTypographyProps:{style:ht},secondaryTypographyProps:{style:ft}})]},ee))})]}),e.jsx(Oe,{children:e.jsx(ie,{onClick:X,children:"Close"})})]}),e.jsxs(Ne,{open:B,onClose:oe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs($e,{children:["Select an entity for ",Z]}),e.jsx(Le,{children:e.jsx(Xe,{dense:!0,children:Qe.filter(y=>y.serial===Z||y.name===Z).map(y=>y.entities?.map((ee,we)=>e.jsxs(st,{onClick:()=>Ye(ee),sx:mt,children:[ee.icon==="wifi"&&e.jsx(G,{children:e.jsx(tt,{style:xe})}),ee.icon==="ble"&&e.jsx(G,{children:e.jsx(at,{style:xe})}),ee.icon==="hub"&&e.jsx(G,{children:e.jsx(lt,{style:xe})}),ee.icon==="component"&&e.jsx(G,{children:e.jsx(Ht,{style:xe})}),ee.icon==="matter"&&e.jsx(G,{children:e.jsx(Ot,{style:xe})}),e.jsx(te,{primary:ee.name,secondary:ee.description,primaryTypographyProps:{style:ht},secondaryTypographyProps:{style:ft}})]},we)))})}),e.jsx(Oe,{children:e.jsx(ie,{onClick:oe,children:"Close"})})]})]})}function be(I){const{onAddClick:M,schema:W,properties:q,title:Z,description:ue}=I,[ae,le]=r.useState(!1),[ge,B]=r.useState(""),U=X=>{B(X.target.value)},m=()=>{le(!ae)},he=X=>{o&&console.log(`ObjectFieldTemplate: handleSelectValue value "${X.serial}" for schema "${W.selectFrom}"`),le(!1);let oe="";W.selectFrom==="serial"?oe=X.serial:W.selectFrom==="name"&&(oe=X.name),V(oe),o&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${oe}"`),M(W)()},ve=()=>{M(W)()},de=!W.additionalProperties;return o&&console.log(`ObjectFieldTemplate: isRoot ${de} newkey "${f}"`),!de&&f!==""&&(o&&console.log("ObjectFieldTemplate: newkey",f,"properties",q),q.forEach(X=>{if(X.name==="newKey"&&X.content.key==="newKey"&&X.content.props.name==="newKey"&&X.content.props.onKeyChange&&f!==""){o&&console.log("ObjectFieldTemplate: newkey onKeyChange",f);const oe=f;V(""),X.content.props.onKeyChange(oe)}})),e.jsxs(Y,{sx:{margin:"0px",padding:de?"10px":"5px 10px 0px 10px",border:de?"none":"1px solid grey"},children:[W.title&&de&&e.jsx(Y,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(se,{sx:Be,children:W.title})}),Z&&!de&&e.jsxs(Y,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(se,{sx:Be,children:Z}),e.jsxs(Y,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[W.selectFrom&&e.jsx(R,{title:"Add a device from the list",children:e.jsx(K,{onClick:m,size:"small",color:"primary",sx:Fe,children:e.jsx(it,{})})}),e.jsx(R,{title:"Add a new item",children:e.jsx(K,{onClick:ve,size:"small",color:"primary",sx:Fe,children:e.jsx(xt,{})})})]})]}),W.description&&e.jsx(Y,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(se,{sx:Ue,children:W.description})}),q.map(({content:X,name:oe,hidden:Ie})=>!Ie&&e.jsxs(Y,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(W.properties[oe].type)?"0px":cn,border:["object","array","boolean"].includes(W.properties[oe].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(W.properties[oe].type)&&e.jsx(se,{sx:Be,children:oe}),e.jsx(Y,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:X})]},oe)),e.jsxs(Ne,{open:ae,onClose:m,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx($e,{children:"Select a device"}),e.jsxs(Le,{children:[e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(me,{fullWidth:!0,variant:"outlined",value:ge,onChange:U,placeholder:"Enter serial or name"})]}),e.jsx(Xe,{dense:!0,children:Qe.filter(X=>X.serial.toLowerCase().includes(ge.toLowerCase())||X.name.toLowerCase().includes(ge.toLowerCase())).map((X,oe)=>e.jsxs(st,{onClick:()=>he(X),sx:mt,children:[X.icon==="wifi"&&e.jsx(G,{children:e.jsx(tt,{style:xe})}),X.icon==="ble"&&e.jsx(G,{children:e.jsx(at,{style:xe})}),X.icon==="hub"&&e.jsx(G,{children:e.jsx(lt,{style:xe})}),e.jsx(te,{primary:X.name,secondary:X.serial,primaryTypographyProps:{style:ht},secondaryTypographyProps:{style:ft}})]},oe))})]}),e.jsx(Oe,{children:e.jsx(ie,{onClick:m,children:"Close"})})]})]})}function ne(I){const{uiSchema:M}=I,{submitText:W,norender:q}=zo(M);return q?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(ie,{type:"submit",variant:"contained",color:"primary",children:W}),e.jsx(ie,{variant:"contained",color:"primary",onClick:c,children:"Cancel"})]})}function Ce(I){const{className:M,disabled:W,onClick:q,registry:Z,style:ue,uiSchema:ae,...le}=I;return e.jsx(R,{title:"Remove the item",children:e.jsx(K,{disabled:W,size:"small",color:"primary",onClick:q,children:e.jsx(yt,{})})})}function J(I){const{className:M,disabled:W,onClick:q,registry:Z,uiSchema:ue,...ae}=I;return e.jsx(R,{title:"Add an item",children:e.jsx(K,{size:"small",color:"primary",onClick:q,children:e.jsx(xt,{})})})}function z(I){const{disabled:M,onClick:W,registry:q,style:Z,uiSchema:ue,...ae}=I;return e.jsx(R,{title:"Move up the item",children:e.jsx(K,{size:"small",color:"primary",onClick:W,children:e.jsx(Rt,{})})})}function w(I){const{disabled:M,onClick:W,registry:q,style:Z,uiSchema:ue,...ae}=I;return e.jsx(R,{title:"Move down the item",children:e.jsx(K,{size:"small",color:"primary",onClick:W,children:e.jsx(Tt,{})})})}function A(I){const{id:M,name:W,value:q,schema:Z,readonly:ue,onChange:ae}=I,[le,ge]=r.useState(),B=m=>{o&&console.log(`CheckboxWidget ${W} onChangeField:`,m),ge(m&&m!==""?m:void 0)},U=()=>{o&&console.log(`CheckboxWidget onClick plugin="${l.name}" action="${W}" value="${le}"`),s({id:t.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name,action:W,value:le,formData:O,id:M}}),Z.buttonClose===!0?c():Z.buttonSave===!0&&j({formData:S})};return Z.buttonText&&Z.description?e.jsxs(Y,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(se,{sx:Ue,children:Z.description}),e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>U(),children:Z.buttonText})]}):Z.buttonField&&Z.description?e.jsxs(Y,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(se,{sx:Ue,children:Z.description}),e.jsx(me,{id:W+"-input",name:W,label:Z.textLabel,placeholder:Z.textPlaceholder,onChange:m=>B(m.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(ie,{id:W+"-button",variant:"contained",color:"primary",disabled:le===void 0,onClick:()=>U(),children:Z.buttonField})]}):e.jsxs(Y,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[W&&e.jsxs(Y,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(se,{sx:Be,children:W}),e.jsx(Ee,{checked:q,readOnly:ue,onChange:()=>ae(!q),sx:{padding:"0px",margin:"0px"}})]}),Z.description&&e.jsx(se,{sx:Ue,children:Z.description})]})}function P({schema:I,id:M,name:W,options:q,label:Z,hideLabel:ue,required:ae,disabled:le,placeholder:ge,readonly:B,value:U,multiple:m,autofocus:he,onChange:ve,onBlur:de,onFocus:X,errorSchema:oe,rawErrors:Ie=[],registry:De,uiSchema:Ye,hideError:y,formContext:ee,...we}){const{enumOptions:Te,enumDisabled:ot,emptyValue:Se}=q;m=typeof m>"u"?!1:!!m;const $t=m?[]:"",Lt=typeof U>"u"||m&&U.length<1||!m&&U===$t,ar=({target:{value:We}})=>ve(kt(We,Te,Se)),lr=({target:We})=>de(M,kt(We&&We.value,Te,Se)),dr=({target:We})=>X(M,kt(We&&We.value,Te,Se)),Wt=Ao(U,Te,m),{InputLabelProps:cr,SelectProps:ur,autocomplete:pr,...gr}=we,mr=!m&&I.default===void 0;return e.jsxs(me,{id:M,name:M,value:!Lt&&typeof Wt<"u"?Wt:$t,required:ae,disabled:le||B,autoFocus:he,autoComplete:pr,placeholder:ge,error:Ie.length>0,onChange:ar,onBlur:lr,onFocus:dr,...gr,select:!0,InputLabelProps:{...cr,shrink:!Lt},SelectProps:{...ur,multiple:m},"aria-describedby":qo(M),children:[mr&&e.jsx(L,{value:"",children:ge}),Array.isArray(Te)&&Te.map(({value:We,label:hr},Ft)=>{const fr=Array.isArray(ot)&&ot.indexOf(We)!==-1;return e.jsx(L,{value:String(Ft),disabled:fr,children:hr},Ft)})]})}return o&&console.log("ConfigPluginDialog rendering..."),!n||!C||!S?null:e.jsxs(Ne,{open:n,onClose:c,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx($e,{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(Le,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Eo,{schema:C,formData:S,uiSchema:E,validator:_o,templates:{FieldTemplate:_,BaseInputTemplate:i,TitleFieldTemplate:v,DescriptionFieldTemplate:F,FieldHelpTemplate:H,FieldErrorTemplate:d,ErrorListTemplate:b,WrapIfAdditionalTemplate:$,ArrayFieldTitleTemplate:u,ArrayFieldDescriptionTemplate:g,ArrayFieldItemTemplate:T,ArrayFieldTemplate:ce,ObjectFieldTemplate:be,ButtonTemplates:{SubmitButton:ne,RemoveButton:Ce,AddButton:J,MoveUpButton:z,MoveDownButton:w}},widgets:{CheckboxWidget:A,SelectWidget:P},onChange:x,onSubmit:j})})]})};function or(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 c=0,l=0;for(const s of n.sessionInformations??[])s.fabric&&s.isPeerActive===!0&&c++,s.numberOfActiveSubscriptions>0&&(l+=s.numberOfActiveSubscriptions);return n.commissioned===!0&&n.fabricInformations&&n.sessionInformations&&(c===0||l===0)?"var(--secondary-color)":"var(--div-text-color)"}function pn(n,c,l){const s=n?.[l],a=c?.[l];return s==null&&a==null?0:s==null?-1:a==null?1:typeof s=="boolean"&&typeof a=="boolean"?s===a?0:s?1:-1:typeof s=="number"&&typeof a=="number"?s-a:String(s).localeCompare(String(a))}function gn({name:n,title:c,columns:l,rows:s,getRowKey:a,footerLeft:p,footerRight:h,onRowClick:t}){const S=r.useRef(new WeakMap),N=r.useRef(1),C=d=>{if(typeof a=="string"&&d&&d[a]!=null)return d[a];if(typeof a=="function"){const g=a(d);if(g!=null)return g}const i=l?.[0]?.id;if(i&&d&&d[i]!=null)return d[i];console.warn(`MbfTable(${n}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let u=S.current.get(d);return u||(u=`rk_${N.current++}`,S.current.set(d,u)),u},[k,E]=r.useState(localStorage.getItem(`${n}_table_order_by`)||null),[D,f]=r.useState(localStorage.getItem(`${n}_table_order`)||null),[V,O]=r.useState(!1),[x,j]=r.useState(()=>{try{const d=localStorage.getItem(`${n}_column_visibility`);if(d)return JSON.parse(d)}catch{}return{}}),$=r.useMemo(()=>{const d={};for(const i of l)i.hidden||(d[i.id]=i.required?!0:x[i.id]!==!1);return d},[l,x]),_=r.useMemo(()=>{if(!k||!D)return s;const d=l.find(u=>u.id===k);if(!d||d.noSort)return s;const i=s.map((u,g)=>({el:u,index:g}));return i.sort((u,g)=>{let T;return typeof d.comparator=="function"?T=d.comparator(u.el,g.el):T=pn(u.el,g.el,k),T!==0?D==="asc"?T:-T:u.index-g.index}),i.map(u=>u.el)},[s,k,D,l]),F=d=>{if(k!==d||!k){E(d),f("asc"),localStorage.setItem(`${n}_table_order_by`,d),localStorage.setItem(`${n}_table_order`,"asc");return}if(D==="asc"){f("desc"),localStorage.setItem(`${n}_table_order`,"desc");return}E(null),f(null),localStorage.removeItem(`${n}_table_order_by`),localStorage.removeItem(`${n}_table_order`)},v=()=>{O(!V)},H=d=>{j(i=>{const u=l.find(ce=>ce.id===d);if(u&&u.required)return i;const g=$[d]!==!1,T={...i};g?T[d]=!1:delete T[d];try{localStorage.setItem(`${n}_column_visibility`,JSON.stringify(T))}catch{}return T})},b=()=>{j({});try{localStorage.removeItem(`${n}_column_visibility`)}catch{}O(!1)};return o&&console.log(`Rendering table ${n}${k&&D?` ordered by ${k}:${D}`:""}`),e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",height:"100%",minHeight:0,overflow:"hidden"},children:[e.jsxs(Ne,{open:V,onClose:(d,i)=>{i==="backdropClick"||i==="escapeKeyDown"||v()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx($e,{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(Le,{children:e.jsx($r,{children:l.filter(d=>!d.hidden).map(d=>e.jsx(Ve,{control:e.jsx(Ee,{disabled:!!d.required,checked:d.required?!0:$[d.id]!==!1,onChange:()=>H(d.id)}),label:d.label},d.id))})}),e.jsxs(Oe,{children:[e.jsx(ie,{onClick:b,children:"Reset"}),e.jsx(ie,{variant:"contained",onClick:d=>{if(d?.currentTarget&&typeof d.currentTarget.blur=="function")try{d.currentTarget.blur()}catch{}const i=document.activeElement;if(i&&i instanceof HTMLElement&&typeof i.blur=="function")try{i.blur()}catch{}v()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:n}),c&&e.jsx("p",{className:"MbfWindowHeaderText",children:c}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(K,{onClick:d=>{if(d?.currentTarget?.blur)try{d.currentTarget.blur()}catch{}v()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(R,{title:`Configure ${n} columns`,children:e.jsx(re,{path:bo,size:"20px",color:"var(--header-text-color)"})})})})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${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(d=>{if(d.hidden||!d.required&&$[d.id]===!1)return null;const i=!d.noSort,u=i&&k===d.id&&!!D;return e.jsxs("th",{onClick:i?()=>F(d.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:d.minWidth,maxWidth:d.maxWidth,textAlign:d.align||"left",cursor:i?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:d.maxWidth?"nowrap":void 0,overflow:d.maxWidth?"hidden":void 0,textOverflow:d.maxWidth?"ellipsis":void 0},"aria-sort":i?u?D==="asc"?"ascending":"descending":"none":void 0,children:[d.label,u&&e.jsxs("span",{style:{marginLeft:6},children:[D==="asc"&&e.jsx(re,{path:vo,size:"15px"}),D==="desc"&&e.jsx(re,{path:yo,size:"15px"})]})]},d.id)})})}),e.jsx("tbody",{children:_.map((d,i)=>{const u=C(d);return e.jsx("tr",{className:i%2===0?"table-content-even":"table-content-odd",onClick:t?g=>t(d,u,g):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:t?"pointer":void 0},children:l.map(g=>{if(g.hidden||!g.required&&$[g.id]===!1)return null;const T=d[g.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:g.align||"left",padding:"5px 10px",margin:"0",maxWidth:g.maxWidth,whiteSpace:g.maxWidth?"nowrap":void 0,overflow:g.maxWidth?"hidden":void 0,textOverflow:g.maxWidth?"ellipsis":void 0},children:typeof g.render=="function"?g.render(T,u,d,g):typeof T=="boolean"?e.jsx(Ee,{checked:T,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):g.format&&typeof T=="number"?g.format(T):T!=null?String(T):null},g.id)})},u)})})]})}),(p||h)&&e.jsxs("div",{className:"MbfWindowFooter",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:p}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:h})]})]})}function mn(n){return r.memo(n)}const Ct=mn(gn);function hn({storeId:n,setStoreId:c}){const{online:l,sendMessage:s,addListener:a,removeListener:p,getUniqueId:h}=r.useContext(fe),{showConfirmCancelDialog:t}=r.useContext(_e),S=r.useRef(h()),[N,C]=r.useState(null),[k,E]=r.useState(null),[D,f]=r.useState([]),V=[{label:"Name",id:"name",required:!0,render:(w,A,P,I)=>e.jsx(R,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>d(P),children:P.name})})},{label:"Description",id:"description",render:(w,A,P,I)=>e.jsx(R,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>d(P),children:P.description})})},{label:"Version",id:"version",render:(w,A,P,I)=>e.jsxs(e.Fragment,{children:[P.latestVersion!==void 0&&P.latestVersion!==P.version&&k&&!k.readOnly&&e.jsx(R,{title:"New plugin stable version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>_(P),children:["Update to v.",P.latestVersion]})}),P.version.includes("-dev-")&&P.devVersion!==void 0&&P.devVersion!==P.version&&k&&!k.readOnly&&e.jsx(R,{title:"New plugin dev version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>F(P),children:["Update to new dev v.",P.devVersion.split("-dev-")[0]]})}),e.jsx(R,{title:"Plugin version",children:e.jsx("span",{children:P.version})})]})},{label:"Author",id:"author",render:(w,A,P,I)=>e.jsx(e.Fragment,{children:P.author?P.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(w,A,P,I)=>e.jsx(e.Fragment,{children:P.type?P.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(w,A,P,I)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[k&&k.bridgeMode==="childbridge"&&!P.error&&P.enabled&&e.jsx(R,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:or(P.matter)},onClick:()=>{P.matter?.id&&c(P.matter?.id)},size:"small",children:e.jsx(Jt,{})})}),k&&k.bridgeMode==="childbridge"&&!P.error&&P.enabled&&e.jsx(R,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>H(P),size:"small",children:e.jsx(bt,{})})}),e.jsx(R,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{disabled:P.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>Ce(P),size:"small",children:e.jsx(Nt,{})})}),k&&!k.readOnly&&e.jsx(R,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{x("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",P)},size:"small",children:e.jsx(yt,{})})}),P.enabled?e.jsx(R,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{x("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",P)},size:"small",children:e.jsx(Lr,{})})}):e.jsx(e.Fragment,{}),P.enabled?e.jsx(e.Fragment,{}):e.jsx(R,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>b(P),size:"small",children:e.jsx(Wr,{})})}),e.jsx(R,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>u(P),size:"small",children:e.jsx(Fr,{})})}),e.jsx(R,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>g(P),size:"small",children:e.jsx(Tr,{})})}),k&&!k.readOnly&&e.jsx(R,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>i(P),size:"small",children:e.jsx(Zt,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(w,A,P,I)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:P.error?e.jsx(e.Fragment,{children:e.jsx(ze,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:P.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(ze,{status:P.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:P.loaded&&P.started&&P.configured?e.jsx(e.Fragment,{children:e.jsx(ze,{status:P.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(ze,{status:P.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(ze,{status:P.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(ze,{status:P.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const w=A=>{A.src==="Matterbridge"&&A.dst==="Frontend"&&(A.method==="refresh_required"&&A.response.changed==="plugins"&&(o&&console.log(`HomePlugins received refresh_required: changed=${A.response.changed} and sending /api/plugins request`),s({id:S.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),A.method==="refresh_required"&&A.response.changed==="matter"&&(o&&console.log(`HomePlugins received refresh_required: changed=${A.response.changed} and setting matter id ${A.response.matter?.id}`),f(P=>{const I=P.findIndex(W=>W.matter?.id===A.response.matter?.id);if(I<0)return o&&console.log(`HomePlugins received refresh_required: changed=${A.response.changed} and matter id ${A.response.matter?.id} not found`),P;o&&console.log(`HomePlugins received refresh_required: changed=${A.response.changed} set matter id ${A.response.matter?.id}`);const M=[...P];return M[I]={...M[I],matter:A.response.matter},M})),A.method==="refresh_required"&&A.response.changed==="settings"&&(o&&console.log(`HomePlugins received refresh_required: changed=${A.response.changed} and sending /api/settings request`),s({id:S.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),A.id===S.current&&A.method==="/api/settings"&&(o&&console.log(`HomePlugins (id: ${A.id}) received settings:`,A.response),C(A.response.systemInformation),E(A.response.matterbridgeInformation)),A.id===S.current&&A.method==="/api/plugins"&&(o&&console.log(`HomePlugins (id: ${A.id}) received ${A.response.length} plugins:`,A.response),f(A.response)))};return a(w,S.current),o&&console.log("HomePlugins added WebSocket listener id:",S.current),()=>{p(w),o&&console.log("HomePlugins removed WebSocket listener")}},[a,p,s]),r.useEffect(()=>{l&&(o&&console.log("HomePlugins sending api requests"),s({id:S.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),s({id:S.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,s]);const O=r.useRef(null),x=(w,A,P,I)=>{o&&console.log(`handleActionWithConfirmCancel ${P} ${I.name}`),O.current=I,t(w,A,P,j,$)},j=w=>{o&&console.log(`handleConfirm action confirmed ${w} ${O.current?.name}`),w==="remove"&&O.current?v(O.current):w==="disable"&&O.current&&b(O.current),O.current=null},$=w=>{o&&console.log(`handleCancel action canceled ${w} ${O.current?.name}`),O.current=null},_=w=>{o&&console.log("handleUpdatePlugin plugin:",w.name),s({id:S.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:w.name,restart:!1}})},F=w=>{o&&console.log("handleUpdateDevPlugin plugin:",w.name),s({id:S.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:w.name+"@dev",restart:!1}})},v=w=>{o&&console.log("handleRemovePlugin plugin:",w.name),s({id:S.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:w.name}})},H=w=>{o&&console.log("handleRestartPlugin plugin:",w.name),s({id:S.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:w.name}})},b=w=>{o&&console.log("handleEnableDisablePlugin plugin:",w.name,"enabled:",w.enabled),w.enabled===!0?(w.enabled=!1,s({id:S.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:w.name}})):(w.enabled=!0,s({id:S.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:w.name}}))},d=w=>{o&&console.log(`handleHomepagePlugin plugin: ${w.name} homepage: ${w.homepage}`),w.homepage&&window.open(w.homepage,"_blank")},i=w=>{o&&console.log("handleSponsorPlugin plugin:",w.name,"funding:",w.funding),w.funding&&window.open(w.funding,"_blank")},u=w=>{o&&console.log("handleHelpPlugin plugin:",w.name,"help:",w.help),w.help&&window.open(w.help,"_blank")},g=w=>{o&&console.log("handleChangelogPlugin plugin:",w.name,"changelog:",w.changelog),w.changelog&&window.open(w.changelog,"_blank")},[T,ce]=r.useState(),[be,ne]=r.useState(!1),Ce=w=>{o&&console.log("handleConfigPlugin plugin:",w.name),s({id:S.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:w.name}}),s({id:S.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:w.name}}),ce(w),J()},J=()=>{ne(!0)},z=()=>{ne(!1)};return o&&console.log("HomePlugins rendering..."),l?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"0 0 auto",overflow:"hidden"},children:[T&&e.jsx(un,{open:be,onClose:z,plugin:T}),e.jsx(Ct,{name:"Plugins",columns:V,rows:D,footerRight:"",footerLeft:""})]}):e.jsx(Me,{})}const fn=r.memo(hn),xn=n=>`${n.pluginName}::${n.serial}`;function bn({storeId:n,setStoreId:c}){const{online:l,sendMessage:s,addListener:a,removeListener:p,getUniqueId:h}=r.useContext(fe),[t,S]=r.useState(!1),[N,C]=r.useState(!0),[k,E]=r.useState(null),[D,f]=r.useState([]),[V,O]=r.useState([]),[x,j]=r.useState([]),[$,_]=r.useState([]),F=r.useRef(h()),v=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(d,i,u,g)=>u.reachable===!0?"Online":u.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(d,i)=>{const u=d.reachable===!0?1:d.reachable===!1?0:-1,g=i.reachable===!0?1:i.reachable===!1?0:-1;return u-g}},{label:"Power",id:"powerSource",render:(d,i,u,g)=>u.powerSource==="ac"||u.powerSource==="dc"?e.jsx(Yt,{fontSize:"small",sx:{color:"var(--primary-color)"}}):u.powerSource==="ok"?e.jsx(vt,{fontSize:"small",sx:{color:"green"}}):u.powerSource==="warning"?e.jsx(vt,{fontSize:"small",sx:{color:"yellow"}}):u.powerSource==="critical"?e.jsx(vt,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Url",id:"configUrl"},{label:"Actions",id:"selected",required:!0,render:(d,i,u,g)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[u.matter!==void 0?e.jsx(R,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{onClick:()=>c(n===u.matter?.id?k?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:u.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:or(u.matter)},children:e.jsx(Jt,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),u.configUrl?e.jsx(R,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{onClick:()=>window.open(u.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(Nt,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),u.selected!==void 0?e.jsx(R,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Ee,{checked:u.selected,onChange:T=>b(T,u),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],H=r.useCallback(d=>{d.selected=void 0;const i=D.find(T=>T.name===d.pluginName);if(!i)return console.error(`HomeDevices isSelected: plugin ${d.pluginName} not found for device ${d.name} `),d.selected;const u=i.schemaJson?.properties?.whiteList?.selectFrom;let g=i.configJson.postfix;return g===""&&(g=void 0),i.hasWhiteList===!0&&i.hasBlackList===!0&&u&&(d.selected=!0,u==="serial"&&i.configJson.whiteList&&i.configJson.whiteList.length>0&&i.configJson.whiteList.includes(g?d.serial.replace("-"+g,""):d.serial)&&(d.selected=!0),u==="serial"&&i.configJson.whiteList&&i.configJson.whiteList.length>0&&!i.configJson.whiteList.includes(g?d.serial.replace("-"+g,""):d.serial)&&(d.selected=!1),u==="serial"&&i.configJson.blackList&&i.configJson.blackList.length>0&&i.configJson.blackList.includes(g?d.serial.replace("-"+g,""):d.serial)&&(d.selected=!1),u==="name"&&i.configJson.whiteList&&i.configJson.whiteList.length>0&&i.configJson.whiteList.includes(d.name)&&(d.selected=!0),u==="name"&&i.configJson.whiteList&&i.configJson.whiteList.length>0&&!i.configJson.whiteList.includes(d.name)&&(d.selected=!1),u==="name"&&i.configJson.blackList&&i.configJson.blackList.length>0&&i.configJson.blackList.includes(d.name)&&(d.selected=!1)),d.selected},[D]);r.useEffect(()=>{const d=i=>{if(i.method==="refresh_required"&&i.response.changed!=="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${i.response.changed} and sending /api/plugins request`),s({id:F.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):i.method==="refresh_required"&&i.response.changed==="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${i.response.changed} and setting matter id ${i.response.matter?.id}`),_(u=>{const g=u.findIndex(ce=>ce.name.replaceAll(" ","")===i.response.matter?.id);if(g<0)return o&&console.debug(`HomeDevices: matter id ${i.response.matter?.id} not found`),u;const T=[...u];return T[g]={...T[g],matter:i.response.matter},o&&console.log(`HomeDevices received refresh_required: changed=${i.response.changed} and set matter id ${i.response.matter?.id}`),T})):i.method==="restart_required"?(o&&console.log("HomeDevices received restart_required"),S(!0)):i.method==="restart_not_required"?(o&&console.log("HomeDevices received restart_not_required"),S(!1)):i.method==="state_update"&&i.response.plugin&&i.response.serialNumber&&i.response.cluster.includes("BasicInformation")&&i.response.attribute==="reachable"&&(o&&console.log(`HomeDevices updating device reachability for plugin ${i.response.plugin} serial ${i.response.serialNumber} value ${i.response.value}`),O(u=>{const g=u.findIndex(T=>T.pluginName===i.response.plugin&&T.serial===i.response.serialNumber);return g<0?(o&&console.warn(`HomeDevices: device to update not found for plugin ${i.response.plugin} serial ${i.response.serialNumber}`),u):(u[g]={...u[g],reachable:i.response.value},[...u])})),i.id===F.current&&i.method==="/api/settings")o&&console.log(`HomeDevices (id: ${i.id}) received settings:`,i.response),E(i.response),S(i.response.matterbridgeInformation.restartRequired||i.response.matterbridgeInformation.fixedRestartRequired);else if(i.id===F.current&&i.method==="/api/plugins"){if(o&&console.log(`HomeDevices (id: ${i.id}) received ${i.response?.length} plugins:`,i.response),i.response){let u=!0;for(const g of i.response)g.enabled===!0&&(g.loaded!==!0||g.started!==!0||g.error===!0)&&(u=!1);if(!u)return;o&&console.log("HomeDevices reset plugins, devices and selectDevices"),C(!1),f(i.response),O([]),j([]),s({id:F.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),o&&console.log("HomeDevices sent /api/devices");for(const g of i.response)g.enabled===!0&&g.loaded===!0&&g.started===!0&&g.error!==!0&&(s({id:F.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:g.name}}),o&&console.log(`HomeDevices sent /api/select/devices for plugin: ${g.name}`))}}else if(i.id===F.current&&i.method==="/api/devices"){if(o&&console.log(`HomeDevices (id: ${i.id}) received ${i.response?.length} devices:`,i.response),i.response){for(const u of i.response)u.selected=H(u);O(i.response)}}else i.id===F.current&&i.method==="/api/select/devices"&&(o&&console.log(`HomeDevices (id: ${i.id}) received ${i.response?.length} selectDevices for plugin ${i.response&&i.response.length>0?i.response[0].pluginName:"without select devices"}:`,i.response),i.response&&i.response.length>0&&j(u=>{const g=u.filter(ce=>ce.pluginName!==i.response[0].pluginName),T=i.response.map(ce=>({...ce,selected:H(ce)}));return[...g,...T]}))};return a(d,F.current),o&&console.log(`HomeDevices added WebSocket listener id ${F.current}`),()=>{p(d),o&&console.log("HomeDevices removed WebSocket listener")}},[D,a,p,s,H]),r.useEffect(()=>{if(V.length===0&&x.length===0){_([]);return}o&&console.log(`HomeDevices mixing devices (${V.length}) and selectDevices (${x.length})`);const d=[];for(const i of V)d.push(i);for(const i of x)V.find(u=>u.pluginName===i.pluginName&&u.serial.includes(i.serial))||d.push(i);d.length>0&&(_(d),o&&console.log(`HomeDevices mixed ${d.length} devices and selectDevices`))},[D,V,x,_]),r.useEffect(()=>{l&&(o&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),s({id:F.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),s({id:F.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,s]);const b=(d,i)=>{o&&console.log(`handleCheckboxChange: checkbox changed to ${d.target.checked} for device ${i.name} serial ${i.serial}`),V.findIndex(u=>u.pluginName===i.pluginName&&u.serial===i.serial)<0?(o&&console.warn(`handleCheckboxChange: device ${i.name} serial ${i.serial} not found in devices, trying in mixedDevices`),_(u=>{const g=u.findIndex(T=>T.pluginName===i.pluginName&&T.serial===i.serial);return g<0?(console.error(`handleCheckboxChange: device ${i.name} serial ${i.serial} not found in mixedDevices`),u):(u[g]={...u[g],selected:d.target.checked},[...u])})):O(u=>{const g=u.findIndex(T=>T.pluginName===i.pluginName&&T.serial===i.serial);return g<0?(console.error(`handleCheckboxChange: device ${i.name} serial ${i.serial} not found in devices`),u):(u[g]={...u[g],selected:d.target.checked},[...u])}),d.target.checked?s({id:F.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:i.pluginName,serial:i.serial,name:i.name}}):s({id:F.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:i.pluginName,serial:i.serial,name:i.name}})};return o&&console.log("HomeDevices rendering..."),l?e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Ct,{name:"Devices",getRowKey:xn,rows:$,columns:v,footerLeft:N?"Waiting for the plugins to fully load...":`Registered devices: ${V.length.toString()}/${$.length.toString()}`,footerRight:t?"Restart required":""})}):e.jsx(Me,{})}const vn=r.memo(bn);function wt({children:n,style:c,name:l}){const{setCurrentPage:s}=r.useContext(_e);s(l),o&&console.log(`MbfPage: current page set to ${l}`);const a={display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"20px"};return e.jsx("div",{style:{...a,...c},children:n})}const yn=()=>"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 jn(){const{messages:n,autoScroll:c}=r.useContext(rr),[l,s]=r.useState(!1),a=r.useRef(null),p=r.useMemo(()=>yn(),[]),h=C=>s(!0),t=C=>s(!1);r.useEffect(()=>{o&&console.log(`WebSocketLogs autoScroll: ${c} isHovering: ${l}`),c&&!l&&!p&&a.current?.scrollIntoView({behavior:"smooth"})},[n,l,c,p]);const S=C=>{switch(C.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"}},N=C=>{switch(C.toLowerCase()){case"warn":return"black";default:return"white"}};return e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:h,onMouseLeave:t,children:[n.map((C,k)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:S(C.level),color:N(C.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:C.level}),C.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+C.time+"]"}),C.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+C.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:C.message})]},k)),e.jsx("div",{ref:a})]})})}const nr=r.memo(jn);function Cn(){const{logFilterLevel:n,logFilterSearch:c,autoScroll:l,online:s}=r.useContext(fe);return o&&console.log("HomeLogs rendering..."),s?e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"1 1 auto",width:"100%",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:"Logs"}),e.jsx("div",{className:"MbfWindowHeaderText",style:{display:"flex",justifyContent:"space-between"},children:e.jsxs("span",{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',n,'" and search "',c,'" Scroll: ',l?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(nr,{})})]}):e.jsx(Me,{})}const wn=r.memo(Cn);function Sn(){const{online:n}=r.useContext(fe);return o&&console.log("HomeBrowserRefresh rendering..."),n?e.jsxs(ke,{children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Frontend Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(ie,{onClick:()=>window.location.reload(),endIcon:e.jsx(Rr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}):e.jsx(Me,{})}const kn=r.memo(Sn);function Mn({changelog:n}){const{online:c}=r.useContext(fe);return o&&console.log("HomeShowChangelog rendering..."),c?e.jsxs(ke,{children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{children:[e.jsx(ie,{onClick:()=>window.open(n,"_blank"),endIcon:e.jsx(Xt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(ie,{onClick:()=>window.location.reload(),endIcon:e.jsx(Hr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}):e.jsx(Me,{})}const In=r.memo(Mn);function Dn(){const[n,c]=r.useState(null),[l,s]=r.useState(null),[a,p]=r.useState([]),[h]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[t,S]=r.useState(localStorage.getItem("homePageMode")??"devices"),[N,C]=r.useState(""),[k,E]=r.useState(!1),[D,f]=r.useState(!1),[V,O]=r.useState(null),{addListener:x,removeListener:j,online:$,sendMessage:_,getUniqueId:F}=r.useContext(fe),v=r.useRef(F());return r.useEffect(()=>{const H=b=>{b.method==="refresh_required"&&b.response.changed==="settings"&&(o&&console.log(`Home received refresh_required: changed=${b.response.changed} and sending /api/settings request`),O(null),p([]),_({id:v.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),_({id:v.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),b.method==="/api/settings"&&b.id===v.current&&(o&&console.log("Home received settings:",b.response),c(b.response.systemInformation),s(b.response.matterbridgeInformation),b.response.matterbridgeInformation.matterbridgeVersion&&C(`https://github.com/Luligu/matterbridge/blob/${b.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&b.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",b.response.matterbridgeInformation.frontendVersion):b.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&b.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",b.response.matterbridgeInformation.frontendVersion),f(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",b.response.matterbridgeInformation.matterbridgeVersion):b.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",b.response.matterbridgeInformation.matterbridgeVersion),E(!0)),b.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),S("devices")))),b.method==="/api/plugins"&&b.id===v.current&&(o&&console.log("Home received plugins:",b.response),p(b.response))};return x(H,v.current),o&&console.log(`Home added WebSocket listener id ${v.current}`),()=>{j(H),o&&console.log("Home removed WebSocket listener")}},[x,j,_]),r.useEffect(()=>{if(o&&console.log(`Home storeId effect with storeId ${V}`),l?.bridgeMode==="bridge"&&!V&&(o&&console.log("Home storeId effect set storeId to Matterbridge"),O("Matterbridge")),l?.bridgeMode==="childbridge"&&!V&&a){for(const H of a)if(H.matter?.id){o&&console.log(`Home storeId effect set storeId to ${H.matter.id}`),O(H.matter.id);break}}},[l,a,V]),r.useEffect(()=>{$&&(o&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),_({id:v.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),_({id:v.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[$,_]),o&&console.log("Home rendering..."),!$||!n||!l?e.jsx(Me,{}):e.jsxs(wt,{name:"Home",style:{flexDirection:"row"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(nn,{id:V}),e.jsx(tn,{systemInfo:n,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[D&&e.jsx(kn,{}),k&&e.jsx(In,{changelog:N}),h&&!l.readOnly&&e.jsx(an,{}),h&&e.jsx(fn,{storeId:V,setStoreId:O}),t==="devices"&&e.jsx(vn,{storeId:V,setStoreId:O}),t==="logs"&&e.jsx(wn,{})]})]})}const Pn=r.memo(Dn),Gt={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},Nn={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},$n={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Kt={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Ln={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Wn={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},Fn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Tn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},Rn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},It={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},Hn=[256,257,268,269],On=[266,267],Vn=[259,260,261,271,272],En=[256,257,268,269,266,267,259,260,261,272];function Q({icon:n,iconColor:c,cluster:l,value:s,unit:a,prefix:p}){return o&&console.log(`Render cluster "${l.clusterName}.${l.attributeName}" value(${typeof s}-${isNaN(s)}) "${s}" unit "${a}"`),p=p??!1,e.jsxs(Y,{sx:Gt,children:[n&&r.cloneElement(n,{key:`${l.clusterId}-${l.attributeId}-icon`,sx:{...Nn,color:c??"var(--primary-color)"}}),e.jsxs(Y,{sx:{...Gt,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[a&&p===!0&&e.jsx(se,{sx:Kt,children:a},`${l.clusterId}-${l.attributeId}-unit`),e.jsx(se,{sx:$n,children:s==null||typeof s=="number"&&isNaN(s)||s==="NaN"?"---":s},`${l.clusterId}-${l.attributeId}-value`),a&&p===!1&&e.jsx(se,{sx:Kt,children:a},`${l.clusterId}-${l.attributeId}-unit`)]},`${l.clusterId}-${l.attributeId}-valueunitbox`)]},`${l.clusterId}-${l.attributeId}-box`)}function _n({device:n,endpoint:c,id:l,deviceType:s,clusters:a}){const p=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let h="";if(o&&console.log(`Device "${n.name}" endpoint "${c}" id "${l}" deviceType "0x${s.toString(16).padStart(4,"0")}" clusters (${a?.length}):`,a),s===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>h=`${t.attributeLocalValue} mV`),En.includes(s)&&a.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>h=`Level ${t.attributeValue}`),s===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>h=`Position ${t.attributeLocalValue/100}%`),s===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>h=`Heat ${t.attributeLocalValue/100}°C `),s===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>h=h+`Cool ${t.attributeLocalValue/100}°C`),s===118&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>h=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),s===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>h=`${t.attributeLocalValue/1e3} V, `),s===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>h=h+`${t.attributeLocalValue/1e3} A, `),s===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>h=h+`${t.attributeLocalValue/1e3} W`),s===116){const t=a.find(N=>N.clusterName==="RvcRunMode"&&N.attributeName==="currentMode")?.attributeLocalValue;h=a.find(N=>N.clusterName==="RvcRunMode"&&N.attributeName==="supportedModes")?.attributeLocalValue?.find(N=>N.mode===t)?.label||"Unknown"}return e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[s===19&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Q,{icon:t.attributeLocalValue===!0?e.jsx(tt,{}):e.jsx(Or,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),s===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(Q,{icon:e.jsx(vt,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),s===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(Q,{icon:e.jsx(Yt,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),s===1293&&a.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:jo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),Hn.includes(s)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Q,{icon:e.jsx(Vr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),On.includes(s)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Vn.includes(s)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),s===115&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:So,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),s===124&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),s===117&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),s===123&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Q,{icon:e.jsx(Vt,{}),cluster:t,value:"Oven"})),s===112&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Q,{icon:e.jsx(Er,{}),cluster:t,value:"Fridge"})),s===113&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Io,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),s===121&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Q,{icon:e.jsx(Vt,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),s===122&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Do,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),s===120&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:zt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),s===119&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:zt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),s===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(Q,{icon:e.jsx(_r,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),s===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),s===10&&a.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(Q,{icon:t.attributeValue==="1"?e.jsx(Ar,{}):e.jsx(qr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),s===43&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(Q,{icon:e.jsx(zr,{}),cluster:t,value:t.attributeValue,unit:"%"})),s===15&&a.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:No,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),s===39&&a.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(Q,{icon:e.jsx(Br,{}),cluster:t,value:t.attributeValue,unit:"mode",prefix:!0})),s===771&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Q,{icon:e.jsx(Ur,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),s===45&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(Q,{icon:e.jsx(Et,{}),cluster:t,value:t.attributeValue,unit:"%"})),s===114&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(Q,{icon:e.jsx(Et,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),s===67&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Q,{icon:e.jsx(Qr,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),s===65&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Q,{icon:e.jsx(Gr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),s===68&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Q,{icon:e.jsx(Kr,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),s===116&&a.filter(t=>t.clusterName==="RvcRunMode"&&t.attributeName==="currentMode").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:$o,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"Run mode",prefix:!0})),s===1292&&a.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Lo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),s===1295&&a.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),s===777&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),s===23&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:To,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),s===24&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Ro,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),s===118&&a.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Bt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),s===118&&a.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Bt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),s===66&&a.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(Q,{icon:e.jsx(Jr,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),s===44&&a.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:p[t.attributeLocalValue??0]})),s===770&&a.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Q,{icon:e.jsx(Zr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),s===775&&a.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Q,{icon:e.jsx(re,{path:Oo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),s===774&&a.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Q,{icon:e.jsx(Yr,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),s===773&&a.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Q,{icon:e.jsx(Xr,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),s===21&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Q,{icon:t.attributeValue==="true"?e.jsx(eo,{}):e.jsx(to,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),s===263&&a.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(Q,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(ro,{}):e.jsx(oo,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),s===262&&a.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Q,{icon:e.jsx(no,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),s===1296&&a.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(Q,{icon:e.jsx(io,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(Y,{sx:Ln,children:e.jsx(se,{sx:Wn,children:h})}),e.jsx(Y,{sx:Fn,children:e.jsx(se,{sx:Tn,children:n.name})}),e.jsxs(Y,{sx:Rn,children:[o&&e.jsx(se,{sx:It,children:c}),e.jsx(se,{sx:It,children:l}),o&&e.jsxs(se,{sx:It,children:["0x",s.toString(16).padStart(4,"0")]})]})]})}function An({filter:n}){const{online:c,sendMessage:l,addListener:s,removeListener:a,getUniqueId:p}=r.useContext(fe),[h,t]=r.useState(null),[S,N]=r.useState([]),[C,k]=r.useState([]),[E,D]=r.useState(C),[f,V]=r.useState({}),[O,x]=r.useState({}),[j,$]=r.useState({}),_=r.useRef(p()),F=r.useRef(E),v=r.useCallback(b=>{o&&console.log(`DevicesIcons received state_update "${b.response.cluster}.${b.response.attribute}" for "${b.response.id}:${b.response.number}": "${b.response.value}"`,b.response);const d=F.current.find(u=>u.pluginName===b.response.plugin&&u.uniqueId===b.response.uniqueId);if(!d){o&&console.warn(`DevicesIcons updater device of plugin "${b.response.plugin}" serial "${b.response.serialNumber}" not found in filteredDevicesRef.current`);return}const i=j[d.serial].find(u=>u.endpoint===b.response.number.toString()&&u.clusterName===b.response.cluster&&u.attributeName===b.response.attribute);if(!i){o&&console.warn(`DevicesIcons updater device "${d.name}" serial "${d.serial}" cluster "${b.response.cluster}" attribute "${b.response.attribute}" not found in clusters`);return}i.attributeValue=String(b.response.value),i.attributeLocalValue=b.response.value,$({...j}),o&&console.log(`DevicesIcons updated "${i.clusterName}.${i.attributeName}" for device "${d.name}" serial "${d.serial}" to "${i.attributeValue}"`)},[j]);r.useEffect(()=>{const b=d=>{if(d.method==="refresh_required")o&&console.log(`DevicesIcons received refresh_required: changed=${d.response.changed} and sending api requests`),l({id:_.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:_.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:_.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(d.method==="state_update"&&d.response)v(d);else if(d.method==="/api/settings"&&d.response)o&&console.log("DevicesIcons received settings:",d.response),t(d.response);else if(d.method==="/api/plugins"&&d.response)o&&console.log("DevicesIcons received plugins:",d.response),N(d.response);else if(d.method==="/api/devices"&&d.response){o&&console.log(`DevicesIcons received ${d.response.length} devices:`,d.response),k(d.response);for(const i of d.response)o&&console.log("DevicesIcons sending /api/clusters"),l({id:_.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:i.pluginName,endpoint:i.endpoint||0}})}else if(d.method==="/api/clusters"&&d.response){if(o&&console.log(`DevicesIcons received for device "${d.response.deviceName}" serial "${d.response.serialNumber}" deviceTypes (${d.response.deviceTypes.length}) "${d.response.deviceTypes.join(",")}" clusters (${d.response.clusters.length}):`,d.response),d.response.clusters.length===0)return;const i=d.response.serialNumber;f[i]=[],O[i]=d.response.deviceTypes,j[i]=[];for(const u of d.response.clusters)f[i].find(g=>g.endpoint===u.endpoint)||f[i].push({endpoint:u.endpoint,id:u.id,deviceTypes:u.deviceTypes}),!["FixedLabel","Descriptor","Identify","Groups","PowerTopology"].includes(u.clusterName)&&j[i].push(u);V({...f}),x({...O}),$({...j}),o&&console.log(`DevicesIcons endpoints for "${i}":`,f[i]),o&&console.log(`DevicesIcons deviceTypes for "${i}":`,O[i]),o&&console.log(`DevicesIcons clusters for "${i}":`,j[i])}};return s(b,_.current),o&&console.log("DevicesIcons useEffect webSocket mounted"),()=>{a(b),o&&console.log("DevicesIcons useEffect webSocket unmounted")}},[]),r.useEffect(()=>(o&&console.log("DevicesIcons useEffect online mounting"),c&&(o&&console.log("DevicesIcons useEffect online sending api requests"),l({id:_.current,sender:"DevicesIcons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:_.current,sender:"DevicesIcons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:_.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")}),[c,l]),r.useEffect(()=>{if(n===""){D(C),F.current=C;return}const b=C.filter(d=>d.name.toLowerCase().includes(n)||d.serial.toLowerCase().includes(n));D(b),F.current=b},[C,n]);const H=r.memo(_n);return o&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:E.map(b=>f[b.serial]&&f[b.serial].map(d=>d.deviceTypes.map(i=>e.jsx(H,{device:b,endpoint:d.endpoint,id:d.id,deviceType:i,clusters:j[b.serial].filter(u=>u.endpoint===d.endpoint)},`${b.pluginName}-${b.uniqueId}-${d.id}-${i.toString()}`))))})}const qn=r.memo(An),zn=[{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,c,l,s)=>l.configUrl?e.jsx(K,{onClick:()=>window.open(l.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(Nt,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],Bn=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(n,c,l,s)=>Array.isArray(n)?e.jsx(e.Fragment,{children:n.map(a=>`0x${a.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,render:(n,c,l,s)=>e.jsx(R,{title:String(n),componentsProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("div",{style:{maxWidth:"500px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:String(n)})})}],Un=n=>`${n.pluginName}::${n.uniqueId}`,Qn=n=>`${n.endpoint}::${n.clusterName}::${n.attributeName}`;function Gn({filter:n}){const{online:c,sendMessage:l,addListener:s,removeListener:a,getUniqueId:p}=r.useContext(fe),[h,t]=r.useState([]),[S,N]=r.useState(h),[C,k]=r.useState([]),[E,D]=r.useState(0),[f,V]=r.useState(null),[O,x]=r.useState(null),[j,$]=r.useState(null),[_,F]=r.useState(null),v=r.useRef(p()),H=r.useRef(S),b=r.useCallback(i=>{o&&console.log(`DevicesTable received state_update "${i.response.cluster}.${i.response.attribute}" for "${i.response.id}:${i.response.number}": "${i.response.value}"`,i.response);const u=H.current.find(g=>g.pluginName===i.response.plugin&&g.uniqueId===i.response.uniqueId);if(!u){o&&console.warn(`DevicesTable updater device of plugin "${i.response.plugin}" serial "${i.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(f&&O&&u.pluginName===f&&u.uniqueId===_&&i.response.number.toString()===O){const g=C.find(T=>T.endpoint===i.response.number.toString()&&T.clusterName===i.response.cluster&&T.attributeName===i.response.attribute);if(!g){o&&console.warn(`DevicesTable updater cluster ${i.response.cluster}.${i.response.attribute} for device "${u.name}" serial "${u.serial}" not found in clusters`);return}g.attributeValue=String(i.response.value),g.attributeLocalValue=i.response.value,k([...C]),o&&console.log(`DevicesTable updated attribute ${g.clusterName}.${g.attributeName} for device "${u.name}" serial "${u.serial}" to "${g.attributeValue}"`)}},[C,O,f,_]);r.useEffect(()=>{const i=u=>{if(o&&console.log("DevicesTable received WebSocket Message:",u),u.method==="refresh_required"&&u.response.changed==="devices")o&&console.log(`DevicesTable received refresh_required: changed=${u.response.changed} and sending /api/devices request`),l({id:v.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(u.method==="state_update"&&u.response)b(u);else if(u.method==="/api/devices")o&&console.log(`DevicesTable received ${u.response.length} devices:`,u.response),t(u.response);else if(u.method==="/api/clusters"){o&&console.log(`DevicesTable received ${u.response.clusters.length} clusters for plugin ${u.response.plugin}:`,u.response),k(u.response.clusters);const g={};for(const T of u.response.clusters)o&&console.log("Cluster:",T.endpoint),g[T.endpoint]?g[T.endpoint]++:g[T.endpoint]=1;D(Object.keys(g).length)}};return s(i,v.current),o&&console.log("DevicesTable added WebSocket listener"),()=>{a(i),o&&console.log("DevicesTable removed WebSocket listener")}},[l,s,a,b]),r.useEffect(()=>{c&&(o&&console.log("DevicesTable sending api requests with id ",v.current),l({id:v.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:v.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:v.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,l]),r.useEffect(()=>{f&&O&&(o&&console.log("DevicesTable sending /api/clusters"),l({id:v.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:f,endpoint:Number(O)}}))},[f,O,l]),r.useEffect(()=>{if(n===""){N(h),H.current=h;return}const i=h.filter(u=>u.name.toLowerCase().includes(n)||u.serial.toLowerCase().includes(n));N(i),H.current=i},[h,n]);const d=i=>{if(i.uniqueId===_){F(null),V(null),x(null),$(null);return}F(i.uniqueId),V(i.pluginName),x(i.endpoint?i.endpoint.toString():null),$(i.name)};return o&&console.log("DevicesTable rendering..."),c?e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0px",padding:"0px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",maxHeight:`${f&&O?"30%":"100%"}`,flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Ct,{name:"Registered devices",getRowKey:Un,onRowClick:d,rows:S,columns:zn,footerLeft:`Total devices: ${S.length.toString()}`})}),f&&O&&e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",height:"70%",maxHeight:"70%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Ct,{name:"Clusters",title:j||"",getRowKey:Qn,rows:C,columns:Bn,footerLeft:`Total child endpoints: ${E-1}`})})]}):e.jsx(Me,{})}const Kn=r.memo(Gn);function Jn(){const{online:n}=r.useContext(fe),[c,l]=r.useState(""),[s,a]=r.useState("icon");r.useEffect(()=>{const t=localStorage.getItem("devicesFilter");t&&l(t)},[]),r.useEffect(()=>{const t=localStorage.getItem("devicesViewMode");t&&a(t)},[]);const p=t=>{l(t.target.value.toLowerCase()),localStorage.setItem("devicesFilter",t.target.value.toLowerCase())},h=t=>{a(t),localStorage.setItem("devicesViewMode",t)};return o&&console.log("Devices rendering..."),n?e.jsxs(wt,{name:"Devices",children:[e.jsxs("div",{className:"MbfWindowBodyRow",style:{justifyContent:"space-between",padding:0,gap:"20px",width:"100%",height:"45px",minHeight:"45px",maxHeight:"45px"},children:[e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(se,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(me,{variant:"outlined",value:c,onChange:p,placeholder:"Enter the device name or serial number",sx:{width:"320px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(se,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(K,{onClick:()=>h("table"),"aria-label":"Table View",disabled:s==="table",children:e.jsx(R,{title:"Table View",children:e.jsx(so,{style:{color:s==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(K,{onClick:()=>h("icon"),"aria-label":"Icon View",disabled:s==="icon",children:e.jsx(R,{title:"Icon View (beta)",children:e.jsx(ao,{style:{color:s==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),s==="table"&&e.jsx(Kn,{filter:c}),s==="icon"&&e.jsx(qn,{filter:c})]}):e.jsx(Me,{})}const Zn=r.memo(Jn);function Yn(){const[n,c]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[l,s]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[a,p]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:h,setLogFilters:t,online:S,setAutoScroll:N}=r.useContext(fe),C=f=>{c(f.target.value),t(f.target.value,l),localStorage.setItem("logFilterLevel",f.target.value),o&&console.log("handleChangeLevel called with value:",f.target.value)},k=f=>{s(f.target.value),t(n,f.target.value),localStorage.setItem("logFilterSearch",f.target.value),o&&console.log("handleChangeSearch called with value:",f.target.value)},E=f=>{p(f.target.checked),N(f.target.checked),localStorage.setItem("logAutoScroll",f.target.value?"true":"false"),o&&console.log("handleAutoScrollChange called with value:",f.target.checked)},D=()=>{o&&console.log("handleClearLogsClick called"),h([])};return o&&console.log("Logs rendering..."),S?e.jsxs(wt,{name:"Logs",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(_t,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Ke,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:n,onChange:C,children:[e.jsx(L,{value:"debug",children:"Debug"}),e.jsx(L,{value:"info",children:"Info"}),e.jsx(L,{value:"notice",children:"Notice"}),e.jsx(L,{value:"warn",children:"Warn"}),e.jsx(L,{value:"error",children:"Error"}),e.jsx(L,{value:"fatal",children:"Fatal"})]}),e.jsx(_t,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(me,{style:{width:"300px"},size:"small",id:"logsearch",variant:"outlined",value:l,onChange:k,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(Ve,{control:e.jsx(Ee,{checked:a,onChange:E}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx(R,{title:"Clear the logs",children:e.jsx(ie,{onClick:D,endIcon:e.jsx(yt,{}),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(nr,{})})]}):e.jsx(Me,{})}const Xn=r.memo(Yn),ei=({open:n,ip:c,onClose:l,onSave:s})=>{const a=c?c.split(".").slice(0,3).join(".")+".1":"",[p,h]=r.useState("dhcp"),[t,S]=r.useState({ip:c??"",subnet:"255.255.255.0",gateway:a,dns:a}),N=E=>D=>{S({...t,[E]:D.target.value})},C=()=>{l()},k=()=>{s({type:p,...t}),l()};return e.jsxs(Ne,{open:n,onClose:(E,D)=>{D==="backdropClick"||D==="escapeKeyDown"||l()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx($e,{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(Le,{dividers:!0,children:[e.jsxs(er,{component:"fieldset",fullWidth:!0,children:[e.jsx(ye,{component:"legend",children:"Select IP Configuration"}),e.jsxs(tr,{row:!0,value:p,onChange:E=>h(E.target.value),children:[e.jsx(Ve,{value:"dhcp",control:e.jsx(jt,{}),label:"DHCP"}),e.jsx(Ve,{value:"static",control:e.jsx(jt,{}),label:"Static"})]})]}),p==="static"&&e.jsxs(He,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(He,{size:6,children:e.jsx(me,{label:"IP Address",fullWidth:!0,value:t.ip,onChange:N("ip")})}),e.jsx(He,{size:6,children:e.jsx(me,{label:"Subnet Mask",fullWidth:!0,value:t.subnet,onChange:N("subnet")})}),e.jsx(He,{size:6,children:e.jsx(me,{label:"Gateway",fullWidth:!0,value:t.gateway,onChange:N("gateway")})}),e.jsx(He,{size:6,children:e.jsx(me,{label:"DNS Server",fullWidth:!0,value:t.dns,onChange:N("dns")})})]})]}),e.jsxs(Oe,{children:[e.jsx(ie,{onClick:C,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:k,children:"Save"})]})]})},ti=({open:n,onClose:c,onSave:l})=>{const[s,a]=r.useState(""),[p,h]=r.useState(""),t=D=>{a(D.target.value)},S=D=>{h(D.target.value)},N=s.length>0&&s===p,C=()=>{c()},k=()=>{N&&(l(s),c())},E=()=>{l(""),c()};return e.jsxs(Ne,{open:n,onClose:(D,f)=>{f==="backdropClick"||f==="escapeKeyDown"||c()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx($e,{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(Le,{dividers:!0,children:e.jsx(er,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(He,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(He,{size:12,children:e.jsx(me,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:s,onChange:t})}),e.jsx(He,{size:12,children:e.jsx(me,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:p,onChange:S,error:p!==""&&s!==p,helperText:p!==""&&s!==p?"Passwords do not match":""})})]})})}),e.jsxs(Oe,{children:[e.jsx(ie,{onClick:C,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:k,disabled:!N,children:"Change"}),e.jsx(ie,{variant:"contained",onClick:E,children:"Reset"})]})]})},pe=500;function ri(){const{online:n,addListener:c,removeListener:l,sendMessage:s,getUniqueId:a}=r.useContext(fe),[p,h]=r.useState(null),[t,S]=r.useState(null),N=r.useRef(a());return r.useEffect(()=>{const C=k=>{k.src==="Matterbridge"&&k.dst==="Frontend"&&(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:N.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),k.method==="/api/settings"&&(o&&console.log("Settings received /api/settings:",k.response),h(k.response.matterbridgeInformation),S(k.response.systemInformation)))};return c(C,N.current),o&&console.log("Settings added WebSocket listener"),()=>{l(C),o&&console.log("Settings removed WebSocket listener")}},[c,l,s]),r.useEffect(()=>{n&&(o&&console.log("Settings received online"),s({id:N.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[n,s]),o&&console.log("Settings rendering..."),!n||!p||!t?e.jsx(Me,{}):e.jsx(wt,{name:"Settings",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(oi,{matterbridgeInfo:p,systemInfo:t}),e.jsx(ni,{matterbridgeInfo:p}),e.jsx(ii,{matterbridgeInfo:p}),e.jsx(si,{systemInfo:t})]})})}function oi({matterbridgeInfo:n,systemInfo:c}){const{sendMessage:l,getUniqueId:s}=r.useContext(fe),[a,p]=r.useState("bridge"),[h,t]=r.useState("Info"),[S,N]=r.useState(!1),[C,k]=r.useState("dark"),[E,D]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[f,V]=r.useState(localStorage.getItem("homePageMode")??"devices"),[O,x]=r.useState(localStorage.getItem("virtualMode")??"outlet"),j=r.useRef(s()),[$,_]=r.useState(!1),F=()=>_(!1),v=J=>{o&&console.log("handleSaveNetConfig called with config:",J),l({id:j.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:J})},[H,b]=r.useState(!1),d=()=>b(!1),i=J=>{o&&console.log("handleSaveChangePassword called with password:",J),l({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:J}})};r.useEffect(()=>{n&&(p(n.bridgeMode==="bridge"?"bridge":"childbridge"),t(n.loggerLevel.charAt(0).toUpperCase()+n.loggerLevel.slice(1)),N(n.fileLogger),x(n.virtualMode))},[n]),r.useEffect(()=>{const J=localStorage.getItem("frontendTheme");J&&k(J)},[]);const u=J=>{o&&console.log("handleChangeBridgeMode called with value:",J.target.value),p(J.target.value),l({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:J.target.value}})},g=J=>{o&&console.log("handleChangeMbLoggerLevel called with value:",J.target.value),t(J.target.value),l({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:J.target.value}})},T=J=>{o&&console.log("handleLogOnFileMbChange called with value:",J.target.checked),N(J.target.checked),l({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:J.target.checked}})},ce=J=>{const z=J.target.value;o&&console.log("handleChangeTheme called with value:",z),k(z),localStorage.setItem("frontendTheme",z),document.body.setAttribute("frontend-theme",z)},be=J=>{const z=J.target.checked;o&&console.log("handleChangeHomePagePlugins called with value:",z),D(z),localStorage.setItem("homePagePlugins",z?"true":"false")},ne=J=>{const z=J.target.value;o&&console.log("handleChangeHomePageMode called with value:",z),V(z),localStorage.setItem("homePageMode",z)},Ce=J=>{const z=J.target.value;o&&console.log("handleChangeVirtualMode called with value:",z),x(z),localStorage.setItem("virtualMode",z),l({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:z}})};return!n||!c?null:e.jsxs(ke,{style:{width:`${pe}px`,maxWidth:`${pe}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(ei,{open:$,ip:c.ipv4Address,onClose:F,onSave:v}),e.jsx(ti,{open:H,onClose:d,onSave:i}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Y,{sx:{gap:"10px",margin:"0px",padding:"10px",width:`${pe-20}px`,backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(tr,{row:!0,name:"mode-buttons-group",value:a,onChange:u,children:[e.jsx(Ve,{value:"bridge",control:e.jsx(jt,{}),label:"Bridge",disabled:n.readOnly===!0}),e.jsx(Ve,{value:"childbridge",control:e.jsx(jt,{}),label:"Childbridge",disabled:n.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(Ke,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:h,onChange:g,children:[e.jsx(L,{value:"Debug",children:"Debug"}),e.jsx(L,{value:"Info",children:"Info"}),e.jsx(L,{value:"Notice",children:"Notice"}),e.jsx(L,{value:"Warn",children:"Warn"}),e.jsx(L,{value:"Error",children:"Error"}),e.jsx(L,{value:"Fatal",children:"Fatal"})]}),e.jsx(Ve,{style:{padding:"0px",margin:"0px"},control:e.jsx(Ee,{checked:S,onChange:T,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(Ke,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:C,onChange:ce,children:[e.jsx(L,{value:"classic",children:"Classic"}),e.jsx(L,{value:"light",children:"Light"}),e.jsx(L,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Ee,{checked:E,onChange:be,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(Ke,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:f,onChange:ne,children:[e.jsx(L,{value:"logs",children:"Logs"}),e.jsx(L,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(Ke,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:O,onChange:Ce,children:[e.jsx(L,{value:"disabled",children:"Disabled"}),e.jsx(L,{value:"outlet",children:"Outlet"}),e.jsx(L,{value:"light",children:"Light"}),e.jsx(L,{value:"switch",children:"Switch"}),e.jsx(L,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>b(!0),children:"Change password"})}),n.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>_(!0),children:"Configure IP"})})]})})]})}function ni({matterbridgeInfo:n}){const{sendMessage:c,getUniqueId:l}=r.useContext(fe),[s,a]=r.useState("Info"),[p,h]=r.useState(!1),[t,S]=r.useState(""),[N,C]=r.useState(""),[k,E]=r.useState(""),[D,f]=r.useState(""),[V,O]=r.useState(""),[x,j]=r.useState(""),$=r.useRef(l());r.useEffect(()=>{n&&(a(["Debug","Info","Notice","Warn","Error","Fatal"][n.matterLoggerLevel]),h(n.matterFileLogger),S(n.matterMdnsInterface||""),C(n.matterIpv4Address||""),E(n.matterIpv6Address||""),f(n.matterPort?n.matterPort.toString():""),O(n.matterDiscriminator?n.matterDiscriminator.toString():""),j(n.matterPasscode?n.matterPasscode.toString():""))},[n]);const _=g=>{o&&console.log("handleChangeMjLoggerLevel called with value:",g.target.value),a(g.target.value),c({id:$.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:g.target.value}})},F=g=>{o&&console.log("handleLogOnFileMjChange called with value:",g.target.checked),h(g.target.checked),c({id:$.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:g.target.checked}})},v=g=>{o&&console.log("handleChangeMdnsInterface called with value:",g.target.value),S(g.target.value),c({id:$.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:g.target.value}})},H=g=>{o&&console.log("handleChangeIpv4Address called with value:",g.target.value),C(g.target.value),c({id:$.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:g.target.value}})},b=g=>{o&&console.log("handleChangeIpv6Address called with value:",g.target.value),E(g.target.value),c({id:$.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:g.target.value}})},d=g=>{o&&console.log("handleChangeMatterPort called with value:",g.target.value),f(g.target.value),c({id:$.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:g.target.value}})},i=g=>{o&&console.log("handleChangeMatterDiscriminator called with value:",g.target.value),O(g.target.value),c({id:$.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:g.target.value}})},u=g=>{o&&console.log("handleChangemMatterPasscode called with value:",g.target.value),j(g.target.value),c({id:$.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:g.target.value}})};return n?e.jsxs(ke,{style:{width:`${pe}px`,maxWidth:`${pe}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matter settings"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Y,{sx:{gap:"20px",margin:"0px",padding:"10px",width:`${pe-20}px`,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(ye,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(Ke,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:s,onChange:_,children:[e.jsx(L,{value:"Debug",children:"Debug"}),e.jsx(L,{value:"Info",children:"Info"}),e.jsx(L,{value:"Notice",children:"Notice"}),e.jsx(L,{value:"Warn",children:"Warn"}),e.jsx(L,{value:"Error",children:"Error"}),e.jsx(L,{value:"Fatal",children:"Fatal"})]}),e.jsx(Ve,{style:{padding:"0px",margin:"0px"},control:e.jsx(Ee,{checked:p,onChange:F,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Mdns interface:"}),e.jsx(me,{value:t,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",marginBottom:"10px",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv4 address:"}),e.jsx(me,{value:N,onChange:H,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",marginBottom:"10px",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv6 address:"}),e.jsx(me,{value:k,onChange:b,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",marginBottom:"10px",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning port:"}),e.jsx(me,{value:D,onChange:d,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",marginBottom:"10px",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning discriminator:"}),e.jsx(me,{value:V,onChange:i,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",marginBottom:"10px",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning passcode:"}),e.jsx(me,{value:x,onChange:u,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]}):null}function ii({matterbridgeInfo:n}){return n?e.jsxs(ke,{style:{width:`${pe}px`,maxWidth:`${pe}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Y,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsx(je,{value:n.matterbridgeVersion,label:"Current Version",width:pe}),e.jsx(je,{value:n.matterbridgeLatestVersion,label:"Latest Version",width:pe}),e.jsx(je,{value:n.homeDirectory,label:"Home Directory",width:pe}),e.jsx(je,{value:n.rootDirectory,label:"Root Directory",width:pe}),e.jsx(je,{value:n.matterbridgeDirectory,label:"Matterbridge Storage Directory",width:pe}),e.jsx(je,{value:n.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory",width:pe}),e.jsx(je,{value:n.globalModulesDirectory,label:"Global Module Directory",width:pe})]})})]}):null}function si({systemInfo:n}){return n?e.jsxs(ke,{style:{width:`${pe}px`,maxWidth:`${pe}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"System info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Y,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsx(je,{value:n.interfaceName,label:"Interface name",width:pe}),e.jsx(je,{value:n.macAddress,label:"MAC Address",width:pe}),e.jsx(je,{value:n.ipv4Address,label:"IPv4 Address",width:pe}),e.jsx(je,{value:n.ipv6Address,label:"IPv6 Address",width:pe}),e.jsx(je,{value:n.nodeVersion,label:"Node Version",width:pe}),e.jsx(je,{value:n.hostname,label:"Hostname",width:pe}),e.jsx(je,{value:n.user,label:"User",width:pe})]})})]}):null}function je({value:n,label:c,width:l}){return e.jsx(me,{focused:!0,value:n,size:"small",label:c,variant:"standard",sx:{width:l?`${l-20}px`:"400px"},InputProps:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},InputLabelProps:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}})}const ai=r.memo(ri);function li(){const{online:n,sendMessage:c,addListener:l,removeListener:s,getUniqueId:a}=r.useContext(fe),{showSnackbarMessage:p}=r.useContext(_e),[h,t]=r.useState(null),[S,N]=r.useState([]),[C,k]=r.useState([]),[E,D]=r.useState(null),[f,V]=r.useState({cpuUsage:0}),[O,x]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[j,$]=r.useState({systemUptime:"",processUptime:""}),_=r.useRef(a());return o&&console.log("Test uniqueId:",_),r.useEffect(()=>{o&&console.log("Test useEffect WebSocketMessage mounting");const F=v=>{if(v.method==="restart_required")o&&console.log("Test received restart_required"),p("Restart required",0);else if(v.method==="refresh_required")o&&console.log(`Test received refresh_required: changed=${v.response.changed} and sending api requests`),p("Refresh required",0),c({id:_.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:_.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:_.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(v.method==="memory_update")o&&console.log("Test received memory_update",v),x(v.response);else if(v.method==="cpu_update")o&&console.log("Test received cpu_update",v),V(v.response);else if(v.method==="uptime_update")o&&console.log("Test received uptime_update",v),$(v.response);else if(v.method==="/api/settings"&&v.response)o&&console.log("Test received /api/settings:",v.response),p("Test received /api/settings",0),t(v.response);else if(v.method==="/api/plugins"&&v.response)o&&console.log(`Test received ${v.response.length} plugins:`,v.response),p("Test received /api/plugins",0),N(v.response);else if(v.method==="/api/devices"&&v.response){o&&console.log(`Test received ${v.response.length} devices:`,v.response),p("Test received /api/devices",0),k(v.response);for(const H of v.response)o&&console.log("Test sending /api/clusters for device:",H.pluginName,H.name,H.endpoint),c({id:_.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:H.pluginName,endpoint:H.endpoint||0}})}else v.method==="/api/clusters"&&v.response&&(o&&console.log(`Test received ${v.response.clusters.length} clusters for device ${v.response.deviceName} endpoint ${v.response.id}:${v.response.number}:`,v),p(`Test received /api/clusters for ${v.response.plugin}::${v.response.deviceName}`,0),D(v.response))};return l(F,_.current),o&&console.log("Test useEffect WebSocketMessage mounted"),()=>{o&&console.log("Test useEffect WebSocketMessage unmounting"),s(F),o&&console.log("Test useEffect WebSocketMessage unmounted")}},[l,s,c,p]),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,c,p]),o&&console.log("Test rendering..."),n?e.jsx("div",{className:"MbfPageDiv",style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",height:"100vh"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",width:"100%"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px"}}),e.jsx("p",{children:"Welcome to the Test page of the Matterbridge frontend"})]})}):e.jsx(Me,{})}const di=r.memo(li);function ci(n,c){o&&console.log("getCssVariable:",n,"defaultValue",c);const l=getComputedStyle(document.body).getPropertyValue(n).trim();return l||console.error("getCssVariable: undefined",l),l||c}function ui(n){return lo({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 pi(){const{mobile:n,showSnackbarMessage:c,showConfirmCancelDialog:l}=r.useContext(_e),{online:s,sendMessage:a,logMessage:p,addListener:h,removeListener:t,getUniqueId:S}=r.useContext(fe),[N,C]=r.useState(!1),[k,E]=r.useState(!1),[D,f]=r.useState(!1),[V,O]=r.useState(!1),[x,j]=r.useState(null),$=r.useRef(S()),[_,F]=r.useState(null),[v,H]=r.useState(null),[b,d]=r.useState(null),[i,u]=r.useState(null),[g,T]=r.useState(null),ce=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},be=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},ne=()=>{x?.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?window.open("https://github.com/Luligu/matterbridge/blob/dev/CHANGELOG.md","_blank"):window.open("https://github.com/Luligu/matterbridge/blob/main/CHANGELOG.md","_blank")},Ce=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},J=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},z=()=>{a({id:$.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},w=()=>{a({id:$.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},A=()=>{a({id:$.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},P=()=>{o&&console.log("Header: handleShellySystemUpdateClick"),p("Matterbridge","Installing system updates..."),a({id:$.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},I=()=>{o&&console.log("Header: handleShellyMainUpdateClick"),p("Matterbridge","Installing software updates..."),a({id:$.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},M=()=>{o&&console.log("Header: handleShellyCreateSystemLog"),a({id:$.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},W=()=>{o&&console.log("Header: handleShellyDownloadSystemLog"),p("Matterbridge","Downloading Shelly system log..."),c("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},q=()=>{x?.matterbridgeInformation.restartMode===""?a({id:$.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):a({id:$.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},Z=()=>{a({id:$.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},ue=()=>{a({id:$.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},ae=()=>{a({id:$.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},le=()=>{a({id:$.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},ge=y=>{F(y.currentTarget)},B=y=>{o&&console.log("Header: handleMenuClose",y),F(null),y==="download-mblog"?(p("Matterbridge","Downloading matterbridge log..."),c("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):y==="download-mjlog"?(p("Matterbridge","Downloading matter log..."),c("Downloading matter log...",5),window.location.href="./api/download-mjlog"):y==="view-mblog"?(p("Matterbridge","Loading matterbridge log..."),c("Loading matterbridge log...",5),window.location.href="./api/view-mblog"):y==="view-mjlog"?(p("Matterbridge","Loading matter log..."),c("Loading matter log...",5),window.location.href="./api/view-mjlog"):y==="view-shellylog"?(p("Matterbridge","Loading shelly system log..."),c("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):y==="download-mbstorage"?(p("Matterbridge","Downloading matterbridge storage..."),c("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):y==="download-pluginstorage"?(p("Matterbridge","Downloading matterbridge plugins storage..."),c("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):y==="download-pluginconfig"?(p("Matterbridge","Downloading matterbridge plugins config..."),c("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):y==="download-mjstorage"?(p("Matterbridge","Downloading matter storage..."),c("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):y==="download-backup"?(p("Matterbridge","Downloading backup..."),c("Downloading backup...",10),window.location.href="./api/download-backup"):y==="update"?z():y==="updatedev"?w():y==="updatecheck"?A():y==="shelly-sys-update"?P():y==="shelly-main-update"?I():y==="shelly-create-system-log"?M():y==="shelly-download-system-log"?W():y==="softreset"?ae():y==="hardreset"?le():y==="restart"?q():y==="shutdown"?Z():y==="reboot"?ue():y==="create-backup"?a({id:$.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):y==="unregister"?a({id:$.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):y==="reset"?a({id:$.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):y==="factoryreset"&&a({id:$.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},U=y=>{o&&console.log("Header: handleMenuCloseCancel:",y),F(null)},m=y=>{H(y.currentTarget)},he=()=>{H(null)},ve=y=>{d(y.currentTarget)},de=()=>{d(null)},X=y=>{u(y.currentTarget)},oe=()=>{u(null)},Ie=y=>{T(y.currentTarget)},De=()=>{T(null)},Ye=()=>{fi(),o&&console.log("Matterbridge logo clicked: debug is now",o)};return r.useEffect(()=>{const y=ee=>{o&&console.log("Header received WebSocket Message:",ee),ee.method==="/api/settings"&&ee.id===$.current?(o&&console.log("Header received settings:",ee.response),j(ee.response),C(ee.response.matterbridgeInformation.restartRequired||ee.response.matterbridgeInformation.fixedRestartRequired),E(ee.response.matterbridgeInformation.fixedRestartRequired),f(ee.response.matterbridgeInformation.updateRequired)):ee.method==="refresh_required"&&ee.response.changed==="settings"?(o&&console.log(`Header received refresh_required: changed=${ee.response.changed} and sending /api/settings request`),a({id:$.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):ee.method==="restart_required"?(o&&console.log(`Header received restart_required with fixed: ${ee.response.fixed}`),C(!0),ee.response.fixed===!0&&E(!0)):ee.method==="restart_not_required"?(o&&console.log("Header received restart_not_required"),C(!1)):ee.method==="update_required"?(o&&console.log("Header received update_required"),ee.response.devVersion===!0?O(!0):f(!0),a({id:$.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):ee.method==="shelly_sys_update"?(o&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),j(we=>we?{matterbridgeInformation:{...we.matterbridgeInformation,shellySysUpdate:ee.response.available},systemInformation:we.systemInformation}:null)):ee.method==="shelly_main_update"&&(o&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),j(we=>we?{matterbridgeInformation:{...we.matterbridgeInformation,shellyMainUpdate:ee.response.available},systemInformation:we.systemInformation}:null))};return h(y,$.current),o&&console.log(`Header added WebSocket listener id ${$.current}`),()=>{t(y),o&&console.log("Header removed WebSocket listener")}},[h,t,a,c]),r.useEffect(()=>{s&&(o&&console.log("Header sending /api/settings requests"),a({id:$.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[s,a]),o&&console.log("Header rendering... mobile %s",n),!s||!x?null:e.jsxs("div",{className:"header",style:{},children:[e.jsxs("div",{className:"sub-header",children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:Ye}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"}),e.jsxs("nav",{children:[e.jsx(nt,{to:"/",className:"nav-link",children:"Home"}),e.jsx(nt,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(nt,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(nt,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!x.matterbridgeInformation.readOnly&&D&&e.jsx(R,{title:"New Matterbridge version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:z,children:["Update to v.",x.matterbridgeInformation.matterbridgeLatestVersion]})}),!x.matterbridgeInformation.readOnly&&V&&e.jsx(R,{title:"New Matterbridge dev version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:w,children:["Update to new dev v.",x.matterbridgeInformation.matterbridgeDevVersion.split("-dev-")[0]]})}),!x.matterbridgeInformation.readOnly&&e.jsx(R,{title:"Matterbridge version, click to see the changelog",children:e.jsxs("span",{className:"status-information",onClick:ne,children:["v.",x.matterbridgeInformation.matterbridgeVersion]})}),x.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),x.matterbridgeInformation.bridgeMode!==""&&x.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:x.matterbridgeInformation.bridgeMode})}):null,x.matterbridgeInformation.restartMode!==""&&x.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:x.matterbridgeInformation.restartMode})}):null,x.matterbridgeInformation.profile&&x.matterbridgeInformation.profile!==""&&x.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:x.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[x.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:Ce})}):null,x.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Give a star to Matterbridge",children:e.jsx(K,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:J,children:e.jsx(co,{})})}):null,x.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Sponsor Matterbridge",children:e.jsx(K,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:ce,children:e.jsx(Zt,{})})}):null,e.jsx(R,{title:"Matterbridge help",children:e.jsx(K,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:be,children:e.jsx(uo,{})})}),e.jsx(R,{title:"Matterbridge changelog",children:e.jsx(K,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:ne,children:e.jsx(Xt,{})})}),x.matterbridgeInformation&&!x.matterbridgeInformation.readOnly&&e.jsx(R,{title:"Update matterbridge to latest version",children:e.jsx(K,{style:{color:D?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:z,children:e.jsx(Re,{})})}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&x.matterbridgeInformation.shellySysUpdate&&e.jsx(R,{title:"Shelly system update",children:e.jsx(K,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:P,children:e.jsx(Re,{})})}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&x.matterbridgeInformation.shellyMainUpdate&&e.jsx(R,{title:"Shelly software update",children:e.jsx(K,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:I,children:e.jsx(Re,{})})}),e.jsx(R,{title:"Restart matterbridge",children:e.jsx(K,{style:{color:N||k?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:q,children:e.jsx(bt,{})})}),x.matterbridgeInformation.restartMode===""?e.jsx(R,{title:"Shut down matterbridge",children:e.jsx(K,{style:{color:N||k?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:Z,children:e.jsx(Ae,{})})}):null,e.jsx(R,{title:"Download, backup and more",children:e.jsx(K,{onClick:ge,children:e.jsx(po,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(Ge,{id:"command-menu",anchorEl:_,keepMounted:!0,open:!!_,onClose:()=>B(""),children:[x.matterbridgeInformation&&!x.matterbridgeInformation.readOnly&&e.jsxs(L,{onClick:()=>B("update"),children:[e.jsx(G,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&!x.matterbridgeInformation.readOnly&&e.jsxs(L,{onClick:()=>B("updatedev"),children:[e.jsx(G,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&!x.matterbridgeInformation.readOnly&&e.jsxs(L,{onClick:()=>B("updatecheck"),children:[e.jsx(G,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&x.matterbridgeInformation.shellySysUpdate&&e.jsxs(L,{onClick:()=>B("shelly-sys-update"),children:[e.jsx(G,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&x.matterbridgeInformation.shellyMainUpdate&&e.jsxs(L,{onClick:()=>B("shelly-main-update"),children:[e.jsx(G,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>B("restart"),children:[e.jsx(G,{children:e.jsx(bt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation.restartMode===""?e.jsxs(L,{onClick:()=>B("shutdown"),children:[e.jsx(G,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{l("Reboot","Are you sure you want to reboot the Shelly board?","reboot",B,U)},children:[e.jsx(G,{children:e.jsx(bt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(dt,{}),e.jsxs(L,{onClick:ve,children:[e.jsx(G,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ge,{id:"sub-menu-view",anchorEl:b,keepMounted:!0,open:!!b,onClose:de,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(L,{onClick:()=>{B("view-mblog"),de()},children:[e.jsx(G,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{B("view-mjlog"),de()},children:[e.jsx(G,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{B("view-shellylog"),de()},children:[e.jsx(G,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(L,{onClick:X,children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ge,{id:"sub-menu-download",anchorEl:i,keepMounted:!0,open:!!i,onClose:oe,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(L,{onClick:()=>{B("download-mbstorage"),oe()},children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{B("download-pluginstorage"),oe()},children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{B("download-pluginconfig"),oe()},children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{B("download-mblog"),oe()},children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{B("download-mjstorage"),oe()},children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{B("download-mjlog"),oe()},children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{B("shelly-create-system-log"),oe()},children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{B("shelly-download-system-log"),oe()},children:[e.jsx(G,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(L,{onClick:m,children:[e.jsx(G,{children:e.jsx(St,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ge,{id:"sub-menu-backup",anchorEl:v,keepMounted:!0,open:!!v,onClose:he,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(L,{onClick:()=>{B("create-backup"),he()},children:[e.jsx(G,{children:e.jsx(St,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{B("download-backup"),he()},children:[e.jsx(G,{children:e.jsx(St,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(L,{onClick:Ie,children:[e.jsx(G,{children:e.jsx(go,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ge,{id:"sub-menu-reset",anchorEl:g,keepMounted:!0,open:!!g,onClose:De,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(L,{onClick:()=>{De(),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",B,U)},children:[e.jsx(G,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{De(),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",B,U)},children:[e.jsx(G,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!x.matterbridgeInformation.readOnly&&e.jsxs(L,{onClick:()=>{De(),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",B,U)},children:[e.jsx(G,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{De(),l("Network reset","Are you sure you want to factory reset the network parameters?","softreset",B,U)},children:[e.jsx(G,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),x.matterbridgeInformation&&x.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{De(),l("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",B,U)},children:[e.jsx(G,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const gi=r.memo(pi),ir=1200,sr=800;let Dt,Pt;function mi(){if(typeof window<"u"){Dt=Math.floor(window.visualViewport?.width??window.innerWidth),Pt=Math.floor(window.visualViewport?.height??window.innerHeight);const n=Dt<ir||Pt<sr;return o&&console.log("Visual viewport width %i height %i mobile %s",Dt,Pt,n),n}return!1}function hi({children:n}){const{mobile:c,setMobile:l}=r.useContext(_e);return r.useEffect(()=>{function s(){l(mi())}return window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[l]),o&&console.log("MbfScreen rendering... mobile %s",c),e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",width:c?`${ir}px`:"calc(100vw - 40px)",height:c?`${sr}px`:"calc(100vh - 40px)",margin:"0px",padding:"20px",gap:"20px"},children:[e.jsx(gi,{}),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 fi=()=>{o=!o},xi=!1;function bi({setLoggedIn:n}){const[c,l]=r.useState(""),[s,a]=r.useState(""),p={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)"},t={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)"},S=async C=>{try{const k=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:C})});if(k.ok){const{valid:E}=await k.json();E?n(!0):C!==""&&a("Incorrect password!")}else console.error("Failed to log in:",k.statusText)}catch(k){console.error("Failed to log in:",k)}},N=C=>{C.preventDefault(),S(c)};return S(""),e.jsx("div",{style:p,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:"64px",width:"64px"}}),e.jsx("h3",{style:{color:"var(--div-text-color)"},children:"Welcome to Matterbridge"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:"20px"},children:[e.jsx("input",{type:"text",name:"username",autoComplete:"username",style:{display:"none"},tabIndex:-1}),e.jsx("input",{type:"password",value:c,onChange:C=>l(C.target.value),style:t,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:s&&e.jsx("p",{style:{color:"red"},children:s})})]})})}function vi(){const[n,c]=r.useState(!1),l=localStorage.getItem("frontendTheme")||"dark";o&&console.log('Setting frontend theme "%s"',l),document.body.setAttribute("frontend-theme",l);const s=ci("--primary-color","#1976d2");o&&console.log('Primary color from CSS "%s"',s);const a=ui(s),p=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";return o&&(console.log("Loading App..."),console.log(`- with href = "${window.location.href}"`),console.log(`- pathname = "${window.location.pathname}"`),console.log(`- baseName = "${p}"`)),n?e.jsx(mo,{theme:a,children:e.jsx(wr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(Jo,{children:e.jsx(Zo,{children:e.jsx(xr,{basename:p,children:e.jsx(hi,{children:e.jsxs(br,{children:[e.jsx(qe,{path:"/",element:e.jsx(Pn,{})}),e.jsx(qe,{path:"/devices",element:e.jsx(Zn,{})}),e.jsx(qe,{path:"/log",element:e.jsx(Xn,{})}),e.jsx(qe,{path:"/settings",element:e.jsx(ai,{})}),e.jsx(qe,{path:"/test",element:e.jsx(di,{})}),e.jsx(qe,{path:"*",element:e.jsx(vr,{to:"/"})})]})})})})})})}):e.jsx(bi,{setLoggedIn:c})}yr.createRoot(document.getElementById("root")).render(e.jsx(jr.StrictMode,{children:e.jsx(vi,{})}));