{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openeik.org/schemas/0.1/drawings/detail-item.schema.json",
  "title": "Detail item",
  "description": "One 2D item of a view: a line, a text, a region, a dimension, a tag and so on (documentation profile).",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "minLength": 1
    },
    "kind": {
      "type": "string",
      "enum": [
        "line",
        "rectangle",
        "text",
        "region",
        "mask",
        "insulation",
        "dimension",
        "circle",
        "leader",
        "component",
        "tag",
        "viewReference",
        "note",
        "schedule",
        "legend",
        "symbol"
      ]
    },
    "symbol": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 40,
          "x-eik-application": true
        },
        "rotation": {
          "type": "number",
          "minimum": -360,
          "maximum": 360
        },
        "mirror": {
          "type": "boolean"
        },
        "texts": {
          "type": "object",
          "additionalProperties": {
            "type": "string",
            "maxLength": 40
          },
          "propertyNames": {
            "minLength": 1,
            "maxLength": 20
          }
        }
      },
      "required": [
        "name"
      ],
      "x-eik-closed": true
    },
    "connect": {
      "type": "object",
      "properties": {
        "start": {
          "type": "object",
          "properties": {
            "detailId": {
              "type": "string",
              "minLength": 1
            },
            "port": {
              "type": "string",
              "minLength": 1,
              "maxLength": 40,
              "x-eik-application": true
            }
          },
          "required": [
            "detailId",
            "port"
          ],
          "x-eik-closed": true
        },
        "end": {
          "type": "object",
          "properties": {
            "detailId": {
              "type": "string",
              "minLength": 1
            },
            "port": {
              "type": "string",
              "minLength": 1,
              "maxLength": 40,
              "x-eik-application": true
            }
          },
          "required": [
            "detailId",
            "port"
          ],
          "x-eik-closed": true
        }
      },
      "x-eik-closed": true
    },
    "component": {
      "type": "object",
      "properties": {
        "family": {
          "type": "string",
          "enum": [
            "toilet",
            "basin",
            "angleBracket",
            "joistHanger",
            "timberSection",
            "bolt",
            "plate",
            "weld",
            "anchorNail",
            "reinforcedBracketFront",
            "gutter",
            "ventArrow",
            "fascia",
            "tongueBoard"
          ]
        },
        "depth": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 10000
        },
        "thickness": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 100
        },
        "holes": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "x": {
                "type": "number"
              },
              "y": {
                "type": "number"
              },
              "diameter": {
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 1000
              },
              "length": {
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 2000
              },
              "angle": {
                "type": "number",
                "minimum": -360,
                "maximum": 360
              }
            },
            "required": [
              "x",
              "y",
              "diameter"
            ],
            "x-eik-closed": true
          },
          "maxItems": 50
        },
        "flange": {
          "type": "number",
          "minimum": -200,
          "maximum": 200
        },
        "nails": {
          "type": "object",
          "properties": {
            "diameter": {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 20
            },
            "cols": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 20
            },
            "spacing": {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 300
            },
            "rows": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 20
            },
            "rowSpacing": {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 300
            },
            "margin": {
              "type": "number",
              "minimum": 0,
              "maximum": 300
            }
          },
          "required": [
            "diameter",
            "cols",
            "spacing",
            "rows",
            "rowSpacing",
            "margin"
          ],
          "x-eik-closed": true
        },
        "bolt": {
          "type": "object",
          "properties": {
            "diameter": {
              "type": "number"
            },
            "grade": {
              "type": "string",
              "enum": [
                "4.6",
                "5.6",
                "8.8",
                "10.9"
              ],
              "default": "8.8"
            },
            "kind": {
              "type": "string",
              "enum": [
                "bolt",
                "anchor",
                "rod"
              ],
              "default": "bolt"
            },
            "washers": {
              "type": "integer",
              "minimum": 0,
              "maximum": 2,
              "default": 1
            },
            "nuts": {
              "type": "integer",
              "minimum": 0,
              "maximum": 2
            },
            "finish": {
              "type": "string",
              "enum": [
                "hdg",
                "black"
              ]
            }
          },
          "required": [
            "diameter"
          ],
          "x-eik-closed": true
        },
        "width": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 10000
        },
        "rotation": {
          "type": "number",
          "default": 0
        }
      },
      "required": [
        "family",
        "depth",
        "width"
      ],
      "x-eik-closed": true
    },
    "familyInstance": {
      "type": "object",
      "properties": {
        "familyId": {
          "type": "string"
        },
        "typeId": {
          "type": "string"
        },
        "values": {
          "type": "object",
          "additionalProperties": {
            "type": "number"
          }
        },
        "rotation": {
          "type": "number"
        }
      },
      "required": [
        "familyId",
        "typeId",
        "values",
        "rotation"
      ],
      "x-eik-closed": true
    },
    "host": {
      "type": "object",
      "properties": {
        "elementId": {
          "type": "string",
          "minLength": 1
        },
        "anchor": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "prefixItems": [
            {
              "type": "number"
            },
            {
              "type": "number"
            }
          ]
        }
      },
      "required": [
        "elementId"
      ],
      "x-eik-closed": true
    },
    "mirrored": {
      "type": "boolean"
    },
    "a": {
      "type": "array",
      "minItems": 2,
      "maxItems": 2,
      "prefixItems": [
        {
          "type": "number"
        },
        {
          "type": "number"
        }
      ]
    },
    "b": {
      "type": "array",
      "minItems": 2,
      "maxItems": 2,
      "prefixItems": [
        {
          "type": "number"
        },
        {
          "type": "number"
        }
      ]
    },
    "text": {
      "type": "string",
      "maxLength": 2000
    },
    "textHeight": {
      "type": "number",
      "exclusiveMinimum": 0,
      "maximum": 100
    },
    "textSize": {
      "type": "number",
      "exclusiveMinimum": 0,
      "maximum": 10000
    },
    "textWidth": {
      "type": "number",
      "exclusiveMinimum": 0,
      "maximum": 100000
    },
    "textWrap": {
      "type": "boolean"
    },
    "textJustify": {
      "type": "string",
      "enum": [
        "left",
        "center",
        "right"
      ]
    },
    "textLeader": {
      "type": "boolean"
    },
    "leaderSide": {
      "type": "string",
      "enum": [
        "auto",
        "left",
        "right"
      ]
    },
    "leaderArrow": {
      "type": "string",
      "enum": [
        "arrow",
        "dot",
        "none"
      ]
    },
    "textRotation": {
      "type": "number"
    },
    "shapeRotation": {
      "type": "number"
    },
    "curveKind": {
      "type": "string",
      "enum": [
        "circle",
        "arc"
      ]
    },
    "textBold": {
      "type": "boolean"
    },
    "textBackground": {
      "type": "string",
      "enum": [
        "opaque",
        "transparent"
      ]
    },
    "textFrame": {
      "type": "object",
      "properties": {
        "shape": {
          "type": "string",
          "enum": [
            "rectangle",
            "rounded",
            "none"
          ]
        },
        "margin": {
          "type": "number",
          "minimum": 0,
          "maximum": 10
        },
        "weight": {
          "type": "number",
          "minimum": 0.05,
          "maximum": 2
        }
      },
      "required": [
        "shape"
      ],
      "x-eik-closed": true
    },
    "fontFamily": {
      "type": "string",
      "x-eik-application": true
    },
    "color": {
      "type": "string",
      "pattern": "^#[0-9a-fA-F]{6}$"
    },
    "filled": {
      "type": "boolean"
    },
    "points": {
      "type": "array",
      "items": {
        "type": "array",
        "minItems": 2,
        "maxItems": 2,
        "prefixItems": [
          {
            "type": "number"
          },
          {
            "type": "number"
          }
        ]
      },
      "minItems": 2,
      "maxItems": 500
    },
    "closed": {
      "type": "boolean"
    },
    "width": {
      "type": "number",
      "exclusiveMinimum": 0,
      "maximum": 10000
    },
    "bulgeRatio": {
      "type": "number",
      "minimum": 1,
      "maximum": 20
    },
    "insulationKind": {
      "type": "string",
      "enum": [
        "bulge",
        "zigzag"
      ]
    },
    "replaceMaterialHatch": {
      "type": "boolean"
    },
    "hatchHost": {
      "type": "object",
      "properties": {
        "elementId": {
          "type": "string",
          "minLength": 1
        },
        "layerId": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "elementId",
        "layerId"
      ],
      "x-eik-closed": true
    },
    "masking": {
      "type": "boolean"
    },
    "under": {
      "type": "boolean"
    },
    "opacity": {
      "type": "number",
      "minimum": 0.1,
      "maximum": 1
    },
    "maskBoundary": {
      "type": "boolean"
    },
    "maskEdges": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "visible": {
            "type": "boolean"
          },
          "lineWeight": {
            "type": "number",
            "exclusiveMinimum": 0,
            "maximum": 3
          },
          "lineStyle": {
            "type": "string",
            "enum": [
              "solid",
              "dash",
              "center"
            ]
          }
        },
        "required": [
          "visible",
          "lineWeight",
          "lineStyle"
        ],
        "x-eik-closed": true
      },
      "minItems": 3,
      "maxItems": 500
    },
    "repeat": {
      "type": "object",
      "properties": {
        "layout": {
          "type": "string",
          "enum": [
            "fill",
            "distance",
            "number",
            "maximum"
          ]
        },
        "spacing": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 100000
        },
        "count": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000
        },
        "inside": {
          "type": "boolean"
        }
      },
      "required": [
        "layout",
        "spacing",
        "count",
        "inside"
      ],
      "x-eik-closed": true
    },
    "lineWeight": {
      "type": "number",
      "minimum": 0,
      "maximum": 3
    },
    "modelPoint": {
      "type": "array",
      "minItems": 3,
      "maxItems": 3,
      "prefixItems": [
        {
          "type": "number"
        },
        {
          "type": "number"
        },
        {
          "type": "number"
        }
      ]
    },
    "dimensionOffset": {
      "type": "number"
    },
    "viewReference": {
      "type": "object",
      "properties": {
        "viewId": {
          "type": "string",
          "minLength": 1
        },
        "label": {
          "type": "string",
          "maxLength": 80
        },
        "shape": {
          "type": "string",
          "enum": [
            "rectangle",
            "circle"
          ]
        },
        "labelOffset": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "prefixItems": [
            {
              "type": "number"
            },
            {
              "type": "number"
            }
          ]
        }
      },
      "required": [
        "viewId"
      ],
      "x-eik-closed": true
    },
    "dimensionAxis": {
      "type": "string",
      "enum": [
        "horizontal",
        "vertical",
        "aligned"
      ]
    },
    "dimensionType": {
      "type": "string",
      "enum": [
        "aligned",
        "linear",
        "angular",
        "radial",
        "diameter",
        "slope",
        "spot"
      ]
    },
    "slopeFormat": {
      "type": "string",
      "enum": [
        "degrees",
        "ratio",
        "percent"
      ]
    },
    "spotDatum": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "project",
            "shared"
          ]
        },
        {
          "type": "object",
          "properties": {
            "levelId": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "levelId"
          ],
          "x-eik-closed": true
        }
      ]
    },
    "dimensionStyleId": {
      "type": "string",
      "minLength": 1
    },
    "dimensionEquality": {
      "type": "boolean"
    },
    "dimensionLeader": {
      "type": "boolean"
    },
    "dimensionSegments": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "maxLength": 200
          },
          "prefix": {
            "type": "string",
            "maxLength": 80
          },
          "suffix": {
            "type": "string",
            "maxLength": 80
          },
          "above": {
            "type": "string",
            "maxLength": 80
          },
          "below": {
            "type": "string",
            "maxLength": 80
          },
          "textOffset": {
            "type": "array",
            "minItems": 2,
            "maxItems": 2,
            "prefixItems": [
              {
                "type": "number"
              },
              {
                "type": "number"
              }
            ]
          }
        },
        "x-eik-closed": true
      },
      "maxItems": 50
    },
    "dimensionReferences": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "reference": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "grid"
                  },
                  "gridId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "kind",
                  "gridId"
                ],
                "x-eik-closed": true
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "face"
                  },
                  "elementId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "face": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "kind",
                  "elementId",
                  "face"
                ],
                "x-eik-closed": true
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "level"
                  },
                  "levelId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "kind",
                  "levelId"
                ],
                "x-eik-closed": true
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "point"
                  }
                },
                "required": [
                  "kind"
                ],
                "x-eik-closed": true
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "detail"
                  },
                  "detailId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "anchor": {
                    "type": "string",
                    "pattern": "^(a|b|center|arc|vertex:\\d+|segment:\\d+)$"
                  }
                },
                "required": [
                  "kind",
                  "detailId",
                  "anchor"
                ],
                "x-eik-closed": true
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "layer"
                  },
                  "elementId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "boundary": {
                    "type": "integer",
                    "minimum": 0
                  }
                },
                "required": [
                  "kind",
                  "elementId",
                  "boundary"
                ],
                "x-eik-closed": true
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "axis"
                  },
                  "elementId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "kind",
                  "elementId"
                ],
                "x-eik-closed": true
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "edge"
                  },
                  "elementId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "nx": {
                    "type": "number"
                  },
                  "ny": {
                    "type": "number"
                  },
                  "offset": {
                    "type": "number"
                  }
                },
                "required": [
                  "kind",
                  "elementId",
                  "nx",
                  "ny",
                  "offset"
                ],
                "x-eik-closed": true
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "opening"
                  },
                  "elementId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "part": {
                    "type": "string",
                    "enum": [
                      "start",
                      "end",
                      "center"
                    ]
                  }
                },
                "required": [
                  "kind",
                  "elementId",
                  "part"
                ],
                "x-eik-closed": true
              }
            ]
          },
          "point": {
            "type": "array",
            "minItems": 2,
            "maxItems": 2,
            "prefixItems": [
              {
                "type": "number"
              },
              {
                "type": "number"
              }
            ]
          }
        },
        "required": [
          "reference",
          "point"
        ],
        "x-eik-closed": true
      },
      "minItems": 1,
      "maxItems": 50
    },
    "pieceFeatures": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 80
      },
      "maxItems": 50
    },
    "tag": {
      "type": "object",
      "properties": {
        "elementId": {
          "type": "string",
          "minLength": 1
        },
        "field": {
          "type": "string",
          "enum": [
            "type",
            "name",
            "typeAndName",
            "mark",
            "bar",
            "mep",
            "room"
          ]
        },
        "leader": {
          "type": "boolean"
        },
        "count": {
          "type": "integer",
          "minimum": 1,
          "maximum": 999
        },
        "anchor": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "prefixItems": [
            {
              "type": "number"
            },
            {
              "type": "number"
            }
          ]
        }
      },
      "required": [
        "elementId",
        "field",
        "leader"
      ],
      "x-eik-closed": true
    },
    "schedule": {
      "type": "object",
      "properties": {
        "source": {
          "type": "string",
          "const": "rooms"
        },
        "fields": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "number",
              "name",
              "type",
              "level",
              "department",
              "unit",
              "class",
              "status",
              "area",
              "perimeter",
              "wallLength",
              "wallArea",
              "netWallArea",
              "openingArea",
              "skirting",
              "ceilingArea",
              "height",
              "volume",
              "notes",
              "floorFinish",
              "skirtingFinish",
              "wallFinish",
              "ceilingFinish"
            ]
          },
          "minItems": 1,
          "maxItems": 12
        },
        "levelIds": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "maxItems": 50
        },
        "group": {
          "type": "string",
          "enum": [
            "level",
            "department",
            "unit",
            "type",
            "class"
          ]
        },
        "sort": {
          "type": "string",
          "enum": [
            "number",
            "name",
            "type",
            "level",
            "department",
            "unit",
            "class",
            "status",
            "area",
            "perimeter",
            "wallLength",
            "wallArea",
            "netWallArea",
            "openingArea",
            "skirting",
            "ceilingArea",
            "height",
            "volume",
            "notes",
            "floorFinish",
            "skirtingFinish",
            "wallFinish",
            "ceilingFinish"
          ]
        },
        "totals": {
          "type": "boolean"
        }
      },
      "required": [
        "source",
        "fields"
      ],
      "x-eik-closed": true
    },
    "partsList": {
      "type": "object",
      "properties": {
        "pieceId": {
          "type": "string",
          "minLength": 1
        },
        "list": {
          "type": "string",
          "enum": [
            "parts",
            "castIn",
            "loose",
            "summary",
            "specs",
            "bars"
          ]
        }
      },
      "required": [
        "pieceId",
        "list"
      ],
      "x-eik-closed": true
    },
    "floorList": {
      "type": "object",
      "properties": {
        "slabId": {
          "type": "string",
          "minLength": 1
        },
        "levelId": {
          "type": "string",
          "minLength": 1
        }
      },
      "x-eik-closed": true
    },
    "legend": {
      "type": "object",
      "properties": {
        "scheme": {
          "type": "string",
          "enum": [
            "type",
            "department",
            "unit",
            "class",
            "systems",
            "fire"
          ]
        },
        "areas": {
          "type": "boolean"
        },
        "counts": {
          "type": "boolean"
        }
      },
      "x-eik-closed": true
    },
    "lineStyle": {
      "type": "string",
      "enum": [
        "solid",
        "dash",
        "center"
      ]
    },
    "fire": {
      "type": "object",
      "properties": {
        "class": {
          "type": "string",
          "minLength": 1,
          "maxLength": 24
        },
        "of": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "class"
      ],
      "x-eik-closed": true
    },
    "pattern": {
      "type": "string",
      "enum": [
        "none",
        "diagonal",
        "cross",
        "solid",
        "concrete",
        "concrete2",
        "concrete5",
        "gravel",
        "soil",
        "rigid",
        "soft",
        "timber",
        "glulam",
        "glulamHorizontal",
        "glulamVertical"
      ]
    },
    "spacing": {
      "type": "number",
      "exclusiveMinimum": 0,
      "maximum": 10000
    },
    "note": {
      "type": "object",
      "properties": {
        "photoHash": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "photoWidth": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 20000
        },
        "photoHeight": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 20000
        },
        "status": {
          "type": "string",
          "enum": [
            "open",
            "done"
          ]
        },
        "author": {
          "type": "string",
          "maxLength": 80
        },
        "createdAt": {
          "type": "string",
          "maxLength": 40
        },
        "doneAt": {
          "type": "string",
          "maxLength": 40
        }
      },
      "required": [
        "status",
        "createdAt"
      ],
      "x-eik-closed": true
    }
  },
  "required": [
    "id",
    "kind",
    "a",
    "b",
    "color"
  ],
  "x-eik-closed": true,
  "allOf": [
    {
      "if": {
        "required": [
          "kind"
        ],
        "properties": {
          "kind": {
            "const": "symbol"
          }
        }
      },
      "then": {
        "required": [
          "symbol"
        ]
      },
      "else": {
        "properties": {
          "symbol": false
        }
      }
    },
    {
      "if": {
        "required": [
          "connect"
        ]
      },
      "then": {
        "required": [
          "kind"
        ],
        "properties": {
          "kind": {
            "const": "line"
          }
        }
      }
    }
  ]
}
