{
  "format": "pricekit-template",
  "schemaVersion": "1.0",
  "engineVersion": "1",
  "createdWithVersion": "1.0.0",
  "template": {
    "templateId": "8e535e79-4afe-44b7-acbe-afd17d4aa4dd",
    "templateVersion": "1.0"
  },
  "calculator": {
    "name": "فيديو إعلاني",
    "description": "سعر الفيديو حسب نوعه ومدته، مع التصوير والتعليق الصوتي والتعديلات.",
    "currency": "USD",
    "calculatorVersion": 1,
    "moneyDecimals": 2,
    "allowNegativeTotal": false,
    "fields": [
      {
        "key": "video_type",
        "label": "نوع الفيديو",
        "description": "السعر لكل ثانية من مدة الفيديو.",
        "type": "singleChoice",
        "required": true,
        "options": [
          {
            "key": "option_1",
            "label": "موشن جرافيك ثنائي الأبعاد"
          },
          {
            "key": "option_2",
            "label": "تصوير واقعي مع مونتاج"
          },
          {
            "key": "option_3",
            "label": "رسوم ثلاثية الأبعاد"
          }
        ],
        "visibleByDefault": true,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "duration",
        "label": "مدة الفيديو",
        "type": "number",
        "required": true,
        "defaultValue": {
          "type": "number",
          "value": 30
        },
        "constraints": {
          "min": 10,
          "max": 180
        },
        "unit": "ثانية",
        "visibleByDefault": true,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "shooting_days",
        "label": "أيام التصوير",
        "type": "number",
        "required": true,
        "defaultValue": {
          "type": "number",
          "value": 1
        },
        "constraints": {
          "min": 1,
          "max": 10
        },
        "unit": "يوم",
        "visibleByDefault": false,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "actors",
        "label": "عدد الممثلين أو الموديلز",
        "type": "number",
        "required": true,
        "defaultValue": {
          "type": "number",
          "value": 0
        },
        "constraints": {
          "min": 0,
          "max": 10
        },
        "unit": "شخص",
        "visibleByDefault": false,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "script",
        "label": "كتابة السيناريو",
        "type": "boolean",
        "required": false,
        "defaultValue": {
          "type": "boolean",
          "value": false
        },
        "visibleByDefault": true,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "voice_over",
        "label": "التعليق الصوتي",
        "type": "singleChoice",
        "required": true,
        "options": [
          {
            "key": "option_1",
            "label": "بدون تعليق صوتي"
          },
          {
            "key": "option_2",
            "label": "صوت عربي"
          },
          {
            "key": "option_3",
            "label": "صوت عربي وإنجليزي"
          }
        ],
        "visibleByDefault": true,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "formats",
        "label": "المقاسات الإضافية",
        "type": "multipleChoice",
        "required": false,
        "options": [
          {
            "key": "option_1",
            "label": "عمودي 9:16 للستوري والريلز"
          },
          {
            "key": "option_2",
            "label": "مربع 1:1"
          }
        ],
        "visibleByDefault": true,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "revisions",
        "label": "جولات التعديل",
        "description": "جولتا تعديل مشمولتان في السعر.",
        "type": "number",
        "required": true,
        "defaultValue": {
          "type": "number",
          "value": 2
        },
        "constraints": {
          "min": 0,
          "max": 10
        },
        "unit": "جولة",
        "visibleByDefault": true,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "urgent",
        "label": "تسليم مستعجل",
        "type": "boolean",
        "required": false,
        "defaultValue": {
          "type": "boolean",
          "value": false
        },
        "visibleByDefault": true,
        "enabledByDefault": true,
        "customerVisible": true
      }
    ],
    "rules": [
      {
        "key": "when_video_type_option_1",
        "name": "نوع الفيديو: موشن جرافيك ثنائي الأبعاد",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "video_type"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_1"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "video_type_option_1"
          }
        ]
      },
      {
        "key": "when_video_type_option_2",
        "name": "نوع الفيديو: تصوير واقعي مع مونتاج",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "video_type"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_2"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "video_type_option_2"
          }
        ]
      },
      {
        "key": "when_video_type_option_3",
        "name": "نوع الفيديو: رسوم ثلاثية الأبعاد",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "video_type"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_3"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "video_type_option_3"
          }
        ]
      },
      {
        "key": "show_shooting_days",
        "name": "أيام التصوير",
        "enabled": true,
        "when": {
          "mode": "any",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "video_type"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_2"
              }
            }
          ]
        },
        "then": [
          {
            "action": "showField",
            "target": "shooting_days"
          }
        ]
      },
      {
        "key": "show_actors",
        "name": "عدد الممثلين أو الموديلز",
        "enabled": true,
        "when": {
          "mode": "any",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "video_type"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_2"
              }
            }
          ]
        },
        "then": [
          {
            "action": "showField",
            "target": "actors"
          }
        ]
      },
      {
        "key": "when_script",
        "name": "كتابة السيناريو",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "script"
              },
              "operator": "equals",
              "operand": {
                "type": "boolean",
                "value": true
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "script_price"
          }
        ]
      },
      {
        "key": "when_urgent",
        "name": "تسليم مستعجل",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "urgent"
              },
              "operator": "equals",
              "operand": {
                "type": "boolean",
                "value": true
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "urgent_percent"
          }
        ]
      },
      {
        "key": "rule_7",
        "name": "urgent",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "duration"
              },
              "operator": "greaterThan",
              "operand": {
                "type": "number",
                "value": 90
              }
            }
          ]
        },
        "then": [
          {
            "action": "hideField",
            "target": "urgent"
          }
        ]
      }
    ],
    "components": [
      {
        "key": "video_type_option_1",
        "label": "نوع الفيديو: موشن جرافيك ثنائي الأبعاد",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "field",
            "key": "duration"
          },
          "rate": 7
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "video_type_option_2",
        "label": "نوع الفيديو: تصوير واقعي مع مونتاج",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "field",
            "key": "duration"
          },
          "rate": 10
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "video_type_option_3",
        "label": "نوع الفيديو: رسوم ثلاثية الأبعاد",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "field",
            "key": "duration"
          },
          "rate": 18
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "shooting_days_price",
        "label": "أيام التصوير",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "field",
            "key": "shooting_days"
          },
          "rate": 350
        },
        "activeByDefault": true,
        "customerVisible": true
      },
      {
        "key": "actors_price",
        "label": "عدد الممثلين أو الموديلز",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "field",
            "key": "actors"
          },
          "rate": 120
        },
        "activeByDefault": true,
        "customerVisible": true
      },
      {
        "key": "script_price",
        "label": "كتابة السيناريو",
        "stage": "base",
        "pricing": {
          "type": "fixedAmount",
          "amount": 80
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "voice_over_price",
        "label": "التعليق الصوتي",
        "stage": "base",
        "pricing": {
          "type": "singleChoice",
          "field": "voice_over",
          "options": [
            {
              "option": "option_1",
              "amount": 0
            },
            {
              "option": "option_2",
              "amount": 70
            },
            {
              "option": "option_3",
              "amount": 120
            }
          ]
        },
        "activeByDefault": true,
        "customerVisible": true
      },
      {
        "key": "formats_price",
        "label": "المقاسات الإضافية",
        "stage": "base",
        "pricing": {
          "type": "multipleChoice",
          "field": "formats",
          "options": [
            {
              "option": "option_1",
              "amount": 40
            },
            {
              "option": "option_2",
              "amount": 40
            }
          ]
        },
        "activeByDefault": true,
        "customerVisible": true
      },
      {
        "key": "urgent_percent",
        "label": "تسليم مستعجل",
        "stage": "adjustment",
        "pricing": {
          "type": "percentage",
          "direction": "surcharge",
          "percent": {
            "type": "fixed",
            "percent": 30
          },
          "base": {
            "type": "subtotal",
            "subtotal": "baseSubtotal"
          }
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "extra_price",
        "label": "جولات تعديل إضافية",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "derived",
            "key": "calc_paid_revisions"
          },
          "rate": 50
        },
        "activeByDefault": true,
        "customerVisible": true
      },
      {
        "key": "minimum_order",
        "label": "الحد الأدنى لإنتاج فيديو",
        "stage": "adjustment",
        "pricing": {
          "type": "minimumCharge",
          "minimum": 300,
          "basis": "beforeTax"
        },
        "activeByDefault": true,
        "customerVisible": true
      }
    ],
    "derivedValues": [
      {
        "key": "calc_paid_revisions",
        "label": "جولات التعديل الإضافية",
        "type": "number",
        "phase": "prePricing",
        "expression": {
          "type": "function",
          "name": "max",
          "arguments": [
            {
              "type": "arithmetic",
              "operator": "subtract",
              "left": {
                "type": "ref",
                "ref": {
                  "kind": "field",
                  "key": "revisions"
                }
              },
              "right": {
                "type": "literal",
                "value": {
                  "type": "number",
                  "value": 2
                }
              }
            },
            {
              "type": "literal",
              "value": {
                "type": "number",
                "value": 0
              }
            }
          ]
        }
      },
      {
        "key": "calc_delivery_days",
        "label": "مدة التنفيذ التقريبية بالأيام",
        "type": "number",
        "phase": "prePricing",
        "expression": {
          "type": "arithmetic",
          "operator": "add",
          "left": {
            "type": "function",
            "name": "ceiling",
            "arguments": [
              {
                "type": "arithmetic",
                "operator": "divide",
                "left": {
                  "type": "ref",
                  "ref": {
                    "kind": "field",
                    "key": "duration"
                  }
                },
                "right": {
                  "type": "literal",
                  "value": {
                    "type": "number",
                    "value": 15
                  }
                }
              }
            ]
          },
          "right": {
            "type": "literal",
            "value": {
              "type": "number",
              "value": 5
            }
          }
        }
      }
    ],
    "outputs": [
      {
        "key": "out_calc_delivery_days",
        "label": "مدة التنفيذ التقريبية بالأيام",
        "source": {
          "kind": "derived",
          "key": "calc_delivery_days"
        },
        "operatorVisible": true,
        "customerVisible": true
      }
    ]
  }
}