import{p as r}from"./useEvent-D91BmmQi.js";import{Fn as o,Ii as n,In as h}from"./cells-DQ5n6Zef.js";import{f as m}from"./arrays-DWxvyYxP.js";var d="marimo:ai:chatState:v5";const v=r(null),I=n("marimo:ai:includeOtherCells",!0,h);function f(t){let a=new Map;for(let[s,e]of t.entries()){if(e.messages.length===0)continue;let c=m(e.messages,l=>l.id);a.set(s,{...e,messages:c})}return a}const i=n(d,{chats:new Map,activeChatId:null},o({toSerializable:t=>({chats:[...f(t.chats).entries()],activeChatId:t.activeChatId}),fromSerializable:t=>({chats:new Map(t.chats),activeChatId:t.activeChatId})})),u=r(t=>{let a=t(i);return a.activeChatId?a.chats.get(a.activeChatId):null},(t,a,s)=>{a(i,e=>({...e,activeChatId:s}))});export{I as i,v as n,i as r,u as t};
