import {
  EQ_ORD,
  GT,
  LT
} from "./chunk-FCKUZQOW.js";

// src/data/tuple.ts
function pair(a, b) {
  return [a, b];
}
function fst(p) {
  return p[0];
}
function snd(p) {
  return p[1];
}
function swap(p) {
  return [p[1], p[0]];
}
function mapFst(p, fn) {
  return [fn(p[0]), p[1]];
}
function mapSnd(p, fn) {
  return [p[0], fn(p[1])];
}
function bimap(p, f, g) {
  return [f(p[0]), g(p[1])];
}
function both(p, fn) {
  return [fn(p[0]), fn(p[1])];
}
function pairToArray(p) {
  return [p[0], p[1]];
}
function curryPair(fn) {
  return (a) => (b) => fn([a, b]);
}
function uncurryPair(fn) {
  return (p) => fn(p[0], p[1]);
}
function triple(a, b, c) {
  return [a, b, c];
}
function tripleFirst(t) {
  return t[0];
}
function tripleSecond(t) {
  return t[1];
}
function tripleThird(t) {
  return t[2];
}
function tripleToArray(t) {
  return [t[0], t[1], t[2]];
}
function tripleMap(t, f, g, h) {
  return [f(t[0]), g(t[1]), h(t[2])];
}
function eqPair(eqA, eqB) {
  return {
    equals: ((a, b) => eqA.equals(a[0], b[0]) && eqB.equals(a[1], b[1])),
    notEquals: ((a, b) => eqA.notEquals(a[0], b[0]) || eqB.notEquals(a[1], b[1]))
  };
}
function ordPair(ordA, ordB) {
  const compare = (a, b) => {
    const cmp1 = ordA.compare(a[0], b[0]);
    if (cmp1 !== EQ_ORD)
      return cmp1;
    return ordB.compare(a[1], b[1]);
  };
  return {
    equals: ((a, b) => compare(a, b) === EQ_ORD),
    notEquals: ((a, b) => compare(a, b) !== EQ_ORD),
    compare,
    lessThan: ((a, b) => compare(a, b) === LT),
    lessThanOrEqual: ((a, b) => compare(a, b) !== GT),
    greaterThan: ((a, b) => compare(a, b) === GT),
    greaterThanOrEqual: ((a, b) => compare(a, b) !== LT)
  };
}
function eqTriple(eqA, eqB, eqC) {
  return {
    equals: ((a, b) => eqA.equals(a[0], b[0]) && eqB.equals(a[1], b[1]) && eqC.equals(a[2], b[2])),
    notEquals: ((a, b) => eqA.notEquals(a[0], b[0]) || eqB.notEquals(a[1], b[1]) || eqC.notEquals(a[2], b[2]))
  };
}
function ordTriple(ordA, ordB, ordC) {
  const compare = (a, b) => {
    const cmp1 = ordA.compare(a[0], b[0]);
    if (cmp1 !== EQ_ORD)
      return cmp1;
    const cmp2 = ordB.compare(a[1], b[1]);
    if (cmp2 !== EQ_ORD)
      return cmp2;
    return ordC.compare(a[2], b[2]);
  };
  return {
    equals: ((a, b) => compare(a, b) === EQ_ORD),
    notEquals: ((a, b) => compare(a, b) !== EQ_ORD),
    compare,
    lessThan: ((a, b) => compare(a, b) === LT),
    lessThanOrEqual: ((a, b) => compare(a, b) !== GT),
    greaterThan: ((a, b) => compare(a, b) === GT),
    greaterThanOrEqual: ((a, b) => compare(a, b) !== LT)
  };
}
function zipToPairs(as, bs) {
  const len = Math.min(as.length, bs.length);
  const result = [];
  for (let i = 0; i < len; i++)
    result.push([as[i], bs[i]]);
  return result;
}
function unzipPairs(pairs) {
  const as = [];
  const bs = [];
  for (const [a, b] of pairs) {
    as.push(a);
    bs.push(b);
  }
  return [as, bs];
}
var TupleExt = {
  pair,
  fst,
  snd,
  swap,
  mapFst,
  mapSnd,
  bimap,
  both,
  toArray: pairToArray,
  curry: curryPair,
  uncurry: uncurryPair,
  triple,
  tripleFirst,
  tripleSecond,
  tripleThird,
  tripleToArray,
  tripleMap,
  zipToPairs,
  unzipPairs
};

