"use strict";(self.webpackChunkpasswords_webextension=self.webpackChunkpasswords_webextension||[]).push([[7513],{8962:(e,t,s)=>{s.d(t,{Z:()=>r});class r{async execute(e,t){console.trace("controller.execute() not implemented")}}},536:(e,t,s)=>{s.r(t),s.d(t,{default:()=>n});var r=s(8962),d=s(9775),a=s(9083),o=(s(7380),s(6567)),i=s(3155),l=s(8419);class n extends r.Z{async execute(e,t){let{data:s}=e.getPayload(),r=new l.Z,d=r.where(r.field("id").equals(s.id)).hidden(!0).execute();if(0===d.length)return void t.setPayload({success:!1,message:"ToastPasswordUpdateFailed"});let i=d[0];if(i.isTrashed())return void t.setPayload({success:!1,message:"ToastPasswordUpdateFailed"});let n=await a.Z.findById(i.getServer().getId());try{i.setFavorite(this._setProperty("favorite",s,i)).setLabel(this._setProperty("label",s,i)).setUserName(this._setProperty("username",s,i)).setPassword(this._setProperty("password",s,i)).setUrl(this._setProperty("url",s,i)).setEdited(this._setEdited(s,i)).setCustomFields(this._setProperty("customFields",s,i)).setNotes(this._setProperty("notes",s,i)).setFolder(await this._setFolder(n,s,i)).setHidden(this._setProperty("hidden",s,i)),await this._updatePassword(n,i),t.setPayload({success:!0,data:s})}catch(e){o.Z.logError(e),t.setPayload({success:!1,message:"ToastPasswordUpdateFailed"})}}_setProperty(e,t,s){return t.hasOwnProperty(e)?t[e]:s.getProperty(e)}_setEdited(e,t){return e.hasOwnProperty("password")&&e.password!==t.getPassword()?new Date:t.getEdited()}async _setFolder(e,t,s){if(!t.hasOwnProperty("hidden"))return s.getFolder();let r=new i.Z,d=await r.getHiddenFolderId(e);return t.hidden&&s.getFolder()!==d?d:t.hidden||s.getFolder()!==d?s.getFolder():"00000000-0000-0000-0000-000000000000"}async _updatePassword(e,t){let s=e.getInstance("repository.password");await s.update(t),t=await s.findById(t.getId()),d.Z.removeItem(t),d.Z.addItem(t,!0)}}}}]);