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