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






var _chunk3GCDIUJCjs = require('./chunk-3GCDIUJC.js');


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



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


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

// src/Tuple.ts
var Tuple_exports = {};
_chunk6C3VEZWHjs.__export.call(void 0, Tuple_exports, {
  Bifunctor: () => Bifunctor,
  Comonad: () => Comonad,
  Foldable: () => Foldable,
  Functor: () => Functor,
  Semigroupoid: () => Semigroupoid,
  Traversable: () => Traversable,
  URI: () => URI,
  bimap: () => bimap,
  compose: () => compose,
  duplicate: () => duplicate,
  extend: () => extend,
  extract: () => extract2,
  flap: () => flap2,
  foldMap: () => foldMap2,
  fst: () => fst2,
  getApplicative: () => getApplicative,
  getApply: () => getApply,
  getChain: () => getChain,
  getChainRec: () => getChainRec,
  getMonad: () => getMonad,
  map: () => map,
  mapFst: () => mapFst,
  mapLeft: () => mapLeft,
  mapSnd: () => mapSnd,
  reduce: () => reduce2,
  reduceRight: () => reduceRight2,
  sequence: () => sequence,
  snd: () => snd2,
  swap: () => swap,
  traverse: () => traverse,
  tuple: () => tuple
});
var fst2 = _chunk3GCDIUJCjs.fst;
var snd2 = _chunk3GCDIUJCjs.snd;
var swap = (ea) => [snd2(ea), fst2(ea)];
function getApply(S) {
  return {
    URI,
    _E: void 0,
    map: _map,
    ap: (fab, fa) => [fst2(fab)(fst2(fa)), S.concat(snd2(fab), snd2(fa))]
  };
}
var of = (M) => (a) => {
  return [a, M.empty];
};
function getApplicative(M) {
  const A = getApply(M);
  return {
    URI,
    _E: void 0,
    map: A.map,
    ap: A.ap,
    of: of(M)
  };
}
function getChain(S) {
  const A = getApply(S);
  return {
    URI,
    _E: void 0,
    map: A.map,
    ap: A.ap,
    chain: (ma, f) => {
      const [b, s] = f(fst2(ma));
      return [b, S.concat(snd2(ma), s)];
    }
  };
}
function getMonad(M) {
  const C = getChain(M);
  return {
    URI,
    _E: void 0,
    map: C.map,
    ap: C.ap,
    chain: C.chain,
    of: of(M)
  };
}
function getChainRec(M) {
  const chainRec = (a, f) => {
    let result = f(a);
    let acc = M.empty;
    let s = fst2(result);
    while (s._tag === "Left") {
      acc = M.concat(acc, snd2(result));
      result = f(s.left);
      s = fst2(result);
    }
    return [s.right, M.concat(acc, snd2(result))];
  };
  const C = getChain(M);
  return {
    URI,
    _E: void 0,
    map: C.map,
    ap: C.ap,
    chain: C.chain,
    chainRec
  };
}
var _compose = (bc, ab) => _chunkSQA7G4TEjs.pipe.call(void 0, bc, compose(ab));
var _map = (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, mapFst(f));
var _bimap = (fa, f, g) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, bimap(f, g));
var _mapLeft = (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, mapSnd(f));
var _extend = (wa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, wa, extend(f));
var _reduce = (fa, b, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, reduce2(b, f));
var _foldMap = (M) => {
  const foldMapM = foldMap2(M);
  return (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, foldMapM(f));
};
var _reduceRight = (fa, b, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, reduceRight2(b, f));
function _traverse(F) {
  const traverseF = traverse(F);
  return (ta, f) => _chunkSQA7G4TEjs.pipe.call(void 0, ta, traverseF(f));
}
var bimap = (f, g) => (fa) => [
  g(fst2(fa)),
  f(snd2(fa))
];
var mapFst = (f) => (fa) => [f(fst2(fa)), snd2(fa)];
var mapSnd = (f) => (fa) => [fst2(fa), f(snd2(fa))];
var compose = (ab) => (bc) => [fst2(bc), snd2(ab)];
var extend = (f) => (wa) => [f(wa), snd2(wa)];
var duplicate = /* @__PURE__ */ extend(_chunkSQA7G4TEjs.identity);
var extract2 = _chunk3GCDIUJCjs.extract;
var foldMap2 = _chunk3GCDIUJCjs.foldMap;
var reduce2 = _chunk3GCDIUJCjs.reduce;
var reduceRight2 = _chunk3GCDIUJCjs.reduceRight;
var traverse = (F) => {
  return (f) => (ta) => F.map(f(fst2(ta)), (b) => [b, snd2(ta)]);
};
var sequence = (F) => (fas) => {
  return F.map(fst2(fas), (a) => [a, snd2(fas)]);
};
var URI = "Tuple";
var Functor = {
  URI,
  map: _map
};
var flap2 = /* @__PURE__ */ _chunk7K74W2G3js.flap.call(void 0, Functor);
var Bifunctor = {
  URI,
  bimap: _bimap,
  mapLeft: _mapLeft
};
var Semigroupoid = {
  URI,
  compose: _compose
};
var Comonad = {
  URI,
  map: _map,
  extend: _extend,
  extract: extract2
};
var Foldable = {
  URI,
  reduce: _reduce,
  foldMap: _foldMap,
  reduceRight: _reduceRight
};
var Traversable = {
  URI,
  map: _map,
  reduce: _reduce,
  foldMap: _foldMap,
  reduceRight: _reduceRight,
  traverse: _traverse,
  sequence
};
var map = mapFst;
var mapLeft = mapSnd;
var tuple = {
  URI,
  compose: _compose,
  map: _map,
  bimap: _bimap,
  mapLeft: _mapLeft,
  extract: extract2,
  extend: _extend,
  reduce: _reduce,
  foldMap: _foldMap,
  reduceRight: _reduceRight,
  traverse: _traverse,
  sequence
};


































exports.fst = fst2; exports.snd = snd2; exports.swap = swap; exports.getApply = getApply; exports.getApplicative = getApplicative; exports.getChain = getChain; exports.getMonad = getMonad; exports.getChainRec = getChainRec; exports.bimap = bimap; exports.mapFst = mapFst; exports.mapSnd = mapSnd; exports.compose = compose; exports.extend = extend; exports.duplicate = duplicate; exports.extract = extract2; exports.foldMap = foldMap2; exports.reduce = reduce2; exports.reduceRight = reduceRight2; exports.traverse = traverse; exports.sequence = sequence; exports.URI = URI; exports.Functor = Functor; exports.flap = flap2; exports.Bifunctor = Bifunctor; exports.Semigroupoid = Semigroupoid; exports.Comonad = Comonad; exports.Foldable = Foldable; exports.Traversable = Traversable; exports.map = map; exports.mapLeft = mapLeft; exports.tuple = tuple; exports.Tuple_exports = Tuple_exports;
