B站大会员影视+弹幕+字幕

B站观影 弹幕 字幕替换 弹幕获取 历史弹幕

// ==UserScript==
// @name         B站大会员影视+弹幕+字幕
// @namespace    http://tampermonkey.net/
// @version      2.5
// @description  B站观影 弹幕 字幕替换 弹幕获取 历史弹幕
// @author       Polygon
// @include      https://www.bilibili.com/bangumi/play/*
// @include      https://www.bilibili.com/video/BV*
// @include      https://jx.parwix.com*
// @include      https://lecurl.cn*
// @grant        GM_xmlhttpRequest
// @grant        unsafeWindow
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_addStyle
// @run-at       document-start
// @connect      *
// ==/UserScript==

const origin = [
    { regex: 'barrage', api: 'https://lecurl.cn/?url=', color: '#0a7353' },
    { regex: 'dmku', api: 'https://vip.parwix.com:4433/player/?url=', color: '#ff6429' }
]

const bangumi = location.href.search('bangumi') !== -1

if (!document.URL.startsWith('https://www.bilibili.com/')) {
    console.log('开启拦截')
    let danmu = GM_getValue('danmu')
    ;(function(open) {
        XMLHttpRequest.prototype.open = function(method, url) {
            console.log(method, url)
            let match = false
            for (let i = 0; i < origin.length; i++) {
                if (url.search(origin[i].regex) !== -1) {
                    match = true
                    break
                }
            }
            if ((method == 'GET')&&match) {
                setupHook(this);
            }
            open.apply(this, arguments);
        }
    })(XMLHttpRequest.prototype.open);
    function setupHook(xhr) {
        function setup() {
            Object.defineProperty(xhr, "response", {
                get: function() {
                    return danmu;
                },
                configurable: true
            });
            Object.defineProperty(xhr, "responseText", {
                get: function() {
                    return JSON.stringify(danmu);
                },
                configurable: true
            });
            console.log(xhr)
        }
        setup();
    }
}

async function dataQuery() {
    var cid, aid
    if (document.URL.startsWith('https://www.bilibili.com/')) {
        // 网页加载完后在bili网站获取cid,aid,并储存
        (function () {
            if (unsafeWindow.cid == undefined) {
                cid = unsafeWindow.__INITIAL_STATE__.epInfo.cid
                console.log('cid=' + cid)
                GM_setValue('cid', cid)
            } else {
                cid = unsafeWindow.cid
                console.log('cid=' + cid)
                GM_setValue('cid', cid)
            }
            if (unsafeWindow.aid == undefined) {
                aid = unsafeWindow.__INITIAL_STATE__.epInfo.aid
                console.log('aid=' + aid)
                GM_setValue('aid', aid)
            } else {
                aid = unsafeWindow.aid
                console.log('aid=' + aid)
                GM_setValue('aid', aid)
            }
        })()
        if (!bangumi) { return }
        var danmu = { code: 23, msg: "success", dannum: 0, danmuku: [], name: cid }
        // 字幕查询
        let subtitleApi = 'https://api.bilibili.com/x/player/v2?'
        let season_id = document.querySelector("meta[property='og:url']").content.match(/ss(\d+)/g)[0].replace('ss', '')
        let params = ['aid=' + aid, 'cid=' + cid, 'season_id=' + season_id]
        let subtitleUrl = await fetch(subtitleApi + params.join('&'), { credentials: 'include' })
            .then(res => res.json())
            .then(res => {
                console.log(res)
                if (!res['data']['subtitle']['subtitles'].length) {
                    console.log('未发现字幕'); return ''
                } else {
                    console.log(res)
                    try {
                        let index = (res['data']['subtitle']['subtitles'][0]['lan_doc'].search('简体') !== -1) ? 0 : 1
                        let url = 'https:' + res['data']['subtitle']['subtitles'][index]['subtitle_url']
                        console.log(`发现字幕 [${res['data']['subtitle']['subtitles'][index]['lan_doc']}]- ` + url)
                        return url
                    } catch {
                        return null
                    }
                }
            })
        var subtitleArray = []
        if (subtitleUrl) {
            subtitleArray = await fetch(subtitleUrl)
                .then(res => res.json())
                .then(res => res.body)
        }
        GM_setValue('subtitleArray', subtitleArray)
        // 弹幕
        let danmuApi = `https://api.bilibili.com/x/v1/dm/list.so?oid=${cid}`
        console.log('当前弹幕接口=' + danmuApi)
        danmu = await fetch(danmuApi, { credentials: 'include' })
            .then(res => res.text())
            .then(restxt => {
                let matchObj = restxt.match(/<d p=".+?">.+?<\/d>/g)
                matchObj.forEach(ele => {
                    let r = /<d p="(.+?)">(.+?)<\/d>/g.exec(ele)
                    let params = r[1].split(',')
                    let content = r[2]
                    let time = params[0]
                    let direction = parseInt(params[1])
                    let fontsize = params[2]
                    let color = '#' + parseInt(params[3]).toString(16)
                    let direction_info
                    if (direction <= 3) {
                        direction_info = 'right'
                    } else if (direction == 4) {
                        direction_info = 'bottom'
                    } else if (direction == 5) {
                        direction_info = 'top'
                    } else {
                        direction_info = 'right'
                    }
                    danmu.danmuku.push([time, direction_info, color, "", content, "", "", `${fontsize}px`])
                })
                danmu.danmuku.push(["0", 'top', '#FF616D', "", `替换弹幕源成功,前方共有${danmu.danmuku.length}条弹幕,请做好准备哟`, "", "", "25px"])
                danmu.dannum = danmu.danmuku.length
                return danmu
            })
        GM_setValue('danmu', danmu)
        console.log(danmu)
        console.log(danmu.length)
    }
}

function pageChange() {
    clear()
    if (!bangumi) { return }
    // 添加按钮和frame
    let parentId = '#toolbar_module'
    // 字幕 参考 <bilibili外挂字幕 哔哩哔哩外挂字幕>
    // https://raw.githubusercontent.com/jonwinters/bilibili-subtitles-plugin/master/build.dist.js
    let addSubtitle = () => {
        if (document.URL.startsWith('https://www.bilibili.com/')) { return }
        let subtitles = GM_getValue('subtitleArray')
        window.startTime = 0
        window.endTime = 0
        window.fontsize = 20
        if (!subtitles.length) { return }
        subtitles.unshift({ content: '字幕加载成功[简体中文]', from: 0, location: 2, to: 0.5 })
        // 00:00
        let percentNode = document.querySelector("[class*='player-played']")
        let totalTime = document.querySelector("[class*='player-dtime']")
        let subtitleNode = document.querySelector("div[class*='player-subtitle']")
        if (!(percentNode && totalTime && subtitleNode)) { return }
        console.log(subtitles)
        // 把小时 分钟 秒解析为秒
        let toSecond = timeStr => {
            let timeArr = timeStr.split(':')
            let timeSec = 0
            for (let i = 0; i < timeArr.length; i++) {
                timeSec += 60 ** (timeArr.length - i - 1) * parseInt(timeArr[i])
            }
            return timeSec
        }
        let totalSec = toSecond(totalTime.textContent)
        let insertSubtitle = function (mutationsList, observer) {
            // 00:00:00 => 秒
            let timeSec = totalSec * parseFloat(percentNode.style.width.replace('%', '')) / 100
            // 保护时间,防止重复
            if (timeSec > window.endTime || timeSec < window.startTime) {
                // 此时用户可能在拖动进度条,反之拖动后重叠,清空subtitleNode
                subtitleNode.innerHTML = ""
            }
            // console.log(timeSec)
            // 快速查找
            let binarySearch = function (target, arr) {
                var from = 0;
                var to = arr.length - 1;
                while (from <= to) {
                    var mid = parseInt(from + (to - from) / 2);
                    if (target >= arr[mid].from && target <= arr[mid].to) {
                        return mid
                    } else if (target > arr[mid].to) {
                        from = mid + 1;
                    } else {
                        to = mid - 1;
                    }
                }
                return -1;
            }
            var index = binarySearch(timeSec, subtitles)
            if (index == -1) { return }
            // 两个解析播放器都支持这个div,应该是基于一套模板
            //<div class="leleplayer-subtitle yzmplayer-subtitle" >替换弹幕源成功,前方共有223条弹幕,请做好准备哟</div>
            let oneSubtitle = subtitles[index]
            if (oneSubtitle.content == window.currentSubtitle && subtitleNode.children.length) { return }
            let subtitleDiv = document.createElement('div')
            subtitleDiv.setAttribute('class', 'leleplayer-subtitle yzmplayer-subtitle player-subtitle .leleplayer-danmaku')
            // 此处可以自定义一些东西 这里是字幕背景色与bilibili一致
            let customStyle = 'background-color: rgba(0, 0, 0, 0.4)'
            subtitleDiv.innerHTML = `<span style='${customStyle}'>${oneSubtitle.content}</span>`
            let duration = oneSubtitle.to - oneSubtitle.from - (timeSec - oneSubtitle.from)
            subtitleNode.appendChild(subtitleDiv)
            let offsetStyle = `bottom: ${30 * (parseInt(oneSubtitle.from) < window.endTime - 1 && mutationsList && observer)}px; font-size: ${window.fontsize}px;`
            subtitleDiv.style = `animation: danmaku-center ${duration}s linear;visibility: hidden; ${offsetStyle}`
            // 记录结束时间
            window.endTime = parseFloat(oneSubtitle.to)
            window.startTime = parseFloat(oneSubtitle.from)
            window.currentSubtitle = oneSubtitle.content
        }
        var config = {
            attributes: true,
            childList: true,
            subtree: true
        }
        var observer = new MutationObserver(insertSubtitle)
        observer.observe(percentNode, config)
        // 暂停播放事件
        document.querySelector('#player').addEventListener('click', () => {
            let timeSec = totalSec * parseFloat(percentNode.style.width.replace('%', '')) / 100
            if (document.querySelector('#player').className.search('playing') !== -1) {
                // 播放状态
                if (timeSec < window.endTime) {
                    subtitleNode.innerHTML = ""
                    insertSubtitle(null, null)
                }
            } else {
                // 暂停状态
                if (timeSec < window.endTime) {
                    if (subtitleNode.lastChild) { (subtitleNode.lastChild.style.visibility = 'visible') }
                }
            }
        })
        document.addEventListener('fullscreenchange', () => {
            window.fontsize = (window.fontsize == 20) ? 40 : 20
            subtitleNode.lastChild.style['font-size'] = window.fontsize + 'px'
        })
    }
    let addButton = () => {
        // 切换
        if (!document.URL.startsWith('https://www.bilibili.com/')) { return }
        let ele = document.querySelector(parentId)
        let switchButton = document.createElement("div")
        switchButton.setAttribute('class', 'share-info')
        switchButton.setAttribute('id', 'switch')
        switchButton.innerHTML = '<i class="iconfont"></i><span style="background-color: #FB7299; border: 1px solid #FB7299; color: #fff; border-radius: 16px; text-align: center;">切换</span> <!---->'
        removeAllNode('switch')
        ele.appendChild(switchButton)
        let modules = document.querySelectorAll('.player-module')
        switchButton.addEventListener('click', function () {
            let activateIndex
            for (let i = 0; i < modules.length; i++) {
                if (modules[i].style.display == 'block') {
                    activateIndex = i
                    modules[i].style.display = 'none'
                    break
                }
            }
            let nextIndex = (activateIndex < modules.length - 1) ? activateIndex + 1 : 0
            modules[nextIndex].style.display = 'block'
            // 按钮颜色
            let color
            if (nextIndex == 0) {
                color = '#fb7299'
            } else {
                color = origin[nextIndex - 1].color
            }
            switchButton.querySelector('span').style['background-color'] = color
            switchButton.querySelector('span').style['border-color'] = color
        })
        $(switchButton).hover(function () {
            let gray = '#757575'
            switchButton.querySelector('span').style['background-color'] = gray
            switchButton.querySelector('span').style['border-color'] = gray
        }, function () {
            let activateIndex, color
            for (let i = 0; i < modules.length; i++) {
                if (modules[i].style.display == 'block') {
                    activateIndex = i
                    break
                }
            }
            if (activateIndex == 0) {
                color = '#fb7299'
            } else {
                color = origin[activateIndex - 1].color
            }
            switchButton.querySelector('span').style['background-color'] = color
            switchButton.querySelector('span').style['border-color'] = color
        })
    }
    let addFrame = (index) => {
        if (!document.URL.startsWith('https://www.bilibili.com/')) { return }
        // 防止匹配到解析网址,控制台会输出错误
        if (!document.URL.startsWith('https://www.bilibili.com/')) return
        let biliDiv = document.querySelector('#player_module')
        biliDiv.style.display = 'block'
        // 创建新player_module
        let diyDiv = biliDiv.cloneNode(true)
        diyDiv.style['padding-left'] = '0px'
        diyDiv.style['margin-left'] = '0px'
        diyDiv.style.display = 'none'
        diyDiv.innerHTML = ""
        diyDiv.setAttribute('id', `diy_module_${index}`)
        let iframe = document.createElement("iframe")
        iframe.id = 'video-iframe'
        iframe.style.height = biliDiv.style.height
        diyDiv.append(iframe)
        let read_url = location.href
        iframe.src = origin[index].api + read_url
        console.log(iframe.src)
        if (document.body.className.includes('player-mode-widescreen')) {
            iframe.style.position = 'absolute'
            iframe.style.top = '0px'
        }
        iframe.height = '0%'
        iframe.width = '100%'
        iframe.setAttribute('frameborder', 'no')
        iframe.setAttribute('border', '0')
        iframe.setAttribute('allowfullscreen', 'allowfullscreen')
        iframe.setAttribute('webkitallowfullscreen', 'webkitallowfullscreen')
        document.querySelector('.plp-l').insertBefore(diyDiv, document.querySelector('.media-wrapper'))
    }
    let init = () => {
        // 将所源作为frmae添加到页面
        for (let i = 0; i < origin.length; i++) {
            addFrame(i)
        }
        // 设置button
        addSubtitle()
        addButton()
    }
    setTimeout(init, 800)
    // 这里延迟可以避免频繁刷新
    setTimeout(() => {
        let obs = document.querySelector('head title')
        if (obs) {
            new MutationObserver(function (mutations, observer) {
                location.reload()
            }).observe(obs, { childList: true })
        }
    }, 500)
}

function changeMonth(message, downloadBtn) {
    let currentYear = parseInt(document.querySelector('#danmuYear').textContent)
    let currentMonth = parseInt(document.querySelector('#danmuMonth').textContent)
    let now = new Date()
    if (isNaN(currentYear) || isNaN(currentMonth)) {
        currentYear = now.getFullYear()
        currentMonth = now.getMonth()
    }
    console.log(this.getAttribute('class'))
    switch (this.getAttribute('class')) {
        case 'next-month':
            // 下个月
            if (now.getFullYear() == currentYear && currentMonth == now.getMonth() + 1) { break }
            currentYear = (currentMonth == 12) ? currentYear + 1 : currentYear
            currentMonth = (currentMonth == 12) ? 1 : currentMonth + 1
            break
        case 'last-month':
            // 上个月
            currentYear = (currentMonth == 1) ? currentYear - 1 : currentYear
            currentMonth = (currentMonth == 1) ? 12 : currentMonth - 1
            break
    }
    // 重新赋值
    document.querySelector('#danmuYear').innerHTML = currentYear
    document.querySelector('#danmuMonth').innerHTML = currentMonth
    // 清空原有day
    let dayBox = document.querySelector('.day')
    dayBox.innerHTML = ""
    let weekStart = new Date(currentYear, currentMonth - 1, 1).getDay()
    let dayEnd = new Date(currentYear, currentMonth, 0).getDate()
    console.log(weekStart, dayEnd)
    let cursor = 0, day = 1
    let htmSTr = ""
    while (cursor < 42) {
        if (cursor < weekStart) {
            htmSTr += '<span class="which-day"></span>'
        } else {
            if (day <= dayEnd) {
                htmSTr += `<span class="which-day" day="${day}">${day}</span>`
                day++
            } else {
                htmSTr += '<span class="which-day"></span>'
            }
        }
        cursor++
    }
    dayBox.innerHTML = htmSTr
    // 查找支持
    let dayQuery = async (year, month) => {
        let cid = GM_getValue('cid')
        // 以当前时间向前查找
        let dateStr, api, data
        dateStr = `${year}-${(month >= 10) ? month : '0' + month}`
        api = `https://api.bilibili.com/x/v2/dm/history/index?month=${dateStr}&type=1&oid=${cid}`
        console.log(api)
        data = await fetch(api, { credentials: 'include' })
            .then(e => e.json())
            .then(res => res.data)
        if (data !== null) {
            console.log(data)
            return data
        } else {
            return []
        }
    }
    dayQuery(currentYear, currentMonth).then(supportDay => {
        supportDay.forEach((date) => {
            let day = parseInt(date.split('-')[2])
            let dayNode = document.querySelector(`.which-day[day="${day}"]`)
            dayNode.classList.add("support")
            dayNode.onclick = function () {
                if (this.classList.contains('active')) {
                    this.classList.remove('active')
                } else {
                    let days = document.querySelectorAll('.which-day.support')
                    days.forEach((day) => {
                        day.classList.contains('active') && day.classList.remove('active')
                    })
                    this.classList.add('active')
                }
                danmuDownload(message, downloadBtn)
            }
        })
    })
}

