import * as T from "@effect-ts/core/Effect";
import * as L from "@effect-ts/core/Effect/Layer";
import * as S from "@effect-ts/core/Effect/Stream";
import { service, tag } from "@effect-ts/core/Has";
import * as NS from "@effect-ts/node/Stream";
import * as NodeJSFileSystem from "fs";
import { FigletFileError } from "../FigletException/index.mjs"; // -----------------------------------------------------------------------------
// Model
// -----------------------------------------------------------------------------

export const FontFileReaderId = /*#__PURE__*/Symbol();
export function makeFontFileReader() {
  return service({
    read: (path, f) => {
      const buffer = S.mapError_(NS.streamFromReadable(() => NodeJSFileSystem.createReadStream(path)), e => new FigletFileError({
        message: e.error.message
      }));
      return f(path, buffer);
    }
  });
}
export const FontFileReader = /*#__PURE__*/tag(FontFileReaderId);
export const LiveFontFileReader = /*#__PURE__*/L.fromFunction(FontFileReader)(makeFontFileReader);
export const {
  read
} = /*#__PURE__*/T.deriveLifted(FontFileReader)(["read"], [], []);
//# sourceMappingURL=index.mjs.map