func newCacheHandle(s string) *CacheHandle {
	c := &CacheHandle{Type: s[:4], Digest: hex.EncodeToString([]byte(s[8:]))}
	regionCode := ""
	for i := 4; i <= 8; i++ {
		if s[i] != 0 {
			regionCode = s[i:8]
			break
		}
	}
	c.Region = regionByCode(regionCode)
	return c
}
newCacheHandle parses the specified source string and returns a new CacheHandle.
package rep
import (
	"encoding/hex"
	"fmt"
	"net/url"
	"path"
	"strings"
)
type Enum struct {
	Name string
}
func (e Enum) String() string {
	return e.Name
}
type GameMode struct {
	Enum
	attrValue string  
}
var GameModes = []*GameMode{
	{Enum{"AutoMM"}, "Amm"},
	{Enum{"Private"}, "Priv"},
	{Enum{"Public"}, "Pub"},
	{Enum{"Single Player"}, ""},
	{Enum{"Unknown"}, "<>"},
}
var (
	GameModeAutoMM       = GameModes[0]
	GameModePrivate      = GameModes[1]
	GameModePublic       = GameModes[2]
	GameModeSinglePlayer = GameModes[3]
	GameModeUnknown      = GameModes[4]
)
var gameModeMap = make(map[string]*GameMode)
func init() {
	for _, gm := range GameModes {
		gameModeMap[gm.attrValue] = gm
	}
}
func gameModeByAttrValue(attrValue string) *GameMode {
	if gm, ok := gameModeMap[attrValue]; ok {
		return gm
	}
	return GameModeUnknown
}
type GameSpeed struct {
	Enum
	attrValue string  
	RelSpeed  int     
}
var GameSpeeds = []*GameSpeed{
	{Enum{"Slower"}, "Slor", 60},
	{Enum{"Slow"}, "Slow", 45},
	{Enum{"Normal"}, "Norm", 36},
	{Enum{"Fast"}, "Fast", 30},
	{Enum{"Faster"}, "Fasr", 26},
	{Enum{"Unknown"}, "", 26},
}
var (
	GameSpeedSlower  = GameSpeeds[0]
	GameSpeedSlow    = GameSpeeds[1]
	GameSpeedNormal  = GameSpeeds[2]
	GameSpeedFast    = GameSpeeds[3]
	GameSpeedFaster  = GameSpeeds[4]
	GameSpeedUnknown = GameSpeeds[5]
)
func gameSpeedByID(gameSpeedID int64) *GameSpeed {
	if id := int(gameSpeedID); id >= 0 && id < len(GameSpeeds) {
		return GameSpeeds[id]
	}
	return GameSpeedUnknown
}
type Race struct {
	Enum
	Letter rune  
}
var Races = []*Race{
	{Enum{"Terran"}, 'T'},
	{Enum{"Zerg"}, 'Z'},
	{Enum{"Protoss"}, 'P'},
	{Enum{"Random"}, 'R'},
	{Enum{"Unknown"}, '-'},
}
var (
	RaceTerran  = Races[0]
	RaceZerg    = Races[1]
	RaceProtoss = Races[2]
	RaceRandom  = Races[3]
	RaceUnknown = Races[4]
)
var localRaceNames = make(map[string]*Race)
func init() {
	for _, s := range []string{"Terran", "Terraner", "Terrano", "테란", "人類", "Терран", "Терраны", "Terrani", "人类"} {
		localRaceNames[s] = RaceTerran
	}
	for _, s := range []string{"Zerg", "저그", "蟲族", "Зерг", "Зерги", "Zergi", "异虫"} {
		localRaceNames[s] = RaceZerg
	}
	for _, s := range []string{"Protoss", "프로토스", "神族", "Протосс", "Протоссы", "Protosi", "星灵"} {
		localRaceNames[s] = RaceProtoss
	}
}
func raceFromLocalString(s string) *Race {
	if r, ok := localRaceNames[s]; ok {
		return r
	}
	switch {
	case strings.HasPrefix(s, "Pr"):
		return RaceProtoss
	case strings.HasPrefix(s, "Te"):
		return RaceTerran
	case strings.HasPrefix(s, "Ze"):
		return RaceZerg
	default:
		return RaceUnknown
	}
}
func raceByID(raceID int64) *Race {
	if id := int(raceID); id >= 0 && id < len(Races) {
		return Races[id]
	}
	return RaceUnknown
}
type Result struct {
	Enum
	Letter rune  
}
var Results = []*Result{
	{Enum{"Unknown"}, '-'},
	{Enum{"Victory"}, 'V'},
	{Enum{"Defeat"}, 'D'},
	{Enum{"Tie"}, 'T'},
}
var (
	ResultUnknown = Results[0]
	ResultVictory = Results[1]
	ResultDefeat  = Results[2]
	ResultTie     = Results[3]
)
func resultByID(resultID int64) *Result {
	if id := int(resultID); id >= 0 && id < len(Results) {
		return Results[id]
	}
	return ResultUnknown
}
type Control struct {
	Enum
	attrValue string  
}
var Controls = []*Control{
	{Enum{"Open"}, "Open"},
	{Enum{"Closed"}, "Clsd"},
	{Enum{"Human"}, "Humn"},
	{Enum{"Computer"}, "Comp"},
	{Enum{"Unknown"}, ""},
}
var (
	ControlOpen     = Controls[0]
	ControlClosed   = Controls[1]
	ControlHuman    = Controls[2]
	ControlComputer = Controls[3]
	ControlUnknown  = Controls[4]
)
func controlByID(controlID int64) *Control {
	if id := int(controlID); id >= 0 && id < len(Controls) {
		return Controls[id]
	}
	return ControlUnknown
}
type Observe struct {
	Enum
}
var Observes = []*Observe{
	{Enum{"Participant"}},
	{Enum{"Spectator"}},
	{Enum{"Referee"}},
	{Enum{"Unknown"}},
}
var (
	ObserveParticipant = Observes[0]
	ObserveSpectator   = Observes[1]  
	ObserveReferee     = Observes[2]  
	ObserveUnknown     = Observes[3]
)
func observeByID(observeID int64) *Observe {
	if id := int(observeID); id >= 0 && id < len(Observes) {
		return Observes[id]
	}
	return ObserveUnknown
}
type Color struct {
	Enum
	RGB       [3]byte  
	Darker    [3]byte  
	Lighter   [3]byte  
	attrValue string   
}
var Colors = []*Color{
	{Enum: Enum{"Unknown"}, RGB: [3]byte{0, 0, 0}},
	{Enum: Enum{"Red"}, RGB: [3]byte{180, 20, 30}},
	{Enum: Enum{"Blue"}, RGB: [3]byte{0, 66, 255}},
	{Enum: Enum{"Teal"}, RGB: [3]byte{28, 167, 234}},
	{Enum: Enum{"Purple"}, RGB: [3]byte{84, 0, 129}},
	{Enum: Enum{"Yellow"}, RGB: [3]byte{235, 225, 41}},
	{Enum: Enum{"Orange"}, RGB: [3]byte{254, 138, 14}},
	{Enum: Enum{"Green"}, RGB: [3]byte{22, 128, 0}},
	{Enum: Enum{"Light Pink"}, RGB: [3]byte{204, 166, 252}},
	{Enum: Enum{"Violet"}, RGB: [3]byte{31, 1, 201}},
	{Enum: Enum{"Light Gray"}, RGB: [3]byte{82, 84, 148}},
	{Enum: Enum{"Dark Green"}, RGB: [3]byte{16, 98, 70}},
	{Enum: Enum{"Brown"}, RGB: [3]byte{78, 42, 4}},
	{Enum: Enum{"Light Green"}, RGB: [3]byte{150, 255, 145}},
	{Enum: Enum{"Dark Gray"}, RGB: [3]byte{35, 35, 35}},
	{Enum: Enum{"Pink"}, RGB: [3]byte{229, 91, 176}},
}
func init() {
	for i, c := range Colors {
		c.attrValue = fmt.Sprintf("tc%02d", i+1)
		c.Darker = [3]byte{c.RGB[0] / 2, c.RGB[1] / 2, c.RGB[2] / 2}
		c.Lighter = [3]byte{128 + c.Darker[0], 128 + c.Darker[1], 128 + c.Darker[2]}
	}
}
var (
	ColorUnknown    = Colors[0]
	ColorRed        = Colors[1]
	ColorBlue       = Colors[2]
	ColorTeal       = Colors[3]
	ColorPurple     = Colors[4]
	ColorYellow     = Colors[5]
	ColorOrange     = Colors[6]
	ColorGreen      = Colors[7]
	ColorLightPink  = Colors[8]
	ColorViolet     = Colors[9]
	ColorLightGray  = Colors[10]
	ColorDarkGreen  = Colors[11]
	ColorBrown      = Colors[12]
	ColorLightGreen = Colors[13]
	ColorDarkGray   = Colors[14]
	ColorPink       = Colors[15]
)
func colorByID(colorID int64) *Color {
	if id := int(colorID); id >= 0 && id < len(Colors) {
		return Colors[id]
	}
	return ColorUnknown
}
type League struct {
	Enum
	Letter rune  
}
var Leagues = []*League{
	{Enum{"Unknown"}, '-'},
	{Enum{"Bronze"}, 'B'},
	{Enum{"Silver"}, 'S'},
	{Enum{"Gold"}, 'G'},
	{Enum{"Platinum"}, 'P'},
	{Enum{"Diamond"}, 'D'},
	{Enum{"Master"}, 'M'},
	{Enum{"Grandmaster"}, 'R'},
	{Enum{"Unranked"}, 'U'},
}
var (
	LeagueUnknown     = Leagues[0]
	LeagueBronze      = Leagues[1]
	LeagueSilver      = Leagues[2]
	LeagueGold        = Leagues[3]
	LeaguePlatinum    = Leagues[4]
	LeagueDiamond     = Leagues[5]
	LeagueMaster      = Leagues[6]
	LeagueGrandmaster = Leagues[7]
	LeagueUnranked    = Leagues[8]
)
func leagueByID(leagueID int64) *League {
	if id := int(leagueID); id >= 0 && id < len(Leagues) {
		return Leagues[id]
	}
	return LeagueUnknown
}
type BnetLang struct {
	Enum
	Code string  
}
var BnetLangs = []*BnetLang{
	{Enum{"English"}, "en"},
	{Enum{"Chinese (Traditional)"}, "zn"},
	{Enum{"French"}, "fr"},
	{Enum{"German"}, "de"},
	{Enum{"Italian"}, "it"},
	{Enum{"Korean"}, "ko"},
	{Enum{"Polish"}, "pl"},
	{Enum{"Portuguese"}, "pt"},
	{Enum{"Russian"}, "ru"},
	{Enum{"Spanish"}, "es"},
}
var (
	BnetLangEnglish            = BnetLangs[0]
	BnetLangChineseTraditional = BnetLangs[1]
	BnetLangFrench             = BnetLangs[2]
	BnetLangGerman             = BnetLangs[3]
	BnetLangItalian            = BnetLangs[4]
	BnetLangKorean             = BnetLangs[5]
	BnetLangPolish             = BnetLangs[6]
	BnetLangPortuguese         = BnetLangs[7]
	BnetLangRussian            = BnetLangs[8]
	BnetLangSpanish            = BnetLangs[9]
)
type Realm struct {
	Enum
}
var Realms = []*Realm{
	{Enum{"North America"}},
	{Enum{"Latin America"}},
	{Enum{"China"}},
	{Enum{"Europe"}},
	{Enum{"Russia"}},
	{Enum{"Korea"}},
	{Enum{"Taiwan"}},
	{Enum{"SEA"}},
	{Enum{"Unknown"}},
}
var (
	RealmNorthAmerica = Realms[0]
	RealmLatinAmerica = Realms[1]
	RealmChina        = Realms[2]
	RealmEurope       = Realms[3]
	RealmRussia       = Realms[4]
	RealmKorea        = Realms[5]
	RealmTaiwan       = Realms[6]
	RealmSEA          = Realms[7]
	RealmUnknown      = Realms[8]
)
type Region struct {
	Enum
	Code      string       
	DepotURL  *url.URL     
	BnetURL   *url.URL     
	Realms    []*Realm     
	BnetLangs []*BnetLang  
}
var Regions = []*Region{
	{Enum{"Unknown"}, "", mustPU("http://unknown.depot.battle.net:1119/"), mustPU("http://unknown.battle.net/"),
		[]*Realm{},
		[]*BnetLang{BnetLangEnglish}},
	{Enum{"US"}, "US", mustPU("https://us-s2-depot.classic.blizzard.com/"), mustPU("http://us.battle.net/"),
		[]*Realm{RealmNorthAmerica, RealmLatinAmerica},
		[]*BnetLang{BnetLangEnglish, BnetLangSpanish, BnetLangPortuguese}},
	{Enum{"Europe"}, "EU", mustPU("https://eu-s2-depot.classic.blizzard.com/"), mustPU("http://eu.battle.net/"),
		[]*Realm{RealmEurope, RealmRussia},
		[]*BnetLang{BnetLangEnglish, BnetLangGerman, BnetLangFrench, BnetLangSpanish, BnetLangRussian, BnetLangItalian, BnetLangPolish}},
	{Enum{"Korea"}, "KR", mustPU("https://kr-s2-depot.classic.blizzard.com/"), mustPU("http://kr.battle.net/"),
		[]*Realm{RealmKorea, RealmTaiwan},
		[]*BnetLang{BnetLangKorean, BnetLangChineseTraditional}},
	{Enum{"SEA"}, "SG", mustPU("http://sg.depot.battle.net:1119/"), mustPU("http://sea.battle.net/"),
		[]*Realm{RealmSEA},
		[]*BnetLang{BnetLangEnglish}},
	{Enum{"China"}, "CN", mustPU("http://cn-s2-depot.battlenet.com.cn/"), mustPU("http://www.battlenet.com.cn/"),
		[]*Realm{RealmChina},
		[]*BnetLang{BnetLangChineseTraditional}},
	{Enum{"Public Test"}, "XX", mustPU("http://xx.depot.battle.net:1119/"), mustPU("http://us.battle.net/"),
		[]*Realm{},
		[]*BnetLang{BnetLangEnglish}},
	{Enum{"Public Test"}, "XX", mustPU("http://xx.depot.battle.net:1119/"), mustPU("http://us.battle.net/"),
		[]*Realm{},
		[]*BnetLang{BnetLangEnglish}},
}
func mustPU(rawurl string) *url.URL {
	if u, err := url.Parse(rawurl); err != nil {
		panic(err)
	} else {
		return u
	}
}
func (r *Region) Realm(realmID int64) *Realm {
	if id := int(realmID) - 1; id >= 0 && id < len(r.Realms) {
		return r.Realms[id]
	}
	return RealmUnknown
}
var (
	RegionUnknown     = Regions[0]
	RegionUS          = Regions[1]
	RegionEU          = Regions[2]
	RegionKR          = Regions[3]
	RegionSEA         = Regions[4]
	RegionCN          = Regions[5]
	RegionPublicTest  = Regions[6]
	RegionPublicTest2 = Regions[7]
)
var regionMap = make(map[string]*Region)
func init() {
	for _, r := range Regions {
		regionMap[r.Code] = r
	}
}
func regionByCode(code string) *Region {
	if r, ok := regionMap[code]; ok {
		return r
	}
	return RegionUnknown
}
func regionByID(regionID int64) *Region {
	if id := int(regionID); id >= 0 && id < len(Regions) {
		return Regions[id]
	}
	return RegionUnknown
}
type ExpLevel struct {
	Enum
	FullName string  
	Digest   string  
}
var ExpLevels = []*ExpLevel{
	{Enum{"LotV"}, "Legacy of the Void", "d92dfc48c484c59154270b924ad7d57484f2ab9a47621c7ab16431bf66c53b40"},
	{Enum{"HotS"}, "Heart of the Swarm", "66093832128453efffbb787c80b7d3eec1ad81bde55c83c930dea79c4e505a04"},
	{Enum{"WoL"}, "Wings of Liberty", "421c8aa0f3619b652d23a2735dfee812ab644228235e7a797edecfe8b67da30e"},
	{Enum{"Unknown"}, "Unknown", ""},
}
var (
	ExpLevelLotV    = ExpLevels[0]
	ExpLevelHotS    = ExpLevels[1]
	ExpLevelWoL     = ExpLevels[2]
	ExpLevelUnknown = ExpLevels[3]
)
type CacheHandle struct {
	Type   string   
	Region *Region  
	Digest string   
}