"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.HiddenWidgets = exports.HiddenSubDocumentWidgets = exports.HiddenInputWidgets = void 0;
var _react = _interopRequireDefault(require("react"));
var _ai = require("react-icons/ai");
var _Stack = _interopRequireDefault(require("react-bootstrap/Stack"));
var _Card = _interopRequireDefault(require("react-bootstrap/Card"));
var _LabelComponent = require("../components/LabelComponent");
var util = _interopRequireWildcard(require("../utils"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var DeleteIcons = function DeleteIcons(_ref) {
  var className = _ref.className;
  if (className !== "tdb__diff__original__deleted") return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null);
  return /*#__PURE__*/_react["default"].createElement(_Stack["default"], {
    direction: "horizontal",
    gap: 2
  }, /*#__PURE__*/_react["default"].createElement(_ai.AiOutlineMinusCircle, {
    className: className
  }), /*#__PURE__*/_react["default"].createElement(_ai.AiOutlineMinusCircle, {
    className: className
  }), /*#__PURE__*/_react["default"].createElement(_ai.AiOutlineMinusCircle, {
    className: className
  }));
};
var AddedIcons = function AddedIcons(_ref2) {
  var className = _ref2.className;
  if (className !== "tdb__diff__changed__deleted") return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null);
  return /*#__PURE__*/_react["default"].createElement(_Stack["default"], {
    direction: "horizontal",
    gap: 2
  }, /*#__PURE__*/_react["default"].createElement(_ai.AiOutlinePlusCircle, {
    className: className
  }), /*#__PURE__*/_react["default"].createElement(_ai.AiOutlinePlusCircle, {
    className: className
  }), /*#__PURE__*/_react["default"].createElement(_ai.AiOutlinePlusCircle, {
    className: className
  }));
};
var HiddenWidgets = function HiddenWidgets(config) {
  var field = config.args.documentFrame[config.name];
  if (util.isDataType(field)) {
    return /*#__PURE__*/_react["default"].createElement(HiddenInputWidgets, {
      name: config.name,
      className: config.className,
      id: config.id,
      hideFieldLabel: config.hideFieldLabel
    });
  } else if (util.isDocumentType(field, config.args.fullFrame)) {
    return /*#__PURE__*/_react["default"].createElement(HiddenInputWidgets, {
      name: config.name,
      className: config.className,
      id: config.id,
      hideFieldLabel: config.hideFieldLabel
    });
  } else if (util.isSubDocumentType(field)) {
    return /*#__PURE__*/_react["default"].createElement(HiddenSubDocumentWidgets, {
      name: config.name,
      className: config.className,
      id: config.id,
      hideFieldLabel: config.hideFieldLabel
    });
  }
};

// NORMAL DATA TYPES
exports.HiddenWidgets = HiddenWidgets;
var HiddenInputWidgets = function HiddenInputWidgets(config) {
  var className = config.className === "tdb__doc__input tdb__diff__original__deleted" ? "tdb__diff__original__deleted" : "tdb__diff__changed__deleted";
  return /*#__PURE__*/_react["default"].createElement(_Stack["default"], {
    direction: "horizontal"
  }, /*#__PURE__*/_react["default"].createElement(_LabelComponent.TDBLabel, {
    name: config.name,
    comment: config.comment,
    isKey: config.isKey,
    id: config.id,
    required: config.required,
    hideFieldLabel: config.hideFieldLabel
  }), /*#__PURE__*/_react["default"].createElement(DeleteIcons, {
    className: className
  }), /*#__PURE__*/_react["default"].createElement(AddedIcons, {
    className: className
  }), /*#__PURE__*/_react["default"].createElement("input", {
    type: "text",
    id: config.id,
    name: config.id,
    className: "tdb__doc__input w-100 opacity-0"
  }));
};

// SUBDOCUMENTS 
exports.HiddenInputWidgets = HiddenInputWidgets;
var HiddenSubDocumentWidgets = function HiddenSubDocumentWidgets(config) {
  var className = config.className === "tdb__doc__input tdb__diff__original__deleted" ? "tdb__diff__original__deleted" : "tdb__diff__changed__deleted";
  return /*#__PURE__*/_react["default"].createElement(_Stack["default"], {
    direction: "horizontal"
  }, /*#__PURE__*/_react["default"].createElement(_LabelComponent.TDBLabel, {
    name: config.name,
    comment: config.comment,
    isKey: config.isKey,
    id: config.id,
    required: config.required,
    hideFieldLabel: config.hideFieldLabel
  }), /*#__PURE__*/_react["default"].createElement(_Card["default"], {
    bg: "secondary",
    className: "tdb__subdocument__input w-100 p-4",
    key: config.id
  }, /*#__PURE__*/_react["default"].createElement(DeleteIcons, {
    className: className
  }), /*#__PURE__*/_react["default"].createElement(AddedIcons, {
    className: className
  })));
};
exports.HiddenSubDocumentWidgets = HiddenSubDocumentWidgets;