"use client";
import { jsx } from "react/jsx-runtime";
import { ComponentReplacementHandles } from "@open-mercato/shared/modules/widgets/component-registry";
import { useRegisteredComponent } from "../injection/useRegisteredComponent.js";
import {
  InlineMultilineEditor,
  InlineSelectEditor,
  InlineTextEditor
} from "./InlineEditors.js";
function DetailFieldsSectionImpl({ fields, className }) {
  return /* @__PURE__ */ jsx("div", { className: ["grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3", className].filter(Boolean).join(" "), children: fields.map((field) => {
    const variant = field.editorVariant ?? "muted";
    const activateOnClick = field.activateOnClick ?? true;
    const containerClassName = field.containerClassName ?? void 0;
    const triggerClassName = field.triggerClassName ?? void 0;
    const wrapperClassName = field.gridClassName ?? void 0;
    if (field.kind === "text") {
      return /* @__PURE__ */ jsx("div", { className: wrapperClassName, children: /* @__PURE__ */ jsx(
        InlineTextEditor,
        {
          label: field.label,
          value: field.value,
          placeholder: field.placeholder,
          emptyLabel: field.emptyLabel,
          onSave: field.onSave,
          inputType: field.inputType,
          validator: field.validator,
          variant,
          activateOnClick,
          containerClassName,
          triggerClassName,
          hideLabel: field.hideLabel,
          renderDisplay: field.renderDisplay
        }
      ) }, field.key);
    }
    if (field.kind === "multiline") {
      return /* @__PURE__ */ jsx("div", { className: wrapperClassName, children: /* @__PURE__ */ jsx(
        InlineMultilineEditor,
        {
          label: field.label,
          value: field.value,
          placeholder: field.placeholder,
          emptyLabel: field.emptyLabel,
          onSave: field.onSave,
          validator: field.validator,
          variant: variant === "plain" ? "default" : variant,
          activateOnClick,
          containerClassName,
          triggerClassName,
          renderDisplay: field.renderDisplay
        }
      ) }, field.key);
    }
    if (field.kind === "select") {
      return /* @__PURE__ */ jsx("div", { className: wrapperClassName, children: /* @__PURE__ */ jsx(
        InlineSelectEditor,
        {
          label: field.label,
          value: field.value,
          emptyLabel: field.emptyLabel,
          onSave: field.onSave,
          options: field.options,
          variant,
          activateOnClick,
          containerClassName,
          triggerClassName
        }
      ) }, field.key);
    }
    return /* @__PURE__ */ jsx("div", { className: wrapperClassName, children: field.render() }, field.key);
  }) });
}
function DetailFieldsSection(props) {
  const handle = ComponentReplacementHandles.section("ui.detail", "DetailFieldsSection");
  const Resolved = useRegisteredComponent(
    handle,
    DetailFieldsSectionImpl
  );
  return /* @__PURE__ */ jsx("div", { "data-component-handle": handle, children: /* @__PURE__ */ jsx(Resolved, { ...props }) });
}
export {
  DetailFieldsSection
};
//# sourceMappingURL=DetailFieldsSection.js.map
