{
  "$schema": "https://schema.spbx.tel/v1/structs.realm.lib",
  "description": "Business-hours routing: run the day slot inside the configured window, the night slot outside it. Both slots must be filled (a branch may not be empty).",
  "params": {
    "weekdays": {
      "type": "list",
      "description": "Weekdays (mon..sun) that count as business days.",
      "default": [
        "mon",
        "tue",
        "wed",
        "thu",
        "fri"
      ]
    },
    "start_hour": {
      "type": "number",
      "description": "Window start hour (0-23).",
      "default": 8
    },
    "start_minute": {
      "type": "number",
      "description": "Window start minute.",
      "default": 0
    },
    "end_hour": {
      "type": "number",
      "description": "Window end hour (0-23).",
      "default": 17
    },
    "end_minute": {
      "type": "number",
      "description": "Window end minute.",
      "default": 0
    }
  },
  "slots": {
    "day": {
      "description": "Flows executed during business hours. Must be filled."
    },
    "night": {
      "description": "Flows executed outside business hours. Must be filled."
    }
  },
  "exports": {
    "route": {
      "description": "Branch into the day or night slot based on the current time.",
      "flow": "flows/if/route"
    }
  },
  "flows": {
    "if": {
      "route": {
        "condition": "conditions/time/hours",
        "then": [
          "slots/day"
        ],
        "else": [
          "slots/night"
        ]
      }
    }
  },
  "conditions": {
    "time": {
      "hours": {
        "weekdays": "${weekdays}",
        "start_hour": "${start_hour}",
        "start_minute": "${start_minute}",
        "end_hour": "${end_hour}",
        "end_minute": "${end_minute}"
      }
    }
  }
}
