{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.calculatorx.com/schemas/math.ratio.input.json",
  "title": "Ratio — input",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "mode": {
      "type": "string",
      "enum": [
        "simplify",
        "proportion",
        "scale",
        "split",
        "compare",
        "convert",
        "simp",
        "reduce",
        "prop",
        "solve",
        "multiply",
        "divide",
        "share",
        "allocate",
        "eq",
        "equivalent",
        "fraction",
        "percent",
        "pct"
      ]
    },
    "a": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "aInput": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "A": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "b": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "bInput": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "B": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "c": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "cInput": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "C": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "d": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "dInput": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "D": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "k": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "kInput": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "factor": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "total": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "totalInput": {
      "oneOf": [
        {
          "type": "number",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "string",
          "maxLength": 128,
          "pattern": "^\\s*(?:[+-]?(?:[0-9]{1,48}|[0-9]{0,47}\\.[0-9]{1,48}|[0-9]{1,48}/[0-9]{1,48}))?\\s*$"
        }
      ],
      "description": "Exact strings:48 decimal digits per integer/decimal or numerator/denominator; total token≤128 characters. Decimal total digits and rational/alias constraints are validated by engine. JSON numbers use shortest normalized decimal; preserve exact source as string."
    },
    "terms": {
      "enum": [
        2,
        3,
        "2",
        "3"
      ]
    },
    "termCount": {
      "enum": [
        2,
        3,
        "2",
        "3"
      ]
    },
    "scaleOp": {
      "enum": [
        "multiply",
        "divide"
      ]
    },
    "scale_op": {
      "enum": [
        "multiply",
        "divide"
      ]
    },
    "op": {
      "enum": [
        "multiply",
        "divide"
      ]
    }
  },
  "description": "Six exact-rational modes. a/b required except exactly one missing/blank in proportion. Aliases must agree, active-mode fields only. Proportion requires nonzero B,D and a unique solution; nonnegative split total and terms. See engine secondary constraints. (calculation_version 1.0.3)",
  "allOf": [
    {
      "if": {
        "required": [
          "mode"
        ],
        "properties": {
          "mode": {
            "enum": [
              "proportion",
              "prop",
              "solve"
            ]
          }
        }
      },
      "then": {
        "anyOf": [
          {
            "allOf": [
              {
                "anyOf": [
                  {
                    "required": [
                      "a"
                    ],
                    "properties": {
                      "a": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "aInput"
                    ],
                    "properties": {
                      "aInput": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "A"
                    ],
                    "properties": {
                      "A": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  }
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "b"
                    ],
                    "properties": {
                      "b": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "bInput"
                    ],
                    "properties": {
                      "bInput": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "B"
                    ],
                    "properties": {
                      "B": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  }
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "c"
                    ],
                    "properties": {
                      "c": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "cInput"
                    ],
                    "properties": {
                      "cInput": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "C"
                    ],
                    "properties": {
                      "C": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  }
                ]
              }
            ]
          },
          {
            "allOf": [
              {
                "anyOf": [
                  {
                    "required": [
                      "a"
                    ],
                    "properties": {
                      "a": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "aInput"
                    ],
                    "properties": {
                      "aInput": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "A"
                    ],
                    "properties": {
                      "A": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  }
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "b"
                    ],
                    "properties": {
                      "b": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "bInput"
                    ],
                    "properties": {
                      "bInput": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "B"
                    ],
                    "properties": {
                      "B": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  }
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "d"
                    ],
                    "properties": {
                      "d": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "dInput"
                    ],
                    "properties": {
                      "dInput": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "D"
                    ],
                    "properties": {
                      "D": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  }
                ]
              }
            ]
          },
          {
            "allOf": [
              {
                "anyOf": [
                  {
                    "required": [
                      "a"
                    ],
                    "properties": {
                      "a": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "aInput"
                    ],
                    "properties": {
                      "aInput": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "A"
                    ],
                    "properties": {
                      "A": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  }
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "c"
                    ],
                    "properties": {
                      "c": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "cInput"
                    ],
                    "properties": {
                      "cInput": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "C"
                    ],
                    "properties": {
                      "C": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  }
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "d"
                    ],
                    "properties": {
                      "d": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "dInput"
                    ],
                    "properties": {
                      "dInput": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "D"
                    ],
                    "properties": {
                      "D": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  }
                ]
              }
            ]
          },
          {
            "allOf": [
              {
                "anyOf": [
                  {
                    "required": [
                      "b"
                    ],
                    "properties": {
                      "b": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "bInput"
                    ],
                    "properties": {
                      "bInput": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "B"
                    ],
                    "properties": {
                      "B": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  }
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "c"
                    ],
                    "properties": {
                      "c": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "cInput"
                    ],
                    "properties": {
                      "cInput": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "C"
                    ],
                    "properties": {
                      "C": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  }
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "d"
                    ],
                    "properties": {
                      "d": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "dInput"
                    ],
                    "properties": {
                      "dInput": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "D"
                    ],
                    "properties": {
                      "D": {
                        "not": {
                          "const": ""
                        }
                      }
                    }
                  }
                ]
              }
            ]
          }
        ]
      },
      "else": {
        "allOf": [
          {
            "anyOf": [
              {
                "required": [
                  "a"
                ],
                "properties": {
                  "a": {
                    "not": {
                      "const": ""
                    }
                  }
                }
              },
              {
                "required": [
                  "aInput"
                ],
                "properties": {
                  "aInput": {
                    "not": {
                      "const": ""
                    }
                  }
                }
              },
              {
                "required": [
                  "A"
                ],
                "properties": {
                  "A": {
                    "not": {
                      "const": ""
                    }
                  }
                }
              }
            ]
          },
          {
            "anyOf": [
              {
                "required": [
                  "b"
                ],
                "properties": {
                  "b": {
                    "not": {
                      "const": ""
                    }
                  }
                }
              },
              {
                "required": [
                  "bInput"
                ],
                "properties": {
                  "bInput": {
                    "not": {
                      "const": ""
                    }
                  }
                }
              },
              {
                "required": [
                  "B"
                ],
                "properties": {
                  "B": {
                    "not": {
                      "const": ""
                    }
                  }
                }
              }
            ]
          }
        ]
      }
    },
    {
      "if": {
        "required": [
          "mode"
        ],
        "properties": {
          "mode": {
            "enum": [
              "scale",
              "multiply",
              "divide"
            ]
          }
        }
      },
      "then": {
        "anyOf": [
          {
            "required": [
              "k"
            ],
            "properties": {
              "k": {
                "not": {
                  "const": ""
                }
              }
            }
          },
          {
            "required": [
              "kInput"
            ],
            "properties": {
              "kInput": {
                "not": {
                  "const": ""
                }
              }
            }
          },
          {
            "required": [
              "factor"
            ],
            "properties": {
              "factor": {
                "not": {
                  "const": ""
                }
              }
            }
          }
        ]
      }
    },
    {
      "if": {
        "required": [
          "mode"
        ],
        "properties": {
          "mode": {
            "enum": [
              "split",
              "share",
              "allocate"
            ]
          }
        }
      },
      "then": {
        "anyOf": [
          {
            "required": [
              "total"
            ],
            "properties": {
              "total": {
                "not": {
                  "const": ""
                }
              }
            }
          },
          {
            "required": [
              "totalInput"
            ],
            "properties": {
              "totalInput": {
                "not": {
                  "const": ""
                }
              }
            }
          }
        ]
      }
    },
    {
      "if": {
        "required": [
          "mode"
        ],
        "properties": {
          "mode": {
            "enum": [
              "compare",
              "eq",
              "equivalent"
            ]
          }
        }
      },
      "then": {
        "allOf": [
          {
            "anyOf": [
              {
                "required": [
                  "c"
                ],
                "properties": {
                  "c": {
                    "not": {
                      "const": ""
                    }
                  }
                }
              },
              {
                "required": [
                  "cInput"
                ],
                "properties": {
                  "cInput": {
                    "not": {
                      "const": ""
                    }
                  }
                }
              },
              {
                "required": [
                  "C"
                ],
                "properties": {
                  "C": {
                    "not": {
                      "const": ""
                    }
                  }
                }
              }
            ]
          },
          {
            "anyOf": [
              {
                "required": [
                  "d"
                ],
                "properties": {
                  "d": {
                    "not": {
                      "const": ""
                    }
                  }
                }
              },
              {
                "required": [
                  "dInput"
                ],
                "properties": {
                  "dInput": {
                    "not": {
                      "const": ""
                    }
                  }
                }
              },
              {
                "required": [
                  "D"
                ],
                "properties": {
                  "D": {
                    "not": {
                      "const": ""
                    }
                  }
                }
              }
            ]
          }
        ]
      }
    }
  ]
}
