/*
    This file is part of jellything (https://codeberg.org/metamuffin/jellything)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2026 metamuffin <metamuffin.org>
*/
use crate::RenderInfo;
use jellycommon::{MESSAGE_KIND, MESSAGE_TEXT, jellyobject::Object};
use markup::define;

define! {
    Message<'a>(ri: &'a RenderInfo<'a>, message: Object<'a>) {
        @let _ = ri;
        @let text = message.get(MESSAGE_TEXT).unwrap_or_default();
        @match message.get(MESSAGE_KIND).unwrap_or("neutral") {
            "success" => { section.message { p.success { @text } } }
            "error" => { section.message { p.error { @text } } }
            "neutral" | _ => { section.message { p { @text } } }
        }
    }
}
