import * as C from "@effect-ts/core/Collections/Immutable/Chunk";
import * as NA from "@effect-ts/core/Collections/Immutable/NonEmptyArray";
import * as E from "@effect-ts/core/Either";
import * as Eq from "@effect-ts/core/Equal";
import * as O from "@effect-ts/core/Option";
import * as Structural from "@effect-ts/core/Structural";
import { FigHeaderError } from "../../FigletException/index.mjs"; // -----------------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------------

export const LeftToRight = {
  _tag: "LeftToRight",
  value: 0
};
export const RightToLeft = {
  _tag: "RightToLeft",
  value: 1
};
export const values = /*#__PURE__*/C.from([LeftToRight, RightToLeft]);
/**
 * Obtains the printing direction starting from the provided value.
 *
 * @param value The number representing the `PrintDirection`.
 * @returns The `PrintDirection` that corresponds to the given numeric value.
 */

export function fromValue(value) {
  if (value === 0) {
    return E.right(LeftToRight);
  } else if (value === 1) {
    return E.right(RightToLeft);
  } else {
    return E.left(NA.single(new FigHeaderError({
      message: `Could not parse value "${value}" to a PrintDirection`
    })));
  }
}
/**
 * Interprets the header settings and returns the selected `PrintDirection`.
 *
 * @param header The `FigHeader` where the print direction is defined.
 * @returns A `FigletResult` containing the `PrintDirection`.
 */

export function fromHeader(header) {
  return O.fold_(header.printDirection, () => E.right(LeftToRight), E.right);
} // -----------------------------------------------------------------------------
// Instances
// -----------------------------------------------------------------------------

export const equalPrintDirection = /*#__PURE__*/Eq.makeEqual(Structural.equals);
//# sourceMappingURL=index.mjs.map