grab-url 1.0.15 → 1.0.16

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 (46) hide show
  1. package/dist/download.cjs.js +1 -1
  2. package/dist/download.cjs.js.map +1 -1
  3. package/dist/download.d.ts +0 -0
  4. package/dist/download.es.js +1 -3713
  5. package/dist/download.es.js.map +1 -1
  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 +4 -5
  9. package/dist/grab-api.es.js +1 -353
  10. package/dist/grab-api.es.js.map +1 -1
  11. package/dist/grab-api.umd.js +0 -0
  12. package/dist/grab-api.umd.js.map +227 -1
  13. package/dist/icons.cjs.js +0 -0
  14. package/dist/icons.cjs.js.map +0 -0
  15. package/dist/icons.d.ts +0 -0
  16. package/dist/icons.es.js +1 -113
  17. package/dist/icons.es.js.map +1 -1
  18. package/dist/log.cjs.js +0 -0
  19. package/dist/log.cjs.js.map +0 -0
  20. package/dist/log.d.ts +0 -0
  21. package/dist/log.es.js +1 -298
  22. package/dist/log.es.js.map +1 -1
  23. package/package.json +2 -1
  24. package/readme.md +1 -1
  25. package/src/grab-api.ts +7 -13
  26. package/src/grab-url.js +0 -0
  27. package/src/icons/cli/spinners.js +0 -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-json.ts +0 -0
