#set page(width: auto, height: auto)
#import "/src/lib.typ": *

#diagram({
  _seq("Alice", "Bob", comment: "Authentication Request")

  _alt(
    "successful case", {
      _seq("Bob", "Alice", comment: "Authentication Accepted")
    },
    "some kind of failure", {
      _seq("Bob", "Alice", comment: "Authentication Failure")

      _grp("My own label", desc: "My own label2", {
        _seq("Alice", "Log", comment: "Log attack start")
        _loop("1000 times", {
          _seq("Alice", "Bob", comment: "DNS Attack")
        })
        _seq("Alice", "Log", comment: "Log attack end")
      })
    },
    "Another type of failure", {
      _seq("Bob", "Alice", comment: "Please repeat")
    }
  )
})

#pagebreak()

#diagram({
  _par("a", display-name: box(width: 1.5em, height: .5em), show-bottom: false)
  _par("b", display-name: box(width: 1.5em, height: .5em), show-bottom: false)
  _col("a", "b", width: 2cm)
  _loop("a<1", min: 1, {
    _seq("a", "b", end-tip: ">>")
    _seq("b", "a", end-tip: ">>")
  })
  _seq("a", "b", end-tip: ">>")
})

#pagebreak()

#diagram({
  _par("A")
  _par("B")
  _col("A", "B", width: 3cm)
  _seq("A", "B", enable-dst: true)
  _alt([desc], {
    _ret()
  })
})