mmx-cli 1.0.7 → 1.0.9

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 +9 -2
  2. package/dist/mmx.mjs +207 -194
  3. package/package.json +1 -1
package/dist/mmx.mjs CHANGED
@@ -1,187 +1,195 @@
1
1
  #!/usr/bin/env node
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,`
2
+ import{createRequire as An}from"node:module";var xn=Object.create;var{getPrototypeOf:yn,defineProperty:Qe,getOwnPropertyNames:wn}=Object;var bn=Object.prototype.hasOwnProperty;function fn(e){return this[e]}var _n,vn,be=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var o=t?_n??=new WeakMap:vn??=new WeakMap,s=o.get(e);if(s)return s}n=e!=null?xn(yn(e)):{};let i=t||!e||!e.__esModule?Qe(n,"default",{value:e,enumerable:!0}):n;for(let m of wn(e))if(!bn.call(i,m))Qe(i,m,{get:fn.bind(e,m),enumerable:!0});if(r)o.set(e,i);return i};var vt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Sn=(e)=>e;function Rn(e,t){this[e]=Sn.bind(null,t)}var St=(e,t)=>{for(var n in t)Qe(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Rn.bind(t,n)})};var Ve=(e,t)=>()=>(e&&(t=e(e=0)),t);var se=An(import.meta.url);var Fe=vt((Ls,Et)=>{var Le={to(e,t){if(!t)return`\x1B[${e+1}G`;return`\x1B[${t+1};${e+1}H`},move(e,t){let n="";if(e<0)n+=`\x1B[${-e}D`;else if(e>0)n+=`\x1B[${e}C`;if(t<0)n+=`\x1B[${-t}A`;else if(t>0)n+=`\x1B[${t}B`;return n},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},tr={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},ir={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let t="";for(let n=0;n<e;n++)t+=this.line+(n<e-1?Le.up():"");if(e)t+=Le.left;return t}};Et.exports={cursor:Le,scroll:tr,erase:ir,beep:"\x07"}});var et=vt((Fs,De)=>{var Te=process||{},Lt=Te.argv||[],je=Te.env||{},nr=!(!!je.NO_COLOR||Lt.includes("--no-color"))&&(!!je.FORCE_COLOR||Lt.includes("--color")||Te.platform==="win32"||(Te.stdout||{}).isTTY&&je.TERM!=="dumb"||!!je.CI),rr=(e,t,n=e)=>(r)=>{let o=""+r,s=o.indexOf(t,e.length);return~s?e+or(o,t,n,s)+t:e+o+t},or=(e,t,n,r)=>{let o="",s=0;do o+=e.substring(s,r)+n,s=r+t.length,r=e.indexOf(t,s);while(~r);return o+e.substring(s)},Ft=(e=nr)=>{let t=e?rr:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};De.exports=Ft();De.exports.createColors=Ft});import{stdin as li,stdout as $i}from"node:process";import*as P from"node:readline";import Dt from"node:readline";import{WriteStream as sr}from"node:tty";function mr({onlyFirst:e=!1}={}){let t=["[\\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(t,e?void 0:"g")}function di(e){if(typeof e!="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(pr,"")}function hi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function he(e,t={}){if(typeof e!="string"||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=di(e),e.length===0))return 0;e=e.replace(lr()," ");let n=t.ambiguousIsNarrow?1:2,r=0;for(let o of e){let s=o.codePointAt(0);if(s<=31||s>=127&&s<=159||s>=768&&s<=879)continue;switch(ur.eastAsianWidth(o)){case"F":case"W":r+=2;break;case"A":r+=n;break;default:r+=1}}return r}function hr(){let e=new Map;for(let[t,n]of Object.entries(k)){for(let[r,o]of Object.entries(n))k[r]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},n[r]=k[r],e.set(o[0],o[1]);Object.defineProperty(k,t,{value:n,enumerable:!1})}return Object.defineProperty(k,"codes",{value:e,enumerable:!1}),k.color.close="\x1B[39m",k.bgColor.close="\x1B[49m",k.color.ansi=ei(),k.color.ansi256=ti(),k.color.ansi16m=ii(),k.bgColor.ansi=ei(tt),k.bgColor.ansi256=ti(tt),k.bgColor.ansi16m=ii(tt),Object.defineProperties(k,{rgbToAnsi256:{value:(t,n,r)=>t===n&&n===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value:(t)=>{let n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[r]=n;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:(t)=>k.rgbToAnsi256(...k.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value:(t)=>{if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,r,o;if(t>=232)n=((t-232)*10+8)/255,r=n,o=n;else{t-=16;let m=t%36;n=Math.floor(t/36)/5,r=Math.floor(m/6)/5,o=m%6/5}let s=Math.max(n,r,o)*2;if(s===0)return 30;let i=30+(Math.round(o)<<2|Math.round(r)<<1|Math.round(n));return s===2&&(i+=60),i},enumerable:!1},rgbToAnsi:{value:(t,n,r)=>k.ansi256ToAnsi(k.rgbToAnsi256(t,n,r)),enumerable:!1},hexToAnsi:{value:(t)=>k.ansi256ToAnsi(k.hexToAnsi256(t)),enumerable:!1}}),k}function oi(e,t,n){return String(e).normalize().replace(/\r\n/g,`
3
3
  `).split(`
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
- ${t}
4
+ `).map((r)=>_r(r,t,n)).join(`
5
+ `)}function Rr(e,t){if(e===t)return;let n=e.split(`
6
+ `),r=t.split(`
7
+ `),o=[];for(let s=0;s<Math.max(n.length,r.length);s++)n[s]!==r[s]&&o.push(s);return o}function Be(e){return e===bi}function Ge(e,t){e.isTTY&&e.setRawMode(t)}class C{constructor({render:e,input:t=li,output:n=$i,...r},o=!0){z(this,"input"),z(this,"output"),z(this,"rl"),z(this,"opts"),z(this,"_track",!1),z(this,"_render"),z(this,"_cursor",0),z(this,"state","initial"),z(this,"value"),z(this,"error",""),z(this,"subscribers",new Map),z(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=e.bind(this),this._track=o,this.input=t,this.output=n}prompt(){let e=new sr(0);return e._write=(t,n,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(e),this.rl=Dt.createInterface({input:this.input,output:e,tabSize:2,prompt:"",escapeCodeTimeout:50}),Dt.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),Ge(this.input,!0),this.output.on("resize",this.render),this.render(),new Promise((t,n)=>{this.once("submit",()=>{this.output.write(G.cursor.show),this.output.off("resize",this.render),Ge(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(G.cursor.show),this.output.off("resize",this.render),Ge(this.input,!1),t(bi)})})}on(e,t){let n=this.subscribers.get(e)??[];n.push({cb:t}),this.subscribers.set(e,n)}once(e,t){let n=this.subscribers.get(e)??[];n.push({cb:t,once:!0}),this.subscribers.set(e,n)}emit(e,...t){let n=this.subscribers.get(e)??[],r=[];for(let o of n)o.cb(...t),o.once&&r.push(()=>n.splice(n.indexOf(o),1));for(let o of r)o()}unsubscribe(){this.subscribers.clear()}onKeypress(e,t){if(this.state==="error"&&(this.state="active"),t?.name&&!this._track&&si.has(t.name)&&this.emit("cursor",si.get(t.name)),t?.name&&Ar.has(t.name)&&this.emit("cursor",t.name),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),e==="\t"&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),e&&this.emit("key",e.toLowerCase()),t?.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")}e==="\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
+ `),Ge(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=oi(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
9
+ `).length-1;this.output.write(G.cursor.move(-999,e*-1))}render(){let e=oi(this._render(this)??"",process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(G.cursor.hide);else{let t=Rr(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let n=t[0];this.output.write(G.cursor.move(0,n)),this.output.write(G.erase.lines(1));let r=e.split(`
10
+ `);this.output.write(r[n]),this._prevFrame=e,this.output.write(G.cursor.move(0,r.length-n-1));return}else if(t&&t?.length>1){let n=t[0];this.output.write(G.cursor.move(0,n)),this.output.write(G.erase.down());let r=e.split(`
11
+ `).slice(n);this.output.write(r.join(`
12
+ `)),this._prevFrame=e;return}this.output.write(G.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}}function vi({input:e=li,output:t=$i,overwrite:n=!0,hideCursor:r=!0}={}){let o=P.createInterface({input:e,output:t,prompt:"",tabSize:1});P.emitKeypressEvents(e,o),e.isTTY&&e.setRawMode(!0);let s=(i,{name:m})=>{if(String(i)==="\x03"){r&&t.write(G.cursor.show),process.exit(0);return}if(!n)return;P.moveCursor(t,m==="return"?0:-1,m==="return"?-1:0,()=>{P.clearLine(t,1,()=>{e.once("keypress",s)})})};return r&&t.write(G.cursor.hide),e.once("keypress",s),()=>{e.off("keypress",s),r&&t.write(G.cursor.show),e.isTTY&&!Xr&&e.setRawMode(!1),o.terminal=!1,o.close()}}var G,te,pr,xi,ar,ur,cr=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},lr,tt=10,ei=(e=0)=>(t)=>`\x1B[${t+e}m`,ti=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,ii=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,k,$r,dr,xr,Oe,yr=39,nt="\x07",yi="[",wr="]",wi="m",rt,ni=(e)=>`${Oe.values().next().value}${yi}${e}${wi}`,ri=(e)=>`${Oe.values().next().value}${rt}${e}${nt}`,br=(e)=>e.split(" ").map((t)=>he(t)),it=(e,t,n)=>{let r=[...t],o=!1,s=!1,i=he(di(e[e.length-1]));for(let[m,u]of r.entries()){let a=he(u);if(i+a<=n?e[e.length-1]+=u:(e.push(u),i=0),Oe.has(u)&&(o=!0,s=r.slice(m+1).join("").startsWith(rt)),o){s?u===nt&&(o=!1,s=!1):u===wi&&(o=!1);continue}i+=a,i===n&&m<r.length-1&&(e.push(""),i=0)}!i&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},fr=(e)=>{let t=e.split(" "),n=t.length;for(;n>0&&!(he(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},_r=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let r="",o,s,i=br(e),m=[""];for(let[a,$]of e.split(" ").entries()){n.trim!==!1&&(m[m.length-1]=m[m.length-1].trimStart());let d=he(m[m.length-1]);if(a!==0&&(d>=t&&(n.wordWrap===!1||n.trim===!1)&&(m.push(""),d=0),(d>0||n.trim===!1)&&(m[m.length-1]+=" ",d++)),n.hard&&i[a]>t){let h=t-d,y=1+Math.floor((i[a]-h-1)/t);Math.floor((i[a]-1)/t)<y&&m.push(""),it(m,$,t);continue}if(d+i[a]>t&&d>0&&i[a]>0){if(n.wordWrap===!1&&d<t){it(m,$,t);continue}m.push("")}if(d+i[a]>t&&n.wordWrap===!1){it(m,$,t);continue}m[m.length-1]+=$}n.trim!==!1&&(m=m.map((a)=>fr(a)));let u=[...m.join(`
13
+ `)];for(let[a,$]of u.entries()){if(r+=$,Oe.has($)){let{groups:h}=new RegExp(`(?:\\${yi}(?<code>\\d+)m|\\${rt}(?<uri>.*)${nt})`).exec(u.slice(a).join(""))||{groups:{}};if(h.code!==void 0){let y=Number.parseFloat(h.code);o=y===yr?void 0:y}else h.uri!==void 0&&(s=h.uri.length===0?void 0:h.uri)}let d=xr.codes.get(Number(o));u[a+1]===`
14
+ `?(s&&(r+=ri("")),o&&d&&(r+=ni(d))):$===`
15
+ `&&(o&&d&&(r+=ni(o)),s&&(r+=ri(s)))}return r},vr,Sr=(e,t,n)=>(t in e)?vr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,z=(e,t,n)=>(Sr(e,typeof t!="symbol"?t+"":t,n),n),bi,si,Ar,ot,kr,Mr=(e,t,n)=>(t in e)?kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mi=(e,t,n)=>(Mr(e,typeof t!="symbol"?t+"":t,n),n),st,qr,jr=(e,t,n)=>(t in e)?qr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pi=(e,t,n)=>(jr(e,typeof t!="symbol"?t+"":t,n),n),fi,Tr,Gr=(e,t,n)=>(t in e)?Tr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ai=(e,t,n)=>(Gr(e,typeof t!="symbol"?t+"":t,n),n),mt,Or,Br=(e,t,n)=>(t in e)?Or(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ui=(e,t,n)=>(Br(e,typeof t!="symbol"?t+"":t,n),n),_i,Nr,gr=(e,t,n)=>(t in e)?Nr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ci=(e,t,n)=>(gr(e,typeof t!="symbol"?t+"":t,n),n),pt,zr,Jr=(e,t,n)=>(t in e)?zr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ir=(e,t,n)=>(Jr(e,typeof t!="symbol"?t+"":t,n),n),at,Xr;var ut=Ve(()=>{G=be(Fe(),1),te=be(et(),1);pr=mr();xi={exports:{}};(function(e){var t={};e.exports=t,t.eastAsianWidth=function(r){var o=r.charCodeAt(0),s=r.length==2?r.charCodeAt(1):0,i=o;return 55296<=o&&o<=56319&&56320<=s&&s<=57343&&(o&=1023,s&=1023,i=o<<10|s,i+=65536),i==12288||65281<=i&&i<=65376||65504<=i&&i<=65510?"F":i==8361||65377<=i&&i<=65470||65474<=i&&i<=65479||65482<=i&&i<=65487||65490<=i&&i<=65495||65498<=i&&i<=65500||65512<=i&&i<=65518?"H":4352<=i&&i<=4447||4515<=i&&i<=4519||4602<=i&&i<=4607||9001<=i&&i<=9002||11904<=i&&i<=11929||11931<=i&&i<=12019||12032<=i&&i<=12245||12272<=i&&i<=12283||12289<=i&&i<=12350||12353<=i&&i<=12438||12441<=i&&i<=12543||12549<=i&&i<=12589||12593<=i&&i<=12686||12688<=i&&i<=12730||12736<=i&&i<=12771||12784<=i&&i<=12830||12832<=i&&i<=12871||12880<=i&&i<=13054||13056<=i&&i<=19903||19968<=i&&i<=42124||42128<=i&&i<=42182||43360<=i&&i<=43388||44032<=i&&i<=55203||55216<=i&&i<=55238||55243<=i&&i<=55291||63744<=i&&i<=64255||65040<=i&&i<=65049||65072<=i&&i<=65106||65108<=i&&i<=65126||65128<=i&&i<=65131||110592<=i&&i<=110593||127488<=i&&i<=127490||127504<=i&&i<=127546||127552<=i&&i<=127560||127568<=i&&i<=127569||131072<=i&&i<=194367||177984<=i&&i<=196605||196608<=i&&i<=262141?"W":32<=i&&i<=126||162<=i&&i<=163||165<=i&&i<=166||i==172||i==175||10214<=i&&i<=10221||10629<=i&&i<=10630?"Na":i==161||i==164||167<=i&&i<=168||i==170||173<=i&&i<=174||176<=i&&i<=180||182<=i&&i<=186||188<=i&&i<=191||i==198||i==208||215<=i&&i<=216||222<=i&&i<=225||i==230||232<=i&&i<=234||236<=i&&i<=237||i==240||242<=i&&i<=243||247<=i&&i<=250||i==252||i==254||i==257||i==273||i==275||i==283||294<=i&&i<=295||i==299||305<=i&&i<=307||i==312||319<=i&&i<=322||i==324||328<=i&&i<=331||i==333||338<=i&&i<=339||358<=i&&i<=359||i==363||i==462||i==464||i==466||i==468||i==470||i==472||i==474||i==476||i==593||i==609||i==708||i==711||713<=i&&i<=715||i==717||i==720||728<=i&&i<=731||i==733||i==735||768<=i&&i<=879||913<=i&&i<=929||931<=i&&i<=937||945<=i&&i<=961||963<=i&&i<=969||i==1025||1040<=i&&i<=1103||i==1105||i==8208||8211<=i&&i<=8214||8216<=i&&i<=8217||8220<=i&&i<=8221||8224<=i&&i<=8226||8228<=i&&i<=8231||i==8240||8242<=i&&i<=8243||i==8245||i==8251||i==8254||i==8308||i==8319||8321<=i&&i<=8324||i==8364||i==8451||i==8453||i==8457||i==8467||i==8470||8481<=i&&i<=8482||i==8486||i==8491||8531<=i&&i<=8532||8539<=i&&i<=8542||8544<=i&&i<=8555||8560<=i&&i<=8569||i==8585||8592<=i&&i<=8601||8632<=i&&i<=8633||i==8658||i==8660||i==8679||i==8704||8706<=i&&i<=8707||8711<=i&&i<=8712||i==8715||i==8719||i==8721||i==8725||i==8730||8733<=i&&i<=8736||i==8739||i==8741||8743<=i&&i<=8748||i==8750||8756<=i&&i<=8759||8764<=i&&i<=8765||i==8776||i==8780||i==8786||8800<=i&&i<=8801||8804<=i&&i<=8807||8810<=i&&i<=8811||8814<=i&&i<=8815||8834<=i&&i<=8835||8838<=i&&i<=8839||i==8853||i==8857||i==8869||i==8895||i==8978||9312<=i&&i<=9449||9451<=i&&i<=9547||9552<=i&&i<=9587||9600<=i&&i<=9615||9618<=i&&i<=9621||9632<=i&&i<=9633||9635<=i&&i<=9641||9650<=i&&i<=9651||9654<=i&&i<=9655||9660<=i&&i<=9661||9664<=i&&i<=9665||9670<=i&&i<=9672||i==9675||9678<=i&&i<=9681||9698<=i&&i<=9701||i==9711||9733<=i&&i<=9734||i==9737||9742<=i&&i<=9743||9748<=i&&i<=9749||i==9756||i==9758||i==9792||i==9794||9824<=i&&i<=9825||9827<=i&&i<=9829||9831<=i&&i<=9834||9836<=i&&i<=9837||i==9839||9886<=i&&i<=9887||9918<=i&&i<=9919||9924<=i&&i<=9933||9935<=i&&i<=9953||i==9955||9960<=i&&i<=9983||i==10045||i==10071||10102<=i&&i<=10111||11093<=i&&i<=11097||12872<=i&&i<=12879||57344<=i&&i<=63743||65024<=i&&i<=65039||i==65533||127232<=i&&i<=127242||127248<=i&&i<=127277||127280<=i&&i<=127337||127344<=i&&i<=127386||917760<=i&&i<=917999||983040<=i&&i<=1048573||1048576<=i&&i<=1114109?"A":"N"},t.characterLength=function(r){var o=this.eastAsianWidth(r);return o=="F"||o=="W"||o=="A"?2:1};function n(r){return r.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(r){for(var o=n(r),s=0,i=0;i<o.length;i++)s=s+this.characterLength(o[i]);return s},t.slice=function(r,o,s){textLen=t.length(r),o=o||0,s=s||1,o<0&&(o=textLen+o),s<0&&(s=textLen+s);for(var i="",m=0,u=n(r),a=0;a<u.length;a++){var $=u[a],d=t.length($);if(m>=o-(d==2?1:0))if(m+d<=s)i+=$;else break;m+=d}return i}})(xi);ar=xi.exports,ur=hi(ar),lr=hi(cr);k={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(k.modifier);$r=Object.keys(k.color),dr=Object.keys(k.bgColor);[...$r,...dr];xr=hr(),Oe=new Set(["\x1B","›"]),rt=`${wr}8;;`;vr=Object.defineProperty;bi=Symbol("clack:cancel");si=new Map([["k","up"],["j","down"],["h","left"],["l","right"]]),Ar=new Set(["up","down","left","right","space","enter"]);ot=class ot extends C{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(t)=>{this.output.write(G.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};kr=Object.defineProperty;st=class st extends C{constructor(e){super(e,!1),mi(this,"options"),mi(this,"cursor",0);let{options:t}=e;this.options=Object.entries(t).flatMap(([n,r])=>[{value:n,group:!0,label:n},...r.map((o)=>({...o,group:n}))]),this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:n})=>n===e.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(e){return this.options.filter((t)=>t.group===e)}isGroupSelected(e){return this.getGroupItems(e).every((t)=>this.value.includes(t.value))}toggleValue(){let e=this.options[this.cursor];if(e.group===!0){let t=e.value,n=this.getGroupItems(t);this.isGroupSelected(t)?this.value=this.value.filter((r)=>n.findIndex((o)=>o.value===r)===-1):this.value=[...this.value,...n.map((r)=>r.value)],this.value=Array.from(new Set(this.value))}else{let t=this.value.includes(e.value);this.value=t?this.value.filter((n)=>n!==e.value):[...this.value,e.value]}}};qr=Object.defineProperty,fi=class extends C{constructor(e){super(e,!1),pi(this,"options"),pi(this,"cursor",0),this.options=e.options,this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on("key",(t)=>{t==="a"&&this.toggleAll()}),this.on("cursor",(t)=>{switch(t){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 e=this.value.length===this.options.length;this.value=e?[]:this.options.map((t)=>t.value)}toggleValue(){let e=this.value.includes(this._value);this.value=e?this.value.filter((t)=>t!==this._value):[...this.value,this._value]}},Tr=Object.defineProperty;mt=class mt extends C{constructor({mask:e,...t}){super(t),ai(this,"valueWithCursor",""),ai(this,"_mask","•"),this._mask=e??"•",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${te.default.inverse(te.default.hidden("_"))}`;else{let n=this.masked.slice(0,this.cursor),r=this.masked.slice(this.cursor);this.valueWithCursor=`${n}${te.default.inverse(r[0])}${r.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}};Or=Object.defineProperty,_i=class extends C{constructor(e){super(e,!1),ui(this,"options"),ui(this,"cursor",0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(t)=>{switch(t){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}},Nr=Object.defineProperty;pt=class pt extends C{constructor(e){super(e,!1),ci(this,"options"),ci(this,"cursor",0),this.options=e.options;let t=this.options.map(({value:[n]})=>n?.toLowerCase());this.cursor=Math.max(t.indexOf(e.initialValue),0),this.on("key",(n)=>{if(!t.includes(n))return;let r=this.options.find(({value:[o]})=>o?.toLowerCase()===n);r&&(this.value=r.value,this.state="submit",this.emit("submit"))})}};zr=Object.defineProperty;at=class at extends C{constructor(e){super(e),Ir(this,"valueWithCursor",""),this.on("finalize",()=>{this.value||(this.value=e.defaultValue),this.valueWithCursor=this.value}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${te.default.inverse(te.default.hidden("_"))}`;else{let t=this.value.slice(0,this.cursor),n=this.value.slice(this.cursor);this.valueWithCursor=`${t}${te.default.inverse(n[0])}${n.slice(1)}`}})}get cursor(){return this._cursor}};Xr=globalThis.process.platform.startsWith("win")});var ge={};St(ge,{text:()=>Lr,spinner:()=>po,selectKey:()=>to,select:()=>eo,password:()=>Fr,outro:()=>mo,note:()=>ro,multiselect:()=>io,log:()=>ie,isCancel:()=>Be,intro:()=>so,groupMultiselect:()=>no,group:()=>uo,confirm:()=>Dr,cancel:()=>oo});import Y from"node:process";function Yr(){return Y.platform!=="win32"?Y.env.TERM!=="linux":Boolean(Y.env.CI)||Boolean(Y.env.WT_SESSION)||Boolean(Y.env.TERMINUS_SUBLIME)||Y.env.ConEmuTask==="{cmd::Cmder}"||Y.env.TERM_PROGRAM==="Terminus-Sublime"||Y.env.TERM_PROGRAM==="vscode"||Y.env.TERM==="xterm-256color"||Y.env.TERM==="alacritty"||Y.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function ao(){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,"g")}var p,ae,lt,M=(e,t)=>lt?e:t,Qr,Ri,Ai,Ne,Vr,x,N,$t,dt,ht,xe,ki,Zr,Si,Wr,Ur,Hr,Kr,Pr,Cr,Er,ne=(e)=>{switch(e){case"initial":case"active":return p.default.cyan(Qr);case"cancel":return p.default.red(Ri);case"error":return p.default.yellow(Ai);case"submit":return p.default.green(Ne)}},Lr=(e)=>new at({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){let t=`${p.default.gray(x)}
16
+ ${ne(this.state)} ${e.message}
17
+ `,n=e.placeholder?p.default.inverse(e.placeholder[0])+p.default.dim(e.placeholder.slice(1)):p.default.inverse(p.default.hidden("_")),r=this.value?this.valueWithCursor:n;switch(this.state){case"error":return`${t.trim()}
18
+ ${p.default.yellow(x)} ${r}
19
+ ${p.default.yellow(N)} ${p.default.yellow(this.error)}
20
+ `;case"submit":return`${t}${p.default.gray(x)} ${p.default.dim(this.value||e.placeholder)}`;case"cancel":return`${t}${p.default.gray(x)} ${p.default.strikethrough(p.default.dim(this.value??""))}${this.value?.trim()?`
21
+ `+p.default.gray(x):""}`;default:return`${t}${p.default.cyan(x)} ${r}
22
+ ${p.default.cyan(N)}
23
+ `}}}).prompt(),Fr=(e)=>new mt({validate:e.validate,mask:e.mask??Zr,render(){let t=`${p.default.gray(x)}
24
+ ${ne(this.state)} ${e.message}
25
+ `,n=this.valueWithCursor,r=this.masked;switch(this.state){case"error":return`${t.trim()}
26
+ ${p.default.yellow(x)} ${r}
27
+ ${p.default.yellow(N)} ${p.default.yellow(this.error)}
28
+ `;case"submit":return`${t}${p.default.gray(x)} ${p.default.dim(r)}`;case"cancel":return`${t}${p.default.gray(x)} ${p.default.strikethrough(p.default.dim(r??""))}${r?`
29
+ `+p.default.gray(x):""}`;default:return`${t}${p.default.cyan(x)} ${n}
30
+ ${p.default.cyan(N)}
31
+ `}}}).prompt(),Dr=(e)=>{let t=e.active??"Yes",n=e.inactive??"No";return new ot({active:t,inactive:n,initialValue:e.initialValue??!0,render(){let r=`${p.default.gray(x)}
32
+ ${ne(this.state)} ${e.message}
33
+ `,o=this.value?t:n;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($t)} ${t}`:`${p.default.dim(dt)} ${p.default.dim(t)}`} ${p.default.dim("/")} ${this.value?`${p.default.dim(dt)} ${p.default.dim(n)}`:`${p.default.green($t)} ${n}`}
35
+ ${p.default.cyan(N)}
36
+ `}}}).prompt()},eo=(e)=>{let t=(r,o)=>{let s=r.label??String(r.value);return o==="active"?`${p.default.green($t)} ${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(dt)} ${p.default.dim(s)}`},n=0;return new _i({options:e.options,initialValue:e.initialValue,render(){let r=`${p.default.gray(x)}
37
+ ${ne(this.state)} ${e.message}
38
+ `;switch(this.state){case"submit":return`${r}${p.default.gray(x)} ${t(this.options[this.cursor],"selected")}`;case"cancel":return`${r}${p.default.gray(x)} ${t(this.options[this.cursor],"cancelled")}
39
+ ${p.default.gray(x)}`;default:{let o=e.maxItems===void 0?1/0:Math.max(e.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,i=o<this.options.length&&n+o<this.options.length;return`${r}${p.default.cyan(x)} ${this.options.slice(n,n+o).map((m,u,a)=>u===0&&s?p.default.dim("..."):u===a.length-1&&i?p.default.dim("..."):t(m,u+n===this.cursor?"active":"inactive")).join(`
40
+ ${p.default.cyan(x)} `)}
41
+ ${p.default.cyan(N)}
42
+ `}}}}).prompt()},to=(e)=>{let t=(n,r="inactive")=>{let o=n.label??String(n.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(` ${n.value} `))} ${o} ${n.hint?p.default.dim(`(${n.hint})`):""}`:`${p.default.gray(p.default.bgWhite(p.default.inverse(` ${n.value} `)))} ${o} ${n.hint?p.default.dim(`(${n.hint})`):""}`};return new pt({options:e.options,initialValue:e.initialValue,render(){let n=`${p.default.gray(x)}
43
+ ${ne(this.state)} ${e.message}
44
+ `;switch(this.state){case"submit":return`${n}${p.default.gray(x)} ${t(this.options.find((r)=>r.value===this.value),"selected")}`;case"cancel":return`${n}${p.default.gray(x)} ${t(this.options[0],"cancelled")}
45
+ ${p.default.gray(x)}`;default:return`${n}${p.default.cyan(x)} ${this.options.map((r,o)=>t(r,o===this.cursor?"active":"inactive")).join(`
46
+ ${p.default.cyan(x)} `)}
47
+ ${p.default.cyan(N)}
48
+ `}}}).prompt()},io=(e)=>{let t=(n,r)=>{let o=n.label??String(n.value);return r==="active"?`${p.default.cyan(ht)} ${o} ${n.hint?p.default.dim(`(${n.hint})`):""}`:r==="selected"?`${p.default.green(xe)} ${p.default.dim(o)}`:r==="cancelled"?`${p.default.strikethrough(p.default.dim(o))}`:r==="active-selected"?`${p.default.green(xe)} ${o} ${n.hint?p.default.dim(`(${n.hint})`):""}`:r==="submitted"?`${p.default.dim(o)}`:`${p.default.dim(ki)} ${p.default.dim(o)}`};return new fi({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(n){if(this.required&&n.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 n=`${p.default.gray(x)}
50
+ ${ne(this.state)} ${e.message}
51
+ `;switch(this.state){case"submit":return`${n}${p.default.gray(x)} ${this.options.filter(({value:r})=>this.value.includes(r)).map((r)=>t(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)=>t(o,"cancelled")).join(p.default.dim(", "));return`${n}${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(N)} ${p.default.yellow(o)}`:` ${o}`).join(`
54
+ `);return n+p.default.yellow(x)+" "+this.options.map((o,s)=>{let i=this.value.includes(o.value),m=s===this.cursor;return m&&i?t(o,"active-selected"):i?t(o,"selected"):t(o,m?"active":"inactive")}).join(`
55
+ ${p.default.yellow(x)} `)+`
56
+ `+r+`
57
+ `}default:return`${n}${p.default.cyan(x)} ${this.options.map((r,o)=>{let s=this.value.includes(r.value),i=o===this.cursor;return i&&s?t(r,"active-selected"):s?t(r,"selected"):t(r,i?"active":"inactive")}).join(`
58
+ ${p.default.cyan(x)} `)}
59
+ ${p.default.cyan(N)}
60
+ `}}}).prompt()},no=(e)=>{let t=(n,r,o=[])=>{let s=n.label??String(n.value),i=typeof n.group=="string",m=i&&(o[o.indexOf(n)+1]??{group:!0}),u=i&&m.group===!0,a=i?`${u?N:x} `:"";return r==="active"?`${p.default.dim(a)}${p.default.cyan(ht)} ${s} ${n.hint?p.default.dim(`(${n.hint})`):""}`:r==="group-active"?`${a}${p.default.cyan(ht)} ${p.default.dim(s)}`:r==="group-active-selected"?`${a}${p.default.green(xe)} ${p.default.dim(s)}`:r==="selected"?`${p.default.dim(a)}${p.default.green(xe)} ${p.default.dim(s)}`:r==="cancelled"?`${p.default.strikethrough(p.default.dim(s))}`:r==="active-selected"?`${p.default.dim(a)}${p.default.green(xe)} ${s} ${n.hint?p.default.dim(`(${n.hint})`):""}`:r==="submitted"?`${p.default.dim(s)}`:`${p.default.dim(a)}${p.default.dim(ki)} ${p.default.dim(s)}`};return new st({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(n){if(this.required&&n.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 n=`${p.default.gray(x)}
62
+ ${ne(this.state)} ${e.message}
63
+ `;switch(this.state){case"submit":return`${n}${p.default.gray(x)} ${this.options.filter(({value:r})=>this.value.includes(r)).map((r)=>t(r,"submitted")).join(p.default.dim(", "))}`;case"cancel":{let r=this.options.filter(({value:o})=>this.value.includes(o)).map((o)=>t(o,"cancelled")).join(p.default.dim(", "));return`${n}${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(N)} ${p.default.yellow(o)}`:` ${o}`).join(`
66
+ `);return`${n}${p.default.yellow(x)} ${this.options.map((o,s,i)=>{let m=this.value.includes(o.value)||o.group===!0&&this.isGroupSelected(`${o.value}`),u=s===this.cursor;return!u&&typeof o.group=="string"&&this.options[this.cursor].value===o.group?t(o,m?"group-active-selected":"group-active",i):u&&m?t(o,"active-selected",i):m?t(o,"selected",i):t(o,u?"active":"inactive",i)}).join(`
67
+ ${p.default.yellow(x)} `)}
68
+ ${r}
69
+ `}default:return`${n}${p.default.cyan(x)} ${this.options.map((r,o,s)=>{let i=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?t(r,i?"group-active-selected":"group-active",s):m&&i?t(r,"active-selected",s):i?t(r,"selected",s):t(r,m?"active":"inactive",s)}).join(`
70
+ ${p.default.cyan(x)} `)}
71
+ ${p.default.cyan(N)}
72
+ `}}}).prompt()},ct=(e)=>e.replace(ao(),""),ro=(e="",t="")=>{let n=`
73
+ ${e}
74
74
  `.split(`
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)}
75
+ `),r=ct(t).length,o=Math.max(n.reduce((i,m)=>(m=ct(m),m.length>i?m.length:i),0),r)+2,s=n.map((i)=>`${p.default.gray(x)} ${p.default.dim(i)}${" ".repeat(o-ct(i).length)}${p.default.gray(x)}`).join(`
76
+ `);process.stdout.write(`${p.default.gray(x)}
77
+ ${p.default.green(Ne)} ${p.default.reset(t)} ${p.default.gray(Si.repeat(Math.max(o-r-1,1))+Wr)}
78
78
  ${s}
79
- ${m.default.gray(Qi+wr.repeat(o+2)+Vi)}
80
- `)},ro=(t="")=>{process.stdout.write(`${m.default.gray(O)} ${m.default.red(t)}
79
+ ${p.default.gray(Ur+Si.repeat(o+2)+Hr)}
80
+ `)},oo=(e="")=>{process.stdout.write(`${p.default.gray(N)} ${p.default.red(e)}
81
81
 
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}
82
+ `)},so=(e="")=>{process.stdout.write(`${p.default.gray(Vr)} ${e}
83
+ `)},mo=(e="")=>{process.stdout.write(`${p.default.gray(x)}
84
+ ${p.default.gray(N)} ${e}
85
85
 
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(`
86
+ `)},ie,po=()=>{let e=lt?["◒","◐","◓","◑"]:["•","o","O","0"],t=lt?80:120,n,r,o=!1,s="",i=($="")=>{o=!0,n=vi(),s=$.replace(/\.+$/,""),process.stdout.write(`${p.default.gray(x)}
87
+ `);let d=0,h=0;r=setInterval(()=>{let y=p.default.magenta(e[d]),f=".".repeat(Math.floor(h)).slice(0,3);process.stdout.write(ae.cursor.move(-999,0)),process.stdout.write(ae.erase.down(1)),process.stdout.write(`${y} ${s}${f}`),d=d+1<e.length?d+1:0,h=h<e.length?h+0.125:0},t)},m=($="",d=0)=>{s=$??s,o=!1,clearInterval(r);let h=d===0?p.default.green(Ne):d===1?p.default.red(Ri):p.default.red(Ai);process.stdout.write(ae.cursor.move(-999,0)),process.stdout.write(ae.erase.down(1)),process.stdout.write(`${h} ${s}
88
+ `),n()},u=($="")=>{s=$??s},a=($)=>{let d=$>1?"Something went wrong":"Canceled";o&&m(d,$)};return process.on("uncaughtExceptionMonitor",()=>a(2)),process.on("unhandledRejection",()=>a(2)),process.on("SIGINT",()=>a(1)),process.on("SIGTERM",()=>a(1)),process.on("exit",a),{start:i,stop:m,message:u}},uo=async(e,t)=>{let n={},r=Object.keys(e);for(let o of r){let s=e[o],i=await s({results:n})?.catch((m)=>{throw m});if(typeof t?.onCancel=="function"&&Be(i)){n[o]="canceled",t.onCancel({results:n});continue}n[o]=i}return n};var ze=Ve(()=>{ut();ut();p=be(et(),1),ae=be(Fe(),1);lt=Yr(),Qr=M("◆","*"),Ri=M("■","x"),Ai=M("▲","x"),Ne=M("◇","o"),Vr=M("┌","T"),x=M("│","|"),N=M("└","—"),$t=M("●",">"),dt=M("○"," "),ht=M("◻","[•]"),xe=M("◼","[+]"),ki=M("◻","[ ]"),Zr=M("▪","•"),Si=M("─","-"),Wr=M("╮","+"),Ur=M("├","+"),Hr=M("╯","+"),Kr=M("●","•"),Pr=M("◆","*"),Cr=M("▲","!"),Er=M("■","x"),ie={message:(e="",{symbol:t=p.default.gray(x)}={})=>{let n=[`${p.default.gray(x)}`];if(e){let[r,...o]=e.split(`
89
+ `);n.push(`${t} ${r}`,...o.map((s)=>`${p.default.gray(x)} ${s}`))}process.stdout.write(`${n.join(`
90
90
  `)}
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(`
91
+ `)},info:(e)=>{ie.message(e,{symbol:p.default.blue(Kr)})},success:(e)=>{ie.message(e,{symbol:p.default.green(Pr)})},step:(e)=>{ie.message(e,{symbol:p.default.green(Ne)})},warn:(e)=>{ie.message(e,{symbol:p.default.yellow(Cr)})},warning:(e)=>{ie.warn(e)},error:(e)=>{ie.message(e,{symbol:p.default.red(Er)})}}});var Ni={};St(Ni,{readTextFromPathOrStdin:()=>ye});import{readFileSync as ho}from"fs";function ye(e){return ho(e==="-"?"/dev/stdin":e,"utf-8")}var Ie=()=>{};function Ze(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function kn(e){let t=e.flag.match(/^--([a-z][a-z0-9-]*)/i);return t?Ze(t[1]):null}function Mn(e){if(e.type==="boolean")return!0;if(e.type==="string"||e.type==="number"||e.type==="array")return!1;return!e.flag.includes("<")&&!e.flag.includes("[")}function Rt(e){let t=new Set,n=new Set,r=new Set;for(let o of e){let s=kn(o);if(!s)continue;if(Mn(o))t.add(s);else if(o.type==="number")n.add(s);else if(o.type==="array")r.add(s)}return{booleans:t,numbers:n,arrays:r}}function At(e,t=[]){let n=Rt(t),r=[],o=0;while(o<e.length){let s=e[o];if(s==="--")break;if(s.startsWith("--")){let i=s.indexOf("="),m=i!==-1?s.slice(2,i):s.slice(2),u=Ze(m);if(!n.booleans.has(u)&&i===-1)o+=2;else o+=1;continue}if(s.startsWith("-")){o++;continue}r.push(s),o++}return r}function We(e,t){let n=Rt(t),r={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},o=0;while(o<e.length){let s=e[o];if(s==="--help"||s==="-h"){r.help=!0,o++;continue}if(s==="--")break;if(s.startsWith("--")){let i=s.indexOf("="),m,u;if(i!==-1)m=s.slice(2,i),u=s.slice(i+1);else m=s.slice(2);let a=Ze(m);if(n.booleans.has(a)){r[a]=!0,o++;continue}if(u===void 0)o++,u=e[o];if(u===void 0)throw Error(`Flag --${m} requires a value.`);if(n.arrays.has(a)){let $=r[a];if($)$.push(u);else r[a]=[u]}else if(n.numbers.has(a))r[a]=Number(u);else r[a]=u}o++}return r}var c={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONTENT_FILTER:10};class l extends Error{exitCode;hint;constructor(e,t=c.GENERAL,n){super(e);this.name="CLIError",this.exitCode=t,this.hint=n}toJSON(){return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{}}}}}var W={global:"https://api.minimax.io",cn:"https://api.minimaxi.com"},$e={global:"https://platform.minimax.io",cn:"https://platform.minimaxi.com"},qn=new Set(["global","cn"]),jn=new Set(["text","json"]);function kt(e){if(!e||typeof e!=="object"||Array.isArray(e))return{};let t=e,n={};if(typeof t.api_key==="string")n.api_key=t.api_key;if(typeof t.region==="string"&&qn.has(t.region))n.region=t.region;if(typeof t.base_url==="string"&&t.base_url.startsWith("http"))n.base_url=t.base_url;if(typeof t.output==="string"&&jn.has(t.output))n.output=t.output;if(typeof t.timeout==="number"&&t.timeout>0)n.timeout=t.timeout;if(typeof t.default_text_model==="string"&&t.default_text_model.length>0)n.default_text_model=t.default_text_model;if(typeof t.default_speech_model==="string"&&t.default_speech_model.length>0)n.default_speech_model=t.default_speech_model;if(typeof t.default_video_model==="string"&&t.default_video_model.length>0)n.default_video_model=t.default_video_model;if(typeof t.default_music_model==="string"&&t.default_music_model.length>0)n.default_music_model=t.default_music_model;return n}function b(e){return{name:e.name,description:e.description,usage:e.usage,options:e.options,examples:e.examples,apiDocs:e.apiDocs,execute:e.run}}var fe=[{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 On,writeFileSync as Bn,renameSync as Nn,unlinkSync as gn,existsSync as Mt,statSync as zn}from"fs";import{homedir as Tn}from"os";import{join as Ue}from"path";var Gn=".mmx";function de(){return Ue(Tn(),Gn)}function U(){return Ue(de(),"config.json")}function _e(){return Ue(de(),"credentials.json")}async function ve(){let e=de();await(await import("fs/promises")).mkdir(e,{recursive:!0,mode:448})}async function I(){let e=_e();if(!Mt(e))return null;try{Jn(e);let t=On(e,"utf-8"),n=JSON.parse(t);if(!n.access_token||!n.refresh_token)return null;return n}catch(t){let n=t;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 me(e){await ve();let t=_e(),n=t+".tmp";Bn(n,JSON.stringify(e,null,2)+`
93
+ `,{mode:384}),Nn(n,t)}async function qt(){let e=_e();if(Mt(e))gn(e)}function Jn(e){try{let n=zn(e).mode&511;if(n!==384)process.stderr.write(`Warning: ${e} has permissions ${n.toString(8)}, expected 600.
94
+ `)}catch{}}var jt={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 Tt(e=jt){let{randomBytes:t,createHash:n}=await import("crypto"),r=t(32).toString("base64url"),o=n("sha256").update(r).digest("base64url"),s=t(16).toString("hex"),i=new URLSearchParams({client_id:e.clientId,response_type:"code",redirect_uri:`http://localhost:${e.callbackPort}/callback`,scope:e.scopes.join(" "),state:s,code_challenge:o,code_challenge_method:"S256"}),m=`${e.authorizationUrl}?${i}`,{exec:u}=await import("child_process"),a=process.platform;u(`${a==="darwin"?"open":a==="win32"?"start":"xdg-open"} "${m}"`),process.stderr.write(`Opening browser to authenticate with MiniMax...
95
+ `);let d=await In(e.callbackPort,s),h=await fetch(e.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:d,client_id:e.clientId,redirect_uri:`http://localhost:${e.callbackPort}/callback`,code_verifier:r})});if(!h.ok){let y=await h.text();throw new l(`OAuth token exchange failed: ${y}`,c.AUTH)}return await h.json()}async function In(e,t){return new Promise((n,r)=>{let o=setTimeout(()=>{s.stop(),r(new l("OAuth callback timed out.",c.TIMEOUT))},120000),s=Bun.serve({port:e,fetch(i){let m=new URL(i.url);if(m.pathname!=="/callback")return new Response("Not found",{status:404});let u=m.searchParams.get("code"),a=m.searchParams.get("state"),$=m.searchParams.get("error");if($)return clearTimeout(o),s.stop(),r(new l(`OAuth error: ${$}`,c.AUTH)),new Response("<html><body><h1>Authentication Failed</h1><p>You can close this tab.</p></body></html>",{headers:{"Content-Type":"text/html"}});if(!u||a!==t)return clearTimeout(o),s.stop(),r(new l("Invalid OAuth callback.",c.AUTH)),new Response("Invalid callback",{status:400});return clearTimeout(o),s.stop(),n(u),new Response("<html><body><h1>Authentication Successful</h1><p>You can close this tab.</p></body></html>",{headers:{"Content-Type":"text/html"}})}})})}async function Gt(e=jt){let t=await fetch(e.deviceCodeUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:e.clientId,scope:e.scopes.join(" ")})});if(!t.ok)throw new l("Failed to start device code flow.",c.AUTH);let{device_code:n,user_code:r,verification_uri:o,interval:s,expires_in:i}=await t.json();process.stderr.write(`
96
96
  Visit: ${o}
97
- `),process.stderr.write(`Enter code: ${i}
97
+ `),process.stderr.write(`Enter code: ${r}
98
98
  `),process.stderr.write(`Waiting for authorization...
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
-
102
- Speech models require the Plus plan or above.`;if(t.includes("/image_generation"))return`
103
-
104
- image-01 requires the Plus plan or above.`;if(t.includes("/video_generation")||t.includes("/query/video_generation"))return`
105
-
106
- Video models (Hailuo-2.3 / 2.3-Fast) require the Max plan or above.`;if(t.includes("/music_generation"))return`
107
-
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.7",o={"User-Agent":"mmx-cli/1.0.7",...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}).
99
+ `);let m=Date.now()+i*1000,u=(s||5)*1000;while(Date.now()<m){await new Promise((d)=>setTimeout(d,u));let a=await fetch(e.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:e.clientId})});if(a.ok)return await a.json();let $=await a.json();if($.error==="authorization_pending")continue;if($.error==="slow_down"){await new Promise((d)=>setTimeout(d,5000));continue}throw new l(`Device code authorization failed: ${$.error}`,c.AUTH)}throw new l("Device code authorization timed out.",c.TIMEOUT)}var Xn="https://api.minimax.io/v1/oauth/token";async function He(e){let t;try{t=await fetch(Xn,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:e}),signal:AbortSignal.timeout(1e4)})}catch(r){let o=r instanceof Error&&(r.name==="AbortError"||r.name==="TimeoutError"||r.message.includes("timed out"));throw new l(o?"Token refresh timed out — auth server did not respond within 10 s.":`Token refresh failed: ${r instanceof Error?r.message:String(r)}`,c.AUTH,`Check your network connection.
100
+ Re-authenticate: mmx auth login`)}if(!t.ok)throw new l("OAuth session expired and could not be refreshed.",c.AUTH,"Re-authenticate: mmx auth login");return await t.json()}async function Ot(e){let t=new Date(e.expires_at).getTime(),n=300000;if(Date.now()<t-300000)return e.access_token;let r=await He(e.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:e.account};return await me(o),o.access_token}async function Se(e){if(e.apiKey)return{token:e.apiKey,method:"api-key",source:"flag"};let t=await I();if(t)return{token:await Ot(t),method:"oauth",source:"credentials.json"};if(e.fileApiKey)return{token:e.fileApiKey,method:"api-key",source:"config.json"};throw new l("No credentials found.",c.AUTH,`Log in: mmx auth login
101
+ Pass directly: --api-key sk-xxxxx`)}function Bt(e){if(!e)return"";if(e.includes("/t2a"))return`
102
+
103
+ Speech models require the Plus plan or above.`;if(e.includes("/image_generation"))return`
104
+
105
+ image-01 requires the Plus plan or above.`;if(e.includes("/video_generation")||e.includes("/query/video_generation"))return`
106
+
107
+ Video models (Hailuo-2.3 / 2.3-Fast) require the Max plan or above.`;if(e.includes("/music_generation"))return`
108
+
109
+ Music-2.6 requires the Max plan or above.`;return""}function Nt(e){return`${e?.includes("minimaxi.com")?"https://platform.minimaxi.com":"https://platform.minimax.io"}/subscribe/token-plan`}function Ke(e,t,n){let r=t.base_resp?.status_msg||t.error?.message||`HTTP ${e}`,o=t.base_resp?.status_code||t.error?.code;if(e===401||e===403)return new l(`API key rejected (HTTP ${e}).`,c.AUTH,`Check status: mmx auth status
110
+ Re-authenticate: mmx auth login`);if(e===429)return new l(`Rate limit or quota exceeded. ${r}`,c.QUOTA,"Check usage: mmx quota show");if(e===408||e===504)return new l(`Request timed out (HTTP ${e}).`,c.TIMEOUT,"Try increasing --timeout or retry later.");if(o===1002||o===1039){let s=t.base_resp?.status_msg||"content sensitivity";return new l(`Input content flagged by sensitivity filter (${s}).`,c.CONTENT_FILTER)}if(o===1028||o===1030){let s=Bt(n);return new l(`Quota exhausted. ${r}`,c.QUOTA,`Check usage: mmx quota show${s}
111
+ Upgrade plan: ${Nt(n)}`)}if(o===2061){let s=Bt(n);return new l(`This model is not available on your current Token Plan. ${r}`,c.QUOTA,`Check usage: mmx quota show${s}
112
+ Upgrade plan: ${Nt(n)}`)}return new l(`API error: ${r} (HTTP ${e})`,c.GENERAL)}import{homedir as gt}from"os";function X(e){return e.length>8?`${e.slice(0,4)}...${e.slice(-4)}`:"***"}var zt=!1;var g="\x1B[0m",H="\x1B[2m",Yn="\x1B[1m",Qn="\x1B[38;2;43;82;255m",Vn="\x1B[38;2;147;51;234m",Zn="\x1B[38;2;6;184;212m",Wn="\x1B[38;2;236;72;153m";function Un(e){return e.startsWith(gt())?e.replace(gt(),"~"):e}function Jt(e,t,n){if(e.quiet||zt||!process.stderr.isTTY)return;zt=!0;let r=e.configPath?Un(e.configPath):"~/.mmx/config.json",o=e.fileRegion?`${e.fileRegion} (file)`:"global (default)",s=e.apiKey?"(flag)":"(file)",i=X(t),m=n?` ${H}|${g} ${H}Model:${g} ${Vn}${n}${g}`:"";process.stderr.write(`${Yn}${Qn}MINIMAX${g} ${H}${r}${g} ${H}|${g} ${H}Region:${g} ${Zn}${o}${g} ${H}|${g} ${H}Key:${g} ${Wn}${i}${g} ${H}${s}${g}${m}
113
+ `)}async function Z(e,t){let n=typeof FormData<"u"&&t.body instanceof FormData,r="1.0.9",o={"User-Agent":"mmx-cli/1.0.9",...t.headers};if(!n&&!o["Content-Type"])o["Content-Type"]="application/json";if(!t.noAuth){let m=await Se(e);if(t.authStyle==="x-api-key")o["x-api-key"]=m.token;else o.Authorization=`Bearer ${m.token}`;if(e.verbose)process.stderr.write(`> ${t.method??"GET"} ${t.url}
114
+ `),process.stderr.write(`> Auth: ${m.token.slice(0,8)}...
115
+ `);let u=t.body&&typeof t.body==="object"&&"model"in t.body?String(t.body.model):void 0;Jt(e,m.token,u)}let s=(t.timeout??e.timeout)*1000,i=await fetch(t.url,{method:t.method??"GET",headers:o,body:t.body?n?t.body:JSON.stringify(t.body):void 0,signal:AbortSignal.timeout(s)});if(e.verbose)process.stderr.write(`< ${i.status} ${i.statusText}
116
+ `);if(!i.ok){let m={};try{m=await i.json()}catch{}throw Ke(i.status,m,t.url)}return i}async function v(e,t){let n=await Z(e,t),r;try{r=await n.json()}catch{let o=n.headers.get("content-type")||"";throw new l(`API returned non-JSON response (${o||"unknown type"}). Server may be experiencing issues.`,c.GENERAL)}if(r.base_resp?.status_code&&r.base_resp.status_code!==0)throw Ke(200,{base_resp:r.base_resp},t.url);return r}function It(e){return`${e}/anthropic/v1/messages`}function Xt(e){return`${e}/v1/t2a_v2`}function Yt(e){return`${e}/v1/get_voice`}function Qt(e){return`${e}/v1/image_generation`}function Vt(e){return`${e}/v1/video_generation`}function Re(e,t){return`${e}/v1/query/video_generation?task_id=${t}`}function Ae(e,t){return`${e}/v1/files/retrieve?file_id=${t}`}function ke(e){return`${e}/v1/music_generation`}function Zt(e){return`${e}/v1/coding_plan/search`}function Wt(e){return`${e}/v1/coding_plan/vlm`}function ee(e){return`${e.includes("minimaxi.com")?"https://api.minimaxi.com":"https://api.minimax.io"}/v1/token_plan/remains`}function Kt(e){if(e<50)return["\x1B[38;2;74;222;128m","\x1B[48;2;22;163;74m"];if(e<=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 Hn={dashboard:"TokenPlan Quota",week:"Week",weekly:"Weekly",resetsIn:"Resets in",noData:"No quota data available.",now:"now"},Kn={dashboard:"TokenPlan 配额面板",week:"周期",weekly:"每周",resetsIn:"重置于",noData:"暂无配额数据",now:"即将"};function Pn(e,t){if(e<=0)return t;let n=Math.floor(e/3600000),r=Math.floor(e%3600000/60000);return n>0?`${n}h ${r}m`:`${r}m`}function Ut(e){return new Date(e).toISOString().slice(0,10)}function Cn(e){return e>=11904&&e<=40959||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65281&&e<=65376||e>=131072&&e<=195103}function K(e){let t=e.replace(/\x1b\[[0-9;]*m/g,""),n=0;for(let r of t)n+=Cn(r.codePointAt(0))?2:1;return n}var qe=16;function Ht(e,t){let n=Math.max(0,Math.min(100,e))/100,r=Math.round(qe*n),o=qe-r,s=`${e}%`.padStart(4);if(!t)return`[${"█".repeat(r)}${".".repeat(o)}] ${s}`;let[i,m]=Kt(e);return`${m}${" ".repeat(r)}\x1B[0m\x1B[48;2;55;65;81m${" ".repeat(o)}\x1B[0m ${i}\x1B[1m${s}\x1B[0m`}function Me(e,t,n,r,o){return o?`\x1B[2m${t}${n.repeat(e)}${r}\x1B[0m`:`+${"-".repeat(e)}+`}function Pe(e,t,n,r){let o=Math.max(0,t-2-n);return r?`${"\x1B[2m"}│${"\x1B[0m"} ${e}${" ".repeat(o)} ${"\x1B[2m"}│${"\x1B[0m"}`:`| ${e}${" ".repeat(o)} |`}function pe(e,t){let n=!t.noColor&&process.stdout.isTTY===!0,r=t.region==="cn"?Kn:Hn,o=e.length>0?Math.max(...e.map((y)=>y.model_name.length)):16,s=n?qe+5:qe+7,i=Math.max(68,o+2+15+2+s+2),m=e.length>0?`${Ut(e[0].weekly_start_time)} — ${Ut(e[0].weekly_end_time)}`:"",u=`MINIMAX ${r.dashboard}`,a=`${r.week}: ${m}`,$=Math.max(2,i-2-K(u)-K(a)),d=n?`\x1B[1m\x1B[38;2;43;82;255mMINIMAX\x1B[0m \x1B[2m${r.dashboard}\x1B[0m${" ".repeat($)}\x1B[2m${r.week}:\x1B[0m \x1B[38;2;6;184;212m${m}\x1B[0m`:`${u}${" ".repeat($)}${a}`,h=K(u)+$+K(a);if(console.log(""),console.log(Me(i,"╭","─","╮",n)),console.log(Pe(d,i,h,n)),e.length===0){console.log(Me(i,"╰","─","╯",n)),console.log(`
117
+ ${r.noData}
118
+ `);return}for(let y of e){console.log(Me(i,"├","─","┤",n));let{current_interval_usage_count:f,current_interval_total_count:A}=y,S=A>0?Math.round(f/A*100):0,q=y.current_weekly_usage_count,B=y.current_weekly_total_count,j=Pn(y.remains_time,r.now),L=y.model_name.padEnd(o),R=`${f.toLocaleString()} / ${A.toLocaleString()}`,J=Ht(S,n),F=o+2+15+2+s,D=n?`\x1B[1m\x1B[38;2;255;255;255m${L}\x1B[0m ${Kt(S)[0]}${R.padStart(15)}\x1B[0m ${J}`:`${L} ${R.padStart(15)} ${Ht(S,!1)}`;console.log(Pe(D,i,F,n));let le=`└ ${r.weekly} ${q.toLocaleString()} / ${B.toLocaleString()}`,we=`${r.resetsIn} ${j}`,Ye=Math.max(2,i-2-2-K(le)-K(we)),dn=2+K(le)+Ye+K(we),hn=n?` \x1B[2m${le}${" ".repeat(Ye)}${we}\x1B[0m`:` ${le}${" ".repeat(Ye)}${we}`;console.log(Pe(hn,i,dn,n))}console.log(Me(i,"╰","─","╯",n)),console.log("")}import{readFileSync as Ln,writeFileSync as Fn,renameSync as Dn,existsSync as er}from"fs";function Pt(e){if(e===null||e===void 0)return"";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean")return String(e);if(Array.isArray(e)){if(e.length===0)return"(empty)";if(typeof e[0]==="object"&&e[0]!==null)return En(e);return e.map(String).join(`
119
+ `)}if(typeof e==="object")return Ce(e);return String(e)}function Ce(e,t=0){let n=" ".repeat(t),r=[];for(let[o,s]of Object.entries(e)){if(s===null||s===void 0)continue;if(Array.isArray(s)){r.push(`${n}${o}:`);for(let i of s)if(typeof i==="object"&&i!==null)r.push(`${n} - ${Ce(i,t+4).trimStart()}`);else r.push(`${n} - ${String(i)}`)}else if(typeof s==="object")r.push(`${n}${o}:`),r.push(Ce(s,t+2));else r.push(`${n}${o}: ${String(s)}`)}return r.join(`
120
+ `)}function En(e){if(e.length===0)return"(empty)";let t=Object.keys(e[0]),n=t.map((i)=>Math.max(i.length,...e.map((m)=>String(m[i]??"").length))),r=t.map((i,m)=>i.toUpperCase().padEnd(n[m])).join(" "),o=n.map((i)=>"-".repeat(i)).join(" "),s=e.map((i)=>t.map((m,u)=>String(i[m]??"").padEnd(n[u])).join(" "));return[r,o,...s].join(`
121
+ `)}function Ct(e){return JSON.stringify(e,null,2)}function _(e){if(e==="json"||e==="text")return e;if(!process.stdout.isTTY)return"json";return"text"}function w(e,t){switch(t){case"json":return Ct(e);case"text":return Pt(e)}}function O(){let e=U();if(!er(e))return{};try{return kt(JSON.parse(Ln(e,"utf-8")))}catch(t){let n=t;if(n instanceof SyntaxError||n.message.includes("JSON"))process.stderr.write(`Warning: config file is corrupted. Run 'mmx config set' to reset.
122
+ `);return{}}}async function Q(e){await ve();let t=U(),n=t+".tmp";Fn(n,JSON.stringify(e,null,2)+`
123
+ `,{mode:384}),Dn(n,t)}function Ee(e){let t=O(),n=e.apiKey||void 0,r=t.api_key,o=e.region||process.env.MINIMAX_REGION||void 0,s=t.region,i=o||s||"global",m=n||r,u=!o&&(!s||m!==void 0&&m!==t.api_key),a=e.baseUrl||process.env.MINIMAX_BASE_URL||t.base_url||W[i]||W.global,$=_(e.output||process.env.MINIMAX_OUTPUT||t.output),d=process.env.MINIMAX_TIMEOUT?Number(process.env.MINIMAX_TIMEOUT):void 0,h=d!==void 0&&Number.isFinite(d)&&d>0?d:void 0,y=e.timeout??h??t.timeout??300;return{apiKey:n,fileApiKey:r,fileRegion:t.region,configPath:U(),region:i,baseUrl:a,output:$,timeout:y,defaultTextModel:t.default_text_model,defaultSpeechModel:t.default_speech_model,defaultVideoModel:t.default_video_model,defaultMusicModel:t.default_music_model,verbose:e.verbose||process.env.MINIMAX_VERBOSE==="1",quiet:e.quiet||!1,noColor:e.noColor||process.env.NO_COLOR!==void 0||!process.stdout.isTTY,yes:e.yes||!1,dryRun:e.dryRun||!1,nonInteractive:e.nonInteractive||!1,async:e.async||!1,needsRegionDetection:u}}function T(e){if(e?.nonInteractive===!0)return!1;if(process.env.CI)return!1;return process.stdout.isTTY===!0&&process.stdin.isTTY===!0}async function Mi(e){try{let t=ee(e.baseUrl),n=await v(e,{url:t});pe(n.model_remains||[],e)}catch{}}var qi=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(e,t){let n=process.env.MINIMAX_API_KEY;if(n&&!t.apiKey){let i=X(n);if(T({nonInteractive:e.nonInteractive})){let{confirm:m}=await Promise.resolve().then(() => (ze(),ge));if(!await m({message:`Detected MINIMAX_API_KEY in environment (${i}).
123
124
  You are already authenticated via env.
124
125
  Do you still want to configure local persistent credentials?`,initialValue:!1}))process.stdout.write(`Login skipped. Using environment variables.
125
126
  `),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 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.
127
+ `)}if((t.apiKey?"api-key":t.method||"oauth")==="api-key"){let i=t.apiKey||e.apiKey;if(!i)throw new l("--api-key is required when using --method api-key.",c.USAGE,"mmx auth login --api-key sk-xxxxx");if(!e.dryRun){process.stderr.write("Testing key... ");try{let u={...e,apiKey:i};await v(u,{url:ee(u.baseUrl)}),process.stderr.write(`Valid
128
+ `)}catch{throw new l("API key validation failed.",c.AUTH,"Check that your key is valid and belongs to a Token Plan.")}let m=O();m.api_key=i,await Q(m),process.stderr.write(`API key saved to ${U()}
129
+ `),await Mi({...e,apiKey:i})}else console.log("Would validate and save API key.");return}if(e.dryRun){console.log("Would start OAuth login flow.");return}let o;if(t.noBrowser)o=await Gt();else o=await Tt();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 me(s),process.stderr.write(`Logged in successfully.
129
130
  `),process.stderr.write(`Credentials saved to ~/.mmx/credentials.json
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
131
+ `),await Mi({...e,apiKey:s.access_token})}});var ji=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(e,t){try{let n=await Se(e),r=_(e.output);if(r!=="text"){let s={method:n.method,source:n.source};if(n.method==="oauth"){let i=await I();if(i){if(s.token_expires=i.expires_at,i.account)s.account=i.account}}else s.key=X(n.token);console.log(w(s,r));return}console.log("Authentication Status:"),console.log(` Method: ${n.method}`),console.log(` Source: ${n.source}`);let o=n.token;if(console.log(` Key: ${X(o)}`),n.method==="oauth"){let s=await I();if(s){if(s.account)console.log(` Account: ${s.account}`);let i=new Date(s.expires_at),m=Math.round((i.getTime()-Date.now())/60000);console.log(` Expires in: ${m} minutes`)}}process.stderr.write(`Fetching quota snapshot...
132
+ `);try{let s=ee(e.baseUrl),i=await v(e,{url:s,method:"GET"});pe(i.model_remains||[],e)}catch(s){console.log(` Quota fetch failed: ${s.message}`)}}catch{let n=_(e.output);console.log(w({authenticated:!1,message:"Not authenticated.",hint:`Run: mmx auth login
133
+ Or set $MINIMAX_API_KEY`},n))}}});var Ti=b({name:"auth refresh",description:"Manually refresh OAuth token",usage:"mmx auth refresh",examples:["mmx auth refresh"],async run(e,t){let n=await I();if(!n)throw new l("Not applicable: not authenticated via OAuth.",c.USAGE,"Run mmx auth login first.");if(e.dryRun){console.log("Would refresh OAuth token.");return}let r=await He(n.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:n.account};await me(o);let s=_(e.output);if(e.quiet){console.log(o.expires_at);return}console.log(w({status:"Token refreshed",expires:o.expires_at},s))}});var Gi=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(e,t){let n=await I(),r=O(),o=!!r.api_key;if(e.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 qt(),process.stderr.write(`Removed ~/.mmx/credentials.json
134
+ `);if(o)try{let s=r;delete s.api_key,await Q(s),process.stderr.write(`Cleared api_key from ~/.mmx/config.json
134
135
  `)}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}
136
+ `)}});async function*Je(e){let t=e.body?.getReader();if(!t)return;let n=new TextDecoder,r="";try{while(!0){let{done:o,value:s}=await t.read();if(o)break;r+=n.decode(s,{stream:!0});let i=r.split(`
137
+ `);r=i.pop()||"";let m={};for(let u of i){if(u===""){if(m.data!==void 0)yield{data:m.data,event:m.event,id:m.id};m={};continue}if(u.startsWith(":"))continue;let a=u.indexOf(":");if(a===-1)continue;let $=u.slice(0,a),d=u.slice(a+1).trimStart();switch($){case"data":m.data=m.data!==void 0?`${m.data}
138
+ ${d}`:d;break;case"event":m.event=d;break;case"id":m.id=d;break}}}if(r.trim()&&r.includes("data:")){let o=r.indexOf(":");if(o!==-1)yield{data:r.slice(o+1).trimStart()}}}finally{t.releaseLock()}}import{readFileSync as xt}from"fs";async function V(e){if(!T())return;let{defaultValue:t,message:n}=e,o=await(await Promise.resolve().then(() => (ze(),ge))).text({message:n,default:t,placeholder:t});if(typeof o==="symbol")return;return o}async function Oi(e){if(!T())return;let{message:t}=e,r=await(await Promise.resolve().then(() => (ze(),ge))).confirm({message:t});if(typeof r==="symbol")return;return r}function ue(e,t){throw new l(`Missing required argument: --${e}
138
139
  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 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(`${_}
140
+ In an interactive terminal, run without --${e} and the CLI will prompt for it.`,c.USAGE,t)}function co(e){let t=[],n;if(e.system)n=e.system;if(e.messagesFile){let r=e.messagesFile,o=r==="-"?xt("/dev/stdin","utf-8"):xt(r,"utf-8"),s=JSON.parse(o);for(let i of s)if(i.role==="system")n=typeof i.content==="string"?i.content:"";else t.push(i)}if(e.message){let r=new Set(["system","user","assistant"]),o=e.message;for(let s of o){let i=s.indexOf(":"),m=i!==-1?s.slice(0,i):"";if(r.has(m)){let u=s.slice(i+1);if(m==="system")n=u;else t.push({role:m,content:u})}else t.push({role:"user",content:s})}}return{system:n,messages:t}}function lo(e){return e.filter((t)=>t.type==="text").map((t)=>t.text).join("")}var Bi=b({name:"text chat",description:"Send a chat completion (MiniMax Messages API)",apiDocs:"/docs/api-reference/text-post",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(e,t){let{system:n,messages:r}=co(t),o=r;if(o.length===0)if(T({nonInteractive:e.nonInteractive})){let $=await V({message:"Enter your message:"});if(!$)process.stderr.write(`Chat cancelled.
141
+ `),process.exit(1);o=[{role:"user",content:$}]}else ue("message","mmx text chat --message <text>");let s=t.model||e.defaultTextModel||"MiniMax-M2.7",i=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,m=_(e.output),u={model:s,messages:o,max_tokens:t.maxTokens??4096,stream:i};if(n)u.system=n;if(t.temperature!==void 0)u.temperature=t.temperature;if(t.topP!==void 0)u.top_p=t.topP;if(t.tool){let $=t.tool.map((d)=>{try{return JSON.parse(d)}catch{let h=xt(d,"utf-8");return JSON.parse(h)}});u.tools=$}if(e.dryRun){console.log(w({request:u},m));return}let a=It(e.baseUrl);if(i){let $=await Z(e,{url:a,method:"POST",body:u,stream:!0,authStyle:"x-api-key"}),d="",h=!1,y=e.noColor?"":"\x1B[2m",f=e.noColor?"":"\x1B[0m",S=process.stdout.isTTY?process.stdout:process.stderr,q=process.stdout;for await(let B of Je($)){if(B.data==="[DONE]")break;try{let j=JSON.parse(B.data);if(j.type==="content_block_start"){if(j.content_block.type==="thinking")h=!0,S.write(`${y}Thinking:
142
+ `);else if(j.content_block.type==="text"&&h)S.write(`${f}
142
143
 
143
144
  Response:
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.7",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}
145
+ `),h=!1}else if(j.type==="content_block_delta"){if(j.delta.type==="text_delta")d+=j.delta.text,q.write(j.delta.text);else if(j.delta.type==="thinking_delta")S.write(j.delta.thinking)}}catch{}}if(h)S.write(f);if(q.write(`
146
+ `),m==="json")console.log(w({content:d},m))}else{let $=await v(e,{url:a,method:"POST",body:u,authStyle:"x-api-key"}),d=lo($.content);if(e.quiet||m==="text")console.log(d);else console.log(w($,m))}}});import{writeFileSync as $o}from"fs";function ce(e,t,n,r){if(t)if($o(t,Buffer.from(e.data.audio,"hex")),r)console.log(t);else console.log(w({saved:t,duration_ms:e.extra_info?.audio_length,size_bytes:e.extra_info?.audio_size,sample_rate:e.extra_info?.audio_sample_rate},n));else{let o=e.data.audio_url??e.data.audio;if(r)console.log(o);else console.log(w({url:o,duration_ms:e.extra_info?.audio_length,size_bytes:e.extra_info?.audio_size},n))}}Ie();var gi=b({name:"speech synthesize",description:"Synchronous TTS, up to 10k chars (speech-2.8-hd / 2.6 / 02)",apiDocs:"/docs/api-reference/speech-t2a-http",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(e,t){let n=t.text??t._positional?.[0];if(t.textFile)n=ye(t.textFile);if(!n)throw new l("--text or --text-file is required.",c.USAGE,'mmx speech synthesize --text "Hello" --out hello.mp3');let r=t.model||e.defaultSpeechModel||"speech-2.8-hd",o=t.voice||"English_expressive_narrator",s=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),i=t.format||"mp3",m=t.out??`speech_${s}.${i}`,u="hex",a=_(e.output),$={model:r,text:n,voice_setting:{voice_id:o,speed:t.speed??void 0,vol:t.volume??void 0,pitch:t.pitch??void 0},audio_setting:{format:t.format||"mp3",sample_rate:t.sampleRate??32000,bitrate:t.bitrate??128000,channel:t.channels??1},output_format:u,stream:t.stream===!0};if(t.language)$.language_boost=t.language;if(t.subtitles)$.subtitle=!0;if(t.pronunciation)$.pronunciation_dict=t.pronunciation.map((y)=>{let[f,A]=y.split("/");return{tone:A||f,text:f}});if(e.dryRun){console.log(w({request:$},a));return}let d=Xt(e.baseUrl);if(t.stream){let y=await Z(e,{url:d,method:"POST",body:$,stream:!0});for await(let f of Je(y)){if(!f.data||f.data==="[DONE]")break;let S=JSON.parse(f.data)?.data?.audio;if(S)process.stdout.write(Buffer.from(S,"hex"))}return}let h=await v(e,{url:d,method:"POST",body:$});if(!e.quiet)process.stderr.write(`[Model: ${r}]
147
+ `);ce(h,m,a,e.quiet)}});function xo(e){let t=e.match(/^(.+?)_[A-Z]/);return t?t[1]:e}function yo(e,t){let n=t.toLowerCase();return e.filter((r)=>xo(r.voice_id).toLowerCase().includes(n))}var zi=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(e,t){let n=_(e.output);if(e.dryRun){console.log(w({request:{voice_type:"system"}},n));return}let o=(await v(e,{url:Yt(e.baseUrl),method:"POST",body:{voice_type:"system"}})).system_voice??[],s=t.language;if(s){let i=yo(o,s);if(n!=="text"){console.log(w(i,n));return}for(let m of i){let u=m.description?.join("; ")||"",a=m.voice_name?` (${m.voice_name})`:"";if(console.log(` ${m.voice_id}${a}`),u)console.log(` ${u}`)}}else{if(n!=="text"){console.log(w(o.map((i)=>i.voice_id),n));return}for(let i of o)console.log(i.voice_id)}}});import{createWriteStream as wo,unlinkSync as bo}from"fs";var Ji=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function Ii(e){let t=process.stderr.isTTY,n=0,r=null,o=e;return{start(){if(!t)return;r=setInterval(()=>{process.stderr.write(`\r${Ji[n%Ji.length]} ${o}`),n++},80)},update(s){o=s},stop(s){if(r)clearInterval(r),r=null;if(t){if(process.stderr.write("\r\x1B[K"),s)process.stderr.write(`${s}
148
+ `)}}}}function Xi(e,t=""){let n=process.stderr.isTTY,r=30;return{update(o){if(!n)return;let s=Math.min(1,o/e),i=Math.round(30*s),m=30-i,u="█".repeat(i)+"░".repeat(m),a=`${Math.round(s*100)}%`;process.stderr.write(`\r${t} ${u} ${a}`)},finish(){if(n)process.stderr.write(`
149
+ `)}}}async function re(e,t,n){let r=await fetch(e);if(!r.ok)throw new l(`Download failed: HTTP ${r.status}`,c.GENERAL);let o=Number(r.headers.get("content-length")||0),s=r.body?.getReader();if(!s)throw new l("No response body",c.GENERAL);let i=wo(t),m=o>0&&!n?.quiet?Xi(o,"Downloading"):null,u=0,a=!1;try{let $=new Promise((d,h)=>{i.on("error",h)});while(!0){let{done:d,value:h}=await Promise.race([s.read(),$]);if(d)break;if(!i.write(h))await new Promise((f)=>i.once("drain",f));u+=h.byteLength,m?.update(u)}a=!0}finally{if(s.releaseLock(),m?.finish(),await new Promise(($,d)=>{i.on("finish",$),i.on("error",d),i.end()}),!a)try{bo(t)}catch{}}return{size:u}}function Xe(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;if(e<1073741824)return`${(e/1048576).toFixed(1)} MB`;return`${(e/1073741824).toFixed(1)} GB`}import{mkdirSync as fo,existsSync as _o,readFileSync as vo}from"fs";import{join as So,resolve as Ro,extname as Ao}from"path";var ko={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"},Yi=b({name:"image generate",description:"Generate images (image-01 / image-01-live)",apiDocs:"/docs/api-reference/image-generation-t2i",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). Ignored if --width and --height are both specified."},{flag:"--n <count>",description:"Number of images to generate (default: 1)",type:"number"},{flag:"--seed <n>",description:"Random seed for reproducible generation (same seed + prompt = identical output)",type:"number"},{flag:"--width <px>",description:"Custom width in pixels. Range [512, 2048], must be multiple of 8. Only effective for image-01 model. Overrides --aspect-ratio if set.",type:"number"},{flag:"--height <px>",description:"Custom height in pixels. Range [512, 2048], must be multiple of 8. Only effective for image-01 model. Overrides --aspect-ratio if set.",type:"number"},{flag:"--prompt-optimizer",description:"Automatically optimize the prompt before generation for better results."},{flag:"--aigc-watermark",description:"Embed AI-generated content watermark in the output image."},{flag:"--subject-ref <params>",description:"Subject reference for character consistency. Format: type=character,image=path-or-url"},{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',"# Reproducible output with seed",'mmx image generate --prompt "A castle" --seed 42',"# Custom dimensions (must be 512–2048, multiple of 8)",'mmx image generate --prompt "Wide landscape" --width 1920 --height 1080',"# Optimized prompt with watermark",'mmx image generate --prompt "sunset" --prompt-optimizer --aigc-watermark'],async run(e,t){let n=t.prompt??t._positional?.[0];if(!n)if(T({nonInteractive:e.nonInteractive})){let y=await V({message:"Enter your image prompt:"});if(!y)process.stderr.write(`Image generation cancelled.
150
+ `),process.exit(1);n=y}else ue("prompt","mmx image generate --prompt <text>");let{width:r,height:o}=t;if(r!==void 0&&o===void 0)throw new l("--width requires --height. Both must be specified together.",c.USAGE);if(o!==void 0&&r===void 0)throw new l("--height requires --width. Both must be specified together.",c.USAGE);if(r!==void 0&&o!==void 0){let y=(f,A)=>{if(A<512||A>2048)throw new l(`--${f} must be between 512 and 2048, got ${A}.`,c.USAGE);if(A%8!==0)throw new l(`--${f} must be a multiple of 8, got ${A}.`,c.USAGE)};y("width",r),y("height",o)}let s={model:"image-01",prompt:n,aspect_ratio:r!==void 0&&o!==void 0?void 0:t.aspectRatio||void 0,n:t.n??1,seed:t.seed,width:r,height:o,prompt_optimizer:t.promptOptimizer===!0||void 0,aigc_watermark:t.aigcWatermark===!0||void 0};if(t.subjectRef){let y=t.subjectRef,f=Object.fromEntries(y.split(",").map((S)=>{let q=S.indexOf("=");if(q===-1)return[S,""];return[S.slice(0,q),S.slice(q+1)]})),A={type:f.type||"character"};if(f.image)if(f.image.startsWith("http"))A.image_url=f.image;else{let S=Ro(f.image),q=vo(S),B=Ao(S).toLowerCase(),j=ko[B]||"image/jpeg";A.image_file=`data:${j};base64,${q.toString("base64")}`}s.subject_reference=[A]}let i=_(e.output);if(e.dryRun){console.log(w({request:s},i));return}let m=Qt(e.baseUrl),u=await v(e,{url:m,method:"POST",body:s}),a=u.data.image_urls||[];if(!e.quiet)process.stderr.write(`[Model: image-01]
151
+ `);let $=t.outDir??".";if(!_o($))fo($,{recursive:!0});let d=t.outPrefix||"image",h=[];for(let y=0;y<a.length;y++){let f=`${d}_${String(y+1).padStart(3,"0")}.jpg`,A=So($,f);await re(a[y],A,{quiet:e.quiet}),h.push(A)}if(e.quiet)console.log(h.join(`
152
+ `));else console.log(w({id:u.data.task_id,saved:h,success_count:u.data.success_count,failed_count:u.data.failed_count},i))}});async function Qi(e,t){let n=Date.now()+t.timeoutSec*1000,r=Ii("Polling...");if(!e.quiet)r.start();try{while(Date.now()<n){let o=await v(e,{url:t.url});if(t.getStatus&&!e.quiet)r.update(`Status: ${t.getStatus(o)}`);if(t.isComplete(o))return r.stop("Done."),o;if(t.isFailed(o))throw r.stop("Failed."),new l("Task failed.",c.GENERAL);await new Promise((s)=>setTimeout(s,t.intervalSec*1000))}}finally{r.stop()}throw new l("Polling timed out.",c.TIMEOUT,"Try increasing --timeout or check task status manually.")}import{readFileSync as yt}from"fs";import{extname as wt}from"path";var bt={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"},Vi=b({name:"video generate",description:"Generate a video (T2V: Hailuo-2.3 / 2.3-Fast / Hailuo-02 | I2V: I2V-01 / I2V-01-Director / I2V-01-live | S2V: S2V-01)",apiDocs:"/docs/api-reference/video-generation",usage:"mmx video generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID (default: MiniMax-Hailuo-2.3). Auto-switched to Hailuo-02 with --last-frame, or S2V-01 with --subject-image."},{flag:"--prompt <text>",description:"Video description",required:!0},{flag:"--first-frame <path-or-url>",description:"First frame image (local path or URL). Auto base64-encoded for local files."},{flag:"--last-frame <path-or-url>",description:"Last frame image (local path or URL). Enables SEF (start-end frame) interpolation mode with Hailuo-02 model. Requires --first-frame."},{flag:"--subject-image <path-or-url>",description:"Subject reference image for character consistency (local path or URL). Switches to S2V-01 model."},{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',"# SEF: first + last frame interpolation (uses Hailuo-02 model)",'mmx video generate --prompt "Walk forward" --first-frame start.jpg --last-frame end.jpg',"# Subject reference: character consistency (uses S2V-01 model)",'mmx video generate --prompt "A detective walking" --subject-image character.jpg'],async run(e,t){let n=t.prompt;if(!n)if(T({nonInteractive:e.nonInteractive})){let R=await V({message:"Enter your video prompt:"});if(!R)process.stderr.write(`Video generation cancelled.
153
+ `),process.exit(1);n=R}else ue("prompt","mmx video generate --prompt <text>");if(t.lastFrame&&t.subjectImage)throw new l("--last-frame and --subject-image cannot be used together (SEF and S2V are different modes).",c.USAGE,"mmx video generate --prompt <text> --first-frame <path> --last-frame <path>");let r=t.model,o;if(r)o=r;else if(t.lastFrame)o="MiniMax-Hailuo-02";else if(t.subjectImage)o="S2V-01";else o=e.defaultVideoModel||"MiniMax-Hailuo-2.3";let s=_(e.output),i={model:o,prompt:n};if(t.firstFrame){let R=t.firstFrame;if(R.startsWith("http"))i.first_frame_image=R;else{let J=yt(R),F=wt(R).toLowerCase(),D=bt[F]||"image/jpeg";i.first_frame_image=`data:${D};base64,${J.toString("base64")}`}}if(t.lastFrame){if(!t.firstFrame)throw new l("--last-frame requires --first-frame (SEF mode).",c.USAGE,"mmx video generate --prompt <text> --first-frame <path> --last-frame <path>");let R=t.lastFrame;if(R.startsWith("http"))i.last_frame_image=R;else{let J=yt(R),F=wt(R).toLowerCase(),D=bt[F]||"image/jpeg";i.last_frame_image=`data:${D};base64,${J.toString("base64")}`}}if(t.subjectImage){let R=t.subjectImage,J;if(R.startsWith("http"))J=R;else{let F=yt(R),D=wt(R).toLowerCase();J=`data:${bt[D]||"image/jpeg"};base64,${F.toString("base64")}`}i.subject_reference=[{type:"character",image:[J]}]}if(t.callbackUrl)i.callback_url=t.callbackUrl;if(e.dryRun){console.log(w({request:i},s));return}let m=Vt(e.baseUrl),a=(await v(e,{url:m,method:"POST",body:i})).task_id;if(!e.quiet)process.stderr.write(`[Model: ${o}]
154
+ `);if(t.noWait||e.async){process.stdout.write(JSON.stringify({taskId:a})),process.stdout.write(`
155
+ `);return}let $=t.pollInterval??5,d=Re(e.baseUrl,a),h=await Qi(e,{url:d,intervalSec:$,timeoutSec:e.timeout,isComplete:(R)=>R.status==="Success",isFailed:(R)=>R.status==="Failed",getStatus:(R)=>R.status});if(!h.file_id)throw new l("Task completed but no file_id returned.",c.GENERAL);let f=(await v(e,{url:Ae(e.baseUrl,h.file_id)})).file?.download_url;if(!f)throw new l("No download URL available for this file.",c.GENERAL);if(t.download){let R=t.download,{size:J}=await re(f,R,{quiet:e.quiet});if(e.quiet)console.log(R);else console.log(w({task_id:a,status:"Success",file_id:h.file_id,saved:R,size:Xe(J)},s));return}let A=await import("os"),{join:S}=await import("path"),q=S(A.tmpdir(),"mmx-video"),{existsSync:B,mkdirSync:j}=await import("fs");if(!B(q))j(q,{recursive:!0});let L=S(q,`${a}.mp4`);await re(f,L,{quiet:e.quiet}),process.stdout.write(L),process.stdout.write(`
156
+ `)}});var Zi=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(e,t){let n=t.taskId;if(!n)throw new l("--task-id is required.",c.USAGE,"mmx video task get --task-id <id>");if(e.dryRun){console.log(`Would query task: ${n}`);return}let r=Re(e.baseUrl,n),o=await v(e,{url:r}),s=_(e.output);if(e.quiet){console.log(o.status);return}console.log(w({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 Wi=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(e,t){let n=t.fileId;if(!n)throw new l("--file-id is required.",c.USAGE,"mmx video download --file-id <id> --out <path>");let r=t.out;if(!r)throw new l("--out is required.",c.USAGE,"mmx video download --file-id <id> --out video.mp4");if(e.dryRun){console.log(`Would download file ${n} to ${r}`);return}let o=Ae(e.baseUrl,n),i=(await v(e,{url:o})).file?.download_url;if(!i)throw new l("No download URL available for this file.",c.GENERAL,"The file may still be processing. Check task status first.");let{size:m}=await re(i,r,{quiet:e.quiet}),u=_(e.output);if(e.quiet){console.log(r);return}console.log(w({saved:r,size:Xe(m)},u))}});Ie();function Ui(e){return(e.apiKey??e.fileApiKey??"").startsWith("sk-cp-")}function Hi(e){if(e.defaultMusicModel)return e.defaultMusicModel;return Ui(e)?"music-2.6":"music-2.6-free"}var Mo=new Set(["music-cover","music-cover-free"]);function Ki(e){if(e.defaultMusicModel&&Mo.has(e.defaultMusicModel))return e.defaultMusicModel;return Ui(e)?"music-cover":"music-cover-free"}var Pi=b({name:"music generate",description:"Generate a song (music-2.6 / music-2.6-free / music-2.5+ / music-2.5)",apiDocs:"/docs/api-reference/music-generation",usage:"mmx music generate --prompt <text> (--lyrics <text> | --instrumental | --lyrics-optimizer) [--out <path>] [flags]",options:[{flag:"--prompt <text>",description:'Music style description (e.g. "cinematic orchestral, building tension"). Max 2000 chars when combined with structured flags.'},{flag:"--lyrics <text>",description:"Song lyrics with structure tags (newline separated). Supported: [Intro], [Verse], [Pre Chorus], [Chorus], [Interlude], [Bridge], [Outro], [Post Chorus], [Transition], [Break], [Hook], [Build Up], [Inst], [Solo]. Tags must be clean — no descriptions inside brackets (they will be sung). Max 3500 chars."},{flag:"--lyrics-file <path>",description:"Read lyrics from file (use - for stdin). Same tag rules as --lyrics."},{flag:"--lyrics-optimizer",description:"Auto-generate lyrics from prompt (cannot be used with --lyrics or --instrumental)"},{flag:"--instrumental",description:"Generate instrumental music (no vocals). music-2.6/music-2.5+: native is_instrumental flag; music-2.5: lyrics workaround. 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, electronic"},{flag:"--mood <text>",description:"Mood or emotion, e.g. warm, melancholic, uplifting"},{flag:"--instruments <text>",description:'Instruments to feature, e.g. "acoustic guitar, piano, strings"'},{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"'},{flag:"--extra <text>",description:"Additional fine-grained requirements not covered above"},{flag:"--model <model>",description:"Model: music-2.6 (recommended), music-2.6-free (default, unlimited), music-2.5+, or music-2.5."},{flag:"--output-format <fmt>",description:"Return format: hex (default, saved to file) or url (24h expiry, download promptly). When --stream, only hex."},{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',"# URL output (24h expiry — download promptly):",'mmx music generate --prompt "Upbeat pop" --lyrics "La la la..." --output-format url',"# Instrumental with music-2.5+:",'mmx music generate --prompt "Cinematic orchestral" --model "music-2.5+" --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(e,t){let{prompt:n,lyrics:r}=t,o=t.instrumental===!0,s=t.lyricsOptimizer===!0;if(t.lyricsFile)r=ye(t.lyricsFile);if(o&&(r||t.lyricsFile))throw new l("Cannot use --instrumental with --lyrics or --lyrics-file.",c.USAGE,"mmx music generate --prompt <style> --instrumental");if(s&&(r||o))throw new l("Cannot use --lyrics-optimizer with --lyrics, --lyrics-file, or --instrumental.",c.USAGE,"mmx music generate --prompt <text> --lyrics-optimizer");if(!n&&!r&&!o&&!s)throw new l("At least one of --prompt or --lyrics is required.",c.USAGE,"mmx music generate --prompt <text> --lyrics <text>");if(!o&&!s&&!r?.trim())throw new l("Lyrics are required. Add --lyrics or --lyrics-file, or use --instrumental for pure music, or --lyrics-optimizer to auto-generate.",c.USAGE,"mmx music generate --prompt <text> --lyrics <text>");let i=[];if(t.vocals)i.push(`Vocals: ${t.vocals}`);if(t.genre)i.push(`Genre: ${t.genre}`);if(t.mood)i.push(`Mood: ${t.mood}`);if(t.instruments)i.push(`Instruments: ${t.instruments}`);if(t.tempo)i.push(`Tempo: ${t.tempo}`);if(t.bpm)i.push(`BPM: ${t.bpm}`);if(t.key)i.push(`Key: ${t.key}`);if(t.avoid)i.push(`Avoid: ${t.avoid}`);if(t.useCase)i.push(`Use case: ${t.useCase}`);if(t.structure)i.push(`Structure: ${t.structure}`);if(t.references)i.push(`References: ${t.references}`);if(t.extra)i.push(`Extra: ${t.extra}`);if(i.length>0){let q=i.join(". ");n=n?`${n}. ${q}`:q}let m=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),u=t.format||"mp3",a=t.out??`music_${m}.${u}`,$=_(e.output),d=t.model||Hi(e),h=["music-2.6","music-2.6-free","music-2.5+","music-2.5"];if(t.model&&!h.includes(d))throw new l(`Invalid model "${d}". Valid models: ${h.join(", ")}`,c.USAGE,"mmx music generate --model music-2.6");let y=t.outputFormat||"hex";if(y!=="hex"&&y!=="url")throw new l('--output-format must be "hex" or "url".',c.USAGE,"mmx music generate --output-format url");if(t.stream&&y==="url")throw new l("--stream and --output-format url cannot be used together. Streaming requires hex format.",c.USAGE,"mmx music generate --output-format url");let f={model:d,prompt:n,lyrics:r,is_instrumental:o||void 0,lyrics_optimizer:s||void 0,audio_setting:{format:t.format||"mp3",sample_rate:t.sampleRate??44100,bitrate:t.bitrate??256000},output_format:t.stream===!0?"hex":y,stream:t.stream===!0};if(t.aigcWatermark)f.aigc_watermark=!0;if(e.dryRun){console.log(w({request:f},$));return}let A=ke(e.baseUrl);if(t.stream){let B=(await Z(e,{url:A,method:"POST",body:f,stream:!0})).body?.getReader();if(!B)throw new l("No response body",c.GENERAL);while(!0){let{done:j,value:L}=await B.read();if(j)break;process.stdout.write(L)}B.releaseLock();return}let S=await v(e,{url:A,method:"POST",body:f});if(!e.quiet)process.stderr.write(`[Model: ${d}]
157
+ `);if(y==="url"){if(S.data?.audio_url)console.log(S.data.audio_url);else throw new l("Requested URL output but API did not return audio_url.",c.GENERAL);return}ce(S,a,$,e.quiet)}});import{readFileSync as qo}from"fs";var Ci=b({name:"music cover",description:"Generate a cover version of a song based on reference audio (music-cover / music-cover-free)",apiDocs:"/docs/api-reference/music-generation",usage:"mmx music cover --prompt <text> (--audio <url> | --audio-file <path>) [--lyrics <text>] [--out <path>] [flags]",options:[{flag:"--model <model>",description:"Model: music-cover (Token Plan), music-cover-free (Pay-as-you-go, default). Override only if needed."},{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(e,t){let{prompt:n,audio:r,audioFile:o}=t;if(!n)throw new l("--prompt is required.",c.USAGE,"mmx music cover --prompt <text> --audio <url>");if(!r&&!o)throw new l("One of --audio <url> or --audio-file <path> is required.",c.USAGE,"mmx music cover --prompt <text> --audio <url>");if(r&&o)throw new l("Use either --audio or --audio-file, not both.",c.USAGE);let s=t.lyrics;if(t.lyricsFile){let{readTextFromPathOrStdin:A}=await Promise.resolve().then(() => (Ie(),Ni));s=A(t.lyricsFile)}let i=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),m=t.format||"mp3",u=t.out??`cover_${i}.${m}`,a=_(e.output),$=t.model||Ki(e),d=["music-cover","music-cover-free"];if(t.model&&!d.includes($))throw new l(`Invalid model "${$}". Valid models: ${d.join(", ")}`,c.USAGE,"mmx music cover --model music-cover");let h={model:$,prompt:n,lyrics:s,seed:t.seed,audio_setting:{format:m,sample_rate:t.sampleRate??44100,bitrate:t.bitrate??256000,channel:t.channel??void 0},output_format:"hex",stream:t.stream===!0};if(r)h.audio_url=r;else h.audio_base64=qo(o).toString("base64");if(e.dryRun){console.log(w({request:h},a));return}let y=ke(e.baseUrl);if(t.stream){let S=(await Z(e,{url:y,method:"POST",body:h,stream:!0})).body?.getReader();if(!S)throw new l("No response body",c.GENERAL);while(!0){let{done:q,value:B}=await S.read();if(q)break;process.stdout.write(B)}S.releaseLock();return}let f=await v(e,{url:y,method:"POST",body:h});if(!e.quiet)process.stderr.write(`[Model: ${$}]
158
+ `);ce(f,u,a,e.quiet)}});var Ei=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(e,t){let n=t.q??t._positional?.[0];if(!n)throw new l("--q is required.",c.USAGE,'mmx search query --q "your search query"');let r=_(e.output);if(e.dryRun){console.log(w({request:{q:n}},r));return}let o=Zt(e.baseUrl),s=await v(e,{url:o,method:"POST",body:{q:n}}),i=s.organic||[];if(r!=="text"){console.log(w(s,r));return}if(e.quiet){for(let m of i)console.log(`${m.title} ${m.link}`);return}if(i.length===0){console.log("No results found.");return}for(let m of i){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 jo,existsSync as To}from"fs";import{extname as Go}from"path";var Oo={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"};async function Bo(e){if(e.startsWith("data:"))return e;if(e.startsWith("http://")||e.startsWith("https://")){let o=await fetch(e);if(!o.ok)throw new l(`Failed to download image: HTTP ${o.status}`,c.GENERAL);let i=(o.headers.get("content-type")||"image/jpeg").split(";")[0].trim(),m=await o.arrayBuffer(),u=Buffer.from(m).toString("base64");return`data:${i};base64,${u}`}if(!To(e))throw new l(`File not found: ${e}`,c.USAGE);let t=Go(e).toLowerCase(),n=Oo[t];if(!n)throw new l(`Unsupported image format "${t}". Supported: jpg, jpeg, png, webp`,c.USAGE);let r=jo(e);return`data:${n};base64,${r.toString("base64")}`}var Li=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(e,t){let n=t.image??t._positional?.[0],r=t.fileId,o=t.prompt||"Describe the image.";if(!n&&!r)if(T({nonInteractive:e.nonInteractive})){let a=await V({message:"Enter image path, URL, or File ID:"});if(!a)process.stderr.write(`Vision describe cancelled.
159
+ `),process.exit(1);if(!a.includes(".")&&!a.startsWith("http"))r=a;else n=a}else throw new l("Missing required argument. Must provide either --image or --file-id.",c.USAGE,"mmx vision describe --image <path> OR --file-id <id>");else if(n&&r)throw new l("Conflicting arguments: cannot provide both --image and --file-id.",c.USAGE);let s=_(e.output);if(e.dryRun){process.stdout.write(w({request:{prompt:o,image:n,fileId:r}},s)+`
160
+ `);return}let i=Wt(e.baseUrl),m={prompt:o};if(r)m.file_id=r;else if(n){let a=await Bo(n);m.image_url=a}let u=await v(e,{url:i,method:"POST",body:m});if(s!=="text"){process.stdout.write(w(u,s)+`
161
+ `);return}process.stdout.write(u.content+`
162
+ `)}});var Fi=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(e,t){if(e.dryRun){console.log("Would fetch quota information.");return}let n=ee(e.baseUrl),r=await v(e,{url:n}),o=r.model_remains||[],s=_(t.output);if(s!=="text"){console.log(w(r,s));return}if(e.quiet){for(let i of o){let m=i.current_interval_total_count-i.current_interval_usage_count;console.log(`${i.model_name} ${i.current_interval_usage_count} ${i.current_interval_total_count} ${m}`)}return}pe(o,e)}});var Di=b({name:"config show",description:"Display current configuration",usage:"mmx config show",examples:["mmx config show","mmx config show --output json"],async run(e,t){let n=O(),r=_(e.output),o={region:e.region,base_url:e.baseUrl,output:e.output,timeout:e.timeout,config_file:U()};if(n.api_key)o.api_key=X(n.api_key);if(n.default_text_model)o.default_text_model=n.default_text_model;if(n.default_speech_model)o.default_speech_model=n.default_speech_model;if(n.default_video_model)o.default_video_model=n.default_video_model;if(n.default_music_model)o.default_music_model=n.default_music_model;console.log(w(o,r))}});var en=["region","base_url","output","timeout","api_key","default_text_model","default_speech_model","default_video_model","default_music_model"],No={"default-text-model":"default_text_model","default-speech-model":"default_speech_model","default-video-model":"default_video_model","default-music-model":"default_music_model"},tn=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, default_text_model, default_speech_model, default_video_model, default_music_model)"},{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(e,t){let{key:n,value:r}=t;if(!n||r===void 0)throw new l("--key and --value are required.",c.USAGE,"mmx config set --key <key> --value <value>");let o=No[n]||n;if(!en.includes(o))throw new l(`Invalid config key "${n}". Valid keys: ${en.join(", ")}`,c.USAGE);if(o==="region"&&!["global","cn"].includes(r))throw new l(`Invalid region "${r}". Valid values: global, cn`,c.USAGE);if(o==="output"&&!["text","json"].includes(r))throw new l(`Invalid output format "${r}". Valid values: text, json`,c.USAGE);if(o==="timeout"){let m=Number(r);if(isNaN(m)||m<=0)throw new l(`Invalid timeout "${r}". Must be a positive number.`,c.USAGE)}let s=_(e.output);if(e.dryRun){console.log(w({would_set:{[o]:r}},s));return}let i=O();if(i[o]=o==="timeout"?Number(r):r,await Q(i),!e.quiet)console.log(w({[o]:i[o]},s))}});function go(e){let t=e.match(/^--([a-zA-Z0-9-]+)/),n=t?t[1]:"",r=n.replace(/-([a-zA-Z0-9])/g,(i,m)=>m.toUpperCase()),o="string",s=!1;if(!e.includes("<")&&!e.includes("["))o="boolean";else if(e.includes("<n>")||e.includes("<hz>")||e.includes("<bps>")||e.includes("<count>"))o="number";if(e.toLowerCase().includes("repeatable"))s=!0;return{name:r,kebabName:n,inferredType:o,isArray:s}}function ft(e){let n={name:`mmx_${e.name.replace(/ /g,"_")}`,description:e.description,input_schema:{type:"object",properties:{},required:[]}};if(e.options)for(let r of e.options){let{name:o,inferredType:s,isArray:i}=go(r.flag);if(!o)continue;let m=r.type,u=i?"array":m??s,a={description:r.description};if(u==="array")a.type="array",a.items={type:"string"};else a.type=u;let $=n.input_schema;if($.properties[o]=a,r.required)$.required.push(o)}return n}var zo=["auth ","config ","update"],nn=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(e,t){let n=t.command;if(n){try{let{command:s}=E.resolve(n.split(" ")),i=ft(s);process.stdout.write(JSON.stringify(i,null,2)+`
163
+ `)}catch{throw new l(`Command "${n}" not found.`,c.USAGE)}return}let o=E.getAllCommands().filter((s)=>!zo.some((i)=>s.name.startsWith(i))).map((s)=>ft(s));process.stdout.write(JSON.stringify(o,null,2)+`
164
+ `)}});var Jo="1.0.9",rn=b({name:"update",description:"Update mmx to the latest version",usage:"mmx update",examples:["mmx update"],async run(){process.stderr.write(`Current version: ${Jo}
165
165
 
166
166
  `),process.stderr.write(`Run:
167
167
  `),process.stderr.write(` npm update -g mmx-cli
168
168
 
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(" ")}
169
+ `)}});var Io=[{command:"mmx text chat",title:"Text Generation (Chat Completion)",path:"/docs/api-reference/text-post"},{command:"mmx speech synthesize",title:"Speech T2A (Text-to-Audio)",path:"/docs/api-reference/speech-t2a-http"},{command:"mmx image generate",title:"Image Generation (T2I / I2I)",path:"/docs/api-reference/image-generation-t2i"},{command:"mmx video generate",title:"Video Generation (T2V / I2V / S2V)",path:"/docs/api-reference/video-generation"},{command:"mmx music generate",title:"Music Generation",path:"/docs/api-reference/music-generation"},{command:"mmx music cover",title:"Music Cover (via Music Generation)",path:"/docs/api-reference/music-generation"},{command:"mmx search query",title:"Web Search",path:"/docs/api-reference/web-search"},{command:"mmx vision describe",title:"Vision (Image Understanding)",path:"/docs/api-reference/vision"}],on=b({name:"help",description:"Show MiniMax API documentation links",usage:"mmx help",async run(e,t){let n=$e[e.region]||$e.global;process.stdout.write(`
170
+ MiniMax API Documentation Links
171
+
172
+ Official docs: ${n}/docs/api-reference
173
+
174
+ `);for(let r of Io)process.stdout.write(` ${r.command.padEnd(30)} ${r.title}
175
+ `),process.stdout.write(` ${" ".repeat(30)} ${n}${r.path}
176
+
177
+ `)}});class sn{root={children:new Map};constructor(e){for(let[t,n]of Object.entries(e))this.register(t,n)}register(e,t){let n=e.split(" "),r=this.root;for(let o of n){if(!r.children.has(o))r.children.set(o,{children:new Map});r=r.children.get(o)}r.command=t}getAllCommands(){let e=[],t=(n)=>{if(n.command)e.push(n.command);for(let r of n.children.values())t(r)};return t(this.root),e}resolve(e){let t=this.root,n=[];for(let r of e){let o=t.children.get(r);if(!o)break;t=o,n.push(r)}if(t.command)return{command:t.command,extra:e.slice(n.length)};if(n.length>0&&t.children.size===1){let[,r]=t.children.entries().next().value;if(r.command)return{command:r.command,extra:e.slice(n.length)}}if(n.length>0&&t.children.size>0){let r=Array.from(t.children.entries()).map(([o,s])=>{if(s.command)return` ${n.join(" ")} ${o} ${s.command.description}`;let i=Array.from(s.children.keys()).join(", ");return` ${n.join(" ")} ${o} [${i}]`}).join(`
178
+ `);throw new l(`Unknown command: mmx ${e.join(" ")}
171
179
 
