import{t as e}from"./ofetch-Dl6dVB_5.mjs";import{t}from"./config-BYRrjYC5.mjs";import{t as n}from"./config-not-found-B9AOp828.mjs";import{t as r}from"./cache-DCQ3KkFK.mjs";const i={path:`/message/unread/:uid`,categories:[`social-media`],example:`/bilibili/message/unread/2267573`,parameters:{uid:`用户 id`},features:{requireConfig:[{name:`BILIBILI_COOKIE_*`,description:"BILIBILI_COOKIE_{uid}: 用于用户关注动态系列路由，对应 uid 的 b 站用户登录后的 Cookie 值，`{uid}` 替换为 uid，如 `BILIBILI_COOKIE_2267573`，获取方式：\n    1.  打开 [https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=0&type=8](https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=0&type=8)\n    2.  打开控制台，切换到 Network 面板，刷新\n    3.  点击 dynamic_new 请求，找到 Cookie\n    4.  视频和专栏，UP 主粉丝及关注只要求 `SESSDATA` 字段，动态需复制整段 Cookie"}],requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1},name:`未读消息`,maintainers:[`pilgrimlyieu`],handler:a,description:`:::warning
  用户消息需要 b 站登录后的 Cookie 值，所以只能自建，详情见部署页面的配置模块。

  此路由返回所有未读消息类型的汇总状态。
:::`};async function a(i){let a=i.req.param(`uid`),o=await r.getUsernameFromUID(a),s=t.bilibili.cookies[a];if(s===void 0)throw new n(`缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值`);let[c,l]=await Promise.all([e(`https://api.vc.bilibili.com/x/im/web/msgfeed/unread`,{query:{build:0,mobi_app:`web`},headers:{Referer:`https://message.bilibili.com/`,Cookie:s}}),e(`https://api.vc.bilibili.com/session_svr/v1/session_svr/single_unread`,{query:{unread_type:0,show_dustbin:1,build:0,mobi_app:`web`},headers:{Referer:`https://message.bilibili.com/`,Cookie:s}})]);if(c.code!==0)throw Error(c.message??`Error code ${c.code}`);let u=c.data,d=l.data,f=[],p=new Date;if(u.recv_reply>0||u.reply>0){let e=u.recv_reply||u.reply;f.push({title:`回复我的：${e} 条未读`,description:`<p>你有 <strong>${e}</strong> 条未读回复消息</p><p><a href="https://message.bilibili.com/#/reply">点击查看</a></p>`,link:`https://message.bilibili.com/#/reply`,pubDate:p,guid:`bilibili-unread-reply-${a}-${e}`})}if(u.at>0&&f.push({title:`@我的：${u.at} 条未读`,description:`<p>你有 <strong>${u.at}</strong> 条未读@消息</p><p><a href="https://message.bilibili.com/#/at">点击查看</a></p>`,link:`https://message.bilibili.com/#/at`,pubDate:p,guid:`bilibili-unread-at-${a}-${u.at}`}),u.recv_like>0||u.like>0){let e=u.recv_like||u.like;f.push({title:`收到的赞：${e} 条未读`,description:`<p>你有 <strong>${e}</strong> 条未读点赞消息</p><p><a href="https://message.bilibili.com/#/love">点击查看</a></p>`,link:`https://message.bilibili.com/#/love`,pubDate:p,guid:`bilibili-unread-like-${a}-${e}`})}u.sys_msg>0&&f.push({title:`系统通知：${u.sys_msg} 条未读`,description:`<p>你有 <strong>${u.sys_msg}</strong> 条未读系统通知</p><p><a href="https://message.bilibili.com/#/system">点击查看</a></p>`,link:`https://message.bilibili.com/#/system`,pubDate:p,guid:`bilibili-unread-system-${a}-${u.sys_msg}`});let m=(d?.follow_unread||0)+(d?.unfollow_unread||0);return m>0&&f.push({title:`私信：${m} 条未读`,description:`<p>你有 <strong>${m}</strong> 条未读私信（已关注: ${d?.follow_unread||0}，未关注: ${d?.unfollow_unread||0}）</p><p><a href="https://message.bilibili.com/#/whisper">点击查看</a></p>`,link:`https://message.bilibili.com/#/whisper`,pubDate:p,guid:`bilibili-unread-session-${a}-${m}`}),u.coin>0&&f.push({title:`收到的投币：${u.coin} 条未读`,description:`<p>你有 <strong>${u.coin}</strong> 条未读投币消息</p>`,link:`https://message.bilibili.com/`,pubDate:p,guid:`bilibili-unread-coin-${a}-${u.coin}`}),u.favorite>0&&f.push({title:`收到的收藏：${u.favorite} 条未读`,description:`<p>你有 <strong>${u.favorite}</strong> 条未读收藏消息</p>`,link:`https://message.bilibili.com/`,pubDate:p,guid:`bilibili-unread-favorite-${a}-${u.favorite}`}),u.up>0&&f.push({title:`UP主助手：${u.up} 条未读`,description:`<p>你有 <strong>${u.up}</strong> 条未读UP主助手消息</p>`,link:`https://message.bilibili.com/`,pubDate:p,guid:`bilibili-unread-up-${a}-${u.up}`}),{title:`${o} 的 B站未读消息`,link:`https://message.bilibili.com/`,description:`${o} 的 B站未读消息汇总`,item:f,allowEmpty:!0}}export{i as route};