import { defineMessage } from 'react-intl';
import { Typography, Checkbox, FormControlLabel, FormHelperText } from '@material-ui/core';
import { jsx as _jsx } from "react/jsx-runtime";
import { Fragment as _Fragment } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";

function CheckboxWidget(_ref) {
  var _options$element, _options$element2, _options$element3, _options$element4, _options$element5;

  var options = _ref.options,
      _onChange = _ref.onChange,
      value = _ref.value,
      id = _ref.id;
  var required = (_options$element = options.element) === null || _options$element === void 0 ? void 0 : _options$element.required;
  var useLabel = (_options$element2 = options.element) === null || _options$element2 === void 0 ? void 0 : _options$element2.useLabel;
  var label = (_options$element3 = options.element) === null || _options$element3 === void 0 ? void 0 : _options$element3.label;
  var consentMessage = (_options$element4 = options.element) === null || _options$element4 === void 0 ? void 0 : _options$element4.yes;
  var title = (useLabel ? label : options.element.title) + (required ? ' *' : '');
  return /*#__PURE__*/_jsxs(_Fragment, {
    children: [/*#__PURE__*/_jsx(Typography, {
      component: "label",
      variant: "subtitle1",
      children: title
    }), /*#__PURE__*/_jsx("br", {}), (useLabel === false || useLabel === undefined) && /*#__PURE__*/_jsx(Typography, {
      component: "span",
      variant: "subtitle1",
      children: label
    }), /*#__PURE__*/_jsx(FormHelperText, {
      component: "span",
      variant: "contained",
      children: options === null || options === void 0 ? void 0 : (_options$element5 = options.element) === null || _options$element5 === void 0 ? void 0 : _options$element5.description
    }), /*#__PURE__*/_jsx(FormControlLabel, {
      control: /*#__PURE__*/_jsx(Checkbox, {
        onChange: function onChange(event, value) {
          value === null ? _onChange(undefined) : _onChange(value);
        },
        checked: value
      }),
      label: consentMessage
    })]
  });
}

export default (function () {
  return {
    schema: {
      type: 'boolean',
      "enum": [true],
      "default": false,
      additionalType: 'consent'
    },
    uiSchema: {
      'ui:widget': CheckboxWidget
    }
  };
});
export var name = defineMessage({
  id: "fsEr4O",
  defaultMessage: [{
    "type": 0,
    "value": "Suostumus"
  }]
});
export var elementType = 'field';
//# sourceMappingURL=consent.js.map