import{t as e}from"./cache-DUthuMSu.mjs";import{t}from"./got-BBDj7u1e.mjs";import{t as n}from"./invalid-parameter-DLv2wPKB.mjs";import{t as r}from"./valid-host-CeDzTNj_.mjs";import{Fragment as i,jsx as a,jsxs as o}from"hono/jsx/jsx-runtime";import{load as s}from"cheerio";import{renderToString as c}from"hono/jsx/dom/server";const l={potd:`picture/browse/potd/`,potw:`picture/browse/potw/`,potm:`picture/browse/potm/`},u={path:`/:category?/:language?`,categories:[`shopping`],example:`/myfigurecollection/potd`,parameters:{category:`分类，默认为每日圖片`,language:"语言，见上表，默认为空，即 `en`"},features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`zh.myfigurecollection.net/browse`,`zh.myfigurecollection.net/`]}],name:`圖片`,maintainers:[`nczitzk`],handler:d,url:`zh.myfigurecollection.net/browse`,description:`| 每日圖片 | 每週圖片 | 每月圖片 |
| -------- | -------- | -------- |
| potd     | potw     | potm     |`};async function d(i){let a=i.req.param(`language`)??``,o=i.req.param(`category`)??`figure`;if(a&&!r(a))throw new n(`Invalid language`);let c=`https://${a===`en`||a===``?``:`${a}.`}myfigurecollection.net`,u=`${c}/${Object.hasOwn(l,o)?l[o]:o}`,d=s((await t({method:`get`,url:u})).data),p=d(`.item-icon, .picture-icon`).slice(0,i.req.query(`limit`)?Number.parseInt(i.req.query(`limit`)):25).toArray().map(e=>{e=d(e).find(`a`);let t=e.attr(`href`);return{link:t.startsWith(`http`)?t:`${c}${t}`}});return p=await Promise.all(p.map(n=>e.tryGet(n.link,async()=>{try{let e=s((await t({method:`get`,url:n.link})).data);n.title=e(`.headline`).text(),n.description=f(/myfigurecollection\.net\/picture\//.test(n.link)?[{src:e(`meta[property="og:image"]`).attr(`content`)}]:JSON.parse(decodeURIComponent(e(`meta[name="pictures"]`).attr(`content`))),e(`.form-field`).toArray().map(t=>({key:e(t).find(`.form-label`).text(),value:e(t).find(`.form-input`).text()})))}catch{n.title=`Item #${n.link.split(`/`).pop()}`}return n}))),{title:d(`title`).text().replace(/ \(.*\)/,``),link:u,item:p}}const f=(e,t)=>c(o(i,{children:[e?.map((e,t)=>a(`img`,{src:e.src,weight:e.w,height:e.h},`${e.src}-${t}`)),t.length?a(`table`,{children:a(`tbody`,{children:t.map((e,t)=>o(`tr`,{children:[a(`th`,{children:e.key}),a(`td`,{children:e.value})]},`${e.key}-${t}`))})}):null]}));export{u as route};