import { useEnvironment, useField, useMutationState } from "@contember/binding";
import { FieldContainer } from "@contember/ui";
import { memo, useMemo } from "react";
import { useLabelMiddleware } from "../../environment/LabelMiddleware.js";
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
import { useAccessorErrors } from "../../errors/useAccessorErrors.js";
var _jsxFileName = "/__w/interface/interface/packages/admin/src/components/bindingFacade/auxiliary/SimpleRelativeSingleField/SimpleRelativeFieldProxy.tsx";
const SimpleRelativeSingleFieldProxy = memo(({
  render,
  label,
  labelDescription,
  labelPosition,
  description,
  ...props
}) => {
  const environment = useEnvironment();
  const field = useField(props);
  const labelMiddleware = useLabelMiddleware();
  const normalizedLabel = useMemo(() => labelMiddleware(label), [labelMiddleware, label]);
  const isMutating = useMutationState();
  const fieldMetadata = useMemo(() => ({
    field,
    environment,
    isMutating
  }), [environment, field, isMutating]);
  const fieldErrors = useAccessorErrors(field);
  const rendered = render(fieldMetadata, props);
  return /* @__PURE__ */ jsxDEV(Fragment, {
    children: rendered && /* @__PURE__ */ jsxDEV(FieldContainer, {
      label: normalizedLabel,
      size: props.size,
      labelDescription,
      labelPosition,
      description,
      errors: fieldErrors,
      required: props.required,
      children: rendered
    }, void 0, false, {
      fileName: _jsxFileName,
      lineNumber: 38,
      columnNumber: 6
    }, void 0)
  }, void 0, false);
});
SimpleRelativeSingleFieldProxy.displayName = "SimpleRelativeSingleFieldProxy";
export {
  SimpleRelativeSingleFieldProxy
};
//# sourceMappingURL=SimpleRelativeFieldProxy.js.map
