"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__name=(target,value)=>__defProp(target,"name",{value:value,configurable:!0}),__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),__async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())}),posts_exports={};__export(posts_exports,{getPosts:()=>getPosts,getSearchPosts:()=>getSearchPosts});var getPosts=__name(function(_0){return __async(this,arguments,function*({filter:filter,page:page,signal:signal,providerContext:providerContext}){var _a,_b,_c,_d;const posts=[],{getBaseUrl:getBaseUrl}=providerContext;if(page>1)return posts;const response=yield fetch("https://dob-worker.1proxy.workers.dev",{signal:signal,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:"/wefeed-mobile-bff/tab-operating?page=3&tabId=0&version=2fe0d7c224603ff7b0df294b46d3b84b",method:"GET"})}),data=yield response.json(),items=(null==(_a=null==data?void 0:data.data)?void 0:_a.items)||[],filterIndex=Number.parseInt(filter,10);let list=null==(_b=null==items?void 0:items[filterIndex])?void 0:_b.subjects;Array.isArray(list)&&0!==list.length||(list=(null==(_c=null==items?void 0:items.find(item=>Array.isArray(null==item?void 0:item.subjects)&&item.subjects.length>0))?void 0:_c.subjects)||[]);for(const item of list){const post={image:null==item?void 0:item.cover.url,title:null==(_d=null==item?void 0:item.title)?void 0:_d.replace(/\s*\[.*?\]\s*$/,""),link:`/wefeed-mobile-bff/subject-api/get?subjectId=${null==item?void 0:item.subjectId}`};posts.push(post)}return posts})},"getPosts"),getSearchPosts=__name(function(_0){return __async(this,arguments,function*({searchQuery:searchQuery,page:page,signal:signal,providerContext:providerContext}){var _a,_b,_c;const{getBaseUrl:getBaseUrl,axios:axios,cheerio:cheerio}=providerContext,baseUrl=yield getBaseUrl("movieBox"),url=`${baseUrl}/wefeed-mobile-bff/subject-api/search/v2`;if(page>1)return[];const response=yield fetch("https://dob-worker.8man.workers.dev",{signal:signal,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:url,method:"POST",body:{page:1,perPage:20,keyword:searchQuery,tabId:"Movie"}})}),data=yield response.json();return((null==(_c=null==(_b=null==(_a=null==data?void 0:data.data)?void 0:_a.results)?void 0:_b[0])?void 0:_c.subjects)||[]).map(item=>{var _a2;return{image:null==(_a2=null==item?void 0:item.cover)?void 0:_a2.url,title:null==item?void 0:item.title,link:`${baseUrl}/wefeed-mobile-bff/subject-api/get?subjectId=${null==item?void 0:item.subjectId}`}})})},"getSearchPosts");exports.getPosts=getPosts,exports.getSearchPosts=getSearchPosts;