let danmuDownload = (message, downloadBtn) => {
    if (!document.URL.startsWith('https://www.bilibili.com/')) { return }
    // 搭建的自动解析protobuf为xml接口
    let xmlApi, date = null
    let protobufApi = 'https://api.bilibili.com/x/v2/dm/web/history/seg.so?type=1'
    let cid = GM_getValue('cid')
    // 获取日期
    let year = document.querySelector('#danmuYear').textContent
    let month = document.querySelector('#danmuMonth').textContent
    let day = document.querySelector('.which-day.support.active')
    if (day) { date = [year, ((parseInt(month) < 10) ? '0' : '') + month, ((parseInt(day.textContent) < 10) ? '0' : '') + day.textContent].join('-') }
    if (date) {
        protobufApi += `&oid=${cid}&date=${date}`
        console.log(protobufApi)
    } else {
        date = 'allTime'
        xmlApi = `https://api.bilibili.com/x/v1/dm/list.so?oid=${cid}`
    }
    // js实现解析protobuf文件
    let xmlPromise
    if (xmlApi) {
        xmlPromise = fetch(xmlApi, { credentials: 'include' })
            .then(e => {
                console.log(e)
                return e.text()
            })
    } else {
        xmlPromise = fetch(protobufApi, { credentials: 'include' })
            .then(e => e.arrayBuffer())
            .then(data => {
                let r = message.decode(new Uint8Array(data))
                let o = message.toObject(r)
                console.log(o)
                return o
            })
            .then(o => {
                let eles = o.elems
                let xmlTagsStr = ''
                for (let i = 0; i < eles.length; i++) {
                    let ele = eles[i]
                    // 特别处理
                    let progress = parseFloat(ele.progress) / 1000
                    let content = ele.content.replace('<', '&lt;').replace('>', '&gt;').replace('&', '&amp;').replace("'", '&apos;').replace('"', '&quot;')
                    xmlTagsStr += `<d p="${progress},${ele.mode},${ele.fontsize},${ele.color},${ele.ctime},0,${ele.midHash},${ele.id}">${content}</d>`
                }
                let xmlStr = `<?xml version="1.0" encoding="UTF-8"?><i><chatserver>chat.bilibili.com</chatserver><chatid></chatid><mission>0</mission><maxlimit>${eles.length}</maxlimit><state>0</state><real_name>0</real_name><source>k-v</source>${xmlTagsStr}</i>`
                return xmlStr
            })
    }
    xmlPromise.then(s => {
        downloadBtn.setAttribute('download', document.title.split('_')[0] + ' ' + date + '.xml')
        downloadBtn.setAttribute('href', URL.createObjectURL(new Blob([s])))
    })
}

let removeAllNode = (id) => {
    let Nodes = document.querySelectorAll(`[id^=${id}]`)
    for (let i = 0; i < Nodes.length; i++) {
        Nodes[i].remove()
    }
}

