import{t as e}from"./cache-DUthuMSu.mjs";import{t}from"./parse-date-BdYTmLpo.mjs";import{t as n}from"./got-BBDj7u1e.mjs";import{n as r,t as i}from"./utils-DKemlon0.mjs";import{Fragment as a,jsx as o,jsxs as s}from"hono/jsx/jsx-runtime";import{load as c}from"cheerio";import{renderToString as l}from"hono/jsx/dom/server";import{raw as u}from"hono/html";const d=({images:e,intro:t,description:n})=>l(s(a,{children:[e?.length?e.map(e=>e?.src?o(`figure`,{children:o(`img`,{src:e.src,alt:e.alt})},e.src):null):null,t?o(`blockquote`,{children:t}):null,n?o(a,{children:u(n)}):null]})),f=async a=>{let{id:o=`1103`}=a.req.param(),s=a.req.query(`limit`)?Number.parseInt(a.req.query(`limit`),10):20,l=new URL(`subject/${o}`,r).href,u=new URL(`api/subject/${o}/article`,r).href,{data:f}=await n(u,{searchParams:i({Subject_Id:o})}),p=f.data.slice(0,s).map(e=>{let n=e.article_title,i=d({intro:e.article_brief}),a=`cls-${e.article_id}`,o=e.article_img;return{title:n,description:i,pubDate:t(e.article_time,`X`),link:new URL(`detail/${e.article_id}`,r).href,category:e.subjects.map(e=>e.subject_name),author:e.article_author,guid:a,id:a,content:{html:i,text:e.article_brief},image:o,banner:o}});p=await Promise.all(p.map(r=>e.tryGet(r.link,async()=>{let{data:e}=await n(r.link),i=c(e),a=JSON.parse(i(`script#__NEXT_DATA__`).text())?.props?.initialState?.detail?.articleDetail??void 0;if(!a)return r;let o=a.title,s=d({images:a.images.map(e=>({src:e,alt:o})),intro:a.brief,description:a.content}),l=`cls-${a.id}`,u=a.images?.[0]??void 0;return r.title=o,r.description=s,r.pubDate=t(a.ctime,`X`),r.category=[...new Set(a.subject?.flatMap(e=>[e.name,...e.subjectCategory?.flatMap(e=>[e.columnName||[],e.name||[]])??[]]))].filter(Boolean),r.author=a.author?.name??r.author,r.guid=l,r.id=l,r.content={html:s,text:a.content},r.image=u,r.banner=u,r.enclosure_url=a.audioUrl,r.enclosure_type=r.enclosure_url?`audio/${r.enclosure_url.split(/\./).pop()}`:void 0,r.enclosure_title=o,r})));let{data:m}=await n(l),h=c(m),g=JSON.parse(h(`script#__NEXT_DATA__`).text())?.props?.initialProps?.pageProps?.subjectDetail??void 0,_=`财联社`,v=g?.img??void 0;return{title:`${_} - ${g?.name??h(`title`).text()}`,description:g?.description??void 0,link:l,item:p,allowEmpty:!0,image:v,author:_}},p={path:`/subject/:id?`,name:`话题`,url:`www.cls.cn`,maintainers:[`nczitzk`],handler:f,example:`/cls/subject/1103`,parameters:{category:`分类，默认为 1103，即A股盘面直播，可在对应话题页 URL 中找到`},description:"::: tip\n  若订阅 [有声早报](https://www.cls.cn/subject/1151)，网址为 `https://www.cls.cn/subject/1151`。截取 `https://www.cls.cn/subject/` 到末尾的部分 `1151` 作为参数填入，此时路由为 [`/cls/subject/1151`](https://rsshub.app/cls/subject/1151)。\n:::\n    ",categories:[`finance`],features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportRadar:!0,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`www.cls.cn/subject/:id`],target:e=>{let t=e.id;return`/subject${t?`/${t}`:``}`}}]};export{f as handler,p as route};