<commit_before>import * as xhr from 'common/xhr';

import { expandMentions } from 'common/richText';

lichess.load.then(() => {
  const noteStore = lichess.storage.make('inquiry-note');
  const usernameNoteStore = lichess.storage.make('inquiry-note-user');
  const username = $('#inquiry .meat > .user-link').text().split(' ')[0];
  if (username != usernameNoteStore.get()) noteStore.remove();
  usernameNoteStore.set(username);
  const noteTextArea = $('#inquiry .notes').find('textarea')[0] as HTMLTextAreaElement;

  $('#inquiry .notes').on('mouseenter', () => {
    noteTextArea.focus();
    noteTextArea.value = noteStore.get() || '';
  });

  const loadNotes = () => {
    const $notes = $('#inquiry .notes');
    $notes.on('input', () => setTimeout(() => noteStore.set(noteTextArea.value), 50));
    $notes.find('form').on('submit', function (this: HTMLFormElement) {
      xhr
        .formToXhr(this)
        .then(html => $notes.replaceWith(html))
        .then(noteStore.remove)
        .then(() => loadNotes())
        .catch(() => alert('Invalid note, is it too short or too long?'));
      return false;
    });
  };
  loadNotes();

  $('#inquiry .costello').on('click', () => {
    $('#inquiry').toggleClass('hidden');
    $('body').toggleClass('no-inquiry');
  });

  const nextStore = lichess.storage.makeBoolean('inquiry-auto-next');

  if (!nextStore.get()) {
    $('#inquiry .switcher input').prop('checked', false);
    $('#inquiry input.auto-next').val('0');
  }

  $('#inquiry .switcher input').on('change', function (this: HTMLInputElement) {
    nextStore.set(this.checked);
    $('#inquiry input.auto-next').val(this.checked ? '1' : '0');
  });

  window.Mousetrap.bind('d', () => $('#inquiry .actions.close form.process button[type="submit"]').trigger('click'));

  $('#inquiry .atom p').each(function (this: HTMLParagraphElement) {
    $(this).html(
      expandMentions(
        $(this)
          .html()
          .replace(/(?:https:\/\/)?lichess\.org\/((?:[\w\/:(&;)=@]|[?.]\w)+)/gi, '<a href="/$1">lichess.org/$1</a>')
      )
    );
  });

  $('#communication').on('click', '.line.author, .post.author', function (this: HTMLElement) {<commit_msg>Linkify URLs with dashes in reports<commit_after>import * as xhr from 'common/xhr';

import { expandMentions } from 'common/richText';

lichess.load.then(() => {
  const noteStore = lichess.storage.make('inquiry-note');
  const usernameNoteStore = lichess.storage.make('inquiry-note-user');
  const username = $('#inquiry .meat > .user-link').text().split(' ')[0];
  if (username != usernameNoteStore.get()) noteStore.remove();
  usernameNoteStore.set(username);
  const noteTextArea = $('#inquiry .notes').find('textarea')[0] as HTMLTextAreaElement;

  $('#inquiry .notes').on('mouseenter', () => {
    noteTextArea.focus();
    noteTextArea.value = noteStore.get() || '';
  });

  const loadNotes = () => {
    const $notes = $('#inquiry .notes');
    $notes.on('input', () => setTimeout(() => noteStore.set(noteTextArea.value), 50));
    $notes.find('form').on('submit', function (this: HTMLFormElement) {
      xhr
        .formToXhr(this)
        .then(html => $notes.replaceWith(html))
        .then(noteStore.remove)
        .then(() => loadNotes())
        .catch(() => alert('Invalid note, is it too short or too long?'));
      return false;
    });
  };
  loadNotes();

  $('#inquiry .costello').on('click', () => {
    $('#inquiry').toggleClass('hidden');
    $('body').toggleClass('no-inquiry');
  });

  const nextStore = lichess.storage.makeBoolean('inquiry-auto-next');

  if (!nextStore.get()) {
    $('#inquiry .switcher input').prop('checked', false);
    $('#inquiry input.auto-next').val('0');
  }

  $('#inquiry .switcher input').on('change', function (this: HTMLInputElement) {
    nextStore.set(this.checked);
    $('#inquiry input.auto-next').val(this.checked ? '1' : '0');
  });

  window.Mousetrap.bind('d', () => $('#inquiry .actions.close form.process button[type="submit"]').trigger('click'));

  $('#inquiry .atom p').each(function (this: HTMLParagraphElement) {
    $(this).html(
      expandMentions(
        $(this)
          .html()
          .replace(/(?:https:\/\/)?lichess\.org\/((?:[\w\/:(&;)=@-]|[?.]\w)+)/gi, '<a href="/$1">lichess.org/$1</a>')
      )
    );
  });

  $('#communication').on('click', '.line.author, .post.author', function (this: HTMLElement) {
{'fraction_non_alphanumeric': 0.23213878110020544, 'fraction_numerical': 0.00410865099292399, 'mean_word_length': 3.627243928194298, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 29, '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': '3704364', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1438, 'n_words': 247}