import {
  separated
} from "./chunk-RAKKSTP2.mjs";
import {
  fromEitherK
} from "./chunk-SEYMJLV6.mjs";
import {
  guard
} from "./chunk-OVCPI5FM.mjs";
import {
  filterE,
  wiltDefault,
  witherDefault
} from "./chunk-DQQFH64X.mjs";
import {
  append,
  appendW,
  chop,
  chunksOf,
  cons,
  empty,
  head,
  init,
  intercalate,
  intersperse,
  isNonEmpty,
  isOutOfBound,
  last,
  makeBy,
  of,
  prepend,
  prependAll,
  prependW,
  range,
  rotate,
  snoc,
  sortBy,
  splitAt,
  tail,
  union,
  uniq,
  unsafeInsertAt,
  unsafeUpdateAt
} from "./chunk-RGZW4IJC.mjs";
import {
  bindTo,
  flap,
  let_
} from "./chunk-WKK6AYQI.mjs";
import {
  fromCompare
} from "./chunk-KKQVF4Y5.mjs";
import {
  fromEquals
} from "./chunk-YQKF55QL.mjs";
import {
  apFirst,
  apS,
  apSecond
} from "./chunk-ZMCLCMOU.mjs";
import {
  bind,
  chainFirst
} from "./chunk-MDNVYLGG.mjs";
import {
  emptyRecord,
  isLeft,
  isNone,
  isSome,
  none,
  some
} from "./chunk-WPJQNT3M.mjs";
import {
  Ord
} from "./chunk-YK6FTF2O.mjs";
import {
  dual,
  identity,
  pipe
} from "./chunk-ZI34HWXZ.mjs";
import {
  __export
} from "./chunk-QK4PKNB3.mjs";

