import c from "react";
const i = (d) => {
  const { data: e, measures: o, customMeasureLabels: t, children: h, source: m } = d, l = {
    locationsData: [],
    nationalData: {},
    measureLabelMap: {}
  };
  e.metadata && e.metadata.measures && e.metadata.measures.forEach((a) => {
    t && t[a.value] && t[a.value].hasCustomLabel && t[a.value].customLabel ? l.measureLabelMap[a.value] = t[a.value].customLabel : l.measureLabelMap[a.value] = a.label;
  });
  const s = o.split(",");
  return e && e.children && (e.children.forEach((a) => {
    s.forEach((r) => {
      const u = {
        ...a,
        label: a.value,
        value: a[r],
        measure: r
      };
      a.children && (u.children = [], a.children.forEach((n) => {
        u.children.push({ ...n, label: n.value, value: n[r] });
      })), l.locationsData.push(u);
    });
  }), l.measures = s.length > 1 ? s : null, l.nationalData.value = e[o]), c.Children.map(h, (a) => c.cloneElement(a, { transformedData: {
    ...l,
    types: e.metadata ? e.metadata.types : []
  } }));
};
export {
  i as default
};
