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 r from"node:crypto";import{load as i}from"cheerio";const a={path:`/news`,categories:[`new-media`],example:`/iapp/news`,radar:[{source:[`iapp.org/news`]}],name:`News`,maintainers:[`TonyRL`],handler:o,url:`iapp.org/news`};async function o(a){let o=a.req.query(`limit`)?Number.parseInt(a.req.query(`limit`),10):20,s=`https://iapp.org`,c=`${s}/news`,{appId:l,apiKey:u,description:d}=await t.tryGet(`iapp:algolia-credentials`,async()=>{let t=i(await e(c)),n,r;if(t(`script`).each((e,i)=>{let a=t(i).text().match(/\\"appID\\":\\"(\w+)\\",\\"apiKey\\":\\"(\w+)\\"/);if(a)return n=a[1],r=a[2],!1}),!n||!r)throw Error(`Failed to extract Algolia credentials from iapp.org`);return{appId:n,apiKey:r,description:t(`meta[name="description"]`).attr(`content`)}}),f=(await e(`https://${l.toLowerCase()}-dsn.algolia.net/1/indexes/*/queries`,{method:`POST`,query:{"x-algolia-api-key":u,"x-algolia-application-id":l},headers:{Referer:`${s}/`},body:{requests:[{indexName:`all_article_date_desc`,clickAnalytics:!0,facets:[`news_tags.domains.domains`,`news_tags.industry.industry`,`news_tags.law_and_regulation.law_and_regulation`,`news_tags.subject.subject`],filters:`_content_type:news_article`,highlightPostTag:`__/ais-highlight__`,highlightPreTag:`__ais-highlight__`,hitsPerPage:o,maxValuesPerFacet:200,page:0,query:``,userToken:`anonymous-${r.randomUUID()}`}]}})).results[0].hits.map(e=>({title:e.article_details.headline,description:e.article_body?.map(e=>e.rte?.rich_text_editor).join(``)||e.entry_summary,link:new URL(e.url,s).href,pubDate:n(e.article_details.date),author:e.article_details.author?.map(e=>e.title).join(`, `),category:[...e.news_tags?.domains?.domains||[],...e.news_tags?.subject?.subject||[],...e.tags_group?.internal_class||[]],image:e.main_image?.url}));return{title:`IAPP - News`,description:d,link:c,language:`en`,image:`${s}/favicon.ico`,item:f}}export{a as route};