import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
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__ */ jsxDEV(FieldFallbackView, { fallback, fallbackStyle }, void 0, false, {
        fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fieldViews/BooleanFieldView.tsx",
        lineNumber: 22,
        columnNumber: 11
      }, globalThis);
    }
    if (format) {
      return /* @__PURE__ */ jsxDEV(Fragment, { children: format(booleanField.value) }, void 0, false, {
        fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fieldViews/BooleanFieldView.tsx",
        lineNumber: 25,
        columnNumber: 11
      }, globalThis);
    }
    switch (booleanStyle) {
      case "checkCross":
        return /* @__PURE__ */ jsxDEV(Fragment, { children: booleanField.value ? "✔" : "✗" }, void 0, false, {
          fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fieldViews/BooleanFieldView.tsx",
          lineNumber: 29,
          columnNumber: 12
        }, globalThis);
      case "oneZero":
        return /* @__PURE__ */ jsxDEV(Fragment, { children: booleanField.value ? "1" : "0" }, void 0, false, {
          fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fieldViews/BooleanFieldView.tsx",
          lineNumber: 31,
          columnNumber: 12
        }, globalThis);
      case "yesNo":
      default:
        return /* @__PURE__ */ jsxDEV(Fragment, { children: booleanField.value ? formatMessage("fieldView.boolean.yes") : formatMessage("fieldView.boolean.no") }, void 0, false, {
          fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fieldViews/BooleanFieldView.tsx",
          lineNumber: 35,
          columnNumber: 6
        }, globalThis);
    }
  },
  (props) => /* @__PURE__ */ jsxDEV(Fragment, { children: [
    /* @__PURE__ */ jsxDEV(SugaredField, { field: props.field }, void 0, false, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fieldViews/BooleanFieldView.tsx",
      lineNumber: 41,
      columnNumber: 4
    }, globalThis),
    /* @__PURE__ */ jsxDEV(FieldFallbackView, { fallback: props.fallback, fallbackStyle: props.fallbackStyle }, void 0, false, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fieldViews/BooleanFieldView.tsx",
      lineNumber: 42,
      columnNumber: 4
    }, globalThis)
  ] }, void 0, true, {
    fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fieldViews/BooleanFieldView.tsx",
    lineNumber: 40,
    columnNumber: 3
  }, globalThis),
  "DateFieldView"
);
export {
  BooleanFieldView
};
//# sourceMappingURL=BooleanFieldView.js.map
