mmx-cli 1.0.29 → 1.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/mmx.mjs +68 -68
  2. package/package.json +1 -1
package/dist/mmx.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as jm}from"node:module";var Pm=Object.create;var{getPrototypeOf:Lm,defineProperty:Xa,getOwnPropertyNames:Fm}=Object;var Qa=Object.prototype.hasOwnProperty;function qm(e){return this[e]}var Dm,Um,Ft=(e,t,n)=>{var i=e!=null&&typeof e==="object";if(i){var r=t?Dm??=new WeakMap:Um??=new WeakMap,s=r.get(e);if(s)return s}n=e!=null?Pm(Lm(e)):{};let o=t||!e||!e.__esModule||!Qa.call(e,"default")?Xa(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Fm(e))if(!Qa.call(o,a))Xa(o,a,{get:qm.bind(e,a),enumerable:!0})}if(i)r.set(e,o);return o};var M=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var I=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(i){n=[i]}if(n)throw n[0];return t};var an=jm(import.meta.url);var b;var j=I(()=>{b={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONTENT_FILTER:10}});var y;var G=I(()=>{j();y=class y extends Error{exitCode;hint;constructor(e,t=b.GENERAL,n){super(e);this.name="CLIError",this.exitCode=t,this.hint=n}toJSON(){return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{}}}}}});function Wm(e){if(!e||typeof e!=="object"||Array.isArray(e))return;let t=e;if(typeof t.access_token!=="string"||!t.access_token)return;if(typeof t.refresh_token!=="string")return;if(typeof t.expires_at!=="string")return;let n={access_token:t.access_token,refresh_token:t.refresh_token,expires_at:t.expires_at};if(typeof t.region==="string"&&el.has(t.region))n.region=t.region;if(typeof t.resource_url==="string"&&t.resource_url.startsWith("http"))n.resource_url=t.resource_url;if(typeof t.account==="string"&&t.account.length>0)n.account=t.account;return n}function tl(e){if(!e||typeof e!=="object"||Array.isArray(e))return{};let t=e,n={};if(typeof t.api_key==="string")n.api_key=t.api_key;if(typeof t.region==="string"&&el.has(t.region))n.region=t.region;if(typeof t.base_url==="string"&&t.base_url.startsWith("http"))n.base_url=t.base_url;if(typeof t.output==="string"&&Km.has(t.output))n.output=t.output;if(typeof t.timeout==="number"&&t.timeout>0)n.timeout=t.timeout;if(typeof t.proxy==="string"&&t.proxy.startsWith("http"))n.proxy=t.proxy;let i=Wm(t.oauth);if(i)n.oauth=i;if(typeof t.default_text_model==="string"&&t.default_text_model.length>0)n.default_text_model=t.default_text_model;if(typeof t.default_speech_model==="string"&&t.default_speech_model.length>0)n.default_speech_model=t.default_speech_model;if(typeof t.default_video_model==="string"&&t.default_video_model.length>0)n.default_video_model=t.default_video_model;return n}var ne,pt,si,el,Km;var $e=I(()=>{ne={global:"https://api.minimax.io",cn:"https://api.minimax.cn"},pt={global:"https://platform.minimax.io",cn:"https://platform.minimax.cn"},si={global:"https://account.minimax.io",cn:"https://account.minimaxi.com"},el=new Set(["global","cn"]),Km=new Set(["text","json"])});function N(e){return{name:e.name,description:e.description,usage:e.usage,options:e.options,examples:e.examples,apiDocs:e.apiDocs,execute:e.run}}var ln;var X=I(()=>{ln=[{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 Jm}from"os";import{join as nl}from"path";function oi(){if(process.env.MMX_CONFIG_DIR)return process.env.MMX_CONFIG_DIR;return nl(Jm(),Ym)}function fe(){return nl(oi(),"config.json")}async function il(e=oi()){let t=await import("fs/promises");await t.mkdir(e,{recursive:!0,mode:448})}var Ym=".mmx";var Xe=()=>{};function rl(e){if(e===null||e===void 0)return"";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean")return String(e);if(Array.isArray(e)){if(e.length===0)return"(empty)";if(typeof e[0]==="object"&&e[0]!==null)return Qr(e);return e.map(String).join(`
2
+ import{createRequire as jm}from"node:module";var Lm=Object.create;var{getPrototypeOf:Pm,defineProperty:Xa,getOwnPropertyNames:Fm}=Object;var Qa=Object.prototype.hasOwnProperty;function qm(e){return this[e]}var Dm,Um,Ft=(e,t,n)=>{var i=e!=null&&typeof e==="object";if(i){var r=t?Dm??=new WeakMap:Um??=new WeakMap,s=r.get(e);if(s)return s}n=e!=null?Lm(Pm(e)):{};let o=t||!e||!e.__esModule||!Qa.call(e,"default")?Xa(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Fm(e))if(!Qa.call(o,a))Xa(o,a,{get:qm.bind(e,a),enumerable:!0})}if(i)r.set(e,o);return o};var M=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var I=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(i){n=[i]}if(n)throw n[0];return t};var an=jm(import.meta.url);var b;var j=I(()=>{b={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONTENT_FILTER:10}});var y;var G=I(()=>{j();y=class y extends Error{exitCode;hint;constructor(e,t=b.GENERAL,n){super(e);this.name="CLIError",this.exitCode=t,this.hint=n}toJSON(){return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{}}}}}});function Wm(e){if(!e||typeof e!=="object"||Array.isArray(e))return;let t=e;if(typeof t.access_token!=="string"||!t.access_token)return;if(typeof t.refresh_token!=="string")return;if(typeof t.expires_at!=="string")return;let n={access_token:t.access_token,refresh_token:t.refresh_token,expires_at:t.expires_at};if(typeof t.region==="string"&&el.has(t.region))n.region=t.region;if(typeof t.resource_url==="string"&&t.resource_url.startsWith("http"))n.resource_url=t.resource_url;if(typeof t.account==="string"&&t.account.length>0)n.account=t.account;return n}function tl(e){if(!e||typeof e!=="object"||Array.isArray(e))return{};let t=e,n={};if(typeof t.api_key==="string")n.api_key=t.api_key;if(typeof t.region==="string"&&el.has(t.region))n.region=t.region;if(typeof t.base_url==="string"&&t.base_url.startsWith("http"))n.base_url=t.base_url;if(typeof t.output==="string"&&Km.has(t.output))n.output=t.output;if(typeof t.timeout==="number"&&t.timeout>0)n.timeout=t.timeout;if(typeof t.proxy==="string"&&t.proxy.startsWith("http"))n.proxy=t.proxy;let i=Wm(t.oauth);if(i)n.oauth=i;if(typeof t.default_text_model==="string"&&t.default_text_model.length>0)n.default_text_model=t.default_text_model;if(typeof t.default_speech_model==="string"&&t.default_speech_model.length>0)n.default_speech_model=t.default_speech_model;if(typeof t.default_video_model==="string"&&t.default_video_model.length>0)n.default_video_model=t.default_video_model;return n}var ne,pt,si,el,Km;var $e=I(()=>{ne={global:"https://api.minimax.io",cn:"https://api.minimax.cn"},pt={global:"https://platform.minimax.io",cn:"https://platform.minimax.cn"},si={global:"https://account.minimax.io",cn:"https://account.minimaxi.com"},el=new Set(["global","cn"]),Km=new Set(["text","json"])});function N(e){return{name:e.name,description:e.description,usage:e.usage,options:e.options,examples:e.examples,apiDocs:e.apiDocs,execute:e.run}}var ln;var X=I(()=>{ln=[{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 Jm}from"os";import{join as nl}from"path";function oi(){if(process.env.MMX_CONFIG_DIR)return process.env.MMX_CONFIG_DIR;return nl(Jm(),Ym)}function fe(){return nl(oi(),"config.json")}async function il(e=oi()){let t=await import("fs/promises");await t.mkdir(e,{recursive:!0,mode:448})}var Ym=".mmx";var Xe=()=>{};function rl(e){if(e===null||e===void 0)return"";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean")return String(e);if(Array.isArray(e)){if(e.length===0)return"(empty)";if(typeof e[0]==="object"&&e[0]!==null)return Qr(e);return e.map(String).join(`
3
3
  `)}if(typeof e==="object")return Xr(e);return String(e)}function Xr(e,t=0){let n=" ".repeat(t),i=[];for(let[r,s]of Object.entries(e)){if(s===null||s===void 0)continue;if(Array.isArray(s)){i.push(`${n}${r}:`);for(let o of s)if(typeof o==="object"&&o!==null)i.push(`${n} - ${Xr(o,t+4).trimStart()}`);else i.push(`${n} - ${String(o)}`)}else if(typeof s==="object")i.push(`${n}${r}:`),i.push(Xr(s,t+2));else i.push(`${n}${r}: ${String(s)}`)}return i.join(`
4
4
  `)}function Qr(e){if(e.length===0)return"(empty)";let t=Object.keys(e[0]),n=t.map((o)=>Math.max(o.length,...e.map((a)=>String(a[o]??"").length))),i=t.map((o,a)=>o.toUpperCase().padEnd(n[a])).join(" "),r=n.map((o)=>"-".repeat(o)).join(" "),s=e.map((o)=>t.map((a,l)=>String(o[a]??"").padEnd(n[l])).join(" "));return[i,r,...s].join(`
5
5
  `)}function sl(e){return JSON.stringify(e,null,2)}function F(e){if(e==="json"||e==="text")return e;if(!process.stdout.isTTY)return"json";return"text"}function O(e,t){switch(t){case"json":return sl(e);case"text":return rl(e)}}function _e(e,t){if(!e.dryRun)return!1;return console.log(O({request:t},F(e.output))),!0}var ee=()=>{};import{copyFileSync as zm,existsSync as Xm,readFileSync as Qm,renameSync as Zm,unlinkSync as eh,writeFileSync as th}from"fs";import{dirname as nh}from"path";function ih(e){return e instanceof Error&&"code"in e&&e.code==="EXDEV"}function rh(e,t,n={rename:Zm,copy:zm,unlink:eh}){try{n.rename(e,t)}catch(i){if(!ih(i))throw i;n.copy(e,t),n.unlink(e)}}function Z(e=fe()){if(!Xm(e))return{};try{return tl(JSON.parse(Qm(e,"utf-8")))}catch(t){let n=t;if(n instanceof SyntaxError||n.message.includes("JSON"))process.stderr.write(`Warning: config file is corrupted. Run 'mmx config set' to reset.
@@ -24,11 +24,11 @@ import{createRequire as jm}from"node:module";var Pm=Object.create;var{getPrototy
24
24
  `,`
25
25
  `).split(`
26
26
  `).map((i)=>Hh(i,t,n)).join(`
27
- `)}var T,hn,ws,kh=()=>process.env.CI==="true",Y=(e,t)=>ws?e:t,Th,Al,kl,Ss,Kk,K,qt,Wk,Jk,xs,wi,Ih,xl,vl,Yk,Sl,Mh,Oh,Ch,Nh,zk,Xk,Qk,Zk,e2,xi=(e)=>{switch(e){case"initial":case"active":return T.default.cyan(Th);case"cancel":return T.default.red(Al);case"error":return T.default.yellow(kl);case"submit":return T.default.green(Ss)}},Tl=(e)=>{switch(e){case"initial":case"active":return T.default.cyan(K);case"cancel":return T.default.red(K);case"error":return T.default.yellow(K);case"submit":return T.default.green(K)}},Rh=(e)=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||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||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,Ph=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Lh=(e)=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,gs,hi,gi,ys,yi,Fh,qh,Il=(e,t={},n={})=>{let i=t.limit??1/0,r=t.ellipsis??"",s=t?.ellipsisWidth??(r?Il(r,qh,n).width:0),o=n.ansiWidth??0,a=n.controlWidth??0,l=n.tabWidth??8,c=n.ambiguousWidth??1,p=n.emojiWidth??2,u=n.fullWidthWidth??2,f=n.regularWidth??1,g=n.wideWidth??2,h=0,d=0,m=e.length,v=0,w=!1,x=m,E=Math.max(0,i-s),A=0,_=0,S=0,k=0;e:for(;;){if(_>A||d>=m&&d>h){let R=e.slice(A,_)||e.slice(h,d);v=0;for(let U of R.replaceAll(Fh,"")){let q=U.codePointAt(0)||0;if(Ph(q)?k=u:Lh(q)?k=g:c!==f&&Rh(q)?k=c:k=f,S+k>E&&(x=Math.min(x,Math.max(A,h)+v)),S+k>i){w=!0;break e}v+=U.length,S+=k}A=_=0}if(d>=m)break;if(yi.lastIndex=d,yi.test(e)){if(v=yi.lastIndex-d,k=v*f,S+k>E&&(x=Math.min(x,d+Math.floor((E-S)/f))),S+k>i){w=!0;break}S+=k,A=h,_=d,d=h=yi.lastIndex;continue}if(gs.lastIndex=d,gs.test(e)){if(S+o>E&&(x=Math.min(x,d)),S+o>i){w=!0;break}S+=o,A=h,_=d,d=h=gs.lastIndex;continue}if(hi.lastIndex=d,hi.test(e)){if(v=hi.lastIndex-d,k=v*a,S+k>E&&(x=Math.min(x,d+Math.floor((E-S)/a))),S+k>i){w=!0;break}S+=k,A=h,_=d,d=h=hi.lastIndex;continue}if(gi.lastIndex=d,gi.test(e)){if(v=gi.lastIndex-d,k=v*l,S+k>E&&(x=Math.min(x,d+Math.floor((E-S)/l))),S+k>i){w=!0;break}S+=k,A=h,_=d,d=h=gi.lastIndex;continue}if(ys.lastIndex=d,ys.test(e)){if(S+p>E&&(x=Math.min(x,d)),S+p>i){w=!0;break}S+=p,A=h,_=d,d=h=ys.lastIndex;continue}d+=1}return{width:w?E:S,index:w?x:m,truncated:w,ellipsed:w&&i>=s}},Dh,Pe=(e,t={})=>Il(e,Dh,t).width,vi="\x1B",Ml="›",Uh=39,$s="\x07",Ol="[",jh="]",Cl="m",_s,$l,Gh=(e)=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},_l=(e)=>`${vi}${Ol}${e}${Cl}`,El=(e)=>`${vi}${_s}${e}${$s}`,Bh=(e)=>e.map((t)=>Pe(t)),bs=(e,t,n)=>{let i=t[Symbol.iterator](),r=!1,s=!1,o=e.at(-1),a=o===void 0?0:Pe(o),l=i.next(),c=i.next(),p=0;for(;!l.done;){let u=l.value,f=Pe(u);a+f<=n?e[e.length-1]+=u:(e.push(u),a=0),(u===vi||u===Ml)&&(r=!0,s=t.startsWith(_s,p+1)),r?s?u===$s&&(r=!1,s=!1):u===Cl&&(r=!1):(a+=f,a===n&&!c.done&&(e.push(""),a=0)),l=c,c=i.next(),p+=u.length}o=e.at(-1),!a&&o!==void 0&&o.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Vh=(e)=>{let t=e.split(" "),n=t.length;for(;n>0&&!(Pe(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},Hh=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let i="",r,s,o=e.split(" "),a=Bh(o),l=[""];for(let[h,d]of o.entries()){n.trim!==!1&&(l[l.length-1]=(l.at(-1)??"").trimStart());let m=Pe(l.at(-1)??"");if(h!==0&&(m>=t&&(n.wordWrap===!1||n.trim===!1)&&(l.push(""),m=0),(m>0||n.trim===!1)&&(l[l.length-1]+=" ",m++)),n.hard&&a[h]>t){let v=t-m,w=1+Math.floor((a[h]-v-1)/t);Math.floor((a[h]-1)/t)<w&&l.push(""),bs(l,d,t);continue}if(m+a[h]>t&&m>0&&a[h]>0){if(n.wordWrap===!1&&m<t){bs(l,d,t);continue}l.push("")}if(m+a[h]>t&&n.wordWrap===!1){bs(l,d,t);continue}l[l.length-1]+=d}n.trim!==!1&&(l=l.map((h)=>Vh(h)));let c=l.join(`
27
+ `)}var T,hn,ws,kh=()=>process.env.CI==="true",Y=(e,t)=>ws?e:t,Th,Al,kl,Ss,Kk,K,qt,Wk,Jk,xs,wi,Ih,xl,vl,Yk,Sl,Mh,Oh,Ch,Nh,zk,Xk,Qk,Zk,e2,xi=(e)=>{switch(e){case"initial":case"active":return T.default.cyan(Th);case"cancel":return T.default.red(Al);case"error":return T.default.yellow(kl);case"submit":return T.default.green(Ss)}},Tl=(e)=>{switch(e){case"initial":case"active":return T.default.cyan(K);case"cancel":return T.default.red(K);case"error":return T.default.yellow(K);case"submit":return T.default.green(K)}},Rh=(e)=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||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||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,Lh=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Ph=(e)=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,gs,hi,gi,ys,yi,Fh,qh,Il=(e,t={},n={})=>{let i=t.limit??1/0,r=t.ellipsis??"",s=t?.ellipsisWidth??(r?Il(r,qh,n).width:0),o=n.ansiWidth??0,a=n.controlWidth??0,l=n.tabWidth??8,c=n.ambiguousWidth??1,p=n.emojiWidth??2,u=n.fullWidthWidth??2,f=n.regularWidth??1,g=n.wideWidth??2,h=0,d=0,m=e.length,v=0,w=!1,x=m,E=Math.max(0,i-s),A=0,_=0,S=0,k=0;e:for(;;){if(_>A||d>=m&&d>h){let R=e.slice(A,_)||e.slice(h,d);v=0;for(let U of R.replaceAll(Fh,"")){let q=U.codePointAt(0)||0;if(Lh(q)?k=u:Ph(q)?k=g:c!==f&&Rh(q)?k=c:k=f,S+k>E&&(x=Math.min(x,Math.max(A,h)+v)),S+k>i){w=!0;break e}v+=U.length,S+=k}A=_=0}if(d>=m)break;if(yi.lastIndex=d,yi.test(e)){if(v=yi.lastIndex-d,k=v*f,S+k>E&&(x=Math.min(x,d+Math.floor((E-S)/f))),S+k>i){w=!0;break}S+=k,A=h,_=d,d=h=yi.lastIndex;continue}if(gs.lastIndex=d,gs.test(e)){if(S+o>E&&(x=Math.min(x,d)),S+o>i){w=!0;break}S+=o,A=h,_=d,d=h=gs.lastIndex;continue}if(hi.lastIndex=d,hi.test(e)){if(v=hi.lastIndex-d,k=v*a,S+k>E&&(x=Math.min(x,d+Math.floor((E-S)/a))),S+k>i){w=!0;break}S+=k,A=h,_=d,d=h=hi.lastIndex;continue}if(gi.lastIndex=d,gi.test(e)){if(v=gi.lastIndex-d,k=v*l,S+k>E&&(x=Math.min(x,d+Math.floor((E-S)/l))),S+k>i){w=!0;break}S+=k,A=h,_=d,d=h=gi.lastIndex;continue}if(ys.lastIndex=d,ys.test(e)){if(S+p>E&&(x=Math.min(x,d)),S+p>i){w=!0;break}S+=p,A=h,_=d,d=h=ys.lastIndex;continue}d+=1}return{width:w?E:S,index:w?x:m,truncated:w,ellipsed:w&&i>=s}},Dh,Le=(e,t={})=>Il(e,Dh,t).width,vi="\x1B",Ml="›",Uh=39,$s="\x07",Ol="[",jh="]",Cl="m",_s,$l,Gh=(e)=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},_l=(e)=>`${vi}${Ol}${e}${Cl}`,El=(e)=>`${vi}${_s}${e}${$s}`,Bh=(e)=>e.map((t)=>Le(t)),bs=(e,t,n)=>{let i=t[Symbol.iterator](),r=!1,s=!1,o=e.at(-1),a=o===void 0?0:Le(o),l=i.next(),c=i.next(),p=0;for(;!l.done;){let u=l.value,f=Le(u);a+f<=n?e[e.length-1]+=u:(e.push(u),a=0),(u===vi||u===Ml)&&(r=!0,s=t.startsWith(_s,p+1)),r?s?u===$s&&(r=!1,s=!1):u===Cl&&(r=!1):(a+=f,a===n&&!c.done&&(e.push(""),a=0)),l=c,c=i.next(),p+=u.length}o=e.at(-1),!a&&o!==void 0&&o.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Vh=(e)=>{let t=e.split(" "),n=t.length;for(;n>0&&!(Le(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},Hh=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let i="",r,s,o=e.split(" "),a=Bh(o),l=[""];for(let[h,d]of o.entries()){n.trim!==!1&&(l[l.length-1]=(l.at(-1)??"").trimStart());let m=Le(l.at(-1)??"");if(h!==0&&(m>=t&&(n.wordWrap===!1||n.trim===!1)&&(l.push(""),m=0),(m>0||n.trim===!1)&&(l[l.length-1]+=" ",m++)),n.hard&&a[h]>t){let v=t-m,w=1+Math.floor((a[h]-v-1)/t);Math.floor((a[h]-1)/t)<w&&l.push(""),bs(l,d,t);continue}if(m+a[h]>t&&m>0&&a[h]>0){if(n.wordWrap===!1&&m<t){bs(l,d,t);continue}l.push("")}if(m+a[h]>t&&n.wordWrap===!1){bs(l,d,t);continue}l[l.length-1]+=d}n.trim!==!1&&(l=l.map((h)=>Vh(h)));let c=l.join(`
28
28
  `),p=c[Symbol.iterator](),u=p.next(),f=p.next(),g=0;for(;!u.done;){let h=u.value,d=f.value;if(i+=h,h===vi||h===Ml){$l.lastIndex=g+1;let v=$l.exec(c)?.groups;if(v?.code!==void 0){let w=Number.parseFloat(v.code);r=w===Uh?void 0:w}else v?.uri!==void 0&&(s=v.uri.length===0?void 0:v.uri)}let m=r?Gh(r):void 0;d===`
29
29
  `?(s&&(i+=El("")),r&&m&&(i+=_l(m))):h===`
30
30
  `&&(r&&m&&(i+=_l(r)),s&&(i+=El(s))),g+=h.length,u=f,f=p.next()}return i},Kh=(e,t,n,i,r)=>{let s=t,o=0;for(let a=n;a<i;a++){let l=e[a];if(s=s-l.length,o++,s<=r)break}return{lineCount:s,removals:o}},vs=(e)=>{let{cursor:t,options:n,style:i}=e,r=e.output??process.stdout,s=fn(r),o=e.columnPadding??0,a=e.rowPadding??4,l=s-o,c=ds(r),p=T.default.dim("..."),u=e.maxItems??Number.POSITIVE_INFINITY,f=Math.max(c-a,0),g=Math.max(Math.min(u,f),5),h=0;t>=g-3&&(h=Math.max(Math.min(t-g+3,n.length-g),0));let d=g<n.length&&h>0,m=g<n.length&&h+g<n.length,v=Math.min(h+g,n.length),w=[],x=0;d&&x++,m&&x++;let E=h+(d?1:0),A=v-(m?1:0);for(let S=E;S<A;S++){let k=gn(i(n[S],S===t),l,{hard:!0,trim:!1}).split(`
31
- `);w.push(k),x+=k.length}if(x>f){let S=0,k=0,R=x,U=t-E,q=(L,C)=>Kh(w,R,L,C,f);d?({lineCount:R,removals:S}=q(0,U),R>f&&({lineCount:R,removals:k}=q(U+1,w.length))):({lineCount:R,removals:k}=q(U+1,w.length),R>f&&({lineCount:R,removals:S}=q(0,U))),S>0&&(d=!0,w.splice(0,S)),k>0&&(m=!0,w.splice(w.length-k,k))}let _=[];d&&_.push(p);for(let S of w)for(let k of S)_.push(k);return m&&_.push(p),_},Es=(e)=>{let t=e.active??"Yes",n=e.inactive??"No";return new ps({active:t,inactive:n,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let i=`${T.default.gray(K)}
31
+ `);w.push(k),x+=k.length}if(x>f){let S=0,k=0,R=x,U=t-E,q=(P,C)=>Kh(w,R,P,C,f);d?({lineCount:R,removals:S}=q(0,U),R>f&&({lineCount:R,removals:k}=q(U+1,w.length))):({lineCount:R,removals:k}=q(U+1,w.length),R>f&&({lineCount:R,removals:S}=q(0,U))),S>0&&(d=!0,w.splice(0,S)),k>0&&(m=!0,w.splice(w.length-k,k))}let _=[];d&&_.push(p);for(let S of w)for(let k of S)_.push(k);return m&&_.push(p),_},Es=(e)=>{let t=e.active??"Yes",n=e.inactive??"No";return new ps({active:t,inactive:n,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let i=`${T.default.gray(K)}
32
32
  ${xi(this.state)} ${e.message}
33
33
  `,r=this.value?t:n;switch(this.state){case"submit":return`${i}${T.default.gray(K)} ${T.default.dim(r)}`;case"cancel":return`${i}${T.default.gray(K)} ${T.default.strikethrough(T.default.dim(r))}
34
34
  ${T.default.gray(K)}`;default:return`${i}${T.default.cyan(K)} ${this.value?`${T.default.green(xs)} ${t}`:`${T.default.dim(wi)} ${T.default.dim(t)}`} ${T.default.dim("/")} ${this.value?`${T.default.dim(wi)} ${T.default.dim(n)}`:`${T.default.green(xs)} ${n}`}
@@ -51,18 +51,18 @@ ${l}
51
51
  ${a}`)}
52
52
  ${T.default.cyan(qt)}
53
53
  `}}}}).prompt()},Jh=(e)=>T.default.dim(e),Yh=(e,t,n)=>{let i={hard:!0,trim:!1},r=gn(e,t,i).split(`
54
- `),s=r.reduce((l,c)=>Math.max(Pe(c),l),0),o=r.map(n).reduce((l,c)=>Math.max(Pe(c),l),0),a=t-(o-s);return gn(e,a,i)},zh=(e="",t="",n)=>{let i=n?.output??be.stdout,r=(n?.withGuide??Ne.withGuide)!==!1,s=n?.format??Jh,o=["",...Yh(e,fn(i)-6,s).split(`
55
- `).map(s),""],a=Pe(t),l=Math.max(o.reduce((f,g)=>{let h=Pe(g);return h>f?h:f},0),a)+2,c=o.map((f)=>`${T.default.gray(K)} ${f}${" ".repeat(l-Pe(f))}${T.default.gray(K)}`).join(`
54
+ `),s=r.reduce((l,c)=>Math.max(Le(c),l),0),o=r.map(n).reduce((l,c)=>Math.max(Le(c),l),0),a=t-(o-s);return gn(e,a,i)},zh=(e="",t="",n)=>{let i=n?.output??be.stdout,r=(n?.withGuide??Ne.withGuide)!==!1,s=n?.format??Jh,o=["",...Yh(e,fn(i)-6,s).split(`
55
+ `).map(s),""],a=Le(t),l=Math.max(o.reduce((f,g)=>{let h=Le(g);return h>f?h:f},0),a)+2,c=o.map((f)=>`${T.default.gray(K)} ${f}${" ".repeat(l-Le(f))}${T.default.gray(K)}`).join(`
56
56
  `),p=r?`${T.default.gray(K)}
57
57
  `:"",u=r?Oh:Nh;i.write(`${p}${T.default.green(Ss)} ${T.default.reset(t)} ${T.default.gray(Sl.repeat(Math.max(l-a-1,1))+Mh)}
58
58
  ${c}
59
59
  ${T.default.gray(u+Sl.repeat(l+2)+Ch)}
60
- `)},Xh,Nl=({indicator:e="dots",onCancel:t,output:n=process.stdout,cancelMessage:i,errorMessage:r,frames:s=ws?["◒","◐","◓","◑"]:["•","o","O","0"],delay:o=ws?80:120,signal:a,...l}={})=>{let c=kh(),p,u,f=!1,g=!1,h="",d,m=performance.now(),v=fn(n),w=l?.styleFrame??Xh,x=(C)=>{let P=C>1?r??Ne.messages.error:i??Ne.messages.cancel;g=C===1,f&&(L(P,C),g&&typeof t=="function"&&t())},E=()=>x(2),A=()=>x(1),_=()=>{process.on("uncaughtExceptionMonitor",E),process.on("unhandledRejection",E),process.on("SIGINT",A),process.on("SIGTERM",A),process.on("exit",x),a&&a.addEventListener("abort",A)},S=()=>{process.removeListener("uncaughtExceptionMonitor",E),process.removeListener("unhandledRejection",E),process.removeListener("SIGINT",A),process.removeListener("SIGTERM",A),process.removeListener("exit",x),a&&a.removeEventListener("abort",A)},k=()=>{if(d===void 0)return;c&&n.write(`
60
+ `)},Xh,Nl=({indicator:e="dots",onCancel:t,output:n=process.stdout,cancelMessage:i,errorMessage:r,frames:s=ws?["◒","◐","◓","◑"]:["•","o","O","0"],delay:o=ws?80:120,signal:a,...l}={})=>{let c=kh(),p,u,f=!1,g=!1,h="",d,m=performance.now(),v=fn(n),w=l?.styleFrame??Xh,x=(C)=>{let L=C>1?r??Ne.messages.error:i??Ne.messages.cancel;g=C===1,f&&(P(L,C),g&&typeof t=="function"&&t())},E=()=>x(2),A=()=>x(1),_=()=>{process.on("uncaughtExceptionMonitor",E),process.on("unhandledRejection",E),process.on("SIGINT",A),process.on("SIGTERM",A),process.on("exit",x),a&&a.addEventListener("abort",A)},S=()=>{process.removeListener("uncaughtExceptionMonitor",E),process.removeListener("unhandledRejection",E),process.removeListener("SIGINT",A),process.removeListener("SIGTERM",A),process.removeListener("exit",x),a&&a.removeEventListener("abort",A)},k=()=>{if(d===void 0)return;c&&n.write(`
61
61
  `);let C=gn(d,v,{hard:!0,trim:!1}).split(`
62
- `);C.length>1&&n.write(hn.cursor.up(C.length-1)),n.write(hn.cursor.to(0)),n.write(hn.erase.down())},R=(C)=>C.replace(/\.+$/,""),U=(C)=>{let P=(performance.now()-C)/1000,J=Math.floor(P/60),ye=Math.floor(P%60);return J>0?`[${J}m ${ye}s]`:`[${ye}s]`},q=(C="")=>{f=!0,p=wl({output:n}),h=R(C),m=performance.now(),n.write(`${T.default.gray(K)}
63
- `);let P=0,J=0;_(),u=setInterval(()=>{if(c&&h===d)return;k(),d=h;let ye=w(s[P]),We;if(c)We=`${ye} ${h}...`;else if(e==="timer")We=`${ye} ${h} ${U(m)}`;else{let Rm=".".repeat(Math.floor(J)).slice(0,3);We=`${ye} ${h}${Rm}`}let Nm=gn(We,v,{hard:!0,trim:!1});n.write(Nm),P=P+1<s.length?P+1:0,J=J<4?J+0.125:0},o)},L=(C="",P=0,J=!1)=>{if(!f)return;f=!1,clearInterval(u),k();let ye=P===0?T.default.green(Ss):P===1?T.default.red(Al):T.default.red(kl);h=C??h,J||(e==="timer"?n.write(`${ye} ${h} ${U(m)}
62
+ `);C.length>1&&n.write(hn.cursor.up(C.length-1)),n.write(hn.cursor.to(0)),n.write(hn.erase.down())},R=(C)=>C.replace(/\.+$/,""),U=(C)=>{let L=(performance.now()-C)/1000,J=Math.floor(L/60),ye=Math.floor(L%60);return J>0?`[${J}m ${ye}s]`:`[${ye}s]`},q=(C="")=>{f=!0,p=wl({output:n}),h=R(C),m=performance.now(),n.write(`${T.default.gray(K)}
63
+ `);let L=0,J=0;_(),u=setInterval(()=>{if(c&&h===d)return;k(),d=h;let ye=w(s[L]),We;if(c)We=`${ye} ${h}...`;else if(e==="timer")We=`${ye} ${h} ${U(m)}`;else{let Rm=".".repeat(Math.floor(J)).slice(0,3);We=`${ye} ${h}${Rm}`}let Nm=gn(We,v,{hard:!0,trim:!1});n.write(Nm),L=L+1<s.length?L+1:0,J=J<4?J+0.125:0},o)},P=(C="",L=0,J=!1)=>{if(!f)return;f=!1,clearInterval(u),k();let ye=L===0?T.default.green(Ss):L===1?T.default.red(Al):T.default.red(kl);h=C??h,J||(e==="timer"?n.write(`${ye} ${h} ${U(m)}
64
64
  `):n.write(`${ye} ${h}
65
- `)),S(),p()};return{start:q,stop:(C="")=>L(C,0),message:(C="")=>{h=R(C??h)},cancel:(C="")=>L(C,1),error:(C="")=>L(C,2),clear:()=>L("",0,!0),get isCancelled(){return g}}},t2,bi=(e,t)=>e.includes(`
65
+ `)),S(),p()};return{start:q,stop:(C="")=>P(C,0),message:(C="")=>{h=R(C??h)},cancel:(C="")=>P(C,1),error:(C="")=>P(C,2),clear:()=>P("",0,!0),get isCancelled(){return g}}},t2,bi=(e,t)=>e.includes(`
66
66
  `)?e.split(`
67
67
  `).map((n)=>t(n)).join(`
68
68
  `):t(e),yn=(e)=>{let t=(n,i)=>{let r=n.label??String(n.value);switch(i){case"disabled":return`${T.default.gray(wi)} ${bi(r,T.default.gray)}${n.hint?` ${T.default.dim(`(${n.hint??"disabled"})`)}`:""}`;case"selected":return`${bi(r,T.default.dim)}`;case"active":return`${T.default.green(xs)} ${r}${n.hint?` ${T.default.dim(`(${n.hint})`)}`:""}`;case"cancelled":return`${bi(r,(s)=>T.default.strikethrough(T.default.dim(s)))}`;default:return`${T.default.dim(wi)} ${bi(r,T.default.dim)}`}};return new hs({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let n=`${xi(this.state)} `,i=`${Tl(this.state)} `,r=ht(e.output,e.message,i,n),s=`${T.default.gray(K)}
@@ -80,7 +80,7 @@ ${l}${o}
80
80
  `}case"submit":{let o=s?` ${T.default.dim(s)}`:"",a=t?T.default.gray(K):"";return`${n}${a}${o}`}case"cancel":{let o=s?` ${T.default.strikethrough(T.default.dim(s))}`:"",a=t?T.default.gray(K):"";return`${n}${a}${o}${s.trim()?`
81
81
  ${a}`:""}`}default:{let o=t?`${T.default.cyan(K)} `:"",a=t?T.default.cyan(qt):"";return`${n}${o}${r}
82
82
  ${a}
83
- `}}}}).prompt();var Ee=I(()=>{mi();mi();T=Ft(cn(),1),hn=Ft(ns(),1);ws=Ah(),Th=Y("◆","*"),Al=Y("■","x"),kl=Y("▲","x"),Ss=Y("◇","o"),Kk=Y("┌","T"),K=Y("│","|"),qt=Y("└","—"),Wk=Y("┐","T"),Jk=Y("┘","—"),xs=Y("●",">"),wi=Y("○"," "),Ih=Y("◻","[•]"),xl=Y("◼","[+]"),vl=Y("◻","[ ]"),Yk=Y("▪","•"),Sl=Y("─","-"),Mh=Y("╮","+"),Oh=Y("├","+"),Ch=Y("╯","+"),Nh=Y("╰","+"),zk=Y("╭","+"),Xk=Y("●","•"),Qk=Y("◆","*"),Zk=Y("▲","!"),e2=Y("■","x"),gs=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,hi=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,gi=/\t{1,1000}/y,ys=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,yi=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Fh=/\p{M}+/gu,qh={limit:1/0,ellipsis:""},Dh={limit:1/0,ellipsis:"",ellipsisWidth:0},_s=`${jh}8;;`,$l=new RegExp(`(?:\\${Ol}(?<code>\\d+)m|\\${_s}(?<uri>.*)${$s})`,"y");Xh=T.default.magenta,t2={light:Y("─","-"),heavy:Y("━","="),block:Y("█","#")},n2=`${T.default.gray(K)} `});async function Ae(e){if(!Q())return;let{defaultValue:t,message:n}=e,i=await Promise.resolve().then(() => (Ee(),{})),r=await As({message:n,default:t,placeholder:t});if(typeof r==="symbol")return;return r}function Qh(e){if(e.length<=Rl)return e;return`${e.slice(0,Rl)}.... (${e.length} chars)`}async function Pl(e){if(!Q())return;await Promise.resolve().then(() => mi());let n=await new pn({render(){let i=Qh(this.userInput),r=ue.default.inverse(ue.default.hidden("_")),s=ue.default.gray("│");switch(this.state){case"submit":return`${s}
83
+ `}}}}).prompt();var Ee=I(()=>{mi();mi();T=Ft(cn(),1),hn=Ft(ns(),1);ws=Ah(),Th=Y("◆","*"),Al=Y("■","x"),kl=Y("▲","x"),Ss=Y("◇","o"),Kk=Y("┌","T"),K=Y("│","|"),qt=Y("└","—"),Wk=Y("┐","T"),Jk=Y("┘","—"),xs=Y("●",">"),wi=Y("○"," "),Ih=Y("◻","[•]"),xl=Y("◼","[+]"),vl=Y("◻","[ ]"),Yk=Y("▪","•"),Sl=Y("─","-"),Mh=Y("╮","+"),Oh=Y("├","+"),Ch=Y("╯","+"),Nh=Y("╰","+"),zk=Y("╭","+"),Xk=Y("●","•"),Qk=Y("◆","*"),Zk=Y("▲","!"),e2=Y("■","x"),gs=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,hi=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,gi=/\t{1,1000}/y,ys=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,yi=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Fh=/\p{M}+/gu,qh={limit:1/0,ellipsis:""},Dh={limit:1/0,ellipsis:"",ellipsisWidth:0},_s=`${jh}8;;`,$l=new RegExp(`(?:\\${Ol}(?<code>\\d+)m|\\${_s}(?<uri>.*)${$s})`,"y");Xh=T.default.magenta,t2={light:Y("─","-"),heavy:Y("━","="),block:Y("█","#")},n2=`${T.default.gray(K)} `});async function Ae(e){if(!Q())return;let{defaultValue:t,message:n}=e,i=await Promise.resolve().then(() => (Ee(),{})),r=await As({message:n,default:t,placeholder:t});if(typeof r==="symbol")return;return r}function Qh(e){if(e.length<=Rl)return e;return`${e.slice(0,Rl)}.... (${e.length} chars)`}async function Ll(e){if(!Q())return;await Promise.resolve().then(() => mi());let n=await new pn({render(){let i=Qh(this.userInput),r=ue.default.inverse(ue.default.hidden("_")),s=ue.default.gray("│");switch(this.state){case"submit":return`${s}
84
84
  ${ue.default.green("◇")} ${e.message}
85
85
  ${s} ${ue.default.dim(i)}`;case"cancel":return`${s}
86
86
  ${ue.default.red("■")} ${e.message}
@@ -90,10 +90,10 @@ ${ue.default.yellow("│")} ${i}${r}
90
90
  ${ue.default.yellow("└")} ${ue.default.yellow(this.error)}`;default:return`${s}
91
91
  ${ue.default.cyan("◆")} ${e.message}
92
92
  ${ue.default.cyan("│")} ${i}${r}
93
- ${ue.default.cyan("└")}`}}}).prompt();if(typeof n==="symbol")return;return n}async function Ll(e,t){if(!Q())return t();await Promise.resolve().then(() => Ee());let i=Nl();i.start(e.message);try{let r=await t();return i.stop(e.successMessage),r}catch(r){throw i.error(e.errorMessage),r}}async function bn(e){if(!Q())return;let{message:t}=e,n=await Promise.resolve().then(() => (Ee(),{})),i=await Es({message:t});if(typeof i==="symbol")return;return i}async function gt(e){if(!Q())return;let t=await Promise.resolve().then(() => (Ee(),{}));zh(e.message,e.title)}async function Si(e){if(!Q())return;let t=await Promise.resolve().then(() => (Ee(),{})),n=await yn({message:e.message,options:e.choices,initialValue:e.initialValue});if(typeof n==="symbol")return;return n}async function ks(e){if(!Q())return;let t=await Promise.resolve().then(() => (Ee(),{})),n=await Wh({message:e.message,options:e.choices,initialValues:e.initialValues,required:e.required});if(typeof n==="symbol")return;return n}function yt(e,t){throw new y(`Missing required argument: --${e}
93
+ ${ue.default.cyan("└")}`}}}).prompt();if(typeof n==="symbol")return;return n}async function Pl(e,t){if(!Q())return t();await Promise.resolve().then(() => Ee());let i=Nl();i.start(e.message);try{let r=await t();return i.stop(e.successMessage),r}catch(r){throw i.error(e.errorMessage),r}}async function bn(e){if(!Q())return;let{message:t}=e,n=await Promise.resolve().then(() => (Ee(),{})),i=await Es({message:t});if(typeof i==="symbol")return;return i}async function gt(e){if(!Q())return;let t=await Promise.resolve().then(() => (Ee(),{}));zh(e.message,e.title)}async function Si(e){if(!Q())return;let t=await Promise.resolve().then(() => (Ee(),{})),n=await yn({message:e.message,options:e.choices,initialValue:e.initialValue});if(typeof n==="symbol")return;return n}async function ks(e){if(!Q())return;let t=await Promise.resolve().then(() => (Ee(),{})),n=await Wh({message:e.message,options:e.choices,initialValues:e.initialValues,required:e.required});if(typeof n==="symbol")return;return n}function yt(e,t){throw new y(`Missing required argument: --${e}
94
94
  Hint: In non-interactive (CI / agent) environments all required flags must be provided.
95
95
  In an interactive terminal, run without --${e} and the CLI will prompt for it.`,b.USAGE,t)}async function Dt(e){if(e.value)return e.value;if(Q({nonInteractive:e.nonInteractive})){let t=await Ae({message:e.message});if(!t)process.stderr.write(e.cancelMessage+`
96
- `),process.exit(1);return t}yt(e.flagName,e.usageHint)}var ue,Rl=30;var Le=I(()=>{G();j();ue=Ft(cn(),1)});function me(e){return e.length>8?`${e.slice(0,4)}...${e.slice(-4)}`:"***"}async function ql(e){let t=si[e],{randomBytes:n,createHash:i}=await import("crypto"),r=n(32).toString("base64url"),s=i("sha256").update(r).digest("base64url"),o=n(16).toString("base64url"),a=await fetch(`${t}/oauth2/device/code`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:Fl,scope:eg.join(" "),code_challenge:s,code_challenge_method:"S256",state:o})});if(!a.ok){let u=await a.text().catch(()=>"");throw new y(`Failed to start device-code flow (HTTP ${a.status}).`,b.AUTH,u||`URL: ${t}/oauth2/device/code`)}let l=await a.json();if(l.state!==o)throw new y("OAuth state mismatch.",b.AUTH);ng(l.verification_uri),process.stderr.write(`
96
+ `),process.exit(1);return t}yt(e.flagName,e.usageHint)}var ue,Rl=30;var Pe=I(()=>{G();j();ue=Ft(cn(),1)});function me(e){return e.length>8?`${e.slice(0,4)}...${e.slice(-4)}`:"***"}async function ql(e){let t=si[e],{randomBytes:n,createHash:i}=await import("crypto"),r=n(32).toString("base64url"),s=i("sha256").update(r).digest("base64url"),o=n(16).toString("base64url"),a=await fetch(`${t}/oauth2/device/code`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:Fl,scope:eg.join(" "),code_challenge:s,code_challenge_method:"S256",state:o})});if(!a.ok){let u=await a.text().catch(()=>"");throw new y(`Failed to start device-code flow (HTTP ${a.status}).`,b.AUTH,u||`URL: ${t}/oauth2/device/code`)}let l=await a.json();if(l.state!==o)throw new y("OAuth state mismatch.",b.AUTH);ng(l.verification_uri),process.stderr.write(`
97
97
  Opened: ${l.verification_uri}
98
98
  `),process.stderr.write(`Code: ${l.user_code}
99
99
  `),process.stderr.write(`Client: ${Zh}
@@ -103,40 +103,40 @@ ${ig}`}var ig;var Ts=I(()=>{Xe();ig=["Log in: mmx auth login","Pass per
103
103
  `)});function Ut(e){return e.replace(/^https?:\/\//,"")}async function Gl(e){if(e.apiKey||e.fileApiKey)return;if(await he())return;let t=process.env.MINIMAX_API_KEY;if(t){if(!Q({nonInteractive:e.nonInteractive}))return;if(await bn({message:`Found MINIMAX_API_KEY in environment (${me(t)}). Save to config file?`}))await jl(e,t);return}if(!Q({nonInteractive:e.nonInteractive}))throw new y("No credentials found.",b.AUTH,_i(e.configPath));let n=await Is();if(n==="api-key"){let i=await Ae({message:"Enter your MiniMax API key:"});if(!i)throw new y("API key is required.",b.AUTH);await jl(e,i);return}await Ms(n==="oauth-cn"?"cn":"global")}async function Is(){await Promise.resolve().then(() => Ee());let n=await yn({message:"How would you like to authenticate?",options:rg.map((i)=>({value:i.value,label:i.label}))});if(Re(n))throw new y("Authentication cancelled.",b.AUTH);return n}async function Bl(){await Promise.resolve().then(() => Ee());let n=await yn({message:"Select an OAuth region:",options:[{value:"global",label:`Global → ${Ut(ne.global)}`},{value:"cn",label:`China → ${Ut(ne.cn)}`}]});if(Re(n))throw new y("Authentication cancelled.",b.AUTH);return n}async function Ms(e){let t=await ql(e),n=Z();delete n.api_key,n.oauth=t,n.region=e,await de(n),process.stderr.write(`Logged in successfully.
104
104
  `),process.stderr.write(`Credentials saved to ~/.mmx/config.json
105
105
  `)}async function jl(e,t){let n={...Z(),api_key:t};await de(n),e.fileApiKey=t,process.stderr.write(`API key saved to ${e.configPath??"~/.mmx/config.json"}
106
- `)}var rg;var Os=I(()=>{$e();Ce();Le();G();j();Dl();Ze();Ts();rg=[{value:"oauth-global",label:`MiniMax (OAuth login → ${Ut(ne.global)})`},{value:"oauth-cn",label:`MiniMax (OAuth login → ${Ut(ne.cn)})`},{value:"api-key",label:`API key (${Ut(ne.global)} or ${Ut(ne.cn)})`}]});import{resolve as sg}from"path";async function Ns(e,t="global"){let n=`${si[t]}/oauth2/token`,i=null;for(let r=0;r<=Vl;r++){if(r>0)await new Promise((a)=>setTimeout(a,ag*r));let s;try{s=await fetch(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:og}),signal:AbortSignal.timeout(lg)})}catch(a){let l=a instanceof Error&&(a.name==="AbortError"||a.name==="TimeoutError"||a.message.includes("timed out"));i=Error(l?"Token refresh timed out — auth server did not respond within 10 s.":`Token refresh failed: ${a instanceof Error?a.message:String(a)}`);continue}if(!s.ok){if(s.status>=400&&s.status<500)throw new y("OAuth session expired and could not be refreshed.",b.AUTH,"Re-authenticate: mmx auth login");i=Error(`Token refresh failed: HTTP ${s.status}`);continue}let o=await s.json();if(o.status!=="success"||!o.access_token)throw new y(`OAuth refresh failed: ${o.status}.`,b.AUTH,"Re-authenticate: mmx auth login");return{access_token:o.access_token,refresh_token:o.refresh_token??e,expires_at:new Date(o.expired_in??Date.now()).toISOString(),resource_url:o.resource_url}}throw new y(`Token refresh failed after ${Vl+1} attempts: ${i?.message}`,b.AUTH,`Check your network connection.
106
+ `)}var rg;var Os=I(()=>{$e();Ce();Pe();G();j();Dl();Ze();Ts();rg=[{value:"oauth-global",label:`MiniMax (OAuth login → ${Ut(ne.global)})`},{value:"oauth-cn",label:`MiniMax (OAuth login → ${Ut(ne.cn)})`},{value:"api-key",label:`API key (${Ut(ne.global)} or ${Ut(ne.cn)})`}]});import{resolve as sg}from"path";async function Ns(e,t="global"){let n=`${si[t]}/oauth2/token`,i=null;for(let r=0;r<=Vl;r++){if(r>0)await new Promise((a)=>setTimeout(a,ag*r));let s;try{s=await fetch(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:og}),signal:AbortSignal.timeout(lg)})}catch(a){let l=a instanceof Error&&(a.name==="AbortError"||a.name==="TimeoutError"||a.message.includes("timed out"));i=Error(l?"Token refresh timed out — auth server did not respond within 10 s.":`Token refresh failed: ${a instanceof Error?a.message:String(a)}`);continue}if(!s.ok){if(s.status>=400&&s.status<500)throw new y("OAuth session expired and could not be refreshed.",b.AUTH,"Re-authenticate: mmx auth login");i=Error(`Token refresh failed: HTTP ${s.status}`);continue}let o=await s.json();if(o.status!=="success"||!o.access_token)throw new y(`OAuth refresh failed: ${o.status}.`,b.AUTH,"Re-authenticate: mmx auth login");return{access_token:o.access_token,refresh_token:o.refresh_token??e,expires_at:new Date(o.expired_in??Date.now()).toISOString(),resource_url:o.resource_url}}throw new y(`Token refresh failed after ${Vl+1} attempts: ${i?.message}`,b.AUTH,`Check your network connection.
107
107
  Re-authenticate: mmx auth login`)}async function Hl(e){let t=new Date(e.expires_at).getTime();if(Date.now()<t-cg)return e.access_token;let n=sg(fe()),i=JSON.stringify([n,e.region??"global",e.refresh_token]),r=Cs.get(i);if(r)return r;let s=(async()=>{let o=await Ns(e.refresh_token,e.region??"global"),a={access_token:o.access_token,refresh_token:o.refresh_token,expires_at:o.expires_at,region:e.region,resource_url:o.resource_url??e.resource_url,account:e.account};return await $i(a,n),a.access_token})();Cs.set(i,s);try{return await s}finally{Cs.delete(i)}}var og="659cf4c1-615c-45f6-a5f6-4bf15eb476e5",Vl=2,ag=500,lg=1e4,cg=300000,Cs;var Rs=I(()=>{$e();Xe();Ze();G();j();Cs=new Map});async function jt(e){if(e.apiKey)return{token:e.apiKey,method:"api-key",source:"flag"};let t=await he();if(t)return{token:await Hl(t),method:"oauth",source:"config.json"};if(e.fileApiKey)return{token:e.fileApiKey,method:"api-key",source:"config.json"};throw new y("No credentials found.",b.AUTH,_i(e.configPath))}var Ei=I(()=>{Ze();Rs();G();j();Ts()});function Kl(e){if(!e)return"";if(e.includes("/t2a"))return`
108
108
 
109
109
  Speech models require the Plus plan or above.`;if(e.includes("/image_generation"))return`
110
110
 
111
111
  image-01 requires the Plus plan or above.`;if(e.includes("/video_generation")||e.includes("/query/video_generation"))return`
112
112
 
113
- Video models (Hailuo-2.3 / 2.3-Fast) require the Max plan or above.`;return""}function Ps(e){return`${e?.includes("api.minimax.cn")||e?.includes("api.minimaxi.com")?"https://platform.minimax.cn":"https://platform.minimax.io"}/subscribe/token-plan`}function ug(e){if(!Array.isArray(e.data))return;let n=e.data.flatMap((i,r)=>i?.error?[`Image ${r+1}${i.error.code!==void 0?` (${i.error.code})`:""}: ${i.error.message??"unknown error"}`]:[]);return n.length>0?n.join(`
113
+ Video models (Hailuo-2.3 / 2.3-Fast) require the Max plan or above.`;return""}function Ls(e){return`${e?.includes("api.minimax.cn")||e?.includes("api.minimaxi.com")?"https://platform.minimax.cn":"https://platform.minimax.io"}/subscribe/token-plan`}function ug(e){if(!Array.isArray(e.data))return;let n=e.data.flatMap((i,r)=>i?.error?[`Image ${r+1}${i.error.code!==void 0?` (${i.error.code})`:""}: ${i.error.message??"unknown error"}`]:[]);return n.length>0?n.join(`
114
114
  `):void 0}function wn(e,t,n){let i=fg(e,t,n),r=n?.includes("/v1/images/")?ug(t):void 0;if(!r)return i;return new y(i.message,i.exitCode,i.hint?`${r}
115
115
  ${i.hint}`:r)}function fg(e,t,n){let i=t.base_resp?.status_msg||t.error?.message||`HTTP ${e}`,r=n?.includes("/v1/images/")?t.error?.message?.match(/\((\d{4})\)\s*$/)?.[1]:void 0,s=t.base_resp?.status_code||t.error?.code||(r?Number(r):void 0),o=t.error?.type;if(e===401||e===403)return new y(`API key rejected (HTTP ${e}).`,b.AUTH,`Check status: mmx auth status
116
116
  Re-authenticate: mmx auth login`);if(e===429||s===1002&&n?.includes("/v1/images/"))return new y(`Rate limit or quota exceeded. ${i}`,b.QUOTA,"Check usage: mmx quota show");if(s===2068&&n?.includes("/v1/images/"))return new y(`This model is not available on your current plan. ${i}`,b.QUOTA,`Check usage: mmx quota show
117
- Upgrade plan: ${Ps(n)}`);if(e===402||o==="insufficient_balance_error")return new y(`Quota or balance exhausted. ${i}`,b.QUOTA,"Check your MiniMax account balance and billing settings.");if(e===408||e===504)return new y(`Request timed out (HTTP ${e}).`,b.TIMEOUT,"Try increasing --timeout or retry later.");if(e===422&&n?.includes("/speech_to_text"))return new y(`Input audio flagged by sensitivity filter${i?` (${i})`:""}.`,b.CONTENT_FILTER);if(e===413&&n?.includes("/speech_to_text"))return new y(`Audio file exceeds the speech-to-text size limit (HTTP 413). ${i}`,b.USAGE,"Re-encode to compressed mono audio (e.g. mp3 / aac) or split it into smaller files.");let a=e===422&&o==="unprocessable_entity_error"&&(/sensitive content/i.test(i)||/(?:^|\D)1026(?:\D|$)/.test(i));if(s===1002||s===1039||s===1026||a){let l=t.base_resp?.status_msg||t.error?.message||"content sensitivity";return new y(`Input content flagged by sensitivity filter (${l}).`,b.CONTENT_FILTER)}if(s===1028||s===1030){let l=Kl(n);return new y(`Quota exhausted. ${i}`,b.QUOTA,`Check usage: mmx quota show${l}
118
- Upgrade plan: ${Ps(n)}`)}if(s===2061){let l=Kl(n);return new y(`This model is not available on your current Token Plan. ${i}`,b.QUOTA,`Check usage: mmx quota show${l}
119
- Upgrade plan: ${Ps(n)}`)}if(s===1027||/output.*sensitive/i.test(i))return new y(`Output withheld by content moderation (${i}).`,b.CONTENT_FILTER,"Refine your query and try again.");return new y(`API error: ${i} (HTTP ${e})`,b.GENERAL)}var Ls=I(()=>{G();j()});import{homedir as Wl}from"os";function yg(e){return e.startsWith(Wl())?e.replace(Wl(),"~"):e}function bg(e){return e.replace(/^https?:\/\//,"")}function Yl(e,t,n){if(e.quiet||Jl||!process.stderr.isTTY)return;Jl=!0;let i=e.configPath?yg(e.configPath):"~/.mmx/config.json",r=bg(e.baseUrl),s=e.apiKey?"(flag)":"(file)",o=me(t),a=n?` ${et}|${we} ${et}Model:${we} ${mg}${n}${we}`:"";process.stderr.write(`${dg}${pg}MINIMAX${we} ${et}${i}${we} ${et}|${we} ${et}URL:${we} ${hg}${r}${we} ${et}|${we} ${et}Key:${we} ${gg}${o}${we} ${et}${s}${we}${a}
120
- `)}var Jl=!1,we="\x1B[0m",et="\x1B[2m",dg="\x1B[1m",pg="\x1B[38;2;43;82;255m",mg="\x1B[38;2;147;51;234m",hg="\x1B[38;2;6;184;212m",gg="\x1B[38;2;236;72;153m";var zl=()=>{};var Xl=()=>{};var bt="1.0.29";var Ai=I(()=>{Xl()});function Ql(e){return new DOMException(e,"TimeoutError")}function wg(e,t,n){if(!e.body)return e;let i=e.body.getReader(),r=!1,s=()=>{if(r)return;r=!0,i.releaseLock()},o=async(c)=>{if(!n.signal.aborted)n.abort(c);try{await i.cancel(c)}finally{s()}},a=new ReadableStream({async pull(c){let p;try{let u=await new Promise((f,g)=>{p=setTimeout(()=>{let h=Ql(`Stream received no data for ${t}ms.`);n.abort(h),g(h)},t),i.read().then(f,g)});if(u.done)s(),c.close();else c.enqueue(u.value)}catch(u){await o(u).catch(()=>{}),c.error(u)}finally{if(p)clearTimeout(p)}},cancel(c){return o(c)}}),l=new Response(a,{status:e.status,statusText:e.statusText,headers:e.headers});return Object.defineProperties(l,{url:{value:e.url},redirected:{value:e.redirected},type:{value:e.type}}),l}async function Fe(e,t){let n=typeof FormData<"u"&&t.body instanceof FormData,i={"User-Agent":`mmx-cli/${bt}`,...t.headers};if(!n&&!i["Content-Type"])i["Content-Type"]="application/json";if(!t.noAuth){let l=await jt(e);if(t.authStyle==="x-api-key")i["x-api-key"]=l.token;else i.Authorization=`Bearer ${l.token}`;if(e.verbose)process.stderr.write(`> ${t.method??"GET"} ${t.url}
117
+ Upgrade plan: ${Ls(n)}`);if(e===402||o==="insufficient_balance_error")return new y(`Quota or balance exhausted. ${i}`,b.QUOTA,"Check your MiniMax account balance and billing settings.");if(e===408||e===504)return new y(`Request timed out (HTTP ${e}).`,b.TIMEOUT,"Try increasing --timeout or retry later.");if(e===422&&n?.includes("/speech_to_text"))return new y(`Input audio flagged by sensitivity filter${i?` (${i})`:""}.`,b.CONTENT_FILTER);if(e===413&&n?.includes("/speech_to_text"))return new y(`Audio file exceeds the speech-to-text size limit (HTTP 413). ${i}`,b.USAGE,"Re-encode to compressed mono audio (e.g. mp3 / aac) or split it into smaller files.");let a=e===422&&o==="unprocessable_entity_error"&&(/sensitive content/i.test(i)||/(?:^|\D)1026(?:\D|$)/.test(i));if(s===1002||s===1039||s===1026||a){let l=t.base_resp?.status_msg||t.error?.message||"content sensitivity";return new y(`Input content flagged by sensitivity filter (${l}).`,b.CONTENT_FILTER)}if(s===1028||s===1030){let l=Kl(n);return new y(`Quota exhausted. ${i}`,b.QUOTA,`Check usage: mmx quota show${l}
118
+ Upgrade plan: ${Ls(n)}`)}if(s===2061){let l=Kl(n);return new y(`This model is not available on your current Token Plan. ${i}`,b.QUOTA,`Check usage: mmx quota show${l}
119
+ Upgrade plan: ${Ls(n)}`)}if(s===1027||/output.*sensitive/i.test(i))return new y(`Output withheld by content moderation (${i}).`,b.CONTENT_FILTER,"Refine your query and try again.");return new y(`API error: ${i} (HTTP ${e})`,b.GENERAL)}var Ps=I(()=>{G();j()});import{homedir as Wl}from"os";function yg(e){return e.startsWith(Wl())?e.replace(Wl(),"~"):e}function bg(e){return e.replace(/^https?:\/\//,"")}function Yl(e,t,n){if(e.quiet||Jl||!process.stderr.isTTY)return;Jl=!0;let i=e.configPath?yg(e.configPath):"~/.mmx/config.json",r=bg(e.baseUrl),s=e.apiKey?"(flag)":"(file)",o=me(t),a=n?` ${et}|${we} ${et}Model:${we} ${mg}${n}${we}`:"";process.stderr.write(`${dg}${pg}MINIMAX${we} ${et}${i}${we} ${et}|${we} ${et}URL:${we} ${hg}${r}${we} ${et}|${we} ${et}Key:${we} ${gg}${o}${we} ${et}${s}${we}${a}
120
+ `)}var Jl=!1,we="\x1B[0m",et="\x1B[2m",dg="\x1B[1m",pg="\x1B[38;2;43;82;255m",mg="\x1B[38;2;147;51;234m",hg="\x1B[38;2;6;184;212m",gg="\x1B[38;2;236;72;153m";var zl=()=>{};var Xl=()=>{};var bt="1.0.30";var Ai=I(()=>{Xl()});function Ql(e){return new DOMException(e,"TimeoutError")}function wg(e,t,n){if(!e.body)return e;let i=e.body.getReader(),r=!1,s=()=>{if(r)return;r=!0,i.releaseLock()},o=async(c)=>{if(!n.signal.aborted)n.abort(c);try{await i.cancel(c)}finally{s()}},a=new ReadableStream({async pull(c){let p;try{let u=await new Promise((f,g)=>{p=setTimeout(()=>{let h=Ql(`Stream received no data for ${t}ms.`);n.abort(h),g(h)},t),i.read().then(f,g)});if(u.done)s(),c.close();else c.enqueue(u.value)}catch(u){await o(u).catch(()=>{}),c.error(u)}finally{if(p)clearTimeout(p)}},cancel(c){return o(c)}}),l=new Response(a,{status:e.status,statusText:e.statusText,headers:e.headers});return Object.defineProperties(l,{url:{value:e.url},redirected:{value:e.redirected},type:{value:e.type}}),l}async function Fe(e,t){let n=typeof FormData<"u"&&t.body instanceof FormData,i={"User-Agent":`mmx-cli/${bt}`,...t.headers};if(!n&&!i["Content-Type"])i["Content-Type"]="application/json";if(!t.noAuth){let l=await jt(e);if(t.authStyle==="x-api-key")i["x-api-key"]=l.token;else i.Authorization=`Bearer ${l.token}`;if(e.verbose)process.stderr.write(`> ${t.method??"GET"} ${t.url}
121
121
  `),process.stderr.write(`> Auth: ${l.token.slice(0,8)}...
122
122
  `);let c=t.body&&typeof t.body==="object"&&"model"in t.body?String(t.body.model):void 0;Yl(e,l.token,c)}let r=(t.timeout??e.timeout)*1000,s=t.stream?new AbortController:void 0,o=s?setTimeout(()=>{s.abort(Ql(`Request headers were not received within ${r}ms.`))},r):void 0,a;try{a=await fetch(t.url,{method:t.method??"GET",headers:i,body:t.body?n?t.body:JSON.stringify(t.body):void 0,signal:s?.signal??AbortSignal.timeout(r)})}finally{if(o)clearTimeout(o)}if(s)a=wg(a,r,s);if(e.verbose)process.stderr.write(`< ${a.status} ${a.statusText}
123
- `);if(!a.ok){let l={};try{l=await a.json()}catch{}throw wn(a.status,l,t.url)}return a}async function D(e,t){let n=await Fe(e,t),i;try{i=await n.json()}catch{let r=n.headers.get("content-type")||"";throw new y(`API returned non-JSON response (${r||"unknown type"}). Server may be experiencing issues.`,b.GENERAL)}if(i.base_resp?.status_code&&i.base_resp.status_code!==0)throw wn(200,{base_resp:i.base_resp},t.url);return i}var oe=I(()=>{G();j();Ei();Ls();zl();Ai()});function ki(e){return`${e}/anthropic/v1/messages`}function Zl(e){return`${e}/v1/t2a_v2`}function ec(e){return`${e}/v1/speech_to_text`}function tc(e){return`${e}/v1/get_voice`}function nc(e){return`${e}/v1/image_generation`}function ic(e){return`${e}/v1/images/generations`}function rc(e){return`${e}/v1/images/edits`}function sc(e){return`${e}/v1/video_generation`}function oc(e){return`${e}/v2/video_generation`}function Ti(e,t){return`${e}/v1/query/video_generation?task_id=${t}`}function Ii(e,t){return`${e}/v2/query/video_generation/${t}`}function Mi(e,t){return`${e}/v1/files/retrieve?file_id=${t}`}function ac(e){return`${e}/v1/coding_plan/search`}function lc(e){return`${e}/v1/coding_plan/vlm`}function xn(e){return`${e}/v1/token_plan/remains`}function xg(e){return`${e}/account/query_balance`}function Fs(e){return e.startsWith("sk-api-")}function qs(e,t){if(t.method==="api-key"&&Fs(t.token))return{url:xg(e),kind:"account-balance"};return{url:xn(e),kind:"quota"}}function tt(e,t){return qs(e,{token:t,method:"api-key"}).url}function cc(e){return`${e}/v1/files/upload`}function uc(e){return`${e}/v1/files/list`}function fc(e){return`${e}/v1/files/delete`}function vg(e){return e?"on":"off"}function dc(e,t){if(console.log("Account Balance:"),console.log(` Available: ${e.available_amount}`),console.log(` Cash: ${e.cash_balance}`),console.log(` Voucher: ${e.voucher_balance}`),console.log(` Credit: ${e.credit_balance}`),console.log(` Owed: ${e.owed_amount}`),console.log(` Alert: ${vg(e.balance_alert_switch)}`),e.balance_alert_threshold)console.log(` Threshold: ${e.balance_alert_threshold}`)}function Oi(e,t,n){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=0||e<0||e>t)return;let i=e;if(n!==void 0&&n!==null&&Number.isFinite(n)){let r=e/t*100,s=(t-e)/t*100,o=Math.abs(r-n),a=Math.abs(s-n);if(Math.min(o,a)>1)return;if(a<o)i=t-e}return{used:t-i,remaining:i,total:t}}function vc(e){if(e>=50)return[yc,wc];if(e>=20)return[_g,Eg];return[bc,Ag]}function Mg(e,t){if(t!=="cn")return e;return Ig[e]??e}function Og(e,t){if(e<=0)return t;if(e<60000)return`${Math.max(1,Math.floor(e/1000))}s`;let n=Math.floor(e/3600000),i=Math.floor(e%3600000/60000);return n>0?`${n}h ${i}m`:`${i}m`}function Cg(e){if(e<=0)return"";if(e%604800000===0)return`${e/604800000}w`;if(e%86400000===0)return`${e/86400000}d`;if(e>=3600000)return`${Math.round(e/3600000)}h`;return`${Math.max(1,Math.round(e/60000))}m`}function pc(e){return new Date(e).toISOString().slice(0,10)}function Ng(e){return e>=11904&&e<=40959||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65281&&e<=65376||e>=131072&&e<=195103}function xe(e){let t=e.replace(/\x1b\[[0-9;]*m/g,""),n=0;for(let i of t)n+=Ng(i.codePointAt(0))?2:1;return n}function Lg(e){return e===3}function Fg(e){return e.current_interval_total_count===0&&e.current_weekly_total_count===0&&e.current_interval_status===3&&e.current_weekly_status===3}function Ds(e){return Math.max(0,Math.min(Pg,Math.round(e)))}function qg(e){if(e===void 0||e===null)return 1;return Math.max(0,e)/1000}function Dg(e,t,n,i){let r=qg(i);if(e!==void 0&&e!==null)return Ds(e*r);return n>0?Ds(t/n*100*r):0}function Ug(e,t,n=Rg,i=!0){let r=Ds(e),s=Math.min(1,r/100),o=Math.round(n*s),a=n-o,l=`${r}%`.padStart(4);if(!t){let f=`[${"█".repeat(o)}${".".repeat(a)}]`;return i?`${f} ${l}`:f}let[c,p]=vc(r),u=`${p}${" ".repeat(o)}${te}${xc}${" ".repeat(a)}${te}`;return i?`${u} ${c}${Sn}${l}${te}`:u}function mc(e,t,n,i,r,s,o,a){if(o){let f=(a??jg).padStart(4);if(r){let h=`${wc}${" ".repeat(vn)}${te}`;return`${ke}${e}${te} ${h} ${yc}${Sn}${f}${te}`}let g=`[${"█".repeat(vn)}]`;return`${e} ${g} ${f}`}let l=Dg(i,t,n,s),c=Oi(t,n,i),p=Ug(l,r,vn,c===void 0);if(c){let u=`${c.remaining.toLocaleString()} / ${c.total.toLocaleString()}`;return r?`${ke}${e}${te} ${p} ${vc(l)[0]}${u}${te}`:`${e} ${p} ${u}`}return`${e} ${p}`}function hc(e,t,n){if(n){let i=`${xc}${" ".repeat(vn)}${te}`;return`${ke}${e}${te} ${i} ${bc}${Sn}${t}${te}`}return`${e} [${".".repeat(vn)}] ${t}`}function Ci(e,t,n,i,r,s,o){if(s===void 0||o===void 0)return r?`${ke}${t}${n.repeat(e)}${i}${te}`:`+${"-".repeat(e)}+`;return r?`${ke}${t}${n.repeat(s-1)}${o}${n.repeat(e-s)}${i}${te}`:`+${"-".repeat(s-1)}+${"-".repeat(e-s)}+`}function gc(e,t,n,i){let r=Math.max(0,t-2-n);return i?`${ke}│${te} ${e}${" ".repeat(r)} ${ke}│${te}`:`| ${e}${" ".repeat(r)} |`}function Sc(e,t){let n=!t.noColor&&process.stdout.isTTY===!0,i=t.region==="cn"?Tg:kg,r=e.map((w)=>{let x=Mg(w.model_name,t.region),E=Fg(w),A=E?hc(i.current,i.notInPlan,n):mc(i.current,w.current_interval_usage_count,w.current_interval_total_count,w.current_interval_remaining_percent,n),_=E?hc(i.weekly,i.notInPlan,n):mc(i.weekly,w.current_weekly_usage_count,w.current_weekly_total_count,w.current_weekly_remaining_percent,n,w.weekly_boost_permille,Lg(w.current_weekly_status),t.region==="cn"?Gg:Bg),S=E?"":Cg(w.end_time-w.start_time),k=S?`${S} ${i.resetsIn}`:i.resetsIn,R=E?"—":Og(w.remains_time,i.now),U=n?`${ke}${k}${te} ${R}`:`${k} ${R}`;return{displayName:x,current:A,weekly:_,reset:U}}),s=Math.max(6,...r.map((w)=>xe(w.displayName))),o=Math.max(...r.map((w)=>xe(w.current)),18),a=Math.max(...r.map((w)=>xe(w.weekly)),18),l=Math.max(...r.map((w)=>xe(w.reset)),10),c=s+2+o+2+a,p=c+3+l+2;if(p<72)c+=72-p,p=72;let u=c+3,f=e.length>0?`${pc(e[0].weekly_start_time)} — ${pc(e[0].weekly_end_time)}`:"",g=`MINIMAX ${i.dashboard}`,h=`${i.week}: ${f}`,d=Math.max(2,p-2-xe(g)-xe(h)),m=n?`${Sn}${Sg}MINIMAX${te} ${ke}${i.dashboard}${te}${" ".repeat(d)}${ke}${i.week}:${te} ${$g}${f}${te}`:`${g}${" ".repeat(d)}${h}`,v=xe(g)+d+xe(h);if(console.log(""),console.log(Ci(p,"╭","─","╮",n)),console.log(gc(m,p,v,n)),e.length===0){console.log(Ci(p,"╰","─","╯",n)),console.log(`
123
+ `);if(!a.ok){let l={};try{l=await a.json()}catch{}throw wn(a.status,l,t.url)}return a}async function D(e,t){let n=await Fe(e,t),i;try{i=await n.json()}catch{let r=n.headers.get("content-type")||"";throw new y(`API returned non-JSON response (${r||"unknown type"}). Server may be experiencing issues.`,b.GENERAL)}if(i.base_resp?.status_code&&i.base_resp.status_code!==0)throw wn(200,{base_resp:i.base_resp},t.url);return i}var oe=I(()=>{G();j();Ei();Ps();zl();Ai()});function ki(e){return`${e}/anthropic/v1/messages`}function Zl(e){return`${e}/v1/t2a_v2`}function ec(e){return`${e}/v1/speech_to_text`}function tc(e){return`${e}/v1/get_voice`}function nc(e){return`${e}/v1/image_generation`}function ic(e){return`${e}/v1/images/generations`}function rc(e){return`${e}/v1/images/edits`}function sc(e){return`${e}/v1/video_generation`}function oc(e){return`${e}/v2/video_generation`}function Ti(e,t){return`${e}/v1/query/video_generation?task_id=${t}`}function Ii(e,t){return`${e}/v2/query/video_generation/${t}`}function Mi(e,t){return`${e}/v1/files/retrieve?file_id=${t}`}function ac(e){return`${e}/v1/coding_plan/search`}function lc(e){return`${e}/v1/coding_plan/vlm`}function xn(e){return`${e}/v1/token_plan/remains`}function xg(e){return`${e}/account/query_balance`}function Fs(e){return e.startsWith("sk-api-")}function qs(e,t){if(t.method==="api-key"&&Fs(t.token))return{url:xg(e),kind:"account-balance"};return{url:xn(e),kind:"quota"}}function tt(e,t){return qs(e,{token:t,method:"api-key"}).url}function cc(e){return`${e}/v1/files/upload`}function uc(e){return`${e}/v1/files/list`}function fc(e){return`${e}/v1/files/delete`}function vg(e){return e?"on":"off"}function dc(e,t){if(console.log("Account Balance:"),console.log(` Available: ${e.available_amount}`),console.log(` Cash: ${e.cash_balance}`),console.log(` Voucher: ${e.voucher_balance}`),console.log(` Credit: ${e.credit_balance}`),console.log(` Owed: ${e.owed_amount}`),console.log(` Alert: ${vg(e.balance_alert_switch)}`),e.balance_alert_threshold)console.log(` Threshold: ${e.balance_alert_threshold}`)}function Oi(e,t,n){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=0||e<0||e>t)return;let i=e;if(n!==void 0&&n!==null&&Number.isFinite(n)){let r=e/t*100,s=(t-e)/t*100,o=Math.abs(r-n),a=Math.abs(s-n);if(Math.min(o,a)>1)return;if(a<o)i=t-e}return{used:t-i,remaining:i,total:t}}function vc(e){if(e>=50)return[yc,wc];if(e>=20)return[_g,Eg];return[bc,Ag]}function Mg(e,t){if(t!=="cn")return e;return Ig[e]??e}function Og(e,t){if(e<=0)return t;if(e<60000)return`${Math.max(1,Math.floor(e/1000))}s`;let n=Math.floor(e/3600000),i=Math.floor(e%3600000/60000);return n>0?`${n}h ${i}m`:`${i}m`}function Cg(e){if(e<=0)return"";if(e%604800000===0)return`${e/604800000}w`;if(e%86400000===0)return`${e/86400000}d`;if(e>=3600000)return`${Math.round(e/3600000)}h`;return`${Math.max(1,Math.round(e/60000))}m`}function pc(e){return new Date(e).toISOString().slice(0,10)}function Ng(e){return e>=11904&&e<=40959||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65281&&e<=65376||e>=131072&&e<=195103}function xe(e){let t=e.replace(/\x1b\[[0-9;]*m/g,""),n=0;for(let i of t)n+=Ng(i.codePointAt(0))?2:1;return n}function Pg(e){return e===3}function Fg(e){return e.current_interval_total_count===0&&e.current_weekly_total_count===0&&e.current_interval_status===3&&e.current_weekly_status===3}function Ds(e){return Math.max(0,Math.min(Lg,Math.round(e)))}function qg(e){if(e===void 0||e===null)return 1;return Math.max(0,e)/1000}function Dg(e,t,n,i){let r=qg(i);if(e!==void 0&&e!==null)return Ds(e*r);return n>0?Ds(t/n*100*r):0}function Ug(e,t,n=Rg,i=!0){let r=Ds(e),s=Math.min(1,r/100),o=Math.round(n*s),a=n-o,l=`${r}%`.padStart(4);if(!t){let f=`[${"█".repeat(o)}${".".repeat(a)}]`;return i?`${f} ${l}`:f}let[c,p]=vc(r),u=`${p}${" ".repeat(o)}${te}${xc}${" ".repeat(a)}${te}`;return i?`${u} ${c}${Sn}${l}${te}`:u}function mc(e,t,n,i,r,s,o,a){if(o){let f=(a??jg).padStart(4);if(r){let h=`${wc}${" ".repeat(vn)}${te}`;return`${ke}${e}${te} ${h} ${yc}${Sn}${f}${te}`}let g=`[${"█".repeat(vn)}]`;return`${e} ${g} ${f}`}let l=Dg(i,t,n,s),c=Oi(t,n,i),p=Ug(l,r,vn,c===void 0);if(c){let u=`${c.remaining.toLocaleString()} / ${c.total.toLocaleString()}`;return r?`${ke}${e}${te} ${p} ${vc(l)[0]}${u}${te}`:`${e} ${p} ${u}`}return`${e} ${p}`}function hc(e,t,n){if(n){let i=`${xc}${" ".repeat(vn)}${te}`;return`${ke}${e}${te} ${i} ${bc}${Sn}${t}${te}`}return`${e} [${".".repeat(vn)}] ${t}`}function Ci(e,t,n,i,r,s,o){if(s===void 0||o===void 0)return r?`${ke}${t}${n.repeat(e)}${i}${te}`:`+${"-".repeat(e)}+`;return r?`${ke}${t}${n.repeat(s-1)}${o}${n.repeat(e-s)}${i}${te}`:`+${"-".repeat(s-1)}+${"-".repeat(e-s)}+`}function gc(e,t,n,i){let r=Math.max(0,t-2-n);return i?`${ke}│${te} ${e}${" ".repeat(r)} ${ke}│${te}`:`| ${e}${" ".repeat(r)} |`}function Sc(e,t){let n=!t.noColor&&process.stdout.isTTY===!0,i=t.region==="cn"?Tg:kg,r=e.map((w)=>{let x=Mg(w.model_name,t.region),E=Fg(w),A=E?hc(i.current,i.notInPlan,n):mc(i.current,w.current_interval_usage_count,w.current_interval_total_count,w.current_interval_remaining_percent,n),_=E?hc(i.weekly,i.notInPlan,n):mc(i.weekly,w.current_weekly_usage_count,w.current_weekly_total_count,w.current_weekly_remaining_percent,n,w.weekly_boost_permille,Pg(w.current_weekly_status),t.region==="cn"?Gg:Bg),S=E?"":Cg(w.end_time-w.start_time),k=S?`${S} ${i.resetsIn}`:i.resetsIn,R=E?"—":Og(w.remains_time,i.now),U=n?`${ke}${k}${te} ${R}`:`${k} ${R}`;return{displayName:x,current:A,weekly:_,reset:U}}),s=Math.max(6,...r.map((w)=>xe(w.displayName))),o=Math.max(...r.map((w)=>xe(w.current)),18),a=Math.max(...r.map((w)=>xe(w.weekly)),18),l=Math.max(...r.map((w)=>xe(w.reset)),10),c=s+2+o+2+a,p=c+3+l+2;if(p<72)c+=72-p,p=72;let u=c+3,f=e.length>0?`${pc(e[0].weekly_start_time)} — ${pc(e[0].weekly_end_time)}`:"",g=`MINIMAX ${i.dashboard}`,h=`${i.week}: ${f}`,d=Math.max(2,p-2-xe(g)-xe(h)),m=n?`${Sn}${Sg}MINIMAX${te} ${ke}${i.dashboard}${te}${" ".repeat(d)}${ke}${i.week}:${te} ${$g}${f}${te}`:`${g}${" ".repeat(d)}${h}`,v=xe(g)+d+xe(h);if(console.log(""),console.log(Ci(p,"╭","─","╮",n)),console.log(gc(m,p,v,n)),e.length===0){console.log(Ci(p,"╰","─","╯",n)),console.log(`
124
124
  ${i.noData}
125
- `);return}r.forEach((w,x)=>{console.log(Ci(p,"├","─","┤",n,u,x===0?"┬":"┼"));let A=`${n?`${Sn}${w.displayName}${te}`:w.displayName}${" ".repeat(Math.max(1,s-xe(w.displayName)+2))}${w.current}${" ".repeat(Math.max(1,o-xe(w.current)+2))}`+w.weekly,_=n?`${ke}│${te}`:"|",S=`${A}${" ".repeat(Math.max(0,c-xe(A)))} ${_} ${w.reset}`;console.log(gc(S,p,xe(S),n))}),console.log(Ci(p,"╰","─","╯",n,u,"┴")),console.log("")}var te="\x1B[0m",Sn="\x1B[1m",ke="\x1B[2m",Sg="\x1B[38;2;43;82;255m",$g="\x1B[38;2;6;184;212m",yc="\x1B[38;2;74;222;128m",_g="\x1B[38;2;250;204;21m",bc="\x1B[38;2;248;113;113m",wc="\x1B[48;2;22;163;74m",Eg="\x1B[48;2;202;138;4m",Ag="\x1B[48;2;220;38;38m",xc="\x1B[48;2;55;65;81m",kg,Tg,Ig,Rg=16,vn=10,Pg=200,jg="∞",Gg="无限",Bg="unlimited";var $c=I(()=>{kg={dashboard:"TokenPlan Quota",week:"Week",current:"Left",weekly:"Wk left",resetsIn:"Reset",noData:"No quota data available.",now:"now",notInPlan:"not in plan"},Tg={dashboard:"TokenPlan 配额面板",week:"周期",current:"剩余",weekly:"周剩余",resetsIn:"重置",noData:"暂无配额数据",now:"即将",notInPlan:"不在当前套餐中"},Ig={general:"通用",video:"视频"}});function Je(e,t,n){if(n&&Fs(n)){dc(e,t);return}Sc(e.model_remains||[],t)}var Ni=I(()=>{$c()});async function Vg(e,t,n){let i=[{Authorization:`Bearer ${t}`},{"x-api-key":t}],r=!1,s=!1;for(let o of i){let a;try{a=await fetch(tt(ne[e],t),{headers:{...o,"Content-Type":"application/json"},signal:AbortSignal.timeout(n)})}catch{r=!0;continue}if(a.status===401||a.status===403)continue;if(!a.ok){s=!0;continue}try{if((await a.json()).base_resp?.status_code===0)return"authorized";s=!0}catch{s=!0}}if(s)return"inconclusive";if(r)return"unreachable";return"unauthorized"}async function Ri(e){process.stderr.write("Detecting region...");let t=Object.keys(ne),n=await Promise.all(t.map(async(s)=>({region:s,result:await Vg(s,e,5000)}))),i=n.find((s)=>s.result==="authorized");if(!i){process.stderr.write(` failed
125
+ `);return}r.forEach((w,x)=>{console.log(Ci(p,"├","─","┤",n,u,x===0?"┬":"┼"));let A=`${n?`${Sn}${w.displayName}${te}`:w.displayName}${" ".repeat(Math.max(1,s-xe(w.displayName)+2))}${w.current}${" ".repeat(Math.max(1,o-xe(w.current)+2))}`+w.weekly,_=n?`${ke}│${te}`:"|",S=`${A}${" ".repeat(Math.max(0,c-xe(A)))} ${_} ${w.reset}`;console.log(gc(S,p,xe(S),n))}),console.log(Ci(p,"╰","─","╯",n,u,"┴")),console.log("")}var te="\x1B[0m",Sn="\x1B[1m",ke="\x1B[2m",Sg="\x1B[38;2;43;82;255m",$g="\x1B[38;2;6;184;212m",yc="\x1B[38;2;74;222;128m",_g="\x1B[38;2;250;204;21m",bc="\x1B[38;2;248;113;113m",wc="\x1B[48;2;22;163;74m",Eg="\x1B[48;2;202;138;4m",Ag="\x1B[48;2;220;38;38m",xc="\x1B[48;2;55;65;81m",kg,Tg,Ig,Rg=16,vn=10,Lg=200,jg="∞",Gg="无限",Bg="unlimited";var $c=I(()=>{kg={dashboard:"TokenPlan Quota",week:"Week",current:"Left",weekly:"Wk left",resetsIn:"Reset",noData:"No quota data available.",now:"now",notInPlan:"not in plan"},Tg={dashboard:"TokenPlan 配额面板",week:"周期",current:"剩余",weekly:"周剩余",resetsIn:"重置",noData:"暂无配额数据",now:"即将",notInPlan:"不在当前套餐中"},Ig={general:"通用",video:"视频"}});function Je(e,t,n){if(n&&Fs(n)){dc(e,t);return}Sc(e.model_remains||[],t)}var Ni=I(()=>{$c()});async function Vg(e,t,n){let i=[{Authorization:`Bearer ${t}`},{"x-api-key":t}],r=!1,s=!1;for(let o of i){let a;try{a=await fetch(tt(ne[e],t),{headers:{...o,"Content-Type":"application/json"},signal:AbortSignal.timeout(n)})}catch{r=!0;continue}if(a.status===401||a.status===403)continue;if(!a.ok){s=!0;continue}try{if((await a.json()).base_resp?.status_code===0)return"authorized";s=!0}catch{s=!0}}if(s)return"inconclusive";if(r)return"unreachable";return"unauthorized"}async function Ri(e){process.stderr.write("Detecting region...");let t=Object.keys(ne),n=await Promise.all(t.map(async(s)=>({region:s,result:await Vg(s,e,5000)}))),i=n.find((s)=>s.result==="authorized");if(!i){process.stderr.write(` failed
126
126
  `);let s=e.startsWith("sk-api-")?"No credentials were changed. Check that the key is valid and belongs to an API secret key.":"No credentials were changed. Check that the key is valid and belongs to a Token Plan.";if(n.every((o)=>o.result==="unauthorized"))throw new y("API key was rejected by all regions.",b.AUTH,s);if(n.some((o)=>o.result==="unreachable"))throw new y("Could not reach the regional API endpoints.",b.NETWORK,"No region was changed. Check the network or proxy, then retry or pass --region global|cn explicitly.");throw new y("Could not determine the API key region.",b.GENERAL,"No region was changed because the API returned an inconclusive response. Retry later or pass --region global|cn explicitly.")}let r=i.region;return process.stderr.write(` ${r}
127
- `),r}async function _c(e){let t=Z();t.region=e,await de(t)}var Us=I(()=>{$e();Ce();G();j()});function Hg(e){if(e instanceof y)return e.exitCode===b.NETWORK||e.exitCode===b.TIMEOUT;if(!(e instanceof Error))return!1;if(e.name==="AbortError"||e.name==="TimeoutError")return!0;let t=e.message.toLowerCase(),n="code"in e?String(e.code).toLowerCase():"";return e instanceof TypeError&&t==="fetch failed"||t.includes("failed to fetch")||t.includes("unable to connect")||t.includes("connection refused")||t.includes("econnrefused")||t.includes("connection reset")||t.includes("econnreset")||t.includes("network error")||t.includes("enotfound")||t.includes("getaddrinfo")||t.includes("proxy")||t.includes("socket")||t.includes("etimedout")||n==="connectionrefused"||n==="econnrefused"||n==="econnreset"||n==="enotfound"||n==="etimedout"}async function Kg(e){try{let t=e.apiKey||e.fileApiKey;if(t&&t.startsWith("sk-api-")){let r=tt(e.baseUrl,t),s=await D(e,{url:r});Je(s,e,t);return}let n=xn(e.baseUrl),i=await D(e,{url:n});Je(i,e)}catch{}}async function kc(e){await Promise.resolve().then(() => Pi());Te.printHelp([],process.stderr,e.region),await Kg(e)}async function Ec(e,t){await Ms(t);let n=Z(),i={...e,region:t,baseUrl:n.oauth?.resource_url||ne[t]};await kc(i)}async function Ac(e,t,n){if(e.dryRun){console.log("Would validate and save API key.");return}let i=n??await Ri(t),r={...e,region:i,baseUrl:ne[i],apiKey:t},s=tt(r.baseUrl,t);try{await D(r,{url:s})}catch(a){if(a instanceof y&&a.exitCode===b.AUTH){let c=t.startsWith("sk-api-")?"Check that your key is valid and belongs to an API secret key.":"Check that your key is valid and belongs to a Token Plan.";throw new y("API key validation failed.",b.AUTH,c)}if(!n)throw a;let l=Hg(a)?`the ${i} API endpoint is unreachable`:`the ${i} API endpoint returned an inconclusive response`;process.stderr.write(`Warning: Could not validate the API key because ${l}.
127
+ `),r}async function _c(e){let t=Z();t.region=e,await de(t)}var Us=I(()=>{$e();Ce();G();j()});function Hg(e){if(e instanceof y)return e.exitCode===b.NETWORK||e.exitCode===b.TIMEOUT;if(!(e instanceof Error))return!1;if(e.name==="AbortError"||e.name==="TimeoutError")return!0;let t=e.message.toLowerCase(),n="code"in e?String(e.code).toLowerCase():"";return e instanceof TypeError&&t==="fetch failed"||t.includes("failed to fetch")||t.includes("unable to connect")||t.includes("connection refused")||t.includes("econnrefused")||t.includes("connection reset")||t.includes("econnreset")||t.includes("network error")||t.includes("enotfound")||t.includes("getaddrinfo")||t.includes("proxy")||t.includes("socket")||t.includes("etimedout")||n==="connectionrefused"||n==="econnrefused"||n==="econnreset"||n==="enotfound"||n==="etimedout"}async function Kg(e){try{let t=e.apiKey||e.fileApiKey;if(t&&t.startsWith("sk-api-")){let r=tt(e.baseUrl,t),s=await D(e,{url:r});Je(s,e,t);return}let n=xn(e.baseUrl),i=await D(e,{url:n});Je(i,e)}catch{}}async function kc(e){await Promise.resolve().then(() => Li());Te.printHelp([],process.stderr,e.region),await Kg(e)}async function Ec(e,t){await Ms(t);let n=Z(),i={...e,region:t,baseUrl:n.oauth?.resource_url||ne[t]};await kc(i)}async function Ac(e,t,n){if(e.dryRun){console.log("Would validate and save API key.");return}let i=n??await Ri(t),r={...e,region:i,baseUrl:ne[i],apiKey:t},s=tt(r.baseUrl,t);try{await D(r,{url:s})}catch(a){if(a instanceof y&&a.exitCode===b.AUTH){let c=t.startsWith("sk-api-")?"Check that your key is valid and belongs to an API secret key.":"Check that your key is valid and belongs to a Token Plan.";throw new y("API key validation failed.",b.AUTH,c)}if(!n)throw a;let l=Hg(a)?`the ${i} API endpoint is unreachable`:`the ${i} API endpoint returned an inconclusive response`;process.stderr.write(`Warning: Could not validate the API key because ${l}.
128
128
  Saving the explicitly selected region "${i}". Requests may fail until validation succeeds.
129
129
  `)}let o=Z();delete o.oauth,o.api_key=t,o.region=i,await de(o),process.stderr.write(`API key saved to ${fe()}
130
130
  `),await kc(r)}var Tc;var Ic=I(()=>{X();G();j();Os();oe();Ni();Us();Xe();Ce();$e();Tc=N({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(e,t){let n=process.env.MINIMAX_API_KEY;if(n&&!t.apiKey){let s=me(n);if(Q({nonInteractive:e.nonInteractive})){await Promise.resolve().then(() => Ee());let l=await Es({message:`MINIMAX_API_KEY is set (${s}). Configure persistent credentials anyway?`,initialValue:!1});if(Re(l)||!l)process.stdout.write(`Login skipped. Using environment variable.
131
131
  `),process.exit(0)}else process.stderr.write(`Warning: MINIMAX_API_KEY is already set in environment.
132
132
  `)}if(t.apiKey){await Ac(e,t.apiKey,t.region);return}if(e.dryRun){console.log("Would prompt for auth method (oauth-global, oauth-cn, api-key).");return}if(!Q({nonInteractive:e.nonInteractive}))throw new y("--api-key is required in non-interactive mode.",b.USAGE,"mmx auth login --api-key sk-xxxxx");if(t.recommend){let s=t.region||await Bl();await Ec(e,s);return}let i=await Is();if(i==="api-key"){await Promise.resolve().then(() => Ee());let a=await As({message:"Paste your MiniMax API key:",validate:(l)=>l&&l.length>0?void 0:"API key cannot be empty."});if(Re(a))throw new y("Authentication cancelled.",b.AUTH);await Ac(e,a,t.region);return}let r=t.region||(i==="oauth-cn"?"cn":"global");await Ec(e,r)}})});var Mc;var Oc=I(()=>{X();Ei();Ze();ee();oe();Ni();Mc=N({name:"auth status",description:"Show current authentication state and quota snapshot",usage:"mmx auth status",examples:["mmx auth status","mmx auth status --output json"],async run(e,t){try{let n=await jt(e),i=F(e.output);if(i!=="text"){let s={method:n.method,source:n.source};if(n.method==="oauth"){let o=await he();if(o){if(s.token_expires=o.expires_at,o.account)s.account=o.account}}else{s.key=me(n.token);let o=tt(e.baseUrl,n.token),a=await D(e,{url:o});s.usage=a}console.log(O(s,i));return}console.log("Authentication Status:"),console.log(` Method: ${n.method}`),console.log(` Source: ${n.source}`);let r=n.token;if(console.log(` Key: ${me(r)}`),n.method==="oauth"){let s=await he();if(s){if(s.account)console.log(` Account: ${s.account}`);let o=new Date(s.expires_at),a=Math.round((o.getTime()-Date.now())/60000);console.log(` Expires in: ${a} minutes`)}}else{let s=tt(e.baseUrl,r);try{let o=await D(e,{url:s});Je(o,e,r)}catch(o){console.log(` Quota fetch failed: ${o.message}`)}return}process.stderr.write(`Fetching quota snapshot...
133
133
  `);try{let s=xn(e.baseUrl),o=await D(e,{url:s,method:"GET"});Je(o,e)}catch(s){console.log(` Quota fetch failed: ${s.message}`)}}catch{let n=F(e.output);console.log(O({authenticated:!1,message:"Not authenticated.",hint:`Run: mmx auth login
134
- Or set $MINIMAX_API_KEY`},n))}}})});var Cc;var Nc=I(()=>{X();G();j();Ze();Rs();ee();Cc=N({name:"auth refresh",description:"Manually refresh OAuth token",usage:"mmx auth refresh",examples:["mmx auth refresh"],async run(e,t){let n=await he();if(!n)throw new y("Not applicable: not authenticated via OAuth.",b.USAGE,"Run mmx auth login first.");if(e.dryRun){console.log("Would refresh OAuth token.");return}let i=await Ns(n.refresh_token,n.region??"global"),r={access_token:i.access_token,refresh_token:i.refresh_token,expires_at:i.expires_at,region:n.region,resource_url:i.resource_url??n.resource_url,account:n.account};await $i(r);let s=F(e.output);if(e.quiet){console.log(r.expires_at);return}console.log(O({status:"Token refreshed",expires:r.expires_at},s))}})});var Rc;var Pc=I(()=>{X();Ze();Ce();Rc=N({name:"auth logout",description:"Revoke tokens and clear stored credentials",usage:"mmx auth logout [--yes] [--dry-run]",options:[{flag:"--yes",description:"Skip confirmation prompt"}],examples:["mmx auth logout","mmx auth logout --dry-run","mmx auth logout --yes"],async run(e,t){let n=await he(),r=!!Z().api_key;if(e.dryRun){if(n)console.log("Would clear oauth from ~/.mmx/config.json");if(r)console.log("Would clear api_key from ~/.mmx/config.json");if(!n&&!r)console.log("No credentials to clear.");console.log("No changes made.");return}if(!n&&!r){process.stderr.write(`No credentials to clear.
134
+ Or set $MINIMAX_API_KEY`},n))}}})});var Cc;var Nc=I(()=>{X();G();j();Ze();Rs();ee();Cc=N({name:"auth refresh",description:"Manually refresh OAuth token",usage:"mmx auth refresh",examples:["mmx auth refresh"],async run(e,t){let n=await he();if(!n)throw new y("Not applicable: not authenticated via OAuth.",b.USAGE,"Run mmx auth login first.");if(e.dryRun){console.log("Would refresh OAuth token.");return}let i=await Ns(n.refresh_token,n.region??"global"),r={access_token:i.access_token,refresh_token:i.refresh_token,expires_at:i.expires_at,region:n.region,resource_url:i.resource_url??n.resource_url,account:n.account};await $i(r);let s=F(e.output);if(e.quiet){console.log(r.expires_at);return}console.log(O({status:"Token refreshed",expires:r.expires_at},s))}})});var Rc;var Lc=I(()=>{X();Ze();Ce();Rc=N({name:"auth logout",description:"Revoke tokens and clear stored credentials",usage:"mmx auth logout [--yes] [--dry-run]",options:[{flag:"--yes",description:"Skip confirmation prompt"}],examples:["mmx auth logout","mmx auth logout --dry-run","mmx auth logout --yes"],async run(e,t){let n=await he(),r=!!Z().api_key;if(e.dryRun){if(n)console.log("Would clear oauth from ~/.mmx/config.json");if(r)console.log("Would clear api_key from ~/.mmx/config.json");if(!n&&!r)console.log("No credentials to clear.");console.log("No changes made.");return}if(!n&&!r){process.stderr.write(`No credentials to clear.
135
135
  `);return}if(n)await Ul(),process.stderr.write(`Cleared oauth from ~/.mmx/config.json
136
136
  `);if(r){let s=Z();delete s.api_key,await de(s),process.stderr.write(`Cleared api_key from ~/.mmx/config.json
137
137
  `)}}})});async function*qe(e){let t=e.body?.getReader();if(!t)return;let n=new TextDecoder,i="",r={},s=(o)=>{let a=o.endsWith("\r")?o.slice(0,-1):o;if(a===""){let u=r.data!==void 0?{data:r.data,event:r.event,id:r.id}:void 0;return r={},u}if(a.startsWith(":"))return;let l=a.indexOf(":");if(l===-1)return;let c=a.slice(0,l),p=a.slice(l+1).trimStart();switch(c){case"data":r.data=r.data!==void 0?`${r.data}
138
138
  ${p}`:p;break;case"event":r.event=p;break;case"id":r.id=p;break}return};try{while(!0){let{done:o,value:a}=await t.read();if(o)break;i+=n.decode(a,{stream:!0});let l=i.split(`
139
- `);i=l.pop()||"";for(let c of l){let p=s(c);if(p)yield p}}if(i+=n.decode(),i.length>0){let o=s(i);if(o)yield o}if(r.data!==void 0)yield{data:r.data,event:r.event,id:r.id}}finally{t.releaseLock()}}var De="MiniMax-M3.1-Flash";import{readFileSync as Wg}from"fs";function Jg(e){return e==="-"?0:e}function Li(e){return Wg(Jg(e),"utf-8")}var js=()=>{};import{readFileSync as Yg}from"fs";function Fc(e,t,n){let i=(1-Math.abs(2*n-1))*t,r=i*(1-Math.abs(e/60%2-1)),s=n-i/2,o=0,a=0,l=0;if(e<60)o=i,a=r;else if(e<120)o=r,a=i;else if(e<180)a=i,l=r;else if(e<240)a=r,l=i;else if(e<300)o=r,l=i;else o=i,l=r;return[Math.round((o+s)*255),Math.round((a+s)*255),Math.round((l+s)*255)]}class qc{frame=0;startTime=0;timer=null;out;noColor;constructor(e,t){this.out=e,this.noColor=t}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 e=Lc[this.frame%Lc.length],t=Math.floor((Date.now()-this.startTime)/1000),n=t>=60?`Thinking (${Math.floor(t/60)}m ${t%60}s)`:`Thinking (${t}s)`;if(this.frame++,this.noColor)this.out.write(`\r${e} ${n}\x1B[0K`);else{let[i,r,s]=Fc(this.frame*17%360,0.85,0.55),[o,a,l]=Fc((this.frame*17+40)%360,0.85,0.55);this.out.write(`\r\x1B[38;2;${i};${r};${s}m${e}\x1B[0m \x1B[38;2;${o};${a};${l}m${n}\x1B[0m\x1B[0K`)}}}function zg(e){let t=[],n;if(e.system)n=e.system;if(e.messagesFile){let i=e.messagesFile,r=Li(i),s=JSON.parse(r);for(let o of s)if(o.role==="system")n=typeof o.content==="string"?o.content:"";else t.push(o)}if(!e.message&&e.prompt)e.message=Array.isArray(e.prompt)?e.prompt:[e.prompt];if(e.message){let i=new Set(["system","user","assistant"]),r=e.message;for(let s of r){let o=s.indexOf(":"),a=o!==-1?s.slice(0,o):"";if(i.has(a)){let l=s.slice(o+1);if(a==="system")n=l;else t.push({role:a,content:l})}else t.push({role:"user",content:s})}}return{system:n,messages:t}}function Xg(e){return e.filter((t)=>t.type==="text").map((t)=>t.text).join("")}var Lc,Dc;var Uc=I(()=>{X();oe();ee();G();j();js();Le();Lc=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];Dc=N({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: ${De})`},{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 ${De} --system "You are a coding assistant." --message "Write fizzbuzz in Python"`,'mmx text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"',"cat conversation.json | mmx text chat --messages-file - --stream",'mmx text chat --message "Hello" --output json'],async run(e,t){let{system:n,messages:i}=zg(t),r=i;if(r.length===0)if(Q({nonInteractive:e.nonInteractive})){let p=await Ae({message:"Enter your message:"});if(!p)process.stderr.write(`Chat cancelled.
139
+ `);i=l.pop()||"";for(let c of l){let p=s(c);if(p)yield p}}if(i+=n.decode(),i.length>0){let o=s(i);if(o)yield o}if(r.data!==void 0)yield{data:r.data,event:r.event,id:r.id}}finally{t.releaseLock()}}var De="MiniMax-M3.1-Flash";import{readFileSync as Wg}from"fs";function Jg(e){return e==="-"?0:e}function Pi(e){return Wg(Jg(e),"utf-8")}var js=()=>{};import{readFileSync as Yg}from"fs";function Fc(e,t,n){let i=(1-Math.abs(2*n-1))*t,r=i*(1-Math.abs(e/60%2-1)),s=n-i/2,o=0,a=0,l=0;if(e<60)o=i,a=r;else if(e<120)o=r,a=i;else if(e<180)a=i,l=r;else if(e<240)a=r,l=i;else if(e<300)o=r,l=i;else o=i,l=r;return[Math.round((o+s)*255),Math.round((a+s)*255),Math.round((l+s)*255)]}class qc{frame=0;startTime=0;timer=null;out;noColor;constructor(e,t){this.out=e,this.noColor=t}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 e=Pc[this.frame%Pc.length],t=Math.floor((Date.now()-this.startTime)/1000),n=t>=60?`Thinking (${Math.floor(t/60)}m ${t%60}s)`:`Thinking (${t}s)`;if(this.frame++,this.noColor)this.out.write(`\r${e} ${n}\x1B[0K`);else{let[i,r,s]=Fc(this.frame*17%360,0.85,0.55),[o,a,l]=Fc((this.frame*17+40)%360,0.85,0.55);this.out.write(`\r\x1B[38;2;${i};${r};${s}m${e}\x1B[0m \x1B[38;2;${o};${a};${l}m${n}\x1B[0m\x1B[0K`)}}}function zg(e){let t=[],n;if(e.system)n=e.system;if(e.messagesFile){let i=e.messagesFile,r=Pi(i),s=JSON.parse(r);for(let o of s)if(o.role==="system")n=typeof o.content==="string"?o.content:"";else t.push(o)}if(!e.message&&e.prompt)e.message=Array.isArray(e.prompt)?e.prompt:[e.prompt];if(e.message){let i=new Set(["system","user","assistant"]),r=e.message;for(let s of r){let o=s.indexOf(":"),a=o!==-1?s.slice(0,o):"";if(i.has(a)){let l=s.slice(o+1);if(a==="system")n=l;else t.push({role:a,content:l})}else t.push({role:"user",content:s})}}return{system:n,messages:t}}function Xg(e){return e.filter((t)=>t.type==="text").map((t)=>t.text).join("")}var Pc,Dc;var Uc=I(()=>{X();oe();ee();G();j();js();Pe();Pc=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];Dc=N({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: ${De})`},{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 ${De} --system "You are a coding assistant." --message "Write fizzbuzz in Python"`,'mmx text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"',"cat conversation.json | mmx text chat --messages-file - --stream",'mmx text chat --message "Hello" --output json'],async run(e,t){let{system:n,messages:i}=zg(t),r=i;if(r.length===0)if(Q({nonInteractive:e.nonInteractive})){let p=await Ae({message:"Enter your message:"});if(!p)process.stderr.write(`Chat cancelled.
140
140
  `),process.exit(1);r=[{role:"user",content:p}]}else yt("message","mmx text chat --message <text>");let s=t.model||e.defaultTextModel||De,o=F(e.output),a=t.stream===!0||t.stream===void 0&&o!=="json"&&process.stdout.isTTY,l={model:s,messages:r,max_tokens:t.maxTokens??4096,stream:a};if(n)l.system=n;if(t.temperature!==void 0)l.temperature=t.temperature;if(t.topP!==void 0)l.top_p=t.topP;if(t.tool){let p=t.tool.map((u)=>{try{return JSON.parse(u)}catch{try{let f=Yg(u,"utf-8");return JSON.parse(f)}catch{throw new y(`Invalid tool definition: "${u}" is neither valid JSON nor a readable file.`,b.USAGE)}}});l.tools=p}if(e.dryRun){console.log(O({request:l},o));return}let c=ki(e.baseUrl);if(a){let p=await Fe(e,{url:c,method:"POST",body:l,stream:!0,authStyle:"x-api-key"}),u=p.headers.get("content-type")||"";if(!u.includes("text/event-stream")&&!u.includes("stream"))throw new y(`Expected SSE stream but got content-type "${u}". Server may be experiencing issues.`,b.GENERAL);let f="",g=!1,h=e.noColor?"":"\x1B[2m",d=e.noColor?"":"\x1B[0m",m=o==="json",w=process.stdout.isTTY&&!m?process.stderr:process.stderr,x=m?void 0:process.stdout,E=new qc(w,e.noColor);for await(let A of qe(p)){if(A.data==="[DONE]")break;try{let _=JSON.parse(A.data);if(_.type==="content_block_start"){if(_.content_block.type==="thinking")g=!0,E.start();else if(_.content_block.type==="text"&&g)E.stop(),g=!1,w.write(`${d}
141
141
  Response:
142
142
  `)}else if(_.type==="content_block_delta"){if(_.delta.type==="text_delta")f+=_.delta.text,x?.write(_.delta.text)}}catch(_){process.stderr.write(`
@@ -187,7 +187,7 @@ ${n}Goodbye!${i}
187
187
  `),h=!1,typeof o.setRawMode==="function")o.setRawMode(!1);o.pause(),process.removeListener("SIGINT",f),process.exit(0)}else a.write(`
188
188
  ${n}Press Ctrl+C again or type /exit to quit.${i}
189
189
  `)};process.on("SIGINT",f);let g=new Bc(a,"> ",n,i),h=!0;o.on("data",(d)=>{g.feed(d)}),a.write(ty);try{while(h){let d=await g.readLine();if(!h)break;let m=d.trim();if(!m)continue;if(m.startsWith("/")){if(u(m)==="exit"){h=!1;break}continue}r.messages.push({role:"user",content:m}),await p()}}finally{if(a.write(ny),typeof o.setRawMode==="function")o.setRawMode(!1);o.pause(),process.removeListener("SIGINT",f),o.removeAllListeners("data"),a.write(`
190
- `)}}})});import{writeFileSync as ry}from"fs";function Kc(e,t,n,i){if(t){let r=e.data.audio;if(!r)throw new y("API response missing audio data (audio field is empty).",b.GENERAL);if(!/^[0-9a-fA-F]*$/.test(r))throw new y("API returned invalid audio data (not valid hex).",b.GENERAL);if(r.length%2!==0)throw new y("API returned truncated audio data (odd-length hex string).",b.GENERAL);try{ry(t,Buffer.from(r,"hex"))}catch(s){if(s.code==="ENOSPC")throw new y("Disk full — cannot write audio file.",b.GENERAL,"Free up disk space and try again.");throw s}if(i)console.log(t);else console.log(O({saved:t,duration_ms:e.extra_info?.audio_length,size_bytes:e.extra_info?.audio_size,sample_rate:e.extra_info?.audio_sample_rate},n))}else{let r=e.data.audio_url??e.data.audio;if(i)console.log(r);else console.log(O({url:r,duration_ms:e.extra_info?.audio_length,size_bytes:e.extra_info?.audio_size},n))}}var Wc=I(()=>{ee();G();j()});function Ks(e){return e.join(", ")}function Yc(e,t){if(!t.includes(e))throw new y(`Invalid audio format "${e}". Supported: ${Ks(t)}`,b.USAGE)}function zc(e,t){return Object.hasOwn(Jc,e)?Jc[e]??t:t}function Xc(e,t){if(t&&e==="wav")throw new y("wav format is not supported in streaming mode.",b.USAGE,"Use mp3, pcm, flac, pcmu_raw, pcmu_wav, or opus for streaming.")}var Hs,Jc;var Qc=I(()=>{G();j();Hs=["mp3","pcm","flac","wav","pcmu_raw","pcmu_wav","opus"];Jc={opus:24000,pcmu_raw:8000,pcmu_wav:8000}});function Zc(e){if(!/^[0-9a-fA-F]+$/.test(e))throw new y("API returned invalid audio data (not valid hex).",b.GENERAL);if(e.length%2!==0)throw new y("API returned truncated audio data (odd-length hex string).",b.GENERAL);return Uint8Array.from(Buffer.from(e,"hex"))}function eu(e,t){let n=t.base_resp?.status_code;if(n!==void 0&&n!==0||t.error)throw wn(e.status,t,e.url||void 0)}function tu(){return new y("API stream ended without audio data.",b.GENERAL)}async function*sy(e){let t=e.headers.get("content-type")||"";if(!t.toLowerCase().includes("text/event-stream")){let i;try{i=await e.json()}catch{throw new y(`Expected SSE audio stream but got content-type "${t||"unknown"}".`,b.GENERAL)}eu(e,i);let r=i.data?.audio;if(!r)throw tu();yield Zc(r);return}let n=!1;for await(let i of qe(e)){if(!i.data||i.data==="[DONE]")break;let r;try{r=JSON.parse(i.data)}catch(o){throw new y(`Failed to parse audio stream chunk: ${o instanceof Error?o.message:String(o)}`,b.GENERAL)}eu(e,r);let s=r.data?.audio;if(s)n=!0,yield Zc(s);if(r.data?.status===2)break}if(!n)throw tu()}async function nu(e){process.stdout.on("error",(t)=>{if(t.code==="EPIPE")process.exit(0);throw t});for await(let t of sy(e))if(!process.stdout.write(t))await new Promise((n)=>process.stdout.once("drain",n))}var iu=I(()=>{Ls();G();j()});import{writeFileSync as oy}from"fs";var Ws;var ru=I(()=>{X();G();j();oe();ee();Wc();js();Qc();iu();Ws=N({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:"--emotion <emotion>",description:"Emotion: happy, sad, angry, fearful, disgusted, surprised, calm, fluent, whisper (passed through as-is; see API Reference below for new values)"},{flag:"--text-normalization",description:"Enable Chinese/English text normalization"},{flag:"--latex-read",description:"Read LaTeX formulas ($$...$$, Chinese only)"},{flag:"--format <fmt>",description:`Audio format: ${Ks(Hs)} (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(e,t){let n=t.text??t._positional?.[0];if(t.textFile)n=Li(t.textFile);if(!n)throw new y("--text or --text-file is required.",b.USAGE,'mmx speech synthesize --text "Hello" --out hello.mp3');let i=t.model||e.defaultSpeechModel||"speech-2.8-hd",r=t.voice||"English_expressive_narrator",s=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),o=t.format||"mp3";Yc(o,Hs),Xc(o,t.stream===!0);let a=t.out??`speech_${s}.${o}`,l="hex",c={model:i,text:n,voice_setting:{voice_id:r,speed:t.speed??void 0,vol:t.volume??void 0,pitch:t.pitch??void 0,emotion:t.emotion||void 0,text_normalization:t.textNormalization===!0?!0:void 0,latex_read:t.latexRead===!0?!0:void 0},audio_setting:{format:t.format||"mp3",sample_rate:t.sampleRate??zc(o,32000),bitrate:t.bitrate??128000,channel:t.channels??1},output_format:l,stream:t.stream===!0};if(t.language)c.language_boost=t.language;if(t.subtitles)c.subtitle_enable=!0;if(t.pronunciation)c.pronunciation_dict={tone:t.pronunciation};if(_e(e,c))return;let p=F(e.output),u=Zl(e.baseUrl);if(t.stream){let g=await Fe(e,{url:u,method:"POST",body:c,stream:!0});await nu(g);return}let f=await D(e,{url:u,method:"POST",body:c});if(!e.quiet)process.stderr.write(`[Model: ${i}]
190
+ `)}}})});import{writeFileSync as ry}from"fs";function Kc(e,t,n,i){if(t){let r=e.data.audio;if(!r)throw new y("API response missing audio data (audio field is empty).",b.GENERAL);if(!/^[0-9a-fA-F]*$/.test(r))throw new y("API returned invalid audio data (not valid hex).",b.GENERAL);if(r.length%2!==0)throw new y("API returned truncated audio data (odd-length hex string).",b.GENERAL);try{ry(t,Buffer.from(r,"hex"))}catch(s){if(s.code==="ENOSPC")throw new y("Disk full — cannot write audio file.",b.GENERAL,"Free up disk space and try again.");throw s}if(i)console.log(t);else console.log(O({saved:t,duration_ms:e.extra_info?.audio_length,size_bytes:e.extra_info?.audio_size,sample_rate:e.extra_info?.audio_sample_rate},n))}else{let r=e.data.audio_url??e.data.audio;if(i)console.log(r);else console.log(O({url:r,duration_ms:e.extra_info?.audio_length,size_bytes:e.extra_info?.audio_size},n))}}var Wc=I(()=>{ee();G();j()});function Ks(e){return e.join(", ")}function Yc(e,t){if(!t.includes(e))throw new y(`Invalid audio format "${e}". Supported: ${Ks(t)}`,b.USAGE)}function zc(e,t){return Object.hasOwn(Jc,e)?Jc[e]??t:t}function Xc(e,t){if(t&&e==="wav")throw new y("wav format is not supported in streaming mode.",b.USAGE,"Use mp3, pcm, flac, pcmu_raw, pcmu_wav, or opus for streaming.")}var Hs,Jc;var Qc=I(()=>{G();j();Hs=["mp3","pcm","flac","wav","pcmu_raw","pcmu_wav","opus"];Jc={opus:24000,pcmu_raw:8000,pcmu_wav:8000}});function Zc(e){if(!/^[0-9a-fA-F]+$/.test(e))throw new y("API returned invalid audio data (not valid hex).",b.GENERAL);if(e.length%2!==0)throw new y("API returned truncated audio data (odd-length hex string).",b.GENERAL);return Uint8Array.from(Buffer.from(e,"hex"))}function eu(e,t){let n=t.base_resp?.status_code;if(n!==void 0&&n!==0||t.error)throw wn(e.status,t,e.url||void 0)}function tu(){return new y("API stream ended without audio data.",b.GENERAL)}async function*sy(e){let t=e.headers.get("content-type")||"";if(!t.toLowerCase().includes("text/event-stream")){let i;try{i=await e.json()}catch{throw new y(`Expected SSE audio stream but got content-type "${t||"unknown"}".`,b.GENERAL)}eu(e,i);let r=i.data?.audio;if(!r)throw tu();yield Zc(r);return}let n=!1;for await(let i of qe(e)){if(!i.data||i.data==="[DONE]")break;let r;try{r=JSON.parse(i.data)}catch(o){throw new y(`Failed to parse audio stream chunk: ${o instanceof Error?o.message:String(o)}`,b.GENERAL)}eu(e,r);let s=r.data?.audio;if(s)n=!0,yield Zc(s);if(r.data?.status===2)break}if(!n)throw tu()}async function nu(e){process.stdout.on("error",(t)=>{if(t.code==="EPIPE")process.exit(0);throw t});for await(let t of sy(e))if(!process.stdout.write(t))await new Promise((n)=>process.stdout.once("drain",n))}var iu=I(()=>{Ps();G();j()});import{writeFileSync as oy}from"fs";var Ws;var ru=I(()=>{X();G();j();oe();ee();Wc();js();Qc();iu();Ws=N({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:"--emotion <emotion>",description:"Emotion: happy, sad, angry, fearful, disgusted, surprised, calm, fluent, whisper (passed through as-is; see API Reference below for new values)"},{flag:"--text-normalization",description:"Enable Chinese/English text normalization"},{flag:"--latex-read",description:"Read LaTeX formulas ($$...$$, Chinese only)"},{flag:"--format <fmt>",description:`Audio format: ${Ks(Hs)} (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(e,t){let n=t.text??t._positional?.[0];if(t.textFile)n=Pi(t.textFile);if(!n)throw new y("--text or --text-file is required.",b.USAGE,'mmx speech synthesize --text "Hello" --out hello.mp3');let i=t.model||e.defaultSpeechModel||"speech-2.8-hd",r=t.voice||"English_expressive_narrator",s=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),o=t.format||"mp3";Yc(o,Hs),Xc(o,t.stream===!0);let a=t.out??`speech_${s}.${o}`,l="hex",c={model:i,text:n,voice_setting:{voice_id:r,speed:t.speed??void 0,vol:t.volume??void 0,pitch:t.pitch??void 0,emotion:t.emotion||void 0,text_normalization:t.textNormalization===!0?!0:void 0,latex_read:t.latexRead===!0?!0:void 0},audio_setting:{format:t.format||"mp3",sample_rate:t.sampleRate??zc(o,32000),bitrate:t.bitrate??128000,channel:t.channels??1},output_format:l,stream:t.stream===!0};if(t.language)c.language_boost=t.language;if(t.subtitles)c.subtitle_enable=!0;if(t.pronunciation)c.pronunciation_dict={tone:t.pronunciation};if(_e(e,c))return;let p=F(e.output),u=Zl(e.baseUrl);if(t.stream){let g=await Fe(e,{url:u,method:"POST",body:c,stream:!0});await nu(g);return}let f=await D(e,{url:u,method:"POST",body:c});if(!e.quiet)process.stderr.write(`[Model: ${i}]
191
191
  `);if(Kc(f,a,p,e.quiet),t.subtitles&&f.data.subtitle_file)try{let g=await fetch(f.data.subtitle_file);if(!g.ok)throw new y(`Failed to download subtitle file: ${g.status}`,b.GENERAL);let h=await g.json();if(h?.length){let d=a.replace(/\.[^.]+$/,"")+".srt",m=h.map((v,w)=>{let x=(E)=>{let A=String(Math.floor(E/3600000)).padStart(2,"0"),_=String(Math.floor(E%3600000/60000)).padStart(2,"0"),S=String(Math.floor(E%60000/1000)).padStart(2,"0"),k=String(Math.round(E%1000)).padStart(3,"0");return`${A}:${_}:${S},${k}`};return`${w+1}
192
192
  ${x(v.time_begin)} --> ${x(v.time_end)}
193
193
  ${v.text}`}).join(`
@@ -196,11 +196,11 @@ ${v.text}`}).join(`
196
196
  `)}else if(t.subtitles&&!f.data.subtitle_file){if(!e.quiet)process.stderr.write(`Warning: subtitles requested but not returned by API
197
197
  `)}}})});import{existsSync as ay}from"node:fs";import{readFile as ly}from"node:fs/promises";import{basename as cy,resolve as uy}from"node:path";function $n(e,t){let n=uy(e);if(!ay(n))throw t(n);return n}async function su({filePath:e,purpose:t,baseUrl:n,requestJson:i,createFileNotFoundError:r}){let s=$n(e,r),o=await ly(s),a=new FormData;return a.append("file",new Blob([o]),cy(s)),a.append("purpose",t),i({url:cc(n),method:"POST",body:a})}var Js=()=>{};function Ys(e){return fy.includes(e)}function lu({model:e,response_format:t,timestamp_level:n,stream:i}){let r={model:e??Di,response_format:t??au};if(n)r.timestamp_level=n;if(i)r.stream="true";return r}function cu(e,t=y){if(!qi.includes(e))throw new t(`Invalid response format "${e}". Supported: ${qi.join(", ")}`,b.USAGE)}function uu(e,t,n=y){if(t&&e!==au)throw new n(`response_format "${e}" cannot be combined with stream=true; streaming returns incremental json only.`,b.USAGE)}function fu(e,t,n=y){if(t>ou)throw new n(`Audio file is ${(t/1024/1024).toFixed(1)} MB; speech-to-text allows at most ${ou/1024/1024} MB: ${e}`,b.USAGE,"Re-encode to compressed mono audio (e.g. mp3 / aac) or split it into smaller files.")}async function du({config:e,url:t,form:n,headers:i,responseFormat:r,stream:s}){if(s)return{kind:"stream",res:await Fe(e,{url:t,method:"POST",body:n,headers:i,stream:!0})};if(Ys(r))return{kind:"subtitle",document:await(await Fe(e,{url:t,method:"POST",body:n,headers:i})).text()};return{kind:"json",response:await D(e,{url:t,method:"POST",body:n,headers:i})}}var Di="asr-1.0",qi,fy,au="json",ou=52428800;var pu=I(()=>{G();j();oe();qi=["json","verbose_json","srt","vtt"],fy=["srt","vtt"]});import{readFileSync as dy,statSync as py,writeFileSync as my}from"node:fs";import{basename as hy,resolve as gy}from"node:path";function zs(e){return e.endsWith(`
198
198
  `)?e:`${e}
199
- `}var Xs;var mu=I(()=>{X();G();j();Js();ee();pu();Le();Xs=N({name:"speech transcribe",description:"Transcribe an audio file to text (asr-1.0)",apiDocs:"/docs/api-reference/speech-to-text",usage:"mmx speech transcribe --file <path> [flags]",options:[{flag:"--file <path>",description:"Audio file to transcribe (mp3, wav, m4a, flac, aac, opus, ogg, aiff)",required:!0},{flag:"--model <model>",description:`Model ID (default: ${Di})`},{flag:"--response-format <fmt>",description:`Transcription format: ${qi.join(", ")} (default: json)`},{flag:"--language <code>",description:"BCP-47 language hint (zh, en, ja, ...); omit for automatic detection"},{flag:"--timestamp-level <level>",description:"Timestamp granularity: sentence, word (verbose_json / srt / vtt only)"},{flag:"--stream",description:"Stream incremental text (json only; pair with --output text when piping)"},{flag:"--out <path>",description:"Write the result to a file instead of stdout"}],examples:["mmx speech transcribe --file meeting.mp3","mmx speech transcribe --file call.mp3 --language zh","mmx speech transcribe --file talk.mp3 --response-format verbose_json --output json","mmx speech transcribe --file talk.mp3 --response-format srt --out talk.srt","mmx speech transcribe --file long.mp3 --stream"],async run(e,t){let n=t.file??t._positional?.[0],i=await Dt({value:n,message:"Enter audio file path:",cancelMessage:"Transcription cancelled.",flagName:"file",usageHint:"mmx speech transcribe --file <path>",nonInteractive:e.nonInteractive}),r=$n(i,(E)=>new y(`File not found: ${E}`,b.USAGE)),s=t.model||Di,o=t.responseFormat||"json",a=t.language||void 0,l=t.timestampLevel||void 0,c=t.stream===!0,p=t.out?gy(t.out):void 0;if(cu(o),fu(r,py(r).size),uu(o,c),c&&p)throw new y("--stream and --out cannot be combined.",b.USAGE,"Redirect stdout instead: mmx speech transcribe --file <path> --stream --output text > transcript.txt");let u=lu({model:s,response_format:o,timestamp_level:l,stream:c}),f={...u,file:r};if(a)f.language=a;if(_e(e,f))return;let g=new FormData;for(let[E,A]of Object.entries(u))g.append(E,A);g.append("file",new Blob([dy(r)]),hy(r));let h={};if(a)h.language=a;let d=ec(e.baseUrl),m=F(e.output);if(!e.quiet)process.stderr.write(`[Model: ${s}]
200
- `);let v=await du({config:e,url:d,form:g,headers:h,responseFormat:o,stream:c});if(v.kind==="stream"){let E=v.res,A=E.headers.get("content-type")||"";if(!A.includes("text/event-stream"))throw new y(`Expected SSE stream but got content-type "${A}". Server may be experiencing issues.`,b.GENERAL);let _=[],S=0,k,R=!1,U=m!=="json";try{for await(let L of qe(E)){if(L.data==="[DONE]")break;let C;try{C=JSON.parse(L.data)}catch(P){process.stderr.write(`[warning] Failed to parse stream chunk: ${P instanceof Error?P.message:String(P)}
199
+ `}var Xs;var mu=I(()=>{X();G();j();Js();ee();pu();Pe();Xs=N({name:"speech transcribe",description:"Transcribe an audio file to text (asr-1.0)",apiDocs:"/docs/api-reference/speech-to-text",usage:"mmx speech transcribe --file <path> [flags]",options:[{flag:"--file <path>",description:"Audio file to transcribe (mp3, wav, m4a, flac, aac, opus, ogg, aiff)",required:!0},{flag:"--model <model>",description:`Model ID (default: ${Di})`},{flag:"--response-format <fmt>",description:`Transcription format: ${qi.join(", ")} (default: json)`},{flag:"--language <code>",description:"BCP-47 language hint (zh, en, ja, ...); omit for automatic detection"},{flag:"--timestamp-level <level>",description:"Timestamp granularity: sentence, word (verbose_json / srt / vtt only)"},{flag:"--stream",description:"Stream incremental text (json only; pair with --output text when piping)"},{flag:"--out <path>",description:"Write the result to a file instead of stdout"}],examples:["mmx speech transcribe --file meeting.mp3","mmx speech transcribe --file call.mp3 --language zh","mmx speech transcribe --file talk.mp3 --response-format verbose_json --output json","mmx speech transcribe --file talk.mp3 --response-format srt --out talk.srt","mmx speech transcribe --file long.mp3 --stream"],async run(e,t){let n=t.file??t._positional?.[0],i=await Dt({value:n,message:"Enter audio file path:",cancelMessage:"Transcription cancelled.",flagName:"file",usageHint:"mmx speech transcribe --file <path>",nonInteractive:e.nonInteractive}),r=$n(i,(E)=>new y(`File not found: ${E}`,b.USAGE)),s=t.model||Di,o=t.responseFormat||"json",a=t.language||void 0,l=t.timestampLevel||void 0,c=t.stream===!0,p=t.out?gy(t.out):void 0;if(cu(o),fu(r,py(r).size),uu(o,c),c&&p)throw new y("--stream and --out cannot be combined.",b.USAGE,"Redirect stdout instead: mmx speech transcribe --file <path> --stream --output text > transcript.txt");let u=lu({model:s,response_format:o,timestamp_level:l,stream:c}),f={...u,file:r};if(a)f.language=a;if(_e(e,f))return;let g=new FormData;for(let[E,A]of Object.entries(u))g.append(E,A);g.append("file",new Blob([dy(r)]),hy(r));let h={};if(a)h.language=a;let d=ec(e.baseUrl),m=F(e.output);if(!e.quiet)process.stderr.write(`[Model: ${s}]
200
+ `);let v=await du({config:e,url:d,form:g,headers:h,responseFormat:o,stream:c});if(v.kind==="stream"){let E=v.res,A=E.headers.get("content-type")||"";if(!A.includes("text/event-stream"))throw new y(`Expected SSE stream but got content-type "${A}". Server may be experiencing issues.`,b.GENERAL);let _=[],S=0,k,R=!1,U=m!=="json";try{for await(let P of qe(E)){if(P.data==="[DONE]")break;let C;try{C=JSON.parse(P.data)}catch(L){process.stderr.write(`[warning] Failed to parse stream chunk: ${L instanceof Error?L.message:String(L)}
201
201
  `);continue}if(typeof C.index==="number"&&C.index!==S)process.stderr.write(`[warning] Stream events arrived out of order (expected index ${S}, got ${C.index}).
202
202
  `);if(typeof C.index==="number")S=C.index+1;if(C.delta){if(_.push({index:typeof C.index==="number"?C.index:_.length,delta:C.delta}),U)process.stdout.write(C.delta)}if(C.finish){k=C.duration,R=!0;break}}}finally{await E.body?.cancel().catch(()=>{return})}if(!R)process.stderr.write(`[warning] Stream ended before the final event; the transcript may be incomplete.
203
- `);let q=_.sort((L,C)=>L.index-C.index).map((L)=>L.delta).join("");if(U)process.stdout.write(`
203
+ `);let q=_.sort((P,C)=>P.index-C.index).map((P)=>P.delta).join("");if(U)process.stdout.write(`
204
204
  `);else process.stdout.write(zs(O({text:q,duration:k},m)));if(!e.quiet&&k!==void 0)process.stderr.write(`[Duration: ${k}s]
205
205
  `);return}let w,x;if(v.kind==="subtitle")w=v.document;else x=v.response.duration,w=m==="json"?O(v.response,m):v.response.text;if(p){try{my(p,Ys(o)?w:zs(w),"utf-8")}catch(E){if(E.code==="ENOSPC")throw new y("Disk full — cannot write transcript file.",b.GENERAL,"Free up disk space and try again.");throw E}if(e.quiet)console.log(p);else{let E={saved:p};if(x!==void 0)E.duration=x;console.log(O(E,m))}return}process.stdout.write(zs(w))}})});function yy(e){let t=e.match(/^(.+?)_[A-Z]/);return t?t[1]:e}function by(e,t){let n=t.toLowerCase();return e.filter((i)=>{let r=yy(i.voice_id).toLowerCase();return r===n||r.startsWith(n+"_")||r.startsWith(n+" (")})}var hu;var gu=I(()=>{X();oe();ee();hu=N({name:"speech voices",description:"List available system voices",usage:"mmx speech voices [--language <lang>]",options:[{flag:"--language <lang>",description:"Filter voices by language (e.g. english, korean, japanese)"}],examples:["mmx speech voices","mmx speech voices --language english","mmx speech voices --language korean","mmx speech voices --output json"],async run(e,t){let n=F(e.output);if(e.dryRun){console.log(O({request:{voice_type:"system"}},n));return}let r=(await D(e,{url:tc(e.baseUrl),method:"POST",body:{voice_type:"system"}})).system_voice??[],s=t.language;if(s){let o=by(r,s);if(n!=="text"){console.log(O(o,n));return}for(let a of o){let l=a.description?.join("; ")||"",c=a.voice_name?` (${a.voice_name})`:"";if(console.log(` ${a.voice_id}${c}`),l)console.log(` ${l}`)}}else{if(n!=="text"){console.log(O(r.map((o)=>o.voice_id),n));return}for(let o of r)console.log(o.voice_id)}}})});function bu(e){let t=process.stderr.isTTY,n=0,i=null,r=e;return{start(){if(!t)return;i=setInterval(()=>{process.stderr.write(`\r${yu[n%yu.length]} ${r}`),n++},80)},update(s){r=s},stop(s){if(i)clearInterval(i),i=null;if(t){if(process.stderr.write("\r\x1B[K"),s)process.stderr.write(`${s}
206
206
  `)}}}}function wu(e,t=""){let n=process.stderr.isTTY,i=30;return{update(r){if(!n)return;let s=Math.min(1,r/e),o=Math.round(30*s),a=30-o,l="█".repeat(o)+"░".repeat(a),c=`${Math.round(s*100)}%`;process.stderr.write(`\r${t} ${l} ${c}`)},finish(){if(n)process.stderr.write(`
@@ -208,30 +208,30 @@ ${v.text}`}).join(`
208
208
  Retry ${m}/${r} in ${w}ms...
209
209
  `);await Iy(w,p.signal)}try{return await Ny(i,t,m,{quiet:c,idleTimeoutMs:a,maxBytes:l},p.signal)}catch(v){if(g=v instanceof Error?v:Error(String(v)),p.signal.aborted)throw nt(p.signal,"Download aborted.");if(!(v instanceof wt||v instanceof Ui&&v.retryable))throw v;if(h=v instanceof Ui||v instanceof wt?v.retryAfterMs:void 0,!c)process.stderr.write(`
210
210
  Download attempt ${m+1} failed: ${g.message}
211
- `);if(m===r)break}}}finally{clearTimeout(f),n?.signal?.removeEventListener("abort",u)}let d=g instanceof y?g.exitCode:b.NETWORK;throw new y(`Download failed after ${r+1} attempts: ${g?.message}`,d,d===b.NETWORK?"Check your network connection and proxy settings.":void 0)}function Gi(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;if(e<1073741824)return`${(e/1048576).toFixed(1)} MB`;return`${(e/1073741824).toFixed(1)} GB`}var Sy=1800000,$y=60000,_y=5368709120,vu=1000,wt,Ui;var _n=I(()=>{Qs();G();j();wt=class wt extends y{retryAfterMs;constructor(e,t=b.NETWORK,n){super(e,t);this.retryAfterMs=n}};Ui=class Ui extends y{retryable;retryAfterMs;constructor(e,t){super(`Download failed: HTTP ${e}`,b.GENERAL);this.retryable=e===408||e===429||e>=500,this.retryAfterMs=t}}});import{readFileSync as Ry,existsSync as Py,statSync as Ly}from"fs";import{extname as Su}from"path";function Gt(e,t){if(t!==void 0){let s=Ly(e).size;if(s>t)throw new y(`Image file is ${(s/1024/1024).toFixed(1)} MB; MiniMax-H3 allows at most ${t/1024/1024} MB.`,b.USAGE,"Use a public URL or mm_file:// file ID for large images.")}let n=Su(e).toLowerCase(),i=Bi[n]||"image/jpeg",r=Ry(e);return`data:${i};base64,${r.toString("base64")}`}function xt(e,t){return e.startsWith("http")||e.startsWith("data:")||e.startsWith("mm_file://")?e:Gt(e,t)}async function $u(e){if(e.startsWith("data:"))return e;if(e.startsWith("http://")||e.startsWith("https://")){let n=await fetch(e);if(!n.ok)throw new y(`Failed to download image: HTTP ${n.status}`,b.GENERAL);let r=(n.headers.get("content-type")||"image/jpeg").split(";")[0].trim(),s=await n.arrayBuffer();if(s.byteLength>Fy)throw new y(`Image too large (${(s.byteLength/1024/1024).toFixed(1)} MB). Maximum is 50 MB.`,b.USAGE);return`data:${r};base64,${Buffer.from(s).toString("base64")}`}if(!Py(e))throw new y(`File not found: ${e}`,b.USAGE);let t=Su(e).toLowerCase();if(!Bi[t])throw new y(`Unsupported image format "${t}". Supported: jpg, jpeg, png, webp`,b.USAGE);return Gt(e)}var Bi,Fy=52428800;var En=I(()=>{G();j();Bi={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp",".heic":"image/heic",".heif":"image/heif"}});import{existsSync as qy,readFileSync as Dy,statSync as Uy}from"fs";import{extname as jy}from"path";function Vi(e){let t=/^data:[^;,]+;base64,([\s\S]*)$/.exec(e);if(!t)return;let n=t[1].replace(/\s/g,""),i=n.endsWith("==")?2:n.endsWith("=")?1:0;return Math.max(0,Math.floor(n.length*3/4)-i)}function eo(e,t){if(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("mm_file://"))return e;if(e.startsWith("data:"))return t==="audio"?e.replace(/^data:audio\/mpeg;base64,/,"data:audio/mp3;base64,"):e;if(!qy(e))throw new y(`File not found: ${e}`,b.USAGE);let n=jy(e).toLowerCase(),i=Gy[t],r=i[n];if(!r){let l=Object.keys(i).map((c)=>c.slice(1)).join(", ");throw new y(`Unsupported ${t} format "${n}". Supported local files: ${l}`,b.USAGE)}let s=vt[t],o=Uy(e).size;if(o>s)throw new y(`${t[0].toUpperCase()}${t.slice(1)} file is ${(o/1024/1024).toFixed(1)} MB; MiniMax-H3 allows at most ${s/1024/1024} MB.`,b.USAGE,"Use a public URL or mm_file:// file ID for large media.");let a=Dy(e);return`data:${r};base64,${a.toString("base64")}`}var Gy,vt,_u=67108864;var Hi=I(()=>{G();j();Gy={video:{".mp4":"video/mp4",".mov":"video/quicktime"},audio:{".mp3":"audio/mp3",".wav":"audio/wav"}},vt={image:31457280,video:52428800,audio:15728640}});import{existsSync as to,mkdirSync as By,writeFileSync as Vy}from"fs";import{dirname as Hy,extname as Ky,join as Wy,resolve as Eu}from"path";function no(e){return e===St}function io(e){return Array.isArray(e.images)}function ro(e){if(e==="png"||e==="webp")return e;return"jpg"}function ib(e){return e==="base64"?"b64_json":e}function Cu(e){if(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("mm_file://"))return e;if(!to(e))throw new z(`Reference image not found: ${e}`);let t=Ky(e).toLowerCase();if(!Bi[t])throw new z(`Unsupported reference image format "${t}". Supported: jpg, jpeg, png, webp, heic, heif.`);return Gt(e,Ou)}function Nu(e){let t={model:St,prompt:e.prompt,n:e.n,size:e.size,aspect_ratio:e.aspectRatio,area:e.area,output_format:e.outputFormat,output_compression:e.outputCompression,response_format:ib(e.responseFormat),aigc_watermark:e.aigcWatermark||void 0},n=e.images??[],i;if(n.length>0){if(e.disablePromptEnhanced)throw new z("Prompt enhancement is always on for image edits; --no-prompt-enhance only applies to text-to-image.");i={...t,images:n.map((r)=>({image_url:r}))}}else i={...t,disable_prompt_enhanced:e.disablePromptEnhanced||void 0};for(let r of Object.keys(i))if(i[r]===void 0)delete i[r];return sb(i),i}function rb(e){let t=/^(\d+):(\d+)$/.exec(e);if(!t)return;return[Number(t[1]),Number(t[2])]}function Iu(e,t){return Math.max(e,t)<=3*Math.min(e,t)}function sb(e){if(!no(e.model))throw new z(`Only ${St} is supported by /v1/images/*.`);let t=typeof e.prompt==="string"?e.prompt.trim():"";if(!t)throw new z("MiniMax-H3-Image requires a non-empty prompt.");if([...t].length>Au)throw new z(`MiniMax-H3-Image prompt must not exceed ${Au} characters.`);if(e.n!==void 0&&(!Number.isInteger(e.n)||e.n<1||e.n>ku))throw new z(`MiniMax-H3-Image n must be an integer from 1 to ${ku}.`);let n=e.size,i=n!==void 0&&n!=="auto";if(i){let o=/^(\d+)x(\d+)$/.exec(n);if(!o)throw new z('MiniMax-H3-Image size must be "auto" or WIDTHxHEIGHT, e.g. 2720x1536.');let a=Number(o[1]),l=Number(o[2]),c=a*l;if(a<1||l<1||c<Jy||c>Yy)throw new z(`MiniMax-H3-Image size area (width x height) must be between 655,360 and 20,000,000 pixels, got ${c.toLocaleString("en-US")}.`);if(!Iu(a,l))throw new z("MiniMax-H3-Image size aspect ratio must be between 1:3 and 3:1.");if(e.aspect_ratio!==void 0||e.area!==void 0)throw new z("MiniMax-H3-Image size WIDTHxHEIGHT cannot be combined with aspect ratio or area.")}let r=e.aspect_ratio;if(r!==void 0&&r!=="auto"){let o=rb(r);if(!o||o.some((a)=>a<1||a>300))throw new z('MiniMax-H3-Image aspect ratio must be "auto" or X:Y with integers from 1 to 300.');if(!Iu(o[0],o[1]))throw new z("MiniMax-H3-Image aspect ratio must be between 1:3 and 3:1.")}if(e.area!==void 0&&!eb.has(e.area))throw new z("MiniMax-H3-Image area must be one of: 1K, 2K, 4K.");if(e.output_format!==void 0&&!tb.has(e.output_format))throw new z("MiniMax-H3-Image output format must be one of: jpg, jpeg, png, webp.");if(e.output_compression!==void 0&&(!Number.isInteger(e.output_compression)||e.output_compression<0||e.output_compression>100))throw new z("MiniMax-H3-Image output compression must be an integer from 0 to 100.");if(e.response_format!==void 0&&!nb.has(e.response_format))throw new z("MiniMax-H3-Image response format must be url or b64_json (alias: base64).");if(e.response_format==="b64_json"){let o=i?Number(n.split("x")[0])*Number(n.split("x")[1]):Xy[e.area??"4K"],a=(e.n??1)*o,l=e.output_format==="png",c=l?Qy:Zy;if(a>c)throw new z(`MiniMax-H3-Image b64_json total output area (n x width x height) is ${a.toLocaleString("en-US")} px; the limit for ${l?"png":"jpeg/webp"} is ${c.toLocaleString("en-US")} px. Lower n or the size/area, or use the url response format.`)}if(io(e)){if(e.disable_prompt_enhanced!==void 0)throw new z("disable_prompt_enhanced is not supported for image edits (enhancement is always on).");let o=e.images.length;if(o<1||o>Tu)throw new z(`MiniMax-H3-Image accepts 1 to ${Tu} reference images.`);for(let a of e.images){if(typeof a?.image_url!=="string"||!a.image_url)throw new z("Each reference image needs a non-empty image_url.");let l=Vi(a.image_url);if(l!==void 0&&l>Ou)throw new z(`MiniMax-H3-Image reference image is ${(l/1024/1024).toFixed(1)} MB; the maximum is 64 MB.`)}}else if(e.disable_prompt_enhanced){if(!i&&!(r!==void 0&&r!=="auto"))throw new z("With prompt enhancement disabled, MiniMax-H3-Image needs an explicit size (WIDTHxHEIGHT) or aspect ratio (X:Y).")}let s=Buffer.byteLength(JSON.stringify(e));if(s>zy)throw new z(`MiniMax-H3-Image request body is ${(s/1024/1024).toFixed(1)} MB; the maximum is 64 MB. Use public URLs or mm_file:// file IDs instead of local files.`)}async function Ru(e,t={}){let n=ro(e.output_format),i=[],r=[];if(e.data.forEach((c,p)=>{if(c.url||c.b64_json)r.push({index:p,url:c.url,b64:c.b64_json});else i.push({index:p,code:c.error?.code,message:c.error?.message})}),t.out&&r.length>1)throw new z("Cannot use `out` with multiple images. Use `outDir` instead.");let s=[],o=t.quiet??!0,a=Eu(t.outDir||"."),l=t.prefix||"image";for(let c of r){let p=t.out?Eu(t.out):Wy(a,`${l}_${String(c.index+1).padStart(3,"0")}.${n}`),u=Hy(p);if(!to(u))By(u,{recursive:!0});if(t.warnOverwrite&&to(p))process.stderr.write(`Warning: overwriting existing file: ${p}
212
- `);if(c.b64)Vy(p,c.b64,"base64");else await Ue(c.url,p,{quiet:o});s.push(p)}return{saved:s,failures:i}}var St="MiniMax-H3-Image",Mu=600,Au=32000,ku=10,Tu=16,Jy=655360,Yy=20000000,Ou=67108864,zy=67108864,Xy,Qy=20000000,Zy=80000000,eb,tb,nb,z;var Pu=I(()=>{_n();En();Hi();Xy={"1K":1048576,"2K":4194304,"4K":16777216},eb=new Set(["1K","2K","4K"]),tb=new Set(["png","jpeg","jpg","webp"]),nb=new Set(["url","b64_json"]);z=class z extends Error{constructor(e){super(e);this.name="ImageH3InputError"}}});import{mkdirSync as Lu,existsSync as An,writeFileSync as Fu}from"fs";import{dirname as ob,extname as ab,join as qu,resolve as so}from"path";function Du(e,t){let n=e;return t.filter(([i])=>n[i]!==void 0&&n[i]!==!1).map(([,i])=>i)}async function ub(e,t,n){let i=Du(t,cb);if(i.length>0)throw new y(`${i.join(", ")} ${i.length>1?"are":"is"} not supported by ${St}.`,b.USAGE,"Use --image for reference images; prompt enhancement is on by default (--no-prompt-enhance to disable).");let{width:r,height:s}=t;if(r===void 0!==(s===void 0))throw new y("--width and --height must be specified together.",b.USAGE,Ki);let o=t.size;if(r!==void 0&&s!==void 0){if(o!==void 0)throw new y("Use either --size or --width/--height, not both.",b.USAGE,Ki);o=`${r}x${s}`}let a=t.out;if(a&&t.n>1)throw new y("--out cannot be used with --n > 1. Use --out-dir instead.",b.USAGE);let l;try{let d=(t.image??[]).map(Cu);l=Nu({prompt:n,images:d,n:t.n,size:o,aspectRatio:t.aspectRatio,area:t.area,outputFormat:t.outputFormat,outputCompression:t.outputCompression,responseFormat:t.responseFormat,disablePromptEnhanced:t.noPromptEnhance===!0,aigcWatermark:t.aigcWatermark===!0})}catch(d){if(d instanceof z)throw new y(d.message,b.USAGE,Ki);throw d}if(_e(e,l))return;let c=F(e.output),p=io(l),u=await D(e,{url:p?rc(e.baseUrl):ic(e.baseUrl),method:"POST",body:l,timeout:Math.max(e.timeout,Mu)});if(!e.quiet)process.stderr.write(`[Model: ${St}${p?" (edit)":""}]
211
+ `);if(m===r)break}}}finally{clearTimeout(f),n?.signal?.removeEventListener("abort",u)}let d=g instanceof y?g.exitCode:b.NETWORK;throw new y(`Download failed after ${r+1} attempts: ${g?.message}`,d,d===b.NETWORK?"Check your network connection and proxy settings.":void 0)}function Gi(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;if(e<1073741824)return`${(e/1048576).toFixed(1)} MB`;return`${(e/1073741824).toFixed(1)} GB`}var Sy=1800000,$y=60000,_y=5368709120,vu=1000,wt,Ui;var _n=I(()=>{Qs();G();j();wt=class wt extends y{retryAfterMs;constructor(e,t=b.NETWORK,n){super(e,t);this.retryAfterMs=n}};Ui=class Ui extends y{retryable;retryAfterMs;constructor(e,t){super(`Download failed: HTTP ${e}`,b.GENERAL);this.retryable=e===408||e===429||e>=500,this.retryAfterMs=t}}});import{readFileSync as Ry,existsSync as Ly,statSync as Py}from"fs";import{extname as Su}from"path";function Gt(e,t){if(t!==void 0){let s=Py(e).size;if(s>t)throw new y(`Image file is ${(s/1024/1024).toFixed(1)} MB; MiniMax-H3 allows at most ${t/1024/1024} MB.`,b.USAGE,"Use a public URL or mm_file:// file ID for large images.")}let n=Su(e).toLowerCase(),i=Bi[n]||"image/jpeg",r=Ry(e);return`data:${i};base64,${r.toString("base64")}`}function xt(e,t){return e.startsWith("http")||e.startsWith("data:")||e.startsWith("mm_file://")?e:Gt(e,t)}async function $u(e){if(e.startsWith("data:"))return e;if(e.startsWith("http://")||e.startsWith("https://")){let n=await fetch(e);if(!n.ok)throw new y(`Failed to download image: HTTP ${n.status}`,b.GENERAL);let r=(n.headers.get("content-type")||"image/jpeg").split(";")[0].trim(),s=await n.arrayBuffer();if(s.byteLength>Fy)throw new y(`Image too large (${(s.byteLength/1024/1024).toFixed(1)} MB). Maximum is 50 MB.`,b.USAGE);return`data:${r};base64,${Buffer.from(s).toString("base64")}`}if(!Ly(e))throw new y(`File not found: ${e}`,b.USAGE);let t=Su(e).toLowerCase();if(!Bi[t])throw new y(`Unsupported image format "${t}". Supported: jpg, jpeg, png, webp`,b.USAGE);return Gt(e)}var Bi,Fy=52428800;var En=I(()=>{G();j();Bi={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp",".heic":"image/heic",".heif":"image/heif"}});import{existsSync as qy,readFileSync as Dy,statSync as Uy}from"fs";import{extname as jy}from"path";function Vi(e){let t=/^data:[^;,]+;base64,([\s\S]*)$/.exec(e);if(!t)return;let n=t[1].replace(/\s/g,""),i=n.endsWith("==")?2:n.endsWith("=")?1:0;return Math.max(0,Math.floor(n.length*3/4)-i)}function eo(e,t){if(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("mm_file://"))return e;if(e.startsWith("data:"))return t==="audio"?e.replace(/^data:audio\/mpeg;base64,/,"data:audio/mp3;base64,"):e;if(!qy(e))throw new y(`File not found: ${e}`,b.USAGE);let n=jy(e).toLowerCase(),i=Gy[t],r=i[n];if(!r){let l=Object.keys(i).map((c)=>c.slice(1)).join(", ");throw new y(`Unsupported ${t} format "${n}". Supported local files: ${l}`,b.USAGE)}let s=vt[t],o=Uy(e).size;if(o>s)throw new y(`${t[0].toUpperCase()}${t.slice(1)} file is ${(o/1024/1024).toFixed(1)} MB; MiniMax-H3 allows at most ${s/1024/1024} MB.`,b.USAGE,"Use a public URL or mm_file:// file ID for large media.");let a=Dy(e);return`data:${r};base64,${a.toString("base64")}`}var Gy,vt,_u=67108864;var Hi=I(()=>{G();j();Gy={video:{".mp4":"video/mp4",".mov":"video/quicktime"},audio:{".mp3":"audio/mp3",".wav":"audio/wav"}},vt={image:31457280,video:52428800,audio:15728640}});import{existsSync as to,mkdirSync as By,writeFileSync as Vy}from"fs";import{dirname as Hy,extname as Ky,join as Wy,resolve as Eu}from"path";function no(e){return e===St}function io(e){return Array.isArray(e.images)}function ro(e){if(e==="png"||e==="webp")return e;return"jpg"}function ib(e){return e==="base64"?"b64_json":e}function Cu(e){if(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("mm_file://"))return e;if(!to(e))throw new z(`Reference image not found: ${e}`);let t=Ky(e).toLowerCase();if(!Bi[t])throw new z(`Unsupported reference image format "${t}". Supported: jpg, jpeg, png, webp, heic, heif.`);return Gt(e,Ou)}function Nu(e){let t={model:St,prompt:e.prompt,n:e.n,size:e.size,aspect_ratio:e.aspectRatio,area:e.area,output_format:e.outputFormat,output_compression:e.outputCompression,response_format:ib(e.responseFormat),aigc_watermark:e.aigcWatermark||void 0},n=e.images??[],i;if(n.length>0){if(e.disablePromptEnhanced)throw new z("Prompt enhancement is always on for image edits; --no-prompt-enhance only applies to text-to-image.");i={...t,images:n.map((r)=>({image_url:r}))}}else i={...t,disable_prompt_enhanced:e.disablePromptEnhanced||void 0};for(let r of Object.keys(i))if(i[r]===void 0)delete i[r];return sb(i),i}function rb(e){let t=/^(\d+):(\d+)$/.exec(e);if(!t)return;return[Number(t[1]),Number(t[2])]}function Iu(e,t){return Math.max(e,t)<=3*Math.min(e,t)}function sb(e){if(!no(e.model))throw new z(`Only ${St} is supported by /v1/images/*.`);let t=typeof e.prompt==="string"?e.prompt.trim():"";if(!t)throw new z("MiniMax-H3-Image requires a non-empty prompt.");if([...t].length>Au)throw new z(`MiniMax-H3-Image prompt must not exceed ${Au} characters.`);if(e.n!==void 0&&(!Number.isInteger(e.n)||e.n<1||e.n>ku))throw new z(`MiniMax-H3-Image n must be an integer from 1 to ${ku}.`);let n=e.size,i=n!==void 0&&n!=="auto";if(i){let o=/^(\d+)x(\d+)$/.exec(n);if(!o)throw new z('MiniMax-H3-Image size must be "auto" or WIDTHxHEIGHT, e.g. 2720x1536.');let a=Number(o[1]),l=Number(o[2]),c=a*l;if(a<1||l<1||c<Jy||c>Yy)throw new z(`MiniMax-H3-Image size area (width x height) must be between 655,360 and 20,000,000 pixels, got ${c.toLocaleString("en-US")}.`);if(!Iu(a,l))throw new z("MiniMax-H3-Image size aspect ratio must be between 1:3 and 3:1.");if(e.aspect_ratio!==void 0||e.area!==void 0)throw new z("MiniMax-H3-Image size WIDTHxHEIGHT cannot be combined with aspect ratio or area.")}let r=e.aspect_ratio;if(r!==void 0&&r!=="auto"){let o=rb(r);if(!o||o.some((a)=>a<1||a>300))throw new z('MiniMax-H3-Image aspect ratio must be "auto" or X:Y with integers from 1 to 300.');if(!Iu(o[0],o[1]))throw new z("MiniMax-H3-Image aspect ratio must be between 1:3 and 3:1.")}if(e.area!==void 0&&!eb.has(e.area))throw new z("MiniMax-H3-Image area must be one of: 1K, 2K, 4K.");if(e.output_format!==void 0&&!tb.has(e.output_format))throw new z("MiniMax-H3-Image output format must be one of: jpg, jpeg, png, webp.");if(e.output_compression!==void 0&&(!Number.isInteger(e.output_compression)||e.output_compression<0||e.output_compression>100))throw new z("MiniMax-H3-Image output compression must be an integer from 0 to 100.");if(e.response_format!==void 0&&!nb.has(e.response_format))throw new z("MiniMax-H3-Image response format must be url or b64_json (alias: base64).");if(e.response_format==="b64_json"){let o=i?Number(n.split("x")[0])*Number(n.split("x")[1]):Xy[e.area??"4K"],a=(e.n??1)*o,l=e.output_format==="png",c=l?Qy:Zy;if(a>c)throw new z(`MiniMax-H3-Image b64_json total output area (n x width x height) is ${a.toLocaleString("en-US")} px; the limit for ${l?"png":"jpeg/webp"} is ${c.toLocaleString("en-US")} px. Lower n or the size/area, or use the url response format.`)}if(io(e)){if(e.disable_prompt_enhanced!==void 0)throw new z("disable_prompt_enhanced is not supported for image edits (enhancement is always on).");let o=e.images.length;if(o<1||o>Tu)throw new z(`MiniMax-H3-Image accepts 1 to ${Tu} reference images.`);for(let a of e.images){if(typeof a?.image_url!=="string"||!a.image_url)throw new z("Each reference image needs a non-empty image_url.");let l=Vi(a.image_url);if(l!==void 0&&l>Ou)throw new z(`MiniMax-H3-Image reference image is ${(l/1024/1024).toFixed(1)} MB; the maximum is 64 MB.`)}}else if(e.disable_prompt_enhanced){if(!i&&!(r!==void 0&&r!=="auto"))throw new z("With prompt enhancement disabled, MiniMax-H3-Image needs an explicit size (WIDTHxHEIGHT) or aspect ratio (X:Y).")}let s=Buffer.byteLength(JSON.stringify(e));if(s>zy)throw new z(`MiniMax-H3-Image request body is ${(s/1024/1024).toFixed(1)} MB; the maximum is 64 MB. Use public URLs or mm_file:// file IDs instead of local files.`)}async function Ru(e,t={}){let n=ro(e.output_format),i=[],r=[];if(e.data.forEach((c,p)=>{if(c.url||c.b64_json)r.push({index:p,url:c.url,b64:c.b64_json});else i.push({index:p,code:c.error?.code,message:c.error?.message})}),t.out&&r.length>1)throw new z("Cannot use `out` with multiple images. Use `outDir` instead.");let s=[],o=t.quiet??!0,a=Eu(t.outDir||"."),l=t.prefix||"image";for(let c of r){let p=t.out?Eu(t.out):Wy(a,`${l}_${String(c.index+1).padStart(3,"0")}.${n}`),u=Hy(p);if(!to(u))By(u,{recursive:!0});if(t.warnOverwrite&&to(p))process.stderr.write(`Warning: overwriting existing file: ${p}
212
+ `);if(c.b64)Vy(p,c.b64,"base64");else await Ue(c.url,p,{quiet:o});s.push(p)}return{saved:s,failures:i}}var St="MiniMax-H3-Image",Mu=600,Au=32000,ku=10,Tu=16,Jy=655360,Yy=20000000,Ou=67108864,zy=67108864,Xy,Qy=20000000,Zy=80000000,eb,tb,nb,z;var Lu=I(()=>{_n();En();Hi();Xy={"1K":1048576,"2K":4194304,"4K":16777216},eb=new Set(["1K","2K","4K"]),tb=new Set(["png","jpeg","jpg","webp"]),nb=new Set(["url","b64_json"]);z=class z extends Error{constructor(e){super(e);this.name="ImageH3InputError"}}});import{mkdirSync as Pu,existsSync as An,writeFileSync as Fu}from"fs";import{dirname as ob,extname as ab,join as qu,resolve as so}from"path";function Du(e,t){let n=e;return t.filter(([i])=>n[i]!==void 0&&n[i]!==!1).map(([,i])=>i)}async function ub(e,t,n){let i=Du(t,cb);if(i.length>0)throw new y(`${i.join(", ")} ${i.length>1?"are":"is"} not supported by ${St}.`,b.USAGE,"Use --image for reference images; prompt enhancement is on by default (--no-prompt-enhance to disable).");let{width:r,height:s}=t;if(r===void 0!==(s===void 0))throw new y("--width and --height must be specified together.",b.USAGE,Ki);let o=t.size;if(r!==void 0&&s!==void 0){if(o!==void 0)throw new y("Use either --size or --width/--height, not both.",b.USAGE,Ki);o=`${r}x${s}`}let a=t.out;if(a&&t.n>1)throw new y("--out cannot be used with --n > 1. Use --out-dir instead.",b.USAGE);let l;try{let d=(t.image??[]).map(Cu);l=Nu({prompt:n,images:d,n:t.n,size:o,aspectRatio:t.aspectRatio,area:t.area,outputFormat:t.outputFormat,outputCompression:t.outputCompression,responseFormat:t.responseFormat,disablePromptEnhanced:t.noPromptEnhance===!0,aigcWatermark:t.aigcWatermark===!0})}catch(d){if(d instanceof z)throw new y(d.message,b.USAGE,Ki);throw d}if(_e(e,l))return;let c=F(e.output),p=io(l),u=await D(e,{url:p?rc(e.baseUrl):ic(e.baseUrl),method:"POST",body:l,timeout:Math.max(e.timeout,Mu)});if(!e.quiet)process.stderr.write(`[Model: ${St}${p?" (edit)":""}]
213
213
  `);let{saved:f,failures:g}=await Ru(u,{out:a,outDir:t.outDir,prefix:t.outPrefix,quiet:e.quiet,warnOverwrite:!0});for(let d of g)process.stderr.write(`Warning: image ${d.index+1} failed${d.code?` (${d.code})`:""}: ${d.message??"unknown error"}
214
214
  `);if(a&&f.length>0){let d=ro(u.output_format),m=ab(a).toLowerCase().replace(/^\./,"").replace(/^jpeg$/,"jpg");if(m!==d)process.stderr.write(`Warning: --out ${a} has a .${m||"(none)"} extension but the image is ${d}.
215
215
  `)}let h={id:u.request_id,saved:f,success_count:f.length,failed_count:g.length};if(g.length>0)h.failures=g;if(c==="json"){if(h.sizes=u.data.map((d)=>d.size??null),h.revised_prompts=u.data.map((d)=>d.revised_prompt??null),u.usage)h.usage=u.usage;console.log(O(h,c))}else if(e.quiet)console.log(f.join(`
216
- `));else console.log(O(h,c))}var Ki="mmx image generate --model MiniMax-H3-Image --prompt <text>",lb,cb,Uu;var ju=I(()=>{X();G();j();oe();_n();ee();En();Le();Pu();lb=[["image","--image"],["size","--size"],["area","--area"],["outputFormat","--output-format"],["outputCompression","--output-compression"],["noPromptEnhance","--no-prompt-enhance"]],cb=[["seed","--seed"],["promptOptimizer","--prompt-optimizer"],["subjectRef","--subject-ref"]];Uu=N({name:"image generate",description:"Generate or edit images (image-01 / MiniMax-H3-Image)",apiDocs:"/docs/guides/image-generation",usage:"mmx image generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID: image-01 (default), image-01-live, or MiniMax-H3-Image. Other values are passed to the image-01 endpoint as-is."},{flag:"--prompt <text>",description:"Image description",required:!0},{flag:"--image <path-or-url>",description:"H3: reference image for image editing (repeatable, 1-16; local file, URL, data URI, or mm_file:// ID).",type:"array"},{flag:"--aspect-ratio <ratio>",description:"Aspect ratio (e.g. 16:9, 1:1). image-01: ignored if --width and --height are both specified. H3: auto or X:Y (integers 1-300) between 1:3 and 3:1; cannot be combined with --size/--width/--height."},{flag:"--size <WxH>",description:"H3: output size, auto (default) or WIDTHxHEIGHT (e.g. 2720x1536). Cannot be combined with --aspect-ratio/--area."},{flag:"--area <level>",description:"H3: area level 1K, 2K, or 4K (default: 4K)."},{flag:"--output-format <fmt>",description:"H3: jpg (default), png, or webp."},{flag:"--output-compression <q>",description:"H3: JPEG/WEBP quality 0-100 (default: 95).",type:"number"},{flag:"--no-prompt-enhance",description:"H3 text-to-image: disable prompt enhancement (requires --size or a concrete --aspect-ratio)."},{flag:"--n <count>",description:"Number of images to generate (default: 1; H3: 1-10)",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. image-01: range [512, 2048], multiple of 8, overrides --aspect-ratio. H3: shorthand for --size WIDTHxHEIGHT.",type:"number"},{flag:"--height <px>",description:"Custom height in pixels. image-01: range [512, 2048], multiple of 8, overrides --aspect-ratio. H3: shorthand for --size WIDTHxHEIGHT.",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. H3 also accepts b64_json; total area n x W x H is limited to 20 MP (png) or 80 MP (jpg/webp)."},{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',"# MiniMax-H3-Image text-to-image",'mmx image generate --model MiniMax-H3-Image --prompt "An orange cat on a sunny windowsill" --aspect-ratio 16:9 --area 2K','mmx image generate --model MiniMax-H3-Image --prompt "Poster" --size 2720x1536 --output-format png',"# MiniMax-H3-Image image editing (1-16 reference images)",'mmx image generate --model MiniMax-H3-Image --prompt "Replace the cat in Picture 1 with the dog in Picture 2" --image cat.jpg --image https://example.com/dog.png'],async run(e,t){let n=t.prompt??t._positional?.[0];n=await Dt({value:n,message:"Enter your image prompt:",cancelMessage:"Image generation cancelled.",flagName:"prompt",usageHint:"mmx image generate --prompt <text>",nonInteractive:e.nonInteractive});let i=t.model||"image-01";if(no(i)){await ub(e,t,n);return}let r=Du(t,lb);if(r.length>0)throw new y(`${r.join(", ")} ${r.length>1?"require":"requires"} --model ${St}.`,b.USAGE,Ki);let{width:s,height:o}=t;if(s!==void 0&&o===void 0)throw new y("--width requires --height. Both must be specified together.",b.USAGE);if(o!==void 0&&s===void 0)throw new y("--height requires --width. Both must be specified together.",b.USAGE);if(s!==void 0&&o!==void 0){let h=(d,m)=>{if(m<512||m>2048)throw new y(`--${d} must be between 512 and 2048, got ${m}.`,b.USAGE);if(m%8!==0)throw new y(`--${d} must be a multiple of 8, got ${m}.`,b.USAGE)};h("width",s),h("height",o)}let a=t.out;if(a&&t.n>1)throw new y("--out cannot be used with --n > 1. Use --out-dir instead.",b.USAGE);let l=t.responseFormat||"url",c={model:i,prompt:n,aspect_ratio:s!==void 0&&o!==void 0?void 0:t.aspectRatio||void 0,n:t.n??1,seed:t.seed,width:s,height:o,prompt_optimizer:t.promptOptimizer===!0||void 0,aigc_watermark:t.aigcWatermark===!0||void 0,response_format:l};if(t.subjectRef){let h=t.subjectRef,d=Object.fromEntries(h.split(",").map((v)=>{let w=v.indexOf("=");if(w===-1)return[v,""];return[v.slice(0,w),v.slice(w+1)]})),m={type:d.type||"character"};if(d.image)if(d.image.startsWith("http"))m.image_url=d.image;else m.image_file=Gt(so(d.image));c.subject_reference=[m]}if(_e(e,c))return;let p=F(e.output),u=nc(e.baseUrl),f=await D(e,{url:u,method:"POST",body:c});if(!e.quiet)process.stderr.write(`[Model: ${i}]
217
- `);let g=[];if(a){let h=ob(so(a));if(!An(h))Lu(h,{recursive:!0});let d=so(a);if(An(d))process.stderr.write(`Warning: overwriting existing file: ${d}
218
- `);if(l==="base64"){let m=(f.data.image_base64||[])[0];if(m)Fu(d,m,"base64")}else{let m=(f.data.image_urls||[])[0];if(m)await Ue(m,d,{quiet:e.quiet})}g.push(d)}else{let h=t.outDir??".";if(!An(h))Lu(h,{recursive:!0});let d=t.outPrefix||"image";if(l==="base64"){let m=f.data.image_base64||[];for(let v=0;v<m.length;v++){let w=`${d}_${String(v+1).padStart(3,"0")}.jpg`,x=qu(h,w);if(An(x))process.stderr.write(`Warning: overwriting existing file: ${x}
216
+ `));else console.log(O(h,c))}var Ki="mmx image generate --model MiniMax-H3-Image --prompt <text>",lb,cb,Uu;var ju=I(()=>{X();G();j();oe();_n();ee();En();Pe();Lu();lb=[["image","--image"],["size","--size"],["area","--area"],["outputFormat","--output-format"],["outputCompression","--output-compression"],["noPromptEnhance","--no-prompt-enhance"]],cb=[["seed","--seed"],["promptOptimizer","--prompt-optimizer"],["subjectRef","--subject-ref"]];Uu=N({name:"image generate",description:"Generate or edit images (image-01 / MiniMax-H3-Image)",apiDocs:"/docs/guides/image-generation",usage:"mmx image generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID: image-01 (default), image-01-live, or MiniMax-H3-Image. Other values are passed to the image-01 endpoint as-is."},{flag:"--prompt <text>",description:"Image description",required:!0},{flag:"--image <path-or-url>",description:"H3: reference image for image editing (repeatable, 1-16; local file, URL, data URI, or mm_file:// ID).",type:"array"},{flag:"--aspect-ratio <ratio>",description:"Aspect ratio (e.g. 16:9, 1:1). image-01: ignored if --width and --height are both specified. H3: auto or X:Y (integers 1-300) between 1:3 and 3:1; cannot be combined with --size/--width/--height."},{flag:"--size <WxH>",description:"H3: output size, auto (default) or WIDTHxHEIGHT (e.g. 2720x1536). Cannot be combined with --aspect-ratio/--area."},{flag:"--area <level>",description:"H3: area level 1K, 2K, or 4K (default: 4K)."},{flag:"--output-format <fmt>",description:"H3: jpg (default), png, or webp."},{flag:"--output-compression <q>",description:"H3: JPEG/WEBP quality 0-100 (default: 95).",type:"number"},{flag:"--no-prompt-enhance",description:"H3 text-to-image: disable prompt enhancement (requires --size or a concrete --aspect-ratio)."},{flag:"--n <count>",description:"Number of images to generate (default: 1; H3: 1-10)",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. image-01: range [512, 2048], multiple of 8, overrides --aspect-ratio. H3: shorthand for --size WIDTHxHEIGHT.",type:"number"},{flag:"--height <px>",description:"Custom height in pixels. image-01: range [512, 2048], multiple of 8, overrides --aspect-ratio. H3: shorthand for --size WIDTHxHEIGHT.",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. H3 also accepts b64_json; total area n x W x H is limited to 20 MP (png) or 80 MP (jpg/webp)."},{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',"# MiniMax-H3-Image text-to-image",'mmx image generate --model MiniMax-H3-Image --prompt "An orange cat on a sunny windowsill" --aspect-ratio 16:9 --area 2K','mmx image generate --model MiniMax-H3-Image --prompt "Poster" --size 2720x1536 --output-format png',"# MiniMax-H3-Image image editing (1-16 reference images)",'mmx image generate --model MiniMax-H3-Image --prompt "Replace the cat in Picture 1 with the dog in Picture 2" --image cat.jpg --image https://example.com/dog.png'],async run(e,t){let n=t.prompt??t._positional?.[0];n=await Dt({value:n,message:"Enter your image prompt:",cancelMessage:"Image generation cancelled.",flagName:"prompt",usageHint:"mmx image generate --prompt <text>",nonInteractive:e.nonInteractive});let i=t.model||"image-01";if(no(i)){await ub(e,t,n);return}let r=Du(t,lb);if(r.length>0)throw new y(`${r.join(", ")} ${r.length>1?"require":"requires"} --model ${St}.`,b.USAGE,Ki);let{width:s,height:o}=t;if(s!==void 0&&o===void 0)throw new y("--width requires --height. Both must be specified together.",b.USAGE);if(o!==void 0&&s===void 0)throw new y("--height requires --width. Both must be specified together.",b.USAGE);if(s!==void 0&&o!==void 0){let h=(d,m)=>{if(m<512||m>2048)throw new y(`--${d} must be between 512 and 2048, got ${m}.`,b.USAGE);if(m%8!==0)throw new y(`--${d} must be a multiple of 8, got ${m}.`,b.USAGE)};h("width",s),h("height",o)}let a=t.out;if(a&&t.n>1)throw new y("--out cannot be used with --n > 1. Use --out-dir instead.",b.USAGE);let l=t.responseFormat||"url",c={model:i,prompt:n,aspect_ratio:s!==void 0&&o!==void 0?void 0:t.aspectRatio||void 0,n:t.n??1,seed:t.seed,width:s,height:o,prompt_optimizer:t.promptOptimizer===!0||void 0,aigc_watermark:t.aigcWatermark===!0||void 0,response_format:l};if(t.subjectRef){let h=t.subjectRef,d=Object.fromEntries(h.split(",").map((v)=>{let w=v.indexOf("=");if(w===-1)return[v,""];return[v.slice(0,w),v.slice(w+1)]})),m={type:d.type||"character"};if(d.image)if(d.image.startsWith("http"))m.image_url=d.image;else m.image_file=Gt(so(d.image));c.subject_reference=[m]}if(_e(e,c))return;let p=F(e.output),u=nc(e.baseUrl),f=await D(e,{url:u,method:"POST",body:c});if(!e.quiet)process.stderr.write(`[Model: ${i}]
217
+ `);let g=[];if(a){let h=ob(so(a));if(!An(h))Pu(h,{recursive:!0});let d=so(a);if(An(d))process.stderr.write(`Warning: overwriting existing file: ${d}
218
+ `);if(l==="base64"){let m=(f.data.image_base64||[])[0];if(m)Fu(d,m,"base64")}else{let m=(f.data.image_urls||[])[0];if(m)await Ue(m,d,{quiet:e.quiet})}g.push(d)}else{let h=t.outDir??".";if(!An(h))Pu(h,{recursive:!0});let d=t.outPrefix||"image";if(l==="base64"){let m=f.data.image_base64||[];for(let v=0;v<m.length;v++){let w=`${d}_${String(v+1).padStart(3,"0")}.jpg`,x=qu(h,w);if(An(x))process.stderr.write(`Warning: overwriting existing file: ${x}
219
219
  `);Fu(x,m[v],"base64"),g.push(x)}}else{let m=f.data.image_urls||[];for(let v=0;v<m.length;v++){let w=`${d}_${String(v+1).padStart(3,"0")}.jpg`,x=qu(h,w);if(An(x))process.stderr.write(`Warning: overwriting existing file: ${x}
220
220
  `);await Ue(m[v],x,{quiet:e.quiet}),g.push(x)}}}if(p==="json")console.log(O({id:f.data.task_id,saved:g,success_count:f.data.success_count,failed_count:f.data.failed_count},p));else if(e.quiet)console.log(g.join(`
221
- `));else console.log(O({id:f.data.task_id,saved:g,success_count:f.data.success_count,failed_count:f.data.failed_count},p))}})});async function oo(e,t){let n=Date.now()+t.timeoutSec*1000,i=bu("Polling...");if(!e.quiet)i.start();try{while(Date.now()<n){let r=await D(e,{url:t.url});if(t.getStatus&&!e.quiet)i.update(`Status: ${t.getStatus(r)}`);if(t.isComplete(r))return i.stop("Done."),r;if(t.isFailed(r)){i.stop("Failed.");let s=t.getStatus?t.getStatus(r):"failed",o=r.base_resp?.status_msg,a=t.getFailureReason?.(r)??o,l=a?` (${a})`:"";throw new y(`Task ${s}.${l}`,b.GENERAL,"Check the MiniMax dashboard or --verbose output for details.")}await new Promise((s)=>setTimeout(s,Math.min(t.intervalSec*1000,Math.max(0,n-Date.now()))))}}finally{i.stop()}throw new y("Polling timed out.",b.TIMEOUT,"Try increasing --timeout or check task status manually.")}var Gu=I(()=>{oe();G();j();Qs()});function $t(e){return e===kn}function Bu(e){return $t(e.model)}function Vu(e){let t=e.error?.code?.trim(),n=e.error?.message?.trim();if(t&&n)return`${t}: ${n}`;return n||t}function Hu(e){let t=e.images??[];if(t.length>1&&t.some((o)=>!o.role))throw new ie("Each image must specify a role when multiple images are provided.");let n=[{type:"text",text:e.prompt},...t.map((o)=>({type:"image_url",image_url:{url:o.url},role:o.role??"first_frame"})),...(e.referenceVideos??[]).map((o)=>({type:"video_url",video_url:{url:o},role:"reference_video"})),...(e.referenceAudios??[]).map((o)=>({type:"audio_url",audio_url:{url:o},role:"reference_audio"}))],i=n.some((o)=>o.type==="image_url"&&(o.role==="first_frame"||o.role==="last_frame")),r=n.some((o)=>o.type!=="text"&&o.role?.startsWith("reference_")),s={model:kn,content:n,resolution:e.resolution??"2K",duration:e.duration??5,ratio:i?"adaptive":e.ratio??(r?"adaptive":"16:9")};if(e.callbackUrl)s.callback_url=e.callbackUrl;return mb(s),s}function mb(e){if(!$t(e.model))throw new ie(`Video Generation V2 only supports ${kn}.`);let t=e.content.filter((f)=>f.type==="text");if(!t.some((f)=>f.text.trim().length>0))throw new ie("MiniMax-H3 requires a non-empty text content item.");if(t.some((f)=>f.text.length>7000))throw new ie("MiniMax-H3 text content must not exceed 7000 characters.");if(!fb.has(e.resolution))throw new ie("MiniMax-H3 resolution must be one of: 768P, 2K.");if(!Number.isInteger(e.duration)||e.duration<4||e.duration>15)throw new ie("MiniMax-H3 duration must be an integer from 4 to 15 seconds.");if(e.ratio&&!db.has(e.ratio))throw new ie("MiniMax-H3 ratio must be one of: adaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16.");let n=e.content.filter((f)=>f.type==="image_url"),i=e.content.filter((f)=>f.type==="video_url"),r=e.content.filter((f)=>f.type==="audio_url");if(n.some((f)=>f.role&&!pb.has(f.role)))throw new ie("MiniMax-H3 image role must be one of: first_frame, last_frame, reference_image.");if(i.some((f)=>f.role!=="reference_video"))throw new ie("MiniMax-H3 video role must be reference_video.");if(r.some((f)=>f.role!=="reference_audio"))throw new ie("MiniMax-H3 audio role must be reference_audio.");for(let f of n)ao(f.image_url.url,"image");for(let f of i)ao(f.video_url.url,"video");for(let f of r)ao(f.audio_url.url,"audio");let s=Buffer.byteLength(JSON.stringify(e));if(s>_u)throw new ie(`MiniMax-H3 request body is ${(s/1024/1024).toFixed(1)} MB; the maximum is 64 MB. Use public URLs or mm_file:// file IDs instead of Base64.`);let o=n.filter((f)=>!f.role||f.role==="first_frame"),a=n.filter((f)=>f.role==="last_frame"),l=n.filter((f)=>f.role==="reference_image"),c=o.length>0||a.length>0,p=l.length>0||i.length>0||r.length>0;if(o.length>1||a.length>1)throw new ie("MiniMax-H3 accepts at most one first frame and one last frame.");if(l.length>9||i.length>3||r.length>3)throw new ie("MiniMax-H3 accepts up to 9 reference images, 3 reference videos, and 3 reference audios.");if(c&&p)throw new ie("MiniMax-H3 frame inputs and reference inputs cannot be used together.");if(r.length>0&&l.length===0&&i.length===0)throw new ie("MiniMax-H3 reference audio requires at least one reference image or reference video.");if(e.content.every((f)=>f.type==="text")&&(!e.ratio||e.ratio==="adaptive"))throw new ie("MiniMax-H3 text-to-video requires a concrete ratio; adaptive is not supported.")}function ao(e,t){let n=Vi(e),i=vt[t];if(n!==void 0&&n>i)throw new ie(`MiniMax-H3 ${t} input is ${(n/1024/1024).toFixed(1)} MB; the maximum is ${i/1024/1024} MB.`)}var kn="MiniMax-H3",fb,db,pb,ie;var lo=I(()=>{Hi();fb=new Set(["768P","2K"]),db=new Set(["adaptive","21:9","16:9","4:3","1:1","3:4","9:16"]),pb=new Set(["first_frame","last_frame","reference_image"]);ie=class ie extends Error{constructor(e){super(e);this.name="VideoV2InputError"}}});var Ku;var Wu=I(()=>{X();G();j();oe();Gu();_n();ee();En();Hi();Le();lo();Ku=N({name:"video generate",description:`Generate a video
221
+ `));else console.log(O({id:f.data.task_id,saved:g,success_count:f.data.success_count,failed_count:f.data.failed_count},p))}})});async function oo(e,t){let n=Date.now()+t.timeoutSec*1000,i=bu("Polling...");if(!e.quiet)i.start();try{while(Date.now()<n){let r=await D(e,{url:t.url});if(t.getStatus&&!e.quiet)i.update(`Status: ${t.getStatus(r)}`);if(t.isComplete(r))return i.stop("Done."),r;if(t.isFailed(r)){i.stop("Failed.");let s=t.getStatus?t.getStatus(r):"failed",o=r.base_resp?.status_msg,a=t.getFailureReason?.(r)??o,l=a?` (${a})`:"";throw new y(`Task ${s}.${l}`,b.GENERAL,"Check the MiniMax dashboard or --verbose output for details.")}await new Promise((s)=>setTimeout(s,Math.min(t.intervalSec*1000,Math.max(0,n-Date.now()))))}}finally{i.stop()}throw new y("Polling timed out.",b.TIMEOUT,"Try increasing --timeout or check task status manually.")}var Gu=I(()=>{oe();G();j();Qs()});function $t(e){return e===kn}function Bu(e){return $t(e.model)}function Vu(e){let t=e.error?.code?.trim(),n=e.error?.message?.trim();if(t&&n)return`${t}: ${n}`;return n||t}function Hu(e){let t=e.images??[];if(t.length>1&&t.some((o)=>!o.role))throw new ie("Each image must specify a role when multiple images are provided.");let n=[{type:"text",text:e.prompt},...t.map((o)=>({type:"image_url",image_url:{url:o.url},role:o.role??"first_frame"})),...(e.referenceVideos??[]).map((o)=>({type:"video_url",video_url:{url:o},role:"reference_video"})),...(e.referenceAudios??[]).map((o)=>({type:"audio_url",audio_url:{url:o},role:"reference_audio"}))],i=n.some((o)=>o.type==="image_url"&&(o.role==="first_frame"||o.role==="last_frame")),r=n.some((o)=>o.type!=="text"&&o.role?.startsWith("reference_")),s={model:kn,content:n,resolution:e.resolution??"2K",duration:e.duration??5,ratio:i?"adaptive":e.ratio??(r?"adaptive":"16:9")};if(e.callbackUrl)s.callback_url=e.callbackUrl;return mb(s),s}function mb(e){if(!$t(e.model))throw new ie(`Video Generation V2 only supports ${kn}.`);let t=e.content.filter((f)=>f.type==="text");if(!t.some((f)=>f.text.trim().length>0))throw new ie("MiniMax-H3 requires a non-empty text content item.");if(t.some((f)=>f.text.length>7000))throw new ie("MiniMax-H3 text content must not exceed 7000 characters.");if(!fb.has(e.resolution))throw new ie("MiniMax-H3 resolution must be one of: 768P, 2K.");if(!Number.isInteger(e.duration)||e.duration<4||e.duration>15)throw new ie("MiniMax-H3 duration must be an integer from 4 to 15 seconds.");if(e.ratio&&!db.has(e.ratio))throw new ie("MiniMax-H3 ratio must be one of: adaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16.");let n=e.content.filter((f)=>f.type==="image_url"),i=e.content.filter((f)=>f.type==="video_url"),r=e.content.filter((f)=>f.type==="audio_url");if(n.some((f)=>f.role&&!pb.has(f.role)))throw new ie("MiniMax-H3 image role must be one of: first_frame, last_frame, reference_image.");if(i.some((f)=>f.role!=="reference_video"))throw new ie("MiniMax-H3 video role must be reference_video.");if(r.some((f)=>f.role!=="reference_audio"))throw new ie("MiniMax-H3 audio role must be reference_audio.");for(let f of n)ao(f.image_url.url,"image");for(let f of i)ao(f.video_url.url,"video");for(let f of r)ao(f.audio_url.url,"audio");let s=Buffer.byteLength(JSON.stringify(e));if(s>_u)throw new ie(`MiniMax-H3 request body is ${(s/1024/1024).toFixed(1)} MB; the maximum is 64 MB. Use public URLs or mm_file:// file IDs instead of Base64.`);let o=n.filter((f)=>!f.role||f.role==="first_frame"),a=n.filter((f)=>f.role==="last_frame"),l=n.filter((f)=>f.role==="reference_image"),c=o.length>0||a.length>0,p=l.length>0||i.length>0||r.length>0;if(o.length>1||a.length>1)throw new ie("MiniMax-H3 accepts at most one first frame and one last frame.");if(l.length>9||i.length>3||r.length>3)throw new ie("MiniMax-H3 accepts up to 9 reference images, 3 reference videos, and 3 reference audios.");if(c&&p)throw new ie("MiniMax-H3 frame inputs and reference inputs cannot be used together.");if(r.length>0&&l.length===0&&i.length===0)throw new ie("MiniMax-H3 reference audio requires at least one reference image or reference video.");if(e.content.every((f)=>f.type==="text")&&(!e.ratio||e.ratio==="adaptive"))throw new ie("MiniMax-H3 text-to-video requires a concrete ratio; adaptive is not supported.")}function ao(e,t){let n=Vi(e),i=vt[t];if(n!==void 0&&n>i)throw new ie(`MiniMax-H3 ${t} input is ${(n/1024/1024).toFixed(1)} MB; the maximum is ${i/1024/1024} MB.`)}var kn="MiniMax-H3",fb,db,pb,ie;var lo=I(()=>{Hi();fb=new Set(["768P","2K"]),db=new Set(["adaptive","21:9","16:9","4:3","1:1","3:4","9:16"]),pb=new Set(["first_frame","last_frame","reference_image"]);ie=class ie extends Error{constructor(e){super(e);this.name="VideoV2InputError"}}});var Ku;var Wu=I(()=>{X();G();j();oe();Gu();_n();ee();En();Hi();Pe();lo();Ku=N({name:"video generate",description:`Generate a video
222
222
  V2: MiniMax-H3 (text/image/video/audio content, 768P/2K)
223
223
  T2V: Hailuo-2.3
224
224
  I2V: Hailuo-2.3 (default) / Hailuo-2.3-Fast (fast mode, requires --image)
225
225
  SEF: Hailuo-02 (requires --image and --last-frame)
226
226
  S2V: S2V-01 (requires --subject-image)`,apiDocs:"/docs/api-reference/video-generation-v2-create",usage:"mmx video generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID. V2: MiniMax-H3. Legacy: MiniMax-Hailuo-2.3 or MiniMax-Hailuo-2.3-Fast. Auto-switched to Hailuo-02 with --last-frame, or S2V-01 with --subject-image."},{flag:"--prompt <text>",description:"Video description",required:!0},{flag:"--image <path-or-url>",description:"Input image for image-to-video (local path or URL)."},{flag:"--first-frame <path-or-url>",description:"Backward-compatible alias for --image.",hidden:!0},{flag:"--last-frame <path-or-url>",description:"Optional ending image. Legacy SEF also requires --image; MiniMax-H3 supports a last frame alone."},{flag:"--subject-image <path-or-url>",description:"Subject reference image for character consistency (local path or URL). Switches to S2V-01 model."},{flag:"--reference-image <path-or-url>",description:"H3 reference image (repeatable).",type:"array"},{flag:"--reference-video <path-or-url>",description:"H3 reference video (repeatable; local MP4/MOV, URL, data URI, or mm_file:// ID).",type:"array"},{flag:"--reference-audio <path-or-url>",description:"H3 reference audio (repeatable; requires a reference image or video).",type:"array"},{flag:"--duration <seconds>",description:"Output duration. H3 supports integer values from 4 to 15 (default: 5).",type:"number"},{flag:"--resolution <resolution>",description:"H3 output resolution: 768P or 2K (default: 2K)."},{flag:"--ratio <ratio>",description:"H3 aspect ratio: adaptive, 21:9, 16:9, 4:3, 1:1, 3:4, or 9:16."},{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',"# H3 text-to-video (Video Generation V2)",'mmx video generate --model MiniMax-H3 --prompt "Ocean waves at sunset"','mmx video generate --model MiniMax-H3 --prompt "Ocean waves at sunset" --resolution 768P',"# H3 image-to-video",'mmx video generate --model MiniMax-H3 --prompt "The subject walks forward" --image start.jpg',"# H3 reference-to-video",'mmx video generate --model MiniMax-H3 --prompt "Keep the same character" --reference-image character.png --reference-video motion.mp4',"# SEF: first + last frame interpolation (uses Hailuo-02 model)",'mmx video generate --prompt "Walk forward" --image start.jpg --last-frame end.jpg',"# Subject reference: character consistency (uses S2V-01 model)",'mmx video generate --prompt "A detective walking" --subject-image character.jpg'],async run(e,t){let n=t.prompt;n=await Dt({value:n,message:"Enter your video prompt:",cancelMessage:"Video generation cancelled.",flagName:"prompt",usageHint:"mmx video generate --prompt <text>",nonInteractive:e.nonInteractive});let i=t.model,r=e.defaultVideoModel||"MiniMax-Hailuo-2.3",{image:s,firstFrame:o}=t;if(s&&o)throw new y("--image and --first-frame are aliases; provide only one.",b.USAGE);let a=s??o,l=Boolean(t.referenceImage||t.referenceVideo||t.referenceAudio||t.resolution!==void 0||t.duration!==void 0||t.ratio),c;if(i)c=i;else if($t(r))c=kn;else if(t.lastFrame)c="MiniMax-Hailuo-02";else if(t.subjectImage)c="S2V-01";else c=r;if(t.lastFrame&&t.subjectImage)throw new y("--last-frame and --subject-image cannot be used together (SEF and S2V are different modes).",b.USAGE,"mmx video generate --prompt <text> --image <path> --last-frame <path>");if(i==="MiniMax-Hailuo-2.3-Fast"&&!a)throw new y("MiniMax-Hailuo-2.3-Fast only supports I2V (image-to-video). Use --image to provide an input image.",b.USAGE,"mmx video generate --prompt <text> --model MiniMax-Hailuo-2.3-Fast --image <path>");let p;if($t(c)){if(t.subjectImage)throw new y("--subject-image is only supported by the legacy S2V-01 model. Use --reference-image for MiniMax-H3.",b.USAGE,"mmx video generate --model MiniMax-H3 --prompt <text> --reference-image <path>");let U=[...a?[{url:xt(a,vt.image),role:"first_frame"}]:[],...t.lastFrame?[{url:xt(t.lastFrame,vt.image),role:"last_frame"}]:[],...(t.referenceImage??[]).map((q)=>({url:xt(q,vt.image),role:"reference_image"}))];try{p=Hu({prompt:n,images:U,referenceVideos:(t.referenceVideo??[]).map((q)=>eo(q,"video")),referenceAudios:(t.referenceAudio??[]).map((q)=>eo(q,"audio")),resolution:t.resolution,duration:t.duration,ratio:t.ratio,callbackUrl:t.callbackUrl})}catch(q){if(q instanceof ie)throw new y(q.message,b.USAGE,"mmx video generate --model MiniMax-H3 --prompt <text>");throw q}}else{if(l)throw new y("--reference-image, --reference-video, --reference-audio, --resolution, --duration, and --ratio require --model MiniMax-H3.",b.USAGE);if(p={model:c,prompt:n},a)p.first_frame_image=xt(a);if(t.lastFrame){if(!a)throw new y("--last-frame requires --image (SEF mode).",b.USAGE,"mmx video generate --prompt <text> --image <path> --last-frame <path>");p.last_frame_image=xt(t.lastFrame)}if(t.subjectImage)p.subject_reference=[{type:"character",image:[xt(t.subjectImage)]}];if(t.callbackUrl)p.callback_url=t.callbackUrl}if(_e(e,p))return;let u=F(e.output),f=Bu(p),g=f?oc(e.baseUrl):sc(e.baseUrl),d=(await D(e,{url:g,method:"POST",body:p})).task_id;if(!e.quiet)process.stderr.write(`[Model: ${c}]
227
227
  `);if(t.noWait||e.async){process.stdout.write(JSON.stringify({taskId:d})),process.stdout.write(`
228
- `);return}let m=t.pollInterval??5,v,w,x;if(f){let U=Ii(e.baseUrl,d),q=await oo(e,{url:U,intervalSec:m,timeoutSec:e.timeout,isComplete:(L)=>L.task.status==="succeeded",isFailed:(L)=>["failed","cancelled","expired"].includes(L.task.status),getStatus:(L)=>L.task.status,getFailureReason:(L)=>Vu(L.task)});x=q.task.status,v=q.task.content?.url}else{let U=Ti(e.baseUrl,d),q=await oo(e,{url:U,intervalSec:m,timeoutSec:e.timeout,isComplete:(C)=>C.status==="Success",isFailed:(C)=>C.status==="Failed",getStatus:(C)=>C.status});if(x=q.status,w=q.file_id,!w)throw new y("Task completed but no file_id returned.",b.GENERAL);v=(await D(e,{url:Mi(e.baseUrl,w)})).file?.download_url}if(!v)throw new y("No download URL available for this file.",b.GENERAL);if(t.download){let U=t.download,{size:q}=await Ue(v,U,{quiet:e.quiet});if(e.quiet)console.log(U);else console.log(O({task_id:d,status:x,file_id:w,saved:U,size:Gi(q)},u));return}let E=await import("os"),{join:A}=await import("path"),_=A(E.tmpdir(),"mmx-video"),{existsSync:S,mkdirSync:k}=await import("fs");if(!S(_))k(_,{recursive:!0});let R=A(_,`${d}.mp4`);await Ue(v,R,{quiet:e.quiet}),process.stdout.write(R),process.stdout.write(`
229
- `)}})});var Ju;var Yu=I(()=>{X();G();j();oe();ee();lo();Ju=N({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"},{flag:"--model <model>",description:"Use MiniMax-H3 for Video Generation V2 tasks; defaults to the legacy V1 query."}],examples:["mmx video task get --task-id 106916112212032","mmx video task get --task-id 106916112212032 --output json","mmx video task get --task-id 424010985738629 --model MiniMax-H3 --output json"],async run(e,t){let n=t.taskId;if(!n)throw new y("--task-id is required.",b.USAGE,"mmx video task get --task-id <id>");if(e.dryRun){console.log(`Would query task: ${n}`);return}let i=F(e.output),r=t.model;if($t(r)){let a=Ii(e.baseUrl,n),c=(await D(e,{url:a})).task;if(e.quiet){console.log(c.status);return}console.log(O({task_id:c.id,model:c.model,status:c.status,url:c.content?.url,resolution:c.resolution,duration:c.duration,ratio:c.ratio,error:c.error},i));return}let s=Ti(e.baseUrl,n),o=await D(e,{url:s});if(e.quiet){console.log(o.status);return}console.log(O({task_id:o.task_id,status:o.status,file_id:o.file_id,video_width:o.video_width,video_height:o.video_height},i))}})});var zu;var Xu=I(()=>{X();G();j();oe();_n();ee();zu=N({name:"video download",description:"Download a completed video by file ID",usage:"mmx video download --file-id <id> --out <path>",options:[{flag:"--file-id <id>",description:"File ID to download"},{flag:"--out <path>",description:"Output file path"}],examples:["mmx video download --file-id 176844028768320 --out video.mp4","mmx video download --file-id 176844028768320 --out video.mp4 --quiet"],async run(e,t){let n=t.fileId;if(!n)throw new y("--file-id is required.",b.USAGE,"mmx video download --file-id <id> --out <path>");let i=t.out;if(!i)throw new y("--out is required.",b.USAGE,"mmx video download --file-id <id> --out video.mp4");if(e.dryRun){console.log(`Would download file ${n} to ${i}`);return}let r=Mi(e.baseUrl,n),o=(await D(e,{url:r})).file?.download_url;if(!o)throw new y("No download URL available for this file.",b.GENERAL,"The file may still be processing. Check task status first.");let{size:a}=await Ue(o,i,{quiet:e.quiet}),l=F(e.output);if(e.quiet){console.log(i);return}console.log(O({saved:i,size:Gi(a)},l))}})});var co;var Qu=I(()=>{X();oe();ee();G();j();co=N({name:"search query",description:"Search the web via MiniMax. Note: the underlying /v1/coding_plan/search API returns at most 10 results per call and does not currently support pagination, so refining your --q is the only way to see different results.",usage:"mmx search query --q <query>",options:[{flag:"--q <query>",description:"Search query string"}],examples:['mmx search query --q "MiniMax AI"','mmx search query --q "latest news" --output json'],async run(e,t){let n=t.q??t.query??t._positional?.[0];if(!n)throw new y("--q is required.",b.USAGE,'mmx search query --q "your search query"');let i=F(e.output);if(e.dryRun){console.log(O({request:{q:n}},i));return}let r=ac(e.baseUrl),s=await D(e,{url:r,method:"POST",body:{q:n}}),o=s.organic||[];if(i!=="text"){console.log(O(s,i));return}if(e.quiet){for(let a of o)console.log(`${a.title} ${a.link}`);return}if(o.length===0){console.log("No results found.");return}for(let a of o){if(console.log(`${a.title}`),console.log(` ${a.link}`),a.snippet)console.log(` ${a.snippet}`);if(a.date)console.log(` ${a.date}`);console.log("")}}})});var Zu;var ef=I(()=>{X();oe();ee();G();j();Le();En();Zu=N({name:"vision describe",description:"Describe an image using MiniMax VLM",usage:"mmx vision describe (--image <path-or-url> | --file-id <id>) [--prompt <text>]",options:[{flag:"--image <path-or-url>",description:"Local image path or URL (base64 encoded automatically)"},{flag:"--file-id <id>",description:"Pre-uploaded file ID (skips base64 conversion)"},{flag:"--prompt <text>",description:'Question about the image (default: "Describe the image.")'}],examples:["mmx vision describe --image photo.jpg",'mmx vision describe --image https://example.com/photo.jpg --prompt "What breed is this dog?"','mmx vision describe --file-id file-123456789 --prompt "Extract the text"'],async run(e,t){let n=t.image??t.file??t.path??t._positional?.[0],i=t.fileId,r=t.prompt||"Describe the image.";if(!n&&!i)if(Q({nonInteractive:e.nonInteractive})){let c=await Ae({message:"Enter image path, URL, or File ID:"});if(!c)process.stderr.write(`Vision describe cancelled.
228
+ `);return}let m=t.pollInterval??5,v,w,x;if(f){let U=Ii(e.baseUrl,d),q=await oo(e,{url:U,intervalSec:m,timeoutSec:e.timeout,isComplete:(P)=>P.task.status==="succeeded",isFailed:(P)=>["failed","cancelled","expired"].includes(P.task.status),getStatus:(P)=>P.task.status,getFailureReason:(P)=>Vu(P.task)});x=q.task.status,v=q.task.content?.url}else{let U=Ti(e.baseUrl,d),q=await oo(e,{url:U,intervalSec:m,timeoutSec:e.timeout,isComplete:(C)=>C.status==="Success",isFailed:(C)=>C.status==="Failed",getStatus:(C)=>C.status});if(x=q.status,w=q.file_id,!w)throw new y("Task completed but no file_id returned.",b.GENERAL);v=(await D(e,{url:Mi(e.baseUrl,w)})).file?.download_url}if(!v)throw new y("No download URL available for this file.",b.GENERAL);if(t.download){let U=t.download,{size:q}=await Ue(v,U,{quiet:e.quiet});if(e.quiet)console.log(U);else console.log(O({task_id:d,status:x,file_id:w,saved:U,size:Gi(q)},u));return}let E=await import("os"),{join:A}=await import("path"),_=A(E.tmpdir(),"mmx-video"),{existsSync:S,mkdirSync:k}=await import("fs");if(!S(_))k(_,{recursive:!0});let R=A(_,`${d}.mp4`);await Ue(v,R,{quiet:e.quiet}),process.stdout.write(R),process.stdout.write(`
229
+ `)}})});var Ju;var Yu=I(()=>{X();G();j();oe();ee();lo();Ju=N({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"},{flag:"--model <model>",description:"Use MiniMax-H3 for Video Generation V2 tasks; defaults to the legacy V1 query."}],examples:["mmx video task get --task-id 106916112212032","mmx video task get --task-id 106916112212032 --output json","mmx video task get --task-id 424010985738629 --model MiniMax-H3 --output json"],async run(e,t){let n=t.taskId;if(!n)throw new y("--task-id is required.",b.USAGE,"mmx video task get --task-id <id>");if(e.dryRun){console.log(`Would query task: ${n}`);return}let i=F(e.output),r=t.model;if($t(r)){let a=Ii(e.baseUrl,n),c=(await D(e,{url:a})).task;if(e.quiet){console.log(c.status);return}console.log(O({task_id:c.id,model:c.model,status:c.status,url:c.content?.url,resolution:c.resolution,duration:c.duration,ratio:c.ratio,error:c.error},i));return}let s=Ti(e.baseUrl,n),o=await D(e,{url:s});if(e.quiet){console.log(o.status);return}console.log(O({task_id:o.task_id,status:o.status,file_id:o.file_id,video_width:o.video_width,video_height:o.video_height},i))}})});var zu;var Xu=I(()=>{X();G();j();oe();_n();ee();zu=N({name:"video download",description:"Download a completed video by file ID",usage:"mmx video download --file-id <id> --out <path>",options:[{flag:"--file-id <id>",description:"File ID to download"},{flag:"--out <path>",description:"Output file path"}],examples:["mmx video download --file-id 176844028768320 --out video.mp4","mmx video download --file-id 176844028768320 --out video.mp4 --quiet"],async run(e,t){let n=t.fileId;if(!n)throw new y("--file-id is required.",b.USAGE,"mmx video download --file-id <id> --out <path>");let i=t.out;if(!i)throw new y("--out is required.",b.USAGE,"mmx video download --file-id <id> --out video.mp4");if(e.dryRun){console.log(`Would download file ${n} to ${i}`);return}let r=Mi(e.baseUrl,n),o=(await D(e,{url:r})).file?.download_url;if(!o)throw new y("No download URL available for this file.",b.GENERAL,"The file may still be processing. Check task status first.");let{size:a}=await Ue(o,i,{quiet:e.quiet}),l=F(e.output);if(e.quiet){console.log(i);return}console.log(O({saved:i,size:Gi(a)},l))}})});var co;var Qu=I(()=>{X();oe();ee();G();j();co=N({name:"search query",description:"Search the web via MiniMax. Note: the underlying /v1/coding_plan/search API returns at most 10 results per call and does not currently support pagination, so refining your --q is the only way to see different results.",usage:"mmx search query --q <query>",options:[{flag:"--q <query>",description:"Search query string"}],examples:['mmx search query --q "MiniMax AI"','mmx search query --q "latest news" --output json'],async run(e,t){let n=t.q??t.query??t._positional?.[0];if(!n)throw new y("--q is required.",b.USAGE,'mmx search query --q "your search query"');let i=F(e.output);if(e.dryRun){console.log(O({request:{q:n}},i));return}let r=ac(e.baseUrl),s=await D(e,{url:r,method:"POST",body:{q:n}}),o=s.organic||[];if(i!=="text"){console.log(O(s,i));return}if(e.quiet){for(let a of o)console.log(`${a.title} ${a.link}`);return}if(o.length===0){console.log("No results found.");return}for(let a of o){if(console.log(`${a.title}`),console.log(` ${a.link}`),a.snippet)console.log(` ${a.snippet}`);if(a.date)console.log(` ${a.date}`);console.log("")}}})});var Zu;var ef=I(()=>{X();oe();ee();G();j();Pe();En();Zu=N({name:"vision describe",description:"Describe an image using MiniMax VLM",usage:"mmx vision describe (--image <path-or-url> | --file-id <id>) [--prompt <text>]",options:[{flag:"--image <path-or-url>",description:"Local image path or URL (base64 encoded automatically)"},{flag:"--file-id <id>",description:"Pre-uploaded file ID (skips base64 conversion)"},{flag:"--prompt <text>",description:'Question about the image (default: "Describe the image.")'}],examples:["mmx vision describe --image photo.jpg",'mmx vision describe --image https://example.com/photo.jpg --prompt "What breed is this dog?"','mmx vision describe --file-id file-123456789 --prompt "Extract the text"'],async run(e,t){let n=t.image??t.file??t.path??t._positional?.[0],i=t.fileId,r=t.prompt||"Describe the image.";if(!n&&!i)if(Q({nonInteractive:e.nonInteractive})){let c=await Ae({message:"Enter image path, URL, or File ID:"});if(!c)process.stderr.write(`Vision describe cancelled.
230
230
  `),process.exit(1);if(!c.includes(".")&&!c.startsWith("http"))i=c;else n=c}else throw new y("Missing required argument. Must provide either --image or --file-id.",b.USAGE,"mmx vision describe --image <path> OR --file-id <id>");else if(n&&i)throw new y("Conflicting arguments: cannot provide both --image and --file-id.",b.USAGE);if(_e(e,{prompt:r,image:n,fileId:i}))return;let s=F(e.output),o=lc(e.baseUrl),a={prompt:r};if(i)a.file_id=i;else if(n){let c=await $u(n);a.image_url=c}let l=await D(e,{url:o,method:"POST",body:a});if(s!=="text"){process.stdout.write(O(l,s)+`
231
231
  `);return}process.stdout.write(l.content+`
232
- `)}})});var tf;var nf=I(()=>{X();oe();Ei();ee();Ni();tf=N({name:"quota show",description:"Display Token Plan usage and remaining quotas",usage:"mmx quota show",examples:["mmx quota show","mmx quota show --output json"],async run(e,t){if(e.dryRun){console.log("Would fetch quota information.");return}let n=F(e.output),i=await jt(e),r=qs(e.baseUrl,i);if(r.kind==="account-balance"){let a=await D(e,{url:r.url});if(n!=="text"){console.log(O(a,n));return}Je(a,e,i.token);return}let s=await D(e,{url:r.url}),o=s.model_remains||[];if(n!=="text"){console.log(O(s,n));return}if(e.quiet){for(let a of o){let l=Oi(a.current_interval_usage_count,a.current_interval_total_count,a.current_interval_remaining_percent);if(l){console.log(`${a.model_name} ${l.used} ${l.total} ${l.remaining}`);continue}let c=a.current_interval_remaining_percent===void 0||a.current_interval_remaining_percent===null?"-":`${a.current_interval_remaining_percent}%`;console.log(`${a.model_name} - ${a.current_interval_total_count} ${c}`)}return}Je(s,e)}})});var rf;var sf=I(()=>{X();Ce();Xe();ee();rf=N({name:"config show",description:"Display current configuration",usage:"mmx config show",examples:["mmx config show","mmx config show --output json"],async run(e,t){let n=Z(),i=F(e.output),r={region:e.region,base_url:e.baseUrl,output:e.output,timeout:e.timeout,config_file:fe()};if(n.api_key)r.api_key=me(n.api_key);if(n.default_text_model)r.default_text_model=n.default_text_model;if(n.default_speech_model)r.default_speech_model=n.default_speech_model;if(n.default_video_model)r.default_video_model=n.default_video_model;if(n.proxy)r.proxy=n.proxy;console.log(O(r,i))}})});function af(e,t){return e==="api_key"?me(String(t)):t}var of,hb,lf;var cf=I(()=>{X();G();j();ee();Ce();of=["region","base_url","output","timeout","api_key","proxy","default_text_model","default_speech_model","default_video_model"],hb={"default-text-model":"default_text_model","default-speech-model":"default_speech_model","default-video-model":"default_video_model"};lf=N({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)"},{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(e,t){let n=t._positional,i=t.key??n?.[0],r=t.value??n?.[1];if(!i||r===void 0)throw new y("--key and --value are required.",b.USAGE,"mmx config set --key <key> --value <value>");let s=hb[i]||i;if(!of.includes(s))throw new y(`Invalid config key "${i}". Valid keys: ${of.join(", ")}`,b.USAGE);let o=s==="api_key"?r.trim():r;if(s==="api_key"&&o.length===0)throw new y("Invalid api_key. The value must not be empty.",b.USAGE);if(s==="region"&&!["global","cn"].includes(r))throw new y(`Invalid region "${r}". Valid values: global, cn`,b.USAGE);if(s==="output"&&!["text","json"].includes(r))throw new y(`Invalid output format "${r}". Valid values: text, json`,b.USAGE);if(s==="base_url"&&!r.startsWith("http"))throw new y(`Invalid base_url "${r}". Must start with http.`,b.USAGE);if(s==="proxy"&&!r.startsWith("http"))throw new y(`Invalid proxy "${r}". Must be a URL starting with http (e.g. http://127.0.0.1:7890).`,b.USAGE);if(s==="timeout"){let c=Number(r);if(isNaN(c)||c<=0)throw new y(`Invalid timeout "${r}". Must be a positive number.`,b.USAGE)}let a=F(e.output);if(e.dryRun){console.log(O({would_set:{[s]:af(s,o)}},a));return}let l=Z();if(l[s]=s==="timeout"?Number(o):o,s==="api_key")delete l.oauth,delete l.region;if(await de(l),!e.quiet)console.log(O({[s]:af(s,l[s])},a))}})});function gb(e){let t=e.match(/^--([a-zA-Z0-9-]+)/),n=t?t[1]:"",i=n.replace(/-([a-zA-Z0-9])/g,(o,a)=>a.toUpperCase()),r="string",s=!1;if(!e.includes("<")&&!e.includes("["))r="boolean";else if(e.includes("<n>")||e.includes("<hz>")||e.includes("<bps>")||e.includes("<count>"))r="number";if(e.toLowerCase().includes("repeatable"))s=!0;return{name:i,kebabName:n,inferredType:r,isArray:s}}function uo(e){let n={name:`mmx_${e.name.replace(/ /g,"_")}`,description:e.description,input_schema:{type:"object",properties:{},required:[]}};if(e.options)for(let i of e.options){if(i.hidden)continue;let{name:r,inferredType:s,isArray:o}=gb(i.flag);if(!r)continue;let a=i.type,l=o?"array":a??s,c={description:i.description};if(l==="array")c.type="array",c.items={type:"string"};else c.type=l;let p=n.input_schema;if(p.properties[r]=c,i.required)p.required.push(r)}return n}var yb,uf;var ff=I(()=>{X();Pi();G();j();yb=["auth ","config ","update"],uf=N({name:"config export-schema",description:"Export all (or one) CLI command(s) as Anthropic/OpenAI-compatible JSON tool schemas",usage:'mmx config export-schema [--command "<name>"]',options:[{flag:"--command <name>",description:'Export schema for a specific command only (e.g. "image generate")'}],examples:["mmx config export-schema",'mmx config export-schema --command "video generate"'],async run(e,t){let n=t.command;if(n){try{let{command:s}=Te.resolve(n.split(" ")),o=uo(s);process.stdout.write(JSON.stringify(o,null,2)+`
232
+ `)}})});var tf;var nf=I(()=>{X();oe();Ei();ee();Ni();tf=N({name:"quota show",description:"Display Token Plan usage and remaining quotas",usage:"mmx quota show",examples:["mmx quota show","mmx quota show --output json"],async run(e,t){if(e.dryRun){console.log("Would fetch quota information.");return}let n=F(e.output),i=await jt(e),r=qs(e.baseUrl,i);if(r.kind==="account-balance"){let a=await D(e,{url:r.url});if(n!=="text"){console.log(O(a,n));return}Je(a,e,i.token);return}let s=await D(e,{url:r.url}),o=s.model_remains||[];if(n!=="text"){console.log(O(s,n));return}if(e.quiet){for(let a of o){let l=Oi(a.current_interval_usage_count,a.current_interval_total_count,a.current_interval_remaining_percent);if(l){console.log(`${a.model_name} ${l.used} ${l.total} ${l.remaining}`);continue}let c=a.current_interval_remaining_percent===void 0||a.current_interval_remaining_percent===null?"-":`${a.current_interval_remaining_percent}%`;console.log(`${a.model_name} - ${a.current_interval_total_count} ${c}`)}return}Je(s,e)}})});var rf;var sf=I(()=>{X();Ce();Xe();ee();rf=N({name:"config show",description:"Display current configuration",usage:"mmx config show",examples:["mmx config show","mmx config show --output json"],async run(e,t){let n=Z(),i=F(e.output),r={region:e.region,base_url:e.baseUrl,output:e.output,timeout:e.timeout,config_file:fe()};if(n.api_key)r.api_key=me(n.api_key);if(n.default_text_model)r.default_text_model=n.default_text_model;if(n.default_speech_model)r.default_speech_model=n.default_speech_model;if(n.default_video_model)r.default_video_model=n.default_video_model;if(n.proxy)r.proxy=n.proxy;console.log(O(r,i))}})});function af(e,t){return e==="api_key"?me(String(t)):t}var of,hb,lf;var cf=I(()=>{X();G();j();ee();Ce();of=["region","base_url","output","timeout","api_key","proxy","default_text_model","default_speech_model","default_video_model"],hb={"default-text-model":"default_text_model","default-speech-model":"default_speech_model","default-video-model":"default_video_model"};lf=N({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)"},{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(e,t){let n=t._positional,i=t.key??n?.[0],r=t.value??n?.[1];if(!i||r===void 0)throw new y("--key and --value are required.",b.USAGE,"mmx config set --key <key> --value <value>");let s=hb[i]||i;if(!of.includes(s))throw new y(`Invalid config key "${i}". Valid keys: ${of.join(", ")}`,b.USAGE);let o=s==="api_key"?r.trim():r;if(s==="api_key"&&o.length===0)throw new y("Invalid api_key. The value must not be empty.",b.USAGE);if(s==="region"&&!["global","cn"].includes(r))throw new y(`Invalid region "${r}". Valid values: global, cn`,b.USAGE);if(s==="output"&&!["text","json"].includes(r))throw new y(`Invalid output format "${r}". Valid values: text, json`,b.USAGE);if(s==="base_url"&&!r.startsWith("http"))throw new y(`Invalid base_url "${r}". Must start with http.`,b.USAGE);if(s==="proxy"&&!r.startsWith("http"))throw new y(`Invalid proxy "${r}". Must be a URL starting with http (e.g. http://127.0.0.1:7890).`,b.USAGE);if(s==="timeout"){let c=Number(r);if(isNaN(c)||c<=0)throw new y(`Invalid timeout "${r}". Must be a positive number.`,b.USAGE)}let a=F(e.output);if(e.dryRun){console.log(O({would_set:{[s]:af(s,o)}},a));return}let l=Z();if(l[s]=s==="timeout"?Number(o):o,s==="api_key")delete l.oauth,delete l.region;if(await de(l),!e.quiet)console.log(O({[s]:af(s,l[s])},a))}})});function gb(e){let t=e.match(/^--([a-zA-Z0-9-]+)/),n=t?t[1]:"",i=n.replace(/-([a-zA-Z0-9])/g,(o,a)=>a.toUpperCase()),r="string",s=!1;if(!e.includes("<")&&!e.includes("["))r="boolean";else if(e.includes("<n>")||e.includes("<hz>")||e.includes("<bps>")||e.includes("<count>"))r="number";if(e.toLowerCase().includes("repeatable"))s=!0;return{name:i,kebabName:n,inferredType:r,isArray:s}}function uo(e){let n={name:`mmx_${e.name.replace(/ /g,"_")}`,description:e.description,input_schema:{type:"object",properties:{},required:[]}};if(e.options)for(let i of e.options){if(i.hidden)continue;let{name:r,inferredType:s,isArray:o}=gb(i.flag);if(!r)continue;let a=i.type,l=o?"array":a??s,c={description:i.description};if(l==="array")c.type="array",c.items={type:"string"};else c.type=l;let p=n.input_schema;if(p.properties[r]=c,i.required)p.required.push(r)}return n}var yb,uf;var ff=I(()=>{X();Li();G();j();yb=["auth ","config ","update"],uf=N({name:"config export-schema",description:"Export all (or one) CLI command(s) as Anthropic/OpenAI-compatible JSON tool schemas",usage:'mmx config export-schema [--command "<name>"]',options:[{flag:"--command <name>",description:'Export schema for a specific command only (e.g. "image generate")'}],examples:["mmx config export-schema",'mmx config export-schema --command "video generate"'],async run(e,t){let n=t.command;if(n){try{let{command:s}=Te.resolve(n.split(" ")),o=uo(s);process.stdout.write(JSON.stringify(o,null,2)+`
233
233
  `)}catch{throw new y(`Command "${n}" not found.`,b.USAGE)}return}let r=Te.getAllCommands().filter((s)=>!yb.some((o)=>s.name.startsWith(o))).map((s)=>uo(s));process.stdout.write(JSON.stringify(r,null,2)+`
234
- `)}})});var df;var pf=I(()=>{X();G();j();oe();Js();ee();Le();df=N({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(e,t){let n=t.file;if(!n)if(Q({nonInteractive:e.nonInteractive})){if(n=await Ae({message:"Enter file path:"}),!n)process.stderr.write(`Upload cancelled.
234
+ `)}})});var df;var pf=I(()=>{X();G();j();oe();Js();ee();Pe();df=N({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(e,t){let n=t.file;if(!n)if(Q({nonInteractive:e.nonInteractive})){if(n=await Ae({message:"Enter file path:"}),!n)process.stderr.write(`Upload cancelled.
235
235
  `),process.exit(1)}else yt("file","mmx file upload --file <path>");let i=(l)=>new y(`File not found: ${l}`,b.USAGE),r=$n(n,i),s=t.purpose||"retrieval",o=F(e.output);if(e.dryRun){process.stdout.write(O({request:{file:r,purpose:s}},o)+`
236
236
  `);return}let a=await su({filePath:r,purpose:s,baseUrl:e.baseUrl,requestJson:(l)=>D(e,l),createFileNotFoundError:i});if(e.quiet){process.stdout.write(a.file.file_id+`
237
237
  `);return}process.stdout.write(O(a.file,o)+`
@@ -239,7 +239,7 @@ ${v.text}`}).join(`
239
239
  `);return}let i=uc(e.baseUrl),r=await D(e,{url:i,method:"GET"});if(n!=="text"){process.stdout.write(O(r,n)+`
240
240
  `);return}if(!r.files||r.files.length===0){process.stdout.write(`No files found.
241
241
  `);return}let s=r.files.map((a)=>({ID:a.file_id,FILENAME:a.filename,PURPOSE:a.purpose,SIZE_KB:(a.bytes/1024).toFixed(1),CREATED:new Date(a.created_at*1000).toISOString().slice(0,16).replace("T"," ")}));await Promise.resolve();process.stdout.write(Qr(s)+`
242
- `)}})});var gf;var yf=I(()=>{X();oe();ee();Le();gf=N({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(e,t){let n=t.fileId;if(!n)if(Q({nonInteractive:e.nonInteractive})){if(n=await Ae({message:"Enter file ID to delete:"}),!n)process.stderr.write(`Delete cancelled.
242
+ `)}})});var gf;var yf=I(()=>{X();oe();ee();Pe();gf=N({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(e,t){let n=t.fileId;if(!n)if(Q({nonInteractive:e.nonInteractive})){if(n=await Ae({message:"Enter file ID to delete:"}),!n)process.stderr.write(`Delete cancelled.
243
243
  `),process.exit(1)}else yt("file-id","mmx file delete --file-id <id>");let i=F(e.output);if(e.dryRun){process.stdout.write(O({request:{delete_file:n}},i)+`
244
244
  `);return}let r=fc(e.baseUrl),s=await D(e,{url:r,method:"POST",body:{file_id:Number(n)}});if(e.quiet){process.stdout.write(`deleted
245
245
  `);return}process.stdout.write(O({file_id:s.file_id,deleted:!0},i)+`
@@ -510,8 +510,8 @@ ${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function po(e,t=0){let n
510
510
  `)return`
511
511
  `}return e&&e.eol||`
512
512
  `}function On(e,t){return`\r
513
- `.indexOf(e.charAt(t))!==-1}var vo=I(()=>{Xi();Of()});function Cf(e,t=[],n=Cn.DEFAULT){let i=null,r=[],s=[];function o(l){if(Array.isArray(r))r.push(l);else if(i!==null)r[i]=l}return $o(e,{onObjectBegin:()=>{let l={};o(l),s.push(r),r=l,i=null},onObjectProperty:(l)=>{i=l},onObjectEnd:()=>{r=s.pop()},onArrayBegin:()=>{let l=[];o(l),s.push(r),r=l,i=null},onArrayEnd:()=>{r=s.pop()},onLiteralValue:o,onError:(l,c,p)=>{t.push({error:l,offset:c,length:p})}},n),r[0]}function So(e,t=[],n=Cn.DEFAULT){let i={type:"array",offset:-1,length:-1,children:[],parent:void 0};function r(l){if(i.type==="property")i.length=l-i.offset,i=i.parent}function s(l){return i.children.push(l),l}$o(e,{onObjectBegin:(l)=>{i=s({type:"object",offset:l,length:-1,parent:i,children:[]})},onObjectProperty:(l,c,p)=>{i=s({type:"property",offset:c,length:-1,parent:i,children:[]}),i.children.push({type:"string",value:l,offset:c,length:p,parent:i})},onObjectEnd:(l,c)=>{r(l+c),i.length=l+c-i.offset,i=i.parent,r(l+c)},onArrayBegin:(l,c)=>{i=s({type:"array",offset:l,length:-1,parent:i,children:[]})},onArrayEnd:(l,c)=>{i.length=l+c-i.offset,i=i.parent,r(l+c)},onLiteralValue:(l,c,p)=>{s({type:Ob(l),offset:c,length:p,parent:i,value:l}),r(c+p)},onSeparator:(l,c,p)=>{if(i.type==="property"){if(l===":")i.colonOffset=c;else if(l===",")r(c)}},onError:(l,c,p)=>{t.push({error:l,offset:c,length:p})}},n);let a=i.children[0];if(a)delete a.parent;return a}function Qi(e,t){if(!e)return;let n=e;for(let i of t)if(typeof i==="string"){if(n.type!=="object"||!Array.isArray(n.children))return;let r=!1;for(let s of n.children)if(Array.isArray(s.children)&&s.children[0].value===i&&s.children.length===2){n=s.children[1],r=!0;break}if(!r)return}else{let r=i;if(n.type!=="array"||r<0||!Array.isArray(n.children)||r>=n.children.length)return;n=n.children[r]}return n}function $o(e,t,n=Cn.DEFAULT){let i=Mn(e,!1),r=[],s=0;function o(P){return P?()=>s===0&&P(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter()):()=>!0}function a(P){return P?(J)=>s===0&&P(J,i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter()):()=>!0}function l(P){return P?(J)=>s===0&&P(J,i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter(),()=>r.slice()):()=>!0}function c(P){return P?()=>{if(s>0)s++;else if(P(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter(),()=>r.slice())===!1)s=1}:()=>!0}function p(P){return P?()=>{if(s>0)s--;if(s===0)P(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter())}:()=>!0}let u=c(t.onObjectBegin),f=l(t.onObjectProperty),g=p(t.onObjectEnd),h=c(t.onArrayBegin),d=p(t.onArrayEnd),m=l(t.onLiteralValue),v=a(t.onSeparator),w=o(t.onComment),x=a(t.onError),E=n&&n.disallowComments,A=n&&n.allowTrailingComma;function _(){while(!0){let P=i.scan();switch(i.getTokenError()){case 4:S(14);break;case 5:S(15);break;case 3:S(13);break;case 1:if(!E)S(11);break;case 2:S(12);break;case 6:S(16);break}switch(P){case 12:case 13:if(E)S(10);else w();break;case 16:S(1);break;case 15:case 14:break;default:return P}}}function S(P,J=[],ye=[]){if(x(P),J.length+ye.length>0){let We=i.getToken();while(We!==17){if(J.indexOf(We)!==-1){_();break}else if(ye.indexOf(We)!==-1)break;We=_()}}}function k(P){let J=i.getTokenValue();if(P)m(J);else f(J),r.push(J);return _(),!0}function R(){switch(i.getToken()){case 11:let P=i.getTokenValue(),J=Number(P);if(isNaN(J))S(2),J=0;m(J);break;case 7:m(null);break;case 8:m(!0);break;case 9:m(!1);break;default:return!1}return _(),!0}function U(){if(i.getToken()!==10)return S(3,[],[2,5]),!1;if(k(!1),i.getToken()===6){if(v(":"),_(),!C())S(4,[],[2,5])}else S(5,[],[2,5]);return r.pop(),!0}function q(){u(),_();let P=!1;while(i.getToken()!==2&&i.getToken()!==17){if(i.getToken()===5){if(!P)S(4,[],[]);if(v(","),_(),i.getToken()===2&&A)break}else if(P)S(6,[],[]);if(!U())S(4,[],[2,5]);P=!0}if(g(),i.getToken()!==2)S(7,[2],[]);else _();return!0}function L(){h(),_();let P=!0,J=!1;while(i.getToken()!==4&&i.getToken()!==17){if(i.getToken()===5){if(!J)S(4,[],[]);if(v(","),_(),i.getToken()===4&&A)break}else if(J)S(6,[],[]);if(P)r.push(0),P=!1;else r[r.length-1]++;if(!C())S(4,[],[4,5]);J=!0}if(d(),!P)r.pop();if(i.getToken()!==4)S(8,[4],[]);else _();return!0}function C(){switch(i.getToken()){case 3:return L();case 1:return q();case 10:return k(!0);default:return R()}}if(_(),i.getToken()===17){if(n.allowEmptyContent)return!0;return S(4,[],[]),!1}if(!C())return S(4,[],[]),!1;if(i.getToken()!==17)S(9,[],[]);return!0}function Ob(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(!e)return"null";else if(Array.isArray(e))return"array";return"object"}default:return"null"}}var Cn;var _o=I(()=>{Xi();(function(e){e.DEFAULT={allowTrailingComma:!1}})(Cn||(Cn={}))});function Nf(e,t,n,i){let r=t.slice(),o=So(e,[]),a=void 0,l=void 0;while(r.length>0)if(l=r.pop(),a=Qi(o,r),a===void 0&&n!==void 0)if(typeof l==="string")n={[l]:n};else n=[n];else break;if(!a){if(n===void 0)throw Error("Can not delete in empty document");return At(e,{offset:o?o.offset:0,length:o?o.length:0,content:JSON.stringify(n)},i)}else if(a.type==="object"&&typeof l==="string"&&Array.isArray(a.children)){let c=Qi(a,[l]);if(c!==void 0)if(n===void 0){if(!c.parent)throw Error("Malformed AST");let p=a.children.indexOf(c.parent),u,f=c.parent.offset+c.parent.length;if(p>0){let g=a.children[p-1];u=g.offset+g.length}else if(u=a.offset+1,a.children.length>1)f=a.children[1].offset;return At(e,{offset:u,length:f-u,content:""},i)}else return At(e,{offset:c.offset,length:c.length,content:JSON.stringify(n)},i);else{if(n===void 0)return[];let p=`${JSON.stringify(l)}: ${JSON.stringify(n)}`,u=i.getInsertionIndex?i.getInsertionIndex(a.children.map((g)=>g.children[0].value)):a.children.length,f;if(u>0){let g=a.children[u-1];f={offset:g.offset+g.length,length:0,content:","+p}}else if(a.children.length===0)f={offset:a.offset+1,length:0,content:p};else f={offset:a.offset+1,length:0,content:p+","};return At(e,f,i)}}else if(a.type==="array"&&typeof l==="number"&&Array.isArray(a.children)){let c=l;if(c===-1){let p=`${JSON.stringify(n)}`,u;if(a.children.length===0)u={offset:a.offset+1,length:0,content:p};else{let f=a.children[a.children.length-1];u={offset:f.offset+f.length,length:0,content:","+p}}return At(e,u,i)}else if(n===void 0&&a.children.length>=0){let p=l,u=a.children[p],f;if(a.children.length===1)f={offset:a.offset+1,length:a.length-2,content:""};else if(a.children.length-1===p){let g=a.children[p-1],h=g.offset+g.length,d=a.offset+a.length;f={offset:h,length:d-2-h,content:""}}else f={offset:u.offset,length:a.children[p+1].offset-u.offset,content:""};return At(e,f,i)}else if(n!==void 0){let p,u=`${JSON.stringify(n)}`;if(!i.isArrayInsertion&&a.children.length>l){let f=a.children[l];p={offset:f.offset,length:f.length,content:u}}else if(a.children.length===0||l===0)p={offset:a.offset+1,length:0,content:a.children.length===0?u:u+","};else{let f=l>a.children.length?a.children.length:l,g=a.children[f-1];p={offset:g.offset+g.length,length:0,content:","+u}}return At(e,p,i)}else throw Error(`Can not ${n===void 0?"remove":i.isArrayInsertion?"insert":"modify"} Array index ${c} as length is not sufficient`)}else throw Error(`Can not add ${typeof l!=="number"?"index":"property"} to parent of type ${a.type}`)}function At(e,t,n){if(!n.formattingOptions)return[t];let i=Zi(e,t),r=t.offset,s=t.offset+t.content.length;if(t.length===0||t.content.length===0){while(r>0&&!On(i,r-1))r--;while(s<i.length&&!On(i,s))s++}let o=xo(i,{offset:r,length:s-r},{...n.formattingOptions,keepLines:!1});for(let l=o.length-1;l>=0;l--){let c=o[l];i=Zi(i,c),r=Math.min(r,c.offset),s=Math.max(s,c.offset+c.length),s+=c.content.length-c.length}let a=e.length-(i.length-s)-r;return[{offset:r,length:a,content:i.substring(r,s)}]}function Zi(e,t){return e.substring(0,t.offset)+t.content+e.substring(t.offset+t.length)}var Rf=I(()=>{vo();_o()});function Df(e,t,n,i){return Nf(e,t,n,i)}function Uf(e,t){let n=t.slice(0).sort((r,s)=>{let o=r.offset-s.offset;if(o===0)return r.length-s.length;return o}),i=e.length;for(let r=n.length-1;r>=0;r--){let s=n[r];if(s.offset+s.length<=i)e=Zi(e,s);else throw Error("Overlapping edit");i=s.offset}return e}var Pf,Lf,qf,Ff;var jf=I(()=>{vo();Rf();Xi();_o();(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(Pf||(Pf={}));(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(Lf||(Lf={}));qf=Cf;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(Ff||(Ff={}))});var V=M(function(jb){var Eo=Symbol.for("yaml.alias"),Gf=Symbol.for("yaml.document"),er=Symbol.for("yaml.map"),Bf=Symbol.for("yaml.pair"),Ao=Symbol.for("yaml.scalar"),tr=Symbol.for("yaml.seq"),Ye=Symbol.for("yaml.node.type"),Rb=(e)=>!!e&&typeof e==="object"&&e[Ye]===Eo,Pb=(e)=>!!e&&typeof e==="object"&&e[Ye]===Gf,Lb=(e)=>!!e&&typeof e==="object"&&e[Ye]===er,Fb=(e)=>!!e&&typeof e==="object"&&e[Ye]===Bf,Vf=(e)=>!!e&&typeof e==="object"&&e[Ye]===Ao,qb=(e)=>!!e&&typeof e==="object"&&e[Ye]===tr;function Hf(e){if(e&&typeof e==="object")switch(e[Ye]){case er:case tr:return!0}return!1}function Db(e){if(e&&typeof e==="object")switch(e[Ye]){case Eo:case er:case Ao:case tr:return!0}return!1}var Ub=(e)=>(Vf(e)||Hf(e))&&!!e.anchor;jb.ALIAS=Eo;jb.DOC=Gf;jb.MAP=er;jb.NODE_TYPE=Ye;jb.PAIR=Bf;jb.SCALAR=Ao;jb.SEQ=tr;jb.hasAnchor=Ub;jb.isAlias=Rb;jb.isCollection=Hf;jb.isDocument=Pb;jb.isMap=Lb;jb.isNode=Db;jb.isPair=Fb;jb.isScalar=Vf;jb.isSeq=qb});var Nn=M(function(rw){var ae=V(),pe=Symbol("break visit"),Kf=Symbol("skip children"),Ge=Symbol("remove node");function nr(e,t){let n=Wf(t);if(ae.isDocument(e)){if(Ht(null,e.contents,n,Object.freeze([e]))===Ge)e.contents=null}else Ht(null,e,n,Object.freeze([]))}nr.BREAK=pe;nr.SKIP=Kf;nr.REMOVE=Ge;function Ht(e,t,n,i){let r=Jf(e,t,n,i);if(ae.isNode(r)||ae.isPair(r))return Yf(e,i,r),Ht(e,r,n,i);if(typeof r!=="symbol"){if(ae.isCollection(t)){i=Object.freeze(i.concat(t));for(let s=0;s<t.items.length;++s){let o=Ht(s,t.items[s],n,i);if(typeof o==="number")s=o-1;else if(o===pe)return pe;else if(o===Ge)t.items.splice(s,1),s-=1}}else if(ae.isPair(t)){i=Object.freeze(i.concat(t));let s=Ht("key",t.key,n,i);if(s===pe)return pe;else if(s===Ge)t.key=null;let o=Ht("value",t.value,n,i);if(o===pe)return pe;else if(o===Ge)t.value=null}}return r}async function ir(e,t){let n=Wf(t);if(ae.isDocument(e)){if(await Kt(null,e.contents,n,Object.freeze([e]))===Ge)e.contents=null}else await Kt(null,e,n,Object.freeze([]))}ir.BREAK=pe;ir.SKIP=Kf;ir.REMOVE=Ge;async function Kt(e,t,n,i){let r=await Jf(e,t,n,i);if(ae.isNode(r)||ae.isPair(r))return Yf(e,i,r),Kt(e,r,n,i);if(typeof r!=="symbol"){if(ae.isCollection(t)){i=Object.freeze(i.concat(t));for(let s=0;s<t.items.length;++s){let o=await Kt(s,t.items[s],n,i);if(typeof o==="number")s=o-1;else if(o===pe)return pe;else if(o===Ge)t.items.splice(s,1),s-=1}}else if(ae.isPair(t)){i=Object.freeze(i.concat(t));let s=await Kt("key",t.key,n,i);if(s===pe)return pe;else if(s===Ge)t.key=null;let o=await Kt("value",t.value,n,i);if(o===pe)return pe;else if(o===Ge)t.value=null}}return r}function Wf(e){if(typeof e==="object"&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}function Jf(e,t,n,i){if(typeof n==="function")return n(e,t,i);if(ae.isMap(t))return n.Map?.(e,t,i);if(ae.isSeq(t))return n.Seq?.(e,t,i);if(ae.isPair(t))return n.Pair?.(e,t,i);if(ae.isScalar(t))return n.Scalar?.(e,t,i);if(ae.isAlias(t))return n.Alias?.(e,t,i);return}function Yf(e,t,n){let i=t[t.length-1];if(ae.isCollection(i))i.items[e]=n;else if(ae.isPair(i))if(e==="key")i.key=n;else i.value=n;else if(ae.isDocument(i))i.contents=n;else{let r=ae.isAlias(i)?"alias":"scalar";throw Error(`Cannot replace node with ${r} parent`)}}rw.visit=nr;rw.visitAsync=ir});var ko=M(function(uw){var zf=V(),aw=Nn(),lw={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},cw=(e)=>e.replace(/[!,[\]{}]/g,(t)=>lw[t]);class ve{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},ve.defaultYaml,e),this.tags=Object.assign({},ve.defaultTags,t)}clone(){let e=new ve(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new ve(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:ve.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},ve.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:ve.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},ve.defaultTags),this.atNextDocument=!1;let n=e.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(n.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),n.length<2)return!1}let[r,s]=n;return this.tags[r]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[r]=n;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;else{let s=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,s),!1}}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let s=e.slice(2,-1);if(s==="!"||s==="!!")return t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null;if(e[e.length-1]!==">")t("Verbatim tags must end with a >");return s}let[,n,i]=e.match(/^(.*!)([^!]*)$/s);if(!i)t(`The ${e} tag has no suffix`);let r=this.tags[n];if(r)try{return r+decodeURIComponent(i)}catch(s){return t(String(s)),null}if(n==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+cw(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),i;if(e&&n.length>0&&zf.isNode(e.contents)){let r={};aw.visit(e.contents,(s,o)=>{if(zf.isNode(o)&&o.tag)r[o.tag]=!0}),i=Object.keys(r)}else i=[];for(let[r,s]of n){if(r==="!!"&&s==="tag:yaml.org,2002:")continue;if(!e||i.some((o)=>o.startsWith(s)))t.push(`%TAG ${r} ${s}`)}return t.join(`
514
- `)}}ve.defaultYaml={explicit:!1,version:"1.2"};ve.defaultTags={"!!":"tag:yaml.org,2002:"};uw.Directives=ve});var rr=M(function(hw){var Xf=V(),dw=Nn();function pw(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(n)}return!0}function Qf(e){let t=new Set;return dw.visit(e,{Value(n,i){if(i.anchor)t.add(i.anchor)}}),t}function Zf(e,t){for(let n=1;;++n){let i=`${e}${n}`;if(!t.has(i))return i}}function mw(e,t){let n=[],i=new Map,r=null;return{onAnchor:(s)=>{n.push(s),r??(r=Qf(e));let o=Zf(t,r);return r.add(o),o},setAnchors:()=>{for(let s of n){let o=i.get(s);if(typeof o==="object"&&o.anchor&&(Xf.isScalar(o.node)||Xf.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=s,a}}},sourceObjects:i}}hw.anchorIsValid=pw;hw.anchorNames=Qf;hw.createNodeAnchors=mw;hw.findNewAnchor=Zf});var To=M(function(xw){function Rn(e,t,n,i){if(i&&typeof i==="object")if(Array.isArray(i))for(let r=0,s=i.length;r<s;++r){let o=i[r],a=Rn(e,i,String(r),o);if(a===void 0)delete i[r];else if(a!==o)i[r]=a}else if(i instanceof Map)for(let r of Array.from(i.keys())){let s=i.get(r),o=Rn(e,i,r,s);if(o===void 0)i.delete(r);else if(o!==s)i.set(r,o)}else if(i instanceof Set)for(let r of Array.from(i)){let s=Rn(e,i,r,r);if(s===void 0)i.delete(r);else if(s!==r)i.delete(r),i.add(s)}else for(let[r,s]of Object.entries(i)){let o=Rn(e,i,r,s);if(o===void 0)delete i[r];else if(o!==s)i[r]=o}return e.call(t,n,i)}xw.applyReviver=Rn});var rt=M(function($w){var Sw=V();function ed(e,t,n){if(Array.isArray(e))return e.map((i,r)=>ed(i,String(r),n));if(e&&typeof e.toJSON==="function"){if(!n||!Sw.hasAnchor(e))return e.toJSON(t,n);let i={aliasCount:0,count:1,res:void 0};n.anchors.set(e,i),n.onCreate=(s)=>{i.res=s,delete n.onCreate};let r=e.toJSON(t,n);if(n.onCreate)n.onCreate(r);return r}if(typeof e==="bigint"&&!n?.keep)return Number(e);return e}$w.toJS=ed});var sr=M(function(kw){var Ew=To(),td=V(),Aw=rt();class nd{constructor(e){Object.defineProperty(this,td.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)e.range=this.range.slice();return e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:i,reviver:r}={}){if(!td.isDocument(e))throw TypeError("A document argument is required");let s={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==="number"?n:100},o=Aw.toJS(this,"",s);if(typeof i==="function")for(let{count:a,res:l}of s.anchors.values())i(l,a);return typeof r==="function"?Ew.applyReviver(r,{"":o},"",o):o}}kw.NodeBase=nd});var Pn=M(function(Nw){var Iw=rr(),Mw=Nn(),Wt=V(),Ow=sr(),Cw=rt();class id extends Ow.NodeBase{constructor(e){super(Wt.ALIAS);this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");let n;if(t?.aliasResolveCache)n=t.aliasResolveCache;else if(n=[],Mw.visit(e,{Node:(r,s)=>{if(Wt.isAlias(s)||Wt.hasAnchor(s))n.push(s)}}),t)t.aliasResolveCache=n;let i=void 0;for(let r of n){if(r===this)break;if(r.anchor===this.source)i=r}return i}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:i,maxAliasCount:r}=t,s=this.resolve(i,t);if(!s){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(a)}let o=n.get(s);if(!o)Cw.toJS(s,null,t),o=n.get(s);if(o?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(r>=0){if(o.count+=1,o.aliasCount===0)o.aliasCount=or(i,s,n);if(o.count*o.aliasCount>r)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return o.res}toString(e,t,n){let i=`*${this.source}`;if(e){if(Iw.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(r)}if(e.implicitKey)return`${i} `}return i}}function or(e,t,n){if(Wt.isAlias(t)){let i=t.resolve(e),r=n&&i&&n.get(i);return r?r.count*r.aliasCount:0}else if(Wt.isCollection(t)){let i=0;for(let r of t.items){let s=or(e,r,n);if(s>i)i=s}return i}else if(Wt.isPair(t)){let i=or(e,t.key,n),r=or(e,t.value,n);return Math.max(i,r)}return 1}Nw.Alias=id});var re=M(function(Dw){var Pw=V(),Lw=sr(),Fw=rt(),qw=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class kt extends Lw.NodeBase{constructor(e){super(Pw.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:Fw.toJS(this.value,e,t)}toString(){return String(this.value)}}kt.BLOCK_FOLDED="BLOCK_FOLDED";kt.BLOCK_LITERAL="BLOCK_LITERAL";kt.PLAIN="PLAIN";kt.QUOTE_DOUBLE="QUOTE_DOUBLE";kt.QUOTE_SINGLE="QUOTE_SINGLE";Dw.Scalar=kt;Dw.isScalarValue=qw});var Ln=M(function(Kw){var Gw=Pn(),Tt=V(),rd=re(),Bw="tag:yaml.org,2002:";function Vw(e,t,n){if(t){let i=n.filter((s)=>s.tag===t),r=i.find((s)=>!s.format)??i[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find((i)=>i.identify?.(e)&&!i.format)}function Hw(e,t,n){if(Tt.isDocument(e))e=e.contents;if(Tt.isNode(e))return e;if(Tt.isPair(e)){let u=n.schema[Tt.MAP].createNode?.(n.schema,null,n);return u.items.push(e),u}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:i,onAnchor:r,onTagObj:s,schema:o,sourceObjects:a}=n,l=void 0;if(i&&e&&typeof e==="object")if(l=a.get(e),l)return l.anchor??(l.anchor=r(e)),new Gw.Alias(l.anchor);else l={anchor:null,node:null},a.set(e,l);if(t?.startsWith("!!"))t=Bw+t.slice(2);let c=Vw(e,t,o.tags);if(!c){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let u=new rd.Scalar(e);if(l)l.node=u;return u}c=e instanceof Map?o[Tt.MAP]:(Symbol.iterator in Object(e))?o[Tt.SEQ]:o[Tt.MAP]}if(s)s(c),delete n.onTagObj;let p=c?.createNode?c.createNode(n.schema,e,n):typeof c?.nodeClass?.from==="function"?c.nodeClass.from(n.schema,e,n):new rd.Scalar(e);if(t)p.tag=t;else if(!c.default)p.tag=c.tag;if(l)l.node=p;return p}Kw.createNode=Hw});var ar=M(function(zw){var Jw=Ln(),Be=V(),Yw=sr();function Io(e,t,n){let i=n;for(let r=t.length-1;r>=0;--r){let s=t[r];if(typeof s==="number"&&Number.isInteger(s)&&s>=0){let o=[];o[s]=i,i=o}else i=new Map([[s,i]])}return Jw.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var sd=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class od extends Yw.NodeBase{constructor(e,t){super(e);Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(e)t.schema=e;if(t.items=t.items.map((n)=>Be.isNode(n)||Be.isPair(n)?n.clone(e):n),this.range)t.range=this.range.slice();return t}addIn(e,t){if(sd(e))this.add(t);else{let[n,...i]=e,r=this.get(n,!0);if(Be.isCollection(r))r.addIn(i,t);else if(r===void 0&&this.schema)this.set(n,Io(this.schema,i,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let i=this.get(t,!0);if(Be.isCollection(i))return i.deleteIn(n);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...i]=e,r=this.get(n,!0);if(i.length===0)return!t&&Be.isScalar(r)?r.value:r;else return Be.isCollection(r)?r.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!Be.isPair(t))return!1;let n=t.value;return n==null||e&&Be.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let i=this.get(t,!0);return Be.isCollection(i)?i.hasIn(n):!1}setIn(e,t){let[n,...i]=e;if(i.length===0)this.set(n,t);else{let r=this.get(n,!0);if(Be.isCollection(r))r.setIn(i,t);else if(r===void 0&&this.schema)this.set(n,Io(this.schema,i,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}}zw.Collection=od;zw.collectionFromPath=Io;zw.isEmptyPath=sd});var Fn=M(function(n0){var e0=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function Mo(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var t0=(e,t,n)=>e.endsWith(`
513
+ `.indexOf(e.charAt(t))!==-1}var vo=I(()=>{Xi();Of()});function Cf(e,t=[],n=Cn.DEFAULT){let i=null,r=[],s=[];function o(l){if(Array.isArray(r))r.push(l);else if(i!==null)r[i]=l}return $o(e,{onObjectBegin:()=>{let l={};o(l),s.push(r),r=l,i=null},onObjectProperty:(l)=>{i=l},onObjectEnd:()=>{r=s.pop()},onArrayBegin:()=>{let l=[];o(l),s.push(r),r=l,i=null},onArrayEnd:()=>{r=s.pop()},onLiteralValue:o,onError:(l,c,p)=>{t.push({error:l,offset:c,length:p})}},n),r[0]}function So(e,t=[],n=Cn.DEFAULT){let i={type:"array",offset:-1,length:-1,children:[],parent:void 0};function r(l){if(i.type==="property")i.length=l-i.offset,i=i.parent}function s(l){return i.children.push(l),l}$o(e,{onObjectBegin:(l)=>{i=s({type:"object",offset:l,length:-1,parent:i,children:[]})},onObjectProperty:(l,c,p)=>{i=s({type:"property",offset:c,length:-1,parent:i,children:[]}),i.children.push({type:"string",value:l,offset:c,length:p,parent:i})},onObjectEnd:(l,c)=>{r(l+c),i.length=l+c-i.offset,i=i.parent,r(l+c)},onArrayBegin:(l,c)=>{i=s({type:"array",offset:l,length:-1,parent:i,children:[]})},onArrayEnd:(l,c)=>{i.length=l+c-i.offset,i=i.parent,r(l+c)},onLiteralValue:(l,c,p)=>{s({type:Ob(l),offset:c,length:p,parent:i,value:l}),r(c+p)},onSeparator:(l,c,p)=>{if(i.type==="property"){if(l===":")i.colonOffset=c;else if(l===",")r(c)}},onError:(l,c,p)=>{t.push({error:l,offset:c,length:p})}},n);let a=i.children[0];if(a)delete a.parent;return a}function Qi(e,t){if(!e)return;let n=e;for(let i of t)if(typeof i==="string"){if(n.type!=="object"||!Array.isArray(n.children))return;let r=!1;for(let s of n.children)if(Array.isArray(s.children)&&s.children[0].value===i&&s.children.length===2){n=s.children[1],r=!0;break}if(!r)return}else{let r=i;if(n.type!=="array"||r<0||!Array.isArray(n.children)||r>=n.children.length)return;n=n.children[r]}return n}function $o(e,t,n=Cn.DEFAULT){let i=Mn(e,!1),r=[],s=0;function o(L){return L?()=>s===0&&L(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter()):()=>!0}function a(L){return L?(J)=>s===0&&L(J,i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter()):()=>!0}function l(L){return L?(J)=>s===0&&L(J,i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter(),()=>r.slice()):()=>!0}function c(L){return L?()=>{if(s>0)s++;else if(L(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter(),()=>r.slice())===!1)s=1}:()=>!0}function p(L){return L?()=>{if(s>0)s--;if(s===0)L(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter())}:()=>!0}let u=c(t.onObjectBegin),f=l(t.onObjectProperty),g=p(t.onObjectEnd),h=c(t.onArrayBegin),d=p(t.onArrayEnd),m=l(t.onLiteralValue),v=a(t.onSeparator),w=o(t.onComment),x=a(t.onError),E=n&&n.disallowComments,A=n&&n.allowTrailingComma;function _(){while(!0){let L=i.scan();switch(i.getTokenError()){case 4:S(14);break;case 5:S(15);break;case 3:S(13);break;case 1:if(!E)S(11);break;case 2:S(12);break;case 6:S(16);break}switch(L){case 12:case 13:if(E)S(10);else w();break;case 16:S(1);break;case 15:case 14:break;default:return L}}}function S(L,J=[],ye=[]){if(x(L),J.length+ye.length>0){let We=i.getToken();while(We!==17){if(J.indexOf(We)!==-1){_();break}else if(ye.indexOf(We)!==-1)break;We=_()}}}function k(L){let J=i.getTokenValue();if(L)m(J);else f(J),r.push(J);return _(),!0}function R(){switch(i.getToken()){case 11:let L=i.getTokenValue(),J=Number(L);if(isNaN(J))S(2),J=0;m(J);break;case 7:m(null);break;case 8:m(!0);break;case 9:m(!1);break;default:return!1}return _(),!0}function U(){if(i.getToken()!==10)return S(3,[],[2,5]),!1;if(k(!1),i.getToken()===6){if(v(":"),_(),!C())S(4,[],[2,5])}else S(5,[],[2,5]);return r.pop(),!0}function q(){u(),_();let L=!1;while(i.getToken()!==2&&i.getToken()!==17){if(i.getToken()===5){if(!L)S(4,[],[]);if(v(","),_(),i.getToken()===2&&A)break}else if(L)S(6,[],[]);if(!U())S(4,[],[2,5]);L=!0}if(g(),i.getToken()!==2)S(7,[2],[]);else _();return!0}function P(){h(),_();let L=!0,J=!1;while(i.getToken()!==4&&i.getToken()!==17){if(i.getToken()===5){if(!J)S(4,[],[]);if(v(","),_(),i.getToken()===4&&A)break}else if(J)S(6,[],[]);if(L)r.push(0),L=!1;else r[r.length-1]++;if(!C())S(4,[],[4,5]);J=!0}if(d(),!L)r.pop();if(i.getToken()!==4)S(8,[4],[]);else _();return!0}function C(){switch(i.getToken()){case 3:return P();case 1:return q();case 10:return k(!0);default:return R()}}if(_(),i.getToken()===17){if(n.allowEmptyContent)return!0;return S(4,[],[]),!1}if(!C())return S(4,[],[]),!1;if(i.getToken()!==17)S(9,[],[]);return!0}function Ob(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(!e)return"null";else if(Array.isArray(e))return"array";return"object"}default:return"null"}}var Cn;var _o=I(()=>{Xi();(function(e){e.DEFAULT={allowTrailingComma:!1}})(Cn||(Cn={}))});function Nf(e,t,n,i){let r=t.slice(),o=So(e,[]),a=void 0,l=void 0;while(r.length>0)if(l=r.pop(),a=Qi(o,r),a===void 0&&n!==void 0)if(typeof l==="string")n={[l]:n};else n=[n];else break;if(!a){if(n===void 0)throw Error("Can not delete in empty document");return At(e,{offset:o?o.offset:0,length:o?o.length:0,content:JSON.stringify(n)},i)}else if(a.type==="object"&&typeof l==="string"&&Array.isArray(a.children)){let c=Qi(a,[l]);if(c!==void 0)if(n===void 0){if(!c.parent)throw Error("Malformed AST");let p=a.children.indexOf(c.parent),u,f=c.parent.offset+c.parent.length;if(p>0){let g=a.children[p-1];u=g.offset+g.length}else if(u=a.offset+1,a.children.length>1)f=a.children[1].offset;return At(e,{offset:u,length:f-u,content:""},i)}else return At(e,{offset:c.offset,length:c.length,content:JSON.stringify(n)},i);else{if(n===void 0)return[];let p=`${JSON.stringify(l)}: ${JSON.stringify(n)}`,u=i.getInsertionIndex?i.getInsertionIndex(a.children.map((g)=>g.children[0].value)):a.children.length,f;if(u>0){let g=a.children[u-1];f={offset:g.offset+g.length,length:0,content:","+p}}else if(a.children.length===0)f={offset:a.offset+1,length:0,content:p};else f={offset:a.offset+1,length:0,content:p+","};return At(e,f,i)}}else if(a.type==="array"&&typeof l==="number"&&Array.isArray(a.children)){let c=l;if(c===-1){let p=`${JSON.stringify(n)}`,u;if(a.children.length===0)u={offset:a.offset+1,length:0,content:p};else{let f=a.children[a.children.length-1];u={offset:f.offset+f.length,length:0,content:","+p}}return At(e,u,i)}else if(n===void 0&&a.children.length>=0){let p=l,u=a.children[p],f;if(a.children.length===1)f={offset:a.offset+1,length:a.length-2,content:""};else if(a.children.length-1===p){let g=a.children[p-1],h=g.offset+g.length,d=a.offset+a.length;f={offset:h,length:d-2-h,content:""}}else f={offset:u.offset,length:a.children[p+1].offset-u.offset,content:""};return At(e,f,i)}else if(n!==void 0){let p,u=`${JSON.stringify(n)}`;if(!i.isArrayInsertion&&a.children.length>l){let f=a.children[l];p={offset:f.offset,length:f.length,content:u}}else if(a.children.length===0||l===0)p={offset:a.offset+1,length:0,content:a.children.length===0?u:u+","};else{let f=l>a.children.length?a.children.length:l,g=a.children[f-1];p={offset:g.offset+g.length,length:0,content:","+u}}return At(e,p,i)}else throw Error(`Can not ${n===void 0?"remove":i.isArrayInsertion?"insert":"modify"} Array index ${c} as length is not sufficient`)}else throw Error(`Can not add ${typeof l!=="number"?"index":"property"} to parent of type ${a.type}`)}function At(e,t,n){if(!n.formattingOptions)return[t];let i=Zi(e,t),r=t.offset,s=t.offset+t.content.length;if(t.length===0||t.content.length===0){while(r>0&&!On(i,r-1))r--;while(s<i.length&&!On(i,s))s++}let o=xo(i,{offset:r,length:s-r},{...n.formattingOptions,keepLines:!1});for(let l=o.length-1;l>=0;l--){let c=o[l];i=Zi(i,c),r=Math.min(r,c.offset),s=Math.max(s,c.offset+c.length),s+=c.content.length-c.length}let a=e.length-(i.length-s)-r;return[{offset:r,length:a,content:i.substring(r,s)}]}function Zi(e,t){return e.substring(0,t.offset)+t.content+e.substring(t.offset+t.length)}var Rf=I(()=>{vo();_o()});function Df(e,t,n,i){return Nf(e,t,n,i)}function Uf(e,t){let n=t.slice(0).sort((r,s)=>{let o=r.offset-s.offset;if(o===0)return r.length-s.length;return o}),i=e.length;for(let r=n.length-1;r>=0;r--){let s=n[r];if(s.offset+s.length<=i)e=Zi(e,s);else throw Error("Overlapping edit");i=s.offset}return e}var Lf,Pf,qf,Ff;var jf=I(()=>{vo();Rf();Xi();_o();(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(Lf||(Lf={}));(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(Pf||(Pf={}));qf=Cf;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(Ff||(Ff={}))});var V=M(function(jb){var Eo=Symbol.for("yaml.alias"),Gf=Symbol.for("yaml.document"),er=Symbol.for("yaml.map"),Bf=Symbol.for("yaml.pair"),Ao=Symbol.for("yaml.scalar"),tr=Symbol.for("yaml.seq"),Ye=Symbol.for("yaml.node.type"),Rb=(e)=>!!e&&typeof e==="object"&&e[Ye]===Eo,Lb=(e)=>!!e&&typeof e==="object"&&e[Ye]===Gf,Pb=(e)=>!!e&&typeof e==="object"&&e[Ye]===er,Fb=(e)=>!!e&&typeof e==="object"&&e[Ye]===Bf,Vf=(e)=>!!e&&typeof e==="object"&&e[Ye]===Ao,qb=(e)=>!!e&&typeof e==="object"&&e[Ye]===tr;function Hf(e){if(e&&typeof e==="object")switch(e[Ye]){case er:case tr:return!0}return!1}function Db(e){if(e&&typeof e==="object")switch(e[Ye]){case Eo:case er:case Ao:case tr:return!0}return!1}var Ub=(e)=>(Vf(e)||Hf(e))&&!!e.anchor;jb.ALIAS=Eo;jb.DOC=Gf;jb.MAP=er;jb.NODE_TYPE=Ye;jb.PAIR=Bf;jb.SCALAR=Ao;jb.SEQ=tr;jb.hasAnchor=Ub;jb.isAlias=Rb;jb.isCollection=Hf;jb.isDocument=Lb;jb.isMap=Pb;jb.isNode=Db;jb.isPair=Fb;jb.isScalar=Vf;jb.isSeq=qb});var Nn=M(function(rw){var ae=V(),pe=Symbol("break visit"),Kf=Symbol("skip children"),Ge=Symbol("remove node");function nr(e,t){let n=Wf(t);if(ae.isDocument(e)){if(Ht(null,e.contents,n,Object.freeze([e]))===Ge)e.contents=null}else Ht(null,e,n,Object.freeze([]))}nr.BREAK=pe;nr.SKIP=Kf;nr.REMOVE=Ge;function Ht(e,t,n,i){let r=Jf(e,t,n,i);if(ae.isNode(r)||ae.isPair(r))return Yf(e,i,r),Ht(e,r,n,i);if(typeof r!=="symbol"){if(ae.isCollection(t)){i=Object.freeze(i.concat(t));for(let s=0;s<t.items.length;++s){let o=Ht(s,t.items[s],n,i);if(typeof o==="number")s=o-1;else if(o===pe)return pe;else if(o===Ge)t.items.splice(s,1),s-=1}}else if(ae.isPair(t)){i=Object.freeze(i.concat(t));let s=Ht("key",t.key,n,i);if(s===pe)return pe;else if(s===Ge)t.key=null;let o=Ht("value",t.value,n,i);if(o===pe)return pe;else if(o===Ge)t.value=null}}return r}async function ir(e,t){let n=Wf(t);if(ae.isDocument(e)){if(await Kt(null,e.contents,n,Object.freeze([e]))===Ge)e.contents=null}else await Kt(null,e,n,Object.freeze([]))}ir.BREAK=pe;ir.SKIP=Kf;ir.REMOVE=Ge;async function Kt(e,t,n,i){let r=await Jf(e,t,n,i);if(ae.isNode(r)||ae.isPair(r))return Yf(e,i,r),Kt(e,r,n,i);if(typeof r!=="symbol"){if(ae.isCollection(t)){i=Object.freeze(i.concat(t));for(let s=0;s<t.items.length;++s){let o=await Kt(s,t.items[s],n,i);if(typeof o==="number")s=o-1;else if(o===pe)return pe;else if(o===Ge)t.items.splice(s,1),s-=1}}else if(ae.isPair(t)){i=Object.freeze(i.concat(t));let s=await Kt("key",t.key,n,i);if(s===pe)return pe;else if(s===Ge)t.key=null;let o=await Kt("value",t.value,n,i);if(o===pe)return pe;else if(o===Ge)t.value=null}}return r}function Wf(e){if(typeof e==="object"&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}function Jf(e,t,n,i){if(typeof n==="function")return n(e,t,i);if(ae.isMap(t))return n.Map?.(e,t,i);if(ae.isSeq(t))return n.Seq?.(e,t,i);if(ae.isPair(t))return n.Pair?.(e,t,i);if(ae.isScalar(t))return n.Scalar?.(e,t,i);if(ae.isAlias(t))return n.Alias?.(e,t,i);return}function Yf(e,t,n){let i=t[t.length-1];if(ae.isCollection(i))i.items[e]=n;else if(ae.isPair(i))if(e==="key")i.key=n;else i.value=n;else if(ae.isDocument(i))i.contents=n;else{let r=ae.isAlias(i)?"alias":"scalar";throw Error(`Cannot replace node with ${r} parent`)}}rw.visit=nr;rw.visitAsync=ir});var ko=M(function(uw){var zf=V(),aw=Nn(),lw={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},cw=(e)=>e.replace(/[!,[\]{}]/g,(t)=>lw[t]);class ve{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},ve.defaultYaml,e),this.tags=Object.assign({},ve.defaultTags,t)}clone(){let e=new ve(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new ve(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:ve.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},ve.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:ve.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},ve.defaultTags),this.atNextDocument=!1;let n=e.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(n.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),n.length<2)return!1}let[r,s]=n;return this.tags[r]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[r]=n;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;else{let s=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,s),!1}}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let s=e.slice(2,-1);if(s==="!"||s==="!!")return t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null;if(e[e.length-1]!==">")t("Verbatim tags must end with a >");return s}let[,n,i]=e.match(/^(.*!)([^!]*)$/s);if(!i)t(`The ${e} tag has no suffix`);let r=this.tags[n];if(r)try{return r+decodeURIComponent(i)}catch(s){return t(String(s)),null}if(n==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+cw(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),i;if(e&&n.length>0&&zf.isNode(e.contents)){let r={};aw.visit(e.contents,(s,o)=>{if(zf.isNode(o)&&o.tag)r[o.tag]=!0}),i=Object.keys(r)}else i=[];for(let[r,s]of n){if(r==="!!"&&s==="tag:yaml.org,2002:")continue;if(!e||i.some((o)=>o.startsWith(s)))t.push(`%TAG ${r} ${s}`)}return t.join(`
514
+ `)}}ve.defaultYaml={explicit:!1,version:"1.2"};ve.defaultTags={"!!":"tag:yaml.org,2002:"};uw.Directives=ve});var rr=M(function(hw){var Xf=V(),dw=Nn();function pw(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(n)}return!0}function Qf(e){let t=new Set;return dw.visit(e,{Value(n,i){if(i.anchor)t.add(i.anchor)}}),t}function Zf(e,t){for(let n=1;;++n){let i=`${e}${n}`;if(!t.has(i))return i}}function mw(e,t){let n=[],i=new Map,r=null;return{onAnchor:(s)=>{n.push(s),r??(r=Qf(e));let o=Zf(t,r);return r.add(o),o},setAnchors:()=>{for(let s of n){let o=i.get(s);if(typeof o==="object"&&o.anchor&&(Xf.isScalar(o.node)||Xf.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=s,a}}},sourceObjects:i}}hw.anchorIsValid=pw;hw.anchorNames=Qf;hw.createNodeAnchors=mw;hw.findNewAnchor=Zf});var To=M(function(xw){function Rn(e,t,n,i){if(i&&typeof i==="object")if(Array.isArray(i))for(let r=0,s=i.length;r<s;++r){let o=i[r],a=Rn(e,i,String(r),o);if(a===void 0)delete i[r];else if(a!==o)i[r]=a}else if(i instanceof Map)for(let r of Array.from(i.keys())){let s=i.get(r),o=Rn(e,i,r,s);if(o===void 0)i.delete(r);else if(o!==s)i.set(r,o)}else if(i instanceof Set)for(let r of Array.from(i)){let s=Rn(e,i,r,r);if(s===void 0)i.delete(r);else if(s!==r)i.delete(r),i.add(s)}else for(let[r,s]of Object.entries(i)){let o=Rn(e,i,r,s);if(o===void 0)delete i[r];else if(o!==s)i[r]=o}return e.call(t,n,i)}xw.applyReviver=Rn});var rt=M(function($w){var Sw=V();function ed(e,t,n){if(Array.isArray(e))return e.map((i,r)=>ed(i,String(r),n));if(e&&typeof e.toJSON==="function"){if(!n||!Sw.hasAnchor(e))return e.toJSON(t,n);let i={aliasCount:0,count:1,res:void 0};n.anchors.set(e,i),n.onCreate=(s)=>{i.res=s,delete n.onCreate};let r=e.toJSON(t,n);if(n.onCreate)n.onCreate(r);return r}if(typeof e==="bigint"&&!n?.keep)return Number(e);return e}$w.toJS=ed});var sr=M(function(kw){var Ew=To(),td=V(),Aw=rt();class nd{constructor(e){Object.defineProperty(this,td.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)e.range=this.range.slice();return e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:i,reviver:r}={}){if(!td.isDocument(e))throw TypeError("A document argument is required");let s={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==="number"?n:100},o=Aw.toJS(this,"",s);if(typeof i==="function")for(let{count:a,res:l}of s.anchors.values())i(l,a);return typeof r==="function"?Ew.applyReviver(r,{"":o},"",o):o}}kw.NodeBase=nd});var Ln=M(function(Nw){var Iw=rr(),Mw=Nn(),Wt=V(),Ow=sr(),Cw=rt();class id extends Ow.NodeBase{constructor(e){super(Wt.ALIAS);this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");let n;if(t?.aliasResolveCache)n=t.aliasResolveCache;else if(n=[],Mw.visit(e,{Node:(r,s)=>{if(Wt.isAlias(s)||Wt.hasAnchor(s))n.push(s)}}),t)t.aliasResolveCache=n;let i=void 0;for(let r of n){if(r===this)break;if(r.anchor===this.source)i=r}return i}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:i,maxAliasCount:r}=t,s=this.resolve(i,t);if(!s){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(a)}let o=n.get(s);if(!o)Cw.toJS(s,null,t),o=n.get(s);if(o?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(r>=0){if(o.count+=1,o.aliasCount===0)o.aliasCount=or(i,s,n);if(o.count*o.aliasCount>r)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return o.res}toString(e,t,n){let i=`*${this.source}`;if(e){if(Iw.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(r)}if(e.implicitKey)return`${i} `}return i}}function or(e,t,n){if(Wt.isAlias(t)){let i=t.resolve(e),r=n&&i&&n.get(i);return r?r.count*r.aliasCount:0}else if(Wt.isCollection(t)){let i=0;for(let r of t.items){let s=or(e,r,n);if(s>i)i=s}return i}else if(Wt.isPair(t)){let i=or(e,t.key,n),r=or(e,t.value,n);return Math.max(i,r)}return 1}Nw.Alias=id});var re=M(function(Dw){var Lw=V(),Pw=sr(),Fw=rt(),qw=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class kt extends Pw.NodeBase{constructor(e){super(Lw.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:Fw.toJS(this.value,e,t)}toString(){return String(this.value)}}kt.BLOCK_FOLDED="BLOCK_FOLDED";kt.BLOCK_LITERAL="BLOCK_LITERAL";kt.PLAIN="PLAIN";kt.QUOTE_DOUBLE="QUOTE_DOUBLE";kt.QUOTE_SINGLE="QUOTE_SINGLE";Dw.Scalar=kt;Dw.isScalarValue=qw});var Pn=M(function(Kw){var Gw=Ln(),Tt=V(),rd=re(),Bw="tag:yaml.org,2002:";function Vw(e,t,n){if(t){let i=n.filter((s)=>s.tag===t),r=i.find((s)=>!s.format)??i[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find((i)=>i.identify?.(e)&&!i.format)}function Hw(e,t,n){if(Tt.isDocument(e))e=e.contents;if(Tt.isNode(e))return e;if(Tt.isPair(e)){let u=n.schema[Tt.MAP].createNode?.(n.schema,null,n);return u.items.push(e),u}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:i,onAnchor:r,onTagObj:s,schema:o,sourceObjects:a}=n,l=void 0;if(i&&e&&typeof e==="object")if(l=a.get(e),l)return l.anchor??(l.anchor=r(e)),new Gw.Alias(l.anchor);else l={anchor:null,node:null},a.set(e,l);if(t?.startsWith("!!"))t=Bw+t.slice(2);let c=Vw(e,t,o.tags);if(!c){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let u=new rd.Scalar(e);if(l)l.node=u;return u}c=e instanceof Map?o[Tt.MAP]:(Symbol.iterator in Object(e))?o[Tt.SEQ]:o[Tt.MAP]}if(s)s(c),delete n.onTagObj;let p=c?.createNode?c.createNode(n.schema,e,n):typeof c?.nodeClass?.from==="function"?c.nodeClass.from(n.schema,e,n):new rd.Scalar(e);if(t)p.tag=t;else if(!c.default)p.tag=c.tag;if(l)l.node=p;return p}Kw.createNode=Hw});var ar=M(function(zw){var Jw=Pn(),Be=V(),Yw=sr();function Io(e,t,n){let i=n;for(let r=t.length-1;r>=0;--r){let s=t[r];if(typeof s==="number"&&Number.isInteger(s)&&s>=0){let o=[];o[s]=i,i=o}else i=new Map([[s,i]])}return Jw.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var sd=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class od extends Yw.NodeBase{constructor(e,t){super(e);Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(e)t.schema=e;if(t.items=t.items.map((n)=>Be.isNode(n)||Be.isPair(n)?n.clone(e):n),this.range)t.range=this.range.slice();return t}addIn(e,t){if(sd(e))this.add(t);else{let[n,...i]=e,r=this.get(n,!0);if(Be.isCollection(r))r.addIn(i,t);else if(r===void 0&&this.schema)this.set(n,Io(this.schema,i,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let i=this.get(t,!0);if(Be.isCollection(i))return i.deleteIn(n);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...i]=e,r=this.get(n,!0);if(i.length===0)return!t&&Be.isScalar(r)?r.value:r;else return Be.isCollection(r)?r.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!Be.isPair(t))return!1;let n=t.value;return n==null||e&&Be.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let i=this.get(t,!0);return Be.isCollection(i)?i.hasIn(n):!1}setIn(e,t){let[n,...i]=e;if(i.length===0)this.set(n,t);else{let r=this.get(n,!0);if(Be.isCollection(r))r.setIn(i,t);else if(r===void 0&&this.schema)this.set(n,Io(this.schema,i,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}}zw.Collection=od;zw.collectionFromPath=Io;zw.isEmptyPath=sd});var Fn=M(function(n0){var e0=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function Mo(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var t0=(e,t,n)=>e.endsWith(`
515
515
  `)?Mo(n,t):n.includes(`
516
516
  `)?`
517
517
  `+Mo(n,t):(e.endsWith(" ")?"":" ")+n;n0.indentComment=Mo;n0.lineComment=t0;n0.stringifyComment=e0});var ld=M(function(a0){function o0(e,t,n="flow",{indentAtStart:i,lineWidth:r=80,minContentWidth:s=20,onFold:o,onOverflow:a}={}){if(!r||r<0)return e;if(r<s)s=0;let l=Math.max(1+s,1+r-t.length);if(e.length<=l)return e;let c=[],p={},u=r-t.length;if(typeof i==="number")if(i>r-Math.max(2,s))c.push(0);else u=r-i;let f=void 0,g=void 0,h=!1,d=-1,m=-1,v=-1;if(n==="block"){if(d=ad(e,d,t.length),d!==-1)u=d+l}for(let x;x=e[d+=1];){if(n==="quoted"&&x==="\\"){switch(m=d,e[d+1]){case"x":d+=3;break;case"u":d+=5;break;case"U":d+=9;break;default:d+=1}v=d}if(x===`
@@ -551,34 +551,34 @@ ${jn.indentComment(S,n.indent)}`}if(A===""&&!n.inFlow){if(_===`
551
551
 
552
552
  `}else _+=`
553
553
  ${n.indent}`}else if(!g&&ze.isCollection(t)){let S=A[0],k=A.indexOf(`
554
- `),R=k!==-1,U=n.inFlow??t.flow??t.items.length===0;if(R||!U){let q=!1;if(R&&(S==="&"||S==="!")){let L=A.indexOf(" ");if(S==="&"&&L!==-1&&L<k&&A[L+1]==="!")L=A.indexOf(" ",L+1);if(L===-1||k<L)q=!0}if(!q)_=`
554
+ `),R=k!==-1,U=n.inFlow??t.flow??t.items.length===0;if(R||!U){let q=!1;if(R&&(S==="&"||S==="!")){let P=A.indexOf(" ");if(S==="&"&&P!==-1&&P<k&&A[P+1]==="!")P=A.indexOf(" ",P+1);if(P===-1||k<P)q=!0}if(!q)_=`
555
555
  ${n.indent}`}}else if(A===""||A[0]===`
556
- `)_="";if(m+=_+A,n.inFlow){if(E&&i)i()}else if(x&&!E)m+=jn.lineComment(m,n.indent,c(x));else if(d&&r)r();return m}T0.stringifyPair=k0});var No=M(function(C0){var dd=an("process");function M0(e,...t){if(e==="debug")console.log(...t)}function O0(e,t){if(e==="debug"||e==="warn")if(typeof dd.emitWarning==="function")dd.emitWarning(t);else console.warn(t)}C0.debug=M0;C0.warn=O0});var mr=M(function(L0){var pr=V(),pd=re(),fr="<<",dr={identify:(e)=>e===fr||typeof e==="symbol"&&e.description===fr,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new pd.Scalar(Symbol(fr)),{addToJSMap:md}),stringify:()=>fr},P0=(e,t)=>(dr.identify(t)||pr.isScalar(t)&&(!t.type||t.type===pd.Scalar.PLAIN)&&dr.identify(t.value))&&e?.doc.schema.tags.some((n)=>n.tag===dr.tag&&n.default);function md(e,t,n){let i=hd(e,n);if(pr.isSeq(i))for(let r of i.items)Ro(e,t,r);else if(Array.isArray(i))for(let r of i)Ro(e,t,r);else Ro(e,t,i)}function Ro(e,t,n){let i=hd(e,n);if(!pr.isMap(i))throw Error("Merge sources must be maps or map aliases");let r=i.toJSON(null,e,Map);for(let[s,o]of r)if(t instanceof Map){if(!t.has(s))t.set(s,o)}else if(t instanceof Set)t.add(s);else if(!Object.prototype.hasOwnProperty.call(t,s))Object.defineProperty(t,s,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function hd(e,t){return e&&pr.isAlias(t)?t.resolve(e.doc,e):t}L0.addMergeToJSMap=md;L0.isMergeKey=P0;L0.merge=dr});var Lo=M(function(V0){var U0=No(),gd=mr(),j0=Un(),yd=V(),Po=rt();function G0(e,t,{key:n,value:i}){if(yd.isNode(n)&&n.addToJSMap)n.addToJSMap(e,t,i);else if(gd.isMergeKey(e,n))gd.addMergeToJSMap(e,t,i);else{let r=Po.toJS(n,"",e);if(t instanceof Map)t.set(r,Po.toJS(i,r,e));else if(t instanceof Set)t.add(r);else{let s=B0(n,r,e),o=Po.toJS(i,s,e);if(s in t)Object.defineProperty(t,s,{value:o,writable:!0,enumerable:!0,configurable:!0});else t[s]=o}}return t}function B0(e,t,n){if(t===null)return"";if(typeof t!=="object")return String(t);if(yd.isNode(e)&&n?.doc){let i=j0.createStringifyContext(n.doc,{});i.anchors=new Set;for(let s of n.anchors.keys())i.anchors.add(s.anchor);i.inFlow=!0,i.inStringifyKey=!0;let r=e.toString(i);if(!n.mapKeyWarned){let s=JSON.stringify(r);if(s.length>40)s=s.substring(0,36)+'..."';U0.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${s}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}V0.addPairToJSMap=G0});var at=M(function(Y0){var bd=Ln(),K0=fd(),W0=Lo(),hr=V();function J0(e,t,n){let i=bd.createNode(e,void 0,n),r=bd.createNode(t,void 0,n);return new gr(i,r)}class gr{constructor(e,t=null){Object.defineProperty(this,hr.NODE_TYPE,{value:hr.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;if(hr.isNode(t))t=t.clone(e);if(hr.isNode(n))n=n.clone(e);return new gr(t,n)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return W0.addPairToJSMap(t,n,this)}toString(e,t,n){return e?.doc?K0.stringifyPair(this,e,t,n):JSON.stringify(this)}}Y0.Pair=gr;Y0.createPair=J0});var Fo=M(function(t1){var It=V(),wd=Un(),yr=Fn();function Q0(e,t,n){return(t.inFlow??e.flow?e1:Z0)(e,t,n)}function Z0({comment:e,items:t},n,{blockItemPrefix:i,flowChars:r,itemIndent:s,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=n,p=Object.assign({},n,{indent:s,type:null}),u=!1,f=[];for(let h=0;h<t.length;++h){let d=t[h],m=null;if(It.isNode(d)){if(!u&&d.spaceBefore)f.push("");if(br(n,f,d.commentBefore,u),d.comment)m=d.comment}else if(It.isPair(d)){let w=It.isNode(d.key)?d.key:null;if(w){if(!u&&w.spaceBefore)f.push("");br(n,f,w.commentBefore,u)}}u=!1;let v=wd.stringify(d,p,()=>m=null,()=>u=!0);if(m)v+=yr.lineComment(v,s,c(m));if(u&&m)u=!1;f.push(i+v)}let g;if(f.length===0)g=r.start+r.end;else{g=f[0];for(let h=1;h<f.length;++h){let d=f[h];g+=d?`
556
+ `)_="";if(m+=_+A,n.inFlow){if(E&&i)i()}else if(x&&!E)m+=jn.lineComment(m,n.indent,c(x));else if(d&&r)r();return m}T0.stringifyPair=k0});var No=M(function(C0){var dd=an("process");function M0(e,...t){if(e==="debug")console.log(...t)}function O0(e,t){if(e==="debug"||e==="warn")if(typeof dd.emitWarning==="function")dd.emitWarning(t);else console.warn(t)}C0.debug=M0;C0.warn=O0});var mr=M(function(P0){var pr=V(),pd=re(),fr="<<",dr={identify:(e)=>e===fr||typeof e==="symbol"&&e.description===fr,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new pd.Scalar(Symbol(fr)),{addToJSMap:md}),stringify:()=>fr},L0=(e,t)=>(dr.identify(t)||pr.isScalar(t)&&(!t.type||t.type===pd.Scalar.PLAIN)&&dr.identify(t.value))&&e?.doc.schema.tags.some((n)=>n.tag===dr.tag&&n.default);function md(e,t,n){let i=hd(e,n);if(pr.isSeq(i))for(let r of i.items)Ro(e,t,r);else if(Array.isArray(i))for(let r of i)Ro(e,t,r);else Ro(e,t,i)}function Ro(e,t,n){let i=hd(e,n);if(!pr.isMap(i))throw Error("Merge sources must be maps or map aliases");let r=i.toJSON(null,e,Map);for(let[s,o]of r)if(t instanceof Map){if(!t.has(s))t.set(s,o)}else if(t instanceof Set)t.add(s);else if(!Object.prototype.hasOwnProperty.call(t,s))Object.defineProperty(t,s,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function hd(e,t){return e&&pr.isAlias(t)?t.resolve(e.doc,e):t}P0.addMergeToJSMap=md;P0.isMergeKey=L0;P0.merge=dr});var Po=M(function(V0){var U0=No(),gd=mr(),j0=Un(),yd=V(),Lo=rt();function G0(e,t,{key:n,value:i}){if(yd.isNode(n)&&n.addToJSMap)n.addToJSMap(e,t,i);else if(gd.isMergeKey(e,n))gd.addMergeToJSMap(e,t,i);else{let r=Lo.toJS(n,"",e);if(t instanceof Map)t.set(r,Lo.toJS(i,r,e));else if(t instanceof Set)t.add(r);else{let s=B0(n,r,e),o=Lo.toJS(i,s,e);if(s in t)Object.defineProperty(t,s,{value:o,writable:!0,enumerable:!0,configurable:!0});else t[s]=o}}return t}function B0(e,t,n){if(t===null)return"";if(typeof t!=="object")return String(t);if(yd.isNode(e)&&n?.doc){let i=j0.createStringifyContext(n.doc,{});i.anchors=new Set;for(let s of n.anchors.keys())i.anchors.add(s.anchor);i.inFlow=!0,i.inStringifyKey=!0;let r=e.toString(i);if(!n.mapKeyWarned){let s=JSON.stringify(r);if(s.length>40)s=s.substring(0,36)+'..."';U0.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${s}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}V0.addPairToJSMap=G0});var at=M(function(Y0){var bd=Pn(),K0=fd(),W0=Po(),hr=V();function J0(e,t,n){let i=bd.createNode(e,void 0,n),r=bd.createNode(t,void 0,n);return new gr(i,r)}class gr{constructor(e,t=null){Object.defineProperty(this,hr.NODE_TYPE,{value:hr.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;if(hr.isNode(t))t=t.clone(e);if(hr.isNode(n))n=n.clone(e);return new gr(t,n)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return W0.addPairToJSMap(t,n,this)}toString(e,t,n){return e?.doc?K0.stringifyPair(this,e,t,n):JSON.stringify(this)}}Y0.Pair=gr;Y0.createPair=J0});var Fo=M(function(t1){var It=V(),wd=Un(),yr=Fn();function Q0(e,t,n){return(t.inFlow??e.flow?e1:Z0)(e,t,n)}function Z0({comment:e,items:t},n,{blockItemPrefix:i,flowChars:r,itemIndent:s,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=n,p=Object.assign({},n,{indent:s,type:null}),u=!1,f=[];for(let h=0;h<t.length;++h){let d=t[h],m=null;if(It.isNode(d)){if(!u&&d.spaceBefore)f.push("");if(br(n,f,d.commentBefore,u),d.comment)m=d.comment}else if(It.isPair(d)){let w=It.isNode(d.key)?d.key:null;if(w){if(!u&&w.spaceBefore)f.push("");br(n,f,w.commentBefore,u)}}u=!1;let v=wd.stringify(d,p,()=>m=null,()=>u=!0);if(m)v+=yr.lineComment(v,s,c(m));if(u&&m)u=!1;f.push(i+v)}let g;if(f.length===0)g=r.start+r.end;else{g=f[0];for(let h=1;h<f.length;++h){let d=f[h];g+=d?`
557
557
  ${l}${d}`:`
558
558
  `}}if(e){if(g+=`
559
559
  `+yr.indentComment(c(e),l),a)a()}else if(u&&o)o();return g}function e1({items:e},t,{flowChars:n,itemIndent:i}){let{indent:r,indentStep:s,flowCollectionPadding:o,options:{commentString:a}}=t;i+=s;let l=Object.assign({},t,{indent:i,inFlow:!0,type:null}),c=!1,p=0,u=[];for(let h=0;h<e.length;++h){let d=e[h],m=null;if(It.isNode(d)){if(d.spaceBefore)u.push("");if(br(t,u,d.commentBefore,!1),d.comment)m=d.comment}else if(It.isPair(d)){let w=It.isNode(d.key)?d.key:null;if(w){if(w.spaceBefore)u.push("");if(br(t,u,w.commentBefore,!1),w.comment)c=!0}let x=It.isNode(d.value)?d.value:null;if(x){if(x.comment)m=x.comment;if(x.commentBefore)c=!0}else if(d.value==null&&w?.comment)m=w.comment}if(m)c=!0;let v=wd.stringify(d,l,()=>m=null);if(c||(c=u.length>p||v.includes(`
560
560
  `)),h<e.length-1)v+=",";else if(t.options.trailingComma){if(t.options.lineWidth>0)c||(c=u.reduce((w,x)=>w+x.length+2,2)+(v.length+2)>t.options.lineWidth);if(c)v+=","}if(m)v+=yr.lineComment(v,i,a(m));u.push(v),p=u.length}let{start:f,end:g}=n;if(u.length===0)return f+g;else{if(!c){let h=u.reduce((d,m)=>d+m.length+2,2);c=t.options.lineWidth>0&&h>t.options.lineWidth}if(c){let h=f;for(let d of u)h+=d?`
561
561
  ${s}${r}${d}`:`
562
562
  `;return`${h}
563
- ${r}${g}`}else return`${f}${o}${u.join(" ")}${o}${g}`}}function br({indent:e,options:{commentString:t}},n,i,r){if(i&&r)i=i.replace(/^\n+/,"");if(i){let s=yr.indentComment(t(i),e);n.push(s.trimStart())}}t1.stringifyCollection=Q0});var ct=M(function(a1){var i1=Fo(),r1=Lo(),s1=ar(),lt=V(),wr=at(),o1=re();function Gn(e,t){let n=lt.isScalar(t)?t.value:t;for(let i of e)if(lt.isPair(i)){if(i.key===t||i.key===n)return i;if(lt.isScalar(i.key)&&i.key.value===n)return i}return}class xd extends s1.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(lt.MAP,e);this.items=[]}static from(e,t,n){let{keepUndefined:i,replacer:r}=n,s=new this(e),o=(a,l)=>{if(typeof r==="function")l=r.call(t,a,l);else if(Array.isArray(r)&&!r.includes(a))return;if(l!==void 0||i)s.items.push(wr.createPair(a,l,n))};if(t instanceof Map)for(let[a,l]of t)o(a,l);else if(t&&typeof t==="object")for(let a of Object.keys(t))o(a,t[a]);if(typeof e.sortMapEntries==="function")s.items.sort(e.sortMapEntries);return s}add(e,t){let n;if(lt.isPair(e))n=e;else if(!e||typeof e!=="object"||!("key"in e))n=new wr.Pair(e,e?.value);else n=new wr.Pair(e.key,e.value);let i=Gn(this.items,n.key),r=this.schema?.sortMapEntries;if(i){if(!t)throw Error(`Key ${n.key} already set`);if(lt.isScalar(i.value)&&o1.isScalarValue(n.value))i.value.value=n.value;else i.value=n.value}else if(r){let s=this.items.findIndex((o)=>r(n,o)<0);if(s===-1)this.items.push(n);else this.items.splice(s,0,n)}else this.items.push(n)}delete(e){let t=Gn(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let i=Gn(this.items,e)?.value;return(!t&&lt.isScalar(i)?i.value:i)??void 0}has(e){return!!Gn(this.items,e)}set(e,t){this.add(new wr.Pair(e,t),!0)}toJSON(e,t,n){let i=n?new n:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(i);for(let r of this.items)r1.addPairToJSMap(t,i,r);return i}toString(e,t,n){if(!e)return JSON.stringify(this);for(let i of this.items)if(!lt.isPair(i))throw Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return i1.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:t})}}a1.YAMLMap=xd;a1.findPair=Gn});var Yt=M(function(d1){var u1=V(),vd=ct(),f1={collection:"map",default:!0,nodeClass:vd.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!u1.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,n)=>vd.YAMLMap.from(e,t,n)};d1.map=f1});var ut=M(function(w1){var m1=Ln(),h1=Fo(),g1=ar(),vr=V(),y1=re(),b1=rt();class Sd extends g1.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(vr.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=xr(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let n=xr(e);if(typeof n!=="number")return;let i=this.items[n];return!t&&vr.isScalar(i)?i.value:i}has(e){let t=xr(e);return typeof t==="number"&&t<this.items.length}set(e,t){let n=xr(e);if(typeof n!=="number")throw Error(`Expected a valid index, not ${e}.`);let i=this.items[n];if(vr.isScalar(i)&&y1.isScalarValue(t))i.value=t;else this.items[n]=t}toJSON(e,t){let n=[];if(t?.onCreate)t.onCreate(n);let i=0;for(let r of this.items)n.push(b1.toJS(r,String(i++),t));return n}toString(e,t,n){if(!e)return JSON.stringify(this);return h1.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:t})}static from(e,t,n){let{replacer:i}=n,r=new this(e);if(t&&Symbol.iterator in Object(t)){let s=0;for(let o of t){if(typeof i==="function"){let a=t instanceof Set?o:String(s++);o=i.call(t,a,o)}r.items.push(m1.createNode(o,void 0,n))}}return r}}function xr(e){let t=vr.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}w1.YAMLSeq=Sd});var zt=M(function($1){var v1=V(),$d=ut(),S1={collection:"seq",default:!0,nodeClass:$d.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!v1.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,n)=>$d.YAMLSeq.from(e,t,n)};$1.seq=S1});var Bn=M(function(k1){var E1=Dn(),A1={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,n,i){return t=Object.assign({actualString:!0},t),E1.stringifyString(e,t,n,i)}};k1.string=A1});var Sr=M(function(I1){var _d=re(),Ed={identify:(e)=>e==null,createNode:()=>new _d.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new _d.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&Ed.test.test(e)?e:t.options.nullStr};I1.nullTag=Ed});var qo=M(function(C1){var O1=re(),Ad={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new O1.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},n){if(e&&Ad.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?n.options.trueStr:n.options.falseStr}};C1.boolTag=Ad});var Xt=M(function(P1){function R1({format:e,minFractionDigits:t,tag:n,value:i}){if(typeof i==="bigint")return String(i);let r=typeof i==="number"?i:Number(i);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let s=Object.is(i,-0)?"-0":JSON.stringify(i);if(!e&&t&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(s)&&!s.includes("e")){let o=s.indexOf(".");if(o<0)o=s.length,s+=".";let a=t-(s.length-o-1);while(a-- >0)s+="0"}return s}P1.stringifyNumber=R1});var Uo=M(function(j1){var F1=re(),Do=Xt(),q1={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Do.stringifyNumber},D1={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Do.stringifyNumber(e)}},U1={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new F1.Scalar(parseFloat(e)),n=e.indexOf(".");if(n!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-n-1;return t},stringify:Do.stringifyNumber};j1.float=U1;j1.floatExp=D1;j1.floatNaN=q1});var Go=M(function(J1){var kd=Xt(),$r=(e)=>typeof e==="bigint"||Number.isInteger(e),jo=(e,t,n,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),n);function Td(e,t,n){let{value:i}=e;if($r(i)&&i>=0)return n+i.toString(t);return kd.stringifyNumber(e)}var H1={identify:(e)=>$r(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,n)=>jo(e,2,8,n),stringify:(e)=>Td(e,8,"0o")},K1={identify:$r,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>jo(e,0,10,n),stringify:kd.stringifyNumber},W1={identify:(e)=>$r(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>jo(e,2,16,n),stringify:(e)=>Td(e,16,"0x")};J1.int=K1;J1.intHex=W1;J1.intOct=H1});var Id=M(function(rx){var Q1=Yt(),Z1=Sr(),ex=zt(),tx=Bn(),nx=qo(),Bo=Uo(),Vo=Go(),ix=[Q1.map,ex.seq,tx.string,Z1.nullTag,nx.boolTag,Vo.intOct,Vo.int,Vo.intHex,Bo.floatNaN,Bo.floatExp,Bo.float];rx.schema=ix});var Od=M(function(dx){var ox=re(),ax=Yt(),lx=zt();function Md(e){return typeof e==="bigint"||Number.isInteger(e)}var _r=({value:e})=>JSON.stringify(e),cx=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:_r},{identify:(e)=>e==null,createNode:()=>new ox.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:_r},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:_r},{identify:Md,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>Md(e)?e.toString():JSON.stringify(e)},{identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(e)=>parseFloat(e),stringify:_r}],ux={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},fx=[ax.map,lx.seq].concat(cx,ux);dx.schema=fx});var Ko=M(function(gx){var Vn=an("buffer"),Ho=re(),mx=Dn(),hx={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Vn.Buffer==="function")return Vn.Buffer.from(e,"base64");else if(typeof atob==="function"){let n=atob(e.replace(/[\n\r]/g,"")),i=new Uint8Array(n.length);for(let r=0;r<n.length;++r)i[r]=n.charCodeAt(r);return i}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:n},i,r,s){if(!n)return"";let o=n,a;if(typeof Vn.Buffer==="function")a=o instanceof Vn.Buffer?o.toString("base64"):Vn.Buffer.from(o.buffer).toString("base64");else if(typeof btoa==="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Ho.Scalar.BLOCK_LITERAL),t!==Ho.Scalar.QUOTE_DOUBLE){let l=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),c=Math.ceil(a.length/l),p=Array(c);for(let u=0,f=0;u<c;++u,f+=l)p[u]=a.substr(f,l);a=p.join(t===Ho.Scalar.BLOCK_LITERAL?`
563
+ ${r}${g}`}else return`${f}${o}${u.join(" ")}${o}${g}`}}function br({indent:e,options:{commentString:t}},n,i,r){if(i&&r)i=i.replace(/^\n+/,"");if(i){let s=yr.indentComment(t(i),e);n.push(s.trimStart())}}t1.stringifyCollection=Q0});var ct=M(function(a1){var i1=Fo(),r1=Po(),s1=ar(),lt=V(),wr=at(),o1=re();function Gn(e,t){let n=lt.isScalar(t)?t.value:t;for(let i of e)if(lt.isPair(i)){if(i.key===t||i.key===n)return i;if(lt.isScalar(i.key)&&i.key.value===n)return i}return}class xd extends s1.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(lt.MAP,e);this.items=[]}static from(e,t,n){let{keepUndefined:i,replacer:r}=n,s=new this(e),o=(a,l)=>{if(typeof r==="function")l=r.call(t,a,l);else if(Array.isArray(r)&&!r.includes(a))return;if(l!==void 0||i)s.items.push(wr.createPair(a,l,n))};if(t instanceof Map)for(let[a,l]of t)o(a,l);else if(t&&typeof t==="object")for(let a of Object.keys(t))o(a,t[a]);if(typeof e.sortMapEntries==="function")s.items.sort(e.sortMapEntries);return s}add(e,t){let n;if(lt.isPair(e))n=e;else if(!e||typeof e!=="object"||!("key"in e))n=new wr.Pair(e,e?.value);else n=new wr.Pair(e.key,e.value);let i=Gn(this.items,n.key),r=this.schema?.sortMapEntries;if(i){if(!t)throw Error(`Key ${n.key} already set`);if(lt.isScalar(i.value)&&o1.isScalarValue(n.value))i.value.value=n.value;else i.value=n.value}else if(r){let s=this.items.findIndex((o)=>r(n,o)<0);if(s===-1)this.items.push(n);else this.items.splice(s,0,n)}else this.items.push(n)}delete(e){let t=Gn(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let i=Gn(this.items,e)?.value;return(!t&&lt.isScalar(i)?i.value:i)??void 0}has(e){return!!Gn(this.items,e)}set(e,t){this.add(new wr.Pair(e,t),!0)}toJSON(e,t,n){let i=n?new n:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(i);for(let r of this.items)r1.addPairToJSMap(t,i,r);return i}toString(e,t,n){if(!e)return JSON.stringify(this);for(let i of this.items)if(!lt.isPair(i))throw Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return i1.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:t})}}a1.YAMLMap=xd;a1.findPair=Gn});var Yt=M(function(d1){var u1=V(),vd=ct(),f1={collection:"map",default:!0,nodeClass:vd.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!u1.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,n)=>vd.YAMLMap.from(e,t,n)};d1.map=f1});var ut=M(function(w1){var m1=Pn(),h1=Fo(),g1=ar(),vr=V(),y1=re(),b1=rt();class Sd extends g1.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(vr.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=xr(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let n=xr(e);if(typeof n!=="number")return;let i=this.items[n];return!t&&vr.isScalar(i)?i.value:i}has(e){let t=xr(e);return typeof t==="number"&&t<this.items.length}set(e,t){let n=xr(e);if(typeof n!=="number")throw Error(`Expected a valid index, not ${e}.`);let i=this.items[n];if(vr.isScalar(i)&&y1.isScalarValue(t))i.value=t;else this.items[n]=t}toJSON(e,t){let n=[];if(t?.onCreate)t.onCreate(n);let i=0;for(let r of this.items)n.push(b1.toJS(r,String(i++),t));return n}toString(e,t,n){if(!e)return JSON.stringify(this);return h1.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:t})}static from(e,t,n){let{replacer:i}=n,r=new this(e);if(t&&Symbol.iterator in Object(t)){let s=0;for(let o of t){if(typeof i==="function"){let a=t instanceof Set?o:String(s++);o=i.call(t,a,o)}r.items.push(m1.createNode(o,void 0,n))}}return r}}function xr(e){let t=vr.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}w1.YAMLSeq=Sd});var zt=M(function($1){var v1=V(),$d=ut(),S1={collection:"seq",default:!0,nodeClass:$d.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!v1.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,n)=>$d.YAMLSeq.from(e,t,n)};$1.seq=S1});var Bn=M(function(k1){var E1=Dn(),A1={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,n,i){return t=Object.assign({actualString:!0},t),E1.stringifyString(e,t,n,i)}};k1.string=A1});var Sr=M(function(I1){var _d=re(),Ed={identify:(e)=>e==null,createNode:()=>new _d.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new _d.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&Ed.test.test(e)?e:t.options.nullStr};I1.nullTag=Ed});var qo=M(function(C1){var O1=re(),Ad={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new O1.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},n){if(e&&Ad.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?n.options.trueStr:n.options.falseStr}};C1.boolTag=Ad});var Xt=M(function(L1){function R1({format:e,minFractionDigits:t,tag:n,value:i}){if(typeof i==="bigint")return String(i);let r=typeof i==="number"?i:Number(i);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let s=Object.is(i,-0)?"-0":JSON.stringify(i);if(!e&&t&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(s)&&!s.includes("e")){let o=s.indexOf(".");if(o<0)o=s.length,s+=".";let a=t-(s.length-o-1);while(a-- >0)s+="0"}return s}L1.stringifyNumber=R1});var Uo=M(function(j1){var F1=re(),Do=Xt(),q1={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Do.stringifyNumber},D1={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Do.stringifyNumber(e)}},U1={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new F1.Scalar(parseFloat(e)),n=e.indexOf(".");if(n!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-n-1;return t},stringify:Do.stringifyNumber};j1.float=U1;j1.floatExp=D1;j1.floatNaN=q1});var Go=M(function(J1){var kd=Xt(),$r=(e)=>typeof e==="bigint"||Number.isInteger(e),jo=(e,t,n,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),n);function Td(e,t,n){let{value:i}=e;if($r(i)&&i>=0)return n+i.toString(t);return kd.stringifyNumber(e)}var H1={identify:(e)=>$r(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,n)=>jo(e,2,8,n),stringify:(e)=>Td(e,8,"0o")},K1={identify:$r,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>jo(e,0,10,n),stringify:kd.stringifyNumber},W1={identify:(e)=>$r(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>jo(e,2,16,n),stringify:(e)=>Td(e,16,"0x")};J1.int=K1;J1.intHex=W1;J1.intOct=H1});var Id=M(function(rx){var Q1=Yt(),Z1=Sr(),ex=zt(),tx=Bn(),nx=qo(),Bo=Uo(),Vo=Go(),ix=[Q1.map,ex.seq,tx.string,Z1.nullTag,nx.boolTag,Vo.intOct,Vo.int,Vo.intHex,Bo.floatNaN,Bo.floatExp,Bo.float];rx.schema=ix});var Od=M(function(dx){var ox=re(),ax=Yt(),lx=zt();function Md(e){return typeof e==="bigint"||Number.isInteger(e)}var _r=({value:e})=>JSON.stringify(e),cx=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:_r},{identify:(e)=>e==null,createNode:()=>new ox.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:_r},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:_r},{identify:Md,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>Md(e)?e.toString():JSON.stringify(e)},{identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(e)=>parseFloat(e),stringify:_r}],ux={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},fx=[ax.map,lx.seq].concat(cx,ux);dx.schema=fx});var Ko=M(function(gx){var Vn=an("buffer"),Ho=re(),mx=Dn(),hx={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Vn.Buffer==="function")return Vn.Buffer.from(e,"base64");else if(typeof atob==="function"){let n=atob(e.replace(/[\n\r]/g,"")),i=new Uint8Array(n.length);for(let r=0;r<n.length;++r)i[r]=n.charCodeAt(r);return i}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:n},i,r,s){if(!n)return"";let o=n,a;if(typeof Vn.Buffer==="function")a=o instanceof Vn.Buffer?o.toString("base64"):Vn.Buffer.from(o.buffer).toString("base64");else if(typeof btoa==="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Ho.Scalar.BLOCK_LITERAL),t!==Ho.Scalar.QUOTE_DOUBLE){let l=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),c=Math.ceil(a.length/l),p=Array(c);for(let u=0,f=0;u<c;++u,f+=l)p[u]=a.substr(f,l);a=p.join(t===Ho.Scalar.BLOCK_LITERAL?`
564
564
  `:" ")}return mx.stringifyString({comment:e,type:t,value:a},i,r,s)}};gx.binary=hx});var Ar=M(function(vx){var Er=V(),Wo=at(),bx=re(),wx=ut();function Cd(e,t){if(Er.isSeq(e))for(let n=0;n<e.items.length;++n){let i=e.items[n];if(Er.isPair(i))continue;else if(Er.isMap(i)){if(i.items.length>1)t("Each pair must have its own sequence indicator");let r=i.items[0]||new Wo.Pair(new bx.Scalar(null));if(i.commentBefore)r.key.commentBefore=r.key.commentBefore?`${i.commentBefore}
565
565
  ${r.key.commentBefore}`:i.commentBefore;if(i.comment){let s=r.value??r.key;s.comment=s.comment?`${i.comment}
566
- ${s.comment}`:i.comment}i=r}e.items[n]=Er.isPair(i)?i:new Wo.Pair(i)}else t("Expected a sequence for this tag");return e}function Nd(e,t,n){let{replacer:i}=n,r=new wx.YAMLSeq(e);r.tag="tag:yaml.org,2002:pairs";let s=0;if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof i==="function")o=i.call(t,String(s++),o);let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;r.items.push(Wo.createPair(a,l,n))}return r}var xx={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Cd,createNode:Nd};vx.createPairs=Nd;vx.pairs=xx;vx.resolvePairs=Cd});var Yo=M(function(kx){var Rd=V(),Jo=rt(),Hn=ct(),Ex=ut(),Pd=Ar();class Mt extends Ex.YAMLSeq{constructor(){super();this.add=Hn.YAMLMap.prototype.add.bind(this),this.delete=Hn.YAMLMap.prototype.delete.bind(this),this.get=Hn.YAMLMap.prototype.get.bind(this),this.has=Hn.YAMLMap.prototype.has.bind(this),this.set=Hn.YAMLMap.prototype.set.bind(this),this.tag=Mt.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;if(t?.onCreate)t.onCreate(n);for(let i of this.items){let r,s;if(Rd.isPair(i))r=Jo.toJS(i.key,"",t),s=Jo.toJS(i.value,r,t);else r=Jo.toJS(i,"",t);if(n.has(r))throw Error("Ordered maps must not include duplicate keys");n.set(r,s)}return n}static from(e,t,n){let i=Pd.createPairs(e,t,n),r=new this;return r.items=i.items,r}}Mt.tag="tag:yaml.org,2002:omap";var Ax={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:Mt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let n=Pd.resolvePairs(e,t),i=[];for(let{key:r}of n.items)if(Rd.isScalar(r))if(i.includes(r.value))t(`Ordered maps must not include duplicate keys: ${r.value}`);else i.push(r.value);return Object.assign(new Mt,n)},createNode:(e,t,n)=>Mt.from(e,t,n)};kx.YAMLOMap=Mt;kx.omap=Ax});var Ud=M(function(Mx){var Ld=re();function Fd({value:e,source:t},n){if(t&&(e?qd:Dd).test.test(t))return t;return e?n.options.trueStr:n.options.falseStr}var qd={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Ld.Scalar(!0),stringify:Fd},Dd={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Ld.Scalar(!1),stringify:Fd};Mx.falseTag=Dd;Mx.trueTag=qd});var jd=M(function(Fx){var Nx=re(),zo=Xt(),Rx={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:zo.stringifyNumber},Px={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():zo.stringifyNumber(e)}},Lx={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Nx.Scalar(parseFloat(e.replace(/_/g,""))),n=e.indexOf(".");if(n!==-1){let i=e.substring(n+1).replace(/_/g,"");if(i[i.length-1]==="0")t.minFractionDigits=i.length}return t},stringify:zo.stringifyNumber};Fx.float=Lx;Fx.floatExp=Px;Fx.floatNaN=Rx});var Bd=M(function(Hx){var Gd=Xt(),Kn=(e)=>typeof e==="bigint"||Number.isInteger(e);function kr(e,t,n,{intAsBigInt:i}){let r=e[0];if(r==="-"||r==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),i){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return r==="-"?BigInt(-1)*o:o}let s=parseInt(e,n);return r==="-"?-1*s:s}function Xo(e,t,n){let{value:i}=e;if(Kn(i)){let r=i.toString(t);return i<0?"-"+n+r.substr(1):n+r}return Gd.stringifyNumber(e)}var jx={identify:Kn,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>kr(e,2,2,n),stringify:(e)=>Xo(e,2,"0b")},Gx={identify:Kn,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>kr(e,1,8,n),stringify:(e)=>Xo(e,8,"0")},Bx={identify:Kn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>kr(e,0,10,n),stringify:Gd.stringifyNumber},Vx={identify:Kn,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>kr(e,2,16,n),stringify:(e)=>Xo(e,16,"0x")};Hx.int=Bx;Hx.intBin=jx;Hx.intHex=Vx;Hx.intOct=Gx});var Qo=M(function(Xx){var Mr=V(),Tr=at(),Ir=ct();class Ot extends Ir.YAMLMap{constructor(e){super(e);this.tag=Ot.tag}add(e){let t;if(Mr.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Tr.Pair(e.key,null);else t=new Tr.Pair(e,null);if(!Ir.findPair(this.items,t.key))this.items.push(t)}get(e,t){let n=Ir.findPair(this.items,e);return!t&&Mr.isPair(n)?Mr.isScalar(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=Ir.findPair(this.items,e);if(n&&!t)this.items.splice(this.items.indexOf(n),1);else if(!n&&t)this.items.push(new Tr.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);else throw Error("Set items must all have null values")}static from(e,t,n){let{replacer:i}=n,r=new this(e);if(t&&Symbol.iterator in Object(t))for(let s of t){if(typeof i==="function")s=i.call(t,s,s);r.items.push(Tr.createPair(s,null,n))}return r}}Ot.tag="tag:yaml.org,2002:set";var zx={collection:"map",identify:(e)=>e instanceof Set,nodeClass:Ot,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>Ot.from(e,t,n),resolve(e,t){if(Mr.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new Ot,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};Xx.YAMLSet=Ot;Xx.set=zx});var ea=M(function(iv){var ev=Xt();function Zo(e,t){let n=e[0],i=n==="-"||n==="+"?e.substring(1):e,r=(o)=>t?BigInt(o):Number(o),s=i.replace(/_/g,"").split(":").reduce((o,a)=>o*r(60)+r(a),r(0));return n==="-"?r(-1)*s:s}function Vd(e){let{value:t}=e,n=(o)=>o;if(typeof t==="bigint")n=(o)=>BigInt(o);else if(isNaN(t)||!isFinite(t))return ev.stringifyNumber(e);let i="";if(t<0)i="-",t*=n(-1);let r=n(60),s=[t%r];if(t<60)s.unshift(0);else if(t=(t-s[0])/r,s.unshift(t%r),t>=60)t=(t-s[0])/r,s.unshift(t);return i+s.map((o)=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var tv={identify:(e)=>typeof e==="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>Zo(e,n),stringify:Vd},nv={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>Zo(e,!1),stringify:Vd},Hd={identify:(e)=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Hd.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,i,r,s,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(n,i-1,r,s||0,o||0,a||0,l),p=t[8];if(p&&p!=="Z"){let u=Zo(p,!1);if(Math.abs(u)<30)u*=60;c-=60000*u}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};iv.floatTime=nv;iv.intTime=tv;iv.timestamp=Hd});var Wd=M(function(yv){var av=Yt(),lv=Sr(),cv=zt(),uv=Bn(),fv=Ko(),Kd=Ud(),ta=jd(),Or=Bd(),dv=mr(),pv=Yo(),mv=Ar(),hv=Qo(),na=ea(),gv=[av.map,cv.seq,uv.string,lv.nullTag,Kd.trueTag,Kd.falseTag,Or.intBin,Or.intOct,Or.int,Or.intHex,ta.floatNaN,ta.floatExp,ta.float,fv.binary,dv.merge,pv.omap,mv.pairs,hv.set,na.intTime,na.floatTime,na.timestamp];yv.schema=gv});var ip=M(function(Av){var Xd=Yt(),wv=Sr(),Qd=zt(),xv=Bn(),vv=qo(),ia=Uo(),ra=Go(),Sv=Id(),$v=Od(),Zd=Ko(),Wn=mr(),ep=Yo(),tp=Ar(),Jd=Wd(),np=Qo(),Cr=ea(),Yd=new Map([["core",Sv.schema],["failsafe",[Xd.map,Qd.seq,xv.string]],["json",$v.schema],["yaml11",Jd.schema],["yaml-1.1",Jd.schema]]),zd={binary:Zd.binary,bool:vv.boolTag,float:ia.float,floatExp:ia.floatExp,floatNaN:ia.floatNaN,floatTime:Cr.floatTime,int:ra.int,intHex:ra.intHex,intOct:ra.intOct,intTime:Cr.intTime,map:Xd.map,merge:Wn.merge,null:wv.nullTag,omap:ep.omap,pairs:tp.pairs,seq:Qd.seq,set:np.set,timestamp:Cr.timestamp},_v={"tag:yaml.org,2002:binary":Zd.binary,"tag:yaml.org,2002:merge":Wn.merge,"tag:yaml.org,2002:omap":ep.omap,"tag:yaml.org,2002:pairs":tp.pairs,"tag:yaml.org,2002:set":np.set,"tag:yaml.org,2002:timestamp":Cr.timestamp};function Ev(e,t,n){let i=Yd.get(t);if(i&&!e)return n&&!i.includes(Wn.merge)?i.concat(Wn.merge):i.slice();let r=i;if(!r)if(Array.isArray(e))r=[];else{let s=Array.from(Yd.keys()).filter((o)=>o!=="yaml11").map((o)=>JSON.stringify(o)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${s} or define customTags array`)}if(Array.isArray(e))for(let s of e)r=r.concat(s);else if(typeof e==="function")r=e(r.slice());if(n)r=r.concat(Wn.merge);return r.reduce((s,o)=>{let a=typeof o==="string"?zd[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(zd).map((p)=>JSON.stringify(p)).join(", ");throw Error(`Unknown custom tag ${l}; use one of ${c}`)}if(!s.includes(a))s.push(a);return s},[])}Av.coreKnownTags=_v;Av.getTags=Ev});var aa=M(function(Nv){var sa=V(),Iv=Yt(),Mv=zt(),Ov=Bn(),Nr=ip(),Cv=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class oa{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:i,schema:r,sortMapEntries:s,toStringDefaults:o}){this.compat=Array.isArray(e)?Nr.getTags(e,"compat"):e?Nr.getTags(null,e):null,this.name=typeof r==="string"&&r||"core",this.knownTags=i?Nr.coreKnownTags:{},this.tags=Nr.getTags(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,sa.MAP,{value:Iv.map}),Object.defineProperty(this,sa.SCALAR,{value:Ov.string}),Object.defineProperty(this,sa.SEQ,{value:Mv.seq}),this.sortMapEntries=typeof s==="function"?s:s===!0?Cv:null}clone(){let e=Object.create(oa.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}Nv.Schema=oa});var rp=M(function(Fv){var Pv=V(),la=Un(),Jn=Fn();function Lv(e,t){let n=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);if(l)n.push(l),i=!0;else if(e.directives.docStart)i=!0}if(i)n.push("---");let r=la.createStringifyContext(e,t),{commentString:s}=r.options;if(e.commentBefore){if(n.length!==1)n.unshift("");let l=s(e.commentBefore);n.unshift(Jn.indentComment(l,""))}let o=!1,a=null;if(e.contents){if(Pv.isNode(e.contents)){if(e.contents.spaceBefore&&i)n.push("");if(e.contents.commentBefore){let p=s(e.contents.commentBefore);n.push(Jn.indentComment(p,""))}r.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=la.stringify(e.contents,r,()=>a=null,l);if(a)c+=Jn.lineComment(c,"",s(a));if((c[0]==="|"||c[0]===">")&&n[n.length-1]==="---")n[n.length-1]=`--- ${c}`;else n.push(c)}else n.push(la.stringify(e.contents,r));if(e.directives?.docEnd)if(e.comment){let l=s(e.comment);if(l.includes(`
566
+ ${s.comment}`:i.comment}i=r}e.items[n]=Er.isPair(i)?i:new Wo.Pair(i)}else t("Expected a sequence for this tag");return e}function Nd(e,t,n){let{replacer:i}=n,r=new wx.YAMLSeq(e);r.tag="tag:yaml.org,2002:pairs";let s=0;if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof i==="function")o=i.call(t,String(s++),o);let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;r.items.push(Wo.createPair(a,l,n))}return r}var xx={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Cd,createNode:Nd};vx.createPairs=Nd;vx.pairs=xx;vx.resolvePairs=Cd});var Yo=M(function(kx){var Rd=V(),Jo=rt(),Hn=ct(),Ex=ut(),Ld=Ar();class Mt extends Ex.YAMLSeq{constructor(){super();this.add=Hn.YAMLMap.prototype.add.bind(this),this.delete=Hn.YAMLMap.prototype.delete.bind(this),this.get=Hn.YAMLMap.prototype.get.bind(this),this.has=Hn.YAMLMap.prototype.has.bind(this),this.set=Hn.YAMLMap.prototype.set.bind(this),this.tag=Mt.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;if(t?.onCreate)t.onCreate(n);for(let i of this.items){let r,s;if(Rd.isPair(i))r=Jo.toJS(i.key,"",t),s=Jo.toJS(i.value,r,t);else r=Jo.toJS(i,"",t);if(n.has(r))throw Error("Ordered maps must not include duplicate keys");n.set(r,s)}return n}static from(e,t,n){let i=Ld.createPairs(e,t,n),r=new this;return r.items=i.items,r}}Mt.tag="tag:yaml.org,2002:omap";var Ax={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:Mt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let n=Ld.resolvePairs(e,t),i=[];for(let{key:r}of n.items)if(Rd.isScalar(r))if(i.includes(r.value))t(`Ordered maps must not include duplicate keys: ${r.value}`);else i.push(r.value);return Object.assign(new Mt,n)},createNode:(e,t,n)=>Mt.from(e,t,n)};kx.YAMLOMap=Mt;kx.omap=Ax});var Ud=M(function(Mx){var Pd=re();function Fd({value:e,source:t},n){if(t&&(e?qd:Dd).test.test(t))return t;return e?n.options.trueStr:n.options.falseStr}var qd={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Pd.Scalar(!0),stringify:Fd},Dd={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Pd.Scalar(!1),stringify:Fd};Mx.falseTag=Dd;Mx.trueTag=qd});var jd=M(function(Fx){var Nx=re(),zo=Xt(),Rx={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:zo.stringifyNumber},Lx={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():zo.stringifyNumber(e)}},Px={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Nx.Scalar(parseFloat(e.replace(/_/g,""))),n=e.indexOf(".");if(n!==-1){let i=e.substring(n+1).replace(/_/g,"");if(i[i.length-1]==="0")t.minFractionDigits=i.length}return t},stringify:zo.stringifyNumber};Fx.float=Px;Fx.floatExp=Lx;Fx.floatNaN=Rx});var Bd=M(function(Hx){var Gd=Xt(),Kn=(e)=>typeof e==="bigint"||Number.isInteger(e);function kr(e,t,n,{intAsBigInt:i}){let r=e[0];if(r==="-"||r==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),i){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return r==="-"?BigInt(-1)*o:o}let s=parseInt(e,n);return r==="-"?-1*s:s}function Xo(e,t,n){let{value:i}=e;if(Kn(i)){let r=i.toString(t);return i<0?"-"+n+r.substr(1):n+r}return Gd.stringifyNumber(e)}var jx={identify:Kn,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>kr(e,2,2,n),stringify:(e)=>Xo(e,2,"0b")},Gx={identify:Kn,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>kr(e,1,8,n),stringify:(e)=>Xo(e,8,"0")},Bx={identify:Kn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>kr(e,0,10,n),stringify:Gd.stringifyNumber},Vx={identify:Kn,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>kr(e,2,16,n),stringify:(e)=>Xo(e,16,"0x")};Hx.int=Bx;Hx.intBin=jx;Hx.intHex=Vx;Hx.intOct=Gx});var Qo=M(function(Xx){var Mr=V(),Tr=at(),Ir=ct();class Ot extends Ir.YAMLMap{constructor(e){super(e);this.tag=Ot.tag}add(e){let t;if(Mr.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Tr.Pair(e.key,null);else t=new Tr.Pair(e,null);if(!Ir.findPair(this.items,t.key))this.items.push(t)}get(e,t){let n=Ir.findPair(this.items,e);return!t&&Mr.isPair(n)?Mr.isScalar(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=Ir.findPair(this.items,e);if(n&&!t)this.items.splice(this.items.indexOf(n),1);else if(!n&&t)this.items.push(new Tr.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);else throw Error("Set items must all have null values")}static from(e,t,n){let{replacer:i}=n,r=new this(e);if(t&&Symbol.iterator in Object(t))for(let s of t){if(typeof i==="function")s=i.call(t,s,s);r.items.push(Tr.createPair(s,null,n))}return r}}Ot.tag="tag:yaml.org,2002:set";var zx={collection:"map",identify:(e)=>e instanceof Set,nodeClass:Ot,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>Ot.from(e,t,n),resolve(e,t){if(Mr.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new Ot,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};Xx.YAMLSet=Ot;Xx.set=zx});var ea=M(function(iv){var ev=Xt();function Zo(e,t){let n=e[0],i=n==="-"||n==="+"?e.substring(1):e,r=(o)=>t?BigInt(o):Number(o),s=i.replace(/_/g,"").split(":").reduce((o,a)=>o*r(60)+r(a),r(0));return n==="-"?r(-1)*s:s}function Vd(e){let{value:t}=e,n=(o)=>o;if(typeof t==="bigint")n=(o)=>BigInt(o);else if(isNaN(t)||!isFinite(t))return ev.stringifyNumber(e);let i="";if(t<0)i="-",t*=n(-1);let r=n(60),s=[t%r];if(t<60)s.unshift(0);else if(t=(t-s[0])/r,s.unshift(t%r),t>=60)t=(t-s[0])/r,s.unshift(t);return i+s.map((o)=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var tv={identify:(e)=>typeof e==="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>Zo(e,n),stringify:Vd},nv={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>Zo(e,!1),stringify:Vd},Hd={identify:(e)=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Hd.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,i,r,s,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(n,i-1,r,s||0,o||0,a||0,l),p=t[8];if(p&&p!=="Z"){let u=Zo(p,!1);if(Math.abs(u)<30)u*=60;c-=60000*u}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};iv.floatTime=nv;iv.intTime=tv;iv.timestamp=Hd});var Wd=M(function(yv){var av=Yt(),lv=Sr(),cv=zt(),uv=Bn(),fv=Ko(),Kd=Ud(),ta=jd(),Or=Bd(),dv=mr(),pv=Yo(),mv=Ar(),hv=Qo(),na=ea(),gv=[av.map,cv.seq,uv.string,lv.nullTag,Kd.trueTag,Kd.falseTag,Or.intBin,Or.intOct,Or.int,Or.intHex,ta.floatNaN,ta.floatExp,ta.float,fv.binary,dv.merge,pv.omap,mv.pairs,hv.set,na.intTime,na.floatTime,na.timestamp];yv.schema=gv});var ip=M(function(Av){var Xd=Yt(),wv=Sr(),Qd=zt(),xv=Bn(),vv=qo(),ia=Uo(),ra=Go(),Sv=Id(),$v=Od(),Zd=Ko(),Wn=mr(),ep=Yo(),tp=Ar(),Jd=Wd(),np=Qo(),Cr=ea(),Yd=new Map([["core",Sv.schema],["failsafe",[Xd.map,Qd.seq,xv.string]],["json",$v.schema],["yaml11",Jd.schema],["yaml-1.1",Jd.schema]]),zd={binary:Zd.binary,bool:vv.boolTag,float:ia.float,floatExp:ia.floatExp,floatNaN:ia.floatNaN,floatTime:Cr.floatTime,int:ra.int,intHex:ra.intHex,intOct:ra.intOct,intTime:Cr.intTime,map:Xd.map,merge:Wn.merge,null:wv.nullTag,omap:ep.omap,pairs:tp.pairs,seq:Qd.seq,set:np.set,timestamp:Cr.timestamp},_v={"tag:yaml.org,2002:binary":Zd.binary,"tag:yaml.org,2002:merge":Wn.merge,"tag:yaml.org,2002:omap":ep.omap,"tag:yaml.org,2002:pairs":tp.pairs,"tag:yaml.org,2002:set":np.set,"tag:yaml.org,2002:timestamp":Cr.timestamp};function Ev(e,t,n){let i=Yd.get(t);if(i&&!e)return n&&!i.includes(Wn.merge)?i.concat(Wn.merge):i.slice();let r=i;if(!r)if(Array.isArray(e))r=[];else{let s=Array.from(Yd.keys()).filter((o)=>o!=="yaml11").map((o)=>JSON.stringify(o)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${s} or define customTags array`)}if(Array.isArray(e))for(let s of e)r=r.concat(s);else if(typeof e==="function")r=e(r.slice());if(n)r=r.concat(Wn.merge);return r.reduce((s,o)=>{let a=typeof o==="string"?zd[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(zd).map((p)=>JSON.stringify(p)).join(", ");throw Error(`Unknown custom tag ${l}; use one of ${c}`)}if(!s.includes(a))s.push(a);return s},[])}Av.coreKnownTags=_v;Av.getTags=Ev});var aa=M(function(Nv){var sa=V(),Iv=Yt(),Mv=zt(),Ov=Bn(),Nr=ip(),Cv=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class oa{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:i,schema:r,sortMapEntries:s,toStringDefaults:o}){this.compat=Array.isArray(e)?Nr.getTags(e,"compat"):e?Nr.getTags(null,e):null,this.name=typeof r==="string"&&r||"core",this.knownTags=i?Nr.coreKnownTags:{},this.tags=Nr.getTags(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,sa.MAP,{value:Iv.map}),Object.defineProperty(this,sa.SCALAR,{value:Ov.string}),Object.defineProperty(this,sa.SEQ,{value:Mv.seq}),this.sortMapEntries=typeof s==="function"?s:s===!0?Cv:null}clone(){let e=Object.create(oa.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}Nv.Schema=oa});var rp=M(function(Fv){var Lv=V(),la=Un(),Jn=Fn();function Pv(e,t){let n=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);if(l)n.push(l),i=!0;else if(e.directives.docStart)i=!0}if(i)n.push("---");let r=la.createStringifyContext(e,t),{commentString:s}=r.options;if(e.commentBefore){if(n.length!==1)n.unshift("");let l=s(e.commentBefore);n.unshift(Jn.indentComment(l,""))}let o=!1,a=null;if(e.contents){if(Lv.isNode(e.contents)){if(e.contents.spaceBefore&&i)n.push("");if(e.contents.commentBefore){let p=s(e.contents.commentBefore);n.push(Jn.indentComment(p,""))}r.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=la.stringify(e.contents,r,()=>a=null,l);if(a)c+=Jn.lineComment(c,"",s(a));if((c[0]==="|"||c[0]===">")&&n[n.length-1]==="---")n[n.length-1]=`--- ${c}`;else n.push(c)}else n.push(la.stringify(e.contents,r));if(e.directives?.docEnd)if(e.comment){let l=s(e.comment);if(l.includes(`
567
567
  `))n.push("..."),n.push(Jn.indentComment(l,""));else n.push(`... ${l}`)}else n.push("...");else{let l=e.comment;if(l&&o)l=l.replace(/^\n+/,"");if(l){if((!o||a)&&n[n.length-1]!=="")n.push("");n.push(Jn.indentComment(s(l),""))}}return n.join(`
568
568
  `)+`
569
- `}Fv.stringifyDocument=Lv});var Yn=M(function(Kv){var Dv=Pn(),Qt=ar(),Se=V(),Uv=at(),jv=rt(),Gv=aa(),Bv=rp(),ca=rr(),Vv=To(),Hv=Ln(),ua=ko();class fa{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Se.NODE_TYPE,{value:Se.DOC});let i=null;if(typeof t==="function"||Array.isArray(t))i=t;else if(n===void 0&&t)n=t,t=void 0;let r=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},n);this.options=r;let{version:s}=r;if(n?._directives){if(this.directives=n._directives.atDocument(),this.directives.yaml.explicit)s=this.directives.yaml.version}else this.directives=new ua.Directives({version:s});this.setSchema(s,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let e=Object.create(fa.prototype,{[Se.NODE_TYPE]:{value:Se.DOC}});if(e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives)e.directives=this.directives.clone();if(e.schema=this.schema.clone(),e.contents=Se.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(Zt(this.contents))this.contents.add(e)}addIn(e,t){if(Zt(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=ca.anchorNames(this);e.anchor=!t||n.has(t)?ca.findNewAnchor(t||"a",n):t}return new Dv.Alias(e.anchor)}createNode(e,t,n){let i=void 0;if(typeof t==="function")e=t.call({"":e},"",e),i=t;else if(Array.isArray(t)){let d=(v)=>typeof v==="number"||v instanceof String||v instanceof Number,m=t.filter(d).map(String);if(m.length>0)t=t.concat(m);i=t}else if(n===void 0&&t)n=t,t=void 0;let{aliasDuplicateObjects:r,anchorPrefix:s,flow:o,keepUndefined:a,onTagObj:l,tag:c}=n??{},{onAnchor:p,setAnchors:u,sourceObjects:f}=ca.createNodeAnchors(this,s||"a"),g={aliasDuplicateObjects:r??!0,keepUndefined:a??!1,onAnchor:p,onTagObj:l,replacer:i,schema:this.schema,sourceObjects:f},h=Hv.createNode(e,c,g);if(o&&Se.isCollection(h))h.flow=!0;return u(),h}createPair(e,t,n={}){let i=this.createNode(e,null,n),r=this.createNode(t,null,n);return new Uv.Pair(i,r)}delete(e){return Zt(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(Qt.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return Zt(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Se.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(Qt.isEmptyPath(e))return!t&&Se.isScalar(this.contents)?this.contents.value:this.contents;return Se.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Se.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(Qt.isEmptyPath(e))return this.contents!==void 0;return Se.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=Qt.collectionFromPath(this.schema,[e],t);else if(Zt(this.contents))this.contents.set(e,t)}setIn(e,t){if(Qt.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=Qt.collectionFromPath(this.schema,Array.from(e),t);else if(Zt(this.contents))this.contents.setIn(e,t)}setSchema(e,t={}){if(typeof e==="number")e=String(e);let n;switch(e){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new ua.Directives({version:"1.1"});n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=e;else this.directives=new ua.Directives({version:e});n={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;n=null;break;default:{let i=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new Gv.Schema(Object.assign(n,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:i,onAnchor:r,reviver:s}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof i==="number"?i:100},a=jv.toJS(this.contents,t??"",o);if(typeof r==="function")for(let{count:l,res:c}of o.anchors.values())r(c,l);return typeof s==="function"?Vv.applyReviver(s,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return Bv.stringifyDocument(this,e)}}function Zt(e){if(Se.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}Kv.Document=fa});var zn=M(function(Yv){class Rr extends Error{constructor(e,t,n,i){super();this.name=e,this.code=n,this.message=i,this.pos=t}}class sp extends Rr{constructor(e,t,n){super("YAMLParseError",e,t,n)}}class op extends Rr{constructor(e,t,n){super("YAMLWarning",e,t,n)}}var Jv=(e,t)=>(n)=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map((a)=>t.linePos(a));let{line:i,col:r}=n.linePos[0];n.message+=` at line ${i}, column ${r}`;let s=r-1,o=e.substring(t.lineStarts[i-1],t.lineStarts[i]).replace(/[\n\r]+$/,"");if(s>=60&&o.length>80){let a=Math.min(s-39,o.length-79);o="…"+o.substring(a),s-=a-1}if(o.length>80)o=o.substring(0,79)+"…";if(i>1&&/^ *$/.test(o.substring(0,s))){let a=e.substring(t.lineStarts[i-2],t.lineStarts[i-1]);if(a.length>80)a=a.substring(0,79)+`…
569
+ `}Fv.stringifyDocument=Pv});var Yn=M(function(Kv){var Dv=Ln(),Qt=ar(),Se=V(),Uv=at(),jv=rt(),Gv=aa(),Bv=rp(),ca=rr(),Vv=To(),Hv=Pn(),ua=ko();class fa{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Se.NODE_TYPE,{value:Se.DOC});let i=null;if(typeof t==="function"||Array.isArray(t))i=t;else if(n===void 0&&t)n=t,t=void 0;let r=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},n);this.options=r;let{version:s}=r;if(n?._directives){if(this.directives=n._directives.atDocument(),this.directives.yaml.explicit)s=this.directives.yaml.version}else this.directives=new ua.Directives({version:s});this.setSchema(s,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let e=Object.create(fa.prototype,{[Se.NODE_TYPE]:{value:Se.DOC}});if(e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives)e.directives=this.directives.clone();if(e.schema=this.schema.clone(),e.contents=Se.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(Zt(this.contents))this.contents.add(e)}addIn(e,t){if(Zt(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=ca.anchorNames(this);e.anchor=!t||n.has(t)?ca.findNewAnchor(t||"a",n):t}return new Dv.Alias(e.anchor)}createNode(e,t,n){let i=void 0;if(typeof t==="function")e=t.call({"":e},"",e),i=t;else if(Array.isArray(t)){let d=(v)=>typeof v==="number"||v instanceof String||v instanceof Number,m=t.filter(d).map(String);if(m.length>0)t=t.concat(m);i=t}else if(n===void 0&&t)n=t,t=void 0;let{aliasDuplicateObjects:r,anchorPrefix:s,flow:o,keepUndefined:a,onTagObj:l,tag:c}=n??{},{onAnchor:p,setAnchors:u,sourceObjects:f}=ca.createNodeAnchors(this,s||"a"),g={aliasDuplicateObjects:r??!0,keepUndefined:a??!1,onAnchor:p,onTagObj:l,replacer:i,schema:this.schema,sourceObjects:f},h=Hv.createNode(e,c,g);if(o&&Se.isCollection(h))h.flow=!0;return u(),h}createPair(e,t,n={}){let i=this.createNode(e,null,n),r=this.createNode(t,null,n);return new Uv.Pair(i,r)}delete(e){return Zt(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(Qt.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return Zt(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Se.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(Qt.isEmptyPath(e))return!t&&Se.isScalar(this.contents)?this.contents.value:this.contents;return Se.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Se.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(Qt.isEmptyPath(e))return this.contents!==void 0;return Se.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=Qt.collectionFromPath(this.schema,[e],t);else if(Zt(this.contents))this.contents.set(e,t)}setIn(e,t){if(Qt.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=Qt.collectionFromPath(this.schema,Array.from(e),t);else if(Zt(this.contents))this.contents.setIn(e,t)}setSchema(e,t={}){if(typeof e==="number")e=String(e);let n;switch(e){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new ua.Directives({version:"1.1"});n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=e;else this.directives=new ua.Directives({version:e});n={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;n=null;break;default:{let i=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new Gv.Schema(Object.assign(n,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:i,onAnchor:r,reviver:s}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof i==="number"?i:100},a=jv.toJS(this.contents,t??"",o);if(typeof r==="function")for(let{count:l,res:c}of o.anchors.values())r(c,l);return typeof s==="function"?Vv.applyReviver(s,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return Bv.stringifyDocument(this,e)}}function Zt(e){if(Se.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}Kv.Document=fa});var zn=M(function(Yv){class Rr extends Error{constructor(e,t,n,i){super();this.name=e,this.code=n,this.message=i,this.pos=t}}class sp extends Rr{constructor(e,t,n){super("YAMLParseError",e,t,n)}}class op extends Rr{constructor(e,t,n){super("YAMLWarning",e,t,n)}}var Jv=(e,t)=>(n)=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map((a)=>t.linePos(a));let{line:i,col:r}=n.linePos[0];n.message+=` at line ${i}, column ${r}`;let s=r-1,o=e.substring(t.lineStarts[i-1],t.lineStarts[i]).replace(/[\n\r]+$/,"");if(s>=60&&o.length>80){let a=Math.min(s-39,o.length-79);o="…"+o.substring(a),s-=a-1}if(o.length>80)o=o.substring(0,79)+"…";if(i>1&&/^ *$/.test(o.substring(0,s))){let a=e.substring(t.lineStarts[i-2],t.lineStarts[i-1]);if(a.length>80)a=a.substring(0,79)+`…
570
570
  `;o=a+o}if(/[^ ]/.test(o)){let a=1,l=n.linePos[1];if(l?.line===i&&l.col>r)a=Math.max(1,Math.min(l.col-r,80-s));let c=" ".repeat(s)+"^".repeat(a);n.message+=`:
571
571
 
572
572
  ${o}
573
573
  ${c}
574
- `}};Yv.YAMLError=Rr;Yv.YAMLParseError=sp;Yv.YAMLWarning=op;Yv.prettifyError=Jv});var Xn=M(function(tS){function eS(e,{flow:t,indicator:n,next:i,offset:r,onError:s,parentIndent:o,startOnNewline:a}){let l=!1,c=a,p=a,u="",f="",g=!1,h=!1,d=null,m=null,v=null,w=null,x=null,E=null,A=null;for(let k of e){if(h){if(k.type!=="space"&&k.type!=="newline"&&k.type!=="comma")s(k.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");h=!1}if(d){if(c&&k.type!=="comment"&&k.type!=="newline")s(d,"TAB_AS_INDENT","Tabs are not allowed as indentation");d=null}switch(k.type){case"space":if(!t&&(n!=="doc-start"||i?.type!=="flow-collection")&&k.source.includes("\t"))d=k;p=!0;break;case"comment":{if(!p)s(k,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let R=k.source.substring(1)||" ";if(!u)u=R;else u+=f+R;f="",c=!1;break}case"newline":if(c){if(u)u+=k.source;else if(!E||n!=="seq-item-ind")l=!0}else f+=k.source;if(c=!0,g=!0,m||v)w=k;p=!0;break;case"anchor":if(m)s(k,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(k.source.endsWith(":"))s(k.offset+k.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);m=k,A??(A=k.offset),c=!1,p=!1,h=!0;break;case"tag":{if(v)s(k,"MULTIPLE_TAGS","A node can have at most one tag");v=k,A??(A=k.offset),c=!1,p=!1,h=!0;break}case n:if(m||v)s(k,"BAD_PROP_ORDER",`Anchors and tags must be after the ${k.source} indicator`);if(E)s(k,"UNEXPECTED_TOKEN",`Unexpected ${k.source} in ${t??"collection"}`);E=k,c=n==="seq-item-ind"||n==="explicit-key-ind",p=!1;break;case"comma":if(t){if(x)s(k,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);x=k,c=!1,p=!1;break}default:s(k,"UNEXPECTED_TOKEN",`Unexpected ${k.type} token`),c=!1,p=!1}}let _=e[e.length-1],S=_?_.offset+_.source.length:r;if(h&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!==""))s(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(d&&(c&&d.indent<=o||i?.type==="block-map"||i?.type==="block-seq"))s(d,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:x,found:E,spaceBefore:l,comment:u,hasNewline:g,anchor:m,tag:v,newlineAfterProp:w,end:S,start:A??S}}tS.resolveProps=eS});var Pr=M(function(iS){function da(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
575
- `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let n of t.start)if(n.type==="newline")return!0;if(t.sep){for(let n of t.sep)if(n.type==="newline")return!0}if(da(t.key)||da(t.value))return!0}return!1;default:return!0}}iS.containsNewline=da});var pa=M(function(aS){var sS=Pr();function oS(e,t,n){if(t?.type==="flow-collection"){let i=t.end[0];if(i.indent===e&&(i.source==="]"||i.source==="}")&&sS.containsNewline(t))n(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}aS.flowIndentCheck=oS});var ma=M(function(uS){var ap=V();function cS(e,t,n){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let r=typeof i==="function"?i:(s,o)=>s===o||ap.isScalar(s)&&ap.isScalar(o)&&s.value===o.value;return t.some((s)=>r(s.key,n))}uS.mapIncludes=cS});var dp=M(function(gS){var lp=at(),dS=ct(),cp=Xn(),pS=Pr(),up=pa(),mS=ma(),fp="All mapping items must start at the same column";function hS({composeNode:e,composeEmptyNode:t},n,i,r,s){let a=new(s?.nodeClass??dS.YAMLMap)(n.schema);if(n.atRoot)n.atRoot=!1;let l=i.offset,c=null;for(let p of i.items){let{start:u,key:f,sep:g,value:h}=p,d=cp.resolveProps(u,{indicator:"explicit-key-ind",next:f??g?.[0],offset:l,onError:r,parentIndent:i.indent,startOnNewline:!0}),m=!d.found;if(m){if(f){if(f.type==="block-seq")r(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in f&&f.indent!==i.indent)r(l,"BAD_INDENT",fp)}if(!d.anchor&&!d.tag&&!g){if(c=d.end,d.comment)if(a.comment)a.comment+=`
574
+ `}};Yv.YAMLError=Rr;Yv.YAMLParseError=sp;Yv.YAMLWarning=op;Yv.prettifyError=Jv});var Xn=M(function(tS){function eS(e,{flow:t,indicator:n,next:i,offset:r,onError:s,parentIndent:o,startOnNewline:a}){let l=!1,c=a,p=a,u="",f="",g=!1,h=!1,d=null,m=null,v=null,w=null,x=null,E=null,A=null;for(let k of e){if(h){if(k.type!=="space"&&k.type!=="newline"&&k.type!=="comma")s(k.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");h=!1}if(d){if(c&&k.type!=="comment"&&k.type!=="newline")s(d,"TAB_AS_INDENT","Tabs are not allowed as indentation");d=null}switch(k.type){case"space":if(!t&&(n!=="doc-start"||i?.type!=="flow-collection")&&k.source.includes("\t"))d=k;p=!0;break;case"comment":{if(!p)s(k,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let R=k.source.substring(1)||" ";if(!u)u=R;else u+=f+R;f="",c=!1;break}case"newline":if(c){if(u)u+=k.source;else if(!E||n!=="seq-item-ind")l=!0}else f+=k.source;if(c=!0,g=!0,m||v)w=k;p=!0;break;case"anchor":if(m)s(k,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(k.source.endsWith(":"))s(k.offset+k.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);m=k,A??(A=k.offset),c=!1,p=!1,h=!0;break;case"tag":{if(v)s(k,"MULTIPLE_TAGS","A node can have at most one tag");v=k,A??(A=k.offset),c=!1,p=!1,h=!0;break}case n:if(m||v)s(k,"BAD_PROP_ORDER",`Anchors and tags must be after the ${k.source} indicator`);if(E)s(k,"UNEXPECTED_TOKEN",`Unexpected ${k.source} in ${t??"collection"}`);E=k,c=n==="seq-item-ind"||n==="explicit-key-ind",p=!1;break;case"comma":if(t){if(x)s(k,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);x=k,c=!1,p=!1;break}default:s(k,"UNEXPECTED_TOKEN",`Unexpected ${k.type} token`),c=!1,p=!1}}let _=e[e.length-1],S=_?_.offset+_.source.length:r;if(h&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!==""))s(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(d&&(c&&d.indent<=o||i?.type==="block-map"||i?.type==="block-seq"))s(d,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:x,found:E,spaceBefore:l,comment:u,hasNewline:g,anchor:m,tag:v,newlineAfterProp:w,end:S,start:A??S}}tS.resolveProps=eS});var Lr=M(function(iS){function da(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
575
+ `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let n of t.start)if(n.type==="newline")return!0;if(t.sep){for(let n of t.sep)if(n.type==="newline")return!0}if(da(t.key)||da(t.value))return!0}return!1;default:return!0}}iS.containsNewline=da});var pa=M(function(aS){var sS=Lr();function oS(e,t,n){if(t?.type==="flow-collection"){let i=t.end[0];if(i.indent===e&&(i.source==="]"||i.source==="}")&&sS.containsNewline(t))n(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}aS.flowIndentCheck=oS});var ma=M(function(uS){var ap=V();function cS(e,t,n){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let r=typeof i==="function"?i:(s,o)=>s===o||ap.isScalar(s)&&ap.isScalar(o)&&s.value===o.value;return t.some((s)=>r(s.key,n))}uS.mapIncludes=cS});var dp=M(function(gS){var lp=at(),dS=ct(),cp=Xn(),pS=Lr(),up=pa(),mS=ma(),fp="All mapping items must start at the same column";function hS({composeNode:e,composeEmptyNode:t},n,i,r,s){let a=new(s?.nodeClass??dS.YAMLMap)(n.schema);if(n.atRoot)n.atRoot=!1;let l=i.offset,c=null;for(let p of i.items){let{start:u,key:f,sep:g,value:h}=p,d=cp.resolveProps(u,{indicator:"explicit-key-ind",next:f??g?.[0],offset:l,onError:r,parentIndent:i.indent,startOnNewline:!0}),m=!d.found;if(m){if(f){if(f.type==="block-seq")r(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in f&&f.indent!==i.indent)r(l,"BAD_INDENT",fp)}if(!d.anchor&&!d.tag&&!g){if(c=d.end,d.comment)if(a.comment)a.comment+=`
576
576
  `+d.comment;else a.comment=d.comment;continue}if(d.newlineAfterProp||pS.containsNewline(f))r(f??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(d.found?.indent!==i.indent)r(l,"BAD_INDENT",fp);n.atKey=!0;let v=d.end,w=f?e(n,f,d,r):t(n,v,u,null,d,r);if(n.schema.compat)up.flowIndentCheck(i.indent,f,r);if(n.atKey=!1,mS.mapIncludes(n,a.items,w))r(v,"DUPLICATE_KEY","Map keys must be unique");let x=cp.resolveProps(g??[],{indicator:"map-value-ind",next:h,offset:w.range[2],onError:r,parentIndent:i.indent,startOnNewline:!f||f.type==="block-scalar"});if(l=x.end,x.found){if(m){if(h?.type==="block-map"&&!x.hasNewline)r(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(n.options.strict&&d.start<x.found.offset-1024)r(w.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let E=h?e(n,h,x,r):t(n,l,g,null,x,r);if(n.schema.compat)up.flowIndentCheck(i.indent,h,r);l=E.range[2];let A=new lp.Pair(w,E);if(n.options.keepSourceTokens)A.srcToken=p;a.items.push(A)}else{if(m)r(w.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(x.comment)if(w.comment)w.comment+=`
577
- `+x.comment;else w.comment=x.comment;let E=new lp.Pair(w);if(n.options.keepSourceTokens)E.srcToken=p;a.items.push(E)}}if(c&&c<l)r(c,"IMPOSSIBLE","Map comment with trailing content");return a.range=[i.offset,l,c??l],a}gS.resolveBlockMap=hS});var pp=M(function(SS){var bS=ut(),wS=Xn(),xS=pa();function vS({composeNode:e,composeEmptyNode:t},n,i,r,s){let a=new(s?.nodeClass??bS.YAMLSeq)(n.schema);if(n.atRoot)n.atRoot=!1;if(n.atKey)n.atKey=!1;let l=i.offset,c=null;for(let{start:p,value:u}of i.items){let f=wS.resolveProps(p,{indicator:"seq-item-ind",next:u,offset:l,onError:r,parentIndent:i.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||u)if(u?.type==="block-seq")r(f.end,"BAD_INDENT","All sequence items must start at the same column");else r(l,"MISSING_CHAR","Sequence item without - indicator");else{if(c=f.end,f.comment)a.comment=f.comment;continue}let g=u?e(n,u,f,r):t(n,f.end,p,null,f,r);if(n.schema.compat)xS.flowIndentCheck(i.indent,u,r);l=g.range[2],a.items.push(g)}return a.range=[i.offset,l,c??l],a}SS.resolveBlockSeq=vS});var en=M(function(ES){function _S(e,t,n,i){let r="";if(e){let s=!1,o="";for(let a of e){let{source:l,type:c}=a;switch(c){case"space":s=!0;break;case"comment":{if(n&&!s)i(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let p=l.substring(1)||" ";if(!r)r=p;else r+=o+p;o="";break}case"newline":if(r)o+=l;s=!0;break;default:i(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}t+=l.length}}return{comment:r,offset:t}}ES.resolveEnd=_S});var gp=M(function(RS){var kS=V(),TS=at(),mp=ct(),IS=ut(),MS=en(),hp=Xn(),OS=Pr(),CS=ma(),ha="Block collections are not allowed within flow collections",ga=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function NS({composeNode:e,composeEmptyNode:t},n,i,r,s){let o=i.start.source==="{",a=o?"flow map":"flow sequence",c=new(s?.nodeClass??(o?mp.YAMLMap:IS.YAMLSeq))(n.schema);c.flow=!0;let p=n.atRoot;if(p)n.atRoot=!1;if(n.atKey)n.atKey=!1;let u=i.offset+i.start.source.length;for(let m=0;m<i.items.length;++m){let v=i.items[m],{start:w,key:x,sep:E,value:A}=v,_=hp.resolveProps(w,{flow:a,indicator:"explicit-key-ind",next:x??E?.[0],offset:u,onError:r,parentIndent:i.indent,startOnNewline:!1});if(!_.found){if(!_.anchor&&!_.tag&&!E&&!A){if(m===0&&_.comma)r(_.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(m<i.items.length-1)r(_.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(_.comment)if(c.comment)c.comment+=`
577
+ `+x.comment;else w.comment=x.comment;let E=new lp.Pair(w);if(n.options.keepSourceTokens)E.srcToken=p;a.items.push(E)}}if(c&&c<l)r(c,"IMPOSSIBLE","Map comment with trailing content");return a.range=[i.offset,l,c??l],a}gS.resolveBlockMap=hS});var pp=M(function(SS){var bS=ut(),wS=Xn(),xS=pa();function vS({composeNode:e,composeEmptyNode:t},n,i,r,s){let a=new(s?.nodeClass??bS.YAMLSeq)(n.schema);if(n.atRoot)n.atRoot=!1;if(n.atKey)n.atKey=!1;let l=i.offset,c=null;for(let{start:p,value:u}of i.items){let f=wS.resolveProps(p,{indicator:"seq-item-ind",next:u,offset:l,onError:r,parentIndent:i.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||u)if(u?.type==="block-seq")r(f.end,"BAD_INDENT","All sequence items must start at the same column");else r(l,"MISSING_CHAR","Sequence item without - indicator");else{if(c=f.end,f.comment)a.comment=f.comment;continue}let g=u?e(n,u,f,r):t(n,f.end,p,null,f,r);if(n.schema.compat)xS.flowIndentCheck(i.indent,u,r);l=g.range[2],a.items.push(g)}return a.range=[i.offset,l,c??l],a}SS.resolveBlockSeq=vS});var en=M(function(ES){function _S(e,t,n,i){let r="";if(e){let s=!1,o="";for(let a of e){let{source:l,type:c}=a;switch(c){case"space":s=!0;break;case"comment":{if(n&&!s)i(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let p=l.substring(1)||" ";if(!r)r=p;else r+=o+p;o="";break}case"newline":if(r)o+=l;s=!0;break;default:i(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}t+=l.length}}return{comment:r,offset:t}}ES.resolveEnd=_S});var gp=M(function(RS){var kS=V(),TS=at(),mp=ct(),IS=ut(),MS=en(),hp=Xn(),OS=Lr(),CS=ma(),ha="Block collections are not allowed within flow collections",ga=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function NS({composeNode:e,composeEmptyNode:t},n,i,r,s){let o=i.start.source==="{",a=o?"flow map":"flow sequence",c=new(s?.nodeClass??(o?mp.YAMLMap:IS.YAMLSeq))(n.schema);c.flow=!0;let p=n.atRoot;if(p)n.atRoot=!1;if(n.atKey)n.atKey=!1;let u=i.offset+i.start.source.length;for(let m=0;m<i.items.length;++m){let v=i.items[m],{start:w,key:x,sep:E,value:A}=v,_=hp.resolveProps(w,{flow:a,indicator:"explicit-key-ind",next:x??E?.[0],offset:u,onError:r,parentIndent:i.indent,startOnNewline:!1});if(!_.found){if(!_.anchor&&!_.tag&&!E&&!A){if(m===0&&_.comma)r(_.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(m<i.items.length-1)r(_.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(_.comment)if(c.comment)c.comment+=`
578
578
  `+_.comment;else c.comment=_.comment;u=_.end;continue}if(!o&&n.options.strict&&OS.containsNewline(x))r(x,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0){if(_.comma)r(_.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`)}else{if(!_.comma)r(_.start,"MISSING_CHAR",`Missing , between ${a} items`);if(_.comment){let S="";e:for(let k of w)switch(k.type){case"comma":case"space":break;case"comment":S=k.source.substring(1);break e;default:break e}if(S){let k=c.items[c.items.length-1];if(kS.isPair(k))k=k.value??k.key;if(k.comment)k.comment+=`
579
- `+S;else k.comment=S;_.comment=_.comment.substring(S.length+1)}}}if(!o&&!E&&!_.found){let S=A?e(n,A,_,r):t(n,_.end,E,null,_,r);if(c.items.push(S),u=S.range[2],ga(A))r(S.range,"BLOCK_IN_FLOW",ha)}else{n.atKey=!0;let S=_.end,k=x?e(n,x,_,r):t(n,S,w,null,_,r);if(ga(x))r(k.range,"BLOCK_IN_FLOW",ha);n.atKey=!1;let R=hp.resolveProps(E??[],{flow:a,indicator:"map-value-ind",next:A,offset:k.range[2],onError:r,parentIndent:i.indent,startOnNewline:!1});if(R.found){if(!o&&!_.found&&n.options.strict){if(E)for(let L of E){if(L===R.found)break;if(L.type==="newline"){r(L,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(_.start<R.found.offset-1024)r(R.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(A)if("source"in A&&A.source?.[0]===":")r(A,"MISSING_CHAR",`Missing space after : in ${a}`);else r(R.start,"MISSING_CHAR",`Missing , or : between ${a} items`);let U=A?e(n,A,R,r):R.found?t(n,R.end,E,null,R,r):null;if(U){if(ga(A))r(U.range,"BLOCK_IN_FLOW",ha)}else if(R.comment)if(k.comment)k.comment+=`
580
- `+R.comment;else k.comment=R.comment;let q=new TS.Pair(k,U);if(n.options.keepSourceTokens)q.srcToken=v;if(o){let L=c;if(CS.mapIncludes(n,L.items,k))r(S,"DUPLICATE_KEY","Map keys must be unique");L.items.push(q)}else{let L=new mp.YAMLMap(n.schema);L.flow=!0,L.items.push(q);let C=(U??k).range;L.range=[k.range[0],C[1],C[2]],c.items.push(L)}u=U?U.range[2]:R.end}}let f=o?"}":"]",[g,...h]=i.end,d=u;if(g?.source===f)d=g.offset+g.source.length;else{let m=a[0].toUpperCase()+a.substring(1),v=p?`${m} must end with a ${f}`:`${m} in block collection must be sufficiently indented and end with a ${f}`;if(r(u,p?"MISSING_CHAR":"BAD_INDENT",v),g&&g.source.length!==1)h.unshift(g)}if(h.length>0){let m=MS.resolveEnd(h,d,n.options.strict,r);if(m.comment)if(c.comment)c.comment+=`
581
- `+m.comment;else c.comment=m.comment;c.range=[i.offset,d,m.offset]}else c.range=[i.offset,d,d];return c}RS.resolveFlowCollection=NS});var yp=M(function(VS){var LS=V(),FS=re(),qS=ct(),DS=ut(),US=dp(),jS=pp(),GS=gp();function ya(e,t,n,i,r,s){let o=n.type==="block-map"?US.resolveBlockMap(e,t,n,i,s):n.type==="block-seq"?jS.resolveBlockSeq(e,t,n,i,s):GS.resolveFlowCollection(e,t,n,i,s),a=o.constructor;if(r==="!"||r===a.tagName)return o.tag=a.tagName,o;if(r)o.tag=r;return o}function BS(e,t,n,i,r){let s=i.tag,o=!s?null:t.directives.tagName(s.source,(f)=>r(s,"TAG_RESOLVE_FAILED",f));if(n.type==="block-seq"){let{anchor:f,newlineAfterProp:g}=i,h=f&&s?f.offset>s.offset?f:s:f??s;if(h&&(!g||g.offset<h.offset))r(h,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!s||!o||o==="!"||o===qS.YAMLMap.tagName&&a==="map"||o===DS.YAMLSeq.tagName&&a==="seq")return ya(e,t,n,r,o);let l=t.schema.tags.find((f)=>f.tag===o&&f.collection===a);if(!l){let f=t.schema.knownTags[o];if(f?.collection===a)t.schema.tags.push(Object.assign({},f,{default:!1})),l=f;else{if(f)r(s,"BAD_COLLECTION_TYPE",`${f.tag} used for ${a} collection, but expects ${f.collection??"scalar"}`,!0);else r(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0);return ya(e,t,n,r,o)}}let c=ya(e,t,n,r,o,l),p=l.resolve?.(c,(f)=>r(s,"TAG_RESOLVE_FAILED",f),t.options)??c,u=LS.isNode(p)?p:new FS.Scalar(p);if(u.range=c.range,u.tag=o,l?.format)u.format=l.format;return u}VS.composeCollection=BS});var wa=M(function(YS){var ba=re();function KS(e,t,n){let i=t.offset,r=WS(t,e.options.strict,n);if(!r)return{value:"",type:null,comment:"",range:[i,i,i]};let s=r.mode===">"?ba.Scalar.BLOCK_FOLDED:ba.Scalar.BLOCK_LITERAL,o=t.source?JS(t.source):[],a=o.length;for(let d=o.length-1;d>=0;--d){let m=o[d][1];if(m===""||m==="\r")a=d;else break}if(a===0){let d=r.chomp==="+"&&o.length>0?`
579
+ `+S;else k.comment=S;_.comment=_.comment.substring(S.length+1)}}}if(!o&&!E&&!_.found){let S=A?e(n,A,_,r):t(n,_.end,E,null,_,r);if(c.items.push(S),u=S.range[2],ga(A))r(S.range,"BLOCK_IN_FLOW",ha)}else{n.atKey=!0;let S=_.end,k=x?e(n,x,_,r):t(n,S,w,null,_,r);if(ga(x))r(k.range,"BLOCK_IN_FLOW",ha);n.atKey=!1;let R=hp.resolveProps(E??[],{flow:a,indicator:"map-value-ind",next:A,offset:k.range[2],onError:r,parentIndent:i.indent,startOnNewline:!1});if(R.found){if(!o&&!_.found&&n.options.strict){if(E)for(let P of E){if(P===R.found)break;if(P.type==="newline"){r(P,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(_.start<R.found.offset-1024)r(R.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(A)if("source"in A&&A.source?.[0]===":")r(A,"MISSING_CHAR",`Missing space after : in ${a}`);else r(R.start,"MISSING_CHAR",`Missing , or : between ${a} items`);let U=A?e(n,A,R,r):R.found?t(n,R.end,E,null,R,r):null;if(U){if(ga(A))r(U.range,"BLOCK_IN_FLOW",ha)}else if(R.comment)if(k.comment)k.comment+=`
580
+ `+R.comment;else k.comment=R.comment;let q=new TS.Pair(k,U);if(n.options.keepSourceTokens)q.srcToken=v;if(o){let P=c;if(CS.mapIncludes(n,P.items,k))r(S,"DUPLICATE_KEY","Map keys must be unique");P.items.push(q)}else{let P=new mp.YAMLMap(n.schema);P.flow=!0,P.items.push(q);let C=(U??k).range;P.range=[k.range[0],C[1],C[2]],c.items.push(P)}u=U?U.range[2]:R.end}}let f=o?"}":"]",[g,...h]=i.end,d=u;if(g?.source===f)d=g.offset+g.source.length;else{let m=a[0].toUpperCase()+a.substring(1),v=p?`${m} must end with a ${f}`:`${m} in block collection must be sufficiently indented and end with a ${f}`;if(r(u,p?"MISSING_CHAR":"BAD_INDENT",v),g&&g.source.length!==1)h.unshift(g)}if(h.length>0){let m=MS.resolveEnd(h,d,n.options.strict,r);if(m.comment)if(c.comment)c.comment+=`
581
+ `+m.comment;else c.comment=m.comment;c.range=[i.offset,d,m.offset]}else c.range=[i.offset,d,d];return c}RS.resolveFlowCollection=NS});var yp=M(function(VS){var PS=V(),FS=re(),qS=ct(),DS=ut(),US=dp(),jS=pp(),GS=gp();function ya(e,t,n,i,r,s){let o=n.type==="block-map"?US.resolveBlockMap(e,t,n,i,s):n.type==="block-seq"?jS.resolveBlockSeq(e,t,n,i,s):GS.resolveFlowCollection(e,t,n,i,s),a=o.constructor;if(r==="!"||r===a.tagName)return o.tag=a.tagName,o;if(r)o.tag=r;return o}function BS(e,t,n,i,r){let s=i.tag,o=!s?null:t.directives.tagName(s.source,(f)=>r(s,"TAG_RESOLVE_FAILED",f));if(n.type==="block-seq"){let{anchor:f,newlineAfterProp:g}=i,h=f&&s?f.offset>s.offset?f:s:f??s;if(h&&(!g||g.offset<h.offset))r(h,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!s||!o||o==="!"||o===qS.YAMLMap.tagName&&a==="map"||o===DS.YAMLSeq.tagName&&a==="seq")return ya(e,t,n,r,o);let l=t.schema.tags.find((f)=>f.tag===o&&f.collection===a);if(!l){let f=t.schema.knownTags[o];if(f?.collection===a)t.schema.tags.push(Object.assign({},f,{default:!1})),l=f;else{if(f)r(s,"BAD_COLLECTION_TYPE",`${f.tag} used for ${a} collection, but expects ${f.collection??"scalar"}`,!0);else r(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0);return ya(e,t,n,r,o)}}let c=ya(e,t,n,r,o,l),p=l.resolve?.(c,(f)=>r(s,"TAG_RESOLVE_FAILED",f),t.options)??c,u=PS.isNode(p)?p:new FS.Scalar(p);if(u.range=c.range,u.tag=o,l?.format)u.format=l.format;return u}VS.composeCollection=BS});var wa=M(function(YS){var ba=re();function KS(e,t,n){let i=t.offset,r=WS(t,e.options.strict,n);if(!r)return{value:"",type:null,comment:"",range:[i,i,i]};let s=r.mode===">"?ba.Scalar.BLOCK_FOLDED:ba.Scalar.BLOCK_LITERAL,o=t.source?JS(t.source):[],a=o.length;for(let d=o.length-1;d>=0;--d){let m=o[d][1];if(m===""||m==="\r")a=d;else break}if(a===0){let d=r.chomp==="+"&&o.length>0?`
582
582
  `.repeat(Math.max(1,o.length-1)):"",m=i+r.length;if(t.source)m+=t.source.length;return{value:d,type:s,comment:r.comment,range:[i,m,m]}}let l=t.indent+r.indent,c=t.offset+r.length,p=0;for(let d=0;d<a;++d){let[m,v]=o[d];if(v===""||v==="\r"){if(r.indent===0&&m.length>l)l=m.length}else{if(m.length<l)n(c+m.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(r.indent===0)l=m.length;if(p=d,l===0&&!e.atRoot)n(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=m.length+v.length+1}for(let d=o.length-1;d>=a;--d)if(o[d][0].length>l)a=d+1;let u="",f="",g=!1;for(let d=0;d<p;++d)u+=o[d][0].slice(l)+`
583
583
  `;for(let d=p;d<a;++d){let[m,v]=o[d];c+=m.length+v.length+1;let w=v[v.length-1]==="\r";if(w)v=v.slice(0,-1);if(v&&m.length<l){let E=`Block scalar lines must not be less indented than their ${r.indent?"explicit indentation indicator":"first line"}`;n(c-v.length-(w?2:1),"BAD_INDENT",E),m=""}if(s===ba.Scalar.BLOCK_LITERAL)u+=f+m.slice(l)+v,f=`
584
584
  `;else if(m.length>l||v[0]==="\t"){if(f===" ")f=`
@@ -608,14 +608,14 @@ ${c}
608
608
  `)break;if(i===`
609
609
  `)n+=`
610
610
  `;t+=1,i=e[t+1]}if(!n)n=" ";return{fold:n,offset:t}}var i$={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
611
- `,r:"\r",t:"\t",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function r$(e,t,n,i){let r=e.substr(t,n),o=r.length===n&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(o)}catch{let a=e.substr(t-2,n+2);return i(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}s$.resolveFlowScalar=QS});var xp=M(function(d$){var Ct=V(),wp=re(),a$=wa(),l$=va();function c$(e,t,n,i){let{value:r,type:s,comment:o,range:a}=t.type==="block-scalar"?a$.resolveBlockScalar(e,t,i):l$.resolveFlowScalar(t,e.options.strict,i),l=n?e.directives.tagName(n.source,(u)=>i(n,"TAG_RESOLVE_FAILED",u)):null,c;if(e.options.stringKeys&&e.atKey)c=e.schema[Ct.SCALAR];else if(l)c=u$(e.schema,r,l,n,i);else if(t.type==="scalar")c=f$(e,r,t,i);else c=e.schema[Ct.SCALAR];let p;try{let u=c.resolve(r,(f)=>i(n??t,"TAG_RESOLVE_FAILED",f),e.options);p=Ct.isScalar(u)?u:new wp.Scalar(u)}catch(u){let f=u instanceof Error?u.message:String(u);i(n??t,"TAG_RESOLVE_FAILED",f),p=new wp.Scalar(r)}if(p.range=a,p.source=r,s)p.type=s;if(l)p.tag=l;if(c.format)p.format=c.format;if(o)p.comment=o;return p}function u$(e,t,n,i,r){if(n==="!")return e[Ct.SCALAR];let s=[];for(let a of e.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)s.push(a);else return a;for(let a of s)if(a.test?.test(t))return a;let o=e.knownTags[n];if(o&&!o.collection)return e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o;return r(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),e[Ct.SCALAR]}function f$({atKey:e,directives:t,schema:n},i,r,s){let o=n.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(i))||n[Ct.SCALAR];if(n.compat){let a=n.compat.find((l)=>l.default&&l.test?.test(i))??n[Ct.SCALAR];if(o.tag!==a.tag){let l=t.tagString(o.tag),c=t.tagString(a.tag),p=`Value may be parsed as either ${l} or ${c}`;s(r,"TAG_RESOLVE_FAILED",p,!0)}}return o}d$.composeScalar=c$});var vp=M(function(h$){function m$(e,t,n){if(t){n??(n=t.length);for(let i=n-1;i>=0;--i){let r=t[i];switch(r.type){case"space":case"comment":case"newline":e-=r.source.length;continue}r=t[++i];while(r?.type==="space")e+=r.source.length,r=t[++i];break}}return e}h$.emptyScalarPosition=m$});var _p=M(function(_$){var y$=Pn(),b$=V(),w$=yp(),Sp=xp(),x$=en(),v$=vp(),S$={composeNode:$p,composeEmptyNode:Sa};function $p(e,t,n,i){let r=e.atKey,{spaceBefore:s,comment:o,anchor:a,tag:l}=n,c,p=!0;switch(t.type){case"alias":if(c=$$(e,t,i),a||l)i(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(c=Sp.composeScalar(e,t,l,i),a)c.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(c=w$.composeCollection(S$,e,t,n,i),a)c.anchor=a.source.substring(1)}catch(u){let f=u instanceof Error?u.message:String(u);i(t,"RESOURCE_EXHAUSTION",f)}break;default:{let u=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;i(t,"UNEXPECTED_TOKEN",u),p=!1}}if(c??(c=Sa(e,t.offset,void 0,null,n,i)),a&&c.anchor==="")i(a,"BAD_ALIAS","Anchor cannot be an empty string");if(r&&e.options.stringKeys&&(!b$.isScalar(c)||typeof c.value!=="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str"))i(l??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(s)c.spaceBefore=!0;if(o)if(t.type==="scalar"&&t.source==="")c.comment=o;else c.commentBefore=o;if(e.options.keepSourceTokens&&p)c.srcToken=t;return c}function Sa(e,t,n,i,{spaceBefore:r,comment:s,anchor:o,tag:a,end:l},c){let p={type:"scalar",offset:v$.emptyScalarPosition(t,n,i),indent:-1,source:""},u=Sp.composeScalar(e,p,a,c);if(o){if(u.anchor=o.source.substring(1),u.anchor==="")c(o,"BAD_ALIAS","Anchor cannot be an empty string")}if(r)u.spaceBefore=!0;if(s)u.comment=s,u.range[2]=l;return u}function $$({options:e},{offset:t,source:n,end:i},r){let s=new y$.Alias(n.substring(1));if(s.source==="")r(t,"BAD_ALIAS","Alias cannot be an empty string");if(s.source.endsWith(":"))r(t+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+n.length,a=x$.resolveEnd(i,o,e.strict,r);if(s.range=[t,o,a.offset],a.comment)s.comment=a.comment;return s}_$.composeEmptyNode=Sa;_$.composeNode=$p});var Ap=M(function(O$){var k$=Yn(),Ep=_p(),T$=en(),I$=Xn();function M$(e,t,{offset:n,start:i,value:r,end:s},o){let a=Object.assign({_directives:t},e),l=new k$.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},p=I$.resolveProps(i,{indicator:"doc-start",next:r??s?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});if(p.found){if(l.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!p.hasNewline)o(p.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}l.contents=r?Ep.composeNode(c,r,p,o):Ep.composeEmptyNode(c,p.end,i,null,p,o);let u=l.contents.range[2],f=T$.resolveEnd(s,u,!1,o);if(f.comment)l.comment=f.comment;return l.range=[n,u,f.offset],l}O$.composeDoc=M$});var $a=M(function(q$){var N$=an("process"),R$=ko(),P$=Yn(),Qn=zn(),kp=V(),L$=Ap(),F$=en();function Zn(e){if(typeof e==="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==="string"?n.length:1)]}function Tp(e){let t="",n=!1,i=!1;for(let r=0;r<e.length;++r){let s=e[r];switch(s[0]){case"#":t+=(t===""?"":i?`
611
+ `,r:"\r",t:"\t",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function r$(e,t,n,i){let r=e.substr(t,n),o=r.length===n&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(o)}catch{let a=e.substr(t-2,n+2);return i(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}s$.resolveFlowScalar=QS});var xp=M(function(d$){var Ct=V(),wp=re(),a$=wa(),l$=va();function c$(e,t,n,i){let{value:r,type:s,comment:o,range:a}=t.type==="block-scalar"?a$.resolveBlockScalar(e,t,i):l$.resolveFlowScalar(t,e.options.strict,i),l=n?e.directives.tagName(n.source,(u)=>i(n,"TAG_RESOLVE_FAILED",u)):null,c;if(e.options.stringKeys&&e.atKey)c=e.schema[Ct.SCALAR];else if(l)c=u$(e.schema,r,l,n,i);else if(t.type==="scalar")c=f$(e,r,t,i);else c=e.schema[Ct.SCALAR];let p;try{let u=c.resolve(r,(f)=>i(n??t,"TAG_RESOLVE_FAILED",f),e.options);p=Ct.isScalar(u)?u:new wp.Scalar(u)}catch(u){let f=u instanceof Error?u.message:String(u);i(n??t,"TAG_RESOLVE_FAILED",f),p=new wp.Scalar(r)}if(p.range=a,p.source=r,s)p.type=s;if(l)p.tag=l;if(c.format)p.format=c.format;if(o)p.comment=o;return p}function u$(e,t,n,i,r){if(n==="!")return e[Ct.SCALAR];let s=[];for(let a of e.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)s.push(a);else return a;for(let a of s)if(a.test?.test(t))return a;let o=e.knownTags[n];if(o&&!o.collection)return e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o;return r(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),e[Ct.SCALAR]}function f$({atKey:e,directives:t,schema:n},i,r,s){let o=n.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(i))||n[Ct.SCALAR];if(n.compat){let a=n.compat.find((l)=>l.default&&l.test?.test(i))??n[Ct.SCALAR];if(o.tag!==a.tag){let l=t.tagString(o.tag),c=t.tagString(a.tag),p=`Value may be parsed as either ${l} or ${c}`;s(r,"TAG_RESOLVE_FAILED",p,!0)}}return o}d$.composeScalar=c$});var vp=M(function(h$){function m$(e,t,n){if(t){n??(n=t.length);for(let i=n-1;i>=0;--i){let r=t[i];switch(r.type){case"space":case"comment":case"newline":e-=r.source.length;continue}r=t[++i];while(r?.type==="space")e+=r.source.length,r=t[++i];break}}return e}h$.emptyScalarPosition=m$});var _p=M(function(_$){var y$=Ln(),b$=V(),w$=yp(),Sp=xp(),x$=en(),v$=vp(),S$={composeNode:$p,composeEmptyNode:Sa};function $p(e,t,n,i){let r=e.atKey,{spaceBefore:s,comment:o,anchor:a,tag:l}=n,c,p=!0;switch(t.type){case"alias":if(c=$$(e,t,i),a||l)i(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(c=Sp.composeScalar(e,t,l,i),a)c.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(c=w$.composeCollection(S$,e,t,n,i),a)c.anchor=a.source.substring(1)}catch(u){let f=u instanceof Error?u.message:String(u);i(t,"RESOURCE_EXHAUSTION",f)}break;default:{let u=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;i(t,"UNEXPECTED_TOKEN",u),p=!1}}if(c??(c=Sa(e,t.offset,void 0,null,n,i)),a&&c.anchor==="")i(a,"BAD_ALIAS","Anchor cannot be an empty string");if(r&&e.options.stringKeys&&(!b$.isScalar(c)||typeof c.value!=="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str"))i(l??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(s)c.spaceBefore=!0;if(o)if(t.type==="scalar"&&t.source==="")c.comment=o;else c.commentBefore=o;if(e.options.keepSourceTokens&&p)c.srcToken=t;return c}function Sa(e,t,n,i,{spaceBefore:r,comment:s,anchor:o,tag:a,end:l},c){let p={type:"scalar",offset:v$.emptyScalarPosition(t,n,i),indent:-1,source:""},u=Sp.composeScalar(e,p,a,c);if(o){if(u.anchor=o.source.substring(1),u.anchor==="")c(o,"BAD_ALIAS","Anchor cannot be an empty string")}if(r)u.spaceBefore=!0;if(s)u.comment=s,u.range[2]=l;return u}function $$({options:e},{offset:t,source:n,end:i},r){let s=new y$.Alias(n.substring(1));if(s.source==="")r(t,"BAD_ALIAS","Alias cannot be an empty string");if(s.source.endsWith(":"))r(t+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+n.length,a=x$.resolveEnd(i,o,e.strict,r);if(s.range=[t,o,a.offset],a.comment)s.comment=a.comment;return s}_$.composeEmptyNode=Sa;_$.composeNode=$p});var Ap=M(function(O$){var k$=Yn(),Ep=_p(),T$=en(),I$=Xn();function M$(e,t,{offset:n,start:i,value:r,end:s},o){let a=Object.assign({_directives:t},e),l=new k$.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},p=I$.resolveProps(i,{indicator:"doc-start",next:r??s?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});if(p.found){if(l.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!p.hasNewline)o(p.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}l.contents=r?Ep.composeNode(c,r,p,o):Ep.composeEmptyNode(c,p.end,i,null,p,o);let u=l.contents.range[2],f=T$.resolveEnd(s,u,!1,o);if(f.comment)l.comment=f.comment;return l.range=[n,u,f.offset],l}O$.composeDoc=M$});var $a=M(function(q$){var N$=an("process"),R$=ko(),L$=Yn(),Qn=zn(),kp=V(),P$=Ap(),F$=en();function Zn(e){if(typeof e==="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==="string"?n.length:1)]}function Tp(e){let t="",n=!1,i=!1;for(let r=0;r<e.length;++r){let s=e[r];switch(s[0]){case"#":t+=(t===""?"":i?`
612
612
 
613
613
  `:`
614
614
  `)+(s.substring(1)||" "),n=!0,i=!1;break;case"%":if(e[r+1]?.[0]!=="#")r+=1;n=!1;break;default:if(!n)i=!0;n=!1}}return{comment:t,afterEmptyLine:i}}class Ip{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,n,i,r)=>{let s=Zn(t);if(r)this.warnings.push(new Qn.YAMLWarning(s,n,i));else this.errors.push(new Qn.YAMLParseError(s,n,i))},this.directives=new R$.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:i}=Tp(this.prelude);if(n){let r=e.contents;if(t)e.comment=e.comment?`${e.comment}
615
615
  ${n}`:n;else if(i||e.directives.docStart||!r)e.commentBefore=n;else if(kp.isCollection(r)&&!r.flow&&r.items.length>0){let s=r.items[0];if(kp.isPair(s))s=s.key;let o=s.commentBefore;s.commentBefore=o?`${n}
616
616
  ${o}`:n}else{let s=r.commentBefore;r.commentBefore=s?`${n}
617
- ${s}`:n}}if(t){for(let r=0;r<this.errors.length;++r)e.errors.push(this.errors[r]);for(let r=0;r<this.warnings.length;++r)e.warnings.push(this.warnings[r])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Tp(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let i of e)yield*this.next(i);yield*this.end(t,n)}*next(e){if(N$.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,n,i)=>{let r=Zn(e);r[0]+=t,this.onError(r,"BAD_DIRECTIVE",n,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=L$.composeDoc(this.options,this.directives,e,this.onError);if(this.atDirectives&&!t.directives.docStart)this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(t,!1),this.doc)yield this.doc;this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new Qn.YAMLParseError(Zn(e),"UNEXPECTED_TOKEN",t);if(this.atDirectives||!this.doc)this.errors.push(n);else this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){this.errors.push(new Qn.YAMLParseError(Zn(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=F$.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let n=this.doc.comment;this.doc.comment=n?`${n}
618
- ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Qn.YAMLParseError(Zn(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let n=Object.assign({_directives:this.directives},this.options),i=new P$.Document(void 0,n);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");i.range=[0,t,t],this.decorate(i,!1),yield i}}}q$.Composer=Ip});var Cp=M(function(W$){var U$=wa(),j$=va(),G$=zn(),Mp=Dn();function B$(e,t=!0,n){if(e){let i=(r,s,o)=>{let a=typeof r==="number"?r:Array.isArray(r)?r[0]:r.offset;if(n)n(a,s,o);else throw new G$.YAMLParseError([a,a+1],s,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return j$.resolveFlowScalar(e,t,i);case"block-scalar":return U$.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function V$(e,t){let{implicitKey:n=!1,indent:i,inFlow:r=!1,offset:s=-1,type:o="PLAIN"}=t,a=Mp.stringifyString({type:o,value:e},{implicitKey:n,indent:i>0?" ".repeat(i):"",inFlow:r,options:{blockQuote:!0,lineWidth:-1}}),l=t.end??[{type:"newline",offset:-1,indent:i,source:`
617
+ ${s}`:n}}if(t){for(let r=0;r<this.errors.length;++r)e.errors.push(this.errors[r]);for(let r=0;r<this.warnings.length;++r)e.warnings.push(this.warnings[r])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Tp(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let i of e)yield*this.next(i);yield*this.end(t,n)}*next(e){if(N$.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,n,i)=>{let r=Zn(e);r[0]+=t,this.onError(r,"BAD_DIRECTIVE",n,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=P$.composeDoc(this.options,this.directives,e,this.onError);if(this.atDirectives&&!t.directives.docStart)this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(t,!1),this.doc)yield this.doc;this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new Qn.YAMLParseError(Zn(e),"UNEXPECTED_TOKEN",t);if(this.atDirectives||!this.doc)this.errors.push(n);else this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){this.errors.push(new Qn.YAMLParseError(Zn(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=F$.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let n=this.doc.comment;this.doc.comment=n?`${n}
618
+ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Qn.YAMLParseError(Zn(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let n=Object.assign({_directives:this.directives},this.options),i=new L$.Document(void 0,n);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");i.range=[0,t,t],this.decorate(i,!1),yield i}}}q$.Composer=Ip});var Cp=M(function(W$){var U$=wa(),j$=va(),G$=zn(),Mp=Dn();function B$(e,t=!0,n){if(e){let i=(r,s,o)=>{let a=typeof r==="number"?r:Array.isArray(r)?r[0]:r.offset;if(n)n(a,s,o);else throw new G$.YAMLParseError([a,a+1],s,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return j$.resolveFlowScalar(e,t,i);case"block-scalar":return U$.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function V$(e,t){let{implicitKey:n=!1,indent:i,inFlow:r=!1,offset:s=-1,type:o="PLAIN"}=t,a=Mp.stringifyString({type:o,value:e},{implicitKey:n,indent:i>0?" ".repeat(i):"",inFlow:r,options:{blockQuote:!0,lineWidth:-1}}),l=t.end??[{type:"newline",offset:-1,indent:i,source:`
619
619
  `}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
620
620
  `),p=a.substring(0,c),u=a.substring(c+1)+`
621
621
  `,f=[{type:"block-scalar-header",offset:s,indent:i,source:p}];if(!Op(f,l))f.push({type:"newline",offset:-1,indent:i,source:`
@@ -623,7 +623,7 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
623
623
  `),i=t.substring(0,n),r=t.substring(n+1)+`
624
624
  `;if(e.type==="block-scalar"){let s=e.props[0];if(s.type!=="block-scalar-header")throw Error("Invalid block scalar header");s.source=i,e.source=r}else{let{offset:s}=e,o="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:s,indent:o,source:i}];if(!Op(a,"end"in e?e.end:void 0))a.push({type:"newline",offset:-1,indent:o,source:`
625
625
  `});for(let l of Object.keys(e))if(l!=="type"&&l!=="offset")delete e[l];Object.assign(e,{type:"block-scalar",indent:o,props:a,source:r})}}function Op(e,t){if(t)for(let n of t)switch(n.type){case"space":case"comment":e.push(n);break;case"newline":return e.push(n),!0}return!1}function _a(e,t,n){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=n,e.source=t;break;case"block-scalar":{let i=e.props.slice(1),r=t.length;if(e.props[0].type==="block-scalar-header")r-=e.props[0].source.length;for(let s of i)s.offset+=r;delete e.props,Object.assign(e,{type:n,source:t,end:i});break}case"block-map":case"block-seq":{let r={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
626
- `};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let i="indent"in e?e.indent:-1,r="end"in e&&Array.isArray(e.end)?e.end.filter((s)=>s.type==="space"||s.type==="comment"||s.type==="newline"):[];for(let s of Object.keys(e))if(s!=="type"&&s!=="offset")delete e[s];Object.assign(e,{type:n,indent:i,source:t,end:r})}}}W$.createScalarToken=V$;W$.resolveAsScalar=B$;W$.setScalarValue=H$});var Np=M(function(Q$){var X$=(e)=>("type"in e)?Fr(e):Lr(e);function Fr(e){switch(e.type){case"block-scalar":{let t="";for(let n of e.props)t+=Fr(n);return t+e.source}case"block-map":case"block-seq":{let t="";for(let n of e.items)t+=Lr(n);return t}case"flow-collection":{let t=e.start.source;for(let n of e.items)t+=Lr(n);for(let n of e.end)t+=n.source;return t}case"document":{let t=Lr(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function Lr({start:e,key:t,sep:n,value:i}){let r="";for(let s of e)r+=s.source;if(t)r+=Fr(t);if(n)for(let s of n)r+=s.source;if(i)r+=Fr(i);return r}Q$.stringify=X$});var Lp=M(function(t_){var Ea=Symbol("break visit"),e_=Symbol("skip children"),Rp=Symbol("remove item");function Nt(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};Pp(Object.freeze([]),e,t)}Nt.BREAK=Ea;Nt.SKIP=e_;Nt.REMOVE=Rp;Nt.itemAtPath=(e,t)=>{let n=e;for(let[i,r]of t){let s=n?.[i];if(s&&"items"in s)n=s.items[r];else return}return n};Nt.parentCollection=(e,t)=>{let n=Nt.itemAtPath(e,t.slice(0,-1)),i=t[t.length-1][0],r=n?.[i];if(r&&"items"in r)return r;throw Error("Parent collection not found")};function Pp(e,t,n){let i=n(t,e);if(typeof i==="symbol")return i;for(let r of["key","value"]){let s=t[r];if(s&&"items"in s){for(let o=0;o<s.items.length;++o){let a=Pp(Object.freeze(e.concat([[r,o]])),s.items[o],n);if(typeof a==="number")o=a-1;else if(a===Ea)return Ea;else if(a===Rp)s.items.splice(o,1),o-=1}if(typeof i==="function"&&r==="key")i=i(t,e)}}return typeof i==="function"?i(t,e):i}t_.visit=Nt});var qr=M(function(c_){var Aa=Cp(),i_=Np(),r_=Lp(),ka="\uFEFF",Ta="\x02",Ia="\x18",Ma="\x1F",s_=(e)=>!!e&&("items"in e),o_=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function a_(e){switch(e){case ka:return"<BOM>";case Ta:return"<DOC>";case Ia:return"<FLOW_END>";case Ma:return"<SCALAR>";default:return JSON.stringify(e)}}function l_(e){switch(e){case ka:return"byte-order-mark";case Ta:return"doc-mode";case Ia:return"flow-error-end";case Ma:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
626
+ `};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let i="indent"in e?e.indent:-1,r="end"in e&&Array.isArray(e.end)?e.end.filter((s)=>s.type==="space"||s.type==="comment"||s.type==="newline"):[];for(let s of Object.keys(e))if(s!=="type"&&s!=="offset")delete e[s];Object.assign(e,{type:n,indent:i,source:t,end:r})}}}W$.createScalarToken=V$;W$.resolveAsScalar=B$;W$.setScalarValue=H$});var Np=M(function(Q$){var X$=(e)=>("type"in e)?Fr(e):Pr(e);function Fr(e){switch(e.type){case"block-scalar":{let t="";for(let n of e.props)t+=Fr(n);return t+e.source}case"block-map":case"block-seq":{let t="";for(let n of e.items)t+=Pr(n);return t}case"flow-collection":{let t=e.start.source;for(let n of e.items)t+=Pr(n);for(let n of e.end)t+=n.source;return t}case"document":{let t=Pr(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function Pr({start:e,key:t,sep:n,value:i}){let r="";for(let s of e)r+=s.source;if(t)r+=Fr(t);if(n)for(let s of n)r+=s.source;if(i)r+=Fr(i);return r}Q$.stringify=X$});var Pp=M(function(t_){var Ea=Symbol("break visit"),e_=Symbol("skip children"),Rp=Symbol("remove item");function Nt(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};Lp(Object.freeze([]),e,t)}Nt.BREAK=Ea;Nt.SKIP=e_;Nt.REMOVE=Rp;Nt.itemAtPath=(e,t)=>{let n=e;for(let[i,r]of t){let s=n?.[i];if(s&&"items"in s)n=s.items[r];else return}return n};Nt.parentCollection=(e,t)=>{let n=Nt.itemAtPath(e,t.slice(0,-1)),i=t[t.length-1][0],r=n?.[i];if(r&&"items"in r)return r;throw Error("Parent collection not found")};function Lp(e,t,n){let i=n(t,e);if(typeof i==="symbol")return i;for(let r of["key","value"]){let s=t[r];if(s&&"items"in s){for(let o=0;o<s.items.length;++o){let a=Lp(Object.freeze(e.concat([[r,o]])),s.items[o],n);if(typeof a==="number")o=a-1;else if(a===Ea)return Ea;else if(a===Rp)s.items.splice(o,1),o-=1}if(typeof i==="function"&&r==="key")i=i(t,e)}}return typeof i==="function"?i(t,e):i}t_.visit=Nt});var qr=M(function(c_){var Aa=Cp(),i_=Np(),r_=Pp(),ka="\uFEFF",Ta="\x02",Ia="\x18",Ma="\x1F",s_=(e)=>!!e&&("items"in e),o_=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function a_(e){switch(e){case ka:return"<BOM>";case Ta:return"<DOC>";case Ia:return"<FLOW_END>";case Ma:return"<SCALAR>";default:return JSON.stringify(e)}}function l_(e){switch(e){case ka:return"byte-order-mark";case Ta:return"doc-mode";case Ia:return"flow-error-end";case Ma:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
627
627
  `:case`\r
628
628
  `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}c_.createScalarToken=Aa.createScalarToken;c_.resolveAsScalar=Aa.resolveAsScalar;c_.setScalarValue=Aa.setScalarValue;c_.stringify=i_.stringify;c_.visit=r_.visit;c_.BOM=ka;c_.DOCUMENT=Ta;c_.FLOW_END=Ia;c_.SCALAR=Ma;c_.isCollection=s_;c_.isScalar=o_;c_.prettyToken=a_;c_.tokenType=l_});var Ca=M(function(E_){var ei=qr();function Me(e){switch(e){case void 0:case" ":case`
629
629
  `:case"\r":case"\t":return!0;default:return!1}}var Fp=new Set("0123456789ABCDEFabcdef"),$_=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Dr=new Set(",[]{}"),__=new Set(` ,[]{}
@@ -648,7 +648,7 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
648
648
  `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
649
649
  `,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let n="end"in t.value?t.value.end:void 0;if((Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment")n?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){jr(i,t.start),i.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,i=n&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",r=[];if(i&&t.sep&&!t.value){let s=[];for(let o=0;o<t.sep.length;++o){let a=t.sep[o];switch(a.type){case"newline":s.push(o);break;case"space":break;case"comment":if(a.indent>e.indent)s.length=0;break;default:s.length=0}}if(s.length>=2)r=t.sep.splice(s[1])}switch(this.type){case"anchor":case"tag":if(i||t.value)r.push(this.sourceToken),e.items.push({start:r}),this.onKeyLine=!0;else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"explicit-key-ind":if(!t.sep&&!t.explicitKey)t.start.push(this.sourceToken),t.explicitKey=!0;else if(i||t.value)r.push(this.sourceToken),e.items.push({start:r,explicitKey:!0});else this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]});this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(!t.sep)if(ft(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let s=tn(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(ft(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]});else if(Bp(t.key)&&!ft(t.sep,"newline")){let s=tn(t.start),{key:o,sep:a}=t;a.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:o,sep:a}]})}else if(r.length>0)t.sep=t.sep.concat(r,this.sourceToken);else t.sep.push(this.sourceToken);else if(!t.sep)Object.assign(t,{key:null,sep:[this.sourceToken]});else if(t.value||i)e.items.push({start:r,key:null,sep:[this.sourceToken]});else if(ft(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else t.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);if(i||t.value)e.items.push({start:r,key:s,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(s);else Object.assign(t,{key:s,sep:[]}),this.onKeyLine=!0;return}default:{let s=this.startBlockValue(e);if(s){if(s.type==="block-seq"){if(!t.explicitKey&&t.sep&&!ft(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(n)e.items.push({start:r});this.stack.push(s);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let n="end"in t.value?t.value.end:void 0;if((Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment")n?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){jr(i,t.start),i.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;if(t.value||ft(t.start,"seq-item-ind"))e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return}if(this.indent>e.indent){let n=this.startBlockValue(e);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!t||t.sep)e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return;case"map-value-ind":if(!t||t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!t||t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);if(!t||t.value)e.items.push({start:[],key:i,sep:[]});else if(t.sep)this.stack.push(i);else Object.assign(t,{key:i,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);if(n)this.stack.push(n);else yield*this.pop(),yield*this.step()}else{let n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===e.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){let i=Ur(n),r=tn(i);Gp(e);let s=e.end.splice(1,e.end.length);s.push(this.sourceToken);let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
650
650
  `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
651
- `,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=Ur(e),n=tn(t);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=Ur(e),n=tn(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((n)=>n.type==="newline"||n.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}O_.Parser=Vp});var Yp=M(function(U_){var Hp=$a(),N_=Yn(),ti=zn(),R_=No(),P_=V(),L_=Na(),Kp=Ra();function Wp(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new L_.LineCounter||null,prettyErrors:t}}function F_(e,t={}){let{lineCounter:n,prettyErrors:i}=Wp(t),r=new Kp.Parser(n?.addNewLine),s=new Hp.Composer(t),o=Array.from(s.compose(r.parse(e)));if(i&&n)for(let a of o)a.errors.forEach(ti.prettifyError(e,n)),a.warnings.forEach(ti.prettifyError(e,n));if(o.length>0)return o;return Object.assign([],{empty:!0},s.streamInfo())}function Jp(e,t={}){let{lineCounter:n,prettyErrors:i}=Wp(t),r=new Kp.Parser(n?.addNewLine),s=new Hp.Composer(t),o=null;for(let a of s.compose(r.parse(e),!0,e.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new ti.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(i&&n)o.errors.forEach(ti.prettifyError(e,n)),o.warnings.forEach(ti.prettifyError(e,n));return o}function q_(e,t,n){let i=void 0;if(typeof t==="function")i=t;else if(n===void 0&&t&&typeof t==="object")n=t;let r=Jp(e,n);if(!r)return null;if(r.warnings.forEach((s)=>R_.warn(r.options.logLevel,s)),r.errors.length>0)if(r.options.logLevel!=="silent")throw r.errors[0];else r.errors=[];return r.toJS(Object.assign({reviver:i},n))}function D_(e,t,n){let i=null;if(typeof t==="function"||Array.isArray(t))i=t;else if(n===void 0&&t)n=t;if(typeof n==="string")n=n.length;if(typeof n==="number"){let r=Math.round(n);n=r<1?void 0:r>8?{indent:8}:{indent:r}}if(e===void 0){let{keepUndefined:r}=n??t??{};if(!r)return}if(P_.isDocument(e)&&!i)return e.toString(n);return new N_.Document(e,i,n).toString(n)}U_.parse=q_;U_.parseAllDocuments=F_;U_.parseDocument=Jp;U_.stringify=D_});var H_,K_,W_,Pa,J_,dt,Y_,z_,X_,Q_,fP,Z_,eE,tE,Gr,zp,nE,iE,rE,sE,oE,aE,lE,cE,uE,fE,dE,pE,mE,hE,gE,yE,bE,wE,xE,vE,SE,$E,_E,EE,Br,AE,kE,TE;var Xp=I(()=>{H_=$a(),K_=Yn(),W_=aa(),Pa=zn(),J_=Pn(),dt=V(),Y_=at(),z_=re(),X_=ct(),Q_=ut(),fP=qr(),Z_=Ca(),eE=Na(),tE=Ra(),Gr=Yp(),zp=Nn();nE=H_.Composer,iE=K_.Document,rE=W_.Schema,sE=Pa.YAMLError,oE=Pa.YAMLParseError,aE=Pa.YAMLWarning,lE=J_.Alias,cE=dt.isAlias,uE=dt.isCollection,fE=dt.isDocument,dE=dt.isMap,pE=dt.isNode,mE=dt.isPair,hE=dt.isScalar,gE=dt.isSeq,yE=Y_.Pair,bE=z_.Scalar,wE=X_.YAMLMap,xE=Q_.YAMLSeq,vE=Z_.Lexer,SE=eE.LineCounter,$E=tE.Parser,_E=Gr.parse,EE=Gr.parseAllDocuments,Br=Gr.parseDocument,AE=Gr.stringify,kE=zp.visit,TE=zp.visitAsync});var Rt,le,La;var Vr=I(()=>{Rt=["claude-code","codex","grok","opencode","hermes","pi","oh-my-pi","zed"],le=[{id:De,contextWindow:524288,maxTokens:128000,input:["text","image"],codex:{defaultReasoningLevel:"max",supportedReasoningLevels:[{effort:"low",description:"Low"},{effort:"medium",description:"Medium"},{effort:"high",description:"High"},{effort:"xhigh",description:"Extra high"},{effort:"max",description:"Maximum"}]}},{id:"MiniMax-M3",contextWindow:1e6,maxTokens:128000,input:["text","image"],codex:{defaultReasoningLevel:"high",supportedReasoningLevels:[{effort:"none",description:"Think-Off"},{effort:"high",description:"Deep"}]}}],La=le[0].id});import{chmodSync as Fa,closeSync as Qp,existsSync as nn,lstatSync as IE,mkdirSync as ME,openSync as OE,readFileSync as CE,realpathSync as NE,renameSync as RE,rmSync as sn,statSync as PE,writeFileSync as Ua}from"fs";import{homedir as LE,tmpdir as FE}from"os";import{basename as tm,dirname as nm,isAbsolute as im,join as H,resolve as Kr}from"path";function ja(e){let t=le.find((n)=>n.id===e);if(!t)throw new y(`Unsupported MiniMax model: ${e}`,b.USAGE);return t}function qa(e){return e==="MiniMax-M3.1-Flash"||e==="MiniMax-M3"?`${e}[1m]`:e}function Zp(e){return e==="MiniMax-M3"?"minimax":e.toLowerCase().replaceAll(".","-")}function He(e){let t=e==="cn"?"https://api.minimax.cn":"https://api.minimax.io";return{anthropic:`${t}/anthropic`,openai:`${t}/v1`}}function Pt(e,t,n){if(!e?.trim())return t;return im(e)?e:Kr(n,e)}function UE(e,t){let n=(t.OMP_PROFILE??t.PI_PROFILE)?.trim(),i=H(e,t.PI_CONFIG_DIR||".omp"),r=(o)=>/^[a-z0-9][a-z0-9._-]{0,63}$/.test(o)&&!o.endsWith(".")&&!/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\..*)?$/i.test(o),s;if(n&&n!=="default"){if(!r(n))throw new y("Invalid Oh my Pi profile name.",b.USAGE);s=H(i,"profiles",n,"agent")}else{let o=t.PI_PROFILE?.trim(),a=o&&o!=="default"&&r(o)?H(i,"profiles",o,"agent"):void 0,l=t.PI_CODING_AGENT_DIR===a?void 0:t.PI_CODING_AGENT_DIR;s=l?Kr(l):H(i,"agent")}return["models","config"].map((o)=>{let a=H(s,`${o}.yml`),l=H(s,`${o}.yaml`);if(nn(a))return a;if(nn(l))return l;let c=H(s,o==="models"?"models.json":"settings.json");if(nn(c))throw new y("Oh my Pi has legacy JSON configuration that needs migration.",b.GENERAL,"Run omp once with the same profile/environment to migrate it to YAML, then retry. No files were changed.");return a})}function jE(e,t){let n=t.homeDir??LE(),i=t.env??process.env;switch(e){case"claude-code":{let r=Pt(i.CLAUDE_CONFIG_DIR,H(n,".claude"),n);return[H(r,"settings.json")]}case"codex":{let r=Pt(i.CODEX_HOME,H(n,".codex"),n);return[H(r,"config.toml"),H(r,Hr)]}case"grok":return[H(Pt(i.GROK_HOME,H(n,".grok"),n),"config.toml")];case"opencode":{if(i.OPENCODE_CONFIG?.trim()){let l=i.OPENCODE_CONFIG.trim();return[im(l)?l:Kr(l)]}let r=Pt(i.XDG_CONFIG_HOME,H(n,".config"),n),s=H(r,"opencode"),o=H(s,"opencode.json"),a=H(s,"opencode.jsonc");return[nn(a)?a:o]}case"hermes":{let r=Pt(i.HERMES_HOME,H(n,".hermes"),n);return[H(r,"config.yaml"),H(r,".env")]}case"pi":{let r=Pt(i.PI_CODING_AGENT_DIR,H(n,".pi","agent"),n);return[H(r,"models.json"),H(r,"settings.json")]}case"oh-my-pi":return UE(n,i);case"zed":{if(process.platform==="win32")return[H(i.APPDATA||H(n,"AppData","Roaming"),"Zed","settings.json")];let r=process.platform==="darwin"?H(n,".config"):i.FLATPAK_XDG_CONFIG_HOME||Pt(i.XDG_CONFIG_HOME,H(n,".config"),n);return[H(r,"zed","settings.json")]}}}function rn(e){return nn(e)?CE(e,"utf8"):null}function Oe(e){let t=Ba(e);return{targetPath:t,before:rn(t)}}function sm(e,t){W(e,`${t} must contain a JSON object at its root.`)}function W(e,t){if(typeof e!=="object"||e===null||Array.isArray(e))throw new y(t,b.GENERAL,Ve)}function on(e,t){let n=[],i=qf(e,n,{allowTrailingComma:!0,disallowComments:!1});if(n.length>0)throw new y(`${t} is not valid JSON/JSONC.`,b.GENERAL,Ve);return sm(i,t),i}function ni(e,t,n){let i=e??`{}
651
+ `,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=Ur(e),n=tn(t);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=Ur(e),n=tn(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((n)=>n.type==="newline"||n.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}O_.Parser=Vp});var Yp=M(function(U_){var Hp=$a(),N_=Yn(),ti=zn(),R_=No(),L_=V(),P_=Na(),Kp=Ra();function Wp(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new P_.LineCounter||null,prettyErrors:t}}function F_(e,t={}){let{lineCounter:n,prettyErrors:i}=Wp(t),r=new Kp.Parser(n?.addNewLine),s=new Hp.Composer(t),o=Array.from(s.compose(r.parse(e)));if(i&&n)for(let a of o)a.errors.forEach(ti.prettifyError(e,n)),a.warnings.forEach(ti.prettifyError(e,n));if(o.length>0)return o;return Object.assign([],{empty:!0},s.streamInfo())}function Jp(e,t={}){let{lineCounter:n,prettyErrors:i}=Wp(t),r=new Kp.Parser(n?.addNewLine),s=new Hp.Composer(t),o=null;for(let a of s.compose(r.parse(e),!0,e.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new ti.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(i&&n)o.errors.forEach(ti.prettifyError(e,n)),o.warnings.forEach(ti.prettifyError(e,n));return o}function q_(e,t,n){let i=void 0;if(typeof t==="function")i=t;else if(n===void 0&&t&&typeof t==="object")n=t;let r=Jp(e,n);if(!r)return null;if(r.warnings.forEach((s)=>R_.warn(r.options.logLevel,s)),r.errors.length>0)if(r.options.logLevel!=="silent")throw r.errors[0];else r.errors=[];return r.toJS(Object.assign({reviver:i},n))}function D_(e,t,n){let i=null;if(typeof t==="function"||Array.isArray(t))i=t;else if(n===void 0&&t)n=t;if(typeof n==="string")n=n.length;if(typeof n==="number"){let r=Math.round(n);n=r<1?void 0:r>8?{indent:8}:{indent:r}}if(e===void 0){let{keepUndefined:r}=n??t??{};if(!r)return}if(L_.isDocument(e)&&!i)return e.toString(n);return new N_.Document(e,i,n).toString(n)}U_.parse=q_;U_.parseAllDocuments=F_;U_.parseDocument=Jp;U_.stringify=D_});var H_,K_,W_,La,J_,dt,Y_,z_,X_,Q_,fL,Z_,eE,tE,Gr,zp,nE,iE,rE,sE,oE,aE,lE,cE,uE,fE,dE,pE,mE,hE,gE,yE,bE,wE,xE,vE,SE,$E,_E,EE,Br,AE,kE,TE;var Xp=I(()=>{H_=$a(),K_=Yn(),W_=aa(),La=zn(),J_=Ln(),dt=V(),Y_=at(),z_=re(),X_=ct(),Q_=ut(),fL=qr(),Z_=Ca(),eE=Na(),tE=Ra(),Gr=Yp(),zp=Nn();nE=H_.Composer,iE=K_.Document,rE=W_.Schema,sE=La.YAMLError,oE=La.YAMLParseError,aE=La.YAMLWarning,lE=J_.Alias,cE=dt.isAlias,uE=dt.isCollection,fE=dt.isDocument,dE=dt.isMap,pE=dt.isNode,mE=dt.isPair,hE=dt.isScalar,gE=dt.isSeq,yE=Y_.Pair,bE=z_.Scalar,wE=X_.YAMLMap,xE=Q_.YAMLSeq,vE=Z_.Lexer,SE=eE.LineCounter,$E=tE.Parser,_E=Gr.parse,EE=Gr.parseAllDocuments,Br=Gr.parseDocument,AE=Gr.stringify,kE=zp.visit,TE=zp.visitAsync});var Rt,le,Pa;var Vr=I(()=>{Rt=["claude-code","codex","grok","opencode","hermes","pi","oh-my-pi","zed"],le=[{id:De,contextWindow:524288,maxTokens:128000,input:["text","image"],codex:{defaultReasoningLevel:"max",supportedReasoningLevels:[{effort:"low",description:"Low"},{effort:"medium",description:"Medium"},{effort:"high",description:"High"},{effort:"xhigh",description:"Extra high"},{effort:"max",description:"Maximum"}]}},{id:"MiniMax-M4",contextWindow:1e6,maxTokens:131072,input:["text","image"],codex:{defaultReasoningLevel:"max",supportedReasoningLevels:[{effort:"low",description:"Low"},{effort:"medium",description:"Medium"},{effort:"high",description:"High"},{effort:"xhigh",description:"Extra high"},{effort:"max",description:"Maximum"}]}},{id:"MiniMax-M3",contextWindow:1e6,maxTokens:128000,input:["text","image"],codex:{defaultReasoningLevel:"high",supportedReasoningLevels:[{effort:"none",description:"Think-Off"},{effort:"high",description:"Deep"}]}}],Pa=le[0].id});import{chmodSync as Fa,closeSync as Qp,existsSync as nn,lstatSync as IE,mkdirSync as ME,openSync as OE,readFileSync as CE,realpathSync as NE,renameSync as RE,rmSync as sn,statSync as LE,writeFileSync as Ua}from"fs";import{homedir as PE,tmpdir as FE}from"os";import{basename as tm,dirname as nm,isAbsolute as im,join as H,resolve as Kr}from"path";function ja(e){let t=le.find((n)=>n.id===e);if(!t)throw new y(`Unsupported MiniMax model: ${e}`,b.USAGE);return t}function qa(e){return e==="MiniMax-M4"||e==="MiniMax-M3.1-Flash"||e==="MiniMax-M3"?`${e}[1m]`:e}function Zp(e){return e==="MiniMax-M3"?"minimax":e.toLowerCase().replaceAll(".","-")}function He(e){let t=e==="cn"?"https://api.minimax.cn":"https://api.minimax.io";return{anthropic:`${t}/anthropic`,openai:`${t}/v1`}}function Lt(e,t,n){if(!e?.trim())return t;return im(e)?e:Kr(n,e)}function UE(e,t){let n=(t.OMP_PROFILE??t.PI_PROFILE)?.trim(),i=H(e,t.PI_CONFIG_DIR||".omp"),r=(o)=>/^[a-z0-9][a-z0-9._-]{0,63}$/.test(o)&&!o.endsWith(".")&&!/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\..*)?$/i.test(o),s;if(n&&n!=="default"){if(!r(n))throw new y("Invalid Oh my Pi profile name.",b.USAGE);s=H(i,"profiles",n,"agent")}else{let o=t.PI_PROFILE?.trim(),a=o&&o!=="default"&&r(o)?H(i,"profiles",o,"agent"):void 0,l=t.PI_CODING_AGENT_DIR===a?void 0:t.PI_CODING_AGENT_DIR;s=l?Kr(l):H(i,"agent")}return["models","config"].map((o)=>{let a=H(s,`${o}.yml`),l=H(s,`${o}.yaml`);if(nn(a))return a;if(nn(l))return l;let c=H(s,o==="models"?"models.json":"settings.json");if(nn(c))throw new y("Oh my Pi has legacy JSON configuration that needs migration.",b.GENERAL,"Run omp once with the same profile/environment to migrate it to YAML, then retry. No files were changed.");return a})}function jE(e,t){let n=t.homeDir??PE(),i=t.env??process.env;switch(e){case"claude-code":{let r=Lt(i.CLAUDE_CONFIG_DIR,H(n,".claude"),n);return[H(r,"settings.json")]}case"codex":{let r=Lt(i.CODEX_HOME,H(n,".codex"),n);return[H(r,"config.toml"),H(r,Hr)]}case"grok":return[H(Lt(i.GROK_HOME,H(n,".grok"),n),"config.toml")];case"opencode":{if(i.OPENCODE_CONFIG?.trim()){let l=i.OPENCODE_CONFIG.trim();return[im(l)?l:Kr(l)]}let r=Lt(i.XDG_CONFIG_HOME,H(n,".config"),n),s=H(r,"opencode"),o=H(s,"opencode.json"),a=H(s,"opencode.jsonc");return[nn(a)?a:o]}case"hermes":{let r=Lt(i.HERMES_HOME,H(n,".hermes"),n);return[H(r,"config.yaml"),H(r,".env")]}case"pi":{let r=Lt(i.PI_CODING_AGENT_DIR,H(n,".pi","agent"),n);return[H(r,"models.json"),H(r,"settings.json")]}case"oh-my-pi":return UE(n,i);case"zed":{if(process.platform==="win32")return[H(i.APPDATA||H(n,"AppData","Roaming"),"Zed","settings.json")];let r=process.platform==="darwin"?H(n,".config"):i.FLATPAK_XDG_CONFIG_HOME||Lt(i.XDG_CONFIG_HOME,H(n,".config"),n);return[H(r,"zed","settings.json")]}}}function rn(e){return nn(e)?CE(e,"utf8"):null}function Oe(e){let t=Ba(e);return{targetPath:t,before:rn(t)}}function sm(e,t){W(e,`${t} must contain a JSON object at its root.`)}function W(e,t){if(typeof e!=="object"||e===null||Array.isArray(e))throw new y(t,b.GENERAL,Ve)}function on(e,t){let n=[],i=qf(e,n,{allowTrailingComma:!0,disallowComments:!1});if(n.length>0)throw new y(`${t} is not valid JSON/JSONC.`,b.GENERAL,Ve);return sm(i,t),i}function ni(e,t,n){let i=e??`{}
652
652
  `;on(i,t);for(let r of n)i=Uf(i,Df(i,r.path,r.value,{formattingOptions:qE}));return i.endsWith(`
653
653
  `)?i:`${i}
654
654
  `}function GE(e,t){let n=e.match(/.*(?:\r?\n|$)/g)?.filter(Boolean)??[],i=0,r;for(let s of n){let o=s.match(/^\s*\[([^\][\r\n]+)]\s*(?:#.*)?(?:\r?\n)?$/),a=s.match(/^\s*\[\[([^\][\r\n]+)]]\s*(?:#.*)?(?:\r?\n)?$/);if(o||a){if(r)return r.end=i,r;if(o?.[1]?.trim()===t)r={bodyStart:i+s.length,end:e.length}}i+=s.length}return r}function om(e){let t;for(let n=0;n<e.length;n+=1){let i=e[n];if(t==='"'&&i==="\\"){n+=1;continue}if(t){if(i===t)t=void 0;continue}if(i==='"'||i==="'"){t=i;continue}if(i==="#"){let r=n;while(r>0&&/[ \t]/.test(e[r-1]))r-=1;return e.slice(r)}}return""}function Da(e,t){let n=e;for(let[i,r]of Object.entries(t)){if(!DE.test(i))throw new y(`Invalid TOML key: ${i}`,b.GENERAL);let s=typeof r==="string"?JSON.stringify(r):String(r),o=`${i} = ${s}`,a=new RegExp(`^(\\s*)${i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*=.*$`,"m");if(a.test(n))n=n.replace(a,(l,c)=>`${c}${o}${om(l)}`);else{if(n.length>0&&!n.endsWith(`
@@ -673,9 +673,9 @@ ${Da("",n)}`,r}function am(e,t){let n=e.search(/^\s*\[/m),i=n===-1?e.length:n;re
673
673
  `}return a.endsWith(`
674
674
  `)?a:`${a}
675
675
  `}function JE(e,t){let n=Oe(t),r=on(n.before??"{}","Claude Code settings.json").modelPicker;if(r!==void 0)W(r,"Claude Code settings.json modelPicker section must be an object.");let s=r?.options;if(s!==void 0&&!Array.isArray(s))throw new y("Claude Code settings.json modelPicker.options must be an array.",b.GENERAL,Ve);let o=r?.replaceBuiltInOptions;if(o!==void 0&&typeof o!=="boolean")throw new y("Claude Code settings.json modelPicker.replaceBuiltInOptions must be a boolean.",b.GENERAL,Ve);let a=He(e.region),l=qa(e.model),c=le.map((g)=>({model:qa(g.id),label:g.id,description:g.id===e.model?`1M supported · ${g.id==="MiniMax-M3.1-Flash"&&(e.m31ContextWindow??524288)!==1e6?"512K":"1M"} compact`:"1M supported"})),p=new Set(le.flatMap((g)=>[g.id,qa(g.id)])),u=[];if(s===void 0)u.push({path:["modelPicker","options"],value:c});else{let g=s.flatMap((d,m)=>{if(typeof d!=="object"||d===null||Array.isArray(d))return[];let v=d.model;return typeof v==="string"&&p.has(v)?[m]:[]});for(let d of g.reverse())u.push({path:["modelPicker","options",d],value:void 0});let h=s.length-g.length;c.forEach((d,m)=>{u.push({path:["modelPicker","options",h+m],value:d})})}let f={ANTHROPIC_BASE_URL:a.anthropic,ANTHROPIC_AUTH_TOKEN:e.apiKey,API_TIMEOUT_MS:"3000000",CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:"1",CLAUDE_CODE_AUTO_COMPACT_WINDOW:String(e.model==="MiniMax-M3.1-Flash"?e.m31ContextWindow??524288:ja(e.model).contextWindow),ANTHROPIC_MODEL:l,ANTHROPIC_DEFAULT_SONNET_MODEL:l,ANTHROPIC_DEFAULT_OPUS_MODEL:l,ANTHROPIC_DEFAULT_HAIKU_MODEL:l};return[{agent:"claude-code",path:t,...n,after:ni(n.before,"Claude Code settings.json",[...Object.entries(f).map(([g,h])=>({path:["env",g],value:h})),...u,{path:["modelPicker","replaceBuiltInOptions"],value:o??!0}])}]}function YE(e){return`${JSON.stringify({_managed_by:rm,models:le.map((t,n)=>{let i=t.id==="MiniMax-M3.1-Flash"?e.m31ContextWindow??524288:t.contextWindow;return{slug:t.id,display_name:t.id,description:t.id==="MiniMax-M3.1-Flash"?"MiniMax M3.1 Flash":"MiniMax",default_reasoning_level:t.codex.defaultReasoningLevel,supported_reasoning_levels:t.codex.supportedReasoningLevels,shell_type:"shell_command",visibility:"list",supported_in_api:!0,priority:n,base_instructions:`You are Codex, a coding agent based on ${t.id}. You and the user share the same workspace and collaborate to achieve the user's goals.`,supports_reasoning_summaries:!0,default_reasoning_summary:"none",support_verbosity:!1,truncation_policy:{mode:"tokens",limit:1e4},supports_parallel_tool_calls:!0,experimental_supported_tools:[],prefer_websockets:!1,apply_patch_tool_type:"freeform",web_search_tool_type:"text",supports_image_detail_original:!1,tool_mode:"code_mode_only",multi_agent_version:"v2",use_responses_lite:!1,effective_context_window_percent:i===1e6?85:95,auto_compact_token_limit:null,reasoning_summary_format:"experimental",supports_search_tool:!0,context_window:i,max_context_window:i,input_modalities:[...t.input]}})},null,2)}
676
- `}function zE(e,t){let[n,i]=t;if(!n||!i)throw new y("Codex paths are incomplete.",b.GENERAL);let r=Oe(n),s=He(e.region),o=ja(e.model),a=lm(r.before,"Codex config.toml",{model:e.model,model_reasoning_effort:o.codex.defaultReasoningLevel,model_provider:"minimax"},[{name:"model_providers.minimax",entries:{name:"MiniMax",base_url:s.openai,experimental_bearer_token:e.apiKey,wire_api:"responses"}}]),l=Et(a).model_catalog_json;if(l!==void 0&&l!==Hr)throw new y("Codex config.toml already uses a user-managed model catalog.",b.GENERAL,"Remove model_catalog_json to let mmx manage a MiniMax-only catalog, or configure Codex manually. No files were changed.");let c=Oe(i);if(c.before!==null){if(on(c.before,"Codex mmx-model-catalog.json")._managed_by!==rm)throw new y(`Codex ${Hr} is not managed by mmx.`,b.GENERAL,"Rename or remove that file, then retry. No files were changed.")}return a=VE(a,["model_context_window","model_auto_compact_token_limit"]),a=am(a,{model_catalog_json:Hr}),[{agent:"codex",path:n,...r,after:a},{agent:"codex",path:i,...c,after:YE(e)}]}function XE(e,t){let n=Oe(t),i=He(e.region),r=le.map((s)=>({name:`model.${Zp(s.id)}`,entries:{model:s.id,base_url:i.openai,name:s.id,api_key:e.apiKey,api_backend:"chat_completions",context_window:s.contextWindow,max_completion_tokens:s.maxTokens}}));return[{agent:"grok",path:t,...n,after:lm(n.before,"Grok config.toml",{},[{name:"models",entries:{default:Zp(e.model)}},...r])}]}function QE(e,t){let n=Oe(t),r=on(n.before??"{}","OpenCode opencode.json").provider;if(r!==void 0)W(r,"OpenCode opencode.json provider section must be an object.");let s=r?.minimax;if(s!==void 0)W(s,"OpenCode opencode.json provider.minimax section must be an object.");for(let u of["options","models"]){let f=s?.[u];if(f!==void 0)W(f,`OpenCode opencode.json provider.minimax.${u} section must be an object.`)}let o=s?.models;for(let u of le){let f=o?.[u.id];if(f!==void 0)W(f,`OpenCode model definition for ${u.id} must be an object.`);let g=f?.limit;if(g!==void 0)W(g,`OpenCode model definition for ${u.id} limit must be an object.`);let h=f?.modalities;if(h!==void 0)W(h,`OpenCode model definition for ${u.id} modalities must be an object.`);if(u.id==="MiniMax-M3.1-Flash"){let d=f?.variants;if(d!==void 0)W(d,`OpenCode model definition for ${u.id} variants must be an object.`)}}let a=He(e.region),l=le.flatMap((u)=>{let f=[...u.input];return[{path:["provider","minimax","models",u.id,"name"],value:u.id},{path:["provider","minimax","models",u.id,"reasoning"],value:!0},{path:["provider","minimax","models",u.id,"temperature"],value:!1},{path:["provider","minimax","models",u.id,"attachment"],value:f.includes("image")},{path:["provider","minimax","models",u.id,"modalities","input"],value:f},{path:["provider","minimax","models",u.id,"modalities","output"],value:["text"]},{path:["provider","minimax","models",u.id,"limit","context"],value:u.id==="MiniMax-M3.1-Flash"?e.m31ContextWindow??524288:u.contextWindow},{path:["provider","minimax","models",u.id,"limit","output"],value:u.maxTokens}]}),c=["provider","minimax","models","MiniMax-M3.1-Flash"],p=[{path:[...c,"interleaved"],value:{field:"reasoning_content"}},{path:[...c,"variants","none","disabled"],value:!0},{path:[...c,"variants","thinking","disabled"],value:!0},{path:[...c,"variants","default","reasoningEffort"],value:"max"},...["low","medium","high","xhigh","max"].map((u)=>({path:[...c,"variants",u,"reasoningEffort"],value:u}))];return[{agent:"opencode",path:t,...n,after:ni(n.before,"OpenCode opencode.json",[{path:["provider","minimax","npm"],value:"@ai-sdk/openai-compatible"},{path:["provider","minimax","name"],value:"MiniMax"},{path:["provider","minimax","options","baseURL"],value:a.openai},{path:["provider","minimax","options","apiKey"],value:e.apiKey},{path:["provider","minimax","options","setCacheKey"],value:void 0},...l,...p,{path:["model"],value:`minimax/${e.model}`}])}]}function ZE(e,t){let[n,i]=t;if(!n||!i)throw new y("Hermes paths are incomplete.",b.GENERAL);let r=Oe(n),s=Oe(i),o=He(e.region),a=e.region==="cn"?"minimax-cn":"minimax",l=e.region==="cn"?"MINIMAX_CN_API_KEY":"MINIMAX_API_KEY";return[{agent:"hermes",path:n,...r,after:HE(r.before,a,e.model,o.anthropic)},{agent:"hermes",path:i,...s,after:WE(s.before,l,e.apiKey)}]}function eA(e,t){let[n,i]=t;if(!n||!i)throw new y("Pi paths are incomplete.",b.GENERAL);let r=Oe(n),s=Oe(i),o=on(r.before??"{}","Pi models.json"),a=He(e.region),l=e.region==="cn"?"minimax-cn":"minimax",c=o.providers;if(c!==void 0)W(c,"Pi models.json providers section must be an object.");let p=c?.[l];if(p!==void 0)W(p,`Pi models.json providers.${l} section must be an object.`);let u=p?.models;if(u!==void 0&&!Array.isArray(u))throw new y(`Pi models.json providers.${l}.models must be an array.`,b.GENERAL,Ve);let f=[{path:["providers",l,"name"],value:"MiniMax"},{path:["providers",l,"baseUrl"],value:a.anthropic},{path:["providers",l,"apiKey"],value:e.apiKey},{path:["providers",l,"api"],value:"anthropic-messages"}],g=le.map((h)=>({id:h.id,name:h.id,reasoning:!0,...h.id==="MiniMax-M3"?{compat:{forceAdaptiveThinking:!0,supportsTemperature:!1}}:{compat:{forceAdaptiveThinking:!0,supportsTemperature:!1},thinkingLevelMap:{off:null,minimal:null,xhigh:"xhigh",max:"max"}},input:[...h.input],contextWindow:h.contextWindow,maxTokens:h.maxTokens}));if(u===void 0)f.push({path:["providers",l,"models"],value:g});else{let h=u.length;for(let d of g){let m=u.findIndex((w)=>typeof w==="object"&&w!==null&&!Array.isArray(w)&&w.id===d.id),v=["providers",l,"models",m>=0?m:h++];if(m<0){f.push({path:v,value:d});continue}W(u[m],`Pi model definition for ${d.id} must be an object.`);for(let[w,x]of Object.entries(d)){if(w==="id")continue;if(w==="compat"||w==="thinkingLevelMap"){let E=u[m][w];if(E!==void 0)W(E,`Pi ${w} for ${d.id} must be an object.`);for(let[A,_]of Object.entries(x))f.push({path:[...v,w,A],value:_});continue}f.push({path:[...v,w],value:x})}}}return[{agent:"pi",path:n,...r,after:ni(r.before,"Pi models.json",f)},{agent:"pi",path:i,...s,after:ni(s.before,"Pi settings.json",[{path:["defaultProvider"],value:l},{path:["defaultModel"],value:e.model}])}]}function tA(e,t){let n=e.region==="cn"?"minimax-cn":"minimax",i=He(e.region).anthropic;return t.map((r,s)=>{let o=Oe(r),a=`Oh my Pi ${tm(r)}`,l=Br(o.before??`{}
677
- `);if(l.errors.length>0)throw new y(`${a} is not valid YAML.`,b.GENERAL,Ve);if(l.contents===null)l.set(s===0?"providers":"modelRoles",l.createNode({}));let c=l.toJS();if(W(c,`${a} must contain an object at its root.`),s===0){if(c.providers!==void 0)W(c.providers,`${a} providers must be an object.`);let p=c.providers?.[n];if(p!==void 0)W(p,`${a} provider must be an object.`);let u=p?.models;if(u!==void 0&&!Array.isArray(u))throw new y(`${a} models must be an array.`,b.GENERAL,Ve);let f=u??[];for(let d of f)W(d,`${a} model entries must be objects.`);let g=["providers",n];for(let[d,m]of Object.entries({baseUrl:i,apiKey:e.apiKey,api:"anthropic-messages",auth:"apiKey"}))l.setIn([...g,d],m);if(u===void 0)l.setIn([...g,"models"],l.createNode([]));let h=f.length;for(let d of le){let m=f.findIndex((x)=>x.id===d.id),v=[...g,"models",m>=0?m:h++],w={id:d.id,name:d.id,api:"anthropic-messages",baseUrl:i,reasoning:!0,input:[...d.input],contextWindow:d.contextWindow,maxTokens:d.maxTokens,...d.id==="MiniMax-M3.1-Flash"?{thinking:{mode:"anthropic-adaptive",efforts:["low","medium","high","xhigh","max"],defaultLevel:"max",requiresEffort:!0,effortMap:{low:"low",medium:"medium",high:"high"}}}:{}};if(m<0)l.setIn(v,l.createNode(w));else for(let[x,E]of Object.entries(w))l.setIn([...v,x],l.createNode(E))}}else{if(c.modelRoles!==void 0)W(c.modelRoles,`${a} modelRoles must be an object.`);let p=e.model==="MiniMax-M3.1-Flash"?":max":"";l.setIn(["modelRoles","default"],`${n}/${e.model}${p}`)}return{agent:"oh-my-pi",path:r,...o,after:l.toString()}})}function nA(e,t){let n=Oe(t),i="Zed settings.json",r=on(n.before??"{}","Zed settings.json"),s=r.language_models;if(s!==void 0)W(s,"Zed settings.json language_models must be an object.");let o=s?.openai_compatible;if(o!==void 0)W(o,"Zed settings.json language_models.openai_compatible must be an object.");let a=o?.minimax;if(a!==void 0)W(a,"Zed settings.json language_models.openai_compatible.minimax must be an object.");let l=a?.available_models;if(l!==void 0&&!Array.isArray(l))throw new y("Zed settings.json minimax available_models must be an array.",b.GENERAL,Ve);let c=r.agent;if(c!==void 0)W(c,"Zed settings.json agent must be an object.");let p=c?.default_model;if(p!==void 0)W(p,"Zed settings.json agent.default_model must be an object.");let u=(d)=>d==="MiniMax-M3.1-Flash"?"max":"high",f=["language_models","openai_compatible","minimax"],g=le.map((d)=>({name:d.id,display_name:d.id,max_tokens:d.id==="MiniMax-M3.1-Flash"?e.m31ContextWindow??524288:d.contextWindow,max_output_tokens:d.maxTokens,reasoning_effort:u(d.id),capabilities:{tools:!0,images:d.input.some((m)=>m==="image"),parallel_tool_calls:!0,prompt_cache_key:!1,chat_completions:!0,interleaved_reasoning:!0,max_tokens_parameter:!1}})),h=[{path:[...f,"api_url"],value:He(e.region).openai}];if(l===void 0)h.push({path:[...f,"available_models"],value:g});else{let d=l.length;for(let m of g){let v=l.findIndex((w)=>typeof w==="object"&&w!==null&&w.name===m.name);h.push({path:[...f,"available_models",v>=0?v:d++],value:m})}}return h.push({path:["agent","default_model","provider"],value:"minimax"},{path:["agent","default_model","model"],value:e.model},{path:["agent","default_model","enable_thinking"],value:!0},{path:["agent","default_model","effort"],value:u(e.model)}),[{agent:"zed",path:t,...n,after:ni(n.before,"Zed settings.json",h)}]}function Ga(e){let t=[];for(let n of e.agents){let i=jE(n,e);switch(n){case"claude-code":t.push(...JE(e,i[0]));break;case"codex":t.push(...zE(e,i));break;case"grok":t.push(...XE(e,i[0]));break;case"opencode":t.push(...QE(e,i[0]));break;case"hermes":t.push(...ZE(e,i));break;case"pi":t.push(...eA(e,i));break;case"oh-my-pi":t.push(...tA(e,i));break;case"zed":t.push(...nA(e,i[0]));break}}return cm(t),t}function em(e,t,n){let i=nm(e);ME(i,{recursive:!0,mode:448});let r=H(i,`.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`),s=()=>{if(Ba(n)!==e)throw new y(`Configuration path changed while mmx was writing it: ${n}`,b.GENERAL)};try{s(),Ua(r,t,{encoding:"utf8",mode:384,flag:"wx"}),s(),RE(r,e)}catch(o){throw sn(r,{force:!0}),o}}function iA(e,t,n){for(let i=0;;i+=1){let r=`${e}.bak.${n}${i===0?"":`.${i}`}`;try{return Ua(r,t,{encoding:"utf8",mode:384,flag:"wx"}),r}catch(s){if(s.code==="EEXIST")continue;throw sn(r,{force:!0}),s}}}function rA(){return new Date().toISOString().replace(/[-:]/g,"").replace("T","-").replace(/\.\d{3}Z$/,"Z")}function Ba(e){let t=e,n=[];while(!0)try{return H(NE(t),...n)}catch(i){if(i.code!=="ENOENT")throw i;try{if(IE(t).isSymbolicLink())throw new y(`Configuration path contains a dangling symbolic link: ${e}`,b.GENERAL,"Fix the symbolic link and retry. No files were changed.")}catch(s){if(s instanceof y)throw s;if(s.code!=="ENOENT")throw s}let r=nm(t);if(r===t)return Kr(e);n.unshift(tm(t)),t=r}}function sA(e){return process.platform!=="win32"&&(e&63)!==0}function cm(e){let t=new Set;for(let n of e){if(t.has(n.targetPath))throw new y(`Multiple agent configuration paths resolve to ${n.targetPath}.`,b.GENERAL,"No files were changed. Use distinct configuration paths and retry.");t.add(n.targetPath)}}function oA(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}function um(){let e=typeof process.getuid==="function"?String(process.getuid()):(process.env.USERNAME??process.env.USER??"user").replace(/[^A-Za-z0-9_-]/g,"_"),t=H(FE(),`mmx-agent-setup-${e}.lock`),n=`${process.pid}:${Date.now()}:${Math.random().toString(16).slice(2)}`;try{let i=OE(t,"wx",384);try{Ua(i,`${n}
678
- `,"utf8")}catch(s){if(Qp(i),rn(t)?.trim()===n)sn(t,{force:!0});throw s}let r=!1;return()=>{if(r)return;if(r=!0,Qp(i),rn(t)?.trim()===n)sn(t,{force:!0})}}catch(i){if(i.code!=="EEXIST")throw i;let s=(rn(t)?.trim()??"").match(/^(\d+):/),o=s?.[1]?Number(s[1]):void 0,a=o!==void 0&&!oA(o);throw new y(a?"A stale mmx agent setup lock exists.":"Another mmx agent setup is already running.",b.GENERAL,a?`Confirm no setup process is running, remove ${t}, then retry. No files were changed.`:"Wait for it to finish, then retry. No files were changed.")}}async function fm(e){let t=um(),n=new Map,i=()=>{for(let[r,s]of n)process.removeListener(r,s)};for(let[r,s]of[["SIGHUP",129],["SIGINT",130],["SIGTERM",143]]){let o=()=>{i(),t(),process.exit(s)};n.set(r,o),process.once(r,o)}process.once("exit",t);try{return await e()}finally{process.off("exit",t),i(),t()}}function dm(e,t=!1,n=!1){let i=t||n?void 0:um();try{let r=e.filter((u)=>u.before!==u.after);cm(e);let s=new Map,o=new Map;for(let u of e)if(u.before!==null&&nn(u.targetPath)){let f=PE(u.targetPath).mode&511;if(s.set(u,f),u.before===u.after&&sA(f))o.set(u,f)}if(t)return e.map((u)=>({agent:u.agent,path:u.path,status:u.before===u.after&&!o.has(u)?"unchanged":"would-configure"}));let a=(u,f)=>{if(Ba(u.path)!==u.targetPath||rn(u.targetPath)!==u.before)throw new y(`Configuration changed while mmx was preparing it: ${u.path}`,b.GENERAL,f)};for(let u of e)if(u.before!==u.after||o.has(u))a(u,"No files were changed. Retry the command.");let l=rA(),c=new Map,p=[];try{for(let u of r)if(u.before!==null)a(u,"No files were changed. Retry the command."),c.set(u.path,iA(u.targetPath,u.before,l));for(let u of e){if(!o.has(u))continue;a(u,"The completed writes were rolled back. Retry the command."),Fa(u.targetPath,384)}for(let u of r)a(u,"The completed writes were rolled back. Retry the command."),em(u.targetPath,u.after,u.path),p.push({file:u,target:u.targetPath})}catch(u){let f=[],g;for(let{file:h,target:d}of p.reverse())try{if(rn(d)!==h.after){f.push(h.path);continue}if(h.before===null)sn(d,{force:!0});else{em(d,h.before,h.path);let m=s.get(h);if(m!==void 0)Fa(d,m)}}catch(m){g??=m}for(let[h,d]of o)try{Fa(h.targetPath,d)}catch(m){g??=m}if(f.length===0&&g===void 0)for(let h of c.values())try{sn(h,{force:!0})}catch(d){g??=d}if(f.length>0||g!==void 0)throw new y("Could not fully roll back agent configuration.",b.GENERAL,`Review the affected files${c.size>0?` and backups: ${[...c.values()].join(", ")}`:"."}`);throw u}return e.map((u)=>({agent:u.agent,path:u.path,status:u.before===u.after&&!o.has(u)?"unchanged":"configured",...c.has(u.path)?{backup:c.get(u.path)}:{}}))}finally{i?.()}}var qE,DE,Hr="mmx-model-catalog.json",rm="mmx agent setup",Ve="Fix the existing configuration file and retry. No files were changed.";var Va=I(()=>{jf();yo();Xp();G();j();Vr();qE={insertSpaces:!0,tabSize:2,eol:`
676
+ `}function zE(e,t){let[n,i]=t;if(!n||!i)throw new y("Codex paths are incomplete.",b.GENERAL);let r=Oe(n),s=He(e.region),o=ja(e.model),a=lm(r.before,"Codex config.toml",{model:e.model,model_reasoning_effort:o.codex.defaultReasoningLevel,model_provider:"minimax"},[{name:"model_providers.minimax",entries:{name:"MiniMax",base_url:s.openai,experimental_bearer_token:e.apiKey,wire_api:"responses"}}]),l=Et(a).model_catalog_json;if(l!==void 0&&l!==Hr)throw new y("Codex config.toml already uses a user-managed model catalog.",b.GENERAL,"Remove model_catalog_json to let mmx manage a MiniMax-only catalog, or configure Codex manually. No files were changed.");let c=Oe(i);if(c.before!==null){if(on(c.before,"Codex mmx-model-catalog.json")._managed_by!==rm)throw new y(`Codex ${Hr} is not managed by mmx.`,b.GENERAL,"Rename or remove that file, then retry. No files were changed.")}return a=VE(a,["model_context_window","model_auto_compact_token_limit"]),a=am(a,{model_catalog_json:Hr}),[{agent:"codex",path:n,...r,after:a},{agent:"codex",path:i,...c,after:YE(e)}]}function XE(e,t){let n=Oe(t),i=He(e.region),r=le.map((s)=>({name:`model.${Zp(s.id)}`,entries:{model:s.id,base_url:i.openai,name:s.id,api_key:e.apiKey,api_backend:"chat_completions",context_window:s.contextWindow,max_completion_tokens:s.maxTokens}}));return[{agent:"grok",path:t,...n,after:lm(n.before,"Grok config.toml",{},[{name:"models",entries:{default:Zp(e.model)}},...r])}]}function QE(e,t){let n=Oe(t),r=on(n.before??"{}","OpenCode opencode.json").provider;if(r!==void 0)W(r,"OpenCode opencode.json provider section must be an object.");let s=r?.minimax;if(s!==void 0)W(s,"OpenCode opencode.json provider.minimax section must be an object.");for(let p of["options","models"]){let u=s?.[p];if(u!==void 0)W(u,`OpenCode opencode.json provider.minimax.${p} section must be an object.`)}let o=s?.models;for(let p of le){let u=o?.[p.id];if(u!==void 0)W(u,`OpenCode model definition for ${p.id} must be an object.`);let f=u?.limit;if(f!==void 0)W(f,`OpenCode model definition for ${p.id} limit must be an object.`);let g=u?.modalities;if(g!==void 0)W(g,`OpenCode model definition for ${p.id} modalities must be an object.`);if(p.id!=="MiniMax-M3"){let h=u?.variants;if(h!==void 0)W(h,`OpenCode model definition for ${p.id} variants must be an object.`)}}let a=He(e.region),l=le.flatMap((p)=>{let u=[...p.input];return[{path:["provider","minimax","models",p.id,"name"],value:p.id},{path:["provider","minimax","models",p.id,"reasoning"],value:!0},{path:["provider","minimax","models",p.id,"temperature"],value:!1},{path:["provider","minimax","models",p.id,"attachment"],value:u.includes("image")},{path:["provider","minimax","models",p.id,"modalities","input"],value:u},{path:["provider","minimax","models",p.id,"modalities","output"],value:["text"]},{path:["provider","minimax","models",p.id,"limit","context"],value:p.id==="MiniMax-M3.1-Flash"?e.m31ContextWindow??524288:p.contextWindow},{path:["provider","minimax","models",p.id,"limit","output"],value:p.maxTokens}]}),c=["MiniMax-M4","MiniMax-M3.1-Flash"].flatMap((p)=>{let u=["provider","minimax","models",p];return[{path:[...u,"interleaved"],value:{field:"reasoning_content"}},{path:[...u,"variants","none","disabled"],value:!0},{path:[...u,"variants","thinking","disabled"],value:!0},{path:[...u,"variants","default","reasoningEffort"],value:"max"},...["low","medium","high","xhigh","max"].map((f)=>({path:[...u,"variants",f,"reasoningEffort"],value:f}))]});return[{agent:"opencode",path:t,...n,after:ni(n.before,"OpenCode opencode.json",[{path:["provider","minimax","npm"],value:"@ai-sdk/openai-compatible"},{path:["provider","minimax","name"],value:"MiniMax"},{path:["provider","minimax","options","baseURL"],value:a.openai},{path:["provider","minimax","options","apiKey"],value:e.apiKey},{path:["provider","minimax","options","setCacheKey"],value:void 0},...l,...c,{path:["model"],value:`minimax/${e.model}`}])}]}function ZE(e,t){let[n,i]=t;if(!n||!i)throw new y("Hermes paths are incomplete.",b.GENERAL);let r=Oe(n),s=Oe(i),o=He(e.region),a=e.region==="cn"?"minimax-cn":"minimax",l=e.region==="cn"?"MINIMAX_CN_API_KEY":"MINIMAX_API_KEY";return[{agent:"hermes",path:n,...r,after:HE(r.before,a,e.model,o.anthropic)},{agent:"hermes",path:i,...s,after:WE(s.before,l,e.apiKey)}]}function eA(e,t){let[n,i]=t;if(!n||!i)throw new y("Pi paths are incomplete.",b.GENERAL);let r=Oe(n),s=Oe(i),o=on(r.before??"{}","Pi models.json"),a=He(e.region),l=e.region==="cn"?"minimax-cn":"minimax",c=o.providers;if(c!==void 0)W(c,"Pi models.json providers section must be an object.");let p=c?.[l];if(p!==void 0)W(p,`Pi models.json providers.${l} section must be an object.`);let u=p?.models;if(u!==void 0&&!Array.isArray(u))throw new y(`Pi models.json providers.${l}.models must be an array.`,b.GENERAL,Ve);let f=[{path:["providers",l,"name"],value:"MiniMax"},{path:["providers",l,"baseUrl"],value:a.anthropic},{path:["providers",l,"apiKey"],value:e.apiKey},{path:["providers",l,"api"],value:"anthropic-messages"}],g=le.map((h)=>({id:h.id,name:h.id,reasoning:!0,...h.id==="MiniMax-M3"?{compat:{forceAdaptiveThinking:!0,supportsTemperature:!1}}:{compat:{forceAdaptiveThinking:!0,supportsTemperature:!1},thinkingLevelMap:{off:null,minimal:null,xhigh:"xhigh",max:"max"}},input:[...h.input],contextWindow:h.contextWindow,maxTokens:h.maxTokens}));if(u===void 0)f.push({path:["providers",l,"models"],value:g});else{let h=u.length;for(let d of g){let m=u.findIndex((w)=>typeof w==="object"&&w!==null&&!Array.isArray(w)&&w.id===d.id),v=["providers",l,"models",m>=0?m:h++];if(m<0){f.push({path:v,value:d});continue}W(u[m],`Pi model definition for ${d.id} must be an object.`);for(let[w,x]of Object.entries(d)){if(w==="id")continue;if(w==="compat"||w==="thinkingLevelMap"){let E=u[m][w];if(E!==void 0)W(E,`Pi ${w} for ${d.id} must be an object.`);for(let[A,_]of Object.entries(x))f.push({path:[...v,w,A],value:_});continue}f.push({path:[...v,w],value:x})}}}return[{agent:"pi",path:n,...r,after:ni(r.before,"Pi models.json",f)},{agent:"pi",path:i,...s,after:ni(s.before,"Pi settings.json",[{path:["defaultProvider"],value:l},{path:["defaultModel"],value:e.model},...e.model==="MiniMax-M4"?[{path:["defaultThinkingLevel"],value:"max"}]:[]])}]}function tA(e,t){let n=e.region==="cn"?"minimax-cn":"minimax",i=He(e.region).anthropic;return t.map((r,s)=>{let o=Oe(r),a=`Oh my Pi ${tm(r)}`,l=Br(o.before??`{}
677
+ `);if(l.errors.length>0)throw new y(`${a} is not valid YAML.`,b.GENERAL,Ve);if(l.contents===null)l.set(s===0?"providers":"modelRoles",l.createNode({}));let c=l.toJS();if(W(c,`${a} must contain an object at its root.`),s===0){if(c.providers!==void 0)W(c.providers,`${a} providers must be an object.`);let p=c.providers?.[n];if(p!==void 0)W(p,`${a} provider must be an object.`);let u=p?.models;if(u!==void 0&&!Array.isArray(u))throw new y(`${a} models must be an array.`,b.GENERAL,Ve);let f=u??[];for(let d of f)W(d,`${a} model entries must be objects.`);let g=["providers",n];for(let[d,m]of Object.entries({baseUrl:i,apiKey:e.apiKey,api:"anthropic-messages",auth:"apiKey"}))l.setIn([...g,d],m);if(u===void 0)l.setIn([...g,"models"],l.createNode([]));let h=f.length;for(let d of le){let m=f.findIndex((x)=>x.id===d.id),v=[...g,"models",m>=0?m:h++],w={id:d.id,name:d.id,api:"anthropic-messages",baseUrl:i,reasoning:!0,input:[...d.input],contextWindow:d.contextWindow,maxTokens:d.maxTokens,...d.id!=="MiniMax-M3"?{thinking:{mode:"anthropic-adaptive",efforts:["low","medium","high","xhigh","max"],defaultLevel:"max",requiresEffort:!0,effortMap:{low:"low",medium:"medium",high:"high"}}}:{}};if(m<0)l.setIn(v,l.createNode(w));else for(let[x,E]of Object.entries(w))l.setIn([...v,x],l.createNode(E))}}else{if(c.modelRoles!==void 0)W(c.modelRoles,`${a} modelRoles must be an object.`);let p=e.model!=="MiniMax-M3"?":max":"";l.setIn(["modelRoles","default"],`${n}/${e.model}${p}`)}return{agent:"oh-my-pi",path:r,...o,after:l.toString()}})}function nA(e,t){let n=Oe(t),i="Zed settings.json",r=on(n.before??"{}","Zed settings.json"),s=r.language_models;if(s!==void 0)W(s,"Zed settings.json language_models must be an object.");let o=s?.openai_compatible;if(o!==void 0)W(o,"Zed settings.json language_models.openai_compatible must be an object.");let a=o?.minimax;if(a!==void 0)W(a,"Zed settings.json language_models.openai_compatible.minimax must be an object.");let l=a?.available_models;if(l!==void 0&&!Array.isArray(l))throw new y("Zed settings.json minimax available_models must be an array.",b.GENERAL,Ve);let c=r.agent;if(c!==void 0)W(c,"Zed settings.json agent must be an object.");let p=c?.default_model;if(p!==void 0)W(p,"Zed settings.json agent.default_model must be an object.");let u=(d)=>d!=="MiniMax-M3"?"max":"high",f=["language_models","openai_compatible","minimax"],g=le.map((d)=>({name:d.id,display_name:d.id,max_tokens:d.id==="MiniMax-M3.1-Flash"?e.m31ContextWindow??524288:d.contextWindow,max_output_tokens:d.maxTokens,reasoning_effort:u(d.id),capabilities:{tools:!0,images:d.input.some((m)=>m==="image"),parallel_tool_calls:!0,prompt_cache_key:!1,chat_completions:!0,interleaved_reasoning:!0,max_tokens_parameter:!1}})),h=[{path:[...f,"api_url"],value:He(e.region).openai}];if(l===void 0)h.push({path:[...f,"available_models"],value:g});else{let d=l.length;for(let m of g){let v=l.findIndex((w)=>typeof w==="object"&&w!==null&&w.name===m.name);h.push({path:[...f,"available_models",v>=0?v:d++],value:m})}}return h.push({path:["agent","default_model","provider"],value:"minimax"},{path:["agent","default_model","model"],value:e.model},{path:["agent","default_model","enable_thinking"],value:!0},{path:["agent","default_model","effort"],value:u(e.model)}),[{agent:"zed",path:t,...n,after:ni(n.before,"Zed settings.json",h)}]}function Ga(e){let t=[];for(let n of e.agents){let i=jE(n,e);switch(n){case"claude-code":t.push(...JE(e,i[0]));break;case"codex":t.push(...zE(e,i));break;case"grok":t.push(...XE(e,i[0]));break;case"opencode":t.push(...QE(e,i[0]));break;case"hermes":t.push(...ZE(e,i));break;case"pi":t.push(...eA(e,i));break;case"oh-my-pi":t.push(...tA(e,i));break;case"zed":t.push(...nA(e,i[0]));break}}return cm(t),t}function em(e,t,n){let i=nm(e);ME(i,{recursive:!0,mode:448});let r=H(i,`.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`),s=()=>{if(Ba(n)!==e)throw new y(`Configuration path changed while mmx was writing it: ${n}`,b.GENERAL)};try{s(),Ua(r,t,{encoding:"utf8",mode:384,flag:"wx"}),s(),RE(r,e)}catch(o){throw sn(r,{force:!0}),o}}function iA(e,t,n){for(let i=0;;i+=1){let r=`${e}.bak.${n}${i===0?"":`.${i}`}`;try{return Ua(r,t,{encoding:"utf8",mode:384,flag:"wx"}),r}catch(s){if(s.code==="EEXIST")continue;throw sn(r,{force:!0}),s}}}function rA(){return new Date().toISOString().replace(/[-:]/g,"").replace("T","-").replace(/\.\d{3}Z$/,"Z")}function Ba(e){let t=e,n=[];while(!0)try{return H(NE(t),...n)}catch(i){if(i.code!=="ENOENT")throw i;try{if(IE(t).isSymbolicLink())throw new y(`Configuration path contains a dangling symbolic link: ${e}`,b.GENERAL,"Fix the symbolic link and retry. No files were changed.")}catch(s){if(s instanceof y)throw s;if(s.code!=="ENOENT")throw s}let r=nm(t);if(r===t)return Kr(e);n.unshift(tm(t)),t=r}}function sA(e){return process.platform!=="win32"&&(e&63)!==0}function cm(e){let t=new Set;for(let n of e){if(t.has(n.targetPath))throw new y(`Multiple agent configuration paths resolve to ${n.targetPath}.`,b.GENERAL,"No files were changed. Use distinct configuration paths and retry.");t.add(n.targetPath)}}function oA(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}function um(){let e=typeof process.getuid==="function"?String(process.getuid()):(process.env.USERNAME??process.env.USER??"user").replace(/[^A-Za-z0-9_-]/g,"_"),t=H(FE(),`mmx-agent-setup-${e}.lock`),n=`${process.pid}:${Date.now()}:${Math.random().toString(16).slice(2)}`;try{let i=OE(t,"wx",384);try{Ua(i,`${n}
678
+ `,"utf8")}catch(s){if(Qp(i),rn(t)?.trim()===n)sn(t,{force:!0});throw s}let r=!1;return()=>{if(r)return;if(r=!0,Qp(i),rn(t)?.trim()===n)sn(t,{force:!0})}}catch(i){if(i.code!=="EEXIST")throw i;let s=(rn(t)?.trim()??"").match(/^(\d+):/),o=s?.[1]?Number(s[1]):void 0,a=o!==void 0&&!oA(o);throw new y(a?"A stale mmx agent setup lock exists.":"Another mmx agent setup is already running.",b.GENERAL,a?`Confirm no setup process is running, remove ${t}, then retry. No files were changed.`:"Wait for it to finish, then retry. No files were changed.")}}async function fm(e){let t=um(),n=new Map,i=()=>{for(let[r,s]of n)process.removeListener(r,s)};for(let[r,s]of[["SIGHUP",129],["SIGINT",130],["SIGTERM",143]]){let o=()=>{i(),t(),process.exit(s)};n.set(r,o),process.once(r,o)}process.once("exit",t);try{return await e()}finally{process.off("exit",t),i(),t()}}function dm(e,t=!1,n=!1){let i=t||n?void 0:um();try{let r=e.filter((u)=>u.before!==u.after);cm(e);let s=new Map,o=new Map;for(let u of e)if(u.before!==null&&nn(u.targetPath)){let f=LE(u.targetPath).mode&511;if(s.set(u,f),u.before===u.after&&sA(f))o.set(u,f)}if(t)return e.map((u)=>({agent:u.agent,path:u.path,status:u.before===u.after&&!o.has(u)?"unchanged":"would-configure"}));let a=(u,f)=>{if(Ba(u.path)!==u.targetPath||rn(u.targetPath)!==u.before)throw new y(`Configuration changed while mmx was preparing it: ${u.path}`,b.GENERAL,f)};for(let u of e)if(u.before!==u.after||o.has(u))a(u,"No files were changed. Retry the command.");let l=rA(),c=new Map,p=[];try{for(let u of r)if(u.before!==null)a(u,"No files were changed. Retry the command."),c.set(u.path,iA(u.targetPath,u.before,l));for(let u of e){if(!o.has(u))continue;a(u,"The completed writes were rolled back. Retry the command."),Fa(u.targetPath,384)}for(let u of r)a(u,"The completed writes were rolled back. Retry the command."),em(u.targetPath,u.after,u.path),p.push({file:u,target:u.targetPath})}catch(u){let f=[],g;for(let{file:h,target:d}of p.reverse())try{if(rn(d)!==h.after){f.push(h.path);continue}if(h.before===null)sn(d,{force:!0});else{em(d,h.before,h.path);let m=s.get(h);if(m!==void 0)Fa(d,m)}}catch(m){g??=m}for(let[h,d]of o)try{Fa(h.targetPath,d)}catch(m){g??=m}if(f.length===0&&g===void 0)for(let h of c.values())try{sn(h,{force:!0})}catch(d){g??=d}if(f.length>0||g!==void 0)throw new y("Could not fully roll back agent configuration.",b.GENERAL,`Review the affected files${c.size>0?` and backups: ${[...c.values()].join(", ")}`:"."}`);throw u}return e.map((u)=>({agent:u.agent,path:u.path,status:u.before===u.after&&!o.has(u)?"unchanged":"configured",...c.has(u.path)?{backup:c.get(u.path)}:{}}))}finally{i?.()}}var qE,DE,Hr="mmx-model-catalog.json",rm="mmx agent setup",Ve="Fix the existing configuration file and retry. No files were changed.";var Va=I(()=>{jf();yo();Xp();G();j();Vr();qE={insertSpaces:!0,tabSize:2,eol:`
679
679
  `},DE=/^[A-Za-z0-9_-]+$/});import{accessSync as aA,constants as pm,statSync as lA}from"fs";import{delimiter as cA,join as uA}from"path";function pA(e=process.env){let t=process.platform==="win32"?e.PATH??e.Path:e.PATH;if(t===void 0)return new Set;let n=t.split(cA).map((s)=>s.replace(/^"|"$/g,"")),i=process.platform==="win32"?(e.PATHEXT??".COM;.EXE;.BAT;.CMD").split(";"):[""],r=process.platform==="win32"?pm.F_OK:pm.X_OK;return new Set(Rt.filter((s)=>fA[s].some((o)=>n.some((a)=>i.some((l)=>{let c=uA(a,`${o}${l}`);try{if(!lA(c).isFile())return!1;return aA(c,r),!0}catch{return!1}})))))}function mm(e=process.env){let t=pA(e);if(e.CODEX_THREAD_ID?.trim())t.add("codex");for(let n of Rt){let i=dA[n];if(i!==void 0&&e[i[0]]===i[1])t.add(n)}return t}var fA,dA;var hm=I(()=>{Vr();fA={"claude-code":["claude"],codex:["codex"],grok:["grok","grok-build","grok-cli"],opencode:["opencode"],hermes:["hermes"],pi:["pi"],"oh-my-pi":["omp"],zed:["zed","zeditor"]},dA={"claude-code":["CLAUDE_CODE_CHILD_SESSION","1"],opencode:["OPENCODE_CLIENT","desktop"],hermes:["HERMES_AGENT","true"],pi:["PI_CODING_AGENT","true"]}});import{spawn as mA,spawnSync as wm}from"child_process";function EA(e,t){return wm(t==="win32"?"where.exe":e,t==="win32"?[e]:["--version"],{stdio:"ignore",timeout:5000}).status===0}function Ka(e,t={}){let n=t.platform??process.platform,i=t.arch??process.arch,r=t.nodeVersion??process.versions.node,s=t.commandExists??((l)=>EA(l,n));if(e==="zed")return"Install Zed from https://zed.dev/download.";if(!xA.has(n))return`Automated installation is not supported on ${n}.`;if(e!=="pi"&&!vA.has(i))return`Automated installation is not supported on ${n}/${i}.`;if(e==="pi"){let[l=0,c=0]=r.replace(/^v/,"").split(".").map(Number);if(l<22||l===22&&c<19)return`Pi requires Node.js 22.19 or newer (current: ${r}).`}let a=(e==="claude-code"||e==="grok"||e==="oh-my-pi"?n==="win32"?["powershell.exe"]:["bash","curl"]:e==="hermes"?n==="win32"?["powershell.exe"]:["bash","curl","git"]:n==="win32"?["cmd.exe","npm"]:["npm"]).filter((l)=>!s(l));if(a.length>0)return`Required command not found on PATH: ${a.join(", ")}.`;return}function AA(e,t){if(t==="win32"){let r=yA[e];if(e!=="hermes")return{executable:"powershell.exe",args:["-NoProfile","-ExecutionPolicy","Bypass","-Command",Ha+`$installer = Invoke-RestMethod '${r}'; & ([scriptblock]::Create($installer))${e==="oh-my-pi"?" -Binary":""}`],display:e==="oh-my-pi"?`& ([scriptblock]::Create((irm ${r}))) -Binary`:`irm ${r} | iex`};let s=wA.map((l)=>`'${l}'`).join(", "),o=`& { ${Ha}& $env:MMX_HERMES_INSTALLER -Stage $env:MMX_HERMES_STAGE -NonInteractive -SkipComputerUse -HermesHome $env:MMX_HERMES_HOME -InstallDir $env:MMX_HERMES_INSTALL_DIR }`,a="$ErrorActionPreference = 'Stop'; "+Ha+`$hermesHome = if ($env:HERMES_HOME) { $env:HERMES_HOME } else { Join-Path $env:USERPROFILE '.hermes' }; $installDir = Join-Path $hermesHome 'hermes-agent'; $installer = Join-Path ([IO.Path]::GetTempPath()) ('hermes-install-{0}.ps1' -f [guid]::NewGuid()); Invoke-WebRequest -UseBasicParsing -Uri '${r}' -OutFile $installer; try { foreach ($stage in @(${s})) { $env:MMX_HERMES_INSTALLER = $installer; $env:MMX_HERMES_STAGE = $stage; $env:MMX_HERMES_HOME = $hermesHome; $env:MMX_HERMES_INSTALL_DIR = $installDir; & powershell.exe -NoProfile -ExecutionPolicy Bypass -Command '${o}'; $code = $LASTEXITCODE; if ($code -ne 0) { throw "Hermes installer stage $stage failed with exit code $code." } } } finally { Remove-Item -LiteralPath $installer -Force -ErrorAction SilentlyContinue }`;return{executable:"powershell.exe",args:["-NoProfile","-ExecutionPolicy","Bypass","-Command",a],display:a}}let n=gA[e];if(e==="hermes"){let r=bA.join(" "),s=`set -e; installer=$(mktemp); trap 'rm -f "$installer"' EXIT; curl -fsSL ${n} -o "$installer"; for stage in ${r}; do bash "$installer" --stage "$stage" --non-interactive; done`;return{executable:"bash",args:["-c",s],display:s}}let i=`curl -fsSL ${n} | bash${e==="oh-my-pi"?" -s -- --binary":""}`;return{executable:"bash",args:["-c",`set -o pipefail; ${i}`],display:i}}function Wa(e,t=process.platform){if(e==="claude-code"||e==="grok"||e==="hermes"||e==="oh-my-pi")return AA(e,t);if(e==="zed")throw new y("Install Zed from https://zed.dev/download.",b.USAGE);let n=["install","-g",...e==="pi"?["--ignore-scripts","--engine-strict"]:[],hA[e]],i=`npm ${n.join(" ")}`;if(t==="win32")return{executable:"cmd.exe",args:["/d","/s","/c",i],display:i};return{executable:"npm",args:n,display:i}}function kA(e,t=process.platform){if(e==="oh-my-pi"){if(t==="win32")return{executable:"powershell.exe",args:["-NoProfile","-Command","$bin = if ($env:PI_INSTALL_DIR) { $env:PI_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA 'omp' }; & (Join-Path $bin 'omp.exe') --version"],display:"omp --version"};return{executable:"bash",args:["-c",'exec "${PI_INSTALL_DIR:-$HOME/.local/bin}/omp" --version'],display:"omp --version"}}if(e==="claude-code"||e==="grok"||e==="hermes"){let r=`${e==="claude-code"?"claude":e} --version`;if(t==="win32")return{executable:"powershell.exe",args:["-NoProfile","-Command",e==="claude-code"?"& (Join-Path $env:USERPROFILE '.local\\bin\\claude.exe') --version":e==="grok"?"$bin = if ($env:GROK_BIN_DIR) { $env:GROK_BIN_DIR } else { Join-Path $env:USERPROFILE '.grok\\bin' }; & (Join-Path $bin 'grok.exe') --version":"$home = if ($env:HERMES_HOME) { $env:HERMES_HOME } else { Join-Path $env:USERPROFILE '.hermes' }; $exe = Join-Path $home 'bin\\hermes.exe'; $cmd = Join-Path $home 'bin\\hermes.cmd'; if (Test-Path $exe) { & $exe --version } elseif (Test-Path $cmd) { & $cmd --version } else { exit 127 }"],display:r};return{executable:"bash",args:["-c",e==="claude-code"?'command -v claude >/dev/null 2>&1 && exec claude --version; exec "$HOME/.local/bin/claude" --version':e==="grok"?'command -v grok >/dev/null 2>&1 && exec grok --version; exec "${GROK_BIN_DIR:-$HOME/.grok/bin}/grok" --version':'command -v hermes >/dev/null 2>&1 && exec hermes --version; for bin in "$HOME/.local/bin/hermes" /usr/local/bin/hermes "${PREFIX:+$PREFIX/bin/hermes}"; do [ -n "$bin" ] && [ -x "$bin" ] && exec "$bin" --version; done; exit 127'],display:r}}if(e==="zed")return{executable:"zed",args:["--version"],display:"zed --version"};let n=`${gm[e]} --version`;if(t==="win32")return{executable:"cmd.exe",args:["/d","/s","/c",n],display:n};return{executable:gm[e],args:["--version"],display:n}}function TA(e){let t={...process.env},n=SA.some((i)=>Boolean(t[i]?.trim()));if(e&&!n)t.HTTPS_PROXY=e,t.https_proxy=e,t.HTTP_PROXY=e,t.http_proxy=e;return t}function IA(e){return e.pid!==void 0&&e.exitCode===null&&e.signalCode===null}function ym(e,t=!1){if(e.pid===void 0)return;if(process.platform==="win32"){if(wm("taskkill.exe",["/pid",String(e.pid),"/t","/f"],{stdio:"ignore",windowsHide:!0,timeout:5000}).status===0)return}else try{process.kill(-e.pid,t?"SIGKILL":"SIGTERM");return}catch(n){if(n.code==="ESRCH")return}if(IA(e))try{e.kill(t?"SIGKILL":"SIGTERM")}catch{}}async function bm(e,t){return new Promise((n,i)=>{let r=mA(e.executable,e.args,{detached:process.platform!=="win32",env:TA(t.proxy),stdio:["inherit",process.stderr,"inherit"]}),s=!1,o=["SIGHUP","SIGINT","SIGTERM"],a=new Map,l=()=>{for(let[f,g]of a)process.removeListener(f,g)},c=(f)=>{if(l(),ym(r,!0),process.listenerCount(f)===0)process.kill(process.pid,f)};for(let f of o){let g=()=>c(f);a.set(f,g),process.prependOnceListener(f,g)}let p=setTimeout(()=>{if(s)return;ym(r,!0),r.unref(),s=!0,l(),i(new Wr(t.timeoutMs))},t.timeoutMs);p.unref();let u=(f)=>{if(s)return;s=!0,clearTimeout(p),l(),f()};r.once("error",(f)=>u(()=>i(f))),r.once("exit",(f)=>u(()=>n(f??1)))})}async function xm(e,t={}){let n=Ka(e,t);if(n)throw new y(`Cannot install ${e}: ${n}`,b.GENERAL,"Leave it unselected and continue with configuration only.");let i=Wa(e,t.platform),r=kA(e,t.platform),s="Check internet access, DNS, firewall, and proxy settings, then retry.",o=e==="claude-code"||e==="grok"||e==="hermes"||e==="oh-my-pi"?`Run the official installer manually:
680
680
  ${i.display}`:`Run the installer manually:
681
681
  ${i.display}
@@ -694,16 +694,16 @@ Check your connection and try again.`);if(e===402)return new y("MiniMax quota or
694
694
  Check the quota or balance for this API key.`);if(e===429)return new y("MiniMax verification was rate limited (HTTP 429).",b.QUOTA,`No agent configuration files were changed.
695
695
  Wait and try again, or check the quota for this API key.`);if(e>=500)return new y(`MiniMax is temporarily unavailable (HTTP ${e}).`,b.GENERAL,`No agent configuration files were changed.
696
696
  Try again later.`);return new y(`MiniMax rejected the agent verification request (HTTP ${e}).`,b.GENERAL,`No agent configuration files were changed.
697
- Check the selected MiniMax region and model.`)}async function $m(e){let t=`${He(e.region).openai}/responses`,n=e.timeoutSeconds??30,i=MA.map((l)=>process.env[l]?.trim()).find((l)=>Boolean(l)),r=i??e.proxy,s=Boolean(i||e.proxy),o;try{let l={method:"POST",headers:{Authorization:`Bearer ${e.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({model:e.model,input:"Reply with exactly OK.",max_output_tokens:16,stream:!0}),signal:AbortSignal.timeout(n*1000)};if(r&&process.versions.bun)l.proxy=r;o=await fetch(t,l)}catch(l){throw Sm(l,t,n,s)}if(!o.ok)throw await o.body?.cancel().catch(()=>{return}),CA(o.status);let a=!1;try{for await(let l of qe(o)){let c;try{c=JSON.parse(l.data)}catch{continue}if(typeof c!=="object"||c===null||Array.isArray(c))continue;let p=c,u=p.response;if(p.type==="response.created"&&typeof u==="object"&&u!==null&&!Array.isArray(u)&&typeof u.id==="string"&&typeof u.model==="string"){a=!0;break}}}catch(l){throw Sm(l,t,n,s,!0)}finally{await o.body?.cancel().catch(()=>{return})}if(!a)throw new y("MiniMax returned an invalid agent verification response.",b.GENERAL,"No agent configuration files were changed. Check --region, --model, and the API key.");return{region:e.region,model:e.model,endpoint:t,status:"ok"}}var MA;var _m=I(()=>{G();j();Va();MA=["HTTPS_PROXY","https_proxy","HTTP_PROXY","http_proxy","ALL_PROXY","all_proxy"]});import{readFileSync as NA}from"fs";import{homedir as RA}from"os";import{isAbsolute as PA,join as Em,resolve as LA}from"path";function GA(e){if(e.startsWith("sk-cp-"))return"token-plan";if(e.startsWith("sk-api-"))return"paygo";return}function Am(e){if(!e.includes("codex"))return;let t=RA(),n=process.env.CODEX_HOME?.trim(),i=n?PA(n)?n:LA(t,n):Em(t,".codex");try{let r=NA(Em(i,"config.toml"),"utf8"),o=Et(r.charCodeAt(0)===65279?r.slice(1):r).model_providers;if(typeof o!=="object"||o===null||Array.isArray(o))return;let a=o.minimax;if(typeof a!=="object"||a===null||Array.isArray(a))return;let l=a.experimental_bearer_token;return typeof l==="string"&&l.trim()?l.trim():void 0}catch{return}}function BA(e,t,n){if(t==="json"||!n)return O(e,t);let i=ii.default.cyan,r=ii.default.green;return O({[i("verification")]:{[i("region")]:e.verification.region,[i("model")]:e.verification.model,[i("endpoint")]:e.verification.endpoint,[i("status")]:r(e.verification.status)},[i("agents")]:e.agents.map((s)=>r(s)),[i("files")]:e.files.map((s)=>({[i("agent")]:r(s.agent),[i("path")]:s.path,[i("status")]:r(s.status),...s.backup?{[i("backup")]:s.backup}:{}}))},"text")}function Ya(e){let t=[];for(let n of e){let i=n.trim().toLowerCase(),r=FA[i];if(!r)throw new y(`Unsupported agent "${n}".`,b.USAGE,`Supported agents: ${Rt.join(", ")}`);if(!t.includes(r))t.push(r)}return t}function VA(e){if(e._hasExplicitOptions===!0)return!1;return Object.values(e).every((t)=>t===void 0||t===!1)}async function HA(e,t,n=jA){let i=e.filter((a)=>!t.has(a));if(i.length===0)return[];let r=i.flatMap((a)=>{let l=n.getIssue(a);return l?[{agent:a,issue:l}]:[]});if(r.length>0)await n.note({title:"Unavailable installers",message:r.map(({agent:a,issue:l})=>`${Ke[a]}: ${l}`).join(`
697
+ Check the selected MiniMax region and model.`)}async function $m(e){let t=`${He(e.region).openai}/responses`,n=e.timeoutSeconds??30,i=MA.map((l)=>process.env[l]?.trim()).find((l)=>Boolean(l)),r=i??e.proxy,s=Boolean(i||e.proxy),o;try{let l={method:"POST",headers:{Authorization:`Bearer ${e.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({model:e.model,input:"Reply with exactly OK.",max_output_tokens:16,stream:!0}),signal:AbortSignal.timeout(n*1000)};if(r&&process.versions.bun)l.proxy=r;o=await fetch(t,l)}catch(l){throw Sm(l,t,n,s)}if(!o.ok)throw await o.body?.cancel().catch(()=>{return}),CA(o.status);let a=!1;try{for await(let l of qe(o)){let c;try{c=JSON.parse(l.data)}catch{continue}if(typeof c!=="object"||c===null||Array.isArray(c))continue;let p=c,u=p.response;if(p.type==="response.created"&&typeof u==="object"&&u!==null&&!Array.isArray(u)&&typeof u.id==="string"&&typeof u.model==="string"){a=!0;break}}}catch(l){throw Sm(l,t,n,s,!0)}finally{await o.body?.cancel().catch(()=>{return})}if(!a)throw new y("MiniMax returned an invalid agent verification response.",b.GENERAL,"No agent configuration files were changed. Check --region, --model, and the API key.");return{region:e.region,model:e.model,endpoint:t,status:"ok"}}var MA;var _m=I(()=>{G();j();Va();MA=["HTTPS_PROXY","https_proxy","HTTP_PROXY","http_proxy","ALL_PROXY","all_proxy"]});import{readFileSync as NA}from"fs";import{homedir as RA}from"os";import{isAbsolute as LA,join as Em,resolve as PA}from"path";function GA(e){if(e.startsWith("sk-cp-"))return"token-plan";if(e.startsWith("sk-api-"))return"paygo";return}function Am(e){if(!e.includes("codex"))return;let t=RA(),n=process.env.CODEX_HOME?.trim(),i=n?LA(n)?n:PA(t,n):Em(t,".codex");try{let r=NA(Em(i,"config.toml"),"utf8"),o=Et(r.charCodeAt(0)===65279?r.slice(1):r).model_providers;if(typeof o!=="object"||o===null||Array.isArray(o))return;let a=o.minimax;if(typeof a!=="object"||a===null||Array.isArray(a))return;let l=a.experimental_bearer_token;return typeof l==="string"&&l.trim()?l.trim():void 0}catch{return}}function BA(e,t,n){if(t==="json"||!n)return O(e,t);let i=ii.default.cyan,r=ii.default.green;return O({[i("verification")]:{[i("region")]:e.verification.region,[i("model")]:e.verification.model,[i("endpoint")]:e.verification.endpoint,[i("status")]:r(e.verification.status)},[i("agents")]:e.agents.map((s)=>r(s)),[i("files")]:e.files.map((s)=>({[i("agent")]:r(s.agent),[i("path")]:s.path,[i("status")]:r(s.status),...s.backup?{[i("backup")]:s.backup}:{}}))},"text")}function Ya(e){let t=[];for(let n of e){let i=n.trim().toLowerCase(),r=FA[i];if(!r)throw new y(`Unsupported agent "${n}".`,b.USAGE,`Supported agents: ${Rt.join(", ")}`);if(!t.includes(r))t.push(r)}return t}function VA(e){if(e._hasExplicitOptions===!0)return!1;return Object.values(e).every((t)=>t===void 0||t===!1)}async function HA(e,t,n=jA){let i=e.filter((a)=>!t.has(a));if(i.length===0)return[];let r=i.flatMap((a)=>{let l=n.getIssue(a);return l?[{agent:a,issue:l}]:[]});if(r.length>0)await n.note({title:"Unavailable installers",message:r.map(({agent:a,issue:l})=>`${Ke[a]}: ${l}`).join(`
698
698
  `)+`
699
699
 
700
700
  These agents will remain configuration-only.`});let s=i.filter((a)=>!r.some((l)=>l.agent===a));if(s.length===0)return[];let o=await n.select({message:"Select missing agents to install",choices:s.map((a)=>({value:a,label:Ke[a]})),initialValues:s,required:!1});if(o===void 0)throw new y("Agent setup cancelled.",b.GENERAL);return Ya(o)}async function KA(e,t,n={},i=UA){for(let r of e){let s=i.getCommand(r);await i.note({title:`Install ${Ke[r]}`,message:`$ ${s.display}`});try{await i.install(r,n),t.add(r)}catch(o){let a=o instanceof y?`${o.message}${o.hint?`
701
701
 
702
702
  ${o.hint}`:""}`:o instanceof Error?o.message:String(o);if(await i.note({title:"Installation failed",message:a}),!await i.confirm({message:`Continue and configure ${Ke[r]} without installing it?`}))throw o}}}async function WA(e,t){let n=await ks({message:"Select agents to configure",choices:Rt.map((d)=>({value:d,label:t.has(d)?Ke[d]:`${Ke[d]} (not detected on PATH)`})),initialValues:DA.filter((d)=>t.has(d)),required:!0});if(!n?.length)throw new y("Agent setup cancelled.",b.GENERAL);let i=Ya(n);if(i.includes("codex"))await gt({title:"Codex version recommendation",message:`Use Codex CLI ${ii.default.bold(ii.default.cyan("0.146.0"))} or newer for the complete MiniMax model catalog.`});let r=i.filter((d)=>!t.has(d)),s=await HA(i,t),o=await Si({message:"Select your MiniMax service region",choices:[{value:"global",label:"Global (minimax.io)"},{value:"cn",label:"Mainland China (minimax.cn)"}],initialValue:e.region});if(o!=="global"&&o!=="cn")throw new y("Agent setup cancelled.",b.GENERAL);let a=524288;if(i.some((d)=>d==="claude-code"||d==="codex"||d==="opencode"||d==="zed")){let d=await Si({message:"Choose the MiniMax-M3.1-Flash context window",choices:[{value:"512k",label:"512K (Recommended)"},{value:"1m",label:"1M"}],initialValue:"512k"});if(d!=="512k"&&d!=="1m")throw new y("Agent setup cancelled.",b.GENERAL);a=d==="1m"?1e6:524288}let l=Am(i),c;if(l)await gt({title:"Reusing existing Codex API key",message:`Found an existing MiniMax API key in ~/.codex/config.toml; it will be reused. To replace it, run mmx agent setup ${i.map((d)=>`--agent ${d}`).join(" ")} --region ${o} --api-key <key>.`});else{let d=await Si({message:"Choose an API key type",choices:Ja,initialValue:"token-plan"});if(c=Ja.find((m)=>m.value===d),!c)throw new y("Agent setup cancelled.",b.GENERAL);await gt({title:c.noteTitle,message:`${pt[o]}${c.pagePath}
703
703
 
704
- Copy the key, then paste it below.`}),l=(await Pl({message:c.prompt}))?.trim()}let p=l?GA(l):void 0;if(p&&c&&p!==c.value){let d=Ja.find((m)=>m.value===p);if(d)await gt({title:"API key type detected",message:`This looks like ${d.label}. ${d.hint}.`})}if(!l)throw new y("A MiniMax API key is required.",b.USAGE);let u=La,f=`Configure ${i.map((d)=>Ke[d]).join(", ")}? mmx will write configuration files.`;if(s.length>0)f+=` It will first install ${s.map((d)=>Ke[d]).join(", ")} using their official installers.`;let g=r.filter((d)=>!s.includes(d));if(g.length>0)f+=` Configuration only: ${g.map((d)=>Ke[d]).join(", ")}.`;if(!await bn({message:f}))throw new y("Agent setup cancelled.",b.GENERAL);return{agents:i,agentsToInstall:s,apiKey:l,region:o,model:u,m31ContextWindow:a}}function JA(e){if(e._positional?.length)throw new y("Unexpected positional argument.",b.USAGE,"Select agents with --agent <name> or --all.");let n=Ya(e.agent??[]),i=e.all?[...Rt]:n;if(i.length===0)throw new y("At least one --agent or --all is required in non-interactive mode.",b.USAGE,"mmx agent setup --agent codex --api-key <key> --region global");let r=e.m31ContextWindow;if(r!==void 0&&r!=="512k"&&r!=="1m")throw new y("Invalid --m31-context-window value.",b.USAGE,"Use --m31-context-window 512k or --m31-context-window 1m.");if(r!==void 0&&!i.some((l)=>l==="claude-code"||l==="codex"||l==="opencode"||l==="zed"))throw new y("--m31-context-window requires Claude Code, Codex, OpenCode, or Zed.",b.USAGE);if(e.region!=="global"&&e.region!=="cn")throw new y("--region global|cn is required in non-interactive mode.",b.USAGE,"Supplying the region makes scripts deterministic and prevents writing configs for the wrong service.");let s=e.apiKey?.trim()||Am(i);if(!s)throw new y("A MiniMax API key is required in non-interactive mode.",b.USAGE,`Pass --api-key <key>, or configure an existing Codex MiniMax provider Key.
705
- Token Plan keys (sk-cp-...) and pay-as-you-go keys (sk-api-...) use separate quotas.`);let o=(e.model??La).trim();if(!o)throw new y("--model must not be empty.",b.USAGE);let a=le.find((l)=>l.id===o)?.id;if(!a)throw new y(`Unsupported MiniMax model "${o}".`,b.USAGE,`Supported models: ${le.map((l)=>l.id).join(", ")}`);return{agents:i,agentsToInstall:[],apiKey:s,region:e.region,model:a,m31ContextWindow:r==="1m"?1e6:524288}}var ii,FA,Ke,qA=`Zed: paste your MiniMax API key in Agent Panel > Settings > minimax, or start Zed with MINIMAX_API_KEY set.
706
- `,DA,UA,jA,Ja,km;var Tm=I(()=>{yo();X();Va();hm();vm();Vr();_m();Ce();$e();G();j();ee();Le();ii=Ft(cn(),1),FA={claude:"claude-code",claudecode:"claude-code","claude-code":"claude-code",codex:"codex",grok:"grok","grok-build":"grok","grok-cli":"grok",opencode:"opencode",hermes:"hermes",pi:"pi","oh-my-pi":"oh-my-pi",omp:"oh-my-pi",zed:"zed"},Ke={"claude-code":"Claude Code",codex:"Codex",grok:"Grok CLI (Grok Build)",opencode:"OpenCode",hermes:"Hermes Agent",pi:"Pi","oh-my-pi":"Oh my Pi (omp)",zed:"Zed"},DA=["claude-code","codex"],UA={getCommand:Wa,install:xm,note:gt,confirm:bn},jA={select:ks,note:gt,getIssue:Ka},Ja=[{value:"token-plan",label:"Token Plan (sk-cp-...)",hint:"Uses plan quota and Credits",pagePath:"/user-center/payment/token-plan",noteTitle:"Get your Token Plan key",prompt:"Paste your Token Plan key"},{value:"paygo",label:"Pay-as-you-go (sk-api-...)",hint:"Uses account balance",pagePath:"/user-center/basic-information/interface-key",noteTitle:"Create a pay-as-you-go key",prompt:"Paste your pay-as-you-go key"}];km=N({name:"agent setup",description:"Configure coding agents using a MiniMax API key and optionally install missing agents",usage:"mmx agent setup [--agent <name> ... | --all] [--api-key <key>] [--region <region>] [--m31-context-window 512k|1m]",options:[{flag:"--agent <name>",description:"Agent: claude-code, codex, grok/grok-build, opencode, hermes, pi, oh-my-pi/omp, zed (repeatable)",type:"array"},{flag:"--api-key <key>",description:"API key; reuses an existing Codex MiniMax provider Key when --api-key is omitted. Token Plan (sk-cp) and pay-as-you-go (sk-api) keys are not interchangeable"},{flag:"--all",description:"Configure every supported agent"},{flag:"--model <model>",description:`Default model (${le.map((e)=>e.id).join(", ")})`},{flag:"--m31-context-window <size>",description:"MiniMax-M3.1-Flash window for Claude Code, Codex, and OpenCode: 512k (recommended) or 1m"}],examples:["mmx agent setup","mmx agent setup --agent claude-code --agent codex --api-key <key> --region global","mmx agent setup --all --api-key <key> --region cn --output json","mmx agent setup --agent opencode --api-key <key> --region cn --dry-run","mmx agent setup --agent codex --api-key <key> --region cn --m31-context-window 1m"],async run(e,t){let n=mm(),i=VA(t),r=i?await WA(e,n):JA(t),s=Z().proxy,o={region:r.region,model:r.model,endpoint:"",status:"skipped"};if(!e.dryRun){let f=()=>$m({apiKey:r.apiKey,region:r.region,model:r.model,timeoutSeconds:Math.min(e.timeout,60),proxy:s});o=i?await Ll({message:"Verifying API key with MiniMax...",successMessage:"API key verified.",errorMessage:"API key verification failed."},f):await f()}let a=async(f=!1)=>{let g=Ga(r);if(!e.dryRun){if(await KA(r.agentsToInstall,n,{proxy:s}),r.agentsToInstall.length>0)g=Ga(r)}return dm(g,e.dryRun,f)},c=!e.dryRun&&r.agentsToInstall.length>0?await fm(()=>a(!0)):await a(),p=F(e.output);if(console.log(BA({verification:o,agents:r.agents,files:c},p,i&&!e.noColor)),r.agents.includes("zed")&&!e.quiet)process.stderr.write(qA);let u=r.agents.filter((f)=>!n.has(f));if(!i&&u.length>0&&!e.quiet)process.stderr.write(`Warning: Not detected on PATH: ${u.map((f)=>Ke[f]).join(", ")}. mmx can write configuration files for them, but will not download or install them for you.
704
+ Copy the key, then paste it below.`}),l=(await Ll({message:c.prompt}))?.trim()}let p=l?GA(l):void 0;if(p&&c&&p!==c.value){let d=Ja.find((m)=>m.value===p);if(d)await gt({title:"API key type detected",message:`This looks like ${d.label}. ${d.hint}.`})}if(!l)throw new y("A MiniMax API key is required.",b.USAGE);let u=Pa,f=`Configure ${i.map((d)=>Ke[d]).join(", ")}? mmx will write configuration files.`;if(s.length>0)f+=` It will first install ${s.map((d)=>Ke[d]).join(", ")} using their official installers.`;let g=r.filter((d)=>!s.includes(d));if(g.length>0)f+=` Configuration only: ${g.map((d)=>Ke[d]).join(", ")}.`;if(!await bn({message:f}))throw new y("Agent setup cancelled.",b.GENERAL);return{agents:i,agentsToInstall:s,apiKey:l,region:o,model:u,m31ContextWindow:a}}function JA(e){if(e._positional?.length)throw new y("Unexpected positional argument.",b.USAGE,"Select agents with --agent <name> or --all.");let n=Ya(e.agent??[]),i=e.all?[...Rt]:n;if(i.length===0)throw new y("At least one --agent or --all is required in non-interactive mode.",b.USAGE,"mmx agent setup --agent codex --api-key <key> --region global");let r=e.m31ContextWindow;if(r!==void 0&&r!=="512k"&&r!=="1m")throw new y("Invalid --m31-context-window value.",b.USAGE,"Use --m31-context-window 512k or --m31-context-window 1m.");if(r!==void 0&&!i.some((l)=>l==="claude-code"||l==="codex"||l==="opencode"||l==="zed"))throw new y("--m31-context-window requires Claude Code, Codex, OpenCode, or Zed.",b.USAGE);if(e.region!=="global"&&e.region!=="cn")throw new y("--region global|cn is required in non-interactive mode.",b.USAGE,"Supplying the region makes scripts deterministic and prevents writing configs for the wrong service.");let s=e.apiKey?.trim()||Am(i);if(!s)throw new y("A MiniMax API key is required in non-interactive mode.",b.USAGE,`Pass --api-key <key>, or configure an existing Codex MiniMax provider Key.
705
+ Token Plan keys (sk-cp-...) and pay-as-you-go keys (sk-api-...) use separate quotas.`);let o=(e.model??Pa).trim();if(!o)throw new y("--model must not be empty.",b.USAGE);let a=le.find((l)=>l.id===o)?.id;if(!a)throw new y(`Unsupported MiniMax model "${o}".`,b.USAGE,`Supported models: ${le.map((l)=>l.id).join(", ")}`);return{agents:i,agentsToInstall:[],apiKey:s,region:e.region,model:a,m31ContextWindow:r==="1m"?1e6:524288}}var ii,FA,Ke,qA=`Zed: paste your MiniMax API key in Agent Panel > Settings > minimax, or start Zed with MINIMAX_API_KEY set.
706
+ `,DA,UA,jA,Ja,km;var Tm=I(()=>{yo();X();Va();hm();vm();Vr();_m();Ce();$e();G();j();ee();Pe();ii=Ft(cn(),1),FA={claude:"claude-code",claudecode:"claude-code","claude-code":"claude-code",codex:"codex",grok:"grok","grok-build":"grok","grok-cli":"grok",opencode:"opencode",hermes:"hermes",pi:"pi","oh-my-pi":"oh-my-pi",omp:"oh-my-pi",zed:"zed"},Ke={"claude-code":"Claude Code",codex:"Codex",grok:"Grok CLI (Grok Build)",opencode:"OpenCode",hermes:"Hermes Agent",pi:"Pi","oh-my-pi":"Oh my Pi (omp)",zed:"Zed"},DA=["claude-code","codex"],UA={getCommand:Wa,install:xm,note:gt,confirm:bn},jA={select:ks,note:gt,getIssue:Ka},Ja=[{value:"token-plan",label:"Token Plan (sk-cp-...)",hint:"Uses plan quota and Credits",pagePath:"/user-center/payment/token-plan",noteTitle:"Get your Token Plan key",prompt:"Paste your Token Plan key"},{value:"paygo",label:"Pay-as-you-go (sk-api-...)",hint:"Uses account balance",pagePath:"/user-center/basic-information/interface-key",noteTitle:"Create a pay-as-you-go key",prompt:"Paste your pay-as-you-go key"}];km=N({name:"agent setup",description:"Configure coding agents using a MiniMax API key and optionally install missing agents",usage:"mmx agent setup [--agent <name> ... | --all] [--api-key <key>] [--region <region>] [--m31-context-window 512k|1m]",options:[{flag:"--agent <name>",description:"Agent: claude-code, codex, grok/grok-build, opencode, hermes, pi, oh-my-pi/omp, zed (repeatable)",type:"array"},{flag:"--api-key <key>",description:"API key; reuses an existing Codex MiniMax provider Key when --api-key is omitted. Token Plan (sk-cp) and pay-as-you-go (sk-api) keys are not interchangeable"},{flag:"--all",description:"Configure every supported agent"},{flag:"--model <model>",description:`Default model (${le.map((e)=>e.id).join(", ")})`},{flag:"--m31-context-window <size>",description:"MiniMax-M3.1-Flash window for Claude Code, Codex, and OpenCode: 512k (recommended) or 1m"}],examples:["mmx agent setup","mmx agent setup --agent claude-code --agent codex --api-key <key> --region global","mmx agent setup --all --api-key <key> --region cn --output json","mmx agent setup --agent opencode --api-key <key> --region cn --dry-run","mmx agent setup --agent codex --api-key <key> --region cn --m31-context-window 1m"],async run(e,t){let n=mm(),i=VA(t),r=i?await WA(e,n):JA(t),s=Z().proxy,o={region:r.region,model:r.model,endpoint:"",status:"skipped"};if(!e.dryRun){let f=()=>$m({apiKey:r.apiKey,region:r.region,model:r.model,timeoutSeconds:Math.min(e.timeout,60),proxy:s});o=i?await Pl({message:"Verifying API key with MiniMax...",successMessage:"API key verified.",errorMessage:"API key verification failed."},f):await f()}let a=async(f=!1)=>{let g=Ga(r);if(!e.dryRun){if(await KA(r.agentsToInstall,n,{proxy:s}),r.agentsToInstall.length>0)g=Ga(r)}return dm(g,e.dryRun,f)},c=!e.dryRun&&r.agentsToInstall.length>0?await fm(()=>a(!0)):await a(),p=F(e.output);if(console.log(BA({verification:o,agents:r.agents,files:c},p,i&&!e.noColor)),r.agents.includes("zed")&&!e.quiet)process.stderr.write(qA);let u=r.agents.filter((f)=>!n.has(f));if(!i&&u.length>0&&!e.quiet)process.stderr.write(`Warning: Not detected on PATH: ${u.map((f)=>Ke[f]).join(", ")}. mmx can write configuration files for them, but will not download or install them for you.
707
707
  `)}})});class Im{root={children:new Map};constructor(e){for(let[t,n]of Object.entries(e))this.register(t,n)}register(e,t){let n=e.split(" "),i=this.root;for(let r of n){if(!i.children.has(r))i.children.set(r,{children:new Map});i=i.children.get(r)}i.command=t}getAllCommands(){let e=new Set,t=[],n=(i)=>{if(i.command&&!e.has(i.command))e.add(i.command),t.push(i.command);for(let r of i.children.values())n(r)};return n(this.root),t}resolve(e){let t=this.root,n=[];for(let i of e){let r=t.children.get(i);if(!r)break;t=r,n.push(i)}if(t.command)return{command:t.command,extra:e.slice(n.length)};if(n.length>0&&t.children.size===1){let[,i]=t.children.entries().next().value;if(i.command)return{command:i.command,extra:e.slice(n.length)}}if(n.length>0&&t.children.size>1){let r=Array.from(t.children.values()).map((o)=>o.command),s=r[0];if(s&&r.every((o)=>o===s))return{command:s,extra:e.slice(n.length)}}if(n.length>0&&t.children.size>0){let i=Array.from(t.children.entries()).map(([r,s])=>{if(s.command)return` ${n.join(" ")} ${r} ${s.command.description}`;let o=Array.from(s.children.keys()).join(", ");return` ${n.join(" ")} ${r} [${o}]`}).join(`
708
708
  `);throw new y(`Unknown command: mmx ${e.join(" ")}
709
709
 
@@ -765,7 +765,7 @@ ${i("API Reference:")} ${s(pt[n]+e.apiDocs)}
765
765
  ${s("Global flags (--api-key, --output, --quiet, etc.) are always available.")}
766
766
  `),t.write(`${s("Run")} mmx --help ${s("for the full list.")}
767
767
  `)}printChildren(e,t,n){let i=[],r=(o,a)=>{for(let[l,c]of o.children){if(c.command)i.push({fullName:`${a} ${l}`,description:c.command.description});if(c.children.size>0)r(c,`${a} ${l}`)}};r(e,t);let s=Math.max(...i.map((o)=>o.fullName.length));for(let{fullName:o,description:a}of i)n.write(` ${this.accent(o.padEnd(s),n)} ${this.dim(a,n)}
768
- `)}}var Te;var Pi=I(()=>{G();j();$e();Ic();Oc();Nc();Pc();Uc();Hc();ru();mu();gu();ju();Wu();Yu();Xu();Qu();ef();nf();sf();cf();ff();pf();hf();yf();wf();vf();Tm();Te=new Im({"auth login":Tc,"auth status":Mc,"auth refresh":Cc,"auth logout":Rc,"text chat":Dc,"text repl":Vc,"speech synthesize":Ws,"speech generate":Ws,"speech transcribe":Xs,"speech recognize":Xs,"speech voices":hu,"image generate":Uu,"video generate":Ku,"video task get":Ju,"video download":zu,"search query":co,"search web":co,"vision describe":Zu,"quota show":tf,"config show":rf,"config set":lf,"config export-schema":uf,"file upload":df,"file list":mf,"file delete":gf,update:bf,help:xf,"agent setup":km})});var Gm=new Set(["true","1","yes","on"]),Bm=new Set(["false","0","no","off"]);function ri(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function Vm(e){let t=e.flag.match(/^--([a-z][a-z0-9-]*)/i);return t?ri(t[1]):null}function Hm(e){if(e.type==="boolean")return!0;if(e.type==="string"||e.type==="number"||e.type==="array")return!1;return!e.flag.includes("<")&&!e.flag.includes("[")}function Jr(e){let t=new Set,n=new Set,i=new Set,r=new Set;for(let s of e){let o=Vm(s);if(!o)continue;if(r.add(o),Hm(s))t.add(o);else if(s.type==="number")n.add(o);else if(s.type==="array")i.add(o)}return{booleans:t,numbers:n,arrays:i,keys:r}}function Za(e,t){let n=Jr(t),i=0;while(i<e.length){let r=e[i];if(r==="--")break;if(r.startsWith("--")){let s=r.indexOf("="),o=s===-1?r.slice(2):r.slice(2,s),a=ri(o);if(!n.keys.has(a))return`Unknown option: --${o}`;if(s!==-1&&!n.booleans.has(a)&&r.slice(s+1).trim()==="")return`Option --${o} requires a value.`;if(s===-1&&!n.booleans.has(a)){let l=e[i+1];if(l===void 0||l.startsWith("-"))return`Option --${o} requires a value.`;i+=2;continue}i+=1;continue}if(r.startsWith("-")&&r!=="-h"&&r!=="-v")return`Unknown option: ${r}`;i+=1}return}function Yr(e,t=[]){let n=Jr(t),i=[],r=0;while(r<e.length){let s=e[r];if(s==="--")break;if(s.startsWith("--")){let o=s.indexOf("="),a=o!==-1?s.slice(2,o):s.slice(2),l=ri(a);if(!n.booleans.has(l)&&o===-1)r+=2;else r+=1;continue}if(s.startsWith("-")){r++;continue}i.push(s),r++}return i}function zr(e,t){let n=Jr(t),i={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},r=0;while(r<e.length){let s=e[r];if(s==="--help"||s==="-h"){i.help=!0,r++;continue}if(s==="--")break;if(s.startsWith("--")){let o=s.indexOf("="),a,l;if(o!==-1)a=s.slice(2,o),l=s.slice(o+1);else a=s.slice(2);let c=ri(a);if(n.booleans.has(c)){if(l===void 0)i[c]=!0;else{let p=l.trim().toLowerCase();if(Gm.has(p))i[c]=!0;else if(Bm.has(p))i[c]=!1;else throw Error(`Flag --${a} requires a boolean value (e.g. true/false), got "${l}".`)}r++;continue}if(l===void 0)r++,l=e[r];if(l===void 0)throw Error(`Flag --${a} requires a value.`);if(n.arrays.has(c)){let p=i[c];if(p)p.push(l);else i[c]=[l]}else if(n.numbers.has(c)){let p=Number(l);if(l.trim()===""||!Number.isFinite(p))throw Error(`Flag --${a} requires a numeric value, got "${l}".`);i[c]=p}else i[c]=l}r++}return i}Pi();X();G();j();G();j();ee();function Lt(e){if(e instanceof y){if(F(process.env.MINIMAX_OUTPUT)==="json")process.stderr.write(JSON.stringify(e.toJSON(),null,2)+`
768
+ `)}}var Te;var Li=I(()=>{G();j();$e();Ic();Oc();Nc();Lc();Uc();Hc();ru();mu();gu();ju();Wu();Yu();Xu();Qu();ef();nf();sf();cf();ff();pf();hf();yf();wf();vf();Tm();Te=new Im({"auth login":Tc,"auth status":Mc,"auth refresh":Cc,"auth logout":Rc,"text chat":Dc,"text repl":Vc,"speech synthesize":Ws,"speech generate":Ws,"speech transcribe":Xs,"speech recognize":Xs,"speech voices":hu,"image generate":Uu,"video generate":Ku,"video task get":Ju,"video download":zu,"search query":co,"search web":co,"vision describe":Zu,"quota show":tf,"config show":rf,"config set":lf,"config export-schema":uf,"file upload":df,"file list":mf,"file delete":gf,update:bf,help:xf,"agent setup":km})});var Gm=new Set(["true","1","yes","on"]),Bm=new Set(["false","0","no","off"]);function ri(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function Vm(e){let t=e.flag.match(/^--([a-z][a-z0-9-]*)/i);return t?ri(t[1]):null}function Hm(e){if(e.type==="boolean")return!0;if(e.type==="string"||e.type==="number"||e.type==="array")return!1;return!e.flag.includes("<")&&!e.flag.includes("[")}function Jr(e){let t=new Set,n=new Set,i=new Set,r=new Set;for(let s of e){let o=Vm(s);if(!o)continue;if(r.add(o),Hm(s))t.add(o);else if(s.type==="number")n.add(o);else if(s.type==="array")i.add(o)}return{booleans:t,numbers:n,arrays:i,keys:r}}function Za(e,t){let n=Jr(t),i=0;while(i<e.length){let r=e[i];if(r==="--")break;if(r.startsWith("--")){let s=r.indexOf("="),o=s===-1?r.slice(2):r.slice(2,s),a=ri(o);if(!n.keys.has(a))return`Unknown option: --${o}`;if(s!==-1&&!n.booleans.has(a)&&r.slice(s+1).trim()==="")return`Option --${o} requires a value.`;if(s===-1&&!n.booleans.has(a)){let l=e[i+1];if(l===void 0||l.startsWith("-"))return`Option --${o} requires a value.`;i+=2;continue}i+=1;continue}if(r.startsWith("-")&&r!=="-h"&&r!=="-v")return`Unknown option: ${r}`;i+=1}return}function Yr(e,t=[]){let n=Jr(t),i=[],r=0;while(r<e.length){let s=e[r];if(s==="--")break;if(s.startsWith("--")){let o=s.indexOf("="),a=o!==-1?s.slice(2,o):s.slice(2),l=ri(a);if(!n.booleans.has(l)&&o===-1)r+=2;else r+=1;continue}if(s.startsWith("-")){r++;continue}i.push(s),r++}return i}function zr(e,t){let n=Jr(t),i={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},r=0;while(r<e.length){let s=e[r];if(s==="--help"||s==="-h"){i.help=!0,r++;continue}if(s==="--")break;if(s.startsWith("--")){let o=s.indexOf("="),a,l;if(o!==-1)a=s.slice(2,o),l=s.slice(o+1);else a=s.slice(2);let c=ri(a);if(n.booleans.has(c)){if(l===void 0)i[c]=!0;else{let p=l.trim().toLowerCase();if(Gm.has(p))i[c]=!0;else if(Bm.has(p))i[c]=!1;else throw Error(`Flag --${a} requires a boolean value (e.g. true/false), got "${l}".`)}r++;continue}if(l===void 0)r++,l=e[r];if(l===void 0)throw Error(`Flag --${a} requires a value.`);if(n.arrays.has(c)){let p=i[c];if(p)p.push(l);else i[c]=[l]}else if(n.numbers.has(c)){let p=Number(l);if(l.trim()===""||!Number.isFinite(p))throw Error(`Flag --${a} requires a numeric value, got "${l}".`);i[c]=p}else i[c]=l}r++}return i}Li();X();G();j();G();j();ee();function Pt(e){if(e instanceof y){if(F(process.env.MINIMAX_OUTPUT)==="json")process.stderr.write(JSON.stringify(e.toJSON(),null,2)+`
769
769
  `);else{if(process.stderr.write(`
770
770
  Error: ${e.message}
771
771
  `),e.hint)process.stderr.write(`
@@ -776,10 +776,10 @@ Error: ${e.message}
776
776
  `)}process.exit(e.exitCode)}if(e instanceof Error){if(e.name==="AbortError"||e.name==="TimeoutError"||e.message.includes("timed out")){let r=new y("Request timed out.",b.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
777
777
  If this happens on every request with a valid API key, you may be hitting the wrong region.
778
778
  `+`Run: mmx auth status — to check your credentials and region.
779
- `+"Run: mmx config set region global (or cn) — to override the region.");return Lt(r)}if(e instanceof TypeError&&e.message==="fetch failed"){let r=new y("Network request failed.",b.NETWORK,`Check your network connection.
780
- To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`);return Lt(r)}let t=e.message.toLowerCase();if(t.includes("failed to fetch")||t.includes("connection refused")||t.includes("econnrefused")||t.includes("connection reset")||t.includes("econnreset")||t.includes("network error")||t.includes("enotfound")||t.includes("getaddrinfo")||t.includes("proxy")||t.includes("socket")||t.includes("etimedout")||t.includes("timeout")||t.includes("eai_AGAIN")){let r=`Check your network connection.
779
+ `+"Run: mmx config set region global (or cn) — to override the region.");return Pt(r)}if(e instanceof TypeError&&e.message==="fetch failed"){let r=new y("Network request failed.",b.NETWORK,`Check your network connection.
780
+ To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`);return Pt(r)}let t=e.message.toLowerCase();if(t.includes("failed to fetch")||t.includes("connection refused")||t.includes("econnrefused")||t.includes("connection reset")||t.includes("econnreset")||t.includes("network error")||t.includes("enotfound")||t.includes("getaddrinfo")||t.includes("proxy")||t.includes("socket")||t.includes("etimedout")||t.includes("timeout")||t.includes("eai_AGAIN")){let r=`Check your network connection.
781
781
  To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`;if(t.includes("proxy"))r=`Proxy connection failed — verify your proxy URL and authentication.
782
- `+"Check: HTTPS_PROXY / HTTP_PROXY env vars, or mmx config show for configured proxy.";let s=new y("Network request failed.",b.NETWORK,r);return Lt(s)}let i=e.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 s=new y(`File system error: ${e.message}`,b.GENERAL,r);return Lt(s)}else if(typeof i==="string"&&i.startsWith("E")){let r=new y(`File system error: ${e.message}`,b.GENERAL,"Check the file path and permissions.");return Lt(r)}if(process.stderr.write(`
782
+ `+"Check: HTTPS_PROXY / HTTP_PROXY env vars, or mmx config show for configured proxy.";let s=new y("Network request failed.",b.NETWORK,r);return Pt(s)}let i=e.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 s=new y(`File system error: ${e.message}`,b.GENERAL,r);return Pt(s)}else if(typeof i==="string"&&i.startsWith("E")){let r=new y(`File system error: ${e.message}`,b.GENERAL,"Check the file path and permissions.");return Pt(r)}if(process.stderr.write(`
783
783
  Error: ${e.message}
784
784
  `),process.env.MINIMAX_VERBOSE==="1")process.stderr.write(`${e.stack}
785
785
  `)}else process.stderr.write(`
@@ -794,4 +794,4 @@ Interrupted. Exiting.
794
794
  Update available: ${h}
795
795
  `),process.stderr.write(` npm update -g mmx-cli
796
796
 
797
- `)}ak().catch(Lt);
797
+ `)}ak().catch(Pt);