(function (global, factory) {
  if (typeof define === "function" && define.amd) {
    define(["exports", "rxjs/operators"], factory);
  } else if (typeof exports !== "undefined") {
    factory(exports, require("rxjs/operators"));
  } else {
    var mod = {
      exports: {}
    };
    factory(mod.exports, global.operators);
    global.recall = mod.exports;
  }
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _operators) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;

  function computeRecall(truePositives, falseNegatives) {
    if (truePositives + falseNegatives === 0) return 0;
    return truePositives / (truePositives + falseNegatives);
  }

  function reducer({
    truePositives,
    falseNegatives
  }, [trueValue, predictedValue]) {
    const newTruePositives = predictedValue === 1 && predictedValue === trueValue ? truePositives + 1 : truePositives;
    const newFalseNegatives = predictedValue === 0 && predictedValue !== trueValue ? falseNegatives + 1 : falseNegatives;
    return {
      truePositives: newTruePositives,
      falseNegatives: newFalseNegatives
    };
  }

  const recall = function recall(initialState = {
    truePositives: 0,
    falseNegatives: 0
  }) {
    return source$ => source$.pipe((0, _operators.scan)(reducer, initialState), (0, _operators.map)(({
      truePositives,
      falseNegatives
    }) => computeRecall(truePositives, falseNegatives)));
  };

  var _default = recall;
  _exports.default = _default;
});
//# sourceMappingURL=recall.js.map