query getWebsiteInterface($language_code: String) {
  websiteInterfaces(
    filters: { ui_language: { code: { eq: $language_code } } }
  ) {
    data {
      attributes {
        library
        contents
        wiki
        chronicles
        library_short_description
        contents_short_description
        wiki_short_description
        chronicles_short_description
        news
        merch
        gallery
        archives
        about_us
        licensing_notice
        copyright_notice
        contents_description
        type
        category
        categories
        size
        release_date
        release_year
        details
        price
        width
        height
        thickness
        subitem
        subitems
        subitem_of
        variant
        variants
        variant_of
        summary
        audio
        video
        textual
        game
        other
        return_to
        left_to_right
        right_to_left
        page
        pages
        page_order
        binding
        type_information
        front_matter
        back_matter
        open_content
        read_content
        watch_content
        listen_content
        view_scans
        paperback
        hardcover
        languages
        select_language
        language
        library_description
        wiki_description
        chronicles_description
        news_description
        merch_description
        gallery_description
        archives_description
        about_us_description
        page_not_found
        default_description
        name
        show_subitems
        show_primary_items
        show_secondary_items
        no_type
        no_year
        order_by
        group_by
        select_option_sidebar
        group
        settings
        theme
        light
        auto
        dark
        font_size
        player_name
        currency
        font
        calculated
        status_incomplete
        status_draft
        status_review
        status_done
        incomplete
        draft
        review
        done
        status
        transcribers
        translators
        proofreaders
        transcript_notice
        translation_notice
        source_language
        pronouns
      }
    }
  }
}

query getEras($language_code: String) {
  chronologyEras(sort: "starting_year") {
    data {
      id
      attributes {
        slug
        starting_year
        ending_year
        title(filters: { language: { code: { eq: $language_code } } }) {
          title
          description
        }
      }
    }
  }
}

query getChronologyItems($language_code: String) {
  chronologyItems(
    pagination: { limit: -1 }
    sort: ["year:asc", "month:asc", "day:asc"]
  ) {
    data {
      id
      attributes {
        year
        month
        day
        displayed_date
        events {
          id
          source {
            data {
              attributes {
                name
              }
            }
          }
          translations(
            filters: { language: { code: { eq: $language_code } } }
          ) {
            title
            description
            note
            status
          }
        }
      }
    }
  }
}

