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) { _defineProperty(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; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
import React, { useState } from 'react';
import * as R from 'ramda';
import * as fps from '@jadesrochers/fpstreamline';
var getFigHeight = (height, margins) => height - margins.top - margins.bottom;
var getFigWidth = (width, margins) => width - margins.left - margins.right;

// Arguments to FigureContainer - Need at the least width/height, margins.
// xdata/ydata/zdata all depends on what the children are and need
// ticks is a good idea so you get reasonable labels.

// The purpose of the FigureContainer is to provide resources
// to all child elements, but not to coordinate or know what they do. 
// setPlotData - tracking when data is set 
// ysetScale, xsetScale - Allow child elements to set the scaling
// ymaxSet - For setting y max When y data is derived, like in histogram
// All props to the container are also passed. 
var FigureContainer = props => {
  var [plotData, setPlotData] = useState(undefined);
  var [xscale, xscaleSet] = useState(undefined);
  var [yscale, yscaleSet] = useState(undefined);
  var [ymax, ymaxSet] = useState(10);
  if (!props.xdata) {
    return null;
  }
  var height, width;
  height = getFigHeight(props.height, props.margins);
  width = getFigWidth(props.width, props.margins);
  var pass = R.dissoc('children', props);
  var propsToChildren = R.map(child => {
    return /*#__PURE__*/React.cloneElement(child, _objectSpread(_objectSpread({}, pass), {}, {
      height,
      width,
      xscale,
      xscaleSet,
      yscale,
      yscaleSet,
      ymaxSet,
      ymax,
      setPlotData,
      plotData
    }));
  })(fps.toArray(props.children));
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("g", {
    transform: "translate(".concat(props.margins.left, ",").concat(props.margins.top, ")")
  }, propsToChildren));
};
export { FigureContainer };