import{t as e}from"./config-BYRrjYC5.mjs";import{t}from"./got-BBDj7u1e.mjs";import{t as n}from"./config-not-found-B9AOp828.mjs";import{Fragment as r,jsx as i,jsxs as a}from"hono/jsx/jsx-runtime";import{load as o}from"cheerio";import{renderToString as s}from"hono/jsx/dom/server";import{raw as c}from"hono/html";const l={path:`/trending/:since/:language/:spoken_language?`,categories:[`programming`],example:`/github/trending/daily/javascript/en`,view:5,parameters:{since:{description:`time range`,options:[{value:`daily`,label:`Today`},{value:`weekly`,label:`This week`},{value:`monthly`,label:`This month`}]},language:{description:"the feed language, available in [Trending page](https://github.com/trending/javascript?since=monthly) 's URL, don't filter option is `any`",default:`any`},spoken_language:{description:`natural language, available in [Trending page](https://github.com/trending/javascript?since=monthly) 's URL`}},features:{requireConfig:[{name:`GITHUB_ACCESS_TOKEN`,description:``}],requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`github.com/trending`],target:`/trending/:since`}],name:`Trending`,maintainers:[`DIYgod`,`jameschensmith`],handler:u,url:`github.com/trending`};async function u(l){if(!e.github||!e.github.access_token)throw new n(`GitHub trending RSS is disabled due to the lack of <a href="https://docs.rsshub.app/deploy/config#route-specific-configurations">relevant config</a>`);let u=l.req.param(`since`),d=l.req.param(`language`)===`any`?``:l.req.param(`language`),f=l.req.param(`spoken_language`)??``,p=`https://github.com/trending/${encodeURIComponent(d)}?since=${u}&spoken_language_code=${f}`,{data:m}=await t({method:`get`,url:p,headers:{Referer:p}}),h=o(m),g=h(`article`).toArray().map(e=>{let[t,n]=h(e).find(`h2`).text().split(`/`);return{name:n.trim(),owner:t.trim()}}),{data:_}=await t({method:`post`,url:`https://api.github.com/graphql`,headers:{Authorization:`bearer ${e.github.access_token}`},json:{query:`
            query {
            ${g.map((e,t)=>`
                _${t}: repository(owner: "${e.owner}", name: "${e.name}") {
                    ...RepositoryFragment
                }
            `).join(`
`)}
            }

            fragment RepositoryFragment on Repository {
                description
                forkCount
                nameWithOwner
                openGraphImageUrl
                primaryLanguage {
                    name
                }
                stargazerCount
            }
            `}}),v=Object.values(_.data).map(e=>({...g.find(t=>`${t.owner}/${t.name}`===e.nameWithOwner),...e}));return{title:h(`title`).text(),link:p,item:v.map(e=>({title:e.nameWithOwner,author:e.owner,description:s(a(r,{children:[i(`img`,{src:e.openGraphImageUrl}),i(`br`,{}),e.description?c(e.description):null,i(`br`,{}),i(`br`,{}),`Language: `,c(e.primaryLanguage?.name||`Unknown`),i(`br`,{}),`Stars: `,c(String(e.stargazerCount)),i(`br`,{}),`Forks: `,c(String(e.forkCount))]})),link:`https://github.com/${e.nameWithOwner}`}))}}export{l as route};