"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.toolOpenUrl = exports.getSignedUrl = void 0;
var _dataSources = require("@mirai/data-sources");
const getSignedUrl = async function () {
  let chain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  try {
    const response = await (0, _dataSources.request)({
      endpoint: chain ? '/elevenlabs/signed-url?chain=true' : '/elevenlabs/signed-url',
      hostname: process.env.SERVICE_SYNAPSE,
      method: 'GET'
    });
    return (response === null || response === void 0 ? void 0 : response.signedUrl) || null;
  } catch (error) {
    return null;
  }
};
exports.getSignedUrl = getSignedUrl;
const toolOpenUrl = _ref => {
  let {
    url
  } = _ref;
  try {
    if (!url) return 'Error: No URL provided';
    try {
      const {
        href
      } = new URL(url.startsWith('http') ? url : "https://".concat(url));
      window.location.href = href;
      return "Successfully opened URL: ".concat(href);
    } catch (_unused) {
      return 'Error: Invalid URL format';
    }
  } catch (error) {
    return 'Error: Failed to open URL';
  }
};
exports.toolOpenUrl = toolOpenUrl;
//# sourceMappingURL=elevenLabs.js.map