!function(){try{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{}).SENTRY_RELEASE={id:"f5a30ae5c234d85a55bf5a5818b0d80fd7936e7b"}}catch(e){}}();try{e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},(t=(new e.Error).stack)&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f839e20a-dcf4-439f-a50e-6a4d612183ab",e._sentryDebugIdIdentifier="sentry-dbid-f839e20a-dcf4-439f-a50e-6a4d612183ab")}catch(e){}var e,t;const a="ai_pod_boards_cache",s="ai_pod_boards_metadata",d=3e5;const o=new class{getCachedBoards(){try{const e=localStorage.getItem(a);if(!e)return null;const t=JSON.parse(e),s=this.getMetadata();return Date.now()-s.lastSyncTime>d?null:t}catch(e){return null}}setCachedBoards(e){try{const t=e.map(e=>({...e,_cached_at:Date.now()}));localStorage.setItem(a,JSON.stringify(t));const s={};e.forEach(e=>{s[e.id]=this.hashBoard(e)}),this.setMetadata({lastSyncTime:Date.now(),boardHashes:s})}catch(t){}}mergeBoards(e){const t=this.getCachedBoards()||[],a=new Map(t.map(e=>[e.id,e]));e.forEach(e=>{a.set(e.id,e)});const s=Array.from(a.values());return this.setCachedBoards(s),s}removeFromCache(e){const t=(this.getCachedBoards()||[]).filter(t=>!e.includes(t.id));this.setCachedBoards(t)}updateBoardInCache(e,t){const a=(this.getCachedBoards()||[]).map(a=>a.id===e?{...a,...t,updated_at:Date.now()}:a);this.setCachedBoards(a)}getMetadata(){try{const e=localStorage.getItem(s);return e?JSON.parse(e):{lastSyncTime:0,boardHashes:{}}}catch{return{lastSyncTime:0,boardHashes:{}}}}setMetadata(e){try{localStorage.setItem(s,JSON.stringify(e))}catch(t){}}getLastSyncTime(){return this.getMetadata().lastSyncTime}hasChanged(e){const t=this.getMetadata().boardHashes[e.id];if(!t)return!0;return t!==this.hashBoard(e)}hashBoard(e){const t=JSON.stringify({name:e.name,emoji:e.emoji,description:e.description,image_ids:e.image_ids,updated_at:e.updated_at});let a=0;for(let s=0;s<t.length;s++){a=(a<<5)-a+t.charCodeAt(s),a&=a}return a.toString(36)}invalidateBoard(e){const t=(this.getCachedBoards()||[]).filter(t=>t.id!==e);this.setCachedBoards(t)}clearCache(){localStorage.removeItem(a),localStorage.removeItem(s)}needsSync(){const e=this.getMetadata();return Date.now()-e.lastSyncTime>d}};export{o as boardCacheService};
//# sourceMappingURL=boardCacheService.Dl8ErewL.js.map
