{"version":3,"file":"globaluserstate.mjs","names":[],"sources":["../../../src/message/twitch-types/globaluserstate.ts"],"sourcesContent":["import type { TwitchBadgesList } from \"../badges\";\nimport type { Color } from \"../color\";\nimport type { TwitchEmoteSets } from \"../parser/emote-sets\";\nimport { type IRCMessageData, IRCMessage } from \"../irc/irc-message\";\nimport { tagParserFor } from \"../parser/tag-values\";\n\n/**\n * Global state of the logged in user.\n */\nexport interface GlobalUserState {\n  badgeInfo: TwitchBadgesList;\n  badgeInfoRaw: string;\n  badges: TwitchBadgesList;\n  badgesRaw: string;\n  color: Color | undefined;\n  colorRaw: string;\n  displayName: string;\n  emoteSets: TwitchEmoteSets;\n  emoteSetsRaw: string;\n  userID: string;\n}\n\nexport class GlobaluserstateMessage\n  extends IRCMessage\n  implements GlobalUserState\n{\n  public readonly badgeInfo: TwitchBadgesList;\n  public readonly badgeInfoRaw: string;\n  public readonly badges: TwitchBadgesList;\n  public readonly badgesRaw: string;\n  public readonly color: Color | undefined;\n  public readonly colorRaw: string;\n  public readonly displayName: string;\n  public readonly emoteSets: TwitchEmoteSets;\n  public readonly emoteSetsRaw: string;\n  public readonly userID: string;\n\n  /** @deprecated Use {@link userID} instead. */\n  public get userId(): string {\n    return this.userID;\n  }\n\n  public constructor(message: IRCMessageData) {\n    super(message);\n\n    const tagParser = tagParserFor(this.ircTags);\n    this.badgeInfo = tagParser.requireBadges(\"badge-info\");\n    this.badgeInfoRaw = tagParser.requireString(\"badge-info\");\n    this.badges = tagParser.requireBadges(\"badges\");\n    this.badgesRaw = tagParser.requireString(\"badges\");\n    this.color = tagParser.getColor(\"color\");\n    this.colorRaw = tagParser.requireString(\"color\");\n    // trim: Twitch workaround for unsanitized data, see https://github.com/robotty/dank-twitch-irc/issues/33\n    this.displayName = tagParser.requireString(\"display-name\").trim();\n    this.emoteSets = tagParser.requireEmoteSets(\"emote-sets\");\n    this.emoteSetsRaw = tagParser.requireString(\"emote-sets\");\n    this.userID = tagParser.requireString(\"user-id\");\n  }\n\n  /**\n   * Extracts a plain object only containing the fields defined by the\n   * {@link GlobalUserState} interface.\n   */\n  public extractGlobalUserState(): GlobalUserState {\n    return {\n      badgeInfo: this.badgeInfo,\n      badgeInfoRaw: this.badgeInfoRaw,\n      badges: this.badges,\n      badgesRaw: this.badgesRaw,\n      color: this.color,\n      colorRaw: this.colorRaw,\n      displayName: this.displayName,\n      emoteSets: this.emoteSets,\n      emoteSetsRaw: this.emoteSetsRaw,\n      userID: this.userID,\n    };\n  }\n}\n"],"mappings":";;;AAsBA,IAAa,yBAAb,cACU,WAEV;CACE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CAGA,IAAW,SAAiB;AAC1B,SAAO,KAAK;;CAGd,YAAmB,SAAyB;AAC1C,QAAM,QAAQ;EAEd,MAAM,YAAY,aAAa,KAAK,QAAQ;AAC5C,OAAK,YAAY,UAAU,cAAc,aAAa;AACtD,OAAK,eAAe,UAAU,cAAc,aAAa;AACzD,OAAK,SAAS,UAAU,cAAc,SAAS;AAC/C,OAAK,YAAY,UAAU,cAAc,SAAS;AAClD,OAAK,QAAQ,UAAU,SAAS,QAAQ;AACxC,OAAK,WAAW,UAAU,cAAc,QAAQ;AAEhD,OAAK,cAAc,UAAU,cAAc,eAAe,CAAC,MAAM;AACjE,OAAK,YAAY,UAAU,iBAAiB,aAAa;AACzD,OAAK,eAAe,UAAU,cAAc,aAAa;AACzD,OAAK,SAAS,UAAU,cAAc,UAAU;;;;;;CAOlD,yBAAiD;AAC/C,SAAO;GACL,WAAW,KAAK;GAChB,cAAc,KAAK;GACnB,QAAQ,KAAK;GACb,WAAW,KAAK;GAChB,OAAO,KAAK;GACZ,UAAU,KAAK;GACf,aAAa,KAAK;GAClB,WAAW,KAAK;GAChB,cAAc,KAAK;GACnB,QAAQ,KAAK;GACd"}