<commit_before>import { h } from 'snabbdom'
import { VNode } from 'snabbdom/vnode'
import { bind, dataIcon } from '../../util';
import AnalyseCtrl from '../../ctrl';
import { StudyCtrl } from '../interfaces';
import { shareButton } from '../studyView';

export function playButtons(root: AnalyseCtrl): VNode | undefined {
  const study = root.study!,
  ctrl = study.gamebookPlay();
  if (!ctrl) return;
  const state = ctrl.state,
  fb = state.feedback;
  return h('div.study_buttons', [
    shareButton(study),
    fb === 'play' ? h('div.gb_buttons', [
      state.hint ? h('a.button.text', {
        attrs: dataIcon(''),
        hook: bind('click', ctrl.hint, ctrl.redraw)
      }, 'Get a hint') : null,
      h('a.button.text', {
        attrs: dataIcon('G'),
        hook: bind('click', ctrl.solution, ctrl.redraw)
      }, 'View the solution'),
      study.vm.gamebookOverride === 'play' ? previewButton(study) : undefined
    ]) : undefined,
  ]);
}

export function previewButton(study: StudyCtrl): VNode | undefined {
  if (study.data.chapter.gamebook) return h('a.button.text', {
    class: { active: study.vm.gamebookOverride === 'play' },
    attrs: dataIcon('v'),
    hook: bind('click', () => {
      study.setGamebookOverride(study.vm.gamebookOverride === 'play' ? undefined : 'play');
    }, study.redraw)
  }, 'Preview');
}
<commit_msg>fix gamebook preview<commit_after>import { h } from 'snabbdom'
import { VNode } from 'snabbdom/vnode'
import { bind, dataIcon } from '../../util';
import AnalyseCtrl from '../../ctrl';
import { StudyCtrl } from '../interfaces';
import { shareButton } from '../studyView';

export function playButtons(root: AnalyseCtrl): VNode | undefined {
  const study = root.study!,
  ctrl = study.gamebookPlay();
  if (!ctrl) return;
  const state = ctrl.state,
  fb = state.feedback,
  myTurn = fb === 'play';
  return h('div.study_buttons', [
    shareButton(study),
    h('div.gb_buttons', [
      myTurn && state.hint ? h('a.button.text.hint', {
        attrs: dataIcon(''),
        hook: bind('click', ctrl.hint, ctrl.redraw)
      }, 'Get a hint') : null,
      myTurn ? h('a.button.text.solution', {
        attrs: dataIcon('G'),
        hook: bind('click', ctrl.solution, ctrl.redraw)
      }, 'View the solution') : undefined,
      study.vm.gamebookOverride === 'play' ? previewButton(study) : undefined
    ]),
  ]);
}

export function previewButton(study: StudyCtrl): VNode | undefined {
  if (study.data.chapter.gamebook) return h('a.button.text.preview', {
    class: { active: study.vm.gamebookOverride === 'play' },
    attrs: dataIcon('v'),
    hook: bind('click', () => {
      study.setGamebookOverride(study.vm.gamebookOverride === 'play' ? undefined : 'play');
    }, study.redraw)
  }, 'Preview');
}

{'fraction_non_alphanumeric': 0.18053545586107092, 'fraction_numerical': 0.0, 'mean_word_length': 3.340659340659341, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1453963', 'n_tokens_mistral': 908, 'n_tokens_neox': 879, 'n_words': 207}