function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
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; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
import { BizGlobalDataContext, IconFont, ajax } from '@zgfe/business-lib';
import { Button, Dropdown, Form, Radio, Skeleton, Spin, message } from 'antd';
import React, { useContext, useEffect, useState } from 'react';
import './index.less';
import useDataList from '../../../../hooks/useDataList';
import { getAttrData, getRegisterDataset, getRegisterDetail, initAttrParams, initParams, mappingButtons, nameIsFine, updateWays, webTypeMap } from './utils';
import { PlusOutlined } from '@ant-design/icons';
import FusionItem from './fusionItem';
import IncrementField from './fusionComponents';
import { DatasetType } from './types';
import ZModulesCDP from '../../../../types';
import FusionFrequency from './fusionComponents/frequency';
import _ from 'lodash';
import FusionSelect from './fusionComponents/select';
import VisualStore from '../../../visualJob/create/store';
import { FusionField, FusionFieldTitle, FusionRerun } from './fusionItem/field';
import { ConfirmTip } from '../confirm';
import apis from '../../../../constants/api';
import FusionRadio from './fusionComponents/radio';
import useEnum from '../../../../hooks/useEnum';
export var classPrefix = 'dataset-registration';
var DatasetRegistration = function DatasetRegistration(props) {
  var _basicConfig$publicCo, _basicConfig$publicCo2;
  var taskId = props.taskId;
  var _useContext = useContext(BizGlobalDataContext),
    currentApp = _useContext.currentApp,
    isDemo = _useContext.isDemo,
    basicConfig = _useContext.basicConfig,
    currentProject = _useContext.currentProject;
  var isOpen = Boolean(basicConfig === null || basicConfig === void 0 ? void 0 : (_basicConfig$publicCo = basicConfig.publicConfig) === null || _basicConfig$publicCo === void 0 ? void 0 : (_basicConfig$publicCo2 = _basicConfig$publicCo.subject) === null || _basicConfig$publicCo2 === void 0 ? void 0 : _basicConfig$publicCo2.isOpen);
  var isUser = (currentApp === null || currentApp === void 0 ? void 0 : currentApp.type) == 'user';
  var _useEnum = useEnum(),
    datasetTypeList = _useEnum.datasetTypeList,
    mappingList = _useEnum.mappingList;
  // 数据集列表
  var _useDataList = useDataList(),
    datasetList = _useDataList.datasetList,
    loading = _useDataList.loading;
  var _Form$useForm = Form.useForm(),
    _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
    form = _Form$useForm2[0];
  var _Form$useForm3 = Form.useForm(),
    _Form$useForm4 = _slicedToArray(_Form$useForm3, 1),
    attrForm = _Form$useForm4[0];
  // 上半部分
  var _useState = useState(_objectSpread(_objectSpread({}, initParams), {}, {
      subjectId: currentApp.appId
    })),
    _useState2 = _slicedToArray(_useState, 2),
    formData = _useState2[0],
    setFormData = _useState2[1];
  // 下半部分
  var _useState3 = useState(initAttrParams),
    _useState4 = _slicedToArray(_useState3, 2),
    attrData = _useState4[0],
    setAttrData = _useState4[1];
  var _useState5 = useState(false),
    _useState6 = _slicedToArray(_useState5, 2),
    pageLoading = _useState6[0],
    setPageLoading = _useState6[1];
  var _useState7 = useState(true),
    _useState8 = _slicedToArray(_useState7, 2),
    isInit = _useState8[0],
    setIsInit = _useState8[1];
  var _useState9 = useState([]),
    _useState0 = _slicedToArray(_useState9, 2),
    tableColumns = _useState0[0],
    setTableColumns = _useState0[1];
  // 已登记的数据集列表
  var _useState1 = useState([]),
    _useState10 = _slicedToArray(_useState1, 2),
    registeredDatasets = _useState10[0],
    setRegisteredDatasets = _useState10[1];
  useEffect(function () {
    var flag = false;
    Promise.all([getRegisterDataset(currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId)].concat(taskId ? [getRegisterDetail(taskId, currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId)] : [])).then(function (arr) {
      setRegisteredDatasets(arr[0] || []);
      if (taskId && arr[1]) {
        setFormData(_objectSpread(_objectSpread({}, arr[1]), {}, {
          subjectId: currentApp.appId
        }));
        setAttrData(getAttrData(arr[1]));
        if (arr[1].datasetId) {
          flag = true;
          queryDataset(arr[1].datasetId);
        }
      }
    }).finally(function () {
      setTimeout(function () {
        if (flag) return;
        setIsInit(false);
      }, 0);
    });
  }, []);
  var onBack = function onBack() {
    props.onBack && props.onBack();
  };
  var onValuesChange = function onValuesChange(changedValues, allValues) {
    var data = _.cloneDeep(allValues);
    // 数据集类型改变时，属性内容清空，明细数据和事件/用户数据不同时，更新方式和更新频率更改
    if (changedValues.datasetType && changedValues.datasetType !== formData.datasetType) {
      if (changedValues.datasetType === 3) {
        data = {
          datasetId: allValues.datasetId,
          datasetType: allValues.datasetType
        };
      } else {
        data = _objectSpread(_objectSpread({}, initParams), data);
        clearAttrs();
      }
    } else if (changedValues.datasetId && changedValues.datasetId !== formData.datasetId) {
      clearAttrs();
      form.setFieldValue('increment', undefined);
      data.increment = undefined;
      // 数据集改变，请求该数据集的字段
      queryDataset(changedValues.datasetId);
    }
    setFormData(_objectSpread(_objectSpread({}, data), {}, {
      subjectId: currentApp.appId
    }));
  };
  function queryDataset(id) {
    setPageLoading(true);
    VisualStore.queryDatasetInfo(id).then(function (list) {
      if (list) {
        setTableColumns(list.map(function (item) {
          return _objectSpread(_objectSpread({}, item), {}, {
            label: "".concat(item.webType ? webTypeMap[item.webType] : '').concat(item.name)
          });
        }));
      }
    }).catch(function (error) {
      console.error('获取数据集字段列表失败', error);
    }).finally(function () {
      setTimeout(function () {
        setPageLoading(false);
        setIsInit(false);
      }, 0);
    });
  }
  var onAttrsChange = function onAttrsChange(changedValues, allValues) {
    setAttrData(allValues);
  };
  // 清空属性
  var clearAttrs = function clearAttrs() {
    initAttr();
    attrForm.setFieldValue('eventName', '');
    attrForm.setFieldValue('userIdentify', '');
    attrForm.setFieldValue('timeField', '');
    attrForm.setFieldValue('attrs', [{
      target: {
        hasMapping: true
      }
    }]);
  };
  // 初始化属性列表
  var initAttr = function initAttr() {
    setAttrData(function () {
      return {
        attrs: [{
          target: {
            hasMapping: true
          }
        }]
      };
    });
  };
  // 提交
  var onSubmit = /*#__PURE__*/function () {
    var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
      var type, validate;
      return _regenerator().w(function (_context) {
        while (1) switch (_context.n) {
          case 0:
            if (formData) {
              _context.n = 1;
              break;
            }
            return _context.a(2);
          case 1:
            type = formData.datasetType;
            validate = Promise.all([form.validateFields()].concat(type !== 3 ? [attrForm.validateFields()] : []));
            validate.then(function () {
              var params = _objectSpread(_objectSpread({}, formData), {}, {
                subjectId: currentApp.appId
              }, type !== 3 ? attrData : {});
              setPageLoading(true);
              var url = taskId ? apis.editFusion : apis.createFusion;
              ajax(url, {
                method: 'post',
                data: _objectSpread({
                  appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
                  id: taskId
                }, params)
              }).then(function (res) {
                if (!res) return;
                if (!taskId) {
                  // 新建
                  ConfirmTip({
                    content: '任务创建成功， 是否立即启用',
                    okLabel: '启用',
                    cancelLabel: '不启用'
                  }, function () {
                    ajax(apis.updateJobStatus, {
                      method: 'post',
                      data: {
                        id: res.data,
                        appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
                        enable: true
                      }
                    }).then(function () {
                      props.onOk && props.onOk();
                    });
                  }, function () {
                    props.onOk && props.onOk();
                  });
                } else {
                  message.success('编辑成功');
                  props.onOk && props.onOk();
                }
              }).finally(function () {
                setPageLoading(false);
              });
            }).catch(function (errorInfo) {
              console.log('校验失败:', errorInfo);
            });
          case 2:
            return _context.a(2);
        }
      }, _callee);
    }));
    return function onSubmit() {
      return _ref.apply(this, arguments);
    };
  }();
  return /*#__PURE__*/React.createElement(Spin, {
    spinning: pageLoading,
    wrapperClassName: "".concat(classPrefix, "-loading")
  }, /*#__PURE__*/React.createElement("div", {
    className: classPrefix
  }, /*#__PURE__*/React.createElement("div", {
    className: "".concat(classPrefix, "-title")
  }, /*#__PURE__*/React.createElement("a", {
    className: "".concat(classPrefix, "-title-back"),
    onClick: onBack
  }, /*#__PURE__*/React.createElement(IconFont, {
    type: "fanhuiicon"
  }), "\u8FD4\u56DE"), /*#__PURE__*/React.createElement("span", {
    className: "".concat(classPrefix, "-title-txt")
  }, "".concat(props.taskId ? '编辑' : '创建', "\u6570\u636E\u878D\u5408"))), /*#__PURE__*/React.createElement(Skeleton, {
    loading: loading || isInit
  }, /*#__PURE__*/React.createElement("div", {
    className: "".concat(classPrefix, "-container")
  }, /*#__PURE__*/React.createElement("div", {
    className: "".concat(classPrefix, "-content")
  }, /*#__PURE__*/React.createElement("a", {
    className: "".concat(classPrefix, "-help"),
    target: "_blank",
    href: "https://docs.zhugeio.com/datamanager/data_fusion.html"
  }, "\u67E5\u770B\u5E2E\u52A9\u6587\u6863"), /*#__PURE__*/React.createElement(Form, {
    initialValues: formData,
    colon: false,
    className: "".concat(classPrefix, "-content-panel ").concat(classPrefix, "-content-form"),
    form: form,
    onValuesChange: onValuesChange
  }, /*#__PURE__*/React.createElement(Form.Item, {
    label: "\u9009\u62E9\u6570\u636E\u96C6",
    name: "datasetId",
    rules: [{
      required: true,
      message: '请选择数据集'
    }]
  }, /*#__PURE__*/React.createElement(FusionSelect, {
    placeholder: "\u8BF7\u9009\u62E9\u6570\u636E\u96C6",
    labelField: "name",
    options: datasetList || [],
    disableItemList: registeredDatasets
  })), isOpen && (/*#__PURE__*/React.createElement(Form.Item, {
    label: "\u5173\u8054\u4E3B\u4F53",
    name: "subjectId",
    rules: [{
      required: true,
      message: '请选择关联主体'
    }]
  }, /*#__PURE__*/React.createElement(FusionSelect, {
    disable: true,
    placeholder: "\u8BF7\u9009\u62E9\u5173\u8054\u4E3B\u4F53",
    labelField: "appName",
    keyField: "id",
    options: currentProject.appList || []
  }))), /*#__PURE__*/React.createElement(Form.Item, {
    label: "\u9009\u62E9\u6570\u636E\u552F\u4E00\u6807\u8BC6",
    name: "dataId",
    rules: [{
      required: true,
      message: '请选择数据唯一标识'
    }]
  }, /*#__PURE__*/React.createElement(FusionSelect, {
    placeholder: "\u8BF7\u9009\u62E9\u6570\u636E\u552F\u4E00\u6807\u8BC6",
    labelField: "name",
    keyField: "name",
    options: tableColumns || [],
    optionType: "number",
    tip: "\u9009\u62E9\u7528\u4E8E\u6807\u8BC6\u6570\u636E\u552F\u4E00\u6027\u7684\u5B57\u6BB5\uFF0C\u4F8B\u5982\u7528\u6237id\uFF0C\u53EA\u80FD\u9009\u5BF9\u6570\u503C\u7C7B\u7684\u5B57\u6BB5\u3002"
  })), /*#__PURE__*/React.createElement(Form.Item, {
    label: "\u6570\u636E\u96C6\u7C7B\u578B",
    name: "datasetType"
  }, /*#__PURE__*/React.createElement(Radio.Group, {
    options: datasetTypeList
  })), /*#__PURE__*/React.createElement(Form.Item, {
    noStyle: true,
    shouldUpdate: function shouldUpdate(prevValues, curValues) {
      return prevValues.datasetType !== curValues.datasetType || prevValues.syncType !== curValues.syncType || prevValues.datasetId !== curValues.datasetId;
    }
  }, function (_ref2) {
    var getFieldValue = _ref2.getFieldValue;
    var type = getFieldValue('datasetType');
    var sType = getFieldValue('syncType');
    if (type === DatasetType.DETAIL) {
      return /*#__PURE__*/React.createElement(Form.Item, {
        label: "".concat(!isUser ? '主体' : '用户', "\u6807\u8BC6\u5B57\u6BB5"),
        name: "userIdentify",
        rules: [{
          required: true,
          message: "\u8BF7\u9009\u62E9".concat(!isUser ? '主体' : '用户', "\u6807\u8BC6\u5B57\u6BB5")
        }]
      }, /*#__PURE__*/React.createElement(FusionSelect, {
        labelField: "name",
        keyField: "name",
        options: tableColumns,
        placeholder: "\u8BF7\u9009\u62E9".concat(!isUser ? '主体' : '用户', "\u6807\u8BC6\u5B57\u6BB5")
      }));
    }
    return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Form.Item, {
      label: "\u66F4\u65B0\u65B9\u5F0F",
      name: "syncType"
    }, /*#__PURE__*/React.createElement(FusionRadio, {
      options: updateWays
    })), sType === ZModulesCDP.DataSet.SyncType.incre && (/*#__PURE__*/React.createElement(Form.Item, {
      label: " ",
      name: "increment",
      className: "".concat(classPrefix, "-form-item"),
      rules: [{
        validator: function validator(_, value) {
          if (!value || !value.name) return Promise.reject('请选择字段');
          if (value.webType === 'date' && !value.format) {
            return Promise.reject();
          }
          return Promise.resolve();
        }
      }]
    }, /*#__PURE__*/React.createElement(IncrementField, {
      tableColumns: tableColumns
    }))), /*#__PURE__*/React.createElement(Form.Item, {
      label: "\u66F4\u65B0\u9891\u7387",
      name: "updateFrequency",
      rules: [{
        validateTrigger: ['submit'],
        validator: function validator(_, value) {
          var type = value.type,
            rule = value.rule;
          var msg = '';
          if (type === 2) {
            if (rule.unit === 5) {
              if (!rule.time) {
                msg = '请选择时间';
              }
            } else {
              if (rule.unit > 1 && !rule.day.length) {
                msg = '请选择日期';
              }
              if (rule.unit > 0 && !rule.time) {
                msg = '请选择小时';
              }
            }
          }
          if (msg) {
            return Promise.reject(msg);
          }
          return Promise.resolve();
        }
      }]
    }, /*#__PURE__*/React.createElement(FusionFrequency, null)), /*#__PURE__*/React.createElement(Form.Item, {
      label: "\u5931\u8D25\u91CD\u8DD1",
      name: "rerun"
    }, /*#__PURE__*/React.createElement(FusionRerun, null)));
  })), (formData === null || formData === void 0 ? void 0 : formData.datasetType) && (formData === null || formData === void 0 ? void 0 : formData.datasetType) !== DatasetType.DETAIL && (/*#__PURE__*/React.createElement("div", {
    className: "".concat(classPrefix, "-content-panel")
  }, /*#__PURE__*/React.createElement(FusionFieldTitle, null), /*#__PURE__*/React.createElement(Form, {
    initialValues: attrData,
    colon: false,
    form: attrForm,
    layout: "vertical",
    onValuesChange: onAttrsChange
  }, mappingList[(formData === null || formData === void 0 ? void 0 : formData.datasetType) - 1].map(function (item, index) {
    if (item.type === 'list') {
      return /*#__PURE__*/React.createElement(Form.Item, {
        label: item.label,
        key: "".concat(index, "-").concat(item.id, "-").concat(formData.datasetId),
        required: true
      }, /*#__PURE__*/React.createElement(Form.List, {
        name: item.id
      }, function (fields, _ref3) {
        var add = _ref3.add,
          remove = _ref3.remove;
        return /*#__PURE__*/React.createElement(React.Fragment, null, fields.map(function (field) {
          return /*#__PURE__*/React.createElement(Form.Item, _objectSpread(_objectSpread({}, field), {}, {
            key: field.key,
            rules: [{
              validateTrigger: ['submit'],
              validator: function validator(_, value) {
                if (!value || !value.source || !value.target.name) {
                  return Promise.reject('请完善属性字段');
                }
                return Promise.resolve();
              }
            }, {
              validator: function validator(_, value) {
                if (!value.target.hasMapping) {
                  var msg = nameIsFine(formData.datasetType, value.target.name);
                  if (msg) {
                    return Promise.reject();
                  }
                }
                return Promise.resolve();
              }
            }]
          }), /*#__PURE__*/React.createElement(FusionItem, {
            label: item.label,
            type: formData === null || formData === void 0 ? void 0 : formData.datasetType,
            tableColumns: tableColumns,
            selectList: attrData.attrs,
            enableDelete: fields.length > 1,
            onDelete: function onDelete() {
              return remove(field.name);
            }
          }));
        }), /*#__PURE__*/React.createElement(Form.Item, null, /*#__PURE__*/React.createElement(Dropdown, {
          trigger: ['click'],
          disabled: (formData === null || formData === void 0 ? void 0 : formData.datasetType) === 1 && fields.length >= 100,
          menu: {
            items: mappingButtons,
            onClick: function onClick(_ref4) {
              var key = _ref4.key;
              return add({
                target: {
                  hasMapping: key == '1',
                  webType: key == '2' ? 'string' : undefined
                }
              });
            }
          }
        }, /*#__PURE__*/React.createElement(Button, {
          type: "primary",
          icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
        }, "\u6DFB\u52A0\u5B57\u6BB5\u6620\u5C04"))));
      }));
    }
    return /*#__PURE__*/React.createElement(Form.Item, {
      label: item.label,
      key: "".concat(index, "-").concat(item.id, "-").concat(formData.datasetId),
      name: item.id,
      rules: [{
        required: true,
        message: "\u8BF7\u9009\u62E9".concat(item.label)
      }]
    }, /*#__PURE__*/React.createElement(FusionField, {
      label: item.label,
      defaultTarget: item.defaultTarget,
      tableColumns: tableColumns,
      sourceType: item.type
    }));
  }))))), /*#__PURE__*/React.createElement("div", {
    className: "".concat(classPrefix, "-container-option")
  }, /*#__PURE__*/React.createElement(Button, {
    type: "text",
    onClick: onBack
  }, "\u53D6\u6D88"), /*#__PURE__*/React.createElement(Button, {
    type: "primary",
    onClick: onSubmit,
    disabled: isDemo
  }, "\u786E\u5B9A"))))));
};
export default DatasetRegistration;