mmx-cli 1.0.5 → 1.0.6

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 (3) hide show
  1. package/README.md +10 -6
  2. package/dist/mmx.mjs +173 -172
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,4 @@
1
- <p align="center">
2
- <img src="https://file.cdn.minimax.io/public/MMX.png" alt="MiniMax" width="320" />
3
- </p>
1
+ <img src="https://file.cdn.minimax.io/public/MMX.png" alt="MiniMax" width="100%" />
4
2
 
5
3
  <p align="center">
6
4
  <strong>The official CLI for the MiniMax AI Platform</strong><br>
@@ -23,7 +21,7 @@
23
21
  - **Image** — Text-to-image with aspect ratio and batch controls
24
22
  - **Video** — Async video generation with progress tracking
25
23
  - **Speech** — TTS with 30+ voices, speed control, streaming playback
26
- - **Music** — Text-to-music with optional lyrics
24
+ - **Music** — Text-to-music with lyrics, instrumental mode, auto lyrics, and cover generation from reference audio
27
25
  - **Vision** — Image understanding and description
28
26
  - **Search** — Web search powered by MiniMax
29
27
  - **Dual Region** — Seamless Global (`api.minimax.io`) and CN (`api.minimaxi.com`) support
@@ -101,9 +99,15 @@ mmx speech voices
101
99
  ### `mmx music`
102
100
 
103
101
  ```bash
104
- mmx music generate --prompt "Upbeat pop" --lyrics "[verse] La da dee, sunny day"
105
- mmx music generate --prompt "Jazz" --lyrics "La la la" --out song.mp3
102
+ # Generate with lyrics
103
+ mmx music generate --prompt "Upbeat pop" --lyrics "[verse] La da dee, sunny day" --out song.mp3
104
+ # Auto-generate lyrics from prompt
105
+ mmx music generate --prompt "Indie folk, melancholic, rainy night" --lyrics-optimizer --out song.mp3
106
+ # Instrumental (no vocals)
106
107
  mmx music generate --prompt "Cinematic orchestral" --instrumental --out bgm.mp3
108
+ # Cover — generate a cover version from a reference audio file
109
+ mmx music cover --prompt "Jazz, piano, warm female vocal" --audio-file original.mp3 --out cover.mp3
110
+ mmx music cover --prompt "Indie folk" --audio https://example.com/song.mp3 --out cover.mp3
107
111
  ```
108
112
 
109
113
  ### `mmx vision`
