function _templateObject() {
  var data = _taggedTemplateLiteral(["\n                    text-align: center;\n                  "]);

  _templateObject = function _templateObject() {
    return data;
  };

  return data;
}

function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }

import { jsx, css } from "@emotion/core";
import shortid from "shortid";
import { bool, arrayOf, shape } from "prop-types";
import SandboxMapLegend from "./SandboxMapLegend";

var SandboxLegend = function SandboxLegend(props) {
  var foundationData = props.foundationData,
      allSlides = props.allSlides,
      foundationMapProps = props.foundationMapProps,
      areSlidesLoading = props.areSlidesLoading,
      errors = props.errors;
  var loader = jsx("div", null);
  return jsx("div", null, !areSlidesLoading && allSlides ? allSlides.map(function (slide) {
    var dataIndex = foundationData.findIndex(function (d) {
      var scatterplot = d.mapType === "ScatterPlotMap" && d.layerInfo.displayName === slide.label;
      var choropleth = d.mapType === "ChoroplethMap" && d.layerInfo.displayName === slide.label;
      var vectorTilesMap = d.mapType === "vtChoroplethMap" && d.legend && d.layerInfo.displayName === slide.label;
      var vtScatterPlotMap = d.mapType === "vtScatterPlotMap" && d.legend && d.layerInfo.displayName === slide.label;
      return choropleth || scatterplot || vectorTilesMap || vtScatterPlotMap;
    });
    var matchFound = dataIndex > -1 && foundationData[dataIndex].data.length > 0;
    var mapLegend = matchFound && jsx(SandboxMapLegend, {
      data: foundationData[dataIndex].data,
      mapProps: foundationMapProps[dataIndex]
    });
    var matchFoundVector = dataIndex > -1 && foundationData[dataIndex].mapType === "vtChoroplethMap" || dataIndex > -1 && foundationData[dataIndex].mapType === "vtScatterPlotMap";
    var mapLegendVector = matchFoundVector && jsx(SandboxMapLegend, {
      mapProps: foundationMapProps[dataIndex]
    });
    var mapLegendBox = (matchFound || matchFoundVector) && jsx("div", null, jsx("h3", {
      css: css(_templateObject())
    }, slide.label), mapLegend, mapLegendVector);
    return jsx("div", {
      key: shortid.generate(),
      css: css("\n                  position: absolute;\n                  bottom: ".concat(30 + dataIndex * 150, "px;\n                  width: 500px;\n                  left: 0px;\n                  background-color: rgba(255,255,255,0.9);\n                  @media (max-width: 500px) {\n                    width: 100%\n                  }\n                "))
    }, mapLegendBox);
  }) : loader, errors ? jsx("div", {
    css: css("\n                margin: auto;\n                width: 80%;\n              ")
  }, jsx("p", null, "There was an error fetching the data.")) : null);
};

export default SandboxLegend;
SandboxLegend.propTypes = {
  foundationData: arrayOf(shape({})),
  allSlides: arrayOf(shape({})),
  foundationMapProps: arrayOf(shape({})),
  areSlidesLoading: bool,
  errors: bool
};