import { getDefaultAudioUrl, getDefaultVideoUrl } from "./convert-nodes.js";
import { toPlainTextBase } from "./to-plain-text-base.js";
const toPlainText = async (content, options = {}) => {
  const gen = toPlainTextBase(content, options.delimiter, options.addLinksToText);
  let next = gen.next();
  while (!next.done) {
    switch (next.value.command) {
      case "getImageUrl": {
        const url = options.urlShortener ? await options.urlShortener?.(next.value.data) : next.value.data;
        next = gen.next(url);
        break;
      }
      case "getVideoUrl": {
        const url = await (options.getVideoUrl ? options.getVideoUrl(next.value.data) : getDefaultVideoUrl(next.value.data));
        next = gen.next(url);
        break;
      }
      case "getVideoEmbeddedUrl": {
        const url = await (options.getVideoEmbeddedUrl ? options.getVideoEmbeddedUrl(next.value.data) : next.value.data);
        next = gen.next(url);
        break;
      }
      case "getAudioUrl": {
        const url = await (options.getAudioUrl ? options.getAudioUrl(next.value.data) : getDefaultAudioUrl(next.value.data));
        next = gen.next(url);
        break;
      }
      case "getGifUrl": {
        const url = await (options.getGifUrl ? options.getGifUrl(next.value.data) : next.value.data);
        next = gen.next(url);
        break;
      }
      default:
        return "";
    }
  }
  return next.value;
};
export {
  toPlainText
};
//# sourceMappingURL=to-plain-text.js.map
