import{load as e}from"cheerio";const t=new Set([`div`,`span`,`p`,`br`,`b`,`strong`,`i`,`em`,`u`,`s`,`a`,`img`,`ul`,`ol`,`li`,`blockquote`,`hr`,`pre`,`code`]),n={a:[`href`,`target`,`rel`],img:[`src`,`alt`,`title`,`style`],div:[`style`],span:[`style`]},r=r=>{let i=e(r),a=new Set;i(`img`).each((e,t)=>{let n=i(t),r=n.parent(`a`),o=r.attr(`href`)||n.attr(`data-src`)||n.attr(`src`)||``;o=o.replace(`/thumb/`,`/`),!o||o.startsWith(`data:`)||a.has(o)?n.remove():(a.add(o),n.attr(`src`,o).removeAttr(`data-src`),r.length&&r.replaceWith(n))}),i(`button, script, style, noscript`).remove();let o=!0;for(;o;)o=!1,i(`*`).each((e,n)=>{if(n.type===`tag`&&!t.has(n.name))return i(n).replaceWith(i(n).html()||``),o=!0,!1});return i(`*`).each((e,t)=>{if(t.type!==`tag`)return;let r=new Set(n[t.name]||[]);for(let e of Object.keys(t.attribs||{}))r.has(e)||i(t).removeAttr(e)}),i(`div`).filter((e,t)=>!i(t).html()?.trim()).remove(),i.html()||``};export{r as t};