import{I as n,a as o,u as i,_ as d,n as l}from"./index-009d300e.js";const c={components:{},props:{node:Object,socket:Object},mixins:[n],data(){return{fwUpdates:[],loading:!1,includePrereleases:!1,showDowngrades:!1}},computed:{filteredUpdates(){return this.fwUpdates.filter(a=>!a.downgrade||a.downgrade&&this.showDowngrades)}},mounted(){this.checkUpdates()},methods:{...o(i,["showSnackbar"]),async checkUpdates(){this.loading=!0,this.fwUpdates=[];const a=await this.app.apiRequest("getAvailableFirmwareUpdates",[this.node.id,{includePrereleases:this.includePrereleases}]);if(this.loading=!1,a.success){const{default:e}=await d(()=>import("./index-b99dfbc3.js").then(t=>t.i),["./index-b99dfbc3.js","./index-009d300e.js","./index-fe507b7b.css"],import.meta.url);for(const t of a.result)t.changelog=e().render(t.changelog);this.fwUpdates=a.result}else this.showSnackbar(`Failed to check for firmware updates: ${a.message}`,"error")},download(a){window.open(a,"_blank")},async updateFirmware(a){if(await this.app.confirm(`OTA ${a.downgrade?"Downgrade":"Upgrade"}`,`<p>Are you sure you want to ${a.downgrade?"downgrade":"upgrade"} node to <b>v${a.version}</b>?</p>
										
					<p><strong>We don't take any responsibility if devices upgraded using Z-Wave JS don't work after an update. Always double-check that the correct update is about to be installed</strong></p>
					
					<p>This will download the desired firmware update from the <a href="https://github.com/zwave-js/firmware-updates/">Z-Wave JS firmware update service</a> and start an over-the-air (OTA) firmware update for the given node.</p>
	
					`,a.downgrade?"error":"warning",{confirmText:`${a.downgrade?"Downgrade":"Upgrade"}`,cancelText:"Cancel",width:"500px"})){const e=await this.app.apiRequest("firmwareUpdateOTA",[this.node.id,a]);await this.app.handleFwUpdateResponse(e)}}}};var p=function(){var e=this,t=e._self._c;return t("v-container",{attrs:{"grid-list-md":""}},[t("v-row",{staticClass:"ml-5"},[t("v-col",{directives:[{name:"show",rawName:"v-show",value:!e.node.firmwareUpdate,expression:"!node.firmwareUpdate"}],attrs:{cols:"12"}},[t("v-row",{staticClass:"mb-2 text-center",attrs:{justify:"center",dense:""}},[t("v-btn",{attrs:{disabled:e.loading,text:"",color:"green"},on:{click:e.checkUpdates}},[e._v("Check updates")]),t("v-checkbox",{staticClass:"ml-1",attrs:{"hide-details":"",dense:"",label:"Include pre-releases"},model:{value:e.includePrereleases,callback:function(s){e.includePrereleases=s},expression:"includePrereleases"}}),t("v-checkbox",{staticClass:"ml-1",attrs:{"hide-details":"",dense:"",label:"Show downgrades"},model:{value:e.showDowngrades,callback:function(s){e.showDowngrades=s},expression:"showDowngrades"}})],1)],1),e.filteredUpdates.length>0&&!e.node.firmwareUpdate?e._l(e.filteredUpdates,function(s){return t("v-col",{key:s.version,attrs:{cols:"12",sm:"6",md:"4"}},[t("v-card",{attrs:{dense:"",elevation:"5"}},[t("v-card-title",[t("v-icon",[e._v("mdi-update")]),t("span",{staticClass:"headline"},[t("strong",[e._v("v"+e._s(s.version)+" ["+e._s(s.channel)+"]")])]),t("v-spacer"),t("v-btn",{attrs:{outlined:"",small:"",color:s.downgrade?"warning":"success"},on:{click:function(r){return e.updateFirmware(s)}}},[t("v-icon",{attrs:{small:""}},[e._v(e._s(s.downgrade?"download":"upload"))]),e._v(" "+e._s(s.downgrade?"Downgrade":"Update")+" ")],1)],1),t("v-divider",{staticClass:"mx-4"}),t("v-card-text",[t("v-subheader",{staticClass:"subtitle-1"},[t("strong",[e._v("Changelog")])]),t("p",{staticClass:"text-caption ml-4",domProps:{innerHTML:e._s(s.changelog)}}),e._l(s.files,function(r){return t("v-list-item",{key:r.url,staticStyle:{"border-bottom":"1px solid #e0e0e0"},attrs:{"two-line":"",dense:""}},[t("v-list-item-icon",{staticClass:"my-auto mr-3"},[t("v-icon",{attrs:{color:"primary"}},[e._v("widgets")])],1),t("v-list-item-content",[t("v-list-item-title",[e._v("Target: "+e._s(r.target))]),t("v-list-item-subtitle",[e._v(e._s(r.url))])],1),t("v-list-item-icon",{staticClass:"my-auto"},[t("v-btn",{attrs:{title:"Download",icon:""},on:{click:function(m){return e.download(r.url)}}},[t("v-icon",{attrs:{color:"success"}},[e._v("download")])],1)],1)],1)})],2)],1)],1)}):e.loading||e.node.firmwareUpdate?t("v-col",{staticClass:"text-center"},[t("v-progress-circular",{attrs:{indeterminate:"",color:"primary"}}),t("p",{staticClass:"text-caption"},[e._v(" "+e._s(e.node.firmwareUpdate?"Update in progress...":"Remember to wake up sleeping devices...")+" ")])],1):t("v-col",{staticClass:"text-center"},[t("h1",{staticClass:"title"},[e._v("No updates available")]),t("span",[e._v("This service relies on "),t("a",{attrs:{href:"https://github.com/zwave-js/firmware-updates#readme",target:"_blank"}},[e._v("Z-Wave JS Firmware Update Service")]),e._v(", and may not represent all updates for your device.")]),t("br"),t("span",[e._v("If you know that a firmware update "),t("i",[e._v("does")]),e._v(" exist, you can help the Z-Wave JS community by encouraging your device manufacturer to provide the firmwares. Read more in the link above.")])])],2)],1)},v=[],w=l(c,p,v,!1,null,null,null,null);const h=w.exports;export{h as default};
