import { createElement, Fragment } from "react";
import { Component, useField, SugaredField } from "@contember/binding";
import { FieldFallbackView } from "./FieldFallbackView.js";
import { fieldViewDictionary } from "./fieldViewDictionary.js";
import { useMessageFormatter } from "../../../i18n/useMessageFormatter.js";
const BooleanFieldView = Component(({ field, booleanStyle, format, fallback, fallbackStyle }) => {
  const booleanField = useField(field);
  const formatMessage = useMessageFormatter(fieldViewDictionary);
  if (booleanField.value === null) {
    return /* @__PURE__ */ createElement(FieldFallbackView, {
      fallback,
      fallbackStyle
    });
  }
  if (format) {
    return /* @__PURE__ */ createElement(Fragment, null, format(booleanField.value));
  }
  switch (booleanStyle) {
    case "checkCross":
      return /* @__PURE__ */ createElement(Fragment, null, booleanField.value ? "\u2714" : "\u274C");
    case "oneZero":
      return /* @__PURE__ */ createElement(Fragment, null, booleanField.value ? "1" : "0");
    case "yesNo":
    default:
      return /* @__PURE__ */ createElement(Fragment, null, booleanField.value ? formatMessage("fieldView.boolean.yes") : formatMessage("fieldView.boolean.no"));
  }
}, (props) => /* @__PURE__ */ createElement(Fragment, null, /* @__PURE__ */ createElement(SugaredField, {
  field: props.field
}), /* @__PURE__ */ createElement(FieldFallbackView, {
  fallback: props.fallback,
  fallbackStyle: props.fallbackStyle
})), "DateFieldView");
export { BooleanFieldView };
//# sourceMappingURL=BooleanFieldView.js.map
