<commit_before>import { CevalCtrl, CevalOpts, Work, Step, Hovering, Started } from './types';

import { Pool, makeWatchdog } from './pool';
import { median } from './math';
import { prop, storedProp, throttle } from 'common';
import { povChances } from './winningChances';

const li = window.lichess;

function sanIrreversible(variant: VariantKey, san: string): boolean {
  if (san.indexOf('O-O') === 0) return true;
  if (variant === 'crazyhouse') return false;
  if (san.indexOf('x') > 0) return true; // capture
  if (san.toLowerCase() === san) return true; // pawn move
  return variant === 'threeCheck' && san.indexOf('+') > 0;
}

function officialStockfish(variant: VariantKey): boolean {
  return variant === 'standard' || variant === 'chess960';
}

function wasmThreadsSupported() {
  // WebAssembly 1.0
  const source = Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00);
  if (typeof WebAssembly !== 'object' || !WebAssembly.validate(source)) return false;

  // SharedArrayBuffer
  if (typeof SharedArrayBuffer !== 'function') return false;

  // Atomics
  if (typeof Atomics !== 'object') return false;

  // Shared memory
  if (!(new WebAssembly!.Memory({shared: true, initial: 8, maximum: 8}).buffer instanceof SharedArrayBuffer)) return false;

  // Structured cloning<commit_msg>wasmx: require 64 bit for now<commit_after>import { CevalCtrl, CevalOpts, Work, Step, Hovering, Started } from './types';

import { Pool, makeWatchdog } from './pool';
import { median } from './math';
import { prop, storedProp, throttle } from 'common';
import { povChances } from './winningChances';

const li = window.lichess;

function sanIrreversible(variant: VariantKey, san: string): boolean {
  if (san.indexOf('O-O') === 0) return true;
  if (variant === 'crazyhouse') return false;
  if (san.indexOf('x') > 0) return true; // capture
  if (san.toLowerCase() === san) return true; // pawn move
  return variant === 'threeCheck' && san.indexOf('+') > 0;
}

function officialStockfish(variant: VariantKey): boolean {
  return variant === 'standard' || variant === 'chess960';
}

function is64Bit(): boolean {
  const x64 = ['x86_64', 'x86-64', 'Win64','x64', 'amd64', 'AMD64'];
  for (const substr of x64) if (navigator.userAgent.indexOf(substr) >= 0) return true;
  return navigator.platform === 'Linux x86_64' || navigator.platform === 'MacIntel';
}

function wasmThreadsSupported() {
  // In theory 32 bit should be supported just the same, but some 32 bit
  // browser builds seem to crash when running WASMX. So for now detect and
  // require a 64 bit platform.
  if (!is64Bit()) return false;

  // WebAssembly 1.0
  const source = Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00);
  if (typeof WebAssembly !== 'object' || !WebAssembly.validate(source)) return false;

  // SharedArrayBuffer
  if (typeof SharedArrayBuffer !== 'function') return false;

  // Atomics
  if (typeof Atomics !== 'object') return false;

  // Shared memory
  if (!(new WebAssembly!.Memory({shared: true, initial: 8, maximum: 8}).buffer instanceof SharedArrayBuffer)) return false;

  // Structured cloning
{'fraction_non_alphanumeric': 0.15382145150931278, 'fraction_numerical': 0.033076429030186254, 'mean_word_length': 4.379965457685665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '6572447', 'n_tokens_mistral': 1070, 'n_tokens_neox': 973, 'n_words': 316}