query getLibraryItemsPreview($language_code: String) {
  libraryItems(pagination: { limit: -1 }) {
    data {
      id
      attributes {
        title
        subtitle
        slug
        root_item
        primary
        thumbnail {
          data {
            attributes {
              name
              alternativeText
              caption
              width
              height
              url
            }
          }
        }
        release_date {
          year
          month
          day
        }
        price {
          amount
          currency {
            data {
              attributes {
                symbol
                code
                rate_to_usd
              }
            }
          }
        }
        metadata {
          __typename
          ... on ComponentMetadataBooks {
            subtype {
              data {
                attributes {
                  slug
                  titles(
                    filters: { language: { code: { eq: $language_code } } }
                  ) {
                    title
                  }
                }
              }
            }
          }
          ... on ComponentMetadataGame {
            platforms {
              data {
                id
                attributes {
                  short
                }
              }
            }
          }
          ... on ComponentMetadataVideo {
            subtype {
              data {
                attributes {
                  slug
                  titles(
                    filters: { language: { code: { eq: $language_code } } }
                  ) {
                    title
                  }
                }
              }
            }
          }
          ... on ComponentMetadataAudio {
            subtype {
              data {
                attributes {
                  slug
                  titles(
                    filters: { language: { code: { eq: $language_code } } }
                  ) {
                    title
                  }
                }
              }
            }
          }
          ... on ComponentMetadataGroup {
            subtype {
              data {
                attributes {
                  slug
                  titles(
                    filters: { language: { code: { eq: $language_code } } }
                  ) {
                    title
                  }
                }
              }
            }
            subitems_type {
              data {
                attributes {
                  slug
                  titles(
                    filters: { language: { code: { eq: $language_code } } }
                  ) {
                    title
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

query getLibraryItemsSlugs {
  libraryItems(pagination: { limit: -1 }) {
    data {
      attributes {
        slug
      }
    }
  }
}

query getLibraryItem($slug: String, $language_code: String) {
  libraryItems(filters: { slug: { eq: $slug } }) {
    data {
      id
      attributes {
        title
        subtitle
        slug
        root_item
        primary
        digital
        thumbnail {
          data {
            attributes {
              name
              alternativeText
              caption
              width
              height
              url
            }
          }
        }
        gallery {
          data {
            id
            attributes {
              name
              alternativeText
              caption
              width
              height
              url
            }
          }
        }
        release_date {
          year
          month
          day
        }
        price {
          amount
          currency {
            data {
              attributes {
                symbol
                code
                rate_to_usd
              }
            }
          }
        }
        size {
          width
          height
          thickness
        }
        descriptions(filters: { language: { code: { eq: $language_code } } }) {
          description
        }
        metadata {
          __typename
          ... on ComponentMetadataBooks {
            subtype {
              data {
                attributes {
                  slug
                  titles(
                    filters: { language: { code: { eq: $language_code } } }
                  ) {
                    title
                  }
                }
              }
            }
            binding_type
            page_count
            page_order
            languages {
              data {
                attributes {
                  code
                  name
                }
              }
            }
          }
          ... on ComponentMetadataVideo {
            subtype {
              data {
                attributes {
                  titles(
                    filters: { language: { code: { eq: $language_code } } }
                  ) {
                    title
                  }
                }
              }
            }
          }
          ... on ComponentMetadataGame {
            platforms {
              data {
                id
                attributes {
                  short
                }
              }
            }
            audio_languages {
              data {
                attributes {
                  code
                  name
                }
              }
            }
            sub_languages {
              data {
                attributes {
                  code
                  name
                }
              }
            }
            interface_languages {
              data {
                attributes {
                  code
                  name
                }
              }
            }
          }
          ... on ComponentMetadataAudio {
            subtype {
              data {
                attributes {
                  slug
                  titles(
                    filters: { language: { code: { eq: $language_code } } }
                  ) {
                    title
                  }
                }
              }
            }
          }
          ... on ComponentMetadataGroup {
            subtype {
              data {
                attributes {
                  slug
                  titles(
                    filters: { language: { code: { eq: $language_code } } }
                  ) {
                    title
                  }
                }
              }
            }
            subitems_type {
              data {
                attributes {
                  slug
                  titles(
                    filters: { language: { code: { eq: $language_code } } }
                  ) {
                    title
                  }
                }
              }
            }
          }
        }
        subitem_of {
          data {
            id
            attributes {
              title
              subtitle
              slug
            }
          }
        }
        subitems {
          data {
            id
            attributes {
              title
              subtitle
              slug
              thumbnail {
                data {
                  attributes {
                    name
                    alternativeText
                    caption
                    width
                    height
                    url
                  }
                }
              }
              release_date {
                year
                month
                day
              }
              price {
                amount
                currency {
                  data {
                    attributes {
                      symbol
                      code
                      rate_to_usd
                    }
                  }
                }
              }
              metadata {
                __typename
                ... on ComponentMetadataBooks {
                  subtype {
                    data {
                      attributes {
                        slug
                        titles(
                          filters: {
                            language: { code: { eq: $language_code } }
                          }
                        ) {
                          title
                        }
                      }
                    }
                  }
                }
                ... on ComponentMetadataGame {
                  platforms {
                    data {
                      id
                      attributes {
                        short
                      }
                    }
                  }
                }
                ... on ComponentMetadataVideo {
                  subtype {
                    data {
                      attributes {
                        slug
                        titles(
                          filters: {
                            language: { code: { eq: $language_code } }
                          }
                        ) {
                          title
                        }
                      }
                    }
                  }
                }
                ... on ComponentMetadataAudio {
                  subtype {
                    data {
                      attributes {
                        slug
                        titles(
                          filters: {
                            language: { code: { eq: $language_code } }
                          }
                        ) {
                          title
                        }
                      }
                    }
                  }
                }
                ... on ComponentMetadataGroup {
                  subtype {
                    data {
                      attributes {
                        slug
                        titles(
                          filters: {
                            language: { code: { eq: $language_code } }
                          }
                        ) {
                          title
                        }
                      }
                    }
                  }
                  subitems_type {
                    data {
                      attributes {
                        slug
                        titles(
                          filters: {
                            language: { code: { eq: $language_code } }
                          }
                        ) {
                          title
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
        submerchs {
          data {
            id
            attributes {
              slug
              title
              subtitle
              thumbnail {
                data {
                  attributes {
                    name
                    alternativeText
                    caption
                    width
                    height
                    url
                  }
                }
              }
            }
          }
        }
        contents(pagination: { limit: -1 }) {
          data {
            id
            attributes {
              slug
              range {
                __typename
                ... on ComponentRangePageRange {
                  starting_page
                  ending_page
                }
                ... on ComponentRangeTimeRange {
                  starting_time
                  ending_time
                }
              }
              scan_set {
                id
              }
              content {
                data {
                  attributes {
                    slug
                    categories {
                      data {
                        id
                        attributes {
                          short
                        }
                      }
                    }
                    type {
                      data {
                        attributes {
                          slug
                          titles(
                            filters: {
                              language: { code: { eq: $language_code } }
                            }
                          ) {
                            title
                          }
                        }
                      }
                    }
                    titles(
                      filters: { language: { code: { eq: $language_code } } }
                    ) {
                      pre_title
                      title
                      subtitle
                    }
                    text_set {
                      id
                    }
                    video_set {
                      id
                    }
                    audio_set {
                      id
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

query getContentsSlugs {
  contents(pagination: { limit: -1 }) {
    data {
      attributes {
        slug
      }
    }
  }
}

query getContents($language_code: String) {
  contents(pagination: { limit: -1 }) {
    data {
      id
      attributes {
        slug
        titles(filters: { language: { code: { eq: $language_code } } }) {
          pre_title
          title
          subtitle
        }
        categories {
          data {
            id
            attributes {
              short
            }
          }
        }
        type {
          data {
            attributes {
              slug
              titles(filters: { language: { code: { eq: $language_code } } }) {
                title
              }
            }
          }
        }
        ranged_contents {
          data {
            id
            attributes {
              slug
              scan_set {
                id
              }
              library_item {
                data {
                  attributes {
                    slug
                    title
                    subtitle
                    thumbnail {
                      data {
                        attributes {
                          name
                          alternativeText
                          caption
                          width
                          height
                          url
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
        text_set {
          id
        }
        video_set {
          id
        }
        audio_set {
          id
        }
        thumbnail {
          data {
            attributes {
              name
              alternativeText
              caption
              width
              height
              url
            }
          }
        }
      }
    }
  }
}

query getContent($slug: String, $language_code: String) {
  contents(filters: { slug: { eq: $slug } }) {
    data {
      attributes {
        slug
        titles(filters: { language: { code: { eq: $language_code } } }) {
          pre_title
          title
          subtitle
          description
        }
        categories {
          data {
            id
            attributes {
              name
              short
            }
          }
        }
        type {
          data {
            attributes {
              slug
              titles(filters: { language: { code: { eq: $language_code } } }) {
                title
              }
            }
          }
        }
        ranged_contents {
          data {
            id
            attributes {
              slug
              scan_set {
                id
              }
              library_item {
                data {
                  attributes {
                    slug
                    title
                    subtitle
                    thumbnail {
                      data {
                        attributes {
                          name
                          alternativeText
                          caption
                          width
                          height
                          url
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
        text_set {
          id
        }
        video_set {
          id
        }
        audio_set {
          id
        }
        thumbnail {
          data {
            attributes {
              name
              alternativeText
              caption
              width
              height
              url
            }
          }
        }
      }
    }
  }
}

query getContentText($slug: String, $language_code: String) {
  contents(filters: { slug: { eq: $slug } }) {
    data {
      id
      attributes {
        slug
        titles(filters: { language: { code: { eq: $language_code } } }) {
          pre_title
          title
          subtitle
          description
        }
        categories {
          data {
            id
            attributes {
              name
              short
            }
          }
        }
        type {
          data {
            attributes {
              slug
              titles(filters: { language: { code: { eq: $language_code } } }) {
                title
              }
            }
          }
        }
        ranged_contents {
          data {
            id
            attributes {
              slug
              scan_set {
                id
              }
              library_item {
                data {
                  attributes {
                    slug
                    title
                    subtitle
                    thumbnail {
                      data {
                        attributes {
                          name
                          alternativeText
                          caption
                          width
                          height
                          url
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
        text_set(filters: { language: { code: { eq: $language_code } } }) {
          status
          text
          source_language {
            data {
              attributes {
                code
              }
            }
          }
          transcribers {
            data {
              id
              attributes {
                username
                anonymize
                anonymous_code
                pronouns
                bio(filters: { language: { code: { eq: $language_code } } }) {
                  bio
                }
                languages {
                  data {
                    attributes {
                      code
                    }
                  }
                }
                avatar {
                  data {
                    attributes {
                      name
                      alternativeText
                      caption
                      width
                      height
                      url
                    }
                  }
                }
              }
            }
          }
          translators {
            data {
              id
              attributes {
                username
                anonymize
                anonymous_code
                pronouns
                bio(filters: { language: { code: { eq: $language_code } } }) {
                  bio
                }
                languages {
                  data {
                    attributes {
                      code
                    }
                  }
                }
                avatar {
                  data {
                    attributes {
                      name
                      alternativeText
                      caption
                      width
                      height
                      url
                    }
                  }
                }
              }
            }
          }
          proofreaders {
            data {
              id
              attributes {
                username
                anonymize
                anonymous_code
                pronouns
                bio(filters: { language: { code: { eq: $language_code } } }) {
                  bio
                }
                languages {
                  data {
                    attributes {
                      code
                    }
                  }
                }
                avatar {
                  data {
                    attributes {
                      name
                      alternativeText
                      caption
                      width
                      height
                      url
                    }
                  }
                }
              }
            }
          }
          notes
        }
        thumbnail {
          data {
            attributes {
              name
              alternativeText
              caption
              width
              height
              url
            }
          }
        }
      }
    }
  }
}

query getCurrencies {
  currencies {
    data {
      id
      attributes {
        code
        symbol
        rate_to_usd
        display_decimals
      }
    }
  }
}

query getLanguages {
  languages {
    data {
      id
      attributes {
        name
        code
        localized_name
      }
    }
  }
}