import m from"classic-level";import n from"path";import f from"os";import r from"fs/promises";import{IS_MAC_OS as g,IS_WINDOWS as w}from"./constants-DED7MIJj.mjs";import"url";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"4.2.860"}}catch{}})();try{(function(){var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c6955918-3f09-41b1-95a7-797d2dc571e6",e._sentryDebugIdIdentifier="sentry-dbid-c6955918-3f09-41b1-95a7-797d2dc571e6")})()}catch{}const{ClassicLevel:_}=m,a="Beeper";function D(){return g?n.join(f.homedir(),"Library","Application Support",a):w?process.env.APPDATA?n.join(process.env.APPDATA,a):n.join(f.homedir(),a):n.join(process.env.XDG_CONFIG_HOME??n.join(f.homedir(),".config"),a)}const p=n.join(D(),"Local Storage","leveldb"),v=async(e,t)=>{let o=!1;const s=t?n.join(e,t):e;try{await r.access(s),o=!0}catch{o=!1}return o},u=(e,t)=>`${e}\0${t}`,y=e=>e?.replace(/\x01/g,"");async function T(){if(!await v(p)){console.log("old app is probably not installed");return}const t=Date.now(),o=`${p}-${t}`;try{await r.cp(p,o,{recursive:!0}),console.log(`database copied to ${o}`);const s=n.join(o,"LOCK");await v(o,"LOCK")&&(await r.unlink(s),console.log("LOCK file removed"));const l=new _(o,{valueEncoding:"utf8",createIfMissing:!1});let c,b=!1,d;try{await l.open();const i=await l.getMany([u("_nova://nova-web","bpAnalyticsEmail"),u("_nova://nova-web","mx_crypto_initialised"),u("_nova://nova-web","mx_device_id")]);c=i[0],b=y(i[1])==="true",d=i[2]}catch(i){console.error("error reading from leveldb:",i)}finally{await l.close()}return{email:c?y(c):void 0,cryptoInitialised:b,deviceID:d?y(d):void 0}}finally{await r.rm(o,{recursive:!0,force:!0}),console.log(`cleaned up backup database at ${o}`)}}export{T as getDataFromBeeperDesktopV3LevelDB};
//# sourceMappingURL=beeper-v3-importer-BwomztBV.mjs.map
