<commit_before>
class profile.signIn extends Apollos.Component

  @register "profile.signIn"
  @card "Apollos.profile.onBoard"

  url: -> "sign-in"

  vars: -> [

    hasAccount: true
    hasErrors: false
    showForgotPassword: false

  ]

  email: -> @.parent()?.email

  events: -> [

    "click [data-form]": @.toggleForm

    # remove showing password if they have retyped it
    "blur input[name=password]": (event) ->
      @.showForgotPassword.set false

    # on the fly email validation to determine if they have an account
    "blur input[name=email]": @.validateEmail

    # signin form handler
    "submit #signin": @.signin

    "submit #signup": @.signup

  ]


  onRendered: ->

    # bind email field changes to update parent if valid
    self = @

    showRegister = Apollos.Router.getQueryParam("register") is "true"

    if showRegister
      self.hasAccount.set false

    self.autorun ->
      children = {}
      for child in self.children()
        data = child.data()
        if not data.name
          continue

        children[data.name] = child

      email = children["email"].getValue()
      parent = self.parent()

      if email
        parent.email.set email



  toggleForm: (event) ->

    self = @

    if event.target.dataset?.form is "signin"
      self.hasAccount.set true

    if event.target.dataset?.form is "signup"
      self.hasAccount.set false
<commit_msg>ability to pass register as component data<commit_after>
class profile.signIn extends Apollos.Component

  @register "profile.signIn"
  @card "Apollos.profile.onBoard"

  url: -> "sign-in"

  vars: -> [

    hasAccount: true
    hasErrors: false
    showForgotPassword: false

  ]

  email: -> @.parent()?.email

  events: -> [

    "click [data-form]": @.toggleForm

    # remove showing password if they have retyped it
    "blur input[name=password]": (event) ->
      @.showForgotPassword.set false

    # on the fly email validation to determine if they have an account
    "blur input[name=email]": @.validateEmail

    # signin form handler
    "submit #signin": @.signin

    "submit #signup": @.signup

  ]


  onRendered: ->

    # bind email field changes to update parent if valid
    self = @

    showRegister = Apollos.Router.getQueryParam("register") is "true" or self.data().register is true

    if showRegister
      self.hasAccount.set false

    self.autorun ->
      children = {}
      for child in self.children()
        data = child.data()
        if not data.name
          continue

        children[data.name] = child

      email = children["email"].getValue()
      parent = self.parent()

      if email
        parent.email.set email



  toggleForm: (event) ->

    self = @

    if event.target.dataset?.form is "signin"
      self.hasAccount.set true

    if event.target.dataset?.form is "signup"
      self.hasAccount.set false

{'fraction_non_alphanumeric': 0.11145942180424939, 'fraction_numerical': 0.0, 'mean_word_length': 2.4477791116446577, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 19, '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': '1220645', 'n_tokens_mistral': 915, 'n_tokens_neox': 852, 'n_words': 244}