iobroker.eos-admin 7.9.40 → 7.9.42

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 CHANGED
@@ -178,3 +178,7 @@ node /opt/iobroker/node_modules/iobroker.eos-admin/tools/nexowatt-repair-eos-adm
178
178
  ## NexoWatt EOS v7.9.40 Update-Hinweis
179
179
 
180
180
  Diese Version korrigiert den Repository-Update-Pfad für den eigenständigen Adapter `eos-admin`. Der Repository-Eintrag muss `packetName: "iobroker.eos-admin"` enthalten, damit ioBroker beim Update nicht den falschen Paketpräfix verwendet. Technische Paketnamen in Befehls-/npm-Dialogen werden nicht mehr zu Branding-Text umgeschrieben, damit Fehlermeldungen eindeutig bleiben.
181
+
182
+ ## NexoWatt EOS v7.9.42 Force-Update-Hinweis
183
+
184
+ Dieses Paket hebt die sichtbare Adapter-Version und die EOS-Frontend-Cache-Buster auf v7.9.42 an. Es enthält den Delete-/DP-Write-Fix aus v7.9.41 und sorgt dafür, dass Browser nicht weiter die v40-Hilfsskripte verwenden.
@@ -1,7 +1,7 @@
1
1
  import{j as e}from"./DefaultPropsProvider-BiXBMQYQ.js";import{i as L,a as J}from"./iobroker_admin__loadShare__react__loadShare__-LM7uyL45.js";import{s as V,C as ut,G as gt,H as nt,L as mt,I as B,A as ft,a as xt,b as at,S as Q}from"./bootstrap-COulQZax.js";import{i as o,a as u}from"./iobroker_admin__loadShare___mf_0_mui_mf_1_icons_mf_2_material__loadShare__-CJO5yP3h.js";import{F as lt}from"./index-BmNcalFW.js";import{M as yt,s as wt,C as tt}from"./sentry-B7YeoTAx.js";import{i as m}from"./iobroker_admin__loadShare___mf_0_iobroker_mf_1_adapter_mf_2_react_mf_2_v5__loadShare__-LFZoiUTt.js";import{c as Y,A as bt}from"./AdapterUpdateDialog-BMg84Hpf.js";import{q as pt,v as jt}from"./createTheme-DFX8CY6F.js";import{b as Ct}from"./blue-CagzI6CQ.js";import{C as vt}from"./CustomModal-CqDLqryN.js";import{a as dt}from"./amber-D7aVlNg3.js";import"./_commonjsHelpers-CE1G-McA.js";import"./iobroker_admin__mf_v__runtimeInit__mf_v__-g2X2zhAf.js";import"./emotion-serialize.esm-Q4o_CgeF.js";import"./iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-BywLg1Xe.js";import"./ace-DEUjyTIn.js";import"./iobroker_admin__loadShare___mf_0_iobroker_mf_1_json_mf_2_config__loadShare__-CpA7pnS5.js";import"./iobroker_admin__loadShare__leaflet__loadShare__-CNUAG3AH.js";import"./ext-language_tools-ylAoucDh.js";import"./iobroker_admin__loadShare__react_mf_2_dropzone__loadShare__-CwjnV48g.js";import"./iobroker_admin__loadShare__react_mf_2_dom__loadShare__-CVeAXnkk.js";import"./preload-helper-BDBacUwf.js";import"./sdk-C-e-e2gd.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B0aQ9eG_.js";import"./useTheme-Bl-M1DYp.js";import"./index-DcK0RDrH.js";import"./ThemeProvider-BOFFjWAF.js";import"./emotion-cache.browser.esm-BgJfNZJN.js";import"./setYear-3ufv5yRD.js";import"./en-US-DBFJNIH6.js";import"./iconBase-2IlPecPg.js";import"./zh-cn-nUtvS7Wc.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";import"./State-qCI8JACH.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 K 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=J.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"||s==="eos-admin"||i&&this.props.repository[s].version&&i.ignoreVersion!==this.props.repository[s].version&&K.isUpdateAvailable({oldVersion:i.version,newVersion:this.props.repository[s].version,name:s})&&(Y(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`):this.props.rightDependenciesFunc(s)?t.push(s):console.log(`Adapter ${s} is filtered out from update all functionality, because its dependencies are not met`))}),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":m.Utils.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
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:m.I18n.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 c,a,g,f;const i=this.props.repository[t],r=this.props.installed[t];s=s||r.version;const n=[];let l,d;const h=this.props.repository._repoInfo;return h!=null&&h.stable?(l=(c=this.props.repository[t])==null?void 0:c.version,d=(a=this.props.repository[t])==null?void 0:a.latestVersion):(l=(g=this.props.repository[t])==null?void 0:g.stable,d=(f=this.props.repository[t])==null?void 0:f.version),r&&(i!=null&&i.news)&&Object.keys(i.news).forEach(x=>{try{if(V.gt(x,s)&&i.news[x]){const b=(this.props.noTranslation?i.news[x].en||"":i.news[x][this.props.lang]||i.news[x].en||"").split(`
3
- `).map(I=>I.trim().replace(/^\*\s?/,"").replace(/<!--[^>]*->/g,"").replace(/<! -[^>]*->/g,"").trim()).filter(I=>!!I);n.push(e.jsxs(o.Grid2,{children:[e.jsxs(o.Typography,{sx:A.versionHeader,children:[x,d===x?e.jsx(o.Box,{component:"span",sx:A.repoLatestVersionText,children:"(latest)"}):null,l===x?e.jsx(o.Box,{component:"span",sx:A.repoStableVersionText,children:`(${m.I18n.t("stable")})`}):null]}),b.map((I,T)=>e.jsx(o.Typography,{component:"div",variant:"body2",children:`• ${I}`},`${x}-${T}`))]},x))}}catch{console.warn(`Cannot compare "${x}" and "${s}"`)}}),n}renderShowNews(){if(this.state.showNews){const t=this.getReactNews(this.state.showNews.adapter,this.state.showNews.fromVersion),s=m.Utils.getStyle(this.props.theme,A.closeButton),i=m.Utils.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:m.I18n.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,{})}),m.I18n.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:m.I18n.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:m.I18n.t("Change log")}),e.jsx(o.Grid2,{container:!0,spacing:2,direction:"column",wrap:"nowrap",children:t})]}):m.I18n.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:m.I18n.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 _={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 Tt 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].sort((t,s)=>t==="eos-admin"?1:s==="eos-admin"?-1:t.localeCompare(s)).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?m.Utils.getStyle(this.props.theme,_.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":_.dialogRoot},scroll:"paper",children:[e.jsx(o.DialogTitle,{id:"update-dialog-title",children:e.jsxs("div",{style:_.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:_.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})}})}),m.I18n.getLanguage()!=="en"&&this.props.toggleTranslation?e.jsx(o.IconButton,{size:"large",style:{..._.languageButton,...t},onClick:()=>this.props.toggleTranslation(),title:m.I18n.t("Disable/Enable translation"),children:e.jsx(u.Language,{})}):null]})}),e.jsxs(o.DialogContent,{sx:{"&.MuiDialogContent-root":_.content},style:{height:"100%"},children:[e.jsxs(o.Grid2,{container:!0,direction:"row",sx:_.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(K,{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,rightDependenciesFunc:this.props.rightDependenciesFunc})})}),!!this.state.current&&e.jsx(o.Grid2,{style:{height:"100%",overflow:"hidden",width:"calc(100% - 260px)",minWidth:240},children:e.jsx(ut,{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:_.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 et extends gt{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 At="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 St(p){return new Promise((t,s)=>{const i=new FileReader;i.onload=()=>{const r=i.result,n=r.indexOf(",");t(n===-1?r:r.substring(n+1))},i.onerror=()=>s(i.error),i.readAsDataURL(p)})}function z(p){return{id:`github-install-dialog-tab-${p}`,"aria-controls":`github-install-dialog-panel-${p}`}}const j={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 It(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 st=10;class kt extends J.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,selectedFile:null,restartAfterInstall:(window._localstorage||window.localStorage).getItem("App.restartAfterInstall")!=="false",uploading:!1,selectedHost:t.currentHost,cmdExecFilesSupported:!1}}async componentDidMount(){try{const t=await this.props.socket.checkFeatureSupported("CONTROLLER_CMD_EXEC_FILES");this.setState({cmdExecFilesSupported:!!t})}catch(t){console.error(`Cannot read feature: ${t}`)}}async uploadFileToServer(){if(!this.state.selectedFile)return null;this.setState({uploading:!0});try{const t=new FormData;t.append("file",this.state.selectedFile);const s=await fetch("./upload-adapter",{method:"POST",body:t});if(!s.ok){let r;try{r=(await s.json()).error||`Upload failed with status ${s.status}`}catch{r=`Upload failed with status ${s.status}`}throw new Error(r)}return(await s.json()).filePath}catch(t){return window.alert(`${m.I18n.t("Upload failed")}: ${t.message}`),null}finally{this.setState({uploading:!1})}}async restartInstances(t){var i;if(!this.state.restartAfterInstall||!t)return;const s=await this.props.socket.getAdapterInstances(t);for(const r of s)(i=r==null?void 0:r.common)!=null&&i.enabled&&await this.props.socket.extendObject(r._id,{})}async installFile(){if(!this.state.selectedFile)return;const t=this.state.selectedFile.name.match(/iobroker\.(.+?)-\d+\.\d+\.\d+/i),s=t?t[1]:"";if(this.state.cmdExecFilesSupported){try{const r=await St(this.state.selectedFile),n=this.state.selectedFile.name.replace(/[^a-zA-Z0-9._-]/g,"_");await this.props.installFromUrl(n,this.state.debug,!0,{host:this.state.selectedHost,files:[{name:n,file:r}]}),await this.restartInstances(s)}catch(r){console.error(`Installation from file failed: ${r.message}`)}return}const i=await this.uploadFileToServer();if(i)try{await this.props.installFromUrl(i,this.state.debug,!0),await this.restartInstances(s)}catch(r){console.error(`Installation from file failed: ${r.message}`)}}async handleInstall(){var t,s;if(this.state.currentTab==="GitHub"){const i=(((t=this.state.autoCompleteValue)==null?void 0:t.value)||"").split("/"),r=`${i[1]}/ioBroker.${i[0]}`;await this.props.installFromUrl(r,this.state.debug,!0)}else if(this.state.currentTab==="URL"){const i=this.state.customHistory.filter(r=>r!==this.state.url);i.unshift(this.state.url),i.length>st&&i.pop(),(window._localstorage||window.localStorage).setItem("App.npmHistory",JSON.stringify(i)),this.state.url.includes(".")?await this.props.installFromUrl(this.state.url,this.state.debug,!0):await this.props.installFromUrl(`iobroker.${this.state.url}`,this.state.debug,!0)}else if(this.state.currentTab==="File")await this.installFile();else if(this.state.currentTab==="npm"){const i=(((s=this.state.autoCompleteValue)==null?void 0:s.value)||"").split("/")[0],r=i.includes(".")?i.split(".")[1]:i;try{await this.props.installFromUrl(`iobroker.${r}@latest`,this.state.debug,!0),this.props.upload(r)}catch(n){console.error(`Installation from url failed: ${n.message}`)}}}renderNpm(){return this.state.currentTab==="npm"?e.jsxs(o.Paper,{style:j.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(m.Icon,{src:((i=this.state.autoCompleteValue)==null?void 0:i.icon)||"",style:j.listIcon})}),e.jsx(o.TextField,{variant:"standard",...t,label:m.I18n.t("Select adapter")})},renderOption:(t,s)=>e.jsxs(o.Box,{component:"li",sx:{"& > img":{mr:2,flexShrink:0}},...t,children:[e.jsx(m.Icon,{src:(s==null?void 0:s.icon)||"",style:j.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:j.warningText,children:this.props.t("npm_warning","NPM","NPM")}),e.jsx("div",{style:j.noteText,children:this.props.t("github_note")})]}):null}renderGitHub(){return this.state.currentTab==="GitHub"?e.jsxs(o.Paper,{style:j.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(m.Icon,{src:(s==null?void 0:s.icon)||"",style:j.listIconWithMargin}),(s==null?void 0:s.name)??"",(s==null?void 0:s.nogit)&&e.jsx("div",{style:j.errorTextNoGit,children:m.I18n.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(m.Icon,{src:((i=this.state.autoCompleteValue)==null?void 0:i.icon)||"",style:j.listIconWithMargin})}),e.jsx(o.TextField,{variant:"standard",...t,label:m.I18n.t("Select adapter")})}})]}),e.jsx("div",{style:{fontSize:24,fontWeight:"bold",marginTop:40},children:this.props.t("Warning!")}),e.jsx("div",{style:j.warningText,children:this.props.t("github_warning","GitHub","GitHub")}),e.jsx("div",{style:j.noteText,children:this.props.t("github_note")})]}):null}renderCustom(){return this.state.currentTab==="URL"?e.jsxs(o.Paper,{style:j.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>st&&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:j.warningText,children:this.props.t("github_warning","URL","URL")}),e.jsx("div",{style:j.noteText,children:this.props.t("github_note")})]}):null}renderFile(){return this.state.currentTab==="File"?e.jsxs(o.Paper,{style:j.tabPaper,id:"github-install-dialog-panel-file",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs(o.Button,{variant:"outlined",component:"label",startIcon:e.jsx(u.Publish,{}),disabled:this.state.uploading,children:[this.props.t("Select file"),e.jsx("input",{type:"file",accept:".tgz",hidden:!0,onChange:t=>{var i;const s=((i=t.target.files)==null?void 0:i[0])||null;this.setState({selectedFile:s,url:""}),(window._localstorage||window.localStorage).setItem("App.userUrl",""),t.target.value=""}})]}),this.state.selectedFile&&e.jsxs(e.Fragment,{children:[e.jsx(o.Typography,{variant:"body2",style:{flex:1},children:this.state.selectedFile.name}),e.jsx(o.IconButton,{size:"small",onClick:()=>this.setState({selectedFile:null}),children:e.jsx(u.Close,{})})]}),this.state.uploading&&e.jsx(o.CircularProgress,{size:24})]}),this.state.selectedFile&&e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:this.state.restartAfterInstall,onChange:t=>{(window._localstorage||window.localStorage).setItem("App.restartAfterInstall",t.target.checked?"true":"false"),this.setState({restartAfterInstall:t.target.checked})}}),label:this.props.t("Restart adapter after install")}),this.state.cmdExecFilesSupported&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:8},children:[e.jsxs(o.Typography,{variant:"body2",children:[this.props.t("Install on host"),":"]}),e.jsx(nt,{socket:this.props.socket,currentHost:this.state.selectedHost,hostsWorker:this.props.hostsWorker,expertMode:this.props.expertMode,themeType:this.props.themeType,tooltip:this.props.t("Install on host"),setCurrentHost:(t,s)=>this.setState({selectedHost:s})})]}),e.jsx("div",{style:{fontSize:24,fontWeight:"bold",marginTop:40},children:this.props.t("Warning!")}),e.jsx("div",{style:j.warningText,children:this.props.t("github_warning","File","File")}),e.jsx("div",{style:j.noteText,children:this.props.t("github_note")})]}):null}getList(){const t=this.props.categories.map(i=>i.adapters),s=It(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 l=(n.extIcon||n.meta||n.readme||"").toString().split("/");let d=n==null?void 0:n.name;d||(d=n.titleLang,d&&typeof d=="object"?d=d[m.I18n.getLanguage()]||d.en:d=n.title||i);const h={value:`${i}/${l[3]}`,name:`${d} [${l[3]}]`,icon:n.extIcon||n.icon,nogit:!!n.nogit,title:i};return this.props.installed[d]&&d!=="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:"",selectedFile:null,uploading:!1});return e.jsxs(o.Dialog,{onClose:()=>this.props.onClose(),open:!0,sx:{"& .MuiDialog-paper":j.paper},children:[e.jsx(o.DialogContent,{dividers:!0,children:e.jsxs(o.Box,{component:"div",sx:j.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":j.tabSelected},icon:e.jsx("img",{src:At,alt:"npm",width:24,height:24}),...z("npm"),value:"npm"}),e.jsx(o.Tab,{label:this.props.t("From github"),wrapped:!0,sx:{"&.Mui-selected":j.tabSelected},icon:e.jsx(lt,{style:{width:24,height:24},width:24,height:24}),...z("github"),value:"GitHub"}),e.jsx(o.Tab,{label:this.props.t("Custom"),wrapped:!0,sx:{"&.Mui-selected":j.tabSelected},icon:e.jsx(u.Language,{width:24,height:24}),...z("custom"),value:"URL"}),e.jsx(o.Tab,{label:this.props.t("From file"),wrapped:!0,sx:{"&.Mui-selected":j.tabSelected},icon:e.jsx(u.UploadFile,{style:{width:24,height:24}}),...z("file"),value:"File"})]})}),e.jsx(o.Box,{component:"div",sx:j.title,children:this.props.t("Install or update the adapter from %s",this.state.currentTab||"npm")}),this.renderNpm(),this.renderGitHub(),this.renderCustom(),this.renderFile()]})}),e.jsxs(o.DialogActions,{children:[e.jsx(o.Button,{id:"github-install-dialog-ok",variant:"contained",disabled:this.state.uploading||this.props.commandRunning||(this.state.currentTab==="GitHub"||this.state.currentTab==="npm")&&!((s=this.state.autoCompleteValue)!=null&&s.value)||this.state.currentTab==="URL"&&!this.state.url||this.state.currentTab==="File"&&!this.state.selectedFile,autoFocus:!0,onClick:async()=>{await this.handleInstall(),this.props.onClose(),t()},color:"primary",startIcon:this.props.commandRunning?e.jsx(o.CircularProgress,{size:20}):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 N={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 Dt extends L.Component{t;messages=null;lang;constructor(t){super(t),this.state={instanceNumbers:[]},this.t=t.t,this.lang=m.I18n.getLanguage(),this.messages=Y(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:N[`messageTitle_${t.level||"warn"}`],children:this.getText(t.title,this.props.noTranslation)||""}),e.jsx(o.Typography,{component:"div",variant:"body2",style:N.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":N.paper},children:[e.jsx(o.DialogTitle,{children:e.jsxs(o.Typography,{component:"h2",variant:"h6",sx:{"&.MuiTypography-root":N.typography},children:[this.t("You are going to add new instance:")," ",this.props.adapter,e.jsx(o.IconButton,{size:"large",sx:N.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:m.Utils.getStyle(this.props.theme,N.languageButton,this.props.noTranslation&&N.languageButtonActive),onClick:this.props.toggleTranslation,title:m.I18n.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(nt,{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:N.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:N.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 Z(p){var s;if(!p)return"";if((s=p.licenseInformation)!=null&&s.link)return p.licenseInformation.link;let t=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 P 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(mt,{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?P.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=Y(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=(t.host||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(),t.files)})}catch(i){window.alert(`${m.I18n.t("Cannot install")}: ${i}`)}}static getDependencies(t,s){var n,l;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 d=i.node;if((n=i.dependencies)!=null&&n.length)for(const c of i.dependencies){const a={name:"",version:null,installed:!1,installedVersion:null,rightVersion:!1},g=typeof c!="string",f=Object.keys(c);if(a.name=g?f?f[0]:null:c,a.version=g?c[a.name]:null,a.name){const x=s.installed[a.name];a.installed=!!x,a.installedVersion=x?x.version:null;try{a.rightVersion=x?g?V.satisfies(x.version,a.version,{includePrerelease:!0}):!0:!1}catch{a.rightVersion=!0}}r.push(a)}if((l=i.globalDependencies)!=null&&l.length)for(const c of i.globalDependencies){const a={name:"",version:null,installed:!1,installedVersion:null,rightVersion:!1},g=typeof c!="string",f=Object.keys(c);if(a.name=g?f?f[0]:null:c,a.version=g?c[a.name]:null,a.name){const x=s.installedGlobal[a.name];a.installed=!!x,a.installedVersion=x?x.version:null;try{a.rightVersion=x?g?V.satisfies(x.version,a.version,{includePrerelease:!0}):!0:!1}catch{a.rightVersion=!0}}r.push(a)}const h=i.ifInstalledDependencies;if(h&&typeof h=="object"&&!Array.isArray(h)){const c=Object.keys(h);for(const a of c){const g={name:a,version:h[a],installed:!1,installedVersion:null,rightVersion:!1};if(g.name){const f=s.installedGlobal[g.name];g.installed=!!f,g.installedVersion=f?f.version:null;try{g.rightVersion=f?V.satisfies(f.version,g.version,{includePrerelease:!0}):!0}catch{g.rightVersion=!0}}r.push(g)}}if(d){const c={name:"node",version:d,installed:!0,installedVersion:s.nodeJsVersion,rightVersion:!1};try{c.rightVersion=V.satisfies(s.nodeJsVersion,d)}catch{c.rightVersion=!0}r.push(c)}}return r}renderAddInstanceDialog(t){return this.state.addInstanceDialog?e.jsx(Dt,{adapter:this.state.addInstanceDialog,socket:t.socket,hostsWorker:t.hostsWorker,instancesWorker:t.instancesWorker,dependencies:P.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 l;const i=s.repository[t],r=Z(i),n=((l=i.licenseInformation)==null?void 0:l.license)||i.license;n==="MIT"||n==="Apache-2.0"||n==="ISC"||n==="BSD-3-Clause"||n==="BSD-2-Clause"||!n?this.addInstance({adapterName:t,context:s}).catch(d=>window.alert(`Cannot add instance: ${d}`)):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 M={name:{flexWrap:"nowrap",width:300,marginTop:0},nameDiv:{display:"flex",alignItems:"center"},categoryName:{fontWeight:"bold",cursor:"pointer"},green:{color:pt[500]},blue:{color:Ct[700]},category:{backgroundColor:"background.default"},marginRight5:{marginRight:5}};function Vt(p){const{installedCount:t,name:s,categoryName:i}=p;return e.jsxs(o.TableRow,{hover:!1,sx:M.category,children:[e.jsx(o.TableCell,{children:e.jsx(o.Grid2,{container:!0,spacing:1,alignItems:"center",style:M.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:{...M.nameDiv,...M.categoryName},children:[e.jsx(yt,{iconName:i,style:M.marginRight5}),s]})}),e.jsxs(o.TableCell,{colSpan:p.descHidden?5:6,children:[e.jsx(o.Typography,{component:"span",variant:"body2",style:M.green,children:t}),` ${p.t("of")} `,e.jsx(o.Typography,{component:"span",variant:"body2",style:M.blue,children:p.count}),` ${p.t("Adapters from this Group installed")}`]})]})}const S={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"}},it=[{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 Rt 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.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(l=>l.json()).then(l=>(window.alert(`${this.props.t("Vote:")} ${t}@${s}=${i}`),delete l.adapter,l)).catch(l=>(window.alert(`Cannot vote: ${l}`),null))}renderInfoText(){return e.jsxs("div",{style:S.infoTextContainer,children:[e.jsx(u.Info,{}),e.jsx(o.Typography,{style:S.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:S.listTitle,children:this.props.t("Comments")}),e.jsxs(o.FormControl,{variant:"standard",style:S.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:S.commentCount,children:this.state.votings.comments.length})]}),it.map(i=>e.jsxs(o.MenuItem,{value:i.id,children:[i.title," ",this.state.commentsByLanguage[i.id]?e.jsx("span",{style:S.commentCount,children:this.state.commentsByLanguage[i.id]}):null]},i.id))]})]}),e.jsxs(o.List,{style:S.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?S.listOwn:void 0},dense:!0,children:[e.jsx(o.ListItemAvatar,{style:S.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":S.listTime}})]},r):null),!s&&e.jsx("div",{style:S.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 l=this.state.votings.rating;s=Object.keys(l),s.sort((d,h)=>l[d].ts>l[h].ts?-1:l[d].ts<l[h].ts?1:0),s.length&&(t=l[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:S.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:(l,d)=>this.setState({ratingNumber:d})}),this.props.version?e.jsxs("div",{style:{width:"100%",textAlign:"left"},children:[e.jsx(o.TextField,{variant:"standard",style:S.ratingTextControl,value:this.state.ratingComment,label:this.props.t("Comment to version"),helperText:this.props.t("Max length %s characters",200),onChange:l=>this.setState({ratingComment:l.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:S.ratingLanguageControl,children:[e.jsx(o.InputLabel,{children:this.props.t("Language")}),e.jsx(o.Select,{variant:"standard",value:this.state.ratingLang,onChange:l=>this.setState({ratingLang:l.target.value}),children:it.map(l=>e.jsx(o.MenuItem,{value:l.id,children:l.title},l.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(l=>this.props.onClose(l)):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 ot={closeButton:p=>({position:"absolute",right:8,top:8,color:p.palette.grey[500]}),typography:{paddingRight:30}};class Lt 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":ot.typography},children:[this.t("Please confirm"),e.jsx(o.IconButton,{size:"large",sx:ot.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 ct={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 Ut extends J.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:m.I18n.t("Auto upgrade policy for %s",this.props.adapter)}),e.jsxs(o.DialogContent,{style:{padding:"0 20px",overflow:"hidden"},children:[e.jsx(B,{value:!this.state.supported,children:e.jsx(o.Typography,{children:m.I18n.t("This feature is supported up from js-controller Kiera (Version 6)!")})}),e.jsxs(B,{value:this.state.supported,children:[e.jsx(o.Typography,{children:m.I18n.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:ft.map(t=>e.jsx(o.MenuItem,{value:t,children:e.jsxs("div",{style:{display:"flex",gap:8},children:[ct[t],xt[t]]})},t))}),e.jsx(B,{value:this.state.repositories.includes("beta")&&this.state.policy!=="none",children:e.jsx(m.InfoBox,{type:"warning",children:m.I18n.t("repo_update_hint")})}),e.jsx(B,{value:this.state.policy==="major",children:e.jsx(m.InfoBox,{type:"warning",children:m.I18n.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:m.I18n.t("Save")}),e.jsx(o.Button,{variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:e.jsx(u.Close,{}),children:m.I18n.t("Close")})]})]})}}const ht={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:jt[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:dt[500]},cardContentFlexBetween:{},cardContentFlex:{}};class H extends P{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:l=>{l.target&&(l.target.onerror=null,l.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(B,{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,{}):ct[s]})})}renderReadmeButton(){const t=this.props.context.repository[this.props.adapterName]?this.props.context.repository[this.props.adapterName].allowAdapterReadme:!0;return e.jsx(B,{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,title:t,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})}):e.jsx("div",{style:{width:24,height:24}})}):null}renderLicenseInfo(t=!1){var n,l,d,h;const s=this.props.context.repository[this.props.adapterName],i=Z(s),r=(n=s.licenseInformation)!=null&&n.type?e.jsx(o.Link,{href:i,target:"_blank",rel:"noopener",sx:(c=>({color:c.palette.mode==="dark"?"white":"black","&:hover":{color:c.palette.mode==="dark"?"white":"black"}})),children:((l=s.licenseInformation)==null?void 0:l.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,{})}):((d=s.licenseInformation)==null?void 0:d.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})}):((h=s.licenseInformation)==null?void 0:h.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;return!r&&t?e.jsx("div",{style:{width:24,height:24}}):r}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:wt})})}):null}getDependencies(){const t=P.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.length?(s.unshift(this.props.context.t("Wrong dependencies")),s.map((i,r)=>e.jsx("div",{style:r?void 0:{fontWeight:"bold",fontSize:"larger"},children:i},i))):null}renderVersion(){const t=this.props.context.repository[this.props.adapterName]?this.props.context.repository[this.props.adapterName].allowAdapterUpdate:!0,s=this.props.context.repository[this.props.adapterName],i=s==null?void 0:s.version;return i?!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,{})}),i]})}):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:i})}):e.jsx("span",{style:this.styles.wrongDependencies,children:this.props.context.t("not maintained")})}static extractGitHubCommitHash(t){if(!t)return null;const s=t.indexOf("#");if(s===-1)return null;const i=t.substring(s+1);return i.length>=7?i.substring(0,7):i}renderInstalledVersion(t){var h,c;const s=this.props.context.installed[this.props.adapterName],i=(c=(h=this.props.context.adapters[`system.adapter.${this.props.adapterName}`])==null?void 0:h.common)==null?void 0:c.installedFrom,{adapterName:r}=this.props,n=i&&!i.startsWith(`iobroker.${r}@`),l=n?H.extractGitHubCommitHash(i):null,d=n&&l?`${this.installedVersion}+${l}`:this.installedVersion;if(t){const a=s==null?void 0:s.enabled,g=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:d+(g?` (${g}${g!==a?"~":""})`:"")}):null,n&&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:[n&&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})}),d]})]}):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(B,{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(Ut,{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(bt,{adapter:this.props.adapterName,adapterObject:this.props.context.repository[this.props.adapterName],t:this.props.context.t,dependencies:P.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,l,d;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=(l=this.props.context.repository[this.props.adapterName])==null?void 0:l.stable,s=(d=this.props.context.repository[this.props.adapterName])==null?void 0:d.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:c})=>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:m.Utils.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:H.formatNews(c)})]})},h))})]})})}renderSetRatingDialog(){return this.state.showSetRating?e.jsx(Rt,{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(Lt,{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(at.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 l;typeof s.news[n]=="object"?l=this.props.noTranslation?s.news[n].en:s.news[n][this.props.context.lang]||s.news[n].en:l=s.news[n],r.push({version:n,news:l})}}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=Z(t),i=((r=t.licenseInformation)==null?void 0:r.license)||t.license;i!=="MIT"&&i!=="Apache-2.0"&&i!=="ISC"&&i!=="BSD-3-Clause"&&i!=="BSD-2-Clause"&&i?this.setState({showLicenseDialog:{url:s,upload:!0,adapterName:this.props.adapterName,licenseType:i},showDialog:!0}):P.upload(this.props.adapterName,this.props.context)}delete(t){if(window.NEXOWATT_EOS_SECURITY&&window.NEXOWATT_EOS_SECURITY.shouldBlockAdapterDelete(this.props.adapterName)){window.alert("Dieser Adapter ist durch NexoWatt EOS geschützt. Nur die Administrator-Gruppe darf ihn löschen.");return}this.props.context.executeCommand(`del ${this.props.adapterName}${t?" --custom":""}${this.props.context.expertMode?" --debug":""}`)}async update(t){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 Ot="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)",Bt="0 8px 17px 0 rgba(0, 0, 0, .2),0 6px 20px 0 rgba(0, 0, 0, .19)",Nt={...ht,type:{color:"tile"},root:p=>({position:"relative",m:"10px",width:300,minHeight:200,background:p.palette.background.default,boxShadow:Ot,display:"flex",flexDirection:"column",transition:"box-shadow 0.5s","&:hover":{boxShadow:Bt}}),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:dt[500],marginRight:5},rating:{marginTop:20}};class Ft extends H{styles=Nt;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:m.Utils.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=>H.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:m.Utils.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(B,{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:m.Utils.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 $t={...ht,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 _t extends H{styles=$t;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:{width:24,height:24}}),this.renderDataSource()||e.jsx("div",{style:{marginLeft:5,width:24,height:24}}),this.renderSentryInfo()||e.jsx("div",{style:{marginLeft:5,width:24,height:24}}),this.renderLicenseInfo(!0)]})}),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 q=246,F={emptyBlock:50,name:300,connectionType:120,installed:120,available:120,update:40,license:80,install:q},G=Object.keys(F).reduce((p,t)=>p+F[t],0),k={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:F.name},emptyBlock:{flexWrap:"nowrap",width:F.emptyBlock},description:{width:`calc(100% - ${G+2}px)`},connectionType:{width:F.connectionType},installed:{width:F.installed},available:{width:F.available,paddingRight:6},license:{width:F.license},install:{width:F.install},viewModeDiv:{display:"flex",flexFlow:"wrap",overflow:"auto",justifyContent:"center"}};class Pt 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(_t,{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 l=this.props.listOfVisibleAdapter[n];i.length>50&&!((r=this.props.context.installed[l])!=null&&r.version)||i.push(this.getRow(l,t))}if(s=i.length,s&&this.props.listOfVisibleAdapter.length>i.length){const n=this.props.listOfVisibleAdapter.length-i.length,l=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:l})},"more"))}}else i=this.props.categories.map(n=>{if(!n.adapters.find(c=>this.props.listOfVisibleAdapter.includes(c)))return null;const d=n.name,h=this.props.categoriesExpanded[d];return s++,e.jsxs(L.Fragment,{children:[e.jsx(Vt,{categoryName:d,count:n.count,expanded:h,installedCount:n.installed,name:n.translation,descHidden:t.descHidden,onToggle:()=>this.props.toggleCategory(d),t:this.props.context.t},`category-${d}1`),h&&n.adapters.map(c=>{const a=this.getRow(c,t);return a&&s++,a})]},`category-${d} ${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],l=this.props.cachedAdapters[n];s.length>50&&!((i=this.props.context.installed[n])!=null&&i.version)||s.push(e.jsx(Ft,{context:t,adapterName:n,cached:l,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||String(s||"").toLowerCase()==="nexowatt"?null:e.jsx(o.Box,{sx:{marginX:2,marginTop:1,width:"calc(100% - 32px)"},children:e.jsx(m.InfoBox,{type:"warning",children:this.props.context.t('Active repo is "%s"',s)})}),e.jsx("div",{style:k.viewModeDiv,children:this.getTiles(i)})]})}renderTableView(t,s,i){return e.jsxs(m.TabContent,{children:[t||String(s||"").toLowerCase()==="nexowatt"?null:e.jsx(o.Box,{sx:{marginX:2,marginTop:1,width:"calc(100% - 32px)"},children:e.jsx(m.InfoBox,{type:"warning",children:this.props.context.t('Active repo is "%s"',s)})}),e.jsx(o.TableContainer,{style:{...k.container,...t?k.containerFullHeight:k.containerNotFullHeight},children:e.jsxs(o.Table,{stickyHeader:!0,size:"small",sx:k.table,children:[e.jsx(o.TableHead,{children:e.jsxs(o.TableRow,{children:[e.jsx(o.TableCell,{style:k.emptyBlock}),e.jsx(o.TableCell,{style:k.name,children:e.jsx(o.Typography,{children:this.props.context.t("Name")})}),!i.descHidden&&e.jsx(o.TableCell,{style:{...k.description,width:this.props.descWidth},children:e.jsx(o.Typography,{children:this.props.context.t("Description")})}),e.jsx(o.TableCell,{style:k.connectionType}),e.jsx(o.TableCell,{style:k.installed,children:e.jsx(o.Typography,{children:this.props.context.t("Installed")})}),e.jsx(o.TableCell,{style:k.available,children:e.jsx(o.Typography,{children:this.props.context.t("Available")})}),e.jsx(o.TableCell,{style:k.license,children:e.jsx(o.Typography,{children:this.props.context.t("License")})}),e.jsx(o.TableCell,{style:{...k.install,width:this.state.expertMode?q:q-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 l=JSON.stringify(t.listOfVisibleAdapter);return l!==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:l,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 Wt 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=J.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:"eos-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:[m.I18n.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(m.I18n.t("%s was successfully updated to %s","eos-admin",this.props.version))):i!=null&&i.stdout&&(i.stdout.unshift(""),i.stdout.unshift("---------------------------------------------------"),i.stdout.unshift(m.I18n.t("updating %s to %s...","eos-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:(l,d)=>{d!=="escapeKeyDown"&&d!=="backdropClick"&&this.props.onClose()},open:!0,maxWidth:"lg",fullWidth:!0,children:[e.jsx(o.DialogTitle,{children:m.I18n.t("Updating %s...","eos-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(`
3
+ `).map(I=>I.trim().replace(/^\*\s?/,"").replace(/<!--[^>]*->/g,"").replace(/<! -[^>]*->/g,"").trim()).filter(I=>!!I);n.push(e.jsxs(o.Grid2,{children:[e.jsxs(o.Typography,{sx:A.versionHeader,children:[x,d===x?e.jsx(o.Box,{component:"span",sx:A.repoLatestVersionText,children:"(latest)"}):null,l===x?e.jsx(o.Box,{component:"span",sx:A.repoStableVersionText,children:`(${m.I18n.t("stable")})`}):null]}),b.map((I,T)=>e.jsx(o.Typography,{component:"div",variant:"body2",children:`• ${I}`},`${x}-${T}`))]},x))}}catch{console.warn(`Cannot compare "${x}" and "${s}"`)}}),n}renderShowNews(){if(this.state.showNews){const t=this.getReactNews(this.state.showNews.adapter,this.state.showNews.fromVersion),s=m.Utils.getStyle(this.props.theme,A.closeButton),i=m.Utils.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:m.I18n.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,{})}),m.I18n.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:m.I18n.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:m.I18n.t("Change log")}),e.jsx(o.Grid2,{container:!0,spacing:2,direction:"column",wrap:"nowrap",children:t})]}):m.I18n.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:m.I18n.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 _={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 Tt 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].sort((t,s)=>t==="eos-admin"?1:s==="eos-admin"?-1:t.localeCompare(s)).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?m.Utils.getStyle(this.props.theme,_.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":_.dialogRoot},scroll:"paper",children:[e.jsx(o.DialogTitle,{id:"update-dialog-title",children:e.jsxs("div",{style:_.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:_.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})}})}),m.I18n.getLanguage()!=="en"&&this.props.toggleTranslation?e.jsx(o.IconButton,{size:"large",style:{..._.languageButton,...t},onClick:()=>this.props.toggleTranslation(),title:m.I18n.t("Disable/Enable translation"),children:e.jsx(u.Language,{})}):null]})}),e.jsxs(o.DialogContent,{sx:{"&.MuiDialogContent-root":_.content},style:{height:"100%"},children:[e.jsxs(o.Grid2,{container:!0,direction:"row",sx:_.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(K,{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,rightDependenciesFunc:this.props.rightDependenciesFunc})})}),!!this.state.current&&e.jsx(o.Grid2,{style:{height:"100%",overflow:"hidden",width:"calc(100% - 260px)",minWidth:240},children:e.jsx(ut,{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:_.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 et extends gt{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 At="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 St(p){return new Promise((t,s)=>{const i=new FileReader;i.onload=()=>{const r=i.result,n=r.indexOf(",");t(n===-1?r:r.substring(n+1))},i.onerror=()=>s(i.error),i.readAsDataURL(p)})}function z(p){return{id:`github-install-dialog-tab-${p}`,"aria-controls":`github-install-dialog-panel-${p}`}}const j={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 It(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 st=10;class kt extends J.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,selectedFile:null,restartAfterInstall:(window._localstorage||window.localStorage).getItem("App.restartAfterInstall")!=="false",uploading:!1,selectedHost:t.currentHost,cmdExecFilesSupported:!1}}async componentDidMount(){try{const t=await this.props.socket.checkFeatureSupported("CONTROLLER_CMD_EXEC_FILES");this.setState({cmdExecFilesSupported:!!t})}catch(t){console.error(`Cannot read feature: ${t}`)}}async uploadFileToServer(){if(!this.state.selectedFile)return null;this.setState({uploading:!0});try{const t=new FormData;t.append("file",this.state.selectedFile);const s=await fetch("./upload-adapter",{method:"POST",body:t});if(!s.ok){let r;try{r=(await s.json()).error||`Upload failed with status ${s.status}`}catch{r=`Upload failed with status ${s.status}`}throw new Error(r)}return(await s.json()).filePath}catch(t){return window.alert(`${m.I18n.t("Upload failed")}: ${t.message}`),null}finally{this.setState({uploading:!1})}}async restartInstances(t){var i;if(!this.state.restartAfterInstall||!t)return;const s=await this.props.socket.getAdapterInstances(t);for(const r of s)(i=r==null?void 0:r.common)!=null&&i.enabled&&await this.props.socket.extendObject(r._id,{})}async installFile(){if(!this.state.selectedFile)return;const t=this.state.selectedFile.name.match(/iobroker\.(.+?)-\d+\.\d+\.\d+/i),s=t?t[1]:"";if(this.state.cmdExecFilesSupported){try{const r=await St(this.state.selectedFile),n=this.state.selectedFile.name.replace(/[^a-zA-Z0-9._-]/g,"_");await this.props.installFromUrl(n,this.state.debug,!0,{host:this.state.selectedHost,files:[{name:n,file:r}]}),await this.restartInstances(s)}catch(r){console.error(`Installation from file failed: ${r.message}`)}return}const i=await this.uploadFileToServer();if(i)try{await this.props.installFromUrl(i,this.state.debug,!0),await this.restartInstances(s)}catch(r){console.error(`Installation from file failed: ${r.message}`)}}async handleInstall(){var t,s;if(this.state.currentTab==="GitHub"){const i=(((t=this.state.autoCompleteValue)==null?void 0:t.value)||"").split("/"),r=`${i[1]}/ioBroker.${i[0]}`;await this.props.installFromUrl(r,this.state.debug,!0)}else if(this.state.currentTab==="URL"){const i=this.state.customHistory.filter(r=>r!==this.state.url);i.unshift(this.state.url),i.length>st&&i.pop(),(window._localstorage||window.localStorage).setItem("App.npmHistory",JSON.stringify(i)),this.state.url.includes(".")?await this.props.installFromUrl(this.state.url,this.state.debug,!0):await this.props.installFromUrl(`iobroker.${this.state.url}`,this.state.debug,!0)}else if(this.state.currentTab==="File")await this.installFile();else if(this.state.currentTab==="npm"){const i=(((s=this.state.autoCompleteValue)==null?void 0:s.value)||"").split("/")[0],r=i.includes(".")?i.split(".")[1]:i;try{await this.props.installFromUrl(`iobroker.${r}@latest`,this.state.debug,!0),this.props.upload(r)}catch(n){console.error(`Installation from url failed: ${n.message}`)}}}renderNpm(){return this.state.currentTab==="npm"?e.jsxs(o.Paper,{style:j.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(m.Icon,{src:((i=this.state.autoCompleteValue)==null?void 0:i.icon)||"",style:j.listIcon})}),e.jsx(o.TextField,{variant:"standard",...t,label:m.I18n.t("Select adapter")})},renderOption:(t,s)=>e.jsxs(o.Box,{component:"li",sx:{"& > img":{mr:2,flexShrink:0}},...t,children:[e.jsx(m.Icon,{src:(s==null?void 0:s.icon)||"",style:j.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:j.warningText,children:this.props.t("npm_warning","NPM","NPM")}),e.jsx("div",{style:j.noteText,children:this.props.t("github_note")})]}):null}renderGitHub(){return this.state.currentTab==="GitHub"?e.jsxs(o.Paper,{style:j.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(m.Icon,{src:(s==null?void 0:s.icon)||"",style:j.listIconWithMargin}),(s==null?void 0:s.name)??"",(s==null?void 0:s.nogit)&&e.jsx("div",{style:j.errorTextNoGit,children:m.I18n.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(m.Icon,{src:((i=this.state.autoCompleteValue)==null?void 0:i.icon)||"",style:j.listIconWithMargin})}),e.jsx(o.TextField,{variant:"standard",...t,label:m.I18n.t("Select adapter")})}})]}),e.jsx("div",{style:{fontSize:24,fontWeight:"bold",marginTop:40},children:this.props.t("Warning!")}),e.jsx("div",{style:j.warningText,children:this.props.t("github_warning","GitHub","GitHub")}),e.jsx("div",{style:j.noteText,children:this.props.t("github_note")})]}):null}renderCustom(){return this.state.currentTab==="URL"?e.jsxs(o.Paper,{style:j.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>st&&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:j.warningText,children:this.props.t("github_warning","URL","URL")}),e.jsx("div",{style:j.noteText,children:this.props.t("github_note")})]}):null}renderFile(){return this.state.currentTab==="File"?e.jsxs(o.Paper,{style:j.tabPaper,id:"github-install-dialog-panel-file",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs(o.Button,{variant:"outlined",component:"label",startIcon:e.jsx(u.Publish,{}),disabled:this.state.uploading,children:[this.props.t("Select file"),e.jsx("input",{type:"file",accept:".tgz",hidden:!0,onChange:t=>{var i;const s=((i=t.target.files)==null?void 0:i[0])||null;this.setState({selectedFile:s,url:""}),(window._localstorage||window.localStorage).setItem("App.userUrl",""),t.target.value=""}})]}),this.state.selectedFile&&e.jsxs(e.Fragment,{children:[e.jsx(o.Typography,{variant:"body2",style:{flex:1},children:this.state.selectedFile.name}),e.jsx(o.IconButton,{size:"small",onClick:()=>this.setState({selectedFile:null}),children:e.jsx(u.Close,{})})]}),this.state.uploading&&e.jsx(o.CircularProgress,{size:24})]}),this.state.selectedFile&&e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:this.state.restartAfterInstall,onChange:t=>{(window._localstorage||window.localStorage).setItem("App.restartAfterInstall",t.target.checked?"true":"false"),this.setState({restartAfterInstall:t.target.checked})}}),label:this.props.t("Restart adapter after install")}),this.state.cmdExecFilesSupported&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:8},children:[e.jsxs(o.Typography,{variant:"body2",children:[this.props.t("Install on host"),":"]}),e.jsx(nt,{socket:this.props.socket,currentHost:this.state.selectedHost,hostsWorker:this.props.hostsWorker,expertMode:this.props.expertMode,themeType:this.props.themeType,tooltip:this.props.t("Install on host"),setCurrentHost:(t,s)=>this.setState({selectedHost:s})})]}),e.jsx("div",{style:{fontSize:24,fontWeight:"bold",marginTop:40},children:this.props.t("Warning!")}),e.jsx("div",{style:j.warningText,children:this.props.t("github_warning","File","File")}),e.jsx("div",{style:j.noteText,children:this.props.t("github_note")})]}):null}getList(){const t=this.props.categories.map(i=>i.adapters),s=It(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 l=(n.extIcon||n.meta||n.readme||"").toString().split("/");let d=n==null?void 0:n.name;d||(d=n.titleLang,d&&typeof d=="object"?d=d[m.I18n.getLanguage()]||d.en:d=n.title||i);const h={value:`${i}/${l[3]}`,name:`${d} [${l[3]}]`,icon:n.extIcon||n.icon,nogit:!!n.nogit,title:i};return this.props.installed[d]&&d!=="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:"",selectedFile:null,uploading:!1});return e.jsxs(o.Dialog,{onClose:()=>this.props.onClose(),open:!0,sx:{"& .MuiDialog-paper":j.paper},children:[e.jsx(o.DialogContent,{dividers:!0,children:e.jsxs(o.Box,{component:"div",sx:j.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":j.tabSelected},icon:e.jsx("img",{src:At,alt:"npm",width:24,height:24}),...z("npm"),value:"npm"}),e.jsx(o.Tab,{label:this.props.t("From github"),wrapped:!0,sx:{"&.Mui-selected":j.tabSelected},icon:e.jsx(lt,{style:{width:24,height:24},width:24,height:24}),...z("github"),value:"GitHub"}),e.jsx(o.Tab,{label:this.props.t("Custom"),wrapped:!0,sx:{"&.Mui-selected":j.tabSelected},icon:e.jsx(u.Language,{width:24,height:24}),...z("custom"),value:"URL"}),e.jsx(o.Tab,{label:this.props.t("From file"),wrapped:!0,sx:{"&.Mui-selected":j.tabSelected},icon:e.jsx(u.UploadFile,{style:{width:24,height:24}}),...z("file"),value:"File"})]})}),e.jsx(o.Box,{component:"div",sx:j.title,children:this.props.t("Install or update the adapter from %s",this.state.currentTab||"npm")}),this.renderNpm(),this.renderGitHub(),this.renderCustom(),this.renderFile()]})}),e.jsxs(o.DialogActions,{children:[e.jsx(o.Button,{id:"github-install-dialog-ok",variant:"contained",disabled:this.state.uploading||this.props.commandRunning||(this.state.currentTab==="GitHub"||this.state.currentTab==="npm")&&!((s=this.state.autoCompleteValue)!=null&&s.value)||this.state.currentTab==="URL"&&!this.state.url||this.state.currentTab==="File"&&!this.state.selectedFile,autoFocus:!0,onClick:async()=>{await this.handleInstall(),this.props.onClose(),t()},color:"primary",startIcon:this.props.commandRunning?e.jsx(o.CircularProgress,{size:20}):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 N={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 Dt extends L.Component{t;messages=null;lang;constructor(t){super(t),this.state={instanceNumbers:[]},this.t=t.t,this.lang=m.I18n.getLanguage(),this.messages=Y(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:N[`messageTitle_${t.level||"warn"}`],children:this.getText(t.title,this.props.noTranslation)||""}),e.jsx(o.Typography,{component:"div",variant:"body2",style:N.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":N.paper},children:[e.jsx(o.DialogTitle,{children:e.jsxs(o.Typography,{component:"h2",variant:"h6",sx:{"&.MuiTypography-root":N.typography},children:[this.t("You are going to add new instance:")," ",this.props.adapter,e.jsx(o.IconButton,{size:"large",sx:N.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:m.Utils.getStyle(this.props.theme,N.languageButton,this.props.noTranslation&&N.languageButtonActive),onClick:this.props.toggleTranslation,title:m.I18n.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(nt,{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:N.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:N.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 Z(p){var s;if(!p)return"";if((s=p.licenseInformation)!=null&&s.link)return p.licenseInformation.link;let t=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 P 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(mt,{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?P.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=Y(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=(t.host||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(),t.files)})}catch(i){window.alert(`${m.I18n.t("Cannot install")}: ${i}`)}}static getDependencies(t,s){var n,l;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 d=i.node;if((n=i.dependencies)!=null&&n.length)for(const c of i.dependencies){const a={name:"",version:null,installed:!1,installedVersion:null,rightVersion:!1},g=typeof c!="string",f=Object.keys(c);if(a.name=g?f?f[0]:null:c,a.version=g?c[a.name]:null,a.name){const x=s.installed[a.name];a.installed=!!x,a.installedVersion=x?x.version:null;try{a.rightVersion=x?g?V.satisfies(x.version,a.version,{includePrerelease:!0}):!0:!1}catch{a.rightVersion=!0}}r.push(a)}if((l=i.globalDependencies)!=null&&l.length)for(const c of i.globalDependencies){const a={name:"",version:null,installed:!1,installedVersion:null,rightVersion:!1},g=typeof c!="string",f=Object.keys(c);if(a.name=g?f?f[0]:null:c,a.version=g?c[a.name]:null,a.name){const x=s.installedGlobal[a.name];a.installed=!!x,a.installedVersion=x?x.version:null;try{a.rightVersion=x?g?V.satisfies(x.version,a.version,{includePrerelease:!0}):!0:!1}catch{a.rightVersion=!0}}r.push(a)}const h=i.ifInstalledDependencies;if(h&&typeof h=="object"&&!Array.isArray(h)){const c=Object.keys(h);for(const a of c){const g={name:a,version:h[a],installed:!1,installedVersion:null,rightVersion:!1};if(g.name){const f=s.installedGlobal[g.name];g.installed=!!f,g.installedVersion=f?f.version:null;try{g.rightVersion=f?V.satisfies(f.version,g.version,{includePrerelease:!0}):!0}catch{g.rightVersion=!0}}r.push(g)}}if(d){const c={name:"node",version:d,installed:!0,installedVersion:s.nodeJsVersion,rightVersion:!1};try{c.rightVersion=V.satisfies(s.nodeJsVersion,d)}catch{c.rightVersion=!0}r.push(c)}}return r}renderAddInstanceDialog(t){return this.state.addInstanceDialog?e.jsx(Dt,{adapter:this.state.addInstanceDialog,socket:t.socket,hostsWorker:t.hostsWorker,instancesWorker:t.instancesWorker,dependencies:P.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 l;const i=s.repository[t],r=Z(i),n=((l=i.licenseInformation)==null?void 0:l.license)||i.license;n==="MIT"||n==="Apache-2.0"||n==="ISC"||n==="BSD-3-Clause"||n==="BSD-2-Clause"||!n?this.addInstance({adapterName:t,context:s}).catch(d=>window.alert(`Cannot add instance: ${d}`)):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 M={name:{flexWrap:"nowrap",width:300,marginTop:0},nameDiv:{display:"flex",alignItems:"center"},categoryName:{fontWeight:"bold",cursor:"pointer"},green:{color:pt[500]},blue:{color:Ct[700]},category:{backgroundColor:"background.default"},marginRight5:{marginRight:5}};function Vt(p){const{installedCount:t,name:s,categoryName:i}=p;return e.jsxs(o.TableRow,{hover:!1,sx:M.category,children:[e.jsx(o.TableCell,{children:e.jsx(o.Grid2,{container:!0,spacing:1,alignItems:"center",style:M.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:{...M.nameDiv,...M.categoryName},children:[e.jsx(yt,{iconName:i,style:M.marginRight5}),s]})}),e.jsxs(o.TableCell,{colSpan:p.descHidden?5:6,children:[e.jsx(o.Typography,{component:"span",variant:"body2",style:M.green,children:t}),` ${p.t("of")} `,e.jsx(o.Typography,{component:"span",variant:"body2",style:M.blue,children:p.count}),` ${p.t("Adapters from this Group installed")}`]})]})}const S={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"}},it=[{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 Rt 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.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(l=>l.json()).then(l=>(window.alert(`${this.props.t("Vote:")} ${t}@${s}=${i}`),delete l.adapter,l)).catch(l=>(window.alert(`Cannot vote: ${l}`),null))}renderInfoText(){return e.jsxs("div",{style:S.infoTextContainer,children:[e.jsx(u.Info,{}),e.jsx(o.Typography,{style:S.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:S.listTitle,children:this.props.t("Comments")}),e.jsxs(o.FormControl,{variant:"standard",style:S.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:S.commentCount,children:this.state.votings.comments.length})]}),it.map(i=>e.jsxs(o.MenuItem,{value:i.id,children:[i.title," ",this.state.commentsByLanguage[i.id]?e.jsx("span",{style:S.commentCount,children:this.state.commentsByLanguage[i.id]}):null]},i.id))]})]}),e.jsxs(o.List,{style:S.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?S.listOwn:void 0},dense:!0,children:[e.jsx(o.ListItemAvatar,{style:S.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":S.listTime}})]},r):null),!s&&e.jsx("div",{style:S.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 l=this.state.votings.rating;s=Object.keys(l),s.sort((d,h)=>l[d].ts>l[h].ts?-1:l[d].ts<l[h].ts?1:0),s.length&&(t=l[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:S.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:(l,d)=>this.setState({ratingNumber:d})}),this.props.version?e.jsxs("div",{style:{width:"100%",textAlign:"left"},children:[e.jsx(o.TextField,{variant:"standard",style:S.ratingTextControl,value:this.state.ratingComment,label:this.props.t("Comment to version"),helperText:this.props.t("Max length %s characters",200),onChange:l=>this.setState({ratingComment:l.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:S.ratingLanguageControl,children:[e.jsx(o.InputLabel,{children:this.props.t("Language")}),e.jsx(o.Select,{variant:"standard",value:this.state.ratingLang,onChange:l=>this.setState({ratingLang:l.target.value}),children:it.map(l=>e.jsx(o.MenuItem,{value:l.id,children:l.title},l.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(l=>this.props.onClose(l)):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 ot={closeButton:p=>({position:"absolute",right:8,top:8,color:p.palette.grey[500]}),typography:{paddingRight:30}};class Lt 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":ot.typography},children:[this.t("Please confirm"),e.jsx(o.IconButton,{size:"large",sx:ot.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 ct={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 Ut extends J.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:m.I18n.t("Auto upgrade policy for %s",this.props.adapter)}),e.jsxs(o.DialogContent,{style:{padding:"0 20px",overflow:"hidden"},children:[e.jsx(B,{value:!this.state.supported,children:e.jsx(o.Typography,{children:m.I18n.t("This feature is supported up from js-controller Kiera (Version 6)!")})}),e.jsxs(B,{value:this.state.supported,children:[e.jsx(o.Typography,{children:m.I18n.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:ft.map(t=>e.jsx(o.MenuItem,{value:t,children:e.jsxs("div",{style:{display:"flex",gap:8},children:[ct[t],xt[t]]})},t))}),e.jsx(B,{value:this.state.repositories.includes("beta")&&this.state.policy!=="none",children:e.jsx(m.InfoBox,{type:"warning",children:m.I18n.t("repo_update_hint")})}),e.jsx(B,{value:this.state.policy==="major",children:e.jsx(m.InfoBox,{type:"warning",children:m.I18n.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:m.I18n.t("Save")}),e.jsx(o.Button,{variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:e.jsx(u.Close,{}),children:m.I18n.t("Close")})]})]})}}const ht={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:jt[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:dt[500]},cardContentFlexBetween:{},cardContentFlex:{}};class H extends P{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:l=>{l.target&&(l.target.onerror=null,l.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(B,{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,{}):ct[s]})})}renderReadmeButton(){const t=this.props.context.repository[this.props.adapterName]?this.props.context.repository[this.props.adapterName].allowAdapterReadme:!0;return e.jsx(B,{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,title:t,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})}):e.jsx("div",{style:{width:24,height:24}})}):null}renderLicenseInfo(t=!1){var n,l,d,h;const s=this.props.context.repository[this.props.adapterName],i=Z(s),r=(n=s.licenseInformation)!=null&&n.type?e.jsx(o.Link,{href:i,target:"_blank",rel:"noopener",sx:(c=>({color:c.palette.mode==="dark"?"white":"black","&:hover":{color:c.palette.mode==="dark"?"white":"black"}})),children:((l=s.licenseInformation)==null?void 0:l.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,{})}):((d=s.licenseInformation)==null?void 0:d.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})}):((h=s.licenseInformation)==null?void 0:h.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;return!r&&t?e.jsx("div",{style:{width:24,height:24}}):r}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:wt})})}):null}getDependencies(){const t=P.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.length?(s.unshift(this.props.context.t("Wrong dependencies")),s.map((i,r)=>e.jsx("div",{style:r?void 0:{fontWeight:"bold",fontSize:"larger"},children:i},i))):null}renderVersion(){const t=this.props.context.repository[this.props.adapterName]?this.props.context.repository[this.props.adapterName].allowAdapterUpdate:!0,s=this.props.context.repository[this.props.adapterName],i=s==null?void 0:s.version;return i?!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,{})}),i]})}):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:i})}):e.jsx("span",{style:this.styles.wrongDependencies,children:this.props.context.t("not maintained")})}static extractGitHubCommitHash(t){if(!t)return null;const s=t.indexOf("#");if(s===-1)return null;const i=t.substring(s+1);return i.length>=7?i.substring(0,7):i}renderInstalledVersion(t){var h,c;const s=this.props.context.installed[this.props.adapterName],i=(c=(h=this.props.context.adapters[`system.adapter.${this.props.adapterName}`])==null?void 0:h.common)==null?void 0:c.installedFrom,{adapterName:r}=this.props,n=i&&!i.startsWith(`iobroker.${r}@`),l=n?H.extractGitHubCommitHash(i):null,d=n&&l?`${this.installedVersion}+${l}`:this.installedVersion;if(t){const a=s==null?void 0:s.enabled,g=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:d+(g?` (${g}${g!==a?"~":""})`:"")}):null,n&&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:[n&&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})}),d]})]}):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=(()=>{const n=String(this.props.adapterName||"").toLowerCase().replace(/^system\.adapter\./,"").replace(/^iobroker\./,"").replace(/^@nexowatt\/iobroker\./,"").replace(/^@nexowatt\//,"").replace(/\.\d+$/,"");return ["admin","eos-admin","backitup","nexowatt-devices","nexowatt-device","nexowatt-dev","nexowatt-ui"].includes(n)})()||window.NEXOWATT_EOS_SECURITY&&window.NEXOWATT_EOS_SECURITY.isProtectedAdapter&&window.NEXOWATT_EOS_SECURITY.isProtectedAdapter(this.props.adapterName);return e.jsx(B,{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(Ut,{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(bt,{adapter:this.props.adapterName,adapterObject:this.props.context.repository[this.props.adapterName],t:this.props.context.t,dependencies:P.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,l,d;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=(l=this.props.context.repository[this.props.adapterName])==null?void 0:l.stable,s=(d=this.props.context.repository[this.props.adapterName])==null?void 0:d.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:c})=>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:m.Utils.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:H.formatNews(c)})]})},h))})]})})}renderSetRatingDialog(){return this.state.showSetRating?e.jsx(Rt,{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(Lt,{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(at.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 l;typeof s.news[n]=="object"?l=this.props.noTranslation?s.news[n].en:s.news[n][this.props.context.lang]||s.news[n].en:l=s.news[n],r.push({version:n,news:l})}}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=Z(t),i=((r=t.licenseInformation)==null?void 0:r.license)||t.license;i!=="MIT"&&i!=="Apache-2.0"&&i!=="ISC"&&i!=="BSD-3-Clause"&&i!=="BSD-2-Clause"&&i?this.setState({showLicenseDialog:{url:s,upload:!0,adapterName:this.props.adapterName,licenseType:i},showDialog:!0}):P.upload(this.props.adapterName,this.props.context)}delete(t){const s=(()=>{const n=String(this.props.adapterName||"").toLowerCase().replace(/^system\.adapter\./,"").replace(/^iobroker\./,"").replace(/^@nexowatt\/iobroker\./,"").replace(/^@nexowatt\//,"").replace(/\.\d+$/,"");return ["admin","eos-admin","backitup","nexowatt-devices","nexowatt-device","nexowatt-dev","nexowatt-ui"].includes(n)})();if(s||window.NEXOWATT_EOS_SECURITY&&window.NEXOWATT_EOS_SECURITY.shouldBlockAdapterDelete(this.props.adapterName)){window.alert("Dieser Adapter ist ein geschütztes NexoWatt-EOS-Systemmodul und darf nicht gelöscht werden.");return}this.props.context.executeCommand(`del ${this.props.adapterName}${t?" --custom":""}${this.props.context.expertMode?" --debug":""}`)}async update(t){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 Ot="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)",Bt="0 8px 17px 0 rgba(0, 0, 0, .2),0 6px 20px 0 rgba(0, 0, 0, .19)",Nt={...ht,type:{color:"tile"},root:p=>({position:"relative",m:"10px",width:300,minHeight:200,background:p.palette.background.default,boxShadow:Ot,display:"flex",flexDirection:"column",transition:"box-shadow 0.5s","&:hover":{boxShadow:Bt}}),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:dt[500],marginRight:5},rating:{marginTop:20}};class Ft extends H{styles=Nt;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:m.Utils.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=>H.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:m.Utils.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(B,{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:m.Utils.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 $t={...ht,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 _t extends H{styles=$t;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:{width:24,height:24}}),this.renderDataSource()||e.jsx("div",{style:{marginLeft:5,width:24,height:24}}),this.renderSentryInfo()||e.jsx("div",{style:{marginLeft:5,width:24,height:24}}),this.renderLicenseInfo(!0)]})}),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 q=246,F={emptyBlock:50,name:300,connectionType:120,installed:120,available:120,update:40,license:80,install:q},G=Object.keys(F).reduce((p,t)=>p+F[t],0),k={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:F.name},emptyBlock:{flexWrap:"nowrap",width:F.emptyBlock},description:{width:`calc(100% - ${G+2}px)`},connectionType:{width:F.connectionType},installed:{width:F.installed},available:{width:F.available,paddingRight:6},license:{width:F.license},install:{width:F.install},viewModeDiv:{display:"flex",flexFlow:"wrap",overflow:"auto",justifyContent:"center"}};class Pt 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(_t,{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 l=this.props.listOfVisibleAdapter[n];i.length>50&&!((r=this.props.context.installed[l])!=null&&r.version)||i.push(this.getRow(l,t))}if(s=i.length,s&&this.props.listOfVisibleAdapter.length>i.length){const n=this.props.listOfVisibleAdapter.length-i.length,l=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:l})},"more"))}}else i=this.props.categories.map(n=>{if(!n.adapters.find(c=>this.props.listOfVisibleAdapter.includes(c)))return null;const d=n.name,h=this.props.categoriesExpanded[d];return s++,e.jsxs(L.Fragment,{children:[e.jsx(Vt,{categoryName:d,count:n.count,expanded:h,installedCount:n.installed,name:n.translation,descHidden:t.descHidden,onToggle:()=>this.props.toggleCategory(d),t:this.props.context.t},`category-${d}1`),h&&n.adapters.map(c=>{const a=this.getRow(c,t);return a&&s++,a})]},`category-${d} ${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],l=this.props.cachedAdapters[n];s.length>50&&!((i=this.props.context.installed[n])!=null&&i.version)||s.push(e.jsx(Ft,{context:t,adapterName:n,cached:l,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||String(s||"").toLowerCase()==="nexowatt"?null:e.jsx(o.Box,{sx:{marginX:2,marginTop:1,width:"calc(100% - 32px)"},children:e.jsx(m.InfoBox,{type:"warning",children:this.props.context.t('Active repo is "%s"',s)})}),e.jsx("div",{style:k.viewModeDiv,children:this.getTiles(i)})]})}renderTableView(t,s,i){return e.jsxs(m.TabContent,{children:[t||String(s||"").toLowerCase()==="nexowatt"?null:e.jsx(o.Box,{sx:{marginX:2,marginTop:1,width:"calc(100% - 32px)"},children:e.jsx(m.InfoBox,{type:"warning",children:this.props.context.t('Active repo is "%s"',s)})}),e.jsx(o.TableContainer,{style:{...k.container,...t?k.containerFullHeight:k.containerNotFullHeight},children:e.jsxs(o.Table,{stickyHeader:!0,size:"small",sx:k.table,children:[e.jsx(o.TableHead,{children:e.jsxs(o.TableRow,{children:[e.jsx(o.TableCell,{style:k.emptyBlock}),e.jsx(o.TableCell,{style:k.name,children:e.jsx(o.Typography,{children:this.props.context.t("Name")})}),!i.descHidden&&e.jsx(o.TableCell,{style:{...k.description,width:this.props.descWidth},children:e.jsx(o.Typography,{children:this.props.context.t("Description")})}),e.jsx(o.TableCell,{style:k.connectionType}),e.jsx(o.TableCell,{style:k.installed,children:e.jsx(o.Typography,{children:this.props.context.t("Installed")})}),e.jsx(o.TableCell,{style:k.available,children:e.jsx(o.Typography,{children:this.props.context.t("Available")})}),e.jsx(o.TableCell,{style:k.license,children:e.jsx(o.Typography,{children:this.props.context.t("License")})}),e.jsx(o.TableCell,{style:{...k.install,width:this.state.expertMode?q:q-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 l=JSON.stringify(t.listOfVisibleAdapter);return l!==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:l,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 Wt 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=J.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:"eos-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:[m.I18n.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(m.I18n.t("%s was successfully updated to %s","eos-admin",this.props.version))):i!=null&&i.stdout&&(i.stdout.unshift(""),i.stdout.unshift("---------------------------------------------------"),i.stdout.unshift(m.I18n.t("updating %s to %s...","eos-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:(l,d)=>{d!=="escapeKeyDown"&&d!=="backdropClick"&&this.props.onClose()},open:!0,maxWidth:"lg",fullWidth:!0,children:[e.jsx(o.DialogTitle,{children:m.I18n.t("Updating %s...","eos-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
5
  `):this.state.response.stdout.join(`
6
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 l;(l=this.state.response)!=null&&l.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?m.I18n.t("Reload"):m.I18n.t("Close")})})]})}}const C={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"}},rt=[{name:"Description A-Z"},{name:"Name A-Z"},{name:"Popular first",notByList:!0},{name:"Recently updated",notByList:!0}];class D extends P{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:Q.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(Q,{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 et(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||=JSON.parse(JSON.stringify(this.state.adapters||{})),this.tempInstalled||=JSON.parse(JSON.stringify(this.state.installed||{})),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:l}=t;s||=this.state.adapters;const d=n||this.state.installed;l||=this.state.installedGlobal,i||=this.state.repository;const h=[];Object.keys(d).forEach(c=>{if(d[c]){const a=d[c].version,g=i[c];g&&g.version!==a&&at.updateAvailable(a,g.version)&&!h.includes(c)&&h.push(c)}}),this.cache.listOfVisibleAdapter=null,this.setState({adapters:s,updateAvailable:h,installed:d,repository:i,installedGlobal:l},()=>r&&r())}async getInstalled(t){let s,i={};const r=await this.props.socket.getHosts(t);for(const n of r)try{const l=await this.props.socket.getState(`${n._id}.alive`);if(l!=null&&l.val){const d=await this.props.socket.getInstalled(n._id,t,this.state.readTimeoutMs);n._id===this.state.currentHost&&(s=d),i={...i,...d}}}catch(l){window.alert(`Cannot getInstalled from "${n._id}" (timeout ${this.state.readTimeoutMs}ms): ${l}`),l.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(c){window.alert(`Cannot getAdapters: ${c}`)}const{installedLocal:l,installedGlobal:d}=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(c){window.alert(`Cannot getRepository: ${c}`),c.toString().includes("timeout")&&this.setState({showSlowConnectionWarning:!0})}return this.analyseInstalled({adapters:n,installedLocal:l,repository:h,installedGlobal:d})}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,l,d,h){const c={};t.sort((a,g)=>{if(l)return r[g].stat===r[a].stat?(c[a]||=D.getAdapterTitle(a,r,s),c[g]||=D.getAdapterTitle(g,r,s),c[a]>c[g]?1:c[a]<c[g]?-1:0):r[g].stat-r[a].stat;if(d)return r[a]?r[g]?r[a].daysAgo===r[g].daysAgo?(c[a]||=D.getAdapterTitle(a,r,s),c[g]||=D.getAdapterTitle(g,r,s),c[a]>c[g]?1:c[a]<c[g]?-1:0):r[a].daysAgo-r[g].daysAgo:1:-1;if(h){if(h[a].exact&&!h[g].exact)return-1;if(!h[a].exact&&h[g].exact)return 1}return i[a]&&i[g]?n?a>g?1:a<g?-1:0:(c[a]||=D.getAdapterTitle(a,r,s),c[g]||=D.getAdapterTitle(g,r,s),c[a]>c[g]?1:c[a]<c[g]?-1:0):i[a]?-1:i[g]?1:n?a>g?1:a<g?-1:0:(c[a]||=D.getAdapterTitle(a,r,s),c[g]||=D.getAdapterTitle(g,r,s),c[a]>c[g]?1:c[a]<c[g]?-1:0)})}calculateInfo(t,s,i,r){i||=this.state.hostData,s||=this.state.ratings,t=t||this.state.compactInstances,r!=null&&r._id||(r=this.state.compactRepositories);const n=this.state.adapters,l=JSON.parse(JSON.stringify(this.state.installed)),d=JSON.parse(JSON.stringify(this.state.repository)),h=((i==null?void 0:i["Node.js"])||"").replace("v",""),c=(i==null?void 0:i.os)||"",a={},g=[];let f={};try{f=JSON.parse((window._localStorage||window.localStorage).getItem("Adapters.expandedCategories"))||{}}catch{}Object.keys(l).forEach(y=>{var O,E;const w=l[y];(E=(O=n[y])==null?void 0:O.common)!=null&&E.ignoreVersion&&(w.ignoreVersion=n[y].common.ignoreVersion),!w.controller&&y!=="hosts"&&(d[y]||(d[y]=JSON.parse(JSON.stringify(w)),d[y].version="")),w.count=0,w.enabled=0}),Object.keys(t).forEach(y=>{const w=t[y].name;l[w]&&l[w].count++});const x=Date.now();this.recentUpdatedAdapters=0,this.installedAdapters=0,Object.keys(d).forEach(y=>{var E;if(y==="hosts"||y.startsWith("_"))return;const w=d[y];if(typeof w!="object"){console.error(`[${y}] ${y} is not an object.`);return}w.keywords&&(w.keywords=w.keywords.map(R=>R.toLowerCase()));const O=l[y];if(w.rating=s==null?void 0:s[y],(E=w.rating)!=null&&E.rating?w.rating.title=[`${this.t("Total rating:")} ${w.rating.rating.r} (${w.rating.rating.c} ${this.getWordVotes(w.rating.rating.c)})`,O!=null&&O.version&&w.rating[O.version]?`${this.t("Rating for")} v${O.version}: ${w.rating[O.version].r} (${w.rating[O.version].c} ${this.getWordVotes(w.rating.rating.c)})`:""].filter(R=>R).join(`
7
7
  `):w.rating={title:this.t("No rating or too few data")},!w.controller){const R=w.type,X=l[y];Math.round((x-new Date(w.versionDate).getTime())/864e5)<=31&&this.recentUpdatedAdapters++,l[y]&&this.installedAdapters++,a[R]?(a[R].count++,a[R].adapters.push(y),X&&a[R].installed++):a[R]={name:R,translation:this.t(`${R}_group`),count:1,installed:X?1:0,adapters:[y]}}}),Object.keys(a).sort((y,w)=>y==="general"&&w!=="general"?-1:y!=="general"&&w==="general"||a[y].translation>a[w].translation?1:a[y].translation<a[w].translation?-1:0).forEach(y=>g.push(a[y]));const v=this.state.filterTiles==="Name A-Z";Object.keys(a).forEach(y=>D.sortAdapters(a[y].adapters,this.props.lang,l,d,v));let b=0;try{b=JSON.parse((window._localStorage||window.localStorage).getItem("Adapters.installedList")),b===!1&&(b=0)}catch{}const I=(window._localStorage||window.localStorage).getItem("Adapters.list")==="true",T=(window._localStorage||window.localStorage).getItem("Adapters.viewMode")==="true",U=(window._localStorage||window.localStorage).getItem("Adapters.updateList")==="true",W=(window._localStorage||window.localStorage).getItem("Adapters.categoriesTiles")||"All";let $=(window._localStorage||window.localStorage).getItem("Adapters.filterTiles")||"Description A-Z";return $==="A-Z"&&($="Description A-Z"),this.allAdapters=Object.keys(d).length-1,this.cache.listOfVisibleAdapter=null,new Promise(y=>{this.setState({repository:d,installed:l,ratings:s,filterTiles:$,categoriesTiles:W,compactRepositories:r,installedList:b,compactInstances:t,updateList:U,tableViewMode:T,oneListView:I,lastUpdate:Date.now(),hostData:i,hostOs:c,nodeJsVersion:h,categories:g,categoriesExpanded:f,init:!0,update:!1},()=>y())})}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(a=>{this.setState({update:!0},()=>a())});const l=await this.props.socket.getHostInfo(r,t,this.state.readTimeoutMs).catch(a=>{window.alert(`Cannot getHostInfo for "${r}": ${a}`),a.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(a){window.alert(`Cannot read ratings: ${a}`)}this.uuid=(n==null?void 0:n.uuid)||null}else n=null;const d=await this.props.socket.getCompactInstances(t).catch(a=>(window.alert(`Cannot read countsOfInstances: ${a}`),{})),c=await this.props.socket.getCompactSystemRepositories(t).catch(a=>(window.alert(`Cannot read getCompactSystemRepositories: ${a}`),{}));await this.calculateInfo(d||{},n,l,c)}catch(l){window.alert(`Cannot get adapters info: ${l}`)}}}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(d=>{const h=typeof d!="string",c=Object.keys(d),a=h?c?c[0]:null:d;if(i&&a){const g=this.state.installed[a];try{i=g?h?V.satisfies(g.version,d[a],{includePrerelease:!0}):!0:!1}catch{i=!0}}});else if(typeof r=="object"){const d=r;Object.keys(d).forEach(h=>{if(h&&d[h]!==void 0&&i){const c=this.state.installed[h],a=typeof d[h]=="string";try{i=c?a?V.satisfies(c.version,d[h],{includePrerelease:!0}):!0:!1}catch{i=!0}}})}else console.error(`[ADAPTERS] Invalid dependencies for ${t}: ${JSON.stringify(r)}`);const l=s.ifInstalledDependencies;if(l&&typeof l=="object"&&!Array.isArray(l)&&Object.keys(l).forEach(h=>{if(i&&h){const c=this.state.installed[h];try{i=c?V.satisfies(c.version,l[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 c;const n=this.state.repository[r];if(!n)return;let l,d;const h=n.titleLang||n.title;typeof h=="object"?l=h[this.props.lang]||h.en:l=h,l=((l||"").toString()||"").replace("ioBroker Visualisation - ",""),n.desc?typeof n.desc=="string"?d=n.desc:d=n.desc[this.props.lang]||n.desc.en||"":d="",r.includes(t)?s[r]={exact:r===t,type:"name",start:r.startsWith(t)}:l&&typeof l=="string"&&l.toLowerCase().includes(t)?s[r]={exact:!1,type:"title"}:d&&typeof d=="string"&&d.toLowerCase().includes(t)?s[r]={exact:!1,type:"desc"}:(c=n.keywords)!=null&&c.find(a=>a.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"),l=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(c=>{var g;const a=this.state.repository[c];if(a&&!a.controller){const f=a.connectionType?a.connectionType:"-",x=this.state.updateAvailable.includes(c),v=this.state.installed[c];let b=!this.state.filteredList||!!this.state.filteredList[c];if(b&&this.state.filterConnectionType&&(b=f==="local"),b&&this.state.updateList&&(b=x),b&&this.state.installedList&&(b=this.state.installedList<2?!!(v&&v.version):!!(v&&v.version&&!v.count)),b){this.cache.listOfVisibleAdapter.push(c);const I=Math.round((s-new Date(a.versionDate).getTime())/864e4),T=Math.round(I/10),U=a.titleLang||a.title;let W;U&&typeof U=="object"?W=U[this.props.lang]||U.en:W=U||c,W=((W||"").toString()||"").replace("ioBroker Visualisation - ","");let $;a.desc?typeof a.desc=="string"?$=a.desc:$=a.desc[this.props.lang]||a.desc.en||"":$="";const y=T%100<=10||T%100>=20?T%10:5;this.cache.adapters[c]={title:W,desc:$,image:v&&this.state.adapters[`system.adapter.${c}`]?`.${v.localIcon}`:a.extIcon,connectionType:a.connectionType?a.connectionType:"-",updateAvailable:this.state.updateAvailable.includes(c),rightDependencies:this.rightDependencies(c),rightOs:this.rightOs(c),sentry:!!((g=a.plugins)!=null&&g.sentry),daysAgo:I,stat:a.stat||0,daysAgoText:T||T===0?T===0?i:y===1?r.replace("%d",T.toString()):y===2||y===3||y===4?n.replace("%d",T.toString()):l.replace("%d",T.toString()):""}}}})),this.listOfVisibleAdapterLength=this.cache.listOfVisibleAdapter.length;const d=this.state.filterTiles==="Name A-Z";this.state.tableViewMode&&this.state.categories.forEach(h=>D.sortAdapters(h.adapters,this.props.lang,this.state.installed,this.cache.adapters,d)),D.sortAdapters(this.cache.listOfVisibleAdapter,this.props.lang,this.state.installed,this.cache.adapters,d,t.sortPopularFirst,t.sortRecentlyUpdated,this.state.filteredList),console.log(`[ADAPTERS] ${new Date().toISOString()} Update cache!`),this.forceUpdate()}getUpdater(){return this.state.showUpdater?e.jsx(Tt,{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,rightDependenciesFunc:this.rightDependencies}):null}getDescWidth(){return this.props.menuOpened?document.body.scrollWidth-G-180+13:this.props.menuClosed?document.body.scrollWidth-G:document.body.scrollWidth-G-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:C.counters,children:[this.t("Total adapters"),":"," ",e.jsx("span",{style:{paddingLeft:6,fontWeight:"bold"},children:this.allAdapters})]}),e.jsxs(o.Box,{component:"div",sx:C.counters,children:[this.t("Installed adapters"),":"," ",e.jsx("span",{style:{paddingLeft:6,fontWeight:"bold"},children:this.installedAdapters})]}),e.jsxs(o.Box,{component:"div",sx:C.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(kt,{t:this.t,categories:this.state.categories,installed:this.state.installedGlobal,socket:t.socket,currentHost:t.currentHost,hostsWorker:t.hostsWorker,expertMode:t.expertMode,themeType:t.themeType,commandRunning:this.props.commandRunning,upload:s=>this.props.executeCommand(`upload ${s}${this.props.expertMode?" --debug":""}`),installFromUrl:(s,i,r,n)=>this.addInstance({adapterName:s,debug:i,customUrl:r,context:t,host:n==null?void 0:n.host,files:n==null?void 0:n.files}),repository:this.state.repository,onClose:()=>{this.setState({gitHubInstallDialog:!1})}}):null}renderRepositoryTimestamp(){var h,c,a,g;const t=(c=(h=this.state.compactRepositories)==null?void 0:h.native)==null?void 0:c.repositories;if(!t)return null;let s=null,i=null;const r=[];if(typeof this.props.systemConfig.common.activeRepo=="string"){const f=(g=(a=t[this.props.systemConfig.common.activeRepo])==null?void 0:a.json)==null?void 0:g._repoInfo;if(f){s=f.repoTime||null,i=f.repoReadTime||null;const x=this.getRepositoryName(f);x&&r.push(x)}}else if(Array.isArray(this.props.systemConfig.common.activeRepo)){let f=null,x=null;this.props.systemConfig.common.activeRepo.forEach(v=>{var I,T;const b=(T=(I=t[v])==null?void 0:I.json)==null?void 0:T._repoInfo;if(b){const U=this.getRepositoryName(b);U&&r.push(U),b.repoTime&&(!f||new Date(b.repoTime)<new Date(f))&&(f=b.repoTime),b.repoReadTime&&(!x||new Date(b.repoReadTime)<new Date(x))&&(x=b.repoReadTime)}}),s=f,i=x}const n=i||s;if(!n)return null;const l=this.formatRepositoryTimestamp(n);let d="";return r.length>1?d=this.t("Repository timestamps (oldest from %s):",r.join(", ")):d=this.t("Repository timestamps:"),s&&(d+=`