<commit_before>import * as h from '../../helper';
import { header as headerWidget, backButton } from '../../shared/common';
import layout from '../../layout';
import i18n from '../../../i18n';
import { ComposeAttrs, ComposeState } from '../interfaces';

export default function view(vnode: Mithril.Vnode<ComposeAttrs>) {
  const ctrl = vnode.state as ComposeState;
  const headerCtrl = () => headerWidget(null,
    backButton(i18n('composeMessage'))
  );
  const bodyCtrl = () => composeBody(ctrl);
  return layout.free(headerCtrl, bodyCtrl, undefined, undefined);
}

function composeBody(ctrl: ComposeState) {
  console.log(ctrl.errors());
  return (
    <div className="composeWrapper">
      <form id="composeForm"
      onsubmit={function(e: Event) {
        e.preventDefault();
        return ctrl.send(e.target as HTMLFormElement);
      }}>
        {ctrl.id() ? recipientWithName(ctrl) : recipientWithoutName()}
        {(ctrl.errors() && ctrl.errors().username) ? renderError('recipientError', ctrl.errors().username[0]) : null}
        <input id="subject" key="subject" type="text" className="composeInput"
        placeholder={i18n('subject')}
        oncreate={ctrl.id() ? h.autofocus : null}
        />
        {(ctrl.errors() && ctrl.errors().subject) ? renderError('subjectError', ctrl.errors().subject[0]) : null}
        <textarea id="body" key="body" className="composeInput" />
        {(ctrl.errors() && ctrl.errors().text) ? renderError('textError', ctrl.errors().text[0]) : null}
        <button key="send" className="fatButton composeSend" type="submit">
          <span className="fa fa-check" />
          {i18n('send')}
        </button>
      </form>
    </div>
  );
}

function recipientWithName(ctrl: ComposeState) {
  return (<commit_msg>Remove residual console.log<commit_after>import * as h from '../../helper';
import { header as headerWidget, backButton } from '../../shared/common';
import layout from '../../layout';
import i18n from '../../../i18n';
import { ComposeAttrs, ComposeState } from '../interfaces';

export default function view(vnode: Mithril.Vnode<ComposeAttrs>) {
  const ctrl = vnode.state as ComposeState;
  const headerCtrl = () => headerWidget(null,
    backButton(i18n('composeMessage'))
  );
  const bodyCtrl = () => composeBody(ctrl);
  return layout.free(headerCtrl, bodyCtrl, undefined, undefined);
}

function composeBody(ctrl: ComposeState) {
  return (
    <div className="composeWrapper">
      <form id="composeForm"
      onsubmit={function(e: Event) {
        e.preventDefault();
        return ctrl.send(e.target as HTMLFormElement);
      }}>
        {ctrl.id() ? recipientWithName(ctrl) : recipientWithoutName()}
        {(ctrl.errors() && ctrl.errors().username) ? renderError('recipientError', ctrl.errors().username[0]) : null}
        <input id="subject" key="subject" type="text" className="composeInput"
        placeholder={i18n('subject')}
        oncreate={ctrl.id() ? h.autofocus : null}
        />
        {(ctrl.errors() && ctrl.errors().subject) ? renderError('subjectError', ctrl.errors().subject[0]) : null}
        <textarea id="body" key="body" className="composeInput" />
        {(ctrl.errors() && ctrl.errors().text) ? renderError('textError', ctrl.errors().text[0]) : null}
        <button key="send" className="fatButton composeSend" type="submit">
          <span className="fa fa-check" />
          {i18n('send')}
        </button>
      </form>
    </div>
  );
}

function recipientWithName(ctrl: ComposeState) {
  return (
{'fraction_non_alphanumeric': 0.1739624786810688, 'fraction_numerical': 0.007390562819783968, 'mean_word_length': 3.4828025477707008, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, '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': '7479497', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1045, 'n_words': 221}