<commit_before>import React, { Component } from 'react';
import PropTypes from 'prop-types';

export default class ViewOptions extends Component {
  onRenderAnnotationsChange = event =>
    this.props.setState({ renderAnnotations: event.target.checked })

  onRenderModeChange = event =>
    this.props.setState({ renderMode: event.target.value })

  onRenderTextLayersChange = event =>
    this.props.setState({ renderTextLayer: event.target.checked })

  onDisplayAllChange = event =>
    this.props.setState({ displayAll: event.target.checked })

  onPageWidthChange = (event) => {
    event.preventDefault();

    const form = event.target;

    const width = form.pageWidth.value;

    if (!width) {
      return;
    }

    this.props.setState({
      pageWidth: parseInt(width, 10),
    });
  }

  rotateLeft = () => this.changeRotation(-90);

  rotateRight = () => this.changeRotation(90);

  changeRotation(by) {
    this.props.setState(prevState => ({ rotate: (prevState.rotate + by) % 360 }));
  }

  resetRotation = () => this.props.setState({ rotate: null })

  resetWidth = () => this.props.setState({ pageWidth: null })

  render() {
    const {
      displayAll,
      pageWidth,
      renderAnnotations,
      renderMode,
      renderTextLayer,
      rotate,
    } = this.props;

    return (
      <fieldset id="viewoptions">
        <legend htmlFor="viewoptions">View options</legend>
<commit_msg>Prevent rotate prop from going below zero<commit_after>import React, { Component } from 'react';
import PropTypes from 'prop-types';

export default class ViewOptions extends Component {
  onRenderAnnotationsChange = event =>
    this.props.setState({ renderAnnotations: event.target.checked })

  onRenderModeChange = event =>
    this.props.setState({ renderMode: event.target.value })

  onRenderTextLayersChange = event =>
    this.props.setState({ renderTextLayer: event.target.checked })

  onDisplayAllChange = event =>
    this.props.setState({ displayAll: event.target.checked })

  onPageWidthChange = (event) => {
    event.preventDefault();

    const form = event.target;

    const width = form.pageWidth.value;

    if (!width) {
      return;
    }

    this.props.setState({
      pageWidth: parseInt(width, 10),
    });
  }

  rotateLeft = () => this.changeRotation(-90);

  rotateRight = () => this.changeRotation(90);

  changeRotation(by) {
    this.props.setState(prevState => ({ rotate: (prevState.rotate + by + 360) % 360 }));
  }

  resetRotation = () => this.props.setState({ rotate: null })

  resetWidth = () => this.props.setState({ pageWidth: null })

  render() {
    const {
      displayAll,
      pageWidth,
      renderAnnotations,
      renderMode,
      renderTextLayer,
      rotate,
    } = this.props;

    return (
      <fieldset id="viewoptions">
        <legend htmlFor="viewoptions">View options</legend>

{'fraction_non_alphanumeric': 0.13293789253314725, 'fraction_numerical': 0.00732728541521284, 'mean_word_length': 3.2474074074074073, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 29, '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': '3669814', 'n_tokens_mistral': 876, 'n_tokens_neox': 835, 'n_words': 175}