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=({intro:e,description:t})=>a(r,{children:[e?i(`blockquote`,{children:e}):null,t?c(t):null]}),u=e=>s(i(l,{...e})),d=`https://www.tmtpost.com`,f=`https://api.tmtpost.com`,p=new URL(`v1/posts/`,f).href,m={"app-version":`web1.0`},h=async(r,i,a,s)=>{let c=await e(a,{query:{limit:r,...i},headers:m}),l=o(await e(s)),f=l(`html`).attr(`lang`)??`zh-CN`,h=c.data.slice(0,r).map(e=>{let t=e.title,r=u({intro:e.summary}),i=e.time_published,a=e.share_link,o=e.guid,s=e.thumb_image?.original?.url,c=e.updated??i;return{title:t,description:r,pubDate:i?n(i,`X`):void 0,link:a,guid:o,id:o,content:{html:r,text:e.content??r},image:s,banner:s,updated:c?n(c,`X`):void 0,language:f}});h=(await Promise.all(h.map(r=>r.link?t.tryGet(r.link,async()=>{let t=new URL(r.guid,p).href,i=(await e(t,{query:{fields:[`authors`,`tags`,`featured_image`,`categories`,`stock_list`,`big_plate`,`concept_plate`,`plate`,`plate_list`,`share_link`].join(`;`)},headers:m})).data;if(!i)return r;let a=i.title,o=u({intro:i.summary,description:i.main}),s=i.time_published,c=i.share_link,l=[...new Set([...i.categories??[],...i.stock_list??[],...i.big_plate??[],...i.concept_plate??[],...i.plate??[],...i.plate_list??[],...i.tags??[]].map(e=>e.title??e.name??e.tag).filter(Boolean))],h=i.authors?.map(e=>({name:e.username,url:new URL(`user/${e.guid}`,d).href,avatar:e.avatar})),g=`tmtpost-${i.post_guid}`,_=i.images?.[0]?.url,v=i.time_updated,y={title:a,description:o,pubDate:s?n(s,`X`):void 0,link:c??r.link,category:l,author:h,guid:g,id:g,content:{html:o,text:o},image:_,banner:_,updated:v?n(v,`X`):void 0,language:f},b=i.audio;if(b){let e=`audio/${b.split(/\./).pop()}`,t=i.duration;y={...y,enclosure_url:b,enclosure_type:e,enclosure_title:a,enclosure_length:void 0,itunes_duration:t,itunes_item_image:_}}let x={};if(i.full_size_images??i.images){let e=i.full_size_images??i.images;for(let t of e){let e=t.url??t;if(!e)continue;let n=`image`,r=`${n}${Object.values(x).filter(e=>e.medium===n).length+1}`;x[r]={url:e,medium:n,title:a,thumbnail:t.thumbnail??e}}}return y={...y,media:x},{...r,...y}}):r))).filter(e=>!0);let g=l(`title`).text(),_=g.split(/-/).pop();return{title:g,description:l(`meta[property="og:description"]`).attr(`content`),link:s,item:h,allowEmpty:!0,image:l(`meta[property="og:image"]`).attr(`content`),author:g.split(/-/).pop(),language:f,itunes_author:_,itunes_category:`Technology`,id:s}};export{d as n,h as r,f as t};