<commit_before>/* eslint-disable no-unused-vars */
import { search } from './search';

let NO_DATA_TEXT = '';
let options;

function style() {
  const code = `
.sidebar {
  padding-top: 0;
}

.search {
  margin-bottom: 20px;
  padding: 6px;
  border-bottom: 1px solid #eee;
}

.search .input-wrap {
  display: flex;
  align-items: center;
}

.search .results-panel {
  display: none;
}

.search .results-panel.show {
  display: block;
}

.search input {
  outline: none;
  border: none;
  width: 100%;
  padding: 0 7px;
  line-height: 36px;
  font-size: 14px;
  border: 1px solid transparent;
}

.search input:focus {
  box-shadow: 0 0 5px var(--theme-color, #42b983);
  border: 1px solid var(--theme-color, #42b983);
}

.search input::-webkit-search-decoration,
.search input::-webkit-search-cancel-button,
.search input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
.search .clear-button {
  width: 36px;
  text-align: right;
  display: none;
}

.search .clear-button.show {
  display: block;
}

.search .clear-button svg {
  transform: scale(.5);
}

.search h2 {
  font-size: 17px;
  margin: 10px 0;
}

.search a {
  text-decoration: none;
  color: inherit;
}

.search .matching-post {
  border-bottom: 1px solid #eee;
}

.search .matching-post:last-child {
  border-bottom: 0;
}

.search p {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search p.empty {
  text-align: center;
}

.app-name.hide, .sidebar-nav.hide {
  display: none;
}`;

  Docsify.dom.style(code);
}

function tpl(defaultValue = '') {
  const html = `<div class="input-wrap">
      <input type="search" value="${defaultValue}" aria-label="Search text" />
      <div class="clear-button">
        <svg width="26" height="24">
          <circle cx="12" cy="12" r="11" fill="#ccc" />
          <path stroke="white" stroke-width="2" d="M8.25,8.25,15.75,15.75" />
          <path stroke="white" stroke-width="2"d="M8.25,15.75,15.75,8.25" />
        </svg>
      </div>
    </div>
    <div class="results-panel"></div>
    </div>`;
  const el = Docsify.dom.create('div', html);
  const aside = Docsify.dom.find('aside');

  Docsify.dom.toggleClass(el, 'search');
  Docsify.dom.before(aside, el);
}

function doSearch(value) {
  const $search = Docsify.dom.find('div.search');
  const $panel = Docsify.dom.find($search, '.results-panel');
  const $clearBtn = Docsify.dom.find($search, '.clear-button');
  const $sidebarNav = Docsify.dom.find('.sidebar-nav');
  const $appName = Docsify.dom.find('.app-name');

  if (!value) {
    $panel.classList.remove('show');
    $clearBtn.classList.remove('show');
    $panel.innerHTML = '';

    if (options.hideOtherSidebarContent) {
      $sidebarNav.classList.remove('hide');
      $appName.classList.remove('hide');
    }

    return;
  }

  const matchs = search(value);

  let html = '';
  matchs.forEach(post => {
    html += `<div class="matching-post">
<a href="${post.url}">
<h2>${post.title}</h2>
<p>${post.content}</p>
</a>
</div>`;
  });

  $panel.classList.add('show');
  $clearBtn.classList.add('show');
  $panel.innerHTML = html || `<p class="empty">${NO_DATA_TEXT}</p>`;
  if (options.hideOtherSidebarContent) {
    $sidebarNav.classList.add('hide');
    $appName.classList.add('hide');
  }
}