@@ -1,3 +1,3 @@
1
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;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("fs"),e=require("path"),s=require("stream/promises"),o=require("stream"),r=require("readline"),u=require("url"),i=require("events");var a="undefined"!=typeof document?document.currentScript:null;const n={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 D(t="",e={}){let{color:s,style:o="color:rgb(54, 165, 220); font-size: 10pt;",hideInProduction:r,startSpinner:u=!1,stopSpinner:i=!1}=e;const a=c();void 0===r&&(r="undefined"!=typeof window&&window?.location.hostname.includes("localhost")),"object"==typeof t&&(t=p(t)+"\n\n"+JSON.stringify(t,null,2)),Array.isArray(s)&&1==s.length&&(s=s[0]),s&&void 0!==typeof process&&(t.includes("%c")&&Array.isArray(s)?t=t.replace(/%c/g,(t,e)=>a[s[e]]||""):s&&"string"==typeof s&&(t=(a[s]||"")+t+a.reset));var n=0;return u?(global||globalThis).interval=setInterval(()=>{process.stdout.write((Array.isArray(s)?a[s[0]]:a[s]||"")+"\r"+"⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏".split("")[n=++n%10]+" "+t+a.reset)},50):i?(clearInterval((global||globalThis).interval),process.stdout.write("\r"+(t||" ")+" ".repeat(t.length+20)+"\n")):"string"==typeof o?(1==o.split(" ").length||s?o=`color: ${s||o}; font-size: 11pt;`:o.match(/^#[0-9a-fA-F]{6}$/)&&(o=`color: ${o}; font-size: 11pt;`),r?console.debug((o?"%c":"")+(t||""),o):console.log((o?"%c":"")+(t||""),o)):"object"==typeof o&&console.log(t,...o),!0}const l={reset:[0,"000000"],black:[30,"000000"],red:[31,"ff0000"],green:[32,"00ff00"],yellow:[33,"ffff00"],blue:[34,"0000ff"],magenta:[35,"ff00ff"],cyan:[36,"00ffff"],white:[37,"ffffff"],gray:[90,"808080"],brightRed:[91,"ff5555"],brightGreen:[92,"55ff55"],brightYellow:[93,"ffff55"],brightBlue:[94,"5555ff"],brightMagenta:[95,"ff55ff"],brightCyan:[96,"55ffff"],brightWhite:[97,"ffffff"],bgBlack:[40,"000000"],bgRed:[41,"ff0000"],bgGreen:[42,"00ff00"],bgYellow:[43,"ffff00"],bgBlue:[44,"0000ff"],bgMagenta:[45,"ff00ff"],bgCyan:[46,"00ffff"],bgWhite:[47,"ffffff"],bgGray:[100,"808080"],bgBrightRed:[101,"ff8888"],bgBrightGreen:[102,"88ff88"],bgBrightYellow:[103,"ffff88"],bgBrightBlue:[104,"8888ff"],bgBrightMagenta:[105,"ff88ff"],bgBrightCyan:[106,"88ffff"],bgBrightWhite:[107,"ffffff"]};function c(t="ansi"){const e={};for(const[s,[o,r]]of Object.entries(l))e[s]="html"===t?"#"+r:"["+o+"m";return e}function h(t){const e=c();return"string"==typeof t?e.yellow:"number"==typeof t?e.cyan:"boolean"==typeof t?e.magenta:"function"==typeof t?e.red:null===t?e.gray:Array.isArray(t)?e.blue:"object"==typeof t?e.green:e.white}function d(t){return"string"==typeof t?'""':"number"==typeof t?"number":"boolean"==typeof t?"bool":"function"==typeof t?"function":null===t?"null":Array.isArray(t)?t.length?"["+d(t[0])+"]":"[]":"object"==typeof t?"{...}":typeof t}function p(t,e=0,s="ansi"){const o=c(s),r=" ".repeat(e);var u="";if("object"!=typeof t||null===t){return h(t)+d(t)+o.reset}if(Array.isArray(t)){if(u=o.blue+"["+o.reset,t.length&&(u+="\n"),!t.every(e=>typeof e==typeof t[0]))return t.forEach((s,o)=>{u+=r+" "+p(s,e+1),o<t.length-1&&(u+=","),u+="\n"}),u+=r+o.blue+"]"+o.reset;u+=r+" "+p(t[0],e+1),u+=",",u+="\n"}u=o.green+"{"+o.reset;const i=Object.keys(t);return i.length&&(u+="\n"),i.forEach((s,a)=>{const n=t[s],D=h(n);u+=r+" ","object"!=typeof n||null===n||Array.isArray(n)?Array.isArray(n)?u+=D+s+o.reset+": "+p(n,e+1):u+=D+s+": "+d(n)+o.reset:u+=D+s+o.reset+": "+p(n,e+1),a<i.length-1&&(u+=","),u+="\n"}),u+=r+o.green+"}"+o.reset}async function f(t,e){var{headers:s,response:o={},method:r=(e.post?"POST":e.put?"PUT":e.patch?"PATCH":"GET"),cache:u=!1,cacheForTime:i=60,timeout:a=30,baseURL:n="undefined"!=typeof process&&process.env.SERVER_API_URL||"/api/",cancelOngoingIfNew:l=!1,cancelNewIfOngoing:c=!1,rateLimit:h=0,debug:d=!1,infiniteScroll:C=null,setDefaults:F=!1,retryAttempts:E=0,logger:b=D,onRequest:y=null,onResponse:B=null,onError:w=null,onStream:A=null,repeatEvery:T=null,repeat:S=0,debounce:v=0,regrabOnStale:O=!1,regrabOnFocus:L=!1,regrabOnNetwork:x=!1,post:R=!1,put:P=!1,patch:M=!1,body:k=null,...$}={..."undefined"!=typeof window?window?.grab?.defaults:(global||globalThis)?.grab?.defaults||{},...e};let I=e=>t.startsWith(e);I("http:")||I("https:")?n="":I("/")||n.endsWith("/")?I("/")&&n.endsWith("/")&&(t=t.slice(1)):t="/"+t;try{if(v>0)return await m(async()=>{await f(t,{...e,debounce:0})},1e3*v);if(S>1){for(let s=0;s<S;s++)await f(t,{...e,repeat:0});return o}if(T)return setInterval(async()=>{await f(t,{...e,repeat:0,repeatEvery:null})},1e3*T),o;if(e?.setDefaults)return void("undefined"!=typeof window?window.grab.defaults={...e,setDefaults:void 0}:void 0!==(global||globalThis).grab&&((global||globalThis).grab.defaults={...e,setDefaults:void 0}));if("undefined"!=typeof window){const s=async()=>await f(t,{...e,cache:!1});O&&u&&setTimeout(s,1e3*i),x&&window.addEventListener("online",s),L&&(window.addEventListener("focus",s),document.addEventListener("visibilitychange",async()=>{"visible"===document.visibilityState&&await s()}))}let g="function"==typeof o?o:null;o&&!g||(o={});var[z,_,N]=C||[];if(C?.length&&void 0!==N&&"undefined"!=typeof window){let s="string"==typeof N?document.querySelector(N):N;s?window.scrollListener&&void 0!==s&&"function"==typeof s.removeEventListener&&s.removeEventListener("scroll",window.scrollListener):D("paginateDOM not found",{color:"red"}),window.scrollListener=async s=>{const o=s.target;localStorage.setItem("scroll",JSON.stringify([o.scrollTop,o.scrollLeft,N])),o.scrollHeight-o.scrollTop<=o.clientHeight+200&&await f(t,{...e,cache:!1,[z]:E?.currentPage+1})},s&&s.addEventListener("scroll",window.scrollListener)}let F=JSON.stringify(z?{...$,[z]:void 0}:$),E=f?.log?.find(e=>e.request==F&&e.path==t);if(z){let t=E?.currentPage+1||$?.[z]||1;E||(o[_]=[],t=1),E&&(E.currentPage=t),$={...$,[z]:t}}else{for(let t of Object.keys(o))o[t]=void 0;if(u&&(!i||E?.lastFetchTime>Date.now()-1e3*i)){for(let t of Object.keys(E.res))o[t]=E.res[t];g&&(o=g(o))}}if(g?g({isLoading:!0}):"object"==typeof o&&(o.isLoading=!0),g&&(o=g(o)),h>0&&E?.lastFetchTime&&E.lastFetchTime>Date.now()-1e3*h)throw new Error(`Fetch rate limit exceeded for ${t}. \n Wait ${h}s between requests.`);if(E?.controller)if(l)E.controller.abort();else if(c)return{isLoading:!0};void 0!==f.log&&f.log?.unshift({path:t,request:F,lastFetchTime:Date.now(),controller:new AbortController});let w={method:r,headers:{"Content-Type":"application/json",Accept:"application/json",...s},body:$.body,redirect:"follow",cache:u?"force-cache":"no-store",signal:l?f.log[0]?.controller?.signal:AbortSignal.timeout(1e3*a)},R="";["POST","PUT","PATCH"].includes(r)?w.body=$.body||JSON.stringify($):R=(Object.keys($).length?"?":"")+new URLSearchParams($).toString(),"function"==typeof y&&([t,o,$,w]=y(t,o,$,w));let P=null,M=new Date,k=f.mock?.[t],I=t=>new Promise(e=>setTimeout(e,1e3*t||0));if(!k||k.params&&k.method!=r||k.params&&F!=JSON.stringify(k.params)){if(P=await fetch(n+t+R,w).catch(t=>{throw new Error(t.message)}),!P.ok)throw new Error(`HTTP error: ${P.status} ${P.statusText}`);let e=P.headers.get("content-type");A?await A(P.body):P=await(e?e.includes("application/json")?P&&P.json():e.includes("application/pdf")||e.includes("application/octet-stream")?P.blob():P.text():P.json()).catch(t=>{throw new Error("Error parsing response: "+t)})}else await I(k.delay),P="function"==typeof k.response?k.response($):k.response;"function"==typeof B&&([t,o,$,w]=B(t,o,$,w)),g?g({isLoading:void 0}):"object"==typeof o&&delete o?.isLoading,delete E?.controller;const j=((Number(new Date)-Number(M))/1e3).toFixed(1);if(d&&b("Path:"+n+t+R+"\n"+JSON.stringify(e,null,2)+"\nTime: "+j+"s\nResponse: "+p(P)),"object"==typeof P){for(let t of Object.keys(P))o[t]=_==t&&o[t]?.length?[...o[t],...P[t]]:P[t];void 0!==o&&(o.data=P)}else g?g({data:P,...P}):"object"==typeof o&&(o.data=P);return void 0!==f.log&&f.log?.unshift({path:t,request:JSON.stringify({...$,paginateKey:void 0}),response:o,lastFetchTime:Date.now()}),g&&(o=g(o)),o}catch(j){let s="Error: "+j.message+"\nPath:"+n+t+"\n";return"function"==typeof w&&w(j.message,n+t,$),e.retryAttempts>0?await f(t,{...e,retryAttempts:--e.retryAttempts}):(!j.message.includes("signal")&&e.debug&&(b(s,{color:"red"}),d&&"undefined"!=typeof document&&g(s)),o.error=j.message,"function"==typeof o?(o.data=o({isLoading:void 0,error:j.message}),o=o.data):delete o?.isLoading,void 0!==f.log&&f.log?.unshift({path:t,request:JSON.stringify($),error:j.message}),o)}}f.instance=(t={})=>(e,s={})=>f(e,{...t,...s});const m=async(t,e)=>{let s;return async function(...o){clearTimeout(s),s=setTimeout(async()=>{clearTimeout(s),await t(...o)},e)}};function g(t){if("undefined"==typeof document)return;let e,s=document.getElementById("alert-overlay");s||(s=document.body.appendChild(document.createElement("div")),s.id="alert-overlay",s.setAttribute("style","position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,0.5);display:flex;align-items:center;justify-content:center"),s.innerHTML='<div id="alert-box" style="background:#fff;padding:1.5em 2em;border-radius:8px;box-shadow:0 2px 16px #0003;min-width:220px;max-height:80vh;position:relative;display:flex;flex-direction:column;">\n <button id="close-alert" style="position:absolute;top:12px;right:20px;font-size:1.5em;background:none;border:none;cursor:pointer;color:black;">&times;</button>\n <div id="alert-list" style="overflow:auto;flex:1;"></div>\n </div>',s.addEventListener("click",t=>t.target==s&&s.remove()),document.getElementById("close-alert").onclick=()=>s.remove()),e=s.querySelector("#alert-list"),e.innerHTML+=`<div style="border-bottom:1px solid #333; font-size:1.2em;margin:0.5em 0;">${t}</div>`}function C(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var F,E,b,y;function B(){if(y)return b;y=1;const t=r;return b=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)}}}"undefined"!=typeof window?(window.log=D,window.grab=f,window.grab.log=[],window.grab.mock={},window.grab.defaults={},document.addEventListener("keydown",t=>{if("i"===t.key&&t.ctrlKey&&t.altKey){let t=" ";for(let e of f.log)t+=`<div style="margin-bottom:1em; border-bottom:1px solid #ccc; padding-bottom:1em;">\n <b>Path:</b> ${e.path}<br>\n <b>Request:</b> ${p(e.request,0,"html")}<br>\n <b>Response:</b> ${p(e.response,0,"html")}<br> \n <b>Time:</b> ${new Date(e.lastFetchTime).toLocaleString()}\n </div>`;g(t)}}),document.addEventListener("DOMContentLoaded",()=>{let[t,e,s]=JSON.parse(localStorage.getItem("scroll"))||[];t&&(document.querySelector(s).scrollTop=t,document.querySelector(s).scrollLeft=e)})):"undefined"!=typeof global?(f.log=[],f.mock={},f.defaults={},global.log=D,global.grab=f.instance()):"undefined"!=typeof globalThis&&(f.log=[],f.mock={},f.defaults={},globalThis.log=D,globalThis.grab=f.instance());var w,A,T,S,v={exports:{}};function O(){if(S)return T;S=1;const t=A?w:(A=1,w=({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 T=e=>"string"==typeof e?e.replace(t(),""):e}var L,x,R,P,M,k,$,I,z,_,N,j,U,G,W,Y,q,H,J,V,K,Z,Q,X,tt,et,st,ot,rt,ut,it,at,nt={exports:{}};function Dt(){if(P)return v.exports;P=1;const t=O(),e=function(){if(L)return nt.exports;L=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 nt.exports=t,nt.exports.default=t,nt.exports}(),s=R?x:(R=1,x=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}),o=o=>{if("string"!=typeof o||0===o.length)return 0;if(0===(o=t(o)).length)return 0;o=o.replace(s()," ");let r=0;for(let t=0;t<o.length;t++){const s=o.codePointAt(t);s<=31||s>=127&&s<=159||(s>=768&&s<=879||(s>65535&&t++,r+=e(s)?2:1))}return r};return v.exports=o,v.exports.default=o,v.exports}function lt(){return k?M:(k=1,M=function(t,e,s){if(!0!==e.autopadding)return t;return"percentage"===s?(o=t,(e.autopaddingChar+o).slice(-3)):t;var o})}function ct(){return I?$:(I=1,$=function(t,e){const s=Math.round(t*e.barsize),o=e.barsize-s;return e.barCompleteString.substr(0,s)+e.barGlue+e.barIncompleteString.substr(0,o)})}function ht(){return _?z:(_=1,z=function(t,e,s){function o(t){return s?s*Math.round(t/s):t}function r(t){return(e.autopaddingChar+t).slice(-2)}return t>3600?r(Math.floor(t/3600))+"h"+r(o(t%3600/60))+"m":t>60?r(Math.floor(t/60))+"m"+r(o(t%60))+"s":t>10?r(o(t))+"s":r(t)+"s"})}function dt(){if(j)return N;j=1;const t=Dt(),e=lt(),s=ct(),o=ht();return N=function(r,u,i){let a=r.format;const n=r.formatTime||o,D=r.formatValue||e,l=r.formatBar||s,c=Math.floor(100*u.progress)+"",h=u.stopTime||Date.now(),d=Math.round((h-u.startTime)/1e3),p=Object.assign({},i,{bar:l(u.progress,r),percentage:D(c,r,"percentage"),total:D(u.total,r,"total"),value:D(u.value,r,"value"),eta:D(u.eta,r,"eta"),eta_formatted:n(u.eta,r,5),duration:D(d,r,"duration"),duration_formatted:n(d,r,1)});a=a.replace(/\{(\w+)\}/g,function(t,e){return void 0!==p[e]?p[e]:t});const f=Math.max(0,u.maxWidth-t(a)-2),m=Math.floor(f/2);switch(r.align){case"right":a=f>0?" ".repeat(f)+a:a;break;case"center":a=m>0?" ".repeat(m)+a:a}return a}}function pt(){if(G)return U;function t(t,e){return null==t?e:t}return G=1,U={parse:function(e,s){const o={},r=Object.assign({},s,e);return o.throttleTime=1e3/t(r.fps,10),o.stream=t(r.stream,process.stderr),o.terminal=t(r.terminal,null),o.clearOnComplete=t(r.clearOnComplete,!1),o.stopOnComplete=t(r.stopOnComplete,!1),o.barsize=t(r.barsize,40),o.align=t(r.align,"left"),o.hideCursor=t(r.hideCursor,!1),o.linewrap=t(r.linewrap,!1),o.barGlue=t(r.barGlue,""),o.barCompleteChar=t(r.barCompleteChar,"="),o.barIncompleteChar=t(r.barIncompleteChar,"-"),o.format=t(r.format,"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}"),o.formatTime=t(r.formatTime,null),o.formatValue=t(r.formatValue,null),o.formatBar=t(r.formatBar,null),o.etaBufferLength=t(r.etaBuffer,10),o.etaAsynchronousUpdate=t(r.etaAsynchronousUpdate,!1),o.progressCalculationRelative=t(r.progressCalculationRelative,!1),o.synchronousUpdate=t(r.synchronousUpdate,!0),o.noTTYOutput=t(r.noTTYOutput,!1),o.notTTYSchedule=t(r.notTTYSchedule,2e3),o.emptyOnZero=t(r.emptyOnZero,!1),o.forceRedraw=t(r.forceRedraw,!1),o.autopadding=t(r.autopadding,!1),o.gracefulExit=t(r.gracefulExit,!1),o},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 ft(){if(Y)return W;Y=1;const t=E?F:(E=1,F=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),o=(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 r=Math.ceil(t/o/1e3);isNaN(r)?this.eta="NULL":isFinite(r)?this.eta=r>1e7?"INF":r<0?0:r:this.eta="INF"}}),e=B(),s=dt(),o=pt(),r=i;return W=class extends r{constructor(r){super(),this.options=o.assignDerivedOptions(r),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,o){this.value=s||0,this.total=void 0!==e&&e>=0?e:100,this.startValue=s||0,this.payload=o||{},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 o in s)this.payload[o]=s[o];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 mt(){if(ut)return rt;ut=1;const t=Z?K:(Z=1,K={format:"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"=",barIncompleteChar:"-"}),e=X?Q:(X=1,Q={format:" {bar} {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"█",barIncompleteChar:"░"}),s=et?tt:(et=1,tt={format:" {bar} {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"█",barIncompleteChar:"░"}),o=ot?st:(ot=1,st={format:" {bar}■ {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"■",barIncompleteChar:" "});return rt={legacy:t,shades_classic:e,shades_grey:s,rect:o}}const gt=C(function(){if(at)return it;at=1;const t=function(){if(H)return q;H=1;const t=ft(),e=pt();return q=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(V)return J;V=1;const t=B(),e=ft(),s=pt(),o=i;return J=class extends o{constructor(e,o){super(),this.bars=[],this.options=s.parse(e,o),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,o,r={}){const u=new e(Object.assign({},this.options,{terminal:this.terminal},r));return this.bars.push(u),!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,u.start(t,s,o),this.emit("start")),u}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=mt(),o=dt(),r=lt(),u=ct(),a=ht();return it={Bar:t,SingleBar:t,MultiBar:e,Presets:s,Format:{Formatter:o,BarFormat:u,ValueFormat:r,TimeFormat:a}}}()),Ct=(t=0)=>e=>`[${e+t}m`,Ft=(t=0)=>e=>`[${38+t};5;${e}m`,Et=(t=0)=>(e,s,o)=>`[${38+t};2;${e};${s};${o}m`,bt={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(bt.modifier);Object.keys(bt.color),Object.keys(bt.bgColor);const yt=function(){const t=new Map;for(const[e,s]of Object.entries(bt)){for(const[e,o]of Object.entries(s))bt[e]={open:`[${o[0]}m`,close:`[${o[1]}m`},s[e]=bt[e],t.set(o[0],o[1]);Object.defineProperty(bt,e,{value:s,enumerable:!1})}return Object.defineProperty(bt,"codes",{value:t,enumerable:!1}),bt.color.close="",bt.bgColor.close="",bt.color.ansi=Ct(),bt.color.ansi256=Ft(),bt.color.ansi16m=Et(),bt.bgColor.ansi=Ct(10),bt.bgColor.ansi256=Ft(10),bt.bgColor.ansi16m=Et(10),Object.defineProperties(bt,{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 o=Number.parseInt(s,16);return[o>>16&255,o>>8&255,255&o]},enumerable:!1},hexToAnsi256:{value:t=>bt.rgbToAnsi256(...bt.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return t-8+90;let e,s,o;if(t>=232)e=(10*(t-232)+8)/255,s=e,o=e;else{const r=(t-=16)%36;e=Math.floor(t/36)/5,s=Math.floor(r/6)/5,o=r%6/5}const r=2*Math.max(e,s,o);if(0===r)return 30;let u=30+(Math.round(o)<<2|Math.round(s)<<1|Math.round(e));return 2===r&&(u+=60),u},enumerable:!1},rgbToAnsi:{value:(t,e,s)=>bt.ansi256ToAnsi(bt.rgbToAnsi256(t,e,s)),enumerable:!1},hexToAnsi:{value:t=>bt.ansi256ToAnsi(bt.hexToAnsi256(t)),enumerable:!1}}),bt}(),Bt=(()=>{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})(),wt=0!==Bt&&{level:Bt},At={stdout:wt,stderr:wt};function Tt(t,e,s){let o=t.indexOf(e);if(-1===o)return t;const r=e.length;let u=0,i="";do{i+=t.slice(u,o)+e+s,u=o+r,o=t.indexOf(e,u)}while(-1!==o);return i+=t.slice(u),i}const{stdout:St,stderr:vt}=At,Ot=Symbol("GENERATOR"),Lt=Symbol("STYLER"),xt=Symbol("IS_EMPTY"),Rt=["ansi","ansi","ansi256","ansi16m"],Pt=Object.create(null),Mt=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=St?St.level:0;t.level=void 0===e.level?s:e.level})(e,t),Object.setPrototypeOf(e,kt.prototype),e};function kt(t){return Mt(t)}Object.setPrototypeOf(kt.prototype,Function.prototype);for(const[Yt,qt]of Object.entries(yt))Pt[Yt]={get(){const t=Nt(this,_t(qt.open,qt.close,this[Lt]),this[xt]);return Object.defineProperty(this,Yt,{value:t}),t}};Pt.visible={get(){const t=Nt(this,this[Lt],!0);return Object.defineProperty(this,"visible",{value:t}),t}};const $t=(t,e,s,...o)=>"rgb"===t?"ansi16m"===e?yt[s].ansi16m(...o):"ansi256"===e?yt[s].ansi256(yt.rgbToAnsi256(...o)):yt[s].ansi(yt.rgbToAnsi(...o)):"hex"===t?$t("rgb",e,s,...yt.hexToRgb(...o)):yt[s][t](...o),It=["rgb","hex","ansi256"];for(const Yt of It){Pt[Yt]={get(){const{level:t}=this;return function(...e){const s=_t($t(Yt,Rt[t],"color",...e),yt.color.close,this[Lt]);return Nt(this,s,this[xt])}}};Pt["bg"+Yt[0].toUpperCase()+Yt.slice(1)]={get(){const{level:t}=this;return function(...e){const s=_t($t(Yt,Rt[t],"bgColor",...e),yt.bgColor.close,this[Lt]);return Nt(this,s,this[xt])}}}}const zt=Object.defineProperties(()=>{},{...Pt,level:{enumerable:!0,get(){return this[Ot].level},set(t){this[Ot].level=t}}}),_t=(t,e,s)=>{let o,r;return void 0===s?(o=t,r=e):(o=s.openAll+t,r=e+s.closeAll),{open:t,close:e,openAll:o,closeAll:r,parent:s}},Nt=(t,e,s)=>{const o=(...t)=>jt(o,1===t.length?""+t[0]:t.join(" "));return Object.setPrototypeOf(o,zt),o[Ot]=t,o[Lt]=e,o[xt]=s,o},jt=(t,e)=>{if(t.level<=0||!e)return t[xt]?"":e;let s=t[Lt];if(void 0===s)return e;const{openAll:o,closeAll:r}=s;if(e.includes(""))for(;void 0!==s;)e=Tt(e,s.close,s.open),s=s.parent;const u=e.indexOf("\n");return-1!==u&&(e=function(t,e,s,o){let r=0,u="";do{const i="\r"===t[o-1];u+=t.slice(r,i?o-1:o)+e+(i?"\r\n":"\n")+s,r=o+1,o=t.indexOf("\n",r)}while(-1!==o);return u+=t.slice(r),u}(e,r,o,u)),o+e+r};Object.defineProperties(kt.prototype,Pt);const Ut=kt();kt({level:vt?vt.level:0}),e.dirname(u.fileURLToPath("undefined"==typeof document?require("url").pathToFileURL(__filename).href:a&&"SCRIPT"===a.tagName.toUpperCase()&&a.src||new URL("download.cjs.js",document.baseURI).href));class Gt{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 o=t.match(/\$0 <(\w+)>/);return o&&(this.commands[o[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 o=0;o<t.length;o++){const r=t[o];if(r.startsWith("--")){const[s,u]=r.split("="),i=s.slice(2);if(void 0!==u)e[i]=this.coerceValue(i,u);else if("boolean"===this.options[i]?.type)e[i]=!0;else{const s=t[o+1];s&&!s.startsWith("-")?(e[i]=this.coerceValue(i,s),o++):e[i]=!0}}else if(r.startsWith("-")&&2===r.length){const s=r[1],u=this.findLongName(s);if(u)if("boolean"===this.options[u]?.type)e[u]=!0;else{const s=t[o+1];s&&!s.startsWith("-")&&(e[u]=this.coerceValue(u,s),o++)}}else s.push(r)}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 Wt{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:Ut.cyan,success:Ut.green,warning:Ut.yellow,error:Ut.red,info:Ut.blue,purple:Ut.magenta,pink:Ut.magentaBright,yellow:Ut.yellowBright,cyan:Ut.cyanBright,green:Ut.green,gradient:[Ut.blue,Ut.magenta,Ut.cyan,Ut.green,Ut.yellow,Ut.red]},this.barColors=["","","","","","","","","","",""],this.barGlueColors=["","","","","","",""],this.spinnerTypes=Object.keys(n.default||n),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=n.default||n,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"),o=e.headers.get("content-length"),r=e.headers.get("last-modified"),u=e.headers.get("etag");return{supportsResume:"bytes"===s,totalSize:o?parseInt(o,10):0,lastModified:r,etag:u,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(o){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,o=[{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}],r=Math.floor(Math.log(t)/Math.log(1024)),u=parseFloat((t/Math.pow(1024,r)).toFixed(s)),i=o[r]||o[o.length-1];return i.color.bold(`${u} ${i.unit}`)}formatBytesPlain(t,e=1){if(0===t)return"0 B";const s=e<0?0:e,o=["B","KB","MB","GB","TB","PB"],r=Math.floor(Math.log(t)/Math.log(1024));return`${parseFloat((t/Math.pow(1024,r)).toFixed(s))} ${o[r]||o[o.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 o=e.extname(t),r=e.basename(t,o);if(r.length<=3)return t.padEnd(s);const u=Math.ceil((s-o.length-3)/2),i=Math.floor((s-o.length-3)/2);return`${r.substring(0,u)+"..."+r.substring(r.length-i)}${o}`.padEnd(s)}formatETA(t){if(!t||t===1/0||t<0)return" -- ";const e=Math.floor(t/3600),s=Math.floor(t%3600/60),o=Math.round(t%60);return`${e}:${s.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`.padEnd(this.COL_ETA)}formatMasterProgress(t,e){const s=1024,o=t/(s*s);if(e/(s*s)>=1024){return`${(o/1024).toFixed(1)}GB`.padEnd(this.COL_DOWNLOADED)}return`${o.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 gt.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 o=0,r=0,u=new Array(t.length).fill(0),i=new Array(t.length).fill(0),a=new Array(t.length).fill(0),n=new Array(t.length).fill(Date.now()),D=Date.now(),l=new Array(t.length).fill(0),c=Date.now(),h=0;const d=t.reduce((t,e)=>t+(e.estimatedSize||104857600),0);r=d;let p=0;const f=setInterval(()=>{const e=Date.now(),s=(e-D)/1e3;for(let r=0;r<t.length;r++)if(s>0){const t=a[r]-l[r];if(u[r]=t/s,E[r]&&E[r].bar){const t=this.formatSpeed(this.formatSpeedDisplay(u[r])),e=i[r]>0?this.formatETA((i[r]-a[r])/u[r]):this.formatETA(0);E[r].bar.update(a[r],{speed:t,progress:this.formatProgress(a[r],i[r]),downloadedDisplay:this.formatBytesCompact(a[r]),totalDisplay:this.formatTotalDisplay(i[r]),etaFormatted:e})}}D=e,l=[...a];const o=u.reduce((t,e)=>t+e,0),c=a.reduce((t,e)=>t+e,0),h=(e-n[0])/1e3,d=(r>0&&o>0?this.formatETA((r-c)/o):this.formatETA(0),r>0&&Math.round(c/r*100),i.reduce((t,e)=>t+e,0)),p=d>0?d:r;F.update(c,{speed:this.formatTotalSpeed(o),progress:this.formatMasterProgress(c,p),downloadedDisplay:this.formatBytesCompact(c),totalDisplay:this.formatTotalDisplay(p),etaFormatted:this.formatETA(h),percentage:p>0?Math.round(c/p*100):0})},1e3),m=this.getSpinnerWidth("⬇️"),g=this.COL_FILENAME-m,C=this.calculateBarSize("⬇️",this.COL_BAR),F=this.multiBar.create(r,0,{filename:"Total".padEnd(g),spinner:"⬇️",speed:"0B".padEnd(this.COL_SPEED),progress:this.formatMasterProgress(0,r),downloadedDisplay:this.formatBytesCompact(0),totalDisplay:this.formatTotalDisplay(r),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:C}),E=t.map((t,e)=>{const s=this.getRandomSpinner(),o=this.getSpinnerFrames(s),r=this.getSpinnerWidth(o[0]),u=this.COL_FILENAME-r,i=this.truncateFilename(t.filename,u),a=this.getRandomBarColor(),n=this.getRandomBarGlueColor(),D=this.calculateBarSize(o[0],this.COL_BAR);return{bar:this.multiBar.create(100,0,{filename:i,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:D}),spinnerFrames:o,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:o,totalSize:r,individualSpeeds:u,individualSizes:i,individualDownloaded:a,individualStartTimes:n,lastTotalUpdate:c,lastTotalDownloaded:h,actualTotalSize:p}),{success:!0,index:s,filename:e.download.filename}}catch(D){return{success:!1,index:s,filename:e.download.filename,error:D}}}),y=await Promise.allSettled(b);clearInterval(f),this.multiBar.stop();const B=y.filter(t=>"fulfilled"===t.status&&t.value.success).length,w=y.length-B;w>0&&(console.log(this.colors.error(`❌ Failed: ${w}/${t.length}`)),y.forEach((e,s)=>{if("rejected"===e.status||!e.value.success){const o=t[s].filename,r=e.reason||e.value?.error||"Unknown error";console.log(this.colors.error(` • ${o}: ${r.message||r}`))}}));const A=["🥳","🎊","🎈","🌟","💯","🚀","✨","🔥"],T=A[Math.floor(Math.random()*A.length)];console.log(this.colors.green(`${T} Success: ${B}/${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,r,u,i){const{bar:a,spinnerFrames:n,download:D}=e,{url:l,outputPath:c,filename:h}=D,d=this.getStateFilePath(c),p=c+".tmp";try{const u=new AbortController;this.setAbortController(u);const D=await this.checkServerSupport(l),h=this.loadDownloadState(d),f=this.getPartialFileSize(p);let m=0,g=!1;if(D.supportsResume&&f>0&&h){!(D.lastModified&&D.lastModified!==h.lastModified||D.etag&&D.etag!==h.etag||D.totalSize!==h.totalSize)&&f<D.totalSize?(m=f,g=!0):(t.existsSync(p)&&t.unlinkSync(p),this.cleanupStateFile(d))}else f>0&&t.existsSync(p)&&t.unlinkSync(p);const C={};g&&m>0&&(C.Range=`bytes=${m}-`);const F=await fetch(l,{headers:C,signal:u.signal});if(!F.ok)throw new Error(`HTTP error! status: ${F.status}`);const E=F.headers.get("content-length"),b=g?D.totalSize:E?parseInt(E,10):0,y={url:l,outputPath:c,totalSize:b,startByte:m,lastModified:D.lastModified,etag:D.etag,timestamp:(new Date).toISOString()};this.saveDownloadState(d,y),a.setTotal(b||100),a.update(m,{progress:this.formatProgress(m,b),downloadedDisplay:this.formatBytesCompact(m),totalDisplay:this.formatTotalDisplay(b)});const B=t.createWriteStream(p,{flags:g?"a":"w"});let w=m,A=Date.now(),T=w;const S=new o.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 o=Date.now(),u=(o-A)/1e3;if(o-e.lastFrameUpdate>=150){e.spinnerIndex=(e.spinnerIndex+1)%n.length,e.lastFrameUpdate=o;const t=n[e.spinnerIndex],s=this.calculateBarSize(t,this.COL_BAR);a.options.barsize=s}if(o-e.lastSpinnerUpdate>=45e3){const t=this.getRandomSpinner();e.spinnerFrames=this.getSpinnerFrames(t),e.spinnerIndex=0,e.lastSpinnerUpdate=o}if(u>=.3){if(a.update(w,{spinner:n[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&&r.setTotal(i.totalSize)}A=o,T=w}else a.update(w,{spinner:n[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,B),t.existsSync(c)&&t.unlinkSync(c),t.renameSync(p,c),this.cleanupStateFile(d);r.value;const O=i.actualTotalSize||i.totalSize,L=i.individualSizes.reduce((t,e)=>t+e,0),x=L>0?L:O;r.update(i.totalDownloaded,{progress:this.formatMasterProgress(i.totalDownloaded,x),downloadedDisplay:this.formatBytesCompact(i.totalDownloaded),totalDisplay:this.formatTotalDisplay(x),etaFormatted:this.formatETA((Date.now()-(i.individualStartTimes?.[0]||Date.now()))/1e3)})}catch(f){throw a.update(a.total,{spinner:"❌",speed:this.formatSpeed("FAILED"),downloadedDisplay:this.formatBytesCompact(0),totalDisplay:this.formatTotalDisplay(0)}),console.log(this.colors.info(`💾 Partial download saved for ${h}. Restart to resume.`)),f}}async downloadFile(e,r){const u=this.getStateFilePath(r),i=r+".tmp";try{this.abortController=new AbortController;const a=this.getRandomOraSpinner();this.loadingSpinner=ora({text:this.colors.primary("🌐 Checking server capabilities..."),spinner:a,color:"cyan"}).start();const n=await this.checkServerSupport(e),D=this.loadDownloadState(u),l=this.getPartialFileSize(i);let c=0,h=!1;if(n.supportsResume&&l>0&&D){!(n.lastModified&&n.lastModified!==D.lastModified||n.etag&&n.etag!==D.etag||n.totalSize!==D.totalSize)&&l<n.totalSize?(c=l,h=!0,this.loadingSpinner.succeed(this.colors.success(`✅ Found partial download: ${this.formatBytes(l)} of ${this.formatTotal(n.totalSize)}`)),console.log(this.colors.info(`🔄 Resuming download from ${this.formatBytes(c)}`))):(this.loadingSpinner.warn(this.colors.warning("⚠️ File changed on server, starting fresh download")),t.existsSync(i)&&t.unlinkSync(i),this.cleanupStateFile(u))}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={};h&&c>0&&(d.Range=`bytes=${c}-`);const p=await fetch(e,{headers:d,signal:this.abortController.signal});if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);const f=p.headers.get("content-length"),m=h?n.totalSize:f?parseInt(f,10):0;f&&parseInt(f,10);h||(0===m?console.log(this.colors.warning("⚠️ Warning: Content-Length not provided, progress will be estimated")):console.log(this.colors.info(`📦 File size: ${this.formatTotal(m)}`)));const g={url:e,outputPath:r,totalSize:m,startByte:c,lastModified:n.lastModified,etag:n.etag,timestamp:(new Date).toISOString()};this.saveDownloadState(u,g);const C=this.getRandomBarColor(),F=this.getRandomBarGlueColor();let E=this.getRandomSpinner(),b=this.getSpinnerFrames(E),y=0;const B=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,r);this.progressBar=new gt.SingleBar({format:this.colors.success("{percentage}%")+" "+this.colors.cyan("{spinner}")+" "+C+"{bar} "+this.colors.info("{downloadedDisplay}")+" "+this.colors.info("{totalDisplay}")+" "+this.colors.purple("{speed}")+" "+this.colors.pink("{etaFormatted}"),barCompleteChar:"█",barIncompleteChar:"░",barGlue:F,hideCursor:!0,barsize:B,stopOnComplete:!0,clearOnComplete:!1}),this.progressBar.start(m||100,c,{speed:this.formatSpeed("0B/s"),etaFormatted:this.formatETA(0),spinner:b[0],progress:this.formatProgress(c,m),downloadedDisplay:this.formatBytesCompact(c),totalDisplay:this.formatTotalDisplay(m)});const w=t.createWriteStream(i,{flags:h?"a":"w"});let A=c,T=0,S=Date.now(),v=A,O=Date.now(),L=Date.now();const x=new o.Readable({read(){}}),R=p.body.getReader();(async()=>{try{for(;;){for(;this.isPaused;)await new Promise(t=>setTimeout(t,100));const{done:t,value:e}=await R.read();if(t){x.push(null);break}T+=e.length,A+=e.length;const s=Date.now(),o=(s-S)/1e3;if(s-O>=45e3&&(E=this.getRandomSpinner(),b=this.getSpinnerFrames(E),y=0,O=s),s-L>=120){y=(y+1)%b.length,L=s;const t=b[y],e=this.calculateBarSize(t,this.COL_BAR);this.progressBar.options.barsize=e}if(o>=.3){const t=(A-v)/o,e=this.formatSpeed(this.formatSpeedDisplay(t)),r=m>0?this.formatETA((m-A)/t):this.formatETA(0);this.progressBar.update(A,{speed:e,etaFormatted:r,spinner:b[y],progress:this.formatProgress(A,m),downloadedDisplay:this.formatBytesCompact(A),totalDisplay:this.formatTotalDisplay(m)}),S=s,v=A}else this.progressBar.update(A,{spinner:b[y],progress:this.formatProgress(A,m),downloadedDisplay:this.formatBytesCompact(A),totalDisplay:this.formatTotalDisplay(m)});x.push(Buffer.from(e))}}catch(t){x.destroy(t)}})(),await s.pipeline(x,w),this.progressBar.stop(),t.existsSync(r)&&t.unlinkSync(r),t.renameSync(i,r),this.cleanupStateFile(u),console.log(this.colors.success("✅ Download completed!")),console.log(this.colors.primary("📁 File saved to: ")+Ut.underline(r)),console.log(this.colors.purple("📊 Total size: ")+this.formatBytes(A)),h&&(console.log(this.colors.info("🔄 Resumed from: ")+this.formatBytes(c)),console.log(this.colors.info("📥 Downloaded this session: ")+this.formatBytes(T)));const P=["🥳","🎊","🎈","🌟","💯","🚀","✨","🔥"],M=P[Math.floor(Math.random()*P.length)];console.log(this.colors.success(`${M} Successfully downloaded! ${M}`))}catch(a){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(a.message)),"AbortError"===a.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.")),a}}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 o=r.createInterface({input:process.stdin,output:process.stdout}),u=await new Promise(t=>{o.question("",e=>{o.close(),t(e.trim())})});if(u&&this.isValidUrl(u)){console.log(this.colors.success(`✅ Adding URL: ${u}`));const o=this.generateFilename(u),r=e.isAbsolute(o)?o:e.join(process.cwd(),o),i=e.dirname(r);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(u,r,o):this.downloadFile(u,r).catch(t=>{console.error(this.colors.error(`❌ Failed to download ${o}: ${t.message}`))}),console.log(this.colors.success("🚀 New download started!"))}else u?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 o=this.getRandomSpinner(),r=this.getSpinnerFrames(o),u=this.getSpinnerWidth(r[0]),i=this.COL_FILENAME-u,a=this.truncateFilename(s,i),n=this.getRandomBarColor(),D=this.getRandomBarGlueColor(),l=this.calculateBarSize(r[0],this.COL_BAR),c={url:t,outputPath:e,filename:s},h={bar:this.multiBar.create(100,0,{filename:a,spinner:r[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}")+" "+n+"{bar} "+this.colors.success("{percentage}%")+" "+this.colors.info("{downloadedDisplay}")+" "+this.colors.info("{totalDisplay}")+" "+this.colors.purple("{speed}")+" "+this.colors.pink("{etaFormatted}"),barCompleteChar:"█",barIncompleteChar:"░",barGlue:D,barsize:l}),spinnerFrames:r,spinnerIndex:0,lastSpinnerUpdate:Date.now(),lastFrameUpdate:Date.now(),download:{...c,index:this.getCurrentDownloadCount()}};this.downloadSingleFileWithBar(h,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 ${c.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=u.pathToFileURL(t).href;return("undefined"==typeof document?require("url").pathToFileURL(__filename).href:a&&"SCRIPT"===a.tagName.toUpperCase()&&a.src||new URL("download.cjs.js",document.baseURI).href)===s}catch{return!1}})()){const s=(new Gt).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(),o=s.urls||[],r=s.params||{},u=s.output,i=s["no-save"],a=o.some(function(t){return/\.[a-zA-Z0-9]{1,5}(?:\.[a-zA-Z0-9]{1,5})*$/.test(t.split("?")[0])}),n=o.length>1||a;(async()=>{if(n){const r=new Wt,i=o.map((t,e)=>{let s=null;return 0===e&&u&&(s=u),{url:t,outputPath:s}}).map((s,o)=>{let u=s.url,i=s.outputPath;i||(i=r.generateFilename(u));const a=e.isAbsolute(i)?i:e.join(process.cwd(),i),n=e.dirname(a);try{t.existsSync(n)||t.mkdirSync(n,{recursive:!0})}catch(D){console.error(Ut.red.bold("❌ Could not create output directory: ")+D.message),process.exit(1)}return{url:u,outputPath:a,filename:e.basename(i)}});try{await r.downloadMultipleFiles(i);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:[]}});i.forEach(s=>{try{const o=t.statSync(s.outputPath);e.push([s.filename,r.formatBytes(o.size),o.birthtime.toLocaleString()])}catch(o){e.push([s.filename,"Error","Could not read"])}}),console.log(Ut.cyan.bold("\nFile Details:")),console.log(e.toString())}catch(s){console.error(Ut.red.bold("Failed to download files: ")+Ut.yellow(s.message)),process.exit(1)}r.cleanup()}else{const a=o[0],n=process.hrtime();try{const s=await f(a,r);s.error&&D(`\n\nStatus: ❌ ${s.error}`);let o,l=null,c=!1;if("string"==typeof s.data)o=s.data,c=!0;else if(Buffer.isBuffer(s.data)||s.data instanceof Uint8Array)o=s.data,c=!1;else if(s.data instanceof Blob){const t=await s.data.arrayBuffer();o=Buffer.from(t),c=!1}else s.data&&"object"==typeof s.data?(o=JSON.stringify(s.data,null,2),c=!0):(o=String(s.data),c=!0);if(i)D(c?o:`Binary data received (${o.length} bytes). Use --output to save to file.`);else{const s=new URL(a).pathname,r=e.extname(s),i=c?".json":r||".bin";l=u?e.resolve(u):e.resolve(process.cwd(),`output${i}`),c?t.writeFileSync(l,o,"utf8"):t.writeFileSync(l,o);const[h,d]=process.hrtime(n),p=(h+d/1e9).toFixed(2),f=t.statSync(l);D(`⏱️ ${p}s 📦 ${(f.size/1048576).toFixed(1)}MB ✅ Saved to: ${l}`)}}catch(s){D(`Error: ${s.message}`,{color:"red"}),process.exit(1)}}})()}exports.ColorFileDownloader=Wt;
3
3
  //# sourceMappingURL=download.cjs.js.map