// src/ReadonlyArray.ts
var ReadonlyArray_exports = {};
__export(ReadonlyArray_exports, {
  Alt: () => Alt,
  Alternative: () => Alternative,
  Applicative: () => Applicative,
  Apply: () => Apply,
  Chain: () => Chain,
  ChainRecBreadthFirst: () => ChainRecBreadthFirst,
  ChainRecDepthFirst: () => ChainRecDepthFirst,
  Compactable: () => Compactable,
  Do: () => Do,
  Extend: () => Extend,
  Filterable: () => Filterable,
  FilterableWithIndex: () => FilterableWithIndex,
  Foldable: () => Foldable,
  FoldableWithIndex: () => FoldableWithIndex,
  FromEither: () => FromEither,
  Functor: () => Functor,
  FunctorWithIndex: () => FunctorWithIndex,
  Monad: () => Monad,
  Pointed: () => Pointed,
  Traversable: () => Traversable,
  TraversableWithIndex: () => TraversableWithIndex,
  URI: () => URI,
  Unfoldable: () => Unfoldable,
  Witherable: () => Witherable,
  Zero: () => Zero,
  _chainRecBreadthFirst: () => _chainRecBreadthFirst,
  _chainRecDepthFirst: () => _chainRecDepthFirst,
  alt: () => alt,
  altW: () => altW,
  ap: () => ap,
  apFirst: () => apFirst2,
  apS: () => apS2,
  apSecond: () => apSecond2,
  append: () => append2,
  appendW: () => appendW2,
  bind: () => bind2,
  bindTo: () => bindTo2,
  chain: () => chain,
  chainFirst: () => chainFirst2,
  chainRecBreadthFirst: () => chainRecBreadthFirst,
  chainRecDepthFirst: () => chainRecDepthFirst,
  chainWithIndex: () => chainWithIndex,
  chop: () => chop2,
  chunksOf: () => chunksOf2,
  compact: () => compact,
  comprehension: () => comprehension,
  concat: () => concat,
  concatW: () => concatW,
  cons: () => cons2,
  deleteAt: () => deleteAt,
  difference: () => difference,
  dropLeft: () => dropLeft,
  dropLeftWhile: () => dropLeftWhile,
  dropRight: () => dropRight,
  duplicate: () => duplicate,
  elem: () => elem,
  empty: () => empty2,
  every: () => every,
  exists: () => exists,
  extend: () => extend,
  filter: () => filter,
  filterE: () => filterE2,
  filterMap: () => filterMap,
  filterMapWithIndex: () => filterMapWithIndex,
  filterWithIndex: () => filterWithIndex,
  findFirst: () => findFirst,
  findFirstMap: () => findFirstMap,
  findIndex: () => findIndex,
  findLast: () => findLast,
  findLastIndex: () => findLastIndex,
  findLastMap: () => findLastMap,
  flap: () => flap2,
  flatMap: () => flatMap,
  flatten: () => flatten,
  foldLeft: () => foldLeft,
  foldMap: () => foldMap,
  foldMapWithIndex: () => foldMapWithIndex,
  foldRight: () => foldRight,
  fromArray: () => fromArray,
  fromEither: () => fromEither,
  fromEitherK: () => fromEitherK2,
  fromOption: () => fromOption,
  fromOptionK: () => fromOptionK,
  fromPredicate: () => fromPredicate,
  getDifferenceMagma: () => getDifferenceMagma,
  getEq: () => getEq,
  getIntersectionSemigroup: () => getIntersectionSemigroup,
  getMonoid: () => getMonoid,
  getOrd: () => getOrd,
  getSemigroup: () => getSemigroup,
  getShow: () => getShow,
  getUnionMonoid: () => getUnionMonoid,
  getUnionSemigroup: () => getUnionSemigroup,
  guard: () => guard2,
  head: () => head2,
  init: () => init2,
  insertAt: () => insertAt,
  intercalate: () => intercalate2,
  intersection: () => intersection,
  intersperse: () => intersperse2,
  isEmpty: () => isEmpty,
  isNonEmpty: () => isNonEmpty2,
  isOutOfBound: () => isOutOfBound2,
  last: () => last2,
  lefts: () => lefts,
  let: () => let_2,
  lookup: () => lookup,
  makeBy: () => makeBy2,
  map: () => map,
  mapWithIndex: () => mapWithIndex,
  match: () => match,
  matchLeft: () => matchLeft,
  matchLeftW: () => matchLeftW,
  matchRight: () => matchRight,
  matchRightW: () => matchRightW,
  matchW: () => matchW,
  modifyAt: () => modifyAt,
  of: () => of2,
  partition: () => partition,
  partitionMap: () => partitionMap,
  partitionMapWithIndex: () => partitionMapWithIndex,
  partitionWithIndex: () => partitionWithIndex,
  prepend: () => prepend2,
  prependAll: () => prependAll2,
  prependToAll: () => prependToAll,
  prependW: () => prependW2,
  range: () => range2,
  readonlyArray: () => readonlyArray,
  reduce: () => reduce,
  reduceRight: () => reduceRight,
  reduceRightWithIndex: () => reduceRightWithIndex,
  reduceWithIndex: () => reduceWithIndex,
  replicate: () => replicate,
  reverse: () => reverse,
  rights: () => rights,
  rotate: () => rotate2,
  scanLeft: () => scanLeft,
  scanRight: () => scanRight,
  separate: () => separate,
  sequence: () => sequence,
  size: () => size,
  snoc: () => snoc2,
  some: () => some2,
  sort: () => sort,
  sortBy: () => sortBy2,
  spanLeft: () => spanLeft,
  splitAt: () => splitAt2,
  tail: () => tail2,
  takeLeft: () => takeLeft,
  takeLeftWhile: () => takeLeftWhile,
  takeRight: () => takeRight,
  toArray: () => toArray,
  traverse: () => traverse,
  traverseWithIndex: () => traverseWithIndex,
  unfold: () => unfold,
  union: () => union2,
  uniq: () => uniq2,
  unsafeDeleteAt: () => unsafeDeleteAt,
  unsafeInsertAt: () => unsafeInsertAt2,
  unsafeUpdateAt: () => unsafeUpdateAt2,
  unzip: () => unzip,
  updateAt: () => updateAt,
  wilt: () => wilt,
  wither: () => wither,
  zero: () => zero,
  zip: () => zip,
  zipWith: () => zipWith
});
var isEmpty = (as) => as.length === 0;
var isNonEmpty2 = isNonEmpty;
var prepend2 = prepend;
var prependW2 = prependW;
var append2 = append;
var appendW2 = appendW;
var makeBy2 = (n, f) => n <= 0 ? empty2 : makeBy(f)(n);
var replicate = (n, a) => makeBy2(n, () => a);
function fromPredicate(predicate) {
  return (a) => predicate(a) ? [a] : empty2;
}
var fromOption = (ma) => isNone(ma) ? empty2 : [ma.value];
var fromEither = (e) => isLeft(e) ? empty2 : [e.right];
var matchW = (onEmpty, onNonEmpty) => (as) => isNonEmpty2(as) ? onNonEmpty(as) : onEmpty();
var match = matchW;
var matchLeftW = (onEmpty, onNonEmpty) => (as) => isNonEmpty2(as) ? onNonEmpty(head(as), tail(as)) : onEmpty();
var matchLeft = matchLeftW;
var foldLeft = matchLeft;
var matchRightW = (onEmpty, onNonEmpty) => (as) => isNonEmpty2(as) ? onNonEmpty(init(as), last(as)) : onEmpty();
var matchRight = matchRightW;
var foldRight = matchRight;
var chainWithIndex = (f) => (as) => {
  if (isEmpty(as)) {
    return empty2;
  }
  const out = [];
  for (let i = 0; i < as.length; i++) {
    out.push(...f(i, as[i]));
  }
  return out;
};
var scanLeft = (b, f) => (as) => {
  const len = as.length;
  const out = new Array(len + 1);
  out[0] = b;
  for (let i = 0; i < len; i++) {
    out[i + 1] = f(out[i], as[i]);
  }
  return out;
};
var scanRight = (b, f) => (as) => {
  const len = as.length;
  const out = new Array(len + 1);
  out[len] = b;
  for (let i = len - 1; i >= 0; i--) {
    out[i] = f(as[i], out[i + 1]);
  }
  return out;
};
var size = (as) => as.length;
var isOutOfBound2 = isOutOfBound;
function lookup(i, as) {
  return as === void 0 ? (as2) => lookup(i, as2) : isOutOfBound2(i, as) ? none : some(as[i]);
}
var head2 = (as) => isNonEmpty2(as) ? some(head(as)) : none;
var last2 = (as) => isNonEmpty2(as) ? some(last(as)) : none;
var tail2 = (as) => isNonEmpty2(as) ? some(tail(as)) : none;
var init2 = (as) => isNonEmpty2(as) ? some(init(as)) : none;
var takeLeft = (n) => (as) => isOutOfBound2(n, as) ? as : n === 0 ? empty2 : as.slice(0, n);
var takeRight = (n) => (as) => isOutOfBound2(n, as) ? as : n === 0 ? empty2 : as.slice(-n);
function takeLeftWhile(predicate) {
  return (as) => {
    const out = [];
    for (const a of as) {
      if (!predicate(a)) {
        break;
      }
      out.push(a);
    }
    const len = out.length;
    return len === as.length ? as : len === 0 ? empty2 : out;
  };
}
var spanLeftIndex = (as, predicate) => {
  const l = as.length;
  let i = 0;
  for (; i < l; i++) {
    if (!predicate(as[i])) {
      break;
    }
  }
  return i;
};
function spanLeft(predicate) {
  return (as) => {
    const [init3, rest] = splitAt2(spanLeftIndex(as, predicate))(as);
    return { init: init3, rest };
  };
}
var dropLeft = (n) => (as) => n <= 0 || isEmpty(as) ? as : n >= as.length ? empty2 : as.slice(n, as.length);
var dropRight = (n) => (as) => n <= 0 || isEmpty(as) ? as : n >= as.length ? empty2 : as.slice(0, as.length - n);
function dropLeftWhile(predicate) {
  return (as) => {
    const i = spanLeftIndex(as, predicate);
    return i === 0 ? as : i === as.length ? empty2 : as.slice(i);
  };
}
var findIndex = (predicate) => (as) => {
  for (let i = 0; i < as.length; i++) {
    if (predicate(as[i])) {
      return some(i);
    }
  }
  return none;
};
function findFirst(predicate) {
  return (as) => {
    for (let i = 0; i < as.length; i++) {
      if (predicate(as[i])) {
        return some(as[i]);
      }
    }
    return none;
  };
}
var findFirstMap = (f) => (as) => {
  for (let i = 0; i < as.length; i++) {
    const out = f(as[i]);
    if (isSome(out)) {
      return out;
    }
  }
  return none;
};
function findLast(predicate) {
  return (as) => {
    for (let i = as.length - 1; i >= 0; i--) {
      if (predicate(as[i])) {
        return some(as[i]);
      }
    }
    return none;
  };
}
var findLastMap = (f) => (as) => {
  for (let i = as.length - 1; i >= 0; i--) {
    const out = f(as[i]);
    if (isSome(out)) {
      return out;
    }
  }
  return none;
};
var findLastIndex = (predicate) => (as) => {
  for (let i = as.length - 1; i >= 0; i--) {
    if (predicate(as[i])) {
      return some(i);
    }
  }
  return none;
};
var insertAt = (i, a) => (as) => i < 0 || i > as.length ? none : some(unsafeInsertAt(i, a, as));
var updateAt = (i, a) => modifyAt(i, () => a);
var deleteAt = (i) => (as) => isOutOfBound2(i, as) ? none : some(unsafeDeleteAt(i, as));
var modifyAt = (i, f) => (as) => isOutOfBound2(i, as) ? none : some(unsafeUpdateAt2(i, f(as[i]), as));
var reverse = (as) => as.length <= 1 ? as : as.slice().reverse();
var rights = (as) => {
  const r = [];
  for (let i = 0; i < as.length; i++) {
    const a = as[i];
    if (a._tag === "Right") {
      r.push(a.right);
    }
  }
  return r;
};
var lefts = (as) => {
  const r = [];
  for (let i = 0; i < as.length; i++) {
    const a = as[i];
    if (a._tag === "Left") {
      r.push(a.left);
    }
  }
  return r;
};
var sort = (O) => (as) => as.length <= 1 ? as : as.slice().sort(O.compare);
var zipWith = (fa, fb, f) => {
  const fc = [];
  const len = Math.min(fa.length, fb.length);
  for (let i = 0; i < len; i++) {
    fc[i] = f(fa[i], fb[i]);
  }
  return fc;
};
function zip(as, bs) {
  if (bs === void 0) {
    return (bs2) => zip(bs2, as);
  }
  return zipWith(as, bs, (a, b) => [a, b]);
}
var unzip = (as) => {
  const fa = [];
  const fb = [];
  for (let i = 0; i < as.length; i++) {
    fa[i] = as[i][0];
    fb[i] = as[i][1];
  }
  return [fa, fb];
};
var prependAll2 = (middle) => {
  const f = prependAll(middle);
  return (as) => isNonEmpty2(as) ? f(as) : as;
};
var intersperse2 = (middle) => {
  const f = intersperse(middle);
  return (as) => isNonEmpty2(as) ? f(as) : as;
};
var rotate2 = (n) => {
  const f = rotate(n);
  return (as) => isNonEmpty2(as) ? f(as) : as;
};
function elem(E) {
  return (a, as) => {
    if (as === void 0) {
      const elemE = elem(E);
      return (as2) => elemE(a, as2);
    }
    const predicate = (element) => E.equals(element, a);
    let i = 0;
    for (; i < as.length; i++) {
      if (predicate(as[i])) {
        return true;
      }
    }
    return false;
  };
}
var uniq2 = (E) => {
  const f = uniq(E);
  return (as) => isNonEmpty2(as) ? f(as) : as;
};
var sortBy2 = (ords) => {
  const f = sortBy(ords);
  return (as) => isNonEmpty2(as) ? f(as) : as;
};
var chop2 = (f) => {
  const g = chop(f);
  return (as) => isNonEmpty2(as) ? g(as) : empty2;
};
var splitAt2 = (n) => (as) => n >= 1 && isNonEmpty2(as) ? splitAt(n)(as) : isEmpty(as) ? [as, empty2] : [empty2, as];
var chunksOf2 = (n) => {
  const f = chunksOf(n);
  return (as) => isNonEmpty2(as) ? f(as) : empty2;
};
var fromOptionK = (f) => (...a) => fromOption(f(...a));
function comprehension(input, f, g = () => true) {
  const go = (scope, input2) => isNonEmpty2(input2) ? flatMap(head(input2), (a) => go(pipe(scope, append2(a)), tail(input2))) : g(...scope) ? [f(...scope)] : empty2;
  return go(empty2, input);
}
var concatW = (second) => (first) => isEmpty(first) ? second : isEmpty(second) ? first : first.concat(second);
var concat = concatW;
function union2(E) {
  const unionE = union(E);
  return (first, second) => {
    if (second === void 0) {
      const unionE2 = union2(E);
      return (second2) => unionE2(second2, first);
    }
    return isNonEmpty2(first) && isNonEmpty2(second) ? unionE(second)(first) : isNonEmpty2(first) ? first : second;
  };
}
function intersection(E) {
  const elemE = elem(E);
  return (xs, ys) => {
    if (ys === void 0) {
      const intersectionE = intersection(E);
      return (ys2) => intersectionE(ys2, xs);
    }
    return xs.filter((a) => elemE(a, ys));
  };
}
function difference(E) {
  const elemE = elem(E);
  return (xs, ys) => {
    if (ys === void 0) {
      const differenceE = difference(E);
      return (ys2) => differenceE(ys2, xs);
    }
    return xs.filter((a) => !elemE(a, ys));
  };
}
var _map = (fa, f) => pipe(fa, map(f));
var _mapWithIndex = (fa, f) => pipe(fa, mapWithIndex(f));
var _ap = (fab, fa) => pipe(fab, ap(fa));
var _filter = (fa, predicate) => pipe(fa, filter(predicate));
var _filterMap = (fa, f) => pipe(fa, filterMap(f));
var _partition = (fa, predicate) => pipe(fa, partition(predicate));
var _partitionMap = (fa, f) => pipe(fa, partitionMap(f));
var _partitionWithIndex = (fa, predicateWithIndex) => pipe(fa, partitionWithIndex(predicateWithIndex));
var _partitionMapWithIndex = (fa, f) => pipe(fa, partitionMapWithIndex(f));
var _alt = (fa, that) => pipe(fa, alt(that));
var _reduce = (fa, b, f) => pipe(fa, reduce(b, f));
var _foldMap = (M) => {
  const foldMapM = foldMap(M);
  return (fa, f) => pipe(fa, foldMapM(f));
};
var _reduceRight = (fa, b, f) => pipe(fa, reduceRight(b, f));
var _reduceWithIndex = (fa, b, f) => pipe(fa, reduceWithIndex(b, f));
var _foldMapWithIndex = (M) => {
  const foldMapWithIndexM = foldMapWithIndex(M);
  return (fa, f) => pipe(fa, foldMapWithIndexM(f));
};
var _reduceRightWithIndex = (fa, b, f) => pipe(fa, reduceRightWithIndex(b, f));
var _filterMapWithIndex = (fa, f) => pipe(fa, filterMapWithIndex(f));
var _filterWithIndex = (fa, predicateWithIndex) => pipe(fa, filterWithIndex(predicateWithIndex));
var _extend = (fa, f) => pipe(fa, extend(f));
var _traverse = (F) => {
  const traverseF = traverse(F);
  return (ta, f) => pipe(ta, traverseF(f));
};
var _traverseWithIndex = (F) => {
  const traverseWithIndexF = traverseWithIndex(F);
  return (ta, f) => pipe(ta, traverseWithIndexF(f));
};
var _chainRecDepthFirst = (a, f) => pipe(a, chainRecDepthFirst(f));
var _chainRecBreadthFirst = (a, f) => pipe(a, chainRecBreadthFirst(f));
var of2 = of;
var zero = () => empty2;
var altW = (that) => (fa) => fa.concat(that());
var alt = altW;
var ap = (fa) => flatMap((f) => pipe(fa, map(f)));
var flatMap = /* @__PURE__ */ dual(
  2,
  (ma, f) => pipe(
    ma,
    chainWithIndex((i, a) => f(a, i))
  )
);
var flatten = /* @__PURE__ */ flatMap(identity);
var map = (f) => (fa) => fa.map((a) => f(a));
var mapWithIndex = (f) => (fa) => fa.map((a, i) => f(i, a));
var separate = (fa) => {
  const left = [];
  const right = [];
  for (const e of fa) {
    if (e._tag === "Left") {
      left.push(e.left);
    } else {
      right.push(e.right);
    }
  }
  return separated(left, right);
};
var filter = (predicate) => (as) => as.filter(predicate);
var filterMapWithIndex = (f) => (fa) => {
  const out = [];
  for (let i = 0; i < fa.length; i++) {
    const optionB = f(i, fa[i]);
    if (isSome(optionB)) {
      out.push(optionB.value);
    }
  }
  return out;
};
var filterMap = (f) => filterMapWithIndex((_, a) => f(a));
var compact = /* @__PURE__ */ filterMap(identity);
var partition = (predicate) => partitionWithIndex((_, a) => predicate(a));
var partitionWithIndex = (predicateWithIndex) => (as) => {
  const left = [];
  const right = [];
  for (let i = 0; i < as.length; i++) {
    const a = as[i];
    if (predicateWithIndex(i, a)) {
      right.push(a);
    } else {
      left.push(a);
    }
  }
  return separated(left, right);
};
var partitionMap = (f) => partitionMapWithIndex((_, a) => f(a));
var partitionMapWithIndex = (f) => (fa) => {
  const left = [];
  const right = [];
  for (let i = 0; i < fa.length; i++) {
    const e = f(i, fa[i]);
    if (e._tag === "Left") {
      left.push(e.left);
    } else {
      right.push(e.right);
    }
  }
  return separated(left, right);
};
var filterWithIndex = (predicateWithIndex) => (as) => as.filter((a, i) => predicateWithIndex(i, a));
var extend = (f) => (wa) => wa.map((_, i) => f(wa.slice(i)));
var duplicate = /* @__PURE__ */ extend(identity);
var foldMapWithIndex = (M) => (f) => (fa) => fa.reduce((b, a, i) => M.concat(b, f(i, a)), M.empty);
var reduce = (b, f) => reduceWithIndex(b, (_, b2, a) => f(b2, a));
var foldMap = (M) => {
  const foldMapWithIndexM = foldMapWithIndex(M);
  return (f) => foldMapWithIndexM((_, a) => f(a));
};
var reduceWithIndex = (b, f) => (fa) => {
  const len = fa.length;
  let out = b;
  for (let i = 0; i < len; i++) {
    out = f(i, out, fa[i]);
  }
  return out;
};
var reduceRight = (b, f) => reduceRightWithIndex(b, (_, a, b2) => f(a, b2));
var reduceRightWithIndex = (b, f) => (fa) => fa.reduceRight((b2, a, i) => f(i, a, b2), b);
var traverse = (F) => {
  const traverseWithIndexF = traverseWithIndex(F);
  return (f) => traverseWithIndexF((_, a) => f(a));
};
var sequence = (F) => (ta) => {
  return _reduce(
    ta,
    F.of(zero()),
    (fas, fa) => F.ap(
      F.map(fas, (as) => (a) => pipe(as, append2(a))),
      fa
    )
  );
};
var traverseWithIndex = (F) => (f) => reduceWithIndex(
  F.of(zero()),
  (i, fbs, a) => F.ap(
    F.map(fbs, (bs) => (b) => pipe(bs, append2(b))),
    f(i, a)
  )
);
var wither = (F) => {
  const _witherF = _wither(F);
  return (f) => (fa) => _witherF(fa, f);
};
var wilt = (F) => {
  const _wiltF = _wilt(F);
  return (f) => (fa) => _wiltF(fa, f);
};
var unfold = (b, f) => {
  const out = [];
  let bb = b;
  while (true) {
    const mt = f(bb);
    if (isSome(mt)) {
      const [a, b2] = mt.value;
      out.push(a);
      bb = b2;
    } else {
      break;
    }
  }
  return out;
};
var URI = "ReadonlyArray";
var getShow = (S) => ({
  show: (as) => `[${as.map(S.show).join(", ")}]`
});
var getSemigroup = () => ({
  concat: (first, second) => isEmpty(first) ? second : isEmpty(second) ? first : first.concat(second)
});
var getMonoid = () => ({
  concat: getSemigroup().concat,
  empty: empty2
});
var getEq = (E) => fromEquals((xs, ys) => xs.length === ys.length && xs.every((x, i) => E.equals(x, ys[i])));
var getOrd = (O) => fromCompare((a, b) => {
  const aLen = a.length;
  const bLen = b.length;
  const len = Math.min(aLen, bLen);
  for (let i = 0; i < len; i++) {
    const ordering = O.compare(a[i], b[i]);
    if (ordering !== 0) {
      return ordering;
    }
  }
  return Ord.compare(aLen, bLen);
});
var getUnionSemigroup = (E) => {
  const unionE = union2(E);
  return {
    concat: (first, second) => unionE(second)(first)
  };
};
var getUnionMonoid = (E) => ({
  concat: getUnionSemigroup(E).concat,
  empty: empty2
});
var getIntersectionSemigroup = (E) => {
  const intersectionE = intersection(E);
  return {
    concat: (first, second) => intersectionE(second)(first)
  };
};
var getDifferenceMagma = (E) => {
  const differenceE = difference(E);
  return {
    concat: (first, second) => differenceE(second)(first)
  };
};
var Functor = {
  URI,
  map: _map
};
var flap2 = /* @__PURE__ */ flap(Functor);
var Pointed = {
  URI,
  of: of2
};
var FunctorWithIndex = {
  URI,
  map: _map,
  mapWithIndex: _mapWithIndex
};
var Apply = {
  URI,
  map: _map,
  ap: _ap
};
var apFirst2 = /* @__PURE__ */ apFirst(Apply);
var apSecond2 = /* @__PURE__ */ apSecond(Apply);
var Applicative = {
  URI,
  map: _map,
  ap: _ap,
  of: of2
};
var Chain = {
  URI,
  map: _map,
  ap: _ap,
  chain: flatMap
};
var Monad = {
  URI,
  map: _map,
  ap: _ap,
  of: of2,
  chain: flatMap
};
var chainFirst2 = /* @__PURE__ */ chainFirst(Chain);
var Unfoldable = {
  URI,
  unfold
};
var Alt = {
  URI,
  map: _map,
  alt: _alt
};
var Zero = {
  URI,
  zero
};
var guard2 = /* @__PURE__ */ guard(Zero, Pointed);
var Alternative = {
  URI,
  map: _map,
  ap: _ap,
  of: of2,
  alt: _alt,
  zero
};
var Extend = {
  URI,
  map: _map,
  extend: _extend
};
var Compactable = {
  URI,
  compact,
  separate
};
var Filterable = {
  URI,
  map: _map,
  compact,
  separate,
  filter: _filter,
  filterMap: _filterMap,
  partition: _partition,
  partitionMap: _partitionMap
};
var FilterableWithIndex = {
  URI,
  map: _map,
  mapWithIndex: _mapWithIndex,
  compact,
  separate,
  filter: _filter,
  filterMap: _filterMap,
  partition: _partition,
  partitionMap: _partitionMap,
  partitionMapWithIndex: _partitionMapWithIndex,
  partitionWithIndex: _partitionWithIndex,
  filterMapWithIndex: _filterMapWithIndex,
  filterWithIndex: _filterWithIndex
};
var Foldable = {
  URI,
  reduce: _reduce,
  foldMap: _foldMap,
  reduceRight: _reduceRight
};
var FoldableWithIndex = {
  URI,
  reduce: _reduce,
  foldMap: _foldMap,
  reduceRight: _reduceRight,
  reduceWithIndex: _reduceWithIndex,
  foldMapWithIndex: _foldMapWithIndex,
  reduceRightWithIndex: _reduceRightWithIndex
};
var Traversable = {
  URI,
  map: _map,
  reduce: _reduce,
  foldMap: _foldMap,
  reduceRight: _reduceRight,
  traverse: _traverse,
  sequence
};
var TraversableWithIndex = {
  URI,
  map: _map,
  mapWithIndex: _mapWithIndex,
  reduce: _reduce,
  foldMap: _foldMap,
  reduceRight: _reduceRight,
  reduceWithIndex: _reduceWithIndex,
  foldMapWithIndex: _foldMapWithIndex,
  reduceRightWithIndex: _reduceRightWithIndex,
  traverse: _traverse,
  sequence,
  traverseWithIndex: _traverseWithIndex
};
var chainRecDepthFirst = (f) => (a) => {
  const todo = [...f(a)];
  const out = [];
  while (todo.length > 0) {
    const e = todo.shift();
    if (isLeft(e)) {
      todo.unshift(...f(e.left));
    } else {
      out.push(e.right);
    }
  }
  return out;
};
var ChainRecDepthFirst = {
  URI,
  map: _map,
  ap: _ap,
  chain: flatMap,
  chainRec: _chainRecDepthFirst
};
var chainRecBreadthFirst = (f) => (a) => {
  const initial = f(a);
  const todo = [];
  const out = [];
  function go(e) {
    if (isLeft(e)) {
      f(e.left).forEach((v) => todo.push(v));
    } else {
      out.push(e.right);
    }
  }
  for (const e of initial) {
    go(e);
  }
  while (todo.length > 0) {
    go(todo.shift());
  }
  return out;
};
var ChainRecBreadthFirst = {
  URI,
  map: _map,
  ap: _ap,
  chain: flatMap,
  chainRec: _chainRecBreadthFirst
};
var _wither = /* @__PURE__ */ witherDefault(Traversable, Compactable);
var _wilt = /* @__PURE__ */ wiltDefault(Traversable, Compactable);
var Witherable = {
  URI,
  map: _map,
  compact,
  separate,
  filter: _filter,
  filterMap: _filterMap,
  partition: _partition,
  partitionMap: _partitionMap,
  reduce: _reduce,
  foldMap: _foldMap,
  reduceRight: _reduceRight,
  traverse: _traverse,
  sequence,
  wither: _wither,
  wilt: _wilt
};
var filterE2 = /* @__PURE__ */ filterE(Witherable);
var FromEither = {
  URI,
  fromEither
};
var fromEitherK2 = /* @__PURE__ */ fromEitherK(FromEither);
var unsafeInsertAt2 = unsafeInsertAt;
var unsafeUpdateAt2 = (i, a, as) => isNonEmpty2(as) ? unsafeUpdateAt(i, a, as) : as;
var unsafeDeleteAt = (i, as) => {
  const xs = as.slice();
  xs.splice(i, 1);
  return xs;
};
var toArray = (as) => as.slice();
var fromArray = (as) => isEmpty(as) ? empty2 : as.slice();
var empty2 = empty;
function every(predicate) {
  return (as) => as.every(predicate);
}
var some2 = (predicate) => (as) => as.some(predicate);
var exists = some2;
var intercalate2 = (M) => {
  const intercalateM = intercalate(M);
  return (middle) => match(() => M.empty, intercalateM(middle));
};
var Do = /* @__PURE__ */ of2(emptyRecord);
var bindTo2 = /* @__PURE__ */ bindTo(Functor);
var let_2 = /* @__PURE__ */ let_(Functor);
var bind2 = /* @__PURE__ */ bind(Chain);
var apS2 = /* @__PURE__ */ apS(Apply);
var chain = flatMap;
var range2 = range;
var cons2 = cons;
var snoc2 = snoc;
var prependToAll = prependAll2;
var readonlyArray = {
  URI,
  compact,
  separate,
  map: _map,
  ap: _ap,
  of: of2,
  chain: flatMap,
  filter: _filter,
  filterMap: _filterMap,
  partition: _partition,
  partitionMap: _partitionMap,
  mapWithIndex: _mapWithIndex,
  partitionMapWithIndex: _partitionMapWithIndex,
  partitionWithIndex: _partitionWithIndex,
  filterMapWithIndex: _filterMapWithIndex,
  filterWithIndex: _filterWithIndex,
  alt: _alt,
  zero,
  unfold,
  reduce: _reduce,
  foldMap: _foldMap,
  reduceRight: _reduceRight,
  traverse: _traverse,
  sequence,
  reduceWithIndex: _reduceWithIndex,
  foldMapWithIndex: _foldMapWithIndex,
  reduceRightWithIndex: _reduceRightWithIndex,
  traverseWithIndex: _traverseWithIndex,
  extend: _extend,
  wither: _wither,
  wilt: _wilt
};

