<commit_before>package views.html.challenge

import lila.api.Context
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import lila.challenge.Challenge
import lila.challenge.Challenge.Status

import controllers.routes

object theirs {

  def apply(
      c: Challenge,
      json: play.api.libs.json.JsObject,
      user: Option[lila.user.User],
      color: Option[chess.Color]
  )(implicit ctx: Context) =
    views.html.base.layout(
      title = challengeTitle(c),
      openGraph = challengeOpenGraph(c).some,
      moreJs = bits.js(c, json, owner = false, color),
      moreCss = cssTag("challenge.page")
    ) {
      main(cls := "page-small challenge-page challenge-theirs box box-pad")(
        c.status match {
          case Status.Created | Status.Offline =>
            frag(
              h1(
                if (c.isOpen) c.name | "Open Challenge"
                else
                  user.fold[Frag]("Anonymous")(u =>
                    frag(
                      userLink(u),
                      " (",
                      u.perfs(c.perfType).glicko.display,
                      ")"
                    )
                  )
              ),
              bits.details(c),
              c.notableInitialFen.map { fen =>
                div(cls := "board-preview", views.html.board.bits.mini(fen, !c.finalColor)(div))
              },
              if (color.map(Challenge.ColorChoice.apply).has(c.colorChoice))
                badTag(
                  // very rare message, don't translate
                  s"You have the wrong color link for this open challenge. The ${color.??(_.name)} player has already joined."
                )
              else if (!c.mode.rated || ctx.isAuth) {
                frag(
                  (c.mode.rated && c.unlimited) option
                    badTag(trans.bewareTheGameIsRatedButHasNoClock()),
                  postForm(cls := "accept", action := routes.Challenge.accept(c.id, color.map(_.name)))(
                    submitButton(cls := "text button button-fat", dataIcon := "G")(trans.joinTheGame())
                  )
                )
              } else
                frag(
                  hr,
                  badTag(
                    p("This game is rated"),
                    p(
                      "You must ",
                      a(
                        cls := "button",
                        href := s"${routes.Auth.login}?referrer=${routes.Round.watcher(c.id, "white")}"
                      )(trans.signIn()),
                      " to join it."
                    )
                  )
                )
            )
          case Status.Declined =>
            div(cls := "follow-up")(
              h1(trans.challenge.challengeDeclined()),
              bits.details(c),
              a(cls := "button button-fat", href := routes.Lobby.home)(trans.newOpponent())
            )
          case Status.Accepted =><commit_msg>Translate challenge error message (#8835)<commit_after>package views.html.challenge

import lila.api.Context
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import lila.challenge.Challenge
import lila.challenge.Challenge.Status

import controllers.routes

object theirs {

  def apply(
      c: Challenge,
      json: play.api.libs.json.JsObject,
      user: Option[lila.user.User],
      color: Option[chess.Color]
  )(implicit ctx: Context) =
    views.html.base.layout(
      title = challengeTitle(c),
      openGraph = challengeOpenGraph(c).some,
      moreJs = bits.js(c, json, owner = false, color),
      moreCss = cssTag("challenge.page")
    ) {
      main(cls := "page-small challenge-page challenge-theirs box box-pad")(
        c.status match {
          case Status.Created | Status.Offline =>
            frag(
              h1(
                if (c.isOpen) c.name | "Open Challenge"
                else
                  user.fold[Frag]("Anonymous")(u =>
                    frag(
                      userLink(u),
                      " (",
                      u.perfs(c.perfType).glicko.display,
                      ")"
                    )
                  )
              ),
              bits.details(c),
              c.notableInitialFen.map { fen =>
                div(cls := "board-preview", views.html.board.bits.mini(fen, !c.finalColor)(div))
              },
              if (color.map(Challenge.ColorChoice.apply).has(c.colorChoice))
                badTag(
                  // very rare message, don't translate
                  s"You have the wrong color link for this open challenge. The ${color.??(_.name)} player has already joined."
                )
              else if (!c.mode.rated || ctx.isAuth) {
                frag(
                  (c.mode.rated && c.unlimited) option
                    badTag(trans.bewareTheGameIsRatedButHasNoClock()),
                  postForm(cls := "accept", action := routes.Challenge.accept(c.id, color.map(_.name)))(
                    submitButton(cls := "text button button-fat", dataIcon := "G")(trans.joinTheGame())
                  )
                )
              } else
                frag(
                  hr,
                  badTag(
                    p(trans.thisGameIsRated()),
                    a(
                      cls := "button",
                      href := s"${routes.Auth.login}?referrer=${routes.Round.watcher(c.id, "white")}"
                    )(trans.signIn())
                  )
                )
            )
          case Status.Declined =>
            div(cls := "follow-up")(
              h1(trans.challenge.challengeDeclined()),
              bits.details(c),
              a(cls := "button button-fat", href := routes.Lobby.home)(trans.newOpponent())
            )
          case Status.Accepted =>
{'fraction_non_alphanumeric': 0.12086404937424995, 'fraction_numerical': 0.0013715069432539003, 'mean_word_length': 1.3439132181599036, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2624674', 'n_tokens_mistral': 1665, 'n_tokens_neox': 1542, 'n_words': 295}