// src/data/range.ts
function range(start, end, step = 1) {
  return { start, end, step, inclusive: false };
}
function rangeInclusive(start, end, step = 1) {
  return { start, end, step, inclusive: true };
}
function rangeBy(r, step) {
  return { ...r, step };
}
function rangeReversed(r) {
  return {
    start: r.inclusive ? r.end : r.end - r.step,
    end: r.start,
    step: -r.step,
    inclusive: r.inclusive
  };
}
function* rangeIterator(r) {
  const { start, end, step, inclusive } = r;
  if (step > 0) {
    for (let i = start; inclusive ? i <= end : i < end; i += step)
      yield i;
  } else if (step < 0) {
    for (let i = start; inclusive ? i >= end : i > end; i += step)
      yield i;
  }
}
function rangeToArray(r) {
  return [...rangeIterator(r)];
}
function rangeForEach(r, fn) {
  let idx = 0;
  for (const n of rangeIterator(r))
    fn(n, idx++);
}
function rangeMap(r, fn) {
  const result = [];
  let idx = 0;
  for (const n of rangeIterator(r))
    result.push(fn(n, idx++));
  return result;
}
function rangeFilter(r, pred) {
  const result = [];
  for (const n of rangeIterator(r))
    if (pred(n))
      result.push(n);
  return result;
}
function rangeReduce(r, init, fn) {
  let acc = init;
  for (const n of rangeIterator(r))
    acc = fn(acc, n);
  return acc;
}
function rangeContains(r, value) {
  const { start, end, step, inclusive } = r;
  if (step > 0) {
    if (inclusive ? value > end : value >= end)
      return false;
    if (value < start)
      return false;
  } else {
    if (inclusive ? value < end : value <= end)
      return false;
    if (value > start)
      return false;
  }
  return (value - start) % step === 0;
}
function rangeSize(r) {
  const { start, end, step, inclusive } = r;
  if (step === 0)
    return 0;
  const diff = end - start;
  if (step > 0 && diff <= 0 || step < 0 && diff >= 0)
    return 0;
  const count = Math.floor(diff / step);
  if (inclusive && diff % step === 0)
    return count + 1;
  return count + (inclusive ? 0 : 0) || count;
}
function rangeFirst(r) {
  const iter = rangeIterator(r);
  const result = iter.next();
  return result.done ? void 0 : result.value;
}
function rangeLast(r) {
  let last;
  for (const n of rangeIterator(r))
    last = n;
  return last;
}
function rangeIsEmpty(r) {
  return rangeFirst(r) === void 0;
}
var eqRange = {
  equals: ((a, b) => a.start === b.start && a.end === b.end && a.step === b.step && a.inclusive === b.inclusive),
  notEquals: ((a, b) => a.start !== b.start || a.end !== b.end || a.step !== b.step || a.inclusive !== b.inclusive)
};
var ordRange = (() => {
  const compare = (a, b) => {
    if (a.start < b.start)
      return LT;
    if (a.start > b.start)
      return GT;
    if (a.end < b.end)
      return LT;
    if (a.end > b.end)
      return GT;
    if (a.step < b.step)
      return LT;
    if (a.step > b.step)
      return GT;
    if (a.inclusive && !b.inclusive)
      return GT;
    if (!a.inclusive && b.inclusive)
      return LT;
    return EQ_ORD;
  };
  return {
    equals: eqRange.equals,
    notEquals: eqRange.notEquals,
    compare,
    lessThan: ((a, b) => compare(a, b) === LT),
    lessThanOrEqual: ((a, b) => compare(a, b) !== GT),
    greaterThan: ((a, b) => compare(a, b) === GT),
    greaterThanOrEqual: ((a, b) => compare(a, b) !== LT)
  };
})();
var RangeExt = {
  range,
  inclusive: rangeInclusive,
  by: rangeBy,
  reversed: rangeReversed,
  iterator: rangeIterator,
  toArray: rangeToArray,
  forEach: rangeForEach,
  map: rangeMap,
  filter: rangeFilter,
  reduce: rangeReduce,
  contains: rangeContains,
  size: rangeSize,
  first: rangeFirst,
  last: rangeLast,
  isEmpty: rangeIsEmpty
};

export {
  pair,
  fst,
  snd,
  swap,
  mapFst,
  mapSnd,
  bimap,
  both,
  pairToArray,
  curryPair,
  uncurryPair,
  triple,
  tripleFirst,
  tripleSecond,
  tripleThird,
  tripleToArray,
  tripleMap,
  eqPair,
  ordPair,
  eqTriple,
  ordTriple,
  zipToPairs,
  unzipPairs,
  TupleExt,
  range,
  rangeInclusive,
  rangeBy,
  rangeReversed,
  rangeIterator,
  rangeToArray,
  rangeForEach,
  rangeMap,
  rangeFilter,
  rangeReduce,
  rangeContains,
  rangeSize,
  rangeFirst,
  rangeLast,
  rangeIsEmpty,
  eqRange,
  ordRange,
  RangeExt
};
//# sourceMappingURL=chunk-5PGNJFUU.js.map