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


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


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



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


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

// src/pipeable.ts
var pipeable_exports = {};
_chunk6C3VEZWHjs.__export.call(void 0, pipeable_exports, {
  alt: () => alt,
  ap: () => ap,
  bimap: () => bimap,
  chain: () => chain,
  compose: () => compose,
  contramap: () => contramap,
  extend: () => extend,
  filter: () => filter,
  filterMap: () => filterMap,
  filterMapWithIndex: () => filterMapWithIndex,
  filterWithIndex: () => filterWithIndex,
  foldMap: () => foldMap,
  foldMapWithIndex: () => foldMapWithIndex,
  map: () => map,
  mapLeft: () => mapLeft,
  mapWithIndex: () => mapWithIndex,
  partition: () => partition,
  partitionMap: () => partitionMap,
  partitionMapWithIndex: () => partitionMapWithIndex,
  partitionWithIndex: () => partitionWithIndex,
  pipe: () => pipe2,
  pipeable: () => pipeable,
  promap: () => promap,
  reduce: () => reduce,
  reduceRight: () => reduceRight,
  reduceRightWithIndex: () => reduceRightWithIndex,
  reduceWithIndex: () => reduceWithIndex
});
function map(F) {
  return (f) => (fa) => F.map(fa, f);
}
function contramap(F) {
  return (f) => (fa) => F.contramap(fa, f);
}
function mapWithIndex(F) {
  return (f) => (fa) => F.mapWithIndex(fa, f);
}
function ap(F) {
  return (fa) => (fab) => F.ap(fab, fa);
}
function chain(F) {
  return (f) => (fa) => F.chain(fa, f);
}
function bimap(F) {
  return (f, g) => (fea) => F.bimap(fea, f, g);
}
function mapLeft(F) {
  return (f) => (fea) => F.mapLeft(fea, f);
}
function extend(F) {
  return (f) => (wa) => F.extend(wa, f);
}
function reduce(F) {
  return (b, f) => (fa) => F.reduce(fa, b, f);
}
function foldMap(F) {
  return (M) => {
    const foldMapM = F.foldMap(M);
    return (f) => (fa) => foldMapM(fa, f);
  };
}
function reduceRight(F) {
  return (b, f) => (fa) => F.reduceRight(fa, b, f);
}
function reduceWithIndex(F) {
  return (b, f) => (fa) => F.reduceWithIndex(fa, b, f);
}
function foldMapWithIndex(F) {
  return (M) => {
    const foldMapWithIndexM = F.foldMapWithIndex(M);
    return (f) => (fa) => foldMapWithIndexM(fa, f);
  };
}
function reduceRightWithIndex(F) {
  return (b, f) => (fa) => F.reduceRightWithIndex(fa, b, f);
}
function alt(F) {
  return (that) => (fa) => F.alt(fa, that);
}
function filter(F) {
  return (predicate) => (fa) => F.filter(fa, predicate);
}
function filterMap(F) {
  return (f) => (fa) => F.filterMap(fa, f);
}
function partition(F) {
  return (f) => (fa) => F.partition(fa, f);
}
function partitionMap(F) {
  return (f) => (fa) => F.partitionMap(fa, f);
}
function filterWithIndex(F) {
  return (predicate) => (fa) => F.filterWithIndex(fa, predicate);
}
function filterMapWithIndex(F) {
  return (f) => (fa) => F.filterMapWithIndex(fa, f);
}
function partitionWithIndex(F) {
  return (f) => (fa) => F.partitionWithIndex(fa, f);
}
function partitionMapWithIndex(F) {
  return (f) => (fa) => F.partitionMapWithIndex(fa, f);
}
function promap(F) {
  return (f, g) => (fbc) => F.promap(fbc, f, g);
}
function compose(F) {
  return (ea) => (ab) => F.compose(ab, ea);
}
var isFunctor = (I) => typeof I.map === "function";
var isContravariant = (I) => typeof I.contramap === "function";
var isFunctorWithIndex = (I) => typeof I.mapWithIndex === "function";
var isApply = (I) => typeof I.ap === "function";
var isChain = (I) => typeof I.chain === "function";
var isBifunctor = (I) => typeof I.bimap === "function";
var isExtend = (I) => typeof I.extend === "function";
var isFoldable = (I) => typeof I.reduce === "function";
var isFoldableWithIndex = (I) => typeof I.reduceWithIndex === "function";
var isAlt = (I) => typeof I.alt === "function";
var isCompactable = (I) => typeof I.compact === "function";
var isFilterable = (I) => typeof I.filter === "function";
var isFilterableWithIndex = (I) => typeof I.filterWithIndex === "function";
var isProfunctor = (I) => typeof I.promap === "function";
var isSemigroupoid = (I) => typeof I.compose === "function";
var isMonadThrow = (I) => typeof I.throwError === "function";
function pipeable(I) {
  const r = {};
  if (isFunctor(I)) {
    r.map = map(I);
  }
  if (isContravariant(I)) {
    r.contramap = contramap(I);
  }
  if (isFunctorWithIndex(I)) {
    r.mapWithIndex = mapWithIndex(I);
  }
  if (isApply(I)) {
    r.ap = ap(I);
    r.apFirst = _chunkQ2LZCTWPjs.apFirst.call(void 0, I);
    r.apSecond = _chunkQ2LZCTWPjs.apSecond.call(void 0, I);
  }
  if (isChain(I)) {
    r.chain = chain(I);
    r.chainFirst = _chunkEBISTSVAjs.chainFirst.call(void 0, I);
    r.flatten = r.chain(_chunkSQA7G4TEjs.identity);
  }
  if (isBifunctor(I)) {
    r.bimap = bimap(I);
    r.mapLeft = mapLeft(I);
  }
  if (isExtend(I)) {
    r.extend = extend(I);
    r.duplicate = r.extend(_chunkSQA7G4TEjs.identity);
  }
  if (isFoldable(I)) {
    r.reduce = reduce(I);
    r.foldMap = foldMap(I);
    r.reduceRight = reduceRight(I);
  }
  if (isFoldableWithIndex(I)) {
    r.reduceWithIndex = reduceWithIndex(I);
    r.foldMapWithIndex = foldMapWithIndex(I);
    r.reduceRightWithIndex = reduceRightWithIndex(I);
  }
  if (isAlt(I)) {
    r.alt = alt(I);
  }
  if (isCompactable(I)) {
    r.compact = I.compact;
    r.separate = I.separate;
  }
  if (isFilterable(I)) {
    r.filter = filter(I);
    r.filterMap = filterMap(I);
    r.partition = partition(I);
    r.partitionMap = partitionMap(I);
  }
  if (isFilterableWithIndex(I)) {
    r.filterWithIndex = filterWithIndex(I);
    r.filterMapWithIndex = filterMapWithIndex(I);
    r.partitionWithIndex = partitionWithIndex(I);
    r.partitionMapWithIndex = partitionMapWithIndex(I);
  }
  if (isProfunctor(I)) {
    r.promap = promap(I);
  }
  if (isSemigroupoid(I)) {
    r.compose = compose(I);
  }
  if (isMonadThrow(I)) {
    const fromOption = (onNone) => (ma) => ma._tag === "None" ? I.throwError(onNone()) : I.of(ma.value);
    const fromEither = (ma) => ma._tag === "Left" ? I.throwError(ma.left) : I.of(ma.right);
    const fromPredicate = (predicate, onFalse) => (a) => predicate(a) ? I.of(a) : I.throwError(onFalse(a));
    const filterOrElse = (predicate, onFalse) => (ma) => I.chain(ma, (a) => predicate(a) ? I.of(a) : I.throwError(onFalse(a)));
    r.fromOption = fromOption;
    r.fromEither = fromEither;
    r.fromPredicate = fromPredicate;
    r.filterOrElse = filterOrElse;
  }
  return r;
}
var pipe2 = _chunkSQA7G4TEjs.pipe;






























exports.map = map; exports.contramap = contramap; exports.mapWithIndex = mapWithIndex; exports.ap = ap; exports.chain = chain; exports.bimap = bimap; exports.mapLeft = mapLeft; exports.extend = extend; exports.reduce = reduce; exports.foldMap = foldMap; exports.reduceRight = reduceRight; exports.reduceWithIndex = reduceWithIndex; exports.foldMapWithIndex = foldMapWithIndex; exports.reduceRightWithIndex = reduceRightWithIndex; exports.alt = alt; exports.filter = filter; exports.filterMap = filterMap; exports.partition = partition; exports.partitionMap = partitionMap; exports.filterWithIndex = filterWithIndex; exports.filterMapWithIndex = filterMapWithIndex; exports.partitionWithIndex = partitionWithIndex; exports.partitionMapWithIndex = partitionMapWithIndex; exports.promap = promap; exports.compose = compose; exports.pipeable = pipeable; exports.pipe = pipe2; exports.pipeable_exports = pipeable_exports;
