"use client";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import { FormHeader } from "@open-mercato/ui/backend/forms";
import { VersionHistoryAction } from "@open-mercato/ui/backend/version-history";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import {
  InlineTextEditor,
  InlineDictionaryEditor,
  InlineNextInteractionEditor
} from "./InlineEditors.js";
function CompanyHighlights({
  company,
  profile,
  validators,
  onDisplayNameSave,
  onPrimaryEmailSave,
  onPrimaryPhoneSave,
  onStatusSave,
  onNextInteractionSave,
  onDelete,
  isDeleting,
  utilityActions
}) {
  const t = useT();
  const historyFallbackId = profile?.id && profile.id !== company.id ? profile.id : void 0;
  return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
    /* @__PURE__ */ jsx(
      FormHeader,
      {
        mode: "detail",
        backHref: "/backend/customers/companies",
        backLabel: t("customers.companies.detail.actions.backToList", "Back to companies"),
        utilityActions: /* @__PURE__ */ jsxs(Fragment, { children: [
          utilityActions,
          /* @__PURE__ */ jsx(
            VersionHistoryAction,
            {
              config: {
                resourceKind: "customers.company",
                resourceId: company.id,
                resourceIdFallback: historyFallbackId,
                organizationId: company.organizationId ?? void 0
              },
              t
            }
          )
        ] }),
        title: /* @__PURE__ */ jsx(
          InlineTextEditor,
          {
            label: t("customers.companies.form.displayName.label", "Display name"),
            value: company.displayName,
            placeholder: t("customers.companies.form.displayName.placeholder", "Enter company name"),
            emptyLabel: t("customers.companies.detail.noValue", "Not provided"),
            validator: validators.displayName,
            onSave: onDisplayNameSave,
            hideLabel: true,
            variant: "plain",
            activateOnClick: true,
            triggerClassName: "opacity-0 transition-opacity duration-150 group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100",
            containerClassName: "max-w-full"
          }
        ),
        onDelete: () => {
          onDelete();
        },
        isDeleting,
        deleteLabel: t("customers.companies.detail.actions.delete", "Delete company")
      }
    ),
    /* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2 xl:grid-cols-4", children: [
      /* @__PURE__ */ jsx(
        InlineTextEditor,
        {
          label: t("customers.companies.detail.highlights.primaryEmail", "Primary email"),
          value: company.primaryEmail || "",
          placeholder: t("customers.companies.form.primaryEmail", "Add email"),
          emptyLabel: t("customers.companies.detail.noValue", "Not provided"),
          type: "email",
          validator: validators.email,
          recordId: company.id,
          activateOnClick: true,
          onSave: onPrimaryEmailSave
        }
      ),
      /* @__PURE__ */ jsx(
        InlineTextEditor,
        {
          label: t("customers.companies.detail.highlights.primaryPhone", "Primary phone"),
          value: company.primaryPhone || "",
          placeholder: t("customers.companies.form.primaryPhone", "Add phone"),
          emptyLabel: t("customers.companies.detail.noValue", "Not provided"),
          type: "tel",
          validator: validators.phone,
          recordId: company.id,
          activateOnClick: true,
          onSave: onPrimaryPhoneSave
        }
      ),
      /* @__PURE__ */ jsx(
        InlineDictionaryEditor,
        {
          label: t("customers.companies.detail.highlights.status", "Status"),
          value: company.status ?? null,
          emptyLabel: t("customers.companies.detail.noValue", "Not provided"),
          activateOnClick: true,
          onSave: onStatusSave,
          kind: "statuses"
        }
      ),
      /* @__PURE__ */ jsx(
        InlineNextInteractionEditor,
        {
          label: t("customers.companies.detail.highlights.nextInteraction", "Next interaction"),
          valueAt: company.nextInteractionAt || null,
          valueName: company.nextInteractionName || null,
          valueRefId: company.nextInteractionRefId || null,
          valueIcon: company.nextInteractionIcon || null,
          valueColor: company.nextInteractionColor || null,
          emptyLabel: t("customers.companies.detail.noValue", "Not provided"),
          onSave: onNextInteractionSave,
          activateOnClick: true
        }
      )
    ] })
  ] });
}
var CompanyHighlights_default = CompanyHighlights;
export {
  CompanyHighlights,
  CompanyHighlights_default as default
};
//# sourceMappingURL=CompanyHighlights.js.map
