import {
  _filter,
  _filterMap,
  _filterMapWithIndex,
  _filterWithIndex,
  _foldMap,
  _foldMapWithIndex,
  _map,
  _mapWithIndex,
  _partition,
  _partitionMap,
  _partitionMapWithIndex,
  _partitionWithIndex,
  _reduce,
  _reduceRight,
  _reduceRightWithIndex,
  _reduceWithIndex,
  _sequence,
  _traverse,
  compact,
  difference,
  elem,
  every,
  filter,
  filterMap,
  filterMapWithIndex,
  filterWithIndex,
  foldMap,
  foldMapWithIndex,
  fromFoldable,
  fromFoldableMap,
  getEq,
  getMonoid,
  getShow,
  has as has2,
  hasOwnProperty,
  intersection,
  isEmpty,
  isSubrecord,
  lookup,
  map,
  mapWithIndex,
  partition,
  partitionMap,
  partitionMapWithIndex,
  partitionWithIndex,
  reduce,
  reduceRight,
  reduceRightWithIndex,
  reduceWithIndex,
  separate,
  sequence,
  singleton,
  size,
  some as some2,
  traverse,
  traverseWithIndex,
  union,
  upsertAt
} from "./chunk-QP6SKG7O.mjs";
import {
  Foldable
} from "./chunk-SSXOLM6A.mjs";
import {
  wiltDefault,
  witherDefault
} from "./chunk-DQQFH64X.mjs";
import {
  Ord
} from "./chunk-F7QG6CT5.mjs";
import {
  flap
} from "./chunk-WKK6AYQI.mjs";
import {
  last
} from "./chunk-CRY5FFSR.mjs";
import {
  has,
  isNone,
  none,
  some
} from "./chunk-WPJQNT3M.mjs";
import {
  pipe
} from "./chunk-ZI34HWXZ.mjs";
import {
  __export
} from "./chunk-QK4PKNB3.mjs";

