import i from"node:fs";import r from"node:path";import{deriveRawAccountId as d}from"../auth/accounts.js";import{resolveStateDir as c}from"./state-dir.js";function a(){return r.join(c(),"openclaw-weixin","accounts")}function S(n){return r.join(a(),`${n}.sync.json`)}function g(){return r.join(c(),"agents","default","sessions",".openclaw-weixin-sync","default.json")}function s(n){try{const t=i.readFileSync(n,"utf-8"),e=JSON.parse(t);if(typeof e.get_updates_buf=="string")return e.get_updates_buf}catch{}}function _(n){const t=s(n);if(t!==void 0)return t;const e=r.basename(n,".sync.json"),o=d(e);if(o){const f=r.join(a(),`${o}.sync.json`),u=s(f);if(u!==void 0)return u}return s(g())}function j(n,t){const e=r.dirname(n);i.mkdirSync(e,{recursive:!0}),i.writeFileSync(n,JSON.stringify({get_updates_buf:t},null,0),"utf-8")}export{S as getSyncBufFilePath,_ as loadGetUpdatesBuf,j as saveGetUpdatesBuf};
