import { Cache } from '../../../../assets/cache/Cache.mjs';
import { FontStylePromiseCache, HTMLTextSystem } from '../HTMLTextSystem.mjs';
import { loadFontCSS } from './loadFontCSS.mjs';

async function getFontCss(fontFamilies, style) {
  const fontPromises = fontFamilies.filter((fontFamily) => Cache.has(fontFamily)).map((fontFamily, i) => {
    if (!FontStylePromiseCache.has(fontFamily)) {
      const { url } = Cache.get(fontFamily);
      if (i === 0) {
        FontStylePromiseCache.set(fontFamily, loadFontCSS(style, url));
      } else {
        FontStylePromiseCache.set(fontFamily, loadFontCSS({
          ...HTMLTextSystem.defaultFontOptions,
          fontFamily
        }, url));
      }
    }
    return FontStylePromiseCache.get(fontFamily);
  });
  return (await Promise.all(fontPromises)).join("\n");
}

export { getFontCss };
//# sourceMappingURL=getFontCss.mjs.map
