import { ApiResponse } from "../request-response";
import isErrorWithMessage from "../../utils/isErrorWithMessage";
async function mergeTranslatedDataHandler(req, { client }) {
  const body = await req.json();
  const { translatedData, elementTree } = body;
  if (translatedData == null) {
    return ApiResponse.json({ message: "translatedData must be defined" }, { status: 400 });
  }
  if (elementTree == null) {
    return ApiResponse.json({ message: "elementTree must be defined" }, { status: 400 });
  }
  try {
    const translatedElementTree = client.mergeTranslatedData(elementTree, translatedData);
    return ApiResponse.json({ elementTree: translatedElementTree });
  } catch (error) {
    if (isErrorWithMessage(error)) {
      return ApiResponse.json({ message: error.message }, { status: 500 });
    }
    return ApiResponse.json({ message: "Error merging translated data" }, { status: 500 });
  }
}
export {
  mergeTranslatedDataHandler
};
//# sourceMappingURL=merge-translated-data.js.map