import{t as e}from"./ofetch-Dl6dVB_5.mjs";import{t}from"./cache-DUthuMSu.mjs";import{t as n}from"./parse-date-BdYTmLpo.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=async r=>{let{category:i,id:a}=r.req.param(),s=r.req.query(`limit`)?Number.parseInt(r.req.query(`limit`),10):50,c=`https://www.jiemian.com`,l=i||(a?`lists/${a}`:``),d=new URL(l?`${l}.html`:``,c).href,f=o(await e(d));f(`.sub-col-right`).remove();let p=f(`#lists`).length?f(`#lists`):f(`body`),m={},h=p.find(`a`).toArray();for(let e of h){let t=f(e),n=t.prop(`href`),r=n?n.startsWith(`/`)?new URL(n,c).href:n:void 0;r&&/\/(article|video)\/\w+\.html/.test(r)&&(m[r]={title:t.text(),link:r})}m=await Promise.all(Object.values(m).slice(0,s).map(r=>t.tryGet(r.link,async()=>{let t=o(await e(r.link)),i=t(`div.article-img img`).first(),a=t(`#video-player`).first();return r.title=t(`div.article-header h1`).eq(0).text(),r.description=u({image:i?{src:i.prop(`src`),alt:i.next(`p`).text()||r.title}:void 0,video:a?{src:a.prop(`data-url`),poster:a.prop(`data-poster`),width:a.prop(`width`),height:a.prop(`height`)}:void 0,intro:t(`div.article-header p`).text(),description:t(`div.article-content`).html()}),r.author=t(`span.author`).first().find(`a`).toArray().map(e=>t(e).text()).join(`/`),r.category=t(`meta.meta-container a`).toArray().map(e=>t(e).text()),r.pubDate=n(t(`div.article-info span[data-article-publish-time]`).prop(`data-article-publish-time`),`X`),r.upvotes=t(`span.opt-praise__count`).text()?Number.parseInt(t(`span.opt-praise__count`).text(),10):0,r.comments=t(`span.opt-comment__count`).text()?Number.parseInt(t(`span.opt-comment__count`).text(),10):0,r})));let g=f(`title`).text(),_=g.split(/_/),v=new URL(f(`link[rel="icon"]`).prop(`href`),c).href;return{item:m,title:g,link:d,description:f(`meta[name="description"]`).prop(`content`),language:f(`html`).prop(`lang`),image:v,icon:v,logo:v,subtitle:_[0],author:_.pop()}},u=({image:e,intro:t,video:n,description:o})=>{let l=e?.height??e?.width??e?.alt,u=n?.poster??e?.src;return s(a(r,{children:[!n?.src&&e?.src?i(`figure`,{children:i(`img`,{src:e.src,alt:l})}):null,t?i(`p`,{children:t}):null,n?.src?a(`video`,{poster:u,controls:!0,children:[i(`source`,{src:n.src,type:n.type}),i(`object`,{data:n.src,children:i(`embed`,{src:n.src})})]}):null,o?i(r,{children:c(o)}):null]}))};export{l as t};