aicommit2 1.7.5 → 1.8.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 (2) hide show
  1. package/dist/cli.mjs +51 -50
  2. package/package.json +3 -3
package/dist/cli.mjs CHANGED
@@ -1,61 +1,62 @@
1
1
  #!/usr/bin/env node
2
- import Pe from"tty";import{createRequire as cn}from"module";import{Buffer as ln}from"node:buffer";import W from"node:path";import Pt from"node:child_process";import _ from"node:process";import fn from"child_process";import V from"path";import _e from"fs";import pn from"node:url";import dn,{constants as _t}from"node:os";import Tt from"assert";import Nt from"events";import mn from"buffer";import Te from"stream";import Lt from"util";import Ne from"inquirer";import Le from"ora";import g from"chalk";import{of as T,concatMap as k,from as N,map as L,catchError as j,mergeMap as hn,BehaviorSubject as Rt,ReplaySubject as gn,lastValueFrom as Cn,filter as Fn,toArray as En}from"rxjs";import Re from"@anthropic-ai/sdk";import{fromPromise as G}from"rxjs/internal/observable/innerFrom";import yn from"http";import wn from"https";import"@dqbd/tiktoken";import bn from"net";import An from"tls";import vn,{fileURLToPath as Bn,pathToFileURL as $n}from"url";import kt from"os";import{FormData as xn,Blob as On}from"formdata-node";import $ from"fs/promises";import In from"axios";import{GoogleGenerativeAI as Sn}from"@google/generative-ai";import{Ollama as Mn}from"ollama";import me from"readline";import Pn from"figlet";import _n from"inquirer-reactive-list-prompt";const Tn="known-flag",Nn="unknown-flag",Ln="argument",{stringify:ue}=JSON,Rn=/\B([A-Z])/g,kn=e=>e.replace(Rn,"-$1").toLowerCase(),{hasOwnProperty:jn}=Object.prototype,se=(e,t)=>jn.call(e,t),Gn=e=>Array.isArray(e),jt=e=>typeof e=="function"?[e,!1]:Gn(e)?[e[0],!0]:jt(e.type),Un=(e,t)=>e===Boolean?t!=="false":t,Hn=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),Kn=/[\s.:=]/,qn=e=>{const t=`Flag name ${ue(e)}`;if(e.length===0)throw new Error(`${t} cannot be empty`);if(e.length===1)throw new Error(`${t} must be longer than a character`);const n=e.match(Kn);if(n)throw new Error(`${t} cannot contain ${ue(n?.[0])}`)},zn=e=>{const t={},n=(r,o)=>{if(se(t,r))throw new Error(`Duplicate flags named ${ue(r)}`);t[r]=o};for(const r in e){if(!se(e,r))continue;qn(r);const o=e[r],u=[[],...jt(o),o];n(r,u);const s=kn(r);if(r!==s&&n(s,u),"alias"in o&&typeof o.alias=="string"){const{alias:a}=o,i=`Flag alias ${ue(a)} for flag ${ue(r)}`;if(a.length===0)throw new Error(`${i} cannot be empty`);if(a.length>1)throw new Error(`${i} must be a single character`);n(a,u)}}return t},Yn=(e,t)=>{const n={};for(const r in e){if(!se(e,r))continue;const[o,,u,s]=t[r];if(o.length===0&&"default"in s){let{default:a}=s;typeof a=="function"&&(a=a()),n[r]=a}else n[r]=u?o:o.pop()}return n},he="--",Wn=/[.:=]/,Vn=/^-{1,2}\w/,Xn=e=>{if(!Vn.test(e))return;const t=!e.startsWith(he);let n=e.slice(t?1:2),r;const o=n.match(Wn);if(o){const{index:u}=o;r=n.slice(u+1),n=n.slice(0,u)}return[n,r,t]},Jn=(e,{onFlag:t,onArgument:n})=>{let r;const o=(u,s)=>{if(typeof r!="function")return!0;r(u,s),r=void 0};for(let u=0;u<e.length;u+=1){const s=e[u];if(s===he){o();const i=e.slice(u+1);n?.(i,[u],!0);break}const a=Xn(s);if(a){if(o(),!t)continue;const[i,l,f]=a;if(f)for(let D=0;D<i.length;D+=1){o();const c=D===i.length-1;r=t(i[D],c?l:void 0,[u,D+1,c])}else r=t(i,l,[u])}else o(s,[u])&&n?.([s],[u])}o()},Zn=(e,t)=>{for(const[n,r,o]of t.reverse()){if(r){const u=e[n];let s=u.slice(0,r);if(o||(s+=u.slice(r+1)),s!=="-"){e[n]=s;continue}}e.splice(n,1)}},Qn=(e,t=process.argv.slice(2),{ignore:n}={})=>{const r=[],o=zn(e),u={},s=[];return s[he]=[],Jn(t,{onFlag(a,i,l){const f=se(o,a);if(!n?.(f?Tn:Nn,a,i)){if(f){const[D,c]=o[a],p=Un(c,i),d=(m,h)=>{r.push(l),h&&r.push(h),D.push(Hn(c,m||""))};return p===void 0?d:d(p)}se(u,a)||(u[a]=[]),u[a].push(i===void 0?!0:i),r.push(l)}},onArgument(a,i,l){n?.(Ln,t[i[0]])||(s.push(...a),l?(s[he]=a,t.splice(i[0])):r.push(i))}}),Zn(t,r),{flags:Yn(e,o),unknownFlags:u,_:s}};var eo=Object.create,ge=Object.defineProperty,to=Object.defineProperties,ro=Object.getOwnPropertyDescriptor,no=Object.getOwnPropertyDescriptors,oo=Object.getOwnPropertyNames,Gt=Object.getOwnPropertySymbols,uo=Object.getPrototypeOf,Ut=Object.prototype.hasOwnProperty,so=Object.prototype.propertyIsEnumerable,Ht=(e,t,n)=>t in e?ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ce=(e,t)=>{for(var n in t||(t={}))Ut.call(t,n)&&Ht(e,n,t[n]);if(Gt)for(var n of Gt(t))so.call(t,n)&&Ht(e,n,t[n]);return e},ke=(e,t)=>to(e,no(t)),io=e=>ge(e,"__esModule",{value:!0}),ao=(e,t)=>()=>(e&&(t=e(e=0)),t),Do=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),co=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of oo(t))!Ut.call(e,o)&&(n||o!=="default")&&ge(e,o,{get:()=>t[o],enumerable:!(r=ro(t,o))||r.enumerable});return e},lo=(e,t)=>co(io(ge(e!=null?eo(uo(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),B=ao(()=>{}),fo=Do((e,t)=>{B(),t.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});B(),B(),B();var po=e=>{var t,n,r;let o=(t=process.stdout.columns)!=null?t:Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(o)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:o}:{columns:(n=e.columns)!=null?n:[],stdoutColumns:(r=e.stdoutColumns)!=null?r:o}};B(),B(),B(),B(),B();function mo({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 Kt(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(mo(),"")}B();function ho(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 go=lo(fo(),1);function U(e){if(typeof e!="string"||e.length===0||(e=Kt(e),e.length===0))return 0;e=e.replace((0,go.default)()," ");let t=0;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);r<=31||r>=127&&r<=159||r>=768&&r<=879||(r>65535&&n++,t+=ho(r)?2:1)}return t}var qt=e=>Math.max(...e.split(`
3
- `).map(U)),Co=e=>{let t=[];for(let n of e){let{length:r}=n,o=r-t.length;for(let u=0;u<o;u+=1)t.push(0);for(let u=0;u<r;u+=1){let s=qt(n[u]);s>t[u]&&(t[u]=s)}}return t};B();var zt=/^\d+%$/,Yt={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},Fo=(e,t)=>{var n;let r=[];for(let o=0;o<e.length;o+=1){let u=(n=t[o])!=null?n:"auto";if(typeof u=="number"||u==="auto"||u==="content-width"||typeof u=="string"&&zt.test(u)){r.push(ke(Ce({},Yt),{width:u,contentWidth:e[o]}));continue}if(u&&typeof u=="object"){let s=ke(Ce(Ce({},Yt),u),{contentWidth:e[o]});s.horizontalPadding=s.paddingLeft+s.paddingRight,r.push(s);continue}throw new Error(`Invalid column width: ${JSON.stringify(u)}`)}return r};function Eo(e,t){for(let n of e){let{width:r}=n;if(r==="content-width"&&(n.width=n.contentWidth),r==="auto"){let i=Math.min(20,n.contentWidth);n.width=i,n.autoOverflow=n.contentWidth-i}if(typeof r=="string"&&zt.test(r)){let i=Number.parseFloat(r.slice(0,-1))/100;n.width=Math.floor(t*i)-(n.paddingLeft+n.paddingRight)}let{horizontalPadding:o}=n,u=1,s=u+o;if(s>=t){let i=s-t,l=Math.ceil(n.paddingLeft/o*i),f=i-l;n.paddingLeft-=l,n.paddingRight-=f,n.horizontalPadding=n.paddingLeft+n.paddingRight}n.paddingLeftString=n.paddingLeft?" ".repeat(n.paddingLeft):"",n.paddingRightString=n.paddingRight?" ".repeat(n.paddingRight):"";let a=t-n.horizontalPadding;n.width=Math.max(Math.min(n.width,a),u)}}var Wt=()=>Object.assign([],{columns:0});function yo(e,t){let n=[Wt()],[r]=n;for(let o of e){let u=o.width+o.horizontalPadding;r.columns+u>t&&(r=Wt(),n.push(r)),r.push(o),r.columns+=u}for(let o of n){let u=o.reduce((c,p)=>c+p.width+p.horizontalPadding,0),s=t-u;if(s===0)continue;let a=o.filter(c=>"autoOverflow"in c),i=a.filter(c=>c.autoOverflow>0),l=i.reduce((c,p)=>c+p.autoOverflow,0),f=Math.min(l,s);for(let c of i){let p=Math.floor(c.autoOverflow/l*f);c.width+=p,s-=p}let D=Math.floor(s/a.length);for(let c=0;c<a.length;c+=1){let p=a[c];c===a.length-1?p.width+=s:p.width+=D,s-=D}}return n}function wo(e,t,n){let r=Fo(n,t);return Eo(r,e),yo(r,e)}B(),B(),B();var je=10,Vt=(e=0)=>t=>`\x1B[${t+e}m`,Xt=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Jt=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`;function bo(){let e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(let[n,r]of Object.entries(t)){for(let[o,u]of Object.entries(r))t[o]={open:`\x1B[${u[0]}m`,close:`\x1B[${u[1]}m`},r[o]=t[o],e.set(u[0],u[1]);Object.defineProperty(t,n,{value:r,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi=Vt(),t.color.ansi256=Xt(),t.color.ansi16m=Jt(),t.bgColor.ansi=Vt(je),t.bgColor.ansi256=Xt(je),t.bgColor.ansi16m=Jt(je),Object.defineProperties(t,{rgbToAnsi256:{value:(n,r,o)=>n===r&&r===o?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(r/255*5)+Math.round(o/255*5),enumerable:!1},hexToRgb:{value:n=>{let r=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(n.toString(16));if(!r)return[0,0,0];let{colorString:o}=r.groups;o.length===3&&(o=o.split("").map(s=>s+s).join(""));let u=Number.parseInt(o,16);return[u>>16&255,u>>8&255,u&255]},enumerable:!1},hexToAnsi256:{value:n=>t.rgbToAnsi256(...t.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value:n=>{if(n<8)return 30+n;if(n<16)return 90+(n-8);let r,o,u;if(n>=232)r=((n-232)*10+8)/255,o=r,u=r;else{n-=16;let i=n%36;r=Math.floor(n/36)/5,o=Math.floor(i/6)/5,u=i%6/5}let s=Math.max(r,o,u)*2;if(s===0)return 30;let a=30+(Math.round(u)<<2|Math.round(o)<<1|Math.round(r));return s===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(n,r,o)=>t.ansi256ToAnsi(t.rgbToAnsi256(n,r,o)),enumerable:!1},hexToAnsi:{value:n=>t.ansi256ToAnsi(t.hexToAnsi256(n)),enumerable:!1}}),t}var Ao=bo(),vo=Ao,Fe=new Set(["\x1B","\x9B"]),Bo=39,Ge="\x07",Zt="[",$o="]",Qt="m",Ue=`${$o}8;;`,er=e=>`${Fe.values().next().value}${Zt}${e}${Qt}`,tr=e=>`${Fe.values().next().value}${Ue}${e}${Ge}`,xo=e=>e.split(" ").map(t=>U(t)),He=(e,t,n)=>{let r=[...t],o=!1,u=!1,s=U(Kt(e[e.length-1]));for(let[a,i]of r.entries()){let l=U(i);if(s+l<=n?e[e.length-1]+=i:(e.push(i),s=0),Fe.has(i)&&(o=!0,u=r.slice(a+1).join("").startsWith(Ue)),o){u?i===Ge&&(o=!1,u=!1):i===Qt&&(o=!1);continue}s+=l,s===n&&a<r.length-1&&(e.push(""),s=0)}!s&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Oo=e=>{let t=e.split(" "),n=t.length;for(;n>0&&!(U(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},Io=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let r="",o,u,s=xo(e),a=[""];for(let[l,f]of e.split(" ").entries()){n.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let D=U(a[a.length-1]);if(l!==0&&(D>=t&&(n.wordWrap===!1||n.trim===!1)&&(a.push(""),D=0),(D>0||n.trim===!1)&&(a[a.length-1]+=" ",D++)),n.hard&&s[l]>t){let c=t-D,p=1+Math.floor((s[l]-c-1)/t);Math.floor((s[l]-1)/t)<p&&a.push(""),He(a,f,t);continue}if(D+s[l]>t&&D>0&&s[l]>0){if(n.wordWrap===!1&&D<t){He(a,f,t);continue}a.push("")}if(D+s[l]>t&&n.wordWrap===!1){He(a,f,t);continue}a[a.length-1]+=f}n.trim!==!1&&(a=a.map(l=>Oo(l)));let i=[...a.join(`
4
- `)];for(let[l,f]of i.entries()){if(r+=f,Fe.has(f)){let{groups:c}=new RegExp(`(?:\\${Zt}(?<code>\\d+)m|\\${Ue}(?<uri>.*)${Ge})`).exec(i.slice(l).join(""))||{groups:{}};if(c.code!==void 0){let p=Number.parseFloat(c.code);o=p===Bo?void 0:p}else c.uri!==void 0&&(u=c.uri.length===0?void 0:c.uri)}let D=vo.codes.get(Number(o));i[l+1]===`
5
- `?(u&&(r+=tr("")),o&&D&&(r+=er(D))):f===`
6
- `&&(o&&D&&(r+=er(o)),u&&(r+=tr(u)))}return r};function So(e,t,n){return String(e).normalize().replace(/\r\n/g,`
2
+ import Re from"tty";import{createRequire as hn}from"module";import{Buffer as gn}from"node:buffer";import W from"node:path";import Nt from"node:child_process";import j from"node:process";import Cn from"child_process";import X from"path";import Le from"fs";import Fn from"node:url";import En,{constants as Tt}from"node:os";import Rt from"assert";import Lt from"events";import yn from"buffer";import ke from"stream";import kt from"util";import je from"inquirer";import Ge from"ora";import g from"chalk";import{of as G,from as S,tap as jt,map as P,concatMap as T,catchError as R,scan as Gt,switchMap as wn,mergeMap as bn,BehaviorSubject as Ut,ReplaySubject as An,lastValueFrom as vn,filter as $n,toArray as Bn}from"rxjs";import ue from"@anthropic-ai/sdk";import{fromPromise as U}from"rxjs/internal/observable/innerFrom";import xn from"http";import On from"https";import"@dqbd/tiktoken";import In from"net";import Sn from"tls";import Pn,{fileURLToPath as Mn,pathToFileURL as _n}from"url";import Ht from"os";import{FormData as Nn,Blob as Tn}from"formdata-node";import B from"fs/promises";import Rn from"axios";import{GoogleGenerativeAI as Ln}from"@google/generative-ai";import{Ollama as kn}from"ollama";import Ce from"readline";import jn from"figlet";import Gn from"inquirer-reactive-list-prompt";const Un="known-flag",Hn="unknown-flag",Kn="argument",{stringify:ie}=JSON,qn=/\B([A-Z])/g,zn=e=>e.replace(qn,"-$1").toLowerCase(),{hasOwnProperty:Yn}=Object.prototype,ae=(e,t)=>Yn.call(e,t),Vn=e=>Array.isArray(e),Kt=e=>typeof e=="function"?[e,!1]:Vn(e)?[e[0],!0]:Kt(e.type),Wn=(e,t)=>e===Boolean?t!=="false":t,Xn=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),Jn=/[\s.:=]/,Zn=e=>{const t=`Flag name ${ie(e)}`;if(e.length===0)throw new Error(`${t} cannot be empty`);if(e.length===1)throw new Error(`${t} must be longer than a character`);const r=e.match(Jn);if(r)throw new Error(`${t} cannot contain ${ie(r?.[0])}`)},Qn=e=>{const t={},r=(n,s)=>{if(ae(t,n))throw new Error(`Duplicate flags named ${ie(n)}`);t[n]=s};for(const n in e){if(!ae(e,n))continue;Zn(n);const s=e[n],o=[[],...Kt(s),s];r(n,o);const u=zn(n);if(n!==u&&r(u,o),"alias"in s&&typeof s.alias=="string"){const{alias:a}=s,i=`Flag alias ${ie(a)} for flag ${ie(n)}`;if(a.length===0)throw new Error(`${i} cannot be empty`);if(a.length>1)throw new Error(`${i} must be a single character`);r(a,o)}}return t},eo=(e,t)=>{const r={};for(const n in e){if(!ae(e,n))continue;const[s,,o,u]=t[n];if(s.length===0&&"default"in u){let{default:a}=u;typeof a=="function"&&(a=a()),r[n]=a}else r[n]=o?s:s.pop()}return r},Fe="--",to=/[.:=]/,ro=/^-{1,2}\w/,no=e=>{if(!ro.test(e))return;const t=!e.startsWith(Fe);let r=e.slice(t?1:2),n;const s=r.match(to);if(s){const{index:o}=s;n=r.slice(o+1),r=r.slice(0,o)}return[r,n,t]},oo=(e,{onFlag:t,onArgument:r})=>{let n;const s=(o,u)=>{if(typeof n!="function")return!0;n(o,u),n=void 0};for(let o=0;o<e.length;o+=1){const u=e[o];if(u===Fe){s();const i=e.slice(o+1);r?.(i,[o],!0);break}const a=no(u);if(a){if(s(),!t)continue;const[i,l,f]=a;if(f)for(let D=0;D<i.length;D+=1){s();const c=D===i.length-1;n=t(i[D],c?l:void 0,[o,D+1,c])}else n=t(i,l,[o])}else s(u,[o])&&r?.([u],[o])}s()},so=(e,t)=>{for(const[r,n,s]of t.reverse()){if(n){const o=e[r];let u=o.slice(0,n);if(s||(u+=o.slice(n+1)),u!=="-"){e[r]=u;continue}}e.splice(r,1)}},uo=(e,t=process.argv.slice(2),{ignore:r}={})=>{const n=[],s=Qn(e),o={},u=[];return u[Fe]=[],oo(t,{onFlag(a,i,l){const f=ae(s,a);if(!r?.(f?Un:Hn,a,i)){if(f){const[D,c]=s[a],p=Wn(c,i),d=(m,h)=>{n.push(l),h&&n.push(h),D.push(Xn(c,m||""))};return p===void 0?d:d(p)}ae(o,a)||(o[a]=[]),o[a].push(i===void 0?!0:i),n.push(l)}},onArgument(a,i,l){r?.(Kn,t[i[0]])||(u.push(...a),l?(u[Fe]=a,t.splice(i[0])):n.push(i))}}),so(t,n),{flags:eo(e,s),unknownFlags:o,_:u}};var io=Object.create,Ee=Object.defineProperty,ao=Object.defineProperties,Do=Object.getOwnPropertyDescriptor,co=Object.getOwnPropertyDescriptors,lo=Object.getOwnPropertyNames,qt=Object.getOwnPropertySymbols,fo=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty,po=Object.prototype.propertyIsEnumerable,Yt=(e,t,r)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ye=(e,t)=>{for(var r in t||(t={}))zt.call(t,r)&&Yt(e,r,t[r]);if(qt)for(var r of qt(t))po.call(t,r)&&Yt(e,r,t[r]);return e},Ue=(e,t)=>ao(e,co(t)),mo=e=>Ee(e,"__esModule",{value:!0}),ho=(e,t)=>()=>(e&&(t=e(e=0)),t),go=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Co=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of lo(t))!zt.call(e,s)&&(r||s!=="default")&&Ee(e,s,{get:()=>t[s],enumerable:!(n=Do(t,s))||n.enumerable});return e},Fo=(e,t)=>Co(mo(Ee(e!=null?io(fo(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),$=ho(()=>{}),Eo=go((e,t)=>{$(),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}});$(),$(),$();var yo=e=>{var t,r,n;let s=(t=process.stdout.columns)!=null?t:Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(s)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:s}:{columns:(r=e.columns)!=null?r:[],stdoutColumns:(n=e.stdoutColumns)!=null?n:s}};$(),$(),$(),$(),$();function wo({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 Vt(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(wo(),"")}$();function bo(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 Ao=Fo(Eo(),1);function K(e){if(typeof e!="string"||e.length===0||(e=Vt(e),e.length===0))return 0;e=e.replace((0,Ao.default)()," ");let t=0;for(let r=0;r<e.length;r++){let n=e.codePointAt(r);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&r++,t+=bo(n)?2:1)}return t}var Wt=e=>Math.max(...e.split(`
3
+ `).map(K)),vo=e=>{let t=[];for(let r of e){let{length:n}=r,s=n-t.length;for(let o=0;o<s;o+=1)t.push(0);for(let o=0;o<n;o+=1){let u=Wt(r[o]);u>t[o]&&(t[o]=u)}}return t};$();var Xt=/^\d+%$/,Jt={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},$o=(e,t)=>{var r;let n=[];for(let s=0;s<e.length;s+=1){let o=(r=t[s])!=null?r:"auto";if(typeof o=="number"||o==="auto"||o==="content-width"||typeof o=="string"&&Xt.test(o)){n.push(Ue(ye({},Jt),{width:o,contentWidth:e[s]}));continue}if(o&&typeof o=="object"){let u=Ue(ye(ye({},Jt),o),{contentWidth:e[s]});u.horizontalPadding=u.paddingLeft+u.paddingRight,n.push(u);continue}throw new Error(`Invalid column width: ${JSON.stringify(o)}`)}return n};function Bo(e,t){for(let r of e){let{width:n}=r;if(n==="content-width"&&(r.width=r.contentWidth),n==="auto"){let i=Math.min(20,r.contentWidth);r.width=i,r.autoOverflow=r.contentWidth-i}if(typeof n=="string"&&Xt.test(n)){let i=Number.parseFloat(n.slice(0,-1))/100;r.width=Math.floor(t*i)-(r.paddingLeft+r.paddingRight)}let{horizontalPadding:s}=r,o=1,u=o+s;if(u>=t){let i=u-t,l=Math.ceil(r.paddingLeft/s*i),f=i-l;r.paddingLeft-=l,r.paddingRight-=f,r.horizontalPadding=r.paddingLeft+r.paddingRight}r.paddingLeftString=r.paddingLeft?" ".repeat(r.paddingLeft):"",r.paddingRightString=r.paddingRight?" ".repeat(r.paddingRight):"";let a=t-r.horizontalPadding;r.width=Math.max(Math.min(r.width,a),o)}}var Zt=()=>Object.assign([],{columns:0});function xo(e,t){let r=[Zt()],[n]=r;for(let s of e){let o=s.width+s.horizontalPadding;n.columns+o>t&&(n=Zt(),r.push(n)),n.push(s),n.columns+=o}for(let s of r){let o=s.reduce((c,p)=>c+p.width+p.horizontalPadding,0),u=t-o;if(u===0)continue;let a=s.filter(c=>"autoOverflow"in c),i=a.filter(c=>c.autoOverflow>0),l=i.reduce((c,p)=>c+p.autoOverflow,0),f=Math.min(l,u);for(let c of i){let p=Math.floor(c.autoOverflow/l*f);c.width+=p,u-=p}let D=Math.floor(u/a.length);for(let c=0;c<a.length;c+=1){let p=a[c];c===a.length-1?p.width+=u:p.width+=D,u-=D}}return r}function Oo(e,t,r){let n=$o(r,t);return Bo(n,e),xo(n,e)}$(),$(),$();var He=10,Qt=(e=0)=>t=>`\x1B[${t+e}m`,er=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,tr=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`;function Io(){let e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(let[r,n]of Object.entries(t)){for(let[s,o]of Object.entries(n))t[s]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},n[s]=t[s],e.set(o[0],o[1]);Object.defineProperty(t,r,{value:n,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi=Qt(),t.color.ansi256=er(),t.color.ansi16m=tr(),t.bgColor.ansi=Qt(He),t.bgColor.ansi256=er(He),t.bgColor.ansi16m=tr(He),Object.defineProperties(t,{rgbToAnsi256:{value:(r,n,s)=>r===n&&n===s?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(n/255*5)+Math.round(s/255*5),enumerable:!1},hexToRgb:{value:r=>{let n=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!n)return[0,0,0];let{colorString:s}=n.groups;s.length===3&&(s=s.split("").map(u=>u+u).join(""));let o=Number.parseInt(s,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:r=>t.rgbToAnsi256(...t.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value:r=>{if(r<8)return 30+r;if(r<16)return 90+(r-8);let n,s,o;if(r>=232)n=((r-232)*10+8)/255,s=n,o=n;else{r-=16;let i=r%36;n=Math.floor(r/36)/5,s=Math.floor(i/6)/5,o=i%6/5}let u=Math.max(n,s,o)*2;if(u===0)return 30;let a=30+(Math.round(o)<<2|Math.round(s)<<1|Math.round(n));return u===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(r,n,s)=>t.ansi256ToAnsi(t.rgbToAnsi256(r,n,s)),enumerable:!1},hexToAnsi:{value:r=>t.ansi256ToAnsi(t.hexToAnsi256(r)),enumerable:!1}}),t}var So=Io(),Po=So,we=new Set(["\x1B","\x9B"]),Mo=39,Ke="\x07",rr="[",_o="]",nr="m",qe=`${_o}8;;`,or=e=>`${we.values().next().value}${rr}${e}${nr}`,sr=e=>`${we.values().next().value}${qe}${e}${Ke}`,No=e=>e.split(" ").map(t=>K(t)),ze=(e,t,r)=>{let n=[...t],s=!1,o=!1,u=K(Vt(e[e.length-1]));for(let[a,i]of n.entries()){let l=K(i);if(u+l<=r?e[e.length-1]+=i:(e.push(i),u=0),we.has(i)&&(s=!0,o=n.slice(a+1).join("").startsWith(qe)),s){o?i===Ke&&(s=!1,o=!1):i===nr&&(s=!1);continue}u+=l,u===r&&a<n.length-1&&(e.push(""),u=0)}!u&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},To=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(K(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Ro=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",s,o,u=No(e),a=[""];for(let[l,f]of e.split(" ").entries()){r.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let D=K(a[a.length-1]);if(l!==0&&(D>=t&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),D=0),(D>0||r.trim===!1)&&(a[a.length-1]+=" ",D++)),r.hard&&u[l]>t){let c=t-D,p=1+Math.floor((u[l]-c-1)/t);Math.floor((u[l]-1)/t)<p&&a.push(""),ze(a,f,t);continue}if(D+u[l]>t&&D>0&&u[l]>0){if(r.wordWrap===!1&&D<t){ze(a,f,t);continue}a.push("")}if(D+u[l]>t&&r.wordWrap===!1){ze(a,f,t);continue}a[a.length-1]+=f}r.trim!==!1&&(a=a.map(l=>To(l)));let i=[...a.join(`
4
+ `)];for(let[l,f]of i.entries()){if(n+=f,we.has(f)){let{groups:c}=new RegExp(`(?:\\${rr}(?<code>\\d+)m|\\${qe}(?<uri>.*)${Ke})`).exec(i.slice(l).join(""))||{groups:{}};if(c.code!==void 0){let p=Number.parseFloat(c.code);s=p===Mo?void 0:p}else c.uri!==void 0&&(o=c.uri.length===0?void 0:c.uri)}let D=Po.codes.get(Number(s));i[l+1]===`
5
+ `?(o&&(n+=sr("")),s&&D&&(n+=or(D))):f===`
6
+ `&&(s&&D&&(n+=or(s)),o&&(n+=sr(o)))}return n};function Lo(e,t,r){return String(e).normalize().replace(/\r\n/g,`
7
7
  `).split(`
8
- `).map(r=>Io(r,t,n)).join(`
9
- `)}var rr=e=>Array.from({length:e}).fill("");function Mo(e,t){let n=[],r=0;for(let o of e){let u=0,s=o.map(i=>{var l;let f=(l=t[r])!=null?l:"";r+=1,i.preprocess&&(f=i.preprocess(f)),qt(f)>i.width&&(f=So(f,i.width,{hard:!0}));let D=f.split(`
10
- `);if(i.postprocess){let{postprocess:c}=i;D=D.map((p,d)=>c.call(i,p,d))}return i.paddingTop&&D.unshift(...rr(i.paddingTop)),i.paddingBottom&&D.push(...rr(i.paddingBottom)),D.length>u&&(u=D.length),ke(Ce({},i),{lines:D})}),a=[];for(let i=0;i<u;i+=1){let l=s.map(f=>{var D;let c=(D=f.lines[i])!=null?D:"",p=Number.isFinite(f.width)?" ".repeat(f.width-U(c)):"",d=f.paddingLeftString;return f.align==="right"&&(d+=p),d+=c,f.align==="left"&&(d+=p),d+f.paddingRightString}).join("");a.push(l)}n.push(a.join(`
11
- `))}return n.join(`
12
- `)}function Po(e,t){if(!e||e.length===0)return"";let n=Co(e),r=n.length;if(r===0)return"";let{stdoutColumns:o,columns:u}=po(t);if(u.length>r)throw new Error(`${u.length} columns defined, but only ${r} columns found`);let s=wo(o,u,n);return e.map(a=>Mo(s,a)).join(`
13
- `)}B();var _o=["<",">","=",">=","<="];function To(e){if(!_o.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)}function No(e){let t=Object.keys(e).map(n=>{let[r,o]=n.split(" ");To(r);let u=Number.parseInt(o,10);if(Number.isNaN(u))throw new TypeError(`Invalid breakpoint value: ${o}`);let s=e[n];return{operator:r,breakpoint:u,value:s}}).sort((n,r)=>r.breakpoint-n.breakpoint);return n=>{var r;return(r=t.find(({operator:o,breakpoint:u})=>o==="="&&n===u||o===">"&&n>u||o==="<"&&n<u||o===">="&&n>=u||o==="<="&&n<=u))==null?void 0:r.value}}const Lo=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,n)=>n?n.toUpperCase():""),Ro=e=>e.replace(/\B([A-Z])/g,"-$1").toLowerCase(),ko={"> 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 jo(e){let t=!1;return{type:"table",data:{tableData:Object.keys(e).sort((n,r)=>n.localeCompare(r)).map(n=>{const r=e[n],o="alias"in r;return o&&(t=!0),{name:n,flag:r,flagFormatted:`--${Ro(n)}`,aliasesEnabled:t,aliasFormatted:o?`-${r.alias}`:void 0}}).map(n=>(n.aliasesEnabled=t,[{type:"flagName",data:n},{type:"flagDescription",data:n}])),tableBreakpoints:ko}}}const nr=e=>!e||(e.version??(e.help?e.help.version:void 0)),or=e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name};function Go(e){const t=[];e.name&&t.push(or(e));const n=nr(e)??("parent"in e&&nr(e.parent));if(n&&t.push(`v${n}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
14
- `}}function Uo(e){const{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
15
- `}}function Ho(e){const t=e.help||{};if("usage"in t)return t.usage?{id:"usage",type:"section",data:{title:"Usage:",body:Array.isArray(t.usage)?t.usage.join(`
16
- `):t.usage}}:void 0;if(e.name){const n=[],r=[or(e)];if(e.flags&&Object.keys(e.flags).length>0&&r.push("[flags...]"),e.parameters&&e.parameters.length>0){const{parameters:o}=e,u=o.indexOf("--"),s=u>-1&&o.slice(u+1).some(a=>a.startsWith("<"));r.push(o.map(a=>a!=="--"?a:s?"--":"[--]").join(" "))}if(r.length>1&&n.push(r.join(" ")),"commands"in e&&e.commands?.length&&n.push(`${e.name} <command>`),n.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:n.join(`
17
- `)}}}}function Ko(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 qo(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:jo(e.flags),indentBody:0}}}function zo(e){const{help:t}=e;if(!t||!t.examples||t.examples.length===0)return;let{examples:n}=t;if(Array.isArray(n)&&(n=n.join(`
18
- `)),n)return{id:"examples",type:"section",data:{title:"Examples:",body:n}}}function Yo(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 Wo=e=>[Go,Uo,Ho,Ko,qo,zo,Yo].map(t=>t(e)).filter(Boolean),Vo=Pe.WriteStream.prototype.hasColors();class Xo{text(t){return t}bold(t){return Vo?`\x1B[1m${t}\x1B[22m`:t.toLocaleUpperCase()}indentText({text:t,spaces:n}){return t.replace(/^/gm," ".repeat(n))}heading(t){return this.bold(t)}section({title:t,body:n,indentBody:r=2}){return`${(t?`${this.heading(t)}
19
- `:"")+(n?this.indentText({text:this.render(n),spaces:r}):"")}
20
- `}table({tableData:t,tableOptions:n,tableBreakpoints:r}){return Po(t.map(o=>o.map(u=>this.render(u))),r?No(r):n)}flagParameter(t){return t===Boolean?"":t===String?"<string>":t===Number?"<number>":Array.isArray(t)?this.flagParameter(t[0]):"<value>"}flagOperator(t){return" "}flagName(t){const{flag:n,flagFormatted:r,aliasesEnabled:o,aliasFormatted:u}=t;let s="";if(u?s+=`${u}, `:o&&(s+=" "),s+=r,"placeholder"in n&&typeof n.placeholder=="string")s+=`${this.flagOperator(t)}${n.placeholder}`;else{const a=this.flagParameter("type"in n?n.type:n);a&&(s+=`${this.flagOperator(t)}${a}`)}return s}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let n="description"in t?t.description??"":"";if("default"in t){let{default:r}=t;typeof r=="function"&&(r=r()),r&&(n+=` (default: ${this.flagDefault(r)})`)}return n}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(n=>this.render(n)).join(`
21
- `);if("type"in t&&this[t.type]){const n=this[t.type];if(typeof n=="function")return n.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}}const Ke=/^[\w.-]+$/,{stringify:I}=JSON,Jo=/[|\\{}()[\]^$+*?.]/;function qe(e){const t=[];let n,r;for(const o of e){if(r)throw new Error(`Invalid parameter: Spread parameter ${I(r)} must be last`);const u=o[0],s=o[o.length-1];let a;if(u==="<"&&s===">"&&(a=!0,n))throw new Error(`Invalid parameter: Required parameter ${I(o)} cannot come after optional parameter ${I(n)}`);if(u==="["&&s==="]"&&(a=!1,n=o),a===void 0)throw new Error(`Invalid parameter: ${I(o)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let i=o.slice(1,-1);const l=i.slice(-3)==="...";l&&(r=o,i=i.slice(0,-3));const f=i.match(Jo);if(f)throw new Error(`Invalid parameter: ${I(o)}. Invalid character found ${I(f[0])}`);t.push({name:i,required:a,spread:l})}return t}function ze(e,t,n,r){for(let o=0;o<t.length;o+=1){const{name:u,required:s,spread:a}=t[o],i=Lo(u);if(i in e)throw new Error(`Invalid parameter: ${I(u)} is used more than once.`);const l=a?n.slice(o):n[o];if(a&&(o=t.length),s&&(!l||a&&l.length===0))return console.error(`Error: Missing required parameter ${I(u)}
22
- `),r(),process.exit(1);e[i]=l}}function Zo(e){return e===void 0||e!==!1}function ur(e,t,n,r){const o={...t.flags},u=t.version;u&&(o.version={type:Boolean,description:"Show version"});const{help:s}=t,a=Zo(s);a&&!("help"in o)&&(o.help={type:Boolean,alias:"h",description:"Show help"});const i=Qn(o,r,{ignore:t.ignoreArgv}),l=()=>{console.log(t.version)};if(u&&i.flags.version===!0)return l(),process.exit(0);const f=new Xo,D=a&&s?.render?s.render:d=>f.render(d),c=d=>{const m=Wo({...t,...d?{help:d}:{},flags:o});console.log(D(m,f))};if(a&&i.flags.help===!0)return c(),process.exit(0);if(t.parameters){let{parameters:d}=t,m=i._;const h=d.indexOf("--"),C=d.slice(h+1),w=Object.create(null);if(h>-1&&C.length>0){d=d.slice(0,h);const O=i._["--"];m=m.slice(0,-O.length||void 0),ze(w,qe(d),m,c),ze(w,qe(C),O,c)}else ze(w,qe(d),m,c);Object.assign(i._,w)}const p={...i,showVersion:l,showHelp:c};return typeof n=="function"&&n(p),{command:e,...p}}function Qo(e,t){const n=new Map;for(const r of t){const o=[r.options.name],{alias:u}=r.options;u&&(Array.isArray(u)?o.push(...u):o.push(u));for(const s of o){if(n.has(s))throw new Error(`Duplicate command name found: ${I(s)}`);n.set(s,r)}}return n.get(e)}function eu(e,t,n=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Ke.test(e.name)))throw new Error(`Invalid script name: ${I(e.name)}`);const r=n[0];if(e.commands&&Ke.test(r)){const o=Qo(r,e.commands);if(o)return ur(o.options.name,{...o.options,parent:e},o.callback,n.slice(1))}return ur(void 0,e,t,n)}function sr(e,t){if(!e)throw new Error("Command options are required");const{name:n}=e;if(e.name===void 0)throw new Error("Command name is required");if(!Ke.test(n))throw new Error(`Invalid command name ${JSON.stringify(n)}. Command names must be one word.`);return{options:e,callback:t}}var tu=cn(import.meta.url),A=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function X(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var J={exports:{}},Ye,ir;function ru(){if(ir)return Ye;ir=1,Ye=r,r.sync=o;var e=_e;function t(u,s){var a=s.pathExt!==void 0?s.pathExt:process.env.PATHEXT;if(!a||(a=a.split(";"),a.indexOf("")!==-1))return!0;for(var i=0;i<a.length;i++){var l=a[i].toLowerCase();if(l&&u.substr(-l.length).toLowerCase()===l)return!0}return!1}function n(u,s,a){return!u.isSymbolicLink()&&!u.isFile()?!1:t(s,a)}function r(u,s,a){e.stat(u,function(i,l){a(i,i?!1:n(l,u,s))})}function o(u,s){return n(e.statSync(u),u,s)}return Ye}var We,ar;function nu(){if(ar)return We;ar=1,We=t,t.sync=n;var e=_e;function t(u,s,a){e.stat(u,function(i,l){a(i,i?!1:r(l,s))})}function n(u,s){return r(e.statSync(u),s)}function r(u,s){return u.isFile()&&o(u,s)}function o(u,s){var a=u.mode,i=u.uid,l=u.gid,f=s.uid!==void 0?s.uid:process.getuid&&process.getuid(),D=s.gid!==void 0?s.gid:process.getgid&&process.getgid(),c=parseInt("100",8),p=parseInt("010",8),d=parseInt("001",8),m=c|p,h=a&d||a&p&&l===D||a&c&&i===f||a&m&&f===0;return h}return We}var Ee;process.platform==="win32"||A.TESTING_WINDOWS?Ee=ru():Ee=nu();var ou=Ve;Ve.sync=uu;function Ve(e,t,n){if(typeof t=="function"&&(n=t,t={}),!n){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(r,o){Ve(e,t||{},function(u,s){u?o(u):r(s)})})}Ee(e,t||{},function(r,o){r&&(r.code==="EACCES"||t&&t.ignoreErrors)&&(r=null,o=!1),n(r,o)})}function uu(e,t){try{return Ee.sync(e,t||{})}catch(n){if(t&&t.ignoreErrors||n.code==="EACCES")return!1;throw n}}const Z=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Dr=V,su=Z?";":":",cr=ou,lr=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),fr=(e,t)=>{const n=t.colon||su,r=e.match(/\//)||Z&&e.match(/\\/)?[""]:[...Z?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(n)],o=Z?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",u=Z?o.split(n):[""];return Z&&e.indexOf(".")!==-1&&u[0]!==""&&u.unshift(""),{pathEnv:r,pathExt:u,pathExtExe:o}},pr=(e,t,n)=>{typeof t=="function"&&(n=t,t={}),t||(t={});const{pathEnv:r,pathExt:o,pathExtExe:u}=fr(e,t),s=[],a=l=>new Promise((f,D)=>{if(l===r.length)return t.all&&s.length?f(s):D(lr(e));const c=r[l],p=/^".*"$/.test(c)?c.slice(1,-1):c,d=Dr.join(p,e),m=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;f(i(m,l,0))}),i=(l,f,D)=>new Promise((c,p)=>{if(D===o.length)return c(a(f+1));const d=o[D];cr(l+d,{pathExt:u},(m,h)=>{if(!m&&h)if(t.all)s.push(l+d);else return c(l+d);return c(i(l,f,D+1))})});return n?a(0).then(l=>n(null,l),n):a(0)},iu=(e,t)=>{t=t||{};const{pathEnv:n,pathExt:r,pathExtExe:o}=fr(e,t),u=[];for(let s=0;s<n.length;s++){const a=n[s],i=/^".*"$/.test(a)?a.slice(1,-1):a,l=Dr.join(i,e),f=!i&&/^\.[\\\/]/.test(e)?e.slice(0,2)+l:l;for(let D=0;D<r.length;D++){const c=f+r[D];try{if(cr.sync(c,{pathExt:o}))if(t.all)u.push(c);else return c}catch{}}}if(t.all&&u.length)return u;if(t.nothrow)return null;throw lr(e)};var au=pr;pr.sync=iu;var Xe={exports:{}};const dr=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"};Xe.exports=dr,Xe.exports.default=dr;var Du=Xe.exports;const mr=V,cu=au,lu=Du;function hr(e,t){const n=e.options.env||process.env,r=process.cwd(),o=e.options.cwd!=null,u=o&&process.chdir!==void 0&&!process.chdir.disabled;if(u)try{process.chdir(e.options.cwd)}catch{}let s;try{s=cu.sync(e.command,{path:n[lu({env:n})],pathExt:t?mr.delimiter:void 0})}catch{}finally{u&&process.chdir(r)}return s&&(s=mr.resolve(o?e.options.cwd:"",s)),s}function fu(e){return hr(e)||hr(e,!0)}var pu=fu,Je={};const Ze=/([()\][%!^"`<>&|;, *?])/g;function du(e){return e=e.replace(Ze,"^$1"),e}function mu(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(Ze,"^$1"),t&&(e=e.replace(Ze,"^$1")),e}Je.command=du,Je.argument=mu;var hu=/^#!(.*)/;const gu=hu;var Cu=(e="")=>{const t=e.match(gu);if(!t)return null;const[n,r]=t[0].replace(/#! ?/,"").split(" "),o=n.split("/").pop();return o==="env"?r:r?`${o} ${r}`:o};const Qe=_e,Fu=Cu;function Eu(e){const n=Buffer.alloc(150);let r;try{r=Qe.openSync(e,"r"),Qe.readSync(r,n,0,150,0),Qe.closeSync(r)}catch{}return Fu(n.toString())}var yu=Eu;const wu=V,gr=pu,Cr=Je,bu=yu,Au=process.platform==="win32",vu=/\.(?:com|exe)$/i,Bu=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function $u(e){e.file=gr(e);const t=e.file&&bu(e.file);return t?(e.args.unshift(e.file),e.command=t,gr(e)):e.file}function xu(e){if(!Au)return e;const t=$u(e),n=!vu.test(t);if(e.options.forceShell||n){const r=Bu.test(t);e.command=wu.normalize(e.command),e.command=Cr.command(e.command),e.args=e.args.map(u=>Cr.argument(u,r));const o=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${o}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function Ou(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);const r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:xu(r)}var Iu=Ou;const et=process.platform==="win32";function tt(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 Su(e,t){if(!et)return;const n=e.emit;e.emit=function(r,o){if(r==="exit"){const u=Fr(o,t);if(u)return n.call(e,"error",u)}return n.apply(e,arguments)}}function Fr(e,t){return et&&e===1&&!t.file?tt(t.original,"spawn"):null}function Mu(e,t){return et&&e===1&&!t.file?tt(t.original,"spawnSync"):null}var Pu={hookChildProcess:Su,verifyENOENT:Fr,verifyENOENTSync:Mu,notFoundError:tt};const Er=fn,rt=Iu,nt=Pu;function yr(e,t,n){const r=rt(e,t,n),o=Er.spawn(r.command,r.args,r.options);return nt.hookChildProcess(o,r),o}function _u(e,t,n){const r=rt(e,t,n),o=Er.spawnSync(r.command,r.args,r.options);return o.error=o.error||nt.verifyENOENTSync(o.status,r),o}J.exports=yr,J.exports.spawn=yr,J.exports.sync=_u,J.exports._parse=rt,J.exports._enoent=nt;var Tu=J.exports,Nu=X(Tu);function Lu(e){const t=typeof e=="string"?`
8
+ `).map(n=>Ro(n,t,r)).join(`
9
+ `)}var ur=e=>Array.from({length:e}).fill("");function ko(e,t){let r=[],n=0;for(let s of e){let o=0,u=s.map(i=>{var l;let f=(l=t[n])!=null?l:"";n+=1,i.preprocess&&(f=i.preprocess(f)),Wt(f)>i.width&&(f=Lo(f,i.width,{hard:!0}));let D=f.split(`
10
+ `);if(i.postprocess){let{postprocess:c}=i;D=D.map((p,d)=>c.call(i,p,d))}return i.paddingTop&&D.unshift(...ur(i.paddingTop)),i.paddingBottom&&D.push(...ur(i.paddingBottom)),D.length>o&&(o=D.length),Ue(ye({},i),{lines:D})}),a=[];for(let i=0;i<o;i+=1){let l=u.map(f=>{var D;let c=(D=f.lines[i])!=null?D:"",p=Number.isFinite(f.width)?" ".repeat(f.width-K(c)):"",d=f.paddingLeftString;return f.align==="right"&&(d+=p),d+=c,f.align==="left"&&(d+=p),d+f.paddingRightString}).join("");a.push(l)}r.push(a.join(`
11
+ `))}return r.join(`
12
+ `)}function jo(e,t){if(!e||e.length===0)return"";let r=vo(e),n=r.length;if(n===0)return"";let{stdoutColumns:s,columns:o}=yo(t);if(o.length>n)throw new Error(`${o.length} columns defined, but only ${n} columns found`);let u=Oo(s,o,r);return e.map(a=>ko(u,a)).join(`
13
+ `)}$();var Go=["<",">","=",">=","<="];function Uo(e){if(!Go.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)}function Ho(e){let t=Object.keys(e).map(r=>{let[n,s]=r.split(" ");Uo(n);let o=Number.parseInt(s,10);if(Number.isNaN(o))throw new TypeError(`Invalid breakpoint value: ${s}`);let u=e[r];return{operator:n,breakpoint:o,value:u}}).sort((r,n)=>n.breakpoint-r.breakpoint);return r=>{var n;return(n=t.find(({operator:s,breakpoint:o})=>s==="="&&r===o||s===">"&&r>o||s==="<"&&r<o||s===">="&&r>=o||s==="<="&&r<=o))==null?void 0:n.value}}const Ko=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,r)=>r?r.toUpperCase():""),qo=e=>e.replace(/\B([A-Z])/g,"-$1").toLowerCase(),zo={"> 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 Yo(e){let t=!1;return{type:"table",data:{tableData:Object.keys(e).sort((r,n)=>r.localeCompare(n)).map(r=>{const n=e[r],s="alias"in n;return s&&(t=!0),{name:r,flag:n,flagFormatted:`--${qo(r)}`,aliasesEnabled:t,aliasFormatted:s?`-${n.alias}`:void 0}}).map(r=>(r.aliasesEnabled=t,[{type:"flagName",data:r},{type:"flagDescription",data:r}])),tableBreakpoints:zo}}}const ir=e=>!e||(e.version??(e.help?e.help.version:void 0)),ar=e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name};function Vo(e){const t=[];e.name&&t.push(ar(e));const r=ir(e)??("parent"in e&&ir(e.parent));if(r&&t.push(`v${r}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
14
+ `}}function Wo(e){const{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
15
+ `}}function Xo(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=[],n=[ar(e)];if(e.flags&&Object.keys(e.flags).length>0&&n.push("[flags...]"),e.parameters&&e.parameters.length>0){const{parameters:s}=e,o=s.indexOf("--"),u=o>-1&&s.slice(o+1).some(a=>a.startsWith("<"));n.push(s.map(a=>a!=="--"?a:u?"--":"[--]").join(" "))}if(n.length>1&&r.push(n.join(" ")),"commands"in e&&e.commands?.length&&r.push(`${e.name} <command>`),r.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:r.join(`
17
+ `)}}}}function Jo(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 Zo(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:Yo(e.flags),indentBody:0}}}function Qo(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 es(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 ts=e=>[Vo,Wo,Xo,Jo,Zo,Qo,es].map(t=>t(e)).filter(Boolean),rs=Re.WriteStream.prototype.hasColors();class ns{text(t){return t}bold(t){return rs?`\x1B[1m${t}\x1B[22m`:t.toLocaleUpperCase()}indentText({text:t,spaces:r}){return t.replace(/^/gm," ".repeat(r))}heading(t){return this.bold(t)}section({title:t,body:r,indentBody:n=2}){return`${(t?`${this.heading(t)}
19
+ `:"")+(r?this.indentText({text:this.render(r),spaces:n}):"")}
20
+ `}table({tableData:t,tableOptions:r,tableBreakpoints:n}){return jo(t.map(s=>s.map(o=>this.render(o))),n?Ho(n):r)}flagParameter(t){return t===Boolean?"":t===String?"<string>":t===Number?"<number>":Array.isArray(t)?this.flagParameter(t[0]):"<value>"}flagOperator(t){return" "}flagName(t){const{flag:r,flagFormatted:n,aliasesEnabled:s,aliasFormatted:o}=t;let u="";if(o?u+=`${o}, `:s&&(u+=" "),u+=n,"placeholder"in r&&typeof r.placeholder=="string")u+=`${this.flagOperator(t)}${r.placeholder}`;else{const a=this.flagParameter("type"in r?r.type:r);a&&(u+=`${this.flagOperator(t)}${a}`)}return u}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let r="description"in t?t.description??"":"";if("default"in t){let{default:n}=t;typeof n=="function"&&(n=n()),n&&(r+=` (default: ${this.flagDefault(n)})`)}return r}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(r=>this.render(r)).join(`
21
+ `);if("type"in t&&this[t.type]){const r=this[t.type];if(typeof r=="function")return r.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}}const Ye=/^[\w.-]+$/,{stringify:M}=JSON,os=/[|\\{}()[\]^$+*?.]/;function Ve(e){const t=[];let r,n;for(const s of e){if(n)throw new Error(`Invalid parameter: Spread parameter ${M(n)} must be last`);const o=s[0],u=s[s.length-1];let a;if(o==="<"&&u===">"&&(a=!0,r))throw new Error(`Invalid parameter: Required parameter ${M(s)} cannot come after optional parameter ${M(r)}`);if(o==="["&&u==="]"&&(a=!1,r=s),a===void 0)throw new Error(`Invalid parameter: ${M(s)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let i=s.slice(1,-1);const l=i.slice(-3)==="...";l&&(n=s,i=i.slice(0,-3));const f=i.match(os);if(f)throw new Error(`Invalid parameter: ${M(s)}. Invalid character found ${M(f[0])}`);t.push({name:i,required:a,spread:l})}return t}function We(e,t,r,n){for(let s=0;s<t.length;s+=1){const{name:o,required:u,spread:a}=t[s],i=Ko(o);if(i in e)throw new Error(`Invalid parameter: ${M(o)} is used more than once.`);const l=a?r.slice(s):r[s];if(a&&(s=t.length),u&&(!l||a&&l.length===0))return console.error(`Error: Missing required parameter ${M(o)}
22
+ `),n(),process.exit(1);e[i]=l}}function ss(e){return e===void 0||e!==!1}function Dr(e,t,r,n){const s={...t.flags},o=t.version;o&&(s.version={type:Boolean,description:"Show version"});const{help:u}=t,a=ss(u);a&&!("help"in s)&&(s.help={type:Boolean,alias:"h",description:"Show help"});const i=uo(s,n,{ignore:t.ignoreArgv}),l=()=>{console.log(t.version)};if(o&&i.flags.version===!0)return l(),process.exit(0);const f=new ns,D=a&&u?.render?u.render:d=>f.render(d),c=d=>{const m=ts({...t,...d?{help:d}:{},flags:s});console.log(D(m,f))};if(a&&i.flags.help===!0)return c(),process.exit(0);if(t.parameters){let{parameters:d}=t,m=i._;const h=d.indexOf("--"),C=d.slice(h+1),w=Object.create(null);if(h>-1&&C.length>0){d=d.slice(0,h);const I=i._["--"];m=m.slice(0,-I.length||void 0),We(w,Ve(d),m,c),We(w,Ve(C),I,c)}else We(w,Ve(d),m,c);Object.assign(i._,w)}const p={...i,showVersion:l,showHelp:c};return typeof r=="function"&&r(p),{command:e,...p}}function us(e,t){const r=new Map;for(const n of t){const s=[n.options.name],{alias:o}=n.options;o&&(Array.isArray(o)?s.push(...o):s.push(o));for(const u of s){if(r.has(u))throw new Error(`Duplicate command name found: ${M(u)}`);r.set(u,n)}}return r.get(e)}function is(e,t,r=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Ye.test(e.name)))throw new Error(`Invalid script name: ${M(e.name)}`);const n=r[0];if(e.commands&&Ye.test(n)){const s=us(n,e.commands);if(s)return Dr(s.options.name,{...s.options,parent:e},s.callback,r.slice(1))}return Dr(void 0,e,t,r)}function cr(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(!Ye.test(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:e,callback:t}}var as=hn(import.meta.url),A=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function J(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Z={exports:{}},Xe,lr;function Ds(){if(lr)return Xe;lr=1,Xe=n,n.sync=s;var e=Le;function t(o,u){var a=u.pathExt!==void 0?u.pathExt:process.env.PATHEXT;if(!a||(a=a.split(";"),a.indexOf("")!==-1))return!0;for(var i=0;i<a.length;i++){var l=a[i].toLowerCase();if(l&&o.substr(-l.length).toLowerCase()===l)return!0}return!1}function r(o,u,a){return!o.isSymbolicLink()&&!o.isFile()?!1:t(u,a)}function n(o,u,a){e.stat(o,function(i,l){a(i,i?!1:r(l,o,u))})}function s(o,u){return r(e.statSync(o),o,u)}return Xe}var Je,fr;function cs(){if(fr)return Je;fr=1,Je=t,t.sync=r;var e=Le;function t(o,u,a){e.stat(o,function(i,l){a(i,i?!1:n(l,u))})}function r(o,u){return n(e.statSync(o),u)}function n(o,u){return o.isFile()&&s(o,u)}function s(o,u){var a=o.mode,i=o.uid,l=o.gid,f=u.uid!==void 0?u.uid:process.getuid&&process.getuid(),D=u.gid!==void 0?u.gid:process.getgid&&process.getgid(),c=parseInt("100",8),p=parseInt("010",8),d=parseInt("001",8),m=c|p,h=a&d||a&p&&l===D||a&c&&i===f||a&m&&f===0;return h}return Je}var be;process.platform==="win32"||A.TESTING_WINDOWS?be=Ds():be=cs();var ls=Ze;Ze.sync=fs;function Ze(e,t,r){if(typeof t=="function"&&(r=t,t={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,s){Ze(e,t||{},function(o,u){o?s(o):n(u)})})}be(e,t||{},function(n,s){n&&(n.code==="EACCES"||t&&t.ignoreErrors)&&(n=null,s=!1),r(n,s)})}function fs(e,t){try{return be.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}const Q=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",pr=X,ps=Q?";":":",dr=ls,mr=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),hr=(e,t)=>{const r=t.colon||ps,n=e.match(/\//)||Q&&e.match(/\\/)?[""]:[...Q?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],s=Q?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=Q?s.split(r):[""];return Q&&e.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:n,pathExt:o,pathExtExe:s}},gr=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});const{pathEnv:n,pathExt:s,pathExtExe:o}=hr(e,t),u=[],a=l=>new Promise((f,D)=>{if(l===n.length)return t.all&&u.length?f(u):D(mr(e));const c=n[l],p=/^".*"$/.test(c)?c.slice(1,-1):c,d=pr.join(p,e),m=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;f(i(m,l,0))}),i=(l,f,D)=>new Promise((c,p)=>{if(D===s.length)return c(a(f+1));const d=s[D];dr(l+d,{pathExt:o},(m,h)=>{if(!m&&h)if(t.all)u.push(l+d);else return c(l+d);return c(i(l,f,D+1))})});return r?a(0).then(l=>r(null,l),r):a(0)},ds=(e,t)=>{t=t||{};const{pathEnv:r,pathExt:n,pathExtExe:s}=hr(e,t),o=[];for(let u=0;u<r.length;u++){const a=r[u],i=/^".*"$/.test(a)?a.slice(1,-1):a,l=pr.join(i,e),f=!i&&/^\.[\\\/]/.test(e)?e.slice(0,2)+l:l;for(let D=0;D<n.length;D++){const c=f+n[D];try{if(dr.sync(c,{pathExt:s}))if(t.all)o.push(c);else return c}catch{}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw mr(e)};var ms=gr;gr.sync=ds;var Qe={exports:{}};const Cr=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};Qe.exports=Cr,Qe.exports.default=Cr;var hs=Qe.exports;const Fr=X,gs=ms,Cs=hs;function Er(e,t){const r=e.options.env||process.env,n=process.cwd(),s=e.options.cwd!=null,o=s&&process.chdir!==void 0&&!process.chdir.disabled;if(o)try{process.chdir(e.options.cwd)}catch{}let u;try{u=gs.sync(e.command,{path:r[Cs({env:r})],pathExt:t?Fr.delimiter:void 0})}catch{}finally{o&&process.chdir(n)}return u&&(u=Fr.resolve(s?e.options.cwd:"",u)),u}function Fs(e){return Er(e)||Er(e,!0)}var Es=Fs,et={};const tt=/([()\][%!^"`<>&|;, *?])/g;function ys(e){return e=e.replace(tt,"^$1"),e}function ws(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(tt,"^$1"),t&&(e=e.replace(tt,"^$1")),e}et.command=ys,et.argument=ws;var bs=/^#!(.*)/;const As=bs;var vs=(e="")=>{const t=e.match(As);if(!t)return null;const[r,n]=t[0].replace(/#! ?/,"").split(" "),s=r.split("/").pop();return s==="env"?n:n?`${s} ${n}`:s};const rt=Le,$s=vs;function Bs(e){const r=Buffer.alloc(150);let n;try{n=rt.openSync(e,"r"),rt.readSync(n,r,0,150,0),rt.closeSync(n)}catch{}return $s(r.toString())}var xs=Bs;const Os=X,yr=Es,wr=et,Is=xs,Ss=process.platform==="win32",Ps=/\.(?:com|exe)$/i,Ms=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function _s(e){e.file=yr(e);const t=e.file&&Is(e.file);return t?(e.args.unshift(e.file),e.command=t,yr(e)):e.file}function Ns(e){if(!Ss)return e;const t=_s(e),r=!Ps.test(t);if(e.options.forceShell||r){const n=Ms.test(t);e.command=Os.normalize(e.command),e.command=wr.command(e.command),e.args=e.args.map(o=>wr.argument(o,n));const s=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${s}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function Ts(e,t,r){t&&!Array.isArray(t)&&(r=t,t=null),t=t?t.slice(0):[],r=Object.assign({},r);const n={command:e,args:t,options:r,file:void 0,original:{command:e,args:t}};return r.shell?n:Ns(n)}var Rs=Ts;const nt=process.platform==="win32";function ot(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function Ls(e,t){if(!nt)return;const r=e.emit;e.emit=function(n,s){if(n==="exit"){const o=br(s,t);if(o)return r.call(e,"error",o)}return r.apply(e,arguments)}}function br(e,t){return nt&&e===1&&!t.file?ot(t.original,"spawn"):null}function ks(e,t){return nt&&e===1&&!t.file?ot(t.original,"spawnSync"):null}var js={hookChildProcess:Ls,verifyENOENT:br,verifyENOENTSync:ks,notFoundError:ot};const Ar=Cn,st=Rs,ut=js;function vr(e,t,r){const n=st(e,t,r),s=Ar.spawn(n.command,n.args,n.options);return ut.hookChildProcess(s,n),s}function Gs(e,t,r){const n=st(e,t,r),s=Ar.spawnSync(n.command,n.args,n.options);return s.error=s.error||ut.verifyENOENTSync(s.status,n),s}Z.exports=vr,Z.exports.spawn=vr,Z.exports.sync=Gs,Z.exports._parse=st,Z.exports._enoent=ut;var Us=Z.exports,Hs=J(Us);function Ks(e){const t=typeof e=="string"?`
23
23
  `:`
24
- `.charCodeAt(),n=typeof e=="string"?"\r":"\r".charCodeAt();return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===n&&(e=e.slice(0,-1)),e}function wr(e={}){const{env:t=process.env,platform:n=process.platform}=e;return n!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"}function Ru(e={}){const{cwd:t=_.cwd(),path:n=_.env[wr()],execPath:r=_.execPath}=e;let o;const u=t instanceof URL?pn.fileURLToPath(t):t;let s=W.resolve(u);const a=[];for(;o!==s;)a.push(W.join(s,"node_modules/.bin")),o=s,s=W.resolve(s,"..");return a.push(W.resolve(u,r,"..")),[...a,n].join(W.delimiter)}function ku({env:e=_.env,...t}={}){e={...e};const n=wr({env:e});return t.path=e[n],e[n]=Ru(t),e}const ju=(e,t,n,r)=>{if(n==="length"||n==="prototype"||n==="arguments"||n==="caller")return;const o=Object.getOwnPropertyDescriptor(e,n),u=Object.getOwnPropertyDescriptor(t,n);!Gu(o,u)&&r||Object.defineProperty(e,n,u)},Gu=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)},Uu=(e,t)=>{const n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},Hu=(e,t)=>`/* Wrapped ${e}*/
25
- ${t}`,Ku=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),qu=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),zu=(e,t,n)=>{const r=n===""?"":`with ${n.trim()}() `,o=Hu.bind(null,r,t.toString());Object.defineProperty(o,"name",qu),Object.defineProperty(e,"toString",{...Ku,value:o})};function Yu(e,t,{ignoreNonConfigurable:n=!1}={}){const{name:r}=e;for(const o of Reflect.ownKeys(t))ju(e,t,o,n);return Uu(e,t),zu(e,t,r),e}const ye=new WeakMap,br=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let n,r=0;const o=e.displayName||e.name||"<anonymous>",u=function(...s){if(ye.set(u,++r),r===1)n=e.apply(this,s),e=null;else if(t.throw===!0)throw new Error(`Function \`${o}\` can only be called once`);return n};return Yu(u,e),ye.set(u,r),u};br.callCount=e=>{if(!ye.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return ye.get(e)};const Wu=()=>{const e=vr-Ar+1;return Array.from({length:e},Vu)},Vu=(e,t)=>({name:`SIGRT${t+1}`,number:Ar+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Ar=34,vr=64,Xu=[{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"}],Br=()=>{const e=Wu();return[...Xu,...e].map(Ju)},Ju=({name:e,number:t,description:n,action:r,forced:o=!1,standard:u})=>{const{signals:{[e]:s}}=_t,a=s!==void 0;return{name:e,number:a?s:t,description:n,supported:a,action:r,forced:o,standard:u}},Zu=()=>{const e=Br();return Object.fromEntries(e.map(Qu))},Qu=({name:e,number:t,description:n,supported:r,action:o,forced:u,standard:s})=>[e,{name:e,number:t,description:n,supported:r,action:o,forced:u,standard:s}],es=Zu(),ts=()=>{const e=Br(),t=vr+1,n=Array.from({length:t},(r,o)=>rs(o,e));return Object.assign({},...n)},rs=(e,t)=>{const n=ns(e,t);if(n===void 0)return{};const{name:r,description:o,supported:u,action:s,forced:a,standard:i}=n;return{[e]:{name:r,number:e,description:o,supported:u,action:s,forced:a,standard:i}}},ns=(e,t)=>{const n=t.find(({name:r})=>_t.signals[r]===e);return n!==void 0?n:t.find(r=>r.number===e)};ts();const os=({timedOut:e,timeout:t,errorCode:n,signal:r,signalDescription:o,exitCode:u,isCanceled:s})=>e?`timed out after ${t} milliseconds`:s?"was canceled":n!==void 0?`failed with ${n}`:r!==void 0?`was killed with ${r} (${o})`:u!==void 0?`failed with exit code ${u}`:"failed",$r=({stdout:e,stderr:t,all:n,error:r,signal:o,exitCode:u,command:s,escapedCommand:a,timedOut:i,isCanceled:l,killed:f,parsed:{options:{timeout:D}}})=>{u=u===null?void 0:u,o=o===null?void 0:o;const c=o===void 0?void 0:es[o].description,p=r&&r.code,m=`Command ${os({timedOut:i,timeout:D,errorCode:p,signal:o,signalDescription:c,exitCode:u,isCanceled:l})}: ${s}`,h=Object.prototype.toString.call(r)==="[object Error]",C=h?`${m}
26
- ${r.message}`:m,w=[C,t,e].filter(Boolean).join(`
27
- `);return h?(r.originalMessage=r.message,r.message=w):r=new Error(w),r.shortMessage=C,r.command=s,r.escapedCommand=a,r.exitCode=u,r.signal=o,r.signalDescription=c,r.stdout=e,r.stderr=t,n!==void 0&&(r.all=n),"bufferedData"in r&&delete r.bufferedData,r.failed=!0,r.timedOut=!!i,r.isCanceled=l,r.killed=f&&!i,r},we=["stdin","stdout","stderr"],us=e=>we.some(t=>e[t]!==void 0),ss=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return we.map(r=>e[r]);if(us(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${we.map(r=>`\`${r}\``).join(", ")}`);if(typeof t=="string")return t;if(!Array.isArray(t))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);const n=Math.max(t.length,we.length);return Array.from({length:n},(r,o)=>t[o])};var Q={exports:{}},be={exports:{}};be.exports;var xr;function is(){return xr||(xr=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")}(be)),be.exports}var F=A.process;const H=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(!H(F))Q.exports=function(){return function(){}};else{var as=Tt,ie=is(),Ds=/^win/i.test(F.platform),Ae=Nt;typeof Ae!="function"&&(Ae=Ae.EventEmitter);var v;F.__signal_exit_emitter__?v=F.__signal_exit_emitter__:(v=F.__signal_exit_emitter__=new Ae,v.count=0,v.emitted={}),v.infinite||(v.setMaxListeners(1/0),v.infinite=!0),Q.exports=function(e,t){if(!H(A.process))return function(){};as.equal(typeof e,"function","a callback must be provided for exit handler"),ae===!1&&Or();var n="exit";t&&t.alwaysLast&&(n="afterexit");var r=function(){v.removeListener(n,e),v.listeners("exit").length===0&&v.listeners("afterexit").length===0&&ot()};return v.on(n,e),r};var ot=function(){!ae||!H(A.process)||(ae=!1,ie.forEach(function(t){try{F.removeListener(t,ut[t])}catch{}}),F.emit=st,F.reallyExit=Ir,v.count-=1)};Q.exports.unload=ot;var ee=function(t,n,r){v.emitted[t]||(v.emitted[t]=!0,v.emit(t,n,r))},ut={};ie.forEach(function(e){ut[e]=function(){if(H(A.process)){var n=F.listeners(e);n.length===v.count&&(ot(),ee("exit",null,e),ee("afterexit",null,e),Ds&&e==="SIGHUP"&&(e="SIGINT"),F.kill(F.pid,e))}}}),Q.exports.signals=function(){return ie};var ae=!1,Or=function(){ae||!H(A.process)||(ae=!0,v.count+=1,ie=ie.filter(function(t){try{return F.on(t,ut[t]),!0}catch{return!1}}),F.emit=ls,F.reallyExit=cs)};Q.exports.load=Or;var Ir=F.reallyExit,cs=function(t){H(A.process)&&(F.exitCode=t||0,ee("exit",F.exitCode,null),ee("afterexit",F.exitCode,null),Ir.call(F,F.exitCode))},st=F.emit,ls=function(t,n){if(t==="exit"&&H(A.process)){n!==void 0&&(F.exitCode=n);var r=st.apply(this,arguments);return ee("exit",F.exitCode,null),ee("afterexit",F.exitCode,null),r}else return st.apply(this,arguments)}}var fs=Q.exports,ps=X(fs);const ds=1e3*5,ms=(e,t="SIGTERM",n={})=>{const r=e(t);return hs(e,t,n,r),r},hs=(e,t,n,r)=>{if(!gs(t,n,r))return;const o=Fs(n),u=setTimeout(()=>{e("SIGKILL")},o);u.unref&&u.unref()},gs=(e,{forceKillAfterTimeout:t},n)=>Cs(e)&&t!==!1&&n,Cs=e=>e===dn.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",Fs=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return ds;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},Es=(e,t)=>{e.kill()&&(t.isCanceled=!0)},ys=(e,t,n)=>{e.kill(t),n(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},ws=(e,{timeout:t,killSignal:n="SIGTERM"},r)=>{if(t===0||t===void 0)return r;let o;const u=new Promise((a,i)=>{o=setTimeout(()=>{ys(e,n,i)},t)}),s=r.finally(()=>{clearTimeout(o)});return Promise.race([u,s])},bs=({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})`)},As=async(e,{cleanup:t,detached:n},r)=>{if(!t||n)return r;const o=ps(()=>{e.kill()});return r.finally(()=>{o()})};function vs(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}var De={exports:{}};const{PassThrough:Bs}=Te;var $s=e=>{e={...e};const{array:t}=e;let{encoding:n}=e;const r=n==="buffer";let o=!1;t?o=!(n||r):n=n||"utf8",r&&(n=null);const u=new Bs({objectMode:o});n&&u.setEncoding(n);let s=0;const a=[];return u.on("data",i=>{a.push(i),o?s=a.length:s+=i.length}),u.getBufferedValue=()=>t?a:r?Buffer.concat(a,s):a.join(""),u.getBufferedLength=()=>s,u};const{constants:xs}=mn,Os=Te,{promisify:Is}=Lt,Ss=$s,Ms=Is(Os.pipeline);class Sr extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function it(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:n}=t,r=Ss(t);return await new Promise((o,u)=>{const s=a=>{a&&r.getBufferedLength()<=xs.MAX_LENGTH&&(a.bufferedData=r.getBufferedValue()),u(a)};(async()=>{try{await Ms(e,r),o()}catch(a){s(a)}})(),r.on("data",()=>{r.getBufferedLength()>n&&s(new Sr)})}),r.getBufferedValue()}De.exports=it,De.exports.buffer=(e,t)=>it(e,{...t,encoding:"buffer"}),De.exports.array=(e,t)=>it(e,{...t,array:!0}),De.exports.MaxBufferError=Sr;var Ps=De.exports,Mr=X(Ps);const{PassThrough:_s}=Te;var Ts=function(){var e=[],t=new _s({objectMode:!0});return t.setMaxListeners(0),t.add=n,t.isEmpty=r,t.on("unpipe",o),Array.prototype.slice.call(arguments).forEach(n),t;function n(u){return Array.isArray(u)?(u.forEach(n),this):(e.push(u),u.once("end",o.bind(null,u)),u.once("error",t.emit.bind(t,"error")),u.pipe(t,{end:!1}),this)}function r(){return e.length==0}function o(u){e=e.filter(function(s){return s!==u}),!e.length&&t.readable&&t.end()}},Ns=X(Ts);const Ls=(e,t)=>{t!==void 0&&(vs(t)?t.pipe(e.stdin):e.stdin.end(t))},Rs=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const n=Ns();return e.stdout&&n.add(e.stdout),e.stderr&&n.add(e.stderr),n},at=async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(n){return n.bufferedData}}},Dt=(e,{encoding:t,buffer:n,maxBuffer:r})=>{if(!(!e||!n))return t?Mr(e,{encoding:t,maxBuffer:r}):Mr.buffer(e,{maxBuffer:r})},ks=async({stdout:e,stderr:t,all:n},{encoding:r,buffer:o,maxBuffer:u},s)=>{const a=Dt(e,{encoding:r,buffer:o,maxBuffer:u}),i=Dt(t,{encoding:r,buffer:o,maxBuffer:u}),l=Dt(n,{encoding:r,buffer:o,maxBuffer:u*2});try{return await Promise.all([s,a,i,l])}catch(f){return Promise.all([{error:f,signal:f.signal,timedOut:f.timedOut},at(e,a),at(t,i),at(n,l)])}},js=(async()=>{})().constructor.prototype,Gs=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(js,e)]),Pr=(e,t)=>{for(const[n,r]of Gs){const o=typeof t=="function"?(...u)=>Reflect.apply(r.value,t(),u):r.value.bind(t);Reflect.defineProperty(e,n,{...r,value:o})}return e},Us=e=>new Promise((t,n)=>{e.on("exit",(r,o)=>{t({exitCode:r,signal:o})}),e.on("error",r=>{n(r)}),e.stdin&&e.stdin.on("error",r=>{n(r)})}),_r=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],Hs=/^[\w.-]+$/,Ks=/"/g,qs=e=>typeof e!="string"||Hs.test(e)?e:`"${e.replace(Ks,'\\"')}"`,zs=(e,t)=>_r(e,t).join(" "),Ys=(e,t)=>_r(e,t).map(n=>qs(n)).join(" "),Ws=1e3*1e3*100,Vs=({env:e,extendEnv:t,preferLocal:n,localDir:r,execPath:o})=>{const u=t?{..._.env,...e}:e;return n?ku({env:u,cwd:r,execPath:o}):u},Xs=(e,t,n={})=>{const r=Nu._parse(e,t,n);return e=r.command,t=r.args,n=r.options,n={maxBuffer:Ws,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:n.cwd||_.cwd(),execPath:_.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...n},n.env=Vs(n),n.stdio=ss(n),_.platform==="win32"&&W.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:n,parsed:r}},ct=(e,t,n)=>typeof t!="string"&&!ln.isBuffer(t)?n===void 0?void 0:"":e.stripFinalNewline?Lu(t):t;function te(e,t,n){const r=Xs(e,t,n),o=zs(e,t),u=Ys(e,t);bs(r.options);let s;try{s=Pt.spawn(r.file,r.args,r.options)}catch(p){const d=new Pt.ChildProcess,m=Promise.reject($r({error:p,stdout:"",stderr:"",all:"",command:o,escapedCommand:u,parsed:r,timedOut:!1,isCanceled:!1,killed:!1}));return Pr(d,m)}const a=Us(s),i=ws(s,r.options,a),l=As(s,r.options,i),f={isCanceled:!1};s.kill=ms.bind(null,s.kill.bind(s)),s.cancel=Es.bind(null,s,f);const c=br(async()=>{const[{error:p,exitCode:d,signal:m,timedOut:h},C,w,O]=await ks(s,r.options,l),S=ct(r.options,C),M=ct(r.options,w),oe=ct(r.options,O);if(p||d!==0||m!==null){const b=$r({error:p,exitCode:d,signal:m,stdout:S,stderr:M,all:oe,command:o,escapedCommand:u,parsed:r,timedOut:h,isCanceled:f.isCanceled||(r.options.signal?r.options.signal.aborted:!1),killed:s.killed});if(!r.options.reject)return b;throw b}return{command:o,escapedCommand:u,exitCode:0,stdout:S,stderr:M,all:oe,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return Ls(s,r.options.input),s.all=Rs(s,r.options),Pr(s,c)}class K{static create(t,n){return new t(n)}}const Js={"":"commit message",conventional:"type(optional scope): description",gitmoji:":emoji: description"},Zs=e=>`The output response must be in ${e} commit type:
28
- ${Js[e]}`,Qs={"":"",gitmoji:"",conventional:`Choose a type from the type-to-description JSON below that best describes the git diff:
29
- ${JSON.stringify({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 our CI configuration files and 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"},null,2)}`},lt=(e,t,n,r)=>["Generate a concise git commit message written in present tense for the following code diff with the given specifications below:",`Message language: ${e}`,`Commit message must be a maximum of ${t} characters.`,"Please exclude anything unnecessary such as translation or explanation. Your entire response will be passed directly into git commit.",Qs[n],Zs(n),r].filter(Boolean).join(`
30
- `),ei=e=>/^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\s\w\.\-\p{Extended_Pictographic}]+\))?(!)?: ([\s\w \p{Extended_Pictographic}])+([\s\S]*)/.test(e),ti=e=>/^\:\w+\: (.*)$/.test(e),R={OPEN_AI:"OPENAI_KEY",GEMINI:"GEMINI_KEY",ANTHROPIC:"ANTHROPIC_KEY",HUGGING:"HUGGING_COOKIE",CLOVA_X:"CLOVAX_COOKIE",MISTRAL:"MISTRAL_KEY",OLLAMA:"OLLAMA_MODEL"},Tr=Object.values(R).map(e=>e);class q{constructor(t){this.handleError$=n=>{let r="An error occurred";return n.message&&(r=n.message),T({name:`${this.errorPrefix} ${r}`,value:r,isError:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}buildPrompt(t,n,r,o,u,s){return`${lt(t,o,u,s)}
31
- Please just generate ${r} commit messages in numbered list format without explanation.
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 $r(e={}){const{env:t=process.env,platform:r=process.platform}=e;return r!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"}function qs(e={}){const{cwd:t=j.cwd(),path:r=j.env[$r()],execPath:n=j.execPath}=e;let s;const o=t instanceof URL?Fn.fileURLToPath(t):t;let u=W.resolve(o);const a=[];for(;s!==u;)a.push(W.join(u,"node_modules/.bin")),s=u,u=W.resolve(u,"..");return a.push(W.resolve(o,n,"..")),[...a,r].join(W.delimiter)}function zs({env:e=j.env,...t}={}){e={...e};const r=$r({env:e});return t.path=e[r],e[r]=qs(t),e}const Ys=(e,t,r,n)=>{if(r==="length"||r==="prototype"||r==="arguments"||r==="caller")return;const s=Object.getOwnPropertyDescriptor(e,r),o=Object.getOwnPropertyDescriptor(t,r);!Vs(s,o)&&n||Object.defineProperty(e,r,o)},Vs=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)},Ws=(e,t)=>{const r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},Xs=(e,t)=>`/* Wrapped ${e}*/
25
+ ${t}`,Js=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Zs=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Qs=(e,t,r)=>{const n=r===""?"":`with ${r.trim()}() `,s=Xs.bind(null,n,t.toString());Object.defineProperty(s,"name",Zs),Object.defineProperty(e,"toString",{...Js,value:s})};function eu(e,t,{ignoreNonConfigurable:r=!1}={}){const{name:n}=e;for(const s of Reflect.ownKeys(t))Ys(e,t,s,r);return Ws(e,t),Qs(e,t,n),e}const Ae=new WeakMap,Br=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let r,n=0;const s=e.displayName||e.name||"<anonymous>",o=function(...u){if(Ae.set(o,++n),n===1)r=e.apply(this,u),e=null;else if(t.throw===!0)throw new Error(`Function \`${s}\` can only be called once`);return r};return eu(o,e),Ae.set(o,n),o};Br.callCount=e=>{if(!Ae.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return Ae.get(e)};const tu=()=>{const e=Or-xr+1;return Array.from({length:e},ru)},ru=(e,t)=>({name:`SIGRT${t+1}`,number:xr+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),xr=34,Or=64,nu=[{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"}],Ir=()=>{const e=tu();return[...nu,...e].map(ou)},ou=({name:e,number:t,description:r,action:n,forced:s=!1,standard:o})=>{const{signals:{[e]:u}}=Tt,a=u!==void 0;return{name:e,number:a?u:t,description:r,supported:a,action:n,forced:s,standard:o}},su=()=>{const e=Ir();return Object.fromEntries(e.map(uu))},uu=({name:e,number:t,description:r,supported:n,action:s,forced:o,standard:u})=>[e,{name:e,number:t,description:r,supported:n,action:s,forced:o,standard:u}],iu=su(),au=()=>{const e=Ir(),t=Or+1,r=Array.from({length:t},(n,s)=>Du(s,e));return Object.assign({},...r)},Du=(e,t)=>{const r=cu(e,t);if(r===void 0)return{};const{name:n,description:s,supported:o,action:u,forced:a,standard:i}=r;return{[e]:{name:n,number:e,description:s,supported:o,action:u,forced:a,standard:i}}},cu=(e,t)=>{const r=t.find(({name:n})=>Tt.signals[n]===e);return r!==void 0?r:t.find(n=>n.number===e)};au();const lu=({timedOut:e,timeout:t,errorCode:r,signal:n,signalDescription:s,exitCode:o,isCanceled:u})=>e?`timed out after ${t} milliseconds`:u?"was canceled":r!==void 0?`failed with ${r}`:n!==void 0?`was killed with ${n} (${s})`:o!==void 0?`failed with exit code ${o}`:"failed",Sr=({stdout:e,stderr:t,all:r,error:n,signal:s,exitCode:o,command:u,escapedCommand:a,timedOut:i,isCanceled:l,killed:f,parsed:{options:{timeout:D}}})=>{o=o===null?void 0:o,s=s===null?void 0:s;const c=s===void 0?void 0:iu[s].description,p=n&&n.code,m=`Command ${lu({timedOut:i,timeout:D,errorCode:p,signal:s,signalDescription:c,exitCode:o,isCanceled:l})}: ${u}`,h=Object.prototype.toString.call(n)==="[object Error]",C=h?`${m}
26
+ ${n.message}`:m,w=[C,t,e].filter(Boolean).join(`
27
+ `);return h?(n.originalMessage=n.message,n.message=w):n=new Error(w),n.shortMessage=C,n.command=u,n.escapedCommand=a,n.exitCode=o,n.signal=s,n.signalDescription=c,n.stdout=e,n.stderr=t,r!==void 0&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!i,n.isCanceled=l,n.killed=f&&!i,n},ve=["stdin","stdout","stderr"],fu=e=>ve.some(t=>e[t]!==void 0),pu=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return ve.map(n=>e[n]);if(fu(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${ve.map(n=>`\`${n}\``).join(", ")}`);if(typeof t=="string")return t;if(!Array.isArray(t))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);const r=Math.max(t.length,ve.length);return Array.from({length:r},(n,s)=>t[s])};var ee={exports:{}},$e={exports:{}};$e.exports;var Pr;function du(){return Pr||(Pr=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")}($e)),$e.exports}var F=A.process;const q=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(!q(F))ee.exports=function(){return function(){}};else{var mu=Rt,De=du(),hu=/^win/i.test(F.platform),Be=Lt;typeof Be!="function"&&(Be=Be.EventEmitter);var v;F.__signal_exit_emitter__?v=F.__signal_exit_emitter__:(v=F.__signal_exit_emitter__=new Be,v.count=0,v.emitted={}),v.infinite||(v.setMaxListeners(1/0),v.infinite=!0),ee.exports=function(e,t){if(!q(A.process))return function(){};mu.equal(typeof e,"function","a callback must be provided for exit handler"),ce===!1&&Mr();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){v.removeListener(r,e),v.listeners("exit").length===0&&v.listeners("afterexit").length===0&&it()};return v.on(r,e),n};var it=function(){!ce||!q(A.process)||(ce=!1,De.forEach(function(t){try{F.removeListener(t,at[t])}catch{}}),F.emit=Dt,F.reallyExit=_r,v.count-=1)};ee.exports.unload=it;var te=function(t,r,n){v.emitted[t]||(v.emitted[t]=!0,v.emit(t,r,n))},at={};De.forEach(function(e){at[e]=function(){if(q(A.process)){var r=F.listeners(e);r.length===v.count&&(it(),te("exit",null,e),te("afterexit",null,e),hu&&e==="SIGHUP"&&(e="SIGINT"),F.kill(F.pid,e))}}}),ee.exports.signals=function(){return De};var ce=!1,Mr=function(){ce||!q(A.process)||(ce=!0,v.count+=1,De=De.filter(function(t){try{return F.on(t,at[t]),!0}catch{return!1}}),F.emit=Cu,F.reallyExit=gu)};ee.exports.load=Mr;var _r=F.reallyExit,gu=function(t){q(A.process)&&(F.exitCode=t||0,te("exit",F.exitCode,null),te("afterexit",F.exitCode,null),_r.call(F,F.exitCode))},Dt=F.emit,Cu=function(t,r){if(t==="exit"&&q(A.process)){r!==void 0&&(F.exitCode=r);var n=Dt.apply(this,arguments);return te("exit",F.exitCode,null),te("afterexit",F.exitCode,null),n}else return Dt.apply(this,arguments)}}var Fu=ee.exports,Eu=J(Fu);const yu=1e3*5,wu=(e,t="SIGTERM",r={})=>{const n=e(t);return bu(e,t,r,n),n},bu=(e,t,r,n)=>{if(!Au(t,r,n))return;const s=$u(r),o=setTimeout(()=>{e("SIGKILL")},s);o.unref&&o.unref()},Au=(e,{forceKillAfterTimeout:t},r)=>vu(e)&&t!==!1&&r,vu=e=>e===En.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",$u=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return yu;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},Bu=(e,t)=>{e.kill()&&(t.isCanceled=!0)},xu=(e,t,r)=>{e.kill(t),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},Ou=(e,{timeout:t,killSignal:r="SIGTERM"},n)=>{if(t===0||t===void 0)return n;let s;const o=new Promise((a,i)=>{s=setTimeout(()=>{xu(e,r,i)},t)}),u=n.finally(()=>{clearTimeout(s)});return Promise.race([o,u])},Iu=({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})`)},Su=async(e,{cleanup:t,detached:r},n)=>{if(!t||r)return n;const s=Eu(()=>{e.kill()});return n.finally(()=>{s()})};function Pu(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}var le={exports:{}};const{PassThrough:Mu}=ke;var _u=e=>{e={...e};const{array:t}=e;let{encoding:r}=e;const n=r==="buffer";let s=!1;t?s=!(r||n):r=r||"utf8",n&&(r=null);const o=new Mu({objectMode:s});r&&o.setEncoding(r);let u=0;const a=[];return o.on("data",i=>{a.push(i),s?u=a.length:u+=i.length}),o.getBufferedValue=()=>t?a:n?Buffer.concat(a,u):a.join(""),o.getBufferedLength=()=>u,o};const{constants:Nu}=yn,Tu=ke,{promisify:Ru}=kt,Lu=_u,ku=Ru(Tu.pipeline);class Nr extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function ct(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:r}=t,n=Lu(t);return await new Promise((s,o)=>{const u=a=>{a&&n.getBufferedLength()<=Nu.MAX_LENGTH&&(a.bufferedData=n.getBufferedValue()),o(a)};(async()=>{try{await ku(e,n),s()}catch(a){u(a)}})(),n.on("data",()=>{n.getBufferedLength()>r&&u(new Nr)})}),n.getBufferedValue()}le.exports=ct,le.exports.buffer=(e,t)=>ct(e,{...t,encoding:"buffer"}),le.exports.array=(e,t)=>ct(e,{...t,array:!0}),le.exports.MaxBufferError=Nr;var ju=le.exports,Tr=J(ju);const{PassThrough:Gu}=ke;var Uu=function(){var e=[],t=new Gu({objectMode:!0});return t.setMaxListeners(0),t.add=r,t.isEmpty=n,t.on("unpipe",s),Array.prototype.slice.call(arguments).forEach(r),t;function r(o){return Array.isArray(o)?(o.forEach(r),this):(e.push(o),o.once("end",s.bind(null,o)),o.once("error",t.emit.bind(t,"error")),o.pipe(t,{end:!1}),this)}function n(){return e.length==0}function s(o){e=e.filter(function(u){return u!==o}),!e.length&&t.readable&&t.end()}},Hu=J(Uu);const Ku=(e,t)=>{t!==void 0&&(Pu(t)?t.pipe(e.stdin):e.stdin.end(t))},qu=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const r=Hu();return e.stdout&&r.add(e.stdout),e.stderr&&r.add(e.stderr),r},lt=async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(r){return r.bufferedData}}},ft=(e,{encoding:t,buffer:r,maxBuffer:n})=>{if(!(!e||!r))return t?Tr(e,{encoding:t,maxBuffer:n}):Tr.buffer(e,{maxBuffer:n})},zu=async({stdout:e,stderr:t,all:r},{encoding:n,buffer:s,maxBuffer:o},u)=>{const a=ft(e,{encoding:n,buffer:s,maxBuffer:o}),i=ft(t,{encoding:n,buffer:s,maxBuffer:o}),l=ft(r,{encoding:n,buffer:s,maxBuffer:o*2});try{return await Promise.all([u,a,i,l])}catch(f){return Promise.all([{error:f,signal:f.signal,timedOut:f.timedOut},lt(e,a),lt(t,i),lt(r,l)])}},Yu=(async()=>{})().constructor.prototype,Vu=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(Yu,e)]),Rr=(e,t)=>{for(const[r,n]of Vu){const s=typeof t=="function"?(...o)=>Reflect.apply(n.value,t(),o):n.value.bind(t);Reflect.defineProperty(e,r,{...n,value:s})}return e},Wu=e=>new Promise((t,r)=>{e.on("exit",(n,s)=>{t({exitCode:n,signal:s})}),e.on("error",n=>{r(n)}),e.stdin&&e.stdin.on("error",n=>{r(n)})}),Lr=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],Xu=/^[\w.-]+$/,Ju=/"/g,Zu=e=>typeof e!="string"||Xu.test(e)?e:`"${e.replace(Ju,'\\"')}"`,Qu=(e,t)=>Lr(e,t).join(" "),ei=(e,t)=>Lr(e,t).map(r=>Zu(r)).join(" "),ti=1e3*1e3*100,ri=({env:e,extendEnv:t,preferLocal:r,localDir:n,execPath:s})=>{const o=t?{...j.env,...e}:e;return r?zs({env:o,cwd:n,execPath:s}):o},ni=(e,t,r={})=>{const n=Hs._parse(e,t,r);return e=n.command,t=n.args,r=n.options,r={maxBuffer:ti,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||j.cwd(),execPath:j.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...r},r.env=ri(r),r.stdio=pu(r),j.platform==="win32"&&W.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:r,parsed:n}},pt=(e,t,r)=>typeof t!="string"&&!gn.isBuffer(t)?r===void 0?void 0:"":e.stripFinalNewline?Ks(t):t;function re(e,t,r){const n=ni(e,t,r),s=Qu(e,t),o=ei(e,t);Iu(n.options);let u;try{u=Nt.spawn(n.file,n.args,n.options)}catch(p){const d=new Nt.ChildProcess,m=Promise.reject(Sr({error:p,stdout:"",stderr:"",all:"",command:s,escapedCommand:o,parsed:n,timedOut:!1,isCanceled:!1,killed:!1}));return Rr(d,m)}const a=Wu(u),i=Ou(u,n.options,a),l=Su(u,n.options,i),f={isCanceled:!1};u.kill=wu.bind(null,u.kill.bind(u)),u.cancel=Bu.bind(null,u,f);const c=Br(async()=>{const[{error:p,exitCode:d,signal:m,timedOut:h},C,w,I]=await zu(u,n.options,l),_=pt(n.options,C),N=pt(n.options,w),se=pt(n.options,I);if(p||d!==0||m!==null){const b=Sr({error:p,exitCode:d,signal:m,stdout:_,stderr:N,all:se,command:s,escapedCommand:o,parsed:n,timedOut:h,isCanceled:f.isCanceled||(n.options.signal?n.options.signal.aborted:!1),killed:u.killed});if(!n.options.reject)return b;throw b}return{command:s,escapedCommand:o,exitCode:0,stdout:_,stderr:N,all:se,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return Ku(u,n.options.input),u.all=qu(u,n.options),Rr(u,c)}class z{static create(t,r){return new t(r)}}const oi={"":"commit message",conventional:"type(optional scope): description",gitmoji:":emoji: description"},si=e=>`The output response must be in ${e} commit type:
28
+ ${oi[e]}`,ui={"":"",gitmoji:"",conventional:`Choose a type from the type-to-description JSON below that best describes the git diff:
29
+ ${JSON.stringify({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 our CI configuration files and 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"},null,2)}`},xe=(e,t,r,n)=>["Generate a concise git commit message written in present tense for the following code diff with the given specifications below:",`Message language: ${e}`,`Commit message must be a maximum of ${t} characters.`,"Please exclude anything unnecessary such as translation or explanation. Your entire response will be passed directly into git commit.",ui[r],si(r),n].filter(Boolean).join(`
30
+ `),ii=e=>/^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\s\w\.\-\p{Extended_Pictographic}]+\))?(!)?: ([\s\w \p{Extended_Pictographic}])+([\s\S]*)/.test(e),ai=e=>/^\:\w+\: (.*)$/.test(e),H={OPEN_AI:"OPENAI_KEY",GEMINI:"GEMINI_KEY",ANTHROPIC:"ANTHROPIC_KEY",HUGGING:"HUGGING_COOKIE",CLOVA_X:"CLOVAX_COOKIE",MISTRAL:"MISTRAL_KEY",OLLAMA:"OLLAMA_MODEL"},kr=Object.values(H).map(e=>e);class Y{constructor(t){this.handleError$=r=>{let n="An error occurred";return r.message&&(n=r.message),G({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}buildPrompt(t,r,n,s,o,u){return`${xe(t,s,o,u)}
31
+ Please just generate ${n} commit messages in numbered list format without explanation.
32
32
  Here are git diff:
33
- ${n}`}extractCommitMessageFromRawText(t,n){switch(t){case"conventional":const r=new RegExp(/(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?: .*$/),o=n.match(r);return o?o[0].replace(/: (\w)/,(a,i)=>`: ${i.toLowerCase()}`):"";case"gitmoji":const u=new RegExp(/\:\w+\: (.*)$/),s=n.match(u);return s?s[0]:"";default:return n}}sanitizeMessage(t,n,r){const o=t.split(`
34
- `).map(u=>u.trim().replace(/^\d+\.\s/,"")).map(u=>u.replace(/`/g,"")).map(u=>this.extractCommitMessageFromRawText(n,u)).filter(u=>!!u);return o.length>r?o.slice(0,r):o}}var Nr="1.7.5",ri="A Reactive CLI that generates git commit messages with various AI";class y extends Error{}const ft=" ",ve=e=>{e instanceof Error&&(e instanceof y||(e.stack&&console.error(g.dim(e.stack.split(`
33
+ ${r}`}extractCommitMessageFromRawText(t,r){switch(t){case"conventional":const n=new RegExp(/(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?: .*$/),s=r.match(n);return s?s[0].replace(/: (\w)/,(a,i)=>`: ${i.toLowerCase()}`):"";case"gitmoji":const o=new RegExp(/\:\w+\: (.*)$/),u=r.match(o);return u?u[0]:"";default:return r}}sanitizeMessage(t,r,n){const s=t.split(`
34
+ `).map(o=>o.trim().replace(/^\d+\.\s/,"")).map(o=>o.replace(/`/g,"")).map(o=>this.extractCommitMessageFromRawText(r,o)).filter(o=>!!o);return s.length>n?s.slice(0,n):s}}var jr="1.8.0",Di="A Reactive CLI that generates git commit messages with various AI";class y extends Error{}const dt=" ",Oe=e=>{e instanceof Error&&(e instanceof y||(e.stack&&console.error(g.dim(e.stack.split(`
35
35
  `).slice(1).join(`
36
36
  `))),console.error(`
37
- ${ft}${g.dim(`aicommit2 v${Nr}`)}`),console.error(`
38
- ${ft}Please open a Bug report with the information above:`),console.error(`${ft}https://github.com/tak-bro/aicommit2/issues/new/choose`)))};var pt={},dt={exports:{}},ce={exports:{}},mt,Lr;function ni(){if(Lr)return mt;Lr=1;var e=1e3,t=e*60,n=t*60,r=n*24,o=r*7,u=r*365.25;mt=function(f,D){D=D||{};var c=typeof f;if(c==="string"&&f.length>0)return s(f);if(c==="number"&&isFinite(f))return D.long?i(f):a(f);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(f))};function s(f){if(f=String(f),!(f.length>100)){var D=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(f);if(D){var c=parseFloat(D[1]),p=(D[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return c*u;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}}}function a(f){var D=Math.abs(f);return D>=r?Math.round(f/r)+"d":D>=n?Math.round(f/n)+"h":D>=t?Math.round(f/t)+"m":D>=e?Math.round(f/e)+"s":f+"ms"}function i(f){var D=Math.abs(f);return D>=r?l(f,D,r,"day"):D>=n?l(f,D,n,"hour"):D>=t?l(f,D,t,"minute"):D>=e?l(f,D,e,"second"):f+" ms"}function l(f,D,c,p){var d=D>=c*1.5;return Math.round(f/c)+" "+p+(d?"s":"")}return mt}var ht,Rr;function kr(){if(Rr)return ht;Rr=1;function e(t){r.debug=r,r.default=r,r.coerce=l,r.disable=s,r.enable=u,r.enabled=a,r.humanize=ni(),r.destroy=f,Object.keys(t).forEach(D=>{r[D]=t[D]}),r.names=[],r.skips=[],r.formatters={};function n(D){let c=0;for(let p=0;p<D.length;p++)c=(c<<5)-c+D.charCodeAt(p),c|=0;return r.colors[Math.abs(c)%r.colors.length]}r.selectColor=n;function r(D){let c,p=null,d,m;function h(...C){if(!h.enabled)return;const w=h,O=Number(new Date),S=O-(c||O);w.diff=S,w.prev=c,w.curr=O,c=O,C[0]=r.coerce(C[0]),typeof C[0]!="string"&&C.unshift("%O");let M=0;C[0]=C[0].replace(/%([a-zA-Z%])/g,(b,Me)=>{if(b==="%%")return"%";M++;const Mt=r.formatters[Me];if(typeof Mt=="function"){const Dn=C[M];b=Mt.call(w,Dn),C.splice(M,1),M--}return b}),r.formatArgs.call(w,C),(w.log||r.log).apply(w,C)}return h.namespace=D,h.useColors=r.useColors(),h.color=r.selectColor(D),h.extend=o,h.destroy=r.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==r.namespaces&&(d=r.namespaces,m=r.enabled(D)),m),set:C=>{p=C}}),typeof r.init=="function"&&r.init(h),h}function o(D,c){const p=r(this.namespace+(typeof c>"u"?":":c)+D);return p.log=this.log,p}function u(D){r.save(D),r.namespaces=D,r.names=[],r.skips=[];let c;const p=(typeof D=="string"?D:"").split(/[\s,]+/),d=p.length;for(c=0;c<d;c++)p[c]&&(D=p[c].replace(/\*/g,".*?"),D[0]==="-"?r.skips.push(new RegExp("^"+D.slice(1)+"$")):r.names.push(new RegExp("^"+D+"$")))}function s(){const D=[...r.names.map(i),...r.skips.map(i).map(c=>"-"+c)].join(",");return r.enable(""),D}function a(D){if(D[D.length-1]==="*")return!0;let c,p;for(c=0,p=r.skips.length;c<p;c++)if(r.skips[c].test(D))return!1;for(c=0,p=r.names.length;c<p;c++)if(r.names[c].test(D))return!0;return!1}function i(D){return D.toString().substring(2,D.toString().length-2).replace(/\.\*\?$/,"*")}function l(D){return D instanceof Error?D.stack||D.message:D}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}return ht=e,ht}ce.exports;var jr;function oi(){return jr||(jr=1,function(e,t){t.formatArgs=r,t.save=o,t.load=u,t.useColors=n,t.storage=s(),t.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;i.splice(1,0,l,"color: inherit");let f=0,D=0;i[0].replace(/%[a-zA-Z%]/g,c=>{c!=="%%"&&(f++,c==="%c"&&(D=f))}),i.splice(D,0,l)}t.log=console.debug||console.log||(()=>{});function o(i){try{i?t.storage.setItem("debug",i):t.storage.removeItem("debug")}catch{}}function u(){let i;try{i=t.storage.getItem("debug")}catch{}return!i&&typeof process<"u"&&"env"in process&&(i=process.env.DEBUG),i}function s(){try{return localStorage}catch{}}e.exports=kr()(t);const{formatters:a}=e.exports;a.j=function(i){try{return JSON.stringify(i)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(ce,ce.exports)),ce.exports}var le={exports:{}},gt,Gr;function ui(){return Gr||(Gr=1,gt=(e,t=process.argv)=>{const n=e.startsWith("-")?"":e.length===1?"-":"--",r=t.indexOf(n+e),o=t.indexOf("--");return r!==-1&&(o===-1||r<o)}),gt}var Ct,Ur;function si(){if(Ur)return Ct;Ur=1;const e=kt,t=Pe,n=ui(),{env:r}=process;let o;n("no-color")||n("no-colors")||n("color=false")||n("color=never")?o=0:(n("color")||n("colors")||n("color=true")||n("color=always"))&&(o=1),"FORCE_COLOR"in r&&(r.FORCE_COLOR==="true"?o=1:r.FORCE_COLOR==="false"?o=0:o=r.FORCE_COLOR.length===0?1:Math.min(parseInt(r.FORCE_COLOR,10),3));function u(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function s(i,l){if(o===0)return 0;if(n("color=16m")||n("color=full")||n("color=truecolor"))return 3;if(n("color=256"))return 2;if(i&&!l&&o===void 0)return 0;const f=o||0;if(r.TERM==="dumb")return f;if(process.platform==="win32"){const D=e.release().split(".");return Number(D[0])>=10&&Number(D[2])>=10586?Number(D[2])>=14931?3:2:1}if("CI"in r)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(D=>D in r)||r.CI_NAME==="codeship"?1:f;if("TEAMCITY_VERSION"in r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if(r.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in r){const D=parseInt((r.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(r.TERM_PROGRAM){case"iTerm.app":return D>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(r.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?1:f}function a(i){const l=s(i,i&&i.isTTY);return u(l)}return Ct={supportsColor:a,stdout:u(s(!0,t.isatty(1))),stderr:u(s(!0,t.isatty(2)))},Ct}le.exports;var Hr;function ii(){return Hr||(Hr=1,function(e,t){const n=Pe,r=Lt;t.init=f,t.log=a,t.formatArgs=u,t.save=i,t.load=l,t.useColors=o,t.destroy=r.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const c=si();c&&(c.stderr||c).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(c=>/^debug_/i.test(c)).reduce((c,p)=>{const d=p.substring(6).toLowerCase().replace(/_([a-z])/g,(h,C)=>C.toUpperCase());let m=process.env[p];return/^(yes|on|true|enabled)$/i.test(m)?m=!0:/^(no|off|false|disabled)$/i.test(m)?m=!1:m==="null"?m=null:m=Number(m),c[d]=m,c},{});function o(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:n.isatty(process.stderr.fd)}function u(c){const{namespace:p,useColors:d}=this;if(d){const m=this.color,h="\x1B[3"+(m<8?m:"8;5;"+m),C=` ${h};1m${p} \x1B[0m`;c[0]=C+c[0].split(`
37
+ ${dt}${g.dim(`aicommit2 v${jr}`)}`),console.error(`
38
+ ${dt}Please open a Bug report with the information above:`),console.error(`${dt}https://github.com/tak-bro/aicommit2/issues/new/choose`)))};var mt={},ht={exports:{}},fe={exports:{}},gt,Gr;function ci(){if(Gr)return gt;Gr=1;var e=1e3,t=e*60,r=t*60,n=r*24,s=n*7,o=n*365.25;gt=function(f,D){D=D||{};var c=typeof f;if(c==="string"&&f.length>0)return u(f);if(c==="number"&&isFinite(f))return D.long?i(f):a(f);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(f))};function u(f){if(f=String(f),!(f.length>100)){var D=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(f);if(D){var c=parseFloat(D[1]),p=(D[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*s;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}}}function a(f){var D=Math.abs(f);return D>=n?Math.round(f/n)+"d":D>=r?Math.round(f/r)+"h":D>=t?Math.round(f/t)+"m":D>=e?Math.round(f/e)+"s":f+"ms"}function i(f){var D=Math.abs(f);return D>=n?l(f,D,n,"day"):D>=r?l(f,D,r,"hour"):D>=t?l(f,D,t,"minute"):D>=e?l(f,D,e,"second"):f+" ms"}function l(f,D,c,p){var d=D>=c*1.5;return Math.round(f/c)+" "+p+(d?"s":"")}return gt}var Ct,Ur;function Hr(){if(Ur)return Ct;Ur=1;function e(t){n.debug=n,n.default=n,n.coerce=l,n.disable=u,n.enable=o,n.enabled=a,n.humanize=ci(),n.destroy=f,Object.keys(t).forEach(D=>{n[D]=t[D]}),n.names=[],n.skips=[],n.formatters={};function r(D){let c=0;for(let p=0;p<D.length;p++)c=(c<<5)-c+D.charCodeAt(p),c|=0;return n.colors[Math.abs(c)%n.colors.length]}n.selectColor=r;function n(D){let c,p=null,d,m;function h(...C){if(!h.enabled)return;const w=h,I=Number(new Date),_=I-(c||I);w.diff=_,w.prev=c,w.curr=I,c=I,C[0]=n.coerce(C[0]),typeof C[0]!="string"&&C.unshift("%O");let N=0;C[0]=C[0].replace(/%([a-zA-Z%])/g,(b,Te)=>{if(b==="%%")return"%";N++;const _t=n.formatters[Te];if(typeof _t=="function"){const mn=C[N];b=_t.call(w,mn),C.splice(N,1),N--}return b}),n.formatArgs.call(w,C),(w.log||n.log).apply(w,C)}return h.namespace=D,h.useColors=n.useColors(),h.color=n.selectColor(D),h.extend=s,h.destroy=n.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==n.namespaces&&(d=n.namespaces,m=n.enabled(D)),m),set:C=>{p=C}}),typeof n.init=="function"&&n.init(h),h}function s(D,c){const p=n(this.namespace+(typeof c>"u"?":":c)+D);return p.log=this.log,p}function o(D){n.save(D),n.namespaces=D,n.names=[],n.skips=[];let c;const p=(typeof D=="string"?D:"").split(/[\s,]+/),d=p.length;for(c=0;c<d;c++)p[c]&&(D=p[c].replace(/\*/g,".*?"),D[0]==="-"?n.skips.push(new RegExp("^"+D.slice(1)+"$")):n.names.push(new RegExp("^"+D+"$")))}function u(){const D=[...n.names.map(i),...n.skips.map(i).map(c=>"-"+c)].join(",");return n.enable(""),D}function a(D){if(D[D.length-1]==="*")return!0;let c,p;for(c=0,p=n.skips.length;c<p;c++)if(n.skips[c].test(D))return!1;for(c=0,p=n.names.length;c<p;c++)if(n.names[c].test(D))return!0;return!1}function i(D){return D.toString().substring(2,D.toString().length-2).replace(/\.\*\?$/,"*")}function l(D){return D instanceof Error?D.stack||D.message:D}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}return Ct=e,Ct}fe.exports;var Kr;function li(){return Kr||(Kr=1,function(e,t){t.formatArgs=n,t.save=s,t.load=o,t.useColors=r,t.storage=u(),t.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;i.splice(1,0,l,"color: inherit");let f=0,D=0;i[0].replace(/%[a-zA-Z%]/g,c=>{c!=="%%"&&(f++,c==="%c"&&(D=f))}),i.splice(D,0,l)}t.log=console.debug||console.log||(()=>{});function s(i){try{i?t.storage.setItem("debug",i):t.storage.removeItem("debug")}catch{}}function o(){let i;try{i=t.storage.getItem("debug")}catch{}return!i&&typeof process<"u"&&"env"in process&&(i=process.env.DEBUG),i}function u(){try{return localStorage}catch{}}e.exports=Hr()(t);const{formatters:a}=e.exports;a.j=function(i){try{return JSON.stringify(i)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(fe,fe.exports)),fe.exports}var pe={exports:{}},Ft,qr;function fi(){return qr||(qr=1,Ft=(e,t=process.argv)=>{const r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),s=t.indexOf("--");return n!==-1&&(s===-1||n<s)}),Ft}var Et,zr;function pi(){if(zr)return Et;zr=1;const e=Ht,t=Re,r=fi(),{env:n}=process;let s;r("no-color")||r("no-colors")||r("color=false")||r("color=never")?s=0:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(s=1),"FORCE_COLOR"in n&&(n.FORCE_COLOR==="true"?s=1:n.FORCE_COLOR==="false"?s=0:s=n.FORCE_COLOR.length===0?1:Math.min(parseInt(n.FORCE_COLOR,10),3));function o(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function u(i,l){if(s===0)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(i&&!l&&s===void 0)return 0;const f=s||0;if(n.TERM==="dumb")return f;if(process.platform==="win32"){const D=e.release().split(".");return Number(D[0])>=10&&Number(D[2])>=10586?Number(D[2])>=14931?3:2:1}if("CI"in n)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(D=>D in n)||n.CI_NAME==="codeship"?1:f;if("TEAMCITY_VERSION"in n)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(n.TEAMCITY_VERSION)?1:0;if(n.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in n){const D=parseInt((n.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n.TERM_PROGRAM){case"iTerm.app":return D>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(n.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n.TERM)||"COLORTERM"in n?1:f}function a(i){const l=u(i,i&&i.isTTY);return o(l)}return Et={supportsColor:a,stdout:o(u(!0,t.isatty(1))),stderr:o(u(!0,t.isatty(2)))},Et}pe.exports;var Yr;function di(){return Yr||(Yr=1,function(e,t){const r=Re,n=kt;t.init=f,t.log=a,t.formatArgs=o,t.save=i,t.load=l,t.useColors=s,t.destroy=n.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const c=pi();c&&(c.stderr||c).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(c=>/^debug_/i.test(c)).reduce((c,p)=>{const d=p.substring(6).toLowerCase().replace(/_([a-z])/g,(h,C)=>C.toUpperCase());let m=process.env[p];return/^(yes|on|true|enabled)$/i.test(m)?m=!0:/^(no|off|false|disabled)$/i.test(m)?m=!1:m==="null"?m=null:m=Number(m),c[d]=m,c},{});function s(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:r.isatty(process.stderr.fd)}function o(c){const{namespace:p,useColors:d}=this;if(d){const m=this.color,h="\x1B[3"+(m<8?m:"8;5;"+m),C=` ${h};1m${p} \x1B[0m`;c[0]=C+c[0].split(`
39
39
  `).join(`
40
- `+C),c.push(h+"m+"+e.exports.humanize(this.diff)+"\x1B[0m")}else c[0]=s()+p+" "+c[0]}function s(){return t.inspectOpts.hideDate?"":new Date().toISOString()+" "}function a(...c){return process.stderr.write(r.format(...c)+`
41
- `)}function i(c){c?process.env.DEBUG=c:delete process.env.DEBUG}function l(){return process.env.DEBUG}function f(c){c.inspectOpts={};const p=Object.keys(t.inspectOpts);for(let d=0;d<p.length;d++)c.inspectOpts[p[d]]=t.inspectOpts[p[d]]}e.exports=kr()(t);const{formatters:D}=e.exports;D.o=function(c){return this.inspectOpts.colors=this.useColors,r.inspect(c,this.inspectOpts).split(`
42
- `).map(p=>p.trim()).join(" ")},D.O=function(c){return this.inspectOpts.colors=this.useColors,r.inspect(c,this.inspectOpts)}}(le,le.exports)),le.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?dt.exports=oi():dt.exports=ii();var Ft=dt.exports,Et={};Object.defineProperty(Et,"__esModule",{value:!0});function ai(e){return function(t,n){return new Promise((r,o)=>{e.call(this,t,n,(u,s)=>{u?o(u):r(s)})})}}Et.default=ai;var Kr=A&&A.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Di=Nt,ci=Kr(Ft),li=Kr(Et),fe=ci.default("agent-base");function fi(e){return!!e&&typeof e.addRequest=="function"}function yt(){const{stack:e}=new Error;return typeof e!="string"?!1:e.split(`
43
- `).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}function Be(e,t){return new Be.Agent(e,t)}(function(e){class t extends Di.EventEmitter{constructor(r,o){super();let u=o;typeof r=="function"?this.callback=r:r&&(u=r),this.timeout=null,u&&typeof u.timeout=="number"&&(this.timeout=u.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:yt()?443:80}set defaultPort(r){this.explicitDefaultPort=r}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:yt()?"https:":"http:"}set protocol(r){this.explicitProtocol=r}callback(r,o,u){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(r,o){const u=Object.assign({},o);typeof u.secureEndpoint!="boolean"&&(u.secureEndpoint=yt()),u.host==null&&(u.host="localhost"),u.port==null&&(u.port=u.secureEndpoint?443:80),u.protocol==null&&(u.protocol=u.secureEndpoint?"https:":"http:"),u.host&&u.path&&delete u.path,delete u.agent,delete u.hostname,delete u._defaultAgent,delete u.defaultPort,delete u.createConnection,r._last=!0,r.shouldKeepAlive=!1;let s=!1,a=null;const i=u.timeout||this.timeout,l=p=>{r._hadError||(r.emit("error",p),r._hadError=!0)},f=()=>{a=null,s=!0;const p=new Error(`A "socket" was not created for HTTP request before ${i}ms`);p.code="ETIMEOUT",l(p)},D=p=>{s||(a!==null&&(clearTimeout(a),a=null),l(p))},c=p=>{if(s)return;if(a!=null&&(clearTimeout(a),a=null),fi(p)){fe("Callback returned another Agent instance %o",p.constructor.name),p.addRequest(r,u);return}if(p){p.once("free",()=>{this.freeSocket(p,u)}),r.onSocket(p);return}const d=new Error(`no Duplex stream was returned to agent-base for \`${r.method} ${r.path}\``);l(d)};if(typeof this.callback!="function"){l(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(fe("Converting legacy callback function to promise"),this.promisifiedCallback=li.default(this.callback)):this.promisifiedCallback=this.callback),typeof i=="number"&&i>0&&(a=setTimeout(f,i)),"port"in u&&typeof u.port!="number"&&(u.port=Number(u.port));try{fe("Resolving socket for %o request: %o",u.protocol,`${r.method} ${r.path}`),Promise.resolve(this.promisifiedCallback(r,u)).then(c,D)}catch(p){Promise.reject(p).catch(D)}}freeSocket(r,o){fe("Freeing socket %o %o",r.constructor.name,o),r.destroy()}destroy(){fe("Destroying agent %o",this.constructor.name)}}e.Agent=t,e.prototype=e.Agent.prototype})(Be||(Be={}));var pi=Be,wt={},di=A&&A.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(wt,"__esModule",{value:!0});const mi=di(Ft),pe=mi.default("https-proxy-agent:parse-proxy-response");function hi(e){return new Promise((t,n)=>{let r=0;const o=[];function u(){const D=e.read();D?f(D):e.once("readable",u)}function s(){e.removeListener("end",i),e.removeListener("error",l),e.removeListener("close",a),e.removeListener("readable",u)}function a(D){pe("onclose had error %o",D)}function i(){pe("onend")}function l(D){s(),pe("onerror %o",D),n(D)}function f(D){o.push(D),r+=D.length;const c=Buffer.concat(o,r);if(c.indexOf(`\r
40
+ `+C),c.push(h+"m+"+e.exports.humanize(this.diff)+"\x1B[0m")}else c[0]=u()+p+" "+c[0]}function u(){return t.inspectOpts.hideDate?"":new Date().toISOString()+" "}function a(...c){return process.stderr.write(n.format(...c)+`
41
+ `)}function i(c){c?process.env.DEBUG=c:delete process.env.DEBUG}function l(){return process.env.DEBUG}function f(c){c.inspectOpts={};const p=Object.keys(t.inspectOpts);for(let d=0;d<p.length;d++)c.inspectOpts[p[d]]=t.inspectOpts[p[d]]}e.exports=Hr()(t);const{formatters:D}=e.exports;D.o=function(c){return this.inspectOpts.colors=this.useColors,n.inspect(c,this.inspectOpts).split(`
42
+ `).map(p=>p.trim()).join(" ")},D.O=function(c){return this.inspectOpts.colors=this.useColors,n.inspect(c,this.inspectOpts)}}(pe,pe.exports)),pe.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?ht.exports=li():ht.exports=di();var yt=ht.exports,wt={};Object.defineProperty(wt,"__esModule",{value:!0});function mi(e){return function(t,r){return new Promise((n,s)=>{e.call(this,t,r,(o,u)=>{o?s(o):n(u)})})}}wt.default=mi;var Vr=A&&A.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const hi=Lt,gi=Vr(yt),Ci=Vr(wt),de=gi.default("agent-base");function Fi(e){return!!e&&typeof e.addRequest=="function"}function bt(){const{stack:e}=new Error;return typeof e!="string"?!1:e.split(`
43
+ `).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}function Ie(e,t){return new Ie.Agent(e,t)}(function(e){class t extends hi.EventEmitter{constructor(n,s){super();let o=s;typeof n=="function"?this.callback=n:n&&(o=n),this.timeout=null,o&&typeof o.timeout=="number"&&(this.timeout=o.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:bt()?443:80}set defaultPort(n){this.explicitDefaultPort=n}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:bt()?"https:":"http:"}set protocol(n){this.explicitProtocol=n}callback(n,s,o){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(n,s){const o=Object.assign({},s);typeof o.secureEndpoint!="boolean"&&(o.secureEndpoint=bt()),o.host==null&&(o.host="localhost"),o.port==null&&(o.port=o.secureEndpoint?443:80),o.protocol==null&&(o.protocol=o.secureEndpoint?"https:":"http:"),o.host&&o.path&&delete o.path,delete o.agent,delete o.hostname,delete o._defaultAgent,delete o.defaultPort,delete o.createConnection,n._last=!0,n.shouldKeepAlive=!1;let u=!1,a=null;const i=o.timeout||this.timeout,l=p=>{n._hadError||(n.emit("error",p),n._hadError=!0)},f=()=>{a=null,u=!0;const p=new Error(`A "socket" was not created for HTTP request before ${i}ms`);p.code="ETIMEOUT",l(p)},D=p=>{u||(a!==null&&(clearTimeout(a),a=null),l(p))},c=p=>{if(u)return;if(a!=null&&(clearTimeout(a),a=null),Fi(p)){de("Callback returned another Agent instance %o",p.constructor.name),p.addRequest(n,o);return}if(p){p.once("free",()=>{this.freeSocket(p,o)}),n.onSocket(p);return}const d=new Error(`no Duplex stream was returned to agent-base for \`${n.method} ${n.path}\``);l(d)};if(typeof this.callback!="function"){l(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(de("Converting legacy callback function to promise"),this.promisifiedCallback=Ci.default(this.callback)):this.promisifiedCallback=this.callback),typeof i=="number"&&i>0&&(a=setTimeout(f,i)),"port"in o&&typeof o.port!="number"&&(o.port=Number(o.port));try{de("Resolving socket for %o request: %o",o.protocol,`${n.method} ${n.path}`),Promise.resolve(this.promisifiedCallback(n,o)).then(c,D)}catch(p){Promise.reject(p).catch(D)}}freeSocket(n,s){de("Freeing socket %o %o",n.constructor.name,s),n.destroy()}destroy(){de("Destroying agent %o",this.constructor.name)}}e.Agent=t,e.prototype=e.Agent.prototype})(Ie||(Ie={}));var Ei=Ie,At={},yi=A&&A.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(At,"__esModule",{value:!0});const wi=yi(yt),me=wi.default("https-proxy-agent:parse-proxy-response");function bi(e){return new Promise((t,r)=>{let n=0;const s=[];function o(){const D=e.read();D?f(D):e.once("readable",o)}function u(){e.removeListener("end",i),e.removeListener("error",l),e.removeListener("close",a),e.removeListener("readable",o)}function a(D){me("onclose had error %o",D)}function i(){me("onend")}function l(D){u(),me("onerror %o",D),r(D)}function f(D){s.push(D),n+=D.length;const c=Buffer.concat(s,n);if(c.indexOf(`\r
44
44
  \r
45
- `)===-1){pe("have not received end of HTTP headers yet..."),u();return}const d=c.toString("ascii",0,c.indexOf(`\r
46
- `)),m=+d.split(" ")[1];pe("got proxy server response: %o",d),t({statusCode:m,buffered:c})}e.on("error",l),e.on("close",a),e.on("end",i),u()})}wt.default=hi;var gi=A&&A.__awaiter||function(e,t,n,r){function o(u){return u instanceof n?u:new n(function(s){s(u)})}return new(n||(n=Promise))(function(u,s){function a(f){try{l(r.next(f))}catch(D){s(D)}}function i(f){try{l(r.throw(f))}catch(D){s(D)}}function l(f){f.done?u(f.value):o(f.value).then(a,i)}l((r=r.apply(e,t||[])).next())})},re=A&&A.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(pt,"__esModule",{value:!0});const qr=re(bn),zr=re(An),Ci=re(vn),Fi=re(Tt),Ei=re(Ft),yi=pi,wi=re(wt),de=Ei.default("https-proxy-agent:agent");class bi extends yi.Agent{constructor(t){let n;if(typeof t=="string"?n=Ci.default.parse(t):n=t,!n)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");de("creating new HttpsProxyAgent instance: %o",n),super(n);const r=Object.assign({},n);this.secureProxy=n.secureProxy||Bi(r.protocol),r.host=r.hostname||r.host,typeof r.port=="string"&&(r.port=parseInt(r.port,10)),!r.port&&r.host&&(r.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in r)&&(r.ALPNProtocols=["http 1.1"]),r.host&&r.path&&(delete r.path,delete r.pathname),this.proxy=r}callback(t,n){return gi(this,void 0,void 0,function*(){const{proxy:r,secureProxy:o}=this;let u;o?(de("Creating `tls.Socket`: %o",r),u=zr.default.connect(r)):(de("Creating `net.Socket`: %o",r),u=qr.default.connect(r));const s=Object.assign({},r.headers);let i=`CONNECT ${`${n.host}:${n.port}`} HTTP/1.1\r
47
- `;r.auth&&(s["Proxy-Authorization"]=`Basic ${Buffer.from(r.auth).toString("base64")}`);let{host:l,port:f,secureEndpoint:D}=n;vi(f,D)||(l+=`:${f}`),s.Host=l,s.Connection="close";for(const h of Object.keys(s))i+=`${h}: ${s[h]}\r
48
- `;const c=wi.default(u);u.write(`${i}\r
49
- `);const{statusCode:p,buffered:d}=yield c;if(p===200){if(t.once("socket",Ai),n.secureEndpoint){de("Upgrading socket connection to TLS");const h=n.servername||n.host;return zr.default.connect(Object.assign(Object.assign({},$i(n,"host","hostname","path","port")),{socket:u,servername:h}))}return u}u.destroy();const m=new qr.default.Socket({writable:!1});return m.readable=!0,t.once("socket",h=>{de("replaying proxy buffer for failed request"),Fi.default(h.listenerCount("data")>0),h.push(d),h.push(null)}),m})}}pt.default=bi;function Ai(e){e.resume()}function vi(e,t){return!!(!t&&e===80||t&&e===443)}function Bi(e){return typeof e=="string"?/^https:?$/i.test(e):!1}function $i(e,...t){const n={};let r;for(r in e)t.includes(r)||(n[r]=e[r]);return n}var xi=A&&A.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const bt=xi(pt);function At(e){return new bt.default(e)}(function(e){e.HttpsProxyAgent=bt.default,e.prototype=bt.default.prototype})(At||(At={}));var Oi=At,Ii=X(Oi);const Si=async(e,t,n,r,o,u,s)=>new Promise((a,i)=>{const l=JSON.stringify(r),D=(e.protocol.includes("https")?wn:yn).request({port:s||void 0,hostname:e.hostname,path:t,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(l),...n},timeout:o,agent:u?Ii(u):void 0},c=>{const p=[];c.on("data",d=>p.push(d)),c.on("end",()=>{a({request:D,response:c,data:Buffer.concat(p).toString()})})});D.on("error",i),D.on("timeout",()=>{D.destroy(),i(new y(`Time out error: request took over ${o}ms. Try increasing the \`timeout\` config`))}),D.write(l),D.end()}),Mi=async(e,t,n,r,o,u)=>{const s=new URL(e),{response:a,data:i}=await Si(s,t,{Authorization:`Bearer ${n}`},r,o,u);if(!a.statusCode||a.statusCode<200||a.statusCode>299){let l=`OpenAI API Error: ${a.statusCode} - ${a.statusMessage}`;throw i&&(l+=`
45
+ `)===-1){me("have not received end of HTTP headers yet..."),o();return}const d=c.toString("ascii",0,c.indexOf(`\r
46
+ `)),m=+d.split(" ")[1];me("got proxy server response: %o",d),t({statusCode:m,buffered:c})}e.on("error",l),e.on("close",a),e.on("end",i),o()})}At.default=bi;var Ai=A&&A.__awaiter||function(e,t,r,n){function s(o){return o instanceof r?o:new r(function(u){u(o)})}return new(r||(r=Promise))(function(o,u){function a(f){try{l(n.next(f))}catch(D){u(D)}}function i(f){try{l(n.throw(f))}catch(D){u(D)}}function l(f){f.done?o(f.value):s(f.value).then(a,i)}l((n=n.apply(e,t||[])).next())})},ne=A&&A.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(mt,"__esModule",{value:!0});const Wr=ne(In),Xr=ne(Sn),vi=ne(Pn),$i=ne(Rt),Bi=ne(yt),xi=Ei,Oi=ne(At),he=Bi.default("https-proxy-agent:agent");class Ii extends xi.Agent{constructor(t){let r;if(typeof t=="string"?r=vi.default.parse(t):r=t,!r)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");he("creating new HttpsProxyAgent instance: %o",r),super(r);const n=Object.assign({},r);this.secureProxy=r.secureProxy||Mi(n.protocol),n.host=n.hostname||n.host,typeof n.port=="string"&&(n.port=parseInt(n.port,10)),!n.port&&n.host&&(n.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in n)&&(n.ALPNProtocols=["http 1.1"]),n.host&&n.path&&(delete n.path,delete n.pathname),this.proxy=n}callback(t,r){return Ai(this,void 0,void 0,function*(){const{proxy:n,secureProxy:s}=this;let o;s?(he("Creating `tls.Socket`: %o",n),o=Xr.default.connect(n)):(he("Creating `net.Socket`: %o",n),o=Wr.default.connect(n));const u=Object.assign({},n.headers);let i=`CONNECT ${`${r.host}:${r.port}`} HTTP/1.1\r
47
+ `;n.auth&&(u["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:l,port:f,secureEndpoint:D}=r;Pi(f,D)||(l+=`:${f}`),u.Host=l,u.Connection="close";for(const h of Object.keys(u))i+=`${h}: ${u[h]}\r
48
+ `;const c=Oi.default(o);o.write(`${i}\r
49
+ `);const{statusCode:p,buffered:d}=yield c;if(p===200){if(t.once("socket",Si),r.secureEndpoint){he("Upgrading socket connection to TLS");const h=r.servername||r.host;return Xr.default.connect(Object.assign(Object.assign({},_i(r,"host","hostname","path","port")),{socket:o,servername:h}))}return o}o.destroy();const m=new Wr.default.Socket({writable:!1});return m.readable=!0,t.once("socket",h=>{he("replaying proxy buffer for failed request"),$i.default(h.listenerCount("data")>0),h.push(d),h.push(null)}),m})}}mt.default=Ii;function Si(e){e.resume()}function Pi(e,t){return!!(!t&&e===80||t&&e===443)}function Mi(e){return typeof e=="string"?/^https:?$/i.test(e):!1}function _i(e,...t){const r={};let n;for(n in e)t.includes(n)||(r[n]=e[n]);return r}var Ni=A&&A.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const vt=Ni(mt);function $t(e){return new vt.default(e)}(function(e){e.HttpsProxyAgent=vt.default,e.prototype=vt.default.prototype})($t||($t={}));var Ti=$t,Ri=J(Ti);const Li=async(e,t,r,n,s,o,u)=>new Promise((a,i)=>{const l=JSON.stringify(n),D=(e.protocol.includes("https")?On:xn).request({port:u||void 0,hostname:e.hostname,path:t,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(l),...r},timeout:s,agent:o?Ri(o):void 0},c=>{const p=[];c.on("data",d=>p.push(d)),c.on("end",()=>{a({request:D,response:c,data:Buffer.concat(p).toString()})})});D.on("error",i),D.on("timeout",()=>{D.destroy(),i(new y(`Time out error: request took over ${s}ms. Try increasing the \`timeout\` config`))}),D.write(l),D.end()}),ki=async(e,t,r,n,s,o)=>{const u=new URL(e),{response:a,data:i}=await Li(u,t,{Authorization:`Bearer ${r}`},n,s,o);if(!a.statusCode||a.statusCode<200||a.statusCode>299){let l=`OpenAI API Error: ${a.statusCode} - ${a.statusMessage}`;throw i&&(l+=`
50
50
 
51
51
  ${i}`),a.statusCode===500&&(l+=`
52
52
 
53
- Check the API status: https://status.openai.com`),new y(l)}return JSON.parse(i)},Pi=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),z=e=>Array.from(new Set(e)),_i=async(e,t,n,r,o,u,s,a,i,l,f,D,c,p)=>{try{const d=await Mi(e,t,n,{model:r,messages:[{role:"system",content:lt(o,a,i,c)},{role:"user",content:u}],temperature:D,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:f,stream:!1,n:s},l,p);return z(d.choices.filter(m=>m.message?.content).map(m=>Pi(m.message.content)).map(m=>{if(i==="conventional"){const h=/: (\w)/;return m.replace(h,(C,w)=>`: ${w.toLowerCase()}`)}return m}).filter(m=>{switch(i){case"gitmoji":return ti(m);case"conventional":return ei(m);case"":default:return!0}}))}catch(d){const m=d;throw m.code==="ENOTFOUND"?new y(`Error connecting to ${m.hostname} (${m.syscall})`):m}};class Ti extends q{constructor(t){super(t),this.params=t,this.handleError$=n=>{const r=n.error?.error?.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return T({name:`${this.errorPrefix} ${r}`,value:r,isError:!0})},this.colors={primary:"#AE5630",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Anthropic]"),this.errorPrefix=g.red.bold("[Anthropic]"),this.anthropic=new Re({apiKey:this.params.config.ANTHROPIC_KEY})}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>N(t)),L(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),j(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:n,generate:r,type:o,prompt:u}=this.params.config,s=this.params.config["max-length"],a=this.buildPrompt(n,t,r,s,o,u),l=(await this.anthropic.completions.create({model:this.params.config.ANTHROPIC_MODEL,max_tokens_to_sample:this.params.config["max-tokens"],temperature:this.params.config.temperature,prompt:`${Re.HUMAN_PROMPT} ${a}${Re.AI_PROMPT}`})).completion;return z(this.sanitizeMessage(l,this.params.config.type,r))}catch(t){const n=t;throw n.code==="ENOTFOUND"?new y(`Error connecting to ${n.hostname} (${n.syscall})`):n}}}const{hasOwnProperty:vt}=Object.prototype,$e=typeof process<"u"&&process.platform==="win32"?`\r
53
+ Check the API status: https://status.openai.com`),new y(l)}return JSON.parse(i)},ji=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),L=e=>Array.from(new Set(e)),Gi=async(e,t,r,n,s,o,u,a,i,l,f,D,c,p)=>{try{const d=await ki(e,t,r,{model:n,messages:[{role:"system",content:xe(s,a,i,c)},{role:"user",content:o}],temperature:D,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:f,stream:!1,n:u},l,p);return L(d.choices.filter(m=>m.message?.content).map(m=>ji(m.message.content)).map(m=>{if(i==="conventional"){const h=/: (\w)/;return m.replace(h,(C,w)=>`: ${w.toLowerCase()}`)}return m}).filter(m=>{switch(i){case"gitmoji":return ai(m);case"conventional":return ii(m);case"":default:return!0}}))}catch(d){const m=d;throw m.code==="ENOTFOUND"?new y(`Error connecting to ${m.hostname} (${m.syscall})`):m}},Ui=(e,t)=>{const r=Math.ceil(e),n=Math.floor(t);return Math.floor(Math.random()*(n-r+1))+r};async function*Jr(e){const t=await e;for await(const r of t)yield r}const ge=(e,t)=>e.disabled&&!t.disabled?1:!e.disabled&&t.disabled?-1:0,x="done",Zr="undone";class Hi extends Y{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.error?.error?.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return G({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.generateStreamChoice$=()=>{const r=this.params.stagedDiff.diff,{locale:n,generate:s,type:o,prompt:u}=this.params.config,a=this.params.config["max-length"],i=this.buildPrompt(n,r,s,a,o,u),l=this.anthropic.completions.create({model:this.params.config.ANTHROPIC_MODEL,max_tokens_to_sample:this.params.config["max-tokens"],temperature:this.params.config.temperature,prompt:`${ue.HUMAN_PROMPT} ${i}${ue.AI_PROMPT}`,stream:!0});let f="";return S(Jr(l)).pipe(jt(D=>f+=D.completion),P(D=>{const c=!!D.stop_reason&&D.stop_reason==="stop_sequence";return{id:this.params.keyName,name:`${this.serviceName} ${f}`,value:`${f}`,isError:!1,description:c?x:Zr,disabled:!c}}))},this.colors={primary:"#AE5630",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Anthropic]"),this.errorPrefix=g.red.bold("[Anthropic]"),this.anthropic=new ue({apiKey:this.params.config.ANTHROPIC_KEY})}generateCommitMessage$(){return U(this.generateMessage()).pipe(T(t=>S(t)),P(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),R(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o}=this.params.config,u=this.params.config["max-length"],a=this.buildPrompt(r,t,n,u,s,o),l=(await this.anthropic.completions.create({model:this.params.config.ANTHROPIC_MODEL,max_tokens_to_sample:this.params.config["max-tokens"],temperature:this.params.config.temperature,prompt:`${ue.HUMAN_PROMPT} ${a}${ue.AI_PROMPT}`})).completion;return L(this.sanitizeMessage(l,this.params.config.type,n))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}generateStreamCommitMessage$(){return this.generateStreamChoice$().pipe(Gt((t,r)=>{if(r.description===x){const o=L(this.sanitizeMessage(r.value,this.params.config.type,this.params.config.generate));return!o||o.length===0?[{id:`${this.params.keyName}_${x}_0`,name:`${this.serviceName} Failed to extract messages from response`,value:"Failed to extract messages from response",isError:!0,description:x,disabled:!0}]:o.map((a,i)=>({id:`${this.params.keyName}_${x}_${i}`,name:`${this.serviceName} ${a}`,value:`${a}`,isError:!1,description:x,disabled:!1}))}return t.find(o=>o.id===r.id)?[...t.map(o=>r.id===o.id?r:o)]:[{...r}]},[]),T(t=>t),R(this.handleError$))}}const{hasOwnProperty:Bt}=Object.prototype,Se=typeof process<"u"&&process.platform==="win32"?`\r
54
54
  `:`
55
- `,Bt=(e,t)=>{const n=[];let r="";typeof t=="string"?t={section:t,whitespace:!1}:(t=t||Object.create(null),t.whitespace=t.whitespace===!0);const o=t.whitespace?" = ":"=";for(const u of Object.keys(e)){const s=e[u];if(s&&Array.isArray(s))for(const a of s)r+=ne(u+"[]")+o+ne(a)+$e;else s&&typeof s=="object"?n.push(u):r+=ne(u)+o+ne(s)+$e}t.section&&r.length&&(r="["+ne(t.section)+"]"+$e+r);for(const u of n){const s=Yr(u).join("\\."),a=(t.section?t.section+".":"")+s,{whitespace:i}=t,l=Bt(e[u],{section:a,whitespace:i});r.length&&l.length&&(r+=$e),r+=l}return r},Yr=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),Wr=e=>{const t=Object.create(null);let n=t,r=null;const o=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,u=e.split(/[\r\n]+/g);for(const a of u){if(!a||a.match(/^\s*[;#]/))continue;const i=a.match(o);if(!i)continue;if(i[1]!==void 0){if(r=xe(i[1]),r==="__proto__"){n=Object.create(null);continue}n=t[r]=t[r]||Object.create(null);continue}const l=xe(i[2]),f=l.length>2&&l.slice(-2)==="[]",D=f?l.slice(0,-2):l;if(D==="__proto__")continue;const c=i[3]?xe(i[4]):!0,p=c==="true"||c==="false"||c==="null"?JSON.parse(c):c;f&&(vt.call(n,D)?Array.isArray(n[D])||(n[D]=[n[D]]):n[D]=[]),Array.isArray(n[D])?n[D].push(p):n[D]=p}const s=[];for(const a of Object.keys(t)){if(!vt.call(t,a)||typeof t[a]!="object"||Array.isArray(t[a]))continue;const i=Yr(a);n=t;const l=i.pop(),f=l.replace(/\\\./g,".");for(const D of i)D!=="__proto__"&&((!vt.call(n,D)||typeof n[D]!="object")&&(n[D]=Object.create(null)),n=n[D]);n===t&&f===l||(n[f]=t[a],s.push(a))}for(const a of s)delete t[a];return t},Vr=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),ne=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&Vr(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),xe=(e,t)=>{if(e=(e||"").trim(),Vr(e)){e.charAt(0)==="'"&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let n=!1,r="";for(let o=0,u=e.length;o<u;o++){const s=e.charAt(o);if(n)"\\;#".indexOf(s)!==-1?r+=s:r+="\\"+s,n=!1;else{if(";#".indexOf(s)!==-1)break;s==="\\"?n=!0:r+=s}}return n&&(r+="\\"),r.trim()}return e};var Ni={parse:Wr,decode:Wr,stringify:Bt,encode:Bt,safe:ne,unsafe:xe},Xr=X(Ni);const Jr=e=>$.lstat(e).then(()=>!0,()=>!1),Li=["","conventional","gitmoji"],{hasOwnProperty:Ri}=Object.prototype,Y=(e,t)=>Ri.call(e,t),E=(e,t,n)=>{if(!t)throw new y(`Invalid config property ${e}: ${n}`)},Oe={OPENAI_KEY(e){return e||""},OPENAI_MODEL(e){return!e||e.length===0?"gpt-3.5-turbo":e},OPENAI_URL(e){return e?(E("OPENAI_URL",/^https?:\/\//.test(e),"Must be a valid URL"),e):"https://api.openai.com"},OPENAI_PATH(e){return e||"/v1/chat/completions"},HUGGING_COOKIE(e){return e||""},HUGGING_MODEL(e){return!e||e.length===0?"mistralai/Mixtral-8x7B-Instruct-v0.1":(E("HUGGING_MODEL",["mistralai/Mixtral-8x7B-Instruct-v0.1","meta-llama/Llama-2-70b-chat-hf","NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO","codellama/CodeLlama-70b-Instruct-hf","mistralai/Mistral-7B-Instruct-v0.2","openchat/openchat-3.5-0106"].includes(e),"Invalid model type of hugging"),e)},CLOVAX_COOKIE(e){return e||""},GEMINI_KEY(e){return e||""},GEMINI_MODEL(e){return!e||e.length===0?"gemini-pro":(E("GEMINI_MODEL",["gemini-pro"].includes(e),"Invalid model type of Gemini"),e)},ANTHROPIC_MODEL(e){return!e||e.length===0?"claude-2.1":(E("ANTHROPIC_MODEL",["claude-2.1","claude-2.0","claude-instant-1.2"].includes(e),"Invalid model type of Anthropic"),e)},ANTHROPIC_KEY(e){return e||""},MISTRAL_KEY(e){return e||""},MISTRAL_MODEL(e){return!e||e.length===0?"mistral-tiny":(E("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)},OLLAMA_MODEL(e){return e||""},OLLAMA_HOST(e){return e?(E("OLLAMA_HOST",/^https?:\/\//.test(e),"Must be a valid URL"),e):"http://localhost:11434"},OLLAMA_TIMEOUT(e){if(!e)return 1e5;E("OLLAMA_TIMEOUT",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("OLLAMA_TIMEOUT",t>=500,"Must be greater than 500ms"),t},confirm(e){return e?typeof e=="boolean"?e:(E("confirm",/^(?:true|false)$/.test(e),"Must be a boolean"),e==="true"):!1},prompt(e){return e||""},locale(e){return e?(E("locale",e,"Cannot be empty"),E("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;E("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("generate",t>0,"Must be greater than 0"),E("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(E("type",Li.includes(e),"Invalid commit type"),e):"conventional"},proxy(e){if(!(!e||e.length===0))return E("proxy",/^https?:\/\//.test(e),"Must be a valid URL"),e},timeout(e){if(!e)return 1e4;E("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("timeout",t>=500,"Must be greater than 500ms"),t},temperature(e){if(!e)return .7;E("temperature",/^(2|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 2");const t=Number(e);return E("temperature",t>0,"Must be greater than 0"),E("temperature",t<=2,"Must be less than or equal to 2"),t},"max-length"(e){if(!e)return 50;E("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("max-length",t>=20,"Must be greater than 20 characters"),t},"max-tokens"(e){return e?(E("max-tokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):200}},$t=V.join(kt.homedir(),".aicommit2"),Zr=async()=>{if(!await Jr($t))return Object.create(null);const t=await $.readFile($t,"utf8");return Xr.parse(t)},xt=async(e,t)=>{const n=await Zr(),r={};for(const o of Object.keys(Oe)){const u=Oe[o],s=e?.[o]??n[o];if(t)try{r[o]=u(s)}catch{}else r[o]=u(s)}return r},ki=async e=>{const t=await Zr();for(const[n,r]of e){if(!Y(Oe,n))throw new y(`Invalid config property: ${n}`);const o=Oe[n](r);t[n]=o}await $.writeFile($t,Xr.stringify(t),"utf8")};class x{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=In.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 ji extends q{constructor(t){super(t),this.params=t,this.host="https://clova-x.naver.com",this.cookie="",this.colors={primary:"#00db9b",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[CLOVA X]"),this.errorPrefix=g.red.bold("[CLOVA X]"),this.cookie=this.params.config.CLOVAX_COOKIE}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>N(t)),L(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),j(this.handleError$))}async generateMessage(){try{const{locale:t,generate:n,type:r,prompt:o}=this.params.config,u=this.params.config["max-length"],s=this.params.stagedDiff.diff,a=this.buildPrompt(t,s,n,u,r,o);await this.getAllConversationIds();const i=await this.sendMessage(a),{conversationId:l,allText:f}=this.parseSendMessageResult(i);return await this.deleteConversation(l),z(this.sanitizeMessage(f,this.params.config.type,n))}catch(t){const n=t;throw n.code==="ENOTFOUND"?new y(`Error connecting to ${n.hostname} (${n.syscall})`):n}}async getAllConversationIds(){const n=(await new x({method:"GET",baseURL:`${this.host}/api/v1/conversations`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).setParams({page:0,size:50,sort:"turnUpdatedTime,DESC"}).execute()).data;if(!n||!n.content)throw new Error("No content on conversations ClovaX");return n.content.length===0?[]:n.content.map(o=>o.conversationId||"").filter(o=>!!o)}async sendMessage(t){const n={text:t,action:"new"},r=new xn;return r.set("form",new On([JSON.stringify(n)],{type:"application/json"})),(await new x({method:"POST",baseURL:`${this.host}/api/v1/generate`,timeout:this.params.config.timeout}).setHeaders({"Content-Type":"multipart/form-data","Content-Length":this.getContentLength(r),Cookie:this.cookie}).setBody(r).execute()).data}parseSendMessageResult(t){const n=/data:{(.*)}/g,r=t.match(n);if(!r)throw new Error("Failed to extract object from generated text");const o=r.map(i=>i.trim().replace(/data:/g,""));if(!o||o.length===0)throw new Error("Cannot extract message");let u="",s="",a="";if(o.map(i=>{try{return JSON.parse(i)}catch{return null}}).filter(i=>!!i).forEach(i=>{if(Y(i,"conversationId")){u=i.conversationId;return}if(Y(i,"text")){s+=i.text;return}if(Y(i,"error")){a=`${i.error}: ${i.type||i.message||""}`;return}}),a)throw new Error(a);if(!u)throw new Error("No conversationId!");if(!s)throw new Error("No allText!");return{conversationId:u,allText:s}}async deleteConversation(t){return(await new x({method:"DELETE",baseURL:`${this.host}/api/v1/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).execute()).data}getContentLength(t){return Array.from(t.entries(),([n,r])=>({[n]:{ContentLength:typeof r=="string"?r.length:r.size}}))}}class Gi extends q{constructor(t){super(t),this.params=t,this.handleError$=n=>{const r=n.message||n.toString(),o=/(\[.*?\]\s*[^[]*)/g,u=[...r.matchAll(o)],s=[];u.forEach(i=>s.push(i[1]));const a=s[1]||"An error occurred";return T({name:`${this.errorPrefix} ${a}`,value:a,isError:!0})},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Gemini]"),this.errorPrefix=g.red.bold("[Gemini]"),this.genAI=new Sn(this.params.config.GEMINI_KEY)}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>N(t)),L(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),j(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:n,generate:r,type:o,prompt:u}=this.params.config,s=this.params.config["max-length"],a=this.buildPrompt(n,t,r,s,o,u),i=this.params.config["max-tokens"],c=(await(await this.genAI.getGenerativeModel({model:this.params.config.GEMINI_MODEL,generationConfig:{maxOutputTokens:i,temperature:this.params.config.temperature}}).generateContent(a)).response).text();return z(this.sanitizeMessage(c,this.params.config.type,r))}catch(t){const n=t;throw n.code==="ENOTFOUND"?new y(`Error connecting to ${n.hostname} (${n.syscall})`):n}}}class Ui extends q{constructor(t){super(t),this.params=t,this.host="https://huggingface.co",this.cookie="",this.colors={primary:"#FED21F",secondary:"#000"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[HuggingFace]"),this.errorPrefix=g.red.bold("[HuggingFace]"),this.cookie=this.params.config.HUGGING_COOKIE}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>N(t)),L(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),j(this.handleError$))}async generateMessage(){try{const{locale:t,generate:n,type:r,prompt:o}=this.params.config,u=this.params.config["max-length"],s=this.params.stagedDiff.diff,a=this.buildPrompt(t,s,n,u,r,o);await this.prepareNewConversation();const{conversationId:i}=await this.getNewConversationId();await this.prepareConversationEvent(i);const{lastMessageId:l}=await this.getConversationInfo(i),f=await this.sendMessage(i,a,l);return await this.deleteConversation(i),z(this.sanitizeHuggingMessage(f,this.params.config.type,n))}catch(t){const n=t;throw n.code==="ENOTFOUND"?new y(`Error connecting to ${n.hostname} (${n.syscall})`):n}}sanitizeHuggingMessage(t,n,r){const o=/{[^{}]*}/g,u=t.match(o);if(!u)throw new Error("Failed to extract object from generated text");let s=null;if(u.forEach((a,i)=>{try{const l=JSON.parse(a);Y(l,"type")&&l.type==="finalAnswer"&&(s=l)}catch{}}),!s||!Y(s,"text"))throw new Error("Cannot parse finalAnswer");return this.sanitizeMessage(t,n,r)}async prepareNewConversation(){return(await new x({method:"POST",baseURL:`${this.host}/api/event`}).setHeaders({"content-type":"application/json",Cookie:this.cookie}).setBody({d:"huggingface.co",n:"pageview",r:"https://huggingface.co/chat/",u:"https://huggingface.co/chat/"}).execute()).data}async prepareConversationEvent(t){return(await new x({method:"POST",baseURL:`${this.host}/api/event`}).setHeaders({"content-type":"application/json",Cookie:this.cookie}).setBody({d:"huggingface.co",n:"pageview",r:"https://huggingface.co/chat/",u:`https://huggingface.co/chat/conversation/${t}`}).execute()).data}async getNewConversationId(){const t=await new x({method:"POST",baseURL:`${this.host}/chat/conversation`,timeout:this.params.config.timeout}).setHeaders({"content-type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Host:"huggingface.co",Origin:"https://huggingface.co"}).setBody({model:this.params.config.HUGGING_MODEL,preprompt:""}).execute();if(!t.data||!t.data.conversationId)throw new Error("No conversationId on Hugging service");return t.data}async getConversationInfo(t){const r=(await new x({method:"GET",baseURL:`${this.host}/chat/conversation/${t}/__data.json`,timeout:this.params.config.timeout}).setParams({"x-sveltekit-invalidated":"11"}).setHeaders({"Content-Type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Referer:"https://huggingface.co/chat/"}).execute()).data;if(!r||!r.nodes||r.nodes.length===0)throw new Error("No Nodes on conversation info");if(!r.nodes[1]||!r.nodes[1].data||r.nodes[1].data.length===0||!r.nodes[1].data[3])throw new Error("No data on node");const s=r.nodes[1]?.data[3];return{conversationInfo:r,lastMessageId:s}}async deleteConversation(t){return await new x({method:"DELETE",baseURL:`${this.host}/chat/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).execute(),(await new x({method:"GET",baseURL:`${this.host}/chat/__data.json`,timeout:this.params.config.timeout}).setParams({"x-sveltekit-trailing-slash":"1","x-sveltekit-invalidated":"10"}).setHeaders({"Content-Type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Referer:"https://huggingface.co/chat/"}).execute()).data}async sendMessage(t,n,r){return(await new x({method:"POST",baseURL:`${this.host}/chat/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({"content-type":"application/json",Cookie:this.cookie,authority:"huggingface.co",accept:"*/*",origin:"https://huggingface.co"}).setBody({files:[],id:r,inputs:n,is_continue:!1,is_retry:!1,use_cache:!1}).execute()).data}}const Hi=(e,t)=>{const n=Math.ceil(e),r=Math.floor(t);return Math.floor(Math.random()*(r-n+1))+n};class Ki extends q{constructor(t){super(t),this.params=t,this.host="https://api.mistral.ai",this.apiKey="",this.handleError$=n=>{const r=n.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return T({name:`${this.errorPrefix} ${r}`,value:r,isError:!0})},this.colors={primary:"#FC4A0A",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[MistralAI]"),this.errorPrefix=g.red.bold("[MistralAI]"),this.apiKey=this.params.config.MISTRAL_KEY}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>N(t)),L(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),j(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:n,generate:r,type:o,prompt:u}=this.params.config,s=this.params.config["max-length"],a=this.buildPrompt(n,t,r,s,o,u);await this.checkAvailableModels();const i=await this.createChatCompletions(a);return z(this.sanitizeMessage(i,this.params.config.type,r))}catch(t){const n=t;throw n.code==="ENOTFOUND"?new y(`Error connecting to ${n.hostname} (${n.syscall})`):n}}async checkAvailableModels(){if((await this.getAvailableModels()).includes(this.params.config.MISTRAL_MODEL))return!0;throw new Error("Invalid model type of Mistral AI")}async getAvailableModels(){return(await new x({method:"GET",baseURL:`${this.host}/v1/models`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).execute()).data.data.filter(n=>n.object==="model").map(n=>n.id)}async createChatCompletions(t){const r=(await new x({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.MISTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed:Hi(10,1e3)}).execute()).data;if(!r.choices||r.choices.length===0||!r.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return r.choices[0].message.content}}class qi extends q{constructor(t){super(t),this.params=t,this.host="http://localhost:11434",this.model="",this.handleError$=n=>{if(n.response.data?.error)return T({name:`${this.errorPrefix} ${n.response.data?.error}`,value:n.response.data?.error,isError:!0});const r=n.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return T({name:`${this.errorPrefix} ${r}`,value:r,isError:!0})},this.colors={primary:"#FFF",secondary:"#000"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Ollama]"),this.errorPrefix=g.red.bold("[Ollama]"),this.model=this.params.config.OLLAMA_MODEL,this.host=this.params.config.OLLAMA_HOST||"http://localhost:11434",this.ollama=new Mn({host:this.host})}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>N(t)),L(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),j(this.handleError$))}async generateMessage(){try{await this.checkIsAvailableOllama();const t=await this.createChatCompletions();return z(this.sanitizeMessage(t,this.params.config.type,this.params.config.generate))}catch(t){const n=t;throw n.code==="ENOTFOUND"?new y(`Error connecting to ${n.hostname} (${n.syscall})`):n}}async checkIsAvailableOllama(){try{return(await new x({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.OLLAMA_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(){const n=`${lt(this.params.config.locale,this.params.config["max-length"],this.params.config.type,this.params.config.prompt)}
56
- Please just generate ${this.params.config.generate} commit messages in numbered list format without explanation.`;return(await this.ollama.chat({model:this.params.config.OLLAMA_MODEL,messages:[{role:"system",content:n},{role:"user",content:this.params.stagedDiff.diff}],stream:!1})).message.content}}class zi extends q{constructor(t){super(t),this.params=t,this.handleError$=n=>{let r="An error occurred";if(n.message){r=n.message.split(`
57
- `)[0];const o=this.extractJSONFromError(n.message);r+=`: ${o.error.message}`}return T({name:`${this.errorPrefix} ${r}`,value:r,isError:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=g.red.bold("[ChatGPT]")}generateCommitMessage$(){return G(_i(this.params.config.OPENAI_URL,this.params.config.OPENAI_PATH,this.params.config.OPENAI_KEY,this.params.config.OPENAI_MODEL,this.params.config.locale,this.params.stagedDiff.diff,this.params.config.generate,this.params.config["max-length"],this.params.config.type,this.params.config.timeout,this.params.config["max-tokens"],this.params.config.temperature,this.params.config.prompt,this.params.config.proxy)).pipe(k(t=>N(t)),L(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),j(this.handleError$))}extractJSONFromError(t){const n=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,r=t.match(n);return r?Object.assign({},...r.map(o=>JSON.parse(o))):{error:{message:"Unknown error"}}}}class Qr{constructor(t,n){this.config=t,this.stagedDiff=n}createAIRequests$(t){return N(t).pipe(hn(n=>{const r={config:this.config,stagedDiff:this.stagedDiff};switch(n){case R.OPEN_AI:return K.create(zi,r).generateCommitMessage$();case R.GEMINI:return K.create(Gi,r).generateCommitMessage$();case R.ANTHROPIC:return K.create(Ti,r).generateCommitMessage$();case R.HUGGING:return K.create(Ui,r).generateCommitMessage$();case R.CLOVA_X:return K.create(ji,r).generateCommitMessage$();case R.MISTRAL:return K.create(Ki,r).generateCommitMessage$();case R.OLLAMA:return K.create(qi,r).generateCommitMessage$();default:const o=g.red.bold(`[${n}]`);return T({name:o+" Invalid AI type",value:"Invalid AI type",isError:!0})}}))}}const en=async()=>{const{stdout:e,failed:t}=await te("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new y("The current directory must be a Git repository!");return e},Ot=e=>`:(exclude)${e}`,tn=["package-lock.json","pnpm-lock.yaml","*.lock"].map(Ot),rn=async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:n}=await te("git",[...t,"--name-only",...tn,...e?e.map(Ot):[]]);if(!n)return null;const{stdout:r}=await te("git",[...t,...tn,...e?e.map(Ot):[]]);return{files:n.split(`
58
- `),diff:r}},Yi=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class Ie{constructor(){this.title="aicommit2"}printTitle(){console.log(Pn.textSync(this.title,{font:"Small"}))}displaySpinner(t){return Le(t).start()}stopSpinner(t){t.stop(),t.clear()}printStagedFiles(t){console.log(g.bold.green("\u2714 ")+g.bold(`${Yi(t.files)}:`)),console.log(`${t.files.map(n=>` ${n}`).join(`
55
+ `,xt=(e,t)=>{const r=[];let n="";typeof t=="string"?t={section:t,whitespace:!1}:(t=t||Object.create(null),t.whitespace=t.whitespace===!0);const s=t.whitespace?" = ":"=";for(const o of Object.keys(e)){const u=e[o];if(u&&Array.isArray(u))for(const a of u)n+=oe(o+"[]")+s+oe(a)+Se;else u&&typeof u=="object"?r.push(o):n+=oe(o)+s+oe(u)+Se}t.section&&n.length&&(n="["+oe(t.section)+"]"+Se+n);for(const o of r){const u=Qr(o).join("\\."),a=(t.section?t.section+".":"")+u,{whitespace:i}=t,l=xt(e[o],{section:a,whitespace:i});n.length&&l.length&&(n+=Se),n+=l}return n},Qr=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),en=e=>{const t=Object.create(null);let r=t,n=null;const s=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,o=e.split(/[\r\n]+/g);for(const a of o){if(!a||a.match(/^\s*[;#]/))continue;const i=a.match(s);if(!i)continue;if(i[1]!==void 0){if(n=Pe(i[1]),n==="__proto__"){r=Object.create(null);continue}r=t[n]=t[n]||Object.create(null);continue}const l=Pe(i[2]),f=l.length>2&&l.slice(-2)==="[]",D=f?l.slice(0,-2):l;if(D==="__proto__")continue;const c=i[3]?Pe(i[4]):!0,p=c==="true"||c==="false"||c==="null"?JSON.parse(c):c;f&&(Bt.call(r,D)?Array.isArray(r[D])||(r[D]=[r[D]]):r[D]=[]),Array.isArray(r[D])?r[D].push(p):r[D]=p}const u=[];for(const a of Object.keys(t)){if(!Bt.call(t,a)||typeof t[a]!="object"||Array.isArray(t[a]))continue;const i=Qr(a);r=t;const l=i.pop(),f=l.replace(/\\\./g,".");for(const D of i)D!=="__proto__"&&((!Bt.call(r,D)||typeof r[D]!="object")&&(r[D]=Object.create(null)),r=r[D]);r===t&&f===l||(r[f]=t[a],u.push(a))}for(const a of u)delete t[a];return t},tn=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),oe=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&tn(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),Pe=(e,t)=>{if(e=(e||"").trim(),tn(e)){e.charAt(0)==="'"&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let r=!1,n="";for(let s=0,o=e.length;s<o;s++){const u=e.charAt(s);if(r)"\\;#".indexOf(u)!==-1?n+=u:n+="\\"+u,r=!1;else{if(";#".indexOf(u)!==-1)break;u==="\\"?r=!0:n+=u}}return r&&(n+="\\"),n.trim()}return e};var Ki={parse:en,decode:en,stringify:xt,encode:xt,safe:oe,unsafe:Pe},rn=J(Ki);const nn=e=>B.lstat(e).then(()=>!0,()=>!1),qi=["","conventional","gitmoji"],{hasOwnProperty:zi}=Object.prototype,V=(e,t)=>zi.call(e,t),E=(e,t,r)=>{if(!t)throw new y(`Invalid config property ${e}: ${r}`)},Me={OPENAI_KEY(e){return e||""},OPENAI_MODEL(e){return!e||e.length===0?"gpt-3.5-turbo":e},OPENAI_URL(e){return e?(E("OPENAI_URL",/^https?:\/\//.test(e),"Must be a valid URL"),e):"https://api.openai.com"},OPENAI_PATH(e){return e||"/v1/chat/completions"},HUGGING_COOKIE(e){return e||""},HUGGING_MODEL(e){return!e||e.length===0?"mistralai/Mixtral-8x7B-Instruct-v0.1":(E("HUGGING_MODEL",["mistralai/Mixtral-8x7B-Instruct-v0.1","meta-llama/Llama-2-70b-chat-hf","NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO","codellama/CodeLlama-70b-Instruct-hf","mistralai/Mistral-7B-Instruct-v0.2","openchat/openchat-3.5-0106"].includes(e),"Invalid model type of hugging"),e)},CLOVAX_COOKIE(e){return e||""},GEMINI_KEY(e){return e||""},GEMINI_MODEL(e){return!e||e.length===0?"gemini-pro":(E("GEMINI_MODEL",["gemini-pro"].includes(e),"Invalid model type of Gemini"),e)},ANTHROPIC_MODEL(e){return!e||e.length===0?"claude-2.1":(E("ANTHROPIC_MODEL",["claude-2.1","claude-2.0","claude-instant-1.2"].includes(e),"Invalid model type of Anthropic"),e)},ANTHROPIC_KEY(e){return e||""},MISTRAL_KEY(e){return e||""},MISTRAL_MODEL(e){return!e||e.length===0?"mistral-tiny":(E("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)},OLLAMA_MODEL(e){return e||""},OLLAMA_HOST(e){return e?(E("OLLAMA_HOST",/^https?:\/\//.test(e),"Must be a valid URL"),e):"http://localhost:11434"},OLLAMA_TIMEOUT(e){if(!e)return 1e5;E("OLLAMA_TIMEOUT",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("OLLAMA_TIMEOUT",t>=500,"Must be greater than 500ms"),t},confirm(e){return e?typeof e=="boolean"?e:(E("confirm",/^(?:true|false)$/.test(e),"Must be a boolean"),e==="true"):!1},prompt(e){return e||""},locale(e){return e?(E("locale",e,"Cannot be empty"),E("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;E("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("generate",t>0,"Must be greater than 0"),E("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(E("type",qi.includes(e),"Invalid commit type"),e):"conventional"},proxy(e){if(!(!e||e.length===0))return E("proxy",/^https?:\/\//.test(e),"Must be a valid URL"),e},timeout(e){if(!e)return 1e4;E("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("timeout",t>=500,"Must be greater than 500ms"),t},temperature(e){if(!e)return .7;E("temperature",/^(2|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 2");const t=Number(e);return E("temperature",t>0,"Must be greater than 0"),E("temperature",t<=2,"Must be less than or equal to 2"),t},"max-length"(e){if(!e)return 50;E("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("max-length",t>=20,"Must be greater than 20 characters"),t},"max-tokens"(e){return e?(E("max-tokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):200}},Ot=X.join(Ht.homedir(),".aicommit2"),on=async()=>{if(!await nn(Ot))return Object.create(null);const t=await B.readFile(Ot,"utf8");return rn.parse(t)},It=async(e,t)=>{const r=await on(),n={};for(const s of Object.keys(Me)){const o=Me[s],u=e?.[s]??r[s];if(t)try{n[s]=o(u)}catch{}else n[s]=o(u)}return n},Yi=async e=>{const t=await on();for(const[r,n]of e){if(!V(Me,r))throw new y(`Invalid config property: ${r}`);const s=Me[r](n);t[r]=s}await B.writeFile(Ot,rn.stringify(t),"utf8")};class O{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=Rn.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 Vi extends Y{constructor(t){super(t),this.params=t,this.host="https://clova-x.naver.com",this.cookie="",this.colors={primary:"#00db9b",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[CLOVA X]"),this.errorPrefix=g.red.bold("[CLOVA X]"),this.cookie=this.params.config.CLOVAX_COOKIE}generateCommitMessage$(){return U(this.generateMessage()).pipe(T(t=>S(t)),P((t,r)=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),R(this.handleError$))}async generateMessage(){try{const{locale:t,generate:r,type:n,prompt:s}=this.params.config,o=this.params.config["max-length"],u=this.params.stagedDiff.diff,a=this.buildPrompt(t,u,r,o,n,s);await this.getAllConversationIds();const i=await this.sendMessage(a),{conversationId:l,allText:f}=this.parseSendMessageResult(i);return await this.deleteConversation(l),L(this.sanitizeMessage(f,this.params.config.type,r))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async getAllConversationIds(){const r=(await new O({method:"GET",baseURL:`${this.host}/api/v1/conversations`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).setParams({page:0,size:50,sort:"turnUpdatedTime,DESC"}).execute()).data;if(!r||!r.content)throw new Error("No content on conversations ClovaX");return r.content.length===0?[]:r.content.map(s=>s.conversationId||"").filter(s=>!!s)}async sendMessage(t){const r={text:t,action:"new"},n=new Nn;return n.set("form",new Tn([JSON.stringify(r)],{type:"application/json"})),(await new O({method:"POST",baseURL:`${this.host}/api/v1/generate`,timeout:this.params.config.timeout}).setHeaders({"Content-Type":"multipart/form-data","Content-Length":this.getContentLength(n),Cookie:this.cookie}).setBody(n).execute()).data}parseSendMessageResult(t){const r=/data:{(.*)}/g,n=t.match(r);if(!n)throw new Error("Failed to extract object from generated text");const s=n.map(i=>i.trim().replace(/data:/g,""));if(!s||s.length===0)throw new Error("Cannot extract message");let o="",u="",a="";if(s.map(i=>{try{return JSON.parse(i)}catch{return null}}).filter(i=>!!i).forEach(i=>{if(V(i,"conversationId")){o=i.conversationId;return}if(V(i,"text")){u+=i.text;return}if(V(i,"error")){a=`${i.error}: ${i.type||i.message||""}`;return}}),a)throw new Error(a);if(!o)throw new Error("No conversationId!");if(!u)throw new Error("No allText!");return{conversationId:o,allText:u}}async deleteConversation(t){return(await new O({method:"DELETE",baseURL:`${this.host}/api/v1/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).execute()).data}getContentLength(t){return Array.from(t.entries(),([r,n])=>({[r]:{ContentLength:typeof n=="string"?n.length:n.size}}))}}class Wi extends Y{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.message||r.toString(),s=/(\[.*?\]\s*[^[]*)/g,o=[...n.matchAll(s)],u=[];o.forEach(i=>u.push(i[1]));const a=u[1]||"An error occurred";return G({name:`${this.errorPrefix} ${a}`,value:a,isError:!0,disabled:!0})},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Gemini]"),this.errorPrefix=g.red.bold("[Gemini]"),this.genAI=new Ln(this.params.config.GEMINI_KEY)}generateCommitMessage$(){return U(this.generateMessage()).pipe(T(t=>S(t)),P(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),R(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o}=this.params.config,u=this.params.config["max-length"],a=this.buildPrompt(r,t,n,u,s,o),i=this.params.config["max-tokens"],c=(await(await this.genAI.getGenerativeModel({model:this.params.config.GEMINI_MODEL,generationConfig:{maxOutputTokens:i,temperature:this.params.config.temperature}}).generateContent(a)).response).text();return L(this.sanitizeMessage(c,this.params.config.type,n))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}}class Xi extends Y{constructor(t){super(t),this.params=t,this.host="https://huggingface.co",this.cookie="",this.colors={primary:"#FED21F",secondary:"#000"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[HuggingFace]"),this.errorPrefix=g.red.bold("[HuggingFace]"),this.cookie=this.params.config.HUGGING_COOKIE}generateCommitMessage$(){return U(this.generateMessage()).pipe(T(t=>S(t)),P((t,r)=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),R(this.handleError$))}async generateMessage(){try{const{locale:t,generate:r,type:n,prompt:s}=this.params.config,o=this.params.config["max-length"],u=this.params.stagedDiff.diff,a=this.buildPrompt(t,u,r,o,n,s);await this.prepareNewConversation();const{conversationId:i}=await this.getNewConversationId();await this.prepareConversationEvent(i);const{lastMessageId:l}=await this.getConversationInfo(i),f=await this.sendMessage(i,a,l);return await this.deleteConversation(i),L(this.sanitizeHuggingMessage(f,this.params.config.type,r))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}sanitizeHuggingMessage(t,r,n){const s=/{[^{}]*}/g,o=t.match(s);if(!o)throw new Error("Failed to extract object from generated text");let u=null;if(o.forEach((a,i)=>{try{const l=JSON.parse(a);V(l,"type")&&l.type==="finalAnswer"&&(u=l)}catch{}}),!u||!V(u,"text"))throw new Error("Cannot parse finalAnswer");return this.sanitizeMessage(u.text,r,n)}async prepareNewConversation(){return(await new O({method:"POST",baseURL:`${this.host}/api/event`}).setHeaders({"content-type":"application/json",Cookie:this.cookie}).setBody({d:"huggingface.co",n:"pageview",r:"https://huggingface.co/chat/",u:"https://huggingface.co/chat/"}).execute()).data}async prepareConversationEvent(t){return(await new O({method:"POST",baseURL:`${this.host}/api/event`}).setHeaders({"content-type":"application/json",Cookie:this.cookie}).setBody({d:"huggingface.co",n:"pageview",r:"https://huggingface.co/chat/",u:`https://huggingface.co/chat/conversation/${t}`}).execute()).data}async getNewConversationId(){const t=await new O({method:"POST",baseURL:`${this.host}/chat/conversation`,timeout:this.params.config.timeout}).setHeaders({"content-type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Host:"huggingface.co",Origin:"https://huggingface.co"}).setBody({model:this.params.config.HUGGING_MODEL,preprompt:""}).execute();if(!t.data||!t.data.conversationId)throw new Error("No conversationId on Hugging service");return t.data}async getConversationInfo(t){const n=(await new O({method:"GET",baseURL:`${this.host}/chat/conversation/${t}/__data.json`,timeout:this.params.config.timeout}).setParams({"x-sveltekit-invalidated":"11"}).setHeaders({"Content-Type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Referer:"https://huggingface.co/chat/"}).execute()).data;if(!n||!n.nodes||n.nodes.length===0)throw new Error("No Nodes on conversation info");if(!n.nodes[1]||!n.nodes[1].data||n.nodes[1].data.length===0||!n.nodes[1].data[3])throw new Error("No data on node");const u=n.nodes[1]?.data[3];return{conversationInfo:n,lastMessageId:u}}async deleteConversation(t){return await new O({method:"DELETE",baseURL:`${this.host}/chat/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).execute(),(await new O({method:"GET",baseURL:`${this.host}/chat/__data.json`,timeout:this.params.config.timeout}).setParams({"x-sveltekit-trailing-slash":"1","x-sveltekit-invalidated":"10"}).setHeaders({"Content-Type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Referer:"https://huggingface.co/chat/"}).execute()).data}async sendMessage(t,r,n){return(await new O({method:"POST",baseURL:`${this.host}/chat/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({"content-type":"application/json",Cookie:this.cookie,authority:"huggingface.co",accept:"*/*",origin:"https://huggingface.co"}).setBody({files:[],id:n,inputs:r,is_continue:!1,is_retry:!1,use_cache:!1}).execute()).data}}class Ji extends Y{constructor(t){super(t),this.params=t,this.host="https://api.mistral.ai",this.apiKey="",this.handleError$=r=>{const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return G({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#FC4A0A",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[MistralAI]"),this.errorPrefix=g.red.bold("[MistralAI]"),this.apiKey=this.params.config.MISTRAL_KEY}generateCommitMessage$(){return U(this.generateMessage()).pipe(T(t=>S(t)),P(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),R(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:s,prompt:o}=this.params.config,u=this.params.config["max-length"],a=this.buildPrompt(r,t,n,u,s,o);await this.checkAvailableModels();const i=await this.createChatCompletions(a);return L(this.sanitizeMessage(i,this.params.config.type,n))}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.MISTRAL_MODEL))return!0;throw new Error("Invalid model type of Mistral AI")}async getAvailableModels(){return(await new O({method:"GET",baseURL:`${this.host}/v1/models`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).execute()).data.data.filter(r=>r.object==="model").map(r=>r.id)}async createChatCompletions(t){const n=(await new O({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.MISTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed:Ui(10,1e3)}).execute()).data;if(!n.choices||n.choices.length===0||!n.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return n.choices[0].message.content}}class Zi extends Y{constructor(t){super(t),this.params=t,this.host="http://localhost:11434",this.model="",this.handleError$=r=>{if(r.response&&r.response.data?.error)return G({name:`${this.errorPrefix} ${r.response.data?.error}`,value:r.response.data?.error,isError:!0,disabled:!0});const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return G({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.generateStreamChoice$=()=>{const n=`${xe(this.params.config.locale,this.params.config["max-length"],this.params.config.type,this.params.config.prompt)}
56
+ Please just generate ${this.params.config.generate} commit messages in numbered list format without explanation.`,s=this.ollama.chat({model:this.model,messages:[{role:"system",content:n},{role:"user",content:this.params.stagedDiff.diff}],stream:!0});let o="";return S(Jr(s)).pipe(jt(u=>o+=u.message.content),P(u=>({id:this.params.keyName,name:`${this.serviceName} ${o}`,value:`${o}`,isError:!1,description:u.done?x:Zr,disabled:!u.done})))},this.colors={primary:"#FFF",secondary:"#000"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Ollama]"),this.errorPrefix=g.red.bold("[Ollama]"),this.model=this.params.config.OLLAMA_MODEL,this.host=this.params.config.OLLAMA_HOST||"http://localhost:11434",this.ollama=new kn({host:this.host})}generateCommitMessage$(){return U(this.generateMessage()).pipe(T(t=>S(t)),P(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),R(this.handleError$))}generateStreamCommitMessage$(){return U(this.checkIsAvailableOllama()).pipe(wn(()=>this.generateStreamChoice$()),Gt((t,r)=>{if(r.description===x){const o=L(this.sanitizeMessage(r.value,this.params.config.type,this.params.config.generate));return!o||o.length===0?[{id:`${this.params.keyName}_${x}_0`,name:`${this.serviceName} Failed to extract messages from response`,value:"Failed to extract messages from response",isError:!0,description:x,disabled:!0}]:o.map((a,i)=>({id:`${this.params.keyName}_${x}_${i}`,name:`${this.serviceName} ${a}`,value:`${a}`,isError:!1,description:x,disabled:!1}))}return t.find(o=>o.id===r.id)?[...t.map(o=>r.id===o.id?r:o)]:[{...r}]},[]),T(t=>t),R(this.handleError$))}async generateMessage(){try{await this.checkIsAvailableOllama();const t=await this.createChatCompletions();return L(this.sanitizeMessage(t,this.params.config.type,this.params.config.generate))}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 O({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.OLLAMA_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(){const r=`${xe(this.params.config.locale,this.params.config["max-length"],this.params.config.type,this.params.config.prompt)}
57
+ Please just generate ${this.params.config.generate} commit messages in numbered list format without explanation.`;return(await this.ollama.chat({model:this.model,messages:[{role:"system",content:r},{role:"user",content:this.params.stagedDiff.diff}],stream:!1})).message.content}}class Qi extends Y{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";if(r.message){n=r.message.split(`
58
+ `)[0];const s=this.extractJSONFromError(r.message);n+=`: ${s.error.message}`}return G({name:`${this.errorPrefix} ${n}`,value:n,isError:!0,disabled:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=g.red.bold("[ChatGPT]")}generateCommitMessage$(){return U(Gi(this.params.config.OPENAI_URL,this.params.config.OPENAI_PATH,this.params.config.OPENAI_KEY,this.params.config.OPENAI_MODEL,this.params.config.locale,this.params.stagedDiff.diff,this.params.config.generate,this.params.config["max-length"],this.params.config.type,this.params.config.timeout,this.params.config["max-tokens"],this.params.config.temperature,this.params.config.prompt,this.params.config.proxy)).pipe(T(t=>S(t)),P(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),R(this.handleError$))}extractJSONFromError(t){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,n=t.match(r);return n?Object.assign({},...n.map(s=>JSON.parse(s))):{error:{message:"Unknown error"}}}}class sn{constructor(t,r){this.config=t,this.stagedDiff=r}createAIRequests$(t){return S(t).pipe(bn(r=>{const n={config:this.config,stagedDiff:this.stagedDiff,keyName:r};switch(r){case H.OPEN_AI:return z.create(Qi,n).generateCommitMessage$();case H.GEMINI:return z.create(Wi,n).generateCommitMessage$();case H.ANTHROPIC:return z.create(Hi,n).generateCommitMessage$();case H.HUGGING:return z.create(Xi,n).generateCommitMessage$();case H.CLOVA_X:return z.create(Vi,n).generateCommitMessage$();case H.MISTRAL:return z.create(Ji,n).generateCommitMessage$();case H.OLLAMA:return z.create(Zi,n).generateCommitMessage$();default:const s=g.red.bold(`[${r}]`);return G({name:s+" Invalid AI type",value:"Invalid AI type",isError:!0,disabled:!0})}}))}}const un=async()=>{const{stdout:e,failed:t}=await re("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new y("The current directory must be a Git repository!");return e},St=e=>`:(exclude)${e}`,an=["package-lock.json","pnpm-lock.yaml","*.lock"].map(St),Dn=async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:r}=await re("git",[...t,"--name-only",...an,...e?e.map(St):[]]);if(!r)return null;const{stdout:n}=await re("git",[...t,...an,...e?e.map(St):[]]);return{files:r.split(`
59
+ `),diff:n}},ea=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class _e{constructor(){this.title="aicommit2"}printTitle(){console.log(jn.textSync(this.title,{font:"Small"}))}displaySpinner(t){return Ge(t).start()}stopSpinner(t){t.stop(),t.clear()}printStagedFiles(t){console.log(g.bold.green("\u2714 ")+g.bold(`${ea(t.files)}:`)),console.log(`${t.files.map(r=>` ${r}`).join(`
59
60
  `)}
60
61
  `)}printAnalyzed(){console.log(`
61
62
  ${g.bold.green("\u2714")} ${g.bold("Changes analyzed")}`)}printCommitted(){console.log(`
@@ -63,14 +64,14 @@ ${g.bold.green("\u2714")} ${g.bold("Successfully committed!")}`)}printCopied(){c
63
64
  ${g.bold.green("\u2714")} ${g.bold("Successfully copied! Press 'Ctrl + V' to paste")}`)}printSavedCommitMessage(){console.log(`
64
65
  ${g.bold.green("\u2714")} ${g.bold("Saved commit message")}`)}printCancelledCommit(){console.log(`
65
66
  ${g.bold.yellow("\u26A0")} ${g.yellow("Commit cancelled")}`)}printErrorMessage(t){console.log(`
66
- ${g.bold.red("\u2716")} ${g.red(`${t}`)}`)}moveCursorUp(){const t=me.createInterface({input:process.stdin,output:process.stdout});me.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=me.createInterface({input:process.stdin,output:process.stdout});me.moveCursor(process.stdout,0,1),t.close()}}const Wi={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},It="No commit messages were generated";class Vi{constructor(){this.choices$=new Rt([]),this.loader$=new Rt(Wi),this.destroyed$=new gn(1)}initPrompt(){return Ne.registerPrompt("reactiveListPrompt",_n),Ne.prompt({type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${It}`,choices$:this.choices$,loader$:this.loader$,loop:!1})}startLoader(){this.loader$.next({isLoading:!0})}refreshChoices(t){const{name:n,value:r,isError:o}=t;if(!t||!r)return;const u=this.choices$.getValue();this.choices$.next([...u,{name:n,value:r,disabled:o,isError:o}])}checkErrorOnChoices(){if(this.choices$.getValue().map(n=>n).every(n=>n?.isError||n?.disabled)){this.alertNoGeneratedMessage(),this.logEmptyCommitMessage(),process.exit(1);return}this.stopLoaderOnSuccess()}completeSubject(){this.choices$.complete(),this.loader$.complete(),this.destroyed$.next(!0),this.destroyed$.complete()}alertNoGeneratedMessage(){this.loader$.next({isLoading:!1,message:It,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:"Changes analyzed"})}logEmptyCommitMessage(){console.log(`${g.bold.yellow("\u26A0")} ${g.yellow(`${It}`)}`)}}const P=new Ie;var Xi=async(e,t,n,r,o,u,s,a,i)=>(async()=>{P.printTitle(),await en(),r&&await te("git",["add","--update"]);const l=P.displaySpinner("Detecting staged files"),f=await rn(n);if(l.stop(),!f)throw new y("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");P.printStagedFiles(f);const{env:D}=process,c=await xt({OPENAI_KEY:D.OPENAI_KEY||D.OPENAI_API_KEY,OPENAI_MODEL:D.OPENAI_MODEL||D["openai-model"]||D.openai_model,OPENAI_URL:D.OPENAI_URL||D["openai-url"]||D.OPENAI_URL,GEMINI_KEY:D.GEMINI_KEY||D.GEMINI_API_KEY,GEMINI_MODEL:D.GEMINI_MODEL||D["gemini-model"]||D.gemini_model,ANTHROPIC_KEY:D.ANTHROPIC_KEY||D.ANTHROPIC_API_KEY,ANTHROPIC_MODEL:D.ANTHROPIC_MODEL||D["anthropic-model"]||D.anthropic_model,HUGGING_COOKIE:D.HUGGING_COOKIE||D.HUGGING_API_KEY||D.HF_TOKEN,HUGGING_MODEL:D.HUGGING_MODEL||D["hugging-model"],CLOVAX_COOKIE:D.CLOVAX_COOKIE||D.CLOVA_X_COOKIE,proxy:D.https_proxy||D.HTTPS_PROXY||D.http_proxy||D.HTTP_PROXY,temperature:D.temperature,generate:t?.toString()||D.generate,type:o?.toString()||D.type,locale:e?.toString()||D.locale,prompt:a?.toString()||D.prompt}),p=Object.entries(c).filter(([b])=>Tr.includes(b)).filter(([b,Me])=>!!Me).map(([b])=>b);if(p.length===0)throw new y("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const m=new Qr(c,f),h=new Vi,C=h.initPrompt();h.startLoader();const w=m.createAIRequests$(p).subscribe(b=>h.refreshChoices(b),()=>{},()=>h.checkErrorOnChoices()),O=await C;w.unsubscribe(),h.completeSubject(),P.moveCursorUp();const S=O.aicommit2Prompt?.value;if(!S)throw new y("An error occurred! No selected message");if(s&&(tu("copy-paste").copy(S),P.printCopied(),process.exit()),u){const b=Le("Committing with the generated message").start();await te("git",["commit","-m",S,...i]),b.stop(),b.clear(),P.printCommitted(),process.exit()}const M=await Ne.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:oe}=M;if(oe){const b=Le("Committing with the generated message").start();await te("git",["commit","-m",S,...i]),b.stop(),b.clear(),P.printCommitted(),process.exit()}P.printCancelledCommit(),process.exit()})().catch(l=>{P.printErrorMessage(l.message),ve(l),process.exit(1)}),Ji=sr({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:n}=e._;if(t==="get"){const r=await xt({},!0);for(const o of n)Y(r,o)&&console.log(`${o}=${r[o]}`);return}if(t==="set"){await ki(n.map(r=>r.split("=")));return}throw new y(`Invalid mode: ${t}`)})().catch(t=>{new Ie().printErrorMessage(t.message),ve(t),process.exit(1)})});const nn="prepare-commit-msg",on=`.git/hooks/${nn}`,Se=Bn(new URL("cli.mjs",import.meta.url)),Zi=process.argv[1].replace(/\\/g,"/").endsWith(`/${on}`),un=process.platform==="win32",sn=`
67
+ ${g.bold.red("\u2716")} ${g.red(`${t}`)}`)}moveCursorUp(){const t=Ce.createInterface({input:process.stdin,output:process.stdout});Ce.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=Ce.createInterface({input:process.stdin,output:process.stdout});Ce.moveCursor(process.stdout,0,1),t.close()}}const ta={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},Pt="No commit messages were generated";class ra{constructor(){this.choices$=new Ut([]),this.loader$=new Ut(ta),this.destroyed$=new An(1)}initPrompt(){return je.registerPrompt("reactiveListPrompt",Gn),je.prompt({type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${Pt}`,choices$:this.choices$,loader$:this.loader$,loop:!1})}startLoader(){this.loader$.next({isLoading:!0})}refreshChoices(t){const{value:r,isError:n}=t;if(!t||!r)return;if(!t.id){this.choices$.next([...this.currentChoices,t].sort(ge));return}this.checkStreamChoice(t)}checkErrorOnChoices(){if(this.choices$.getValue().map(r=>r).every(r=>r?.isError||r?.disabled)){this.alertNoGeneratedMessage(),this.logEmptyCommitMessage(),process.exit(1);return}this.stopLoaderOnSuccess()}completeSubject(){this.choices$.complete(),this.loader$.complete(),this.destroyed$.next(!0),this.destroyed$.complete()}alertNoGeneratedMessage(){this.loader$.next({isLoading:!1,message:Pt,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:"Changes analyzed"})}logEmptyCommitMessage(){console.log(`${g.bold.yellow("\u26A0")} ${g.yellow(`${Pt}`)}`)}checkStreamChoice(t){if(t.description===x){const s=this.currentChoices.find(o=>{const u=o.id||"",a=/\d/.test(u);return t.id?.includes(u)&&!a});if(s){this.choices$.next([...this.currentChoices.filter(o=>o.id!==s.id),t].sort(ge));return}this.choices$.next([...this.currentChoices,t].sort(ge));return}if(this.currentChoices.find(s=>s?.id===t.id)){this.choices$.next(this.currentChoices.map(s=>s?.id===t.id?t:s).sort(ge));return}this.choices$.next([...this.currentChoices,t].sort(ge))}get currentChoices(){return this.choices$.getValue().map(t=>t)}}const k=new _e;var na=async(e,t,r,n,s,o,u,a,i)=>(async()=>{k.printTitle(),await un(),n&&await re("git",["add","--update"]);const l=k.displaySpinner("Detecting staged files"),f=await Dn(r);if(l.stop(),!f)throw new y("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");k.printStagedFiles(f);const{env:D}=process,c=await It({OPENAI_KEY:D.OPENAI_KEY||D.OPENAI_API_KEY,OPENAI_MODEL:D.OPENAI_MODEL||D["openai-model"]||D.openai_model,OPENAI_URL:D.OPENAI_URL||D["openai-url"]||D.OPENAI_URL,GEMINI_KEY:D.GEMINI_KEY||D.GEMINI_API_KEY,GEMINI_MODEL:D.GEMINI_MODEL||D["gemini-model"]||D.gemini_model,ANTHROPIC_KEY:D.ANTHROPIC_KEY||D.ANTHROPIC_API_KEY,ANTHROPIC_MODEL:D.ANTHROPIC_MODEL||D["anthropic-model"]||D.anthropic_model,HUGGING_COOKIE:D.HUGGING_COOKIE||D.HUGGING_API_KEY||D.HF_TOKEN,HUGGING_MODEL:D.HUGGING_MODEL||D["hugging-model"],CLOVAX_COOKIE:D.CLOVAX_COOKIE||D.CLOVA_X_COOKIE,proxy:D.https_proxy||D.HTTPS_PROXY||D.http_proxy||D.HTTP_PROXY,temperature:D.temperature,generate:t?.toString()||D.generate,type:s?.toString()||D.type,locale:e?.toString()||D.locale,prompt:a?.toString()||D.prompt}),p=Object.entries(c).filter(([b])=>kr.includes(b)).filter(([b,Te])=>!!Te).map(([b])=>b);if(p.length===0)throw new y("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const m=new sn(c,f),h=new ra,C=h.initPrompt();h.startLoader();const w=m.createAIRequests$(p).subscribe(b=>h.refreshChoices(b),()=>{},()=>h.checkErrorOnChoices()),I=await C;w.unsubscribe(),h.completeSubject(),k.moveCursorUp();const _=I.aicommit2Prompt?.value;if(!_)throw new y("An error occurred! No selected message");if(u&&(as("copy-paste").copy(_),k.printCopied(),process.exit()),o){const b=Ge("Committing with the generated message").start();await re("git",["commit","-m",_,...i]),b.stop(),b.clear(),k.printCommitted(),process.exit()}const N=await je.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:se}=N;if(se){const b=Ge("Committing with the generated message").start();await re("git",["commit","-m",_,...i]),b.stop(),b.clear(),k.printCommitted(),process.exit()}k.printCancelledCommit(),process.exit()})().catch(l=>{k.printErrorMessage(l.message),Oe(l),process.exit(1)}),oa=cr({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:r}=e._;if(t==="get"){const n=await It({},!0);for(const s of r)V(n,s)&&console.log(`${s}=${n[s]}`);return}if(t==="set"){await Yi(r.map(n=>n.split("=")));return}throw new y(`Invalid mode: ${t}`)})().catch(t=>{new _e().printErrorMessage(t.message),Oe(t),process.exit(1)})});const cn="prepare-commit-msg",ln=`.git/hooks/${cn}`,Ne=Mn(new URL("cli.mjs",import.meta.url)),sa=process.argv[1].replace(/\\/g,"/").endsWith(`/${ln}`),fn=process.platform==="win32",pn=`
67
68
  #!/usr/bin/env node
68
- import(${JSON.stringify($n(Se))})
69
- `.trim();var Qi=sr({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await en(),{installUninstall:n}=e._,r=V.join(t,on),o=await Jr(r);if(n==="install"){if(o){if(await $.realpath(r).catch(()=>{})===Se){console.warn("The hook is already installed");return}throw new y(`A different ${nn} hook seems to be installed. Please remove it before installing aicommit2.`)}await $.mkdir(V.dirname(r),{recursive:!0}),un?await $.writeFile(r,sn):(await $.symlink(Se,r,"file"),await $.chmod(r,493)),console.log(`${g.green("\u2714")} Hook installed`);return}if(n==="uninstall"){if(!o){console.warn("Hook is not installed");return}if(un){if(await $.readFile(r,"utf8")!==sn){console.warn("Hook is not installed");return}}else if(await $.realpath(r)!==Se){console.warn("Hook is not installed");return}await $.rm(r),console.log(`${g.green("\u2714")} Hook uninstalled`);return}throw new y(`Invalid mode: ${n}`)})().catch(t=>{console.error(`${g.red("\u2716")} ${t.message}`),ve(t),process.exit(1)})});const[St,ea]=process.argv.slice(2);var ta=()=>(async()=>{if(!St)throw new y('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(ea)return;const e=await rn();if(!e)return;const t=new Ie;t.printTitle();const{env:n}=process,r=await xt({proxy:n.https_proxy||n.HTTPS_PROXY||n.http_proxy||n.HTTP_PROXY}),o=Object.entries(r).filter(([p])=>Tr.includes(p)).filter(([p,d])=>!!d).map(([p])=>p);if(o.length===0)throw new y("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const s=new Qr(r,e),a=t.displaySpinner("The AI is analyzing your changes");let i;try{i=await Cn(s.createAIRequests$(o).pipe(Fn(p=>!p.isError),L(p=>p.value),En()))}finally{a.stop(),a.clear(),t.printAnalyzed()}const f=await $.readFile(St,"utf8")!=="",D=i.length>1;let c="";f&&(c=`# \u{1F916} AI generated commit${D?"s":""}
69
+ import(${JSON.stringify(_n(Ne))})
70
+ `.trim();var ua=cr({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await un(),{installUninstall:r}=e._,n=X.join(t,ln),s=await nn(n);if(r==="install"){if(s){if(await B.realpath(n).catch(()=>{})===Ne){console.warn("The hook is already installed");return}throw new y(`A different ${cn} hook seems to be installed. Please remove it before installing aicommit2.`)}await B.mkdir(X.dirname(n),{recursive:!0}),fn?await B.writeFile(n,pn):(await B.symlink(Ne,n,"file"),await B.chmod(n,493)),console.log(`${g.green("\u2714")} Hook installed`);return}if(r==="uninstall"){if(!s){console.warn("Hook is not installed");return}if(fn){if(await B.readFile(n,"utf8")!==pn){console.warn("Hook is not installed");return}}else if(await B.realpath(n)!==Ne){console.warn("Hook is not installed");return}await B.rm(n),console.log(`${g.green("\u2714")} Hook uninstalled`);return}throw new y(`Invalid mode: ${r}`)})().catch(t=>{console.error(`${g.red("\u2716")} ${t.message}`),Oe(t),process.exit(1)})});const[Mt,ia]=process.argv.slice(2);var aa=()=>(async()=>{if(!Mt)throw new y('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(ia)return;const e=await Dn();if(!e)return;const t=new _e;t.printTitle();const{env:r}=process,n=await It({proxy:r.https_proxy||r.HTTPS_PROXY||r.http_proxy||r.HTTP_PROXY}),s=Object.entries(n).filter(([p])=>kr.includes(p)).filter(([p,d])=>!!d).map(([p])=>p);if(s.length===0)throw new y("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const u=new sn(n,e),a=t.displaySpinner("The AI is analyzing your changes");let i;try{i=await vn(u.createAIRequests$(s).pipe($n(p=>!p.isError),P(p=>p.value),Bn()))}finally{a.stop(),a.clear(),t.printAnalyzed()}const f=await B.readFile(Mt,"utf8")!=="",D=i.length>1;let c="";f&&(c=`# \u{1F916} AI generated commit${D?"s":""}
70
71
  `),D?(f&&(c+=`# Select one of the following messages by uncommenting:
71
72
  `),c+=`
72
73
  ${i.map(p=>`# ${p}`).join(`
73
74
  `)}`):(f&&(c+=`# Edit the message below and commit:
74
75
  `),c+=`
75
76
  ${i[0]}
76
- `),await $.appendFile(St,c),t.printSavedCommitMessage()})().catch(e=>{new Ie().printErrorMessage(e.message),ve(e),process.exit(1)});const an=process.argv.slice(2);eu({name:"aicommit2",version:Nr,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",default:"conventional"},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:"Additional prompt to let users fine-tune provided prompt",alias:"p"}},commands:[Ji,Qi],help:{description:ri},ignoreArgv:e=>e==="unknown-flag"||e==="argument"},e=>{if(Zi){ta();return}Xi(e.flags.locale,e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,e.flags.confirm,e.flags.clipboard,e.flags.prompt,an)},an);
77
+ `),await B.appendFile(Mt,c),t.printSavedCommitMessage()})().catch(e=>{new _e().printErrorMessage(e.message),Oe(e),process.exit(1)});const dn=process.argv.slice(2);is({name:"aicommit2",version:jr,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",default:"conventional"},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:"Additional prompt to let users fine-tune provided prompt",alias:"p"}},commands:[oa,ua],help:{description:Di},ignoreArgv:e=>e==="unknown-flag"||e==="argument"},e=>{if(sa){aa();return}na(e.flags.locale,e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,e.flags.confirm,e.flags.clipboard,e.flags.prompt,dn)},dn);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicommit2",
3
- "version": "1.7.5",
3
+ "version": "1.8.0",
4
4
  "description": "A Reactive CLI that generates git commit messages with various AI",
5
5
  "keywords": [
6
6
  "cli",
@@ -34,11 +34,11 @@
34
34
  "aic2": "./dist/cli.mjs"
35
35
  },
36
36
  "dependencies": {
37
- "@anthropic-ai/sdk": "^0.14.1",
37
+ "@anthropic-ai/sdk": "^0.20.4",
38
38
  "@dqbd/tiktoken": "^1.0.2",
39
39
  "@google/generative-ai": "^0.2.1",
40
40
  "@inquirer/prompts": "^3.0.0",
41
- "axios": "^1.4.0",
41
+ "axios": "^1.6.8",
42
42
  "chalk": "^5.3.0",
43
43
  "copy-paste": "^1.5.3",
44
44
  "figlet": "^1.7.0",