import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _typeof from '@babel/runtime/helpers/typeof';
import _pick from '../../node_modules/lodash-es/pick.js';
import _omit from '../../node_modules/lodash-es/omit.js';
import isEmpty from '../../node_modules/lodash-es/isEmpty.js';
import isNil from '../../node_modules/lodash-es/isNil.js';
import 'core-js/modules/es.array.concat.js';
import 'core-js/modules/es.array.filter.js';
import 'core-js/modules/es.array.iterator.js';
import 'core-js/modules/es.array.join.js';
import 'core-js/modules/es.symbol.js';
import 'core-js/modules/es.array.map.js';
import 'core-js/modules/es.object.get-own-property-descriptor.js';
import 'core-js/modules/es.object.get-own-property-descriptors.js';
import 'core-js/modules/es.object.keys.js';
import 'core-js/modules/es.object.to-string.js';
import 'core-js/modules/web.dom-collections.for-each.js';
import 'core-js/modules/web.dom-collections.iterator.js';
import React__default, { useMemo, useState } from 'react';
import PropTypes from 'prop-types';
import warning from 'warning';
import { DASHBOARD_EDITOR_CARD_TYPES, CARD_TYPES } from '../../constants/LayoutConstants.js';
import CardCodeEditor from '../CardCodeEditor/CardCodeEditor.js';
import Button from '../Button/Button.js';
import { settings } from '../../constants/Settings.js';
import { DashboardEditorActionsPropTypes, defaultDashboardEditorActionsProps } from '../DashboardEditor/editorUtils.js';
import CardGalleryList from './CardGalleryList/CardGalleryList.js';
import CardEditForm from './CardEditForm/CardEditForm.js';
import { Code, Apps, Data_1 } from '@carbon/icons-react';

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var iotPrefix = settings.iotPrefix;
var propTypes = {
  /** card data being edited */
  cardConfig: PropTypes.shape({
    id: PropTypes.string,
    title: PropTypes.string,
    size: PropTypes.string,
    type: PropTypes.string,
    content: PropTypes.oneOfType([PropTypes.shape({
      series: PropTypes.arrayOf(PropTypes.shape({
        label: PropTypes.string,
        dataSourceId: PropTypes.string,
        color: PropTypes.string
      })),
      xLabel: PropTypes.string,
      yLabel: PropTypes.string,
      unit: PropTypes.string,
      includeZeroOnXaxis: PropTypes.bool,
      includeZeroOnYaxis: PropTypes.bool,
      timeDataSourceId: PropTypes.string,
      showLegend: PropTypes.bool
    }),
    // custom card content is a function
    PropTypes.func]),
    interval: PropTypes.string
  }),
  /** Callback function when user clicks Show Gallery */
  onShowGallery: PropTypes.func.isRequired,
  /** Callback function when form data changes, passes the updated card configuration */
  onChange: PropTypes.func.isRequired,
  /** Callback function when card is added from list */
  onAddCard: PropTypes.func.isRequired,
  /** optional function passes the card props being edited and you can updated the card props
   * This allows you to add things to the edit form that are not in the main card JSON.  This is a better
   * way to add custom editor props to the Card.
   */
  onRenderCardEditForm: PropTypes.func,
  /** if provided, allows the consumer to make changes to the cardConfig for preview in the JSON editor modal.
   * onCardJsonPreview(card)
   */
  onCardJsonPreview: PropTypes.func,
  /** if provided, returns an array of strings which are the dataItems to be allowed
   * on each card
   * getValidDataItems(card, selectedTimeRange)
   */
  getValidDataItems: PropTypes.func,
  /** if provided, returns an array of strings which are the timeRanges to be allowed
   * on each card
   * getValidTimeRanges(card, selectedDataItems)
   */
  getValidTimeRanges: PropTypes.func,
  /** an array of dataItems to be included on each card
   * this prop will be ignored if getValidDataItems is defined
   */
  dataItems: PropTypes.arrayOf(PropTypes.shape({
    dataSourceId: PropTypes.string,
    label: PropTypes.string
  })),
  /** if provided, returns an object where the keys are available dimensions which are the dimensions to be allowed
   * on each card
   * ex response: { manufacturer: ['Rentech', 'GHI Industries'], deviceid: ['73000', '73001', '73002'] }
   * getValidDimensions(card)
   */
  getValidDimensions: PropTypes.func,
  /** an object where the keys are available dimensions and the values are the values available for those dimensions
   *  ex: { manufacturer: ['Rentech', 'GHI Industries'], deviceid: ['73000', '73001', '73002'] }
   */
  availableDimensions: PropTypes.shape({}),
  /** If provided, runs the function when the user clicks submit in the Card code JSON editor
   * onValidateCardJson(cardConfig)
   * @returns Array<string> error strings. return empty array if there is no errors
   */
  onValidateCardJson: PropTypes.func,
  /**
   * An array of card types that are allowed to show up in the list. These keys will also be used in both icons and i18n
   * ex: [ DASHBOARD_EDITOR_CARD_TYPES.TIMESERIES, DASHBOARD_EDITOR_CARD_TYPES.ALERT, 'CUSTOM', 'ANOTHER_CUSTOM']
   */
  supportedCardTypes: PropTypes.arrayOf(PropTypes.string),
  /**
   * Dictionary of icons that corresponds to both `supportedCardTypes` and `i18n`
   * ex:
   * {
   *  TIMESERIES: <EscalatorDown />,
   *  ALERT: <Code24 />,
   *  CUSTOM: <Basketball32 />,
   *  ANOTHER_CUSTOM: <Automobile32 />,
   * }
   */
  icons: PropTypes.objectOf(PropTypes.node),
  /**
   * i18n must include the label for each `supportedCardTypes`
   * ex:
   * [
   *  TIMESERIES: 'ITEM 1',
   *  ALERT: 'ITEM 8',
   *  CUSTOM: 'ITEM 10',
   *  COOL_NEW_CARD: 'Missing Icon',
   * ]
   */
  i18n: PropTypes.shape({
    galleryHeader: PropTypes.string,
    addCardButton: PropTypes.string,
    searchPlaceHolderText: PropTypes.string,
    editDataItems: PropTypes.string
  }),
  /** whether to use translated labels in cards */
  shouldUseTranslatedLabels: PropTypes.bool,
  currentBreakpoint: PropTypes.string,
  isSummaryDashboard: PropTypes.bool,
  /** Id that can be used for testing */
  testId: PropTypes.string,
  /** optional link href's for each card type that will appear in a tooltip */
  dataSeriesItemLinks: PropTypes.shape({
    simpleBar: PropTypes.string,
    groupedBar: PropTypes.string,
    stackedBar: PropTypes.string,
    timeSeries: PropTypes.string,
    value: PropTypes.string,
    custom: PropTypes.string,
    table: PropTypes.string,
    image: PropTypes.string
  }),
  onEditDataItems: PropTypes.func,
  actions: DashboardEditorActionsPropTypes
};
var defaultProps = {
  cardConfig: null,
  i18n: {
    galleryHeader: 'Gallery',
    openGalleryButton: 'Add card',
    addCardButton: 'Add card',
    closeGalleryButton: 'Back',
    openJSONButton: 'Open JSON editor',
    searchPlaceHolderText: 'Enter a search',
    editDataItems: 'Edit data items',
    modalTitle: 'Edit card JSON configuration',
    modalLabel: 'Card editor',
    modalHelpText: 'The JSON definition for this card is provided below.  You can modify this data directly to update the card configuration.',
    modalIconDescription: 'Close'
  },
  shouldUseTranslatedLabels: false,
  getValidDimensions: null,
  getValidDataItems: null,
  getValidTimeRanges: null,
  onCardJsonPreview: null,
  onRenderCardEditForm: null,
  dataItems: [],
  availableDimensions: {},
  supportedCardTypes: Object.keys(DASHBOARD_EDITOR_CARD_TYPES),
  icons: null,
  onValidateCardJson: null,
  currentBreakpoint: 'xl',
  isSummaryDashboard: false,
  testId: 'card-editor',
  dataSeriesItemLinks: null,
  onEditDataItems: null,
  actions: defaultDashboardEditorActionsProps
};
var baseClassName = "".concat(iotPrefix, "--card-editor");

