"use strict";

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

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

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

var _debug = _interopRequireDefault(require("debug"));

var _graphingUtils = require("../../../graphing-utils");

var _withRootEdge = require("../shared/line/with-root-edge");

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

var log = (0, _debug["default"])('pie-lib:graphing:sine');
var Sine = (0, _withRootEdge.withRootEdge)(function (props) {
  var root = props.root,
      edge = props.edge,
      graphProps = props.graphProps;
  var domain = graphProps.domain,
      range = graphProps.range;

  var _getAmplitudeAndFreq = (0, _graphingUtils.getAmplitudeAndFreq)(root, edge),
      amplitude = _getAmplitudeAndFreq.amplitude,
      freq = _getAmplitudeAndFreq.freq;

  var interval = freq / _graphingUtils.FREQ_DIVIDER;
  log('[getPoints] amplitude:', amplitude, 'freq:', freq);
  var dataPoints = edge && edge.x === root.x ? [] : (0, _graphingUtils.buildDataPoints)(_objectSpread(_objectSpread({}, domain), {}, {
    step: interval
  }), range, root, edge, (0, _graphingUtils.sinY)(amplitude, freq, {
    phase: root.x,
    vertical: root.y
  }));
  return {
    root: props.root,
    edge: props.edge,
    dataPoints: dataPoints
  };
});
var Component = (0, _withRootEdge.rootEdgeComponent)(Sine);
var _default = Component;
exports["default"] = _default;
//# sourceMappingURL=component.js.map