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{load as r}from"cheerio";const i=`https://www.quantamagazine.org`,a=(e,t)=>{if(!e)return``;let n=e.replaceAll(/\$latex([\S\s]+?)\$/g,`<img align="center" src="https://latex.codecogs.com/png.latex?$1"/>`);n=n.replaceAll(/<div id=[\S\s]+?"src":"(https?:?[\S\s]+?)",[\S\s]+?"caption":"([\S\s]*?)",[\S\s]+?<\/div>?/g,(e,t,n)=>`<figure>${`<img src="${t.replaceAll(/\\([^nu])/g,`$1`)}" />`}<figcaption>${n.replaceAll(/\\([^nu])/g,`$1`).replaceAll(String.raw`\n`,``).replaceAll(/\\u(\d{1,3}[a-z]\d?|\d{4}?)/g,(e,t)=>String.fromCodePoint(Number.parseInt(t,16)))}</figcaption></figure>`);let r=[...n.matchAll(/<lottie-player[^>]*src="([^"]+)"[^>]*><\/lottie-player>/g)],a=new Set;for(let e of r){let r=e[1].split(`/`).pop()?.replace(/-(Desktop|Mobile).*\.json$/,``)||`animation`;if(a.has(r))n=n.replace(e[0],``);else{a.add(r);let o=`<p style="text-align: center; margin: 20px 0;"><a href="${t||i}" target="_blank"><img src="https://img.shields.io/badge/🎬-View_Interactive_Animation-0066CC?style=for-the-badge" alt="View Interactive Animation" /></a></p>`;n=n.replace(e[0],o)}}return n},o=async o=>{let s=o.req.query(`limit`)?Number.parseInt(o.req.query(`limit`),10):20,c=await e(`${i}/wp-json/wp/v2/posts`,{query:{per_page:s,page:1,_embed:`author`}});return{title:`Quanta Magazine`,link:i,item:await Promise.all(c.map(i=>t.tryGet(i.link,async()=>{let t=i._embedded?.author?.[0]?.name||``,o=r(await e(i.link,{parseResponse:e=>e}));o(`.header-spacer, .scale1.mha, .post__title__author-date, .post__aside--divider`).remove(),o(`.hide-on-print, .post__aside__pullquote, aside.post__sidebar.hide, nav[data-glide-el]`).remove(),o(`.post__footer, .post__title__author-date`).remove(),o(`.iframe-placeholder`).remove();let s=a(o(`#postBody`).html(),i.link);return{title:i.title.rendered,author:t,description:s,link:i.link,guid:i.link,pubDate:n(i.date)}})))}},s={path:`/archive`,name:`Archive`,url:`quantamagazine.org`,maintainers:[`emdoe`],handler:o,example:`/quantamagazine/archive`,parameters:{},description:`Get the latest articles from Quanta Magazine.`,categories:[`new-media`],features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportRadar:!0,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`quantamagazine.org`],target:`/archive`}]};export{o as handler,s as route};