<commit_before>import Ember from 'ember';
import FocusableInput from '../focusable-input/component';

export var maxChars = 64;

function replaceWithLower(match){
  return match.toLowerCase();
}

function truncate(input){
  return input.slice(0, maxChars);
}

let capitalLetters = /[A-Z]/g;
let spaces = /\s+/g;
let nonAlphaNumerics = /[^0-9a-z._-]/g;

function sanitizeInput(input){
  if (typeof input !== 'string') { return input; }

  return truncate(input, maxChars).
         replace(capitalLetters, replaceWithLower).
         replace(spaces, '-').
         replace(nonAlphaNumerics, '');
}

export default FocusableInput.extend({
  _sanitizedValue: null,
  value: Ember.computed({
    get() {
      return this._sanitizedValue;
    },
    set(key, value) {
      this._sanitizedValue = sanitizeInput(value);
      return this._sanitizedValue;
    }
  })
});<commit_msg>Ensure upstream bound values are updated via two-way bindings.<commit_after>import Ember from 'ember';
import FocusableInput from '../focusable-input/component';

export var maxChars = 64;

function replaceWithLower(match){
  return match.toLowerCase();
}

function truncate(input){
  return input.slice(0, maxChars);
}

let capitalLetters = /[A-Z]/g;
let spaces = /\s+/g;
let nonAlphaNumerics = /[^0-9a-z._-]/g;

function sanitizeInput(input){
  if (typeof input !== 'string') { return input; }

  return truncate(input, maxChars).
         replace(capitalLetters, replaceWithLower).
         replace(spaces, '-').
         replace(nonAlphaNumerics, '');
}

export default FocusableInput.extend({
  _sanitizedValue: null,
  value: Ember.computed({
    get() {
      return this._sanitizedValue;
    },
    set(key, value) {
      this._sanitizedValue = sanitizeInput(value);

      this.attrs.value.update(this._sanitizedValue);

      return this._sanitizedValue;
    }
  })
});
{'fraction_non_alphanumeric': 0.13954741379310345, 'fraction_numerical': 0.005387931034482759, 'mean_word_length': 3.6194029850746268, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3299243', 'n_tokens_mistral': 619, 'n_tokens_neox': 593, 'n_words': 131}