aicommit2 1.12.3 → 1.12.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +20 -12
  2. package/dist/cli.mjs +59 -59
  3. package/package.json +6 -3
package/README.md CHANGED
@@ -21,7 +21,15 @@
21
21
 
22
22
  ## Introduction
23
23
 
24
- _aicommit2_ streamlines interactions with various AI, enabling users to request multiple AI simultaneously and select the most suitable commit message without waiting for all AI responses. The core functionalities and architecture of this project are inspired by [AICommits](https://github.com/Nutlope/aicommits).
24
+ _aicommit2_ is a reactive CLI tool that automatically generates Git commit messages using various AI models. It supports simultaneous requests to multiple AI providers, allowing users to select the most suitable commit message. The core functionalities and architecture of this project are inspired by [AICommits](https://github.com/Nutlope/aicommits).
25
+
26
+ ## Key Features
27
+
28
+ - **Multi-AI Support**: Integrates with OpenAI, Anthropic Claude, Google Gemini, Mistral AI, Cohere, Groq, Huggingface.
29
+ - **Local Model Support**: Use local AI models via Ollama.
30
+ - **Reactive CLI**: Enables simultaneous requests to multiple AIs and selection of the best commit message.
31
+ - **Git Hook Integration**: Can be used as a prepare-commit-msg hook.
32
+ - **Custom Prompts**: Supports user-defined prompt templates.
25
33
 
26
34
  ## Supported Providers
27
35
 
@@ -332,7 +340,7 @@ aicommit2 config set OPENAI_KEY=<your-api-key> generate=3 locale=en
332
340
  | `temperature` | `0.7` | The temperature (0.0-2.0) is used to control the randomness of the output (for **Open AI, Anthropic, Gemini, Mistral, Codestral**) |
333
341
  | `promptPath` | N/A | Allow users to specify a custom file path for their own prompt template |
334
342
  | `logging` | `false` | Whether to log AI responses for debugging (true or false) |
335
- | `ignoreBody` | `false` | Whether the commit message includes body (true or false) |
343
+ | `ignoreBody` | `true` | Whether the commit message includes body (true or false) |
336
344
 
337
345
  > **Currently, options are set universally. However, there are plans to develop the ability to set individual options in the future.**
338
346
 
@@ -380,7 +388,7 @@ aicommit2 config set proxy=
380
388
 
381
389
  ##### timeout
382
390
 
383
- The timeout for network requests to the OpenAI API in milliseconds.
391
+ The timeout for network requests to AI in milliseconds.
384
392
 
385
393
  Default: `10_000` (10 seconds)
386
394
 
@@ -464,23 +472,22 @@ aicommit2 log removeAll
464
472
 
465
473
  ##### ignoreBody
466
474
 
467
- Default: `false`
475
+ Default: `true`
468
476
 
469
- This option determines whether the commit message includes body. If you don't want to include body in message, you can set it to `true`.
477
+ This option determines whether the commit message includes body. If you want to include body in message, you can set it to `false`.
470
478
 
471
479
  ```sh
472
- aicommit2 config set ignoreBody="true"
480
+ aicommit2 config set ignoreBody="false"
473
481
  ```
474
482
 
475
- ![ignore_body_true](https://github.com/tak-bro/aicommit2/blob/main/img/ignore_body_true.png?raw=true)
483
+ ![ignore_body_false](https://github.com/tak-bro/aicommit2/blob/main/img/ignore_body_false.png?raw=true)
476
484
 
477
485
 
478
486
  ```sh
479
- aicommit2 config set ignoreBody="false"
487
+ aicommit2 config set ignoreBody="true"
480
488
  ```
481
489
 
482
- ![ignore_body_false](https://github.com/tak-bro/aicommit2/blob/main/img/ignore_body_false.png?raw=true)
483
-
490
+ ![ignore_body_true](https://github.com/tak-bro/aicommit2/blob/main/img/ignore_body_true.png?raw=true)
484
491
 
485
492
  ### Ollama
486
493
 
@@ -510,7 +517,7 @@ Default: `100_000` (100 seconds)
510
517
  Request timeout for the Ollama. Default OLLAMA_TIMEOUT is **100 seconds** because it can take a long time to run locally.
511
518
 
512
519
  ```sh
513
- aicommit2 config set OLLAMA_TIMEOUT=<timout>
520
+ aicommit2 config set OLLAMA_TIMEOUT=<timeout>
514
521
  ```
515
522
 
516
523
  ### OPEN AI
@@ -655,7 +662,7 @@ Default: `gemma-7b-it`
655
662
 
656
663
  Supported:
657
664
  - `llama3-8b-8192`
658
- - 'llama3-70b-8192'
665
+ - `llama3-70b-8192`
659
666
  - `mixtral-8x7b-32768`
660
667
  - `gemma-7b-it`
661
668
 
@@ -746,6 +753,7 @@ Example response format:
746
753
  "body": "string",
747
754
  "footer": "string"
748
755
  },
756
+ ...
749
757
  ]
750
758
  ```
751
759
 
package/dist/cli.mjs CHANGED
@@ -1,31 +1,31 @@
1
1
  #!/usr/bin/env node
2
- import Le from"tty";import{createRequire as vn}from"module";import k from"fs";import P from"path";import{Buffer as $n}from"node:buffer";import J from"node:path";import kt,{ChildProcess as Bn}from"node:child_process";import I from"node:process";import On from"child_process";import{fileURLToPath as jt}from"node:url";import xn,{constants as Gt}from"node:os";import Ht from"assert";import Ut from"events";import{createWriteStream as Mn,createReadStream as Sn}from"node:fs";import Pn from"buffer";import Re from"stream";import Kt from"util";import{debuglog as In}from"node:util";import Ne from"inquirer";import ke from"ora";import g from"chalk";import{of as x,concatMap as j,from as S,map as _,catchError as T,mergeMap as qt,BehaviorSubject as zt,ReplaySubject as _n,lastValueFrom as Tn,filter as Ln,toArray as Rn}from"rxjs";import Nn from"@anthropic-ai/sdk";import{fromPromise as G}from"rxjs/internal/observable/innerFrom";import je from"os";import{xxh64 as kn}from"@pacote/xxhash";import jn from"axios";import{CohereClient as Gn,CohereTimeoutError as Hn}from"cohere-ai";import{GoogleGenerativeAI as Un}from"@google/generative-ai";import Kn from"groq-sdk";import{Ollama as qn}from"ollama";import O from"fs/promises";import zn from"http";import Yn from"https";import Wn from"net";import Jn from"tls";import Vn,{fileURLToPath as Xn,pathToFileURL as Qn}from"url";import Fe from"readline";import Zn from"figlet";import eo from"inquirer-reactive-list-prompt";import{rm as to}from"node:fs/promises";const ro="known-flag",no="unknown-flag",oo="argument",{stringify:ie}=JSON,so=/\B([A-Z])/g,uo=e=>e.replace(so,"-$1").toLowerCase(),{hasOwnProperty:io}=Object.prototype,ae=(e,t)=>io.call(e,t),ao=e=>Array.isArray(e),Yt=e=>typeof e=="function"?[e,!1]:ao(e)?[e[0],!0]:Yt(e.type),co=(e,t)=>e===Boolean?t!=="false":t,Do=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),lo=/[\s.:=]/,fo=e=>{const t=`Flag name ${ie(e)}`;if(e.length===0)throw new Error(`${t} cannot be empty`);if(e.length===1)throw new Error(`${t} must be longer than a character`);const n=e.match(lo);if(n)throw new Error(`${t} cannot contain ${ie(n?.[0])}`)},po=e=>{const t={},n=(r,o)=>{if(ae(t,r))throw new Error(`Duplicate flags named ${ie(r)}`);t[r]=o};for(const r in e){if(!ae(e,r))continue;fo(r);const o=e[r],s=[[],...Yt(o),o];n(r,s);const u=uo(r);if(r!==u&&n(u,s),"alias"in o&&typeof o.alias=="string"){const{alias:i}=o,c=`Flag alias ${ie(i)} for flag ${ie(r)}`;if(i.length===0)throw new Error(`${c} cannot be empty`);if(i.length>1)throw new Error(`${c} must be a single character`);n(i,s)}}return t},mo=(e,t)=>{const n={};for(const r in e){if(!ae(e,r))continue;const[o,,s,u]=t[r];if(o.length===0&&"default"in u){let{default:i}=u;typeof i=="function"&&(i=i()),n[r]=i}else n[r]=s?o:o.pop()}return n},ye="--",ho=/[.:=]/,go=/^-{1,2}\w/,Co=e=>{if(!go.test(e))return;const t=!e.startsWith(ye);let n=e.slice(t?1:2),r;const o=n.match(ho);if(o){const{index:s}=o;r=n.slice(s+1),n=n.slice(0,s)}return[n,r,t]},Eo=(e,{onFlag:t,onArgument:n})=>{let r;const o=(s,u)=>{if(typeof r!="function")return!0;r(s,u),r=void 0};for(let s=0;s<e.length;s+=1){const u=e[s];if(u===ye){o();const c=e.slice(s+1);n?.(c,[s],!0);break}const i=Co(u);if(i){if(o(),!t)continue;const[c,l,f]=i;if(f)for(let a=0;a<c.length;a+=1){o();const D=a===c.length-1;r=t(c[a],D?l:void 0,[s,a+1,D])}else r=t(c,l,[s])}else o(u,[s])&&n?.([u],[s])}o()},Fo=(e,t)=>{for(const[n,r,o]of t.reverse()){if(r){const s=e[n];let u=s.slice(0,r);if(o||(u+=s.slice(r+1)),u!=="-"){e[n]=u;continue}}e.splice(n,1)}},yo=(e,t=process.argv.slice(2),{ignore:n}={})=>{const r=[],o=po(e),s={},u=[];return u[ye]=[],Eo(t,{onFlag(i,c,l){const f=ae(o,i);if(!n?.(f?ro:no,i,c)){if(f){const[a,D]=o[i],p=co(D,c),d=(h,m)=>{r.push(l),m&&r.push(m),a.push(Do(D,h||""))};return p===void 0?d:d(p)}ae(s,i)||(s[i]=[]),s[i].push(c===void 0?!0:c),r.push(l)}},onArgument(i,c,l){n?.(oo,t[c[0]])||(u.push(...i),l?(u[ye]=i,t.splice(c[0])):r.push(c))}}),Fo(t,r),{flags:mo(e,o),unknownFlags:s,_:u}};var bo=Object.create,be=Object.defineProperty,wo=Object.defineProperties,Ao=Object.getOwnPropertyDescriptor,vo=Object.getOwnPropertyDescriptors,$o=Object.getOwnPropertyNames,Wt=Object.getOwnPropertySymbols,Bo=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty,Oo=Object.prototype.propertyIsEnumerable,Vt=(e,t,n)=>t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,we=(e,t)=>{for(var n in t||(t={}))Jt.call(t,n)&&Vt(e,n,t[n]);if(Wt)for(var n of Wt(t))Oo.call(t,n)&&Vt(e,n,t[n]);return e},Ge=(e,t)=>wo(e,vo(t)),xo=e=>be(e,"__esModule",{value:!0}),Mo=(e,t)=>()=>(e&&(t=e(e=0)),t),So=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Po=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $o(t))!Jt.call(e,o)&&(n||o!=="default")&&be(e,o,{get:()=>t[o],enumerable:!(r=Ao(t,o))||r.enumerable});return e},Io=(e,t)=>Po(xo(be(e!=null?bo(Bo(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),B=Mo(()=>{}),_o=So((e,t)=>{B(),t.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});B(),B(),B();var To=e=>{var t,n,r;let o=(t=process.stdout.columns)!=null?t:Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(o)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:o}:{columns:(n=e.columns)!=null?n:[],stdoutColumns:(r=e.stdoutColumns)!=null?r:o}};B(),B(),B(),B(),B();function Lo({onlyFirst:e=!1}={}){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}function Xt(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Lo(),"")}B();function Ro(e){return Number.isInteger(e)?e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141):!1}var No=Io(_o(),1);function z(e){if(typeof e!="string"||e.length===0||(e=Xt(e),e.length===0))return 0;e=e.replace((0,No.default)()," ");let t=0;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);r<=31||r>=127&&r<=159||r>=768&&r<=879||(r>65535&&n++,t+=Ro(r)?2:1)}return t}var Qt=e=>Math.max(...e.split(`
3
- `).map(z)),ko=e=>{let t=[];for(let n of e){let{length:r}=n,o=r-t.length;for(let s=0;s<o;s+=1)t.push(0);for(let s=0;s<r;s+=1){let u=Qt(n[s]);u>t[s]&&(t[s]=u)}}return t};B();var Zt=/^\d+%$/,er={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},jo=(e,t)=>{var n;let r=[];for(let o=0;o<e.length;o+=1){let s=(n=t[o])!=null?n:"auto";if(typeof s=="number"||s==="auto"||s==="content-width"||typeof s=="string"&&Zt.test(s)){r.push(Ge(we({},er),{width:s,contentWidth:e[o]}));continue}if(s&&typeof s=="object"){let u=Ge(we(we({},er),s),{contentWidth:e[o]});u.horizontalPadding=u.paddingLeft+u.paddingRight,r.push(u);continue}throw new Error(`Invalid column width: ${JSON.stringify(s)}`)}return r};function Go(e,t){for(let n of e){let{width:r}=n;if(r==="content-width"&&(n.width=n.contentWidth),r==="auto"){let c=Math.min(20,n.contentWidth);n.width=c,n.autoOverflow=n.contentWidth-c}if(typeof r=="string"&&Zt.test(r)){let c=Number.parseFloat(r.slice(0,-1))/100;n.width=Math.floor(t*c)-(n.paddingLeft+n.paddingRight)}let{horizontalPadding:o}=n,s=1,u=s+o;if(u>=t){let c=u-t,l=Math.ceil(n.paddingLeft/o*c),f=c-l;n.paddingLeft-=l,n.paddingRight-=f,n.horizontalPadding=n.paddingLeft+n.paddingRight}n.paddingLeftString=n.paddingLeft?" ".repeat(n.paddingLeft):"",n.paddingRightString=n.paddingRight?" ".repeat(n.paddingRight):"";let i=t-n.horizontalPadding;n.width=Math.max(Math.min(n.width,i),s)}}var tr=()=>Object.assign([],{columns:0});function Ho(e,t){let n=[tr()],[r]=n;for(let o of e){let s=o.width+o.horizontalPadding;r.columns+s>t&&(r=tr(),n.push(r)),r.push(o),r.columns+=s}for(let o of n){let s=o.reduce((D,p)=>D+p.width+p.horizontalPadding,0),u=t-s;if(u===0)continue;let i=o.filter(D=>"autoOverflow"in D),c=i.filter(D=>D.autoOverflow>0),l=c.reduce((D,p)=>D+p.autoOverflow,0),f=Math.min(l,u);for(let D of c){let p=Math.floor(D.autoOverflow/l*f);D.width+=p,u-=p}let a=Math.floor(u/i.length);for(let D=0;D<i.length;D+=1){let p=i[D];D===i.length-1?p.width+=u:p.width+=a,u-=a}}return n}function Uo(e,t,n){let r=jo(n,t);return Go(r,e),Ho(r,e)}B(),B(),B();var He=10,rr=(e=0)=>t=>`\x1B[${t+e}m`,nr=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,or=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`;function Ko(){let e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(let[n,r]of Object.entries(t)){for(let[o,s]of Object.entries(r))t[o]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},r[o]=t[o],e.set(s[0],s[1]);Object.defineProperty(t,n,{value:r,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi=rr(),t.color.ansi256=nr(),t.color.ansi16m=or(),t.bgColor.ansi=rr(He),t.bgColor.ansi256=nr(He),t.bgColor.ansi16m=or(He),Object.defineProperties(t,{rgbToAnsi256:{value:(n,r,o)=>n===r&&r===o?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(r/255*5)+Math.round(o/255*5),enumerable:!1},hexToRgb:{value:n=>{let r=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(n.toString(16));if(!r)return[0,0,0];let{colorString:o}=r.groups;o.length===3&&(o=o.split("").map(u=>u+u).join(""));let s=Number.parseInt(o,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:n=>t.rgbToAnsi256(...t.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value:n=>{if(n<8)return 30+n;if(n<16)return 90+(n-8);let r,o,s;if(n>=232)r=((n-232)*10+8)/255,o=r,s=r;else{n-=16;let c=n%36;r=Math.floor(n/36)/5,o=Math.floor(c/6)/5,s=c%6/5}let u=Math.max(r,o,s)*2;if(u===0)return 30;let i=30+(Math.round(s)<<2|Math.round(o)<<1|Math.round(r));return u===2&&(i+=60),i},enumerable:!1},rgbToAnsi:{value:(n,r,o)=>t.ansi256ToAnsi(t.rgbToAnsi256(n,r,o)),enumerable:!1},hexToAnsi:{value:n=>t.ansi256ToAnsi(t.hexToAnsi256(n)),enumerable:!1}}),t}var qo=Ko(),zo=qo,Ae=new Set(["\x1B","\x9B"]),Yo=39,Ue="\x07",sr="[",Wo="]",ur="m",Ke=`${Wo}8;;`,ir=e=>`${Ae.values().next().value}${sr}${e}${ur}`,ar=e=>`${Ae.values().next().value}${Ke}${e}${Ue}`,Jo=e=>e.split(" ").map(t=>z(t)),qe=(e,t,n)=>{let r=[...t],o=!1,s=!1,u=z(Xt(e[e.length-1]));for(let[i,c]of r.entries()){let l=z(c);if(u+l<=n?e[e.length-1]+=c:(e.push(c),u=0),Ae.has(c)&&(o=!0,s=r.slice(i+1).join("").startsWith(Ke)),o){s?c===Ue&&(o=!1,s=!1):c===ur&&(o=!1);continue}u+=l,u===n&&i<r.length-1&&(e.push(""),u=0)}!u&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Vo=e=>{let t=e.split(" "),n=t.length;for(;n>0&&!(z(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},Xo=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let r="",o,s,u=Jo(e),i=[""];for(let[l,f]of e.split(" ").entries()){n.trim!==!1&&(i[i.length-1]=i[i.length-1].trimStart());let a=z(i[i.length-1]);if(l!==0&&(a>=t&&(n.wordWrap===!1||n.trim===!1)&&(i.push(""),a=0),(a>0||n.trim===!1)&&(i[i.length-1]+=" ",a++)),n.hard&&u[l]>t){let D=t-a,p=1+Math.floor((u[l]-D-1)/t);Math.floor((u[l]-1)/t)<p&&i.push(""),qe(i,f,t);continue}if(a+u[l]>t&&a>0&&u[l]>0){if(n.wordWrap===!1&&a<t){qe(i,f,t);continue}i.push("")}if(a+u[l]>t&&n.wordWrap===!1){qe(i,f,t);continue}i[i.length-1]+=f}n.trim!==!1&&(i=i.map(l=>Vo(l)));let c=[...i.join(`
4
- `)];for(let[l,f]of c.entries()){if(r+=f,Ae.has(f)){let{groups:D}=new RegExp(`(?:\\${sr}(?<code>\\d+)m|\\${Ke}(?<uri>.*)${Ue})`).exec(c.slice(l).join(""))||{groups:{}};if(D.code!==void 0){let p=Number.parseFloat(D.code);o=p===Yo?void 0:p}else D.uri!==void 0&&(s=D.uri.length===0?void 0:D.uri)}let a=zo.codes.get(Number(o));c[l+1]===`
5
- `?(s&&(r+=ar("")),o&&a&&(r+=ir(a))):f===`
6
- `&&(o&&a&&(r+=ir(o)),s&&(r+=ar(s)))}return r};function Qo(e,t,n){return String(e).normalize().replace(/\r\n/g,`
2
+ import Le from"tty";import{createRequire as vn}from"module";import k from"fs";import P from"path";import{Buffer as $n}from"node:buffer";import J from"node:path";import kt,{ChildProcess as Bn}from"node:child_process";import I from"node:process";import On from"child_process";import{fileURLToPath as jt}from"node:url";import xn,{constants as Gt}from"node:os";import Ht from"assert";import Ut from"events";import{createWriteStream as Mn,createReadStream as Sn}from"node:fs";import Pn from"buffer";import Re from"stream";import Kt from"util";import{debuglog as In}from"node:util";import Ne from"inquirer";import ke from"ora";import g from"chalk";import{of as x,concatMap as j,from as S,map as _,catchError as T,mergeMap as qt,BehaviorSubject as zt,ReplaySubject as _n,lastValueFrom as Tn,filter as Ln,toArray as Rn}from"rxjs";import Nn from"@anthropic-ai/sdk";import{fromPromise as G}from"rxjs/internal/observable/innerFrom";import je from"os";import{xxh64 as kn}from"@pacote/xxhash";import jn from"axios";import{CohereClient as Gn,CohereTimeoutError as Hn}from"cohere-ai";import{GoogleGenerativeAI as Un}from"@google/generative-ai";import Kn from"groq-sdk";import{Ollama as qn}from"ollama";import O from"fs/promises";import zn from"http";import Yn from"https";import Wn from"net";import Jn from"tls";import Vn,{fileURLToPath as Xn,pathToFileURL as Qn}from"url";import Fe from"readline";import Zn from"figlet";import eo from"inquirer-reactive-list-prompt";import{rm as to}from"node:fs/promises";const ro="known-flag",no="unknown-flag",oo="argument",{stringify:ie}=JSON,so=/\B([A-Z])/g,uo=e=>e.replace(so,"-$1").toLowerCase(),{hasOwnProperty:io}=Object.prototype,ae=(e,t)=>io.call(e,t),ao=e=>Array.isArray(e),Yt=e=>typeof e=="function"?[e,!1]:ao(e)?[e[0],!0]:Yt(e.type),co=(e,t)=>e===Boolean?t!=="false":t,Do=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),lo=/[\s.:=]/,fo=e=>{const t=`Flag name ${ie(e)}`;if(e.length===0)throw new Error(`${t} cannot be empty`);if(e.length===1)throw new Error(`${t} must be longer than a character`);const r=e.match(lo);if(r)throw new Error(`${t} cannot contain ${ie(r?.[0])}`)},po=e=>{const t={},r=(n,o)=>{if(ae(t,n))throw new Error(`Duplicate flags named ${ie(n)}`);t[n]=o};for(const n in e){if(!ae(e,n))continue;fo(n);const o=e[n],s=[[],...Yt(o),o];r(n,s);const u=uo(n);if(n!==u&&r(u,s),"alias"in o&&typeof o.alias=="string"){const{alias:i}=o,c=`Flag alias ${ie(i)} for flag ${ie(n)}`;if(i.length===0)throw new Error(`${c} cannot be empty`);if(i.length>1)throw new Error(`${c} must be a single character`);r(i,s)}}return t},mo=(e,t)=>{const r={};for(const n in e){if(!ae(e,n))continue;const[o,,s,u]=t[n];if(o.length===0&&"default"in u){let{default:i}=u;typeof i=="function"&&(i=i()),r[n]=i}else r[n]=s?o:o.pop()}return r},ye="--",ho=/[.:=]/,go=/^-{1,2}\w/,Co=e=>{if(!go.test(e))return;const t=!e.startsWith(ye);let r=e.slice(t?1:2),n;const o=r.match(ho);if(o){const{index:s}=o;n=r.slice(s+1),r=r.slice(0,s)}return[r,n,t]},Eo=(e,{onFlag:t,onArgument:r})=>{let n;const o=(s,u)=>{if(typeof n!="function")return!0;n(s,u),n=void 0};for(let s=0;s<e.length;s+=1){const u=e[s];if(u===ye){o();const c=e.slice(s+1);r?.(c,[s],!0);break}const i=Co(u);if(i){if(o(),!t)continue;const[c,l,f]=i;if(f)for(let a=0;a<c.length;a+=1){o();const D=a===c.length-1;n=t(c[a],D?l:void 0,[s,a+1,D])}else n=t(c,l,[s])}else o(u,[s])&&r?.([u],[s])}o()},Fo=(e,t)=>{for(const[r,n,o]of t.reverse()){if(n){const s=e[r];let u=s.slice(0,n);if(o||(u+=s.slice(n+1)),u!=="-"){e[r]=u;continue}}e.splice(r,1)}},yo=(e,t=process.argv.slice(2),{ignore:r}={})=>{const n=[],o=po(e),s={},u=[];return u[ye]=[],Eo(t,{onFlag(i,c,l){const f=ae(o,i);if(!r?.(f?ro:no,i,c)){if(f){const[a,D]=o[i],p=co(D,c),d=(h,m)=>{n.push(l),m&&n.push(m),a.push(Do(D,h||""))};return p===void 0?d:d(p)}ae(s,i)||(s[i]=[]),s[i].push(c===void 0?!0:c),n.push(l)}},onArgument(i,c,l){r?.(oo,t[c[0]])||(u.push(...i),l?(u[ye]=i,t.splice(c[0])):n.push(c))}}),Fo(t,n),{flags:mo(e,o),unknownFlags:s,_:u}};var bo=Object.create,be=Object.defineProperty,wo=Object.defineProperties,Ao=Object.getOwnPropertyDescriptor,vo=Object.getOwnPropertyDescriptors,$o=Object.getOwnPropertyNames,Wt=Object.getOwnPropertySymbols,Bo=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty,Oo=Object.prototype.propertyIsEnumerable,Vt=(e,t,r)=>t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,we=(e,t)=>{for(var r in t||(t={}))Jt.call(t,r)&&Vt(e,r,t[r]);if(Wt)for(var r of Wt(t))Oo.call(t,r)&&Vt(e,r,t[r]);return e},Ge=(e,t)=>wo(e,vo(t)),xo=e=>be(e,"__esModule",{value:!0}),Mo=(e,t)=>()=>(e&&(t=e(e=0)),t),So=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Po=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $o(t))!Jt.call(e,o)&&(r||o!=="default")&&be(e,o,{get:()=>t[o],enumerable:!(n=Ao(t,o))||n.enumerable});return e},Io=(e,t)=>Po(xo(be(e!=null?bo(Bo(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),B=Mo(()=>{}),_o=So((e,t)=>{B(),t.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});B(),B(),B();var To=e=>{var t,r,n;let o=(t=process.stdout.columns)!=null?t:Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(o)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:o}:{columns:(r=e.columns)!=null?r:[],stdoutColumns:(n=e.stdoutColumns)!=null?n:o}};B(),B(),B(),B(),B();function Lo({onlyFirst:e=!1}={}){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}function Xt(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Lo(),"")}B();function Ro(e){return Number.isInteger(e)?e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141):!1}var No=Io(_o(),1);function z(e){if(typeof e!="string"||e.length===0||(e=Xt(e),e.length===0))return 0;e=e.replace((0,No.default)()," ");let t=0;for(let r=0;r<e.length;r++){let n=e.codePointAt(r);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&r++,t+=Ro(n)?2:1)}return t}var Qt=e=>Math.max(...e.split(`
3
+ `).map(z)),ko=e=>{let t=[];for(let r of e){let{length:n}=r,o=n-t.length;for(let s=0;s<o;s+=1)t.push(0);for(let s=0;s<n;s+=1){let u=Qt(r[s]);u>t[s]&&(t[s]=u)}}return t};B();var Zt=/^\d+%$/,er={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},jo=(e,t)=>{var r;let n=[];for(let o=0;o<e.length;o+=1){let s=(r=t[o])!=null?r:"auto";if(typeof s=="number"||s==="auto"||s==="content-width"||typeof s=="string"&&Zt.test(s)){n.push(Ge(we({},er),{width:s,contentWidth:e[o]}));continue}if(s&&typeof s=="object"){let u=Ge(we(we({},er),s),{contentWidth:e[o]});u.horizontalPadding=u.paddingLeft+u.paddingRight,n.push(u);continue}throw new Error(`Invalid column width: ${JSON.stringify(s)}`)}return n};function Go(e,t){for(let r of e){let{width:n}=r;if(n==="content-width"&&(r.width=r.contentWidth),n==="auto"){let c=Math.min(20,r.contentWidth);r.width=c,r.autoOverflow=r.contentWidth-c}if(typeof n=="string"&&Zt.test(n)){let c=Number.parseFloat(n.slice(0,-1))/100;r.width=Math.floor(t*c)-(r.paddingLeft+r.paddingRight)}let{horizontalPadding:o}=r,s=1,u=s+o;if(u>=t){let c=u-t,l=Math.ceil(r.paddingLeft/o*c),f=c-l;r.paddingLeft-=l,r.paddingRight-=f,r.horizontalPadding=r.paddingLeft+r.paddingRight}r.paddingLeftString=r.paddingLeft?" ".repeat(r.paddingLeft):"",r.paddingRightString=r.paddingRight?" ".repeat(r.paddingRight):"";let i=t-r.horizontalPadding;r.width=Math.max(Math.min(r.width,i),s)}}var tr=()=>Object.assign([],{columns:0});function Ho(e,t){let r=[tr()],[n]=r;for(let o of e){let s=o.width+o.horizontalPadding;n.columns+s>t&&(n=tr(),r.push(n)),n.push(o),n.columns+=s}for(let o of r){let s=o.reduce((D,p)=>D+p.width+p.horizontalPadding,0),u=t-s;if(u===0)continue;let i=o.filter(D=>"autoOverflow"in D),c=i.filter(D=>D.autoOverflow>0),l=c.reduce((D,p)=>D+p.autoOverflow,0),f=Math.min(l,u);for(let D of c){let p=Math.floor(D.autoOverflow/l*f);D.width+=p,u-=p}let a=Math.floor(u/i.length);for(let D=0;D<i.length;D+=1){let p=i[D];D===i.length-1?p.width+=u:p.width+=a,u-=a}}return r}function Uo(e,t,r){let n=jo(r,t);return Go(n,e),Ho(n,e)}B(),B(),B();var He=10,rr=(e=0)=>t=>`\x1B[${t+e}m`,nr=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,or=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`;function Ko(){let e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(let[r,n]of Object.entries(t)){for(let[o,s]of Object.entries(n))t[o]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[o]=t[o],e.set(s[0],s[1]);Object.defineProperty(t,r,{value:n,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi=rr(),t.color.ansi256=nr(),t.color.ansi16m=or(),t.bgColor.ansi=rr(He),t.bgColor.ansi256=nr(He),t.bgColor.ansi16m=or(He),Object.defineProperties(t,{rgbToAnsi256:{value:(r,n,o)=>r===n&&n===o?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(n/255*5)+Math.round(o/255*5),enumerable:!1},hexToRgb:{value:r=>{let n=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!n)return[0,0,0];let{colorString:o}=n.groups;o.length===3&&(o=o.split("").map(u=>u+u).join(""));let s=Number.parseInt(o,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:r=>t.rgbToAnsi256(...t.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value:r=>{if(r<8)return 30+r;if(r<16)return 90+(r-8);let n,o,s;if(r>=232)n=((r-232)*10+8)/255,o=n,s=n;else{r-=16;let c=r%36;n=Math.floor(r/36)/5,o=Math.floor(c/6)/5,s=c%6/5}let u=Math.max(n,o,s)*2;if(u===0)return 30;let i=30+(Math.round(s)<<2|Math.round(o)<<1|Math.round(n));return u===2&&(i+=60),i},enumerable:!1},rgbToAnsi:{value:(r,n,o)=>t.ansi256ToAnsi(t.rgbToAnsi256(r,n,o)),enumerable:!1},hexToAnsi:{value:r=>t.ansi256ToAnsi(t.hexToAnsi256(r)),enumerable:!1}}),t}var qo=Ko(),zo=qo,Ae=new Set(["\x1B","\x9B"]),Yo=39,Ue="\x07",sr="[",Wo="]",ur="m",Ke=`${Wo}8;;`,ir=e=>`${Ae.values().next().value}${sr}${e}${ur}`,ar=e=>`${Ae.values().next().value}${Ke}${e}${Ue}`,Jo=e=>e.split(" ").map(t=>z(t)),qe=(e,t,r)=>{let n=[...t],o=!1,s=!1,u=z(Xt(e[e.length-1]));for(let[i,c]of n.entries()){let l=z(c);if(u+l<=r?e[e.length-1]+=c:(e.push(c),u=0),Ae.has(c)&&(o=!0,s=n.slice(i+1).join("").startsWith(Ke)),o){s?c===Ue&&(o=!1,s=!1):c===ur&&(o=!1);continue}u+=l,u===r&&i<n.length-1&&(e.push(""),u=0)}!u&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Vo=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(z(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Xo=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",o,s,u=Jo(e),i=[""];for(let[l,f]of e.split(" ").entries()){r.trim!==!1&&(i[i.length-1]=i[i.length-1].trimStart());let a=z(i[i.length-1]);if(l!==0&&(a>=t&&(r.wordWrap===!1||r.trim===!1)&&(i.push(""),a=0),(a>0||r.trim===!1)&&(i[i.length-1]+=" ",a++)),r.hard&&u[l]>t){let D=t-a,p=1+Math.floor((u[l]-D-1)/t);Math.floor((u[l]-1)/t)<p&&i.push(""),qe(i,f,t);continue}if(a+u[l]>t&&a>0&&u[l]>0){if(r.wordWrap===!1&&a<t){qe(i,f,t);continue}i.push("")}if(a+u[l]>t&&r.wordWrap===!1){qe(i,f,t);continue}i[i.length-1]+=f}r.trim!==!1&&(i=i.map(l=>Vo(l)));let c=[...i.join(`
4
+ `)];for(let[l,f]of c.entries()){if(n+=f,Ae.has(f)){let{groups:D}=new RegExp(`(?:\\${sr}(?<code>\\d+)m|\\${Ke}(?<uri>.*)${Ue})`).exec(c.slice(l).join(""))||{groups:{}};if(D.code!==void 0){let p=Number.parseFloat(D.code);o=p===Yo?void 0:p}else D.uri!==void 0&&(s=D.uri.length===0?void 0:D.uri)}let a=zo.codes.get(Number(o));c[l+1]===`
5
+ `?(s&&(n+=ar("")),o&&a&&(n+=ir(a))):f===`
6
+ `&&(o&&a&&(n+=ir(o)),s&&(n+=ar(s)))}return n};function Qo(e,t,r){return String(e).normalize().replace(/\r\n/g,`
7
7
  `).split(`
8
- `).map(r=>Xo(r,t,n)).join(`
9
- `)}var cr=e=>Array.from({length:e}).fill("");function Zo(e,t){let n=[],r=0;for(let o of e){let s=0,u=o.map(c=>{var l;let f=(l=t[r])!=null?l:"";r+=1,c.preprocess&&(f=c.preprocess(f)),Qt(f)>c.width&&(f=Qo(f,c.width,{hard:!0}));let a=f.split(`
10
- `);if(c.postprocess){let{postprocess:D}=c;a=a.map((p,d)=>D.call(c,p,d))}return c.paddingTop&&a.unshift(...cr(c.paddingTop)),c.paddingBottom&&a.push(...cr(c.paddingBottom)),a.length>s&&(s=a.length),Ge(we({},c),{lines:a})}),i=[];for(let c=0;c<s;c+=1){let l=u.map(f=>{var a;let D=(a=f.lines[c])!=null?a:"",p=Number.isFinite(f.width)?" ".repeat(f.width-z(D)):"",d=f.paddingLeftString;return f.align==="right"&&(d+=p),d+=D,f.align==="left"&&(d+=p),d+f.paddingRightString}).join("");i.push(l)}n.push(i.join(`
11
- `))}return n.join(`
12
- `)}function es(e,t){if(!e||e.length===0)return"";let n=ko(e),r=n.length;if(r===0)return"";let{stdoutColumns:o,columns:s}=To(t);if(s.length>r)throw new Error(`${s.length} columns defined, but only ${r} columns found`);let u=Uo(o,s,n);return e.map(i=>Zo(u,i)).join(`
13
- `)}B();var ts=["<",">","=",">=","<="];function rs(e){if(!ts.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)}function ns(e){let t=Object.keys(e).map(n=>{let[r,o]=n.split(" ");rs(r);let s=Number.parseInt(o,10);if(Number.isNaN(s))throw new TypeError(`Invalid breakpoint value: ${o}`);let u=e[n];return{operator:r,breakpoint:s,value:u}}).sort((n,r)=>r.breakpoint-n.breakpoint);return n=>{var r;return(r=t.find(({operator:o,breakpoint:s})=>o==="="&&n===s||o===">"&&n>s||o==="<"&&n<s||o===">="&&n>=s||o==="<="&&n<=s))==null?void 0:r.value}}const os=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,n)=>n?n.toUpperCase():""),ss=e=>e.replace(/\B([A-Z])/g,"-$1").toLowerCase(),us={"> 80":[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"auto"}],"> 40":[{width:"auto",paddingLeft:2,paddingRight:8,preprocess:e=>e.trim()},{width:"100%",paddingLeft:2,paddingBottom:1}],"> 0":{stdoutColumns:1e3,columns:[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"content-width"}]}};function is(e){let t=!1;return{type:"table",data:{tableData:Object.keys(e).sort((n,r)=>n.localeCompare(r)).map(n=>{const r=e[n],o="alias"in r;return o&&(t=!0),{name:n,flag:r,flagFormatted:`--${ss(n)}`,aliasesEnabled:t,aliasFormatted:o?`-${r.alias}`:void 0}}).map(n=>(n.aliasesEnabled=t,[{type:"flagName",data:n},{type:"flagDescription",data:n}])),tableBreakpoints:us}}}const Dr=e=>!e||(e.version??(e.help?e.help.version:void 0)),lr=e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name};function as(e){const t=[];e.name&&t.push(lr(e));const n=Dr(e)??("parent"in e&&Dr(e.parent));if(n&&t.push(`v${n}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
8
+ `).map(n=>Xo(n,t,r)).join(`
9
+ `)}var cr=e=>Array.from({length:e}).fill("");function Zo(e,t){let r=[],n=0;for(let o of e){let s=0,u=o.map(c=>{var l;let f=(l=t[n])!=null?l:"";n+=1,c.preprocess&&(f=c.preprocess(f)),Qt(f)>c.width&&(f=Qo(f,c.width,{hard:!0}));let a=f.split(`
10
+ `);if(c.postprocess){let{postprocess:D}=c;a=a.map((p,d)=>D.call(c,p,d))}return c.paddingTop&&a.unshift(...cr(c.paddingTop)),c.paddingBottom&&a.push(...cr(c.paddingBottom)),a.length>s&&(s=a.length),Ge(we({},c),{lines:a})}),i=[];for(let c=0;c<s;c+=1){let l=u.map(f=>{var a;let D=(a=f.lines[c])!=null?a:"",p=Number.isFinite(f.width)?" ".repeat(f.width-z(D)):"",d=f.paddingLeftString;return f.align==="right"&&(d+=p),d+=D,f.align==="left"&&(d+=p),d+f.paddingRightString}).join("");i.push(l)}r.push(i.join(`
11
+ `))}return r.join(`
12
+ `)}function es(e,t){if(!e||e.length===0)return"";let r=ko(e),n=r.length;if(n===0)return"";let{stdoutColumns:o,columns:s}=To(t);if(s.length>n)throw new Error(`${s.length} columns defined, but only ${n} columns found`);let u=Uo(o,s,r);return e.map(i=>Zo(u,i)).join(`
13
+ `)}B();var ts=["<",">","=",">=","<="];function rs(e){if(!ts.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)}function ns(e){let t=Object.keys(e).map(r=>{let[n,o]=r.split(" ");rs(n);let s=Number.parseInt(o,10);if(Number.isNaN(s))throw new TypeError(`Invalid breakpoint value: ${o}`);let u=e[r];return{operator:n,breakpoint:s,value:u}}).sort((r,n)=>n.breakpoint-r.breakpoint);return r=>{var n;return(n=t.find(({operator:o,breakpoint:s})=>o==="="&&r===s||o===">"&&r>s||o==="<"&&r<s||o===">="&&r>=s||o==="<="&&r<=s))==null?void 0:n.value}}const os=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,r)=>r?r.toUpperCase():""),ss=e=>e.replace(/\B([A-Z])/g,"-$1").toLowerCase(),us={"> 80":[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"auto"}],"> 40":[{width:"auto",paddingLeft:2,paddingRight:8,preprocess:e=>e.trim()},{width:"100%",paddingLeft:2,paddingBottom:1}],"> 0":{stdoutColumns:1e3,columns:[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"content-width"}]}};function is(e){let t=!1;return{type:"table",data:{tableData:Object.keys(e).sort((r,n)=>r.localeCompare(n)).map(r=>{const n=e[r],o="alias"in n;return o&&(t=!0),{name:r,flag:n,flagFormatted:`--${ss(r)}`,aliasesEnabled:t,aliasFormatted:o?`-${n.alias}`:void 0}}).map(r=>(r.aliasesEnabled=t,[{type:"flagName",data:r},{type:"flagDescription",data:r}])),tableBreakpoints:us}}}const Dr=e=>!e||(e.version??(e.help?e.help.version:void 0)),lr=e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name};function as(e){const t=[];e.name&&t.push(lr(e));const r=Dr(e)??("parent"in e&&Dr(e.parent));if(r&&t.push(`v${r}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
14
14
  `}}function cs(e){const{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
15
15
  `}}function Ds(e){const t=e.help||{};if("usage"in t)return t.usage?{id:"usage",type:"section",data:{title:"Usage:",body:Array.isArray(t.usage)?t.usage.join(`
16
- `):t.usage}}:void 0;if(e.name){const n=[],r=[lr(e)];if(e.flags&&Object.keys(e.flags).length>0&&r.push("[flags...]"),e.parameters&&e.parameters.length>0){const{parameters:o}=e,s=o.indexOf("--"),u=s>-1&&o.slice(s+1).some(i=>i.startsWith("<"));r.push(o.map(i=>i!=="--"?i:u?"--":"[--]").join(" "))}if(r.length>1&&n.push(r.join(" ")),"commands"in e&&e.commands?.length&&n.push(`${e.name} <command>`),n.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:n.join(`
17
- `)}}}}function ls(e){return!("commands"in e)||!e.commands?.length?void 0:{id:"commands",type:"section",data:{title:"Commands:",body:{type:"table",data:{tableData:e.commands.map(t=>[t.options.name,t.options.help?t.options.help.description:""]),tableOptions:[{width:"content-width",paddingLeft:2,paddingRight:8}]}},indentBody:0}}}function fs(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:is(e.flags),indentBody:0}}}function ps(e){const{help:t}=e;if(!t||!t.examples||t.examples.length===0)return;let{examples:n}=t;if(Array.isArray(n)&&(n=n.join(`
18
- `)),n)return{id:"examples",type:"section",data:{title:"Examples:",body:n}}}function ds(e){if(!("alias"in e)||!e.alias)return;const{alias:t}=e;return{id:"aliases",type:"section",data:{title:"Aliases:",body:Array.isArray(t)?t.join(", "):t}}}const ms=e=>[as,cs,Ds,ls,fs,ps,ds].map(t=>t(e)).filter(Boolean),hs=Le.WriteStream.prototype.hasColors();class gs{text(t){return t}bold(t){return hs?`\x1B[1m${t}\x1B[22m`:t.toLocaleUpperCase()}indentText({text:t,spaces:n}){return t.replace(/^/gm," ".repeat(n))}heading(t){return this.bold(t)}section({title:t,body:n,indentBody:r=2}){return`${(t?`${this.heading(t)}
19
- `:"")+(n?this.indentText({text:this.render(n),spaces:r}):"")}
20
- `}table({tableData:t,tableOptions:n,tableBreakpoints:r}){return es(t.map(o=>o.map(s=>this.render(s))),r?ns(r):n)}flagParameter(t){return t===Boolean?"":t===String?"<string>":t===Number?"<number>":Array.isArray(t)?this.flagParameter(t[0]):"<value>"}flagOperator(t){return" "}flagName(t){const{flag:n,flagFormatted:r,aliasesEnabled:o,aliasFormatted:s}=t;let u="";if(s?u+=`${s}, `:o&&(u+=" "),u+=r,"placeholder"in n&&typeof n.placeholder=="string")u+=`${this.flagOperator(t)}${n.placeholder}`;else{const i=this.flagParameter("type"in n?n.type:n);i&&(u+=`${this.flagOperator(t)}${i}`)}return u}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let n="description"in t?t.description??"":"";if("default"in t){let{default:r}=t;typeof r=="function"&&(r=r()),r&&(n+=` (default: ${this.flagDefault(r)})`)}return n}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(n=>this.render(n)).join(`
21
- `);if("type"in t&&this[t.type]){const n=this[t.type];if(typeof n=="function")return n.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}}const ze=/^[\w.-]+$/,{stringify:L}=JSON,Cs=/[|\\{}()[\]^$+*?.]/;function Ye(e){const t=[];let n,r;for(const o of e){if(r)throw new Error(`Invalid parameter: Spread parameter ${L(r)} must be last`);const s=o[0],u=o[o.length-1];let i;if(s==="<"&&u===">"&&(i=!0,n))throw new Error(`Invalid parameter: Required parameter ${L(o)} cannot come after optional parameter ${L(n)}`);if(s==="["&&u==="]"&&(i=!1,n=o),i===void 0)throw new Error(`Invalid parameter: ${L(o)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let c=o.slice(1,-1);const l=c.slice(-3)==="...";l&&(r=o,c=c.slice(0,-3));const f=c.match(Cs);if(f)throw new Error(`Invalid parameter: ${L(o)}. Invalid character found ${L(f[0])}`);t.push({name:c,required:i,spread:l})}return t}function We(e,t,n,r){for(let o=0;o<t.length;o+=1){const{name:s,required:u,spread:i}=t[o],c=os(s);if(c in e)throw new Error(`Invalid parameter: ${L(s)} is used more than once.`);const l=i?n.slice(o):n[o];if(i&&(o=t.length),u&&(!l||i&&l.length===0))return console.error(`Error: Missing required parameter ${L(s)}
22
- `),r(),process.exit(1);e[c]=l}}function Es(e){return e===void 0||e!==!1}function fr(e,t,n,r){const o={...t.flags},s=t.version;s&&(o.version={type:Boolean,description:"Show version"});const{help:u}=t,i=Es(u);i&&!("help"in o)&&(o.help={type:Boolean,alias:"h",description:"Show help"});const c=yo(o,r,{ignore:t.ignoreArgv}),l=()=>{console.log(t.version)};if(s&&c.flags.version===!0)return l(),process.exit(0);const f=new gs,a=i&&u?.render?u.render:d=>f.render(d),D=d=>{const h=ms({...t,...d?{help:d}:{},flags:o});console.log(a(h,f))};if(i&&c.flags.help===!0)return D(),process.exit(0);if(t.parameters){let{parameters:d}=t,h=c._;const m=d.indexOf("--"),E=d.slice(m+1),b=Object.create(null);if(m>-1&&E.length>0){d=d.slice(0,m);const A=c._["--"];h=h.slice(0,-A.length||void 0),We(b,Ye(d),h,D),We(b,Ye(E),A,D)}else We(b,Ye(d),h,D);Object.assign(c._,b)}const p={...c,showVersion:l,showHelp:D};return typeof n=="function"&&n(p),{command:e,...p}}function Fs(e,t){const n=new Map;for(const r of t){const o=[r.options.name],{alias:s}=r.options;s&&(Array.isArray(s)?o.push(...s):o.push(s));for(const u of o){if(n.has(u))throw new Error(`Duplicate command name found: ${L(u)}`);n.set(u,r)}}return n.get(e)}function ys(e,t,n=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!ze.test(e.name)))throw new Error(`Invalid script name: ${L(e.name)}`);const r=n[0];if(e.commands&&ze.test(r)){const o=Fs(r,e.commands);if(o)return fr(o.options.name,{...o.options,parent:e},o.callback,n.slice(1))}return fr(void 0,e,t,n)}function Je(e,t){if(!e)throw new Error("Command options are required");const{name:n}=e;if(e.name===void 0)throw new Error("Command name is required");if(!ze.test(n))throw new Error(`Invalid command name ${JSON.stringify(n)}. Command names must be one word.`);return{options:e,callback:t}}var bs=vn(import.meta.url),v=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function V(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var X={exports:{}},Ve,pr;function ws(){if(pr)return Ve;pr=1,Ve=r,r.sync=o;var e=k;function t(s,u){var i=u.pathExt!==void 0?u.pathExt:process.env.PATHEXT;if(!i||(i=i.split(";"),i.indexOf("")!==-1))return!0;for(var c=0;c<i.length;c++){var l=i[c].toLowerCase();if(l&&s.substr(-l.length).toLowerCase()===l)return!0}return!1}function n(s,u,i){return!s.isSymbolicLink()&&!s.isFile()?!1:t(u,i)}function r(s,u,i){e.stat(s,function(c,l){i(c,c?!1:n(l,s,u))})}function o(s,u){return n(e.statSync(s),s,u)}return Ve}var Xe,dr;function As(){if(dr)return Xe;dr=1,Xe=t,t.sync=n;var e=k;function t(s,u,i){e.stat(s,function(c,l){i(c,c?!1:r(l,u))})}function n(s,u){return r(e.statSync(s),u)}function r(s,u){return s.isFile()&&o(s,u)}function o(s,u){var i=s.mode,c=s.uid,l=s.gid,f=u.uid!==void 0?u.uid:process.getuid&&process.getuid(),a=u.gid!==void 0?u.gid:process.getgid&&process.getgid(),D=parseInt("100",8),p=parseInt("010",8),d=parseInt("001",8),h=D|p,m=i&d||i&p&&l===a||i&D&&c===f||i&h&&f===0;return m}return Xe}var ve;process.platform==="win32"||v.TESTING_WINDOWS?ve=ws():ve=As();var vs=Qe;Qe.sync=$s;function Qe(e,t,n){if(typeof t=="function"&&(n=t,t={}),!n){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(r,o){Qe(e,t||{},function(s,u){s?o(s):r(u)})})}ve(e,t||{},function(r,o){r&&(r.code==="EACCES"||t&&t.ignoreErrors)&&(r=null,o=!1),n(r,o)})}function $s(e,t){try{return ve.sync(e,t||{})}catch(n){if(t&&t.ignoreErrors||n.code==="EACCES")return!1;throw n}}const Q=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",mr=P,Bs=Q?";":":",hr=vs,gr=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),Cr=(e,t)=>{const n=t.colon||Bs,r=e.match(/\//)||Q&&e.match(/\\/)?[""]:[...Q?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(n)],o=Q?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=Q?o.split(n):[""];return Q&&e.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:r,pathExt:s,pathExtExe:o}},Er=(e,t,n)=>{typeof t=="function"&&(n=t,t={}),t||(t={});const{pathEnv:r,pathExt:o,pathExtExe:s}=Cr(e,t),u=[],i=l=>new Promise((f,a)=>{if(l===r.length)return t.all&&u.length?f(u):a(gr(e));const D=r[l],p=/^".*"$/.test(D)?D.slice(1,-1):D,d=mr.join(p,e),h=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;f(c(h,l,0))}),c=(l,f,a)=>new Promise((D,p)=>{if(a===o.length)return D(i(f+1));const d=o[a];hr(l+d,{pathExt:s},(h,m)=>{if(!h&&m)if(t.all)u.push(l+d);else return D(l+d);return D(c(l,f,a+1))})});return n?i(0).then(l=>n(null,l),n):i(0)},Os=(e,t)=>{t=t||{};const{pathEnv:n,pathExt:r,pathExtExe:o}=Cr(e,t),s=[];for(let u=0;u<n.length;u++){const i=n[u],c=/^".*"$/.test(i)?i.slice(1,-1):i,l=mr.join(c,e),f=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+l:l;for(let a=0;a<r.length;a++){const D=f+r[a];try{if(hr.sync(D,{pathExt:o}))if(t.all)s.push(D);else return D}catch{}}}if(t.all&&s.length)return s;if(t.nothrow)return null;throw gr(e)};var xs=Er;Er.sync=Os;var Ze={exports:{}};const Fr=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"};Ze.exports=Fr,Ze.exports.default=Fr;var Ms=Ze.exports;const yr=P,Ss=xs,Ps=Ms;function br(e,t){const n=e.options.env||process.env,r=process.cwd(),o=e.options.cwd!=null,s=o&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(e.options.cwd)}catch{}let u;try{u=Ss.sync(e.command,{path:n[Ps({env:n})],pathExt:t?yr.delimiter:void 0})}catch{}finally{s&&process.chdir(r)}return u&&(u=yr.resolve(o?e.options.cwd:"",u)),u}function Is(e){return br(e)||br(e,!0)}var _s=Is,et={};const tt=/([()\][%!^"`<>&|;, *?])/g;function Ts(e){return e=e.replace(tt,"^$1"),e}function Ls(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(tt,"^$1"),t&&(e=e.replace(tt,"^$1")),e}et.command=Ts,et.argument=Ls;var Rs=/^#!(.*)/;const Ns=Rs;var ks=(e="")=>{const t=e.match(Ns);if(!t)return null;const[n,r]=t[0].replace(/#! ?/,"").split(" "),o=n.split("/").pop();return o==="env"?r:r?`${o} ${r}`:o};const rt=k,js=ks;function Gs(e){const n=Buffer.alloc(150);let r;try{r=rt.openSync(e,"r"),rt.readSync(r,n,0,150,0),rt.closeSync(r)}catch{}return js(n.toString())}var Hs=Gs;const Us=P,wr=_s,Ar=et,Ks=Hs,qs=process.platform==="win32",zs=/\.(?:com|exe)$/i,Ys=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Ws(e){e.file=wr(e);const t=e.file&&Ks(e.file);return t?(e.args.unshift(e.file),e.command=t,wr(e)):e.file}function Js(e){if(!qs)return e;const t=Ws(e),n=!zs.test(t);if(e.options.forceShell||n){const r=Ys.test(t);e.command=Us.normalize(e.command),e.command=Ar.command(e.command),e.args=e.args.map(s=>Ar.argument(s,r));const o=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${o}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function Vs(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);const r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:Js(r)}var Xs=Vs;const nt=process.platform==="win32";function ot(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function Qs(e,t){if(!nt)return;const n=e.emit;e.emit=function(r,o){if(r==="exit"){const s=vr(o,t);if(s)return n.call(e,"error",s)}return n.apply(e,arguments)}}function vr(e,t){return nt&&e===1&&!t.file?ot(t.original,"spawn"):null}function Zs(e,t){return nt&&e===1&&!t.file?ot(t.original,"spawnSync"):null}var eu={hookChildProcess:Qs,verifyENOENT:vr,verifyENOENTSync:Zs,notFoundError:ot};const $r=On,st=Xs,ut=eu;function Br(e,t,n){const r=st(e,t,n),o=$r.spawn(r.command,r.args,r.options);return ut.hookChildProcess(o,r),o}function tu(e,t,n){const r=st(e,t,n),o=$r.spawnSync(r.command,r.args,r.options);return o.error=o.error||ut.verifyENOENTSync(o.status,r),o}X.exports=Br,X.exports.spawn=Br,X.exports.sync=tu,X.exports._parse=st,X.exports._enoent=ut;var ru=X.exports,nu=V(ru);function ou(e){const t=typeof e=="string"?`
16
+ `):t.usage}}:void 0;if(e.name){const r=[],n=[lr(e)];if(e.flags&&Object.keys(e.flags).length>0&&n.push("[flags...]"),e.parameters&&e.parameters.length>0){const{parameters:o}=e,s=o.indexOf("--"),u=s>-1&&o.slice(s+1).some(i=>i.startsWith("<"));n.push(o.map(i=>i!=="--"?i:u?"--":"[--]").join(" "))}if(n.length>1&&r.push(n.join(" ")),"commands"in e&&e.commands?.length&&r.push(`${e.name} <command>`),r.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:r.join(`
17
+ `)}}}}function ls(e){return!("commands"in e)||!e.commands?.length?void 0:{id:"commands",type:"section",data:{title:"Commands:",body:{type:"table",data:{tableData:e.commands.map(t=>[t.options.name,t.options.help?t.options.help.description:""]),tableOptions:[{width:"content-width",paddingLeft:2,paddingRight:8}]}},indentBody:0}}}function fs(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:is(e.flags),indentBody:0}}}function ps(e){const{help:t}=e;if(!t||!t.examples||t.examples.length===0)return;let{examples:r}=t;if(Array.isArray(r)&&(r=r.join(`
18
+ `)),r)return{id:"examples",type:"section",data:{title:"Examples:",body:r}}}function ds(e){if(!("alias"in e)||!e.alias)return;const{alias:t}=e;return{id:"aliases",type:"section",data:{title:"Aliases:",body:Array.isArray(t)?t.join(", "):t}}}const ms=e=>[as,cs,Ds,ls,fs,ps,ds].map(t=>t(e)).filter(Boolean),hs=Le.WriteStream.prototype.hasColors();class gs{text(t){return t}bold(t){return hs?`\x1B[1m${t}\x1B[22m`:t.toLocaleUpperCase()}indentText({text:t,spaces:r}){return t.replace(/^/gm," ".repeat(r))}heading(t){return this.bold(t)}section({title:t,body:r,indentBody:n=2}){return`${(t?`${this.heading(t)}
19
+ `:"")+(r?this.indentText({text:this.render(r),spaces:n}):"")}
20
+ `}table({tableData:t,tableOptions:r,tableBreakpoints:n}){return es(t.map(o=>o.map(s=>this.render(s))),n?ns(n):r)}flagParameter(t){return t===Boolean?"":t===String?"<string>":t===Number?"<number>":Array.isArray(t)?this.flagParameter(t[0]):"<value>"}flagOperator(t){return" "}flagName(t){const{flag:r,flagFormatted:n,aliasesEnabled:o,aliasFormatted:s}=t;let u="";if(s?u+=`${s}, `:o&&(u+=" "),u+=n,"placeholder"in r&&typeof r.placeholder=="string")u+=`${this.flagOperator(t)}${r.placeholder}`;else{const i=this.flagParameter("type"in r?r.type:r);i&&(u+=`${this.flagOperator(t)}${i}`)}return u}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let r="description"in t?t.description??"":"";if("default"in t){let{default:n}=t;typeof n=="function"&&(n=n()),n&&(r+=` (default: ${this.flagDefault(n)})`)}return r}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(r=>this.render(r)).join(`
21
+ `);if("type"in t&&this[t.type]){const r=this[t.type];if(typeof r=="function")return r.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}}const ze=/^[\w.-]+$/,{stringify:L}=JSON,Cs=/[|\\{}()[\]^$+*?.]/;function Ye(e){const t=[];let r,n;for(const o of e){if(n)throw new Error(`Invalid parameter: Spread parameter ${L(n)} must be last`);const s=o[0],u=o[o.length-1];let i;if(s==="<"&&u===">"&&(i=!0,r))throw new Error(`Invalid parameter: Required parameter ${L(o)} cannot come after optional parameter ${L(r)}`);if(s==="["&&u==="]"&&(i=!1,r=o),i===void 0)throw new Error(`Invalid parameter: ${L(o)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let c=o.slice(1,-1);const l=c.slice(-3)==="...";l&&(n=o,c=c.slice(0,-3));const f=c.match(Cs);if(f)throw new Error(`Invalid parameter: ${L(o)}. Invalid character found ${L(f[0])}`);t.push({name:c,required:i,spread:l})}return t}function We(e,t,r,n){for(let o=0;o<t.length;o+=1){const{name:s,required:u,spread:i}=t[o],c=os(s);if(c in e)throw new Error(`Invalid parameter: ${L(s)} is used more than once.`);const l=i?r.slice(o):r[o];if(i&&(o=t.length),u&&(!l||i&&l.length===0))return console.error(`Error: Missing required parameter ${L(s)}
22
+ `),n(),process.exit(1);e[c]=l}}function Es(e){return e===void 0||e!==!1}function fr(e,t,r,n){const o={...t.flags},s=t.version;s&&(o.version={type:Boolean,description:"Show version"});const{help:u}=t,i=Es(u);i&&!("help"in o)&&(o.help={type:Boolean,alias:"h",description:"Show help"});const c=yo(o,n,{ignore:t.ignoreArgv}),l=()=>{console.log(t.version)};if(s&&c.flags.version===!0)return l(),process.exit(0);const f=new gs,a=i&&u?.render?u.render:d=>f.render(d),D=d=>{const h=ms({...t,...d?{help:d}:{},flags:o});console.log(a(h,f))};if(i&&c.flags.help===!0)return D(),process.exit(0);if(t.parameters){let{parameters:d}=t,h=c._;const m=d.indexOf("--"),E=d.slice(m+1),b=Object.create(null);if(m>-1&&E.length>0){d=d.slice(0,m);const A=c._["--"];h=h.slice(0,-A.length||void 0),We(b,Ye(d),h,D),We(b,Ye(E),A,D)}else We(b,Ye(d),h,D);Object.assign(c._,b)}const p={...c,showVersion:l,showHelp:D};return typeof r=="function"&&r(p),{command:e,...p}}function Fs(e,t){const r=new Map;for(const n of t){const o=[n.options.name],{alias:s}=n.options;s&&(Array.isArray(s)?o.push(...s):o.push(s));for(const u of o){if(r.has(u))throw new Error(`Duplicate command name found: ${L(u)}`);r.set(u,n)}}return r.get(e)}function ys(e,t,r=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!ze.test(e.name)))throw new Error(`Invalid script name: ${L(e.name)}`);const n=r[0];if(e.commands&&ze.test(n)){const o=Fs(n,e.commands);if(o)return fr(o.options.name,{...o.options,parent:e},o.callback,r.slice(1))}return fr(void 0,e,t,r)}function Je(e,t){if(!e)throw new Error("Command options are required");const{name:r}=e;if(e.name===void 0)throw new Error("Command name is required");if(!ze.test(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:e,callback:t}}var bs=vn(import.meta.url),v=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function V(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var X={exports:{}},Ve,pr;function ws(){if(pr)return Ve;pr=1,Ve=n,n.sync=o;var e=k;function t(s,u){var i=u.pathExt!==void 0?u.pathExt:process.env.PATHEXT;if(!i||(i=i.split(";"),i.indexOf("")!==-1))return!0;for(var c=0;c<i.length;c++){var l=i[c].toLowerCase();if(l&&s.substr(-l.length).toLowerCase()===l)return!0}return!1}function r(s,u,i){return!s.isSymbolicLink()&&!s.isFile()?!1:t(u,i)}function n(s,u,i){e.stat(s,function(c,l){i(c,c?!1:r(l,s,u))})}function o(s,u){return r(e.statSync(s),s,u)}return Ve}var Xe,dr;function As(){if(dr)return Xe;dr=1,Xe=t,t.sync=r;var e=k;function t(s,u,i){e.stat(s,function(c,l){i(c,c?!1:n(l,u))})}function r(s,u){return n(e.statSync(s),u)}function n(s,u){return s.isFile()&&o(s,u)}function o(s,u){var i=s.mode,c=s.uid,l=s.gid,f=u.uid!==void 0?u.uid:process.getuid&&process.getuid(),a=u.gid!==void 0?u.gid:process.getgid&&process.getgid(),D=parseInt("100",8),p=parseInt("010",8),d=parseInt("001",8),h=D|p,m=i&d||i&p&&l===a||i&D&&c===f||i&h&&f===0;return m}return Xe}var ve;process.platform==="win32"||v.TESTING_WINDOWS?ve=ws():ve=As();var vs=Qe;Qe.sync=$s;function Qe(e,t,r){if(typeof t=="function"&&(r=t,t={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,o){Qe(e,t||{},function(s,u){s?o(s):n(u)})})}ve(e,t||{},function(n,o){n&&(n.code==="EACCES"||t&&t.ignoreErrors)&&(n=null,o=!1),r(n,o)})}function $s(e,t){try{return ve.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}const Q=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",mr=P,Bs=Q?";":":",hr=vs,gr=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),Cr=(e,t)=>{const r=t.colon||Bs,n=e.match(/\//)||Q&&e.match(/\\/)?[""]:[...Q?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],o=Q?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=Q?o.split(r):[""];return Q&&e.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:n,pathExt:s,pathExtExe:o}},Er=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});const{pathEnv:n,pathExt:o,pathExtExe:s}=Cr(e,t),u=[],i=l=>new Promise((f,a)=>{if(l===n.length)return t.all&&u.length?f(u):a(gr(e));const D=n[l],p=/^".*"$/.test(D)?D.slice(1,-1):D,d=mr.join(p,e),h=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;f(c(h,l,0))}),c=(l,f,a)=>new Promise((D,p)=>{if(a===o.length)return D(i(f+1));const d=o[a];hr(l+d,{pathExt:s},(h,m)=>{if(!h&&m)if(t.all)u.push(l+d);else return D(l+d);return D(c(l,f,a+1))})});return r?i(0).then(l=>r(null,l),r):i(0)},Os=(e,t)=>{t=t||{};const{pathEnv:r,pathExt:n,pathExtExe:o}=Cr(e,t),s=[];for(let u=0;u<r.length;u++){const i=r[u],c=/^".*"$/.test(i)?i.slice(1,-1):i,l=mr.join(c,e),f=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+l:l;for(let a=0;a<n.length;a++){const D=f+n[a];try{if(hr.sync(D,{pathExt:o}))if(t.all)s.push(D);else return D}catch{}}}if(t.all&&s.length)return s;if(t.nothrow)return null;throw gr(e)};var xs=Er;Er.sync=Os;var Ze={exports:{}};const Fr=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};Ze.exports=Fr,Ze.exports.default=Fr;var Ms=Ze.exports;const yr=P,Ss=xs,Ps=Ms;function br(e,t){const r=e.options.env||process.env,n=process.cwd(),o=e.options.cwd!=null,s=o&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(e.options.cwd)}catch{}let u;try{u=Ss.sync(e.command,{path:r[Ps({env:r})],pathExt:t?yr.delimiter:void 0})}catch{}finally{s&&process.chdir(n)}return u&&(u=yr.resolve(o?e.options.cwd:"",u)),u}function Is(e){return br(e)||br(e,!0)}var _s=Is,et={};const tt=/([()\][%!^"`<>&|;, *?])/g;function Ts(e){return e=e.replace(tt,"^$1"),e}function Ls(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(tt,"^$1"),t&&(e=e.replace(tt,"^$1")),e}et.command=Ts,et.argument=Ls;var Rs=/^#!(.*)/;const Ns=Rs;var ks=(e="")=>{const t=e.match(Ns);if(!t)return null;const[r,n]=t[0].replace(/#! ?/,"").split(" "),o=r.split("/").pop();return o==="env"?n:n?`${o} ${n}`:o};const rt=k,js=ks;function Gs(e){const r=Buffer.alloc(150);let n;try{n=rt.openSync(e,"r"),rt.readSync(n,r,0,150,0),rt.closeSync(n)}catch{}return js(r.toString())}var Hs=Gs;const Us=P,wr=_s,Ar=et,Ks=Hs,qs=process.platform==="win32",zs=/\.(?:com|exe)$/i,Ys=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Ws(e){e.file=wr(e);const t=e.file&&Ks(e.file);return t?(e.args.unshift(e.file),e.command=t,wr(e)):e.file}function Js(e){if(!qs)return e;const t=Ws(e),r=!zs.test(t);if(e.options.forceShell||r){const n=Ys.test(t);e.command=Us.normalize(e.command),e.command=Ar.command(e.command),e.args=e.args.map(s=>Ar.argument(s,n));const o=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${o}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function Vs(e,t,r){t&&!Array.isArray(t)&&(r=t,t=null),t=t?t.slice(0):[],r=Object.assign({},r);const n={command:e,args:t,options:r,file:void 0,original:{command:e,args:t}};return r.shell?n:Js(n)}var Xs=Vs;const nt=process.platform==="win32";function ot(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function Qs(e,t){if(!nt)return;const r=e.emit;e.emit=function(n,o){if(n==="exit"){const s=vr(o,t);if(s)return r.call(e,"error",s)}return r.apply(e,arguments)}}function vr(e,t){return nt&&e===1&&!t.file?ot(t.original,"spawn"):null}function Zs(e,t){return nt&&e===1&&!t.file?ot(t.original,"spawnSync"):null}var eu={hookChildProcess:Qs,verifyENOENT:vr,verifyENOENTSync:Zs,notFoundError:ot};const $r=On,st=Xs,ut=eu;function Br(e,t,r){const n=st(e,t,r),o=$r.spawn(n.command,n.args,n.options);return ut.hookChildProcess(o,n),o}function tu(e,t,r){const n=st(e,t,r),o=$r.spawnSync(n.command,n.args,n.options);return o.error=o.error||ut.verifyENOENTSync(o.status,n),o}X.exports=Br,X.exports.spawn=Br,X.exports.sync=tu,X.exports._parse=st,X.exports._enoent=ut;var ru=X.exports,nu=V(ru);function ou(e){const t=typeof e=="string"?`
23
23
  `:`
24
- `.charCodeAt(),n=typeof e=="string"?"\r":"\r".charCodeAt();return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===n&&(e=e.slice(0,-1)),e}function Or(e={}){const{env:t=process.env,platform:n=process.platform}=e;return n!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"}const su=({cwd:e=I.cwd(),path:t=I.env[Or()],preferLocal:n=!0,execPath:r=I.execPath,addExecPath:o=!0}={})=>{const s=e instanceof URL?jt(e):e,u=J.resolve(s),i=[];return n&&uu(i,u),o&&iu(i,r,u),[...i,t].join(J.delimiter)},uu=(e,t)=>{let n;for(;n!==t;)e.push(J.join(t,"node_modules/.bin")),n=t,t=J.resolve(t,"..")},iu=(e,t,n)=>{const r=t instanceof URL?jt(t):t;e.push(J.resolve(n,r,".."))},au=({env:e=I.env,...t}={})=>{e={...e};const n=Or({env:e});return t.path=e[n],e[n]=su(t),e},cu=(e,t,n,r)=>{if(n==="length"||n==="prototype"||n==="arguments"||n==="caller")return;const o=Object.getOwnPropertyDescriptor(e,n),s=Object.getOwnPropertyDescriptor(t,n);!Du(o,s)&&r||Object.defineProperty(e,n,s)},Du=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},lu=(e,t)=>{const n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},fu=(e,t)=>`/* Wrapped ${e}*/
25
- ${t}`,pu=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),du=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),mu=(e,t,n)=>{const r=n===""?"":`with ${n.trim()}() `,o=fu.bind(null,r,t.toString());Object.defineProperty(o,"name",du),Object.defineProperty(e,"toString",{...pu,value:o})};function hu(e,t,{ignoreNonConfigurable:n=!1}={}){const{name:r}=e;for(const o of Reflect.ownKeys(t))cu(e,t,o,n);return lu(e,t),mu(e,t,r),e}const $e=new WeakMap,xr=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let n,r=0;const o=e.displayName||e.name||"<anonymous>",s=function(...u){if($e.set(s,++r),r===1)n=e.apply(this,u),e=null;else if(t.throw===!0)throw new Error(`Function \`${o}\` can only be called once`);return n};return hu(s,e),$e.set(s,r),s};xr.callCount=e=>{if(!$e.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return $e.get(e)};const gu=()=>{const e=Sr-Mr+1;return Array.from({length:e},Cu)},Cu=(e,t)=>({name:`SIGRT${t+1}`,number:Mr+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Mr=34,Sr=64,Eu=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}],Pr=()=>{const e=gu();return[...Eu,...e].map(Fu)},Fu=({name:e,number:t,description:n,action:r,forced:o=!1,standard:s})=>{const{signals:{[e]:u}}=Gt,i=u!==void 0;return{name:e,number:i?u:t,description:n,supported:i,action:r,forced:o,standard:s}},yu=()=>{const e=Pr();return Object.fromEntries(e.map(bu))},bu=({name:e,number:t,description:n,supported:r,action:o,forced:s,standard:u})=>[e,{name:e,number:t,description:n,supported:r,action:o,forced:s,standard:u}],wu=yu(),Au=()=>{const e=Pr(),t=Sr+1,n=Array.from({length:t},(r,o)=>vu(o,e));return Object.assign({},...n)},vu=(e,t)=>{const n=$u(e,t);if(n===void 0)return{};const{name:r,description:o,supported:s,action:u,forced:i,standard:c}=n;return{[e]:{name:r,number:e,description:o,supported:s,action:u,forced:i,standard:c}}},$u=(e,t)=>{const n=t.find(({name:r})=>Gt.signals[r]===e);return n!==void 0?n:t.find(r=>r.number===e)};Au();const Bu=({timedOut:e,timeout:t,errorCode:n,signal:r,signalDescription:o,exitCode:s,isCanceled:u})=>e?`timed out after ${t} milliseconds`:u?"was canceled":n!==void 0?`failed with ${n}`:r!==void 0?`was killed with ${r} (${o})`:s!==void 0?`failed with exit code ${s}`:"failed",Ir=({stdout:e,stderr:t,all:n,error:r,signal:o,exitCode:s,command:u,escapedCommand:i,timedOut:c,isCanceled:l,killed:f,parsed:{options:{timeout:a,cwd:D=I.cwd()}}})=>{s=s===null?void 0:s,o=o===null?void 0:o;const p=o===void 0?void 0:wu[o].description,d=r&&r.code,m=`Command ${Bu({timedOut:c,timeout:a,errorCode:d,signal:o,signalDescription:p,exitCode:s,isCanceled:l})}: ${u}`,E=Object.prototype.toString.call(r)==="[object Error]",b=E?`${m}
26
- ${r.message}`:m,A=[b,t,e].filter(Boolean).join(`
27
- `);return E?(r.originalMessage=r.message,r.message=A):r=new Error(A),r.shortMessage=b,r.command=u,r.escapedCommand=i,r.exitCode=s,r.signal=o,r.signalDescription=p,r.stdout=e,r.stderr=t,r.cwd=D,n!==void 0&&(r.all=n),"bufferedData"in r&&delete r.bufferedData,r.failed=!0,r.timedOut=!!c,r.isCanceled=l,r.killed=f&&!c,r},Be=["stdin","stdout","stderr"],Ou=e=>Be.some(t=>e[t]!==void 0),xu=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return Be.map(r=>e[r]);if(Ou(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Be.map(r=>`\`${r}\``).join(", ")}`);if(typeof t=="string")return t;if(!Array.isArray(t))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);const n=Math.max(t.length,Be.length);return Array.from({length:n},(r,o)=>t[o])};var Z={exports:{}},Oe={exports:{}};Oe.exports;var _r;function Mu(){return _r||(_r=1,function(e){e.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],process.platform!=="win32"&&e.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),process.platform==="linux"&&e.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")}(Oe)),Oe.exports}var y=v.process;const Y=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};if(!Y(y))Z.exports=function(){return function(){}};else{var Su=Ht,ce=Mu(),Pu=/^win/i.test(y.platform),xe=Ut;typeof xe!="function"&&(xe=xe.EventEmitter);var $;y.__signal_exit_emitter__?$=y.__signal_exit_emitter__:($=y.__signal_exit_emitter__=new xe,$.count=0,$.emitted={}),$.infinite||($.setMaxListeners(1/0),$.infinite=!0),Z.exports=function(e,t){if(!Y(v.process))return function(){};Su.equal(typeof e,"function","a callback must be provided for exit handler"),De===!1&&Tr();var n="exit";t&&t.alwaysLast&&(n="afterexit");var r=function(){$.removeListener(n,e),$.listeners("exit").length===0&&$.listeners("afterexit").length===0&&it()};return $.on(n,e),r};var it=function(){!De||!Y(v.process)||(De=!1,ce.forEach(function(t){try{y.removeListener(t,at[t])}catch{}}),y.emit=ct,y.reallyExit=Lr,$.count-=1)};Z.exports.unload=it;var ee=function(t,n,r){$.emitted[t]||($.emitted[t]=!0,$.emit(t,n,r))},at={};ce.forEach(function(e){at[e]=function(){if(Y(v.process)){var n=y.listeners(e);n.length===$.count&&(it(),ee("exit",null,e),ee("afterexit",null,e),Pu&&e==="SIGHUP"&&(e="SIGINT"),y.kill(y.pid,e))}}}),Z.exports.signals=function(){return ce};var De=!1,Tr=function(){De||!Y(v.process)||(De=!0,$.count+=1,ce=ce.filter(function(t){try{return y.on(t,at[t]),!0}catch{return!1}}),y.emit=_u,y.reallyExit=Iu)};Z.exports.load=Tr;var Lr=y.reallyExit,Iu=function(t){Y(v.process)&&(y.exitCode=t||0,ee("exit",y.exitCode,null),ee("afterexit",y.exitCode,null),Lr.call(y,y.exitCode))},ct=y.emit,_u=function(t,n){if(t==="exit"&&Y(v.process)){n!==void 0&&(y.exitCode=n);var r=ct.apply(this,arguments);return ee("exit",y.exitCode,null),ee("afterexit",y.exitCode,null),r}else return ct.apply(this,arguments)}}var Tu=Z.exports,Lu=V(Tu);const Ru=1e3*5,Nu=(e,t="SIGTERM",n={})=>{const r=e(t);return ku(e,t,n,r),r},ku=(e,t,n,r)=>{if(!ju(t,n,r))return;const o=Hu(n),s=setTimeout(()=>{e("SIGKILL")},o);s.unref&&s.unref()},ju=(e,{forceKillAfterTimeout:t},n)=>Gu(e)&&t!==!1&&n,Gu=e=>e===xn.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",Hu=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return Ru;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},Uu=(e,t)=>{e.kill()&&(t.isCanceled=!0)},Ku=(e,t,n)=>{e.kill(t),n(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},qu=(e,{timeout:t,killSignal:n="SIGTERM"},r)=>{if(t===0||t===void 0)return r;let o;const s=new Promise((i,c)=>{o=setTimeout(()=>{Ku(e,n,c)},t)}),u=r.finally(()=>{clearTimeout(o)});return Promise.race([s,u])},zu=({timeout:e})=>{if(e!==void 0&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)},Yu=async(e,{cleanup:t,detached:n},r)=>{if(!t||n)return r;const o=Lu(()=>{e.kill()});return r.finally(()=>{o()})};function Rr(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}function Nr(e){return Rr(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}const Wu=e=>e instanceof Bn&&typeof e.then=="function",Dt=(e,t,n)=>{if(typeof n=="string")return e[t].pipe(Mn(n)),e;if(Nr(n))return e[t].pipe(n),e;if(!Wu(n))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!Nr(n.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(n.stdin),n},Ju=e=>{e.stdout!==null&&(e.pipeStdout=Dt.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=Dt.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=Dt.bind(void 0,e,"all"))};var le={exports:{}};const{PassThrough:Vu}=Re;var Xu=e=>{e={...e};const{array:t}=e;let{encoding:n}=e;const r=n==="buffer";let o=!1;t?o=!(n||r):n=n||"utf8",r&&(n=null);const s=new Vu({objectMode:o});n&&s.setEncoding(n);let u=0;const i=[];return s.on("data",c=>{i.push(c),o?u=i.length:u+=c.length}),s.getBufferedValue=()=>t?i:r?Buffer.concat(i,u):i.join(""),s.getBufferedLength=()=>u,s};const{constants:Qu}=Pn,Zu=Re,{promisify:ei}=Kt,ti=Xu,ri=ei(Zu.pipeline);class kr extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function lt(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:n}=t,r=ti(t);return await new Promise((o,s)=>{const u=i=>{i&&r.getBufferedLength()<=Qu.MAX_LENGTH&&(i.bufferedData=r.getBufferedValue()),s(i)};(async()=>{try{await ri(e,r),o()}catch(i){u(i)}})(),r.on("data",()=>{r.getBufferedLength()>n&&u(new kr)})}),r.getBufferedValue()}le.exports=lt,le.exports.buffer=(e,t)=>lt(e,{...t,encoding:"buffer"}),le.exports.array=(e,t)=>lt(e,{...t,array:!0}),le.exports.MaxBufferError=kr;var ni=le.exports,jr=V(ni);const{PassThrough:oi}=Re;var si=function(){var e=[],t=new oi({objectMode:!0});return t.setMaxListeners(0),t.add=n,t.isEmpty=r,t.on("unpipe",o),Array.prototype.slice.call(arguments).forEach(n),t;function n(s){return Array.isArray(s)?(s.forEach(n),this):(e.push(s),s.once("end",o.bind(null,s)),s.once("error",t.emit.bind(t,"error")),s.pipe(t,{end:!1}),this)}function r(){return e.length==0}function o(s){e=e.filter(function(u){return u!==s}),!e.length&&t.readable&&t.end()}},ui=V(si);const ii=e=>{if(e!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},ai=({input:e,inputFile:t})=>typeof t!="string"?e:(ii(e),Sn(t)),ci=(e,t)=>{const n=ai(t);n!==void 0&&(Rr(n)?n.pipe(e.stdin):e.stdin.end(n))},Di=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const n=ui();return e.stdout&&n.add(e.stdout),e.stderr&&n.add(e.stderr),n},ft=async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(n){return n.bufferedData}}},pt=(e,{encoding:t,buffer:n,maxBuffer:r})=>{if(!(!e||!n))return t?jr(e,{encoding:t,maxBuffer:r}):jr.buffer(e,{maxBuffer:r})},li=async({stdout:e,stderr:t,all:n},{encoding:r,buffer:o,maxBuffer:s},u)=>{const i=pt(e,{encoding:r,buffer:o,maxBuffer:s}),c=pt(t,{encoding:r,buffer:o,maxBuffer:s}),l=pt(n,{encoding:r,buffer:o,maxBuffer:s*2});try{return await Promise.all([u,i,c,l])}catch(f){return Promise.all([{error:f,signal:f.signal,timedOut:f.timedOut},ft(e,i),ft(t,c),ft(n,l)])}},fi=(async()=>{})().constructor.prototype,pi=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(fi,e)]),Gr=(e,t)=>{for(const[n,r]of pi){const o=typeof t=="function"?(...s)=>Reflect.apply(r.value,t(),s):r.value.bind(t);Reflect.defineProperty(e,n,{...r,value:o})}},di=e=>new Promise((t,n)=>{e.on("exit",(r,o)=>{t({exitCode:r,signal:o})}),e.on("error",r=>{n(r)}),e.stdin&&e.stdin.on("error",r=>{n(r)})}),Hr=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],mi=/^[\w.-]+$/,hi=/"/g,gi=e=>typeof e!="string"||mi.test(e)?e:`"${e.replace(hi,'\\"')}"`,Ci=(e,t)=>Hr(e,t).join(" "),Ei=(e,t)=>Hr(e,t).map(n=>gi(n)).join(" "),Fi=In("execa").enabled,Me=(e,t)=>String(e).padStart(t,"0"),yi=()=>{const e=new Date;return`${Me(e.getHours(),2)}:${Me(e.getMinutes(),2)}:${Me(e.getSeconds(),2)}.${Me(e.getMilliseconds(),3)}`},bi=(e,{verbose:t})=>{t&&I.stderr.write(`[${yi()}] ${e}
28
- `)},wi=1e3*1e3*100,Ai=({env:e,extendEnv:t,preferLocal:n,localDir:r,execPath:o})=>{const s=t?{...I.env,...e}:e;return n?au({env:s,cwd:r,execPath:o}):s},vi=(e,t,n={})=>{const r=nu._parse(e,t,n);return e=r.command,t=r.args,n=r.options,n={maxBuffer:wi,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:n.cwd||I.cwd(),execPath:I.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:Fi,...n},n.env=Ai(n),n.stdio=xu(n),I.platform==="win32"&&J.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:n,parsed:r}},dt=(e,t,n)=>typeof t!="string"&&!$n.isBuffer(t)?n===void 0?void 0:"":e.stripFinalNewline?ou(t):t;function te(e,t,n){const r=vi(e,t,n),o=Ci(e,t),s=Ei(e,t);bi(s,r.options),zu(r.options);let u;try{u=kt.spawn(r.file,r.args,r.options)}catch(p){const d=new kt.ChildProcess,h=Promise.reject(Ir({error:p,stdout:"",stderr:"",all:"",command:o,escapedCommand:s,parsed:r,timedOut:!1,isCanceled:!1,killed:!1}));return Gr(d,h),d}const i=di(u),c=qu(u,r.options,i),l=Yu(u,r.options,c),f={isCanceled:!1};u.kill=Nu.bind(null,u.kill.bind(u)),u.cancel=Uu.bind(null,u,f);const D=xr(async()=>{const[{error:p,exitCode:d,signal:h,timedOut:m},E,b,A]=await li(u,r.options,l),R=dt(r.options,E),N=dt(r.options,b),se=dt(r.options,A);if(p||d!==0||h!==null){const w=Ir({error:p,exitCode:d,signal:h,stdout:R,stderr:N,all:se,command:o,escapedCommand:s,parsed:r,timedOut:m,isCanceled:f.isCanceled||(r.options.signal?r.options.signal.aborted:!1),killed:u.killed});if(!r.options.reject)return w;throw w}return{command:o,escapedCommand:s,exitCode:0,stdout:R,stderr:N,all:se,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return ci(u,r.options),u.all=Di(u,r.options),Ju(u),Gr(u,D),u}class H{static create(t,n){return new t(n)}}const W={locale:"en",maxLength:50,type:"conventional",generate:1,promptPath:""},$i={"":"<commit message>",conventional:`<type>(<optional scope>): <description>
24
+ `.charCodeAt(),r=typeof e=="string"?"\r":"\r".charCodeAt();return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===r&&(e=e.slice(0,-1)),e}function Or(e={}){const{env:t=process.env,platform:r=process.platform}=e;return r!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"}const su=({cwd:e=I.cwd(),path:t=I.env[Or()],preferLocal:r=!0,execPath:n=I.execPath,addExecPath:o=!0}={})=>{const s=e instanceof URL?jt(e):e,u=J.resolve(s),i=[];return r&&uu(i,u),o&&iu(i,n,u),[...i,t].join(J.delimiter)},uu=(e,t)=>{let r;for(;r!==t;)e.push(J.join(t,"node_modules/.bin")),r=t,t=J.resolve(t,"..")},iu=(e,t,r)=>{const n=t instanceof URL?jt(t):t;e.push(J.resolve(r,n,".."))},au=({env:e=I.env,...t}={})=>{e={...e};const r=Or({env:e});return t.path=e[r],e[r]=su(t),e},cu=(e,t,r,n)=>{if(r==="length"||r==="prototype"||r==="arguments"||r==="caller")return;const o=Object.getOwnPropertyDescriptor(e,r),s=Object.getOwnPropertyDescriptor(t,r);!Du(o,s)&&n||Object.defineProperty(e,r,s)},Du=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},lu=(e,t)=>{const r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},fu=(e,t)=>`/* Wrapped ${e}*/
25
+ ${t}`,pu=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),du=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),mu=(e,t,r)=>{const n=r===""?"":`with ${r.trim()}() `,o=fu.bind(null,n,t.toString());Object.defineProperty(o,"name",du),Object.defineProperty(e,"toString",{...pu,value:o})};function hu(e,t,{ignoreNonConfigurable:r=!1}={}){const{name:n}=e;for(const o of Reflect.ownKeys(t))cu(e,t,o,r);return lu(e,t),mu(e,t,n),e}const $e=new WeakMap,xr=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let r,n=0;const o=e.displayName||e.name||"<anonymous>",s=function(...u){if($e.set(s,++n),n===1)r=e.apply(this,u),e=null;else if(t.throw===!0)throw new Error(`Function \`${o}\` can only be called once`);return r};return hu(s,e),$e.set(s,n),s};xr.callCount=e=>{if(!$e.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return $e.get(e)};const gu=()=>{const e=Sr-Mr+1;return Array.from({length:e},Cu)},Cu=(e,t)=>({name:`SIGRT${t+1}`,number:Mr+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Mr=34,Sr=64,Eu=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}],Pr=()=>{const e=gu();return[...Eu,...e].map(Fu)},Fu=({name:e,number:t,description:r,action:n,forced:o=!1,standard:s})=>{const{signals:{[e]:u}}=Gt,i=u!==void 0;return{name:e,number:i?u:t,description:r,supported:i,action:n,forced:o,standard:s}},yu=()=>{const e=Pr();return Object.fromEntries(e.map(bu))},bu=({name:e,number:t,description:r,supported:n,action:o,forced:s,standard:u})=>[e,{name:e,number:t,description:r,supported:n,action:o,forced:s,standard:u}],wu=yu(),Au=()=>{const e=Pr(),t=Sr+1,r=Array.from({length:t},(n,o)=>vu(o,e));return Object.assign({},...r)},vu=(e,t)=>{const r=$u(e,t);if(r===void 0)return{};const{name:n,description:o,supported:s,action:u,forced:i,standard:c}=r;return{[e]:{name:n,number:e,description:o,supported:s,action:u,forced:i,standard:c}}},$u=(e,t)=>{const r=t.find(({name:n})=>Gt.signals[n]===e);return r!==void 0?r:t.find(n=>n.number===e)};Au();const Bu=({timedOut:e,timeout:t,errorCode:r,signal:n,signalDescription:o,exitCode:s,isCanceled:u})=>e?`timed out after ${t} milliseconds`:u?"was canceled":r!==void 0?`failed with ${r}`:n!==void 0?`was killed with ${n} (${o})`:s!==void 0?`failed with exit code ${s}`:"failed",Ir=({stdout:e,stderr:t,all:r,error:n,signal:o,exitCode:s,command:u,escapedCommand:i,timedOut:c,isCanceled:l,killed:f,parsed:{options:{timeout:a,cwd:D=I.cwd()}}})=>{s=s===null?void 0:s,o=o===null?void 0:o;const p=o===void 0?void 0:wu[o].description,d=n&&n.code,m=`Command ${Bu({timedOut:c,timeout:a,errorCode:d,signal:o,signalDescription:p,exitCode:s,isCanceled:l})}: ${u}`,E=Object.prototype.toString.call(n)==="[object Error]",b=E?`${m}
26
+ ${n.message}`:m,A=[b,t,e].filter(Boolean).join(`
27
+ `);return E?(n.originalMessage=n.message,n.message=A):n=new Error(A),n.shortMessage=b,n.command=u,n.escapedCommand=i,n.exitCode=s,n.signal=o,n.signalDescription=p,n.stdout=e,n.stderr=t,n.cwd=D,r!==void 0&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!c,n.isCanceled=l,n.killed=f&&!c,n},Be=["stdin","stdout","stderr"],Ou=e=>Be.some(t=>e[t]!==void 0),xu=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return Be.map(n=>e[n]);if(Ou(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Be.map(n=>`\`${n}\``).join(", ")}`);if(typeof t=="string")return t;if(!Array.isArray(t))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);const r=Math.max(t.length,Be.length);return Array.from({length:r},(n,o)=>t[o])};var Z={exports:{}},Oe={exports:{}};Oe.exports;var _r;function Mu(){return _r||(_r=1,function(e){e.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],process.platform!=="win32"&&e.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),process.platform==="linux"&&e.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")}(Oe)),Oe.exports}var y=v.process;const Y=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};if(!Y(y))Z.exports=function(){return function(){}};else{var Su=Ht,ce=Mu(),Pu=/^win/i.test(y.platform),xe=Ut;typeof xe!="function"&&(xe=xe.EventEmitter);var $;y.__signal_exit_emitter__?$=y.__signal_exit_emitter__:($=y.__signal_exit_emitter__=new xe,$.count=0,$.emitted={}),$.infinite||($.setMaxListeners(1/0),$.infinite=!0),Z.exports=function(e,t){if(!Y(v.process))return function(){};Su.equal(typeof e,"function","a callback must be provided for exit handler"),De===!1&&Tr();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){$.removeListener(r,e),$.listeners("exit").length===0&&$.listeners("afterexit").length===0&&it()};return $.on(r,e),n};var it=function(){!De||!Y(v.process)||(De=!1,ce.forEach(function(t){try{y.removeListener(t,at[t])}catch{}}),y.emit=ct,y.reallyExit=Lr,$.count-=1)};Z.exports.unload=it;var ee=function(t,r,n){$.emitted[t]||($.emitted[t]=!0,$.emit(t,r,n))},at={};ce.forEach(function(e){at[e]=function(){if(Y(v.process)){var r=y.listeners(e);r.length===$.count&&(it(),ee("exit",null,e),ee("afterexit",null,e),Pu&&e==="SIGHUP"&&(e="SIGINT"),y.kill(y.pid,e))}}}),Z.exports.signals=function(){return ce};var De=!1,Tr=function(){De||!Y(v.process)||(De=!0,$.count+=1,ce=ce.filter(function(t){try{return y.on(t,at[t]),!0}catch{return!1}}),y.emit=_u,y.reallyExit=Iu)};Z.exports.load=Tr;var Lr=y.reallyExit,Iu=function(t){Y(v.process)&&(y.exitCode=t||0,ee("exit",y.exitCode,null),ee("afterexit",y.exitCode,null),Lr.call(y,y.exitCode))},ct=y.emit,_u=function(t,r){if(t==="exit"&&Y(v.process)){r!==void 0&&(y.exitCode=r);var n=ct.apply(this,arguments);return ee("exit",y.exitCode,null),ee("afterexit",y.exitCode,null),n}else return ct.apply(this,arguments)}}var Tu=Z.exports,Lu=V(Tu);const Ru=1e3*5,Nu=(e,t="SIGTERM",r={})=>{const n=e(t);return ku(e,t,r,n),n},ku=(e,t,r,n)=>{if(!ju(t,r,n))return;const o=Hu(r),s=setTimeout(()=>{e("SIGKILL")},o);s.unref&&s.unref()},ju=(e,{forceKillAfterTimeout:t},r)=>Gu(e)&&t!==!1&&r,Gu=e=>e===xn.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",Hu=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return Ru;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},Uu=(e,t)=>{e.kill()&&(t.isCanceled=!0)},Ku=(e,t,r)=>{e.kill(t),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},qu=(e,{timeout:t,killSignal:r="SIGTERM"},n)=>{if(t===0||t===void 0)return n;let o;const s=new Promise((i,c)=>{o=setTimeout(()=>{Ku(e,r,c)},t)}),u=n.finally(()=>{clearTimeout(o)});return Promise.race([s,u])},zu=({timeout:e})=>{if(e!==void 0&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)},Yu=async(e,{cleanup:t,detached:r},n)=>{if(!t||r)return n;const o=Lu(()=>{e.kill()});return n.finally(()=>{o()})};function Rr(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}function Nr(e){return Rr(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}const Wu=e=>e instanceof Bn&&typeof e.then=="function",Dt=(e,t,r)=>{if(typeof r=="string")return e[t].pipe(Mn(r)),e;if(Nr(r))return e[t].pipe(r),e;if(!Wu(r))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!Nr(r.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(r.stdin),r},Ju=e=>{e.stdout!==null&&(e.pipeStdout=Dt.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=Dt.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=Dt.bind(void 0,e,"all"))};var le={exports:{}};const{PassThrough:Vu}=Re;var Xu=e=>{e={...e};const{array:t}=e;let{encoding:r}=e;const n=r==="buffer";let o=!1;t?o=!(r||n):r=r||"utf8",n&&(r=null);const s=new Vu({objectMode:o});r&&s.setEncoding(r);let u=0;const i=[];return s.on("data",c=>{i.push(c),o?u=i.length:u+=c.length}),s.getBufferedValue=()=>t?i:n?Buffer.concat(i,u):i.join(""),s.getBufferedLength=()=>u,s};const{constants:Qu}=Pn,Zu=Re,{promisify:ei}=Kt,ti=Xu,ri=ei(Zu.pipeline);class kr extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function lt(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:r}=t,n=ti(t);return await new Promise((o,s)=>{const u=i=>{i&&n.getBufferedLength()<=Qu.MAX_LENGTH&&(i.bufferedData=n.getBufferedValue()),s(i)};(async()=>{try{await ri(e,n),o()}catch(i){u(i)}})(),n.on("data",()=>{n.getBufferedLength()>r&&u(new kr)})}),n.getBufferedValue()}le.exports=lt,le.exports.buffer=(e,t)=>lt(e,{...t,encoding:"buffer"}),le.exports.array=(e,t)=>lt(e,{...t,array:!0}),le.exports.MaxBufferError=kr;var ni=le.exports,jr=V(ni);const{PassThrough:oi}=Re;var si=function(){var e=[],t=new oi({objectMode:!0});return t.setMaxListeners(0),t.add=r,t.isEmpty=n,t.on("unpipe",o),Array.prototype.slice.call(arguments).forEach(r),t;function r(s){return Array.isArray(s)?(s.forEach(r),this):(e.push(s),s.once("end",o.bind(null,s)),s.once("error",t.emit.bind(t,"error")),s.pipe(t,{end:!1}),this)}function n(){return e.length==0}function o(s){e=e.filter(function(u){return u!==s}),!e.length&&t.readable&&t.end()}},ui=V(si);const ii=e=>{if(e!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},ai=({input:e,inputFile:t})=>typeof t!="string"?e:(ii(e),Sn(t)),ci=(e,t)=>{const r=ai(t);r!==void 0&&(Rr(r)?r.pipe(e.stdin):e.stdin.end(r))},Di=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const r=ui();return e.stdout&&r.add(e.stdout),e.stderr&&r.add(e.stderr),r},ft=async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(r){return r.bufferedData}}},pt=(e,{encoding:t,buffer:r,maxBuffer:n})=>{if(!(!e||!r))return t?jr(e,{encoding:t,maxBuffer:n}):jr.buffer(e,{maxBuffer:n})},li=async({stdout:e,stderr:t,all:r},{encoding:n,buffer:o,maxBuffer:s},u)=>{const i=pt(e,{encoding:n,buffer:o,maxBuffer:s}),c=pt(t,{encoding:n,buffer:o,maxBuffer:s}),l=pt(r,{encoding:n,buffer:o,maxBuffer:s*2});try{return await Promise.all([u,i,c,l])}catch(f){return Promise.all([{error:f,signal:f.signal,timedOut:f.timedOut},ft(e,i),ft(t,c),ft(r,l)])}},fi=(async()=>{})().constructor.prototype,pi=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(fi,e)]),Gr=(e,t)=>{for(const[r,n]of pi){const o=typeof t=="function"?(...s)=>Reflect.apply(n.value,t(),s):n.value.bind(t);Reflect.defineProperty(e,r,{...n,value:o})}},di=e=>new Promise((t,r)=>{e.on("exit",(n,o)=>{t({exitCode:n,signal:o})}),e.on("error",n=>{r(n)}),e.stdin&&e.stdin.on("error",n=>{r(n)})}),Hr=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],mi=/^[\w.-]+$/,hi=/"/g,gi=e=>typeof e!="string"||mi.test(e)?e:`"${e.replace(hi,'\\"')}"`,Ci=(e,t)=>Hr(e,t).join(" "),Ei=(e,t)=>Hr(e,t).map(r=>gi(r)).join(" "),Fi=In("execa").enabled,Me=(e,t)=>String(e).padStart(t,"0"),yi=()=>{const e=new Date;return`${Me(e.getHours(),2)}:${Me(e.getMinutes(),2)}:${Me(e.getSeconds(),2)}.${Me(e.getMilliseconds(),3)}`},bi=(e,{verbose:t})=>{t&&I.stderr.write(`[${yi()}] ${e}
28
+ `)},wi=1e3*1e3*100,Ai=({env:e,extendEnv:t,preferLocal:r,localDir:n,execPath:o})=>{const s=t?{...I.env,...e}:e;return r?au({env:s,cwd:n,execPath:o}):s},vi=(e,t,r={})=>{const n=nu._parse(e,t,r);return e=n.command,t=n.args,r=n.options,r={maxBuffer:wi,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||I.cwd(),execPath:I.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:Fi,...r},r.env=Ai(r),r.stdio=xu(r),I.platform==="win32"&&J.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:r,parsed:n}},dt=(e,t,r)=>typeof t!="string"&&!$n.isBuffer(t)?r===void 0?void 0:"":e.stripFinalNewline?ou(t):t;function te(e,t,r){const n=vi(e,t,r),o=Ci(e,t),s=Ei(e,t);bi(s,n.options),zu(n.options);let u;try{u=kt.spawn(n.file,n.args,n.options)}catch(p){const d=new kt.ChildProcess,h=Promise.reject(Ir({error:p,stdout:"",stderr:"",all:"",command:o,escapedCommand:s,parsed:n,timedOut:!1,isCanceled:!1,killed:!1}));return Gr(d,h),d}const i=di(u),c=qu(u,n.options,i),l=Yu(u,n.options,c),f={isCanceled:!1};u.kill=Nu.bind(null,u.kill.bind(u)),u.cancel=Uu.bind(null,u,f);const D=xr(async()=>{const[{error:p,exitCode:d,signal:h,timedOut:m},E,b,A]=await li(u,n.options,l),R=dt(n.options,E),N=dt(n.options,b),se=dt(n.options,A);if(p||d!==0||h!==null){const w=Ir({error:p,exitCode:d,signal:h,stdout:R,stderr:N,all:se,command:o,escapedCommand:s,parsed:n,timedOut:m,isCanceled:f.isCanceled||(n.options.signal?n.options.signal.aborted:!1),killed:u.killed});if(!n.options.reject)return w;throw w}return{command:o,escapedCommand:s,exitCode:0,stdout:R,stderr:N,all:se,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return ci(u,n.options),u.all=Di(u,n.options),Ju(u),Gr(u,D),u}class H{static create(t,r){return new t(r)}}const W={locale:"en",maxLength:50,type:"conventional",generate:1,promptPath:""},$i={"":"<commit message>",conventional:`<type>(<optional scope>): <description>
29
29
 
30
30
  [optional body]
31
31
 
@@ -37,38 +37,38 @@ ${r.message}`:m,A=[b,t,e].filter(Boolean).join(`
37
37
  ${Object.entries({":sparkles:":"Introduce new features.",":bug:":"Fix a bug.",":memo:":"Add or update documentation.",":art:":"Improve structure / format of the code.",":zap:":"Improve performance.",":fire:":"Remove code or files.",":ambulance:":"Critical hotfix.",":white_check_mark:":"Add, update, or pass tests.",":lock:":"Fix security or privacy issues.",":rocket:":"Deploy stuff.",":lipstick:":"Add or update the UI and style files.",":tada:":"Begin a project.",":recycle:":"Refactor code.",":wrench:":"Add or update configuration files.",":bulb:":"Add or update comments in source code.",":twisted_rightwards_arrows:":"Merge branches."}).map(([e,t])=>` - ${e}: ${t}`).join(`
38
38
  `)}`,conventional:`
39
39
  ${Object.entries({docs:"Documentation only changes",style:"Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",refactor:"A code change that neither fixes a bug nor adds a feature",perf:"A code change that improves performance",test:"Adding missing tests or correcting existing tests",build:"Changes that affect the build system or external dependencies",ci:"Changes to CI configuration files, scripts",chore:"Other changes that don't modify src or test files",revert:"Reverts a previous commit",feat:"A new feature",fix:"A bug fix"}).map(([e,t])=>` - ${e}: ${t}`).join(`
40
- `)}`},Oi=(e,t)=>e.replace(/{(\w+)}/g,(n,r)=>t[r]?.toString()||W[r]?.toString()),Ur=e=>{const{type:t,maxLength:n,generate:r,locale:o}=e;return["You are an AI assistant specialized in generating high-quality git commit messages following the Conventional Commits specification.","Your task is to create commit messages based on the following guidelines",`1. Language: ${o}`,`2. Format: follow the ${t} Commits format:`,`${$i[t]}`,`3. Types: use one of the following types:${Bi[t]}`,"4. Scope: optional, can be anything specifying the place of the commit change (e.g., component name, file name, module name)","5. Description: ",' - Use imperative, present tense: "change" not "changed" nor "changes"'," - Don't capitalize the first letter"," - No period (.) at the end","6. Body: Optional"," - Use imperative, present tense"," - Wrap lines at 72 characters","7. Footer: Optional",' - Mention any breaking changes, starting with "BREAKING CHANGE:"',' - Reference any related issues or pull requests (e.g., "Fixes #123", "Closes #456")',"8. General Rules:"," - Be concise but descriptive",' - Focus on the "why" behind the change, not just the "what"'," - Separate subject from body with a blank line"," - Use the body to explain what and why vs. how",`Generate ${r} commit messages based on these guidelines.`].filter(Boolean).join(`
41
- `)},mt=e=>`Provide your response as a JSON array where each element is an object with "subject", "body", and "footer" keys.
42
- The "subject" should include the ${e==="conventional"?"type":"emoji"}, optional scope, and description . If there's no body or footer, use an empty string for those fields.
43
- Example response format:
44
- [
45
- {
46
- "subject": "string",
47
- "body": "string",
48
- "footer": "string"
49
- },
50
- ]`,re=e=>{const{type:t,generate:n,promptPath:r}=e;if(!r)return`${Ur(e)}
51
- ${mt(t)}`;try{const o=k.readFileSync(P.resolve(r),"utf-8");return`${Oi(o,e)}
52
- ${mt(t)}`}catch{return`${Ur(e)}
53
- ${mt(t)}`}},M={OPEN_AI:"OPENAI_KEY",GEMINI:"GEMINI_KEY",ANTHROPIC:"ANTHROPIC_KEY",HUGGINGFACE:"HUGGINGFACE_COOKIE",MISTRAL:"MISTRAL_KEY",CODESTRAL:"CODESTRAL_KEY",OLLAMA:"OLLAMA_MODEL",COHERE:"COHERE_KEY",GROQ:"GROQ_KEY"},Kr=Object.values(M).map(e=>e);class U{constructor(t){this.handleError$=n=>{let r="An error occurred";return n.message&&(r=n.message),x({name:`${this.errorPrefix} ${r}`,value:r,isError:!0,disabled:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}buildPrompt(t,n,r,o,s,u){const i={...W,locale:t,maxLength:o,type:s,generate:r,promptPath:u};return`${re(i)}}
40
+ `)}`},Oi=(e,t)=>e.replace(/{(\w+)}/g,(r,n)=>t[n]?.toString()||W[n]?.toString()),Ur=e=>{const{type:t,maxLength:r,generate:n,locale:o}=e;return["You are an AI assistant specialized in generating high-quality git commit messages following the Conventional Commits specification.","Your task is to create commit messages based on the following guidelines",`1. Language: ${o}`,`2. Format: follow the ${t} Commits format:`,`${$i[t]}`,`3. Types: use one of the following types:${Bi[t]}`,"4. Scope: optional, can be anything specifying the place of the commit change (e.g., component name, file name, module name)","5. Description: ",' - Use imperative, present tense: "change" not "changed" nor "changes"'," - Don't capitalize the first letter"," - No period (.) at the end","6. Body: Optional"," - Use imperative, present tense"," - Wrap lines at 72 characters","7. Footer: Optional",' - Mention any breaking changes, starting with "BREAKING CHANGE:"',' - Reference any related issues or pull requests (e.g., "Fixes #123", "Closes #456")',"8. General Rules:"," - Be concise but descriptive",' - Focus on the "why" behind the change, not just the "what"'," - Separate subject from body with a blank line"," - Use the body to explain what and why vs. how"].filter(Boolean).join(`
41
+ `)},mt=(e,t)=>[`Generate exactly ${t} ${e} commit message${t!==1?"s":""}.`,`Provide your response as a JSON array containing exactly ${t} object${t!==1?"s":""}, each with the following keys:`,'- "subject": The main commit message. It should be a concise summary of the changes.','- "body": An optional detailed explanation of the changes. If not needed, use an empty string.','- "footer": An optional footer for metadata like issue tracker IDs. If not needed, use an empty string.',`The array must always contain ${t} element${t!==1?"s":""}, no more and no less.`,`Example response format:
42
+ [
43
+ ${Array(t).fill(null).map((r,n)=>`{
44
+ "subject": "fix: fix bug in user authentication process",
45
+ "body": "- Updated login function to handle edge cases\\n- Added additional error logging for debugging\\n- Refactored password hashing method for better security",
46
+ "footer": ""
47
+ }`).join(`,
48
+ `)}
49
+ ]`].filter(Boolean).join(`
50
+ `),re=e=>{const{type:t,generate:r,promptPath:n}=e;if(!n)return`${Ur(e)}
51
+ ${mt(t,r)}`;try{const o=k.readFileSync(P.resolve(n),"utf-8");return`${Oi(o,e)}
52
+ ${mt(t,r)}`}catch{return`${Ur(e)}
53
+ ${mt(t,r)}`}},M={OPEN_AI:"OPENAI_KEY",GEMINI:"GEMINI_KEY",ANTHROPIC:"ANTHROPIC_KEY",HUGGINGFACE:"HUGGINGFACE_COOKIE",MISTRAL:"MISTRAL_KEY",CODESTRAL:"CODESTRAL_KEY",OLLAMA:"OLLAMA_MODEL",COHERE:"COHERE_KEY",GROQ:"GROQ_KEY"},Kr=Object.values(M).map(e=>e);class U{constructor(t){this.handleError$=r=>{let n="An error occurred";return r.message&&(n=r.message),x({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}buildPrompt(t,r,n,o,s,u){const i={...W,locale:t,maxLength:o,type:s,generate:n,promptPath:u};return`${re(i)}}
54
54
  Here are diff:
55
- ${n}`}sanitizeMessage(t,n,r,o){try{const u=JSON.parse(t).map(i=>this.extractMessageAsType(i,n)).map(i=>o?{title:`${i.subject}`,value:`${i.subject}`}:{title:`${i.subject}`,value:`${i.subject}${i.body?`
55
+ ${r}`}sanitizeMessage(t,r,n,o){try{const u=JSON.parse(t).map(i=>this.extractMessageAsType(i,r)).map(i=>o?{title:`${i.subject}`,value:`${i.subject}`}:{title:`${i.subject}`,value:`${i.subject}${i.body?`
56
56
 
57
57
  ${i.body}`:""}${i.footer?`
58
58
 
59
- ${i.footer}`:""}`});return u.length>r?u.slice(0,r):u}catch{const u=/\[[\s\S]*?\]/;try{const i=t.match(u);if(!i)return[];const c=i[0],f=JSON.parse(c).map(a=>this.extractMessageAsType(a,n)).map(a=>o?{title:`${a.subject}`,value:`${a.subject}`}:{title:`${a.subject}`,value:`${a.subject}${a.body?`
59
+ ${i.footer}`:""}`});return u.length>n?u.slice(0,n):u}catch{const u=/\[[\s\S]*?\]/;try{const i=t.match(u);if(!i)return[];const c=i[0],f=JSON.parse(c).map(a=>this.extractMessageAsType(a,r)).map(a=>o?{title:`${a.subject}`,value:`${a.subject}`}:{title:`${a.subject}`,value:`${a.subject}${a.body?`
60
60
 
61
61
  ${a.body}`:""}${a.footer?`
62
62
 
63
- ${a.footer}`:""}`});return f.length>r?f.slice(0,r):f}catch{return[]}}}extractMessageAsType(t,n){switch(n){case"conventional":const r=/(\w+)(?:\(.*?\))?:\s*(.*)/,o=t.subject.match(r),s=o?o[0]:t.subject;return{...t,subject:this.normalizeCommitMessage(s)};case"gitmoji":const u=/:\w*:\s*(.*)/,i=t.subject.match(u);return{...t,subject:i?i[0].toLowerCase():t.subject};default:return t}}normalizeCommitMessage(t){const n=/^(\w+)(\(.*?\))?:\s(.*)$/,r=t.match(n);if(r){const[,o,s,u]=r,i=o.toLowerCase(),c=u.charAt(0).toLowerCase()+u.slice(1);t=`${i}${s||""}: ${c}`}return t}}var qr="1.12.3",xi="A Reactive CLI that generates git commit messages with various AI";class F extends Error{}const ht=" ",fe=e=>{e instanceof Error&&(e instanceof F||(e.stack&&console.error(g.dim(e.stack.split(`
63
+ ${a.footer}`:""}`});return f.length>n?f.slice(0,n):f}catch{return[]}}}extractMessageAsType(t,r){switch(r){case"conventional":const n=/(\w+)(?:\(.*?\))?:\s*(.*)/,o=t.subject.match(n),s=o?o[0]:t.subject;return{...t,subject:this.normalizeCommitMessage(s)};case"gitmoji":const u=/:\w*:\s*(.*)/,i=t.subject.match(u);return{...t,subject:i?i[0].toLowerCase():t.subject};default:return t}}normalizeCommitMessage(t){const r=/^(\w+)(\(.*?\))?:\s(.*)$/,n=t.match(r);if(n){const[,o,s,u]=n,i=o.toLowerCase(),c=u.charAt(0).toLowerCase()+u.slice(1);t=`${i}${s||""}: ${c}`}return t}}var qr="1.12.5",xi="A Reactive CLI that generates git commit messages with various AI";class F extends Error{}const ht=" ",fe=e=>{e instanceof Error&&(e instanceof F||(e.stack&&console.error(g.dim(e.stack.split(`
64
64
  `).slice(1).join(`
65
65
  `))),console.error(`
66
66
  ${ht}${g.dim(`aicommit2 v${qr}`)}`),console.error(`
67
- ${ht}Please open a Bug report with the information above:`),console.error(`${ht}https://github.com/tak-bro/aicommit2/issues/new/choose`)))},zr=e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`,Yr=(e,t)=>{const n=Math.ceil(e),r=Math.floor(t);return Math.floor(Math.random()*(r-n+1))+n},pe=(e,t)=>e.disabled&&!t.disabled?1:!e.disabled&&t.disabled?-1:0,Mi="done",Si=(e,t,n=!1)=>{const r=e.indexOf(t);if(r!==-1){const o=n?t.length:0;return e.slice(0,r+o).trim()}return e},Wr=P.join(je.homedir(),".aicommit2_log"),Pi=new Date,K=(e,t,n,r)=>{const o=`[${e} Response]`,s=Ii(Pi,t),u=`${Wr}/${s}`;if(k.existsSync(u)){const c=k.readFileSync(u,"utf-8");Jr(u,`${o}
68
- ${r}
67
+ ${ht}Please open a Bug report with the information above:`),console.error(`${ht}https://github.com/tak-bro/aicommit2/issues/new/choose`)))},zr=e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`,Yr=(e,t)=>{const r=Math.ceil(e),n=Math.floor(t);return Math.floor(Math.random()*(n-r+1))+r},pe=(e,t)=>e.disabled&&!t.disabled?1:!e.disabled&&t.disabled?-1:0,Mi="done",Si=(e,t,r=!1)=>{const n=e.indexOf(t);if(n!==-1){const o=r?t.length:0;return e.slice(0,n+o).trim()}return e},Wr=P.join(je.homedir(),".aicommit2_log"),Pi=new Date,K=(e,t,r,n)=>{const o=`[${e} Response]`,s=Ii(Pi,t),u=`${Wr}/${s}`;if(k.existsSync(u)){const c=k.readFileSync(u,"utf-8");Jr(u,`${o}
68
+ ${n}
69
69
 
70
- ${c}`);return}const i=Si(n,"Here are diff");Jr(u,`${o}
71
- ${r}
70
+ ${c}`);return}const i=Si(r,"Here are diff");Jr(u,`${o}
71
+ ${n}
72
72
 
73
73
 
74
74
  [AICommit2 Prompt]
@@ -76,27 +76,27 @@ ${i}
76
76
 
77
77
 
78
78
  [Git Diff]
79
- ${t}`)},Ii=(e,t)=>{const{year:n,month:r,day:o,hours:s,minutes:u,seconds:i}=_i(e),l=kn(0).update(t).digest("hex");return`aic2_${n}-${r}-${o}_${s}:${u}:${i}_${l}.log`},Jr=(e,t="")=>{k.mkdirSync(P.dirname(e),{recursive:!0}),k.writeFileSync(e,t,"utf-8")},_i=e=>{const t=e.getFullYear().toString(),n=(e.getMonth()+1).toString().padStart(2,"0"),r=e.getDate().toString().padStart(2,"0"),o=e.getHours().toString().padStart(2,"0"),s=e.getMinutes().toString().padStart(2,"0"),u=e.getSeconds().toString().padStart(2,"0");return{year:t,month:n,day:r,hours:o,minutes:s,seconds:u}};class Ti extends U{constructor(t){super(t),this.params=t,this.handleError$=n=>{const r=n.error?.error?.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return x({name:`${this.errorPrefix} ${r}`,value:r,isError:!0,disabled:!0})},this.colors={primary:"#AE5630",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Anthropic]"),this.errorPrefix=g.red.bold("[Anthropic]"),this.anthropic=new Nn({apiKey:this.params.config.ANTHROPIC_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:n,generate:r,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c={...W,locale:n,maxLength:i,type:o,generate:r,promptPath:s},f=`${re(c)}`,a={max_tokens:this.params.config["max-tokens"],temperature:this.params.config.temperature,system:f,messages:[{role:"user",content:`Here are diff: ${t}`}],model:this.params.config.ANTHROPIC_MODEL},p=(await this.anthropic.messages.create(a)).content.map(({text:d})=>d).join("");return u&&K("Anthropic",t,f,p),this.sanitizeMessage(p,this.params.config.type,r,this.params.config.ignoreBody)}catch(t){const n=t;throw n.code==="ENOTFOUND"?new F(`Error connecting to ${n.hostname} (${n.syscall})`):n}}}class Se{constructor(t={}){if(!t.method)throw new Error("method should be defined!");if(!t.baseURL)throw new Error("baseURL should be defined!");this.config={...t},this.axiosInstance=jn.create(this.config)}setHeaders(t){return this.config.headers=t,this}setParams(t){return this.config.params=t,this}setBody(t){return this.config.data=t,this}setMethod(t){return this.config.method=t,this}async execute(){try{return await this.axiosInstance.request(this.config)}catch(t){throw t}}}class Li extends U{constructor(t){super(t),this.params=t,this.host="https://codestral.mistral.ai",this.apiKey="",this.handleError$=n=>{const r=n.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return x({name:`${this.errorPrefix} ${r}`,value:r,isError:!0,disabled:!0})},this.colors={primary:"#e28c58",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Codestral]"),this.errorPrefix=g.red.bold("[Codestral]"),this.apiKey=this.params.config.CODESTRAL_KEY}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:n,generate:r,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(n,t,r,i,o,s);this.checkAvailableModels();const l=await this.createChatCompletions(c);return u&&K("Codestral",t,c,l),this.sanitizeMessage(l,this.params.config.type,r,this.params.config.ignoreBody)}catch(t){const n=t;throw n.code==="ENOTFOUND"?new F(`Error connecting to ${n.hostname} (${n.syscall})`):n}}checkAvailableModels(){if(["codestral-latest","codestral-2405"].includes(this.params.config.CODESTRAL_MODEL))return!0;throw new Error("Invalid model type of Codestral AI")}async createChatCompletions(t){const r=(await new Se({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.CODESTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed:Yr(10,1e3)}).execute()).data;if(!r.choices||r.choices.length===0||!r.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return r.choices[0].message.content}}class Ri extends U{constructor(t){super(t),this.params=t,this.handleError$=n=>{const r=/"message":\s*"([^"]*)"/,o=n.message.match(r);let s=n?.body?.message;o&&o[1]&&(s=o[1]);const u=`${n.statusCode} ${s}`;return x({name:`${this.errorPrefix} ${u}`,value:s,isError:!0,disabled:!0})},this.colors={primary:"#D18EE2",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Cohere]"),this.errorPrefix=g.red.bold("[Cohere]"),this.cohere=new Gn({token:this.params.config.COHERE_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:n,generate:r,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(n,t,r,i,o,s),l=this.params.config["max-tokens"],a=(await this.cohere.generate({prompt:c,maxTokens:l,temperature:this.params.config.temperature,model:this.params.config.COHERE_MODEL})).generations.map(D=>D.text).join("");return u&&K("Cohere",t,c,a),this.sanitizeMessage(a,this.params.config.type,r,this.params.config.ignoreBody)}catch(t){const n=t;throw n instanceof Hn?new F("Request timed out error!"):n}}}class Ni extends U{constructor(t){super(t),this.params=t,this.handleError$=n=>{const r=n.message||n.toString(),o=/(\[.*?\]\s*[^[]*)/g,s=[...r.matchAll(o)],u=[];s.forEach(c=>u.push(c[1]));const i=u[1]||"An error occurred";return x({name:`${this.errorPrefix} ${i}`,value:i,isError:!0,disabled:!0})},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Gemini]"),this.errorPrefix=g.red.bold("[Gemini]"),this.genAI=new Un(this.params.config.GEMINI_KEY)}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:n,generate:r,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(n,t,r,i,o,s),l=this.params.config["max-tokens"],p=(await(await this.genAI.getGenerativeModel({model:this.params.config.GEMINI_MODEL,generationConfig:{maxOutputTokens:l,temperature:this.params.config.temperature}}).generateContent(c)).response).text();return u&&K("Gemini",t,c,p),this.sanitizeMessage(p,this.params.config.type,r,this.params.config.ignoreBody)}catch(t){const n=t;throw n.code==="ENOTFOUND"?new F(`Error connecting to ${n.hostname} (${n.syscall})`):n}}}class ki extends U{constructor(t){super(t),this.params=t,this.handleError$=n=>{let r="An error occurred";const o=/"message":\s*"([^"]*)"/,s=n.message.match(o);s&&s[1]&&(r=s[1]);const u=`${n.status} ${r}`;return x({name:`${this.errorPrefix} ${u}`,value:r,isError:!0,disabled:!0})},this.colors={primary:"#f55036",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Groq]"),this.errorPrefix=g.red.bold("[Groq]"),this.groq=new Kn({apiKey:this.params.config.GROQ_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:n,generate:r,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c={...W,locale:n,maxLength:i,type:o,generate:r,promptPath:s},f=`${re(c)}`,D=(await this.groq.chat.completions.create({messages:[{role:"system",content:f},{role:"user",content:`Here are diff: ${t}`}],model:this.params.config.GROQ_MODEL},{timeout:this.params.config.timeout})).choices[0].message.content||"";return u&&K("Groq",t,f,D),this.sanitizeMessage(D,this.params.config.type,r,this.params.config.ignoreBody)}catch(t){throw t}}}class ji extends U{constructor(t){super(t),this.params=t,this.headers={accept:"*/*","accept-language":"en-US,en;q=0.9","sec-ch-ua":'"Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin",origin:"https://huggingface.co","Referrer-Policy":"strict-origin-when-cross-origin"},this.models=[],this.currentModelId=null,this.currentConversation=void 0,this.currentConversionID=void 0,this.cookie="",this.colors={primary:"#FED21F",secondary:"#000"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[HuggingFace]"),this.errorPrefix=g.red.bold("[HuggingFace]"),this.cookie=this.params.config.HUGGINGFACE_COOKIE}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{await this.intialize();const t=this.getSystemPrompt(),n=await this.getNewChat(t),r=`Here are diff: ${this.params.stagedDiff.diff}`,s=await(await this.sendMessage(r,n.id)).completeResponsePromise(),{generate:u,logging:i}=this.params.config;return i&&K("HuggingFace",this.params.stagedDiff.diff,t,s),this.sanitizeMessage(s,this.params.config.type,u,this.params.config.ignoreBody)}catch(t){const n=t;throw n.code==="ENOTFOUND"?new F(`Error connecting to ${n.hostname} (${n.syscall})`):n}}async intialize(){const t=await this.getRemoteLlms(),n=t.find(r=>r.name?.toLowerCase()===this.params.config.HUGGINGFACE_MODEL.toLowerCase());if(n){this.currentModel=n,this.currentModelId=n.id;return}this.currentModel=t[0],this.currentModelId=t[0].id}async getRemoteLlms(){const t=await fetch("https://huggingface.co/chat/__data.json",{headers:{...this.headers,cookie:this.cookie},body:null,method:"GET"});if(t.status!==200)throw new Error(`Failed to get remote LLMs with status code: ${t.status}`);const r=(await t.json()).nodes[0].data,o=r[r[0].models],s=[],u=i=>i===-1?null:r[i];for(const i of o){const c=r[i];if(r[c.unlisted])continue;const l={id:u(c.id),name:u(c.name),displayName:u(c.displayName),preprompt:u(c.preprompt),promptExamples:[],websiteUrl:u(c.websiteUrl),description:u(c.description),datasetName:u(c.datasetName),datasetUrl:u(c.datasetUrl),modelUrl:u(c.modelUrl),parameters:{}},f=u(c.promptExamples);if(f!==null){const p=f.map(d=>u(d));l.promptExamples=p.map(d=>({title:r[d.title],prompt:r[d.prompt]}))}const a=u(c.parameters),D={};for(const[p,d]of Object.entries(a)){if(d===-1){D[p]=null;continue}if(Array.isArray(r[d])){D[p]=r[d].map(h=>r[h]);continue}D[p]=r[d]}l.parameters=D,s.push(l)}return this.models=s,s}async getNewChat(t){const n={model:this.currentModelId,preprompt:t};let r=0;for(;r<5;){const o=await fetch("https://huggingface.co/chat/conversation",{headers:{...this.headers,"content-type":"application/json",cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:JSON.stringify(n),method:"POST"}),{conversationId:s}=await o.json();if(s){this.currentConversionID=s;break}else r++}if(!this.currentConversionID)throw new Error("Failed to create new conversion");return await this.getConversationHistory(this.currentConversionID)}async getConversationHistory(t){if(!t)throw new Error("conversationId is required for getConversationHistory");const n=await fetch("https://huggingface.co/chat/conversation/"+t+"/__data.json",{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:null,method:"GET"});if(n.status!=200)throw new Error("Unable get conversation details "+n);{const r=await n.json();return this.metadataParser(r,t)}}metadataParser(t,n){const r={id:"",model:"",systemPrompt:"",title:"",history:[]},o=t.nodes[1].data,s=o[o[0].model],u=o[o[0].preprompt],i=o[o[0].title],c=o[o[0].messages],l=[];for(const f of c){const a=o[f],D=new Date(o[a.createdAt][1]).getTime()/1e3,p=new Date(o[a.updatedAt][1]).getTime()/1e3;l.push({id:o[a.id],role:o[a.from],content:o[a.content],createdAt:D,updatedAt:p})}return r.id=n,r.model=s,r.systemPrompt=u,r.title=i,r.history=l,this.currentConversation=r,r}async sendMessage(t,n){if(t==="")throw new Error("the prompt can not be empty.");if(!n&&!this.currentConversionID?await this.getNewChat():n?(this.currentConversionID=n,await this.getConversationHistory(n)):this.currentConversionID&&await this.getConversationHistory(this.currentConversionID),!this.currentConversation)throw new Error("Failed to create new conversion");const r={inputs:t,id:this.currentConversation.history[this.currentConversation.history.length-1].id,is_retry:!1,is_continue:!1,web_search:!1,tools:{}},o=new FormData;o.append("data",JSON.stringify(r));const s=await fetch("https://huggingface.co/chat/conversation/"+this.currentConversionID,{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/conversation/"+this.currentConversionID},body:o,method:"POST"});function u(D){try{const p=D.split(`
80
- `),d=[];for(const h of p)h.trim()&&d.push(JSON.parse(h));return d}catch{return[{}]}}const i=new TextDecoder;let c="";const l=new TransformStream({async transform(D,p){const d=i.decode(D);try{const h=u(d);for(const m of h)m.type==="finalAnswer"?(c=m?.text||"",p.terminate()):m.type==="stream"&&p.enqueue(m?.token||"")}catch{throw new Error("Error during parsing response")}}}),f=s.body?.pipeThrough(l);async function a(){return new Promise(async(D,p)=>{try{if(!f)p("ModifiedStream undefined");else{const d=f.getReader();for(;;){const{done:h,value:m}=await d.read();if(h){D(c);break}}}}catch(d){p(d)}})}return{id:this.currentConversionID,stream:f,completeResponsePromise:a}}async deleteConversation(t){return(await fetch(`https://huggingface.co/chat/conversation/${t}`,{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:null,method:"DELETE"})).json()}getSystemPrompt(){const{locale:t,generate:n,type:r,promptPath:o}=this.params.config,s=this.params.config["max-length"],u={...W,locale:t,maxLength:s,type:r,generate:n,promptPath:o};return`${re(u)}`}}class Gi extends U{constructor(t){super(t),this.params=t,this.host="https://api.mistral.ai",this.apiKey="",this.handleError$=n=>{const r=n.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return x({name:`${this.errorPrefix} ${r}`,value:r,isError:!0,disabled:!0})},this.colors={primary:"#ff7000",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[MistralAI]"),this.errorPrefix=g.red.bold("[MistralAI]"),this.apiKey=this.params.config.MISTRAL_KEY}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:n,generate:r,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(n,t,r,i,o,s);await this.checkAvailableModels();const l=await this.createChatCompletions(c);return u&&K("MistralAI",t,c,l),this.sanitizeMessage(l,this.params.config.type,r,this.params.config.ignoreBody)}catch(t){const n=t;throw n.code==="ENOTFOUND"?new F(`Error connecting to ${n.hostname} (${n.syscall})`):n}}async checkAvailableModels(){if((await this.getAvailableModels()).includes(this.params.config.MISTRAL_MODEL))return!0;throw new Error("Invalid model type of Mistral AI")}async getAvailableModels(){return(await new Se({method:"GET",baseURL:`${this.host}/v1/models`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).execute()).data.data.filter(n=>n.object==="model").map(n=>n.id)}async createChatCompletions(t){const r=(await new Se({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.MISTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed:Yr(10,1e3)}).execute()).data;if(!r.choices||r.choices.length===0||!r.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return r.choices[0].message.content}}const{hasOwnProperty:gt}=Object.prototype,Pe=typeof process<"u"&&process.platform==="win32"?`\r
79
+ ${t}`)},Ii=(e,t)=>{const{year:r,month:n,day:o,hours:s,minutes:u,seconds:i}=_i(e),l=kn(0).update(t).digest("hex");return`aic2_${r}-${n}-${o}_${s}:${u}:${i}_${l}.log`},Jr=(e,t="")=>{k.mkdirSync(P.dirname(e),{recursive:!0}),k.writeFileSync(e,t,"utf-8")},_i=e=>{const t=e.getFullYear().toString(),r=(e.getMonth()+1).toString().padStart(2,"0"),n=e.getDate().toString().padStart(2,"0"),o=e.getHours().toString().padStart(2,"0"),s=e.getMinutes().toString().padStart(2,"0"),u=e.getSeconds().toString().padStart(2,"0");return{year:t,month:r,day:n,hours:o,minutes:s,seconds:u}};class Ti extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.error?.error?.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return x({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#AE5630",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Anthropic]"),this.errorPrefix=g.red.bold("[Anthropic]"),this.anthropic=new Nn({apiKey:this.params.config.ANTHROPIC_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c={...W,locale:r,maxLength:i,type:o,generate:n,promptPath:s},f=`${re(c)}`,a={max_tokens:this.params.config["max-tokens"],temperature:this.params.config.temperature,system:f,messages:[{role:"user",content:`Here are diff: ${t}`}],model:this.params.config.ANTHROPIC_MODEL},p=(await this.anthropic.messages.create(a)).content.map(({text:d})=>d).join("");return u&&K("Anthropic",t,f,p),this.sanitizeMessage(p,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}class Se{constructor(t={}){if(!t.method)throw new Error("method should be defined!");if(!t.baseURL)throw new Error("baseURL should be defined!");this.config={...t},this.axiosInstance=jn.create(this.config)}setHeaders(t){return this.config.headers=t,this}setParams(t){return this.config.params=t,this}setBody(t){return this.config.data=t,this}setMethod(t){return this.config.method=t,this}async execute(){try{return await this.axiosInstance.request(this.config)}catch(t){throw t}}}class Li extends U{constructor(t){super(t),this.params=t,this.host="https://codestral.mistral.ai",this.apiKey="",this.handleError$=r=>{const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return x({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#e28c58",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Codestral]"),this.errorPrefix=g.red.bold("[Codestral]"),this.apiKey=this.params.config.CODESTRAL_KEY}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,o,s);this.checkAvailableModels();const l=await this.createChatCompletions(c);return u&&K("Codestral",t,c,l),this.sanitizeMessage(l,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}checkAvailableModels(){if(["codestral-latest","codestral-2405"].includes(this.params.config.CODESTRAL_MODEL))return!0;throw new Error("Invalid model type of Codestral AI")}async createChatCompletions(t){const n=(await new Se({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.CODESTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed:Yr(10,1e3)}).execute()).data;if(!n.choices||n.choices.length===0||!n.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return n.choices[0].message.content}}class Ri extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=/"message":\s*"([^"]*)"/,o=r.message.match(n);let s=r?.body?.message;o&&o[1]&&(s=o[1]);const u=`${r.statusCode} ${s}`;return x({name:`${this.errorPrefix} ${u}`,value:s,isError:!0,disabled:!0})},this.colors={primary:"#D18EE2",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Cohere]"),this.errorPrefix=g.red.bold("[Cohere]"),this.cohere=new Gn({token:this.params.config.COHERE_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,o,s),l=this.params.config["max-tokens"],a=(await this.cohere.generate({prompt:c,maxTokens:l,temperature:this.params.config.temperature,model:this.params.config.COHERE_MODEL})).generations.map(D=>D.text).join("");return u&&K("Cohere",t,c,a),this.sanitizeMessage(a,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r instanceof Hn?new F("Request timed out error!"):r}}}class Ni extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.message||r.toString(),o=/(\[.*?\]\s*[^[]*)/g,s=[...n.matchAll(o)],u=[];s.forEach(c=>u.push(c[1]));const i=u[1]||"An error occurred";return x({name:`${this.errorPrefix} ${i}`,value:i,isError:!0,disabled:!0})},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Gemini]"),this.errorPrefix=g.red.bold("[Gemini]"),this.genAI=new Un(this.params.config.GEMINI_KEY)}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,o,s),l=this.params.config["max-tokens"],p=(await(await this.genAI.getGenerativeModel({model:this.params.config.GEMINI_MODEL,generationConfig:{maxOutputTokens:l,temperature:this.params.config.temperature}}).generateContent(c)).response).text();return u&&K("Gemini",t,c,p),this.sanitizeMessage(p,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}class ki extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";const o=/"message":\s*"([^"]*)"/,s=r.message.match(o);s&&s[1]&&(n=s[1]);const u=`${r.status} ${n}`;return x({name:`${this.errorPrefix} ${u}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#f55036",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Groq]"),this.errorPrefix=g.red.bold("[Groq]"),this.groq=new Kn({apiKey:this.params.config.GROQ_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c={...W,locale:r,maxLength:i,type:o,generate:n,promptPath:s},f=`${re(c)}`,D=(await this.groq.chat.completions.create({messages:[{role:"system",content:f},{role:"user",content:`Here are diff: ${t}`}],model:this.params.config.GROQ_MODEL},{timeout:this.params.config.timeout})).choices[0].message.content||"";return u&&K("Groq",t,f,D),this.sanitizeMessage(D,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){throw t}}}class ji extends U{constructor(t){super(t),this.params=t,this.headers={accept:"*/*","accept-language":"en-US,en;q=0.9","sec-ch-ua":'"Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin",origin:"https://huggingface.co","Referrer-Policy":"strict-origin-when-cross-origin"},this.models=[],this.currentModelId=null,this.currentConversation=void 0,this.currentConversionID=void 0,this.cookie="",this.colors={primary:"#FED21F",secondary:"#000"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[HuggingFace]"),this.errorPrefix=g.red.bold("[HuggingFace]"),this.cookie=this.params.config.HUGGINGFACE_COOKIE}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{await this.intialize();const t=this.getSystemPrompt(),r=await this.getNewChat(t),n=`Here are diff: ${this.params.stagedDiff.diff}`,s=await(await this.sendMessage(n,r.id)).completeResponsePromise(),{generate:u,logging:i}=this.params.config;return i&&K("HuggingFace",this.params.stagedDiff.diff,t,s),this.sanitizeMessage(s,this.params.config.type,u,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async intialize(){const t=await this.getRemoteLlms(),r=t.find(n=>n.name?.toLowerCase()===this.params.config.HUGGINGFACE_MODEL.toLowerCase());if(r){this.currentModel=r,this.currentModelId=r.id;return}this.currentModel=t[0],this.currentModelId=t[0].id}async getRemoteLlms(){const t=await fetch("https://huggingface.co/chat/__data.json",{headers:{...this.headers,cookie:this.cookie},body:null,method:"GET"});if(t.status!==200)throw new Error(`Failed to get remote LLMs with status code: ${t.status}`);const n=(await t.json()).nodes[0].data,o=n[n[0].models],s=[],u=i=>i===-1?null:n[i];for(const i of o){const c=n[i];if(n[c.unlisted])continue;const l={id:u(c.id),name:u(c.name),displayName:u(c.displayName),preprompt:u(c.preprompt),promptExamples:[],websiteUrl:u(c.websiteUrl),description:u(c.description),datasetName:u(c.datasetName),datasetUrl:u(c.datasetUrl),modelUrl:u(c.modelUrl),parameters:{}},f=u(c.promptExamples);if(f!==null){const p=f.map(d=>u(d));l.promptExamples=p.map(d=>({title:n[d.title],prompt:n[d.prompt]}))}const a=u(c.parameters),D={};for(const[p,d]of Object.entries(a)){if(d===-1){D[p]=null;continue}if(Array.isArray(n[d])){D[p]=n[d].map(h=>n[h]);continue}D[p]=n[d]}l.parameters=D,s.push(l)}return this.models=s,s}async getNewChat(t){const r={model:this.currentModelId,preprompt:t};let n=0;for(;n<5;){const o=await fetch("https://huggingface.co/chat/conversation",{headers:{...this.headers,"content-type":"application/json",cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:JSON.stringify(r),method:"POST"}),{conversationId:s}=await o.json();if(s){this.currentConversionID=s;break}else n++}if(!this.currentConversionID)throw new Error("Failed to create new conversion");return await this.getConversationHistory(this.currentConversionID)}async getConversationHistory(t){if(!t)throw new Error("conversationId is required for getConversationHistory");const r=await fetch("https://huggingface.co/chat/conversation/"+t+"/__data.json",{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:null,method:"GET"});if(r.status!=200)throw new Error("Unable get conversation details "+r);{const n=await r.json();return this.metadataParser(n,t)}}metadataParser(t,r){const n={id:"",model:"",systemPrompt:"",title:"",history:[]},o=t.nodes[1].data,s=o[o[0].model],u=o[o[0].preprompt],i=o[o[0].title],c=o[o[0].messages],l=[];for(const f of c){const a=o[f],D=new Date(o[a.createdAt][1]).getTime()/1e3,p=new Date(o[a.updatedAt][1]).getTime()/1e3;l.push({id:o[a.id],role:o[a.from],content:o[a.content],createdAt:D,updatedAt:p})}return n.id=r,n.model=s,n.systemPrompt=u,n.title=i,n.history=l,this.currentConversation=n,n}async sendMessage(t,r){if(t==="")throw new Error("the prompt can not be empty.");if(!r&&!this.currentConversionID?await this.getNewChat():r?(this.currentConversionID=r,await this.getConversationHistory(r)):this.currentConversionID&&await this.getConversationHistory(this.currentConversionID),!this.currentConversation)throw new Error("Failed to create new conversion");const n={inputs:t,id:this.currentConversation.history[this.currentConversation.history.length-1].id,is_retry:!1,is_continue:!1,web_search:!1,tools:{}},o=new FormData;o.append("data",JSON.stringify(n));const s=await fetch("https://huggingface.co/chat/conversation/"+this.currentConversionID,{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/conversation/"+this.currentConversionID},body:o,method:"POST"});function u(D){try{const p=D.split(`
80
+ `),d=[];for(const h of p)h.trim()&&d.push(JSON.parse(h));return d}catch{return[{}]}}const i=new TextDecoder;let c="";const l=new TransformStream({async transform(D,p){const d=i.decode(D);try{const h=u(d);for(const m of h)m.type==="finalAnswer"?(c=m?.text||"",p.terminate()):m.type==="stream"&&p.enqueue(m?.token||"")}catch{throw new Error("Error during parsing response")}}}),f=s.body?.pipeThrough(l);async function a(){return new Promise(async(D,p)=>{try{if(!f)p("ModifiedStream undefined");else{const d=f.getReader();for(;;){const{done:h,value:m}=await d.read();if(h){D(c);break}}}}catch(d){p(d)}})}return{id:this.currentConversionID,stream:f,completeResponsePromise:a}}async deleteConversation(t){return(await fetch(`https://huggingface.co/chat/conversation/${t}`,{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:null,method:"DELETE"})).json()}getSystemPrompt(){const{locale:t,generate:r,type:n,promptPath:o}=this.params.config,s=this.params.config["max-length"],u={...W,locale:t,maxLength:s,type:n,generate:r,promptPath:o};return`${re(u)}`}}class Gi extends U{constructor(t){super(t),this.params=t,this.host="https://api.mistral.ai",this.apiKey="",this.handleError$=r=>{const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return x({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#ff7000",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[MistralAI]"),this.errorPrefix=g.red.bold("[MistralAI]"),this.apiKey=this.params.config.MISTRAL_KEY}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o,promptPath:s,logging:u}=this.params.config,i=this.params.config["max-length"],c=this.buildPrompt(r,t,n,i,o,s);await this.checkAvailableModels();const l=await this.createChatCompletions(c);return u&&K("MistralAI",t,c,l),this.sanitizeMessage(l,this.params.config.type,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkAvailableModels(){if((await this.getAvailableModels()).includes(this.params.config.MISTRAL_MODEL))return!0;throw new Error("Invalid model type of Mistral AI")}async getAvailableModels(){return(await new Se({method:"GET",baseURL:`${this.host}/v1/models`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).execute()).data.data.filter(r=>r.object==="model").map(r=>r.id)}async createChatCompletions(t){const n=(await new Se({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.MISTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed:Yr(10,1e3)}).execute()).data;if(!n.choices||n.choices.length===0||!n.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return n.choices[0].message.content}}const{hasOwnProperty:gt}=Object.prototype,Pe=typeof process<"u"&&process.platform==="win32"?`\r
81
81
  `:`
82
- `,Ct=(e,t)=>{const n=[];let r="";typeof t=="string"?t={section:t,whitespace:!1}:(t=t||Object.create(null),t.whitespace=t.whitespace===!0);const o=t.whitespace?" = ":"=";for(const s of Object.keys(e)){const u=e[s];if(u&&Array.isArray(u))for(const i of u)r+=ne(s+"[]")+o+ne(i)+Pe;else u&&typeof u=="object"?n.push(s):r+=ne(s)+o+ne(u)+Pe}t.section&&r.length&&(r="["+ne(t.section)+"]"+Pe+r);for(const s of n){const u=Vr(s).join("\\."),i=(t.section?t.section+".":"")+u,{whitespace:c}=t,l=Ct(e[s],{section:i,whitespace:c});r.length&&l.length&&(r+=Pe),r+=l}return r},Vr=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),Xr=e=>{const t=Object.create(null);let n=t,r=null;const o=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,s=e.split(/[\r\n]+/g);for(const i of s){if(!i||i.match(/^\s*[;#]/))continue;const c=i.match(o);if(!c)continue;if(c[1]!==void 0){if(r=Ie(c[1]),r==="__proto__"){n=Object.create(null);continue}n=t[r]=t[r]||Object.create(null);continue}const l=Ie(c[2]),f=l.length>2&&l.slice(-2)==="[]",a=f?l.slice(0,-2):l;if(a==="__proto__")continue;const D=c[3]?Ie(c[4]):!0,p=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;f&&(gt.call(n,a)?Array.isArray(n[a])||(n[a]=[n[a]]):n[a]=[]),Array.isArray(n[a])?n[a].push(p):n[a]=p}const u=[];for(const i of Object.keys(t)){if(!gt.call(t,i)||typeof t[i]!="object"||Array.isArray(t[i]))continue;const c=Vr(i);n=t;const l=c.pop(),f=l.replace(/\\\./g,".");for(const a of c)a!=="__proto__"&&((!gt.call(n,a)||typeof n[a]!="object")&&(n[a]=Object.create(null)),n=n[a]);n===t&&f===l||(n[f]=t[i],u.push(i))}for(const i of u)delete t[i];return t},Qr=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),ne=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&Qr(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),Ie=(e,t)=>{if(e=(e||"").trim(),Qr(e)){e.charAt(0)==="'"&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let n=!1,r="";for(let o=0,s=e.length;o<s;o++){const u=e.charAt(o);if(n)"\\;#".indexOf(u)!==-1?r+=u:r+="\\"+u,n=!1;else{if(";#".indexOf(u)!==-1)break;u==="\\"?n=!0:r+=u}}return n&&(r+="\\"),r.trim()}return e};var Hi={parse:Xr,decode:Xr,stringify:Ct,encode:Ct,safe:ne,unsafe:Ie},Zr=V(Hi);const en=e=>O.lstat(e).then(()=>!0,()=>!1),Ui=["","conventional","gitmoji"],Et="http://localhost:11434",{hasOwnProperty:Ki}=Object.prototype,Ft=(e,t)=>Ki.call(e,t),C=(e,t,n)=>{if(!t)throw new F(`Invalid config property ${e}: ${n}`)},tn={confirm(e){return e?typeof e=="boolean"?e:(C("confirm",/^(?:true|false)$/.test(e),"Must be a boolean"),e==="true"):!1},promptPath(e){return e||""},locale(e){return e?(C("locale",e,"Cannot be empty"),C("locale",/^[a-z-]+$/i.test(e),"Must be a valid locale (letters and dashes/underscores). You can consult the list of codes in: https://wikipedia.org/wiki/List_of_ISO_639-1_codes"),e):"en"},generate(e){if(!e)return 1;C("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("generate",t>0,"Must be greater than 0"),C("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(C("type",Ui.includes(e),"Invalid commit type"),e):"conventional"},proxy(e){if(!(!e||e.length===0))return C("proxy",/^https?:\/\//.test(e),"Must be a valid URL"),e},timeout(e){if(!e)return 1e4;C("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("timeout",t>=500,"Must be greater than 500ms"),t},temperature(e){if(!e)return .7;C("temperature",/^(2|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 2");const t=Number(e);return C("temperature",t>0,"Must be greater than 0"),C("temperature",t<=2,"Must be less than or equal to 2"),t},"max-length"(e){if(!e)return 50;C("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("max-length",t>=20,"Must be greater than 20 characters"),t},"max-tokens"(e){return e?(C("max-tokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):1024},logging(e){return e?typeof e=="boolean"?e:(C("logging",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1},ignoreBody(e){return e?typeof e=="boolean"?e:(C("ignoreBody",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1}},rn={OPENAI_KEY(e){return e||""},OPENAI_MODEL(e){return!e||e.length===0?"gpt-3.5-turbo":e},OPENAI_URL(e){return e?(C("OPENAI_URL",/^https?:\/\//.test(e),"Must be a valid URL"),e):"https://api.openai.com"},OPENAI_PATH(e){return e||"/v1/chat/completions"},HUGGINGFACE_COOKIE(e){return e||""},HUGGINGFACE_MODEL(e){return!e||e.length===0?"CohereForAI/c4ai-command-r-plus":(C("HUGGINGFACE_MODEL",["CohereForAI/c4ai-command-r-plus","meta-llama/Meta-Llama-3-70B-Instruct","HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1","mistralai/Mixtral-8x7B-Instruct-v0.1","NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO","01-ai/Yi-1.5-34B-Chat","mistralai/Mistral-7B-Instruct-v0.2","microsoft/Phi-3-mini-4k-instruct"].includes(e),"Invalid model type of HuggingFace chat"),e)},GEMINI_KEY(e){return e||""},GEMINI_MODEL(e){return!e||e.length===0?"gemini-1.5-pro-latest":(C("GEMINI_MODEL",["gemini-1.5-flash-latest","gemini-1.5-pro-latest"].includes(e),"Invalid model type of Gemini"),e)},ANTHROPIC_MODEL(e){return!e||e.length===0?"claude-3-haiku-20240307":(C("ANTHROPIC_MODEL",["claude-2.1","claude-2.0","claude-instant-1.2","claude-3-haiku-20240307","claude-3-sonnet-20240229","claude-3-opus-20240229"].includes(e),"Invalid model type of Anthropic"),e)},ANTHROPIC_KEY(e){return e||""},MISTRAL_KEY(e){return e||""},MISTRAL_MODEL(e){return!e||e.length===0?"mistral-tiny":(C("MISTRAL_MODEL",["open-mistral-7b","mistral-tiny-2312","mistral-tiny","open-mixtral-8x7b","mistral-small-2312","mistral-small","mistral-small-2402","mistral-small-latest","mistral-medium-latest","mistral-medium-2312","mistral-medium","mistral-large-latest","mistral-large-2402","mistral-embed"].includes(e),"Invalid model type of Mistral AI"),e)},CODESTRAL_KEY(e){return e||""},CODESTRAL_MODEL(e){return!e||e.length===0?"codestral-latest":(C("CODESTRAL_MODEL",["codestral-latest","codestral-2405"].includes(e),"Invalid model type of Codestral"),e)},OLLAMA_MODEL(e){return e?(typeof e=="string"?e?.split(","):e).map(n=>n.trim()).filter(n=>!!n&&n.length>0):[]},OLLAMA_HOST(e){return e?(C("OLLAMA_HOST",/^https?:\/\//.test(e),"Must be a valid URL"),e):Et},OLLAMA_TIMEOUT(e){if(!e)return 1e5;C("OLLAMA_TIMEOUT",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("OLLAMA_TIMEOUT",t>=500,"Must be greater than 500ms"),t},OLLAMA_STREAM(e){return e?typeof e=="boolean"?e:(C("OLLAMA_STREAM",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1},COHERE_KEY(e){return e||""},COHERE_MODEL(e){return!e||e.length===0?"command":(C("COHERE_MODEL",["command","command-nightly","command-light","command-light-nightly"].includes(e),"Invalid model type of Cohere"),e)},GROQ_KEY(e){return e||""},GROQ_MODEL(e){return!e||e.length===0?"gemma-7b-it":(C("GROQ_MODEL",["llama3-8b-8192","llama3-70b-8192","mixtral-8x7b-32768","gemma-7b-it"].includes(e),"Invalid model type of Groq"),e)}},yt=P.join(je.homedir(),".aicommit2"),nn=async()=>{if(!await en(yt))return Object.create(null);const t=await O.readFile(yt,"utf8");let n=Zr.parse(t);return Ft(n,"OLLAMA_MODEL")&&(n={...n,OLLAMA_MODEL:typeof n.OLLAMA_MODEL=="string"?[n.OLLAMA_MODEL]:n.OLLAMA_MODEL}),n},bt=async(e,t)=>{const n=await nn(),r={},o={...tn,...rn};for(const s of Object.keys(o)){const u=o[s],i=e?.[s]??n[s];if(t)try{r[s]=u(i)}catch{}else r[s]=u(i)}return r},qi=async e=>{const t=await nn(),n={...tn,...rn};for(const[r,o]of e){if(!Ft(n,r))throw new F(`Invalid config property: ${r}`);const s=n[r](o);t[r]=s}await O.writeFile(yt,Zr.stringify(t),"utf8")};class zi extends U{constructor(t){super(t),this.params=t,this.host=Et,this.model="",this.handleError$=n=>{if(n.response&&n.response.data?.error)return x({name:`${this.errorPrefix} ${n.response.data?.error}`,value:n.response.data?.error,isError:!0,disabled:!0});const r=n.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return x({name:`${this.errorPrefix} ${r}`,value:r,isError:!0,disabled:!0})},this.colors={primary:"#FFF",secondary:"#000"},this.model=this.params.keyName,this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${zr(this.model)}]`),this.errorPrefix=g.red.bold(`[${zr(this.model)}]`),this.host=this.params.config.OLLAMA_HOST||Et,this.ollama=new qn({host:this.host})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{await this.checkIsAvailableOllama();const t=await this.createChatCompletions(),{type:n,generate:r,logging:o}=this.params.config,s=this.createSystemPrompt();return o&&K(`Ollama_${this.model}`,this.params.stagedDiff.diff,s,t),this.sanitizeMessage(t,n,r,this.params.config.ignoreBody)}catch(t){const n=t;throw n.code==="ENOTFOUND"?new F(`Error connecting to ${n.hostname} (${n.syscall})`):n}}async checkIsAvailableOllama(){try{return(await new Se({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.OLLAMA_TIMEOUT}).execute()).data}catch(t){throw t.code==="ECONNREFUSED"?new F(`Error connecting to ${this.host}. Please run Ollama or check host`):t}}async createChatCompletions(){const t=this.createSystemPrompt();return(await this.ollama.chat({model:this.model,messages:[{role:"system",content:t},{role:"user",content:`Here are diff: ${this.params.stagedDiff.diff}`}],stream:!1,options:{temperature:this.params.config.temperature}})).message.content}createSystemPrompt(){const t={...W,locale:this.params.config.locale,maxLength:this.params.config["max-length"],type:this.params.config.type,generate:this.params.config.generate,promptPath:this.params.config.promptPath};return`${re(t)}`}}var wt={},At={exports:{}},de={exports:{}},vt,on;function Yi(){if(on)return vt;on=1;var e=1e3,t=e*60,n=t*60,r=n*24,o=r*7,s=r*365.25;vt=function(f,a){a=a||{};var D=typeof f;if(D==="string"&&f.length>0)return u(f);if(D==="number"&&isFinite(f))return a.long?c(f):i(f);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(f))};function u(f){if(f=String(f),!(f.length>100)){var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(f);if(a){var D=parseFloat(a[1]),p=(a[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return D*s;case"weeks":case"week":case"w":return D*o;case"days":case"day":case"d":return D*r;case"hours":case"hour":case"hrs":case"hr":case"h":return D*n;case"minutes":case"minute":case"mins":case"min":case"m":return D*t;case"seconds":case"second":case"secs":case"sec":case"s":return D*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return D;default:return}}}}function i(f){var a=Math.abs(f);return a>=r?Math.round(f/r)+"d":a>=n?Math.round(f/n)+"h":a>=t?Math.round(f/t)+"m":a>=e?Math.round(f/e)+"s":f+"ms"}function c(f){var a=Math.abs(f);return a>=r?l(f,a,r,"day"):a>=n?l(f,a,n,"hour"):a>=t?l(f,a,t,"minute"):a>=e?l(f,a,e,"second"):f+" ms"}function l(f,a,D,p){var d=a>=D*1.5;return Math.round(f/D)+" "+p+(d?"s":"")}return vt}var $t,sn;function un(){if(sn)return $t;sn=1;function e(t){r.debug=r,r.default=r,r.coerce=l,r.disable=u,r.enable=s,r.enabled=i,r.humanize=Yi(),r.destroy=f,Object.keys(t).forEach(a=>{r[a]=t[a]}),r.names=[],r.skips=[],r.formatters={};function n(a){let D=0;for(let p=0;p<a.length;p++)D=(D<<5)-D+a.charCodeAt(p),D|=0;return r.colors[Math.abs(D)%r.colors.length]}r.selectColor=n;function r(a){let D,p=null,d,h;function m(...E){if(!m.enabled)return;const b=m,A=Number(new Date),R=A-(D||A);b.diff=R,b.prev=D,b.curr=A,D=A,E[0]=r.coerce(E[0]),typeof E[0]!="string"&&E.unshift("%O");let N=0;E[0]=E[0].replace(/%([a-zA-Z%])/g,(w,ue)=>{if(w==="%%")return"%";N++;const Nt=r.formatters[ue];if(typeof Nt=="function"){const An=E[N];w=Nt.call(b,An),E.splice(N,1),N--}return w}),r.formatArgs.call(b,E),(b.log||r.log).apply(b,E)}return m.namespace=a,m.useColors=r.useColors(),m.color=r.selectColor(a),m.extend=o,m.destroy=r.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==r.namespaces&&(d=r.namespaces,h=r.enabled(a)),h),set:E=>{p=E}}),typeof r.init=="function"&&r.init(m),m}function o(a,D){const p=r(this.namespace+(typeof D>"u"?":":D)+a);return p.log=this.log,p}function s(a){r.save(a),r.namespaces=a,r.names=[],r.skips=[];let D;const p=(typeof a=="string"?a:"").split(/[\s,]+/),d=p.length;for(D=0;D<d;D++)p[D]&&(a=p[D].replace(/\*/g,".*?"),a[0]==="-"?r.skips.push(new RegExp("^"+a.slice(1)+"$")):r.names.push(new RegExp("^"+a+"$")))}function u(){const a=[...r.names.map(c),...r.skips.map(c).map(D=>"-"+D)].join(",");return r.enable(""),a}function i(a){if(a[a.length-1]==="*")return!0;let D,p;for(D=0,p=r.skips.length;D<p;D++)if(r.skips[D].test(a))return!1;for(D=0,p=r.names.length;D<p;D++)if(r.names[D].test(a))return!0;return!1}function c(a){return a.toString().substring(2,a.toString().length-2).replace(/\.\*\?$/,"*")}function l(a){return a instanceof Error?a.stack||a.message:a}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}return $t=e,$t}de.exports;var an;function Wi(){return an||(an=1,function(e,t){t.formatArgs=r,t.save=o,t.load=s,t.useColors=n,t.storage=u(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;c.splice(1,0,l,"color: inherit");let f=0,a=0;c[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(f++,D==="%c"&&(a=f))}),c.splice(a,0,l)}t.log=console.debug||console.log||(()=>{});function o(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function s(){let c;try{c=t.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function u(){try{return localStorage}catch{}}e.exports=un()(t);const{formatters:i}=e.exports;i.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(de,de.exports)),de.exports}var me={exports:{}},Bt,cn;function Ji(){return cn||(cn=1,Bt=(e,t=process.argv)=>{const n=e.startsWith("-")?"":e.length===1?"-":"--",r=t.indexOf(n+e),o=t.indexOf("--");return r!==-1&&(o===-1||r<o)}),Bt}var Ot,Dn;function Vi(){if(Dn)return Ot;Dn=1;const e=je,t=Le,n=Ji(),{env:r}=process;let o;n("no-color")||n("no-colors")||n("color=false")||n("color=never")?o=0:(n("color")||n("colors")||n("color=true")||n("color=always"))&&(o=1),"FORCE_COLOR"in r&&(r.FORCE_COLOR==="true"?o=1:r.FORCE_COLOR==="false"?o=0:o=r.FORCE_COLOR.length===0?1:Math.min(parseInt(r.FORCE_COLOR,10),3));function s(c){return c===0?!1:{level:c,hasBasic:!0,has256:c>=2,has16m:c>=3}}function u(c,l){if(o===0)return 0;if(n("color=16m")||n("color=full")||n("color=truecolor"))return 3;if(n("color=256"))return 2;if(c&&!l&&o===void 0)return 0;const f=o||0;if(r.TERM==="dumb")return f;if(process.platform==="win32"){const a=e.release().split(".");return Number(a[0])>=10&&Number(a[2])>=10586?Number(a[2])>=14931?3:2:1}if("CI"in r)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(a=>a in r)||r.CI_NAME==="codeship"?1:f;if("TEAMCITY_VERSION"in r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if(r.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in r){const a=parseInt((r.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(r.TERM_PROGRAM){case"iTerm.app":return a>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(r.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?1:f}function i(c){const l=u(c,c&&c.isTTY);return s(l)}return Ot={supportsColor:i,stdout:s(u(!0,t.isatty(1))),stderr:s(u(!0,t.isatty(2)))},Ot}me.exports;var ln;function Xi(){return ln||(ln=1,function(e,t){const n=Le,r=Kt;t.init=f,t.log=i,t.formatArgs=s,t.save=c,t.load=l,t.useColors=o,t.destroy=r.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const D=Vi();D&&(D.stderr||D).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}t.inspectOpts=Object.keys(process.env).filter(D=>/^debug_/i.test(D)).reduce((D,p)=>{const d=p.substring(6).toLowerCase().replace(/_([a-z])/g,(m,E)=>E.toUpperCase());let h=process.env[p];return/^(yes|on|true|enabled)$/i.test(h)?h=!0:/^(no|off|false|disabled)$/i.test(h)?h=!1:h==="null"?h=null:h=Number(h),D[d]=h,D},{});function o(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:n.isatty(process.stderr.fd)}function s(D){const{namespace:p,useColors:d}=this;if(d){const h=this.color,m="\x1B[3"+(h<8?h:"8;5;"+h),E=` ${m};1m${p} \x1B[0m`;D[0]=E+D[0].split(`
82
+ `,Ct=(e,t)=>{const r=[];let n="";typeof t=="string"?t={section:t,whitespace:!1}:(t=t||Object.create(null),t.whitespace=t.whitespace===!0);const o=t.whitespace?" = ":"=";for(const s of Object.keys(e)){const u=e[s];if(u&&Array.isArray(u))for(const i of u)n+=ne(s+"[]")+o+ne(i)+Pe;else u&&typeof u=="object"?r.push(s):n+=ne(s)+o+ne(u)+Pe}t.section&&n.length&&(n="["+ne(t.section)+"]"+Pe+n);for(const s of r){const u=Vr(s).join("\\."),i=(t.section?t.section+".":"")+u,{whitespace:c}=t,l=Ct(e[s],{section:i,whitespace:c});n.length&&l.length&&(n+=Pe),n+=l}return n},Vr=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),Xr=e=>{const t=Object.create(null);let r=t,n=null;const o=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,s=e.split(/[\r\n]+/g);for(const i of s){if(!i||i.match(/^\s*[;#]/))continue;const c=i.match(o);if(!c)continue;if(c[1]!==void 0){if(n=Ie(c[1]),n==="__proto__"){r=Object.create(null);continue}r=t[n]=t[n]||Object.create(null);continue}const l=Ie(c[2]),f=l.length>2&&l.slice(-2)==="[]",a=f?l.slice(0,-2):l;if(a==="__proto__")continue;const D=c[3]?Ie(c[4]):!0,p=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;f&&(gt.call(r,a)?Array.isArray(r[a])||(r[a]=[r[a]]):r[a]=[]),Array.isArray(r[a])?r[a].push(p):r[a]=p}const u=[];for(const i of Object.keys(t)){if(!gt.call(t,i)||typeof t[i]!="object"||Array.isArray(t[i]))continue;const c=Vr(i);r=t;const l=c.pop(),f=l.replace(/\\\./g,".");for(const a of c)a!=="__proto__"&&((!gt.call(r,a)||typeof r[a]!="object")&&(r[a]=Object.create(null)),r=r[a]);r===t&&f===l||(r[f]=t[i],u.push(i))}for(const i of u)delete t[i];return t},Qr=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),ne=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&Qr(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),Ie=(e,t)=>{if(e=(e||"").trim(),Qr(e)){e.charAt(0)==="'"&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let r=!1,n="";for(let o=0,s=e.length;o<s;o++){const u=e.charAt(o);if(r)"\\;#".indexOf(u)!==-1?n+=u:n+="\\"+u,r=!1;else{if(";#".indexOf(u)!==-1)break;u==="\\"?r=!0:n+=u}}return r&&(n+="\\"),n.trim()}return e};var Hi={parse:Xr,decode:Xr,stringify:Ct,encode:Ct,safe:ne,unsafe:Ie},Zr=V(Hi);const en=e=>O.lstat(e).then(()=>!0,()=>!1),Ui=["","conventional","gitmoji"],Et="http://localhost:11434",{hasOwnProperty:Ki}=Object.prototype,Ft=(e,t)=>Ki.call(e,t),C=(e,t,r)=>{if(!t)throw new F(`Invalid config property ${e}: ${r}`)},tn={confirm(e){return e?typeof e=="boolean"?e:(C("confirm",/^(?:true|false)$/.test(e),"Must be a boolean"),e==="true"):!1},promptPath(e){return e||""},locale(e){return e?(C("locale",e,"Cannot be empty"),C("locale",/^[a-z-]+$/i.test(e),"Must be a valid locale (letters and dashes/underscores). You can consult the list of codes in: https://wikipedia.org/wiki/List_of_ISO_639-1_codes"),e):"en"},generate(e){if(!e)return 1;C("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("generate",t>0,"Must be greater than 0"),C("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(C("type",Ui.includes(e),"Invalid commit type"),e):"conventional"},proxy(e){if(!(!e||e.length===0))return C("proxy",/^https?:\/\//.test(e),"Must be a valid URL"),e},timeout(e){if(!e)return 1e4;C("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("timeout",t>=500,"Must be greater than 500ms"),t},temperature(e){if(!e)return .7;C("temperature",/^(2|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 2");const t=Number(e);return C("temperature",t>0,"Must be greater than 0"),C("temperature",t<=2,"Must be less than or equal to 2"),t},"max-length"(e){if(!e)return 50;C("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("max-length",t>=20,"Must be greater than 20 characters"),t},"max-tokens"(e){return e?(C("max-tokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):1024},logging(e){return e?typeof e=="boolean"?e:(C("logging",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1},ignoreBody(e){return e?typeof e=="boolean"?e:(C("ignoreBody",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!0}},rn={OPENAI_KEY(e){return e||""},OPENAI_MODEL(e){return!e||e.length===0?"gpt-3.5-turbo":e},OPENAI_URL(e){return e?(C("OPENAI_URL",/^https?:\/\//.test(e),"Must be a valid URL"),e):"https://api.openai.com"},OPENAI_PATH(e){return e||"/v1/chat/completions"},HUGGINGFACE_COOKIE(e){return e||""},HUGGINGFACE_MODEL(e){return!e||e.length===0?"CohereForAI/c4ai-command-r-plus":(C("HUGGINGFACE_MODEL",["CohereForAI/c4ai-command-r-plus","meta-llama/Meta-Llama-3-70B-Instruct","HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1","mistralai/Mixtral-8x7B-Instruct-v0.1","NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO","01-ai/Yi-1.5-34B-Chat","mistralai/Mistral-7B-Instruct-v0.2","microsoft/Phi-3-mini-4k-instruct"].includes(e),"Invalid model type of HuggingFace chat"),e)},GEMINI_KEY(e){return e||""},GEMINI_MODEL(e){return!e||e.length===0?"gemini-1.5-pro":(C("GEMINI_MODEL",["gemini-1.5-flash","gemini-1.5-pro","gemini-1.5-pro-exp-0801"].includes(e),"Invalid model type of Gemini"),e)},ANTHROPIC_MODEL(e){return!e||e.length===0?"claude-3-haiku-20240307":(C("ANTHROPIC_MODEL",["claude-3-haiku-20240307","claude-3-sonnet-20240229","claude-3-opus-20240229","claude-3-5-sonnet-20240620"].includes(e),"Invalid model type of Anthropic"),e)},ANTHROPIC_KEY(e){return e||""},MISTRAL_KEY(e){return e||""},MISTRAL_MODEL(e){return!e||e.length===0?"mistral-tiny":(C("MISTRAL_MODEL",["open-mistral-7b","mistral-tiny-2312","mistral-tiny","open-mixtral-8x7b","mistral-small-2312","mistral-small","mistral-small-2402","mistral-small-latest","mistral-medium-latest","mistral-medium-2312","mistral-medium","mistral-large-latest","mistral-large-2402","mistral-embed"].includes(e),"Invalid model type of Mistral AI"),e)},CODESTRAL_KEY(e){return e||""},CODESTRAL_MODEL(e){return!e||e.length===0?"codestral-latest":(C("CODESTRAL_MODEL",["codestral-latest","codestral-2405"].includes(e),"Invalid model type of Codestral"),e)},OLLAMA_MODEL(e){return e?(typeof e=="string"?e?.split(","):e).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[]},OLLAMA_HOST(e){return e?(C("OLLAMA_HOST",/^https?:\/\//.test(e),"Must be a valid URL"),e):Et},OLLAMA_TIMEOUT(e){if(!e)return 1e5;C("OLLAMA_TIMEOUT",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return C("OLLAMA_TIMEOUT",t>=500,"Must be greater than 500ms"),t},OLLAMA_STREAM(e){return e?typeof e=="boolean"?e:(C("OLLAMA_STREAM",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true"):!1},COHERE_KEY(e){return e||""},COHERE_MODEL(e){return!e||e.length===0?"command":(C("COHERE_MODEL",["command","command-nightly","command-light","command-light-nightly"].includes(e),"Invalid model type of Cohere"),e)},GROQ_KEY(e){return e||""},GROQ_MODEL(e){return!e||e.length===0?"gemma2-9b-it":(C("GROQ_MODEL",["gemma2-9b-it","gemma-7b-it","llama-3.1-70b-versatile","llama-3.1-8b-instant","llama3-70b-8192","llama3-8b-8192","llama3-groq-70b-8192-tool-use-preview","llama3-groq-8b-8192-tool-use-preview"].includes(e),"Invalid model type of Groq"),e)}},yt=P.join(je.homedir(),".aicommit2"),nn=async()=>{if(!await en(yt))return Object.create(null);const t=await O.readFile(yt,"utf8");let r=Zr.parse(t);return Ft(r,"OLLAMA_MODEL")&&(r={...r,OLLAMA_MODEL:typeof r.OLLAMA_MODEL=="string"?[r.OLLAMA_MODEL]:r.OLLAMA_MODEL}),r},bt=async(e,t)=>{const r=await nn(),n={},o={...tn,...rn};for(const s of Object.keys(o)){const u=o[s],i=e?.[s]??r[s];if(t)try{n[s]=u(i)}catch{}else n[s]=u(i)}return n},qi=async e=>{const t=await nn(),r={...tn,...rn};for(const[n,o]of e){if(!Ft(r,n))throw new F(`Invalid config property: ${n}`);const s=r[n](o);t[n]=s}await O.writeFile(yt,Zr.stringify(t),"utf8")};class zi extends U{constructor(t){super(t),this.params=t,this.host=Et,this.model="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return x({name:`${this.errorPrefix} ${r.response.data?.error}`,value:r.response.data?.error,isError:!0,disabled:!0});const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return x({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#FFF",secondary:"#000"},this.model=this.params.keyName,this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${zr(this.model)}]`),this.errorPrefix=g.red.bold(`[${zr(this.model)}]`),this.host=this.params.config.OLLAMA_HOST||Et,this.ollama=new qn({host:this.host})}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{await this.checkIsAvailableOllama();const t=await this.createChatCompletions(),{type:r,generate:n,logging:o}=this.params.config,s=this.createSystemPrompt();return o&&K(`Ollama_${this.model}`,this.params.stagedDiff.diff,s,t),this.sanitizeMessage(t,r,n,this.params.config.ignoreBody)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new F(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkIsAvailableOllama(){try{return(await new Se({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.OLLAMA_TIMEOUT}).execute()).data}catch(t){throw t.code==="ECONNREFUSED"?new F(`Error connecting to ${this.host}. Please run Ollama or check host`):t}}async createChatCompletions(){const t=this.createSystemPrompt();return(await this.ollama.chat({model:this.model,messages:[{role:"system",content:t},{role:"user",content:`Here are diff: ${this.params.stagedDiff.diff}`}],stream:!1,options:{temperature:this.params.config.temperature}})).message.content}createSystemPrompt(){const t={...W,locale:this.params.config.locale,maxLength:this.params.config["max-length"],type:this.params.config.type,generate:this.params.config.generate,promptPath:this.params.config.promptPath};return`${re(t)}`}}var wt={},At={exports:{}},de={exports:{}},vt,on;function Yi(){if(on)return vt;on=1;var e=1e3,t=e*60,r=t*60,n=r*24,o=n*7,s=n*365.25;vt=function(f,a){a=a||{};var D=typeof f;if(D==="string"&&f.length>0)return u(f);if(D==="number"&&isFinite(f))return a.long?c(f):i(f);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(f))};function u(f){if(f=String(f),!(f.length>100)){var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(f);if(a){var D=parseFloat(a[1]),p=(a[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return D*s;case"weeks":case"week":case"w":return D*o;case"days":case"day":case"d":return D*n;case"hours":case"hour":case"hrs":case"hr":case"h":return D*r;case"minutes":case"minute":case"mins":case"min":case"m":return D*t;case"seconds":case"second":case"secs":case"sec":case"s":return D*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return D;default:return}}}}function i(f){var a=Math.abs(f);return a>=n?Math.round(f/n)+"d":a>=r?Math.round(f/r)+"h":a>=t?Math.round(f/t)+"m":a>=e?Math.round(f/e)+"s":f+"ms"}function c(f){var a=Math.abs(f);return a>=n?l(f,a,n,"day"):a>=r?l(f,a,r,"hour"):a>=t?l(f,a,t,"minute"):a>=e?l(f,a,e,"second"):f+" ms"}function l(f,a,D,p){var d=a>=D*1.5;return Math.round(f/D)+" "+p+(d?"s":"")}return vt}var $t,sn;function un(){if(sn)return $t;sn=1;function e(t){n.debug=n,n.default=n,n.coerce=l,n.disable=u,n.enable=s,n.enabled=i,n.humanize=Yi(),n.destroy=f,Object.keys(t).forEach(a=>{n[a]=t[a]}),n.names=[],n.skips=[],n.formatters={};function r(a){let D=0;for(let p=0;p<a.length;p++)D=(D<<5)-D+a.charCodeAt(p),D|=0;return n.colors[Math.abs(D)%n.colors.length]}n.selectColor=r;function n(a){let D,p=null,d,h;function m(...E){if(!m.enabled)return;const b=m,A=Number(new Date),R=A-(D||A);b.diff=R,b.prev=D,b.curr=A,D=A,E[0]=n.coerce(E[0]),typeof E[0]!="string"&&E.unshift("%O");let N=0;E[0]=E[0].replace(/%([a-zA-Z%])/g,(w,ue)=>{if(w==="%%")return"%";N++;const Nt=n.formatters[ue];if(typeof Nt=="function"){const An=E[N];w=Nt.call(b,An),E.splice(N,1),N--}return w}),n.formatArgs.call(b,E),(b.log||n.log).apply(b,E)}return m.namespace=a,m.useColors=n.useColors(),m.color=n.selectColor(a),m.extend=o,m.destroy=n.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==n.namespaces&&(d=n.namespaces,h=n.enabled(a)),h),set:E=>{p=E}}),typeof n.init=="function"&&n.init(m),m}function o(a,D){const p=n(this.namespace+(typeof D>"u"?":":D)+a);return p.log=this.log,p}function s(a){n.save(a),n.namespaces=a,n.names=[],n.skips=[];let D;const p=(typeof a=="string"?a:"").split(/[\s,]+/),d=p.length;for(D=0;D<d;D++)p[D]&&(a=p[D].replace(/\*/g,".*?"),a[0]==="-"?n.skips.push(new RegExp("^"+a.slice(1)+"$")):n.names.push(new RegExp("^"+a+"$")))}function u(){const a=[...n.names.map(c),...n.skips.map(c).map(D=>"-"+D)].join(",");return n.enable(""),a}function i(a){if(a[a.length-1]==="*")return!0;let D,p;for(D=0,p=n.skips.length;D<p;D++)if(n.skips[D].test(a))return!1;for(D=0,p=n.names.length;D<p;D++)if(n.names[D].test(a))return!0;return!1}function c(a){return a.toString().substring(2,a.toString().length-2).replace(/\.\*\?$/,"*")}function l(a){return a instanceof Error?a.stack||a.message:a}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}return $t=e,$t}de.exports;var an;function Wi(){return an||(an=1,function(e,t){t.formatArgs=n,t.save=o,t.load=s,t.useColors=r,t.storage=u(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;c.splice(1,0,l,"color: inherit");let f=0,a=0;c[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(f++,D==="%c"&&(a=f))}),c.splice(a,0,l)}t.log=console.debug||console.log||(()=>{});function o(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function s(){let c;try{c=t.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function u(){try{return localStorage}catch{}}e.exports=un()(t);const{formatters:i}=e.exports;i.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(de,de.exports)),de.exports}var me={exports:{}},Bt,cn;function Ji(){return cn||(cn=1,Bt=(e,t=process.argv)=>{const r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),o=t.indexOf("--");return n!==-1&&(o===-1||n<o)}),Bt}var Ot,Dn;function Vi(){if(Dn)return Ot;Dn=1;const e=je,t=Le,r=Ji(),{env:n}=process;let o;r("no-color")||r("no-colors")||r("color=false")||r("color=never")?o=0:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(o=1),"FORCE_COLOR"in n&&(n.FORCE_COLOR==="true"?o=1:n.FORCE_COLOR==="false"?o=0:o=n.FORCE_COLOR.length===0?1:Math.min(parseInt(n.FORCE_COLOR,10),3));function s(c){return c===0?!1:{level:c,hasBasic:!0,has256:c>=2,has16m:c>=3}}function u(c,l){if(o===0)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(c&&!l&&o===void 0)return 0;const f=o||0;if(n.TERM==="dumb")return f;if(process.platform==="win32"){const a=e.release().split(".");return Number(a[0])>=10&&Number(a[2])>=10586?Number(a[2])>=14931?3:2:1}if("CI"in n)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(a=>a in n)||n.CI_NAME==="codeship"?1:f;if("TEAMCITY_VERSION"in n)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(n.TEAMCITY_VERSION)?1:0;if(n.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in n){const a=parseInt((n.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n.TERM_PROGRAM){case"iTerm.app":return a>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(n.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n.TERM)||"COLORTERM"in n?1:f}function i(c){const l=u(c,c&&c.isTTY);return s(l)}return Ot={supportsColor:i,stdout:s(u(!0,t.isatty(1))),stderr:s(u(!0,t.isatty(2)))},Ot}me.exports;var ln;function Xi(){return ln||(ln=1,function(e,t){const r=Le,n=Kt;t.init=f,t.log=i,t.formatArgs=s,t.save=c,t.load=l,t.useColors=o,t.destroy=n.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const D=Vi();D&&(D.stderr||D).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}t.inspectOpts=Object.keys(process.env).filter(D=>/^debug_/i.test(D)).reduce((D,p)=>{const d=p.substring(6).toLowerCase().replace(/_([a-z])/g,(m,E)=>E.toUpperCase());let h=process.env[p];return/^(yes|on|true|enabled)$/i.test(h)?h=!0:/^(no|off|false|disabled)$/i.test(h)?h=!1:h==="null"?h=null:h=Number(h),D[d]=h,D},{});function o(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:r.isatty(process.stderr.fd)}function s(D){const{namespace:p,useColors:d}=this;if(d){const h=this.color,m="\x1B[3"+(h<8?h:"8;5;"+h),E=` ${m};1m${p} \x1B[0m`;D[0]=E+D[0].split(`
83
83
  `).join(`
84
- `+E),D.push(m+"m+"+e.exports.humanize(this.diff)+"\x1B[0m")}else D[0]=u()+p+" "+D[0]}function u(){return t.inspectOpts.hideDate?"":new Date().toISOString()+" "}function i(...D){return process.stderr.write(r.formatWithOptions(t.inspectOpts,...D)+`
85
- `)}function c(D){D?process.env.DEBUG=D:delete process.env.DEBUG}function l(){return process.env.DEBUG}function f(D){D.inspectOpts={};const p=Object.keys(t.inspectOpts);for(let d=0;d<p.length;d++)D.inspectOpts[p[d]]=t.inspectOpts[p[d]]}e.exports=un()(t);const{formatters:a}=e.exports;a.o=function(D){return this.inspectOpts.colors=this.useColors,r.inspect(D,this.inspectOpts).split(`
86
- `).map(p=>p.trim()).join(" ")},a.O=function(D){return this.inspectOpts.colors=this.useColors,r.inspect(D,this.inspectOpts)}}(me,me.exports)),me.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?At.exports=Wi():At.exports=Xi();var xt=At.exports,Mt={};Object.defineProperty(Mt,"__esModule",{value:!0});function Qi(e){return function(t,n){return new Promise((r,o)=>{e.call(this,t,n,(s,u)=>{s?o(s):r(u)})})}}Mt.default=Qi;var fn=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Zi=Ut,ea=fn(xt),ta=fn(Mt),he=ea.default("agent-base");function ra(e){return!!e&&typeof e.addRequest=="function"}function St(){const{stack:e}=new Error;return typeof e!="string"?!1:e.split(`
87
- `).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}function _e(e,t){return new _e.Agent(e,t)}(function(e){class t extends Zi.EventEmitter{constructor(r,o){super();let s=o;typeof r=="function"?this.callback=r:r&&(s=r),this.timeout=null,s&&typeof s.timeout=="number"&&(this.timeout=s.timeout),this.maxFreeSockets=1,this.maxSockets=1,this.maxTotalSockets=1/0,this.sockets={},this.freeSockets={},this.requests={},this.options={}}get defaultPort(){return typeof this.explicitDefaultPort=="number"?this.explicitDefaultPort:St()?443:80}set defaultPort(r){this.explicitDefaultPort=r}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:St()?"https:":"http:"}set protocol(r){this.explicitProtocol=r}callback(r,o,s){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(r,o){const s=Object.assign({},o);typeof s.secureEndpoint!="boolean"&&(s.secureEndpoint=St()),s.host==null&&(s.host="localhost"),s.port==null&&(s.port=s.secureEndpoint?443:80),s.protocol==null&&(s.protocol=s.secureEndpoint?"https:":"http:"),s.host&&s.path&&delete s.path,delete s.agent,delete s.hostname,delete s._defaultAgent,delete s.defaultPort,delete s.createConnection,r._last=!0,r.shouldKeepAlive=!1;let u=!1,i=null;const c=s.timeout||this.timeout,l=p=>{r._hadError||(r.emit("error",p),r._hadError=!0)},f=()=>{i=null,u=!0;const p=new Error(`A "socket" was not created for HTTP request before ${c}ms`);p.code="ETIMEOUT",l(p)},a=p=>{u||(i!==null&&(clearTimeout(i),i=null),l(p))},D=p=>{if(u)return;if(i!=null&&(clearTimeout(i),i=null),ra(p)){he("Callback returned another Agent instance %o",p.constructor.name),p.addRequest(r,s);return}if(p){p.once("free",()=>{this.freeSocket(p,s)}),r.onSocket(p);return}const d=new Error(`no Duplex stream was returned to agent-base for \`${r.method} ${r.path}\``);l(d)};if(typeof this.callback!="function"){l(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(he("Converting legacy callback function to promise"),this.promisifiedCallback=ta.default(this.callback)):this.promisifiedCallback=this.callback),typeof c=="number"&&c>0&&(i=setTimeout(f,c)),"port"in s&&typeof s.port!="number"&&(s.port=Number(s.port));try{he("Resolving socket for %o request: %o",s.protocol,`${r.method} ${r.path}`),Promise.resolve(this.promisifiedCallback(r,s)).then(D,a)}catch(p){Promise.reject(p).catch(a)}}freeSocket(r,o){he("Freeing socket %o %o",r.constructor.name,o),r.destroy()}destroy(){he("Destroying agent %o",this.constructor.name)}}e.Agent=t,e.prototype=e.Agent.prototype})(_e||(_e={}));var na=_e,Pt={},oa=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Pt,"__esModule",{value:!0});const sa=oa(xt),ge=sa.default("https-proxy-agent:parse-proxy-response");function ua(e){return new Promise((t,n)=>{let r=0;const o=[];function s(){const a=e.read();a?f(a):e.once("readable",s)}function u(){e.removeListener("end",c),e.removeListener("error",l),e.removeListener("close",i),e.removeListener("readable",s)}function i(a){ge("onclose had error %o",a)}function c(){ge("onend")}function l(a){u(),ge("onerror %o",a),n(a)}function f(a){o.push(a),r+=a.length;const D=Buffer.concat(o,r);if(D.indexOf(`\r
84
+ `+E),D.push(m+"m+"+e.exports.humanize(this.diff)+"\x1B[0m")}else D[0]=u()+p+" "+D[0]}function u(){return t.inspectOpts.hideDate?"":new Date().toISOString()+" "}function i(...D){return process.stderr.write(n.formatWithOptions(t.inspectOpts,...D)+`
85
+ `)}function c(D){D?process.env.DEBUG=D:delete process.env.DEBUG}function l(){return process.env.DEBUG}function f(D){D.inspectOpts={};const p=Object.keys(t.inspectOpts);for(let d=0;d<p.length;d++)D.inspectOpts[p[d]]=t.inspectOpts[p[d]]}e.exports=un()(t);const{formatters:a}=e.exports;a.o=function(D){return this.inspectOpts.colors=this.useColors,n.inspect(D,this.inspectOpts).split(`
86
+ `).map(p=>p.trim()).join(" ")},a.O=function(D){return this.inspectOpts.colors=this.useColors,n.inspect(D,this.inspectOpts)}}(me,me.exports)),me.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?At.exports=Wi():At.exports=Xi();var xt=At.exports,Mt={};Object.defineProperty(Mt,"__esModule",{value:!0});function Qi(e){return function(t,r){return new Promise((n,o)=>{e.call(this,t,r,(s,u)=>{s?o(s):n(u)})})}}Mt.default=Qi;var fn=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Zi=Ut,ea=fn(xt),ta=fn(Mt),he=ea.default("agent-base");function ra(e){return!!e&&typeof e.addRequest=="function"}function St(){const{stack:e}=new Error;return typeof e!="string"?!1:e.split(`
87
+ `).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}function _e(e,t){return new _e.Agent(e,t)}(function(e){class t extends Zi.EventEmitter{constructor(n,o){super();let s=o;typeof n=="function"?this.callback=n:n&&(s=n),this.timeout=null,s&&typeof s.timeout=="number"&&(this.timeout=s.timeout),this.maxFreeSockets=1,this.maxSockets=1,this.maxTotalSockets=1/0,this.sockets={},this.freeSockets={},this.requests={},this.options={}}get defaultPort(){return typeof this.explicitDefaultPort=="number"?this.explicitDefaultPort:St()?443:80}set defaultPort(n){this.explicitDefaultPort=n}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:St()?"https:":"http:"}set protocol(n){this.explicitProtocol=n}callback(n,o,s){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(n,o){const s=Object.assign({},o);typeof s.secureEndpoint!="boolean"&&(s.secureEndpoint=St()),s.host==null&&(s.host="localhost"),s.port==null&&(s.port=s.secureEndpoint?443:80),s.protocol==null&&(s.protocol=s.secureEndpoint?"https:":"http:"),s.host&&s.path&&delete s.path,delete s.agent,delete s.hostname,delete s._defaultAgent,delete s.defaultPort,delete s.createConnection,n._last=!0,n.shouldKeepAlive=!1;let u=!1,i=null;const c=s.timeout||this.timeout,l=p=>{n._hadError||(n.emit("error",p),n._hadError=!0)},f=()=>{i=null,u=!0;const p=new Error(`A "socket" was not created for HTTP request before ${c}ms`);p.code="ETIMEOUT",l(p)},a=p=>{u||(i!==null&&(clearTimeout(i),i=null),l(p))},D=p=>{if(u)return;if(i!=null&&(clearTimeout(i),i=null),ra(p)){he("Callback returned another Agent instance %o",p.constructor.name),p.addRequest(n,s);return}if(p){p.once("free",()=>{this.freeSocket(p,s)}),n.onSocket(p);return}const d=new Error(`no Duplex stream was returned to agent-base for \`${n.method} ${n.path}\``);l(d)};if(typeof this.callback!="function"){l(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(he("Converting legacy callback function to promise"),this.promisifiedCallback=ta.default(this.callback)):this.promisifiedCallback=this.callback),typeof c=="number"&&c>0&&(i=setTimeout(f,c)),"port"in s&&typeof s.port!="number"&&(s.port=Number(s.port));try{he("Resolving socket for %o request: %o",s.protocol,`${n.method} ${n.path}`),Promise.resolve(this.promisifiedCallback(n,s)).then(D,a)}catch(p){Promise.reject(p).catch(a)}}freeSocket(n,o){he("Freeing socket %o %o",n.constructor.name,o),n.destroy()}destroy(){he("Destroying agent %o",this.constructor.name)}}e.Agent=t,e.prototype=e.Agent.prototype})(_e||(_e={}));var na=_e,Pt={},oa=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Pt,"__esModule",{value:!0});const sa=oa(xt),ge=sa.default("https-proxy-agent:parse-proxy-response");function ua(e){return new Promise((t,r)=>{let n=0;const o=[];function s(){const a=e.read();a?f(a):e.once("readable",s)}function u(){e.removeListener("end",c),e.removeListener("error",l),e.removeListener("close",i),e.removeListener("readable",s)}function i(a){ge("onclose had error %o",a)}function c(){ge("onend")}function l(a){u(),ge("onerror %o",a),r(a)}function f(a){o.push(a),n+=a.length;const D=Buffer.concat(o,n);if(D.indexOf(`\r
88
88
  \r
89
89
  `)===-1){ge("have not received end of HTTP headers yet..."),s();return}const d=D.toString("ascii",0,D.indexOf(`\r
90
- `)),h=+d.split(" ")[1];ge("got proxy server response: %o",d),t({statusCode:h,buffered:D})}e.on("error",l),e.on("close",i),e.on("end",c),s()})}Pt.default=ua;var ia=v&&v.__awaiter||function(e,t,n,r){function o(s){return s instanceof n?s:new n(function(u){u(s)})}return new(n||(n=Promise))(function(s,u){function i(f){try{l(r.next(f))}catch(a){u(a)}}function c(f){try{l(r.throw(f))}catch(a){u(a)}}function l(f){f.done?s(f.value):o(f.value).then(i,c)}l((r=r.apply(e,t||[])).next())})},oe=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(wt,"__esModule",{value:!0});const pn=oe(Wn),dn=oe(Jn),aa=oe(Vn),ca=oe(Ht),Da=oe(xt),la=na,fa=oe(Pt),Ce=Da.default("https-proxy-agent:agent");class pa extends la.Agent{constructor(t){let n;if(typeof t=="string"?n=aa.default.parse(t):n=t,!n)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");Ce("creating new HttpsProxyAgent instance: %o",n),super(n);const r=Object.assign({},n);this.secureProxy=n.secureProxy||ha(r.protocol),r.host=r.hostname||r.host,typeof r.port=="string"&&(r.port=parseInt(r.port,10)),!r.port&&r.host&&(r.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in r)&&(r.ALPNProtocols=["http 1.1"]),r.host&&r.path&&(delete r.path,delete r.pathname),this.proxy=r}callback(t,n){return ia(this,void 0,void 0,function*(){const{proxy:r,secureProxy:o}=this;let s;o?(Ce("Creating `tls.Socket`: %o",r),s=dn.default.connect(r)):(Ce("Creating `net.Socket`: %o",r),s=pn.default.connect(r));const u=Object.assign({},r.headers);let c=`CONNECT ${`${n.host}:${n.port}`} HTTP/1.1\r
91
- `;r.auth&&(u["Proxy-Authorization"]=`Basic ${Buffer.from(r.auth).toString("base64")}`);let{host:l,port:f,secureEndpoint:a}=n;ma(f,a)||(l+=`:${f}`),u.Host=l,u.Connection="close";for(const m of Object.keys(u))c+=`${m}: ${u[m]}\r
90
+ `)),h=+d.split(" ")[1];ge("got proxy server response: %o",d),t({statusCode:h,buffered:D})}e.on("error",l),e.on("close",i),e.on("end",c),s()})}Pt.default=ua;var ia=v&&v.__awaiter||function(e,t,r,n){function o(s){return s instanceof r?s:new r(function(u){u(s)})}return new(r||(r=Promise))(function(s,u){function i(f){try{l(n.next(f))}catch(a){u(a)}}function c(f){try{l(n.throw(f))}catch(a){u(a)}}function l(f){f.done?s(f.value):o(f.value).then(i,c)}l((n=n.apply(e,t||[])).next())})},oe=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(wt,"__esModule",{value:!0});const pn=oe(Wn),dn=oe(Jn),aa=oe(Vn),ca=oe(Ht),Da=oe(xt),la=na,fa=oe(Pt),Ce=Da.default("https-proxy-agent:agent");class pa extends la.Agent{constructor(t){let r;if(typeof t=="string"?r=aa.default.parse(t):r=t,!r)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");Ce("creating new HttpsProxyAgent instance: %o",r),super(r);const n=Object.assign({},r);this.secureProxy=r.secureProxy||ha(n.protocol),n.host=n.hostname||n.host,typeof n.port=="string"&&(n.port=parseInt(n.port,10)),!n.port&&n.host&&(n.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in n)&&(n.ALPNProtocols=["http 1.1"]),n.host&&n.path&&(delete n.path,delete n.pathname),this.proxy=n}callback(t,r){return ia(this,void 0,void 0,function*(){const{proxy:n,secureProxy:o}=this;let s;o?(Ce("Creating `tls.Socket`: %o",n),s=dn.default.connect(n)):(Ce("Creating `net.Socket`: %o",n),s=pn.default.connect(n));const u=Object.assign({},n.headers);let c=`CONNECT ${`${r.host}:${r.port}`} HTTP/1.1\r
91
+ `;n.auth&&(u["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:l,port:f,secureEndpoint:a}=r;ma(f,a)||(l+=`:${f}`),u.Host=l,u.Connection="close";for(const m of Object.keys(u))c+=`${m}: ${u[m]}\r
92
92
  `;const D=fa.default(s);s.write(`${c}\r
93
- `);const{statusCode:p,buffered:d}=yield D;if(p===200){if(t.once("socket",da),n.secureEndpoint){Ce("Upgrading socket connection to TLS");const m=n.servername||n.host;return dn.default.connect(Object.assign(Object.assign({},ga(n,"host","hostname","path","port")),{socket:s,servername:m}))}return s}s.destroy();const h=new pn.default.Socket({writable:!1});return h.readable=!0,t.once("socket",m=>{Ce("replaying proxy buffer for failed request"),ca.default(m.listenerCount("data")>0),m.push(d),m.push(null)}),h})}}wt.default=pa;function da(e){e.resume()}function ma(e,t){return!!(!t&&e===80||t&&e===443)}function ha(e){return typeof e=="string"?/^https:?$/i.test(e):!1}function ga(e,...t){const n={};let r;for(r in e)t.includes(r)||(n[r]=e[r]);return n}var Ca=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const It=Ca(wt);function _t(e){return new It.default(e)}(function(e){e.HttpsProxyAgent=It.default,e.prototype=It.default.prototype})(_t||(_t={}));var Ea=_t,Fa=V(Ea);const ya=async(e,t,n,r,o,s,u)=>new Promise((i,c)=>{const l=JSON.stringify(r),a=(e.protocol.includes("https")?Yn:zn).request({port:u||void 0,hostname:e.hostname,path:t,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(l),...n},timeout:o,agent:s?Fa(s):void 0},D=>{const p=[];D.on("data",d=>p.push(d)),D.on("end",()=>{i({request:a,response:D,data:Buffer.concat(p).toString()})})});a.on("error",c),a.on("timeout",()=>{a.destroy(),c(new F(`Time out error: request took over ${o}ms. Try increasing the \`timeout\` config`))}),a.write(l),a.end()}),ba=async(e,t,n,r,o,s)=>{const u=new URL(e),{response:i,data:c}=await ya(u,t,{Authorization:`Bearer ${n}`},r,o,s);if(!i.statusCode||i.statusCode<200||i.statusCode>299){let l=`OpenAI API Error: ${i.statusCode} - ${i.statusMessage}`;throw c&&(l+=`
93
+ `);const{statusCode:p,buffered:d}=yield D;if(p===200){if(t.once("socket",da),r.secureEndpoint){Ce("Upgrading socket connection to TLS");const m=r.servername||r.host;return dn.default.connect(Object.assign(Object.assign({},ga(r,"host","hostname","path","port")),{socket:s,servername:m}))}return s}s.destroy();const h=new pn.default.Socket({writable:!1});return h.readable=!0,t.once("socket",m=>{Ce("replaying proxy buffer for failed request"),ca.default(m.listenerCount("data")>0),m.push(d),m.push(null)}),h})}}wt.default=pa;function da(e){e.resume()}function ma(e,t){return!!(!t&&e===80||t&&e===443)}function ha(e){return typeof e=="string"?/^https:?$/i.test(e):!1}function ga(e,...t){const r={};let n;for(n in e)t.includes(n)||(r[n]=e[n]);return r}var Ca=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const It=Ca(wt);function _t(e){return new It.default(e)}(function(e){e.HttpsProxyAgent=It.default,e.prototype=It.default.prototype})(_t||(_t={}));var Ea=_t,Fa=V(Ea);const ya=async(e,t,r,n,o,s,u)=>new Promise((i,c)=>{const l=JSON.stringify(n),a=(e.protocol.includes("https")?Yn:zn).request({port:u||void 0,hostname:e.hostname,path:t,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(l),...r},timeout:o,agent:s?Fa(s):void 0},D=>{const p=[];D.on("data",d=>p.push(d)),D.on("end",()=>{i({request:a,response:D,data:Buffer.concat(p).toString()})})});a.on("error",c),a.on("timeout",()=>{a.destroy(),c(new F(`Time out error: request took over ${o}ms. Try increasing the \`timeout\` config`))}),a.write(l),a.end()}),ba=async(e,t,r,n,o,s)=>{const u=new URL(e),{response:i,data:c}=await ya(u,t,{Authorization:`Bearer ${r}`},n,o,s);if(!i.statusCode||i.statusCode<200||i.statusCode>299){let l=`OpenAI API Error: ${i.statusCode} - ${i.statusMessage}`;throw c&&(l+=`
94
94
 
95
95
  ${c}`),i.statusCode===500&&(l+=`
96
96
 
97
- Check the API status: https://status.openai.com`),new F(l)}return JSON.parse(c)},wa=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),Aa=async(e,t,n,r,o,s,u,i,c,l,f,a,D,p,d)=>{try{const h={...W,locale:o,maxLength:i,type:c,generate:u,promptPath:D},m=re(h),b=(await ba(e,t,n,{model:r,messages:[{role:"system",content:`${m}`},{role:"user",content:`Here are diff: ${s}`}],temperature:a,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:f,stream:!1},l,d)).choices.filter(A=>A.message?.content).map(A=>wa(A.message.content)).join();return p&&K("OPEN AI",s,m,b),b}catch(h){const m=h;throw m.code==="ENOTFOUND"?new F(`Error connecting to ${m.hostname} (${m.syscall})`):m}};class va extends U{constructor(t){super(t),this.params=t,this.handleError$=n=>{let r="An error occurred";if(n.message){r=n.message.split(`
98
- `)[0];const o=this.extractJSONFromError(n.message);r+=`: ${o.error.message}`}return x({name:`${this.errorPrefix} ${r}`,value:r,isError:!0,disabled:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=g.red.bold("[ChatGPT]")}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}extractJSONFromError(t){const n=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,r=t.match(n);return r?Object.assign({},...r.map(o=>JSON.parse(o))):{error:{message:"Unknown error"}}}async generateMessage(){const t=this.params.stagedDiff.diff,{locale:n,generate:r,type:o}=this.params.config,s=this.params.config["max-length"],u=await Aa(this.params.config.OPENAI_URL,this.params.config.OPENAI_PATH,this.params.config.OPENAI_KEY,this.params.config.OPENAI_MODEL,n,t,r,s,o,this.params.config.timeout,this.params.config["max-tokens"],this.params.config.temperature,this.params.config.prompt,this.params.config.logging,this.params.config.proxy);return this.sanitizeMessage(u,this.params.config.type,r,this.params.config.ignoreBody)}}class mn{constructor(t,n){this.config=t,this.stagedDiff=n}createAIRequests$(t){return S(t).pipe(qt(n=>{const r={config:this.config,stagedDiff:this.stagedDiff,keyName:n};switch(n){case M.OPEN_AI:return H.create(va,r).generateCommitMessage$();case M.GEMINI:return H.create(Ni,r).generateCommitMessage$();case M.ANTHROPIC:return H.create(Ti,r).generateCommitMessage$();case M.HUGGINGFACE:return H.create(ji,r).generateCommitMessage$();case M.MISTRAL:return H.create(Gi,r).generateCommitMessage$();case M.CODESTRAL:return H.create(Li,r).generateCommitMessage$();case M.OLLAMA:return S(this.config.OLLAMA_MODEL).pipe(qt(s=>{const u={...r,keyName:s};return H.create(zi,u).generateCommitMessage$()}));case M.COHERE:return H.create(Ri,r).generateCommitMessage$();case M.GROQ:return H.create(ki,r).generateCommitMessage$();default:const o=g.red.bold(`[${n}]`);return x({name:o+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}),T(n=>{const r=g.red.bold("[UNKNOWN]");return x({name:r+` ${n.message||""}`,value:"Unknown error",isError:!0,disabled:!0})}))}}const hn=async()=>{const{stdout:e,failed:t}=await te("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new F("The current directory must be a Git repository!");return e},Tt=e=>`:(exclude)${e}`,gn=["package-lock.json","pnpm-lock.yaml","*.lock","*.gif","*.png"].map(Tt),Cn=async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:n}=await te("git",[...t,"--name-only",...gn,...e?e.map(Tt):[]]);if(!n)return null;const{stdout:r}=await te("git",[...t,...gn,...e?e.map(Tt):[]]);return{files:n.split(`
99
- `),diff:r}},$a=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class Ee{constructor(){this.title="aicommit2"}printTitle(){console.log(Zn.textSync(this.title,{font:"Small"}))}displaySpinner(t){return ke(t).start()}stopSpinner(t){t.stop(),t.clear()}printStagedFiles(t){console.log(g.bold.green("\u2714 ")+g.bold(`${$a(t.files)}:`)),console.log(`${t.files.map(n=>` ${n}`).join(`
97
+ Check the API status: https://status.openai.com`),new F(l)}return JSON.parse(c)},wa=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),Aa=async(e,t,r,n,o,s,u,i,c,l,f,a,D,p,d)=>{try{const h={...W,locale:o,maxLength:i,type:c,generate:u,promptPath:D},m=re(h),b=(await ba(e,t,r,{model:n,messages:[{role:"system",content:`${m}`},{role:"user",content:`Here are diff: ${s}`}],temperature:a,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:f,stream:!1},l,d)).choices.filter(A=>A.message?.content).map(A=>wa(A.message.content)).join();return p&&K("OPEN AI",s,m,b),b}catch(h){const m=h;throw m.code==="ENOTFOUND"?new F(`Error connecting to ${m.hostname} (${m.syscall})`):m}};class va extends U{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";if(r.message){n=r.message.split(`
98
+ `)[0];const o=this.extractJSONFromError(r.message);n+=`: ${o.error.message}`}return x({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=g.red.bold("[ChatGPT]")}generateCommitMessage$(){return G(this.generateMessage()).pipe(j(t=>S(t)),_(t=>({name:`${this.serviceName} ${t.title}`,value:t.value,description:t.value,isError:!1})),T(this.handleError$))}extractJSONFromError(t){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,n=t.match(r);return n?Object.assign({},...n.map(o=>JSON.parse(o))):{error:{message:"Unknown error"}}}async generateMessage(){const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o}=this.params.config,s=this.params.config["max-length"],u=await Aa(this.params.config.OPENAI_URL,this.params.config.OPENAI_PATH,this.params.config.OPENAI_KEY,this.params.config.OPENAI_MODEL,r,t,n,s,o,this.params.config.timeout,this.params.config["max-tokens"],this.params.config.temperature,this.params.config.prompt,this.params.config.logging,this.params.config.proxy);return this.sanitizeMessage(u,this.params.config.type,n,this.params.config.ignoreBody)}}class mn{constructor(t,r){this.config=t,this.stagedDiff=r}createAIRequests$(t){return S(t).pipe(qt(r=>{const n={config:this.config,stagedDiff:this.stagedDiff,keyName:r};switch(r){case M.OPEN_AI:return H.create(va,n).generateCommitMessage$();case M.GEMINI:return H.create(Ni,n).generateCommitMessage$();case M.ANTHROPIC:return H.create(Ti,n).generateCommitMessage$();case M.HUGGINGFACE:return H.create(ji,n).generateCommitMessage$();case M.MISTRAL:return H.create(Gi,n).generateCommitMessage$();case M.CODESTRAL:return H.create(Li,n).generateCommitMessage$();case M.OLLAMA:return S(this.config.OLLAMA_MODEL).pipe(qt(s=>{const u={...n,keyName:s};return H.create(zi,u).generateCommitMessage$()}));case M.COHERE:return H.create(Ri,n).generateCommitMessage$();case M.GROQ:return H.create(ki,n).generateCommitMessage$();default:const o=g.red.bold(`[${r}]`);return x({name:o+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}),T(r=>{const n=g.red.bold("[UNKNOWN]");return x({name:n+` ${r.message||""}`,value:"Unknown error",isError:!0,disabled:!0})}))}}const hn=async()=>{const{stdout:e,failed:t}=await te("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new F("The current directory must be a Git repository!");return e},Tt=e=>`:(exclude)${e}`,gn=["package-lock.json","pnpm-lock.yaml","*.lock","*.gif","*.png"].map(Tt),Cn=async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:r}=await te("git",[...t,"--name-only",...gn,...e?e.map(Tt):[]]);if(!r)return null;const{stdout:n}=await te("git",[...t,...gn,...e?e.map(Tt):[]]);return{files:r.split(`
99
+ `),diff:n}},$a=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class Ee{constructor(){this.title="aicommit2"}printTitle(){console.log(Zn.textSync(this.title,{font:"Small"}))}displaySpinner(t){return ke(t).start()}stopSpinner(t){t.stop(),t.clear()}printStagedFiles(t){console.log(g.bold.green("\u2714 ")+g.bold(`${$a(t.files)}:`)),console.log(`${t.files.map(r=>` ${r}`).join(`
100
100
  `)}
101
101
  `)}printAnalyzed(){console.log(`
102
102
  ${g.bold.green("\u2714")} ${g.bold("Changes analyzed")}`)}printCommitted(){console.log(`
@@ -104,10 +104,10 @@ ${g.bold.green("\u2714")} ${g.bold("Successfully committed!")}`)}printCopied(){c
104
104
  ${g.bold.green("\u2714")} ${g.bold("Successfully copied! Press 'Ctrl + V' to paste")}`)}printSavedCommitMessage(){console.log(`
105
105
  ${g.bold.green("\u2714")} ${g.bold("Saved commit message")}`)}printCancelledCommit(){console.log(`
106
106
  ${g.bold.yellow("\u26A0")} ${g.yellow("Commit cancelled")}`)}printErrorMessage(t){console.log(`
107
- ${g.bold.red("\u2716")} ${g.red(`${t}`)}`)}moveCursorUp(){const t=Fe.createInterface({input:process.stdin,output:process.stdout});Fe.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=Fe.createInterface({input:process.stdin,output:process.stdout});Fe.moveCursor(process.stdout,0,1),t.close()}}const Ba={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},Lt="No commit messages were generated";class Oa{constructor(){this.choices$=new zt([]),this.loader$=new zt(Ba),this.destroyed$=new _n(1)}initPrompt(t){return Ne.registerPrompt("reactiveListPrompt",eo),Ne.prompt({type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${Lt}`,loop:!1,showDescription:t,descPageSize:10,choices$:this.choices$,loader$:this.loader$})}startLoader(){this.loader$.next({isLoading:!0})}refreshChoices(t){const{value:n,isError:r}=t;if(!t||!n)return;if(!t.id){this.choices$.next([...this.currentChoices,t].sort(pe));return}this.checkStreamChoice(t)}checkErrorOnChoices(){if(this.choices$.getValue().map(n=>n).every(n=>n?.isError||n?.disabled)){this.alertNoGeneratedMessage(),this.logEmptyCommitMessage(),process.exit(1);return}this.stopLoaderOnSuccess()}completeSubject(){this.choices$.complete(),this.loader$.complete(),this.destroyed$.next(!0),this.destroyed$.complete()}alertNoGeneratedMessage(){this.loader$.next({isLoading:!1,message:Lt,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:"Changes analyzed"})}logEmptyCommitMessage(){console.log(`${g.bold.yellow("\u26A0")} ${g.yellow(`${Lt}`)}`)}checkStreamChoice(t){if(t.description===Mi){const o=this.currentChoices.find(s=>{const u=s.id||"",i=/\d/.test(u);return t.id?.includes(u)&&!i});if(o){this.choices$.next([...this.currentChoices.filter(s=>s.id!==o.id),t].sort(pe));return}this.choices$.next([...this.currentChoices,t].sort(pe));return}if(this.currentChoices.find(o=>o?.id===t.id)){this.choices$.next(this.currentChoices.map(o=>o?.id===t.id?t:o).sort(pe));return}this.choices$.next([...this.currentChoices,t].sort(pe))}get currentChoices(){return this.choices$.getValue().map(t=>t)}}const q=new Ee;var xa=async(e,t,n,r,o,s,u,i,c)=>(async()=>{q.printTitle(),await hn(),r&&await te("git",["add","--update"]);const l=q.displaySpinner("Detecting staged files"),f=await Cn(n);if(l.stop(),!f)throw new F("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");q.printStagedFiles(f);const{env:a}=process,D=await bt({OPENAI_KEY:a.OPENAI_KEY||a.OPENAI_API_KEY,OPENAI_MODEL:a.OPENAI_MODEL||a["openai-model"]||a.openai_model,OPENAI_URL:a.OPENAI_URL||a["openai-url"]||a.OPENAI_URL,GEMINI_KEY:a.GEMINI_KEY||a.GEMINI_API_KEY,GEMINI_MODEL:a.GEMINI_MODEL||a["gemini-model"]||a.gemini_model,ANTHROPIC_KEY:a.ANTHROPIC_KEY||a.ANTHROPIC_API_KEY,ANTHROPIC_MODEL:a.ANTHROPIC_MODEL||a["anthropic-model"]||a.anthropic_model,HUGGINGFACE_MODEL:a.HUGGINGFACE_MODEL,MISTRAL_KEY:a.MISTRAL_KEY||a.MISTRAL_API_KEY,CODESTRAL_KEY:a.CODESTRAL_KEY||a.CODESTRAL_API_KEY,MISTRAL_MODEL:a.MISTRAL_MODEL||a["mistral-model"]||a.mistral_model,proxy:a.https_proxy||a.HTTPS_PROXY||a.http_proxy||a.HTTP_PROXY,temperature:a.temperature,generate:t?.toString()||a.generate,type:o?.toString()||a.type,locale:e?.toString()||a.locale,promptPath:i?.toString()||a.promptPath});if(D.promptPath)try{k.readFileSync(P.resolve(D.promptPath),"utf-8")}catch{throw new F(`Error reading user prompt file: ${D.promptPath}`)}const p=Object.entries(D).filter(([w])=>Kr.includes(w)).filter(([w,ue])=>w===M.OLLAMA?!!ue&&ue.length>0:!!ue).map(([w])=>w);if(p.length===0)throw new F("Please set at least one API key via the `aicommit2 config set` command");const h=new mn(D,f),m=new Oa,E=m.initPrompt(!D.ignoreBody);m.startLoader();const b=h.createAIRequests$(p).subscribe(w=>m.refreshChoices(w),()=>{},()=>m.checkErrorOnChoices()),A=await E;b.unsubscribe(),m.completeSubject(),q.moveCursorUp();const R=A.aicommit2Prompt?.value;if(!R)throw new F("An error occurred! No selected message");if(u&&(bs("copy-paste").copy(R),q.printCopied(),process.exit()),s){const w=ke("Committing with the generated message").start();await te("git",["commit","-m",R,...c]),w.stop(),w.clear(),q.printCommitted(),process.exit()}const N=await Ne.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:se}=N;if(se){const w=ke("Committing with the generated message").start();await te("git",["commit","-m",R,...c]),w.stop(),w.clear(),q.printCommitted(),process.exit()}q.printCancelledCommit(),process.exit()})().catch(l=>{q.printErrorMessage(l.message),fe(l),process.exit(1)}),Ma=Je({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:n}=e._;if(t==="get"){const r=await bt({},!0);for(const o of n)Ft(r,o)&&console.log(`${o}=${r[o]}`);return}if(t==="set"){await qi(n.map(r=>r.split("=")));return}throw new F(`Invalid mode: ${t}`)})().catch(t=>{new Ee().printErrorMessage(t.message),fe(t),process.exit(1)})});const En="prepare-commit-msg",Fn=`.git/hooks/${En}`,Te=Xn(new URL("cli.mjs",import.meta.url)),Sa=process.argv[1].replace(/\\/g,"/").endsWith(`/${Fn}`),yn=process.platform==="win32",bn=`
107
+ ${g.bold.red("\u2716")} ${g.red(`${t}`)}`)}moveCursorUp(){const t=Fe.createInterface({input:process.stdin,output:process.stdout});Fe.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=Fe.createInterface({input:process.stdin,output:process.stdout});Fe.moveCursor(process.stdout,0,1),t.close()}}const Ba={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},Lt="No commit messages were generated";class Oa{constructor(){this.choices$=new zt([]),this.loader$=new zt(Ba),this.destroyed$=new _n(1)}initPrompt(t){return Ne.registerPrompt("reactiveListPrompt",eo),Ne.prompt({type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${Lt}`,loop:!1,showDescription:t,descPageSize:10,choices$:this.choices$,loader$:this.loader$})}startLoader(){this.loader$.next({isLoading:!0})}refreshChoices(t){const{value:r,isError:n}=t;if(!t||!r)return;if(!t.id){this.choices$.next([...this.currentChoices,t].sort(pe));return}this.checkStreamChoice(t)}checkErrorOnChoices(){if(this.choices$.getValue().map(r=>r).every(r=>r?.isError||r?.disabled)){this.alertNoGeneratedMessage(),this.logEmptyCommitMessage(),process.exit(1);return}this.stopLoaderOnSuccess()}completeSubject(){this.choices$.complete(),this.loader$.complete(),this.destroyed$.next(!0),this.destroyed$.complete()}alertNoGeneratedMessage(){this.loader$.next({isLoading:!1,message:Lt,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:"Changes analyzed"})}logEmptyCommitMessage(){console.log(`${g.bold.yellow("\u26A0")} ${g.yellow(`${Lt}`)}`)}checkStreamChoice(t){if(t.description===Mi){const o=this.currentChoices.find(s=>{const u=s.id||"",i=/\d/.test(u);return t.id?.includes(u)&&!i});if(o){this.choices$.next([...this.currentChoices.filter(s=>s.id!==o.id),t].sort(pe));return}this.choices$.next([...this.currentChoices,t].sort(pe));return}if(this.currentChoices.find(o=>o?.id===t.id)){this.choices$.next(this.currentChoices.map(o=>o?.id===t.id?t:o).sort(pe));return}this.choices$.next([...this.currentChoices,t].sort(pe))}get currentChoices(){return this.choices$.getValue().map(t=>t)}}const q=new Ee;var xa=async(e,t,r,n,o,s,u,i,c)=>(async()=>{q.printTitle(),await hn(),n&&await te("git",["add","--update"]);const l=q.displaySpinner("Detecting staged files"),f=await Cn(r);if(l.stop(),!f)throw new F("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");q.printStagedFiles(f);const{env:a}=process,D=await bt({OPENAI_KEY:a.OPENAI_KEY||a.OPENAI_API_KEY,OPENAI_MODEL:a.OPENAI_MODEL||a["openai-model"]||a.openai_model,OPENAI_URL:a.OPENAI_URL||a["openai-url"]||a.OPENAI_URL,GEMINI_KEY:a.GEMINI_KEY||a.GEMINI_API_KEY,GEMINI_MODEL:a.GEMINI_MODEL||a["gemini-model"]||a.gemini_model,ANTHROPIC_KEY:a.ANTHROPIC_KEY||a.ANTHROPIC_API_KEY,ANTHROPIC_MODEL:a.ANTHROPIC_MODEL||a["anthropic-model"]||a.anthropic_model,HUGGINGFACE_MODEL:a.HUGGINGFACE_MODEL,MISTRAL_KEY:a.MISTRAL_KEY||a.MISTRAL_API_KEY,CODESTRAL_KEY:a.CODESTRAL_KEY||a.CODESTRAL_API_KEY,MISTRAL_MODEL:a.MISTRAL_MODEL||a["mistral-model"]||a.mistral_model,proxy:a.https_proxy||a.HTTPS_PROXY||a.http_proxy||a.HTTP_PROXY,temperature:a.temperature,generate:t?.toString()||a.generate,type:o?.toString()||a.type,locale:e?.toString()||a.locale,promptPath:i?.toString()||a.promptPath});if(D.promptPath)try{k.readFileSync(P.resolve(D.promptPath),"utf-8")}catch{throw new F(`Error reading user prompt file: ${D.promptPath}`)}const p=Object.entries(D).filter(([w])=>Kr.includes(w)).filter(([w,ue])=>w===M.OLLAMA?!!ue&&ue.length>0:!!ue).map(([w])=>w);if(p.length===0)throw new F("Please set at least one API key via the `aicommit2 config set` command");const h=new mn(D,f),m=new Oa,E=m.initPrompt(!D.ignoreBody);m.startLoader();const b=h.createAIRequests$(p).subscribe(w=>m.refreshChoices(w),()=>{},()=>m.checkErrorOnChoices()),A=await E;b.unsubscribe(),m.completeSubject(),q.moveCursorUp();const R=A.aicommit2Prompt?.value;if(!R)throw new F("An error occurred! No selected message");if(u&&(bs("copy-paste").copy(R),q.printCopied(),process.exit()),s){const w=ke("Committing with the generated message").start();await te("git",["commit","-m",R,...c]),w.stop(),w.clear(),q.printCommitted(),process.exit()}const N=await Ne.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:se}=N;if(se){const w=ke("Committing with the generated message").start();await te("git",["commit","-m",R,...c]),w.stop(),w.clear(),q.printCommitted(),process.exit()}q.printCancelledCommit(),process.exit()})().catch(l=>{q.printErrorMessage(l.message),fe(l),process.exit(1)}),Ma=Je({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:r}=e._;if(t==="get"){const n=await bt({},!0);for(const o of r)Ft(n,o)&&console.log(`${o}=${n[o]}`);return}if(t==="set"){await qi(r.map(n=>n.split("=")));return}throw new F(`Invalid mode: ${t}`)})().catch(t=>{new Ee().printErrorMessage(t.message),fe(t),process.exit(1)})});const En="prepare-commit-msg",Fn=`.git/hooks/${En}`,Te=Xn(new URL("cli.mjs",import.meta.url)),Sa=process.argv[1].replace(/\\/g,"/").endsWith(`/${Fn}`),yn=process.platform==="win32",bn=`
108
108
  #!/usr/bin/env node
109
109
  import(${JSON.stringify(Qn(Te))})
110
- `.trim();var Pa=Je({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await hn(),{installUninstall:n}=e._,r=P.join(t,Fn),o=await en(r);if(n==="install"){if(o){if(await O.realpath(r).catch(()=>{})===Te){console.warn("The hook is already installed");return}throw new F(`A different ${En} hook seems to be installed. Please remove it before installing aicommit2.`)}await O.mkdir(P.dirname(r),{recursive:!0}),yn?await O.writeFile(r,bn):(await O.symlink(Te,r,"file"),await O.chmod(r,493)),console.log(`${g.green("\u2714")} Hook installed`);return}if(n==="uninstall"){if(!o){console.warn("Hook is not installed");return}if(yn){if(await O.readFile(r,"utf8")!==bn){console.warn("Hook is not installed");return}}else if(await O.realpath(r)!==Te){console.warn("Hook is not installed");return}await O.rm(r),console.log(`${g.green("\u2714")} Hook uninstalled`);return}throw new F(`Invalid mode: ${n}`)})().catch(t=>{console.error(`${g.red("\u2716")} ${t.message}`),fe(t),process.exit(1)})}),Ia=Je({name:"log",parameters:["<removeAll>"]},e=>{(async()=>{const{removeAll:t}=e._;if(t==="removeAll"){await to(Wr,{recursive:!0,force:!0}),console.log(`${g.green("\u2714")} All Log files are removed!`);return}throw new F(`Invalid mode: ${t}`)})().catch(t=>{new Ee().printErrorMessage(t.message),fe(t),process.exit(1)})});const[Rt,_a]=process.argv.slice(2);var Ta=()=>(async()=>{if(!Rt)throw new F('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(_a)return;const e=await Cn();if(!e)return;const t=new Ee;t.printTitle();const{env:n}=process,r=await bt({proxy:n.https_proxy||n.HTTPS_PROXY||n.http_proxy||n.HTTP_PROXY}),o=Object.entries(r).filter(([p])=>Kr.includes(p)).filter(([p,d])=>p===M.OLLAMA?!!d&&d.length>0:!!d).map(([p])=>p);if(o.length===0)throw new F("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const u=new mn(r,e),i=t.displaySpinner("The AI is analyzing your changes");let c;try{c=await Tn(u.createAIRequests$(o).pipe(Ln(p=>!p.isError),_(p=>p.value),Rn()))}finally{i.stop(),i.clear(),t.printAnalyzed()}const f=await O.readFile(Rt,"utf8")!=="",a=c.length>1;let D="";f&&(D=`# \u{1F916} AI generated commit${a?"s":""}
110
+ `.trim();var Pa=Je({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await hn(),{installUninstall:r}=e._,n=P.join(t,Fn),o=await en(n);if(r==="install"){if(o){if(await O.realpath(n).catch(()=>{})===Te){console.warn("The hook is already installed");return}throw new F(`A different ${En} hook seems to be installed. Please remove it before installing aicommit2.`)}await O.mkdir(P.dirname(n),{recursive:!0}),yn?await O.writeFile(n,bn):(await O.symlink(Te,n,"file"),await O.chmod(n,493)),console.log(`${g.green("\u2714")} Hook installed`);return}if(r==="uninstall"){if(!o){console.warn("Hook is not installed");return}if(yn){if(await O.readFile(n,"utf8")!==bn){console.warn("Hook is not installed");return}}else if(await O.realpath(n)!==Te){console.warn("Hook is not installed");return}await O.rm(n),console.log(`${g.green("\u2714")} Hook uninstalled`);return}throw new F(`Invalid mode: ${r}`)})().catch(t=>{console.error(`${g.red("\u2716")} ${t.message}`),fe(t),process.exit(1)})}),Ia=Je({name:"log",parameters:["<removeAll>"]},e=>{(async()=>{const{removeAll:t}=e._;if(t==="removeAll"){await to(Wr,{recursive:!0,force:!0}),console.log(`${g.green("\u2714")} All Log files are removed!`);return}throw new F(`Invalid mode: ${t}`)})().catch(t=>{new Ee().printErrorMessage(t.message),fe(t),process.exit(1)})});const[Rt,_a]=process.argv.slice(2);var Ta=()=>(async()=>{if(!Rt)throw new F('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(_a)return;const e=await Cn();if(!e)return;const t=new Ee;t.printTitle();const{env:r}=process,n=await bt({proxy:r.https_proxy||r.HTTPS_PROXY||r.http_proxy||r.HTTP_PROXY}),o=Object.entries(n).filter(([p])=>Kr.includes(p)).filter(([p,d])=>p===M.OLLAMA?!!d&&d.length>0:!!d).map(([p])=>p);if(o.length===0)throw new F("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const u=new mn(n,e),i=t.displaySpinner("The AI is analyzing your changes");let c;try{c=await Tn(u.createAIRequests$(o).pipe(Ln(p=>!p.isError),_(p=>p.value),Rn()))}finally{i.stop(),i.clear(),t.printAnalyzed()}const f=await O.readFile(Rt,"utf8")!=="",a=c.length>1;let D="";f&&(D=`# \u{1F916} AI generated commit${a?"s":""}
111
111
  `),a?(f&&(D+=`# Select one of the following messages by uncommenting:
112
112
  `),D+=`
113
113
  ${c.map(p=>`# ${p}`).join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicommit2",
3
- "version": "1.12.3",
3
+ "version": "1.12.5",
4
4
  "description": "A Reactive CLI that generates git commit messages with various AI",
5
5
  "keywords": [
6
6
  "cli",
@@ -10,6 +10,7 @@
10
10
  "git-commit",
11
11
  "command-line",
12
12
  "commandline",
13
+ "aipick",
13
14
  "aicommit",
14
15
  "aicommits",
15
16
  "aicommit2",
@@ -26,10 +27,12 @@
26
27
  "mistral",
27
28
  "ollama",
28
29
  "llama3",
30
+ "llama3.1",
29
31
  "llm",
30
32
  "chatgpt",
31
33
  "cohere",
32
- "groq"
34
+ "groq",
35
+ "codestral"
33
36
  ],
34
37
  "license": "MIT",
35
38
  "repository": "tak-bro/aicommit2",
@@ -57,7 +60,7 @@
57
60
  "groq-sdk": "^0.4.0",
58
61
  "inquirer": "9.2.8",
59
62
  "inquirer-reactive-list-prompt": "^1.0.8",
60
- "ollama": "^0.5.0",
63
+ "ollama": "^0.5.6",
61
64
  "ora": "^8.0.1",
62
65
  "readline": "^1.3.0",
63
66
  "rxjs": "^7.8.1",