import{t as e}from"./ofetch-Dl6dVB_5.mjs";import{t}from"./parse-date-BdYTmLpo.mjs";import{t as n}from"./timezone-keeL11Io.mjs";import{t as r}from"./utils-DaRnY32j.mjs";import{load as i}from"cheerio";import a from"p-map";const o={path:`/sitemap/:route`,categories:[`traditional-media`],example:`/apnews/sitemap/ap-sitemap-latest`,view:0,parameters:{route:{description:"Route for sitemap, excluding the `.xml` extension"}},features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`apnews.com/`]}],name:`Sitemap`,maintainers:[`zoenglinghou`,`mjysci`,`TonyRL`,`dzx-dzx`],handler:s};async function s(o){let s=o.req.param(`route`),c=i(await e(`https://apnews.com/${s}.xml`)),l=c(`urlset url`).toArray().map(e=>{let r=new Map([[`eng`,`en`],[`spa`,`es`]]),i=c(e).find(String.raw`news\:title`).text(),a=t(c(e).find(String.raw`news\:publication_date`).text()),o=n(t(c(e).find(`lastmod`).text()),-4),s=r.get(c(e).find(String.raw`news\:language`).text()),l={link:c(e).find(`loc`).text()};return i&&(l=Object.assign(l,{title:i})),a.toString()!==`Invalid Date`&&(l=Object.assign(l,{pubDate:a})),s&&(l=Object.assign(l,{language:s})),o.toString()!==`Invalid Date`&&(l=Object.assign(l,{lastmod:o})),l}).filter(e=>!!e.link&&!new URL(e.link).pathname.split(`/`).includes(`hub`)).toSorted((e,t)=>e.pubDate&&t.pubDate?t.pubDate-e.pubDate:t.lastmod-e.lastmod).slice(0,o.req.query(`limit`)?Number.parseInt(o.req.query(`limit`),10):20),u=o.req.query(`fulltext`)===`true`?await a(l,e=>r(e),{concurrency:20}):l;return{title:`AP News sitemap:${s}`,item:u,link:`https://apnews.com`}}export{o as route};