{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://postflight.co/aeronautiql/planning/v1_1/results/range-estimate.schema.json",
  "title": "Negotiated disclosure for a table-floor range continuation",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "basis",
    "level",
    "totals",
    "totalFuelBurnLb",
    "crossings",
    "tableReplay",
    "work"
  ],
  "properties": {
    "basis": {
      "enum": ["complete_search", "manual_level"]
    },
    "level": {
      "type": "object",
      "additionalProperties": false,
      "required": ["value", "unit", "datum"],
      "properties": {
        "value": { "type": "number" },
        "unit": { "const": "ft" },
        "datum": { "const": "pressureAltitude" }
      }
    },
    "totals": {
      "type": "object",
      "additionalProperties": false,
      "required": ["fuel", "timeSeconds", "distanceNm"],
      "properties": {
        "fuel": {
          "oneOf": [
            { "type": "null" },
            { "$ref": "https://postflight.co/aeronautiql/planning/v1/results/trajectory-result-v1.schema.json#/$defs/fuel" }
          ]
        },
        "timeSeconds": { "type": "number", "minimum": 0 },
        "distanceNm": { "type": "number", "minimum": 0 }
      }
    },
    "totalFuelBurnLb": { "type": "number", "minimum": 0 },
    "usableFuelLb": { "type": "number", "exclusiveMinimum": 0 },
    "reserveLb": { "type": "number", "minimum": 0 },
    "shortfallLb": { "type": "number", "minimum": 0 },
    "crossings": {
      "type": "array",
      "minItems": 1,
      "maxItems": 16,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["boundary", "routeDistanceNm", "elapsedSeconds", "fuelBurnLb"],
        "properties": {
          "boundary": {
            "enum": [
              "reserve_requirement_exceeded",
              "usable_fuel_exhausted",
              "minimum_cruise_weight"
            ]
          },
          "routeDistanceNm": { "type": "number", "minimum": 0 },
          "elapsedSeconds": { "type": "number", "minimum": 0 },
          "fuelBurnLb": { "type": "number", "minimum": 0 }
        }
      }
    },
    "weightHold": {
      "type": "object",
      "additionalProperties": false,
      "required": ["minimumCruiseWeightLb", "heldFromRouteDistanceNm"],
      "properties": {
        "minimumCruiseWeightLb": { "type": "number", "exclusiveMinimum": 0 },
        "heldFromRouteDistanceNm": { "type": "number", "minimum": 0 },
        "ledgerBelowBasicOperatingWeight": { "type": "boolean" }
      }
    },
    "tableReplay": { "$ref": "table-replay.schema.json" },
    "work": {
      "type": "object",
      "additionalProperties": false,
      "required": ["strict", "estimate"],
      "properties": {
        "strict": { "$ref": "#/$defs/work" },
        "estimate": { "$ref": "#/$defs/work" }
      }
    }
  },
  "$defs": {
    "work": {
      "type": "object",
      "additionalProperties": false,
      "required": ["forecastQueries", "steps", "queryLimit"],
      "properties": {
        "forecastQueries": { "type": "integer", "minimum": 0, "maximum": 100000 },
        "steps": { "type": "integer", "minimum": 0 },
        "queryLimit": { "const": 100000 }
      }
    }
  }
}
