grab-url 1.0.7 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/download.cjs.js +3 -0
  2. package/dist/download.cjs.js.map +1 -0
  3. package/dist/download.d.ts +1 -0
  4. package/dist/download.es.js +3715 -0
  5. package/dist/download.es.js.map +1 -0
  6. package/dist/grab-api.cjs.js +1 -1
  7. package/dist/grab-api.cjs.js.map +1 -1
  8. package/dist/grab-api.d.ts +63 -54
  9. package/dist/grab-api.es.js +244 -354
  10. package/dist/grab-api.es.js.map +1 -1
  11. package/dist/grab-api.umd.js +2 -0
  12. package/dist/grab-api.umd.js.map +1 -0
  13. package/dist/icons.cjs.js +1 -1
  14. package/dist/icons.cjs.js.map +1 -1
  15. package/dist/icons.d.ts +0 -0
  16. package/dist/icons.es.js +3 -3
  17. package/dist/icons.es.js.map +1 -1
  18. package/dist/log.cjs.js +2 -0
  19. package/dist/log.cjs.js.map +1 -0
  20. package/dist/log.d.ts +123 -0
  21. package/dist/log.es.js +299 -0
  22. package/dist/log.es.js.map +1 -0
  23. package/package.json +17 -13
  24. package/readme.md +7 -7
  25. package/src/grab-api.ts +150 -112
  26. package/src/grab-url.js +9 -40
  27. package/src/icons/cli/spinners.js +818 -0
  28. package/src/icons/svg/index.ts +0 -0
  29. package/src/icons/svg/loading-bouncy-ball.svg +0 -0
  30. package/src/icons/svg/loading-double-ring.svg +0 -0
  31. package/src/icons/svg/loading-eclipse.svg +0 -0
  32. package/src/icons/svg/loading-ellipsis.svg +0 -0
  33. package/src/icons/svg/loading-floating-search.svg +0 -0
  34. package/src/icons/svg/loading-gears.svg +0 -0
  35. package/src/icons/svg/loading-infinity.svg +0 -0
  36. package/src/icons/svg/loading-orbital.svg +0 -0
  37. package/src/icons/svg/loading-pacman.svg +0 -0
  38. package/src/icons/svg/loading-pulse-bars.svg +0 -0
  39. package/src/icons/svg/loading-red-blue-ball.svg +0 -0
  40. package/src/icons/svg/loading-reload-arrow.svg +0 -0
  41. package/src/icons/svg/loading-ring.svg +0 -0
  42. package/src/icons/svg/loading-ripple.svg +0 -0
  43. package/src/icons/svg/loading-spinner-oval.svg +0 -0
  44. package/src/icons/svg/loading-spinner.svg +0 -0
  45. package/src/icons/svg/loading-square-blocks.svg +0 -0
  46. package/src/{log.ts → log-json.ts} +128 -129
  47. package/src/icons/cli/spinners.json +0 -1074
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("fs"),e=require("path"),s=require("stream/promises"),u=require("stream"),o=require("readline"),r=require("./grab-api.cjs.js"),i=require("url"),D=require("events"),a=require("./log.cjs.js");var n="undefined"!=typeof document?document.currentScript:null;const l={dots:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],dots2:["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],dots3:["⠋","⠙","⠚","⠞","⠖","⠦","⠴","⠲","⠳","⠓"],dots4:["⠄","⠆","⠇","⠋","⠙","⠸","⠰","⠠","⠰","⠸","⠙","⠋","⠇","⠆"],dots5:["⠋","⠙","⠚","⠒","⠂","⠂","⠒","⠲","⠴","⠦","⠖","⠒","⠐","⠐","⠒","⠓","⠋"],dots6:["⠁","⠉","⠙","⠚","⠒","⠂","⠂","⠒","⠲","⠴","⠤","⠄","⠄","⠤","⠴","⠲","⠒","⠂","⠂","⠒","⠚","⠙","⠉","⠁"],dots7:["⠈","⠉","⠋","⠓","⠒","⠐","⠐","⠒","⠖","⠦","⠤","⠠","⠠","⠤","⠦","⠖","⠒","⠐","⠐","⠒","⠓","⠋","⠉","⠈"],dots8:["⠁","⠁","⠉","⠙","⠚","⠒","⠂","⠂","⠒","⠲","⠴","⠤","⠄","⠄","⠤","⠠","⠠","⠤","⠦","⠖","⠒","⠐","⠐","⠒","⠓","⠋","⠉","⠈","⠈"],dots9:["⢹","⢺","⢼","⣸","⣇","⡧","⡗","⡏"],dots10:["⢄","⢂","⢁","⡁","⡈","⡐","⡠"],dots11:["⠁","⠂","⠄","⡀","⢀","⠠","⠐","⠈"],dots12:["⢀⠀","⡀⠀","⠄⠀","⢂⠀","⡂⠀","⠅⠀","⢃⠀","⡃⠀","⠍⠀","⢋⠀","⡋⠀","⠍⠁","⢋⠁","⡋⠁","⠍⠉","⠋⠉","⠋⠉","⠉⠙","⠉⠙","⠉⠩","⠈⢙","⠈⡙","⢈⠩","⡀⢙","⠄⡙","⢂⠩","⡂⢘","⠅⡘","⢃⠨","⡃⢐","⠍⡐","⢋⠠","⡋⢀","⠍⡁","⢋⠁","⡋⠁","⠍⠉","⠋⠉","⠋⠉","⠉⠙","⠉⠙","⠉⠩","⠈⢙","⠈⡙","⠈⠩","⠀⢙","⠀⡙","⠀⠩","⠀⢘","⠀⡘","⠀⠨","⠀⢐","⠀⡐","⠀⠠","⠀⢀","⠀⡀"],dots13:["⣼","⣹","⢻","⠿","⡟","⣏","⣧","⣶"],dots14:["⠉⠉","⠈⠙","⠀⠹","⠀⢸","⠀⣰","⢀⣠","⣀⣀","⣄⡀","⣆⠀","⡇⠀","⠏⠀","⠋⠁"],dotsCircle:["⢎ ","⠎⠁","⠊⠑","⠈⠱"," ⡱","⢀⡰","⢄⡠","⢆⡀"],sand:["⠁","⠂","⠄","⡀","⡈","⡐","⡠","⣀","⣁","⣂","⣄","⣌","⣔","⣤","⣥","⣦","⣮","⣶","⣷","⣿","⡿","⠿","⢟","⠟","⡛","⠛","⠫","⢋","⠋","⠍","⡉","⠉","⠑","⠡","⢁"],line:["-","\\","|","/"],line2:["⠂","-","–","—","–","-"],pipe:["┤","┘","┴","└","├","┌","┬","┐"],simpleDots:[". ",".. ","..."," "],simpleDotsScrolling:[". ",".. ","..."," .."," ."," "],star:["✶","✸","✹","✺","✹","✷"],star2:["+","x","*"],flip:["_","_","_","-","`","`","'","´","-","_","_","_"],hamburger:["☱","☲","☴"],growVertical:["▁","▃","▄","▅","▆","▇","▆","▅","▄","▃"],growHorizontal:["▏","▎","▍","▌","▋","▊","▉","▊","▋","▌","▍","▎"],balloon:[" ",".","o","O","@","*"," "],balloon2:[".","o","O","°","O","o","."],noise:["▓","▒","░"],bounce:["⠁","⠂","⠄","⠂"],boxBounce:["▖","▘","▝","▗"],boxBounce2:["▌","▀","▐","▄"],triangle:["◢","◣","◤","◥"],binary:["010010","001100","100101","111010","111101","010111","101011","111000","110011","110101"],arc:["◜","◠","◝","◞","◡","◟"],circle:["◡","⊙","◠"],squareCorners:["◰","◳","◲","◱"],circleQuarters:["◴","◷","◶","◵"],circleHalves:["◐","◓","◑","◒"],squish:["╫","╪"],toggle:["⊶","⊷"],toggle2:["▫","▪"],toggle3:["□","■"],toggle4:["■","□","▪","▫"],toggle5:["▮","▯"],toggle6:["ဝ","၀"],toggle7:["⦾","⦿"],toggle8:["◍","◌"],toggle9:["◉","◎"],toggle10:["㊂","㊀","㊁"],toggle11:["⧇","⧆"],toggle12:["☗","☖"],toggle13:["=","*","-"],arrow:["←","↖","↑","↗","→","↘","↓","↙"],arrow2:["⬆️ ","↗️ ","➡️ ","↘️ ","⬇️ ","↙️ ","⬅️ ","↖️ "],arrow3:["▹▹▹▹▹","▸▹▹▹▹","▹▸▹▹▹","▹▹▸▹▹","▹▹▹▸▹","▹▹▹▹▸"],bouncingBar:["[ ]","[= ]","[== ]","[=== ]","[====]","[ ===]","[ ==]","[ =]","[ ]","[ =]","[ ==]","[ ===]","[====]","[=== ]","[== ]","[= ]"],bouncingBall:["( ● )","( ● )","( ● )","( ● )","( ●)","( ● )","( ● )","( ● )","( ● )","(● )"],smiley:["😄 ","😝 "],monkey:["🙈 ","🙈 ","🙉 ","🙊 "],hearts:["💛 ","💙 ","💜 ","💚 ","❤️ "],clock:["🕛 ","🕐 ","🕑 ","🕒 ","🕓 ","🕔 ","🕕 ","🕖 ","🕗 ","🕘 ","🕙 ","🕚 "],earth:["🌍 ","🌎 ","🌏 "],moon:["🌑 ","🌒 ","🌓 ","🌔 ","🌕 ","🌖 ","🌗 ","🌘 "],runner:["🚶 ","🏃 "],dqpb:["d","q","p","b"],weather:["☀️ ","☀️ ","☀️ ","🌤 ","⛅️ ","🌥 ","☁️ ","🌧 ","🌨 ","🌧 ","🌨 ","🌧 ","🌨 ","⛈ ","🌨 ","🌧 ","🌨 ","☁️ ","🌥 ","⛅️ ","🌤 ","☀️ ","☀️ "],christmas:["🌲","🎄"],grenade:["، ","′ "," ´ "," ‾ "," ⸌"," ⸊"," |"," ⁎"," ⁕"," ෴ "," ⁓"," "," "," "],point:["∙∙∙","●∙∙","∙●∙","∙∙●","∙∙∙"],layer:["-","=","≡"],betaWave:["ρββββββ","βρβββββ","ββρββββ","βββρβββ","ββββρββ","βββββρβ","ββββββρ"],fingerDance:["🤘 ","🤟 ","🖖 ","✋ ","🤚 ","👆 "],mindblown:["😐 ","😐 ","😮 ","😮 ","😦 ","😦 ","😧 ","😧 ","🤯 ","💥 ","✨ ","  ","  ","  "],speaker:["🔈 ","🔉 ","🔊 ","🔉 "],orangePulse:["🔸 ","🔶 ","🟠 ","🟠 ","🔶 "],bluePulse:["🔹 ","🔷 ","🔵 ","🔵 ","🔷 "],orangeBluePulse:["🔸 ","🔶 ","🟠 ","🟠 ","🔶 ","🔹 ","🔷 ","🔵 ","🔵 ","🔷 "],timeTravel:["🕛 ","🕚 ","🕙 ","🕘 ","🕗 ","🕖 ","🕕 ","🕔 ","🕓 ","🕒 ","🕑 ","🕐 "],aesthetic:["▰▱▱▱▱▱▱","▰▰▱▱▱▱▱","▰▰▰▱▱▱▱","▰▰▰▰▱▱▱","▰▰▰▰▰▱▱","▰▰▰▰▰▰▱","▰▰▰▰▰▰▰","▰▱▱▱▱▱▱"]};function h(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var c,d,p,m;function C(){if(m)return p;m=1;const t=o;return p=class{constructor(t){this.stream=t,this.linewrap=!0,this.dy=0}cursorSave(){this.stream.isTTY&&this.stream.write("7")}cursorRestore(){this.stream.isTTY&&this.stream.write("8")}cursor(t){this.stream.isTTY&&(t?this.stream.write("[?25h"):this.stream.write("[?25l"))}cursorTo(e=null,s=null){this.stream.isTTY&&t.cursorTo(this.stream,e,s)}cursorRelative(e=null,s=null){this.stream.isTTY&&(this.dy=this.dy+s,t.moveCursor(this.stream,e,s))}cursorRelativeReset(){this.stream.isTTY&&(t.moveCursor(this.stream,0,-this.dy),t.cursorTo(this.stream,0,null),this.dy=0)}clearRight(){this.stream.isTTY&&t.clearLine(this.stream,1)}clearLine(){this.stream.isTTY&&t.clearLine(this.stream,0)}clearBottom(){this.stream.isTTY&&t.clearScreenDown(this.stream)}newline(){this.stream.write("\n"),this.dy++}write(t,e=!1){!0===this.linewrap&&!1===e?this.stream.write(t.substr(0,this.getWidth())):this.stream.write(t)}lineWrapping(t){this.stream.isTTY&&(this.linewrap=t,t?this.stream.write("[?7h"):this.stream.write("[?7l"))}isTTY(){return!0===this.stream.isTTY}getWidth(){return this.stream.columns||(this.stream.isTTY?80:200)}}}var F,g,f,E,B={exports:{}};function b(){if(E)return f;E=1;const t=g?F:(g=1,F=({onlyFirst:t=!1}={})=>{const e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,t?void 0:"g")});return f=e=>"string"==typeof e?e.replace(t(),""):e}var y,w,A,T,S,v,O,L,R,x,M,P,k,$,_,z,I,U,N,j,Y,G,W,q,V,K,H,Z,J,Q,X,tt,et={exports:{}};function st(){if(T)return B.exports;T=1;const t=b(),e=function(){if(y)return et.exports;y=1;const t=t=>!Number.isNaN(t)&&t>=4352&&(t<=4447||9001===t||9002===t||11904<=t&&t<=12871&&12351!==t||12880<=t&&t<=19903||19968<=t&&t<=42182||43360<=t&&t<=43388||44032<=t&&t<=55203||63744<=t&&t<=64255||65040<=t&&t<=65049||65072<=t&&t<=65131||65281<=t&&t<=65376||65504<=t&&t<=65510||110592<=t&&t<=110593||127488<=t&&t<=127569||131072<=t&&t<=262141);return et.exports=t,et.exports.default=t,et.exports}(),s=A?w:(A=1,w=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}),u=u=>{if("string"!=typeof u||0===u.length)return 0;if(0===(u=t(u)).length)return 0;u=u.replace(s()," ");let o=0;for(let t=0;t<u.length;t++){const s=u.codePointAt(t);s<=31||s>=127&&s<=159||(s>=768&&s<=879||(s>65535&&t++,o+=e(s)?2:1))}return o};return B.exports=u,B.exports.default=u,B.exports}function ut(){return v?S:(v=1,S=function(t,e,s){if(!0!==e.autopadding)return t;return"percentage"===s?(u=t,(e.autopaddingChar+u).slice(-3)):t;var u})}function ot(){return L?O:(L=1,O=function(t,e){const s=Math.round(t*e.barsize),u=e.barsize-s;return e.barCompleteString.substr(0,s)+e.barGlue+e.barIncompleteString.substr(0,u)})}function rt(){return x?R:(x=1,R=function(t,e,s){function u(t){return s?s*Math.round(t/s):t}function o(t){return(e.autopaddingChar+t).slice(-2)}return t>3600?o(Math.floor(t/3600))+"h"+o(u(t%3600/60))+"m":t>60?o(Math.floor(t/60))+"m"+o(u(t%60))+"s":t>10?o(u(t))+"s":o(t)+"s"})}function it(){if(P)return M;P=1;const t=st(),e=ut(),s=ot(),u=rt();return M=function(o,r,i){let D=o.format;const a=o.formatTime||u,n=o.formatValue||e,l=o.formatBar||s,h=Math.floor(100*r.progress)+"",c=r.stopTime||Date.now(),d=Math.round((c-r.startTime)/1e3),p=Object.assign({},i,{bar:l(r.progress,o),percentage:n(h,o,"percentage"),total:n(r.total,o,"total"),value:n(r.value,o,"value"),eta:n(r.eta,o,"eta"),eta_formatted:a(r.eta,o,5),duration:n(d,o,"duration"),duration_formatted:a(d,o,1)});D=D.replace(/\{(\w+)\}/g,function(t,e){return void 0!==p[e]?p[e]:t});const m=Math.max(0,r.maxWidth-t(D)-2),C=Math.floor(m/2);switch(o.align){case"right":D=m>0?" ".repeat(m)+D:D;break;case"center":D=C>0?" ".repeat(C)+D:D}return D}}function Dt(){if($)return k;function t(t,e){return null==t?e:t}return $=1,k={parse:function(e,s){const u={},o=Object.assign({},s,e);return u.throttleTime=1e3/t(o.fps,10),u.stream=t(o.stream,process.stderr),u.terminal=t(o.terminal,null),u.clearOnComplete=t(o.clearOnComplete,!1),u.stopOnComplete=t(o.stopOnComplete,!1),u.barsize=t(o.barsize,40),u.align=t(o.align,"left"),u.hideCursor=t(o.hideCursor,!1),u.linewrap=t(o.linewrap,!1),u.barGlue=t(o.barGlue,""),u.barCompleteChar=t(o.barCompleteChar,"="),u.barIncompleteChar=t(o.barIncompleteChar,"-"),u.format=t(o.format,"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}"),u.formatTime=t(o.formatTime,null),u.formatValue=t(o.formatValue,null),u.formatBar=t(o.formatBar,null),u.etaBufferLength=t(o.etaBuffer,10),u.etaAsynchronousUpdate=t(o.etaAsynchronousUpdate,!1),u.progressCalculationRelative=t(o.progressCalculationRelative,!1),u.synchronousUpdate=t(o.synchronousUpdate,!0),u.noTTYOutput=t(o.noTTYOutput,!1),u.notTTYSchedule=t(o.notTTYSchedule,2e3),u.emptyOnZero=t(o.emptyOnZero,!1),u.forceRedraw=t(o.forceRedraw,!1),u.autopadding=t(o.autopadding,!1),u.gracefulExit=t(o.gracefulExit,!1),u},assignDerivedOptions:function(e){return e.barCompleteString=e.barCompleteChar.repeat(e.barsize+1),e.barIncompleteString=e.barIncompleteChar.repeat(e.barsize+1),e.autopaddingChar=e.autopadding?t(e.autopaddingChar," "):"",e}}}function at(){if(z)return _;z=1;const t=d?c:(d=1,c=class{constructor(t,e,s){this.etaBufferLength=t||100,this.valueBuffer=[s],this.timeBuffer=[e],this.eta="0"}update(t,e,s){this.valueBuffer.push(e),this.timeBuffer.push(t),this.calculate(s-e)}getTime(){return this.eta}calculate(t){const e=this.valueBuffer.length,s=Math.min(this.etaBufferLength,e),u=(this.valueBuffer[e-1]-this.valueBuffer[e-s])/(this.timeBuffer[e-1]-this.timeBuffer[e-s]);this.valueBuffer=this.valueBuffer.slice(-this.etaBufferLength),this.timeBuffer=this.timeBuffer.slice(-this.etaBufferLength);const o=Math.ceil(t/u/1e3);isNaN(o)?this.eta="NULL":isFinite(o)?this.eta=o>1e7?"INF":o<0?0:o:this.eta="INF"}}),e=C(),s=it(),u=Dt(),o=D;return _=class extends o{constructor(o){super(),this.options=u.assignDerivedOptions(o),this.terminal=this.options.terminal?this.options.terminal:new e(this.options.stream),this.value=0,this.startValue=0,this.total=100,this.lastDrawnString=null,this.startTime=null,this.stopTime=null,this.lastRedraw=Date.now(),this.eta=new t(this.options.etaBufferLength,0,0),this.payload={},this.isActive=!1,this.formatter="function"==typeof this.options.format?this.options.format:s}render(t=!1){const e={progress:this.getProgress(),eta:this.eta.getTime(),startTime:this.startTime,stopTime:this.stopTime,total:this.total,value:this.value,maxWidth:this.terminal.getWidth()};this.options.etaAsynchronousUpdate&&this.updateETA();const s=this.formatter(this.options,e,this.payload);(t||this.options.forceRedraw||this.options.noTTYOutput&&!this.terminal.isTTY()||this.lastDrawnString!=s)&&(this.emit("redraw-pre"),this.terminal.cursorTo(0,null),this.terminal.write(s),this.terminal.clearRight(),this.lastDrawnString=s,this.lastRedraw=Date.now(),this.emit("redraw-post"))}start(e,s,u){this.value=s||0,this.total=void 0!==e&&e>=0?e:100,this.startValue=s||0,this.payload=u||{},this.startTime=Date.now(),this.stopTime=null,this.lastDrawnString="",this.eta=new t(this.options.etaBufferLength,this.startTime,this.value),this.isActive=!0,this.emit("start",e,s)}stop(){this.isActive=!1,this.stopTime=Date.now(),this.emit("stop",this.total,this.value)}update(t,e={}){"number"==typeof t&&(this.value=t,this.eta.update(Date.now(),t,this.total));const s=("object"==typeof t?t:e)||{};this.emit("update",this.total,this.value);for(const u in s)this.payload[u]=s[u];this.value>=this.getTotal()&&this.options.stopOnComplete&&this.stop()}getProgress(){let t=this.value/this.total;return this.options.progressCalculationRelative&&(t=(this.value-this.startValue)/(this.total-this.startValue)),isNaN(t)&&(t=this.options&&this.options.emptyOnZero?0:1),t=Math.min(Math.max(t,0),1),t}increment(t=1,e={}){"object"==typeof t?this.update(this.value+1,t):this.update(this.value+t,e)}getTotal(){return this.total}setTotal(t){void 0!==t&&t>=0&&(this.total=t)}updateETA(){this.eta.update(Date.now(),this.value,this.total)}}}function nt(){if(Q)return J;Q=1;const t=G?Y:(G=1,Y={format:"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"=",barIncompleteChar:"-"}),e=q?W:(q=1,W={format:" {bar} {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"█",barIncompleteChar:"░"}),s=K?V:(K=1,V={format:" {bar} {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"█",barIncompleteChar:"░"}),u=Z?H:(Z=1,H={format:" {bar}■ {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"■",barIncompleteChar:" "});return J={legacy:t,shades_classic:e,shades_grey:s,rect:u}}const lt=h(function(){if(tt)return X;tt=1;const t=function(){if(U)return I;U=1;const t=at(),e=Dt();return I=class extends t{constructor(t,s){super(e.parse(t,s)),this.timer=null,this.options.noTTYOutput&&!1===this.terminal.isTTY()&&(this.options.synchronousUpdate=!1),this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.sigintCallback=null}render(){this.timer&&(clearTimeout(this.timer),this.timer=null),super.render(),this.options.noTTYOutput&&!1===this.terminal.isTTY()&&this.terminal.newline(),this.timer=setTimeout(this.render.bind(this),this.schedulingRate)}update(t,e){this.timer&&(super.update(t,e),this.options.synchronousUpdate&&this.lastRedraw+2*this.options.throttleTime<Date.now()&&this.render())}start(t,e,s){!1===this.options.noTTYOutput&&!1===this.terminal.isTTY()||(null===this.sigintCallback&&this.options.gracefulExit&&(this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback)),this.terminal.cursorSave(),!0===this.options.hideCursor&&this.terminal.cursor(!1),!1===this.options.linewrap&&this.terminal.lineWrapping(!1),super.start(t,e,s),this.render())}stop(){this.timer&&(this.sigintCallback&&(process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null),this.render(),super.stop(),clearTimeout(this.timer),this.timer=null,!0===this.options.hideCursor&&this.terminal.cursor(!0),!1===this.options.linewrap&&this.terminal.lineWrapping(!0),this.terminal.cursorRestore(),this.options.clearOnComplete?(this.terminal.cursorTo(0,null),this.terminal.clearLine()):this.terminal.newline())}}}(),e=function(){if(j)return N;j=1;const t=C(),e=at(),s=Dt(),u=D;return N=class extends u{constructor(e,u){super(),this.bars=[],this.options=s.parse(e,u),this.options.synchronousUpdate=!1,this.terminal=this.options.terminal?this.options.terminal:new t(this.options.stream),this.timer=null,this.isActive=!1,this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.loggingBuffer=[],this.sigintCallback=null}create(t,s,u,o={}){const r=new e(Object.assign({},this.options,{terminal:this.terminal},o));return this.bars.push(r),!1===this.options.noTTYOutput&&!1===this.terminal.isTTY()||(null===this.sigintCallback&&this.options.gracefulExit&&(this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback)),this.isActive||(!0===this.options.hideCursor&&this.terminal.cursor(!1),!1===this.options.linewrap&&this.terminal.lineWrapping(!1),this.timer=setTimeout(this.update.bind(this),this.schedulingRate)),this.isActive=!0,r.start(t,s,u),this.emit("start")),r}remove(t){const e=this.bars.indexOf(t);return!(e<0||(this.bars.splice(e,1),this.update(),this.terminal.newline(),this.terminal.clearBottom(),0))}update(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),this.emit("update-pre"),this.terminal.cursorRelativeReset(),this.emit("redraw-pre"),this.loggingBuffer.length>0)for(this.terminal.clearLine();this.loggingBuffer.length>0;)this.terminal.write(this.loggingBuffer.shift(),!0);for(let t=0;t<this.bars.length;t++)t>0&&this.terminal.newline(),this.bars[t].render();this.emit("redraw-post"),this.options.noTTYOutput&&!1===this.terminal.isTTY()&&(this.terminal.newline(),this.terminal.newline()),this.timer=setTimeout(this.update.bind(this),this.schedulingRate),this.emit("update-post"),this.options.stopOnComplete&&!this.bars.find(t=>t.isActive)&&this.stop()}stop(){if(clearTimeout(this.timer),this.timer=null,this.sigintCallback&&(process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null),this.isActive=!1,!0===this.options.hideCursor&&this.terminal.cursor(!0),!1===this.options.linewrap&&this.terminal.lineWrapping(!0),this.terminal.cursorRelativeReset(),this.emit("stop-pre-clear"),this.options.clearOnComplete)this.terminal.clearBottom();else{for(let t=0;t<this.bars.length;t++)t>0&&this.terminal.newline(),this.bars[t].render(),this.bars[t].stop();this.terminal.newline()}this.emit("stop")}log(t){this.loggingBuffer.push(t)}}}(),s=nt(),u=it(),o=ut(),r=ot(),i=rt();return X={Bar:t,SingleBar:t,MultiBar:e,Presets:s,Format:{Formatter:u,BarFormat:r,ValueFormat:o,TimeFormat:i}}}()),ht=(t=0)=>e=>`[${e+t}m`,ct=(t=0)=>e=>`[${38+t};5;${e}m`,dt=(t=0)=>(e,s,u)=>`[${38+t};2;${e};${s};${u}m`,pt={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(pt.modifier);Object.keys(pt.color),Object.keys(pt.bgColor);const mt=function(){const t=new Map;for(const[e,s]of Object.entries(pt)){for(const[e,u]of Object.entries(s))pt[e]={open:`[${u[0]}m`,close:`[${u[1]}m`},s[e]=pt[e],t.set(u[0],u[1]);Object.defineProperty(pt,e,{value:s,enumerable:!1})}return Object.defineProperty(pt,"codes",{value:t,enumerable:!1}),pt.color.close="",pt.bgColor.close="",pt.color.ansi=ht(),pt.color.ansi256=ct(),pt.color.ansi16m=dt(),pt.bgColor.ansi=ht(10),pt.bgColor.ansi256=ct(10),pt.bgColor.ansi16m=dt(10),Object.defineProperties(pt,{rgbToAnsi256:{value:(t,e,s)=>t===e&&e===s?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(e/255*5)+Math.round(s/255*5),enumerable:!1},hexToRgb:{value(t){const e=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!e)return[0,0,0];let[s]=e;3===s.length&&(s=[...s].map(t=>t+t).join(""));const u=Number.parseInt(s,16);return[u>>16&255,u>>8&255,255&u]},enumerable:!1},hexToAnsi256:{value:t=>pt.rgbToAnsi256(...pt.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return t-8+90;let e,s,u;if(t>=232)e=(10*(t-232)+8)/255,s=e,u=e;else{const o=(t-=16)%36;e=Math.floor(t/36)/5,s=Math.floor(o/6)/5,u=o%6/5}const o=2*Math.max(e,s,u);if(0===o)return 30;let r=30+(Math.round(u)<<2|Math.round(s)<<1|Math.round(e));return 2===o&&(r+=60),r},enumerable:!1},rgbToAnsi:{value:(t,e,s)=>pt.ansi256ToAnsi(pt.rgbToAnsi256(t,e,s)),enumerable:!1},hexToAnsi:{value:t=>pt.ansi256ToAnsi(pt.hexToAnsi256(t)),enumerable:!1}}),pt}(),Ct=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const t=navigator.userAgentData.brands.find(({brand:t})=>"Chromium"===t);if(t&&t.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),Ft=0!==Ct&&{level:Ct},gt={stdout:Ft,stderr:Ft};function ft(t,e,s){let u=t.indexOf(e);if(-1===u)return t;const o=e.length;let r=0,i="";do{i+=t.slice(r,u)+e+s,r=u+o,u=t.indexOf(e,r)}while(-1!==u);return i+=t.slice(r),i}const{stdout:Et,stderr:Bt}=gt,bt=Symbol("GENERATOR"),yt=Symbol("STYLER"),wt=Symbol("IS_EMPTY"),At=["ansi","ansi","ansi256","ansi16m"],Tt=Object.create(null),St=t=>{const e=(...t)=>t.join(" ");return((t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const s=Et?Et.level:0;t.level=void 0===e.level?s:e.level})(e,t),Object.setPrototypeOf(e,vt.prototype),e};function vt(t){return St(t)}Object.setPrototypeOf(vt.prototype,Function.prototype);for(const[zt,It]of Object.entries(mt))Tt[zt]={get(){const t=Mt(this,xt(It.open,It.close,this[yt]),this[wt]);return Object.defineProperty(this,zt,{value:t}),t}};Tt.visible={get(){const t=Mt(this,this[yt],!0);return Object.defineProperty(this,"visible",{value:t}),t}};const Ot=(t,e,s,...u)=>"rgb"===t?"ansi16m"===e?mt[s].ansi16m(...u):"ansi256"===e?mt[s].ansi256(mt.rgbToAnsi256(...u)):mt[s].ansi(mt.rgbToAnsi(...u)):"hex"===t?Ot("rgb",e,s,...mt.hexToRgb(...u)):mt[s][t](...u),Lt=["rgb","hex","ansi256"];for(const zt of Lt){Tt[zt]={get(){const{level:t}=this;return function(...e){const s=xt(Ot(zt,At[t],"color",...e),mt.color.close,this[yt]);return Mt(this,s,this[wt])}}};Tt["bg"+zt[0].toUpperCase()+zt.slice(1)]={get(){const{level:t}=this;return function(...e){const s=xt(Ot(zt,At[t],"bgColor",...e),mt.bgColor.close,this[yt]);return Mt(this,s,this[wt])}}}}const Rt=Object.defineProperties(()=>{},{...Tt,level:{enumerable:!0,get(){return this[bt].level},set(t){this[bt].level=t}}}),xt=(t,e,s)=>{let u,o;return void 0===s?(u=t,o=e):(u=s.openAll+t,o=e+s.closeAll),{open:t,close:e,openAll:u,closeAll:o,parent:s}},Mt=(t,e,s)=>{const u=(...t)=>Pt(u,1===t.length?""+t[0]:t.join(" "));return Object.setPrototypeOf(u,Rt),u[bt]=t,u[yt]=e,u[wt]=s,u},Pt=(t,e)=>{if(t.level<=0||!e)return t[wt]?"":e;let s=t[yt];if(void 0===s)return e;const{openAll:u,closeAll:o}=s;if(e.includes(""))for(;void 0!==s;)e=ft(e,s.close,s.open),s=s.parent;const r=e.indexOf("\n");return-1!==r&&(e=function(t,e,s,u){let o=0,r="";do{const i="\r"===t[u-1];r+=t.slice(o,i?u-1:u)+e+(i?"\r\n":"\n")+s,o=u+1,u=t.indexOf("\n",o)}while(-1!==u);return r+=t.slice(o),r}(e,o,u,r)),u+e+o};Object.defineProperties(vt.prototype,Tt);const kt=vt();vt({level:Bt?Bt.level:0}),dirname("undefined"==typeof document?require("url").pathToFileURL(__filename).href:n&&"SCRIPT"===n.tagName.toUpperCase()&&n.src||new URL("download.cjs.js",document.baseURI).href);class $t{constructor(){this.commands={},this.options={},this.examples=[],this.helpText="",this.versionText="1.0.0"}usage(t){return this.helpText=t,this}command(t,e,s){const u=t.match(/\$0 <(\w+)>/);return u&&(this.commands[u[1]]={desc:e,handler:s,required:!0}),this}option(t,e={}){return this.options[t]=e,this}example(t,e){return this.examples.push({cmd:t,desc:e}),this}help(){return this}alias(t,e){return this.options[e]&&(this.options[e].alias=t),this}version(t){return t&&(this.versionText=t),this}strict(){return this}parseSync(){const t=process.argv.slice(2),e={},s=[];(t.includes("--help")||t.includes("-h"))&&(this.showHelp(),process.exit(0)),t.includes("--version")&&(console.log(this.versionText),process.exit(0));for(let u=0;u<t.length;u++){const o=t[u];if(o.startsWith("--")){const[s,r]=o.split("="),i=s.slice(2);if(void 0!==r)e[i]=this.coerceValue(i,r);else if("boolean"===this.options[i]?.type)e[i]=!0;else{const s=t[u+1];s&&!s.startsWith("-")?(e[i]=this.coerceValue(i,s),u++):e[i]=!0}}else if(o.startsWith("-")&&2===o.length){const s=o[1],r=this.findLongName(s);if(r)if("boolean"===this.options[r]?.type)e[r]=!0;else{const s=t[u+1];s&&!s.startsWith("-")&&(e[r]=this.coerceValue(r,s),u++)}}else s.push(o)}return s.length>0&&(e.urls=s),Object.keys(this.options).forEach(t=>{void 0===e[t]&&void 0!==this.options[t].default&&(e[t]=this.options[t].default)}),e.urls&&0!==e.urls.length||!this.commands.url?.required||(console.error("Error: Missing required argument: url"),this.showHelp(),process.exit(1)),e}coerceValue(t,e){const s=this.options[t];if(!s)return e;if(s.coerce)return s.coerce(e);switch(s.type){case"number":return Number(e);case"boolean":return"true"===e||"1"===e;default:return e}}findLongName(t){return Object.keys(this.options).find(e=>this.options[e].alias===t)}showHelp(){console.log(this.helpText||"Usage: grab <url> [options]"),console.log("\nPositional arguments:"),Object.keys(this.commands).forEach(t=>{console.log(` ${t.padEnd(20)} ${this.commands[t].desc}`)}),console.log("\nOptions:"),Object.keys(this.options).forEach(t=>{const e=this.options[t],s=e.alias?`-${e.alias}, --${t}`:`--${t}`;console.log(` ${s.padEnd(20)} ${e.describe||""}`)}),this.examples.length>0&&(console.log("\nExamples:"),this.examples.forEach(t=>{console.log(` ${t.cmd}`),console.log(` ${t.desc}`)}))}}class _t{constructor(){this.progressBar=null,this.multiBar=null,this.loadingSpinner=null,this.abortController=null,this.COL_FILENAME=25,this.COL_SPINNER=2,this.COL_BAR=15,this.COL_PERCENT=4,this.COL_DOWNLOADED=16,this.COL_TOTAL=10,this.COL_SPEED=10,this.COL_ETA=10,this.colors={primary:kt.cyan,success:kt.green,warning:kt.yellow,error:kt.red,info:kt.blue,purple:kt.magenta,pink:kt.magentaBright,yellow:kt.yellowBright,cyan:kt.cyanBright,green:kt.green,gradient:[kt.blue,kt.magenta,kt.cyan,kt.green,kt.yellow,kt.red]},this.barColors=["","","","","","","","","","",""],this.barGlueColors=["","","","","","",""],this.spinnerTypes=Object.keys(l.default||l),this.stateDir=this.getStateDirectory(),this.ensureStateDirectoryExists(),this.isPaused=!1,this.pauseCallback=null,this.resumeCallback=null,this.abortControllers=[],this.keyboardListener=null,this.isAddingUrl=!1}getStateDirectory(){return process.env.GRAB_DOWNLOAD_STATE_DIR||e.join(process.cwd(),".grab-downloads")}ensureStateDirectoryExists(){try{t.existsSync(this.stateDir)||t.mkdirSync(this.stateDir,{recursive:!0})}catch(e){console.log(this.colors.warning("⚠️ Could not create state directory, using current directory")),this.stateDir=process.cwd()}}getStateFilePath(t){const s=e.basename(t)+".download-state";return e.join(this.stateDir,s)}cleanupStateFile(e){try{t.existsSync(e)&&t.unlinkSync(e)}catch(s){console.log(this.colors.warning("⚠️ Could not clean up state file"))}}printHeaderRow(){console.log(this.colors.success("📈 %".padEnd(this.COL_PERCENT))+this.colors.yellow("📁 Files".padEnd(this.COL_FILENAME))+this.colors.cyan("🔄".padEnd(this.COL_SPINNER))+" "+this.colors.green("📊 Progress".padEnd(this.COL_BAR+1))+this.colors.info("📥 Downloaded".padEnd(this.COL_DOWNLOADED))+this.colors.info("📦 Total".padEnd(this.COL_TOTAL))+this.colors.purple("⚡ Speed".padEnd(this.COL_SPEED))+this.colors.pink("⏱️ ETA".padEnd(this.COL_ETA)))}getRandomOraSpinner(){return this.spinnerTypes[Math.floor(Math.random()*this.spinnerTypes.length)]}getRandomBarColor(){return this.barColors[Math.floor(Math.random()*this.barColors.length)]}getRandomBarGlueColor(){return this.barGlueColors[Math.floor(Math.random()*this.barGlueColors.length)]}getRandomSpinner(){return this.spinnerTypes[Math.floor(Math.random()*this.spinnerTypes.length)]}getSpinnerFrames(t){const e=l.default||l,s=e[t];return s&&s.frames?s.frames:e.dots?.frames||["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"]}getSpinnerWidth(t){let e=0;for(const s of t){const t=s.codePointAt(0);e+=t>=126976&&t<=128767||t>=127744&&t<=128511||t>=128512&&t<=128591||t>=128640&&t<=128767||t>=128768&&t<=128895||t>=128896&&t<=129023||t>=129024&&t<=129279||t>=9728&&t<=9983||t>=9984&&t<=10175?2:1}return e}calculateBarSize(t,e=20){const s=(process.stdout.columns||120)-59-20-this.getSpinnerWidth(t);return Math.max(10,Math.min(e,s))}async checkServerSupport(t){try{const e=await fetch(t,{method:"HEAD",signal:this.abortController?.signal});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);const s=e.headers.get("accept-ranges"),u=e.headers.get("content-length"),o=e.headers.get("last-modified"),r=e.headers.get("etag");return{supportsResume:"bytes"===s,totalSize:u?parseInt(u,10):0,lastModified:o,etag:r,headers:e.headers}}catch(e){return console.log(this.colors.warning("⚠️ Could not check server resume support, proceeding with regular download")),{supportsResume:!1,totalSize:0,lastModified:null,etag:null,headers:null}}}loadDownloadState(e){try{if(t.existsSync(e)){const s=t.readFileSync(e,"utf8");return JSON.parse(s)}}catch(s){console.log(this.colors.warning("⚠️ Could not load download state, starting fresh"))}return null}saveDownloadState(e,s){try{t.writeFileSync(e,JSON.stringify(s,null,2))}catch(u){console.log(this.colors.warning("⚠️ Could not save download state"))}}getPartialFileSize(e){try{if(t.existsSync(e)){return t.statSync(e).size}}catch(s){console.log(this.colors.warning("⚠️ Could not read partial file size"))}return 0}getRandomColor(){return this.colors.gradient[Math.floor(Math.random()*this.colors.gradient.length)]}formatBytes(t,e=2){if(0===t)return this.colors.info("0 B");const s=e<0?0:e,u=[{unit:"B",color:this.colors.info},{unit:"KB",color:this.colors.cyan},{unit:"MB",color:this.colors.yellow},{unit:"GB",color:this.colors.purple},{unit:"TB",color:this.colors.pink},{unit:"PB",color:this.colors.primary}],o=Math.floor(Math.log(t)/Math.log(1024)),r=parseFloat((t/Math.pow(1024,o)).toFixed(s)),i=u[o]||u[u.length-1];return i.color.bold(`${r} ${i.unit}`)}formatBytesPlain(t,e=1){if(0===t)return"0 B";const s=e<0?0:e,u=["B","KB","MB","GB","TB","PB"],o=Math.floor(Math.log(t)/Math.log(1024));return`${parseFloat((t/Math.pow(1024,o)).toFixed(s))} ${u[o]||u[u.length-1]}`}formatBytesCompact(t){if(0===t)return"0B";const e=1024,s=t/e;if(s<100){return`${Math.round(s)}KB`}return`${(t/(e*e)).toFixed(1)}`}truncateFilename(t,s=25){if(t.length<=s)return t.padEnd(s);const u=e.extname(t),o=e.basename(t,u);if(o.length<=3)return t.padEnd(s);const r=Math.ceil((s-u.length-3)/2),i=Math.floor((s-u.length-3)/2);return`${o.substring(0,r)+"..."+o.substring(o.length-i)}${u}`.padEnd(s)}formatETA(t){if(!t||t===1/0||t<0)return" -- ";const e=Math.floor(t/3600),s=Math.floor(t%3600/60),u=Math.round(t%60);return`${e}:${s.toString().padStart(2,"0")}:${u.toString().padStart(2,"0")}`.padEnd(this.COL_ETA)}formatMasterProgress(t,e){const s=1024,u=t/(s*s);if(e/(s*s)>=1024){return`${(u/1024).toFixed(1)}GB`.padEnd(this.COL_DOWNLOADED)}return`${u.toFixed(1)}MB`.padEnd(this.COL_DOWNLOADED)}formatProgress(t,e){return this.formatBytesCompact(t).padEnd(this.COL_DOWNLOADED)}formatDownloaded(t){return this.formatBytesCompact(t).padEnd(this.COL_DOWNLOADED)}formatTotalDisplay(t){if(0===t)return"0MB".padEnd(this.COL_TOTAL);const e=t/1048576;if(e>=1024){return`${(e/1024).toFixed(1)}GB`.padEnd(this.COL_TOTAL)}return e<1?`${e.toFixed(2)}MB`.padEnd(this.COL_TOTAL):`${e.toFixed(1)}MB`.padEnd(this.COL_TOTAL)}formatTotal(t){if(0===t)return"0MB".padEnd(this.COL_TOTAL);const e=t/1048576;if(e>=1024){return`${(e/1024).toFixed(1)}GB`.padEnd(this.COL_TOTAL)}return e<1?`${e.toFixed(2)}MB`.padEnd(this.COL_TOTAL):`${e.toFixed(1)}MB`.padEnd(this.COL_TOTAL)}formatSpeed(t){return t.padEnd(this.COL_SPEED)}formatSpeedDisplay(t){if(0===t)return"0B";const e=1024,s=t/e;if(s<100){return`${Math.round(s)}KB`}return`${(t/(e*e)).toFixed(1)}`}formatTotalSpeed(t){return this.formatSpeedDisplay(t).padEnd(this.COL_SPEED)}async downloadMultipleFiles(t){try{this.setupGlobalKeyboardListener();const e=this.getRandomBarColor(),s=this.getRandomBarGlueColor();this.multiBar=new lt.MultiBar({format:this.colors.success("{percentage}%")+" "+this.colors.yellow("{filename}")+" "+this.colors.cyan("{spinner}")+" "+e+"{bar} "+this.colors.info("{downloadedDisplay}")+" "+this.colors.info("{totalDisplay}")+" "+this.colors.purple("{speed}")+" "+this.colors.pink("{etaFormatted}"),hideCursor:!0,clearOnComplete:!1,stopOnComplete:!0,autopadding:!1,barCompleteChar:"█",barIncompleteChar:"░",barGlue:s,barsize:this.COL_BAR});let u=0,o=0,r=new Array(t.length).fill(0),i=new Array(t.length).fill(0),D=new Array(t.length).fill(0),a=new Array(t.length).fill(Date.now()),n=Date.now(),l=new Array(t.length).fill(0),h=Date.now(),c=0;const d=t.reduce((t,e)=>t+(e.estimatedSize||104857600),0);o=d;let p=0;const m=setInterval(()=>{const e=Date.now(),s=(e-n)/1e3;for(let o=0;o<t.length;o++)if(s>0){const t=D[o]-l[o];if(r[o]=t/s,E[o]&&E[o].bar){const t=this.formatSpeed(this.formatSpeedDisplay(r[o])),e=i[o]>0?this.formatETA((i[o]-D[o])/r[o]):this.formatETA(0);E[o].bar.update(D[o],{speed:t,progress:this.formatProgress(D[o],i[o]),downloadedDisplay:this.formatBytesCompact(D[o]),totalDisplay:this.formatTotalDisplay(i[o]),etaFormatted:e})}}n=e,l=[...D];const u=r.reduce((t,e)=>t+e,0),h=D.reduce((t,e)=>t+e,0),c=(e-a[0])/1e3,d=(o>0&&u>0?this.formatETA((o-h)/u):this.formatETA(0),o>0&&Math.round(h/o*100),i.reduce((t,e)=>t+e,0)),p=d>0?d:o;f.update(h,{speed:this.formatTotalSpeed(u),progress:this.formatMasterProgress(h,p),downloadedDisplay:this.formatBytesCompact(h),totalDisplay:this.formatTotalDisplay(p),etaFormatted:this.formatETA(c),percentage:p>0?Math.round(h/p*100):0})},1e3),C=this.getSpinnerWidth("⬇️"),F=this.COL_FILENAME-C,g=this.calculateBarSize("⬇️",this.COL_BAR),f=this.multiBar.create(o,0,{filename:"Total".padEnd(F),spinner:"⬇️",speed:"0B".padEnd(this.COL_SPEED),progress:this.formatMasterProgress(0,o),downloadedDisplay:this.formatBytesCompact(0),totalDisplay:this.formatTotalDisplay(o),etaFormatted:this.formatETA(0),percentage:" 0".padStart(this.COL_PERCENT-1)},{format:this.colors.success("{percentage}%")+" "+this.colors.yellow.bold("{filename}")+" "+this.colors.success("{spinner}")+" {bar} "+this.colors.info("{downloadedDisplay}")+" "+this.colors.info("{totalDisplay}")+" "+this.colors.purple("{speed}")+" "+this.colors.pink("{etaFormatted}"),barCompleteChar:"▶",barIncompleteChar:"▷",barGlue:"",barsize:g}),E=t.map((t,e)=>{const s=this.getRandomSpinner(),u=this.getSpinnerFrames(s),o=this.getSpinnerWidth(u[0]),r=this.COL_FILENAME-o,i=this.truncateFilename(t.filename,r),D=this.getRandomBarColor(),a=this.getRandomBarGlueColor(),n=this.calculateBarSize(u[0],this.COL_BAR);return{bar:this.multiBar.create(100,0,{filename:i,spinner:u[0],speed:this.formatSpeed("0B"),progress:this.formatProgress(0,0),downloadedDisplay:this.formatBytesCompact(0),totalDisplay:this.formatTotalDisplay(0),etaFormatted:this.formatETA(0),percentage:" 0".padStart(3)},{format:this.colors.yellow("{filename}")+" "+this.colors.cyan("{spinner}")+" "+D+"{bar} "+this.colors.success("{percentage}%")+" "+this.colors.info("{downloadedDisplay}")+" "+this.colors.info("{totalDisplay}")+" "+this.colors.purple("{speed}")+" "+this.colors.pink("{etaFormatted}"),barCompleteChar:"█",barIncompleteChar:"░",barGlue:a,barsize:n}),spinnerFrames:u,spinnerIndex:0,lastSpinnerUpdate:Date.now(),lastFrameUpdate:Date.now(),download:{...t,index:e}}}),B=E.map(async(e,s)=>{try{return await this.downloadSingleFileWithBar(e,f,t.length,{totalDownloaded:u,totalSize:o,individualSpeeds:r,individualSizes:i,individualDownloaded:D,individualStartTimes:a,lastTotalUpdate:h,lastTotalDownloaded:c,actualTotalSize:p}),{success:!0,index:s,filename:e.download.filename}}catch(n){return{success:!1,index:s,filename:e.download.filename,error:n}}}),b=await Promise.allSettled(B);clearInterval(m),this.multiBar.stop();const y=b.filter(t=>"fulfilled"===t.status&&t.value.success).length,w=b.length-y;w>0&&(console.log(this.colors.error(`❌ Failed: ${w}/${t.length}`)),b.forEach((e,s)=>{if("rejected"===e.status||!e.value.success){const u=t[s].filename,o=e.reason||e.value?.error||"Unknown error";console.log(this.colors.error(` • ${u}: ${o.message||o}`))}}));const A=["🥳","🎊","🎈","🌟","💯","🚀","✨","🔥"],T=A[Math.floor(Math.random()*A.length)];console.log(this.colors.green(`${T} Success: ${y}/${t.length}`)),this.clearAbortControllers();let S=!1;this.setPauseCallback(()=>{S||(this.multiBar.stop(),console.log(this.colors.warning("⏸️ Paused. Press p to resume, a to add URL.")),S=!0)}),this.setResumeCallback(()=>{S&&(console.log(this.colors.success("▶️ Resumed. Press p to pause, a to add URL.")),S=!1)})}catch(e){throw this.multiBar&&this.multiBar.stop(),console.error(this.colors.error.bold("💥 Batch download failed: ")+this.colors.warning(e.message)),e}}async downloadSingleFileWithBar(e,o,r,i){const{bar:D,spinnerFrames:a,download:n}=e,{url:l,outputPath:h,filename:c}=n,d=this.getStateFilePath(h),p=h+".tmp";try{const r=new AbortController;this.setAbortController(r);const n=await this.checkServerSupport(l),c=this.loadDownloadState(d),m=this.getPartialFileSize(p);let C=0,F=!1;if(n.supportsResume&&m>0&&c){!(n.lastModified&&n.lastModified!==c.lastModified||n.etag&&n.etag!==c.etag||n.totalSize!==c.totalSize)&&m<n.totalSize?(C=m,F=!0):(t.existsSync(p)&&t.unlinkSync(p),this.cleanupStateFile(d))}else m>0&&t.existsSync(p)&&t.unlinkSync(p);const g={};F&&C>0&&(g.Range=`bytes=${C}-`);const f=await fetch(l,{headers:g,signal:r.signal});if(!f.ok)throw new Error(`HTTP error! status: ${f.status}`);const E=f.headers.get("content-length"),B=F?n.totalSize:E?parseInt(E,10):0,b={url:l,outputPath:h,totalSize:B,startByte:C,lastModified:n.lastModified,etag:n.etag,timestamp:(new Date).toISOString()};this.saveDownloadState(d,b),D.setTotal(B||100),D.update(C,{progress:this.formatProgress(C,B),downloadedDisplay:this.formatBytesCompact(C),totalDisplay:this.formatTotalDisplay(B)});const y=t.createWriteStream(p,{flags:F?"a":"w"});let w=C,A=Date.now(),T=w;const S=new u.Readable({read(){}}),v=f.body.getReader();(async()=>{try{for(;;){for(;this.isPaused;)await new Promise(t=>setTimeout(t,100));const{done:t,value:s}=await v.read();if(t){S.push(null);break}w+=s.length;const u=Date.now(),r=(u-A)/1e3;if(u-e.lastFrameUpdate>=150){e.spinnerIndex=(e.spinnerIndex+1)%a.length,e.lastFrameUpdate=u;const t=a[e.spinnerIndex],s=this.calculateBarSize(t,this.COL_BAR);D.options.barsize=s}if(u-e.lastSpinnerUpdate>=45e3){const t=this.getRandomSpinner();e.spinnerFrames=this.getSpinnerFrames(t),e.spinnerIndex=0,e.lastSpinnerUpdate=u}if(r>=.3){if(D.update(w,{spinner:a[e.spinnerIndex],progress:this.formatProgress(w,B),downloadedDisplay:this.formatBytesCompact(w),totalDisplay:this.formatTotalDisplay(B)}),i){const t=w-T;i.totalDownloaded+=t;const s=e.download.index||0;i.individualDownloaded[s]=w,i.individualSizes[s]=B,i.totalSize=i.individualSizes.reduce((t,e)=>t+e,0),void 0!==i.actualTotalSize&&(i.actualTotalSize=i.totalSize),B>0&&i.individualSizes[s]===B&&o.setTotal(i.totalSize)}A=u,T=w}else D.update(w,{spinner:a[e.spinnerIndex],progress:this.formatProgress(w,B),downloadedDisplay:this.formatBytesCompact(w),totalDisplay:this.formatTotalDisplay(B)});S.push(Buffer.from(s))}}catch(t){S.destroy(t)}})(),await s.pipeline(S,y),t.existsSync(h)&&t.unlinkSync(h),t.renameSync(p,h),this.cleanupStateFile(d);o.value;const O=i.actualTotalSize||i.totalSize,L=i.individualSizes.reduce((t,e)=>t+e,0),R=L>0?L:O;o.update(i.totalDownloaded,{progress:this.formatMasterProgress(i.totalDownloaded,R),downloadedDisplay:this.formatBytesCompact(i.totalDownloaded),totalDisplay:this.formatTotalDisplay(R),etaFormatted:this.formatETA((Date.now()-(i.individualStartTimes?.[0]||Date.now()))/1e3)})}catch(m){throw D.update(D.total,{spinner:"❌",speed:this.formatSpeed("FAILED"),downloadedDisplay:this.formatBytesCompact(0),totalDisplay:this.formatTotalDisplay(0)}),console.log(this.colors.info(`💾 Partial download saved for ${c}. Restart to resume.`)),m}}async downloadFile(e,o){const r=this.getStateFilePath(o),i=o+".tmp";try{this.abortController=new AbortController;const D=this.getRandomOraSpinner();this.loadingSpinner=ora({text:this.colors.primary("🌐 Checking server capabilities..."),spinner:D,color:"cyan"}).start();const a=await this.checkServerSupport(e),n=this.loadDownloadState(r),l=this.getPartialFileSize(i);let h=0,c=!1;if(a.supportsResume&&l>0&&n){!(a.lastModified&&a.lastModified!==n.lastModified||a.etag&&a.etag!==n.etag||a.totalSize!==n.totalSize)&&l<a.totalSize?(h=l,c=!0,this.loadingSpinner.succeed(this.colors.success(`✅ Found partial download: ${this.formatBytes(l)} of ${this.formatTotal(a.totalSize)}`)),console.log(this.colors.info(`🔄 Resuming download from ${this.formatBytes(h)}`))):(this.loadingSpinner.warn(this.colors.warning("⚠️ File changed on server, starting fresh download")),t.existsSync(i)&&t.unlinkSync(i),this.cleanupStateFile(r))}else this.loadingSpinner.stop(),l>0&&(console.log(this.colors.warning("⚠️ Server does not support resumable downloads, starting fresh")),t.existsSync(i)&&t.unlinkSync(i));const d={};c&&h>0&&(d.Range=`bytes=${h}-`);const p=await fetch(e,{headers:d,signal:this.abortController.signal});if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);const m=p.headers.get("content-length"),C=c?a.totalSize:m?parseInt(m,10):0;m&&parseInt(m,10);c||(0===C?console.log(this.colors.warning("⚠️ Warning: Content-Length not provided, progress will be estimated")):console.log(this.colors.info(`📦 File size: ${this.formatTotal(C)}`)));const F={url:e,outputPath:o,totalSize:C,startByte:h,lastModified:a.lastModified,etag:a.etag,timestamp:(new Date).toISOString()};this.saveDownloadState(r,F);const g=this.getRandomBarColor(),f=this.getRandomBarGlueColor();let E=this.getRandomSpinner(),B=this.getSpinnerFrames(E),b=0;const y=this.calculateBarSize(B[0],this.COL_BAR);console.log(this.colors.success("📈 %".padEnd(this.COL_PERCENT))+this.colors.cyan("🔄".padEnd(this.COL_SPINNER))+" "+this.colors.green("📊 Progress".padEnd(this.COL_BAR+1))+this.colors.info("📥 Downloaded".padEnd(this.COL_DOWNLOADED))+this.colors.info("📦 Total".padEnd(this.COL_TOTAL))+this.colors.purple("⚡ Speed".padEnd(this.COL_SPEED))+this.colors.pink("⏱️ ETA".padEnd(this.COL_ETA)));this.setupSingleFileKeyboardListeners(e,o);this.progressBar=new lt.SingleBar({format:this.colors.success("{percentage}%")+" "+this.colors.cyan("{spinner}")+" "+g+"{bar} "+this.colors.info("{downloadedDisplay}")+" "+this.colors.info("{totalDisplay}")+" "+this.colors.purple("{speed}")+" "+this.colors.pink("{etaFormatted}"),barCompleteChar:"█",barIncompleteChar:"░",barGlue:f,hideCursor:!0,barsize:y,stopOnComplete:!0,clearOnComplete:!1}),this.progressBar.start(C||100,h,{speed:this.formatSpeed("0B/s"),etaFormatted:this.formatETA(0),spinner:B[0],progress:this.formatProgress(h,C),downloadedDisplay:this.formatBytesCompact(h),totalDisplay:this.formatTotalDisplay(C)});const w=t.createWriteStream(i,{flags:c?"a":"w"});let A=h,T=0,S=Date.now(),v=A,O=Date.now(),L=Date.now();const R=new u.Readable({read(){}}),x=p.body.getReader();(async()=>{try{for(;;){for(;this.isPaused;)await new Promise(t=>setTimeout(t,100));const{done:t,value:e}=await x.read();if(t){R.push(null);break}T+=e.length,A+=e.length;const s=Date.now(),u=(s-S)/1e3;if(s-O>=45e3&&(E=this.getRandomSpinner(),B=this.getSpinnerFrames(E),b=0,O=s),s-L>=120){b=(b+1)%B.length,L=s;const t=B[b],e=this.calculateBarSize(t,this.COL_BAR);this.progressBar.options.barsize=e}if(u>=.3){const t=(A-v)/u,e=this.formatSpeed(this.formatSpeedDisplay(t)),o=C>0?this.formatETA((C-A)/t):this.formatETA(0);this.progressBar.update(A,{speed:e,etaFormatted:o,spinner:B[b],progress:this.formatProgress(A,C),downloadedDisplay:this.formatBytesCompact(A),totalDisplay:this.formatTotalDisplay(C)}),S=s,v=A}else this.progressBar.update(A,{spinner:B[b],progress:this.formatProgress(A,C),downloadedDisplay:this.formatBytesCompact(A),totalDisplay:this.formatTotalDisplay(C)});R.push(Buffer.from(e))}}catch(t){R.destroy(t)}})(),await s.pipeline(R,w),this.progressBar.stop(),t.existsSync(o)&&t.unlinkSync(o),t.renameSync(i,o),this.cleanupStateFile(r),console.log(this.colors.success("✅ Download completed!")),console.log(this.colors.primary("📁 File saved to: ")+kt.underline(o)),console.log(this.colors.purple("📊 Total size: ")+this.formatBytes(A)),c&&(console.log(this.colors.info("🔄 Resumed from: ")+this.formatBytes(h)),console.log(this.colors.info("📥 Downloaded this session: ")+this.formatBytes(T)));const M=["🥳","🎊","🎈","🌟","💯","🚀","✨","🔥"],P=M[Math.floor(Math.random()*M.length)];console.log(this.colors.success(`${P} Successfully downloaded! ${P}`))}catch(D){throw this.loadingSpinner&&this.loadingSpinner.isSpinning&&this.loadingSpinner.fail(this.colors.error("❌ Connection failed")),this.progressBar&&this.progressBar.stop(),console.error(this.colors.error.bold("💥 Download failed: ")+this.colors.warning(D.message)),"AbortError"===D.name?console.log(this.colors.info("💾 Download state saved. You can resume later by running the same command.")):console.log(this.colors.info("💾 Partial download saved. Restart to resume from where it left off.")),D}}cleanup(){if(this.loadingSpinner&&this.loadingSpinner.isSpinning&&this.loadingSpinner.stop(),this.progressBar&&this.progressBar.stop(),this.multiBar&&this.multiBar.stop(),this.abortController&&this.abortController.abort(),this.keyboardListener)try{this.keyboardListener.kill()}catch(t){}process.stdin.isTTY&&(process.stdin.setRawMode(!1),process.stdin.pause())}setupGlobalKeyboardListener(){this.setupFallbackKeyboardListener()}async handleGlobalKeyPress(t){"P"===t?(console.log(this.colors.info("P key pressed - toggling pause/resume")),this.isPaused?this.resumeAll():this.pauseAll()):"A"!==t||this.isAddingUrl||(console.log(this.colors.info("A key pressed - adding URL")),await this.promptForNewUrl())}async promptForNewUrl(){this.isAddingUrl=!0;try{console.log(this.colors.cyan("\n📥 Enter URL to add (or press Enter to cancel):"));const u=o.createInterface({input:process.stdin,output:process.stdout}),r=await new Promise(t=>{u.question("",e=>{u.close(),t(e.trim())})});if(r&&this.isValidUrl(r)){console.log(this.colors.success(`✅ Adding URL: ${r}`));const u=this.generateFilename(r),o=e.isAbsolute(u)?u:e.join(process.cwd(),u),i=e.dirname(o);try{t.existsSync(i)||t.mkdirSync(i,{recursive:!0})}catch(s){return void console.error(this.colors.red.bold("❌ Could not create output directory: ")+s.message)}this.multiBar?await this.addToMultipleDownloads(r,o,u):this.downloadFile(r,o).catch(t=>{console.error(this.colors.error(`❌ Failed to download ${u}: ${t.message}`))}),console.log(this.colors.success("🚀 New download started!"))}else r?console.log(this.colors.red("❌ Invalid URL provided.")):console.log(this.colors.yellow("⚠️ No URL provided, cancelling."))}catch(s){console.error(this.colors.red("❌ Error adding URL: ")+s.message)}finally{this.isAddingUrl=!1,this.isPaused?console.log(this.colors.warning("⏸️ Still paused. Press p to resume, a to add URL.")):console.log(this.colors.success("▶️ Downloads active. Press p to pause, a to add URL."))}}async addToMultipleDownloads(t,e,s){const u=this.getRandomSpinner(),o=this.getSpinnerFrames(u),r=this.getSpinnerWidth(o[0]),i=this.COL_FILENAME-r,D=this.truncateFilename(s,i),a=this.getRandomBarColor(),n=this.getRandomBarGlueColor(),l=this.calculateBarSize(o[0],this.COL_BAR),h={url:t,outputPath:e,filename:s},c={bar:this.multiBar.create(100,0,{filename:D,spinner:o[0],speed:this.formatSpeed("0B"),progress:this.formatProgress(0,0),downloadedDisplay:this.formatBytesCompact(0),totalDisplay:this.formatTotalDisplay(0),etaFormatted:this.formatETA(0),percentage:" 0".padStart(3)},{format:this.colors.yellow("{filename}")+" "+this.colors.cyan("{spinner}")+" "+a+"{bar} "+this.colors.success("{percentage}%")+" "+this.colors.info("{downloadedDisplay}")+" "+this.colors.info("{totalDisplay}")+" "+this.colors.purple("{speed}")+" "+this.colors.pink("{etaFormatted}"),barCompleteChar:"█",barIncompleteChar:"░",barGlue:n,barsize:l}),spinnerFrames:o,spinnerIndex:0,lastSpinnerUpdate:Date.now(),lastFrameUpdate:Date.now(),download:{...h,index:this.getCurrentDownloadCount()}};this.downloadSingleFileWithBar(c,this.getMasterBar(),this.getCurrentDownloadCount()+1,{totalDownloaded:0,totalSize:0,individualSpeeds:[],individualSizes:[],individualDownloaded:[],individualStartTimes:[],lastTotalUpdate:Date.now(),lastTotalDownloaded:0,actualTotalSize:0}).catch(t=>{console.error(this.colors.error(`❌ Failed to download ${h.filename}: ${t.message}`))})}getCurrentDownloadCount(){return 1}getMasterBar(){return null}setupFallbackKeyboardListener(){if(process.stdin.isTTY){process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding("utf8");const t=async t=>{""===t&&(console.log(this.colors.yellow.bold("\n🛑 Download cancelled by user")),process.exit(0)),"p"===t.toLowerCase()&&(console.log(this.colors.info("P key pressed - toggling pause/resume")),this.isPaused?this.resumeAll():this.pauseAll()),"a"!==t.toLowerCase()||this.isAddingUrl||(console.log(this.colors.info("A key pressed - adding URL")),await this.promptForNewUrl())};process.stdin.on("data",t)}}setupSingleFileKeyboardListeners(t,e){return this.setupGlobalKeyboardListener(),null}isValidUrl(t){try{return new URL(t),!0}catch{return!1}}getFileExtension(t){try{const s=new URL(t).pathname;return e.extname(s).toLowerCase()}catch{return""}}generateFilename(t){try{return e.basename(new URL(t).pathname)||"downloaded-file"}catch(s){return"downloaded-file"}}setPauseCallback(t){this.pauseCallback=t}setResumeCallback(t){this.resumeCallback=t}setAbortController(t){this.abortControllers.push(t)}clearAbortControllers(){this.abortControllers=[]}pauseAll(){this.isPaused=!0,console.log(this.colors.warning("⏸️ Pausing all downloads...")),this.pauseCallback&&this.pauseCallback()}resumeAll(){this.isPaused=!1,console.log(this.colors.success("▶️ Resuming all downloads...")),this.resumeCallback&&this.resumeCallback()}}if((()=>{try{const t=process.argv[1]?e.resolve(process.argv[1]):"";if(!t)return!1;const s=i.pathToFileURL(t).href;return("undefined"==typeof document?require("url").pathToFileURL(__filename).href:n&&"SCRIPT"===n.tagName.toUpperCase()&&n.src||new URL("download.cjs.js",document.baseURI).href)===s}catch{return!1}})()){const s=(new $t).usage("Usage: grab-url <url...> [options]").command("$0 <url>","Fetch data or download files; pass one or more URLs").option("no-save",{type:"boolean",default:!1,describe:"Don't save output to file, just print to console"}).option("output",{alias:"o",type:"string",describe:"Output filename (default: output.json)",default:null}).option("params",{alias:"p",type:"string",describe:'JSON string of query parameters (e.g., \'{"key":"value"}\')',coerce:t=>{if(!t)return{};try{return JSON.parse(t)}catch(e){throw new Error(`Invalid JSON in params: ${t}`)}}}).help().alias("h","help").example("grab-url https://api.example.com/data","Fetch JSON/text from an API and save to output.json").example("grab-url https://example.com/file1.zip https://example.com/file2.zip","Download multiple files concurrently").example("grab-url https://example.com/file.iso -o ubuntu.iso","Save the first URL to a custom filename").version("1.0.0").strict().parseSync(),u=s.urls||[],o=s.params||{},i=s.output,D=s["no-save"],n=u.some(function(t){return/\.[a-zA-Z0-9]{1,5}(?:\.[a-zA-Z0-9]{1,5})*$/.test(t.split("?")[0])}),l=u.length>1||n;(async()=>{if(l){const o=new _t,r=u.map((t,e)=>{let s=null;return 0===e&&i&&(s=i),{url:t,outputPath:s}}).map((s,u)=>{let r=s.url,i=s.outputPath;i||(i=o.generateFilename(r));const D=e.isAbsolute(i)?i:e.join(process.cwd(),i),a=e.dirname(D);try{t.existsSync(a)||t.mkdirSync(a,{recursive:!0})}catch(n){console.error(kt.red.bold("❌ Could not create output directory: ")+n.message),process.exit(1)}return{url:r,outputPath:D,filename:e.basename(i)}});try{await o.downloadMultipleFiles(r);const e=new Table({head:["Filename","Size","Created"],colWidths:[32,14,25],colAligns:["left","right","left"],style:{"padding-left":1,"padding-right":1,head:[],border:[]}});r.forEach(s=>{try{const u=t.statSync(s.outputPath);e.push([s.filename,o.formatBytes(u.size),u.birthtime.toLocaleString()])}catch(u){e.push([s.filename,"Error","Could not read"])}}),console.log(kt.cyan.bold("\nFile Details:")),console.log(e.toString())}catch(s){console.error(kt.red.bold("Failed to download files: ")+kt.yellow(s.message)),process.exit(1)}o.cleanup()}else{const n=u[0],l=process.hrtime();try{const s=await r.default(n,o);s.error&&a.log(`\n\nStatus: ❌ ${s.error}`);let u,h=null,c=!1;if("string"==typeof s.data)u=s.data,c=!0;else if(Buffer.isBuffer(s.data)||s.data instanceof Uint8Array)u=s.data,c=!1;else if(s.data instanceof Blob){const t=await s.data.arrayBuffer();u=Buffer.from(t),c=!1}else s.data&&"object"==typeof s.data?(u=JSON.stringify(s.data,null,2),c=!0):(u=String(s.data),c=!0);if(D)c?a.log(u):a.log(`Binary data received (${u.length} bytes). Use --output to save to file.`);else{const s=new URL(n).pathname,o=e.extname(s),r=c?".json":o||".bin";h=i?e.resolve(i):e.resolve(process.cwd(),`output${r}`),c?t.writeFileSync(h,u,"utf8"):t.writeFileSync(h,u);const[D,d]=process.hrtime(l),p=(D+d/1e9).toFixed(2),m=(t.statSync(h).size/1048576).toFixed(1);a.log(`⏱️ ${p}s 📦 ${m}MB ✅ Saved to: ${h}`)}}catch(s){a.log(`Error: ${s.message}`,{color:"red"}),process.exit(1)}}})()}exports.ColorFileDownloader=_t;
3
+ //# sourceMappingURL=download.cjs.js.map