mmx-cli 1.0.13 → 1.0.14
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.
- package/README.md +13 -5
- package/dist/index.d.ts +101 -0
- package/dist/mmx.mjs +279 -228
- package/dist/sdk.mjs +421 -217
- package/package.json +1 -1
package/dist/mmx.mjs
CHANGED
|
@@ -1,104 +1,113 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as
|
|
2
|
+
import{createRequire as Mr}from"node:module";var rr=Object.create;var{getPrototypeOf:mr,defineProperty:Bn,getOwnPropertyNames:pr}=Object;var xr=Object.prototype.hasOwnProperty;function or(t){return this[t]}var yr,_r,Ht=(t,n,e)=>{var i=t!=null&&typeof t==="object";if(i){var r=n?yr??=new WeakMap:_r??=new WeakMap,m=r.get(t);if(m)return m}e=t!=null?rr(mr(t)):{};let $=n||!t||!t.__esModule?Bn(e,"default",{value:t,enumerable:!0}):e;for(let p of pr(t))if(!xr.call($,p))Bn($,p,{get:or.bind(t,p),enumerable:!0});if(i)r.set(t,$);return $};var M$=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports);var wr=(t)=>t;function ur(t,n){this[t]=wr.bind(null,n)}var It=(t,n)=>{for(var e in n)Bn(t,e,{get:n[e],enumerable:!0,configurable:!0,set:ur.bind(n,e)})};var b=(t,n)=>()=>(t&&(n=t(t=0)),n);var jt=Mr(import.meta.url);var y;var h=b(()=>{y={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONTENT_FILTER:10}});var _;var k=b(()=>{h();_=class _ extends Error{exitCode;hint;constructor(t,n=y.GENERAL,e){super(t);this.name="CLIError",this.exitCode=n,this.hint=e}toJSON(){return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{}}}}}});function Gr(t){if(!t||typeof t!=="object"||Array.isArray(t))return;let n=t;if(typeof n.access_token!=="string"||!n.access_token)return;if(typeof n.refresh_token!=="string")return;if(typeof n.expires_at!=="string")return;let e={access_token:n.access_token,refresh_token:n.refresh_token,expires_at:n.expires_at};if(typeof n.region==="string"&&b$.has(n.region))e.region=n.region;if(typeof n.resource_url==="string"&&n.resource_url.startsWith("http"))e.resource_url=n.resource_url;if(typeof n.account==="string"&&n.account.length>0)e.account=n.account;return e}function G$(t){if(!t||typeof t!=="object"||Array.isArray(t))return{};let n=t,e={};if(typeof n.api_key==="string")e.api_key=n.api_key;if(typeof n.region==="string"&&b$.has(n.region))e.region=n.region;if(typeof n.base_url==="string"&&n.base_url.startsWith("http"))e.base_url=n.base_url;if(typeof n.output==="string"&&br.has(n.output))e.output=n.output;if(typeof n.timeout==="number"&&n.timeout>0)e.timeout=n.timeout;if(typeof n.proxy==="string"&&n.proxy.startsWith("http"))e.proxy=n.proxy;let i=Gr(n.oauth);if(i)e.oauth=i;if(typeof n.default_text_model==="string"&&n.default_text_model.length>0)e.default_text_model=n.default_text_model;if(typeof n.default_speech_model==="string"&&n.default_speech_model.length>0)e.default_speech_model=n.default_speech_model;if(typeof n.default_video_model==="string"&&n.default_video_model.length>0)e.default_video_model=n.default_video_model;if(typeof n.default_music_model==="string"&&n.default_music_model.length>0)e.default_music_model=n.default_music_model;return e}var K,Qt,Pt,b$,br;var g=b(()=>{K={global:"https://api.minimax.io",cn:"https://api.minimaxi.com"},Qt={global:"https://platform.minimax.io",cn:"https://platform.minimaxi.com"},Pt={global:"https://account.minimax.io",cn:"https://account.minimaxi.com"},b$=new Set(["global","cn"]),br=new Set(["text","json"])});function q(t){return{name:t.name,description:t.description,usage:t.usage,options:t.options,examples:t.examples,apiDocs:t.apiDocs,execute:t.run}}var st;var V=b(()=>{st=[{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{homedir as Sr}from"os";import{join as S$}from"path";function lt(){if(process.env.MMX_CONFIG_DIR)return process.env.MMX_CONFIG_DIR;return S$(Sr(),Rr)}function et(){return S$(lt(),"config.json")}async function R$(){let t=lt();await(await import("fs/promises")).mkdir(t,{recursive:!0,mode:448})}var Rr=".mmx";var Vt=()=>{};var j$={};It(j$,{formatText:()=>Tn,formatTable:()=>q$,formatKeyValue:()=>Et});function Tn(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 q$(t);return t.map(String).join(`
|
|
3
|
+
`)}if(typeof t==="object")return Et(t);return String(t)}function Et(t,n=0){let e=" ".repeat(n),i=[];for(let[r,m]of Object.entries(t)){if(m===null||m===void 0)continue;if(Array.isArray(m)){i.push(`${e}${r}:`);for(let $ of m)if(typeof $==="object"&&$!==null)i.push(`${e} - ${Et($,n+4).trimStart()}`);else i.push(`${e} - ${String($)}`)}else if(typeof m==="object")i.push(`${e}${r}:`),i.push(Et(m,n+2));else i.push(`${e}${r}: ${String(m)}`)}return i.join(`
|
|
4
|
+
`)}function q$(t){if(t.length===0)return"(empty)";let n=Object.keys(t[0]),e=n.map(($)=>Math.max($.length,...t.map((p)=>String(p[$]??"").length))),i=n.map(($,p)=>$.toUpperCase().padEnd(e[p])).join(" "),r=e.map(($)=>"-".repeat($)).join(" "),m=t.map(($)=>n.map((p,o)=>String($[p]??"").padEnd(e[o])).join(" "));return[i,r,...m].join(`
|
|
5
|
+
`)}function B$(t){return JSON.stringify(t,null,2)}function A(t){if(t==="json"||t==="text")return t;if(!process.stdout.isTTY)return"json";return"text"}function j(t,n){switch(n){case"json":return B$(t);case"text":return Tn(t)}}function tt(t,n){if(!t.dryRun)return!1;return console.log(j({request:n},A(t.output))),!0}var W=()=>{};import{readFileSync as qr,writeFileSync as jr,renameSync as Br,existsSync as Ar}from"fs";function O(){let t=et();if(!Ar(t))return{};try{return G$(JSON.parse(qr(t,"utf-8")))}catch(n){let e=n;if(e instanceof SyntaxError||e.message.includes("JSON"))process.stderr.write(`Warning: config file is corrupted. Run 'mmx config set' to reset.
|
|
6
|
+
`);return{}}}async function s(t){await R$();let n=et(),e=n+".tmp";jr(e,JSON.stringify(t,null,2)+`
|
|
7
|
+
`,{mode:384}),Br(e,n)}function hn(t){let n=O(),e=t.apiKey||void 0,i=n.api_key,r=t.region||process.env.MINIMAX_REGION||void 0;if(r&&!(r in K))throw new _(`Invalid region "${r}". Valid values: ${Object.keys(K).join(", ")}`,y.USAGE);let m=n.region,$=r||m||"global",p=e||i,o=!r&&(!m||p!==void 0&&p!==n.api_key),w=t.baseUrl||process.env.MINIMAX_BASE_URL||n.base_url||n.oauth?.resource_url||K[$]||K.global,u=A(t.output||process.env.MINIMAX_OUTPUT||n.output),M=process.env.MINIMAX_TIMEOUT?Number(process.env.MINIMAX_TIMEOUT):void 0,c=M!==void 0&&Number.isFinite(M)&&M>0?M:void 0,v=t.timeout??c??n.timeout??300;return{apiKey:e,fileApiKey:i,fileRegion:n.region,configPath:et(),region:$,baseUrl:w,output:u,timeout:v,defaultTextModel:n.default_text_model,defaultSpeechModel:n.default_speech_model,defaultVideoModel:n.default_video_model,defaultMusicModel:n.default_music_model,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:o}}var nt=b(()=>{g();Vt();W();k();h()});function H(t){if(t?.nonInteractive===!0)return!1;if(process.env.CI)return!1;return process.stdout.isTTY===!0&&process.stdin.isTTY===!0}var Xn=M$((G1,A$)=>{var kn={to(t,n){if(!n)return`\x1B[${t+1}G`;return`\x1B[${n+1};${t+1}H`},move(t,n){let e="";if(t<0)e+=`\x1B[${-t}D`;else if(t>0)e+=`\x1B[${t}C`;if(n<0)e+=`\x1B[${-n}A`;else if(n>0)e+=`\x1B[${n}B`;return e},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"},Jr={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},Tr={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 n="";for(let e=0;e<t;e++)n+=this.line+(e<t-1?kn.up():"");if(t)n+=kn.left;return n}};A$.exports={cursor:kn,scroll:Jr,erase:Tr,beep:"\x07"}});var Zn=M$((S1,Yn)=>{var Ct=process||{},J$=Ct.argv||[],Lt=Ct.env||{},hr=!(!!Lt.NO_COLOR||J$.includes("--no-color"))&&(!!Lt.FORCE_COLOR||J$.includes("--color")||Ct.platform==="win32"||(Ct.stdout||{}).isTTY&&Lt.TERM!=="dumb"||!!Lt.CI),kr=(t,n,e=t)=>(i)=>{let r=""+i,m=r.indexOf(n,t.length);return~m?t+Xr(r,n,e,m)+n:t+r+n},Xr=(t,n,e,i)=>{let r="",m=0;do r+=t.substring(m,i)+e,m=i+n.length,i=t.indexOf(n,m);while(~i);return r+t.substring(m)},T$=(t=hr)=>{let n=t?kr:()=>String;return{isColorSupported:t,reset:n("\x1B[0m","\x1B[0m"),bold:n("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:n("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:n("\x1B[3m","\x1B[23m"),underline:n("\x1B[4m","\x1B[24m"),inverse:n("\x1B[7m","\x1B[27m"),hidden:n("\x1B[8m","\x1B[28m"),strikethrough:n("\x1B[9m","\x1B[29m"),black:n("\x1B[30m","\x1B[39m"),red:n("\x1B[31m","\x1B[39m"),green:n("\x1B[32m","\x1B[39m"),yellow:n("\x1B[33m","\x1B[39m"),blue:n("\x1B[34m","\x1B[39m"),magenta:n("\x1B[35m","\x1B[39m"),cyan:n("\x1B[36m","\x1B[39m"),white:n("\x1B[37m","\x1B[39m"),gray:n("\x1B[90m","\x1B[39m"),bgBlack:n("\x1B[40m","\x1B[49m"),bgRed:n("\x1B[41m","\x1B[49m"),bgGreen:n("\x1B[42m","\x1B[49m"),bgYellow:n("\x1B[43m","\x1B[49m"),bgBlue:n("\x1B[44m","\x1B[49m"),bgMagenta:n("\x1B[45m","\x1B[49m"),bgCyan:n("\x1B[46m","\x1B[49m"),bgWhite:n("\x1B[47m","\x1B[49m"),blackBright:n("\x1B[90m","\x1B[39m"),redBright:n("\x1B[91m","\x1B[39m"),greenBright:n("\x1B[92m","\x1B[39m"),yellowBright:n("\x1B[93m","\x1B[39m"),blueBright:n("\x1B[94m","\x1B[39m"),magentaBright:n("\x1B[95m","\x1B[39m"),cyanBright:n("\x1B[96m","\x1B[39m"),whiteBright:n("\x1B[97m","\x1B[39m"),bgBlackBright:n("\x1B[100m","\x1B[49m"),bgRedBright:n("\x1B[101m","\x1B[49m"),bgGreenBright:n("\x1B[102m","\x1B[49m"),bgYellowBright:n("\x1B[103m","\x1B[49m"),bgBlueBright:n("\x1B[104m","\x1B[49m"),bgMagentaBright:n("\x1B[105m","\x1B[49m"),bgCyanBright:n("\x1B[106m","\x1B[49m"),bgWhiteBright:n("\x1B[107m","\x1B[49m")}};Yn.exports=T$();Yn.exports.createColors=T$});import{stdin as H$,stdout as I$}from"node:process";import*as it from"node:readline";import h$ from"node:readline";import{WriteStream as Yr}from"node:tty";function Zr({onlyFirst:t=!1}={}){let n=["[\\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(n,t?void 0:"g")}function P$(t){if(typeof t!="string")throw TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(Qr,"")}function s$(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Nt(t,n={}){if(typeof t!="string"||t.length===0||(n={ambiguousIsNarrow:!0,...n},t=P$(t),t.length===0))return 0;t=t.replace(Wr()," ");let e=n.ambiguousIsNarrow?1:2,i=0;for(let r of t){let m=r.codePointAt(0);if(m<=31||m>=127&&m<=159||m>=768&&m<=879)continue;switch(Nr.eastAsianWidth(r)){case"F":case"W":i+=2;break;case"A":i+=e;break;default:i+=1}}return i}function Kr(){let t=new Map;for(let[n,e]of Object.entries(z)){for(let[i,r]of Object.entries(e))z[i]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},e[i]=z[i],t.set(r[0],r[1]);Object.defineProperty(z,n,{value:e,enumerable:!1})}return Object.defineProperty(z,"codes",{value:t,enumerable:!1}),z.color.close="\x1B[39m",z.bgColor.close="\x1B[49m",z.color.ansi=k$(),z.color.ansi256=X$(),z.color.ansi16m=Y$(),z.bgColor.ansi=k$(Qn),z.bgColor.ansi256=X$(Qn),z.bgColor.ansi16m=Y$(Qn),Object.defineProperties(z,{rgbToAnsi256:{value:(n,e,i)=>n===e&&e===i?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(e/255*5)+Math.round(i/255*5),enumerable:!1},hexToRgb:{value:(n)=>{let e=/[a-f\d]{6}|[a-f\d]{3}/i.exec(n.toString(16));if(!e)return[0,0,0];let[i]=e;i.length===3&&(i=[...i].map((m)=>m+m).join(""));let r=Number.parseInt(i,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:(n)=>z.rgbToAnsi256(...z.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value:(n)=>{if(n<8)return 30+n;if(n<16)return 90+(n-8);let e,i,r;if(n>=232)e=((n-232)*10+8)/255,i=e,r=e;else{n-=16;let p=n%36;e=Math.floor(n/36)/5,i=Math.floor(p/6)/5,r=p%6/5}let m=Math.max(e,i,r)*2;if(m===0)return 30;let $=30+(Math.round(r)<<2|Math.round(i)<<1|Math.round(e));return m===2&&($+=60),$},enumerable:!1},rgbToAnsi:{value:(n,e,i)=>z.ansi256ToAnsi(z.rgbToAnsi256(n,e,i)),enumerable:!1},hexToAnsi:{value:(n)=>z.ansi256ToAnsi(z.hexToAnsi256(n)),enumerable:!1}}),z}function V$(t,n,e){return String(t).normalize().replace(/\r\n/g,`
|
|
3
8
|
`).split(`
|
|
4
|
-
`).map((
|
|
5
|
-
`)}function
|
|
6
|
-
`),
|
|
7
|
-
`),
|
|
8
|
-
`),
|
|
9
|
-
`).length-1;this.output.write(
|
|
10
|
-
`);this.output.write(
|
|
11
|
-
`).slice(
|
|
12
|
-
`)),this._prevFrame=t;return}this.output.write(X.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}function Oe({input:t=je,output:n=Te,overwrite:i=!0,hideCursor:r=!0}={}){let o=L.createInterface({input:t,output:n,prompt:"",tabSize:1});L.emitKeypressEvents(t,o),t.isTTY&&t.setRawMode(!0);let m=(e,{name:$})=>{if(String(e)==="\x03"){r&&n.write(X.cursor.show),process.exit(0);return}if(!i)return;L.moveCursor(n,$==="return"?0:-1,$==="return"?-1:0,()=>{L.clearLine(n,1,()=>{t.once("keypress",m)})})};return r&&n.write(X.cursor.hide),t.once("keypress",m),()=>{t.off("keypress",m),r&&n.write(X.cursor.show),t.isTTY&&!eo&&t.setRawMode(!1),o.terminal=!1,o.close()}}var X,tt,Tr,Be,Gr,lr,Br=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},qr,cn=10,xe=(t=0)=>(n)=>`\x1B[${n+t}m`,ye=(t=0)=>(n)=>`\x1B[${38+t};5;${n}m`,_e=(t=0)=>(n,i,r)=>`\x1B[${38+t};2;${n};${i};${r}m`,l,Nr,Yr,Jr,Qt,Or=39,xn="\x07",qe="[",Qr="]",Ne="m",yn,we=(t)=>`${Qt.values().next().value}${qe}${t}${Ne}`,he=(t)=>`${Qt.values().next().value}${yn}${t}${xn}`,Zr=(t)=>t.split(" ").map((n)=>ht(n)),sn=(t,n,i)=>{let r=[...n],o=!1,m=!1,e=ht(Ge(t[t.length-1]));for(let[$,c]of r.entries()){let x=ht(c);if(e+x<=i?t[t.length-1]+=c:(t.push(c),e=0),Qt.has(c)&&(o=!0,m=r.slice($+1).join("").startsWith(yn)),o){m?c===xn&&(o=!1,m=!1):c===Ne&&(o=!1);continue}e+=x,e===i&&$<r.length-1&&(t.push(""),e=0)}!e&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},Vr=(t)=>{let n=t.split(" "),i=n.length;for(;i>0&&!(ht(n[i-1])>0);)i--;return i===n.length?t:n.slice(0,i).join(" ")+n.slice(i).join("")},zr=(t,n,i={})=>{if(i.trim!==!1&&t.trim()==="")return"";let r="",o,m,e=Zr(t),$=[""];for(let[x,y]of t.split(" ").entries()){i.trim!==!1&&($[$.length-1]=$[$.length-1].trimStart());let _=ht($[$.length-1]);if(x!==0&&(_>=n&&(i.wordWrap===!1||i.trim===!1)&&($.push(""),_=0),(_>0||i.trim===!1)&&($[$.length-1]+=" ",_++)),i.hard&&e[x]>n){let w=n-_,h=1+Math.floor((e[x]-w-1)/n);Math.floor((e[x]-1)/n)<h&&$.push(""),sn($,y,n);continue}if(_+e[x]>n&&_>0&&e[x]>0){if(i.wordWrap===!1&&_<n){sn($,y,n);continue}$.push("")}if(_+e[x]>n&&i.wordWrap===!1){sn($,y,n);continue}$[$.length-1]+=y}i.trim!==!1&&($=$.map((x)=>Vr(x)));let c=[...$.join(`
|
|
13
|
-
`)];for(let[
|
|
14
|
-
`?(m&&(
|
|
15
|
-
`&&(o&&_&&(r+=we(o)),m&&(r+=he(m)))}return r},Wr,dr=(t,n,i)=>(n in t)?Wr(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,V=(t,n,i)=>(dr(t,typeof n!="symbol"?n+"":n,i),i),Ye,Se,ar,_n,Ur,Hr=(t,n,i)=>(n in t)?Ur(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,Me=(t,n,i)=>(Hr(t,typeof n!="symbol"?n+"":n,i),i),wn,Ir,Pr=(t,n,i)=>(n in t)?Ir(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,ve=(t,n,i)=>(Pr(t,typeof n!="symbol"?n+"":n,i),i),Xe,Cr,Lr=(t,n,i)=>(n in t)?Cr(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,ke=(t,n,i)=>(Lr(t,typeof n!="symbol"?n+"":n,i),i),hn,Er,fr=(t,n,i)=>(n in t)?Er(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,Ae=(t,n,i)=>(fr(t,typeof n!="symbol"?n+"":n,i),i),Je,Fr,gr=(t,n,i)=>(n in t)?Fr(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,Re=(t,n,i)=>(gr(t,typeof n!="symbol"?n+"":n,i),i),bn,Dr,to=(t,n,i)=>(n in t)?Dr(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,no=(t,n,i)=>(to(t,typeof n!="symbol"?n+"":n,i),i),Sn,eo;var Mn=ft(()=>{X=At($n(),1),tt=At(un(),1);Tr=jr();Be={exports:{}};(function(t){var n={};t.exports=n,n.eastAsianWidth=function(r){var o=r.charCodeAt(0),m=r.length==2?r.charCodeAt(1):0,e=o;return 55296<=o&&o<=56319&&56320<=m&&m<=57343&&(o&=1023,m&=1023,e=o<<10|m,e+=65536),e==12288||65281<=e&&e<=65376||65504<=e&&e<=65510?"F":e==8361||65377<=e&&e<=65470||65474<=e&&e<=65479||65482<=e&&e<=65487||65490<=e&&e<=65495||65498<=e&&e<=65500||65512<=e&&e<=65518?"H":4352<=e&&e<=4447||4515<=e&&e<=4519||4602<=e&&e<=4607||9001<=e&&e<=9002||11904<=e&&e<=11929||11931<=e&&e<=12019||12032<=e&&e<=12245||12272<=e&&e<=12283||12289<=e&&e<=12350||12353<=e&&e<=12438||12441<=e&&e<=12543||12549<=e&&e<=12589||12593<=e&&e<=12686||12688<=e&&e<=12730||12736<=e&&e<=12771||12784<=e&&e<=12830||12832<=e&&e<=12871||12880<=e&&e<=13054||13056<=e&&e<=19903||19968<=e&&e<=42124||42128<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||55216<=e&&e<=55238||55243<=e&&e<=55291||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65106||65108<=e&&e<=65126||65128<=e&&e<=65131||110592<=e&&e<=110593||127488<=e&&e<=127490||127504<=e&&e<=127546||127552<=e&&e<=127560||127568<=e&&e<=127569||131072<=e&&e<=194367||177984<=e&&e<=196605||196608<=e&&e<=262141?"W":32<=e&&e<=126||162<=e&&e<=163||165<=e&&e<=166||e==172||e==175||10214<=e&&e<=10221||10629<=e&&e<=10630?"Na":e==161||e==164||167<=e&&e<=168||e==170||173<=e&&e<=174||176<=e&&e<=180||182<=e&&e<=186||188<=e&&e<=191||e==198||e==208||215<=e&&e<=216||222<=e&&e<=225||e==230||232<=e&&e<=234||236<=e&&e<=237||e==240||242<=e&&e<=243||247<=e&&e<=250||e==252||e==254||e==257||e==273||e==275||e==283||294<=e&&e<=295||e==299||305<=e&&e<=307||e==312||319<=e&&e<=322||e==324||328<=e&&e<=331||e==333||338<=e&&e<=339||358<=e&&e<=359||e==363||e==462||e==464||e==466||e==468||e==470||e==472||e==474||e==476||e==593||e==609||e==708||e==711||713<=e&&e<=715||e==717||e==720||728<=e&&e<=731||e==733||e==735||768<=e&&e<=879||913<=e&&e<=929||931<=e&&e<=937||945<=e&&e<=961||963<=e&&e<=969||e==1025||1040<=e&&e<=1103||e==1105||e==8208||8211<=e&&e<=8214||8216<=e&&e<=8217||8220<=e&&e<=8221||8224<=e&&e<=8226||8228<=e&&e<=8231||e==8240||8242<=e&&e<=8243||e==8245||e==8251||e==8254||e==8308||e==8319||8321<=e&&e<=8324||e==8364||e==8451||e==8453||e==8457||e==8467||e==8470||8481<=e&&e<=8482||e==8486||e==8491||8531<=e&&e<=8532||8539<=e&&e<=8542||8544<=e&&e<=8555||8560<=e&&e<=8569||e==8585||8592<=e&&e<=8601||8632<=e&&e<=8633||e==8658||e==8660||e==8679||e==8704||8706<=e&&e<=8707||8711<=e&&e<=8712||e==8715||e==8719||e==8721||e==8725||e==8730||8733<=e&&e<=8736||e==8739||e==8741||8743<=e&&e<=8748||e==8750||8756<=e&&e<=8759||8764<=e&&e<=8765||e==8776||e==8780||e==8786||8800<=e&&e<=8801||8804<=e&&e<=8807||8810<=e&&e<=8811||8814<=e&&e<=8815||8834<=e&&e<=8835||8838<=e&&e<=8839||e==8853||e==8857||e==8869||e==8895||e==8978||9312<=e&&e<=9449||9451<=e&&e<=9547||9552<=e&&e<=9587||9600<=e&&e<=9615||9618<=e&&e<=9621||9632<=e&&e<=9633||9635<=e&&e<=9641||9650<=e&&e<=9651||9654<=e&&e<=9655||9660<=e&&e<=9661||9664<=e&&e<=9665||9670<=e&&e<=9672||e==9675||9678<=e&&e<=9681||9698<=e&&e<=9701||e==9711||9733<=e&&e<=9734||e==9737||9742<=e&&e<=9743||9748<=e&&e<=9749||e==9756||e==9758||e==9792||e==9794||9824<=e&&e<=9825||9827<=e&&e<=9829||9831<=e&&e<=9834||9836<=e&&e<=9837||e==9839||9886<=e&&e<=9887||9918<=e&&e<=9919||9924<=e&&e<=9933||9935<=e&&e<=9953||e==9955||9960<=e&&e<=9983||e==10045||e==10071||10102<=e&&e<=10111||11093<=e&&e<=11097||12872<=e&&e<=12879||57344<=e&&e<=63743||65024<=e&&e<=65039||e==65533||127232<=e&&e<=127242||127248<=e&&e<=127277||127280<=e&&e<=127337||127344<=e&&e<=127386||917760<=e&&e<=917999||983040<=e&&e<=1048573||1048576<=e&&e<=1114109?"A":"N"},n.characterLength=function(r){var o=this.eastAsianWidth(r);return o=="F"||o=="W"||o=="A"?2:1};function i(r){return r.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}n.length=function(r){for(var o=i(r),m=0,e=0;e<o.length;e++)m=m+this.characterLength(o[e]);return m},n.slice=function(r,o,m){textLen=n.length(r),o=o||0,m=m||1,o<0&&(o=textLen+o),m<0&&(m=textLen+m);for(var e="",$=0,c=i(r),x=0;x<c.length;x++){var y=c[x],_=n.length(y);if($>=o-(_==2?1:0))if($+_<=m)e+=y;else break;$+=_}return e}})(Be);Gr=Be.exports,lr=le(Gr),qr=le(Br);l={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(l.modifier);Nr=Object.keys(l.color),Yr=Object.keys(l.bgColor);[...Nr,...Yr];Jr=Xr(),Qt=new Set(["\x1B",""]),yn=`${Qr}8;;`;Wr=Object.defineProperty;Ye=Symbol("clack:cancel");Se=new Map([["k","up"],["j","down"],["h","left"],["l","right"]]),ar=new Set(["up","down","left","right","space","enter"]);_n=class _n extends E{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",(n)=>{this.output.write(X.cursor.move(0,-1)),this.value=n,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};Ur=Object.defineProperty;wn=class wn extends E{constructor(t){super(t,!1),Me(this,"options"),Me(this,"cursor",0);let{options:n}=t;this.options=Object.entries(n).flatMap(([i,r])=>[{value:i,group:!0,label:i},...r.map((o)=>({...o,group:i}))]),this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:i})=>i===t.cursorAt),0),this.on("cursor",(i)=>{switch(i){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}getGroupItems(t){return this.options.filter((n)=>n.group===t)}isGroupSelected(t){return this.getGroupItems(t).every((n)=>this.value.includes(n.value))}toggleValue(){let t=this.options[this.cursor];if(t.group===!0){let n=t.value,i=this.getGroupItems(n);this.isGroupSelected(n)?this.value=this.value.filter((r)=>i.findIndex((o)=>o.value===r)===-1):this.value=[...this.value,...i.map((r)=>r.value)],this.value=Array.from(new Set(this.value))}else{let n=this.value.includes(t.value);this.value=n?this.value.filter((i)=>i!==t.value):[...this.value,t.value]}}};Ir=Object.defineProperty,Xe=class extends E{constructor(t){super(t,!1),ve(this,"options"),ve(this,"cursor",0),this.options=t.options,this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:n})=>n===t.cursorAt),0),this.on("key",(n)=>{n==="a"&&this.toggleAll()}),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}})}get _value(){return this.options[this.cursor].value}toggleAll(){let t=this.value.length===this.options.length;this.value=t?[]:this.options.map((n)=>n.value)}toggleValue(){let t=this.value.includes(this._value);this.value=t?this.value.filter((n)=>n!==this._value):[...this.value,this._value]}},Cr=Object.defineProperty;hn=class hn extends E{constructor({mask:t,...n}){super(n),ke(this,"valueWithCursor",""),ke(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}${tt.default.inverse(tt.default.hidden("_"))}`;else{let i=this.masked.slice(0,this.cursor),r=this.masked.slice(this.cursor);this.valueWithCursor=`${i}${tt.default.inverse(r[0])}${r.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}};Er=Object.defineProperty,Je=class extends E{constructor(t){super(t,!1),Ae(this,"options"),Ae(this,"cursor",0),this.options=t.options,this.cursor=this.options.findIndex(({value:n})=>n===t.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),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}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},Fr=Object.defineProperty;bn=class bn extends E{constructor(t){super(t,!1),Re(this,"options"),Re(this,"cursor",0),this.options=t.options;let n=this.options.map(({value:[i]})=>i?.toLowerCase());this.cursor=Math.max(n.indexOf(t.initialValue),0),this.on("key",(i)=>{if(!n.includes(i))return;let r=this.options.find(({value:[o]})=>o?.toLowerCase()===i);r&&(this.value=r.value,this.state="submit",this.emit("submit"))})}};Dr=Object.defineProperty;Sn=class Sn extends E{constructor(t){super(t),no(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}${tt.default.inverse(tt.default.hidden("_"))}`;else{let n=this.value.slice(0,this.cursor),i=this.value.slice(this.cursor);this.valueWithCursor=`${n}${tt.default.inverse(i[0])}${i.slice(1)}`}})}get cursor(){return this._cursor}};eo=globalThis.process.platform.startsWith("win")});var zt={};On(zt,{text:()=>_o,spinner:()=>To,selectKey:()=>So,select:()=>bo,password:()=>wo,outro:()=>jo,note:()=>ko,multiselect:()=>Mo,log:()=>nt,isCancel:()=>Zt,intro:()=>Ro,groupMultiselect:()=>vo,group:()=>lo,confirm:()=>ho,cancel:()=>Ao});import d from"node:process";function io(){return d.platform!=="win32"?d.env.TERM!=="linux":Boolean(d.env.CI)||Boolean(d.env.WT_SESSION)||Boolean(d.env.TERMINUS_SUBLIME)||d.env.ConEmuTask==="{cmd::Cmder}"||d.env.TERM_PROGRAM==="Terminus-Sublime"||d.env.TERM_PROGRAM==="vscode"||d.env.TERM==="xterm-256color"||d.env.TERM==="alacritty"||d.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function Go(){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,"g")}var p,ut,kn,q=(t,n)=>kn?t:n,ro,Ze,Ve,Vt,oo,b,O,An,Rn,jn,bt,ze,mo,Qe,$o,po,uo,co,so,xo,yo,et=(t)=>{switch(t){case"initial":case"active":return p.default.cyan(ro);case"cancel":return p.default.red(Ze);case"error":return p.default.yellow(Ve);case"submit":return p.default.green(Vt)}},_o=(t)=>new Sn({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){let n=`${p.default.gray(b)}
|
|
16
|
-
${
|
|
17
|
-
`,
|
|
18
|
-
${
|
|
19
|
-
${
|
|
20
|
-
`;case"submit":return`${n}${
|
|
21
|
-
`+
|
|
22
|
-
${
|
|
23
|
-
`}}}).prompt(),
|
|
24
|
-
${
|
|
25
|
-
`,
|
|
26
|
-
${
|
|
27
|
-
${
|
|
28
|
-
`;case"submit":return`${n}${
|
|
29
|
-
`+
|
|
30
|
-
${
|
|
31
|
-
`}}}).prompt(),
|
|
32
|
-
${
|
|
33
|
-
`,
|
|
34
|
-
${
|
|
35
|
-
${
|
|
36
|
-
`}}}).prompt()},
|
|
37
|
-
${
|
|
38
|
-
`;switch(this.state){case"submit":return`${
|
|
39
|
-
${
|
|
40
|
-
${
|
|
41
|
-
${
|
|
42
|
-
`}}}}).prompt()},
|
|
43
|
-
${
|
|
44
|
-
`;switch(this.state){case"submit":return`${
|
|
45
|
-
${
|
|
46
|
-
${
|
|
47
|
-
${
|
|
48
|
-
`}}}).prompt()},
|
|
49
|
-
${
|
|
50
|
-
${
|
|
51
|
-
`;switch(this.state){case"submit":return`${
|
|
52
|
-
${
|
|
53
|
-
`).map((
|
|
54
|
-
`);return
|
|
55
|
-
${
|
|
56
|
-
`+
|
|
57
|
-
`}default:return`${
|
|
58
|
-
${
|
|
59
|
-
${
|
|
60
|
-
`}}}).prompt()},
|
|
61
|
-
${
|
|
62
|
-
${
|
|
63
|
-
`;switch(this.state){case"submit":return`${
|
|
64
|
-
${
|
|
65
|
-
`).map((
|
|
66
|
-
`);return`${
|
|
67
|
-
${
|
|
68
|
-
${
|
|
69
|
-
`}default:return`${
|
|
70
|
-
${
|
|
71
|
-
${
|
|
72
|
-
`}}}).prompt()},
|
|
9
|
+
`).map((i)=>Er(i,n,e)).join(`
|
|
10
|
+
`)}function Fr(t,n){if(t===n)return;let e=t.split(`
|
|
11
|
+
`),i=n.split(`
|
|
12
|
+
`),r=[];for(let m=0;m<Math.max(e.length,i.length);m++)e[m]!==i[m]&&r.push(m);return r}function ft(t){return t===C$}function Ft(t,n){t.isTTY&&t.setRawMode(n)}class rt{constructor({render:t,input:n=H$,output:e=I$,...i},r=!0){C(this,"input"),C(this,"output"),C(this,"rl"),C(this,"opts"),C(this,"_track",!1),C(this,"_render"),C(this,"_cursor",0),C(this,"state","initial"),C(this,"value"),C(this,"error",""),C(this,"subscribers",new Map),C(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=r,this.input=n,this.output=e}prompt(){let t=new Yr(0);return t._write=(n,e,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=h$.createInterface({input:this.input,output:t,tabSize:2,prompt:"",escapeCodeTimeout:50}),h$.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),Ft(this.input,!0),this.output.on("resize",this.render),this.render(),new Promise((n,e)=>{this.once("submit",()=>{this.output.write(P.cursor.show),this.output.off("resize",this.render),Ft(this.input,!1),n(this.value)}),this.once("cancel",()=>{this.output.write(P.cursor.show),this.output.off("resize",this.render),Ft(this.input,!1),n(C$)})})}on(t,n){let e=this.subscribers.get(t)??[];e.push({cb:n}),this.subscribers.set(t,e)}once(t,n){let e=this.subscribers.get(t)??[];e.push({cb:n,once:!0}),this.subscribers.set(t,e)}emit(t,...n){let e=this.subscribers.get(t)??[],i=[];for(let r of e)r.cb(...n),r.once&&i.push(()=>e.splice(e.indexOf(r),1));for(let r of i)r()}unsubscribe(){this.subscribers.clear()}onKeypress(t,n){if(this.state==="error"&&(this.state="active"),n?.name&&!this._track&&N$.has(n.name)&&this.emit("cursor",N$.get(n.name)),n?.name&&dr.has(n.name)&&this.emit("cursor",n.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()),n?.name==="return"){if(this.opts.validate){let e=this.opts.validate(this.value);e&&(this.error=e,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(`
|
|
13
|
+
`),Ft(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let t=V$(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
14
|
+
`).length-1;this.output.write(P.cursor.move(-999,t*-1))}render(){let t=V$(this._render(this)??"",process.stdout.columns,{hard:!0});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(P.cursor.hide);else{let n=Fr(this._prevFrame,t);if(this.restoreCursor(),n&&n?.length===1){let e=n[0];this.output.write(P.cursor.move(0,e)),this.output.write(P.erase.lines(1));let i=t.split(`
|
|
15
|
+
`);this.output.write(i[e]),this._prevFrame=t,this.output.write(P.cursor.move(0,i.length-e-1));return}else if(n&&n?.length>1){let e=n[0];this.output.write(P.cursor.move(0,e)),this.output.write(P.erase.down());let i=t.split(`
|
|
16
|
+
`).slice(e);this.output.write(i.join(`
|
|
17
|
+
`)),this._prevFrame=t;return}this.output.write(P.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}function f$({input:t=H$,output:n=I$,overwrite:e=!0,hideCursor:i=!0}={}){let r=it.createInterface({input:t,output:n,prompt:"",tabSize:1});it.emitKeypressEvents(t,r),t.isTTY&&t.setRawMode(!0);let m=($,{name:p})=>{if(String($)==="\x03"){i&&n.write(P.cursor.show),process.exit(0);return}if(!e)return;it.moveCursor(n,p==="return"?0:-1,p==="return"?-1:0,()=>{it.clearLine(n,1,()=>{t.once("keypress",m)})})};return i&&n.write(P.cursor.hide),t.once("keypress",m),()=>{t.off("keypress",m),i&&n.write(P.cursor.show),t.isTTY&&!om&&t.setRawMode(!1),r.terminal=!1,r.close()}}var P,_t,Qr,l$,Vr,Nr,zr=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},Wr,Qn=10,k$=(t=0)=>(n)=>`\x1B[${n+t}m`,X$=(t=0)=>(n)=>`\x1B[${38+t};5;${n}m`,Y$=(t=0)=>(n,e,i)=>`\x1B[${38+t};2;${n};${e};${i}m`,z,Or,Ur,Hr,dt,Ir=39,Nn="\x07",E$="[",Pr="]",L$="m",zn,Z$=(t)=>`${dt.values().next().value}${E$}${t}${L$}`,Q$=(t)=>`${dt.values().next().value}${zn}${t}${Nn}`,sr=(t)=>t.split(" ").map((n)=>Nt(n)),Vn=(t,n,e)=>{let i=[...n],r=!1,m=!1,$=Nt(P$(t[t.length-1]));for(let[p,o]of i.entries()){let w=Nt(o);if($+w<=e?t[t.length-1]+=o:(t.push(o),$=0),dt.has(o)&&(r=!0,m=i.slice(p+1).join("").startsWith(zn)),r){m?o===Nn&&(r=!1,m=!1):o===L$&&(r=!1);continue}$+=w,$===e&&p<i.length-1&&(t.push(""),$=0)}!$&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},lr=(t)=>{let n=t.split(" "),e=n.length;for(;e>0&&!(Nt(n[e-1])>0);)e--;return e===n.length?t:n.slice(0,e).join(" ")+n.slice(e).join("")},Er=(t,n,e={})=>{if(e.trim!==!1&&t.trim()==="")return"";let i="",r,m,$=sr(t),p=[""];for(let[w,u]of t.split(" ").entries()){e.trim!==!1&&(p[p.length-1]=p[p.length-1].trimStart());let M=Nt(p[p.length-1]);if(w!==0&&(M>=n&&(e.wordWrap===!1||e.trim===!1)&&(p.push(""),M=0),(M>0||e.trim===!1)&&(p[p.length-1]+=" ",M++)),e.hard&&$[w]>n){let c=n-M,v=1+Math.floor(($[w]-c-1)/n);Math.floor(($[w]-1)/n)<v&&p.push(""),Vn(p,u,n);continue}if(M+$[w]>n&&M>0&&$[w]>0){if(e.wordWrap===!1&&M<n){Vn(p,u,n);continue}p.push("")}if(M+$[w]>n&&e.wordWrap===!1){Vn(p,u,n);continue}p[p.length-1]+=u}e.trim!==!1&&(p=p.map((w)=>lr(w)));let o=[...p.join(`
|
|
18
|
+
`)];for(let[w,u]of o.entries()){if(i+=u,dt.has(u)){let{groups:c}=new RegExp(`(?:\\${E$}(?<code>\\d+)m|\\${zn}(?<uri>.*)${Nn})`).exec(o.slice(w).join(""))||{groups:{}};if(c.code!==void 0){let v=Number.parseFloat(c.code);r=v===Ir?void 0:v}else c.uri!==void 0&&(m=c.uri.length===0?void 0:c.uri)}let M=Hr.codes.get(Number(r));o[w+1]===`
|
|
19
|
+
`?(m&&(i+=Q$("")),r&&M&&(i+=Z$(M))):u===`
|
|
20
|
+
`&&(r&&M&&(i+=Z$(r)),m&&(i+=Q$(m)))}return i},Lr,Cr=(t,n,e)=>(n in t)?Lr(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,C=(t,n,e)=>(Cr(t,typeof n!="symbol"?n+"":n,e),e),C$,N$,dr,Wn,fr,ar=(t,n,e)=>(n in t)?fr(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,z$=(t,n,e)=>(ar(t,typeof n!="symbol"?n+"":n,e),e),On,Dr,gr=(t,n,e)=>(n in t)?Dr(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,W$=(t,n,e)=>(gr(t,typeof n!="symbol"?n+"":n,e),e),F$,tm,nm=(t,n,e)=>(n in t)?tm(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,O$=(t,n,e)=>(nm(t,typeof n!="symbol"?n+"":n,e),e),Un,$m,em=(t,n,e)=>(n in t)?$m(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,U$=(t,n,e)=>(em(t,typeof n!="symbol"?n+"":n,e),e),d$,im,rm=(t,n,e)=>(n in t)?im(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,K$=(t,n,e)=>(rm(t,typeof n!="symbol"?n+"":n,e),e),Kn,mm,pm=(t,n,e)=>(n in t)?mm(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,xm=(t,n,e)=>(pm(t,typeof n!="symbol"?n+"":n,e),e),Hn,om;var In=b(()=>{P=Ht(Xn(),1),_t=Ht(Zn(),1);Qr=Zr();l$={exports:{}};(function(t){var n={};t.exports=n,n.eastAsianWidth=function(i){var r=i.charCodeAt(0),m=i.length==2?i.charCodeAt(1):0,$=r;return 55296<=r&&r<=56319&&56320<=m&&m<=57343&&(r&=1023,m&=1023,$=r<<10|m,$+=65536),$==12288||65281<=$&&$<=65376||65504<=$&&$<=65510?"F":$==8361||65377<=$&&$<=65470||65474<=$&&$<=65479||65482<=$&&$<=65487||65490<=$&&$<=65495||65498<=$&&$<=65500||65512<=$&&$<=65518?"H":4352<=$&&$<=4447||4515<=$&&$<=4519||4602<=$&&$<=4607||9001<=$&&$<=9002||11904<=$&&$<=11929||11931<=$&&$<=12019||12032<=$&&$<=12245||12272<=$&&$<=12283||12289<=$&&$<=12350||12353<=$&&$<=12438||12441<=$&&$<=12543||12549<=$&&$<=12589||12593<=$&&$<=12686||12688<=$&&$<=12730||12736<=$&&$<=12771||12784<=$&&$<=12830||12832<=$&&$<=12871||12880<=$&&$<=13054||13056<=$&&$<=19903||19968<=$&&$<=42124||42128<=$&&$<=42182||43360<=$&&$<=43388||44032<=$&&$<=55203||55216<=$&&$<=55238||55243<=$&&$<=55291||63744<=$&&$<=64255||65040<=$&&$<=65049||65072<=$&&$<=65106||65108<=$&&$<=65126||65128<=$&&$<=65131||110592<=$&&$<=110593||127488<=$&&$<=127490||127504<=$&&$<=127546||127552<=$&&$<=127560||127568<=$&&$<=127569||131072<=$&&$<=194367||177984<=$&&$<=196605||196608<=$&&$<=262141?"W":32<=$&&$<=126||162<=$&&$<=163||165<=$&&$<=166||$==172||$==175||10214<=$&&$<=10221||10629<=$&&$<=10630?"Na":$==161||$==164||167<=$&&$<=168||$==170||173<=$&&$<=174||176<=$&&$<=180||182<=$&&$<=186||188<=$&&$<=191||$==198||$==208||215<=$&&$<=216||222<=$&&$<=225||$==230||232<=$&&$<=234||236<=$&&$<=237||$==240||242<=$&&$<=243||247<=$&&$<=250||$==252||$==254||$==257||$==273||$==275||$==283||294<=$&&$<=295||$==299||305<=$&&$<=307||$==312||319<=$&&$<=322||$==324||328<=$&&$<=331||$==333||338<=$&&$<=339||358<=$&&$<=359||$==363||$==462||$==464||$==466||$==468||$==470||$==472||$==474||$==476||$==593||$==609||$==708||$==711||713<=$&&$<=715||$==717||$==720||728<=$&&$<=731||$==733||$==735||768<=$&&$<=879||913<=$&&$<=929||931<=$&&$<=937||945<=$&&$<=961||963<=$&&$<=969||$==1025||1040<=$&&$<=1103||$==1105||$==8208||8211<=$&&$<=8214||8216<=$&&$<=8217||8220<=$&&$<=8221||8224<=$&&$<=8226||8228<=$&&$<=8231||$==8240||8242<=$&&$<=8243||$==8245||$==8251||$==8254||$==8308||$==8319||8321<=$&&$<=8324||$==8364||$==8451||$==8453||$==8457||$==8467||$==8470||8481<=$&&$<=8482||$==8486||$==8491||8531<=$&&$<=8532||8539<=$&&$<=8542||8544<=$&&$<=8555||8560<=$&&$<=8569||$==8585||8592<=$&&$<=8601||8632<=$&&$<=8633||$==8658||$==8660||$==8679||$==8704||8706<=$&&$<=8707||8711<=$&&$<=8712||$==8715||$==8719||$==8721||$==8725||$==8730||8733<=$&&$<=8736||$==8739||$==8741||8743<=$&&$<=8748||$==8750||8756<=$&&$<=8759||8764<=$&&$<=8765||$==8776||$==8780||$==8786||8800<=$&&$<=8801||8804<=$&&$<=8807||8810<=$&&$<=8811||8814<=$&&$<=8815||8834<=$&&$<=8835||8838<=$&&$<=8839||$==8853||$==8857||$==8869||$==8895||$==8978||9312<=$&&$<=9449||9451<=$&&$<=9547||9552<=$&&$<=9587||9600<=$&&$<=9615||9618<=$&&$<=9621||9632<=$&&$<=9633||9635<=$&&$<=9641||9650<=$&&$<=9651||9654<=$&&$<=9655||9660<=$&&$<=9661||9664<=$&&$<=9665||9670<=$&&$<=9672||$==9675||9678<=$&&$<=9681||9698<=$&&$<=9701||$==9711||9733<=$&&$<=9734||$==9737||9742<=$&&$<=9743||9748<=$&&$<=9749||$==9756||$==9758||$==9792||$==9794||9824<=$&&$<=9825||9827<=$&&$<=9829||9831<=$&&$<=9834||9836<=$&&$<=9837||$==9839||9886<=$&&$<=9887||9918<=$&&$<=9919||9924<=$&&$<=9933||9935<=$&&$<=9953||$==9955||9960<=$&&$<=9983||$==10045||$==10071||10102<=$&&$<=10111||11093<=$&&$<=11097||12872<=$&&$<=12879||57344<=$&&$<=63743||65024<=$&&$<=65039||$==65533||127232<=$&&$<=127242||127248<=$&&$<=127277||127280<=$&&$<=127337||127344<=$&&$<=127386||917760<=$&&$<=917999||983040<=$&&$<=1048573||1048576<=$&&$<=1114109?"A":"N"},n.characterLength=function(i){var r=this.eastAsianWidth(i);return r=="F"||r=="W"||r=="A"?2:1};function e(i){return i.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}n.length=function(i){for(var r=e(i),m=0,$=0;$<r.length;$++)m=m+this.characterLength(r[$]);return m},n.slice=function(i,r,m){textLen=n.length(i),r=r||0,m=m||1,r<0&&(r=textLen+r),m<0&&(m=textLen+m);for(var $="",p=0,o=e(i),w=0;w<o.length;w++){var u=o[w],M=n.length(u);if(p>=r-(M==2?1:0))if(p+M<=m)$+=u;else break;p+=M}return $}})(l$);Vr=l$.exports,Nr=s$(Vr),Wr=s$(zr);z={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(z.modifier);Or=Object.keys(z.color),Ur=Object.keys(z.bgColor);[...Or,...Ur];Hr=Kr(),dt=new Set(["\x1B",""]),zn=`${Pr}8;;`;Lr=Object.defineProperty;C$=Symbol("clack:cancel");N$=new Map([["k","up"],["j","down"],["h","left"],["l","right"]]),dr=new Set(["up","down","left","right","space","enter"]);Wn=class Wn extends rt{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",(n)=>{this.output.write(P.cursor.move(0,-1)),this.value=n,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};fr=Object.defineProperty;On=class On extends rt{constructor(t){super(t,!1),z$(this,"options"),z$(this,"cursor",0);let{options:n}=t;this.options=Object.entries(n).flatMap(([e,i])=>[{value:e,group:!0,label:e},...i.map((r)=>({...r,group:e}))]),this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===t.cursorAt),0),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}})}getGroupItems(t){return this.options.filter((n)=>n.group===t)}isGroupSelected(t){return this.getGroupItems(t).every((n)=>this.value.includes(n.value))}toggleValue(){let t=this.options[this.cursor];if(t.group===!0){let n=t.value,e=this.getGroupItems(n);this.isGroupSelected(n)?this.value=this.value.filter((i)=>e.findIndex((r)=>r.value===i)===-1):this.value=[...this.value,...e.map((i)=>i.value)],this.value=Array.from(new Set(this.value))}else{let n=this.value.includes(t.value);this.value=n?this.value.filter((e)=>e!==t.value):[...this.value,t.value]}}};Dr=Object.defineProperty,F$=class extends rt{constructor(t){super(t,!1),W$(this,"options"),W$(this,"cursor",0),this.options=t.options,this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:n})=>n===t.cursorAt),0),this.on("key",(n)=>{n==="a"&&this.toggleAll()}),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}})}get _value(){return this.options[this.cursor].value}toggleAll(){let t=this.value.length===this.options.length;this.value=t?[]:this.options.map((n)=>n.value)}toggleValue(){let t=this.value.includes(this._value);this.value=t?this.value.filter((n)=>n!==this._value):[...this.value,this._value]}},tm=Object.defineProperty;Un=class Un extends rt{constructor({mask:t,...n}){super(n),O$(this,"valueWithCursor",""),O$(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}${_t.default.inverse(_t.default.hidden("_"))}`;else{let e=this.masked.slice(0,this.cursor),i=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${_t.default.inverse(i[0])}${i.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}};$m=Object.defineProperty,d$=class extends rt{constructor(t){super(t,!1),U$(this,"options"),U$(this,"cursor",0),this.options=t.options,this.cursor=this.options.findIndex(({value:n})=>n===t.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),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}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},im=Object.defineProperty;Kn=class Kn extends rt{constructor(t){super(t,!1),K$(this,"options"),K$(this,"cursor",0),this.options=t.options;let n=this.options.map(({value:[e]})=>e?.toLowerCase());this.cursor=Math.max(n.indexOf(t.initialValue),0),this.on("key",(e)=>{if(!n.includes(e))return;let i=this.options.find(({value:[r]})=>r?.toLowerCase()===e);i&&(this.value=i.value,this.state="submit",this.emit("submit"))})}};mm=Object.defineProperty;Hn=class Hn extends rt{constructor(t){super(t),xm(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}${_t.default.inverse(_t.default.hidden("_"))}`;else{let n=this.value.slice(0,this.cursor),e=this.value.slice(this.cursor);this.valueWithCursor=`${n}${_t.default.inverse(e[0])}${e.slice(1)}`}})}get cursor(){return this._cursor}};om=globalThis.process.platform.startsWith("win")});var Mt={};It(Mt,{text:()=>qm,spinner:()=>Qm,selectKey:()=>Jm,select:()=>Am,password:()=>jm,outro:()=>Zm,note:()=>km,multiselect:()=>Tm,log:()=>wt,isCancel:()=>ft,intro:()=>Ym,groupMultiselect:()=>hm,group:()=>Nm,confirm:()=>Bm,cancel:()=>Xm});import d from"node:process";function ym(){return d.platform!=="win32"?d.env.TERM!=="linux":Boolean(d.env.CI)||Boolean(d.env.WT_SESSION)||Boolean(d.env.TERMINUS_SUBLIME)||d.env.ConEmuTask==="{cmd::Cmder}"||d.env.TERM_PROGRAM==="Terminus-Sublime"||d.env.TERM_PROGRAM==="vscode"||d.env.TERM==="xterm-256color"||d.env.TERM==="alacritty"||d.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function Vm(){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 x,Bt,sn,U=(t,n)=>sn?t:n,_m,D$,g$,at,wm,G,l,ln,En,Ln,zt,te,um,a$,Mm,cm,vm,bm,Gm,Sm,Rm,ut=(t)=>{switch(t){case"initial":case"active":return x.default.cyan(_m);case"cancel":return x.default.red(D$);case"error":return x.default.yellow(g$);case"submit":return x.default.green(at)}},qm=(t)=>new Hn({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){let n=`${x.default.gray(G)}
|
|
21
|
+
${ut(this.state)} ${t.message}
|
|
22
|
+
`,e=t.placeholder?x.default.inverse(t.placeholder[0])+x.default.dim(t.placeholder.slice(1)):x.default.inverse(x.default.hidden("_")),i=this.value?this.valueWithCursor:e;switch(this.state){case"error":return`${n.trim()}
|
|
23
|
+
${x.default.yellow(G)} ${i}
|
|
24
|
+
${x.default.yellow(l)} ${x.default.yellow(this.error)}
|
|
25
|
+
`;case"submit":return`${n}${x.default.gray(G)} ${x.default.dim(this.value||t.placeholder)}`;case"cancel":return`${n}${x.default.gray(G)} ${x.default.strikethrough(x.default.dim(this.value??""))}${this.value?.trim()?`
|
|
26
|
+
`+x.default.gray(G):""}`;default:return`${n}${x.default.cyan(G)} ${i}
|
|
27
|
+
${x.default.cyan(l)}
|
|
28
|
+
`}}}).prompt(),jm=(t)=>new Un({validate:t.validate,mask:t.mask??um,render(){let n=`${x.default.gray(G)}
|
|
29
|
+
${ut(this.state)} ${t.message}
|
|
30
|
+
`,e=this.valueWithCursor,i=this.masked;switch(this.state){case"error":return`${n.trim()}
|
|
31
|
+
${x.default.yellow(G)} ${i}
|
|
32
|
+
${x.default.yellow(l)} ${x.default.yellow(this.error)}
|
|
33
|
+
`;case"submit":return`${n}${x.default.gray(G)} ${x.default.dim(i)}`;case"cancel":return`${n}${x.default.gray(G)} ${x.default.strikethrough(x.default.dim(i??""))}${i?`
|
|
34
|
+
`+x.default.gray(G):""}`;default:return`${n}${x.default.cyan(G)} ${e}
|
|
35
|
+
${x.default.cyan(l)}
|
|
36
|
+
`}}}).prompt(),Bm=(t)=>{let n=t.active??"Yes",e=t.inactive??"No";return new Wn({active:n,inactive:e,initialValue:t.initialValue??!0,render(){let i=`${x.default.gray(G)}
|
|
37
|
+
${ut(this.state)} ${t.message}
|
|
38
|
+
`,r=this.value?n:e;switch(this.state){case"submit":return`${i}${x.default.gray(G)} ${x.default.dim(r)}`;case"cancel":return`${i}${x.default.gray(G)} ${x.default.strikethrough(x.default.dim(r))}
|
|
39
|
+
${x.default.gray(G)}`;default:return`${i}${x.default.cyan(G)} ${this.value?`${x.default.green(ln)} ${n}`:`${x.default.dim(En)} ${x.default.dim(n)}`} ${x.default.dim("/")} ${this.value?`${x.default.dim(En)} ${x.default.dim(e)}`:`${x.default.green(ln)} ${e}`}
|
|
40
|
+
${x.default.cyan(l)}
|
|
41
|
+
`}}}).prompt()},Am=(t)=>{let n=(i,r)=>{let m=i.label??String(i.value);return r==="active"?`${x.default.green(ln)} ${m} ${i.hint?x.default.dim(`(${i.hint})`):""}`:r==="selected"?`${x.default.dim(m)}`:r==="cancelled"?`${x.default.strikethrough(x.default.dim(m))}`:`${x.default.dim(En)} ${x.default.dim(m)}`},e=0;return new d$({options:t.options,initialValue:t.initialValue,render(){let i=`${x.default.gray(G)}
|
|
42
|
+
${ut(this.state)} ${t.message}
|
|
43
|
+
`;switch(this.state){case"submit":return`${i}${x.default.gray(G)} ${n(this.options[this.cursor],"selected")}`;case"cancel":return`${i}${x.default.gray(G)} ${n(this.options[this.cursor],"cancelled")}
|
|
44
|
+
${x.default.gray(G)}`;default:{let r=t.maxItems===void 0?1/0:Math.max(t.maxItems,5);this.cursor>=e+r-3?e=Math.max(Math.min(this.cursor-r+3,this.options.length-r),0):this.cursor<e+2&&(e=Math.max(this.cursor-2,0));let m=r<this.options.length&&e>0,$=r<this.options.length&&e+r<this.options.length;return`${i}${x.default.cyan(G)} ${this.options.slice(e,e+r).map((p,o,w)=>o===0&&m?x.default.dim("..."):o===w.length-1&&$?x.default.dim("..."):n(p,o+e===this.cursor?"active":"inactive")).join(`
|
|
45
|
+
${x.default.cyan(G)} `)}
|
|
46
|
+
${x.default.cyan(l)}
|
|
47
|
+
`}}}}).prompt()},Jm=(t)=>{let n=(e,i="inactive")=>{let r=e.label??String(e.value);return i==="selected"?`${x.default.dim(r)}`:i==="cancelled"?`${x.default.strikethrough(x.default.dim(r))}`:i==="active"?`${x.default.bgCyan(x.default.gray(` ${e.value} `))} ${r} ${e.hint?x.default.dim(`(${e.hint})`):""}`:`${x.default.gray(x.default.bgWhite(x.default.inverse(` ${e.value} `)))} ${r} ${e.hint?x.default.dim(`(${e.hint})`):""}`};return new Kn({options:t.options,initialValue:t.initialValue,render(){let e=`${x.default.gray(G)}
|
|
48
|
+
${ut(this.state)} ${t.message}
|
|
49
|
+
`;switch(this.state){case"submit":return`${e}${x.default.gray(G)} ${n(this.options.find((i)=>i.value===this.value),"selected")}`;case"cancel":return`${e}${x.default.gray(G)} ${n(this.options[0],"cancelled")}
|
|
50
|
+
${x.default.gray(G)}`;default:return`${e}${x.default.cyan(G)} ${this.options.map((i,r)=>n(i,r===this.cursor?"active":"inactive")).join(`
|
|
51
|
+
${x.default.cyan(G)} `)}
|
|
52
|
+
${x.default.cyan(l)}
|
|
53
|
+
`}}}).prompt()},Tm=(t)=>{let n=(e,i)=>{let r=e.label??String(e.value);return i==="active"?`${x.default.cyan(Ln)} ${r} ${e.hint?x.default.dim(`(${e.hint})`):""}`:i==="selected"?`${x.default.green(zt)} ${x.default.dim(r)}`:i==="cancelled"?`${x.default.strikethrough(x.default.dim(r))}`:i==="active-selected"?`${x.default.green(zt)} ${r} ${e.hint?x.default.dim(`(${e.hint})`):""}`:i==="submitted"?`${x.default.dim(r)}`:`${x.default.dim(te)} ${x.default.dim(r)}`};return new F$({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
|
|
54
|
+
${x.default.reset(x.default.dim(`Press ${x.default.gray(x.default.bgWhite(x.default.inverse(" space ")))} to select, ${x.default.gray(x.default.bgWhite(x.default.inverse(" enter ")))} to submit`))}`},render(){let e=`${x.default.gray(G)}
|
|
55
|
+
${ut(this.state)} ${t.message}
|
|
56
|
+
`;switch(this.state){case"submit":return`${e}${x.default.gray(G)} ${this.options.filter(({value:i})=>this.value.includes(i)).map((i)=>n(i,"submitted")).join(x.default.dim(", "))||x.default.dim("none")}`;case"cancel":{let i=this.options.filter(({value:r})=>this.value.includes(r)).map((r)=>n(r,"cancelled")).join(x.default.dim(", "));return`${e}${x.default.gray(G)} ${i.trim()?`${i}
|
|
57
|
+
${x.default.gray(G)}`:""}`}case"error":{let i=this.error.split(`
|
|
58
|
+
`).map((r,m)=>m===0?`${x.default.yellow(l)} ${x.default.yellow(r)}`:` ${r}`).join(`
|
|
59
|
+
`);return e+x.default.yellow(G)+" "+this.options.map((r,m)=>{let $=this.value.includes(r.value),p=m===this.cursor;return p&&$?n(r,"active-selected"):$?n(r,"selected"):n(r,p?"active":"inactive")}).join(`
|
|
60
|
+
${x.default.yellow(G)} `)+`
|
|
61
|
+
`+i+`
|
|
62
|
+
`}default:return`${e}${x.default.cyan(G)} ${this.options.map((i,r)=>{let m=this.value.includes(i.value),$=r===this.cursor;return $&&m?n(i,"active-selected"):m?n(i,"selected"):n(i,$?"active":"inactive")}).join(`
|
|
63
|
+
${x.default.cyan(G)} `)}
|
|
64
|
+
${x.default.cyan(l)}
|
|
65
|
+
`}}}).prompt()},hm=(t)=>{let n=(e,i,r=[])=>{let m=e.label??String(e.value),$=typeof e.group=="string",p=$&&(r[r.indexOf(e)+1]??{group:!0}),o=$&&p.group===!0,w=$?`${o?l:G} `:"";return i==="active"?`${x.default.dim(w)}${x.default.cyan(Ln)} ${m} ${e.hint?x.default.dim(`(${e.hint})`):""}`:i==="group-active"?`${w}${x.default.cyan(Ln)} ${x.default.dim(m)}`:i==="group-active-selected"?`${w}${x.default.green(zt)} ${x.default.dim(m)}`:i==="selected"?`${x.default.dim(w)}${x.default.green(zt)} ${x.default.dim(m)}`:i==="cancelled"?`${x.default.strikethrough(x.default.dim(m))}`:i==="active-selected"?`${x.default.dim(w)}${x.default.green(zt)} ${m} ${e.hint?x.default.dim(`(${e.hint})`):""}`:i==="submitted"?`${x.default.dim(m)}`:`${x.default.dim(w)}${x.default.dim(te)} ${x.default.dim(m)}`};return new On({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
|
|
66
|
+
${x.default.reset(x.default.dim(`Press ${x.default.gray(x.default.bgWhite(x.default.inverse(" space ")))} to select, ${x.default.gray(x.default.bgWhite(x.default.inverse(" enter ")))} to submit`))}`},render(){let e=`${x.default.gray(G)}
|
|
67
|
+
${ut(this.state)} ${t.message}
|
|
68
|
+
`;switch(this.state){case"submit":return`${e}${x.default.gray(G)} ${this.options.filter(({value:i})=>this.value.includes(i)).map((i)=>n(i,"submitted")).join(x.default.dim(", "))}`;case"cancel":{let i=this.options.filter(({value:r})=>this.value.includes(r)).map((r)=>n(r,"cancelled")).join(x.default.dim(", "));return`${e}${x.default.gray(G)} ${i.trim()?`${i}
|
|
69
|
+
${x.default.gray(G)}`:""}`}case"error":{let i=this.error.split(`
|
|
70
|
+
`).map((r,m)=>m===0?`${x.default.yellow(l)} ${x.default.yellow(r)}`:` ${r}`).join(`
|
|
71
|
+
`);return`${e}${x.default.yellow(G)} ${this.options.map((r,m,$)=>{let p=this.value.includes(r.value)||r.group===!0&&this.isGroupSelected(`${r.value}`),o=m===this.cursor;return!o&&typeof r.group=="string"&&this.options[this.cursor].value===r.group?n(r,p?"group-active-selected":"group-active",$):o&&p?n(r,"active-selected",$):p?n(r,"selected",$):n(r,o?"active":"inactive",$)}).join(`
|
|
72
|
+
${x.default.yellow(G)} `)}
|
|
73
|
+
${i}
|
|
74
|
+
`}default:return`${e}${x.default.cyan(G)} ${this.options.map((i,r,m)=>{let $=this.value.includes(i.value)||i.group===!0&&this.isGroupSelected(`${i.value}`),p=r===this.cursor;return!p&&typeof i.group=="string"&&this.options[this.cursor].value===i.group?n(i,$?"group-active-selected":"group-active",m):p&&$?n(i,"active-selected",m):$?n(i,"selected",m):n(i,p?"active":"inactive",m)}).join(`
|
|
75
|
+
${x.default.cyan(G)} `)}
|
|
76
|
+
${x.default.cyan(l)}
|
|
77
|
+
`}}}).prompt()},Pn=(t)=>t.replace(Vm(),""),km=(t="",n="")=>{let e=`
|
|
73
78
|
${t}
|
|
74
79
|
`.split(`
|
|
75
|
-
`),
|
|
76
|
-
`);process.stdout.write(`${
|
|
77
|
-
${
|
|
80
|
+
`),i=Pn(n).length,r=Math.max(e.reduce(($,p)=>(p=Pn(p),p.length>$?p.length:$),0),i)+2,m=e.map(($)=>`${x.default.gray(G)} ${x.default.dim($)}${" ".repeat(r-Pn($).length)}${x.default.gray(G)}`).join(`
|
|
81
|
+
`);process.stdout.write(`${x.default.gray(G)}
|
|
82
|
+
${x.default.green(at)} ${x.default.reset(n)} ${x.default.gray(a$.repeat(Math.max(r-i-1,1))+Mm)}
|
|
78
83
|
${m}
|
|
79
|
-
${
|
|
80
|
-
`)},
|
|
84
|
+
${x.default.gray(cm+a$.repeat(r+2)+vm)}
|
|
85
|
+
`)},Xm=(t="")=>{process.stdout.write(`${x.default.gray(l)} ${x.default.red(t)}
|
|
81
86
|
|
|
82
|
-
`)},
|
|
83
|
-
`)},
|
|
84
|
-
${
|
|
87
|
+
`)},Ym=(t="")=>{process.stdout.write(`${x.default.gray(wm)} ${t}
|
|
88
|
+
`)},Zm=(t="")=>{process.stdout.write(`${x.default.gray(G)}
|
|
89
|
+
${x.default.gray(l)} ${t}
|
|
85
90
|
|
|
86
|
-
`)},
|
|
87
|
-
`);let
|
|
88
|
-
`),
|
|
89
|
-
`);
|
|
91
|
+
`)},wt,Qm=()=>{let t=sn?["◒","◐","◓","◑"]:["•","o","O","0"],n=sn?80:120,e,i,r=!1,m="",$=(u="")=>{r=!0,e=f$(),m=u.replace(/\.+$/,""),process.stdout.write(`${x.default.gray(G)}
|
|
92
|
+
`);let M=0,c=0;i=setInterval(()=>{let v=x.default.magenta(t[M]),S=".".repeat(Math.floor(c)).slice(0,3);process.stdout.write(Bt.cursor.move(-999,0)),process.stdout.write(Bt.erase.down(1)),process.stdout.write(`${v} ${m}${S}`),M=M+1<t.length?M+1:0,c=c<t.length?c+0.125:0},n)},p=(u="",M=0)=>{m=u??m,r=!1,clearInterval(i);let c=M===0?x.default.green(at):M===1?x.default.red(D$):x.default.red(g$);process.stdout.write(Bt.cursor.move(-999,0)),process.stdout.write(Bt.erase.down(1)),process.stdout.write(`${c} ${m}
|
|
93
|
+
`),e()},o=(u="")=>{m=u??m},w=(u)=>{let M=u>1?"Something went wrong":"Canceled";r&&p(M,u)};return process.on("uncaughtExceptionMonitor",()=>w(2)),process.on("unhandledRejection",()=>w(2)),process.on("SIGINT",()=>w(1)),process.on("SIGTERM",()=>w(1)),process.on("exit",w),{start:$,stop:p,message:o}},Nm=async(t,n)=>{let e={},i=Object.keys(t);for(let r of i){let m=t[r],$=await m({results:e})?.catch((p)=>{throw p});if(typeof n?.onCancel=="function"&&ft($)){e[r]="canceled",n.onCancel({results:e});continue}e[r]=$}return e};var ct=b(()=>{In();In();x=Ht(Zn(),1),Bt=Ht(Xn(),1);sn=ym(),_m=U("◆","*"),D$=U("■","x"),g$=U("▲","x"),at=U("◇","o"),wm=U("┌","T"),G=U("│","|"),l=U("└","—"),ln=U("●",">"),En=U("○"," "),Ln=U("◻","[•]"),zt=U("◼","[+]"),te=U("◻","[ ]"),um=U("▪","•"),a$=U("─","-"),Mm=U("╮","+"),cm=U("├","+"),vm=U("╯","+"),bm=U("●","•"),Gm=U("◆","*"),Sm=U("▲","!"),Rm=U("■","x"),wt={message:(t="",{symbol:n=x.default.gray(G)}={})=>{let e=[`${x.default.gray(G)}`];if(t){let[i,...r]=t.split(`
|
|
94
|
+
`);e.push(`${n} ${i}`,...r.map((m)=>`${x.default.gray(G)} ${m}`))}process.stdout.write(`${e.join(`
|
|
90
95
|
`)}
|
|
91
|
-
`)},info:(t)=>{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
`)}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
`),process.stderr.write(`
|
|
96
|
+
`)},info:(t)=>{wt.message(t,{symbol:x.default.blue(bm)})},success:(t)=>{wt.message(t,{symbol:x.default.green(Gm)})},step:(t)=>{wt.message(t,{symbol:x.default.green(at)})},warn:(t)=>{wt.message(t,{symbol:x.default.yellow(Sm)})},warning:(t)=>{wt.warn(t)},error:(t)=>{wt.message(t,{symbol:x.default.red(Rm)})}}});async function f(t){if(!H())return;let{defaultValue:n,message:e}=t,r=await(await Promise.resolve().then(() => (ct(),Mt))).text({message:e,default:n,placeholder:n});if(typeof r==="symbol")return;return r}async function ne(t){if(!H())return;let{message:n}=t,i=await(await Promise.resolve().then(() => (ct(),Mt))).confirm({message:n});if(typeof i==="symbol")return;return i}function vt(t,n){throw new _(`Missing required argument: --${t}
|
|
97
|
+
Hint: In non-interactive (CI / agent) environments all required flags must be provided.
|
|
98
|
+
In an interactive terminal, run without --${t} and the CLI will prompt for it.`,y.USAGE,n)}async function Dt(t){if(t.value)return t.value;if(H({nonInteractive:t.nonInteractive})){let n=await f({message:t.message});if(!n)process.stderr.write(t.cancelMessage+`
|
|
99
|
+
`),process.exit(1);return n}vt(t.flagName,t.usageHint)}var mt=b(()=>{k();h()});function a(t){return t.length>8?`${t.slice(0,4)}...${t.slice(-4)}`:"***"}async function ee(t){let n=Pt[t],{randomBytes:e,createHash:i}=await import("crypto"),r=e(32).toString("base64url"),m=i("sha256").update(r).digest("base64url"),$=e(16).toString("base64url"),p=await fetch(`${n}/oauth2/device/code`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:$e,scope:Wm.join(" "),code_challenge:m,code_challenge_method:"S256",state:$})});if(!p.ok){let M=await p.text().catch(()=>"");throw new _(`Failed to start device-code flow (HTTP ${p.status}).`,y.AUTH,M||`URL: ${n}/oauth2/device/code`)}let o=await p.json();if(o.state!==$)throw new _("OAuth state mismatch.",y.AUTH);Um(o.verification_uri),process.stderr.write(`
|
|
100
|
+
Opened: ${o.verification_uri}
|
|
101
|
+
`),process.stderr.write(`Code: ${o.user_code}
|
|
102
|
+
`),process.stderr.write(`Client: ${zm}
|
|
98
103
|
`),process.stderr.write(`Waiting for authorization...
|
|
99
|
-
`);let
|
|
100
|
-
|
|
101
|
-
|
|
104
|
+
`);let w=o.expired_in,u=o.interval||3000;while(Date.now()<w){await Om(u);let M=await fetch(`${n}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",client_id:$e,user_code:o.user_code,code_verifier:r})});if(!M.ok)throw new _(`Device-code authorization failed (HTTP ${M.status}).`,y.AUTH);let c=await M.json();if(c.status==="pending")continue;if(c.status==="success"&&c.access_token)return{access_token:c.access_token,refresh_token:c.refresh_token??"",expires_at:new Date(c.expired_in??Date.now()).toISOString(),region:t,resource_url:c.resource_url};throw new _(`Device-code authorization failed: ${c.status}`,y.AUTH)}throw new _("Device-code authorization timed out.",y.TIMEOUT)}function Om(t){return new Promise((n)=>setTimeout(n,t))}function Um(t){let{execFile:n,spawn:e}=jt("child_process");if(process.platform==="darwin")n("open",[t]);else if(process.platform==="win32")e("cmd.exe",["/c","start","",t],{shell:!1,detached:!0});else n("xdg-open",[t])}var $e="659cf4c1-615c-45f6-a5f6-4bf15eb476e5",zm="MiniMax CLI",Wm;var ie=b(()=>{g();k();h();Wm=["openid","profile","coding_plan"]});async function L(){return O().oauth??null}async function gt(t){let n=O();n.oauth=t,await s(n)}async function re(){let t=O();if(!("oauth"in t))return;delete t.oauth,await s(t)}var pt=b(()=>{nt()});function At(t){return t.replace(/^https?:\/\//,"")}async function pe(t){if(t.apiKey||t.fileApiKey)return;if(await L())return;let n=process.env.MINIMAX_API_KEY;if(n){if(!H({nonInteractive:t.nonInteractive}))return;if(await ne({message:`Found MINIMAX_API_KEY in environment (${a(n)}). Save to config file?`}))await me(t,n);return}if(!H({nonInteractive:t.nonInteractive}))throw new _("No credentials found.",y.AUTH,`Log in: mmx auth login
|
|
105
|
+
Pass directly: --api-key sk-xxxxx`);let e=await Cn();if(e==="api-key"){let i=await f({message:"Enter your MiniMax API key:"});if(!i)throw new _("API key is required.",y.AUTH);await me(t,i);return}await Fn(e==="oauth-cn"?"cn":"global")}async function Cn(){let{select:t,isCancel:n}=await Promise.resolve().then(() => (ct(),Mt)),e=await t({message:"How would you like to authenticate?",options:Km.map((i)=>({value:i.value,label:i.label}))});if(n(e))throw new _("Authentication cancelled.",y.AUTH);return e}async function xe(){let{select:t,isCancel:n}=await Promise.resolve().then(() => (ct(),Mt)),e=await t({message:"Select an OAuth region:",options:[{value:"global",label:`Global → ${At(K.global)}`},{value:"cn",label:`China → ${At(K.cn)}`}]});if(n(e))throw new _("Authentication cancelled.",y.AUTH);return e}async function Fn(t){let n=await ee(t),e=O();delete e.api_key,e.oauth=n,e.region=t,await s(e),process.stderr.write(`Logged in successfully.
|
|
106
|
+
`),process.stderr.write(`Credentials saved to ~/.mmx/config.json
|
|
107
|
+
`)}async function me(t,n){let e={...O(),api_key:n};await s(e),t.fileApiKey=n,process.stderr.write(`API key saved to ${t.configPath??"~/.mmx/config.json"}
|
|
108
|
+
`)}var Km;var dn=b(()=>{g();nt();mt();k();h();ie();pt();Km=[{value:"oauth-global",label:`MiniMax (OAuth login → ${At(K.global)})`},{value:"oauth-cn",label:`MiniMax (OAuth login → ${At(K.cn)})`},{value:"api-key",label:`API key (${At(K.global)} or ${At(K.cn)})`}]});async function fn(t,n="global"){let e=`${Pt[n]}/oauth2/token`,i=null;for(let r=0;r<=oe;r++){if(r>0)await new Promise((p)=>setTimeout(p,Im*r));let m;try{m=await fetch(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:t,client_id:Hm}),signal:AbortSignal.timeout(Pm)})}catch(p){let o=p instanceof Error&&(p.name==="AbortError"||p.name==="TimeoutError"||p.message.includes("timed out"));i=Error(o?"Token refresh timed out — auth server did not respond within 10 s.":`Token refresh failed: ${p instanceof Error?p.message:String(p)}`);continue}if(!m.ok){if(m.status>=400&&m.status<500)throw new _("OAuth session expired and could not be refreshed.",y.AUTH,"Re-authenticate: mmx auth login");i=Error(`Token refresh failed: HTTP ${m.status}`);continue}let $=await m.json();if($.status!=="success"||!$.access_token)throw new _(`OAuth refresh failed: ${$.status}.`,y.AUTH,"Re-authenticate: mmx auth login");return{access_token:$.access_token,refresh_token:$.refresh_token??t,expires_at:new Date($.expired_in??Date.now()).toISOString(),resource_url:$.resource_url}}throw new _(`Token refresh failed after ${oe+1} attempts: ${i?.message}`,y.AUTH,`Check your network connection.
|
|
109
|
+
Re-authenticate: mmx auth login`)}async function ye(t){let n=new Date(t.expires_at).getTime();if(Date.now()<n-sm)return t.access_token;let e=await fn(t.refresh_token,t.region??"global"),i={access_token:e.access_token,refresh_token:e.refresh_token,expires_at:e.expires_at,region:t.region,resource_url:e.resource_url??t.resource_url,account:t.account};return await gt(i),i.access_token}var Hm="659cf4c1-615c-45f6-a5f6-4bf15eb476e5",oe=2,Im=500,Pm=1e4,sm=300000;var an=b(()=>{g();pt();k();h()});async function tn(t){if(t.apiKey)return{token:t.apiKey,method:"api-key",source:"flag"};let n=await L();if(n)return{token:await ye(n),method:"oauth",source:"config.json"};if(t.fileApiKey)return{token:t.fileApiKey,method:"api-key",source:"config.json"};throw new _("No credentials found.",y.AUTH,`Log in: mmx auth login
|
|
110
|
+
Pass directly: --api-key sk-xxxxx`)}var Dn=b(()=>{pt();an();k();h()});function _e(t){if(!t)return"";if(t.includes("/t2a"))return`
|
|
102
111
|
|
|
103
112
|
Speech models require the Plus plan or above.`;if(t.includes("/image_generation"))return`
|
|
104
113
|
|
|
@@ -106,152 +115,201 @@ image-01 requires the Plus plan or above.`;if(t.includes("/video_generation")||t
|
|
|
106
115
|
|
|
107
116
|
Video models (Hailuo-2.3 / 2.3-Fast) require the Max plan or above.`;if(t.includes("/music_generation"))return`
|
|
108
117
|
|
|
109
|
-
Music-2.6 requires the Max plan or above.`;return""}function
|
|
110
|
-
Re-authenticate: mmx auth login`);if(t===429)return new
|
|
111
|
-
Upgrade plan: ${
|
|
112
|
-
Upgrade plan: ${
|
|
113
|
-
`)}var
|
|
114
|
-
`),process.stderr.write(`> Auth: ${
|
|
115
|
-
`);let
|
|
116
|
-
`);if(!m.ok){let
|
|
117
|
-
${
|
|
118
|
-
`);return}for(let
|
|
119
|
-
`)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
118
|
+
Music-2.6 requires the Max plan or above.`;return""}function we(t){return`${t?.includes("minimaxi.com")?"https://platform.minimaxi.com":"https://platform.minimax.io"}/subscribe/token-plan`}function gn(t,n,e){let i=n.base_resp?.status_msg||n.error?.message||`HTTP ${t}`,r=n.base_resp?.status_code||n.error?.code;if(t===401||t===403)return new _(`API key rejected (HTTP ${t}).`,y.AUTH,`Check status: mmx auth status
|
|
119
|
+
Re-authenticate: mmx auth login`);if(t===429)return new _(`Rate limit or quota exceeded. ${i}`,y.QUOTA,"Check usage: mmx quota show");if(t===408||t===504)return new _(`Request timed out (HTTP ${t}).`,y.TIMEOUT,"Try increasing --timeout or retry later.");if(r===1002||r===1039){let m=n.base_resp?.status_msg||"content sensitivity";return new _(`Input content flagged by sensitivity filter (${m}).`,y.CONTENT_FILTER)}if(r===1028||r===1030){let m=_e(e);return new _(`Quota exhausted. ${i}`,y.QUOTA,`Check usage: mmx quota show${m}
|
|
120
|
+
Upgrade plan: ${we(e)}`)}if(r===2061){let m=_e(e);return new _(`This model is not available on your current Token Plan. ${i}`,y.QUOTA,`Check usage: mmx quota show${m}
|
|
121
|
+
Upgrade plan: ${we(e)}`)}return new _(`API error: ${i} (HTTP ${t})`,y.GENERAL)}var ue=b(()=>{k();h()});import{homedir as Me}from"os";function dm(t){return t.startsWith(Me())?t.replace(Me(),"~"):t}function fm(t){return t.replace(/^https?:\/\//,"")}function ve(t,n,e){if(t.quiet||ce||!process.stderr.isTTY)return;ce=!0;let i=t.configPath?dm(t.configPath):"~/.mmx/config.json",r=fm(t.baseUrl),m=t.apiKey?"(flag)":"(file)",$=a(n),p=e?` ${xt}|${F} ${xt}Model:${F} ${Lm}${e}${F}`:"";process.stderr.write(`${lm}${Em}MINIMAX${F} ${xt}${i}${F} ${xt}|${F} ${xt}URL:${F} ${Cm}${r}${F} ${xt}|${F} ${xt}Key:${F} ${Fm}${$}${F} ${xt}${m}${F}${p}
|
|
122
|
+
`)}var ce=!1,F="\x1B[0m",xt="\x1B[2m",lm="\x1B[1m",Em="\x1B[38;2;43;82;255m",Lm="\x1B[38;2;147;51;234m",Cm="\x1B[38;2;6;184;212m",Fm="\x1B[38;2;236;72;153m";var be=()=>{};var Ge=()=>{};var bt="1.0.14";var nn=b(()=>{Ge()});async function D(t,n){let e=typeof FormData<"u"&&n.body instanceof FormData,i={"User-Agent":`mmx-cli/${bt}`,...n.headers};if(!e&&!i["Content-Type"])i["Content-Type"]="application/json";if(!n.noAuth){let $=await tn(t);if(n.authStyle==="x-api-key")i["x-api-key"]=$.token;else i.Authorization=`Bearer ${$.token}`;if(t.verbose)process.stderr.write(`> ${n.method??"GET"} ${n.url}
|
|
123
|
+
`),process.stderr.write(`> Auth: ${$.token.slice(0,8)}...
|
|
124
|
+
`);let p=n.body&&typeof n.body==="object"&&"model"in n.body?String(n.body.model):void 0;ve(t,$.token,p)}let r=(n.timeout??t.timeout)*1000,m=await fetch(n.url,{method:n.method??"GET",headers:i,body:n.body?e?n.body:JSON.stringify(n.body):void 0,signal:n.stream?void 0:AbortSignal.timeout(r)});if(t.verbose)process.stderr.write(`< ${m.status} ${m.statusText}
|
|
125
|
+
`);if(!m.ok){let $={};try{$=await m.json()}catch{}throw gn(m.status,$,n.url)}return m}async function J(t,n){let e=await D(t,n),i;try{i=await e.json()}catch{let r=e.headers.get("content-type")||"";throw new _(`API returned non-JSON response (${r||"unknown type"}). Server may be experiencing issues.`,y.GENERAL)}if(i.base_resp?.status_code&&i.base_resp.status_code!==0)throw gn(200,{base_resp:i.base_resp},n.url);return i}var I=b(()=>{k();h();Dn();ue();be();nn()});function $n(t){return`${t}/anthropic/v1/messages`}function Se(t){return`${t}/v1/t2a_v2`}function Re(t){return`${t}/v1/get_voice`}function qe(t){return`${t}/v1/image_generation`}function je(t){return`${t}/v1/video_generation`}function en(t,n){return`${t}/v1/query/video_generation?task_id=${n}`}function rn(t,n){return`${t}/v1/files/retrieve?file_id=${n}`}function mn(t){return`${t}/v1/music_generation`}function Be(t){return`${t}/v1/coding_plan/search`}function Ae(t){return`${t}/v1/coding_plan/vlm`}function Gt(t){return`${t.includes("minimaxi.com")?"https://api.minimaxi.com":"https://api.minimax.io"}/v1/token_plan/remains`}function Je(t){return`${t}/v1/files`}function Te(t){return`${t}/v1/files/list`}function he(t){return`${t}/v1/files/delete`}function Ye(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"]}function gm(t,n){if(t<=0)return n;let e=Math.floor(t/3600000),i=Math.floor(t%3600000/60000);return e>0?`${e}h ${i}m`:`${i}m`}function ke(t){return new Date(t).toISOString().slice(0,10)}function tp(t){return t>=11904&&t<=40959||t>=63744&&t<=64255||t>=65072&&t<=65103||t>=65281&&t<=65376||t>=131072&&t<=195103}function ot(t){let n=t.replace(/\x1b\[[0-9;]*m/g,""),e=0;for(let i of n)e+=tp(i.codePointAt(0))?2:1;return e}function Xe(t,n){let e=Math.max(0,Math.min(100,t))/100,i=Math.round(xn*e),r=xn-i,m=`${t}%`.padStart(4);if(!n)return`[${"█".repeat(i)}${".".repeat(r)}] ${m}`;let[$,p]=Ye(t);return`${p}${" ".repeat(i)}\x1B[0m\x1B[48;2;55;65;81m${" ".repeat(r)}\x1B[0m ${$}\x1B[1m${m}\x1B[0m`}function pn(t,n,e,i,r){return r?`\x1B[2m${n}${e.repeat(t)}${i}\x1B[0m`:`+${"-".repeat(t)}+`}function t$(t,n,e,i){let r=Math.max(0,n-2-e);return i?`${"\x1B[2m"}│${"\x1B[0m"} ${t}${" ".repeat(r)} ${"\x1B[2m"}│${"\x1B[0m"}`:`| ${t}${" ".repeat(r)} |`}function Jt(t,n){let e=!n.noColor&&process.stdout.isTTY===!0,i=n.region==="cn"?Dm:am,r=t.length>0?Math.max(...t.map((v)=>v.model_name.length)):16,m=e?xn+5:xn+7,$=Math.max(68,r+2+15+2+m+2),p=t.length>0?`${ke(t[0].weekly_start_time)} — ${ke(t[0].weekly_end_time)}`:"",o=`MINIMAX ${i.dashboard}`,w=`${i.week}: ${p}`,u=Math.max(2,$-2-ot(o)-ot(w)),M=e?`\x1B[1m\x1B[38;2;43;82;255mMINIMAX\x1B[0m \x1B[2m${i.dashboard}\x1B[0m${" ".repeat(u)}\x1B[2m${i.week}:\x1B[0m \x1B[38;2;6;184;212m${p}\x1B[0m`:`${o}${" ".repeat(u)}${w}`,c=ot(o)+u+ot(w);if(console.log(""),console.log(pn($,"╭","─","╮",e)),console.log(t$(M,$,c,e)),t.length===0){console.log(pn($,"╰","─","╯",e)),console.log(`
|
|
126
|
+
${i.noData}
|
|
127
|
+
`);return}for(let v of t){console.log(pn($,"├","─","┤",e));let{current_interval_usage_count:S,current_interval_total_count:R}=v,T=R>0?Math.round(S/R*100):0,B=v.current_weekly_usage_count,Q=v.current_weekly_total_count,X=gm(v.remains_time,i.now),Z=v.model_name.padEnd(r),N=`${S.toLocaleString()} / ${R.toLocaleString()}`,Y=Xe(T,e),Ut=r+2+15+2+m,Zt=e?`\x1B[1m${Z}\x1B[0m ${Ye(T)[0]}${N.padStart(15)}\x1B[0m ${Y}`:`${Z} ${N.padStart(15)} ${Xe(T,!1)}`;console.log(t$(Zt,$,Ut,e));let qt=`└ ${i.weekly} ${B.toLocaleString()} / ${Q.toLocaleString()}`,Kt=`${i.resetsIn} ${X}`,jn=Math.max(2,$-2-2-ot(qt)-ot(Kt)),er=2+ot(qt)+jn+ot(Kt),ir=e?` \x1B[2m${qt}${" ".repeat(jn)}${Kt}\x1B[0m`:` ${qt}${" ".repeat(jn)}${Kt}`;console.log(t$(ir,$,er,e))}console.log(pn($,"╰","─","╯",e)),console.log("")}var am,Dm,xn=16;var on=b(()=>{am={dashboard:"TokenPlan Quota",week:"Week",weekly:"Weekly",resetsIn:"Resets in",noData:"No quota data available.",now:"now"},Dm={dashboard:"TokenPlan 配额面板",week:"周期",weekly:"每周",resetsIn:"重置于",noData:"暂无配额数据",now:"即将"}});function $p(t){return K[t]+np}async function ep(t,n,e){let i=[{Authorization:`Bearer ${n}`},{"x-api-key":n}];for(let r of i)try{let m=await fetch($p(t),{headers:{...r,"Content-Type":"application/json"},signal:AbortSignal.timeout(e)});if(!m.ok)continue;if((await m.json()).base_resp?.status_code===0)return!0}catch{}return!1}async function yn(t){process.stderr.write("Detecting region...");let n=Object.keys(K),i=(await Promise.all(n.map(async(m)=>({region:m,ok:await ep(m,t,5000)})))).find((m)=>m.ok);if(!i)return process.stderr.write(` failed
|
|
128
|
+
`),process.stderr.write(`Warning: API key failed validation against all regions (global, cn).
|
|
129
|
+
This usually means the API key is invalid or the network is blocking requests.
|
|
130
|
+
Falling back to 'global'. Subsequent requests may fail.
|
|
131
|
+
Run 'mmx auth status' to verify your credentials.
|
|
132
|
+
`),"global";let r=i.region;return process.stderr.write(` ${r}
|
|
133
|
+
`),r}async function Ze(t){let n=O();n.region=t,await s(n)}var np="/v1/token_plan/remains";var n$=b(()=>{g();nt()});async function ip(t){try{let n=Gt(t.baseUrl),e=await J(t,{url:n});Jt(e.model_remains||[],t)}catch{}}async function Ne(t){let{registry:n}=await Promise.resolve().then(() => (_n(),Oe));n.printHelp([],process.stderr,t.region),await ip(t)}async function Qe(t,n){await Fn(n);let e=O(),i={...t,region:n,baseUrl:e.oauth?.resource_url||K[n]};await Ne(i)}async function Ve(t,n){if(t.dryRun){console.log("Would validate and save API key.");return}let e=await yn(n),i={...t,region:e,baseUrl:K[e],apiKey:n};try{await J(i,{url:Gt(i.baseUrl)})}catch{throw new _("API key validation failed.",y.AUTH,"Check that your key is valid and belongs to a Token Plan.")}let r=O();delete r.oauth,r.api_key=n,r.region=e,await s(r),process.stderr.write(`API key saved to ${et()}
|
|
134
|
+
`),await Ne(i)}var ze;var We=b(()=>{V();k();h();dn();I();on();n$();Vt();nt();g();ze=q({name:"auth login",description:"Authenticate via OAuth or API key",usage:"mmx auth login [--api-key <key>] [--recommend] [--region=global|cn]",options:[{flag:"--api-key <key>",description:"Skip the menu and save this API key directly"},{flag:"--recommend",description:"Skip the menu, go straight to OAuth (combine with --region= to skip the region picker)"}],examples:["mmx auth login","mmx auth login --api-key sk-cp-xxxxx","mmx auth login --recommend","mmx auth login --recommend --region=global","mmx auth login --recommend --region=cn"],async run(t,n){let e=process.env.MINIMAX_API_KEY;if(e&&!n.apiKey){let m=a(e);if(H({nonInteractive:t.nonInteractive})){let{confirm:$,isCancel:p}=await Promise.resolve().then(() => (ct(),Mt)),o=await $({message:`MINIMAX_API_KEY is set (${m}). Configure persistent credentials anyway?`,initialValue:!1});if(p(o)||!o)process.stdout.write(`Login skipped. Using environment variable.
|
|
126
135
|
`),process.exit(0)}else process.stderr.write(`Warning: MINIMAX_API_KEY is already set in environment.
|
|
127
|
-
`)}if((n.apiKey
|
|
128
|
-
`)
|
|
129
|
-
`),
|
|
130
|
-
`),process.stderr.write(`
|
|
131
|
-
`)
|
|
132
|
-
`);
|
|
133
|
-
|
|
134
|
-
`);
|
|
135
|
-
`)}catch{}if(!
|
|
136
|
-
`)}});async function*dt(t){let n=t.body?.getReader();if(!n)return;let i=new TextDecoder,r="";try{while(!0){let{done:o,value:m}=await n.read();if(o)break;r+=i.decode(m,{stream:!0});let e=r.split(`
|
|
137
|
-
`);r=e.pop()||"";let $={};for(let c of e){if(c===""){if($.data!==void 0)yield{data:$.data,event:$.event,id:$.id};$={};continue}if(c.startsWith(":"))continue;let x=c.indexOf(":");if(x===-1)continue;let y=c.slice(0,x),_=c.slice(x+1).trimStart();switch(y){case"data":$.data=$.data!==void 0?`${$.data}
|
|
138
|
-
${_}`:_;break;case"event":$.event=_;break;case"id":$.id=_;break}}}if(r.trim()&&r.includes("data:")){let o=r.indexOf(":");if(o!==-1)yield{data:r.slice(o+1).trimStart()}}}finally{n.releaseLock()}}import{readFileSync as Gn}from"fs";async function it(t){if(!Q())return;let{defaultValue:n,message:i}=t,o=await(await Promise.resolve().then(() => (Wt(),zt))).text({message:i,default:n,placeholder:n});if(typeof o==="symbol")return;return o}async function He(t){if(!Q())return;let{message:n}=t,r=await(await Promise.resolve().then(() => (Wt(),zt))).confirm({message:n});if(typeof r==="symbol")return;return r}function Tn(t,n){throw new s(`Missing required argument: --${t}
|
|
139
|
-
Hint: In non-interactive (CI / agent) environments all required flags must be provided.
|
|
140
|
-
In an interactive terminal, run without --${t} and the CLI will prompt for it.`,u.USAGE,n)}async function Kt(t){if(t.value)return t.value;if(Q({nonInteractive:t.nonInteractive})){let n=await it({message:t.message});if(!n)process.stderr.write(t.cancelMessage+`
|
|
141
|
-
`),process.exit(1);return n}Tn(t.flagName,t.usageHint)}function Bo(t){let n=[],i;if(t.system)i=t.system;if(t.messagesFile){let r=t.messagesFile,o=r==="-"?Gn("/dev/stdin","utf-8"):Gn(r,"utf-8"),m=JSON.parse(o);for(let e of m)if(e.role==="system")i=typeof e.content==="string"?e.content:"";else n.push(e)}if(!t.message&&t.prompt)t.message=Array.isArray(t.prompt)?t.prompt:[t.prompt];if(t.message){let r=new Set(["system","user","assistant"]),o=t.message;for(let m of o){let e=m.indexOf(":"),$=e!==-1?m.slice(0,e):"";if(r.has($)){let c=m.slice(e+1);if($==="system")i=c;else n.push({role:$,content:c})}else n.push({role:"user",content:m})}}return{system:i,messages:n}}function qo(t){return t.filter((n)=>n.type==="text").map((n)=>n.text).join("")}var Ie=v({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(t,n){let{system:i,messages:r}=Bo(n),o=r;if(o.length===0)if(Q({nonInteractive:t.nonInteractive})){let y=await it({message:"Enter your message:"});if(!y)process.stderr.write(`Chat cancelled.
|
|
142
|
-
`),process.exit(1);o=[{role:"user",content:y}]}else Tn("message","mmx text chat --message <text>");let m=n.model||t.defaultTextModel||"MiniMax-M2.7",e=A(t.output),$=n.stream===!0||n.stream===void 0&&e!=="json"&&process.stdout.isTTY,c={model:m,messages:o,max_tokens:n.maxTokens??4096,stream:$};if(i)c.system=i;if(n.temperature!==void 0)c.temperature=n.temperature;if(n.topP!==void 0)c.top_p=n.topP;if(n.tool){let y=n.tool.map((_)=>{try{return JSON.parse(_)}catch{try{let w=Gn(_,"utf-8");return JSON.parse(w)}catch{throw new s(`Invalid tool definition: "${_}" is neither valid JSON nor a readable file.`,u.USAGE)}}});c.tools=y}if(t.dryRun){console.log(k({request:c},e));return}let x=fn(t.baseUrl);if($){let y=await U(t,{url:x,method:"POST",body:c,stream:!0,authStyle:"x-api-key"}),_=y.headers.get("content-type")||"";if(!_.includes("text/event-stream")&&!_.includes("stream"))throw new s(`Expected SSE stream but got content-type "${_}". Server may be experiencing issues.`,u.GENERAL);let w="",h=!1,S=t.noColor?"":"\x1B[2m",M=t.noColor?"":"\x1B[0m",R=e==="json",B=process.stdout.isTTY&&!R?process.stdout:process.stderr,N=R?void 0:process.stdout;for await(let Y of dt(y)){if(Y.data==="[DONE]")break;try{let G=JSON.parse(Y.data);if(G.type==="content_block_start"){if(G.content_block.type==="thinking")h=!0,B.write(`${S}Thinking:
|
|
143
|
-
`);else if(G.content_block.type==="text"&&h)B.write(`${M}
|
|
144
|
-
|
|
136
|
+
`)}if(n.apiKey){await Ve(t,n.apiKey);return}if(t.dryRun){console.log("Would prompt for auth method (oauth-global, oauth-cn, api-key).");return}if(!H({nonInteractive:t.nonInteractive}))throw new _("--api-key is required in non-interactive mode.",y.USAGE,"mmx auth login --api-key sk-xxxxx");if(n.recommend){let m=n.region||await xe();await Qe(t,m);return}let i=await Cn();if(i==="api-key"){let{text:m,isCancel:$}=await Promise.resolve().then(() => (ct(),Mt)),p=await m({message:"Paste your MiniMax API key:",validate:(o)=>o&&o.length>0?void 0:"API key cannot be empty."});if($(p))throw new _("Authentication cancelled.",y.AUTH);await Ve(t,p);return}let r=n.region||(i==="oauth-cn"?"cn":"global");await Qe(t,r)}})});var Ue;var Ke=b(()=>{V();Dn();pt();W();I();on();Ue=q({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,n){try{let e=await tn(t),i=A(t.output);if(i!=="text"){let m={method:e.method,source:e.source};if(e.method==="oauth"){let $=await L();if($){if(m.token_expires=$.expires_at,$.account)m.account=$.account}}else m.key=a(e.token);console.log(j(m,i));return}console.log("Authentication Status:"),console.log(` Method: ${e.method}`),console.log(` Source: ${e.source}`);let r=e.token;if(console.log(` Key: ${a(r)}`),e.method==="oauth"){let m=await L();if(m){if(m.account)console.log(` Account: ${m.account}`);let $=new Date(m.expires_at),p=Math.round(($.getTime()-Date.now())/60000);console.log(` Expires in: ${p} minutes`)}}process.stderr.write(`Fetching quota snapshot...
|
|
137
|
+
`);try{let m=Gt(t.baseUrl),$=await J(t,{url:m,method:"GET"});Jt($.model_remains||[],t)}catch(m){console.log(` Quota fetch failed: ${m.message}`)}}catch{let e=A(t.output);console.log(j({authenticated:!1,message:"Not authenticated.",hint:`Run: mmx auth login
|
|
138
|
+
Or set $MINIMAX_API_KEY`},e))}}})});var He;var Ie=b(()=>{V();k();h();pt();an();W();He=q({name:"auth refresh",description:"Manually refresh OAuth token",usage:"mmx auth refresh",examples:["mmx auth refresh"],async run(t,n){let e=await L();if(!e)throw new _("Not applicable: not authenticated via OAuth.",y.USAGE,"Run mmx auth login first.");if(t.dryRun){console.log("Would refresh OAuth token.");return}let i=await fn(e.refresh_token,e.region??"global"),r={access_token:i.access_token,refresh_token:i.refresh_token,expires_at:i.expires_at,region:e.region,resource_url:i.resource_url??e.resource_url,account:e.account};await gt(r);let m=A(t.output);if(t.quiet){console.log(r.expires_at);return}console.log(j({status:"Token refreshed",expires:r.expires_at},m))}})});var Pe;var se=b(()=>{V();pt();nt();Pe=q({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,n){let e=await L(),r=!!O().api_key;if(t.dryRun){if(e)console.log("Would clear oauth from ~/.mmx/config.json");if(r)console.log("Would clear api_key from ~/.mmx/config.json");if(!e&&!r)console.log("No credentials to clear.");console.log("No changes made.");return}if(!e&&!r){process.stderr.write(`No credentials to clear.
|
|
139
|
+
`);return}if(e)await re(),process.stderr.write(`Cleared oauth from ~/.mmx/config.json
|
|
140
|
+
`);if(r){let m=O();delete m.api_key,await s(m),process.stderr.write(`Cleared api_key from ~/.mmx/config.json
|
|
141
|
+
`)}}})});async function*Tt(t){let n=t.body?.getReader();if(!n)return;let e=new TextDecoder,i="",r={},m=($)=>{let p=$.endsWith("\r")?$.slice(0,-1):$;if(p===""){let M=r.data!==void 0?{data:r.data,event:r.event,id:r.id}:void 0;return r={},M}if(p.startsWith(":"))return;let o=p.indexOf(":");if(o===-1)return;let w=p.slice(0,o),u=p.slice(o+1).trimStart();switch(w){case"data":r.data=r.data!==void 0?`${r.data}
|
|
142
|
+
${u}`:u;break;case"event":r.event=u;break;case"id":r.id=u;break}return};try{while(!0){let{done:$,value:p}=await n.read();if($)break;i+=e.decode(p,{stream:!0});let o=i.split(`
|
|
143
|
+
`);i=o.pop()||"";for(let w of o){let u=m(w);if(u)yield u}}if(i+=e.decode(),i.length>0){let $=m(i);if($)yield $}if(r.data!==void 0)yield{data:r.data,event:r.event,id:r.id}}finally{n.releaseLock()}}import{readFileSync as $$}from"fs";function Ee(t,n,e){let i=(1-Math.abs(2*e-1))*n,r=i*(1-Math.abs(t/60%2-1)),m=e-i/2,$=0,p=0,o=0;if(t<60)$=i,p=r;else if(t<120)$=r,p=i;else if(t<180)p=i,o=r;else if(t<240)p=r,o=i;else if(t<300)$=r,o=i;else $=i,o=r;return[Math.round(($+m)*255),Math.round((p+m)*255),Math.round((o+m)*255)]}class Le{frame=0;startTime=0;timer=null;out;noColor;constructor(t,n){this.out=t,this.noColor=n}start(){this.frame=0,this.startTime=Date.now(),this.tick(),this.timer=setInterval(()=>this.tick(),80)}stop(){if(this.timer)clearInterval(this.timer),this.timer=null;this.out.write("\r\x1B[0K")}tick(){let t=le[this.frame%le.length],n=Math.floor((Date.now()-this.startTime)/1000),e=n>=60?`Thinking (${Math.floor(n/60)}m ${n%60}s)`:`Thinking (${n}s)`;if(this.frame++,this.noColor)this.out.write(`\r${t} ${e}\x1B[0K`);else{let[i,r,m]=Ee(this.frame*17%360,0.85,0.55),[$,p,o]=Ee((this.frame*17+40)%360,0.85,0.55);this.out.write(`\r\x1B[38;2;${i};${r};${m}m${t}\x1B[0m \x1B[38;2;${$};${p};${o}m${e}\x1B[0m\x1B[0K`)}}}function rp(t){let n=[],e;if(t.system)e=t.system;if(t.messagesFile){let i=t.messagesFile,r=i==="-"?$$("/dev/stdin","utf-8"):$$(i,"utf-8"),m=JSON.parse(r);for(let $ of m)if($.role==="system")e=typeof $.content==="string"?$.content:"";else n.push($)}if(!t.message&&t.prompt)t.message=Array.isArray(t.prompt)?t.prompt:[t.prompt];if(t.message){let i=new Set(["system","user","assistant"]),r=t.message;for(let m of r){let $=m.indexOf(":"),p=$!==-1?m.slice(0,$):"";if(i.has(p)){let o=m.slice($+1);if(p==="system")e=o;else n.push({role:p,content:o})}else n.push({role:"user",content:m})}}return{system:e,messages:n}}function mp(t){return t.filter((n)=>n.type==="text").map((n)=>n.text).join("")}var le,Ce;var Fe=b(()=>{V();I();W();k();h();mt();le=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];Ce=q({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(t,n){let{system:e,messages:i}=rp(n),r=i;if(r.length===0)if(H({nonInteractive:t.nonInteractive})){let u=await f({message:"Enter your message:"});if(!u)process.stderr.write(`Chat cancelled.
|
|
144
|
+
`),process.exit(1);r=[{role:"user",content:u}]}else vt("message","mmx text chat --message <text>");let m=n.model||t.defaultTextModel||"MiniMax-M2.7",$=A(t.output),p=n.stream===!0||n.stream===void 0&&$!=="json"&&process.stdout.isTTY,o={model:m,messages:r,max_tokens:n.maxTokens??4096,stream:p};if(e)o.system=e;if(n.temperature!==void 0)o.temperature=n.temperature;if(n.topP!==void 0)o.top_p=n.topP;if(n.tool){let u=n.tool.map((M)=>{try{return JSON.parse(M)}catch{try{let c=$$(M,"utf-8");return JSON.parse(c)}catch{throw new _(`Invalid tool definition: "${M}" is neither valid JSON nor a readable file.`,y.USAGE)}}});o.tools=u}if(t.dryRun){console.log(j({request:o},$));return}let w=$n(t.baseUrl);if(p){let u=await D(t,{url:w,method:"POST",body:o,stream:!0,authStyle:"x-api-key"}),M=u.headers.get("content-type")||"";if(!M.includes("text/event-stream")&&!M.includes("stream"))throw new _(`Expected SSE stream but got content-type "${M}". Server may be experiencing issues.`,y.GENERAL);let c="",v=!1,S=t.noColor?"":"\x1B[2m",R=t.noColor?"":"\x1B[0m",T=$==="json",Q=process.stdout.isTTY&&!T?process.stderr:process.stderr,X=T?void 0:process.stdout,Z=new Le(Q,t.noColor);for await(let N of Tt(u)){if(N.data==="[DONE]")break;try{let Y=JSON.parse(N.data);if(Y.type==="content_block_start"){if(Y.content_block.type==="thinking")v=!0,Z.start();else if(Y.content_block.type==="text"&&v)Z.stop(),v=!1,Q.write(`${R}
|
|
145
145
|
Response:
|
|
146
|
-
`)
|
|
147
|
-
${S}[warning] Failed to parse stream chunk: ${
|
|
148
|
-
`)}}if(
|
|
149
|
-
`)}else{let
|
|
150
|
-
|
|
151
|
-
${
|
|
152
|
-
|
|
146
|
+
`)}else if(Y.type==="content_block_delta"){if(Y.delta.type==="text_delta")c+=Y.delta.text,X?.write(Y.delta.text)}}catch(Y){process.stderr.write(`
|
|
147
|
+
${S}[warning] Failed to parse stream chunk: ${Y instanceof Error?Y.message:String(Y)}${R}
|
|
148
|
+
`)}}if(v)Z.stop();if($==="json")console.log(j({content:c},$));else X?.write(`
|
|
149
|
+
`)}else{let u=await J(t,{url:w,method:"POST",body:o,authStyle:"x-api-key"}),M=mp(u.content);if(t.quiet||$==="text")console.log(M);else console.log(j(u,$))}}})});import{writeFileSync as pp}from"node:fs";function de(t){return`\x1B[${t}A`}function xp(t){return`\x1B[${t}B`}function e$(t){return`\x1B[${t}G`}function wn(){return"\x1B[2K"}function op(){return"\x1B[0J"}function wp(){process.stdout.write(`
|
|
150
|
+
Available commands:
|
|
151
|
+
`);for(let[t,n]of Object.entries(r$))process.stdout.write(` ${t.padEnd(fe+2)} ${n}
|
|
152
|
+
`);process.stdout.write(`
|
|
153
|
+
`)}class ae{buffer="";cursor=0;history=[];historyIdx=-1;out;promptLen;dim;reset;width;lastTotal=0;resolve=null;constructor(t,n,e,i){this.out=t,this.promptLen=n.length,this.dim=e,this.reset=i,this.width=t.columns||80}readLine(){return new Promise((t)=>{this.buffer="",this.cursor=0,this.lastTotal=0,this.resolve=t,this.render()})}feed(t){let n=t.toString(),e=0;while(e<n.length){let i=n[e];if(i==="\x1B"&&e+1<n.length&&n[e+1]==="["){let r=n.slice(e,e+3);if(r==="\x1B[A"){this.historyUp(),e+=3;continue}if(r==="\x1B[B"){this.historyDown(),e+=3;continue}if(r==="\x1B[C"){if(this.cursor<this.buffer.length)this.cursor++;this.render(),e+=3;continue}if(r==="\x1B[D"){if(this.cursor>0)this.cursor--;this.render(),e+=3;continue}if(r==="\x1B[H"){this.cursor=0,this.render(),e+=3;continue}if(r==="\x1B[F"){this.cursor=this.buffer.length,this.render(),e+=3;continue}if(e+3<n.length&&n.slice(e,e+4)==="\x1B[3~"){if(this.cursor<this.buffer.length)this.buffer=this.buffer.slice(0,this.cursor)+this.buffer.slice(this.cursor+1);this.render(),e+=4;continue}e+=1;continue}if(i==="\r"||i===`
|
|
154
|
+
`){let r=this.buffer;if(r.trim())this.history.push(r),this.historyIdx=-1;let m=this.lastTotal>0?this.lastTotal-1:0;this.out.write(xp(m)+`
|
|
155
|
+
`),this.lastTotal=0;let $=this.resolve;if(this.resolve=null,$)$(r);e++;continue}if(i===""||i==="\b"){if(this.cursor>0)this.buffer=this.buffer.slice(0,this.cursor-1)+this.buffer.slice(this.cursor),this.cursor--;this.render(),e++;continue}if(i==="\x01"){this.cursor=0,this.render(),e++;continue}if(i==="\x05"){this.cursor=this.buffer.length,this.render(),e++;continue}if(i==="\x15"){this.buffer="",this.cursor=0,this.render(),e++;continue}if(i==="\x17"){let r=this.buffer.slice(0,this.cursor),m=this.buffer.slice(this.cursor),$=r.replace(/\S+\s*$/,"");this.cursor=$.length,this.buffer=$+m,this.render(),e++;continue}if(i==="\t"){if(this.buffer.startsWith("/")){let r=i$.filter((m)=>m.startsWith(this.buffer));if(r.length===1)this.buffer=r[0],this.cursor=this.buffer.length,this.render()}e++;continue}if(i.charCodeAt(0)>=32){this.buffer=this.buffer.slice(0,this.cursor)+i+this.buffer.slice(this.cursor),this.cursor++,this.render(),e++;continue}e++}}historyUp(){if(this.history.length===0)return;if(this.historyIdx===-1)this.historyIdx=this.history.length-1;else if(this.historyIdx>0)this.historyIdx--;this.buffer=this.history[this.historyIdx],this.cursor=this.buffer.length,this.render()}historyDown(){if(this.historyIdx===-1)return;if(this.historyIdx<this.history.length-1)this.historyIdx++,this.buffer=this.history[this.historyIdx];else this.historyIdx=-1,this.buffer="";this.cursor=this.buffer.length,this.render()}border(){return this.dim+"─".repeat(this.width)+this.reset}render(){let t=this.buffer.startsWith("/")?i$.filter(($)=>$.startsWith(this.buffer)):[],n=t.length===1&&t[0]===this.buffer,e=t.length>0&&!n,i=e?t.length:0,r=3+i,m="";if(this.lastTotal>0)m+=de(1);if(m+=e$(1)+wn()+this.border()+`
|
|
156
|
+
`,m+=wn()+"> "+this.buffer+`
|
|
157
|
+
`,m+=e$(1)+wn()+this.border()+`
|
|
158
|
+
`,e)for(let $ of t)m+=wn()+` ${this.dim}${$.padEnd(fe+2)} ${r$[$]}${this.reset}
|
|
159
|
+
`;if(r<this.lastTotal)m+=op();m+=de(i+2),m+=e$(this.promptLen+this.cursor+1),this.out.write(m),this.lastTotal=r}}var yp="\x1B[?25l",_p="\x1B[?25h",r$,i$,fe,De;var ge=b(()=>{V();I();k();h();r$={"/exit":"Exit the conversation","/clear":"Clear conversation history (keeps system prompt)","/system":"Show or set the system prompt. Usage: /system [new prompt]","/model":"Show or set the model. Usage: /model [model-id]","/save":"Save conversation to a JSON file. Usage: /save <path>","/help":"Show available slash commands","/history":"Show conversation messages with content preview"},i$=Object.keys(r$),fe=Math.max(...i$.map((t)=>t.length));De=q({name:"text repl",description:"Start an interactive multi-turn chat session",usage:"mmx text repl [flags]",options:[{flag:"--model <model>",description:"Model ID (default: MiniMax-M2.7)"},{flag:"--system <text>",description:"System prompt"},{flag:"--max-tokens <n>",description:"Maximum tokens per response (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"}],examples:["mmx text repl",'mmx text repl --model MiniMax-M2.7-highspeed --system "You are a coding assistant."',"mmx text repl --temperature 0.7 --max-tokens 8192"],async run(t,n){if(!H({nonInteractive:t.nonInteractive}))throw new _("The repl command requires an interactive terminal.",y.USAGE,"mmx text repl");if(!process.stdin.isTTY)throw new _("The repl command requires a TTY.",y.USAGE);let e=t.noColor?"":"\x1B[2m",i=t.noColor?"":"\x1B[0m",r={messages:[],system:n.system,model:n.model||t.defaultTextModel||"MiniMax-M2.7",maxTokens:n.maxTokens??4096,temperature:n.temperature!==void 0?n.temperature:void 0,topP:n.topP!==void 0?n.topP:void 0},m=t.noColor?"":"\x1B[1m";if(process.stdout.write(`
|
|
160
|
+
${m}MiniMax Chat REPL${i}
|
|
161
|
+
`),process.stdout.write(`${e}Model: ${r.model}${i}
|
|
162
|
+
`),r.system)process.stdout.write(`${e}System: ${r.system.slice(0,80)}${r.system.length>80?"...":""}${i}
|
|
163
|
+
`);process.stdout.write(`${e}Type / to see commands, /exit to quit.${i}
|
|
164
|
+
`);let{stdin:$,stdout:p}=process;if(typeof $.setRawMode==="function")$.setRawMode(!0);$.resume(),$.setEncoding("utf8");let o=!1,w=0;async function u(){if(r.messages.length===0){p.write(`${e}No messages to send. Type something first.${i}
|
|
165
|
+
`);return}let R={model:r.model,messages:r.messages,max_tokens:r.maxTokens,stream:!0};if(r.system)R.system=r.system;if(r.temperature!==void 0)R.temperature=r.temperature;if(r.topP!==void 0)R.top_p=r.topP;o=!0;let T=$n(t.baseUrl);try{let B=await D(t,{url:T,method:"POST",body:R,stream:!0,authStyle:"x-api-key"}),Q=B.headers.get("content-type")||"";if(!Q.includes("text/event-stream")&&!Q.includes("stream"))throw new _(`Expected SSE stream but got content-type "${Q}".`,y.GENERAL);let X="",Z=!1;for await(let N of Tt(B)){if(N.data==="[DONE]")break;try{let Y=JSON.parse(N.data);if(Y.type==="content_block_start"){if(Y.content_block.type==="thinking")Z=!0,p.write(`${e}Thinking:
|
|
166
|
+
`);else if(Y.content_block.type==="text"&&Z)p.write(`${i}
|
|
167
|
+
Response:
|
|
168
|
+
`),Z=!1}else if(Y.type==="content_block_delta"){if(Y.delta.type==="text_delta")X+=Y.delta.text,p.write(Y.delta.text);else if(Y.delta.type==="thinking_delta")p.write(Y.delta.thinking)}}catch{}}if(Z)p.write(i);if(X)r.messages.push({role:"assistant",content:X}),p.write(`
|
|
169
|
+
`);else p.write(`${e}[empty response]${i}
|
|
170
|
+
`)}catch(B){p.write(`${e}[error] ${B instanceof Error?B.message:String(B)}${i}
|
|
171
|
+
`)}finally{o=!1,w=0}}function M(R){let T=R.trim().split(/\s+/),B=T[0],Q=T.slice(1).join(" ");switch(B){case"/exit":return p.write(`${e}Goodbye!${i}
|
|
172
|
+
`),"exit";case"/help":return wp(),"ok";case"/clear":return r.messages=[],p.write(`${e}Conversation cleared.${i}
|
|
173
|
+
`),"ok";case"/system":{if(Q)r.system=Q,p.write(`${e}System prompt set.${i}
|
|
174
|
+
`);else if(r.system)p.write(`${e}System prompt:${i}
|
|
175
|
+
${r.system}
|
|
176
|
+
`);else p.write(`${e}No system prompt set.${i}
|
|
177
|
+
`);return"ok"}case"/model":{if(Q)r.model=Q,p.write(`${e}Model set to: ${r.model}${i}
|
|
178
|
+
`);else p.write(`${e}Current model: ${r.model}${i}
|
|
179
|
+
`);return"ok"}case"/save":{if(!Q)return p.write(`${e}Usage: /save <file-path>${i}
|
|
180
|
+
`),"ok";try{let X=[];if(r.system)X.push({role:"system",content:r.system});for(let Z of r.messages)X.push({role:Z.role,content:typeof Z.content==="string"?Z.content:JSON.stringify(Z.content)});pp(Q,JSON.stringify(X,null,2),"utf-8"),p.write(`${e}Conversation saved to ${Q} (${X.length} messages)${i}
|
|
181
|
+
`)}catch(X){p.write(`${e}[error] Failed to save: ${X instanceof Error?X.message:String(X)}${i}
|
|
182
|
+
`)}return"ok"}case"/history":{if(r.messages.length===0)return p.write(`${e}No messages in conversation.${i}
|
|
183
|
+
`),"ok";if(r.system)p.write(`${e}[system] ${r.system.slice(0,100)}${r.system.length>100?"...":""}${i}
|
|
184
|
+
`);let X=1;for(let Z of r.messages){let N=Z.role==="user"?"user":"assistant",Y=typeof Z.content==="string"?Z.content:"[structured content]",Zt=(Y.length>120?Y.slice(0,120)+"...":Y).replace(/\n/g,"↵"),qt=` ${String(X).padStart(2)} ${N.padEnd(11)}`;p.write(`${e}${qt}${i}${Zt}
|
|
185
|
+
`),X++}return p.write(`${e}── ${X-1} messages ──${i}
|
|
186
|
+
`),"ok"}default:if(B.startsWith("/"))return p.write(`${e}Unknown command: ${B}. Type /help for available commands.${i}
|
|
187
|
+
`),"ok";return"ok"}}let c=()=>{if(o){p.write(`
|
|
188
|
+
${e}[interrupted]${i}
|
|
189
|
+
`),w=0,o=!1;return}if(w++,w>=2){if(p.write(`
|
|
190
|
+
${e}Goodbye!${i}
|
|
191
|
+
`),S=!1,typeof $.setRawMode==="function")$.setRawMode(!1);$.pause(),process.removeListener("SIGINT",c),process.exit(0)}else p.write(`
|
|
192
|
+
${e}Press Ctrl+C again or type /exit to quit.${i}
|
|
193
|
+
`)};process.on("SIGINT",c);let v=new ae(p,"> ",e,i),S=!0;$.on("data",(R)=>{v.feed(R)}),p.write(yp);try{while(S){let R=await v.readLine();if(!S)break;let T=R.trim();if(!T)continue;if(T.startsWith("/")){if(M(T)==="exit"){S=!1;break}continue}r.messages.push({role:"user",content:T}),await u()}}finally{if(p.write(_p),typeof $.setRawMode==="function")$.setRawMode(!1);$.pause(),process.removeListener("SIGINT",c),$.removeAllListeners("data"),p.write(`
|
|
194
|
+
`)}}})});import{writeFileSync as up}from"fs";function ht(t,n,e,i){if(n){let r=t.data.audio;if(!r)throw new _("API response missing audio data (audio field is empty).",y.GENERAL);if(!/^[0-9a-fA-F]*$/.test(r))throw new _("API returned invalid audio data (not valid hex).",y.GENERAL);if(r.length%2!==0)throw new _("API returned truncated audio data (odd-length hex string).",y.GENERAL);try{up(n,Buffer.from(r,"hex"))}catch(m){if(m.code==="ENOSPC")throw new _("Disk full — cannot write audio file.",y.GENERAL,"Free up disk space and try again.");throw m}if(i)console.log(n);else console.log(j({saved:n,duration_ms:t.extra_info?.audio_length,size_bytes:t.extra_info?.audio_size,sample_rate:t.extra_info?.audio_sample_rate},e))}else{let r=t.data.audio_url??t.data.audio;if(i)console.log(r);else console.log(j({url:r,duration_ms:t.extra_info?.audio_length,size_bytes:t.extra_info?.audio_size},e))}}var un=b(()=>{W();k();h()});var ti={};It(ti,{readTextFromPathOrStdin:()=>Wt});import{readFileSync as Mp}from"fs";function Wt(t){return Mp(t==="-"?"/dev/stdin":t,"utf-8")}var Mn=()=>{};function St(t){return t.join(", ")}function Xt(t,n){if(!n.includes(t))throw new _(`Invalid audio format "${t}". Supported: ${St(n)}`,y.USAGE)}function ni(t,n){return cp[t]??n}function $i(t,n){if(n&&t==="wav")throw new _("wav format is not supported in streaming mode.",y.USAGE,"Use mp3, pcm, flac, pcmu_raw, pcmu_wav, or opus for streaming.")}var m$,kt,cp;var cn=b(()=>{k();h();m$=["mp3","pcm","flac","wav","pcmu_raw","pcmu_wav","opus"],kt=["mp3","wav","pcm"];cp={opus:24000,pcmu_raw:8000,pcmu_wav:8000}});async function Yt(t){process.stdout.on("error",(n)=>{if(n.code==="EPIPE")process.exit(0);throw n});for await(let n of Tt(t)){if(!n.data||n.data==="[DONE]")break;let e;try{e=JSON.parse(n.data)}catch{continue}if(e.data?.status===2)continue;let i=e.data?.audio;if(!i)continue;let r=Buffer.from(i,"hex");if(!process.stdout.write(r))await new Promise((m)=>process.stdout.once("drain",m))}}var vn=()=>{};import{writeFileSync as vp}from"fs";var p$;var ei=b(()=>{V();k();h();I();W();un();Mn();cn();vn();p$=q({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: ${St(m$)} (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','mmx speech synthesize --text "Hello" --subtitles --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,n){let e=n.text??n._positional?.[0];if(n.textFile)e=Wt(n.textFile);if(!e)throw new _("--text or --text-file is required.",y.USAGE,'mmx speech synthesize --text "Hello" --out hello.mp3');let i=n.model||t.defaultSpeechModel||"speech-2.8-hd",r=n.voice||"English_expressive_narrator",m=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),$=n.format||"mp3";Xt($,m$),$i($,n.stream===!0);let p=n.out??`speech_${m}.${$}`,o="hex",w={model:i,text:e,voice_setting:{voice_id:r,speed:n.speed??void 0,vol:n.volume??void 0,pitch:n.pitch??void 0},audio_setting:{format:n.format||"mp3",sample_rate:n.sampleRate??ni($,32000),bitrate:n.bitrate??128000,channel:n.channels??1},output_format:o,stream:n.stream===!0};if(n.language)w.language_boost=n.language;if(n.subtitles)w.subtitle_enable=!0;if(n.pronunciation)w.pronunciation_dict=n.pronunciation.map((v)=>{let[S,R]=v.split("/");return{tone:R||S,text:S}});if(tt(t,w))return;let u=A(t.output),M=Se(t.baseUrl);if(n.stream){let v=await D(t,{url:M,method:"POST",body:w,stream:!0});await Yt(v);return}let c=await J(t,{url:M,method:"POST",body:w});if(!t.quiet)process.stderr.write(`[Model: ${i}]
|
|
195
|
+
`);if(ht(c,p,u,t.quiet),n.subtitles&&c.data.subtitle_file)try{let v=await fetch(c.data.subtitle_file);if(!v.ok)throw new _(`Failed to download subtitle file: ${v.status}`,y.GENERAL);let S=await v.json();if(S?.length){let R=p.replace(/\.[^.]+$/,"")+".srt",T=S.map((B,Q)=>{let X=(Z)=>{let N=String(Math.floor(Z/3600000)).padStart(2,"0"),Y=String(Math.floor(Z%3600000/60000)).padStart(2,"0"),Ut=String(Math.floor(Z%60000/1000)).padStart(2,"0"),Zt=String(Math.round(Z%1000)).padStart(3,"0");return`${N}:${Y}:${Ut},${Zt}`};return`${Q+1}
|
|
196
|
+
${X(B.time_begin)} --> ${X(B.time_end)}
|
|
197
|
+
${B.text}`}).join(`
|
|
153
198
|
|
|
154
|
-
`);if(
|
|
155
|
-
`)}else if(n.subtitles&&!
|
|
156
|
-
`)}}});function
|
|
157
|
-
`)}}}}function
|
|
158
|
-
`)}}}async function
|
|
159
|
-
Retry ${
|
|
160
|
-
`);await new Promise((
|
|
161
|
-
Download attempt ${
|
|
162
|
-
`)}throw new
|
|
163
|
-
`);let
|
|
164
|
-
`);if(
|
|
165
|
-
`);
|
|
166
|
-
`);await
|
|
167
|
-
`));else console.log(
|
|
199
|
+
`);if(vp(R,T,"utf-8"),!t.quiet)console.log(j({subtitles:R},u));else console.log(R)}}catch(v){if(!t.quiet)process.stderr.write(`Warning: failed to download subtitles: ${v.message}
|
|
200
|
+
`)}else if(n.subtitles&&!c.data.subtitle_file){if(!t.quiet)process.stderr.write(`Warning: subtitles requested but not returned by API
|
|
201
|
+
`)}}})});function bp(t){let n=t.match(/^(.+?)_[A-Z]/);return n?n[1]:t}function Gp(t,n){let e=n.toLowerCase();return t.filter((i)=>{let r=bp(i.voice_id).toLowerCase();return r===e||r.startsWith(e+"_")||r.startsWith(e+" (")})}var ii;var ri=b(()=>{V();I();W();ii=q({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,n){let e=A(t.output);if(t.dryRun){console.log(j({request:{voice_type:"system"}},e));return}let r=(await J(t,{url:Re(t.baseUrl),method:"POST",body:{voice_type:"system"}})).system_voice??[],m=n.language;if(m){let $=Gp(r,m);if(e!=="text"){console.log(j($,e));return}for(let p of $){let o=p.description?.join("; ")||"",w=p.voice_name?` (${p.voice_name})`:"";if(console.log(` ${p.voice_id}${w}`),o)console.log(` ${o}`)}}else{if(e!=="text"){console.log(j(r.map(($)=>$.voice_id),e));return}for(let $ of r)console.log($.voice_id)}}})});function pi(t){let n=process.stderr.isTTY,e=0,i=null,r=t;return{start(){if(!n)return;i=setInterval(()=>{process.stderr.write(`\r${mi[e%mi.length]} ${r}`),e++},80)},update(m){r=m},stop(m){if(i)clearInterval(i),i=null;if(n){if(process.stderr.write("\r\x1B[K"),m)process.stderr.write(`${m}
|
|
202
|
+
`)}}}}function xi(t,n=""){let e=process.stderr.isTTY,i=30;return{update(r){if(!e)return;let m=Math.min(1,r/t),$=Math.round(30*m),p=30-$,o="█".repeat($)+"░".repeat(p),w=`${Math.round(m*100)}%`;process.stderr.write(`\r${n} ${o} ${w}`)},finish(){if(e)process.stderr.write(`
|
|
203
|
+
`)}}}var mi;var x$=b(()=>{mi=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"]});import{createWriteStream as Sp,renameSync as Rp,unlinkSync as qp}from"fs";async function yt(t,n,e){let i=t.startsWith("http://")?t.replace("http://","https://"):t,r=e?.retries??3,m=e?.retryDelayMs??1000,$;for(let p=0;p<=r;p++)try{if(p>0){let B=m*Math.pow(2,p-1);if(!e?.quiet)process.stderr.write(`
|
|
204
|
+
Retry ${p}/${r} in ${B}ms...
|
|
205
|
+
`);await new Promise((Q)=>setTimeout(Q,B))}let o=await fetch(i);if(!o.ok)throw new _(`Download failed: HTTP ${o.status}`,y.GENERAL);let w=Number(o.headers.get("content-length")||0),u=o.body?.getReader();if(!u)throw new _("No response body",y.GENERAL);let M=`${n}.tmp-${process.pid}-${Date.now()}-${p}-${Math.random().toString(36).slice(2)}`,c=Sp(M),v=w>0&&!e?.quiet?xi(w,"Downloading"):null,S=0,R=!1,T=!1;try{let B=new Promise((Q,X)=>{c.on("error",X)});while(!0){let{done:Q,value:X}=await Promise.race([u.read(),B]);if(Q)break;if(!c.write(X))await new Promise((N)=>c.once("drain",N));S+=X.byteLength,v?.update(S)}R=!0}finally{u.releaseLock(),v?.finish();try{if(!c.destroyed)await new Promise((B,Q)=>{c.on("finish",B),c.on("error",Q),c.end()}),T=R}finally{if(!T)try{qp(M)}catch{}}}return Rp(M,n),{size:S}}catch(o){if($=o instanceof Error?o:Error(String(o)),!e?.quiet)process.stderr.write(`
|
|
206
|
+
Download attempt ${p+1} failed: ${$.message}
|
|
207
|
+
`)}throw new _(`Download failed after ${r+1} attempts: ${$?.message}`,y.NETWORK,"Check your network connection and proxy settings.")}function bn(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`}var Gn=b(()=>{x$();k();h()});import{readFileSync as jp,existsSync as Bp}from"fs";import{extname as oi}from"path";function Sn(t){let n=oi(t).toLowerCase(),e=yi[n]||"image/jpeg",i=jp(t);return`data:${e};base64,${i.toString("base64")}`}function Rn(t){return t.startsWith("http")?t:Sn(t)}async function _i(t){if(t.startsWith("data:"))return t;if(t.startsWith("http://")||t.startsWith("https://")){let e=await fetch(t);if(!e.ok)throw new _(`Failed to download image: HTTP ${e.status}`,y.GENERAL);let r=(e.headers.get("content-type")||"image/jpeg").split(";")[0].trim(),m=await e.arrayBuffer();if(m.byteLength>Ap)throw new _(`Image too large (${(m.byteLength/1024/1024).toFixed(1)} MB). Maximum is 50 MB.`,y.USAGE);return`data:${r};base64,${Buffer.from(m).toString("base64")}`}if(!Bp(t))throw new _(`File not found: ${t}`,y.USAGE);let n=oi(t).toLowerCase();if(!yi[n])throw new _(`Unsupported image format "${n}". Supported: jpg, jpeg, png, webp`,y.USAGE);return Sn(t)}var yi,Ap=52428800;var qn=b(()=>{k();h();yi={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"}});import{mkdirSync as wi,existsSync as Ot,writeFileSync as ui}from"fs";import{dirname as Jp,join as Mi,resolve as o$}from"path";var ci;var vi=b(()=>{V();k();h();I();Gn();W();qn();mt();ci=q({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 <path>",description:"Save image to exact file path (single image only)"},{flag:"--response-format <format>",description:"Response format: url (download), base64 (embed). Default: 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',"# Save to exact path",'mmx image generate --prompt "A cat" --out /tmp/cat.jpg',"# Base64 response (bypasses CDN, useful when image URLs are unreachable)",'mmx image generate --prompt "A cat" --response-format base64'],async run(t,n){let e=n.prompt??n._positional?.[0];e=await Dt({value:e,message:"Enter your image prompt:",cancelMessage:"Image generation cancelled.",flagName:"prompt",usageHint:"mmx image generate --prompt <text>",nonInteractive:t.nonInteractive});let{width:i,height:r}=n;if(i!==void 0&&r===void 0)throw new _("--width requires --height. Both must be specified together.",y.USAGE);if(r!==void 0&&i===void 0)throw new _("--height requires --width. Both must be specified together.",y.USAGE);if(i!==void 0&&r!==void 0){let c=(v,S)=>{if(S<512||S>2048)throw new _(`--${v} must be between 512 and 2048, got ${S}.`,y.USAGE);if(S%8!==0)throw new _(`--${v} must be a multiple of 8, got ${S}.`,y.USAGE)};c("width",i),c("height",r)}let m=n.out;if(m&&n.n>1)throw new _("--out cannot be used with --n > 1. Use --out-dir instead.",y.USAGE);let $=n.responseFormat||"url",p={model:"image-01",prompt:e,aspect_ratio:i!==void 0&&r!==void 0?void 0:n.aspectRatio||void 0,n:n.n??1,seed:n.seed,width:i,height:r,prompt_optimizer:n.promptOptimizer===!0||void 0,aigc_watermark:n.aigcWatermark===!0||void 0,response_format:$};if(n.subjectRef){let c=n.subjectRef,v=Object.fromEntries(c.split(",").map((R)=>{let T=R.indexOf("=");if(T===-1)return[R,""];return[R.slice(0,T),R.slice(T+1)]})),S={type:v.type||"character"};if(v.image)if(v.image.startsWith("http"))S.image_url=v.image;else S.image_file=Sn(o$(v.image));p.subject_reference=[S]}if(tt(t,p))return;let o=A(t.output),w=qe(t.baseUrl),u=await J(t,{url:w,method:"POST",body:p});if(!t.quiet)process.stderr.write(`[Model: image-01]
|
|
208
|
+
`);let M=[];if(m){let c=Jp(o$(m));if(!Ot(c))wi(c,{recursive:!0});let v=o$(m);if(Ot(v))process.stderr.write(`Warning: overwriting existing file: ${v}
|
|
209
|
+
`);if($==="base64"){let S=(u.data.image_base64||[])[0];if(S)ui(v,S,"base64")}else{let S=(u.data.image_urls||[])[0];if(S)await yt(S,v,{quiet:t.quiet})}M.push(v)}else{let c=n.outDir??".";if(!Ot(c))wi(c,{recursive:!0});let v=n.outPrefix||"image";if($==="base64"){let S=u.data.image_base64||[];for(let R=0;R<S.length;R++){let T=`${v}_${String(R+1).padStart(3,"0")}.jpg`,B=Mi(c,T);if(Ot(B))process.stderr.write(`Warning: overwriting existing file: ${B}
|
|
210
|
+
`);ui(B,S[R],"base64"),M.push(B)}}else{let S=u.data.image_urls||[];for(let R=0;R<S.length;R++){let T=`${v}_${String(R+1).padStart(3,"0")}.jpg`,B=Mi(c,T);if(Ot(B))process.stderr.write(`Warning: overwriting existing file: ${B}
|
|
211
|
+
`);await yt(S[R],B,{quiet:t.quiet}),M.push(B)}}}if(o==="json")console.log(j({id:u.data.task_id,saved:M,success_count:u.data.success_count,failed_count:u.data.failed_count},o));else if(t.quiet)console.log(M.join(`
|
|
212
|
+
`));else console.log(j({id:u.data.task_id,saved:M,success_count:u.data.success_count,failed_count:u.data.failed_count},o))}})});async function bi(t,n){let e=Date.now()+n.timeoutSec*1000,i=pi("Polling...");if(!t.quiet)i.start();try{while(Date.now()<e){let r=await J(t,{url:n.url});if(n.getStatus&&!t.quiet)i.update(`Status: ${n.getStatus(r)}`);if(n.isComplete(r))return i.stop("Done."),r;if(n.isFailed(r)){i.stop("Failed.");let m=n.getStatus?n.getStatus(r):"failed",$=r?.base_resp?` (${r.base_resp.status_msg})`:"";throw new _(`Task ${m}.${$}`,y.GENERAL,"Check the MiniMax dashboard or --verbose output for details.")}await new Promise((m)=>setTimeout(m,n.intervalSec*1000))}}finally{i.stop()}throw new _("Polling timed out.",y.TIMEOUT,"Try increasing --timeout or check task status manually.")}var Gi=b(()=>{I();k();h();x$()});var Si;var Ri=b(()=>{V();k();h();I();Gi();Gn();W();qn();mt();Si=q({name:"video generate",description:`Generate a video
|
|
168
213
|
T2V: Hailuo-2.3
|
|
169
214
|
I2V: Hailuo-2.3 (default) / Hailuo-2.3-Fast (fast mode, requires --first-frame)
|
|
170
215
|
SEF: Hailuo-02 (requires --first-frame and --last-frame)
|
|
171
|
-
S2V: S2V-01 (requires --subject-image)`,apiDocs:"/docs/api-reference/video-generation",usage:"mmx video generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID. T2V: MiniMax-Hailuo-2.3; I2V: MiniMax-Hailuo-2.3 (default) or MiniMax-Hailuo-2.3-Fast (fast, requires --first-frame). 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(t,n){let
|
|
172
|
-
`);if(n.noWait||t.async){process.stdout.write(JSON.stringify({taskId:
|
|
173
|
-
`);return}let
|
|
174
|
-
`)}});var
|
|
175
|
-
`);if(
|
|
176
|
-
`);
|
|
177
|
-
`),process.exit(1);if(!
|
|
178
|
-
`);return}process.stdout.write(
|
|
179
|
-
`)}});var
|
|
180
|
-
`)}catch{throw new
|
|
181
|
-
`)}});var
|
|
216
|
+
S2V: S2V-01 (requires --subject-image)`,apiDocs:"/docs/api-reference/video-generation",usage:"mmx video generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID. T2V: MiniMax-Hailuo-2.3; I2V: MiniMax-Hailuo-2.3 (default) or MiniMax-Hailuo-2.3-Fast (fast, requires --first-frame). 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(t,n){let e=n.prompt;if(e=await Dt({value:e,message:"Enter your video prompt:",cancelMessage:"Video generation cancelled.",flagName:"prompt",usageHint:"mmx video generate --prompt <text>",nonInteractive:t.nonInteractive}),n.lastFrame&&n.subjectImage)throw new _("--last-frame and --subject-image cannot be used together (SEF and S2V are different modes).",y.USAGE,"mmx video generate --prompt <text> --first-frame <path> --last-frame <path>");let i=n.model;if(i==="MiniMax-Hailuo-2.3-Fast"&&!n.firstFrame)throw new _("MiniMax-Hailuo-2.3-Fast only supports I2V (image-to-video). Use --first-frame to provide an input image.",y.USAGE,"mmx video generate --prompt <text> --model MiniMax-Hailuo-2.3-Fast --first-frame <image>");let r;if(i)r=i;else if(n.lastFrame)r="MiniMax-Hailuo-02";else if(n.subjectImage)r="S2V-01";else r=t.defaultVideoModel||"MiniMax-Hailuo-2.3";let m={model:r,prompt:e};if(n.firstFrame)m.first_frame_image=Rn(n.firstFrame);if(n.lastFrame){if(!n.firstFrame)throw new _("--last-frame requires --first-frame (SEF mode).",y.USAGE,"mmx video generate --prompt <text> --first-frame <path> --last-frame <path>");m.last_frame_image=Rn(n.lastFrame)}if(n.subjectImage)m.subject_reference=[{type:"character",image:[Rn(n.subjectImage)]}];if(n.callbackUrl)m.callback_url=n.callbackUrl;if(tt(t,m))return;let $=A(t.output),p=je(t.baseUrl),w=(await J(t,{url:p,method:"POST",body:m})).task_id;if(!t.quiet)process.stderr.write(`[Model: ${r}]
|
|
217
|
+
`);if(n.noWait||t.async){process.stdout.write(JSON.stringify({taskId:w})),process.stdout.write(`
|
|
218
|
+
`);return}let u=n.pollInterval??5,M=en(t.baseUrl,w),c=await bi(t,{url:M,intervalSec:u,timeoutSec:t.timeout,isComplete:(N)=>N.status==="Success",isFailed:(N)=>N.status==="Failed",getStatus:(N)=>N.status});if(!c.file_id)throw new _("Task completed but no file_id returned.",y.GENERAL);let S=(await J(t,{url:rn(t.baseUrl,c.file_id)})).file?.download_url;if(!S)throw new _("No download URL available for this file.",y.GENERAL);if(n.download){let N=n.download,{size:Y}=await yt(S,N,{quiet:t.quiet});if(t.quiet)console.log(N);else console.log(j({task_id:w,status:"Success",file_id:c.file_id,saved:N,size:bn(Y)},$));return}let R=await import("os"),{join:T}=await import("path"),B=T(R.tmpdir(),"mmx-video"),{existsSync:Q,mkdirSync:X}=await import("fs");if(!Q(B))X(B,{recursive:!0});let Z=T(B,`${w}.mp4`);await yt(S,Z,{quiet:t.quiet}),process.stdout.write(Z),process.stdout.write(`
|
|
219
|
+
`)}})});var qi;var ji=b(()=>{V();k();h();I();W();qi=q({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,n){let e=n.taskId;if(!e)throw new _("--task-id is required.",y.USAGE,"mmx video task get --task-id <id>");if(t.dryRun){console.log(`Would query task: ${e}`);return}let i=en(t.baseUrl,e),r=await J(t,{url:i}),m=A(t.output);if(t.quiet){console.log(r.status);return}console.log(j({task_id:r.task_id,status:r.status,file_id:r.file_id,video_width:r.video_width,video_height:r.video_height},m))}})});var Bi;var Ai=b(()=>{V();k();h();I();Gn();W();Bi=q({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,n){let e=n.fileId;if(!e)throw new _("--file-id is required.",y.USAGE,"mmx video download --file-id <id> --out <path>");let i=n.out;if(!i)throw new _("--out is required.",y.USAGE,"mmx video download --file-id <id> --out video.mp4");if(t.dryRun){console.log(`Would download file ${e} to ${i}`);return}let r=rn(t.baseUrl,e),$=(await J(t,{url:r})).file?.download_url;if(!$)throw new _("No download URL available for this file.",y.GENERAL,"The file may still be processing. Check task status first.");let{size:p}=await yt($,i,{quiet:t.quiet}),o=A(t.output);if(t.quiet){console.log(i);return}console.log(j({saved:i,size:bn(p)},o))}})});function Ji(t){return t.defaultMusicModel??"music-2.6"}function Ti(t){if(t.defaultMusicModel&&Tp.has(t.defaultMusicModel))return t.defaultMusicModel;return"music-cover"}var Tp;var y$=b(()=>{Tp=new Set(["music-cover"])});var hi;var ki=b(()=>{V();k();h();I();W();un();Mn();cn();vn();y$();hi=q({name:"music generate",description:"Generate a song (music-2.6 / 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 (default), 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: ${St(kt)} (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(t,n){let{prompt:e,lyrics:i}=n,r=n.instrumental===!0,m=n.lyricsOptimizer===!0;if(n.lyricsFile)i=Wt(n.lyricsFile);if(r&&(i||n.lyricsFile))throw new _("Cannot use --instrumental with --lyrics or --lyrics-file.",y.USAGE,"mmx music generate --prompt <style> --instrumental");if(m&&(i||r))throw new _("Cannot use --lyrics-optimizer with --lyrics, --lyrics-file, or --instrumental.",y.USAGE,"mmx music generate --prompt <text> --lyrics-optimizer");if(!e&&!i&&!r&&!m)throw new _("At least one of --prompt or --lyrics is required.",y.USAGE,"mmx music generate --prompt <text> --lyrics <text>");if(!r&&!m&&!i?.trim())throw new _("Lyrics are required. Add --lyrics or --lyrics-file, or use --instrumental for pure music, or --lyrics-optimizer to auto-generate.",y.USAGE,"mmx music generate --prompt <text> --lyrics <text>");let $=[];if(n.vocals)$.push(`Vocals: ${n.vocals}`);if(n.genre)$.push(`Genre: ${n.genre}`);if(n.mood)$.push(`Mood: ${n.mood}`);if(n.instruments)$.push(`Instruments: ${n.instruments}`);if(n.tempo)$.push(`Tempo: ${n.tempo}`);if(n.bpm)$.push(`BPM: ${n.bpm}`);if(n.key)$.push(`Key: ${n.key}`);if(n.avoid)$.push(`Avoid: ${n.avoid}`);if(n.useCase)$.push(`Use case: ${n.useCase}`);if(n.structure)$.push(`Structure: ${n.structure}`);if(n.references)$.push(`References: ${n.references}`);if(n.extra)$.push(`Extra: ${n.extra}`);if($.length>0){let B=$.join(". ");e=e?`${e}. ${B}`:B}let p=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),o=n.format||"mp3";Xt(o,kt);let w=n.out??`music_${p}.${o}`,u=n.model||Ji(t),M=["music-2.6","music-2.5+","music-2.5"];if(n.model&&!M.includes(u))throw new _(`Invalid model "${u}". Valid models: ${M.join(", ")}`,y.USAGE,"mmx music generate --model music-2.6");let c=n.outputFormat||"hex";if(c!=="hex"&&c!=="url")throw new _('--output-format must be "hex" or "url".',y.USAGE,"mmx music generate --output-format url");if(n.stream&&c==="url")throw new _("--stream and --output-format url cannot be used together. Streaming requires hex format.",y.USAGE,"mmx music generate --output-format url");let v={model:u,prompt:e,lyrics:i,is_instrumental:r||void 0,lyrics_optimizer:m||void 0,audio_setting:{format:n.format||"mp3",sample_rate:n.sampleRate??44100,bitrate:n.bitrate??256000},output_format:n.stream===!0?"hex":c,stream:n.stream===!0};if(n.aigcWatermark)v.aigc_watermark=!0;if(tt(t,v))return;let S=A(t.output),R=mn(t.baseUrl);if(n.stream){let B=await D(t,{url:R,method:"POST",body:v,stream:!0});await Yt(B);return}let T=await J(t,{url:R,method:"POST",body:v});if(!t.quiet)process.stderr.write(`[Model: ${u}]
|
|
220
|
+
`);if(c==="url"){if(T.data?.audio_url)console.log(T.data.audio_url);else throw new _("Requested URL output but API did not return audio_url.",y.GENERAL);return}ht(T,w,S,t.quiet)}})});import{readFileSync as hp}from"fs";var Xi;var Yi=b(()=>{V();k();h();I();W();un();cn();vn();y$();Xi=q({name:"music cover",description:"Generate a cover version of a song based on reference audio (music-cover)",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 (default)."},{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: ${St(kt)} (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,n){let{prompt:e,audio:i,audioFile:r}=n;if(!e)throw new _("--prompt is required.",y.USAGE,"mmx music cover --prompt <text> --audio <url>");if(!i&&!r)throw new _("One of --audio <url> or --audio-file <path> is required.",y.USAGE,"mmx music cover --prompt <text> --audio <url>");if(i&&r)throw new _("Use either --audio or --audio-file, not both.",y.USAGE);let m=n.lyrics;if(n.lyricsFile){let{readTextFromPathOrStdin:R}=await Promise.resolve().then(() => (Mn(),ti));m=R(n.lyricsFile)}let $=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),p=n.format||"mp3";Xt(p,kt);let o=n.out??`cover_${$}.${p}`,w=A(t.output),u=n.model||Ti(t),M=["music-cover"];if(n.model&&!M.includes(u))throw new _(`Invalid model "${u}". Valid models: ${M.join(", ")}`,y.USAGE,"mmx music cover --model music-cover");let c={model:u,prompt:e,lyrics:m,seed:n.seed,audio_setting:{format:p,sample_rate:n.sampleRate??44100,bitrate:n.bitrate??256000,channel:n.channel??void 0},output_format:"hex",stream:n.stream===!0};if(i)c.audio_url=i;else c.audio_base64=hp(r).toString("base64");if(t.dryRun){console.log(j({request:c},w));return}let v=mn(t.baseUrl);if(n.stream){let R=await D(t,{url:v,method:"POST",body:c,stream:!0});await Yt(R);return}let S=await J(t,{url:v,method:"POST",body:c});if(!t.quiet)process.stderr.write(`[Model: ${u}]
|
|
221
|
+
`);ht(S,o,w,t.quiet)}})});var _$;var Zi=b(()=>{V();I();W();k();h();_$=q({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,n){let e=n.q??n.query??n._positional?.[0];if(!e)throw new _("--q is required.",y.USAGE,'mmx search query --q "your search query"');let i=A(t.output);if(t.dryRun){console.log(j({request:{q:e}},i));return}let r=Be(t.baseUrl),m=await J(t,{url:r,method:"POST",body:{q:e}}),$=m.organic||[];if(i!=="text"){console.log(j(m,i));return}if(t.quiet){for(let p of $)console.log(`${p.title} ${p.link}`);return}if($.length===0){console.log("No results found.");return}for(let p of $){if(console.log(`${p.title}`),console.log(` ${p.link}`),p.snippet)console.log(` ${p.snippet}`);if(p.date)console.log(` ${p.date}`);console.log("")}}})});var Qi;var Vi=b(()=>{V();I();W();k();h();mt();qn();Qi=q({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,n){let e=n.image??n.file??n.path??n._positional?.[0],i=n.fileId,r=n.prompt||"Describe the image.";if(!e&&!i)if(H({nonInteractive:t.nonInteractive})){let w=await f({message:"Enter image path, URL, or File ID:"});if(!w)process.stderr.write(`Vision describe cancelled.
|
|
222
|
+
`),process.exit(1);if(!w.includes(".")&&!w.startsWith("http"))i=w;else e=w}else throw new _("Missing required argument. Must provide either --image or --file-id.",y.USAGE,"mmx vision describe --image <path> OR --file-id <id>");else if(e&&i)throw new _("Conflicting arguments: cannot provide both --image and --file-id.",y.USAGE);if(tt(t,{prompt:r,image:e,fileId:i}))return;let m=A(t.output),$=Ae(t.baseUrl),p={prompt:r};if(i)p.file_id=i;else if(e){let w=await _i(e);p.image_url=w}let o=await J(t,{url:$,method:"POST",body:p});if(m!=="text"){process.stdout.write(j(o,m)+`
|
|
223
|
+
`);return}process.stdout.write(o.content+`
|
|
224
|
+
`)}})});var Ni;var zi=b(()=>{V();I();W();on();Ni=q({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,n){if(t.dryRun){console.log("Would fetch quota information.");return}let e=Gt(t.baseUrl),i=await J(t,{url:e}),r=i.model_remains||[],m=A(n.output);if(m!=="text"){console.log(j(i,m));return}if(t.quiet){for(let $ of r){let p=$.current_interval_total_count-$.current_interval_usage_count;console.log(`${$.model_name} ${$.current_interval_usage_count} ${$.current_interval_total_count} ${p}`)}return}Jt(r,t)}})});var Wi;var Oi=b(()=>{V();nt();Vt();W();Wi=q({name:"config show",description:"Display current configuration",usage:"mmx config show",examples:["mmx config show","mmx config show --output json"],async run(t,n){let e=O(),i=A(t.output),r={region:t.region,base_url:t.baseUrl,output:t.output,timeout:t.timeout,config_file:et()};if(e.api_key)r.api_key=a(e.api_key);if(e.default_text_model)r.default_text_model=e.default_text_model;if(e.default_speech_model)r.default_speech_model=e.default_speech_model;if(e.default_video_model)r.default_video_model=e.default_video_model;if(e.default_music_model)r.default_music_model=e.default_music_model;if(e.proxy)r.proxy=e.proxy;console.log(j(r,i))}})});var Ui,kp,Ki;var Hi=b(()=>{V();k();h();W();nt();Ui=["region","base_url","output","timeout","api_key","proxy","default_text_model","default_speech_model","default_video_model","default_music_model"],kp={"default-text-model":"default_text_model","default-speech-model":"default_speech_model","default-video-model":"default_video_model","default-music-model":"default_music_model"},Ki=q({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, proxy, 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 proxy --value http://127.0.0.1:7890","mmx config set --key base_url --value https://api-uw.minimax.io"],async run(t,n){let e=n._positional,i=n.key??e?.[0],r=n.value??e?.[1];if(!i||r===void 0)throw new _("--key and --value are required.",y.USAGE,"mmx config set --key <key> --value <value>");let m=kp[i]||i;if(!Ui.includes(m))throw new _(`Invalid config key "${i}". Valid keys: ${Ui.join(", ")}`,y.USAGE);if(m==="region"&&!["global","cn"].includes(r))throw new _(`Invalid region "${r}". Valid values: global, cn`,y.USAGE);if(m==="output"&&!["text","json"].includes(r))throw new _(`Invalid output format "${r}". Valid values: text, json`,y.USAGE);if(m==="base_url"&&!r.startsWith("http"))throw new _(`Invalid base_url "${r}". Must start with http.`,y.USAGE);if(m==="proxy"&&!r.startsWith("http"))throw new _(`Invalid proxy "${r}". Must be a URL starting with http (e.g. http://127.0.0.1:7890).`,y.USAGE);if(m==="timeout"){let o=Number(r);if(isNaN(o)||o<=0)throw new _(`Invalid timeout "${r}". Must be a positive number.`,y.USAGE)}let $=A(t.output);if(t.dryRun){console.log(j({would_set:{[m]:r}},$));return}let p=O();if(p[m]=m==="timeout"?Number(r):r,m==="api_key")delete p.region;if(await s(p),!t.quiet)console.log(j({[m]:p[m]},$))}})});function Xp(t){let n=t.match(/^--([a-zA-Z0-9-]+)/),e=n?n[1]:"",i=e.replace(/-([a-zA-Z0-9])/g,($,p)=>p.toUpperCase()),r="string",m=!1;if(!t.includes("<")&&!t.includes("["))r="boolean";else if(t.includes("<n>")||t.includes("<hz>")||t.includes("<bps>")||t.includes("<count>"))r="number";if(t.toLowerCase().includes("repeatable"))m=!0;return{name:i,kebabName:e,inferredType:r,isArray:m}}function w$(t){let e={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:r,inferredType:m,isArray:$}=Xp(i.flag);if(!r)continue;let p=i.type,o=$?"array":p??m,w={description:i.description};if(o==="array")w.type="array",w.items={type:"string"};else w.type=o;let u=e.input_schema;if(u.properties[r]=w,i.required)u.required.push(r)}return e}var Yp,Ii;var Pi=b(()=>{V();_n();k();h();Yp=["auth ","config ","update"],Ii=q({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,n){let e=n.command;if(e){try{let{command:m}=$t.resolve(e.split(" ")),$=w$(m);process.stdout.write(JSON.stringify($,null,2)+`
|
|
225
|
+
`)}catch{throw new _(`Command "${e}" not found.`,y.USAGE)}return}let r=$t.getAllCommands().filter((m)=>!Yp.some(($)=>m.name.startsWith($))).map((m)=>w$(m));process.stdout.write(JSON.stringify(r,null,2)+`
|
|
226
|
+
`)}})});import{existsSync as Zp}from"fs";import{readFile as Qp}from"fs/promises";import{resolve as Vp,basename as Np}from"path";var si;var li=b(()=>{V();k();h();I();W();mt();si=q({name:"file upload",description:"Upload a file to MiniMax storage",usage:"mmx file upload --file <path> [--purpose <purpose>]",options:[{flag:"--file <path>",description:"Local path to the file",required:!0},{flag:"--purpose <string>",description:"File purpose (default: retrieval)"}],examples:["mmx file upload --file doc.pdf","mmx file upload --file image.png --purpose vision"],async run(t,n){let e=n.file;if(!e)if(H({nonInteractive:t.nonInteractive})){if(e=await f({message:"Enter file path:"}),!e)process.stderr.write(`Upload cancelled.
|
|
227
|
+
`),process.exit(1)}else vt("file","mmx file upload --file <path>");let i=Vp(e);if(!Zp(i))throw new _(`File not found: ${i}`,y.USAGE);let r=n.purpose||"retrieval",m=A(t.output);if(t.dryRun){process.stdout.write(j({request:{file:i,purpose:r}},m)+`
|
|
228
|
+
`);return}let $=new FormData,p=await Qp(i),o=Np(i),w=new Blob([p]);$.append("file",w,o),$.append("purpose",r);let u=Je(t.baseUrl),M=await J(t,{url:u,method:"POST",body:$});if(t.quiet){process.stdout.write(M.file.file_id+`
|
|
229
|
+
`);return}process.stdout.write(j(M.file,m)+`
|
|
230
|
+
`)}})});var Ei;var Li=b(()=>{V();I();W();Ei=q({name:"file list",description:"List uploaded files in MiniMax storage",usage:"mmx file list",examples:["mmx file list","mmx file list --output json"],async run(t,n){let e=A(t.output);if(t.dryRun){process.stdout.write(`Would list uploaded files.
|
|
231
|
+
`);return}let i=Te(t.baseUrl),r=await J(t,{url:i,method:"GET"});if(e!=="text"){process.stdout.write(j(r,e)+`
|
|
232
|
+
`);return}if(!r.files||r.files.length===0){process.stdout.write(`No files found.
|
|
233
|
+
`);return}let m=r.files.map((p)=>({ID:p.file_id,FILENAME:p.filename,PURPOSE:p.purpose,SIZE_KB:(p.bytes/1024).toFixed(1),CREATED:new Date(p.created_at*1000).toISOString().slice(0,16).replace("T"," ")})),{formatTable:$}=await Promise.resolve().then(() => j$);process.stdout.write($(m)+`
|
|
234
|
+
`)}})});var Ci;var Fi=b(()=>{V();I();W();mt();Ci=q({name:"file delete",description:"Delete an uploaded file from MiniMax storage",usage:"mmx file delete --file-id <id>",options:[{flag:"--file-id <id>",description:"ID of the file to delete",required:!0}],examples:["mmx file delete --file-id 123456789"],async run(t,n){let e=n.fileId;if(!e)if(H({nonInteractive:t.nonInteractive})){if(e=await f({message:"Enter file ID to delete:"}),!e)process.stderr.write(`Delete cancelled.
|
|
235
|
+
`),process.exit(1)}else vt("file-id","mmx file delete --file-id <id>");let i=A(t.output);if(t.dryRun){process.stdout.write(j({request:{delete_file:e}},i)+`
|
|
236
|
+
`);return}let r=he(t.baseUrl),m=await J(t,{url:r,method:"POST",body:{file_id:Number(e)}});if(t.quiet){process.stdout.write(`deleted
|
|
237
|
+
`);return}process.stdout.write(j({file_id:m.file_id,deleted:!0},i)+`
|
|
238
|
+
`)}})});var di;var fi=b(()=>{V();nn();di=q({name:"update",description:"Update mmx to the latest version",usage:"mmx update",examples:["mmx update"],async run(){process.stderr.write(`Current version: ${bt}
|
|
182
239
|
|
|
183
240
|
`),process.stderr.write(`Run:
|
|
184
241
|
`),process.stderr.write(` npm update -g mmx-cli
|
|
185
242
|
|
|
186
|
-
`)}});var
|
|
243
|
+
`)}})});var zp,ai;var Di=b(()=>{V();g();zp=[{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"}],ai=q({name:"help",description:"Show MiniMax API documentation links",usage:"mmx help",async run(t,n){let e=Qt[t.region]||Qt.global;process.stdout.write(`
|
|
187
244
|
MiniMax API Documentation Links
|
|
188
245
|
|
|
189
|
-
Official docs: ${
|
|
246
|
+
Official docs: ${e}/docs/api-reference
|
|
190
247
|
|
|
191
|
-
`);for(let
|
|
192
|
-
`),process.stdout.write(` ${" ".repeat(30)} ${
|
|
248
|
+
`);for(let i of zp)process.stdout.write(` ${i.command.padEnd(30)} ${i.title}
|
|
249
|
+
`),process.stdout.write(` ${" ".repeat(30)} ${e}${i.path}
|
|
193
250
|
|
|
194
|
-
`)}});class
|
|
195
|
-
`);throw new
|
|
251
|
+
`)}})});var Oe={};It(Oe,{registry:()=>$t});class gi{root={children:new Map};constructor(t){for(let[n,e]of Object.entries(t))this.register(n,e)}register(t,n){let e=t.split(" "),i=this.root;for(let r of e){if(!i.children.has(r))i.children.set(r,{children:new Map});i=i.children.get(r)}i.command=n}getAllCommands(){let t=[],n=(e)=>{if(e.command)t.push(e.command);for(let i of e.children.values())n(i)};return n(this.root),t}resolve(t){let n=this.root,e=[];for(let i of t){let r=n.children.get(i);if(!r)break;n=r,e.push(i)}if(n.command)return{command:n.command,extra:t.slice(e.length)};if(e.length>0&&n.children.size===1){let[,i]=n.children.entries().next().value;if(i.command)return{command:i.command,extra:t.slice(e.length)}}if(e.length>0&&n.children.size>1){let r=Array.from(n.children.values()).map(($)=>$.command),m=r[0];if(m&&r.every(($)=>$===m))return{command:m,extra:t.slice(e.length)}}if(e.length>0&&n.children.size>0){let i=Array.from(n.children.entries()).map(([r,m])=>{if(m.command)return` ${e.join(" ")} ${r} ${m.command.description}`;let $=Array.from(m.children.keys()).join(", ");return` ${e.join(" ")} ${r} [${$}]`}).join(`
|
|
252
|
+
`);throw new _(`Unknown command: mmx ${t.join(" ")}
|
|
196
253
|
|
|
197
254
|
Available commands:
|
|
198
|
-
${
|
|
199
|
-
${this.bold("Usage:",n)} mmx ${
|
|
255
|
+
${i}`,y.USAGE,`mmx ${e.join(" ")} --help`)}throw new _(`Unknown command: mmx ${t.join(" ")}`,y.USAGE,"mmx --help")}bold=(t,n)=>n.isTTY?`\x1B[1m${t}\x1B[0m`:t;accent=(t,n)=>n.isTTY?`\x1B[38;2;248;103;58m${t}\x1B[0m`:t;dim=(t,n)=>n.isTTY?`\x1B[2m${t}\x1B[0m`:t;printHelp(t,n=process.stdout,e="global"){if(t.length===0){this.printRootHelp(n);return}let i=this.root;for(let m of t){let $=i.children.get(m);if(!$){this.printRootHelp(n);return}i=$}if(i.command){this.printCommandHelp(i.command,n,e);return}let r=t.join(" ");n.write(`
|
|
256
|
+
${this.bold("Usage:",n)} mmx ${r} <command> [flags]
|
|
200
257
|
|
|
201
258
|
`),n.write(`${this.bold("Commands:",n)}
|
|
202
|
-
`),this.printChildren(r,
|
|
203
|
-
`)}printRootHelp(t){let n=["███╗ ███╗███╗ ███╗██╗ ██╗","████╗ ████║████╗ ████║╚██╗██╔╝","██╔████╔██║██╔████╔██║ ╚███╔╝ ","██║╚██╔╝██║██║╚██╔╝██║ ██╔██╗ ","██║ ╚═╝ ██║██║ ╚═╝ ██║██╔╝ ██╗","╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝"],
|
|
204
|
-
`);for(let
|
|
205
|
-
`)}else t.write(n[
|
|
206
|
-
`);let
|
|
207
|
-
${
|
|
259
|
+
`),this.printChildren(i,r,n),n.write(`
|
|
260
|
+
`)}printRootHelp(t){let n=["███╗ ███╗███╗ ███╗██╗ ██╗","████╗ ████║████╗ ████║╚██╗██╔╝","██╔████╔██║██╔████╔██║ ╚███╔╝ ","██║╚██╔╝██║██║╚██╔╝██║ ██╔██╗ ","██║ ╚═╝ ██║██║ ╚═╝ ██║██╔╝ ██╗","╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝"],e=[[240,23,122],[242,43,106],[244,63,90],[246,83,74],[248,103,58],[250,123,42]];t.write(`
|
|
261
|
+
`);for(let $=0;$<n.length;$++)if(t.isTTY){let[p,o,w]=e[$];t.write(`\x1B[1;38;2;${p};${o};${w}m${n[$]}\x1B[0m
|
|
262
|
+
`)}else t.write(n[$]+`
|
|
263
|
+
`);let i=($)=>this.bold($,t),r=($)=>this.accent($,t),m=($)=>this.dim($,t);t.write(`
|
|
264
|
+
${i("Usage:")} mmx <resource> <command> [flags]
|
|
208
265
|
|
|
209
|
-
${
|
|
210
|
-
${
|
|
211
|
-
${
|
|
212
|
-
${
|
|
213
|
-
${
|
|
214
|
-
${
|
|
215
|
-
${
|
|
216
|
-
${
|
|
217
|
-
${
|
|
218
|
-
${
|
|
219
|
-
${
|
|
220
|
-
${
|
|
266
|
+
${i("Resources:")}
|
|
267
|
+
${r("auth")} ${m("Authentication (login, status, refresh, logout)")}
|
|
268
|
+
${r("text")} ${m("Text generation (chat)")}
|
|
269
|
+
${r("speech")} ${m("Speech synthesis (synthesize, voices)")}
|
|
270
|
+
${r("image")} ${m("Image generation (generate)")}
|
|
271
|
+
${r("video")} ${m("Video generation (generate, task get, download)")}
|
|
272
|
+
${r("music")} ${m("Music generation (generate, cover)")}
|
|
273
|
+
${r("search")} ${m("Web search (query)")}
|
|
274
|
+
${r("vision")} ${m("Image understanding (describe)")}
|
|
275
|
+
${r("quota")} ${m("Usage quotas (show)")}
|
|
276
|
+
${r("config")} ${m("CLI configuration (show, set, export-schema)")}
|
|
277
|
+
${r("file")} ${m("File storage (upload, list, delete)")}
|
|
278
|
+
${r("update")} ${m("Update mmx to a newer version")}
|
|
221
279
|
|
|
222
|
-
${
|
|
223
|
-
${
|
|
224
|
-
${
|
|
225
|
-
${
|
|
226
|
-
${
|
|
227
|
-
${
|
|
228
|
-
${
|
|
229
|
-
${
|
|
230
|
-
${
|
|
231
|
-
${
|
|
232
|
-
${
|
|
233
|
-
${
|
|
234
|
-
${
|
|
280
|
+
${i("Global Flags:")}
|
|
281
|
+
${r("--api-key <key>")} ${m("API key (overrides all other auth)")}
|
|
282
|
+
${r("--region <region>")} ${m("API region: global (default), cn")}
|
|
283
|
+
${r("--base-url <url>")} ${m("API base URL (overrides region)")}
|
|
284
|
+
${r("--output <format>")} ${m("Output format: text, json")}
|
|
285
|
+
${r("--quiet")} ${m("Suppress non-essential output")}
|
|
286
|
+
${r("--verbose")} ${m("Print HTTP request/response details")}
|
|
287
|
+
${r("--timeout <seconds>")} ${m("Request timeout (default: 300)")}
|
|
288
|
+
${r("--no-color")} ${m("Disable ANSI colors and spinners")}
|
|
289
|
+
${r("--dry-run")} ${m("Show what would happen without executing")}
|
|
290
|
+
${r("--non-interactive")} ${m("Disable interactive prompts (CI/agent mode)")}
|
|
291
|
+
${r("--version")} ${m("Print version and exit")}
|
|
292
|
+
${r("--help")} ${m("Show help")}
|
|
235
293
|
|
|
236
|
-
${
|
|
294
|
+
${i("Getting Help:")}
|
|
237
295
|
${m("Add --help after any command to see its full list of options, defaults,")}
|
|
238
296
|
${m("and usage examples. For example:")} mmx text chat --help
|
|
239
|
-
`)}printCommandHelp(t,n,
|
|
297
|
+
`)}printCommandHelp(t,n,e="global"){let i=($)=>this.bold($,n),r=($)=>this.accent($,n),m=($)=>this.dim($,n);if(n.write(`
|
|
240
298
|
${t.description}
|
|
241
|
-
`),t.usage)n.write(`${
|
|
242
|
-
`);if(t.options&&t.options.length>0){let
|
|
243
|
-
${
|
|
244
|
-
`);for(let
|
|
299
|
+
`),t.usage)n.write(`${i("Usage:")} ${t.usage}
|
|
300
|
+
`);if(t.options&&t.options.length>0){let $=Math.max(...t.options.map((p)=>p.flag.length));n.write(`
|
|
301
|
+
${i("Options:")}
|
|
302
|
+
`);for(let p of t.options)n.write(` ${r(p.flag.padEnd($+2))} ${m(p.description)}
|
|
245
303
|
`)}if(t.examples&&t.examples.length>0){n.write(`
|
|
246
|
-
${
|
|
247
|
-
`);for(let
|
|
304
|
+
${i("Examples:")}
|
|
305
|
+
`);for(let $ of t.examples)n.write(` ${m($)}
|
|
248
306
|
`)}if(t.apiDocs)n.write(`
|
|
249
|
-
${
|
|
307
|
+
${i("API Reference:")} ${m(Qt[e]+t.apiDocs)}
|
|
250
308
|
`);n.write(`
|
|
251
309
|
${m("Global flags (--api-key, --output, --quiet, etc.) are always available.")}
|
|
252
310
|
`),n.write(`${m("Run")} mmx --help ${m("for the full list.")}
|
|
253
|
-
`)}printChildren(t,n,
|
|
254
|
-
`)}}var
|
|
311
|
+
`)}printChildren(t,n,e){let i=[],r=($,p)=>{for(let[o,w]of $.children){if(w.command)i.push({fullName:`${p} ${o}`,description:w.command.description});if(w.children.size>0)r(w,`${p} ${o}`)}};r(t,n);let m=Math.max(...i.map(($)=>$.fullName.length));for(let{fullName:$,description:p}of i)e.write(` ${this.accent($.padEnd(m),e)} ${this.dim(p,e)}
|
|
312
|
+
`)}}var $t;var _n=b(()=>{k();h();g();We();Ke();Ie();se();Fe();ge();ei();ri();vi();Ri();ji();Ai();ki();Yi();Zi();Vi();zi();Oi();Hi();Pi();li();Li();Fi();fi();Di();$t=new gi({"auth login":ze,"auth status":Ue,"auth refresh":He,"auth logout":Pe,"text chat":Ce,"text repl":De,"speech synthesize":p$,"speech generate":p$,"speech voices":ii,"image generate":ci,"video generate":Si,"video task get":qi,"video download":Bi,"music generate":hi,"music cover":Xi,"search query":_$,"search web":_$,"vision describe":Qi,"quota show":Ni,"config show":Wi,"config set":Ki,"config export-schema":Ii,"file upload":si,"file list":Ei,"file delete":Ci,update:di,help:ai})});function An(t){return t.replace(/-([a-z])/g,(n,e)=>e.toUpperCase())}function cr(t){let n=t.flag.match(/^--([a-z][a-z0-9-]*)/i);return n?An(n[1]):null}function vr(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 c$(t){let n=new Set,e=new Set,i=new Set;for(let r of t){let m=cr(r);if(!m)continue;if(vr(r))n.add(m);else if(r.type==="number")e.add(m);else if(r.type==="array")i.add(m)}return{booleans:n,numbers:e,arrays:i}}function v$(t,n=[]){let e=c$(n),i=[],r=0;while(r<t.length){let m=t[r];if(m==="--")break;if(m.startsWith("--")){let $=m.indexOf("="),p=$!==-1?m.slice(2,$):m.slice(2),o=An(p);if(!e.booleans.has(o)&&$===-1)r+=2;else r+=1;continue}if(m.startsWith("-")){r++;continue}i.push(m),r++}return i}function Jn(t,n){let e=c$(n),i={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},r=0;while(r<t.length){let m=t[r];if(m==="--help"||m==="-h"){i.help=!0,r++;continue}if(m==="--")break;if(m.startsWith("--")){let $=m.indexOf("="),p,o;if($!==-1)p=m.slice(2,$),o=m.slice($+1);else p=m.slice(2);let w=An(p);if(e.booleans.has(w)){i[w]=!0,r++;continue}if(o===void 0)r++,o=t[r];if(o===void 0)throw Error(`Flag --${p} requires a value.`);if(e.arrays.has(w)){let u=i[w];if(u)u.push(o);else i[w]=[o]}else if(e.numbers.has(w)){let u=Number(o);if(o.trim()===""||!Number.isFinite(u))throw Error(`Flag --${p} requires a numeric value, got "${o}".`);i[w]=u}else i[w]=o}r++}return i}_n();V();k();h();W();function Rt(t){if(t instanceof _){if(A(process.env.MINIMAX_OUTPUT)==="json")process.stderr.write(JSON.stringify(t.toJSON(),null,2)+`
|
|
255
313
|
`);else{if(process.stderr.write(`
|
|
256
314
|
Error: ${t.message}
|
|
257
315
|
`),t.hint)process.stderr.write(`
|
|
@@ -259,32 +317,25 @@ Error: ${t.message}
|
|
|
259
317
|
`).join(`
|
|
260
318
|
`)}
|
|
261
319
|
`);process.stderr.write(` (exit code ${t.exitCode})
|
|
262
|
-
`)}process.exit(t.exitCode)}if(t instanceof Error){if(t.name==="AbortError"||t.name==="TimeoutError"||t.message.includes("timed out")){let
|
|
320
|
+
`)}process.exit(t.exitCode)}if(t instanceof Error){if(t.name==="AbortError"||t.name==="TimeoutError"||t.message.includes("timed out")){let r=new _("Request timed out.",y.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
|
|
263
321
|
If this happens on every request with a valid API key, you may be hitting the wrong region.
|
|
264
322
|
`+`Run: mmx auth status — to check your credentials and region.
|
|
265
|
-
`+"Run: mmx config set region global (or cn) — to override the region.");return
|
|
266
|
-
To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`);return
|
|
267
|
-
To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`;if(n.includes("proxy"))
|
|
268
|
-
`+"Check: HTTPS_PROXY / HTTP_PROXY env vars, or mmx config show for configured proxy.";let m=new
|
|
323
|
+
`+"Run: mmx config set region global (or cn) — to override the region.");return Rt(r)}if(t instanceof TypeError&&t.message==="fetch failed"){let r=new _("Network request failed.",y.NETWORK,`Check your network connection.
|
|
324
|
+
To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`);return Rt(r)}let n=t.message.toLowerCase();if(n.includes("failed to fetch")||n.includes("connection refused")||n.includes("econnrefused")||n.includes("connection reset")||n.includes("econnreset")||n.includes("network error")||n.includes("enotfound")||n.includes("getaddrinfo")||n.includes("proxy")||n.includes("socket")||n.includes("etimedout")||n.includes("timeout")||n.includes("eai_AGAIN")){let r=`Check your network connection.
|
|
325
|
+
To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`;if(n.includes("proxy"))r=`Proxy connection failed — verify your proxy URL and authentication.
|
|
326
|
+
`+"Check: HTTPS_PROXY / HTTP_PROXY env vars, or mmx config show for configured proxy.";let m=new _("Network request failed.",y.NETWORK,r);return Rt(m)}let i=t.code;if(i==="ENOENT"||i==="EACCES"||i==="ENOSPC"||i==="ENOTDIR"||i==="EISDIR"||i==="EPERM"||i==="EBUSY"){let r="Check the file path and permissions.";if(i==="ENOENT")r="File or directory not found.";if(i==="EACCES"||i==="EPERM")r="Permission denied — check file or directory permissions.";if(i==="ENOSPC")r="Disk full — free up space and try again.";let m=new _(`File system error: ${t.message}`,y.GENERAL,r);return Rt(m)}else if(typeof i==="string"&&i.startsWith("E")){let r=new _(`File system error: ${t.message}`,y.GENERAL,"Check the file path and permissions.");return Rt(r)}if(process.stderr.write(`
|
|
269
327
|
Error: ${t.message}
|
|
270
328
|
`),process.env.MINIMAX_VERBOSE==="1")process.stderr.write(`${t.stack}
|
|
271
329
|
`)}else process.stderr.write(`
|
|
272
330
|
Error: ${String(t)}
|
|
273
|
-
`);process.exit(
|
|
274
|
-
`),process.stderr.write(`Warning: API key failed validation against all regions (global, cn).
|
|
275
|
-
This usually means the API key is invalid or the network is blocking requests.
|
|
276
|
-
Falling back to 'global'. Subsequent requests may fail.
|
|
277
|
-
Run 'mmx auth status' to verify your credentials.
|
|
278
|
-
`),"global";let o=r.region;return process.stderr.write(` ${o}
|
|
279
|
-
`),o}async function Ti(t){let n=J();n.region=t,await a(n)}import{join as Do}from"path";import{readFileSync as tm,writeFileSync as nm}from"fs";var Gi=()=>Do(wt(),"update-state.json"),em=86400000,im=3000,rm="MiniMax-AI-Dev/minimax-cli";function om(){try{let t=tm(Gi(),"utf-8");return JSON.parse(t)}catch{return null}}function mm(t){try{nm(Gi(),JSON.stringify(t))}catch{}}async function $m(){try{let t=await fetch(`https://api.github.com/repos/${rm}/releases/latest`,{headers:{Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},signal:AbortSignal.timeout(im)});if(!t.ok)return null;return(await t.json()).tag_name??null}catch{return null}}var Xn=null;function li(){return Xn}async function Bi(t){if(process.env.CI||!process.stderr.isTTY)return;let n=om(),i=Date.now();if(n&&i-n.lastChecked<em){if(n.latestVersion&&n.latestVersion!==`v${t}`)Xn=n.latestVersion;return}let r=await $m();if(!r)return;if(mm({lastChecked:i,latestVersion:r}),r!==`v${t}`)Xn=r}async function qi(t){if(t.apiKey||t.fileApiKey)return;let n=process.env.MINIMAX_API_KEY,i;if(n){if(!Q({nonInteractive:t.nonInteractive}))i=n;else if(await He({message:`Found MINIMAX_API_KEY in environment (${W(n)}). Save it to config file?`}))i=n}if(!i){if(!Q({nonInteractive:t.nonInteractive}))throw new s("No API key found.",u.AUTH,`Set env var: export MINIMAX_API_KEY=sk-xxxxx
|
|
280
|
-
Pass directly: --api-key sk-xxxxx`);let m=await it({message:"Enter your MiniMax API key:"});if(!m)throw new s("API key is required.",u.AUTH);i=m}let r={...J(),api_key:i};await a(r),t.fileApiKey=i;let o=t.configPath??"~/.mmx/config.json";process.stderr.write(`API key saved to ${o}
|
|
281
|
-
`)}import{ProxyAgent as pm,setGlobalDispatcher as um}from"undici";process.on("SIGINT",()=>{process.stderr.write(`
|
|
331
|
+
`);process.exit(y.GENERAL)}nt();n$();g();Vt();import{join as Wp}from"path";import{readFileSync as Op,writeFileSync as Up}from"fs";var tr=()=>Wp(lt(),"update-state.json"),Kp=86400000,Hp=3000,Ip="MiniMax-AI-Dev/minimax-cli";function Pp(){try{let t=Op(tr(),"utf-8");return JSON.parse(t)}catch{return null}}function sp(t){try{Up(tr(),JSON.stringify(t))}catch{}}async function lp(){try{let t=await fetch(`https://api.github.com/repos/${Ip}/releases/latest`,{headers:{Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},signal:AbortSignal.timeout(Hp)});if(!t.ok)return null;return(await t.json()).tag_name??null}catch{return null}}var u$=null;function nr(){return u$}async function $r(t){if(process.env.CI||!process.stderr.isTTY)return;let n=Pp(),e=Date.now();if(n&&e-n.lastChecked<Kp){if(n.latestVersion&&n.latestVersion!==`v${t}`)u$=n.latestVersion;return}let i=await lp();if(!i)return;if(sp({lastChecked:e,latestVersion:i}),i!==`v${t}`)u$=i}pt();dn();nn();import{ProxyAgent as Ep,setGlobalDispatcher as Lp}from"undici";process.on("SIGINT",()=>{process.stderr.write(`
|
|
282
332
|
Interrupted. Exiting.
|
|
283
|
-
`),process.exit(130)});process.stdout.on("error",(t)=>{if(t.code==="EPIPE")process.exit(0);else throw t});var
|
|
284
|
-
`),process.stderr.write(` mmx auth login
|
|
333
|
+
`),process.exit(130)});process.stdout.on("error",(t)=>{if(t.code==="EPIPE")process.exit(0);else throw t});var Cp=[["auth","login"],["auth","logout"],["config","show"],["config","set"],["config","export-schema"],["update"]];async function Fp(){let t=process.argv.slice(2);if(t.includes("--version")||t.includes("-v"))console.log(`mmx ${bt}`),process.exit(0);let n=v$(t,st),e=O(),i=process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy||e.proxy;if(i)Lp(new Ep(i));if(t.includes("--help")||t.includes("-h")){let M=t.indexOf("--region"),c=M>=0&&t[M+1]||process.env.MINIMAX_REGION||e.region||"global";$t.printHelp(n,process.stderr,c),process.exit(0)}if(n.length===0){$t.printHelp([],process.stderr);let{command:M}=$t.resolve(["quota","show"]),c=Jn(t,[...st,...M.options??[]]),v=hn(c),S=!!(v.apiKey||v.fileApiKey),R=!!await L();if(S||R)await M.execute(v,c);else process.stderr.write(` Not logged in.
|
|
334
|
+
`),process.stderr.write(` mmx auth login Choose MiniMax OAuth (Global/China) or paste an API key
|
|
335
|
+
`),process.stderr.write(` mmx auth login --api-key Save an API key directly
|
|
285
336
|
|
|
286
|
-
`);process.exit(0)}let{command:
|
|
287
|
-
Update available: ${
|
|
337
|
+
`);process.exit(0)}let{command:r,extra:m}=$t.resolve(n),$=Jn(t,[...st,...r.options??[]]);if(m.length>0)$._positional=m;let p=hn($);if(!Cp.some((M)=>M.every((c,v)=>n[v]===c)))await pe(p);if(p.needsRegionDetection){let M=p.apiKey||p.fileApiKey;if(M){let c=await yn(M);p.region=c,p.baseUrl=K[c],p.needsRegionDetection=!1,await Ze(c)}}let w=$r(bt).catch(()=>{});await r.execute(p,$),await w;let u=nr();if(u&&!p.quiet)process.stderr.write(`
|
|
338
|
+
Update available: ${u}
|
|
288
339
|
`),process.stderr.write(` npm update -g mmx-cli
|
|
289
340
|
|
|
290
|
-
`)}
|
|
341
|
+
`)}Fp().catch(Rt);
|