"use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropNames=Object.getOwnPropertyNames,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value:value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__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())}),meta_exports={};__export(meta_exports,{getMeta:()=>getMeta});var getMeta=__name(function(_0){return __async(this,arguments,function*({link:link,providerContext:providerContext}){var _a,_b,_c,_d,_e,_f,_g;try{const{axios:axios,openWebView:openWebView,commonHeaders:commonHeaders}=providerContext,baseUrl="https://animetsu.net",url=`${baseUrl}/v2/api/anime/info/${link}`;let cookies,res;try{res=yield axios.get(url,{headers:__spreadProps(__spreadValues({},commonHeaders),{Referer:baseUrl})})}catch(error){if(403!==(null==(_a=error.response)?void 0:_a.status))throw error;{const wafResult=yield openWebView(baseUrl,{title:"Solve the captcha below and click done",description:"Required to bypass Animetsu anti-bot protection.",headers:__spreadProps(__spreadValues({},commonHeaders),{Referer:baseUrl}),force:!0,waitForCookie:"cf_clearance"});cookies=wafResult.cookies,res=yield axios.get(url,{headers:__spreadProps(__spreadValues({},commonHeaders),{Referer:baseUrl,Cookie:cookies})})}}const data=res.data,meta={title:(null==(_b=data.title)?void 0:_b.english)||(null==(_c=data.title)?void 0:_c.romaji)||(null==(_d=data.title)?void 0:_d.native)||"",synopsis:data.description||"",image:(null==(_e=data.cover_image)?void 0:_e.large)||(null==(_f=data.cover_image)?void 0:_f.medium)||(null==(_g=data.cover_image)?void 0:_g.small)||"",tags:[null==data?void 0:data.format,null==data?void 0:data.status,...(null==data?void 0:data.genres)||[]].filter(Boolean),imdbId:"",type:"MOVIE"===data.format?"movie":"series"},linkList=[],seasons=data.seasons;if(seasons&&seasons.length>0)yield Promise.all(seasons.map(season=>__async(null,null,function*(){var _a2,_b2,_c2;const seasonTitle=(null==(_a2=season.title)?void 0:_a2.english)||(null==(_b2=season.title)?void 0:_b2.romaji)||(null==(_c2=season.title)?void 0:_c2.native),directLinks=[];try{const episodes=(yield axios.get(`${baseUrl}/v2/api/anime/eps/${season.id}`,{headers:__spreadValues(__spreadProps(__spreadValues({},commonHeaders),{Referer:baseUrl}),cookies?{Cookie:cookies}:{})})).data;episodes&&episodes.length>0&&episodes.forEach(ep=>{directLinks.push({title:`Episode ${ep.ep_num}`,link:`${season.id}:${ep.ep_num}`})})}catch(e){const total=season.total_eps||1;for(let i=1;i<=total;i++)directLinks.push({title:`Episode ${i}`,link:`${season.id}:${i}`})}directLinks.length>0&&linkList.push({title:seasonTitle||meta.title,directLinks:directLinks})})));else{const total=data.total_eps||1,directLinks=[];for(let i=1;i<=total;i++)directLinks.push({title:1===total?"Movie":`Episode ${i}`,link:`${link}:${i}`});linkList.push({title:meta.title,directLinks:directLinks})}return __spreadProps(__spreadValues({},meta),{linkList:linkList})}catch(err){return console.error("animetsu meta error:",err),{title:"",synopsis:"",image:"",imdbId:"",type:"movie",linkList:[]}}})},"getMeta");exports.getMeta=getMeta;