let clear = () => {
    removeAllNode('danmuDownloadBox')
    removeAllNode('switch')
    removeAllNode('diy_module_')
}
// 引入protobuf
if (document.URL.startsWith('https://www.bilibili.com/')) {
    !function (Q) { "use strict"; var r, e, t, i; r = { 1: [function (t, i, n) { i.exports = function (t, i) { var n = Array(arguments.length - 1), s = 0, r = 2, o = !0; for (; r < arguments.length;)n[s++] = arguments[r++]; return new Promise(function (r, e) { n[s] = function (t) { if (o) if (o = !1, t) e(t); else { for (var i = Array(arguments.length - 1), n = 0; n < i.length;)i[n++] = arguments[n]; r.apply(null, i) } }; try { t.apply(i || null, n) } catch (t) { o && (o = !1, e(t)) } }) } }, {}], 2: [function (t, i, n) { n.length = function (t) { var i = t.length; if (!i) return 0; for (var n = 0; 1 < --i % 4 && "=" == (t[0 | i] || "");)++n; return Math.ceil(3 * t.length) / 4 - n }; for (var h = Array(64), f = Array(123), r = 0; r < 64;)f[h[r] = r < 26 ? r + 65 : r < 52 ? r + 71 : r < 62 ? r - 4 : r - 59 | 43] = r++; n.encode = function (t, i, n) { for (var r, e = null, s = [], o = 0, u = 0; i < n;) { var f = t[i++]; switch (u) { case 0: s[o++] = h[f >> 2], r = (3 & f) << 4, u = 1; break; case 1: s[o++] = h[r | f >> 4], r = (15 & f) << 2, u = 2; break; case 2: s[o++] = h[r | f >> 6], s[o++] = h[63 & f], u = 0 }8191 < o && ((e = e || []).push(String.fromCharCode.apply(String, s)), o = 0) } return u && (s[o++] = h[r], s[o++] = 61, 1 === u && (s[o++] = 61)), e ? (o && e.push(String.fromCharCode.apply(String, s.slice(0, o))), e.join("")) : String.fromCharCode.apply(String, s.slice(0, o)) }; var a = "invalid encoding"; n.decode = function (t, i, n) { for (var r, e = n, s = 0, o = 0; o < t.length;) { var u = t.charCodeAt(o++); if (61 == u && 1 < s) break; if ((u = f[u]) === Q) throw Error(a); switch (s) { case 0: r = u, s = 1; break; case 1: i[n++] = r << 2 | (48 & u) >> 4, r = u, s = 2; break; case 2: i[n++] = (15 & r) << 4 | (60 & u) >> 2, r = u, s = 3; break; case 3: i[n++] = (3 & r) << 6 | u, s = 0 } } if (1 === s) throw Error(a); return n - e }, n.test = function (t) { return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t) } }, {}], 3: [function (t, i, n) { function c(i, n) { "string" == typeof i && (n = i, i = Q); var f = []; function h(t) { if ("string" != typeof t) { var i = a(); if (c.verbose && console.log("codegen: " + i), i = "return " + i, t) { for (var n = Object.keys(t), r = Array(n.length + 1), e = Array(n.length), s = 0; s < n.length;)r[s] = n[s], e[s] = t[n[s++]]; return r[s] = i, Function.apply(null, r).apply(null, e) } return Function(i)() } for (var o = Array(arguments.length - 1), u = 0; u < o.length;)o[u] = arguments[++u]; if (u = 0, t = t.replace(/%([%dfijs])/g, function (t, i) { var n = o[u++]; switch (i) { case "d": case "f": return "" + +("" + n); case "i": return "" + Math.floor(n); case "j": return JSON.stringify(n); case "s": return "" + n }return "%" }), u !== o.length) throw Error("parameter count mismatch"); return f.push(t), h } function a(t) { return "function " + (t || n || "") + "(" + (i && i.join(",") || "") + "){\n  " + f.join("\n  ") + "\n}" } return h.toString = a, h } (i.exports = c).verbose = !1 }, {}], 4: [function (t, i, n) { function r() { this.i = {} } (i.exports = r).prototype.on = function (t, i, n) { return (this.i[t] || (this.i[t] = [])).push({ fn: i, ctx: n || this }), this }, r.prototype.off = function (t, i) { if (t === Q) this.i = {}; else if (i === Q) this.i[t] = []; else for (var n = this.i[t], r = 0; r < n.length;)n[r].fn === i ? n.splice(r, 1) : ++r; return this }, r.prototype.emit = function (t) { var i = this.i[t]; if (i) { for (var n = [], r = 1; r < arguments.length;)n.push(arguments[r++]); for (r = 0; r < i.length;)i[r].fn.apply(i[r++].ctx, n) } return this } }, {}], 5: [function (t, i, n) { i.exports = u; var s = t(1), o = t(7)("fs"); function u(n, r, e) { return r = "function" == typeof r ? (e = r, {}) : r || {}, e ? !r.xhr && o && o.readFile ? o.readFile(n, function (t, i) { return t && "undefined" != typeof XMLHttpRequest ? u.xhr(n, r, e) : t ? e(t) : e(null, r.binary ? i : i.toString("utf8")) }) : u.xhr(n, r, e) : s(u, this, n, r) } u.xhr = function (t, n, r) { var e = new XMLHttpRequest; e.onreadystatechange = function () { if (4 !== e.readyState) return Q; if (0 !== e.status && 200 !== e.status) return r(Error("status " + e.status)); if (n.binary) { if (!(t = e.response)) for (var t = [], i = 0; i < e.responseText.length; ++i)t.push(255 & e.responseText.charCodeAt(i)); return r(null, "undefined" != typeof Uint8Array ? new Uint8Array(t) : t) } return r(null, e.responseText) }, n.binary && ("overrideMimeType" in e && e.overrideMimeType("text/plain; charset=x-user-defined"), e.responseType = "arraybuffer"), e.open("GET", t), e.send() } }, { 1: 1, 7: 7 }], 6: [function (t, i, n) { function r(t) { function i(t, i, n, r) { var e = i < 0 ? 1 : 0; t(0 === (i = e ? -i : i) ? 0 < 1 / i ? 0 : 2147483648 : isNaN(i) ? 2143289344 : 34028234663852886e22 < i ? (e << 31 | 2139095040) >>> 0 : i < 11754943508222875e-54 ? (e << 31 | Math.round(i / 1401298464324817e-60)) >>> 0 : (e << 31 | 127 + (e = Math.floor(Math.log(i) / Math.LN2)) << 23 | 8388607 & Math.round(i * Math.pow(2, -e) * 8388608)) >>> 0, n, r) } function n(t, i, n) { t = t(i, n), i = 2 * (t >> 31) + 1, n = t >>> 23 & 255, t &= 8388607; return 255 == n ? t ? NaN : 1 / 0 * i : 0 == n ? 1401298464324817e-60 * i * t : i * Math.pow(2, n - 150) * (8388608 + t) } function r(t, i, n) { u[0] = t, i[n] = f[0], i[n + 1] = f[1], i[n + 2] = f[2], i[n + 3] = f[3] } function e(t, i, n) { u[0] = t, i[n] = f[3], i[n + 1] = f[2], i[n + 2] = f[1], i[n + 3] = f[0] } function s(t, i) { return f[0] = t[i], f[1] = t[i + 1], f[2] = t[i + 2], f[3] = t[i + 3], u[0] } function o(t, i) { return f[3] = t[i], f[2] = t[i + 1], f[1] = t[i + 2], f[0] = t[i + 3], u[0] } var u, f, h, a, c; function l(t, i, n, r, e, s) { var o, u = r < 0 ? 1 : 0; 0 === (r = u ? -r : r) ? (t(0, e, s + i), t(0 < 1 / r ? 0 : 2147483648, e, s + n)) : isNaN(r) ? (t(0, e, s + i), t(2146959360, e, s + n)) : 17976931348623157e292 < r ? (t(0, e, s + i), t((u << 31 | 2146435072) >>> 0, e, s + n)) : r < 22250738585072014e-324 ? (t((o = r / 5e-324) >>> 0, e, s + i), t((u << 31 | o / 4294967296) >>> 0, e, s + n)) : (t(4503599627370496 * (o = r * Math.pow(2, -(r = 1024 === (r = Math.floor(Math.log(r) / Math.LN2)) ? 1023 : r))) >>> 0, e, s + i), t((u << 31 | r + 1023 << 20 | 1048576 * o & 1048575) >>> 0, e, s + n)) } function v(t, i, n, r, e) { i = t(r, e + i), r = t(r, e + n), e = 2 * (r >> 31) + 1, n = r >>> 20 & 2047, i = 4294967296 * (1048575 & r) + i; return 2047 == n ? i ? NaN : 1 / 0 * e : 0 == n ? 5e-324 * e * i : e * Math.pow(2, n - 1075) * (i + 4503599627370496) } function d(t, i, n) { h[0] = t, i[n] = a[0], i[n + 1] = a[1], i[n + 2] = a[2], i[n + 3] = a[3], i[n + 4] = a[4], i[n + 5] = a[5], i[n + 6] = a[6], i[n + 7] = a[7] } function p(t, i, n) { h[0] = t, i[n] = a[7], i[n + 1] = a[6], i[n + 2] = a[5], i[n + 3] = a[4], i[n + 4] = a[3], i[n + 5] = a[2], i[n + 6] = a[1], i[n + 7] = a[0] } function b(t, i) { return a[0] = t[i], a[1] = t[i + 1], a[2] = t[i + 2], a[3] = t[i + 3], a[4] = t[i + 4], a[5] = t[i + 5], a[6] = t[i + 6], a[7] = t[i + 7], h[0] } function w(t, i) { return a[7] = t[i], a[6] = t[i + 1], a[5] = t[i + 2], a[4] = t[i + 3], a[3] = t[i + 4], a[2] = t[i + 5], a[1] = t[i + 6], a[0] = t[i + 7], h[0] } return "undefined" != typeof Float32Array ? (u = new Float32Array([-0]), f = new Uint8Array(u.buffer), c = 128 === f[3], t.writeFloatLE = c ? r : e, t.writeFloatBE = c ? e : r, t.readFloatLE = c ? s : o, t.readFloatBE = c ? o : s) : (t.writeFloatLE = i.bind(null, y), t.writeFloatBE = i.bind(null, m), t.readFloatLE = n.bind(null, g), t.readFloatBE = n.bind(null, j)), "undefined" != typeof Float64Array ? (h = new Float64Array([-0]), a = new Uint8Array(h.buffer), c = 128 === a[7], t.writeDoubleLE = c ? d : p, t.writeDoubleBE = c ? p : d, t.readDoubleLE = c ? b : w, t.readDoubleBE = c ? w : b) : (t.writeDoubleLE = l.bind(null, y, 0, 4), t.writeDoubleBE = l.bind(null, m, 4, 0), t.readDoubleLE = v.bind(null, g, 0, 4), t.readDoubleBE = v.bind(null, j, 4, 0)), t } function y(t, i, n) { i[n] = 255 & t, i[n + 1] = t >>> 8 & 255, i[n + 2] = t >>> 16 & 255, i[n + 3] = t >>> 24 } function m(t, i, n) { i[n] = t >>> 24, i[n + 1] = t >>> 16 & 255, i[n + 2] = t >>> 8 & 255, i[n + 3] = 255 & t } function g(t, i) { return (t[i] | t[i + 1] << 8 | t[i + 2] << 16 | t[i + 3] << 24) >>> 0 } function j(t, i) { return (t[i] << 24 | t[i + 1] << 16 | t[i + 2] << 8 | t[i + 3]) >>> 0 } i.exports = r(r) }, {}], 7: [function (t, i, n) { function r(t) { try { var i = eval("require")(t); if (i && (i.length || Object.keys(i).length)) return i } catch (t) { } return null } i.exports = r }, {}], 8: [function (t, i, n) { var n = n, e = n.isAbsolute = function (t) { return /^(?:\/|\w+:)/.test(t) }, r = n.normalize = function (t) { var i = (t = t.replace(/\\/g, "/").replace(/\/{2,}/g, "/")).split("/"), n = e(t), t = ""; n && (t = i.shift() + "/"); for (var r = 0; r < i.length;)".." === i[r] ? 0 < r && ".." !== i[r - 1] ? i.splice(--r, 2) : n ? i.splice(r, 1) : ++r : "." === i[r] ? i.splice(r, 1) : ++r; return t + i.join("/") }; n.resolve = function (t, i, n) { return n || (i = r(i)), !e(i) && (t = (t = !n ? r(t) : t).replace(/(?:\/|^)[^/]+$/, "")).length ? r(t + "/" + i) : i } }, {}], 9: [function (t, i, n) { i.exports = function (i, n, t) { var r = t || 8192, e = r >>> 1, s = null, o = r; return function (t) { if (t < 1 || e < t) return i(t); r < o + t && (s = i(r), o = 0); t = n.call(s, o, o += t); return 7 & o && (o = 1 + (7 | o)), t } } }, {}], 10: [function (t, i, n) { n.length = function (t) { for (var i, n = 0, r = 0; r < t.length; ++r)(i = t.charCodeAt(r)) < 128 ? n += 1 : i < 2048 ? n += 2 : 55296 == (64512 & i) && 56320 == (64512 & t.charCodeAt(r + 1)) ? (++r, n += 4) : n += 3; return n }, n.read = function (t, i, n) { if (n - i < 1) return ""; for (var r, e = null, s = [], o = 0; i < n;)(r = t[i++]) < 128 ? s[o++] = r : 191 < r && r < 224 ? s[o++] = (31 & r) << 6 | 63 & t[i++] : 239 < r && r < 365 ? (r = ((7 & r) << 18 | (63 & t[i++]) << 12 | (63 & t[i++]) << 6 | 63 & t[i++]) - 65536, s[o++] = 55296 + (r >> 10), s[o++] = 56320 + (1023 & r)) : s[o++] = (15 & r) << 12 | (63 & t[i++]) << 6 | 63 & t[i++], 8191 < o && ((e = e || []).push(String.fromCharCode.apply(String, s)), o = 0); return e ? (o && e.push(String.fromCharCode.apply(String, s.slice(0, o))), e.join("")) : String.fromCharCode.apply(String, s.slice(0, o)) }, n.write = function (t, i, n) { for (var r, e, s = n, o = 0; o < t.length; ++o)(r = t.charCodeAt(o)) < 128 ? i[n++] = r : (r < 2048 ? i[n++] = r >> 6 | 192 : (55296 == (64512 & r) && 56320 == (64512 & (e = t.charCodeAt(o + 1))) ? (++o, i[n++] = (r = 65536 + ((1023 & r) << 10) + (1023 & e)) >> 18 | 240, i[n++] = r >> 12 & 63 | 128) : i[n++] = r >> 12 | 224, i[n++] = r >> 6 & 63 | 128), i[n++] = 63 & r | 128); return n - s } }, {}], 11: [function (t, i, n) { i.exports = e; var r = /\/|\./; function e(t, i) { r.test(t) || (t = "google/protobuf/" + t + ".proto", i = { nested: { google: { nested: { protobuf: { nested: i } } } } }), e[t] = i } e("any", { Any: { fields: { type_url: { type: "string", id: 1 }, value: { type: "bytes", id: 2 } } } }), e("duration", { Duration: i = { fields: { seconds: { type: "int64", id: 1 }, nanos: { type: "int32", id: 2 } } } }), e("timestamp", { Timestamp: i }), e("empty", { Empty: { fields: {} } }), e("struct", { Struct: { fields: { fields: { keyType: "string", type: "Value", id: 1 } } }, Value: { oneofs: { kind: { oneof: ["nullValue", "numberValue", "stringValue", "boolValue", "structValue", "listValue"] } }, fields: { nullValue: { type: "NullValue", id: 1 }, numberValue: { type: "double", id: 2 }, stringValue: { type: "string", id: 3 }, boolValue: { type: "bool", id: 4 }, structValue: { type: "Struct", id: 5 }, listValue: { type: "ListValue", id: 6 } } }, NullValue: { values: { NULL_VALUE: 0 } }, ListValue: { fields: { values: { rule: "repeated", type: "Value", id: 1 } } } }), e("wrappers", { DoubleValue: { fields: { value: { type: "double", id: 1 } } }, FloatValue: { fields: { value: { type: "float", id: 1 } } }, Int64Value: { fields: { value: { type: "int64", id: 1 } } }, UInt64Value: { fields: { value: { type: "uint64", id: 1 } } }, Int32Value: { fields: { value: { type: "int32", id: 1 } } }, UInt32Value: { fields: { value: { type: "uint32", id: 1 } } }, BoolValue: { fields: { value: { type: "bool", id: 1 } } }, StringValue: { fields: { value: { type: "string", id: 1 } } }, BytesValue: { fields: { value: { type: "bytes", id: 1 } } } }), e("field_mask", { FieldMask: { fields: { paths: { rule: "repeated", type: "string", id: 1 } } } }), e.get = function (t) { return e[t] || null } }, {}], 12: [function (t, i, n) { var n = n, l = t(15), v = t(37); function o(t, i, n, r) { if (i.resolvedType) if (i.resolvedType instanceof l) { t("switch(d%s){", r); for (var e = i.resolvedType.values, s = Object.keys(e), o = 0; o < s.length; ++o)i.repeated && e[s[o]] === i.typeDefault && t("default:"), t("case%j:", s[o])("case %i:", e[s[o]])("m%s=%j", r, e[s[o]])("break"); t("}") } else t('if(typeof d%s!=="object")', r)("throw TypeError(%j)", i.fullName + ": object expected")("m%s=types[%i].fromObject(d%s)", r, n, r); else { var u = !1; switch (i.type) { case "double": case "float": t("m%s=Number(d%s)", r, r); break; case "uint32": case "fixed32": t("m%s=d%s>>>0", r, r); break; case "int32": case "sint32": case "sfixed32": t("m%s=d%s|0", r, r); break; case "uint64": u = !0; case "int64": case "sint64": case "fixed64": case "sfixed64": t("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j", r, r, u)('else if(typeof d%s==="string")', r)("m%s=parseInt(d%s,10)", r, r)('else if(typeof d%s==="number")', r)("m%s=d%s", r, r)('else if(typeof d%s==="object")', r)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)", r, r, r, u ? "true" : ""); break; case "bytes": t('if(typeof d%s==="string")', r)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)", r, r, r)("else if(d%s.length)", r)("m%s=d%s", r, r); break; case "string": t("m%s=String(d%s)", r, r); break; case "bool": t("m%s=Boolean(d%s)", r, r) } } return t } function d(t, i, n, r) { if (i.resolvedType) i.resolvedType instanceof l ? t("d%s=o.enums===String?types[%i].values[m%s]:m%s", r, n, r, r) : t("d%s=types[%i].toObject(m%s,o)", r, n, r); else { var e = !1; switch (i.type) { case "double": case "float": t("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s", r, r, r, r); break; case "uint64": e = !0; case "int64": case "sint64": case "fixed64": case "sfixed64": t('if(typeof m%s==="number")', r)("d%s=o.longs===String?String(m%s):m%s", r, r, r)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s", r, r, r, r, e ? "true" : "", r); break; case "bytes": t("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s", r, r, r, r, r); break; default: t("d%s=m%s", r, r) } } return t } n.fromObject = function (t) { var i = t.fieldsArray, n = v.codegen(["d"], t.name + "$fromObject")("if(d instanceof this.ctor)")("return d"); if (!i.length) return n("return new this.ctor"); n("var m=new this.ctor"); for (var r = 0; r < i.length; ++r) { var e = i[r].resolve(), s = v.safeProp(e.name); e.map ? (n("if(d%s){", s)('if(typeof d%s!=="object")', s)("throw TypeError(%j)", e.fullName + ": object expected")("m%s={}", s)("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){", s), o(n, e, r, s + "[ks[i]]")("}")("}")) : e.repeated ? (n("if(d%s){", s)("if(!Array.isArray(d%s))", s)("throw TypeError(%j)", e.fullName + ": array expected")("m%s=[]", s)("for(var i=0;i<d%s.length;++i){", s), o(n, e, r, s + "[i]")("}")("}")) : (e.resolvedType instanceof l || n("if(d%s!=null){", s), o(n, e, r, s), e.resolvedType instanceof l || n("}")) } return n("return m") }, n.toObject = function (t) { var i = t.fieldsArray.slice().sort(v.compareFieldsById); if (!i.length) return v.codegen()("return {}"); for (var n = v.codegen(["m", "o"], t.name + "$toObject")("if(!o)")("o={}")("var d={}"), r = [], e = [], s = [], o = 0; o < i.length; ++o)i[o].partOf || (i[o].resolve().repeated ? r : i[o].map ? e : s).push(i[o]); if (r.length) { for (n("if(o.arrays||o.defaults){"), o = 0; o < r.length; ++o)n("d%s=[]", v.safeProp(r[o].name)); n("}") } if (e.length) { for (n("if(o.objects||o.defaults){"), o = 0; o < e.length; ++o)n("d%s={}", v.safeProp(e[o].name)); n("}") } if (s.length) { for (n("if(o.defaults){"), o = 0; o < s.length; ++o) { var u, f = s[o], h = v.safeProp(f.name); f.resolvedType instanceof l ? n("d%s=o.enums===String?%j:%j", h, f.resolvedType.valuesById[f.typeDefault], f.typeDefault) : f.long ? n("if(util.Long){")("var n=new util.Long(%i,%i,%j)", f.typeDefault.low, f.typeDefault.high, f.typeDefault.unsigned)("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n", h)("}else")("d%s=o.longs===String?%j:%i", h, f.typeDefault.toString(), f.typeDefault.toNumber()) : f.bytes ? (u = "[" + Array.prototype.slice.call(f.typeDefault).join(",") + "]", n("if(o.bytes===String)d%s=%j", h, String.fromCharCode.apply(String, f.typeDefault))("else{")("d%s=%s", h, u)("if(o.bytes!==Array)d%s=util.newBuffer(d%s)", h, h)("}")) : n("d%s=%j", h, f.typeDefault) } n("}") } for (var a = !1, o = 0; o < i.length; ++o) { var f = i[o], c = t.e.indexOf(f), h = v.safeProp(f.name); f.map ? (a || (a = !0, n("var ks2")), n("if(m%s&&(ks2=Object.keys(m%s)).length){", h, h)("d%s={}", h)("for(var j=0;j<ks2.length;++j){"), d(n, f, c, h + "[ks2[j]]")("}")) : f.repeated ? (n("if(m%s&&m%s.length){", h, h)("d%s=[]", h)("for(var j=0;j<m%s.length;++j){", h), d(n, f, c, h + "[j]")("}")) : (n("if(m%s!=null&&m.hasOwnProperty(%j)){", h, f.name), d(n, f, c, h), f.partOf && n("if(o.oneofs)")("d%s=%j", v.safeProp(f.partOf.name), f.name)), n("}") } return n("return d") } }, { 15: 15, 37: 37 }], 13: [function (t, i, n) { i.exports = function (t) { var i = h.codegen(["r", "l"], t.name + "$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor" + (t.fieldsArray.filter(function (t) { return t.map }).length ? ",k,value" : ""))("while(r.pos<c){")("var t=r.uint32()"); t.group && i("if((t&7)===4)")("break"); i("switch(t>>>3){"); for (var n = 0; n < t.fieldsArray.length; ++n) { var r = t.e[n].resolve(), e = r.resolvedType instanceof u ? "int32" : r.type, s = "m" + h.safeProp(r.name); i("case %i:", r.id), r.map ? (i("if(%s===util.emptyObject)", s)("%s={}", s)("var c2 = r.uint32()+r.pos"), f.defaults[r.keyType] !== Q ? i("k=%j", f.defaults[r.keyType]) : i("k=null"), f.defaults[e] !== Q ? i("value=%j", f.defaults[e]) : i("value=null"), i("while(r.pos<c2){")("var tag2=r.uint32()")("switch(tag2>>>3){")("case 1: k=r.%s(); break", r.keyType)("case 2:"), f.basic[e] === Q ? i("value=types[%i].decode(r,r.uint32())", n) : i("value=r.%s()", e), i("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"), f.long[r.keyType] !== Q ? i('%s[typeof k==="object"?util.longToHash(k):k]=value', s) : i("%s[k]=value", s)) : r.repeated ? (i("if(!(%s&&%s.length))", s, s)("%s=[]", s), f.packed[e] !== Q && i("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos<c2)")("%s.push(r.%s())", s, e)("}else"), f.basic[e] === Q ? i(r.resolvedType.group ? "%s.push(types[%i].decode(r))" : "%s.push(types[%i].decode(r,r.uint32()))", s, n) : i("%s.push(r.%s())", s, e)) : f.basic[e] === Q ? i(r.resolvedType.group ? "%s=types[%i].decode(r)" : "%s=types[%i].decode(r,r.uint32())", s, n) : i("%s=r.%s()", s, e), i("break") } for (i("default:")("r.skipType(t&7)")("break")("}")("}"), n = 0; n < t.e.length; ++n) { var o = t.e[n]; o.required && i("if(!m.hasOwnProperty(%j))", o.name)("throw util.ProtocolError(%j,{instance:m})", "missing required '" + o.name + "'") } return i("return m") }; var u = t(15), f = t(36), h = t(37) }, { 15: 15, 36: 36, 37: 37 }], 14: [function (t, i, n) { i.exports = function (t) { for (var i, n = c.codegen(["m", "w"], t.name + "$encode")("if(!w)")("w=Writer.create()"), r = t.fieldsArray.slice().sort(c.compareFieldsById), e = 0; e < r.length; ++e) { var s = r[e].resolve(), o = t.e.indexOf(s), u = s.resolvedType instanceof h ? "int32" : s.type, f = a.basic[u]; i = "m" + c.safeProp(s.name), s.map ? (n("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){", i, s.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){", i)("w.uint32(%i).fork().uint32(%i).%s(ks[i])", (s.id << 3 | 2) >>> 0, 8 | a.mapKey[s.keyType], s.keyType), f === Q ? n("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()", o, i) : n(".uint32(%i).%s(%s[ks[i]]).ldelim()", 16 | f, u, i), n("}")("}")) : s.repeated ? (n("if(%s!=null&&%s.length){", i, i), s.packed && a.packed[u] !== Q ? n("w.uint32(%i).fork()", (s.id << 3 | 2) >>> 0)("for(var i=0;i<%s.length;++i)", i)("w.%s(%s[i])", u, i)("w.ldelim()") : (n("for(var i=0;i<%s.length;++i)", i), f === Q ? l(n, s, o, i + "[i]") : n("w.uint32(%i).%s(%s[i])", (s.id << 3 | f) >>> 0, u, i)), n("}")) : (s.optional && n("if(%s!=null&&Object.hasOwnProperty.call(m,%j))", i, s.name), f === Q ? l(n, s, o, i) : n("w.uint32(%i).%s(%s)", (s.id << 3 | f) >>> 0, u, i)) } return n("return w") }; var h = t(15), a = t(36), c = t(37); function l(t, i, n, r) { return i.resolvedType.group ? t("types[%i].encode(%s,w.uint32(%i)).uint32(%i)", n, r, (i.id << 3 | 3) >>> 0, (i.id << 3 | 4) >>> 0) : t("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()", n, r, (i.id << 3 | 2) >>> 0) } }, { 15: 15, 36: 36, 37: 37 }], 15: [function (t, i, n) { i.exports = s; var u = t(24); ((s.prototype = Object.create(u.prototype)).constructor = s).className = "Enum"; var r = t(23), e = t(37); function s(t, i, n, r, e) { if (u.call(this, t, n), i && "object" != typeof i) throw TypeError("values must be an object"); if (this.valuesById = {}, this.values = Object.create(this.valuesById), this.comment = r, this.comments = e || {}, this.reserved = Q, i) for (var s = Object.keys(i), o = 0; o < s.length; ++o)"number" == typeof i[s[o]] && (this.valuesById[this.values[s[o]] = i[s[o]]] = s[o]) } s.fromJSON = function (t, i) { t = new s(t, i.values, i.options, i.comment, i.comments); return t.reserved = i.reserved, t }, s.prototype.toJSON = function (t) { t = !!t && !!t.keepComments; return e.toObject(["options", this.options, "values", this.values, "reserved", this.reserved && this.reserved.length ? this.reserved : Q, "comment", t ? this.comment : Q, "comments", t ? this.comments : Q]) }, s.prototype.add = function (t, i, n) { if (!e.isString(t)) throw TypeError("name must be a string"); if (!e.isInteger(i)) throw TypeError("id must be an integer"); if (this.values[t] !== Q) throw Error("duplicate name '" + t + "' in " + this); if (this.isReservedId(i)) throw Error("id " + i + " is reserved in " + this); if (this.isReservedName(t)) throw Error("name '" + t + "' is reserved in " + this); if (this.valuesById[i] !== Q) { if (!this.options || !this.options.allow_alias) throw Error("duplicate id " + i + " in " + this); this.values[t] = i } else this.valuesById[this.values[t] = i] = t; return this.comments[t] = n || null, this }, s.prototype.remove = function (t) { if (!e.isString(t)) throw TypeError("name must be a string"); var i = this.values[t]; if (null == i) throw Error("name '" + t + "' does not exist in " + this); return delete this.valuesById[i], delete this.values[t], delete this.comments[t], this }, s.prototype.isReservedId = function (t) { return r.isReservedId(this.reserved, t) }, s.prototype.isReservedName = function (t) { return r.isReservedName(this.reserved, t) } }, { 23: 23, 24: 24, 37: 37 }], 16: [function (t, i, n) { i.exports = o; var u = t(24); ((o.prototype = Object.create(u.prototype)).constructor = o).className = "Field"; var r, e = t(15), f = t(36), h = t(37), a = /^required|optional|repeated$/; function o(t, i, n, r, e, s, o) { if (h.isObject(r) ? (o = e, s = r, r = e = Q) : h.isObject(e) && (o = s, s = e, e = Q), u.call(this, t, s), !h.isInteger(i) || i < 0) throw TypeError("id must be a non-negative integer"); if (!h.isString(n)) throw TypeError("type must be a string"); if (r !== Q && !a.test(r = r.toString().toLowerCase())) throw TypeError("rule must be a string rule"); if (e !== Q && !h.isString(e)) throw TypeError("extend must be a string"); this.rule = (r = "proto3_optional" === r ? "optional" : r) && "optional" !== r ? r : Q, this.type = n, this.id = i, this.extend = e || Q, this.required = "required" === r, this.optional = !this.required, this.repeated = "repeated" === r, this.map = !1, this.message = null, this.partOf = null, this.typeDefault = null, this.defaultValue = null, this.long = !!h.Long && f.long[n] !== Q, this.bytes = "bytes" === n, this.resolvedType = null, this.extensionField = null, this.declaringField = null, this.o = null, this.comment = o } o.fromJSON = function (t, i) { return new o(t, i.id, i.type, i.rule, i.extend, i.options, i.comment) }, Object.defineProperty(o.prototype, "packed", { get: function () { return null === this.o && (this.o = !1 !== this.getOption("packed")), this.o } }), o.prototype.setOption = function (t, i, n) { return "packed" === t && (this.o = null), u.prototype.setOption.call(this, t, i, n) }, o.prototype.toJSON = function (t) { t = !!t && !!t.keepComments; return h.toObject(["rule", "optional" !== this.rule && this.rule || Q, "type", this.type, "id", this.id, "extend", this.extend, "options", this.options, "comment", t ? this.comment : Q]) }, o.prototype.resolve = function () { return this.resolved ? this : ((this.typeDefault = f.defaults[this.type]) === Q && (this.resolvedType = (this.declaringField || this).parent.lookupTypeOrEnum(this.type), this.resolvedType instanceof r ? this.typeDefault = null : this.typeDefault = this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]), this.options && null != this.options.default && (this.typeDefault = this.options.default, this.resolvedType instanceof e && "string" == typeof this.typeDefault && (this.typeDefault = this.resolvedType.values[this.typeDefault])), this.options && (!0 !== this.options.packed && (this.options.packed === Q || !this.resolvedType || this.resolvedType instanceof e) || delete this.options.packed, Object.keys(this.options).length || (this.options = Q)), this.long ? (this.typeDefault = h.Long.fromNumber(this.typeDefault, "u" == (this.type[0] || "")), Object.freeze && Object.freeze(this.typeDefault)) : this.bytes && "string" == typeof this.typeDefault && (h.base64.test(this.typeDefault) ? h.base64.decode(this.typeDefault, t = h.newBuffer(h.base64.length(this.typeDefault)), 0) : h.utf8.write(this.typeDefault, t = h.newBuffer(h.utf8.length(this.typeDefault)), 0), this.typeDefault = t), this.map ? this.defaultValue = h.emptyObject : this.repeated ? this.defaultValue = h.emptyArray : this.defaultValue = this.typeDefault, this.parent instanceof r && (this.parent.ctor.prototype[this.name] = this.defaultValue), u.prototype.resolve.call(this)); var t }, o.d = function (n, r, e, s) { return "function" == typeof r ? r = h.decorateType(r).name : r && "object" == typeof r && (r = h.decorateEnum(r).name), function (t, i) { h.decorateType(t.constructor).add(new o(i, n, r, e, { default: s })) } }, o.u = function (t) { r = t } }, { 15: 15, 24: 24, 36: 36, 37: 37 }], 17: [function (t, i, n) { var r = i.exports = t(18); r.build = "light", r.load = function (t, i, n) { return (i = "function" == typeof i ? (n = i, new r.Root) : i || new r.Root).load(t, n) }, r.loadSync = function (t, i) { return (i = i || new r.Root).loadSync(t) }, r.encoder = t(14), r.decoder = t(13), r.verifier = t(40), r.converter = t(12), r.ReflectionObject = t(24), r.Namespace = t(23), r.Root = t(29), r.Enum = t(15), r.Type = t(35), r.Field = t(16), r.OneOf = t(25), r.MapField = t(20), r.Service = t(33), r.Method = t(22), r.Message = t(21), r.wrappers = t(41), r.types = t(36), r.util = t(37), r.ReflectionObject.u(r.Root), r.Namespace.u(r.Type, r.Service, r.Enum), r.Root.u(r.Type), r.Field.u(r.Type) }, { 12: 12, 13: 13, 14: 14, 15: 15, 16: 16, 18: 18, 20: 20, 21: 21, 22: 22, 23: 23, 24: 24, 25: 25, 29: 29, 33: 33, 35: 35, 36: 36, 37: 37, 40: 40, 41: 41 }], 18: [function (t, i, n) { var r = n; function e() { r.util.u(), r.Writer.u(r.BufferWriter), r.Reader.u(r.BufferReader) } r.build = "minimal", r.Writer = t(42), r.BufferWriter = t(43), r.Reader = t(27), r.BufferReader = t(28), r.util = t(39), r.rpc = t(31), r.roots = t(30), r.configure = e, e() }, { 27: 27, 28: 28, 30: 30, 31: 31, 39: 39, 42: 42, 43: 43 }], 19: [function (t, i, n) { i = i.exports = t(17); i.build = "full", i.tokenize = t(34), i.parse = t(26), i.common = t(11), i.Root.u(i.Type, i.parse, i.common) }, { 11: 11, 17: 17, 26: 26, 34: 34 }], 20: [function (t, i, n) { i.exports = s; var o = t(16); ((s.prototype = Object.create(o.prototype)).constructor = s).className = "MapField"; var r = t(36), u = t(37); function s(t, i, n, r, e, s) { if (o.call(this, t, i, r, Q, Q, e, s), !u.isString(n)) throw TypeError("keyType must be a string"); this.keyType = n, this.resolvedKeyType = null, this.map = !0 } s.fromJSON = function (t, i) { return new s(t, i.id, i.keyType, i.type, i.options, i.comment) }, s.prototype.toJSON = function (t) { t = !!t && !!t.keepComments; return u.toObject(["keyType", this.keyType, "type", this.type, "id", this.id, "extend", this.extend, "options", this.options, "comment", t ? this.comment : Q]) }, s.prototype.resolve = function () { if (this.resolved) return this; if (r.mapKey[this.keyType] === Q) throw Error("invalid key type: " + this.keyType); return o.prototype.resolve.call(this) }, s.d = function (n, r, e) { return "function" == typeof e ? e = u.decorateType(e).name : e && "object" == typeof e && (e = u.decorateEnum(e).name), function (t, i) { u.decorateType(t.constructor).add(new s(i, n, r, e)) } } }, { 16: 16, 36: 36, 37: 37 }], 21: [function (t, i, n) { i.exports = e; var r = t(39); function e(t) { if (t) for (var i = Object.keys(t), n = 0; n < i.length; ++n)this[i[n]] = t[i[n]] } e.create = function (t) { return this.$type.create(t) }, e.encode = function (t, i) { return this.$type.encode(t, i) }, e.encodeDelimited = function (t, i) { return this.$type.encodeDelimited(t, i) }, e.decode = function (t) { return this.$type.decode(t) }, e.decodeDelimited = function (t) { return this.$type.decodeDelimited(t) }, e.verify = function (t) { return this.$type.verify(t) }, e.fromObject = function (t) { return this.$type.fromObject(t) }, e.toObject = function (t, i) { return this.$type.toObject(t, i) }, e.prototype.toJSON = function () { return this.$type.toObject(this, r.toJSONOptions) } }, { 39: 39 }], 22: [function (t, i, n) { i.exports = r; var h = t(24); ((r.prototype = Object.create(h.prototype)).constructor = r).className = "Method"; var a = t(37); function r(t, i, n, r, e, s, o, u, f) { if (a.isObject(e) ? (o = e, e = s = Q) : a.isObject(s) && (o = s, s = Q), i !== Q && !a.isString(i)) throw TypeError("type must be a string"); if (!a.isString(n)) throw TypeError("requestType must be a string"); if (!a.isString(r)) throw TypeError("responseType must be a string"); h.call(this, t, o), this.type = i || "rpc", this.requestType = n, this.requestStream = !!e || Q, this.responseType = r, this.responseStream = !!s || Q, this.resolvedRequestType = null, this.resolvedResponseType = null, this.comment = u, this.parsedOptions = f } r.fromJSON = function (t, i) { return new r(t, i.type, i.requestType, i.responseType, i.requestStream, i.responseStream, i.options, i.comment, i.parsedOptions) }, r.prototype.toJSON = function (t) { t = !!t && !!t.keepComments; return a.toObject(["type", "rpc" !== this.type && this.type || Q, "requestType", this.requestType, "requestStream", this.requestStream, "responseType", this.responseType, "responseStream", this.responseStream, "options", this.options, "comment", t ? this.comment : Q, "parsedOptions", this.parsedOptions]) }, r.prototype.resolve = function () { return this.resolved ? this : (this.resolvedRequestType = this.parent.lookupType(this.requestType), this.resolvedResponseType = this.parent.lookupType(this.responseType), h.prototype.resolve.call(this)) } }, { 24: 24, 37: 37 }], 23: [function (t, i, n) { i.exports = a; var r = t(24); ((a.prototype = Object.create(r.prototype)).constructor = a).className = "Namespace"; var e, s, o, u = t(16), f = t(37); function h(t, i) { if (!t || !t.length) return Q; for (var n = {}, r = 0; r < t.length; ++r)n[t[r].name] = t[r].toJSON(i); return n } function a(t, i) { r.call(this, t, i), this.nested = Q, this.f = null } function c(t) { return t.f = null, t } a.fromJSON = function (t, i) { return new a(t, i.options).addJSON(i.nested) }, a.arrayToJSON = h, a.isReservedId = function (t, i) { if (t) for (var n = 0; n < t.length; ++n)if ("string" != typeof t[n] && t[n][0] <= i && t[n][1] > i) return !0; return !1 }, a.isReservedName = function (t, i) { if (t) for (var n = 0; n < t.length; ++n)if (t[n] === i) return !0; return !1 }, Object.defineProperty(a.prototype, "nestedArray", { get: function () { return this.f || (this.f = f.toArray(this.nested)) } }), a.prototype.toJSON = function (t) { return f.toObject(["options", this.options, "nested", h(this.nestedArray, t)]) }, a.prototype.addJSON = function (t) { if (t) for (var i, n = Object.keys(t), r = 0; r < n.length; ++r)i = t[n[r]], this.add((i.fields !== Q ? e : i.values !== Q ? o : i.methods !== Q ? s : i.id !== Q ? u : a).fromJSON(n[r], i)); return this }, a.prototype.get = function (t) { return this.nested && this.nested[t] || null }, a.prototype.getEnum = function (t) { if (this.nested && this.nested[t] instanceof o) return this.nested[t].values; throw Error("no such enum: " + t) }, a.prototype.add = function (t) { if (!(t instanceof u && t.extend !== Q || t instanceof e || t instanceof o || t instanceof s || t instanceof a)) throw TypeError("object must be a valid nested object"); if (this.nested) { var i = this.get(t.name); if (i) { if (!(i instanceof a && t instanceof a) || i instanceof e || i instanceof s) throw Error("duplicate name '" + t.name + "' in " + this); for (var n = i.nestedArray, r = 0; r < n.length; ++r)t.add(n[r]); this.remove(i), this.nested || (this.nested = {}), t.setOptions(i.options, !0) } } else this.nested = {}; return (this.nested[t.name] = t).onAdd(this), c(this) }, a.prototype.remove = function (t) { if (!(t instanceof r)) throw TypeError("object must be a ReflectionObject"); if (t.parent !== this) throw Error(t + " is not a member of " + this); return delete this.nested[t.name], Object.keys(this.nested).length || (this.nested = Q), t.onRemove(this), c(this) }, a.prototype.define = function (t, i) { if (f.isString(t)) t = t.split("."); else if (!Array.isArray(t)) throw TypeError("illegal path"); if (t && t.length && "" === t[0]) throw Error("path must be relative"); for (var n = this; 0 < t.length;) { var r = t.shift(); if (n.nested && n.nested[r]) { if (!((n = n.nested[r]) instanceof a)) throw Error("path conflicts with non-namespace objects") } else n.add(n = new a(r)) } return i && n.addJSON(i), n }, a.prototype.resolveAll = function () { for (var t = this.nestedArray, i = 0; i < t.length;)t[i] instanceof a ? t[i++].resolveAll() : t[i++].resolve(); return this.resolve() }, a.prototype.lookup = function (t, i, n) { if ("boolean" == typeof i ? (n = i, i = Q) : i && !Array.isArray(i) && (i = [i]), f.isString(t) && t.length) { if ("." === t) return this.root; t = t.split(".") } else if (!t.length) return this; if ("" === t[0]) return this.root.lookup(t.slice(1), i); var r = this.get(t[0]); if (r) { if (1 === t.length) { if (!i || ~i.indexOf(r.constructor)) return r } else if (r instanceof a && (r = r.lookup(t.slice(1), i, !0))) return r } else for (var e = 0; e < this.nestedArray.length; ++e)if (this.f[e] instanceof a && (r = this.f[e].lookup(t, i, !0))) return r; return null === this.parent || n ? null : this.parent.lookup(t, i) }, a.prototype.lookupType = function (t) { var i = this.lookup(t, [e]); if (!i) throw Error("no such type: " + t); return i }, a.prototype.lookupEnum = function (t) { var i = this.lookup(t, [o]); if (!i) throw Error("no such Enum '" + t + "' in " + this); return i }, a.prototype.lookupTypeOrEnum = function (t) { var i = this.lookup(t, [e, o]); if (!i) throw Error("no such Type or Enum '" + t + "' in " + this); return i }, a.prototype.lookupService = function (t) { var i = this.lookup(t, [s]); if (!i) throw Error("no such Service '" + t + "' in " + this); return i }, a.u = function (t, i, n) { e = t, s = i, o = n } }, { 16: 16, 24: 24, 37: 37 }], 24: [function (t, i, n) { (i.exports = e).className = "ReflectionObject"; var r, o = t(37); function e(t, i) { if (!o.isString(t)) throw TypeError("name must be a string"); if (i && !o.isObject(i)) throw TypeError("options must be an object"); this.options = i, this.parsedOptions = null, this.name = t, this.parent = null, this.resolved = !1, this.comment = null, this.filename = null } Object.defineProperties(e.prototype, { root: { get: function () { for (var t = this; null !== t.parent;)t = t.parent; return t } }, fullName: { get: function () { for (var t = [this.name], i = this.parent; i;)t.unshift(i.name), i = i.parent; return t.join(".") } } }), e.prototype.toJSON = function () { throw Error() }, e.prototype.onAdd = function (t) { this.parent && this.parent !== t && this.parent.remove(this), this.parent = t, this.resolved = !1; t = t.root; t instanceof r && t.h(this) }, e.prototype.onRemove = function (t) { t = t.root; t instanceof r && t.a(this), this.parent = null, this.resolved = !1 }, e.prototype.resolve = function () { return this.resolved || this.root instanceof r && (this.resolved = !0), this }, e.prototype.getOption = function (t) { return this.options ? this.options[t] : Q }, e.prototype.setOption = function (t, i, n) { return n && this.options && this.options[t] !== Q || ((this.options || (this.options = {}))[t] = i), this }, e.prototype.setParsedOption = function (i, t, n) { this.parsedOptions || (this.parsedOptions = []); var r, e, s = this.parsedOptions; return n ? (e = s.find(function (t) { return Object.prototype.hasOwnProperty.call(t, i) })) ? (r = e[i], o.setProperty(r, n, t)) : ((e = {})[i] = o.setProperty({}, n, t), s.push(e)) : ((e = {})[i] = t, s.push(e)), this }, e.prototype.setOptions = function (t, i) { if (t) for (var n = Object.keys(t), r = 0; r < n.length; ++r)this.setOption(n[r], t[n[r]], i); return this }, e.prototype.toString = function () { var t = this.constructor.className, i = this.fullName; return i.length ? t + " " + i : t }, e.u = function (t) { r = t } }, { 37: 37 }], 25: [function (t, i, n) { i.exports = o; var e = t(24); ((o.prototype = Object.create(e.prototype)).constructor = o).className = "OneOf"; var r = t(16), s = t(37); function o(t, i, n, r) { if (Array.isArray(i) || (n = i, i = Q), e.call(this, t, n), i !== Q && !Array.isArray(i)) throw TypeError("fieldNames must be an Array"); this.oneof = i || [], this.fieldsArray = [], this.comment = r } function u(t) { if (t.parent) for (var i = 0; i < t.fieldsArray.length; ++i)t.fieldsArray[i].parent || t.parent.add(t.fieldsArray[i]) } o.fromJSON = function (t, i) { return new o(t, i.oneof, i.options, i.comment) }, o.prototype.toJSON = function (t) { t = !!t && !!t.keepComments; return s.toObject(["options", this.options, "oneof", this.oneof, "comment", t ? this.comment : Q]) }, o.prototype.add = function (t) { if (!(t instanceof r)) throw TypeError("field must be a Field"); return t.parent && t.parent !== this.parent && t.parent.remove(t), this.oneof.push(t.name), this.fieldsArray.push(t), u(t.partOf = this), this }, o.prototype.remove = function (t) { if (!(t instanceof r)) throw TypeError("field must be a Field"); var i = this.fieldsArray.indexOf(t); if (i < 0) throw Error(t + " is not a member of " + this); return this.fieldsArray.splice(i, 1), -1 < (i = this.oneof.indexOf(t.name)) && this.oneof.splice(i, 1), t.partOf = null, this }, o.prototype.onAdd = function (t) { e.prototype.onAdd.call(this, t); for (var i = 0; i < this.oneof.length; ++i) { var n = t.get(this.oneof[i]); n && !n.partOf && (n.partOf = this).fieldsArray.push(n) } u(this) }, o.prototype.onRemove = function (t) { for (var i, n = 0; n < this.fieldsArray.length; ++n)(i = this.fieldsArray[n]).parent && i.parent.remove(i); e.prototype.onRemove.call(this, t) }, o.d = function () { for (var n = Array(arguments.length), t = 0; t < arguments.length;)n[t] = arguments[t++]; return function (t, i) { s.decorateType(t.constructor).add(new o(i, n)), Object.defineProperty(t, i, { get: s.oneOfGetter(n), set: s.oneOfSetter(n) }) } } }, { 16: 16, 24: 24, 37: 37 }], 26: [function (t, i, n) { (i.exports = K).filename = null, K.defaults = { keepCase: !1 }; var V = t(34), $ = t(29), M = t(35), _ = t(16), I = t(20), F = t(25), L = t(15), U = t(33), q = t(22), R = t(36), z = t(37), Z = /^[1-9][0-9]*$/, B = /^-?[1-9][0-9]*$/, P = /^0[x][0-9a-fA-F]+$/, H = /^-?0[x][0-9a-fA-F]+$/, X = /^0[0-7]+$/, C = /^-?0[0-7]+$/, D = /^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/, J = /^[a-zA-Z_][a-zA-Z_0-9]*$/, W = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/, G = /^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/; function K(t, i, n) { i instanceof $ || (n = i, i = new $); var r, e, s, o, f, u = (n = n || K.defaults).preferTrailingComment || !1, h = V(t, n.alternateCommentMode || !1), a = h.next, c = h.push, l = h.peek, v = h.skip, d = h.cmnt, p = !0, b = !1, w = i, y = n.keepCase ? function (t) { return t } : z.camelCase; function m(t, i, n) { var r = K.filename; return n || (K.filename = null), Error("illegal " + (i || "token") + " '" + t + "' (" + (r ? r + ", " : "") + "line " + h.line + ")") } function g() { var t, i = []; do { if ('"' !== (t = a()) && "'" !== t) throw m(t) } while (i.push(a()), v(t), '"' === (t = l()) || "'" === t); return i.join("") } function j(i) { var n = a(); switch (n) { case "'": case '"': return c(n), g(); case "true": case "TRUE": return !0; case "false": case "FALSE": return !1 }try { return function (t, i) { var n = 1; "-" == (t[0] || "") && (n = -1, t = t.substring(1)); switch (t) { case "inf": case "INF": case "Inf": return n * (1 / 0); case "nan": case "NAN": case "Nan": case "NaN": return NaN; case "0": return 0 }if (Z.test(t)) return n * parseInt(t, 10); if (P.test(t)) return n * parseInt(t, 16); if (X.test(t)) return n * parseInt(t, 8); if (D.test(t)) return n * parseFloat(t); throw m(t, "number", i) }(n, !0) } catch (t) { if (i && W.test(n)) return n; throw m(n, "value") } } function k(t, i) { for (var n; !i || '"' !== (n = l()) && "'" !== n ? t.push([n = O(a()), v("to", !0) ? O(a()) : n]) : t.push(g()), v(",", !0);); v(";") } function O(t, i) { switch (t) { case "max": case "MAX": case "Max": return 536870911; case "0": return 0 }if (!i && "-" == (t[0] || "")) throw m(t, "id"); if (B.test(t)) return parseInt(t, 10); if (H.test(t)) return parseInt(t, 16); if (C.test(t)) return parseInt(t, 8); throw m(t, "id") } function E(t, i) { switch (i) { case "option": return T(t, i), v(";"), 1; case "message": return function (t, i) { if (!J.test(i = a())) throw m(i, "type name"); var n = new M(i); A(n, function (t) { if (!E(n, t)) switch (t) { case "map": !function (t) { v("<"); var i = a(); if (R.mapKey[i] === Q) throw m(i, "type"); v(","); var n = a(); if (!W.test(n)) throw m(n, "type"); v(">"); var r = a(); if (!J.test(r)) throw m(r, "name"); v("="); var e = new I(y(r), O(a()), i, n); A(e, function (t) { if ("option" !== t) throw m(t); T(e, t), v(";") }, function () { N(e) }), t.add(e) }(n); break; case "required": case "repeated": x(n, t); break; case "optional": x(n, b ? "proto3_optional" : "optional"); break; case "oneof": !function (t, i) { if (!J.test(i = a())) throw m(i, "name"); var n = new F(y(i)); A(n, function (t) { "option" === t ? (T(n, t), v(";")) : (c(t), x(n, "optional")) }), t.add(n) }(n, t); break; case "extensions": k(n.extensions || (n.extensions = [])); break; case "reserved": k(n.reserved || (n.reserved = []), !0); break; default: if (!b || !W.test(t)) throw m(t); c(t), x(n, "optional") } }), t.add(n) }(t, i), 1; case "enum": return function (t, i) { if (!J.test(i = a())) throw m(i, "name"); var n = new L(i); A(n, function (t) { switch (t) { case "option": T(n, t), v(";"); break; case "reserved": k(n.reserved || (n.reserved = []), !0); break; default: !function (t, i) { if (!J.test(i)) throw m(i, "name"); v("="); var n = O(a(), !0), r = {}; A(r, function (t) { if ("option" !== t) throw m(t); T(r, t), v(";") }, function () { N(r) }), t.add(i, n, r.comment) }(n, t) } }), t.add(n) }(t, i), 1; case "service": return function (t, i) { if (!J.test(i = a())) throw m(i, "service name"); var n = new U(i); A(n, function (t) { if (!E(n, t)) { if ("rpc" !== t) throw m(t); !function (t, i) { var n = d(), r = i; if (!J.test(i = a())) throw m(i, "name"); var e, s, o, u = i; v("("), v("stream", !0) && (s = !0); if (!W.test(i = a())) throw m(i); e = i, v(")"), v("returns"), v("("), v("stream", !0) && (o = !0); if (!W.test(i = a())) throw m(i); i = i, v(")"); var f = new q(u, r, e, i, s, o); f.comment = n, A(f, function (t) { if ("option" !== t) throw m(t); T(f, t), v(";") }), t.add(f) }(n, t) } }), t.add(n) }(t, i), 1; case "extend": return function (i, t) { if (!W.test(t = a())) throw m(t, "reference"); var n = t; A(null, function (t) { switch (t) { case "required": case "repeated": x(i, t, n); break; case "optional": x(i, b ? "proto3_optional" : "optional", n); break; default: if (!b || !W.test(t)) throw m(t); c(t), x(i, "optional", n) } }) }(t, i), 1 } } function A(t, i, n) { var r, e = h.line; if (t && ("string" != typeof t.comment && (t.comment = d()), t.filename = K.filename), v("{", !0)) { for (; "}" !== (r = a());)i(r); v(";", !0) } else n && n(), v(";"), t && ("string" != typeof t.comment || u) && (t.comment = d(e) || t.comment) } function x(t, i, n) { var r = a(); if ("group" !== r) { if (!W.test(r)) throw m(r, "type"); var e = a(); if (!J.test(e)) throw m(e, "name"); e = y(e), v("="); var s = new _(e, O(a()), r, i, n); A(s, function (t) { if ("option" !== t) throw m(t); T(s, t), v(";") }, function () { N(s) }), "proto3_optional" === i ? (e = new F("_" + e), s.setOption("proto3_optional", !0), e.add(s), t.add(e)) : t.add(s), b || !s.repeated || R.packed[r] === Q && R.basic[r] !== Q || s.setOption("packed", !1, !0) } else !function (t, i) { var n = a(); if (!J.test(n)) throw m(n, "name"); var r = z.lcFirst(n); n === r && (n = z.ucFirst(n)); v("="); var e = O(a()), s = new M(n); s.group = !0; i = new _(r, e, n, i); i.filename = K.filename, A(s, function (t) { switch (t) { case "option": T(s, t), v(";"); break; case "required": case "repeated": x(s, t); break; case "optional": x(s, b ? "proto3_optional" : "optional"); break; default: throw m(t) } }), t.add(s).add(i) }(t, i) } function T(t, i) { var n = v("(", !0); if (!W.test(i = a())) throw m(i, "name"); var r = i, e = r; n && (v(")"), e = r = "(" + r + ")", i = l(), G.test(i) && (s = i.substr(1), r += i, a())), v("="); var s, r = function t(i, n) { if (v("{", !0)) { for (var r = {}; !v("}", !0);) { if (!J.test(f = a())) throw m(f, "name"); var e, s = f; "{" === l() ? e = t(i, n + "." + f) : (v(":"), "{" === l() ? e = t(i, n + "." + f) : (e = j(!0), S(i, n + "." + f, e))); var o = r[s]; o && (e = [].concat(o).concat(e)), r[s] = e, v(",", !0) } return r } var u = j(!0); S(i, n, u); return u }(t, r); e = e, r = r, s = s, (t = t).setParsedOption && t.setParsedOption(e, r, s) } function S(t, i, n) { t.setOption && t.setOption(i, n) } function N(t) { if (v("[", !0)) { for (; T(t, "option"), v(",", !0);); v("]") } return t } for (; null !== (f = a());)switch (f) { case "package": if (!p) throw m(f); !function () { if (r !== Q) throw m("package"); if (r = a(), !W.test(r)) throw m(r, "name"); w = w.define(r), v(";") }(); break; case "import": if (!p) throw m(f); !function () { var t, i = l(); switch (i) { case "weak": t = s = s || [], a(); break; case "public": a(); default: t = e = e || [] }i = g(), v(";"), t.push(i) }(); break; case "syntax": if (!p) throw m(f); !function () { if (v("="), o = g(), !(b = "proto3" === o) && "proto2" !== o) throw m(o, "syntax"); v(";") }(); break; case "option": T(w, f), v(";"); break; default: if (E(w, f)) { p = !1; continue } throw m(f) }return K.filename = null, { package: r, imports: e, weakImports: s, syntax: o, root: i } } }, { 15: 15, 16: 16, 20: 20, 22: 22, 25: 25, 29: 29, 33: 33, 34: 34, 35: 35, 36: 36, 37: 37 }], 27: [function (t, i, n) { i.exports = f; var r, e = t(39), s = e.LongBits, o = e.utf8; function u(t, i) { return RangeError("index out of range: " + t.pos + " + " + (i || 1) + " > " + t.len) } function f(t) { this.buf = t, this.pos = 0, this.len = t.length } function h() { return e.Buffer ? function (t) { return (f.create = function (t) { return e.Buffer.isBuffer(t) ? new r(t) : c(t) })(t) } : c } var a, c = "undefined" != typeof Uint8Array ? function (t) { if (t instanceof Uint8Array || Array.isArray(t)) return new f(t); throw Error("illegal buffer") } : function (t) { if (Array.isArray(t)) return new f(t); throw Error("illegal buffer") }; function l() { var t = new s(0, 0), i = 0; if (!(4 < this.len - this.pos)) { for (; i < 3; ++i) { if (this.pos >= this.len) throw u(this); if (t.lo = (t.lo | (127 & this.buf[this.pos]) << 7 * i) >>> 0, this.buf[this.pos++] < 128) return t } return t.lo = (t.lo | (127 & this.buf[this.pos++]) << 7 * i) >>> 0, t } for (; i < 4; ++i)if (t.lo = (t.lo | (127 & this.buf[this.pos]) << 7 * i) >>> 0, this.buf[this.pos++] < 128) return t; if (t.lo = (t.lo | (127 & this.buf[this.pos]) << 28) >>> 0, t.hi = (t.hi | (127 & this.buf[this.pos]) >> 4) >>> 0, this.buf[this.pos++] < 128) return t; if (i = 0, 4 < this.len - this.pos) { for (; i < 5; ++i)if (t.hi = (t.hi | (127 & this.buf[this.pos]) << 7 * i + 3) >>> 0, this.buf[this.pos++] < 128) return t } else for (; i < 5; ++i) { if (this.pos >= this.len) throw u(this); if (t.hi = (t.hi | (127 & this.buf[this.pos]) << 7 * i + 3) >>> 0, this.buf[this.pos++] < 128) return t } throw Error("invalid varint encoding") } function v(t, i) { return (t[i - 4] | t[i - 3] << 8 | t[i - 2] << 16 | t[i - 1] << 24) >>> 0 } function d() { if (this.pos + 8 > this.len) throw u(this, 8); return new s(v(this.buf, this.pos += 4), v(this.buf, this.pos += 4)) } f.create = h(), f.prototype.c = e.Array.prototype.subarray || e.Array.prototype.slice, f.prototype.uint32 = (a = 4294967295, function () { if (a = (127 & this.buf[this.pos]) >>> 0, this.buf[this.pos++] < 128) return a; if (a = (a | (127 & this.buf[this.pos]) << 7) >>> 0, this.buf[this.pos++] < 128) return a; if (a = (a | (127 & this.buf[this.pos]) << 14) >>> 0, this.buf[this.pos++] < 128) return a; if (a = (a | (127 & this.buf[this.pos]) << 21) >>> 0, this.buf[this.pos++] < 128) return a; if (a = (a | (15 & this.buf[this.pos]) << 28) >>> 0, this.buf[this.pos++] < 128) return a; if ((this.pos += 5) > this.len) throw this.pos = this.len, u(this, 10); return a }), f.prototype.int32 = function () { return 0 | this.uint32() }, f.prototype.sint32 = function () { var t = this.uint32(); return t >>> 1 ^ -(1 & t) | 0 }, f.prototype.bool = function () { return 0 !== this.uint32() }, f.prototype.fixed32 = function () { if (this.pos + 4 > this.len) throw u(this, 4); return v(this.buf, this.pos += 4) }, f.prototype.sfixed32 = function () { if (this.pos + 4 > this.len) throw u(this, 4); return 0 | v(this.buf, this.pos += 4) }, f.prototype.float = function () { if (this.pos + 4 > this.len) throw u(this, 4); var t = e.float.readFloatLE(this.buf, this.pos); return this.pos += 4, t }, f.prototype.double = function () { if (this.pos + 8 > this.len) throw u(this, 4); var t = e.float.readDoubleLE(this.buf, this.pos); return this.pos += 8, t }, f.prototype.bytes = function () { var t = this.uint32(), i = this.pos, n = this.pos + t; if (n > this.len) throw u(this, t); return this.pos += t, Array.isArray(this.buf) ? this.buf.slice(i, n) : i === n ? new this.buf.constructor(0) : this.c.call(this.buf, i, n) }, f.prototype.string = function () { var t = this.bytes(); return o.read(t, 0, t.length) }, f.prototype.skip = function (t) { if ("number" == typeof t) { if (this.pos + t > this.len) throw u(this, t); this.pos += t } else do { if (this.pos >= this.len) throw u(this) } while (128 & this.buf[this.pos++]); return this }, f.prototype.skipType = function (t) { switch (t) { case 0: this.skip(); break; case 1: this.skip(8); break; case 2: this.skip(this.uint32()); break; case 3: for (; 4 != (t = 7 & this.uint32());)this.skipType(t); break; case 5: this.skip(4); break; default: throw Error("invalid wire type " + t + " at offset " + this.pos) }return this }, f.u = function (t) { r = t, f.create = h(), r.u(); var i = e.Long ? "toLong" : "toNumber"; e.merge(f.prototype, { int64: function () { return l.call(this)[i](!1) }, uint64: function () { return l.call(this)[i](!0) }, sint64: function () { return l.call(this).zzDecode()[i](!1) }, fixed64: function () { return d.call(this)[i](!0) }, sfixed64: function () { return d.call(this)[i](!1) } }) } }, { 39: 39 }], 28: [function (t, i, n) { i.exports = s; var r = t(27); (s.prototype = Object.create(r.prototype)).constructor = s; var e = t(39); function s(t) { r.call(this, t) } s.u = function () { e.Buffer && (s.prototype.c = e.Buffer.prototype.slice) }, s.prototype.string = function () { var t = this.uint32(); return this.buf.utf8Slice ? this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + t, this.len)) : this.buf.toString("utf-8", this.pos, this.pos = Math.min(this.pos + t, this.len)) }, s.u() }, { 27: 27, 39: 39 }], 29: [function (t, i, n) { i.exports = f; var r = t(23); ((f.prototype = Object.create(r.prototype)).constructor = f).className = "Root"; var e, v, d, s = t(16), o = t(15), u = t(25), p = t(37); function f(t) { r.call(this, "", t), this.deferred = [], this.files = [] } function b() { } f.fromJSON = function (t, i) { return i = i || new f, t.options && i.setOptions(t.options), i.addJSON(t.nested) }, f.prototype.resolvePath = p.path.resolve, f.prototype.fetch = p.fetch, f.prototype.load = function t(i, s, e) { "function" == typeof s && (e = s, s = Q); var o = this; if (!e) return p.asPromise(t, o, i, s); var u = e === b; function f(t, i) { if (e) { var n = e; if (e = null, u) throw t; n(t, i) } } function h(t) { var i = t.lastIndexOf("google/protobuf/"); if (-1 < i) { i = t.substring(i); if (i in d) return i } return null } function a(t, i) { try { if (p.isString(i) && "{" == (i[0] || "") && (i = JSON.parse(i)), p.isString(i)) { v.filename = t; var n, r = v(i, o, s), e = 0; if (r.imports) for (; e < r.imports.length; ++e)(n = h(r.imports[e]) || o.resolvePath(t, r.imports[e])) && c(n); if (r.weakImports) for (e = 0; e < r.weakImports.length; ++e)(n = h(r.weakImports[e]) || o.resolvePath(t, r.weakImports[e])) && c(n, !0) } else o.setOptions(i.options).addJSON(i.nested) } catch (t) { f(t) } u || l || f(null, o) } function c(n, r) { if (!~o.files.indexOf(n)) if (o.files.push(n), n in d) u ? a(n, d[n]) : (++l, setTimeout(function () { --l, a(n, d[n]) })); else if (u) { var t; try { t = p.fs.readFileSync(n).toString("utf8") } catch (t) { return void (r || f(t)) } a(n, t) } else ++l, o.fetch(n, function (t, i) { --l, e && (t ? r ? l || f(null, o) : f(t) : a(n, i)) }) } var l = 0; p.isString(i) && (i = [i]); for (var n, r = 0; r < i.length; ++r)(n = o.resolvePath("", i[r])) && c(n); return u ? o : (l || f(null, o), Q) }, f.prototype.loadSync = function (t, i) { if (!p.isNode) throw Error("not supported"); return this.load(t, i, b) }, f.prototype.resolveAll = function () { if (this.deferred.length) throw Error("unresolvable extensions: " + this.deferred.map(function (t) { return "'extend " + t.extend + "' in " + t.parent.fullName }).join(", ")); return r.prototype.resolveAll.call(this) }; var h = /^[A-Z]/; function a(t, i) { var n = i.parent.lookup(i.extend); if (n) { var r = new s(i.fullName, i.id, i.type, i.rule, Q, i.options); return (r.declaringField = i).extensionField = r, n.add(r), 1 } } f.prototype.h = function (t) { if (t instanceof s) t.extend === Q || t.extensionField || a(0, t) || this.deferred.push(t); else if (t instanceof o) h.test(t.name) && (t.parent[t.name] = t.values); else if (!(t instanceof u)) { if (t instanceof e) for (var i = 0; i < this.deferred.length;)a(0, this.deferred[i]) ? this.deferred.splice(i, 1) : ++i; for (var n = 0; n < t.nestedArray.length; ++n)this.h(t.f[n]); h.test(t.name) && (t.parent[t.name] = t) } }, f.prototype.a = function (t) { var i; if (t instanceof s) t.extend !== Q && (t.extensionField ? (t.extensionField.parent.remove(t.extensionField), t.extensionField = null) : -1 < (i = this.deferred.indexOf(t)) && this.deferred.splice(i, 1)); else if (t instanceof o) h.test(t.name) && delete t.parent[t.name]; else if (t instanceof r) { for (var n = 0; n < t.nestedArray.length; ++n)this.a(t.f[n]); h.test(t.name) && delete t.parent[t.name] } }, f.u = function (t, i, n) { e = t, v = i, d = n } }, { 15: 15, 16: 16, 23: 23, 25: 25, 37: 37 }], 30: [function (t, i, n) { i.exports = {} }, {}], 31: [function (t, i, n) { n.Service = t(32) }, { 32: 32 }], 32: [function (t, i, n) { i.exports = r; var u = t(39); function r(t, i, n) { if ("function" != typeof t) throw TypeError("rpcImpl must be a function"); u.EventEmitter.call(this), this.rpcImpl = t, this.requestDelimited = !!i, this.responseDelimited = !!n } ((r.prototype = Object.create(u.EventEmitter.prototype)).constructor = r).prototype.rpcCall = function t(n, i, r, e, s) { if (!e) throw TypeError("request must be specified"); var o = this; if (!s) return u.asPromise(t, o, n, i, r, e); if (!o.rpcImpl) return setTimeout(function () { s(Error("already ended")) }, 0), Q; try { return o.rpcImpl(n, i[o.requestDelimited ? "encodeDelimited" : "encode"](e).finish(), function (t, i) { if (t) return o.emit("error", t, n), s(t); if (null === i) return o.end(!0), Q; if (!(i instanceof r)) try { i = r[o.responseDelimited ? "decodeDelimited" : "decode"](i) } catch (t) { return o.emit("error", t, n), s(t) } return o.emit("data", i, n), s(null, i) }) } catch (t) { return o.emit("error", t, n), setTimeout(function () { s(t) }, 0), Q } }, r.prototype.end = function (t) { return this.rpcImpl && (t || this.rpcImpl(null, null, null), this.rpcImpl = null, this.emit("end").off()), this } }, { 39: 39 }], 33: [function (t, i, n) { i.exports = o; var r = t(23); ((o.prototype = Object.create(r.prototype)).constructor = o).className = "Service"; var s = t(22), u = t(37), f = t(31); function o(t, i) { r.call(this, t, i), this.methods = {}, this.l = null } function e(t) { return t.l = null, t } o.fromJSON = function (t, i) { var n = new o(t, i.options); if (i.methods) for (var r = Object.keys(i.methods), e = 0; e < r.length; ++e)n.add(s.fromJSON(r[e], i.methods[r[e]])); return i.nested && n.addJSON(i.nested), n.comment = i.comment, n }, o.prototype.toJSON = function (t) { var i = r.prototype.toJSON.call(this, t), n = !!t && !!t.keepComments; return u.toObject(["options", i && i.options || Q, "methods", r.arrayToJSON(this.methodsArray, t) || {}, "nested", i && i.nested || Q, "comment", n ? this.comment : Q]) }, Object.defineProperty(o.prototype, "methodsArray", { get: function () { return this.l || (this.l = u.toArray(this.methods)) } }), o.prototype.get = function (t) { return this.methods[t] || r.prototype.get.call(this, t) }, o.prototype.resolveAll = function () { for (var t = this.methodsArray, i = 0; i < t.length; ++i)t[i].resolve(); return r.prototype.resolve.call(this) }, o.prototype.add = function (t) { if (this.get(t.name)) throw Error("duplicate name '" + t.name + "' in " + this); return t instanceof s ? e((this.methods[t.name] = t).parent = this) : r.prototype.add.call(this, t) }, o.prototype.remove = function (t) { if (t instanceof s) { if (this.methods[t.name] !== t) throw Error(t + " is not a member of " + this); return delete this.methods[t.name], t.parent = null, e(this) } return r.prototype.remove.call(this, t) }, o.prototype.create = function (t, i, n) { for (var r, e = new f.Service(t, i, n), s = 0; s < this.methodsArray.length; ++s) { var o = u.lcFirst((r = this.l[s]).resolve().name).replace(/[^$\w_]/g, ""); e[o] = u.codegen(["r", "c"], u.isReserved(o) ? o + "_" : o)("return this.rpcCall(m,q,s,r,c)")({ m: r, q: r.resolvedRequestType.ctor, s: r.resolvedResponseType.ctor }) } return e } }, { 22: 22, 23: 23, 31: 31, 37: 37 }], 34: [function (t, i, n) { i.exports = s; var A = /[\s{}=;:[\],'"()<>]/g, x = /(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g, T = /(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g, S = /^ *[*/]+ */, N = /^\s*\*?\/*/, V = /\n/g, $ = /\s/, r = /\\(.?)/g, e = { 0: "\0", r: "\r", n: "\n", t: "\t" }; function M(t) { return t.replace(r, function (t, i) { switch (i) { case "\\": case "": return i; default: return e[i] || "" } }) } function s(f, h) { f = f.toString(); var a = 0, c = f.length, l = 1, u = null, v = null, d = 0, p = !1, b = !1, w = [], y = null; function m(t) { return Error("illegal " + t + " (line " + l + ")") } function g(t) { return f[0 | t] || "" } function j(t, i, n) { u = f[0 | t++] || "", d = l, p = !1, b = n; var r, e = t - (h ? 2 : 3); do { if (--e < 0 || "\n" == (r = f[0 | e] || "")) { p = !0; break } } while (" " === r || "\t" === r); for (var s = f.substring(t, i).split(V), o = 0; o < s.length; ++o)s[o] = s[o].replace(h ? N : S, "").trim(); v = s.join("\n").trim() } function k(t) { var i = O(t), i = f.substring(t, i); return /^\s*\/{1,2}/.test(i) } function O(t) { for (var i = t; i < c && "\n" !== g(i);)i++; return i } function r() { if (0 < w.length) return w.shift(); if (y) return function () { var t = "'" === y ? T : x; t.lastIndex = a - 1; var i = t.exec(f); if (!i) throw m("string"); return a = t.lastIndex, E(y), y = null, M(i[1]) }(); var t, i, n, r, e, s = 0 === a; do { if (a === c) return null; for (t = !1; $.test(n = g(a));)if ("\n" === n && (s = !0, ++l), ++a === c) return null; if ("/" === g(a)) { if (++a === c) throw m("comment"); if ("/" === g(a)) if (h) { if (e = !1, k(r = a)) for (e = !0; (a = O(a)) !== c && k(++a);); else a = Math.min(c, O(a) + 1); e && j(r, a, s), l++, t = !0 } else { for (e = "/" === g(r = a + 1); "\n" !== g(++a);)if (a === c) return null; ++a, e && j(r, a - 1, s), ++l, t = !0 } else { if ("*" !== (n = g(a))) return "/"; r = a + 1, e = h || "*" === g(r); do { if ("\n" === n && ++l, ++a === c) throw m("comment") } while (i = n, n = g(a), "*" !== i || "/" !== n); ++a, e && j(r, a - 2, s), t = !0 } } } while (t); var o = a; if (A.lastIndex = 0, !A.test(g(o++))) for (; o < c && !A.test(g(o));)++o; var u = f.substring(a, a = o); return '"' != u && "'" != u || (y = u), u } function E(t) { w.push(t) } function e() { if (!w.length) { var t = r(); if (null === t) return null; E(t) } return w[0] } return Object.defineProperty({ next: r, peek: e, push: E, skip: function (t, i) { var n = e(); if (n === t) return r(), !0; if (!i) throw m("token '" + n + "', '" + t + "' expected"); return !1 }, cmnt: function (t) { var i = null; return t === Q ? d === l - 1 && (h || "*" === u || p) && (i = b ? v : null) : (d < t && e(), d !== t || p || !h && "/" !== u || (i = b ? null : v)), i } }, "line", { get: function () { return l } }) } s.unescape = M }, {}], 35: [function (t, i, n) { i.exports = m; var o = t(23); ((m.prototype = Object.create(o.prototype)).constructor = m).className = "Type"; var u = t(15), f = t(25), h = t(16), a = t(20), c = t(33), e = t(21), s = t(27), l = t(42), v = t(37), d = t(14), p = t(13), b = t(40), w = t(12), y = t(41); function m(t, i) { o.call(this, t, i), this.fields = {}, this.oneofs = Q, this.extensions = Q, this.reserved = Q, this.group = Q, this.v = null, this.e = null, this.p = null, this.b = null } function r(t) { return t.v = t.e = t.p = null, delete t.encode, delete t.decode, delete t.verify, t } Object.defineProperties(m.prototype, { fieldsById: { get: function () { if (this.v) return this.v; this.v = {}; for (var t = Object.keys(this.fields), i = 0; i < t.length; ++i) { var n = this.fields[t[i]], r = n.id; if (this.v[r]) throw Error("duplicate id " + r + " in " + this); this.v[r] = n } return this.v } }, fieldsArray: { get: function () { return this.e || (this.e = v.toArray(this.fields)) } }, oneofsArray: { get: function () { return this.p || (this.p = v.toArray(this.oneofs)) } }, ctor: { get: function () { return this.b || (this.ctor = m.generateConstructor(this)()) }, set: function (t) { var i = t.prototype; i instanceof e || ((t.prototype = new e).constructor = t, v.merge(t.prototype, i)), t.$type = t.prototype.$type = this, v.merge(t, e, !0), this.b = t; for (var n = 0; n < this.fieldsArray.length; ++n)this.e[n].resolve(); for (var r = {}, n = 0; n < this.oneofsArray.length; ++n)r[this.p[n].resolve().name] = { get: v.oneOfGetter(this.p[n].oneof), set: v.oneOfSetter(this.p[n].oneof) }; n && Object.defineProperties(t.prototype, r) } } }), m.generateConstructor = function (t) { for (var i, n = v.codegen(["p"], t.name), r = 0; r < t.fieldsArray.length; ++r)(i = t.e[r]).map ? n("this%s={}", v.safeProp(i.name)) : i.repeated && n("this%s=[]", v.safeProp(i.name)); return n("if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)")("this[ks[i]]=p[ks[i]]") }, m.fromJSON = function (t, i) { var n = new m(t, i.options); n.extensions = i.extensions, n.reserved = i.reserved; for (var r = Object.keys(i.fields), e = 0; e < r.length; ++e)n.add((void 0 !== i.fields[r[e]].keyType ? a : h).fromJSON(r[e], i.fields[r[e]])); if (i.oneofs) for (r = Object.keys(i.oneofs), e = 0; e < r.length; ++e)n.add(f.fromJSON(r[e], i.oneofs[r[e]])); if (i.nested) for (r = Object.keys(i.nested), e = 0; e < r.length; ++e) { var s = i.nested[r[e]]; n.add((s.id !== Q ? h : s.fields !== Q ? m : s.values !== Q ? u : s.methods !== Q ? c : o).fromJSON(r[e], s)) } return i.extensions && i.extensions.length && (n.extensions = i.extensions), i.reserved && i.reserved.length && (n.reserved = i.reserved), i.group && (n.group = !0), i.comment && (n.comment = i.comment), n }, m.prototype.toJSON = function (t) { var i = o.prototype.toJSON.call(this, t), n = !!t && !!t.keepComments; return v.toObject(["options", i && i.options || Q, "oneofs", o.arrayToJSON(this.oneofsArray, t), "fields", o.arrayToJSON(this.fieldsArray.filter(function (t) { return !t.declaringField }), t) || {}, "extensions", this.extensions && this.extensions.length ? this.extensions : Q, "reserved", this.reserved && this.reserved.length ? this.reserved : Q, "group", this.group || Q, "nested", i && i.nested || Q, "comment", n ? this.comment : Q]) }, m.prototype.resolveAll = function () { for (var t = this.fieldsArray, i = 0; i < t.length;)t[i++].resolve(); for (var n = this.oneofsArray, i = 0; i < n.length;)n[i++].resolve(); return o.prototype.resolveAll.call(this) }, m.prototype.get = function (t) { return this.fields[t] || this.oneofs && this.oneofs[t] || this.nested && this.nested[t] || null }, m.prototype.add = function (t) { if (this.get(t.name)) throw Error("duplicate name '" + t.name + "' in " + this); if (t instanceof h && t.extend === Q) { if ((this.v || this.fieldsById)[t.id]) throw Error("duplicate id " + t.id + " in " + this); if (this.isReservedId(t.id)) throw Error("id " + t.id + " is reserved in " + this); if (this.isReservedName(t.name)) throw Error("name '" + t.name + "' is reserved in " + this); return t.parent && t.parent.remove(t), (this.fields[t.name] = t).message = this, t.onAdd(this), r(this) } return t instanceof f ? (this.oneofs || (this.oneofs = {}), (this.oneofs[t.name] = t).onAdd(this), r(this)) : o.prototype.add.call(this, t) }, m.prototype.remove = function (t) { if (t instanceof h && t.extend === Q) { if (!this.fields || this.fields[t.name] !== t) throw Error(t + " is not a member of " + this); return delete this.fields[t.name], t.parent = null, t.onRemove(this), r(this) } if (t instanceof f) { if (!this.oneofs || this.oneofs[t.name] !== t) throw Error(t + " is not a member of " + this); return delete this.oneofs[t.name], t.parent = null, t.onRemove(this), r(this) } return o.prototype.remove.call(this, t) }, m.prototype.isReservedId = function (t) { return o.isReservedId(this.reserved, t) }, m.prototype.isReservedName = function (t) { return o.isReservedName(this.reserved, t) }, m.prototype.create = function (t) { return new this.ctor(t) }, m.prototype.setup = function () { for (var t = this.fullName, i = [], n = 0; n < this.fieldsArray.length; ++n)i.push(this.e[n].resolve().resolvedType); this.encode = d(this)({ Writer: l, types: i, util: v }), this.decode = p(this)({ Reader: s, types: i, util: v }), this.verify = b(this)({ types: i, util: v }), this.fromObject = w.fromObject(this)({ types: i, util: v }), this.toObject = w.toObject(this)({ types: i, util: v }); var r = y[t]; return r && ((t = Object.create(this)).fromObject = this.fromObject, this.fromObject = r.fromObject.bind(t), t.toObject = this.toObject, this.toObject = r.toObject.bind(t)), this }, m.prototype.encode = function (t, i) { return this.setup().encode(t, i) }, m.prototype.encodeDelimited = function (t, i) { return this.encode(t, i && i.len ? i.fork() : i).ldelim() }, m.prototype.decode = function (t, i) { return this.setup().decode(t, i) }, m.prototype.decodeDelimited = function (t) { return t instanceof s || (t = s.create(t)), this.decode(t, t.uint32()) }, m.prototype.verify = function (t) { return this.setup().verify(t) }, m.prototype.fromObject = function (t) { return this.setup().fromObject(t) }, m.prototype.toObject = function (t, i) { return this.setup().toObject(t, i) }, m.d = function (i) { return function (t) { v.decorateType(t, i) } } }, { 12: 12, 13: 13, 14: 14, 15: 15, 16: 16, 20: 20, 21: 21, 23: 23, 25: 25, 27: 27, 33: 33, 37: 37, 40: 40, 41: 41, 42: 42 }], 36: [function (t, i, n) { var n = n, t = t(37), e = ["double", "float", "int32", "uint32", "sint32", "fixed32", "sfixed32", "int64", "uint64", "sint64", "fixed64", "sfixed64", "bool", "string", "bytes"]; function r(t, i) { var n = 0, r = {}; for (i |= 0; n < t.length;)r[e[n + i]] = t[n++]; return r } n.basic = r([1, 5, 0, 0, 0, 5, 5, 0, 0, 0, 1, 1, 0, 2, 2]), n.defaults = r([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, !1, "", t.emptyArray, null]), n.long = r([0, 0, 0, 1, 1], 7), n.mapKey = r([0, 0, 0, 5, 5, 0, 0, 0, 1, 1, 0, 2], 2), n.packed = r([1, 5, 0, 0, 0, 5, 5, 0, 0, 0, 1, 1, 0]) }, { 37: 37 }], 37: [function (n, t, i) { var r, e, s = t.exports = n(39), o = n(30); s.codegen = n(3), s.fetch = n(5), s.path = n(8), s.fs = s.inquire("fs"), s.toArray = function (t) { if (t) { for (var i = Object.keys(t), n = Array(i.length), r = 0; r < i.length;)n[r] = t[i[r++]]; return n } return [] }, s.toObject = function (t) { for (var i = {}, n = 0; n < t.length;) { var r = t[n++], e = t[n++]; e !== Q && (i[r] = e) } return i }; var u = /\\/g, f = /"/g; s.isReserved = function (t) { return /^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(t) }, s.safeProp = function (t) { return !/^[$\w_]+$/.test(t) || s.isReserved(t) ? '["' + t.replace(u, "\\\\").replace(f, '\\"') + '"]' : "." + t }, s.ucFirst = function (t) { return (t[0] || "").toUpperCase() + t.substring(1) }; var h = /_([a-z])/g; s.camelCase = function (t) { return t.substring(0, 1) + t.substring(1).replace(h, function (t, i) { return i.toUpperCase() }) }, s.compareFieldsById = function (t, i) { return t.id - i.id }, s.decorateType = function (t, i) { if (t.$type) return i && t.$type.name !== i && (s.decorateRoot.remove(t.$type), t.$type.name = i, s.decorateRoot.add(t.$type)), t.$type; i = new (r = r || n(35))(i || t.name); return s.decorateRoot.add(i), i.ctor = t, Object.defineProperty(t, "$type", { value: i, enumerable: !1 }), Object.defineProperty(t.prototype, "$type", { value: i, enumerable: !1 }), i }; var a = 0; s.decorateEnum = function (t) { if (t.$type) return t.$type; var i = new (e = e || n(15))("Enum" + a++, t); return s.decorateRoot.add(i), Object.defineProperty(t, "$type", { value: i, enumerable: !1 }), i }, s.setProperty = function (t, i, n) { if ("object" != typeof t) throw TypeError("dst must be an object"); if (!i) throw TypeError("path must be specified"); return function t(i, n, r) { var e = n.shift(); return 0 < n.length ? i[e] = t(i[e] || {}, n, r) : ((n = i[e]) && (r = [].concat(n).concat(r)), i[e] = r), i }(t, i = i.split("."), n) }, Object.defineProperty(s, "decorateRoot", { get: function () { return o.decorated || (o.decorated = new (n(29))) } }) }, { 15: 15, 29: 29, 3: 3, 30: 30, 35: 35, 39: 39, 5: 5, 8: 8 }], 38: [function (t, i, n) { i.exports = e; var r = t(39); function e(t, i) { this.lo = t >>> 0, this.hi = i >>> 0 } var s = e.zero = new e(0, 0); s.toNumber = function () { return 0 }, s.zzEncode = s.zzDecode = function () { return this }, s.length = function () { return 1 }; e.zeroHash = "\0\0\0\0\0\0\0\0"; e.fromNumber = function (t) { if (0 === t) return s; var i = t < 0, n = (t = i ? -t : t) >>> 0, t = (t - n) / 4294967296 >>> 0; return i && (t = ~t >>> 0, n = ~n >>> 0, 4294967295 < ++n && (n = 0, 4294967295 < ++t && (t = 0))), new e(n, t) }, e.from = function (t) { if ("number" == typeof t) return e.fromNumber(t); if (r.isString(t)) { if (!r.Long) return e.fromNumber(parseInt(t, 10)); t = r.Long.fromString(t) } return t.low || t.high ? new e(t.low >>> 0, t.high >>> 0) : s }, e.prototype.toNumber = function (t) { if (!t && this.hi >>> 31) { var i = 1 + ~this.lo >>> 0, t = ~this.hi >>> 0; return -(i + 4294967296 * (t = !i ? t + 1 >>> 0 : t)) } return this.lo + 4294967296 * this.hi }, e.prototype.toLong = function (t) { return r.Long ? new r.Long(0 | this.lo, 0 | this.hi, !!t) : { low: 0 | this.lo, high: 0 | this.hi, unsigned: !!t } }; var o = String.prototype.charCodeAt; e.fromHash = function (t) { return "\0\0\0\0\0\0\0\0" === t ? s : new e((o.call(t, 0) | o.call(t, 1) << 8 | o.call(t, 2) << 16 | o.call(t, 3) << 24) >>> 0, (o.call(t, 4) | o.call(t, 5) << 8 | o.call(t, 6) << 16 | o.call(t, 7) << 24) >>> 0) }, e.prototype.toHash = function () { return String.fromCharCode(255 & this.lo, this.lo >>> 8 & 255, this.lo >>> 16 & 255, this.lo >>> 24, 255 & this.hi, this.hi >>> 8 & 255, this.hi >>> 16 & 255, this.hi >>> 24) }, e.prototype.zzEncode = function () { var t = this.hi >> 31; return this.hi = ((this.hi << 1 | this.lo >>> 31) ^ t) >>> 0, this.lo = (this.lo << 1 ^ t) >>> 0, this }, e.prototype.zzDecode = function () { var t = -(1 & this.lo); return this.lo = ((this.lo >>> 1 | this.hi << 31) ^ t) >>> 0, this.hi = (this.hi >>> 1 ^ t) >>> 0, this }, e.prototype.length = function () { var t = this.lo, i = (this.lo >>> 28 | this.hi << 4) >>> 0, n = this.hi >>> 24; return 0 == n ? 0 == i ? t < 16384 ? t < 128 ? 1 : 2 : t < 2097152 ? 3 : 4 : i < 16384 ? i < 128 ? 5 : 6 : i < 2097152 ? 7 : 8 : n < 128 ? 9 : 10 } }, { 39: 39 }], 39: [function (t, i, n) { var r = n; function e(t, i, n) { for (var r = Object.keys(i), e = 0; e < r.length; ++e)t[r[e]] !== Q && n || (t[r[e]] = i[r[e]]); return t } function s(t) { function n(t, i) { if (!(this instanceof n)) return new n(t, i); Object.defineProperty(this, "message", { get: function () { return t } }), Error.captureStackTrace ? Error.captureStackTrace(this, n) : Object.defineProperty(this, "stack", { value: Error().stack || "" }), i && e(this, i) } return (n.prototype = Object.create(Error.prototype)).constructor = n, Object.defineProperty(n.prototype, "name", { get: function () { return t } }), n.prototype.toString = function () { return this.name + ": " + this.message }, n } r.asPromise = t(1), r.base64 = t(2), r.EventEmitter = t(4), r.float = t(6), r.inquire = t(7), r.utf8 = t(10), r.pool = t(9), r.LongBits = t(38), r.isNode = !!("undefined" != typeof global && global && global.process && global.process.versions && global.process.versions.node), r.global = r.isNode && global || "undefined" != typeof window && window || "undefined" != typeof self && self || this, r.emptyArray = Object.freeze ? Object.freeze([]) : [], r.emptyObject = Object.freeze ? Object.freeze({}) : {}, r.isInteger = Number.isInteger || function (t) { return "number" == typeof t && isFinite(t) && Math.floor(t) === t }, r.isString = function (t) { return "string" == typeof t || t instanceof String }, r.isObject = function (t) { return t && "object" == typeof t }, r.isset = r.isSet = function (t, i) { var n = t[i]; return null != n && t.hasOwnProperty(i) && ("object" != typeof n || 0 < (Array.isArray(n) ? n : Object.keys(n)).length) }, r.Buffer = function () { try { var t = r.inquire("buffer").Buffer; return t.prototype.utf8Write ? t : null } catch (t) { return null } }(), r.w = null, r.y = null, r.newBuffer = function (t) { return "number" == typeof t ? r.Buffer ? r.y(t) : new r.Array(t) : r.Buffer ? r.w(t) : "undefined" == typeof Uint8Array ? t : new Uint8Array(t) }, r.Array = "undefined" != typeof Uint8Array ? Uint8Array : Array, r.Long = r.global.dcodeIO && r.global.dcodeIO.Long || r.global.Long || r.inquire("long"), r.key2Re = /^true|false|0|1$/, r.key32Re = /^-?(?:0|[1-9][0-9]*)$/, r.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/, r.longToHash = function (t) { return t ? r.LongBits.from(t).toHash() : r.LongBits.zeroHash }, r.longFromHash = function (t, i) { t = r.LongBits.fromHash(t); return r.Long ? r.Long.fromBits(t.lo, t.hi, i) : t.toNumber(!!i) }, r.merge = e, r.lcFirst = function (t) { return (t[0] || "").toLowerCase() + t.substring(1) }, r.newError = s, r.ProtocolError = s("ProtocolError"), r.oneOfGetter = function (t) { for (var n = {}, i = 0; i < t.length; ++i)n[t[i]] = 1; return function () { for (var t = Object.keys(this), i = t.length - 1; -1 < i; --i)if (1 === n[t[i]] && this[t[i]] !== Q && null !== this[t[i]]) return t[i] } }, r.oneOfSetter = function (n) { return function (t) { for (var i = 0; i < n.length; ++i)n[i] !== t && delete this[n[i]] } }, r.toJSONOptions = { longs: String, enums: String, bytes: String, json: !0 }, r.u = function () { var n = r.Buffer; n ? (r.w = n.from !== Uint8Array.from && n.from || function (t, i) { return new n(t, i) }, r.y = n.allocUnsafe || function (t) { return new n(t) }) : r.w = r.y = null } }, { 1: 1, 10: 10, 2: 2, 38: 38, 4: 4, 6: 6, 7: 7, 9: 9 }], 40: [function (t, i, n) { i.exports = function (t) { var i = f.codegen(["m"], t.name + "$verify")('if(typeof m!=="object"||m===null)')("return%j", "object expected"), n = t.oneofsArray, r = {}; n.length && i("var p={}"); for (var e = 0; e < t.fieldsArray.length; ++e) { var s, o = t.e[e].resolve(), u = "m" + f.safeProp(o.name); o.optional && i("if(%s!=null&&m.hasOwnProperty(%j)){", u, o.name), o.map ? (i("if(!util.isObject(%s))", u)("return%j", h(o, "object"))("var k=Object.keys(%s)", u)("for(var i=0;i<k.length;++i){"), function (t, i, n) { switch (i.keyType) { case "int32": case "uint32": case "sint32": case "fixed32": case "sfixed32": t("if(!util.key32Re.test(%s))", n)("return%j", h(i, "integer key")); break; case "int64": case "uint64": case "sint64": case "fixed64": case "sfixed64": t("if(!util.key64Re.test(%s))", n)("return%j", h(i, "integer|Long key")); break; case "bool": t("if(!util.key2Re.test(%s))", n)("return%j", h(i, "boolean key")) } }(i, o, "k[i]"), a(i, o, e, u + "[k[i]]")("}")) : o.repeated ? (i("if(!Array.isArray(%s))", u)("return%j", h(o, "array"))("for(var i=0;i<%s.length;++i){", u), a(i, o, e, u + "[i]")("}")) : (o.partOf && (s = f.safeProp(o.partOf.name), 1 === r[o.partOf.name] && i("if(p%s===1)", s)("return%j", o.partOf.name + ": multiple values"), r[o.partOf.name] = 1, i("p%s=1", s)), a(i, o, e, u)), o.optional && i("}") } return i("return null") }; var o = t(15), f = t(37); function h(t, i) { return t.name + ": " + i + (t.repeated && "array" !== i ? "[]" : t.map && "object" !== i ? "{k:" + t.keyType + "}" : "") + " expected" } function a(t, i, n, r) { if (i.resolvedType) if (i.resolvedType instanceof o) { t("switch(%s){", r)("default:")("return%j", h(i, "enum value")); for (var e = Object.keys(i.resolvedType.values), s = 0; s < e.length; ++s)t("case %i:", i.resolvedType.values[e[s]]); t("break")("}") } else t("{")("var e=types[%i].verify(%s);", n, r)("if(e)")("return%j+e", i.name + ".")("}"); else switch (i.type) { case "int32": case "uint32": case "sint32": case "fixed32": case "sfixed32": t("if(!util.isInteger(%s))", r)("return%j", h(i, "integer")); break; case "int64": case "uint64": case "sint64": case "fixed64": case "sfixed64": t("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))", r, r, r, r)("return%j", h(i, "integer|Long")); break; case "float": case "double": t('if(typeof %s!=="number")', r)("return%j", h(i, "number")); break; case "bool": t('if(typeof %s!=="boolean")', r)("return%j", h(i, "boolean")); break; case "string": t("if(!util.isString(%s))", r)("return%j", h(i, "string")); break; case "bytes": t('if(!(%s&&typeof %s.length==="number"||util.isString(%s)))', r, r, r)("return%j", h(i, "buffer")) }return t } }, { 15: 15, 37: 37 }], 41: [function (t, i, n) { var n = n, s = t(21); n[".google.protobuf.Any"] = { fromObject: function (t) { if (t && t["@type"]) { var i = t["@type"].substring(1 + t["@type"].lastIndexOf("/")), n = this.lookup(i); if (n) { i = "." == (t["@type"][0] || "") ? t["@type"].substr(1) : t["@type"]; return ~i.indexOf("/") || (i = "/" + i), this.create({ type_url: i, value: n.encode(n.fromObject(t)).finish() }) } } return this.fromObject(t) }, toObject: function (t, i) { var n, r = "", e = ""; if (i && i.json && t.type_url && t.value && (e = t.type_url.substring(1 + t.type_url.lastIndexOf("/")), r = t.type_url.substring(0, 1 + t.type_url.lastIndexOf("/")), (n = this.lookup(e)) && (t = n.decode(t.value))), t instanceof this.ctor || !(t instanceof s)) return this.toObject(t, i); i = t.$type.toObject(t, i), t = "." === t.$type.fullName[0] ? t.$type.fullName.substr(1) : t.$type.fullName; return i["@type"] = e = (r = "" === r ? "type.googleapis.com/" : r) + t, i } } }, { 21: 21 }], 42: [function (t, i, n) { i.exports = c; var r, e = t(39), s = e.LongBits, o = e.base64, u = e.utf8; function f(t, i, n) { this.fn = t, this.len = i, this.next = Q, this.val = n } function h() { } function a(t) { this.head = t.head, this.tail = t.tail, this.len = t.len, this.next = t.states } function c() { this.len = 0, this.head = new f(h, 0, 0), this.tail = this.head, this.states = null } function l() { return e.Buffer ? function () { return (c.create = function () { return new r })() } : function () { return new c } } function v(t, i, n) { i[n] = 255 & t } function d(t, i) { this.len = t, this.next = Q, this.val = i } function p(t, i, n) { for (; t.hi;)i[n++] = 127 & t.lo | 128, t.lo = (t.lo >>> 7 | t.hi << 25) >>> 0, t.hi >>>= 7; for (; 127 < t.lo;)i[n++] = 127 & t.lo | 128, t.lo = t.lo >>> 7; i[n++] = t.lo } function b(t, i, n) { i[n] = 255 & t, i[n + 1] = t >>> 8 & 255, i[n + 2] = t >>> 16 & 255, i[n + 3] = t >>> 24 } c.create = l(), c.alloc = function (t) { return new e.Array(t) }, e.Array !== Array && (c.alloc = e.pool(c.alloc, e.Array.prototype.subarray)), c.prototype.g = function (t, i, n) { return this.tail = this.tail.next = new f(t, i, n), this.len += i, this }, (d.prototype = Object.create(f.prototype)).fn = function (t, i, n) { for (; 127 < t;)i[n++] = 127 & t | 128, t >>>= 7; i[n] = t }, c.prototype.uint32 = function (t) { return this.len += (this.tail = this.tail.next = new d((t >>>= 0) < 128 ? 1 : t < 16384 ? 2 : t < 2097152 ? 3 : t < 268435456 ? 4 : 5, t)).len, this }, c.prototype.int32 = function (t) { return t < 0 ? this.g(p, 10, s.fromNumber(t)) : this.uint32(t) }, c.prototype.sint32 = function (t) { return this.uint32((t << 1 ^ t >> 31) >>> 0) }, c.prototype.int64 = c.prototype.uint64 = function (t) { t = s.from(t); return this.g(p, t.length(), t) }, c.prototype.sint64 = function (t) { t = s.from(t).zzEncode(); return this.g(p, t.length(), t) }, c.prototype.bool = function (t) { return this.g(v, 1, t ? 1 : 0) }, c.prototype.sfixed32 = c.prototype.fixed32 = function (t) { return this.g(b, 4, t >>> 0) }, c.prototype.sfixed64 = c.prototype.fixed64 = function (t) { t = s.from(t); return this.g(b, 4, t.lo).g(b, 4, t.hi) }, c.prototype.float = function (t) { return this.g(e.float.writeFloatLE, 4, t) }, c.prototype.double = function (t) { return this.g(e.float.writeDoubleLE, 8, t) }; var w = e.Array.prototype.set ? function (t, i, n) { i.set(t, n) } : function (t, i, n) { for (var r = 0; r < t.length; ++r)i[n + r] = t[r] }; c.prototype.bytes = function (t) { var i, n = t.length >>> 0; return n ? (e.isString(t) && (i = c.alloc(n = o.length(t)), o.decode(t, i, 0), t = i), this.uint32(n).g(w, n, t)) : this.g(v, 1, 0) }, c.prototype.string = function (t) { var i = u.length(t); return i ? this.uint32(i).g(u.write, i, t) : this.g(v, 1, 0) }, c.prototype.fork = function () { return this.states = new a(this), this.head = this.tail = new f(h, 0, 0), this.len = 0, this }, c.prototype.reset = function () { return this.states ? (this.head = this.states.head, this.tail = this.states.tail, this.len = this.states.len, this.states = this.states.next) : (this.head = this.tail = new f(h, 0, 0), this.len = 0), this }, c.prototype.ldelim = function () { var t = this.head, i = this.tail, n = this.len; return this.reset().uint32(n), n && (this.tail.next = t.next, this.tail = i, this.len += n), this }, c.prototype.finish = function () { for (var t = this.head.next, i = this.constructor.alloc(this.len), n = 0; t;)t.fn(t.val, i, n), n += t.len, t = t.next; return i }, c.u = function (t) { r = t, c.create = l(), r.u() } }, { 39: 39 }], 43: [function (t, i, n) { i.exports = s; var r = t(42); (s.prototype = Object.create(r.prototype)).constructor = s; var e = t(39); function s() { r.call(this) } function o(t, i, n) { t.length < 40 ? e.utf8.write(t, i, n) : i.utf8Write ? i.utf8Write(t, n) : i.write(t, n) } s.u = function () { s.alloc = e.y, s.writeBytesBuffer = e.Buffer && e.Buffer.prototype instanceof Uint8Array && "set" === e.Buffer.prototype.set.name ? function (t, i, n) { i.set(t, n) } : function (t, i, n) { if (t.copy) t.copy(i, n, 0, t.length); else for (var r = 0; r < t.length;)i[n++] = t[r++] } }, s.prototype.bytes = function (t) { var i = (t = e.isString(t) ? e.w(t, "base64") : t).length >>> 0; return this.uint32(i), i && this.g(s.writeBytesBuffer, i, t), this }, s.prototype.string = function (t) { var i = e.Buffer.byteLength(t); return this.uint32(i), i && this.g(o, i, t), this }, s.u() }, { 39: 39, 42: 42 }] }, e = {}, t = [19], i = function t(i) { var n = e[i]; return n || r[i][0].call(n = e[i] = { exports: {} }, t, n, n.exports), n.exports }(t[0]), i.util.global.protobuf = i, "function" == typeof define && define.amd && define(["long"], function (t) { return t && t.isLong && (i.util.Long = t, i.configure()), i }), "object" == typeof module && module && module.exports && (module.exports = i) }();
}

