{
  "schemaVersion": 1,
  "slug": "gift-budget-calculator",
  "category": "party",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "2682f989ef93f92025af2b4c9d70f11b48fb0477ddc22e7cbd0a29885bc2a935",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/gift-budget-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "T = n×g + n_c×g_c + E",
    "vars": [
      [
        "T",
        "Total gift budget"
      ],
      [
        "n",
        "Number of regular recipients"
      ],
      [
        "g",
        "Average gift per regular recipient"
      ],
      [
        "n_c",
        "Number of close recipients"
      ],
      [
        "g_c",
        "Gift cost per close recipient"
      ],
      [
        "E",
        "Cards, wrapping and extras"
      ]
    ],
    "note": "Average per gift (excluding extras): (n×g + n_c×g_c)/(n + n_c). Money values rounded to 2 decimals."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const main = recipients*avgGift; const close = closeRecipients*closeGift; const total = main + close + extras; const count = recipients + closeRecipients; return { giftTotal: main, closeTotal: close, extrasTotal: extras, total: total, averageAll: count > 0 ? (main + close)/count : 0, giftCount: count };",
    "inputs": [
      {
        "name": "recipients",
        "type": "number",
        "default": 10,
        "min": 0,
        "max": 500,
        "step": 1,
        "slider": true
      },
      {
        "name": "avgGift",
        "type": "number",
        "default": 30,
        "min": 0,
        "max": 10000,
        "step": 0.01
      },
      {
        "name": "closeRecipients",
        "type": "number",
        "default": 3,
        "min": 0,
        "max": 100,
        "step": 1,
        "slider": true
      },
      {
        "name": "closeGift",
        "type": "number",
        "default": 100,
        "min": 0,
        "max": 100000,
        "step": 0.01
      },
      {
        "name": "extras",
        "type": "number",
        "default": 40,
        "min": 0,
        "max": 100000,
        "step": 1
      }
    ],
    "outputs": [
      {
        "name": "total",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "giftTotal",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "closeTotal",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "extrasTotal",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "averageAll",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "giftCount",
        "precision": 0,
        "unit": ""
      }
    ],
    "interpret": null
  }
}
