import{p as r}from"./useEvent-D91BmmQi.js";import{Fn as o,In as h,ki as n}from"./cells-DOA0Gew8.js";import{f as m}from"./arrays-DYDL-3-i.js";var d="marimo:ai:chatState:v5";const v=r(null),f=n("marimo:ai:includeOtherCells",!0,h);function u(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:[...u(t.chats).entries()],activeChatId:t.activeChatId}),fromSerializable:t=>({chats:new Map(t.chats),activeChatId:t.activeChatId})})),C=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{f as i,v as n,i as r,C as t};
