UNPKG

@xbibzlibrary/tiktokscrap

Version:

Powerful TikTok Scraper and Downloader Library

2 lines 169 kB
/*! For license information please see index.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("axios"),require("tough-cookie"),require("user-agents"),require("cheerio"),require("fs-extra"),require("node-fetch")):"function"==typeof define&&define.amd?define(["axios","tough-cookie","user-agents","cheerio","fs-extra","node-fetch"],t):"object"==typeof exports?exports.TikTokScrap=t(require("axios"),require("tough-cookie"),require("user-agents"),require("cheerio"),require("fs-extra"),require("node-fetch")):e.TikTokScrap=t(e.axios,e["tough-cookie"],e["user-agents"],e.cheerio,e["fs-extra"],e["node-fetch"])}(this,(e,t,r,n,o,i)=>(()=>{var a={41:(e,t,r)=>{"use strict";var n=r(655),o=r(8068),i=r(9675),a=r(5795);e.exports=function(e,t,r){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new i("`obj` must be an object or a function`");if("string"!=typeof t&&"symbol"!=typeof t)throw new i("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new i("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new i("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new i("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new i("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,c=arguments.length>5?arguments[5]:null,l=arguments.length>6&&arguments[6],f=!!a&&a(e,t);if(n)n(e,t,{configurable:null===c&&f?f.configurable:!c,enumerable:null===s&&f?f.enumerable:!s,value:r,writable:null===u&&f?f.writable:!u});else{if(!l&&(s||u||c))throw new o("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=r}}},76:e=>{"use strict";e.exports=Function.prototype.call},110:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServerError=t.NotFoundError=t.ForbiddenError=t.AuthenticationError=t.RateLimitError=t.DownloadError=t.ValidationError=t.ParseError=t.NetworkError=t.TikTokScrapError=void 0;class r extends Error{constructor(e,t,r,n){super(e),this.name="TikTokScrapError",this.code=t,this.statusCode=r,this.details=n,Error.captureStackTrace(this,this.constructor)}}t.TikTokScrapError=r,t.NetworkError=class extends r{constructor(e,t,r){super(e,"NETWORK_ERROR",t,r),this.name="NetworkError"}},t.ParseError=class extends r{constructor(e,t){super(e,"PARSE_ERROR",void 0,t),this.name="ParseError"}},t.ValidationError=class extends r{constructor(e,t){super(e,"VALIDATION_ERROR",void 0,t),this.name="ValidationError"}},t.DownloadError=class extends r{constructor(e,t){super(e,"DOWNLOAD_ERROR",void 0,t),this.name="DownloadError"}},t.RateLimitError=class extends r{constructor(e,t){super(e,"RATE_LIMIT_ERROR",429,{retryAfter:t}),this.name="RateLimitError"}},t.AuthenticationError=class extends r{constructor(e){super(e,"AUTHENTICATION_ERROR",401),this.name="AuthenticationError"}},t.ForbiddenError=class extends r{constructor(e){super(e,"FORBIDDEN_ERROR",403),this.name="ForbiddenError"}},t.NotFoundError=class extends r{constructor(e){super(e,"NOT_FOUND_ERROR",404),this.name="NotFoundError"}},t.ServerError=class extends r{constructor(e){super(e,"SERVER_ERROR",500),this.name="ServerError"}}},120:e=>{"use strict";e.exports=o},251:(e,t)=>{t.read=function(e,t,r,n,o){var i,a,s=8*o-n-1,u=(1<<s)-1,c=u>>1,l=-7,f=r?o-1:0,h=r?-1:1,d=e[t+f];for(f+=h,i=d&(1<<-l)-1,d>>=-l,l+=s;l>0;i=256*i+e[t+f],f+=h,l-=8);for(a=i&(1<<-l)-1,i>>=-l,l+=n;l>0;a=256*a+e[t+f],f+=h,l-=8);if(0===i)i=1-c;else{if(i===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),i-=c}return(d?-1:1)*a*Math.pow(2,i-n)},t.write=function(e,t,r,n,o,i){var a,s,u,c=8*i-o-1,l=(1<<c)-1,f=l>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(a++,u/=2),a+f>=l?(s=0,a=l):a+f>=1?(s=(t*u-1)*Math.pow(2,o),a+=f):(s=t*Math.pow(2,f-1)*Math.pow(2,o),a=0));o>=8;e[r+d]=255&s,d+=p,s/=256,o-=8);for(a=a<<o|s,c+=o;c>0;e[r+d]=255&a,d+=p,a/=256,c-=8);e[r+d-p]|=128*g}},345:(e,t,r)=>{e.exports=r(7007).EventEmitter},414:e=>{"use strict";e.exports=Math.round},453:(e,t,r)=>{"use strict";var n,o=r(9612),i=r(9383),a=r(1237),s=r(9290),u=r(9538),c=r(8068),l=r(9675),f=r(5345),h=r(1514),d=r(8968),p=r(6188),g=r(8002),y=r(5880),b=r(414),m=r(3093),w=Function,v=function(e){try{return w('"use strict"; return ('+e+").constructor;")()}catch(e){}},E=r(5795),_=r(655),S=function(){throw new l},O=E?function(){try{return S}catch(e){try{return E(arguments,"callee").get}catch(e){return S}}}():S,A=r(4039)(),R=r(3628),x=r(1064),k=r(8648),j=r(1002),P=r(76),U={},T="undefined"!=typeof Uint8Array&&R?R(Uint8Array):n,I={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?n:ArrayBuffer,"%ArrayIteratorPrototype%":A&&R?R([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":U,"%AsyncGenerator%":U,"%AsyncGeneratorFunction%":U,"%AsyncIteratorPrototype%":U,"%Atomics%":"undefined"==typeof Atomics?n:Atomics,"%BigInt%":"undefined"==typeof BigInt?n:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?n:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":i,"%eval%":eval,"%EvalError%":a,"%Float16Array%":"undefined"==typeof Float16Array?n:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?n:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?n:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?n:FinalizationRegistry,"%Function%":w,"%GeneratorFunction%":U,"%Int8Array%":"undefined"==typeof Int8Array?n:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?n:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":A&&R?R(R([][Symbol.iterator]())):n,"%JSON%":"object"==typeof JSON?JSON:n,"%Map%":"undefined"==typeof Map?n:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&A&&R?R((new Map)[Symbol.iterator]()):n,"%Math%":Math,"%Number%":Number,"%Object%":o,"%Object.getOwnPropertyDescriptor%":E,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?n:Promise,"%Proxy%":"undefined"==typeof Proxy?n:Proxy,"%RangeError%":s,"%ReferenceError%":u,"%Reflect%":"undefined"==typeof Reflect?n:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?n:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&A&&R?R((new Set)[Symbol.iterator]()):n,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":A&&R?R(""[Symbol.iterator]()):n,"%Symbol%":A?Symbol:n,"%SyntaxError%":c,"%ThrowTypeError%":O,"%TypedArray%":T,"%TypeError%":l,"%Uint8Array%":"undefined"==typeof Uint8Array?n:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?n:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?n:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?n:Uint32Array,"%URIError%":f,"%WeakMap%":"undefined"==typeof WeakMap?n:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?n:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?n:WeakSet,"%Function.prototype.call%":P,"%Function.prototype.apply%":j,"%Object.defineProperty%":_,"%Object.getPrototypeOf%":x,"%Math.abs%":h,"%Math.floor%":d,"%Math.max%":p,"%Math.min%":g,"%Math.pow%":y,"%Math.round%":b,"%Math.sign%":m,"%Reflect.getPrototypeOf%":k};if(R)try{null.error}catch(e){var M=R(R(e));I["%Error.prototype%"]=M}var C=function e(t){var r;if("%AsyncFunction%"===t)r=v("async function () {}");else if("%GeneratorFunction%"===t)r=v("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=v("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var o=e("%AsyncGenerator%");o&&R&&(r=R(o.prototype))}return I[t]=r,r},B={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},L=r(6743),D=r(9957),N=L.call(P,Array.prototype.concat),F=L.call(j,Array.prototype.splice),V=L.call(P,String.prototype.replace),$=L.call(P,String.prototype.slice),q=L.call(P,RegExp.prototype.exec),W=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,H=/\\(\\)?/g,G=function(e,t){var r,n=e;if(D(B,n)&&(n="%"+(r=B[n])[0]+"%"),D(I,n)){var o=I[n];if(o===U&&(o=C(n)),void 0===o&&!t)throw new l("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:o}}throw new c("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new l("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new l('"allowMissing" argument must be a boolean');if(null===q(/^%?[^%]*%?$/,e))throw new c("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(e){var t=$(e,0,1),r=$(e,-1);if("%"===t&&"%"!==r)throw new c("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new c("invalid intrinsic syntax, expected opening `%`");var n=[];return V(e,W,function(e,t,r,o){n[n.length]=r?V(o,H,"$1"):t||e}),n}(e),n=r.length>0?r[0]:"",o=G("%"+n+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(n=u[0],F(r,N([0,1],u)));for(var f=1,h=!0;f<r.length;f+=1){var d=r[f],p=$(d,0,1),g=$(d,-1);if(('"'===p||"'"===p||"`"===p||'"'===g||"'"===g||"`"===g)&&p!==g)throw new c("property names with quotes must have matching quotes");if("constructor"!==d&&h||(s=!0),D(I,i="%"+(n+="."+d)+"%"))a=I[i];else if(null!=a){if(!(d in a)){if(!t)throw new l("base intrinsic for "+e+" exists, but the property is not available.");return}if(E&&f+1>=r.length){var y=E(a,d);a=(h=!!y)&&"get"in y&&!("originalValue"in y.get)?y.get:a[d]}else h=D(a,d),a=a[d];h&&!s&&(I[i]=a)}}return a}},483:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),a=0;a<r.length;a++)"default"!==r[a]&&o(t,e,r[a]);return i(t,e),t}),s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Parser=void 0;const u=a(r(7749)),c=r(110),l=s(r(5628));class f{constructor(){this.logger=l.default}parseVideoData(e){try{const t=u.load(e),r=this.extractScriptData(t);if(!r||!r.ItemModule)throw new c.ParseError("Could not find video data in the page");const n=Object.keys(r.ItemModule)[0],o=r.ItemModule[n];if(!o)throw new c.ParseError("Invalid video data structure");return this.parseVideoObject(o)}catch(e){throw this.logger.error(`Error parsing video data: ${e.message}`),new c.ParseError(`Failed to parse video data: ${e.message}`)}}parsePhotoData(e){try{const t=u.load(e),r=this.extractScriptData(t);if(!r||!r.ItemModule)throw new c.ParseError("Could not find photo data in the page");const n=Object.keys(r.ItemModule)[0],o=r.ItemModule[n];if(!o)throw new c.ParseError("Invalid photo data structure");return this.parsePhotoObject(o)}catch(e){throw this.logger.error(`Error parsing photo data: ${e.message}`),new c.ParseError(`Failed to parse photo data: ${e.message}`)}}parseUserData(e){try{const t=u.load(e),r=this.extractScriptData(t);if(!r||!r.UserModule)throw new c.ParseError("Could not find user data in the page");const n=Object.keys(r.UserModule.users)[0],o=r.UserModule.users[n];if(!o)throw new c.ParseError("Invalid user data structure");return this.parseUserObject(o)}catch(e){throw this.logger.error(`Error parsing user data: ${e.message}`),new c.ParseError(`Failed to parse user data: ${e.message}`)}}parseHashtagData(e){try{const t=u.load(e),r=this.extractScriptData(t);if(!r||!r.ChallengeModule)throw new c.ParseError("Could not find hashtag data in the page");const n=Object.keys(r.ChallengeModule)[0],o=r.ChallengeModule[n];if(!o)throw new c.ParseError("Invalid hashtag data structure");return this.parseHashtagObject(o)}catch(e){throw this.logger.error(`Error parsing hashtag data: ${e.message}`),new c.ParseError(`Failed to parse hashtag data: ${e.message}`)}}parseCommentsData(e){try{const t=u.load(e),r=this.extractScriptData(t);if(!r||!r.CommentModule)throw new c.ParseError("Could not find comments data in the page");return Object.values(r.CommentModule).map(e=>this.parseCommentObject(e))}catch(e){throw this.logger.error(`Error parsing comments data: ${e.message}`),new c.ParseError(`Failed to parse comments data: ${e.message}`)}}extractScriptData(e){try{const t=e("script").toArray();for(const r of t){const t=e(r).html();if(t&&t.includes("__NEXT_DATA__")){const e=t.match(/__NEXT_DATA__\s*=\s*({.+});/);if(e&&e[1])return JSON.parse(e[1]).props.pageProps}if(t&&t.includes("window['SIGI_STATE']")){const e=t.match(/window\['SIGI_STATE'\]\s*=\s*({.+});/);if(e&&e[1])return JSON.parse(e[1])}}return null}catch(e){return this.logger.error(`Error extracting script data: ${e.message}`),null}}parseVideoObject(e){return{id:e.id,text:e.desc,createTime:parseInt(e.createTime),author:this.parseUserObject(e.author),music:{id:e.music.id,title:e.music.title,author:e.music.authorName,album:e.music.album,playUrl:e.music.playUrl,coverLarge:e.music.coverLarge,coverMedium:e.music.coverMedium,coverThumb:e.music.coverThumb,duration:parseInt(e.music.duration)},stats:{digg:parseInt(e.stats.diggCount),share:parseInt(e.stats.shareCount),comment:parseInt(e.stats.commentCount),play:parseInt(e.stats.playCount)},videoMeta:{width:e.video.width,height:e.video.height,duration:parseInt(e.video.duration),cover:e.video.cover,dynamicCover:e.video.dynamicCover,originCover:e.video.originCover},downloadAddr:e.video.downloadAddr,webVideoUrl:`https://www.tiktok.com/@${e.author.uniqueId}/video/${e.id}`,hashtags:e.challenge?Object.values(e.challenge).map(e=>({id:e.id,name:e.title,title:e.title,cover:e.cover})):[],mentions:e.textExtra?e.textExtra.filter(e=>1===e.type).map(e=>({id:e.userId,uniqueId:e.userUniqueId,nickname:e.userName})):[],effects:e.effectStickers?e.effectStickers.map(e=>({id:e.id,name:e.name,icon:e.icon})):[],isAd:e.isAd,commentsDisabled:2===e.commentSetting,duetEnabled:1===e.duetSetting,stitchEnabled:1===e.stitchSetting,secret:e.privateItem,forFriend:e.forFriend,digged:e.stats.diggCount>0,itemCommentStatus:e.itemCommentStatus}}parsePhotoObject(e){return{id:e.id,text:e.desc,createTime:parseInt(e.createTime),author:this.parseUserObject(e.author),music:{id:e.music.id,title:e.music.title,author:e.music.authorName,album:e.music.album,playUrl:e.music.playUrl,coverLarge:e.music.coverLarge,coverMedium:e.music.coverMedium,coverThumb:e.music.coverThumb,duration:parseInt(e.music.duration)},stats:{digg:parseInt(e.stats.diggCount),share:parseInt(e.stats.shareCount),comment:parseInt(e.stats.commentCount),play:parseInt(e.stats.playCount)},covers:e.images?e.images.map(e=>({url:e.urlList[0],width:e.width,height:e.height})):[],webVideoUrl:`https://www.tiktok.com/@${e.author.uniqueId}/photo/${e.id}`,hashtags:e.challenge?Object.values(e.challenge).map(e=>({id:e.id,name:e.title,title:e.title,cover:e.cover})):[],mentions:e.textExtra?e.textExtra.filter(e=>1===e.type).map(e=>({id:e.userId,uniqueId:e.userUniqueId,nickname:e.userName})):[],effects:e.effectStickers?e.effectStickers.map(e=>({id:e.id,name:e.name,icon:e.icon})):[],isAd:e.isAd,commentsDisabled:2===e.commentSetting,duetEnabled:1===e.duetSetting,stitchEnabled:1===e.stitchSetting,secret:e.privateItem,forFriend:e.forFriend,digged:e.stats.diggCount>0,itemCommentStatus:e.itemCommentStatus}}parseUserObject(e){return{id:e.id,uniqueId:e.uniqueId,nickname:e.nickname,avatarUrl:e.avatarLarger,signature:e.signature,verified:e.verified,following:parseInt(e.followingCount),fans:parseInt(e.followerCount),heart:parseInt(e.heartCount),video:parseInt(e.videoCount),digg:parseInt(e.diggCount),privateAccount:e.privateAccount,isSecret:e.isSecret,secUid:e.secUid}}parseHashtagObject(e){return{id:e.challengeId,name:e.challengeName,title:e.title,description:e.desc,cover:e.cover,icon:e.icon,viewCount:parseInt(e.viewCount),isCommerce:e.isCommerce,isAd:e.isAd,challengeType:e.challengeType,videos:[]}}parseCommentObject(e){return{id:e.cid,text:e.text,createTime:parseInt(e.createTime),user:this.parseUserObject(e.user),digg:parseInt(e.diggCount),reply:parseInt(e.replyCommentTotal),isPinned:e.isPinned,isAuthorDigged:e.isAuthorDigged,replies:e.replies?e.replies.map(e=>this.parseCommentObject(e)):[]}}}t.Parser=f,t.default=f},487:(e,t,r)=>{"use strict";var n=r(6897),o=r(655),i=r(3126),a=r(2205);e.exports=function(e){var t=i(arguments),r=e.length-(arguments.length-1);return n(t,1+(r>0?r:0),!0)},o?o(e.exports,"apply",{value:a}):e.exports.apply=a},537:(e,t,r)=>{var n=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),r={},n=0;n<t.length;n++)r[t[n]]=Object.getOwnPropertyDescriptor(e,t[n]);return r},o=/%[sdj%]/g;t.format=function(e){if(!m(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(u(arguments[r]));return t.join(" ")}r=1;for(var n=arguments,i=n.length,a=String(e).replace(o,function(e){if("%%"===e)return"%";if(r>=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),s=n[r];r<i;s=n[++r])y(s)||!E(s)?a+=" "+s:a+=" "+u(s);return a},t.deprecate=function(e,r){if("undefined"!=typeof process&&!0===process.noDeprecation)return e;if("undefined"==typeof process)return function(){return t.deprecate(e,r).apply(this,arguments)};var n=!1;return function(){if(!n){if(process.throwDeprecation)throw new Error(r);process.traceDeprecation?console.trace(r):console.error(r),n=!0}return e.apply(this,arguments)}};var i={},a=/^$/;if(process.env.NODE_DEBUG){var s=process.env.NODE_DEBUG;s=s.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),a=new RegExp("^"+s+"$","i")}function u(e,r){var n={seen:[],stylize:l};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),g(r)?n.showHidden=r:r&&t._extend(n,r),w(n.showHidden)&&(n.showHidden=!1),w(n.depth)&&(n.depth=2),w(n.colors)&&(n.colors=!1),w(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),f(n,e,n.depth)}function c(e,t){var r=u.styles[t];return r?"["+u.colors[r][0]+"m"+e+"["+u.colors[r][1]+"m":e}function l(e,t){return e}function f(e,r,n){if(e.customInspect&&r&&O(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var o=r.inspect(n,e);return m(o)||(o=f(e,o,n)),o}var i=function(e,t){if(w(t))return e.stylize("undefined","undefined");if(m(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return b(t)?e.stylize(""+t,"number"):g(t)?e.stylize(""+t,"boolean"):y(t)?e.stylize("null","null"):void 0}(e,r);if(i)return i;var a=Object.keys(r),s=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(r)),S(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return h(r);if(0===a.length){if(O(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(v(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(_(r))return e.stylize(Date.prototype.toString.call(r),"date");if(S(r))return h(r)}var c,l="",E=!1,A=["{","}"];return p(r)&&(E=!0,A=["[","]"]),O(r)&&(l=" [Function"+(r.name?": "+r.name:"")+"]"),v(r)&&(l=" "+RegExp.prototype.toString.call(r)),_(r)&&(l=" "+Date.prototype.toUTCString.call(r)),S(r)&&(l=" "+h(r)),0!==a.length||E&&0!=r.length?n<0?v(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),c=E?function(e,t,r,n,o){for(var i=[],a=0,s=t.length;a<s;++a)k(t,String(a))?i.push(d(e,t,r,n,String(a),!0)):i.push("");return o.forEach(function(o){o.match(/^\d+$/)||i.push(d(e,t,r,n,o,!0))}),i}(e,r,n,s,a):a.map(function(t){return d(e,r,n,s,t,E)}),e.seen.pop(),function(e,t,r){return e.reduce(function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}(c,l,A)):A[0]+l+A[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function d(e,t,r,n,o,i){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),k(n,o)||(a="["+o+"]"),s||(e.seen.indexOf(u.value)<0?(s=y(r)?f(e,u.value,null):f(e,u.value,r-1)).indexOf("\n")>-1&&(s=i?s.split("\n").map(function(e){return" "+e}).join("\n").slice(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n")):s=e.stylize("[Circular]","special")),w(a)){if(i&&o.match(/^\d+$/))return s;(a=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.slice(1,-1),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function p(e){return Array.isArray(e)}function g(e){return"boolean"==typeof e}function y(e){return null===e}function b(e){return"number"==typeof e}function m(e){return"string"==typeof e}function w(e){return void 0===e}function v(e){return E(e)&&"[object RegExp]"===A(e)}function E(e){return"object"==typeof e&&null!==e}function _(e){return E(e)&&"[object Date]"===A(e)}function S(e){return E(e)&&("[object Error]"===A(e)||e instanceof Error)}function O(e){return"function"==typeof e}function A(e){return Object.prototype.toString.call(e)}function R(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(e=e.toUpperCase(),!i[e])if(a.test(e)){var r=process.pid;i[e]=function(){var n=t.format.apply(t,arguments);console.error("%s %d: %s",e,r,n)}}else i[e]=function(){};return i[e]},t.inspect=u,u.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},u.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.types=r(9032),t.isArray=p,t.isBoolean=g,t.isNull=y,t.isNullOrUndefined=function(e){return null==e},t.isNumber=b,t.isString=m,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=w,t.isRegExp=v,t.types.isRegExp=v,t.isObject=E,t.isDate=_,t.types.isDate=_,t.isError=S,t.types.isNativeError=S,t.isFunction=O,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=r(1135);var x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function k(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){var e,r;console.log("%s - %s",(r=[R((e=new Date).getHours()),R(e.getMinutes()),R(e.getSeconds())].join(":"),[e.getDate(),x[e.getMonth()],r].join(" ")),t.format.apply(t,arguments))},t.inherits=r(6698),t._extend=function(e,t){if(!t||!E(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};var j="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function P(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(j&&e[j]){var t;if("function"!=typeof(t=e[j]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,j,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,r,n=new Promise(function(e,n){t=e,r=n}),o=[],i=0;i<arguments.length;i++)o.push(arguments[i]);o.push(function(e,n){e?r(e):t(n)});try{e.apply(this,o)}catch(e){r(e)}return n}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),j&&Object.defineProperty(t,j,{value:t,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(t,n(e))},t.promisify.custom=j,t.callbackify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');function t(){for(var t=[],r=0;r<arguments.length;r++)t.push(arguments[r]);var n=t.pop();if("function"!=typeof n)throw new TypeError("The last argument must be of type Function");var o=this,i=function(){return n.apply(o,arguments)};e.apply(this,t).then(function(e){process.nextTick(i.bind(null,null,e))},function(e){process.nextTick(P.bind(null,e,i))})}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,n(e)),t}},592:(e,t,r)=>{"use strict";var n=r(655),o=function(){return!!n};o.hasArrayLengthDefineBug=function(){if(!n)return null;try{return 1!==n([],"length",{value:1}).length}catch(e){return!0}},e.exports=o},655:e=>{"use strict";var t=Object.defineProperty||!1;if(t)try{t({},"a",{value:1})}catch(e){t=!1}e.exports=t},734:(e,t,r)=>{const n=r(5659),o=r(8507),i={};Object.keys(n).forEach(e=>{i[e]={},Object.defineProperty(i[e],"channels",{value:n[e].channels}),Object.defineProperty(i[e],"labels",{value:n[e].labels});const t=o(e);Object.keys(t).forEach(r=>{const n=t[r];i[e][r]=function(e){const t=function(...t){const r=t[0];if(null==r)return r;r.length>1&&(t=r);const n=e(t);if("object"==typeof n)for(let e=n.length,t=0;t<e;t++)n[t]=Math.round(n[t]);return n};return"conversion"in e&&(t.conversion=e.conversion),t}(n),i[e][r].raw=function(e){const t=function(...t){const r=t[0];return null==r?r:(r.length>1&&(t=r),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(n)})}),e.exports=i},1002:e=>{"use strict";e.exports=Function.prototype.apply},1064:(e,t,r)=>{"use strict";var n=r(9612);e.exports=n.getPrototypeOf||null},1077:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VideoScraper=void 0;const o=n(r(2209)),i=r(110);class a extends o.default{constructor(e={}){super(e)}async getVideoByUrl(e){return this.executeRequest(async()=>{if(!this.validator.validateTikTokUrl(e))throw new i.ValidationError("Invalid TikTok URL");const t=this.extractVideoIdFromUrl(e);if(!t)throw new i.ValidationError("Could not extract video ID from URL");return this.getVideoById(t)},`Get video by URL: ${e}`)}async getVideoById(e){this.validator.validateId(e);const t=this.buildUrl("https://www.tiktok.com",`/@placeholder/video/${e}`),r=await this.http.get(t);if(200!==r.status)throw new i.NotFoundError("Video not found");return this.parser.parseVideoData(r.data)}async getVideoTrends(e=20){return this.executeRequest(async()=>{if(e<=0||e>100)throw new i.ValidationError("Count must be between 1 and 100");const t=this.buildUrl("https://www.tiktok.com","/api/item_list/",{count:e,id:1,type:5,secUid:"",maxCursor:0,minCursor:0,retryType:0,isWeb:1}),r=await this.http.get(t);if(200!==r.status)throw new i.NotFoundError("Could not fetch trending videos");const n=r.data;return n.body&&n.body.itemListData?n.body.itemListData.map(e=>this.parser.parseVideoObject(e)):[]},`Get trending videos: ${e}`)}async getRecommendedVideos(e,t=10){return this.executeRequest(async()=>{if(this.validator.validateId(e),t<=0||t>50)throw new i.ValidationError("Count must be between 1 and 50");const r=this.buildUrl("https://www.tiktok.com","/api/recommend/item_list/",{count:t,id:e,type:0,secUid:"",maxCursor:0,minCursor:0,retryType:0,isWeb:1}),n=await this.http.get(r);if(200!==n.status)throw new i.NotFoundError("Could not fetch recommended videos");const o=n.data;return o.body&&o.body.itemListData?o.body.itemListData.map(e=>this.parser.parseVideoObject(e)):[]},`Get recommended videos for ${e}: ${t}`)}}t.VideoScraper=a,t.default=a},1135:e=>{e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},1237:e=>{"use strict";e.exports=EvalError},1333:e=>{"use strict";e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(var n in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var o=Object.getOwnPropertySymbols(e);if(1!==o.length||o[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(e,t);if(42!==i.value||!0!==i.enumerable)return!1}return!0}},1494:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HashtagScraper=void 0;const o=n(r(2209)),i=r(110);class a extends o.default{constructor(e={}){super(e)}async getHashtagByName(e){return this.executeRequest(async()=>{if(!this.validator.validateTikTokHashtag(e))throw new i.ValidationError("Invalid TikTok hashtag");const t=e.startsWith("#")?e.substring(1):e,r=this.buildUrl("https://www.tiktok.com",`/tag/${t}`),n=await this.http.get(r);if(200!==n.status)throw new i.NotFoundError("Hashtag not found");return this.parser.parseHashtagData(n.data)},`Get hashtag by name: ${e}`)}async getHashtagFeed(e){return this.executeRequest(async()=>{this.validator.validateHashtagFeedOptions(e);const{hashtag:t,cursor:r=0,count:n=20}=e,o=await this.getHashtagByName(t);if(!o.success||!o.data)throw new i.NotFoundError("Hashtag not found");const a=this.buildUrl("https://www.tiktok.com","/api/challenge/item_list/",{count:n,id:o.data.id,type:3,secUid:"",maxCursor:r,minCursor:0,retryType:0,isWeb:1}),s=await this.http.get(a);if(200!==s.status)throw new i.NotFoundError("Could not fetch hashtag feed");const u=s.data;return u.body&&u.body.itemListData?u.body.itemListData.map(e=>{if(e.video)return this.parser.parseVideoObject(e);if(e.images)return this.parser.parsePhotoObject(e);throw new i.ValidationError("Unknown item type in hashtag feed")}):[]},`Get hashtag feed for ${e.hashtag}: ${e.count}`)}async getHashtagVideos(e,t=0,r=20){return this.getHashtagFeed({hashtag:e,cursor:t,count:r})}async getHashtagPhotos(e,t=0,r=20){return this.getHashtagFeed({hashtag:e,cursor:t,count:r})}async getTrendingHashtags(e=20){return this.executeRequest(async()=>{if(e<=0||e>100)throw new i.ValidationError("Count must be between 1 and 100");const t=this.buildUrl("https://www.tiktok.com","/api/challenge/discover/",{count:e,isWeb:1}),r=await this.http.get(t);if(200!==r.status)throw new i.NotFoundError("Could not fetch trending hashtags");const n=r.data;return n.body&&n.body.challengeList?n.body.challengeList.map(e=>this.parser.parseHashtagObject(e)):[]},`Get trending hashtags: ${e}`)}}t.HashtagScraper=a,t.default=a},1514:e=>{"use strict";e.exports=Math.abs},2205:(e,t,r)=>{"use strict";var n=r(6743),o=r(1002),i=r(3144);e.exports=function(){return i(n,o,arguments)}},2209:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.BaseScraper=void 0;const o=n(r(3260)),i=n(r(483)),a=n(r(7064)),s=n(r(5628)),u=r(110);class c{constructor(e={}){this.logger=s.default,this.http=new o.default(e),this.parser=new i.default,this.validator=new a.default}async executeRequest(e,t){try{this.logger.info(`Starting request: ${t}`);const r=await e();return this.logger.success(`Request completed successfully: ${t}`),{success:!0,data:r,message:"Success"}}catch(e){return this.logger.error(`Request failed: ${t} - ${e.message}`),e instanceof u.TikTokScrapError?{success:!1,error:e.message,message:e.code}:{success:!1,error:e.message,message:"UNKNOWN_ERROR"}}}buildUrl(e,t,r={}){const n=new URL(t,e);return Object.entries(r).forEach(([e,t])=>{null!=t&&n.searchParams.append(e,String(t))}),n.toString()}extractVideoIdFromUrl(e){const t=e.match(/\/video\/(\d+)/);return t?t[1]:null}extractPhotoIdFromUrl(e){const t=e.match(/\/photo\/(\d+)/);return t?t[1]:null}extractUsernameFromUrl(e){const t=e.match(/\/(@[\w.-]+)/);return t?t[1]:null}extractHashtagFromUrl(e){const t=e.match(/\/tag\/([\w]+)/);return t?t[1]:null}updateOptions(e){this.http.updateOptions(e)}getOptions(){return this.http.getOptions()}}t.BaseScraper=c,t.default=c},2635:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PhotoDownloader=void 0;const o=n(r(3438));class i extends o.default{async downloadPhoto(e,t={}){return this.executeDownload(async()=>{const{outputDir:r="./downloads",filename:n}=t;if(!e.covers||0===e.covers.length)throw new Error("Photo URLs not available");const o=e.covers.map((e,o)=>{const i=this.generateFilename(e.url,".jpg",n?{filename:`${n}_${o+1}`}:void 0),a=this.getOutputPath(r,i);return this.downloadFile(e.url,a,t)});return Promise.all(o)},`Download photo: ${e.id}`)}async downloadPhotoByUrl(e,t={}){return this.executeDownload(async()=>{const r=this.extractPhotoIdFromUrl(e);if(!r)throw new Error("Could not extract photo ID from URL");const n={id:r,text:"",createTime:0,author:{id:"",uniqueId:"",nickname:"",avatarUrl:"",signature:"",verified:!1,following:0,fans:0,heart:0,video:0,digg:0,privateAccount:!1,isSecret:!1,secUid:""},music:{id:"",title:"",author:"",album:"",playUrl:"",coverLarge:"",coverMedium:"",coverThumb:"",duration:0},stats:{digg:0,share:0,comment:0,play:0},covers:[{url:e,width:0,height:0}],webVideoUrl:e,hashtags:[],mentions:[],effects:[],isAd:!1,commentsDisabled:!1,duetEnabled:!1,stitchEnabled:!1,secret:!1,forFriend:!1,digged:!1,itemCommentStatus:0},o=await this.downloadPhoto(n,t);if(o.success&&o.data)return o.data;throw new Error(o.error||"Failed to download photo by URL")},`Download photo by URL: ${e}`)}extractPhotoIdFromUrl(e){const t=e.match(/\/photo\/(\d+)/);return t?t[1]:null}}t.PhotoDownloader=i,t.default=i},2682:(e,t,r)=>{"use strict";var n=r(9600),o=Object.prototype.toString,i=Object.prototype.hasOwnProperty;e.exports=function(e,t,r){if(!n(t))throw new TypeError("iterator must be a function");var a,s;arguments.length>=3&&(a=r),s=e,"[object Array]"===o.call(s)?function(e,t,r){for(var n=0,o=e.length;n<o;n++)i.call(e,n)&&(null==r?t(e[n],n,e):t.call(r,e[n],n,e))}(e,t,a):"string"==typeof e?function(e,t,r){for(var n=0,o=e.length;n<o;n++)null==r?t(e.charAt(n),n,e):t.call(r,e.charAt(n),n,e)}(e,t,a):function(e,t,r){for(var n in e)i.call(e,n)&&(null==r?t(e[n],n,e):t.call(r,e[n],n,e))}(e,t,a)}},2726:(e,t,r)=>{"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function i(e,t,r){return(t=s(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,s(n.key),n)}}function s(e){var t=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}var u=r(8287).Buffer,c=r(5340).inspect,l=c&&c.custom||"inspect";function f(e,t,r){u.prototype.copy.call(e,t,r)}e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}var t,r;return t=e,(r=[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return u.alloc(0);for(var t=u.allocUnsafe(e>>>0),r=this.head,n=0;r;)f(r.data,t,n),n+=r.data.length,r=r.next;return t}},{key:"consume",value:function(e,t){var r;return e<this.head.data.length?(r=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):r=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,r=1,n=t.data;for(e-=n.length;t=t.next;){var o=t.data,i=e>o.length?o.length:e;if(i===o.length?n+=o:n+=o.slice(0,e),0===(e-=i)){i===o.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=o.slice(i));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=u.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var o=r.data,i=e>o.length?o.length:e;if(o.copy(t,t.length-e,0,i),0===(e-=i)){i===o.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=o.slice(i));break}++n}return this.length-=n,t}},{key:l,value:function(e,t){return c(this,o(o({},t),{},{depth:0,customInspect:!1}))}}])&&a(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}()},2742:t=>{"use strict";t.exports=e},2747:e=>{"use strict";e.exports={stdout:!1,stderr:!1}},2800:e=>{"use strict";e.exports=r},2861:(e,t,r)=>{var n=r(8287),o=n.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function a(e,t,r){return o(e,t,r)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=n:(i(n,t),t.Buffer=a),a.prototype=Object.create(o.prototype),i(o,a),a.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,r)},a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=o(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},2955:(e,t,r)=>{"use strict";var n;function o(e,t,r){return(t=function(e){var t=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var i=r(6238),a=Symbol("lastResolve"),s=Symbol("lastReject"),u=Symbol("error"),c=Symbol("ended"),l=Symbol("lastPromise"),f=Symbol("handlePromise"),h=Symbol("stream");function d(e,t){return{value:e,done:t}}function p(e){var t=e[a];if(null!==t){var r=e[h].read();null!==r&&(e[l]=null,e[a]=null,e[s]=null,t(d(r,!1)))}}function g(e){process.nextTick(p,e)}var y=Object.getPrototypeOf(function(){}),b=Object.setPrototypeOf((o(n={get stream(){return this[h]},next:function(){var e=this,t=this[u];if(null!==t)return Promise.reject(t);if(this[c])return Promise.resolve(d(void 0,!0));if(this[h].destroyed)return new Promise(function(t,r){process.nextTick(function(){e[u]?r(e[u]):t(d(void 0,!0))})});var r,n=this[l];if(n)r=new Promise(function(e,t){return function(r,n){e.then(function(){t[c]?r(d(void 0,!0)):t[f](r,n)},n)}}(n,this));else{var o=this[h].read();if(null!==o)return Promise.resolve(d(o,!1));r=new Promise(this[f])}return this[l]=r,r}},Symbol.asyncIterator,function(){return this}),o(n,"return",function(){var e=this;return new Promise(function(t,r){e[h].destroy(null,function(e){e?r(e):t(d(void 0,!0))})})}),n),y);e.exports=function(e){var t,r=Object.create(b,(o(t={},h,{value:e,writable:!0}),o(t,a,{value:null,writable:!0}),o(t,s,{value:null,writable:!0}),o(t,u,{value:null,writable:!0}),o(t,c,{value:e._readableState.endEmitted,writable:!0}),o(t,f,{value:function(e,t){var n=r[h].read();n?(r[l]=null,r[a]=null,r[s]=null,e(d(n,!1))):(r[a]=e,r[s]=t)},writable:!0}),t));return r[l]=null,i(e,function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[s];return null!==t&&(r[l]=null,r[a]=null,r[s]=null,t(e)),void(r[u]=e)}var n=r[a];null!==n&&(r[l]=null,r[a]=null,r[s]=null,n(d(void 0,!0))),r[c]=!0}),e.on("readable",g.bind(null,r)),r}},2991:e=>{"use strict";const t=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,r=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,n=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,o=/\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,i=new Map([["n","\n"],["r","\r"],["t","\t"],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["\\","\\"],["e",""],["a",""]]);function a(e){const t="u"===e[0],r="{"===e[1];return t&&!r&&5===e.length||"x"===e[0]&&3===e.length?String.fromCharCode(parseInt(e.slice(1),16)):t&&r?String.fromCodePoint(parseInt(e.slice(2,-1),16)):i.get(e)||e}function s(e,t){const r=[],i=t.trim().split(/\s*,\s*/g);let s;for(const t of i){const i=Number(t);if(Number.isNaN(i)){if(!(s=t.match(n)))throw new Error(`Invalid Chalk template style argument: ${t} (in style '${e}')`);r.push(s[2].replace(o,(e,t,r)=>t?a(t):r))}else r.push(i)}return r}function u(e){r.lastIndex=0;const t=[];let n;for(;null!==(n=r.exec(e));){const e=n[1];if(n[2]){const r=s(e,n[2]);t.push([e].concat(r))}else t.push([e])}return t}function c(e,t){const r={};for(const e of t)for(const t of e.styles)r[t[0]]=e.inverse?null:t.slice(1);let n=e;for(const[e,t]of Object.entries(r))if(Array.isArray(t)){if(!(e in n))throw new Error(`Unknown Chalk style: ${e}`);n=t.length>0?n[e](...t):n[e]}return n}e.exports=(e,r)=>{const n=[],o=[];let i=[];if(r.replace(t,(t,r,s,l,f,h)=>{if(r)i.push(a(r));else if(l){const t=i.join("");i=[],o.push(0===n.length?t:c(e,n)(t)),n.push({inverse:s,styles:u(l)})}else if(f){if(0===n.length)throw new Error("Found extraneous } in Chalk template literal");o.push(c(e,n)(i.join(""))),i=[],n.pop()}else i.push(h)}),o.push(i.join("")),n.length>0){const e=`Chalk template literal is missing ${n.length} closing bracket${1===n.length?"":"s"} (\`}\`)`;throw new Error(e)}return o.join("")}},3093:(e,t,r)=>{"use strict";var n=r(4459);e.exports=function(e){return n(e)||0===e?e:e<0?-1:1}},3126:(e,t,r)=>{"use strict";var n=r(6743),o=r(9675),i=r(76),a=r(3144);e.exports=function(e){if(e.length<1||"function"!=typeof e[0])throw new o("a function is required");return a(n,i,e)}},3141:(e,t,r)=>{"use strict";var n=r(2861).Buffer,o=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===o||!o(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=l,this.end=f,t=3;break;default:return this.write=h,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function l(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}t.I=i,i.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},i.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},i.prototype.text=function(e,t){var r=function(e,t,r){var n=t.length-1;if(n<r)return 0;var o=a(t[n]);return o>=0?(o>0&&(e.lastNeed=o-1),o):--n<r||-2===o?0:(o=a(t[n]))>=0?(o>0&&(e.lastNeed=o-2),o):--n<r||-2===o?0:(o=a(t[n]))>=0?(o>0&&(2===o?o=0:e.lastNeed=o-3),o):0}(this,e,t);if(!this.lastNe