function bindEvents() {
  const $search = Docsify.dom.find('div.search');
  const $input = Docsify.dom.find($search, 'input');
  const $inputWrap = Docsify.dom.find($search, '.input-wrap');

  let timeId;
  // Prevent to Fold sidebar
  Docsify.dom.on($input, 'input', e => {<commit_msg>Update component.js<commit_after>/* eslint-disable no-unused-vars */
import { search } from './search';

let NO_DATA_TEXT = '';
let options;

function style() {
  const code = `
.sidebar {
  padding-top: 0;
}

.search {
  margin-bottom: 20px;
  padding: 6px;
  border-bottom: 1px solid #eee;
}

.search .input-wrap {
  display: flex;
  align-items: center;
}

.search .results-panel {
  display: none;
}

.search .results-panel.show {
  display: block;
}

.search input {
  outline: none;
  border: none;
  width: 100%;
  padding: 0 7px;
  line-height: 36px;
  font-size: 14px;
  border: 1px solid transparent;
}

.search input:focus {
  box-shadow: 0 0 5px var(--theme-color, #42b983);
  border: 1px solid var(--theme-color, #42b983);
}

.search input::-webkit-search-decoration,
.search input::-webkit-search-cancel-button,
.search input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
.search .clear-button {
  width: 36px;
  text-align: right;
  display: none;
}

.search .clear-button.show {
  display: block;
}

.search .clear-button svg {
  transform: scale(.5);
}

.search h2 {
  font-size: 17px;
  margin: 10px 0;
}

.search a {
  text-decoration: none;
  color: inherit;
}

.search .matching-post {
  border-bottom: 1px solid #eee;
}

.search .matching-post:last-child {
  border-bottom: 0;
}

.search p {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search p.empty {
  text-align: center;
}

.app-name.hide, .sidebar-nav.hide {
  display: none;
}`;

  Docsify.dom.style(code);
}

function tpl(defaultValue = '') {
  const html = `<div class="input-wrap">
      <input type="search" value="${defaultValue}" aria-label="Search text" />
      <div class="clear-button">
        <svg width="26" height="24">
          <circle cx="12" cy="12" r="11" fill="#ccc" />
          <path stroke="white" stroke-width="2" d="M8.25,8.25,15.75,15.75" />
          <path stroke="white" stroke-width="2"d="M8.25,15.75,15.75,8.25" />
        </svg>
      </div>
    </div>
    <div class="results-panel"></div>
    </div>`;
  const el = Docsify.dom.create('div', html);
  const aside = Docsify.dom.find('aside');

  Docsify.dom.toggleClass(el, 'search');
  Docsify.dom.before(aside, el);
}

function doSearch(value) {
  const $search = Docsify.dom.find('div.search');
  const $panel = Docsify.dom.find($search, '.results-panel');
  const $clearBtn = Docsify.dom.find($search, '.clear-button');
  const $sidebarNav = Docsify.dom.find('.sidebar-nav');
  const $appName = Docsify.dom.find('.app-name');

  if (!value) {
    $panel.classList.remove('show');
    $clearBtn.classList.remove('show');
    $panel.innerHTML = '';

    if (options.hideOtherSidebarContent) {
      $sidebarNav.classList.remove('hide');
      $appName.classList.remove('hide');
    }

    return;
  }

  const matchs = search(value);

  let html = '';
  matchs.forEach(post => {
    html += `<div class="matching-post">
<a href="${post.url}">
<h2>${post.title}</h2>
<p>${post.content}</p>
</a>
</div>`;
  });

  $panel.classList.add('show');
  $clearBtn.classList.add('show');
  $panel.innerHTML = html || `<p class="empty">${NO_DATA_TEXT}</p>`;
  if (options.hideOtherSidebarContent) {
    $sidebarNav.classList.add('hide');
    $appName.classList.add('hide');
  }
}

function bindEvents() {
  const $search = Docsify.dom.find('div.search');
  const $input = Docsify.dom.find($search, 'input');
  const $inputWrap = Docsify.dom.find($search, '.input-wrap');

  let timeId;
  // Prevent to Fold sidebar
  Docsify.dom.on(
    $search,
    'click',
    e => e.target.tagName !== 'A' && e.stopPropagation()
  );
  Docsify.dom.on($input, 'input', e => {
{'fraction_non_alphanumeric': 0.1902762730227519, 'fraction_numerical': 0.023022751895991334, 'mean_word_length': 3.3415637860082303, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 54, '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': '1187443', 'n_tokens_mistral': 2906, 'n_tokens_neox': 2766, 'n_words': 546}