<commit_before>/** @jsx hJSX */

import {Rx} from '@cycle/core';
import {hJSX} from '@cycle/dom'; // eslint-disable-line
import combineClassNames from "util-combine-class-names";

const DIALOGUE_NAME = `atom-AutogrowTextarea`;

function intent(DOM, optNamespace) {
  const namespace = optNamespace ? `.${optNamespace}` : ``;

  return {
    value$: DOM.select(`TEXTAREA${namespace}`).events(`input`)
      .map(e => e.target.value)
      .startWith(``),
  };
}

function model(props$, actions) {
  return Rx.Observable.combineLatest(
    props$,
    actions.value$,
    (props, value) => {
      let {maxRows, rows} = props;

      maxRows = maxRows || 0;
      rows = rows || 1;

      const tokens = value.replace(/&/gm, `&amp;`)
        .replace(/"/gm, `&quot;`)
        .replace(/'/gm, `&#39;`)
        .replace(/</gm, `&lt;`)
        .replace(/>/gm, `&gt;`)
        .split(`\n`);

      let adjustedTokens;

      if (maxRows > 0 && tokens.length > maxRows) {
        adjustedTokens = tokens.slice(0, maxRows);
      } else {
        adjustedTokens = tokens.slice(0);
      }

      while (rows > 0 && adjustedTokens.length < rows) {
        adjustedTokens.push(``);
      }<commit_msg>bug: autogrow not working when dialogue is nested<commit_after>/** @jsx hJSX */

import {Rx} from '@cycle/core';
import {hJSX} from '@cycle/dom'; // eslint-disable-line
import combineClassNames from "util-combine-class-names";

const DIALOGUE_NAME = `atom-AutogrowTextarea`;

function intent(DOM, optNamespace) {
  const namespace = optNamespace ? `.${optNamespace}` : ``;

  const selector = `TEXTAREA${namespace}`;

  return {
    value$: Rx.Observable.merge(
      DOM.select(selector).observable
        .filter(elements => elements.length > 0)
        .map(elements => elements[0].value)
        .take(1)
        .startWith(``),
       DOM.select(selector).events(`input`)
        .map(e => e.target.value)
        .startWith(``)
    ),
  };
}

function model(props$, actions) {
  return Rx.Observable.combineLatest(
    props$,
    actions.value$,
    (props, value) => {
      let {maxRows, rows} = props;

      maxRows = maxRows || 0;
      rows = rows || 1;

      const tokens = value.replace(/&/gm, `&amp;`)
        .replace(/"/gm, `&quot;`)
        .replace(/'/gm, `&#39;`)
        .replace(/</gm, `&lt;`)
        .replace(/>/gm, `&gt;`)
        .split(`\n`);

      let adjustedTokens;

      if (maxRows > 0 && tokens.length > maxRows) {
        adjustedTokens = tokens.slice(0, maxRows);
      } else {
        adjustedTokens = tokens.slice(0);
      }

      while (rows > 0 && adjustedTokens.length < rows) {
        adjustedTokens.push(``);
      }
{'fraction_non_alphanumeric': 0.17870579382994733, 'fraction_numerical': 0.0071482317531978935, 'mean_word_length': 2.5312084993359893, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 18, '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': '2727241', 'n_tokens_mistral': 912, 'n_tokens_neox': 890, 'n_words': 185}