export {
  isEmpty,
  isNonEmpty2 as isNonEmpty,
  prepend2 as prepend,
  prependW2 as prependW,
  append2 as append,
  appendW2 as appendW,
  makeBy2 as makeBy,
  replicate,
  fromPredicate,
  fromOption,
  fromEither,
  matchW,
  match,
  matchLeftW,
  matchLeft,
  foldLeft,
  matchRightW,
  matchRight,
  foldRight,
  chainWithIndex,
  scanLeft,
  scanRight,
  size,
  isOutOfBound2 as isOutOfBound,
  lookup,
  head2 as head,
  last2 as last,
  tail2 as tail,
  init2 as init,
  takeLeft,
  takeRight,
  takeLeftWhile,
  spanLeft,
  dropLeft,
  dropRight,
  dropLeftWhile,
  findIndex,
  findFirst,
  findFirstMap,
  findLast,
  findLastMap,
  findLastIndex,
  insertAt,
  updateAt,
  deleteAt,
  modifyAt,
  reverse,
  rights,
  lefts,
  sort,
  zipWith,
  zip,
  unzip,
  prependAll2 as prependAll,
  intersperse2 as intersperse,
  rotate2 as rotate,
  elem,
  uniq2 as uniq,
  sortBy2 as sortBy,
  chop2 as chop,
  splitAt2 as splitAt,
  chunksOf2 as chunksOf,
  fromOptionK,
  comprehension,
  concatW,
  concat,
  union2 as union,
  intersection,
  difference,
  _chainRecDepthFirst,
  _chainRecBreadthFirst,
  of2 as of,
  zero,
  altW,
  alt,
  ap,
  flatMap,
  flatten,
  map,
  mapWithIndex,
  separate,
  filter,
  filterMapWithIndex,
  filterMap,
  compact,
  partition,
  partitionWithIndex,
  partitionMap,
  partitionMapWithIndex,
  filterWithIndex,
  extend,
  duplicate,
  foldMapWithIndex,
  reduce,
  foldMap,
  reduceWithIndex,
  reduceRight,
  reduceRightWithIndex,
  traverse,
  sequence,
  traverseWithIndex,
  wither,
  wilt,
  unfold,
  URI,
  getShow,
  getSemigroup,
  getMonoid,
  getEq,
  getOrd,
  getUnionSemigroup,
  getUnionMonoid,
  getIntersectionSemigroup,
  getDifferenceMagma,
  Functor,
  flap2 as flap,
  Pointed,
  FunctorWithIndex,
  Apply,
  apFirst2 as apFirst,
  apSecond2 as apSecond,
  Applicative,
  Chain,
  Monad,
  chainFirst2 as chainFirst,
  Unfoldable,
  Alt,
  Zero,
  guard2 as guard,
  Alternative,
  Extend,
  Compactable,
  Filterable,
  FilterableWithIndex,
  Foldable,
  FoldableWithIndex,
  Traversable,
  TraversableWithIndex,
  chainRecDepthFirst,
  ChainRecDepthFirst,
  chainRecBreadthFirst,
  ChainRecBreadthFirst,
  Witherable,
  filterE2 as filterE,
  FromEither,
  fromEitherK2 as fromEitherK,
  unsafeInsertAt2 as unsafeInsertAt,
  unsafeUpdateAt2 as unsafeUpdateAt,
  unsafeDeleteAt,
  toArray,
  fromArray,
  empty2 as empty,
  every,
  some2 as some,
  exists,
  intercalate2 as intercalate,
  Do,
  bindTo2 as bindTo,
  let_2 as let_,
  bind2 as bind,
  apS2 as apS,
  chain,
  range2 as range,
  cons2 as cons,
  snoc2 as snoc,
  prependToAll,
  readonlyArray,
  ReadonlyArray_exports
};
