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{Fragment as r,jsx as i,jsxs as a}from"hono/jsx/jsx-runtime";import*as o from"cheerio";import{renderToString as s}from"hono/jsx/dom/server";import{destr as c}from"destr";import{raw as l}from"hono/html";const u=new Set([`style`,`watches`,`lifestyle`,`health`,`money-investment`,`gear`,`people`,`watch`,`mens-talk`]),d=async r=>{let{id:i=`Fashion`}=r.req.param();i=i.toLowerCase();let a=`https://www.esquirehk.com`,s=`${a}/tag/${i}`;u.has(i)&&(s=`${a}/${i}`);let l=await e(s),d=o.load(l),p=[...d(`div[class^="max-w-[100%]"] > div > div:nth-child(2) > a`).toArray().map(e=>(e=d(e),{title:e.text().trim(),link:new URL(e.attr(`href`),s).href})),...d(`div.list-item > div > div:nth-child(2) > a`).toArray().map(e=>(e=d(e),{title:e.text().trim(),link:new URL(e.attr(`href`),s).href}))].map(e=>({...e,slug:e.link.replace(a,``)})).filter(e=>!e.slug.startsWith(`/campaign`)),m=await Promise.all(p.map(r=>t.tryGet(r.link,async()=>{let t=c(await e(`https://api.esquirehk.com${r.slug}`));return t.status===`404`?r:(r.description=t.intro.raw+f(t.subpages),r.pubDate=n(t.date.published,`X`),r.updated=n(t.date.lastModified,`X`),r.author=t.author.name,r.category=[...t.tags.topic.map(e=>e.name),...t.tags.normal.map(e=>e.name)],r)})));return{title:`${d(`head title`).text()} - Esquirehk`,description:d(`head meta[name="description"]`).attr(`content`),image:d(`head meta[property="og:image"]`).attr(`content`),logo:d(`head meta[property="og:image"]`).attr(`content`),link:s,item:m}},f=e=>s(i(r,{children:e?.map((e,t)=>{let n=[];switch(e.type){case`image`:{let r=e.image?.large||e.image?.desktop||e.image?.mobile;n.push(i(`img`,{src:r?.src,alt:r?.alt},`image-${t}`));break}case`video_block`:{let r=e.source?.split(`&`)[0];n.push(i(`iframe`,{id:`ytplayer`,type:`text/html`,width:`640`,height:`360`,src:`https://www.youtube-nocookie.com/embed/${r}`,frameborder:`0`,allowfullscreen:!0,referrerpolicy:`strict-origin-when-cross-origin`},`video-${t}`));break}case`ctc_product_list`:n.push(i(`span`,{children:e.products?.map((e,t)=>{let n=e.image?.desktop||e.image?.mobile;return a(`span`,{children:[i(`img`,{src:n?.src,alt:n?.alt}),i(`br`,{}),e.brand,i(`br`,{}),e.name,i(`br`,{}),`HKD $`,e.price,i(`br`,{}),i(`a`,{href:e.url,children:`SHOP NOW`})]},`product-${t}`)})},`products-${t}`));break;default:n.push(a(`span`,{children:[`UNHANDLED PAGE TYPE: `,e.type]},`unknown-${t}`))}return e.title&&n.push(a(`h2`,{children:[e.order?`${e.order} `:``,e.title]},`title-${t}`)),e.description?.raw&&n.push(i(`span`,{children:l(e.description.raw)},`description-${t}`)),i(`span`,{children:n},`page-${t}`)})})),p={path:`/tag/:id?`,categories:[`new-media`],example:`/esquirehk/tag/Fashion`,parameters:{id:`标签，可在对应标签页 URL 中找到`},name:`Tag`,maintainers:[`nczitzk`],radar:[{source:[`www.esquirehk.com/tag/:id`,`www.esquirehk.com/:id`]}],handler:d};export{p as route};