https://www.outfame.com/_next/static/chunks/c3c6faf8adef3710.js?dpl=dpl_HVnGmZ5MtoDVJsBbJKFfvGAzA67T
1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,801921,497775,674507,e=>{"use strict";e.s(["IG_QUERY_TYPES",()=>iu,"Instagram",()=>iS],801921);var t=e.i(167225),s=e.i(552503),i=e.i(467034);let n=globalThis.crypto.subtle;var r=Object.defineProperty,a={},o={UpstashError:()=>h,UpstashJSONParseError:()=>p,UrlError:()=>l};for(var c in o)r(a,c,{get:o[c],enumerable:!0});var h=class extends Error{constructor(e,t){super(e,t),this.name="UpstashError"}},l=class extends Error{constructor(e){super(`Upstash Redis client was passed an invalid URL. You should pass a URL starting with https. Received: "${e}". `),this.name="UrlError"}},p=class extends h{constructor(e,t){const s=e.length>200?e.slice(0,200)+"...":e;super(`Unable to parse response body: ${s}`,t),this.name="UpstashJSONParseError"}};function u(e){try{return function e(t){let s=Array.isArray(t)?t.map(t=>{try{return e(t)}catch{return t}}):JSON.parse(t);return"number"==typeof s&&s.toString()!==t?t:s}(e)}catch{return e}}function d(e){return[e[0],...u(e.slice(1))]}function m(e){let[t,s]=e,i=[];for(let e=0;e<s.length;e+=2)i.push({key:s[e],type:s[e+1]});return[t,i]}function f(e){if("object"==typeof e&&null!==e&&!Array.isArray(e))return e;if(!Array.isArray(e))return{};let t={};for(let s=0;s<e.length;s+=2)"string"==typeof e[s]&&(t[e[s]]=e[s+1]);return t}var w=class{baseUrl;headers;options;readYourWrites;upstashSyncToken="";hasCredentials;retry;constructor(e){if(this.options={backend:e.options?.backend,agent:e.agent,responseEncoding:e.responseEncoding??"base64",cache:e.cache,signal:e.signal,keepAlive:e.keepAlive??!0},this.upstashSyncToken="",this.readYourWrites=e.readYourWrites??!0,this.baseUrl=(e.baseUrl||"").replace(/\/$/,""),this.baseUrl&&!/^https?:\/\/[^\s#$./?].\S*$/.test(this.baseUrl))throw new l(this.baseUrl);this.headers={"Content-Type":"application/json",...e.headers},this.hasCredentials=!!(this.baseUrl&&this.headers.authorization.split(" ")[1]),"base64"===this.options.responseEncoding&&(this.headers["Upstash-Encoding"]="base64"),this.retry="boolean"!=typeof e.retry||e.retry?{attempts:e.retry?.retries??5,backoff:e.retry?.backoff??(e=>50*Math.exp(e))}:{attempts:1,backoff:()=>0}}mergeTelemetry(e){this.headers=y(this.headers,"Upstash-Telemetry-Runtime",e.runtime),this.headers=y(this.headers,"Upstash-Telemetry-Platform",e.platform),this.headers=y(this.headers,"Upstash-Telemetry-Sdk",e.sdk)}async request(e){let t,s=function(...e){let t={};for(let s of e)if(s)for(let[e,i]of Object.entries(s))null!=i&&(t[e]=i);return t}(this.headers,e.headers??{}),i=[this.baseUrl,...e.path??[]].join("/"),n="text/event-stream"===s.Accept,r=e.signal??this.options.signal,a="function"==typeof r,o={cache:this.options.cache,method:"POST",headers:s,body:JSON.stringify(e.body),keepalive:this.options.keepAlive,agent:this.options.agent,signal:a?r():r,backend:this.options.backend};if(this.hasCredentials||console.warn("[Upstash Redis] Redis client was initialized without url or token. Failed to execute command."),this.readYourWrites){let e=this.upstashSyncToken;this.headers["upstash-sync-token"]=e}let c=null,l=null;for(let e=0;e<=this.retry.attempts;e++)try{c=await fetch(i,o);break}catch(t){if(o.signal?.aborted&&a)throw t;if(o.signal?.aborted){c=new Response(new Blob([JSON.stringify({result:o.signal.reason??"Aborted"})]),{status:200,statusText:o.signal.reason??"Aborted"});break}l=t,e<this.retry.attempts&&await new Promise(t=>setTimeout(t,this.retry.backoff(e)))}if(!c)throw l??Error("Exhausted all retries");if(!c.ok){let t,s=await c.text();try{t=JSON.parse(s)}catch(e){throw new p(s,{cause:e})}throw new h(`${t.error}, command was: ${JSON.stringify(e.body)}`)}if(this.readYourWrites){let e=c.headers;this.upstashSyncToken=e.get("upstash-sync-token")??""}if(n&&e&&e.onMessage&&c.body){let t=c.body.getReader(),s=new TextDecoder;return(async()=>{try{let i="";for(;;){let{value:n,done:r}=await t.read();if(r)break;let a=(i+=s.decode(n,{stream:!0})).split("\n");if((i=a.pop()||"").length>1048576)throw Error("Buffer size exceeded (1MB)");for(let t of a)if(t.startsWith("data: ")){let s=t.slice(6);e.onMessage?.(s)}}}catch(e){e instanceof Error&&"AbortError"===e.name||console.error("Stream reading error:",e)}finally{try{await t.cancel()}catch{}}})(),{result:1}}let u=await c.text();try{t=JSON.parse(u)}catch(e){throw new p(u,{cause:e})}if(this.readYourWrites){let e=c.headers;this.upstashSyncToken=e.get("upstash-sync-token")??""}return"base64"===this.options.responseEncoding?Array.isArray(t)?t.map(({result:e,error:t})=>({result:x(e),error:t})):{result:x(t.result),error:t.error}:t}};function g(e){let t="";try{let s=atob(e),i=s.length,n=new Uint8Array(i);for(let e=0;e<i;e++)n[e]=s.charCodeAt(e);t=new TextDecoder().decode(n)}catch{t=e}return t}function x(e){let t;switch(typeof e){case"undefined":return e;case"number":t=e;break;case"object":t=Array.isArray(e)?e.map(e=>"string"==typeof e?g(e):Array.isArray(e)?e.map(e=>x(e)):e):null;break;case"string":t="OK"===e?"OK":g(e)}return t}function y(e,t,s){return s&&(e[t]=e[t]?[e[t],s].join(","):s),e}var _=e=>{switch(typeof e){case"string":case"number":case"boolean":return e;default:return JSON.stringify(e)}},b=class{command;serialize;deserialize;headers;path;onMessage;isStreaming;signal;constructor(e,t){if(this.serialize=_,this.deserialize=t?.automaticDeserialization===void 0||t.automaticDeserialization?t?.deserialize??u:e=>e,this.command=e.map(e=>this.serialize(e)),this.headers=t?.headers,this.path=t?.path,this.onMessage=t?.streamOptions?.onMessage,this.isStreaming=t?.streamOptions?.isStreaming??!1,this.signal=t?.streamOptions?.signal,t?.latencyLogging){const e=this.exec.bind(this);this.exec=async t=>{let s=performance.now(),i=await e(t),n=(performance.now()-s).toFixed(2);return console.log(`Latency for \x1b[38;2;19;185;39m${this.command[0].toString().toUpperCase()}\x1b[0m: \x1b[38;2;0;255;255m${n} ms\x1b[0m`),i}}}async exec(e){let{result:t,error:s}=await e.request({body:this.command,path:this.path,upstashSyncToken:e.upstashSyncToken,headers:this.headers,onMessage:this.onMessage,isStreaming:this.isStreaming,signal:this.signal});if(s)throw new h(s);if(void 0===t)throw TypeError("Request did not return a result");return this.deserialize(t)}},O=class extends b{constructor(e,t){const s=["hrandfield",e[0]];"number"==typeof e[1]&&s.push(e[1]),e[2]&&s.push("WITHVALUES"),super(s,{deserialize:e[2]?e=>(function(e){if(0===e.length)return null;let t={};for(let s=0;s<e.length;s+=2){let i=e[s],n=e[s+1];try{t[i]=JSON.parse(n)}catch{t[i]=n}}return t})(e):t?.deserialize,...t})}},S=class extends b{constructor(e,t){super(["append",...e],t)}},A=class extends b{constructor([e,t,s],i){const n=["bitcount",e];"number"==typeof t&&n.push(t),"number"==typeof s&&n.push(s),super(n,i)}},v=class{constructor(e,t,s,i=e=>e.exec(this.client)){this.client=t,this.opts=s,this.execOperation=i,this.command=["bitfield",...e]}command;chain(...e){return this.command.push(...e),this}get(...e){return this.chain("get",...e)}set(...e){return this.chain("set",...e)}incrby(...e){return this.chain("incrby",...e)}overflow(e){return this.chain("overflow",e)}exec(){let e=new b(this.command,this.opts);return this.execOperation(e)}},E=class extends b{constructor(e,t){super(["bitop",...e],t)}},I=class extends b{constructor(e,t){super(["bitpos",...e],t)}},k=class extends b{constructor([e,t],s){super(["CLIENT","SETINFO",e.toUpperCase(),t],s)}},R=class extends b{constructor([e,t,s],i){super(["COPY",e,t,...s?.replace?["REPLACE"]:[]],{...i,deserialize:e=>e>0?"COPIED":"NOT_COPIED"})}},T=class extends b{constructor(e){super(["dbsize"],e)}},P=class extends b{constructor(e,t){super(["decr",...e],t)}},N=class extends b{constructor(e,t){super(["decrby",...e],t)}},U=class extends b{constructor(e,t){super(["del",...e],t)}},C=class extends b{constructor(e,t){super(["echo",...e],t)}},$=class extends b{constructor([e,t,s],i){super(["eval_ro",e,t.length,...t,...s??[]],i)}},z=class extends b{constructor([e,t,s],i){super(["eval",e,t.length,...t,...s??[]],i)}},D=class extends b{constructor([e,t,s],i){super(["evalsha_ro",e,t.length,...t,...s??[]],i)}},L=class extends b{constructor([e,t,s],i){super(["evalsha",e,t.length,...t,...s??[]],i)}},M=class extends b{constructor(e,t){super(e.map(e=>"string"==typeof e?e:String(e)),t)}},F=class extends b{constructor(e,t){super(["exists",...e],t)}},j=class extends b{constructor(e,t){super(["expire",...e.filter(Boolean)],t)}},J=class extends b{constructor(e,t){super(["expireat",...e],t)}},q=class extends b{constructor([e,t,s],i){super(["fcall",e,...t?[t.length,...t]:[0],...s??[]],i)}},B=class extends b{constructor([e,t,s],i){super(["fcall_ro",e,...t?[t.length,...t]:[0],...s??[]],i)}},K=class extends b{constructor(e,t){const s=["flushall"];e&&e.length>0&&e[0].async&&s.push("async"),super(s,t)}},H=class extends b{constructor([e],t){const s=["flushdb"];e?.async&&s.push("async"),super(s,t)}},G=class extends b{constructor([e],t){super(["function","delete",e],t)}},Y=class extends b{constructor(e){super(["function","flush"],e)}},X=class extends b{constructor([e],t){const s=["function","list"];e?.libraryName&&s.push("libraryname",e.libraryName),e?.withCode&&s.push("withcode"),super(s,{deserialize:W,...t})}};function W(e){return Array.isArray(e)?e.map(e=>{let t=f(e),s=t.functions.map(e=>f(e));return{libraryName:t.library_name,engine:t.engine,functions:s.map(e=>({name:e.name,description:e.description??void 0,flags:e.flags})),libraryCode:t.library_code}}):[]}var Q=class extends b{constructor([e],t){super(["function","load",...e.replace?["replace"]:[],e.code],t)}},V=class extends b{constructor(e){super(["function","stats"],{deserialize:Z,...e})}};function Z(e){return{engines:Object.fromEntries(Object.entries(Object.fromEntries(Object.entries(f(f(e).engines)).map(([e,t])=>[e,f(t)]))).map(([e,t])=>[e,{librariesCount:t.libraries_count,functionsCount:t.functions_count}]))}}var ee=class extends b{constructor([e,t,...s],i){const n=["geoadd",e];"nx"in t&&t.nx?n.push("nx"):"xx"in t&&t.xx&&n.push("xx"),"ch"in t&&t.ch&&n.push("ch"),"latitude"in t&&t.latitude&&n.push(t.longitude,t.latitude,t.member),n.push(...s.flatMap(({latitude:e,longitude:t,member:s}
1)=>[t,e,s])),super(n,i)}},et=class extends b{constructor([e,t,s,i="M"],n){super(["GEODIST",e,t,s,i],n)}},es=class extends b{constructor(e,t){const[s]=e;super(["GEOHASH",s,...Array.isArray(e[1])?e[1]:e.slice(1)],t)}},ei=class extends b{constructor(e,t){const[s]=e;super(["GEOPOS",s,...Array.isArray(e[1])?e[1]:e.slice(1)],{deserialize:e=>(function(e){let t=[];for(let s of e)s?.[0]&&s?.[1]&&t.push({lng:Number.parseFloat(s[0]),lat:Number.parseFloat(s[1])});return t})(e),...t})}},en=class extends b{constructor([e,t,s,i,n],r){const a=["GEOSEARCH",e];("FROMMEMBER"===t.type||"frommember"===t.type)&&a.push(t.type,t.member),("FROMLONLAT"===t.type||"fromlonlat"===t.type)&&a.push(t.type,t.coordinate.lon,t.coordinate.lat),("BYRADIUS"===s.type||"byradius"===s.type)&&a.push(s.type,s.radius,s.radiusType),("BYBOX"===s.type||"bybox"===s.type)&&a.push(s.type,s.rect.width,s.rect.height,s.rectType),a.push(i),n?.count&&a.push("COUNT",n.count.limit,...n.count.any?["ANY"]:[]),super([...a,...n?.withCoord?["WITHCOORD"]:[],...n?.withDist?["WITHDIST"]:[],...n?.withHash?["WITHHASH"]:[]],{deserialize:e=>n?.withCoord||n?.withDist||n?.withHash?e.map(e=>{let t=1,s={};try{s.member=JSON.parse(e[0])}catch{s.member=e[0]}return n.withDist&&(s.dist=Number.parseFloat(e[t++])),n.withHash&&(s.hash=e[t++].toString()),n.withCoord&&(s.coord={long:Number.parseFloat(e[t][0]),lat:Number.parseFloat(e[t][1])}),s}):e.map(e=>{try{return{member:JSON.parse(e)}}catch{return{member:e}}}),...r})}},er=class extends b{constructor([e,t,s,i,n,r],a){const o=["GEOSEARCHSTORE",e,t];("FROMMEMBER"===s.type||"frommember"===s.type)&&o.push(s.type,s.member),("FROMLONLAT"===s.type||"fromlonlat"===s.type)&&o.push(s.type,s.coordinate.lon,s.coordinate.lat),("BYRADIUS"===i.type||"byradius"===i.type)&&o.push(i.type,i.radius,i.radiusType),("BYBOX"===i.type||"bybox"===i.type)&&o.push(i.type,i.rect.width,i.rect.height,i.rectType),o.push(n),r?.count&&o.push("COUNT",r.count.limit,...r.count.any?["ANY"]:[]),super([...o,...r?.storeDist?["STOREDIST"]:[]],a)}},ea=class extends b{constructor(e,t){super(["get",...e],t)}},eo=class extends b{constructor(e,t){super(["getbit",...e],t)}},ec=class extends b{constructor(e,t){super(["getdel",...e],t)}},eh=class extends b{constructor([e,t],s){const i=["getex",e];t&&("ex"in t&&"number"==typeof t.ex?i.push("ex",t.ex):"px"in t&&"number"==typeof t.px?i.push("px",t.px):"exat"in t&&"number"==typeof t.exat?i.push("exat",t.exat):"pxat"in t&&"number"==typeof t.pxat?i.push("pxat",t.pxat):"persist"in t&&t.persist&&i.push("persist")),super(i,s)}},el=class extends b{constructor(e,t){super(["getrange",...e],t)}},ep=class extends b{constructor(e,t){super(["getset",...e],t)}},eu=class extends b{constructor(e,t){super(["hdel",...e],t)}},ed=class extends b{constructor(e,t){super(["hexists",...e],t)}},em=class extends b{constructor(e,t){const[s,i,n,r]=e,a=Array.isArray(i)?i:[i];super(["hexpire",s,n,...r?[r]:[],"FIELDS",a.length,...a],t)}},ef=class extends b{constructor(e,t){const[s,i,n,r]=e,a=Array.isArray(i)?i:[i];super(["hexpireat",s,n,...r?[r]:[],"FIELDS",a.length,...a],t)}},ew=class extends b{constructor(e,t){const[s,i]=e,n=Array.isArray(i)?i:[i];super(["hexpiretime",s,"FIELDS",n.length,...n],t)}},eg=class extends b{constructor(e,t){const[s,i]=e,n=Array.isArray(i)?i:[i];super(["hpersist",s,"FIELDS",n.length,...n],t)}},ex=class extends b{constructor(e,t){const[s,i,n,r]=e,a=Array.isArray(i)?i:[i];super(["hpexpire",s,n,...r?[r]:[],"FIELDS",a.length,...a],t)}},ey=class extends b{constructor(e,t){const[s,i,n,r]=e,a=Array.isArray(i)?i:[i];super(["hpexpireat",s,n,...r?[r]:[],"FIELDS",a.length,...a],t)}},e_=class extends b{constructor(e,t){const[s,i]=e,n=Array.isArray(i)?i:[i];super(["hpexpiretime",s,"FIELDS",n.length,...n],t)}},eb=class extends b{constructor(e,t){const[s,i]=e,n=Array.isArray(i)?i:[i];super(["hpttl",s,"FIELDS",n.length,...n],t)}},eO=class extends b{constructor(e,t){super(["hget",...e],t)}},eS=class extends b{constructor(e,t){super(["hgetall",...e],{deserialize:e=>(function(e){if(0===e.length)return null;let t={};for(let s=0;s<e.length;s+=2){let i=e[s],n=e[s+1];try{let e=!Number.isNaN(Number(n))&&!Number.isSafeInteger(Number(n));t[i]=e?n:JSON.parse(n)}catch{t[i]=n}}return t})(e),...t})}};function eA(e,t){if(t.every(e=>null===e))return null;let s={};for(let[i,n]of e.entries())try{s[n]=JSON.parse(t[i])}catch{s[n]=t[i]}return s}var ev=class extends b{constructor([e,...t],s){super(["hmget",e,...t],{deserialize:e=>eA(t,e),...s})}},eE=class extends b{constructor([e,...t],s){super(["hgetdel",e,"FIELDS",t.length,...t],{deserialize:e=>eA(t.map(String),e),...s})}},eI=class extends b{constructor([e,t,...s],i){const n=["hgetex",e];"ex"in t&&"number"==typeof t.ex?n.push("EX",t.ex):"px"in t&&"number"==typeof t.px?n.push("PX",t.px):"exat"in t&&"number"==typeof t.exat?n.push("EXAT",t.exat):"pxat"in t&&"number"==typeof t.pxat?n.push("PXAT",t.pxat):"persist"in t&&t.persist&&n.push("PERSIST"),n.push("FIELDS",s.length,...s),super(n,{deserialize:e=>eA(s.map(String),e),...i})}},ek=class extends b{constructor(e,t){super(["hincrby",...e],t)}},eR=class extends b{constructor(e,t){super(["hincrbyfloat",...e],t)}},eT=class extends b{constructor([e],t){super(["hkeys",e],t)}},eP=class extends b{constructor(e,t){super(["hlen",...e],t)}},eN=class extends b{constructor([e,t],s){super(["hmset",e,...Object.entries(t).flatMap(([e,t])=>[e,t])],s)}},eU=class extends b{constructor([e,t,s],i){const n=["hscan",e,t];s?.match&&n.push("match",s.match),"number"==typeof s?.count&&n.push("count",s.count),super(n,{deserialize:d,...i})}},eC=class extends b{constructor([e,t],s){super(["hset",e,...Object.entries(t).flatMap(([e,t])=>[e,t])],s)}},e$=class extends b{constructor([e,t,s],i){const n=["hsetex",e];t.conditional&&n.push(t.conditional.toUpperCase()),t.expiration&&("ex"in t.expiration&&"number"==typeof t.expiration.ex?n.push("EX",t.expiration.ex):"px"in t.expiration&&"number"==typeof t.expiration.px?n.push("PX",t.expiration.px):"exat"in t.expiration&&"number"==typeof t.expiration.exat?n.push("EXAT",t.expiration.exat):"pxat"in t.expiration&&"number"==typeof t.expiration.pxat?n.push("PXAT",t.expiration.pxat):"keepttl"in t.expiration&&t.expiration.keepttl&&n.push("KEEPTTL"));const r=Object.entries(s);for(const[e,t]of(n.push("FIELDS",r.length),r))n.push(e,t);super(n,i)}},ez=class extends b{constructor(e,t){super(["hsetnx",...e],t)}},eD=class extends b{constructor(e,t){super(["hstrlen",...e],t)}},eL=class extends b{constructor(e,t){const[s,i]=e,n=Array.isArray(i)?i:[i];super(["httl",s,"FIELDS",n.length,...n],t)}},eM=class extends b{constructor(e,t){super(["hvals",...e],t)}},eF=class extends b{constructor(e,t){super(["incr",...e],t)}},ej=class extends b{constructor(e,t){super(["incrby",...e],t)}},eJ=class extends b{constructor(e,t){super(["incrbyfloat",...e],t)}},eq=class extends b{constructor(e,t){super(["JSON.ARRAPPEND",...e],t)}},eB=class extends b{constructor(e,t){super(["JSON.ARRINDEX",...e],t)}},eK=class extends b{constructor(e,t){super(["JSON.ARRINSERT",...e],t)}},eH=class extends b{constructor(e,t){super(["JSON.ARRLEN",e[0],e[1]??"$"],t)}},eG=class extends b{constructor(e,t){super(["JSON.ARRPOP",...e],t)}},eY=class extends b{constructor(e,t){const s=e[1]??"$",i=e[2]??0,n=e[3]??0;super(["JSON.ARRTRIM",e[0],s,i,n],t)}},eX=class extends b{constructor(e,t){super(["JSON.CLEAR",...e],t)}},eW=class extends b{constructor(e,t){super(["JSON.DEL",...e],t)}},eQ=class extends b{constructor(e,t){super(["JSON.FORGET",...e],t)}},eV=class extends b{constructor(e,t){const s=["JSON.GET"];"string"==typeof e[1]?s.push(...e):(s.push(e[0]),e[1]&&(e[1].indent&&s.push("INDENT",e[1].indent),e[1].newline&&s.push("NEWLINE",e[1].newline),e[1].space&&s.push("SPACE",e[1].space)),s.push(...e.slice(2))),super(s,t)}},eZ=class extends b{constructor(e,t){super(["JSON.MERGE",...e],t)}},e0=class extends b{constructor(e,t){super(["JSON.MGET",...e[0],e[1]],t)}},e1=class extends b{constructor(e,t){const s=["JSON.MSET"];for(const t of e)s.push(t.key,t.path,t.value);super(s,t)}},e2=class extends b{constructor(e,t){super(["JSON.NUMINCRBY",...e],t)}},e5=class extends b{constructor(e,t){super(["JSON.NUMMULTBY",...e],t)}},e3=class extends b{constructor(e,t){super(["JSON.OBJKEYS",...e],t)}},e4=class extends b{constructor(e,t){super(["JSON.OBJLEN",...e],t)}},e6=class extends b{constructor(e,t){super(["JSON.RESP",...e],t)}},e8=class extends b{constructor(e,t){const s=["JSON.SET",e[0],e[1],e[2]];e[3]&&(e[3].nx?s.push("NX"):e[3].xx&&s.push("XX")),super(s,t)}},e7=class extends b{constructor(e,t){super(["JSON.STRAPPEND",...e],t)}},e9=class extends b{constructor(e,t){super(["JSON.STRLEN",...e],t)}},te=class extends b{constructor(e,t){super(["JSON.TOGGLE",...e],t)}},tt=class extends b{constructor(e,t){super(["JSON.TYPE",...e],t)}},ts=class extends b{constructor(e,t){super(["keys",...e],t)}},ti=class extends b{constructor(e,t){super(["lindex",...e],t)}},tn=class extends b{constructor(e,t){super(["linsert",...e],t)}},tr=class extends b{constructor(e,t){super(["llen",...e],t)}},ta=class extends b{constructor(e,t){super(["lmove",...e],t)}},to=class extends b{constructor(e,t){const[s,i,n,r]=e;super(["LMPOP",s,...i,n,...r?["COUNT",r]:[]],t)}},tc=class extends b{constructor(e,t){super(["lpop",...e],t)}},th=class extends b{constructor(e,t){const s=["lpos",e[0],e[1]];"number"==typeof e[2]?.rank&&s.push("rank",e[2].rank),"number"==typeof e[2]?.count&&s.push("count",e[2].count),"number"==typeof e[2]?.maxLen&&s.push("maxLen",e[2].maxLen),super(s,t)}},tl=class extends b{constructor(e,t){super(["lpush",...e],t)}},tp=class extends b{constructor(e,t){super(["lpushx",...e],t)}},tu=class extends b{constructor(e,t){super(["lrange",...e],t)}},td=class extends b{constructor(e,t){super(["lrem",...e],t)}},tm=class extends b{constructor(e,t){super(["lset",...e],t)}},tf=class extends b{constructor(e,t){super(["ltrim",...e],t)}},tw=class extends b{constructor(e,t){super(["mget",...Array.isArray(e[0])?e[0]:e],t)}},tg=class extends b{constructor([e],t){super(["mset",...Object.entries(e).flatMap(([e,t])=>[e,t])],t)}},tx=class extends b{constructor([e],t){super(["msetnx",...Object.entries(e).flat()],t)}},ty=class extends b{constructor(e,t){super(["persist",...e],t)}},t_=class extends b{constructor(e,t){super(["pexpire",...e],t)}},tb=class extends b{constructor(e,t){super(["pexpireat",...e],t)}},tO=class extends b{constructor(e,t){super(["pfadd",...e],t)}},tS=class extends b{constructor(e,t){super(["pfcount",...e],t)}},tA=class extends b{constructor(e,t){super(["pfmerge",...e],t)}},tv=class extends b{constructor(e,t){const s=["ping"];e?.[0]!==void 0&&s.push(e[0]),super(s,t)}},tE=class extends b{constructor(e,t){super(["psetex",...e],t)}},tI=class extends b{constructor(e,t){super(["pttl",...e],t)}},tk=class extends b{constructor(e,t){super(["publish",...e],t)}},tR=class extends b{constructor(e){super(["randomkey"],e)}},tT=class extends b{constructor(e,t){super(["rename",...e],t)}},tP=class extends b{constructor(e,t){super(["renamenx",...e],t)}},tN=class extends b{constructor(e,t){super(["rpop",...e],t)}},tU=class extends b{constructor(e,t){super(["rpush",...e],t)}},tC=class extends b{constructor(e,t){super(["rpushx",...e],t)}},t$=class extends b{constructor(e,t){super(["sadd",...e],t)}},tz=class extends b{constructor([e,t],s){const i=["scan",e];t?.match&&i.push("match",t.match),"number"==typeof t?.count&&i.push("count",t.count),t&&"withType"in t&&!0===t.withType?i.push("withtype"):t&&"type"in t&&t.type&&t.type.length>0&&i.push("type",t.type),super(i,{deserialize:t?.withType?m:d,...s})}},tD=class extends b{constructor(e,t){super(["scard",...e],t)}},tL=class extends b{constructor(e,t){super(["script","exists",...e],{deserialize:e=>e,...t})}},tM=class extends b{constructor([e],t){const s=["script","flush"];e?.sync?s.push("sync"):e?.async&&s.push("async"),super(s,t)}},tF=class extends b{constructor(e,t){super(["script","load",...e],t)}},tj=class extends b{constructor(e,t){super(["sdiff",...e],t)}},tJ=class extends b{constructor(e,t){super(["sdiffstore",...e],t)}},tq=class extends b{constructor([e,t,s],i){const n=["set",e,t];s&&("nx"in s&&s.nx?n.push("nx"):"xx"in s&&s.xx&&n.push("xx"),"get"in s&&s.get&&n.push("get"),"ex"in s&&"number"==typeof s.ex?n.push("ex",s.ex):"px"in s&&"number"==typeof s.px?n.push("px",s.px):"exat"in s&&"number"==typeof s.exat?n.push("exat",s.exat):"pxat"in s&&"number"==typeof s.pxat?n.push("pxat",s.pxat):"keepTtl"in s&&s.keepTtl&&n.push("keepTtl")),super(n,i)}},tB=class extends b{constructor(e,t){super(["setbit",...e],t)}},tK=class extends b{constructor(e,t){super(["setex",...e],t)}},tH=class extends b{constructor(e,t){super(["setnx",...e],t)}},tG=class extends b{constructor(e,t){super(["setrange",...e],t)}},tY=class extends b{constructor(e,t){super(["sinter",...e],t)}},tX=class extends b{constructor(e,t){super(["sinterstore",...e],t)}},tW=class extends b{constructor(e,t){super(["sismember",...e],t)}},tQ=class extends b{constructor(e,t){super(["smembers",...e],t)}},tV=class extends b{constructor(e,t){super(["smismember",e[0],...e[1]],t)}},tZ=class extends b{constructor(e,t){super(["smove",...e],t)}},t0=class extends b{constructor([e,t],s){const i=["spop",e];"number"==typeof t&&i.push(t),super(i,s)}},t1=class extends b{constructor([e,t],s){const i=["srandmember",e];"number"==typeof t&&i.push(t),super(i,s)}},t2=class extends b{constructor(e,t){super(["srem",...e],t)}},t5=class extends b{constructor([e,t,s],i){const n=["sscan",e,t];s?.match&&n.push("match",s.match),"number"==typeof s?.count&&n.push("count",s.count),super(n,{deserialize:d,...i})}},t3=class extends b{constructor(e,t){super(["strlen",...e],t)}},t4=class extends b{constructor(e,t){super(["sunion",...e],t)}},t6=class extends b{constructor(e,t){super(["sunionstore",...e],t)}},t8=class extends b{constructor(e){super(["time"],e)}},t7=class extends b{constructor(e,t){super(["touch",...e],t)}},t9=class extends b{constructor(e,t){super(["ttl",...e],t)}},se=class extends b{constructor(e,t){super(["type",...e],t)}},st=class extends b{constructor(e,t){super(["unlink",...e],t)}},ss=class extends b{constructor([e,t,s],i){super(["XACK",e,t,...Array.isArray(s)?[...s]:[s]],i)}},si=class extends b{constructor([e,t,s,...i],n){const r=["XACKDEL",e,t];r.push(s.toUpperCase()),r.push("IDS",i.length,...i),super(r,n)}},sn=class extends b{constructor([e,t,s,i],n){const r=["XADD",e];for(const[e,n]of(i&&(i.nomkStream&&r.push("NOMKSTREAM"),i.trim&&(r.push(i.trim.type,i.trim.comparison,i.trim.threshold),void 0!==i.trim.limit&&r.push("LIMIT",i.trim.limit))),r.push(t),Object.entries(s)))r.push(e,n);super(r,n)}},sr=class extends b{constructor([e,t,s,i,n,r],a){const o=[];r?.count&&o.push("COUNT",r.count),r?.justId&&o.push("JUSTID"),super(["XAUTOCLAIM",e,t,s,i,n,...o],a)}},sa=class extends b{constructor([e,t,s,i,n,r],a){const o=Array.isArray(n)?[...n]:[n],c=[];r?.idleMS&&c.push("IDLE",r.idleMS),r?.idleMS&&c.push("TIME",r.timeMS),r?.retryCount&&c.push("RETRYCOUNT",r.retryCount),r?.force&&c.push("FORCE"),r?.justId&&c.push("JUSTID"),r?.lastId&&c.push("LASTID",r.lastId),super(["XCLAIM",e,t,s,i,...o,...c],a)}},so=class extends b{constructor([e,t],s){super(["XDEL",e,...Array.isArray(t)?[...t]:[t]],s)}},sc=class extends b{constructor([e,t,...s],i){const n=["XDELEX",e];t&&n.push(t.toUpperCase()),n.push("IDS",s.length,...s),super(n,i)}},sh=class extends b{constructor([e,t],s){const i=["XGROUP"];switch(t.type){case"CREATE":i.push("CREATE",e,t.group,t.id),t.options&&(t.options.MKSTREAM&&i.push("MKSTREAM"),void 0!==t.options.ENTRIESREAD&&i.push("ENTRIESREAD",t.options.ENTRIESREAD.toString()));break;case"CREATECONSUMER":i.push("CREATECONSUMER",e,t.group,t.consumer);break;case"DELCONSUMER":i.push("DELCONSUMER",e,t.group,t.consumer);break;case"DESTROY":i.push("DESTROY",e,t.group);break;case"SETID":i.push("SETID",e,t.group,t.id),t.options?.ENTRIESREAD!==void 0&&i.push("ENTRIESREAD",t.options.ENTRIESREAD.toString());break;default:throw Error("Invalid XGROUP")}super(i,s)}},sl=class extends b{constructor([e,t],s){const i=[];"CONSUMERS"===t.type?i.push("CONSUMERS",e,t.group):i.push("GROUPS",e),super(["XINFO",...i],s)}},sp=class extends b{constructor(e,t){super(["XLEN",...e],t)}},su=class extends b{constructor([e,t,s,i,n,r],a){const o=r?.consumer===void 0?[]:Array.isArray(r.consumer)?[...r.consumer]:[r.consumer];super(["XPENDING",e,t,...r?.idleTime?["IDLE",r.idleTime]:[],s,i,n,...o],a)}},sd=class extends b{constructor([e,
1t,s,i],n){const r=["XRANGE",e,t,s];"number"==typeof i&&r.push("COUNT",i),super(r,{deserialize:e=>(function(e){let t={};for(let s of e)for(let e=0;e<s.length;e+=2){let i=s[e],n=s[e+1];i in t||(t[i]={});for(let e=0;e<n.length;e+=2){let s=n[e],r=n[e+1];try{t[i][s]=JSON.parse(r)}catch{t[i][s]=r}}}return t})(e),...n})}},sm=class extends b{constructor([e,t,s],i){if(Array.isArray(e)&&Array.isArray(t)&&e.length!==t.length)throw Error("ERR Unbalanced XREAD list of streams: for each stream key an ID or '$' must be specified");const n=[];"number"==typeof s?.count&&n.push("COUNT",s.count),"number"==typeof s?.blockMS&&n.push("BLOCK",s.blockMS),n.push("STREAMS",...Array.isArray(e)?[...e]:[e],...Array.isArray(t)?[...t]:[t]),super(["XREAD",...n],i)}},sf=class extends b{constructor([e,t,s,i,n],r){if(Array.isArray(s)&&Array.isArray(i)&&s.length!==i.length)throw Error("ERR Unbalanced XREADGROUP list of streams: for each stream key an ID or '$' must be specified");const a=[];"number"==typeof n?.count&&a.push("COUNT",n.count),"number"==typeof n?.blockMS&&a.push("BLOCK",n.blockMS),"boolean"==typeof n?.NOACK&&n.NOACK&&a.push("NOACK"),a.push("STREAMS",...Array.isArray(s)?[...s]:[s],...Array.isArray(i)?[...i]:[i]),super(["XREADGROUP","GROUP",e,t,...a],r)}},sw=class extends b{constructor([e,t,s,i],n){const r=["XREVRANGE",e,t,s];"number"==typeof i&&r.push("COUNT",i),super(r,{deserialize:e=>(function(e){let t={};for(let s of e)for(let e=0;e<s.length;e+=2){let i=s[e],n=s[e+1];i in t||(t[i]={});for(let e=0;e<n.length;e+=2){let s=n[e],r=n[e+1];try{t[i][s]=JSON.parse(r)}catch{t[i][s]=r}}}return t})(e),...n})}},sg=class extends b{constructor([e,t],s){const{limit:i,strategy:n,threshold:r,exactness:a="~"}=t;super(["XTRIM",e,n,a,r,...i?["LIMIT",i]:[]],s)}},sx=class extends b{constructor([e,t,...s],i){const n=["zadd",e];"nx"in t&&t.nx?n.push("nx"):"xx"in t&&t.xx&&n.push("xx"),"ch"in t&&t.ch&&n.push("ch"),"incr"in t&&t.incr&&n.push("incr"),"lt"in t&&t.lt?n.push("lt"):"gt"in t&&t.gt&&n.push("gt"),"score"in t&&"member"in t&&n.push(t.score,t.member),n.push(...s.flatMap(({score:e,member:t})=>[e,t])),super(n,i)}},sy=class extends b{constructor(e,t){super(["zcard",...e],t)}},s_=class extends b{constructor(e,t){super(["zcount",...e],t)}},sb=class extends b{constructor(e,t){super(["zincrby",...e],t)}},sO=class extends b{constructor([e,t,s,i],n){const r=["zinterstore",e,t];Array.isArray(s)?r.push(...s):r.push(s),i&&("weights"in i&&i.weights?r.push("weights",...i.weights):"weight"in i&&"number"==typeof i.weight&&r.push("weights",i.weight),"aggregate"in i&&r.push("aggregate",i.aggregate)),super(r,n)}},sS=class extends b{constructor(e,t){super(["zlexcount",...e],t)}},sA=class extends b{constructor([e,t],s){const i=["zpopmax",e];"number"==typeof t&&i.push(t),super(i,s)}},sv=class extends b{constructor([e,t],s){const i=["zpopmin",e];"number"==typeof t&&i.push(t),super(i,s)}},sE=class extends b{constructor([e,t,s,i],n){const r=["zrange",e,t,s];i?.byScore&&r.push("byscore"),i?.byLex&&r.push("bylex"),i?.rev&&r.push("rev"),i?.count!==void 0&&void 0!==i.offset&&r.push("limit",i.offset,i.count),i?.withScores&&r.push("withscores"),super(r,n)}},sI=class extends b{constructor(e,t){super(["zrank",...e],t)}},sk=class extends b{constructor(e,t){super(["zrem",...e],t)}},sR=class extends b{constructor(e,t){super(["zremrangebylex",...e],t)}},sT=class extends b{constructor(e,t){super(["zremrangebyrank",...e],t)}},sP=class extends b{constructor(e,t){super(["zremrangebyscore",...e],t)}},sN=class extends b{constructor(e,t){super(["zrevrank",...e],t)}},sU=class extends b{constructor([e,t,s],i){const n=["zscan",e,t];s?.match&&n.push("match",s.match),"number"==typeof s?.count&&n.push("count",s.count),super(n,{deserialize:d,...i})}},sC=class extends b{constructor(e,t){super(["zscore",...e],t)}},s$=class extends b{constructor([e,t,s],i){const n=["zunion",e];Array.isArray(t)?n.push(...t):n.push(t),s&&("weights"in s&&s.weights?n.push("weights",...s.weights):"weight"in s&&"number"==typeof s.weight&&n.push("weights",s.weight),"aggregate"in s&&n.push("aggregate",s.aggregate),s.withScores&&n.push("withscores")),super(n,i)}},sz=class extends b{constructor([e,t,s,i],n){const r=["zunionstore",e,t];Array.isArray(s)?r.push(...s):r.push(s),i&&("weights"in i&&i.weights?r.push("weights",...i.weights):"weight"in i&&"number"==typeof i.weight&&r.push("weights",i.weight),"aggregate"in i&&r.push("aggregate",i.aggregate)),super(r,n)}},sD=class extends b{constructor(e,t){super(["zdiffstore",...e],t)}},sL=class extends b{constructor(e,t){const[s,i]=e;super(["zmscore",s,...i],t)}},sM=class{client;commands;commandOptions;multiExec;constructor(e){if(this.client=e.client,this.commands=[],this.commandOptions=e.commandOptions,this.multiExec=e.multiExec??!1,this.commandOptions?.latencyLogging){const e=this.exec.bind(this);this.exec=async t=>{let s=performance.now(),i=await (t?e(t):e()),n=(performance.now()-s).toFixed(2);return console.log(`Latency for \x1b[38;2;19;185;39m${this.multiExec?["MULTI-EXEC"]:["PIPELINE"].toString().toUpperCase()}\x1b[0m: \x1b[38;2;0;255;255m${n} ms\x1b[0m`),i}}}exec=async e=>{if(0===this.commands.length)throw Error("Pipeline is empty");let t=this.multiExec?["multi-exec"]:["pipeline"],s=await this.client.request({path:t,body:Object.values(this.commands).map(e=>e.command)});return e?.keepErrors?s.map(({error:e,result:t},s)=>({error:e,result:this.commands[s].deserialize(t)})):s.map(({error:e,result:t},s)=>{if(e)throw new h(`Command ${s+1} [ ${this.commands[s].command[0]} ] failed: ${e}`);return this.commands[s].deserialize(t)})};length(){return this.commands.length}chain(e){return this.commands.push(e),this}append=(...e)=>this.chain(new S(e,this.commandOptions));bitcount=(...e)=>this.chain(new A(e,this.commandOptions));bitfield=(...e)=>new v(e,this.client,this.commandOptions,this.chain.bind(this));bitop=(e,t,s,...i)=>this.chain(new E([e,t,s,...i],this.commandOptions));bitpos=(...e)=>this.chain(new I(e,this.commandOptions));clientSetinfo=(...e)=>this.chain(new k(e,this.commandOptions));copy=(...e)=>this.chain(new R(e,this.commandOptions));zdiffstore=(...e)=>this.chain(new sD(e,this.commandOptions));dbsize=()=>this.chain(new T(this.commandOptions));decr=(...e)=>this.chain(new P(e,this.commandOptions));decrby=(...e)=>this.chain(new N(e,this.commandOptions));del=(...e)=>this.chain(new U(e,this.commandOptions));echo=(...e)=>this.chain(new C(e,this.commandOptions));evalRo=(...e)=>this.chain(new $(e,this.commandOptions));eval=(...e)=>this.chain(new z(e,this.commandOptions));evalshaRo=(...e)=>this.chain(new D(e,this.commandOptions));evalsha=(...e)=>this.chain(new L(e,this.commandOptions));exists=(...e)=>this.chain(new F(e,this.commandOptions));expire=(...e)=>this.chain(new j(e,this.commandOptions));expireat=(...e)=>this.chain(new J(e,this.commandOptions));flushall=e=>this.chain(new K(e,this.commandOptions));flushdb=(...e)=>this.chain(new H(e,this.commandOptions));geoadd=(...e)=>this.chain(new ee(e,this.commandOptions));geodist=(...e)=>this.chain(new et(e,this.commandOptions));geopos=(...e)=>this.chain(new ei(e,this.commandOptions));geohash=(...e)=>this.chain(new es(e,this.commandOptions));geosearch=(...e)=>this.chain(new en(e,this.commandOptions));geosearchstore=(...e)=>this.chain(new er(e,this.commandOptions));get=(...e)=>this.chain(new ea(e,this.commandOptions));getbit=(...e)=>this.chain(new eo(e,this.commandOptions));getdel=(...e)=>this.chain(new ec(e,this.commandOptions));getex=(...e)=>this.chain(new eh(e,this.commandOptions));getrange=(...e)=>this.chain(new el(e,this.commandOptions));getset=(e,t)=>this.chain(new ep([e,t],this.commandOptions));hdel=(...e)=>this.chain(new eu(e,this.commandOptions));hexists=(...e)=>this.chain(new ed(e,this.commandOptions));hexpire=(...e)=>this.chain(new em(e,this.commandOptions));hexpireat=(...e)=>this.chain(new ef(e,this.commandOptions));hexpiretime=(...e)=>this.chain(new ew(e,this.commandOptions));httl=(...e)=>this.chain(new eL(e,this.commandOptions));hpexpire=(...e)=>this.chain(new ex(e,this.commandOptions));hpexpireat=(...e)=>this.chain(new ey(e,this.commandOptions));hpexpiretime=(...e)=>this.chain(new e_(e,this.commandOptions));hpttl=(...e)=>this.chain(new eb(e,this.commandOptions));hpersist=(...e)=>this.chain(new eg(e,this.commandOptions));hget=(...e)=>this.chain(new eO(e,this.commandOptions));hgetall=(...e)=>this.chain(new eS(e,this.commandOptions));hgetdel=(...e)=>this.chain(new eE(e,this.commandOptions));hgetex=(...e)=>this.chain(new eI(e,this.commandOptions));hincrby=(...e)=>this.chain(new ek(e,this.commandOptions));hincrbyfloat=(...e)=>this.chain(new eR(e,this.commandOptions));hkeys=(...e)=>this.chain(new eT(e,this.commandOptions));hlen=(...e)=>this.chain(new eP(e,this.commandOptions));hmget=(...e)=>this.chain(new ev(e,this.commandOptions));hmset=(e,t)=>this.chain(new eN([e,t],this.commandOptions));hrandfield=(e,t,s)=>this.chain(new O([e,t,s],this.commandOptions));hscan=(...e)=>this.chain(new eU(e,this.commandOptions));hset=(e,t)=>this.chain(new eC([e,t],this.commandOptions));hsetex=(...e)=>this.chain(new e$(e,this.commandOptions));hsetnx=(e,t,s)=>this.chain(new ez([e,t,s],this.commandOptions));hstrlen=(...e)=>this.chain(new eD(e,this.commandOptions));hvals=(...e)=>this.chain(new eM(e,this.commandOptions));incr=(...e)=>this.chain(new eF(e,this.commandOptions));incrby=(...e)=>this.chain(new ej(e,this.commandOptions));incrbyfloat=(...e)=>this.chain(new eJ(e,this.commandOptions));keys=(...e)=>this.chain(new ts(e,this.commandOptions));lindex=(...e)=>this.chain(new ti(e,this.commandOptions));linsert=(e,t,s,i)=>this.chain(new tn([e,t,s,i],this.commandOptions));llen=(...e)=>this.chain(new tr(e,this.commandOptions));lmove=(...e)=>this.chain(new ta(e,this.commandOptions));lpop=(...e)=>this.chain(new tc(e,this.commandOptions));lmpop=(...e)=>this.chain(new to(e,this.commandOptions));lpos=(...e)=>this.chain(new th(e,this.commandOptions));lpush=(e,...t)=>this.chain(new tl([e,...t],this.commandOptions));lpushx=(e,...t)=>this.chain(new tp([e,...t],this.commandOptions));lrange=(...e)=>this.chain(new tu(e,this.commandOptions));lrem=(e,t,s)=>this.chain(new td([e,t,s],this.commandOptions));lset=(e,t,s)=>this.chain(new tm([e,t,s],this.commandOptions));ltrim=(...e)=>this.chain(new tf(e,this.commandOptions));mget=(...e)=>this.chain(new tw(e,this.commandOptions));mset=e=>this.chain(new tg([e],this.commandOptions));msetnx=e=>this.chain(new tx([e],this.commandOptions));persist=(...e)=>this.chain(new ty(e,this.commandOptions));pexpire=(...e)=>this.chain(new t_(e,this.commandOptions));pexpireat=(...e)=>this.chain(new tb(e,this.commandOptions));pfadd=(...e)=>this.chain(new tO(e,this.commandOptions));pfcount=(...e)=>this.chain(new tS(e,this.commandOptions));pfmerge=(...e)=>this.chain(new tA(e,this.commandOptions));ping=e=>this.chain(new tv(e,this.commandOptions));psetex=(e,t,s)=>this.chain(new tE([e,t,s],this.commandOptions));pttl=(...e)=>this.chain(new tI(e,this.commandOptions));publish=(...e)=>this.chain(new tk(e,this.commandOptions));randomkey=()=>this.chain(new tR(this.commandOptions));rename=(...e)=>this.chain(new tT(e,this.commandOptions));renamenx=(...e)=>this.chain(new tP(e,this.commandOptions));rpop=(...e)=>this.chain(new tN(e,this.commandOptions));rpush=(e,...t)=>this.chain(new tU([e,...t],this.commandOptions));rpushx=(e,...t)=>this.chain(new tC([e,...t],this.commandOptions));sadd=(e,t,...s)=>this.chain(new t$([e,t,...s],this.commandOptions));scan=(...e)=>this.chain(new tz(e,this.commandOptions));scard=(...e)=>this.chain(new tD(e,this.commandOptions));scriptExists=(...e)=>this.chain(new tL(e,this.commandOptions));scriptFlush=(...e)=>this.chain(new tM(e,this.commandOptions));scriptLoad=(...e)=>this.chain(new tF(e,this.commandOptions));sdiff=(...e)=>this.chain(new tj(e,this.commandOptions));sdiffstore=(...e)=>this.chain(new tJ(e,this.commandOptions));set=(e,t,s)=>this.chain(new tq([e,t,s],this.commandOptions));setbit=(...e)=>this.chain(new tB(e,this.commandOptions));setex=(e,t,s)=>this.chain(new tK([e,t,s],this.commandOptions));setnx=(e,t)=>this.chain(new tH([e,t],this.commandOptions));setrange=(...e)=>this.chain(new tG(e,this.commandOptions));sinter=(...e)=>this.chain(new tY(e,this.commandOptions));sinterstore=(...e)=>this.chain(new tX(e,this.commandOptions));sismember=(e,t)=>this.chain(new tW([e,t],this.commandOptions));smembers=(...e)=>this.chain(new tQ(e,this.commandOptions));smismember=(e,t)=>this.chain(new tV([e,t],this.commandOptions));smove=(e,t,s)=>this.chain(new tZ([e,t,s],this.commandOptions));spop=(...e)=>this.chain(new t0(e,this.commandOptions));srandmember=(...e)=>this.chain(new t1(e,this.commandOptions));srem=(e,...t)=>this.chain(new t2([e,...t],this.commandOptions));sscan=(...e)=>this.chain(new t5(e,this.commandOptions));strlen=(...e)=>this.chain(new t3(e,this.commandOptions));sunion=(...e)=>this.chain(new t4(e,this.commandOptions));sunionstore=(...e)=>this.chain(new t6(e,this.commandOptions));time=()=>this.chain(new t8(this.commandOptions));touch=(...e)=>this.chain(new t7(e,this.commandOptions));ttl=(...e)=>this.chain(new t9(e,this.commandOptions));type=(...e)=>this.chain(new se(e,this.commandOptions));unlink=(...e)=>this.chain(new st(e,this.commandOptions));zadd=(...e)=>("score"in e[1],this.chain(new sx([e[0],e[1],...e.slice(2)],this.commandOptions)));xadd=(...e)=>this.chain(new sn(e,this.commandOptions));xack=(...e)=>this.chain(new ss(e,this.commandOptions));xackdel=(...e)=>this.chain(new si(e,this.commandOptions));xdel=(...e)=>this.chain(new so(e,this.commandOptions));xdelex=(...e)=>this.chain(new sc(e,this.commandOptions));xgroup=(...e)=>this.chain(new sh(e,this.commandOptions));xread=(...e)=>this.chain(new sm(e,this.commandOptions));xreadgroup=(...e)=>this.chain(new sf(e,this.commandOptions));xinfo=(...e)=>this.chain(new sl(e,this.commandOptions));xlen=(...e)=>this.chain(new sp(e,this.commandOptions));xpending=(...e)=>this.chain(new su(e,this.commandOptions));xclaim=(...e)=>this.chain(new sa(e,this.commandOptions));xautoclaim=(...e)=>this.chain(new sr(e,this.commandOptions));xtrim=(...e)=>this.chain(new sg(e,this.commandOptions));xrange=(...e)=>this.chain(new sd(e,this.commandOptions));xrevrange=(...e)=>this.chain(new sw(e,this.commandOptions));zcard=(...e)=>this.chain(new sy(e,this.commandOptions));zcount=(...e)=>this.chain(new s_(e,this.commandOptions));zincrby=(e,t,s)=>this.chain(new sb([e,t,s],this.commandOptions));zinterstore=(...e)=>this.chain(new sO(e,this.commandOptions));zlexcount=(...e)=>this.chain(new sS(e,this.commandOptions));zmscore=(...e)=>this.chain(new sL(e,this.commandOptions));zpopmax=(...e)=>this.chain(new sA(e,this.commandOptions));zpopmin=(...e)=>this.chain(new sv(e,this.commandOptions));zrange=(...e)=>this.chain(new sE(e,this.commandOptions));zrank=(e,t)=>this.chain(new sI([e,t],this.commandOptions));zrem=(e,...t)=>this.chain(new sk([e,...t],this.commandOptions));zremrangebylex=(...e)=>this.chain(new sR(e,this.commandOptions));zremrangebyrank=(...e)=>this.chain(new sT(e,this.commandOptions));zremrangebyscore=(...e)=>this.chain(new sP(e,this.commandOptions));zrevrank=(e,t)=>this.chain(new sN([e,t],this.commandOptions));zscan=(...e)=>this.chain(new sU(e,this.commandOptions));zscore=(e,t)=>
1this.chain(new sC([e,t],this.commandOptions));zunionstore=(...e)=>this.chain(new sz(e,this.commandOptions));zunion=(...e)=>this.chain(new s$(e,this.commandOptions));get json(){return{arrappend:(...e)=>this.chain(new eq(e,this.commandOptions)),arrindex:(...e)=>this.chain(new eB(e,this.commandOptions)),arrinsert:(...e)=>this.chain(new eK(e,this.commandOptions)),arrlen:(...e)=>this.chain(new eH(e,this.commandOptions)),arrpop:(...e)=>this.chain(new eG(e,this.commandOptions)),arrtrim:(...e)=>this.chain(new eY(e,this.commandOptions)),clear:(...e)=>this.chain(new eX(e,this.commandOptions)),del:(...e)=>this.chain(new eW(e,this.commandOptions)),forget:(...e)=>this.chain(new eQ(e,this.commandOptions)),get:(...e)=>this.chain(new eV(e,this.commandOptions)),merge:(...e)=>this.chain(new eZ(e,this.commandOptions)),mget:(...e)=>this.chain(new e0(e,this.commandOptions)),mset:(...e)=>this.chain(new e1(e,this.commandOptions)),numincrby:(...e)=>this.chain(new e2(e,this.commandOptions)),nummultby:(...e)=>this.chain(new e5(e,this.commandOptions)),objkeys:(...e)=>this.chain(new e3(e,this.commandOptions)),objlen:(...e)=>this.chain(new e4(e,this.commandOptions)),resp:(...e)=>this.chain(new e6(e,this.commandOptions)),set:(...e)=>this.chain(new e8(e,this.commandOptions)),strappend:(...e)=>this.chain(new e7(e,this.commandOptions)),strlen:(...e)=>this.chain(new e9(e,this.commandOptions)),toggle:(...e)=>this.chain(new te(e,this.commandOptions)),type:(...e)=>this.chain(new tt(e,this.commandOptions))}}get functions(){return{load:(...e)=>this.chain(new Q(e,this.commandOptions)),list:(...e)=>this.chain(new X(e,this.commandOptions)),delete:(...e)=>this.chain(new G(e,this.commandOptions)),flush:()=>this.chain(new Y(this.commandOptions)),stats:()=>this.chain(new V(this.commandOptions)),call:(...e)=>this.chain(new q(e,this.commandOptions)),callRo:(...e)=>this.chain(new B(e,this.commandOptions))}}},sF=new Set(["scan","keys","flushdb","flushall","dbsize","hscan","hgetall","hkeys","lrange","sscan","smembers","xrange","xrevrange","zscan","zrange","exec"]),sj=class{pipelinePromises=new WeakMap;activePipeline=null;indexInCurrentPipeline=0;redis;pipeline;pipelineCounter=0;constructor(e){this.redis=e,this.pipeline=e.pipeline()}async withAutoPipeline(e){let t=this.activePipeline??this.redis.pipeline();this.activePipeline||(this.activePipeline=t,this.indexInCurrentPipeline=0);let s=this.indexInCurrentPipeline++;e(t);let i=this.deferExecution().then(()=>{if(!this.pipelinePromises.has(t)){let e=t.exec({keepErrors:!0});this.pipelineCounter+=1,this.pipelinePromises.set(t,e),this.activePipeline=null}return this.pipelinePromises.get(t)}),n=(await i)[s];if(n.error)throw new h(`Command failed: ${n.error}`);return n.result}async deferExecution(){await Promise.resolve(),await Promise.resolve()}},sJ=class extends b{constructor(e,t){super([],{...t,headers:{Accept:"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"},path:["psubscribe",...e],streamOptions:{isStreaming:!0,onMessage:t?.streamOptions?.onMessage,signal:t?.streamOptions?.signal}})}},sq=class extends EventTarget{subscriptions;client;listeners;opts;constructor(e,t,s=!1,i){for(const n of(super(),this.client=e,this.subscriptions=new Map,this.listeners=new Map,this.opts=i,t))s?this.subscribeToPattern(n):this.subscribeToChannel(n)}subscribeToChannel(e){let t=new AbortController,s=new sB([e],{streamOptions:{signal:t.signal,onMessage:e=>this.handleMessage(e,!1)}});s.exec(this.client).catch(e=>{"AbortError"!==e.name&&this.dispatchToListeners("error",e)}),this.subscriptions.set(e,{command:s,controller:t,isPattern:!1})}subscribeToPattern(e){let t=new AbortController,s=new sJ([e],{streamOptions:{signal:t.signal,onMessage:e=>this.handleMessage(e,!0)}});s.exec(this.client).catch(e=>{"AbortError"!==e.name&&this.dispatchToListeners("error",e)}),this.subscriptions.set(e,{command:s,controller:t,isPattern:!0})}handleMessage(e,t){let s=e.replace(/^data:\s*/,""),i=s.indexOf(","),n=s.indexOf(",",i+1),r=t?s.indexOf(",",n+1):-1;if(-1!==i&&-1!==n){let e=s.slice(0,i);if(t&&"pmessage"===e&&-1!==r){let e=s.slice(i+1,n),t=s.slice(n+1,r),a=s.slice(r+1);try{let s=this.opts?.automaticDeserialization===!1?a:JSON.parse(a);this.dispatchToListeners("pmessage",{pattern:e,channel:t,message:s}),this.dispatchToListeners(`pmessage:${e}`,{pattern:e,channel:t,message:s})}catch(e){this.dispatchToListeners("error",Error(`Failed to parse message: ${e}`))}}else{let t=s.slice(i+1,n),r=s.slice(n+1);try{if("subscribe"===e||"psubscribe"===e||"unsubscribe"===e||"punsubscribe"===e){let t=Number.parseInt(r);this.dispatchToListeners(e,t)}else{let s=this.opts?.automaticDeserialization===!1?r:sK(r);this.dispatchToListeners(e,{channel:t,message:s}),this.dispatchToListeners(`${e}:${t}`,{channel:t,message:s})}}catch(e){this.dispatchToListeners("error",Error(`Failed to parse message: ${e}`))}}}}dispatchToListeners(e,t){let s=this.listeners.get(e);if(s)for(let e of s)e(t)}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e)?.add(t)}removeAllListeners(){this.listeners.clear()}async unsubscribe(e){if(e)for(let t of e){let e=this.subscriptions.get(t);if(e){try{e.controller.abort()}catch{}this.subscriptions.delete(t)}}else{for(let e of this.subscriptions.values())try{e.controller.abort()}catch{}this.subscriptions.clear(),this.removeAllListeners()}}getSubscribedChannels(){return[...this.subscriptions.keys()]}},sB=class extends b{constructor(e,t){super([],{...t,headers:{Accept:"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"},path:["subscribe",...e],streamOptions:{isStreaming:!0,onMessage:t?.streamOptions?.onMessage,signal:t?.streamOptions?.signal}})}},sK=e=>{try{return JSON.parse(e)}catch{return e}},sH=class{script;sha1;redis;constructor(e,t){this.redis=e,this.script=t,this.sha1="",this.init(t)}async init(e){this.sha1||(this.sha1=await this.digest(e))}async eval(e,t){return await this.init(this.script),await this.redis.eval(this.script,e,t)}async evalsha(e,t){return await this.init(this.script),await this.redis.evalsha(this.sha1,e,t)}async exec(e,t){return await this.init(this.script),await this.redis.evalsha(this.sha1,e,t).catch(async s=>{if(s instanceof Error&&s.message.toLowerCase().includes("noscript"))return await this.redis.eval(this.script,e,t);throw s})}async digest(e){let t=new TextEncoder().encode(e);return[...new Uint8Array(await n.digest("SHA-1",t))].map(e=>e.toString(16).padStart(2,"0")).join("")}},sG=class{script;sha1;redis;constructor(e,t){this.redis=e,this.sha1="",this.script=t,this.init(t)}async init(e){this.sha1||(this.sha1=await this.digest(e))}async evalRo(e,t){return await this.init(this.script),await this.redis.evalRo(this.script,e,t)}async evalshaRo(e,t){return await this.init(this.script),await this.redis.evalshaRo(this.sha1,e,t)}async exec(e,t){return await this.init(this.script),await this.redis.evalshaRo(this.sha1,e,t).catch(async s=>{if(s instanceof Error&&s.message.toLowerCase().includes("noscript"))return await this.redis.evalRo(this.script,e,t);throw s})}async digest(e){let t=new TextEncoder().encode(e);return[...new Uint8Array(await n.digest("SHA-1",t))].map(e=>e.toString(16).padStart(2,"0")).join("")}},sY=class{client;opts;enableTelemetry;enableAutoPipelining;constructor(e,t){this.client=e,this.opts=t,this.enableTelemetry=t?.enableTelemetry??!0,t?.readYourWrites===!1&&(this.client.readYourWrites=!1),this.enableAutoPipelining=t?.enableAutoPipelining??!0}get readYourWritesSyncToken(){return this.client.upstashSyncToken}set readYourWritesSyncToken(e){this.client.upstashSyncToken=e}get json(){return{arrappend:(...e)=>new eq(e,this.opts).exec(this.client),arrindex:(...e)=>new eB(e,this.opts).exec(this.client),arrinsert:(...e)=>new eK(e,this.opts).exec(this.client),arrlen:(...e)=>new eH(e,this.opts).exec(this.client),arrpop:(...e)=>new eG(e,this.opts).exec(this.client),arrtrim:(...e)=>new eY(e,this.opts).exec(this.client),clear:(...e)=>new eX(e,this.opts).exec(this.client),del:(...e)=>new eW(e,this.opts).exec(this.client),forget:(...e)=>new eQ(e,this.opts).exec(this.client),get:(...e)=>new eV(e,this.opts).exec(this.client),merge:(...e)=>new eZ(e,this.opts).exec(this.client),mget:(...e)=>new e0(e,this.opts).exec(this.client),mset:(...e)=>new e1(e,this.opts).exec(this.client),numincrby:(...e)=>new e2(e,this.opts).exec(this.client),nummultby:(...e)=>new e5(e,this.opts).exec(this.client),objkeys:(...e)=>new e3(e,this.opts).exec(this.client),objlen:(...e)=>new e4(e,this.opts).exec(this.client),resp:(...e)=>new e6(e,this.opts).exec(this.client),set:(...e)=>new e8(e,this.opts).exec(this.client),strappend:(...e)=>new e7(e,this.opts).exec(this.client),strlen:(...e)=>new e9(e,this.opts).exec(this.client),toggle:(...e)=>new te(e,this.opts).exec(this.client),type:(...e)=>new tt(e,this.opts).exec(this.client)}}get functions(){return{load:(...e)=>new Q(e,this.opts).exec(this.client),list:(...e)=>new X(e,this.opts).exec(this.client),delete:(...e)=>new G(e,this.opts).exec(this.client),flush:()=>new Y(this.opts).exec(this.client),stats:()=>new V(this.opts).exec(this.client),call:(...e)=>new q(e,this.opts).exec(this.client),callRo:(...e)=>new B(e,this.opts).exec(this.client)}}use=e=>{let t=this.client.request.bind(this.client);this.client.request=s=>e(s,t)};addTelemetry=e=>{if(this.enableTelemetry)try{this.client.mergeTelemetry(e)}catch{}};createScript(e,t){return t?.readonly?new sG(this,e):new sH(this,e)}pipeline=()=>new sM({client:this.client,commandOptions:this.opts,multiExec:!1});autoPipeline=()=>(function e(t,s="root"){return t.autoPipelineExecutor||(t.autoPipelineExecutor=new sj(t)),new Proxy(t,{get:(t,i)=>{if("pipelineCounter"===i)return t.autoPipelineExecutor.pipelineCounter;if("root"===s&&"json"===i)return e(t,"json");if("root"===s&&"functions"===i)return e(t,"functions");
1if("root"===s){let e=i in t&&!(i in t.autoPipelineExecutor.pipeline),s=sF.has(i);if(e||s)return t[i]}let n=t.autoPipelineExecutor.pipeline,r="json"===s?n.json[i]:"functions"===s?n.functions[i]:n[i];return"function"==typeof r?(...e)=>t.autoPipelineExecutor.withAutoPipeline(t=>{("json"===s?t.json[i]:"functions"===s?t.functions[i]:t[i])(...e)}):r}})})(this);multi=()=>new sM({client:this.client,commandOptions:this.opts,multiExec:!0});bitfield=(...e)=>new v(e,this.client,this.opts);append=(...e)=>new S(e,this.opts).exec(this.client);bitcount=(...e)=>new A(e,this.opts).exec(this.client);bitop=(e,t,s,...i)=>new E([e,t,s,...i],this.opts).exec(this.client);bitpos=(...e)=>new I(e,this.opts).exec(this.client);clientSetinfo=(...e)=>new k(e,this.opts).exec(this.client);copy=(...e)=>new R(e,this.opts).exec(this.client);dbsize=()=>new T(this.opts).exec(this.client);decr=(...e)=>new P(e,this.opts).exec(this.client);decrby=(...e)=>new N(e,this.opts).exec(this.client);del=(...e)=>new U(e,this.opts).exec(this.client);echo=(...e)=>new C(e,this.opts).exec(this.client);evalRo=(...e)=>new $(e,this.opts).exec(this.client);eval=(...e)=>new z(e,this.opts).exec(this.client);evalshaRo=(...e)=>new D(e,this.opts).exec(this.client);evalsha=(...e)=>new L(e,this.opts).exec(this.client);exec=e=>new M(e,this.opts).exec(this.client);exists=(...e)=>new F(e,this.opts).exec(this.client);expire=(...e)=>new j(e,this.opts).exec(this.client);expireat=(...e)=>new J(e,this.opts).exec(this.client);flushall=e=>new K(e,this.opts).exec(this.client);flushdb=(...e)=>new H(e,this.opts).exec(this.client);geoadd=(...e)=>new ee(e,this.opts).exec(this.client);geopos=(...e)=>new ei(e,this.opts).exec(this.client);geodist=(...e)=>new et(e,this.opts).exec(this.client);geohash=(...e)=>new es(e,this.opts).exec(this.client);geosearch=(...e)=>new en(e,this.opts).exec(this.client);geosearchstore=(...e)=>new er(e,this.opts).exec(this.client);get=(...e)=>new ea(e,this.opts).exec(this.client);getbit=(...e)=>new eo(e,this.opts).exec(this.client);getdel=(...e)=>new ec(e,this.opts).exec(this.client);getex=(...e)=>new eh(e,this.opts).exec(this.client);getrange=(...e)=>new el(e,this.opts).exec(this.client);getset=(e,t)=>new ep([e,t],this.opts).exec(this.client);hdel=(...e)=>new eu(e,this.opts).exec(this.client);hexists=(...e)=>new ed(e,this.opts).exec(this.client);hexpire=(...e)=>new em(e,this.opts).exec(this.client);hexpireat=(...e)=>new ef(e,this.opts).exec(this.client);hexpiretime=(...e)=>new ew(e,this.opts).exec(this.client);httl=(...e)=>new eL(e,this.opts).exec(this.client);hpexpire=(...e)=>new ex(e,this.opts).exec(this.client);hpexpireat=(...e)=>new ey(e,this.opts).exec(this.client);hpexpiretime=(...e)=>new e_(e,this.opts).exec(this.client);hpttl=(...e)=>new eb(e,this.opts).exec(this.client);hpersist=(...e)=>new eg(e,this.opts).exec(this.client);hget=(...e)=>new eO(e,this.opts).exec(this.client);hgetall=(...e)=>new eS(e,this.opts).exec(this.client);hgetdel=(...e)=>new eE(e,this.opts).exec(this.client);hgetex=(...e)=>new eI(e,this.opts).exec(this.client);hincrby=(...e)=>new ek(e,this.opts).exec(this.client);hincrbyfloat=(...e)=>new eR(e,this.opts).exec(this.client);hkeys=(...e)=>new eT(e,this.opts).exec(this.client);hlen=(...e)=>new eP(e,this.opts).exec(this.client);hmget=(...e)=>new ev(e,this.opts).exec(this.client);hmset=(e,t)=>new eN([e,t],this.opts).exec(this.client);hrandfield=(e,t,s)=>new O([e,t,s],this.opts).exec(this.client);hscan=(...e)=>new eU(e,this.opts).exec(this.client);hset=(e,t)=>new eC([e,t],this.opts).exec(this.client);hsetex=(...e)=>new e$(e,this.opts).exec(this.client);hsetnx=(e,t,s)=>new ez([e,t,s],this.opts).exec(this.client);hstrlen=(...e)=>new eD(e,this.opts).exec(this.client);hvals=(...e)=>new eM(e,this.opts).exec(this.client);incr=(...e)=>new eF(e,this.opts).exec(this.client);incrby=(...e)=>new ej(e,this.opts).exec(this.client);incrbyfloat=(...e)=>new eJ(e,this.opts).exec(this.client);keys=(...e)=>new ts(e,this.opts).exec(this.client);lindex=(...e)=>new ti(e,this.opts).exec(this.client);linsert=(e,t,s,i)=>new tn([e,t,s,i],this.opts).exec(this.client);llen=(...e)=>new tr(e,this.opts).exec(this.client);lmove=(...e)=>new ta(e,this.opts).exec(this.client);lpop=(...e)=>new tc(e,this.opts).exec(this.client);lmpop=(...e)=>new to(e,this.opts).exec(this.client);lpos=(...e)=>new th(e,this.opts).exec(this.client);lpush=(e,...t)=>new tl([e,...t],this.opts).exec(this.client);lpushx=(e,...t)=>new tp([e,...t],this.opts).exec(this.client);lrange=(...e)=>new tu(e,this.opts).exec(this.client);lrem=(e,t,s)=>new td([e,t,s],this.opts).exec(this.client);lset=(e,t,s)=>new tm([e,t,s],this.opts).exec(this.client);ltrim=(...e)=>new tf(e,this.opts).exec(this.client);mget=(...e)=>new tw(e,this.opts).exec(this.client);mset=e=>new tg([e],this.opts).exec(this.client);msetnx=e=>
1new tx([e],this.opts).exec(this.client);persist=(...e)=>new ty(e,this.opts).exec(this.client);pexpire=(...e)=>new t_(e,this.opts).exec(this.client);pexpireat=(...e)=>new tb(e,this.opts).exec(this.client);pfadd=(...e)=>new tO(e,this.opts).exec(this.client);pfcount=(...e)=>new tS(e,this.opts).exec(this.client);pfmerge=(...e)=>new tA(e,this.opts).exec(this.client);ping=e=>new tv(e,this.opts).exec(this.client);psetex=(e,t,s)=>new tE([e,t,s],this.opts).exec(this.client);psubscribe=e=>{let t=Array.isArray(e)?e:[e];return new sq(this.client,t,!0,this.opts)};pttl=(...e)=>new tI(e,this.opts).exec(this.client);publish=(...e)=>new tk(e,this.opts).exec(this.client);randomkey=()=>new tR().exec(this.client);rename=(...e)=>new tT(e,this.opts).exec(this.client);renamenx=(...e)=>new tP(e,this.opts).exec(this.client);rpop=(...e)=>new tN(e,this.opts).exec(this.client);rpush=(e,...t)=>new tU([e,...t],this.opts).exec(this.client);rpushx=(e,...t)=>new tC([e,...t],this.opts).exec(this.client);sadd=(e,t,...s)=>new t$([e,t,...s],this.opts).exec(this.client);scan(e,t){return new tz([e,t],this.opts).exec(this.client)}scard=(...e)=>new tD(e,this.opts).exec(this.client);scriptExists=(...e)=>new tL(e,this.opts).exec(this.client);scriptFlush=(...e)=>new tM(e,this.opts).exec(this.client);scriptLoad=(...e)=>new tF(e,this.opts).exec(this.client);sdiff=(...e)=>new tj(e,this.opts).exec(this.client);sdiffstore=(...e)=>new tJ(e,this.opts).exec(this.client);set=(e,t,s)=>new tq([e,t,s],this.opts).exec(this.client);setbit=(...e)=>new tB(e,this.opts).exec(this.client);setex=(e,t,s)=>new tK([e,t,s],this.opts).exec(this.client);setnx=(e,t)=>new tH([e,t],this.opts).exec(this.client);setrange=(...e)=>new tG(e,this.opts).exec(this.client);sinter=(...e)=>new tY(e,this.opts).exec(this.client);sinterstore=(...e)=>new tX(e,this.opts).exec(this.client);sismember=(e,t)=>new tW([e,t],this.opts).exec(this.client);smismember=(e,t)=>new tV([e,t],this.opts).exec(this.client);smembers=(...e)=>new tQ(e,this.opts).exec(this.client);smove=(e,t,s)=>new tZ([e,t,s],this.opts).exec(this.client);spop=(...e)=>new t0(e,this.opts).exec(this.client);srandmember=(...e)=>new t1(e,this.opts).exec(this.client);srem=(e,...t)=>new t2([e,...t],this.opts).exec(this.client);sscan=(...e)=>new t5(e,this.opts).exec(this.client);strlen=(...e)=>new t3(e,this.opts).exec(this.client);subscribe=e=>{let t=Array.isArray(e)?e:[e];return new sq(this.client,t,!1,this.opts)};sunion=(...e)=>new t4(e,this.opts).exec(this.client);sunionstore=(...e)=>new t6(e,this.opts).exec(this.client);time=()=>new t8().exec(this.client);touch=(...e)=>new t7(e,this.opts).exec(this.client);ttl=(...e)=>new t9(e,this.opts).exec(this.client);type=(...e)=>new se(e,this.opts).exec(this.client);unlink=(...e)=>new st(e,this.opts).exec(this.client);xadd=(...e)=>new sn(e,this.opts).exec(this.client);xack=(...e)=>new ss(e,this.opts).exec(this.client);xackdel=(...e)=>new si(e,this.opts).exec(this.client);xdel=(...e)=>new so(e,this.opts).exec(this.client);xdelex=(...e)=>new sc(e,this.opts).exec(this.client);xgroup=(...e)=>new sh(e,this.opts).exec(this.client);xread=(...e)=>new sm(e,this.opts).exec(this.client);xreadgroup=(...e)=>new sf(e,this.opts).exec(this.client);xinfo=(...e)=>new sl(e,this.opts).exec(this.client);xlen=(...e)=>new sp(e,this.opts).exec(this.client);xpending=(...e)=>new su(e,this.opts).exec(this.client);xclaim=(...e)=>new sa(e,this.opts).exec(this.client);xautoclaim=(...e)=>new sr(e,this.opts).exec(this.client);xtrim=(...e)=>new sg(e,this.opts).exec(this.client);xrange=(...e)=>new sd(e,this.opts).exec(this.client);xrevrange=(...e)=>new sw(e,this.opts).exec(this.client);zadd=(...e)=>("score"in e[1],new sx([e[0],e[1],...e.slice(2)],this.opts).exec(this.client));zcard=(...e)=>new sy(e,this.opts).exec(this.client);zcount=(...e)=>new s_(e,this.opts).exec(this.client);zdiffstore=(...e)=>new sD(e,this.opts).exec(this.client);zincrby=(e,t,s)=>new sb([e,t,s],this.opts).exec(this.client);zinterstore=(...e)=>new sO(e,this.opts).exec(this.client);zlexcount=(...e)=>new sS(e,this.opts).exec(this.client);zmscore=(...e)=>new sL(e,this.opts).exec(this.client);zpopmax=(...e)=>new sA(e,this.opts).exec(this.client);zpopmin=(...e)=>new sv(e,this.opts).exec(this.client);zrange=(...e)=>new sE(e,this.opts).exec(this.client);zrank=(e,t)=>new sI([e,t],this.opts).exec(this.client);zrem=(e,...t)=>new sk([e,...t],this.opts).exec(this.client);zremrangebylex=(...e)=>new sR(e,this.opts).exec(this.client);zremrangebyrank=(...e)=>new sT(e,this.opts).exec(this.client);zremrangebyscore=(...e)=>new sP(e,this.opts).exec(this.client);zrevrank=(e,t)=>new sN([e,t],this.opts).exec(this.client);zscan=(...e)=>new sU(e,this.opts).exec(this.client);zscore=(e,t)=>
1new sC([e,t],this.opts).exec(this.client);zunion=(...e)=>new s$(e,this.opts).exec(this.client);zunionstore=(...e)=>new sz(e,this.opts).exec(this.client)};"u"<typeof atob&&(e.g.atob=e=>i.Buffer.from(e,"base64").toString("utf8"));var sX=class e extends sY{constructor(e){if("request"in e)return void super(e);e.url?(e.url.startsWith(" ")||e.url.endsWith(" ")||/\r|\n/.test(e.url))&&console.warn("[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"):console.warn("[Upstash Redis] The 'url' property is missing or undefined in your Redis config."),e.token?(e.token.startsWith(" ")||e.token.endsWith(" ")||/\r|\n/.test(e.token))&&console.warn("[Upstash Redis] The redis token contains whitespace or newline, which can cause errors!"):console.warn("[Upstash Redis] The 'token' property is missing or undefined in your Redis config.");const s=new w({baseUrl:e.url,retry:e.retry,headers:{authorization:`Bearer ${e.token}`},agent:e.agent,responseEncoding:e.responseEncoding,cache:e.cache??"no-store",signal:e.signal,keepAlive:e.keepAlive,readYourWrites:e.readYourWrites}),i="object"==typeof t.default&&t.default&&"object"==typeof t.default.env&&t.default.env?t.default.env:{};super(s,{automaticDeserialization:e.automaticDeserialization,enableTelemetry:e.enableTelemetry??!i.UPSTASH_DISABLE_TELEMETRY,latencyLogging:e.latencyLogging,enableAutoPipelining:e.enableAutoPipelining});const n="object"==typeof t.default&&t.default?t.default.version:void 0;if(this.addTelemetry({runtime:"string"==typeof EdgeRuntime?"edge-light":n?`node@${n}`:"unknown",platform:i.UPSTASH_CONSOLE?"console":i.VERCEL?"vercel":i.AWS_REGION?"aws":"unknown",sdk:"@upstash/[email protected]"}),this.enableAutoPipelining)return this.autoPipeline()}static fromEnv(s){if("object"!=typeof t.default||!t.default||"object"!=typeof t.default.env||!t.default.env)throw TypeError('[Upstash Redis] Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead');let i=t.default.env.UPSTASH_REDIS_REST_URL||t.default.env.KV_REST_API_URL;i||console.warn("[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");let n=t.default.env.UPSTASH_REDIS_REST_TOKEN||t.default.env.KV_REST_API_TOKEN;return n||console.warn("[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"),new e({...s,url:i,token:n})}};let sW="https://hot-dragon-27662.upstash.io",sQ="AWwOAAIncDFlODY2ZjM2OWVmMTA0NjNjODFhYWYxYjJhM2JhMDcyOHAxMjc2NjI",sV=sW;try{new URL(sW)}catch(e){console.error(`[Redis] Invalid URL format: "${sW?.substring(0,50)}..."`),sV=void 0}let sZ=sV&&sQ?new sX({url:sV,token:sQ}):{get:async()=>null,set:async()=>null,setex:async()=>null,del:async()=>null,expire:async()=>null,scan:async()=>[0,[]],keys:async()=>[],sadd:async()=>0,scard:async()=>0,exists:async()=>0};e.s(["redisClient",0,sZ],497775);var s0=e.i(724255);let s1=t.default.env.RAPIDAPI_KEY,s2=t.default.env.RAPIDAPI_KEY_FALLBACK;function s5(e){if(!s1)throw Error("[RapidAPI Keys] Missing required env var RAPIDAPI_KEY. Set it in the server environment (.env.local locally, Vercel project env in prod). RapidAPI requests cannot proceed.");let t=[s1];return s2&&s2!==s1&&t.push(s2),t}let s3=new Map;function s4(e){return s3.has(e)||s3.set(e,{failedKeys:new Map,alertSent:!1}),s3.get(e)}let s6=["too many requests","exceeded the rate limit","quota exceeded","exceeded the monthly quota","exceeded the daily quota"],s8=["you are not subscribed","account suspended","subscription has been suspended","invalid api key","not allowed to access this api","blocked user"];function s7(e,t){let s=e.get(t);if(null===s||!/^\d+$/.test(s.trim()))return null;let i=Number(s);return Number.isSafeInteger(i)?i:null}let s9=new Set(["tiktok-scraper7.p.rapidapi.com","tiktok82.p.rapidapi.com"]);async function ie(e,t,s,i="unknown",n={}){if(s9.has(s))throw Error(`[RapidAPI Keys] Host ${s} is not subscribed on the current key â skipping ${i} (fast-fail, no alert).`);let r=s4(s);for(let[e,t]of r.failedKeys)Date.now()-t.getTime()>18e5&&(r.failedKeys.delete(e),r.alertSent=!1);let a=s5(s),o=s4(s),c=a.map((e,t)=>({key:e,label:`${0===t?"preferred":"fallback"}(...${e.slice(-4)})`})).filter(e=>!o.failedKeys.has(e.key)),h=Number.isSafeInteger(n.maxAttempts)&&Number(n.maxAttempts)>0?Number(n.maxAttempts):c.length,l=c.slice(0,h);if(0===l.length)throw Error(`[RapidAPI Keys] All keys failed for ${i} (${s}). Auto-recovery in 30 min.`);let p=null;for(let{key:r,label:a}of l)try{let o={...t.headers,"X-RapidAPI-Key":r,"X-RapidAPI-Host":s},c=await fetch(e,{...t,headers:o,signal:t.signal??AbortSignal.timeout(8e3)});n.logQuota&&function(e){var t;let s;s={requestsLimit:s7(t=e.headers,"x-ratelimit-requests-limit"),requestsRemaining:s7(t,"x-ratelimit-requests-remaining"),requestsResetSeconds:s7(t,"x-ratelimit-requests-reset"),freePlanHardLimit:s7(t,"x-rate-limit-rapid-free-plans-hard-limit-limit"),freePlanHardRemaining:s7(t,"x-rate-limit-rapid-free-plans-hard-limit-remaining"),freePlanHardResetSeconds:s7(t,"x-rate-limit-rapid-free-plans-hard-limit-reset")},!Object.values(s).some(e=>null!==e)}(c);let h=await c.text();if(function(e,t){let s=t.toLowerCase();return!!s6.some(e=>s.includes(e))||429===e}(c.status,h)){console.warn(`[RapidAPI Keys] Rate-limited (${a}) for ${i} (${e}): HTTP ${c.status} â not evicting key`),p=Error(`RapidAPI rate-limited: HTTP ${c.status} - ${h.substring(0,200)}`);continue}if(function(e,t){let s=t.toLowerCase();return!!s8.some(e=>s.includes(e))||401===e}(c.status,h)){console.warn(`[RapidAPI Keys] Key ${a} failed for ${i} (${e}): HTTP ${c.status}`),function(e,t,s){let i=s4(e);
1if(i.failedKeys.has(t))return;i.failedKeys.set(t,new Date);let n=s5(e),r=t===n[0],a=n.length>1;console.error(`[RapidAPI Keys] Key ...${t.slice(-4)} marked FAILED for host ${e}`,s),r&&a&&!i.alertSent&&(i.alertSent=!0,s0.Notifications.sendNotification("api-alerts",`RapidAPI Key Failed for ${s.provider} â Switched to Fallback`,"ð¨",!0,void 0,{provider:s.provider,endpoint:s.endpoint,"status-code":s.statusCode,"response-preview":s.responseBody.substring(0,200),"failed-at":new Date().toISOString(),"failed-key-last-four":t.slice(-4),"fallback-key-last-four":n[1].slice(-4),host:e}).catch(e=>console.error("[RapidAPI Keys] Failed to send LogSnag alert:",e))),n.every(e=>i.failedKeys.has(e))&&s0.Notifications.sendNotification("api-alerts",`CRITICAL: All Keys Failed for ${s.provider}`,"ð´",!0,void 0,{provider:s.provider,endpoint:s.endpoint,"status-code":s.statusCode,"response-preview":s.responseBody.substring(0,200),"failed-at":new Date().toISOString(),host:e}).catch(e=>console.error("[RapidAPI Keys] Failed to send critical LogSnag alert:",e))}(s,r,{provider:i,endpoint:e,statusCode:c.status,responseBody:h}),p=Error(`RapidAPI key ${a} failed: HTTP ${c.status} - ${h.substring(0,200)}`);continue}try{return JSON.parse(h)}catch{return h}}catch(e){console.error(`[RapidAPI Keys] Network error for ${i} with ${a} key:`,e),p=e instanceof Error?e:Error(String(e))}throw p||Error(`All RapidAPI keys exhausted for ${i}`)}e.s(["makeRapidApiRequest",0,ie],674507);let it="users",is="hashtags",ii="places",ir="similarUsers",ia="upleap:token",io="upleap:token_exp";class ic{static instance;token=null;expirationTime=0;static getInstance(){return ic.instance||(ic.instance=new ic),ic.instance}async getToken(){return(!this.token||Date.now()>this.expirationTime)&&await this.refreshToken(),this.token}invalidateToken(){this.token=null,this.expirationTime=0,sZ.del(ia).catch(()=>{}),sZ.del(io).catch(()=>{})}async refreshToken(){try{let[e,t]=await Promise.all([sZ.get(ia),sZ.get(io)]);if(e&&t){let s=Number(t);if(Date.now()<s){this.token=e,this.expirationTime=s;return}}let s=await fetch("https://api.upleap.com/api/v1/oauth/login",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({username:"[email protected]",password:"123123"})});if(!s.ok)throw Error(`Upleap login failed: ${s.status} ${s.statusText}`);let i=await s.json();if("ok"===i.status&&i.token)this.token=i.token,this.expirationTime=Date.now()+5184e5,sZ.setex(ia,518400,this.token).catch(()=>{}),sZ.setex(io,518400,String(this.expirationTime)).catch(()=>{});else throw Error(`Upleap login returned unexpected response: ${JSON.stringify(i)}`)}catch(e){throw console.error("[UpleapAPIKeyManager] Error refreshing token:",e),e}}}let ih={authority:"api.upleap.com",origin:"https://upleap.com",accept:"application/json","accept-language":"en-US,en;q=0.9","Content-Type":"application/json","cache-control":"no-cache"};class il{strategyName="UpleapAPI";apiKeyManager;static cachedHeaders=null;static headerExpirationTime=0;constructor(){this.apiKeyManager=ic.getInstance()}async getHeaders(){let e=Date.now();if(il.cachedHeaders&&e<il.headerExpirationTime)return il.cachedHeaders;let t=await this.apiKeyManager.getToken();return il.cachedHeaders={...ih,Authorization:`Bearer ${t}`},il.headerExpirationTime=e+36e5,il.cachedHeaders}async fetchWithAuthRetry(e){let t=await this.getHeaders(),s=await fetch(e,{method:"GET",headers:t});if(401===s.status){this.apiKeyManager.invalidateToken(),il.cachedHeaders=null,il.headerExpirationTime=0;let t=await this.getHeaders(),s=await fetch(e,{method:"GET",headers:t});if(!s.ok)throw Error(`UpleapAPI retry failed: ${s.status} ${s.statusText}`);return s.json()}if(!s.ok)throw Error(`UpleapAPI request failed: ${s.status} ${s.statusText}`);return s.json()}async fetchProfile(e,t){let s=`https://api.upleap.com/api/v1/instagram/usernames/${e}`,i=await this.fetchWithAuthRetry(s);return this.processResponse("fetchProfile",i,"users",t)}async fetchUsernameByInstagramID(e){return!1}async fetchInstagramQuery(e,t,s=15,i=0,n=!1){let r={users:"user",hashtags:"hashtag",places:"place"}[t];if(!r)throw Error(`Invalid query type: ${t}`);let a=`https://api.upleap.com/api/v1/instagram/search?context=${r}&fast=true&query=${e}`,o=await this.fetchWithAuthRetry(a);return this.processResponse("fetchInstagramQuery",o,t)}async fetchSimilarInstagramAccounts(e,t=15){return!1}async fetchUserFollowers(e,t=15){return!1}processResponse(e,t,s,i){let n;if("fetchProfile"==e){if("error"===t.status&&t.error&&t.error.message&&t.error.message.includes("User not found"))return!1;if(t&&"ok"===t.status&&t.data){let e=t.data;n={graphql:{user:{id:e.pk,username:e.username,full_name:e.full_name,biography:e.biography,profile_pic_url:e.profile_pic_url,follower_count:e.follower_count,following_count:e.following_count,media_count:e.media_count,edge_followed_by:{count:e.follower_count},edge_follow:{count:e.following_count},external_url:e.external_url,category:e.category,is_verified:e.is_verified,is_private:e.is_private,is_business:e.is_business}}}}}else if("fetchInstagramQuery"==e)if(t&&"ok"===t.status)switch(s){case"users":if(!t.users||!t.users.length)return!1;n=t.users.map(e=>({full_name:e.user.full_name,avatar_url:e.user.profile_pic_url,profile_pic_url:e.user.profile_pic_url,username:e.user.username,is_verified:e.user.is_verified,is_private:e.user.is_private,link:`instagram/${e.user.username}/`,type:"ig",user_id:e.user.pk,follower_count:0}));break;case"hashtags":if(t.hashtags&&t.hashtags.length)n=t.hashtags.map(e=>({name:e.hashtag.name,target_id:e.hashtag.id,mediaCount:e.hashtag.media_count,search_result_subtitle:e.hashtag.search_result_subtitle}));else{if(!t.see_more||!t.see_more.list||!t.see_more.list.length)return!1;n=t.see_more.list.map(e=>({name:e.keyword.name,target_id:e.keyword.id,mediaCount:0,search_result_subtitle:""}))}break;case"places":if(!t.places||!t.places.length)return!1;n=t.places.map(e=>({target:e.place.location.title,target_id:e.place.location&&e.place.location.pk?e.place.location.pk:null,address:e.place.subt
1itle?e.place.subtitle:"â"}));break;default:throw Error(`Invalid query type: ${s}`)}else throw Error(`Invalid response from UpleapAPI: ${JSON.stringify(t)}`);return n}}let ip="flashapi1.p.rapidapi.com",iu={profile:"profile",users:"users",hashtags:"hashtags",places:"places",similarUsers:"similarUsers",userFollowers:"userFollowers",content_stories:"content_stories",content_posts:"content_posts",content_highlights:"content_highlights"},id=["cdninstagram.com","fbcdn.net"],im=new Set([301,302,303,307,308]);function iw(e){if("string"!=typeof e||!e.trim())return null;try{let t=new URL(e);if("https:"!==t.protocol||t.username||t.password||t.port)return null;return t}catch{return null}}function ig(e){let t=iw(e);if(!t)return!1;let s=t.hostname.toLowerCase();return id.some(e=>s===e||s.endsWith(`.${e}`))}function ix(e){if(ig(e))return!0;let t=iw(e);return t?.hostname.toLowerCase()==="www.outfame.com"&&"/ig-assets/"===t.pathname}async function iy(e){let t=e;for(let e=0;e<=3;e+=1){let s=await fetch(t,{redirect:"manual"});if(s.url&&!ix(s.url)){await s.body?.cancel().catch(()=>void 0);break}if(!im.has(s.status))return s;if(3===e){await s.body?.cancel().catch(()=>void 0);break}let i=s.headers.get("location");if(!i){await s.body?.cancel().catch(()=>void 0);break}let n=new URL(i,t).toString();if(!ix(n)){await s.body?.cancel().catch(()=>void 0);break}t=n}return null}let i_=[new class{strategyName="StarAPI";async makeRequest(e,t,s,i){return await ie(`https://starapi1.p.rapidapi.com${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:s},"starapi1.p.rapidapi.com","StarAPI",i)}async fetchMediaByShortcode(e,t){return await this.makeRequest("/instagram/media/get_info_by_shortcode",{shortcode:e},t,{maxAttempts:1,logQuota:!0})}async fetchMediaById(e,t){return await this.makeRequest("/instagram/media/get_info",{id:e},t,{maxAttempts:1,logQuota:!0})}async fetchProfile(e,t){if(t)throw Error("StarAPI doesn't support fetching posts in profile endpoint");let s=await this.makeRequest("/instagram/user/get_web_profile_info",{username:e});return this.processResponse("fetchProfile",s)}async fetchUsernameByInstagramID(e){let t=await this.makeRequest("/instagram/user/get_info_by_id",{id:e});return!!("done"===t.status&&t.response?.status_code===200&&t.response?.body?.user?.username)&&t.response.body.user.username}async fetchInstagramQuery(e,t,s=15,i=0,n=!1){let r;if(t===it)r=await this.makeRequest("/instagram/user/search",{query:e});else if(t===is)r=await this.makeRequest("/instagram/hashtag/search",{query:e});else if(t===ii)throw Error("StarAPI doesn't support places search");else throw Error(`Unknown query type: ${t}`);return this.processResponse("fetchInstagramQuery",r,t)}async fetchSimilarInstagramAccounts(e,t=15){let s=await this.makeRequest("/instagram/user/get_similar_accounts",{id:e});return this.processResponse("fetchSimilarInstagramAccounts",s,ir)}async fetchUserFollowers(e,t=15){let s=await this.makeRequest("/instagram/user/get_followers",{id:e,count:t,max_id:null});return this.processResponse("fetchUserFollowers",s,ir)}async fetchStoriesByInstagramID(e){let t=await this.makeRequest("/instagram/user/get_stories",{ids:[parseInt(e)]});if("done"!==t.status||t.response?.status_code!==200)throw Error(`Failed to fetch stories from StarAPI: ${t.response?.body?.status||"Unknown error"}`);let s=!!t.response.body.user&&{graphql:{user:{...t.response.body.user,id:e}}},i=t.response.body.reels?.[e];return i?{profile:s,stories:i.items?.map(e=>({id:e.id,taken_at:e.taken_at,media_type:e.media_type,shortcode:e.code,image_url:e.image_versions2?.candidates?.[0]?.url,video_url:e.video_versions?e.video_versions[0].url:null,video_view_count:e.view_count||0,accessibility_caption:e.accessibility_caption||null}))||[]}:{profile:s,stories:[]}}async fetchHighlightsByInstagramID(e){let t=await this.makeRequest("/instagram/user/get_highlights",{id:parseInt(e)});if("done"!==t.status||t.response?.status_code!==200)throw Error(`Failed to fetch highlights from StarAPI: ${t.response?.body?.status||"Unknown error"}`);let s=!!t.response.body.user&&{graphql:{user:{...t.response.body.user,id:e}}},i=t.response.body.data?.user?.edge_highlight_reels?.edges;return i&&0!==i.length?{profile:s,highlights:i.map(e=>({id:e.node.id,title:e.node.title,cover_media_url:e.node.cover_media?.thumbnail_src,items:[]}))}:{profile:s,highlights:[]}}
1async fetchPostsByInstagramID(e){let t=await this.makeRequest("/instagram/user/get_media",{id:parseInt(e),count:12,max_id:null});if("done"!==t.status||t.response?.status_code!==200)throw Error(`Failed to fetch posts from StarAPI: ${t.response?.body?.status||"Unknown error"}`);let s=!!t.response.body.user&&{graphql:{user:{...t.response.body.user,id:e}}},i=t.response.body.items;return i&&0!==i.length?{profile:s,posts:i.map(e=>({id:e.code,caption:e.caption?.text||null,media_type:e.media_type,image_url:e.image_versions2?.candidates?.[0]?.url||null,video_url:e.video_versions?e.video_versions[0].url:null,like_count:e.like_count,comment_count:e.comment_count,taken_at:e.taken_at,is_video:2===e.media_type,accessibility_caption:e.accessibility_caption||null,is_album:8===e.media_type,album_children:e.carousel_media?e.carousel_media.map(e=>({id:e.id,image_url:e.image_versions2?.candidates?.[0]?.url||null,is_video:2===e.media_type,video_url:e.video_versions?e.video_versions[0].url:null,accessibility_caption:e.accessibility_caption||null})):null}))}:{profile:s,posts:[]}}async processResponse(e,t,s){let i;if(!t?.response)throw Error(`Failed to fetch data from StarAPI: ${t?.message||t?.status||"No response received"}`);if("done"===t.status&&t.response?.status_code===404)return!1;if("done"!==t.status||t.response?.status_code!==200)throw Error(`Failed to fetch data from StarAPI: ${t.message||t.response?.status_message||"Unknown error"}`);if("fetchProfile"===e){let e=t.response.body?.data?.user;if(!e||!e.id)return!1;i={graphql:{user:{id:e.id,username:e.username,full_name:e.full_name,biography:e.biography,category:e.category_name||e.category_enum,external_url:e.external_url,external_url_title:e.bio_links?.[0]?.title||null,profile_pic_url:e.profile_pic_url,profile_pic_url_hd:e.profile_pic_url_hd||e.profile_pic_url,follower_count:e.edge_followed_by?.count,following_count:e.edge_follow?.count,media_count:e.edge_owner_to_timeline_media?.count,is_private:e.is_private,is_verified:e.is_verified,is_business:e.is_business_account,is_professional:e.is_professional_account,edge_followed_by:e.edge_followed_by,edge_follow:e.edge_follow,edge_owner_to_timeline_media:e.edge_owner_to_timeline_media?.edges?.map(e=>({id:e.node.shortcode,caption:e.node.edge_media_to_caption?.edges?.[0]?.node?.text,location:e.node.location?.name||null,image_url:e.node.display_url,hd_image_url:e.node.thumbnail_resources?.[e.node.thumbnail_resources.length-1]?.src,like_count:e.node.edge_liked_by?.count,comment_count:e.node.edge_media_to_comment?.count,taken_at:e.node.taken_at_timestamp,accessibility_caption:e.node.accessibility_caption||null,is_video:e.node.is_video,video_view_count:e.node.video_view_count||null,is_album:!!e.node.edge_sidecar_to_children,album_children:e.node.edge_sidecar_to_children?.edges?.map(e=>({id:e.node.shortcode,image_url:e.node.display_url,is_video:e.node.is_video,video_url:e.node.video_url||null,video_view_count:e.node.video_view_count||null,accessibility_caption:e.node.accessibility_caption||null}))||null}))||[]}}}}else if("fetchInstagramQuery"===e)switch(s){case it:t.response.body?.users&&(i=t.response.body.users.map(e=>({full_name:e.full_name,avatar_url:e.profile_pic_url,profile_pic_url:e.profile_pic_url,username:e.username,is_verified:e.is_verified,is_private:e.is_private,link:`instagram/${e.username}/`,type:"ig",user_id:e.pk||e.id,follower_count:0})));break;case is:t.response.body?.hashtags&&(i=t.response.body.hashtags.map(e=>({name:e.name,profile_pic_url:e.profile_pic_url,target_id:e.id,mediaCount:e.media_count,search_result_subtitle:e.search_result_subtitle})));break;case ii:throw Error("StarAPI doesn't support places search")}else if("fetchSimilarInstagramAccounts"===e){if("done"===t.status&&t.response?.status_code===200){let e=t.response.body?.data?.user?.edge_chaining?.edges;e&&(i=e.map(e=>({id:e.node.id,full_name:e.node.full_name,is_verified:e.node.is_verified,profile_pic_url:e.node.profile_pic_url,username:e.node.username,is_private:e.node.is_private})))}}else if("fetchUserFollowers"===e&&"done"===t.status&&t.response?.status_code===200){let e=t.response.body?.users;e&&(i=e.map(e=>({full_name:e.full_name,avatar_url:e.profile_pic_url,profile_pic_url:e.profile_pic_url,username:e.username,is_verified:e.is_verified,is_private:e.is_private,user_id:e.pk})))}return i}},new il,new class{strategyName="IGFlashAPI";async fetchProfile(e,t){let s=await ie("https://flashapi1.p.rapidapi.com/ig/web_profile_info/?user="+e,{method:"GET",headers:{"Content-Type":"application/json"}},ip,"IGFlashAPI");return this.processResponse("fetchProfile",s)}async fetchUsernameByInstagramID(e){return!1}async fetchInstagramQuery(e,t,s=15,i=0,n=!1){return!1}async fetchSimilarInstagramAccounts(e,t=15){let s=await ie(`https://flashapi1.p.rapidapi.com/ig/similar_accounts/?id_user=${e}`,{method:"GET",headers:{"Content-Type":"application/json"}},ip,"IGFlashAPI");return this.processResponse("fetchSimilarInstagramAccounts",s,iu.similarUsers)}async fetchUserFollowers(e,t=15){if(!e)return console.error("â ï¸ fetchUserFollowers: instagramId is required"),!1;let s=await ie(`https://flashapi1.p.rapidapi.com/ig/followers/?id_user=${e}`,{method:"GET",headers:{"Content-Type":"application/json"}},ip,"IGFlashAPI");return this.processResponse("fetchUserFollowers",s,iu.similarUsers)}async processResponse(e,t,s){let i;if("Page not found"==t.message)return!1;if("fetchProfile"==e&&"ok"!==t.status)throw Error(`Failed to fetch data from IGFlashAPI: ${JSON.stringify(t)}`);if("fetchProfile"==e){if(!t||!t.data||!t.data.user||!t.data.user.id)return!1;i={graphql:{user:{id:t.data.user.id,username:t.data.user.username,full_name:t.data.user.full_name,biography:t.data.user.biography,category:t.data.user.category||t.data.user.category_name,external_url:t.data.user.external_url,external_url_title:t.data.user.bio_links&&t.data.user.bio_links.length&&t.data.user.bio_links[0].title?t.data.user.bio_links[0].title:null,profile_pic_url:t.data.user.profile_pic_url,profile_pic_url_hd:t.data.user.profile_pic_url_hd,follower_count:t.data.user.edge_followed_by?t.data.user.edge_followed_by.count:t.data.user.follower_count,following_count:t.data.user.edge_follow?t.data.user.edge_follow.count:t.data.user.following_count,media_count:t.data.user.edge_owner_to_timeline_media?t.data.user.edge_owner_to_timeline_media.count:t.data.user.media_count,is_private:t.data.user.is_private,is_verified:t.data.user.is_verified,is_business:t.data.user.is_business||t.data.user.is_business_account,is_professional:t.data.user.is_professional||t.data.user.is_professional_account||!1,edge_followed_by:t.data.user.edge_followed_by,edge_follow:t.data.user.edge_follow,edge_owner_to_timeline_media:t.data.user.edge_owner_to_timeline_media.edges.map(e=>({id:e.node.shortcode,caption:e.node.edge_media_to_caption.edges[0]?.node.text,location:e.node.location&&e.node.location.name?e.node.location.name:null,image_url:e.node.display_url,hd_image_url:e.node.thumbnail_resources[e.node.thumbnail_resources.length-1]?.src,like_count:e.node.edge_liked_by.count,comment_count:e.node.edge_media_to_comment.count,taken_at:e.node.taken_at_timestamp,accessibility_caption:e.node.accessibility_caption?e.node.accessibility_caption:null,is_video:e.node.is_video,video_view_count:e.node.video_view_count?e.node.video_view_count:null,is_album:!!e.node.edge_sidecar_to_children,album_children:e.node.edge_sidecar_to_children&&e.node.edge_sidecar_to_children.edges&&e.node.edge_sidecar_to_children.edges.length?e.node.edge_sidecar_to_children.edges.map(e=>({id:e.node.shortcode,image_url:e.node.display_url,is_video:e.node.is_video,video_url:e.node.video_url?e.node.video_url:null,video_view_count:e.node.video_view_count?e.node.video_view_count:null,accessibility_caption:e.node.accessibility_caption?e.node.accessibility_caption:null})):null}))}}}}else"fetchSimilarInstagramAccounts"==e?"ok"===t.status&&t.users&&t.users.length&&(i=t.users.map(e=>({id:e.pk||e.id,full_name:e.full_name,is_verified:e.is_verified,profile_pic_url:e.profile_pic_url,username:e.username,is_private:e.is_private}))):"fetchUserFollowers"==e&&"ok"===t.status&&t.users&&t.users.length&&(i=t.users.map(e=>({full_name:e.full_name,avatar_url:e.profile_pic_url,profile_pic_url:e.profile_pic_url,username:e.username,is_verified:e.is_verified,is_private:e.is_private,user_id:e.pk})));return i}}];async function ib(e,t,s=!1,i){let n,r;if(!s){let s=await sZ.get(e);if(s)if(!t.startsWith("content_"))return s;else try{let e=t.split("_")[1];if(s&&s[e]&&Array.isArray(s[e]))return s}catch(e){console.error("Error parsing cached data:",e)}}if("boolean"==typeof(n=await i()))return n;if(!n)return console.warn(`[cacheOrFetch] No data fetched for query: ${e}`),!1;r=t.startsWith("content_")?3600:t===iu.users||t===iu.profile?86400:t===iu.hashtags||t===iu.places?2592e3:604800;try{await sZ.setex(e,r,JSON.stringify(n))}catch(e){console.error("Error saving data in Redis: ",e)}return n}async function iO(e){let t=0,s=-1,i=[];for(;t<e.maxRetries;){let n;if(0===t&&e.preferredStrategy)n=e.preferredStrategy;else if(!e.forcePreferredStrategy){let{strategy:e,nextIndex:t}=function(e){let t=(e+1)%i_.length;return{strategy:i_[t],nextIndex:t}}(s);n=e,s=t}try{return await e.fetchFunction(n)}catch(s){let e=s.message?.includes("Skipping");i.push(`Strategy ${n?.strategyName}: ${s.message}`),e||(t+=1)}}throw Error(`Failed to fetch data after ${e.maxRetries} retries with all strategies. Errors: ${i.join("; ")}`)}class iS{static async fetchInstagramProfile(e,t=!1,s=!1,i=null,n=3,r=!1){let a=`ig_profile_${t?"full_":""}${e.replaceAll(" ","")}`;return await ib(a,iu.profile,s,async()=>await iO({redisKey:a,maxRetries:n,preferredStrategy:i,forcePreferredStrategy:r,fetchFunction:async s=>await s.fetchProfile(e,t)}))}static async fetchUsernameByInstagramID(e){return await iO({maxRetries:3,fetchFunction:async t=>{if("StarAPI"===t.strategyName)return await t.fetchUsernameByInstagramID(e);throw Error(`ðµ Skipping ${t.strategyName} for fetchUsernameByInstagramID as it is not supported.`)}})}static async fetchInstagramQuery(e,t,s=15,i=null,n=!1,r=3,a=!1,o=!1){if(!iu[t])return{error:`Invalid query type: ${t}`};let c=`ig_query_${t}_${e}`;return await ib(c,t,n,async()=>await iO({redisKey:c,maxRetries:r,preferredStrategy:i,forcePreferredStrategy:o,fetchFunction:async i=>{if(("hashtags"===t||"places"===t)&&"UpleapAPI"===i.strategyName)throw Error("Skipping UpleapAPI for hashtags/places (broken on Upleap server)");if("IGFlashAPI"===i.strategyName)throw Error("Skipping IGFlashAPI");return await i.fetchInstagramQuery(e,t,s,r,a)}}))}static async fetchSimilarInstagramAccounts(e,t=15,s=null,i=!1,n=3,r=!1,a=!1){let o=`ig_similar_for_${e}`;return await ib(o,iu.users,i,async()=>await iO({redisKey:o,maxRetries:n,preferredStrategy:s,forcePreferredStrategy:a,fetchFunction:async s=>{if("StarAPI"!==s.strategyName&&"IGFlashAPI"!==s.strategyName)throw Error(`ðµ Skipping ${s.strategyName} for fetchSimilarInstagramAccounts as it is not supported.`);return await s.fetchSimilarInstagramAccounts(e,t,n,r)}}))}static async fetchInstagramContent(e,t){let s=`ig_content_${t}`;return await ib(s,`content_${e}`,!1,async()=>{let i=await sZ.get(s),n=await iO({redisKey:s,maxRetries:3,preferredStrategy:i_.find(e=>"StarAPI"===e.strategyName),forcePreferredStrategy:!1,fetchFunction:async s=>{let n;if("StarAPI"!==s.strategyName)throw Error(`fetch${e}ByInstagramID is only supported by StarAPI.`);switch(e){case"stories":n=await s.fetchStoriesByInstagramID(t);break;case"highlights":n=await s.fetchHighlightsByInstagramID(t);break;case"posts":n=await s.fetchPostsByInstagramID(t);break;default:throw Error(`Invalid fetchType: ${e}`)}
1return{reportUpdatedAt:new Date().toISOString(),...i&&"object"==typeof i?i:{},profile:i?.profile?{...i.profile,...n?.profile&&Object.fromEntries(Object.entries(n.profile).filter(([e,t])=>null!=t))}:n?.profile||{},[e]:n[e]||[]}}});return await sZ.setex(s,3600,JSON.stringify(n)),n})}static async fetchStoriesByInstagramID(e){let t=await this.fetchInstagramContent("stories",e);return{profile:t.profile,stories:t.stories}}static async fetchHighlightsByInstagramID(e){let t=await this.fetchInstagramContent("highlights",e);return{profile:t.profile,highlights:t.highlights}}static async fetchPostsByInstagramID(e){let t=await this.fetchInstagramContent("posts",e);return{profile:t.profile,posts:t.posts}}static async downloadInstagramAvatar(e,t,i,n="avatars",r=""){try{if(!ig(t))return console.warn(`Rejected non-Instagram avatar URL for '${e}'.`),null;let a=this.getProxiedImageUrl(t),o=Array.from(new Set([a,t].filter(e=>!!e&&ix(e)))),c=null;for(let e of o){if(c=await iy(e),c?.ok)break;await c?.body?.cancel().catch(()=>void 0)}if(!c?.ok)return console.warn(`Failed to fetch IG avatar for '${e}'.`),null;let h=await c.arrayBuffer(),l=r?`${r}/${e}.jpg`:`${e}.jpg`,p=(0,s.default)("https://vrolvqxfjnlcrzwqbfxt.supabase.co",`/storage/v1/object/public/${n}`,l),{error:u}=await i.storage.from(n).upload(l,h,{upsert:!0,contentType:"image/jpeg",cacheControl:"31536000"});if(u){if(u.message.includes("The resource already exists"))return p;return console.warn(`Error uploading IG avatar for '${e}': ${u.message}`),null}return p}catch(t){return console.warn(`[downloadInstagramAvatar] Non-fatal error for '${e}': ${t instanceof Error?t.message:t}`),null}}static async downloadInstagramImage(e,t,i,n){try{let r=this.getProxiedImageUrl(e),a=await fetch(r,{redirect:"follow"});if(!a.ok&&!(a=await fetch(e,{redirect:"follow"})).ok)return null;let o=await a.arrayBuffer(),c=(0,s.default)("https://vrolvqxfjnlcrzwqbfxt.supabase.co",`/storage/v1/object/public/${i}`,n),{error:h}=await t.storage.from(i).upload(n,o,{upsert:!0,contentType:"image/jpeg",cacheControl:"31536000"});if(h&&!String(h.message).includes("The resource already exists"))return null;return c}catch{return null}}static async fetchUserFollowers(e,t=15,s=!1){let i=`ig_followers_for_${e}`;return await ib(i,iu.userFollowers,s,async()=>await iO({redisKey:i,maxRetries:3,fetchFunction:async s=>{if("StarAPI"!==s.strategyName&&"IGFlashAPI"!==s.strategyName)throw Error(`ðµ Skipping ${s.strategyName} for fetchUserFollowers as it is not supported.`);return await s.fetchUserFollowers(e,t)}}))}static async fetchAllCachedInstagramProfiles(){let e=0,t=[];do{let s=await sZ.scan(e,{match:"ig_profile_*",count:1e3});e=parseInt(s[0],10),t.push(...s[1])}while(0!==e)return t&&0!==t.length?[...new Set(t.map(e=>e.replace("ig_profile_full_","").replace("ig_profile_","")))]:[]}static async isInstagramProfileCached(e){let t=0;do{let s=await sZ.scan(t,{match:`ig_profile_*${e}`,count:1e3});if(t=parseInt(s[0]),s[1].length>0)return!0}while(0!==t)return!1}static EDGE_PROXY_URL="https://www.outfame.com/ig-assets/";static getProxiedImageUrl(e,t=!0){return!e||!e.includes("http")||e.includes("/api/ig-proxy")||e.includes("outfame.com/ig-assets")||e.includes("instagram-asset-cdn.dragos-balan-pr.workers.dev")||e.includes("/storage/v1/object/public/")||!(e.includes("cdninstagram.com")||e.includes("fbcdn.net")||e.includes("instagram.")||e.includes("scontent"))?e:t?`${this.EDGE_PROXY_URL}?url=${encodeURIComponent(e)}`:this.decodeInstagramMediaURLLegacy(e)}static decodeInstagramMediaURLLegacy(e){if(!e.includes("http")||e.includes(atob("LnRyYW5zbGF0ZS5nb29n")))return e;let t=e.split("/"),s="";for(let e=0;e<t.length;e++)s+=2==e?t[e].replaceAll("-","--").replaceAll(".","-")+atob("LnRyYW5zbGF0ZS5nb29n")+"/":e!=t.length-1?t[e]+"/":t[e];return s}static decodeInstagramMediaURL(e){return this.getProxiedImageUrl(e,!0)}static decodeInstagramURLtoSelfHosted(e){let t=e.includes("instagram.fmad")?e.split("/").pop()?.split("?")[0]:e.match(/\/([^\/]+?\.(jpg|mp4|webp))/i)?.[1];return t?`https://www.outfame.com/ig-assets/${t}?url=${encodeURIComponent(e)}&time=${Math.floor(Date.now()/1e3+86400)}`:e}static graphqlIDToShortcode(e){let t=BigInt(e.split("_")[0]),s="";for(;t>BigInt(0);){let e=t%BigInt(64);t/=BigInt(64),s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".charAt(Number(e))+s}return s}}}]); 2 3//# sourceMappingURL=233d7f8e2e6edb2c.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.