"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.equalOldLayout = exports.UnderscoreSmushing = exports.OppositePairSmushing = exports.HorizontalFitting = exports.HierarchySmushing = exports.HardblankSmushing = exports.FullWidth = exports.EqualCharacterSmushing = exports.BigXSmushing = void 0;
exports.fromValue = fromValue;
exports.values = void 0;

var C = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect-ts/core/Collections/Immutable/Chunk"));

var NA = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect-ts/core/Collections/Immutable/NonEmptyArray"));

var E = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect-ts/core/Either"));

var _Function = /*#__PURE__*/require("@effect-ts/core/Function");

var _Equal = /*#__PURE__*/require("@effect-ts/system/Equal");

var _index = /*#__PURE__*/require("../../FigletException/index.js");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

const FullWidth = {
  _tag: "FullWidth",
  value: -1
};
exports.FullWidth = FullWidth;
const HorizontalFitting = {
  _tag: "HorizontalFitting",
  value: 0
};
exports.HorizontalFitting = HorizontalFitting;
const EqualCharacterSmushing = {
  _tag: "EqualCharacterSmushing",
  value: 1
};
exports.EqualCharacterSmushing = EqualCharacterSmushing;
const UnderscoreSmushing = {
  _tag: "UnderscoreSmushing",
  value: 2
};
exports.UnderscoreSmushing = UnderscoreSmushing;
const HierarchySmushing = {
  _tag: "HierarchySmushing",
  value: 4
};
exports.HierarchySmushing = HierarchySmushing;
const OppositePairSmushing = {
  _tag: "OppositePairSmushing",
  value: 8
};
exports.OppositePairSmushing = OppositePairSmushing;
const BigXSmushing = {
  _tag: "BigXSmushing",
  value: 16
};
exports.BigXSmushing = BigXSmushing;
const HardblankSmushing = {
  _tag: "HardblankSmushing",
  value: 32
};
exports.HardblankSmushing = HardblankSmushing;
const values = /*#__PURE__*/C.from([FullWidth, HorizontalFitting, EqualCharacterSmushing, UnderscoreSmushing, HierarchySmushing, OppositePairSmushing, BigXSmushing, HardblankSmushing]); // -----------------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------------

/**
 * Obtains the list of requested settings starting from the provided value.
 *
 * @param requestedSettings The number representing the `OldLayout`.
 * @return The `OldLayout` that corresponds to the given numeric value.
 */

exports.values = values;

function fromValue(requestedSettings) {
  if (requestedSettings < -1 || requestedSettings > 63) {
    return E.left(NA.single(new _index.FigHeaderError({
      message: `OldLayout needs a value between 1 and 63, inclusive, received "${requestedSettings}"`
    })));
  }

  if (requestedSettings === -1) {
    return E.right(C.single(FullWidth));
  }

  if (requestedSettings === 0) {
    return E.right(C.single(HorizontalFitting));
  }

  const result = C.chain_(C.filter_(values, setting => setting.value !== 0), setting => (requestedSettings & setting.value) === setting.value ? C.single(setting) : C.empty());
  return E.right(result);
} // -----------------------------------------------------------------------------
// Instances
// -----------------------------------------------------------------------------


const equalOldLayout = /*#__PURE__*/(0, _Equal.makeEqual)((x, y) => x._tag === y._tag && x.value === y.value);
exports.equalOldLayout = equalOldLayout;
//# sourceMappingURL=index.js.map