{
  "version": 3,
  "sources": ["../../../../../src/functions/math/sum/sumifs.ts"],
  "sourcesContent": [
    "import {\n  type FunctionDefinition,\n  type FunctionEvaluationResult\n} from \"../../../core/types.mjs\";\nimport {\n  parseCriteriaPairs,\n  processMultiCriteriaValues,\n  validateMultiCriteriaArgs,\n} from \"../../criteria-utils.mjs\";\nimport { performSummation } from \"./summation-utils.mjs\";\n\n/**\n * SUMIFS function - Sums cells in a range that meet multiple criteria\n *\n * Usage: SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...)\n *\n * sum_range: The range of cells to sum\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 *   SUMIFS(B1:B10, A1:A10, \"Apple\") - sums B1:B10 where A1:A10 = \"Apple\"\n *   SUMIFS(C1:C10, A1:A10, \"Apple\", B1:B10, \">10\") - sums C1:C10 where A1:A10 = \"Apple\" AND B1:B10 > 10\n *\n * Note:\n * - All criteria must be satisfied for a value to be included\n * - Only numeric values are included in the sum\n * - Returns 0 if no values match all criteria (unlike other IFS functions that return error)\n */\nexport const SUMIFS: FunctionDefinition = {\n  name: \"SUMIFS\",\n  evaluate: function (node, context): FunctionEvaluationResult {\n    // Validate arguments\n    const argError = validateMultiCriteriaArgs(\"SUMIFS\", node.args.length, context);\n    if (argError) {\n      return argError;\n    }\n\n    // Evaluate sum range (first argument)\n    const sumRangeResult = this.evaluateNode(node.args[0]!, context);\n    if (sumRangeResult.type === \"error\") {\n      return sumRangeResult;\n    }\n\n    // Parse criteria pairs starting from argument 1\n    const criteriaPairsResult = parseCriteriaPairs.call(\n      this,\n      node,\n      context,\n      this.evaluateNode,\n      1\n    );\n    if (\"type\" in criteriaPairsResult) {\n      return criteriaPairsResult;\n    }\n\n    // Use shared summation utility for standard cases\n    const matchingValues = processMultiCriteriaValues(\n      this,\n      sumRangeResult,\n      criteriaPairsResult,\n      context,\n      \"col-major\"\n    );\n\n    if (matchingValues.type === \"error\" || matchingValues.type === \"awaiting-evaluation\") {\n      return matchingValues;\n    }\n\n    return performSummation(matchingValues.values);\n  },\n};\n"
  ],
  "mappings": ";AAIA;AAAA;AAAA;AAAA;AAAA;AAKA;AAqBO,IAAM,SAA6B;AAAA,EACxC,MAAM;AAAA,EACN,UAAU,QAAS,CAAC,MAAM,SAAmC;AAAA,IAE3D,MAAM,WAAW,0BAA0B,UAAU,KAAK,KAAK,QAAQ,OAAO;AAAA,IAC9E,IAAI,UAAU;AAAA,MACZ,OAAO;AAAA,IACT;AAAA,IAGA,MAAM,iBAAiB,KAAK,aAAa,KAAK,KAAK,IAAK,OAAO;AAAA,IAC/D,IAAI,eAAe,SAAS,SAAS;AAAA,MACnC,OAAO;AAAA,IACT;AAAA,IAGA,MAAM,sBAAsB,mBAAmB,KAC7C,MACA,MACA,SACA,KAAK,cACL,CACF;AAAA,IACA,IAAI,UAAU,qBAAqB;AAAA,MACjC,OAAO;AAAA,IACT;AAAA,IAGA,MAAM,iBAAiB,2BACrB,MACA,gBACA,qBACA,SACA,WACF;AAAA,IAEA,IAAI,eAAe,SAAS,WAAW,eAAe,SAAS,uBAAuB;AAAA,MACpF,OAAO;AAAA,IACT;AAAA,IAEA,OAAO,iBAAiB,eAAe,MAAM;AAAA;AAEjD;",
  "debugId": "E9A98FD8BC29414D64756E2164756E21",
  "names": []
}