import{t as e}from"./logger-B0fjfmRH.mjs";import{t}from"./cache-DUthuMSu.mjs";import{t as n}from"./parse-date-BdYTmLpo.mjs";import{n as r}from"./playwright-1-2p8zlN.mjs";const i={path:`/news/:options?`,categories:[`game`],example:`/fortnite/news`,parameters:{options:`Params`},features:{requireConfig:!1,requirePuppeteer:!0,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1},name:`News`,maintainers:[`lyqluis`],handler:a,description:`-   \`options.lang\`, optional, language, eg. \`/fortnite/news/lang=en-US\`, common languages are listed below, more languages are available one the [official website](https://www.fortnite.com/news)

| English (default) | Spanish | Japanese | French | Korean | Polish |
| ----------------- | ------- | -------- | ------ | ------ | ------ |
| en-US             | es-ES   | ja       | fr     | ko     | pl     |`};async function a(i){let a=i.req.param(`options`)?.split(`&`).map(e=>e.split(`=`)),o=`https://www.fortnite.com`,s=`news`,c=a?.find(e=>e[0]===`lang`)[1]??`en-US`,l=`${o}/${s}?lang=${c}`,u=`https://www.fortnite.com/api/blog/getPosts?category=&postsPerPage=0&offset=0&locale=${c}&rootPageSlug=blog`,d=await r(),f=await d.newPage();await f.setRequestInterception(!0),f.on(`request`,e=>{e.resourceType()===`document`?e.continue():e.abort()}),e.http(`Requesting ${u}`);let p;try{let e=await f.goto(u,{waitUntil:`networkidle0`});if(!e)throw Error(`No response received from ${u}`);if(!e.ok()){let t=e.statusText(),n=[e.status(),t].filter(Boolean).join(` `);throw Error(`Fortnite API responded with ${n} for ${u}`)}let t=e.headers()[`content-type`];if(!t?.includes(`application/json`))throw Error(`Fortnite API returned non-JSON response with content-type ${t??`unknown`}`);p=await e.json()}finally{await f.close(),await d.close()}let{blogList:m}=p;return{title:`Fortnite News`,link:l,item:await Promise.all(m.map(e=>t.tryGet(e.link,()=>({title:e.title,link:`${o}/${s}/${e.slug}?lang=${c}`,pubDate:n(e.date),author:e.author,description:e.content}))))}}export{i as route};