// src/Record.ts
var Record_exports = {};
__export(Record_exports, {
  Compactable: () => Compactable,
  Filterable: () => Filterable,
  FilterableWithIndex: () => FilterableWithIndex,
  Foldable: () => Foldable2,
  FoldableWithIndex: () => FoldableWithIndex,
  Functor: () => Functor,
  FunctorWithIndex: () => FunctorWithIndex,
  Traversable: () => Traversable,
  TraversableWithIndex: () => TraversableWithIndex,
  URI: () => URI,
  Witherable: () => Witherable,
  collect: () => collect,
  compact: () => compact2,
  deleteAt: () => deleteAt,
  difference: () => difference2,
  elem: () => elem2,
  empty: () => empty,
  every: () => every2,
  filter: () => filter2,
  filterMap: () => filterMap2,
  filterMapWithIndex: () => filterMapWithIndex2,
  filterWithIndex: () => filterWithIndex2,
  flap: () => flap2,
  foldMap: () => foldMap2,
  foldMapWithIndex: () => foldMapWithIndex2,
  fromEntries: () => fromEntries,
  fromFoldable: () => fromFoldable2,
  fromFoldableMap: () => fromFoldableMap2,
  getDifferenceMagma: () => getDifferenceMagma,
  getEq: () => getEq2,
  getFoldable: () => getFoldable,
  getFoldableWithIndex: () => getFoldableWithIndex,
  getIntersectionSemigroup: () => getIntersectionSemigroup,
  getMonoid: () => getMonoid2,
  getShow: () => getShow2,
  getTraversable: () => getTraversable,
  getTraversableWithIndex: () => getTraversableWithIndex,
  getUnionMonoid: () => getUnionMonoid,
  getUnionSemigroup: () => getUnionSemigroup,
  getWitherable: () => getWitherable,
  has: () => has3,
  hasOwnProperty: () => hasOwnProperty2,
  insertAt: () => insertAt,
  intersection: () => intersection2,
  isEmpty: () => isEmpty2,
  isSubrecord: () => isSubrecord2,
  keys: () => keys,
  lookup: () => lookup2,
  map: () => map2,
  mapWithIndex: () => mapWithIndex2,
  modifyAt: () => modifyAt,
  partition: () => partition2,
  partitionMap: () => partitionMap2,
  partitionMapWithIndex: () => partitionMapWithIndex2,
  partitionWithIndex: () => partitionWithIndex2,
  pop: () => pop,
  record: () => record,
  reduce: () => reduce2,
  reduceRight: () => reduceRight2,
  reduceRightWithIndex: () => reduceRightWithIndex2,
  reduceWithIndex: () => reduceWithIndex2,
  separate: () => separate2,
  sequence: () => sequence2,
  singleton: () => singleton2,
  size: () => size2,
  some: () => some3,
  toArray: () => toArray,
  toEntries: () => toEntries,
  toUnfoldable: () => toUnfoldable,
  traverse: () => traverse2,
  traverseWithIndex: () => traverseWithIndex2,
  union: () => union2,
  updateAt: () => updateAt,
  upsertAt: () => upsertAt2,
  wilt: () => wilt,
  wither: () => wither
});
var size2 = size;
var isEmpty2 = isEmpty;
var keys_ = (O) => (r) => Object.keys(r).sort(O.compare);
var keys = /* @__PURE__ */ keys_(Ord);
function collect(O) {
  if (typeof O === "function") {
    return collect(Ord)(O);
  }
  const keysO = keys_(O);
  return (f) => (r) => {
    const out = [];
    for (const key of keysO(r)) {
      out.push(f(key, r[key]));
    }
    return out;
  };
}
var toArray = /* @__PURE__ */ collect(Ord)((k, a) => [
  k,
  a
]);
function toUnfoldable(U) {
  return (r) => {
    const sas = toArray(r);
    const len = sas.length;
    return U.unfold(0, (b) => b < len ? some([sas[b], b + 1]) : none);
  };
}
var upsertAt2 = upsertAt;
var has3 = has2;
function deleteAt(k) {
  return (r) => {
    if (!has.call(r, k)) {
      return r;
    }
    const out = Object.assign({}, r);
    delete out[k];
    return out;
  };
}
var updateAt = (k, a) => modifyAt(k, () => a);
var modifyAt = (k, f) => (r) => {
  if (!has3(k, r)) {
    return none;
  }
  const out = Object.assign({}, r);
  out[k] = f(r[k]);
  return some(out);
};
function pop(k) {
  const deleteAtk = deleteAt(k);
  return (r) => {
    const oa = lookup2(k, r);
    return isNone(oa) ? none : some([oa.value, deleteAtk(r)]);
  };
}
var isSubrecord2 = isSubrecord;
var lookup2 = lookup;
var mapWithIndex2 = mapWithIndex;
var map2 = map;
function reduceWithIndex2(...args) {
  return args.length === 1 ? reduceWithIndex(args[0]) : reduceWithIndex(Ord)(...args);
}
function foldMapWithIndex2(O) {
  return "compare" in O ? foldMapWithIndex(O) : foldMapWithIndex(Ord)(O);
}
function reduceRightWithIndex2(...args) {
  return args.length === 1 ? reduceRightWithIndex(args[0]) : reduceRightWithIndex(Ord)(...args);
}
var singleton2 = singleton;
function traverseWithIndex2(F) {
  return traverseWithIndex(F);
}
function traverse2(F) {
  return traverse(F);
}
function sequence2(F) {
  return sequence(F);
}
var wither = (F) => {
  const traverseF = traverse2(F);
  return (f) => (fa) => F.map(pipe(fa, traverseF(f)), compact2);
};
var wilt = (F) => {
  const traverseF = traverse2(F);
  return (f) => (fa) => F.map(pipe(fa, traverseF(f)), separate2);
};
var partitionMapWithIndex2 = partitionMapWithIndex;
function partitionWithIndex2(predicateWithIndex) {
  return partitionWithIndex(predicateWithIndex);
}
var filterMapWithIndex2 = filterMapWithIndex;
function filterWithIndex2(predicateWithIndex) {
  return filterWithIndex(predicateWithIndex);
}
function fromFoldable2(M, F) {
  return fromFoldable(M, F);
}
var toEntries = toArray;
var fromEntries = (fa) => fromFoldable2(last(), Foldable)(fa);
function fromFoldableMap2(M, F) {
  return fromFoldableMap(M, F);
}
var every2 = every;
var some3 = some2;
var elem2 = elem;
var union2 = (M) => {
  const unionM = union(M);
  return (second) => (first) => {
    if (isEmpty2(first)) {
      return { ...second };
    }
    if (isEmpty2(second)) {
      return { ...first };
    }
    return unionM(second)(first);
  };
};
var intersection2 = (M) => (second) => (first) => {
  if (isEmpty2(first) || isEmpty2(second)) {
    return {};
  }
  return intersection(M)(second)(first);
};
var difference2 = (second) => (first) => {
  if (isEmpty2(first)) {
    return { ...second };
  }
  if (isEmpty2(second)) {
    return { ...first };
  }
  return difference(second)(first);
};
var _map2 = _map;
var _mapWithIndex2 = _mapWithIndex;
var _reduce2 = _reduce;
var _foldMap2 = _foldMap;
var _reduceRight2 = _reduceRight;
var _filter2 = _filter;
var _filterMap2 = _filterMap;
var _partition2 = _partition;
var _partitionMap2 = _partitionMap;
var _reduceWithIndex2 = _reduceWithIndex;
var _foldMapWithIndex2 = _foldMapWithIndex;
var _reduceRightWithIndex2 = _reduceRightWithIndex;
var _partitionMapWithIndex2 = _partitionMapWithIndex;
var _partitionWithIndex2 = _partitionWithIndex;
var _filterMapWithIndex2 = _filterMapWithIndex;
var _filterWithIndex2 = _filterWithIndex;
var _traverse2 = _traverse;
var _sequence2 = _sequence;
var _traverseWithIndex = (O) => (F) => {
  const keysO = keys_(O);
  return (ta, f) => {
    const ks = keysO(ta);
    if (ks.length === 0) {
      return F.of({});
    }
    let fr = F.of({});
    for (const key of ks) {
      fr = F.ap(
        F.map(fr, (r) => (b) => {
          r[key] = b;
          return r;
        }),
        f(key, ta[key])
      );
    }
    return fr;
  };
};
var filter2 = filter;
var filterMap2 = filterMap;
var partition2 = partition;
var partitionMap2 = partitionMap;
function reduce2(...args) {
  return args.length === 1 ? reduce(args[0]) : reduce(Ord)(...args);
}
function foldMap2(O) {
  return "compare" in O ? foldMap(O) : foldMap(Ord)(O);
}
function reduceRight2(...args) {
  return args.length === 1 ? reduceRight(args[0]) : reduceRight(Ord)(...args);
}
var compact2 = compact;
var separate2 = separate;
var URI = "Record";
function getShow2(O) {
  return "compare" in O ? getShow(O) : getShow(Ord)(O);
}
var getEq2 = getEq;
var getMonoid2 = getMonoid;
var Functor = {
  URI,
  map: _map2
};
var flap2 = /* @__PURE__ */ flap(Functor);
var FunctorWithIndex = {
  URI,
  map: _map2,
  mapWithIndex: _mapWithIndex2
};
var getFoldable = (O) => ({
  URI,
  reduce: _reduce2(O),
  foldMap: _foldMap2(O),
  reduceRight: _reduceRight2(O)
});
var getFoldableWithIndex = (O) => ({
  URI,
  reduce: _reduce2(O),
  foldMap: _foldMap2(O),
  reduceRight: _reduceRight2(O),
  reduceWithIndex: _reduceWithIndex2(O),
  foldMapWithIndex: _foldMapWithIndex2(O),
  reduceRightWithIndex: _reduceRightWithIndex2(O)
});
var Compactable = {
  URI,
  compact: compact2,
  separate: separate2
};
var Filterable = {
  URI,
  map: _map2,
  compact: compact2,
  separate: separate2,
  filter: _filter2,
  filterMap: _filterMap2,
  partition: _partition2,
  partitionMap: _partitionMap2
};
var FilterableWithIndex = {
  URI,
  map: _map2,
  mapWithIndex: _mapWithIndex2,
  compact: compact2,
  separate: separate2,
  filter: _filter2,
  filterMap: _filterMap2,
  partition: _partition2,
  partitionMap: _partitionMap2,
  filterMapWithIndex: _filterMapWithIndex2,
  filterWithIndex: _filterWithIndex2,
  partitionMapWithIndex: _partitionMapWithIndex2,
  partitionWithIndex: _partitionWithIndex2
};
var getTraversable = (O) => ({
  URI,
  map: _map2,
  reduce: _reduce2(O),
  foldMap: _foldMap2(O),
  reduceRight: _reduceRight2(O),
  traverse: _traverse2(O),
  sequence: _sequence2(O)
});
var getTraversableWithIndex = (O) => ({
  URI,
  map: _map2,
  mapWithIndex: _mapWithIndex2,
  reduce: _reduce2(O),
  foldMap: _foldMap2(O),
  reduceRight: _reduceRight2(O),
  reduceWithIndex: _reduceWithIndex2(O),
  foldMapWithIndex: _foldMapWithIndex2(O),
  reduceRightWithIndex: _reduceRightWithIndex2(O),
  traverse: _traverse2(O),
  sequence: _sequence2(O),
  traverseWithIndex: _traverseWithIndex(O)
});
var getWitherable = (O) => {
  const T = getTraversable(O);
  return {
    URI,
    map: _map2,
    reduce: _reduce2(O),
    foldMap: _foldMap2(O),
    reduceRight: _reduceRight2(O),
    traverse: T.traverse,
    sequence: T.sequence,
    compact: compact2,
    separate: separate2,
    filter: _filter2,
    filterMap: _filterMap2,
    partition: _partition2,
    partitionMap: _partitionMap2,
    wither: witherDefault(T, Compactable),
    wilt: wiltDefault(T, Compactable)
  };
};
var getUnionSemigroup = (S) => {
  const unionS = union2(S);
  return {
    concat: (first, second) => unionS(second)(first)
  };
};
var getUnionMonoid = (S) => ({
  concat: getUnionSemigroup(S).concat,
  empty: {}
});
var getIntersectionSemigroup = (S) => {
  const intersectionS = intersection2(S);
  return {
    concat: (first, second) => intersectionS(second)(first)
  };
};
var getDifferenceMagma = () => ({
  concat: (first, second) => difference2(second)(first)
});
var Foldable2 = {
  URI,
  reduce: /* @__PURE__ */ _reduce2(Ord),
  foldMap: /* @__PURE__ */ _foldMap2(Ord),
  reduceRight: /* @__PURE__ */ _reduceRight2(Ord)
};
var FoldableWithIndex = {
  URI,
  reduce: /* @__PURE__ */ _reduce2(Ord),
  foldMap: /* @__PURE__ */ _foldMap2(Ord),
  reduceRight: /* @__PURE__ */ _reduceRight2(Ord),
  reduceWithIndex: /* @__PURE__ */ _reduceWithIndex2(Ord),
  foldMapWithIndex: /* @__PURE__ */ _foldMapWithIndex2(Ord),
  reduceRightWithIndex: /* @__PURE__ */ _reduceRightWithIndex2(Ord)
};
var Traversable = {
  URI,
  map: _map2,
  reduce: /* @__PURE__ */ _reduce2(Ord),
  foldMap: /* @__PURE__ */ _foldMap2(Ord),
  reduceRight: /* @__PURE__ */ _reduceRight2(Ord),
  traverse: /* @__PURE__ */ _traverse2(Ord),
  sequence: sequence2
};
var TraversableWithIndex = {
  URI,
  map: _map2,
  mapWithIndex: _mapWithIndex2,
  reduce: /* @__PURE__ */ _reduce2(Ord),
  foldMap: /* @__PURE__ */ _foldMap2(Ord),
  reduceRight: /* @__PURE__ */ _reduceRight2(Ord),
  reduceWithIndex: /* @__PURE__ */ _reduceWithIndex2(Ord),
  foldMapWithIndex: /* @__PURE__ */ _foldMapWithIndex2(Ord),
  reduceRightWithIndex: /* @__PURE__ */ _reduceRightWithIndex2(Ord),
  traverse: /* @__PURE__ */ _traverse2(Ord),
  sequence: sequence2,
  traverseWithIndex: /* @__PURE__ */ _traverseWithIndex(Ord)
};
var _wither = /* @__PURE__ */ witherDefault(Traversable, Compactable);
var _wilt = /* @__PURE__ */ wiltDefault(Traversable, Compactable);
var Witherable = {
  URI,
  map: _map2,
  reduce: /* @__PURE__ */ _reduce2(Ord),
  foldMap: /* @__PURE__ */ _foldMap2(Ord),
  reduceRight: /* @__PURE__ */ _reduceRight2(Ord),
  traverse: /* @__PURE__ */ _traverse2(Ord),
  sequence: sequence2,
  compact: compact2,
  separate: separate2,
  filter: _filter2,
  filterMap: _filterMap2,
  partition: _partition2,
  partitionMap: _partitionMap2,
  wither: _wither,
  wilt: _wilt
};
var empty = {};
var insertAt = upsertAt2;
var hasOwnProperty2 = hasOwnProperty;
var record = {
  URI,
  map: _map2,
  reduce: /* @__PURE__ */ _reduce2(Ord),
  foldMap: /* @__PURE__ */ _foldMap2(Ord),
  reduceRight: /* @__PURE__ */ _reduceRight2(Ord),
  traverse: /* @__PURE__ */ _traverse2(Ord),
  sequence: sequence2,
  compact: compact2,
  separate: separate2,
  filter: _filter2,
  filterMap: _filterMap2,
  partition: _partition2,
  partitionMap: _partitionMap2,
  mapWithIndex: _mapWithIndex2,
  reduceWithIndex: /* @__PURE__ */ _reduceWithIndex2(Ord),
  foldMapWithIndex: /* @__PURE__ */ _foldMapWithIndex2(Ord),
  reduceRightWithIndex: /* @__PURE__ */ _reduceRightWithIndex2(Ord),
  filterMapWithIndex: _filterMapWithIndex2,
  filterWithIndex: _filterWithIndex2,
  partitionMapWithIndex: _partitionMapWithIndex2,
  partitionWithIndex: _partitionWithIndex2,
  traverseWithIndex: /* @__PURE__ */ _traverseWithIndex(Ord),
  wither: _wither,
  wilt: _wilt
};

