aicommit2 2.0.9 → 2.1.0

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 +55 -23
  2. package/dist/cli.mjs +82 -74
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -202,7 +202,7 @@ systemPromptPath="<your-prompt-path>"
202
202
  [GEMINI]
203
203
  key="<your-api-key>"
204
204
  generate=5
205
- ignoreBody=false
205
+ includeBody=true
206
206
 
207
207
  [OLLAMA]
208
208
  temperature=0.7
@@ -217,27 +217,29 @@ model[]=codestral
217
217
  The following settings can be applied to most models, but support may vary.
218
218
  Please check the documentation for each specific model to confirm which settings are supported.
219
219
 
220
- | Setting | Description | Default |
221
- |--------------------|---------------------------------------------------------------------|--------------|
222
- | `systemPrompt` | System Prompt text | - |
223
- | `systemPromptPath` | Path to system prompt file | - |
224
- | `exclude` | Files to exclude from AI analysis | - |
225
- | `type` | Type of commit message to generate | conventional |
226
- | `locale` | Locale for the generated commit messages | en |
227
- | `generate` | Number of commit messages to generate | 1 |
228
- | `logging` | Enable logging | true |
229
- | `ignoreBody` | Whether the commit message includes body | true |
230
- | `maxLength` | Maximum character length of the Subject of generated commit message | 50 |
231
- | `timeout` | Request timeout (milliseconds) | 10000 |
232
- | `temperature` | Model's creativity (0.0 - 2.0) | 0.7 |
233
- | `maxTokens` | Maximum number of tokens to generate | 1024 |
234
- | `topP` | Nucleus sampling | 0.9 |
220
+ | Setting | Description | Default |
221
+ |------------------------|---------------------------------------------------------------------|--------------|
222
+ | `systemPrompt` | System Prompt text | - |
223
+ | `systemPromptPath` | Path to system prompt file | - |
224
+ | `exclude` | Files to exclude from AI analysis | - |
225
+ | `type` | Type of commit message to generate | conventional |
226
+ | `locale` | Locale for the generated commit messages | en |
227
+ | `generate` | Number of commit messages to generate | 1 |
228
+ | `logging` | Enable logging | true |
229
+ | `includeBody` | Whether the commit message includes body | false |
230
+ | `maxLength` | Maximum character length of the Subject of generated commit message | 50 |
231
+ | `timeout` | Request timeout (milliseconds) | 10000 |
232
+ | `temperature` | Model's creativity (0.0 - 2.0) | 0.7 |
233
+ | `maxTokens` | Maximum number of tokens to generate | 1024 |
234
+ | `topP` | Nucleus sampling | 0.9 |
235
+ | `codeReview` | whether to include an automated code review in the process | false |
236
+ | `codeReviewPromptPath` | Path to code review prompt file | - |
235
237
 
236
238
  > 👉 **Tip:** To set the General Settings for each model, use the following command.
237
239
  > ```shell
238
240
  > aicommit2 config set OPENAI.locale="jp"
239
241
  > aicommit2 config set CODESTRAL.type="gitmoji"
240
- > aicommit2 config set GEMINI.ignoreBody=false
242
+ > aicommit2 config set GEMINI.includeBody=true
241
243
  > ```
242
244
 
243
245
  ##### systemPrompt
