<script>
  let visible = $state(false);
  let message = $state("");
  let error = $state(false);
  let timer;

  export function show(text, isError = false) {
    message = text;
    error = isError;
    visible = true;
    clearTimeout(timer);
    timer = setTimeout(() => (visible = false), 2800);
  }
</script>

<div class:show={visible} class:error id="toast" role="status">{message}</div>
