import { z } from "zod";
import { s as sendPayload } from "./sendPayload-94-N-Ckq.js";
const sendWebhookPayloadSchema = z.object({
  secretKey: z.string().nullable(),
  triggerEvent: z.string(),
  createdAt: z.string(),
  webhook: z.object({
    subscriberUrl: z.string().url(),
    appId: z.string().nullable(),
    payloadTemplate: z.string().nullable()
  }),
  // TODO: Define the data schema
  data: z.any()
});
async function sendWebhook(payload) {
  try {
    const { secretKey, triggerEvent, createdAt, webhook, data } = sendWebhookPayloadSchema.parse(
      JSON.parse(payload)
    );
    await sendPayload(secretKey, triggerEvent, createdAt, webhook, data);
  } catch (error) {
    console.error(error);
    throw error;
  }
}
export {
  sendWebhook
};
