Liferay.Loader.define("dynamic-data-mapping-form-field-type@5.0.68/Checkbox/Checkbox.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/form', '@frontend-taglib-clay$clayui/icon', 'frontend-js-react-web$react', '../FieldBase/ReactFieldBase.es'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = exports.Main = void 0;

    var _form = require("@frontend-taglib-clay$clayui/form");

    var _icon = _interopRequireDefault(require("@frontend-taglib-clay$clayui/icon"));

    var _react = _interopRequireWildcard(require("frontend-js-react-web$react"));

    var _ReactFieldBase = require("../FieldBase/ReactFieldBase.es");

    function _getRequireWildcardCache() {
      if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function _getRequireWildcardCache() {
        return cache;
      };return cache;
    }

    function _interopRequireWildcard(obj) {
      if (obj && obj.__esModule) {
        return obj;
      }if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
        return { default: obj };
      }var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {
        return cache.get(obj);
      }var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {
        if (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 };
    }

    function _extends() {
      _extends = Object.assign || function (target) {
        for (var i = 1; i < arguments.length; i++) {
          var source = arguments[i];for (var key in source) {
            if (Object.prototype.hasOwnProperty.call(source, key)) {
              target[key] = source[key];
            }
          }
        }return target;
      };return _extends.apply(this, arguments);
    }

    function _objectWithoutProperties(source, excluded) {
      if (source == null) return {};var target = _objectWithoutPropertiesLoose(source, excluded);var key, i;if (Object.getOwnPropertySymbols) {
        var sourceSymbolKeys = Object.getOwnPropertySymbols(source);for (i = 0; i < sourceSymbolKeys.length; i++) {
          key = sourceSymbolKeys[i];if (excluded.indexOf(key) >= 0) continue;if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;target[key] = source[key];
        }
      }return target;
    }

    function _objectWithoutPropertiesLoose(source, excluded) {
      if (source == null) return {};var target = {};var sourceKeys = Object.keys(source);var key, i;for (i = 0; i < sourceKeys.length; i++) {
        key = sourceKeys[i];if (excluded.indexOf(key) >= 0) continue;target[key] = source[key];
      }return target;
    }

    function _slicedToArray(arr, i) {
      return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
    }

    function _nonIterableRest() {
      throw new TypeError("Invalid attempt to destructure non-iterable instance");
    }

    function _iterableToArrayLimit(arr, i) {
      if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
        return;
      }var _arr = [];var _n = true;var _d = false;var _e = undefined;try {
        for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
          _arr.push(_s.value);if (i && _arr.length === i) break;
        }
      } catch (err) {
        _d = true;_e = err;
      } finally {
        try {
          if (!_n && _i["return"] != null) _i["return"]();
        } finally {
          if (_d) throw _e;
        }
      }return _arr;
    }

    function _arrayWithHoles(arr) {
      if (Array.isArray(arr)) return arr;
    }

    var Switcher = function Switcher(_ref) {
      var initialChecked = _ref.checked,
          disabled = _ref.disabled,
          label = _ref.label,
          name = _ref.name,
          _onChange = _ref.onChange,
          required = _ref.required,
          showLabel = _ref.showLabel,
          showMaximumRepetitionsInfo = _ref.showMaximumRepetitionsInfo,
          spritemap = _ref.spritemap,
          systemSettingsURL = _ref.systemSettingsURL;

      var _useState = (0, _react.useState)(initialChecked),
          _useState2 = _slicedToArray(_useState, 2),
          checked = _useState2[0],
          setChecked = _useState2[1];

      return (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("label", {
          className: "ddm-toggle-switch toggle-switch"
        }, /*#__PURE__*/_react.default.createElement("input", {
          checked: checked,
          className: "toggle-switch-check",
          disabled: disabled,
          name: name,
          onChange: function onChange(event) {
            setChecked(event.target.checked);

            _onChange(event, event.target.checked);
          },
          type: "checkbox",
          value: true
        }), /*#__PURE__*/_react.default.createElement("span", {
          "aria-hidden": "true",
          className: "toggle-switch-bar"
        }, /*#__PURE__*/_react.default.createElement("span", {
          className: "toggle-switch-handle"
        }), (showLabel || required) && /*#__PURE__*/_react.default.createElement("span", {
          className: "toggle-switch-text toggle-switch-text-right"
        }, showLabel && label, required && /*#__PURE__*/_react.default.createElement(_icon.default, {
          className: "reference-mark",
          spritemap: spritemap,
          symbol: "asterisk"
        })))), checked && showMaximumRepetitionsInfo && /*#__PURE__*/_react.default.createElement("div", {
          className: "ddm-info"
        }, /*#__PURE__*/_react.default.createElement("span", {
          className: "ddm-tooltip"
        }, /*#__PURE__*/_react.default.createElement(_icon.default, {
          symbol: "info-circle"
        })), /*#__PURE__*/_react.default.createElement("div", {
          className: "ddm-info-text",
          dangerouslySetInnerHTML: {
            __html: Liferay.Util.sub(Liferay.Language.get('for-security-reasons-upload-field-repeatibilty-is-limited-the-limit-is-defined-in-x-system-settings-x'), "<a href=".concat(systemSettingsURL, " target=\"_blank\">"), '</a>')
          }
        })))
      );
    };

    var Checkbox = function Checkbox(_ref2) {
      var initialChecked = _ref2.checked,
          disabled = _ref2.disabled,
          label = _ref2.label,
          name = _ref2.name,
          _onChange2 = _ref2.onChange,
          required = _ref2.required,
          showLabel = _ref2.showLabel,
          spritemap = _ref2.spritemap;

      var _useState3 = (0, _react.useState)(initialChecked),
          _useState4 = _slicedToArray(_useState3, 2),
          checked = _useState4[0],
          setChecked = _useState4[1];

      return (/*#__PURE__*/_react.default.createElement(_form.ClayCheckbox, {
          checked: checked,
          disabled: disabled,
          label: showLabel && label,
          name: name,
          onChange: function onChange(event) {
            setChecked(event.target.checked);

            _onChange2(event, event.target.checked);
          }
        }, showLabel && required && /*#__PURE__*/_react.default.createElement(_icon.default, {
          className: "reference-mark",
          spritemap: spritemap,
          symbol: "asterisk"
        }))
      );
    };

    var Main = function Main(_ref3) {
      var disabled = _ref3.disabled,
          label = _ref3.label,
          name = _ref3.name,
          onChange = _ref3.onChange,
          _ref3$predefinedValue = _ref3.predefinedValue,
          predefinedValue = _ref3$predefinedValue === void 0 ? true : _ref3$predefinedValue,
          required = _ref3.required,
          _ref3$showAsSwitcher = _ref3.showAsSwitcher,
          showAsSwitcher = _ref3$showAsSwitcher === void 0 ? true : _ref3$showAsSwitcher,
          _ref3$showLabel = _ref3.showLabel,
          showLabel = _ref3$showLabel === void 0 ? true : _ref3$showLabel,
          _ref3$showMaximumRepe = _ref3.showMaximumRepetitionsInfo,
          showMaximumRepetitionsInfo = _ref3$showMaximumRepe === void 0 ? false : _ref3$showMaximumRepe,
          spritemap = _ref3.spritemap,
          systemSettingsURL = _ref3.systemSettingsURL,
          value = _ref3.value,
          otherProps = _objectWithoutProperties(_ref3, ["disabled", "label", "name", "onChange", "predefinedValue", "required", "showAsSwitcher", "showLabel", "showMaximumRepetitionsInfo", "spritemap", "systemSettingsURL", "value"]);

      var Toggle = showAsSwitcher ? Switcher : Checkbox;
      return (/*#__PURE__*/_react.default.createElement(_ReactFieldBase.FieldBase, _extends({
          label: label,
          name: name,
          required: required,
          showLabel: false,
          spritemap: spritemap
        }, otherProps), /*#__PURE__*/_react.default.createElement(Toggle, {
          checked: value !== undefined ? value : predefinedValue,
          disabled: disabled,
          label: label,
          name: name,
          onChange: onChange,
          required: required,
          showLabel: showLabel,
          showMaximumRepetitionsInfo: showMaximumRepetitionsInfo,
          spritemap: spritemap,
          systemSettingsURL: systemSettingsURL
        }))
      );
    };

    exports.Main = Main;
    Main.displayName = 'Checkbox';
    var _default = Main;
    exports.default = _default;
    //# sourceMappingURL=Checkbox.es.js.map
  }
});
//# sourceMappingURL=Checkbox.es.js.map