"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _typeof = require("@babel/runtime/helpers/typeof");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.normalizeAdditionalKeys = exports.keysForGrade = exports.gradeSets = void 0;

var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));

var comparison = _interopRequireWildcard(require("./comparison"));

var vars = _interopRequireWildcard(require("./vars"));

var fractions = _interopRequireWildcard(require("./fractions"));

var exponent = _interopRequireWildcard(require("./exponent"));

var misc = _interopRequireWildcard(require("./misc"));

var constants = _interopRequireWildcard(require("./constants"));

var trigonometry = _interopRequireWildcard(require("./trigonometry"));

var geometry = _interopRequireWildcard(require("./geometry"));

var operators = _interopRequireWildcard(require("./operators"));

var log = _interopRequireWildcard(require("./log"));

var subSup = _interopRequireWildcard(require("./sub-sup"));

var statistics = _interopRequireWildcard(require("./statistics"));

var basicOperators = _interopRequireWildcard(require("./basic-operators"));

var matrices = _interopRequireWildcard(require("./matrices"));

var _digits = _interopRequireDefault(require("./digits"));

var logic = _interopRequireWildcard(require("./logic"));

var nav = _interopRequireWildcard(require("./navigation"));

var edit = _interopRequireWildcard(require("./edit"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var hs = [[fractions.blankOverBlank, misc.percentage, vars.x, exponent.squared, exponent.squareRoot], [operators.circleDot, vars.y, subSup.subscript, exponent.xToPowerOfN, exponent.nthRoot], [misc.plusMinus, comparison.lessThan, comparison.greaterThan, comparison.lessThanEqual, comparison.greaterThanEqual], [constants.pi, vars.theta, misc.parenthesis, misc.brackets, misc.absValue], [misc.notEqual, trigonometry.sin, trigonometry.cos, trigonometry.tan, geometry.degree]];

var advancedAlgebra = function () {
  var out = (0, _toConsumableArray2["default"])(hs.map(function (arr) {
    return (0, _toConsumableArray2["default"])(arr);
  }));
  out[0].push({
    name: 'i',
    latex: 'i',
    write: 'i'
  });
  out[1].push(log.log);
  out[2].push(log.logSubscript);
  out[3].push(log.ln);
  out[4].push(constants.eulers);
  return out;
}();

var statisticsSet = function () {
  var out = (0, _toConsumableArray2["default"])(hs.map(function (arr) {
    return (0, _toConsumableArray2["default"])(arr);
  }));
  out[0].push(statistics.mu);
  out[1].push(statistics.xBar);
  out[2].push(statistics.yBar);
  out[3].push(statistics.sigma);
  out[4].push(statistics.smallSigma);
  return out;
}();

var gradeSets = [{
  predicate: function predicate(n) {
    return n >= 3 && n <= 5;
  },
  set: [[comparison.lessThan, comparison.greaterThan], [fractions.xOverBlank, fractions.xBlankBlank], [vars.x, logic.longDivision], [exponent.squared, exponent.xToPowerOfN]]
}, {
  predicate: function predicate(n) {
    return n >= 6 && n <= 7;
  },
  set: [[geometry.degree, comparison.lessThan, comparison.greaterThan], [operators.circleDot, comparison.lessThanEqual, comparison.greaterThanEqual], [vars.x, vars.y, exponent.squared, exponent.xToPowerOfN], [misc.plusMinus, fractions.xOverBlank, fractions.xBlankBlank, exponent.squareRoot], [constants.pi, misc.parenthesis, misc.absValue, exponent.nthRoot]]
}, {
  predicate: function predicate(n) {
    return n >= 8 || n === 'HS';
  },
  set: hs
}, {
  predicate: 'non-negative-integers',
  set: [[_digits["default"].seven, _digits["default"].eight, _digits["default"].nine], [_digits["default"].four, _digits["default"].five, _digits["default"].six], [_digits["default"].one, _digits["default"].two, _digits["default"].three], [_digits["default"].zero, {
    name: '',
    latex: '',
    write: ''
  }, {
    name: '',
    latex: '',
    write: ''
  }], [nav.left, nav.right, edit.del]]
}, {
  predicate: 'integers',
  set: [[_digits["default"].seven, _digits["default"].eight, _digits["default"].nine], [_digits["default"].four, _digits["default"].five, _digits["default"].six], [_digits["default"].one, _digits["default"].two, _digits["default"].three], [_digits["default"].zero, {
    name: '',
    latex: '',
    write: ''
  }, basicOperators.minus], [nav.left, nav.right, edit.del]]
}, {
  predicate: 'decimals',
  set: [[_digits["default"].seven, _digits["default"].eight, _digits["default"].nine], [_digits["default"].four, _digits["default"].five, _digits["default"].six], [_digits["default"].one, _digits["default"].two, _digits["default"].three], [_digits["default"].zero, _digits["default"].decimalPoint, basicOperators.minus], [nav.left, nav.right, edit.del]]
}, {
  predicate: 'fractions',
  set: [[_digits["default"].seven, _digits["default"].eight, _digits["default"].nine], [_digits["default"].four, _digits["default"].five, _digits["default"].six], [_digits["default"].one, _digits["default"].two, _digits["default"].three], [_digits["default"].zero, fractions.blankOverBlank, basicOperators.minus], [nav.left, nav.right, edit.del]]
}, {
  predicate: 'geometry',
  set: [[fractions.blankOverBlank, geometry.degree, geometry.primeArcminute, geometry.doublePrimeArcSecond, geometry.congruentTo, geometry.similarTo], [operators.circleDot, geometry.angle, geometry.measureOfAngle, geometry.triangle, geometry.notCongruentTo, misc.notSimilar], [trigonometry.sin, trigonometry.cos, trigonometry.tan, constants.pi, exponent.squareRoot, exponent.nthRoot], [trigonometry.csc, trigonometry.sec, trigonometry.cot, vars.theta, subSup.subscript, exponent.xToPowerOfN], [geometry.overline, geometry.overRightArrow, geometry.overLeftRightArrow, geometry.overArc, geometry.perpindicular, geometry.parallel]]
}, // {
//   predicate: 'miscellaneous',
//   set: [
//     [
//       subSup.superscript,
//       subSup.subscript,
//       fractions.blankOverBlank,
//       misc.percentage,
//       geometry.segment,
//       geometry.parallel
//     ],
//     [
//       exponent.squareRoot,
//       exponent.nthRoot,
//       misc.absValue,
//       misc.parenthesis,
//       geometry.perpindicular,
//       geometry.angle
//     ],
//     [
//       comparison.lessThan,
//       comparison.greaterThan,
//       geometry.degree,
//       misc.approx,
//       geometry.measureOfAngle,
//       geometry.triangle
//     ],
//     [
//       misc.nApprox,
//       misc.notEqual,
//       geometry.congruentTo,
//       geometry.notCongruentTo,
//       geometry.parallelogram,
//       geometry.circledDot
//     ],
//     [
//       misc.similar,
//       misc.notSimilar,
//       comparison.lessThanEqual,
//       comparison.greaterThanEqual,
//       vars.x,
//       vars.y
//     ]
//   ]
// },
// {
//   predicate: 'everything',
//   set: [
//     [
//       subSup.superscript,
//       subSup.subscript,
//       fractions.blankOverBlank,
//       misc.percentage,
//       geometry.segment,
//       geometry.parallel
//     ],
//     [
//       exponent.squareRoot,
//       exponent.nthRoot,
//       misc.absValue,
//       misc.parenthesis,
//       geometry.perpindicular,
//       geometry.angle
//     ],
//     [
//       comparison.lessThan,
//       comparison.greaterThan,
//       geometry.degree,
//       misc.approx,
//       geometry.measureOfAngle,
//       geometry.triangle
//     ],
//     [
//       misc.nApprox,
//       misc.notEqual,
//       geometry.congruentTo,
//       geometry.notCongruentTo,
//       geometry.parallelogram,
//       geometry.circledDot
//     ],
//     [
//       misc.similar,
//       misc.notSimilar,
//       comparison.lessThanEqual,
//       comparison.greaterThanEqual,
//       vars.x,
//       vars.y
//     ]
//   ]
// },
{
  predicate: 'advanced-algebra',
  set: advancedAlgebra
}, {
  predicate: 'statistics',
  set: statisticsSet
}, {
  predicate: 'item-authoring',
  set: [[basicOperators.divide, fractions.blankOverBlank, logic.longDivision, constants.halfInfinity, exponent.squared, exponent.squareRoot, geometry.overline, geometry.overRightArrow, geometry.overLeftRightArrow, log.log], [basicOperators.multiply, operators.circleDot, {
    name: '',
    latex: '',
    write: ''
  }, subSup.subscript, exponent.xToPowerOfN, exponent.nthRoot, geometry.perpindicular, geometry.parallel, geometry.overArc, log.logSubscript], [misc.plusMinus, constants.pi, vars.theta, geometry.degree, geometry.angle, geometry.leftArrow, geometry.rightArrow, geometry.triangle, geometry.square, log.ln], [misc.notEqual, misc.absValue, statistics.smallSigma, statistics.mu, logic.therefore, statistics.sigma, geometry.leftrightArrow, trigonometry.sin, trigonometry.cos, trigonometry.tan], [comparison.lessThanEqual, comparison.greaterThanEqual, {
    name: '',
    latex: '',
    write: ''
  }, {
    name: '',
    latex: '',
    write: ''
  }, constants.infinity, {
    name: '',
    latex: '',
    write: ''
  }, {
    name: '',
    latex: '',
    write: ''
  }, trigonometry.csc, trigonometry.sec, trigonometry.cot]]
}, // for grade 1-2, we want to display the base set only
// we need it here because we don't want to display the default set (grade 8)
{
  predicate: function predicate(n) {
    return n >= 1 && n <= 2;
  },
  set: []
}];
exports.gradeSets = gradeSets;

var keysForGrade = function keysForGrade(n) {
  var number = parseInt(n, 10);
  n = isNaN(number) ? n : number;

  if (!n) {
    return [];
  }

  var match = gradeSets.find(function (gs) {
    if (typeof gs.predicate === 'string') {
      return gs.predicate === n;
    } else {
      return gs.predicate(n);
    }
  });

  if (match) {
    return match.set || [];
  } // if the grade is not found, return the default set which is grade 8 (as per PD-3549), for mode language it is not the default


  if (n !== 'language') {
    return gradeSets[2].set;
  }
};

exports.keysForGrade = keysForGrade;
var ALL_KEYS = [].concat((0, _toConsumableArray2["default"])(Object.values(basicOperators)), (0, _toConsumableArray2["default"])(Object.values(comparison)), (0, _toConsumableArray2["default"])(Object.values(constants)), (0, _toConsumableArray2["default"])(Object.values(_digits["default"])), (0, _toConsumableArray2["default"])(Object.values(exponent)), (0, _toConsumableArray2["default"])(Object.values(fractions)), (0, _toConsumableArray2["default"])(Object.values(geometry)), (0, _toConsumableArray2["default"])(Object.values(log)), (0, _toConsumableArray2["default"])(Object.values(matrices)), (0, _toConsumableArray2["default"])(Object.values(misc)), (0, _toConsumableArray2["default"])(Object.values(operators)), (0, _toConsumableArray2["default"])(Object.values(statistics)), (0, _toConsumableArray2["default"])(Object.values(subSup)), (0, _toConsumableArray2["default"])(Object.values(trigonometry)), (0, _toConsumableArray2["default"])(Object.values(vars)));

var normalizeAdditionalKeys = function normalizeAdditionalKeys(additionalKeys) {
  return (additionalKeys || []).map(function (additionalkey) {
    var latex = additionalkey.latex;
    var predefinedKey = (ALL_KEYS || []).find(function (key) {
      return latex === key.latex || latex === key.write || latex === key.command || latex === key.otherNotation;
    });
    return !latex ? additionalkey : predefinedKey || additionalkey;
  });
};

exports.normalizeAdditionalKeys = normalizeAdditionalKeys;
//# sourceMappingURL=grades.js.map