iobroker.admin 7.4.8 → 7.4.9
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 +5 -5
- package/adminWww/asset-manifest.json +15 -15
- package/adminWww/index.html +1 -1
- package/adminWww/static/js/{288.23e8413f.chunk.js → 288.18e82468.chunk.js} +2 -2
- package/adminWww/static/js/{288.23e8413f.chunk.js.map → 288.18e82468.chunk.js.map} +1 -1
- package/adminWww/static/js/4289.a5fc8b2e.chunk.js +2 -0
- package/adminWww/static/js/4289.a5fc8b2e.chunk.js.map +1 -0
- package/adminWww/static/js/6853.6655ed69.chunk.js +2 -0
- package/adminWww/static/js/6853.6655ed69.chunk.js.map +1 -0
- package/adminWww/static/js/{7137.7b5ca6b5.chunk.js → 7137.c988b7e1.chunk.js} +2 -2
- package/adminWww/static/js/7137.c988b7e1.chunk.js.map +1 -0
- package/adminWww/static/js/{7424.223daaa3.chunk.js → 7424.5cf79afc.chunk.js} +2 -2
- package/adminWww/static/js/7424.5cf79afc.chunk.js.map +1 -0
- package/adminWww/static/js/9823.8a42dea5.chunk.js +3 -0
- package/adminWww/static/js/9823.8a42dea5.chunk.js.map +1 -0
- package/adminWww/static/js/{main.a833ed54.js → main.dbb63dc9.js} +2 -2
- package/adminWww/static/js/{main.a833ed54.js.map → main.dbb63dc9.js.map} +1 -1
- package/build-backend/main.js +5 -0
- package/build-backend/main.js.map +1 -1
- package/io-package.json +14 -14
- package/package.json +4 -4
- package/adminWww/static/js/4289.cbde8e52.chunk.js +0 -2
- package/adminWww/static/js/4289.cbde8e52.chunk.js.map +0 -1
- package/adminWww/static/js/6853.ff130602.chunk.js +0 -2
- package/adminWww/static/js/6853.ff130602.chunk.js.map +0 -1
- package/adminWww/static/js/7137.7b5ca6b5.chunk.js.map +0 -1
- package/adminWww/static/js/7424.223daaa3.chunk.js.map +0 -1
- package/adminWww/static/js/9823.f3f5cd8c.chunk.js +0 -3
- package/adminWww/static/js/9823.f3f5cd8c.chunk.js.map +0 -1
- /package/adminWww/static/js/{9823.f3f5cd8c.chunk.js.LICENSE.txt → 9823.8a42dea5.chunk.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";(self.webpackChunksrc_rx=self.webpackChunksrc_rx||[]).push([[4289],{16244:(t,e,s)=>{s.d(e,{A:()=>i});s(28437);const i="./static/media/sentry.e732e10c5c1ceed0955b2fec6dab33f8.svg"},73852:(t,e,s)=>{s.d(e,{A:()=>l});var i=s(28437),o=s(89303),n=s(90457),a=s(70579);const r={button:{marginLeft:10,marginRight:10},icon:{marginRight:5}};const l=function(t){let{arrayItem:e,title:s,onClick:l,value:p,contained:d,buttonIcon:c,icons:h,t:u,translateSuffix:g,noTranslation:m}=t;const[x,y]=(0,i.useState)(null);return g=g||"",(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.Tooltip,{title:s||"",slotProps:{popper:{sx:{pointerEvents:"none"}}},children:(0,a.jsxs)(o.Button,{style:r.button,variant:d?"contained":"outlined",color:"primary",onClick:t=>y(t.currentTarget),children:[c||h&&(0,a.jsx)(n.A,{iconName:p,style:r.icon}),"number"===typeof p||m?p:u(p+g)]})}),(0,a.jsx)(o.Menu,{anchorEl:x,keepMounted:!0,open:Boolean(x),onClose:()=>y(null),children:e.map(((t,e)=>{let{name:s}=t;return(0,a.jsxs)(o.MenuItem,{selected:p||0===p?s===p:0===e,disabled:p||0===p?s===p:0===e,className:"tag-card-".concat(s),style:{placeContent:"space-between"},value:s,onClick:()=>{l(s),y(null)},children:[h&&(0,a.jsx)(n.A,{iconName:s,style:r.icon}),"number"===typeof s||m?s:u(s+g)]},s)}))})]})}},90457:(t,e,s)=>{s.d(e,{A:()=>l});var i=s(28437),o=s(32075),n=s(70579);const a={},r={All:o.AllInclusive,messaging:o.Message,communication:o.WifiTethering,general:o.Apps,logic:o.VpnKey,alarm:o.NotificationsActive,"iot-systems":o.SystemUpdateAlt,"misc-data":o.EmojiSymbols,multimedia:o.PermMedia,network:o.SettingsEthernet,storage:o.Storage,visualization:o.Visibility,"climate-control":o.SettingsBrightness,"date-and-time":o.DateRange,energy:o.BatteryChargingFull,garden:o.FilterVintage,geoposition:o.LocationOn,hardware:o.Phonelink,health:o.Favorite,household:o.House,infrastructure:o.Apartment,lighting:o.EmojiObjects,protocols:o.DialerSip,utility:o.PhonelinkSetup,vehicle:o.AirportShuttle,"visualization-icons":o.BubbleChart,"visualization-widgets":o.Widgets,weather:o.Brightness6,metering:o.LinearScale};const l=function(t){let{iconName:e,className:s,adapter:l,socket:p,onClick:d,style:c}=t;const[h,u]=(0,i.useState)("");if((0,i.useEffect)((()=>{l&&p&&(a[l]instanceof Promise||(a[l]=p.getObject("system.adapter.".concat(l))),a[l].then((t=>{var e;return(null===t||void 0===t||null===(e=t.common)||void 0===e?void 0:e.icon)&&u("../../adapter/".concat(l,"/").concat(t.common.icon))})))}),[l,p]),l)return(0,n.jsx)("img",{onClick:t=>d&&d(t),src:h||"",className:s,style:c,alt:""});const g=r[e]||o.Help;return(0,n.jsx)(g,{className:s,style:c,onClick:t=>d&&d(t)})}},94289:(t,e,s)=>{s.r(e),s.d(e,{default:()=>jt});var i=s(89379),o=s(28437),n=s.n(o),a=s(78613),r=s.n(a),l=s(89303),p=s(32075),d=s(60184),c=s(73852),h=s(16904),u=s(53002),g=s(70579);const m={smallAvatar:{width:24,height:24},listItem:t=>({mb:"2px",background:t.palette.background,"@media screen and (max-width: 400px)":{pl:"2px"}}),toVersion:t=>({color:"dark"===t.palette.mode?"#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:t=>({position:"absolute",right:8,top:8,color:t.palette.grey[500]}),languageButton:{position:"absolute",right:60,top:8},languageButtonActive:t=>({color:t.palette.primary.main}),versionHeader:t=>({background:"#4dabf5",borderRadius:"3px",pl:"10px",fontWeight:"bold",color:"dark"===t.palette.mode?"black":"white"}),repoStableVersionText:t=>({color:"dark"===t.palette.mode?"#8dff7a":"#2b9800",fontWeight:"bold",marginLeft:"4px"}),repoLatestVersionText:t=>({color:"dark"===t.palette.mode?"#a3fcff":"#005498",fontWeight:"bold",marginLeft:"4px"})};class x extends o.Component{constructor(t){super(t),this.updateAvailable=void 0,this.initialVersions=void 0,this.currentRef=void 0,this.current=void 0,this.updateAvailable=this.detectUpdates(),this.initialVersions={},this.updateAvailable.forEach((t=>this.initialVersions[t]=this.props.installed[t].version)),this.state={showNews:null},this.currentRef=n().createRef(),this.current=t.current,this.props.onUpdateSelected([...this.updateAvailable],this.updateAvailable)}static isUpdateAvailable(t){const{oldVersion:e,newVersion:s,name:i}=t;try{return r().gt(s,e)}catch(o){return console.warn('Cannot compare "'.concat(s,'" and "').concat(e,'" of adapter ').concat(i)),!1}}detectUpdates(){const t=[];return Object.keys(this.props.repository).forEach((e=>{const s=this.props.installed[e];"js-controller"!==e&&"admin"!==e&&s&&this.props.repository[e].version&&s.ignoreVersion!==this.props.repository[e].version&&x.isUpdateAvailable({oldVersion:s.version,newVersion:this.props.repository[e].version,name:e})&&((0,u.Q)(this.props.repository[e].messages,s.version,this.props.repository[e].version)?console.log("Adapter ".concat(e," is filtered out from update all functionality, because it has messages which need to be read before update")):t.push(e))})),t.sort(),t}getNews(t){const e=this.props.repository[t],s=this.props.installed[t],i=[];return s&&null!==e&&void 0!==e&&e.news&&Object.keys(e.news).forEach((t=>{try{r().gt(t,s.version)&&i.push({version:t,news:this.props.noTranslation?e.news[t].en:e.news[t][this.props.lang]||e.news[t].en})}catch(o){console.warn('Cannot compare "'.concat(t,'" and "').concat(s.version,'"'))}})),i}renderOneAdapter(t){const e=this.props.selected.includes(t);if((this.props.finished||this.props.inProcess)&&!e)return null;if(!this.props.installed[t])return null;const s=".".concat(this.props.installed[t].localIcon);return(0,g.jsxs)(l.ListItem,{dense:!0,sx:{"&.MuiListItem-root":h.Utils.getStyle(this.props.theme,m.listItem,this.props.updated.includes(t)&&m.updateDone)},ref:this.props.current===t?this.currentRef:null,secondaryAction:this.props.finished||this.props.inProcess?this.props.current===t&&!this.props.stopped&&!this.props.finished&&(0,g.jsx)(l.CircularProgress,{}):(0,g.jsx)(l.Checkbox,{edge:"end",checked:e,tabIndex:-1,disableRipple:!0,disabled:this.props.inProcess,onClick:()=>{const e=[...this.props.selected],s=e.indexOf(t);-1!==s?e.splice(s,1):(e.push(t),e.sort()),this.props.onUpdateSelected(e)}}),children:[(0,g.jsx)(l.ListItemIcon,{sx:m.minWidthCss,children:(0,g.jsx)(l.Avatar,{variant:"square",alt:t,src:s,style:m.smallAvatar})}),(0,g.jsx)(l.ListItemText,{primary:t,title:this.getNews(t).map((t=>"".concat(t.version,": ").concat(t.news))).join("\n"),secondary:(0,g.jsxs)("span",{children:[(0,g.jsxs)("div",{style:m.versions,children:[this.initialVersions[t]," \u2192",(0,g.jsx)(l.Box,{component:"span",sx:m.toVersion,children:this.props.repository[t].version})]}),(0,g.jsx)(l.IconButton,{title:h.I18n.t("Show change log"),onClick:()=>this.setState({showNews:{adapter:t,version:this.props.repository[t].version,fromVersion:this.initialVersions[t]}}),size:"small",children:(0,g.jsx)(p.Info,{})})]})})]},t)}getReactNews(t,e){const s=this.props.repository[t],i=this.props.installed[t];e=e||i.version;const o=[];let n,a;const p=this.props.repository._repoInfo;var d,c,u,x;null!==p&&void 0!==p&&p.stable?(n=null===(d=this.props.repository[t])||void 0===d?void 0:d.version,a=null===(c=this.props.repository[t])||void 0===c?void 0:c.latestVersion):(n=null===(u=this.props.repository[t])||void 0===u?void 0:u.stable,a=null===(x=this.props.repository[t])||void 0===x?void 0:x.version);return i&&null!==s&&void 0!==s&&s.news&&Object.keys(s.news).forEach((t=>{try{if(r().gt(t,e)&&s.news[t]){const e=(this.props.noTranslation?s.news[t].en||"":s.news[t][this.props.lang]||s.news[t].en||"").split("\n").map((t=>t.trim().replace(/^\*\s?/,"").replace(/<!--[^>]*->/g,"").replace(/<! -[^>]*->/g,"").trim())).filter((t=>!!t));o.push((0,g.jsxs)(l.Grid2,{children:[(0,g.jsxs)(l.Typography,{sx:m.versionHeader,children:[t,a===t?(0,g.jsx)(l.Box,{component:"span",sx:m.repoLatestVersionText,children:"(latest)"}):null,n===t?(0,g.jsx)(l.Box,{component:"span",sx:m.repoStableVersionText,children:"(".concat(h.I18n.t("stable"),")")}):null]}),e.map(((e,s)=>(0,g.jsx)(l.Typography,{component:"div",variant:"body2",children:"\u2022 ".concat(e)},"".concat(t,"-").concat(s))))]},t))}}catch(i){console.warn('Cannot compare "'.concat(t,'" and "').concat(e,'"'))}})),o}renderShowNews(){if(this.state.showNews){const t=this.getReactNews(this.state.showNews.adapter,this.state.showNews.fromVersion),e=h.Utils.getStyle(this.props.theme,m.closeButton),s=h.Utils.getStyle(this.props.theme,m.languageButtonActive);return(0,g.jsxs)(l.Dialog,{onClose:()=>this.setState({showNews:null}),open:!0,children:[(0,g.jsx)(l.DialogTitle,{children:(0,g.jsxs)(l.Typography,{component:"h2",variant:"h6",sx:{"&.MuiTypography-root":m.typography},children:[(0,g.jsx)("div",{style:{width:"calc(100% - 60px)"},children:h.I18n.t('Update "%s" to v%s',this.state.showNews.adapter,this.state.showNews.version)}),(0,g.jsx)(l.IconButton,{size:"large",style:e,onClick:()=>this.setState({showNews:null}),children:(0,g.jsx)(p.Close,{})}),"en"!==h.I18n.getLanguage()&&this.props.toggleTranslation?(0,g.jsx)(l.IconButton,{size:"large",style:(0,i.A)((0,i.A)({},m.languageButton),this.props.noTranslation?s:void 0),onClick:this.props.toggleTranslation,title:h.I18n.t("Disable/Enable translation"),children:(0,g.jsx)(p.Language,{})}):null]})}),(0,g.jsx)(l.DialogContent,{dividers:!0,children:(0,g.jsx)(l.Grid2,{container:!0,direction:"column",spacing:2,wrap:"nowrap",children:t.length?(0,g.jsxs)(l.Grid2,{children:[(0,g.jsx)(l.Typography,{variant:"h6",gutterBottom:!0,children:h.I18n.t("Change log")}),(0,g.jsx)(l.Grid2,{container:!0,spacing:2,direction:"column",wrap:"nowrap",children:t})]}):h.I18n.t("No change log available")})}),(0,g.jsx)(l.DialogActions,{style:m.wrapperButton,children:(0,g.jsx)(l.Button,{variant:"contained",onClick:()=>this.setState({showNews:null}),color:"grey",startIcon:(0,g.jsx)(p.Close,{}),children:h.I18n.t("Close")})})]})}return null}render(){return this.current!==this.props.current&&(this.current=this.props.current,setTimeout((()=>{var t;return null===(t=this.currentRef.current)||void 0===t?void 0:t.scrollIntoView()}),200)),(0,g.jsxs)(l.List,{style:m.root,children:[this.updateAvailable.map((t=>this.renderOneAdapter(t))),this.renderShowNews()]})}}const y=x;var v=s(67958);const f={dialogRoot:{height:"calc(100% - 64px)"},wrapperHead:{justifyContent:"space-between",display:"flex"},checkbox:{marginRight:10},appBar:t=>({flexWrap:"wrap",position:"sticky",bottom:-10,pl:1,background:"blue"===t.name?"#5d6467":"dark"===t.name?"#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:t=>({color:t.palette.primary.main})};class w extends o.Component{constructor(t){super(t),this.updateAvailable=[],this.onAdapterFinished=void 0,this.processList=void 0,this.state={selected:[],inProcess:!1,finished:!1,current:"",updated:[],stopped:!1,debug:"true"===(window._localStorage||window.localStorage).getItem("AdaptersUpdaterDialog.debug"),stopOnError:"false"!==(window._localStorage||window.localStorage).getItem("AdaptersUpdaterDialog.stopOnError"),closeOnFinished:"true"===(window._localStorage||window.localStorage).getItem("AdaptersUpdaterDialog.closeOnFinished"),currentVersion:""},this.updateAvailable=[]}updateAdapter(t,e,s){this.onAdapterFinished=s,this.setState({current:t,currentVersion:e})}onStartUpdate(){this.setState({inProcess:!0},(()=>{this.props.onSetCommandRunning(!0),this.processList=[...this.state.selected].map((t=>{var e;return{adapter:t,version:null===(e=this.props.repository[t])||void 0===e?void 0:e.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){const{adapter:e,version:s}=this.processList.shift();this.updateAdapter(e,s,(()=>{const s=[...this.state.updated];s.push(e),this.setState({updated:s},(()=>setTimeout((()=>this.updateAdapters(t)),200)))}))}else t&&t()}render(){const t=this.props.noTranslation?h.Utils.getStyle(this.props.theme,f.languageButtonActive):void 0;return(0,g.jsxs)(l.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":f.dialogRoot},scroll:"paper",children:[(0,g.jsx)(l.DialogTitle,{id:"update-dialog-title",children:(0,g.jsxs)("div",{style:f.wrapperHead,children:[this.props.t("Update %s adapter(s)",this.state.selected.length),!this.state.finished&&!this.state.inProcess&&(0,g.jsx)(l.Tooltip,{title:this.props.t("Select/Unselect all"),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:(0,g.jsx)(l.Checkbox,{checked:this.state.selected.length===this.updateAvailable.length,style:f.checkbox,tabIndex:-1,indeterminate:this.state.selected.length!==this.updateAvailable.length&&0!==this.state.selected.length,disableRipple:!0,onClick:()=>{let t=[];this.state.selected.length!==this.updateAvailable.length&&(t=[...this.updateAvailable]),this.setState({selected:t})}})}),"en"!==h.I18n.getLanguage()&&this.props.toggleTranslation?(0,g.jsx)(l.IconButton,{size:"large",style:(0,i.A)((0,i.A)({},f.languageButton),t),onClick:()=>this.props.toggleTranslation(),title:h.I18n.t("Disable/Enable translation"),children:(0,g.jsx)(p.Language,{})}):null]})}),(0,g.jsxs)(l.DialogContent,{sx:{"&.MuiDialogContent-root":f.content},style:{height:"100%"},children:[(0,g.jsxs)(l.Grid2,{container:!0,direction:"row",sx:f.container,children:[(0,g.jsx)(l.Grid2,{style:{height:"100%",overflow:"hidden",width:this.state.current?250:"100%"},children:(0,g.jsx)("div",{style:{height:"100%",overflow:"auto"},children:(0,g.jsx)(y,{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:(t,e)=>{e&&(this.updateAvailable=e),this.setState({selected:t})},theme:this.props.theme})})}),!!this.state.current&&(0,g.jsx)(l.Grid2,{style:{height:"100%",overflow:"hidden",width:"calc(100% - 260px)",minWidth:240},children:(0,g.jsx)(v.A,{noSpacing:!0,ready:!0,host:this.props.currentHost,socket:this.props.socket,t:this.props.t,cmd:"upgrade ".concat(this.state.current,"@").concat(this.state.currentVersion).concat(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)})]}),(0,g.jsxs)(l.Toolbar,{variant:"dense",disableGutters:!0,sx:f.appBar,children:[(0,g.jsx)(l.FormControlLabel,{control:(0,g.jsx)(l.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")}),(0,g.jsx)(l.FormControlLabel,{control:(0,g.jsx)(l.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")}),(0,g.jsx)(l.FormControlLabel,{control:(0,g.jsx)(l.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")})]})]}),(0,g.jsxs)(l.DialogActions,{children:[(0,g.jsx)(l.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:(0,g.jsx)(p.Check,{}),children:this.props.t("Update")}),(0,g.jsx)(l.Button,{id:"adapters-update-dialog-cancel",variant:"contained",disabled:!this.state.inProcess,color:"grey",startIcon:(0,g.jsx)(p.Cancel,{}),onClick:()=>{this.setState({stopped:!0,finished:!0}),this.props.onSetCommandRunning(!1)},children:this.props.t("Cancel")}),(0,g.jsx)(l.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:(0,g.jsx)(p.Close,{}),children:this.props.t("Close")})]})]})}}const b=w;var j=s(27985),A=s(79091),C=s(17774),T=s(13459);class S extends T.y{constructor(t,e){super(t,"".concat(e,".adapter"),"adapter"),this.host=void 0,this.prefix=void 0,this.prefix="".concat(e,".adapter."),this.host=e}getObject(t){return this.objects&&this.objects[this.prefix+t]||null}getHost(){return this.host}}function I(t){return{id:"github-install-dialog-tab-".concat(t),"aria-controls":"github-install-dialog-panel-".concat(t)}}const k={root:t=>({backgroundColor:t.palette.background.paper,width:"100%",height:"100%"}),paper:{maxWidth:1e3},tabPaper:{padding:16},title:t=>({mt:"10px",p:1,ml:1,fontSize:18,color:t.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:t=>({color:"dark"===t.palette.mode?t.palette.secondary.contrastText:"#222 !important"})};class V extends n().Component{constructor(t){super(t);let e=[];const s=(window._localstorage||window.localStorage).getItem("App.npmHistory");if(s)try{e=JSON.parse(s)}catch(i){}this.state={autoCompleteValue:(window._localstorage||window.localStorage).getItem("App.autocomplete")||null,debug:"true"===(window._localstorage||window.localStorage).getItem("App.gitDebug"),url:(window._localstorage||window.localStorage).getItem("App.userUrl")||"",currentTab:(window._localstorage||window.localStorage).getItem("App.gitTab")||"npm",customHistory:e}}renderNpm(){return"npm"===this.state.currentTab?(0,g.jsxs)(l.Paper,{style:k.tabPaper,id:"github-install-dialog-panel-npm",children:[(0,g.jsx)("div",{style:{display:"flex",alignItems:"center"},children:(0,g.jsx)(l.FormControlLabel,{control:(0,g.jsx)(l.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")})}),(0,g.jsxs)("div",{style:{display:"flex",alignItems:"flex-end"},children:[(0,g.jsx)(p.Sms,{style:{marginRight:10}}),(0,g.jsx)(l.Autocomplete,{fullWidth:!0,value:this.state.autoCompleteValue,onChange:(t,e)=>{(window._localstorage||window.localStorage).setItem("App.autocomplete",e),this.setState({autoCompleteValue:e})},options:this.getList(),getOptionLabel:t=>{var e;return null!==(e=null===t||void 0===t?void 0:t.name)&&void 0!==e?e:""},renderInput:t=>{var e;const s=(0,i.A)({},t);return s.InputProps=s.InputProps||{},s.InputProps.startAdornment=(0,g.jsx)(l.InputAdornment,{position:"start",children:(0,g.jsx)(h.Icon,{src:(null===(e=this.state.autoCompleteValue)||void 0===e?void 0:e.icon)||"",style:k.listIcon})}),(0,g.jsx)(l.TextField,(0,i.A)((0,i.A)({variant:"standard"},t),{},{label:h.I18n.t("Select adapter")}))},renderOption:(t,e)=>{var s;return(0,g.jsxs)(l.Box,(0,i.A)((0,i.A)({component:"li",sx:{"& > img":{mr:2,flexShrink:0}}},t),{},{children:[(0,g.jsx)(h.Icon,{src:(null===e||void 0===e?void 0:e.icon)||"",style:k.listIconWithMargin}),null!==(s=null===e||void 0===e?void 0:e.name)&&void 0!==s?s:""]}))}})]}),(0,g.jsx)("div",{style:{fontSize:24,fontWeight:"bold",marginTop:40},children:this.props.t("Warning!")}),(0,g.jsx)("div",{style:k.warningText,children:this.props.t("npm_warning","NPM","NPM")}),(0,g.jsx)("div",{style:k.noteText,children:this.props.t("github_note")})]}):null}renderGitHub(){return"GitHub"===this.state.currentTab?(0,g.jsxs)(l.Paper,{style:k.tabPaper,id:"github-install-dialog-panel-github",children:[(0,g.jsx)("div",{style:{display:"flex",alignItems:"center"},children:(0,g.jsx)(l.FormControlLabel,{control:(0,g.jsx)(l.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")})}),(0,g.jsxs)("div",{style:{display:"flex",alignItems:"flex-end"},children:[(0,g.jsx)(p.Sms,{style:{marginRight:10}}),(0,g.jsx)(l.Autocomplete,{fullWidth:!0,value:this.state.autoCompleteValue,getOptionDisabled:t=>!(null===t||void 0===t||!t.nogit),renderOption:(t,e)=>{var s;return(0,g.jsxs)(l.Box,(0,i.A)((0,i.A)({component:"li",sx:{"& > img":{mr:2,flexShrink:0}}},t),{},{children:[(0,g.jsx)(h.Icon,{src:(null===e||void 0===e?void 0:e.icon)||"",style:k.listIconWithMargin}),null!==(s=null===e||void 0===e?void 0:e.name)&&void 0!==s?s:"",(null===e||void 0===e?void 0:e.nogit)&&(0,g.jsx)("div",{style:k.errorTextNoGit,children:h.I18n.t("This adapter cannot be installed from git as must be built before installation.")})]}))},onChange:(t,e)=>{(window._localstorage||window.localStorage).setItem("App.autocomplete",e),this.setState({autoCompleteValue:e})},options:this.getList(),getOptionLabel:t=>{var e;return null!==(e=null===t||void 0===t?void 0:t.name)&&void 0!==e?e:""},renderInput:t=>{var e;const s=(0,i.A)({},t);return s.InputProps=s.InputProps||{},s.InputProps.startAdornment=(0,g.jsx)(l.InputAdornment,{position:"start",children:(0,g.jsx)(h.Icon,{src:(null===(e=this.state.autoCompleteValue)||void 0===e?void 0:e.icon)||"",style:k.listIconWithMargin})}),(0,g.jsx)(l.TextField,(0,i.A)((0,i.A)({variant:"standard"},t),{},{label:h.I18n.t("Select adapter")}))}})]}),(0,g.jsx)("div",{style:{fontSize:24,fontWeight:"bold",marginTop:40},children:this.props.t("Warning!")}),(0,g.jsx)("div",{style:k.warningText,children:this.props.t("github_warning","GitHub","GitHub")}),(0,g.jsx)("div",{style:k.noteText,children:this.props.t("github_note")})]}):null}renderCustom(){return"URL"===this.state.currentTab?(0,g.jsxs)(l.Paper,{style:k.tabPaper,id:"github-install-dialog-panel-custom",children:[(0,g.jsx)("div",{style:{display:"flex",alignItems:"center"},children:(0,g.jsx)(l.FormControlLabel,{control:(0,g.jsx)(l.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")})}),(0,g.jsx)("div",{style:{display:"flex",alignItems:"center"},children:(0,g.jsx)(l.Autocomplete,{fullWidth:!0,value:this.state.url||"",onInputChange:(t,e)=>{(window._localstorage||window.localStorage).setItem("App.userUrl",e||""),this.setState({url:e})},onChange:(t,e)=>{(window._localstorage||window.localStorage).setItem("App.userUrl",e||""),this.setState({url:e})},renderOption:(t,e)=>(0,g.jsxs)(l.Box,(0,i.A)((0,i.A)({component:"li"},t),{},{style:{display:"flex",alignItems:"left"},children:[e,(0,g.jsx)("div",{style:{flexGrow:1}}),(0,g.jsx)(l.IconButton,{size:"small",onClick:t=>{t.stopPropagation();const s=this.state.customHistory.filter((t=>t!==e));(window._localstorage||window.localStorage).setItem("App.npmHistory",JSON.stringify(s)),this.setState({customHistory:s})},children:(0,g.jsx)(p.Delete,{})})]})),freeSolo:!0,options:this.state.customHistory,renderInput:t=>(0,g.jsx)(l.TextField,(0,i.A)((0,i.A)({variant:"standard"},t),{},{onKeyUp:t=>{if("Enter"===t.key&&this.state.url){const t=[...this.state.customHistory];t.unshift(this.state.url),t.length>10&&t.pop(),(window._localstorage||window.localStorage).setItem("App.npmHistory",JSON.stringify(t)),this.state.url.includes(".")?this.props.installFromUrl(this.state.url,this.state.debug,!0):this.props.installFromUrl("iobroker.".concat(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")}))})}),(0,g.jsx)("div",{style:{fontSize:24,fontWeight:"bold",marginTop:40},children:this.props.t("Warning!")}),(0,g.jsx)("div",{style:k.warningText,children:this.props.t("github_warning","URL","URL")}),(0,g.jsx)("div",{style:k.noteText,children:this.props.t("github_note")})]}):null}getList(){const t=function(t){const e=[];for(let s=0;s<t.length;s++)"object"===typeof t[s]?t[s].forEach((t=>e.push(t))):e.push(t[s]);return e}(this.props.categories.map((t=>t.adapters)));return t.sort(),t.map(((e,s)=>{if(s&&t[s-1]===e)return null;const i=this.props.repository[e];if(null===i||void 0===i||!i.controller){const t=(i.extIcon||i.meta||i.readme||"").toString().split("/");let s=null===i||void 0===i?void 0:i.name;s||(s=i.titleLang,s=s&&"object"===typeof s?s[h.I18n.getLanguage()]||s.en:i.title||e);const o={value:"".concat(e,"/").concat(t[3]),name:"".concat(s," [").concat(t[3],"]"),icon:i.extIcon||i.icon,nogit:!!i.nogit,title:e};return this.props.installed[s]&&"admin"!==s&&(o.icon="/adapter/".concat(e,"/").concat(i.icon.split("/admin/").pop())),o}return null})).filter((t=>t)).sort(((t,e)=>t.name<e.name?-1:t.name>e.name?1:0))}render(){var t;const e=()=>this.setState({autoCompleteValue:null,url:""});return(0,g.jsxs)(l.Dialog,{onClose:()=>this.props.onClose(),open:!0,sx:{"& .MuiDialog-paper":k.paper},children:[(0,g.jsx)(l.DialogContent,{dividers:!0,children:(0,g.jsxs)(l.Box,{component:"div",sx:k.root,children:[(0,g.jsx)(l.AppBar,{position:"static",color:"default",children:(0,g.jsxs)(l.Tabs,{value:this.state.currentTab,onChange:(t,e)=>{(window._localstorage||window.localStorage).setItem("App.gitTab",e),this.setState({currentTab:e})},variant:"fullWidth",indicatorColor:"secondary",children:[(0,g.jsx)(l.Tab,(0,i.A)((0,i.A)({label:this.props.t("From npm"),wrapped:!0,sx:{"&.Mui-selected":k.tabSelected},icon:(0,g.jsx)("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEOSURBVGhD7dixCoJQGMVxDSOoodFACJSmaPQ5mpscfYUeo6WXCFx6gFanpsDRqMWhRYgGIbSWbxFBbdDThfNb9Iz/4XJF/aypbSBPZTEAjQFoDEBjAJryAS0+JXRdNwx578snz7WikFGrOWBk28soktGXm+elQSCjVosAx1nFsYy+XDeb9HCQUYuHGI0BaAxAUz6g23vgeToVWSajbGiaE9eVUdH+Hug24GJZ7ySRUTZdrxfHo4wKXmTqYAAaA9AYgMYANAagMQCNAWgMQGMAGgPQGIDGADTlA5r/jRqmOd/vZfzo7vt5msooG7vubLuVUfHY7V5hKKNWc8Cf4xlAYwAaA9AYgMYANAZgadoX+gw72Zvh2hIAAAAASUVORK5CYII=",alt:"npm",width:24,height:24})},I("npm")),{},{value:"npm"})),(0,g.jsx)(l.Tab,(0,i.A)((0,i.A)({label:this.props.t("From github"),wrapped:!0,sx:{"&.Mui-selected":k.tabSelected},icon:(0,g.jsx)(d.hL4,{style:{width:24,height:24},width:24,height:24})},I("github")),{},{value:"GitHub"})),(0,g.jsx)(l.Tab,(0,i.A)((0,i.A)({label:this.props.t("Custom"),wrapped:!0,sx:{"&.Mui-selected":k.tabSelected},icon:(0,g.jsx)(p.Language,{width:24,height:24})},I("custom")),{},{value:"URL"}))]})}),(0,g.jsx)(l.Box,{component:"div",sx:k.title,children:this.props.t("Install or update the adapter from %s",this.state.currentTab||"npm")}),this.renderNpm(),this.renderGitHub(),this.renderCustom()]})}),(0,g.jsxs)(l.DialogActions,{children:[(0,g.jsx)(l.Button,{id:"github-install-dialog-ok",variant:"contained",disabled:("GitHub"===this.state.currentTab||"npm"===this.state.currentTab)&&!(null!==(t=this.state.autoCompleteValue)&&void 0!==t&&t.value)||"URL"===this.state.currentTab&&!this.state.url,autoFocus:!0,onClick:async()=>{if("GitHub"===this.state.currentTab){var t;const e=((null===(t=this.state.autoCompleteValue)||void 0===t?void 0:t.value)||"").split("/"),s="".concat(e[1],"/ioBroker.").concat(e[0]);this.props.installFromUrl(s,this.state.debug,!0)}else if("URL"===this.state.currentTab){const t=[...this.state.customHistory];t.unshift(this.state.url),t.length>10&&t.pop(),(window._localstorage||window.localStorage).setItem("App.npmHistory",JSON.stringify(t)),this.state.url.includes(".")?this.props.installFromUrl(this.state.url,this.state.debug,!0):this.props.installFromUrl("iobroker.".concat(this.state.url),this.state.debug,!0)}else if("npm"===this.state.currentTab){var s;const t=((null===(s=this.state.autoCompleteValue)||void 0===s?void 0:s.value)||"").split("/")[0],e=t.includes(".")?t.split(".")[1]:t;try{await this.props.installFromUrl("iobroker.".concat(e,"@latest"),this.state.debug,!0),this.props.upload(e)}catch(i){console.error("Installation from url failed: ".concat(i.message))}}this.props.onClose(),e()},color:"primary",startIcon:(0,g.jsx)(p.Check,{}),children:this.props.t("Install")}),(0,g.jsx)(l.Button,{id:"github-install-dialog-close",variant:"contained",onClick:()=>{this.props.onClose(),e()},color:"grey",startIcon:(0,g.jsx)(p.Close,{}),children:this.props.t("Close")})]})]})}}const D=V;var R=s(31341);const N={formControl:{marginTop:24,width:100},closeButton:t=>({position:"absolute",right:8,top:8,color:t.palette.grey[500]}),languageButton:{position:"absolute",right:60,top:8},languageButtonActive:t=>({color:t.palette.primary.main}),paper:{},typography:{pr:"30px"},messageText:{},messageColor_warn:{color:"#cb7642"},messageColor_error:{color:"#f5614d"},messageColor_info:{color:"#5abd29"},messageTitle_warn:t=>({background:"#cb7642",borderRadius:"3px",pl:"10px",fontWeight:"bold",color:"dark"===t.palette.mode?"black":"white"}),messageTitle_error:t=>({background:"#f5614d",borderRadius:"3px",pl:"10px",fontWeight:"bold",color:"dark"===t.palette.mode?"black":"white"}),messageTitle_info:t=>({background:"#5abd29",borderRadius:"3px",pl:"10px",fontWeight:"bold",color:"dark"===t.palette.mode?"black":"white"}),deps:t=>({m:"10px",fontSize:16,color:"dark"===t.palette.mode?"#e70000":"#840101"})};class L extends o.Component{constructor(t){super(t),this.t=void 0,this.messages=null,this.lang=void 0,this.state={instanceNumbers:[]},this.t=t.t,this.lang=h.I18n.getLanguage(),this.messages=(0,u.Q)(t.adapterObject.messages,null,t.adapterObject.version,t.instances)}componentDidMount(){this.props.instancesWorker.getObjects().then((t=>{const e=Object.keys(t).filter((e=>{var s,i;return(null===(s=t[e])||void 0===s||null===(i=s.common)||void 0===i?void 0:i.name)===this.props.adapter})).map((t=>t.substring(t.lastIndexOf(".")+1)));this.setState({instanceNumbers:e})}))}getAvailableInstances(){const t=[];t.push((0,g.jsx)(l.MenuItem,{value:"auto",children:this.t("auto")},"auto"));for(let e=0;e<=100&&(this.state.instanceNumbers.includes(e.toString())||t.push((0,g.jsx)(l.MenuItem,{value:e.toString(),children:e},e)),!(t.length>11));e++);return t}checkDependencies(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props.dependencies;if(!t)return"";const e=[];for(const s of t)s.installedVersion?s.rightVersion||e.push("".concat(this.props.t("Invalid version of %s. Required %s. Current ",s.name,s.version)).concat(s.installedVersion)):e.push(this.props.t("No version of %s",s.name,s.name));return e.length?e.map((t=>(0,g.jsx)("div",{children:t},t))):""}getText(t,e){return t&&"object"===typeof t?e?t.en:t[this.lang]||t.en:"object"===typeof t?"":t}renderOneMessage(t,e){return(0,g.jsxs)(l.Grid2,{children:[(0,g.jsx)(l.Typography,{sx:N["messageTitle_".concat(t.level||"warn")],children:this.getText(t.title,this.props.noTranslation)||""}),(0,g.jsx)(l.Typography,{component:"div",variant:"body2",style:N.messageText,children:this.getText(t.text,this.props.noTranslation)||""}),t.link?(0,g.jsx)(l.Button,{onClick:()=>{window.open(t.link,"_blank").focus()},startIcon:(0,g.jsx)(p.Public,{}),variant:"contained",color:"grey",children:this.getText(t.linkText,this.props.noTranslation)||this.props.t("More info")}):null]},e)}renderMessages(){return this.messages?(0,g.jsx)(l.Grid2,{container:!0,spacing:2,direction:"column",wrap:"nowrap",sx:{marginBottom:1},children:this.messages.map(((t,e)=>this.renderOneMessage(t,e)))}):null}render(){const t=this.checkDependencies();return(0,g.jsxs)(l.Dialog,{onClose:()=>{},open:!0,sx:{"& .MuiDialog-paper":N.paper},children:[(0,g.jsx)(l.DialogTitle,{children:(0,g.jsxs)(l.Typography,{component:"h2",variant:"h6",sx:{"&.MuiTypography-root":N.typography},children:[this.t("You are going to add new instance:")," ",this.props.adapter,(0,g.jsx)(l.IconButton,{size:"large",sx:N.closeButton,onClick:()=>this.props.onClose(!1),children:(0,g.jsx)(p.Close,{})}),this.messages&&"en"!==this.lang&&this.props.toggleTranslation?(0,g.jsx)(l.IconButton,{size:"large",style:h.Utils.getStyle(this.props.theme,N.languageButton,this.props.noTranslation&&N.languageButtonActive),onClick:this.props.toggleTranslation,title:h.I18n.t("Disable/Enable translation"),children:(0,g.jsx)(p.Language,{})}):null]})}),(0,g.jsxs)(l.DialogContent,{dividers:!0,children:[this.renderMessages(),!t&&this.props.expertMode?(0,g.jsxs)(l.Grid2,{container:!0,direction:"column",children:[(0,g.jsx)(R.A,{tooltip:this.t("Select host to add the instance"),expertMode:!0,socket:this.props.socket,hostsWorker:this.props.hostsWorker,currentHost:this.props.currentHost,setCurrentHost:(t,e)=>this.props.onHostChange(e.replace(/^system\.host\./,""))}),(0,g.jsxs)(l.FormControl,{variant:"standard",style:N.formControl,children:[(0,g.jsx)(l.InputLabel,{id:"instance-label",children:this.t("Instance")}),(0,g.jsx)(l.Select,{variant:"standard",labelId:"instance-label",value:this.props.currentInstance,onChange:this.props.onInstanceChange,children:this.getAvailableInstances()})]})]}):null,(0,g.jsx)(l.Box,{component:"div",sx:N.deps,children:t})]}),(0,g.jsxs)(l.DialogActions,{children:[(0,g.jsx)(l.Button,{id:"instance-add-dialog-ok",variant:"contained",autoFocus:!0,disabled:!!t,onClick:()=>this.props.onClose(!0),color:"primary",startIcon:(0,g.jsx)(p.Add,{}),children:this.t("Add")}),(0,g.jsx)(l.Button,{id:"instance-add-dialog-cancel",variant:"contained",onClick:()=>this.props.onClose(!1),color:"grey",startIcon:(0,g.jsx)(p.Close,{}),children:this.t("Close")})]})]})}}const U=L;var B=s(60521);function O(t){var e;if(!t)return"";let s=(null===(e=t.licenseInformation)||void 0===e?void 0:e.link)||t.licenseUrl;if(!s||!s.includes("/LICENSE")||!s.includes("raw.githubusercontent.com")){if(s=t.extIcon,!s){if(s=t.readme,!s)return console.error("No extIcon for ".concat(t.name||JSON.stringify(t))),"";s=s.replace("github.com","raw.githubusercontent.com").replace("/blob/","/"),s.includes("/main")?s="".concat(s.split("/main")[0],"/main/LICENSE"):s.includes("/master")&&(s="".concat(s.split("/master")[0],"/master/LICENSE"))}if(s.includes("/main"))s="".concat(s.split("/main")[0],"/main/LICENSE");else{if(!s.includes("/master"))return"";s="".concat(s.split("/master")[0],"/master/LICENSE")}}return s}class W extends o.Component{constructor(t){super(t),this.state={showDialog:!1,showLicenseDialog:null,addInstanceHostName:"",addInstanceId:"auto",addInstanceDialog:""}}renderLicenseDialog(t){return this.state.showLicenseDialog?(0,g.jsx)(B.A,{licenseType:this.state.showLicenseDialog.licenseType,url:this.state.showLicenseDialog.url,onClose:e=>{const s=e?this.state.showLicenseDialog:null;this.setState({showLicenseDialog:null,showDialog:!1},(()=>{s&&(s.upload?W.upload(s.adapterName,t):this.addInstance({adapterName:s.adapterName,context:t}).catch((t=>window.alert("Cannot add instance: ".concat(t)))))}))}}):null}async addInstance(t){if(!t.customUrl){const e=t.context.repository[t.adapterName],s=(0,u.Q)(e.messages,null,e.version,t.context.compactInstances);if(!t.instance&&(t.context.expertMode||s))return void this.setState({addInstanceDialog:t.adapterName,showDialog:!0,addInstanceHostName:t.context.currentHost.replace(/^system\.host\./,""),addInstanceId:t.instance||"auto"});if(t.instance){const e=await t.context.instancesWorker.getObjects();if(e&&e["system.adapter.".concat(t.adapterName,".").concat(t.instance)])return void window.alert(t.context.t("Instance %s already exists","".concat(t.adapterName,".").concat(t.instance)))}}const e=(this.state.addInstanceHostName||t.context.currentHost).replace(/^system\.host\./,"");try{await new Promise(((s,i)=>{t.context.executeCommand("".concat(t.customUrl?"url":"add"," ").concat(t.adapterName," ").concat(t.instance?"".concat(t.instance," "):"","--host ").concat(e," ").concat(t.debug||t.context.expertMode?"--debug":""),e,(t=>t?i(new Error("The process returned an exit code of ".concat(t))):s()))}))}catch(s){window.alert("".concat(h.I18n.t("Cannot install"),": ").concat(s))}}static getDependencies(t,e){const s=e.repository[t],i=[];if(s){var o,n;s.dependencies&&!Array.isArray(s.dependencies)&&(s.dependencies=[s.dependencies]),s.globalDependencies&&!Array.isArray(s.globalDependencies)&&(s.globalDependencies=[s.globalDependencies]);const t=s.node;if(null!==(o=s.dependencies)&&void 0!==o&&o.length)for(const o of s.dependencies){const t={name:"",version:null,installed:!1,installedVersion:null,rightVersion:!1},s="string"!==typeof o,n=Object.keys(o);if(t.name=s?n?n[0]:null:o,t.version=s?o[t.name]:null,i&&t.name){const i=e.installed[t.name];t.installed=!!i,t.installedVersion=i?i.version:null;try{t.rightVersion=!!i&&(!s||r().satisfies(i.version,t.version,{includePrerelease:!0}))}catch(a){t.rightVersion=!0}}i.push(t)}if(null!==(n=s.globalDependencies)&&void 0!==n&&n.length)for(const o of s.globalDependencies){const t={name:"",version:null,installed:!1,installedVersion:null,rightVersion:!1},s="string"!==typeof o,n=Object.keys(o);if(t.name=s?n?n[0]:null:o,t.version=s?o[t.name]:null,i&&t.name){const i=e.installedGlobal[t.name];t.installed=!!i,t.installedVersion=i?i.version:null;try{t.rightVersion=!!i&&(!s||r().satisfies(i.version,t.version,{includePrerelease:!0}))}catch(l){t.rightVersion=!0}}i.push(t)}if(t){const s={name:"node",version:t,installed:!0,installedVersion:e.nodeJsVersion,rightVersion:!1};try{s.rightVersion=r().satisfies(e.nodeJsVersion,t)}catch(p){s.rightVersion=!0}i.push(s)}}return i}renderAddInstanceDialog(t){return this.state.addInstanceDialog?(0,g.jsx)(U,{adapter:this.state.addInstanceDialog,socket:t.socket,hostsWorker:t.hostsWorker,instancesWorker:t.instancesWorker,dependencies:W.getDependencies(this.state.addInstanceDialog,t),currentHost:"system.host.".concat(this.state.addInstanceHostName),currentInstance:this.state.addInstanceId,t:t.t,onClose:e=>{const s=e?this.state.addInstanceDialog:"",i=e?this.state.addInstanceId:"";this.setState({addInstanceDialog:"",addInstanceId:"auto",showDialog:!1},(()=>{if(s)try{this.addInstance({adapterName:s,instance:i,context:t})}catch(e){window.alert("Cannot add instance: ".concat(e))}}))},onHostChange:t=>this.setState({addInstanceHostName:t.replace(/^system\.host\./,"")}),onInstanceChange:t=>this.setState({addInstanceId:t.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,e){e.executeCommand("upload ".concat(t).concat(e.expertMode?" --debug":""))}onAddInstance(t,e){var s;const i=e.repository[t],o=O(i),n=(null===(s=i.licenseInformation)||void 0===s?void 0:s.license)||i.license;"MIT"===n?this.addInstance({adapterName:t,context:e}).catch((t=>window.alert("Cannot add instance: ".concat(t)))):this.setState({showLicenseDialog:{url:o,adapterName:t,licenseType:n},showDialog:!0})}renderDialogs(t){return this.state.showDialog?(0,g.jsxs)(g.Fragment,{children:[this.renderAddInstanceDialog(t),this.renderLicenseDialog(t)]}):null}}var F=s(22631),P=s(23106),M=s(90457);const H={name:{flexWrap:"nowrap",width:300,marginTop:0},nameDiv:{display:"flex",alignItems:"center"},categoryName:{fontWeight:"bold",cursor:"pointer"},green:{color:F.A[500]},blue:{color:P.A[700]},category:{backgroundColor:"background.default"},marginRight5:{marginRight:5}};const E=function(t){const{installedCount:e,name:s,categoryName:o}=t;return(0,g.jsxs)(l.TableRow,{hover:!1,sx:H.category,children:[(0,g.jsx)(l.TableCell,{children:(0,g.jsx)(l.Grid2,{container:!0,spacing:1,alignItems:"center",style:H.name,children:(0,g.jsx)(l.Grid2,{component:"div",children:(0,g.jsx)(l.IconButton,{size:"small",onClick:t.onToggle,children:t.expanded?(0,g.jsx)(p.ExpandMore,{}):(0,g.jsx)(p.ChevronRight,{})})})})}),(0,g.jsx)(l.TableCell,{onClick:t.onToggle,children:(0,g.jsxs)("div",{style:(0,i.A)((0,i.A)({},H.nameDiv),H.categoryName),children:[(0,g.jsx)(M.A,{iconName:o,style:H.marginRight5}),s]})}),(0,g.jsxs)(l.TableCell,{colSpan:t.descHidden?5:6,children:[(0,g.jsx)(l.Typography,{component:"span",variant:"body2",style:H.green,children:e})," ".concat(t.t("of")," "),(0,g.jsx)(l.Typography,{component:"span",variant:"body2",style:H.blue,children:t.count})," ".concat(t.t("Adapters from this Group installed"))]})]})};var _=s(83123),G=s(53986),z=s(22103),J=s(79313);const Y={rating:{marginBottom:20},listRating:{marginRight:8},listTime:{opacity:.5,fontStyle:"italic"},list:{},listOwn:t=>({backgroundColor:"colored"===t.name||"light"===t.name?"#16516e2e":t.palette.secondary.dark}),listTitle:t=>({backgroundColor:t.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"}},Z=[{id:"en",title:"English"},{id:"de",title:"Deutsch"},{id:"ru",title:"\u0440\u0443\u0441\u0441\u043a\u0438\u0439"},{id:"pt",title:"Portugues"},{id:"nl",title:"Nederlands"},{id:"fr",title:"fran\xe7ais"},{id:"it",title:"Italiano"},{id:"es",title:"Espanol"},{id:"pl",title:"Polski"},{id:"uk",title:"\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430"},{id:"zh-cn",title:"\u7b80\u4f53\u4e2d\u6587"}];class Q extends o.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/".concat(this.props.adapter,"?uuid=").concat(this.props.uuid)).then((t=>t.json())).then((t=>{(t=t||{}).rating=t.rating||{};const e=Object.keys(t.rating);e.sort(((e,s)=>t.rating[e].ts>t.rating[s].ts?-1:t.rating[e].ts<t.rating[s].ts?1:0));const s={};if(t.comments&&(t.comments.sort(((t,e)=>t.ts>e.ts?-1:t.ts<e.ts?1:0)),t.comments.forEach((t=>{s[t.lang]=s[t.lang]||0,s[t.lang]++}))),e.length){const i=t.rating[e[0]];this.setState({votings:t,ratingNumber:i?i.r:0,commentsByLanguage:s})}else this.setState({votings:t,commentsByLanguage:s})}))}setAdapterRating(t,e,s,i,o){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:e,rating:s,comment:i,lang:o})}).then((t=>t.json())).then((i=>(window.alert("".concat(this.props.t("Vote:")," ").concat(t,"@").concat(e,"=").concat(s)),delete i.adapter,i))).catch((t=>(window.alert("Cannot vote: ".concat(t)),null)))}renderInfoText(){return(0,g.jsxs)("div",{style:Y.infoTextContainer,children:[(0,g.jsx)(p.Info,{}),(0,g.jsx)(l.Typography,{style:Y.infoText,children:this.props.t("use GitHub for issues")})]})}renderComments(){var t;if(null!==(t=this.state.votings)&&void 0!==t&&t.comments&&this.state.votings.comments.length){const t=this.state.votings.comments.find((t=>!(this.state.filterLang&&"_"!==this.state.filterLang&&t.lang!==this.state.filterLang)));return(0,g.jsxs)("div",{style:{width:"100%",textAlign:"left"},children:[(0,g.jsx)(l.Box,{component:"h3",sx:Y.listTitle,children:this.props.t("Comments")}),(0,g.jsxs)(l.FormControl,{variant:"standard",style:Y.languageFilter,children:[(0,g.jsx)(l.InputLabel,{children:this.props.t("Show comments in language")}),(0,g.jsxs)(l.Select,{variant:"standard",value:this.state.filterLang,onChange:t=>{(window._localStorage||window.localStorage).setItem("app.commentLang",t.target.value),this.setState({filterLang:t.target.value})},children:[(0,g.jsxs)(l.MenuItem,{value:"_",children:[this.props.t("All")," ",(0,g.jsx)("span",{style:Y.commentCount,children:this.state.votings.comments.length})]}),Z.map((t=>(0,g.jsxs)(l.MenuItem,{value:t.id,children:[t.title," ",this.state.commentsByLanguage[t.id]?(0,g.jsx)("span",{style:Y.commentCount,children:this.state.commentsByLanguage[t.id]}):null]},t.id)))]})]}),(0,g.jsxs)(l.List,{style:Y.list,dense:!0,disablePadding:!0,children:[t&&this.state.votings.comments.map(((t,e)=>this.state.filterLang&&"_"!==this.state.filterLang&&t.lang!==this.state.filterLang?null:t?(0,g.jsxs)(l.ListItem,{title:t.uuid?this.props.t("Your comment"):"",sx:{"&.MuiListItem-root":t.uuid?Y.listOwn:void 0},dense:!0,children:[(0,g.jsx)(l.ListItemAvatar,{style:Y.listRating,children:(0,g.jsx)(l.Rating,{readOnly:!0,defaultValue:t.rating,size:"small"})}),(0,g.jsx)(l.ListItemText,{primary:t.comment,secondary:"".concat(new Date(t.ts).toLocaleString()," / v").concat(t.version),sx:{"& .MuiListItemText-secondary":Y.listTime}})]},e):null)),!t&&(0,g.jsx)("div",{style:Y.noComments,children:this.props.t("No comments in selected language")})]})]})}return null}render(){var t,e,s;let i,o;if(this.state.votings){const t=this.state.votings.rating;o=Object.keys(t),o.sort(((e,s)=>t[e].ts>t[s].ts?-1:t[e].ts<t[s].ts?1:0)),o.length&&(i=t[o[0]])}return(0,g.jsxs)(l.Dialog,{open:!0,onClose:()=>this.props.onClose(),children:[(0,g.jsx)(l.DialogTitle,{children:"".concat(this.props.t("Review")," ").concat(this.props.adapter).concat(this.props.version?"@".concat(this.props.version):"")}),(0,g.jsxs)(l.DialogContent,{style:{textAlign:"center"},title:(null===(t=this.props.currentRating)||void 0===t?void 0:t.title)||"",children:[this.renderInfoText(),(0,g.jsx)(l.Rating,{style:Y.rating,name:this.props.adapter,value:this.props.version?this.state.ratingNumber:null===(e=this.props.currentRating)||void 0===e||null===(s=e.rating)||void 0===s?void 0:s.r,size:"large",readOnly:!this.props.version,onChange:(t,e)=>this.setState({ratingNumber:e})}),this.props.version?(0,g.jsxs)("div",{style:{width:"100%",textAlign:"left"},children:[(0,g.jsx)(l.TextField,{variant:"standard",style:Y.ratingTextControl,value:this.state.ratingComment,label:this.props.t("Comment to version"),helperText:this.props.t("Max length %s characters",200),onChange:t=>this.setState({ratingComment:t.target.value}),slotProps:{input:{endAdornment:this.state.ratingComment?(0,g.jsx)(l.InputAdornment,{position:"end",children:(0,g.jsx)(l.IconButton,{size:"small",onClick:()=>this.setState({ratingComment:""}),children:(0,g.jsx)(p.Close,{})})}):null},htmlInput:{maxLength:200}}}),(0,g.jsxs)(l.FormControl,{variant:"standard",style:Y.ratingLanguageControl,children:[(0,g.jsx)(l.InputLabel,{children:this.props.t("Language")}),(0,g.jsx)(l.Select,{variant:"standard",value:this.state.ratingLang,onChange:t=>this.setState({ratingLang:t.target.value}),children:Z.map((t=>(0,g.jsx)(l.MenuItem,{value:t.id,children:t.title},t.id)))})]})]}):null,this.props.version?(0,g.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,o&&i?(0,g.jsx)("div",{children:this.props.t("You voted for %s on %s",o[0],new Date(i.ts).toLocaleDateString())}):null,this.renderComments()]}),(0,g.jsxs)(l.DialogActions,{children:[this.props.version&&(0,g.jsx)(l.Button,{variant:"contained",autoFocus:!0,color:"primary",disabled:!this.state.ratingNumber||null===this.state.votings,onClick:()=>{var t;this.state.ratingNumber!==(null===(t=i)||void 0===t?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((t=>this.props.onClose(t))):this.props.onClose()},startIcon:(0,g.jsx)(p.HowToVote,{}),children:this.props.t("Rate")}),(0,g.jsx)(l.Button,{autoFocus:!this.props.version,variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:(0,g.jsx)(p.Close,{}),children:this.props.t("Close")})]})]})}}const q=Q,K={formControl:{marginTop:24},closeButton:t=>({position:"absolute",right:8,top:8,color:t.palette.grey[500]}),typography:{paddingRight:30}};class X extends o.Component{constructor(t){super(t),this.t=void 0,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.".concat(this.props.adapter)).then((t=>{null!==t&&void 0!==t&&t.common?t.common.supportCustoms&&this.setState({deleteCustomSupported:t.common.supportCustoms}):this.setState({deleteCustomSupported:!0})}))}))}render(){return(0,g.jsxs)(l.Dialog,{onClose:this.props.onClose,open:!0,children:[(0,g.jsx)(l.DialogTitle,{children:(0,g.jsxs)(l.Typography,{component:"h2",variant:"h6",sx:{"&.MuiTypography-root":K.typography},children:[this.t("Please confirm"),(0,g.jsx)(l.IconButton,{size:"large",sx:K.closeButton,onClick:this.props.onClose,children:(0,g.jsx)(p.Close,{})})]})}),(0,g.jsxs)(l.DialogContent,{dividers:!0,children:[(0,g.jsx)(l.Typography,{gutterBottom:!0,children:this.t("Are you sure you want to delete adapter %s?",this.props.adapter)}),this.state.deleteCustomSupported&&(0,g.jsx)(l.FormControlLabel,{control:(0,g.jsx)(l.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")})]}),(0,g.jsxs)(l.DialogActions,{children:[(0,g.jsx)(l.Button,{id:"adapter-delete-dialog-ok",variant:"contained",autoFocus:!0,onClick:()=>{this.props.onClick(this.state.deleteCustom),this.props.onClose()},color:"primary",startIcon:(0,g.jsx)(p.Check,{}),children:this.t("Ok")}),(0,g.jsx)(l.Button,{id:"adapter-delete-dialog-cancel",variant:"contained",autoFocus:!0,onClick:()=>this.props.onClose(),color:"grey",startIcon:(0,g.jsx)(p.Close,{}),children:this.t("Close")})]})]})}}const $=X;var tt=s(81266),et=s(29465);const st={none:(0,g.jsx)(p.HorizontalRule,{}),patch:(0,g.jsx)(p.KeyboardDoubleArrowUp,{style:{color:"green"}}),minor:(0,g.jsx)(p.North,{style:{color:"orange"}}),major:(0,g.jsx)(p.VerticalAlignTop,{style:{color:"red"}})};class it extends n().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 t;const e=await this.props.socket.getObject("system.config");if(null===e||void 0===e||null===(t=e.common)||void 0===t||!t.adapterAutoUpgrade)return;const s=Object.entries(e.common.adapterAutoUpgrade.repositories).filter((t=>{let[,e]=t;return e})).map((t=>{let[e]=t;return e}));this.setState({repositories:s})}getAdapterId(){return"".concat(this.props.hostId,".adapter.").concat(this.props.adapter)}async getCurrentAutoUpgradeSetting(){const t=await this.props.socket.getObject(this.getAdapterId());if(!t)return console.error("no adapter object existing"),void this.setState({supported:!1});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)return console.error("no adapter object existing"),void this.setState({supported:!1});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(0,g.jsxs)(l.Dialog,{open:!0,maxWidth:"md",fullWidth:!0,children:[(0,g.jsx)(l.DialogTitle,{children:h.I18n.t("Auto upgrade policy for %s",this.props.adapter)}),(0,g.jsxs)(l.DialogContent,{style:{padding:"0 20px",overflow:"hidden"},children:[(0,g.jsx)(A.A,{value:!this.state.supported,children:(0,g.jsx)(l.Typography,{children:h.I18n.t("This feature is supported up from js-controller Kiera (Version 6)!")})}),(0,g.jsxs)(A.A,{value:this.state.supported,children:[(0,g.jsx)(l.Typography,{children:h.I18n.t("Allow only the following upgrades to be performed automatically:")}),(0,g.jsx)(l.Select,{variant:"standard",style:{marginTop:20,minWidth:150,marginBottom:8},value:this.state.policy,onChange:t=>this.setState({policy:t.target.value}),children:et.LS.map((t=>(0,g.jsx)(l.MenuItem,{value:t,children:(0,g.jsxs)("div",{style:{display:"flex",gap:8},children:[st[t],et.bd[t]]})},t)))}),(0,g.jsx)(A.A,{value:this.state.repositories.includes("beta")&&"none"!==this.state.policy,children:(0,g.jsx)(tt.InfoBox,{type:"warning",children:h.I18n.t("repo_update_hint")})}),(0,g.jsx)(A.A,{value:"major"===this.state.policy,children:(0,g.jsx)(tt.InfoBox,{type:"warning",children:h.I18n.t("The current selected configuration will allow to automatically pull in incompatible changes of this adapter!")})})]})]}),(0,g.jsxs)(l.DialogActions,{children:[(0,g.jsx)(l.Button,{disabled:this.state.currentSavedPolicy===this.state.policy,color:"primary",variant:"contained",startIcon:(0,g.jsx)(p.Save,{}),onClick:()=>this.save(),children:h.I18n.t("Save")}),(0,g.jsx)(l.Button,{variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:(0,g.jsx)(p.Close,{}),children:h.I18n.t("Close")})]})]})}}var ot=s(16244);const nt=["style","alt"],at={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:z.A[700]},updateAvailable:{color:F.A[700]},currentVersion:t=>({cursor:"pointer",mb:"6px",mr:"8px",mt:"4px","&:hover":{background:t.palette.primary.dark}}),header:t=>({fontWeight:"bold",background:t.palette.secondary.main,p:"10px"}),modalDialog:{height:"calc(100% - 64px)",overflowY:"hidden"},currentVersionText:t=>({color:"dark"===t.palette.mode?"#a3ffa3":"#009800",fontWeight:"bold",marginLeft:"4px"}),repoStableVersionText:t=>({color:"dark"===t.palette.mode?"#8dff7a":"#2b9800",fontWeight:"bold",marginLeft:"4px"}),repoLatestVersionText:t=>({color:"dark"===t.palette.mode?"#a3fcff":"#005498",fontWeight:"bold",marginLeft:"4px"}),rating:{},containerVersion:{},containerSpecificVersion:{},versionWarn:{color:_.A[500]},cardContentFlexBetween:{},cardContentFlex:{}};class rt extends W{constructor(t){super(t),this.installedVersion="",this.styles=void 0,Object.assign(this.state,{autoUpgradeDialogOpen:!1,showUpdateDialog:!1,adapterDeletionDialog:!1,adapterInstallSpecificVersion:"",showInstallVersion:!1,showSetRating:null})}static renderImage(t){const{style:e,alt:s}=t,o=(0,G.A)(t,nt),n=e.backgroundImage.substring(5,e.backgroundImage.length-2);return(0,g.jsx)("img",(0,i.A)((0,i.A)({},o),{},{alt:s,src:n,onError:t=>{t.target&&(t.target.onerror=null,t.target.src="./img/no-image.png")}}))}renderAddInstanceButton(){const t=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterInstall;return(0,g.jsx)(A.A,{value:t,children:(0,g.jsx)(l.Tooltip,{title:this.props.context.t("Add instance"),slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsx)(l.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:(0,g.jsx)(p.Add,{})})})})}renderAutoUpgradeButton(){var t;const e=this.props.context.hostAdapterWorker.getObject(this.props.adapterName);if(!e)return(0,g.jsx)("div",{style:{width:34,height:34,display:"inline-block"}});const s=null===(t=e.common)||void 0===t?void 0:t.automaticUpgrade;return(0,g.jsx)(l.Tooltip,{title:this.props.context.t("Automatic Upgrade Policy")+(s?": ".concat(s):""),slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsx)(l.IconButton,{size:"small",onClick:()=>this.setState({autoUpgradeDialogOpen:!0,showDialog:!0}),children:s&&"none"!==s?st[s]:(0,g.jsx)(p.KeyboardArrowUp,{})})})}renderReadmeButton(){const t=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterReadme;return(0,g.jsx)(A.A,{value:t,children:(0,g.jsx)(l.Tooltip,{title:this.props.context.t("Readme"),slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsx)(l.IconButton,{size:"small",onClick:()=>this.openInfoDialog(),children:(0,g.jsx)(p.Help,{})})})})}renderRating(){var t,e,s;const o=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterRating;if(this.props.context.isTileView&&(this.props.context.sortPopularFirst||this.props.context.sortRecentlyUpdated))return null;return this.props.context.repository[this.props.adapterName].stat&&!1!==o?(0,g.jsx)("div",{onClick:()=>this.setState({showSetRating:{version:this.installedVersion,rating:this.props.context.repository[this.props.adapterName].rating},showDialog:!0}),style:(0,i.A)((0,i.A)({},this.styles.rating),this.styles.ratingSet),title:null===(t=this.props.context.repository[this.props.adapterName].rating)||void 0===t?void 0:t.title,children:(0,g.jsx)(l.Rating,{name:this.props.adapterName,precision:.5,size:"small",readOnly:!0,value:(null===(e=this.props.context.repository[this.props.adapterName].rating)||void 0===e||null===(s=e.rating)||void 0===s?void 0:s.r)||0})}):null}renderConnectionType(){var t;const e=null===(t=this.props.context.repository[this.props.adapterName])||void 0===t?void 0:t.connectionType;return"cloud"===e?(0,g.jsx)(l.Tooltip,{title:this.props.context.t("Adapter requires the specific cloud access for these devices/service"),slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsx)(p.Cloud,{})}):"local"===e?(0,g.jsx)(l.Tooltip,{title:this.props.context.t("Adapter does not use the cloud for these devices/service"),slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsx)(p.CloudOff,{})}):null}renderDataSource(){var t;const e=null===(t=this.props.context.repository[this.props.adapterName])||void 0===t?void 0:t.dataSource;return e?(0,g.jsx)("div",{style:this.styles.marginLeft5,children:"poll"===e?(0,g.jsx)(l.Tooltip,{title:this.props.context.t("The device or service will be periodically asked"),slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsx)(p.ArrowUpward,{style:this.styles.classPoll})}):"push"===e?(0,g.jsx)(l.Tooltip,{title:this.props.context.t("The device or service delivers the new state actively"),slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsx)(p.ArrowDownward,{style:this.styles.classPush})}):"assumption"===e?(0,g.jsx)(l.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:(0,g.jsx)(p.Remove,{style:this.styles.classAssumption})}):null}):null}renderLicenseInfo(){var t,e,s,i;const o=this.props.context.repository[this.props.adapterName],n=O(o);return null!==(t=o.licenseInformation)&&void 0!==t&&t.type?(0,g.jsx)(l.Link,{href:n,target:"_blank",rel:"noopener",sx:t=>({color:"dark"===t.palette.mode?"white":"black","&:hover":{color:"dark"===t.palette.mode?"white":"black"}}),children:"paid"===(null===(e=o.licenseInformation)||void 0===e?void 0:e.type)?(0,g.jsx)(l.Tooltip,{title:this.props.context.t("The adapter requires a paid license."),slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsx)(p.MonetizationOn,{})}):"commercial"===(null===(s=o.licenseInformation)||void 0===s?void 0:s.type)?(0,g.jsx)(l.Tooltip,{slotProps:{popper:{sx:this.styles.tooltip}},title:this.props.context.t("The adapter requires a paid license for commercial use."),children:(0,g.jsx)(p.MonetizationOn,{opacity:.5})}):"limited"===(null===(i=o.licenseInformation)||void 0===i?void 0:i.type)?(0,g.jsx)(l.Tooltip,{slotProps:{popper:{sx:this.styles.tooltip}},title:this.props.context.t("The adapter has a limited functionality without a paid license."),children:(0,g.jsx)(p.MonetizationOn,{opacity:.5})}):null}):null}renderSentryInfo(){var t,e;return(null===(t=this.props.context.repository[this.props.adapterName])||void 0===t||null===(e=t.plugins)||void 0===e?void 0:e.sentry)?(0,g.jsx)("div",{style:this.styles.marginLeft5,children:(0,g.jsx)(l.Tooltip,{title:"sentry",slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsx)(l.CardMedia,{style:this.styles.sentry,component:"img",image:ot.A})})}):null}renderVersion(){const t=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterUpdate;return!this.props.commandRunning&&this.props.cached.updateAvailable&&!1!==t?(0,g.jsx)(l.Tooltip,{title:this.props.context.t("Update"),slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsxs)("div",{onClick:()=>this.setState({showUpdateDialog:!0,showDialog:!0}),style:(0,i.A)((0,i.A)({},this.styles.buttonUpdate),this.props.cached.rightDependencies?this.styles.updateAvailable:void 0),children:[(0,g.jsx)(l.IconButton,{style:this.styles.buttonUpdateIcon,size:"small",children:(0,g.jsx)(p.Refresh,{})}),this.props.context.repository[this.props.adapterName].version]})}):(0,g.jsx)("span",{style:this.props.cached.rightDependencies?void 0:this.styles.wrongDependencies,children:this.props.context.repository[this.props.adapterName].version})}renderInstalledVersion(t){const e=this.props.context.installed[this.props.adapterName],s=null===e||void 0===e?void 0:e.installedFrom,{adapterName:i}=this.props;if(t){const t=null===e||void 0===e?void 0:e.enabled,o=null===e||void 0===e?void 0:e.count;return(0,g.jsxs)(l.Grid2,{container:!0,wrap:"nowrap",alignItems:"center",spacing:1,children:[this.installedVersion?(0,g.jsx)(l.Grid2,{children:this.installedVersion+(o?" (".concat(o).concat(o!==t?"~":"",")"):"")}):null,s&&!s.startsWith("iobroker.".concat(i,"@"))&&(0,g.jsx)(l.Grid2,{container:!0,children:(0,g.jsx)(l.Tooltip,{title:this.props.context.t("Non-NPM-Version: ")+s,slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsx)(p.GitHub,{fontSize:"small",style:this.styles.versionWarn})})})]})}return this.installedVersion?(0,g.jsxs)(l.Typography,{component:"span",style:this.styles.cardContentFlexBetween,children:[(0,g.jsxs)("div",{children:[this.props.context.t("Installed version"),":"]}),(0,g.jsxs)("div",{style:this.styles.cardContentFlex,children:[s&&!s.startsWith("iobroker.".concat(i,"@"))&&(0,g.jsx)(l.Tooltip,{title:this.props.context.t("Non-NPM-Version: ")+s,slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsx)(p.GitHub,{fontSize:"small",style:this.styles.versionWarn})}),this.installedVersion]})]}):null}renderUploadButton(){return this.props.context.expertMode&&this.installedVersion?(0,g.jsx)(l.Tooltip,{title:this.props.context.t("Upload"),slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsx)(l.IconButton,{size:"small",disabled:this.props.commandRunning,onClick:()=>this.onUpload(),children:(0,g.jsx)(p.Publish,{})})}):null}renderDeleteButton(){const t=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterDelete;return(0,g.jsx)(A.A,{value:!!this.installedVersion&&t,children:(0,g.jsx)(l.Tooltip,{title:this.props.context.t("Delete adapter"),slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsx)(l.IconButton,{size:"small",disabled:this.props.commandRunning,onClick:()=>this.setState({adapterDeletionDialog:!0,showDialog:!0}),children:(0,g.jsx)(p.DeleteForever,{})})})})}renderInstallSpecificVersionButton(){const t=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterUpdate;return this.props.context.expertMode&&!1!==t&&this.installedVersion&&(0,g.jsx)(l.Tooltip,{title:this.props.context.t("Install a specific version"),slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsx)(l.IconButton,{disabled:this.props.commandRunning,size:"small",onClick:()=>this.setState({showInstallVersion:!0,showDialog:!0}),children:(0,g.jsx)(p.AddToPhotos,{})})})}renderRebuildButton(){return this.props.context.expertMode&&this.installedVersion?(0,g.jsx)(l.Tooltip,{title:this.props.context.t("Rebuild"),children:(0,g.jsx)(l.IconButton,{size:"small",disabled:this.props.commandRunning,onClick:()=>this.rebuild(),children:(0,g.jsx)(p.Build,{})})}):null}renderAutoUpdateDialog(){return this.state.autoUpgradeDialogOpen?(0,g.jsx)(it,{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=null===(t=this.props.context.installed[this.props.adapterName])||void 0===t?void 0:t.version,(0,g.jsx)(u.A,{adapter:this.props.adapterName,adapterObject:this.props.context.repository[this.props.adapterName],t:this.props.context.t,dependencies:W.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:t=>this.setState({showUpdateDialog:!1,showDialog:!1},(()=>this.update(t))),isStable:this.props.context.repository._repoInfo.stable,onIgnore:t=>this.setState({showUpdateDialog:!1,showDialog:!1},(()=>this.props.context.socket.getObject("system.adapter.".concat(this.props.adapterName)).then((e=>{null!==e&&void 0!==e&&e.common?(e.common.ignoreVersion=t,this.props.context.socket.setObject(e._id,e).catch((t=>window.alert("Cannot write object: ".concat(t))))):window.alert('Adapter "'.concat(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("\n").map((t=>t.trim().replace(/^\*+/,"").replace(/^-/,"").replace(/\*+$/,"").replace(/\r/g,"").trim())).filter((t=>t)).map(((t,e)=>(0,g.jsxs)("div",{style:{},children:[(0,g.jsx)("span",{children:"- "}),t]},e)))}renderAdapterInstallVersion(){if(!this.state.showInstallVersion)return null;let t,e;const s=this.props.context.repository._repoInfo;var o,n,a,r;null!==s&&void 0!==s&&s.stable?(t=null===(o=this.props.context.repository[this.props.adapterName])||void 0===o?void 0:o.version,e=null===(n=this.props.context.repository[this.props.adapterName])||void 0===n?void 0:n.latestVersion):(t=null===(a=this.props.context.repository[this.props.adapterName])||void 0===a?void 0:a.stable,e=null===(r=this.props.context.repository[this.props.adapterName])||void 0===r?void 0:r.version);return(0,g.jsx)(J.A,{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:(0,g.jsxs)("div",{style:{height:"100%",overflowY:"hidden"},children:[(0,g.jsxs)("div",{style:this.styles.containerSpecificVersion,children:[(0,g.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,g.jsx)(l.TextField,{variant:"standard",style:{flexGrow:1},label:this.props.context.t("Enter version manually"),value:this.state.adapterInstallSpecificVersion,onChange:t=>this.setState({adapterInstallSpecificVersion:t.target.value}),slotProps:{input:{endAdornment:this.state.adapterInstallSpecificVersion?(0,g.jsx)(l.InputAdornment,{position:"end",children:(0,g.jsx)(l.IconButton,{size:"small",onClick:()=>this.setState({adapterInstallSpecificVersion:""}),children:(0,g.jsx)(p.Close,{})})}):null}}}),(0,g.jsx)(l.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")})]}),(0,g.jsx)(l.Tooltip,{title:this.props.context.t("npmjs.com"),slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsx)(l.IconButton,{size:"small",onClick:()=>{window.open("https://www.npmjs.com/package/iobroker.".concat(this.props.adapterName,"?activeTab=versions"),this.props.adapterName).focus()},children:(0,g.jsx)(p.Link,{})})})]}),(0,g.jsx)(l.Box,{component:"div",sx:this.styles.header,children:this.props.context.t("Or select from the list")}),(0,g.jsx)("div",{style:(0,i.A)((0,i.A)({},this.styles.containerVersion),{},{height:"calc(100% - 122px)",overflowY:"auto"}),children:this.getNews(!0).map((s=>{let{version:i,news:o}=s;return(0,g.jsx)(l.Card,{variant:"outlined",sx:this.styles.currentVersion,onClick:()=>{this.update(i),this.setState({showInstallVersion:!1,showDialog:!1})},children:(0,g.jsxs)(l.CardContent,{children:[(0,g.jsxs)(l.Typography,{sx:h.Utils.getStyle(this.props.context.theme,this.installedVersion===i&&this.styles.currentVersionText,{fontSize:16,fontWeight:"bold"}),color:"text.secondary",gutterBottom:!0,children:[i,this.installedVersion===i?(0,g.jsx)(l.Box,{component:"span",sx:this.styles.currentVersionText,children:"(".concat(this.props.context.t("current"),")")}):null,e===i?(0,g.jsx)(l.Box,{component:"span",sx:this.styles.repoLatestVersionText,children:"(latest)"}):null,t===i?(0,g.jsx)(l.Box,{component:"span",sx:this.styles.repoStableVersionText,children:"(".concat(this.props.context.t("stable"),")")}):null]}),(0,g.jsx)(l.Typography,{variant:"body2",style:{opacity:.7},children:rt.formatNews(o)})]})},i)}))})]})})}renderSetRatingDialog(){return this.state.showSetRating?(0,g.jsx)(q,{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?(0,g.jsx)($,{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 t;const e=null!==(t=this.props.context.repository[this.props.adapterName].docs)&&void 0!==t&&t[this.props.context.lang]?this.props.context.lang:"en";window.open(C.A.getDocsLinkForAdapter({lang:e,adapterName:this.props.adapterName}),"help")}getNews(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const e=this.props.context.repository[this.props.adapterName],s=this.props.context.installed[this.props.adapterName],i=[];return s&&null!==e&&void 0!==e&&e.news&&Object.keys(e.news).forEach((o=>{try{if(r().gt(o,s.version)||t){let t;t="object"===typeof e.news[o]?this.props.noTranslation?e.news[o].en:e.news[o][this.props.context.lang]||e.news[o].en:e.news[o],i.push({version:o,news:t})}}catch(n){console.warn('[ADAPTERS] Cannot compare "'.concat(o,'" and "').concat(s.version,'" (').concat(this.props.adapterName,")"))}})),i}onUpload(){var t;const e=this.props.context.repository[this.props.adapterName],s=O(e),i=(null===(t=e.licenseInformation)||void 0===t?void 0:t.license)||e.license;"MIT"!==i?this.setState({showLicenseDialog:{url:s,upload:!0,adapterName:this.props.adapterName,licenseType:i},showDialog:!0}):W.upload(this.props.adapterName,this.props.context)}delete(t){this.props.context.executeCommand("del ".concat(this.props.adapterName).concat(t?" --custom":"").concat(this.props.context.expertMode?" --debug":""))}async update(t){"admin"===this.props.adapterName&&this.props.context.adminHost===this.props.context.currentHost&&await this.props.context.socket.checkFeatureSupported("ADAPTER_WEBSERVER_UPGRADE")?this.props.context.setAdminUpgradeTo(t):this.props.context.executeCommand("upgrade ".concat(this.props.adapterName,"@").concat(t).concat(this.props.context.expertMode?" --debug":""))}rebuild(){this.props.context.executeCommand("rebuild ".concat(this.props.adapterName).concat(this.props.context.expertMode?" --debug":""))}renderDialogs(){return this.state.showDialog?(0,g.jsxs)(g.Fragment,{children:[this.renderAddInstanceDialog(this.props.context),this.renderLicenseDialog(this.props.context),this.renderUpdateAdapterDialog(),this.renderAdapterInstallVersion(),this.renderSetRatingDialog(),this.renderAdapterDeletionDialog(),this.renderAutoUpdateDialog()]}):null}}const lt=(0,i.A)((0,i.A)({},at),{},{type:{color:"tile"},root:t=>({position:"relative",m:"10px",width:300,minHeight:200,background:t.palette.background.default,boxShadow:"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)",display:"flex",flexDirection:"column",transition:"box-shadow 0.5s","&:hover":{boxShadow:"0 8px 17px 0 rgba(0, 0, 0, .2),0 6px 20px 0 rgba(0, 0, 0, .19)"}}),imageBlock:t=>({background:"dark"===t.palette.mode?"#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.png") 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:t=>({color:t.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:t=>({background:t.palette.background.default,p:"10px",display:"flex",justifyContent:"space-between"}),versionDate:{alignSelf:"center"},adapter:t=>({width:"100%",fontWeight:"bold",fontSize:16,verticalAlign:"middle",pl:1,pt:2,color:(t.palette.mode,"#333")}),adapterWithAgo:{width:"calc(100% - 145px)"},description:t=>({color:"dark"===t.palette.mode?"#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:_.A[500],marginRight:5},rating:{marginTop:20}});const pt=class extends rt{constructor(t){super(t),this.styles=lt,Object.assign(this.state,{openCollapse:!1})}renderInfoCard(){return(0,g.jsxs)("div",{style:this.styles.collapse,children:[(0,g.jsxs)(l.CardContent,{style:this.styles.cardContent,children:[(0,g.jsx)("div",{style:this.styles.cardContentDiv,children:(0,g.jsx)(l.Box,{component:"div",sx:this.styles.close,onClick:()=>this.setState({openCollapse:!this.state.openCollapse})})}),(0,g.jsx)(l.Typography,{gutterBottom:!0,component:"span",variant:"body2",sx:this.styles.description,children:this.props.cached.desc})]}),(0,g.jsxs)(l.Box,{component:"div",sx:this.styles.footerBlock,children:[this.renderAddInstanceButton(),(0,g.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],e=null===t||void 0===t?void 0:t.version;return(0,g.jsxs)(l.Box,{component:"div",sx:h.Utils.getStyle(this.props.context.theme,this.styles.imageBlock,this.installedVersion&&this.styles.installed,this.installedVersion&&e&&this.installedVersion!==e&&this.props.cached.updateAvailable&&this.styles.update),children:[(0,g.jsx)(l.CardMedia,{sx:this.styles.img,component:t=>rt.renderImage(t),src:this.props.cached.image||"img/no-image.png",image:this.props.cached.image||"img/no-image.png"}),(0,g.jsx)(l.Box,{component:"div",sx:h.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?(0,g.jsx)("div",{style:this.styles.versionDate,children:t.stat}):null,this.props.context.sortRecentlyUpdated?(0,g.jsx)("div",{style:this.styles.versionDate,children:this.props.cached.daysAgoText}):null,this.props.context.sortPopularFirst||this.props.context.sortRecentlyUpdated?null:this.renderRating(),this.state.openCollapse?null:(0,g.jsx)(l.Tooltip,{title:this.props.context.t("Info"),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:(0,g.jsx)(l.Fab,{onClick:()=>this.setState({openCollapse:!this.state.openCollapse}),style:this.styles.fab,color:"primary","aria-label":"add",children:(0,g.jsx)(p.MoreVert,{})})})]})}renderCardContent(){const t=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterUpdate,e=this.props.context.installed[this.props.adapterName];return(0,g.jsxs)(l.CardContent,{style:this.styles.cardContent2,children:[(0,g.jsx)(l.Typography,{gutterBottom:!0,variant:"h5",component:"h5",children:this.props.cached.title}),(0,g.jsxs)("div",{style:this.styles.cardContentFlex,children:[this.renderConnectionType(),this.renderDataSource(),(0,g.jsx)("div",{children:this.renderLicenseInfo()}),this.renderSentryInfo()]}),(0,g.jsxs)("div",{style:this.styles.cardMargin10,children:[null!==e&&void 0!==e&&e.count?(0,g.jsxs)(l.Typography,{component:"span",style:this.styles.cardContentFlexBetween,children:[(0,g.jsxs)("div",{children:[this.props.context.t("Installed instances"),":"]}),(0,g.jsx)("div",{children:e.count})]}):null,(0,g.jsx)(A.A,{value:t,children:(0,g.jsxs)(l.Typography,{component:"span",style:this.styles.availableVersion,children:[(0,g.jsx)("div",{children:this.props.context.t("Available version:")}),(0,g.jsx)(l.Box,{component:"div",sx:h.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=null===(t=this.props.context.installed[this.props.adapterName])||void 0===t?void 0:t.version,(0,g.jsxs)(l.Card,{sx:this.styles.root,children:[this.state.openCollapse?this.renderInfoCard():null,this.renderCardMedia(),this.renderCardContent(),this.renderDialogs()]})}},dt=(0,i.A)((0,i.A)({},at),{},{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"}});const ct=class extends rt{constructor(){super(...arguments),this.styles=dt}render(){var t,e;const s=this.props.context.repository[this.props.adapterName],i=!s||s.allowAdapterRating;return this.installedVersion=null===(t=this.props.context.installed[this.props.adapterName])||void 0===t?void 0:t.version,(0,g.jsxs)(l.TableRow,{hover:!0,children:[(0,g.jsx)(l.TableCell,{}),(0,g.jsx)(l.TableCell,{children:(0,g.jsxs)(l.Grid2,{container:!0,spacing:1,alignItems:"center",style:this.styles.name,children:[(0,g.jsx)(l.Tooltip,{title:this.props.adapterName,slotProps:{popper:{sx:this.styles.tooltip}},children:(0,g.jsx)(l.Grid2,{style:this.styles.paddingNone,children:(0,g.jsx)(l.Avatar,{variant:"square",alt:this.props.cached.title,src:this.props.cached.image,style:this.styles.smallAvatar})})}),!1!==i?(0,g.jsxs)(l.Grid2,{style:this.styles.nameCell,children:[(0,g.jsx)("div",{children:this.props.cached.title}),this.renderRating()]}):(0,g.jsx)(l.Grid2,{children:this.props.cached.title})]})}),!this.props.context.descHidden&&(0,g.jsx)(l.TableCell,{title:this.props.cached.desc,style:{width:20,wordWrap:"break-word"},children:this.props.cached.desc}),(0,g.jsx)(l.TableCell,{children:(0,g.jsxs)("div",{style:this.styles.flex,children:[this.renderConnectionType()||(0,g.jsx)("div",{style:{marginLeft:5,width:24,height:24}}),this.renderDataSource()||(0,g.jsx)("div",{style:{width:24,height:24}}),this.renderSentryInfo()||(0,g.jsx)("div",{style:{width:24,height:24}}),this.renderLicenseInfo()]})}),(0,g.jsx)(l.TableCell,{children:this.renderInstalledVersion(!0)}),(0,g.jsx)(l.TableCell,{children:(0,g.jsx)(l.Grid2,{container:!0,alignItems:"center",children:this.renderVersion()})}),(0,g.jsx)(l.TableCell,{style:{fontSize:"smaller"},children:(null===s||void 0===s||null===(e=s.licenseInformation)||void 0===e?void 0:e.license)||(null===s||void 0===s?void 0:s.license)}),(0,g.jsxs)(l.TableCell,{children:[this.renderAddInstanceButton(),this.renderAutoUpgradeButton(),this.renderReadmeButton(),this.renderUploadButton(),this.renderDeleteButton(),this.renderInstallSpecificVersionButton(),this.renderRebuildButton()]}),this.renderDialogs()]})}},ht={emptyBlock:50,name:300,connectionType:120,installed:120,available:120,update:40,license:80,install:246},ut=Object.keys(ht).reduce(((t,e)=>t+ht[e]),0),gt={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:ht.name},emptyBlock:{flexWrap:"nowrap",width:ht.emptyBlock},description:{width:"calc(100% - ".concat(ut+2,"px)")},connectionType:{width:ht.connectionType},installed:{width:ht.installed},available:{width:ht.available,paddingRight:6},update:{width:ht.update,padding:0},license:{width:ht.license},install:{width:ht.install},viewModeDiv:{display:"flex",flexFlow:"wrap",overflow:"auto",justifyContent:"center"}};class mt extends o.Component{constructor(t){super(t),this.lastRenderCounter=-1,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,e){const s=this.props.cachedAdapters[t];return s?(0,g.jsx)(ct,{context:e,adapterName:t,cached:s,commandRunning:this.state.commandRunning,noTranslation:this.state.noTranslation},"adapter-".concat(t)):null}getRows(t){if(!this.props.listOfVisibleAdapter)return(0,g.jsx)(l.TableRow,{children:(0,g.jsx)(l.TableCell,{colSpan:8,children:(0,g.jsx)(l.LinearProgress,{})})});let e=0,s=[];if(this.props.oneListView){for(let e=0;e<this.props.listOfVisibleAdapter.length;e++){var i;const o=this.props.listOfVisibleAdapter[e];s.length>50&&(null===(i=this.props.context.installed[o])||void 0===i||!i.version)||s.push(this.getRow(o,t))}if(e=s.length,e&&this.props.listOfVisibleAdapter.length>s.length){const t=this.props.listOfVisibleAdapter.length-s.length,e=1===t?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",t);s.push((0,g.jsx)(l.TableRow,{children:(0,g.jsx)(l.TableCell,{colSpan:8,style:{fontSize:20,padding:20,textAlign:"center"},children:e})},"more"))}}else s=this.props.categories.map((s=>{if(!s.adapters.find((t=>this.props.listOfVisibleAdapter.includes(t))))return null;const i=s.name,n=this.props.categoriesExpanded[i];return e++,(0,g.jsxs)(o.Fragment,{children:[(0,g.jsx)(E,{categoryName:i,count:s.count,expanded:n,installedCount:s.installed,name:s.translation,descHidden:t.descHidden,onToggle:()=>this.props.toggleCategory(i),t:this.props.context.t},"category-".concat(i,1)),n&&s.adapters.map((s=>{const i=this.getRow(s,t);return i&&e++,i}))]},"category-".concat(i," ").concat(s.adapters.length))}));return e?s:this.props.update?null:(0,g.jsx)("tr",{children:(0,g.jsxs)("td",{colSpan:8,style:{textAlign:"center"},children:[this.props.searchFilter||this.props.installedListFilter?(0,g.jsx)(l.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)?(0,g.jsx)("br",{}):null,this.props.updateListFilter?(0,g.jsx)(l.Button,{style:{marginTop:16},variant:"outlined",onClick:()=>this.props.clearAllFilters(!0),startIcon:(0,g.jsx)(p.Update,{}),children:this.props.context.t("Remove filter for updatable adapters")}):null]})})}getTiles(t){if(!this.props.listOfVisibleAdapter)return(0,g.jsx)(l.LinearProgress,{});if(!this.props.listOfVisibleAdapter.length)return this.props.update?null:(0,g.jsxs)("div",{style:{width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:16},children:[this.props.searchFilter||this.props.installedListFilter?(0,g.jsx)(l.Tooltip,{title:this.props.context.t("Click to clear all filters"),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:(0,g.jsx)(l.Button,{variant:"outlined",onClick:()=>this.props.clearAllFilters(),children:this.props.context.t("all items are filtered out")})}):null,this.props.updateListFilter?(0,g.jsx)(l.Button,{variant:"outlined",onClick:()=>this.props.clearAllFilters(!0),startIcon:(0,g.jsx)(p.Update,{}),children:this.props.context.t("Remove filter for updatable adapters")}):null]});const e=[];for(let i=0;i<this.props.listOfVisibleAdapter.length;i++){var s;const o=this.props.listOfVisibleAdapter[i],n=this.props.cachedAdapters[o];e.length>50&&(null===(s=this.props.context.installed[o])||void 0===s||!s.version)||e.push((0,g.jsx)(pt,{context:t,adapterName:o,cached:n,commandRunning:this.state.commandRunning,noTranslation:this.state.noTranslation},"adapter-".concat(o)))}return this.props.listOfVisibleAdapter.length>e.length&&(e.push((0,g.jsx)("div",{style:{flexBasis:"100%",height:0}},"newLine")),e.push((0,g.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-e.length)},"more"))),e}renderTileView(t,e,s){return(0,g.jsxs)(g.Fragment,{children:[t?null:(0,g.jsx)(l.Box,{sx:{marginX:2,marginTop:1,width:"calc(100% - 32px)"},children:(0,g.jsx)(tt.InfoBox,{type:"warning",children:this.props.context.t('Active repo is "%s"',e)})}),(0,g.jsx)("div",{style:gt.viewModeDiv,children:this.getTiles(s)})]})}renderTableView(t,e,s){return(0,g.jsxs)(h.TabContent,{children:[t?null:(0,g.jsx)(l.Box,{sx:{marginX:2,marginTop:1,width:"calc(100% - 32px)"},children:(0,g.jsx)(tt.InfoBox,{type:"warning",children:this.props.context.t('Active repo is "%s"',e)})}),(0,g.jsx)(l.TableContainer,{style:(0,i.A)((0,i.A)({},gt.container),t?gt.containerFullHeight:gt.containerNotFullHeight),children:(0,g.jsxs)(l.Table,{stickyHeader:!0,size:"small",sx:gt.table,children:[(0,g.jsx)(l.TableHead,{children:(0,g.jsxs)(l.TableRow,{children:[(0,g.jsx)(l.TableCell,{style:gt.emptyBlock}),(0,g.jsx)(l.TableCell,{style:gt.name,children:(0,g.jsx)(l.Typography,{children:this.props.context.t("Name")})}),!s.descHidden&&(0,g.jsx)(l.TableCell,{style:(0,i.A)((0,i.A)({},gt.description),{},{width:this.props.descWidth}),children:(0,g.jsx)(l.Typography,{children:this.props.context.t("Description")})}),(0,g.jsx)(l.TableCell,{style:gt.connectionType}),(0,g.jsx)(l.TableCell,{style:gt.installed,children:(0,g.jsx)(l.Typography,{children:this.props.context.t("Installed")})}),(0,g.jsx)(l.TableCell,{style:gt.available,children:(0,g.jsx)(l.Typography,{children:this.props.context.t("Available")})}),(0,g.jsx)(l.TableCell,{style:gt.license,children:(0,g.jsx)(l.Typography,{children:this.props.context.t("License")})}),(0,g.jsx)(l.TableCell,{style:(0,i.A)((0,i.A)({},gt.install),{},{width:this.state.expertMode?246:178}),children:(0,g.jsx)(l.Typography,{children:this.props.context.t("Install")})})]})}),(0,g.jsx)(l.TableBody,{children:this.getRows(s)})]})})]})}static getDerivedStateFromProps(t,e){let s=!1;t.descWidth!==e.descWidth&&(console.log("Render because of descWidth"),s=!0),t.repoName!==e.repoName&&(console.log("Render because of repoName"),s=!0),!!t.systemConfig!==e.systemConfig&&(console.log("Render because of systemConfig"),s=!0),t.tableViewMode!==e.tableViewMode&&(console.log("Render because of tableViewMode"),s=!0),t.oneListView!==e.oneListView&&(console.log("Render because of oneListView"),s=!0);const i=JSON.stringify(t.categoriesExpanded);i!==e.categoriesExpanded&&(console.log("Render because of categoriesExpanded"),s=!0);const o=t.cachedAdapters?Object.keys(t.cachedAdapters).length:0;o!==e.cachedAdapters&&(console.log("Render because of cachedAdapters ".concat(o," <> ").concat(e.cachedAdapters)),s=!0),t.update!==e.update&&(console.log("Render because of update"),s=!0),t.sortByName!==e.sortByName&&(console.log("Render because of sortByName"),s=!0),t.sortPopularFirst!==e.sortPopularFirst&&(console.log("Render because of sortPopularFirst"),s=!0),t.sortRecentlyUpdated!==e.sortRecentlyUpdated&&(console.log("Render because of sortRecentlyUpdated"),s=!0),t.context.expertMode!==e.expertMode&&(console.log("Render because of expertMode"),s=!0);const n=JSON.stringify(t.listOfVisibleAdapter);return n!==e.listOfVisibleAdapter&&(console.log("Render because of listOfVisibleAdapter"),s=!0),t.commandRunning!==e.commandRunning&&(console.log("Render because of commandRunning"),s=!0),t.noTranslation!==e.noTranslation&&(console.log("Render because of commandRunning"),s=!0),s?{descWidth:t.descWidth,repoName:t.repoName,systemConfig:!!t.systemConfig,tableViewMode:t.tableViewMode,oneListView:t.oneListView,categoriesExpanded:i,cachedAdapters:o,update:t.update,sortByName:t.sortByName,sortPopularFirst:t.sortPopularFirst,sortRecentlyUpdated:t.sortRecentlyUpdated,listOfVisibleAdapter:n,renderCounter:e.renderCounter+1,expertMode:t.context.expertMode,commandRunning:t.commandRunning,noTranslation:t.noTranslation}:null}shouldComponentUpdate(t,e){return this.lastRenderCounter!==e.renderCounter&&(this.lastRenderCounter=e.renderCounter,!0)}render(){var t,e;return null!==(t=this.props.systemConfig)&&void 0!==t&&null!==(e=t.common)&&void 0!==e&&e.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):(0,g.jsx)(l.LinearProgress,{})}}const xt=mt;class yt extends o.Component{constructor(t){super(t),this.updating=void 0,this.interval=void 0,this.startTimeout=void 0,this.textareaRef=void 0,this.link=void 0,this.oldVersion=void 0,this.state={response:null,error:null,starting:!0,upAgain:!1},this.updating=!1,this.textareaRef=n().createRef(),this.link="".concat(window.location.protocol,"//").concat(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.".concat(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:e,port:s,useHttps:i}=await this.getWebserverParams();this.oldVersion=this.props.currentAdminVersion,await this.props.socket.upgradeAdapterWithWebserver(this.props.host,{version:this.props.version,adapterName:"admin",port:s,useHttps:i,certPublicName:e,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 t=await fetch("./version"),e=await t.text();return e&&e.length<20&&e!==this.oldVersion?(this.interval&&(clearInterval(this.interval),this.interval=null),this.setState({response:{running:!1,success:!0,stderr:[],stdout:[h.I18n.t("Version updated to %s",e)]},upAgain:!0,error:null},(()=>this.setUpdating(!1))),!0):e===this.oldVersion}catch(t){return!1}}async checkStatus(){console.log("Request update status from: ".concat(this.link));try{const e=await fetch(this.link),s=await e.text();if(console.log("Received status: ".concat(s)),s.startsWith("{")&&s.endsWith("}"))try{const t=JSON.parse(s);null!==t&&void 0!==t&&t.stderr&&(t.stderr=t.stderr.filter((t=>t.trim()))),t&&!t.running&&t.success&&t.stdout?(t.stdout.push(""),t.stdout.push("---------------------------------------------------"),t.stdout.push(h.I18n.t("%s was successfully updated to %s","admin",this.props.version))):null!==t&&void 0!==t&&t.stdout&&(t.stdout.unshift(""),t.stdout.unshift("---------------------------------------------------"),t.stdout.unshift(h.I18n.t("updating %s to %s...","admin",this.props.version))),this.setState({response:t,error:null},(()=>{t&&!t.running?(this.interval&&(clearInterval(this.interval),this.interval=null),this.waitForAdapterStart()):null!==t&&void 0!==t&&t.running&&this.setUpdating(!0),this.textareaRef.current&&setTimeout((()=>this.textareaRef.current.scrollTop=this.textareaRef.current.scrollHeight),100)}))}catch(t){console.error("Cannot parse response: ".concat(t)),this.setState({error:s},(()=>this.setUpdating(!1)))}else await this.checkVersion()||console.error("Response is not JSON: ".concat(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(t){}}),1e3)}render(){var t,e,s,i,o;return(0,g.jsxs)(l.Dialog,{onClose:(t,e)=>{"escapeKeyDown"!==e&&"backdropClick"!==e&&this.props.onClose()},open:!0,maxWidth:"lg",fullWidth:!0,children:[(0,g.jsx)(l.DialogTitle,{children:h.I18n.t("Updating %s...","admin")}),(0,g.jsxs)(l.DialogContent,{style:{height:400,padding:"0 20px",overflow:"hidden"},children:[this.state.response&&!this.state.response.running||this.state.error?null:(0,g.jsx)(l.LinearProgress,{}),this.state.response||this.state.error?(0,g.jsx)("textarea",{ref:this.textareaRef,style:{width:"100%",height:"100%",resize:"none",background:"dark"===this.props.themeType?"#000":"#fff",color:"dark"===this.props.themeType?"#EEE":"#111",boxSizing:"border-box",fontFamily:"Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace",border:null!==(t=this.state.response)&&void 0!==t&&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("\n"):this.state.response.stdout.join("\n"),readOnly:!0}):null]}),(0,g.jsx)(l.DialogActions,{children:(0,g.jsx)(l.Button,{variant:"contained",disabled:this.state.starting||!this.state.error&&!this.state.upAgain,onClick:()=>{var t;null!==(t=this.state.response)&&void 0!==t&&t.success&&window.location.reload(),this.props.onClose()},color:null!==(e=this.state.response)&&void 0!==e&&e.success?"primary":"grey",startIcon:null!==(s=this.state.response)&&void 0!==s&&s.success?(0,g.jsx)(p.Refresh,{}):(0,g.jsx)(p.Close,{}),children:null!==(i=this.state.response)&&void 0!==i&&i.success&&!this.state.upAgain?(0,g.jsx)(l.CircularProgress,{}):null!==(o=this.state.response)&&void 0!==o&&o.success?h.I18n.t("Reload"):h.I18n.t("Close")})})]})}}const vt=yt,ft={grow:{flexGrow:1},updateAllButton:t=>({position:"relative","& .admin-update-second-icon":{position:"absolute",top:15,left:15,opacity:.4,color:"dark"===t.palette.mode?"#aad5ff":"#007fff"}}),counters:{mr:"10px",minWidth:120,display:"flex","& div":{ml:"3px"}},infoAdapters:t=>({fontSize:10,color:"dark"===t.palette.mode?"#9c9c9c":"#333",cursor:"pointer"}),greenText:{color:"#00a005d1"},tooltip:{pointerEvents:"none"}},wt=[{name:"Description A-Z"},{name:"Name A-Z"},{name:"Popular first",notByList:!0},{name:"Recently updated",notByList:!0}];class bt extends W{constructor(t){super(t),this.inputRef=void 0,this.countRef=void 0,this.t=void 0,this.wordCache={},this.cache={listOfVisibleAdapter:null,adapters:null},this.listOfVisibleAdapterLength=0,this.allAdapters=0,this.installedAdapters=0,this.recentUpdatedAdapters=0,this.uuid="",this.buildCacheTimer=null,this.updateTimeout=null,this.typingTimer=null,this.hostsTimer=null,this.onHostAdapterTimer=null,this.tempAdapters=null,this.tempInstalled=null,this.tempInstances=null,this.hostAdapterWorker=null,this.translate=(t,e,s)=>void 0!==e?this.props.t(t,e,s):(this.wordCache[t]||(this.wordCache[t]=this.props.t(t)),this.wordCache[t]),this.onAdaptersChanged=t=>{this.tempAdapters=this.tempAdapters||JSON.parse(JSON.stringify(this.state.adapters||{})),this.tempInstalled=this.tempInstalled||JSON.parse(JSON.stringify(this.state.installed||{})),this.tempInstances=this.tempInstances||JSON.parse(JSON.stringify(this.state.compactInstances||{})),t.forEach((t=>{if(!!t.id.match(/\.\d+$/))"deleted"!==t.type&&t.obj?this.tempInstances[t.id]={enabled:t.obj.common.enabled,icon:t.obj.common.icon,name:t.obj.common.name,adminTab:t.obj.common.adminTab,version:t.obj.common.version}:delete this.tempInstances[t.id];else if("deleted"!==t.type&&t.obj){const e=t.obj.common.name;this.tempInstalled[e]?Object.keys(this.tempInstalled[e]).forEach((s=>{void 0!==t.obj.common[s]&&"installedFrom"!==s&&(this.tempInstalled[e][s]=t.obj.common[s])})):this.tempInstalled[t.id.split(".").pop()]=JSON.parse(JSON.stringify(t.obj.common)),this.tempAdapters[t.id]=t.obj}else{const e=t.id.split(".");delete this.tempInstalled[e[2]],delete this.tempAdapters[t.id]}})),this.updateTimeout&&clearTimeout(this.updateTimeout),this.updateTimeout=setTimeout((()=>{this.updateTimeout=null;const t=this.tempAdapters;this.tempAdapters=null;const e=this.tempInstalled;this.tempInstalled=null;const s=this.tempInstances;this.tempInstances=null,this.analyseInstalled({adapters:t,installedLocal:e,cb:()=>this.calculateInfo(s)})}),300)},this.rightDependencies=t=>{const e=this.state.repository[t];let s=!0;if(e){const o=e.dependencies,n=e.node;if(o)if(o instanceof Array)o.forEach((t=>{const e="string"!==typeof t,i=Object.keys(t),o=e?i?i[0]:null:t;if(s&&o){const i=this.state.installed[o];try{s=!!i&&(!e||r().satisfies(i.version,t[o],{includePrerelease:!0}))}catch(n){s=!0}}}));else if("object"===typeof o){const t=o;Object.keys(t).forEach((e=>{if(e&&void 0!==t[e]&&s){const o=this.state.installed[e],n="string"===typeof t[e];try{s=!!o&&(!n||r().satisfies(o.version,t[e],{includePrerelease:!0}))}catch(i){s=!0}}}))}else console.error("[ADAPTERS] Invalid dependencies for ".concat(t,": ").concat(JSON.stringify(o)));if(s&&n)try{s=r().satisfies(this.state.nodeJsVersion,n)}catch(i){s=!0}}return s},this.onHostAdapterChanged=t=>{this.onHostAdapterTimer&&clearTimeout(this.onHostAdapterTimer),this.onHostAdapterTimer=setTimeout((()=>{this.onHostAdapterTimer=null,this.cache.listOfVisibleAdapter=null,this.forceUpdate()}),200)},this.setAdminUpgradeTo=t=>this.setState({adminUpgradeTo: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:j.o.getReadTimeoutMs(),showSlowConnectionWarning:!1,currentHost:t.currentHost,forceUpdateAdapters:t.forceUpdateAdapters,triggerUpdate:t.triggerUpdate,ratings:null,categoriesExpanded:{},adminUpgradeTo:""}),this.inputRef=(0,o.createRef)(),this.countRef=(0,o.createRef)(),this.t=this.translate}renderSlowConnectionWarning(){return this.state.showSlowConnectionWarning?(0,g.jsx)(j.A,{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 S(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,e,s){await this.getAdapters(t,e,s),await this.getAdaptersInfo(t,s)}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}analyseInstalled(t){let{adapters:e,repository:s}=t;const{cb:i,installedLocal:o}=t;let{installedGlobal:n}=t;e=e||this.state.adapters;const a=o||this.state.installed;n=n||this.state.installedGlobal,s=s||this.state.repository;const r=[];Object.keys(a).forEach((t=>{if(a[t]){const e=a[t].version,i=s[t];i&&i.version!==e&&C.A.updateAvailable(e,i.version)&&!r.includes(t)&&r.push(t)}})),this.cache.listOfVisibleAdapter=null,this.setState({adapters:e,updateAvailable:r,installed:a,repository:s,installedGlobal:n},(()=>i&&i()))}async getInstalled(t){let e,s={};const o=await this.props.socket.getHosts(t);for(const a of o)try{const o=await this.props.socket.getState("".concat(a._id,".alive"));if(null!==o&&void 0!==o&&o.val){const o=await this.props.socket.getInstalled(a._id,t,this.state.readTimeoutMs);a._id===this.state.currentHost&&(e=o),s=(0,i.A)((0,i.A)({},s),o)}}catch(n){window.alert('Cannot getInstalled from "'.concat(a._id,'" (timeout ').concat(this.state.readTimeoutMs,"ms): ").concat(n)),n.toString().includes("timeout")&&this.setState({showSlowConnectionWarning:!0})}return{installedLocal:e,installedGlobal:s}}async getAdapters(t,e,s){console.log("[ADAPTERS] getAdapters");const i=this.state.currentHost;let o;t=t||this.props.adaptersWorker.isForceUpdate(),this.state.update||!t&&!s||this.setState({update:!0});try{o=await this.props.adaptersWorker.getObjects(t)||{}}catch(l){window.alert("Cannot getAdapters: ".concat(l))}const{installedLocal:n,installedGlobal:a}=await this.getInstalled(t);let r;try{r=await this.props.socket.getRepository(i,{repo:this.props.systemConfig.common.activeRepo,update:e||s},t,this.state.readTimeoutMs)}catch(l){window.alert("Cannot getRepository: ".concat(l)),l.toString().includes("timeout")&&this.setState({showSlowConnectionWarning:!0})}return this.analyseInstalled({adapters:o,installedLocal:n,repository:r,installedGlobal:a})}getWordVotes(t){if(1===t)return this.t("vote");if(t>=2&&t<=4)return this.t("votes2");if(t>=5&&t<=20)return this.t("votes");const e=t%10;return 1===e?this.t("vote21"):e>=2&&e<=4?this.t("votes2"):this.t("votes")}static getAdapterTitle(t,e,s){if(!e[t])return t;const i=e[t].titleLang||e[t].title;let o;return o="object"===typeof i?i[s]||i.en:i,o=((o||"").toString()||"").replace("ioBroker Visualisation - ",""),o.toLowerCase()}static sortAdapters(t,e,s,i,o,n,a,r){const l={};t.sort(((t,p)=>{if(n)return i[p].stat===i[t].stat?(l[t]=l[t]||bt.getAdapterTitle(t,i,e),l[p]=l[p]||bt.getAdapterTitle(p,i,e),l[t]>l[p]?1:l[t]<l[p]?-1:0):i[p].stat-i[t].stat;if(a)return i[t]?i[p]?i[t].daysAgo===i[p].daysAgo?(l[t]=l[t]||bt.getAdapterTitle(t,i,e),l[p]=l[p]||bt.getAdapterTitle(p,i,e),l[t]>l[p]?1:l[t]<l[p]?-1:0):i[t].daysAgo-i[p].daysAgo:1:-1;if(r){if(r[t].exact&&!r[p].exact)return-1;if(!r[t].exact&&r[p].exact)return 1}return s[t]&&s[p]?o?t>p?1:t<p?-1:0:(l[t]=l[t]||bt.getAdapterTitle(t,i,e),l[p]=l[p]||bt.getAdapterTitle(p,i,e),l[t]>l[p]?1:l[t]<l[p]?-1:0):s[t]?-1:s[p]?1:o?t>p?1:t<p?-1:0:(l[t]=l[t]||bt.getAdapterTitle(t,i,e),l[p]=l[p]||bt.getAdapterTitle(p,i,e),l[t]>l[p]?1:l[t]<l[p]?-1:0)}))}calculateInfo(t,e,s,i){var o,n,a;s=s||this.state.hostData,e=e||this.state.ratings,t=t||this.state.compactInstances,null!==(o=i)&&void 0!==o&&o._id||(i=this.state.compactRepositories);const r=this.state.adapters,l=JSON.parse(JSON.stringify(this.state.installed)),p=JSON.parse(JSON.stringify(this.state.repository)),d=((null===(n=s)||void 0===n?void 0:n["Node.js"])||"").replace("v",""),c=(null===(a=s)||void 0===a?void 0:a.os)||"",h={},u=[];let g={};try{g=JSON.parse((window._localStorage||window.localStorage).getItem("Adapters.expandedCategories"))||{}}catch(A){}Object.keys(l).forEach((t=>{var e,s;const i=l[t];null!==(e=r[t])&&void 0!==e&&null!==(s=e.common)&&void 0!==s&&s.ignoreVersion&&(i.ignoreVersion=r[t].common.ignoreVersion),i.controller||"hosts"===t||p[t]||(p[t]=JSON.parse(JSON.stringify(i)),p[t].version=""),i.count=0,i.enabled=0})),Object.keys(t).forEach((e=>{const s=t[e].name;l[s]&&l[s].count++}));const m=Date.now();this.recentUpdatedAdapters=0,this.installedAdapters=0,Object.keys(p).forEach((t=>{var s,i;if("hosts"===t)return;if(t.startsWith("_"))return;const o=p[t];o.keywords&&(o.keywords=o.keywords.map((t=>t.toLowerCase())));const n=l[t];if(o.rating=null===(s=e)||void 0===s?void 0:s[t],null!==(i=o.rating)&&void 0!==i&&i.rating?o.rating.title=["".concat(this.t("Total rating:")," ").concat(o.rating.rating.r," (").concat(o.rating.rating.c," ").concat(this.getWordVotes(o.rating.rating.c),")"),n&&n.version&&o.rating[n.version]?"".concat(this.t("Rating for")," v").concat(n.version,": ").concat(o.rating[n.version].r," (").concat(o.rating[n.version].c," ").concat(this.getWordVotes(o.rating.rating.c),")"):""].filter((t=>t)).join("\n"):o.rating={title:this.t("No rating or too few data")},!o.controller){const e=o.type,s=l[t];Math.round((m-new Date(o.versionDate).getTime())/864e5)<=31&&this.recentUpdatedAdapters++,l[t]&&this.installedAdapters++,h[e]?(h[e].count++,h[e].adapters.push(t),s&&h[e].installed++):h[e]={name:e,translation:this.t("".concat(e,"_group")),count:1,installed:s?1:0,adapters:[t]}}})),Object.keys(h).sort(((t,e)=>"general"===t&&"general"!==e?-1:"general"!==t&&"general"===e||h[t].translation>h[e].translation?1:h[t].translation<h[e].translation?-1:0)).forEach((t=>u.push(h[t])));const x="Name A-Z"===this.state.filterTiles;Object.keys(h).forEach((t=>bt.sortAdapters(h[t].adapters,this.props.lang,l,p,x)));let y=0;try{y=JSON.parse((window._localStorage||window.localStorage).getItem("Adapters.installedList")),!1===y&&(y=0)}catch(C){}const v="true"===(window._localStorage||window.localStorage).getItem("Adapters.list"),f="true"===(window._localStorage||window.localStorage).getItem("Adapters.viewMode"),w="true"===(window._localStorage||window.localStorage).getItem("Adapters.updateList"),b=(window._localStorage||window.localStorage).getItem("Adapters.categoriesTiles")||"All";let j=(window._localStorage||window.localStorage).getItem("Adapters.filterTiles")||"Description A-Z";return"A-Z"===j&&(j="Description A-Z"),this.allAdapters=Object.keys(p).length-1,this.cache.listOfVisibleAdapter=null,new Promise((o=>{this.setState({repository:p,installed:l,ratings:e,filterTiles:j,categoriesTiles:b,compactRepositories:i,installedList:y,compactInstances:t,updateList:w,tableViewMode:f,oneListView:v,lastUpdate:Date.now(),hostData:s,hostOs:c,nodeJsVersion:d,categories:u,categoriesExpanded:g,init:!0,update:!1},(()=>o()))}))}async getAdaptersInfo(t,e){if(this.state.currentHost&&Date.now()-this.state.lastUpdate>1e3){console.log("[ADAPTERS] getAdaptersInfo");const a=this.state.currentHost;let r;try{var s;this.state.update&&!e||await new Promise((t=>{this.setState({update:!0},(()=>t()))}));const n=await this.props.socket.getHostInfo(a,t,this.state.readTimeoutMs).catch((t=>{window.alert('Cannot getHostInfo for "'.concat(a,'": ').concat(t)),t.toString().includes("timeout")&&this.setState({showSlowConnectionWarning:!0})}));if(!1!==(null===(s=this.props.adminGuiConfig.admin.adapters)||void 0===s?void 0:s.allowAdapterRating)){var i;try{r=await this.props.socket.getRatings(t)}catch(o){window.alert("Cannot read ratings: ".concat(o))}this.uuid=(null===(i=r)||void 0===i?void 0:i.uuid)||null}else r=null;const l=await this.props.socket.getCompactInstances(t).catch((t=>(window.alert("Cannot read countsOfInstances: ".concat(t)),{}))),p=await this.props.socket.getCompactSystemRepositories(t).catch((t=>(window.alert("Cannot read getCompactSystemRepositories: ".concat(t)),{})));await this.calculateInfo(l||{},r,n,p)}catch(n){window.alert("Cannot get adapters info: ".concat(n))}}}toggleCategory(t){this.setState((e=>{const s=e.categoriesExpanded;return s[t]=!s[t],(window._localStorage||window.localStorage).setItem("Adapters.expandedCategories",JSON.stringify(s)),{categoriesExpanded:s}}))}rightOs(t){const e=this.state.repository[t];return null===e||void 0===e||!e.os||(Array.isArray(e.os)?!!e.os.find((t=>this.state.hostOs===t)):this.state.hostOs===e.os)}handleFilterChange(t){this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout((t=>{(window._localStorage||window.localStorage).setItem("Adapter.search",t||""),this.typingTimer=null,this.filterAdapters(t)}),300,t.target.value)}expandAll(){this.setState((t=>{const e=t.categories,s=t.categoriesExpanded;return e.forEach((t=>s[t.name]=!0)),(window._localStorage||window.localStorage).setItem("Adapters.expandedCategories",JSON.stringify(s)),{categoriesExpanded:s}}))}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 e=this.state.filterTiles;t&&"Description A-Z"!==e&&"Name A-Z"!==e&&(e="Description A-Z",(window._localStorage||window.localStorage).setItem("Adapters.filterTiles",e)),(window._localStorage||window.localStorage).setItem("Adapters.viewMode",t?"true":"false"),this.setState({tableViewMode:t,filterTiles:e})}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 e=this.state.installedList?this.state.installedList<2?2:0:1;!e&&t&&(e=1),(window._localStorage||window.localStorage).setItem("Adapters.installedList",JSON.stringify(e)),this.setState({installedList:e})}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===t?this.state.search:t)||"").toLowerCase().trim();let e={};t?this.state.categories.forEach((s=>s.adapters.forEach((s=>{var i;const o=this.state.repository[s];if(!o)return;let n,a;const r=o.titleLang||o.title;n="object"===typeof r?r[this.props.lang]||r.en:r,n=((n||"").toString()||"").replace("ioBroker Visualisation - ",""),a=o.desc?"string"===typeof o.desc?o.desc:o.desc[this.props.lang]||o.desc.en||"":"",s.includes(t)?e[s]={exact:s===t,type:"name",start:s.startsWith(t)}:n&&"string"===typeof n&&n.toLowerCase().includes(t)?e[s]={exact:!1,type:"title"}:a&&"string"===typeof a&&a.toLowerCase().includes(t)?e[s]={exact:!1,type:"desc"}:null!==(i=o.keywords)&&void 0!==i&&i.find((e=>e.includes(t)))&&(e[s]={exact:!1,type:"keywords"})})))):e=null,this.setState({filteredList:e,search:t},(()=>{this.cache.listOfVisibleAdapter=null,this.forceUpdate()}))}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:t=>{const e=[...this.state.updateAvailable],s=e.indexOf(t);-1!==s&&(e.splice(s,1),this.setState({updateAvailable:e}))},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&&"Popular first"===this.state.filterTiles,sortRecentlyUpdated:!this.state.tableViewMode&&"Recently updated"===this.state.filterTiles,isTileView:!this.state.tableViewMode,updateRating:(t,e)=>{const s=JSON.parse(JSON.stringify(this.state.repository));Object.assign(s[t].rating,e),this.setState({repository:s})},setAdminUpgradeTo:this.setAdminUpgradeTo,hostAdapterWorker:this.hostAdapterWorker}}buildCache(t){this.cache.listOfVisibleAdapter=[],this.cache.adapters={};const e=Date.now(),s=this.t("0 %d days ago"),i=this.t("1 %d days ago"),o=this.t("2 %d days ago"),n=this.t("5 %d days ago");this.state.categories.filter((t=>this.state.tableViewMode||!this.state.categoriesTiles||"All"===this.state.categoriesTiles||t.name===this.state.categoriesTiles)).forEach((t=>t.adapters.forEach((t=>{const a=this.state.repository[t];if(a&&!a.controller){const l=a.connectionType?a.connectionType:"-",p=this.state.updateAvailable.includes(t),d=this.state.installed[t];let c=!this.state.filteredList||!!this.state.filteredList[t];if(c&&this.state.filterConnectionType&&(c="local"===l),c&&this.state.updateList&&(c=p),c&&this.state.installedList&&(c=this.state.installedList<2?!(!d||!d.version):!(!d||!d.version||d.count)),c){var r;this.cache.listOfVisibleAdapter.push(t);const l=Math.round((e-new Date(a.versionDate).getTime())/864e4),p=Math.round(l/10),c=a.titleLang||a.title;let h,u;h=c&&"object"===typeof c?c[this.props.lang]||c.en:c||t,h=((h||"").toString()||"").replace("ioBroker Visualisation - ",""),u=a.desc?"string"===typeof a.desc?a.desc:a.desc[this.props.lang]||a.desc.en||"":"";const g=p%100<=10||p%100>=20?p%10:5;this.cache.adapters[t]={title:h,desc:u,image:d&&this.state.adapters["system.adapter.".concat(t)]?".".concat(d.localIcon):a.extIcon,connectionType:a.connectionType?a.connectionType:"-",updateAvailable:this.state.updateAvailable.includes(t),rightDependencies:this.rightDependencies(t),rightOs:this.rightOs(t),sentry:!(null===(r=a.plugins)||void 0===r||!r.sentry),daysAgo:l,stat:a.stat||0,daysAgoText:p||0===p?0===p?s:1===g?i.replace("%d",p.toString()):2===g||3===g||4===g?o.replace("%d",p.toString()):n.replace("%d",p.toString()):""}}}})))),this.listOfVisibleAdapterLength=this.cache.listOfVisibleAdapter.length;const a="Name A-Z"===this.state.filterTiles;this.state.tableViewMode&&this.state.categories.forEach((t=>bt.sortAdapters(t.adapters,this.props.lang,this.state.installed,this.cache.adapters,a))),bt.sortAdapters(this.cache.listOfVisibleAdapter,this.props.lang,this.state.installed,this.cache.adapters,a,t.sortPopularFirst,t.sortRecentlyUpdated,this.state.filteredList),console.log("[ADAPTERS] ".concat((new Date).toISOString()," Update cache!")),this.forceUpdate()}getUpdater(){return this.state.showUpdater?(0,g.jsx)(b,{theme:this.props.theme,onSetCommandRunning:t=>this.props.onSetCommandRunning(t),t:this.props.t,currentHost:this.state.currentHost,lang:this.props.lang,installed:this.state.installed,repository:this.state.repository,toggleTranslation:this.props.toggleTranslation,noTranslation:this.props.noTranslation,onClose:t=>this.setState({showUpdater:!1},(()=>t&&this.updateAll(!0,!1))),socket:this.props.socket}):null}getDescWidth(){return this.props.menuOpened?document.body.scrollWidth-ut-180+13:this.props.menuClosed?document.body.scrollWidth-ut:document.body.scrollWidth-ut-50+13}getStatistics(){return this.state.showStatistics?(0,g.jsxs)(l.Dialog,{open:!0,onClose:()=>this.setState({showStatistics:!1}),children:[(0,g.jsx)(l.DialogTitle,{children:this.t("Statistics")}),(0,g.jsxs)(l.DialogContent,{style:{fontSize:16},children:[(0,g.jsxs)(l.Box,{component:"div",sx:ft.counters,children:[this.t("Total adapters"),":"," ",(0,g.jsx)("span",{style:{paddingLeft:6,fontWeight:"bold"},children:this.allAdapters})]}),(0,g.jsxs)(l.Box,{component:"div",sx:ft.counters,children:[this.t("Installed adapters"),":"," ",(0,g.jsx)("span",{style:{paddingLeft:6,fontWeight:"bold"},children:this.installedAdapters})]}),(0,g.jsxs)(l.Box,{component:"div",sx:ft.counters,children:[this.t("Last month updated adapters"),":"," ",(0,g.jsx)("span",{style:{paddingLeft:6,fontWeight:"bold"},children:this.recentUpdatedAdapters})]})]}),(0,g.jsx)(l.DialogActions,{children:(0,g.jsx)(l.Button,{variant:"contained",onClick:()=>this.setState({showStatistics:!1}),color:"primary",autoFocus:!0,startIcon:(0,g.jsx)(p.Close,{}),children:this.props.t("Close")})})]}):null}renderGitHubInstallDialog(t){return this.state.gitHubInstallDialog?(0,g.jsx)(D,{t:this.t,categories:this.state.categories,installed:this.state.installedGlobal,upload:t=>this.props.executeCommand("upload ".concat(t).concat(this.props.expertMode?" --debug":"")),installFromUrl:(e,s,i)=>this.addInstance({adapterName:e,debug:s,customUrl:i,context:t}),repository:this.state.repository,onClose:()=>{this.setState({gitHubInstallDialog:!1})}}):null}renderHeader(){var t;let e=!this.props.commandRunning&&!!this.props.ready&&!!this.state.updateList&&this.state.updateAvailable.length>1;return e&&2===this.state.updateAvailable.length&&this.state.updateAvailable.includes("admin")&&(e=!1),(0,g.jsxs)(h.TabHeader,{children:[(0,g.jsx)(l.Tooltip,{title:this.t("Change view mode"),slotProps:{popper:{sx:ft.tooltip}},children:(0,g.jsx)(l.IconButton,{size:"large",onClick:()=>this.changeViewMode(),children:this.state.tableViewMode?(0,g.jsx)(p.ViewModule,{}):(0,g.jsx)(p.ViewList,{})})}),(0,g.jsx)(l.Tooltip,{title:this.t("Check adapter for updates"),slotProps:{popper:{sx:ft.tooltip}},children:(0,g.jsx)(l.IconButton,{size:"large",onClick:()=>this.updateAll(!0,!0),children:(0,g.jsx)(p.Refresh,{})})}),this.state.tableViewMode&&!this.state.oneListView&&(0,g.jsx)(l.Tooltip,{title:this.t("expand all"),slotProps:{popper:{sx:ft.tooltip}},children:(0,g.jsx)(l.IconButton,{size:"large",onClick:()=>this.expandAll(),children:(0,g.jsx)(p.FolderOpen,{})})}),this.state.tableViewMode&&!this.state.oneListView&&(0,g.jsx)(l.Tooltip,{title:this.t("collapse all"),slotProps:{popper:{sx:ft.tooltip}},children:(0,g.jsx)(l.IconButton,{size:"large",onClick:()=>this.collapseAll(),children:(0,g.jsx)(p.Folder,{})})}),this.state.tableViewMode&&(0,g.jsx)(l.Tooltip,{title:this.t("list"),slotProps:{popper:{sx:ft.tooltip}},children:(0,g.jsx)(l.IconButton,{size:"large",onClick:()=>this.listTable(),children:(0,g.jsx)(p.List,{color:this.state.oneListView?"primary":"inherit"})})}),this.state.updateList?(0,g.jsx)(l.IconButton,{size:"large",onClick:()=>this.changeInstalledList(!0),children:(0,g.jsx)(p.Star,{color:"primary",style:{opacity:.3,color:2===this.state.installedList?"red":void 0}})}):(0,g.jsx)(l.Tooltip,{slotProps:{popper:{sx:ft.tooltip}},title:this.t(this.state.installedList?1===this.state.installedList?"Showed only installed adapters":"Showed only installed adapters without instance.":"Show only installed"),children:(0,g.jsx)(l.IconButton,{size:"large",onClick:()=>this.changeInstalledList(),children:(0,g.jsx)(p.Star,{style:2===this.state.installedList?{color:"red"}:null,color:1===this.state.installedList?"primary":"inherit"})})}),(0,g.jsx)(A.A,{config:this.props.adminGuiConfig.admin,name:"admin.adapters.filterUpdates",children:(0,g.jsx)(l.Tooltip,{title:this.t("Filter adapter with updates"),slotProps:{popper:{sx:ft.tooltip}},children:(0,g.jsx)(l.IconButton,{size:"large",onClick:()=>this.changeUpdateList(),children:(0,g.jsx)(p.Update,{color:this.state.updateList?"primary":"inherit"})})})}),e&&(0,g.jsx)(l.Tooltip,{title:this.t("Update all adapters"),slotProps:{popper:{sx:ft.tooltip}},children:(0,g.jsxs)(l.IconButton,{size:"large",onClick:()=>this.setState({showUpdater:!0}),sx:ft.updateAllButton,children:[(0,g.jsx)(p.Update,{}),(0,g.jsx)(p.Update,{className:"admin-update-second-icon"})]})}),this.props.expertMode&&!1!==(null===(t=this.props.adminGuiConfig.admin)||void 0===t?void 0:t.adapters.gitHubInstall)&&(0,g.jsx)(l.Tooltip,{title:this.t("Install from custom URL"),slotProps:{popper:{sx:ft.tooltip}},children:(0,g.jsx)(l.IconButton,{size:"large",onClick:()=>this.setState({gitHubInstallDialog:!0}),children:(0,g.jsx)(d.hL4,{})})}),(0,g.jsx)("div",{style:ft.grow}),(0,g.jsx)(l.TextField,{variant:"standard",inputRef:this.inputRef,label:this.t("Filter by name"),defaultValue:this.state.search,onChange:t=>this.handleFilterChange(t),slotProps:{input:{endAdornment:this.state.search?(0,g.jsx)(l.InputAdornment,{position:"end",children:(0,g.jsx)(l.IconButton,{size:"small",onClick:()=>{(window._localStorage||window.localStorage).removeItem("Adapter.search"),this.inputRef.current.value="",this.setState({search:""},(()=>this.filterAdapters()))},children:(0,g.jsx)(p.Close,{})})}):null}}}),!this.state.tableViewMode&&(0,g.jsx)(c.A,{t:this.t,icons:!0,contained:"All"!==this.state.categoriesTiles,translateSuffix:"_group",arrayItem:[{name:"All"},...this.state.categories],onClick:t=>this.changeCategoriesTiles(t),value:this.state.categoriesTiles}),(0,g.jsx)(c.A,{t:this.t,arrayItem:this.state.tableViewMode?wt.filter((t=>!t.notByList)):wt,onClick:t=>this.changeFilterTiles(t),value:this.state.filterTiles}),(0,g.jsx)("div",{style:ft.grow}),(0,g.jsx)(A.A,{config:this.props.adminGuiConfig.admin,name:"admin.adapters.statistics",children:(0,g.jsxs)(l.Box,{component:"div",sx:h.Utils.getStyle(this.props.theme,ft.infoAdapters,{display:{sm:"none",md:"inline-block"}}),onClick:()=>this.setState({showStatistics:!0}),children:[(0,g.jsxs)(l.Box,{component:"div",sx:(0,i.A)((0,i.A)({},ft.counters),ft.greenText),children:[this.t("Selected adapters"),(0,g.jsx)("div",{ref:this.countRef})]}),(0,g.jsxs)(l.Box,{component:"div",sx:ft.counters,children:[this.t("Total adapters"),":",(0,g.jsx)("div",{children:this.allAdapters})]}),(0,g.jsxs)(l.Box,{component:"div",sx:ft.counters,children:[this.t("Installed adapters"),":",(0,g.jsx)("div",{children:this.installedAdapters})]}),(0,g.jsxs)(l.Box,{component:"div",sx:ft.counters,children:[this.t("Last month updated adapters"),":",(0,g.jsx)("div",{children:this.recentUpdatedAdapters})]})]})})]})}renderWebserverUpgrade(){return this.state.adminUpgradeTo?(0,g.jsx)(vt,{socket:this.props.socket,themeType:this.props.themeType,host:this.props.adminHost,onClose:()=>{console.log("Close dialog"),this.setState({adminUpgradeTo:"",showDialog:!1})},version:this.state.adminUpgradeTo,adminInstance:this.props.adminInstance,onUpdating:t=>{this.props.onUpdating(t)},currentAdminVersion:this.props.currentAdminVersion}):null}render(){var t,e;if(!this.state.init)return(0,g.jsx)(l.LinearProgress,{});this.state.triggerUpdate!==this.props.triggerUpdate&&setTimeout((()=>{this.setState({triggerUpdate:this.props.triggerUpdate},(()=>this.updateAll(!0)))}),100),this.props.currentHost===this.state.currentHost&&this.props.forceUpdateAdapters===this.state.forceUpdateAdapters||(this.hostsTimer=this.hostsTimer||setTimeout((()=>{this.hostsTimer=null,this.setState({currentHost:this.props.currentHost,forceUpdateAdapters:this.props.forceUpdateAdapters},(async()=>{this.hostAdapterWorker.getHost()!==this.props.currentHost&&(this.hostAdapterWorker.destroy(),this.hostAdapterWorker=new S(this.props.socket,this.props.currentHost),this.hostAdapterWorker.registerHandler(this.onHostAdapterChanged),await this.hostAdapterWorker.getObjects()),await this.updateAll(!1,!1,!0)}))}),200));let s=h.Utils.isStableRepository(this.props.systemConfig.common.activeRepo);const i=null===(t=this.state.compactRepositories)||void 0===t||null===(e=t.native)||void 0===e?void 0:e.repositories;if(i&&this.props.systemConfig.common.activeRepo)if(Array.isArray(this.props.systemConfig.common.activeRepo))s=this.props.systemConfig.common.activeRepo.every((t=>{var e,s,o;return t.toLowerCase().startsWith("stable")||(null===(e=i[t])||void 0===e||null===(s=e.json)||void 0===s||null===(o=s._repoInfo)||void 0===o?void 0:o.stable)}));else if("string"===typeof this.props.systemConfig.common.activeRepo){var o,n,a;s=this.props.systemConfig.common.activeRepo.toLowerCase().startsWith("stable")||(null===(o=i[this.props.systemConfig.common.activeRepo])||void 0===o||null===(n=o.json)||void 0===n||null===(a=n._repoInfo)||void 0===a?void 0:a.stable)}let r;if(!s)if(r=Array.isArray(this.props.systemConfig.common.activeRepo)?this.props.systemConfig.common.activeRepo.join(", "):this.props.systemConfig.common.activeRepo,"string"===typeof this.props.systemConfig.common.activeRepo){var p,d;const t=i&&(null===(p=i[this.props.systemConfig.common.activeRepo])||void 0===p||null===(d=p.json)||void 0===d?void 0:d._repoInfo);null!==t&&void 0!==t&&t.name&&(r=t.name&&"object"===typeof t.name?t.name[this.props.lang]||t.name.en:t.name)}else this.props.systemConfig.common.activeRepo&&"string"!==typeof this.props.systemConfig.common.activeRepo&&(r=this.props.systemConfig.common.activeRepo.map((t=>{var e,s;const o=i&&(null===(e=i[t])||void 0===e||null===(s=e.json)||void 0===s?void 0:s._repoInfo);return null!==o&&void 0!==o&&o.name?o.name&&"object"===typeof o.name?o.name[this.props.lang]||o.name.en:o.name:t})).join(", "));const c=this.getContext(this.state.descWidth<50);return this.cache.listOfVisibleAdapter||(this.buildCacheTimer=this.buildCacheTimer||setTimeout((()=>{this.buildCacheTimer=null,this.buildCache(c)}),0)),(0,g.jsxs)(h.TabContainer,{children:[this.state.update&&(0,g.jsx)(l.Grid2,{children:(0,g.jsx)(l.LinearProgress,{})}),this.renderHeader(),(0,g.jsx)(xt,{stableRepo:s,repoName:r,context:c,noTranslation:this.props.noTranslation,systemConfig:this.props.systemConfig,tableViewMode:this.state.tableViewMode,oneListView:this.state.oneListView,update:this.state.update,updateListFilter:this.state.updateList,searchFilter:this.state.search,installedListFilter:this.state.installedList,cachedAdapters:this.cache.adapters,categories:this.state.categories,categoriesExpanded:this.state.categoriesExpanded,listOfVisibleAdapter:this.cache.listOfVisibleAdapter,toggleCategory:t=>this.toggleCategory(t),clearAllFilters:t=>this.clearAllFilters(t),descWidth:this.state.descWidth,sortByName:"Name A-Z"===this.state.filterTiles,sortPopularFirst:c.sortPopularFirst,sortRecentlyUpdated:c.sortRecentlyUpdated,commandRunning:this.props.commandRunning}),this.getUpdater(),this.getStatistics(),this.renderSlowConnectionWarning(),this.renderGitHubInstallDialog(c),this.renderWebserverUpgrade(),this.renderDialogs(c)]})}}const jt=bt}}]);
|
|
2
|
+
//# sourceMappingURL=4289.a5fc8b2e.chunk.js.map
|