@@ -318,21 +320,21 @@ The log files will be stored in the `~/.aicommit2_log` directory(user's home).
318
320
  aicommit2 log removeAll
319
321
  ```
320
322
 
321
- ##### ignoreBody
323
+ ##### includeBody
322
324
 
323
- Default: `true`
325
+ Default: `false`
324
326
 
325
- This option determines whether the commit message includes body. If you want to include body in message, you can set it to `false`.
327
+ This option determines whether the commit message includes body. If you want to include body in message, you can set it to `true`.
326
328
 
327
329
  ```sh
328
- aicommit2 config set ignoreBody="false"
330
+ aicommit2 config set includeBody="true"
329
331
  ```
330
332
 
331
333
  ![ignore_body_false](https://github.com/tak-bro/aicommit2/blob/main/img/demo_body_min.gif?raw=true)
332
334
 
333
335
 
334
336
  ```sh
335
- aicommit2 config set ignoreBody="true"
337
+ aicommit2 config set includeBody="false"
336
338
  ```
337
339
 
338
340
  ![ignore_body_true](https://github.com/tak-bro/aicommit2/blob/main/img/ignore_body_true.png?raw=true)
@@ -387,6 +389,36 @@ Nucleus sampling, where the model considers the results of the tokens with top_p
387
389
  aicommit2 config set topP=0.2
388
390
  ```
389
391
 
392
+ ##### codeReview
393
+
394
+ Default: `false`
395
+
396
+ The `codeReview` parameter determines whether to include an automated code review in the process.
397
+
398
+ ```sh
399
+ aicommit2 config set codeReview=true
400
+ ```
401
+
402
+ > NOTE: When enabled, aicommit2 will perform a code review before generating commit messages.
403
+
404
+ <img src="https://github.com/tak-bro/aicommit2/blob/main/img/code_review.gif?raw=true" alt="CODE_REVIEW" />
405
+
406
+ ⚠️ **CAUTION**
407
+
408
+ - The `codeReview` feature is currently experimental.
409
+ - This feature performs a code review before generating commit messages.
410
+ - Using this feature will significantly increase the overall processing time.
411
+ - It may significantly impact performance and cost.
412
+ - **The code review process consumes a large number of tokens, due to the lack of caching for git diff.**
413
+
414
+ ##### codeReviewPromptPath
415
+ - Allow users to specify a custom file path for code review
416
+
417
+ ```sh
418
+ aicommit2 config set codeReviewPromptPath="/path/to/user/prompt.txt"
419
+ ```
420
+
421
+
390
422
  ## Available General Settings by Model
391
423
  | | timeout | temperature | maxTokens | topP |
392
424
  |:--------------------:|:-------:|:-----------:|:---------:|:------:|
@@ -403,7 +435,7 @@ aicommit2 config set topP=0.2
403
435
  | **Ollama** | ✓ | ✓ | | ✓ |
404
436
 
405
437
  > All AI support the following options in General Settings.
406
- > - systemPrompt, systemPromptPath, exclude, type, locale, generate, logging, ignoreBody, maxLength
438
+ > - systemPrompt, systemPromptPath, codeReview, codeReviewPromptPath, exclude, type, locale, generate, logging, includeBody, maxLength
407
439
 
408
440
  ## Model-Specific Settings
409
441
 
package/dist/cli.mjs CHANGED
@@ -1,56 +1,56 @@
1
1
  #!/usr/bin/env node
2
- import ze from"tty";import{createRequire as Bo}from"module";import W from"fs";import L from"path";import{Buffer as xo}from"node:buffer";import X from"node:path";import Wt,{ChildProcess as Po}from"node:child_process";import U from"node:process";import So from"child_process";import{fileURLToPath as Kt}from"node:url";import Oo,{constants as Vt}from"node:os";import Jt from"assert";import Yt from"events";import{createWriteStream as Mo,createReadStream as Io}from"node:fs";import To from"buffer";import We from"stream";import Xt from"util";import{debuglog as ko}from"node:util";import Ke from"inquirer";import Ve from"ora";import C from"chalk";import{of as O,concatMap as N,from as M,map as I,catchError as T,mergeMap as Zt,BehaviorSubject as Qt,ReplaySubject as Lo,lastValueFrom as No,filter as Ro,toArray as _o}from"rxjs";import jo from"@anthropic-ai/sdk";import{fromPromise as R}from"rxjs/internal/observable/innerFrom";import Je from"os";import{xxh64 as Go}from"@pacote/xxhash";import Ho from"axios";import{CohereClient as Uo,CohereTimeoutError as qo}from"cohere-ai";import{GoogleGenerativeAI as zo,HarmCategory as ye,HarmBlockThreshold as Ee}from"@google/generative-ai";import Wo from"groq-sdk";import Ko from"http";import Vo from"https";import Jo from"net";import Yo from"tls";import Xo,{fileURLToPath as Zo,pathToFileURL as Qo}from"url";import{Ollama as en}from"ollama";import P from"fs/promises";import be from"readline";import tn from"figlet";import rn from"inquirer-reactive-list-prompt";import{rm as on}from"node:fs/promises";const nn="known-flag",sn="unknown-flag",un="argument",{stringify:ae}=JSON,an=/\B([A-Z])/g,cn=e=>e.replace(an,"-$1").toLowerCase(),{hasOwnProperty:Dn}=Object.prototype,ce=(e,t)=>Dn.call(e,t),ln=e=>Array.isArray(e),er=e=>typeof e=="function"?[e,!1]:ln(e)?[e[0],!0]:er(e.type),mn=(e,t)=>e===Boolean?t!=="false":t,pn=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),fn=/[\s.:=]/,dn=e=>{const t=`Flag name ${ae(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(fn);if(r)throw new Error(`${t} cannot contain ${ae(r?.[0])}`)},hn=e=>{const t={},r=(o,n)=>{if(ce(t,o))throw new Error(`Duplicate flags named ${ae(o)}`);t[o]=n};for(const o in e){if(!ce(e,o))continue;dn(o);const n=e[o],s=[[],...er(n),n];r(o,s);const i=cn(o);if(o!==i&&r(i,s),"alias"in n&&typeof n.alias=="string"){const{alias:u}=n,a=`Flag alias ${ae(u)} for flag ${ae(o)}`;if(u.length===0)throw new Error(`${a} cannot be empty`);if(u.length>1)throw new Error(`${a} must be a single character`);r(u,s)}}return t},gn=(e,t)=>{const r={};for(const o in e){if(!ce(e,o))continue;const[n,,s,i]=t[o];if(n.length===0&&"default"in i){let{default:u}=i;typeof u=="function"&&(u=u()),r[o]=u}else r[o]=s?n:n.pop()}return r},we="--",Cn=/[.:=]/,Fn=/^-{1,2}\w/,yn=e=>{if(!Fn.test(e))return;const t=!e.startsWith(we);let r=e.slice(t?1:2),o;const n=r.match(Cn);if(n){const{index:s}=n;o=r.slice(s+1),r=r.slice(0,s)}return[r,o,t]},En=(e,{onFlag:t,onArgument:r})=>{let o;const n=(s,i)=>{if(typeof o!="function")return!0;o(s,i),o=void 0};for(let s=0;s<e.length;s+=1){const i=e[s];if(i===we){n();const a=e.slice(s+1);r?.(a,[s],!0);break}const u=yn(i);if(u){if(n(),!t)continue;const[a,D,m]=u;if(m)for(let c=0;c<a.length;c+=1){n();const l=c===a.length-1;o=t(a[c],l?D:void 0,[s,c+1,l])}else o=t(a,D,[s])}else n(i,[s])&&r?.([i],[s])}n()},bn=(e,t)=>{for(const[r,o,n]of t.reverse()){if(o){const s=e[r];let i=s.slice(0,o);if(n||(i+=s.slice(o+1)),i!=="-"){e[r]=i;continue}}e.splice(r,1)}},wn=(e,t=process.argv.slice(2),{ignore:r}={})=>{const o=[],n=hn(e),s={},i=[];return i[we]=[],En(t,{onFlag(u,a,D){const m=ce(n,u);if(!r?.(m?nn:sn,u,a)){if(m){const[c,l]=n[u],p=mn(l,a),d=(h,g)=>{o.push(D),g&&o.push(g),c.push(pn(l,h||""))};return p===void 0?d:d(p)}ce(s,u)||(s[u]=[]),s[u].push(a===void 0?!0:a),o.push(D)}},onArgument(u,a,D){r?.(un,t[a[0]])||(i.push(...u),D?(i[we]=u,t.splice(a[0])):o.push(a))}}),bn(t,o),{flags:gn(e,n),unknownFlags:s,_:i}};var An=Object.create,Ae=Object.defineProperty,$n=Object.defineProperties,vn=Object.getOwnPropertyDescriptor,Bn=Object.getOwnPropertyDescriptors,xn=Object.getOwnPropertyNames,tr=Object.getOwnPropertySymbols,Pn=Object.getPrototypeOf,rr=Object.prototype.hasOwnProperty,Sn=Object.prototype.propertyIsEnumerable,or=(e,t,r)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$e=(e,t)=>{for(var r in t||(t={}))rr.call(t,r)&&or(e,r,t[r]);if(tr)for(var r of tr(t))Sn.call(t,r)&&or(e,r,t[r]);return e},Ye=(e,t)=>$n(e,Bn(t)),On=e=>Ae(e,"__esModule",{value:!0}),Mn=(e,t)=>()=>(e&&(t=e(e=0)),t),In=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Tn=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of xn(t))!rr.call(e,n)&&(r||n!=="default")&&Ae(e,n,{get:()=>t[n],enumerable:!(o=vn(t,n))||o.enumerable});return e},kn=(e,t)=>Tn(On(Ae(e!=null?An(Pn(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),S=Mn(()=>{}),Ln=In((e,t)=>{S(),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}});S(),S(),S();var Nn=e=>{var t,r,o;let n=(t=process.stdout.columns)!=null?t:Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(n)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:n}:{columns:(r=e.columns)!=null?r:[],stdoutColumns:(o=e.stdoutColumns)!=null?o:n}};S(),S(),S(),S(),S();function Rn({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 nr(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Rn(),"")}S();function _n(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 jn=kn(Ln(),1);function V(e){if(typeof e!="string"||e.length===0||(e=nr(e),e.length===0))return 0;e=e.replace((0,jn.default)()," ");let t=0;for(let r=0;r<e.length;r++){let o=e.codePointAt(r);o<=31||o>=127&&o<=159||o>=768&&o<=879||(o>65535&&r++,t+=_n(o)?2:1)}return t}var sr=e=>Math.max(...e.split(`
3
- `).map(V)),Gn=e=>{let t=[];for(let r of e){let{length:o}=r,n=o-t.length;for(let s=0;s<n;s+=1)t.push(0);for(let s=0;s<o;s+=1){let i=sr(r[s]);i>t[s]&&(t[s]=i)}}return t};S();var ir=/^\d+%$/,ur={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},Hn=(e,t)=>{var r;let o=[];for(let n=0;n<e.length;n+=1){let s=(r=t[n])!=null?r:"auto";if(typeof s=="number"||s==="auto"||s==="content-width"||typeof s=="string"&&ir.test(s)){o.push(Ye($e({},ur),{width:s,contentWidth:e[n]}));continue}if(s&&typeof s=="object"){let i=Ye($e($e({},ur),s),{contentWidth:e[n]});i.horizontalPadding=i.paddingLeft+i.paddingRight,o.push(i);continue}throw new Error(`Invalid column width: ${JSON.stringify(s)}`)}return o};function Un(e,t){for(let r of e){let{width:o}=r;if(o==="content-width"&&(r.width=r.contentWidth),o==="auto"){let a=Math.min(20,r.contentWidth);r.width=a,r.autoOverflow=r.contentWidth-a}if(typeof o=="string"&&ir.test(o)){let a=Number.parseFloat(o.slice(0,-1))/100;r.width=Math.floor(t*a)-(r.paddingLeft+r.paddingRight)}let{horizontalPadding:n}=r,s=1,i=s+n;if(i>=t){let a=i-t,D=Math.ceil(r.paddingLeft/n*a),m=a-D;r.paddingLeft-=D,r.paddingRight-=m,r.horizontalPadding=r.paddingLeft+r.paddingRight}r.paddingLeftString=r.paddingLeft?" ".repeat(r.paddingLeft):"",r.paddingRightString=r.paddingRight?" ".repeat(r.paddingRight):"";let u=t-r.horizontalPadding;r.width=Math.max(Math.min(r.width,u),s)}}var ar=()=>Object.assign([],{columns:0});function qn(e,t){let r=[ar()],[o]=r;for(let n of e){let s=n.width+n.horizontalPadding;o.columns+s>t&&(o=ar(),r.push(o)),o.push(n),o.columns+=s}for(let n of r){let s=n.reduce((l,p)=>l+p.width+p.horizontalPadding,0),i=t-s;if(i===0)continue;let u=n.filter(l=>"autoOverflow"in l),a=u.filter(l=>l.autoOverflow>0),D=a.reduce((l,p)=>l+p.autoOverflow,0),m=Math.min(D,i);for(let l of a){let p=Math.floor(l.autoOverflow/D*m);l.width+=p,i-=p}let c=Math.floor(i/u.length);for(let l=0;l<u.length;l+=1){let p=u[l];l===u.length-1?p.width+=i:p.width+=c,i-=c}}return r}function zn(e,t,r){let o=Hn(r,t);return Un(o,e),qn(o,e)}S(),S(),S();var Xe=10,cr=(e=0)=>t=>`\x1B[${t+e}m`,Dr=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,lr=(e=0)=>(t,r,o)=>`\x1B[${38+e};2;${t};${r};${o}m`;function Wn(){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,o]of Object.entries(t)){for(let[n,s]of Object.entries(o))t[n]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},o[n]=t[n],e.set(s[0],s[1]);Object.defineProperty(t,r,{value:o,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi=cr(),t.color.ansi256=Dr(),t.color.ansi16m=lr(),t.bgColor.ansi=cr(Xe),t.bgColor.ansi256=Dr(Xe),t.bgColor.ansi16m=lr(Xe),Object.defineProperties(t,{rgbToAnsi256:{value:(r,o,n)=>r===o&&o===n?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(o/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:r=>{let o=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!o)return[0,0,0];let{colorString:n}=o.groups;n.length===3&&(n=n.split("").map(i=>i+i).join(""));let s=Number.parseInt(n,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 o,n,s;if(r>=232)o=((r-232)*10+8)/255,n=o,s=o;else{r-=16;let a=r%36;o=Math.floor(r/36)/5,n=Math.floor(a/6)/5,s=a%6/5}let i=Math.max(o,n,s)*2;if(i===0)return 30;let u=30+(Math.round(s)<<2|Math.round(n)<<1|Math.round(o));return i===2&&(u+=60),u},enumerable:!1},rgbToAnsi:{value:(r,o,n)=>t.ansi256ToAnsi(t.rgbToAnsi256(r,o,n)),enumerable:!1},hexToAnsi:{value:r=>t.ansi256ToAnsi(t.hexToAnsi256(r)),enumerable:!1}}),t}var Kn=Wn(),Vn=Kn,ve=new Set(["\x1B","\x9B"]),Jn=39,Ze="\x07",mr="[",Yn="]",pr="m",Qe=`${Yn}8;;`,fr=e=>`${ve.values().next().value}${mr}${e}${pr}`,dr=e=>`${ve.values().next().value}${Qe}${e}${Ze}`,Xn=e=>e.split(" ").map(t=>V(t)),et=(e,t,r)=>{let o=[...t],n=!1,s=!1,i=V(nr(e[e.length-1]));for(let[u,a]of o.entries()){let D=V(a);if(i+D<=r?e[e.length-1]+=a:(e.push(a),i=0),ve.has(a)&&(n=!0,s=o.slice(u+1).join("").startsWith(Qe)),n){s?a===Ze&&(n=!1,s=!1):a===pr&&(n=!1);continue}i+=D,i===r&&u<o.length-1&&(e.push(""),i=0)}!i&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Zn=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(V(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Qn=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let o="",n,s,i=Xn(e),u=[""];for(let[D,m]of e.split(" ").entries()){r.trim!==!1&&(u[u.length-1]=u[u.length-1].trimStart());let c=V(u[u.length-1]);if(D!==0&&(c>=t&&(r.wordWrap===!1||r.trim===!1)&&(u.push(""),c=0),(c>0||r.trim===!1)&&(u[u.length-1]+=" ",c++)),r.hard&&i[D]>t){let l=t-c,p=1+Math.floor((i[D]-l-1)/t);Math.floor((i[D]-1)/t)<p&&u.push(""),et(u,m,t);continue}if(c+i[D]>t&&c>0&&i[D]>0){if(r.wordWrap===!1&&c<t){et(u,m,t);continue}u.push("")}if(c+i[D]>t&&r.wordWrap===!1){et(u,m,t);continue}u[u.length-1]+=m}r.trim!==!1&&(u=u.map(D=>Zn(D)));let a=[...u.join(`
4
- `)];for(let[D,m]of a.entries()){if(o+=m,ve.has(m)){let{groups:l}=new RegExp(`(?:\\${mr}(?<code>\\d+)m|\\${Qe}(?<uri>.*)${Ze})`).exec(a.slice(D).join(""))||{groups:{}};if(l.code!==void 0){let p=Number.parseFloat(l.code);n=p===Jn?void 0:p}else l.uri!==void 0&&(s=l.uri.length===0?void 0:l.uri)}let c=Vn.codes.get(Number(n));a[D+1]===`
5
- `?(s&&(o+=dr("")),n&&c&&(o+=fr(c))):m===`
6
- `&&(n&&c&&(o+=fr(n)),s&&(o+=dr(s)))}return o};function es(e,t,r){return String(e).normalize().replace(/\r\n/g,`
2
+ import Ve from"tty";import{createRequire as qo}from"module";import T from"fs";import N from"path";import{Buffer as Wo}from"node:buffer";import X from"node:path";import Kt,{ChildProcess as Ko}from"node:child_process";import U from"node:process";import Vo from"child_process";import{fileURLToPath as Vt}from"node:url";import Jo,{constants as Jt}from"node:os";import Yt from"assert";import Xt from"events";import{createWriteStream as Yo,createReadStream as Xo}from"node:fs";import Qo from"buffer";import Je from"stream";import Qt from"util";import{debuglog as Zo}from"node:util";import ye from"inquirer";import Zt from"ora";import C from"chalk";import{of as R,concatMap as P,from as v,map as A,catchError as b,mergeMap as we,BehaviorSubject as er,ReplaySubject as en,lastValueFrom as tn,filter as rn,toArray as on}from"rxjs";import nn from"@anthropic-ai/sdk";import{fromPromise as B}from"rxjs/internal/observable/innerFrom";import Ye from"os";import{xxh64 as sn}from"@pacote/xxhash";import un from"axios";import{CohereClient as an,CohereTimeoutError as cn}from"cohere-ai";import{GoogleGenerativeAI as ln,HarmCategory as ve,HarmBlockThreshold as be}from"@google/generative-ai";import Dn from"groq-sdk";import mn from"http";import dn from"https";import pn from"net";import fn from"tls";import hn,{fileURLToPath as gn,pathToFileURL as Cn}from"url";import{Ollama as En}from"ollama";import I from"fs/promises";import $e from"readline";import Fn from"figlet";import yn from"inquirer-reactive-list-prompt";import{rm as wn}from"node:fs/promises";const vn="known-flag",bn="unknown-flag",$n="argument",{stringify:ae}=JSON,An=/\B([A-Z])/g,Pn=t=>t.replace(An,"-$1").toLowerCase(),{hasOwnProperty:Bn}=Object.prototype,ce=(t,e)=>Bn.call(t,e),xn=t=>Array.isArray(t),tr=t=>typeof t=="function"?[t,!1]:xn(t)?[t[0],!0]:tr(t.type),Sn=(t,e)=>t===Boolean?e!=="false":e,Mn=(t,e)=>typeof e=="boolean"?e:t===Number&&e===""?Number.NaN:t(e),On=/[\s.:=]/,Rn=t=>{const e=`Flag name ${ae(t)}`;if(t.length===0)throw new Error(`${e} cannot be empty`);if(t.length===1)throw new Error(`${e} must be longer than a character`);const r=t.match(On);if(r)throw new Error(`${e} cannot contain ${ae(r?.[0])}`)},In=t=>{const e={},r=(o,n)=>{if(ce(e,o))throw new Error(`Duplicate flags named ${ae(o)}`);e[o]=n};for(const o in t){if(!ce(t,o))continue;Rn(o);const n=t[o],s=[[],...tr(n),n];r(o,s);const i=Pn(o);if(o!==i&&r(i,s),"alias"in n&&typeof n.alias=="string"){const{alias:u}=n,a=`Flag alias ${ae(u)} for flag ${ae(o)}`;if(u.length===0)throw new Error(`${a} cannot be empty`);if(u.length>1)throw new Error(`${a} must be a single character`);r(u,s)}}return e},kn=(t,e)=>{const r={};for(const o in t){if(!ce(t,o))continue;const[n,,s,i]=e[o];if(n.length===0&&"default"in i){let{default:u}=i;typeof u=="function"&&(u=u()),r[o]=u}else r[o]=s?n:n.pop()}return r},Ae="--",Nn=/[.:=]/,Ln=/^-{1,2}\w/,Tn=t=>{if(!Ln.test(t))return;const e=!t.startsWith(Ae);let r=t.slice(e?1:2),o;const n=r.match(Nn);if(n){const{index:s}=n;o=r.slice(s+1),r=r.slice(0,s)}return[r,o,e]},_n=(t,{onFlag:e,onArgument:r})=>{let o;const n=(s,i)=>{if(typeof o!="function")return!0;o(s,i),o=void 0};for(let s=0;s<t.length;s+=1){const i=t[s];if(i===Ae){n();const a=t.slice(s+1);r?.(a,[s],!0);break}const u=Tn(i);if(u){if(n(),!e)continue;const[a,l,m]=u;if(m)for(let c=0;c<a.length;c+=1){n();const D=c===a.length-1;o=e(a[c],D?l:void 0,[s,c+1,D])}else o=e(a,l,[s])}else n(i,[s])&&r?.([i],[s])}n()},jn=(t,e)=>{for(const[r,o,n]of e.reverse()){if(o){const s=t[r];let i=s.slice(0,o);if(n||(i+=s.slice(o+1)),i!=="-"){t[r]=i;continue}}t.splice(r,1)}},Gn=(t,e=process.argv.slice(2),{ignore:r}={})=>{const o=[],n=In(t),s={},i=[];return i[Ae]=[],_n(e,{onFlag(u,a,l){const m=ce(n,u);if(!r?.(m?vn:bn,u,a)){if(m){const[c,D]=n[u],d=Sn(D,a),f=(h,g)=>{o.push(l),g&&o.push(g),c.push(Mn(D,h||""))};return d===void 0?f:f(d)}ce(s,u)||(s[u]=[]),s[u].push(a===void 0?!0:a),o.push(l)}},onArgument(u,a,l){r?.($n,e[a[0]])||(i.push(...u),l?(i[Ae]=u,e.splice(a[0])):o.push(a))}}),jn(e,o),{flags:kn(t,n),unknownFlags:s,_:i}};var Hn=Object.create,Pe=Object.defineProperty,Un=Object.defineProperties,zn=Object.getOwnPropertyDescriptor,qn=Object.getOwnPropertyDescriptors,Wn=Object.getOwnPropertyNames,rr=Object.getOwnPropertySymbols,Kn=Object.getPrototypeOf,or=Object.prototype.hasOwnProperty,Vn=Object.prototype.propertyIsEnumerable,nr=(t,e,r)=>e in t?Pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Be=(t,e)=>{for(var r in e||(e={}))or.call(e,r)&&nr(t,r,e[r]);if(rr)for(var r of rr(e))Vn.call(e,r)&&nr(t,r,e[r]);return t},Xe=(t,e)=>Un(t,qn(e)),Jn=t=>Pe(t,"__esModule",{value:!0}),Yn=(t,e)=>()=>(t&&(e=t(t=0)),e),Xn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Qn=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Wn(e))!or.call(t,n)&&(r||n!=="default")&&Pe(t,n,{get:()=>e[n],enumerable:!(o=zn(e,n))||o.enumerable});return t},Zn=(t,e)=>Qn(Jn(Pe(t!=null?Hn(Kn(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),k=Yn(()=>{}),es=Xn((t,e)=>{k(),e.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}});k(),k(),k();var ts=t=>{var e,r,o;let n=(e=process.stdout.columns)!=null?e:Number.POSITIVE_INFINITY;return typeof t=="function"&&(t=t(n)),t||(t={}),Array.isArray(t)?{columns:t,stdoutColumns:n}:{columns:(r=t.columns)!=null?r:[],stdoutColumns:(o=t.stdoutColumns)!=null?o:n}};k(),k(),k(),k(),k();function rs({onlyFirst:t=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}function sr(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(rs(),"")}k();function os(t){return Number.isInteger(t)?t>=4352&&(t<=4447||t===9001||t===9002||11904<=t&&t<=12871&&t!==12351||12880<=t&&t<=19903||19968<=t&&t<=42182||43360<=t&&t<=43388||44032<=t&&t<=55203||63744<=t&&t<=64255||65040<=t&&t<=65049||65072<=t&&t<=65131||65281<=t&&t<=65376||65504<=t&&t<=65510||110592<=t&&t<=110593||127488<=t&&t<=127569||131072<=t&&t<=262141):!1}var ns=Zn(es(),1);function K(t){if(typeof t!="string"||t.length===0||(t=sr(t),t.length===0))return 0;t=t.replace((0,ns.default)()," ");let e=0;for(let r=0;r<t.length;r++){let o=t.codePointAt(r);o<=31||o>=127&&o<=159||o>=768&&o<=879||(o>65535&&r++,e+=os(o)?2:1)}return e}var ir=t=>Math.max(...t.split(`
3
+ `).map(K)),ss=t=>{let e=[];for(let r of t){let{length:o}=r,n=o-e.length;for(let s=0;s<n;s+=1)e.push(0);for(let s=0;s<o;s+=1){let i=ir(r[s]);i>e[s]&&(e[s]=i)}}return e};k();var ur=/^\d+%$/,ar={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},is=(t,e)=>{var r;let o=[];for(let n=0;n<t.length;n+=1){let s=(r=e[n])!=null?r:"auto";if(typeof s=="number"||s==="auto"||s==="content-width"||typeof s=="string"&&ur.test(s)){o.push(Xe(Be({},ar),{width:s,contentWidth:t[n]}));continue}if(s&&typeof s=="object"){let i=Xe(Be(Be({},ar),s),{contentWidth:t[n]});i.horizontalPadding=i.paddingLeft+i.paddingRight,o.push(i);continue}throw new Error(`Invalid column width: ${JSON.stringify(s)}`)}return o};function us(t,e){for(let r of t){let{width:o}=r;if(o==="content-width"&&(r.width=r.contentWidth),o==="auto"){let a=Math.min(20,r.contentWidth);r.width=a,r.autoOverflow=r.contentWidth-a}if(typeof o=="string"&&ur.test(o)){let a=Number.parseFloat(o.slice(0,-1))/100;r.width=Math.floor(e*a)-(r.paddingLeft+r.paddingRight)}let{horizontalPadding:n}=r,s=1,i=s+n;if(i>=e){let a=i-e,l=Math.ceil(r.paddingLeft/n*a),m=a-l;r.paddingLeft-=l,r.paddingRight-=m,r.horizontalPadding=r.paddingLeft+r.paddingRight}r.paddingLeftString=r.paddingLeft?" ".repeat(r.paddingLeft):"",r.paddingRightString=r.paddingRight?" ".repeat(r.paddingRight):"";let u=e-r.horizontalPadding;r.width=Math.max(Math.min(r.width,u),s)}}var cr=()=>Object.assign([],{columns:0});function as(t,e){let r=[cr()],[o]=r;for(let n of t){let s=n.width+n.horizontalPadding;o.columns+s>e&&(o=cr(),r.push(o)),o.push(n),o.columns+=s}for(let n of r){let s=n.reduce((D,d)=>D+d.width+d.horizontalPadding,0),i=e-s;if(i===0)continue;let u=n.filter(D=>"autoOverflow"in D),a=u.filter(D=>D.autoOverflow>0),l=a.reduce((D,d)=>D+d.autoOverflow,0),m=Math.min(l,i);for(let D of a){let d=Math.floor(D.autoOverflow/l*m);D.width+=d,i-=d}let c=Math.floor(i/u.length);for(let D=0;D<u.length;D+=1){let d=u[D];D===u.length-1?d.width+=i:d.width+=c,i-=c}}return r}function cs(t,e,r){let o=is(r,e);return us(o,t),as(o,t)}k(),k(),k();var Qe=10,lr=(t=0)=>e=>`\x1B[${e+t}m`,Dr=(t=0)=>e=>`\x1B[${38+t};5;${e}m`,mr=(t=0)=>(e,r,o)=>`\x1B[${38+t};2;${e};${r};${o}m`;function ls(){let t=new Map,e={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]}};e.color.gray=e.color.blackBright,e.bgColor.bgGray=e.bgColor.bgBlackBright,e.color.grey=e.color.blackBright,e.bgColor.bgGrey=e.bgColor.bgBlackBright;for(let[r,o]of Object.entries(e)){for(let[n,s]of Object.entries(o))e[n]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},o[n]=e[n],t.set(s[0],s[1]);Object.defineProperty(e,r,{value:o,enumerable:!1})}return Object.defineProperty(e,"codes",{value:t,enumerable:!1}),e.color.close="\x1B[39m",e.bgColor.close="\x1B[49m",e.color.ansi=lr(),e.color.ansi256=Dr(),e.color.ansi16m=mr(),e.bgColor.ansi=lr(Qe),e.bgColor.ansi256=Dr(Qe),e.bgColor.ansi16m=mr(Qe),Object.defineProperties(e,{rgbToAnsi256:{value:(r,o,n)=>r===o&&o===n?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(o/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:r=>{let o=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!o)return[0,0,0];let{colorString:n}=o.groups;n.length===3&&(n=n.split("").map(i=>i+i).join(""));let s=Number.parseInt(n,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:r=>e.rgbToAnsi256(...e.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value:r=>{if(r<8)return 30+r;if(r<16)return 90+(r-8);let o,n,s;if(r>=232)o=((r-232)*10+8)/255,n=o,s=o;else{r-=16;let a=r%36;o=Math.floor(r/36)/5,n=Math.floor(a/6)/5,s=a%6/5}let i=Math.max(o,n,s)*2;if(i===0)return 30;let u=30+(Math.round(s)<<2|Math.round(n)<<1|Math.round(o));return i===2&&(u+=60),u},enumerable:!1},rgbToAnsi:{value:(r,o,n)=>e.ansi256ToAnsi(e.rgbToAnsi256(r,o,n)),enumerable:!1},hexToAnsi:{value:r=>e.ansi256ToAnsi(e.hexToAnsi256(r)),enumerable:!1}}),e}var Ds=ls(),ms=Ds,xe=new Set(["\x1B","\x9B"]),ds=39,Ze="\x07",dr="[",ps="]",pr="m",et=`${ps}8;;`,fr=t=>`${xe.values().next().value}${dr}${t}${pr}`,hr=t=>`${xe.values().next().value}${et}${t}${Ze}`,fs=t=>t.split(" ").map(e=>K(e)),tt=(t,e,r)=>{let o=[...e],n=!1,s=!1,i=K(sr(t[t.length-1]));for(let[u,a]of o.entries()){let l=K(a);if(i+l<=r?t[t.length-1]+=a:(t.push(a),i=0),xe.has(a)&&(n=!0,s=o.slice(u+1).join("").startsWith(et)),n){s?a===Ze&&(n=!1,s=!1):a===pr&&(n=!1);continue}i+=l,i===r&&u<o.length-1&&(t.push(""),i=0)}!i&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},hs=t=>{let e=t.split(" "),r=e.length;for(;r>0&&!(K(e[r-1])>0);)r--;return r===e.length?t:e.slice(0,r).join(" ")+e.slice(r).join("")},gs=(t,e,r={})=>{if(r.trim!==!1&&t.trim()==="")return"";let o="",n,s,i=fs(t),u=[""];for(let[l,m]of t.split(" ").entries()){r.trim!==!1&&(u[u.length-1]=u[u.length-1].trimStart());let c=K(u[u.length-1]);if(l!==0&&(c>=e&&(r.wordWrap===!1||r.trim===!1)&&(u.push(""),c=0),(c>0||r.trim===!1)&&(u[u.length-1]+=" ",c++)),r.hard&&i[l]>e){let D=e-c,d=1+Math.floor((i[l]-D-1)/e);Math.floor((i[l]-1)/e)<d&&u.push(""),tt(u,m,e);continue}if(c+i[l]>e&&c>0&&i[l]>0){if(r.wordWrap===!1&&c<e){tt(u,m,e);continue}u.push("")}if(c+i[l]>e&&r.wordWrap===!1){tt(u,m,e);continue}u[u.length-1]+=m}r.trim!==!1&&(u=u.map(l=>hs(l)));let a=[...u.join(`
4
+ `)];for(let[l,m]of a.entries()){if(o+=m,xe.has(m)){let{groups:D}=new RegExp(`(?:\\${dr}(?<code>\\d+)m|\\${et}(?<uri>.*)${Ze})`).exec(a.slice(l).join(""))||{groups:{}};if(D.code!==void 0){let d=Number.parseFloat(D.code);n=d===ds?void 0:d}else D.uri!==void 0&&(s=D.uri.length===0?void 0:D.uri)}let c=ms.codes.get(Number(n));a[l+1]===`
5
+ `?(s&&(o+=hr("")),n&&c&&(o+=fr(c))):m===`
6
+ `&&(n&&c&&(o+=fr(n)),s&&(o+=hr(s)))}return o};function Cs(t,e,r){return String(t).normalize().replace(/\r\n/g,`
7
7
  `).split(`
8
- `).map(o=>Qn(o,t,r)).join(`
9
- `)}var hr=e=>Array.from({length:e}).fill("");function ts(e,t){let r=[],o=0;for(let n of e){let s=0,i=n.map(a=>{var D;let m=(D=t[o])!=null?D:"";o+=1,a.preprocess&&(m=a.preprocess(m)),sr(m)>a.width&&(m=es(m,a.width,{hard:!0}));let c=m.split(`
10
- `);if(a.postprocess){let{postprocess:l}=a;c=c.map((p,d)=>l.call(a,p,d))}return a.paddingTop&&c.unshift(...hr(a.paddingTop)),a.paddingBottom&&c.push(...hr(a.paddingBottom)),c.length>s&&(s=c.length),Ye($e({},a),{lines:c})}),u=[];for(let a=0;a<s;a+=1){let D=i.map(m=>{var c;let l=(c=m.lines[a])!=null?c:"",p=Number.isFinite(m.width)?" ".repeat(m.width-V(l)):"",d=m.paddingLeftString;return m.align==="right"&&(d+=p),d+=l,m.align==="left"&&(d+=p),d+m.paddingRightString}).join("");u.push(D)}r.push(u.join(`
8
+ `).map(o=>gs(o,e,r)).join(`
9
+ `)}var gr=t=>Array.from({length:t}).fill("");function Es(t,e){let r=[],o=0;for(let n of t){let s=0,i=n.map(a=>{var l;let m=(l=e[o])!=null?l:"";o+=1,a.preprocess&&(m=a.preprocess(m)),ir(m)>a.width&&(m=Cs(m,a.width,{hard:!0}));let c=m.split(`
10
+ `);if(a.postprocess){let{postprocess:D}=a;c=c.map((d,f)=>D.call(a,d,f))}return a.paddingTop&&c.unshift(...gr(a.paddingTop)),a.paddingBottom&&c.push(...gr(a.paddingBottom)),c.length>s&&(s=c.length),Xe(Be({},a),{lines:c})}),u=[];for(let a=0;a<s;a+=1){let l=i.map(m=>{var c;let D=(c=m.lines[a])!=null?c:"",d=Number.isFinite(m.width)?" ".repeat(m.width-K(D)):"",f=m.paddingLeftString;return m.align==="right"&&(f+=d),f+=D,m.align==="left"&&(f+=d),f+m.paddingRightString}).join("");u.push(l)}r.push(u.join(`
11
11
  `))}return r.join(`
12
- `)}function rs(e,t){if(!e||e.length===0)return"";let r=Gn(e),o=r.length;if(o===0)return"";let{stdoutColumns:n,columns:s}=Nn(t);if(s.length>o)throw new Error(`${s.length} columns defined, but only ${o} columns found`);let i=zn(n,s,r);return e.map(u=>ts(i,u)).join(`
13
- `)}S();var os=["<",">","=",">=","<="];function ns(e){if(!os.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)}function ss(e){let t=Object.keys(e).map(r=>{let[o,n]=r.split(" ");ns(o);let s=Number.parseInt(n,10);if(Number.isNaN(s))throw new TypeError(`Invalid breakpoint value: ${n}`);let i=e[r];return{operator:o,breakpoint:s,value:i}}).sort((r,o)=>o.breakpoint-r.breakpoint);return r=>{var o;return(o=t.find(({operator:n,breakpoint:s})=>n==="="&&r===s||n===">"&&r>s||n==="<"&&r<s||n===">="&&r>=s||n==="<="&&r<=s))==null?void 0:o.value}}const is=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,r)=>r?r.toUpperCase():""),us=e=>e.replace(/\B([A-Z])/g,"-$1").toLowerCase(),as={"> 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 cs(e){let t=!1;return{type:"table",data:{tableData:Object.keys(e).sort((r,o)=>r.localeCompare(o)).map(r=>{const o=e[r],n="alias"in o;return n&&(t=!0),{name:r,flag:o,flagFormatted:`--${us(r)}`,aliasesEnabled:t,aliasFormatted:n?`-${o.alias}`:void 0}}).map(r=>(r.aliasesEnabled=t,[{type:"flagName",data:r},{type:"flagDescription",data:r}])),tableBreakpoints:as}}}const gr=e=>!e||(e.version??(e.help?e.help.version:void 0)),Cr=e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name};function Ds(e){const t=[];e.name&&t.push(Cr(e));const r=gr(e)??("parent"in e&&gr(e.parent));if(r&&t.push(`v${r}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
14
- `}}function ls(e){const{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
15
- `}}function ms(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 r=[],o=[Cr(e)];if(e.flags&&Object.keys(e.flags).length>0&&o.push("[flags...]"),e.parameters&&e.parameters.length>0){const{parameters:n}=e,s=n.indexOf("--"),i=s>-1&&n.slice(s+1).some(u=>u.startsWith("<"));o.push(n.map(u=>u!=="--"?u:i?"--":"[--]").join(" "))}if(o.length>1&&r.push(o.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 ps(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:cs(e.flags),indentBody:0}}}function ds(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 hs(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 gs=e=>[Ds,ls,ms,ps,fs,ds,hs].map(t=>t(e)).filter(Boolean),Cs=ze.WriteStream.prototype.hasColors();class Fs{text(t){return t}bold(t){return Cs?`\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:o=2}){return`${(t?`${this.heading(t)}
12
+ `)}function Fs(t,e){if(!t||t.length===0)return"";let r=ss(t),o=r.length;if(o===0)return"";let{stdoutColumns:n,columns:s}=ts(e);if(s.length>o)throw new Error(`${s.length} columns defined, but only ${o} columns found`);let i=cs(n,s,r);return t.map(u=>Es(i,u)).join(`
13
+ `)}k();var ys=["<",">","=",">=","<="];function ws(t){if(!ys.includes(t))throw new TypeError(`Invalid breakpoint operator: ${t}`)}function vs(t){let e=Object.keys(t).map(r=>{let[o,n]=r.split(" ");ws(o);let s=Number.parseInt(n,10);if(Number.isNaN(s))throw new TypeError(`Invalid breakpoint value: ${n}`);let i=t[r];return{operator:o,breakpoint:s,value:i}}).sort((r,o)=>o.breakpoint-r.breakpoint);return r=>{var o;return(o=e.find(({operator:n,breakpoint:s})=>n==="="&&r===s||n===">"&&r>s||n==="<"&&r<s||n===">="&&r>=s||n==="<="&&r<=s))==null?void 0:o.value}}const bs=t=>t.replace(/[\W_]([a-z\d])?/gi,(e,r)=>r?r.toUpperCase():""),$s=t=>t.replace(/\B([A-Z])/g,"-$1").toLowerCase(),As={"> 80":[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"auto"}],"> 40":[{width:"auto",paddingLeft:2,paddingRight:8,preprocess:t=>t.trim()},{width:"100%",paddingLeft:2,paddingBottom:1}],"> 0":{stdoutColumns:1e3,columns:[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"content-width"}]}};function Ps(t){let e=!1;return{type:"table",data:{tableData:Object.keys(t).sort((r,o)=>r.localeCompare(o)).map(r=>{const o=t[r],n="alias"in o;return n&&(e=!0),{name:r,flag:o,flagFormatted:`--${$s(r)}`,aliasesEnabled:e,aliasFormatted:n?`-${o.alias}`:void 0}}).map(r=>(r.aliasesEnabled=e,[{type:"flagName",data:r},{type:"flagDescription",data:r}])),tableBreakpoints:As}}}const Cr=t=>!t||(t.version??(t.help?t.help.version:void 0)),Er=t=>{const e="parent"in t&&t.parent?.name;return(e?`${e} `:"")+t.name};function Bs(t){const e=[];t.name&&e.push(Er(t));const r=Cr(t)??("parent"in t&&Cr(t.parent));if(r&&e.push(`v${r}`),e.length!==0)return{id:"name",type:"text",data:`${e.join(" ")}
14
+ `}}function xs(t){const{help:e}=t;if(!(!e||!e.description))return{id:"description",type:"text",data:`${e.description}
15
+ `}}function Ss(t){const e=t.help||{};if("usage"in e)return e.usage?{id:"usage",type:"section",data:{title:"Usage:",body:Array.isArray(e.usage)?e.usage.join(`
16
+ `):e.usage}}:void 0;if(t.name){const r=[],o=[Er(t)];if(t.flags&&Object.keys(t.flags).length>0&&o.push("[flags...]"),t.parameters&&t.parameters.length>0){const{parameters:n}=t,s=n.indexOf("--"),i=s>-1&&n.slice(s+1).some(u=>u.startsWith("<"));o.push(n.map(u=>u!=="--"?u:i?"--":"[--]").join(" "))}if(o.length>1&&r.push(o.join(" ")),"commands"in t&&t.commands?.length&&r.push(`${t.name} <command>`),r.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:r.join(`
17
+ `)}}}}function Ms(t){return!("commands"in t)||!t.commands?.length?void 0:{id:"commands",type:"section",data:{title:"Commands:",body:{type:"table",data:{tableData:t.commands.map(e=>[e.options.name,e.options.help?e.options.help.description:""]),tableOptions:[{width:"content-width",paddingLeft:2,paddingRight:8}]}},indentBody:0}}}function Os(t){if(!(!t.flags||Object.keys(t.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:Ps(t.flags),indentBody:0}}}function Rs(t){const{help:e}=t;if(!e||!e.examples||e.examples.length===0)return;let{examples:r}=e;if(Array.isArray(r)&&(r=r.join(`
18
+ `)),r)return{id:"examples",type:"section",data:{title:"Examples:",body:r}}}function Is(t){if(!("alias"in t)||!t.alias)return;const{alias:e}=t;return{id:"aliases",type:"section",data:{title:"Aliases:",body:Array.isArray(e)?e.join(", "):e}}}const ks=t=>[Bs,xs,Ss,Ms,Os,Rs,Is].map(e=>e(t)).filter(Boolean),Ns=Ve.WriteStream.prototype.hasColors();class Ls{text(e){return e}bold(e){return Ns?`\x1B[1m${e}\x1B[22m`:e.toLocaleUpperCase()}indentText({text:e,spaces:r}){return e.replace(/^/gm," ".repeat(r))}heading(e){return this.bold(e)}section({title:e,body:r,indentBody:o=2}){return`${(e?`${this.heading(e)}
19
19
  `:"")+(r?this.indentText({text:this.render(r),spaces:o}):"")}
20
- `}table({tableData:t,tableOptions:r,tableBreakpoints:o}){return rs(t.map(n=>n.map(s=>this.render(s))),o?ss(o):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:o,aliasesEnabled:n,aliasFormatted:s}=t;let i="";if(s?i+=`${s}, `:n&&(i+=" "),i+=o,"placeholder"in r&&typeof r.placeholder=="string")i+=`${this.flagOperator(t)}${r.placeholder}`;else{const u=this.flagParameter("type"in r?r.type:r);u&&(i+=`${this.flagOperator(t)}${u}`)}return i}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let r="description"in t?t.description??"":"";if("default"in t){let{default:o}=t;typeof o=="function"&&(o=o()),o&&(r+=` (default: ${this.flagDefault(o)})`)}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 tt=/^[\w.-]+$/,{stringify:q}=JSON,ys=/[|\\{}()[\]^$+*?.]/;function rt(e){const t=[];let r,o;for(const n of e){if(o)throw new Error(`Invalid parameter: Spread parameter ${q(o)} must be last`);const s=n[0],i=n[n.length-1];let u;if(s==="<"&&i===">"&&(u=!0,r))throw new Error(`Invalid parameter: Required parameter ${q(n)} cannot come after optional parameter ${q(r)}`);if(s==="["&&i==="]"&&(u=!1,r=n),u===void 0)throw new Error(`Invalid parameter: ${q(n)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=n.slice(1,-1);const D=a.slice(-3)==="...";D&&(o=n,a=a.slice(0,-3));const m=a.match(ys);if(m)throw new Error(`Invalid parameter: ${q(n)}. Invalid character found ${q(m[0])}`);t.push({name:a,required:u,spread:D})}return t}function ot(e,t,r,o){for(let n=0;n<t.length;n+=1){const{name:s,required:i,spread:u}=t[n],a=is(s);if(a in e)throw new Error(`Invalid parameter: ${q(s)} is used more than once.`);const D=u?r.slice(n):r[n];if(u&&(n=t.length),i&&(!D||u&&D.length===0))return console.error(`Error: Missing required parameter ${q(s)}
22
- `),o(),process.exit(1);e[a]=D}}function Es(e){return e===void 0||e!==!1}function Fr(e,t,r,o){const n={...t.flags},s=t.version;s&&(n.version={type:Boolean,description:"Show version"});const{help:i}=t,u=Es(i);u&&!("help"in n)&&(n.help={type:Boolean,alias:"h",description:"Show help"});const a=wn(n,o,{ignore:t.ignoreArgv}),D=()=>{console.log(t.version)};if(s&&a.flags.version===!0)return D(),process.exit(0);const m=new Fs,c=u&&i?.render?i.render:d=>m.render(d),l=d=>{const h=gs({...t,...d?{help:d}:{},flags:n});console.log(c(h,m))};if(u&&a.flags.help===!0)return l(),process.exit(0);if(t.parameters){let{parameters:d}=t,h=a._;const g=d.indexOf("--"),E=d.slice(g+1),A=Object.create(null);if(g>-1&&E.length>0){d=d.slice(0,g);const v=a._["--"];h=h.slice(0,-v.length||void 0),ot(A,rt(d),h,l),ot(A,rt(E),v,l)}else ot(A,rt(d),h,l);Object.assign(a._,A)}const p={...a,showVersion:D,showHelp:l};return typeof r=="function"&&r(p),{command:e,...p}}function bs(e,t){const r=new Map;for(const o of t){const n=[o.options.name],{alias:s}=o.options;s&&(Array.isArray(s)?n.push(...s):n.push(s));for(const i of n){if(r.has(i))throw new Error(`Duplicate command name found: ${q(i)}`);r.set(i,o)}}return r.get(e)}function ws(e,t,r=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!tt.test(e.name)))throw new Error(`Invalid script name: ${q(e.name)}`);const o=r[0];if(e.commands&&tt.test(o)){const n=bs(o,e.commands);if(n)return Fr(n.options.name,{...n.options,parent:e},n.callback,r.slice(1))}return Fr(void 0,e,t,r)}function nt(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(!tt.test(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:e,callback:t}}var As=Bo(import.meta.url),$=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Z(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Q={exports:{}},st,yr;function $s(){if(yr)return st;yr=1,st=o,o.sync=n;var e=W;function t(s,i){var u=i.pathExt!==void 0?i.pathExt:process.env.PATHEXT;if(!u||(u=u.split(";"),u.indexOf("")!==-1))return!0;for(var a=0;a<u.length;a++){var D=u[a].toLowerCase();if(D&&s.substr(-D.length).toLowerCase()===D)return!0}return!1}function r(s,i,u){return!s.isSymbolicLink()&&!s.isFile()?!1:t(i,u)}function o(s,i,u){e.stat(s,function(a,D){u(a,a?!1:r(D,s,i))})}function n(s,i){return r(e.statSync(s),s,i)}return st}var it,Er;function vs(){if(Er)return it;Er=1,it=t,t.sync=r;var e=W;function t(s,i,u){e.stat(s,function(a,D){u(a,a?!1:o(D,i))})}function r(s,i){return o(e.statSync(s),i)}function o(s,i){return s.isFile()&&n(s,i)}function n(s,i){var u=s.mode,a=s.uid,D=s.gid,m=i.uid!==void 0?i.uid:process.getuid&&process.getuid(),c=i.gid!==void 0?i.gid:process.getgid&&process.getgid(),l=parseInt("100",8),p=parseInt("010",8),d=parseInt("001",8),h=l|p,g=u&d||u&p&&D===c||u&l&&a===m||u&h&&m===0;return g}return it}var Be;process.platform==="win32"||$.TESTING_WINDOWS?Be=$s():Be=vs();var Bs=ut;ut.sync=xs;function ut(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(o,n){ut(e,t||{},function(s,i){s?n(s):o(i)})})}Be(e,t||{},function(o,n){o&&(o.code==="EACCES"||t&&t.ignoreErrors)&&(o=null,n=!1),r(o,n)})}function xs(e,t){try{return Be.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}const ee=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",br=L,Ps=ee?";":":",wr=Bs,Ar=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),$r=(e,t)=>{const r=t.colon||Ps,o=e.match(/\//)||ee&&e.match(/\\/)?[""]:[...ee?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],n=ee?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=ee?n.split(r):[""];return ee&&e.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:o,pathExt:s,pathExtExe:n}},vr=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});const{pathEnv:o,pathExt:n,pathExtExe:s}=$r(e,t),i=[],u=D=>new Promise((m,c)=>{if(D===o.length)return t.all&&i.length?m(i):c(Ar(e));const l=o[D],p=/^".*"$/.test(l)?l.slice(1,-1):l,d=br.join(p,e),h=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;m(a(h,D,0))}),a=(D,m,c)=>new Promise((l,p)=>{if(c===n.length)return l(u(m+1));const d=n[c];wr(D+d,{pathExt:s},(h,g)=>{if(!h&&g)if(t.all)i.push(D+d);else return l(D+d);return l(a(D,m,c+1))})});return r?u(0).then(D=>r(null,D),r):u(0)},Ss=(e,t)=>{t=t||{};const{pathEnv:r,pathExt:o,pathExtExe:n}=$r(e,t),s=[];for(let i=0;i<r.length;i++){const u=r[i],a=/^".*"$/.test(u)?u.slice(1,-1):u,D=br.join(a,e),m=!a&&/^\.[\\\/]/.test(e)?e.slice(0,2)+D:D;for(let c=0;c<o.length;c++){const l=m+o[c];try{if(wr.sync(l,{pathExt:n}))if(t.all)s.push(l);else return l}catch{}}}if(t.all&&s.length)return s;if(t.nothrow)return null;throw Ar(e)};var Os=vr;vr.sync=Ss;var at={exports:{}};const Br=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(o=>o.toUpperCase()==="PATH")||"Path"};at.exports=Br,at.exports.default=Br;var Ms=at.exports;const xr=L,Is=Os,Ts=Ms;function Pr(e,t){const r=e.options.env||process.env,o=process.cwd(),n=e.options.cwd!=null,s=n&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(e.options.cwd)}catch{}let i;try{i=Is.sync(e.command,{path:r[Ts({env:r})],pathExt:t?xr.delimiter:void 0})}catch{}finally{s&&process.chdir(o)}return i&&(i=xr.resolve(n?e.options.cwd:"",i)),i}function ks(e){return Pr(e)||Pr(e,!0)}var Ls=ks,ct={};const Dt=/([()\][%!^"`<>&|;, *?])/g;function Ns(e){return e=e.replace(Dt,"^$1"),e}function Rs(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(Dt,"^$1"),t&&(e=e.replace(Dt,"^$1")),e}ct.command=Ns,ct.argument=Rs;var _s=/^#!(.*)/;const js=_s;var Gs=(e="")=>{const t=e.match(js);if(!t)return null;const[r,o]=t[0].replace(/#! ?/,"").split(" "),n=r.split("/").pop();return n==="env"?o:o?`${n} ${o}`:n};const lt=W,Hs=Gs;function Us(e){const r=Buffer.alloc(150);let o;try{o=lt.openSync(e,"r"),lt.readSync(o,r,0,150,0),lt.closeSync(o)}catch{}return Hs(r.toString())}var qs=Us;const zs=L,Sr=Ls,Or=ct,Ws=qs,Ks=process.platform==="win32",Vs=/\.(?:com|exe)$/i,Js=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Ys(e){e.file=Sr(e);const t=e.file&&Ws(e.file);return t?(e.args.unshift(e.file),e.command=t,Sr(e)):e.file}function Xs(e){if(!Ks)return e;const t=Ys(e),r=!Vs.test(t);if(e.options.forceShell||r){const o=Js.test(t);e.command=zs.normalize(e.command),e.command=Or.command(e.command),e.args=e.args.map(s=>Or.argument(s,o));const n=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${n}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function Zs(e,t,r){t&&!Array.isArray(t)&&(r=t,t=null),t=t?t.slice(0):[],r=Object.assign({},r);const o={command:e,args:t,options:r,file:void 0,original:{command:e,args:t}};return r.shell?o:Xs(o)}var Qs=Zs;const mt=process.platform==="win32";function pt(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 ei(e,t){if(!mt)return;const r=e.emit;e.emit=function(o,n){if(o==="exit"){const s=Mr(n,t);if(s)return r.call(e,"error",s)}return r.apply(e,arguments)}}function Mr(e,t){return mt&&e===1&&!t.file?pt(t.original,"spawn"):null}function ti(e,t){return mt&&e===1&&!t.file?pt(t.original,"spawnSync"):null}var ri={hookChildProcess:ei,verifyENOENT:Mr,verifyENOENTSync:ti,notFoundError:pt};const Ir=So,ft=Qs,dt=ri;function Tr(e,t,r){const o=ft(e,t,r),n=Ir.spawn(o.command,o.args,o.options);return dt.hookChildProcess(n,o),n}function oi(e,t,r){const o=ft(e,t,r),n=Ir.spawnSync(o.command,o.args,o.options);return n.error=n.error||dt.verifyENOENTSync(n.status,o),n}Q.exports=Tr,Q.exports.spawn=Tr,Q.exports.sync=oi,Q.exports._parse=ft,Q.exports._enoent=dt;var ni=Q.exports,si=Z(ni);function ii(e){const t=typeof e=="string"?`
20
+ `}table({tableData:e,tableOptions:r,tableBreakpoints:o}){return Fs(e.map(n=>n.map(s=>this.render(s))),o?vs(o):r)}flagParameter(e){return e===Boolean?"":e===String?"<string>":e===Number?"<number>":Array.isArray(e)?this.flagParameter(e[0]):"<value>"}flagOperator(e){return" "}flagName(e){const{flag:r,flagFormatted:o,aliasesEnabled:n,aliasFormatted:s}=e;let i="";if(s?i+=`${s}, `:n&&(i+=" "),i+=o,"placeholder"in r&&typeof r.placeholder=="string")i+=`${this.flagOperator(e)}${r.placeholder}`;else{const u=this.flagParameter("type"in r?r.type:r);u&&(i+=`${this.flagOperator(e)}${u}`)}return i}flagDefault(e){return JSON.stringify(e)}flagDescription({flag:e}){let r="description"in e?e.description??"":"";if("default"in e){let{default:o}=e;typeof o=="function"&&(o=o()),o&&(r+=` (default: ${this.flagDefault(o)})`)}return r}render(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(r=>this.render(r)).join(`
21
+ `);if("type"in e&&this[e.type]){const r=this[e.type];if(typeof r=="function")return r.call(this,e.data)}throw new Error(`Invalid node type: ${JSON.stringify(e)}`)}}const rt=/^[\w.-]+$/,{stringify:z}=JSON,Ts=/[|\\{}()[\]^$+*?.]/;function ot(t){const e=[];let r,o;for(const n of t){if(o)throw new Error(`Invalid parameter: Spread parameter ${z(o)} must be last`);const s=n[0],i=n[n.length-1];let u;if(s==="<"&&i===">"&&(u=!0,r))throw new Error(`Invalid parameter: Required parameter ${z(n)} cannot come after optional parameter ${z(r)}`);if(s==="["&&i==="]"&&(u=!1,r=n),u===void 0)throw new Error(`Invalid parameter: ${z(n)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=n.slice(1,-1);const l=a.slice(-3)==="...";l&&(o=n,a=a.slice(0,-3));const m=a.match(Ts);if(m)throw new Error(`Invalid parameter: ${z(n)}. Invalid character found ${z(m[0])}`);e.push({name:a,required:u,spread:l})}return e}function nt(t,e,r,o){for(let n=0;n<e.length;n+=1){const{name:s,required:i,spread:u}=e[n],a=bs(s);if(a in t)throw new Error(`Invalid parameter: ${z(s)} is used more than once.`);const l=u?r.slice(n):r[n];if(u&&(n=e.length),i&&(!l||u&&l.length===0))return console.error(`Error: Missing required parameter ${z(s)}
22
+ `),o(),process.exit(1);t[a]=l}}function _s(t){return t===void 0||t!==!1}function Fr(t,e,r,o){const n={...e.flags},s=e.version;s&&(n.version={type:Boolean,description:"Show version"});const{help:i}=e,u=_s(i);u&&!("help"in n)&&(n.help={type:Boolean,alias:"h",description:"Show help"});const a=Gn(n,o,{ignore:e.ignoreArgv}),l=()=>{console.log(e.version)};if(s&&a.flags.version===!0)return l(),process.exit(0);const m=new Ls,c=u&&i?.render?i.render:f=>m.render(f),D=f=>{const h=ks({...e,...f?{help:f}:{},flags:n});console.log(c(h,m))};if(u&&a.flags.help===!0)return D(),process.exit(0);if(e.parameters){let{parameters:f}=e,h=a._;const g=f.indexOf("--"),E=f.slice(g+1),F=Object.create(null);if(g>-1&&E.length>0){f=f.slice(0,g);const O=a._["--"];h=h.slice(0,-O.length||void 0),nt(F,ot(f),h,D),nt(F,ot(E),O,D)}else nt(F,ot(f),h,D);Object.assign(a._,F)}const d={...a,showVersion:l,showHelp:D};return typeof r=="function"&&r(d),{command:t,...d}}function js(t,e){const r=new Map;for(const o of e){const n=[o.options.name],{alias:s}=o.options;s&&(Array.isArray(s)?n.push(...s):n.push(s));for(const i of n){if(r.has(i))throw new Error(`Duplicate command name found: ${z(i)}`);r.set(i,o)}}return r.get(t)}function Gs(t,e,r=process.argv.slice(2)){if(!t)throw new Error("Options is required");if("name"in t&&(!t.name||!rt.test(t.name)))throw new Error(`Invalid script name: ${z(t.name)}`);const o=r[0];if(t.commands&&rt.test(o)){const n=js(o,t.commands);if(n)return Fr(n.options.name,{...n.options,parent:t},n.callback,r.slice(1))}return Fr(void 0,t,e,r)}function st(t,e){if(!t)throw new Error("Command options are required");const{name:r}=t;if(t.name===void 0)throw new Error("Command name is required");if(!rt.test(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:t,callback:e}}var Hs=qo(import.meta.url),S=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Q(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Z={exports:{}},it,yr;function Us(){if(yr)return it;yr=1,it=o,o.sync=n;var t=T;function e(s,i){var u=i.pathExt!==void 0?i.pathExt:process.env.PATHEXT;if(!u||(u=u.split(";"),u.indexOf("")!==-1))return!0;for(var a=0;a<u.length;a++){var l=u[a].toLowerCase();if(l&&s.substr(-l.length).toLowerCase()===l)return!0}return!1}function r(s,i,u){return!s.isSymbolicLink()&&!s.isFile()?!1:e(i,u)}function o(s,i,u){t.stat(s,function(a,l){u(a,a?!1:r(l,s,i))})}function n(s,i){return r(t.statSync(s),s,i)}return it}var ut,wr;function zs(){if(wr)return ut;wr=1,ut=e,e.sync=r;var t=T;function e(s,i,u){t.stat(s,function(a,l){u(a,a?!1:o(l,i))})}function r(s,i){return o(t.statSync(s),i)}function o(s,i){return s.isFile()&&n(s,i)}function n(s,i){var u=s.mode,a=s.uid,l=s.gid,m=i.uid!==void 0?i.uid:process.getuid&&process.getuid(),c=i.gid!==void 0?i.gid:process.getgid&&process.getgid(),D=parseInt("100",8),d=parseInt("010",8),f=parseInt("001",8),h=D|d,g=u&f||u&d&&l===c||u&D&&a===m||u&h&&m===0;return g}return ut}var Se;process.platform==="win32"||S.TESTING_WINDOWS?Se=Us():Se=zs();var qs=at;at.sync=Ws;function at(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(o,n){at(t,e||{},function(s,i){s?n(s):o(i)})})}Se(t,e||{},function(o,n){o&&(o.code==="EACCES"||e&&e.ignoreErrors)&&(o=null,n=!1),r(o,n)})}function Ws(t,e){try{return Se.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}const ee=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",vr=N,Ks=ee?";":":",br=qs,$r=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),Ar=(t,e)=>{const r=e.colon||Ks,o=t.match(/\//)||ee&&t.match(/\\/)?[""]:[...ee?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],n=ee?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=ee?n.split(r):[""];return ee&&t.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:o,pathExt:s,pathExtExe:n}},Pr=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});const{pathEnv:o,pathExt:n,pathExtExe:s}=Ar(t,e),i=[],u=l=>new Promise((m,c)=>{if(l===o.length)return e.all&&i.length?m(i):c($r(t));const D=o[l],d=/^".*"$/.test(D)?D.slice(1,-1):D,f=vr.join(d,t),h=!d&&/^\.[\\\/]/.test(t)?t.slice(0,2)+f:f;m(a(h,l,0))}),a=(l,m,c)=>new Promise((D,d)=>{if(c===n.length)return D(u(m+1));const f=n[c];br(l+f,{pathExt:s},(h,g)=>{if(!h&&g)if(e.all)i.push(l+f);else return D(l+f);return D(a(l,m,c+1))})});return r?u(0).then(l=>r(null,l),r):u(0)},Vs=(t,e)=>{e=e||{};const{pathEnv:r,pathExt:o,pathExtExe:n}=Ar(t,e),s=[];for(let i=0;i<r.length;i++){const u=r[i],a=/^".*"$/.test(u)?u.slice(1,-1):u,l=vr.join(a,t),m=!a&&/^\.[\\\/]/.test(t)?t.slice(0,2)+l:l;for(let c=0;c<o.length;c++){const D=m+o[c];try{if(br.sync(D,{pathExt:n}))if(e.all)s.push(D);else return D}catch{}}}if(e.all&&s.length)return s;if(e.nothrow)return null;throw $r(t)};var Js=Pr;Pr.sync=Vs;var ct={exports:{}};const Br=(t={})=>{const e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(o=>o.toUpperCase()==="PATH")||"Path"};ct.exports=Br,ct.exports.default=Br;var Ys=ct.exports;const xr=N,Xs=Js,Qs=Ys;function Sr(t,e){const r=t.options.env||process.env,o=process.cwd(),n=t.options.cwd!=null,s=n&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(t.options.cwd)}catch{}let i;try{i=Xs.sync(t.command,{path:r[Qs({env:r})],pathExt:e?xr.delimiter:void 0})}catch{}finally{s&&process.chdir(o)}return i&&(i=xr.resolve(n?t.options.cwd:"",i)),i}function Zs(t){return Sr(t)||Sr(t,!0)}var ei=Zs,lt={};const Dt=/([()\][%!^"`<>&|;, *?])/g;function ti(t){return t=t.replace(Dt,"^$1"),t}function ri(t,e){return t=`${t}`,t=t.replace(/(\\*)"/g,'$1$1\\"'),t=t.replace(/(\\*)$/,"$1$1"),t=`"${t}"`,t=t.replace(Dt,"^$1"),e&&(t=t.replace(Dt,"^$1")),t}lt.command=ti,lt.argument=ri;var oi=/^#!(.*)/;const ni=oi;var si=(t="")=>{const e=t.match(ni);if(!e)return null;const[r,o]=e[0].replace(/#! ?/,"").split(" "),n=r.split("/").pop();return n==="env"?o:o?`${n} ${o}`:n};const mt=T,ii=si;function ui(t){const r=Buffer.alloc(150);let o;try{o=mt.openSync(t,"r"),mt.readSync(o,r,0,150,0),mt.closeSync(o)}catch{}return ii(r.toString())}var ai=ui;const ci=N,Mr=ei,Or=lt,li=ai,Di=process.platform==="win32",mi=/\.(?:com|exe)$/i,di=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function pi(t){t.file=Mr(t);const e=t.file&&li(t.file);return e?(t.args.unshift(t.file),t.command=e,Mr(t)):t.file}function fi(t){if(!Di)return t;const e=pi(t),r=!mi.test(e);if(t.options.forceShell||r){const o=di.test(e);t.command=ci.normalize(t.command),t.command=Or.command(t.command),t.args=t.args.map(s=>Or.argument(s,o));const n=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${n}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function hi(t,e,r){e&&!Array.isArray(e)&&(r=e,e=null),e=e?e.slice(0):[],r=Object.assign({},r);const o={command:t,args:e,options:r,file:void 0,original:{command:t,args:e}};return r.shell?o:fi(o)}var gi=hi;const dt=process.platform==="win32";function pt(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function Ci(t,e){if(!dt)return;const r=t.emit;t.emit=function(o,n){if(o==="exit"){const s=Rr(n,e);if(s)return r.call(t,"error",s)}return r.apply(t,arguments)}}function Rr(t,e){return dt&&t===1&&!e.file?pt(e.original,"spawn"):null}function Ei(t,e){return dt&&t===1&&!e.file?pt(e.original,"spawnSync"):null}var Fi={hookChildProcess:Ci,verifyENOENT:Rr,verifyENOENTSync:Ei,notFoundError:pt};const Ir=Vo,ft=gi,ht=Fi;function kr(t,e,r){const o=ft(t,e,r),n=Ir.spawn(o.command,o.args,o.options);return ht.hookChildProcess(n,o),n}function yi(t,e,r){const o=ft(t,e,r),n=Ir.spawnSync(o.command,o.args,o.options);return n.error=n.error||ht.verifyENOENTSync(n.status,o),n}Z.exports=kr,Z.exports.spawn=kr,Z.exports.sync=yi,Z.exports._parse=ft,Z.exports._enoent=ht;var wi=Z.exports,vi=Q(wi);function bi(t){const e=typeof t=="string"?`
23
23
  `:`
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 kr(e={}){const{env:t=process.env,platform:r=process.platform}=e;return r!=="win32"?"PATH":Object.keys(t).reverse().find(o=>o.toUpperCase()==="PATH")||"Path"}const ui=({cwd:e=U.cwd(),path:t=U.env[kr()],preferLocal:r=!0,execPath:o=U.execPath,addExecPath:n=!0}={})=>{const s=e instanceof URL?Kt(e):e,i=X.resolve(s),u=[];return r&&ai(u,i),n&&ci(u,o,i),[...u,t].join(X.delimiter)},ai=(e,t)=>{let r;for(;r!==t;)e.push(X.join(t,"node_modules/.bin")),r=t,t=X.resolve(t,"..")},ci=(e,t,r)=>{const o=t instanceof URL?Kt(t):t;e.push(X.resolve(r,o,".."))},Di=({env:e=U.env,...t}={})=>{e={...e};const r=kr({env:e});return t.path=e[r],e[r]=ui(t),e},li=(e,t,r,o)=>{if(r==="length"||r==="prototype"||r==="arguments"||r==="caller")return;const n=Object.getOwnPropertyDescriptor(e,r),s=Object.getOwnPropertyDescriptor(t,r);!mi(n,s)&&o||Object.defineProperty(e,r,s)},mi=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)},pi=(e,t)=>{const r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},fi=(e,t)=>`/* Wrapped ${e}*/
25
- ${t}`,di=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),hi=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),gi=(e,t,r)=>{const o=r===""?"":`with ${r.trim()}() `,n=fi.bind(null,o,t.toString());Object.defineProperty(n,"name",hi),Object.defineProperty(e,"toString",{...di,value:n})};function Ci(e,t,{ignoreNonConfigurable:r=!1}={}){const{name:o}=e;for(const n of Reflect.ownKeys(t))li(e,t,n,r);return pi(e,t),gi(e,t,o),e}const xe=new WeakMap,Lr=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let r,o=0;const n=e.displayName||e.name||"<anonymous>",s=function(...i){if(xe.set(s,++o),o===1)r=e.apply(this,i),e=null;else if(t.throw===!0)throw new Error(`Function \`${n}\` can only be called once`);return r};return Ci(s,e),xe.set(s,o),s};Lr.callCount=e=>{if(!xe.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return xe.get(e)};const Fi=()=>{const e=Rr-Nr+1;return Array.from({length:e},yi)},yi=(e,t)=>({name:`SIGRT${t+1}`,number:Nr+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Nr=34,Rr=64,Ei=[{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"}],_r=()=>{const e=Fi();return[...Ei,...e].map(bi)},bi=({name:e,number:t,description:r,action:o,forced:n=!1,standard:s})=>{const{signals:{[e]:i}}=Vt,u=i!==void 0;return{name:e,number:u?i:t,description:r,supported:u,action:o,forced:n,standard:s}},wi=()=>{const e=_r();return Object.fromEntries(e.map(Ai))},Ai=({name:e,number:t,description:r,supported:o,action:n,forced:s,standard:i})=>[e,{name:e,number:t,description:r,supported:o,action:n,forced:s,standard:i}],$i=wi(),vi=()=>{const e=_r(),t=Rr+1,r=Array.from({length:t},(o,n)=>Bi(n,e));return Object.assign({},...r)},Bi=(e,t)=>{const r=xi(e,t);if(r===void 0)return{};const{name:o,description:n,supported:s,action:i,forced:u,standard:a}=r;return{[e]:{name:o,number:e,description:n,supported:s,action:i,forced:u,standard:a}}},xi=(e,t)=>{const r=t.find(({name:o})=>Vt.signals[o]===e);return r!==void 0?r:t.find(o=>o.number===e)};vi();const Pi=({timedOut:e,timeout:t,errorCode:r,signal:o,signalDescription:n,exitCode:s,isCanceled:i})=>e?`timed out after ${t} milliseconds`:i?"was canceled":r!==void 0?`failed with ${r}`:o!==void 0?`was killed with ${o} (${n})`:s!==void 0?`failed with exit code ${s}`:"failed",jr=({stdout:e,stderr:t,all:r,error:o,signal:n,exitCode:s,command:i,escapedCommand:u,timedOut:a,isCanceled:D,killed:m,parsed:{options:{timeout:c,cwd:l=U.cwd()}}})=>{s=s===null?void 0:s,n=n===null?void 0:n;const p=n===void 0?void 0:$i[n].description,d=o&&o.code,g=`Command ${Pi({timedOut:a,timeout:c,errorCode:d,signal:n,signalDescription:p,exitCode:s,isCanceled:D})}: ${i}`,E=Object.prototype.toString.call(o)==="[object Error]",A=E?`${g}
26
- ${o.message}`:g,v=[A,t,e].filter(Boolean).join(`
27
- `);return E?(o.originalMessage=o.message,o.message=v):o=new Error(v),o.shortMessage=A,o.command=i,o.escapedCommand=u,o.exitCode=s,o.signal=n,o.signalDescription=p,o.stdout=e,o.stderr=t,o.cwd=l,r!==void 0&&(o.all=r),"bufferedData"in o&&delete o.bufferedData,o.failed=!0,o.timedOut=!!a,o.isCanceled=D,o.killed=m&&!a,o},Pe=["stdin","stdout","stderr"],Si=e=>Pe.some(t=>e[t]!==void 0),Oi=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return Pe.map(o=>e[o]);if(Si(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Pe.map(o=>`\`${o}\``).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,Pe.length);return Array.from({length:r},(o,n)=>t[n])};var te={exports:{}},Se={exports:{}};Se.exports;var Gr;function Mi(){return Gr||(Gr=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")}(Se)),Se.exports}var b=$.process;const J=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(!J(b))te.exports=function(){return function(){}};else{var Ii=Jt,De=Mi(),Ti=/^win/i.test(b.platform),Oe=Yt;typeof Oe!="function"&&(Oe=Oe.EventEmitter);var B;b.__signal_exit_emitter__?B=b.__signal_exit_emitter__:(B=b.__signal_exit_emitter__=new Oe,B.count=0,B.emitted={}),B.infinite||(B.setMaxListeners(1/0),B.infinite=!0),te.exports=function(e,t){if(!J($.process))return function(){};Ii.equal(typeof e,"function","a callback must be provided for exit handler"),le===!1&&Hr();var r="exit";t&&t.alwaysLast&&(r="afterexit");var o=function(){B.removeListener(r,e),B.listeners("exit").length===0&&B.listeners("afterexit").length===0&&ht()};return B.on(r,e),o};var ht=function(){!le||!J($.process)||(le=!1,De.forEach(function(t){try{b.removeListener(t,gt[t])}catch{}}),b.emit=Ct,b.reallyExit=Ur,B.count-=1)};te.exports.unload=ht;var re=function(t,r,o){B.emitted[t]||(B.emitted[t]=!0,B.emit(t,r,o))},gt={};De.forEach(function(e){gt[e]=function(){if(J($.process)){var r=b.listeners(e);r.length===B.count&&(ht(),re("exit",null,e),re("afterexit",null,e),Ti&&e==="SIGHUP"&&(e="SIGINT"),b.kill(b.pid,e))}}}),te.exports.signals=function(){return De};var le=!1,Hr=function(){le||!J($.process)||(le=!0,B.count+=1,De=De.filter(function(t){try{return b.on(t,gt[t]),!0}catch{return!1}}),b.emit=Li,b.reallyExit=ki)};te.exports.load=Hr;var Ur=b.reallyExit,ki=function(t){J($.process)&&(b.exitCode=t||0,re("exit",b.exitCode,null),re("afterexit",b.exitCode,null),Ur.call(b,b.exitCode))},Ct=b.emit,Li=function(t,r){if(t==="exit"&&J($.process)){r!==void 0&&(b.exitCode=r);var o=Ct.apply(this,arguments);return re("exit",b.exitCode,null),re("afterexit",b.exitCode,null),o}else return Ct.apply(this,arguments)}}var Ni=te.exports,Ri=Z(Ni);const _i=1e3*5,ji=(e,t="SIGTERM",r={})=>{const o=e(t);return Gi(e,t,r,o),o},Gi=(e,t,r,o)=>{if(!Hi(t,r,o))return;const n=qi(r),s=setTimeout(()=>{e("SIGKILL")},n);s.unref&&s.unref()},Hi=(e,{forceKillAfterTimeout:t},r)=>Ui(e)&&t!==!1&&r,Ui=e=>e===Oo.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",qi=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return _i;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},zi=(e,t)=>{e.kill()&&(t.isCanceled=!0)},Wi=(e,t,r)=>{e.kill(t),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},Ki=(e,{timeout:t,killSignal:r="SIGTERM"},o)=>{if(t===0||t===void 0)return o;let n;const s=new Promise((u,a)=>{n=setTimeout(()=>{Wi(e,r,a)},t)}),i=o.finally(()=>{clearTimeout(n)});return Promise.race([s,i])},Vi=({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})`)},Ji=async(e,{cleanup:t,detached:r},o)=>{if(!t||r)return o;const n=Ri(()=>{e.kill()});return o.finally(()=>{n()})};function qr(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}function zr(e){return qr(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}const Yi=e=>e instanceof Po&&typeof e.then=="function",Ft=(e,t,r)=>{if(typeof r=="string")return e[t].pipe(Mo(r)),e;if(zr(r))return e[t].pipe(r),e;if(!Yi(r))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!zr(r.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(r.stdin),r},Xi=e=>{e.stdout!==null&&(e.pipeStdout=Ft.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=Ft.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=Ft.bind(void 0,e,"all"))};var me={exports:{}};const{PassThrough:Zi}=We;var Qi=e=>{e={...e};const{array:t}=e;let{encoding:r}=e;const o=r==="buffer";let n=!1;t?n=!(r||o):r=r||"utf8",o&&(r=null);const s=new Zi({objectMode:n});r&&s.setEncoding(r);let i=0;const u=[];return s.on("data",a=>{u.push(a),n?i=u.length:i+=a.length}),s.getBufferedValue=()=>t?u:o?Buffer.concat(u,i):u.join(""),s.getBufferedLength=()=>i,s};const{constants:eu}=To,tu=We,{promisify:ru}=Xt,ou=Qi,nu=ru(tu.pipeline);class Wr extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function yt(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:r}=t,o=ou(t);return await new Promise((n,s)=>{const i=u=>{u&&o.getBufferedLength()<=eu.MAX_LENGTH&&(u.bufferedData=o.getBufferedValue()),s(u)};(async()=>{try{await nu(e,o),n()}catch(u){i(u)}})(),o.on("data",()=>{o.getBufferedLength()>r&&i(new Wr)})}),o.getBufferedValue()}me.exports=yt,me.exports.buffer=(e,t)=>yt(e,{...t,encoding:"buffer"}),me.exports.array=(e,t)=>yt(e,{...t,array:!0}),me.exports.MaxBufferError=Wr;var su=me.exports,Kr=Z(su);const{PassThrough:iu}=We;var uu=function(){var e=[],t=new iu({objectMode:!0});return t.setMaxListeners(0),t.add=r,t.isEmpty=o,t.on("unpipe",n),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",n.bind(null,s)),s.once("error",t.emit.bind(t,"error")),s.pipe(t,{end:!1}),this)}function o(){return e.length==0}function n(s){e=e.filter(function(i){return i!==s}),!e.length&&t.readable&&t.end()}},au=Z(uu);const cu=e=>{if(e!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},Du=({input:e,inputFile:t})=>typeof t!="string"?e:(cu(e),Io(t)),lu=(e,t)=>{const r=Du(t);r!==void 0&&(qr(r)?r.pipe(e.stdin):e.stdin.end(r))},mu=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const r=au();return e.stdout&&r.add(e.stdout),e.stderr&&r.add(e.stderr),r},Et=async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(r){return r.bufferedData}}},bt=(e,{encoding:t,buffer:r,maxBuffer:o})=>{if(!(!e||!r))return t?Kr(e,{encoding:t,maxBuffer:o}):Kr.buffer(e,{maxBuffer:o})},pu=async({stdout:e,stderr:t,all:r},{encoding:o,buffer:n,maxBuffer:s},i)=>{const u=bt(e,{encoding:o,buffer:n,maxBuffer:s}),a=bt(t,{encoding:o,buffer:n,maxBuffer:s}),D=bt(r,{encoding:o,buffer:n,maxBuffer:s*2});try{return await Promise.all([i,u,a,D])}catch(m){return Promise.all([{error:m,signal:m.signal,timedOut:m.timedOut},Et(e,u),Et(t,a),Et(r,D)])}},fu=(async()=>{})().constructor.prototype,du=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(fu,e)]),Vr=(e,t)=>{for(const[r,o]of du){const n=typeof t=="function"?(...s)=>Reflect.apply(o.value,t(),s):o.value.bind(t);Reflect.defineProperty(e,r,{...o,value:n})}},hu=e=>new Promise((t,r)=>{e.on("exit",(o,n)=>{t({exitCode:o,signal:n})}),e.on("error",o=>{r(o)}),e.stdin&&e.stdin.on("error",o=>{r(o)})}),Jr=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],gu=/^[\w.-]+$/,Cu=/"/g,Fu=e=>typeof e!="string"||gu.test(e)?e:`"${e.replace(Cu,'\\"')}"`,yu=(e,t)=>Jr(e,t).join(" "),Eu=(e,t)=>Jr(e,t).map(r=>Fu(r)).join(" "),bu=ko("execa").enabled,Me=(e,t)=>String(e).padStart(t,"0"),wu=()=>{const e=new Date;return`${Me(e.getHours(),2)}:${Me(e.getMinutes(),2)}:${Me(e.getSeconds(),2)}.${Me(e.getMilliseconds(),3)}`},Au=(e,{verbose:t})=>{t&&U.stderr.write(`[${wu()}] ${e}
28
- `)},$u=1e3*1e3*100,vu=({env:e,extendEnv:t,preferLocal:r,localDir:o,execPath:n})=>{const s=t?{...U.env,...e}:e;return r?Di({env:s,cwd:o,execPath:n}):s},Bu=(e,t,r={})=>{const o=si._parse(e,t,r);return e=o.command,t=o.args,r=o.options,r={maxBuffer:$u,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||U.cwd(),execPath:U.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:bu,...r},r.env=vu(r),r.stdio=Oi(r),U.platform==="win32"&&X.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:r,parsed:o}},wt=(e,t,r)=>typeof t!="string"&&!xo.isBuffer(t)?r===void 0?void 0:"":e.stripFinalNewline?ii(t):t;function oe(e,t,r){const o=Bu(e,t,r),n=yu(e,t),s=Eu(e,t);Au(s,o.options),Vi(o.options);let i;try{i=Wt.spawn(o.file,o.args,o.options)}catch(p){const d=new Wt.ChildProcess,h=Promise.reject(jr({error:p,stdout:"",stderr:"",all:"",command:n,escapedCommand:s,parsed:o,timedOut:!1,isCanceled:!1,killed:!1}));return Vr(d,h),d}const u=hu(i),a=Ki(i,o.options,u),D=Ji(i,o.options,a),m={isCanceled:!1};i.kill=ji.bind(null,i.kill.bind(i)),i.cancel=zi.bind(null,i,m);const l=Lr(async()=>{const[{error:p,exitCode:d,signal:h,timedOut:g},E,A,v]=await pu(i,o.options,D),Y=wt(o.options,E),z=wt(o.options,A),w=wt(o.options,v);if(p||d!==0||h!==null){const x=jr({error:p,exitCode:d,signal:h,stdout:Y,stderr:z,all:w,command:n,escapedCommand:s,parsed:o,timedOut:g,isCanceled:m.isCanceled||(o.options.signal?o.options.signal.aborted:!1),killed:i.killed});if(!o.options.reject)return x;throw x}return{command:n,escapedCommand:s,exitCode:0,stdout:Y,stderr:z,all:w,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return lu(i,o.options),i.all=mu(i,o.options),Xi(i),Vr(i,l),i}class _{static create(t,r){return new t(r)}}class j{constructor(t){this.handleError$=r=>{let o="An error occurred";return r.message&&(o=r.message),O({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}parseMessage(t,r,o){try{const s=JSON.parse(t).map(i=>this.extractMessageAsType(i,r)).map(i=>({title:`${i.subject}`,value:`${i.subject}${i.body?`
24
+ `.charCodeAt(),r=typeof t=="string"?"\r":"\r".charCodeAt();return t[t.length-1]===e&&(t=t.slice(0,-1)),t[t.length-1]===r&&(t=t.slice(0,-1)),t}function Nr(t={}){const{env:e=process.env,platform:r=process.platform}=t;return r!=="win32"?"PATH":Object.keys(e).reverse().find(o=>o.toUpperCase()==="PATH")||"Path"}const $i=({cwd:t=U.cwd(),path:e=U.env[Nr()],preferLocal:r=!0,execPath:o=U.execPath,addExecPath:n=!0}={})=>{const s=t instanceof URL?Vt(t):t,i=X.resolve(s),u=[];return r&&Ai(u,i),n&&Pi(u,o,i),[...u,e].join(X.delimiter)},Ai=(t,e)=>{let r;for(;r!==e;)t.push(X.join(e,"node_modules/.bin")),r=e,e=X.resolve(e,"..")},Pi=(t,e,r)=>{const o=e instanceof URL?Vt(e):e;t.push(X.resolve(r,o,".."))},Bi=({env:t=U.env,...e}={})=>{t={...t};const r=Nr({env:t});return e.path=t[r],t[r]=$i(e),t},xi=(t,e,r,o)=>{if(r==="length"||r==="prototype"||r==="arguments"||r==="caller")return;const n=Object.getOwnPropertyDescriptor(t,r),s=Object.getOwnPropertyDescriptor(e,r);!Si(n,s)&&o||Object.defineProperty(t,r,s)},Si=function(t,e){return t===void 0||t.configurable||t.writable===e.writable&&t.enumerable===e.enumerable&&t.configurable===e.configurable&&(t.writable||t.value===e.value)},Mi=(t,e)=>{const r=Object.getPrototypeOf(e);r!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,r)},Oi=(t,e)=>`/* Wrapped ${t}*/
25
+ ${e}`,Ri=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Ii=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),ki=(t,e,r)=>{const o=r===""?"":`with ${r.trim()}() `,n=Oi.bind(null,o,e.toString());Object.defineProperty(n,"name",Ii),Object.defineProperty(t,"toString",{...Ri,value:n})};function Ni(t,e,{ignoreNonConfigurable:r=!1}={}){const{name:o}=t;for(const n of Reflect.ownKeys(e))xi(t,e,n,r);return Mi(t,e),ki(t,e,o),t}const Me=new WeakMap,Lr=(t,e={})=>{if(typeof t!="function")throw new TypeError("Expected a function");let r,o=0;const n=t.displayName||t.name||"<anonymous>",s=function(...i){if(Me.set(s,++o),o===1)r=t.apply(this,i),t=null;else if(e.throw===!0)throw new Error(`Function \`${n}\` can only be called once`);return r};return Ni(s,t),Me.set(s,o),s};Lr.callCount=t=>{if(!Me.has(t))throw new Error(`The given function \`${t.name}\` is not wrapped by the \`onetime\` package`);return Me.get(t)};const Li=()=>{const t=_r-Tr+1;return Array.from({length:t},Ti)},Ti=(t,e)=>({name:`SIGRT${e+1}`,number:Tr+e,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Tr=34,_r=64,_i=[{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"}],jr=()=>{const t=Li();return[..._i,...t].map(ji)},ji=({name:t,number:e,description:r,action:o,forced:n=!1,standard:s})=>{const{signals:{[t]:i}}=Jt,u=i!==void 0;return{name:t,number:u?i:e,description:r,supported:u,action:o,forced:n,standard:s}},Gi=()=>{const t=jr();return Object.fromEntries(t.map(Hi))},Hi=({name:t,number:e,description:r,supported:o,action:n,forced:s,standard:i})=>[t,{name:t,number:e,description:r,supported:o,action:n,forced:s,standard:i}],Ui=Gi(),zi=()=>{const t=jr(),e=_r+1,r=Array.from({length:e},(o,n)=>qi(n,t));return Object.assign({},...r)},qi=(t,e)=>{const r=Wi(t,e);if(r===void 0)return{};const{name:o,description:n,supported:s,action:i,forced:u,standard:a}=r;return{[t]:{name:o,number:t,description:n,supported:s,action:i,forced:u,standard:a}}},Wi=(t,e)=>{const r=e.find(({name:o})=>Jt.signals[o]===t);return r!==void 0?r:e.find(o=>o.number===t)};zi();const Ki=({timedOut:t,timeout:e,errorCode:r,signal:o,signalDescription:n,exitCode:s,isCanceled:i})=>t?`timed out after ${e} milliseconds`:i?"was canceled":r!==void 0?`failed with ${r}`:o!==void 0?`was killed with ${o} (${n})`:s!==void 0?`failed with exit code ${s}`:"failed",Gr=({stdout:t,stderr:e,all:r,error:o,signal:n,exitCode:s,command:i,escapedCommand:u,timedOut:a,isCanceled:l,killed:m,parsed:{options:{timeout:c,cwd:D=U.cwd()}}})=>{s=s===null?void 0:s,n=n===null?void 0:n;const d=n===void 0?void 0:Ui[n].description,f=o&&o.code,g=`Command ${Ki({timedOut:a,timeout:c,errorCode:f,signal:n,signalDescription:d,exitCode:s,isCanceled:l})}: ${i}`,E=Object.prototype.toString.call(o)==="[object Error]",F=E?`${g}
26
+ ${o.message}`:g,O=[F,e,t].filter(Boolean).join(`
27
+ `);return E?(o.originalMessage=o.message,o.message=O):o=new Error(O),o.shortMessage=F,o.command=i,o.escapedCommand=u,o.exitCode=s,o.signal=n,o.signalDescription=d,o.stdout=t,o.stderr=e,o.cwd=D,r!==void 0&&(o.all=r),"bufferedData"in o&&delete o.bufferedData,o.failed=!0,o.timedOut=!!a,o.isCanceled=l,o.killed=m&&!a,o},Oe=["stdin","stdout","stderr"],Vi=t=>Oe.some(e=>t[e]!==void 0),Ji=t=>{if(!t)return;const{stdio:e}=t;if(e===void 0)return Oe.map(o=>t[o]);if(Vi(t))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Oe.map(o=>`\`${o}\``).join(", ")}`);if(typeof e=="string")return e;if(!Array.isArray(e))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof e}\``);const r=Math.max(e.length,Oe.length);return Array.from({length:r},(o,n)=>e[n])};var te={exports:{}},Re={exports:{}};Re.exports;var Hr;function Yi(){return Hr||(Hr=1,function(t){t.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],process.platform!=="win32"&&t.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),process.platform==="linux"&&t.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")}(Re)),Re.exports}var $=S.process;const V=function(t){return t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function"};if(!V($))te.exports=function(){return function(){}};else{var Xi=Yt,le=Yi(),Qi=/^win/i.test($.platform),Ie=Xt;typeof Ie!="function"&&(Ie=Ie.EventEmitter);var M;$.__signal_exit_emitter__?M=$.__signal_exit_emitter__:(M=$.__signal_exit_emitter__=new Ie,M.count=0,M.emitted={}),M.infinite||(M.setMaxListeners(1/0),M.infinite=!0),te.exports=function(t,e){if(!V(S.process))return function(){};Xi.equal(typeof t,"function","a callback must be provided for exit handler"),De===!1&&Ur();var r="exit";e&&e.alwaysLast&&(r="afterexit");var o=function(){M.removeListener(r,t),M.listeners("exit").length===0&&M.listeners("afterexit").length===0&&gt()};return M.on(r,t),o};var gt=function(){!De||!V(S.process)||(De=!1,le.forEach(function(e){try{$.removeListener(e,Ct[e])}catch{}}),$.emit=Et,$.reallyExit=zr,M.count-=1)};te.exports.unload=gt;var re=function(e,r,o){M.emitted[e]||(M.emitted[e]=!0,M.emit(e,r,o))},Ct={};le.forEach(function(t){Ct[t]=function(){if(V(S.process)){var r=$.listeners(t);r.length===M.count&&(gt(),re("exit",null,t),re("afterexit",null,t),Qi&&t==="SIGHUP"&&(t="SIGINT"),$.kill($.pid,t))}}}),te.exports.signals=function(){return le};var De=!1,Ur=function(){De||!V(S.process)||(De=!0,M.count+=1,le=le.filter(function(e){try{return $.on(e,Ct[e]),!0}catch{return!1}}),$.emit=eu,$.reallyExit=Zi)};te.exports.load=Ur;var zr=$.reallyExit,Zi=function(e){V(S.process)&&($.exitCode=e||0,re("exit",$.exitCode,null),re("afterexit",$.exitCode,null),zr.call($,$.exitCode))},Et=$.emit,eu=function(e,r){if(e==="exit"&&V(S.process)){r!==void 0&&($.exitCode=r);var o=Et.apply(this,arguments);return re("exit",$.exitCode,null),re("afterexit",$.exitCode,null),o}else return Et.apply(this,arguments)}}var tu=te.exports,ru=Q(tu);const ou=1e3*5,nu=(t,e="SIGTERM",r={})=>{const o=t(e);return su(t,e,r,o),o},su=(t,e,r,o)=>{if(!iu(e,r,o))return;const n=au(r),s=setTimeout(()=>{t("SIGKILL")},n);s.unref&&s.unref()},iu=(t,{forceKillAfterTimeout:e},r)=>uu(t)&&e!==!1&&r,uu=t=>t===Jo.constants.signals.SIGTERM||typeof t=="string"&&t.toUpperCase()==="SIGTERM",au=({forceKillAfterTimeout:t=!0})=>{if(t===!0)return ou;if(!Number.isFinite(t)||t<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`);return t},cu=(t,e)=>{t.kill()&&(e.isCanceled=!0)},lu=(t,e,r)=>{t.kill(e),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:e}))},Du=(t,{timeout:e,killSignal:r="SIGTERM"},o)=>{if(e===0||e===void 0)return o;let n;const s=new Promise((u,a)=>{n=setTimeout(()=>{lu(t,r,a)},e)}),i=o.finally(()=>{clearTimeout(n)});return Promise.race([s,i])},mu=({timeout:t})=>{if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`)},du=async(t,{cleanup:e,detached:r},o)=>{if(!e||r)return o;const n=ru(()=>{t.kill()});return o.finally(()=>{n()})};function qr(t){return t!==null&&typeof t=="object"&&typeof t.pipe=="function"}function Wr(t){return qr(t)&&t.writable!==!1&&typeof t._write=="function"&&typeof t._writableState=="object"}const pu=t=>t instanceof Ko&&typeof t.then=="function",Ft=(t,e,r)=>{if(typeof r=="string")return t[e].pipe(Yo(r)),t;if(Wr(r))return t[e].pipe(r),t;if(!pu(r))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!Wr(r.stdin))throw new TypeError("The target child process's stdin must be available.");return t[e].pipe(r.stdin),r},fu=t=>{t.stdout!==null&&(t.pipeStdout=Ft.bind(void 0,t,"stdout")),t.stderr!==null&&(t.pipeStderr=Ft.bind(void 0,t,"stderr")),t.all!==void 0&&(t.pipeAll=Ft.bind(void 0,t,"all"))};var me={exports:{}};const{PassThrough:hu}=Je;var gu=t=>{t={...t};const{array:e}=t;let{encoding:r}=t;const o=r==="buffer";let n=!1;e?n=!(r||o):r=r||"utf8",o&&(r=null);const s=new hu({objectMode:n});r&&s.setEncoding(r);let i=0;const u=[];return s.on("data",a=>{u.push(a),n?i=u.length:i+=a.length}),s.getBufferedValue=()=>e?u:o?Buffer.concat(u,i):u.join(""),s.getBufferedLength=()=>i,s};const{constants:Cu}=Qo,Eu=Je,{promisify:Fu}=Qt,yu=gu,wu=Fu(Eu.pipeline);class Kr extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function yt(t,e){if(!t)throw new Error("Expected a stream");e={maxBuffer:1/0,...e};const{maxBuffer:r}=e,o=yu(e);return await new Promise((n,s)=>{const i=u=>{u&&o.getBufferedLength()<=Cu.MAX_LENGTH&&(u.bufferedData=o.getBufferedValue()),s(u)};(async()=>{try{await wu(t,o),n()}catch(u){i(u)}})(),o.on("data",()=>{o.getBufferedLength()>r&&i(new Kr)})}),o.getBufferedValue()}me.exports=yt,me.exports.buffer=(t,e)=>yt(t,{...e,encoding:"buffer"}),me.exports.array=(t,e)=>yt(t,{...e,array:!0}),me.exports.MaxBufferError=Kr;var vu=me.exports,Vr=Q(vu);const{PassThrough:bu}=Je;var $u=function(){var t=[],e=new bu({objectMode:!0});return e.setMaxListeners(0),e.add=r,e.isEmpty=o,e.on("unpipe",n),Array.prototype.slice.call(arguments).forEach(r),e;function r(s){return Array.isArray(s)?(s.forEach(r),this):(t.push(s),s.once("end",n.bind(null,s)),s.once("error",e.emit.bind(e,"error")),s.pipe(e,{end:!1}),this)}function o(){return t.length==0}function n(s){t=t.filter(function(i){return i!==s}),!t.length&&e.readable&&e.end()}},Au=Q($u);const Pu=t=>{if(t!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},Bu=({input:t,inputFile:e})=>typeof e!="string"?t:(Pu(t),Xo(e)),xu=(t,e)=>{const r=Bu(e);r!==void 0&&(qr(r)?r.pipe(t.stdin):t.stdin.end(r))},Su=(t,{all:e})=>{if(!e||!t.stdout&&!t.stderr)return;const r=Au();return t.stdout&&r.add(t.stdout),t.stderr&&r.add(t.stderr),r},wt=async(t,e)=>{if(!(!t||e===void 0)){t.destroy();try{return await e}catch(r){return r.bufferedData}}},vt=(t,{encoding:e,buffer:r,maxBuffer:o})=>{if(!(!t||!r))return e?Vr(t,{encoding:e,maxBuffer:o}):Vr.buffer(t,{maxBuffer:o})},Mu=async({stdout:t,stderr:e,all:r},{encoding:o,buffer:n,maxBuffer:s},i)=>{const u=vt(t,{encoding:o,buffer:n,maxBuffer:s}),a=vt(e,{encoding:o,buffer:n,maxBuffer:s}),l=vt(r,{encoding:o,buffer:n,maxBuffer:s*2});try{return await Promise.all([i,u,a,l])}catch(m){return Promise.all([{error:m,signal:m.signal,timedOut:m.timedOut},wt(t,u),wt(e,a),wt(r,l)])}},Ou=(async()=>{})().constructor.prototype,Ru=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Ou,t)]),Jr=(t,e)=>{for(const[r,o]of Ru){const n=typeof e=="function"?(...s)=>Reflect.apply(o.value,e(),s):o.value.bind(e);Reflect.defineProperty(t,r,{...o,value:n})}},Iu=t=>new Promise((e,r)=>{t.on("exit",(o,n)=>{e({exitCode:o,signal:n})}),t.on("error",o=>{r(o)}),t.stdin&&t.stdin.on("error",o=>{r(o)})}),Yr=(t,e=[])=>Array.isArray(e)?[t,...e]:[t],ku=/^[\w.-]+$/,Nu=/"/g,Lu=t=>typeof t!="string"||ku.test(t)?t:`"${t.replace(Nu,'\\"')}"`,Tu=(t,e)=>Yr(t,e).join(" "),_u=(t,e)=>Yr(t,e).map(r=>Lu(r)).join(" "),ju=Zo("execa").enabled,ke=(t,e)=>String(t).padStart(e,"0"),Gu=()=>{const t=new Date;return`${ke(t.getHours(),2)}:${ke(t.getMinutes(),2)}:${ke(t.getSeconds(),2)}.${ke(t.getMilliseconds(),3)}`},Hu=(t,{verbose:e})=>{e&&U.stderr.write(`[${Gu()}] ${t}
28
+ `)},Uu=1e3*1e3*100,zu=({env:t,extendEnv:e,preferLocal:r,localDir:o,execPath:n})=>{const s=e?{...U.env,...t}:t;return r?Bi({env:s,cwd:o,execPath:n}):s},qu=(t,e,r={})=>{const o=vi._parse(t,e,r);return t=o.command,e=o.args,r=o.options,r={maxBuffer:Uu,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||U.cwd(),execPath:U.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:ju,...r},r.env=zu(r),r.stdio=Ji(r),U.platform==="win32"&&X.basename(t,".exe")==="cmd"&&e.unshift("/q"),{file:t,args:e,options:r,parsed:o}},bt=(t,e,r)=>typeof e!="string"&&!Wo.isBuffer(e)?r===void 0?void 0:"":t.stripFinalNewline?bi(e):e;function de(t,e,r){const o=qu(t,e,r),n=Tu(t,e),s=_u(t,e);Hu(s,o.options),mu(o.options);let i;try{i=Kt.spawn(o.file,o.args,o.options)}catch(d){const f=new Kt.ChildProcess,h=Promise.reject(Gr({error:d,stdout:"",stderr:"",all:"",command:n,escapedCommand:s,parsed:o,timedOut:!1,isCanceled:!1,killed:!1}));return Jr(f,h),f}const u=Iu(i),a=Du(i,o.options,u),l=du(i,o.options,a),m={isCanceled:!1};i.kill=nu.bind(null,i.kill.bind(i)),i.cancel=cu.bind(null,i,m);const D=Lr(async()=>{const[{error:d,exitCode:f,signal:h,timedOut:g},E,F,O]=await Mu(i,o.options,l),J=bt(o.options,E),W=bt(o.options,F),Ke=bt(o.options,O);if(d||f!==0||h!==null){const Y=Gr({error:d,exitCode:f,signal:h,stdout:J,stderr:W,all:Ke,command:n,escapedCommand:s,parsed:o,timedOut:g,isCanceled:m.isCanceled||(o.options.signal?o.options.signal.aborted:!1),killed:i.killed});if(!o.options.reject)return Y;throw Y}return{command:n,escapedCommand:s,exitCode:0,stdout:J,stderr:W,all:Ke,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return xu(i,o.options),i.all=Su(i,o.options),fu(i),Jr(i,D),i}class x{static create(e,r){return new e(r)}}const Xr=t=>t&&`${t[0].toUpperCase()}${t.slice(1)}`,Ne=(t,e)=>{const r=Math.ceil(t),o=Math.floor(e);return Math.floor(Math.random()*(o-r+1))+r},Wu=(t,e)=>t.disabled&&!e.disabled?1:!t.disabled&&e.disabled?-1:0,oe=t=>t.reduce((e,r)=>Array.isArray(r)?e.concat(oe(r)):e.concat(r),[]),Qr=(t,e=5)=>t.replace(/[\n\r]/g,"").split(" ").slice(0,e).join(" ");class _{constructor(e){this.handleError$=r=>{let o="An error occurred";return r.message&&(o=r.message),R({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}parseMessage(e,r,o){try{const s=JSON.parse(e).map(i=>this.extractMessageAsType(i,r)).map(i=>({title:`${i.subject}`,value:`${i.subject}${i.body?`
29
29
 
30
30
  ${i.body}`:""}${i.footer?`
31
31
 
32
- ${i.footer}`:""}`}));return s.length>o?s.slice(0,o):s}catch{const s=/\[[\s\S]*?\]/;try{const i=t.match(s);if(!i)return[];const u=i[0],D=JSON.parse(u).map(m=>this.extractMessageAsType(m,r)).map(m=>({title:`${m.subject}`,value:`${m.subject}${m.body?`
32
+ ${i.footer}`:""}`}));return s.length>o?s.slice(0,o):s}catch{const s=/\[[\s\S]*?\]/;try{const i=e.match(s);if(!i)return[];const u=i[0],l=JSON.parse(u).map(m=>this.extractMessageAsType(m,r)).map(m=>({title:`${m.subject}`,value:`${m.subject}${m.body?`
33
33
 
34
34
  ${m.body}`:""}${m.footer?`
35
35
 
36
- ${m.footer}`:""}`}));return D.length>o?D.slice(0,o):D}catch{return[]}}}extractMessageAsType(t,r){switch(r){case"conventional":const o=/(\w+)(?:\(.*?\))?:\s*(.*)/,n=t.subject.match(o),s=n?n[0]:t.subject;return{...t,subject:this.normalizeCommitMessage(s)};case"gitmoji":const i=/:\w*:\s*(.*)/,u=t.subject.match(i);return{...t,subject:u?u[0].toLowerCase():t.subject};default:return t}}normalizeCommitMessage(t){const r=/^(\w+)(\(.*?\))?:\s(.*)$/,o=t.match(r);if(o){const[,n,s,i]=o,u=n.toLowerCase(),a=i.charAt(0).toLowerCase()+i.slice(1);t=`${u}${s||""}: ${a}`}return t}}var Yr="2.0.9",xu="A Reactive CLI that generates git commit messages with various AI";class y extends Error{}const At=" ",pe=e=>{e instanceof Error&&(e instanceof y||(e.stack&&console.error(C.dim(e.stack.split(`
36
+ ${m.footer}`:""}`}));return l.length>o?l.slice(0,o):l}catch{return[]}}}extractMessageAsType(e,r){switch(r){case"conventional":const o=/(\w+)(?:\(.*?\))?:\s*(.*)/,n=e.subject.match(o),s=n?n[0]:e.subject;return{...e,subject:this.normalizeCommitMessage(s)};case"gitmoji":const i=/:\w*:\s*(.*)/,u=e.subject.match(i);return{...e,subject:u?u[0].toLowerCase():e.subject};default:return e}}normalizeCommitMessage(e){const r=/^(\w+)(\(.*?\))?:\s(.*)$/,o=e.match(r);if(o){const[,n,s,i]=o,u=n.toLowerCase(),a=i.charAt(0).toLowerCase()+i.slice(1);e=`${u}${s||""}: ${a}`}return e}sanitizeResponse(e){if(typeof e=="string")try{return[{title:`${Qr(e)}...`,value:e}]}catch{return[]}return e.map(r=>{try{return{title:`${Qr(r)}...`,value:r}}catch{return{title:"",value:""}}})}}var Zr="2.1.0",Ku="A Reactive CLI that generates git commit messages with various AI";class y extends Error{}const $t=" ",pe=t=>{t instanceof Error&&(t instanceof y||(t.stack&&console.error(C.dim(t.stack.split(`
37
37
  `).slice(1).join(`
38
38
  `))),console.error(`
39
- ${At}${C.dim(`aicommit2 v${Yr}`)}`),console.error(`
40
- ${At}Please open a Bug report with the information above:`),console.error(`${At}https://github.com/tak-bro/aicommit2/issues/new/choose`)))},Xr=L.join(Je.homedir(),".aicommit2_log"),Pu=new Date,G=(e,t,r,o)=>{const n=`[${e}]`,s=Su(Pu,t),i=`${Xr}/${s}`,u=`- System Prompt
41
- ${r}`,a=`- Response
42
- ${o}`,D=`[Git Diff]
43
- ${t}`;if(W.existsSync(i)){const m=W.readFileSync(i,"utf-8");Zr(i,`${n}
39
+ ${$t}${C.dim(`aicommit2 v${Zr}`)}`),console.error(`
40
+ ${$t}Please open a Bug report with the information above:`),console.error(`${$t}https://github.com/tak-bro/aicommit2/issues/new/choose`)))},eo=N.join(Ye.homedir(),".aicommit2_log"),Vu=new Date,j=(t,e,r,o,n)=>{const s=`[${t}]`,i=Ju(Vu,e,n),u=`${eo}/${i}`,a=`- System Prompt
41
+ ${r}`,l=`- Response
42
+ ${o}`,m=`[Git Diff]
43
+ ${e}`;if(T.existsSync(u)){const c=T.readFileSync(u,"utf-8");to(u,`${s}
44
+ ${l}
45
+
44
46
  ${a}
45
47
 
46
- ${u}
48
+ ${c}`);return}to(u,`${s}
49
+ ${l}
47
50
 
48
- ${m}`);return}Zr(i,`${n}
49
51
  ${a}
50
52
 
51
- ${u}
52
-
53
- ${D}`)},Su=(e,t)=>{const{year:r,month:o,day:n,hours:s,minutes:i,seconds:u}=Ou(e),D=Go(0).update(t).digest("hex");return`aic2_${r}-${o}-${n}_${s}-${i}-${u}_${D}.log`},Zr=(e,t="")=>{W.mkdirSync(L.dirname(e),{recursive:!0}),W.writeFileSync(e,t,"utf-8")},Ou=e=>{const t=e.getFullYear().toString(),r=(e.getMonth()+1).toString().padStart(2,"0"),o=e.getDate().toString().padStart(2,"0"),n=e.getHours().toString().padStart(2,"0"),s=e.getMinutes().toString().padStart(2,"0"),i=e.getSeconds().toString().padStart(2,"0");return{year:t,month:r,day:o,hours:n,minutes:s,seconds:i}},k={locale:"en",maxLength:50,type:"conventional",generate:1,systemPrompt:"",systemPromptPath:""},Mu={"":"<commit message>",conventional:`<type>(<optional scope>): <description>
53
+ ${m}`)},Ju=(t,e,r)=>{const{year:o,month:n,day:s,hours:i,minutes:u,seconds:a}=Yu(t),m=sn(0).update(e).digest("hex");return r==="review"?`aic2_review_${o}-${n}-${s}_${i}-${u}-${a}_${m}.log`:`aic2_${o}-${n}-${s}_${i}-${u}-${a}_${m}.log`},to=(t,e="")=>{T.mkdirSync(N.dirname(t),{recursive:!0}),T.writeFileSync(t,e,"utf-8")},Yu=t=>{const e=t.getFullYear().toString(),r=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),n=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0"),i=t.getSeconds().toString().padStart(2,"0");return{year:e,month:r,day:o,hours:n,minutes:s,seconds:i}},L={locale:"en",maxLength:50,type:"conventional",generate:1,systemPrompt:"",systemPromptPath:"",codeReviewPromptPath:""},Xu={"":"<commit message>",conventional:`<type>(<optional scope>): <description>
54
54
 
