const {
Task}
=require('../task'),b4a=require('b4a');
module.exports=class LeaveRoomTask extends Task{
constructor(_0x29ac38){
_0x5eec79={
_0xd52bd3:0x7e,_0x3ebc26:0x150},_0x5bbf7c={
_0x103da5:0x41,_0x184028:0x1bc}
;
super(_0x29ac38);
const _0x2ae65a=this.description.leaveRoom;
this._roomKey=_0x2ae65a.roomKey,this._isGossiped=_0x2ae65a.isGossiped,this._roomInfo=null;
this._identityInfo=null,this._room=null,this._privateProfile=null;
}
async._close(){
_0x5173e3={
_0x5b68af:0x433,_0x43bd14:0x13e,_0x1b0ea9:0xea},_0x8b0a85={
_0x84b010:0x203,_0x56fed8:0xf4}
;
if(this._room)this.keet.internalReleaseRoom(this._room);
if(this._privateProfile)this.keet.internalReleaseRoom(this._privateProfile);
}
async._load(){
_0x451b4b={
_0x2fc3e5:0x427,_0x26f095:0x100},_0x1c3f23={
_0x5a55fc:0x94,_0x13da76:0x19}
;
const [_0x3e6b7e,_0x3f079d]=await Promise.all([this.local.get("@local/rooms",{'roomKey':this._roomKey}),this.local.get("@local/identity")]);
if(this.closing||!_0x3e6b7e||!_0x3f079d)return![];
this._roomInfo=_0x3e6b7e,this._identityInfo=_0x3f079d,this._privateProfile=this.keet.internalOpenExistingRoom(this._identityInfo.privateProfileKey),await this._privateProfile.ready();
if(this.closing)return![];
if(this.discovery&&this._roomInfo){
const _0x5ba8be=this._roomInfo.capabilities.discoveryKeyPair.publicKey;
this.discovery.unsubscribe(_0x5ba8be);
}
this._room=this.keet.internalOpenExistingRoom(this._roomKey),await this._room.ready();
if(this.closing)return![];
let _0x28f65c=![];
const _0x7fb7cf=await this._privateProfile.db.find("@keet-private-id/pending-invitations").toArray();
for(const _0x15d113 of _0x7fb7cf){
if(!b4a.equals(_0x15d113.mailbox,this._roomInfo.capabilities.mailboxKeyPair.publicKey))continue;
_0x28f65c=!![];
}
if(this.closing||_0x28f65c)return![];
return!![];
}
async._save(){
_0x29196a={
_0x512ed9:0x3f,_0x1b6b60:0x3a},_0x5b1e41={
_0x41d51d:0x122},_0x81e39c=await this.keet.internalEnterLocalTransaction();
try{
await _0x81e39c.delete("@local/writers",{'mailbox':this._roomInfo.capabilities.mailboxKeyPair.publicKey}),await _0x81e39c.flush();
}finally{
await this.keet.internalExitLocalTransaction();
}
await this.files.clearAllFiles(this._roomKey,{'leaving':!![]});
}
async._run(){
_0xac3819={
_0x4f9619:0x423,_0x14d8e7:0x5d,_0x4461c0:0x1d5},_0x23542f={
_0x43ea8a:0x1a0,_0xb7327e:0x254},_0x47d094=await this._load();
if(this.closing||!_0x47d094)return;
await this._save();
}
}
;