# This file is auto-generated by alef — DO NOT EDIT.
# alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
# To regenerate: alef generate
# To verify freshness: alef verify --exit-code
# Issues & docs: https://github.com/kreuzberg-dev/alef

# Resolve fixture paths against the repo's `test_documents/` directory.
# testthat sources setup-*.R with the working directory at tests/,
# so test_documents lives three directories up: tests/ -> e2e/r/ -> e2e/ -> repo root.
# Each `test_that()` block has its working directory reset back to tests/, so
# fixture lookups must be performed via this helper rather than relying on `setwd`.
.alef_test_documents <- normalizePath("../../../test_documents", mustWork = FALSE)
.resolve_fixture <- function(path) {
  if (dir.exists(.alef_test_documents)) {
    file.path(.alef_test_documents, path)
  } else {
    path
  }
}

.alef_format_value <- function(x) {
  if (is.list(x)) {
    for (variant in names(x)) {
      v <- x[[variant]]
      if (is.list(v) && !is.null(v[["format"]]) && is.character(v[["format"]])) {
        return(v[["format"]])
      }
    }
    if (!is.null(x[["format"]]) && is.character(x[["format"]])) {
      return(x[["format"]])
    }
    if (!is.null(x[["format_type"]])) {
      return(x[["format_type"]])
    }
  }
  x
}
