"use strict";Object.defineProperty(exports, "__esModule", {value: true});

var _chunkT4ZJ6CA2js = require('./chunk-T4ZJ6CA2.js');


var _chunkR2MJP25Ojs = require('./chunk-R2MJP25O.js');


var _chunkD6EN5A4Bjs = require('./chunk-D6EN5A4B.js');




var _chunkUNAIGMDHjs = require('./chunk-UNAIGMDH.js');





























var _chunk67GC34HGjs = require('./chunk-67GC34HG.js');




var _chunk7K74W2G3js = require('./chunk-7K74W2G3.js');


var _chunkQC33EBBCjs = require('./chunk-QC33EBBC.js');


var _chunkTGVEPLW2js = require('./chunk-TGVEPLW2.js');




var _chunkQ2LZCTWPjs = require('./chunk-Q2LZCTWP.js');



var _chunkEBISTSVAjs = require('./chunk-EBISTSVA.js');







var _chunkOTKMOSH2js = require('./chunk-OTKMOSH2.js');


var _chunkR6SGMBHRjs = require('./chunk-R6SGMBHR.js');




var _chunkSQA7G4TEjs = require('./chunk-SQA7G4TE.js');


var _chunk6C3VEZWHjs = require('./chunk-6C3VEZWH.js');

