import { useMemo } from 'react' import { ChevronDown } from 'lucide-react' import { cn } from '@/lib' import { useChatInitStore } from '@/features/chat/stores/useChatInitStore' interface Props { isOpen: boolean setIsOpen: (isOpen: boolean) => void } export function MDInformation({ isOpen, setIsOpen }: Props) { const { quotation_memo } = useChatInitStore() const memoArray = useMemo(() => { if (!quotation_memo?.trim()) return [] return quotation_memo .split(/\r?\n+/) .map((s) => s.trim()) .filter(Boolean) }, [quotation_memo]) if (memoArray.length === 0) return null return (
{isOpen && (
{memoArray.map((item, i) => (
•
{linkText(item)}
))}
)}
) } function linkText(text: string) { const urlRegex = /(https?:\/\/[^\s]+)/g const isUrl = (s: string) => /^https?:\/\/[^\s]+$/.test(s) const parts = text.split(urlRegex) return (
{parts.map((part, i) => isUrl(part) ? ( 상품 사이트로 이동 ) : ( {i > 0 && isUrl(parts[i - 1]) ? part.replace(/^(\s)/, '') : part} ), )}
) }