#import "PageTemplate.typ": *

#set document(
  title: "เครื่องยืนยันตัวตนด้วย NFC",
  author: (
    "ประภากร ศรีวรสาร",
    "พีรดา แสงแป้",
    "ศตคุณ อุตมะ",
  ),
)

#include "ปก.typ"

#counter(page).update(1)
#show: page-theme
#include "Abstract.typ"
#pagebreak()
#include "Acknowledgements.typ"
#pagebreak()

#show outline: set heading(outlined: true)
#show outline.entry: it => {
  show linebreak: [ ]
  link(
    it.element.location(),
    it.indented(it.prefix(), context [
      #it.body()
      #box(width: 1fr, repeat[.])
      #context thai-numbering(counter(page).at(it.element.location()).first())
    ]),
  )
}

#outline(depth: 2, indent: 3.75em)

#pagebreak()

#import "@preview/i-figured:0.2.4"

#i-figured.outline(target-kind: table, title: [สารบัญตาราง])

#pagebreak()

#i-figured.outline(
  title: [สารบัญภาพ],
)

#include "Chapter1.typ"

#include "Chapter2/Chapter2.typ"
#include "Chapter3.typ"
#include "Chapter4.typ"
#include "Chapter5.typ"

#bibliography("References.yaml", title: "บรรณานุกรม", full: true, style: "chicago-author-date")

#pagebreak()

= บรรณานุกรมภาพ

#let image-credits() = context {
  let figures = query(figure.where(kind: "i-figured-image"))
  let attributions = query(<afig>)

  for (idx, f) in figures.enumerate() {
    if (idx >= attributions.len()) {
      return
    }

    f.caption
    // f.counter.display(f.numbering)
    h(2.2em)
    attributions.at(idx).body.body
  }
}

#image-credits()

#include "ภาคผนวก/ภาคผนวก.typ"
#include "History.typ"
