import { Component, useField, SugaredField } from "@contember/binding";
import { FieldFallbackView } from "./FieldFallbackView.js";
import { fieldViewDictionary } from "./fieldViewDictionary.js";
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
import { useMessageFormatter } from "../../../i18n/useMessageFormatter.js";
var _jsxFileName = "/__w/interface/interface/packages/admin/src/components/bindingFacade/fieldViews/BooleanFieldView.tsx";
const BooleanFieldView = Component(({
  field,
  booleanStyle,
  format,
  fallback,
  fallbackStyle
}) => {
  const booleanField = useField(field);
  const formatMessage = useMessageFormatter(fieldViewDictionary);
  if (booleanField.value === null) {
    return /* @__PURE__ */ jsxDEV(FieldFallbackView, {
      fallback,
      fallbackStyle
    }, void 0, false, {
      fileName: _jsxFileName,
      lineNumber: 19,
      columnNumber: 11
    }, void 0);
  }
  if (format) {
    return /* @__PURE__ */ jsxDEV(Fragment, {
      children: format(booleanField.value)
    }, void 0, false);
  }
  switch (booleanStyle) {
    case "checkCross":
      return /* @__PURE__ */ jsxDEV(Fragment, {
        children: booleanField.value ? "\u2714" : "\u2717"
      }, void 0, false);
    case "oneZero":
      return /* @__PURE__ */ jsxDEV(Fragment, {
        children: booleanField.value ? "1" : "0"
      }, void 0, false);
    case "yesNo":
    default:
      return /* @__PURE__ */ jsxDEV(Fragment, {
        children: booleanField.value ? formatMessage("fieldView.boolean.yes") : formatMessage("fieldView.boolean.no")
      }, void 0, false);
  }
}, (props) => /* @__PURE__ */ jsxDEV(Fragment, {
  children: [/* @__PURE__ */ jsxDEV(SugaredField, {
    field: props.field
  }, void 0, false, {
    fileName: _jsxFileName,
    lineNumber: 38,
    columnNumber: 4
  }, void 0), /* @__PURE__ */ jsxDEV(FieldFallbackView, {
    fallback: props.fallback,
    fallbackStyle: props.fallbackStyle
  }, void 0, false, {
    fileName: _jsxFileName,
    lineNumber: 39,
    columnNumber: 4
  }, void 0)]
}, void 0, true), "DateFieldView");
export {
  BooleanFieldView
};
//# sourceMappingURL=BooleanFieldView.js.map
