"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports._CustomFieldModal = exports.CustomFieldModal = void 0;
var _react = _interopRequireDefault(require("react"));
var _mobxReactLite = require("mobx-react-lite");
var _designSystem = require("@wix/design-system");
var _ActionModal = require("../ActionModal");
var _ = require(".");
var _react2 = require("@wix/bex-core/react");
var _CustomFieldModalPrimaryButton = require("./CustomFieldModalPrimaryButton");
var _minimalRequiredWdsRuntimeCheck = require("../../minimalRequiredWdsRuntimeCheck");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/CustomFieldModal/CustomFieldModal.tsx";
const _CustomFieldModal = ({
  state
}) => {
  if (process.env.NODE_ENV !== 'production') {
    // We show form errors in the FormField status messages which were introduced
    // in wix-style-react 10.56.0
    (0, _minimalRequiredWdsRuntimeCheck.minimalRequiredWdsRuntimeCheck)({
      required: '^1.64.1',
      requiredBy: 'WixPatterns/CustomFieldModal'
    });
  }
  const {
    translate: t,
    environment: {
      language
    }
  } = (0, _react2.useWixPatternsContainer)();
  const {
    mode,
    customFieldModalBiReporter: {
      reportLearnMoreClick,
      reportModalEndProcess
    }
  } = state;
  if (mode === 'new' && state.dataExtensionState.isReachedMaxCustomFields) {
    return /*#__PURE__*/_react.default.createElement(_ActionModal.MessageActionModal, {
      state: state.modalState,
      title: t('cairo.customFields.maxLimit.modal.title'),
      primaryButtonText: t('cairo.customFields.maxLimit.modal.cta'),
      content: t('cairo.customFields.maxLimit.modal.description'),
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 37,
        columnNumber: 7
      }
    });
  }
  return /*#__PURE__*/_react.default.createElement(_ActionModal.CustomActionModal, {
    dataHook: "custom-field-modal",
    state: state.modalState,
    title: mode === 'new' ? t('cairo.customFields.addCustomField.modal.title') : t('cairo.customFields.editCustomField.modal.title'),
    subtitle: mode === 'new' && /*#__PURE__*/_react.default.createElement(CustomFieldModalSubtitle, {
      t: t,
      language: language,
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 56,
        columnNumber: 27
      }
    }),
    content: /*#__PURE__*/_react.default.createElement(_.CustomFieldForm, {
      state: state,
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 58,
        columnNumber: 16
      }
    }),
    primaryButtonText: /*#__PURE__*/_react.default.createElement(_CustomFieldModalPrimaryButton.CustomFieldModalPrimaryButton, {
      state: state,
      content: mode === 'new' ? t('cairo.customFields.addCustomField.modal.add.CTA') : t('cairo.customFields.editCustomField.save.CTA'),
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 60,
        columnNumber: 9
      }
    }),
    secondaryButtonText: t('cairo.customFields.addCustomField.modal.cancel.CTA'),
    onCloseButtonClick: () => reportModalEndProcess({
      endType: 'Cancel'
    }),
    secondaryButtonOnClick: () => reportModalEndProcess({
      endType: 'Cancel'
    }),
    footnote: state.dataExtensionState.containsPii ? null : /*#__PURE__*/_react.default.createElement(Footnote, {
      language: language,
      reportLearnMoreClick: reportLearnMoreClick,
      t: t,
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 78,
        columnNumber: 11
      }
    }),
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 47,
      columnNumber: 5
    }
  });
};
exports._CustomFieldModal = _CustomFieldModal;
const CustomFieldModal = exports.CustomFieldModal = (0, _mobxReactLite.observer)(_CustomFieldModal);
const Footnote = ({
  language,
  reportLearnMoreClick,
  t
}) => {
  return /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
    size: "small",
    dataHook: "pii-footnote",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 103,
      columnNumber: 5
    }
  }, t('cairo.customFields.addCustomField.modal.PII'), "\xA0", /*#__PURE__*/_react.default.createElement("a", {
    href: `https://support.wix.com/${language}/article/about-personally-identifiable-information-pii`,
    target: "_blank",
    rel: "noreferrer",
    onClick: reportLearnMoreClick,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 106,
      columnNumber: 7
    }
  }, t('cairo.customFields.addCustomField.modal.PII.learnMore')));
};
const CustomFieldModalSubtitle = ({
  t,
  language
}) => {
  return /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    direction: "vertical",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 128,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 129,
      columnNumber: 7
    }
  }, t('cairo.customFields.addCustomField.modal.subtitle')), /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 130,
      columnNumber: 7
    }
  }, t('cairo.customFields.addCustomField.modal.subtitle.note'), "\xA0", /*#__PURE__*/_react.default.createElement(_designSystem.TextButton, {
    as: "a",
    rel: "noopener",
    target: "_blank",
    href: `https://support.wix.com/${language}/article/about-custom-fields`,
    dataHook: "custom-field-modal-subtitle-learnmore",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 133,
      columnNumber: 9
    }
  }, t('cairo.subtitle.learnMore'))));
};
//# sourceMappingURL=CustomFieldModal.js.map