{
  "version": 3,
  "sources": ["../../../../../src/functions/lookup/count/countifs.ts"],
  "sourcesContent": [
    "import {\n  FormulaError,\n  type FunctionDefinition,\n  type FunctionEvaluationResult,\n} from \"../../../core/types.mjs\";\nimport type { EvaluationContext } from \"../../../evaluator/evaluation-context.mjs\";\nimport { \n  parseCriteriaPairs, \n  processMultiCriteriaValues, \n  validateCountifsArgs \n} from \"../../criteria-utils.mjs\";\n\n/**\n * COUNTIFS function - Counts cells that meet multiple criteria\n * \n * Usage: COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...)\n * \n * criteria_range1: The first range to evaluate against criteria1\n * criteria1: The first criteria to match against\n * criteria_range2, criteria2: Optional additional criteria pairs\n * \n * Examples:\n *   COUNTIFS(A1:A10, \"Apple\") - counts cells in A1:A10 that equal \"Apple\"\n *   COUNTIFS(A1:A10, \"Apple\", B1:B10, \">10\") - counts where A1:A10 = \"Apple\" AND B1:B10 > 10\n * \n * Note:\n * - All criteria must be satisfied for a cell to be counted\n * - Counts all matching cells, not just numeric ones\n * - Returns 0 if no cells match all criteria\n * - Unlike other IFS functions, COUNTIFS counts the first criteria range itself\n */\nexport const COUNTIFS: FunctionDefinition = {\n  name: \"COUNTIFS\",\n  evaluate: function (node, context): FunctionEvaluationResult {\n    // Validate arguments\n    const argError = validateCountifsArgs(node.args.length, context);\n    if (argError) {\n      return argError;\n    }\n\n    // Parse criteria pairs starting from argument 0 (COUNTIFS has different syntax)\n    const criteriaPairsResult = parseCriteriaPairs.call(this, node, context, this.evaluateNode, 0);\n    if ('type' in criteriaPairsResult) {\n      return criteriaPairsResult;\n    }\n\n    // The first criteria range is what we count\n    const countRangeResult = criteriaPairsResult[0]!.rangeResult;\n\n    // Process values with criteria using generator - count all matching cells (including non-numeric)\n    let count = 0;\n\n    const matchingValues = processMultiCriteriaValues(\n      this,\n      countRangeResult,\n      criteriaPairsResult,\n      context,\n      \"col-major\"\n    );\n    \n    if (matchingValues.type === \"error\" || matchingValues.type === \"awaiting-evaluation\") {\n      return matchingValues;\n    }\n\n    for (const result of matchingValues.values) {\n      // COUNTIFS counts all matching cells, including errors and non-numeric values\n      count++;\n    }\n\n    return {\n      type: \"value\",\n      result: { type: \"number\", value: count },\n    };\n  },\n};\n"
  ],
  "mappings": ";AAMA;AAAA;AAAA;AAAA;AAAA;AAyBO,IAAM,WAA+B;AAAA,EAC1C,MAAM;AAAA,EACN,UAAU,QAAS,CAAC,MAAM,SAAmC;AAAA,IAE3D,MAAM,WAAW,qBAAqB,KAAK,KAAK,QAAQ,OAAO;AAAA,IAC/D,IAAI,UAAU;AAAA,MACZ,OAAO;AAAA,IACT;AAAA,IAGA,MAAM,sBAAsB,mBAAmB,KAAK,MAAM,MAAM,SAAS,KAAK,cAAc,CAAC;AAAA,IAC7F,IAAI,UAAU,qBAAqB;AAAA,MACjC,OAAO;AAAA,IACT;AAAA,IAGA,MAAM,mBAAmB,oBAAoB,GAAI;AAAA,IAGjD,IAAI,QAAQ;AAAA,IAEZ,MAAM,iBAAiB,2BACrB,MACA,kBACA,qBACA,SACA,WACF;AAAA,IAEA,IAAI,eAAe,SAAS,WAAW,eAAe,SAAS,uBAAuB;AAAA,MACpF,OAAO;AAAA,IACT;AAAA,IAEA,WAAW,UAAU,eAAe,QAAQ;AAAA,MAE1C;AAAA,IACF;AAAA,IAEA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ,EAAE,MAAM,UAAU,OAAO,MAAM;AAAA,IACzC;AAAA;AAEJ;",
  "debugId": "F0EF47E92080589364756E2164756E21",
  "names": []
}