// 配置生成变量
let initProtobuf = () => {
    clear()
    if (!document.URL.startsWith('https://www.bilibili.com/')) { return }
    var jsonDescriptor = JSON.parse('{"nested":{"bilibili":{"nested":{"community":{"nested":{"service":{"nested":{"dm":{"nested":{"v1":{"nested":{"DmWebViewReply":{"fields":{"state":{"type":"int32","id":1},"text":{"type":"string","id":2},"textSide":{"type":"string","id":3},"dmSge":{"type":"DmSegConfig","id":4},"flag":{"type":"DanmakuFlagConfig","id":5},"specialDms":{"rule":"repeated","type":"string","id":6},"checkBox":{"type":"bool","id":7},"count":{"type":"int64","id":8},"commandDms":{"rule":"repeated","type":"CommandDm","id":9},"dmSetting":{"type":"DanmuWebPlayerConfig","id":10},"reportFilter":{"rule":"repeated","type":"string","id":11}}},"CommandDm":{"fields":{"id":{"type":"int64","id":1},"oid":{"type":"int64","id":2},"mid":{"type":"int64","id":3},"command":{"type":"string","id":4},"content":{"type":"string","id":5},"progress":{"type":"int32","id":6},"ctime":{"type":"string","id":7},"mtime":{"type":"string","id":8},"extra":{"type":"string","id":9},"idStr":{"type":"string","id":10}}},"DmSegConfig":{"fields":{"pageSize":{"type":"int64","id":1},"total":{"type":"int64","id":2}}},"DanmakuFlagConfig":{"fields":{"recFlag":{"type":"int32","id":1},"recText":{"type":"string","id":2},"recSwitch":{"type":"int32","id":3}}},"DmSegMobileReply":{"fields":{"elems":{"rule":"repeated","type":"DanmakuElem","id":1}}},"DanmakuElem":{"fields":{"id":{"type":"int64","id":1},"progress":{"type":"int32","id":2},"mode":{"type":"int32","id":3},"fontsize":{"type":"int32","id":4},"color":{"type":"uint32","id":5},"midHash":{"type":"string","id":6},"content":{"type":"string","id":7},"ctime":{"type":"int64","id":8},"weight":{"type":"int32","id":9},"action":{"type":"string","id":10},"pool":{"type":"int32","id":11},"idStr":{"type":"string","id":12},"attr":{"type":"int32","id":13}}},"DanmuWebPlayerConfig":{"fields":{"dmSwitch":{"type":"bool","id":1},"aiSwitch":{"type":"bool","id":2},"aiLevel":{"type":"int32","id":3},"blocktop":{"type":"bool","id":4},"blockscroll":{"type":"bool","id":5},"blockbottom":{"type":"bool","id":6},"blockcolor":{"type":"bool","id":7},"blockspecial":{"type":"bool","id":8},"preventshade":{"type":"bool","id":9},"dmask":{"type":"bool","id":10},"opacity":{"type":"float","id":11},"dmarea":{"type":"int32","id":12},"speedplus":{"type":"float","id":13},"fontsize":{"type":"float","id":14},"screensync":{"type":"bool","id":15},"speedsync":{"type":"bool","id":16},"fontfamily":{"type":"string","id":17},"bold":{"type":"bool","id":18},"fontborder":{"type":"int32","id":19},"drawType":{"type":"string","id":20}}}}}}}}}}}}}}}')
    let Root = window.protobuf.Root.fromJSON(jsonDescriptor);
    let message = Root.lookupType("bilibili.community.service.dm.v1.DmSegMobileReply")
    console.log('message已加载')
    // 创建下载弹幕div
    let downloadBox = document.createElement('div')
    downloadBox.setAttribute('class', 'danmuBox')
    downloadBox.setAttribute('id', 'danmuDownloadBox')
    downloadBox.innerHTML = `
    <div class="danmuTool">
        <span>
            <a id='danmuDownloadBtn'>下载弹幕</a>
        </span>
        <span id='danmuMore'>展开</span>
    </div>
    <div class="danmuContent" style="height: 0px">
        <div class="calendar">
            <div class="calendar-title-box">
                <div class="last-month">
                    <svg t="1625923239465" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2210"
                        width="20" height="20">
                        <path
                            d="M682.666667 810.666667a42.666667 42.666667 0 0 1-30.08-12.586667l-256-256a42.666667 42.666667 0 0 1 0-60.16l256-256a42.666667 42.666667 0 1 1 60.16 60.16L487.04 512l225.706667 225.92A42.666667 42.666667 0 0 1 682.666667 810.666667z"
                            fill="#333333" p-id="2211"></path>
                    </svg>
                </div>
                <div id="year-month"><div><span id="danmuYear"></span><span>&nbsp;年</span></div><div><span id="danmuMonth"></span><span>&nbsp;月</span></div></div>
                <div class="next-month">
                    <svg t="1625923704105" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1494"
                        width="20" height="20">
                        <path
                            d="M384 810.666667a42.666667 42.666667 0 0 1-30.08-72.746667L579.626667 512 353.92 286.08a42.666667 42.666667 0 0 1 60.16-60.16l256 256a42.666667 42.666667 0 0 1 0 60.16l-256 256A42.666667 42.666667 0 0 1 384 810.666667z"
                            fill="#333333" p-id="1495"></path>
                    </svg>
                </div>
            </div>
            <div class="calendar-date">
                <div class="week">
                    <span class="which-week">日</span>
                    <span class="which-week">一</span>
                    <span class="which-week">二</span>
                    <span class="which-week">三</span>
                    <span class="which-week">四</span>
                    <span class="which-week">五</span>
                    <span class="which-week">六</span>
                </div>
                <div class="day">
                </div>
            </div>
        </div>
    </div>
    `
    document.querySelector(bangumi ? '.plp-r' : '.r-con').insertBefore(downloadBox, document.querySelector('#danmukuBox'))
    let downloadBtn = document.querySelector('#danmuDownloadBtn')
    // 上一个月 下一个月按钮
    document.querySelector('.last-month').onclick = function () { changeMonth.call(this, message, downloadBtn) }
    document.querySelector('.next-month').onclick = function () { changeMonth.call(this, message, downloadBtn) }
    document.querySelector('.next-month').click()
    downloadBox.querySelector('#danmuMore').onclick = function () {
        let contentBox = document.querySelector('.danmuContent')
        if (this.textContent == '展开') {
            contentBox.style.height = 'calc(93px + 320px / 7 * 6)'
            this.textContent = '收起'
        } else {
            contentBox.style.height = '0px'
            this.textContent = '展开'
        }
    }
    GM_addStyle(`
        .danmuBox * {
            display: flex;
            font-family: -apple-system,BlinkMacSystemFont,Helvetica Neue,Helvetica,Arial,PingFang SC,Hiragino Sans GB,Microsoft YaHei,sans-serif;
            color: #222;
            user-select: none;
            box-sizing: border-box;
        }
        .danmuBox {
            flex-direction: column;
            align-items: center;
            width: 320px;
            margin: 20px 0px;
        }
        #danmuMore {
            font-size: 10px;
            cursor: pointer;
            color: #222;
        }
        #danmuDownloadBtn {
            cursor: pointer;
            font-size: 16px;
            color: #222;
        }
        .danmuTool {
            display: flex;
            justify-content: space-between;
            align-items: center;
            width: 320px;
            height: 46px;
            padding: 0px 16px 0px 16px;
            background-color: #f4f4f4;
        }
        .danmuContent {
            display: block;
            overflow: hidden;
            transition: height .3s;
        }
        /* 日历相关 */
        .calendar {
            flex-direction: column;
            align-items: center;
            border: 1px solid #e5e9ef;
            background-color: #fff;
            width: 320px;
        }
        .calendar-title-box {
            justify-content: space-around;
            padding: 0px 80px;
            height: 50px;
            /* border: 1px solid rgb(204, 74, 74); */
        }
        .calendar-date {
            width: 320px;
            align-items: center;
            flex-direction: column;
            border-top: 1px solid #e5e9ef;
        }
        #year-month {
            margin: auto;
            height: 20px;
            line-height: 20px;
            font-size: 16px;
            width: 95px;
            justify-content: space-between;
            /* border: 1px solid salmon; */
        }
        .last-month, .next-month {
            align-items: center;
            align-content: center;
            cursor: pointer;
        }
        .week {
            height: 30px;
            width: 100%;
            line-height: 30px;
            margin-bottom: 10px;
            /* border: 1px solid red; */
        }
        .day {
            width: 320px;
            flex-wrap: wrap;
        }
        .which-day, .which-week {
            display: inline-block;
            border-radius: 12.5px;
            color: #6d757a;
            text-align: center;
            padding: 0px;
            font-size: 16px;
            line-height: 25px;
            width: 25px;
            height: 25px;
            margin: calc((320px - 25 * 7px) / 14);
            cursor: pointer;
        }
        .which-week {
            font-size: 15px;
        }
        .which-day {
            color: #ccc;
        }
        span.which-day.support {
            color: black;
        }
        span.which-day.active {
            background-color: #fb7299;
            color: white;
        }
        `)

}

let main = setInterval(() => {
    try {
        dataQuery().then(
            () => {
                clearInterval(main)
                pageChange()
                initProtobuf()
            })
    } catch (err) {
        console.log('[ERROR] —— ' + err)
    }
}, 5000)