"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/services/slack.ts
var slack_exports = {};
__export(slack_exports, {
  makeSlackClient: () => makeSlackClient
});
module.exports = __toCommonJS(slack_exports);

// src/services/delegates/slack/sendMessage.ts
async function sendSlackMessage(message, baseUrl, botToken) {
  try {
    const response = await fetch(`${baseUrl}/chat.postMessage`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "Authorization": `Bearer ${botToken}`
      },
      body: JSON.stringify({
        channel: message.channelId,
        text: message.message,
        unfurl_links: true,
        unfurl_media: true
      })
    });
    if (!response.ok) {
      return {
        ok: false,
        channel: message.channelId,
        ts: (/* @__PURE__ */ new Date()).getTime(),
        error: `HTTP error: ${response.status} ${response.statusText}`
      };
    }
    const result = await response.json();
    if (!result.ok) {
      return {
        ok: false,
        channel: message.channelId,
        ts: (/* @__PURE__ */ new Date()).getTime(),
        error: `Slack API error: ${result.error}`
      };
    }
    return {
      ok: true,
      channel: result.channel,
      ts: (/* @__PURE__ */ new Date()).getTime()
    };
  } catch (error) {
    console.error("Error sending Slack message:", error);
    return {
      ok: false,
      channel: message.channelId,
      ts: (/* @__PURE__ */ new Date()).getTime(),
      error: `Failed to send Slack message: ${error instanceof Error ? error.message : String(error)}`
    };
  }
}

// src/services/slack.ts
function makeSlackClient(baseUrl, botToken) {
  return {
    sendMessage: async (message) => {
      const response = await sendSlackMessage(message, baseUrl, botToken);
      return response;
    }
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  makeSlackClient
});
