"use client"; import React, { useEffect, useState } from "react"; import { Sidebar } from "../sidebar"; import Chat, { ChatProps, ChatTopbarProps } from "./chat"; interface ChatLayoutProps { defaultLayout: number[] | undefined; defaultCollapsed?: boolean; navCollapsedSize: number; chatId: string; } type MergedProps = ChatLayoutProps & ChatProps & ChatTopbarProps; export function ChatLayout({ defaultLayout = [30, 160], defaultCollapsed = false, navCollapsedSize = 768, messages, input, handleInputChange, handleSubmit, isLoading, error, stop, chatId, setChatId, chatOptions, setChatOptions, }: MergedProps) { const [isCollapsed, setIsCollapsed] = React.useState(false); const [isMobile, setIsMobile] = useState(false); useEffect(() => { const checkScreenWidth = () => { setIsMobile(window.innerWidth <= 768); setIsCollapsed(window.innerWidth <= 768); }; // Initial check checkScreenWidth(); // Event listener for screen width changes window.addEventListener("resize", checkScreenWidth); // Cleanup the event listener on component unmount return () => { window.removeEventListener("resize", checkScreenWidth); }; }, []); return (