import "./chunk-NCMUZ6BQ.js";
import {
  MetadataForm
} from "./chunk-O7UECTZO.js";
import "./chunk-TKGWSUEI.js";
import "./chunk-U2ZFCAPX.js";
import "./chunk-INNFZYX2.js";
import "./chunk-LAVHRER2.js";
import "./chunk-Y7QKP6QU.js";
import {
  RouteDrawer
} from "./chunk-OV7R2AH5.js";
import "./chunk-3QSRE5LS.js";
import "./chunk-3MDRW5MA.js";
import "./chunk-MFL2TZ3W.js";
import "./chunk-YNIIYGL4.js";
import "./chunk-CBHNHLUZ.js";
import "./chunk-VME3CJER.js";
import "./chunk-XMVTX2EN.js";
import "./chunk-5PUHROK4.js";
import "./chunk-TPPONKYW.js";
import "./chunk-DF3OGJAK.js";
import "./chunk-XRDP2SYY.js";
import "./chunk-FNBKEF54.js";
import "./chunk-EHQESDH2.js";
import {
  useUpdateUser,
  useUser
} from "./chunk-XKVXLDSJ.js";
import "./chunk-XDZGOUCR.js";
import "./chunk-K4BGK3CO.js";
import "./chunk-YYTI5JIC.js";
import "./chunk-HAFZQK53.js";
import "./chunk-IJWG755C.js";
import "./chunk-M3YP3NX4.js";
import "./chunk-UU2RQMXS.js";
import "./chunk-O4STPJR2.js";
import "./chunk-R74OHYTB.js";
import "./chunk-22XJUSMM.js";
import "./chunk-OFKUNYQJ.js";
import "./chunk-W5UPPL3W.js";
import "./chunk-LC6TM5OT.js";
import "./chunk-7SJC6BWZ.js";
import "./chunk-N4JU7GWK.js";
import "./chunk-52BRBQMY.js";
import "./chunk-BA2HXHTW.js";
import "./chunk-RHKRREUU.js";
import "./chunk-ZA2KFUFR.js";
import "./chunk-RIN4CBRB.js";
import "./chunk-NBMM2TZK.js";

// src/pages/users/user-metadata/user-metadata.tsx
import { useParams } from "react-router-dom";
import { ClientError } from "@mercurjs/client";
import { jsx } from "react/jsx-runtime";
var UserMetadata = () => {
  const { id } = useParams();
  const { user, isPending, isError, error } = useUser(id);
  const { mutateAsync, isPending: isMutating } = useUpdateUser(id);
  if (isError) {
    throw error;
  }
  const handleSubmit = async (params, callbacks) => {
    try {
      const result = await mutateAsync({
        metadata: params.metadata === void 0 ? void 0 : params.metadata
      });
      callbacks.onSuccess?.();
      return result;
    } catch (error2) {
      const message = error2 instanceof ClientError ? error2.message : "An error occurred";
      callbacks.onError?.(message);
      throw error2;
    }
  };
  return /* @__PURE__ */ jsx(RouteDrawer, { "data-testid": "user-metadata-drawer", children: /* @__PURE__ */ jsx(
    MetadataForm,
    {
      isPending,
      isMutating,
      hook: handleSubmit,
      metadata: user?.metadata
    }
  ) });
};
export {
  UserMetadata as Component
};
