#show link: it => if type(it.dest) == label {
  context {
    if query(it.dest).len() == 0 {
      it.body
    } else {
      it
    }
  }
} else {
  it
}

#let get_figures(body) = {
  if type(body) == array {
    body.map(get_figures).flatten()
  } else if type(body) == dictionary {
    body.values().map(get_figures).flatten()
  } else if type(body) != content {
    ()
  }else if body.func() == figure {
    (body,)
  } else {
    body.fields().values().map(get_figures).flatten()
  }
}

#let main = include("./main.typ")
#let figs = get_figures(main)
// #repr(figs)
#for f in figs {
  f
}

#bibliography("bibliography.bib")