export {
  size2 as size,
  isEmpty2 as isEmpty,
  keys,
  collect,
  toArray,
  toUnfoldable,
  upsertAt2 as upsertAt,
  has3 as has,
  deleteAt,
  updateAt,
  modifyAt,
  pop,
  isSubrecord2 as isSubrecord,
  lookup2 as lookup,
  mapWithIndex2 as mapWithIndex,
  map2 as map,
  reduceWithIndex2 as reduceWithIndex,
  foldMapWithIndex2 as foldMapWithIndex,
  reduceRightWithIndex2 as reduceRightWithIndex,
  singleton2 as singleton,
  traverseWithIndex2 as traverseWithIndex,
  traverse2 as traverse,
  sequence2 as sequence,
  wither,
  wilt,
  partitionMapWithIndex2 as partitionMapWithIndex,
  partitionWithIndex2 as partitionWithIndex,
  filterMapWithIndex2 as filterMapWithIndex,
  filterWithIndex2 as filterWithIndex,
  fromFoldable2 as fromFoldable,
  toEntries,
  fromEntries,
  fromFoldableMap2 as fromFoldableMap,
  every2 as every,
  some3 as some,
  elem2 as elem,
  union2 as union,
  intersection2 as intersection,
  difference2 as difference,
  filter2 as filter,
  filterMap2 as filterMap,
  partition2 as partition,
  partitionMap2 as partitionMap,
  reduce2 as reduce,
  foldMap2 as foldMap,
  reduceRight2 as reduceRight,
  compact2 as compact,
  separate2 as separate,
  URI,
  getShow2 as getShow,
  getEq2 as getEq,
  getMonoid2 as getMonoid,
  Functor,
  flap2 as flap,
  FunctorWithIndex,
  getFoldable,
  getFoldableWithIndex,
  Compactable,
  Filterable,
  FilterableWithIndex,
  getTraversable,
  getTraversableWithIndex,
  getWitherable,
  getUnionSemigroup,
  getUnionMonoid,
  getIntersectionSemigroup,
  getDifferenceMagma,
  Foldable2 as Foldable,
  FoldableWithIndex,
  Traversable,
  TraversableWithIndex,
  Witherable,
  empty,
  insertAt,
  hasOwnProperty2 as hasOwnProperty,
  record,
  Record_exports
};
