///|
pub let delim : String = "\n§\n"

///| Render a memory block as a formatted string.
/// Returns empty string if entries is empty.
pub fn render_block(
  target : String,
  entries : Array[String],
  max_chars : Int
) -> String {
  if entries.is_empty() {
    return ""
  }
  let body = entries.join(delim)
  let used = body.length()
  let pct = ((used.to_double() / max_chars.to_double()) * 100.0)
    .round()
    .to_int()
  let rule = "═".repeat(43)
  let label = if target == "memory" {
    "MEMORY (your personal notes)"
  } else {
    "USER (what you know about the user)"
  }
  "\{rule}\n\{label} [\{pct}% — \{used}/\{max_chars} chars]\n\{rule}\n\{body}"
}