// src/ReadonlyArray.ts
var ReadonlyArray_exports = {};
_chunk6C3VEZWHjs.__export.call(void 0, 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 = _chunk67GC34HGjs.isNonEmpty;
var prepend2 = _chunk67GC34HGjs.prepend;
var prependW2 = _chunk67GC34HGjs.prependW;
var append2 = _chunk67GC34HGjs.append;
var appendW2 = _chunk67GC34HGjs.appendW;
var makeBy2 = (n, f) => n <= 0 ? empty2 : _chunk67GC34HGjs.makeBy.call(void 0, f)(n);
var replicate = (n, a) => makeBy2(n, () => a);
function fromPredicate(predicate) {
  return (a) => predicate(a) ? [a] : empty2;
}
var fromOption = (ma) => _chunkOTKMOSH2js.isNone.call(void 0, ma) ? empty2 : [ma.value];
var fromEither = (e) => _chunkOTKMOSH2js.isLeft.call(void 0, 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(_chunk67GC34HGjs.head.call(void 0, as), _chunk67GC34HGjs.tail.call(void 0, as)) : onEmpty();
var matchLeft = matchLeftW;
var foldLeft = matchLeft;
var matchRightW = (onEmpty, onNonEmpty) => (as) => isNonEmpty2(as) ? onNonEmpty(_chunk67GC34HGjs.init.call(void 0, as), _chunk67GC34HGjs.last.call(void 0, 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 = _chunk67GC34HGjs.isOutOfBound;
function lookup(i, as) {
  return as === void 0 ? (as2) => lookup(i, as2) : isOutOfBound2(i, as) ? _chunkOTKMOSH2js.none : _chunkOTKMOSH2js.some.call(void 0, as[i]);
}
var head2 = (as) => isNonEmpty2(as) ? _chunkOTKMOSH2js.some.call(void 0, _chunk67GC34HGjs.head.call(void 0, as)) : _chunkOTKMOSH2js.none;
var last2 = (as) => isNonEmpty2(as) ? _chunkOTKMOSH2js.some.call(void 0, _chunk67GC34HGjs.last.call(void 0, as)) : _chunkOTKMOSH2js.none;
var tail2 = (as) => isNonEmpty2(as) ? _chunkOTKMOSH2js.some.call(void 0, _chunk67GC34HGjs.tail.call(void 0, as)) : _chunkOTKMOSH2js.none;
var init2 = (as) => isNonEmpty2(as) ? _chunkOTKMOSH2js.some.call(void 0, _chunk67GC34HGjs.init.call(void 0, as)) : _chunkOTKMOSH2js.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 _chunkOTKMOSH2js.some.call(void 0, i);
    }
  }
  return _chunkOTKMOSH2js.none;
};
function findFirst(predicate) {
  return (as) => {
    for (let i = 0; i < as.length; i++) {
      if (predicate(as[i])) {
        return _chunkOTKMOSH2js.some.call(void 0, as[i]);
      }
    }
    return _chunkOTKMOSH2js.none;
  };
}
var findFirstMap = (f) => (as) => {
  for (let i = 0; i < as.length; i++) {
    const out = f(as[i]);
    if (_chunkOTKMOSH2js.isSome.call(void 0, out)) {
      return out;
    }
  }
  return _chunkOTKMOSH2js.none;
};
function findLast(predicate) {
  return (as) => {
    for (let i = as.length - 1; i >= 0; i--) {
      if (predicate(as[i])) {
        return _chunkOTKMOSH2js.some.call(void 0, as[i]);
      }
    }
    return _chunkOTKMOSH2js.none;
  };
}
var findLastMap = (f) => (as) => {
  for (let i = as.length - 1; i >= 0; i--) {
    const out = f(as[i]);
    if (_chunkOTKMOSH2js.isSome.call(void 0, out)) {
      return out;
    }
  }
  return _chunkOTKMOSH2js.none;
};
var findLastIndex = (predicate) => (as) => {
  for (let i = as.length - 1; i >= 0; i--) {
    if (predicate(as[i])) {
      return _chunkOTKMOSH2js.some.call(void 0, i);
    }
  }
  return _chunkOTKMOSH2js.none;
};
var insertAt = (i, a) => (as) => i < 0 || i > as.length ? _chunkOTKMOSH2js.none : _chunkOTKMOSH2js.some.call(void 0, _chunk67GC34HGjs.unsafeInsertAt.call(void 0, i, a, as));
var updateAt = (i, a) => modifyAt(i, () => a);
var deleteAt = (i) => (as) => isOutOfBound2(i, as) ? _chunkOTKMOSH2js.none : _chunkOTKMOSH2js.some.call(void 0, unsafeDeleteAt(i, as));
var modifyAt = (i, f) => (as) => isOutOfBound2(i, as) ? _chunkOTKMOSH2js.none : _chunkOTKMOSH2js.some.call(void 0, 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 = _chunk67GC34HGjs.prependAll.call(void 0, middle);
  return (as) => isNonEmpty2(as) ? f(as) : as;
};
var intersperse2 = (middle) => {
  const f = _chunk67GC34HGjs.intersperse.call(void 0, middle);
  return (as) => isNonEmpty2(as) ? f(as) : as;
};
var rotate2 = (n) => {
  const f = _chunk67GC34HGjs.rotate.call(void 0, 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 = _chunk67GC34HGjs.uniq.call(void 0, E);
  return (as) => isNonEmpty2(as) ? f(as) : as;
};
var sortBy2 = (ords) => {
  const f = _chunk67GC34HGjs.sortBy.call(void 0, ords);
  return (as) => isNonEmpty2(as) ? f(as) : as;
};
var chop2 = (f) => {
  const g = _chunk67GC34HGjs.chop.call(void 0, f);
  return (as) => isNonEmpty2(as) ? g(as) : empty2;
};
var splitAt2 = (n) => (as) => n >= 1 && isNonEmpty2(as) ? _chunk67GC34HGjs.splitAt.call(void 0, n)(as) : isEmpty(as) ? [as, empty2] : [empty2, as];
var chunksOf2 = (n) => {
  const f = _chunk67GC34HGjs.chunksOf.call(void 0, 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(_chunk67GC34HGjs.head.call(void 0, input2), (a) => go(_chunkSQA7G4TEjs.pipe.call(void 0, scope, append2(a)), _chunk67GC34HGjs.tail.call(void 0, 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 = _chunk67GC34HGjs.union.call(void 0, 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) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, map(f));
var _mapWithIndex = (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, mapWithIndex(f));
var _ap = (fab, fa) => _chunkSQA7G4TEjs.pipe.call(void 0, fab, ap(fa));
var _filter = (fa, predicate) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, filter(predicate));
var _filterMap = (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, filterMap(f));
var _partition = (fa, predicate) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, partition(predicate));
var _partitionMap = (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, partitionMap(f));
var _partitionWithIndex = (fa, predicateWithIndex) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, partitionWithIndex(predicateWithIndex));
var _partitionMapWithIndex = (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, partitionMapWithIndex(f));
var _alt = (fa, that) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, alt(that));
var _reduce = (fa, b, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, reduce(b, f));
var _foldMap = (M) => {
  const foldMapM = foldMap(M);
  return (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, foldMapM(f));
};
var _reduceRight = (fa, b, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, reduceRight(b, f));
var _reduceWithIndex = (fa, b, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, reduceWithIndex(b, f));
var _foldMapWithIndex = (M) => {
  const foldMapWithIndexM = foldMapWithIndex(M);
  return (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, foldMapWithIndexM(f));
};
var _reduceRightWithIndex = (fa, b, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, reduceRightWithIndex(b, f));
var _filterMapWithIndex = (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, filterMapWithIndex(f));
var _filterWithIndex = (fa, predicateWithIndex) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, filterWithIndex(predicateWithIndex));
var _extend = (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, extend(f));
var _traverse = (F) => {
  const traverseF = traverse(F);
  return (ta, f) => _chunkSQA7G4TEjs.pipe.call(void 0, ta, traverseF(f));
};
var _traverseWithIndex = (F) => {
  const traverseWithIndexF = traverseWithIndex(F);
  return (ta, f) => _chunkSQA7G4TEjs.pipe.call(void 0, ta, traverseWithIndexF(f));
};
var _chainRecDepthFirst = (a, f) => _chunkSQA7G4TEjs.pipe.call(void 0, a, chainRecDepthFirst(f));
var _chainRecBreadthFirst = (a, f) => _chunkSQA7G4TEjs.pipe.call(void 0, a, chainRecBreadthFirst(f));
var of2 = _chunk67GC34HGjs.of;
var zero = () => empty2;
var altW = (that) => (fa) => fa.concat(that());
var alt = altW;
var ap = (fa) => flatMap((f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, map(f)));
var flatMap = /* @__PURE__ */ _chunkSQA7G4TEjs.dual.call(void 0, 
  2,
  (ma, f) => _chunkSQA7G4TEjs.pipe.call(void 0, 
    ma,
    chainWithIndex((i, a) => f(a, i))
  )
);
var flatten = /* @__PURE__ */ flatMap(_chunkSQA7G4TEjs.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 _chunkT4ZJ6CA2js.separated.call(void 0, 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 (_chunkOTKMOSH2js.isSome.call(void 0, optionB)) {
      out.push(optionB.value);
    }
  }
  return out;
};
var filterMap = (f) => filterMapWithIndex((_, a) => f(a));
var compact = /* @__PURE__ */ filterMap(_chunkSQA7G4TEjs.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 _chunkT4ZJ6CA2js.separated.call(void 0, 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 _chunkT4ZJ6CA2js.separated.call(void 0, 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(_chunkSQA7G4TEjs.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) => _chunkSQA7G4TEjs.pipe.call(void 0, as, append2(a))),
      fa
    )
  );
};
var traverseWithIndex = (F) => (f) => reduceWithIndex(
  F.of(zero()),
  (i, fbs, a) => F.ap(
    F.map(fbs, (bs) => (b) => _chunkSQA7G4TEjs.pipe.call(void 0, 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 (_chunkOTKMOSH2js.isSome.call(void 0, 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) => _chunkTGVEPLW2js.fromEquals.call(void 0, (xs, ys) => xs.length === ys.length && xs.every((x, i) => E.equals(x, ys[i])));
var getOrd = (O) => _chunkQC33EBBCjs.fromCompare.call(void 0, (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 _chunkR6SGMBHRjs.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__ */ _chunk7K74W2G3js.flap.call(void 0, Functor);
var Pointed = {
  URI,
  of: of2
};
var FunctorWithIndex = {
  URI,
  map: _map,
  mapWithIndex: _mapWithIndex
};
var Apply = {
  URI,
  map: _map,
  ap: _ap
};
var apFirst2 = /* @__PURE__ */ _chunkQ2LZCTWPjs.apFirst.call(void 0, Apply);
var apSecond2 = /* @__PURE__ */ _chunkQ2LZCTWPjs.apSecond.call(void 0, 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__ */ _chunkEBISTSVAjs.chainFirst.call(void 0, Chain);
var Unfoldable = {
  URI,
  unfold
};
var Alt = {
  URI,
  map: _map,
  alt: _alt
};
var Zero = {
  URI,
  zero
};
var guard2 = /* @__PURE__ */ _chunkD6EN5A4Bjs.guard.call(void 0, 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 (_chunkOTKMOSH2js.isLeft.call(void 0, 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 (_chunkOTKMOSH2js.isLeft.call(void 0, 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__ */ _chunkUNAIGMDHjs.witherDefault.call(void 0, Traversable, Compactable);
var _wilt = /* @__PURE__ */ _chunkUNAIGMDHjs.wiltDefault.call(void 0, 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__ */ _chunkUNAIGMDHjs.filterE.call(void 0, Witherable);
var FromEither = {
  URI,
  fromEither
};
var fromEitherK2 = /* @__PURE__ */ _chunkR2MJP25Ojs.fromEitherK.call(void 0, FromEither);
var unsafeInsertAt2 = _chunk67GC34HGjs.unsafeInsertAt;
var unsafeUpdateAt2 = (i, a, as) => isNonEmpty2(as) ? _chunk67GC34HGjs.unsafeUpdateAt.call(void 0, 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 = _chunk67GC34HGjs.empty;
function every(predicate) {
  return (as) => as.every(predicate);
}
var some2 = (predicate) => (as) => as.some(predicate);
var exists = some2;
var intercalate2 = (M) => {
  const intercalateM = _chunk67GC34HGjs.intercalate.call(void 0, M);
  return (middle) => match(() => M.empty, intercalateM(middle));
};
var Do = /* @__PURE__ */ of2(_chunkOTKMOSH2js.emptyRecord);
var bindTo2 = /* @__PURE__ */ _chunk7K74W2G3js.bindTo.call(void 0, Functor);
var let_2 = /* @__PURE__ */ _chunk7K74W2G3js.let_.call(void 0, Functor);
var bind2 = /* @__PURE__ */ _chunkEBISTSVAjs.bind.call(void 0, Chain);
var apS2 = /* @__PURE__ */ _chunkQ2LZCTWPjs.apS.call(void 0, Apply);
var chain = flatMap;
var range2 = _chunk67GC34HGjs.range;
var cons2 = _chunk67GC34HGjs.cons;
var snoc2 = _chunk67GC34HGjs.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
};










































































































































































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