import{t as e}from"./parse-date-BdYTmLpo.mjs";import{Fragment as t,jsx as n,jsxs as r}from"hono/jsx/jsx-runtime";import{load as i}from"cheerio";import{renderToString as a}from"hono/jsx/dom/server";import{raw as o}from"hono/html";const s=`https://www.science.org`,c=(e,t,n)=>Promise.all(e.map(e=>n(e.link,async()=>{let n=await t.newPage();await n.setRequestInterception(!0),n.on(`request`,e=>{e.resourceType()===`document`||e.resourceType()===`script`?e.continue():e.abort()}),await n.goto(e.link,{waitUntil:`domcontentloaded`}),await n.waitForSelector(`section#bodymatter, .news-article-content, .news-article-content--featured`);let r=await n.evaluate(()=>document.documentElement.innerHTML);await n.close();let a=i(r);return e.description=u(a(`div#abstracts`).html(),a(`.news-article-content--featured`).length?a(`.news-article-content--featured`).html():a(`.news-article-content`).length?a(`.news-article-content`).html():a(`.info-panel__formats a.btn__request-access`).length||a(`.info-panel__formats a.btn--access`).length?``:a(`section#bodymatter`).html()),e}))),l=(t,n)=>(t=n(t),{title:t.find(`.article-title a`).attr(`title`),link:`${s}${t.find(`.article-title a`).attr(`href`)}`,doi:t.find(`.article-title a`).attr(`href`).replace(`/doi/`,``),pubDate:e(t.find(`.card-meta__item time`).text()),author:t.find(`.card-meta ul[title="list of authors"] li`).toArray().map(e=>n(e).text()).join(`, `)}),u=(e,i)=>a(r(t,{children:[e?o(e):null,i?r(t,{children:[n(`br`,{}),o(i)]}):null]}));export{c as n,l as r,s as t};