172
180
  Available commands:
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]
175
-
176
- `),e.write(`${this.bold("Commands:",e)}
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:")}
181
+ ${r}`,c.USAGE,`mmx ${n.join(" ")} --help`)}throw new l(`Unknown command: mmx ${e.join(" ")}`,c.USAGE,"mmx --help")}bold=(e,t)=>t.isTTY?`\x1B[1m${e}\x1B[0m`:e;accent=(e,t)=>t.isTTY?`\x1B[38;2;248;103;58m${e}\x1B[0m`:e;dim=(e,t)=>t.isTTY?`\x1B[2m${e}\x1B[0m`:e;printHelp(e,t=process.stdout,n="global"){if(e.length===0){this.printRootHelp(t);return}let r=this.root;for(let s of e){let i=r.children.get(s);if(!i){this.printRootHelp(t);return}r=i}if(r.command){this.printCommandHelp(r.command,t,n);return}let o=e.join(" ");t.write(`
182
+ ${this.bold("Usage:",t)} mmx ${o} <command> [flags]
183
+
184
+ `),t.write(`${this.bold("Commands:",t)}
185
+ `),this.printChildren(r,o,t),t.write(`
186
+ `)}printRootHelp(e){let t=["███╗ ███╗███╗ ███╗██╗ ██╗","████╗ ████║████╗ ████║╚██╗██╔╝","██╔████╔██║██╔████╔██║ ╚███╔╝ ","██║╚██╔╝██║██║╚██╔╝██║ ██╔██╗ ","██║ ╚═╝ ██║██║ ╚═╝ ██║██╔╝ ██╗","╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝"],n=[[240,23,122],[242,43,106],[244,63,90],[246,83,74],[248,103,58],[250,123,42]];e.write(`
187
+ `);for(let i=0;i<t.length;i++)if(e.isTTY){let[m,u,a]=n[i];e.write(`\x1B[1;38;2;${m};${u};${a}m${t[i]}\x1B[0m
188
+ `)}else e.write(t[i]+`
189
+ `);let r=(i)=>this.bold(i,e),o=(i)=>this.accent(i,e),s=(i)=>this.dim(i,e);e.write(`
190
+ ${r("Usage:")} mmx <resource> <command> [flags]
191
+
192
+ ${r("Resources:")}
185
193
  ${o("auth")} ${s("Authentication (login, status, refresh, logout)")}
186
194
  ${o("text")} ${s("Text generation (chat)")}
187
195
  ${o("speech")} ${s("Speech synthesis (synthesize, voices)")}
@@ -194,7 +202,7 @@ ${i("Resources:")}
194
202
  ${o("config")} ${s("CLI configuration (show, set, export-schema)")}
195
203
  ${o("update")} ${s("Update mmx to a newer version")}
196
204
 
197
- ${i("Global Flags:")}
205
+ ${r("Global Flags:")}
198
206
  ${o("--api-key <key>")} ${s("API key (overrides all other auth)")}
199
207
  ${o("--region <region>")} ${s("API region: global (default), cn")}
200
208
  ${o("--base-url <url>")} ${s("API base URL (overrides region)")}
@@ -208,47 +216,52 @@ ${i("Global Flags:")}
208
216
  ${o("--version")} ${s("Print version and exit")}
209
217
  ${o("--help")} ${s("Show help")}
210
218
 
211
- ${i("Getting Help:")}
219
+ ${r("Getting Help:")}
212
220
  ${s("Add --help after any command to see its full list of options, defaults,")}
213
221
  ${s("and usage examples. For example:")} mmx text chat --help
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(`
215
- ${t.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)}
220
- `)}if(t.examples&&t.examples.length>0){e.write(`
221
- ${n("Examples:")}
222
- `);for(let s of t.examples)e.write(` ${o(s)}
223
- `)}e.write(`
224
- ${o("Global flags (--api-key, --output, --quiet, etc.) are always available.")}
225
- `),e.write(`${o("Run")} mmx --help ${o("for the full list.")}
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)+`
222
+ `)}printCommandHelp(e,t,n="global"){let r=(i)=>this.bold(i,t),o=(i)=>this.accent(i,t),s=(i)=>this.dim(i,t);if(t.write(`
223
+ ${e.description}
224
+ `),e.usage)t.write(`${r("Usage:")} ${e.usage}
225
+ `);if(e.options&&e.options.length>0){let i=Math.max(...e.options.map((m)=>m.flag.length));t.write(`
226
+ ${r("Options:")}
227
+ `);for(let m of e.options)t.write(` ${o(m.flag.padEnd(i+2))} ${s(m.description)}
228
+ `)}if(e.examples&&e.examples.length>0){t.write(`
229
+ ${r("Examples:")}
230
+ `);for(let i of e.examples)t.write(` ${s(i)}
231
+ `)}if(e.apiDocs)t.write(`
232
+ ${r("API Reference:")} ${s($e[n]+e.apiDocs)}
233
+ `);t.write(`
234
+ ${s("Global flags (--api-key, --output, --quiet, etc.) are always available.")}
235
+ `),t.write(`${s("Run")} mmx --help ${s("for the full list.")}
236
+ `)}printChildren(e,t,n){let r=[],o=(i,m)=>{for(let[u,a]of i.children){if(a.command)r.push({fullName:`${m} ${u}`,description:a.command.description});if(a.children.size>0)o(a,`${m} ${u}`)}};o(e,t);let s=Math.max(...r.map((i)=>i.fullName.length));for(let{fullName:i,description:m}of r)n.write(` ${this.accent(i.padEnd(s),n)} ${this.dim(m,n)}
237
+ `)}}var E=new sn({"auth login":qi,"auth status":ji,"auth refresh":Ti,"auth logout":Gi,"text chat":Bi,"speech synthesize":gi,"speech voices":zi,"image generate":Yi,"video generate":Vi,"video task get":Zi,"video download":Wi,"music generate":Pi,"music cover":Ci,"search query":Ei,"vision describe":Li,"quota show":Fi,"config show":Di,"config set":tn,"config export-schema":nn,update:rn,help:on});function oe(e){if(e instanceof l){if(_(process.env.MINIMAX_OUTPUT)==="json")process.stderr.write(JSON.stringify(e.toJSON(),null,2)+`
228
238
  `);else{if(process.stderr.write(`
229
- Error: ${t.message}
230
- `),t.hint)process.stderr.write(`
231
- ${t.hint.split(`
239
+ Error: ${e.message}
240
+ `),e.hint)process.stderr.write(`
241
+ ${e.hint.split(`
232
242
  `).join(`
233
243
  `)}
234
- `);process.stderr.write(` (exit code ${t.exitCode})
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(`
236
- Error: ${t.message}
237
- `),process.env.MINIMAX_VERBOSE==="1")process.stderr.write(`${t.stack}
244
+ `);process.stderr.write(` (exit code ${e.exitCode})
245
+ `)}process.exit(e.exitCode)}if(e instanceof Error){if(e.name==="AbortError"||e.name==="TimeoutError"||e.message.includes("timed out")){let o=new l("Request timed out.",c.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
246
+ If this happens on every request with a valid API key, you may be hitting the wrong region.
247
+ `+`Run: mmx auth status — to check your credentials and region.
248
+ `+"Run: mmx config set region global (or cn) — to override the region.");return oe(o)}if(e instanceof TypeError&&e.message==="fetch failed"){let o=new l("Network request failed.",c.NETWORK,"Check your network connection and proxy settings. Also verify MINIMAX_BASE_URL is a valid URL.");return oe(o)}let t=e.message.toLowerCase();if(t.includes("failed to fetch")||t.includes("connection refused")||t.includes("econnrefused")||t.includes("connection reset")||t.includes("econnreset")||t.includes("network error")||t.includes("enotfound")||t.includes("getaddrinfo")||t.includes("proxy")||t.includes("socket")||t.includes("etimedout")||t.includes("timeout")||t.includes("eai_AGAIN")){let o="Check your network connection and proxy settings.";if(t.includes("proxy"))o="Proxy error — check HTTP_PROXY / HTTPS_PROXY environment variables and proxy authentication.";let s=new l("Network request failed.",c.NETWORK,o);return oe(s)}let r=e.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 l(`File system error: ${e.message}`,c.GENERAL,o);return oe(s)}else if(typeof r==="string"&&r.startsWith("E")){let o=new l(`File system error: ${e.message}`,c.GENERAL,"Check the file path and permissions.");return oe(o)}if(process.stderr.write(`
249
+ Error: ${e.message}
250
+ `),process.env.MINIMAX_VERBOSE==="1")process.stderr.write(`${e.stack}
238
251
  `)}else process.stderr.write(`
239
- Error: ${String(t)}
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
252
+ Error: ${String(e)}
253
+ `);process.exit(c.GENERAL)}var Xo="/v1/token_plan/remains";function Yo(e){return W[e]+Xo}async function Qo(e,t,n){let r=[{Authorization:`Bearer ${t}`},{"x-api-key":t}];for(let o of r)try{let s=await fetch(Yo(e),{headers:{...o,"Content-Type":"application/json"},signal:AbortSignal.timeout(n)});if(!s.ok)continue;if((await s.json()).base_resp?.status_code===0)return!0}catch{}return!1}async function mn(e){process.stderr.write("Detecting region...");let t=Object.keys(W),r=(await Promise.all(t.map(async(s)=>({region:s,ok:await Qo(s,e,5000)})))).find((s)=>s.ok);if(!r)return process.stderr.write(` failed
241
254
  `),process.stderr.write(`Warning: API key failed validation against all regions. Falling back to global.
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.7";process.on("SIGINT",()=>{process.stderr.write(`
255
+ `),"global";let o=r.region;return process.stderr.write(` ${o}
256
+ `),o}async function pn(e){let t=O();t.region=e,await Q(t)}import{join as Vo}from"path";import{readFileSync as Zo,writeFileSync as Wo}from"fs";var an=()=>Vo(de(),"update-state.json"),Uo=86400000,Ho=3000,Ko="MiniMax-AI-Dev/minimax-cli";function Po(){try{let e=Zo(an(),"utf-8");return JSON.parse(e)}catch{return null}}function Co(e){try{Wo(an(),JSON.stringify(e))}catch{}}async function Eo(){try{let e=await fetch(`https://api.github.com/repos/${Ko}/releases/latest`,{headers:{Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},signal:AbortSignal.timeout(Ho)});if(!e.ok)return null;return(await e.json()).tag_name??null}catch{return null}}var _t=null;function un(){return _t}async function cn(e){if(process.env.CI||!process.stderr.isTTY)return;let t=Po(),n=Date.now();if(t&&n-t.lastChecked<Uo){if(t.latestVersion&&t.latestVersion!==`v${e}`)_t=t.latestVersion;return}let r=await Eo();if(!r)return;if(Co({lastChecked:n,latestVersion:r}),r!==`v${e}`)_t=r}async function ln(e){if(e.apiKey||e.fileApiKey)return;let t=process.env.MINIMAX_API_KEY,n;if(t){if(!T({nonInteractive:e.nonInteractive}))n=t;else if(await Oi({message:`Found MINIMAX_API_KEY in environment (${X(t)}). Save it to config file?`}))n=t}if(!n){if(!T({nonInteractive:e.nonInteractive}))throw new l("No API key found.",c.AUTH,`Set env var: export MINIMAX_API_KEY=sk-xxxxx
257
+ Pass directly: --api-key sk-xxxxx`);let s=await V({message:"Enter your MiniMax API key:"});if(!s)throw new l("API key is required.",c.AUTH);n=s}let r={...O(),api_key:n};await Q(r),e.fileApiKey=n;let o=e.configPath??"~/.mmx/config.json";process.stderr.write(`API key saved to ${o}
258
+ `)}var $n="1.0.9";process.on("SIGINT",()=>{process.stderr.write(`
246
259
  Interrupted. Exiting.
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.
260
+ `),process.exit(130)});process.stdout.on("error",(e)=>{if(e.code==="EPIPE")process.exit(0);else throw e});var Lo=[["auth","login"],["auth","logout"],["config","show"],["config","set"],["config","export-schema"],["update"]];async function Fo(){let e=process.argv.slice(2);if(e.includes("--version")||e.includes("-v"))console.log(`mmx ${$n}`),process.exit(0);let t=At(e,fe);if(e.includes("--help")||e.includes("-h")){let a=e.indexOf("--region"),$=a>=0&&e[a+1]||process.env.MINIMAX_REGION||O().region||"global";E.printHelp(t,process.stderr,$),process.exit(0)}if(t.length===0){E.printHelp([],process.stderr);let{command:a}=E.resolve(["quota","show"]),$=We(e,[...fe,...a.options??[]]),d=Ee($),h=!!(d.apiKey||d.fileApiKey),y=!!await I();if(h||y)await a.execute(d,$);else process.stderr.write(` Not logged in.
248
261
  `),process.stderr.write(` mmx auth login --api-key sk-xxxxx
249
262
 
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}
263
+ `);process.exit(0)}let{command:n,extra:r}=E.resolve(t),o=We(e,[...fe,...n.options??[]]);if(r.length>0)o._positional=r;let s=Ee(o);if(!Lo.some((a)=>a.every(($,d)=>t[d]===$)))await ln(s);if(s.needsRegionDetection){let a=s.apiKey||s.fileApiKey;if(a){let $=await mn(a);s.region=$,s.baseUrl=W[$],s.needsRegionDetection=!1,await pn($)}}let m=cn($n).catch(()=>{});await n.execute(s,o),await m;let u=un();if(u&&!s.quiet)process.stderr.write(`
264
+ Update available: ${u}
252
265
  `),process.stderr.write(` npm update -g mmx-cli
253
266
 
254
- `)}Eo().catch(et);
267
+ `)}Fo().catch(oe);