@matterbridge/frontend 3.5.5-dev-20260725-031fcae → 3.5.5-dev-20260727-b80c82f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/assets/index.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/build/assets/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import{a as e}from"./rolldown-runtime.js";import{c as t}from"./vendor_emotion.js
|
|
|
19
19
|
::-webkit-scrollbar-track {
|
|
20
20
|
background: ${i};
|
|
21
21
|
}
|
|
22
|
-
`,t.head.appendChild(a)},style:{display:`block`,flex:`1 1 auto`,width:`100%`,height:`100%`,border:`none`,backgroundColor:`var(--div-bg-color)`}})}),(0,Y.jsx)(D,{sx:{flex:`0 0 auto`,justifyContent:`center`},children:(0,Y.jsx)(W,{onClick:()=>w(null),children:`Close`})})]})]}):(0,Y.jsx)(qt,{})}var zn=(0,G.memo)(Rn),Bn=[`matterbridge-`,`matterbridge-plugin-template`,`matterbridge-dyson`,`matterbridge-tuya`,`matterbridge-matter`,`matterbridge-automations`,`matterbridge-securitysystem`,`matterbridge-adapter`],Vn=e=>e.replace(`git+`,``).replace(`.git`,``).trim(),Hn=e=>{let t=Vn(e);return t.startsWith(`git://`)&&(t=`https://${t.slice(6)}`),t.startsWith(`ssh://git@github.com/`)&&(t=`https://github.com/${t.slice(21)}`),t.startsWith(`git@github.com:`)&&(t=`https://github.com/${t.slice(15).replace(`:`,`/`)}`),t},Un=e=>{if(typeof e==`string`)return e.trim()||null;if(!e||typeof e!=`object`)return null;let t=e.url;return typeof t==`string`&&t.trim()||null},Wn=()=>{try{let e=window.localStorage.getItem(K.searchPluginsTotal);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.total==`number`&&typeof t.asOf==`string`&&(n[e]={total:t.total,asOf:t.asOf})}return n}catch{return{}}},Gn=e=>{try{window.localStorage.setItem(K.searchPluginsTotal,JSON.stringify(e))}catch{}},Kn=()=>{try{let e=window.localStorage.getItem(K.searchPluginsMeta);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.asOf==`string`&&(n[e]={homepage:typeof t.homepage==`string`?t.homepage:null,help:typeof t.help==`string`?t.help:null,changelog:typeof t.changelog==`string`?t.changelog:null,asOf:t.asOf})}return n}catch{return{}}},qn=e=>{try{window.localStorage.setItem(K.searchPluginsMeta,JSON.stringify(e))}catch{}},Jn=()=>{try{let e=window.localStorage.getItem(K.searchPluginsVersions);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.asOf==`string`&&Array.isArray(t.versions)&&(n[e]={versions:t.versions.filter(e=>typeof e==`string`),asOf:t.asOf})}return n}catch{return{}}},Yn=e=>{try{window.localStorage.setItem(K.searchPluginsVersions,JSON.stringify(e))}catch{}},Xn=({open:e,onClose:t,onSelect:n,onVersions:r})=>{let{mobile:i}=(0,G.useContext)(Wt),[a,o]=(0,G.useState)(``),s=(0,G.useRef)(``),c=(0,G.useRef)(!1),l=(0,G.useRef)(null),[u,d]=(0,G.useState)([]),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[_,y]=(0,G.useState)(!1),[b,S]=(0,G.useState)({done:0,total:0}),[C,w]=(0,G.useState)(null),T=(0,G.useRef)({}),E=()=>{let e=document.activeElement;e&&e instanceof HTMLElement&&e.blur()},O=e=>`${e.getFullYear().toString()}-${(e.getMonth()+1).toString().padStart(2,`0`)}-${e.getDate().toString().padStart(2,`0`)}`,k=(0,G.useCallback)(async(e,t)=>{let n=T.current[e];if(n&&n.asOf===t&&Array.isArray(n.versions)&&n.versions.length>0&&n.versions[0]===`latest`)return q&&console.log(`[SearchPluginsDialog] versions cache hit for ${e} (${n.versions.length.toString()})`),n.versions;n&&n.asOf===t&&n.versions.length>0&&n.versions[0]!==`latest`&&q&&console.log(`[SearchPluginsDialog] versions cache ignored (old format) for ${e} (asOf=${t})`);let r=`https://registry.npmjs.org/${encodeURIComponent(e)}`;q&&console.log(`[SearchPluginsDialog] fetching versions for ${e} from: ${r}`);let i=await fetch(r,{signal:l.current?.signal});if(!i.ok)return q&&console.log(`[SearchPluginsDialog] versions fetch failed for ${e}: ${i.status.toString()} ${i.statusText}`),[];let a=await i.json(),o=Object.keys(a.versions??{}),s=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`});o.sort((e,t)=>s.compare(e,t)).reverse();let c=a[`dist-tags`]??{},u=typeof c?.dev==`string`&&String(c.dev).trim().length>0,d=o.slice(0,20),f=[`latest`];return u&&f.push(`dev`),f.push(...d),q&&console.log(`[SearchPluginsDialog] fetched versions for ${e} (tags: latest${u?`, dev`:``}; latestVersions=${d.length.toString()}; allVersions=${o.length.toString()}):`,f),T.current[e]={versions:f,asOf:t},Yn(T.current),f},[]),A=e=>new Intl.NumberFormat().format(e),j=[{label:`Name`,id:`name`,required:!0,maxWidth:230,tooltip:!0},{label:`Version`,id:`version`,required:!0,maxWidth:110,tooltip:!0},{label:`Monthly`,id:`downloads`,align:`right`,maxWidth:120,render:e=>typeof e==`number`?A(e):``},{label:`Total`,id:`total`,align:`right`,maxWidth:120,render:e=>typeof e==`number`?A(e):``},{label:`Description`,id:`description`,required:!0,maxWidth:300,tooltip:!0},{label:`Author`,id:`author`,maxWidth:140,tooltip:!0},{label:`Action`,id:`action`,align:`center`,maxWidth:100,noSort:!0,required:!0,render:(e,t,n,r)=>(0,Y.jsxs)(`div`,{style:{margin:`0`,padding:`0`,gap:`4px`,display:`flex`,flexDirection:`row`,justifyContent:`center`},children:[(0,Y.jsx)(V,{title:n.homepage?`Open the plugin homepage`:`No homepage available`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(L,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.homepage,onClick:e=>{if(e.stopPropagation(),n.homepage)try{let e=new URL(n.homepage);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,Y.jsx)(v,{})})})}),(0,Y.jsx)(V,{title:n.help?`Open the plugin help`:`No help available`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(L,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.help,onClick:e=>{if(e.stopPropagation(),n.help)try{let e=new URL(n.help);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,Y.jsx)(re,{})})})}),(0,Y.jsx)(V,{title:n.changelog?`Open the plugin changelog`:`No changelog available`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(L,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.changelog,onClick:e=>{if(e.stopPropagation(),n.changelog)try{let e=new URL(n.changelog);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,Y.jsx)(g,{})})})})]})}];(0,G.useEffect)(()=>{if(!e){c.current=!1,s.current=``,l.current?.abort(),l.current=null,d([]),p(!1),h(!1),y(!1),S({done:0,total:0}),w(null),o(``);return}if(c.current)return;c.current=!0;let t=new AbortController;return l.current=t,T.current=Jn(),(async()=>{let e=`matterbridge-`,n=e=>new Promise(t=>setTimeout(t,e)),r=e=>{if(!Array.isArray(e.downloads))return null;let t=0,n=!1;for(let r of e.downloads)typeof r?.downloads==`number`&&(t+=r.downloads,n=!0);return n?t:null};try{p(!0),w(null);let i=e=>{let t=String(e??``).trim().toLowerCase();return t?!!(t===`github actions`||t===`github-actions`||t===`github-actions[bot]`||t.includes(`github-actions`)||t.endsWith(`[bot]`)):!1},a=e=>{let t=(e.maintainers??[]).map(e=>(e.username??``).trim()).filter(Boolean),n=(e.publisher?.username??``).trim();return t.find(e=>!i(e))||(n&&!i(n)?n:t[0]??n??``)},o=await fetch(`https://registry.npmjs.org/-/v1/search?text=matterbridge-&size=250`,{signal:t.signal});if(!o.ok)throw Error(`npm registry request failed: ${o.status} ${o.statusText}`);let s=await o.json(),c=`luligu`,l=e=>e.publisher?.username?.toLowerCase()===c||(e.maintainers??[]).some(e=>e.username?.toLowerCase()===c),u=(s.objects??[]).filter(e=>!!e?.package&&typeof e.package.name==`string`).filter(t=>t.package?.name?.startsWith(e)).filter(e=>!Bn.includes(e.package?.name??``)).sort((e,t)=>{let n=l(e.package??{});return n===l(t.package??{})?(e.package?.name??``).localeCompare(t.package?.name??``):n?-1:1}).map(e=>{let t=e.package,n=t.name??``,r=a(t),i=typeof e.downloads?.monthly==`number`?e.downloads.monthly:null,o=(t.links?.npm??``).trim(),s=((t.links?.homepage??``).trim()||o||(n?`https://www.npmjs.com/package/${encodeURIComponent(n)}`:``)).trim()||null;return{name:n,version:t.version??``,downloads:i,total:null,description:t.description??``,author:r,official:l(t),homepage:s,help:null,changelog:null}}),f=O(new Date),m=Wn(),h=Kn(),g=u.map(e=>{let t=m[e.name];return!t||typeof t.total!=`number`?e:(q&&console.log(`[SearchPluginsDialog] total downloads loaded from cache for ${e.name} (asOf=${t.asOf}):`,t.total),{...e,total:t.total})}).map(e=>{let t=h[e.name];if(!t||t.asOf!==f)return e;let n=t.homepage??e.homepage,r=t.help,i=t.changelog;return q&&(r||i||n&&n!==e.homepage)&&console.log(`[SearchPluginsDialog] metadata loaded from cache for ${e.name} (asOf=${t.asOf}):`,{homepage:n,help:r,changelog:i}),{...e,homepage:n,help:r,changelog:i}});d(g);let _=u.map(e=>e.name).filter(e=>{let t=T.current[e];return!t||t.asOf!==f||t.versions.length===0});q&&console.log(`[SearchPluginsDialog] versions prefetch queue (${_.length.toString()}):`,_);let v=0,b=async()=>{for(;v<_.length;){if(t.signal.aborted)return;let e=v;v+=1;let r=_[e];if(r)try{let e=await k(r,f);q&&e.length>0&&console.log(`[SearchPluginsDialog] versions fetched for ${r} (${e.length.toString()}):`,e.slice(0,5))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return}finally{t.signal.aborted||await n(200)}}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>b()));let x=u.map(e=>e.name).filter(e=>{let t=h[e],n=!!t&&t.asOf===f,r=!!t&&!!t.help&&!!t.changelog,i=!n||!r;return!i&&q&&console.log(`[SearchPluginsDialog] metadata fetch skipped (cache fresh+complete) for ${e} (asOf=${t.asOf}).`),n&&!r&&q&&console.log(`[SearchPluginsDialog] metadata fetch forced (cache incomplete) for ${e} (asOf=${t.asOf}).`),i}),C=new Set(x),E=async(e,n)=>{let r=`https://registry.npmjs.org/${encodeURIComponent(e)}/latest`;try{let e=await fetch(r,{signal:t.signal});if(!e.ok)return null;let i=await e.json(),a=typeof i.homepage==`string`&&i.homepage.includes(`http`)?Vn(i.homepage):null,o=typeof i.help==`string`&&i.help.startsWith(`http`)?i.help.trim():null,s=typeof i.changelog==`string`&&i.changelog.startsWith(`http`)?i.changelog.trim():null,c=Un(i.repository),l=c?Hn(c):null,u=l&&l.includes(`http`)?l:null,d=a||u||n||null;return{homepage:d,help:o||(u?`${u}/blob/main/README.md`:null)||d||null,changelog:s||(u?`${u}/blob/main/CHANGELOG.md`:null)||d||null}}catch(e){return e instanceof DOMException&&e.name,null}},D=0,A=async()=>{for(;D<x.length;){if(t.signal.aborted)return;let e=D;D+=1;let r=x[e];if(!r||!C.has(r))continue;C.delete(r);let i=u.find(e=>e.name===r)?.homepage??null,a=await E(r,i);if(t.signal.aborted)return;a&&(d(e=>e.map(e=>e.name===r?{...e,homepage:a.homepage??e.homepage,help:a.help,changelog:a.changelog}:e)),h[r]={homepage:a.homepage,help:a.help,changelog:a.changelog,asOf:f},qn(h)),t.signal.aborted||await n(250)}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>A()));let j=`2020-01-01`,M=u.map(e=>e.name).filter(e=>{let t=m[e],n=!t||t.asOf!==f;return n||q&&console.log(`[SearchPluginsDialog] total downloads fetch skipped (cache fresh) for ${e} (asOf=${t.asOf}).`),n}),ee=new Set(M),te=M.length;S({done:0,total:te}),y(te>0);let ne=async e=>{let i=`https://api.npmjs.org/downloads/range/${j}:${f}/${encodeURIComponent(e)}`;for(let e=0;e<3;e+=1){let a=await fetch(i,{signal:t.signal});if(a.ok){let e=await a.json();return r(e)}if(a.status===404)return null;if(a.status===429){let t=a.headers.get(`retry-after`),r=t?Number(t):NaN,i=Number.isFinite(r)?r*1e3:2e3*(e+1);await n(i);continue}return null}return null},N=0,re=0,P=async()=>{for(;N<M.length;){if(t.signal.aborted)return;let e=N;N+=1;let r=M[e];if(r&&ee.has(r)){ee.delete(r);try{q&&console.log(`[SearchPluginsDialog] fetching total downloads for ${r} (range ${j}:${f})...`);let e=await ne(r);if(t.signal.aborted)return;q&&console.log(`[SearchPluginsDialog] total downloads fetched for ${r}:`,e),d(t=>t.map(t=>t.name===r?{...t,total:e}:t)),typeof e==`number`&&(m[r]={total:e,asOf:f},Gn(m),q&&console.log(`[SearchPluginsDialog] total downloads saved to localStorage for ${r} (asOf=${f}):`,e))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return}finally{re+=1,S({done:re,total:te}),t.signal.aborted||await n(500)}}}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>P())).finally(()=>{t.signal.aborted||y(!1)}),q&&console.log(`[SearchPluginsDialog] npm packages starting with "${e}" (filtered/sorted):`,u)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;console.error(`[SearchPluginsDialog] npm registry fetch error:`,e),w(e instanceof Error?e.message:String(e))}finally{p(!1)}})(),()=>t.abort()},[e,k]);let ee=async()=>{E();let e=s.current||a;if(!(!e||m))try{h(!0);let t=O(new Date),i=await k(e,t);q&&console.log(`[SearchPluginsDialog] passing versions to onVersions() for ${e} (${i.length.toString()}):`,i),r(i),h(!1),n(e)}catch(t){if(t instanceof DOMException&&t.name===`AbortError`)return;console.error(`[SearchPluginsDialog] npm versions fetch error:`,t),r([]),h(!1),n(e)}},te=()=>{E(),t(),r([])},ne=u.reduce((e,t)=>e+(typeof t.downloads==`number`?t.downloads:0),0),N=u.reduce((e,t)=>(typeof t.total==`number`&&(e.total+=t.total,e.hasAny=!0),e),{total:0,hasAny:!1}),P=_?` Totals: ${b.done.toString()}/${b.total.toString()} fetched`:``,ie=N.hasAny?A(N.total):`...`;return(0,Y.jsxs)(M,{open:e,onClose:()=>{E(),t()},maxWidth:!1,fullWidth:!0,slotProps:{paper:{sx:{width:J&&i?`100vw`:`75vw`,height:J&&i?`100vh`:`75vh`,maxWidth:J&&i?`100vw`:`75vw`,maxHeight:J&&i?`100vh`:`75vh`,margin:J&&i?`0px`:void 0,display:`flex`,flexDirection:`column`}}},children:[(0,Y.jsx)(F,{children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:`Search Plugins`})]})}),(0,Y.jsx)(x,{dividers:!0,sx:{padding:`10px`,flex:`1 1 auto`,minHeight:0},children:(0,Y.jsx)(`div`,{style:{height:`100%`,width:`100%`,display:`flex`,flexDirection:`column`,minHeight:0},children:f?(0,Y.jsx)(`div`,{style:{padding:`20px`},children:`Loading npm registry...`}):C?(0,Y.jsx)(`div`,{style:{padding:`20px`},children:C}):(0,Y.jsx)(wn,{name:`Search plugins`,rows:u,columns:j,getRowKey:`name`,onRowClick:(e,t,n)=>{s.current=e.name,o(e.name),n.detail===2&&ee()},footerLeft:`Total packages: ${u.length.toString()} Total downloads: ${A(ne)} / ${ie}${P}`,footerRight:a?`Selected: ${a}`:``})})}),(0,Y.jsxs)(D,{sx:{justifyContent:`center`,gap:1.5,flexWrap:`wrap`},children:[(0,Y.jsx)(V,{title:`Select the plugin and close the dialog. Double-click a row to select and close the dialog.`,children:(0,Y.jsx)(W,{variant:`contained`,onClick:ee,disabled:!(s.current||a)||m,children:`Select`})}),(0,Y.jsx)(V,{title:`Close the dialog without selecting a plugin.`,children:(0,Y.jsx)(W,{onClick:te,children:`Cancel`})})]})]})};function Zn(){let{mobile:e,showSnackbarMessage:t}=(0,G.useContext)(Wt),{logMessage:n,sendMessage:r,getUniqueId:i}=(0,G.useContext)(X),[a,o]=(0,G.useState)(`matterbridge-`),[s,c]=(0,G.useState)([`latest`,`dev`]),[l,d]=(0,G.useState)(`latest`),[f,p]=(0,G.useState)(!1),m=(0,G.useRef)(i()),h=e=>{let t=(e??``).trim();if(!t)return{name:``,specifier:null};if(t.startsWith(`@`)){let e=t.lastIndexOf(`@`);if(e>0){let n=t.slice(0,e),r=t.slice(e+1);if(n.includes(`/`)&&r)return{name:n,specifier:r}}return{name:t,specifier:null}}let n=t.indexOf(`@`);if(n>0){let e=t.slice(0,n),r=t.slice(n+1);return r?{name:e,specifier:r}:{name:e,specifier:null}}return{name:t,specifier:null}},g=()=>{let{name:e,specifier:t}=h(a);return e?t?`${e}@${t}`:l?`${e}@${l}`:e:``},_=e=>{e.preventDefault(),p(!0)},v=()=>{p(!1)},b=e=>{e.preventDefault(),p(!1);let t=e.dataTransfer.files[0];if(t){n(`Plugins`,`Installing package ${t.name}. Please wait...`);let e=new FormData;e.append(`file`,t),e.append(`filename`,t.name),fetch(`./api/uploadpackage`,{method:`POST`,body:e}).then(e=>e.text()).then(e=>{n(`Plugins`,`Server response: ${e}`)}).catch(e=>{console.error(`Error uploading plugin file:`,e),n(`Plugins`,`Error installing package ${e}`)})}},x=e=>{let t=e.target.files&&e.target.files[0];if(t){n(`Plugins`,`Uploading package ${t.name}`);let e=new FormData;e.append(`file`,t),e.append(`filename`,t.name),fetch(`./api/uploadpackage`,{method:`POST`,body:e}).then(e=>e.text()).then(e=>{n(`Plugins`,`Server response: ${e}`)}).catch(e=>{console.error(`Error uploading plugin file:`,e),n(`Plugins`,`Error uploading package ${e}`)})}},S=()=>{let e=g();if(e){if(Bn.includes(e.split(`@`)[0])){t(`Installation of plugin "${e}" is blocked by the ignore list.`);return}r({id:m.current,sender:`InstallPlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e,restart:!1}})}},C=()=>{r({id:m.current,sender:`InstallPlugins`,method:`/api/uninstall`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:a}})},w=()=>{document.getElementById(`file-upload`)?.click()},T=()=>{if(Bn.includes(a.split(`@`)[0])){t(`Addition of plugin "${a}" is blocked by the ignore list.`);return}r({id:m.current,sender:`InstallPlugins`,method:`/api/addplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginNameOrPath:a}})},E=e=>{e.preventDefault(),q&&console.log(`Right-clicked Upload button`)},D=e=>{e.preventDefault(),q&&console.log(`Right-clicked Add button`)},[O,k]=(0,G.useState)(!1),A=()=>{k(!0),q&&console.log(`Dialog opened for selection`)},j=()=>{o(`matterbridge-`),k(!1),q&&console.log(`Dialog closed without selection`)},M=e=>{o(e),k(!1),q&&console.log(`Select plugin:`,e)},N=e=>{c(e),d(e.includes(`latest`)?`latest`:e[0]??``),q&&console.log(`Select plugin versions:`,e)},[re,P]=(0,G.useState)(!1);return q&&console.log(`HomeInstallAddPlugins rendering...`),re?null:(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(Jt,{children:[(0,Y.jsx)(Yt,{children:`Install plugins`}),(0,Y.jsx)(en,{close:()=>P(!0)})]}),(0,Y.jsxs)($t,{onDragOver:_,onDragLeave:v,onDrop:b,style:J&&e?{flexWrap:`wrap`,alignItems:`center`,gap:`10px`}:{flexWrap:`wrap`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(Xn,{open:O,onClose:j,onSelect:M,onVersions:N}),(0,Y.jsxs)(`div`,{style:{flex:`1 1 auto`,display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(V,{title:`Provide the npm name or the local path of the plugin to install, uninstall, or add`,children:(0,Y.jsx)(H,{value:a,onChange:e=>{let t=e.target.value;c([`latest`,`dev`]),d(`latest`),o(t)},size:`small`,id:`plugin-name`,label:`Plugin name or plugin path`,variant:`outlined`,fullWidth:!0})}),s.length>0&&(0,Y.jsx)(V,{title:`Select the npm tag/version to install`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsxs)(te,{size:`small`,style:{minWidth:`150px`},children:[(0,Y.jsx)(y,{id:`plugin-version-label`,children:`Tag or version`}),(0,Y.jsx)(it,{labelId:`plugin-version-label`,id:`plugin-version`,value:l,label:`Tag or version`,onChange:e=>d(e.target.value??``),sx:{"& .MuiSelect-icon":{color:`var(--main-label-color)`}},children:s.map(e=>(0,Y.jsx)(z,{value:e,children:e},e))})]})})}),(0,Y.jsx)(V,{title:`Search on npm the plugin to install`,children:(0,Y.jsx)(L,{size:`large`,onClick:A,children:(0,Y.jsx)(Le,{fontSize:`inherit`})})})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(V,{title:`Install or update a plugin from npm`,children:(0,Y.jsxs)(W,{onClick:S,endIcon:(0,Y.jsx)(Fe,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Install`]})}),(0,Y.jsx)(V,{title:`Uninstall and remove a plugin`,children:(0,Y.jsxs)(W,{onClick:C,endIcon:(0,Y.jsx)(ee,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Uninstall`]})}),(0,Y.jsx)(V,{title:`Upload and install a plugin from a tarball`,children:(0,Y.jsxs)(W,{onClick:w,onContextMenu:E,endIcon:(0,Y.jsx)(u,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Upload`]})}),(0,Y.jsx)(V,{title:`Add an already installed plugin or a plugin from a local path`,children:(0,Y.jsxs)(W,{onClick:T,onContextMenu:D,endIcon:(0,Y.jsx)(ne,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Add`]})}),(0,Y.jsx)(`input`,{id:`file-upload`,type:`file`,accept:`.tgz`,style:{display:`none`},onChange:x})]})]})]})}var Qn=(0,G.memo)(Zn),$n=()=>{let e=window;return`ontouchstart`in window||e.DocumentTouch!==void 0&&document instanceof e.DocumentTouch?(q&&console.log(`WebSocketLogs detectTouchscreen = true`),!0):(q&&console.log(`WebSocketLogs detectTouchscreen = false`),!1)};function er(){let{messages:e,logAutoScroll:t}=(0,G.useContext)(Gt),[n,r]=(0,G.useState)(!1),i=(0,G.useRef)(null),a=(0,G.useRef)(0),o=(0,G.useRef)(null),s=(0,G.useMemo)(()=>$n(),[]),c=()=>r(!0),l=()=>r(!1);(0,G.useEffect)(()=>{if(q&&console.log(`WebSocketLogs logAutoScroll: ${t.current} isHovering: ${n}`),t.current&&!n&&!s){let e=Date.now();e-a.current>=500?(q&&console.log(`WebSocketLogs auto-scroll to bottom`),a.current=e,i.current?.scrollIntoView({behavior:`smooth`,block:`end`})):(q&&console.log(`WebSocketLogs auto-scroll skipped to avoid flicker`),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{i.current?.scrollIntoView({behavior:`smooth`}),a.current=Date.now()},1e3))}},[e,t,n,s]);let u=e=>{switch(e.toLowerCase()){case`debug`:return`gray`;case`info`:return`#267fb7`;case`notice`:return`green`;case`warn`:return`#e9db18`;case`error`:return`red`;case`fatal`:return`#ff0000`;case`spawn`:return`#ff00d0`;default:return`#5c0e91`}},d=e=>{switch(e.toLowerCase()){case`warn`:return`black`;default:return`white`}};return(0,Y.jsx)(`div`,{style:{margin:`0px`,padding:`0px`},onMouseEnter:c,onMouseLeave:l,children:(0,Y.jsxs)(`ul`,{style:{margin:`0px`,padding:`0px`},children:[e.map((e,t)=>(0,Y.jsxs)(`li`,{style:{wordWrap:`break-word`,maxHeight:`200px`,overflow:`hidden`},children:[(0,Y.jsx)(`span`,{style:{marginRight:`5px`,padding:`1px 5px`,backgroundColor:u(e.level),color:d(e.level),fontSize:`12px`,borderRadius:`3px`,textAlign:`center`},children:e.level}),e.time&&(0,Y.jsx)(`span`,{style:{marginRight:`3px`,color:`#505050`},children:`[`+e.time+`]`}),e.name&&(0,Y.jsx)(`span`,{style:{marginRight:`3px`,color:`#09516d`},children:`[`+e.name+`]`}),(0,Y.jsx)(`span`,{style:{color:`var(--main-log-color)`},children:e.message})]},t)),(0,Y.jsx)(`div`,{ref:i})]})})}var tr=(0,G.memo)(er);function nr(){let[e,t]=(0,G.useState)(localStorage.getItem(K.logFilterLevel)??`info`),[n,r]=(0,G.useState)(localStorage.getItem(K.logFilterSearch)??`*`),{online:i,logAutoScroll:a}=(0,G.useContext)(X);return q&&console.log(`HomeLogs rendering...`),i?(0,Y.jsxs)(Q,{style:{flex:`1 1 auto`},children:[(0,Y.jsxs)(Jt,{children:[(0,Y.jsx)(Yt,{children:`Logs`}),(0,Y.jsxs)(Yt,{style:{fontWeight:`normal`,fontSize:`12px`,marginTop:`2px`},children:[`Filter: logger level "`,e,`" and search "`,n===``?`*`:n,`" Scroll: `,a.current?`auto`:`manual`]})]}),(0,Y.jsx)($t,{style:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`10px`,alignItems:`start`},children:(0,Y.jsx)(tr,{})})]}):(0,Y.jsx)(qt,{})}var rr=(0,G.memo)(nr);function ir(e){return e.id!==0&&e.src===`Matterbridge`&&e.dst===`Frontend`}var ar={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},or={fontSize:`12px`,fontWeight:`normal`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},sr={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},cr={fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`,backgroundColor:`var(--div-bg-color)`},lr={fontSize:`16px`,fontWeight:`bold`,backgroundColor:`var(--div-bg-color)`},ur={padding:`0px`,margin:`0px`},dr=`5px 10px 5px 10px`,fr={},pr={},mr={},hr={},gr=[],_r=[],vr=[];function yr(e,t){let n=e?.properties;if(!n||typeof n!=`object`)return!1;let r=n[t];return!r||typeof r!=`object`?!1:typeof r.type==`string`}function br(e){let t=e.items;return t!==void 0&&typeof t==`object`&&!Array.isArray(t)}function xr(e,t){let n=e?.properties;if(!n||typeof n!=`object`)return!1;let r=n[t];if(!r||typeof r!=`object`||r.type!==`array`||r.uniqueItems!==!0)return!1;let i=r.items;return i!==void 0&&typeof i==`object`&&!Array.isArray(i)&&Array.isArray(i.enum)}var Sr=({open:e,onClose:t,plugin:n})=>{let{sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(X),s=(0,G.useRef)(o()),c=(0,G.useRef)({}),l=(0,G.useRef)({}),[u,d]=(0,G.useState)(n.configJson),[f,m]=(0,G.useState)(n.schemaJson),[g,_]=(0,G.useState)({"ui:submitButtonOptions":{submitText:`Confirm`},"ui:globalOptions":{orderable:!0}}),v=(0,G.useRef)(``),y=n.configJson;(0,G.useEffect)(()=>{let e=e=>{e.src===`Matterbridge`&&e.dst===`Frontend`&&(ir(e)&&e.id===s.current&&e.method===`/api/select/devices`&&e.response&&(q&&console.log(`ConfigPluginDialog (id: ${e.id}) received ${e.response.length} /api/select/devices:`,e.response),_r=e.response),ir(e)&&e.id===s.current&&e.method===`/api/select/entities`&&e.response&&(q&&console.log(`ConfigPluginDialog (id: ${e.id}) received ${e.response.length} /api/select/entities:`,e.response),vr=e.response))};if(i(e,s.current),q&&console.log(`ConfigPluginDialog added WebSocket listener id:`,s.current),q&&console.log(`ConfigPluginDialog mounting...`),q&&console.log(`ConfigPluginDialog mounting with form:`,u),q&&console.log(`ConfigPluginDialog mounting with schema:`,f),q&&console.log(`ConfigPluginDialog mounting with uiSchema:`,g),u&&f&&f.properties){let e=(t,n,r=[])=>{!t||typeof t!=`object`||(t.properties&&Object.keys(t.properties).forEach(i=>{let a=t.properties?.[i],o=[...r,i];Object.keys(a).forEach(e=>{if(e.startsWith(`ui:`)){let t=n;o.forEach(e=>{t[e]||(t[e]={}),t=t[e]}),t[e]=a[e],delete a[e]}}),e(a,n,o)}),[`oneOf`,`anyOf`,`allOf`].forEach(i=>{Array.isArray(t[i])&&t[i].forEach(t=>{e(t,n,r)})}),t.items&&typeof t.items==`object`&&e(t.items,n,r))};e(f,g),_(g),c.current=f,l.current=g}return n.name&&n.configJson&&n.schemaJson&&(d(n.configJson),m(n.schemaJson),r({id:s.current,sender:`ConfigPlugin`,method:`/api/select/devices`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name}}),r({id:s.current,sender:`ConfigPlugin`,method:`/api/select/entities`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name}}),q&&console.log(`HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:`,n.name)),()=>{a(e),q&&console.log(`ConfigPluginDialog removed WebSocket listener`)}},[i,u,n,a,f,r,g]);let b=(e,t)=>{y=e.formData},S=e=>{q&&console.log(`ConfigPluginDialog handleSaveChanges:`,e.formData),d(e.formData),n.configJson=e.formData,n.restartRequired=!0,r({id:s.current,sender:`ConfigPlugin`,method:`/api/savepluginconfig`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.formData.name,formData:e.formData}}),t()};function C(e){let{id:t,label:n,onKeyRenameBlur:r,onRemoveProperty:i,disabled:a,schema:o,children:s,registry:c,readonly:l,required:u}=e,{templates:d}=c,{RemoveButton:f}=d.ButtonTemplates,m=wt in o,h=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let e=v.current;!m||e===``||!/^newKey(?:-\d+)?$/.test(n)||!h.current||(q&&console.log(`WrapIfAdditionalTemplate: renaming additional property "${n}" to "${e}"`),h.current.value=e,r({target:h.current}),v.current=``)},[m,n,r]),m?(0,Y.jsxs)(p,{sx:{display:`flex`,flexDirection:`row`,flexGrow:1,padding:0,margin:0,border:`none`},children:[(0,Y.jsx)(H,{id:`${t}-key`,name:`${t}-key`,required:u,disabled:a||l,defaultValue:n,inputRef:h,onBlur:l?void 0:r,type:`text`,variant:`outlined`,sx:{width:`250px`,minWidth:`250px`,maxWidth:`250px`,marginRight:`20px`}}),(0,Y.jsx)(p,{sx:{flex:1},children:s}),(0,Y.jsx)(f,{disabled:a||l,onClick:i,registry:c})]}):(0,Y.jsx)(p,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:s})}function w(e){let{children:t,description:n,displayLabel:r,errors:i,help:a,hidden:o,registry:s,uiSchema:c}=e,l=Ct(`WrapIfAdditionalTemplate`,s,St(c));return o?(0,Y.jsx)(`div`,{style:{display:`none`},children:t}):(0,Y.jsx)(p,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:(0,Y.jsxs)(l,{...e,children:[r===!0&&n,t,i,a]})})}function T(e){let{description:t}=e;return t?(0,Y.jsx)(R,{sx:or,children:t}):null}function E(e){let{required:t,title:n}=e;return n?(0,Y.jsx)(p,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,Y.jsxs)(R,{sx:ar,children:[`Title `,n,` `,t&&(0,Y.jsx)(`mark`,{children:`***`})]})}):null}function O(e){let{help:t}=e;return t?(0,Y.jsx)(p,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,Y.jsx)(R,{sx:cr,children:t})}):null}function k(e){let{errors:t}=e;return t?(0,Y.jsxs)(p,{sx:{padding:`10px`,margin:`10px`,border:`1px solid grey`},children:[(0,Y.jsx)(R,{color:`error`,sx:lr,children:`Please fix the following errors:`}),(0,Y.jsx)(ue,{children:t.map((e,t)=>(0,Y.jsxs)(h,{children:[(0,Y.jsx)(I,{children:(0,Y.jsx)(Ve,{color:`error`})}),(0,Y.jsx)(U,{primary:e.stack})]},t))})]}):null}function A(e){let{errors:t}=e;return t?(0,Y.jsx)(p,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:t.map((e,t)=>(0,Y.jsxs)(R,{color:`error`,variant:`body2`,sx:{marginLeft:1},children:[`This field `,e]},t))}):null}function j(e){let{id:t,name:n,_schema:r,_uiSchema:i,value:a,options:o,label:s,type:c,placeholder:l,required:u,disabled:d,readonly:f,autofocus:m,onChange:h,onChangeOverride:g,onBlur:_,onFocus:v,_rawErrors:y,_hideError:b,_registry:x,_formContext:S}=e;return(0,Y.jsx)(p,{sx:{padding:`0px`,margin:`0px`},children:(0,Y.jsx)(H,{id:t,name:t,label:l&&l!==``?s:void 0,variant:`outlined`,placeholder:l&&l!==``?l:s,required:u,disabled:d||f,autoFocus:m,value:a||a===0?a:``,type:c,autoComplete:c===`password`?`current-password`:n,onChange:g||(({target:{value:e}})=>h(e===``?o.emptyValue:e)),onBlur:({target:e})=>_(t,e&&e.value),onFocus:({target:e})=>v(t,e&&e.value),fullWidth:!0})})}function ee(e){return console.log(`ArrayFieldTitleTemplate:`,e),null}function te(e){return console.log(`ArrayFieldDescriptionTemplate:`,e),null}function N(e){let{buttonsProps:t,children:n}=e;return(0,Y.jsxs)(p,{sx:{margin:`2px 0px`,padding:`0px`,display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(p,{sx:{flexGrow:1,marginRight:`10px`},children:n}),(0,Y.jsx)(L,{disabled:!t.hasMoveUp,onClick:t.onMoveUpItem,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(we,{})}),(0,Y.jsx)(L,{disabled:!t.hasMoveDown,onClick:t.onMoveDownItem,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(De,{})}),t.hasRemove&&(0,Y.jsx)(L,{onClick:t.onRemoveItem,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(ke,{})})]})}function re(e){let{canAdd:t,onAddClick:n,schema:r,title:i,formData:a}=e,[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),[f,m]=(0,G.useState)(``),h=e=>{m(e.target.value)},g=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogDeviceToggle filter:`,f,`selectDevices:`,_r),s(!o)},_=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogEntityToggle filter:`,f,`selectEntities:`,vr),l(!c)},v=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:`,f,`selectDevices:`,_r),d(!u)},y=e=>{s(!1),r.selectFrom===`serial`&&br(r)?r.items.default=e.serial:r.selectFrom===`name`&&br(r)&&(r.items.default=e.name),n()},b=e=>{l(!1),r.selectEntityFrom===`name`&&br(r)?r.items.default=e.name:r.selectEntityFrom===`description`&&br(r)&&(r.items.default=e.description),n()},S=e=>{d(!1),r.selectDeviceEntityFrom===`name`&&br(r)?r.items.default=e.name:r.selectDeviceEntityFrom===`description`&&br(r)&&(r.items.default=e.description),n()};return(0,Y.jsxs)(p,{sx:{margin:`0px`,padding:`5px 10px 5px 10px`,border:`1px solid grey`},children:[i&&(0,Y.jsxs)(p,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[i&&(0,Y.jsx)(R,{sx:ar,children:i}),t&&(0,Y.jsxs)(p,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[r.selectFrom&&(0,Y.jsx)(V,{title:`Add a device from the list`,children:(0,Y.jsx)(L,{onClick:g,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(tt,{})})}),r.selectEntityFrom&&(0,Y.jsx)(V,{title:`Add an entity from the list`,children:(0,Y.jsx)(L,{onClick:_,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(tt,{})})}),r.selectDeviceEntityFrom&&(0,Y.jsx)(V,{title:`Add a device entity from the list`,children:(0,Y.jsx)(L,{onClick:v,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(tt,{})})}),(0,Y.jsx)(V,{title:`Add a new item`,children:(0,Y.jsx)(L,{onClick:n,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(ne,{})})})]})]}),r.description&&(0,Y.jsx)(R,{sx:or,children:r.description}),e.items,(0,Y.jsxs)(M,{open:o,onClose:g,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsx)(F,{children:`Select a device`}),(0,Y.jsxs)(x,{children:[(0,Y.jsxs)(p,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,Y.jsx)(R,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,Y.jsx)(H,{fullWidth:!0,variant:`outlined`,value:f,onChange:h,placeholder:`Enter serial or name`})]}),(0,Y.jsx)(ue,{dense:!0,children:_r.filter(e=>e.serial.toLowerCase().includes(f.toLowerCase())||e.name.toLowerCase().includes(f.toLowerCase())).filter(e=>!r.uniqueItems||!a.includes(r.selectFrom===`serial`?e.serial:e.name)).map((e,t)=>(0,Y.jsxs)(ot,{onClick:()=>y(e),sx:fr,children:[e.icon===`wifi`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(oe,{style:pr})}),e.icon===`ble`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(ve,{style:pr})}),e.icon===`hub`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(Ke,{style:pr})}),(0,Y.jsx)(U,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:mr},secondaryTypographyProps:{style:hr}})]},t))})]}),(0,Y.jsx)(D,{children:(0,Y.jsx)(W,{onClick:g,children:`Close`})})]}),(0,Y.jsxs)(M,{open:c,onClose:_,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsx)(F,{children:`Select an entity`}),(0,Y.jsxs)(x,{children:[(0,Y.jsxs)(p,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,Y.jsx)(R,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,Y.jsx)(H,{fullWidth:!0,variant:`outlined`,value:f,onChange:h,placeholder:`Enter name or description`})]}),(0,Y.jsx)(ue,{dense:!0,children:vr.filter(e=>e.name.toLowerCase().includes(f.toLowerCase())||e.description.toLowerCase().includes(f.toLowerCase())).filter(e=>!r.uniqueItems||!a.includes(r.selectEntityFrom===`name`?e.name:e.description)).map((e,t)=>(0,Y.jsxs)(ot,{onClick:()=>b(e),sx:fr,children:[e.icon===`wifi`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(oe,{style:pr})}),e.icon===`ble`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(ve,{style:pr})}),e.icon===`hub`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(Ke,{style:pr})}),e.icon===`component`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(ze,{style:pr})}),e.icon===`matter`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(je,{style:pr})}),(0,Y.jsx)(U,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:mr},secondaryTypographyProps:{style:hr}})]},t))})]}),(0,Y.jsx)(D,{children:(0,Y.jsx)(W,{onClick:_,children:`Close`})})]}),(0,Y.jsxs)(M,{open:u,onClose:v,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsxs)(F,{children:[`Select an entity for `,i]}),(0,Y.jsx)(x,{children:(0,Y.jsx)(ue,{dense:!0,children:_r.filter(e=>e.serial===i||e.name===i).map(e=>e.entities?.filter(e=>!r.uniqueItems||!Array.isArray(a)||!a.includes(r.selectDeviceEntityFrom===`name`?e.name:e.description)).map((e,t)=>(0,Y.jsxs)(ot,{onClick:()=>S(e),sx:fr,children:[e.icon===`wifi`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(oe,{style:pr})}),e.icon===`ble`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(ve,{style:pr})}),e.icon===`hub`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(Ke,{style:pr})}),e.icon===`component`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(ze,{style:pr})}),e.icon===`matter`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(je,{style:pr})}),(0,Y.jsx)(U,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:mr},secondaryTypographyProps:{style:hr}})]},t)))})}),(0,Y.jsx)(D,{children:(0,Y.jsx)(W,{onClick:v,children:`Close`})})]})]})}function P(e){let{onAddProperty:t,schema:n,properties:r,title:i,description:a}=e,[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(``),u=e=>{l(e.target.value)},d=()=>{s(!o)},f=e=>{q&&console.log(`ObjectFieldTemplate: handleSelectValue value "${e.serial}" for schema "${n.selectFrom}"`),s(!1);let r=``;n.selectFrom===`serial`?r=e.serial:n.selectFrom===`name`&&(r=e.name),v.current=r,q&&console.log(`ObjectFieldTemplate: handleSelectValue pendingAdditionalPropertyKey "${r}"`),t()},m=()=>{t()},h=!n.additionalProperties;return q&&console.log(`ObjectFieldTemplate: isRoot ${h} pendingAdditionalPropertyKey "${v.current}"`),(0,Y.jsxs)(p,{sx:{margin:`0px`,padding:h?`10px`:`5px 10px 0px 10px`,border:h?`none`:`1px solid grey`},children:[n.title&&h&&(0,Y.jsx)(p,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,Y.jsx)(R,{sx:ar,children:n.title})}),i&&!h&&(0,Y.jsxs)(p,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[(0,Y.jsx)(R,{sx:ar,children:i}),(0,Y.jsxs)(p,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[n.selectFrom&&(0,Y.jsx)(V,{title:`Add a device from the list`,children:(0,Y.jsx)(L,{onClick:d,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(tt,{})})}),(0,Y.jsx)(V,{title:`Add a new item`,children:(0,Y.jsx)(L,{onClick:m,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(ne,{})})})]})]}),n.description&&(0,Y.jsx)(p,{sx:{padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,Y.jsx)(R,{sx:or,children:n.description})}),r.map(({content:e,name:t,hidden:r})=>{if(r)return null;let i=yr(n,t),a=xr(n,t),o=i&&[`object`,`array`].includes(n.properties[t].type);return(0,Y.jsxs)(p,{sx:{margin:`0px`,marginBottom:`10px`,padding:o&&!a?`0px`:dr,border:o&&!a?`none`:`1px solid grey`},children:[i&&![`object`,`array`,`boolean`].includes(n.properties[t].type)&&(0,Y.jsx)(R,{sx:ar,children:n.properties[t].title||t}),a&&(0,Y.jsx)(R,{sx:ar,children:n.properties[t].title||t}),(0,Y.jsx)(p,{sx:{flexGrow:1,padding:`0px`,margin:`0px`},children:e})]},t)}),(0,Y.jsxs)(M,{open:o,onClose:d,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsx)(F,{children:`Select a device`}),(0,Y.jsxs)(x,{children:[(0,Y.jsxs)(p,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,Y.jsx)(R,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,Y.jsx)(H,{fullWidth:!0,variant:`outlined`,value:c,onChange:u,placeholder:`Enter serial or name`})]}),(0,Y.jsx)(ue,{dense:!0,children:_r.filter(e=>e.serial.toLowerCase().includes(c.toLowerCase())||e.name.toLowerCase().includes(c.toLowerCase())).map((e,t)=>(0,Y.jsxs)(ot,{onClick:()=>f(e),sx:fr,children:[e.icon===`wifi`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(oe,{style:pr})}),e.icon===`ble`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(ve,{style:pr})}),e.icon===`hub`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(Ke,{style:pr})}),(0,Y.jsx)(U,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:mr},secondaryTypographyProps:{style:hr}})]},t))})]}),(0,Y.jsx)(D,{children:(0,Y.jsx)(W,{onClick:d,children:`Close`})})]})]})}function ie(e){let{uiSchema:n}=e,{submitText:r,norender:i}=xt(n);return i?null:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,margin:`10px`,padding:`0px`,gap:`20px`},children:[(0,Y.jsx)(W,{type:`submit`,variant:`contained`,color:`primary`,children:r}),(0,Y.jsx)(W,{variant:`contained`,color:`primary`,onClick:t,children:`Cancel`})]})}function ae(e){let{className:t,disabled:n,onClick:r,registry:i,style:a,uiSchema:o,...s}=e;return(0,Y.jsx)(V,{title:`Remove the item`,children:(0,Y.jsx)(L,{disabled:n,size:`small`,color:`primary`,onClick:r,children:(0,Y.jsx)(ke,{})})})}function ce(e){let{className:t,disabled:n,onClick:r,registry:i,uiSchema:a,...o}=e;return(0,Y.jsx)(V,{title:`Add an item`,children:(0,Y.jsx)(L,{size:`small`,color:`primary`,onClick:r,children:(0,Y.jsx)(ne,{})})})}function le(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,Y.jsx)(V,{title:`Move up the item`,children:(0,Y.jsx)(L,{size:`small`,color:`primary`,onClick:n,children:(0,Y.jsx)(we,{})})})}function de(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,Y.jsx)(V,{title:`Move down the item`,children:(0,Y.jsx)(L,{size:`small`,color:`primary`,onClick:n,children:(0,Y.jsx)(De,{})})})}function fe(e){let{id:i,name:a,value:o,schema:c,readonly:l,onChange:d}=e,[f,m]=(0,G.useState)(),h=e=>{q&&console.log(`CheckboxWidget ${a} onChangeField:`,e),m(e&&e!==``?e:void 0)},g=()=>{q&&console.log(`CheckboxWidget onClick plugin="${n.name}" action="${a}" value="${f}"`),r({id:s.current,sender:`ConfigPlugin`,method:`/api/action`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name,action:a,value:f,formData:y,id:i}}),c.buttonClose===!0?t():c.buttonSave===!0&&S({formData:u})};return c.buttonText&&(c.title||c.description)?(0,Y.jsxs)(p,{sx:{margin:`0px`,padding:`5px 0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Y.jsx)(R,{sx:sr,children:c.title||c.description}),(0,Y.jsx)(W,{variant:`contained`,color:`primary`,onClick:()=>g(),children:c.buttonText})]}):c.buttonField&&(c.title||c.description)?(0,Y.jsxs)(p,{sx:{margin:`0px`,padding:`5px 0px`,gap:`20px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Y.jsx)(R,{sx:sr,children:c.title||c.description}),(0,Y.jsx)(H,{id:a+`-input`,name:a,label:c.textLabel,placeholder:c.textPlaceholder,onChange:e=>h(e.target.value),sx:{width:`250px`,minWidth:`250px`,maxWidth:`250px`}}),(0,Y.jsx)(W,{id:a+`-button`,variant:`contained`,color:`primary`,disabled:f===void 0,onClick:()=>g(),children:c.buttonField})]}):(0,Y.jsxs)(p,{sx:{margin:`0px`,padding:`0px`},children:[a&&(0,Y.jsxs)(p,{sx:{margin:`0px`,padding:`0px`,gap:`10px`,display:`flex`,justifyContent:`flex-start`,alignItems:`center`},children:[(0,Y.jsx)(R,{sx:ar,children:c.title||a}),(0,Y.jsx)(se,{checked:o,readOnly:l,onChange:()=>d(!o),sx:{padding:`0px`,margin:`0px`}})]}),c.description&&(0,Y.jsx)(R,{sx:or,children:c.description})]})}function pe({schema:e,id:t,name:n,options:r,label:i,hideLabel:a,required:o,disabled:s,placeholder:c,readonly:l,value:u,multiple:d,autofocus:f,onChange:p,onBlur:m,onFocus:h,errorSchema:g,rawErrors:_=gr,registry:v,uiSchema:y,hideError:b,...x}){let{enumOptions:S,enumDisabled:C,emptyValue:w}=r,T=d?[]:``,E=u===void 0||d&&u.length<1||!d&&u===T,D=({target:{value:e}})=>p(Ot(e,S,w)),O=({target:e})=>m(t,Ot(e&&e.value,S,w)),k=({target:e})=>h(t,Ot(e&&e.value,S,w)),A=Et(u,S,d);return(0,Y.jsx)(H,{id:t,name:n,value:!E&&A!==void 0?A:T,required:o,disabled:s||l,autoFocus:f,error:_.length>0,onChange:D,onBlur:O,onFocus:k,select:!0,slotProps:{select:{multiple:d,...d?{renderValue:e=>!Array.isArray(e)||!Array.isArray(S)?``:e.map(e=>S[Number(e)]?.label).filter(e=>typeof e==`string`).join(`, `)}:{}}},"aria-describedby":Dt(t),children:Array.isArray(S)&&S.map(({value:e,label:t},n)=>{let r=Array.isArray(C)&&C.indexOf(e)!==-1,i=Array.isArray(A)&&A.includes(String(n));return(0,Y.jsxs)(z,{value:String(n),disabled:r,children:[d&&(0,Y.jsx)(I,{sx:{minWidth:`32px`},children:(0,Y.jsx)(se,{checked:i,disableRipple:!0,tabIndex:-1,sx:{padding:`0px`,margin:`0px`}})}),t]},n)})})}return q&&console.log(`ConfigPluginDialog rendering...`),!e||!f||!u?null:(0,Y.jsxs)(M,{open:e,onClose:t,slotProps:{paper:{sx:{maxWidth:`800px`}}},children:[(0,Y.jsx)(F,{gap:`20px`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h3`,{children:`Matterbridge plugin configuration`})]})}),(0,Y.jsx)(x,{style:{padding:`0px`,margin:`0px`,width:`800px`,height:`600px`,overflow:`auto`},children:(0,Y.jsx)(kt,{schema:f,formData:u,uiSchema:g,validator:Tt,templates:{FieldTemplate:w,BaseInputTemplate:j,TitleFieldTemplate:E,DescriptionFieldTemplate:T,FieldHelpTemplate:O,FieldErrorTemplate:A,ErrorListTemplate:k,WrapIfAdditionalTemplate:C,ArrayFieldTitleTemplate:ee,ArrayFieldDescriptionTemplate:te,ArrayFieldItemTemplate:N,ArrayFieldTemplate:re,ObjectFieldTemplate:P,ButtonTemplates:{SubmitButton:ie,RemoveButton:ae,AddButton:ce,MoveUpButton:le,MoveDownButton:de}},widgets:{CheckboxWidget:fe,SelectWidget:pe},onChange:b,onSubmit:S})})]})};function Cr({status:e,enabledText:t=`Enabled`,disabledText:n,tooltipText:r}){if(e===void 0)return null;{let i=(0,Y.jsx)(`div`,{className:e?`status-enabled`:`status-disabled`,style:{cursor:`default`},children:e?t:n??t});return r===void 0?i:(0,Y.jsx)(V,{title:r,children:i})}}function wr({storeId:e,setStoreId:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(X),{mobile:s,showConfirmCancelDialog:c}=(0,G.useContext)(Wt),l=(0,G.useRef)(o()),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(null),[h,_]=(0,G.useState)([]),[v,y]=(0,G.useState)(null),[b,S]=(0,G.useState)(`inactive`),C=[{label:`Name`,id:`name`,required:!0,render:(e,t,n,r)=>(0,Y.jsx)(V,{title:n.local===!0?`Local plugin path: ${n.path}`:`Plugin path ${n.path}`,children:(0,Y.jsxs)(`button`,{type:`button`,style:{cursor:`pointer`,background:`none`,border:`none`,margin:0,padding:0,font:`inherit`,color:`inherit`,textAlign:`left`,display:`flex`,alignItems:`center`,gap:`4px`},onClick:()=>N(n),children:[n.name,n.local===!0&&(0,Y.jsx)(at,{style:{width:`14px`,height:`14px`,color:`var(--primary-color)`}})]})})},{label:`Description`,id:`description`,render:(e,t,n,r)=>(0,Y.jsx)(V,{title:`Open the plugin homepage`,children:(0,Y.jsx)(`button`,{type:`button`,style:{cursor:`pointer`,background:`none`,border:`none`,padding:0,font:`inherit`,color:`inherit`,textAlign:`left`},onClick:()=>N(n),children:n.description})})},{label:`Version`,id:`version`,render:(e,t,n,r)=>(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(V,{title:`Plugin v.${n.version}`,children:(0,Y.jsx)(`span`,{children:n.version.split(`-`)[0]+(n.version.includes(`-dev-`)?`@dev`:``)+(n.version.includes(`-git-`)?`@git`:``)})})})},{label:`Author`,id:`author`,render:(e,t,n,r)=>(0,Y.jsx)(Y.Fragment,{children:n.author?n.author.replace(`https://github.com/`,``):`Unknown`})},{label:`Type`,id:`type`,render:(e,t,n,r)=>(0,Y.jsx)(Y.Fragment,{children:n.type?n.type.replace(`Platform`,``):`Unknown`})},{label:`Devices`,id:`registeredDevices`},{label:`Actions`,id:`actions`,required:!0,noSort:!0,render:(e,n,r,i)=>(0,Y.jsxs)(`div`,{style:{margin:`0px`,padding:`0px`,gap:`4px`,display:`flex`,flexDirection:`row`},children:[f&&f.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,Y.jsx)(V,{title:`Shows the QRCode or the fabrics`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:In(r.matter)},onClick:()=>{r.matter?.id&&t(r.matter?.id)},size:`small`,children:(0,Y.jsx)(ie,{})})}),f&&f.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,Y.jsx)(V,{title:`Restart the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`},onClick:()=>te(r),size:`small`,children:(0,Y.jsx)(st,{})})}),(0,Y.jsx)(V,{title:`Plugin config`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{disabled:r.restartRequired===!0,style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>R(r),size:`small`,children:(0,Y.jsx)(B,{})})}),f&&!f.readOnly&&(0,Y.jsx)(V,{title:`Remove the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{T(`Remove plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`remove`,r)},size:`small`,children:(0,Y.jsx)(ee,{})})}),r.enabled?(0,Y.jsx)(V,{title:`Disable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{T(`Disable plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`disable`,r)},size:`small`,children:(0,Y.jsx)(rt,{})})}):(0,Y.jsx)(Y.Fragment,{}),r.enabled?(0,Y.jsx)(Y.Fragment,{}):(0,Y.jsx)(V,{title:`Enable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>ne(r),size:`small`,children:(0,Y.jsx)(ce,{})})}),(0,Y.jsx)(V,{title:`Open the plugin help`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>F(r),size:`small`,children:(0,Y.jsx)(re,{})})}),(0,Y.jsx)(V,{title:`Open the plugin version history`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>ae(r),size:`small`,children:(0,Y.jsx)(g,{})})}),r.enabled&&r.frontendPath&&(0,Y.jsx)(V,{title:`Open the plugin frontend`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>oe(r),size:`small`,children:(0,Y.jsx)(m,{})})}),r.local!==!0&&r.latestVersion!==void 0&&r.latestVersion!==r.version&&f&&!f.readOnly&&(0,Y.jsx)(V,{title:`Update the plugin to the latest version v.${r.latestVersion}`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{color:`var(--primary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>k(r),size:`small`,children:(0,Y.jsx)(ct,{})})}),r.local!==!0&&(r.version.includes(`-dev-`)||r.version.includes(`-git-`))&&r.devVersion!==void 0&&r.devVersion!==r.version&&f&&!f.readOnly&&(0,Y.jsx)(V,{title:`Update the plugin to the latest dev version v.${r.devVersion}`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{color:`var(--secondary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>A(r),size:`small`,children:(0,Y.jsx)(ct,{})})}),f&&!f.readOnly&&(0,Y.jsx)(V,{title:`Sponsor the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`#b6409c`},onClick:()=>P(r),size:`small`,children:(0,Y.jsx)(le,{})})})]})},{label:`Status`,id:`status`,required:!0,noSort:!0,render:(e,t,n,r)=>(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,flex:`1 1 auto`,margin:`0`,padding:`0`,gap:`5px`,width:`auto`,maxWidth:`max-content`},children:n.error?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(Cr,{status:!1,enabledText:`Error`,disabledText:`Error`,tooltipText:`The plugin is in error state. Check the log!`})}):(0,Y.jsx)(Y.Fragment,{children:n.enabled?(0,Y.jsx)(Y.Fragment,{children:n.loaded&&n.started&&n.configured?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(Cr,{status:n.loaded,enabledText:`Running`,tooltipText:`Whether the plugin is running`})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Cr,{status:n.loaded,enabledText:`Loaded`,tooltipText:`Whether the plugin has been loaded`}),(0,Y.jsx)(Cr,{status:n.started,enabledText:`Started`,tooltipText:`Whether the plugin started`}),(0,Y.jsx)(Cr,{status:n.configured,enabledText:`Configured`,tooltipText:`Whether the plugin has been configured`})]})}):(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(Cr,{status:n.enabled,enabledText:`Enabled`,disabledText:`Disabled`,tooltipText:`Whether the plugin is enable or disabled`})})})})}];(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`HomePlugins received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`plugins`?e.response.lock?(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} lock=${e.response.lock} and locking plugins list`),_(t=>t.map(t=>t.name===e.response.lock?{...t,restartRequired:!0}:t))):(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} lock=${e.response.lock} and sending /api/plugins request`),r({id:l.current,sender:`HomePlugins`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`refresh_required`&&e.response.changed===`matter`?(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and setting matter id ${e.response.matter?.id}`),_(t=>{let n=t.findIndex(t=>t.matter?.id===e.response.matter?.id);if(n<0)return q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and matter id ${e.response.matter?.id} not found`),t;q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} set matter id ${e.response.matter?.id}`);let r=[...t];return r[n]={...r[n],matter:e.response.matter},r})):e.method===`refresh_required`&&e.response.changed===`settings`?(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and sending /api/settings request`),r({id:l.current,sender:`HomePlugins`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`plugin_update_required`?(q&&console.log(`HomePlugins received plugin_update_required`,e.response),_(t=>t.map(t=>t.name===e.response.plugin?e.response.devVersion?{...t,devVersion:e.response.version}:{...t,latestVersion:e.response.version}:t))):e.method===`plugin_status_update`?(q&&console.log(`HomePlugins received plugin_status_update`,e.response),_(t=>t.map(t=>t.name===e.response.plugin?{...t,...e.response.status}:t))):e.method===`matterbridge_status_update`&&(q&&console.log(`HomePlugins received matterbridge_status_update: ${e.response.status}`),S(e.response.status)),e.id===l.current&&e.method===`/api/settings`?(q&&console.log(`HomePlugins (id: ${e.id}) received settings:`,e.response),d(e.response.systemInformation),p(e.response.matterbridgeInformation),S(e.response.matterbridgeInformation.bridgeStatus)):e.id===l.current&&e.method===`/api/plugins`&&(q&&console.log(`HomePlugins (id: ${e.id}) received ${e.response.length} plugins:`,e.response),_(e.response))};return i(e,l.current),q&&console.log(`HomePlugins added WebSocket listener id:`,l.current),()=>{a(e),q&&console.log(`HomePlugins removed WebSocket listener`)}},[i,a,r]),(0,G.useEffect)(()=>{n&&(q&&console.log(`HomePlugins sending api requests`),r({id:l.current,sender:`HomePlugins`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:l.current,sender:`HomePlugins`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[n,r]);let w=(0,G.useRef)(null),T=(e,t,n,r)=>{q&&console.log(`handleActionWithConfirmCancel ${n} ${r.name}`),w.current=r,c(e,t,n,E,O)},E=e=>{q&&console.log(`handleConfirm action confirmed ${e} ${w.current?.name}`),e===`remove`&&w.current?j(w.current):e===`disable`&&w.current&&ne(w.current),w.current=null},O=e=>{q&&console.log(`handleCancel action canceled ${e} ${w.current?.name}`),w.current=null},k=e=>{q&&console.log(`handleUpdatePlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e.name,restart:!1}})},A=e=>{q&&console.log(`handleUpdateDevPlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e.name+`@dev`,restart:!1}})},j=e=>{q&&console.log(`handleRemovePlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/removeplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},te=e=>{q&&console.log(`handleRestartPlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/restartplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},ne=e=>{q&&console.log(`handleEnableDisablePlugin plugin:`,e.name,`enabled:`,e.enabled),e.enabled?(e.enabled=!1,r({id:l.current,sender:`HomePlugins`,method:`/api/disableplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})):(e.enabled=!0,r({id:l.current,sender:`HomePlugins`,method:`/api/enableplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}}))},N=e=>{q&&console.log(`handleHomepagePlugin plugin: ${e.name} homepage: ${e.homepage}`),e.homepage&&window.open(e.homepage,`_blank`)},P=e=>{q&&console.log(`handleSponsorPlugin plugin:`,e.name,`funding:`,e.funding),e.funding&&window.open(e.funding,`_blank`)},F=e=>{q&&console.log(`handleHelpPlugin plugin:`,e.name,`help:`,e.help),e.help&&window.open(e.help,`_blank`)},ae=e=>{q&&console.log(`handleChangelogPlugin plugin:`,e.name,`changelog:`,e.changelog),e.changelog&&window.open(e.changelog,`_blank`)},oe=e=>{let t=`${Vt}plugins/${e.name}/`;console.log(`handleFrontendPlugin plugin:`,e.name,`basePath:`,Vt,`frontendPath:`,e.frontendPath,`computed pluginFrontendPath:`,t),e.frontendPath&&y({name:e.name,path:t})},se=e=>{let t=e.currentTarget.contentDocument;if(!t?.head)return;let n=getComputedStyle(document.body),r=n.getPropertyValue(`--primary-color`).trim()||`#0d6efd`,i=n.getPropertyValue(`--div-bg-color`).trim()||`#111111`;t.getElementById(`matterbridge-plugin-scrollbar-style`)?.remove();let a=t.createElement(`style`);a.id=`matterbridge-plugin-scrollbar-style`,a.textContent=`
|
|
22
|
+
`,t.head.appendChild(a)},style:{display:`block`,flex:`1 1 auto`,width:`100%`,height:`100%`,border:`none`,backgroundColor:`var(--div-bg-color)`}})}),(0,Y.jsx)(D,{sx:{flex:`0 0 auto`,justifyContent:`center`},children:(0,Y.jsx)(W,{onClick:()=>w(null),children:`Close`})})]})]}):(0,Y.jsx)(qt,{})}var zn=(0,G.memo)(Rn),Bn=[`matterbridge-`,`matterbridge-plugin-template`,`matterbridge-dyson`,`matterbridge-tuya`,`matterbridge-matter`,`matterbridge-automations`,`matterbridge-camera`,`matterbridge-webcam`,`matterbridge-securitysystem`,`matterbridge-adapter`],Vn=e=>e.replace(`git+`,``).replace(`.git`,``).trim(),Hn=e=>{let t=Vn(e);return t.startsWith(`git://`)&&(t=`https://${t.slice(6)}`),t.startsWith(`ssh://git@github.com/`)&&(t=`https://github.com/${t.slice(21)}`),t.startsWith(`git@github.com:`)&&(t=`https://github.com/${t.slice(15).replace(`:`,`/`)}`),t},Un=e=>{if(typeof e==`string`)return e.trim()||null;if(!e||typeof e!=`object`)return null;let t=e.url;return typeof t==`string`&&t.trim()||null},Wn=()=>{try{let e=window.localStorage.getItem(K.searchPluginsTotal);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.total==`number`&&typeof t.asOf==`string`&&(n[e]={total:t.total,asOf:t.asOf})}return n}catch{return{}}},Gn=e=>{try{window.localStorage.setItem(K.searchPluginsTotal,JSON.stringify(e))}catch{}},Kn=()=>{try{let e=window.localStorage.getItem(K.searchPluginsMeta);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.asOf==`string`&&(n[e]={homepage:typeof t.homepage==`string`?t.homepage:null,help:typeof t.help==`string`?t.help:null,changelog:typeof t.changelog==`string`?t.changelog:null,asOf:t.asOf})}return n}catch{return{}}},qn=e=>{try{window.localStorage.setItem(K.searchPluginsMeta,JSON.stringify(e))}catch{}},Jn=()=>{try{let e=window.localStorage.getItem(K.searchPluginsVersions);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.asOf==`string`&&Array.isArray(t.versions)&&(n[e]={versions:t.versions.filter(e=>typeof e==`string`),asOf:t.asOf})}return n}catch{return{}}},Yn=e=>{try{window.localStorage.setItem(K.searchPluginsVersions,JSON.stringify(e))}catch{}},Xn=({open:e,onClose:t,onSelect:n,onVersions:r})=>{let{mobile:i}=(0,G.useContext)(Wt),[a,o]=(0,G.useState)(``),s=(0,G.useRef)(``),c=(0,G.useRef)(!1),l=(0,G.useRef)(null),[u,d]=(0,G.useState)([]),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[_,y]=(0,G.useState)(!1),[b,S]=(0,G.useState)({done:0,total:0}),[C,w]=(0,G.useState)(null),T=(0,G.useRef)({}),E=()=>{let e=document.activeElement;e&&e instanceof HTMLElement&&e.blur()},O=e=>`${e.getFullYear().toString()}-${(e.getMonth()+1).toString().padStart(2,`0`)}-${e.getDate().toString().padStart(2,`0`)}`,k=(0,G.useCallback)(async(e,t)=>{let n=T.current[e];if(n&&n.asOf===t&&Array.isArray(n.versions)&&n.versions.length>0&&n.versions[0]===`latest`)return q&&console.log(`[SearchPluginsDialog] versions cache hit for ${e} (${n.versions.length.toString()})`),n.versions;n&&n.asOf===t&&n.versions.length>0&&n.versions[0]!==`latest`&&q&&console.log(`[SearchPluginsDialog] versions cache ignored (old format) for ${e} (asOf=${t})`);let r=`https://registry.npmjs.org/${encodeURIComponent(e)}`;q&&console.log(`[SearchPluginsDialog] fetching versions for ${e} from: ${r}`);let i=await fetch(r,{signal:l.current?.signal});if(!i.ok)return q&&console.log(`[SearchPluginsDialog] versions fetch failed for ${e}: ${i.status.toString()} ${i.statusText}`),[];let a=await i.json(),o=Object.keys(a.versions??{}),s=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`});o.sort((e,t)=>s.compare(e,t)).reverse();let c=a[`dist-tags`]??{},u=typeof c?.dev==`string`&&String(c.dev).trim().length>0,d=o.slice(0,20),f=[`latest`];return u&&f.push(`dev`),f.push(...d),q&&console.log(`[SearchPluginsDialog] fetched versions for ${e} (tags: latest${u?`, dev`:``}; latestVersions=${d.length.toString()}; allVersions=${o.length.toString()}):`,f),T.current[e]={versions:f,asOf:t},Yn(T.current),f},[]),A=e=>new Intl.NumberFormat().format(e),j=[{label:`Name`,id:`name`,required:!0,maxWidth:230,tooltip:!0},{label:`Version`,id:`version`,required:!0,maxWidth:110,tooltip:!0},{label:`Monthly`,id:`downloads`,align:`right`,maxWidth:120,render:e=>typeof e==`number`?A(e):``},{label:`Total`,id:`total`,align:`right`,maxWidth:120,render:e=>typeof e==`number`?A(e):``},{label:`Description`,id:`description`,required:!0,maxWidth:300,tooltip:!0},{label:`Author`,id:`author`,maxWidth:140,tooltip:!0},{label:`Action`,id:`action`,align:`center`,maxWidth:100,noSort:!0,required:!0,render:(e,t,n,r)=>(0,Y.jsxs)(`div`,{style:{margin:`0`,padding:`0`,gap:`4px`,display:`flex`,flexDirection:`row`,justifyContent:`center`},children:[(0,Y.jsx)(V,{title:n.homepage?`Open the plugin homepage`:`No homepage available`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(L,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.homepage,onClick:e=>{if(e.stopPropagation(),n.homepage)try{let e=new URL(n.homepage);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,Y.jsx)(v,{})})})}),(0,Y.jsx)(V,{title:n.help?`Open the plugin help`:`No help available`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(L,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.help,onClick:e=>{if(e.stopPropagation(),n.help)try{let e=new URL(n.help);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,Y.jsx)(re,{})})})}),(0,Y.jsx)(V,{title:n.changelog?`Open the plugin changelog`:`No changelog available`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(L,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.changelog,onClick:e=>{if(e.stopPropagation(),n.changelog)try{let e=new URL(n.changelog);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,Y.jsx)(g,{})})})})]})}];(0,G.useEffect)(()=>{if(!e){c.current=!1,s.current=``,l.current?.abort(),l.current=null,d([]),p(!1),h(!1),y(!1),S({done:0,total:0}),w(null),o(``);return}if(c.current)return;c.current=!0;let t=new AbortController;return l.current=t,T.current=Jn(),(async()=>{let e=`matterbridge-`,n=e=>new Promise(t=>setTimeout(t,e)),r=e=>{if(!Array.isArray(e.downloads))return null;let t=0,n=!1;for(let r of e.downloads)typeof r?.downloads==`number`&&(t+=r.downloads,n=!0);return n?t:null};try{p(!0),w(null);let i=e=>{let t=String(e??``).trim().toLowerCase();return t?!!(t===`github actions`||t===`github-actions`||t===`github-actions[bot]`||t.includes(`github-actions`)||t.endsWith(`[bot]`)):!1},a=e=>{let t=(e.maintainers??[]).map(e=>(e.username??``).trim()).filter(Boolean),n=(e.publisher?.username??``).trim();return t.find(e=>!i(e))||(n&&!i(n)?n:t[0]??n??``)},o=await fetch(`https://registry.npmjs.org/-/v1/search?text=matterbridge-&size=250`,{signal:t.signal});if(!o.ok)throw Error(`npm registry request failed: ${o.status} ${o.statusText}`);let s=await o.json(),c=`luligu`,l=e=>e.publisher?.username?.toLowerCase()===c||(e.maintainers??[]).some(e=>e.username?.toLowerCase()===c),u=(s.objects??[]).filter(e=>!!e?.package&&typeof e.package.name==`string`).filter(t=>t.package?.name?.startsWith(e)).filter(e=>!Bn.includes(e.package?.name??``)).sort((e,t)=>{let n=l(e.package??{});return n===l(t.package??{})?(e.package?.name??``).localeCompare(t.package?.name??``):n?-1:1}).map(e=>{let t=e.package,n=t.name??``,r=a(t),i=typeof e.downloads?.monthly==`number`?e.downloads.monthly:null,o=(t.links?.npm??``).trim(),s=((t.links?.homepage??``).trim()||o||(n?`https://www.npmjs.com/package/${encodeURIComponent(n)}`:``)).trim()||null;return{name:n,version:t.version??``,downloads:i,total:null,description:t.description??``,author:r,official:l(t),homepage:s,help:null,changelog:null}}),f=O(new Date),m=Wn(),h=Kn(),g=u.map(e=>{let t=m[e.name];return!t||typeof t.total!=`number`?e:(q&&console.log(`[SearchPluginsDialog] total downloads loaded from cache for ${e.name} (asOf=${t.asOf}):`,t.total),{...e,total:t.total})}).map(e=>{let t=h[e.name];if(!t||t.asOf!==f)return e;let n=t.homepage??e.homepage,r=t.help,i=t.changelog;return q&&(r||i||n&&n!==e.homepage)&&console.log(`[SearchPluginsDialog] metadata loaded from cache for ${e.name} (asOf=${t.asOf}):`,{homepage:n,help:r,changelog:i}),{...e,homepage:n,help:r,changelog:i}});d(g);let _=u.map(e=>e.name).filter(e=>{let t=T.current[e];return!t||t.asOf!==f||t.versions.length===0});q&&console.log(`[SearchPluginsDialog] versions prefetch queue (${_.length.toString()}):`,_);let v=0,b=async()=>{for(;v<_.length;){if(t.signal.aborted)return;let e=v;v+=1;let r=_[e];if(r)try{let e=await k(r,f);q&&e.length>0&&console.log(`[SearchPluginsDialog] versions fetched for ${r} (${e.length.toString()}):`,e.slice(0,5))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return}finally{t.signal.aborted||await n(200)}}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>b()));let x=u.map(e=>e.name).filter(e=>{let t=h[e],n=!!t&&t.asOf===f,r=!!t&&!!t.help&&!!t.changelog,i=!n||!r;return!i&&q&&console.log(`[SearchPluginsDialog] metadata fetch skipped (cache fresh+complete) for ${e} (asOf=${t.asOf}).`),n&&!r&&q&&console.log(`[SearchPluginsDialog] metadata fetch forced (cache incomplete) for ${e} (asOf=${t.asOf}).`),i}),C=new Set(x),E=async(e,n)=>{let r=`https://registry.npmjs.org/${encodeURIComponent(e)}/latest`;try{let e=await fetch(r,{signal:t.signal});if(!e.ok)return null;let i=await e.json(),a=typeof i.homepage==`string`&&i.homepage.includes(`http`)?Vn(i.homepage):null,o=typeof i.help==`string`&&i.help.startsWith(`http`)?i.help.trim():null,s=typeof i.changelog==`string`&&i.changelog.startsWith(`http`)?i.changelog.trim():null,c=Un(i.repository),l=c?Hn(c):null,u=l&&l.includes(`http`)?l:null,d=a||u||n||null;return{homepage:d,help:o||(u?`${u}/blob/main/README.md`:null)||d||null,changelog:s||(u?`${u}/blob/main/CHANGELOG.md`:null)||d||null}}catch(e){return e instanceof DOMException&&e.name,null}},D=0,A=async()=>{for(;D<x.length;){if(t.signal.aborted)return;let e=D;D+=1;let r=x[e];if(!r||!C.has(r))continue;C.delete(r);let i=u.find(e=>e.name===r)?.homepage??null,a=await E(r,i);if(t.signal.aborted)return;a&&(d(e=>e.map(e=>e.name===r?{...e,homepage:a.homepage??e.homepage,help:a.help,changelog:a.changelog}:e)),h[r]={homepage:a.homepage,help:a.help,changelog:a.changelog,asOf:f},qn(h)),t.signal.aborted||await n(250)}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>A()));let j=`2020-01-01`,M=u.map(e=>e.name).filter(e=>{let t=m[e],n=!t||t.asOf!==f;return n||q&&console.log(`[SearchPluginsDialog] total downloads fetch skipped (cache fresh) for ${e} (asOf=${t.asOf}).`),n}),ee=new Set(M),te=M.length;S({done:0,total:te}),y(te>0);let ne=async e=>{let i=`https://api.npmjs.org/downloads/range/${j}:${f}/${encodeURIComponent(e)}`;for(let e=0;e<3;e+=1){let a=await fetch(i,{signal:t.signal});if(a.ok){let e=await a.json();return r(e)}if(a.status===404)return null;if(a.status===429){let t=a.headers.get(`retry-after`),r=t?Number(t):NaN,i=Number.isFinite(r)?r*1e3:2e3*(e+1);await n(i);continue}return null}return null},N=0,re=0,P=async()=>{for(;N<M.length;){if(t.signal.aborted)return;let e=N;N+=1;let r=M[e];if(r&&ee.has(r)){ee.delete(r);try{q&&console.log(`[SearchPluginsDialog] fetching total downloads for ${r} (range ${j}:${f})...`);let e=await ne(r);if(t.signal.aborted)return;q&&console.log(`[SearchPluginsDialog] total downloads fetched for ${r}:`,e),d(t=>t.map(t=>t.name===r?{...t,total:e}:t)),typeof e==`number`&&(m[r]={total:e,asOf:f},Gn(m),q&&console.log(`[SearchPluginsDialog] total downloads saved to localStorage for ${r} (asOf=${f}):`,e))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return}finally{re+=1,S({done:re,total:te}),t.signal.aborted||await n(500)}}}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>P())).finally(()=>{t.signal.aborted||y(!1)}),q&&console.log(`[SearchPluginsDialog] npm packages starting with "${e}" (filtered/sorted):`,u)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;console.error(`[SearchPluginsDialog] npm registry fetch error:`,e),w(e instanceof Error?e.message:String(e))}finally{p(!1)}})(),()=>t.abort()},[e,k]);let ee=async()=>{E();let e=s.current||a;if(!(!e||m))try{h(!0);let t=O(new Date),i=await k(e,t);q&&console.log(`[SearchPluginsDialog] passing versions to onVersions() for ${e} (${i.length.toString()}):`,i),r(i),h(!1),n(e)}catch(t){if(t instanceof DOMException&&t.name===`AbortError`)return;console.error(`[SearchPluginsDialog] npm versions fetch error:`,t),r([]),h(!1),n(e)}},te=()=>{E(),t(),r([])},ne=u.reduce((e,t)=>e+(typeof t.downloads==`number`?t.downloads:0),0),N=u.reduce((e,t)=>(typeof t.total==`number`&&(e.total+=t.total,e.hasAny=!0),e),{total:0,hasAny:!1}),P=_?` Totals: ${b.done.toString()}/${b.total.toString()} fetched`:``,ie=N.hasAny?A(N.total):`...`;return(0,Y.jsxs)(M,{open:e,onClose:()=>{E(),t()},maxWidth:!1,fullWidth:!0,slotProps:{paper:{sx:{width:J&&i?`100vw`:`75vw`,height:J&&i?`100vh`:`75vh`,maxWidth:J&&i?`100vw`:`75vw`,maxHeight:J&&i?`100vh`:`75vh`,margin:J&&i?`0px`:void 0,display:`flex`,flexDirection:`column`}}},children:[(0,Y.jsx)(F,{children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:`Search Plugins`})]})}),(0,Y.jsx)(x,{dividers:!0,sx:{padding:`10px`,flex:`1 1 auto`,minHeight:0},children:(0,Y.jsx)(`div`,{style:{height:`100%`,width:`100%`,display:`flex`,flexDirection:`column`,minHeight:0},children:f?(0,Y.jsx)(`div`,{style:{padding:`20px`},children:`Loading npm registry...`}):C?(0,Y.jsx)(`div`,{style:{padding:`20px`},children:C}):(0,Y.jsx)(wn,{name:`Search plugins`,rows:u,columns:j,getRowKey:`name`,onRowClick:(e,t,n)=>{s.current=e.name,o(e.name),n.detail===2&&ee()},footerLeft:`Total packages: ${u.length.toString()} Total downloads: ${A(ne)} / ${ie}${P}`,footerRight:a?`Selected: ${a}`:``})})}),(0,Y.jsxs)(D,{sx:{justifyContent:`center`,gap:1.5,flexWrap:`wrap`},children:[(0,Y.jsx)(V,{title:`Select the plugin and close the dialog. Double-click a row to select and close the dialog.`,children:(0,Y.jsx)(W,{variant:`contained`,onClick:ee,disabled:!(s.current||a)||m,children:`Select`})}),(0,Y.jsx)(V,{title:`Close the dialog without selecting a plugin.`,children:(0,Y.jsx)(W,{onClick:te,children:`Cancel`})})]})]})};function Zn(){let{mobile:e,showSnackbarMessage:t}=(0,G.useContext)(Wt),{logMessage:n,sendMessage:r,getUniqueId:i}=(0,G.useContext)(X),[a,o]=(0,G.useState)(`matterbridge-`),[s,c]=(0,G.useState)([`latest`,`dev`]),[l,d]=(0,G.useState)(`latest`),[f,p]=(0,G.useState)(!1),m=(0,G.useRef)(i()),h=e=>{let t=(e??``).trim();if(!t)return{name:``,specifier:null};if(t.startsWith(`@`)){let e=t.lastIndexOf(`@`);if(e>0){let n=t.slice(0,e),r=t.slice(e+1);if(n.includes(`/`)&&r)return{name:n,specifier:r}}return{name:t,specifier:null}}let n=t.indexOf(`@`);if(n>0){let e=t.slice(0,n),r=t.slice(n+1);return r?{name:e,specifier:r}:{name:e,specifier:null}}return{name:t,specifier:null}},g=()=>{let{name:e,specifier:t}=h(a);return e?t?`${e}@${t}`:l?`${e}@${l}`:e:``},_=e=>{e.preventDefault(),p(!0)},v=()=>{p(!1)},b=e=>{e.preventDefault(),p(!1);let t=e.dataTransfer.files[0];if(t){n(`Plugins`,`Installing package ${t.name}. Please wait...`);let e=new FormData;e.append(`file`,t),e.append(`filename`,t.name),fetch(`./api/uploadpackage`,{method:`POST`,body:e}).then(e=>e.text()).then(e=>{n(`Plugins`,`Server response: ${e}`)}).catch(e=>{console.error(`Error uploading plugin file:`,e),n(`Plugins`,`Error installing package ${e}`)})}},x=e=>{let t=e.target.files&&e.target.files[0];if(t){n(`Plugins`,`Uploading package ${t.name}`);let e=new FormData;e.append(`file`,t),e.append(`filename`,t.name),fetch(`./api/uploadpackage`,{method:`POST`,body:e}).then(e=>e.text()).then(e=>{n(`Plugins`,`Server response: ${e}`)}).catch(e=>{console.error(`Error uploading plugin file:`,e),n(`Plugins`,`Error uploading package ${e}`)})}},S=()=>{let e=g();if(e){if(Bn.includes(e.split(`@`)[0])){t(`Installation of plugin "${e}" is blocked by the ignore list.`);return}r({id:m.current,sender:`InstallPlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e,restart:!1}})}},C=()=>{r({id:m.current,sender:`InstallPlugins`,method:`/api/uninstall`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:a}})},w=()=>{document.getElementById(`file-upload`)?.click()},T=()=>{if(Bn.includes(a.split(`@`)[0])){t(`Addition of plugin "${a}" is blocked by the ignore list.`);return}r({id:m.current,sender:`InstallPlugins`,method:`/api/addplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginNameOrPath:a}})},E=e=>{e.preventDefault(),q&&console.log(`Right-clicked Upload button`)},D=e=>{e.preventDefault(),q&&console.log(`Right-clicked Add button`)},[O,k]=(0,G.useState)(!1),A=()=>{k(!0),q&&console.log(`Dialog opened for selection`)},j=()=>{o(`matterbridge-`),k(!1),q&&console.log(`Dialog closed without selection`)},M=e=>{o(e),k(!1),q&&console.log(`Select plugin:`,e)},N=e=>{c(e),d(e.includes(`latest`)?`latest`:e[0]??``),q&&console.log(`Select plugin versions:`,e)},[re,P]=(0,G.useState)(!1);return q&&console.log(`HomeInstallAddPlugins rendering...`),re?null:(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(Jt,{children:[(0,Y.jsx)(Yt,{children:`Install plugins`}),(0,Y.jsx)(en,{close:()=>P(!0)})]}),(0,Y.jsxs)($t,{onDragOver:_,onDragLeave:v,onDrop:b,style:J&&e?{flexWrap:`wrap`,alignItems:`center`,gap:`10px`}:{flexWrap:`wrap`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(Xn,{open:O,onClose:j,onSelect:M,onVersions:N}),(0,Y.jsxs)(`div`,{style:{flex:`1 1 auto`,display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(V,{title:`Provide the npm name or the local path of the plugin to install, uninstall, or add`,children:(0,Y.jsx)(H,{value:a,onChange:e=>{let t=e.target.value;c([`latest`,`dev`]),d(`latest`),o(t)},size:`small`,id:`plugin-name`,label:`Plugin name or plugin path`,variant:`outlined`,fullWidth:!0})}),s.length>0&&(0,Y.jsx)(V,{title:`Select the npm tag/version to install`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsxs)(te,{size:`small`,style:{minWidth:`150px`},children:[(0,Y.jsx)(y,{id:`plugin-version-label`,children:`Tag or version`}),(0,Y.jsx)(it,{labelId:`plugin-version-label`,id:`plugin-version`,value:l,label:`Tag or version`,onChange:e=>d(e.target.value??``),sx:{"& .MuiSelect-icon":{color:`var(--main-label-color)`}},children:s.map(e=>(0,Y.jsx)(z,{value:e,children:e},e))})]})})}),(0,Y.jsx)(V,{title:`Search on npm the plugin to install`,children:(0,Y.jsx)(L,{size:`large`,onClick:A,children:(0,Y.jsx)(Le,{fontSize:`inherit`})})})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(V,{title:`Install or update a plugin from npm`,children:(0,Y.jsxs)(W,{onClick:S,endIcon:(0,Y.jsx)(Fe,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Install`]})}),(0,Y.jsx)(V,{title:`Uninstall and remove a plugin`,children:(0,Y.jsxs)(W,{onClick:C,endIcon:(0,Y.jsx)(ee,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Uninstall`]})}),(0,Y.jsx)(V,{title:`Upload and install a plugin from a tarball`,children:(0,Y.jsxs)(W,{onClick:w,onContextMenu:E,endIcon:(0,Y.jsx)(u,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Upload`]})}),(0,Y.jsx)(V,{title:`Add an already installed plugin or a plugin from a local path`,children:(0,Y.jsxs)(W,{onClick:T,onContextMenu:D,endIcon:(0,Y.jsx)(ne,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Add`]})}),(0,Y.jsx)(`input`,{id:`file-upload`,type:`file`,accept:`.tgz`,style:{display:`none`},onChange:x})]})]})]})}var Qn=(0,G.memo)(Zn),$n=()=>{let e=window;return`ontouchstart`in window||e.DocumentTouch!==void 0&&document instanceof e.DocumentTouch?(q&&console.log(`WebSocketLogs detectTouchscreen = true`),!0):(q&&console.log(`WebSocketLogs detectTouchscreen = false`),!1)};function er(){let{messages:e,logAutoScroll:t}=(0,G.useContext)(Gt),[n,r]=(0,G.useState)(!1),i=(0,G.useRef)(null),a=(0,G.useRef)(0),o=(0,G.useRef)(null),s=(0,G.useMemo)(()=>$n(),[]),c=()=>r(!0),l=()=>r(!1);(0,G.useEffect)(()=>{if(q&&console.log(`WebSocketLogs logAutoScroll: ${t.current} isHovering: ${n}`),t.current&&!n&&!s){let e=Date.now();e-a.current>=500?(q&&console.log(`WebSocketLogs auto-scroll to bottom`),a.current=e,i.current?.scrollIntoView({behavior:`smooth`,block:`end`})):(q&&console.log(`WebSocketLogs auto-scroll skipped to avoid flicker`),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{i.current?.scrollIntoView({behavior:`smooth`}),a.current=Date.now()},1e3))}},[e,t,n,s]);let u=e=>{switch(e.toLowerCase()){case`debug`:return`gray`;case`info`:return`#267fb7`;case`notice`:return`green`;case`warn`:return`#e9db18`;case`error`:return`red`;case`fatal`:return`#ff0000`;case`spawn`:return`#ff00d0`;default:return`#5c0e91`}},d=e=>{switch(e.toLowerCase()){case`warn`:return`black`;default:return`white`}};return(0,Y.jsx)(`div`,{style:{margin:`0px`,padding:`0px`},onMouseEnter:c,onMouseLeave:l,children:(0,Y.jsxs)(`ul`,{style:{margin:`0px`,padding:`0px`},children:[e.map((e,t)=>(0,Y.jsxs)(`li`,{style:{wordWrap:`break-word`,maxHeight:`200px`,overflow:`hidden`},children:[(0,Y.jsx)(`span`,{style:{marginRight:`5px`,padding:`1px 5px`,backgroundColor:u(e.level),color:d(e.level),fontSize:`12px`,borderRadius:`3px`,textAlign:`center`},children:e.level}),e.time&&(0,Y.jsx)(`span`,{style:{marginRight:`3px`,color:`#505050`},children:`[`+e.time+`]`}),e.name&&(0,Y.jsx)(`span`,{style:{marginRight:`3px`,color:`#09516d`},children:`[`+e.name+`]`}),(0,Y.jsx)(`span`,{style:{color:`var(--main-log-color)`},children:e.message})]},t)),(0,Y.jsx)(`div`,{ref:i})]})})}var tr=(0,G.memo)(er);function nr(){let[e,t]=(0,G.useState)(localStorage.getItem(K.logFilterLevel)??`info`),[n,r]=(0,G.useState)(localStorage.getItem(K.logFilterSearch)??`*`),{online:i,logAutoScroll:a}=(0,G.useContext)(X);return q&&console.log(`HomeLogs rendering...`),i?(0,Y.jsxs)(Q,{style:{flex:`1 1 auto`},children:[(0,Y.jsxs)(Jt,{children:[(0,Y.jsx)(Yt,{children:`Logs`}),(0,Y.jsxs)(Yt,{style:{fontWeight:`normal`,fontSize:`12px`,marginTop:`2px`},children:[`Filter: logger level "`,e,`" and search "`,n===``?`*`:n,`" Scroll: `,a.current?`auto`:`manual`]})]}),(0,Y.jsx)($t,{style:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`10px`,alignItems:`start`},children:(0,Y.jsx)(tr,{})})]}):(0,Y.jsx)(qt,{})}var rr=(0,G.memo)(nr);function ir(e){return e.id!==0&&e.src===`Matterbridge`&&e.dst===`Frontend`}var ar={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},or={fontSize:`12px`,fontWeight:`normal`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},sr={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},cr={fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`,backgroundColor:`var(--div-bg-color)`},lr={fontSize:`16px`,fontWeight:`bold`,backgroundColor:`var(--div-bg-color)`},ur={padding:`0px`,margin:`0px`},dr=`5px 10px 5px 10px`,fr={},pr={},mr={},hr={},gr=[],_r=[],vr=[];function yr(e,t){let n=e?.properties;if(!n||typeof n!=`object`)return!1;let r=n[t];return!r||typeof r!=`object`?!1:typeof r.type==`string`}function br(e){let t=e.items;return t!==void 0&&typeof t==`object`&&!Array.isArray(t)}function xr(e,t){let n=e?.properties;if(!n||typeof n!=`object`)return!1;let r=n[t];if(!r||typeof r!=`object`||r.type!==`array`||r.uniqueItems!==!0)return!1;let i=r.items;return i!==void 0&&typeof i==`object`&&!Array.isArray(i)&&Array.isArray(i.enum)}var Sr=({open:e,onClose:t,plugin:n})=>{let{sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(X),s=(0,G.useRef)(o()),c=(0,G.useRef)({}),l=(0,G.useRef)({}),[u,d]=(0,G.useState)(n.configJson),[f,m]=(0,G.useState)(n.schemaJson),[g,_]=(0,G.useState)({"ui:submitButtonOptions":{submitText:`Confirm`},"ui:globalOptions":{orderable:!0}}),v=(0,G.useRef)(``),y=n.configJson;(0,G.useEffect)(()=>{let e=e=>{e.src===`Matterbridge`&&e.dst===`Frontend`&&(ir(e)&&e.id===s.current&&e.method===`/api/select/devices`&&e.response&&(q&&console.log(`ConfigPluginDialog (id: ${e.id}) received ${e.response.length} /api/select/devices:`,e.response),_r=e.response),ir(e)&&e.id===s.current&&e.method===`/api/select/entities`&&e.response&&(q&&console.log(`ConfigPluginDialog (id: ${e.id}) received ${e.response.length} /api/select/entities:`,e.response),vr=e.response))};if(i(e,s.current),q&&console.log(`ConfigPluginDialog added WebSocket listener id:`,s.current),q&&console.log(`ConfigPluginDialog mounting...`),q&&console.log(`ConfigPluginDialog mounting with form:`,u),q&&console.log(`ConfigPluginDialog mounting with schema:`,f),q&&console.log(`ConfigPluginDialog mounting with uiSchema:`,g),u&&f&&f.properties){let e=(t,n,r=[])=>{!t||typeof t!=`object`||(t.properties&&Object.keys(t.properties).forEach(i=>{let a=t.properties?.[i],o=[...r,i];Object.keys(a).forEach(e=>{if(e.startsWith(`ui:`)){let t=n;o.forEach(e=>{t[e]||(t[e]={}),t=t[e]}),t[e]=a[e],delete a[e]}}),e(a,n,o)}),[`oneOf`,`anyOf`,`allOf`].forEach(i=>{Array.isArray(t[i])&&t[i].forEach(t=>{e(t,n,r)})}),t.items&&typeof t.items==`object`&&e(t.items,n,r))};e(f,g),_(g),c.current=f,l.current=g}return n.name&&n.configJson&&n.schemaJson&&(d(n.configJson),m(n.schemaJson),r({id:s.current,sender:`ConfigPlugin`,method:`/api/select/devices`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name}}),r({id:s.current,sender:`ConfigPlugin`,method:`/api/select/entities`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name}}),q&&console.log(`HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:`,n.name)),()=>{a(e),q&&console.log(`ConfigPluginDialog removed WebSocket listener`)}},[i,u,n,a,f,r,g]);let b=(e,t)=>{y=e.formData},S=e=>{q&&console.log(`ConfigPluginDialog handleSaveChanges:`,e.formData),d(e.formData),n.configJson=e.formData,n.restartRequired=!0,r({id:s.current,sender:`ConfigPlugin`,method:`/api/savepluginconfig`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.formData.name,formData:e.formData}}),t()};function C(e){let{id:t,label:n,onKeyRenameBlur:r,onRemoveProperty:i,disabled:a,schema:o,children:s,registry:c,readonly:l,required:u}=e,{templates:d}=c,{RemoveButton:f}=d.ButtonTemplates,m=wt in o,h=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let e=v.current;!m||e===``||!/^newKey(?:-\d+)?$/.test(n)||!h.current||(q&&console.log(`WrapIfAdditionalTemplate: renaming additional property "${n}" to "${e}"`),h.current.value=e,r({target:h.current}),v.current=``)},[m,n,r]),m?(0,Y.jsxs)(p,{sx:{display:`flex`,flexDirection:`row`,flexGrow:1,padding:0,margin:0,border:`none`},children:[(0,Y.jsx)(H,{id:`${t}-key`,name:`${t}-key`,required:u,disabled:a||l,defaultValue:n,inputRef:h,onBlur:l?void 0:r,type:`text`,variant:`outlined`,sx:{width:`250px`,minWidth:`250px`,maxWidth:`250px`,marginRight:`20px`}}),(0,Y.jsx)(p,{sx:{flex:1},children:s}),(0,Y.jsx)(f,{disabled:a||l,onClick:i,registry:c})]}):(0,Y.jsx)(p,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:s})}function w(e){let{children:t,description:n,displayLabel:r,errors:i,help:a,hidden:o,registry:s,uiSchema:c}=e,l=Ct(`WrapIfAdditionalTemplate`,s,St(c));return o?(0,Y.jsx)(`div`,{style:{display:`none`},children:t}):(0,Y.jsx)(p,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:(0,Y.jsxs)(l,{...e,children:[r===!0&&n,t,i,a]})})}function T(e){let{description:t}=e;return t?(0,Y.jsx)(R,{sx:or,children:t}):null}function E(e){let{required:t,title:n}=e;return n?(0,Y.jsx)(p,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,Y.jsxs)(R,{sx:ar,children:[`Title `,n,` `,t&&(0,Y.jsx)(`mark`,{children:`***`})]})}):null}function O(e){let{help:t}=e;return t?(0,Y.jsx)(p,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,Y.jsx)(R,{sx:cr,children:t})}):null}function k(e){let{errors:t}=e;return t?(0,Y.jsxs)(p,{sx:{padding:`10px`,margin:`10px`,border:`1px solid grey`},children:[(0,Y.jsx)(R,{color:`error`,sx:lr,children:`Please fix the following errors:`}),(0,Y.jsx)(ue,{children:t.map((e,t)=>(0,Y.jsxs)(h,{children:[(0,Y.jsx)(I,{children:(0,Y.jsx)(Ve,{color:`error`})}),(0,Y.jsx)(U,{primary:e.stack})]},t))})]}):null}function A(e){let{errors:t}=e;return t?(0,Y.jsx)(p,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:t.map((e,t)=>(0,Y.jsxs)(R,{color:`error`,variant:`body2`,sx:{marginLeft:1},children:[`This field `,e]},t))}):null}function j(e){let{id:t,name:n,_schema:r,_uiSchema:i,value:a,options:o,label:s,type:c,placeholder:l,required:u,disabled:d,readonly:f,autofocus:m,onChange:h,onChangeOverride:g,onBlur:_,onFocus:v,_rawErrors:y,_hideError:b,_registry:x,_formContext:S}=e;return(0,Y.jsx)(p,{sx:{padding:`0px`,margin:`0px`},children:(0,Y.jsx)(H,{id:t,name:t,label:l&&l!==``?s:void 0,variant:`outlined`,placeholder:l&&l!==``?l:s,required:u,disabled:d||f,autoFocus:m,value:a||a===0?a:``,type:c,autoComplete:c===`password`?`current-password`:n,onChange:g||(({target:{value:e}})=>h(e===``?o.emptyValue:e)),onBlur:({target:e})=>_(t,e&&e.value),onFocus:({target:e})=>v(t,e&&e.value),fullWidth:!0})})}function ee(e){return console.log(`ArrayFieldTitleTemplate:`,e),null}function te(e){return console.log(`ArrayFieldDescriptionTemplate:`,e),null}function N(e){let{buttonsProps:t,children:n}=e;return(0,Y.jsxs)(p,{sx:{margin:`2px 0px`,padding:`0px`,display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(p,{sx:{flexGrow:1,marginRight:`10px`},children:n}),(0,Y.jsx)(L,{disabled:!t.hasMoveUp,onClick:t.onMoveUpItem,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(we,{})}),(0,Y.jsx)(L,{disabled:!t.hasMoveDown,onClick:t.onMoveDownItem,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(De,{})}),t.hasRemove&&(0,Y.jsx)(L,{onClick:t.onRemoveItem,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(ke,{})})]})}function re(e){let{canAdd:t,onAddClick:n,schema:r,title:i,formData:a}=e,[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),[f,m]=(0,G.useState)(``),h=e=>{m(e.target.value)},g=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogDeviceToggle filter:`,f,`selectDevices:`,_r),s(!o)},_=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogEntityToggle filter:`,f,`selectEntities:`,vr),l(!c)},v=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:`,f,`selectDevices:`,_r),d(!u)},y=e=>{s(!1),r.selectFrom===`serial`&&br(r)?r.items.default=e.serial:r.selectFrom===`name`&&br(r)&&(r.items.default=e.name),n()},b=e=>{l(!1),r.selectEntityFrom===`name`&&br(r)?r.items.default=e.name:r.selectEntityFrom===`description`&&br(r)&&(r.items.default=e.description),n()},S=e=>{d(!1),r.selectDeviceEntityFrom===`name`&&br(r)?r.items.default=e.name:r.selectDeviceEntityFrom===`description`&&br(r)&&(r.items.default=e.description),n()};return(0,Y.jsxs)(p,{sx:{margin:`0px`,padding:`5px 10px 5px 10px`,border:`1px solid grey`},children:[i&&(0,Y.jsxs)(p,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[i&&(0,Y.jsx)(R,{sx:ar,children:i}),t&&(0,Y.jsxs)(p,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[r.selectFrom&&(0,Y.jsx)(V,{title:`Add a device from the list`,children:(0,Y.jsx)(L,{onClick:g,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(tt,{})})}),r.selectEntityFrom&&(0,Y.jsx)(V,{title:`Add an entity from the list`,children:(0,Y.jsx)(L,{onClick:_,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(tt,{})})}),r.selectDeviceEntityFrom&&(0,Y.jsx)(V,{title:`Add a device entity from the list`,children:(0,Y.jsx)(L,{onClick:v,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(tt,{})})}),(0,Y.jsx)(V,{title:`Add a new item`,children:(0,Y.jsx)(L,{onClick:n,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(ne,{})})})]})]}),r.description&&(0,Y.jsx)(R,{sx:or,children:r.description}),e.items,(0,Y.jsxs)(M,{open:o,onClose:g,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsx)(F,{children:`Select a device`}),(0,Y.jsxs)(x,{children:[(0,Y.jsxs)(p,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,Y.jsx)(R,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,Y.jsx)(H,{fullWidth:!0,variant:`outlined`,value:f,onChange:h,placeholder:`Enter serial or name`})]}),(0,Y.jsx)(ue,{dense:!0,children:_r.filter(e=>e.serial.toLowerCase().includes(f.toLowerCase())||e.name.toLowerCase().includes(f.toLowerCase())).filter(e=>!r.uniqueItems||!a.includes(r.selectFrom===`serial`?e.serial:e.name)).map((e,t)=>(0,Y.jsxs)(ot,{onClick:()=>y(e),sx:fr,children:[e.icon===`wifi`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(oe,{style:pr})}),e.icon===`ble`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(ve,{style:pr})}),e.icon===`hub`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(Ke,{style:pr})}),(0,Y.jsx)(U,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:mr},secondaryTypographyProps:{style:hr}})]},t))})]}),(0,Y.jsx)(D,{children:(0,Y.jsx)(W,{onClick:g,children:`Close`})})]}),(0,Y.jsxs)(M,{open:c,onClose:_,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsx)(F,{children:`Select an entity`}),(0,Y.jsxs)(x,{children:[(0,Y.jsxs)(p,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,Y.jsx)(R,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,Y.jsx)(H,{fullWidth:!0,variant:`outlined`,value:f,onChange:h,placeholder:`Enter name or description`})]}),(0,Y.jsx)(ue,{dense:!0,children:vr.filter(e=>e.name.toLowerCase().includes(f.toLowerCase())||e.description.toLowerCase().includes(f.toLowerCase())).filter(e=>!r.uniqueItems||!a.includes(r.selectEntityFrom===`name`?e.name:e.description)).map((e,t)=>(0,Y.jsxs)(ot,{onClick:()=>b(e),sx:fr,children:[e.icon===`wifi`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(oe,{style:pr})}),e.icon===`ble`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(ve,{style:pr})}),e.icon===`hub`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(Ke,{style:pr})}),e.icon===`component`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(ze,{style:pr})}),e.icon===`matter`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(je,{style:pr})}),(0,Y.jsx)(U,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:mr},secondaryTypographyProps:{style:hr}})]},t))})]}),(0,Y.jsx)(D,{children:(0,Y.jsx)(W,{onClick:_,children:`Close`})})]}),(0,Y.jsxs)(M,{open:u,onClose:v,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsxs)(F,{children:[`Select an entity for `,i]}),(0,Y.jsx)(x,{children:(0,Y.jsx)(ue,{dense:!0,children:_r.filter(e=>e.serial===i||e.name===i).map(e=>e.entities?.filter(e=>!r.uniqueItems||!Array.isArray(a)||!a.includes(r.selectDeviceEntityFrom===`name`?e.name:e.description)).map((e,t)=>(0,Y.jsxs)(ot,{onClick:()=>S(e),sx:fr,children:[e.icon===`wifi`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(oe,{style:pr})}),e.icon===`ble`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(ve,{style:pr})}),e.icon===`hub`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(Ke,{style:pr})}),e.icon===`component`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(ze,{style:pr})}),e.icon===`matter`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(je,{style:pr})}),(0,Y.jsx)(U,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:mr},secondaryTypographyProps:{style:hr}})]},t)))})}),(0,Y.jsx)(D,{children:(0,Y.jsx)(W,{onClick:v,children:`Close`})})]})]})}function P(e){let{onAddProperty:t,schema:n,properties:r,title:i,description:a}=e,[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(``),u=e=>{l(e.target.value)},d=()=>{s(!o)},f=e=>{q&&console.log(`ObjectFieldTemplate: handleSelectValue value "${e.serial}" for schema "${n.selectFrom}"`),s(!1);let r=``;n.selectFrom===`serial`?r=e.serial:n.selectFrom===`name`&&(r=e.name),v.current=r,q&&console.log(`ObjectFieldTemplate: handleSelectValue pendingAdditionalPropertyKey "${r}"`),t()},m=()=>{t()},h=!n.additionalProperties;return q&&console.log(`ObjectFieldTemplate: isRoot ${h} pendingAdditionalPropertyKey "${v.current}"`),(0,Y.jsxs)(p,{sx:{margin:`0px`,padding:h?`10px`:`5px 10px 0px 10px`,border:h?`none`:`1px solid grey`},children:[n.title&&h&&(0,Y.jsx)(p,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,Y.jsx)(R,{sx:ar,children:n.title})}),i&&!h&&(0,Y.jsxs)(p,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[(0,Y.jsx)(R,{sx:ar,children:i}),(0,Y.jsxs)(p,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[n.selectFrom&&(0,Y.jsx)(V,{title:`Add a device from the list`,children:(0,Y.jsx)(L,{onClick:d,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(tt,{})})}),(0,Y.jsx)(V,{title:`Add a new item`,children:(0,Y.jsx)(L,{onClick:m,size:`small`,color:`primary`,sx:ur,children:(0,Y.jsx)(ne,{})})})]})]}),n.description&&(0,Y.jsx)(p,{sx:{padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,Y.jsx)(R,{sx:or,children:n.description})}),r.map(({content:e,name:t,hidden:r})=>{if(r)return null;let i=yr(n,t),a=xr(n,t),o=i&&[`object`,`array`].includes(n.properties[t].type);return(0,Y.jsxs)(p,{sx:{margin:`0px`,marginBottom:`10px`,padding:o&&!a?`0px`:dr,border:o&&!a?`none`:`1px solid grey`},children:[i&&![`object`,`array`,`boolean`].includes(n.properties[t].type)&&(0,Y.jsx)(R,{sx:ar,children:n.properties[t].title||t}),a&&(0,Y.jsx)(R,{sx:ar,children:n.properties[t].title||t}),(0,Y.jsx)(p,{sx:{flexGrow:1,padding:`0px`,margin:`0px`},children:e})]},t)}),(0,Y.jsxs)(M,{open:o,onClose:d,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsx)(F,{children:`Select a device`}),(0,Y.jsxs)(x,{children:[(0,Y.jsxs)(p,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,Y.jsx)(R,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,Y.jsx)(H,{fullWidth:!0,variant:`outlined`,value:c,onChange:u,placeholder:`Enter serial or name`})]}),(0,Y.jsx)(ue,{dense:!0,children:_r.filter(e=>e.serial.toLowerCase().includes(c.toLowerCase())||e.name.toLowerCase().includes(c.toLowerCase())).map((e,t)=>(0,Y.jsxs)(ot,{onClick:()=>f(e),sx:fr,children:[e.icon===`wifi`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(oe,{style:pr})}),e.icon===`ble`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(ve,{style:pr})}),e.icon===`hub`&&(0,Y.jsx)(I,{children:(0,Y.jsx)(Ke,{style:pr})}),(0,Y.jsx)(U,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:mr},secondaryTypographyProps:{style:hr}})]},t))})]}),(0,Y.jsx)(D,{children:(0,Y.jsx)(W,{onClick:d,children:`Close`})})]})]})}function ie(e){let{uiSchema:n}=e,{submitText:r,norender:i}=xt(n);return i?null:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,margin:`10px`,padding:`0px`,gap:`20px`},children:[(0,Y.jsx)(W,{type:`submit`,variant:`contained`,color:`primary`,children:r}),(0,Y.jsx)(W,{variant:`contained`,color:`primary`,onClick:t,children:`Cancel`})]})}function ae(e){let{className:t,disabled:n,onClick:r,registry:i,style:a,uiSchema:o,...s}=e;return(0,Y.jsx)(V,{title:`Remove the item`,children:(0,Y.jsx)(L,{disabled:n,size:`small`,color:`primary`,onClick:r,children:(0,Y.jsx)(ke,{})})})}function ce(e){let{className:t,disabled:n,onClick:r,registry:i,uiSchema:a,...o}=e;return(0,Y.jsx)(V,{title:`Add an item`,children:(0,Y.jsx)(L,{size:`small`,color:`primary`,onClick:r,children:(0,Y.jsx)(ne,{})})})}function le(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,Y.jsx)(V,{title:`Move up the item`,children:(0,Y.jsx)(L,{size:`small`,color:`primary`,onClick:n,children:(0,Y.jsx)(we,{})})})}function de(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,Y.jsx)(V,{title:`Move down the item`,children:(0,Y.jsx)(L,{size:`small`,color:`primary`,onClick:n,children:(0,Y.jsx)(De,{})})})}function fe(e){let{id:i,name:a,value:o,schema:c,readonly:l,onChange:d}=e,[f,m]=(0,G.useState)(),h=e=>{q&&console.log(`CheckboxWidget ${a} onChangeField:`,e),m(e&&e!==``?e:void 0)},g=()=>{q&&console.log(`CheckboxWidget onClick plugin="${n.name}" action="${a}" value="${f}"`),r({id:s.current,sender:`ConfigPlugin`,method:`/api/action`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name,action:a,value:f,formData:y,id:i}}),c.buttonClose===!0?t():c.buttonSave===!0&&S({formData:u})};return c.buttonText&&(c.title||c.description)?(0,Y.jsxs)(p,{sx:{margin:`0px`,padding:`5px 0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Y.jsx)(R,{sx:sr,children:c.title||c.description}),(0,Y.jsx)(W,{variant:`contained`,color:`primary`,onClick:()=>g(),children:c.buttonText})]}):c.buttonField&&(c.title||c.description)?(0,Y.jsxs)(p,{sx:{margin:`0px`,padding:`5px 0px`,gap:`20px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Y.jsx)(R,{sx:sr,children:c.title||c.description}),(0,Y.jsx)(H,{id:a+`-input`,name:a,label:c.textLabel,placeholder:c.textPlaceholder,onChange:e=>h(e.target.value),sx:{width:`250px`,minWidth:`250px`,maxWidth:`250px`}}),(0,Y.jsx)(W,{id:a+`-button`,variant:`contained`,color:`primary`,disabled:f===void 0,onClick:()=>g(),children:c.buttonField})]}):(0,Y.jsxs)(p,{sx:{margin:`0px`,padding:`0px`},children:[a&&(0,Y.jsxs)(p,{sx:{margin:`0px`,padding:`0px`,gap:`10px`,display:`flex`,justifyContent:`flex-start`,alignItems:`center`},children:[(0,Y.jsx)(R,{sx:ar,children:c.title||a}),(0,Y.jsx)(se,{checked:o,readOnly:l,onChange:()=>d(!o),sx:{padding:`0px`,margin:`0px`}})]}),c.description&&(0,Y.jsx)(R,{sx:or,children:c.description})]})}function pe({schema:e,id:t,name:n,options:r,label:i,hideLabel:a,required:o,disabled:s,placeholder:c,readonly:l,value:u,multiple:d,autofocus:f,onChange:p,onBlur:m,onFocus:h,errorSchema:g,rawErrors:_=gr,registry:v,uiSchema:y,hideError:b,...x}){let{enumOptions:S,enumDisabled:C,emptyValue:w}=r,T=d?[]:``,E=u===void 0||d&&u.length<1||!d&&u===T,D=({target:{value:e}})=>p(Ot(e,S,w)),O=({target:e})=>m(t,Ot(e&&e.value,S,w)),k=({target:e})=>h(t,Ot(e&&e.value,S,w)),A=Et(u,S,d);return(0,Y.jsx)(H,{id:t,name:n,value:!E&&A!==void 0?A:T,required:o,disabled:s||l,autoFocus:f,error:_.length>0,onChange:D,onBlur:O,onFocus:k,select:!0,slotProps:{select:{multiple:d,...d?{renderValue:e=>!Array.isArray(e)||!Array.isArray(S)?``:e.map(e=>S[Number(e)]?.label).filter(e=>typeof e==`string`).join(`, `)}:{}}},"aria-describedby":Dt(t),children:Array.isArray(S)&&S.map(({value:e,label:t},n)=>{let r=Array.isArray(C)&&C.indexOf(e)!==-1,i=Array.isArray(A)&&A.includes(String(n));return(0,Y.jsxs)(z,{value:String(n),disabled:r,children:[d&&(0,Y.jsx)(I,{sx:{minWidth:`32px`},children:(0,Y.jsx)(se,{checked:i,disableRipple:!0,tabIndex:-1,sx:{padding:`0px`,margin:`0px`}})}),t]},n)})})}return q&&console.log(`ConfigPluginDialog rendering...`),!e||!f||!u?null:(0,Y.jsxs)(M,{open:e,onClose:t,slotProps:{paper:{sx:{maxWidth:`800px`}}},children:[(0,Y.jsx)(F,{gap:`20px`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h3`,{children:`Matterbridge plugin configuration`})]})}),(0,Y.jsx)(x,{style:{padding:`0px`,margin:`0px`,width:`800px`,height:`600px`,overflow:`auto`},children:(0,Y.jsx)(kt,{schema:f,formData:u,uiSchema:g,validator:Tt,templates:{FieldTemplate:w,BaseInputTemplate:j,TitleFieldTemplate:E,DescriptionFieldTemplate:T,FieldHelpTemplate:O,FieldErrorTemplate:A,ErrorListTemplate:k,WrapIfAdditionalTemplate:C,ArrayFieldTitleTemplate:ee,ArrayFieldDescriptionTemplate:te,ArrayFieldItemTemplate:N,ArrayFieldTemplate:re,ObjectFieldTemplate:P,ButtonTemplates:{SubmitButton:ie,RemoveButton:ae,AddButton:ce,MoveUpButton:le,MoveDownButton:de}},widgets:{CheckboxWidget:fe,SelectWidget:pe},onChange:b,onSubmit:S})})]})};function Cr({status:e,enabledText:t=`Enabled`,disabledText:n,tooltipText:r}){if(e===void 0)return null;{let i=(0,Y.jsx)(`div`,{className:e?`status-enabled`:`status-disabled`,style:{cursor:`default`},children:e?t:n??t});return r===void 0?i:(0,Y.jsx)(V,{title:r,children:i})}}function wr({storeId:e,setStoreId:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(X),{mobile:s,showConfirmCancelDialog:c}=(0,G.useContext)(Wt),l=(0,G.useRef)(o()),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(null),[h,_]=(0,G.useState)([]),[v,y]=(0,G.useState)(null),[b,S]=(0,G.useState)(`inactive`),C=[{label:`Name`,id:`name`,required:!0,render:(e,t,n,r)=>(0,Y.jsx)(V,{title:n.local===!0?`Local plugin path: ${n.path}`:`Plugin path ${n.path}`,children:(0,Y.jsxs)(`button`,{type:`button`,style:{cursor:`pointer`,background:`none`,border:`none`,margin:0,padding:0,font:`inherit`,color:`inherit`,textAlign:`left`,display:`flex`,alignItems:`center`,gap:`4px`},onClick:()=>N(n),children:[n.name,n.local===!0&&(0,Y.jsx)(at,{style:{width:`14px`,height:`14px`,color:`var(--primary-color)`}})]})})},{label:`Description`,id:`description`,render:(e,t,n,r)=>(0,Y.jsx)(V,{title:`Open the plugin homepage`,children:(0,Y.jsx)(`button`,{type:`button`,style:{cursor:`pointer`,background:`none`,border:`none`,padding:0,font:`inherit`,color:`inherit`,textAlign:`left`},onClick:()=>N(n),children:n.description})})},{label:`Version`,id:`version`,render:(e,t,n,r)=>(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(V,{title:`Plugin v.${n.version}`,children:(0,Y.jsx)(`span`,{children:n.version.split(`-`)[0]+(n.version.includes(`-dev-`)?`@dev`:``)+(n.version.includes(`-git-`)?`@git`:``)})})})},{label:`Author`,id:`author`,render:(e,t,n,r)=>(0,Y.jsx)(Y.Fragment,{children:n.author?n.author.replace(`https://github.com/`,``):`Unknown`})},{label:`Type`,id:`type`,render:(e,t,n,r)=>(0,Y.jsx)(Y.Fragment,{children:n.type?n.type.replace(`Platform`,``):`Unknown`})},{label:`Devices`,id:`registeredDevices`},{label:`Actions`,id:`actions`,required:!0,noSort:!0,render:(e,n,r,i)=>(0,Y.jsxs)(`div`,{style:{margin:`0px`,padding:`0px`,gap:`4px`,display:`flex`,flexDirection:`row`},children:[f&&f.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,Y.jsx)(V,{title:`Shows the QRCode or the fabrics`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:In(r.matter)},onClick:()=>{r.matter?.id&&t(r.matter?.id)},size:`small`,children:(0,Y.jsx)(ie,{})})}),f&&f.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,Y.jsx)(V,{title:`Restart the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`},onClick:()=>te(r),size:`small`,children:(0,Y.jsx)(st,{})})}),(0,Y.jsx)(V,{title:`Plugin config`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{disabled:r.restartRequired===!0,style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>R(r),size:`small`,children:(0,Y.jsx)(B,{})})}),f&&!f.readOnly&&(0,Y.jsx)(V,{title:`Remove the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{T(`Remove plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`remove`,r)},size:`small`,children:(0,Y.jsx)(ee,{})})}),r.enabled?(0,Y.jsx)(V,{title:`Disable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{T(`Disable plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`disable`,r)},size:`small`,children:(0,Y.jsx)(rt,{})})}):(0,Y.jsx)(Y.Fragment,{}),r.enabled?(0,Y.jsx)(Y.Fragment,{}):(0,Y.jsx)(V,{title:`Enable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>ne(r),size:`small`,children:(0,Y.jsx)(ce,{})})}),(0,Y.jsx)(V,{title:`Open the plugin help`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>F(r),size:`small`,children:(0,Y.jsx)(re,{})})}),(0,Y.jsx)(V,{title:`Open the plugin version history`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>ae(r),size:`small`,children:(0,Y.jsx)(g,{})})}),r.enabled&&r.frontendPath&&(0,Y.jsx)(V,{title:`Open the plugin frontend`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>oe(r),size:`small`,children:(0,Y.jsx)(m,{})})}),r.local!==!0&&r.latestVersion!==void 0&&r.latestVersion!==r.version&&f&&!f.readOnly&&(0,Y.jsx)(V,{title:`Update the plugin to the latest version v.${r.latestVersion}`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{color:`var(--primary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>k(r),size:`small`,children:(0,Y.jsx)(ct,{})})}),r.local!==!0&&(r.version.includes(`-dev-`)||r.version.includes(`-git-`))&&r.devVersion!==void 0&&r.devVersion!==r.version&&f&&!f.readOnly&&(0,Y.jsx)(V,{title:`Update the plugin to the latest dev version v.${r.devVersion}`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{color:`var(--secondary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>A(r),size:`small`,children:(0,Y.jsx)(ct,{})})}),f&&!f.readOnly&&(0,Y.jsx)(V,{title:`Sponsor the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(L,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`#b6409c`},onClick:()=>P(r),size:`small`,children:(0,Y.jsx)(le,{})})})]})},{label:`Status`,id:`status`,required:!0,noSort:!0,render:(e,t,n,r)=>(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,flex:`1 1 auto`,margin:`0`,padding:`0`,gap:`5px`,width:`auto`,maxWidth:`max-content`},children:n.error?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(Cr,{status:!1,enabledText:`Error`,disabledText:`Error`,tooltipText:`The plugin is in error state. Check the log!`})}):(0,Y.jsx)(Y.Fragment,{children:n.enabled?(0,Y.jsx)(Y.Fragment,{children:n.loaded&&n.started&&n.configured?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(Cr,{status:n.loaded,enabledText:`Running`,tooltipText:`Whether the plugin is running`})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Cr,{status:n.loaded,enabledText:`Loaded`,tooltipText:`Whether the plugin has been loaded`}),(0,Y.jsx)(Cr,{status:n.started,enabledText:`Started`,tooltipText:`Whether the plugin started`}),(0,Y.jsx)(Cr,{status:n.configured,enabledText:`Configured`,tooltipText:`Whether the plugin has been configured`})]})}):(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(Cr,{status:n.enabled,enabledText:`Enabled`,disabledText:`Disabled`,tooltipText:`Whether the plugin is enable or disabled`})})})})}];(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`HomePlugins received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`plugins`?e.response.lock?(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} lock=${e.response.lock} and locking plugins list`),_(t=>t.map(t=>t.name===e.response.lock?{...t,restartRequired:!0}:t))):(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} lock=${e.response.lock} and sending /api/plugins request`),r({id:l.current,sender:`HomePlugins`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`refresh_required`&&e.response.changed===`matter`?(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and setting matter id ${e.response.matter?.id}`),_(t=>{let n=t.findIndex(t=>t.matter?.id===e.response.matter?.id);if(n<0)return q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and matter id ${e.response.matter?.id} not found`),t;q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} set matter id ${e.response.matter?.id}`);let r=[...t];return r[n]={...r[n],matter:e.response.matter},r})):e.method===`refresh_required`&&e.response.changed===`settings`?(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and sending /api/settings request`),r({id:l.current,sender:`HomePlugins`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`plugin_update_required`?(q&&console.log(`HomePlugins received plugin_update_required`,e.response),_(t=>t.map(t=>t.name===e.response.plugin?e.response.devVersion?{...t,devVersion:e.response.version}:{...t,latestVersion:e.response.version}:t))):e.method===`plugin_status_update`?(q&&console.log(`HomePlugins received plugin_status_update`,e.response),_(t=>t.map(t=>t.name===e.response.plugin?{...t,...e.response.status}:t))):e.method===`matterbridge_status_update`&&(q&&console.log(`HomePlugins received matterbridge_status_update: ${e.response.status}`),S(e.response.status)),e.id===l.current&&e.method===`/api/settings`?(q&&console.log(`HomePlugins (id: ${e.id}) received settings:`,e.response),d(e.response.systemInformation),p(e.response.matterbridgeInformation),S(e.response.matterbridgeInformation.bridgeStatus)):e.id===l.current&&e.method===`/api/plugins`&&(q&&console.log(`HomePlugins (id: ${e.id}) received ${e.response.length} plugins:`,e.response),_(e.response))};return i(e,l.current),q&&console.log(`HomePlugins added WebSocket listener id:`,l.current),()=>{a(e),q&&console.log(`HomePlugins removed WebSocket listener`)}},[i,a,r]),(0,G.useEffect)(()=>{n&&(q&&console.log(`HomePlugins sending api requests`),r({id:l.current,sender:`HomePlugins`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:l.current,sender:`HomePlugins`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[n,r]);let w=(0,G.useRef)(null),T=(e,t,n,r)=>{q&&console.log(`handleActionWithConfirmCancel ${n} ${r.name}`),w.current=r,c(e,t,n,E,O)},E=e=>{q&&console.log(`handleConfirm action confirmed ${e} ${w.current?.name}`),e===`remove`&&w.current?j(w.current):e===`disable`&&w.current&&ne(w.current),w.current=null},O=e=>{q&&console.log(`handleCancel action canceled ${e} ${w.current?.name}`),w.current=null},k=e=>{q&&console.log(`handleUpdatePlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e.name,restart:!1}})},A=e=>{q&&console.log(`handleUpdateDevPlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e.name+`@dev`,restart:!1}})},j=e=>{q&&console.log(`handleRemovePlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/removeplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},te=e=>{q&&console.log(`handleRestartPlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/restartplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},ne=e=>{q&&console.log(`handleEnableDisablePlugin plugin:`,e.name,`enabled:`,e.enabled),e.enabled?(e.enabled=!1,r({id:l.current,sender:`HomePlugins`,method:`/api/disableplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})):(e.enabled=!0,r({id:l.current,sender:`HomePlugins`,method:`/api/enableplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}}))},N=e=>{q&&console.log(`handleHomepagePlugin plugin: ${e.name} homepage: ${e.homepage}`),e.homepage&&window.open(e.homepage,`_blank`)},P=e=>{q&&console.log(`handleSponsorPlugin plugin:`,e.name,`funding:`,e.funding),e.funding&&window.open(e.funding,`_blank`)},F=e=>{q&&console.log(`handleHelpPlugin plugin:`,e.name,`help:`,e.help),e.help&&window.open(e.help,`_blank`)},ae=e=>{q&&console.log(`handleChangelogPlugin plugin:`,e.name,`changelog:`,e.changelog),e.changelog&&window.open(e.changelog,`_blank`)},oe=e=>{let t=`${Vt}plugins/${e.name}/`;console.log(`handleFrontendPlugin plugin:`,e.name,`basePath:`,Vt,`frontendPath:`,e.frontendPath,`computed pluginFrontendPath:`,t),e.frontendPath&&y({name:e.name,path:t})},se=e=>{let t=e.currentTarget.contentDocument;if(!t?.head)return;let n=getComputedStyle(document.body),r=n.getPropertyValue(`--primary-color`).trim()||`#0d6efd`,i=n.getPropertyValue(`--div-bg-color`).trim()||`#111111`;t.getElementById(`matterbridge-plugin-scrollbar-style`)?.remove();let a=t.createElement(`style`);a.id=`matterbridge-plugin-scrollbar-style`,a.textContent=`
|
|
23
23
|
html,
|
|
24
24
|
body {
|
|
25
25
|
background-color: ${i};
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matterbridge/frontend",
|
|
3
|
-
"version": "3.5.5-dev-
|
|
3
|
+
"version": "3.5.5-dev-20260727-b80c82f",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@matterbridge/frontend",
|
|
9
|
-
"version": "3.5.5-dev-
|
|
9
|
+
"version": "3.5.5-dev-20260727-b80c82f",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@emotion/react": "11.14.0",
|
package/package.json
CHANGED