import{t as e}from"./ofetch-Dl6dVB_5.mjs";import{t}from"./logger-B0fjfmRH.mjs";import{t as n}from"./cache-DUthuMSu.mjs";import{load as r}from"cheerio";const i=`https://www.capitalmind.in`;async function a(a){let o=r(await e(`${i}/${a}/page/1`)),s=o(`.article-wrapper a.article-card-wrapper`).toArray().map(async a=>{let s=o(a),c=i+s.attr(`href`);return await n.tryGet(c,async()=>{let n=s.find(`h3`).text().trim(),a=s.find(String.raw`div.text-[16px]`).text().trim(),o=s.find(`img`).attr(`src`),l=o?.startsWith(`/_next/image`)?o.split(`url=`)[1].split(`&`)[0]:o,u=l?decodeURIComponent(l):``,d=r(await e(c)),f=d(`article`).clone(),p=f.find(`footer div`).toArray().map(e=>{let t=d(e);return t.find(`.sr-only`).remove(),t.text().trim()}).filter(Boolean),m=``,h=f.find(`header`).find(`time`);h.length&&(m=h.attr(`datetime`)||h.text().trim());let g=f.find(`section[aria-label="Post content"]`).clone();g.find(`footer`).remove();let _={},v=g.find(`iframe[src*="libsyn.com/embed/episode/id/"]`);if(v.length){let n=v.attr(`src`);if(n){let r=n.match(/\/id\/(\d+)\//);if(r&&r[1]){let n=r[1];try{let t=await e(`https://html5-player.libsyn.com/api/episode/id/${n}`);t&&t._item&&t._item._primary_content&&(_={mediaUrl:t._item._primary_content._download_url,image:`https://assets.libsyn.com/item/${n}`,itunes_duration:t._item._primary_content.duration})}catch{t.info(`Failed to fetch podcast data for episode ID ${n}`)}}}}return g.find(`figure img`).each((e,t)=>{let n=d(t),r=n.attr(`src`);if(n.removeAttr(`srcset`),r&&r.startsWith(`/_next/image`)){let e=r.match(/url=([^&]+)/);if(e&&e[1]){let t=decodeURIComponent(e[1]);n.attr(`src`,t)}else r.startsWith(`/`)&&n.attr(`src`,i+r)}}),{title:n,link:c,author:a,description:g.html()||`<p><img src="${u}" alt="${n}"></p><p>Author: ${a}</p>`,guid:c,itunes_item_image:_?.image||u,category:p,pubDate:m,enclosure_url:_?.mediaUrl||null,itunes_duration:_?.itunes_duration||null,enclosure_type:_?.mediaUrl?`audio/mpeg`:null}})});return Promise.all(s)}export{a as n,i as t};