{
  "format": "pricekit-template",
  "schemaVersion": "1.0",
  "engineVersion": "1",
  "createdWithVersion": "1.0.0",
  "template": {
    "templateId": "a99715e7-aebc-4d2e-a1b3-a4484a548276",
    "templateVersion": "1.0"
  },
  "calculator": {
    "name": "ألمنيوم ومطابخ",
    "description": "مطابخ وشبابيك وأبواب وواجهات: السعر حسب المقاسات والخامات، والتركيب مشمول.",
    "currency": "USD",
    "calculatorVersion": 1,
    "moneyDecimals": 2,
    "allowNegativeTotal": false,
    "fields": [
      {
        "key": "work",
        "label": "نوع العمل",
        "type": "singleChoice",
        "required": true,
        "options": [
          {
            "key": "option_1",
            "label": "مطبخ"
          },
          {
            "key": "option_2",
            "label": "شبابيك ألمنيوم"
          },
          {
            "key": "option_3",
            "label": "أبواب ألمنيوم"
          },
          {
            "key": "option_4",
            "label": "واجهات زجاجية"
          }
        ],
        "visibleByDefault": true,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "kitchen_length",
        "label": "طول المطبخ",
        "type": "number",
        "required": true,
        "defaultValue": {
          "type": "number",
          "value": 4
        },
        "constraints": {
          "min": 1,
          "max": 30
        },
        "unit": "متر طولي",
        "visibleByDefault": false,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "kitchen_material",
        "label": "خامة المطبخ",
        "description": "السعر لكل متر طولي.",
        "type": "singleChoice",
        "required": true,
        "options": [
          {
            "key": "mdf",
            "label": "خشب MDF"
          },
          {
            "key": "option_2",
            "label": "خشب طبيعي"
          },
          {
            "key": "option_3",
            "label": "ألمنيوم"
          }
        ],
        "visibleByDefault": false,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "upper_cabinets",
        "label": "خزائن علوية",
        "type": "boolean",
        "required": false,
        "defaultValue": {
          "type": "boolean",
          "value": false
        },
        "visibleByDefault": false,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "countertop",
        "label": "سطح المطبخ",
        "type": "singleChoice",
        "required": true,
        "options": [
          {
            "key": "option_1",
            "label": "رخام صناعي"
          },
          {
            "key": "option_2",
            "label": "جرانيت"
          },
          {
            "key": "option_3",
            "label": "كوارتز"
          }
        ],
        "visibleByDefault": false,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "width",
        "label": "عرض القطعة",
        "type": "number",
        "required": true,
        "defaultValue": {
          "type": "number",
          "value": 1.5
        },
        "constraints": {
          "min": 0.3,
          "max": 10
        },
        "unit": "م",
        "visibleByDefault": false,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "height",
        "label": "ارتفاع القطعة",
        "type": "number",
        "required": true,
        "defaultValue": {
          "type": "number",
          "value": 1.2
        },
        "constraints": {
          "min": 0.3,
          "max": 6
        },
        "unit": "م",
        "visibleByDefault": false,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "pieces",
        "label": "عدد القطع",
        "type": "number",
        "required": true,
        "defaultValue": {
          "type": "number",
          "value": 1
        },
        "constraints": {
          "min": 1,
          "max": 100
        },
        "unit": "قطعة",
        "visibleByDefault": false,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "profile",
        "label": "نوع القطاع",
        "description": "السعر لكل متر مربع.",
        "type": "singleChoice",
        "required": true,
        "options": [
          {
            "key": "option_1",
            "label": "قطاع عادي"
          },
          {
            "key": "option_2",
            "label": "قطاع حراري عازل"
          },
          {
            "key": "option_3",
            "label": "قطاع سحّاب فاخر"
          }
        ],
        "visibleByDefault": false,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "glass",
        "label": "نوع الزجاج",
        "type": "singleChoice",
        "required": true,
        "options": [
          {
            "key": "option_1",
            "label": "زجاج مفرد"
          },
          {
            "key": "option_2",
            "label": "زجاج مزدوج عازل"
          }
        ],
        "visibleByDefault": false,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "mesh",
        "label": "شبك حماية من الحشرات",
        "type": "boolean",
        "required": false,
        "defaultValue": {
          "type": "boolean",
          "value": false
        },
        "visibleByDefault": false,
        "enabledByDefault": true,
        "customerVisible": true
      }
    ],
    "rules": [
      {
        "key": "when_kitchen_material_mdf",
        "name": "خامة المطبخ: خشب MDF",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "kitchen_material"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "mdf"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "kitchen_material_mdf"
          }
        ]
      },
      {
        "key": "when_kitchen_material_option_2",
        "name": "خامة المطبخ: خشب طبيعي",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "kitchen_material"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_2"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "kitchen_material_option_2"
          }
        ]
      },
      {
        "key": "when_kitchen_material_option_3",
        "name": "خامة المطبخ: ألمنيوم",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "kitchen_material"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_3"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "kitchen_material_option_3"
          }
        ]
      },
      {
        "key": "when_upper_cabinets",
        "name": "خزائن علوية",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "upper_cabinets"
              },
              "operator": "equals",
              "operand": {
                "type": "boolean",
                "value": true
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "upper_cabinets_price"
          }
        ]
      },
      {
        "key": "when_countertop_option_1",
        "name": "سطح المطبخ: رخام صناعي",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "countertop"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_1"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "countertop_option_1"
          }
        ]
      },
      {
        "key": "when_countertop_option_2",
        "name": "سطح المطبخ: جرانيت",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "countertop"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_2"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "countertop_option_2"
          }
        ]
      },
      {
        "key": "when_countertop_option_3",
        "name": "سطح المطبخ: كوارتز",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "countertop"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_3"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "countertop_option_3"
          }
        ]
      },
      {
        "key": "when_profile_option_1",
        "name": "نوع القطاع: قطاع عادي",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "profile"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_1"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "profile_option_1"
          }
        ]
      },
      {
        "key": "when_profile_option_2",
        "name": "نوع القطاع: قطاع حراري عازل",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "profile"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_2"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "profile_option_2"
          }
        ]
      },
      {
        "key": "when_profile_option_3",
        "name": "نوع القطاع: قطاع سحّاب فاخر",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "profile"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_3"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "profile_option_3"
          }
        ]
      },
      {
        "key": "when_glass_option_2",
        "name": "نوع الزجاج: زجاج مزدوج عازل",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "glass"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_2"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "glass_option_2"
          }
        ]
      },
      {
        "key": "when_mesh",
        "name": "شبك حماية من الحشرات",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "mesh"
              },
              "operator": "equals",
              "operand": {
                "type": "boolean",
                "value": true
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "mesh_price"
          }
        ]
      },
      {
        "key": "rule_12",
        "name": "kitchen_length, kitchen_material, upper_cabinets, countertop",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "work"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_1"
              }
            }
          ]
        },
        "then": [
          {
            "action": "showField",
            "target": "kitchen_length"
          },
          {
            "action": "showField",
            "target": "kitchen_material"
          },
          {
            "action": "showField",
            "target": "upper_cabinets"
          },
          {
            "action": "showField",
            "target": "countertop"
          }
        ]
      },
      {
        "key": "rule_13",
        "name": "width, height, pieces, profile, glass, mesh",
        "enabled": true,
        "when": {
          "mode": "any",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "work"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_2"
              }
            },
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "work"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_3"
              }
            },
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "work"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_4"
              }
            }
          ]
        },
        "then": [
          {
            "action": "showField",
            "target": "width"
          },
          {
            "action": "showField",
            "target": "height"
          },
          {
            "action": "showField",
            "target": "pieces"
          },
          {
            "action": "showField",
            "target": "profile"
          },
          {
            "action": "showField",
            "target": "glass"
          },
          {
            "action": "showField",
            "target": "mesh"
          }
        ]
      }
    ],
    "components": [
      {
        "key": "work_price",
        "label": "نوع العمل",
        "stage": "base",
        "pricing": {
          "type": "singleChoice",
          "field": "work",
          "options": [
            {
              "option": "option_1",
              "amount": 0
            },
            {
              "option": "option_2",
              "amount": 0
            },
            {
              "option": "option_3",
              "amount": 0
            },
            {
              "option": "option_4",
              "amount": 0
            }
          ]
        },
        "activeByDefault": true,
        "customerVisible": true
      },
      {
        "key": "kitchen_material_mdf",
        "label": "خامة المطبخ: خشب MDF",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "field",
            "key": "kitchen_length"
          },
          "rate": 330
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "kitchen_material_option_2",
        "label": "خامة المطبخ: خشب طبيعي",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "field",
            "key": "kitchen_length"
          },
          "rate": 600
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "kitchen_material_option_3",
        "label": "خامة المطبخ: ألمنيوم",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "field",
            "key": "kitchen_length"
          },
          "rate": 420
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "upper_cabinets_price",
        "label": "خزائن علوية",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "field",
            "key": "kitchen_length"
          },
          "rate": 200
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "countertop_option_1",
        "label": "سطح المطبخ: رخام صناعي",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "field",
            "key": "kitchen_length"
          },
          "rate": 110
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "countertop_option_2",
        "label": "سطح المطبخ: جرانيت",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "field",
            "key": "kitchen_length"
          },
          "rate": 150
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "countertop_option_3",
        "label": "سطح المطبخ: كوارتز",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "field",
            "key": "kitchen_length"
          },
          "rate": 220
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "profile_option_1",
        "label": "نوع القطاع: قطاع عادي",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "derived",
            "key": "calc_total_area"
          },
          "rate": 100
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "profile_option_2",
        "label": "نوع القطاع: قطاع حراري عازل",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "derived",
            "key": "calc_total_area"
          },
          "rate": 150
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "profile_option_3",
        "label": "نوع القطاع: قطاع سحّاب فاخر",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "derived",
            "key": "calc_total_area"
          },
          "rate": 190
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "glass_option_2",
        "label": "نوع الزجاج: زجاج مزدوج عازل",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "derived",
            "key": "calc_total_area"
          },
          "rate": 35
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "mesh_price",
        "label": "شبك حماية من الحشرات",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "derived",
            "key": "calc_total_area"
          },
          "rate": 15
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "minimum_order",
        "label": "الحد الأدنى للعمل",
        "stage": "adjustment",
        "pricing": {
          "type": "minimumCharge",
          "minimum": 280,
          "basis": "beforeTax"
        },
        "activeByDefault": true,
        "customerVisible": true
      }
    ],
    "derivedValues": [
      {
        "key": "calc_total_area",
        "label": "إجمالي المساحة بالمتر المربع",
        "type": "number",
        "phase": "prePricing",
        "expression": {
          "type": "function",
          "name": "round",
          "arguments": [
            {
              "type": "arithmetic",
              "operator": "multiply",
              "left": {
                "type": "arithmetic",
                "operator": "multiply",
                "left": {
                  "type": "ref",
                  "ref": {
                    "kind": "field",
                    "key": "width"
                  }
                },
                "right": {
                  "type": "ref",
                  "ref": {
                    "kind": "field",
                    "key": "height"
                  }
                }
              },
              "right": {
                "type": "ref",
                "ref": {
                  "kind": "field",
                  "key": "pieces"
                }
              }
            },
            {
              "type": "literal",
              "value": {
                "type": "number",
                "value": 2
              }
            }
          ]
        }
      }
    ],
    "outputs": [
      {
        "key": "out_calc_total_area",
        "label": "إجمالي المساحة بالمتر المربع",
        "source": {
          "kind": "derived",
          "key": "calc_total_area"
        },
        "operatorVisible": true,
        "customerVisible": true
      }
    ]
  }
}