"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())}),stream_exports={};__export(stream_exports,{getStream:()=>getStream});var getStream=__name(function(_0){return __async(this,arguments,function*({link:id,providerContext:providerContext}){try{const{axios:axios}=providerContext,baseUrl="https://backend.animetsu.to",[animeId,episodeNumber]=id.split(":");if(!animeId||!episodeNumber)throw new Error("Invalid link format");const servers=["pahe","zoro"],streamLinks=[];return yield Promise.all(servers.map(server=>__async(null,null,function*(){try{const url=`${baseUrl}/api/anime/tiddies?server=${server}&id=${animeId}&num=${episodeNumber}&subType=sub`,res=yield axios.get(url,{headers:{Referer:"https://animetsu.to/"}});if(res.data&&res.data.sources){const subtitles=[];res.data.sources.forEach(source=>{streamLinks.push({server:server+`: ${source.quality}`,link:`https://m3u8.8man.workers.dev?url=${source.url}`,type:"m3u8",quality:source.quality,headers:{referer:"https://animetsu.to/"},subtitles:subtitles.length>0?subtitles:[]})})}}catch(e){console.log(`Error with server ${server}:`,e)}}))),yield Promise.all(servers.map(server=>__async(null,null,function*(){try{const url=`${baseUrl}/api/anime/tiddies?server=${server}&id=${animeId}&num=${episodeNumber}&subType=dub`,res=yield axios.get(url,{headers:{referer:"https://animetsu.to/"}});if(res.data&&res.data.sources){const subtitles=[];res.data.sources.forEach(source=>{streamLinks.push({server:`${server} (Dub) : ${source.quality}`,link:`https://m3u8.8man.workers.dev?url=${source.url}`,type:"m3u8",quality:source.quality,headers:{referer:"https://animetsu.to/"},subtitles:subtitles.length>0?subtitles:[]})})}}catch(e){console.log(`Error with server ${server} (dub):`,e)}}))),console.log("Stream links:",streamLinks),streamLinks}catch(err){return console.error("animetsu stream error:",err),[]}})},"getStream");exports.getStream=getStream;