{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://betterstart.dev/schemas/schema.json",
  "title": "BetterStart Schema Definition",
  "description": "JSON Schema for validating custom schema files (courses.json, testimonials.json, instructors.json, events.json, etc.)",
  "type": "object",
  "required": ["type", "name", "label"],
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string",
      "description": "JSON Schema reference (typically './schema.json')"
    },
    "name": {
      "type": "string",
      "description": "Unique identifier for the schema (e.g., 'courses', 'site-settings')",
      "pattern": "^[a-z][a-zA-Z0-9-]*$"
    },
    "label": {
      "type": "string",
      "description": "Human-readable display name for the schema"
    },
    "labelSingular": {
      "type": "string",
      "description": "Display noun for one record, used inside sentences (e.g., 'Job application' in 'Delete this job application?'). Derived from 'label' when omitted."
    },
    "labelPlural": {
      "type": "string",
      "description": "Display noun for many records, used inside sentences (e.g., 'job applications' in '3 job applications deleted'). Falls back to 'label' when omitted."
    },
    "description": {
      "type": "string",
      "description": "Brief description of what this schema represents"
    },
    "icon": {
      "type": "string",
      "description": "Icon name from the icon library (e.g., 'BookOpen', 'Package')"
    },
    "type": {
      "type": "string",
      "description": "Schema type: 'entity' for CRUD list (default), 'single' for singleton record (site settings, about page), or 'form' for public submission forms",
      "enum": ["entity", "single", "form"]
    },
    "fields": {
      "type": "array",
      "description": "Array of field definitions",
      "items": {
        "$ref": "#/$defs/field"
      },
      "minItems": 1
    },
    "columns": {
      "type": "array",
      "description": "Table column definitions for list views",
      "items": {
        "$ref": "#/$defs/column"
      }
    },
    "actions": {
      "$ref": "#/$defs/actions"
    },
    "search": {
      "$ref": "#/$defs/search"
    },
    "filters": {
      "$ref": "#/$defs/filters"
    },
    "navGroup": {
      "type": "object",
      "description": "Sidebar navigation group. Items sharing the same group label appear together.",
      "additionalProperties": false,
      "properties": {
        "label": {
          "type": "string",
          "description": "Group label displayed in the sidebar"
        },
        "icon": {
          "type": "string",
          "description": "Lucide icon name for the group header"
        },
        "position": {
          "type": "integer",
          "description": "Sort order for this group (lower = first, unset = end)",
          "minimum": 0
        }
      },
      "required": ["label", "icon"]
    },
    "navPosition": {
      "type": "integer",
      "description": "Sort order within navigation group (lower = first, unset = end)",
      "minimum": 0
    },
    "metadata": {
      "type": "boolean",
      "description": "Show the metadata widget (updated/created timestamps, entity ID, and version history button) at the top of entity edit pages. Defaults to true for 'entity'; ignored for 'single'.",
      "default": true
    },
    "slot": {
      "$ref": "#/$defs/slotLayout",
      "description": "Entity edit-page layout. main.fields render in the primary column; sidebar.fields render in the fixed right sidebar."
    },
    "submitButtonText": {
      "type": "string",
      "description": "Form-only: text shown on the public form submit button. Defaults to 'Submit'."
    },
    "successMessage": {
      "type": "string",
      "description": "Form-only: confirmation message shown after a successful submission (ignored when redirectUrl is set)."
    },
    "redirectUrl": {
      "type": "string",
      "description": "Form-only: navigate the browser to this URL after a successful submission instead of showing the success message."
    },
    "notificationEmail": {
      "type": "string",
      "description": "Form-only: schema-level notification recipient. Used as a fallback when no admin form settings notificationEmails list is configured.",
      "format": "email"
    },
    "mailchimp": {
      "description": "Form-only: enable Mailchimp audience subscription on submit. Pass true to use the email field automatically, or { emailField: '<name>' } to specify a different source.",
      "oneOf": [
        {
          "type": "boolean"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "emailField": {
              "type": "string"
            }
          }
        }
      ]
    },
    "steps": {
      "type": "array",
      "description": "Form-only: declare multi-step forms. Each step groups its own fields shown sequentially.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["name", "label", "fields"],
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^[a-zA-Z][a-zA-Z0-9]*$"
          },
          "label": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "fields": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/$defs/field"
            }
          }
        }
      },
      "minItems": 1
    }
  },
  "$defs": {
    "actions": {
      "type": "object",
      "description": "CRUD action configuration",
      "additionalProperties": false,
      "properties": {
        "draft": {
          "type": "boolean",
          "description": "Enable draft/publish workflow",
          "default": false
        },
        "create": {
          "type": "boolean",
          "description": "Enable create action",
          "default": true
        },
        "edit": {
          "type": "boolean",
          "description": "Enable edit action",
          "default": true
        },
        "delete": {
          "type": "boolean",
          "description": "Enable delete action",
          "default": true
        },
        "export": {
          "type": "boolean",
          "description": "Form-only: surface a CSV export action for submissions.",
          "default": false
        }
      }
    },
    "baseFieldProperties": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Field identifier (camelCase)",
          "pattern": "^[a-zA-Z][a-zA-Z0-9]*$"
        },
        "label": {
          "type": "string",
          "description": "Human-readable field label"
        },
        "required": {
          "type": "boolean",
          "description": "Whether this field is required",
          "default": false
        },
        "hint": {
          "type": "string",
          "description": "Helper text displayed below the field"
        },
        "showWhen": {
          "$ref": "#/$defs/showWhenCondition"
        },
        "dependsOn": {
          "$ref": "#/$defs/dependsOnCondition"
        }
      }
    },
    "booleanField": {
      "type": "object",
      "description": "Toggle/checkbox field",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "boolean"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "default": {
          "type": "boolean"
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "hint": {
          "type": "string"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "column": {
      "type": "object",
      "description": "Table column definition for list views",
      "required": ["accessorKey", "header"],
      "additionalProperties": false,
      "properties": {
        "accessorKey": {
          "type": "string",
          "description": "Field name to access data from"
        },
        "header": {
          "type": "string",
          "description": "Column header text"
        },
        "type": {
          "type": "string",
          "description": "Column display type",
          "enum": ["image", "avatar", "text", "badge", "date", "email", "number", "link"]
        },
        "sortable": {
          "type": "boolean",
          "description": "Whether the column is sortable",
          "default": false
        },
        "size": {
          "type": "string",
          "description": "Default table column width preset",
          "enum": ["sm", "default", "lg", "xl"],
          "default": "default"
        },
        "format": {
          "type": "string",
          "description": "Display format (e.g., 'currency' for numbers)",
          "enum": ["currency", "percentage"]
        },
        "align": {
          "type": "string",
          "description": "Column text alignment",
          "enum": ["left", "center", "right"],
          "default": "left"
        }
      }
    },
    "dateField": {
      "type": "object",
      "description": "Date picker field",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "date"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "default": {
          "type": "string"
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "hint": {
          "type": "string"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "decimalField": {
      "type": "object",
      "description": "Decimal number field (for prices, percentages, etc.)",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "decimal"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "format": {
          "type": "string",
          "description": "Display format",
          "enum": ["currency", "percentage", "plain"]
        },
        "precision": {
          "type": "integer",
          "description": "Total number of digits",
          "minimum": 1,
          "maximum": 65
        },
        "scale": {
          "type": "integer",
          "description": "Number of decimal places",
          "minimum": 0,
          "maximum": 30
        },
        "hint": {
          "type": "string"
        },
        "placeholder": {
          "type": "string",
          "description": "Placeholder text displayed in the decimal input"
        },
        "default": {
          "type": "number"
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "defaultValueFrom": {
      "type": "string",
      "description": "Name of another field in the same schema to copy into this field when this field has no initial value and has not been edited away from the copied default."
    },
    "dependsOnCondition": {
      "type": "object",
      "description": "For cascading fields - specifies which sibling field(s) this field depends on",
      "additionalProperties": false,
      "properties": {
        "repo": {
          "type": "string",
          "description": "Name of the repo field for branch/directory selectors"
        },
        "branch": {
          "type": "string",
          "description": "Name of the branch field for directory selectors"
        },
        "directory": {
          "type": "string",
          "description": "Name of the directory field for chapters loader"
        }
      }
    },
    "emailField": {
      "type": "object",
      "description": "Email input field, stored as VARCHAR",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "email"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "length": {
          "type": "integer",
          "description": "Maximum character length",
          "minimum": 1,
          "maximum": 65535
        },
        "hint": {
          "type": "string"
        },
        "placeholder": {
          "type": "string",
          "description": "Placeholder text displayed in the input field"
        },
        "default": {
          "type": "string"
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "hasIcon": {
          "type": "boolean",
          "description": "Whether this field has an associated icon picker"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "showWhen": {
          "$ref": "#/$defs/showWhenCondition"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "field": {
      "type": "object",
      "description": "A field definition",
      "oneOf": [
        {
          "$ref": "#/$defs/uuidField"
        },
        {
          "$ref": "#/$defs/stringField"
        },
        {
          "$ref": "#/$defs/emailField"
        },
        {
          "$ref": "#/$defs/varcharField"
        },
        {
          "$ref": "#/$defs/textField"
        },
        {
          "$ref": "#/$defs/markdownField"
        },
        {
          "$ref": "#/$defs/richtextField"
        },
        {
          "$ref": "#/$defs/imageField"
        },
        {
          "$ref": "#/$defs/iconField"
        },
        {
          "$ref": "#/$defs/dateField"
        },
        {
          "$ref": "#/$defs/booleanField"
        },
        {
          "$ref": "#/$defs/timestampField"
        },
        {
          "$ref": "#/$defs/timeField"
        },
        {
          "$ref": "#/$defs/numberField"
        },
        {
          "$ref": "#/$defs/decimalField"
        },
        {
          "$ref": "#/$defs/selectField"
        },
        {
          "$ref": "#/$defs/listField"
        },
        {
          "$ref": "#/$defs/groupField"
        },
        {
          "$ref": "#/$defs/sectionField"
        },
        {
          "$ref": "#/$defs/tabsField"
        },
        {
          "$ref": "#/$defs/relationshipField"
        },
        {
          "$ref": "#/$defs/separatorField"
        },
        {
          "$ref": "#/$defs/videoField"
        },
        {
          "$ref": "#/$defs/mediaField"
        },
        {
          "$ref": "#/$defs/galleryField"
        }
      ]
    },
    "fieldArrayWithCreatableSelect": {
      "type": "array",
      "contains": {
        "$ref": "#/$defs/fieldWithCreatableSelect"
      }
    },
    "fieldArrayWithTitle": {
      "type": "array",
      "contains": {
        "$ref": "#/$defs/fieldWithTitle"
      }
    },
    "fieldWithCreatableSelect": {
      "type": "object",
      "anyOf": [
        {
          "properties": {
            "type": {
              "const": "select"
            },
            "creatable": {
              "const": true
            }
          },
          "required": ["type", "creatable"]
        },
        {
          "properties": {
            "fields": {
              "$ref": "#/$defs/fieldArrayWithCreatableSelect"
            }
          },
          "required": ["fields"]
        },
        {
          "properties": {
            "tabs": {
              "type": "array",
              "contains": {
                "$ref": "#/$defs/tabWithCreatableSelect"
              }
            }
          },
          "required": ["tabs"]
        }
      ]
    },
    "fieldWithTitle": {
      "type": "object",
      "anyOf": [
        {
          "properties": {
            "name": {
              "const": "title"
            },
            "type": {
              "enum": ["string", "varchar", "text"]
            }
          },
          "required": ["name", "type"]
        },
        {
          "properties": {
            "type": {
              "enum": ["group", "section"]
            },
            "fields": {
              "$ref": "#/$defs/fieldArrayWithTitle"
            }
          },
          "required": ["type", "fields"]
        },
        {
          "properties": {
            "tabs": {
              "type": "array",
              "contains": {
                "$ref": "#/$defs/tabWithTitle"
              }
            }
          },
          "required": ["tabs"]
        }
      ]
    },
    "filter": {
      "type": "object",
      "description": "Filter definition for admin tables",
      "required": ["field", "label"],
      "additionalProperties": false,
      "properties": {
        "key": {
          "type": "string",
          "description": "Optional query param key for this filter. Defaults to the field name."
        },
        "field": {
          "type": "string",
          "description": "Field name to filter by"
        },
        "label": {
          "type": "string",
          "description": "Label for the filter dropdown"
        },
        "type": {
          "type": "string",
          "description": "Filter type",
          "enum": ["select", "boolean"],
          "default": "select"
        },
        "source": {
          "type": "string",
          "description": "Where select filter options come from",
          "enum": ["distinct", "static"]
        },
        "options": {
          "type": "array",
          "description": "Static options for select filters",
          "items": {
            "type": "object",
            "required": ["label", "value"],
            "additionalProperties": false,
            "properties": {
              "label": {
                "type": "string",
                "description": "Option label shown in the filter UI"
              },
              "value": {
                "type": "string",
                "description": "Option value sent to the backend filter"
              }
            }
          }
        }
      }
    },
    "filters": {
      "type": "array",
      "description": "Filter configuration for admin tables",
      "items": {
        "$ref": "#/$defs/filter"
      }
    },
    "galleryField": {
      "type": "object",
      "description": "Multi-select media gallery field storing an array of media IDs with drag-to-reorder",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "gallery"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "hint": {
          "type": "string"
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "maxItems": {
          "type": "integer",
          "minimum": 1,
          "description": "Maximum number of media items"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "groupField": {
      "type": "object",
      "description": "Group of fields displayed together",
      "required": ["name", "type", "fields"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "group"
        },
        "label": {
          "type": "string"
        },
        "columns": {
          "type": "integer",
          "description": "Number of columns for layout",
          "minimum": 1,
          "maximum": 4
        },
        "fields": {
          "type": "array",
          "description": "Nested field definitions",
          "items": {
            "$ref": "#/$defs/field"
          },
          "minItems": 1
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "iconField": {
      "type": "object",
      "description": "Lucide icon picker field, stored as VARCHAR",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "icon"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "length": {
          "type": "integer",
          "description": "Maximum character length",
          "minimum": 1,
          "maximum": 65535
        },
        "hint": {
          "type": "string"
        },
        "placeholder": {
          "type": "string",
          "description": "Placeholder text displayed in the input field"
        },
        "default": {
          "type": "string"
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "hasIcon": {
          "type": "boolean",
          "description": "Whether this field has an associated icon picker"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "showWhen": {
          "$ref": "#/$defs/showWhenCondition"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "imageField": {
      "type": "object",
      "description": "Image upload field",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "image"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "length": {
          "type": "integer",
          "description": "Maximum URL length"
        },
        "hint": {
          "type": "string"
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "listField": {
      "type": "object",
      "description": "Repeatable list of items with nested fields",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "list"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "maxItems": {
          "type": "integer",
          "description": "Maximum number of items allowed",
          "minimum": 1
        },
        "length": {
          "type": "integer",
          "description": "Maximum length for simple list items"
        },
        "hint": {
          "type": "string"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "showWhen": {
          "$ref": "#/$defs/showWhenCondition"
        },
        "fields": {
          "type": "array",
          "description": "Nested field definitions for complex list items",
          "items": {
            "$ref": "#/$defs/field"
          }
        },
        "items": {
          "description": "Single field definition for simple list items",
          "$ref": "#/$defs/simpleListItem"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "markdownField": {
      "type": "object",
      "description": "Rich text editor with markdown support",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "markdown"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "hint": {
          "type": "string"
        },
        "placeholder": {
          "type": "string",
          "description": "Placeholder text displayed in the markdown editor"
        },
        "output": {
          "type": "string",
          "description": "Output format \u2014 'html' adds a pre-rendered HTML column alongside the markdown source",
          "enum": ["html", "markdown"]
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "showWhen": {
          "$ref": "#/$defs/showWhenCondition"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "mediaField": {
      "type": "object",
      "description": "Media upload field supporting both images and videos",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "media"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "hint": {
          "type": "string"
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "maxSizeInMB": {
          "type": "integer",
          "description": "Maximum file size in megabytes"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "numberField": {
      "type": "object",
      "description": "Integer number input field",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "number"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "default": {
          "type": "integer"
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "hint": {
          "type": "string"
        },
        "placeholder": {
          "type": "string",
          "description": "Placeholder text displayed in the number input"
        },
        "min": {
          "type": "integer"
        },
        "max": {
          "type": "integer"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "relationshipField": {
      "type": "object",
      "description": "Relationship field linking to another schema/entity",
      "required": ["name", "type", "relationship"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "relationship"
        },
        "relationship": {
          "type": "string",
          "description": "Name of the related schema/entity (e.g., 'instructors', 'courses')"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "hint": {
          "type": "string"
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "multiple": {
          "type": "boolean",
          "description": "Whether multiple items can be selected",
          "default": false
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "showWhen": {
          "$ref": "#/$defs/showWhenCondition"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "richtextField": {
      "type": "object",
      "description": "WYSIWYG rich text editor with markdown storage",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "richtext"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "hint": {
          "type": "string"
        },
        "placeholder": {
          "type": "string",
          "description": "Placeholder text displayed in the rich text editor"
        },
        "output": {
          "type": "string",
          "description": "Output format \u2014 'html' adds a pre-rendered HTML column alongside the markdown source",
          "enum": ["html", "markdown"]
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "showWhen": {
          "$ref": "#/$defs/showWhenCondition"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "search": {
      "type": "object",
      "description": "Backend search configuration for admin tables",
      "additionalProperties": false,
      "required": ["fields"],
      "properties": {
        "fields": {
          "type": "array",
          "description": "Array of field names to search across (should be text-type columns like string, text, varchar)",
          "items": {
            "type": "string",
            "description": "Field name to include in search"
          },
          "minItems": 1
        }
      }
    },
    "sectionField": {
      "type": "object",
      "description": "Section of fields displayed together. Top-level sidebar sections render as separate cards.",
      "required": ["name", "type", "fields"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "section"
        },
        "label": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "hint": {
          "type": "string"
        },
        "heading": {
          "$ref": "#/$defs/sectionHeading"
        },
        "columns": {
          "type": "integer",
          "description": "Number of columns for layout",
          "minimum": 1,
          "maximum": 4
        },
        "fields": {
          "type": "array",
          "description": "Nested field definitions",
          "items": {
            "$ref": "#/$defs/field"
          },
          "minItems": 1
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "sectionHeading": {
      "type": "object",
      "description": "Optional card heading rendered for sidebar section cards.",
      "required": ["title"],
      "additionalProperties": false,
      "properties": {
        "title": {
          "type": "string",
          "description": "Heading text rendered in the section card header."
        },
        "icon": {
          "type": "string",
          "description": "Lucide icon name rendered before the heading title, for example bolt or globe."
        }
      }
    },
    "selectField": {
      "type": "object",
      "description": "Dropdown select field",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "select"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "hint": {
          "type": "string"
        },
        "placeholder": {
          "type": "string",
          "description": "Placeholder text displayed in the select trigger"
        },
        "options": {
          "type": "array",
          "description": "Available options for the select",
          "items": {
            "type": "object",
            "required": ["label", "value"],
            "additionalProperties": false,
            "properties": {
              "label": {
                "type": "string",
                "description": "Display label"
              },
              "value": {
                "type": "string",
                "description": "Value stored in database"
              }
            }
          },
          "minItems": 1
        },
        "default": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "creatable": {
          "type": "boolean",
          "description": "Allow admins to create field-scoped options from the generated form"
        },
        "multiple": {
          "type": "boolean",
          "description": "Allow multiple selected option values"
        },
        "previewLimit": {
          "type": "integer",
          "minimum": 1,
          "description": "Number of selected labels shown before collapsing the rest into a count badge"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "multiple": {
                "const": true
              }
            },
            "required": ["multiple"]
          },
          "else": {
            "properties": {
              "default": {
                "type": "string"
              }
            },
            "not": {
              "required": ["previewLimit"]
            }
          }
        }
      ]
    },
    "separatorField": {
      "type": "object",
      "description": "Visual separator between form fields",
      "required": ["type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "separator"
        },
        "label": {
          "type": "string",
          "description": "Optional label to display with the separator"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "showWhenCondition": {
      "type": "object",
      "description": "Conditional visibility based on sibling field value",
      "required": ["field", "value"],
      "additionalProperties": false,
      "properties": {
        "field": {
          "type": "string",
          "description": "Name of the sibling field to watch"
        },
        "value": {
          "oneOf": [
            {
              "type": "boolean"
            },
            {
              "type": "string"
            },
            {
              "type": "number"
            }
          ],
          "description": "Value that makes this field visible"
        }
      }
    },
    "simpleListItem": {
      "type": "object",
      "description": "Simple list item definition",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "length": {
          "type": "integer"
        }
      }
    },
    "slotArea": {
      "type": "object",
      "description": "A named layout area containing generated form fields.",
      "required": ["fields"],
      "additionalProperties": false,
      "properties": {
        "fields": {
          "type": "array",
          "description": "Fields rendered in this layout area.",
          "items": {
            "$ref": "#/$defs/field"
          },
          "minItems": 1
        }
      }
    },
    "slotLayout": {
      "type": "object",
      "description": "Main/sidebar layout groups for an entity edit form or tab panel.",
      "additionalProperties": false,
      "properties": {
        "main": {
          "$ref": "#/$defs/slotArea"
        },
        "sidebar": {
          "$ref": "#/$defs/slotArea"
        }
      },
      "anyOf": [
        {
          "required": ["main"]
        },
        {
          "required": ["sidebar"]
        }
      ]
    },
    "slotLayoutWithCreatableSelect": {
      "type": "object",
      "anyOf": [
        {
          "properties": {
            "main": {
              "properties": {
                "fields": {
                  "$ref": "#/$defs/fieldArrayWithCreatableSelect"
                }
              },
              "required": ["fields"]
            }
          },
          "required": ["main"]
        },
        {
          "properties": {
            "sidebar": {
              "properties": {
                "fields": {
                  "$ref": "#/$defs/fieldArrayWithCreatableSelect"
                }
              },
              "required": ["fields"]
            }
          },
          "required": ["sidebar"]
        }
      ]
    },
    "slotLayoutWithTitle": {
      "type": "object",
      "anyOf": [
        {
          "properties": {
            "main": {
              "properties": {
                "fields": {
                  "$ref": "#/$defs/fieldArrayWithTitle"
                }
              },
              "required": ["fields"]
            }
          },
          "required": ["main"]
        },
        {
          "properties": {
            "sidebar": {
              "properties": {
                "fields": {
                  "$ref": "#/$defs/fieldArrayWithTitle"
                }
              },
              "required": ["fields"]
            }
          },
          "required": ["sidebar"]
        }
      ]
    },
    "stepWithTitle": {
      "type": "object",
      "properties": {
        "fields": {
          "$ref": "#/$defs/fieldArrayWithTitle"
        }
      },
      "required": ["fields"]
    },
    "stringField": {
      "type": "object",
      "description": "Single-line text input field",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "string"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "length": {
          "type": "integer",
          "description": "Maximum character length",
          "minimum": 1,
          "maximum": 65535
        },
        "hint": {
          "type": "string"
        },
        "placeholder": {
          "type": "string",
          "description": "Placeholder text displayed in the input field"
        },
        "default": {
          "type": "string"
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "hasIcon": {
          "type": "boolean",
          "description": "Whether this field has an associated icon picker"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "showWhen": {
          "$ref": "#/$defs/showWhenCondition"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "tab": {
      "type": "object",
      "description": "A single tab containing fields",
      "required": ["name", "label"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string",
          "description": "Tab identifier"
        },
        "label": {
          "type": "string",
          "description": "Tab display label"
        },
        "icon": {
          "type": "string",
          "description": "Lucide icon name rendered before the tab label"
        },
        "fields": {
          "type": "array",
          "description": "Fields within this tab",
          "items": {
            "$ref": "#/$defs/field"
          },
          "minItems": 1
        },
        "slot": {
          "$ref": "#/$defs/slotLayout",
          "description": "Tab-scoped main/sidebar layout. Sidebar fields render only while this tab is active."
        }
      },
      "oneOf": [
        {
          "required": ["fields"],
          "not": {
            "required": ["slot"]
          }
        },
        {
          "required": ["slot"],
          "not": {
            "required": ["fields"]
          }
        }
      ]
    },
    "tabWithCreatableSelect": {
      "type": "object",
      "anyOf": [
        {
          "properties": {
            "fields": {
              "$ref": "#/$defs/fieldArrayWithCreatableSelect"
            }
          },
          "required": ["fields"]
        },
        {
          "properties": {
            "slot": {
              "$ref": "#/$defs/slotLayoutWithCreatableSelect"
            }
          },
          "required": ["slot"]
        }
      ]
    },
    "tabWithTitle": {
      "type": "object",
      "anyOf": [
        {
          "properties": {
            "fields": {
              "$ref": "#/$defs/fieldArrayWithTitle"
            }
          },
          "required": ["fields"]
        },
        {
          "properties": {
            "slot": {
              "$ref": "#/$defs/slotLayoutWithTitle"
            }
          },
          "required": ["slot"]
        }
      ]
    },
    "tabsField": {
      "type": "object",
      "description": "Tabbed interface for organizing fields",
      "required": ["name", "type", "tabs"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "tabs"
        },
        "tabs": {
          "type": "array",
          "description": "Tab definitions",
          "items": {
            "$ref": "#/$defs/tab"
          },
          "minItems": 1
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "textField": {
      "type": "object",
      "description": "Multi-line text area field",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "text"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "length": {
          "type": "integer",
          "description": "Maximum character length",
          "minimum": 1
        },
        "hint": {
          "type": "string"
        },
        "placeholder": {
          "type": "string",
          "description": "Placeholder text displayed in the text area"
        },
        "default": {
          "type": "string"
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "showWhen": {
          "$ref": "#/$defs/showWhenCondition"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "timeField": {
      "type": "object",
      "description": "Time-of-day input field, stored as VARCHAR",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "time"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "length": {
          "type": "integer",
          "description": "Maximum character length",
          "minimum": 1,
          "maximum": 65535
        },
        "hint": {
          "type": "string"
        },
        "placeholder": {
          "type": "string",
          "description": "Placeholder text displayed in the input field"
        },
        "default": {
          "type": "string"
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "hasIcon": {
          "type": "boolean",
          "description": "Whether this field has an associated icon picker"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "showWhen": {
          "$ref": "#/$defs/showWhenCondition"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "timestampField": {
      "type": "object",
      "description": "Timestamp field (typically auto-generated)",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "timestamp"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "uuidField": {
      "type": "object",
      "description": "UUID primary key field",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "uuid"
        },
        "primaryKey": {
          "type": "boolean",
          "description": "Whether this is the primary key",
          "default": true
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "varcharField": {
      "type": "object",
      "description": "Fixed-length text input field",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "varchar"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "length": {
          "type": "integer",
          "description": "Maximum character length",
          "minimum": 1,
          "maximum": 65535
        },
        "hint": {
          "type": "string"
        },
        "placeholder": {
          "type": "string",
          "description": "Placeholder text displayed in the input field"
        },
        "default": {
          "type": "string"
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "hasIcon": {
          "type": "boolean",
          "description": "Whether this field has an associated icon picker"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "showWhen": {
          "$ref": "#/$defs/showWhenCondition"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    },
    "videoField": {
      "type": "object",
      "description": "Video upload field",
      "required": ["name", "type"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "const": "video"
        },
        "label": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "hint": {
          "type": "string"
        },
        "defaultValueFrom": {
          "$ref": "#/$defs/defaultValueFrom"
        },
        "maxSizeInMB": {
          "type": "integer",
          "description": "Maximum file size in megabytes"
        },
        "hidden": {
          "type": "boolean",
          "description": "Whether this field is hidden from the form UI but still exists in the database"
        },
        "height": {
          "enum": ["auto", "fill"],
          "default": "auto",
          "description": "Generated field height behavior: auto size or fill remaining flexible space."
        }
      }
    }
  },
  "oneOf": [
    {
      "required": ["fields"],
      "not": {
        "anyOf": [
          {
            "required": ["slot"]
          },
          {
            "required": ["steps"]
          }
        ]
      }
    },
    {
      "required": ["slot"],
      "not": {
        "anyOf": [
          {
            "required": ["fields"]
          },
          {
            "required": ["steps"]
          }
        ]
      }
    },
    {
      "required": ["steps"],
      "not": {
        "anyOf": [
          {
            "required": ["fields"]
          },
          {
            "required": ["slot"]
          }
        ]
      }
    }
  ],
  "allOf": [
    {
      "anyOf": [
        {
          "properties": {
            "fields": {
              "$ref": "#/$defs/fieldArrayWithTitle"
            }
          },
          "required": ["fields"]
        },
        {
          "properties": {
            "slot": {
              "$ref": "#/$defs/slotLayoutWithTitle"
            }
          },
          "required": ["slot"]
        },
        {
          "properties": {
            "steps": {
              "type": "array",
              "contains": {
                "$ref": "#/$defs/stepWithTitle"
              }
            }
          },
          "required": ["steps"]
        }
      ]
    },
    {
      "if": {
        "properties": {
          "type": {
            "enum": ["single", "form"]
          }
        },
        "required": ["type"]
      },
      "then": {
        "not": {
          "anyOf": [
            {
              "properties": {
                "fields": {
                  "$ref": "#/$defs/fieldArrayWithCreatableSelect"
                }
              },
              "required": ["fields"]
            },
            {
              "properties": {
                "slot": {
                  "$ref": "#/$defs/slotLayoutWithCreatableSelect"
                }
              },
              "required": ["slot"]
            }
          ]
        }
      }
    }
  ]
}