package/dist/mmx.mjs CHANGED
@@ -1,103 +1,103 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as hi}from"node:module";var si=Object.create;var{getPrototypeOf:pi,defineProperty:It,getOwnPropertyNames:mi}=Object;var ai=Object.prototype.hasOwnProperty;function ui(t){return this[t]}var $i,li,xt=(t,e,i)=>{var r=t!=null&&typeof t==="object";if(r){var o=e?$i??=new WeakMap:li??=new WeakMap,s=o.get(t);if(s)return s}i=t!=null?si(pi(t)):{};let n=e||!t||!t.__esModule?It(i,"default",{value:t,enumerable:!0}):i;for(let m of mi(t))if(!ai.call(n,m))It(n,m,{get:ui.bind(t,m),enumerable:!0});if(r)o.set(t,n);return n};var ce=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ci=(t)=>t;function yi(t,e){this[t]=ci.bind(null,e)}var xi=(t,e)=>{for(var i in e)It(t,i,{get:e[i],enumerable:!0,configurable:!0,set:yi.bind(e,i)})};var ye=(t,e)=>()=>(t&&(e=t(t=0)),e);var nt=hi(import.meta.url);var Ht=ce((Xs,Qe)=>{var Wt={to(t,e){if(!e)return`\x1B[${t+1}G`;return`\x1B[${e+1};${t+1}H`},move(t,e){let i="";if(t<0)i+=`\x1B[${-t}D`;else if(t>0)i+=`\x1B[${t}C`;if(e<0)i+=`\x1B[${-e}A`;else if(e>0)i+=`\x1B[${e}B`;return i},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},Hi={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},Ui={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let e="";for(let i=0;i<t;i++)e+=this.line+(i<t-1?Wt.up():"");if(t)e+=Wt.left;return e}};Qe.exports={cursor:Wt,scroll:Hi,erase:Ui,beep:"\x07"}});var Ct=ce((Qs,Ut)=>{var kt=process||{},Ve=kt.argv||[],Rt=kt.env||{},Ci=!(!!Rt.NO_COLOR||Ve.includes("--no-color"))&&(!!Rt.FORCE_COLOR||Ve.includes("--color")||kt.platform==="win32"||(kt.stdout||{}).isTTY&&Rt.TERM!=="dumb"||!!Rt.CI),Pi=(t,e,i=t)=>(r)=>{let o=""+r,s=o.indexOf(e,t.length);return~s?t+Ei(o,e,i,s)+e:t+o+e},Ei=(t,e,i,r)=>{let o="",s=0;do o+=t.substring(s,r)+i,s=r+e.length,r=t.indexOf(e,s);while(~r);return o+t.substring(s)},Ze=(t=Ci)=>{let e=t?Pi:()=>String;return{isColorSupported:t,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};Ut.exports=Ze();Ut.exports.createColors=Ze});import{stdin as on,stdout as sn}from"node:process";import*as W from"node:readline";import We from"node:readline";import{WriteStream as Li}from"node:tty";function Fi({onlyFirst:t=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}function pn(t){if(typeof t!="string")throw TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(Di,"")}function mn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function at(t,e={}){if(typeof t!="string"||t.length===0||(e={ambiguousIsNarrow:!0,...e},t=pn(t),t.length===0))return 0;t=t.replace(ir()," ");let i=e.ambiguousIsNarrow?1:2,r=0;for(let o of t){let s=o.codePointAt(0);if(s<=31||s>=127&&s<=159||s>=768&&s<=879)continue;switch(er.eastAsianWidth(o)){case"F":case"W":r+=2;break;case"A":r+=i;break;default:r+=1}}return r}function sr(){let t=new Map;for(let[e,i]of Object.entries(S)){for(let[r,o]of Object.entries(i))S[r]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},i[r]=S[r],t.set(o[0],o[1]);Object.defineProperty(S,e,{value:i,enumerable:!1})}return Object.defineProperty(S,"codes",{value:t,enumerable:!1}),S.color.close="\x1B[39m",S.bgColor.close="\x1B[49m",S.color.ansi=He(),S.color.ansi256=Ue(),S.color.ansi16m=Ce(),S.bgColor.ansi=He(Pt),S.bgColor.ansi256=Ue(Pt),S.bgColor.ansi16m=Ce(Pt),Object.defineProperties(S,{rgbToAnsi256:{value:(e,i,r)=>e===i&&i===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(i/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value:(e)=>{let i=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!i)return[0,0,0];let[r]=i;r.length===3&&(r=[...r].map((s)=>s+s).join(""));let o=Number.parseInt(r,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:(e)=>S.rgbToAnsi256(...S.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:(e)=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let i,r,o;if(e>=232)i=((e-232)*10+8)/255,r=i,o=i;else{e-=16;let m=e%36;i=Math.floor(e/36)/5,r=Math.floor(m/6)/5,o=m%6/5}let s=Math.max(i,r,o)*2;if(s===0)return 30;let n=30+(Math.round(o)<<2|Math.round(r)<<1|Math.round(i));return s===2&&(n+=60),n},enumerable:!1},rgbToAnsi:{value:(e,i,r)=>S.ansi256ToAnsi(S.rgbToAnsi256(e,i,r)),enumerable:!1},hexToAnsi:{value:(e)=>S.ansi256ToAnsi(S.hexToAnsi256(e)),enumerable:!1}}),S}function Le(t,e,i){return String(t).normalize().replace(/\r\n/g,`
2
+ import{createRequire as _n}from"node:module";var $n=Object.create;var{getPrototypeOf:yn,defineProperty:Yt,getOwnPropertyNames:xn}=Object;var dn=Object.prototype.hasOwnProperty;function hn(t){return this[t]}var wn,bn,ht=(t,e,n)=>{var i=t!=null&&typeof t==="object";if(i){var o=e?wn??=new WeakMap:bn??=new WeakMap,s=o.get(t);if(s)return s}n=t!=null?$n(yn(t)):{};let r=e||!t||!t.__esModule?Yt(n,"default",{value:t,enumerable:!0}):n;for(let a of xn(t))if(!dn.call(r,a))Yt(r,a,{get:hn.bind(t,a),enumerable:!0});if(i)o.set(t,r);return r};var he=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var fn=(t)=>t;function vn(t,e){this[t]=fn.bind(null,e)}var we=(t,e)=>{for(var n in e)Yt(t,n,{get:e[n],enumerable:!0,configurable:!0,set:vn.bind(e,n)})};var Kt=(t,e)=>()=>(t&&(e=t(t=0)),e);var rt=_n(import.meta.url);var Pt=he((Cs,Ue)=>{var Et={to(t,e){if(!e)return`\x1B[${t+1}G`;return`\x1B[${e+1};${t+1}H`},move(t,e){let n="";if(t<0)n+=`\x1B[${-t}D`;else if(t>0)n+=`\x1B[${t}C`;if(e<0)n+=`\x1B[${-e}A`;else if(e>0)n+=`\x1B[${e}B`;return n},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},Fn={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},Dn={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let e="";for(let n=0;n<t;n++)e+=this.line+(n<t-1?Et.up():"");if(t)e+=Et.left;return e}};Ue.exports={cursor:Et,scroll:Fn,erase:Dn,beep:"\x07"}});var Ft=he((Es,Lt)=>{var jt=process||{},We=jt.argv||[],At=jt.env||{},ti=!(!!At.NO_COLOR||We.includes("--no-color"))&&(!!At.FORCE_COLOR||We.includes("--color")||jt.platform==="win32"||(jt.stdout||{}).isTTY&&At.TERM!=="dumb"||!!At.CI),ei=(t,e,n=t)=>(i)=>{let o=""+i,s=o.indexOf(e,t.length);return~s?t+ri(o,e,n,s)+e:t+o+e},ri=(t,e,n,i)=>{let o="",s=0;do o+=t.substring(s,i)+n,s=i+e.length,i=t.indexOf(e,s);while(~i);return o+t.substring(s)},He=(t=ti)=>{let e=t?ei:()=>String;return{isColorSupported:t,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};Lt.exports=He();Lt.exports.createColors=He});import{stdin as ar,stdout as mr}from"node:process";import*as H from"node:readline";import Ce from"node:readline";import{WriteStream as ni}from"node:tty";function ii({onlyFirst:t=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}function pr(t){if(typeof t!="string")throw TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(oi,"")}function ur(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ut(t,e={}){if(typeof t!="string"||t.length===0||(e={ambiguousIsNarrow:!0,...e},t=pr(t),t.length===0))return 0;t=t.replace(pi()," ");let n=e.ambiguousIsNarrow?1:2,i=0;for(let o of t){let s=o.codePointAt(0);if(s<=31||s>=127&&s<=159||s>=768&&s<=879)continue;switch(ai.eastAsianWidth(o)){case"F":case"W":i+=2;break;case"A":i+=n;break;default:i+=1}}return i}function li(){let t=new Map;for(let[e,n]of Object.entries(R)){for(let[i,o]of Object.entries(n))R[i]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},n[i]=R[i],t.set(o[0],o[1]);Object.defineProperty(R,e,{value:n,enumerable:!1})}return Object.defineProperty(R,"codes",{value:t,enumerable:!1}),R.color.close="\x1B[39m",R.bgColor.close="\x1B[49m",R.color.ansi=Ee(),R.color.ansi256=Pe(),R.color.ansi16m=Le(),R.bgColor.ansi=Ee(Dt),R.bgColor.ansi256=Pe(Dt),R.bgColor.ansi16m=Le(Dt),Object.defineProperties(R,{rgbToAnsi256:{value:(e,n,i)=>e===n&&n===i?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(i/255*5),enumerable:!1},hexToRgb:{value:(e)=>{let n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!n)return[0,0,0];let[i]=n;i.length===3&&(i=[...i].map((s)=>s+s).join(""));let o=Number.parseInt(i,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:(e)=>R.rgbToAnsi256(...R.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:(e)=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let n,i,o;if(e>=232)n=((e-232)*10+8)/255,i=n,o=n;else{e-=16;let a=e%36;n=Math.floor(e/36)/5,i=Math.floor(a/6)/5,o=a%6/5}let s=Math.max(n,i,o)*2;if(s===0)return 30;let r=30+(Math.round(o)<<2|Math.round(i)<<1|Math.round(n));return s===2&&(r+=60),r},enumerable:!1},rgbToAnsi:{value:(e,n,i)=>R.ansi256ToAnsi(R.rgbToAnsi256(e,n,i)),enumerable:!1},hexToAnsi:{value:(e)=>R.ansi256ToAnsi(R.hexToAnsi256(e)),enumerable:!1}}),R}function tr(t,e,n){return String(t).normalize().replace(/\r\n/g,`
3
3
  `).split(`
4
- `).map((r)=>lr(r,e,i)).join(`
5
- `)}function xr(t,e){if(t===e)return;let i=t.split(`
6
- `),r=e.split(`
7
- `),o=[];for(let s=0;s<Math.max(i.length,r.length);s++)i[s]!==r[s]&&o.push(s);return o}function jt(t){return t===ln}function gt(t,e){t.isTTY&&t.setRawMode(e)}class H{constructor({render:t,input:e=on,output:i=sn,...r},o=!0){N(this,"input"),N(this,"output"),N(this,"rl"),N(this,"opts"),N(this,"_track",!1),N(this,"_render"),N(this,"_cursor",0),N(this,"state","initial"),N(this,"value"),N(this,"error",""),N(this,"subscribers",new Map),N(this,"_prevFrame",""),this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=t.bind(this),this._track=o,this.input=e,this.output=i}prompt(){let t=new Li(0);return t._write=(e,i,r)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,""),this._cursor=this.rl.cursor,this.emit("value",this.value)),r()},this.input.pipe(t),this.rl=We.createInterface({input:this.input,output:t,tabSize:2,prompt:"",escapeCodeTimeout:50}),We.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),gt(this.input,!0),this.output.on("resize",this.render),this.render(),new Promise((e,i)=>{this.once("submit",()=>{this.output.write(j.cursor.show),this.output.off("resize",this.render),gt(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(j.cursor.show),this.output.off("resize",this.render),gt(this.input,!1),e(ln)})})}on(t,e){let i=this.subscribers.get(t)??[];i.push({cb:e}),this.subscribers.set(t,i)}once(t,e){let i=this.subscribers.get(t)??[];i.push({cb:e,once:!0}),this.subscribers.set(t,i)}emit(t,...e){let i=this.subscribers.get(t)??[],r=[];for(let o of i)o.cb(...e),o.once&&r.push(()=>i.splice(i.indexOf(o),1));for(let o of r)o()}unsubscribe(){this.subscribers.clear()}onKeypress(t,e){if(this.state==="error"&&(this.state="active"),e?.name&&!this._track&&Fe.has(e.name)&&this.emit("cursor",Fe.get(e.name)),e?.name&&hr.has(e.name)&&this.emit("cursor",e.name),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),t==="\t"&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),t&&this.emit("key",t.toLowerCase()),e?.name==="return"){if(this.opts.validate){let i=this.opts.validate(this.value);i&&(this.error=i,this.state="error",this.rl.write(this.value))}this.state!=="error"&&(this.state="submit")}t==="\x03"&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
8
- `),gt(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let t=Le(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
9
- `).length-1;this.output.write(j.cursor.move(-999,t*-1))}render(){let t=Le(this._render(this)??"",process.stdout.columns,{hard:!0});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(j.cursor.hide);else{let e=xr(this._prevFrame,t);if(this.restoreCursor(),e&&e?.length===1){let i=e[0];this.output.write(j.cursor.move(0,i)),this.output.write(j.erase.lines(1));let r=t.split(`
10
- `);this.output.write(r[i]),this._prevFrame=t,this.output.write(j.cursor.move(0,r.length-i-1));return}else if(e&&e?.length>1){let i=e[0];this.output.write(j.cursor.move(0,i)),this.output.write(j.erase.down());let r=t.split(`
11
- `).slice(i);this.output.write(r.join(`
12
- `)),this._prevFrame=t;return}this.output.write(j.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}function xn({input:t=on,output:e=sn,overwrite:i=!0,hideCursor:r=!0}={}){let o=W.createInterface({input:t,output:e,prompt:"",tabSize:1});W.emitKeypressEvents(t,o),t.isTTY&&t.setRawMode(!0);let s=(n,{name:m})=>{if(String(n)==="\x03"){r&&e.write(j.cursor.show),process.exit(0);return}if(!i)return;W.moveCursor(e,m==="return"?0:-1,m==="return"?-1:0,()=>{W.clearLine(e,1,()=>{t.once("keypress",s)})})};return r&&e.write(j.cursor.hide),t.once("keypress",s),()=>{t.off("keypress",s),r&&e.write(j.cursor.show),t.isTTY&&!qr&&t.setRawMode(!1),o.terminal=!1,o.close()}}var j,E,Di,an,tr,er,nr=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\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])|\uD83C[\uDF3E\uDF73\uDF7C\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\uDF7C\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\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\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\uDF7C\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\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\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\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\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-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*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\u26A7\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-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\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[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},ir,Pt=10,He=(t=0)=>(e)=>`\x1B[${e+t}m`,Ue=(t=0)=>(e)=>`\x1B[${38+t};5;${e}m`,Ce=(t=0)=>(e,i,r)=>`\x1B[${38+t};2;${e};${i};${r}m`,S,rr,or,pr,At,mr=39,Lt="\x07",un="[",ar="]",$n="m",Ft,Pe=(t)=>`${At.values().next().value}${un}${t}${$n}`,Ee=(t)=>`${At.values().next().value}${Ft}${t}${Lt}`,ur=(t)=>t.split(" ").map((e)=>at(e)),Et=(t,e,i)=>{let r=[...e],o=!1,s=!1,n=at(pn(t[t.length-1]));for(let[m,a]of r.entries()){let u=at(a);if(n+u<=i?t[t.length-1]+=a:(t.push(a),n=0),At.has(a)&&(o=!0,s=r.slice(m+1).join("").startsWith(Ft)),o){s?a===Lt&&(o=!1,s=!1):a===$n&&(o=!1);continue}n+=u,n===i&&m<r.length-1&&(t.push(""),n=0)}!n&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},$r=(t)=>{let e=t.split(" "),i=e.length;for(;i>0&&!(at(e[i-1])>0);)i--;return i===e.length?t:e.slice(0,i).join(" ")+e.slice(i).join("")},lr=(t,e,i={})=>{if(i.trim!==!1&&t.trim()==="")return"";let r="",o,s,n=ur(t),m=[""];for(let[u,y]of t.split(" ").entries()){i.trim!==!1&&(m[m.length-1]=m[m.length-1].trimStart());let $=at(m[m.length-1]);if(u!==0&&($>=e&&(i.wordWrap===!1||i.trim===!1)&&(m.push(""),$=0),($>0||i.trim===!1)&&(m[m.length-1]+=" ",$++)),i.hard&&n[u]>e){let h=e-$,w=1+Math.floor((n[u]-h-1)/e);Math.floor((n[u]-1)/e)<w&&m.push(""),Et(m,y,e);continue}if($+n[u]>e&&$>0&&n[u]>0){if(i.wordWrap===!1&&$<e){Et(m,y,e);continue}m.push("")}if($+n[u]>e&&i.wordWrap===!1){Et(m,y,e);continue}m[m.length-1]+=y}i.trim!==!1&&(m=m.map((u)=>$r(u)));let a=[...m.join(`
13
- `)];for(let[u,y]of a.entries()){if(r+=y,At.has(y)){let{groups:h}=new RegExp(`(?:\\${un}(?<code>\\d+)m|\\${Ft}(?<uri>.*)${Lt})`).exec(a.slice(u).join(""))||{groups:{}};if(h.code!==void 0){let w=Number.parseFloat(h.code);o=w===mr?void 0:w}else h.uri!==void 0&&(s=h.uri.length===0?void 0:h.uri)}let $=pr.codes.get(Number(o));a[u+1]===`
14
- `?(s&&(r+=Ee("")),o&&$&&(r+=Pe($))):y===`
15
- `&&(o&&$&&(r+=Pe(o)),s&&(r+=Ee(s)))}return r},cr,yr=(t,e,i)=>(e in t)?cr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,N=(t,e,i)=>(yr(t,typeof e!="symbol"?e+"":e,i),i),ln,Fe,hr,Dt,wr,br=(t,e,i)=>(e in t)?wr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,De=(t,e,i)=>(br(t,typeof e!="symbol"?e+"":e,i),i),te,dr,_r=(t,e,i)=>(e in t)?dr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,tn=(t,e,i)=>(_r(t,typeof e!="symbol"?e+"":e,i),i),cn,vr,fr=(t,e,i)=>(e in t)?vr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,en=(t,e,i)=>(fr(t,typeof e!="symbol"?e+"":e,i),i),ee,Sr,Rr=(t,e,i)=>(e in t)?Sr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,nn=(t,e,i)=>(Rr(t,typeof e!="symbol"?e+"":e,i),i),yn,kr,gr=(t,e,i)=>(e in t)?kr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,rn=(t,e,i)=>(gr(t,typeof e!="symbol"?e+"":e,i),i),ne,Ar,jr=(t,e,i)=>(e in t)?Ar(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Mr=(t,e,i)=>(jr(t,typeof e!="symbol"?e+"":e,i),i),ie,qr;var re=ye(()=>{j=xt(Ht(),1),E=xt(Ct(),1);Di=Fi();an={exports:{}};(function(t){var e={};t.exports=e,e.eastAsianWidth=function(r){var o=r.charCodeAt(0),s=r.length==2?r.charCodeAt(1):0,n=o;return 55296<=o&&o<=56319&&56320<=s&&s<=57343&&(o&=1023,s&=1023,n=o<<10|s,n+=65536),n==12288||65281<=n&&n<=65376||65504<=n&&n<=65510?"F":n==8361||65377<=n&&n<=65470||65474<=n&&n<=65479||65482<=n&&n<=65487||65490<=n&&n<=65495||65498<=n&&n<=65500||65512<=n&&n<=65518?"H":4352<=n&&n<=4447||4515<=n&&n<=4519||4602<=n&&n<=4607||9001<=n&&n<=9002||11904<=n&&n<=11929||11931<=n&&n<=12019||12032<=n&&n<=12245||12272<=n&&n<=12283||12289<=n&&n<=12350||12353<=n&&n<=12438||12441<=n&&n<=12543||12549<=n&&n<=12589||12593<=n&&n<=12686||12688<=n&&n<=12730||12736<=n&&n<=12771||12784<=n&&n<=12830||12832<=n&&n<=12871||12880<=n&&n<=13054||13056<=n&&n<=19903||19968<=n&&n<=42124||42128<=n&&n<=42182||43360<=n&&n<=43388||44032<=n&&n<=55203||55216<=n&&n<=55238||55243<=n&&n<=55291||63744<=n&&n<=64255||65040<=n&&n<=65049||65072<=n&&n<=65106||65108<=n&&n<=65126||65128<=n&&n<=65131||110592<=n&&n<=110593||127488<=n&&n<=127490||127504<=n&&n<=127546||127552<=n&&n<=127560||127568<=n&&n<=127569||131072<=n&&n<=194367||177984<=n&&n<=196605||196608<=n&&n<=262141?"W":32<=n&&n<=126||162<=n&&n<=163||165<=n&&n<=166||n==172||n==175||10214<=n&&n<=10221||10629<=n&&n<=10630?"Na":n==161||n==164||167<=n&&n<=168||n==170||173<=n&&n<=174||176<=n&&n<=180||182<=n&&n<=186||188<=n&&n<=191||n==198||n==208||215<=n&&n<=216||222<=n&&n<=225||n==230||232<=n&&n<=234||236<=n&&n<=237||n==240||242<=n&&n<=243||247<=n&&n<=250||n==252||n==254||n==257||n==273||n==275||n==283||294<=n&&n<=295||n==299||305<=n&&n<=307||n==312||319<=n&&n<=322||n==324||328<=n&&n<=331||n==333||338<=n&&n<=339||358<=n&&n<=359||n==363||n==462||n==464||n==466||n==468||n==470||n==472||n==474||n==476||n==593||n==609||n==708||n==711||713<=n&&n<=715||n==717||n==720||728<=n&&n<=731||n==733||n==735||768<=n&&n<=879||913<=n&&n<=929||931<=n&&n<=937||945<=n&&n<=961||963<=n&&n<=969||n==1025||1040<=n&&n<=1103||n==1105||n==8208||8211<=n&&n<=8214||8216<=n&&n<=8217||8220<=n&&n<=8221||8224<=n&&n<=8226||8228<=n&&n<=8231||n==8240||8242<=n&&n<=8243||n==8245||n==8251||n==8254||n==8308||n==8319||8321<=n&&n<=8324||n==8364||n==8451||n==8453||n==8457||n==8467||n==8470||8481<=n&&n<=8482||n==8486||n==8491||8531<=n&&n<=8532||8539<=n&&n<=8542||8544<=n&&n<=8555||8560<=n&&n<=8569||n==8585||8592<=n&&n<=8601||8632<=n&&n<=8633||n==8658||n==8660||n==8679||n==8704||8706<=n&&n<=8707||8711<=n&&n<=8712||n==8715||n==8719||n==8721||n==8725||n==8730||8733<=n&&n<=8736||n==8739||n==8741||8743<=n&&n<=8748||n==8750||8756<=n&&n<=8759||8764<=n&&n<=8765||n==8776||n==8780||n==8786||8800<=n&&n<=8801||8804<=n&&n<=8807||8810<=n&&n<=8811||8814<=n&&n<=8815||8834<=n&&n<=8835||8838<=n&&n<=8839||n==8853||n==8857||n==8869||n==8895||n==8978||9312<=n&&n<=9449||9451<=n&&n<=9547||9552<=n&&n<=9587||9600<=n&&n<=9615||9618<=n&&n<=9621||9632<=n&&n<=9633||9635<=n&&n<=9641||9650<=n&&n<=9651||9654<=n&&n<=9655||9660<=n&&n<=9661||9664<=n&&n<=9665||9670<=n&&n<=9672||n==9675||9678<=n&&n<=9681||9698<=n&&n<=9701||n==9711||9733<=n&&n<=9734||n==9737||9742<=n&&n<=9743||9748<=n&&n<=9749||n==9756||n==9758||n==9792||n==9794||9824<=n&&n<=9825||9827<=n&&n<=9829||9831<=n&&n<=9834||9836<=n&&n<=9837||n==9839||9886<=n&&n<=9887||9918<=n&&n<=9919||9924<=n&&n<=9933||9935<=n&&n<=9953||n==9955||9960<=n&&n<=9983||n==10045||n==10071||10102<=n&&n<=10111||11093<=n&&n<=11097||12872<=n&&n<=12879||57344<=n&&n<=63743||65024<=n&&n<=65039||n==65533||127232<=n&&n<=127242||127248<=n&&n<=127277||127280<=n&&n<=127337||127344<=n&&n<=127386||917760<=n&&n<=917999||983040<=n&&n<=1048573||1048576<=n&&n<=1114109?"A":"N"},e.characterLength=function(r){var o=this.eastAsianWidth(r);return o=="F"||o=="W"||o=="A"?2:1};function i(r){return r.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}e.length=function(r){for(var o=i(r),s=0,n=0;n<o.length;n++)s=s+this.characterLength(o[n]);return s},e.slice=function(r,o,s){textLen=e.length(r),o=o||0,s=s||1,o<0&&(o=textLen+o),s<0&&(s=textLen+s);for(var n="",m=0,a=i(r),u=0;u<a.length;u++){var y=a[u],$=e.length(y);if(m>=o-($==2?1:0))if(m+$<=s)n+=y;else break;m+=$}return n}})(an);tr=an.exports,er=mn(tr),ir=mn(nr);S={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(S.modifier);rr=Object.keys(S.color),or=Object.keys(S.bgColor);[...rr,...or];pr=sr(),At=new Set(["\x1B","›"]),Ft=`${ar}8;;`;cr=Object.defineProperty;ln=Symbol("clack:cancel");Fe=new Map([["k","up"],["j","down"],["h","left"],["l","right"]]),hr=new Set(["up","down","left","right","space","enter"]);Dt=class Dt extends H{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(e)=>{this.output.write(j.cursor.move(0,-1)),this.value=e,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};wr=Object.defineProperty;te=class te extends H{constructor(t){super(t,!1),De(this,"options"),De(this,"cursor",0);let{options:e}=t;this.options=Object.entries(e).flatMap(([i,r])=>[{value:i,group:!0,label:i},...r.map((o)=>({...o,group:i}))]),this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:i})=>i===t.cursorAt),0),this.on("cursor",(i)=>{switch(i){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}getGroupItems(t){return this.options.filter((e)=>e.group===t)}isGroupSelected(t){return this.getGroupItems(t).every((e)=>this.value.includes(e.value))}toggleValue(){let t=this.options[this.cursor];if(t.group===!0){let e=t.value,i=this.getGroupItems(e);this.isGroupSelected(e)?this.value=this.value.filter((r)=>i.findIndex((o)=>o.value===r)===-1):this.value=[...this.value,...i.map((r)=>r.value)],this.value=Array.from(new Set(this.value))}else{let e=this.value.includes(t.value);this.value=e?this.value.filter((i)=>i!==t.value):[...this.value,t.value]}}};dr=Object.defineProperty,cn=class extends H{constructor(t){super(t,!1),tn(this,"options"),tn(this,"cursor",0),this.options=t.options,this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===t.cursorAt),0),this.on("key",(e)=>{e==="a"&&this.toggleAll()}),this.on("cursor",(e)=>{switch(e){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let t=this.value.length===this.options.length;this.value=t?[]:this.options.map((e)=>e.value)}toggleValue(){let t=this.value.includes(this._value);this.value=t?this.value.filter((e)=>e!==this._value):[...this.value,this._value]}},vr=Object.defineProperty;ee=class ee extends H{constructor({mask:t,...e}){super(e),en(this,"valueWithCursor",""),en(this,"_mask","•"),this._mask=t??"•",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${E.default.inverse(E.default.hidden("_"))}`;else{let i=this.masked.slice(0,this.cursor),r=this.masked.slice(this.cursor);this.valueWithCursor=`${i}${E.default.inverse(r[0])}${r.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}};Sr=Object.defineProperty,yn=class extends H{constructor(t){super(t,!1),nn(this,"options"),nn(this,"cursor",0),this.options=t.options,this.cursor=this.options.findIndex(({value:e})=>e===t.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(e)=>{switch(e){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},kr=Object.defineProperty;ne=class ne extends H{constructor(t){super(t,!1),rn(this,"options"),rn(this,"cursor",0),this.options=t.options;let e=this.options.map(({value:[i]})=>i?.toLowerCase());this.cursor=Math.max(e.indexOf(t.initialValue),0),this.on("key",(i)=>{if(!e.includes(i))return;let r=this.options.find(({value:[o]})=>o?.toLowerCase()===i);r&&(this.value=r.value,this.state="submit",this.emit("submit"))})}};Ar=Object.defineProperty;ie=class ie extends H{constructor(t){super(t),Mr(this,"valueWithCursor",""),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.valueWithCursor=this.value}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${E.default.inverse(E.default.hidden("_"))}`;else{let e=this.value.slice(0,this.cursor),i=this.value.slice(this.cursor);this.valueWithCursor=`${e}${E.default.inverse(i[0])}${i.slice(1)}`}})}get cursor(){return this._cursor}};qr=globalThis.process.platform.startsWith("win")});var qt={};xi(qt,{text:()=>Qr,spinner:()=>Dr,selectKey:()=>Hr,select:()=>Wr,password:()=>Vr,outro:()=>Fr,note:()=>Pr,multiselect:()=>Ur,log:()=>L,isCancel:()=>jt,intro:()=>Lr,groupMultiselect:()=>Cr,group:()=>eo,confirm:()=>Zr,cancel:()=>Er});import z from"node:process";function Tr(){return z.platform!=="win32"?z.env.TERM!=="linux":Boolean(z.env.CI)||Boolean(z.env.WT_SESSION)||Boolean(z.env.TERMINUS_SUBLIME)||z.env.ConEmuTask==="{cmd::Cmder}"||z.env.TERM_PROGRAM==="Terminus-Sublime"||z.env.TERM_PROGRAM==="vscode"||z.env.TERM==="xterm-256color"||z.env.TERM==="alacritty"||z.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function to(){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,"g")}var p,ot,se,R=(t,e)=>se?t:e,Or,wn,bn,Mt,Gr,x,T,pe,me,ae,ut,dn,Nr,hn,Br,Ir,zr,Jr,Yr,Kr,Xr,F=(t)=>{switch(t){case"initial":case"active":return p.default.cyan(Or);case"cancel":return p.default.red(wn);case"error":return p.default.yellow(bn);case"submit":return p.default.green(Mt)}},Qr=(t)=>new ie({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){let e=`${p.default.gray(x)}
16
- ${F(this.state)} ${t.message}
17
- `,i=t.placeholder?p.default.inverse(t.placeholder[0])+p.default.dim(t.placeholder.slice(1)):p.default.inverse(p.default.hidden("_")),r=this.value?this.valueWithCursor:i;switch(this.state){case"error":return`${e.trim()}
18
- ${p.default.yellow(x)} ${r}
19
- ${p.default.yellow(T)} ${p.default.yellow(this.error)}
20
- `;case"submit":return`${e}${p.default.gray(x)} ${p.default.dim(this.value||t.placeholder)}`;case"cancel":return`${e}${p.default.gray(x)} ${p.default.strikethrough(p.default.dim(this.value??""))}${this.value?.trim()?`
21
- `+p.default.gray(x):""}`;default:return`${e}${p.default.cyan(x)} ${r}
22
- ${p.default.cyan(T)}
23
- `}}}).prompt(),Vr=(t)=>new ee({validate:t.validate,mask:t.mask??Nr,render(){let e=`${p.default.gray(x)}
24
- ${F(this.state)} ${t.message}
25
- `,i=this.valueWithCursor,r=this.masked;switch(this.state){case"error":return`${e.trim()}
26
- ${p.default.yellow(x)} ${r}
27
- ${p.default.yellow(T)} ${p.default.yellow(this.error)}
28
- `;case"submit":return`${e}${p.default.gray(x)} ${p.default.dim(r)}`;case"cancel":return`${e}${p.default.gray(x)} ${p.default.strikethrough(p.default.dim(r??""))}${r?`
29
- `+p.default.gray(x):""}`;default:return`${e}${p.default.cyan(x)} ${i}
30
- ${p.default.cyan(T)}
31
- `}}}).prompt(),Zr=(t)=>{let e=t.active??"Yes",i=t.inactive??"No";return new Dt({active:e,inactive:i,initialValue:t.initialValue??!0,render(){let r=`${p.default.gray(x)}
32
- ${F(this.state)} ${t.message}
33
- `,o=this.value?e:i;switch(this.state){case"submit":return`${r}${p.default.gray(x)} ${p.default.dim(o)}`;case"cancel":return`${r}${p.default.gray(x)} ${p.default.strikethrough(p.default.dim(o))}
34
- ${p.default.gray(x)}`;default:return`${r}${p.default.cyan(x)} ${this.value?`${p.default.green(pe)} ${e}`:`${p.default.dim(me)} ${p.default.dim(e)}`} ${p.default.dim("/")} ${this.value?`${p.default.dim(me)} ${p.default.dim(i)}`:`${p.default.green(pe)} ${i}`}
35
- ${p.default.cyan(T)}
36
- `}}}).prompt()},Wr=(t)=>{let e=(r,o)=>{let s=r.label??String(r.value);return o==="active"?`${p.default.green(pe)} ${s} ${r.hint?p.default.dim(`(${r.hint})`):""}`:o==="selected"?`${p.default.dim(s)}`:o==="cancelled"?`${p.default.strikethrough(p.default.dim(s))}`:`${p.default.dim(me)} ${p.default.dim(s)}`},i=0;return new yn({options:t.options,initialValue:t.initialValue,render(){let r=`${p.default.gray(x)}
37
- ${F(this.state)} ${t.message}
38
- `;switch(this.state){case"submit":return`${r}${p.default.gray(x)} ${e(this.options[this.cursor],"selected")}`;case"cancel":return`${r}${p.default.gray(x)} ${e(this.options[this.cursor],"cancelled")}
39
- ${p.default.gray(x)}`;default:{let o=t.maxItems===void 0?1/0:Math.max(t.maxItems,5);this.cursor>=i+o-3?i=Math.max(Math.min(this.cursor-o+3,this.options.length-o),0):this.cursor<i+2&&(i=Math.max(this.cursor-2,0));let s=o<this.options.length&&i>0,n=o<this.options.length&&i+o<this.options.length;return`${r}${p.default.cyan(x)} ${this.options.slice(i,i+o).map((m,a,u)=>a===0&&s?p.default.dim("..."):a===u.length-1&&n?p.default.dim("..."):e(m,a+i===this.cursor?"active":"inactive")).join(`
40
- ${p.default.cyan(x)} `)}
41
- ${p.default.cyan(T)}
42
- `}}}}).prompt()},Hr=(t)=>{let e=(i,r="inactive")=>{let o=i.label??String(i.value);return r==="selected"?`${p.default.dim(o)}`:r==="cancelled"?`${p.default.strikethrough(p.default.dim(o))}`:r==="active"?`${p.default.bgCyan(p.default.gray(` ${i.value} `))} ${o} ${i.hint?p.default.dim(`(${i.hint})`):""}`:`${p.default.gray(p.default.bgWhite(p.default.inverse(` ${i.value} `)))} ${o} ${i.hint?p.default.dim(`(${i.hint})`):""}`};return new ne({options:t.options,initialValue:t.initialValue,render(){let i=`${p.default.gray(x)}
43
- ${F(this.state)} ${t.message}
44
- `;switch(this.state){case"submit":return`${i}${p.default.gray(x)} ${e(this.options.find((r)=>r.value===this.value),"selected")}`;case"cancel":return`${i}${p.default.gray(x)} ${e(this.options[0],"cancelled")}
45
- ${p.default.gray(x)}`;default:return`${i}${p.default.cyan(x)} ${this.options.map((r,o)=>e(r,o===this.cursor?"active":"inactive")).join(`
46
- ${p.default.cyan(x)} `)}
47
- ${p.default.cyan(T)}
48
- `}}}).prompt()},Ur=(t)=>{let e=(i,r)=>{let o=i.label??String(i.value);return r==="active"?`${p.default.cyan(ae)} ${o} ${i.hint?p.default.dim(`(${i.hint})`):""}`:r==="selected"?`${p.default.green(ut)} ${p.default.dim(o)}`:r==="cancelled"?`${p.default.strikethrough(p.default.dim(o))}`:r==="active-selected"?`${p.default.green(ut)} ${o} ${i.hint?p.default.dim(`(${i.hint})`):""}`:r==="submitted"?`${p.default.dim(o)}`:`${p.default.dim(dn)} ${p.default.dim(o)}`};return new cn({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
49
- ${p.default.reset(p.default.dim(`Press ${p.default.gray(p.default.bgWhite(p.default.inverse(" space ")))} to select, ${p.default.gray(p.default.bgWhite(p.default.inverse(" enter ")))} to submit`))}`},render(){let i=`${p.default.gray(x)}
50
- ${F(this.state)} ${t.message}
51
- `;switch(this.state){case"submit":return`${i}${p.default.gray(x)} ${this.options.filter(({value:r})=>this.value.includes(r)).map((r)=>e(r,"submitted")).join(p.default.dim(", "))||p.default.dim("none")}`;case"cancel":{let r=this.options.filter(({value:o})=>this.value.includes(o)).map((o)=>e(o,"cancelled")).join(p.default.dim(", "));return`${i}${p.default.gray(x)} ${r.trim()?`${r}
52
- ${p.default.gray(x)}`:""}`}case"error":{let r=this.error.split(`
53
- `).map((o,s)=>s===0?`${p.default.yellow(T)} ${p.default.yellow(o)}`:` ${o}`).join(`
54
- `);return i+p.default.yellow(x)+" "+this.options.map((o,s)=>{let n=this.value.includes(o.value),m=s===this.cursor;return m&&n?e(o,"active-selected"):n?e(o,"selected"):e(o,m?"active":"inactive")}).join(`
55
- ${p.default.yellow(x)} `)+`
56
- `+r+`
57
- `}default:return`${i}${p.default.cyan(x)} ${this.options.map((r,o)=>{let s=this.value.includes(r.value),n=o===this.cursor;return n&&s?e(r,"active-selected"):s?e(r,"selected"):e(r,n?"active":"inactive")}).join(`
58
- ${p.default.cyan(x)} `)}
59
- ${p.default.cyan(T)}
60
- `}}}).prompt()},Cr=(t)=>{let e=(i,r,o=[])=>{let s=i.label??String(i.value),n=typeof i.group=="string",m=n&&(o[o.indexOf(i)+1]??{group:!0}),a=n&&m.group===!0,u=n?`${a?T:x} `:"";return r==="active"?`${p.default.dim(u)}${p.default.cyan(ae)} ${s} ${i.hint?p.default.dim(`(${i.hint})`):""}`:r==="group-active"?`${u}${p.default.cyan(ae)} ${p.default.dim(s)}`:r==="group-active-selected"?`${u}${p.default.green(ut)} ${p.default.dim(s)}`:r==="selected"?`${p.default.dim(u)}${p.default.green(ut)} ${p.default.dim(s)}`:r==="cancelled"?`${p.default.strikethrough(p.default.dim(s))}`:r==="active-selected"?`${p.default.dim(u)}${p.default.green(ut)} ${s} ${i.hint?p.default.dim(`(${i.hint})`):""}`:r==="submitted"?`${p.default.dim(s)}`:`${p.default.dim(u)}${p.default.dim(dn)} ${p.default.dim(s)}`};return new te({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
61
- ${p.default.reset(p.default.dim(`Press ${p.default.gray(p.default.bgWhite(p.default.inverse(" space ")))} to select, ${p.default.gray(p.default.bgWhite(p.default.inverse(" enter ")))} to submit`))}`},render(){let i=`${p.default.gray(x)}
62
- ${F(this.state)} ${t.message}
63
- `;switch(this.state){case"submit":return`${i}${p.default.gray(x)} ${this.options.filter(({value:r})=>this.value.includes(r)).map((r)=>e(r,"submitted")).join(p.default.dim(", "))}`;case"cancel":{let r=this.options.filter(({value:o})=>this.value.includes(o)).map((o)=>e(o,"cancelled")).join(p.default.dim(", "));return`${i}${p.default.gray(x)} ${r.trim()?`${r}
64
- ${p.default.gray(x)}`:""}`}case"error":{let r=this.error.split(`
65
- `).map((o,s)=>s===0?`${p.default.yellow(T)} ${p.default.yellow(o)}`:` ${o}`).join(`
66
- `);return`${i}${p.default.yellow(x)} ${this.options.map((o,s,n)=>{let m=this.value.includes(o.value)||o.group===!0&&this.isGroupSelected(`${o.value}`),a=s===this.cursor;return!a&&typeof o.group=="string"&&this.options[this.cursor].value===o.group?e(o,m?"group-active-selected":"group-active",n):a&&m?e(o,"active-selected",n):m?e(o,"selected",n):e(o,a?"active":"inactive",n)}).join(`
67
- ${p.default.yellow(x)} `)}
68
- ${r}
69
- `}default:return`${i}${p.default.cyan(x)} ${this.options.map((r,o,s)=>{let n=this.value.includes(r.value)||r.group===!0&&this.isGroupSelected(`${r.value}`),m=o===this.cursor;return!m&&typeof r.group=="string"&&this.options[this.cursor].value===r.group?e(r,n?"group-active-selected":"group-active",s):m&&n?e(r,"active-selected",s):n?e(r,"selected",s):e(r,m?"active":"inactive",s)}).join(`
70
- ${p.default.cyan(x)} `)}
71
- ${p.default.cyan(T)}
72
- `}}}).prompt()},oe=(t)=>t.replace(to(),""),Pr=(t="",e="")=>{let i=`
4
+ `).map((i)=>wi(i,e,n)).join(`
5
+ `)}function vi(t,e){if(t===e)return;let n=t.split(`
6
+ `),i=e.split(`
7
+ `),o=[];for(let s=0;s<Math.max(n.length,i.length);s++)n[s]!==i[s]&&o.push(s);return o}function Tt(t){return t===yr}function qt(t,e){t.isTTY&&t.setRawMode(e)}class C{constructor({render:t,input:e=ar,output:n=mr,...i},o=!0){B(this,"input"),B(this,"output"),B(this,"rl"),B(this,"opts"),B(this,"_track",!1),B(this,"_render"),B(this,"_cursor",0),B(this,"state","initial"),B(this,"value"),B(this,"error",""),B(this,"subscribers",new Map),B(this,"_prevFrame",""),this.opts=i,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=t.bind(this),this._track=o,this.input=e,this.output=n}prompt(){let t=new ni(0);return t._write=(e,n,i)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,""),this._cursor=this.rl.cursor,this.emit("value",this.value)),i()},this.input.pipe(t),this.rl=Ce.createInterface({input:this.input,output:t,tabSize:2,prompt:"",escapeCodeTimeout:50}),Ce.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),qt(this.input,!0),this.output.on("resize",this.render),this.render(),new Promise((e,n)=>{this.once("submit",()=>{this.output.write(q.cursor.show),this.output.off("resize",this.render),qt(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(q.cursor.show),this.output.off("resize",this.render),qt(this.input,!1),e(yr)})})}on(t,e){let n=this.subscribers.get(t)??[];n.push({cb:e}),this.subscribers.set(t,n)}once(t,e){let n=this.subscribers.get(t)??[];n.push({cb:e,once:!0}),this.subscribers.set(t,n)}emit(t,...e){let n=this.subscribers.get(t)??[],i=[];for(let o of n)o.cb(...e),o.once&&i.push(()=>n.splice(n.indexOf(o),1));for(let o of i)o()}unsubscribe(){this.subscribers.clear()}onKeypress(t,e){if(this.state==="error"&&(this.state="active"),e?.name&&!this._track&&er.has(e.name)&&this.emit("cursor",er.get(e.name)),e?.name&&_i.has(e.name)&&this.emit("cursor",e.name),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),t==="\t"&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),t&&this.emit("key",t.toLowerCase()),e?.name==="return"){if(this.opts.validate){let n=this.opts.validate(this.value);n&&(this.error=n,this.state="error",this.rl.write(this.value))}this.state!=="error"&&(this.state="submit")}t==="\x03"&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
8
+ `),qt(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let t=tr(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
9
+ `).length-1;this.output.write(q.cursor.move(-999,t*-1))}render(){let t=tr(this._render(this)??"",process.stdout.columns,{hard:!0});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(q.cursor.hide);else{let e=vi(this._prevFrame,t);if(this.restoreCursor(),e&&e?.length===1){let n=e[0];this.output.write(q.cursor.move(0,n)),this.output.write(q.erase.lines(1));let i=t.split(`
10
+ `);this.output.write(i[n]),this._prevFrame=t,this.output.write(q.cursor.move(0,i.length-n-1));return}else if(e&&e?.length>1){let n=e[0];this.output.write(q.cursor.move(0,n)),this.output.write(q.erase.down());let i=t.split(`
11
+ `).slice(n);this.output.write(i.join(`
12
+ `)),this._prevFrame=t;return}this.output.write(q.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}function hr({input:t=ar,output:e=mr,overwrite:n=!0,hideCursor:i=!0}={}){let o=H.createInterface({input:t,output:e,prompt:"",tabSize:1});H.emitKeypressEvents(t,o),t.isTTY&&t.setRawMode(!0);let s=(r,{name:a})=>{if(String(r)==="\x03"){i&&e.write(q.cursor.show),process.exit(0);return}if(!n)return;H.moveCursor(e,a==="return"?0:-1,a==="return"?-1:0,()=>{H.clearLine(e,1,()=>{t.once("keypress",s)})})};return i&&e.write(q.cursor.hide),t.once("keypress",s),()=>{t.off("keypress",s),i&&e.write(q.cursor.show),t.isTTY&&!Ii&&t.setRawMode(!1),o.terminal=!1,o.close()}}var q,L,oi,cr,si,ai,mi=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\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])|\uD83C[\uDF3E\uDF73\uDF7C\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\uDF7C\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\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\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\uDF7C\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\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\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\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\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-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*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\u26A7\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-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\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[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},pi,Dt=10,Ee=(t=0)=>(e)=>`\x1B[${e+t}m`,Pe=(t=0)=>(e)=>`\x1B[${38+t};5;${e}m`,Le=(t=0)=>(e,n,i)=>`\x1B[${38+t};2;${e};${n};${i}m`,R,ui,ci,$i,Mt,yi=39,ee="\x07",lr="[",xi="]",$r="m",re,Fe=(t)=>`${Mt.values().next().value}${lr}${t}${$r}`,De=(t)=>`${Mt.values().next().value}${re}${t}${ee}`,di=(t)=>t.split(" ").map((e)=>ut(e)),te=(t,e,n)=>{let i=[...e],o=!1,s=!1,r=ut(pr(t[t.length-1]));for(let[a,p]of i.entries()){let u=ut(p);if(r+u<=n?t[t.length-1]+=p:(t.push(p),r=0),Mt.has(p)&&(o=!0,s=i.slice(a+1).join("").startsWith(re)),o){s?p===ee&&(o=!1,s=!1):p===$r&&(o=!1);continue}r+=u,r===n&&a<i.length-1&&(t.push(""),r=0)}!r&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},hi=(t)=>{let e=t.split(" "),n=e.length;for(;n>0&&!(ut(e[n-1])>0);)n--;return n===e.length?t:e.slice(0,n).join(" ")+e.slice(n).join("")},wi=(t,e,n={})=>{if(n.trim!==!1&&t.trim()==="")return"";let i="",o,s,r=di(t),a=[""];for(let[u,y]of t.split(" ").entries()){n.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let c=ut(a[a.length-1]);if(u!==0&&(c>=e&&(n.wordWrap===!1||n.trim===!1)&&(a.push(""),c=0),(c>0||n.trim===!1)&&(a[a.length-1]+=" ",c++)),n.hard&&r[u]>e){let x=e-c,w=1+Math.floor((r[u]-x-1)/e);Math.floor((r[u]-1)/e)<w&&a.push(""),te(a,y,e);continue}if(c+r[u]>e&&c>0&&r[u]>0){if(n.wordWrap===!1&&c<e){te(a,y,e);continue}a.push("")}if(c+r[u]>e&&n.wordWrap===!1){te(a,y,e);continue}a[a.length-1]+=y}n.trim!==!1&&(a=a.map((u)=>hi(u)));let p=[...a.join(`
13
+ `)];for(let[u,y]of p.entries()){if(i+=y,Mt.has(y)){let{groups:x}=new RegExp(`(?:\\${lr}(?<code>\\d+)m|\\${re}(?<uri>.*)${ee})`).exec(p.slice(u).join(""))||{groups:{}};if(x.code!==void 0){let w=Number.parseFloat(x.code);o=w===yi?void 0:w}else x.uri!==void 0&&(s=x.uri.length===0?void 0:x.uri)}let c=$i.codes.get(Number(o));p[u+1]===`
14
+ `?(s&&(i+=De("")),o&&c&&(i+=Fe(c))):y===`
15
+ `&&(o&&c&&(i+=Fe(o)),s&&(i+=De(s)))}return i},bi,fi=(t,e,n)=>(e in t)?bi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,B=(t,e,n)=>(fi(t,typeof e!="symbol"?e+"":e,n),n),yr,er,_i,ne,Si,Ri=(t,e,n)=>(e in t)?Si(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,rr=(t,e,n)=>(Ri(t,typeof e!="symbol"?e+"":e,n),n),ie,ki,gi=(t,e,n)=>(e in t)?ki(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,nr=(t,e,n)=>(gi(t,typeof e!="symbol"?e+"":e,n),n),xr,Ai,ji=(t,e,n)=>(e in t)?Ai(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ir=(t,e,n)=>(ji(t,typeof e!="symbol"?e+"":e,n),n),oe,qi,Mi=(t,e,n)=>(e in t)?qi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,or=(t,e,n)=>(Mi(t,typeof e!="symbol"?e+"":e,n),n),dr,Ti,Oi=(t,e,n)=>(e in t)?Ti(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,sr=(t,e,n)=>(Oi(t,typeof e!="symbol"?e+"":e,n),n),se,Gi,Ni=(t,e,n)=>(e in t)?Gi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Bi=(t,e,n)=>(Ni(t,typeof e!="symbol"?e+"":e,n),n),ae,Ii;var me=Kt(()=>{q=ht(Pt(),1),L=ht(Ft(),1);oi=ii();cr={exports:{}};(function(t){var e={};t.exports=e,e.eastAsianWidth=function(i){var o=i.charCodeAt(0),s=i.length==2?i.charCodeAt(1):0,r=o;return 55296<=o&&o<=56319&&56320<=s&&s<=57343&&(o&=1023,s&=1023,r=o<<10|s,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?"F":r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?"H":4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?"W":32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?"Na":r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?"A":"N"},e.characterLength=function(i){var o=this.eastAsianWidth(i);return o=="F"||o=="W"||o=="A"?2:1};function n(i){return i.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}e.length=function(i){for(var o=n(i),s=0,r=0;r<o.length;r++)s=s+this.characterLength(o[r]);return s},e.slice=function(i,o,s){textLen=e.length(i),o=o||0,s=s||1,o<0&&(o=textLen+o),s<0&&(s=textLen+s);for(var r="",a=0,p=n(i),u=0;u<p.length;u++){var y=p[u],c=e.length(y);if(a>=o-(c==2?1:0))if(a+c<=s)r+=y;else break;a+=c}return r}})(cr);si=cr.exports,ai=ur(si),pi=ur(mi);R={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(R.modifier);ui=Object.keys(R.color),ci=Object.keys(R.bgColor);[...ui,...ci];$i=li(),Mt=new Set(["\x1B","›"]),re=`${xi}8;;`;bi=Object.defineProperty;yr=Symbol("clack:cancel");er=new Map([["k","up"],["j","down"],["h","left"],["l","right"]]),_i=new Set(["up","down","left","right","space","enter"]);ne=class ne extends C{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(e)=>{this.output.write(q.cursor.move(0,-1)),this.value=e,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};Si=Object.defineProperty;ie=class ie extends C{constructor(t){super(t,!1),rr(this,"options"),rr(this,"cursor",0);let{options:e}=t;this.options=Object.entries(e).flatMap(([n,i])=>[{value:n,group:!0,label:n},...i.map((o)=>({...o,group:n}))]),this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:n})=>n===t.cursorAt),0),this.on("cursor",(n)=>{switch(n){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}getGroupItems(t){return this.options.filter((e)=>e.group===t)}isGroupSelected(t){return this.getGroupItems(t).every((e)=>this.value.includes(e.value))}toggleValue(){let t=this.options[this.cursor];if(t.group===!0){let e=t.value,n=this.getGroupItems(e);this.isGroupSelected(e)?this.value=this.value.filter((i)=>n.findIndex((o)=>o.value===i)===-1):this.value=[...this.value,...n.map((i)=>i.value)],this.value=Array.from(new Set(this.value))}else{let e=this.value.includes(t.value);this.value=e?this.value.filter((n)=>n!==t.value):[...this.value,t.value]}}};ki=Object.defineProperty,xr=class extends C{constructor(t){super(t,!1),nr(this,"options"),nr(this,"cursor",0),this.options=t.options,this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===t.cursorAt),0),this.on("key",(e)=>{e==="a"&&this.toggleAll()}),this.on("cursor",(e)=>{switch(e){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let t=this.value.length===this.options.length;this.value=t?[]:this.options.map((e)=>e.value)}toggleValue(){let t=this.value.includes(this._value);this.value=t?this.value.filter((e)=>e!==this._value):[...this.value,this._value]}},Ai=Object.defineProperty;oe=class oe extends C{constructor({mask:t,...e}){super(e),ir(this,"valueWithCursor",""),ir(this,"_mask","•"),this._mask=t??"•",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${L.default.inverse(L.default.hidden("_"))}`;else{let n=this.masked.slice(0,this.cursor),i=this.masked.slice(this.cursor);this.valueWithCursor=`${n}${L.default.inverse(i[0])}${i.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}};qi=Object.defineProperty,dr=class extends C{constructor(t){super(t,!1),or(this,"options"),or(this,"cursor",0),this.options=t.options,this.cursor=this.options.findIndex(({value:e})=>e===t.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(e)=>{switch(e){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},Ti=Object.defineProperty;se=class se extends C{constructor(t){super(t,!1),sr(this,"options"),sr(this,"cursor",0),this.options=t.options;let e=this.options.map(({value:[n]})=>n?.toLowerCase());this.cursor=Math.max(e.indexOf(t.initialValue),0),this.on("key",(n)=>{if(!e.includes(n))return;let i=this.options.find(({value:[o]})=>o?.toLowerCase()===n);i&&(this.value=i.value,this.state="submit",this.emit("submit"))})}};Gi=Object.defineProperty;ae=class ae extends C{constructor(t){super(t),Bi(this,"valueWithCursor",""),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.valueWithCursor=this.value}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${L.default.inverse(L.default.hidden("_"))}`;else{let e=this.value.slice(0,this.cursor),n=this.value.slice(this.cursor);this.valueWithCursor=`${e}${L.default.inverse(n[0])}${n.slice(1)}`}})}get cursor(){return this._cursor}};Ii=globalThis.process.platform.startsWith("win")});var Gt={};we(Gt,{text:()=>Ci,spinner:()=>oo,selectKey:()=>Fi,select:()=>Li,password:()=>Ei,outro:()=>io,note:()=>eo,multiselect:()=>Di,log:()=>F,isCancel:()=>Tt,intro:()=>no,groupMultiselect:()=>to,group:()=>ao,confirm:()=>Pi,cancel:()=>ro});import z from"node:process";function Ji(){return z.platform!=="win32"?z.env.TERM!=="linux":Boolean(z.env.CI)||Boolean(z.env.WT_SESSION)||Boolean(z.env.TERMINUS_SUBLIME)||z.env.ConEmuTask==="{cmd::Cmder}"||z.env.TERM_PROGRAM==="Terminus-Sublime"||z.env.TERM_PROGRAM==="vscode"||z.env.TERM==="xterm-256color"||z.env.TERM==="alacritty"||z.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function so(){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,"g")}var m,ot,ue,g=(t,e)=>ue?t:e,zi,br,fr,Ot,Yi,d,O,ce,le,$e,ct,vr,Ki,wr,Xi,Qi,Vi,Zi,Ui,Wi,Hi,D=(t)=>{switch(t){case"initial":case"active":return m.default.cyan(zi);case"cancel":return m.default.red(br);case"error":return m.default.yellow(fr);case"submit":return m.default.green(Ot)}},Ci=(t)=>new ae({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){let e=`${m.default.gray(d)}
16
+ ${D(this.state)} ${t.message}
17
+ `,n=t.placeholder?m.default.inverse(t.placeholder[0])+m.default.dim(t.placeholder.slice(1)):m.default.inverse(m.default.hidden("_")),i=this.value?this.valueWithCursor:n;switch(this.state){case"error":return`${e.trim()}
18
+ ${m.default.yellow(d)} ${i}
19
+ ${m.default.yellow(O)} ${m.default.yellow(this.error)}
20
+ `;case"submit":return`${e}${m.default.gray(d)} ${m.default.dim(this.value||t.placeholder)}`;case"cancel":return`${e}${m.default.gray(d)} ${m.default.strikethrough(m.default.dim(this.value??""))}${this.value?.trim()?`
21
+ `+m.default.gray(d):""}`;default:return`${e}${m.default.cyan(d)} ${i}
22
+ ${m.default.cyan(O)}
23
+ `}}}).prompt(),Ei=(t)=>new oe({validate:t.validate,mask:t.mask??Ki,render(){let e=`${m.default.gray(d)}
24
+ ${D(this.state)} ${t.message}
25
+ `,n=this.valueWithCursor,i=this.masked;switch(this.state){case"error":return`${e.trim()}
26
+ ${m.default.yellow(d)} ${i}
27
+ ${m.default.yellow(O)} ${m.default.yellow(this.error)}
28
+ `;case"submit":return`${e}${m.default.gray(d)} ${m.default.dim(i)}`;case"cancel":return`${e}${m.default.gray(d)} ${m.default.strikethrough(m.default.dim(i??""))}${i?`
29
+ `+m.default.gray(d):""}`;default:return`${e}${m.default.cyan(d)} ${n}
30
+ ${m.default.cyan(O)}
31
+ `}}}).prompt(),Pi=(t)=>{let e=t.active??"Yes",n=t.inactive??"No";return new ne({active:e,inactive:n,initialValue:t.initialValue??!0,render(){let i=`${m.default.gray(d)}
32
+ ${D(this.state)} ${t.message}
33
+ `,o=this.value?e:n;switch(this.state){case"submit":return`${i}${m.default.gray(d)} ${m.default.dim(o)}`;case"cancel":return`${i}${m.default.gray(d)} ${m.default.strikethrough(m.default.dim(o))}
34
+ ${m.default.gray(d)}`;default:return`${i}${m.default.cyan(d)} ${this.value?`${m.default.green(ce)} ${e}`:`${m.default.dim(le)} ${m.default.dim(e)}`} ${m.default.dim("/")} ${this.value?`${m.default.dim(le)} ${m.default.dim(n)}`:`${m.default.green(ce)} ${n}`}
35
+ ${m.default.cyan(O)}
36
+ `}}}).prompt()},Li=(t)=>{let e=(i,o)=>{let s=i.label??String(i.value);return o==="active"?`${m.default.green(ce)} ${s} ${i.hint?m.default.dim(`(${i.hint})`):""}`:o==="selected"?`${m.default.dim(s)}`:o==="cancelled"?`${m.default.strikethrough(m.default.dim(s))}`:`${m.default.dim(le)} ${m.default.dim(s)}`},n=0;return new dr({options:t.options,initialValue:t.initialValue,render(){let i=`${m.default.gray(d)}
37
+ ${D(this.state)} ${t.message}
38
+ `;switch(this.state){case"submit":return`${i}${m.default.gray(d)} ${e(this.options[this.cursor],"selected")}`;case"cancel":return`${i}${m.default.gray(d)} ${e(this.options[this.cursor],"cancelled")}
39
+ ${m.default.gray(d)}`;default:{let o=t.maxItems===void 0?1/0:Math.max(t.maxItems,5);this.cursor>=n+o-3?n=Math.max(Math.min(this.cursor-o+3,this.options.length-o),0):this.cursor<n+2&&(n=Math.max(this.cursor-2,0));let s=o<this.options.length&&n>0,r=o<this.options.length&&n+o<this.options.length;return`${i}${m.default.cyan(d)} ${this.options.slice(n,n+o).map((a,p,u)=>p===0&&s?m.default.dim("..."):p===u.length-1&&r?m.default.dim("..."):e(a,p+n===this.cursor?"active":"inactive")).join(`
40
+ ${m.default.cyan(d)} `)}
41
+ ${m.default.cyan(O)}
42
+ `}}}}).prompt()},Fi=(t)=>{let e=(n,i="inactive")=>{let o=n.label??String(n.value);return i==="selected"?`${m.default.dim(o)}`:i==="cancelled"?`${m.default.strikethrough(m.default.dim(o))}`:i==="active"?`${m.default.bgCyan(m.default.gray(` ${n.value} `))} ${o} ${n.hint?m.default.dim(`(${n.hint})`):""}`:`${m.default.gray(m.default.bgWhite(m.default.inverse(` ${n.value} `)))} ${o} ${n.hint?m.default.dim(`(${n.hint})`):""}`};return new se({options:t.options,initialValue:t.initialValue,render(){let n=`${m.default.gray(d)}
43
+ ${D(this.state)} ${t.message}
44
+ `;switch(this.state){case"submit":return`${n}${m.default.gray(d)} ${e(this.options.find((i)=>i.value===this.value),"selected")}`;case"cancel":return`${n}${m.default.gray(d)} ${e(this.options[0],"cancelled")}
45
+ ${m.default.gray(d)}`;default:return`${n}${m.default.cyan(d)} ${this.options.map((i,o)=>e(i,o===this.cursor?"active":"inactive")).join(`
46
+ ${m.default.cyan(d)} `)}
47
+ ${m.default.cyan(O)}
48
+ `}}}).prompt()},Di=(t)=>{let e=(n,i)=>{let o=n.label??String(n.value);return i==="active"?`${m.default.cyan($e)} ${o} ${n.hint?m.default.dim(`(${n.hint})`):""}`:i==="selected"?`${m.default.green(ct)} ${m.default.dim(o)}`:i==="cancelled"?`${m.default.strikethrough(m.default.dim(o))}`:i==="active-selected"?`${m.default.green(ct)} ${o} ${n.hint?m.default.dim(`(${n.hint})`):""}`:i==="submitted"?`${m.default.dim(o)}`:`${m.default.dim(vr)} ${m.default.dim(o)}`};return new xr({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(n){if(this.required&&n.length===0)return`Please select at least one option.
49
+ ${m.default.reset(m.default.dim(`Press ${m.default.gray(m.default.bgWhite(m.default.inverse(" space ")))} to select, ${m.default.gray(m.default.bgWhite(m.default.inverse(" enter ")))} to submit`))}`},render(){let n=`${m.default.gray(d)}
50
+ ${D(this.state)} ${t.message}
51
+ `;switch(this.state){case"submit":return`${n}${m.default.gray(d)} ${this.options.filter(({value:i})=>this.value.includes(i)).map((i)=>e(i,"submitted")).join(m.default.dim(", "))||m.default.dim("none")}`;case"cancel":{let i=this.options.filter(({value:o})=>this.value.includes(o)).map((o)=>e(o,"cancelled")).join(m.default.dim(", "));return`${n}${m.default.gray(d)} ${i.trim()?`${i}
52
+ ${m.default.gray(d)}`:""}`}case"error":{let i=this.error.split(`
53
+ `).map((o,s)=>s===0?`${m.default.yellow(O)} ${m.default.yellow(o)}`:` ${o}`).join(`
54
+ `);return n+m.default.yellow(d)+" "+this.options.map((o,s)=>{let r=this.value.includes(o.value),a=s===this.cursor;return a&&r?e(o,"active-selected"):r?e(o,"selected"):e(o,a?"active":"inactive")}).join(`
55
+ ${m.default.yellow(d)} `)+`
56
+ `+i+`
57
+ `}default:return`${n}${m.default.cyan(d)} ${this.options.map((i,o)=>{let s=this.value.includes(i.value),r=o===this.cursor;return r&&s?e(i,"active-selected"):s?e(i,"selected"):e(i,r?"active":"inactive")}).join(`
58
+ ${m.default.cyan(d)} `)}
59
+ ${m.default.cyan(O)}
60
+ `}}}).prompt()},to=(t)=>{let e=(n,i,o=[])=>{let s=n.label??String(n.value),r=typeof n.group=="string",a=r&&(o[o.indexOf(n)+1]??{group:!0}),p=r&&a.group===!0,u=r?`${p?O:d} `:"";return i==="active"?`${m.default.dim(u)}${m.default.cyan($e)} ${s} ${n.hint?m.default.dim(`(${n.hint})`):""}`:i==="group-active"?`${u}${m.default.cyan($e)} ${m.default.dim(s)}`:i==="group-active-selected"?`${u}${m.default.green(ct)} ${m.default.dim(s)}`:i==="selected"?`${m.default.dim(u)}${m.default.green(ct)} ${m.default.dim(s)}`:i==="cancelled"?`${m.default.strikethrough(m.default.dim(s))}`:i==="active-selected"?`${m.default.dim(u)}${m.default.green(ct)} ${s} ${n.hint?m.default.dim(`(${n.hint})`):""}`:i==="submitted"?`${m.default.dim(s)}`:`${m.default.dim(u)}${m.default.dim(vr)} ${m.default.dim(s)}`};return new ie({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(n){if(this.required&&n.length===0)return`Please select at least one option.
61
+ ${m.default.reset(m.default.dim(`Press ${m.default.gray(m.default.bgWhite(m.default.inverse(" space ")))} to select, ${m.default.gray(m.default.bgWhite(m.default.inverse(" enter ")))} to submit`))}`},render(){let n=`${m.default.gray(d)}
62
+ ${D(this.state)} ${t.message}
63
+ `;switch(this.state){case"submit":return`${n}${m.default.gray(d)} ${this.options.filter(({value:i})=>this.value.includes(i)).map((i)=>e(i,"submitted")).join(m.default.dim(", "))}`;case"cancel":{let i=this.options.filter(({value:o})=>this.value.includes(o)).map((o)=>e(o,"cancelled")).join(m.default.dim(", "));return`${n}${m.default.gray(d)} ${i.trim()?`${i}
64
+ ${m.default.gray(d)}`:""}`}case"error":{let i=this.error.split(`
65
+ `).map((o,s)=>s===0?`${m.default.yellow(O)} ${m.default.yellow(o)}`:` ${o}`).join(`
66
+ `);return`${n}${m.default.yellow(d)} ${this.options.map((o,s,r)=>{let a=this.value.includes(o.value)||o.group===!0&&this.isGroupSelected(`${o.value}`),p=s===this.cursor;return!p&&typeof o.group=="string"&&this.options[this.cursor].value===o.group?e(o,a?"group-active-selected":"group-active",r):p&&a?e(o,"active-selected",r):a?e(o,"selected",r):e(o,p?"active":"inactive",r)}).join(`
67
+ ${m.default.yellow(d)} `)}
68
+ ${i}
69
+ `}default:return`${n}${m.default.cyan(d)} ${this.options.map((i,o,s)=>{let r=this.value.includes(i.value)||i.group===!0&&this.isGroupSelected(`${i.value}`),a=o===this.cursor;return!a&&typeof i.group=="string"&&this.options[this.cursor].value===i.group?e(i,r?"group-active-selected":"group-active",s):a&&r?e(i,"active-selected",s):r?e(i,"selected",s):e(i,a?"active":"inactive",s)}).join(`
70
+ ${m.default.cyan(d)} `)}
71
+ ${m.default.cyan(O)}
72
+ `}}}).prompt()},pe=(t)=>t.replace(so(),""),eo=(t="",e="")=>{let n=`
73
73
  ${t}
74
74
  `.split(`
75
- `),r=oe(e).length,o=Math.max(i.reduce((n,m)=>(m=oe(m),m.length>n?m.length:n),0),r)+2,s=i.map((n)=>`${p.default.gray(x)} ${p.default.dim(n)}${" ".repeat(o-oe(n).length)}${p.default.gray(x)}`).join(`
76
- `);process.stdout.write(`${p.default.gray(x)}
77
- ${p.default.green(Mt)} ${p.default.reset(e)} ${p.default.gray(hn.repeat(Math.max(o-r-1,1))+Br)}
75
+ `),i=pe(e).length,o=Math.max(n.reduce((r,a)=>(a=pe(a),a.length>r?a.length:r),0),i)+2,s=n.map((r)=>`${m.default.gray(d)} ${m.default.dim(r)}${" ".repeat(o-pe(r).length)}${m.default.gray(d)}`).join(`
76
+ `);process.stdout.write(`${m.default.gray(d)}
77
+ ${m.default.green(Ot)} ${m.default.reset(e)} ${m.default.gray(wr.repeat(Math.max(o-i-1,1))+Xi)}
78
78
  ${s}
79
- ${p.default.gray(Ir+hn.repeat(o+2)+zr)}
80
- `)},Er=(t="")=>{process.stdout.write(`${p.default.gray(T)} ${p.default.red(t)}
79
+ ${m.default.gray(Qi+wr.repeat(o+2)+Vi)}
80
+ `)},ro=(t="")=>{process.stdout.write(`${m.default.gray(O)} ${m.default.red(t)}
81
81
 
82
- `)},Lr=(t="")=>{process.stdout.write(`${p.default.gray(Gr)} ${t}
83
- `)},Fr=(t="")=>{process.stdout.write(`${p.default.gray(x)}
84
- ${p.default.gray(T)} ${t}
82
+ `)},no=(t="")=>{process.stdout.write(`${m.default.gray(Yi)} ${t}
83
+ `)},io=(t="")=>{process.stdout.write(`${m.default.gray(d)}
84
+ ${m.default.gray(O)} ${t}
85
85
 
86
- `)},L,Dr=()=>{let t=se?["◒","◐","◓","◑"]:["•","o","O","0"],e=se?80:120,i,r,o=!1,s="",n=(y="")=>{o=!0,i=xn(),s=y.replace(/\.+$/,""),process.stdout.write(`${p.default.gray(x)}
87
- `);let $=0,h=0;r=setInterval(()=>{let w=p.default.magenta(t[$]),f=".".repeat(Math.floor(h)).slice(0,3);process.stdout.write(ot.cursor.move(-999,0)),process.stdout.write(ot.erase.down(1)),process.stdout.write(`${w} ${s}${f}`),$=$+1<t.length?$+1:0,h=h<t.length?h+0.125:0},e)},m=(y="",$=0)=>{s=y??s,o=!1,clearInterval(r);let h=$===0?p.default.green(Mt):$===1?p.default.red(wn):p.default.red(bn);process.stdout.write(ot.cursor.move(-999,0)),process.stdout.write(ot.erase.down(1)),process.stdout.write(`${h} ${s}
88
- `),i()},a=(y="")=>{s=y??s},u=(y)=>{let $=y>1?"Something went wrong":"Canceled";o&&m($,y)};return process.on("uncaughtExceptionMonitor",()=>u(2)),process.on("unhandledRejection",()=>u(2)),process.on("SIGINT",()=>u(1)),process.on("SIGTERM",()=>u(1)),process.on("exit",u),{start:n,stop:m,message:a}},eo=async(t,e)=>{let i={},r=Object.keys(t);for(let o of r){let s=t[o],n=await s({results:i})?.catch((m)=>{throw m});if(typeof e?.onCancel=="function"&&jt(n)){i[o]="canceled",e.onCancel({results:i});continue}i[o]=n}return i};var Tt=ye(()=>{re();re();p=xt(Ct(),1),ot=xt(Ht(),1);se=Tr(),Or=R("◆","*"),wn=R("■","x"),bn=R("▲","x"),Mt=R("◇","o"),Gr=R("┌","T"),x=R("│","|"),T=R("└","—"),pe=R("●",">"),me=R("○"," "),ae=R("◻","[•]"),ut=R("◼","[+]"),dn=R("◻","[ ]"),Nr=R("▪","•"),hn=R("─","-"),Br=R("╮","+"),Ir=R("├","+"),zr=R("╯","+"),Jr=R("●","•"),Yr=R("◆","*"),Kr=R("▲","!"),Xr=R("■","x"),L={message:(t="",{symbol:e=p.default.gray(x)}={})=>{let i=[`${p.default.gray(x)}`];if(t){let[r,...o]=t.split(`
89
- `);i.push(`${e} ${r}`,...o.map((s)=>`${p.default.gray(x)} ${s}`))}process.stdout.write(`${i.join(`
86
+ `)},F,oo=()=>{let t=ue?["◒","◐","◓","◑"]:["•","o","O","0"],e=ue?80:120,n,i,o=!1,s="",r=(y="")=>{o=!0,n=hr(),s=y.replace(/\.+$/,""),process.stdout.write(`${m.default.gray(d)}
87
+ `);let c=0,x=0;i=setInterval(()=>{let w=m.default.magenta(t[c]),_=".".repeat(Math.floor(x)).slice(0,3);process.stdout.write(ot.cursor.move(-999,0)),process.stdout.write(ot.erase.down(1)),process.stdout.write(`${w} ${s}${_}`),c=c+1<t.length?c+1:0,x=x<t.length?x+0.125:0},e)},a=(y="",c=0)=>{s=y??s,o=!1,clearInterval(i);let x=c===0?m.default.green(Ot):c===1?m.default.red(br):m.default.red(fr);process.stdout.write(ot.cursor.move(-999,0)),process.stdout.write(ot.erase.down(1)),process.stdout.write(`${x} ${s}
88
+ `),n()},p=(y="")=>{s=y??s},u=(y)=>{let c=y>1?"Something went wrong":"Canceled";o&&a(c,y)};return process.on("uncaughtExceptionMonitor",()=>u(2)),process.on("unhandledRejection",()=>u(2)),process.on("SIGINT",()=>u(1)),process.on("SIGTERM",()=>u(1)),process.on("exit",u),{start:r,stop:a,message:p}},ao=async(t,e)=>{let n={},i=Object.keys(t);for(let o of i){let s=t[o],r=await s({results:n})?.catch((a)=>{throw a});if(typeof e?.onCancel=="function"&&Tt(r)){n[o]="canceled",e.onCancel({results:n});continue}n[o]=r}return n};var Nt=Kt(()=>{me();me();m=ht(Ft(),1),ot=ht(Pt(),1);ue=Ji(),zi=g("◆","*"),br=g("■","x"),fr=g("▲","x"),Ot=g("◇","o"),Yi=g("┌","T"),d=g("│","|"),O=g("└","—"),ce=g("●",">"),le=g("○"," "),$e=g("◻","[•]"),ct=g("◼","[+]"),vr=g("◻","[ ]"),Ki=g("▪","•"),wr=g("─","-"),Xi=g("╮","+"),Qi=g("├","+"),Vi=g("╯","+"),Zi=g("●","•"),Ui=g("◆","*"),Wi=g("▲","!"),Hi=g("■","x"),F={message:(t="",{symbol:e=m.default.gray(d)}={})=>{let n=[`${m.default.gray(d)}`];if(t){let[i,...o]=t.split(`
89
+ `);n.push(`${e} ${i}`,...o.map((s)=>`${m.default.gray(d)} ${s}`))}process.stdout.write(`${n.join(`
90
90
  `)}
91
- `)},info:(t)=>{L.message(t,{symbol:p.default.blue(Jr)})},success:(t)=>{L.message(t,{symbol:p.default.green(Yr)})},step:(t)=>{L.message(t,{symbol:p.default.green(Mt)})},warn:(t)=>{L.message(t,{symbol:p.default.yellow(Kr)})},warning:(t)=>{L.warn(t)},error:(t)=>{L.message(t,{symbol:p.default.red(Xr)})}}});function zt(t){return t.replace(/-([a-z])/g,(e,i)=>i.toUpperCase())}function wi(t){let e=t.flag.match(/^--([a-z][a-z0-9-]*)/i);return e?zt(e[1]):null}function bi(t){if(t.type==="boolean")return!0;if(t.type==="string"||t.type==="number"||t.type==="array")return!1;return!t.flag.includes("<")&&!t.flag.includes("[")}function xe(t){let e=new Set,i=new Set,r=new Set;for(let o of t){let s=wi(o);if(!s)continue;if(bi(o))e.add(s);else if(o.type==="number")i.add(s);else if(o.type==="array")r.add(s)}return{booleans:e,numbers:i,arrays:r}}function he(t,e=[]){let i=xe(e),r=[],o=0;while(o<t.length){let s=t[o];if(s==="--")break;if(s.startsWith("--")){let n=s.indexOf("="),m=n!==-1?s.slice(2,n):s.slice(2),a=zt(m);if(!i.booleans.has(a)&&n===-1)o+=2;else o+=1;continue}if(s.startsWith("-")){o++;continue}r.push(s),o++}return r}function Jt(t,e){let i=xe(e),r={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},o=0;while(o<t.length){let s=t[o];if(s==="--help"||s==="-h"){r.help=!0,o++;continue}if(s==="--")break;if(s.startsWith("--")){let n=s.indexOf("="),m,a;if(n!==-1)m=s.slice(2,n),a=s.slice(n+1);else m=s.slice(2);let u=zt(m);if(i.booleans.has(u)){r[u]=!0,o++;continue}if(a===void 0)o++,a=t[o];if(a===void 0)throw Error(`Flag --${m} requires a value.`);if(i.arrays.has(u)){let y=r[u];if(y)y.push(a);else r[u]=[a]}else if(i.numbers.has(u))r[u]=Number(a);else r[u]=a}o++}return r}var l={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONTENT_FILTER:10};class c extends Error{exitCode;hint;constructor(t,e=l.GENERAL,i){super(t);this.name="CLIError",this.exitCode=e,this.hint=i}toJSON(){return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{}}}}}function d(t){return{name:t.name,description:t.description,usage:t.usage,options:t.options,examples:t.examples,execute:t.run}}var ht=[{flag:"--api-key <key>",description:"API key"},{flag:"--region <region>",description:"API region: global, cn"},{flag:"--base-url <url>",description:"API base URL"},{flag:"--output <format>",description:"Output format: text, json"},{flag:"--timeout <seconds>",description:"Request timeout",type:"number"},{flag:"--quiet",description:"Suppress non-essential output"},{flag:"--verbose",description:"Print HTTP request/response details"},{flag:"--no-color",description:"Disable ANSI colors"},{flag:"--dry-run",description:"Dry run mode"},{flag:"--non-interactive",description:"Disable interactive prompts"},{flag:"--help",description:"Show help"},{flag:"--version",description:"Print version"}];import{readFileSync as vi,writeFileSync as fi,renameSync as Si,unlinkSync as Ri,existsSync as we,statSync as ki}from"fs";import{homedir as di}from"os";import{join as Yt}from"path";var _i=".mmx";function mt(){return Yt(di(),_i)}function X(){return Yt(mt(),"config.json")}function wt(){return Yt(mt(),"credentials.json")}async function bt(){let t=mt();await(await import("fs/promises")).mkdir(t,{recursive:!0,mode:448})}async function B(){let t=wt();if(!we(t))return null;try{gi(t);let e=vi(t,"utf-8"),i=JSON.parse(e);if(!i.access_token||!i.refresh_token)return null;return i}catch(e){let i=e;if(i instanceof SyntaxError||i.message.includes("JSON"))process.stderr.write(`Warning: credentials file is corrupted. Run 'mmx auth logout' to reset.
92
- `);return null}}async function it(t){await bt();let e=wt(),i=e+".tmp";fi(i,JSON.stringify(t,null,2)+`
93
- `,{mode:384}),Si(i,e)}async function be(){let t=wt();if(we(t))Ri(t)}function gi(t){try{let i=ki(t).mode&511;if(i!==384)process.stderr.write(`Warning: ${t} has permissions ${i.toString(8)}, expected 600.
94
- `)}catch{}}var de={clientId:"mmx-cli",authorizationUrl:"https://platform.minimax.io/oauth/authorize",tokenUrl:"https://api.minimax.io/v1/oauth/token",deviceCodeUrl:"https://api.minimax.io/v1/oauth/device/code",scopes:["api"],callbackPort:18991};async function _e(t=de){let{randomBytes:e,createHash:i}=await import("crypto"),r=e(32).toString("base64url"),o=i("sha256").update(r).digest("base64url"),s=e(16).toString("hex"),n=new URLSearchParams({client_id:t.clientId,response_type:"code",redirect_uri:`http://localhost:${t.callbackPort}/callback`,scope:t.scopes.join(" "),state:s,code_challenge:o,code_challenge_method:"S256"}),m=`${t.authorizationUrl}?${n}`,{exec:a}=await import("child_process"),u=process.platform;a(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} "${m}"`),process.stderr.write(`Opening browser to authenticate with MiniMax...
95
- `);let $=await Ai(t.callbackPort,s),h=await fetch(t.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:$,client_id:t.clientId,redirect_uri:`http://localhost:${t.callbackPort}/callback`,code_verifier:r})});if(!h.ok){let w=await h.text();throw new c(`OAuth token exchange failed: ${w}`,l.AUTH)}return await h.json()}async function Ai(t,e){return new Promise((i,r)=>{let o=setTimeout(()=>{s.stop(),r(new c("OAuth callback timed out.",l.TIMEOUT))},120000),s=Bun.serve({port:t,fetch(n){let m=new URL(n.url);if(m.pathname!=="/callback")return new Response("Not found",{status:404});let a=m.searchParams.get("code"),u=m.searchParams.get("state"),y=m.searchParams.get("error");if(y)return clearTimeout(o),s.stop(),r(new c(`OAuth error: ${y}`,l.AUTH)),new Response("<html><body><h1>Authentication Failed</h1><p>You can close this tab.</p></body></html>",{headers:{"Content-Type":"text/html"}});if(!a||u!==e)return clearTimeout(o),s.stop(),r(new c("Invalid OAuth callback.",l.AUTH)),new Response("Invalid callback",{status:400});return clearTimeout(o),s.stop(),i(a),new Response("<html><body><h1>Authentication Successful</h1><p>You can close this tab.</p></body></html>",{headers:{"Content-Type":"text/html"}})}})})}async function ve(t=de){let e=await fetch(t.deviceCodeUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:t.clientId,scope:t.scopes.join(" ")})});if(!e.ok)throw new c("Failed to start device code flow.",l.AUTH);let{device_code:i,user_code:r,verification_uri:o,interval:s,expires_in:n}=await e.json();process.stderr.write(`
91
+ `)},info:(t)=>{F.message(t,{symbol:m.default.blue(Zi)})},success:(t)=>{F.message(t,{symbol:m.default.green(Ui)})},step:(t)=>{F.message(t,{symbol:m.default.green(Ot)})},warn:(t)=>{F.message(t,{symbol:m.default.yellow(Wi)})},warning:(t)=>{F.warn(t)},error:(t)=>{F.message(t,{symbol:m.default.red(Hi)})}}});var qr={};we(qr,{readTextFromPathOrStdin:()=>lt});import{readFileSync as co}from"fs";function lt(t){return co(t==="-"?"/dev/stdin":t,"utf-8")}var It=()=>{};function Xt(t){return t.replace(/-([a-z])/g,(e,n)=>n.toUpperCase())}function Sn(t){let e=t.flag.match(/^--([a-z][a-z0-9-]*)/i);return e?Xt(e[1]):null}function Rn(t){if(t.type==="boolean")return!0;if(t.type==="string"||t.type==="number"||t.type==="array")return!1;return!t.flag.includes("<")&&!t.flag.includes("[")}function be(t){let e=new Set,n=new Set,i=new Set;for(let o of t){let s=Sn(o);if(!s)continue;if(Rn(o))e.add(s);else if(o.type==="number")n.add(s);else if(o.type==="array")i.add(s)}return{booleans:e,numbers:n,arrays:i}}function fe(t,e=[]){let n=be(e),i=[],o=0;while(o<t.length){let s=t[o];if(s==="--")break;if(s.startsWith("--")){let r=s.indexOf("="),a=r!==-1?s.slice(2,r):s.slice(2),p=Xt(a);if(!n.booleans.has(p)&&r===-1)o+=2;else o+=1;continue}if(s.startsWith("-")){o++;continue}i.push(s),o++}return i}function Qt(t,e){let n=be(e),i={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},o=0;while(o<t.length){let s=t[o];if(s==="--help"||s==="-h"){i.help=!0,o++;continue}if(s==="--")break;if(s.startsWith("--")){let r=s.indexOf("="),a,p;if(r!==-1)a=s.slice(2,r),p=s.slice(r+1);else a=s.slice(2);let u=Xt(a);if(n.booleans.has(u)){i[u]=!0,o++;continue}if(p===void 0)o++,p=t[o];if(p===void 0)throw Error(`Flag --${a} requires a value.`);if(n.arrays.has(u)){let y=i[u];if(y)y.push(p);else i[u]=[p]}else if(n.numbers.has(u))i[u]=Number(p);else i[u]=p}o++}return i}var l={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONTENT_FILTER:10};class $ extends Error{exitCode;hint;constructor(t,e=l.GENERAL,n){super(t);this.name="CLIError",this.exitCode=e,this.hint=n}toJSON(){return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{}}}}}function b(t){return{name:t.name,description:t.description,usage:t.usage,options:t.options,examples:t.examples,execute:t.run}}var wt=[{flag:"--api-key <key>",description:"API key"},{flag:"--region <region>",description:"API region: global, cn"},{flag:"--base-url <url>",description:"API base URL"},{flag:"--output <format>",description:"Output format: text, json"},{flag:"--timeout <seconds>",description:"Request timeout",type:"number"},{flag:"--quiet",description:"Suppress non-essential output"},{flag:"--verbose",description:"Print HTTP request/response details"},{flag:"--no-color",description:"Disable ANSI colors"},{flag:"--dry-run",description:"Dry run mode"},{flag:"--non-interactive",description:"Disable interactive prompts"},{flag:"--help",description:"Show help"},{flag:"--version",description:"Print version"}];import{readFileSync as An,writeFileSync as jn,renameSync as qn,unlinkSync as Mn,existsSync as ve,statSync as Tn}from"fs";import{homedir as kn}from"os";import{join as Vt}from"path";var gn=".mmx";function pt(){return Vt(kn(),gn)}function V(){return Vt(pt(),"config.json")}function bt(){return Vt(pt(),"credentials.json")}async function ft(){let t=pt();await(await import("fs/promises")).mkdir(t,{recursive:!0,mode:448})}async function I(){let t=bt();if(!ve(t))return null;try{On(t);let e=An(t,"utf-8"),n=JSON.parse(e);if(!n.access_token||!n.refresh_token)return null;return n}catch(e){let n=e;if(n instanceof SyntaxError||n.message.includes("JSON"))process.stderr.write(`Warning: credentials file is corrupted. Run 'mmx auth logout' to reset.
92
+ `);return null}}async function nt(t){await ft();let e=bt(),n=e+".tmp";jn(n,JSON.stringify(t,null,2)+`
93
+ `,{mode:384}),qn(n,e)}async function _e(){let t=bt();if(ve(t))Mn(t)}function On(t){try{let n=Tn(t).mode&511;if(n!==384)process.stderr.write(`Warning: ${t} has permissions ${n.toString(8)}, expected 600.
94
+ `)}catch{}}var Se={clientId:"mmx-cli",authorizationUrl:"https://platform.minimax.io/oauth/authorize",tokenUrl:"https://api.minimax.io/v1/oauth/token",deviceCodeUrl:"https://api.minimax.io/v1/oauth/device/code",scopes:["api"],callbackPort:18991};async function Re(t=Se){let{randomBytes:e,createHash:n}=await import("crypto"),i=e(32).toString("base64url"),o=n("sha256").update(i).digest("base64url"),s=e(16).toString("hex"),r=new URLSearchParams({client_id:t.clientId,response_type:"code",redirect_uri:`http://localhost:${t.callbackPort}/callback`,scope:t.scopes.join(" "),state:s,code_challenge:o,code_challenge_method:"S256"}),a=`${t.authorizationUrl}?${r}`,{exec:p}=await import("child_process"),u=process.platform;p(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} "${a}"`),process.stderr.write(`Opening browser to authenticate with MiniMax...
95
+ `);let c=await Gn(t.callbackPort,s),x=await fetch(t.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:c,client_id:t.clientId,redirect_uri:`http://localhost:${t.callbackPort}/callback`,code_verifier:i})});if(!x.ok){let w=await x.text();throw new $(`OAuth token exchange failed: ${w}`,l.AUTH)}return await x.json()}async function Gn(t,e){return new Promise((n,i)=>{let o=setTimeout(()=>{s.stop(),i(new $("OAuth callback timed out.",l.TIMEOUT))},120000),s=Bun.serve({port:t,fetch(r){let a=new URL(r.url);if(a.pathname!=="/callback")return new Response("Not found",{status:404});let p=a.searchParams.get("code"),u=a.searchParams.get("state"),y=a.searchParams.get("error");if(y)return clearTimeout(o),s.stop(),i(new $(`OAuth error: ${y}`,l.AUTH)),new Response("<html><body><h1>Authentication Failed</h1><p>You can close this tab.</p></body></html>",{headers:{"Content-Type":"text/html"}});if(!p||u!==e)return clearTimeout(o),s.stop(),i(new $("Invalid OAuth callback.",l.AUTH)),new Response("Invalid callback",{status:400});return clearTimeout(o),s.stop(),n(p),new Response("<html><body><h1>Authentication Successful</h1><p>You can close this tab.</p></body></html>",{headers:{"Content-Type":"text/html"}})}})})}async function ke(t=Se){let e=await fetch(t.deviceCodeUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:t.clientId,scope:t.scopes.join(" ")})});if(!e.ok)throw new $("Failed to start device code flow.",l.AUTH);let{device_code:n,user_code:i,verification_uri:o,interval:s,expires_in:r}=await e.json();process.stderr.write(`
96
96
  Visit: ${o}
97
- `),process.stderr.write(`Enter code: ${r}
97
+ `),process.stderr.write(`Enter code: ${i}
98
98
  `),process.stderr.write(`Waiting for authorization...
99
- `);let m=Date.now()+n*1000,a=(s||5)*1000;while(Date.now()<m){await new Promise(($)=>setTimeout($,a));let u=await fetch(t.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:i,client_id:t.clientId})});if(u.ok)return await u.json();let y=await u.json();if(y.error==="authorization_pending")continue;if(y.error==="slow_down"){await new Promise(($)=>setTimeout($,5000));continue}throw new c(`Device code authorization failed: ${y.error}`,l.AUTH)}throw new c("Device code authorization timed out.",l.TIMEOUT)}var ji="https://api.minimax.io/v1/oauth/token";async function Kt(t){let e=await fetch(ji,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:t})});if(!e.ok)throw new c("OAuth session expired and could not be refreshed.",l.AUTH,"Re-authenticate: mmx auth login");return await e.json()}async function fe(t){let e=new Date(t.expires_at).getTime(),i=300000;if(Date.now()<e-300000)return t.access_token;let r=await Kt(t.refresh_token),o={access_token:r.access_token,refresh_token:r.refresh_token,expires_at:new Date(Date.now()+r.expires_in*1000).toISOString(),token_type:"Bearer",account:t.account};return await it(o),o.access_token}async function dt(t){if(t.apiKey)return{token:t.apiKey,method:"api-key",source:"flag"};let e=await B();if(e)return{token:await fe(e),method:"oauth",source:"credentials.json"};if(t.fileApiKey)return{token:t.fileApiKey,method:"api-key",source:"config.json"};throw new c("No credentials found.",l.AUTH,`Log in: mmx auth login
100
- Pass directly: --api-key sk-xxxxx`)}function Se(t){if(!t)return"";if(t.includes("/t2a"))return`
99
+ `);let a=Date.now()+r*1000,p=(s||5)*1000;while(Date.now()<a){await new Promise((c)=>setTimeout(c,p));let u=await fetch(t.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:n,client_id:t.clientId})});if(u.ok)return await u.json();let y=await u.json();if(y.error==="authorization_pending")continue;if(y.error==="slow_down"){await new Promise((c)=>setTimeout(c,5000));continue}throw new $(`Device code authorization failed: ${y.error}`,l.AUTH)}throw new $("Device code authorization timed out.",l.TIMEOUT)}var Nn="https://api.minimax.io/v1/oauth/token";async function Zt(t){let e=await fetch(Nn,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:t})});if(!e.ok)throw new $("OAuth session expired and could not be refreshed.",l.AUTH,"Re-authenticate: mmx auth login");return await e.json()}async function ge(t){let e=new Date(t.expires_at).getTime(),n=300000;if(Date.now()<e-300000)return t.access_token;let i=await Zt(t.refresh_token),o={access_token:i.access_token,refresh_token:i.refresh_token,expires_at:new Date(Date.now()+i.expires_in*1000).toISOString(),token_type:"Bearer",account:t.account};return await nt(o),o.access_token}async function vt(t){if(t.apiKey)return{token:t.apiKey,method:"api-key",source:"flag"};let e=await I();if(e)return{token:await ge(e),method:"oauth",source:"credentials.json"};if(t.fileApiKey)return{token:t.fileApiKey,method:"api-key",source:"config.json"};throw new $("No credentials found.",l.AUTH,`Log in: mmx auth login
100
+ Pass directly: --api-key sk-xxxxx`)}function Ae(t){if(!t)return"";if(t.includes("/t2a"))return`
101
101
 
102
102
  Speech models require the Plus plan or above.`;if(t.includes("/image_generation"))return`
103
103
 
@@ -105,95 +105,96 @@ image-01 requires the Plus plan or above.`;if(t.includes("/video_generation")||t
105
105
 
106
106
  Video models (Hailuo-2.3 / 2.3-Fast) require the Max plan or above.`;if(t.includes("/music_generation"))return`
107
107
 
108
- Music-2.5 requires the Max plan or above.`;return""}function Re(t){return`${t?.includes("minimaxi.com")?"https://platform.minimaxi.com":"https://platform.minimax.io"}/subscribe/token-plan`}function Xt(t,e,i){let r=e.base_resp?.status_msg||e.error?.message||`HTTP ${t}`,o=e.base_resp?.status_code||e.error?.code;if(t===401||t===403)return new c(`API key rejected (HTTP ${t}).`,l.AUTH,`Check status: mmx auth status
109
- Re-authenticate: mmx auth login`);if(t===429)return new c(`Rate limit or quota exceeded. ${r}`,l.QUOTA,"Check usage: mmx quota show");if(t===408||t===504)return new c(`Request timed out (HTTP ${t}).`,l.TIMEOUT,"Try increasing --timeout or retry later.");if(o===1002||o===1039){let s=e.base_resp?.status_msg||"content sensitivity";return new c(`Input content flagged by sensitivity filter (${s}).`,l.CONTENT_FILTER)}if(o===1028||o===1030){let s=Se(i);return new c(`Quota exhausted. ${r}`,l.QUOTA,`Check usage: mmx quota show${s}
110
- Upgrade plan: ${Re(i)}`)}if(o===2061){let s=Se(i);return new c(`This model is not available on your current Token Plan. ${r}`,l.QUOTA,`Check usage: mmx quota show${s}
111
- Upgrade plan: ${Re(i)}`)}return new c(`API error: ${r} (HTTP ${t})`,l.GENERAL)}import{homedir as ke}from"os";function I(t){return t.length>8?`${t.slice(0,4)}...${t.slice(-4)}`:"***"}var ge=!1;var G="\x1B[0m",Q="\x1B[2m",Mi="\x1B[1m",qi="\x1B[38;2;43;82;255m",Ti="\x1B[38;2;147;51;234m",Oi="\x1B[38;2;6;184;212m",Gi="\x1B[38;2;236;72;153m";function Ni(t){return t.startsWith(ke())?t.replace(ke(),"~"):t}function Ae(t,e,i){if(t.quiet||ge||!process.stderr.isTTY)return;ge=!0;let r=t.configPath?Ni(t.configPath):"~/.mmx/config.json",o=t.fileRegion?`${t.fileRegion} (file)`:"global (default)",s=t.apiKey?"(flag)":"(file)",n=I(e),m=i?` ${Q}|${G} ${Q}Model:${G} ${Ti}${i}${G}`:"";process.stderr.write(`${Mi}${qi}MINIMAX${G} ${Q}${r}${G} ${Q}|${G} ${Q}Region:${G} ${Oi}${o}${G} ${Q}|${G} ${Q}Key:${G} ${Gi}${n}${G} ${Q}${s}${G}${m}
112
- `)}async function C(t,e){let i=typeof FormData<"u"&&e.body instanceof FormData,r="1.0.5",o={"User-Agent":"mmx-cli/1.0.5",...e.headers};if(!i&&!o["Content-Type"])o["Content-Type"]="application/json";if(!e.noAuth){let m=await dt(t);if(e.authStyle==="x-api-key")o["x-api-key"]=m.token;else o.Authorization=`Bearer ${m.token}`;if(t.verbose)process.stderr.write(`> ${e.method??"GET"} ${e.url}
113
- `),process.stderr.write(`> Auth: ${m.token.slice(0,8)}...
114
- `);let a=e.body&&typeof e.body==="object"&&"model"in e.body?String(e.body.model):void 0;Ae(t,m.token,a)}let s=(e.timeout??t.timeout)*1000,n=await fetch(e.url,{method:e.method??"GET",headers:o,body:e.body?i?e.body:JSON.stringify(e.body):void 0,signal:AbortSignal.timeout(s)});if(t.verbose)process.stderr.write(`< ${n.status} ${n.statusText}
115
- `);if(!n.ok){let m={};try{m=await n.json()}catch{}throw Xt(n.status,m,e.url)}return n}async function v(t,e){let i=await C(t,e),r;try{r=await i.json()}catch{let o=i.headers.get("content-type")||"";throw new c(`API returned non-JSON response (${o||"unknown type"}). Server may be experiencing issues.`,l.GENERAL)}if(r.base_resp?.status_code&&r.base_resp.status_code!==0)throw Xt(200,{base_resp:r.base_resp},e.url);return r}function je(t){return`${t}/anthropic/v1/messages`}function Me(t){return`${t}/v1/t2a_v2`}function qe(t){return`${t}/v1/get_voice`}function Te(t){return`${t}/v1/image_generation`}function Oe(t){return`${t}/v1/video_generation`}function _t(t,e){return`${t}/v1/query/video_generation?task_id=${e}`}function vt(t,e){return`${t}/v1/files/retrieve?file_id=${e}`}function Ge(t){return`${t}/v1/music_generation`}function Ne(t){return`${t}/v1/coding_plan/search`}function Be(t){return`${t}/v1/coding_plan/vlm`}function P(t){return`${t.includes("minimaxi.com")?"https://api.minimaxi.com":"https://api.minimax.io"}/v1/api/openplatform/coding_plan/remains`}function Je(t){if(t<50)return["\x1B[38;2;74;222;128m","\x1B[48;2;22;163;74m"];if(t<=80)return["\x1B[38;2;250;204;21m","\x1B[48;2;202;138;4m"];return["\x1B[38;2;248;113;113m","\x1B[48;2;220;38;38m"]}var Bi={dashboard:"TokenPlan Quota",week:"Week",weekly:"Weekly",resetsIn:"Resets in",noData:"No quota data available.",now:"now"},Ii={dashboard:"TokenPlan 配额面板",week:"周期",weekly:"每周",resetsIn:"重置于",noData:"暂无配额数据",now:"即将"};function zi(t,e){if(t<=0)return e;let i=Math.floor(t/3600000),r=Math.floor(t%3600000/60000);return i>0?`${i}h ${r}m`:`${r}m`}function Ie(t){return new Date(t).toISOString().slice(0,10)}function Ji(t){return t>=11904&&t<=40959||t>=63744&&t<=64255||t>=65072&&t<=65103||t>=65281&&t<=65376||t>=131072&&t<=195103}function V(t){let e=t.replace(/\x1b\[[0-9;]*m/g,""),i=0;for(let r of e)i+=Ji(r.codePointAt(0))?2:1;return i}var St=16;function ze(t,e){let i=Math.max(0,Math.min(100,t))/100,r=Math.round(St*i),o=St-r,s=`${t}%`.padStart(4);if(!e)return`[${"█".repeat(r)}${".".repeat(o)}] ${s}`;let[n,m]=Je(t);return`${m}${" ".repeat(r)}\x1B[0m\x1B[48;2;55;65;81m${" ".repeat(o)}\x1B[0m ${n}\x1B[1m${s}\x1B[0m`}function ft(t,e,i,r,o){return o?`\x1B[2m${e}${i.repeat(t)}${r}\x1B[0m`:`+${"-".repeat(t)}+`}function Qt(t,e,i,r){let o=Math.max(0,e-2-i);return r?`${"\x1B[2m"}│${"\x1B[0m"} ${t}${" ".repeat(o)} ${"\x1B[2m"}│${"\x1B[0m"}`:`| ${t}${" ".repeat(o)} |`}function rt(t,e){let i=!e.noColor&&process.stdout.isTTY===!0,r=e.region==="cn"?Ii:Bi,o=t.length>0?Math.max(...t.map((w)=>w.model_name.length)):16,s=i?St+5:St+7,n=Math.max(68,o+2+15+2+s+2),m=t.length>0?`${Ie(t[0].weekly_start_time)} — ${Ie(t[0].weekly_end_time)}`:"",a=`MINIMAX ${r.dashboard}`,u=`${r.week}: ${m}`,y=Math.max(2,n-2-V(a)-V(u)),$=i?`\x1B[1m\x1B[38;2;43;82;255mMINIMAX\x1B[0m \x1B[2m${r.dashboard}\x1B[0m${" ".repeat(y)}\x1B[2m${r.week}:\x1B[0m \x1B[38;2;6;184;212m${m}\x1B[0m`:`${a}${" ".repeat(y)}${u}`,h=V(a)+y+V(u);if(console.log(""),console.log(ft(n,"╭","─","╮",i)),console.log(Qt($,n,h,i)),t.length===0){console.log(ft(n,"╰","─","╯",i)),console.log(`
116
- ${r.noData}
117
- `);return}for(let w of t){console.log(ft(n,"├","─","┤",i));let{current_interval_usage_count:f,current_interval_total_count:g}=w,M=Math.max(0,g-f),J=g>0?Math.round(M/g*100):0,et=w.current_weekly_usage_count,q=w.current_weekly_total_count,k=Math.max(0,q-et),pt=zi(w.remains_time,r.now),$t=w.model_name.padEnd(o),lt=`${M.toLocaleString()} / ${g.toLocaleString()}`,ei=ze(J,i),ni=o+2+15+2+s,ii=i?`\x1B[1m\x1B[38;2;255;255;255m${$t}\x1B[0m ${Je(J)[0]}${lt.padStart(15)}\x1B[0m ${ei}`:`${$t} ${lt.padStart(15)} ${ze(J,!1)}`;console.log(Qt(ii,n,ni,i));let ct=`└ ${r.weekly} ${k.toLocaleString()} / ${q.toLocaleString()}`,yt=`${r.resetsIn} ${pt}`,Bt=Math.max(2,n-2-2-V(ct)-V(yt)),ri=2+V(ct)+Bt+V(yt),oi=i?` \x1B[2m${ct}${" ".repeat(Bt)}${yt}\x1B[0m`:` ${ct}${" ".repeat(Bt)}${yt}`;console.log(Qt(oi,n,ri,i))}console.log(ft(n,"╰","─","╯",i)),console.log("")}import{readFileSync as Qi,writeFileSync as Vi,renameSync as Zi,existsSync as Wi}from"fs";var Z={global:"https://api.minimax.io",cn:"https://api.minimaxi.com"},Yi=new Set(["global","cn"]),Ki=new Set(["text","json"]);function Ye(t){if(!t||typeof t!=="object"||Array.isArray(t))return{};let e=t,i={};if(typeof e.api_key==="string")i.api_key=e.api_key;if(typeof e.region==="string"&&Yi.has(e.region))i.region=e.region;if(typeof e.base_url==="string"&&e.base_url.startsWith("http"))i.base_url=e.base_url;if(typeof e.output==="string"&&Ki.has(e.output))i.output=e.output;if(typeof e.timeout==="number"&&e.timeout>0)i.timeout=e.timeout;return i}function Ke(t){if(t===null||t===void 0)return"";if(typeof t==="string")return t;if(typeof t==="number"||typeof t==="boolean")return String(t);if(Array.isArray(t)){if(t.length===0)return"(empty)";if(typeof t[0]==="object"&&t[0]!==null)return Xi(t);return t.map(String).join(`
118
- `)}if(typeof t==="object")return Vt(t);return String(t)}function Vt(t,e=0){let i=" ".repeat(e),r=[];for(let[o,s]of Object.entries(t)){if(s===null||s===void 0)continue;if(Array.isArray(s)){r.push(`${i}${o}:`);for(let n of s)if(typeof n==="object"&&n!==null)r.push(`${i} - ${Vt(n,e+4).trimStart()}`);else r.push(`${i} - ${String(n)}`)}else if(typeof s==="object")r.push(`${i}${o}:`),r.push(Vt(s,e+2));else r.push(`${i}${o}: ${String(s)}`)}return r.join(`
119
- `)}function Xi(t){if(t.length===0)return"(empty)";let e=Object.keys(t[0]),i=e.map((n)=>Math.max(n.length,...t.map((m)=>String(m[n]??"").length))),r=e.map((n,m)=>n.toUpperCase().padEnd(i[m])).join(" "),o=i.map((n)=>"-".repeat(n)).join(" "),s=t.map((n)=>e.map((m,a)=>String(n[m]??"").padEnd(i[a])).join(" "));return[r,o,...s].join(`
120
- `)}function Xe(t){return JSON.stringify(t,null,2)}function _(t){if(t==="json"||t==="text")return t;if(!process.stdout.isTTY)return"json";return"text"}function b(t,e){switch(e){case"json":return Xe(t);case"text":return Ke(t)}}function O(){let t=X();if(!Wi(t))return{};try{return Ye(JSON.parse(Qi(t,"utf-8")))}catch(e){let i=e;if(i instanceof SyntaxError||i.message.includes("JSON"))process.stderr.write(`Warning: config file is corrupted. Run 'mmx config set' to reset.
121
- `);return{}}}async function Y(t){await bt();let e=X(),i=e+".tmp";Vi(i,JSON.stringify(t,null,2)+`
122
- `,{mode:384}),Zi(i,e)}function Zt(t){let e=O(),i=t.apiKey||void 0,r=e.api_key,o=t.region||process.env.MINIMAX_REGION||void 0,s=e.region,n=o||s||"global",m=i||r,a=!o&&(!s||m!==void 0&&m!==e.api_key),u=t.baseUrl||process.env.MINIMAX_BASE_URL||e.base_url||Z[n]||Z.global,y=_(t.output||process.env.MINIMAX_OUTPUT||e.output),$=process.env.MINIMAX_TIMEOUT?Number(process.env.MINIMAX_TIMEOUT):void 0,h=$!==void 0&&Number.isFinite($)&&$>0?$:void 0,w=t.timeout??h??e.timeout??300;return{apiKey:i,fileApiKey:r,fileRegion:e.region,configPath:X(),region:n,baseUrl:u,output:y,timeout:w,verbose:t.verbose||process.env.MINIMAX_VERBOSE==="1",quiet:t.quiet||!1,noColor:t.noColor||process.env.NO_COLOR!==void 0||!process.stdout.isTTY,yes:t.yes||!1,dryRun:t.dryRun||!1,nonInteractive:t.nonInteractive||!1,async:t.async||!1,needsRegionDetection:a}}function A(t){if(t?.nonInteractive===!0)return!1;if(process.env.CI)return!1;return process.stdout.isTTY===!0&&process.stdin.isTTY===!0}async function _n(t){try{let e=P(t.baseUrl),i=await v(t,{url:e});rt(i.model_remains||[],t)}catch{}}var vn=d({name:"auth login",description:"Authenticate via OAuth or API key",usage:"mmx auth login [--method oauth|api-key] [--api-key <key>] [--no-browser]",options:[{flag:"--method <method>",description:"Auth method: oauth (default), api-key"},{flag:"--api-key <key>",description:"API key to store"},{flag:"--no-browser",description:"Use device-code flow instead of browser"}],examples:["mmx auth login","mmx auth login --no-browser","mmx auth login --api-key sk-xxxxx","mmx auth login --method api-key --api-key sk-xxxxx"],async run(t,e){let i=process.env.MINIMAX_API_KEY;if(i&&!e.apiKey){let n=I(i);if(A({nonInteractive:t.nonInteractive})){let{confirm:m}=await Promise.resolve().then(() => (Tt(),qt));if(!await m({message:`Detected MINIMAX_API_KEY in environment (${n}).
108
+ Music-2.6 requires the Max plan or above.`;return""}function je(t){return`${t?.includes("minimaxi.com")?"https://platform.minimaxi.com":"https://platform.minimax.io"}/subscribe/token-plan`}function Ut(t,e,n){let i=e.base_resp?.status_msg||e.error?.message||`HTTP ${t}`,o=e.base_resp?.status_code||e.error?.code;if(t===401||t===403)return new $(`API key rejected (HTTP ${t}).`,l.AUTH,`Check status: mmx auth status
109
+ Re-authenticate: mmx auth login`);if(t===429)return new $(`Rate limit or quota exceeded. ${i}`,l.QUOTA,"Check usage: mmx quota show");if(t===408||t===504)return new $(`Request timed out (HTTP ${t}).`,l.TIMEOUT,"Try increasing --timeout or retry later.");if(o===1002||o===1039){let s=e.base_resp?.status_msg||"content sensitivity";return new $(`Input content flagged by sensitivity filter (${s}).`,l.CONTENT_FILTER)}if(o===1028||o===1030){let s=Ae(n);return new $(`Quota exhausted. ${i}`,l.QUOTA,`Check usage: mmx quota show${s}
110
+ Upgrade plan: ${je(n)}`)}if(o===2061){let s=Ae(n);return new $(`This model is not available on your current Token Plan. ${i}`,l.QUOTA,`Check usage: mmx quota show${s}
111
+ Upgrade plan: ${je(n)}`)}return new $(`API error: ${i} (HTTP ${t})`,l.GENERAL)}import{homedir as qe}from"os";function J(t){return t.length>8?`${t.slice(0,4)}...${t.slice(-4)}`:"***"}var Me=!1;var N="\x1B[0m",Z="\x1B[2m",Bn="\x1B[1m",In="\x1B[38;2;43;82;255m",Jn="\x1B[38;2;147;51;234m",zn="\x1B[38;2;6;184;212m",Yn="\x1B[38;2;236;72;153m";function Kn(t){return t.startsWith(qe())?t.replace(qe(),"~"):t}function Te(t,e,n){if(t.quiet||Me||!process.stderr.isTTY)return;Me=!0;let i=t.configPath?Kn(t.configPath):"~/.mmx/config.json",o=t.fileRegion?`${t.fileRegion} (file)`:"global (default)",s=t.apiKey?"(flag)":"(file)",r=J(e),a=n?` ${Z}|${N} ${Z}Model:${N} ${Jn}${n}${N}`:"";process.stderr.write(`${Bn}${In}MINIMAX${N} ${Z}${i}${N} ${Z}|${N} ${Z}Region:${N} ${zn}${o}${N} ${Z}|${N} ${Z}Key:${N} ${Yn}${r}${N} ${Z}${s}${N}${a}
112
+ `)}async function X(t,e){let n=typeof FormData<"u"&&e.body instanceof FormData,i="1.0.6",o={"User-Agent":"mmx-cli/1.0.6",...e.headers};if(!n&&!o["Content-Type"])o["Content-Type"]="application/json";if(!e.noAuth){let a=await vt(t);if(e.authStyle==="x-api-key")o["x-api-key"]=a.token;else o.Authorization=`Bearer ${a.token}`;if(t.verbose)process.stderr.write(`> ${e.method??"GET"} ${e.url}
113
+ `),process.stderr.write(`> Auth: ${a.token.slice(0,8)}...
114
+ `);let p=e.body&&typeof e.body==="object"&&"model"in e.body?String(e.body.model):void 0;Te(t,a.token,p)}let s=(e.timeout??t.timeout)*1000,r=await fetch(e.url,{method:e.method??"GET",headers:o,body:e.body?n?e.body:JSON.stringify(e.body):void 0,signal:AbortSignal.timeout(s)});if(t.verbose)process.stderr.write(`< ${r.status} ${r.statusText}
115
+ `);if(!r.ok){let a={};try{a=await r.json()}catch{}throw Ut(r.status,a,e.url)}return r}async function v(t,e){let n=await X(t,e),i;try{i=await n.json()}catch{let o=n.headers.get("content-type")||"";throw new $(`API returned non-JSON response (${o||"unknown type"}). Server may be experiencing issues.`,l.GENERAL)}if(i.base_resp?.status_code&&i.base_resp.status_code!==0)throw Ut(200,{base_resp:i.base_resp},e.url);return i}function Oe(t){return`${t}/anthropic/v1/messages`}function Ge(t){return`${t}/v1/t2a_v2`}function Ne(t){return`${t}/v1/get_voice`}function Be(t){return`${t}/v1/image_generation`}function Ie(t){return`${t}/v1/video_generation`}function _t(t,e){return`${t}/v1/query/video_generation?task_id=${e}`}function St(t,e){return`${t}/v1/files/retrieve?file_id=${e}`}function Rt(t){return`${t}/v1/music_generation`}function Je(t){return`${t}/v1/coding_plan/search`}function ze(t){return`${t}/v1/coding_plan/vlm`}function P(t){return`${t.includes("minimaxi.com")?"https://api.minimaxi.com":"https://api.minimax.io"}/v1/api/openplatform/coding_plan/remains`}function Xe(t){if(t<50)return["\x1B[38;2;74;222;128m","\x1B[48;2;22;163;74m"];if(t<=80)return["\x1B[38;2;250;204;21m","\x1B[48;2;202;138;4m"];return["\x1B[38;2;248;113;113m","\x1B[48;2;220;38;38m"]}var Xn={dashboard:"TokenPlan Quota",week:"Week",weekly:"Weekly",resetsIn:"Resets in",noData:"No quota data available.",now:"now"},Qn={dashboard:"TokenPlan 配额面板",week:"周期",weekly:"每周",resetsIn:"重置于",noData:"暂无配额数据",now:"即将"};function Vn(t,e){if(t<=0)return e;let n=Math.floor(t/3600000),i=Math.floor(t%3600000/60000);return n>0?`${n}h ${i}m`:`${i}m`}function Ye(t){return new Date(t).toISOString().slice(0,10)}function Zn(t){return t>=11904&&t<=40959||t>=63744&&t<=64255||t>=65072&&t<=65103||t>=65281&&t<=65376||t>=131072&&t<=195103}function U(t){let e=t.replace(/\x1b\[[0-9;]*m/g,""),n=0;for(let i of e)n+=Zn(i.codePointAt(0))?2:1;return n}var gt=16;function Ke(t,e){let n=Math.max(0,Math.min(100,t))/100,i=Math.round(gt*n),o=gt-i,s=`${t}%`.padStart(4);if(!e)return`[${"█".repeat(i)}${".".repeat(o)}] ${s}`;let[r,a]=Xe(t);return`${a}${" ".repeat(i)}\x1B[0m\x1B[48;2;55;65;81m${" ".repeat(o)}\x1B[0m ${r}\x1B[1m${s}\x1B[0m`}function kt(t,e,n,i,o){return o?`\x1B[2m${e}${n.repeat(t)}${i}\x1B[0m`:`+${"-".repeat(t)}+`}function Wt(t,e,n,i){let o=Math.max(0,e-2-n);return i?`${"\x1B[2m"}│${"\x1B[0m"} ${t}${" ".repeat(o)} ${"\x1B[2m"}│${"\x1B[0m"}`:`| ${t}${" ".repeat(o)} |`}function it(t,e){let n=!e.noColor&&process.stdout.isTTY===!0,i=e.region==="cn"?Qn:Xn,o=t.length>0?Math.max(...t.map((w)=>w.model_name.length)):16,s=n?gt+5:gt+7,r=Math.max(68,o+2+15+2+s+2),a=t.length>0?`${Ye(t[0].weekly_start_time)} — ${Ye(t[0].weekly_end_time)}`:"",p=`MINIMAX ${i.dashboard}`,u=`${i.week}: ${a}`,y=Math.max(2,r-2-U(p)-U(u)),c=n?`\x1B[1m\x1B[38;2;43;82;255mMINIMAX\x1B[0m \x1B[2m${i.dashboard}\x1B[0m${" ".repeat(y)}\x1B[2m${i.week}:\x1B[0m \x1B[38;2;6;184;212m${a}\x1B[0m`:`${p}${" ".repeat(y)}${u}`,x=U(p)+y+U(u);if(console.log(""),console.log(kt(r,"╭","─","╮",n)),console.log(Wt(c,r,x,n)),t.length===0){console.log(kt(r,"╰","─","╯",n)),console.log(`
116
+ ${i.noData}
117
+ `);return}for(let w of t){console.log(kt(r,"├","─","┤",n));let{current_interval_usage_count:_,current_interval_total_count:S}=w,k=Math.max(0,S-_),T=S>0?Math.round(k/S*100):0,Q=w.current_weekly_usage_count,M=w.current_weekly_total_count,A=Math.max(0,M-Q),mt=Vn(w.remains_time,i.now),$t=w.model_name.padEnd(o),yt=`${k.toLocaleString()} / ${S.toLocaleString()}`,mn=Ke(T,n),pn=o+2+15+2+s,un=n?`\x1B[1m\x1B[38;2;255;255;255m${$t}\x1B[0m ${Xe(T)[0]}${yt.padStart(15)}\x1B[0m ${mn}`:`${$t} ${yt.padStart(15)} ${Ke(T,!1)}`;console.log(Wt(un,r,pn,n));let xt=`└ ${i.weekly} ${A.toLocaleString()} / ${M.toLocaleString()}`,dt=`${i.resetsIn} ${mt}`,zt=Math.max(2,r-2-2-U(xt)-U(dt)),cn=2+U(xt)+zt+U(dt),ln=n?` \x1B[2m${xt}${" ".repeat(zt)}${dt}\x1B[0m`:` ${xt}${" ".repeat(zt)}${dt}`;console.log(Wt(ln,r,cn,n))}console.log(kt(r,"╰","─","╯",n)),console.log("")}import{readFileSync as Cn,writeFileSync as En,renameSync as Pn,existsSync as Ln}from"fs";var W={global:"https://api.minimax.io",cn:"https://api.minimaxi.com"},Un=new Set(["global","cn"]),Wn=new Set(["text","json"]);function Qe(t){if(!t||typeof t!=="object"||Array.isArray(t))return{};let e=t,n={};if(typeof e.api_key==="string")n.api_key=e.api_key;if(typeof e.region==="string"&&Un.has(e.region))n.region=e.region;if(typeof e.base_url==="string"&&e.base_url.startsWith("http"))n.base_url=e.base_url;if(typeof e.output==="string"&&Wn.has(e.output))n.output=e.output;if(typeof e.timeout==="number"&&e.timeout>0)n.timeout=e.timeout;return n}function Ve(t){if(t===null||t===void 0)return"";if(typeof t==="string")return t;if(typeof t==="number"||typeof t==="boolean")return String(t);if(Array.isArray(t)){if(t.length===0)return"(empty)";if(typeof t[0]==="object"&&t[0]!==null)return Hn(t);return t.map(String).join(`
118
+ `)}if(typeof t==="object")return Ht(t);return String(t)}function Ht(t,e=0){let n=" ".repeat(e),i=[];for(let[o,s]of Object.entries(t)){if(s===null||s===void 0)continue;if(Array.isArray(s)){i.push(`${n}${o}:`);for(let r of s)if(typeof r==="object"&&r!==null)i.push(`${n} - ${Ht(r,e+4).trimStart()}`);else i.push(`${n} - ${String(r)}`)}else if(typeof s==="object")i.push(`${n}${o}:`),i.push(Ht(s,e+2));else i.push(`${n}${o}: ${String(s)}`)}return i.join(`
119
+ `)}function Hn(t){if(t.length===0)return"(empty)";let e=Object.keys(t[0]),n=e.map((r)=>Math.max(r.length,...t.map((a)=>String(a[r]??"").length))),i=e.map((r,a)=>r.toUpperCase().padEnd(n[a])).join(" "),o=n.map((r)=>"-".repeat(r)).join(" "),s=t.map((r)=>e.map((a,p)=>String(r[a]??"").padEnd(n[p])).join(" "));return[i,o,...s].join(`
120
+ `)}function Ze(t){return JSON.stringify(t,null,2)}function f(t){if(t==="json"||t==="text")return t;if(!process.stdout.isTTY)return"json";return"text"}function h(t,e){switch(e){case"json":return Ze(t);case"text":return Ve(t)}}function G(){let t=V();if(!Ln(t))return{};try{return Qe(JSON.parse(Cn(t,"utf-8")))}catch(e){let n=e;if(n instanceof SyntaxError||n.message.includes("JSON"))process.stderr.write(`Warning: config file is corrupted. Run 'mmx config set' to reset.
121
+ `);return{}}}async function Y(t){await ft();let e=V(),n=e+".tmp";En(n,JSON.stringify(t,null,2)+`
122
+ `,{mode:384}),Pn(n,e)}function Ct(t){let e=G(),n=t.apiKey||void 0,i=e.api_key,o=t.region||process.env.MINIMAX_REGION||void 0,s=e.region,r=o||s||"global",a=n||i,p=!o&&(!s||a!==void 0&&a!==e.api_key),u=t.baseUrl||process.env.MINIMAX_BASE_URL||e.base_url||W[r]||W.global,y=f(t.output||process.env.MINIMAX_OUTPUT||e.output),c=process.env.MINIMAX_TIMEOUT?Number(process.env.MINIMAX_TIMEOUT):void 0,x=c!==void 0&&Number.isFinite(c)&&c>0?c:void 0,w=t.timeout??x??e.timeout??300;return{apiKey:n,fileApiKey:i,fileRegion:e.region,configPath:V(),region:r,baseUrl:u,output:y,timeout:w,verbose:t.verbose||process.env.MINIMAX_VERBOSE==="1",quiet:t.quiet||!1,noColor:t.noColor||process.env.NO_COLOR!==void 0||!process.stdout.isTTY,yes:t.yes||!1,dryRun:t.dryRun||!1,nonInteractive:t.nonInteractive||!1,async:t.async||!1,needsRegionDetection:p}}function j(t){if(t?.nonInteractive===!0)return!1;if(process.env.CI)return!1;return process.stdout.isTTY===!0&&process.stdin.isTTY===!0}async function _r(t){try{let e=P(t.baseUrl),n=await v(t,{url:e});it(n.model_remains||[],t)}catch{}}var Sr=b({name:"auth login",description:"Authenticate via OAuth or API key",usage:"mmx auth login [--method oauth|api-key] [--api-key <key>] [--no-browser]",options:[{flag:"--method <method>",description:"Auth method: oauth (default), api-key"},{flag:"--api-key <key>",description:"API key to store"},{flag:"--no-browser",description:"Use device-code flow instead of browser"}],examples:["mmx auth login","mmx auth login --no-browser","mmx auth login --api-key sk-xxxxx","mmx auth login --method api-key --api-key sk-xxxxx"],async run(t,e){let n=process.env.MINIMAX_API_KEY;if(n&&!e.apiKey){let r=J(n);if(j({nonInteractive:t.nonInteractive})){let{confirm:a}=await Promise.resolve().then(() => (Nt(),Gt));if(!await a({message:`Detected MINIMAX_API_KEY in environment (${r}).
123
123
  You are already authenticated via env.
124
124
  Do you still want to configure local persistent credentials?`,initialValue:!1}))process.stdout.write(`Login skipped. Using environment variables.
125
125
  `),process.exit(0)}else process.stderr.write(`Warning: MINIMAX_API_KEY is already set in environment.
126
- `)}if((e.apiKey?"api-key":e.method||"oauth")==="api-key"){let n=e.apiKey||t.apiKey;if(!n)throw new c("--api-key is required when using --method api-key.",l.USAGE,"mmx auth login --api-key sk-xxxxx");if(!t.dryRun){process.stderr.write("Testing key... ");try{let a={...t,apiKey:n};await v(a,{url:P(a.baseUrl)}),process.stderr.write(`Valid
127
- `)}catch{throw new c("API key validation failed.",l.AUTH,"Check that your key is valid and belongs to a Token Plan.")}let m=O();m.api_key=n,await Y(m),process.stderr.write(`API key saved to ${X()}
128
- `),await _n({...t,apiKey:n})}else console.log("Would validate and save API key.");return}if(t.dryRun){console.log("Would start OAuth login flow.");return}let o;if(e.noBrowser)o=await ve();else o=await _e();let s={access_token:o.access_token,refresh_token:o.refresh_token,expires_at:new Date(Date.now()+o.expires_in*1000).toISOString(),token_type:"Bearer"};await it(s),process.stderr.write(`Logged in successfully.
126
+ `)}if((e.apiKey?"api-key":e.method||"oauth")==="api-key"){let r=e.apiKey||t.apiKey;if(!r)throw new $("--api-key is required when using --method api-key.",l.USAGE,"mmx auth login --api-key sk-xxxxx");if(!t.dryRun){process.stderr.write("Testing key... ");try{let p={...t,apiKey:r};await v(p,{url:P(p.baseUrl)}),process.stderr.write(`Valid
127
+ `)}catch{throw new $("API key validation failed.",l.AUTH,"Check that your key is valid and belongs to a Token Plan.")}let a=G();a.api_key=r,await Y(a),process.stderr.write(`API key saved to ${V()}
128
+ `),await _r({...t,apiKey:r})}else console.log("Would validate and save API key.");return}if(t.dryRun){console.log("Would start OAuth login flow.");return}let o;if(e.noBrowser)o=await ke();else o=await Re();let s={access_token:o.access_token,refresh_token:o.refresh_token,expires_at:new Date(Date.now()+o.expires_in*1000).toISOString(),token_type:"Bearer"};await nt(s),process.stderr.write(`Logged in successfully.
129
129
  `),process.stderr.write(`Credentials saved to ~/.mmx/credentials.json
130
- `),await _n({...t,apiKey:s.access_token})}});var fn=d({name:"auth status",description:"Show current authentication state and quota snapshot",usage:"mmx auth status",examples:["mmx auth status","mmx auth status --output json"],async run(t,e){try{let i=await dt(t),r=_(t.output);if(r!=="text"){let s={method:i.method,source:i.source};if(i.method==="oauth"){let n=await B();if(n){if(s.token_expires=n.expires_at,n.account)s.account=n.account}}else s.key=I(i.token);console.log(b(s,r));return}console.log("Authentication Status:"),console.log(` Method: ${i.method}`),console.log(` Source: ${i.source}`);let o=i.token;if(console.log(` Key: ${I(o)}`),i.method==="oauth"){let s=await B();if(s){if(s.account)console.log(` Account: ${s.account}`);let n=new Date(s.expires_at),m=Math.round((n.getTime()-Date.now())/60000);console.log(` Expires in: ${m} minutes`)}}process.stderr.write(`Fetching quota snapshot...
131
- `);try{let s=P(t.baseUrl),n=await v(t,{url:s,method:"GET"});rt(n.model_remains||[],t)}catch(s){console.log(` Quota fetch failed: ${s.message}`)}}catch{let i=_(t.output);console.log(b({authenticated:!1,message:"Not authenticated.",hint:`Run: mmx auth login
132
- Or set $MINIMAX_API_KEY`},i))}}});var Sn=d({name:"auth refresh",description:"Manually refresh OAuth token",usage:"mmx auth refresh",examples:["mmx auth refresh"],async run(t,e){let i=await B();if(!i)throw new c("Not applicable: not authenticated via OAuth.",l.USAGE,"Run mmx auth login first.");if(t.dryRun){console.log("Would refresh OAuth token.");return}let r=await Kt(i.refresh_token),o={access_token:r.access_token,refresh_token:r.refresh_token,expires_at:new Date(Date.now()+r.expires_in*1000).toISOString(),token_type:"Bearer",account:i.account};await it(o);let s=_(t.output);if(t.quiet){console.log(o.expires_at);return}console.log(b({status:"Token refreshed",expires:o.expires_at},s))}});var Rn=d({name:"auth logout",description:"Revoke tokens and clear stored credentials",usage:"mmx auth logout [--yes] [--dry-run]",options:[{flag:"--yes",description:"Skip confirmation prompt"}],examples:["mmx auth logout","mmx auth logout --dry-run","mmx auth logout --yes"],async run(t,e){let i=await B(),r=O(),o=!!r.api_key;if(t.dryRun){if(i)console.log("Would remove ~/.mmx/credentials.json");if(o)console.log("Would clear api_key from ~/.mmx/config.json");if(!i&&!o)console.log("No credentials to clear.");console.log("No changes made.");return}if(i)await be(),process.stderr.write(`Removed ~/.mmx/credentials.json
133
- `);if(o)try{let s=r;delete s.api_key,await Y(s),process.stderr.write(`Cleared api_key from ~/.mmx/config.json
134
- `)}catch{}if(!i&&!o)process.stderr.write(`No credentials to clear.
135
- `)}});async function*kn(t){let e=t.body?.getReader();if(!e)return;let i=new TextDecoder,r="";try{while(!0){let{done:o,value:s}=await e.read();if(o)break;r+=i.decode(s,{stream:!0});let n=r.split(`
136
- `);r=n.pop()||"";let m={};for(let a of n){if(a===""){if(m.data!==void 0)yield{data:m.data,event:m.event,id:m.id};m={};continue}if(a.startsWith(":"))continue;let u=a.indexOf(":");if(u===-1)continue;let y=a.slice(0,u),$=a.slice(u+1).trimStart();switch(y){case"data":m.data=m.data!==void 0?`${m.data}
137
- ${$}`:$;break;case"event":m.event=$;break;case"id":m.id=$;break}}}if(r.trim()&&r.includes("data:")){let o=r.indexOf(":");if(o!==-1)yield{data:r.slice(o+1).trimStart()}}}finally{e.releaseLock()}}import{readFileSync as ue}from"fs";async function K(t){if(!A())return;let{defaultValue:e,message:i}=t,o=await(await Promise.resolve().then(() => (Tt(),qt))).text({message:i,default:e,placeholder:e});if(typeof o==="symbol")return;return o}async function gn(t){if(!A())return;let{message:e}=t,r=await(await Promise.resolve().then(() => (Tt(),qt))).confirm({message:e});if(typeof r==="symbol")return;return r}function st(t,e){throw new c(`Missing required argument: --${t}
130
+ `),await _r({...t,apiKey:s.access_token})}});var Rr=b({name:"auth status",description:"Show current authentication state and quota snapshot",usage:"mmx auth status",examples:["mmx auth status","mmx auth status --output json"],async run(t,e){try{let n=await vt(t),i=f(t.output);if(i!=="text"){let s={method:n.method,source:n.source};if(n.method==="oauth"){let r=await I();if(r){if(s.token_expires=r.expires_at,r.account)s.account=r.account}}else s.key=J(n.token);console.log(h(s,i));return}console.log("Authentication Status:"),console.log(` Method: ${n.method}`),console.log(` Source: ${n.source}`);let o=n.token;if(console.log(` Key: ${J(o)}`),n.method==="oauth"){let s=await I();if(s){if(s.account)console.log(` Account: ${s.account}`);let r=new Date(s.expires_at),a=Math.round((r.getTime()-Date.now())/60000);console.log(` Expires in: ${a} minutes`)}}process.stderr.write(`Fetching quota snapshot...
131
+ `);try{let s=P(t.baseUrl),r=await v(t,{url:s,method:"GET"});it(r.model_remains||[],t)}catch(s){console.log(` Quota fetch failed: ${s.message}`)}}catch{let n=f(t.output);console.log(h({authenticated:!1,message:"Not authenticated.",hint:`Run: mmx auth login
132
+ Or set $MINIMAX_API_KEY`},n))}}});var kr=b({name:"auth refresh",description:"Manually refresh OAuth token",usage:"mmx auth refresh",examples:["mmx auth refresh"],async run(t,e){let n=await I();if(!n)throw new $("Not applicable: not authenticated via OAuth.",l.USAGE,"Run mmx auth login first.");if(t.dryRun){console.log("Would refresh OAuth token.");return}let i=await Zt(n.refresh_token),o={access_token:i.access_token,refresh_token:i.refresh_token,expires_at:new Date(Date.now()+i.expires_in*1000).toISOString(),token_type:"Bearer",account:n.account};await nt(o);let s=f(t.output);if(t.quiet){console.log(o.expires_at);return}console.log(h({status:"Token refreshed",expires:o.expires_at},s))}});var gr=b({name:"auth logout",description:"Revoke tokens and clear stored credentials",usage:"mmx auth logout [--yes] [--dry-run]",options:[{flag:"--yes",description:"Skip confirmation prompt"}],examples:["mmx auth logout","mmx auth logout --dry-run","mmx auth logout --yes"],async run(t,e){let n=await I(),i=G(),o=!!i.api_key;if(t.dryRun){if(n)console.log("Would remove ~/.mmx/credentials.json");if(o)console.log("Would clear api_key from ~/.mmx/config.json");if(!n&&!o)console.log("No credentials to clear.");console.log("No changes made.");return}if(n)await _e(),process.stderr.write(`Removed ~/.mmx/credentials.json
133
+ `);if(o)try{let s=i;delete s.api_key,await Y(s),process.stderr.write(`Cleared api_key from ~/.mmx/config.json
134
+ `)}catch{}if(!n&&!o)process.stderr.write(`No credentials to clear.
135
+ `)}});async function*Bt(t){let e=t.body?.getReader();if(!e)return;let n=new TextDecoder,i="";try{while(!0){let{done:o,value:s}=await e.read();if(o)break;i+=n.decode(s,{stream:!0});let r=i.split(`
136
+ `);i=r.pop()||"";let a={};for(let p of r){if(p===""){if(a.data!==void 0)yield{data:a.data,event:a.event,id:a.id};a={};continue}if(p.startsWith(":"))continue;let u=p.indexOf(":");if(u===-1)continue;let y=p.slice(0,u),c=p.slice(u+1).trimStart();switch(y){case"data":a.data=a.data!==void 0?`${a.data}
137
+ ${c}`:c;break;case"event":a.event=c;break;case"id":a.id=c;break}}}if(i.trim()&&i.includes("data:")){let o=i.indexOf(":");if(o!==-1)yield{data:i.slice(o+1).trimStart()}}}finally{e.releaseLock()}}import{readFileSync as ye}from"fs";async function K(t){if(!j())return;let{defaultValue:e,message:n}=t,o=await(await Promise.resolve().then(() => (Nt(),Gt))).text({message:n,default:e,placeholder:e});if(typeof o==="symbol")return;return o}async function Ar(t){if(!j())return;let{message:e}=t,i=await(await Promise.resolve().then(() => (Nt(),Gt))).confirm({message:e});if(typeof i==="symbol")return;return i}function st(t,e){throw new $(`Missing required argument: --${t}
138
138
  Hint: In non-interactive (CI / agent) environments all required flags must be provided.
139
- In an interactive terminal, run without --${t} and the CLI will prompt for it.`,l.USAGE,e)}function no(t){let e=[],i;if(t.system)i=t.system;if(t.messagesFile){let r=t.messagesFile,o=r==="-"?ue("/dev/stdin","utf-8"):ue(r,"utf-8"),s=JSON.parse(o);for(let n of s)if(n.role==="system")i=typeof n.content==="string"?n.content:"";else e.push(n)}if(t.message){let r=new Set(["system","user","assistant"]),o=t.message;for(let s of o){let n=s.indexOf(":"),m=n!==-1?s.slice(0,n):"";if(r.has(m)){let a=s.slice(n+1);if(m==="system")i=a;else e.push({role:m,content:a})}else e.push({role:"user",content:s})}}return{system:i,messages:e}}function io(t){return t.filter((e)=>e.type==="text").map((e)=>e.text).join("")}var An=d({name:"text chat",description:"Send a chat completion (MiniMax Messages API)",usage:"mmx text chat --message <text> [flags]",options:[{flag:"--model <model>",description:"Model ID (default: MiniMax-M2.7)"},{flag:"--message <text>",description:"Message text (repeatable, prefix role: to set role)",required:!0,type:"array"},{flag:"--messages-file <path>",description:"JSON file with messages array (use - for stdin)"},{flag:"--system <text>",description:"System prompt"},{flag:"--max-tokens <n>",description:"Maximum tokens to generate (default: 4096)",type:"number"},{flag:"--temperature <n>",description:"Sampling temperature (0.0, 1.0]",type:"number"},{flag:"--top-p <n>",description:"Nucleus sampling threshold",type:"number"},{flag:"--stream",description:"Stream response tokens (default: on in TTY)"},{flag:"--tool <json-or-path>",description:"Tool definition as JSON or file path (repeatable)",type:"array"}],examples:['mmx text chat --message "What is MiniMax?"','mmx text chat --model MiniMax-M2.7-highspeed --system "You are a coding assistant." --message "Write fizzbuzz in Python"','mmx text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"',"cat conversation.json | mmx text chat --messages-file - --stream",'mmx text chat --message "Hello" --output json'],async run(t,e){let{system:i,messages:r}=no(e),o=r;if(o.length===0)if(A({nonInteractive:t.nonInteractive})){let y=await K({message:"Enter your message:"});if(!y)process.stderr.write(`Chat cancelled.
140
- `),process.exit(1);o=[{role:"user",content:y}]}else st("message","mmx text chat --message <text>");let s=e.model||"MiniMax-M2.7",n=e.stream===!0||e.stream===void 0&&process.stdout.isTTY,m=_(t.output),a={model:s,messages:o,max_tokens:e.maxTokens??4096,stream:n};if(i)a.system=i;if(e.temperature!==void 0)a.temperature=e.temperature;if(e.topP!==void 0)a.top_p=e.topP;if(e.tool){let y=e.tool.map(($)=>{try{return JSON.parse($)}catch{let h=ue($,"utf-8");return JSON.parse(h)}});a.tools=y}if(t.dryRun){console.log(b({request:a},m));return}let u=je(t.baseUrl);if(n){let y=await C(t,{url:u,method:"POST",body:a,stream:!0,authStyle:"x-api-key"}),$="",h=!1,w=t.noColor?"":"\x1B[2m",f=t.noColor?"":"\x1B[0m",M=process.stdout.isTTY?process.stdout:process.stderr,J=process.stdout;for await(let et of kn(y)){if(et.data==="[DONE]")break;try{let q=JSON.parse(et.data);if(q.type==="content_block_start"){if(q.content_block.type==="thinking")h=!0,M.write(`${w}Thinking:
141
- `);else if(q.content_block.type==="text"&&h)M.write(`${f}
139
+ In an interactive terminal, run without --${t} and the CLI will prompt for it.`,l.USAGE,e)}function mo(t){let e=[],n;if(t.system)n=t.system;if(t.messagesFile){let i=t.messagesFile,o=i==="-"?ye("/dev/stdin","utf-8"):ye(i,"utf-8"),s=JSON.parse(o);for(let r of s)if(r.role==="system")n=typeof r.content==="string"?r.content:"";else e.push(r)}if(t.message){let i=new Set(["system","user","assistant"]),o=t.message;for(let s of o){let r=s.indexOf(":"),a=r!==-1?s.slice(0,r):"";if(i.has(a)){let p=s.slice(r+1);if(a==="system")n=p;else e.push({role:a,content:p})}else e.push({role:"user",content:s})}}return{system:n,messages:e}}function po(t){return t.filter((e)=>e.type==="text").map((e)=>e.text).join("")}var jr=b({name:"text chat",description:"Send a chat completion (MiniMax Messages API)",usage:"mmx text chat --message <text> [flags]",options:[{flag:"--model <model>",description:"Model ID (default: MiniMax-M2.7)"},{flag:"--message <text>",description:"Message text (repeatable, prefix role: to set role)",required:!0,type:"array"},{flag:"--messages-file <path>",description:"JSON file with messages array (use - for stdin)"},{flag:"--system <text>",description:"System prompt"},{flag:"--max-tokens <n>",description:"Maximum tokens to generate (default: 4096)",type:"number"},{flag:"--temperature <n>",description:"Sampling temperature (0.0, 1.0]",type:"number"},{flag:"--top-p <n>",description:"Nucleus sampling threshold",type:"number"},{flag:"--stream",description:"Stream response tokens (default: on in TTY)"},{flag:"--tool <json-or-path>",description:"Tool definition as JSON or file path (repeatable)",type:"array"}],examples:['mmx text chat --message "What is MiniMax?"','mmx text chat --model MiniMax-M2.7-highspeed --system "You are a coding assistant." --message "Write fizzbuzz in Python"','mmx text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"',"cat conversation.json | mmx text chat --messages-file - --stream",'mmx text chat --message "Hello" --output json'],async run(t,e){let{system:n,messages:i}=mo(e),o=i;if(o.length===0)if(j({nonInteractive:t.nonInteractive})){let y=await K({message:"Enter your message:"});if(!y)process.stderr.write(`Chat cancelled.
140
+ `),process.exit(1);o=[{role:"user",content:y}]}else st("message","mmx text chat --message <text>");let s=e.model||"MiniMax-M2.7",r=e.stream===!0||e.stream===void 0&&process.stdout.isTTY,a=f(t.output),p={model:s,messages:o,max_tokens:e.maxTokens??4096,stream:r};if(n)p.system=n;if(e.temperature!==void 0)p.temperature=e.temperature;if(e.topP!==void 0)p.top_p=e.topP;if(e.tool){let y=e.tool.map((c)=>{try{return JSON.parse(c)}catch{let x=ye(c,"utf-8");return JSON.parse(x)}});p.tools=y}if(t.dryRun){console.log(h({request:p},a));return}let u=Oe(t.baseUrl);if(r){let y=await X(t,{url:u,method:"POST",body:p,stream:!0,authStyle:"x-api-key"}),c="",x=!1,w=t.noColor?"":"\x1B[2m",_=t.noColor?"":"\x1B[0m",k=process.stdout.isTTY?process.stdout:process.stderr,T=process.stdout;for await(let Q of Bt(y)){if(Q.data==="[DONE]")break;try{let M=JSON.parse(Q.data);if(M.type==="content_block_start"){if(M.content_block.type==="thinking")x=!0,k.write(`${w}Thinking:
141
+ `);else if(M.content_block.type==="text"&&x)k.write(`${_}
142
142
 
143
143
  Response:
144
- `),h=!1}else if(q.type==="content_block_delta"){if(q.delta.type==="text_delta")$+=q.delta.text,J.write(q.delta.text);else if(q.delta.type==="thinking_delta")M.write(q.delta.thinking)}}catch{}}if(h)M.write(f);if(J.write(`
145
- `),m==="json")console.log(b({content:$},m))}else{let y=await v(t,{url:u,method:"POST",body:a,authStyle:"x-api-key"}),$=io(y.content);if(t.quiet||m==="text")console.log($);else console.log(b(y,m))}}});import{writeFileSync as ro}from"fs";function Ot(t,e,i,r){if(e)if(ro(e,Buffer.from(t.data.audio,"hex")),r)console.log(e);else console.log(b({saved:e,duration_ms:t.extra_info?.audio_length,size_bytes:t.extra_info?.audio_size,sample_rate:t.extra_info?.audio_sample_rate},i));else{let o=t.data.audio_url??t.data.audio;if(r)console.log(o);else console.log(b({url:o,duration_ms:t.extra_info?.audio_length,size_bytes:t.extra_info?.audio_size},i))}}import{readFileSync as oo}from"fs";function Gt(t){return oo(t==="-"?"/dev/stdin":t,"utf-8")}var jn=d({name:"speech synthesize",description:"Synchronous TTS, up to 10k chars (speech-2.8-hd / 2.6 / 02)",usage:"mmx speech synthesize --text <text> [--out <path>] [flags]",options:[{flag:"--model <model>",description:"Model ID (default: speech-2.8-hd)"},{flag:"--text <text>",description:"Text to synthesize"},{flag:"--text-file <path>",description:"Read text from file (use - for stdin)"},{flag:"--voice <id>",description:"Voice ID (default: English_expressive_narrator)"},{flag:"--speed <n>",description:"Speech speed multiplier",type:"number"},{flag:"--volume <n>",description:"Volume level",type:"number"},{flag:"--pitch <n>",description:"Pitch adjustment",type:"number"},{flag:"--format <fmt>",description:"Audio format (default: mp3)"},{flag:"--sample-rate <hz>",description:"Sample rate (default: 32000)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate (default: 128000)",type:"number"},{flag:"--channels <n>",description:"Audio channels (default: 1)",type:"number"},{flag:"--language <code>",description:"Language boost"},{flag:"--subtitles",description:"Include subtitle timing data"},{flag:"--pronunciation <from/to>",description:"Custom pronunciation (repeatable)",type:"array"},{flag:"--out <path>",description:"Save audio to file (uses hex decoding)"},{flag:"--stream",description:"Stream raw audio to stdout"}],examples:['mmx speech synthesize --text "Hello, world!"','mmx speech synthesize --text "Hello, world!" --out hello.mp3','echo "Breaking news." | mmx speech synthesize --text-file - --out news.mp3','mmx speech synthesize --text "Stream" --stream | mpv --no-terminal -'],async run(t,e){let i=e.text??e._positional?.[0];if(e.textFile)i=Gt(e.textFile);if(!i)throw new c("--text or --text-file is required.",l.USAGE,'mmx speech synthesize --text "Hello" --out hello.mp3');let r=e.model||"speech-2.8-hd",o=e.voice||"English_expressive_narrator",s=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),n=e.out??`speech_${s}.mp3`,m="hex",a=_(t.output),u={model:r,text:i,voice_setting:{voice_id:o,speed:e.speed??void 0,vol:e.volume??void 0,pitch:e.pitch??void 0},audio_setting:{format:e.format||"mp3",sample_rate:e.sampleRate??32000,bitrate:e.bitrate??128000,channel:e.channels??1},output_format:m,stream:e.stream===!0};if(e.language)u.language_boost=e.language;if(e.subtitles)u.subtitle=!0;if(e.pronunciation)u.pronunciation_dict=e.pronunciation.map((h)=>{let[w,f]=h.split("/");return{tone:f||w,text:w}});if(t.dryRun){console.log(b({request:u},a));return}let y=Me(t.baseUrl);if(e.stream){let w=(await C(t,{url:y,method:"POST",body:u,stream:!0})).body?.getReader();if(!w)throw new c("No response body",l.GENERAL);while(!0){let{done:f,value:g}=await w.read();if(f)break;process.stdout.write(g)}w.releaseLock();return}let $=await v(t,{url:y,method:"POST",body:u});if(!t.quiet)process.stderr.write(`[Model: ${r}]
146
- `);Ot($,n,a,t.quiet)}});function so(t){let e=t.match(/^(.+?)_[A-Z]/);return e?e[1]:t}function po(t,e){let i=e.toLowerCase();return t.filter((r)=>so(r.voice_id).toLowerCase().includes(i))}var Mn=d({name:"speech voices",description:"List available system voices",usage:"mmx speech voices [--language <lang>]",options:[{flag:"--language <lang>",description:"Filter voices by language (e.g. english, korean, japanese)"}],examples:["mmx speech voices","mmx speech voices --language english","mmx speech voices --language korean","mmx speech voices --output json"],async run(t,e){let i=_(t.output);if(t.dryRun){console.log(b({request:{voice_type:"system"}},i));return}let o=(await v(t,{url:qe(t.baseUrl),method:"POST",body:{voice_type:"system"}})).system_voice??[],s=e.language;if(s){let n=po(o,s);if(i!=="text"){console.log(b(n,i));return}for(let m of n){let a=m.description?.join("; ")||"",u=m.voice_name?` (${m.voice_name})`:"";if(console.log(` ${m.voice_id}${u}`),a)console.log(` ${a}`)}}else{if(i!=="text"){console.log(b(o.map((n)=>n.voice_id),i));return}for(let n of o)console.log(n.voice_id)}}});import{createWriteStream as mo,unlinkSync as ao}from"fs";var qn=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function Tn(t){let e=process.stderr.isTTY,i=0,r=null,o=t;return{start(){if(!e)return;r=setInterval(()=>{process.stderr.write(`\r${qn[i%qn.length]} ${o}`),i++},80)},update(s){o=s},stop(s){if(r)clearInterval(r),r=null;if(e){if(process.stderr.write("\r\x1B[K"),s)process.stderr.write(`${s}
147
- `)}}}}function On(t,e=""){let i=process.stderr.isTTY,r=30;return{update(o){if(!i)return;let s=Math.min(1,o/t),n=Math.round(30*s),m=30-n,a="█".repeat(n)+"░".repeat(m),u=`${Math.round(s*100)}%`;process.stderr.write(`\r${e} ${a} ${u}`)},finish(){if(i)process.stderr.write(`
148
- `)}}}async function D(t,e,i){let r=await fetch(t);if(!r.ok)throw new c(`Download failed: HTTP ${r.status}`,l.GENERAL);let o=Number(r.headers.get("content-length")||0),s=r.body?.getReader();if(!s)throw new c("No response body",l.GENERAL);let n=mo(e),m=o>0&&!i?.quiet?On(o,"Downloading"):null,a=0,u=!1;try{let y=new Promise(($,h)=>{n.on("error",h)});while(!0){let{done:$,value:h}=await Promise.race([s.read(),y]);if($)break;if(!n.write(h))await new Promise((f)=>n.once("drain",f));a+=h.byteLength,m?.update(a)}u=!0}finally{if(s.releaseLock(),m?.finish(),await new Promise((y,$)=>{n.on("finish",y),n.on("error",$),n.end()}),!u)try{ao(e)}catch{}}return{size:a}}function Nt(t){if(t<1024)return`${t} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;if(t<1073741824)return`${(t/1048576).toFixed(1)} MB`;return`${(t/1073741824).toFixed(1)} GB`}import{mkdirSync as uo,existsSync as $o,readFileSync as lo}from"fs";import{join as co,resolve as yo,extname as xo}from"path";var ho={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"},Gn=d({name:"image generate",description:"Generate images (image-01)",usage:"mmx image generate --prompt <text> [flags]",options:[{flag:"--prompt <text>",description:"Image description",required:!0},{flag:"--aspect-ratio <ratio>",description:"Aspect ratio (e.g. 16:9, 1:1)"},{flag:"--n <count>",description:"Number of images to generate (default: 1)",type:"number"},{flag:"--subject-ref <params>",description:"Subject reference (type=character,image=path)"},{flag:"--out-dir <dir>",description:"Download images to directory"},{flag:"--out-prefix <prefix>",description:"Filename prefix (default: image)"}],examples:['mmx image generate --prompt "A cat in a spacesuit on Mars" --aspect-ratio 16:9','mmx image generate --prompt "Logo design" --n 3 --out-dir ./generated/','mmx image generate --prompt "Mountain landscape" --quiet'],async run(t,e){let i=e.prompt??e._positional?.[0];if(!i)if(A({nonInteractive:t.nonInteractive})){let $=await K({message:"Enter your image prompt:"});if(!$)process.stderr.write(`Image generation cancelled.
149
- `),process.exit(1);i=$}else st("prompt","mmx image generate --prompt <text>");let r={model:"image-01",prompt:i,aspect_ratio:e.aspectRatio||void 0,n:e.n??1};if(e.subjectRef){let $=e.subjectRef,h=Object.fromEntries($.split(",").map((f)=>{let g=f.indexOf("=");if(g===-1)return[f,""];return[f.slice(0,g),f.slice(g+1)]})),w={type:h.type||"character"};if(h.image)if(h.image.startsWith("http"))w.image_url=h.image;else{let f=yo(h.image),g=lo(f),M=xo(f).toLowerCase(),J=ho[M]||"image/jpeg";w.image_file=`data:${J};base64,${g.toString("base64")}`}r.subject_reference=[w]}let o=_(t.output);if(t.dryRun){console.log(b({request:r},o));return}let s=Te(t.baseUrl),n=await v(t,{url:s,method:"POST",body:r}),m=n.data.image_urls||[];if(!t.quiet)process.stderr.write(`[Model: image-01]
150
- `);let a=e.outDir??".";if(!$o(a))uo(a,{recursive:!0});let u=e.outPrefix||"image",y=[];for(let $=0;$<m.length;$++){let h=`${u}_${String($+1).padStart(3,"0")}.jpg`,w=co(a,h);await D(m[$],w,{quiet:t.quiet}),y.push(w)}if(t.quiet)console.log(y.join(`
151
- `));else console.log(b({id:n.data.task_id,saved:y,success_count:n.data.success_count,failed_count:n.data.failed_count},o))}});async function Nn(t,e){let i=Date.now()+e.timeoutSec*1000,r=Tn("Polling...");if(!t.quiet)r.start();try{while(Date.now()<i){let o=await v(t,{url:e.url});if(e.getStatus&&!t.quiet)r.update(`Status: ${e.getStatus(o)}`);if(e.isComplete(o))return r.stop("Done."),o;if(e.isFailed(o))throw r.stop("Failed."),new c("Task failed.",l.GENERAL);await new Promise((s)=>setTimeout(s,e.intervalSec*1000))}}finally{r.stop()}throw new c("Polling timed out.",l.TIMEOUT,"Try increasing --timeout or check task status manually.")}import{readFileSync as wo}from"fs";import{extname as bo}from"path";var _o={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"},Bn=d({name:"video generate",description:"Generate a video (Hailuo-2.3 / 2.3-Fast)",usage:"mmx video generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID (default: MiniMax-Hailuo-2.3)"},{flag:"--prompt <text>",description:"Video description",required:!0},{flag:"--first-frame <path-or-url>",description:"First frame image"},{flag:"--callback-url <url>",description:"Webhook URL for completion notification"},{flag:"--download <path>",description:"Save video to file on completion"},{flag:"--no-wait",description:"Return task ID immediately without waiting"},{flag:"--async",description:"Return task ID immediately (agent/CI mode, same as --no-wait but explicit)"},{flag:"--poll-interval <seconds>",description:"Polling interval when waiting (default: 5)",type:"number"}],examples:['mmx video generate --prompt "A man reads a book. Static shot."','mmx video generate --prompt "Ocean waves at sunset." --download sunset.mp4','mmx video generate --prompt "A robot painting." --async --quiet','mmx video generate --prompt "A robot painting." --no-wait --quiet'],async run(t,e){let i=e.prompt;if(!i)if(A({nonInteractive:t.nonInteractive})){let k=await K({message:"Enter your video prompt:"});if(!k)process.stderr.write(`Video generation cancelled.
152
- `),process.exit(1);i=k}else st("prompt","mmx video generate --prompt <text>");let r=e.model||"MiniMax-Hailuo-2.3",o=_(t.output),s={model:r,prompt:i};if(e.firstFrame){let k=e.firstFrame;if(k.startsWith("http"))s.first_frame_image=k;else{let pt=wo(k),$t=bo(k).toLowerCase(),lt=_o[$t]||"image/jpeg";s.first_frame_image=`data:${lt};base64,${pt.toString("base64")}`}}if(e.callbackUrl)s.callback_url=e.callbackUrl;if(t.dryRun){console.log(b({request:s},o));return}let n=Oe(t.baseUrl),a=(await v(t,{url:n,method:"POST",body:s})).task_id;if(!t.quiet&&!e.noWait&&!t.async)process.stderr.write(`[Model: ${r}]
153
- `);else if(!t.quiet)process.stderr.write(`[Model: ${r}]
154
- `);if(e.noWait||t.async){process.stdout.write(JSON.stringify({taskId:a})),process.stdout.write(`
155
- `);return}let u=e.pollInterval??5,y=_t(t.baseUrl,a),$=await Nn(t,{url:y,intervalSec:u,timeoutSec:t.timeout,isComplete:(k)=>k.status==="Success",isFailed:(k)=>k.status==="Failed",getStatus:(k)=>k.status});if(!$.file_id)throw new c("Task completed but no file_id returned.",l.GENERAL);let w=(await v(t,{url:vt(t.baseUrl,$.file_id)})).file?.download_url;if(!w)throw new c("No download URL available for this file.",l.GENERAL);if(e.download){let k=e.download,{size:pt}=await D(w,k,{quiet:t.quiet});if(t.quiet)console.log(k);else console.log(b({task_id:a,status:"Success",file_id:$.file_id,saved:k,size:Nt(pt)},o));return}let f=await import("os"),{join:g}=await import("path"),M=g(f.tmpdir(),"mmx-video"),{existsSync:J,mkdirSync:et}=await import("fs");if(!J(M))et(M,{recursive:!0});let q=g(M,`${a}.mp4`);await D(w,q,{quiet:t.quiet}),process.stdout.write(q),process.stdout.write(`
156
- `)}});var In=d({name:"video task get",description:"Query video task status",usage:"mmx video task get --task-id <id>",options:[{flag:"--task-id <id>",description:"Video generation task ID"}],examples:["mmx video task get --task-id 106916112212032","mmx video task get --task-id 106916112212032 --output json"],async run(t,e){let i=e.taskId;if(!i)throw new c("--task-id is required.",l.USAGE,"mmx video task get --task-id <id>");if(t.dryRun){console.log(`Would query task: ${i}`);return}let r=_t(t.baseUrl,i),o=await v(t,{url:r}),s=_(t.output);if(t.quiet){console.log(o.status);return}console.log(b({task_id:o.task_id,status:o.status,file_id:o.file_id,video_width:o.video_width,video_height:o.video_height},s))}});var zn=d({name:"video download",description:"Download a completed video by file ID",usage:"mmx video download --file-id <id> --out <path>",options:[{flag:"--file-id <id>",description:"File ID to download"},{flag:"--out <path>",description:"Output file path"}],examples:["mmx video download --file-id 176844028768320 --out video.mp4","mmx video download --file-id 176844028768320 --out video.mp4 --quiet"],async run(t,e){let i=e.fileId;if(!i)throw new c("--file-id is required.",l.USAGE,"mmx video download --file-id <id> --out <path>");let r=e.out;if(!r)throw new c("--out is required.",l.USAGE,"mmx video download --file-id <id> --out video.mp4");if(t.dryRun){console.log(`Would download file ${i} to ${r}`);return}let o=vt(t.baseUrl,i),n=(await v(t,{url:o})).file?.download_url;if(!n)throw new c("No download URL available for this file.",l.GENERAL,"The file may still be processing. Check task status first.");let{size:m}=await D(n,r,{quiet:t.quiet}),a=_(t.output);if(t.quiet){console.log(r);return}console.log(b({saved:r,size:Nt(m)},a))}});var Jn=d({name:"music generate",description:"Generate a song (music-2.5)",usage:"mmx music generate --prompt <text> (--lyrics <text> | --instrumental) [--out <path>] [flags]",options:[{flag:"--prompt <text>",description:"Music style description (can be detailed — see examples)"},{flag:"--lyrics <text>",description:'Song lyrics with structure tags. Use "无歌词" for instrumental music. Cannot be used with --instrumental.'},{flag:"--lyrics-file <path>",description:'Read lyrics from file. Use "无歌词" for instrumental. (use - for stdin)'},{flag:"--vocals <text>",description:'Vocal style, e.g. "warm male baritone", "bright female soprano", "duet with harmonies"'},{flag:"--genre <text>",description:"Music genre, e.g. folk, pop, jazz"},{flag:"--mood <text>",description:"Mood or emotion, e.g. warm, melancholic, uplifting"},{flag:"--instruments <text>",description:'Instruments to feature, e.g. "acoustic guitar, piano"'},{flag:"--tempo <text>",description:"Tempo description, e.g. fast, slow, moderate"},{flag:"--bpm <number>",description:"Exact tempo in beats per minute",type:"number"},{flag:"--key <text>",description:"Musical key, e.g. C major, A minor, G sharp"},{flag:"--avoid <text>",description:"Elements to avoid in the generated music"},{flag:"--use-case <text>",description:'Use case context, e.g. "background music for video", "theme song"'},{flag:"--structure <text>",description:'Song structure, e.g. "verse-chorus-verse-bridge-chorus"'},{flag:"--references <text>",description:'Reference tracks or artists, e.g. "similar to Ed Sheeran, Taylor Swift"'},{flag:"--extra <text>",description:"Additional fine-grained requirements not covered above"},{flag:"--instrumental",description:"Generate instrumental music (no vocals)"},{flag:"--aigc-watermark",description:"Embed AI-generated content watermark in audio for content provenance"},{flag:"--format <fmt>",description:"Audio format (default: mp3)"},{flag:"--sample-rate <hz>",description:"Sample rate (default: 44100)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate (default: 256000)",type:"number"},{flag:"--stream",description:"Stream raw audio to stdout"},{flag:"--out <path>",description:"Save audio to file (uses hex decoding)"}],examples:['mmx music generate --prompt "Upbeat pop" --lyrics "La la la..." --out summer.mp3','mmx music generate --prompt "Indie folk, melancholic" --lyrics-file song.txt --out my_song.mp3',"# Detailed prompt with vocal characteristics — music-2.5 responds well to rich descriptions:",'mmx music generate --prompt "Warm morning folk" --vocals "male and female duet, harmonies in chorus" --instruments "acoustic guitar, piano" --bpm 95 --lyrics-file song.txt --out duet.mp3',"# Instrumental (use --instrumental flag):",'mmx music generate --prompt "Cinematic orchestral, building tension" --instrumental --out bgm.mp3','# Or specify "无歌词" in lyrics:','mmx music generate --prompt "Cinematic orchestral" --lyrics "无歌词" --out bgm.mp3'],async run(t,e){let{prompt:i,lyrics:r}=e;if(e.lyricsFile)r=Gt(e.lyricsFile);if(e.instrumental&&(r||e.lyricsFile))throw new c("Cannot use --instrumental with --lyrics or --lyrics-file. For instrumental music, simply use --instrumental without --lyrics.",l.USAGE,"mmx music generate --prompt <style> --instrumental");let o=[];if(e.vocals)o.push(`Vocals: ${e.vocals}`);if(e.genre)o.push(`Genre: ${e.genre}`);if(e.mood)o.push(`Mood: ${e.mood}`);if(e.instruments)o.push(`Instruments: ${e.instruments}`);if(e.tempo)o.push(`Tempo: ${e.tempo}`);if(e.bpm)o.push(`BPM: ${e.bpm}`);if(e.key)o.push(`Key: ${e.key}`);if(e.avoid)o.push(`Avoid: ${e.avoid}`);if(e.useCase)o.push(`Use case: ${e.useCase}`);if(e.structure)o.push(`Structure: ${e.structure}`);if(e.references)o.push(`References: ${e.references}`);if(e.extra)o.push(`Extra: ${e.extra}`);if(r==="无歌词"||r==="no lyrics")r="[intro] [outro]",o.push("Style: instrumental, no vocals, pure music");if(e.instrumental)r="[intro] [outro]",o.push("Style: instrumental, no vocals, pure music");if(!i&&!r)throw new c("At least one of --prompt or --lyrics is required.",l.USAGE,"mmx music generate --prompt <text> --lyrics <text>");if(!r?.trim())throw new c('The API requires lyrics. Add --lyrics or --lyrics-file, or use --instrumental (or --lyrics "无歌词") for instrumental output.',l.USAGE,"mmx music generate --prompt <text> --lyrics <text>");if(o.length>0){let w=o.join(". ");i=i?`${i}. ${w}`:w}let s=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),n=e.format||"mp3",m=e.out??`music_${s}.${n}`,a="hex",u=_(t.output),y={model:"music-2.5",prompt:i,lyrics:r,audio_setting:{format:e.format||"mp3",sample_rate:e.sampleRate??44100,bitrate:e.bitrate??256000},output_format:a,stream:e.stream===!0};if(e.aigcWatermark)y.aigc_watermark=!0;if(t.dryRun){console.log(b({request:y},u));return}let $=Ge(t.baseUrl);if(e.stream){let f=(await C(t,{url:$,method:"POST",body:y,stream:!0})).body?.getReader();if(!f)throw new c("No response body",l.GENERAL);while(!0){let{done:g,value:M}=await f.read();if(g)break;process.stdout.write(M)}f.releaseLock();return}let h=await v(t,{url:$,method:"POST",body:y});if(!t.quiet)process.stderr.write(`[Model: music-2.5]
157
- `);Ot(h,m,u,t.quiet)}});var Yn=d({name:"search query",description:"Search the web via MiniMax",usage:"mmx search query --q <query>",options:[{flag:"--q <query>",description:"Search query string"}],examples:['mmx search query --q "MiniMax AI"','mmx search query --q "latest news" --output json'],async run(t,e){let i=e.q??e._positional?.[0];if(!i)throw new c("--q is required.",l.USAGE,'mmx search query --q "your search query"');let r=_(t.output);if(t.dryRun){console.log(b({request:{q:i}},r));return}let o=Ne(t.baseUrl),s=await v(t,{url:o,method:"POST",body:{q:i}}),n=s.organic||[];if(r!=="text"){console.log(b(s,r));return}if(t.quiet){for(let m of n)console.log(`${m.title} ${m.link}`);return}if(n.length===0){console.log("No results found.");return}for(let m of n){if(console.log(`${m.title}`),console.log(` ${m.link}`),m.snippet)console.log(` ${m.snippet}`);if(m.date)console.log(` ${m.date}`);console.log("")}}});import{readFileSync as vo,existsSync as fo}from"fs";import{extname as So}from"path";var Ro={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"};async function ko(t){if(t.startsWith("data:"))return t;if(t.startsWith("http://")||t.startsWith("https://")){let o=await fetch(t);if(!o.ok)throw new c(`Failed to download image: HTTP ${o.status}`,l.GENERAL);let n=(o.headers.get("content-type")||"image/jpeg").split(";")[0].trim(),m=await o.arrayBuffer(),a=Buffer.from(m).toString("base64");return`data:${n};base64,${a}`}if(!fo(t))throw new c(`File not found: ${t}`,l.USAGE);let e=So(t).toLowerCase(),i=Ro[e];if(!i)throw new c(`Unsupported image format "${e}". Supported: jpg, jpeg, png, webp`,l.USAGE);let r=vo(t);return`data:${i};base64,${r.toString("base64")}`}var Kn=d({name:"vision describe",description:"Describe an image using MiniMax VLM",usage:"mmx vision describe (--image <path-or-url> | --file-id <id>) [--prompt <text>]",options:[{flag:"--image <path-or-url>",description:"Local image path or URL (base64 encoded automatically)"},{flag:"--file-id <id>",description:"Pre-uploaded file ID (skips base64 conversion)"},{flag:"--prompt <text>",description:'Question about the image (default: "Describe the image.")'}],examples:["mmx vision describe --image photo.jpg",'mmx vision describe --image https://example.com/photo.jpg --prompt "What breed is this dog?"','mmx vision describe --file-id file-123456789 --prompt "Extract the text"'],async run(t,e){let i=e.image??e._positional?.[0],r=e.fileId,o=e.prompt||"Describe the image.";if(!i&&!r)if(A({nonInteractive:t.nonInteractive})){let u=await K({message:"Enter image path, URL, or File ID:"});if(!u)process.stderr.write(`Vision describe cancelled.
158
- `),process.exit(1);if(!u.includes(".")&&!u.startsWith("http"))r=u;else i=u}else throw new c("Missing required argument. Must provide either --image or --file-id.",l.USAGE,"mmx vision describe --image <path> OR --file-id <id>");else if(i&&r)throw new c("Conflicting arguments: cannot provide both --image and --file-id.",l.USAGE);let s=_(t.output);if(t.dryRun){process.stdout.write(b({request:{prompt:o,image:i,fileId:r}},s)+`
159
- `);return}let n=Be(t.baseUrl),m={prompt:o};if(r)m.file_id=r;else if(i){let u=await ko(i);m.image_url=u}let a=await v(t,{url:n,method:"POST",body:m});if(s!=="text"){process.stdout.write(b(a,s)+`
160
- `);return}process.stdout.write(a.content+`
161
- `)}});var Xn=d({name:"quota show",description:"Display Token Plan usage and remaining quotas",usage:"mmx quota show",examples:["mmx quota show","mmx quota show --output json"],async run(t,e){if(t.dryRun){console.log("Would fetch quota information.");return}let i=P(t.baseUrl),r=await v(t,{url:i}),o=r.model_remains||[],s=_(e.output);if(s!=="text"){console.log(b(r,s));return}if(t.quiet){for(let n of o){let m=n.current_interval_total_count-n.current_interval_usage_count;console.log(`${n.model_name} ${n.current_interval_usage_count} ${n.current_interval_total_count} ${m}`)}return}rt(o,t)}});var Qn=d({name:"config show",description:"Display current configuration",usage:"mmx config show",examples:["mmx config show","mmx config show --output json"],async run(t,e){let i=O(),r=_(t.output),o={region:t.region,base_url:t.baseUrl,output:t.output,timeout:t.timeout,config_file:X()};if(i.api_key)o.api_key=I(i.api_key);console.log(b(o,r))}});var Vn=["region","base_url","output","timeout","api_key"],Zn=d({name:"config set",description:"Set a config value",usage:"mmx config set --key <key> --value <value>",options:[{flag:"--key <key>",description:"Config key (region, base_url, output, timeout, api_key)"},{flag:"--value <value>",description:"Value to set"}],examples:["mmx config set --key output --value json","mmx config set --key timeout --value 600","mmx config set --key base_url --value https://api-uw.minimax.io"],async run(t,e){let{key:i,value:r}=e;if(!i||r===void 0)throw new c("--key and --value are required.",l.USAGE,"mmx config set --key <key> --value <value>");if(!Vn.includes(i))throw new c(`Invalid config key "${i}". Valid keys: ${Vn.join(", ")}`,l.USAGE);if(i==="region"&&!["global","cn"].includes(r))throw new c(`Invalid region "${r}". Valid values: global, cn`,l.USAGE);if(i==="output"&&!["text","json"].includes(r))throw new c(`Invalid output format "${r}". Valid values: text, json`,l.USAGE);if(i==="timeout"){let n=Number(r);if(isNaN(n)||n<=0)throw new c(`Invalid timeout "${r}". Must be a positive number.`,l.USAGE)}let o=_(t.output);if(t.dryRun){console.log(b({would_set:{[i]:r}},o));return}let s=O();if(s[i]=i==="timeout"?Number(r):r,await Y(s),!t.quiet)console.log(b({[i]:s[i]},o))}});function go(t){let e=t.match(/^--([a-zA-Z0-9-]+)/),i=e?e[1]:"",r=i.replace(/-([a-zA-Z0-9])/g,(n,m)=>m.toUpperCase()),o="string",s=!1;if(!t.includes("<")&&!t.includes("["))o="boolean";else if(t.includes("<n>")||t.includes("<hz>")||t.includes("<bps>")||t.includes("<count>"))o="number";if(t.toLowerCase().includes("repeatable"))s=!0;return{name:r,kebabName:i,inferredType:o,isArray:s}}function $e(t){let i={name:`mmx_${t.name.replace(/ /g,"_")}`,description:t.description,input_schema:{type:"object",properties:{},required:[]}};if(t.options)for(let r of t.options){let{name:o,inferredType:s,isArray:n}=go(r.flag);if(!o)continue;let m=r.type,a=n?"array":m??s,u={description:r.description};if(a==="array")u.type="array",u.items={type:"string"};else u.type=a;let y=i.input_schema;if(y.properties[o]=u,r.required)y.required.push(o)}return i}var Ao=["auth ","config ","update"],Wn=d({name:"config export-schema",description:"Export all (or one) CLI command(s) as Anthropic/OpenAI-compatible JSON tool schemas",usage:'mmx config export-schema [--command "<name>"]',options:[{flag:"--command <name>",description:'Export schema for a specific command only (e.g. "image generate")'}],examples:["mmx config export-schema",'mmx config export-schema --command "video generate"'],async run(t,e){let i=e.command;if(i){try{let{command:s}=U.resolve(i.split(" ")),n=$e(s);process.stdout.write(JSON.stringify(n,null,2)+`
162
- `)}catch{throw new c(`Command "${i}" not found.`,l.USAGE)}return}let o=U.getAllCommands().filter((s)=>!Ao.some((n)=>s.name.startsWith(n))).map((s)=>$e(s));process.stdout.write(JSON.stringify(o,null,2)+`
163
- `)}});var jo="1.0.5",Hn=d({name:"update",description:"Update mmx to the latest version",usage:"mmx update",examples:["mmx update"],async run(){process.stderr.write(`Current version: ${jo}
144
+ `),x=!1}else if(M.type==="content_block_delta"){if(M.delta.type==="text_delta")c+=M.delta.text,T.write(M.delta.text);else if(M.delta.type==="thinking_delta")k.write(M.delta.thinking)}}catch{}}if(x)k.write(_);if(T.write(`
145
+ `),a==="json")console.log(h({content:c},a))}else{let y=await v(t,{url:u,method:"POST",body:p,authStyle:"x-api-key"}),c=po(y.content);if(t.quiet||a==="text")console.log(c);else console.log(h(y,a))}}});import{writeFileSync as uo}from"fs";function at(t,e,n,i){if(e)if(uo(e,Buffer.from(t.data.audio,"hex")),i)console.log(e);else console.log(h({saved:e,duration_ms:t.extra_info?.audio_length,size_bytes:t.extra_info?.audio_size,sample_rate:t.extra_info?.audio_sample_rate},n));else{let o=t.data.audio_url??t.data.audio;if(i)console.log(o);else console.log(h({url:o,duration_ms:t.extra_info?.audio_length,size_bytes:t.extra_info?.audio_size},n))}}It();var Mr=b({name:"speech synthesize",description:"Synchronous TTS, up to 10k chars (speech-2.8-hd / 2.6 / 02)",usage:"mmx speech synthesize --text <text> [--out <path>] [flags]",options:[{flag:"--model <model>",description:"Model ID (default: speech-2.8-hd)"},{flag:"--text <text>",description:"Text to synthesize"},{flag:"--text-file <path>",description:"Read text from file (use - for stdin)"},{flag:"--voice <id>",description:"Voice ID (default: English_expressive_narrator)"},{flag:"--speed <n>",description:"Speech speed multiplier",type:"number"},{flag:"--volume <n>",description:"Volume level",type:"number"},{flag:"--pitch <n>",description:"Pitch adjustment",type:"number"},{flag:"--format <fmt>",description:"Audio format (default: mp3)"},{flag:"--sample-rate <hz>",description:"Sample rate (default: 32000)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate (default: 128000)",type:"number"},{flag:"--channels <n>",description:"Audio channels (default: 1)",type:"number"},{flag:"--language <code>",description:"Language boost"},{flag:"--subtitles",description:"Include subtitle timing data"},{flag:"--pronunciation <from/to>",description:"Custom pronunciation (repeatable)",type:"array"},{flag:"--out <path>",description:"Save audio to file (uses hex decoding)"},{flag:"--stream",description:"Stream raw audio to stdout"}],examples:['mmx speech synthesize --text "Hello, world!"','mmx speech synthesize --text "Hello, world!" --out hello.mp3','echo "Breaking news." | mmx speech synthesize --text-file - --out news.mp3','mmx speech synthesize --text "Stream" --stream | mpv --no-terminal -'],async run(t,e){let n=e.text??e._positional?.[0];if(e.textFile)n=lt(e.textFile);if(!n)throw new $("--text or --text-file is required.",l.USAGE,'mmx speech synthesize --text "Hello" --out hello.mp3');let i=e.model||"speech-2.8-hd",o=e.voice||"English_expressive_narrator",s=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),r=e.format||"mp3",a=e.out??`speech_${s}.${r}`,p="hex",u=f(t.output),y={model:i,text:n,voice_setting:{voice_id:o,speed:e.speed??void 0,vol:e.volume??void 0,pitch:e.pitch??void 0},audio_setting:{format:e.format||"mp3",sample_rate:e.sampleRate??32000,bitrate:e.bitrate??128000,channel:e.channels??1},output_format:p,stream:e.stream===!0};if(e.language)y.language_boost=e.language;if(e.subtitles)y.subtitle=!0;if(e.pronunciation)y.pronunciation_dict=e.pronunciation.map((w)=>{let[_,S]=w.split("/");return{tone:S||_,text:_}});if(t.dryRun){console.log(h({request:y},u));return}let c=Ge(t.baseUrl);if(e.stream){let w=await X(t,{url:c,method:"POST",body:y,stream:!0});for await(let _ of Bt(w)){if(!_.data||_.data==="[DONE]")break;let k=JSON.parse(_.data)?.data?.audio;if(k)process.stdout.write(Buffer.from(k,"hex"))}return}let x=await v(t,{url:c,method:"POST",body:y});if(!t.quiet)process.stderr.write(`[Model: ${i}]
146
+ `);at(x,a,u,t.quiet)}});function lo(t){let e=t.match(/^(.+?)_[A-Z]/);return e?e[1]:t}function $o(t,e){let n=e.toLowerCase();return t.filter((i)=>lo(i.voice_id).toLowerCase().includes(n))}var Tr=b({name:"speech voices",description:"List available system voices",usage:"mmx speech voices [--language <lang>]",options:[{flag:"--language <lang>",description:"Filter voices by language (e.g. english, korean, japanese)"}],examples:["mmx speech voices","mmx speech voices --language english","mmx speech voices --language korean","mmx speech voices --output json"],async run(t,e){let n=f(t.output);if(t.dryRun){console.log(h({request:{voice_type:"system"}},n));return}let o=(await v(t,{url:Ne(t.baseUrl),method:"POST",body:{voice_type:"system"}})).system_voice??[],s=e.language;if(s){let r=$o(o,s);if(n!=="text"){console.log(h(r,n));return}for(let a of r){let p=a.description?.join("; ")||"",u=a.voice_name?` (${a.voice_name})`:"";if(console.log(` ${a.voice_id}${u}`),p)console.log(` ${p}`)}}else{if(n!=="text"){console.log(h(o.map((r)=>r.voice_id),n));return}for(let r of o)console.log(r.voice_id)}}});import{createWriteStream as yo,unlinkSync as xo}from"fs";var Or=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function Gr(t){let e=process.stderr.isTTY,n=0,i=null,o=t;return{start(){if(!e)return;i=setInterval(()=>{process.stderr.write(`\r${Or[n%Or.length]} ${o}`),n++},80)},update(s){o=s},stop(s){if(i)clearInterval(i),i=null;if(e){if(process.stderr.write("\r\x1B[K"),s)process.stderr.write(`${s}
147
+ `)}}}}function Nr(t,e=""){let n=process.stderr.isTTY,i=30;return{update(o){if(!n)return;let s=Math.min(1,o/t),r=Math.round(30*s),a=30-r,p="█".repeat(r)+"░".repeat(a),u=`${Math.round(s*100)}%`;process.stderr.write(`\r${e} ${p} ${u}`)},finish(){if(n)process.stderr.write(`
148
+ `)}}}async function tt(t,e,n){let i=await fetch(t);if(!i.ok)throw new $(`Download failed: HTTP ${i.status}`,l.GENERAL);let o=Number(i.headers.get("content-length")||0),s=i.body?.getReader();if(!s)throw new $("No response body",l.GENERAL);let r=yo(e),a=o>0&&!n?.quiet?Nr(o,"Downloading"):null,p=0,u=!1;try{let y=new Promise((c,x)=>{r.on("error",x)});while(!0){let{done:c,value:x}=await Promise.race([s.read(),y]);if(c)break;if(!r.write(x))await new Promise((_)=>r.once("drain",_));p+=x.byteLength,a?.update(p)}u=!0}finally{if(s.releaseLock(),a?.finish(),await new Promise((y,c)=>{r.on("finish",y),r.on("error",c),r.end()}),!u)try{xo(e)}catch{}}return{size:p}}function Jt(t){if(t<1024)return`${t} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;if(t<1073741824)return`${(t/1048576).toFixed(1)} MB`;return`${(t/1073741824).toFixed(1)} GB`}import{mkdirSync as ho,existsSync as wo,readFileSync as bo}from"fs";import{join as fo,resolve as vo,extname as _o}from"path";var So={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"},Br=b({name:"image generate",description:"Generate images (image-01)",usage:"mmx image generate --prompt <text> [flags]",options:[{flag:"--prompt <text>",description:"Image description",required:!0},{flag:"--aspect-ratio <ratio>",description:"Aspect ratio (e.g. 16:9, 1:1)"},{flag:"--n <count>",description:"Number of images to generate (default: 1)",type:"number"},{flag:"--subject-ref <params>",description:"Subject reference (type=character,image=path)"},{flag:"--out-dir <dir>",description:"Download images to directory"},{flag:"--out-prefix <prefix>",description:"Filename prefix (default: image)"}],examples:['mmx image generate --prompt "A cat in a spacesuit on Mars" --aspect-ratio 16:9','mmx image generate --prompt "Logo design" --n 3 --out-dir ./generated/','mmx image generate --prompt "Mountain landscape" --quiet'],async run(t,e){let n=e.prompt??e._positional?.[0];if(!n)if(j({nonInteractive:t.nonInteractive})){let c=await K({message:"Enter your image prompt:"});if(!c)process.stderr.write(`Image generation cancelled.
149
+ `),process.exit(1);n=c}else st("prompt","mmx image generate --prompt <text>");let i={model:"image-01",prompt:n,aspect_ratio:e.aspectRatio||void 0,n:e.n??1};if(e.subjectRef){let c=e.subjectRef,x=Object.fromEntries(c.split(",").map((_)=>{let S=_.indexOf("=");if(S===-1)return[_,""];return[_.slice(0,S),_.slice(S+1)]})),w={type:x.type||"character"};if(x.image)if(x.image.startsWith("http"))w.image_url=x.image;else{let _=vo(x.image),S=bo(_),k=_o(_).toLowerCase(),T=So[k]||"image/jpeg";w.image_file=`data:${T};base64,${S.toString("base64")}`}i.subject_reference=[w]}let o=f(t.output);if(t.dryRun){console.log(h({request:i},o));return}let s=Be(t.baseUrl),r=await v(t,{url:s,method:"POST",body:i}),a=r.data.image_urls||[];if(!t.quiet)process.stderr.write(`[Model: image-01]
150
+ `);let p=e.outDir??".";if(!wo(p))ho(p,{recursive:!0});let u=e.outPrefix||"image",y=[];for(let c=0;c<a.length;c++){let x=`${u}_${String(c+1).padStart(3,"0")}.jpg`,w=fo(p,x);await tt(a[c],w,{quiet:t.quiet}),y.push(w)}if(t.quiet)console.log(y.join(`
151
+ `));else console.log(h({id:r.data.task_id,saved:y,success_count:r.data.success_count,failed_count:r.data.failed_count},o))}});async function Ir(t,e){let n=Date.now()+e.timeoutSec*1000,i=Gr("Polling...");if(!t.quiet)i.start();try{while(Date.now()<n){let o=await v(t,{url:e.url});if(e.getStatus&&!t.quiet)i.update(`Status: ${e.getStatus(o)}`);if(e.isComplete(o))return i.stop("Done."),o;if(e.isFailed(o))throw i.stop("Failed."),new $("Task failed.",l.GENERAL);await new Promise((s)=>setTimeout(s,e.intervalSec*1000))}}finally{i.stop()}throw new $("Polling timed out.",l.TIMEOUT,"Try increasing --timeout or check task status manually.")}import{readFileSync as Ro}from"fs";import{extname as ko}from"path";var go={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"},Jr=b({name:"video generate",description:"Generate a video (Hailuo-2.3 / 2.3-Fast)",usage:"mmx video generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID (default: MiniMax-Hailuo-2.3)"},{flag:"--prompt <text>",description:"Video description",required:!0},{flag:"--first-frame <path-or-url>",description:"First frame image"},{flag:"--callback-url <url>",description:"Webhook URL for completion notification"},{flag:"--download <path>",description:"Save video to file on completion"},{flag:"--no-wait",description:"Return task ID immediately without waiting"},{flag:"--async",description:"Return task ID immediately (agent/CI mode, same as --no-wait but explicit)"},{flag:"--poll-interval <seconds>",description:"Polling interval when waiting (default: 5)",type:"number"}],examples:['mmx video generate --prompt "A man reads a book. Static shot."','mmx video generate --prompt "Ocean waves at sunset." --download sunset.mp4','mmx video generate --prompt "A robot painting." --async --quiet','mmx video generate --prompt "A robot painting." --no-wait --quiet'],async run(t,e){let n=e.prompt;if(!n)if(j({nonInteractive:t.nonInteractive})){let A=await K({message:"Enter your video prompt:"});if(!A)process.stderr.write(`Video generation cancelled.
152
+ `),process.exit(1);n=A}else st("prompt","mmx video generate --prompt <text>");let i=e.model||"MiniMax-Hailuo-2.3",o=f(t.output),s={model:i,prompt:n};if(e.firstFrame){let A=e.firstFrame;if(A.startsWith("http"))s.first_frame_image=A;else{let mt=Ro(A),$t=ko(A).toLowerCase(),yt=go[$t]||"image/jpeg";s.first_frame_image=`data:${yt};base64,${mt.toString("base64")}`}}if(e.callbackUrl)s.callback_url=e.callbackUrl;if(t.dryRun){console.log(h({request:s},o));return}let r=Ie(t.baseUrl),p=(await v(t,{url:r,method:"POST",body:s})).task_id;if(!t.quiet&&!e.noWait&&!t.async)process.stderr.write(`[Model: ${i}]
153
+ `);else if(!t.quiet)process.stderr.write(`[Model: ${i}]
154
+ `);if(e.noWait||t.async){process.stdout.write(JSON.stringify({taskId:p})),process.stdout.write(`
155
+ `);return}let u=e.pollInterval??5,y=_t(t.baseUrl,p),c=await Ir(t,{url:y,intervalSec:u,timeoutSec:t.timeout,isComplete:(A)=>A.status==="Success",isFailed:(A)=>A.status==="Failed",getStatus:(A)=>A.status});if(!c.file_id)throw new $("Task completed but no file_id returned.",l.GENERAL);let w=(await v(t,{url:St(t.baseUrl,c.file_id)})).file?.download_url;if(!w)throw new $("No download URL available for this file.",l.GENERAL);if(e.download){let A=e.download,{size:mt}=await tt(w,A,{quiet:t.quiet});if(t.quiet)console.log(A);else console.log(h({task_id:p,status:"Success",file_id:c.file_id,saved:A,size:Jt(mt)},o));return}let _=await import("os"),{join:S}=await import("path"),k=S(_.tmpdir(),"mmx-video"),{existsSync:T,mkdirSync:Q}=await import("fs");if(!T(k))Q(k,{recursive:!0});let M=S(k,`${p}.mp4`);await tt(w,M,{quiet:t.quiet}),process.stdout.write(M),process.stdout.write(`
156
+ `)}});var zr=b({name:"video task get",description:"Query video task status",usage:"mmx video task get --task-id <id>",options:[{flag:"--task-id <id>",description:"Video generation task ID"}],examples:["mmx video task get --task-id 106916112212032","mmx video task get --task-id 106916112212032 --output json"],async run(t,e){let n=e.taskId;if(!n)throw new $("--task-id is required.",l.USAGE,"mmx video task get --task-id <id>");if(t.dryRun){console.log(`Would query task: ${n}`);return}let i=_t(t.baseUrl,n),o=await v(t,{url:i}),s=f(t.output);if(t.quiet){console.log(o.status);return}console.log(h({task_id:o.task_id,status:o.status,file_id:o.file_id,video_width:o.video_width,video_height:o.video_height},s))}});var Yr=b({name:"video download",description:"Download a completed video by file ID",usage:"mmx video download --file-id <id> --out <path>",options:[{flag:"--file-id <id>",description:"File ID to download"},{flag:"--out <path>",description:"Output file path"}],examples:["mmx video download --file-id 176844028768320 --out video.mp4","mmx video download --file-id 176844028768320 --out video.mp4 --quiet"],async run(t,e){let n=e.fileId;if(!n)throw new $("--file-id is required.",l.USAGE,"mmx video download --file-id <id> --out <path>");let i=e.out;if(!i)throw new $("--out is required.",l.USAGE,"mmx video download --file-id <id> --out video.mp4");if(t.dryRun){console.log(`Would download file ${n} to ${i}`);return}let o=St(t.baseUrl,n),r=(await v(t,{url:o})).file?.download_url;if(!r)throw new $("No download URL available for this file.",l.GENERAL,"The file may still be processing. Check task status first.");let{size:a}=await tt(r,i,{quiet:t.quiet}),p=f(t.output);if(t.quiet){console.log(i);return}console.log(h({saved:i,size:Jt(a)},p))}});It();function Kr(t){return(t.apiKey??t.fileApiKey??"").startsWith("sk-cp-")}function Xr(t){return Kr(t)?"music-2.6":"music-2.6-free"}function Qr(t){return Kr(t)?"music-cover":"music-cover-free"}var Vr=b({name:"music generate",description:"Generate a song (music-2.6-free)",usage:"mmx music generate --prompt <text> (--lyrics <text> | --instrumental | --lyrics-optimizer) [--out <path>] [flags]",options:[{flag:"--prompt <text>",description:"Music style description (can be detailed — see examples)"},{flag:"--lyrics <text>",description:"Song lyrics with structure tags. Required unless --instrumental or --lyrics-optimizer is used."},{flag:"--lyrics-file <path>",description:"Read lyrics from file (use - for stdin)"},{flag:"--lyrics-optimizer",description:"Auto-generate lyrics from prompt (cannot be used with --lyrics or --instrumental)"},{flag:"--instrumental",description:"Generate instrumental music (no vocals). Cannot be used with --lyrics."},{flag:"--vocals <text>",description:'Vocal style, e.g. "warm male baritone", "bright female soprano", "duet with harmonies"'},{flag:"--genre <text>",description:"Music genre, e.g. folk, pop, jazz"},{flag:"--mood <text>",description:"Mood or emotion, e.g. warm, melancholic, uplifting"},{flag:"--instruments <text>",description:'Instruments to feature, e.g. "acoustic guitar, piano"'},{flag:"--tempo <text>",description:"Tempo description, e.g. fast, slow, moderate"},{flag:"--bpm <number>",description:"Exact tempo in beats per minute",type:"number"},{flag:"--key <text>",description:"Musical key, e.g. C major, A minor, G sharp"},{flag:"--avoid <text>",description:"Elements to avoid in the generated music"},{flag:"--use-case <text>",description:'Use case context, e.g. "background music for video", "theme song"'},{flag:"--structure <text>",description:'Song structure, e.g. "verse-chorus-verse-bridge-chorus"'},{flag:"--references <text>",description:'Reference tracks or artists, e.g. "similar to Ed Sheeran, Taylor Swift"'},{flag:"--extra <text>",description:"Additional fine-grained requirements not covered above"},{flag:"--aigc-watermark",description:"Embed AI-generated content watermark in audio for content provenance"},{flag:"--format <fmt>",description:"Audio format (default: mp3)"},{flag:"--sample-rate <hz>",description:"Sample rate (default: 44100)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate (default: 256000)",type:"number"},{flag:"--stream",description:"Stream raw audio to stdout"},{flag:"--out <path>",description:"Save audio to file (uses hex decoding)"}],examples:['mmx music generate --prompt "Upbeat pop" --lyrics "La la la..." --out summer.mp3','mmx music generate --prompt "Indie folk, melancholic" --lyrics-file song.txt --out my_song.mp3',"# Auto-generate lyrics from prompt:",'mmx music generate --prompt "Upbeat pop about summer" --lyrics-optimizer --out summer.mp3',"# Instrumental:",'mmx music generate --prompt "Cinematic orchestral, building tension" --instrumental --out bgm.mp3',"# Detailed prompt with vocal characteristics:",'mmx music generate --prompt "Warm morning folk" --vocals "male and female duet, harmonies in chorus" --instruments "acoustic guitar, piano" --bpm 95 --lyrics-file song.txt --out duet.mp3'],async run(t,e){let{prompt:n,lyrics:i}=e,o=e.instrumental===!0,s=e.lyricsOptimizer===!0;if(e.lyricsFile)i=lt(e.lyricsFile);if(o&&(i||e.lyricsFile))throw new $("Cannot use --instrumental with --lyrics or --lyrics-file.",l.USAGE,"mmx music generate --prompt <style> --instrumental");if(s&&(i||o))throw new $("Cannot use --lyrics-optimizer with --lyrics, --lyrics-file, or --instrumental.",l.USAGE,"mmx music generate --prompt <text> --lyrics-optimizer");if(!n&&!i&&!o&&!s)throw new $("At least one of --prompt or --lyrics is required.",l.USAGE,"mmx music generate --prompt <text> --lyrics <text>");if(!o&&!s&&!i?.trim())throw new $("Lyrics are required. Add --lyrics or --lyrics-file, or use --instrumental for pure music, or --lyrics-optimizer to auto-generate.",l.USAGE,"mmx music generate --prompt <text> --lyrics <text>");let r=[];if(e.vocals)r.push(`Vocals: ${e.vocals}`);if(e.genre)r.push(`Genre: ${e.genre}`);if(e.mood)r.push(`Mood: ${e.mood}`);if(e.instruments)r.push(`Instruments: ${e.instruments}`);if(e.tempo)r.push(`Tempo: ${e.tempo}`);if(e.bpm)r.push(`BPM: ${e.bpm}`);if(e.key)r.push(`Key: ${e.key}`);if(e.avoid)r.push(`Avoid: ${e.avoid}`);if(e.useCase)r.push(`Use case: ${e.useCase}`);if(e.structure)r.push(`Structure: ${e.structure}`);if(e.references)r.push(`References: ${e.references}`);if(e.extra)r.push(`Extra: ${e.extra}`);if(r.length>0){let S=r.join(". ");n=n?`${n}. ${S}`:S}let a=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),p=e.format||"mp3",u=e.out??`music_${a}.${p}`,y=f(t.output),c=Xr(t),x={model:c,prompt:n,lyrics:i,is_instrumental:o||void 0,lyrics_optimizer:s||void 0,audio_setting:{format:e.format||"mp3",sample_rate:e.sampleRate??44100,bitrate:e.bitrate??256000},output_format:"hex",stream:e.stream===!0};if(e.aigcWatermark)x.aigc_watermark=!0;if(t.dryRun){console.log(h({request:x},y));return}let w=Rt(t.baseUrl);if(e.stream){let k=(await X(t,{url:w,method:"POST",body:x,stream:!0})).body?.getReader();if(!k)throw new $("No response body",l.GENERAL);while(!0){let{done:T,value:Q}=await k.read();if(T)break;process.stdout.write(Q)}k.releaseLock();return}let _=await v(t,{url:w,method:"POST",body:x});if(!t.quiet)process.stderr.write(`[Model: ${c}]
157
+ `);at(_,u,y,t.quiet)}});import{readFileSync as Ao}from"fs";var Zr=b({name:"music cover",description:"Generate a cover version of a song based on reference audio (music-cover-free)",usage:"mmx music cover --prompt <text> (--audio <url> | --audio-file <path>) [--lyrics <text>] [--out <path>] [flags]",options:[{flag:"--prompt <text>",description:'Target cover style, e.g. "Indie folk, acoustic guitar, warm male vocal"'},{flag:"--audio <url>",description:"URL of the reference audio (mp3, wav, flac, etc. — 6s to 6min, max 50MB)"},{flag:"--audio-file <path>",description:"Local reference audio file (auto base64-encoded)"},{flag:"--lyrics <text>",description:"Cover lyrics. If omitted, extracted from reference audio via ASR."},{flag:"--lyrics-file <path>",description:"Read lyrics from file (use - for stdin)"},{flag:"--seed <number>",description:"Random seed 0–1000000 for reproducible results",type:"number"},{flag:"--format <fmt>",description:"Audio format: mp3, wav, pcm (default: mp3)"},{flag:"--sample-rate <hz>",description:"Sample rate: 16000, 24000, 32000, 44100 (default: 44100)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate: 32000, 64000, 128000, 256000 (default: 256000)",type:"number"},{flag:"--channel <n>",description:"Channels: 1 (mono) or 2 (stereo, default)",type:"number"},{flag:"--stream",description:"Stream raw audio to stdout"},{flag:"--out <path>",description:"Save audio to file"}],examples:['mmx music cover --prompt "Indie folk, acoustic guitar, warm male vocal" --audio https://example.com/song.mp3 --out cover.mp3','mmx music cover --prompt "Jazz, piano, slow" --audio-file original.mp3 --lyrics-file lyrics.txt --out jazz_cover.mp3','mmx music cover --prompt "Pop, upbeat" --audio https://example.com/ref.mp3 --seed 42 --out reproducible.mp3'],async run(t,e){let{prompt:n,audio:i,audioFile:o}=e;if(!n)throw new $("--prompt is required.",l.USAGE,"mmx music cover --prompt <text> --audio <url>");if(!i&&!o)throw new $("One of --audio <url> or --audio-file <path> is required.",l.USAGE,"mmx music cover --prompt <text> --audio <url>");if(i&&o)throw new $("Use either --audio or --audio-file, not both.",l.USAGE);let s=e.lyrics;if(e.lyricsFile){let{readTextFromPathOrStdin:_}=await Promise.resolve().then(() => (It(),qr));s=_(e.lyricsFile)}let r=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),a=e.format||"mp3",p=e.out??`cover_${r}.${a}`,u=f(t.output),y=Qr(t),c={model:y,prompt:n,lyrics:s,seed:e.seed,audio_setting:{format:a,sample_rate:e.sampleRate??44100,bitrate:e.bitrate??256000,channel:e.channel??void 0},output_format:"hex",stream:e.stream===!0};if(i)c.audio_url=i;else c.audio_base64=Ao(o).toString("base64");if(t.dryRun){console.log(h({request:c},u));return}let x=Rt(t.baseUrl);if(e.stream){let S=(await X(t,{url:x,method:"POST",body:c,stream:!0})).body?.getReader();if(!S)throw new $("No response body",l.GENERAL);while(!0){let{done:k,value:T}=await S.read();if(k)break;process.stdout.write(T)}S.releaseLock();return}let w=await v(t,{url:x,method:"POST",body:c});if(!t.quiet)process.stderr.write(`[Model: ${y}]
158
+ `);at(w,p,u,t.quiet)}});var Ur=b({name:"search query",description:"Search the web via MiniMax",usage:"mmx search query --q <query>",options:[{flag:"--q <query>",description:"Search query string"}],examples:['mmx search query --q "MiniMax AI"','mmx search query --q "latest news" --output json'],async run(t,e){let n=e.q??e._positional?.[0];if(!n)throw new $("--q is required.",l.USAGE,'mmx search query --q "your search query"');let i=f(t.output);if(t.dryRun){console.log(h({request:{q:n}},i));return}let o=Je(t.baseUrl),s=await v(t,{url:o,method:"POST",body:{q:n}}),r=s.organic||[];if(i!=="text"){console.log(h(s,i));return}if(t.quiet){for(let a of r)console.log(`${a.title} ${a.link}`);return}if(r.length===0){console.log("No results found.");return}for(let a of r){if(console.log(`${a.title}`),console.log(` ${a.link}`),a.snippet)console.log(` ${a.snippet}`);if(a.date)console.log(` ${a.date}`);console.log("")}}});import{readFileSync as jo,existsSync as qo}from"fs";import{extname as Mo}from"path";var To={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"};async function Oo(t){if(t.startsWith("data:"))return t;if(t.startsWith("http://")||t.startsWith("https://")){let o=await fetch(t);if(!o.ok)throw new $(`Failed to download image: HTTP ${o.status}`,l.GENERAL);let r=(o.headers.get("content-type")||"image/jpeg").split(";")[0].trim(),a=await o.arrayBuffer(),p=Buffer.from(a).toString("base64");return`data:${r};base64,${p}`}if(!qo(t))throw new $(`File not found: ${t}`,l.USAGE);let e=Mo(t).toLowerCase(),n=To[e];if(!n)throw new $(`Unsupported image format "${e}". Supported: jpg, jpeg, png, webp`,l.USAGE);let i=jo(t);return`data:${n};base64,${i.toString("base64")}`}var Wr=b({name:"vision describe",description:"Describe an image using MiniMax VLM",usage:"mmx vision describe (--image <path-or-url> | --file-id <id>) [--prompt <text>]",options:[{flag:"--image <path-or-url>",description:"Local image path or URL (base64 encoded automatically)"},{flag:"--file-id <id>",description:"Pre-uploaded file ID (skips base64 conversion)"},{flag:"--prompt <text>",description:'Question about the image (default: "Describe the image.")'}],examples:["mmx vision describe --image photo.jpg",'mmx vision describe --image https://example.com/photo.jpg --prompt "What breed is this dog?"','mmx vision describe --file-id file-123456789 --prompt "Extract the text"'],async run(t,e){let n=e.image??e._positional?.[0],i=e.fileId,o=e.prompt||"Describe the image.";if(!n&&!i)if(j({nonInteractive:t.nonInteractive})){let u=await K({message:"Enter image path, URL, or File ID:"});if(!u)process.stderr.write(`Vision describe cancelled.
159
+ `),process.exit(1);if(!u.includes(".")&&!u.startsWith("http"))i=u;else n=u}else throw new $("Missing required argument. Must provide either --image or --file-id.",l.USAGE,"mmx vision describe --image <path> OR --file-id <id>");else if(n&&i)throw new $("Conflicting arguments: cannot provide both --image and --file-id.",l.USAGE);let s=f(t.output);if(t.dryRun){process.stdout.write(h({request:{prompt:o,image:n,fileId:i}},s)+`
160
+ `);return}let r=ze(t.baseUrl),a={prompt:o};if(i)a.file_id=i;else if(n){let u=await Oo(n);a.image_url=u}let p=await v(t,{url:r,method:"POST",body:a});if(s!=="text"){process.stdout.write(h(p,s)+`
161
+ `);return}process.stdout.write(p.content+`
162
+ `)}});var Hr=b({name:"quota show",description:"Display Token Plan usage and remaining quotas",usage:"mmx quota show",examples:["mmx quota show","mmx quota show --output json"],async run(t,e){if(t.dryRun){console.log("Would fetch quota information.");return}let n=P(t.baseUrl),i=await v(t,{url:n}),o=i.model_remains||[],s=f(e.output);if(s!=="text"){console.log(h(i,s));return}if(t.quiet){for(let r of o){let a=r.current_interval_total_count-r.current_interval_usage_count;console.log(`${r.model_name} ${r.current_interval_usage_count} ${r.current_interval_total_count} ${a}`)}return}it(o,t)}});var Cr=b({name:"config show",description:"Display current configuration",usage:"mmx config show",examples:["mmx config show","mmx config show --output json"],async run(t,e){let n=G(),i=f(t.output),o={region:t.region,base_url:t.baseUrl,output:t.output,timeout:t.timeout,config_file:V()};if(n.api_key)o.api_key=J(n.api_key);console.log(h(o,i))}});var Er=["region","base_url","output","timeout","api_key"],Pr=b({name:"config set",description:"Set a config value",usage:"mmx config set --key <key> --value <value>",options:[{flag:"--key <key>",description:"Config key (region, base_url, output, timeout, api_key)"},{flag:"--value <value>",description:"Value to set"}],examples:["mmx config set --key output --value json","mmx config set --key timeout --value 600","mmx config set --key base_url --value https://api-uw.minimax.io"],async run(t,e){let{key:n,value:i}=e;if(!n||i===void 0)throw new $("--key and --value are required.",l.USAGE,"mmx config set --key <key> --value <value>");if(!Er.includes(n))throw new $(`Invalid config key "${n}". Valid keys: ${Er.join(", ")}`,l.USAGE);if(n==="region"&&!["global","cn"].includes(i))throw new $(`Invalid region "${i}". Valid values: global, cn`,l.USAGE);if(n==="output"&&!["text","json"].includes(i))throw new $(`Invalid output format "${i}". Valid values: text, json`,l.USAGE);if(n==="timeout"){let r=Number(i);if(isNaN(r)||r<=0)throw new $(`Invalid timeout "${i}". Must be a positive number.`,l.USAGE)}let o=f(t.output);if(t.dryRun){console.log(h({would_set:{[n]:i}},o));return}let s=G();if(s[n]=n==="timeout"?Number(i):i,await Y(s),!t.quiet)console.log(h({[n]:s[n]},o))}});function Go(t){let e=t.match(/^--([a-zA-Z0-9-]+)/),n=e?e[1]:"",i=n.replace(/-([a-zA-Z0-9])/g,(r,a)=>a.toUpperCase()),o="string",s=!1;if(!t.includes("<")&&!t.includes("["))o="boolean";else if(t.includes("<n>")||t.includes("<hz>")||t.includes("<bps>")||t.includes("<count>"))o="number";if(t.toLowerCase().includes("repeatable"))s=!0;return{name:i,kebabName:n,inferredType:o,isArray:s}}function xe(t){let n={name:`mmx_${t.name.replace(/ /g,"_")}`,description:t.description,input_schema:{type:"object",properties:{},required:[]}};if(t.options)for(let i of t.options){let{name:o,inferredType:s,isArray:r}=Go(i.flag);if(!o)continue;let a=i.type,p=r?"array":a??s,u={description:i.description};if(p==="array")u.type="array",u.items={type:"string"};else u.type=p;let y=n.input_schema;if(y.properties[o]=u,i.required)y.required.push(o)}return n}var No=["auth ","config ","update"],Lr=b({name:"config export-schema",description:"Export all (or one) CLI command(s) as Anthropic/OpenAI-compatible JSON tool schemas",usage:'mmx config export-schema [--command "<name>"]',options:[{flag:"--command <name>",description:'Export schema for a specific command only (e.g. "image generate")'}],examples:["mmx config export-schema",'mmx config export-schema --command "video generate"'],async run(t,e){let n=e.command;if(n){try{let{command:s}=E.resolve(n.split(" ")),r=xe(s);process.stdout.write(JSON.stringify(r,null,2)+`
163
+ `)}catch{throw new $(`Command "${n}" not found.`,l.USAGE)}return}let o=E.getAllCommands().filter((s)=>!No.some((r)=>s.name.startsWith(r))).map((s)=>xe(s));process.stdout.write(JSON.stringify(o,null,2)+`
164
+ `)}});var Bo="1.0.6",Fr=b({name:"update",description:"Update mmx to the latest version",usage:"mmx update",examples:["mmx update"],async run(){process.stderr.write(`Current version: ${Bo}
164
165
 
165
166
  `),process.stderr.write(`Run:
166
167
  `),process.stderr.write(` npm update -g mmx-cli
167
168
 
168
- `)}});class Un{root={children:new Map};constructor(t){for(let[e,i]of Object.entries(t))this.register(e,i)}register(t,e){let i=t.split(" "),r=this.root;for(let o of i){if(!r.children.has(o))r.children.set(o,{children:new Map});r=r.children.get(o)}r.command=e}getAllCommands(){let t=[],e=(i)=>{if(i.command)t.push(i.command);for(let r of i.children.values())e(r)};return e(this.root),t}resolve(t){let e=this.root,i=[];for(let r of t){let o=e.children.get(r);if(!o)break;e=o,i.push(r)}if(e.command)return{command:e.command,extra:t.slice(i.length)};if(i.length>0&&e.children.size===1){let[,r]=e.children.entries().next().value;if(r.command)return{command:r.command,extra:t.slice(i.length)}}if(i.length>0&&e.children.size>0){let r=Array.from(e.children.entries()).map(([o,s])=>{if(s.command)return` ${i.join(" ")} ${o} ${s.command.description}`;let n=Array.from(s.children.keys()).join(", ");return` ${i.join(" ")} ${o} [${n}]`}).join(`
169
- `);throw new c(`Unknown command: mmx ${t.join(" ")}
169
+ `)}});class Dr{root={children:new Map};constructor(t){for(let[e,n]of Object.entries(t))this.register(e,n)}register(t,e){let n=t.split(" "),i=this.root;for(let o of n){if(!i.children.has(o))i.children.set(o,{children:new Map});i=i.children.get(o)}i.command=e}getAllCommands(){let t=[],e=(n)=>{if(n.command)t.push(n.command);for(let i of n.children.values())e(i)};return e(this.root),t}resolve(t){let e=this.root,n=[];for(let i of t){let o=e.children.get(i);if(!o)break;e=o,n.push(i)}if(e.command)return{command:e.command,extra:t.slice(n.length)};if(n.length>0&&e.children.size===1){let[,i]=e.children.entries().next().value;if(i.command)return{command:i.command,extra:t.slice(n.length)}}if(n.length>0&&e.children.size>0){let i=Array.from(e.children.entries()).map(([o,s])=>{if(s.command)return` ${n.join(" ")} ${o} ${s.command.description}`;let r=Array.from(s.children.keys()).join(", ");return` ${n.join(" ")} ${o} [${r}]`}).join(`
170
+ `);throw new $(`Unknown command: mmx ${t.join(" ")}
170
171
 
171
172
  Available commands:
172
- ${r}`,l.USAGE,`mmx ${i.join(" ")} --help`)}throw new c(`Unknown command: mmx ${t.join(" ")}`,l.USAGE,"mmx --help")}bold=(t,e)=>e.isTTY?`\x1B[1m${t}\x1B[0m`:t;accent=(t,e)=>e.isTTY?`\x1B[38;2;248;103;58m${t}\x1B[0m`:t;dim=(t,e)=>e.isTTY?`\x1B[2m${t}\x1B[0m`:t;printHelp(t,e=process.stdout){if(t.length===0){this.printRootHelp(e);return}let i=this.root;for(let o of t){let s=i.children.get(o);if(!s){this.printRootHelp(e);return}i=s}if(i.command){this.printCommandHelp(i.command,e);return}let r=t.join(" ");e.write(`
173
- ${this.bold("Usage:",e)} mmx ${r} <command> [flags]
173
+ ${i}`,l.USAGE,`mmx ${n.join(" ")} --help`)}throw new $(`Unknown command: mmx ${t.join(" ")}`,l.USAGE,"mmx --help")}bold=(t,e)=>e.isTTY?`\x1B[1m${t}\x1B[0m`:t;accent=(t,e)=>e.isTTY?`\x1B[38;2;248;103;58m${t}\x1B[0m`:t;dim=(t,e)=>e.isTTY?`\x1B[2m${t}\x1B[0m`:t;printHelp(t,e=process.stdout){if(t.length===0){this.printRootHelp(e);return}let n=this.root;for(let o of t){let s=n.children.get(o);if(!s){this.printRootHelp(e);return}n=s}if(n.command){this.printCommandHelp(n.command,e);return}let i=t.join(" ");e.write(`
174
+ ${this.bold("Usage:",e)} mmx ${i} <command> [flags]
174
175
 
175
176
  `),e.write(`${this.bold("Commands:",e)}
176
- `),this.printChildren(i,r,e),e.write(`
177
- `)}printRootHelp(t){let e=["███╗ ███╗███╗ ███╗██╗ ██╗","████╗ ████║████╗ ████║╚██╗██╔╝","██╔████╔██║██╔████╔██║ ╚███╔╝ ","██║╚██╔╝██║██║╚██╔╝██║ ██╔██╗ ","██║ ╚═╝ ██║██║ ╚═╝ ██║██╔╝ ██╗","╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝"],i=[[240,23,122],[242,43,106],[244,63,90],[246,83,74],[248,103,58],[250,123,42]];t.write(`
178
- `);for(let n=0;n<e.length;n++)if(t.isTTY){let[m,a,u]=i[n];t.write(`\x1B[1;38;2;${m};${a};${u}m${e[n]}\x1B[0m
179
- `)}else t.write(e[n]+`
180
- `);let r=(n)=>this.bold(n,t),o=(n)=>this.accent(n,t),s=(n)=>this.dim(n,t);t.write(`
181
- ${r("Usage:")} mmx <resource> <command> [flags]
182
-
183
- ${r("Resources:")}
177
+ `),this.printChildren(n,i,e),e.write(`
178
+ `)}printRootHelp(t){let e=["███╗ ███╗███╗ ███╗██╗ ██╗","████╗ ████║████╗ ████║╚██╗██╔╝","██╔████╔██║██╔████╔██║ ╚███╔╝ ","██║╚██╔╝██║██║╚██╔╝██║ ██╔██╗ ","██║ ╚═╝ ██║██║ ╚═╝ ██║██╔╝ ██╗","╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝"],n=[[240,23,122],[242,43,106],[244,63,90],[246,83,74],[248,103,58],[250,123,42]];t.write(`
179
+ `);for(let r=0;r<e.length;r++)if(t.isTTY){let[a,p,u]=n[r];t.write(`\x1B[1;38;2;${a};${p};${u}m${e[r]}\x1B[0m
180
+ `)}else t.write(e[r]+`
181
+ `);let i=(r)=>this.bold(r,t),o=(r)=>this.accent(r,t),s=(r)=>this.dim(r,t);t.write(`
182
+ ${i("Usage:")} mmx <resource> <command> [flags]
183
+
184
+ ${i("Resources:")}
184
185
  ${o("auth")} ${s("Authentication (login, status, refresh, logout)")}
185
186
  ${o("text")} ${s("Text generation (chat)")}
186
187
  ${o("speech")} ${s("Speech synthesis (synthesize, voices)")}
187
188
  ${o("image")} ${s("Image generation (generate)")}
188
189
  ${o("video")} ${s("Video generation (generate, task get, download)")}
189
- ${o("music")} ${s("Music generation (generate)")}
190
+ ${o("music")} ${s("Music generation (generate, cover)")}
190
191
  ${o("search")} ${s("Web search (query)")}
191
192
  ${o("vision")} ${s("Image understanding (describe)")}
192
193
  ${o("quota")} ${s("Usage quotas (show)")}
193
194
  ${o("config")} ${s("CLI configuration (show, set, export-schema)")}
194
195
  ${o("update")} ${s("Update mmx to a newer version")}
195
196
 
196
- ${r("Global Flags:")}
197
+ ${i("Global Flags:")}
197
198
  ${o("--api-key <key>")} ${s("API key (overrides all other auth)")}
198
199
  ${o("--region <region>")} ${s("API region: global (default), cn")}
199
200
  ${o("--base-url <url>")} ${s("API base URL (overrides region)")}
@@ -207,23 +208,23 @@ ${r("Global Flags:")}
207
208
  ${o("--version")} ${s("Print version and exit")}
208
209
  ${o("--help")} ${s("Show help")}
209
210
 
210
- ${r("Getting Help:")}
211
+ ${i("Getting Help:")}
211
212
  ${s("Add --help after any command to see its full list of options, defaults,")}
212
213
  ${s("and usage examples. For example:")} mmx text chat --help
213
- `)}printCommandHelp(t,e){let i=(s)=>this.bold(s,e),r=(s)=>this.accent(s,e),o=(s)=>this.dim(s,e);if(e.write(`
214
+ `)}printCommandHelp(t,e){let n=(s)=>this.bold(s,e),i=(s)=>this.accent(s,e),o=(s)=>this.dim(s,e);if(e.write(`
214
215
  ${t.description}
215
- `),t.usage)e.write(`${i("Usage:")} ${t.usage}
216
- `);if(t.options&&t.options.length>0){let s=Math.max(...t.options.map((n)=>n.flag.length));e.write(`
217
- ${i("Options:")}
218
- `);for(let n of t.options)e.write(` ${r(n.flag.padEnd(s+2))} ${o(n.description)}
216
+ `),t.usage)e.write(`${n("Usage:")} ${t.usage}
217
+ `);if(t.options&&t.options.length>0){let s=Math.max(...t.options.map((r)=>r.flag.length));e.write(`
218
+ ${n("Options:")}
219
+ `);for(let r of t.options)e.write(` ${i(r.flag.padEnd(s+2))} ${o(r.description)}
219
220
  `)}if(t.examples&&t.examples.length>0){e.write(`
220
- ${i("Examples:")}
221
+ ${n("Examples:")}
221
222
  `);for(let s of t.examples)e.write(` ${o(s)}
222
223
  `)}e.write(`
223
224
  ${o("Global flags (--api-key, --output, --quiet, etc.) are always available.")}
224
225
  `),e.write(`${o("Run")} mmx --help ${o("for the full list.")}
225
- `)}printChildren(t,e,i){let r=[],o=(n,m)=>{for(let[a,u]of n.children){if(u.command)r.push({fullName:`${m} ${a}`,description:u.command.description});if(u.children.size>0)o(u,`${m} ${a}`)}};o(t,e);let s=Math.max(...r.map((n)=>n.fullName.length));for(let{fullName:n,description:m}of r)i.write(` ${this.accent(n.padEnd(s),i)} ${this.dim(m,i)}
226
- `)}}var U=new Un({"auth login":vn,"auth status":fn,"auth refresh":Sn,"auth logout":Rn,"text chat":An,"speech synthesize":jn,"speech voices":Mn,"image generate":Gn,"video generate":Bn,"video task get":In,"video download":zn,"music generate":Jn,"search query":Yn,"vision describe":Kn,"quota show":Xn,"config show":Qn,"config set":Zn,"config export-schema":Wn,update:Hn});function tt(t){if(t instanceof c){if(_(process.env.MINIMAX_OUTPUT)==="json")process.stderr.write(JSON.stringify(t.toJSON(),null,2)+`
226
+ `)}printChildren(t,e,n){let i=[],o=(r,a)=>{for(let[p,u]of r.children){if(u.command)i.push({fullName:`${a} ${p}`,description:u.command.description});if(u.children.size>0)o(u,`${a} ${p}`)}};o(t,e);let s=Math.max(...i.map((r)=>r.fullName.length));for(let{fullName:r,description:a}of i)n.write(` ${this.accent(r.padEnd(s),n)} ${this.dim(a,n)}
227
+ `)}}var E=new Dr({"auth login":Sr,"auth status":Rr,"auth refresh":kr,"auth logout":gr,"text chat":jr,"speech synthesize":Mr,"speech voices":Tr,"image generate":Br,"video generate":Jr,"video task get":zr,"video download":Yr,"music generate":Vr,"music cover":Zr,"search query":Ur,"vision describe":Wr,"quota show":Hr,"config show":Cr,"config set":Pr,"config export-schema":Lr,update:Fr});function et(t){if(t instanceof $){if(f(process.env.MINIMAX_OUTPUT)==="json")process.stderr.write(JSON.stringify(t.toJSON(),null,2)+`
227
228
  `);else{if(process.stderr.write(`
228
229
  Error: ${t.message}
229
230
  `),t.hint)process.stderr.write(`
@@ -231,23 +232,23 @@ Error: ${t.message}
231
232
  `).join(`
232
233
  `)}
233
234
  `);process.stderr.write(` (exit code ${t.exitCode})
234
- `)}process.exit(t.exitCode)}if(t instanceof Error){if(t.name==="AbortError"||t.message.includes("timed out")){let o=new c("Request timed out.",l.TIMEOUT,"Try increasing --timeout or retry later.");return tt(o)}if(t instanceof TypeError&&t.message==="fetch failed"){let o=new c("Network request failed.",l.NETWORK,"Check your network connection and proxy settings. Also verify MINIMAX_BASE_URL is a valid URL.");return tt(o)}let e=t.message.toLowerCase();if(e.includes("failed to fetch")||e.includes("connection refused")||e.includes("econnrefused")||e.includes("connection reset")||e.includes("econnreset")||e.includes("network error")||e.includes("enotfound")||e.includes("getaddrinfo")||e.includes("proxy")||e.includes("socket")||e.includes("etimedout")||e.includes("timeout")||e.includes("eai_AGAIN")){let o="Check your network connection and proxy settings.";if(e.includes("proxy"))o="Proxy error — check HTTP_PROXY / HTTPS_PROXY environment variables and proxy authentication.";let s=new c("Network request failed.",l.NETWORK,o);return tt(s)}let r=t.code;if(r==="ENOENT"||r==="EACCES"||r==="ENOSPC"||r==="ENOTDIR"||r==="EISDIR"||r==="EPERM"||r==="EBUSY"){let o="Check the file path and permissions.";if(r==="ENOENT")o="File or directory not found.";if(r==="EACCES"||r==="EPERM")o="Permission denied — check file or directory permissions.";if(r==="ENOSPC")o="Disk full — free up space and try again.";let s=new c(`File system error: ${t.message}`,l.GENERAL,o);return tt(s)}else if(typeof r==="string"&&r.startsWith("E")){let o=new c(`File system error: ${t.message}`,l.GENERAL,"Check the file path and permissions.");return tt(o)}if(process.stderr.write(`
235
+ `)}process.exit(t.exitCode)}if(t instanceof Error){if(t.name==="AbortError"||t.message.includes("timed out")){let o=new $("Request timed out.",l.TIMEOUT,"Try increasing --timeout or retry later.");return et(o)}if(t instanceof TypeError&&t.message==="fetch failed"){let o=new $("Network request failed.",l.NETWORK,"Check your network connection and proxy settings. Also verify MINIMAX_BASE_URL is a valid URL.");return et(o)}let e=t.message.toLowerCase();if(e.includes("failed to fetch")||e.includes("connection refused")||e.includes("econnrefused")||e.includes("connection reset")||e.includes("econnreset")||e.includes("network error")||e.includes("enotfound")||e.includes("getaddrinfo")||e.includes("proxy")||e.includes("socket")||e.includes("etimedout")||e.includes("timeout")||e.includes("eai_AGAIN")){let o="Check your network connection and proxy settings.";if(e.includes("proxy"))o="Proxy error — check HTTP_PROXY / HTTPS_PROXY environment variables and proxy authentication.";let s=new $("Network request failed.",l.NETWORK,o);return et(s)}let i=t.code;if(i==="ENOENT"||i==="EACCES"||i==="ENOSPC"||i==="ENOTDIR"||i==="EISDIR"||i==="EPERM"||i==="EBUSY"){let o="Check the file path and permissions.";if(i==="ENOENT")o="File or directory not found.";if(i==="EACCES"||i==="EPERM")o="Permission denied — check file or directory permissions.";if(i==="ENOSPC")o="Disk full — free up space and try again.";let s=new $(`File system error: ${t.message}`,l.GENERAL,o);return et(s)}else if(typeof i==="string"&&i.startsWith("E")){let o=new $(`File system error: ${t.message}`,l.GENERAL,"Check the file path and permissions.");return et(o)}if(process.stderr.write(`
235
236
  Error: ${t.message}
236
237
  `),process.env.MINIMAX_VERBOSE==="1")process.stderr.write(`${t.stack}
237
238
  `)}else process.stderr.write(`
238
239
  Error: ${String(t)}
239
- `);process.exit(l.GENERAL)}var Mo="/v1/api/openplatform/coding_plan/remains";function qo(t){return Z[t]+Mo}async function To(t,e,i){try{let r=await fetch(qo(t),{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},signal:AbortSignal.timeout(i)});if(!r.ok)return!1;return(await r.json()).base_resp?.status_code===0}catch{return!1}}async function Cn(t){process.stderr.write("Detecting region...");let e=Object.keys(Z),r=(await Promise.all(e.map(async(s)=>({region:s,ok:await To(s,t,5000)})))).find((s)=>s.ok);if(!r)return process.stderr.write(` failed
240
+ `);process.exit(l.GENERAL)}var Io="/v1/api/openplatform/coding_plan/remains";function Jo(t){return W[t]+Io}async function zo(t,e,n){try{let i=await fetch(Jo(t),{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},signal:AbortSignal.timeout(n)});if(!i.ok)return!1;return(await i.json()).base_resp?.status_code===0}catch{return!1}}async function tn(t){process.stderr.write("Detecting region...");let e=Object.keys(W),i=(await Promise.all(e.map(async(s)=>({region:s,ok:await zo(s,t,5000)})))).find((s)=>s.ok);if(!i)return process.stderr.write(` failed
240
241
  `),process.stderr.write(`Warning: API key failed validation against all regions. Falling back to global.
241
- `),"global";let o=r.region;return process.stderr.write(` ${o}
242
- `),o}async function Pn(t){let e=O();e.region=t,await Y(e)}import{join as Oo}from"path";import{readFileSync as Go,writeFileSync as No}from"fs";var En=()=>Oo(mt(),"update-state.json"),Bo=86400000,Io=3000,zo="MiniMax-AI-Dev/minimax-cli";function Jo(){try{let t=Go(En(),"utf-8");return JSON.parse(t)}catch{return null}}function Yo(t){try{No(En(),JSON.stringify(t))}catch{}}async function Ko(){try{let t=await fetch(`https://api.github.com/repos/${zo}/releases/latest`,{headers:{Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},signal:AbortSignal.timeout(Io)});if(!t.ok)return null;return(await t.json()).tag_name??null}catch{return null}}var le=null;function Ln(){return le}async function Fn(t){if(process.env.CI||!process.stderr.isTTY)return;let e=Jo(),i=Date.now();if(e&&i-e.lastChecked<Bo){if(e.latestVersion&&e.latestVersion!==`v${t}`)le=e.latestVersion;return}let r=await Ko();if(!r)return;if(Yo({lastChecked:i,latestVersion:r}),r!==`v${t}`)le=r}async function Dn(t){if(t.apiKey||t.fileApiKey)return;let e=process.env.MINIMAX_API_KEY,i;if(e){if(!A({nonInteractive:t.nonInteractive}))i=e;else if(await gn({message:`Found MINIMAX_API_KEY in environment (${I(e)}). Save it to config file?`}))i=e}if(!i){if(!A({nonInteractive:t.nonInteractive}))throw new c("No API key found.",l.AUTH,`Set env var: export MINIMAX_API_KEY=sk-xxxxx
243
- Pass directly: --api-key sk-xxxxx`);let s=await K({message:"Enter your MiniMax API key:"});if(!s)throw new c("API key is required.",l.AUTH);i=s}let r={...O(),api_key:i};await Y(r),t.fileApiKey=i;let o=t.configPath??"~/.mmx/config.json";process.stderr.write(`API key saved to ${o}
244
- `)}var ti="1.0.5";process.on("SIGINT",()=>{process.stderr.write(`
242
+ `),"global";let o=i.region;return process.stderr.write(` ${o}
243
+ `),o}async function en(t){let e=G();e.region=t,await Y(e)}import{join as Yo}from"path";import{readFileSync as Ko,writeFileSync as Xo}from"fs";var rn=()=>Yo(pt(),"update-state.json"),Qo=86400000,Vo=3000,Zo="MiniMax-AI-Dev/minimax-cli";function Uo(){try{let t=Ko(rn(),"utf-8");return JSON.parse(t)}catch{return null}}function Wo(t){try{Xo(rn(),JSON.stringify(t))}catch{}}async function Ho(){try{let t=await fetch(`https://api.github.com/repos/${Zo}/releases/latest`,{headers:{Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},signal:AbortSignal.timeout(Vo)});if(!t.ok)return null;return(await t.json()).tag_name??null}catch{return null}}var de=null;function nn(){return de}async function on(t){if(process.env.CI||!process.stderr.isTTY)return;let e=Uo(),n=Date.now();if(e&&n-e.lastChecked<Qo){if(e.latestVersion&&e.latestVersion!==`v${t}`)de=e.latestVersion;return}let i=await Ho();if(!i)return;if(Wo({lastChecked:n,latestVersion:i}),i!==`v${t}`)de=i}async function sn(t){if(t.apiKey||t.fileApiKey)return;let e=process.env.MINIMAX_API_KEY,n;if(e){if(!j({nonInteractive:t.nonInteractive}))n=e;else if(await Ar({message:`Found MINIMAX_API_KEY in environment (${J(e)}). Save it to config file?`}))n=e}if(!n){if(!j({nonInteractive:t.nonInteractive}))throw new $("No API key found.",l.AUTH,`Set env var: export MINIMAX_API_KEY=sk-xxxxx
244
+ Pass directly: --api-key sk-xxxxx`);let s=await K({message:"Enter your MiniMax API key:"});if(!s)throw new $("API key is required.",l.AUTH);n=s}let i={...G(),api_key:n};await Y(i),t.fileApiKey=n;let o=t.configPath??"~/.mmx/config.json";process.stderr.write(`API key saved to ${o}
245
+ `)}var an="1.0.6";process.on("SIGINT",()=>{process.stderr.write(`
245
246
  Interrupted. Exiting.
246
- `),process.exit(130)});var Xo=[["auth","login"],["auth","logout"],["config","show"],["config","set"],["config","export-schema"],["update"]];async function Qo(){let t=process.argv.slice(2);if(t.includes("--version")||t.includes("-v"))console.log(`mmx ${ti}`),process.exit(0);let e=he(t,ht);if(t.includes("--help")||t.includes("-h"))U.printHelp(e,process.stderr),process.exit(0);if(e.length===0){U.printHelp([],process.stderr);let{command:u}=U.resolve(["quota","show"]),y=Jt(t,[...ht,...u.options??[]]),$=Zt(y),h=!!($.apiKey||$.fileApiKey),w=!!await B();if(h||w)await u.execute($,y);else process.stderr.write(` Not logged in.
247
+ `),process.exit(130)});process.stdout.on("error",(t)=>{if(t.code==="EPIPE")process.exit(0);else throw t});var Co=[["auth","login"],["auth","logout"],["config","show"],["config","set"],["config","export-schema"],["update"]];async function Eo(){let t=process.argv.slice(2);if(t.includes("--version")||t.includes("-v"))console.log(`mmx ${an}`),process.exit(0);let e=fe(t,wt);if(t.includes("--help")||t.includes("-h"))E.printHelp(e,process.stderr),process.exit(0);if(e.length===0){E.printHelp([],process.stderr);let{command:u}=E.resolve(["quota","show"]),y=Qt(t,[...wt,...u.options??[]]),c=Ct(y),x=!!(c.apiKey||c.fileApiKey),w=!!await I();if(x||w)await u.execute(c,y);else process.stderr.write(` Not logged in.
247
248
  `),process.stderr.write(` mmx auth login --api-key sk-xxxxx
248
249
 
249
- `);process.exit(0)}let{command:i,extra:r}=U.resolve(e),o=Jt(t,[...ht,...i.options??[]]);if(r.length>0)o._positional=r;let s=Zt(o);if(!Xo.some((u)=>u.every((y,$)=>e[$]===y)))await Dn(s);if(s.needsRegionDetection){let u=s.apiKey||s.fileApiKey;if(u){let y=await Cn(u);s.region=y,s.baseUrl=Z[y],s.needsRegionDetection=!1,await Pn(y)}}let m=Fn(ti).catch(()=>{});await i.execute(s,o),await m;let a=Ln();if(a&&!s.quiet)process.stderr.write(`
250
- Update available: ${a}
250
+ `);process.exit(0)}let{command:n,extra:i}=E.resolve(e),o=Qt(t,[...wt,...n.options??[]]);if(i.length>0)o._positional=i;let s=Ct(o);if(!Co.some((u)=>u.every((y,c)=>e[c]===y)))await sn(s);if(s.needsRegionDetection){let u=s.apiKey||s.fileApiKey;if(u){let y=await tn(u);s.region=y,s.baseUrl=W[y],s.needsRegionDetection=!1,await en(y)}}let a=on(an).catch(()=>{});await n.execute(s,o),await a;let p=nn();if(p&&!s.quiet)process.stderr.write(`
251
+ Update available: ${p}
251
252
  `),process.stderr.write(` npm update -g mmx-cli
252
253
 
253
- `)}Qo().catch(tt);
254
+ `)}Eo().catch(et);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mmx-cli",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "CLI for the MiniMax AI Platform",
5
5
  "type": "module",
6
6
  "engines": {