55
55
  [optional body]
56
56
 
@@ -58,67 +58,75 @@ ${D}`)},Su=(e,t)=>{const{year:r,month:o,day:n,hours:s,minutes:i,seconds:u}=Ou(e)
58
58
 
59
59
  [optional body]
60
60
 
61
- [optional footer(s)]`},Iu={"":"",gitmoji:`
62
- ${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(`
61
+ [optional footer(s)]`},Qu={"":"",gitmoji:`
62
+ ${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(([t,e])=>` - ${t}: ${e}`).join(`
63
63
  `)}`,conventional:`
64
- ${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(`
65
- `)}`},Tu=(e,t)=>e.replace(/{(\w+)}/g,(r,o)=>t[o]?.toString()||k[o]?.toString()),Qr=e=>{const{type:t,maxLength:r,generate:o,locale:n}=e;return[`You are a helpful assistant specializing in writing clear and informative Git commit messages using the ${t} style`,`Based on the given code changes or context, generate exactly ${o} ${t} Git commit message${o!==1?"s":""} based on the following guidelines.`,`1. Message Language: ${n}`,`2. Format: follow the ${t} Commits format:`,`${Mu[t]}`,`3. Types: use one of the following types:${Iu[t]}`,"4. Exclude anything unnecessary such as translation. Your entire response will be passed directly into git commit."].filter(Boolean).join(`
66
- `)},Ie=(e,t)=>{const r=o=>o==="conventional"?`${Array(t).fill(null).map((n,s)=>`
64
+ ${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(([t,e])=>` - ${t}: ${e}`).join(`
65
+ `)}`},ro=(t,e)=>t.replace(/{(\w+)}/g,(r,o)=>e[o]?.toString()||L[o]?.toString()),oo=t=>{const{type:e,maxLength:r,generate:o,locale:n}=t;return[`You are a helpful assistant specializing in writing clear and informative Git commit messages using the ${e} style`,`Based on the given code changes or context, generate exactly ${o} ${e} Git commit message${o!==1?"s":""} based on the following guidelines.`,`1. Message Language: ${n}`,`2. Format: follow the ${e} Commits format:`,`${Xu[e]}`,`3. Types: use one of the following types:${Qu[e]}`,"4. Exclude anything unnecessary such as translation. Your entire response will be passed directly into git commit."].filter(Boolean).join(`
66
+ `)},Le=(t,e)=>{const r=o=>o==="conventional"?`${Array(e).fill(null).map((n,s)=>`
67
67
  {
68
68
  "subject": "fix: fix bug in user authentication process",
69
69
  "body": "- Update login function to handle edge cases\\n- Add additional error logging for debugging",
70
70
  "footer": ""
71
- }`).join(",")}`:`${Array(t).fill(null).map((n,s)=>`
71
+ }`).join(",")}`:`${Array(e).fill(null).map((n,s)=>`
72
72
  {
73
73
  "subject": "\u{1F5BC}\uFE0F Add profile picture upload feature",
74
74
  "body": "- Implement server-side handling of file uploads\\n- Add client-side image preview and cropping",
75
75
  "footer": ""
76
76
  }`).join(",")}`;return[`
77
- Lastly, Provide your response as a JSON array containing exactly ${t} object${t!==1?"s":""}, each with the following keys:`,`- "subject": The main commit message using the ${e} style. 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 BREAKING CHANGES. 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:
78
- [${r(e)}
79
- ]`,`Ensure you generate exactly ${t} commit message${t!==1?"s":""}, even if it requires creating slightly varied versions for similar changes.`,"The response should be valid JSON that can be parsed without errors."].filter(Boolean).join(`
80
- `)},H=e=>{const{systemPrompt:t,systemPromptPath:r,type:o,generate:n}=e;if(t)return`${t}
81
- ${Ie(o,n)}`;if(!r)return`${Qr(e)}
82
- ${Ie(o,n)}`;try{const s=W.readFileSync(L.resolve(r),"utf-8");return`${Tu(s,e)}
83
- ${Ie(o,n)}`}catch{return`${Qr(e)}
84
- ${Ie(o,n)}`}};class ku extends j{constructor(t){super(t),this.params=t,this.handleError$=r=>{const o=r.error?.error?.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return O({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#AE5630",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Anthropic]"),this.errorPrefix=C.red.bold("[Anthropic]"),this.anthropic=new jo({apiKey:this.params.config.key})}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:o,logging:n,temperature:s,locale:i,generate:u,type:a,maxLength:D}=this.params.config,m={...k,locale:i,maxLength:D,type:a,generate:u,systemPrompt:r,systemPromptPath:o},c=H(m),l={max_tokens:this.params.config.maxTokens,temperature:s,system:c,messages:[{role:"user",content:`Here is the diff: ${t}`}],top_p:this.params.config.topP,model:this.params.config.model},d=(await this.anthropic.messages.create(l)).content.map(({text:h})=>h).join("");return n&&G("Anthropic",t,c,d),this.parseMessage(d,a,u)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}const eo=e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`,Te=(e,t)=>{const r=Math.ceil(e),o=Math.floor(t);return Math.floor(Math.random()*(o-r+1))+r},Lu=(e,t)=>e.disabled&&!t.disabled?1:!e.disabled&&t.disabled?-1:0,ke=e=>e.reduce((t,r)=>Array.isArray(r)?t.concat(ke(r)):t.concat(r),[]);class ne{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=Ho.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 Nu extends j{constructor(t){super(t),this.params=t,this.host="https://codestral.mistral.ai",this.apiKey="",this.handleError$=r=>{const o=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return O({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#e28c58",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Codestral]"),this.errorPrefix=C.red.bold("[Codestral]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:o,logging:n,locale:s,generate:i,type:u,maxLength:a}=this.params.config,D={...k,locale:s,maxLength:a,type:u,generate:i,systemPrompt:r,systemPromptPath:o},m=H(D);this.checkAvailableModels();const c=await this.createChatCompletions(m);return n&&G("Codestral",t,m,c),this.parseMessage(c,u,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}checkAvailableModels(){if(["codestral-latest","codestral-2405"].includes(this.params.config.model))return!0;throw new Error("Invalid model type of Codestral AI")}async createChatCompletions(t){const o=(await new ne({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.model,messages:[{role:"system",content:t},{role:"user",content:`Here is the diff: ${this.params.stagedDiff.diff}`}],temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1,safe_prompt:!1,random_seed:Te(10,1e3),response_format:{type:"json_object"}}).execute()).data;if(!o.choices||o.choices.length===0||!o.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return o.choices[0].message.content}}class Ru extends j{constructor(t){super(t),this.params=t,this.handleError$=r=>{const o=/"message":\s*"([^"]*)"/,n=r.message.match(o);let s=r?.body?.message;n&&n[1]&&(s=n[1]);const i=`${r.statusCode} ${s}`;return O({name:`${this.errorPrefix} ${i}`,value:s,isError:!0,disabled:!0})},this.colors={primary:"#D18EE2",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Cohere]"),this.errorPrefix=C.red.bold("[Cohere]"),this.cohere=new Uo({token:this.params.config.key})}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:o,logging:n,locale:s,temperature:i,generate:u,type:a,maxLength:D}=this.params.config,m={...k,locale:s,maxLength:D,type:a,generate:u,systemPrompt:r,systemPromptPath:o},c=H(m),l=this.params.config.maxTokens,p=await this.cohere.chat({chatHistory:c?[{role:"SYSTEM",message:c}]:[],message:`Here is the diff: ${t}`,connectors:[{id:"web-search"}],maxTokens:l,temperature:i,model:this.params.config.model,seed:Te(10,1e3),p:this.params.config.topP});return n&&G("Cohere",t,c,p.text),this.parseMessage(p.text,a,u)}catch(t){const r=t;throw r instanceof qo?new y("Request timed out error!"):r}}}class _u extends j{constructor(t){super(t),this.params=t,this.host="https://api.deepseek.com",this.apiKey="",this.handleError$=r=>{const o=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return O({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#53a3f9",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[DeepSeek]"),this.errorPrefix=C.red.bold("[DeepSeek]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:o,logging:n,locale:s,generate:i,type:u,maxLength:a}=this.params.config,D={...k,locale:s,maxLength:a,type:u,generate:i,systemPrompt:r,systemPromptPath:o},m=H(D);this.checkAvailableModels();const c=await this.createChatCompletions(m);return n&&G("DeepSeek",t,m,c),this.parseMessage(c,u,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}checkAvailableModels(){if(["deepseek-coder","deepseek-chat"].includes(this.params.config.model))return!0;throw new Error("Invalid model type of DeepSeek")}async createChatCompletions(t){const o=(await new ne({method:"POST",baseURL:`${this.host}/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.model,messages:[{role:"system",content:t},{role:"user",content:`Here is the diff: ${this.params.stagedDiff.diff}`}],response_format:{type:"json_object"},temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1}).execute()).data;if(!o.choices||o.choices.length===0||!o.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return o.choices[0].message.content}}class ju extends j{constructor(t){super(t),this.params=t,this.handleError$=r=>{const o=r.message||r.toString(),n=/(\[.*?\]\s*[^[]*)/g,s=[...o.matchAll(n)],i=[];s.forEach(a=>i.push(a[1]));const u=i[1]||"An error occurred";return O({name:`${this.errorPrefix} ${u}`,value:u,isError:!0,disabled:!0})},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Gemini]"),this.errorPrefix=C.red.bold("[Gemini]"),this.genAI=new zo(this.params.config.key)}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:o,logging:n,locale:s,temperature:i,generate:u,type:a,maxLength:D}=this.params.config,m=this.params.config.maxTokens,c={...k,locale:s,maxLength:D,type:a,generate:u,systemPrompt:r,systemPromptPath:o},l=H(c),g=(await this.genAI.getGenerativeModel({model:this.params.config.model,systemInstruction:l,generationConfig:{maxOutputTokens:m,temperature:this.params.config.temperature,topP:this.params.config.topP},safetySettings:[{category:ye.HARM_CATEGORY_HATE_SPEECH,threshold:Ee.BLOCK_LOW_AND_ABOVE},{category:ye.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:Ee.BLOCK_LOW_AND_ABOVE},{category:ye.HARM_CATEGORY_HARASSMENT,threshold:Ee.BLOCK_LOW_AND_ABOVE},{category:ye.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:Ee.BLOCK_LOW_AND_ABOVE}]}).generateContent(`Here is the diff: ${t}`)).response.text();return n&&G("Gemini",t,l,g),this.parseMessage(g,a,u)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}var $t={},vt={exports:{}},fe={exports:{}},Bt,to;function Gu(){if(to)return Bt;to=1;var e=1e3,t=e*60,r=t*60,o=r*24,n=o*7,s=o*365.25;Bt=function(m,c){c=c||{};var l=typeof m;if(l==="string"&&m.length>0)return i(m);if(l==="number"&&isFinite(m))return c.long?a(m):u(m);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(m))};function i(m){if(m=String(m),!(m.length>100)){var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(m);if(c){var l=parseFloat(c[1]),p=(c[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return l*s;case"weeks":case"week":case"w":return l*n;case"days":case"day":case"d":return l*o;case"hours":case"hour":case"hrs":case"hr":case"h":return l*r;case"minutes":case"minute":case"mins":case"min":case"m":return l*t;case"seconds":case"second":case"secs":case"sec":case"s":return l*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:return}}}}function u(m){var c=Math.abs(m);return c>=o?Math.round(m/o)+"d":c>=r?Math.round(m/r)+"h":c>=t?Math.round(m/t)+"m":c>=e?Math.round(m/e)+"s":m+"ms"}function a(m){var c=Math.abs(m);return c>=o?D(m,c,o,"day"):c>=r?D(m,c,r,"hour"):c>=t?D(m,c,t,"minute"):c>=e?D(m,c,e,"second"):m+" ms"}function D(m,c,l,p){var d=c>=l*1.5;return Math.round(m/l)+" "+p+(d?"s":"")}return Bt}var xt,ro;function oo(){if(ro)return xt;ro=1;function e(t){o.debug=o,o.default=o,o.coerce=D,o.disable=i,o.enable=s,o.enabled=u,o.humanize=Gu(),o.destroy=m,Object.keys(t).forEach(c=>{o[c]=t[c]}),o.names=[],o.skips=[],o.formatters={};function r(c){let l=0;for(let p=0;p<c.length;p++)l=(l<<5)-l+c.charCodeAt(p),l|=0;return o.colors[Math.abs(l)%o.colors.length]}o.selectColor=r;function o(c){let l,p=null,d,h;function g(...E){if(!g.enabled)return;const A=g,v=Number(new Date),Y=v-(l||v);A.diff=Y,A.prev=l,A.curr=v,l=v,E[0]=o.coerce(E[0]),typeof E[0]!="string"&&E.unshift("%O");let z=0;E[0]=E[0].replace(/%([a-zA-Z%])/g,(x,$o)=>{if(x==="%%")return"%";z++;const zt=o.formatters[$o];if(typeof zt=="function"){const vo=E[z];x=zt.call(A,vo),E.splice(z,1),z--}return x}),o.formatArgs.call(A,E),(A.log||o.log).apply(A,E)}return g.namespace=c,g.useColors=o.useColors(),g.color=o.selectColor(c),g.extend=n,g.destroy=o.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==o.namespaces&&(d=o.namespaces,h=o.enabled(c)),h),set:E=>{p=E}}),typeof o.init=="function"&&o.init(g),g}function n(c,l){const p=o(this.namespace+(typeof l>"u"?":":l)+c);return p.log=this.log,p}function s(c){o.save(c),o.namespaces=c,o.names=[],o.skips=[];let l;const p=(typeof c=="string"?c:"").split(/[\s,]+/),d=p.length;for(l=0;l<d;l++)p[l]&&(c=p[l].replace(/\*/g,".*?"),c[0]==="-"?o.skips.push(new RegExp("^"+c.slice(1)+"$")):o.names.push(new RegExp("^"+c+"$")))}function i(){const c=[...o.names.map(a),...o.skips.map(a).map(l=>"-"+l)].join(",");return o.enable(""),c}function u(c){if(c[c.length-1]==="*")return!0;let l,p;for(l=0,p=o.skips.length;l<p;l++)if(o.skips[l].test(c))return!1;for(l=0,p=o.names.length;l<p;l++)if(o.names[l].test(c))return!0;return!1}function a(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function D(c){return c instanceof Error?c.stack||c.message:c}function m(){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 o.enable(o.load()),o}return xt=e,xt}fe.exports;var no;function Hu(){return no||(no=1,function(e,t){t.formatArgs=o,t.save=n,t.load=s,t.useColors=r,t.storage=i(),t.destroy=(()=>{let a=!1;return()=>{a||(a=!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 o(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const D="color: "+this.color;a.splice(1,0,D,"color: inherit");let m=0,c=0;a[0].replace(/%[a-zA-Z%]/g,l=>{l!=="%%"&&(m++,l==="%c"&&(c=m))}),a.splice(c,0,D)}t.log=console.debug||console.log||(()=>{});function n(a){try{a?t.storage.setItem("debug",a):t.storage.removeItem("debug")}catch{}}function s(){let a;try{a=t.storage.getItem("debug")}catch{}return!a&&typeof process<"u"&&"env"in process&&(a=process.env.DEBUG),a}function i(){try{return localStorage}catch{}}e.exports=oo()(t);const{formatters:u}=e.exports;u.j=function(a){try{return JSON.stringify(a)}catch(D){return"[UnexpectedJSONParseError]: "+D.message}}}(fe,fe.exports)),fe.exports}var de={exports:{}},Pt,so;function Uu(){return so||(so=1,Pt=(e,t=process.argv)=>{const r=e.startsWith("-")?"":e.length===1?"-":"--",o=t.indexOf(r+e),n=t.indexOf("--");return o!==-1&&(n===-1||o<n)}),Pt}var St,io;function qu(){if(io)return St;io=1;const e=Je,t=ze,r=Uu(),{env:o}=process;let n;r("no-color")||r("no-colors")||r("color=false")||r("color=never")?n=0:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(n=1),"FORCE_COLOR"in o&&(o.FORCE_COLOR==="true"?n=1:o.FORCE_COLOR==="false"?n=0:n=o.FORCE_COLOR.length===0?1:Math.min(parseInt(o.FORCE_COLOR,10),3));function s(a){return a===0?!1:{level:a,hasBasic:!0,has256:a>=2,has16m:a>=3}}function i(a,D){if(n===0)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(a&&!D&&n===void 0)return 0;const m=n||0;if(o.TERM==="dumb")return m;if(process.platform==="win32"){const c=e.release().split(".");return Number(c[0])>=10&&Number(c[2])>=10586?Number(c[2])>=14931?3:2:1}if("CI"in o)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(c=>c in o)||o.CI_NAME==="codeship"?1:m;if("TEAMCITY_VERSION"in o)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(o.TEAMCITY_VERSION)?1:0;if(o.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in o){const c=parseInt((o.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(o.TERM_PROGRAM){case"iTerm.app":return c>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(o.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(o.TERM)||"COLORTERM"in o?1:m}function u(a){const D=i(a,a&&a.isTTY);return s(D)}return St={supportsColor:u,stdout:s(i(!0,t.isatty(1))),stderr:s(i(!0,t.isatty(2)))},St}de.exports;var uo;function zu(){return uo||(uo=1,function(e,t){const r=ze,o=Xt;t.init=m,t.log=u,t.formatArgs=s,t.save=a,t.load=D,t.useColors=n,t.destroy=o.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 l=qu();l&&(l.stderr||l).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(l=>/^debug_/i.test(l)).reduce((l,p)=>{const d=p.substring(6).toLowerCase().replace(/_([a-z])/g,(g,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),l[d]=h,l},{});function n(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:r.isatty(process.stderr.fd)}function s(l){const{namespace:p,useColors:d}=this;if(d){const h=this.color,g="\x1B[3"+(h<8?h:"8;5;"+h),E=` ${g};1m${p} \x1B[0m`;l[0]=E+l[0].split(`
77
+ Lastly, Provide your response as a JSON array containing exactly ${e} object${e!==1?"s":""}, each with the following keys:`,`- "subject": The main commit message using the ${t} style. 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 BREAKING CHANGES. If not needed, use an empty string.',`The array must always contain ${e} element${e!==1?"s":""}, no more and no less.`,`Example response format:
78
+ [${r(t)}
79
+ ]`,`Ensure you generate exactly ${e} commit message${e!==1?"s":""}, even if it requires creating slightly varied versions for similar changes.`,"The response should be valid JSON that can be parsed without errors."].filter(Boolean).join(`
80
+ `)},G=t=>{const{systemPrompt:e,systemPromptPath:r,type:o,generate:n}=t;if(e)return`${e}
81
+ ${Le(o,n)}`;if(!r)return`${oo(t)}
82
+ ${Le(o,n)}`;try{const s=T.readFileSync(N.resolve(r),"utf-8");return`${ro(s,t)}
83
+ ${Le(o,n)}`}catch{return`${oo(t)}
84
+ ${Le(o,n)}`}},H=t=>{const{codeReviewPromptPath:e,locale:r}=t,o=`I'll give you the output of the "git diff" command as an input. Please review the following code and provide your feedback in Markdown format. Focus on:
85
+
86
+ 1. Language: ${r}
87
+ 2. Code quality and best practices
88
+ 3. Potential bugs or errors
89
+ 4. Performance improvements
90
+ 5. Readability and maintainability
91
+
92
+ Please structure your response with appropriate Markdown headings, code blocks, and bullet points.`;if(!e)return o;try{const n=T.readFileSync(N.resolve(e),"utf-8");return`${ro(n,t)}`}catch{return o}};class no extends _{constructor(e){super(e),this.params=e,this.handleError$=r=>{const o=r.error?.error?.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return R({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#AE5630",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Anthropic]"),this.errorPrefix=C.red.bold("[Anthropic]"),this.anthropic=new nn({apiKey:this.params.config.key})}generateCommitMessage$(){return B(this.generateMessage("commit")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return B(this.generateMessage("review")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,temperature:u,locale:a,generate:l,type:m,maxLength:c,maxTokens:D,topP:d,model:f}=this.params.config,h={...L,locale:a,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},g=e==="review"?H(h):G(h),E={max_tokens:D,temperature:u,system:g,messages:[{role:"user",content:`Here is the diff: ${r}`}],top_p:d,model:f},O=(await this.anthropic.messages.create(E)).content.map(({text:J})=>J).join("");return i&&j("Anthropic",r,g,O,e),e==="review"?this.sanitizeResponse(O):this.parseMessage(O,m,l)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new y(`Error connecting to ${o.hostname} (${o.syscall})`):o}}}class ne{constructor(e={}){if(!e.method)throw new Error("method should be defined!");if(!e.baseURL)throw new Error("baseURL should be defined!");this.config={...e},this.axiosInstance=un.create(this.config)}setHeaders(e){return this.config.headers=e,this}setParams(e){return this.config.params=e,this}setBody(e){return this.config.data=e,this}addBody(e){return this.config.data={...this.config.data,...e},this}setMethod(e){return this.config.method=e,this}async execute(){try{return await this.axiosInstance.request(this.config)}catch(e){throw e}}}class so extends _{constructor(e){super(e),this.params=e,this.host="https://codestral.mistral.ai",this.apiKey="",this.handleError$=r=>{const o=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return R({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#e28c58",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Codestral]"),this.errorPrefix=C.red.bold("[Codestral]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return B(this.generateMessage("commit")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return B(this.generateMessage("review")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,locale:u,generate:a,type:l,maxLength:m}=this.params.config,c={...L,locale:u,maxLength:m,type:l,generate:a,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},D=e==="review"?H(c):G(c);this.checkAvailableModels();const d=await this.createChatCompletions(D,e);return i&&j("Codestral",r,D,d,e),e==="review"?this.sanitizeResponse(d):this.parseMessage(d,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new y(`Error connecting to ${o.hostname} (${o.syscall})`):o}}checkAvailableModels(){if(["codestral-latest","codestral-2405"].includes(this.params.config.model))return!0;throw new Error("Invalid model type of Codestral AI")}async createChatCompletions(e,r){const o=new ne({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.model,messages:[{role:"system",content:e},{role:"user",content:`Here is the diff: ${this.params.stagedDiff.diff}`}],temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1,safe_prompt:!1,random_seed:Ne(10,1e3)});r==="commit"&&o.addBody({response_format:{type:"json_object"}});const s=(await o.execute()).data;if(!s.choices||s.choices.length===0||!s.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return s.choices[0].message.content}}class io extends _{constructor(e){super(e),this.params=e,this.handleError$=r=>{const o=/"message":\s*"([^"]*)"/,n=r.message.match(o);let s=r?.body?.message;n&&n[1]&&(s=n[1]);const i=`${r.statusCode} ${s}`;return R({name:`${this.errorPrefix} ${i}`,value:s,isError:!0,disabled:!0})},this.colors={primary:"#D18EE2",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Cohere]"),this.errorPrefix=C.red.bold("[Cohere]"),this.cohere=new an({token:this.params.config.key})}generateCommitMessage$(){return B(this.generateMessage("commit")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return B(this.generateMessage("review")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,temperature:u,locale:a,generate:l,type:m,maxLength:c,maxTokens:D,topP:d,model:f}=this.params.config,h={...L,locale:a,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},g=e==="review"?H(h):G(h),E=await this.cohere.chat({chatHistory:g?[{role:"SYSTEM",message:g}]:[],message:`Here is the diff: ${r}`,connectors:[{id:"web-search"}],maxTokens:D,temperature:u,model:this.params.config.model,seed:Ne(10,1e3),p:this.params.config.topP});return i&&j("Cohere",r,g,E.text,e),e==="review"?this.sanitizeResponse(E.text):this.parseMessage(E.text,m,l)}catch(r){const o=r;throw o instanceof cn?new y("Request timed out error!"):o}}}class uo extends _{constructor(e){super(e),this.params=e,this.host="https://api.deepseek.com",this.apiKey="",this.handleError$=r=>{const o=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return R({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#53a3f9",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[DeepSeek]"),this.errorPrefix=C.red.bold("[DeepSeek]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return B(this.generateMessage("commit")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return B(this.generateMessage("review")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,locale:u,generate:a,type:l,maxLength:m}=this.params.config,c={...L,locale:u,maxLength:m,type:l,generate:a,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},D=e==="review"?H(c):G(c);this.checkAvailableModels();const d=await this.createChatCompletions(D,e);return i&&j("DeepSeek",r,D,d,e),e==="review"?this.sanitizeResponse(d):this.parseMessage(d,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new y(`Error connecting to ${o.hostname} (${o.syscall})`):o}}checkAvailableModels(){if(["deepseek-coder","deepseek-chat"].includes(this.params.config.model))return!0;throw new Error("Invalid model type of DeepSeek")}async createChatCompletions(e,r){const o=new ne({method:"POST",baseURL:`${this.host}/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.model,messages:[{role:"system",content:e},{role:"user",content:`Here is the diff: ${this.params.stagedDiff.diff}`}],temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1});r==="commit"&&o.addBody({response_format:{type:"json_object"}});const s=(await o.execute()).data;if(!s.choices||s.choices.length===0||!s.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return s.choices[0].message.content}}class ao extends _{constructor(e){super(e),this.params=e,this.handleError$=r=>{const o=r.message||r.toString(),n=/(\[.*?\]\s*[^[]*)/g,s=[...o.matchAll(n)],i=[];s.forEach(a=>i.push(a[1]));const u=i[1]||"An error occurred";return R({name:`${this.errorPrefix} ${u}`,value:u,isError:!0,disabled:!0})},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Gemini]"),this.errorPrefix=C.red.bold("[Gemini]"),this.genAI=new ln(this.params.config.key)}generateCommitMessage$(){return B(this.generateMessage("commit")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return B(this.generateMessage("review")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,logging:s,locale:i,codeReviewPromptPath:u,generate:a,type:l,maxLength:m}=this.params.config,c=this.params.config.maxTokens,D={...L,locale:i,maxLength:m,type:l,generate:a,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:u},d=e==="review"?H(D):G(D),E=(await this.genAI.getGenerativeModel({model:this.params.config.model,systemInstruction:d,generationConfig:{maxOutputTokens:c,temperature:this.params.config.temperature,topP:this.params.config.topP},safetySettings:[{category:ve.HARM_CATEGORY_HATE_SPEECH,threshold:be.BLOCK_LOW_AND_ABOVE},{category:ve.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:be.BLOCK_LOW_AND_ABOVE},{category:ve.HARM_CATEGORY_HARASSMENT,threshold:be.BLOCK_LOW_AND_ABOVE},{category:ve.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:be.BLOCK_LOW_AND_ABOVE}]}).generateContent(`Here is the diff: ${r}`)).response.text();return s&&j("Gemini",r,d,E,e),e==="review"?this.sanitizeResponse(E):this.parseMessage(E,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new y(`Error connecting to ${o.hostname} (${o.syscall})`):o}}}var At={},Pt={exports:{}},fe={exports:{}},Bt,co;function Zu(){if(co)return Bt;co=1;var t=1e3,e=t*60,r=e*60,o=r*24,n=o*7,s=o*365.25;Bt=function(m,c){c=c||{};var D=typeof m;if(D==="string"&&m.length>0)return i(m);if(D==="number"&&isFinite(m))return c.long?a(m):u(m);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(m))};function i(m){if(m=String(m),!(m.length>100)){var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(m);if(c){var D=parseFloat(c[1]),d=(c[2]||"ms").toLowerCase();switch(d){case"years":case"year":case"yrs":case"yr":case"y":return D*s;case"weeks":case"week":case"w":return D*n;case"days":case"day":case"d":return D*o;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*e;case"seconds":case"second":case"secs":case"sec":case"s":return D*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return D;default:return}}}}function u(m){var c=Math.abs(m);return c>=o?Math.round(m/o)+"d":c>=r?Math.round(m/r)+"h":c>=e?Math.round(m/e)+"m":c>=t?Math.round(m/t)+"s":m+"ms"}function a(m){var c=Math.abs(m);return c>=o?l(m,c,o,"day"):c>=r?l(m,c,r,"hour"):c>=e?l(m,c,e,"minute"):c>=t?l(m,c,t,"second"):m+" ms"}function l(m,c,D,d){var f=c>=D*1.5;return Math.round(m/D)+" "+d+(f?"s":"")}return Bt}var xt,lo;function Do(){if(lo)return xt;lo=1;function t(e){o.debug=o,o.default=o,o.coerce=l,o.disable=i,o.enable=s,o.enabled=u,o.humanize=Zu(),o.destroy=m,Object.keys(e).forEach(c=>{o[c]=e[c]}),o.names=[],o.skips=[],o.formatters={};function r(c){let D=0;for(let d=0;d<c.length;d++)D=(D<<5)-D+c.charCodeAt(d),D|=0;return o.colors[Math.abs(D)%o.colors.length]}o.selectColor=r;function o(c){let D,d=null,f,h;function g(...E){if(!g.enabled)return;const F=g,O=Number(new Date),J=O-(D||O);F.diff=J,F.prev=D,F.curr=O,D=O,E[0]=o.coerce(E[0]),typeof E[0]!="string"&&E.unshift("%O");let W=0;E[0]=E[0].replace(/%([a-zA-Z%])/g,(Y,Uo)=>{if(Y==="%%")return"%";W++;const Wt=o.formatters[Uo];if(typeof Wt=="function"){const zo=E[W];Y=Wt.call(F,zo),E.splice(W,1),W--}return Y}),o.formatArgs.call(F,E),(F.log||o.log).apply(F,E)}return g.namespace=c,g.useColors=o.useColors(),g.color=o.selectColor(c),g.extend=n,g.destroy=o.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(f!==o.namespaces&&(f=o.namespaces,h=o.enabled(c)),h),set:E=>{d=E}}),typeof o.init=="function"&&o.init(g),g}function n(c,D){const d=o(this.namespace+(typeof D>"u"?":":D)+c);return d.log=this.log,d}function s(c){o.save(c),o.namespaces=c,o.names=[],o.skips=[];let D;const d=(typeof c=="string"?c:"").split(/[\s,]+/),f=d.length;for(D=0;D<f;D++)d[D]&&(c=d[D].replace(/\*/g,".*?"),c[0]==="-"?o.skips.push(new RegExp("^"+c.slice(1)+"$")):o.names.push(new RegExp("^"+c+"$")))}function i(){const c=[...o.names.map(a),...o.skips.map(a).map(D=>"-"+D)].join(",");return o.enable(""),c}function u(c){if(c[c.length-1]==="*")return!0;let D,d;for(D=0,d=o.skips.length;D<d;D++)if(o.skips[D].test(c))return!1;for(D=0,d=o.names.length;D<d;D++)if(o.names[D].test(c))return!0;return!1}function a(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function l(c){return c instanceof Error?c.stack||c.message:c}function m(){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 o.enable(o.load()),o}return xt=t,xt}fe.exports;var mo;function ea(){return mo||(mo=1,function(t,e){e.formatArgs=o,e.save=n,e.load=s,e.useColors=r,e.storage=i(),e.destroy=(()=>{let a=!1;return()=>{a||(a=!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`."))}})(),e.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 o(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;a.splice(1,0,l,"color: inherit");let m=0,c=0;a[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(m++,D==="%c"&&(c=m))}),a.splice(c,0,l)}e.log=console.debug||console.log||(()=>{});function n(a){try{a?e.storage.setItem("debug",a):e.storage.removeItem("debug")}catch{}}function s(){let a;try{a=e.storage.getItem("debug")}catch{}return!a&&typeof process<"u"&&"env"in process&&(a=process.env.DEBUG),a}function i(){try{return localStorage}catch{}}t.exports=Do()(e);const{formatters:u}=t.exports;u.j=function(a){try{return JSON.stringify(a)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(fe,fe.exports)),fe.exports}var he={exports:{}},St,po;function ta(){return po||(po=1,St=(t,e=process.argv)=>{const r=t.startsWith("-")?"":t.length===1?"-":"--",o=e.indexOf(r+t),n=e.indexOf("--");return o!==-1&&(n===-1||o<n)}),St}var Mt,fo;function ra(){if(fo)return Mt;fo=1;const t=Ye,e=Ve,r=ta(),{env:o}=process;let n;r("no-color")||r("no-colors")||r("color=false")||r("color=never")?n=0:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(n=1),"FORCE_COLOR"in o&&(o.FORCE_COLOR==="true"?n=1:o.FORCE_COLOR==="false"?n=0:n=o.FORCE_COLOR.length===0?1:Math.min(parseInt(o.FORCE_COLOR,10),3));function s(a){return a===0?!1:{level:a,hasBasic:!0,has256:a>=2,has16m:a>=3}}function i(a,l){if(n===0)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(a&&!l&&n===void 0)return 0;const m=n||0;if(o.TERM==="dumb")return m;if(process.platform==="win32"){const c=t.release().split(".");return Number(c[0])>=10&&Number(c[2])>=10586?Number(c[2])>=14931?3:2:1}if("CI"in o)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(c=>c in o)||o.CI_NAME==="codeship"?1:m;if("TEAMCITY_VERSION"in o)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(o.TEAMCITY_VERSION)?1:0;if(o.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in o){const c=parseInt((o.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(o.TERM_PROGRAM){case"iTerm.app":return c>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(o.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(o.TERM)||"COLORTERM"in o?1:m}function u(a){const l=i(a,a&&a.isTTY);return s(l)}return Mt={supportsColor:u,stdout:s(i(!0,e.isatty(1))),stderr:s(i(!0,e.isatty(2)))},Mt}he.exports;var ho;function oa(){return ho||(ho=1,function(t,e){const r=Ve,o=Qt;e.init=m,e.log=u,e.formatArgs=s,e.save=a,e.load=l,e.useColors=n,e.destroy=o.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),e.colors=[6,2,3,4,5,1];try{const D=ra();D&&(D.stderr||D).level>=2&&(e.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{}e.inspectOpts=Object.keys(process.env).filter(D=>/^debug_/i.test(D)).reduce((D,d)=>{const f=d.substring(6).toLowerCase().replace(/_([a-z])/g,(g,E)=>E.toUpperCase());let h=process.env[d];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[f]=h,D},{});function n(){return"colors"in e.inspectOpts?!!e.inspectOpts.colors:r.isatty(process.stderr.fd)}function s(D){const{namespace:d,useColors:f}=this;if(f){const h=this.color,g="\x1B[3"+(h<8?h:"8;5;"+h),E=` ${g};1m${d} \x1B[0m`;D[0]=E+D[0].split(`
85
93
  `).join(`
86
- `+E),l.push(g+"m+"+e.exports.humanize(this.diff)+"\x1B[0m")}else l[0]=i()+p+" "+l[0]}function i(){return t.inspectOpts.hideDate?"":new Date().toISOString()+" "}function u(...l){return process.stderr.write(o.formatWithOptions(t.inspectOpts,...l)+`
87
- `)}function a(l){l?process.env.DEBUG=l:delete process.env.DEBUG}function D(){return process.env.DEBUG}function m(l){l.inspectOpts={};const p=Object.keys(t.inspectOpts);for(let d=0;d<p.length;d++)l.inspectOpts[p[d]]=t.inspectOpts[p[d]]}e.exports=oo()(t);const{formatters:c}=e.exports;c.o=function(l){return this.inspectOpts.colors=this.useColors,o.inspect(l,this.inspectOpts).split(`
88
- `).map(p=>p.trim()).join(" ")},c.O=function(l){return this.inspectOpts.colors=this.useColors,o.inspect(l,this.inspectOpts)}}(de,de.exports)),de.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?vt.exports=Hu():vt.exports=zu();var Ot=vt.exports,Mt={};Object.defineProperty(Mt,"__esModule",{value:!0});function Wu(e){return function(t,r){return new Promise((o,n)=>{e.call(this,t,r,(s,i)=>{s?n(s):o(i)})})}}Mt.default=Wu;var ao=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Ku=Yt,Vu=ao(Ot),Ju=ao(Mt),he=Vu.default("agent-base");function Yu(e){return!!e&&typeof e.addRequest=="function"}function It(){const{stack:e}=new Error;return typeof e!="string"?!1:e.split(`
89
- `).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}function Le(e,t){return new Le.Agent(e,t)}(function(e){class t extends Ku.EventEmitter{constructor(o,n){super();let s=n;typeof o=="function"?this.callback=o:o&&(s=o),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:It()?443:80}set defaultPort(o){this.explicitDefaultPort=o}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:It()?"https:":"http:"}set protocol(o){this.explicitProtocol=o}callback(o,n,s){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(o,n){const s=Object.assign({},n);typeof s.secureEndpoint!="boolean"&&(s.secureEndpoint=It()),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,o._last=!0,o.shouldKeepAlive=!1;let i=!1,u=null;const a=s.timeout||this.timeout,D=p=>{o._hadError||(o.emit("error",p),o._hadError=!0)},m=()=>{u=null,i=!0;const p=new Error(`A "socket" was not created for HTTP request before ${a}ms`);p.code="ETIMEOUT",D(p)},c=p=>{i||(u!==null&&(clearTimeout(u),u=null),D(p))},l=p=>{if(i)return;if(u!=null&&(clearTimeout(u),u=null),Yu(p)){he("Callback returned another Agent instance %o",p.constructor.name),p.addRequest(o,s);return}if(p){p.once("free",()=>{this.freeSocket(p,s)}),o.onSocket(p);return}const d=new Error(`no Duplex stream was returned to agent-base for \`${o.method} ${o.path}\``);D(d)};if(typeof this.callback!="function"){D(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(he("Converting legacy callback function to promise"),this.promisifiedCallback=Ju.default(this.callback)):this.promisifiedCallback=this.callback),typeof a=="number"&&a>0&&(u=setTimeout(m,a)),"port"in s&&typeof s.port!="number"&&(s.port=Number(s.port));try{he("Resolving socket for %o request: %o",s.protocol,`${o.method} ${o.path}`),Promise.resolve(this.promisifiedCallback(o,s)).then(l,c)}catch(p){Promise.reject(p).catch(c)}}freeSocket(o,n){he("Freeing socket %o %o",o.constructor.name,n),o.destroy()}destroy(){he("Destroying agent %o",this.constructor.name)}}e.Agent=t,e.prototype=e.Agent.prototype})(Le||(Le={}));var Xu=Le,Tt={},Zu=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Tt,"__esModule",{value:!0});const Qu=Zu(Ot),ge=Qu.default("https-proxy-agent:parse-proxy-response");function ea(e){return new Promise((t,r)=>{let o=0;const n=[];function s(){const c=e.read();c?m(c):e.once("readable",s)}function i(){e.removeListener("end",a),e.removeListener("error",D),e.removeListener("close",u),e.removeListener("readable",s)}function u(c){ge("onclose had error %o",c)}function a(){ge("onend")}function D(c){i(),ge("onerror %o",c),r(c)}function m(c){n.push(c),o+=c.length;const l=Buffer.concat(n,o);if(l.indexOf(`\r
94
+ `+E),D.push(g+"m+"+t.exports.humanize(this.diff)+"\x1B[0m")}else D[0]=i()+d+" "+D[0]}function i(){return e.inspectOpts.hideDate?"":new Date().toISOString()+" "}function u(...D){return process.stderr.write(o.formatWithOptions(e.inspectOpts,...D)+`
95
+ `)}function a(D){D?process.env.DEBUG=D:delete process.env.DEBUG}function l(){return process.env.DEBUG}function m(D){D.inspectOpts={};const d=Object.keys(e.inspectOpts);for(let f=0;f<d.length;f++)D.inspectOpts[d[f]]=e.inspectOpts[d[f]]}t.exports=Do()(e);const{formatters:c}=t.exports;c.o=function(D){return this.inspectOpts.colors=this.useColors,o.inspect(D,this.inspectOpts).split(`
96
+ `).map(d=>d.trim()).join(" ")},c.O=function(D){return this.inspectOpts.colors=this.useColors,o.inspect(D,this.inspectOpts)}}(he,he.exports)),he.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Pt.exports=ea():Pt.exports=oa();var Ot=Pt.exports,Rt={};Object.defineProperty(Rt,"__esModule",{value:!0});function na(t){return function(e,r){return new Promise((o,n)=>{t.call(this,e,r,(s,i)=>{s?n(s):o(i)})})}}Rt.default=na;var go=S&&S.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const sa=Xt,ia=go(Ot),ua=go(Rt),ge=ia.default("agent-base");function aa(t){return!!t&&typeof t.addRequest=="function"}function It(){const{stack:t}=new Error;return typeof t!="string"?!1:t.split(`
97
+ `).some(e=>e.indexOf("(https.js:")!==-1||e.indexOf("node:https:")!==-1)}function Te(t,e){return new Te.Agent(t,e)}(function(t){class e extends sa.EventEmitter{constructor(o,n){super();let s=n;typeof o=="function"?this.callback=o:o&&(s=o),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:It()?443:80}set defaultPort(o){this.explicitDefaultPort=o}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:It()?"https:":"http:"}set protocol(o){this.explicitProtocol=o}callback(o,n,s){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(o,n){const s=Object.assign({},n);typeof s.secureEndpoint!="boolean"&&(s.secureEndpoint=It()),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,o._last=!0,o.shouldKeepAlive=!1;let i=!1,u=null;const a=s.timeout||this.timeout,l=d=>{o._hadError||(o.emit("error",d),o._hadError=!0)},m=()=>{u=null,i=!0;const d=new Error(`A "socket" was not created for HTTP request before ${a}ms`);d.code="ETIMEOUT",l(d)},c=d=>{i||(u!==null&&(clearTimeout(u),u=null),l(d))},D=d=>{if(i)return;if(u!=null&&(clearTimeout(u),u=null),aa(d)){ge("Callback returned another Agent instance %o",d.constructor.name),d.addRequest(o,s);return}if(d){d.once("free",()=>{this.freeSocket(d,s)}),o.onSocket(d);return}const f=new Error(`no Duplex stream was returned to agent-base for \`${o.method} ${o.path}\``);l(f)};if(typeof this.callback!="function"){l(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(ge("Converting legacy callback function to promise"),this.promisifiedCallback=ua.default(this.callback)):this.promisifiedCallback=this.callback),typeof a=="number"&&a>0&&(u=setTimeout(m,a)),"port"in s&&typeof s.port!="number"&&(s.port=Number(s.port));try{ge("Resolving socket for %o request: %o",s.protocol,`${o.method} ${o.path}`),Promise.resolve(this.promisifiedCallback(o,s)).then(D,c)}catch(d){Promise.reject(d).catch(c)}}freeSocket(o,n){ge("Freeing socket %o %o",o.constructor.name,n),o.destroy()}destroy(){ge("Destroying agent %o",this.constructor.name)}}t.Agent=e,t.prototype=t.Agent.prototype})(Te||(Te={}));var ca=Te,kt={},la=S&&S.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(kt,"__esModule",{value:!0});const Da=la(Ot),Ce=Da.default("https-proxy-agent:parse-proxy-response");function ma(t){return new Promise((e,r)=>{let o=0;const n=[];function s(){const c=t.read();c?m(c):t.once("readable",s)}function i(){t.removeListener("end",a),t.removeListener("error",l),t.removeListener("close",u),t.removeListener("readable",s)}function u(c){Ce("onclose had error %o",c)}function a(){Ce("onend")}function l(c){i(),Ce("onerror %o",c),r(c)}function m(c){n.push(c),o+=c.length;const D=Buffer.concat(n,o);if(D.indexOf(`\r
90
98
  \r
91
- `)===-1){ge("have not received end of HTTP headers yet..."),s();return}const d=l.toString("ascii",0,l.indexOf(`\r
92
- `)),h=+d.split(" ")[1];ge("got proxy server response: %o",d),t({statusCode:h,buffered:l})}e.on("error",D),e.on("close",u),e.on("end",a),s()})}Tt.default=ea;var ta=$&&$.__awaiter||function(e,t,r,o){function n(s){return s instanceof r?s:new r(function(i){i(s)})}return new(r||(r=Promise))(function(s,i){function u(m){try{D(o.next(m))}catch(c){i(c)}}function a(m){try{D(o.throw(m))}catch(c){i(c)}}function D(m){m.done?s(m.value):n(m.value).then(u,a)}D((o=o.apply(e,t||[])).next())})},se=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty($t,"__esModule",{value:!0});const co=se(Jo),Do=se(Yo),ra=se(Xo),oa=se(Jt),na=se(Ot),sa=Xu,ia=se(Tt),Ce=na.default("https-proxy-agent:agent");class ua extends sa.Agent{constructor(t){let r;if(typeof t=="string"?r=ra.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 o=Object.assign({},r);this.secureProxy=r.secureProxy||Da(o.protocol),o.host=o.hostname||o.host,typeof o.port=="string"&&(o.port=parseInt(o.port,10)),!o.port&&o.host&&(o.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in o)&&(o.ALPNProtocols=["http 1.1"]),o.host&&o.path&&(delete o.path,delete o.pathname),this.proxy=o}callback(t,r){return ta(this,void 0,void 0,function*(){const{proxy:o,secureProxy:n}=this;let s;n?(Ce("Creating `tls.Socket`: %o",o),s=Do.default.connect(o)):(Ce("Creating `net.Socket`: %o",o),s=co.default.connect(o));const i=Object.assign({},o.headers);let a=`CONNECT ${`${r.host}:${r.port}`} HTTP/1.1\r
93
- `;o.auth&&(i["Proxy-Authorization"]=`Basic ${Buffer.from(o.auth).toString("base64")}`);let{host:D,port:m,secureEndpoint:c}=r;ca(m,c)||(D+=`:${m}`),i.Host=D,i.Connection="close";for(const g of Object.keys(i))a+=`${g}: ${i[g]}\r
94
- `;const l=ia.default(s);s.write(`${a}\r
95
- `);const{statusCode:p,buffered:d}=yield l;if(p===200){if(t.once("socket",aa),r.secureEndpoint){Ce("Upgrading socket connection to TLS");const g=r.servername||r.host;return Do.default.connect(Object.assign(Object.assign({},la(r,"host","hostname","path","port")),{socket:s,servername:g}))}return s}s.destroy();const h=new co.default.Socket({writable:!1});return h.readable=!0,t.once("socket",g=>{Ce("replaying proxy buffer for failed request"),oa.default(g.listenerCount("data")>0),g.push(d),g.push(null)}),h})}}$t.default=ua;function aa(e){e.resume()}function ca(e,t){return!!(!t&&e===80||t&&e===443)}function Da(e){return typeof e=="string"?/^https:?$/i.test(e):!1}function la(e,...t){const r={};let o;for(o in e)t.includes(o)||(r[o]=e[o]);return r}var ma=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const kt=ma($t);function Lt(e){return new kt.default(e)}(function(e){e.HttpsProxyAgent=kt.default,e.prototype=kt.default.prototype})(Lt||(Lt={}));var pa=Lt,fa=Z(pa);const da=async(e,t,r,o,n,s,i)=>new Promise((u,a)=>{const D=JSON.stringify(o),c=(e.protocol.includes("https")?Vo:Ko).request({port:i||void 0,hostname:e.hostname,path:t,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(D),...r},timeout:n,agent:s?fa(s):void 0},l=>{const p=[];l.on("data",d=>p.push(d)),l.on("end",()=>{u({request:c,response:l,data:Buffer.concat(p).toString()})})});c.on("error",a),c.on("timeout",()=>{c.destroy(),a(new y(`Time out error: request took over ${n}ms. Try increasing the \`timeout\` config`))}),c.write(D),c.end()}),ha=async(e,t,r,o,n,s)=>{const i=new URL(e),{response:u,data:a}=await da(i,t,{Authorization:`Bearer ${r}`},o,n,s);if(!u.statusCode||u.statusCode<200||u.statusCode>299){let D=`OpenAI API Error: ${u.statusCode} - ${u.statusMessage}`;throw a&&(D+=`
99
+ `)===-1){Ce("have not received end of HTTP headers yet..."),s();return}const f=D.toString("ascii",0,D.indexOf(`\r
100
+ `)),h=+f.split(" ")[1];Ce("got proxy server response: %o",f),e({statusCode:h,buffered:D})}t.on("error",l),t.on("close",u),t.on("end",a),s()})}kt.default=ma;var da=S&&S.__awaiter||function(t,e,r,o){function n(s){return s instanceof r?s:new r(function(i){i(s)})}return new(r||(r=Promise))(function(s,i){function u(m){try{l(o.next(m))}catch(c){i(c)}}function a(m){try{l(o.throw(m))}catch(c){i(c)}}function l(m){m.done?s(m.value):n(m.value).then(u,a)}l((o=o.apply(t,e||[])).next())})},se=S&&S.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(At,"__esModule",{value:!0});const Co=se(pn),Eo=se(fn),pa=se(hn),fa=se(Yt),ha=se(Ot),ga=ca,Ca=se(kt),Ee=ha.default("https-proxy-agent:agent");class Ea extends ga.Agent{constructor(e){let r;if(typeof e=="string"?r=pa.default.parse(e):r=e,!r)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");Ee("creating new HttpsProxyAgent instance: %o",r),super(r);const o=Object.assign({},r);this.secureProxy=r.secureProxy||wa(o.protocol),o.host=o.hostname||o.host,typeof o.port=="string"&&(o.port=parseInt(o.port,10)),!o.port&&o.host&&(o.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in o)&&(o.ALPNProtocols=["http 1.1"]),o.host&&o.path&&(delete o.path,delete o.pathname),this.proxy=o}callback(e,r){return da(this,void 0,void 0,function*(){const{proxy:o,secureProxy:n}=this;let s;n?(Ee("Creating `tls.Socket`: %o",o),s=Eo.default.connect(o)):(Ee("Creating `net.Socket`: %o",o),s=Co.default.connect(o));const i=Object.assign({},o.headers);let a=`CONNECT ${`${r.host}:${r.port}`} HTTP/1.1\r
101
+ `;o.auth&&(i["Proxy-Authorization"]=`Basic ${Buffer.from(o.auth).toString("base64")}`);let{host:l,port:m,secureEndpoint:c}=r;ya(m,c)||(l+=`:${m}`),i.Host=l,i.Connection="close";for(const g of Object.keys(i))a+=`${g}: ${i[g]}\r
102
+ `;const D=Ca.default(s);s.write(`${a}\r
103
+ `);const{statusCode:d,buffered:f}=yield D;if(d===200){if(e.once("socket",Fa),r.secureEndpoint){Ee("Upgrading socket connection to TLS");const g=r.servername||r.host;return Eo.default.connect(Object.assign(Object.assign({},va(r,"host","hostname","path","port")),{socket:s,servername:g}))}return s}s.destroy();const h=new Co.default.Socket({writable:!1});return h.readable=!0,e.once("socket",g=>{Ee("replaying proxy buffer for failed request"),fa.default(g.listenerCount("data")>0),g.push(f),g.push(null)}),h})}}At.default=Ea;function Fa(t){t.resume()}function ya(t,e){return!!(!e&&t===80||e&&t===443)}function wa(t){return typeof t=="string"?/^https:?$/i.test(t):!1}function va(t,...e){const r={};let o;for(o in t)e.includes(o)||(r[o]=t[o]);return r}var ba=S&&S.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const Nt=ba(At);function Lt(t){return new Nt.default(t)}(function(t){t.HttpsProxyAgent=Nt.default,t.prototype=Nt.default.prototype})(Lt||(Lt={}));var $a=Lt,Aa=Q($a);const Pa=async(t,e,r,o,n,s,i)=>new Promise((u,a)=>{const l=JSON.stringify(o),c=(t.protocol.includes("https")?dn:mn).request({port:i||void 0,hostname:t.hostname,path:e,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(l),...r},timeout:n,agent:s?Aa(s):void 0},D=>{const d=[];D.on("data",f=>d.push(f)),D.on("end",()=>{u({request:c,response:D,data:Buffer.concat(d).toString()})})});c.on("error",a),c.on("timeout",()=>{c.destroy(),a(new y(`Time out error: request took over ${n}ms. Try increasing the \`timeout\` config`))}),c.write(l),c.end()}),Ba=async(t,e,r,o,n,s)=>{const i=new URL(t),{response:u,data:a}=await Pa(i,e,{Authorization:`Bearer ${r}`},o,n,s);if(!u.statusCode||u.statusCode<200||u.statusCode>299){let l=`OpenAI API Error: ${u.statusCode} - ${u.statusMessage}`;throw a&&(l+=`
96
104
 
97
- ${a}`),u.statusCode===500&&(D+=`
105
+ ${a}`),u.statusCode===500&&(l+=`
98
106
 
99
- Check the API status: https://status.openai.com`),new y(D)}return JSON.parse(a)},Ne=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),ga=async(e,t,r,o,n,s,i,u,a,D,m,c)=>{try{const l={model:o,messages:[{role:"system",content:D},{role:"user",content:`Here is the diff: ${n}`}],temperature:u,max_tokens:i,stream:!1,n:1,top_p:a,frequency_penalty:0,presence_penalty:0},p=await ha(e,t,r,l,s,c),d=p.choices.filter(h=>h.message?.content).map(h=>Ne(h.message.content)).join();return m&&G("OPENAI",n,D,d),p.choices.filter(h=>h.message?.content).map(h=>Ne(h.message.content))}catch(l){const p=l;throw p.code==="ENOTFOUND"?new y(`Error connecting to ${p.hostname} (${p.syscall})`):p}};class Ca extends j{constructor(t){super(t),this.params=t,this.handleError$=r=>{let o="An error occurred";const n=/"message":\s*"([^"]*)"/,s=r.message.match(n);s&&s[1]&&(o=s[1]);const i=`${r.status} ${o}`;return O({name:`${this.errorPrefix} ${i}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#f55036",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Groq]"),this.errorPrefix=C.red.bold("[Groq]"),this.groq=new Wo({apiKey:this.params.config.key})}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:o,logging:n,locale:s,temperature:i,generate:u,type:a,maxLength:D}=this.params.config,m=this.params.config.maxTokens,c={...k,locale:s,maxLength:D,type:a,generate:u,systemPrompt:r,systemPromptPath:o},l=H(c),p=await this.groq.chat.completions.create({messages:[{role:"system",content:l},{role:"user",content:`Here is the diff: ${t}`}],model:this.params.config.model,max_tokens:m,top_p:this.params.config.topP,temperature:i},{timeout:this.params.config.timeout}),d=p.choices.filter(g=>g.message?.content).map(g=>Ne(g.message.content)).join();n&&G("Groq",t,l,d);const h=p.choices.filter(g=>g.message?.content).map(g=>Ne(g.message.content));return ke(h.map(g=>this.parseMessage(g,a,u)))}catch(t){throw t}}}class Fa extends j{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=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[HuggingFace]"),this.errorPrefix=C.red.bold("[HuggingFace]"),this.cookie=this.params.config.cookie}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{await this.intialize();const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:o,logging:n,locale:s,generate:i,type:u,maxLength:a}=this.params.config,D={...k,locale:s,maxLength:a,type:u,generate:i,systemPrompt:r,systemPromptPath:o},m=H(D),c=await this.getNewChat(m),p=await(await this.sendMessage(`Here is the diff: ${t}`,c.id)).completeResponsePromise();return n&&G("HuggingFace",t,m,p),this.parseMessage(p,u,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async intialize(){const t=await this.getRemoteLlms(),r=t.find(o=>o.name?.toLowerCase()===this.params.config.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 o=(await t.json()).nodes[0].data,n=o[o[0].models],s=[],i=u=>u===-1?null:o[u];for(const u of n){const a=o[u];if(o[a.unlisted])continue;const D={id:i(a.id),name:i(a.name),displayName:i(a.displayName),preprompt:i(a.preprompt),promptExamples:[],websiteUrl:i(a.websiteUrl),description:i(a.description),datasetName:i(a.datasetName),datasetUrl:i(a.datasetUrl),modelUrl:i(a.modelUrl),parameters:{}},m=i(a.promptExamples);if(m!==null){const p=m.map(d=>i(d));D.promptExamples=p.map(d=>({title:o[d.title],prompt:o[d.prompt]}))}const c=i(a.parameters),l={};for(const[p,d]of Object.entries(c)){if(d===-1){l[p]=null;continue}if(Array.isArray(o[d])){l[p]=o[d].map(h=>o[h]);continue}l[p]=o[d]}D.parameters=l,s.push(D)}return this.models=s,s}async getNewChat(t){const r={model:this.currentModelId,preprompt:t};let o=0;for(;o<5;){const n=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 n.json();if(s){this.currentConversionID=s;break}else o++}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 o=await r.json();return this.metadataParser(o,t)}}metadataParser(t,r){const o={id:"",model:"",systemPrompt:"",title:"",history:[]},n=t.nodes[1].data,s=n[n[0].model],i=n[n[0].preprompt],u=n[n[0].title],a=n[n[0].messages],D=[];for(const m of a){const c=n[m],l=new Date(n[c.createdAt][1]).getTime()/1e3,p=new Date(n[c.updatedAt][1]).getTime()/1e3;D.push({id:n[c.id],role:n[c.from],content:n[c.content],createdAt:l,updatedAt:p})}return o.id=r,o.model=s,o.systemPrompt=i,o.title=u,o.history=D,this.currentConversation=o,o}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 o={inputs:t,id:this.currentConversation.history[this.currentConversation.history.length-1].id,is_retry:!1,is_continue:!1,web_search:!1,tools:[]},n=new FormData;n.append("data",JSON.stringify(o));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:n,method:"POST"});function i(l){try{const p=l.split(`
100
- `),d=[];for(const h of p)h.trim()&&d.push(JSON.parse(h));return d}catch{return[{}]}}const u=new TextDecoder;let a="";const D=new TransformStream({async transform(l,p){const d=u.decode(l);try{const h=i(d);for(const g of h)g.type==="finalAnswer"?(a=g?.text||"",p.terminate()):g.type==="stream"&&p.enqueue(g?.token||"")}catch{throw new Error("Error during parsing response")}}}),m=s.body?.pipeThrough(D);async function c(){return new Promise(async(l,p)=>{try{if(!m)p("ModifiedStream undefined");else{const d=m.getReader();for(;;){const{done:h,value:g}=await d.read();if(h){l(a);break}}}}catch(d){p(d)}})}return{id:this.currentConversionID,stream:m,completeResponsePromise:c}}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()}}class ya extends j{constructor(t){super(t),this.params=t,this.host="https://api.mistral.ai",this.apiKey="",this.handleError$=r=>{const o=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return O({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#ff7000",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[MistralAI]"),this.errorPrefix=C.red.bold("[MistralAI]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:o,logging:n,locale:s,generate:i,type:u,maxLength:a}=this.params.config,D={...k,locale:s,maxLength:a,type:u,generate:i,systemPrompt:r,systemPromptPath:o},m=H(D);await this.checkAvailableModels();const c=await this.createChatCompletions(m,`Here is the diff: ${t}`);return n&&G("MistralAI",t,m,c),this.parseMessage(c,this.params.config.type,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkAvailableModels(){if((await this.getAvailableModels()).includes(this.params.config.model))return!0;throw new Error(`Invalid model type of Mistral AI: ${this.params.config.model}`)}async getAvailableModels(){return(await new ne({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,r){const n=(await new ne({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.model,messages:[{role:"system",content:t},{role:"user",content:r}],temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1,safe_prompt:!1,random_seed:Te(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:Nt}=Object.prototype,Re=typeof process<"u"&&process.platform==="win32"?`\r
107
+ Check the API status: https://status.openai.com`),new y(l)}return JSON.parse(a)},_e=t=>t.trim(),xa=async(t,e,r,o,n,s,i,u,a,l,m,c,D)=>{try{const d={model:o,messages:[{role:"system",content:l},{role:"user",content:`Here is the diff: ${n}`}],temperature:u,max_tokens:i,stream:!1,n:1,top_p:a,frequency_penalty:0,presence_penalty:0},f=await Ba(t,e,r,d,s,D),h=f.choices.filter(g=>g.message?.content).map(g=>_e(g.message.content)).join();return m&&j("OPENAI",n,l,h,c),f.choices.filter(g=>g.message?.content).map(g=>_e(g.message.content))}catch(d){const f=d;throw f.code==="ENOTFOUND"?new y(`Error connecting to ${f.hostname} (${f.syscall})`):f}};class Fo extends _{constructor(e){super(e),this.params=e,this.handleError$=r=>{let o="An error occurred";const n=/"message":\s*"([^"]*)"/,s=r.message.match(n);s&&s[1]&&(o=s[1]);const i=`${r.status} ${o}`;return R({name:`${this.errorPrefix} ${i}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#f55036",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Groq]"),this.errorPrefix=C.red.bold("[Groq]"),this.groq=new Dn({apiKey:this.params.config.key})}generateCommitMessage$(){return B(this.generateMessage("commit")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return B(this.generateMessage("review")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,locale:u,temperature:a,generate:l,type:m,maxLength:c}=this.params.config,D=this.params.config.maxTokens,d={...L,locale:u,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},f=e==="review"?H(d):G(d),h=await this.groq.chat.completions.create({messages:[{role:"system",content:f},{role:"user",content:`Here is the diff: ${r}`}],model:this.params.config.model,max_tokens:D,top_p:this.params.config.topP,temperature:a},{timeout:this.params.config.timeout}),g=h.choices.filter(F=>F.message?.content).map(F=>_e(F.message.content)).join();i&&j("Groq",r,f,g,e);const E=h.choices.filter(F=>F.message?.content).map(F=>_e(F.message.content));return oe(e==="review"?E.map(F=>this.sanitizeResponse(F)):E.map(F=>this.parseMessage(F,m,l)))}catch(r){throw r}}}class yo extends _{constructor(e){super(e),this.params=e,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=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[HuggingFace]"),this.errorPrefix=C.red.bold("[HuggingFace]"),this.cookie=this.params.config.cookie}generateCommitMessage$(){return B(this.generateMessage("commit")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return B(this.generateMessage("review")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{await this.intialize();const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,locale:u,generate:a,type:l,maxLength:m}=this.params.config,c={...L,locale:u,maxLength:m,type:l,generate:a,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},D=e==="review"?H(c):G(c),d=await this.getNewChat(D),h=await(await this.sendMessage(`Here is the diff: ${r}`,d.id)).completeResponsePromise();return await this.deleteConversation(d.id),i&&j("HuggingFace",r,D,h,e),e==="review"?this.sanitizeResponse(h):this.parseMessage(h,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new y(`Error connecting to ${o.hostname} (${o.syscall})`):o}}async intialize(){const e=await this.getRemoteLlms(),r=e.find(o=>o.name?.toLowerCase()===this.params.config.model.toLowerCase());if(r){this.currentModel=r,this.currentModelId=r.id;return}this.currentModel=e[0],this.currentModelId=e[0].id}async getRemoteLlms(){const e=await fetch("https://huggingface.co/chat/__data.json",{headers:{...this.headers,cookie:this.cookie},body:null,method:"GET"});if(e.status!==200)throw new Error(`Failed to get remote LLMs with status code: ${e.status}`);const o=(await e.json()).nodes[0].data,n=o[o[0].models],s=[],i=u=>u===-1?null:o[u];for(const u of n){const a=o[u];if(o[a.unlisted])continue;const l={id:i(a.id),name:i(a.name),displayName:i(a.displayName),preprompt:i(a.preprompt),promptExamples:[],websiteUrl:i(a.websiteUrl),description:i(a.description),datasetName:i(a.datasetName),datasetUrl:i(a.datasetUrl),modelUrl:i(a.modelUrl),parameters:{}},m=i(a.promptExamples);if(m!==null){const d=m.map(f=>i(f));l.promptExamples=d.map(f=>({title:o[f.title],prompt:o[f.prompt]}))}const c=i(a.parameters),D={};for(const[d,f]of Object.entries(c)){if(f===-1){D[d]=null;continue}if(Array.isArray(o[f])){D[d]=o[f].map(h=>o[h]);continue}D[d]=o[f]}l.parameters=D,s.push(l)}return this.models=s,s}async getNewChat(e){const r={model:this.currentModelId,preprompt:e};let o=0;for(;o<5;){const n=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 n.json();if(s){this.currentConversionID=s;break}else o++}if(!this.currentConversionID)throw new Error("Failed to create new conversion");return await this.getConversationHistory(this.currentConversionID)}async getConversationHistory(e){if(!e)throw new Error("conversationId is required for getConversationHistory");const r=await fetch("https://huggingface.co/chat/conversation/"+e+"/__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 o=await r.json();return this.metadataParser(o,e)}}metadataParser(e,r){const o={id:"",model:"",systemPrompt:"",title:"",history:[]},n=e.nodes[1].data,s=n[n[0].model],i=n[n[0].preprompt],u=n[n[0].title],a=n[n[0].messages],l=[];for(const m of a){const c=n[m],D=new Date(n[c.createdAt][1]).getTime()/1e3,d=new Date(n[c.updatedAt][1]).getTime()/1e3;l.push({id:n[c.id],role:n[c.from],content:n[c.content],createdAt:D,updatedAt:d})}return o.id=r,o.model=s,o.systemPrompt=i,o.title=u,o.history=l,this.currentConversation=o,o}async sendMessage(e,r){if(e==="")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 o={inputs:e,id:this.currentConversation.history[this.currentConversation.history.length-1].id,is_retry:!1,is_continue:!1,web_search:!1,tools:[]},n=new FormData;n.append("data",JSON.stringify(o));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:n,method:"POST"});function i(D){try{const d=D.split(`
108
+ `),f=[];for(const h of d)h.trim()&&f.push(JSON.parse(h));return f}catch{return[{}]}}const u=new TextDecoder;let a="";const l=new TransformStream({async transform(D,d){const f=u.decode(D);try{const h=i(f);for(const g of h)g.type==="finalAnswer"?(a=g?.text||"",d.terminate()):g.type==="stream"&&d.enqueue(g?.token||"")}catch{throw new Error("Error during parsing response")}}}),m=s.body?.pipeThrough(l);async function c(){return new Promise(async(D,d)=>{try{if(!m)d("ModifiedStream undefined");else{const f=m.getReader();for(;;){const{done:h,value:g}=await f.read();if(h){D(a);break}}}}catch(f){d(f)}})}return{id:this.currentConversionID,stream:m,completeResponsePromise:c}}async deleteConversation(e){return(await fetch(`https://huggingface.co/chat/conversation/${e}`,{headers:{...this.headers,cookie:this.cookie,Referer:"https://huggingface.co/chat/"},body:null,method:"DELETE"})).json()}}class wo extends _{constructor(e){super(e),this.params=e,this.host="https://api.mistral.ai",this.apiKey="",this.handleError$=r=>{const o=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return R({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#ff7000",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[MistralAI]"),this.errorPrefix=C.red.bold("[MistralAI]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return B(this.generateMessage("commit")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return B(this.generateMessage("review")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,locale:u,generate:a,type:l,maxLength:m}=this.params.config,c={...L,locale:u,maxLength:m,type:l,generate:a,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},D=e==="review"?H(c):G(c);await this.checkAvailableModels();const d=await this.createChatCompletions(D,`Here is the diff: ${r}`);return i&&j("MistralAI",r,D,d,e),e==="review"?this.sanitizeResponse(d):this.parseMessage(d,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new y(`Error connecting to ${o.hostname} (${o.syscall})`):o}}async checkAvailableModels(){if((await this.getAvailableModels()).includes(this.params.config.model))return!0;throw new Error(`Invalid model type of Mistral AI: ${this.params.config.model}`)}async getAvailableModels(){return(await new ne({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(e,r){const n=(await new ne({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.model,messages:[{role:"system",content:e},{role:"user",content:r}],temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1,safe_prompt:!1,random_seed:Ne(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:Tt}=Object.prototype,je=typeof process<"u"&&process.platform==="win32"?`\r
101
109
  `:`
102
- `,Rt=(e,t)=>{const r=[];let o="";typeof t=="string"?t={section:t,whitespace:!1}:(t=t||Object.create(null),t.whitespace=t.whitespace===!0);const n=t.whitespace?" = ":"=";for(const s of Object.keys(e)){const i=e[s];if(i&&Array.isArray(i))for(const u of i)o+=ie(s+"[]")+n+ie(u)+Re;else i&&typeof i=="object"?r.push(s):o+=ie(s)+n+ie(i)+Re}t.section&&o.length&&(o="["+ie(t.section)+"]"+Re+o);for(const s of r){const i=lo(s).join("\\."),u=(t.section?t.section+".":"")+i,{whitespace:a}=t,D=Rt(e[s],{section:u,whitespace:a});o.length&&D.length&&(o+=Re),o+=D}return o},lo=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),mo=e=>{const t=Object.create(null);let r=t,o=null;const n=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,s=e.split(/[\r\n]+/g);for(const u of s){if(!u||u.match(/^\s*[;#]/))continue;const a=u.match(n);if(!a)continue;if(a[1]!==void 0){if(o=_e(a[1]),o==="__proto__"){r=Object.create(null);continue}r=t[o]=t[o]||Object.create(null);continue}const D=_e(a[2]),m=D.length>2&&D.slice(-2)==="[]",c=m?D.slice(0,-2):D;if(c==="__proto__")continue;const l=a[3]?_e(a[4]):!0,p=l==="true"||l==="false"||l==="null"?JSON.parse(l):l;m&&(Nt.call(r,c)?Array.isArray(r[c])||(r[c]=[r[c]]):r[c]=[]),Array.isArray(r[c])?r[c].push(p):r[c]=p}const i=[];for(const u of Object.keys(t)){if(!Nt.call(t,u)||typeof t[u]!="object"||Array.isArray(t[u]))continue;const a=lo(u);r=t;const D=a.pop(),m=D.replace(/\\\./g,".");for(const c of a)c!=="__proto__"&&((!Nt.call(r,c)||typeof r[c]!="object")&&(r[c]=Object.create(null)),r=r[c]);r===t&&m===D||(r[m]=t[u],i.push(u))}for(const u of i)delete t[u];return t},po=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),ie=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&po(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),_e=(e,t)=>{if(e=(e||"").trim(),po(e)){e.charAt(0)==="'"&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let r=!1,o="";for(let n=0,s=e.length;n<s;n++){const i=e.charAt(n);if(r)"\\;#".indexOf(i)!==-1?o+=i:o+="\\"+i,r=!1;else{if(";#".indexOf(i)!==-1)break;i==="\\"?r=!0:o+=i}}return r&&(o+="\\"),o.trim()}return e};var Ea={parse:mo,decode:mo,stringify:Rt,encode:Rt,safe:ie,unsafe:_e},_t=Z(Ea);const fo=e=>P.lstat(e).then(()=>!0,()=>!1),ba=["","conventional","gitmoji"],jt="http://localhost:11434",{hasOwnProperty:wa}=Object.prototype,je=(e,t)=>wa.call(e,t),Gt=["OPENAI","OLLAMA","HUGGINGFACE","GEMINI","ANTHROPIC","MISTRAL","CODESTRAL","COHERE","GROQ","PERPLEXITY","DEEPSEEK"],F=(e,t,r)=>{if(!t)throw new y(`Invalid config property ${e}: ${r}`)},f={systemPrompt(e){return e||""},systemPromptPath(e){return e||""},timeout(e){if(!e)return 1e4;F("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return F("timeout",t>=500,"Must be greater than 500ms"),t},temperature(e){if(!e)return .7;F("temperature",/^(2|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 2");const t=Number(e);return F("temperature",t>0,"Must be greater than 0"),F("temperature",t<=2,"Must be less than or equal to 2"),t},maxTokens(e){return e?(F("maxTokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):1024},logging(e){return typeof e=="boolean"?e:e==null?!0:(F("logging",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true")},locale(e){return e?(F("locale",e,"Cannot be empty"),F("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;F("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return F("generate",t>0,"Must be greater than 0"),F("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(F("type",ba.includes(e),"Invalid commit type"),e):"conventional"},maxLength(e){if(!e)return 50;F("maxLength",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return F("maxLength",t>=20,"Must be greater than 20 characters"),t},ignoreBody(e){return typeof e=="boolean"?e:e==null?!0:(F("ignoreBody",/^(?:true|false)$/.test(e),"Must be a boolean(true or false)"),e==="true")},exclude:e=>e?(typeof e=="string"?e?.split(","):e).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[],topP:e=>{if(!e)return .9;F("topP",/^(1|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 1");const t=Number(e);return F("topP",t>0,"Must be greater than 0"),F("topP",t<=1,"Must be less than or equal to 1"),t}},ue={OPENAI:{key:e=>e||"",model:e=>e||"gpt-4o-mini",url:e=>e?(F("OPENAI.url",/^https?:\/\//.test(e),"Must be a valid URL"),e):"https://api.openai.com",path:e=>e||"/v1/chat/completions",proxy:e=>e||"",topP:f.topP,systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,timeout:f.timeout,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody},HUGGINGFACE:{cookie:e=>e||"",model:e=>e?(F("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):"CohereForAI/c4ai-command-r-plus",systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody},GEMINI:{key:e=>e||"",model:e=>!e||e.length===0?"gemini-1.5-pro":(F("GEMINI.model",["gemini-1.5-flash","gemini-1.5-pro","gemini-1.5-pro-exp-0801"].includes(e),"Invalid model type of Gemini"),e),systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody,topP:f.topP},ANTHROPIC:{key:e=>e||"",model:e=>!e||e.length===0?"claude-3-haiku-20240307":(F("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),systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody,topP:f.topP},MISTRAL:{key:e=>e||"",model:e=>!e||e.length===0?"mistral-tiny":(F("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),systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,timeout:f.timeout,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody,topP:f.topP},CODESTRAL:{key:e=>e||"",model:e=>!e||e.length===0?"codestral-latest":(F("CODESTRAL.model",["codestral-latest","codestral-2405"].includes(e),"Invalid model type of Codestral"),e),topP:f.topP,systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,timeout:f.timeout,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody},OLLAMA:{model:e=>e?(typeof e=="string"?e?.split(","):e).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[],host:e=>e?(F("OLLAMA.host",/^https?:\/\//.test(e),"Must be a valid URL"),e):jt,timeout:e=>{if(!e)return 1e5;F("OLLAMA.timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return F("OLLAMA.timeout",t>=500,"Must be greater than 500ms"),t},systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,temperature:f.temperature,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody,topP:f.topP},COHERE:{key:e=>e||"",model:e=>!e||e.length===0?"command":(F("COHERE.model",["command","command-nightly","command-light","command-light-nightly"].includes(e),"Invalid model type of Cohere"),e),systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody,topP:f.topP},GROQ:{key:e=>e||"",model:e=>!e||e.length===0?"gemma2-9b-it":(F("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","llama-guard-3-8b","mixtral-8x7b-32768"].includes(e),"Invalid model type of Groq"),e),systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,timeout:f.timeout,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody,topP:f.topP},PERPLEXITY:{key:e=>e||"",model:e=>!e||e.length===0?"llama-3.1-sonar-small-128k-chat":(F("PERPLEXITY.model",["llama-3.1-sonar-small-128k-online","llama-3.1-sonar-small-128k-chat","llama-3.1-sonar-large-128k-online","llama-3.1-sonar-large-128k-chat","llama-3.1-8b-instruct","llama-3.1-70b-instruct"].includes(e),"Invalid model type of Perplexity"),e),topP:f.topP,systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,timeout:f.timeout,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody},DEEPSEEK:{key:e=>e||"",model:e=>!e||e.length===0?"deepseek-coder":(F("DEEPSEEK.model",["deepseek-coder","deepseek-chat"].includes(e),"Invalid model type of DeepSeek"),e),topP:f.topP,systemPrompt:f.systemPrompt,systemPromptPath:f.systemPromptPath,timeout:f.timeout,temperature:f.temperature,maxTokens:f.maxTokens,logging:f.logging,locale:f.locale,generate:f.generate,type:f.type,maxLength:f.maxLength,ignoreBody:f.ignoreBody}},Ge=L.join(Je.homedir(),".aicommit2"),Aa=(e=[])=>{const t={};for(const r of e)if(r.startsWith("--")){const[o,n]=r.slice(2).split("="),[s,i]=o.split(".");s&&i&&s in ue?(t[s]||(t[s]={}),t[s][i]=n):t[o]=n}return t},Ht=async()=>{if(!await fo(Ge))return Object.create(null);const t=await P.readFile(Ge,"utf8");let r=_t.parse(t);return je(r,"OLLAMA")&&je(r.OLLAMA,"model")&&(r={...r,OLLAMA:{...r.OLLAMA,model:typeof r.OLLAMA.model=="string"?[r.OLLAMA.model]:r.OLLAMA.model}}),je(r,"exclude")&&(r={...r,exclude:typeof r.exclude=="string"?[r.exclude]:r.exclude}),r},Ut=async(e,t=[])=>{const r=await Ht(),o=Aa(t),n={...e,...o},s={},i=(u,a)=>{const D=n[`${u}.${a}`]??n[u]?.[a],m=r[u]?.[a],c=n[a]??r[a];return D!==void 0?D:m!==void 0?m:c};for(const[u,a]of Object.entries(f)){const D=n[u]??r[u];s[u]=a(D)}for(const[u,a]of Object.entries(ue)){s[u]={};for(const[D,m]of Object.entries(a)){const c=i(u,D);s[u][D]=m(c)}}return s},$a=async e=>{const t=await Ht();for(const[r,o]of e){const[n,s]=r.split(".");if(n in ue){t[n]||(t[n]={});const i=ue[n][s];if(!i)throw new y(`Invalid config property: ${r}`);t[n][s]=i(o)}else{const i=f[r];if(!i)throw new y(`Invalid config property: ${r}`);t[r]=i(o)}}await P.writeFile(Ge,_t.stringify(t),"utf8")},va=async e=>{const t=await Ht();for(const[r,o]of e){const[n,s]=r.split(".");if(n in ue){t[n]||(t[n]={});const i=n==="OLLAMA"&&s==="model",u=ue[n][s];if(!u||!i)throw new y(`Invalid config property: ${r}. Only supports OLLAMA.model`);const a=t[n][s]||[];t[n][s]=ke([...a,u(o)])}else throw new y(`Invalid config property: ${r}. Only supports OLLAMA.model`)}await P.writeFile(Ge,_t.stringify(t),"utf8")};class Ba extends j{constructor(t){super(t),this.params=t,this.host=jt,this.model="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return O({name:`${this.errorPrefix} ${r.response.data?.error}`,value:r.response.data?.error,isError:!0,disabled:!0});const o=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return O({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#FFF",secondary:"#000"},this.model=this.params.keyName,this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${eo(this.model)}]`),this.errorPrefix=C.red.bold(`[${eo(this.model)}]`),this.host=this.params.config.host||jt,this.ollama=new en({host:this.host})}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),T(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:o,logging:n,locale:s,generate:i,type:u,maxLength:a}=this.params.config,D={...k,locale:s,maxLength:a,type:u,generate:i,systemPrompt:r,systemPromptPath:o},m=H(D);await this.checkIsAvailableOllama();const c=await this.createChatCompletions(m,`Here is the diff: ${t}`);return n&&G(`Ollama_${this.model}`,t,m,c),this.parseMessage(c,u,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkIsAvailableOllama(){try{return(await new ne({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.timeout}).execute()).data}catch(t){throw t.code==="ECONNREFUSED"?new y(`Error connecting to ${this.host}. Please run Ollama or check host`):t}}async createChatCompletions(t,r){return(await this.ollama.chat({model:this.model,messages:[{role:"system",content:t},{role:"user",content:r}],stream:!1,options:{temperature:this.params.config.temperature,top_p:this.params.config.topP,seed:Te(10,1e3)}})).message.content}}class xa extends j{constructor(t){super(t),this.params=t,this.handleError$=r=>{let o="An error occurred";if(r.message){o=r.message.split(`
103
- `)[0];const n=this.extractJSONFromError(r.message);o+=`: ${n.error.message}`}return O({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=C.red.bold("[ChatGPT]")}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),T(this.handleError$))}extractJSONFromError(t){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,o=t.match(r);return o?Object.assign({},...o.map(n=>JSON.parse(n))):{error:{message:"Unknown error"}}}async generateMessage(){const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:o,temperature:n,logging:s,locale:i,generate:u,type:a,maxLength:D,proxy:m,maxTokens:c,timeout:l}=this.params.config,p={...k,locale:i,maxLength:D,type:a,generate:u,systemPrompt:r,systemPromptPath:o},d=H(p),h=await ga(this.params.config.url,this.params.config.path,this.params.config.key,this.params.config.model,t,l,c,n,this.params.config.topP,d,s,m);return ke(h.map(g=>this.parseMessage(g,a,u)))}}class Pa extends j{constructor(t){super(t),this.params=t,this.host="https://api.perplexity.ai",this.apiKey="",this.handleError$=r=>{let o="An error occurred";if(r.message){o=r.message.split(`
104
- `)[0];const n=this.extractJSONFromError(r.message);o+=`: ${n.error.message}`}return O({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#20808D",secondary:"#FFF"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Perplexity]"),this.errorPrefix=C.red.bold("[Perplexity]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return R(this.generateMessage()).pipe(N(t=>M(t)),I(t=>({name:`${this.serviceName} ${t.title}`,short:t.title,value:this.params.config.ignoreBody?t.title:t.value,description:this.params.config.ignoreBody?"":t.value,isError:!1})),T(this.handleError$))}extractJSONFromError(t){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,o=t.match(r);return o?Object.assign({},...o.map(n=>JSON.parse(n))):{error:{message:"Unknown error"}}}async generateMessage(){try{const t=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:o,logging:n,locale:s,generate:i,type:u,maxLength:a}=this.params.config,D={...k,locale:s,maxLength:a,type:u,generate:i,systemPrompt:r,systemPromptPath:o},m=H(D),c=await this.createChatCompletions(m,t);return n&&G("Perplexity",t,m,c),this.parseMessage(c,u,i)}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async createChatCompletions(t,r){const n=(await new ne({method:"POST",baseURL:`${this.host}/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.model,messages:[{role:"system",content:`${t}`},{role:"user",content:`Here is the diff: ${r}`}],temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1}).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 ho{constructor(t,r){this.config=t,this.stagedDiff=r}createAIRequests$(t){return M(t).pipe(Zt(r=>{switch(r){case"OPENAI":return _.create(xa,{config:this.config.OPENAI,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"GEMINI":return _.create(ju,{config:this.config.GEMINI,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"ANTHROPIC":return _.create(ku,{config:this.config.ANTHROPIC,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"HUGGINGFACE":return _.create(Fa,{config:this.config.HUGGINGFACE,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"MISTRAL":return _.create(ya,{config:this.config.MISTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"CODESTRAL":return _.create(Nu,{config:this.config.CODESTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"OLLAMA":return M(this.config.OLLAMA.model).pipe(Zt(n=>_.create(Ba,{config:this.config.OLLAMA,keyName:n,stagedDiff:this.stagedDiff}).generateCommitMessage$()));case"COHERE":return _.create(Ru,{config:this.config.COHERE,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"GROQ":return _.create(Ca,{config:this.config.GROQ,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"PERPLEXITY":return _.create(Pa,{config:this.config.PERPLEXITY,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"DEEPSEEK":return _.create(_u,{config:this.config.DEEPSEEK,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();default:const o=C.red.bold(`[${r}]`);return O({name:o+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}),T(r=>{const o=C.red.bold("[UNKNOWN]");return O({name:o+` ${r.message||""}`,value:"Unknown error",isError:!0,disabled:!0})}))}}const go=async()=>{const{stdout:e,failed:t}=await oe("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new y("The current directory must be a Git repository!");return e},He=e=>`:(exclude)${e}`,Co=["package-lock.json","pnpm-lock.yaml","*.lock","*.lockb","*.gif","*.png"].map(He),Fo=async(e,t)=>{const r=["diff","--cached","--diff-algorithm=minimal"],{stdout:o}=await oe("git",[...r,"--name-only",...Co,...e?e.map(He):[],...t?t.map(He):[]]);if(!o)return null;const{stdout:n}=await oe("git",[...r,...Co,...e?e.map(He):[]]);return{files:o.split(`
105
- `),diff:n}},Sa=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class Fe{constructor(){this.title="aicommit2"}printTitle(){console.log(tn.textSync(this.title,{font:"Small"}))}displaySpinner(t){return Ve(t).start()}stopSpinner(t){t.stop(),t.clear()}printStagedFiles(t){console.log(C.bold.green("\u2714 ")+C.bold(`${Sa(t.files)}:`)),console.log(`${t.files.map(r=>` ${r}`).join(`
110
+ `,_t=(t,e)=>{const r=[];let o="";typeof e=="string"?e={section:e,whitespace:!1}:(e=e||Object.create(null),e.whitespace=e.whitespace===!0);const n=e.whitespace?" = ":"=";for(const s of Object.keys(t)){const i=t[s];if(i&&Array.isArray(i))for(const u of i)o+=ie(s+"[]")+n+ie(u)+je;else i&&typeof i=="object"?r.push(s):o+=ie(s)+n+ie(i)+je}e.section&&o.length&&(o="["+ie(e.section)+"]"+je+o);for(const s of r){const i=vo(s).join("\\."),u=(e.section?e.section+".":"")+i,{whitespace:a}=e,l=_t(t[s],{section:u,whitespace:a});o.length&&l.length&&(o+=je),o+=l}return o},vo=t=>t.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(e=>e.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),bo=t=>{const e=Object.create(null);let r=e,o=null;const n=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,s=t.split(/[\r\n]+/g);for(const u of s){if(!u||u.match(/^\s*[;#]/))continue;const a=u.match(n);if(!a)continue;if(a[1]!==void 0){if(o=Ge(a[1]),o==="__proto__"){r=Object.create(null);continue}r=e[o]=e[o]||Object.create(null);continue}const l=Ge(a[2]),m=l.length>2&&l.slice(-2)==="[]",c=m?l.slice(0,-2):l;if(c==="__proto__")continue;const D=a[3]?Ge(a[4]):!0,d=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;m&&(Tt.call(r,c)?Array.isArray(r[c])||(r[c]=[r[c]]):r[c]=[]),Array.isArray(r[c])?r[c].push(d):r[c]=d}const i=[];for(const u of Object.keys(e)){if(!Tt.call(e,u)||typeof e[u]!="object"||Array.isArray(e[u]))continue;const a=vo(u);r=e;const l=a.pop(),m=l.replace(/\\\./g,".");for(const c of a)c!=="__proto__"&&((!Tt.call(r,c)||typeof r[c]!="object")&&(r[c]=Object.create(null)),r=r[c]);r===e&&m===l||(r[m]=e[u],i.push(u))}for(const u of i)delete e[u];return e},$o=t=>t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"),ie=t=>typeof t!="string"||t.match(/[=\r\n]/)||t.match(/^\[/)||t.length>1&&$o(t)||t!==t.trim()?JSON.stringify(t):t.split(";").join("\\;").split("#").join("\\#"),Ge=(t,e)=>{if(t=(t||"").trim(),$o(t)){t.charAt(0)==="'"&&(t=t.slice(1,-1));try{t=JSON.parse(t)}catch{}}else{let r=!1,o="";for(let n=0,s=t.length;n<s;n++){const i=t.charAt(n);if(r)"\\;#".indexOf(i)!==-1?o+=i:o+="\\"+i,r=!1;else{if(";#".indexOf(i)!==-1)break;i==="\\"?r=!0:o+=i}}return r&&(o+="\\"),o.trim()}return t};var Sa={parse:bo,decode:bo,stringify:_t,encode:_t,safe:ie,unsafe:Ge},jt=Q(Sa);const Ao=t=>I.lstat(t).then(()=>!0,()=>!1),Ma=["","conventional","gitmoji"],Gt="http://localhost:11434",{hasOwnProperty:Oa}=Object.prototype,He=(t,e)=>Oa.call(t,e),Ht=["OPENAI","OLLAMA","HUGGINGFACE","GEMINI","ANTHROPIC","MISTRAL","CODESTRAL","COHERE","GROQ","PERPLEXITY","DEEPSEEK"],w=(t,e,r)=>{if(!e)throw new y(`Invalid config property ${t}: ${r}`)},p={systemPrompt(t){return t||""},systemPromptPath(t){return t||""},codeReviewPromptPath(t){return t||""},timeout(t){if(!t)return 1e4;w("timeout",/^\d+$/.test(t),"Must be an integer");const e=Number(t);return w("timeout",e>=500,"Must be greater than 500ms"),e},temperature(t){if(!t)return .7;w("temperature",/^(2|\d)(\.\d{1,2})?$/.test(t),"Must be decimal between 0 and 2");const e=Number(t);return w("temperature",e>0,"Must be greater than 0"),w("temperature",e<=2,"Must be less than or equal to 2"),e},maxTokens(t){return t?(w("maxTokens",/^\d+$/.test(t),"Must be an integer"),Number(t)):1024},logging(t){return typeof t=="boolean"?t:t==null?!0:(w("logging",/^(?:true|false)$/.test(t),"Must be a boolean(true or false)"),t==="true")},locale(t){return t?(w("locale",t,"Cannot be empty"),w("locale",/^[a-z-]+$/i.test(t),"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"),t):"en"},generate(t){if(!t)return 1;w("generate",/^\d+$/.test(t),"Must be an integer");const e=Number(t);return w("generate",e>0,"Must be greater than 0"),w("generate",e<=5,"Must be less or equal to 5"),e},type(t){return t?(w("type",Ma.includes(t),"Invalid commit type"),t):"conventional"},maxLength(t){if(!t)return 50;w("maxLength",/^\d+$/.test(t),"Must be an integer");const e=Number(t);return w("maxLength",e>=20,"Must be greater than 20 characters"),e},includeBody(t){return typeof t=="boolean"?t:t==null?!1:(w("includeBody",/^(?:true|false)$/.test(t),"Must be a boolean(true or false)"),t==="true")},exclude:t=>t?(typeof t=="string"?t?.split(","):t).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[],topP:t=>{if(!t)return .9;w("topP",/^(1|\d)(\.\d{1,2})?$/.test(t),"Must be decimal between 0 and 1");const e=Number(t);return w("topP",e>0,"Must be greater than 0"),w("topP",e<=1,"Must be less than or equal to 1"),e},codeReview(t){return typeof t=="boolean"?t:t==null?!1:(w("codeReview",/^(?:true|false)$/.test(t),"Must be a boolean(true or false)"),t==="true")}},ue={OPENAI:{key:t=>t||"",model:t=>t||"gpt-4o-mini",url:t=>t?(w("OPENAI.url",/^https?:\/\//.test(t),"Must be a valid URL"),t):"https://api.openai.com",path:t=>t||"/v1/chat/completions",proxy:t=>t||"",topP:p.topP,systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,codeReview:p.codeReview},HUGGINGFACE:{cookie:t=>t||"",model:t=>t?(w("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(t),"Invalid model type of HuggingFace chat"),t):"CohereForAI/c4ai-command-r-plus",systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,codeReview:p.codeReview},GEMINI:{key:t=>t||"",model:t=>!t||t.length===0?"gemini-1.5-pro":(w("GEMINI.model",["gemini-1.5-flash","gemini-1.5-pro","gemini-1.5-pro-exp-0801"].includes(t),"Invalid model type of Gemini"),t),systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview},ANTHROPIC:{key:t=>t||"",model:t=>!t||t.length===0?"claude-3-haiku-20240307":(w("ANTHROPIC.model",["claude-3-haiku-20240307","claude-3-sonnet-20240229","claude-3-opus-20240229","claude-3-5-sonnet-20240620"].includes(t),"Invalid model type of Anthropic"),t),systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview},MISTRAL:{key:t=>t||"",model:t=>!t||t.length===0?"mistral-tiny":(w("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(t),"Invalid model type of Mistral AI"),t),systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview},CODESTRAL:{key:t=>t||"",model:t=>!t||t.length===0?"codestral-latest":(w("CODESTRAL.model",["codestral-latest","codestral-2405"].includes(t),"Invalid model type of Codestral"),t),topP:p.topP,systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,codeReview:p.codeReview},OLLAMA:{model:t=>t?(typeof t=="string"?t?.split(","):t).map(r=>r.trim()).filter(r=>!!r&&r.length>0):[],host:t=>t?(w("OLLAMA.host",/^https?:\/\//.test(t),"Must be a valid URL"),t):Gt,timeout:t=>{if(!t)return 1e5;w("OLLAMA.timeout",/^\d+$/.test(t),"Must be an integer");const e=Number(t);return w("OLLAMA.timeout",e>=500,"Must be greater than 500ms"),e},systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,temperature:p.temperature,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview},COHERE:{key:t=>t||"",model:t=>!t||t.length===0?"command":(w("COHERE.model",["command","command-nightly","command-light","command-light-nightly"].includes(t),"Invalid model type of Cohere"),t),systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview},GROQ:{key:t=>t||"",model:t=>!t||t.length===0?"gemma2-9b-it":(w("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","llama-guard-3-8b","mixtral-8x7b-32768"].includes(t),"Invalid model type of Groq"),t),systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,topP:p.topP,codeReview:p.codeReview},PERPLEXITY:{key:t=>t||"",model:t=>!t||t.length===0?"llama-3.1-sonar-small-128k-chat":(w("PERPLEXITY.model",["llama-3.1-sonar-small-128k-online","llama-3.1-sonar-small-128k-chat","llama-3.1-sonar-large-128k-online","llama-3.1-sonar-large-128k-chat","llama-3.1-8b-instruct","llama-3.1-70b-instruct"].includes(t),"Invalid model type of Perplexity"),t),topP:p.topP,systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,codeReview:p.codeReview},DEEPSEEK:{key:t=>t||"",model:t=>!t||t.length===0?"deepseek-coder":(w("DEEPSEEK.model",["deepseek-coder","deepseek-chat"].includes(t),"Invalid model type of DeepSeek"),t),topP:p.topP,systemPrompt:p.systemPrompt,systemPromptPath:p.systemPromptPath,codeReviewPromptPath:p.codeReviewPromptPath,timeout:p.timeout,temperature:p.temperature,maxTokens:p.maxTokens,logging:p.logging,locale:p.locale,generate:p.generate,type:p.type,maxLength:p.maxLength,includeBody:p.includeBody,codeReview:p.codeReview}},Ue=N.join(Ye.homedir(),".aicommit2"),Ra=(t=[])=>{const e={};for(const r of t)if(r.startsWith("--")){const[o,n]=r.slice(2).split("="),[s,i]=o.split(".");s&&i&&s in ue?(e[s]||(e[s]={}),e[s][i]=n):e[o]=n}return e},Ut=async()=>{if(!await Ao(Ue))return Object.create(null);const e=await I.readFile(Ue,"utf8");let r=jt.parse(e);return He(r,"OLLAMA")&&He(r.OLLAMA,"model")&&(r={...r,OLLAMA:{...r.OLLAMA,model:typeof r.OLLAMA.model=="string"?[r.OLLAMA.model]:r.OLLAMA.model}}),He(r,"exclude")&&(r={...r,exclude:typeof r.exclude=="string"?[r.exclude]:r.exclude}),r},zt=async(t,e=[])=>{const r=await Ut(),o=Ra(e),n={...t,...o},s={},i=(u,a)=>{const l=n[`${u}.${a}`]??n[u]?.[a],m=r[u]?.[a],c=n[a]??r[a];return l!==void 0?l:m!==void 0?m:c};for(const[u,a]of Object.entries(p)){const l=n[u]??r[u];s[u]=a(l)}for(const[u,a]of Object.entries(ue)){s[u]={};for(const[l,m]of Object.entries(a)){const c=i(u,l);s[u][l]=m(c)}}return s},Ia=async t=>{const e=await Ut();for(const[r,o]of t){const[n,s]=r.split(".");if(n in ue){e[n]||(e[n]={});const i=ue[n][s];if(!i)throw new y(`Invalid config property: ${r}`);e[n][s]=i(o)}else{const i=p[r];if(!i)throw new y(`Invalid config property: ${r}`);e[r]=i(o)}}await I.writeFile(Ue,jt.stringify(e),"utf8")},ka=async t=>{const e=await Ut();for(const[r,o]of t){const[n,s]=r.split(".");if(n in ue){e[n]||(e[n]={});const i=n==="OLLAMA"&&s==="model",u=ue[n][s];if(!u||!i)throw new y(`Invalid config property: ${r}. Only supports OLLAMA.model`);const a=e[n][s]||[];e[n][s]=oe([...a,u(o)])}else throw new y(`Invalid config property: ${r}. Only supports OLLAMA.model`)}await I.writeFile(Ue,jt.stringify(e),"utf8")};class Po extends _{constructor(e){super(e),this.params=e,this.host=Gt,this.model="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return R({name:`${this.errorPrefix} ${r.response.data?.error}`,value:r.response.data?.error,isError:!0,disabled:!0});const o=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return R({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#FFF",secondary:"#000"},this.model=this.params.keyName,this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${Xr(this.model)}]`),this.errorPrefix=C.red.bold(`[${Xr(this.model)}]`),this.host=this.params.config.host||Gt,this.ollama=new En({host:this.host})}generateCommitMessage$(){return B(this.generateMessage("commit")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return B(this.generateMessage("review")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,locale:u,generate:a,type:l,maxLength:m}=this.params.config,c={...L,locale:u,maxLength:m,type:l,generate:a,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},D=e==="review"?H(c):G(c);await this.checkIsAvailableOllama();const d=await this.createChatCompletions(D,`Here is the diff: ${r}`);return i&&j(`Ollama_${this.model}`,r,D,d,e),e==="review"?this.sanitizeResponse(d):this.parseMessage(d,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new y(`Error connecting to ${o.hostname} (${o.syscall})`):o}}async checkIsAvailableOllama(){try{return(await new ne({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.timeout}).execute()).data}catch(e){throw e.code==="ECONNREFUSED"?new y(`Error connecting to ${this.host}. Please run Ollama or check host`):e}}async createChatCompletions(e,r){return(await this.ollama.chat({model:this.model,messages:[{role:"system",content:e},{role:"user",content:r}],stream:!1,options:{temperature:this.params.config.temperature,top_p:this.params.config.topP,seed:Ne(10,1e3)}})).message.content}}class Bo extends _{constructor(e){super(e),this.params=e,this.handleError$=r=>{let o="An error occurred";if(r.message){o=r.message.split(`
111
+ `)[0];const n=this.extractJSONFromError(r.message);o+=`: ${n.error.message}`}return R({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=C.red.bold("[ChatGPT]")}generateCommitMessage$(){return B(this.generateMessage("commit")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return B(this.generateMessage("review")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}extractJSONFromError(e){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,o=e.match(r);return o?Object.assign({},...o.map(n=>JSON.parse(n))):{error:{message:"Unknown error"}}}async generateMessage(e){const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,temperature:i,logging:u,locale:a,generate:l,type:m,maxLength:c,proxy:D,maxTokens:d,timeout:f}=this.params.config,h={...L,locale:a,maxLength:c,type:m,generate:l,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},g=e==="review"?H(h):G(h),E=await xa(this.params.config.url,this.params.config.path,this.params.config.key,this.params.config.model,r,f,d,i,this.params.config.topP,g,u,e,D);return oe(e==="review"?E.map(F=>this.sanitizeResponse(F)):E.map(F=>this.parseMessage(F,m,l)))}}class xo extends _{constructor(e){super(e),this.params=e,this.host="https://api.perplexity.ai",this.apiKey="",this.handleError$=r=>{let o="An error occurred";if(r.message){o=r.message.split(`
112
+ `)[0];const n=this.extractJSONFromError(r.message);o+=`: ${n.error.message}`}return R({name:`${this.errorPrefix} ${o}`,value:o,isError:!0,disabled:!0})},this.colors={primary:"#20808D",secondary:"#FFF"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Perplexity]"),this.errorPrefix=C.red.bold("[Perplexity]"),this.apiKey=this.params.config.key}generateCommitMessage$(){return B(this.generateMessage("commit")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:this.params.config.includeBody?e.value:e.title,description:this.params.config.includeBody?e.value:"",isError:!1})),b(this.handleError$))}generateCodeReview$(){return B(this.generateMessage("review")).pipe(P(e=>v(e)),A(e=>({name:`${this.serviceName} ${e.title}`,short:e.title,value:e.value,description:e.value,isError:!1})),b(this.handleError$))}extractJSONFromError(e){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,o=e.match(r);return o?Object.assign({},...o.map(n=>JSON.parse(n))):{error:{message:"Unknown error"}}}async generateMessage(e){try{const r=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s,logging:i,locale:u,generate:a,type:l,maxLength:m}=this.params.config,c={...L,locale:u,maxLength:m,type:l,generate:a,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:s},D=e==="review"?H(c):G(c),d=await this.createChatCompletions(D,r);return i&&j("Perplexity",r,D,d,e),this.parseMessage(d,l,a)}catch(r){const o=r;throw o.code==="ENOTFOUND"?new y(`Error connecting to ${o.hostname} (${o.syscall})`):o}}async createChatCompletions(e,r){const n=(await new ne({method:"POST",baseURL:`${this.host}/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.model,messages:[{role:"system",content:`${e}`},{role:"user",content:`Here is the diff: ${r}`}],temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1}).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 So{constructor(e,r){this.config=e,this.stagedDiff=r}createCommitMsgRequests$(e){return v(e).pipe(we(r=>{switch(r){case"OPENAI":return x.create(Bo,{config:this.config.OPENAI,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"GEMINI":return x.create(ao,{config:this.config.GEMINI,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"ANTHROPIC":return x.create(no,{config:this.config.ANTHROPIC,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"HUGGINGFACE":return x.create(yo,{config:this.config.HUGGINGFACE,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"MISTRAL":return x.create(wo,{config:this.config.MISTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"CODESTRAL":return x.create(so,{config:this.config.CODESTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"OLLAMA":return v(this.config.OLLAMA.model).pipe(we(n=>x.create(Po,{config:this.config.OLLAMA,keyName:n,stagedDiff:this.stagedDiff}).generateCommitMessage$()));case"COHERE":return x.create(io,{config:this.config.COHERE,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"GROQ":return x.create(Fo,{config:this.config.GROQ,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"PERPLEXITY":return x.create(xo,{config:this.config.PERPLEXITY,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();case"DEEPSEEK":return x.create(uo,{config:this.config.DEEPSEEK,stagedDiff:this.stagedDiff,keyName:r}).generateCommitMessage$();default:const o=C.red.bold(`[${r}]`);return R({name:o+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}),b(r=>{const o=C.red.bold("[UNKNOWN]");return R({name:o+` ${r.message||""}`,value:"Unknown error",isError:!0,disabled:!0})}))}createCodeReviewRequests$(e){return v(e).pipe(we(r=>{switch(r){case"OPENAI":return x.create(Bo,{config:this.config.OPENAI,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"GEMINI":return x.create(ao,{config:this.config.GEMINI,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"ANTHROPIC":return x.create(no,{config:this.config.ANTHROPIC,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"HUGGINGFACE":return x.create(yo,{config:this.config.HUGGINGFACE,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"MISTRAL":return x.create(wo,{config:this.config.MISTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"CODESTRAL":return x.create(so,{config:this.config.CODESTRAL,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"OLLAMA":return v(this.config.OLLAMA.model).pipe(we(n=>x.create(Po,{config:this.config.OLLAMA,keyName:n,stagedDiff:this.stagedDiff}).generateCodeReview$()));case"COHERE":return x.create(io,{config:this.config.COHERE,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"GROQ":return x.create(Fo,{config:this.config.GROQ,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"PERPLEXITY":return x.create(xo,{config:this.config.PERPLEXITY,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();case"DEEPSEEK":return x.create(uo,{config:this.config.DEEPSEEK,stagedDiff:this.stagedDiff,keyName:r}).generateCodeReview$();default:const o=C.red.bold(`[${r}]`);return R({name:o+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}),b(r=>{const o=C.red.bold("[UNKNOWN]");return R({name:o+` ${r.message||""}`,value:"Unknown error",isError:!0,disabled:!0})}))}}const Mo=async()=>{const{stdout:t,failed:e}=await de("git",["rev-parse","--show-toplevel"],{reject:!1});if(e)throw new y("The current directory must be a Git repository!");return t},ze=t=>`:(exclude)${t}`,Oo=["package-lock.json","pnpm-lock.yaml","*.lock","*.lockb","*.gif","*.png"].map(ze),Ro=async(t,e)=>{const r=["diff","--cached","--diff-algorithm=minimal"],{stdout:o}=await de("git",[...r,"--name-only",...Oo,...t?t.map(ze):[],...e?e.map(ze):[]]);if(!o)return null;const{stdout:n}=await de("git",[...r,...Oo,...t?t.map(ze):[]]);return{files:o.split(`
113
+ `),diff:n}},Na=t=>`Detected ${t.length.toLocaleString()} staged file${t.length>1?"s":""}`;class Fe{constructor(){this.title="aicommit2"}printTitle(){console.log(Fn.textSync(this.title,{font:"Small"}))}displaySpinner(e){return Zt(e).start()}stopSpinner(e){e.stop(),e.clear()}printStagedFiles(e){console.log(C.bold.green("\u2714 ")+C.bold(`${Na(e.files)}:`)),console.log(`${e.files.map(r=>` ${r}`).join(`
106
114
  `)}
107
115
  `)}printAnalyzed(){console.log(`
108
116
  ${C.bold.green("\u2714")} ${C.bold("Changes analyzed")}`)}printCommitted(){console.log(`
109
117
  ${C.bold.green("\u2714")} ${C.bold("Successfully committed!")}`)}printCopied(){console.log(`
110
118
  ${C.bold.green("\u2714")} ${C.bold("Successfully copied! Press 'Ctrl + V' to paste")}`)}printSavedCommitMessage(){console.log(`
111
119
  ${C.bold.green("\u2714")} ${C.bold("Saved commit message")}`)}printCancelledCommit(){console.log(`
112
- ${C.bold.yellow("\u26A0")} ${C.yellow("Commit cancelled")}`)}printErrorMessage(t){console.log(`
113
- ${C.bold.red("\u2716")} ${C.red(`${t}`)}`)}moveCursorUp(){const t=be.createInterface({input:process.stdin,output:process.stdout});be.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=be.createInterface({input:process.stdin,output:process.stdout});be.moveCursor(process.stdout,0,1),t.close()}}const Oa={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},qt="No commit messages were generated";class Ma{constructor(){this.choices$=new Qt([]),this.loader$=new Qt(Oa),this.destroyed$=new Lo(1)}initPrompt(t=!0){return Ke.registerPrompt("reactiveListPrompt",rn),Ke.prompt({type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${qt}`,loop:!1,showDescription:t,descPageSize:15,choices$:this.choices$,loader$:this.loader$,pickKey:"short"})}startLoader(){this.loader$.next({isLoading:!0})}refreshChoices(t){const{value:r,isError:o}=t;!t||!r||this.choices$.next([...this.currentChoices,t].sort(Lu))}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:qt,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:"Changes analyzed"})}logEmptyCommitMessage(){console.log(`${C.bold.yellow("\u26A0")} ${C.yellow(`${qt}`)}`)}get currentChoices(){return this.choices$.getValue().map(t=>t)}}const K=new Fe;var Ia=async(e,t,r,o,n,s,i,u,a)=>(async()=>{K.printTitle(),await go(),o&&await oe("git",["add","--update"]);const D=await Ut({locale:e?.toString(),generate:t?.toString(),commitType:n?.toString(),systemPrompt:u?.toString()},a);if(D.systemPromptPath)try{W.readFileSync(L.resolve(D.systemPromptPath),"utf-8")}catch{throw new y(`Error reading system prompt file: ${D.systemPromptPath}`)}const m=K.displaySpinner("Detecting staged files"),c=await Fo(r,D.exclude);if(m.stop(),!c)throw new y("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");K.printStagedFiles(c);const l=Object.entries(D).filter(([w])=>Gt.includes(w)).map(([w,x])=>[w,x]).filter(([w,x])=>w==="OLLAMA"?!!x&&!!x.model&&x.model.length>0:w==="HUGGINGFACE"?!!x&&!!x.cookie:!!x.key&&x.key.length>0).map(([w])=>w);if(l.length===0)throw new y("Please set at least one API key via the `aicommit2 config set` command");const d=new ho(D,c),h=new Ma,g=h.initPrompt();h.startLoader();const E=d.createAIRequests$(l).subscribe(w=>h.refreshChoices(w),()=>{},()=>h.checkErrorOnChoices()),A=await g;E.unsubscribe(),h.completeSubject(),K.moveCursorUp();const v=A.aicommit2Prompt?.value;if(!v)throw new y("An error occurred! No selected message");if(i&&(As("copy-paste").copy(v),K.printCopied(),process.exit()),s){const w=Ve("Committing with the generated message").start();await oe("git",["commit","-m",v,...a]),w.stop(),w.clear(),K.printCommitted(),process.exit()}const Y=await Ke.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:z}=Y;if(z){const w=Ve("Committing with the generated message").start();await oe("git",["commit","-m",v,...a]),w.stop(),w.clear(),K.printCommitted(),process.exit()}K.printCancelledCommit(),process.exit()})().catch(D=>{K.printErrorMessage(D.message),pe(D),process.exit(1)}),Ta=nt({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:r}=e._;if(t==="get"){const o=await Ut({},[]);for(const n of r)if(je(o,n)){if(Gt.includes(n)){console.log(n,o[n]);return}console.log(`${n}=${o[n]}`)}return}if(t==="set"){await $a(r.map(o=>o.split("=")));return}if(t==="add"){await va(r.map(o=>o.split("=")));return}throw new y(`Invalid mode: ${t}`)})().catch(t=>{new Fe().printErrorMessage(t.message),pe(t),process.exit(1)})});const yo="prepare-commit-msg",Eo=`.git/hooks/${yo}`,Ue=Zo(new URL("cli.mjs",import.meta.url)),ka=process.argv[1].replace(/\\/g,"/").endsWith(`/${Eo}`),bo=process.platform==="win32",wo=`
120
+ ${C.bold.yellow("\u26A0")} ${C.yellow("Commit cancelled")}`)}printErrorMessage(e){console.log(`
121
+ ${C.bold.red("\u2716")} ${C.red(`${e}`)}`)}moveCursorUp(){const e=$e.createInterface({input:process.stdin,output:process.stdout});$e.moveCursor(process.stdout,0,-1),e.close()}moveCursorDown(){const e=$e.createInterface({input:process.stdin,output:process.stdout});$e.moveCursor(process.stdout,0,1),e.close()}}const La={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},Ta={isLoading:!1,startOption:{text:"AI is performing a code review"}},qt="No commit messages were generated",_a="No code reviews were generated",Io={type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${qt}`,loop:!1,descPageSize:15,showDescription:!0,pickKey:"short",isDescriptionDim:!0,stopMessage:"Changes analyzed"};class ko{constructor(e){this.choices$=new er([]),this.destroyed$=new en(1),this.stopMessage="Changes analyzed",this.loader$=new er(e)}initPrompt(e=Io){return this.stopMessage=e.stopMessage,ye.registerPrompt("reactiveListPrompt",yn),ye.prompt({...e,choices$:this.choices$,loader$:this.loader$})}startLoader(){this.loader$.next({isLoading:!0})}refreshChoices(e){const{value:r,isError:o}=e;!e||!r||this.choices$.next([...this.currentChoices,e].sort(Wu))}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:qt,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:this.stopMessage})}logEmptyCommitMessage(){console.log(`${C.bold.yellow("\u26A0")} ${C.yellow(`${qt}`)}`)}get currentChoices(){return this.choices$.getValue().map(e=>e)}}const q=new Fe;var ja=async(t,e,r,o,n,s,i,u,a)=>(async()=>{q.printTitle(),await Mo(),o&&await de("git",["add","--update"]);const l=await zt({locale:t?.toString(),generate:e?.toString(),commitType:n?.toString(),systemPrompt:u?.toString()},a);await Ga(l);const m=q.displaySpinner("Detecting staged files"),c=await Ro(r,l.exclude);if(m.stop(),!c)throw new y("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");q.printStagedFiles(c);const D=No(l,"commit");if(D.length===0)throw new y("Please set at least one API key via the `aicommit2 config set` command");const d=new So(l,c),f=No(l,"review");f.length>0&&await Ha(d,f);const h=await Ua(d,D);i&&(Hs("copy-paste").copy(h),q.printCopied(),process.exit()),s&&(await Lo(h,a),process.exit());const{confirmationPrompt:g}=await ye.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]);g?await Lo(h,a):q.printCancelledCommit(),process.exit()})().catch(l=>{q.printErrorMessage(l.message),pe(l),process.exit(1)});async function Ga(t){if(t.systemPromptPath)try{T.readFileSync(N.resolve(t.systemPromptPath),"utf-8")}catch{throw new y(`Error reading system prompt file: ${t.systemPromptPath}`)}if(t.codeReview&&t.codeReviewPromptPath)try{T.readFileSync(N.resolve(t.codeReviewPromptPath),"utf-8")}catch{throw new y(`Error reading code review prompt file: ${t.codeReviewPromptPath}`)}}function No(t,e){return Object.entries(t).filter(([r])=>Ht.includes(r)).map(([r,o])=>[r,o]).filter(([r,o])=>{switch(e){case"commit":return r==="OLLAMA"?!!o&&!!o.model&&o.model.length>0:r==="HUGGINGFACE"?!!o&&!!o.cookie:!!o.key&&o.key.length>0;case"review":const n=t.codeReview||o.codeReview;return r==="OLLAMA"?!!o&&!!o.model&&o.model.length>0&&n:r==="HUGGINGFACE"?!!o&&!!o.cookie&&n:!!o.key&&o.key.length>0&&n}return!1}).map(([r])=>r)}async function Ha(t,e){const r=new ko(Ta),o=r.initPrompt({...Io,name:"codeReviewPrompt",message:"Please check code reviews: ",emptyMessage:`\u26A0 ${_a}`,isDescriptionDim:!1,stopMessage:"Code review completed",descPageSize:20});r.startLoader();const n=t.createCodeReviewRequests$(e).subscribe(a=>r.refreshChoices(a),()=>{},()=>r.checkErrorOnChoices());if(!(await o).codeReviewPrompt?.value)throw new y("An error occurred! No selected code review");n.unsubscribe(),r.completeSubject(),q.moveCursorUp();const{continuePrompt:u}=await ye.prompt([{type:"confirm",name:"continuePrompt",message:"Will you continue without changing the code?",default:!0}]);u||(q.printCancelledCommit(),process.exit())}async function Ua(t,e){const r=new ko(La),o=r.initPrompt();r.startLoader();const n=t.createCommitMsgRequests$(e).subscribe(u=>r.refreshChoices(u),()=>{},()=>r.checkErrorOnChoices()),s=await o;n.unsubscribe(),r.completeSubject(),q.moveCursorUp();const i=s.aicommit2Prompt?.value;if(!i)throw new y("An error occurred! No selected message");return i}async function Lo(t,e){const r=Zt("Committing with the generated message").start();await de("git",["commit","-m",t,...e]),r.stop(),r.clear(),q.printCommitted()}var za=st({name:"config",parameters:["<mode>","<key=value...>"]},t=>{(async()=>{const{mode:e,keyValue:r}=t._;if(e==="get"){const o=await zt({},[]);for(const n of r)if(He(o,n)){if(Ht.includes(n)){console.log(n,o[n]);return}console.log(`${n}=${o[n]}`)}return}if(e==="set"){await Ia(r.map(o=>o.split("=")));return}if(e==="add"){await ka(r.map(o=>o.split("=")));return}throw new y(`Invalid mode: ${e}`)})().catch(e=>{new Fe().printErrorMessage(e.message),pe(e),process.exit(1)})});const To="prepare-commit-msg",_o=`.git/hooks/${To}`,qe=gn(new URL("cli.mjs",import.meta.url)),qa=process.argv[1].replace(/\\/g,"/").endsWith(`/${_o}`),jo=process.platform==="win32",Go=`
114
122
  #!/usr/bin/env node
115
- import(${JSON.stringify(Qo(Ue))})
116
- `.trim();var La=nt({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await go(),{installUninstall:r}=e._,o=L.join(t,Eo),n=await fo(o);if(r==="install"){if(n){if(await P.realpath(o).catch(()=>{})===Ue){console.warn("The hook is already installed");return}throw new y(`A different ${yo} hook seems to be installed. Please remove it before installing aicommit2.`)}await P.mkdir(L.dirname(o),{recursive:!0}),bo?await P.writeFile(o,wo):(await P.symlink(Ue,o,"file"),await P.chmod(o,493)),console.log(`${C.green("\u2714")} Hook installed`);return}if(r==="uninstall"){if(!n){console.warn("Hook is not installed");return}if(bo){if(await P.readFile(o,"utf8")!==wo){console.warn("Hook is not installed");return}}else if(await P.realpath(o)!==Ue){console.warn("Hook is not installed");return}await P.rm(o),console.log(`${C.green("\u2714")} Hook uninstalled`);return}throw new y(`Invalid mode: ${r}`)})().catch(t=>{console.error(`${C.red("\u2716")} ${t.message}`),pe(t),process.exit(1)})}),Na=nt({name:"log",parameters:["<removeAll>"]},e=>{(async()=>{const{removeAll:t}=e._;if(t==="removeAll"){await on(Xr,{recursive:!0,force:!0}),console.log(`${C.green("\u2714")} All Log files are removed!`);return}throw new y(`Invalid mode: ${t}`)})().catch(t=>{new Fe().printErrorMessage(t.message),pe(t),process.exit(1)})});const[qe,Ra]=process.argv.slice(2);var _a=()=>(async()=>{if(!qe)throw new y('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(Ra)return;const e=await Fo();if(!e)return;const t=new Fe;t.printTitle();const r=await Ut({});if(r.systemPromptPath)try{await P.readFile(L.resolve(r.systemPromptPath),"utf-8")}catch{throw new y(`Error reading system prompt file: ${r.systemPromptPath}`)}const o=Object.entries(r).filter(([d])=>Gt.includes(d)).map(([d,h])=>[d,h]).filter(([d,h])=>d==="OLLAMA"?!!h&&!!h.model&&h.model.length>0:d==="HUGGINGFACE"?!!h&&!!h.cookie:!!h.key&&h.key.length>0).map(([d])=>d);if(o.length===0)throw new y("Please set at least one API key via the `aicommit2 config set` command");const s=new ho(r,e),i=t.displaySpinner("The AI is analyzing your changes");let u;try{u=await No(s.createAIRequests$(o).pipe(Ro(d=>!d.isError),I(d=>d.value),_o()))}finally{i.stop(),i.clear(),t.printAnalyzed()}const D=await P.readFile(qe,"utf8")!=="",m=u.length>1;let c="";D&&(c=`# \u{1F916} AI generated commit${m?"s":""}
117
- `),m?(D&&(c+=`# Select one of the following messages by uncommenting:
123
+ import(${JSON.stringify(Cn(qe))})
124
+ `.trim();var Wa=st({name:"hook",parameters:["<install/uninstall>"]},t=>{(async()=>{const e=await Mo(),{installUninstall:r}=t._,o=N.join(e,_o),n=await Ao(o);if(r==="install"){if(n){if(await I.realpath(o).catch(()=>{})===qe){console.warn("The hook is already installed");return}throw new y(`A different ${To} hook seems to be installed. Please remove it before installing aicommit2.`)}await I.mkdir(N.dirname(o),{recursive:!0}),jo?await I.writeFile(o,Go):(await I.symlink(qe,o,"file"),await I.chmod(o,493)),console.log(`${C.green("\u2714")} Hook installed`);return}if(r==="uninstall"){if(!n){console.warn("Hook is not installed");return}if(jo){if(await I.readFile(o,"utf8")!==Go){console.warn("Hook is not installed");return}}else if(await I.realpath(o)!==qe){console.warn("Hook is not installed");return}await I.rm(o),console.log(`${C.green("\u2714")} Hook uninstalled`);return}throw new y(`Invalid mode: ${r}`)})().catch(e=>{console.error(`${C.red("\u2716")} ${e.message}`),pe(e),process.exit(1)})}),Ka=st({name:"log",parameters:["<removeAll>"]},t=>{(async()=>{const{removeAll:e}=t._;if(e==="removeAll"){await wn(eo,{recursive:!0,force:!0}),console.log(`${C.green("\u2714")} All Log files are removed!`);return}throw new y(`Invalid mode: ${e}`)})().catch(e=>{new Fe().printErrorMessage(e.message),pe(e),process.exit(1)})});const[We,Va]=process.argv.slice(2);var Ja=()=>(async()=>{if(!We)throw new y('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(Va)return;const t=await Ro();if(!t)return;const e=new Fe;e.printTitle();const r=await zt({});if(r.systemPromptPath)try{await I.readFile(N.resolve(r.systemPromptPath),"utf-8")}catch{throw new y(`Error reading system prompt file: ${r.systemPromptPath}`)}const o=Object.entries(r).filter(([f])=>Ht.includes(f)).map(([f,h])=>[f,h]).filter(([f,h])=>f==="OLLAMA"?!!h&&!!h.model&&h.model.length>0:f==="HUGGINGFACE"?!!h&&!!h.cookie:!!h.key&&h.key.length>0).map(([f])=>f);if(o.length===0)throw new y("Please set at least one API key via the `aicommit2 config set` command");const s=new So(r,t),i=e.displaySpinner("The AI is analyzing your changes");let u;try{u=await tn(s.createCommitMsgRequests$(o).pipe(rn(f=>!f.isError),A(f=>f.value),on()))}finally{i.stop(),i.clear(),e.printAnalyzed()}const l=await I.readFile(We,"utf8")!=="",m=u.length>1;let c="";l&&(c=`# \u{1F916} AI generated commit${m?"s":""}
125
+ `),m?(l&&(c+=`# Select one of the following messages by uncommenting:
118
126
  `),c+=`
119
- ${u.map(d=>`# ${d}`).join(`
120
- `)}`):(D&&(c+=`# Edit the message below and commit:
127
+ ${u.map(f=>`# ${f}`).join(`
128
+ `)}`):(l&&(c+=`# Edit the message below and commit:
121
129
  `),c+=`
122
130
  ${u[0]}
123
- `);const l=await P.readFile(qe,"utf8"),p=c+`
124
- `+l;await P.writeFile(qe,p),t.printSavedCommitMessage()})().catch(e=>{new Fe().printErrorMessage(e.message),pe(e),process.exit(1)});const Ao=process.argv.slice(2);ws({name:"aicommit2",version:Yr,flags:{locale:{type:String,description:"Locale to use for the generated commit messages (default: en)",alias:"l"},generate:{type:Number,description:"Number of messages to generate (Warning: generating multiple costs more) (default: 1)",alias:"g"},exclude:{type:[String],description:"Files to exclude from AI analysis",alias:"x"},all:{type:Boolean,description:"Automatically stage changes in tracked files for the commit",alias:"a",default:!1},type:{type:String,description:"Type of commit message to generate",alias:"t"},confirm:{type:Boolean,description:"Skip confirmation when committing after message generation (default: false)",alias:"y",default:!1},clipboard:{type:Boolean,description:"Copy the selected message to the clipboard",alias:"c",default:!1},prompt:{type:String,description:"Custom prompt to let users fine-tune provided prompt",alias:"p"}},commands:[Ta,La,Na],help:{description:xu},ignoreArgv:e=>e==="unknown-flag"||e==="argument"},e=>{if(ka){_a();return}Ia(e.flags.locale,e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,e.flags.confirm,e.flags.clipboard,e.flags.prompt,Ao)},Ao);
131
+ `);const D=await I.readFile(We,"utf8"),d=c+`
132
+ `+D;await I.writeFile(We,d),e.printSavedCommitMessage()})().catch(t=>{new Fe().printErrorMessage(t.message),pe(t),process.exit(1)});const Ho=process.argv.slice(2);Gs({name:"aicommit2",version:Zr,flags:{locale:{type:String,description:"Locale to use for the generated commit messages (default: en)",alias:"l"},generate:{type:Number,description:"Number of messages to generate (Warning: generating multiple costs more) (default: 1)",alias:"g"},exclude:{type:[String],description:"Files to exclude from AI analysis",alias:"x"},all:{type:Boolean,description:"Automatically stage changes in tracked files for the commit",alias:"a",default:!1},type:{type:String,description:"Type of commit message to generate",alias:"t"},confirm:{type:Boolean,description:"Skip confirmation when committing after message generation (default: false)",alias:"y",default:!1},clipboard:{type:Boolean,description:"Copy the selected message to the clipboard",alias:"c",default:!1},prompt:{type:String,description:"Custom prompt to let users fine-tune provided prompt",alias:"p"}},commands:[za,Wa,Ka],help:{description:Ku},ignoreArgv:t=>t==="unknown-flag"||t==="argument"},t=>{if(qa){Ja();return}ja(t.flags.locale,t.flags.generate,t.flags.exclude,t.flags.all,t.flags.type,t.flags.confirm,t.flags.clipboard,t.flags.prompt,Ho)},Ho);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicommit2",
3
- "version": "2.0.9",
3
+ "version": "2.1.0",
4
4
  "description": "A Reactive CLI that generates git commit messages with various AI",
5
5
  "keywords": [
6
6
  "cli",
@@ -61,7 +61,7 @@
61
61
  "formdata-node": "^6.0.3",
62
62
  "groq-sdk": "^0.5.0",
63
63
  "inquirer": "9.2.8",
64
- "inquirer-reactive-list-prompt": "^1.0.9",
64
+ "inquirer-reactive-list-prompt": "^1.0.10",
65
65
  "ollama": "^0.5.6",
66
66
  "ora": "^8.0.1",
67
67
  "readline": "^1.3.0",