/**
 * Returns errors of basic JSON syntax
 * Must not be empty string, Must be valid JSON
 * @param {Object} card JSON currently being edited
 * @returns {Array<string>} error strings
 */
var basicCardValidation = function basicCardValidation(card) {
  var errors = [];
  try {
    var json = JSON.parse(card);
    if (!json || _typeof(json) !== 'object') {
      errors.push("".concat(card.substring(0, 8), " is not valid JSON"));
    }
  } catch (e) {
    errors.push(e.message);
  }
  return errors;
};

/**
 * removes properties needed for the editor that we don't want the user to be able to modify
 * @param {Object} card JSON currently being edited
 * @returns {Object} card with omitted attributes
 */
var hideCardPropertiesForEditor = function hideCardPropertiesForEditor(card) {
  var _card$content, _card$content2, _card$content3, _card$values, _card$values2;
  var attributes;
  var series;
  var columns;
  var itemsToOmit = ['aggregationMethods', 'grain'];
  if ((_card$content = card.content) !== null && _card$content !== void 0 && _card$content.attributes) {
    attributes = card.content.attributes.map(function (attribute) {
      return _omit(attribute, itemsToOmit);
    });
  }
  if ((_card$content2 = card.content) !== null && _card$content2 !== void 0 && _card$content2.series) {
    series = card.content.series.map(function (attribute) {
      return _omit(attribute, itemsToOmit);
    });
  }
  if ((_card$content3 = card.content) !== null && _card$content3 !== void 0 && _card$content3.columns) {
    columns = card.content.columns.map(function (column) {
      return _omit(column, itemsToOmit);
    });
  }
  // Need to exclued content for custom cards because the card's JSX element lives on it in this case
  if (!CARD_TYPES.hasOwnProperty(card.type) || card.type === CARD_TYPES.CUSTOM) {
    return _omit(card, 'content');
  }
  return _omit(attributes // VALUE CARD
  ? _objectSpread(_objectSpread({}, card), {}, {
    content: _objectSpread(_objectSpread({}, card.content), {}, {
      attributes: attributes
    })
  }) : series // TIMESERIES AND BAR CHART CARDS
  ? _objectSpread(_objectSpread({}, card), {}, {
    content: _objectSpread(_objectSpread({}, card.content), {}, {
      series: series
    })
  }) : (_card$values = card.values) !== null && _card$values !== void 0 && _card$values.hotspots // IMAGE CARD
  ? _objectSpread(_objectSpread({}, card), {}, {
    values: _objectSpread(_objectSpread({}, card.values), {}, {
      hotspots: (_card$values2 = card.values) === null || _card$values2 === void 0 || (_card$values2 = _card$values2.hotspots) === null || _card$values2 === void 0 ? void 0 : _card$values2.map(function (hotspot) {
        var _hotspot$content;
        return _objectSpread(_objectSpread({}, hotspot), {}, {
          content: _objectSpread(_objectSpread({}, hotspot.content), {}, {
            attributes: (_hotspot$content = hotspot.content) === null || _hotspot$content === void 0 || (_hotspot$content = _hotspot$content.attributes) === null || _hotspot$content === void 0 ? void 0 : _hotspot$content.map(function (attribute) {
              return _omit(attribute, itemsToOmit);
            })
          })
        });
      })
    })
  }) : columns // TABLE CARD
  ? _objectSpread(_objectSpread({}, card), {}, {
    content: _objectSpread(_objectSpread({}, card.content), {}, {
      columns: columns
    })
  }) : card, ['content.src', 'content.imgState', 'i18n', 'validateUploadedImage', 'children']);
};

