"use strict";

exports.__esModule = true;
exports.createTreeRelationItem = createTreeRelationItem;
exports.getCustomStateRelation = getCustomStateRelation;
exports.getDataSourceDataRelation = getDataSourceDataRelation;
exports.getDictionaryRelation = getDictionaryRelation;
exports.getEngineRuleRelation = getEngineRuleRelation;
exports.getLoopDataSelectedRelation = getLoopDataSelectedRelation;
exports.getModalDialogRelation = getModalDialogRelation;
exports.getPageTreeDataRelation = getPageTreeDataRelation;
exports.getRelationListByProps = getRelationListByProps;
exports.getStorageDataRelation = getStorageDataRelation;
exports.getUrlRelation = getUrlRelation;
exports.getWalletConnectRelation = getWalletConnectRelation;
var _utils = require("../../../_utils/utils");
var _treeDataRelationService = require("../../../_utils/treeDataRelationFn/treeDataRelationService");
var _formKeyType = require("../../../_utils/formKeyType");
var _lodash = require("lodash");
var _type = require("../../../_utils/treeDataRelationFn/type");
var treeDataRelationService = new _treeDataRelationService.TreeDataRelationService();
function comHandleTreeDataFn(treeData) {
  return treeDataRelationService.createRelationDataByTreeData(treeData);
}
function getPageTreeDataRelation() {
  var treeData = treeDataRelationService.getFormStateDataBySchema();
  return comHandleTreeDataFn(treeData);
}
function getDataSourceDataRelation() {
  var treeData = treeDataRelationService.getDataSourceBySchema();
  return comHandleTreeDataFn(treeData);
}
function getDictionaryRelation() {
  var treeData = treeDataRelationService.getDictionaryRelation();
  return comHandleTreeDataFn(treeData);
}
function getEngineRuleRelation() {
  var treeData = treeDataRelationService.getEngineRuleRelation();
  return comHandleTreeDataFn(treeData);
}
function getLoopDataSelectedRelation() {
  var treeData = treeDataRelationService.getLoopDataSelectedRelation();
  return comHandleTreeDataFn(treeData);
}
function getCustomStateRelation() {
  var treeData = treeDataRelationService.getCustomStateBySchema();
  return comHandleTreeDataFn(treeData);
}
function getModalDialogRelation() {
  var treeData = treeDataRelationService.getModalDialogRelation();
  return comHandleTreeDataFn(treeData);
}
function getWalletConnectRelation() {
  var treeData = treeDataRelationService.getWalletConnectRelation();
  return comHandleTreeDataFn(treeData);
}
function getUrlRelation() {
  var treeData = treeDataRelationService.getUrlRelation();
  return comHandleTreeDataFn(treeData);
}
function getStorageDataRelation() {
  var treeData = treeDataRelationService.getStorageDataRelation();
  return comHandleTreeDataFn(treeData);
}
function createTreeRelationItem(config) {
  var name = config.name,
    disabled = config.disabled,
    value = config.value,
    required = config.required,
    formKey = config.formKey,
    type = config.type;
  return {
    id: (0, _utils.uuid)(),
    name: name || '',
    type: type || '',
    disabled: disabled || false,
    data: (0, _utils.getValidString)(value),
    required: required ? (0, _lodash.isNumber)(required) ? required : parseInt(required) : 0,
    treeData: [],
    formKey: formKey ? formKey : _formKeyType.DataSourceType.defaultType
  };
}
function getRelationListByProps(props) {
  var _props$field, _props$field$extraPro;
  var list = (0, _formKeyType.getRelationList)();
  if (props !== null && props !== void 0 && (_props$field = props.field) !== null && _props$field !== void 0 && (_props$field$extraPro = _props$field.extraProps) !== null && _props$field$extraPro !== void 0 && _props$field$extraPro.componentName) {
    var comList = [_type.ComponentName.ModalDefault, _type.ComponentName.Drawer, _type.ComponentName.Modal];
    var name = props.field.extraProps.componentName;
    if (comList.includes(name)) {
      var mate = list.filter(function (item) {
        return item.value === _formKeyType.DataSourceType.materielType;
      }) || [];
      if (mate.length === 0) {
        list.push({
          label: "物料数据",
          value: _formKeyType.DataSourceType.materielType
        });
      }
    }
  }
  return list;
}