<commit_before><template>
  <div class="search search--main">
    <button 
      v-if="popout"
      class="search__trigger"
      @click="toggleInput"
    />

    <div 
      :class="['search__pane', { 'active': isActive, 'popout': popout }]"
      >
      
      <input 
        v-model="searchTerm"
        type="text"
        class="search__input"
        :placeholder="placeholder" 
        v-on:keyup.enter="submit"
      />

      <i class="search__icon" />

      <button 
        v-show="showClose"
        class="search__close"
        @click="closeInput"
      />
    </div>
  </div>
</template>

<script>
import axios from 'axios'
import mixinAxiosHelpers from '../../mixins/mixin-axios-helpers'

export default {
  name: 'search',

  mixins: [ mixinAxiosHelpers ],

  props: {
    endpoint: {
      type: String,
      required: true
    },
    placeholder: {
      type: String,
      required: true
    },
    popout: {
      type: Boolean,
      default: false
    }
  },

  data () {
    return {
      isActive: true,
      searchTerm: ''
    }
  },

  created () {
    if(this.popout) { this.isActive = false }
  },

  computed: {
    showClose () {
      const hasSearchTerm = this.searchTerm.length != 0

      return this.popout ? true : hasSearchTerm
    }
  },

  methods: {
    toggleInput () { this.isActive = !this.isActive },

    openInput () { this.isActive = true },

    closeInput () { 
      if(this.popout) { this.isActive = false }

      this.searchTerm = ''
    },

    submit () {
      let data = {
        params: {
          search_term: this.searchTerm
        }
      }

      this.axiosSetHeaders()

      axios.post(this.endpoint, data)
      .then(response => {
        console.log(success)
      })
      .catch(function (error) {
        console.log(error)
      })
    }<commit_msg>Fix console log message<commit_after><template>
  <div class="search search--main">
    <button
      v-if="popout"
      class="search__trigger"
      @click="toggleInput"
    />

    <div
      :class="['search__pane', { 'active': isActive, 'popout': popout }]"
      >

      <input
        v-model="searchTerm"
        type="text"
        class="search__input"
        :placeholder="placeholder"
        v-on:keyup.enter="submit"
      />

      <i class="search__icon" />

      <button
        v-show="showClose"
        class="search__close"
        @click="closeInput"
      />
    </div>
  </div>
</template>

<script>
import axios from 'axios'
import mixinAxiosHelpers from '../../mixins/mixin-axios-helpers'

export default {
  name: 'search',

  mixins: [ mixinAxiosHelpers ],

  props: {
    endpoint: {
      type: String,
      required: true
    },
    placeholder: {
      type: String,
      required: true
    },
    popout: {
      type: Boolean,
      default: false
    }
  },

  data () {
    return {
      isActive: true,
      searchTerm: ''
    }
  },

  created () {
    if(this.popout) { this.isActive = false }
  },

  computed: {
    showClose () {
      const hasSearchTerm = this.searchTerm.length != 0

      return this.popout ? true : hasSearchTerm
    }
  },

  methods: {
    toggleInput () { this.isActive = !this.isActive },

    openInput () { this.isActive = true },

    closeInput () {
      if(this.popout) { this.isActive = false }

      this.searchTerm = ''
    },

    submit () {
      let data = {
        params: {
          search_term: this.searchTerm
        }
      }

      this.axiosSetHeaders()

      axios.post(this.endpoint, data)
      .then(response => {
        console.log(response)
      })
      .catch(function (error) {
        console.log(error)
      })
    }
{'fraction_non_alphanumeric': 0.14196014196014195, 'fraction_numerical': 0.000546000546000546, 'mean_word_length': 1.871473354231975, 'pattern_counts': {'":': 0, '<': 25, '<?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': '6635797', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1180, 'n_words': 213}