#import "core/draw/delay.typ"
#import "core/draw/event.typ": render as evt-render
#import "core/draw/separator.typ"
#import "core/draw/sync.typ"
#import "core/utils.typ": set-ctx

#let _sep(name, ..style) = {
  return ((
    type: "sep",
    draw: separator.render,
    name: name,
    style: style.named()
  ),)
}

#let _delay(name: none, ..style) = {
  return ((
    type: "delay",
    draw: delay.render,
    name: name,
    style: style.named()
  ),)
}

#let _sync(elmts) = {
  return ((
    type: "sync",
    draw: sync.render,
    elmts: elmts
  ),)
}

#let gap-render(gap) = set-ctx(ctx => {
  ctx.y -= gap.size
  return ctx
})

#let _gap(size: 20) = {
  return ((
    type: "gap",
    draw: gap-render,
    size: size
  ),)
}

#let _evt(participant, event) = {
  return ((
    type: "evt",
    draw: evt-render,
    participant: participant,
    event: event,
    lifeline-style: auto
  ),)
}

#let _col(p1, p2, width: auto, margin: 0, min-width: 0, max-width: none) = {
  return ((
    type: "col",
    p1: p1,
    p2: p2,
    width: width,
    margin: margin,
    min-width: min-width,
    max-width: max-width
  ),)
}