iobroker.admin 7.7.2 → 7.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -8
- package/admin/admin.png +0 -0
- package/admin/i18n/de.json +1 -1
- package/admin/i18n/es.json +1 -1
- package/admin/i18n/fr.json +1 -1
- package/admin/i18n/it.json +1 -1
- package/admin/i18n/nl.json +1 -1
- package/admin/i18n/pl.json +1 -1
- package/admin/i18n/pt.json +1 -1
- package/admin/i18n/ru.json +1 -1
- package/admin/i18n/uk.json +1 -1
- package/admin/i18n/zh-cn.json +1 -1
- package/admin/jsonConfig.json5 +1 -2
- package/adminWww/assets/{AdapterUpdateDialog-DHGhgEEq.js → AdapterUpdateDialog-BQUTMe7v.js} +1 -1
- package/adminWww/assets/Adapters-KuMqwfzU.js +9 -0
- package/adminWww/assets/Config-LH40Fzyp.js +1 -0
- package/adminWww/assets/CustomModal-UQ6ICKdg.js +1 -0
- package/adminWww/assets/CustomTab-CE2qvngn.js +1 -0
- package/adminWww/assets/DefaultPropsProvider-BxjOYH1h.js +30 -0
- package/adminWww/assets/EasyMode-XXQKZmWs.js +1 -0
- package/adminWww/assets/{Enums-BSICIhWI.js → Enums-Ddmi-fYo.js} +3 -3
- package/adminWww/assets/{Fields-C3JkTmfP.js → Fields-CQNdUYkd.js} +1 -1
- package/adminWww/assets/{Files-DK85-COY.js → Files-DgOiCRiN.js} +2 -2
- package/adminWww/assets/FilledInput-B9JSi0Ta.js +2 -0
- package/adminWww/assets/Hosts-BgDpLhdl.js +121 -0
- package/adminWww/assets/Instances-DikJwBl0.js +2 -0
- package/adminWww/assets/Intro-vxIHtYzr.js +2 -0
- package/adminWww/assets/Logs-DZUWTbJn.js +1 -0
- package/adminWww/assets/Objects-Dm1_4aGR.js +60 -0
- package/adminWww/assets/{State-BqfD2ABf.js → State-CrcWiBdx.js} +1 -1
- package/adminWww/assets/TextField-j-uewRwI.js +138 -0
- package/adminWww/assets/ThemeProvider-DHntAcOp.js +29 -0
- package/adminWww/assets/Users-GcWjwa7A.js +1 -0
- package/adminWww/assets/ace-1DqSbvTN.js +985 -0
- package/adminWww/assets/{bootstrap-BYQTdf9r.js → bootstrap-B3ZI_-0g.js} +112 -112
- package/adminWww/assets/{createSvgIcon-Bh3KWtyp.js → createSvgIcon-Ds12z7B3.js} +1 -1
- package/adminWww/assets/emotion-cache.browser.esm-BgJfNZJN.js +1 -0
- package/adminWww/assets/emotion-react.browser.esm-CBtpmfsG.js +8 -0
- package/adminWww/assets/emotion-serialize.esm-Q4o_CgeF.js +1 -0
- package/adminWww/assets/emotion-styled.browser.esm-BeD8nBzN.js +1 -0
- package/adminWww/assets/emotion-use-insertion-effect-with-fallbacks.browser.esm-BIy6Leuu.js +1 -0
- package/adminWww/assets/geosearch.module-B6h9BuIR.js +1 -0
- package/adminWww/assets/hostInit-fzxL8JAx.js +1 -1
- package/adminWww/assets/iconBase-BAOnvyiQ.js +1 -0
- package/adminWww/assets/{index-Qa7Q_Dz5.js → index-BOnh7es7.js} +1 -1
- package/adminWww/assets/{index-B1ITPhEY.js → index-BSfwmoAE.js} +3 -3
- package/adminWww/assets/{index-rKfs-rCa.js → index-BVgYaw7t.js} +1 -1
- package/adminWww/assets/{index-D--ojYan.js → index-C9i3HTsG.js} +1 -1
- package/adminWww/assets/{index-wN1ZlPSW.js → index-CELb-gCK.js} +2 -2
- package/adminWww/assets/{index-DPDg2YA0.js → index-CU6eZCem.js} +1 -1
- package/adminWww/assets/{index-DTGUg51P.js → index-DZ0MncEz.js} +2 -2
- package/adminWww/assets/index-Dg-s3k0-.js +10 -0
- package/adminWww/assets/index-tS5iCAF7.js +55 -0
- package/adminWww/assets/{iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-BOKYvG_W.js → iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-CXogaIXO.js} +1 -1
- package/adminWww/assets/{iobroker_admin__loadShare__leaflet__loadShare__-h9SMNPLU.js → iobroker_admin__loadShare__leaflet__loadShare__-DIpcqFbm.js} +1 -1
- package/adminWww/assets/{iobroker_admin__loadShare__prop_mf_2_types__loadShare__-BnsS7SOQ.js → iobroker_admin__loadShare__prop_mf_2_types__loadShare__-pDONiJUe.js} +1 -1
- package/adminWww/assets/{iobroker_admin__loadShare__react__loadShare__-Bis6NHgw.js → iobroker_admin__loadShare__react__loadShare__-CuzHmAOj.js} +1 -1
- package/adminWww/assets/iobroker_admin__mf_v__runtimeInit__mf_v__-CHE4rLsT.js +5 -0
- package/adminWww/assets/leaflet-src-BRBM-1HK.js +4 -0
- package/adminWww/assets/{sentry-H_UdJ2zx.js → sentry-B6yHtsbd.js} +1 -1
- package/adminWww/assets/{zh-cn-vvAC9zpl.js → zh-cn-heTcsLnU.js} +13 -13
- package/adminWww/img/admin.png +0 -0
- package/adminWww/index.html +2 -2
- package/adminWww/mf-manifest.json +1 -1
- package/adminWww/remoteEntry.js +2 -2
- package/build/i18n/de.json +18 -0
- package/build/i18n/es.json +18 -0
- package/build/i18n/fr.json +18 -0
- package/build/i18n/it.json +18 -0
- package/build/i18n/nl.json +18 -0
- package/build/i18n/pl.json +18 -0
- package/build/i18n/pt.json +18 -0
- package/build/i18n/ru.json +18 -0
- package/build/i18n/uk.json +18 -0
- package/build/i18n/zh-cn.json +18 -0
- package/build/lib/DockerManager.js +1315 -0
- package/build/lib/DockerManager.js.map +1 -0
- package/build/lib/dockerManager.types.js +3 -0
- package/build/lib/dockerManager.types.js.map +1 -0
- package/{build-backend → build}/lib/testPassword.js +1 -1
- package/{build-backend → build}/lib/testPassword.js.map +1 -1
- package/{build-backend → build}/lib/translations.js +16 -1
- package/build/lib/translations.js.map +1 -0
- package/{build-backend → build}/main.js +58 -5
- package/build/main.js.map +1 -0
- package/io-package.json +14 -14
- package/package.json +7 -7
- package/adminWww/assets/Adapters-CgSIajcF.js +0 -7
- package/adminWww/assets/Config-BQSl4bfA.js +0 -1
- package/adminWww/assets/CustomModal-DNMTLv4y.js +0 -1
- package/adminWww/assets/CustomTab-Bl8S8QZW.js +0 -1
- package/adminWww/assets/DefaultPropsProvider-u5xB1Fxz.js +0 -30
- package/adminWww/assets/EasyMode-xDbqrply.js +0 -1
- package/adminWww/assets/FilledInput-CysG4ax_.js +0 -2
- package/adminWww/assets/Hosts-qIsB4Gub.js +0 -121
- package/adminWww/assets/Instances-BA_DCzs8.js +0 -2
- package/adminWww/assets/Intro-00oh6SLw.js +0 -2
- package/adminWww/assets/Logs-Cvpgh-zN.js +0 -1
- package/adminWww/assets/Objects-Dp71iotS.js +0 -60
- package/adminWww/assets/Tabs-sxfWgN0b.js +0 -138
- package/adminWww/assets/Users-CDcWqTfZ.js +0 -1
- package/adminWww/assets/ace-BG5WYul1.js +0 -985
- package/adminWww/assets/blueGrey-DYsiMDOn.js +0 -29
- package/adminWww/assets/emotion-cache.browser.esm-B8BFze5o.js +0 -1
- package/adminWww/assets/emotion-react.browser.esm-BCDt9NrH.js +0 -8
- package/adminWww/assets/emotion-serialize.esm-BUa21YfQ.js +0 -1
- package/adminWww/assets/emotion-styled.browser.esm-CyFqGgyG.js +0 -1
- package/adminWww/assets/emotion-utils.browser.esm-pglN4_eI.js +0 -1
- package/adminWww/assets/geosearch.module-DH4NhiPj.js +0 -1
- package/adminWww/assets/iconBase-C3vi24ZE.js +0 -1
- package/adminWww/assets/index-D3IAEXXP.js +0 -10
- package/adminWww/assets/index-qcIeekse.js +0 -55
- package/adminWww/assets/iobroker_admin__mf_v__runtimeInit__mf_v__-CTkuGOOk.js +0 -5
- package/adminWww/assets/leaflet-src-A2ZHl6nF.js +0 -4
- package/build-backend/i18n/de.json +0 -18
- package/build-backend/i18n/es.json +0 -18
- package/build-backend/i18n/fr.json +0 -18
- package/build-backend/i18n/it.json +0 -18
- package/build-backend/i18n/nl.json +0 -18
- package/build-backend/i18n/pl.json +0 -18
- package/build-backend/i18n/pt.json +0 -18
- package/build-backend/i18n/ru.json +0 -18
- package/build-backend/i18n/uk.json +0 -18
- package/build-backend/i18n/zh-cn.json +0 -18
- package/build-backend/lib/translations.js.map +0 -1
- package/build-backend/main.js.map +0 -1
- /package/{build-backend → build}/i18n/en.json +0 -0
- /package/{build-backend → build}/lib/checkLinuxPass.js +0 -0
- /package/{build-backend → build}/lib/checkLinuxPass.js.map +0 -0
- /package/{build-backend → build}/lib/utils.js +0 -0
- /package/{build-backend → build}/lib/utils.js.map +0 -0
- /package/{build-backend → build}/lib/web.js +0 -0
- /package/{build-backend → build}/lib/web.js.map +0 -0
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{j as e,E as pt,B as mt,J as xt}from"./DefaultPropsProvider-u5xB1Fxz.js";import{i as L,R as q}from"./iobroker_admin__loadShare__react__loadShare__-Bis6NHgw.js";import{s as V,i as o,U as R,I as w,a as u,C as ft,G as yt,b as z,H as wt,L as bt,c as N,A as jt,d as Ct,e as Z,f as dt,T as vt,S as st,g as At,h as Tt}from"./bootstrap-BYQTdf9r.js";import{F as ct}from"./index-DPDg2YA0.js";import{M as St,s as It,C as it}from"./sentry-H_UdJ2zx.js";import{c as Q,A as kt}from"./AdapterUpdateDialog-DHGhgEEq.js";import{C as Vt}from"./CustomModal-DNMTLv4y.js";import{a as ht}from"./blueGrey-DYsiMDOn.js";import"./iobroker_admin__loadShare__prop_mf_2_types__loadShare__-BnsS7SOQ.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./iobroker_admin__mf_v__runtimeInit__mf_v__-CTkuGOOk.js";import"./emotion-serialize.esm-BUa21YfQ.js";import"./iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-BOKYvG_W.js";import"./ace-BG5WYul1.js";import"./FilledInput-CysG4ax_.js";import"./preload-helper-Dp1pzeXC.js";import"./iobroker_admin__loadShare__leaflet__loadShare__-h9SMNPLU.js";import"./extends-CF3RwP-h.js";import"./iconBase-C3vi24ZE.js";import"./zh-cn-vvAC9zpl.js";import"./State-BqfD2ABf.js";import"./emotion-cache.browser.esm-B8BFze5o.js";const A={smallAvatar:{width:24,height:24},listItem:p=>({mb:"2px",background:p.palette.background,"@media screen and (max-width: 400px)":{pl:"2px"}}),toVersion:p=>({color:p.palette.mode==="dark"?"#00dc00":"#008100",fontWeight:"bold",ml:"4px"}),updateDone:{background:"#5ef05e80",opacity:.7},minWidthCss:{"@media screen and (max-width: 400px)":{minWidth:32}},wrapperButton:{},typography:{paddingRight:30},versions:{minWidth:110,display:"inline-block"},closeButton:p=>({position:"absolute",right:8,top:8,color:p.palette.grey[500]}),languageButton:{position:"absolute",right:60,top:8},languageButtonActive:p=>({color:p.palette.primary.main}),versionHeader:p=>({background:"#4dabf5",borderRadius:"3px",pl:"10px",fontWeight:"bold",color:p.palette.mode==="dark"?"black":"white"}),repoStableVersionText:p=>({color:p.palette.mode==="dark"?"#8dff7a":"#2b9800",fontWeight:"bold",marginLeft:"4px"}),repoLatestVersionText:p=>({color:p.palette.mode==="dark"?"#a3fcff":"#005498",fontWeight:"bold",marginLeft:"4px"})};class tt extends L.Component{updateAvailable;initialVersions;currentRef;current;constructor(t){super(t),this.updateAvailable=this.detectUpdates(),this.initialVersions={},this.updateAvailable.forEach(s=>this.initialVersions[s]=this.props.installed[s].version),this.state={showNews:null},this.currentRef=q.createRef(),this.current=t.current,this.props.onUpdateSelected([...this.updateAvailable],this.updateAvailable)}static isUpdateAvailable(t){const{oldVersion:s,newVersion:i,name:r}=t;try{return V.gt(i,s)}catch{return console.warn(`Cannot compare "${i}" and "${s}" of adapter ${r}`),!1}}detectUpdates(){const t=[];return Object.keys(this.props.repository).forEach(s=>{const i=this.props.installed[s];s==="js-controller"||s==="admin"||i&&this.props.repository[s].version&&i.ignoreVersion!==this.props.repository[s].version&&tt.isUpdateAvailable({oldVersion:i.version,newVersion:this.props.repository[s].version,name:s})&&(Q(this.props.repository[s].messages,i.version,this.props.repository[s].version)?console.log(`Adapter ${s} is filtered out from update all functionality, because it has messages which need to be read before update`):t.push(s))}),t.sort(),t}getNews(t){const s=this.props.repository[t],i=this.props.installed[t],r=[];return i&&(s!=null&&s.news)&&Object.keys(s.news).forEach(n=>{try{V.gt(n,i.version)&&r.push({version:n,news:this.props.noTranslation?s.news[n].en:s.news[n][this.props.lang]||s.news[n].en})}catch{console.warn(`Cannot compare "${n}" and "${i.version}"`)}}),r}renderOneAdapter(t){const s=this.props.selected.includes(t);if((this.props.finished||this.props.inProcess)&&!s||!this.props.installed[t])return null;const i=`.${this.props.installed[t].localIcon}`;return e.jsxs(o.ListItem,{dense:!0,sx:{"&.MuiListItem-root":R.getStyle(this.props.theme,A.listItem,this.props.updated.includes(t)&&A.updateDone)},ref:this.props.current===t?this.currentRef:null,secondaryAction:!this.props.finished&&!this.props.inProcess?e.jsx(o.Checkbox,{edge:"end",checked:s,tabIndex:-1,disableRipple:!0,disabled:this.props.inProcess,onClick:()=>{const r=[...this.props.selected],n=r.indexOf(t);n!==-1?r.splice(n,1):(r.push(t),r.sort()),this.props.onUpdateSelected(r)}}):this.props.current===t&&!this.props.stopped&&!this.props.finished&&e.jsx(o.CircularProgress,{}),children:[e.jsx(o.ListItemIcon,{sx:A.minWidthCss,children:e.jsx(o.Avatar,{variant:"square",alt:t,src:i,style:A.smallAvatar})}),e.jsx(o.ListItemText,{primary:t,title:this.getNews(t).map(r=>`${r.version}: ${r.news}`).join(`
|
|
2
|
-
`),secondary:e.jsxs("span",{children:[e.jsxs("div",{style:A.versions,children:[this.initialVersions[t]," →",e.jsx(o.Box,{component:"span",sx:A.toVersion,children:this.props.repository[t].version})]}),e.jsx(o.IconButton,{title:w.t("Show change log"),onClick:()=>this.setState({showNews:{adapter:t,version:this.props.repository[t].version,fromVersion:this.initialVersions[t]}}),size:"small",children:e.jsx(u.Info,{})})]})})]},t)}getReactNews(t,s){var d,l,g,x;const i=this.props.repository[t],r=this.props.installed[t];s=s||r.version;const n=[];let a,c;const h=this.props.repository._repoInfo;return h!=null&&h.stable?(a=(d=this.props.repository[t])==null?void 0:d.version,c=(l=this.props.repository[t])==null?void 0:l.latestVersion):(a=(g=this.props.repository[t])==null?void 0:g.stable,c=(x=this.props.repository[t])==null?void 0:x.version),r&&(i!=null&&i.news)&&Object.keys(i.news).forEach(m=>{try{if(V.gt(m,s)&&i.news[m]){const j=(this.props.noTranslation?i.news[m].en||"":i.news[m][this.props.lang]||i.news[m].en||"").split(`
|
|
3
|
-
`).map(O=>O.trim().replace(/^\*\s?/,"").replace(/<!--[^>]*->/g,"").replace(/<! -[^>]*->/g,"").trim()).filter(O=>!!O);n.push(e.jsxs(o.Grid2,{children:[e.jsxs(o.Typography,{sx:A.versionHeader,children:[m,c===m?e.jsx(o.Box,{component:"span",sx:A.repoLatestVersionText,children:"(latest)"}):null,a===m?e.jsx(o.Box,{component:"span",sx:A.repoStableVersionText,children:`(${w.t("stable")})`}):null]}),j.map((O,S)=>e.jsx(o.Typography,{component:"div",variant:"body2",children:`• ${O}`},`${m}-${S}`))]},m))}}catch{console.warn(`Cannot compare "${m}" and "${s}"`)}}),n}renderShowNews(){if(this.state.showNews){const t=this.getReactNews(this.state.showNews.adapter,this.state.showNews.fromVersion),s=R.getStyle(this.props.theme,A.closeButton),i=R.getStyle(this.props.theme,A.languageButtonActive);return e.jsxs(o.Dialog,{onClose:()=>this.setState({showNews:null}),open:!0,children:[e.jsx(o.DialogTitle,{children:e.jsxs(o.Typography,{component:"h2",variant:"h6",sx:{"&.MuiTypography-root":A.typography},children:[e.jsx("div",{style:{width:"calc(100% - 60px)"},children:w.t('Update "%s" to v%s',this.state.showNews.adapter,this.state.showNews.version)}),e.jsx(o.IconButton,{size:"large",style:s,onClick:()=>this.setState({showNews:null}),children:e.jsx(u.Close,{})}),w.getLanguage()!=="en"&&this.props.toggleTranslation?e.jsx(o.IconButton,{size:"large",style:{...A.languageButton,...this.props.noTranslation?i:void 0},onClick:this.props.toggleTranslation,title:w.t("Disable/Enable translation"),children:e.jsx(u.Language,{})}):null]})}),e.jsx(o.DialogContent,{dividers:!0,children:e.jsx(o.Grid2,{container:!0,direction:"column",spacing:2,wrap:"nowrap",children:t.length?e.jsxs(o.Grid2,{children:[e.jsx(o.Typography,{variant:"h6",gutterBottom:!0,children:w.t("Change log")}),e.jsx(o.Grid2,{container:!0,spacing:2,direction:"column",wrap:"nowrap",children:t})]}):w.t("No change log available")})}),e.jsx(o.DialogActions,{style:A.wrapperButton,children:e.jsx(o.Button,{variant:"contained",onClick:()=>this.setState({showNews:null}),color:"grey",startIcon:e.jsx(u.Close,{}),children:w.t("Close")})})]})}return null}render(){return this.current!==this.props.current&&(this.current=this.props.current,setTimeout(()=>{var t;return(t=this.currentRef.current)==null?void 0:t.scrollIntoView()},200)),e.jsxs(o.List,{style:A.root,children:[this.updateAvailable.map(t=>this.renderOneAdapter(t)),this.renderShowNews()]})}}const P={dialogRoot:{height:"calc(100% - 64px)"},wrapperHead:{justifyContent:"space-between",display:"flex"},checkbox:{marginRight:10},appBar:p=>({flexWrap:"wrap",position:"sticky",bottom:-10,pl:1,background:p.name==="blue"?"#5d6467":p.name==="dark"?"#5b5b5b":"#FFF"}),container:{overflow:"hidden",height:"calc(100% - 48px)","@media screen and (max-width: 602px)":{height:"auto"}},content:{"@media screen and (max-width: 500px)":{p:1}},languageButton:{position:"absolute",right:73,top:11},languageButtonActive:p=>({color:p.palette.primary.main})};class Dt extends L.Component{updateAvailable=[];onAdapterFinished;processList;constructor(t){super(t),this.state={selected:[],inProcess:!1,finished:!1,current:"",updated:[],stopped:!1,debug:(window._localStorage||window.localStorage).getItem("AdaptersUpdaterDialog.debug")==="true",stopOnError:(window._localStorage||window.localStorage).getItem("AdaptersUpdaterDialog.stopOnError")!=="false",closeOnFinished:(window._localStorage||window.localStorage).getItem("AdaptersUpdaterDialog.closeOnFinished")==="true",currentVersion:""},this.updateAvailable=[]}updateAdapter(t,s,i){this.onAdapterFinished=i,this.setState({current:t,currentVersion:s})}onStartUpdate(){this.setState({inProcess:!0},()=>{this.props.onSetCommandRunning(!0),this.processList=[...this.state.selected].map(t=>{var s;return{adapter:t,version:(s=this.props.repository[t])==null?void 0:s.version}}),this.updateAdapters(()=>{this.setState({inProcess:!1,finished:!0},()=>{this.props.onSetCommandRunning(!1),this.state.closeOnFinished&&this.props.onClose(!!this.state.updated.length)})})})}updateAdapters(t){if(!this.processList||!this.processList.length||this.state.stopped)t&&t();else{const{adapter:s,version:i}=this.processList.shift();this.updateAdapter(s,i,()=>{const r=[...this.state.updated];r.push(s),this.setState({updated:r},()=>setTimeout(()=>this.updateAdapters(t),200))})}}render(){const t=this.props.noTranslation?R.getStyle(this.props.theme,P.languageButtonActive):void 0;return e.jsxs(o.Dialog,{open:!0,maxWidth:"lg",fullWidth:!!this.state.current,onClose:()=>this.props.onClose(!!this.state.updated.length),"aria-labelledby":"update-dialog-title","aria-describedby":"update-dialog-description",sx:{"& .MuiPaper-root":P.dialogRoot},scroll:"paper",children:[e.jsx(o.DialogTitle,{id:"update-dialog-title",children:e.jsxs("div",{style:P.wrapperHead,children:[this.props.t("Update %s adapter(s)",this.state.selected.length),!this.state.finished&&!this.state.inProcess&&e.jsx(o.Tooltip,{title:this.props.t("Select/Unselect all"),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:e.jsx(o.Checkbox,{checked:this.state.selected.length===this.updateAvailable.length,style:P.checkbox,tabIndex:-1,indeterminate:this.state.selected.length!==this.updateAvailable.length&&this.state.selected.length!==0,disableRipple:!0,onClick:()=>{let s=[];this.state.selected.length!==this.updateAvailable.length&&(s=[...this.updateAvailable]),this.setState({selected:s})}})}),w.getLanguage()!=="en"&&this.props.toggleTranslation?e.jsx(o.IconButton,{size:"large",style:{...P.languageButton,...t},onClick:()=>this.props.toggleTranslation(),title:w.t("Disable/Enable translation"),children:e.jsx(u.Language,{})}):null]})}),e.jsxs(o.DialogContent,{sx:{"&.MuiDialogContent-root":P.content},style:{height:"100%"},children:[e.jsxs(o.Grid2,{container:!0,direction:"row",sx:P.container,children:[e.jsx(o.Grid2,{style:{height:"100%",overflow:"hidden",width:this.state.current?250:"100%"},children:e.jsx("div",{style:{height:"100%",overflow:"auto"},children:e.jsx(tt,{finished:this.state.finished,inProcess:this.state.inProcess,selected:this.state.selected,current:this.state.current,stopped:this.state.stopped,updated:this.state.updated,lang:this.props.lang,installed:this.props.installed,repository:this.props.repository,noTranslation:this.props.noTranslation,toggleTranslation:this.props.toggleTranslation,onUpdateSelected:(s,i)=>{i&&(this.updateAvailable=i),this.setState({selected:s})},theme:this.props.theme})})}),!!this.state.current&&e.jsx(o.Grid2,{style:{height:"100%",overflow:"hidden",width:"calc(100% - 260px)",minWidth:240},children:e.jsx(ft,{noSpacing:!0,ready:!0,host:this.props.currentHost,socket:this.props.socket,t:this.props.t,cmd:`upgrade ${this.state.current}@${this.state.currentVersion}${this.state.debug?" --debug":""}`,onFinished:()=>this.onAdapterFinished(),errorFunc:()=>{this.state.stopOnError?(this.setState({stopped:!0,finished:!0}),this.onAdapterFinished=null,this.props.onSetCommandRunning(!1)):this.onAdapterFinished()}},this.state.current)})]}),e.jsxs(o.Toolbar,{variant:"dense",disableGutters:!0,sx:P.appBar,children:[e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{disabled:this.state.finished,checked:this.state.stopOnError,onChange:()=>{(window._localStorage||window.localStorage).setItem("AdaptersUpdaterDialog.stopOnError",this.state.stopOnError?"false":"true"),this.setState({stopOnError:!this.state.stopOnError})}}),label:this.props.t("Stop on error")}),e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{disabled:this.state.finished,checked:this.state.closeOnFinished,onChange:()=>{(window._localStorage||window.localStorage).setItem("AdaptersUpdaterDialog.closeOnFinished",this.state.closeOnFinished?"false":"true"),this.setState({closeOnFinished:!this.state.closeOnFinished})}}),label:this.props.t("Close on finished")}),e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{disabled:this.state.finished||this.state.inProcess,checked:this.state.debug,onChange:()=>{(window._localStorage||window.localStorage).setItem("AdaptersUpdaterDialog.debug",this.state.debug?"false":"true"),this.setState({debug:!this.state.debug})}}),label:this.props.t("Debug info")})]})]}),e.jsxs(o.DialogActions,{children:[e.jsx(o.Button,{id:"adapters-update-dialog-update",variant:"contained",disabled:this.state.stopped||this.state.inProcess||this.state.finished||!this.state.selected.length,onClick:()=>this.onStartUpdate(),color:"primary",autoFocus:!0,startIcon:e.jsx(u.Check,{}),children:this.props.t("Update")}),e.jsx(o.Button,{id:"adapters-update-dialog-cancel",variant:"contained",disabled:!this.state.inProcess,color:"grey",startIcon:e.jsx(u.Cancel,{}),onClick:()=>{this.setState({stopped:!0,finished:!0}),this.props.onSetCommandRunning(!1)},children:this.props.t("Cancel")}),e.jsx(o.Button,{id:"adapters-update-dialog-close",variant:"contained",onClick:()=>this.props.onClose(!!this.state.updated.length),disabled:this.state.inProcess&&!this.state.stopped,color:this.state.stopped?"error":"grey",startIcon:e.jsx(u.Close,{}),children:this.props.t("Close")})]})]})}}class ot extends yt{host;prefix;constructor(t,s){super(t,`${s}.adapter`,"adapter"),this.prefix=`${s}.adapter.`,this.host=s}getObject(t){return this.objects&&this.objects[this.prefix+t]||null}getHost(){return this.host}}const Rt="data:image/svg+xml,%3csvg%20viewBox='0%200%202500%202500'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M0%200h2500v2500H0z'%20fill='%23c00'/%3e%3cpath%20d='M1241.5%20268.5h-973v1962.9h972.9V763.5h495v1467.9h495V268.5z'%20fill='%23fff'/%3e%3c/svg%3e";function Y(p){return{id:`github-install-dialog-tab-${p}`,"aria-controls":`github-install-dialog-panel-${p}`}}const C={root:p=>({backgroundColor:p.palette.background.paper,width:"100%",height:"100%"}),paper:{maxWidth:1e3},tabPaper:{padding:16},title:p=>({mt:"10px",p:1,ml:1,fontSize:18,color:p.palette.primary.main}),warningText:{color:"#f53939"},noteText:{marginTop:16},errorTextNoGit:{fontSize:13,color:"#ff1616"},listIcon:{width:24,height:24},listIconWithMargin:{width:24,height:24,marginRight:8},tabSelected:p=>({color:p.palette.mode==="dark"?p.palette.secondary.contrastText:"#222 !important"})};function Lt(p){const t=[];for(let s=0;s<p.length;s++)typeof p[s]=="object"?p[s].forEach(i=>t.push(i)):t.push(p[s]);return t}const rt=10;class Ot extends q.Component{constructor(t){super(t);let s=[];const i=(window._localstorage||window.localStorage).getItem("App.npmHistory");if(i)try{s=JSON.parse(i)}catch{}this.state={autoCompleteValue:(window._localstorage||window.localStorage).getItem("App.autocomplete")||null,debug:(window._localstorage||window.localStorage).getItem("App.gitDebug")==="true",url:(window._localstorage||window.localStorage).getItem("App.userUrl")||"",currentTab:(window._localstorage||window.localStorage).getItem("App.gitTab")||"npm",customHistory:s}}renderNpm(){return this.state.currentTab==="npm"?e.jsxs(o.Paper,{style:C.tabPaper,id:"github-install-dialog-panel-npm",children:[e.jsx("div",{style:{display:"flex",alignItems:"center"},children:e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:this.state.debug,onChange:t=>{(window._localstorage||window.localStorage).setItem("App.gitDebug",t.target.checked?"true":"false"),this.setState({debug:t.target.checked})}}),label:this.props.t("Debug outputs")})}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-end"},children:[e.jsx(u.Sms,{style:{marginRight:10}}),e.jsx(o.Autocomplete,{fullWidth:!0,value:this.state.autoCompleteValue,onChange:(t,s)=>{(window._localstorage||window.localStorage).setItem("App.autocomplete",s),this.setState({autoCompleteValue:s})},options:this.getList(),getOptionLabel:t=>(t==null?void 0:t.name)??"",renderInput:t=>{var i;const s={...t};return s.InputProps=s.InputProps||{},s.InputProps.startAdornment=e.jsx(o.InputAdornment,{position:"start",children:e.jsx(z,{src:((i=this.state.autoCompleteValue)==null?void 0:i.icon)||"",style:C.listIcon})}),e.jsx(o.TextField,{variant:"standard",...t,label:w.t("Select adapter")})},renderOption:(t,s)=>e.jsxs(o.Box,{component:"li",sx:{"& > img":{mr:2,flexShrink:0}},...t,children:[e.jsx(z,{src:(s==null?void 0:s.icon)||"",style:C.listIconWithMargin}),(s==null?void 0:s.name)??""]})})]}),e.jsx("div",{style:{fontSize:24,fontWeight:"bold",marginTop:40},children:this.props.t("Warning!")}),e.jsx("div",{style:C.warningText,children:this.props.t("npm_warning","NPM","NPM")}),e.jsx("div",{style:C.noteText,children:this.props.t("github_note")})]}):null}renderGitHub(){return this.state.currentTab==="GitHub"?e.jsxs(o.Paper,{style:C.tabPaper,id:"github-install-dialog-panel-github",children:[e.jsx("div",{style:{display:"flex",alignItems:"center"},children:e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:this.state.debug,onChange:t=>{(window._localstorage||window.localStorage).setItem("App.gitDebug",t.target.checked?"true":"false"),this.setState({debug:t.target.checked})}}),label:this.props.t("Debug outputs")})}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-end"},children:[e.jsx(u.Sms,{style:{marginRight:10}}),e.jsx(o.Autocomplete,{fullWidth:!0,value:this.state.autoCompleteValue,getOptionDisabled:t=>!!(t!=null&&t.nogit),renderOption:(t,s)=>e.jsxs(o.Box,{component:"li",sx:{"& > img":{mr:2,flexShrink:0}},...t,children:[e.jsx(z,{src:(s==null?void 0:s.icon)||"",style:C.listIconWithMargin}),(s==null?void 0:s.name)??"",(s==null?void 0:s.nogit)&&e.jsx("div",{style:C.errorTextNoGit,children:w.t("This adapter cannot be installed from git as must be built before installation.")})]}),onChange:(t,s)=>{(window._localstorage||window.localStorage).setItem("App.autocomplete",s),this.setState({autoCompleteValue:s})},options:this.getList(),getOptionLabel:t=>(t==null?void 0:t.name)??"",renderInput:t=>{var i;const s={...t};return s.InputProps=s.InputProps||{},s.InputProps.startAdornment=e.jsx(o.InputAdornment,{position:"start",children:e.jsx(z,{src:((i=this.state.autoCompleteValue)==null?void 0:i.icon)||"",style:C.listIconWithMargin})}),e.jsx(o.TextField,{variant:"standard",...t,label:w.t("Select adapter")})}})]}),e.jsx("div",{style:{fontSize:24,fontWeight:"bold",marginTop:40},children:this.props.t("Warning!")}),e.jsx("div",{style:C.warningText,children:this.props.t("github_warning","GitHub","GitHub")}),e.jsx("div",{style:C.noteText,children:this.props.t("github_note")})]}):null}renderCustom(){return this.state.currentTab==="URL"?e.jsxs(o.Paper,{style:C.tabPaper,id:"github-install-dialog-panel-custom",children:[e.jsx("div",{style:{display:"flex",alignItems:"center"},children:e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:this.state.debug,onChange:t=>{(window._localstorage||window.localStorage).setItem("App.gitDebug",t.target.checked?"true":"false"),this.setState({debug:t.target.checked})}}),label:this.props.t("Debug outputs")})}),e.jsx("div",{style:{display:"flex",alignItems:"center"},children:e.jsx(o.Autocomplete,{fullWidth:!0,value:this.state.url||"",onInputChange:(t,s)=>{(window._localstorage||window.localStorage).setItem("App.userUrl",s||""),this.setState({url:s})},onChange:(t,s)=>{(window._localstorage||window.localStorage).setItem("App.userUrl",s||""),this.setState({url:s})},renderOption:(t,s)=>e.jsxs(o.Box,{component:"li",...t,style:{display:"flex",alignItems:"left"},children:[s,e.jsx("div",{style:{flexGrow:1}}),e.jsx(o.IconButton,{size:"small",onClick:i=>{i.stopPropagation();const r=this.state.customHistory.filter(n=>n!==s);(window._localstorage||window.localStorage).setItem("App.npmHistory",JSON.stringify(r)),this.setState({customHistory:r})},children:e.jsx(u.Delete,{})})]}),freeSolo:!0,options:this.state.customHistory,renderInput:t=>e.jsx(o.TextField,{variant:"standard",...t,onKeyUp:s=>{if(s.key==="Enter"&&this.state.url){const i=this.state.customHistory.filter(r=>r!==this.state.url);i.unshift(this.state.url),i.length>rt&&i.pop(),(window._localstorage||window.localStorage).setItem("App.npmHistory",JSON.stringify(i)),this.state.url.includes(".")?this.props.installFromUrl(this.state.url,this.state.debug,!0):this.props.installFromUrl(`iobroker.${this.state.url}`,this.state.debug,!0),this.setState({autoCompleteValue:null,url:""}),this.props.onClose()}},helperText:this.props.t("URL or file path"),label:this.props.t("URL")})})}),e.jsx("div",{style:{fontSize:24,fontWeight:"bold",marginTop:40},children:this.props.t("Warning!")}),e.jsx("div",{style:C.warningText,children:this.props.t("github_warning","URL","URL")}),e.jsx("div",{style:C.noteText,children:this.props.t("github_note")})]}):null}getList(){const t=this.props.categories.map(i=>i.adapters),s=Lt(t);return s.sort(),s.map((i,r)=>{if(r&&s[r-1]===i)return null;const n=this.props.repository[i];if(!(n!=null&&n.controller)){const a=(n.extIcon||n.meta||n.readme||"").toString().split("/");let c=n==null?void 0:n.name;c||(c=n.titleLang,c&&typeof c=="object"?c=c[w.getLanguage()]||c.en:c=n.title||i);const h={value:`${i}/${a[3]}`,name:`${c} [${a[3]}]`,icon:n.extIcon||n.icon,nogit:!!n.nogit,title:i};return this.props.installed[c]&&c!=="admin"&&(h.icon=`/adapter/${i}/${n.icon.split("/admin/").pop()}`),h}return null}).filter(i=>i).sort((i,r)=>i.name<r.name?-1:i.name>r.name?1:0)}render(){var s;const t=()=>this.setState({autoCompleteValue:null,url:""});return e.jsxs(o.Dialog,{onClose:()=>this.props.onClose(),open:!0,sx:{"& .MuiDialog-paper":C.paper},children:[e.jsx(o.DialogContent,{dividers:!0,children:e.jsxs(o.Box,{component:"div",sx:C.root,children:[e.jsx(o.AppBar,{position:"static",color:"default",children:e.jsxs(o.Tabs,{value:this.state.currentTab,onChange:(i,r)=>{(window._localstorage||window.localStorage).setItem("App.gitTab",r),this.setState({currentTab:r})},variant:"fullWidth",indicatorColor:"secondary",children:[e.jsx(o.Tab,{label:this.props.t("From npm"),wrapped:!0,sx:{"&.Mui-selected":C.tabSelected},icon:e.jsx("img",{src:Rt,alt:"npm",width:24,height:24}),...Y("npm"),value:"npm"}),e.jsx(o.Tab,{label:this.props.t("From github"),wrapped:!0,sx:{"&.Mui-selected":C.tabSelected},icon:e.jsx(ct,{style:{width:24,height:24},width:24,height:24}),...Y("github"),value:"GitHub"}),e.jsx(o.Tab,{label:this.props.t("Custom"),wrapped:!0,sx:{"&.Mui-selected":C.tabSelected},icon:e.jsx(u.Language,{width:24,height:24}),...Y("custom"),value:"URL"})]})}),e.jsx(o.Box,{component:"div",sx:C.title,children:this.props.t("Install or update the adapter from %s",this.state.currentTab||"npm")}),this.renderNpm(),this.renderGitHub(),this.renderCustom()]})}),e.jsxs(o.DialogActions,{children:[e.jsx(o.Button,{id:"github-install-dialog-ok",variant:"contained",disabled:(this.state.currentTab==="GitHub"||this.state.currentTab==="npm")&&!((s=this.state.autoCompleteValue)!=null&&s.value)||this.state.currentTab==="URL"&&!this.state.url,autoFocus:!0,onClick:async()=>{var i,r;if(this.state.currentTab==="GitHub"){const n=(((i=this.state.autoCompleteValue)==null?void 0:i.value)||"").split("/"),a=`${n[1]}/ioBroker.${n[0]}`;this.props.installFromUrl(a,this.state.debug,!0)}else if(this.state.currentTab==="URL"){const n=this.state.customHistory.filter(a=>a!==this.state.url);n.unshift(this.state.url),n.length>rt&&n.pop(),(window._localstorage||window.localStorage).setItem("App.npmHistory",JSON.stringify(n)),this.state.url.includes(".")?this.props.installFromUrl(this.state.url,this.state.debug,!0):this.props.installFromUrl(`iobroker.${this.state.url}`,this.state.debug,!0)}else if(this.state.currentTab==="npm"){const n=(((r=this.state.autoCompleteValue)==null?void 0:r.value)||"").split("/")[0],a=n.includes(".")?n.split(".")[1]:n;try{await this.props.installFromUrl(`iobroker.${a}@latest`,this.state.debug,!0),this.props.upload(a)}catch(c){console.error(`Installation from url failed: ${c.message}`)}}this.props.onClose(),t()},color:"primary",startIcon:e.jsx(u.Check,{}),children:this.props.t("Install")}),e.jsx(o.Button,{id:"github-install-dialog-close",variant:"contained",onClick:()=>{this.props.onClose(),t()},color:"grey",startIcon:e.jsx(u.Close,{}),children:this.props.t("Close")})]})]})}}const B={formControl:{marginTop:24,width:100},closeButton:p=>({position:"absolute",right:8,top:8,color:p.palette.grey[500]}),languageButton:{position:"absolute",right:60,top:8},languageButtonActive:p=>({color:p.palette.primary.main}),paper:{},typography:{pr:"30px"},messageText:{},messageColor_warn:{color:"#cb7642"},messageColor_error:{color:"#f5614d"},messageColor_info:{color:"#5abd29"},messageTitle_warn:p=>({background:"#cb7642",borderRadius:"3px",pl:"10px",fontWeight:"bold",color:p.palette.mode==="dark"?"black":"white"}),messageTitle_error:p=>({background:"#f5614d",borderRadius:"3px",pl:"10px",fontWeight:"bold",color:p.palette.mode==="dark"?"black":"white"}),messageTitle_info:p=>({background:"#5abd29",borderRadius:"3px",pl:"10px",fontWeight:"bold",color:p.palette.mode==="dark"?"black":"white"}),deps:p=>({m:"10px",fontSize:16,color:p.palette.mode==="dark"?"#e70000":"#840101"})};class Nt extends L.Component{t;messages=null;lang;constructor(t){super(t),this.state={instanceNumbers:[]},this.t=t.t,this.lang=w.getLanguage(),this.messages=Q(t.adapterObject.messages,null,t.adapterObject.version,t.instances)}componentDidMount(){this.props.instancesWorker.getObjects().then(t=>{const s=Object.keys(t).filter(i=>{var r,n;return((n=(r=t[i])==null?void 0:r.common)==null?void 0:n.name)===this.props.adapter}).map(i=>i.substring(i.lastIndexOf(".")+1));this.setState({instanceNumbers:s})})}getAvailableInstances(){const t=[];t.push(e.jsx(o.MenuItem,{value:"auto",children:this.t("auto")},"auto"));for(let s=0;s<=100&&(this.state.instanceNumbers.includes(s.toString())||t.push(e.jsx(o.MenuItem,{value:s.toString(),children:s},s)),!(t.length>11));s++);return t}checkDependencies(t=this.props.dependencies){if(!t)return"";const s=[];for(const i of t)i.installedVersion?i.rightVersion||s.push(`${this.props.t("Invalid version of %s. Required %s. Current ",i.name,i.version)}${i.installedVersion}`):s.push(this.props.t("No version of %s",i.name,i.name));return s.length?s.map(i=>e.jsx("div",{children:i},i)):""}getText(t,s){return t&&typeof t=="object"?s?t.en:t[this.lang]||t.en:typeof t=="object"?"":t}renderOneMessage(t,s){return e.jsxs(o.Grid2,{children:[e.jsx(o.Typography,{sx:B[`messageTitle_${t.level||"warn"}`],children:this.getText(t.title,this.props.noTranslation)||""}),e.jsx(o.Typography,{component:"div",variant:"body2",style:B.messageText,children:this.getText(t.text,this.props.noTranslation)||""}),t.link?e.jsx(o.Button,{onClick:()=>{window.open(t.link,"_blank").focus()},startIcon:e.jsx(u.Public,{}),variant:"contained",color:"grey",children:this.getText(t.linkText,this.props.noTranslation)||this.props.t("More info")}):null]},s)}renderMessages(){return this.messages?e.jsx(o.Grid2,{container:!0,spacing:2,direction:"column",wrap:"nowrap",sx:{marginBottom:1},children:this.messages.map((t,s)=>this.renderOneMessage(t,s))}):null}render(){const t=this.checkDependencies();return e.jsxs(o.Dialog,{onClose:()=>{},open:!0,sx:{"& .MuiDialog-paper":B.paper},children:[e.jsx(o.DialogTitle,{children:e.jsxs(o.Typography,{component:"h2",variant:"h6",sx:{"&.MuiTypography-root":B.typography},children:[this.t("You are going to add new instance:")," ",this.props.adapter,e.jsx(o.IconButton,{size:"large",sx:B.closeButton,onClick:()=>this.props.onClose(!1),children:e.jsx(u.Close,{})}),this.messages&&this.lang!=="en"&&this.props.toggleTranslation?e.jsx(o.IconButton,{size:"large",style:R.getStyle(this.props.theme,B.languageButton,this.props.noTranslation&&B.languageButtonActive),onClick:this.props.toggleTranslation,title:w.t("Disable/Enable translation"),children:e.jsx(u.Language,{})}):null]})}),e.jsxs(o.DialogContent,{dividers:!0,children:[this.renderMessages(),!t&&this.props.expertMode?e.jsxs(o.Grid2,{container:!0,direction:"column",children:[e.jsx(wt,{tooltip:this.t("Select host to add the instance"),expertMode:!0,socket:this.props.socket,hostsWorker:this.props.hostsWorker,currentHost:this.props.currentHost,setCurrentHost:(s,i)=>this.props.onHostChange(i.replace(/^system\.host\./,""))}),e.jsxs(o.FormControl,{variant:"standard",style:B.formControl,children:[e.jsx(o.InputLabel,{id:"instance-label",children:this.t("Instance")}),e.jsx(o.Select,{variant:"standard",labelId:"instance-label",value:this.props.currentInstance,onChange:this.props.onInstanceChange,children:this.getAvailableInstances()})]})]}):null,e.jsx(o.Box,{component:"div",sx:B.deps,children:t})]}),e.jsxs(o.DialogActions,{children:[e.jsx(o.Button,{id:"instance-add-dialog-ok",variant:"contained",autoFocus:!0,disabled:!!t,onClick:()=>this.props.onClose(!0),color:"primary",startIcon:e.jsx(u.Add,{}),children:this.t("Add")}),e.jsx(o.Button,{id:"instance-add-dialog-cancel",variant:"contained",onClick:()=>this.props.onClose(!1),color:"grey",startIcon:e.jsx(u.Close,{}),children:this.t("Close")})]})]})}}function K(p){var s;if(!p)return"";let t=((s=p.licenseInformation)==null?void 0:s.link)||p.licenseUrl;if(!t||!t.includes("/LICENSE")||!t.includes("raw.githubusercontent.com")){if(t=p.extIcon,!t){if(t=p.readme,!t)return console.error(`No extIcon for ${p.name||JSON.stringify(p)}`),"";t=t.replace("github.com","raw.githubusercontent.com").replace("/blob/","/"),t.includes("/main")?t=`${t.split("/main")[0]}/main/LICENSE`:t.includes("/master")&&(t=`${t.split("/master")[0]}/master/LICENSE`)}if(t.includes("/main"))t=`${t.split("/main")[0]}/main/LICENSE`;else if(t.includes("/master"))t=`${t.split("/master")[0]}/master/LICENSE`;else return""}return t}class F extends L.Component{constructor(t){super(t),this.state={showDialog:!1,showLicenseDialog:null,addInstanceHostName:"",addInstanceId:"auto",addInstanceDialog:""}}renderLicenseDialog(t){return this.state.showLicenseDialog?e.jsx(bt,{licenseType:this.state.showLicenseDialog.licenseType,url:this.state.showLicenseDialog.url,onClose:s=>{const i=s?this.state.showLicenseDialog:null;this.setState({showLicenseDialog:null,showDialog:!1},()=>{i&&(i.upload?F.upload(i.adapterName,t):this.addInstance({adapterName:i.adapterName,context:t}).catch(r=>window.alert(`Cannot add instance: ${r}`)))})}}):null}async addInstance(t){if(!t.customUrl){const i=t.context.repository[t.adapterName],r=Q(i.messages,null,i.version,t.context.compactInstances);if(!t.instance&&(t.context.expertMode||r)){this.setState({addInstanceDialog:t.adapterName,showDialog:!0,addInstanceHostName:t.context.currentHost.replace(/^system\.host\./,""),addInstanceId:t.instance||"auto"});return}if(t.instance){const n=await t.context.instancesWorker.getObjects();if(n&&n[`system.adapter.${t.adapterName}.${t.instance}`]){window.alert(t.context.t("Instance %s already exists",`${t.adapterName}.${t.instance}`));return}}}const s=(this.state.addInstanceHostName||t.context.currentHost).replace(/^system\.host\./,"");try{await new Promise((i,r)=>{t.context.executeCommand(`${t.customUrl?"url":"add"} ${t.adapterName} ${t.instance?`${t.instance} `:""}--host ${s} ${t.debug||t.context.expertMode?"--debug":""}`,s,n=>n?r(new Error(`The process returned an exit code of ${n}`)):i())})}catch(i){window.alert(`${w.t("Cannot install")}: ${i}`)}}static getDependencies(t,s){var n,a;const i=s.repository[t],r=[];if(i){i.dependencies&&!Array.isArray(i.dependencies)&&(i.dependencies=[i.dependencies]),i.globalDependencies&&!Array.isArray(i.globalDependencies)&&(i.globalDependencies=[i.globalDependencies]);const c=i.node;if((n=i.dependencies)!=null&&n.length)for(const d of i.dependencies){const l={name:"",version:null,installed:!1,installedVersion:null,rightVersion:!1},g=typeof d!="string",x=Object.keys(d);if(l.name=g?x?x[0]:null:d,l.version=g?d[l.name]:null,l.name){const m=s.installed[l.name];l.installed=!!m,l.installedVersion=m?m.version:null;try{l.rightVersion=m?g?V.satisfies(m.version,l.version,{includePrerelease:!0}):!0:!1}catch{l.rightVersion=!0}}r.push(l)}if((a=i.globalDependencies)!=null&&a.length)for(const d of i.globalDependencies){const l={name:"",version:null,installed:!1,installedVersion:null,rightVersion:!1},g=typeof d!="string",x=Object.keys(d);if(l.name=g?x?x[0]:null:d,l.version=g?d[l.name]:null,l.name){const m=s.installedGlobal[l.name];l.installed=!!m,l.installedVersion=m?m.version:null;try{l.rightVersion=m?g?V.satisfies(m.version,l.version,{includePrerelease:!0}):!0:!1}catch{l.rightVersion=!0}}r.push(l)}const h=i.ifInstalledDependencies;if(h&&typeof h=="object"&&!Array.isArray(h)){const d=Object.keys(h);for(const l of d){const g={name:l,version:h[l],installed:!1,installedVersion:null,rightVersion:!1};if(g.name){const x=s.installedGlobal[g.name];g.installed=!!x,g.installedVersion=x?x.version:null;try{g.rightVersion=x?V.satisfies(x.version,g.version,{includePrerelease:!0}):!0}catch{g.rightVersion=!0}}r.push(g)}}if(c){const d={name:"node",version:c,installed:!0,installedVersion:s.nodeJsVersion,rightVersion:!1};try{d.rightVersion=V.satisfies(s.nodeJsVersion,c)}catch{d.rightVersion=!0}r.push(d)}}return r}renderAddInstanceDialog(t){return this.state.addInstanceDialog?e.jsx(Nt,{adapter:this.state.addInstanceDialog,socket:t.socket,hostsWorker:t.hostsWorker,instancesWorker:t.instancesWorker,dependencies:F.getDependencies(this.state.addInstanceDialog,t),currentHost:`system.host.${this.state.addInstanceHostName}`,currentInstance:this.state.addInstanceId,t:t.t,onClose:s=>{const i=s?this.state.addInstanceDialog:"",r=s?this.state.addInstanceId:"";this.setState({addInstanceDialog:"",addInstanceId:"auto",showDialog:!1},()=>{if(i)try{this.addInstance({adapterName:i,instance:r,context:t})}catch(n){window.alert(`Cannot add instance: ${n}`)}})},onHostChange:s=>this.setState({addInstanceHostName:s.replace(/^system\.host\./,"")}),onInstanceChange:s=>this.setState({addInstanceId:s.target.value.toString()}),adapterObject:t.repository[this.state.addInstanceDialog],instances:t.compactInstances,toggleTranslation:t.toggleTranslation,noTranslation:this.props.noTranslation,expertMode:t.expertMode,theme:t.theme}):null}static upload(t,s){s.executeCommand(`upload ${t}${s.expertMode?" --debug":""}`)}onAddInstance(t,s){var a;const i=s.repository[t],r=K(i),n=((a=i.licenseInformation)==null?void 0:a.license)||i.license;n==="MIT"?this.addInstance({adapterName:t,context:s}).catch(c=>window.alert(`Cannot add instance: ${c}`)):this.setState({showLicenseDialog:{url:r,adapterName:t,licenseType:n},showDialog:!0})}renderDialogs(t){return this.state.showDialog?e.jsxs(e.Fragment,{children:[this.renderAddInstanceDialog(t),this.renderLicenseDialog(t)]}):null}}const H={name:{flexWrap:"nowrap",width:300,marginTop:0},nameDiv:{display:"flex",alignItems:"center"},categoryName:{fontWeight:"bold",cursor:"pointer"},green:{color:pt[500]},blue:{color:mt[700]},category:{backgroundColor:"background.default"},marginRight5:{marginRight:5}};function Ut(p){const{installedCount:t,name:s,categoryName:i}=p;return e.jsxs(o.TableRow,{hover:!1,sx:H.category,children:[e.jsx(o.TableCell,{children:e.jsx(o.Grid2,{container:!0,spacing:1,alignItems:"center",style:H.name,children:e.jsx(o.Grid2,{component:"div",children:e.jsx(o.IconButton,{size:"small",onClick:p.onToggle,children:p.expanded?e.jsx(u.ExpandMore,{}):e.jsx(u.ChevronRight,{})})})})}),e.jsx(o.TableCell,{onClick:p.onToggle,children:e.jsxs("div",{style:{...H.nameDiv,...H.categoryName},children:[e.jsx(St,{iconName:i,style:H.marginRight5}),s]})}),e.jsxs(o.TableCell,{colSpan:p.descHidden?5:6,children:[e.jsx(o.Typography,{component:"span",variant:"body2",style:H.green,children:t}),` ${p.t("of")} `,e.jsx(o.Typography,{component:"span",variant:"body2",style:H.blue,children:p.count}),` ${p.t("Adapters from this Group installed")}`]})]})}const T={rating:{marginBottom:20},listRating:{marginRight:8},listTime:{opacity:.5,fontStyle:"italic"},list:{},listOwn:p=>({backgroundColor:p.name==="colored"||p.name==="light"?"#16516e2e":p.palette.secondary.dark}),listTitle:p=>({backgroundColor:p.palette.primary.dark,pt:"4px",pb:"4px",mb:"4px",color:"#ffffff",textAlign:"center"}),languageFilter:{width:300},ratingTextControl:{width:"calc(100% - 138px)",marginRight:8},ratingLanguageControl:{width:130},noComments:{width:"100%",textAlign:"center",marginTop:16},commentCount:{marginTop:2,marginLeft:8,opacity:.8,fontSize:10,float:"right"},infoText:{textAlign:"left",fontSize:"14px"},infoTextContainer:{display:"flex",paddingBottom:"10px",alignItems:"center",gap:"10px"}},nt=[{id:"en",title:"English"},{id:"de",title:"Deutsch"},{id:"ru",title:"русский"},{id:"pt",title:"Portugues"},{id:"nl",title:"Nederlands"},{id:"fr",title:"français"},{id:"it",title:"Italiano"},{id:"es",title:"Espanol"},{id:"pl",title:"Polski"},{id:"uk",title:"Українська"},{id:"zh-cn",title:"简体中文"}];class Bt extends L.Component{constructor(t){super(t),this.state={ratingNumber:0,ratingComment:"",votings:null,ratingLang:this.props.lang,filterLang:(window._localStorage||window.localStorage).getItem("app.commentLang")||this.props.lang,commentsByLanguage:{}}}componentDidMount(){fetch(`https://rating.iobroker.net/adapter/${this.props.adapter}?uuid=${this.props.uuid}`).then(t=>t.json()).then(t=>{t=t||{},t.rating=t.rating||{};const s=Object.keys(t.rating);s.sort((r,n)=>t.rating[r].ts>t.rating[n].ts?-1:t.rating[r].ts<t.rating[n].ts?1:0);const i={};if(t.comments&&(t.comments.sort((r,n)=>r.ts>n.ts?-1:r.ts<n.ts?1:0),t.comments.forEach(r=>{i[r.lang]=i[r.lang]||0,i[r.lang]++})),s.length){const r=t.rating[s[0]];this.setState({votings:t,ratingNumber:r?r.r:0,commentsByLanguage:i})}else this.setState({votings:t,commentsByLanguage:i})})}setAdapterRating(t,s,i,r,n){return fetch("https://rating.iobroker.net/vote",{method:"POST",headers:{"Content-Type":"application/json"},redirect:"follow",body:JSON.stringify({uuid:this.props.uuid,adapter:t,version:s,rating:i,comment:r,lang:n})}).then(a=>a.json()).then(a=>(window.alert(`${this.props.t("Vote:")} ${t}@${s}=${i}`),delete a.adapter,a)).catch(a=>(window.alert(`Cannot vote: ${a}`),null))}renderInfoText(){return e.jsxs("div",{style:T.infoTextContainer,children:[e.jsx(u.Info,{}),e.jsx(o.Typography,{style:T.infoText,children:this.props.t("use GitHub for issues")})]})}renderComments(){var t;if((t=this.state.votings)!=null&&t.comments&&this.state.votings.comments.length){const s=this.state.votings.comments.find(i=>!(this.state.filterLang&&this.state.filterLang!=="_"&&i.lang!==this.state.filterLang));return e.jsxs("div",{style:{width:"100%",textAlign:"left"},children:[e.jsx(o.Box,{component:"h3",sx:T.listTitle,children:this.props.t("Comments")}),e.jsxs(o.FormControl,{variant:"standard",style:T.languageFilter,children:[e.jsx(o.InputLabel,{children:this.props.t("Show comments in language")}),e.jsxs(o.Select,{variant:"standard",value:this.state.filterLang,onChange:i=>{(window._localStorage||window.localStorage).setItem("app.commentLang",i.target.value),this.setState({filterLang:i.target.value})},children:[e.jsxs(o.MenuItem,{value:"_",children:[this.props.t("All")," ",e.jsx("span",{style:T.commentCount,children:this.state.votings.comments.length})]}),nt.map(i=>e.jsxs(o.MenuItem,{value:i.id,children:[i.title," ",this.state.commentsByLanguage[i.id]?e.jsx("span",{style:T.commentCount,children:this.state.commentsByLanguage[i.id]}):null]},i.id))]})]}),e.jsxs(o.List,{style:T.list,dense:!0,disablePadding:!0,children:[s&&this.state.votings.comments.map((i,r)=>this.state.filterLang&&this.state.filterLang!=="_"&&i.lang!==this.state.filterLang?null:i?e.jsxs(o.ListItem,{title:i.uuid?this.props.t("Your comment"):"",sx:{"&.MuiListItem-root":i.uuid?T.listOwn:void 0},dense:!0,children:[e.jsx(o.ListItemAvatar,{style:T.listRating,children:e.jsx(o.Rating,{readOnly:!0,defaultValue:i.rating,size:"small"})}),e.jsx(o.ListItemText,{primary:i.comment,secondary:`${new Date(i.ts).toLocaleString()} / v${i.version}`,sx:{"& .MuiListItemText-secondary":T.listTime}})]},r):null),!s&&e.jsx("div",{style:T.noComments,children:this.props.t("No comments in selected language")})]})]})}return null}render(){var i,r,n;let t,s;if(this.state.votings){const a=this.state.votings.rating;s=Object.keys(a),s.sort((c,h)=>a[c].ts>a[h].ts?-1:a[c].ts<a[h].ts?1:0),s.length&&(t=a[s[0]])}return e.jsxs(o.Dialog,{open:!0,onClose:()=>this.props.onClose(),children:[e.jsx(o.DialogTitle,{children:`${this.props.t("Review")} ${this.props.adapter}${this.props.version?`@${this.props.version}`:""}`}),e.jsxs(o.DialogContent,{style:{textAlign:"center"},title:((i=this.props.currentRating)==null?void 0:i.title)||"",children:[this.renderInfoText(),e.jsx(o.Rating,{style:T.rating,name:this.props.adapter,value:this.props.version?this.state.ratingNumber:(n=(r=this.props.currentRating)==null?void 0:r.rating)==null?void 0:n.r,size:"large",readOnly:!this.props.version,onChange:(a,c)=>this.setState({ratingNumber:c})}),this.props.version?e.jsxs("div",{style:{width:"100%",textAlign:"left"},children:[e.jsx(o.TextField,{variant:"standard",style:T.ratingTextControl,value:this.state.ratingComment,label:this.props.t("Comment to version"),helperText:this.props.t("Max length %s characters",200),onChange:a=>this.setState({ratingComment:a.target.value}),slotProps:{input:{endAdornment:this.state.ratingComment?e.jsx(o.InputAdornment,{position:"end",children:e.jsx(o.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({ratingComment:""}),children:e.jsx(u.Close,{})})}):null},htmlInput:{maxLength:200}}}),e.jsxs(o.FormControl,{variant:"standard",style:T.ratingLanguageControl,children:[e.jsx(o.InputLabel,{children:this.props.t("Language")}),e.jsx(o.Select,{variant:"standard",value:this.state.ratingLang,onChange:a=>this.setState({ratingLang:a.target.value}),children:nt.map(a=>e.jsx(o.MenuItem,{value:a.id,children:a.title},a.id))})]})]}):null,this.props.version?e.jsx("div",{style:{paddingTop:20,paddingBottom:16},children:this.props.t("Rate how good this version of the adapter works on your system. You can vote for every new version.")}):null,s&&t?e.jsx("div",{children:this.props.t("You voted for %s on %s",s[0],new Date(t.ts).toLocaleDateString())}):null,this.renderComments()]}),e.jsxs(o.DialogActions,{children:[this.props.version&&e.jsx(o.Button,{variant:"contained",autoFocus:!0,color:"primary",disabled:!this.state.ratingNumber||this.state.votings===null,onClick:()=>{this.state.ratingNumber!==(t==null?void 0:t.r)||this.state.ratingComment?this.setAdapterRating(this.props.adapter,this.props.version,this.state.ratingNumber,this.state.ratingComment,this.state.ratingLang).then(a=>this.props.onClose(a)):this.props.onClose()},startIcon:e.jsx(u.HowToVote,{}),children:this.props.t("Rate")}),e.jsx(o.Button,{autoFocus:!this.props.version,variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:e.jsx(u.Close,{}),children:this.props.t("Close")})]})]})}}const at={closeButton:p=>({position:"absolute",right:8,top:8,color:p.palette.grey[500]}),typography:{paddingRight:30}};class $t extends L.Component{t;constructor(t){super(t),this.state={deleteCustom:!1,deleteCustomSupported:!1},this.t=t.t}componentDidMount(){this.props.socket.checkFeatureSupported("DEL_INSTANCE_CUSTOM").then(t=>{if(t)return this.props.socket.getObject(`system.adapter.${this.props.adapter}`).then(s=>{s!=null&&s.common?s.common.supportCustoms&&this.setState({deleteCustomSupported:s.common.supportCustoms}):this.setState({deleteCustomSupported:!0})})})}render(){return e.jsxs(o.Dialog,{onClose:this.props.onClose,open:!0,children:[e.jsx(o.DialogTitle,{children:e.jsxs(o.Typography,{component:"h2",variant:"h6",sx:{"&.MuiTypography-root":at.typography},children:[this.t("Please confirm"),e.jsx(o.IconButton,{size:"large",sx:at.closeButton,onClick:this.props.onClose,children:e.jsx(u.Close,{})})]})}),e.jsxs(o.DialogContent,{dividers:!0,children:[e.jsx(o.Typography,{gutterBottom:!0,children:this.t("Are you sure you want to delete adapter %s?",this.props.adapter)}),this.state.deleteCustomSupported&&e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:this.state.deleteCustom,onChange:t=>this.setState({deleteCustom:t.target.checked})}),label:this.t("Delete all custom object settings of this adapter too")})]}),e.jsxs(o.DialogActions,{children:[e.jsx(o.Button,{id:"adapter-delete-dialog-ok",variant:"contained",autoFocus:!0,onClick:()=>{this.props.onClick(this.state.deleteCustom),this.props.onClose()},color:"primary",startIcon:e.jsx(u.Check,{}),children:this.t("Ok")}),e.jsx(o.Button,{id:"adapter-delete-dialog-cancel",variant:"contained",autoFocus:!0,onClick:()=>this.props.onClose(),color:"grey",startIcon:e.jsx(u.Close,{}),children:this.t("Close")})]})]})}}const ut={none:e.jsx(u.HorizontalRule,{}),patch:e.jsx(u.KeyboardDoubleArrowUp,{style:{color:"green"}}),minor:e.jsx(u.North,{style:{color:"orange"}}),major:e.jsx(u.VerticalAlignTop,{style:{color:"red"}})};class Wt extends q.Component{constructor(t){super(t),this.state={currentSavedPolicy:"none",policy:"none",repositories:[],supported:!0}}async componentDidMount(){await this.getConfiguredRepositories(),await this.getCurrentAutoUpgradeSetting()}async getConfiguredRepositories(){var i;const t=await this.props.socket.getObject("system.config");if(!((i=t==null?void 0:t.common)!=null&&i.adapterAutoUpgrade))return;const s=Object.entries(t.common.adapterAutoUpgrade.repositories).filter(([,r])=>r).map(([r])=>r);this.setState({repositories:s})}getAdapterId(){return`${this.props.hostId}.adapter.${this.props.adapter}`}async getCurrentAutoUpgradeSetting(){const t=await this.props.socket.getObject(this.getAdapterId());if(!t){console.error("no adapter object existing"),this.setState({supported:!1});return}this.setState({policy:t.common.automaticUpgrade||"none",currentSavedPolicy:t.common.automaticUpgrade||"none"})}async save(){const t=await this.props.socket.getObject(this.getAdapterId());if(!t){console.error("no adapter object existing"),this.setState({supported:!1});return}t.common.automaticUpgrade=this.state.policy,await this.props.socket.setObject(this.getAdapterId(),t),this.setState({currentSavedPolicy:this.state.policy},()=>this.props.onClose())}render(){return e.jsxs(o.Dialog,{open:!0,maxWidth:"md",fullWidth:!0,children:[e.jsx(o.DialogTitle,{children:w.t("Auto upgrade policy for %s",this.props.adapter)}),e.jsxs(o.DialogContent,{style:{padding:"0 20px",overflow:"hidden"},children:[e.jsx(N,{value:!this.state.supported,children:e.jsx(o.Typography,{children:w.t("This feature is supported up from js-controller Kiera (Version 6)!")})}),e.jsxs(N,{value:this.state.supported,children:[e.jsx(o.Typography,{children:w.t("Allow only the following upgrades to be performed automatically:")}),e.jsx(o.Select,{variant:"standard",style:{marginTop:20,minWidth:150,marginBottom:8},value:this.state.policy,onChange:t=>this.setState({policy:t.target.value}),children:jt.map(t=>e.jsx(o.MenuItem,{value:t,children:e.jsxs("div",{style:{display:"flex",gap:8},children:[ut[t],Ct[t]]})},t))}),e.jsx(N,{value:this.state.repositories.includes("beta")&&this.state.policy!=="none",children:e.jsx(Z,{type:"warning",children:w.t("repo_update_hint")})}),e.jsx(N,{value:this.state.policy==="major",children:e.jsx(Z,{type:"warning",children:w.t("The current selected configuration will allow to automatically pull in incompatible changes of this adapter!")})})]})]}),e.jsxs(o.DialogActions,{children:[e.jsx(o.Button,{disabled:this.state.currentSavedPolicy===this.state.policy,color:"primary",variant:"contained",startIcon:e.jsx(u.Save,{}),onClick:()=>this.save(),children:w.t("Save")}),e.jsx(o.Button,{variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:e.jsx(u.Close,{}),children:w.t("Close")})]})]})}}const gt={hidden:{display:"none"},buttonUpdate:{border:"1px solid",padding:"0px 7px",borderRadius:5,display:"flex",alignItems:"center",cursor:"pointer",transition:"background 0.5s","&:hover":{background:"#00800026"}},buttonUpdateIcon:{height:20,width:20,marginRight:10},classPoll:{color:"orange"},classPush:{color:"green"},classAssumption:{color:"red",transform:"rotate(90deg)"},marginLeft5:{marginLeft:5},ratingSet:{cursor:"pointer"},sentry:{width:21,height:21,objectFit:"fill",marginTop:3,filter:"invert(0%) sepia(90%) saturate(1267%) hue-rotate(-260deg) brightness(99%) contrast(97%)"},tooltip:{pointerEvents:"none"},wrongDependencies:{color:xt[700]},updateAvailable:{color:pt[700]},currentVersion:p=>({cursor:"pointer",mb:"6px",mr:"8px",mt:"4px","&:hover":{background:p.palette.primary.dark}}),header:p=>({fontWeight:"bold",background:p.palette.secondary.main,p:"10px"}),modalDialog:{height:"calc(100% - 64px)",overflowY:"hidden"},currentVersionText:p=>({color:p.palette.mode==="dark"?"#a3ffa3":"#009800",fontWeight:"bold",marginLeft:"4px"}),repoStableVersionText:p=>({color:p.palette.mode==="dark"?"#8dff7a":"#2b9800",fontWeight:"bold",marginLeft:"4px"}),repoLatestVersionText:p=>({color:p.palette.mode==="dark"?"#a3fcff":"#005498",fontWeight:"bold",marginLeft:"4px"}),rating:{},containerVersion:{},containerSpecificVersion:{},versionWarn:{color:ht[500]},cardContentFlexBetween:{},cardContentFlex:{}};class G extends F{installedVersion="";constructor(t){super(t),Object.assign(this.state,{autoUpgradeDialogOpen:!1,showUpdateDialog:!1,adapterDeletionDialog:!1,adapterInstallSpecificVersion:"",showInstallVersion:!1,showSetRating:null})}static renderImage(t){const{style:s,alt:i,...r}=t,n=s.backgroundImage.substring(5,s.backgroundImage.length-2);return e.jsx("img",{...r,alt:i,src:n,onError:a=>{a.target&&(a.target.onerror=null,a.target.src="img/no-image.svg")}})}renderAddInstanceButton(){const t=this.props.context.repository[this.props.adapterName]?this.props.context.repository[this.props.adapterName].allowAdapterInstall:!0;return e.jsx(N,{value:t,children:e.jsx(o.Tooltip,{title:this.props.context.t("Add instance"),slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx(o.IconButton,{size:"small",disabled:this.props.commandRunning,style:this.props.cached.rightOs?void 0:this.styles.hidden,onClick:this.props.cached.rightOs?()=>this.onAddInstance(this.props.adapterName,this.props.context):void 0,children:e.jsx(u.Add,{})})})})}renderAutoUpgradeButton(){var i;const t=this.props.context.hostAdapterWorker.getObject(this.props.adapterName);if(!t)return e.jsx("div",{style:{width:34,height:34,display:"inline-block"}});const s=(i=t.common)==null?void 0:i.automaticUpgrade;return e.jsx(o.Tooltip,{title:this.props.context.t("Automatic Upgrade Policy")+(s?`: ${s}`:""),slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx(o.IconButton,{size:"small",onClick:()=>this.setState({autoUpgradeDialogOpen:!0,showDialog:!0}),children:!s||s==="none"?e.jsx(u.KeyboardArrowUp,{}):ut[s]})})}renderReadmeButton(){const t=this.props.context.repository[this.props.adapterName]?this.props.context.repository[this.props.adapterName].allowAdapterReadme:!0;return e.jsx(N,{value:t,children:e.jsx(o.Tooltip,{title:this.props.context.t("Readme"),slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx(o.IconButton,{size:"small",onClick:()=>this.openInfoDialog(),children:e.jsx(u.Help,{})})})})}renderRating(){var i,r,n;const t=this.props.context.repository[this.props.adapterName]?this.props.context.repository[this.props.adapterName].allowAdapterRating:!0;return this.props.context.isTileView&&(this.props.context.sortPopularFirst||this.props.context.sortRecentlyUpdated)||!this.props.context.repository[this.props.adapterName].stat||t===!1?null:e.jsx("div",{onClick:()=>this.setState({showSetRating:{version:this.installedVersion,rating:this.props.context.repository[this.props.adapterName].rating},showDialog:!0}),style:{...this.styles.rating,...this.styles.ratingSet},title:(i=this.props.context.repository[this.props.adapterName].rating)==null?void 0:i.title,children:e.jsx(o.Rating,{name:this.props.adapterName,precision:.5,size:"small",readOnly:!0,value:((n=(r=this.props.context.repository[this.props.adapterName].rating)==null?void 0:r.rating)==null?void 0:n.r)||0})})}renderConnectionType(){var s;const t=(s=this.props.context.repository[this.props.adapterName])==null?void 0:s.connectionType;return t==="cloud"?e.jsx(o.Tooltip,{title:this.props.context.t("Adapter requires the specific cloud access for these devices/service"),slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx(u.Cloud,{})}):t==="local"?e.jsx(o.Tooltip,{title:this.props.context.t("Adapter does not use the cloud for these devices/service"),slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx(u.CloudOff,{})}):null}renderDataSource(){var s;const t=(s=this.props.context.repository[this.props.adapterName])==null?void 0:s.dataSource;return t?e.jsx("div",{style:this.styles.marginLeft5,children:t==="poll"?e.jsx(o.Tooltip,{title:this.props.context.t("The device or service will be periodically asked"),slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx(u.ArrowUpward,{style:this.styles.classPoll})}):t==="push"?e.jsx(o.Tooltip,{title:this.props.context.t("The device or service delivers the new state actively"),slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx(u.ArrowDownward,{style:this.styles.classPush})}):t==="assumption"?e.jsx(o.Tooltip,{slotProps:{popper:{sx:this.styles.tooltip}},title:this.props.context.t("Adapter cannot request the exactly device status and the status will be guessed on the last sent command"),children:e.jsx(u.Remove,{style:this.styles.classAssumption})}):null}):null}renderLicenseInfo(){var i,r,n,a;const t=this.props.context.repository[this.props.adapterName],s=K(t);return(i=t.licenseInformation)!=null&&i.type?e.jsx(o.Link,{href:s,target:"_blank",rel:"noopener",sx:c=>({color:c.palette.mode==="dark"?"white":"black","&:hover":{color:c.palette.mode==="dark"?"white":"black"}}),children:((r=t.licenseInformation)==null?void 0:r.type)==="paid"?e.jsx(o.Tooltip,{title:this.props.context.t("The adapter requires a paid license."),slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx(u.MonetizationOn,{})}):((n=t.licenseInformation)==null?void 0:n.type)==="commercial"?e.jsx(o.Tooltip,{slotProps:{popper:{sx:this.styles.tooltip}},title:this.props.context.t("The adapter requires a paid license for commercial use."),children:e.jsx(u.MonetizationOn,{opacity:.5})}):((a=t.licenseInformation)==null?void 0:a.type)==="limited"?e.jsx(o.Tooltip,{slotProps:{popper:{sx:this.styles.tooltip}},title:this.props.context.t("The adapter has a limited functionality without a paid license."),children:e.jsx(u.MonetizationOn,{opacity:.5})}):null}):null}renderSentryInfo(){var s,i;return((i=(s=this.props.context.repository[this.props.adapterName])==null?void 0:s.plugins)==null?void 0:i.sentry)?e.jsx("div",{style:this.styles.marginLeft5,children:e.jsx(o.Tooltip,{title:"sentry",slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx(o.CardMedia,{style:this.styles.sentry,component:"img",image:It})})}):null}getDependencies(){const t=F.getDependencies(this.props.adapterName,this.props.context);if(!t)return null;const s=[];for(const i of t)i.installedVersion?i.rightVersion||s.push(`${this.props.context.t("Invalid version of %s. Required %s. Current ",i.name,i.version)}${i.installedVersion}`):s.push(this.props.context.t("No version of %s",i.name,i.name));return s.push(this.props.context.t("Wrong dependencies")),s.map((i,r)=>e.jsx("div",{style:r?void 0:{fontWeight:"bold",fontSize:"larger"},children:i},i))}renderVersion(){const t=this.props.context.repository[this.props.adapterName]?this.props.context.repository[this.props.adapterName].allowAdapterUpdate:!0;return!this.props.commandRunning&&this.props.cached.updateAvailable&&t!==!1?e.jsx(o.Tooltip,{title:this.props.context.t("Update"),slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsxs("div",{onClick:()=>this.setState({showUpdateDialog:!0,showDialog:!0}),style:{...this.styles.buttonUpdate,...this.props.cached.rightDependencies?this.styles.updateAvailable:void 0},children:[e.jsx(o.IconButton,{style:this.styles.buttonUpdateIcon,size:"small",children:e.jsx(u.Refresh,{})}),this.props.context.repository[this.props.adapterName].version]})}):e.jsx(o.Tooltip,{title:this.getDependencies(),slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx("span",{style:this.props.cached.rightDependencies?void 0:this.styles.wrongDependencies,children:this.props.context.repository[this.props.adapterName].version})})}renderInstalledVersion(t){var n,a;const s=this.props.context.installed[this.props.adapterName],i=(a=(n=this.props.context.adapters[`system.adapter.${this.props.adapterName}`])==null?void 0:n.common)==null?void 0:a.installedFrom,{adapterName:r}=this.props;if(t){const c=s==null?void 0:s.enabled,h=s==null?void 0:s.count;return e.jsxs(o.Grid2,{container:!0,wrap:"nowrap",alignItems:"center",spacing:1,children:[this.installedVersion?e.jsx(o.Grid2,{children:this.installedVersion+(h?` (${h}${h!==c?"~":""})`:"")}):null,i&&!i.startsWith(`iobroker.${r}@`)&&e.jsx(o.Grid2,{container:!0,children:e.jsx(o.Tooltip,{title:`${this.props.context.t("Non-NPM-Version")}: ${i}`,slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx(u.GitHub,{fontSize:"small",style:this.styles.versionWarn})})})]})}return this.installedVersion?e.jsxs(o.Typography,{component:"span",style:this.styles.cardContentFlexBetween,children:[e.jsxs("div",{children:[this.props.context.t("Installed version"),":"]}),e.jsxs("div",{style:this.styles.cardContentFlex,children:[i&&!i.startsWith(`iobroker.${r}@`)&&e.jsx(o.Tooltip,{title:`${this.props.context.t("Non-NPM-Version")}: ${i}`,slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx(u.GitHub,{fontSize:"small",style:this.styles.versionWarn})}),this.installedVersion]})]}):null}renderUploadButton(){return this.props.context.expertMode&&this.installedVersion?e.jsx(o.Tooltip,{title:this.props.context.t("Upload"),slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx(o.IconButton,{size:"small",disabled:this.props.commandRunning,onClick:()=>this.onUpload(),children:e.jsx(u.Publish,{})})}):null}renderDeleteButton(){const t=this.props.context.repository[this.props.adapterName]?this.props.context.repository[this.props.adapterName].allowAdapterDelete:!0;return e.jsx(N,{value:!!this.installedVersion&&t,children:e.jsx(o.Tooltip,{title:this.props.context.t("Delete adapter"),slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx(o.IconButton,{size:"small",disabled:this.props.commandRunning,onClick:()=>this.setState({adapterDeletionDialog:!0,showDialog:!0}),children:e.jsx(u.DeleteForever,{})})})})}renderInstallSpecificVersionButton(){const t=this.props.context.repository[this.props.adapterName]?this.props.context.repository[this.props.adapterName].allowAdapterUpdate:!0;return this.props.context.expertMode&&t!==!1&&this.installedVersion&&e.jsx(o.Tooltip,{title:this.props.context.t("Install a specific version"),slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx(o.IconButton,{disabled:this.props.commandRunning,size:"small",onClick:()=>this.setState({showInstallVersion:!0,showDialog:!0}),children:e.jsx(u.AddToPhotos,{})})})}renderRebuildButton(){return!this.props.context.expertMode||!this.installedVersion?null:e.jsx(o.Tooltip,{title:this.props.context.t("Rebuild"),children:e.jsx(o.IconButton,{size:"small",disabled:this.props.commandRunning,onClick:()=>this.rebuild(),children:e.jsx(u.Build,{})})})}renderAutoUpdateDialog(){return this.state.autoUpgradeDialogOpen?e.jsx(Wt,{onClose:()=>this.setState({autoUpgradeDialogOpen:!1,showDialog:!1}),adapter:this.props.adapterName,hostId:this.props.context.adminHost,socket:this.props.context.socket}):null}renderUpdateAdapterDialog(){var t;return this.state.showUpdateDialog?(this.installedVersion=(t=this.props.context.installed[this.props.adapterName])==null?void 0:t.version,e.jsx(kt,{adapter:this.props.adapterName,adapterObject:this.props.context.repository[this.props.adapterName],t:this.props.context.t,dependencies:F.getDependencies(this.props.adapterName,this.props.context),rightDependencies:this.props.context.rightDependenciesFunc(this.props.adapterName),news:this.getNews(),toggleTranslation:this.props.context.toggleTranslation,noTranslation:this.props.noTranslation,installedVersion:this.installedVersion,onUpdate:s=>this.setState({showUpdateDialog:!1,showDialog:!1},()=>this.update(s)),isStable:this.props.context.repository._repoInfo.stable,onIgnore:s=>this.setState({showUpdateDialog:!1,showDialog:!1},()=>this.props.context.socket.getObject(`system.adapter.${this.props.adapterName}`).then(i=>{i!=null&&i.common?(i.common.ignoreVersion=s,this.props.context.socket.setObject(i._id,i).catch(r=>window.alert(`Cannot write object: ${r}`))):window.alert(`Adapter "${this.props.adapterName}" does not exist!`)}).then(()=>this.props.context.removeUpdateAvailable(this.props.adapterName))),onClose:()=>this.setState({showUpdateDialog:!1,showDialog:!1}),instances:this.props.context.compactInstances,theme:this.props.context.theme})):null}static formatNews(t){return(t||"").toString().split(`
|
|
4
|
-
`).map(i=>i.trim().replace(/^\*+/,"").replace(/^-/,"").replace(/\*+$/,"").replace(/\r/g,"").trim()).filter(i=>i).map((i,r)=>e.jsxs("div",{style:{},children:[e.jsx("span",{children:"- "}),i]},r))}renderAdapterInstallVersion(){var r,n,a,c;if(!this.state.showInstallVersion)return null;let t,s;const i=this.props.context.repository._repoInfo;return i!=null&&i.stable?(t=(r=this.props.context.repository[this.props.adapterName])==null?void 0:r.version,s=(n=this.props.context.repository[this.props.adapterName])==null?void 0:n.latestVersion):(t=(a=this.props.context.repository[this.props.adapterName])==null?void 0:a.stable,s=(c=this.props.context.repository[this.props.adapterName])==null?void 0:c.version),e.jsx(Vt,{title:this.props.context.t("Please select specific version of %s",this.props.adapterName),applyButton:!1,onClose:()=>this.setState({showInstallVersion:!1,adapterInstallSpecificVersion:"",showDialog:!1}),theme:this.props.context.theme,toggleTranslation:this.props.context.toggleTranslation,noTranslation:this.props.noTranslation,children:e.jsxs("div",{style:{height:"100%",overflowY:"hidden"},children:[e.jsxs("div",{style:this.styles.containerSpecificVersion,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(o.TextField,{variant:"standard",style:{flexGrow:1},label:this.props.context.t("Enter version manually"),value:this.state.adapterInstallSpecificVersion,onChange:h=>this.setState({adapterInstallSpecificVersion:h.target.value}),slotProps:{input:{endAdornment:this.state.adapterInstallSpecificVersion?e.jsx(o.InputAdornment,{position:"end",children:e.jsx(o.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({adapterInstallSpecificVersion:""}),children:e.jsx(u.Close,{})})}):null}}}),e.jsx(o.Button,{color:"primary",variant:"contained",size:"small",disabled:!this.state.adapterInstallSpecificVersion,onClick:()=>{this.state.adapterInstallSpecificVersion&&(this.update(this.state.adapterInstallSpecificVersion),this.setState({showInstallVersion:!1,adapterInstallSpecificVersion:"",showDialog:!1}))},children:this.props.context.t("Install")})]}),e.jsx(o.Tooltip,{title:this.props.context.t("npmjs.com"),slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx(o.IconButton,{size:"small",onClick:()=>{window.open(`https://www.npmjs.com/package/iobroker.${this.props.adapterName}?activeTab=versions`,this.props.adapterName).focus()},children:e.jsx(u.Link,{})})})]}),e.jsx(o.Box,{component:"div",sx:this.styles.header,children:this.props.context.t("Or select from the list")}),e.jsx("div",{style:{...this.styles.containerVersion,height:"calc(100% - 122px)",overflowY:"auto"},children:this.getNews(!0).map(({version:h,news:d})=>e.jsx(o.Card,{variant:"outlined",sx:this.styles.currentVersion,onClick:()=>{this.update(h),this.setState({showInstallVersion:!1,showDialog:!1})},children:e.jsxs(o.CardContent,{children:[e.jsxs(o.Typography,{sx:R.getStyle(this.props.context.theme,this.installedVersion===h&&this.styles.currentVersionText,{fontSize:16,fontWeight:"bold"}),color:"text.secondary",gutterBottom:!0,children:[h,this.installedVersion===h?e.jsx(o.Box,{component:"span",sx:this.styles.currentVersionText,children:`(${this.props.context.t("current")})`}):null,s===h?e.jsx(o.Box,{component:"span",sx:this.styles.repoLatestVersionText,children:"(latest)"}):null,t===h?e.jsx(o.Box,{component:"span",sx:this.styles.repoStableVersionText,children:`(${this.props.context.t("stable")})`}):null]}),e.jsx(o.Typography,{variant:"body2",style:{opacity:.7},children:G.formatNews(d)})]})},h))})]})})}renderSetRatingDialog(){return this.state.showSetRating?e.jsx(Bt,{t:this.props.context.t,lang:this.props.context.lang,version:this.state.showSetRating.version,adapter:this.props.adapterName,currentRating:this.state.showSetRating.rating,onClose:t=>{t&&this.props.context.updateRating(this.props.adapterName,t),this.setState({showSetRating:null,showDialog:!1})},uuid:this.props.context.uuid}):null}renderAdapterDeletionDialog(){return this.state.adapterDeletionDialog?e.jsx($t,{adapter:this.props.adapterName,socket:this.props.context.socket,t:this.props.context.t,onClick:t=>this.delete(t),onClose:()=>this.setState({adapterDeletionDialog:!1,showDialog:!1})}):null}openInfoDialog(){var i;const s=(i=this.props.context.repository[this.props.adapterName].docs)!=null&&i[this.props.context.lang]?this.props.context.lang:"en";window.open(dt.getDocsLinkForAdapter({lang:s,adapterName:this.props.adapterName}),"help")}getNews(t=!1){const s=this.props.context.repository[this.props.adapterName],i=this.props.context.installed[this.props.adapterName],r=[];return i&&(s!=null&&s.news)&&Object.keys(s.news).forEach(n=>{try{if(V.gt(n,i.version)||t){let a;typeof s.news[n]=="object"?a=this.props.noTranslation?s.news[n].en:s.news[n][this.props.context.lang]||s.news[n].en:a=s.news[n],r.push({version:n,news:a})}}catch{console.warn(`[ADAPTERS] Cannot compare "${n}" and "${i.version}" (${this.props.adapterName})`)}}),r}onUpload(){var r;const t=this.props.context.repository[this.props.adapterName],s=K(t),i=((r=t.licenseInformation)==null?void 0:r.license)||t.license;i!=="MIT"?this.setState({showLicenseDialog:{url:s,upload:!0,adapterName:this.props.adapterName,licenseType:i},showDialog:!0}):F.upload(this.props.adapterName,this.props.context)}delete(t){this.props.context.executeCommand(`del ${this.props.adapterName}${t?" --custom":""}${this.props.context.expertMode?" --debug":""}`)}async update(t){if(this.props.adapterName==="admin"&&this.props.context.adminHost===this.props.context.currentHost&&await this.props.context.socket.checkFeatureSupported("ADAPTER_WEBSERVER_UPGRADE")){this.props.context.setAdminUpgradeTo(t);return}this.props.context.executeCommand(`upgrade ${this.props.adapterName}@${t}${this.props.context.expertMode?" --debug":""}`)}rebuild(){this.props.context.executeCommand(`rebuild ${this.props.adapterName}${this.props.context.expertMode?" --debug":""}`)}renderDialogs(){return this.state.showDialog?e.jsxs(e.Fragment,{children:[this.renderAddInstanceDialog(this.props.context),this.renderLicenseDialog(this.props.context),this.renderUpdateAdapterDialog(),this.renderAdapterInstallVersion(),this.renderSetRatingDialog(),this.renderAdapterDeletionDialog(),this.renderAutoUpdateDialog()]}):null}}const Pt="0 2px 2px 0 rgba(0, 0, 0, .14),0 3px 1px -2px rgba(0, 0, 0, .12),0 1px 5px 0 rgba(0, 0, 0, .2)",Ft="0 8px 17px 0 rgba(0, 0, 0, .2),0 6px 20px 0 rgba(0, 0, 0, .19)",Mt={...gt,type:{color:"tile"},root:p=>({position:"relative",m:"10px",width:300,minHeight:200,background:p.palette.background.default,boxShadow:Pt,display:"flex",flexDirection:"column",transition:"box-shadow 0.5s","&:hover":{boxShadow:Ft}}),imageBlock:p=>({background:p.palette.mode==="dark"?"#848484":"#c0c0c0",minHeight:60,display:"flex",padding:"0 10px 0 10px",position:"relative",justifyContent:"space-between",color:"#000"}),img:{width:45,height:45,margin:"auto 0",position:"relative","&:after":{content:'""',position:"absolute",zIndex:2,top:0,left:0,width:"100%",height:"100%",background:'url("img/no-image.svg") 100% 100% no-repeat',backgroundSize:"cover",backgroundColor:"#fff"}},installed:{background:"#77c7ff8c"},update:{background:"#10ff006b"},fab:{position:"absolute",bottom:-20,width:40,height:40,right:20},greenText:p=>({color:p.palette.success.dark}),collapse:{height:"100%",backgroundColor:"silver",position:"absolute",width:"100%",zIndex:3,marginTop:"auto",bottom:0,justifyContent:"space-between",display:"flex",flexDirection:"column"},close:{width:20,height:20,opacity:.9,cursor:"pointer",position:"relative",marginLeft:"auto",mb:"10px",transition:"all 0.6s ease","&:hover":{transform:"rotate(90deg)"},"&:before":{position:"absolute",left:9,content:'""',height:20,width:3,backgroundColor:"rgba(0, 0, 0, 0.54)",transform:"rotate(45deg)"},"&:after":{position:"absolute",left:9,content:'""',height:20,width:3,backgroundColor:"rgba(0, 0, 0, 0.54)",transform:"rotate(-45deg)"}},footerBlock:p=>({background:p.palette.background.default,p:"10px",display:"flex",justifyContent:"space-between"}),versionDate:{alignSelf:"center"},adapter:p=>({width:"100%",fontWeight:"bold",fontSize:16,verticalAlign:"middle",pl:1,pt:2,color:(p.palette.mode==="dark","#333")}),adapterWithAgo:{width:"calc(100% - 145px)"},description:p=>({color:p.palette.mode==="dark"?"#222":"inherit"}),cardContent:{overflow:"auto"},cardContentDiv:{position:"sticky",right:0,top:0,background:"silver"},cardContentFlex:{display:"flex"},cardContentFlexBetween:{display:"flex",justifyContent:"space-between"},cardContent2:{height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between"},cardMargin10:{marginTop:10},availableVersion:{display:"flex",justifyContent:"space-between"},curdContentFlexCenter:{display:"flex",alignItems:"center"},versionWarn:{color:ht[500],marginRight:5},rating:{marginTop:20}};class _t extends G{styles=Mt;constructor(t){super(t),Object.assign(this.state,{openCollapse:!1})}renderInfoCard(){return e.jsxs("div",{style:this.styles.collapse,children:[e.jsxs(o.CardContent,{style:this.styles.cardContent,children:[e.jsx("div",{style:this.styles.cardContentDiv,children:e.jsx(o.Box,{component:"div",sx:this.styles.close,onClick:()=>this.setState({openCollapse:!this.state.openCollapse})})}),e.jsx(o.Typography,{gutterBottom:!0,component:"span",variant:"body2",sx:this.styles.description,children:this.props.cached.desc})]}),e.jsxs(o.Box,{component:"div",sx:this.styles.footerBlock,children:[this.renderAddInstanceButton(),e.jsxs("div",{style:this.styles.cardContentFlex,children:[this.renderAutoUpgradeButton(),this.renderReadmeButton(),this.renderUploadButton(),this.renderDeleteButton(),this.renderInstallSpecificVersionButton()]})]})]})}renderCardMedia(){const t=this.props.context.repository[this.props.adapterName],s=t==null?void 0:t.version;return e.jsxs(o.Box,{component:"div",sx:R.getStyle(this.props.context.theme,this.styles.imageBlock,this.installedVersion&&this.styles.installed,this.installedVersion&&s&&this.installedVersion!==s&&this.props.cached.updateAvailable&&this.styles.update),children:[e.jsx(o.CardMedia,{sx:this.styles.img,component:i=>G.renderImage(i),src:this.props.cached.image||"img/no-image.svg",image:this.props.cached.image||"img/no-image.svg"}),e.jsx(o.Box,{component:"div",sx:R.getStyle(this.props.context.theme,this.styles.adapter,(t.stat||this.props.context.sortRecentlyUpdated)&&this.styles.adapterWithAgo),children:this.props.adapterName}),this.props.context.sortPopularFirst?e.jsx("div",{style:this.styles.versionDate,children:t.stat}):null,this.props.context.sortRecentlyUpdated?e.jsx("div",{style:this.styles.versionDate,children:this.props.cached.daysAgoText}):null,!this.props.context.sortPopularFirst&&!this.props.context.sortRecentlyUpdated?this.renderRating():null,this.state.openCollapse?null:e.jsx(o.Tooltip,{title:this.props.context.t("Info"),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:e.jsx(o.Fab,{onClick:()=>this.setState({openCollapse:!this.state.openCollapse}),style:this.styles.fab,color:"primary","aria-label":"add",children:e.jsx(u.MoreVert,{})})})]})}renderCardContent(){const t=this.props.context.repository[this.props.adapterName]?this.props.context.repository[this.props.adapterName].allowAdapterUpdate:!0,s=this.props.context.installed[this.props.adapterName];return e.jsxs(o.CardContent,{style:this.styles.cardContent2,children:[e.jsx(o.Typography,{gutterBottom:!0,variant:"h5",component:"h5",children:this.props.cached.title}),e.jsxs("div",{style:this.styles.cardContentFlex,children:[this.renderConnectionType(),this.renderDataSource(),e.jsx("div",{children:this.renderLicenseInfo()}),this.renderSentryInfo()]}),e.jsxs("div",{style:this.styles.cardMargin10,children:[s!=null&&s.count?e.jsxs(o.Typography,{component:"span",style:this.styles.cardContentFlexBetween,children:[e.jsxs("div",{children:[this.props.context.t("Installed instances"),":"]}),e.jsx("div",{children:s.count})]}):null,e.jsx(N,{value:t,children:e.jsxs(o.Typography,{component:"span",style:this.styles.availableVersion,children:[e.jsx("div",{children:this.props.context.t("Available version:")}),e.jsx(o.Box,{component:"div",sx:R.getStyle(this.props.context.theme,this.props.cached.updateAvailable&&this.styles.greenText,this.styles.curdContentFlexCenter),children:this.renderVersion()})]})}),this.renderInstalledVersion()]})]})}render(){var t;return this.installedVersion=(t=this.props.context.installed[this.props.adapterName])==null?void 0:t.version,e.jsxs(o.Card,{sx:this.styles.root,children:[this.state.openCollapse?this.renderInfoCard():null,this.renderCardMedia(),this.renderCardContent(),this.renderDialogs()]})}}const Ht={...gt,type:{color:"line"},smallAvatar:{width:32,height:32,marginLeft:4},paddingNone:{padding:"0 !important"},name:{flexWrap:"nowrap",width:300,marginTop:0},flex:{display:"flex"},nameCell:{paddingTop:"0 !important",paddingBottom:"0 !important"}};class Et extends G{styles=Ht;render(){var i,r;const t=this.props.context.repository[this.props.adapterName],s=t?t.allowAdapterRating:!0;return this.installedVersion=(i=this.props.context.installed[this.props.adapterName])==null?void 0:i.version,e.jsxs(o.TableRow,{hover:!0,children:[e.jsx(o.TableCell,{}),e.jsx(o.TableCell,{children:e.jsxs(o.Grid2,{container:!0,spacing:1,alignItems:"center",style:this.styles.name,children:[e.jsx(o.Tooltip,{title:this.props.adapterName,slotProps:{popper:{sx:this.styles.tooltip}},children:e.jsx(o.Grid2,{style:this.styles.paddingNone,children:e.jsx(o.Avatar,{variant:"square",alt:this.props.cached.title,src:this.props.cached.image,style:this.styles.smallAvatar})})}),s!==!1?e.jsxs(o.Grid2,{style:this.styles.nameCell,children:[e.jsx("div",{children:this.props.cached.title}),this.renderRating()]}):e.jsx(o.Grid2,{children:this.props.cached.title})]})}),!this.props.context.descHidden&&e.jsx(o.TableCell,{title:this.props.cached.desc,style:{width:20,wordWrap:"break-word"},children:this.props.cached.desc}),e.jsx(o.TableCell,{children:e.jsxs("div",{style:this.styles.flex,children:[this.renderConnectionType()||e.jsx("div",{style:{marginLeft:5,width:24,height:24}}),this.renderDataSource()||e.jsx("div",{style:{width:24,height:24}}),this.renderSentryInfo()||e.jsx("div",{style:{width:24,height:24}}),this.renderLicenseInfo()]})}),e.jsx(o.TableCell,{children:this.renderInstalledVersion(!0)}),e.jsx(o.TableCell,{children:e.jsx(o.Grid2,{container:!0,alignItems:"center",children:this.renderVersion()})}),e.jsx(o.TableCell,{style:{fontSize:"smaller"},children:((r=t==null?void 0:t.licenseInformation)==null?void 0:r.license)||(t==null?void 0:t.license)}),e.jsxs(o.TableCell,{children:[this.renderAddInstanceButton(),this.renderAutoUpgradeButton(),this.renderReadmeButton(),this.renderUploadButton(),this.renderDeleteButton(),this.renderInstallSpecificVersionButton(),this.renderRebuildButton()]}),this.renderDialogs()]})}}const X=246,$={emptyBlock:50,name:300,connectionType:120,installed:120,available:120,update:40,license:80,install:X},J=Object.keys($).reduce((p,t)=>p+$[t],0),I={container:{height:"100%",width:"100%"},containerNotFullHeight:{height:"calc(100% - 50px)"},containerFullHeight:{height:"100%"},table:{width:"100%",tableLayout:"fixed",minWidth:960,"& td":{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",pt:"2px",pb:"2px",pr:"4px",pl:"4px"},"& th":{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",pt:"2px",pb:"2px",pr:"4px",pl:"4px"}},name:{flexWrap:"nowrap",width:$.name},emptyBlock:{flexWrap:"nowrap",width:$.emptyBlock},description:{width:`calc(100% - ${J+2}px)`},connectionType:{width:$.connectionType},installed:{width:$.installed},available:{width:$.available,paddingRight:6},license:{width:$.license},install:{width:$.install},viewModeDiv:{display:"flex",flexFlow:"wrap",overflow:"auto",justifyContent:"center"}};class Gt extends L.Component{lastRenderCounter=-1;constructor(t){super(t),this.state={descWidth:t.descWidth,repoName:t.repoName,systemConfig:!!t.systemConfig,tableViewMode:t.tableViewMode,oneListView:t.oneListView,categoriesExpanded:JSON.stringify(t.categoriesExpanded),cachedAdapters:t.cachedAdapters?Object.keys(t.cachedAdapters).length:0,update:t.update,sortByName:t.sortByName,sortPopularFirst:t.sortPopularFirst,sortRecentlyUpdated:t.sortRecentlyUpdated,renderCounter:0,listOfVisibleAdapter:JSON.stringify(t.listOfVisibleAdapter),expertMode:t.context.expertMode,commandRunning:t.commandRunning,noTranslation:t.noTranslation}}getRow(t,s){const i=this.props.cachedAdapters[t];return i?e.jsx(Et,{context:s,adapterName:t,cached:i,commandRunning:this.state.commandRunning,noTranslation:this.state.noTranslation},`adapter-${t}`):null}getRows(t){var r;if(!this.props.listOfVisibleAdapter)return e.jsx(o.TableRow,{children:e.jsx(o.TableCell,{colSpan:8,children:e.jsx(o.LinearProgress,{})})});let s=0,i=[];if(this.props.oneListView){for(let n=0;n<this.props.listOfVisibleAdapter.length;n++){const a=this.props.listOfVisibleAdapter[n];i.length>50&&!((r=this.props.context.installed[a])!=null&&r.version)||i.push(this.getRow(a,t))}if(s=i.length,s&&this.props.listOfVisibleAdapter.length>i.length){const n=this.props.listOfVisibleAdapter.length-i.length,a=n===1?this.props.context.t("Filter adapters to see others. There is %s more",1):this.props.context.t("Filter adapters to see others. There are %s more",n);i.push(e.jsx(o.TableRow,{children:e.jsx(o.TableCell,{colSpan:8,style:{fontSize:20,padding:20,textAlign:"center"},children:a})},"more"))}}else i=this.props.categories.map(n=>{if(!n.adapters.find(d=>this.props.listOfVisibleAdapter.includes(d)))return null;const c=n.name,h=this.props.categoriesExpanded[c];return s++,e.jsxs(L.Fragment,{children:[e.jsx(Ut,{categoryName:c,count:n.count,expanded:h,installedCount:n.installed,name:n.translation,descHidden:t.descHidden,onToggle:()=>this.props.toggleCategory(c),t:this.props.context.t},`category-${c}1`),h&&n.adapters.map(d=>{const l=this.getRow(d,t);return l&&s++,l})]},`category-${c} ${n.adapters.length}`)});return s?i:this.props.update?null:e.jsx("tr",{children:e.jsxs("td",{colSpan:8,style:{textAlign:"center"},children:[this.props.searchFilter||this.props.installedListFilter?e.jsx(o.Button,{variant:"outlined",title:this.props.context.t("Click to clear all filters"),onClick:()=>this.props.clearAllFilters(),children:this.props.context.t("all items are filtered out")}):null,this.props.updateListFilter&&(this.props.searchFilter||this.props.installedListFilter)?e.jsx("br",{}):null,this.props.updateListFilter?e.jsx(o.Button,{style:{marginTop:16},variant:"outlined",onClick:()=>this.props.clearAllFilters(!0),startIcon:e.jsx(u.Update,{}),children:this.props.context.t("Remove filter for updatable adapters")}):null]})})}getTiles(t){var i;if(!this.props.listOfVisibleAdapter)return e.jsx(o.LinearProgress,{});if(!this.props.listOfVisibleAdapter.length)return this.props.update?null:e.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:16},children:[this.props.searchFilter||this.props.installedListFilter?e.jsx(o.Tooltip,{title:this.props.context.t("Click to clear all filters"),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:e.jsx(o.Button,{variant:"outlined",onClick:()=>this.props.clearAllFilters(),children:this.props.context.t("all items are filtered out")})}):null,this.props.updateListFilter?e.jsx(o.Button,{variant:"outlined",onClick:()=>this.props.clearAllFilters(!0),startIcon:e.jsx(u.Update,{}),children:this.props.context.t("Remove filter for updatable adapters")}):null]});const s=[];for(let r=0;r<this.props.listOfVisibleAdapter.length;r++){const n=this.props.listOfVisibleAdapter[r],a=this.props.cachedAdapters[n];s.length>50&&!((i=this.props.context.installed[n])!=null&&i.version)||s.push(e.jsx(_t,{context:t,adapterName:n,cached:a,commandRunning:this.state.commandRunning,noTranslation:this.state.noTranslation},`adapter-${n}`))}return this.props.listOfVisibleAdapter.length>s.length&&(s.push(e.jsx("div",{style:{flexBasis:"100%",height:0}},"newLine")),s.push(e.jsx("div",{style:{fontSize:20,margin:20},children:this.props.context.t("Filter adapters to see others. There is %s more",this.props.listOfVisibleAdapter.length-s.length)},"more"))),s}renderTileView(t,s,i){return e.jsxs(e.Fragment,{children:[t?null:e.jsx(o.Box,{sx:{marginX:2,marginTop:1,width:"calc(100% - 32px)"},children:e.jsx(Z,{type:"warning",children:this.props.context.t('Active repo is "%s"',s)})}),e.jsx("div",{style:I.viewModeDiv,children:this.getTiles(i)})]})}renderTableView(t,s,i){return e.jsxs(vt,{children:[t?null:e.jsx(o.Box,{sx:{marginX:2,marginTop:1,width:"calc(100% - 32px)"},children:e.jsx(Z,{type:"warning",children:this.props.context.t('Active repo is "%s"',s)})}),e.jsx(o.TableContainer,{style:{...I.container,...t?I.containerFullHeight:I.containerNotFullHeight},children:e.jsxs(o.Table,{stickyHeader:!0,size:"small",sx:I.table,children:[e.jsx(o.TableHead,{children:e.jsxs(o.TableRow,{children:[e.jsx(o.TableCell,{style:I.emptyBlock}),e.jsx(o.TableCell,{style:I.name,children:e.jsx(o.Typography,{children:this.props.context.t("Name")})}),!i.descHidden&&e.jsx(o.TableCell,{style:{...I.description,width:this.props.descWidth},children:e.jsx(o.Typography,{children:this.props.context.t("Description")})}),e.jsx(o.TableCell,{style:I.connectionType}),e.jsx(o.TableCell,{style:I.installed,children:e.jsx(o.Typography,{children:this.props.context.t("Installed")})}),e.jsx(o.TableCell,{style:I.available,children:e.jsx(o.Typography,{children:this.props.context.t("Available")})}),e.jsx(o.TableCell,{style:I.license,children:e.jsx(o.Typography,{children:this.props.context.t("License")})}),e.jsx(o.TableCell,{style:{...I.install,width:this.state.expertMode?X:X-68},children:e.jsx(o.Typography,{children:this.props.context.t("Install")})})]})}),e.jsx(o.TableBody,{children:this.getRows(i)})]})})]})}static getDerivedStateFromProps(t,s){let i=!1;t.descWidth!==s.descWidth&&(console.log("Render because of descWidth"),i=!0),t.repoName!==s.repoName&&(console.log("Render because of repoName"),i=!0),!!t.systemConfig!==s.systemConfig&&(console.log("Render because of systemConfig"),i=!0),t.tableViewMode!==s.tableViewMode&&(console.log("Render because of tableViewMode"),i=!0),t.oneListView!==s.oneListView&&(console.log("Render because of oneListView"),i=!0);const r=JSON.stringify(t.categoriesExpanded);r!==s.categoriesExpanded&&(console.log("Render because of categoriesExpanded"),i=!0);const n=t.cachedAdapters?Object.keys(t.cachedAdapters).length:0;n!==s.cachedAdapters&&(console.log(`Render because of cachedAdapters ${n} <> ${s.cachedAdapters}`),i=!0),t.update!==s.update&&(console.log("Render because of update"),i=!0),t.sortByName!==s.sortByName&&(console.log("Render because of sortByName"),i=!0),t.sortPopularFirst!==s.sortPopularFirst&&(console.log("Render because of sortPopularFirst"),i=!0),t.sortRecentlyUpdated!==s.sortRecentlyUpdated&&(console.log("Render because of sortRecentlyUpdated"),i=!0),t.context.expertMode!==s.expertMode&&(console.log("Render because of expertMode"),i=!0);const a=JSON.stringify(t.listOfVisibleAdapter);return a!==s.listOfVisibleAdapter&&(console.log("Render because of listOfVisibleAdapter"),i=!0),t.commandRunning!==s.commandRunning&&(console.log("Render because of commandRunning"),i=!0),t.noTranslation!==s.noTranslation&&(console.log("Render because of commandRunning"),i=!0),i?{descWidth:t.descWidth,repoName:t.repoName,systemConfig:!!t.systemConfig,tableViewMode:t.tableViewMode,oneListView:t.oneListView,categoriesExpanded:r,cachedAdapters:n,update:t.update,sortByName:t.sortByName,sortPopularFirst:t.sortPopularFirst,sortRecentlyUpdated:t.sortRecentlyUpdated,listOfVisibleAdapter:a,renderCounter:s.renderCounter+1,expertMode:t.context.expertMode,commandRunning:t.commandRunning,noTranslation:t.noTranslation}:null}shouldComponentUpdate(t,s){return this.lastRenderCounter!==s.renderCounter?(this.lastRenderCounter=s.renderCounter,!0):!1}render(){var t,s;return(s=(t=this.props.systemConfig)==null?void 0:t.common)!=null&&s.activeRepo?this.props.tableViewMode?this.renderTableView(this.props.stableRepo,this.props.repoName,this.props.context):this.renderTileView(this.props.stableRepo,this.props.repoName,this.props.context):e.jsx(o.LinearProgress,{})}}class zt extends L.Component{updating;interval;startTimeout;textareaRef;link;oldVersion;constructor(t){super(t),this.state={response:null,error:null,starting:!0,upAgain:!1},this.updating=!1,this.textareaRef=q.createRef(),this.link=`${window.location.protocol}//${window.location.host}/`}setUpdating(t){this.updating!==t&&(this.updating=t,this.props.onUpdating(t))}async getWebserverParams(){const t=await this.props.socket.getObject(`system.adapter.${this.props.adminInstance}`);return{useHttps:t.native.secure,port:t.native.port,certPrivateName:t.native.certPrivate,certPublicName:t.native.certPublic}}async componentDidMount(){const{certPrivateName:t,certPublicName:s,port:i,useHttps:r}=await this.getWebserverParams();this.oldVersion=this.props.currentAdminVersion,await this.props.socket.upgradeAdapterWithWebserver(this.props.host,{version:this.props.version,adapterName:"admin",port:i,useHttps:r,certPublicName:s,certPrivateName:t}),this.setUpdating(!0),this.interval=setInterval(()=>this.checkStatus(),1e3),this.startTimeout=setTimeout(()=>{this.startTimeout=null,this.setState({starting:!1})},1e4)}componentWillUnmount(){this.interval&&(clearInterval(this.interval),this.interval=null),this.startTimeout&&(clearTimeout(this.startTimeout),this.startTimeout=null)}async checkVersion(){try{const s=await(await fetch("./version")).text();return s&&s.length<20&&s!==this.oldVersion?(this.interval&&(clearInterval(this.interval),this.interval=null),this.setState({response:{running:!1,success:!0,stderr:[],stdout:[w.t("Version updated to %s",s)]},upAgain:!0,error:null},()=>this.setUpdating(!1)),!0):s===this.oldVersion}catch{return!1}}async checkStatus(){console.log(`Request update status from: ${this.link}`);try{const s=await(await fetch(this.link)).text();if(console.log(`Received status: ${s}`),s.startsWith("{")&&s.endsWith("}"))try{const i=JSON.parse(s);i!=null&&i.stderr&&(i.stderr=i.stderr.filter(r=>r.trim())),i&&!i.running&&i.success&&i.stdout?(i.stdout.push(""),i.stdout.push("---------------------------------------------------"),i.stdout.push(w.t("%s was successfully updated to %s","admin",this.props.version))):i!=null&&i.stdout&&(i.stdout.unshift(""),i.stdout.unshift("---------------------------------------------------"),i.stdout.unshift(w.t("updating %s to %s...","admin",this.props.version))),this.setState({response:i,error:null},()=>{i&&!i.running?(this.interval&&(clearInterval(this.interval),this.interval=null),this.waitForAdapterStart()):i!=null&&i.running&&this.setUpdating(!0),this.textareaRef.current&&setTimeout(()=>this.textareaRef.current.scrollTop=this.textareaRef.current.scrollHeight,100)})}catch(i){console.error(`Cannot parse response: ${i}`),this.setState({error:s},()=>this.setUpdating(!1))}else await this.checkVersion()||console.error(`Response is not JSON: ${s}`)}catch(t){this.state.starting||this.setState({error:t.toString()},()=>this.setUpdating(!1))}}waitForAdapterStart(){this.interval=setInterval(async()=>{try{await fetch(this.link),clearInterval(this.interval),this.interval=null,this.setState({upAgain:!0})}catch{}},1e3)}render(){var t,s,i,r,n;return e.jsxs(o.Dialog,{onClose:(a,c)=>{c!=="escapeKeyDown"&&c!=="backdropClick"&&this.props.onClose()},open:!0,maxWidth:"lg",fullWidth:!0,children:[e.jsx(o.DialogTitle,{children:w.t("Updating %s...","admin")}),e.jsxs(o.DialogContent,{style:{height:400,padding:"0 20px",overflow:"hidden"},children:[(!this.state.response||this.state.response.running)&&!this.state.error?e.jsx(o.LinearProgress,{}):null,this.state.response||this.state.error?e.jsx("textarea",{ref:this.textareaRef,style:{width:"100%",height:"100%",resize:"none",background:this.props.themeType==="dark"?"#000":"#fff",color:this.props.themeType==="dark"?"#EEE":"#111",boxSizing:"border-box",fontFamily:"Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace",border:(t=this.state.response)!=null&&t.success?"2px solid green":this.state.error||this.state.response&&!this.state.response.running&&!this.state.response.success?"2px solid red":void 0},value:this.state.error?this.state.error:this.state.response.stderr&&this.state.response.stderr.length?this.state.response.stderr.join(`
|
|
5
|
-
`):this.state.response.stdout.join(`
|
|
6
|
-
`),readOnly:!0}):null]}),e.jsx(o.DialogActions,{children:e.jsx(o.Button,{variant:"contained",disabled:this.state.starting||!this.state.error&&!this.state.upAgain,onClick:()=>{var a;(a=this.state.response)!=null&&a.success&&window.location.reload(),this.props.onClose()},color:(s=this.state.response)!=null&&s.success?"primary":"grey",startIcon:(i=this.state.response)!=null&&i.success?e.jsx(u.Refresh,{}):e.jsx(u.Close,{}),children:(r=this.state.response)!=null&&r.success&&!this.state.upAgain?e.jsx(o.CircularProgress,{}):(n=this.state.response)!=null&&n.success?w.t("Reload"):w.t("Close")})})]})}}const b={grow:{flexGrow:1},updateAllButton:p=>({position:"relative","& .admin-update-second-icon":{position:"absolute",top:15,left:15,opacity:.4,color:p.palette.mode==="dark"?"#aad5ff":"#007fff"}}),counters:{mr:"10px",minWidth:120,display:"flex","& div":{ml:"3px"}},infoAdapters:p=>({fontSize:10,color:p.palette.mode==="dark"?"#9c9c9c":"#333",cursor:"pointer"}),greenText:{color:"#00a005d1"},tooltip:{pointerEvents:"none"}},lt=[{name:"Description A-Z"},{name:"Name A-Z"},{name:"Popular first",notByList:!0},{name:"Recently updated",notByList:!0}];class k extends F{inputRef;countRef;t;wordCache={};cache={listOfVisibleAdapter:null,adapters:null};listOfVisibleAdapterLength=0;allAdapters=0;installedAdapters=0;recentUpdatedAdapters=0;uuid="";buildCacheTimer=null;updateTimeout=null;typingTimer=null;hostsTimer=null;onHostAdapterTimer=null;tempAdapters=null;tempInstalled=null;tempInstances=null;hostAdapterWorker=null;constructor(t){super(t),Object.assign(this.state,{lastUpdate:0,repository:{},installed:{},installedGlobal:{},adapters:{},compactInstances:{},categories:[],hostData:null,compactRepositories:null,hostOs:"",nodeJsVersion:"",init:!1,update:!1,filterConnectionType:!1,search:(window._localStorage||window.localStorage).getItem("Adapter.search")||"",oneListView:!1,tableViewMode:!1,updateList:!1,installedList:0,categoriesTiles:"All",filterTiles:"Description A-Z",gitHubInstallDialog:!1,updateAvailable:[],filteredList:null,showUpdater:!1,descWidth:300,showStatistics:!1,readTimeoutMs:st.getReadTimeoutMs(),showSlowConnectionWarning:!1,currentHost:t.currentHost,forceUpdateAdapters:t.forceUpdateAdapters,triggerUpdate:t.triggerUpdate,ratings:null,categoriesExpanded:{},adminUpgradeTo:""}),this.inputRef=L.createRef(),this.countRef=L.createRef(),this.t=this.translate}translate=(t,s,i)=>s!==void 0?this.props.t(t,s,i):(this.wordCache[t]||(this.wordCache[t]=this.props.t(t)),this.wordCache[t]);renderSlowConnectionWarning(){return this.state.showSlowConnectionWarning?e.jsx(st,{readTimeoutMs:this.state.readTimeoutMs,t:this.t,onClose:t=>{t?this.setState({showSlowConnectionWarning:!1,readTimeoutMs:t},()=>this.updateAll()):this.setState({showSlowConnectionWarning:!1})}}):null}async componentDidMount(){this.props.ready&&(this.hostAdapterWorker=new ot(this.props.socket,this.props.currentHost),this.hostAdapterWorker.registerHandler(this.onHostAdapterChanged),await this.hostAdapterWorker.getObjects(),await this.updateAll(),this.state.search&&this.filterAdapters(),this.props.adaptersWorker.registerHandler(this.onAdaptersChanged),this.props.instancesWorker.registerHandler(this.onAdaptersChanged))}async updateAll(t,s,i){await this.getAdapters(t,s,i),await this.getAdaptersInfo(t,i)}componentDidUpdate(){const t=this.getDescWidth();this.state.descWidth!==t&&this.setState({descWidth:t}),this.countRef.current&&(this.countRef.current.innerHTML=this.listOfVisibleAdapterLength.toString())}componentWillUnmount(){this.updateTimeout&&(clearTimeout(this.updateTimeout),this.updateTimeout=null),this.buildCacheTimer&&(clearTimeout(this.buildCacheTimer),this.buildCacheTimer=null),this.typingTimer&&(clearTimeout(this.typingTimer),this.typingTimer=null),this.hostsTimer&&(clearTimeout(this.hostsTimer),this.hostsTimer=null),this.onHostAdapterTimer&&(clearTimeout(this.onHostAdapterTimer),this.onHostAdapterTimer=null),this.props.adaptersWorker.unregisterHandler(this.onAdaptersChanged),this.props.instancesWorker.unregisterHandler(this.onAdaptersChanged),this.hostAdapterWorker.destroy(),this.hostAdapterWorker=null}onAdaptersChanged=t=>{this.tempAdapters=this.tempAdapters||JSON.parse(JSON.stringify(this.state.adapters||{})),this.tempInstalled=this.tempInstalled||JSON.parse(JSON.stringify(this.state.installed||{})),this.tempInstances=this.tempInstances||JSON.parse(JSON.stringify(this.state.compactInstances||{})),t.forEach(s=>{if(!!s.id.match(/\.\d+$/))s.type==="deleted"||!s.obj?delete this.tempInstances[s.id]:this.tempInstances[s.id]={enabled:s.obj.common.enabled,icon:s.obj.common.icon,name:s.obj.common.name,adminTab:s.obj.common.adminTab,version:s.obj.common.version};else if(s.type==="deleted"||!s.obj){const r=s.id.split(".");delete this.tempInstalled[r[2]],delete this.tempAdapters[s.id]}else{const r=s.obj.common.name;this.tempInstalled[r]?Object.keys(this.tempInstalled[r]).forEach(n=>{s.obj.common[n]!==void 0&&n!=="installedFrom"&&(this.tempInstalled[r][n]=s.obj.common[n])}):this.tempInstalled[s.id.split(".").pop()]=JSON.parse(JSON.stringify(s.obj.common)),this.tempAdapters[s.id]=s.obj}}),this.updateTimeout&&clearTimeout(this.updateTimeout),this.updateTimeout=setTimeout(()=>{this.updateTimeout=null;const s=this.tempAdapters;this.tempAdapters=null;const i=this.tempInstalled;this.tempInstalled=null;const r=this.tempInstances;this.tempInstances=null,this.analyseInstalled({adapters:s,installedLocal:i,cb:()=>this.calculateInfo(r)})},300)};analyseInstalled(t){let{adapters:s,repository:i}=t;const{cb:r,installedLocal:n}=t;let{installedGlobal:a}=t;s=s||this.state.adapters;const c=n||this.state.installed;a=a||this.state.installedGlobal,i=i||this.state.repository;const h=[];Object.keys(c).forEach(d=>{if(c[d]){const l=c[d].version,g=i[d];g&&g.version!==l&&dt.updateAvailable(l,g.version)&&!h.includes(d)&&h.push(d)}}),this.cache.listOfVisibleAdapter=null,this.setState({adapters:s,updateAvailable:h,installed:c,repository:i,installedGlobal:a},()=>r&&r())}async getInstalled(t){let s,i={};const r=await this.props.socket.getHosts(t);for(const n of r)try{const a=await this.props.socket.getState(`${n._id}.alive`);if(a!=null&&a.val){const c=await this.props.socket.getInstalled(n._id,t,this.state.readTimeoutMs);n._id===this.state.currentHost&&(s=c),i={...i,...c}}}catch(a){window.alert(`Cannot getInstalled from "${n._id}" (timeout ${this.state.readTimeoutMs}ms): ${a}`),a.toString().includes("timeout")&&this.setState({showSlowConnectionWarning:!0})}return{installedLocal:s,installedGlobal:i}}async getAdapters(t,s,i){console.log("[ADAPTERS] getAdapters");const r=this.state.currentHost;t=t||this.props.adaptersWorker.isForceUpdate(),!this.state.update&&(t||i)&&this.setState({update:!0});let n;try{n=await this.props.adaptersWorker.getObjects(t)||{}}catch(d){window.alert(`Cannot getAdapters: ${d}`)}const{installedLocal:a,installedGlobal:c}=await this.getInstalled(t);let h;try{h=await this.props.socket.getRepository(r,{repo:this.props.systemConfig.common.activeRepo,update:s||i},t,this.state.readTimeoutMs)}catch(d){window.alert(`Cannot getRepository: ${d}`),d.toString().includes("timeout")&&this.setState({showSlowConnectionWarning:!0})}return this.analyseInstalled({adapters:n,installedLocal:a,repository:h,installedGlobal:c})}getWordVotes(t){if(t===1)return this.t("vote");if(t>=2&&t<=4)return this.t("votes2");if(t>=5&&t<=20)return this.t("votes");const s=t%10;return s===1?this.t("vote21"):s>=2&&s<=4?this.t("votes2"):this.t("votes")}static getAdapterTitle(t,s,i){if(!s[t])return t;const r=s[t].titleLang||s[t].title;let n;return typeof r=="object"?n=r[i]||r.en:n=r,n=((n||"").toString()||"").replace("ioBroker Visualisation - ",""),n.toLowerCase()}static sortAdapters(t,s,i,r,n,a,c,h){const d={};t.sort((l,g)=>{if(a)return r[g].stat===r[l].stat?(d[l]=d[l]||k.getAdapterTitle(l,r,s),d[g]=d[g]||k.getAdapterTitle(g,r,s),d[l]>d[g]?1:d[l]<d[g]?-1:0):r[g].stat-r[l].stat;if(c)return r[l]?r[g]?r[l].daysAgo===r[g].daysAgo?(d[l]=d[l]||k.getAdapterTitle(l,r,s),d[g]=d[g]||k.getAdapterTitle(g,r,s),d[l]>d[g]?1:d[l]<d[g]?-1:0):r[l].daysAgo-r[g].daysAgo:1:-1;if(h){if(h[l].exact&&!h[g].exact)return-1;if(!h[l].exact&&h[g].exact)return 1}return i[l]&&i[g]?n?l>g?1:l<g?-1:0:(d[l]=d[l]||k.getAdapterTitle(l,r,s),d[g]=d[g]||k.getAdapterTitle(g,r,s),d[l]>d[g]?1:d[l]<d[g]?-1:0):i[l]?-1:i[g]?1:n?l>g?1:l<g?-1:0:(d[l]=d[l]||k.getAdapterTitle(l,r,s),d[g]=d[g]||k.getAdapterTitle(g,r,s),d[l]>d[g]?1:d[l]<d[g]?-1:0)})}calculateInfo(t,s,i,r){i=i||this.state.hostData,s=s||this.state.ratings,t=t||this.state.compactInstances,r!=null&&r._id||(r=this.state.compactRepositories);const n=this.state.adapters,a=JSON.parse(JSON.stringify(this.state.installed)),c=JSON.parse(JSON.stringify(this.state.repository)),h=((i==null?void 0:i["Node.js"])||"").replace("v",""),d=(i==null?void 0:i.os)||"",l={},g=[];let x={};try{x=JSON.parse((window._localStorage||window.localStorage).getItem("Adapters.expandedCategories"))||{}}catch{}Object.keys(a).forEach(f=>{var U,E;const y=a[f];(E=(U=n[f])==null?void 0:U.common)!=null&&E.ignoreVersion&&(y.ignoreVersion=n[f].common.ignoreVersion),!y.controller&&f!=="hosts"&&(c[f]||(c[f]=JSON.parse(JSON.stringify(y)),c[f].version="")),y.count=0,y.enabled=0}),Object.keys(t).forEach(f=>{const y=t[f].name;a[y]&&a[y].count++});const m=Date.now();this.recentUpdatedAdapters=0,this.installedAdapters=0,Object.keys(c).forEach(f=>{var E;if(f==="hosts"||f.startsWith("_"))return;const y=c[f];y.keywords&&(y.keywords=y.keywords.map(D=>D.toLowerCase()));const U=a[f];if(y.rating=s==null?void 0:s[f],(E=y.rating)!=null&&E.rating?y.rating.title=[`${this.t("Total rating:")} ${y.rating.rating.r} (${y.rating.rating.c} ${this.getWordVotes(y.rating.rating.c)})`,U&&U.version&&y.rating[U.version]?`${this.t("Rating for")} v${U.version}: ${y.rating[U.version].r} (${y.rating[U.version].c} ${this.getWordVotes(y.rating.rating.c)})`:""].filter(D=>D).join(`
|
|
7
|
-
`):y.rating={title:this.t("No rating or too few data")},!y.controller){const D=y.type,et=a[f];Math.round((m-new Date(y.versionDate).getTime())/864e5)<=31&&this.recentUpdatedAdapters++,a[f]&&this.installedAdapters++,l[D]?(l[D].count++,l[D].adapters.push(f),et&&l[D].installed++):l[D]={name:D,translation:this.t(`${D}_group`),count:1,installed:et?1:0,adapters:[f]}}}),Object.keys(l).sort((f,y)=>f==="general"&&y!=="general"?-1:f!=="general"&&y==="general"||l[f].translation>l[y].translation?1:l[f].translation<l[y].translation?-1:0).forEach(f=>g.push(l[f]));const v=this.state.filterTiles==="Name A-Z";Object.keys(l).forEach(f=>k.sortAdapters(l[f].adapters,this.props.lang,a,c,v));let j=0;try{j=JSON.parse((window._localStorage||window.localStorage).getItem("Adapters.installedList")),j===!1&&(j=0)}catch{}const O=(window._localStorage||window.localStorage).getItem("Adapters.list")==="true",S=(window._localStorage||window.localStorage).getItem("Adapters.viewMode")==="true",M=(window._localStorage||window.localStorage).getItem("Adapters.updateList")==="true",_=(window._localStorage||window.localStorage).getItem("Adapters.categoriesTiles")||"All";let W=(window._localStorage||window.localStorage).getItem("Adapters.filterTiles")||"Description A-Z";return W==="A-Z"&&(W="Description A-Z"),this.allAdapters=Object.keys(c).length-1,this.cache.listOfVisibleAdapter=null,new Promise(f=>{this.setState({repository:c,installed:a,ratings:s,filterTiles:W,categoriesTiles:_,compactRepositories:r,installedList:j,compactInstances:t,updateList:M,tableViewMode:S,oneListView:O,lastUpdate:Date.now(),hostData:i,hostOs:d,nodeJsVersion:h,categories:g,categoriesExpanded:x,init:!0,update:!1},()=>f())})}async getAdaptersInfo(t,s){var i;if(this.state.currentHost&&Date.now()-this.state.lastUpdate>1e3){console.log("[ADAPTERS] getAdaptersInfo");const r=this.state.currentHost;let n;try{(!this.state.update||s)&&await new Promise(l=>{this.setState({update:!0},()=>l())});const a=await this.props.socket.getHostInfo(r,t,this.state.readTimeoutMs).catch(l=>{window.alert(`Cannot getHostInfo for "${r}": ${l}`),l.toString().includes("timeout")&&this.setState({showSlowConnectionWarning:!0})});if(((i=this.props.adminGuiConfig.admin.adapters)==null?void 0:i.allowAdapterRating)!==!1){try{n=await this.props.socket.getRatings(t)}catch(l){window.alert(`Cannot read ratings: ${l}`)}this.uuid=(n==null?void 0:n.uuid)||null}else n=null;const c=await this.props.socket.getCompactInstances(t).catch(l=>(window.alert(`Cannot read countsOfInstances: ${l}`),{})),d=await this.props.socket.getCompactSystemRepositories(t).catch(l=>(window.alert(`Cannot read getCompactSystemRepositories: ${l}`),{}));await this.calculateInfo(c||{},n,a,d)}catch(a){window.alert(`Cannot get adapters info: ${a}`)}}}toggleCategory(t){this.setState(s=>{const i=s.categoriesExpanded;return i[t]=!i[t],(window._localStorage||window.localStorage).setItem("Adapters.expandedCategories",JSON.stringify(i)),{categoriesExpanded:i}})}rightDependencies=t=>{const s=this.state.repository[t];let i=!0;if(s){const r=s.dependencies,n=s.node;if(r)if(r instanceof Array)r.forEach(c=>{const h=typeof c!="string",d=Object.keys(c),l=h?d?d[0]:null:c;if(i&&l){const g=this.state.installed[l];try{i=g?h?V.satisfies(g.version,c[l],{includePrerelease:!0}):!0:!1}catch{i=!0}}});else if(typeof r=="object"){const c=r;Object.keys(c).forEach(h=>{if(h&&c[h]!==void 0&&i){const d=this.state.installed[h],l=typeof c[h]=="string";try{i=d?l?V.satisfies(d.version,c[h],{includePrerelease:!0}):!0:!1}catch{i=!0}}})}else console.error(`[ADAPTERS] Invalid dependencies for ${t}: ${JSON.stringify(r)}`);const a=s.ifInstalledDependencies;if(a&&typeof a=="object"&&!Array.isArray(a)&&Object.keys(a).forEach(h=>{if(i&&h){const d=this.state.installed[h];try{i=d?V.satisfies(d.version,a[h],{includePrerelease:!0}):!0}catch{i=!0}}}),i&&n)try{i=V.satisfies(this.state.nodeJsVersion,n)}catch{i=!0}}return i};rightOs(t){const s=this.state.repository[t];return s!=null&&s.os?Array.isArray(s.os)?!!s.os.find(i=>this.state.hostOs===i):this.state.hostOs===s.os:!0}handleFilterChange(t){this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout(s=>{(window._localStorage||window.localStorage).setItem("Adapter.search",s||""),this.typingTimer=null,this.filterAdapters(s)},300,t.target.value)}expandAll(){this.setState(t=>{const s=t.categories,i=t.categoriesExpanded;return s.forEach(r=>i[r.name]=!0),(window._localStorage||window.localStorage).setItem("Adapters.expandedCategories",JSON.stringify(i)),{categoriesExpanded:i}})}collapseAll(){const t={};(window._localStorage||window.localStorage).setItem("Adapters.expandedCategories",JSON.stringify(t)),this.setState({categoriesExpanded:t})}listTable(){const t=!this.state.oneListView;t&&this.expandAll(),(window._localStorage||window.localStorage).setItem("Adapters.list",t?"true":"false"),this.setState({oneListView:t})}changeViewMode(){this.cache.listOfVisibleAdapter=null;const t=!this.state.tableViewMode;let s=this.state.filterTiles;t&&s!=="Description A-Z"&&s!=="Name A-Z"&&(s="Description A-Z",(window._localStorage||window.localStorage).setItem("Adapters.filterTiles",s)),(window._localStorage||window.localStorage).setItem("Adapters.viewMode",t?"true":"false"),this.setState({tableViewMode:t,filterTiles:s})}changeUpdateList(){this.cache.listOfVisibleAdapter=null;const t=!this.state.updateList;(window._localStorage||window.localStorage).setItem("Adapters.updateList",t?"true":"false"),this.setState({updateList:t})}changeInstalledList(t){this.cache.listOfVisibleAdapter=null;let s=this.state.installedList?this.state.installedList<2?2:0:1;!s&&t&&(s=1),(window._localStorage||window.localStorage).setItem("Adapters.installedList",JSON.stringify(s)),this.setState({installedList:s})}changeFilterTiles(t){this.cache.listOfVisibleAdapter=null,(window._localStorage||window.localStorage).setItem("Adapters.filterTiles",t),this.setState({filterTiles:t})}changeCategoriesTiles(t){this.cache.listOfVisibleAdapter=null,(window._localStorage||window.localStorage).setItem("Adapters.categoriesTiles",t),this.setState({categoriesTiles:t})}filterAdapters(t){t=t===void 0?this.state.search:t,t=(t||"").toLowerCase().trim();let s={};t?this.state.categories.forEach(i=>i.adapters.forEach(r=>{var d;const n=this.state.repository[r];if(!n)return;let a,c;const h=n.titleLang||n.title;typeof h=="object"?a=h[this.props.lang]||h.en:a=h,a=((a||"").toString()||"").replace("ioBroker Visualisation - ",""),n.desc?typeof n.desc=="string"?c=n.desc:c=n.desc[this.props.lang]||n.desc.en||"":c="",r.includes(t)?s[r]={exact:r===t,type:"name",start:r.startsWith(t)}:a&&typeof a=="string"&&a.toLowerCase().includes(t)?s[r]={exact:!1,type:"title"}:c&&typeof c=="string"&&c.toLowerCase().includes(t)?s[r]={exact:!1,type:"desc"}:(d=n.keywords)!=null&&d.find(l=>l.includes(t))&&(s[r]={exact:!1,type:"keywords"})})):s=null,this.setState({filteredList:s,search:t},()=>{this.cache.listOfVisibleAdapter=null,this.forceUpdate()})}onHostAdapterChanged=t=>{this.onHostAdapterTimer&&clearTimeout(this.onHostAdapterTimer),this.onHostAdapterTimer=setTimeout(()=>{this.onHostAdapterTimer=null,this.cache.listOfVisibleAdapter=null,this.forceUpdate()},200)};clearAllFilters(t){t?((window._localStorage||window.localStorage).removeItem("Adapters.updateList"),this.setState({updateList:!1},()=>this.filterAdapters())):((window._localStorage||window.localStorage).removeItem("Adapter.search"),(window._localStorage||window.localStorage).removeItem("Adapters.installedList"),(window._localStorage||window.localStorage).removeItem("Adapters.updateList"),this.inputRef.current&&(this.inputRef.current.value=""),this.setState({filteredList:null,updateList:!1,filterConnectionType:!1,installedList:0,search:""},()=>this.filterAdapters()))}getContext(t){return{expertMode:this.props.expertMode,t:this.t,socket:this.props.socket,removeUpdateAvailable:s=>{const i=[...this.state.updateAvailable],r=i.indexOf(s);r!==-1&&(i.splice(r,1),this.setState({updateAvailable:i}))},toggleTranslation:this.props.toggleTranslation,rightDependenciesFunc:this.rightDependencies,lang:this.props.lang,uuid:this.uuid,themeType:this.props.themeType,theme:this.props.theme,onUpdating:this.props.onUpdating,repository:this.state.repository,installed:this.state.installed,installedGlobal:this.state.installedGlobal,compactInstances:this.state.compactInstances||{},adapters:this.state.adapters,nodeJsVersion:this.state.nodeJsVersion,currentHost:this.state.currentHost,adminHost:this.props.adminHost,adminInstance:this.props.adminInstance,instancesWorker:this.props.instancesWorker,hostsWorker:this.props.hostsWorker,executeCommand:this.props.executeCommand,categories:this.state.categories,descHidden:t,sortPopularFirst:!this.state.tableViewMode&&this.state.filterTiles==="Popular first",sortRecentlyUpdated:!this.state.tableViewMode&&this.state.filterTiles==="Recently updated",isTileView:!this.state.tableViewMode,updateRating:(s,i)=>{const r=JSON.parse(JSON.stringify(this.state.repository));Object.assign(r[s].rating,i),this.setState({repository:r})},setAdminUpgradeTo:this.setAdminUpgradeTo,hostAdapterWorker:this.hostAdapterWorker}}setAdminUpgradeTo=t=>this.setState({adminUpgradeTo:t});buildCache(t){this.cache.listOfVisibleAdapter=[],this.cache.adapters={};const s=Date.now(),i=this.t("0 %d days ago"),r=this.t("1 %d days ago"),n=this.t("2 %d days ago"),a=this.t("5 %d days ago");this.state.categories.filter(h=>this.state.tableViewMode||!this.state.categoriesTiles||this.state.categoriesTiles==="All"||h.name===this.state.categoriesTiles).forEach(h=>h.adapters.forEach(d=>{var g;const l=this.state.repository[d];if(l&&!l.controller){const x=l.connectionType?l.connectionType:"-",m=this.state.updateAvailable.includes(d),v=this.state.installed[d];let j=!this.state.filteredList||!!this.state.filteredList[d];if(j&&this.state.filterConnectionType&&(j=x==="local"),j&&this.state.updateList&&(j=m),j&&this.state.installedList&&(j=this.state.installedList<2?!!(v&&v.version):!!(v&&v.version&&!v.count)),j){this.cache.listOfVisibleAdapter.push(d);const O=Math.round((s-new Date(l.versionDate).getTime())/864e4),S=Math.round(O/10),M=l.titleLang||l.title;let _;M&&typeof M=="object"?_=M[this.props.lang]||M.en:_=M||d,_=((_||"").toString()||"").replace("ioBroker Visualisation - ","");let W;l.desc?typeof l.desc=="string"?W=l.desc:W=l.desc[this.props.lang]||l.desc.en||"":W="";const f=S%100<=10||S%100>=20?S%10:5;this.cache.adapters[d]={title:_,desc:W,image:v&&this.state.adapters[`system.adapter.${d}`]?`.${v.localIcon}`:l.extIcon,connectionType:l.connectionType?l.connectionType:"-",updateAvailable:this.state.updateAvailable.includes(d),rightDependencies:this.rightDependencies(d),rightOs:this.rightOs(d),sentry:!!((g=l.plugins)!=null&&g.sentry),daysAgo:O,stat:l.stat||0,daysAgoText:S||S===0?S===0?i:f===1?r.replace("%d",S.toString()):f===2||f===3||f===4?n.replace("%d",S.toString()):a.replace("%d",S.toString()):""}}}})),this.listOfVisibleAdapterLength=this.cache.listOfVisibleAdapter.length;const c=this.state.filterTiles==="Name A-Z";this.state.tableViewMode&&this.state.categories.forEach(h=>k.sortAdapters(h.adapters,this.props.lang,this.state.installed,this.cache.adapters,c)),k.sortAdapters(this.cache.listOfVisibleAdapter,this.props.lang,this.state.installed,this.cache.adapters,c,t.sortPopularFirst,t.sortRecentlyUpdated,this.state.filteredList),console.log(`[ADAPTERS] ${new Date().toISOString()} Update cache!`),this.forceUpdate()}getUpdater(){return this.state.showUpdater?e.jsx(Dt,{theme:this.props.theme,onSetCommandRunning:t=>this.props.onSetCommandRunning(t),t:this.props.t,currentHost:this.state.currentHost,lang:this.props.lang,installed:this.state.installed,repository:this.state.repository,toggleTranslation:this.props.toggleTranslation,noTranslation:this.props.noTranslation,onClose:t=>this.setState({showUpdater:!1},()=>t&&this.updateAll(!0,!1)),socket:this.props.socket}):null}getDescWidth(){return this.props.menuOpened?document.body.scrollWidth-J-180+13:this.props.menuClosed?document.body.scrollWidth-J:document.body.scrollWidth-J-50+13}getStatistics(){return this.state.showStatistics?e.jsxs(o.Dialog,{open:!0,onClose:()=>this.setState({showStatistics:!1}),children:[e.jsx(o.DialogTitle,{children:this.t("Statistics")}),e.jsxs(o.DialogContent,{style:{fontSize:16},children:[e.jsxs(o.Box,{component:"div",sx:b.counters,children:[this.t("Total adapters"),":"," ",e.jsx("span",{style:{paddingLeft:6,fontWeight:"bold"},children:this.allAdapters})]}),e.jsxs(o.Box,{component:"div",sx:b.counters,children:[this.t("Installed adapters"),":"," ",e.jsx("span",{style:{paddingLeft:6,fontWeight:"bold"},children:this.installedAdapters})]}),e.jsxs(o.Box,{component:"div",sx:b.counters,children:[this.t("Last month updated adapters"),":"," ",e.jsx("span",{style:{paddingLeft:6,fontWeight:"bold"},children:this.recentUpdatedAdapters})]})]}),e.jsx(o.DialogActions,{children:e.jsx(o.Button,{variant:"contained",onClick:()=>this.setState({showStatistics:!1}),color:"primary",autoFocus:!0,startIcon:e.jsx(u.Close,{}),children:this.props.t("Close")})})]}):null}renderGitHubInstallDialog(t){return this.state.gitHubInstallDialog?e.jsx(Ot,{t:this.t,categories:this.state.categories,installed:this.state.installedGlobal,upload:s=>this.props.executeCommand(`upload ${s}${this.props.expertMode?" --debug":""}`),installFromUrl:(s,i,r)=>this.addInstance({adapterName:s,debug:i,customUrl:r,context:t}),repository:this.state.repository,onClose:()=>{this.setState({gitHubInstallDialog:!1})}}):null}renderHeader(){var s;let t=!this.props.commandRunning&&!!this.props.ready&&!!this.state.updateList&&this.state.updateAvailable.length>1;return t&&this.state.updateAvailable.length===2&&this.state.updateAvailable.includes("admin")&&(t=!1),e.jsxs(At,{children:[e.jsx(o.Tooltip,{title:this.t("Change view mode"),slotProps:{popper:{sx:b.tooltip}},children:e.jsx(o.IconButton,{size:"large",onClick:()=>this.changeViewMode(),children:this.state.tableViewMode?e.jsx(u.ViewModule,{}):e.jsx(u.ViewList,{})})}),e.jsx(o.Tooltip,{title:this.t("Check adapter for updates"),slotProps:{popper:{sx:b.tooltip}},children:e.jsx(o.IconButton,{size:"large",onClick:()=>this.updateAll(!0,!0),children:e.jsx(u.Refresh,{})})}),this.state.tableViewMode&&!this.state.oneListView&&e.jsx(o.Tooltip,{title:this.t("expand all"),slotProps:{popper:{sx:b.tooltip}},children:e.jsx(o.IconButton,{size:"large",onClick:()=>this.expandAll(),children:e.jsx(u.FolderOpen,{})})}),this.state.tableViewMode&&!this.state.oneListView&&e.jsx(o.Tooltip,{title:this.t("collapse all"),slotProps:{popper:{sx:b.tooltip}},children:e.jsx(o.IconButton,{size:"large",onClick:()=>this.collapseAll(),children:e.jsx(u.Folder,{})})}),this.state.tableViewMode&&e.jsx(o.Tooltip,{title:this.t("list"),slotProps:{popper:{sx:b.tooltip}},children:e.jsx(o.IconButton,{size:"large",onClick:()=>this.listTable(),children:e.jsx(u.List,{color:this.state.oneListView?"primary":"inherit"})})}),this.state.updateList?e.jsx(o.IconButton,{size:"large",onClick:()=>this.changeInstalledList(!0),children:e.jsx(u.Star,{color:"primary",style:{opacity:.3,color:this.state.installedList===2?"red":void 0}})}):e.jsx(o.Tooltip,{slotProps:{popper:{sx:b.tooltip}},title:this.t(this.state.installedList?this.state.installedList===1?"Showed only installed adapters":"Showed only installed adapters without instance.":"Show only installed"),children:e.jsx(o.IconButton,{size:"large",onClick:()=>this.changeInstalledList(),children:e.jsx(u.Star,{style:this.state.installedList===2?{color:"red"}:null,color:this.state.installedList===1?"primary":"inherit"})})}),e.jsx(N,{config:this.props.adminGuiConfig.admin,name:"admin.adapters.filterUpdates",children:e.jsx(o.Tooltip,{title:this.t("Filter adapter with updates"),slotProps:{popper:{sx:b.tooltip}},children:e.jsx(o.IconButton,{size:"large",onClick:()=>this.changeUpdateList(),children:e.jsx(u.Update,{color:this.state.updateList?"primary":"inherit"})})})}),t&&e.jsx(o.Tooltip,{title:this.t("Update all adapters"),slotProps:{popper:{sx:b.tooltip}},children:e.jsxs(o.IconButton,{size:"large",onClick:()=>this.setState({showUpdater:!0}),sx:b.updateAllButton,children:[e.jsx(u.Update,{}),e.jsx(u.Update,{className:"admin-update-second-icon"})]})}),this.props.expertMode&&((s=this.props.adminGuiConfig.admin)==null?void 0:s.adapters.gitHubInstall)!==!1&&e.jsx(o.Tooltip,{title:this.t("Install from custom URL"),slotProps:{popper:{sx:b.tooltip}},children:e.jsx(o.IconButton,{size:"large",onClick:()=>this.setState({gitHubInstallDialog:!0}),children:e.jsx(ct,{})})}),e.jsx("div",{style:b.grow}),e.jsx(o.TextField,{variant:"standard",inputRef:this.inputRef,label:this.t("Filter by name"),defaultValue:this.state.search,onChange:i=>this.handleFilterChange(i),slotProps:{input:{endAdornment:this.state.search?e.jsx(o.InputAdornment,{position:"end",children:e.jsx(o.IconButton,{tabIndex:-1,size:"small",onClick:()=>{(window._localStorage||window.localStorage).removeItem("Adapter.search"),this.inputRef.current.value="",this.setState({search:""},()=>this.filterAdapters())},children:e.jsx(u.Close,{})})}):null}}}),!this.state.tableViewMode&&e.jsx(it,{t:this.t,icons:!0,contained:this.state.categoriesTiles!=="All",translateSuffix:"_group",arrayItem:[{name:"All"},...this.state.categories],onClick:i=>this.changeCategoriesTiles(i),value:this.state.categoriesTiles}),e.jsx(it,{t:this.t,arrayItem:this.state.tableViewMode?lt.filter(i=>!i.notByList):lt,onClick:i=>this.changeFilterTiles(i),value:this.state.filterTiles}),e.jsx("div",{style:b.grow}),e.jsx(N,{config:this.props.adminGuiConfig.admin,name:"admin.adapters.statistics",children:e.jsxs(o.Box,{component:"div",sx:R.getStyle(this.props.theme,b.infoAdapters,{display:{sm:"none",md:"inline-block"}}),onClick:()=>this.setState({showStatistics:!0}),children:[e.jsxs(o.Box,{component:"div",sx:{...b.counters,...b.greenText},children:[this.t("Selected adapters"),e.jsx("div",{ref:this.countRef})]}),e.jsxs(o.Box,{component:"div",sx:b.counters,children:[this.t("Total adapters"),":",e.jsx("div",{children:this.allAdapters})]}),e.jsxs(o.Box,{component:"div",sx:b.counters,children:[this.t("Installed adapters"),":",e.jsx("div",{children:this.installedAdapters})]}),e.jsxs(o.Box,{component:"div",sx:b.counters,children:[this.t("Last month updated adapters"),":",e.jsx("div",{children:this.recentUpdatedAdapters})]})]})})]})}renderWebserverUpgrade(){return this.state.adminUpgradeTo?e.jsx(zt,{socket:this.props.socket,themeType:this.props.themeType,host:this.props.adminHost,onClose:()=>{console.log("Close dialog"),this.setState({adminUpgradeTo:"",showDialog:!1})},version:this.state.adminUpgradeTo,adminInstance:this.props.adminInstance,onUpdating:t=>{this.props.onUpdating(t)},currentAdminVersion:this.props.currentAdminVersion}):null}render(){var n,a,c,h,d,l,g;if(!this.state.init)return e.jsx(o.LinearProgress,{});this.state.triggerUpdate!==this.props.triggerUpdate&&setTimeout(()=>{this.setState({triggerUpdate:this.props.triggerUpdate},()=>this.updateAll(!0))},100),(this.props.currentHost!==this.state.currentHost||this.props.forceUpdateAdapters!==this.state.forceUpdateAdapters)&&(this.hostsTimer=this.hostsTimer||setTimeout(()=>{this.hostsTimer=null,this.setState({currentHost:this.props.currentHost,forceUpdateAdapters:this.props.forceUpdateAdapters},async()=>{this.hostAdapterWorker.getHost()!==this.props.currentHost&&(this.hostAdapterWorker.destroy(),this.hostAdapterWorker=new ot(this.props.socket,this.props.currentHost),this.hostAdapterWorker.registerHandler(this.onHostAdapterChanged),await this.hostAdapterWorker.getObjects()),await this.updateAll(!1,!1,!0)})},200));let t=R.isStableRepository(this.props.systemConfig.common.activeRepo);const s=(a=(n=this.state.compactRepositories)==null?void 0:n.native)==null?void 0:a.repositories;s&&this.props.systemConfig.common.activeRepo&&(Array.isArray(this.props.systemConfig.common.activeRepo)?t=this.props.systemConfig.common.activeRepo.every(x=>{var m,v,j;return x.toLowerCase().startsWith("stable")||((j=(v=(m=s[x])==null?void 0:m.json)==null?void 0:v._repoInfo)==null?void 0:j.stable)}):typeof this.props.systemConfig.common.activeRepo=="string"&&(t=this.props.systemConfig.common.activeRepo.toLowerCase().startsWith("stable")||((d=(h=(c=s[this.props.systemConfig.common.activeRepo])==null?void 0:c.json)==null?void 0:h._repoInfo)==null?void 0:d.stable)));let i;if(!t)if(i=Array.isArray(this.props.systemConfig.common.activeRepo)?this.props.systemConfig.common.activeRepo.join(", "):this.props.systemConfig.common.activeRepo,typeof this.props.systemConfig.common.activeRepo=="string"){const x=s&&((g=(l=s[this.props.systemConfig.common.activeRepo])==null?void 0:l.json)==null?void 0:g._repoInfo);x!=null&&x.name&&(x.name&&typeof x.name=="object"?i=x.name[this.props.lang]||x.name.en:i=x.name)}else this.props.systemConfig.common.activeRepo&&typeof this.props.systemConfig.common.activeRepo!="string"&&(i=this.props.systemConfig.common.activeRepo.map(x=>{var v,j;const m=s&&((j=(v=s[x])==null?void 0:v.json)==null?void 0:j._repoInfo);return m!=null&&m.name?m.name&&typeof m.name=="object"?m.name[this.props.lang]||m.name.en:m.name:x}).join(", "));const r=this.getContext(this.state.descWidth<50);return this.cache.listOfVisibleAdapter||(this.buildCacheTimer=this.buildCacheTimer||setTimeout(()=>{this.buildCacheTimer=null,this.buildCache(r)},0)),e.jsxs(Tt,{children:[this.state.update&&e.jsx(o.Grid2,{children:e.jsx(o.LinearProgress,{})}),this.renderHeader(),e.jsx(Gt,{stableRepo:t,repoName:i,context:r,noTranslation:this.props.noTranslation,systemConfig:this.props.systemConfig,tableViewMode:this.state.tableViewMode,oneListView:this.state.oneListView,update:this.state.update,updateListFilter:this.state.updateList,searchFilter:this.state.search,installedListFilter:this.state.installedList,cachedAdapters:this.cache.adapters,categories:this.state.categories,categoriesExpanded:this.state.categoriesExpanded,listOfVisibleAdapter:this.cache.listOfVisibleAdapter,toggleCategory:x=>this.toggleCategory(x),clearAllFilters:x=>this.clearAllFilters(x),descWidth:this.state.descWidth,sortByName:this.state.filterTiles==="Name A-Z",sortPopularFirst:r.sortPopularFirst,sortRecentlyUpdated:r.sortRecentlyUpdated,commandRunning:this.props.commandRunning}),this.getUpdater(),this.getStatistics(),this.renderSlowConnectionWarning(),this.renderGitHubInstallDialog(r),this.renderWebserverUpgrade(),this.renderDialogs(r)]})}}export{k as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as s,H as te,F as Te,J as U,E as K}from"./DefaultPropsProvider-u5xB1Fxz.js";import{i as L}from"./iobroker_admin__loadShare__react__loadShare__-Bis6NHgw.js";import{i as a,I as v,b as $,a as c,J as ye,U as H,af as Q,f as Ie,ag as Ce,D as $e}from"./bootstrap-BYQTdf9r.js";import"./iobroker_admin__mf_v__runtimeInit__mf_v__-CTkuGOOk.js";var I={},A={},E={},M={};Object.defineProperty(M,"__esModule",{value:!0});M.ErrorCodes=void 0;var se;(function(n){n[n.E_INSTANCE_ACTION_NOT_INITIALIZED=101]="E_INSTANCE_ACTION_NOT_INITIALIZED",n[n.E_INSTANCE_ACTION_UNKNOWN=102]="E_INSTANCE_ACTION_UNKNOWN",n[n.E_INSTANCE_ACTION_NO_HANDLER=103]="E_INSTANCE_ACTION_NO_HANDLER",n[n.E_DEVICE_ACTION_NOT_INITIALIZED=201]="E_DEVICE_ACTION_NOT_INITIALIZED",n[n.E_DEVICE_ACTION_DEVICE_UNKNOWN=202]="E_DEVICE_ACTION_DEVICE_UNKNOWN",n[n.E_DEVICE_ACTION_UNKNOWN=203]="E_DEVICE_ACTION_UNKNOWN",n[n.E_DEVICE_ACTION_NO_HANDLER=204]="E_DEVICE_ACTION_NO_HANDLER",n[n.E_DEVICE_CONTROL_NOT_INITIALIZED=301]="E_DEVICE_CONTROL_NOT_INITIALIZED",n[n.E_DEVICE_CONTROL_DEVICE_UNKNOWN=302]="E_DEVICE_CONTROL_DEVICE_UNKNOWN",n[n.E_DEVICE_CONTROL_UNKNOWN=303]="E_DEVICE_CONTROL_UNKNOWN",n[n.E_DEVICE_CONTROL_NO_HANDLER=304]="E_DEVICE_CONTROL_NO_HANDLER",n[n.E_DEVICE_GET_STATE_NOT_INITIALIZED=401]="E_DEVICE_GET_STATE_NOT_INITIALIZED",n[n.E_DEVICE_GET_STATE_DEVICE_UNKNOWN=402]="E_DEVICE_GET_STATE_DEVICE_UNKNOWN",n[n.E_DEVICE_GET_STATE_UNKNOWN=403]="E_DEVICE_GET_STATE_UNKNOWN",n[n.E_DEVICE_GET_STATE_NO_HANDLER=404]="E_DEVICE_GET_STATE_NO_HANDLER"})(se||(M.ErrorCodes=se={}));var R={};Object.defineProperty(R,"__esModule",{value:!0});R.ACTIONS=void 0;R.ACTIONS={STATUS:"status",ENABLE_DISABLE:"enable/disable"};(function(n){var e=E&&E.__createBinding||(Object.create?function(r,i,l,d){d===void 0&&(d=l);var h=Object.getOwnPropertyDescriptor(i,l);(!h||("get"in h?!i.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return i[l]}}),Object.defineProperty(r,d,h)}:function(r,i,l,d){d===void 0&&(d=l),r[d]=i[l]}),t=E&&E.__exportStar||function(r,i){for(var l in r)l!=="default"&&!Object.prototype.hasOwnProperty.call(i,l)&&e(i,r,l)};Object.defineProperty(n,"__esModule",{value:!0}),n.ACTIONS=void 0,t(M,n);var o=R;Object.defineProperty(n,"ACTIONS",{enumerable:!0,get:function(){return o.ACTIONS}})})(E);Object.defineProperty(A,"__esModule",{value:!0});A.MessageContext=A.DeviceManagement=void 0;const g=E;class we{constructor(e){this.adapter=e,this.contexts=new Map,e.on("message",this.onMessage.bind(this))}get log(){return this.adapter.log}getInstanceInfo(){return{apiVersion:"v1"}}getDeviceDetails(e){return{id:e,schema:{}}}handleInstanceAction(e,t,o){var r;if(!this.instanceInfo)return this.log.warn(`Instance action ${e} was called before getInstanceInfo()`),{error:{code:g.ErrorCodes.E_INSTANCE_ACTION_NOT_INITIALIZED,message:`Instance action ${e} was called before getInstanceInfo()`}};const i=(r=this.instanceInfo.actions)===null||r===void 0?void 0:r.find(l=>l.id===e);return i?i.handler?i.handler(t,o):(this.log.warn(`Instance action ${e} is disabled because it has no handler`),{error:{code:g.ErrorCodes.E_INSTANCE_ACTION_NO_HANDLER,message:`Instance action ${e} is disabled because it has no handler`}}):(this.log.warn(`Instance action ${e} is unknown`),{error:{code:g.ErrorCodes.E_INSTANCE_ACTION_UNKNOWN,message:`Instance action ${e} is unknown`}})}handleDeviceAction(e,t,o,r){var i;if(!this.devices)return this.log.warn(`Device action ${t} was called before listDevices()`),{error:{code:g.ErrorCodes.E_DEVICE_ACTION_NOT_INITIALIZED,message:`Device action ${t} was called before listDevices()`}};const l=this.devices.get(e);if(!l)return this.log.warn(`Device action ${t} was called on unknown device: ${e}`),{error:{code:g.ErrorCodes.E_DEVICE_ACTION_DEVICE_UNKNOWN,message:`Device action ${t} was called on unknown device: ${e}`}};const d=(i=l.actions)===null||i===void 0?void 0:i.find(h=>h.id===t);return d?d.handler?d.handler(e,o,r):(this.log.warn(`Device action ${t} on ${e} is disabled because it has no handler`),{error:{code:g.ErrorCodes.E_DEVICE_ACTION_NO_HANDLER,message:`Device action ${t} on ${e} is disabled because it has no handler`}}):(this.log.warn(`Device action ${t} doesn't exist on device ${e}`),{error:{code:g.ErrorCodes.E_DEVICE_ACTION_UNKNOWN,message:`Device action ${t} doesn't exist on device ${e}`}})}handleDeviceControl(e,t,o,r){var i;if(!this.devices)return this.log.warn(`Device control ${t} was called before listDevices()`),{error:{code:g.ErrorCodes.E_DEVICE_CONTROL_NOT_INITIALIZED,message:`Device control ${t} was called before listDevices()`}};const l=this.devices.get(e);if(!l)return this.log.warn(`Device control ${t} was called on unknown device: ${e}`),{error:{code:g.ErrorCodes.E_DEVICE_CONTROL_DEVICE_UNKNOWN,message:`Device control ${t} was called on unknown device: ${e}`}};const d=(i=l.controls)===null||i===void 0?void 0:i.find(h=>h.id===t);return d?d.handler?d.handler(e,t,o,r):(this.log.warn(`Device control ${t} on ${e} is disabled because it has no handler`),{error:{code:g.ErrorCodes.E_DEVICE_CONTROL_NO_HANDLER,message:`Device control ${t} on ${e} is disabled because it has no handler`}}):(this.log.warn(`Device control ${t} doesn't exist on device ${e}`),{error:{code:g.ErrorCodes.E_DEVICE_CONTROL_UNKNOWN,message:`Device control ${t} doesn't exist on device ${e}`}})}handleDeviceControlState(e,t,o){var r;if(!this.devices)return this.log.warn(`Device get state ${t} was called before listDevices()`),{error:{code:g.ErrorCodes.E_DEVICE_GET_STATE_NOT_INITIALIZED,message:`Device control ${t} was called before listDevices()`}};const i=this.devices.get(e);if(!i)return this.log.warn(`Device get state ${t} was called on unknown device: ${e}`),{error:{code:g.ErrorCodes.E_DEVICE_GET_STATE_DEVICE_UNKNOWN,message:`Device control ${t} was called on unknown device: ${e}`}};const l=(r=i.controls)===null||r===void 0?void 0:r.find(d=>d.id===t);return l?l.getStateHandler?l.getStateHandler(e,t,o):(this.log.warn(`Device get state ${t} on ${e} is disabled because it has no handler`),{error:{code:g.ErrorCodes.E_DEVICE_GET_STATE_NO_HANDLER,message:`Device get state ${t} on ${e} is disabled because it has no handler`}}):(this.log.warn(`Device get state ${t} doesn't exist on device ${e}`),{error:{code:g.ErrorCodes.E_DEVICE_GET_STATE_UNKNOWN,message:`Device control ${t} doesn't exist on device ${e}`}})}onMessage(e){e.command.startsWith("dm:")&&this.handleMessage(e).catch(this.log.error)}async handleMessage(e){switch(this.log.debug(`DeviceManagement received: ${JSON.stringify(e)}`),e.command){case"dm:instanceInfo":{this.instanceInfo=await this.getInstanceInfo(),this.sendReply(Object.assign(Object.assign({},this.instanceInfo),{actions:this.convertActions(this.instanceInfo.actions)}),e);return}case"dm:listDevices":{const t=await this.listDevices();this.devices=t.reduce((r,i)=>{if(r.has(i.id))throw new Error(`Device ID ${i.id} is not unique`);return r.set(i.id,i),r},new Map);const o=t.map(r=>Object.assign(Object.assign({},r),{actions:this.convertActions(r.actions),controls:this.convertControls(r.controls)}));this.sendReply(o,e),this.adapter.sendTo(e.from,e.command,this.devices,e.callback);return}case"dm:deviceDetails":{const t=await this.getDeviceDetails(e.message);this.adapter.sendTo(e.from,e.command,t,e.callback);return}case"dm:instanceAction":{const t=e.message,o=new P(e,this.adapter);this.contexts.set(e._id,o);const r=await this.handleInstanceAction(t.actionId,o,{value:t.value});this.contexts.delete(e._id),o.sendFinalResult(r);return}case"dm:deviceAction":{const t=e.message,o=new P(e,this.adapter);this.contexts.set(e._id,o);const r=await this.handleDeviceAction(t.deviceId,t.actionId,o,{value:t.value});this.contexts.delete(e._id),o.sendFinalResult(r);return}case"dm:deviceControl":{const t=e.message,o=new P(e,this.adapter);this.contexts.set(e._id,o);const r=await this.handleDeviceControl(t.deviceId,t.controlId,t.state,o);this.contexts.delete(e._id),o.sendControlResult(t.deviceId,t.controlId,r);return}case"dm:deviceControlState":{const t=e.message,o=new P(e,this.adapter);this.contexts.set(e._id,o);const r=await this.handleDeviceControlState(t.deviceId,t.controlId,o);this.contexts.delete(e._id),o.sendControlResult(t.deviceId,t.controlId,r);return}case"dm:actionProgress":{const{origin:t}=e.message,o=this.contexts.get(t);if(!o){this.log.warn(`Unknown message origin: ${t}`),this.sendReply({error:"Unknown action origin"},e);return}o.handleProgress(e);return}}}convertActions(e){if(!e)return;const t=new Set;return e.forEach(o=>{if(t.has(o.id))throw new Error(`Action ID ${o.id} is used twice, this would lead to unexpected behavior`);t.add(o.id)}),e.map(o=>Object.assign(Object.assign({},o),{handler:void 0,disabled:!o.handler}))}convertControls(e){if(!e)return;const t=new Set;return e.forEach(o=>{if(t.has(o.id))throw new Error(`Control ID ${o.id} is used twice, this would lead to unexpected behavior`);t.add(o.id)}),e.map(o=>Object.assign(Object.assign({},o),{handler:void 0,getStateHandler:void 0}))}sendReply(e,t){this.adapter.sendTo(t.from,t.command,e,t.callback)}}A.DeviceManagement=we;class P{constructor(e,t){this.adapter=t,this.hasOpenProgressDialog=!1,this.lastMessage=e}showMessage(e){this.checkPreconditions();const t=new Promise(o=>{this.progressHandler=()=>o()});return this.send("message",{message:e}),t}showConfirmation(e){this.checkPreconditions();const t=new Promise(o=>{this.progressHandler=r=>o(!!r.confirm)});return this.send("confirm",{confirm:e}),t}showForm(e,t){this.checkPreconditions();const o=new Promise(r=>{this.progressHandler=i=>r(i.data)});return this.send("form",{form:Object.assign({schema:e},t)}),o}openProgress(e,t){this.checkPreconditions(),this.hasOpenProgressDialog=!0;const o={update:i=>{const l=new Promise(d=>{this.progressHandler=()=>d()});return this.send("progress",{progress:Object.assign(Object.assign(Object.assign({title:e},t),i),{open:!0})},!0),l},close:()=>{const i=new Promise(l=>{this.progressHandler=()=>{this.hasOpenProgressDialog=!1,l()}});return this.send("progress",{progress:{open:!1}}),i}},r=new Promise(i=>{this.progressHandler=()=>i(o)});return this.send("progress",{progress:Object.assign(Object.assign({title:e},t),{open:!0})},!0),r}sendFinalResult(e){this.send("result",{result:e})}sendControlResult(e,t,o){typeof o=="object"&&"error"in o?this.send("result",{result:{error:o.error,deviceId:e,controlId:t}}):this.send("result",{result:{state:o,deviceId:e,controlId:t}})}handleProgress(e){const t=this.progressHandler;t&&typeof e.message!="string"&&(this.lastMessage=e,this.progressHandler=void 0,t(e.message))}checkPreconditions(){if(this.hasOpenProgressDialog)throw new Error("Can't show another dialog while a progress dialog is open. Please call 'close()' on the dialog before opening another dialog.")}send(e,t,o){if(!this.lastMessage)throw new Error("No outstanding message, can't send a new one");this.adapter.sendTo(this.lastMessage.from,this.lastMessage.command,Object.assign(Object.assign({},t),{type:e,origin:this.lastMessage.message.origin||this.lastMessage._id}),this.lastMessage.callback),o||(this.lastMessage=void 0)}}A.MessageContext=P;(function(n){var e=I&&I.__createBinding||(Object.create?function(o,r,i,l){l===void 0&&(l=i);var d=Object.getOwnPropertyDescriptor(r,i);(!d||("get"in d?!r.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return r[i]}}),Object.defineProperty(o,l,d)}:function(o,r,i,l){l===void 0&&(l=i),o[l]=r[i]}),t=I&&I.__exportStar||function(o,r){for(var i in o)i!=="default"&&!Object.prototype.hasOwnProperty.call(r,i)&&e(r,o,i)};Object.defineProperty(n,"__esModule",{value:!0}),t(A,n),t(E,n)})(I);function pe(n){const{tooltip:e,label:t,disabled:o,Icon:r,onClick:i}=n,l=!!t&&s.jsx(a.Typography,{variant:"button",style:{marginLeft:4},children:t});return e?s.jsx(a.Tooltip,{title:e,slotProps:{popper:{sx:{pointerEvents:"none"}}},children:s.jsx("span",{children:s.jsxs(a.IconButton,{onClick:i,disabled:o,size:"small",children:[r,l]})})}):s.jsxs(a.IconButton,{onClick:i,disabled:o,size:"small",children:[r,l]})}function he(n,e){const t=n.split(" ").map(o=>o.trim()).filter(o=>o!=="fa-solid");return t.includes("fa-trash-can")||t.includes("fa-trash")?s.jsx(c.Delete,{style:{color:e}}):t.includes("fa-pen")?s.jsx(c.Edit,{style:{color:e}}):t.includes("fa-redo-alt")?s.jsx(c.Refresh,{style:{color:e}}):t.includes("fa-plus")?s.jsx(c.Add,{style:{color:e}}):t.includes("fa-qrcode")||t.includes("qrcode")?s.jsx(c.QrCode,{style:{color:e}}):t.includes("fa-wifi")?s.jsx(c.Wifi,{style:{color:e}}):t.includes("fa-wifi-slash")?s.jsx(c.WifiOff,{style:{color:e}}):t.includes("fa-bluetooth")?s.jsx(c.Bluetooth,{style:{color:e}}):t.includes("fa-bluetooth-slash")?s.jsx(c.BluetoothDisabled,{style:{color:e}}):t.includes("fa-eye")?s.jsx(c.Visibility,{style:{color:e}}):t.includes("fa-search")?s.jsx(c.Search,{style:{color:e}}):t.includes("fa-unlink")?s.jsx(c.LinkOff,{style:{color:e}}):t.includes("fa-link")?s.jsx(c.Link,{style:{color:e}}):t.includes("fa-search-location")?s.jsx(c.NotListedLocation,{style:{color:e}}):t.includes("fa-play")?s.jsx(c.PlayArrow,{style:{color:e}}):t.includes("fa-stop")?s.jsx(c.Stop,{style:{color:e}}):t.includes("fa-pause")?s.jsx(c.Pause,{style:{color:e}}):s.jsx(c.QuestionMark,{style:{color:e}})}function ue(n,e,t){return n==="edit"||n==="rename"||e==="edit"||e==="rename"?s.jsx(c.Edit,{style:{color:t}}):n==="delete"||e==="delete"?s.jsx(c.Delete,{style:{color:t}}):n==="refresh"||e==="refresh"?s.jsx(c.Refresh,{style:{color:t}}):n==="newDevice"||n==="new"||n==="add"||e==="newDevice"||e==="new"||e==="add"?s.jsx(c.Add,{style:{color:t}}):n==="discover"||n==="search"||e==="discover"||e==="search"?s.jsx(c.Search,{style:{color:t}}):n==="unpairDevice"||n==="unpair"||e==="unpairDevice"||e==="unpair"?s.jsx(c.LinkOff,{style:{color:t}}):n==="pairDevice"||n==="pair"||e==="pairDevice"||e==="pair"?s.jsx(c.Link,{style:{color:t}}):n==="identify"||e==="identify"?s.jsx(c.NotListedLocation,{style:{color:t}}):n==="play"||e==="play"?s.jsx(c.PlayArrow,{style:{color:t}}):n==="stop"||e==="stop"?s.jsx(c.Stop,{style:{color:t}}):n==="pause"||e==="pause"?s.jsx(c.Pause,{style:{color:t}}):n==="forward"||n==="next"||e==="forward"||e==="next"?s.jsx(c.FastForward,{style:{color:t}}):n==="rewind"||n==="previous"||e==="rewind"||e==="previous"?s.jsx(c.FastRewind,{style:{color:t}}):n==="lamp"||n==="light"||e==="lamp"||e==="light"?s.jsx(c.Lightbulb,{style:{color:t}}):n==="backlight"||e==="backlight"?s.jsx(c.Fluorescent,{style:{color:t}}):n==="dimmer"||e==="dimmer"?s.jsx(c.WbIncandescent,{style:{color:t}}):n==="socket"||e==="socket"?s.jsx(c.Power,{style:{color:t}}):n==="settings"||e==="settings"?s.jsx(c.Settings,{style:{color:t}}):n==="users"||n==="group"||e==="users"||e==="group"?s.jsx(c.Group,{style:{color:t}}):n==="user"||e==="user"?s.jsx(c.Person,{style:{color:t}}):n==="qrcode"||e==="qrcode"?s.jsx(c.QrCode,{style:{color:t}}):n==="info"||e==="info"?s.jsx(c.Info,{style:{color:t}}):n==="lines"||e==="lines"?s.jsx(c.Article,{style:{color:t}}):s.jsx(c.QuestionMark,{style:{color:t}})}function oe(n,e,t){var r,i,l,d;if(!n)return null;let o=t&&n.colorOn||n.color||(n.state?"primary":"inherit");return e&&(o==="primary"?o=e.primary:o==="secondary"&&(o=e.secondary)),(r=n.icon)!=null&&r.startsWith("fa-")||(i=n.icon)!=null&&i.startsWith("fas")?he(n.icon,o):t&&((l=n.iconOn)!=null&&l.startsWith("data:image"))?s.jsx($,{src:n.iconOn,style:{color:o}}):(d=n.icon)!=null&&d.startsWith("data:image")?s.jsx($,{src:n.icon,style:{color:o}}):ue(n.id,n.icon,o)}function fe(n){var e,t,o;return n?(e=n.icon)!=null&&e.startsWith("fa-")||(t=n.icon)!=null&&t.startsWith("fas")?he(n.icon,n.color):(o=n.icon)!=null&&o.startsWith("data:image")?s.jsx($,{src:n.icon,style:{color:n.color}}):ue(n.id,n.icon,n.color):null}let G;function p(n,e){return G=G||v.getLanguage(),typeof n=="object"?n[G]||n.en:e?n:v.t(n)}function je(n){const{deviceId:e,action:t,refresh:o,deviceHandler:r,disabled:i}=n,l=fe(t),d=p(t.description??"")||(l?null:t.id);return s.jsx(pe,{tooltip:d||void 0,disabled:i||t.disabled,Icon:l,onClick:r(e,t,o)})}class ne extends L.Component{constructor(e){var t,o;super(e),this.state={value:(t=e.control.state)==null?void 0:t.val,ts:(o=e.control.state)==null?void 0:o.ts,unit:e.control.unit||""}}async componentDidMount(){var e;if(this.props.control.stateId){const t=this.props.socket.subscribeState(this.props.control.stateId,this.stateHandler);if(t instanceof Promise&&await t,this.props.control.type==="slider"||this.props.control.type==="number")if(this.props.control.min===void 0&&this.props.control.max===void 0)this.props.socket.getObject(this.props.control.stateId).then(o=>{if(o!=null&&o.common){let r=this.props.control.min;r===void 0&&(r=o.common.min),r===void 0&&(r=0);let i=this.props.control.max;i===void 0&&(r=o.common.max),r===void 0&&(i=100);let l=this.props.control.step;l===void 0&&(l=o.common.step),l===void 0&&(l=(i-r)/100);let d=this.props.control.unit;d===void 0&&(d=o.common.unit),this.setState({min:r,max:i,step:l,unit:d})}});else{const o=this.props.control.min===void 0?0:this.props.control.min,r=this.props.control.max===void 0?100:this.props.control.max;this.setState({min:o,max:r,step:this.props.control.step===void 0?(r-o)/100:this.props.control.step,unit:this.props.control.unit||""})}else this.props.control.type==="select"?(e=this.props.control.options)!=null&&e.length?this.setState({options:this.props.control.options.map(o=>({label:p(o.label),value:o.value,icon:o.icon,color:o.color}))}):this.props.socket.getObject(this.props.control.stateId).then(o=>{var r;if((r=o==null?void 0:o.common)!=null&&r.states){let i;typeof o.common.states=="string"?i=o.common.states.split(";").map(d=>{const h=d.split(":");return{value:h[0],label:h[1]}}):Array.isArray(o.common.states)?i=o.common.states.map(l=>({label:l,value:l})):i=Object.keys(o.common.states).map(l=>({label:l,value:o.common.states[l]})),this.setState({options:i})}}):this.props.control.type==="info"&&(this.props.control.unit||this.props.socket.getObject(this.props.control.stateId).then(o=>{var r;(r=o==null?void 0:o.common)!=null&&r.unit&&this.setState({unit:o.common.unit})}))}}stateHandler=async(e,t)=>{if(e===this.props.control.stateId&&t){const o=await this.props.controlStateHandler(this.props.deviceId,this.props.control)();o!=null&&o.ts&&(!this.state.ts||o.ts>this.state.ts)&&this.setState({value:o.val,ts:o.ts})}};componentWillUnmount(){this.props.control.stateId&&this.props.socket.unsubscribeState(this.props.control.stateId,this.stateHandler)}static getDerivedStateFromProps(e,t){var o,r;return(o=e.control.state)!=null&&o.ts&&(!t.ts||((r=e.control.state)==null?void 0:r.ts)>t.ts)?{value:e.control.state.val,ts:e.control.state.ts}:null}async sendControl(e,t,o){const r=await this.props.controlHandler(e,t,o)();r!=null&&r.ts&&(!this.state.ts||(r==null?void 0:r.ts)>this.state.ts)&&this.setState({value:r.val,ts:r.ts})}renderButton(){const e=p(this.props.control.description??""),t=oe(this.props.control,this.props.colors,this.state.value);return this.props.control.label?s.jsx(a.Button,{disabled:this.props.disabled,title:e,onClick:()=>this.sendControl(this.props.deviceId,this.props.control,!0),startIcon:t,children:p(this.props.control.label)}):s.jsx(a.Fab,{size:"small",disabled:this.props.disabled,title:e,onClick:()=>this.sendControl(this.props.deviceId,this.props.control,!0),children:t})}renderSwitch(){const e=p(this.props.control.description??"");return s.jsx(a.Switch,{disabled:this.props.disabled,title:e,checked:!!this.state.value,onChange:t=>this.sendControl(this.props.deviceId,this.props.control,t.target.checked)})}getColor(){let e;return this.state.value?e=this.props.control.colorOn||"primary":this.props.control.type==="switch"&&(e=this.props.control.color),e==="primary"?this.props.colors.primary:e==="secondary"?this.props.colors.secondary:e}renderSelect(){var t,o;const e=(t=this.state.options)==null?void 0:t.some(r=>!!r.icon);return s.jsxs(a.FormControl,{fullWidth:!0,variant:"standard",children:[this.props.control.label?s.jsx(a.InputLabel,{children:p(this.props.control.label)}):null,s.jsx(a.Select,{variant:"standard",value:this.state.value,onChange:r=>this.sendControl(this.props.deviceId,this.props.control,r.target.value),children:(o=this.state.options)==null?void 0:o.map((r,i)=>s.jsxs(a.MenuItem,{value:typeof r.value=="boolean"?r.value.toString():r.value,style:{color:r.color},children:[e?s.jsx($,{src:r.icon,style:{width:24,height:24}}):null,r.label]},i.toString()))})]})}renderSlider(){return this.state.min===void 0||this.state.max===void 0?s.jsx("div",{style:{width:"100%"},children:"..."}):s.jsxs(a.Stack,{spacing:2,direction:"row",sx:{alignItems:"center",mb:1,width:"100%"},children:[this.props.control.label?s.jsx(a.InputLabel,{style:{color:this.props.control.color},children:p(this.props.control.label)}):null,this.props.control.icon?s.jsx($,{style:{color:this.props.control.color},src:this.props.control.icon}):null,s.jsx(a.Slider,{value:parseFloat(this.state.value||"0"),min:this.state.min,max:this.state.max,step:this.state.step,valueLabelDisplay:"auto",onChange:(e,t)=>this.sendControl(this.props.deviceId,this.props.control,t)}),this.props.control.iconOn?s.jsx($,{style:{color:this.props.control.colorOn},src:this.props.control.iconOn}):null,this.props.control.labelOn?s.jsx(a.InputLabel,{style:{color:this.props.control.colorOn},children:p(this.props.control.labelOn)}):null]})}renderColor(){return s.jsx(a.TextField,{fullWidth:!0,label:this.props.control.label?p(this.props.control.label):void 0,type:"color",value:this.state.value,onChange:e=>this.sendControl(this.props.deviceId,this.props.control,e.target.value),variant:"standard"})}renderText(){return s.jsx(a.TextField,{fullWidth:!0,label:this.props.control.label?p(this.props.control.label):void 0,value:this.state.value,onChange:e=>this.sendControl(this.props.deviceId,this.props.control,e.target.value),variant:"standard"})}renderNumber(){return s.jsx(a.TextField,{fullWidth:!0,type:"number",label:this.props.control.label?p(this.props.control.label):void 0,value:this.state.value,onChange:e=>isNaN(parseFloat(e.target.value))?Promise.resolve():this.sendControl(this.props.deviceId,this.props.control,parseFloat(e.target.value)),slotProps:{htmlInput:{min:this.state.min,max:this.state.max,step:this.state.step},input:{endAdornment:this.state.unit?s.jsx(a.InputAdornment,{position:"end",children:this.state.unit}):void 0}},variant:"standard"})}renderIcon(){const e=p(this.props.control.description??""),t=oe(this.props.control,this.props.colors,this.state.value),o=this.getColor(),r=o===this.props.colors.primary||o===this.props.colors.secondary?{}:{color:o},i=o===this.props.colors.primary?"primary":o===this.props.colors.secondary?"secondary":void 0;return this.props.control.label?s.jsx(a.Button,{disabled:this.props.disabled,title:e,color:i,style:r,onClick:()=>this.sendControl(this.props.deviceId,this.props.control,!this.state.value),startIcon:t,children:p(this.props.control.label)}):(r.width=34,r.height=34,r.minHeight=34,s.jsx(a.Fab,{disabled:this.props.disabled,size:"small",title:e,color:i,style:r,onClick:()=>this.sendControl(this.props.deviceId,this.props.control,!this.state.value),children:t}))}renderInfo(){return s.jsxs("div",{children:[this.props.control.label?s.jsx(a.InputLabel,{children:p(this.props.control.label)}):null,s.jsxs("span",{children:[this.state.value,s.jsx("span",{style:{fontSize:"smaller",opacity:.7,marginLeft:this.state.unit?4:0},children:this.state.unit})]})]})}render(){return this.props.control.type==="button"?this.renderButton():this.props.control.type==="icon"?this.renderIcon():this.props.control.type==="switch"?this.renderSwitch():this.props.control.type==="select"?this.renderSelect():this.props.control.type==="slider"?this.renderSlider():this.props.control.type==="color"?this.renderColor():this.props.control.type==="text"?this.renderText():this.props.control.type==="number"?this.renderNumber():this.props.control.type==="info"?this.renderInfo():s.jsx("div",{style:{color:"red"},children:this.props.control.type})}}const ie=34,N=20,re=30,V=15;class Se extends L.Component{render(){const e=s.jsxs("div",{style:{width:this.props.size==="small"?re:ie,height:N,display:"flex",alignItems:"center",cursor:"pointer",position:"relative",opacity:this.props.disabled?.7:1},onClick:t=>{this.props.disabled||(t.stopPropagation(),t.preventDefault(),this.props.onChange(!this.props.checked))},children:[s.jsx("div",{style:{borderRadius:15,width:"100%",height:(this.props.size==="small"?V:N)*.7,opacity:.6,backgroundColor:this.props.checked?this.props.theme.palette.primary.main:this.props.theme.palette.text.disabled}}),s.jsx("div",{style:{position:"absolute",top:this.props.size==="small"?(N-V)/2:0,left:this.props.checked?this.props.size==="small"?re-V:ie-N:0,transition:"left 0.2s",borderRadius:50,width:this.props.size==="small"?V:N,height:this.props.size==="small"?V:N,backgroundColor:this.props.checked?this.props.theme.palette.primary.main:"#EEE",boxShadow:"rgba(0, 0, 0, 0.2) 0px 2px 1px -1px, rgba(0, 0, 0, 0.14) 0px 1px 1px 0px, rgba(0, 0, 0, 0.12) 0px 1px 3px 0px"}})]});return this.props.labelOn||this.props.labelOff?s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[this.props.labelOff,e,this.props.labelOn]}):e}}const B={tooltip:{pointerEvents:"none"}};function Z(n){return s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",onClick:e=>n.onClick&&n.onClick(e),viewBox:"0 0 165 165",width:n.width||(n.fontSize==="small"?16:20),height:n.height||n.width||(n.fontSize==="small"?16:20),className:n.className,style:n.style,children:[s.jsx("path",{fill:"currentColor",d:"M82.498,0C37.008,0,0,37.008,0,82.496c0,45.181,36.51,81.977,81.573,82.476V82.569l-27.002-0.002 c-8.023,0-14.554,6.53-14.554,14.561c0,8.023,6.531,14.551,14.554,14.551v17.98c-17.939,0-32.534-14.595-32.534-32.531 c0-17.944,14.595-32.543,32.534-32.543l27.002,0.004v-9.096c0-14.932,12.146-27.08,27.075-27.08 c14.932,0,27.082,12.148,27.082,27.08c0,14.931-12.15,27.08-27.082,27.08l-9.097-0.001v80.641 C136.889,155.333,165,122.14,165,82.496C165,37.008,127.99,0,82.498,0z"}),s.jsx("path",{fill:"currentColor",d:"M117.748,55.493c0-5.016-4.082-9.098-9.1-9.098c-5.015,0-9.097,4.082-9.097,9.098v9.097l9.097,0.001 C113.666,64.591,117.748,60.51,117.748,55.493z"})]})}function J(n){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",onClick:e=>n.onClick&&n.onClick(e),viewBox:"0 0 1073 1068",width:n.width||(n.fontSize==="small"?16:20),height:n.height||n.width||(n.fontSize==="small"?16:20),className:n.className,style:n.style,children:s.jsx("path",{fill:"currentColor",d:"M716 1.1C632.9 5.3 549.8 23.7 472 55c-66.4 26.7-132.6 65.5-188.5 110.4-43.8 35.1-85.2 76.7-120.1 120.6C72.4 400.4 16.7 539.8 3.5 686 1.8 705.1-.1 754.7.7 758c.5 2 1 2 49.7 1.8l49.1-.3.7-20c2.4-64.6 13.4-126 33.2-186 80.8-243.9 297-419.9 552.1-449.4 20.2-2.4 44.2-4.1 56.6-4.1h8.9V50 0l-9.7.1c-5.4.1-16.8.6-25.3 1zm-.8 208c-78.5 4.7-158 27.4-226.5 64.5-68.7 37.3-126.4 86.3-175.2 148.9-11 14-33.2 47.3-42.3 63.5-44 77.8-68.6 164.9-70.9 251.2l-.6 22.8h49.5 49.4l1.2-19c6.3-98.7 40-185.8 102.2-263.3 12.7-15.9 41.2-45.2 57-58.7 66.1-56.3 142.1-91.8 226-105.5 18.9-3 44.1-5.5 56.7-5.5h9.3v-50-50l-11.2.1c-6.2.1-17.3.6-24.6 1zm17.8 251c-104.5 9.2-195.2 69.7-243.6 162.4-43.9 84-45.5 184.2-4.5 270 60.3 125.9 198.1 194.2 334.9 166 46.6-9.7 89.5-29.7 127.2-59.6 13.5-10.7 37.3-34.5 48-47.9 34.2-43.1 55.2-92 63.7-148.6 2.2-15.1 2.5-62.7.5-77.4-3.6-25.2-10.1-51.4-17.8-71.2-10.1-26.2-29.4-59.7-47-81.8-9.7-12.1-35-37.2-47.4-47-47.8-37.9-104.5-60.1-165.4-65-14.7-1.1-34.7-1.1-48.6.1zm174.7 138.6c-.3.5-30.9 49.2-68.1 108.3L772 814.5l67.9.5 68 .5-30.1 48.8-30 48.7h-131c-104.4 0-130.9-.3-130.5-1.3.2-.6 32.7-51.1 72.1-112.1L730 687.9c0-.5-29.5-1-66.5-1.1l-66.6-.3 27.7-44.3 27.6-44.2h128l127.5.7z"})})}function q(n){return s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",onClick:e=>n.onClick&&n.onClick(e),viewBox:"0 0 48 48",width:n.width||(n.fontSize==="small"?16:20),height:n.height||n.width||(n.fontSize==="small"?16:20),className:n.className,style:n.style,children:[s.jsx("path",{fill:"currentColor",d:"M32.042,9.792c4.595,1.238,4.88,3.165,5.524,5.048C34.841,17.664,17.35,35.7,17.35,35.7 s10.901,1.177,23.487-1.003c-0.001,0.029-0.002,0.048-0.003,0.076C42.829,31.661,44,27.97,44,24c0-11.046-8.954-20-20-20 c-5.634,0-10.715,2.338-14.35,6.087C15.489,9.124,26.89,8.403,32.042,9.792z"}),s.jsx("path",{fill:"currentColor",d:"M14.724,37.285c-1.982-0.347-4.212-2.131-4.707-5.302c1.437-1.239,19.994-20.507,19.994-20.507 c-7.008-0.424-14.569-0.465-22.237,0.864C5.408,15.625,4,19.644,4,24c0,11.046,8.954,20,20,20c6.173,0,11.689-2.8,15.358-7.195 C35.486,37.33,23.257,38.769,14.724,37.285z"})]})}function De(n,e){return n<-80?e==="dark"?"#ff5c5c":"#aa0000":n<-60?e==="dark"?"#fa8547":"#ae5c00":n<-50?e==="dark"?"#cdff4f":"#7b9500":e==="dark"?"#5cff5c":"#008500"}const x={fill:"#00ac00",color:"#00ac00"},S={fill:"#ff0000",color:"#ff0000"},Y={fill:"#da8200",color:"#da8200"},O={fill:"#8a8a8a",color:"#8a8a8a"},ae={fill:"#ffcc00",color:"#ffcc00"};function be(n){return n>95?s.jsx(c.BatteryFull,{style:x}):n>85&&n<=95?s.jsx(c.Battery90,{style:x}):n>70&&n<=85?s.jsx(c.Battery80,{style:x}):n>55&&n<=70?s.jsx(c.Battery60,{style:x}):n>40&&n<=55?s.jsx(c.Battery50,{style:ae}):n>25&&n<=40?s.jsx(c.Battery30,{style:ae}):n>10&&n<=25?s.jsx(c.Battery20,{style:Y}):s.jsx(c.BatteryAlert,{style:S})}function le(n){if(!n.status)return null;let e;typeof n.status=="string"?e={connection:n.status}:e=n.status;let t=null;typeof e.battery=="number"&&(t=be(e.battery));const o=typeof n.enabled=="boolean"?s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{flexGrow:1}}),s.jsx(a.Tooltip,{title:n.enabled?p("disableIconTooltip"):p("enableIconTooltip"),slotProps:{popper:{sx:B.tooltip}},children:s.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:s.jsx(Se,{size:"small",checked:n.enabled,disabled:!n.disableEnableAction,onChange:()=>n.disableEnableAction&&n.deviceHandler(n.deviceId,n.disableEnableAction,n.refresh)(),theme:n.theme})})})]}):null;let r;n.connectionType==="wifi"?r=e.connection==="connected"?s.jsx(c.Wifi,{style:x}):e.connection==="disconnected"?s.jsx(c.WifiOff,{style:S}):s.jsx(c.Wifi,{style:O}):n.connectionType==="bluetooth"?r=e.connection==="connected"?s.jsx(c.Bluetooth,{style:x}):e.connection==="disconnected"?s.jsx(c.BluetoothDisabled,{style:S}):s.jsx(c.Bluetooth,{style:O}):n.connectionType==="lan"?r=e.connection==="connected"?s.jsx(c.Cable,{style:x}):e.connection==="disconnected"?s.jsx(c.Cable,{style:S}):s.jsx(c.Cable,{style:O}):n.connectionType==="thread"?r=e.connection==="connected"?s.jsx(Z,{style:x}):e.connection==="disconnected"?s.jsx(Z,{style:S}):s.jsx(Z,{style:O}):n.connectionType==="z-wave"?r=e.connection==="connected"?s.jsx(J,{style:x}):e.connection==="disconnected"?s.jsx(J,{style:S}):s.jsx(J,{style:O}):n.connectionType==="zigbee"?r=e.connection==="connected"?s.jsx(q,{style:x}):e.connection==="disconnected"?s.jsx(q,{style:S}):s.jsx(q,{style:O}):r=e.connection==="connected"?s.jsx(c.Link,{style:x}):e.connection==="disconnected"?s.jsx(c.LinkOff,{style:S}):null;const i=e.connection==="connected"||e.connection==="disconnected"?s.jsx(a.Tooltip,{title:(e.connection==="connected"?p("connectedIconTooltip"):p("disconnectedIconTooltip"))+(n.statusAction?`. ${p(n.statusAction.description||"moreInformation")}`:""),slotProps:{popper:{sx:B.tooltip}},children:n.statusAction?s.jsxs(a.IconButton,{onClick:l=>{n.statusAction&&(l.stopPropagation(),n.deviceHandler(n.deviceId,n.statusAction,n.refresh)())},children:[r,s.jsx("div",{style:{position:"absolute",top:0,left:0,color:"grey"},children:"*"})]}):s.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:r})}):r;return s.jsxs("div",{style:{display:"flex",alignItems:"baseline",cursor:n.statusAction?"pointer":void 0,width:n.disableEnableAction?"100%":void 0,gap:8},children:[i,e.rssi&&s.jsx(a.Tooltip,{title:"RSSI",slotProps:{popper:{sx:B.tooltip}},children:s.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[s.jsx(c.NetworkCheck,{style:{color:De(e.rssi,n.theme.palette.mode)}}),s.jsx("p",{style:{fontSize:"small",margin:0},children:e.rssi})]})}),typeof e.battery=="number"&&s.jsx(a.Tooltip,{title:p("batteryTooltip"),slotProps:{popper:{sx:B.tooltip}},children:s.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[t,s.jsxs("p",{style:{fontSize:"small",margin:0},children:[e.battery,"%"]})]})}),typeof e.battery=="string"&&s.jsx(a.Tooltip,{title:p("batteryTooltip"),slotProps:{popper:{sx:B.tooltip}},children:s.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[e.battery==="charging"?s.jsx(c.BatteryCharging50,{}):s.jsx(c.BatteryFull,{}),e.battery!=="charging"?e.battery.includes("V")||e.battery.includes("mV")?s.jsx("p",{style:{fontSize:"small",margin:0},children:e.battery}):s.jsxs("p",{style:{fontSize:"small",margin:0},children:[s.jsx("span",{style:{marginRight:4},children:e.battery}),"mV"]}):null]})}),typeof e.battery=="boolean"&&s.jsx(a.Tooltip,{title:p("batteryTooltip"),slotProps:{popper:{sx:B.tooltip}},children:s.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:e.battery?s.jsx(c.BatteryFull,{style:x}):s.jsx(c.BatteryAlert,{style:S})})}),e.warning?typeof e.warning=="string"||typeof e.warning=="object"?s.jsx(a.Tooltip,{title:p(e.warning),slotProps:{popper:{sx:B.tooltip}},children:s.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:s.jsx(c.Warning,{style:Y})})}):s.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:s.jsx(c.Warning,{style:Y})}):null,o]})}function me(n){var m,T;const{instanceId:e,socket:t,schema:o,data:r,onChange:i}=n,[l,d]=L.useState(!1);if(o===void 0)return null;const[h,u]=e.split(".",2);return s.jsxs(s.Fragment,{children:[l&&s.jsx("div",{children:l}),s.jsx(ye,{expertMode:n.expertMode,socket:t,adapterName:h,instance:parseInt(u,10),schema:o,data:r,onError:d,onChange:y=>i(y),embedded:!0,themeName:n.themeName,themeType:n.themeType,theme:n.theme,isFloatComma:n.isFloatComma===void 0?!!((m=n.socket.systemConfig)!=null&&m.common.isFloatComma):n.isFloatComma,dateFormat:n.dateFormat===void 0?(T=n.socket.systemConfig)==null?void 0:T.common.dateFormat:n.dateFormat})]})}function ce(n){const{socket:e,manufacturer:t,model:o,deviceId:r,onImageSelect:i,uploadImagesToInstance:l}=n,d=m=>{const y=m.target.files;if(!y||y.length===0)return;const D=y[0];if(D){const w=new FileReader;w.onload=k=>{if(!k.target||!k.target.result)return;const F=new Image;F.src=k.target.result,F.onload=async()=>{let b=F.width,_=F.height;b>_?b>100&&(_*=100/b,b=100):_>100&&(b*=100/_,_=100);const z=document.createElement("canvas"),X=z.getContext("2d");if(X){z.width=b,z.height=_,X.drawImage(F,0,0,b,_);const ee=z.toDataURL("image/webp"),ge=`${t?`${t}_`:""}${o||r}.webp`,xe=ee.replace(/^data:image\/webp;base64,/,""),ve=await e.writeFile64(l,ge,xe);console.log(`saveImage response: ${JSON.stringify(ve)}`),i&&i(ee)}}},w.readAsDataURL(D)}},h={opacity:0,position:"absolute",width:45,height:45,zIndex:3},u={position:"relative",top:-22};return s.jsx("div",{style:u,children:s.jsx("input",{style:h,type:"file",accept:"image/*",onChange:d})})}const C={cardStyle:{width:300,minHeight:280,margin:10,overflow:"hidden",display:"inline-block"},headerStyle:{display:"flex",alignItems:"center",gap:8,paddingLeft:8,paddingRight:8,position:"relative",minHeight:60,color:"#000"},imgAreaStyle:{height:45,width:45,justifyContent:"center",display:"flex",alignItems:"center"},imgStyle:{zIndex:2,maxWidth:"100%",maxHeight:"100%",color:"#FFF"},titleStyle:{fontSize:16,fontWeight:"bold",overflow:"hidden",textOverflow:"ellipsis"},detailsButtonStyle:{right:20,bottom:-20,position:"absolute"},bodyStyle:{height:"calc(100% - 116px)"},deviceInfoStyle:{padding:"20px 16px 0 16px",height:133},statusStyle:{padding:"15px 25px 0 15px",height:41}};function de(n){return s.jsx("svg",{viewBox:"0 0 24 24",width:"24",height:"24",style:n.style,className:n.className,children:s.jsx("path",{fill:"currentColor",d:"M21.9,21.9l-8.49-8.49l0,0L3.59,3.59l0,0L2.1,2.1L0.69,3.51L3,5.83V19c0,1.1,0.9,2,2,2h13.17l2.31,2.31L21.9,21.9z M5,18 l3.5-4.5l2.5,3.01L12.17,15l3,3H5z M21,18.17L5.83,3H19c1.1,0,2,0.9,2,2V18.17z"})})}function j(n){return typeof n=="object"?n[v.getLanguage()]||n.en:n}class _e extends L.Component{constructor(e){super(e),this.state={open:!1,details:null,data:{},icon:e.device.icon,showControlDialog:!1}}async fetchIcon(){if(!this.props.device.icon){const e=v.getLanguage(),t=this.props.device.manufacturer&&typeof this.props.device.manufacturer=="object"?this.props.device.manufacturer[e]||this.props.device.manufacturer.en:this.props.device.manufacturer,o=this.props.device.model&&typeof this.props.device.model=="object"?this.props.device.model[e]||this.props.device.model.en:this.props.device.model,r=`${t?`${t}_`:""}${o||this.props.device.id}`;try{const i=await this.props.socket.readFile(this.props.instanceId.replace("system.adapter.",""),`${r}.webp`,!0);i?this.setState({icon:`data:${i.mimeType};base64,${i.file}`}):this.setState({icon:""})}catch{this.state.icon&&this.setState({icon:""})}}}componentDidMount(){this.fetchIcon().catch(e=>console.error(e))}async loadDetails(){console.log(`Loading device details for ${this.props.device.id}... from ${this.props.instanceId}`);const e=await this.props.socket.sendTo(this.props.instanceId,"dm:deviceDetails",this.props.device.id);console.log(`Got device details for ${this.props.device.id}:`,e),this.setState({details:e,data:(e==null?void 0:e.data)||{}})}refresh=()=>{this.setState({details:null}),this.loadDetails().catch(console.error)};copyToClipboard=()=>{const e=this.props.device.id;H.copyToClipboard(e),alert(`${p("copied")} ${e} ${p("toClipboard")}!`)};renderDialog(){return!this.state.open||!this.state.details?null:s.jsxs(a.Dialog,{open:!0,maxWidth:"md",onClose:()=>this.setState({open:!1}),children:[s.jsx(a.DialogContent,{children:s.jsx(me,{instanceId:this.props.instanceId,socket:this.props.socket,schema:this.state.details.schema,data:this.state.data,onChange:e=>this.setState({data:e}),themeName:this.props.themeName,themeType:this.props.themeType,theme:this.props.theme,isFloatComma:this.props.isFloatComma,dateFormat:this.props.dateFormat})}),s.jsx(a.DialogActions,{children:s.jsx(a.Button,{disabled:!this.props.alive,variant:"contained",color:"primary",onClick:()=>this.setState({open:!1}),autoFocus:!0,children:p("closeButtonText")})})]})}renderControlDialog(){var t;if(!this.state.showControlDialog||!this.props.alive)return null;const e={primary:"#111",secondary:"#888"};return s.jsxs(a.Dialog,{open:!0,onClose:()=>this.setState({showControlDialog:!1}),children:[s.jsxs(a.DialogTitle,{children:[this.props.title,s.jsx(a.IconButton,{style:{position:"absolute",top:5,right:5,zIndex:10},onClick:()=>this.setState({showControlDialog:!1}),children:s.jsx(c.Close,{})})]}),s.jsx(a.DialogContent,{style:{display:"flex",flexDirection:"column"},children:(t=this.props.device.controls)==null?void 0:t.map(o=>s.jsx(ne,{disabled:!1,control:o,socket:this.props.socket,colors:e,deviceId:this.props.device.id,controlHandler:this.props.controlHandler,controlStateHandler:this.props.controlStateHandler},o.id))})]})}renderControls(){var o,r,i;const e={primary:"#111",secondary:"#888"},t=(o=this.props.device.controls)==null?void 0:o[0];return((r=this.props.device.controls)==null?void 0:r.length)===1&&t&&(t.type==="icon"||t.type==="switch")&&!t.label?s.jsx(ne,{disabled:!this.props.alive,control:t,colors:e,socket:this.props.socket,deviceId:this.props.device.id,controlHandler:this.props.controlHandler,controlStateHandler:this.props.controlStateHandler}):(i=this.props.device.controls)!=null&&i.length?s.jsx(a.Fab,{size:"small",disabled:!this.props.alive,onClick:()=>this.setState({showControlDialog:!0}),children:s.jsx(c.VideogameAsset,{})}):null}renderActions(){var t;const e=(t=this.props.device.actions)==null?void 0:t.filter(o=>o.id!==I.ACTIONS.STATUS&&o.id!==I.ACTIONS.ENABLE_DISABLE);return e!=null&&e.length?e.map(o=>s.jsx(je,{disabled:!this.props.alive,deviceId:this.props.device.id,action:o,deviceHandler:this.props.deviceHandler,refresh:this.refresh},o.id)):null}renderSmall(){const e=this.props.device.hasDetails,t=this.props.device.status?Array.isArray(this.props.device.status)?this.props.device.status:[this.props.device.status]:[],o=this.state.icon?s.jsx(Q,{src:this.state.icon}):s.jsx(de,{}),r=this.getCardHeaderStyle(this.props.theme,345);return s.jsxs(a.Card,{sx:{maxWidth:345,minWidth:200},children:[s.jsx(a.CardHeader,{style:r,avatar:s.jsxs("div",{children:[this.props.uploadImagesToInstance?s.jsx(ce,{uploadImagesToInstance:this.props.uploadImagesToInstance,deviceId:this.props.device.id,manufacturer:j(this.props.device.manufacturer),model:j(this.props.device.model),onImageSelect:i=>{i&&this.setState({icon:i})},socket:this.props.socket}):null,o]}),action:e?s.jsx(a.IconButton,{"aria-label":"settings",onClick:()=>{this.state.open||(this.loadDetails().catch(console.error),this.setState({open:!0}))},children:s.jsx(c.MoreVert,{})}):null,title:this.props.title,subheader:this.props.device.manufacturer?s.jsxs("span",{children:[s.jsxs("b",{style:{marginRight:4},children:[p("manufacturer"),":"]}),j(this.props.device.manufacturer)]}):null}),s.jsxs(a.CardContent,{style:{position:"relative"},children:[t!=null&&t.length?s.jsx("div",{style:{display:"flex",position:"absolute",top:-11,background:"#88888880",padding:"0 8px",borderRadius:5,width:"calc(100% - 46px)"},children:t.map((i,l)=>{var d,h;return s.jsx(le,{status:i,connectionType:this.props.device.connectionType,enabled:this.props.device.enabled,deviceId:this.props.device.id,statusAction:(d=this.props.device.actions)==null?void 0:d.find(u=>u.id===I.ACTIONS.STATUS),disableEnableAction:(h=this.props.device.actions)==null?void 0:h.find(u=>u.id===I.ACTIONS.ENABLE_DISABLE),deviceHandler:this.props.deviceHandler,refresh:this.refresh,theme:this.props.theme},l)})}):null,s.jsx("div",{children:s.jsxs(a.Typography,{variant:"body1",children:[s.jsxs("div",{onClick:this.copyToClipboard,style:{textOverflow:"ellipsis",overflow:"hidden"},children:[s.jsx("b",{children:"ID:"}),s.jsx("span",{style:{marginLeft:4},children:this.props.device.id.replace(/.*\.\d\./,"")})]}),this.props.device.manufacturer?s.jsxs("div",{children:[s.jsxs("b",{style:{marginRight:4},children:[p("manufacturer"),":"]}),j(this.props.device.manufacturer)]}):null,this.props.device.model?s.jsxs("div",{children:[s.jsxs("b",{style:{marginRight:4},children:[p("model"),":"]}),j(this.props.device.model)]}):null]})})]}),s.jsxs(a.CardActions,{disableSpacing:!0,children:[this.renderActions(),s.jsx("div",{style:{flexGrow:1}}),this.renderControls()]}),this.renderDialog(),this.renderControlDialog()]})}getCardHeaderStyle(e,t){const o=this.props.device;if(!o)return{};const r=o.backgroundColor==="primary"?e.palette.primary.main:o.backgroundColor==="secondary"?e.palette.secondary.main:o.backgroundColor||e.palette.secondary.main;let i;return o.color&&o.color!=="primary"&&o.color!=="secondary"?i=o.color:o.color==="primary"?i=e.palette.primary.main:o.color==="secondary"?i=e.palette.secondary.main:o.backgroundColor==="primary"?i=e.palette.primary.contrastText:o.backgroundColor==="secondary"||!o.backgroundColor?i=e.palette.secondary.contrastText:i=H.invertColor(r,!0),{backgroundColor:r,color:i,maxWidth:t}}renderBig(){var i,l,d,h,u;const e=this.props.device.status?Array.isArray(this.props.device.status)?this.props.device.status:[this.props.device.status]:[],t=this.state.icon?s.jsx(Q,{src:this.state.icon,style:C.imgStyle}):s.jsx(de,{style:C.imgStyle}),o=this.getCardHeaderStyle(this.props.theme),r=((l=(i=this.state.details)==null?void 0:i.data)==null?void 0:l.name)||this.props.title||"";return s.jsxs(a.Paper,{style:C.cardStyle,children:[s.jsxs(a.Box,{sx:o,style:C.headerStyle,children:[s.jsxs("div",{style:C.imgAreaStyle,children:[this.props.uploadImagesToInstance?s.jsx(ce,{uploadImagesToInstance:this.props.uploadImagesToInstance,deviceId:this.props.device.id,manufacturer:j(this.props.device.manufacturer),model:j(this.props.device.model),onImageSelect:m=>{m&&this.setState({icon:m})},socket:this.props.socket}):null,t]}),s.jsx(a.Box,{style:C.titleStyle,title:r.length>20?r:void 0,sx:m=>({color:o.color||m.palette.secondary.contrastText}),children:((h=(d=this.state.details)==null?void 0:d.data)==null?void 0:h.name)||this.props.title}),this.props.device.hasDetails?s.jsx(a.Fab,{disabled:!this.props.alive,size:"small",style:C.detailsButtonStyle,onClick:()=>{this.state.open||(this.loadDetails().catch(console.error),this.setState({open:!0}))},color:"primary",children:s.jsx(c.MoreVert,{})}):null]}),s.jsx("div",{style:C.statusStyle,children:e.map((m,T)=>{var y,D;return s.jsx(le,{deviceId:this.props.device.id,connectionType:this.props.device.connectionType,status:m,enabled:this.props.device.enabled,statusAction:(y=this.props.device.actions)==null?void 0:y.find(w=>w.id===I.ACTIONS.STATUS),disableEnableAction:(D=this.props.device.actions)==null?void 0:D.find(w=>w.id===I.ACTIONS.ENABLE_DISABLE),deviceHandler:this.props.deviceHandler,refresh:this.refresh,theme:this.props.theme},T)})}),s.jsxs("div",{style:C.bodyStyle,children:[s.jsxs(a.Typography,{variant:"body1",style:C.deviceInfoStyle,children:[s.jsxs("div",{onClick:this.copyToClipboard,children:[s.jsx("b",{style:{marginRight:4},children:"ID:"}),this.props.device.id.replace(/.*\.\d\./,"")]}),this.props.device.manufacturer?s.jsxs("div",{children:[s.jsxs("b",{style:{marginRight:4},children:[p("manufacturer"),":"]}),j(this.props.device.manufacturer)]}):null,this.props.device.model?s.jsxs("div",{children:[s.jsxs("b",{style:{marginRight:4},children:[p("model"),":"]}),j(this.props.device.model)]}):null]}),!!((u=this.props.device.actions)!=null&&u.length)&&s.jsxs("div",{style:{flex:1,position:"relative",display:"flex",gap:8,paddingBottom:5,height:34,paddingLeft:10,paddingRight:10},children:[this.renderActions(),s.jsx("div",{style:{flexGrow:1}}),this.renderControls()]})]}),this.renderDialog(),this.renderControlDialog()]},this.props.id)}render(){return this.props.smallCards?this.renderSmall():this.renderBig()}}class Be extends L.Component{responseTimeout=null;instanceHandler;deviceHandler;controlHandler;controlStateHandler;constructor(e){super(e),this.state={showSpinner:!1,showToast:null,message:null,confirm:null,form:null,progress:null,showConfirmation:null,showInput:null,inputValue:null},this.instanceHandler=t=>()=>{if(t.confirmation){this.setState({showConfirmation:t});return}if(t.inputBefore){this.setState({showInput:t});return}this.sendActionToInstance("dm:instanceAction",{actionId:t.id,timeout:t.timeout})},this.deviceHandler=(t,o,r)=>()=>{if(o.confirmation){this.setState({showConfirmation:{...o,deviceId:t,refresh:r}});return}if(o.inputBefore){this.setState({showInput:{...o,deviceId:t,refresh:r},inputValue:o.inputBefore.defaultValue||""});return}this.sendActionToInstance("dm:deviceAction",{deviceId:t,actionId:o.id,timeout:o.timeout},r)},this.controlHandler=(t,o,r)=>()=>this.sendControlToInstance("dm:deviceControl",{deviceId:t,controlId:o.id,state:r}),this.controlStateHandler=(t,o)=>()=>this.sendControlToInstance("dm:deviceControlState",{deviceId:t,controlId:o.id}),this.props.registerHandler&&this.props.registerHandler(()=>this.loadData())}componentWillUnmount(){this.responseTimeout&&(clearTimeout(this.responseTimeout),this.responseTimeout=null)}loadData(){console.error("loadData not implemented")}sendActionToInstance=(e,t,o)=>{(async()=>{this.setState({showSpinner:!0}),this.responseTimeout=setTimeout(()=>{this.setState({showSpinner:!1}),window.alert(v.t("ra_No response from the backend"))},t.timeout||5e3);const i=await this.props.socket.sendTo(this.props.selectedInstance,e,t);this.responseTimeout&&(clearTimeout(this.responseTimeout),this.responseTimeout=null);const l=i.type;switch(console.log(`Response: ${i.type}`),l){case"message":console.log(`Message received: ${i.message}`),i.message&&this.setState({message:{message:i.message,handleClose:()=>this.setState({message:null},()=>this.sendActionToInstance("dm:actionProgress",{origin:i.origin},o))},showSpinner:!1});break;case"confirm":console.log(`Confirm received: ${i.confirm}`),i.confirm&&this.setState({confirm:{message:i.confirm,handleClose:d=>this.setState({confirm:null},()=>this.sendActionToInstance("dm:actionProgress",{origin:i.origin,confirm:d},o))},showSpinner:!1});break;case"form":if(console.log("Form received"),i.form){const d=i.form.data,h={};d&&Object.keys(d).forEach(u=>{d[u]!==void 0&&(h[u]=d[u])}),i.form.data=JSON.parse(JSON.stringify(h)),this.setState({form:{...i.form,changed:!1,originalData:JSON.stringify(h),handleClose:u=>this.setState({form:null},()=>{console.log(`Form ${JSON.stringify(u)}`),this.sendActionToInstance("dm:actionProgress",{origin:i.origin,data:u},o)})},showSpinner:!1})}break;case"progress":if(i.progress)if(this.state.progress){const d={...this.state.progress,...i.progress};this.setState({progress:d,showSpinner:!1})}else this.setState({progress:i.progress,showSpinner:!1});this.sendActionToInstance("dm:actionProgress",{origin:i.origin},o);break;case"result":console.log("Response content",i.result),i.result.refresh&&(i.result.refresh===!0?(console.log("Refreshing all"),this.loadData()):i.result.refresh==="instance"?console.log(`Refreshing instance infos: ${this.props.selectedInstance}`):i.result.refresh==="device"?o?(console.log(`Refreshing device infos: ${this.props.selectedInstance}`),o()):console.log('No refresh function provided to refresh "device"'):console.log("Not refreshing anything")),i.result.error?(console.error(`Error: ${i.result.error.message}`),this.setState({showToast:i.result.error.message,showSpinner:!1})):this.setState({showSpinner:!1});break;default:console.log(`Unknown response type: ${l}`),this.setState({showSpinner:!1});break}})().catch(console.error)};sendControlToInstance=async(e,t)=>{const o=await this.props.socket.sendTo(this.props.selectedInstance,e,t),r=o.type;if(console.log(`Response: ${o.type}`),o.type==="result"){if(console.log("Response content",o.result),o.result.error)console.error(`Error: ${o.result.error.message}`),this.setState({showToast:o.result.error.message});else if(o.result.state!==void 0)return o.result.state}else console.warn("Unexpected response type",r);return null};loadDevices(){return this.props.socket.sendTo(this.props.selectedInstance,"dm:listDevices")}loadInstanceInfos(){return this.props.socket.sendTo(this.props.selectedInstance,"dm:instanceInfo")}renderMessageDialog(){var e;return this.state.message?s.jsxs(a.Dialog,{open:!0,onClose:()=>{var t;return(t=this.state.message)==null?void 0:t.handleClose()},hideBackdrop:!0,"aria-describedby":"message-dialog-description",children:[s.jsx(a.DialogContent,{children:s.jsx(a.DialogContentText,{id:"message-dialog-description",children:(e=this.state.message)==null?void 0:e.message})}),s.jsx(a.DialogActions,{children:s.jsx(a.Button,{color:"primary",onClick:()=>{var t;return(t=this.state.message)==null?void 0:t.handleClose()},variant:"contained",autoFocus:!0,children:p("okButtonText")})})]}):null}renderConfirmDialog(){var e;return this.state.confirm?s.jsxs(a.Dialog,{open:!0,onClose:()=>{var t;return(t=this.state.confirm)==null?void 0:t.handleClose()},hideBackdrop:!0,"aria-describedby":"confirm-dialog-description",children:[s.jsx(a.DialogContent,{children:s.jsx(a.DialogContentText,{id:"confirm-dialog-description",children:p((e=this.state.confirm)==null?void 0:e.message)})}),s.jsxs(a.DialogActions,{children:[s.jsx(a.Button,{variant:"contained",color:"primary",onClick:()=>{var t;return(t=this.state.confirm)==null?void 0:t.handleClose(!0)},autoFocus:!0,children:p("yesButtonText")}),s.jsx(a.Button,{variant:"contained",color:"grey",onClick:()=>{var t;return(t=this.state.confirm)==null?void 0:t.handleClose(!1)},autoFocus:!0,children:p("noButtonText")})]})]}):null}renderSnackbar(){return s.jsx(a.Snackbar,{open:!!this.state.showToast,autoHideDuration:6e3,onClose:()=>this.setState({showToast:null}),message:this.state.showToast})}getOkButton(e){var t;return typeof e=="string"&&(e=void 0),s.jsx(a.Button,{disabled:!((t=this.state.form)!=null&&t.changed),variant:(e==null?void 0:e.variant)||"contained",color:(e==null?void 0:e.color)==="primary"?"primary":(e==null?void 0:e.color)==="secondary"?"secondary":"primary",style:{backgroundColor:e!=null&&e.color&&(e==null?void 0:e.color)!=="primary"&&(e==null?void 0:e.color)!=="secondary"?e==null?void 0:e.color:void 0,...(e==null?void 0:e.style)||void 0},onClick:()=>{var o,r;return((o=this.state.form)==null?void 0:o.handleClose)&&this.state.form.handleClose((r=this.state.form)==null?void 0:r.data)},startIcon:e!=null&&e.icon?s.jsx($,{src:e==null?void 0:e.icon}):void 0,children:p((e==null?void 0:e.label)||"okButtonText",e==null?void 0:e.noTranslation)},"apply")}getCancelButton(e){let t=!1;return typeof e=="string"&&(t=e==="close",e=void 0),s.jsx(a.Button,{variant:(e==null?void 0:e.variant)||"contained",color:(e==null?void 0:e.color)==="primary"?"primary":(e==null?void 0:e.color)==="secondary"?"secondary":"grey",style:{backgroundColor:e!=null&&e.color&&(e==null?void 0:e.color)!=="primary"&&(e==null?void 0:e.color)!=="secondary"?e==null?void 0:e.color:void 0,...(e==null?void 0:e.style)||void 0},onClick:()=>{var o;return((o=this.state.form)==null?void 0:o.handleClose)&&this.state.form.handleClose()},startIcon:t?s.jsx(c.Close,{}):e!=null&&e.icon?s.jsx($,{src:e==null?void 0:e.icon}):void 0,children:p((e==null?void 0:e.label)||"cancelButtonText",e==null?void 0:e.noTranslation)},"cancel")}renderFormDialog(){var t,o,r;if(!this.state.form||!this.state.form.schema)return null;let e;return this.state.form.buttons?(e=[],this.state.form.buttons.forEach(i=>{typeof i=="object"&&i.type==="copyToClipboard"?e.push(s.jsx(a.Button,{variant:i.variant||"outlined",color:i.color==="primary"?"primary":i.color==="secondary"?"secondary":void 0,style:{backgroundColor:i.color&&i.color!=="primary"&&i.color!=="secondary"?i.color:void 0,...i.style||void 0},onClick:()=>{var l;if(i.copyToClipboardAttr&&this.state.form.data){const d=this.state.form.data[i.copyToClipboardAttr];typeof d=="string"?H.copyToClipboard(d):H.copyToClipboard(JSON.stringify(d,null,2)),window.alert(v.t("copied"))}else(l=this.state.form)!=null&&l.data?(H.copyToClipboard(JSON.stringify(this.state.form.data,null,2)),window.alert(v.t("copied"))):window.alert(v.t("nothingToCopy"))},startIcon:i!=null&&i.icon?s.jsx($,{src:i==null?void 0:i.icon}):s.jsx(c.ContentCopy,{}),children:p((i==null?void 0:i.label)||"ctcButtonText",i==null?void 0:i.noTranslation)},"copyToClipboard")):i==="apply"||i.type==="apply"?e.push(this.getOkButton(i)):e.push(this.getCancelButton(i))})):e=[this.getOkButton(),this.getCancelButton()],s.jsxs(a.Dialog,{open:!0,onClose:()=>this.state.form.handleClose&&this.state.form.handleClose(),hideBackdrop:!0,fullWidth:!0,sx:{"& .MuiDialog-paper":{minWidth:this.state.form.minWidth||void 0}},maxWidth:this.state.form.maxWidth||"md",children:[(t=this.state.form)!=null&&t.title?s.jsx(a.DialogTitle,{children:p(((o=this.state.form)==null?void 0:o.label)||((r=this.state.form)==null?void 0:r.title),this.state.form.noTranslation)}):null,s.jsx(a.DialogContent,{children:s.jsx(me,{instanceId:this.props.selectedInstance,schema:this.state.form.schema,data:this.state.form.data||{},socket:this.props.socket,onChange:i=>{console.log("handleFormChange",{data:i});const l={...this.state.form};l&&(l.data=i,l.changed=JSON.stringify(i)!==l.originalData,this.setState({form:l}))},themeName:this.props.themeName,themeType:this.props.themeType,theme:this.props.theme,isFloatComma:this.props.isFloatComma,dateFormat:this.props.dateFormat})}),s.jsx(a.DialogActions,{children:e})]})}renderProgressDialog(){var e,t;return(e=this.state.progress)!=null&&e.open?s.jsx(a.Dialog,{open:!0,onClose:()=>{},hideBackdrop:!0,children:s.jsx(a.LinearProgress,{variant:"determinate",value:((t=this.state.progress)==null?void 0:t.progress)||0})}):null}renderContent(){return null}renderSpinner(){return this.state.showSpinner?s.jsx(a.Backdrop,{style:{zIndex:1e3},open:!0,children:s.jsx(a.CircularProgress,{})}):null}renderConfirmationDialog(){return this.state.showConfirmation?s.jsxs(a.Dialog,{open:!0,onClose:()=>this.setState({showConfirmation:null}),children:[s.jsx(a.DialogTitle,{children:p(this.state.showConfirmation.confirmation===!0?p("areYouSureText"):p(this.state.showConfirmation.confirmation))}),s.jsxs(a.DialogActions,{children:[s.jsx(a.Button,{variant:"contained",color:"primary",onClick:()=>{if(!this.state.showConfirmation)return;const e=this.state.showConfirmation;this.setState({showConfirmation:null},()=>{e.deviceId?this.sendActionToInstance("dm:deviceAction",{actionId:e.id,deviceId:e.deviceId,timeout:e.timeout},e.refresh):this.sendActionToInstance("dm:instanceAction",{actionId:e.id,timeout:e.timeout})})},autoFocus:!0,startIcon:s.jsx(c.Check,{}),children:p("yesButtonText")}),s.jsx(a.Button,{variant:"contained",color:"grey",onClick:()=>this.setState({showConfirmation:null}),startIcon:s.jsx(c.Close,{}),children:p("cancelButtonText")})]})]}):null}onShowInputOk(){if(!this.state.showInput)return;const e=this.state.showInput;this.setState({showInput:null},()=>{var t,o,r,i;e.deviceId?this.sendActionToInstance("dm:deviceAction",{actionId:e.id,deviceId:e.deviceId,timeout:e.timeout,value:((t=e.inputBefore)==null?void 0:t.type)==="checkbox"?!!this.state.inputValue:((o=e.inputBefore)==null?void 0:o.type)==="number"?parseFloat(this.state.inputValue)||0:this.state.inputValue},e.refresh):this.sendActionToInstance("dm:instanceAction",{actionId:e.id,timeout:e.timeout,value:((r=e.inputBefore)==null?void 0:r.type)==="checkbox"?!!this.state.inputValue:((i=e.inputBefore)==null?void 0:i.type)==="number"?parseFloat(this.state.inputValue)||0:this.state.inputValue})})}renderInputDialog(){var t;if(!this.state.showInput||!this.state.showInput.inputBefore)return null;let e=!1;return!this.state.showInput.inputBefore.allowEmptyValue&&this.state.showInput.inputBefore.type!=="checkbox"&&(this.state.showInput.inputBefore.type==="number"||this.state.showInput.inputBefore.type==="slider"?e=this.state.inputValue===""||this.state.inputValue===null||!window.isFinite(this.state.inputValue):e=!this.state.inputValue),s.jsxs(a.Dialog,{open:!0,onClose:()=>this.setState({showInput:null}),children:[s.jsx(a.DialogTitle,{children:p("pleaseEnterValueText")}),s.jsxs(a.DialogContent,{children:[this.state.showInput.inputBefore.type==="text"||this.state.showInput.inputBefore.type==="number"||!this.state.showInput.inputBefore.type?s.jsx(a.TextField,{autoFocus:!0,margin:"dense",label:p(this.state.showInput.inputBefore.label),slotProps:{htmlInput:this.state.showInput.inputBefore.type==="number"?{min:this.state.showInput.inputBefore.min,max:this.state.showInput.inputBefore.max,step:this.state.showInput.inputBefore.step}:void 0,input:{endAdornment:this.state.inputValue?s.jsx(a.InputAdornment,{position:"end",children:s.jsx(a.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({inputValue:""}),children:s.jsx(c.Close,{})})}):null}},type:this.state.showInput.inputBefore.type==="number"?"number":"text",fullWidth:!0,value:this.state.inputValue,onChange:o=>this.setState({inputValue:o.target.value}),onKeyUp:o=>{o.key==="Enter"&&this.onShowInputOk()}}):null,this.state.showInput.inputBefore.type==="checkbox"?s.jsx(a.FormControlLabel,{control:s.jsx(a.Checkbox,{checked:!!this.state.inputValue,autoFocus:!0,onChange:o=>this.setState({inputValue:o.target.checked})}),label:p(this.state.showInput.inputBefore.label)}):null,this.state.showInput.inputBefore.type==="select"?s.jsxs(a.FormControl,{fullWidth:!0,children:[s.jsx(a.InputLabel,{children:p(this.state.showInput.inputBefore.label)}),s.jsx(a.Select,{variant:"standard",value:this.state.inputValue,onChange:o=>this.setState({inputValue:o.target.value}),children:(t=this.state.showInput.inputBefore.options)==null?void 0:t.map(o=>s.jsx(a.MenuItem,{value:o.value,children:p(o.label)},o.value))})]}):null,this.state.showInput.inputBefore.type==="slider"?s.jsxs(a.Box,{sx:{width:"100%"},children:[s.jsx(a.Typography,{gutterBottom:!0,children:p(this.state.showInput.inputBefore.label)}),s.jsxs(a.Grid2,{container:!0,spacing:2,alignItems:"center",children:[s.jsx(a.Grid2,{children:s.jsx(a.Slider,{value:typeof this.state.inputValue=="number"?this.state.inputValue:0,onChange:(o,r)=>this.setState({inputValue:r})})}),s.jsx(a.Grid2,{children:s.jsx(a.Input,{value:this.state.inputValue,size:"small",onChange:o=>this.setState({inputValue:o.target.value===""?0:Number(o.target.value)}),onBlur:()=>{var i,l;if(!this.state.showInput)return;const o=((i=this.state.showInput.inputBefore)==null?void 0:i.min)===void 0?0:this.state.showInput.inputBefore.min,r=((l=this.state.showInput.inputBefore)==null?void 0:l.max)===void 0?100:this.state.showInput.inputBefore.max;this.state.inputValue<o?this.setState({inputValue:o}):this.state.inputValue>r&&this.setState({inputValue:r})},inputProps:{step:this.state.showInput.inputBefore.step,min:this.state.showInput.inputBefore.min===void 0?0:this.state.showInput.inputBefore.min,max:this.state.showInput.inputBefore.max===void 0?100:this.state.showInput.inputBefore.max,type:"number"}})})]})]}):null]}),s.jsxs(a.DialogActions,{children:[s.jsx(a.Button,{variant:"contained",disabled:e,color:"primary",onClick:()=>this.onShowInputOk(),startIcon:s.jsx(c.Check,{}),children:p("yesButtonText")}),s.jsx(a.Button,{variant:"contained",color:"grey",onClick:()=>this.setState({showInput:null}),startIcon:s.jsx(c.Close,{}),children:p("cancelButtonText")})]})]})}render(){return s.jsxs(s.Fragment,{children:[this.renderSnackbar(),this.renderContent(),this.renderConfirmDialog(),this.renderMessageDialog(),this.renderFormDialog(),this.renderProgressDialog(),this.renderConfirmationDialog(),this.renderInputDialog(),this.renderSpinner()]})}}function Ee(n){const{action:e,instanceHandler:t}=n,o=p(e!=null&&e.description?e.description:""),r=p(e!=null&&e.title?e.title:""),i=fe(e);return s.jsx(pe,{tooltip:o,label:r,disabled:e.disabled,Icon:i,onClick:t(e)})}const ke="Alle Geräte herausgefiltert",Ne="Batterie",Oe="Abbrechen",Ae="Schließen",Le="Verbunden",Fe="Kopiert",Ve="In die Zwischenablage kopieren",Pe="Gerät deaktivieren",He="Getrennt",ze="Gerät aktivieren",We="Nach Name filtern",Me="Instanz",Re="Instanz ist nicht aktiv",Ue="Hersteller",Ke="Modell",Ge="Klicken, um weitere Informationen zu erhalten",Ze="Nein",Je="Keine Geräte gefunden",qe="Bitte Instanz auswählen",Qe="nichts zu kopieren",Ye="OK",Xe="Bitte eingeben",et="Instanzliste aktualisieren",tt="Aktualisieren",st="in die Zwischenablage kopiert",ot="Ja",nt={allDevicesFilteredOut:ke,batteryTooltip:Ne,cancelButtonText:Oe,closeButtonText:Ae,connectedIconTooltip:Le,copied:Fe,ctcButtonText:Ve,disableIconTooltip:Pe,disconnectedIconTooltip:He,enableIconTooltip:ze,filterLabelText:We,instanceLabelText:Me,instanceNotAlive:Re,manufacturer:Ue,model:Ke,moreInformation:Ge,noButtonText:Ze,noDevicesFoundText:Je,noInstanceSelectedText:qe,nothingToCopy:Qe,okButtonText:Ye,pleaseEnterValueText:Xe,refreshInstanceList:et,refreshTooltip:tt,toClipboard:st,yesButtonText:ot},it="All devices filtered out",rt="Battery",at="Cancel",lt="Close",ct="Connected",dt="Copied",pt="Copy to clipboard",ht="Disable device",ut="Disconnected",ft="Enable device",mt="Filter by name",gt="Instance",xt="Instance is not alive",vt="Manufacturer",Tt="Model",yt="Click to get more information",It="No",Ct="No devices found",$t="Please select instance",wt="nothingToCopy",jt="OK",St="Please enter",Dt="Refresh instance list",bt="Refresh",_t="to clipboard",Bt="Yes",Et={allDevicesFilteredOut:it,batteryTooltip:rt,cancelButtonText:at,closeButtonText:lt,connectedIconTooltip:ct,copied:dt,ctcButtonText:pt,disableIconTooltip:ht,disconnectedIconTooltip:ut,enableIconTooltip:ft,filterLabelText:mt,instanceLabelText:gt,instanceNotAlive:xt,manufacturer:vt,model:Tt,moreInformation:yt,noButtonText:It,noDevicesFoundText:Ct,noInstanceSelectedText:$t,nothingToCopy:wt,okButtonText:jt,pleaseEnterValueText:St,refreshInstanceList:Dt,refreshTooltip:bt,toClipboard:_t,yesButtonText:Bt},kt="Все устройства отфильтрованы",Nt="Батарея",Ot="Отмена",At="Закрыть",Lt="Подключено",Ft="Скопировано",Vt="Копировать в буфер обмена",Pt="Деактивировать устройство",Ht="Отключено",zt="Активировать устройство",Wt="Фильтровать по имени",Mt="Екземпляр",Rt="Экземпляр не жив",Ut="Производитель",Kt="Модель",Gt="Нажмите, чтобы получить больше информации",Zt="Нет",Jt="Устройства не найдены",qt="Пожалуйста, выберите экземпляр",Qt="ничегоКопировать",Yt="ХОРОШО",Xt="Пожалуйста входите",es="Обновить список экземпляров",ts="Обновить",ss="в буфер обмена",os="Да",ns={allDevicesFilteredOut:kt,batteryTooltip:Nt,cancelButtonText:Ot,closeButtonText:At,connectedIconTooltip:Lt,copied:Ft,ctcButtonText:Vt,disableIconTooltip:Pt,disconnectedIconTooltip:Ht,enableIconTooltip:zt,filterLabelText:Wt,instanceLabelText:Mt,instanceNotAlive:Rt,manufacturer:Ut,model:Kt,moreInformation:Gt,noButtonText:Zt,noDevicesFoundText:Jt,noInstanceSelectedText:qt,nothingToCopy:Qt,okButtonText:Yt,pleaseEnterValueText:Xt,refreshInstanceList:es,refreshTooltip:ts,toClipboard:ss,yesButtonText:os},is="Todos os dispositivos foram filtrados",rs="Bateria",as="Cancelar",ls="Fechar",cs="Conectado",ds="Copiado",ps="Copiar para área de transferência",hs="Desativar dispositivo",us="Desconectado",fs="Habilitar dispositivo",ms="Filtrar por nome",gs="Instância",xs="A instância não está ativa",vs="Fabricante",Ts="Modelo",ys="Clique para obter mais informações",Is="Não",Cs="Nenhum dispositivo encontrado",$s="Selecione a instância",ws="nadaParaCopiar",js="OK",Ss="Por favor, insira",Ds="Atualizar lista de instâncias",bs="Atualizar",_s="para a área de transferência",Bs="Sim",Es={allDevicesFilteredOut:is,batteryTooltip:rs,cancelButtonText:as,closeButtonText:ls,connectedIconTooltip:cs,copied:ds,ctcButtonText:ps,disableIconTooltip:hs,disconnectedIconTooltip:us,enableIconTooltip:fs,filterLabelText:ms,instanceLabelText:gs,instanceNotAlive:xs,manufacturer:vs,model:Ts,moreInformation:ys,noButtonText:Is,noDevicesFoundText:Cs,noInstanceSelectedText:$s,nothingToCopy:ws,okButtonText:js,pleaseEnterValueText:Ss,refreshInstanceList:Ds,refreshTooltip:bs,toClipboard:_s,yesButtonText:Bs},ks="Alle apparaten zijn eruit gefilterd",Ns="Batterij",Os="Annuleren",As="Dichtbij",Ls="Verbonden",Fs="Gekopieerd",Vs="Kopiëren naar klembord",Ps="Apparaat uitschakelen",Hs="Losgekoppeld",zs="Apparaat inschakelen",Ws="Filter op naam",Ms="Voorbeeld",Rs="Instantie leeft niet",Us="Fabrikant",Ks="Model",Gs="Klik voor meer informatie",Zs="Nee",Js="Geen apparaten gevonden",qs="Selecteer een exemplaar",Qs="nietsOmTeKopiëren",Ys="OK",Xs="Kom binnen alstublieft",eo="Ververs de exemplaarlijst",to="Vernieuwen",so="naar klembord",oo="Ja",no={allDevicesFilteredOut:ks,batteryTooltip:Ns,cancelButtonText:Os,closeButtonText:As,connectedIconTooltip:Ls,copied:Fs,ctcButtonText:Vs,disableIconTooltip:Ps,disconnectedIconTooltip:Hs,enableIconTooltip:zs,filterLabelText:Ws,instanceLabelText:Ms,instanceNotAlive:Rs,manufacturer:Us,model:Ks,moreInformation:Gs,noButtonText:Zs,noDevicesFoundText:Js,noInstanceSelectedText:qs,nothingToCopy:Qs,okButtonText:Ys,pleaseEnterValueText:Xs,refreshInstanceList:eo,refreshTooltip:to,toClipboard:so,yesButtonText:oo},io="Tous les appareils filtrés",ro="Batterie",ao="Annuler",lo="Fermer",co="Connecté",po="Copié",ho="Copier dans le presse-papier",uo="Désactiver l'appareil",fo="Débranché",mo="Activer l'appareil",go="Filtrer par nom",xo="Exemple",vo="L'instance n'est pas vivante",To="Fabricant",yo="Modèle",Io="Cliquez pour obtenir plus d'informations",Co="Non",$o="Aucun périphérique trouvé",wo="Veuillez sélectionner une instance",jo="rien à copier",So="D'ACCORD",Do="Entrez s'il vous plait",bo="Actualiser la liste des instances",_o="Rafraîchir",Bo="au presse-papiers",Eo="Oui",ko={allDevicesFilteredOut:io,batteryTooltip:ro,cancelButtonText:ao,closeButtonText:lo,connectedIconTooltip:co,copied:po,ctcButtonText:ho,disableIconTooltip:uo,disconnectedIconTooltip:fo,enableIconTooltip:mo,filterLabelText:go,instanceLabelText:xo,instanceNotAlive:vo,manufacturer:To,model:yo,moreInformation:Io,noButtonText:Co,noDevicesFoundText:$o,noInstanceSelectedText:wo,nothingToCopy:jo,okButtonText:So,pleaseEnterValueText:Do,refreshInstanceList:bo,refreshTooltip:_o,toClipboard:Bo,yesButtonText:Eo},No="Tutti i dispositivi sono stati filtrati",Oo="Batteria",Ao="Annulla",Lo="Vicino",Fo="Connesso",Vo="Copiato",Po="Copia negli appunti",Ho="Disabilita dispositivo",zo="Disconnesso",Wo="Abilita dispositivo",Mo="Filtra per nome",Ro="Esempio",Uo="L'istanza non è viva",Ko="Produttore",Go="Modello",Zo="Clicca per avere maggiori informazioni",Jo="NO",qo="Nessun dispositivo trovato",Qo="Seleziona l'istanza",Yo="Niente da copiare",Xo="OK",en="Prego entra",tn="Aggiorna l'elenco delle istanze",sn="ricaricare",on="negli appunti",nn="SÌ",rn={allDevicesFilteredOut:No,batteryTooltip:Oo,cancelButtonText:Ao,closeButtonText:Lo,connectedIconTooltip:Fo,copied:Vo,ctcButtonText:Po,disableIconTooltip:Ho,disconnectedIconTooltip:zo,enableIconTooltip:Wo,filterLabelText:Mo,instanceLabelText:Ro,instanceNotAlive:Uo,manufacturer:Ko,model:Go,moreInformation:Zo,noButtonText:Jo,noDevicesFoundText:qo,noInstanceSelectedText:Qo,nothingToCopy:Yo,okButtonText:Xo,pleaseEnterValueText:en,refreshInstanceList:tn,refreshTooltip:sn,toClipboard:on,yesButtonText:nn},an="Todos los dispositivos filtrados",ln="Batería",cn="Cancelar",dn="Cerca",pn="Conectado",hn="copiado",un="Copiar al portapapeles",fn="Deshabilitar dispositivo",mn="Desconectado",gn="Habilitar dispositivo",xn="Filtrar por nombre",vn="Instancia",Tn="La instancia no está viva.",yn="Fabricante",In="Modelo",Cn="Haga clic para obtener más información",$n="No",wn="No se encontraron dispositivos",jn="Por favor seleccione instancia",Sn="nada que copiar",Dn="DE ACUERDO",bn="Por favor escribe",_n="Actualizar lista de instancias",Bn="Actualizar",En="al portapapeles",kn="Sí",Nn={allDevicesFilteredOut:an,batteryTooltip:ln,cancelButtonText:cn,closeButtonText:dn,connectedIconTooltip:pn,copied:hn,ctcButtonText:un,disableIconTooltip:fn,disconnectedIconTooltip:mn,enableIconTooltip:gn,filterLabelText:xn,instanceLabelText:vn,instanceNotAlive:Tn,manufacturer:yn,model:In,moreInformation:Cn,noButtonText:$n,noDevicesFoundText:wn,noInstanceSelectedText:jn,nothingToCopy:Sn,okButtonText:Dn,pleaseEnterValueText:bn,refreshInstanceList:_n,refreshTooltip:Bn,toClipboard:En,yesButtonText:kn},On="Wszystkie urządzenia zostały odfiltrowane",An="Bateria",Ln="Anulować",Fn="Zamknąć",Vn="Połączono",Pn="Skopiowano",Hn="Kopiuj do schowka",zn="Wyłącz urządzenie",Wn="Bezładny",Mn="Włącz urządzenie",Rn="Filtruj według nazwy",Un="Instancja",Kn="Instancja nie żyje",Gn="Producent",Zn="Model",Jn="Kliknij, aby uzyskać więcej informacji",qn="NIE",Qn="Nie znaleziono urządzeń",Yn="Wybierz instancję",Xn="nicDoSkopiowania",ei="OK",ti="Podaj",si="Odśwież listę instancji",oi="Odświeżać",ni="do schowka",ii="Tak",ri={allDevicesFilteredOut:On,batteryTooltip:An,cancelButtonText:Ln,closeButtonText:Fn,connectedIconTooltip:Vn,copied:Pn,ctcButtonText:Hn,disableIconTooltip:zn,disconnectedIconTooltip:Wn,enableIconTooltip:Mn,filterLabelText:Rn,instanceLabelText:Un,instanceNotAlive:Kn,manufacturer:Gn,model:Zn,moreInformation:Jn,noButtonText:qn,noDevicesFoundText:Qn,noInstanceSelectedText:Yn,nothingToCopy:Xn,okButtonText:ei,pleaseEnterValueText:ti,refreshInstanceList:si,refreshTooltip:oi,toClipboard:ni,yesButtonText:ii},ai="Усі пристрої відфільтровано",li="Батарея",ci="Скасувати",di="Закрити",pi="Підключено",hi="Скопійовано",ui="Копіювати в буфер обміну",fi="Вимкнути пристрій",mi="Відключено",gi="Увімкнути пристрій",xi="Фільтрувати за назвою",vi="Екземпляр",Ti="Примірник не живий",yi="Виробник",Ii="Модель",Ci="Натисніть, щоб отримати більше інформації",$i="Немає",wi="Пристроїв не знайдено",ji="Виберіть екземпляр",Si="нічого для копіювання",Di="в порядку",bi="Будь ласка введіть",_i="Оновити список екземплярів",Bi="Оновити",Ei="в буфер обміну",ki="Так",Ni={allDevicesFilteredOut:ai,batteryTooltip:li,cancelButtonText:ci,closeButtonText:di,connectedIconTooltip:pi,copied:hi,ctcButtonText:ui,disableIconTooltip:fi,disconnectedIconTooltip:mi,enableIconTooltip:gi,filterLabelText:xi,instanceLabelText:vi,instanceNotAlive:Ti,manufacturer:yi,model:Ii,moreInformation:Ci,noButtonText:$i,noDevicesFoundText:wi,noInstanceSelectedText:ji,nothingToCopy:Si,okButtonText:Di,pleaseEnterValueText:bi,refreshInstanceList:_i,refreshTooltip:Bi,toClipboard:Ei,yesButtonText:ki},Oi="所有设备均被过滤掉",Ai="电池",Li="取消",Fi="关闭",Vi="已连接",Pi="已复制",Hi="复制到剪贴板",zi="禁用设备",Wi="已断开连接",Mi="启用设备",Ri="按名称过滤",Ui="实例",Ki="实例不存在",Gi="制造商",Zi="型号",Ji="点击获取更多信息",qi="不",Qi="未找到设备",Yi="请选择实例",Xi="无可复制",er="好的",tr="请输入",sr="刷新实例列表",or="刷新",nr="到剪贴板",ir="是的",rr={allDevicesFilteredOut:Oi,batteryTooltip:Ai,cancelButtonText:Li,closeButtonText:Fi,connectedIconTooltip:Vi,copied:Pi,ctcButtonText:Hi,disableIconTooltip:zi,disconnectedIconTooltip:Wi,enableIconTooltip:Mi,filterLabelText:Ri,instanceLabelText:Ui,instanceNotAlive:Ki,manufacturer:Gi,model:Zi,moreInformation:Ji,noButtonText:qi,noDevicesFoundText:Qi,noInstanceSelectedText:Yi,nothingToCopy:Xi,okButtonText:er,pleaseEnterValueText:tr,refreshInstanceList:sr,refreshTooltip:or,toClipboard:nr,yesButtonText:ir};class W extends Be{static i18nInitialized=!1;lastPropsFilter;lastInstance;lastTriggerLoad=0;filterTimeout;language;constructor(e){super(e),W.i18nInitialized||(W.i18nInitialized=!0,v.extendTranslations({en:Et,de:nt,ru:ns,pt:Es,nl:no,fr:ko,it:rn,es:Nn,pl:ri,uk:Ni,"zh-cn":rr})),Object.assign(this.state,{devices:[],filteredDevices:[],filter:"",instanceInfo:null,loading:null,alive:null,groupKey:""}),this.lastPropsFilter=this.props.filter,this.lastInstance=this.props.selectedInstance,this.lastTriggerLoad=this.props.triggerLoad||0,this.filterTimeout=null,this.language=v.getLanguage()}async componentDidMount(){let e=!1;if(this.state.alive===null){try{const t=await this.props.socket.getState(`system.adapter.${this.props.selectedInstance}.alive`);t!=null&&t.val&&(e=!0)}catch(t){console.error(t)}if(this.setState({alive:e},()=>this.props.socket.subscribeState(`system.adapter.${this.props.selectedInstance}.alive`,this.aliveHandler)),!e)return}else e=this.state.alive;if(!this.props.embedded&&e)try{const t=await this.loadInstanceInfos();this.setState({instanceInfo:t})}catch(t){console.error(t)}e&&this.loadData()}componentWillUnmount(){this.props.socket.unsubscribeState(`system.adapter.${this.props.selectedInstance}.alive`,this.aliveHandler)}aliveHandler=(e,t)=>{if(e===`system.adapter.${this.props.selectedInstance}.alive`){const o=!!(t!=null&&t.val);o!==this.state.alive&&this.setState({alive:o},()=>{o&&this.componentDidMount().catch(console.error)})}};loadData(){this.setState({loading:!0},async()=>{console.log(`Loading devices for ${this.props.selectedInstance}...`);let e=[];try{e=await this.loadDevices(),(!e||!Array.isArray(e))&&(console.error(`Message returned from sendTo() doesn't look like one from DeviceManagement, did you accidentally handle the message in your adapter? ${JSON.stringify(e)}`),e=[])}catch(t){console.error(t),e=[]}this.setState({devices:e,loading:!1},()=>this.applyFilter())})}getText(e){return typeof e=="object"?e[this.language]||e.en:e}applyFilter(){const e=this.props.embedded?this.props.filter:this.state.filter;if(e){const t=this.state.devices.filter(o=>this.getText(o.name).toLowerCase().includes(e.toLowerCase()));this.setState({filteredDevices:t})}else this.setState({filteredDevices:this.state.devices})}handleFilterChange(e){this.setState({filter:e},()=>{this.filterTimeout&&clearTimeout(this.filterTimeout),this.filterTimeout=setTimeout(()=>{this.filterTimeout=null,this.applyFilter()},250)})}renderGroups(e){return e!=null&&e.length?s.jsx(a.Select,{style:{minWidth:120,marginRight:8,marginTop:12.5},variant:"standard",value:this.state.groupKey||"_",renderValue:t=>{t==="_"&&(t="");const o=e.find(r=>r.value===t);return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(o==null?void 0:o.icon)||s.jsx("div",{style:{width:24}}),(o==null?void 0:o.name)||t]})},onChange:t=>this.setState({groupKey:t.target.value==="_"?"":t.target.value}),children:e.map(t=>s.jsxs(a.MenuItem,{value:t.value||"_",style:{display:"flex",alignItems:"center",gap:8},children:[t.icon||s.jsx("div",{style:{width:24}}),t.name]},t.value||"_"))}):null}renderContent(){var r,i;const e={padding:25};(this.props.triggerLoad||0)!==this.lastTriggerLoad&&(this.lastTriggerLoad=this.props.triggerLoad||0,setTimeout(()=>this.loadData(),50)),this.props.embedded&&this.lastPropsFilter!==this.props.filter&&(this.lastPropsFilter=this.props.filter,setTimeout(()=>this.applyFilter(),50)),this.props.embedded&&this.lastInstance!==this.props.selectedInstance&&(this.lastInstance=this.props.selectedInstance,setTimeout(()=>this.loadData(),50));const t=[];let o;if(!this.props.embedded&&!this.state.alive)o=[s.jsx("div",{style:e,children:s.jsx("span",{children:p("instanceNotAlive")})},"notAlive")];else if(!this.state.devices.length&&this.props.selectedInstance)o=[s.jsx("div",{style:e,children:s.jsx("span",{children:p("noDevicesFoundText")})},"notFound")];else if(this.state.devices.length&&!this.state.filteredDevices.length)o=[s.jsx("div",{style:e,children:s.jsx("span",{children:p("allDevicesFilteredOut")})},"filtered")];else{let l=this.state.filteredDevices;if(!this.props.embedded&&l.find(d=>d.group)){t.push({name:v.t("All"),value:"",count:l.length,icon:s.jsx(c.FilterAltOff,{})}),l.forEach(h=>{if(h.group){const u=t.find(m=>{var T;return m.value===((T=h.group)==null?void 0:T.key)});if(u)u.count++;else{const m=h.group.icon?s.jsx(Q,{src:h.group.icon}):null;t.push({name:this.getText(h.group.name||h.group.key),value:h.group.key,count:1,icon:m})}}});const d=l.filter(h=>!h.group);d.length&&t.push({name:v.t("Unknown"),value:"?",count:d.length,icon:s.jsx(c.QuestionMark,{})}),this.state.groupKey&&(this.state.groupKey==="?"?l=l.filter(h=>{var u;return!((u=h.group)!=null&&u.key)}):l=l.filter(h=>{var u;return((u=h.group)==null?void 0:u.key)===this.state.groupKey}),l.length||(o=[s.jsx("div",{style:e,children:s.jsx("span",{children:p("allDevicesFilteredOut")})},"filtered")]))}l.length&&(o=l.map(d=>s.jsx(_e,{alive:!!this.state.alive,id:d.id,title:this.getText(d.name),device:d,instanceId:this.props.selectedInstance,uploadImagesToInstance:this.props.uploadImagesToInstance,deviceHandler:this.deviceHandler,controlHandler:this.controlHandler,controlStateHandler:this.controlStateHandler,socket:this.props.socket,themeName:this.props.themeName,themeType:this.props.themeType,theme:this.props.theme,isFloatComma:this.props.isFloatComma,dateFormat:this.props.dateFormat},d.id)))}return this.props.embedded?s.jsxs(s.Fragment,{children:[this.state.loading?s.jsx(a.LinearProgress,{style:{width:"100%"}}):null,o]}):s.jsxs("div",{style:{width:"100%",height:"100%",overflow:"hidden"},children:[s.jsxs(a.Toolbar,{variant:"dense",style:{backgroundColor:"#777",display:"flex"},children:[this.props.title,this.props.selectedInstance?s.jsx(a.Tooltip,{title:p("refreshTooltip"),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:s.jsx("span",{children:s.jsx(a.IconButton,{onClick:()=>this.loadData(),disabled:!this.state.alive,size:"small",children:s.jsx(c.Refresh,{})})})}):null,this.state.alive&&((i=(r=this.state.instanceInfo)==null?void 0:r.actions)!=null&&i.length)?s.jsx("div",{style:{marginLeft:20},children:this.state.instanceInfo.actions.map(l=>s.jsx(Ee,{action:l,instanceHandler:this.instanceHandler},l.id))}):null,s.jsx("div",{style:{flexGrow:1}}),this.renderGroups(t),this.state.alive?s.jsx(a.TextField,{variant:"standard",style:{width:200},size:"small",label:p("filterLabelText"),onChange:l=>this.handleFilterChange(l.target.value),value:this.state.filter,autoComplete:"off",slotProps:{input:{autoComplete:"new-password",endAdornment:this.state.filter?s.jsx(a.InputAdornment,{position:"end",children:s.jsx(a.IconButton,{tabIndex:-1,onClick:()=>this.handleFilterChange(""),edge:"end",children:s.jsx(c.Clear,{})})}):null},htmlInput:{autoComplete:"off"}}}):null]}),s.jsxs("div",{style:{width:"100%",height:"calc(100% - 56px)",marginTop:8,overflow:"auto",...this.props.style},children:[this.state.loading?s.jsx(a.LinearProgress,{style:{width:"100%"}}):null,o]})]})}}const ar=["silly","debug","info","warn","error"],f={root:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},scroll:{height:"100%",overflowY:"auto"},instanceIcon:{width:42,height:42,marginRight:16,verticalAlign:"middle"},button:{width:36,height:36},version:{fontSize:12,opacity:.8,marginLeft:20,marginRight:10},versionAliveConnected:n=>({color:n.palette.mode==="dark"?"#23a623":"#60ff60"}),versionAliveNotConnected:{color:"#a67223"},buttonControl:{padding:"5px",transition:"opacity 0.2s",height:34},enabled:{color:K[400],"&:hover":{backgroundColor:K[200]}},disabled:{color:U[400],"&:hover":{backgroundColor:U[200]}},hide:{visibility:"hidden"},formControl:{width:"100%",marginBottom:5},logLevel:{fontSize:12,marginLeft:10},green:{color:K[700]},red:{color:U[700]},grey:{color:Te[700]},blue:{color:"#0055a9"},orange:{color:te[400]},orangeDevice:{color:te[300]},tooltip:{pointerEvents:"none"}};class fr extends L.Component{refIframe;registered;constructor(e){super(e),this.state={checkedExist:!1,showStopAdminDialog:!1,running:!1,canStart:!1,alive:!1,connected:!1,connectedToHost:!1,logOnTheFlyValue:!1,logLevel:"info",logLevelValue:"info",tempLogLevel:"info",showLogLevelDialog:!1,showMore:null},this.refIframe=null,this.registered=!1}componentDidUpdate(){var e;!this.registered&&((e=this.refIframe)!=null&&e.contentWindow)&&(this.registered=!0,this.props.onRegisterIframeRef(this.refIframe))}componentDidMount(){var e;if(this.props.tab)this.props.socket.fileExists(`${this.props.adapter}.admin`,"tab.html").then(t=>{if(t)this.setState({checkedExist:"tab.html"});else return this.props.socket.fileExists(`${this.props.adapter}.admin`,"tab_m.html").then(o=>o?this.setState({checkedExist:"tab_m.html"}):window.alert("Cannot find tab(_m).html"))});else{const t=`system.adapter.${this.props.adapter}.${this.props.instance}`;this.props.socket.subscribeObject(t,this.onObjectChange),this.props.socket.getObject(t).then(async o=>{var u,m,T,y,D,w,k;const r=await this.props.socket.getState(`${t}.logLevel`);await this.props.socket.subscribeState(`${t}.logLevel`,this.onStateChange);const i=await this.props.socket.getState(`${t}.alive`);await this.props.socket.subscribeState(`${t}.alive`,this.onStateChange);const l=await this.props.socket.getState(`${t}.connected`);await this.props.socket.subscribeState(`${t}.connected`,this.onStateChange);let d;try{d=await this.props.socket.getState(`${this.props.adapter}.${this.props.instance}.info.connection`),this.props.socket.subscribeState(`${this.props.adapter}.${this.props.instance}.info.connection`,this.onStateChange)}catch{d=null}let h;try{h=await this.props.socket.getState(`${this.props.adapter}.${this.props.instance}.info.extension`),this.props.socket.subscribeState(`${this.props.adapter}.${this.props.instance}.info.extension`,this.onStateChange)}catch{h=null}this.setState({checkedExist:!0,running:((u=o==null?void 0:o.common)==null?void 0:u.onlyWWW)||((m=o==null?void 0:o.common)==null?void 0:m.enabled),canStart:!((T=o==null?void 0:o.common)!=null&&T.onlyWWW),alive:!!(i!=null&&i.val),extension:h?!!(h!=null&&h.val):null,connectedToHost:!!(l!=null&&l.val),connected:d?!!d.val:null,logLevel:((y=o==null?void 0:o.common)==null?void 0:y.loglevel)||"info",logLevelValue:((D=o==null?void 0:o.common)==null?void 0:D.loglevel)||"info",tempLogLevel:(r==null?void 0:r.val)||((w=o==null?void 0:o.common)==null?void 0:w.loglevel)||"info",common:(o==null?void 0:o.common)||{},native:(o==null?void 0:o.native)||{},adapterDocLangs:(k=o==null?void 0:o.common)!=null&&k.docs?Object.keys(o.common.docs):["en"]})}).catch(o=>{console.error(o),this.setState({checkedExist:!0,running:!1})})}!this.registered&&((e=this.refIframe)!=null&&e.contentWindow)&&(this.registered=!0,this.props.onRegisterIframeRef(this.refIframe)),(window.addEventListener||window.attachEvent)(window.addEventListener?"message":"onmessage",this.closeConfig,!1)}onObjectChange=(e,t)=>{var o,r,i,l;e===`system.adapter.${this.props.adapter}.${this.props.instance}`&&this.setState({running:((o=t==null?void 0:t.common)==null?void 0:o.onlyWWW)||((r=t==null?void 0:t.common)==null?void 0:r.enabled),canStart:!((i=t==null?void 0:t.common)!=null&&i.onlyWWW),logLevel:((l=t==null?void 0:t.common)==null?void 0:l.loglevel)||"info"})};getInstanceStatus(){var o,r,i,l;const e=((o=this.state.common)==null?void 0:o.mode)||"";let t=e==="daemon"?"green":"blue";if((r=this.state.common)!=null&&r.enabled&&(!this.state.common.webExtension||!((i=this.state.native)!=null&&i.webInstance)||e==="daemon")){if(this.state.common.webExtension&&((l=this.state.native)!=null&&l.webInstance)&&this.state.extension!==null)return this.state.extension?"green":"red";(!this.state.connectedToHost||!this.state.alive)&&(t=e==="daemon"?"red":"orangeDevice"),this.state.connected!==null&&!this.state.connected&&t!=="red"&&(t="orange")}else t=e==="daemon"?"grey":"blue";return t}onStateChange=(e,t)=>{const o=`system.adapter.${this.props.adapter}.${this.props.instance}`;e===`${o}.alive`?this.setState({alive:!!(t!=null&&t.val)}):e===`${o}.connected`?this.setState({connectedToHost:!!(t!=null&&t.val)}):e===`${this.props.adapter}.${this.props.instance}.info.connection`?this.setState({connected:t?!!t.val:null}):e===`${this.props.adapter}.${this.props.instance}.info.extension`?this.setState({extension:t?!!t.val:null}):e===`${o}.logLevel`&&this.setState({tempLogLevel:t?t.val:null})};componentWillUnmount(){this.props.socket.unsubscribeObject(`system.adapter.${this.props.adapter}.${this.props.instance}`,this.onObjectChange),(window.removeEventListener||window.detachEvent)(window.removeEventListener?"message":"onmessage",this.closeConfig,!1),this.registered&&this.refIframe&&this.props.onUnregisterIframeRef(this.refIframe),this.refIframe=null}closeConfig=e=>{if(e.origin===window.location.origin){if(e.data==="close"||e.message==="close")this.props.easyMode?this.props.handleNavigation("easy"):this.props.handleNavigation("tab-instances");else if(e.data==="change"||e.message==="change")this.props.configStored(!1);else if(e.data==="nochange"||e.message==="nochange")this.props.configStored(!0);else if(typeof e.data=="string"&&e.data.startsWith("goto:")||typeof e.message=="string"&&e.message.startsWith("goto:")){const[,t]=(e.data||e.message).split(":"),[o,r,i]=t.split("/");this.props.handleNavigation(o,r,i)}}};renderHelpButton(){return this.props.jsonConfig?s.jsx(a.Tooltip,{title:this.props.t("Show help for this adapter"),slotProps:{popper:{sx:f.tooltip}},children:s.jsx(a.Fab,{sx:{"&.MuiFab-root":f.button},onClick:()=>{var t;const e=(t=this.state.adapterDocLangs)!=null&&t.includes(this.props.lang)?this.props.lang:"en";window.open(Ie.getDocsLinkForAdapter({lang:e,adapterName:this.props.adapter}),"help")},children:s.jsx(c.Help,{})})}):null}getConfigurator(){if(this.props.jsonConfig)return s.jsx(Ce,{expertMode:this.props.expertMode,theme:this.props.theme,width:this.props.width,adapterName:this.props.adapter,instance:this.props.instance,socket:this.props.socket,themeName:this.props.themeName,themeType:this.props.themeType,dateFormat:this.props.dateFormat,isFloatComma:this.props.isFloatComma,configStored:this.props.configStored,t:this.props.t,DeviceManager:W});const e=`adapter/${this.props.adapter}/${this.props.tab?this.state.checkedExist:this.props.materialize?"index_m.html":"index.html"}?${this.props.instance||0}&newReact=true&${this.props.instance||0}&react=${this.props.themeName}`;return this.state.checkedExist?s.jsx("iframe",{ref:t=>this&&(this.refIframe=t),title:"config",style:this.props.style,src:e}):null}returnStopAdminDialog(){return this.state.showStopAdminDialog?s.jsx($e,{title:this.props.t("Please confirm"),text:this.props.t("stop_admin",this.props.instance),ok:this.props.t("Stop admin"),onClose:e=>{e&&this.props.socket.extendObject(`system.adapter.${this.props.adapter}.${this.props.instance}`,{common:{enabled:!1}}).catch(t=>window.alert(t)),this.setState({showStopAdminDialog:!1})}}):null}renderLogLevelDialog(){return this.state.showLogLevelDialog?s.jsxs(a.Dialog,{open:!0,onClose:()=>this.setState({showLogLevelDialog:!1}),children:[s.jsx(a.DialogTitle,{children:this.props.t("Edit log level rule for %s",`${this.props.adapter}.${this.props.instance}`)}),s.jsxs(a.DialogContent,{children:[s.jsxs(a.FormControl,{style:{...f.formControl,marginTop:10},variant:"outlined",children:[s.jsx(a.InputLabel,{children:this.props.t("log level")}),s.jsx(a.Select,{variant:"standard",value:this.state.logLevelValue,fullWidth:!0,onChange:e=>this.setState({logLevelValue:e.target.value}),children:ar.map(e=>s.jsx(a.MenuItem,{value:e,children:this.props.t(e)},e))})]}),s.jsxs(a.FormControl,{style:f.formControl,variant:"outlined",children:[s.jsx(a.FormControlLabel,{control:s.jsx(a.Checkbox,{checked:this.state.logOnTheFlyValue,onChange:e=>this.setState({logOnTheFlyValue:e.target.checked})}),label:this.props.t("Without restart")}),s.jsx(a.FormHelperText,{children:this.state.logOnTheFlyValue?this.props.t("Will be reset to the saved log level after restart of adapter"):this.props.t("Log level will be saved permanently")})]})]}),s.jsxs(a.DialogActions,{children:[s.jsx(a.Button,{color:"primary",variant:"contained",onClick:()=>{this.state.logOnTheFlyValue?this.props.socket.setState(`system.adapter.${this.props.adapter}.${this.props.instance}.logLevel`,this.state.logLevelValue):this.props.socket.extendObject(`system.adapter.${this.props.adapter}.${this.props.instance}`,{common:{loglevel:this.state.logLevelValue}}).catch(e=>window.alert(`Cannot set log level: ${e}`)),this.setState({showLogLevelDialog:!1})},children:this.props.t("Ok")}),s.jsx(a.Button,{color:"grey",variant:"contained",onClick:()=>this.setState({showLogLevelDialog:!1}),children:this.props.t("Cancel")})]})]}):null}render(){const e=[this.props.version?s.jsxs("span",{style:{...f.version,...f[this.getInstanceStatus()]},children:["v",this.props.version]},"version"):null,s.jsx(a.Tooltip,{title:this.props.t("Start/stop"),slotProps:{popper:{sx:f.tooltip}},children:s.jsx("span",{children:s.jsx(a.IconButton,{size:"small",onClick:t=>{t.stopPropagation(),t.preventDefault(),this.state.running&&`${this.props.adapter}.${this.props.instance}`===this.props.adminInstance?this.setState({showStopAdminDialog:!0,showMore:null}):(this.setState({showMore:null}),this.props.socket.extendObject(`system.adapter.${this.props.adapter}.${this.props.instance}`,{common:{enabled:!this.state.running}}).catch(o=>window.alert(`Cannot set log level: ${o}`)))},onFocus:t=>t.stopPropagation(),sx:{...f.buttonControl,...this.state.canStart?this.state.running?f.enabled:f.disabled:f.hide},children:this.state.running?s.jsx(c.Pause,{}):s.jsx(c.PlayArrow,{})})})},"start"),s.jsx(a.Tooltip,{title:this.props.t("Restart"),slotProps:{popper:{sx:f.tooltip}},children:s.jsx("span",{children:s.jsx(a.IconButton,{size:"small",onClick:t=>{this.setState({showMore:null}),t.stopPropagation(),this.props.socket.extendObject(`system.adapter.${this.props.adapter}.${this.props.instance}`,{}).catch(o=>window.alert(`Cannot set log level: ${o}`))},onFocus:t=>t.stopPropagation(),style:{...f.buttonControl,...this.state.canStart?void 0:f.hide},disabled:!this.state.running,children:s.jsx(c.Refresh,{})})})},"restart"),this.state.tempLogLevel!==this.state.logLevel?s.jsx(a.Tooltip,{title:this.props.t("temporary log level"),slotProps:{popper:{sx:f.tooltip}},children:s.jsx("span",{style:f.logLevel,children:this.state.tempLogLevel})},"log"):null,s.jsx(a.Tooltip,{title:this.props.t("log level"),slotProps:{popper:{sx:f.tooltip}},children:s.jsx("span",{style:f.logLevel,children:this.state.tempLogLevel!==this.state.logLevel?`/ ${this.state.logLevel}`:this.state.logLevel})},"logLevel"),s.jsx(a.Tooltip,{title:this.props.t("Edit log level rule for %s",`${this.props.adapter}.${this.props.instance}`),children:s.jsx(a.IconButton,{size:"small",onClick:t=>{t.stopPropagation(),this.setState({showLogLevelDialog:!0,showMore:null})},onFocus:t=>t.stopPropagation(),style:{...f.buttonControl,...this.state.canStart?void 0:f.hide,width:34,height:34},children:s.jsx(c.Edit,{style:{width:20,height:20}})})},"editLog")];return s.jsxs(a.Paper,{style:f.root,children:[s.jsx(a.AppBar,{color:"default",position:"static",children:s.jsxs(a.Toolbar,{variant:"dense",style:{marginLeft:8,paddingRight:6},children:[s.jsxs(a.Typography,{variant:"h6",color:"inherit",style:{display:"flex",alignItems:"center"},children:[s.jsx(a.IconButton,{size:"small",onClick:()=>{this.props.easyMode?this.props.handleNavigation("easy"):this.props.handleNavigation("tab-instances")},onFocus:t=>t.stopPropagation(),style:{marginRight:10},children:s.jsx(c.ArrowBack,{})}),this.props.jsonConfig?s.jsx($,{src:this.props.icon,style:f.instanceIcon}):null,s.jsx(a.Box,{component:"span",sx:t=>({[t.breakpoints.down("md")]:{display:"none"},marginRight:"8px"}),children:`${this.props.t("Instance settings")}:`}),`${this.props.adapter}.${this.props.instance}`,s.jsx(a.Box,{component:"div",sx:t=>({[t.breakpoints.down("sm")]:{display:"none"}}),children:e}),s.jsxs(a.Box,{component:"span",sx:t=>({[t.breakpoints.up("sm")]:{display:"none"}}),children:[s.jsx(a.IconButton,{style:{marginLeft:8},onClick:t=>this.setState({showMore:t.currentTarget}),children:s.jsx(c.MoreVert,{})}),this.state.showMore?s.jsx(a.Menu,{open:!0,anchorEl:this.state.showMore,onClose:()=>this.setState({showMore:null}),children:e}):null]})]}),s.jsx("div",{style:{flexGrow:1}}),this.renderHelpButton()]})}),this.getConfigurator(),this.returnStopAdminDialog(),this.renderLogLevelDialog()]})}}export{fr as C};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t}from"./DefaultPropsProvider-u5xB1Fxz.js";import{i as j}from"./iobroker_admin__loadShare__react__loadShare__-Bis6NHgw.js";import{U as w,i as e,I as l,a as s}from"./bootstrap-BYQTdf9r.js";const o={modalDialog:{minWidth:400,maxWidth:800},overflowHidden:{display:"flex",overflow:"hidden"},titleIcon:{marginRight:5},content:{fontSize:16},languageButton:{position:"absolute",right:8,top:8},languageButtonActive:n=>({color:n.palette.primary.main})},H=({toggleTranslation:n,noTranslation:v,title:_,fullWidth:p,help:c,maxWidth:C,progress:u,icon:r,disableApplyIfNotChanged:b,applyButton:m,onClose:g,children:I,titleButtonApply:k,titleButtonClose:S,onApply:h,textInput:x,defaultValue:i,overflowHidden:y,disableApply:B,theme:D})=>{const[a,d]=j.useState(i);j.useEffect(()=>{d(i)},[i]);let f=null;r&&(f=r);const A=w.getStyle(D,o.languageButtonActive);return t.jsxs(e.Dialog,{open:!0,maxWidth:C||"md",fullWidth:!!p,disableEscapeKeyDown:!1,onClose:g,sx:{"& .MuiPaper-root":o.modalDialog},children:[_&&t.jsxs(e.DialogTitle,{children:[r?t.jsx(f,{style:o.titleIcon}):null,_,l.getLanguage()!=="en"&&n?t.jsx(e.IconButton,{size:"large",style:{...o.languageButton,...v?A:void 0},onClick:()=>n(),title:l.t("Disable/Enable translation"),children:t.jsx(s.Language,{})}):null]}),t.jsxs(e.DialogContent,{style:{...y?o.overflowHidden:void 0,...o.content,paddingTop:8},children:[x&&t.jsx(e.TextField,{autoComplete:"off",fullWidth:!0,autoFocus:!0,variant:"standard",size:"medium",multiline:!0,value:a,onChange:W=>d(W.target.value),slotProps:{input:{endAdornment:a?t.jsx(e.InputAdornment,{position:"end",children:t.jsx(e.IconButton,{tabIndex:-1,size:"small",onClick:()=>d(""),children:t.jsx(s.Close,{})})}):null}}}),I,c?t.jsx("div",{children:c}):null]}),t.jsxs(e.DialogActions,{children:[(m===void 0||m)&&t.jsx(e.Button,{startIcon:t.jsx(s.Check,{}),disabled:B||u||b&&i===a,onClick:()=>h&&h(x?a:""),variant:"contained",color:"primary",children:l.t(k||"Ok")}),t.jsx(e.Button,{color:"grey",onClick:g,disabled:u,variant:"contained",startIcon:t.jsx(s.Close,{}),children:l.t(S||"Cancel")})]})]})};export{H as C};
|