export default async function addTotaller(db, data) {
  var _a, _b, _c;
  const sums = {};
  for (const sumName of typeof (data === null || data === void 0 ? void 0 : data.sums) === "object"
    ? Object.keys(data.sums)
    : []) {
    sums[sumName] = {
      ...(((_a = data === null || data === void 0 ? void 0 : data.sums) === null || _a === void 0 ? void 0 : _a[sumName]) || {}),
      logic: JSON.stringify((_c = (_b = data === null || data === void 0 ? void 0 : data.sums) === null || _b === void 0 ? void 0 : _b[sumName]) === null || _c === void 0 ? void 0 : _c.logic),
    };
  }
  const newTotaller = {
    ...data,
    sums,
    createdAt: new Date(),
  };
  return db.add("totallers", newTotaller);
}
//# sourceMappingURL=addTotaller.js.map