"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())}),stream_exports={};__export(stream_exports,{getStream:()=>getStream});var getStream=__name(_0=>__async(null,[_0],function*({link:data,providerContext:providerContext}){var _a,_b;try{const{cheerio:cheerio,commonHeaders:headers,axios:axios}=providerContext,streamData=JSON.parse(data),streamLinks=[],url=(null==streamData?void 0:streamData.baseUrl)+"/api/"+(null==streamData?void 0:streamData.slug);console.log("rido url",url);const iframe=null==(_b=null==(_a=(yield axios.get(url,{headers:headers})).data.data)?void 0:_a[0])?void 0:_b.url;console.log("rido data",iframe);const iframeUrl=iframe.split('src="')[1].split('"')[0];console.log("rido iframeUrl",iframeUrl);const iframeRes=yield axios.get(iframeUrl,{headers:__spreadProps(__spreadValues({},headers),{Referer:null==streamData?void 0:streamData.baseUrl})}),script=cheerio.load(iframeRes.data)('script:contains("eval")').html();if(!script)throw new Error("Unable to find script");const srcUrl=unpackJavaScript(script.trim());return console.log("rido srcUrl",srcUrl),streamLinks.push({link:srcUrl,server:"rido",type:"m3u8",headers:{Referer:iframeUrl}}),streamLinks}catch(e){return console.log("rido get stream err",e),[]}}),"getStream");function unpackJavaScript(packedCode){const base64Url="aHR"+packedCode.split("|aHR")[1].split("|")[0];function addPadding(base64){return base64+"=".repeat((4-base64.length%4)%4)}return __name(addPadding,"addPadding"),console.log("rido base64Url",base64Url),atob(addPadding(base64Url))}__name(unpackJavaScript,"unpackJavaScript"),exports.getStream=getStream;