/**
 * Checks for JSON form errors
 * @param {Object} card JSON text input
 * @param {Function} setError
 * @param {Function} onValidateCardJson
 * @param {Function} onChange
 * @param {Function} setShowEditor
 */
var handleSubmit = function handleSubmit(card, id, setError, onValidateCardJson, onChange, setShowEditor) {
  // first validate basic JSON syntax
  var basicErrors = basicCardValidation(card);
  // second validate the consumer's custom function if provided
  var customValidationErrors = [];
  if (onValidateCardJson) {
    customValidationErrors = onValidateCardJson(card);
  }
  var allErrors = basicErrors.concat(customValidationErrors);
  // then submit
  if (isEmpty(allErrors)) {
    onChange(_objectSpread(_objectSpread({}, JSON.parse(card)), {}, {
      id: id
    }));
    setShowEditor(false);
    return true;
  }
  setError(allErrors.join('. '));
  return false;
};
var CardEditor = function CardEditor(_ref) {
  var cardConfig = _ref.cardConfig,
    isSummaryDashboard = _ref.isSummaryDashboard,
    onShowGallery = _ref.onShowGallery,
    onChange = _ref.onChange,
    onAddCard = _ref.onAddCard,
    getValidDataItems = _ref.getValidDataItems,
    getValidTimeRanges = _ref.getValidTimeRanges,
    dataItems = _ref.dataItems,
    onValidateCardJson = _ref.onValidateCardJson,
    onCardJsonPreview = _ref.onCardJsonPreview,
    supportedCardTypes = _ref.supportedCardTypes,
    availableDimensionsProp = _ref.availableDimensions,
    getValidDimensions = _ref.getValidDimensions,
    onRenderCardEditForm = _ref.onRenderCardEditForm,
    icons = _ref.icons,
    i18n = _ref.i18n,
    shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
    currentBreakpoint = _ref.currentBreakpoint,
    testId = _ref.testId,
    dataSeriesItemLinks = _ref.dataSeriesItemLinks,
    onFetchDynamicDemoHotspots = _ref.onFetchDynamicDemoHotspots,
    onEditDataItems = _ref.onEditDataItems,
    actions = _ref.actions;
  React__default.useEffect(function () {
    {
      warning(false, 'The `CardEditor` is an experimental component and could be lacking unit test and documentation. Be aware that minor version bumps could introduce breaking changes. For the reasons listed above use of this component in production is highly discouraged') ;
    }
  }, []);
  var mergedI18n = useMemo(function () {
    return _objectSpread(_objectSpread({}, defaultProps.i18n), i18n);
  }, [i18n]);
  var _useState = useState(),
    _useState2 = _slicedToArray(_useState, 2),
    modalJsonData = _useState2[0],
    setModalJsonData = _useState2[1];
  var _useState3 = useState(false),
    _useState4 = _slicedToArray(_useState3, 2),
    showJsonEditor = _useState4[0],
    setShowJsonEditor = _useState4[1];
  var availableDimensions = useMemo(function () {
    return getValidDimensions ? getValidDimensions(cardConfig) : availableDimensionsProp;
  }, [availableDimensionsProp, cardConfig, getValidDimensions]);

  // show the gallery if no card is being edited
  var showGallery = isNil(cardConfig);
  var finalCardToEdit = useMemo(function () {
    return onRenderCardEditForm && cardConfig ? onRenderCardEditForm(cardConfig) : cardConfig;
  }, [cardConfig, onRenderCardEditForm]);
  return /*#__PURE__*/React__default.createElement("div", {
    className: baseClassName,
    "data-testid": testId
  }, showGallery ? /*#__PURE__*/React__default.createElement("div", {
    className: "".concat(baseClassName, "--header")
  }, /*#__PURE__*/React__default.createElement("h2", {
    className: "".concat(baseClassName, "--header--title")
  }, mergedI18n.galleryHeader)) : null, /*#__PURE__*/React__default.createElement("div", {
    className: "".concat(baseClassName, "--content")
  }, showGallery ? /*#__PURE__*/React__default.createElement(CardGalleryList, {
    icons: icons,
    onAddCard: onAddCard,
    supportedCardTypes: supportedCardTypes,
    i18n: mergedI18n,
    testId: "".concat(testId, "-card-gallery-list")
  }) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, showJsonEditor ? /*#__PURE__*/React__default.createElement(CardCodeEditor, {
    onSubmit: function onSubmit(card, setError) {
      return handleSubmit(card, cardConfig.id, setError, onValidateCardJson, onChange, setShowJsonEditor);
    },
    onClose: function onClose() {
      return setShowJsonEditor(false);
    },
    initialValue: modalJsonData,
    i18n: _pick(mergedI18n, 'errorTitle', 'modalTitle', 'modalLabel', 'modalHelpText', 'modalIconDescription', 'copyBtnDescription', 'copyBtnFeedBack', 'expandBtnLabel', 'modalPrimaryButtonLabel', 'modalSecondaryButtonLabel')
  }) : null, /*#__PURE__*/React__default.createElement(CardEditForm, {
    key: cardConfig.id,
    cardConfig: finalCardToEdit,
    isSummaryDashboard: isSummaryDashboard,
    onChange: onChange,
    dataItems: dataItems,
    getValidDataItems: getValidDataItems,
    getValidTimeRanges: getValidTimeRanges,
    availableDimensions: availableDimensions,
    i18n: mergedI18n,
    shouldUseTranslatedLabels: shouldUseTranslatedLabels,
    currentBreakpoint: currentBreakpoint,
    dataSeriesItemLinks: dataSeriesItemLinks,
    onFetchDynamicDemoHotspots: onFetchDynamicDemoHotspots,
    actions: actions
  }))), showGallery ? null : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
    className: "".concat(baseClassName, "--footer")
  }, /*#__PURE__*/React__default.createElement(Button, {
    testId: "".concat(testId, "-open-editor-button"),
    kind: "ghost",
    size: "sm",
    renderIcon: Code,
    onClick: function onClick() {
      var cardConfigForModal = onCardJsonPreview ? onCardJsonPreview(hideCardPropertiesForEditor(cardConfig)) : hideCardPropertiesForEditor(cardConfig);
      setModalJsonData(JSON.stringify(cardConfigForModal, null, 4));
      setShowJsonEditor(true);
    }
  }, mergedI18n.openJSONButton)), /*#__PURE__*/React__default.createElement("div", {
    className: "".concat(baseClassName, "--footer")
  }, /*#__PURE__*/React__default.createElement(Button, {
    kind: "ghost",
    size: "sm",
    renderIcon: Apps,
    onClick: onShowGallery,
    testId: "".concat(testId, "-add-card-button")
  }, mergedI18n.addCardButton))), isSummaryDashboard ? /*#__PURE__*/React__default.createElement("div", {
    className: "".concat(baseClassName, "--footer")
  }, /*#__PURE__*/React__default.createElement(Button, {
    key: "edit-data-item",
    kind: "ghost",
    size: "sm",
    renderIcon: Data_1,
    onClick: onEditDataItems,
    iconDescription: mergedI18n.editDataItems,
    testId: "".concat(testId, "-edit-button")
  }, mergedI18n.editDataItems)) : null);
};
CardEditor.propTypes = propTypes;
CardEditor.defaultProps = defaultProps;
CardEditor.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "CardEditor",
  "props": {
    "cardConfig": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "card data being edited",
      "type": {
        "name": "shape",
        "value": {
          "id": {
            "name": "string",
            "required": false
          },
          "title": {
            "name": "string",
            "required": false
          },
          "size": {
            "name": "string",
            "required": false
          },
          "type": {
            "name": "string",
            "required": false
          },
          "content": {
            "name": "union",
            "value": [{
              "name": "shape",
              "value": {
                "series": {
                  "name": "arrayOf",
                  "value": {
                    "name": "shape",
                    "value": {
                      "label": {
                        "name": "string",
                        "required": false
                      },
                      "dataSourceId": {
                        "name": "string",
                        "required": false
                      },
                      "color": {
                        "name": "string",
                        "required": false
                      }
                    }
                  },
                  "required": false
                },
                "xLabel": {
                  "name": "string",
                  "required": false
                },
                "yLabel": {
                  "name": "string",
                  "required": false
                },
                "unit": {
                  "name": "string",
                  "required": false
                },
                "includeZeroOnXaxis": {
                  "name": "bool",
                  "required": false
                },
                "includeZeroOnYaxis": {
                  "name": "bool",
                  "required": false
                },
                "timeDataSourceId": {
                  "name": "string",
                  "required": false
                },
                "showLegend": {
                  "name": "bool",
                  "required": false
                }
              }
            }, {
              "name": "func"
            }],
            "required": false
          },
          "interval": {
            "name": "string",
            "required": false
          }
        }
      },
      "required": false
    },
    "i18n": {
      "defaultValue": {
        "value": "{\n  galleryHeader: 'Gallery',\n  openGalleryButton: 'Add card',\n  addCardButton: 'Add card',\n  closeGalleryButton: 'Back',\n  openJSONButton: 'Open JSON editor',\n  searchPlaceHolderText: 'Enter a search',\n  editDataItems: 'Edit data items',\n  modalTitle: 'Edit card JSON configuration',\n  modalLabel: 'Card editor',\n  modalHelpText:\n    'The JSON definition for this card is provided below.  You can modify this data directly to update the card configuration.',\n  modalIconDescription: 'Close',\n}",
        "computed": false
      },
      "description": "i18n must include the label for each `supportedCardTypes`\nex:\n[\n TIMESERIES: 'ITEM 1',\n ALERT: 'ITEM 8',\n CUSTOM: 'ITEM 10',\n COOL_NEW_CARD: 'Missing Icon',\n]",
      "type": {
        "name": "shape",
        "value": {
          "galleryHeader": {
            "name": "string",
            "required": false
          },
          "addCardButton": {
            "name": "string",
            "required": false
          },
          "searchPlaceHolderText": {
            "name": "string",
            "required": false
          },
          "editDataItems": {
            "name": "string",
            "required": false
          }
        }
      },
      "required": false
    },
    "shouldUseTranslatedLabels": {
      "defaultValue": {
        "value": "false",
        "computed": false
      },
      "description": "whether to use translated labels in cards",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "getValidDimensions": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "if provided, returns an object where the keys are available dimensions which are the dimensions to be allowed\non each card\nex response: { manufacturer: ['Rentech', 'GHI Industries'], deviceid: ['73000', '73001', '73002'] }\ngetValidDimensions(card)",
      "type": {
        "name": "func"
      },
      "required": false
    },
    "getValidDataItems": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "if provided, returns an array of strings which are the dataItems to be allowed\non each card\ngetValidDataItems(card, selectedTimeRange)",
      "type": {
        "name": "func"
      },
      "required": false
    },
    "getValidTimeRanges": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "if provided, returns an array of strings which are the timeRanges to be allowed\non each card\ngetValidTimeRanges(card, selectedDataItems)",
      "type": {
        "name": "func"
      },
      "required": false
    },
    "onCardJsonPreview": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "if provided, allows the consumer to make changes to the cardConfig for preview in the JSON editor modal.\nonCardJsonPreview(card)",
      "type": {
        "name": "func"
      },
      "required": false
    },
    "onRenderCardEditForm": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "optional function passes the card props being edited and you can updated the card props\nThis allows you to add things to the edit form that are not in the main card JSON.  This is a better\nway to add custom editor props to the Card.",
      "type": {
        "name": "func"
      },
      "required": false
    },
    "dataItems": {
      "defaultValue": {
        "value": "[]",
        "computed": false
      },
      "description": "an array of dataItems to be included on each card\nthis prop will be ignored if getValidDataItems is defined",
      "type": {
        "name": "arrayOf",
        "value": {
          "name": "shape",
          "value": {
            "dataSourceId": {
              "name": "string",
              "required": false
            },
            "label": {
              "name": "string",
              "required": false
            }
          }
        }
      },
      "required": false
    },
    "availableDimensions": {
      "defaultValue": {
        "value": "{}",
        "computed": false
      },
      "description": "an object where the keys are available dimensions and the values are the values available for those dimensions\n ex: { manufacturer: ['Rentech', 'GHI Industries'], deviceid: ['73000', '73001', '73002'] }",
      "type": {
        "name": "shape",
        "value": {}
      },
      "required": false
    },
    "supportedCardTypes": {
      "defaultValue": {
        "value": "Object.keys(DASHBOARD_EDITOR_CARD_TYPES)",
        "computed": true
      },
      "description": "An array of card types that are allowed to show up in the list. These keys will also be used in both icons and i18n\nex: [ DASHBOARD_EDITOR_CARD_TYPES.TIMESERIES, DASHBOARD_EDITOR_CARD_TYPES.ALERT, 'CUSTOM', 'ANOTHER_CUSTOM']",
      "type": {
        "name": "arrayOf",
        "value": {
          "name": "string"
        }
      },
      "required": false
    },
    "icons": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "Dictionary of icons that corresponds to both `supportedCardTypes` and `i18n`\nex:\n{\n TIMESERIES: <EscalatorDown />,\n ALERT: <Code24 />,\n CUSTOM: <Basketball32 />,\n ANOTHER_CUSTOM: <Automobile32 />,\n}",
      "type": {
        "name": "objectOf",
        "value": {
          "name": "node"
        }
      },
      "required": false
    },
    "onValidateCardJson": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "If provided, runs the function when the user clicks submit in the Card code JSON editor\nonValidateCardJson(cardConfig)\n@returns Array<string> error strings. return empty array if there is no errors",
      "type": {
        "name": "func"
      },
      "required": false
    },
    "currentBreakpoint": {
      "defaultValue": {
        "value": "'xl'",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "isSummaryDashboard": {
      "defaultValue": {
        "value": "false",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "testId": {
      "defaultValue": {
        "value": "'card-editor'",
        "computed": false
      },
      "description": "Id that can be used for testing",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "dataSeriesItemLinks": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "optional link href's for each card type that will appear in a tooltip",
      "type": {
        "name": "shape",
        "value": {
          "simpleBar": {
            "name": "string",
            "required": false
          },
          "groupedBar": {
            "name": "string",
            "required": false
          },
          "stackedBar": {
            "name": "string",
            "required": false
          },
          "timeSeries": {
            "name": "string",
            "required": false
          },
          "value": {
            "name": "string",
            "required": false
          },
          "custom": {
            "name": "string",
            "required": false
          },
          "table": {
            "name": "string",
            "required": false
          },
          "image": {
            "name": "string",
            "required": false
          }
        }
      },
      "required": false
    },
    "onEditDataItems": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "func"
      },
      "required": false
    },
    "actions": {
      "defaultValue": {
        "value": "defaultDashboardEditorActionsProps",
        "computed": true
      },
      "description": "",
      "type": {
        "name": "custom",
        "raw": "DashboardEditorActionsPropTypes"
      },
      "required": false
    },
    "onShowGallery": {
      "description": "Callback function when user clicks Show Gallery",
      "type": {
        "name": "func"
      },
      "required": true
    },
    "onChange": {
      "description": "Callback function when form data changes, passes the updated card configuration",
      "type": {
        "name": "func"
      },
      "required": true
    },
    "onAddCard": {
      "description": "Callback function when card is added from list",
      "type": {
        "name": "func"
      },
      "required": true
    }
  }
};
var CardEditor$1 = CardEditor;

export { basicCardValidation, CardEditor$1 as default, handleSubmit, hideCardPropertiesForEditor };
