class TotalType3ContentModel {
  List<TotalType3Content> contents;
  int lastPage;

  TotalType3ContentModel({required this.contents, required this.lastPage});

  factory TotalType3ContentModel.fromJson(Map<String, dynamic> json) {
    return TotalType3ContentModel(
      contents: List<TotalType3Content>.from(
          json['contents'].map((x) => TotalType3Content.fromJson(x))),
      lastPage: json['lastPage'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'contents': contents.map((content) => content.toJson()).toList(),
      'lastPage': lastPage,
    };
  }
}

class TotalType3Content {
  final int id;
  final String label;
  final String title;
  final int type;
  final bool marked;
  final List<DataItem> data;

  TotalType3Content({
    required this.id,
    required this.label,
    required this.title,
    required this.type,
    required this.marked,
    required this.data,
  });

  factory TotalType3Content.fromJson(Map<String, dynamic> json) {
    return TotalType3Content(
      id: json['id'],
      label: json['label'],
      title: json['title'],
      type: json['type'],
      marked: json['marked'],
      data: List<DataItem>.from(
          json['data'].map((data) => DataItem.fromJson(data))),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'label': label,
      'title': title,
      'type': type,
      'marked': marked,
      'data': data.map((dataItem) => dataItem.toJson()).toList(),
    };
  }
}

class DataItem {
  final String name;
  final dynamic y;
  final dynamic p;
  final dynamic dp;

  DataItem({
    required this.name,
    required this.y,
    required this.p,
    required this.dp,
  });

  factory DataItem.fromJson(Map<String, dynamic> json) {
    return DataItem(
      name: json['name'],
      p: json['p'],

      y: json['y'],

      dp: json['dp'].toDouble(), // Ensuring correct type
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'name': name,
      'p': p,
      "y": y,
      'dp': dp,
    };
  }
}
