// Douyin Live WebSocket Protobuf Schema (simplified)
//
// References:
//   - https://github.com/saermart/DouyinLiveWebFetcher (full douyin.proto, 20K+ lines)
//   - https://github.com/zangxx66/VSingerBoard (betterproto2 generated code)
//
// This is a minimal subset containing only the message types needed for
// danmaku reception. Check upstream repos for schema updates if parsing breaks.
//
// Extracted on 2026-02-06.

syntax = "proto3";

package douyin;

// Outer push frame
message PushFrame {
  uint64 SeqID = 1;
  uint64 LogID = 2;
  int32 service = 3;
  int32 method = 4;
  repeated PushHeader headers = 5;
  string payload_encoding = 6;
  string payload_type = 7;
  bytes payload = 8;
}

message PushHeader {
  string key = 1;
  string value = 2;
}

// Inner response
message Response {
  repeated Message messages = 1;
  string cursor = 2;
  uint64 fetch_interval = 3;
  uint64 now = 4;
  string internal_ext = 5;
  int32 fetch_type = 6;
  map<string, string> route_params = 7;
  uint64 heartbeat_duration = 8;
  bool need_ack = 9;
  string push_server = 10;
}

// Message entry
message Message {
  string method = 1;
  bytes payload = 2;
  uint64 msg_id = 3;
  int32 msg_type = 4;
  uint64 offset = 5;
}

// Chat message
message ChatMessage {
  Common common = 1;
  User user = 2;
  string content = 3;
  bool visible_to_sender = 4;
  uint64 event_time = 15;
}

// Common header
message Common {
  string method = 1;
  uint64 msg_id = 2;
  uint64 room_id = 3;
  uint64 create_time = 4;
}

// User info
message User {
  uint64 id = 1;
  uint64 short_id = 2;
  string nickname = 3;
  int32 gender = 4;
  string signature = 5;
  int32 level = 6;
  Image avatar_thumb = 9;
  FansClub fans_club = 24;
  string display_id = 38;
  string sec_uid = 46;
}

// Fans club
message FansClub {
  FansClubData data = 1;
}

message FansClubData {
  string club_name = 1;
  int32 level = 2;
  int32 user_fans_club_status = 3;
  uint64 anchor_id = 6;
}

// Image
message Image {
  repeated string url_list = 1;
  string uri = 2;
  int64 width = 3;
  int64 height = 4;
}

// Gift message
message GiftMessage {
  Common common = 1;
  uint64 gift_id = 2;
  uint64 fan_ticket_count = 3;
  uint64 group_count = 4;
  uint64 repeat_count = 5;
  uint64 combo_count = 6;
  User user = 7;
  User to_user = 8;
  uint32 repeat_end = 9;
  uint64 group_id = 11;
  GiftStruct gift = 15;
  uint64 send_type = 17;
  uint64 total_count = 29;
  uint64 send_time = 33;
}

message GiftStruct {
  Image image = 1;
  string describe = 2;
  uint64 duration = 4;
  uint64 id = 5;
  bool combo = 10;
  uint32 type = 11;
  uint32 diamond_count = 12;
  string name = 16;
  Image icon = 21;
}

// Member message (user enters room)
message MemberMessage {
  Common common = 1;
  User user = 2;
  uint64 member_count = 3;
  uint64 action = 10;
}

// Social message (follow/share)
message SocialMessage {
  Common common = 1;
  User user = 2;
  uint64 share_type = 3;
  uint64 action = 4;
  string share_target = 5;
  uint64 follow_count = 6;
}

// Like message
message LikeMessage {
  Common common = 1;
  uint64 count = 2;
  uint64 total = 3;
  uint64 color = 4;
  User user = 5;
}

// Control message (live start/end)
message ControlMessage {
  Common common = 1;
  int32 status = 2;
}
