let d = import "../../adrs/defaults.ncl" in
let mk = d.make_adr in

mk {
  id     = "{{ id }}",
  title  = "{{ title }}",
  status = '{{ status }},
  date   = "{{ date }}",

  context  = "{{ context | replace('"', '\\"') | replace('\n', ' ') | trim }}",
  decision = "{{ decision | replace('"', '\\"') | replace('\n', ' ') | trim }}",

  rationale = {{ rationale }},

  consequences = {
    positive = {{ consequences_positive }},
    negative = {{ consequences_negative }},
  },

  alternatives_considered = {{ alternatives_considered }},

  constraints = {{ constraints }},

  {% if related_adrs and related_adrs != "" %}
  related_adrs = [{{ related_adrs | split(",") | map("trim") | map("json") | join(", ") }}],
  {% else %}
  related_adrs = [],
  {% endif %}

  {% if supersedes and supersedes != "" %}
  supersedes = "{{ supersedes }}",
  {% endif %}

  ontology_check = {
    decision_string    = "{{ ontology_decision_string }}",
    invariants_at_risk = {{ ontology_invariants_at_risk | tojson }},
    verdict            = '{{ ontology_verdict }},
  },
}
