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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(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 _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _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(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
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(arr) { if (Array.isArray(arr)) return arr; }
import React, { useState, useEffect, useCallback, useRef } from 'react';
import { message } from 'antd';
import { Button } from '@pisell/materials';
import { PlusOutlined } from '@ant-design/icons';
import { locales } from '@pisell/utils';
import useEngineContext from "../../../hooks/useEngineContext";
import { SectionList, SettingsTable, GroupModal, ItemModal } from "./components";
import { createGroup, updateGroup, deleteGroup, sortGroups, getSectionList, getGroupList, createItem, updateItem, deleteItem, sortItems } from "./services";
import { validateDefaultValue, parseDefaultValue } from "./utils/typeValidation";
import localeTexts from "./locales";
import "./index.less";

// 注释掉这里的初始化，使用 useEffect 中的初始化
// locales.init(localeTexts, localStorage.getItem('umi_locale') || 'en');

var Registry = function Registry(_ref) {
  var _context$engine2;
  var className = _ref.className,
    style = _ref.style,
    _ref$sections = _ref.sections,
    sections = _ref$sections === void 0 ? [] : _ref$sections,
    selectedSectionId = _ref.selectedSectionId,
    onSectionSelect = _ref.onSectionSelect,
    onDataChange = _ref.onDataChange;
  var context = useEngineContext();
  var request = context.appHelper.utils.request;
  var _useState = useState(sections),
    _useState2 = _slicedToArray(_useState, 2),
    localSections = _useState2[0],
    setLocalSections = _useState2[1];
  var _useState3 = useState(selectedSectionId || (sections.length > 0 ? sections[0].id : 0)),
    _useState4 = _slicedToArray(_useState3, 2),
    currentSectionId = _useState4[0],
    setCurrentSectionId = _useState4[1];

  // 分页相关状态
  var _useState5 = useState(false),
    _useState6 = _slicedToArray(_useState5, 2),
    loading = _useState6[0],
    setLoading = _useState6[1];
  var _useState7 = useState(true),
    _useState8 = _slicedToArray(_useState7, 2),
    hasMore = _useState8[0],
    setHasMore = _useState8[1];
  var _useState9 = useState(1),
    _useState10 = _slicedToArray(_useState9, 2),
    currentPage = _useState10[0],
    setCurrentPage = _useState10[1];
  var _useState11 = useState(20),
    _useState12 = _slicedToArray(_useState11, 1),
    pageSize = _useState12[0];
  var _useState13 = useState(true),
    _useState14 = _slicedToArray(_useState13, 2),
    isInitialLoad = _useState14[0],
    setIsInitialLoad = _useState14[1];

  // 组数据状态
  var _useState15 = useState([]),
    _useState16 = _slicedToArray(_useState15, 2),
    groupList = _useState16[0],
    setGroupList = _useState16[1];
  var _useState17 = useState(false),
    _useState18 = _slicedToArray(_useState17, 2),
    groupLoading = _useState18[0],
    setGroupLoading = _useState18[1];

  // 使用 ref 存储最新的回调函数和上次加载的section code，避免依赖项问题
  var onDataChangeRef = useRef(onDataChange);
  var lastLoadedSectionCodeRef = useRef('');
  onDataChangeRef.current = onDataChange;

  // 模态框状态
  var _useState19 = useState(false),
    _useState20 = _slicedToArray(_useState19, 2),
    groupModalOpen = _useState20[0],
    setGroupModalOpen = _useState20[1];
  var _useState21 = useState(false),
    _useState22 = _slicedToArray(_useState21, 2),
    itemModalOpen = _useState22[0],
    setItemModalOpen = _useState22[1];
  var _useState23 = useState('add'),
    _useState24 = _slicedToArray(_useState23, 2),
    modalType = _useState24[0],
    setModalType = _useState24[1];
  var _useState25 = useState(),
    _useState26 = _slicedToArray(_useState25, 2),
    editingGroup = _useState26[0],
    setEditingGroup = _useState26[1];
  var _useState27 = useState(),
    _useState28 = _slicedToArray(_useState27, 2),
    editingItem = _useState28[0],
    setEditingItem = _useState28[1];
  var _useState29 = useState(0),
    _useState30 = _slicedToArray(_useState29, 2),
    targetGroupId = _useState30[0],
    setTargetGroupId = _useState30[1];

  // 创建组
  var handleCreateGroup = /*#__PURE__*/function () {
    var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
      var response, _currentSection;
      return _regeneratorRuntime().wrap(function _callee$(_context) {
        while (1) switch (_context.prev = _context.next) {
          case 0:
            _context.prev = 0;
            _context.next = 3;
            return createGroup(request, params);
          case 3:
            response = _context.sent;
            if (!currentSectionId) {
              _context.next = 9;
              break;
            }
            _currentSection = localSections.find(function (s) {
              return s.id === currentSectionId;
            });
            if (!_currentSection) {
              _context.next = 9;
              break;
            }
            _context.next = 9;
            return loadGroupData(_currentSection.code, true);
          case 9:
            message.success(locales.getText('registry.message.save.success'));
            return _context.abrupt("return", response);
          case 13:
            _context.prev = 13;
            _context.t0 = _context["catch"](0);
            message.error(locales.getText('registry.message.create.group.error'));
            throw _context.t0;
          case 17:
          case "end":
            return _context.stop();
        }
      }, _callee, null, [[0, 13]]);
    }));
    return function handleCreateGroup(_x) {
      return _ref2.apply(this, arguments);
    };
  }();

  // 更新组
  var handleUpdateGroup = /*#__PURE__*/function () {
    var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
      var response, _currentSection2;
      return _regeneratorRuntime().wrap(function _callee2$(_context2) {
        while (1) switch (_context2.prev = _context2.next) {
          case 0:
            _context2.prev = 0;
            _context2.next = 3;
            return updateGroup(request, params);
          case 3:
            response = _context2.sent;
            if (!currentSectionId) {
              _context2.next = 9;
              break;
            }
            _currentSection2 = localSections.find(function (s) {
              return s.id === currentSectionId;
            });
            if (!_currentSection2) {
              _context2.next = 9;
              break;
            }
            _context2.next = 9;
            return loadGroupData(_currentSection2.code, true);
          case 9:
            message.success(locales.getText('registry.message.save.success'));
            return _context2.abrupt("return", response);
          case 13:
            _context2.prev = 13;
            _context2.t0 = _context2["catch"](0);
            throw _context2.t0;
          case 16:
          case "end":
            return _context2.stop();
        }
      }, _callee2, null, [[0, 13]]);
    }));
    return function handleUpdateGroup(_x2) {
      return _ref3.apply(this, arguments);
    };
  }();

  // 删除组
  var handleDeleteGroup = /*#__PURE__*/function () {
    var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
      var response, _currentSection3;
      return _regeneratorRuntime().wrap(function _callee3$(_context3) {
        while (1) switch (_context3.prev = _context3.next) {
          case 0:
            _context3.prev = 0;
            _context3.next = 3;
            return deleteGroup(request, params);
          case 3:
            response = _context3.sent;
            if (!currentSectionId) {
              _context3.next = 9;
              break;
            }
            _currentSection3 = localSections.find(function (s) {
              return s.id === currentSectionId;
            });
            if (!_currentSection3) {
              _context3.next = 9;
              break;
            }
            _context3.next = 9;
            return loadGroupData(_currentSection3.code, true);
          case 9:
            message.success(locales.getText('registry.message.delete.success'));
            return _context3.abrupt("return", response);
          case 13:
            _context3.prev = 13;
            _context3.t0 = _context3["catch"](0);
            throw _context3.t0;
          case 16:
          case "end":
            return _context3.stop();
        }
      }, _callee3, null, [[0, 13]]);
    }));
    return function handleDeleteGroup(_x3) {
      return _ref4.apply(this, arguments);
    };
  }();

  // 创建设置项
  var handleCreateItem = /*#__PURE__*/function () {
    var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
      var response, _currentSection4;
      return _regeneratorRuntime().wrap(function _callee4$(_context4) {
        while (1) switch (_context4.prev = _context4.next) {
          case 0:
            _context4.prev = 0;
            _context4.next = 3;
            return createItem(request, params);
          case 3:
            response = _context4.sent;
            if (!currentSectionId) {
              _context4.next = 9;
              break;
            }
            _currentSection4 = localSections.find(function (s) {
              return s.id === currentSectionId;
            });
            if (!_currentSection4) {
              _context4.next = 9;
              break;
            }
            _context4.next = 9;
            return loadGroupData(_currentSection4.code, true);
          case 9:
            message.success(locales.getText('registry.message.save.success'));
            return _context4.abrupt("return", response);
          case 13:
            _context4.prev = 13;
            _context4.t0 = _context4["catch"](0);
            throw _context4.t0;
          case 16:
          case "end":
            return _context4.stop();
        }
      }, _callee4, null, [[0, 13]]);
    }));
    return function handleCreateItem(_x4) {
      return _ref5.apply(this, arguments);
    };
  }();

  // 更新设置项
  var handleUpdateItem = /*#__PURE__*/function () {
    var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
      var response, _currentSection5;
      return _regeneratorRuntime().wrap(function _callee5$(_context5) {
        while (1) switch (_context5.prev = _context5.next) {
          case 0:
            _context5.prev = 0;
            _context5.next = 3;
            return updateItem(request, params);
          case 3:
            response = _context5.sent;
            if (!currentSectionId) {
              _context5.next = 9;
              break;
            }
            _currentSection5 = localSections.find(function (s) {
              return s.id === currentSectionId;
            });
            if (!_currentSection5) {
              _context5.next = 9;
              break;
            }
            _context5.next = 9;
            return loadGroupData(_currentSection5.code, true);
          case 9:
            message.success(locales.getText('registry.message.save.success'));
            return _context5.abrupt("return", response);
          case 13:
            _context5.prev = 13;
            _context5.t0 = _context5["catch"](0);
            throw _context5.t0;
          case 16:
          case "end":
            return _context5.stop();
        }
      }, _callee5, null, [[0, 13]]);
    }));
    return function handleUpdateItem(_x5) {
      return _ref6.apply(this, arguments);
    };
  }();

  // 删除设置项
  var handleDeleteItem = /*#__PURE__*/function () {
    var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
      var response, _currentSection6;
      return _regeneratorRuntime().wrap(function _callee6$(_context6) {
        while (1) switch (_context6.prev = _context6.next) {
          case 0:
            _context6.prev = 0;
            _context6.next = 3;
            return deleteItem(request, params);
          case 3:
            response = _context6.sent;
            if (!currentSectionId) {
              _context6.next = 9;
              break;
            }
            _currentSection6 = localSections.find(function (s) {
              return s.id === currentSectionId;
            });
            if (!_currentSection6) {
              _context6.next = 9;
              break;
            }
            _context6.next = 9;
            return loadGroupData(_currentSection6.code, true);
          case 9:
            message.success(locales.getText('registry.message.delete.success'));
            return _context6.abrupt("return", response);
          case 13:
            _context6.prev = 13;
            _context6.t0 = _context6["catch"](0);
            console.error('Failed to delete item:', _context6.t0);
            // message.error(locales.getText('registry.message.delete.item.error'));
            throw _context6.t0;
          case 17:
          case "end":
            return _context6.stop();
        }
      }, _callee6, null, [[0, 13]]);
    }));
    return function handleDeleteItem(_x6) {
      return _ref7.apply(this, arguments);
    };
  }();

  // 组排序
  var handleGroupReorder = /*#__PURE__*/function () {
    var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(groupIds) {
      var _currentSection7, reorderedGroups, _currentSection8;
      return _regeneratorRuntime().wrap(function _callee7$(_context7) {
        while (1) switch (_context7.prev = _context7.next) {
          case 0:
            _context7.prev = 0;
            // 获取当前section的code
            _currentSection7 = localSections.find(function (s) {
              return s.id === currentSectionId;
            });
            if (_currentSection7) {
              _context7.next = 4;
              break;
            }
            throw new Error('Current section not found');
          case 4:
            _context7.next = 6;
            return sortGroups(request, {
              section_code: _currentSection7.code,
              group_ids: groupIds
            });
          case 6:
            // API调用成功后，更新本地状态
            reorderedGroups = groupIds.map(function (id) {
              var group = groupList.find(function (g) {
                return g.id === id;
              });
              return group ? _objectSpread({}, group) : null;
            }).filter(Boolean);
            setGroupList(reorderedGroups);
            message.success(locales.getText('registry.message.reorder.success'));
            _context7.next = 18;
            break;
          case 11:
            _context7.prev = 11;
            _context7.t0 = _context7["catch"](0);
            console.error('Failed to reorder groups:', _context7.t0);
            // message.error(locales.getText('registry.message.reorder.error'));

            // 如果API调用失败，重新加载组数据以恢复原始状态
            _currentSection8 = localSections.find(function (s) {
              return s.id === currentSectionId;
            });
            if (!_currentSection8) {
              _context7.next = 18;
              break;
            }
            _context7.next = 18;
            return loadGroupData(_currentSection8.code, true);
          case 18:
          case "end":
            return _context7.stop();
        }
      }, _callee7, null, [[0, 11]]);
    }));
    return function handleGroupReorder(_x7) {
      return _ref8.apply(this, arguments);
    };
  }();

  // 设置项移动
  var handleItemMove = /*#__PURE__*/function () {
    var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(itemId, targetGroupId, newOrder) {
      var targetGroup, targetGroupItems, existingIndex, _targetGroupItems$spl, _targetGroupItems$spl2, movedItem, allItems, _movedItem, sortedItemIds, _currentSection9, _currentSection10;
      return _regeneratorRuntime().wrap(function _callee8$(_context8) {
        while (1) switch (_context8.prev = _context8.next) {
          case 0:
            _context8.prev = 0;
            // 找到目标组
            targetGroup = groupList.find(function (g) {
              return g.id === targetGroupId;
            });
            if (targetGroup) {
              _context8.next = 4;
              break;
            }
            throw new Error('Target group not found');
          case 4:
            // 获取目标组的所有设置项ID，并在指定位置插入当前移动的项
            targetGroupItems = _toConsumableArray(targetGroup.items); // 如果是跨组移动，需要先移除原来的项，然后在新位置插入
            existingIndex = targetGroupItems.findIndex(function (item) {
              return item.id === itemId;
            });
            if (existingIndex !== -1) {
              // 同组内移动
              _targetGroupItems$spl = targetGroupItems.splice(existingIndex, 1), _targetGroupItems$spl2 = _slicedToArray(_targetGroupItems$spl, 1), movedItem = _targetGroupItems$spl2[0];
              targetGroupItems.splice(newOrder, 0, movedItem);
            } else {
              // 跨组移动，需要找到原来的项
              allItems = groupList.reduce(function (acc, g) {
                return [].concat(_toConsumableArray(acc), _toConsumableArray(g.items));
              }, []);
              _movedItem = allItems.find(function (item) {
                return item.id === itemId;
              });
              if (_movedItem) {
                targetGroupItems.splice(newOrder, 0, _movedItem);
              }
            }

            // 构建排序后的item_ids数组
            sortedItemIds = targetGroupItems.map(function (item) {
              return item.id;
            }); // 调用排序API
            _context8.next = 10;
            return sortItems(request, {
              id: itemId,
              group_id: targetGroupId.toString(),
              item_ids: sortedItemIds
            });
          case 10:
            // API调用成功后，重新加载组数据以获取最新状态
            _currentSection9 = localSections.find(function (s) {
              return s.id === currentSectionId;
            });
            if (!_currentSection9) {
              _context8.next = 14;
              break;
            }
            _context8.next = 14;
            return loadGroupData(_currentSection9.code, true);
          case 14:
            message.success(locales.getText('registry.message.move.success'));
            _context8.next = 24;
            break;
          case 17:
            _context8.prev = 17;
            _context8.t0 = _context8["catch"](0);
            console.error('Failed to move item:', _context8.t0);
            // message.error(locales.getText('registry.message.move.error'));

            // 如果API调用失败，重新加载组数据以恢复原始状态
            _currentSection10 = localSections.find(function (s) {
              return s.id === currentSectionId;
            });
            if (!_currentSection10) {
              _context8.next = 24;
              break;
            }
            _context8.next = 24;
            return loadGroupData(_currentSection10.code, true);
          case 24:
          case "end":
            return _context8.stop();
        }
      }, _callee8, null, [[0, 17]]);
    }));
    return function handleItemMove(_x8, _x9, _x10) {
      return _ref9.apply(this, arguments);
    };
  }();

  // 加载组数据
  var loadGroupData = useCallback( /*#__PURE__*/function () {
    var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(sectionCode) {
      var forceRefresh,
        response,
        newGroups,
        _args9 = arguments;
      return _regeneratorRuntime().wrap(function _callee9$(_context9) {
        while (1) switch (_context9.prev = _context9.next) {
          case 0:
            forceRefresh = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : false;
            if (!(groupLoading || !forceRefresh && lastLoadedSectionCodeRef.current === sectionCode)) {
              _context9.next = 3;
              break;
            }
            return _context9.abrupt("return");
          case 3:
            lastLoadedSectionCodeRef.current = sectionCode;
            setGroupLoading(true);
            _context9.prev = 5;
            _context9.next = 8;
            return getGroupList(request, {
              page: 1,
              pageSize: 100,
              // 获取所有组数据
              filter: {
                section_code: sectionCode
              }
            });
          case 8:
            response = _context9.sent;
            newGroups = response.data || [];
            setGroupList(newGroups);
            _context9.next = 17;
            break;
          case 13:
            _context9.prev = 13;
            _context9.t0 = _context9["catch"](5);
            console.error('Failed to load group data:', _context9.t0);
            // message.error(locales.getText('registry.message.load.failed'));
            setGroupList([]);
          case 17:
            _context9.prev = 17;
            setGroupLoading(false);
            return _context9.finish(17);
          case 20:
          case "end":
            return _context9.stop();
        }
      }, _callee9, null, [[5, 13, 17, 20]]);
    }));
    return function (_x11) {
      return _ref10.apply(this, arguments);
    };
  }(), []); // 移除所有依赖项，使用ref来避免无限循环

  // 加载区块数据
  var loadSectionData = useCallback( /*#__PURE__*/function () {
    var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(page) {
      var isLoadMore,
        response,
        newSections,
        totalPage,
        _onDataChangeRef$curr2,
        _args10 = arguments;
      return _regeneratorRuntime().wrap(function _callee10$(_context10) {
        while (1) switch (_context10.prev = _context10.next) {
          case 0:
            isLoadMore = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : false;
            if (!loading) {
              _context10.next = 3;
              break;
            }
            return _context10.abrupt("return");
          case 3:
            setLoading(true);
            _context10.prev = 4;
            _context10.next = 7;
            return getSectionList(request, {
              page: page,
              pageSize: pageSize,
              filter: {}
            });
          case 7:
            response = _context10.sent;
            newSections = response.data || [];
            if (isLoadMore) {
              // 加载更多时追加数据
              setLocalSections(function (prev) {
                return [].concat(_toConsumableArray(prev), _toConsumableArray(newSections));
              });
            } else {
              // 初始加载时替换数据
              setLocalSections(newSections);
              // 如果当前没有选中的section或currentSectionId为null/0，设置为第一个section
              if (newSections.length > 0 && (!currentSectionId || currentSectionId === 0)) {
                setCurrentSectionId(newSections[0].id);
              }
            }

            // 判断是否还有更多数据 - 使用新的 meta 信息
            totalPage = response.meta.totalPage;
            setHasMore(page < totalPage);
            if (isLoadMore) {
              setLocalSections(function (prev) {
                var _onDataChangeRef$curr;
                var updatedSections = [].concat(_toConsumableArray(prev), _toConsumableArray(newSections));
                (_onDataChangeRef$curr = onDataChangeRef.current) === null || _onDataChangeRef$curr === void 0 || _onDataChangeRef$curr.call(onDataChangeRef, updatedSections);
                return updatedSections;
              });
            } else {
              (_onDataChangeRef$curr2 = onDataChangeRef.current) === null || _onDataChangeRef$curr2 === void 0 || _onDataChangeRef$curr2.call(onDataChangeRef, newSections);
            }
            _context10.next = 18;
            break;
          case 15:
            _context10.prev = 15;
            _context10.t0 = _context10["catch"](4);
            console.error('Failed to load section data:', _context10.t0);
            // message.error(locales.getText('registry.message.load.failed'));
          case 18:
            _context10.prev = 18;
            setLoading(false);
            return _context10.finish(18);
          case 21:
          case "end":
            return _context10.stop();
        }
      }, _callee10, null, [[4, 15, 18, 21]]);
    }));
    return function (_x12) {
      return _ref11.apply(this, arguments);
    };
  }(), [loading, pageSize, currentSectionId]); // 移除 onDataChange 依赖

  // 加载更多数据
  var handleLoadMore = useCallback(function () {
    if (!hasMore || loading) return;
    var nextPage = currentPage + 1;
    setCurrentPage(nextPage);
    loadSectionData(nextPage, true);
  }, [hasMore, loading, currentPage]); // 移除 loadSectionData 依赖

  // 初始化多语言
  useEffect(function () {
    var _context$engine;
    var currentLocale = (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || localStorage.getItem('umi_locale') || 'zh-CN';
    locales.init(localeTexts, currentLocale);
  }, [context === null || context === void 0 || (_context$engine2 = context.engine) === null || _context$engine2 === void 0 || (_context$engine2 = _context$engine2.props) === null || _context$engine2 === void 0 ? void 0 : _context$engine2.locale]);

  // 初始加载数据
  useEffect(function () {
    if (isInitialLoad) {
      setIsInitialLoad(false);
      loadSectionData(1, false);
    }
  }, [isInitialLoad]); // 移除 loadSectionData 依赖，避免无限循环

  // 同步外部区块数据（仅在不是初始加载时且有外部数据时）
  useEffect(function () {
    if (!isInitialLoad && sections && sections.length > 0) {
      setLocalSections(sections);
    }
  }, [sections, isInitialLoad]);

  // 同步外部选中区块
  useEffect(function () {
    if (selectedSectionId) {
      setCurrentSectionId(selectedSectionId);
    }
  }, [selectedSectionId]);

  // 当currentSectionId改变时加载对应的组数据
  useEffect(function () {
    if (currentSectionId && localSections.length > 0) {
      var selectedSection = localSections.find(function (section) {
        return section.id === currentSectionId;
      });
      if (selectedSection) {
        // 重置上次加载的section code，确保新section能够加载
        lastLoadedSectionCodeRef.current = '';
        loadGroupData(selectedSection.code);
      }
    }
  }, [currentSectionId, localSections]); // loadGroupData现在是稳定的，不需要作为依赖项

  // 处理区块选择
  var handleSectionSelect = function handleSectionSelect(sectionId) {
    setCurrentSectionId(sectionId);
    onSectionSelect === null || onSectionSelect === void 0 || onSectionSelect(sectionId);
    // 移除这里的loadGroupData调用，因为useEffect会自动处理
  };

  // 处理数据变更
  var handleDataChange = function handleDataChange(updatedSection) {
    var newSections = localSections.map(function (section) {
      return section.id === updatedSection.id ? updatedSection : section;
    });
    setLocalSections(newSections);
    onDataChange === null || onDataChange === void 0 || onDataChange(newSections);
  };

  // 获取当前选中的区块
  var currentSection = localSections.find(function (section) {
    return section.id === currentSectionId;
  });

  // 检查代码是否已存在
  var isCodeExists = function isCodeExists(code, excludeId) {
    if (!currentSection || !currentSection.groups) return false;
    return currentSection.groups.some(function (group) {
      return group.code === code && group.id !== excludeId;
    });
  };

  // 检查键是否已存在
  var isKeyExists = function isKeyExists(key, excludeId) {
    if (!currentSection || !currentSection.groups) return false;
    return currentSection.groups.some(function (group) {
      return group.items && group.items.some(function (item) {
        return item.key === key && item.id !== excludeId;
      });
    });
  };

  // 处理添加组
  var handleAddGroup = function handleAddGroup() {
    setModalType('add');
    setEditingGroup(undefined);
    setGroupModalOpen(true);
  };

  // 处理编辑组
  var handleEditGroup = function handleEditGroup(group) {
    setModalType('edit');
    setEditingGroup(group);
    console.log('group', group);
    setGroupModalOpen(true);
  };

  // 处理添加设置项
  var handleAddItem = function handleAddItem(groupId) {
    setModalType('add');
    setEditingItem(undefined);
    setTargetGroupId(groupId);
    setItemModalOpen(true);
  };

  // 处理编辑设置项
  var handleEditItem = function handleEditItem(item) {
    setModalType('edit');
    setEditingItem(item);
    setTargetGroupId(item.groupId || item.group_id || 0);
    setItemModalOpen(true);
  };

  // 处理组表单提交
  var handleGroupSubmit = /*#__PURE__*/function () {
    var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(formData) {
      var maxSort, newSort;
      return _regeneratorRuntime().wrap(function _callee11$(_context11) {
        while (1) switch (_context11.prev = _context11.next) {
          case 0:
            if (currentSection) {
              _context11.next = 2;
              break;
            }
            return _context11.abrupt("return");
          case 2:
            if (!isCodeExists(formData.code, editingGroup === null || editingGroup === void 0 ? void 0 : editingGroup.id)) {
              _context11.next = 4;
              break;
            }
            return _context11.abrupt("return");
          case 4:
            _context11.prev = 4;
            if (!(modalType === 'add')) {
              _context11.next = 12;
              break;
            }
            // 计算新组的sort值：最后一个组的sort值+1
            maxSort = groupList.length > 0 ? Math.max.apply(Math, _toConsumableArray(groupList.map(function (group) {
              return group.sort || 0;
            }))) : 0;
            newSort = maxSort + 1; // 创建新组 - 使用 API 调用
            _context11.next = 10;
            return handleCreateGroup({
              section_code: currentSection.code,
              code: formData.code,
              title: formData.title,
              sort: newSort
            });
          case 10:
            _context11.next = 17;
            break;
          case 12:
            if (editingGroup !== null && editingGroup !== void 0 && editingGroup.id) {
              _context11.next = 15;
              break;
            }
            console.error('No editing group ID found');
            return _context11.abrupt("return");
          case 15:
            _context11.next = 17;
            return handleUpdateGroup({
              id: editingGroup.id,
              code: formData.code,
              title: formData.title
            });
          case 17:
            // 只有在保存成功后才关闭模态框
            setGroupModalOpen(false);
            _context11.next = 23;
            break;
          case 20:
            _context11.prev = 20;
            _context11.t0 = _context11["catch"](4);
            console.error('Failed to submit group form:', _context11.t0);
            // 错误消息已在 handleCreateGroup 中处理
            // 保存失败时不关闭模态框
          case 23:
          case "end":
            return _context11.stop();
        }
      }, _callee11, null, [[4, 20]]);
    }));
    return function handleGroupSubmit(_x13) {
      return _ref12.apply(this, arguments);
    };
  }();

  // 处理设置项表单提交
  var handleItemSubmit = /*#__PURE__*/function () {
    var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(formData) {
      var processedDefaultValue, validation, targetGroup, maxSort, newSort;
      return _regeneratorRuntime().wrap(function _callee12$(_context12) {
        while (1) switch (_context12.prev = _context12.next) {
          case 0:
            if (currentSection) {
              _context12.next = 2;
              break;
            }
            return _context12.abrupt("return");
          case 2:
            if (!isKeyExists(formData.key, editingItem === null || editingItem === void 0 ? void 0 : editingItem.id)) {
              _context12.next = 4;
              break;
            }
            return _context12.abrupt("return");
          case 4:
            // 验证和解析默认值
            processedDefaultValue = formData.default;
            if (!(formData.default !== undefined && formData.default !== null && formData.default !== '')) {
              _context12.next = 13;
              break;
            }
            validation = validateDefaultValue(formData.fieldType, formData.default);
            if (validation.isValid) {
              _context12.next = 10;
              break;
            }
            message.error("\u9ED8\u8BA4\u503C\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.error));
            return _context12.abrupt("return");
          case 10:
            // 解析默认值为对应的类型
            processedDefaultValue = parseDefaultValue(formData.fieldType, formData.default);
            _context12.next = 14;
            break;
          case 13:
            processedDefaultValue = null;
          case 14:
            _context12.prev = 14;
            if (!(modalType === 'add')) {
              _context12.next = 23;
              break;
            }
            // 计算新设置项的sort值：目标组内最后一个item的sort值+1
            targetGroup = groupList.find(function (group) {
              return group.id === targetGroupId;
            });
            maxSort = targetGroup && targetGroup.items && targetGroup.items.length > 0 ? Math.max.apply(Math, _toConsumableArray(targetGroup.items.map(function (item) {
              return item.sort || 0;
            }))) : 0;
            newSort = maxSort + 1; // 创建新设置项 - 使用 API 调用
            _context12.next = 21;
            return handleCreateItem({
              section_code: currentSection.code,
              group_id: targetGroupId,
              code: formData.key,
              title: formData.name,
              description: formData.description,
              type: formData.fieldType,
              interface: formData.interfaceType,
              default: processedDefaultValue,
              scopes: formData.scopes,
              schema: formData.uiSchema ? function () {
                try {
                  return JSON.parse(formData.uiSchema);
                } catch (e) {
                  console.warn('Invalid JSON in uiSchema:', e);
                  return formData.uiSchema;
                }
              }() : undefined,
              sort: newSort
            });
          case 21:
            _context12.next = 28;
            break;
          case 23:
            if (editingItem !== null && editingItem !== void 0 && editingItem.id) {
              _context12.next = 26;
              break;
            }
            console.error('No editing item ID found');
            return _context12.abrupt("return");
          case 26:
            _context12.next = 28;
            return handleUpdateItem({
              id: editingItem.id,
              section_code: currentSection.code,
              group_id: targetGroupId,
              code: formData.key,
              title: formData.name,
              description: formData.description,
              type: formData.fieldType,
              interface: formData.interfaceType,
              default: processedDefaultValue,
              scopes: formData.scopes,
              schema: formData.uiSchema ? function () {
                try {
                  return JSON.parse(formData.uiSchema);
                } catch (e) {
                  console.warn('Invalid JSON in uiSchema:', e);
                  return formData.uiSchema;
                }
              }() : undefined,
              sort: editingItem.sort
            });
          case 28:
            // 只有在保存成功后才关闭模态框
            setItemModalOpen(false);
            _context12.next = 34;
            break;
          case 31:
            _context12.prev = 31;
            _context12.t0 = _context12["catch"](14);
            console.error('Failed to submit item form:', _context12.t0);
            // 错误消息已在 handleCreateItem/handleUpdateItem 中处理
            // 保存失败时不关闭模态框
          case 34:
          case "end":
            return _context12.stop();
        }
      }, _callee12, null, [[14, 31]]);
    }));
    return function handleItemSubmit(_x14) {
      return _ref13.apply(this, arguments);
    };
  }();
  return /*#__PURE__*/React.createElement("div", {
    className: "pisell-settings-registry ".concat(className || ''),
    style: style
  }, /*#__PURE__*/React.createElement("div", {
    className: "pisell-settings-registry-sidebar"
  }, /*#__PURE__*/React.createElement("div", {
    className: "pisell-settings-registry-sidebar-header"
  }, /*#__PURE__*/React.createElement("div", {
    className: "pisell-settings-registry-sidebar-title"
  }, locales.getText('registry.sections.title'))), /*#__PURE__*/React.createElement(SectionList, {
    sections: localSections,
    selectedSectionId: currentSectionId,
    onSectionSelect: handleSectionSelect,
    loading: loading,
    hasMore: hasMore,
    onLoadMore: handleLoadMore
  })), /*#__PURE__*/React.createElement("div", {
    className: "pisell-settings-registry-content"
  }, /*#__PURE__*/React.createElement("div", {
    className: "pisell-settings-registry-content-header"
  }, /*#__PURE__*/React.createElement("div", {
    className: "pisell-settings-registry-content-title"
  }, /*#__PURE__*/React.createElement("div", {
    className: "pisell-settings-registry-content-main-title"
  }, locales.getText('registry.title'))), /*#__PURE__*/React.createElement(Button, {
    type: "primary",
    icon: /*#__PURE__*/React.createElement(PlusOutlined, null),
    onClick: handleAddGroup,
    disabled: !currentSection
  }, locales.getText('registry.action.add.group'))), /*#__PURE__*/React.createElement(SettingsTable, {
    section: currentSection,
    groupList: groupList,
    groupLoading: groupLoading,
    onDataChange: handleDataChange,
    onEditGroup: handleEditGroup,
    onDeleteGroup: function onDeleteGroup(groupId) {
      return handleDeleteGroup({
        id: groupId
      });
    },
    onAddItem: handleAddItem,
    onEditItem: handleEditItem,
    onDeleteItem: function onDeleteItem(itemId) {
      return handleDeleteItem({
        id: itemId
      });
    },
    onGroupReorder: handleGroupReorder,
    onItemMove: handleItemMove
  })), /*#__PURE__*/React.createElement(GroupModal, {
    open: groupModalOpen,
    type: modalType,
    data: editingGroup,
    onOk: handleGroupSubmit,
    onCancel: function onCancel() {
      return setGroupModalOpen(false);
    }
  }), /*#__PURE__*/React.createElement(ItemModal, {
    open: itemModalOpen,
    type: modalType,
    data: editingItem,
    section: currentSection,
    onOk: handleItemSubmit,
    onCancel: function onCancel() {
      return setItemModalOpen(false);
    }
  }));
};
export default Registry;