@staff0rd/assist 0.739.0 → 0.741.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.
package/README.md CHANGED
@@ -65,7 +65,7 @@ After installation, the `assist` command will be available globally. You can als
65
65
  - `/rename [title]` - Retitle this session's dashboard card via `assist sessions rename`; uses the argument verbatim, or infers a short title from the conversation when given none
66
66
  - `/restructure` - Analyze and restructure tightly-coupled files
67
67
  - `/review-config` - Set this repo's high-level review checklist keys: propose `review.highLevel.criticalPaths` and `uiPaths` from the repo's own tree with the files each glob matches, put them to the user to accept or edit, then write the accepted answers with `assist review --high-level --configure --answer ...` to the project `assist.yml` or this repo's block in `~/.assist.yml`
68
- - `/review-ci` - Install a PR review workflow that has no dependency on assist: copy the bundled `init.mjs` and `check.mjs` to `.github/review-ci/` and the workflow to `.github/workflows/review-ci.yml` (showing a diff and asking before overwriting either), then have the user run `node .github/review-ci/init.mjs` in their terminal. `init.mjs` prompts for the provider (`litellm`), base URL, Claude model, Codex model and API key, checks both models can be reached, then sets the repo variables `ASSIST_REVIEW_PROVIDER`, `ASSIST_REVIEW_BASE_URL`, `ASSIST_REVIEW_CLAUDE_MODEL`, `ASSIST_REVIEW_CODEX_MODEL` and the repo secret `ASSIST_REVIEW_API_KEY` with `gh`. The workflow runs on `pull_request: opened`, installs only Node, Claude Code and Codex, and its first step `check.mjs` fails naming each unset variable or secret, or the model, endpoint and error for a model it cannot reach. The skill ships as a directory that `assist sync` copies whole to `~/.claude/skills/review-ci/`
68
+ - `/review-ci` - Install a PR review workflow that has no dependency on assist: copy the bundled `init.mjs`, `check.mjs` and `review.mjs` to `.github/review-ci/` and the workflow to `.github/workflows/review-ci.yml` (showing a diff and asking before overwriting either), then have the user run `node .github/review-ci/init.mjs` in their terminal. `init.mjs` prompts for the provider (`litellm` or `foundry`), base URL (for `litellm` the proxy root, from which Claude uses the root and Codex `<url>/v1`; for `foundry` the Azure AI Foundry resource root `https://<resource>.services.ai.azure.com`, from which Claude Code runs in Foundry mode against `<url>/anthropic` and Codex uses `<url>/openai/v1`, with deployment names as the models), Claude model, Codex model and API key, checks both models can be reached, then sets the repo variables `ASSIST_REVIEW_PROVIDER`, `ASSIST_REVIEW_BASE_URL`, `ASSIST_REVIEW_CLAUDE_MODEL`, `ASSIST_REVIEW_CODEX_MODEL` and the repo secret `ASSIST_REVIEW_API_KEY` with `gh`. The workflow runs on `pull_request: opened`, installs only Node, Claude Code and Codex, and its first step `check.mjs` fails naming each unset variable or secret, or the model, endpoint and error for a model it cannot reach. Its next step `review.mjs` is the `assist review` pipeline bundled with its CI path: the PR comes from the workflow event rather than the checked-out branch, both reviewers and the synthesis run against the provider's models, line-bound findings post and a `COMMENT` review is submitted with `GITHUB_TOKEN`, and a failed reviewer or synthesis fails the job with nothing posted. The skill ships as a directory that `assist sync` copies whole to `~/.claude/skills/review-ci/`
69
69
  - `/review-high-level [number]` - Open the high-level review checklist for the current branch's PR, or PR `<number>`, via `assist review --high-level`, then report the verdict, the saved review path and any item comments
70
70
  - `/review-pr-comments` - Process PR review comments one by one
71
71
  - `/jira [action] [KEY] [args]` - Jira actions: `view`, `associate`, `update`, `started`, `done`, `help`. `[KEY]` is optional — it resolves from the session's backlog item
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: review-ci
3
- description: Install a GitHub workflow that reviews new PRs with Claude and Codex through LiteLLM, without depending on assist
3
+ description: Install a GitHub workflow that reviews new PRs with Claude and Codex through LiteLLM or Azure AI Foundry, without depending on assist
4
4
  ---
5
5
 
6
6
  Install the review-ci workflow into the current repo. This skill's directory (`~/.claude/skills/review-ci/`) holds the bundled scripts in `scripts/` and the workflow template `review-ci.yml`. The installed workflow and scripts must never install or invoke assist.
@@ -17,6 +17,7 @@ Copy each source to its target, relative to the repo root:
17
17
  | ---------------------------------- | --------------------------------- |
18
18
  | `scripts/init.mjs` | `.github/review-ci/init.mjs` |
19
19
  | `scripts/check.mjs` | `.github/review-ci/check.mjs` |
20
+ | `scripts/review.mjs` | `.github/review-ci/review.mjs` |
20
21
  | `review-ci.yml` | `.github/workflows/review-ci.yml` |
21
22
 
22
23
  For each pair:
@@ -31,15 +32,17 @@ Never overwrite a differing target without the user's confirmation.
31
32
 
32
33
  `init.mjs` asks for the provider, base URL, Claude model, Codex model and API key, checks both models can be reached, then sets the repo variables `ASSIST_REVIEW_PROVIDER`, `ASSIST_REVIEW_BASE_URL`, `ASSIST_REVIEW_CLAUDE_MODEL`, `ASSIST_REVIEW_CODEX_MODEL` and the secret `ASSIST_REVIEW_API_KEY` with `gh`. It needs a terminal for its prompts, and the API key must never pass through this conversation.
33
34
 
34
- 1. Ask the user for the base URL (e.g. `https://litellm.example.com`), the Claude model and the Codex model, as the provider's model names. The provider is `litellm`. Do not ask for the API key.
35
+ 1. Ask the user for the provider (`litellm` or `foundry`), the base URL, the Claude model and the Codex model, as the provider's model names. Do not ask for the API key. The base URL is:
36
+ - `litellm`: the proxy root (e.g. `https://litellm.example.com`); Claude uses it directly and Codex uses `<url>/v1`.
37
+ - `foundry`: the Azure AI Foundry resource root, `https://<resource>.services.ai.azure.com`, with no path; Claude uses `<url>/anthropic` and Codex uses `<url>/openai/v1`. The models are the resource's deployment names, and the API key is the resource's key.
35
38
  2. Tell the user to run this in their own terminal from the repo root, where it prompts for the API key with masked input:
36
39
 
37
40
  ```
38
- node .github/review-ci/init.mjs --provider litellm --base-url <url> --claude-model <model> --codex-model <model>
41
+ node .github/review-ci/init.mjs --provider <provider> --base-url <url> --claude-model <model> --codex-model <model>
39
42
  ```
40
43
 
41
44
  3. Once they report it finished, confirm with `gh variable list` and `gh secret list` that the four variables and the secret are set. If init reported an unreachable model, relay its error and let the user re-run it.
42
45
 
43
46
  ## 4. Report
44
47
 
45
- List the files written or skipped, and remind the user to commit `.github/review-ci/` and `.github/workflows/review-ci.yml`. The workflow runs on `pull_request: opened` and fails at its check step, naming the problem, when a variable or the secret is unset or a model cannot be reached.
48
+ List the files written or skipped, and remind the user to commit `.github/review-ci/` and `.github/workflows/review-ci.yml`. The workflow runs on `pull_request: opened` and fails at its check step, naming the problem, when a variable or the secret is unset or a model cannot be reached. Its review step then posts the findings as a `COMMENT` review on the PR.
@@ -35,3 +35,6 @@ jobs:
35
35
 
36
36
  - name: Check review config
37
37
  run: node .github/review-ci/check.mjs
38
+
39
+ - name: Review PR
40
+ run: node .github/review-ci/review.mjs
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
2
- var S=["ASSIST_REVIEW_PROVIDER","ASSIST_REVIEW_BASE_URL","ASSIST_REVIEW_CLAUDE_MODEL","ASSIST_REVIEW_CODEX_MODEL"],n="ASSIST_REVIEW_API_KEY",p=[...S,n],d=["litellm"];function E(i,e){if(i==="litellm")return{anthropic:e,responses:`${e}/v1`};throw new Error(`Unsupported ASSIST_REVIEW_PROVIDER "${i}" (expected one of: ${d.join(", ")})`)}async function s(i,e,t){try{let r=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...e},body:JSON.stringify(t),signal:AbortSignal.timeout(6e4)});if(r.ok)return;let o=(await r.text()).trim().slice(0,300);return`HTTP ${r.status}${o?`: ${o}`:""}`}catch(r){if(!(r instanceof Error))return String(r);let o=r.cause instanceof Error?r.cause.message:"";return o?`${r.message} (${o})`:r.message}}async function l(i,e){let t={Authorization:`Bearer ${i.apiKey}`},r=`${e.anthropic}/v1/messages`,o=`${e.responses}/responses`,[c,a]=await Promise.all([s(r,{...t,"x-api-key":i.apiKey,"anthropic-version":"2023-06-01"},{model:i.claudeModel,max_tokens:1,messages:[{role:"user",content:"ping"}]}),s(o,t,{model:i.codexModel,input:"ping",max_output_tokens:16})]);return[...c?[`Claude model "${i.claudeModel}" at ${r}: ${c}`]:[],...a?[`Codex model "${i.codexModel}" at ${o}: ${a}`]:[]]}function m(i){let e=r=>i[r]?.trim()??"",t=p.filter(r=>!e(r));return t.length>0?{config:null,missing:t}:{config:{provider:e("ASSIST_REVIEW_PROVIDER"),baseUrl:e("ASSIST_REVIEW_BASE_URL").replace(/\/+$/,""),claudeModel:e("ASSIST_REVIEW_CLAUDE_MODEL"),codexModel:e("ASSIST_REVIEW_CODEX_MODEL"),apiKey:e(n)},missing:t}}async function v(i){let{config:e,missing:t}=m(i);if(!e)return t.map(o=>`${o} is not set`);let r;try{r=E(e.provider,e.baseUrl)}catch(o){return[o instanceof Error?o.message:String(o)]}return l(e,r)}async function u(){let i=await v(process.env);if(i.length>0){for(let e of i)console.error(`review-ci: ${e}`);process.exit(1)}console.log("review-ci: config is set and both models are reachable")}await u();export{u as reviewCiCheck};
2
+ var v=["ASSIST_REVIEW_PROVIDER","ASSIST_REVIEW_BASE_URL","ASSIST_REVIEW_CLAUDE_MODEL","ASSIST_REVIEW_CODEX_MODEL"],n="ASSIST_REVIEW_API_KEY",p=[...v,n],d=["litellm","foundry"];function E(i,e){if(i==="litellm")return{anthropic:e,responses:`${e}/v1`,anthropicKind:"gateway"};if(i==="foundry")return{anthropic:`${e}/anthropic`,responses:`${e}/openai/v1`,anthropicKind:"foundry"};throw new Error(`Unsupported ASSIST_REVIEW_PROVIDER "${i}" (expected one of: ${d.join(", ")})`)}async function s(i,e,t){try{let r=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...e},body:JSON.stringify(t),signal:AbortSignal.timeout(6e4)});if(r.ok)return;let o=(await r.text()).trim().slice(0,300);return`HTTP ${r.status}${o?`: ${o}`:""}`}catch(r){if(!(r instanceof Error))return String(r);let o=r.cause instanceof Error?r.cause.message:"";return o?`${r.message} (${o})`:r.message}}async function l(i,e){let t={Authorization:`Bearer ${i.apiKey}`},r=`${e.anthropic}/v1/messages`,o=`${e.responses}/responses`,[a,c]=await Promise.all([s(r,{...e.anthropicKind==="gateway"?t:{},"x-api-key":i.apiKey,"anthropic-version":"2023-06-01"},{model:i.claudeModel,max_tokens:1,messages:[{role:"user",content:"ping"}]}),s(o,t,{model:i.codexModel,input:"ping",max_output_tokens:16})]);return[...a?[`Claude model "${i.claudeModel}" at ${r}: ${a}`]:[],...c?[`Codex model "${i.codexModel}" at ${o}: ${c}`]:[]]}function m(i){let e=r=>i[r]?.trim()??"",t=p.filter(r=>!e(r));return t.length>0?{config:null,missing:t}:{config:{provider:e("ASSIST_REVIEW_PROVIDER"),baseUrl:e("ASSIST_REVIEW_BASE_URL").replace(/\/+$/,""),claudeModel:e("ASSIST_REVIEW_CLAUDE_MODEL"),codexModel:e("ASSIST_REVIEW_CODEX_MODEL"),apiKey:e(n)},missing:t}}async function u(i){let{config:e,missing:t}=m(i);if(!e)return t.map(o=>`${o} is not set`);let r;try{r=E(e.provider,e.baseUrl)}catch(o){return[o instanceof Error?o.message:String(o)]}return l(e,r)}async function S(){let i=await u(process.env);if(i.length>0){for(let e of i)console.error(`review-ci: ${e}`);process.exit(1)}console.log("review-ci: config is set and both models are reachable")}await S();export{S as reviewCiCheck};
@@ -2,7 +2,7 @@ import { createRequire } from "node:module"; const require = createRequire(impor
2
2
  var rs=Object.create;var it=Object.defineProperty;var ns=Object.getOwnPropertyDescriptor;var ls=Object.getOwnPropertyNames;var as=Object.getPrototypeOf,os=Object.prototype.hasOwnProperty;var J=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var d=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var hs=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ls(e))!os.call(s,r)&&r!==t&&it(s,r,{get:()=>e[r],enumerable:!(i=ns(e,r))||i.enumerable});return s};var us=(s,e,t)=>(t=s!=null?rs(as(s)):{},hs(e||!s||!s.__esModule?it(t,"default",{value:s,enumerable:!0}):t,s));var ut=d((Gr,H)=>{"use strict";var cs=typeof process<"u"&&process.env.TERM_PROGRAM==="Hyper",ds=typeof process<"u"&&process.platform==="win32",at=typeof process<"u"&&process.platform==="linux",ue={ballotDisabled:"\u2612",ballotOff:"\u2610",ballotOn:"\u2611",bullet:"\u2022",bulletWhite:"\u25E6",fullBlock:"\u2588",heart:"\u2764",identicalTo:"\u2261",line:"\u2500",mark:"\u203B",middot:"\xB7",minus:"\uFF0D",multiplication:"\xD7",obelus:"\xF7",pencilDownRight:"\u270E",pencilRight:"\u270F",pencilUpRight:"\u2710",percent:"%",pilcrow2:"\u2761",pilcrow:"\xB6",plusMinus:"\xB1",question:"?",section:"\xA7",starsOff:"\u2606",starsOn:"\u2605",upDownArrow:"\u2195"},ot=Object.assign({},ue,{check:"\u221A",cross:"\xD7",ellipsisLarge:"...",ellipsis:"...",info:"i",questionSmall:"?",pointer:">",pointerSmall:"\xBB",radioOff:"( )",radioOn:"(*)",warning:"\u203C"}),ht=Object.assign({},ue,{ballotCross:"\u2718",check:"\u2714",cross:"\u2716",ellipsisLarge:"\u22EF",ellipsis:"\u2026",info:"\u2139",questionFull:"\uFF1F",questionSmall:"\uFE56",pointer:at?"\u25B8":"\u276F",pointerSmall:at?"\u2023":"\u203A",radioOff:"\u25EF",radioOn:"\u25C9",warning:"\u26A0"});H.exports=ds&&!cs?ot:ht;Reflect.defineProperty(H.exports,"common",{enumerable:!1,value:ue});Reflect.defineProperty(H.exports,"windows",{enumerable:!1,value:ot});Reflect.defineProperty(H.exports,"other",{enumerable:!1,value:ht})});var ee=d((Zr,ce)=>{"use strict";var ps=s=>s!==null&&typeof s=="object"&&!Array.isArray(s),fs=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,ms=()=>typeof process<"u"?process.env.FORCE_COLOR!=="0":!1,ct=()=>{let s={enabled:ms(),visible:!0,styles:{},keys:{}},e=n=>{let l=n.open=`\x1B[${n.codes[0]}m`,a=n.close=`\x1B[${n.codes[1]}m`,o=n.regex=new RegExp(`\\u001b\\[${n.codes[1]}m`,"g");return n.wrap=(h,c)=>{h.includes(a)&&(h=h.replace(o,a+l));let u=l+h+a;return c?u.replace(/\r*\n/g,`${a}$&${l}`):u},n},t=(n,l,a)=>typeof n=="function"?n(l):n.wrap(l,a),i=(n,l)=>{if(n===""||n==null)return"";if(s.enabled===!1)return n;if(s.visible===!1)return"";let a=""+n,o=a.includes(`
3
3
  `),h=l.length;for(h>0&&l.includes("unstyle")&&(l=[...new Set(["unstyle",...l])].reverse());h-- >0;)a=t(s.styles[l[h]],a,o);return a},r=(n,l,a)=>{s.styles[n]=e({name:n,codes:l}),(s.keys[a]||(s.keys[a]=[])).push(n),Reflect.defineProperty(s,n,{configurable:!0,enumerable:!0,set(h){s.alias(n,h)},get(){let h=c=>i(c,h.stack);return Reflect.setPrototypeOf(h,s),h.stack=this.stack?this.stack.concat(n):[n],h}})};return r("reset",[0,0],"modifier"),r("bold",[1,22],"modifier"),r("dim",[2,22],"modifier"),r("italic",[3,23],"modifier"),r("underline",[4,24],"modifier"),r("inverse",[7,27],"modifier"),r("hidden",[8,28],"modifier"),r("strikethrough",[9,29],"modifier"),r("black",[30,39],"color"),r("red",[31,39],"color"),r("green",[32,39],"color"),r("yellow",[33,39],"color"),r("blue",[34,39],"color"),r("magenta",[35,39],"color"),r("cyan",[36,39],"color"),r("white",[37,39],"color"),r("gray",[90,39],"color"),r("grey",[90,39],"color"),r("bgBlack",[40,49],"bg"),r("bgRed",[41,49],"bg"),r("bgGreen",[42,49],"bg"),r("bgYellow",[43,49],"bg"),r("bgBlue",[44,49],"bg"),r("bgMagenta",[45,49],"bg"),r("bgCyan",[46,49],"bg"),r("bgWhite",[47,49],"bg"),r("blackBright",[90,39],"bright"),r("redBright",[91,39],"bright"),r("greenBright",[92,39],"bright"),r("yellowBright",[93,39],"bright"),r("blueBright",[94,39],"bright"),r("magentaBright",[95,39],"bright"),r("cyanBright",[96,39],"bright"),r("whiteBright",[97,39],"bright"),r("bgBlackBright",[100,49],"bgBright"),r("bgRedBright",[101,49],"bgBright"),r("bgGreenBright",[102,49],"bgBright"),r("bgYellowBright",[103,49],"bgBright"),r("bgBlueBright",[104,49],"bgBright"),r("bgMagentaBright",[105,49],"bgBright"),r("bgCyanBright",[106,49],"bgBright"),r("bgWhiteBright",[107,49],"bgBright"),s.ansiRegex=fs,s.hasColor=s.hasAnsi=n=>(s.ansiRegex.lastIndex=0,typeof n=="string"&&n!==""&&s.ansiRegex.test(n)),s.alias=(n,l)=>{let a=typeof l=="string"?s[l]:l;if(typeof a!="function")throw new TypeError("Expected alias to be the name of an existing color (string) or a function");a.stack||(Reflect.defineProperty(a,"name",{value:n}),s.styles[n]=a,a.stack=[n]),Reflect.defineProperty(s,n,{configurable:!0,enumerable:!0,set(o){s.alias(n,o)},get(){let o=h=>i(h,o.stack);return Reflect.setPrototypeOf(o,s),o.stack=this.stack?this.stack.concat(a.stack):a.stack,o}})},s.theme=n=>{if(!ps(n))throw new TypeError("Expected theme to be an object");for(let l of Object.keys(n))s.alias(l,n[l]);return s},s.alias("unstyle",n=>typeof n=="string"&&n!==""?(s.ansiRegex.lastIndex=0,n.replace(s.ansiRegex,"")):""),s.alias("noop",n=>n),s.none=s.clear=s.noop,s.stripColor=s.unstyle,s.symbols=ut(),s.define=r,s};ce.exports=ct();ce.exports.create=ct});var k=d(g=>{"use strict";var gs=Object.prototype.toString,P=ee(),dt=!1,G=new Set,pt={yellow:"blue",cyan:"red",green:"magenta",black:"white",blue:"yellow",red:"cyan",magenta:"green",white:"black"};g.longest=(s,e)=>s.reduce((t,i)=>Math.max(t,e?i[e].length:i.length),0);g.hasColor=s=>!!s&&P.hasColor(s);var te=g.isObject=s=>s!==null&&typeof s=="object"&&!Array.isArray(s);g.nativeType=s=>gs.call(s).slice(8,-1).toLowerCase().replace(/\s/g,"");g.isAsyncFn=s=>g.nativeType(s)==="asyncfunction";g.isPrimitive=s=>s!=null&&typeof s!="object"&&typeof s!="function";g.resolve=(s,e,...t)=>typeof e=="function"?e.call(s,...t):e;g.scrollDown=(s=[])=>[...s.slice(1),s[0]];g.scrollUp=(s=[])=>[s.pop(),...s];g.reorder=(s=[])=>{let e=s.slice();return e.sort((t,i)=>t.index>i.index?1:t.index<i.index?-1:0),e};g.swap=(s,e,t)=>{let i=s.length,r=t===i?0:t<0?i-1:t,n=s[e];s[e]=s[r],s[r]=n};g.width=(s,e=80)=>{let t=s&&s.columns?s.columns:e;return s&&typeof s.getWindowSize=="function"&&(t=s.getWindowSize()[0]),process.platform==="win32"?t-1:t};g.height=(s,e=20)=>{let t=s&&s.rows?s.rows:e;return s&&typeof s.getWindowSize=="function"&&(t=s.getWindowSize()[1]),t};g.wordWrap=(s,e={})=>{if(!s)return s;typeof e=="number"&&(e={width:e});let{indent:t="",newline:i=`
4
4
  `+t,width:r=80}=e,n=(i+t).match(/[^\S\n]/g)||[];r-=n.length;let l=`.{1,${r}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,a=s.trim(),o=new RegExp(l,"g"),h=a.match(o)||[];return h=h.map(c=>c.replace(/\n$/,"")),e.padEnd&&(h=h.map(c=>c.padEnd(r," "))),e.padStart&&(h=h.map(c=>c.padStart(r," "))),t+h.join(i)};g.unmute=s=>{let e=s.stack.find(i=>P.keys.color.includes(i));return e?P[e]:s.stack.find(i=>i.slice(2)==="bg")?P[e.slice(2)]:i=>i};g.pascal=s=>s?s[0].toUpperCase()+s.slice(1):"";g.inverse=s=>{if(!s||!s.stack)return s;let e=s.stack.find(i=>P.keys.color.includes(i));if(e){let i=P["bg"+g.pascal(e)];return i?i.black:s}let t=s.stack.find(i=>i.slice(0,2)==="bg");return t?P[t.slice(2).toLowerCase()]||s:P.none};g.complement=s=>{if(!s||!s.stack)return s;let e=s.stack.find(i=>P.keys.color.includes(i)),t=s.stack.find(i=>i.slice(0,2)==="bg");if(e&&!t)return P[pt[e]||e];if(t){let i=t.slice(2).toLowerCase(),r=pt[i];return r&&P["bg"+g.pascal(r)]||s}return P.none};g.meridiem=s=>{let e=s.getHours(),t=s.getMinutes(),i=e>=12?"pm":"am";e=e%12;let r=e===0?12:e,n=t<10?"0"+t:t;return r+":"+n+" "+i};g.set=(s={},e="",t)=>e.split(".").reduce((i,r,n,l)=>{let a=l.length-1>n?i[r]||{}:t;return!g.isObject(a)&&n<l.length-1&&(a={}),i[r]=a},s);g.get=(s={},e="",t)=>{let i=s[e]==null?e.split(".").reduce((r,n)=>r&&r[n],s):s[e];return i??t};g.mixin=(s,e)=>{if(!te(s))return e;if(!te(e))return s;for(let t of Object.keys(e)){let i=Object.getOwnPropertyDescriptor(e,t);if(hasOwnProperty.call(i,"value"))if(hasOwnProperty.call(s,t)&&te(i.value)){let r=Object.getOwnPropertyDescriptor(s,t);te(r.value)&&r.value!==i.value?s[t]=g.merge({},s[t],e[t]):Reflect.defineProperty(s,t,i)}else Reflect.defineProperty(s,t,i);else Reflect.defineProperty(s,t,i)}return s};g.merge=(...s)=>{let e={};for(let t of s)g.mixin(e,t);return e};g.mixinEmitter=(s,e)=>{let t=e.constructor.prototype;for(let i of Object.keys(t)){let r=t[i];typeof r=="function"?g.define(s,i,r.bind(e)):g.define(s,i,r)}};var ie=(s,e)=>{dt||(dt=!0,G.forEach(t=>t()),s===!0&&process.exit(128+e))},ft=ie.bind(null,!0,15),mt=ie.bind(null,!0,2);g.onExit=s=>(G.size===0&&(process.once("SIGTERM",ft),process.once("SIGINT",mt),process.once("exit",ie)),G.add(s),()=>{G.delete(s),G.size===0&&(process.off("SIGTERM",ft),process.off("SIGINT",mt),process.off("exit",ie))});g.define=(s,e,t)=>{Reflect.defineProperty(s,e,{value:t})};g.defineExport=(s,e,t)=>{let i;Reflect.defineProperty(s,e,{enumerable:!0,configurable:!0,set(r){i=r},get(){return i?i():t()}})}});var yt=d((Jr,gt)=>{"use strict";gt.exports=({onlyFirst:s=!1}={})=>{let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,s?void 0:"g")}});var D=d((Xr,wt)=>{"use strict";var ys=yt();wt.exports=s=>typeof s=="string"?s.replace(ys(),""):s});var bt=d(W=>{"use strict";W.ctrl={a:"first",b:"backward",c:"cancel",d:"deleteForward",e:"last",f:"forward",g:"reset",i:"tab",k:"cutForward",l:"reset",n:"newItem",m:"cancel",j:"submit",p:"search",r:"remove",s:"save",u:"undo",w:"cutLeft",x:"toggleCursor",v:"paste"};W.shift={up:"shiftUp",down:"shiftDown",left:"shiftLeft",right:"shiftRight",tab:"prev"};W.fn={up:"pageUp",down:"pageDown",left:"pageLeft",right:"pageRight",delete:"deleteForward"};W.option={b:"backward",f:"forward",d:"cutRight",left:"cutLeft",up:"altUp",down:"altDown"};W.keys={pageup:"pageUp",pagedown:"pageDown",home:"home",end:"end",cancel:"cancel",delete:"deleteForward",backspace:"delete",down:"down",enter:"submit",escape:"cancel",left:"left",space:"space",number:"number",return:"submit",right:"right",tab:"next",up:"up"}});var xt=d((tn,vt)=>{"use strict";vt.exports=class{_queue=[];_executing=!1;_jobRunner=null;constructor(e){this._jobRunner=e}enqueue=(...e)=>{this._queue.push(e),this._dequeue()};destroy(){this._queue.length=0,this._jobRunner=null}_dequeue(){this._executing||!this._queue.length||(this._executing=!0,this._jobRunner(...this._queue.shift()),setTimeout(()=>{this._executing=!1,this._dequeue()}))}}});var de=d((sn,Et)=>{"use strict";var Ct=J("readline"),ws=bt(),bs=xt(),vs=/^(?:\x1b)([a-zA-Z0-9])$/,xs=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,Cs={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"};function Es(s){return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(s)}function Ss(s){return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(s)}var se=(s="",e={})=>{let t,i={name:e.name,ctrl:!1,meta:!1,shift:!1,option:!1,sequence:s,raw:s,...e};if(Buffer.isBuffer(s)?s[0]>127&&s[1]===void 0?(s[0]-=128,s="\x1B"+String(s)):s=String(s):s!==void 0&&typeof s!="string"?s=String(s):s||(s=i.sequence||""),i.sequence=i.sequence||s||i.name,s==="\r")i.raw=void 0,i.name="return";else if(s===`
5
- `)i.name="enter";else if(s===" ")i.name="tab";else if(s==="\b"||s==="\x7F"||s==="\x1B\x7F"||s==="\x1B\b")i.name="backspace",i.meta=s.charAt(0)==="\x1B";else if(s==="\x1B"||s==="\x1B\x1B")i.name="escape",i.meta=s.length===2;else if(s===" "||s==="\x1B ")i.name="space",i.meta=s.length===2;else if(s<="")i.name=String.fromCharCode(s.charCodeAt(0)+97-1),i.ctrl=!0;else if(s.length===1&&s>="0"&&s<="9")i.name="number";else if(s.length===1&&s>="a"&&s<="z")i.name=s;else if(s.length===1&&s>="A"&&s<="Z")i.name=s.toLowerCase(),i.shift=!0;else if(t=vs.exec(s))i.meta=!0,i.shift=/^[A-Z]$/.test(t[1]);else if(t=xs.exec(s)){let r=[...s];r[0]==="\x1B"&&r[1]==="\x1B"&&(i.option=!0);let n=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),l=(t[3]||t[5]||1)-1;i.ctrl=!!(l&4),i.meta=!!(l&10),i.shift=!!(l&1),i.code=n,i.name=Cs[n],i.shift=Es(n)||i.shift,i.ctrl=Ss(n)||i.ctrl}return i};se.listen=(s={},e)=>{let{stdin:t}=s;if(!t||t!==process.stdin&&!t.isTTY)throw new Error("Invalid stream passed");let i=Ct.createInterface({terminal:!0,input:t});Ct.emitKeypressEvents(t,i);let r=new bs((a,o)=>e(a,se(a,o),i)),n=t.isRaw;return t.isTTY&&t.setRawMode(!0),t.on("keypress",r.enqueue),i.resume(),()=>{t.isTTY&&t.setRawMode(n),t.removeListener("keypress",r.enqueue),r.destroy(),i.pause(),i.close()}};se.action=(s,e,t)=>{let i={...ws,...t};return e.ctrl?(e.action=i.ctrl[e.name],e):e.option&&i.option?(e.action=i.option[e.name],e):e.shift?(e.action=i.shift[e.name],e):(e.action=i.keys[e.name],e)};Et.exports=se});var Rt=d((rn,St)=>{"use strict";St.exports=s=>{s.timers=s.timers||{};let e=s.options.timers;if(e)for(let t of Object.keys(e)){let i=e[t];typeof i=="number"&&(i={interval:i}),Rs(s,t,i)}};function Rs(s,e,t={}){let i=s.timers[e]={name:e,start:Date.now(),ms:0,tick:0},r=t.interval||120;i.frames=t.frames||[],i.loading=!0;let n=setInterval(()=>{i.ms=Date.now()-i.start,i.tick++,s.render()},r);return i.stop=()=>{i.loading=!1,clearInterval(n)},Reflect.defineProperty(i,"interval",{value:n}),s.once("close",()=>i.stop()),i.stop}});var _t=d((nn,kt)=>{"use strict";var{define:ks,width:_s}=k(),pe=class{constructor(e){let t=e.options;ks(this,"_prompt",e),this.type=e.type,this.name=e.name,this.message="",this.header="",this.footer="",this.error="",this.hint="",this.input="",this.cursor=0,this.index=0,this.lines=0,this.tick=0,this.prompt="",this.buffer="",this.width=_s(t.stdout||process.stdout),Object.assign(this,t),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=e.symbols,this.styles=e.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let e={...this};return e.status=this.status,e.buffer=Buffer.from(e.buffer),delete e.clone,e}set color(e){this._color=e}get color(){let e=this.prompt.styles;if(this.cancelled)return e.cancelled;if(this.submitted)return e.submitted;let t=this._color||e[this.status];return typeof t=="function"?t:e.pending}set loading(e){this._loading=e}get loading(){return typeof this._loading=="boolean"?this._loading:this.loadingChoices?"choices":!1}get status(){return this.cancelled?"cancelled":this.submitted?"submitted":"pending"}};kt.exports=pe});var At=d((ln,qt)=>{"use strict";var fe=k(),R=ee(),me={default:R.noop,noop:R.noop,set inverse(s){this._inverse=s},get inverse(){return this._inverse||fe.inverse(this.primary)},set complement(s){this._complement=s},get complement(){return this._complement||fe.complement(this.primary)},primary:R.cyan,success:R.green,danger:R.magenta,strong:R.bold,warning:R.yellow,muted:R.dim,disabled:R.gray,dark:R.dim.gray,underline:R.underline,set info(s){this._info=s},get info(){return this._info||this.primary},set em(s){this._em=s},get em(){return this._em||this.primary.underline},set heading(s){this._heading=s},get heading(){return this._heading||this.muted.underline},set pending(s){this._pending=s},get pending(){return this._pending||this.primary},set submitted(s){this._submitted=s},get submitted(){return this._submitted||this.success},set cancelled(s){this._cancelled=s},get cancelled(){return this._cancelled||this.danger},set typing(s){this._typing=s},get typing(){return this._typing||this.dim},set placeholder(s){this._placeholder=s},get placeholder(){return this._placeholder||this.primary.dim},set highlight(s){this._highlight=s},get highlight(){return this._highlight||this.inverse}};me.merge=(s={})=>{s.styles&&typeof s.styles.enabled=="boolean"&&(R.enabled=s.styles.enabled),s.styles&&typeof s.styles.visible=="boolean"&&(R.visible=s.styles.visible);let e=fe.merge({},me,s.styles);delete e.merge;for(let t of Object.keys(R))hasOwnProperty.call(e,t)||Reflect.defineProperty(e,t,{get:()=>R[t]});for(let t of Object.keys(R.styles))hasOwnProperty.call(e,t)||Reflect.defineProperty(e,t,{get:()=>R[t]});return e};qt.exports=me});var Ot=d((an,Pt)=>{"use strict";var ge=process.platform==="win32",j=ee(),qs=k(),ye={...j.symbols,upDownDoubleArrow:"\u21D5",upDownDoubleArrow2:"\u2B0D",upDownArrow:"\u2195",asterisk:"*",asterism:"\u2042",bulletWhite:"\u25E6",electricArrow:"\u2301",ellipsisLarge:"\u22EF",ellipsisSmall:"\u2026",fullBlock:"\u2588",identicalTo:"\u2261",indicator:j.symbols.check,leftAngle:"\u2039",mark:"\u203B",minus:"\u2212",multiplication:"\xD7",obelus:"\xF7",percent:"%",pilcrow:"\xB6",pilcrow2:"\u2761",pencilUpRight:"\u2710",pencilDownRight:"\u270E",pencilRight:"\u270F",plus:"+",plusMinus:"\xB1",pointRight:"\u261E",rightAngle:"\u203A",section:"\xA7",hexagon:{off:"\u2B21",on:"\u2B22",disabled:"\u2B22"},ballot:{on:"\u2611",off:"\u2610",disabled:"\u2612"},stars:{on:"\u2605",off:"\u2606",disabled:"\u2606"},folder:{on:"\u25BC",off:"\u25B6",disabled:"\u25B6"},prefix:{pending:j.symbols.question,submitted:j.symbols.check,cancelled:j.symbols.cross},separator:{pending:j.symbols.pointerSmall,submitted:j.symbols.middot,cancelled:j.symbols.middot},radio:{off:ge?"( )":"\u25EF",on:ge?"(*)":"\u25C9",disabled:ge?"(|)":"\u24BE"},numbers:["\u24EA","\u2460","\u2461","\u2462","\u2463","\u2464","\u2465","\u2466","\u2467","\u2468","\u2469","\u246A","\u246B","\u246C","\u246D","\u246E","\u246F","\u2470","\u2471","\u2472","\u2473","\u3251","\u3252","\u3253","\u3254","\u3255","\u3256","\u3257","\u3258","\u3259","\u325A","\u325B","\u325C","\u325D","\u325E","\u325F","\u32B1","\u32B2","\u32B3","\u32B4","\u32B5","\u32B6","\u32B7","\u32B8","\u32B9","\u32BA","\u32BB","\u32BC","\u32BD","\u32BE","\u32BF"]};ye.merge=s=>{let e=qs.merge({},j.symbols,ye,s.symbols);return delete e.merge,e};Pt.exports=ye});var It=d((on,$t)=>{"use strict";var As=At(),Ps=Ot(),Os=k();$t.exports=s=>{s.options=Os.merge({},s.options.theme,s.options),s.symbols=Ps.merge(s.options),s.styles=As.merge(s.options)}});var Mt=d((Bt,Tt)=>{"use strict";var jt=process.env.TERM_PROGRAM==="Apple_Terminal",$s=D(),we=k(),O=Tt.exports=Bt,b="\x1B[",Dt="\x07",be=!1,B=O.code={bell:Dt,beep:Dt,beginning:`${b}G`,down:`${b}J`,esc:b,getPosition:`${b}6n`,hide:`${b}?25l`,line:`${b}2K`,lineEnd:`${b}K`,lineStart:`${b}1K`,restorePosition:b+(jt?"8":"u"),savePosition:b+(jt?"7":"s"),screen:`${b}2J`,show:`${b}?25h`,up:`${b}1J`},L=O.cursor={get hidden(){return be},hide(){return be=!0,B.hide},show(){return be=!1,B.show},forward:(s=1)=>`${b}${s}C`,backward:(s=1)=>`${b}${s}D`,nextLine:(s=1)=>`${b}E`.repeat(s),prevLine:(s=1)=>`${b}F`.repeat(s),up:(s=1)=>s?`${b}${s}A`:"",down:(s=1)=>s?`${b}${s}B`:"",right:(s=1)=>s?`${b}${s}C`:"",left:(s=1)=>s?`${b}${s}D`:"",to(s,e){return e?`${b}${e+1};${s+1}H`:`${b}${s+1}G`},move(s=0,e=0){let t="";return t+=s<0?L.left(-s):s>0?L.right(s):"",t+=e<0?L.up(-e):e>0?L.down(e):"",t},strLen(s){for(var e=0,t=s.length,i=-1,r=0;r<t;r++)i=s.charCodeAt(r),i>=0&&i<=128?e+=1:e+=2;return e},restore(s={}){let{after:e,cursor:t,initial:i,input:r,prompt:n,size:l,value:a}=s;if(i=we.isPrimitive(i)?String(i):"",r=we.isPrimitive(r)?String(r):"",a=we.isPrimitive(a)?String(a):"",l){let o=O.cursor.up(l)+O.cursor.to(this.strLen(n)),h=r.length-t;return h>0&&(o+=O.cursor.left(h)),o}if(a||e){let o=!r&&i?-this.strLen(i):-this.strLen(r)+t;return e&&(o-=this.strLen(e)),r===""&&i&&!n.includes(i)&&(o+=this.strLen(i)),O.cursor.move(o)}}},ve=O.erase={screen:B.screen,up:B.up,down:B.down,line:B.line,lineEnd:B.lineEnd,lineStart:B.lineStart,lines(s){let e="";for(let t=0;t<s;t++)e+=O.erase.line+(t<s-1?O.cursor.up(1):"");return s&&(e+=O.code.beginning),e}};O.clear=(s="",e=process.stdout.columns)=>{if(!e)return ve.line+L.to(0);let t=n=>[...$s(n)].length,i=s.split(/\r?\n/),r=0;for(let n of i)r+=1+Math.floor(Math.max(t(n)-1,0)/e);return(ve.line+L.prevLine()).repeat(r-1)+ve.line+L.to(0)}});var U=d((hn,Vt)=>{"use strict";var Is=J("events"),Lt=D(),xe=de(),js=Rt(),Ds=_t(),Bs=It(),q=k(),V=Mt(),Ce=class s extends Is{constructor(e={}){super(),this.name=e.name,this.type=e.type,this.options=e,Bs(this),js(this),this.state=new Ds(this),this.initial=[e.initial,e.default].find(t=>t!=null),this.stdout=e.stdout||process.stdout,this.stdin=e.stdin||process.stdin,this.scale=e.scale||1,this.term=this.options.term||process.env.TERM_PROGRAM,this.margin=Ms(this.options.margin),this.setMaxListeners(0),Ts(this)}async keypress(e,t={}){this.keypressed=!0;let i=xe.action(e,xe(e,t),this.options.actions);this.state.keypress=i,this.emit("keypress",e,i),this.emit("state",this.state.clone());let r=this.options[i.action]||this[i.action]||this.dispatch;if(typeof r=="function")return await r.call(this,e,i);this.alert()}alert(){delete this.state.alert,this.options.show===!1?this.emit("alert"):this.stdout.write(V.code.beep)}cursorHide(){this.stdout.write(V.cursor.hide());let e=q.onExit(()=>this.cursorShow());this.on("close",()=>{this.cursorShow(),e()})}cursorShow(){this.stdout.write(V.cursor.show())}write(e){e&&(this.stdout&&this.state.show!==!1&&this.stdout.write(e),this.state.buffer+=e)}clear(e=0){let t=this.state.buffer;this.state.buffer="",!(!t&&!e||this.options.show===!1)&&this.stdout.write(V.cursor.down(e)+V.clear(t,this.width))}restore(){if(this.state.closed||this.options.show===!1)return;let{prompt:e,after:t,rest:i}=this.sections(),{cursor:r,initial:n="",input:l="",value:a=""}=this,o=this.state.size=i.length,h={after:t,cursor:r,initial:n,input:l,prompt:e,size:o,value:a},c=V.cursor.restore(h);c&&this.stdout.write(c)}sections(){let{buffer:e,input:t,prompt:i}=this.state;i=Lt(i);let r=Lt(e),n=r.indexOf(i),l=r.slice(0,n),o=r.slice(n).split(`
5
+ `)i.name="enter";else if(s===" ")i.name="tab";else if(s==="\b"||s==="\x7F"||s==="\x1B\x7F"||s==="\x1B\b")i.name="backspace",i.meta=s.charAt(0)==="\x1B";else if(s==="\x1B"||s==="\x1B\x1B")i.name="escape",i.meta=s.length===2;else if(s===" "||s==="\x1B ")i.name="space",i.meta=s.length===2;else if(s<="")i.name=String.fromCharCode(s.charCodeAt(0)+97-1),i.ctrl=!0;else if(s.length===1&&s>="0"&&s<="9")i.name="number";else if(s.length===1&&s>="a"&&s<="z")i.name=s;else if(s.length===1&&s>="A"&&s<="Z")i.name=s.toLowerCase(),i.shift=!0;else if(t=vs.exec(s))i.meta=!0,i.shift=/^[A-Z]$/.test(t[1]);else if(t=xs.exec(s)){let r=[...s];r[0]==="\x1B"&&r[1]==="\x1B"&&(i.option=!0);let n=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),l=(t[3]||t[5]||1)-1;i.ctrl=!!(l&4),i.meta=!!(l&10),i.shift=!!(l&1),i.code=n,i.name=Cs[n],i.shift=Es(n)||i.shift,i.ctrl=Ss(n)||i.ctrl}return i};se.listen=(s={},e)=>{let{stdin:t}=s;if(!t||t!==process.stdin&&!t.isTTY)throw new Error("Invalid stream passed");let i=Ct.createInterface({terminal:!0,input:t});Ct.emitKeypressEvents(t,i);let r=new bs((a,o)=>e(a,se(a,o),i)),n=t.isRaw;return t.isTTY&&t.setRawMode(!0),t.on("keypress",r.enqueue),i.resume(),()=>{t.isTTY&&t.setRawMode(n),t.removeListener("keypress",r.enqueue),r.destroy(),i.pause(),i.close()}};se.action=(s,e,t)=>{let i={...ws,...t};return e.ctrl?(e.action=i.ctrl[e.name],e):e.option&&i.option?(e.action=i.option[e.name],e):e.shift?(e.action=i.shift[e.name],e):(e.action=i.keys[e.name],e)};Et.exports=se});var Rt=d((rn,St)=>{"use strict";St.exports=s=>{s.timers=s.timers||{};let e=s.options.timers;if(e)for(let t of Object.keys(e)){let i=e[t];typeof i=="number"&&(i={interval:i}),Rs(s,t,i)}};function Rs(s,e,t={}){let i=s.timers[e]={name:e,start:Date.now(),ms:0,tick:0},r=t.interval||120;i.frames=t.frames||[],i.loading=!0;let n=setInterval(()=>{i.ms=Date.now()-i.start,i.tick++,s.render()},r);return i.stop=()=>{i.loading=!1,clearInterval(n)},Reflect.defineProperty(i,"interval",{value:n}),s.once("close",()=>i.stop()),i.stop}});var _t=d((nn,kt)=>{"use strict";var{define:ks,width:_s}=k(),pe=class{constructor(e){let t=e.options;ks(this,"_prompt",e),this.type=e.type,this.name=e.name,this.message="",this.header="",this.footer="",this.error="",this.hint="",this.input="",this.cursor=0,this.index=0,this.lines=0,this.tick=0,this.prompt="",this.buffer="",this.width=_s(t.stdout||process.stdout),Object.assign(this,t),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=e.symbols,this.styles=e.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let e={...this};return e.status=this.status,e.buffer=Buffer.from(e.buffer),delete e.clone,e}set color(e){this._color=e}get color(){let e=this.prompt.styles;if(this.cancelled)return e.cancelled;if(this.submitted)return e.submitted;let t=this._color||e[this.status];return typeof t=="function"?t:e.pending}set loading(e){this._loading=e}get loading(){return typeof this._loading=="boolean"?this._loading:this.loadingChoices?"choices":!1}get status(){return this.cancelled?"cancelled":this.submitted?"submitted":"pending"}};kt.exports=pe});var At=d((ln,qt)=>{"use strict";var fe=k(),R=ee(),me={default:R.noop,noop:R.noop,set inverse(s){this._inverse=s},get inverse(){return this._inverse||fe.inverse(this.primary)},set complement(s){this._complement=s},get complement(){return this._complement||fe.complement(this.primary)},primary:R.cyan,success:R.green,danger:R.magenta,strong:R.bold,warning:R.yellow,muted:R.dim,disabled:R.gray,dark:R.dim.gray,underline:R.underline,set info(s){this._info=s},get info(){return this._info||this.primary},set em(s){this._em=s},get em(){return this._em||this.primary.underline},set heading(s){this._heading=s},get heading(){return this._heading||this.muted.underline},set pending(s){this._pending=s},get pending(){return this._pending||this.primary},set submitted(s){this._submitted=s},get submitted(){return this._submitted||this.success},set cancelled(s){this._cancelled=s},get cancelled(){return this._cancelled||this.danger},set typing(s){this._typing=s},get typing(){return this._typing||this.dim},set placeholder(s){this._placeholder=s},get placeholder(){return this._placeholder||this.primary.dim},set highlight(s){this._highlight=s},get highlight(){return this._highlight||this.inverse}};me.merge=(s={})=>{s.styles&&typeof s.styles.enabled=="boolean"&&(R.enabled=s.styles.enabled),s.styles&&typeof s.styles.visible=="boolean"&&(R.visible=s.styles.visible);let e=fe.merge({},me,s.styles);delete e.merge;for(let t of Object.keys(R))hasOwnProperty.call(e,t)||Reflect.defineProperty(e,t,{get:()=>R[t]});for(let t of Object.keys(R.styles))hasOwnProperty.call(e,t)||Reflect.defineProperty(e,t,{get:()=>R[t]});return e};qt.exports=me});var $t=d((an,Pt)=>{"use strict";var ge=process.platform==="win32",j=ee(),qs=k(),ye={...j.symbols,upDownDoubleArrow:"\u21D5",upDownDoubleArrow2:"\u2B0D",upDownArrow:"\u2195",asterisk:"*",asterism:"\u2042",bulletWhite:"\u25E6",electricArrow:"\u2301",ellipsisLarge:"\u22EF",ellipsisSmall:"\u2026",fullBlock:"\u2588",identicalTo:"\u2261",indicator:j.symbols.check,leftAngle:"\u2039",mark:"\u203B",minus:"\u2212",multiplication:"\xD7",obelus:"\xF7",percent:"%",pilcrow:"\xB6",pilcrow2:"\u2761",pencilUpRight:"\u2710",pencilDownRight:"\u270E",pencilRight:"\u270F",plus:"+",plusMinus:"\xB1",pointRight:"\u261E",rightAngle:"\u203A",section:"\xA7",hexagon:{off:"\u2B21",on:"\u2B22",disabled:"\u2B22"},ballot:{on:"\u2611",off:"\u2610",disabled:"\u2612"},stars:{on:"\u2605",off:"\u2606",disabled:"\u2606"},folder:{on:"\u25BC",off:"\u25B6",disabled:"\u25B6"},prefix:{pending:j.symbols.question,submitted:j.symbols.check,cancelled:j.symbols.cross},separator:{pending:j.symbols.pointerSmall,submitted:j.symbols.middot,cancelled:j.symbols.middot},radio:{off:ge?"( )":"\u25EF",on:ge?"(*)":"\u25C9",disabled:ge?"(|)":"\u24BE"},numbers:["\u24EA","\u2460","\u2461","\u2462","\u2463","\u2464","\u2465","\u2466","\u2467","\u2468","\u2469","\u246A","\u246B","\u246C","\u246D","\u246E","\u246F","\u2470","\u2471","\u2472","\u2473","\u3251","\u3252","\u3253","\u3254","\u3255","\u3256","\u3257","\u3258","\u3259","\u325A","\u325B","\u325C","\u325D","\u325E","\u325F","\u32B1","\u32B2","\u32B3","\u32B4","\u32B5","\u32B6","\u32B7","\u32B8","\u32B9","\u32BA","\u32BB","\u32BC","\u32BD","\u32BE","\u32BF"]};ye.merge=s=>{let e=qs.merge({},j.symbols,ye,s.symbols);return delete e.merge,e};Pt.exports=ye});var It=d((on,Ot)=>{"use strict";var As=At(),Ps=$t(),$s=k();Ot.exports=s=>{s.options=$s.merge({},s.options.theme,s.options),s.symbols=Ps.merge(s.options),s.styles=As.merge(s.options)}});var Mt=d((Bt,Tt)=>{"use strict";var jt=process.env.TERM_PROGRAM==="Apple_Terminal",Os=D(),we=k(),$=Tt.exports=Bt,b="\x1B[",Dt="\x07",be=!1,B=$.code={bell:Dt,beep:Dt,beginning:`${b}G`,down:`${b}J`,esc:b,getPosition:`${b}6n`,hide:`${b}?25l`,line:`${b}2K`,lineEnd:`${b}K`,lineStart:`${b}1K`,restorePosition:b+(jt?"8":"u"),savePosition:b+(jt?"7":"s"),screen:`${b}2J`,show:`${b}?25h`,up:`${b}1J`},L=$.cursor={get hidden(){return be},hide(){return be=!0,B.hide},show(){return be=!1,B.show},forward:(s=1)=>`${b}${s}C`,backward:(s=1)=>`${b}${s}D`,nextLine:(s=1)=>`${b}E`.repeat(s),prevLine:(s=1)=>`${b}F`.repeat(s),up:(s=1)=>s?`${b}${s}A`:"",down:(s=1)=>s?`${b}${s}B`:"",right:(s=1)=>s?`${b}${s}C`:"",left:(s=1)=>s?`${b}${s}D`:"",to(s,e){return e?`${b}${e+1};${s+1}H`:`${b}${s+1}G`},move(s=0,e=0){let t="";return t+=s<0?L.left(-s):s>0?L.right(s):"",t+=e<0?L.up(-e):e>0?L.down(e):"",t},strLen(s){for(var e=0,t=s.length,i=-1,r=0;r<t;r++)i=s.charCodeAt(r),i>=0&&i<=128?e+=1:e+=2;return e},restore(s={}){let{after:e,cursor:t,initial:i,input:r,prompt:n,size:l,value:a}=s;if(i=we.isPrimitive(i)?String(i):"",r=we.isPrimitive(r)?String(r):"",a=we.isPrimitive(a)?String(a):"",l){let o=$.cursor.up(l)+$.cursor.to(this.strLen(n)),h=r.length-t;return h>0&&(o+=$.cursor.left(h)),o}if(a||e){let o=!r&&i?-this.strLen(i):-this.strLen(r)+t;return e&&(o-=this.strLen(e)),r===""&&i&&!n.includes(i)&&(o+=this.strLen(i)),$.cursor.move(o)}}},ve=$.erase={screen:B.screen,up:B.up,down:B.down,line:B.line,lineEnd:B.lineEnd,lineStart:B.lineStart,lines(s){let e="";for(let t=0;t<s;t++)e+=$.erase.line+(t<s-1?$.cursor.up(1):"");return s&&(e+=$.code.beginning),e}};$.clear=(s="",e=process.stdout.columns)=>{if(!e)return ve.line+L.to(0);let t=n=>[...Os(n)].length,i=s.split(/\r?\n/),r=0;for(let n of i)r+=1+Math.floor(Math.max(t(n)-1,0)/e);return(ve.line+L.prevLine()).repeat(r-1)+ve.line+L.to(0)}});var U=d((hn,Vt)=>{"use strict";var Is=J("events"),Lt=D(),xe=de(),js=Rt(),Ds=_t(),Bs=It(),q=k(),V=Mt(),Ce=class s extends Is{constructor(e={}){super(),this.name=e.name,this.type=e.type,this.options=e,Bs(this),js(this),this.state=new Ds(this),this.initial=[e.initial,e.default].find(t=>t!=null),this.stdout=e.stdout||process.stdout,this.stdin=e.stdin||process.stdin,this.scale=e.scale||1,this.term=this.options.term||process.env.TERM_PROGRAM,this.margin=Ms(this.options.margin),this.setMaxListeners(0),Ts(this)}async keypress(e,t={}){this.keypressed=!0;let i=xe.action(e,xe(e,t),this.options.actions);this.state.keypress=i,this.emit("keypress",e,i),this.emit("state",this.state.clone());let r=this.options[i.action]||this[i.action]||this.dispatch;if(typeof r=="function")return await r.call(this,e,i);this.alert()}alert(){delete this.state.alert,this.options.show===!1?this.emit("alert"):this.stdout.write(V.code.beep)}cursorHide(){this.stdout.write(V.cursor.hide());let e=q.onExit(()=>this.cursorShow());this.on("close",()=>{this.cursorShow(),e()})}cursorShow(){this.stdout.write(V.cursor.show())}write(e){e&&(this.stdout&&this.state.show!==!1&&this.stdout.write(e),this.state.buffer+=e)}clear(e=0){let t=this.state.buffer;this.state.buffer="",!(!t&&!e||this.options.show===!1)&&this.stdout.write(V.cursor.down(e)+V.clear(t,this.width))}restore(){if(this.state.closed||this.options.show===!1)return;let{prompt:e,after:t,rest:i}=this.sections(),{cursor:r,initial:n="",input:l="",value:a=""}=this,o=this.state.size=i.length,h={after:t,cursor:r,initial:n,input:l,prompt:e,size:o,value:a},c=V.cursor.restore(h);c&&this.stdout.write(c)}sections(){let{buffer:e,input:t,prompt:i}=this.state;i=Lt(i);let r=Lt(e),n=r.indexOf(i),l=r.slice(0,n),o=r.slice(n).split(`
6
6
  `),h=o[0],c=o[o.length-1],v=(i+(t?" "+t:"")).length,y=v<h.length?h.slice(v+1):"";return{header:l,prompt:h,after:y,rest:o.slice(1),last:c}}async submit(){this.state.submitted=!0,this.state.validating=!0,this.options.onSubmit&&await this.options.onSubmit.call(this,this.name,this.value,this);let e=this.state.error||await this.validate(this.value,this.state);if(e!==!0){let t=`
7
7
  `+this.symbols.pointer+" ";typeof e=="string"?t+=e.trim():t+="Invalid input",this.state.error=`
8
8
  `+this.styles.danger(t),this.state.submitted=!1,await this.render(),await this.alert(),this.state.validating=!1,this.state.error=void 0;return}this.state.validating=!1,await this.render(),await this.close(),this.value=await this.result(this.value),this.emit("submit",this.value)}async cancel(e){this.state.cancelled=this.state.submitted=!0,await this.render(),await this.close(),typeof this.options.onCancel=="function"&&await this.options.onCancel.call(this,this.name,this.value,this),this.emit("cancel",await this.error(e))}async close(){this.state.closed=!0;try{let e=this.sections(),t=Math.ceil(e.prompt.length/this.width);e.rest&&this.write(V.cursor.down(e.rest.length)),this.write(`
@@ -10,8 +10,8 @@ var rs=Object.create;var it=Object.defineProperty;var ns=Object.getOwnPropertyDe
10
10
  `:" ",i=[];for(let r=0;r<4;r++){let n=t(r);e[r]?i.push(n.repeat(e[r])):i.push("")}return i}Vt.exports=Ce});var Wt=d((un,Kt)=>{"use strict";var Ls=k(),zt={default(s,e){return e},checkbox(s,e){throw new Error("checkbox role is not implemented yet")},editable(s,e){throw new Error("editable role is not implemented yet")},expandable(s,e){throw new Error("expandable role is not implemented yet")},heading(s,e){return e.disabled="",e.indicator=[e.indicator," "].find(t=>t!=null),e.message=e.message||"",e},input(s,e){throw new Error("input role is not implemented yet")},option(s,e){return zt.default(s,e)},radio(s,e){throw new Error("radio role is not implemented yet")},separator(s,e){return e.disabled="",e.indicator=[e.indicator," "].find(t=>t!=null),e.message=e.message||s.symbols.line.repeat(5),e},spacer(s,e){return e}};Kt.exports=(s,e={})=>{let t=Ls.merge({},zt,e.roles);return t[s]||t.default}});var Z=d((cn,Ft)=>{"use strict";var Vs=D(),zs=U(),Ks=Wt(),re=k(),{reorder:Ee,scrollUp:Ws,scrollDown:Us,isObject:Ut,swap:Ns}=re,Se=class extends zs{constructor(e){super(e),this.cursorHide(),this.maxSelected=e.maxSelected||1/0,this.multiple=e.multiple||!1,this.initial=e.initial||0,this.delay=e.delay||0,this.longest=0,this.num=""}async initialize(){typeof this.options.initial=="function"&&(this.initial=await this.options.initial.call(this)),await this.reset(!0),await super.initialize()}async reset(){let{choices:e,initial:t,autofocus:i,suggest:r}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(e)),this.choices.forEach(n=>n.enabled=!1),typeof r!="function"&&this.selectable.length===0)throw new Error("At least one choice must be selectable");Ut(t)&&(t=Object.keys(t)),Array.isArray(t)?(i!=null&&(this.index=this.findIndex(i)),t.forEach(n=>this.enable(this.find(n))),await this.render()):(i!=null&&(t=i),typeof t=="string"&&(t=this.findIndex(t)),typeof t=="number"&&t>-1&&(this.index=Math.max(0,Math.min(t,this.choices.length)),this.enable(this.find(this.index)))),this.isDisabled(this.focused)&&await this.down()}async toChoices(e,t){this.state.loadingChoices=!0;let i=[],r=0,n=async(l,a)=>{typeof l=="function"&&(l=await l.call(this)),l instanceof Promise&&(l=await l);for(let o=0;o<l.length;o++){let h=l[o]=await this.toChoice(l[o],r++,a);i.push(h),h.choices&&await n(h.choices,h)}return i};return n(e,t).then(l=>(this.state.loadingChoices=!1,l))}async toChoice(e,t,i){if(typeof e=="function"&&(e=await e.call(this,this)),e instanceof Promise&&(e=await e),typeof e=="string"&&(e={name:e}),e.normalized)return e;e.normalized=!0;let r=e.value;if(e=Ks(e.role,this.options)(this,e),typeof e.disabled=="string"&&!e.hint&&(e.hint=e.disabled,e.disabled=!0),e.disabled===!0&&e.hint==null&&(e.hint="(disabled)"),e.index!=null)return e;e.name=e.name||e.key||e.title||e.value||e.message,e.message=e.message||e.name||"",e.value=[e.value,e.name].find(this.isValue.bind(this)),e.input="",e.index=t,e.cursor=0,re.define(e,"parent",i),e.level=i?i.level+1:1,e.indent==null&&(e.indent=i?i.indent+" ":e.indent||""),e.path=i?i.path+"."+e.name:e.name,e.enabled=!!(this.multiple&&!this.isDisabled(e)&&(e.enabled||this.isSelected(e))),this.isDisabled(e)||(this.longest=Math.max(this.longest,Vs(e.message).length));let l={...e};return e.reset=(a=l.input,o=l.value)=>{for(let h of Object.keys(l))e[h]=l[h];e.input=a,e.value=o},r==null&&typeof e.initial=="function"&&(e.input=await e.initial.call(this,this.state,e,t)),e}async onChoice(e,t){this.emit("choice",e,t,this),typeof e.onChoice=="function"&&await e.onChoice.call(this,this.state,e,t)}async addChoice(e,t,i){let r=await this.toChoice(e,t,i);return this.choices.push(r),this.index=this.choices.length-1,this.limit=this.choices.length,r}async newItem(e,t,i){let r={name:"New choice name?",editable:!0,newChoice:!0,...e},n=await this.addChoice(r,t,i);return n.updateChoice=()=>{delete n.newChoice,n.name=n.message=n.input,n.input="",n.cursor=0},this.render()}indent(e){return e.indent==null?e.level>1?" ".repeat(e.level-1):"":e.indent}dispatch(e,t){if(this.multiple&&this[t.name])return this[t.name]();this.alert()}focus(e,t){return typeof t!="boolean"&&(t=e.enabled),t&&!e.enabled&&this.selected.length>=this.maxSelected?this.alert():(this.index=e.index,e.enabled=t&&!this.isDisabled(e),e)}space(){if(!this.multiple)return this.alert();if(this.focused)return this.toggle(this.focused),this.render()}a(){if(this.maxSelected<this.choices.length)return this.alert();let e=this.selectable.every(t=>t.enabled);return this.choices.forEach(t=>t.enabled=!e),this.render()}i(){return this.choices.length-this.selected.length>this.maxSelected?this.alert():(this.choices.forEach(e=>e.enabled=!e.enabled),this.render())}g(){if(!this.choices.some(t=>!!t.parent))return this.a();let e=this.focused;return this.toggle(e.parent&&!e.choices?e.parent:e),this.render()}toggle(e,t){if(!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();typeof t!="boolean"&&(t=!e.enabled),e.enabled=t,e.choices&&e.choices.forEach(r=>this.toggle(r,t));let i=e.parent;for(;i;){let r=i.choices.filter(n=>this.isDisabled(n));i.enabled=r.every(n=>n.enabled===!0),i=i.parent}return Nt(this,this.choices),this.emit("toggle",e,this),e}enable(e){return this.selected.length>=this.maxSelected?this.alert():(e.enabled=!this.isDisabled(e),e.choices&&e.choices.forEach(this.enable.bind(this)),e)}disable(e){return e.enabled=!1,e.choices&&e.choices.forEach(this.disable.bind(this)),e}number(e){this.num+=e;let t=i=>{let r=Number(i);if(r>this.choices.length-1)return this.alert();let n=this.focused,l=this.choices.find(a=>r===a.index);if(!l.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(this.visible.indexOf(l)===-1){let a=Ee(this.choices),o=a.indexOf(l);if(n.index>o){let h=a.slice(o,o+this.limit),c=a.filter(u=>!h.includes(u));this.choices=h.concat(c)}else{let h=o-this.limit+1;this.choices=a.slice(h).concat(a.slice(0,h))}}return this.index=this.choices.indexOf(l),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise(i=>{let r=this.choices.length,n=this.num,l=(a=!1,o)=>{clearTimeout(this.numberTimeout),a&&(o=t(n)),this.num="",i(o)};if(n==="0"||n.length===1&&+(n+"0")>r)return l(!0);if(Number(n)>r)return l(!1,this.alert());this.numberTimeout=setTimeout(()=>l(!0),this.delay)})}home(){return this.choices=Ee(this.choices),this.index=0,this.render()}end(){let e=this.choices.length-this.limit,t=Ee(this.choices);return this.choices=t.slice(e).concat(t.slice(0,e)),this.index=this.limit-1,this.render()}first(){return this.index=0,this.render()}last(){return this.index=this.visible.length-1,this.render()}prev(){return this.visible.length<=1?this.alert():this.up()}next(){return this.visible.length<=1?this.alert():this.down()}right(){return this.cursor>=this.input.length?this.alert():(this.cursor++,this.render())}left(){return this.cursor<=0?this.alert():(this.cursor--,this.render())}up(){let e=this.choices.length,t=this.visible.length,i=this.index;return this.options.scroll===!1&&i===0?this.alert():e>t&&i===0?this.scrollUp():(this.index=(i-1%e+e)%e,this.isDisabled()&&!this.allChoicesAreDisabled()?this.up():this.render())}down(){let e=this.choices.length,t=this.visible.length,i=this.index;return this.options.scroll===!1&&i===t-1?this.alert():e>t&&i===t-1?this.scrollDown():(this.index=(i+1)%e,this.isDisabled()&&!this.allChoicesAreDisabled()?this.down():this.render())}scrollUp(e=0){return this.choices=Ws(this.choices),this.index=e,this.isDisabled()?this.up():this.render()}scrollDown(e=this.visible.length-1){return this.choices=Us(this.choices),this.index=e,this.isDisabled()?this.down():this.render()}async shiftUp(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index-1),await this.up(),this.sorting=!1;return}return this.scrollUp(this.index)}async shiftDown(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index+1),await this.down(),this.sorting=!1;return}return this.scrollDown(this.index)}pageUp(){return this.visible.length<=1?this.alert():(this.limit=Math.max(this.limit-1,0),this.index=Math.min(this.limit-1,this.index),this._limit=this.limit,this.isDisabled()?this.up():this.render())}pageDown(){return this.visible.length>=this.choices.length?this.alert():(this.index=Math.max(0,this.index),this.limit=Math.min(this.limit+1,this.choices.length),this._limit=this.limit,this.isDisabled()?this.down():this.render())}swap(e){Ns(this.choices,this.index,e)}allChoicesAreDisabled(e=this.choices){return e.every(t=>this.isDisabled(t))}isDisabled(e=this.focused){return e&&["disabled","collapsed","hidden","completing","readonly"].some(i=>e[i]===!0)?!0:e&&e.role==="heading"}isEnabled(e=this.focused){if(Array.isArray(e))return e.every(t=>this.isEnabled(t));if(e.choices){let t=e.choices.filter(i=>!this.isDisabled(i));return e.enabled&&t.every(i=>this.isEnabled(i))}return e.enabled&&!this.isDisabled(e)}isChoice(e,t){return e.name===t||e.index===Number(t)}isSelected(e){return Array.isArray(this.initial)?this.initial.some(t=>this.isChoice(e,t)):this.isChoice(e,this.initial)}map(e=[],t="value"){return[].concat(e||[]).reduce((i,r)=>(i[r]=this.find(r,t),i),{})}filter(e,t){let r=typeof e=="function"?e:(a,o)=>[a.name,o].includes(e),l=(this.options.multiple?this.state._choices:this.choices).filter(r);return t?l.map(a=>a[t]):l}find(e,t){if(Ut(e))return t?e[t]:e;let r=typeof e=="function"?e:(l,a)=>[l.name,a].includes(e),n=this.choices.find(r);if(n)return t?n[t]:n}findIndex(e){return this.choices.indexOf(this.find(e))}async submit(){let e=this.focused;if(!e)return this.alert();if(e.newChoice)return e.input?(e.updateChoice(),this.render()):this.alert();if(this.choices.some(l=>l.newChoice))return this.alert();let{reorder:t,sort:i}=this.options,r=this.multiple===!0,n=this.selected;return n===void 0?this.alert():(Array.isArray(n)&&t!==!1&&i!==!0&&(n=re.reorder(n)),this.value=r?n.map(l=>l.name):n.name,super.submit())}set choices(e=[]){this.state._choices=this.state._choices||[],this.state.choices=e;for(let t of e)this.state._choices.some(i=>i.name===t.name)||this.state._choices.push(t);if(!this._initial&&this.options.initial){this._initial=!0;let t=this.initial;if(typeof t=="string"||typeof t=="number"){let i=this.find(t);i&&(this.initial=i.index,this.focus(i,!0))}}}get choices(){return Nt(this,this.state.choices||[])}set visible(e){this.state.visible=e}get visible(){return(this.state.visible||this.choices).slice(0,this.limit)}set limit(e){this.state.limit=e}get limit(){let{state:e,options:t,choices:i}=this,r=e.limit||this._limit||t.limit||i.length;return Math.min(r,this.height)}set value(e){super.value=e}get value(){return typeof super.value!="string"&&super.value===this.initial?this.input:super.value}set index(e){this.state.index=e}get index(){return Math.max(0,this.state?this.state.index:0)}get enabled(){return this.filter(this.isEnabled.bind(this))}get focused(){let e=this.choices[this.index];return e&&this.state.submitted&&this.multiple!==!0&&(e.enabled=!0),e}get selectable(){return this.choices.filter(e=>!this.isDisabled(e))}get selected(){return this.multiple?this.enabled:this.focused}};function Nt(s,e){if(e instanceof Promise)return e;if(typeof e=="function"){if(re.isAsyncFn(e))return e;e=e.call(s,s)}for(let t of e){if(Array.isArray(t.choices)){let i=t.choices.filter(r=>!s.isDisabled(r));t.enabled=i.every(r=>r.enabled===!0)}s.isDisabled(t)===!0&&delete t.enabled}return e}Ft.exports=Se});var T=d((dn,Ht)=>{"use strict";var Fs=Z(),Re=k(),ke=class extends Fs{constructor(e){super(e),this.emptyError=this.options.emptyError||"No items were selected"}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}separator(){if(this.options.separator)return super.separator();let e=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():e}pointer(e,t){return!this.multiple||this.options.pointer?super.pointer(e,t):""}indicator(e,t){return this.multiple?super.indicator(e,t):""}choiceMessage(e,t){let i=this.resolve(e.message,this.state,e,t);return e.role==="heading"&&!Re.hasColor(i)&&(i=this.styles.strong(i)),this.resolve(i,this.state,e,t)}choiceSeparator(){return":"}async renderChoice(e,t){await this.onChoice(e,t);let i=this.index===t,r=await this.pointer(e,t),n=await this.indicator(e,t)+(e.pad||""),l=await this.resolve(e.hint,this.state,e,t);l&&!Re.hasColor(l)&&(l=this.styles.muted(l));let a=this.indent(e),o=await this.choiceMessage(e,t),h=()=>[this.margin[3],a+r+n,o,this.margin[1],l].filter(Boolean).join(" ");return e.role==="heading"?h():e.disabled?(Re.hasColor(o)||(o=this.styles.disabled(o)),h()):(i&&(o=this.styles.em(o)),h())}async renderChoices(){if(this.state.loading==="choices")return this.styles.warning("Loading choices");if(this.state.submitted)return"";let e=this.visible.map(async(n,l)=>await this.renderChoice(n,l)),t=await Promise.all(e);t.length||t.push(this.styles.danger("No matching choices"));let i=this.margin[0]+t.join(`
11
11
  `),r;return this.options.choicesHeader&&(r=await this.resolve(this.options.choicesHeader,this.state)),[r,i].filter(Boolean).join(`
12
12
  `)}format(){return!this.state.submitted||this.state.cancelled?"":Array.isArray(this.selected)?this.selected.map(e=>this.styles.primary(e.name)).join(", "):this.styles.primary(this.selected.name)}async render(){let{submitted:e,size:t}=this.state,i="",r=await this.header(),n=await this.prefix(),l=await this.separator(),a=await this.message();this.options.promptLine!==!1&&(i=[n,a,l,""].join(" "),this.state.prompt=i);let o=await this.format(),h=await this.error()||await this.hint(),c=await this.renderChoices(),u=await this.footer();o&&(i+=o),h&&!i.includes(h)&&(i+=" "+h),e&&!o&&!c.trim()&&this.multiple&&this.emptyError!=null&&(i+=this.styles.danger(this.emptyError)),this.clear(t),this.write([r,i,c,u].filter(Boolean).join(`
13
- `)),this.write(this.margin[2]),this.restore()}};Ht.exports=ke});var Zt=d((pn,Gt)=>{"use strict";var Hs=T(),Gs=(s,e)=>{let t=s?new RegExp(s,"ig"):/$^/;return i=>s?i.replace(t,r=>e(r)):i},_e=class extends Hs{constructor(e){super(e),this.cursorShow()}moveCursor(e){this.state.cursor+=e}dispatch(e){return this.append(e)}space(e){return this.options.multiple?super.space(e):this.append(e)}append(e){let{cursor:t,input:i}=this.state;return this.input=i.slice(0,t)+e+i.slice(t),this.moveCursor(1),this.complete()}delete(){let{cursor:e,input:t}=this.state;return t?(this.input=t.slice(0,e-1)+t.slice(e),this.moveCursor(-1),this.complete()):this.alert()}deleteForward(){let{cursor:e,input:t}=this.state;return t[e]===void 0?this.alert():(this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.complete())}number(e){return this.append(e)}async complete(){this.completing=!0,this.choices=await this.suggest(this.input,this.state._choices),this.state.limit=void 0,this.index=Math.min(Math.max(this.visible.length-1,0),this.index),await this.render(),this.completing=!1}suggest(e=this.input,t=this.state._choices){if(typeof this.options.suggest=="function")return this.options.suggest.call(this,e,t);let i=e.toLowerCase();return t.filter(r=>r.message.toLowerCase().includes(i))}pointer(){return""}format(){if(!this.focused)return this.input;if(this.options.multiple&&this.state.submitted)return this.selected.map(e=>this.styles.primary(e.message)).join(", ");if(this.state.submitted){let e=this.value=this.input=this.focused.value;return this.styles.primary(e)}return this.input}async render(){if(this.state.status!=="pending")return super.render();let e=this.options.highlight||this.styles.complement,t=(n,l)=>n&&(e.stack?e(n):e.call(this,n)),i=Gs(this.input,t),r=this.choices;this.choices=r.map(n=>({...n,message:i(n.message)})),await super.render(),this.choices=r}submit(){return this.options.multiple&&(this.value=this.selected.map(e=>e.name)),super.submit()}};Gt.exports=_e});var Ae=d((fn,Yt)=>{"use strict";var qe=k();Yt.exports=(s,e={})=>{s.cursorHide();let{input:t="",initial:i="",pos:r,showCursor:n=!0,color:l}=e,a=l||s.styles.placeholder,o=qe.inverse(s.styles.primary),h=x=>o(s.styles.black(x)),c=t,u=" ",v=h(u);if(s.blink&&s.blink.off===!0&&(h=x=>x,v=""),n&&r===0&&i===""&&t==="")return h(u);if(n&&r===0&&(t===i||t===""))return h(i[0])+a(i.slice(1));i=qe.isPrimitive(i)?`${i}`:"",t=qe.isPrimitive(t)?`${t}`:"";let y=i&&i.startsWith(t)&&i!==t,p=y?h(i[t.length]):v;if(r!==t.length&&n===!0&&(c=t.slice(0,r)+h(t[r])+t.slice(r+1),p=""),n===!1&&(p=""),y){let x=s.styles.unstyle(c+p);return c+p+a(i.slice(x.length))}return c+p}});var ne=d((mn,Jt)=>{"use strict";var Zs=D(),Ys=T(),Js=Ae(),Pe=class extends Ys{constructor(e){super({...e,multiple:!0}),this.type="form",this.initial=this.options.initial,this.align=[this.options.align,"right"].find(t=>t!=null),this.emptyError="",this.values={}}async reset(e){return await super.reset(),e===!0&&(this._index=this.index),this.index=this._index,this.values={},this.choices.forEach(t=>t.reset&&t.reset()),this.render()}dispatch(e){return!!e&&this.append(e)}append(e){let t=this.focused;if(!t)return this.alert();let{cursor:i,input:r}=t;return t.value=t.input=r.slice(0,i)+e+r.slice(i),t.cursor++,this.render()}delete(){let e=this.focused;if(!e||e.cursor<=0)return this.alert();let{cursor:t,input:i}=e;return e.value=e.input=i.slice(0,t-1)+i.slice(t),e.cursor--,this.render()}deleteForward(){let e=this.focused;if(!e)return this.alert();let{cursor:t,input:i}=e;if(i[t]===void 0)return this.alert();let r=`${i}`.slice(0,t)+`${i}`.slice(t+1);return e.value=e.input=r,this.render()}right(){let e=this.focused;return e?e.cursor>=e.input.length?this.alert():(e.cursor++,this.render()):this.alert()}left(){let e=this.focused;return e?e.cursor<=0?this.alert():(e.cursor--,this.render()):this.alert()}space(e,t){return this.dispatch(e,t)}number(e,t){return this.dispatch(e,t)}next(){let e=this.focused;if(!e)return this.alert();let{initial:t,input:i}=e;return t&&t.startsWith(i)&&i!==t?(e.value=e.input=t,e.cursor=e.value.length,this.render()):super.next()}prev(){let e=this.focused;return e?e.cursor===0?super.prev():(e.value=e.input="",e.cursor=0,this.render()):this.alert()}separator(){return""}format(e){return this.state.submitted?"":super.format(e)}pointer(){return""}indicator(e){return e.input?"\u29BF":"\u2299"}async choiceSeparator(e,t){let i=await this.resolve(e.separator,this.state,e,t)||":";return i?" "+this.styles.disabled(i):""}async renderChoice(e,t){await this.onChoice(e,t);let{state:i,styles:r}=this,{cursor:n,initial:l="",name:a,input:o=""}=e,{muted:h,submitted:c,primary:u,danger:v}=r,y=this.index===t,p=e.validate||(()=>!0),x=await this.choiceSeparator(e,t),E=e.message;this.align==="right"&&(E=E.padStart(this.longest+1," ")),this.align==="left"&&(E=E.padEnd(this.longest+1," "));let f=this.values[a]=o||l,w=o?"success":"dark";await p.call(e,f,this.state)!==!0&&(w="danger");let m=r[w],C=m(await this.indicator(e,t))+(e.pad||""),_=this.indent(e),A=()=>[_,C,E+x,o].filter(Boolean).join(" ");if(i.submitted)return E=Zs(E),o=c(o),A();if(e.format)o=await e.format.call(this,o,e,t);else{let tt=this.styles.muted;o=Js(this,{input:o,initial:l,pos:n,showCursor:y,color:tt})}return this.isValue(o)||(o=this.styles.muted(this.symbols.ellipsis)),e.result&&(this.values[a]=await e.result.call(this,f,e,t)),y&&(E=u(E)),e.error?o+=(o?" ":"")+v(e.error.trim()):e.hint&&(o+=(o?" ":"")+h(e.hint.trim())),A()}async submit(){return this.value=this.values,super.base.submit.call(this)}};Jt.exports=Pe});var Oe=d((gn,Qt)=>{"use strict";var Xs=ne(),Qs=()=>{throw new Error("expected prompt to have a custom authenticate method")},Xt=(s=Qs)=>{class e extends Xs{constructor(i){super(i)}async submit(){this.value=await s.call(this,this.values,this.state),super.base.submit.call(this)}static create(i){return Xt(i)}}return e};Qt.exports=Xt()});var ii=d((yn,ti)=>{"use strict";var er=Oe();function tr(s,e){return s.username===this.options.username&&s.password===this.options.password}var ei=(s=tr)=>{let e=[{name:"username",message:"username"},{name:"password",message:"password",format(i){return this.options.showPassword?i:(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(i.length))}}];class t extends er.create(s){constructor(r){super({...r,choices:e})}static create(r){return ei(r)}}return t};ti.exports=ei()});var le=d((wn,si)=>{"use strict";var ir=U(),{isPrimitive:sr,hasColor:rr}=k(),$e=class extends ir{constructor(e){super(e),this.cursorHide()}async initialize(){let e=await this.resolve(this.initial,this.state);this.input=await this.cast(e),await super.initialize()}dispatch(e){return this.isValue(e)?(this.input=e,this.submit()):this.alert()}format(e){let{styles:t,state:i}=this;return i.submitted?t.success(e):t.primary(e)}cast(e){return this.isTrue(e)}isTrue(e){return/^[ty1]/i.test(e)}isFalse(e){return/^[fn0]/i.test(e)}isValue(e){return sr(e)&&(this.isTrue(e)||this.isFalse(e))}async hint(){if(this.state.status==="pending"){let e=await this.element("hint");return rr(e)?e:this.styles.muted(e)}}async render(){let{input:e,size:t}=this.state,i=await this.prefix(),r=await this.separator(),n=await this.message(),l=this.styles.muted(this.default),a=[i,n,l,r].filter(Boolean).join(" ");this.state.prompt=a;let o=await this.header(),h=this.value=this.cast(e),c=await this.format(h),u=await this.error()||await this.hint(),v=await this.footer();u&&!a.includes(u)&&(c+=" "+u),a+=" "+c,this.clear(t),this.write([o,a,v].filter(Boolean).join(`
14
- `)),this.restore()}set value(e){super.value=e}get value(){return this.cast(super.value)}};si.exports=$e});var ni=d((bn,ri)=>{"use strict";var nr=le(),Ie=class extends nr{constructor(e){super(e),this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}};ri.exports=Ie});var ai=d((vn,li)=>{"use strict";var lr=T(),ar=ne(),N=ar.prototype,je=class extends lr{constructor(e){super({...e,multiple:!0}),this.align=[this.options.align,"left"].find(t=>t!=null),this.emptyError="",this.values={}}dispatch(e,t){let i=this.focused,r=i.parent||{};return!i.editable&&!r.editable&&(e==="a"||e==="i")?super[e]():N.dispatch.call(this,e,t)}append(e,t){return N.append.call(this,e,t)}delete(e,t){return N.delete.call(this,e,t)}space(e){return this.focused.editable?this.append(e):super.space()}number(e){return this.focused.editable?this.append(e):super.number(e)}next(){return this.focused.editable?N.next.call(this):super.next()}prev(){return this.focused.editable?N.prev.call(this):super.prev()}async indicator(e,t){let i=e.indicator||"",r=e.editable?i:super.indicator(e,t);return await this.resolve(r,this.state,e,t)||""}indent(e){return e.role==="heading"?"":e.editable?" ":" "}async renderChoice(e,t){return e.indent="",e.editable?N.renderChoice.call(this,e,t):super.renderChoice(e,t)}error(){return""}footer(){return this.state.error}async validate(){let e=!0;for(let t of this.choices){if(typeof t.validate!="function"||t.role==="heading")continue;let i=t.parent?this.value[t.parent.name]:this.value;if(t.editable?i=t.value===t.name?t.initial||"":t.value:this.isDisabled(t)||(i=t.enabled===!0),e=await t.validate(i,this.state),e!==!0)break}return e!==!0&&(this.state.error=typeof e=="string"?e:"Invalid Input"),e}submit(){if(this.focused.newChoice===!0)return super.submit();if(this.choices.some(e=>e.newChoice))return this.alert();this.value={};for(let e of this.choices){let t=e.parent?this.value[e.parent.name]:this.value;if(e.role==="heading"){this.value[e.name]={};continue}e.editable?t[e.name]=e.value===e.name?e.initial||"":e.value:this.isDisabled(e)||(t[e.name]=e.enabled===!0)}return this.base.submit.call(this)}};li.exports=je});var z=d((xn,oi)=>{"use strict";var or=U(),hr=de(),ur=Ae(),{isPrimitive:cr}=k(),De=class extends or{constructor(e){super(e),this.initial=cr(this.initial)?String(this.initial):"",this.initial&&this.cursorHide(),this.state.prevCursor=0,this.state.clipboard=[],this.keypressTimeout=this.options.keypressTimeout!==void 0?this.options.keypressTimeout:null}async keypress(e,t=e?hr(e,{}):{}){let i=Date.now(),r=i-this.lastKeypress;this.lastKeypress=i;let n=t.name==="return"||t.name==="enter",l=this.state.prevKeypress,a;if(this.state.prevKeypress=t,this.keypressTimeout!=null&&n){if(r<this.keypressTimeout)return this.submit();this.state.multilineBuffer=this.state.multilineBuffer||"",this.state.multilineBuffer+=e,a=!0,l=null}return(a||this.options.multiline&&n)&&(!l||l.name!=="return")?this.append(`
13
+ `)),this.write(this.margin[2]),this.restore()}};Ht.exports=ke});var Zt=d((pn,Gt)=>{"use strict";var Hs=T(),Gs=(s,e)=>{let t=s?new RegExp(s,"ig"):/$^/;return i=>s?i.replace(t,r=>e(r)):i},_e=class extends Hs{constructor(e){super(e),this.cursorShow()}moveCursor(e){this.state.cursor+=e}dispatch(e){return this.append(e)}space(e){return this.options.multiple?super.space(e):this.append(e)}append(e){let{cursor:t,input:i}=this.state;return this.input=i.slice(0,t)+e+i.slice(t),this.moveCursor(1),this.complete()}delete(){let{cursor:e,input:t}=this.state;return t?(this.input=t.slice(0,e-1)+t.slice(e),this.moveCursor(-1),this.complete()):this.alert()}deleteForward(){let{cursor:e,input:t}=this.state;return t[e]===void 0?this.alert():(this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.complete())}number(e){return this.append(e)}async complete(){this.completing=!0,this.choices=await this.suggest(this.input,this.state._choices),this.state.limit=void 0,this.index=Math.min(Math.max(this.visible.length-1,0),this.index),await this.render(),this.completing=!1}suggest(e=this.input,t=this.state._choices){if(typeof this.options.suggest=="function")return this.options.suggest.call(this,e,t);let i=e.toLowerCase();return t.filter(r=>r.message.toLowerCase().includes(i))}pointer(){return""}format(){if(!this.focused)return this.input;if(this.options.multiple&&this.state.submitted)return this.selected.map(e=>this.styles.primary(e.message)).join(", ");if(this.state.submitted){let e=this.value=this.input=this.focused.value;return this.styles.primary(e)}return this.input}async render(){if(this.state.status!=="pending")return super.render();let e=this.options.highlight||this.styles.complement,t=(n,l)=>n&&(e.stack?e(n):e.call(this,n)),i=Gs(this.input,t),r=this.choices;this.choices=r.map(n=>({...n,message:i(n.message)})),await super.render(),this.choices=r}submit(){return this.options.multiple&&(this.value=this.selected.map(e=>e.name)),super.submit()}};Gt.exports=_e});var Ae=d((fn,Yt)=>{"use strict";var qe=k();Yt.exports=(s,e={})=>{s.cursorHide();let{input:t="",initial:i="",pos:r,showCursor:n=!0,color:l}=e,a=l||s.styles.placeholder,o=qe.inverse(s.styles.primary),h=x=>o(s.styles.black(x)),c=t,u=" ",v=h(u);if(s.blink&&s.blink.off===!0&&(h=x=>x,v=""),n&&r===0&&i===""&&t==="")return h(u);if(n&&r===0&&(t===i||t===""))return h(i[0])+a(i.slice(1));i=qe.isPrimitive(i)?`${i}`:"",t=qe.isPrimitive(t)?`${t}`:"";let y=i&&i.startsWith(t)&&i!==t,p=y?h(i[t.length]):v;if(r!==t.length&&n===!0&&(c=t.slice(0,r)+h(t[r])+t.slice(r+1),p=""),n===!1&&(p=""),y){let x=s.styles.unstyle(c+p);return c+p+a(i.slice(x.length))}return c+p}});var ne=d((mn,Jt)=>{"use strict";var Zs=D(),Ys=T(),Js=Ae(),Pe=class extends Ys{constructor(e){super({...e,multiple:!0}),this.type="form",this.initial=this.options.initial,this.align=[this.options.align,"right"].find(t=>t!=null),this.emptyError="",this.values={}}async reset(e){return await super.reset(),e===!0&&(this._index=this.index),this.index=this._index,this.values={},this.choices.forEach(t=>t.reset&&t.reset()),this.render()}dispatch(e){return!!e&&this.append(e)}append(e){let t=this.focused;if(!t)return this.alert();let{cursor:i,input:r}=t;return t.value=t.input=r.slice(0,i)+e+r.slice(i),t.cursor++,this.render()}delete(){let e=this.focused;if(!e||e.cursor<=0)return this.alert();let{cursor:t,input:i}=e;return e.value=e.input=i.slice(0,t-1)+i.slice(t),e.cursor--,this.render()}deleteForward(){let e=this.focused;if(!e)return this.alert();let{cursor:t,input:i}=e;if(i[t]===void 0)return this.alert();let r=`${i}`.slice(0,t)+`${i}`.slice(t+1);return e.value=e.input=r,this.render()}right(){let e=this.focused;return e?e.cursor>=e.input.length?this.alert():(e.cursor++,this.render()):this.alert()}left(){let e=this.focused;return e?e.cursor<=0?this.alert():(e.cursor--,this.render()):this.alert()}space(e,t){return this.dispatch(e,t)}number(e,t){return this.dispatch(e,t)}next(){let e=this.focused;if(!e)return this.alert();let{initial:t,input:i}=e;return t&&t.startsWith(i)&&i!==t?(e.value=e.input=t,e.cursor=e.value.length,this.render()):super.next()}prev(){let e=this.focused;return e?e.cursor===0?super.prev():(e.value=e.input="",e.cursor=0,this.render()):this.alert()}separator(){return""}format(e){return this.state.submitted?"":super.format(e)}pointer(){return""}indicator(e){return e.input?"\u29BF":"\u2299"}async choiceSeparator(e,t){let i=await this.resolve(e.separator,this.state,e,t)||":";return i?" "+this.styles.disabled(i):""}async renderChoice(e,t){await this.onChoice(e,t);let{state:i,styles:r}=this,{cursor:n,initial:l="",name:a,input:o=""}=e,{muted:h,submitted:c,primary:u,danger:v}=r,y=this.index===t,p=e.validate||(()=>!0),x=await this.choiceSeparator(e,t),E=e.message;this.align==="right"&&(E=E.padStart(this.longest+1," ")),this.align==="left"&&(E=E.padEnd(this.longest+1," "));let f=this.values[a]=o||l,w=o?"success":"dark";await p.call(e,f,this.state)!==!0&&(w="danger");let m=r[w],C=m(await this.indicator(e,t))+(e.pad||""),_=this.indent(e),A=()=>[_,C,E+x,o].filter(Boolean).join(" ");if(i.submitted)return E=Zs(E),o=c(o),A();if(e.format)o=await e.format.call(this,o,e,t);else{let tt=this.styles.muted;o=Js(this,{input:o,initial:l,pos:n,showCursor:y,color:tt})}return this.isValue(o)||(o=this.styles.muted(this.symbols.ellipsis)),e.result&&(this.values[a]=await e.result.call(this,f,e,t)),y&&(E=u(E)),e.error?o+=(o?" ":"")+v(e.error.trim()):e.hint&&(o+=(o?" ":"")+h(e.hint.trim())),A()}async submit(){return this.value=this.values,super.base.submit.call(this)}};Jt.exports=Pe});var $e=d((gn,Qt)=>{"use strict";var Xs=ne(),Qs=()=>{throw new Error("expected prompt to have a custom authenticate method")},Xt=(s=Qs)=>{class e extends Xs{constructor(i){super(i)}async submit(){this.value=await s.call(this,this.values,this.state),super.base.submit.call(this)}static create(i){return Xt(i)}}return e};Qt.exports=Xt()});var ii=d((yn,ti)=>{"use strict";var er=$e();function tr(s,e){return s.username===this.options.username&&s.password===this.options.password}var ei=(s=tr)=>{let e=[{name:"username",message:"username"},{name:"password",message:"password",format(i){return this.options.showPassword?i:(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(i.length))}}];class t extends er.create(s){constructor(r){super({...r,choices:e})}static create(r){return ei(r)}}return t};ti.exports=ei()});var le=d((wn,si)=>{"use strict";var ir=U(),{isPrimitive:sr,hasColor:rr}=k(),Oe=class extends ir{constructor(e){super(e),this.cursorHide()}async initialize(){let e=await this.resolve(this.initial,this.state);this.input=await this.cast(e),await super.initialize()}dispatch(e){return this.isValue(e)?(this.input=e,this.submit()):this.alert()}format(e){let{styles:t,state:i}=this;return i.submitted?t.success(e):t.primary(e)}cast(e){return this.isTrue(e)}isTrue(e){return/^[ty1]/i.test(e)}isFalse(e){return/^[fn0]/i.test(e)}isValue(e){return sr(e)&&(this.isTrue(e)||this.isFalse(e))}async hint(){if(this.state.status==="pending"){let e=await this.element("hint");return rr(e)?e:this.styles.muted(e)}}async render(){let{input:e,size:t}=this.state,i=await this.prefix(),r=await this.separator(),n=await this.message(),l=this.styles.muted(this.default),a=[i,n,l,r].filter(Boolean).join(" ");this.state.prompt=a;let o=await this.header(),h=this.value=this.cast(e),c=await this.format(h),u=await this.error()||await this.hint(),v=await this.footer();u&&!a.includes(u)&&(c+=" "+u),a+=" "+c,this.clear(t),this.write([o,a,v].filter(Boolean).join(`
14
+ `)),this.restore()}set value(e){super.value=e}get value(){return this.cast(super.value)}};si.exports=Oe});var ni=d((bn,ri)=>{"use strict";var nr=le(),Ie=class extends nr{constructor(e){super(e),this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}};ri.exports=Ie});var ai=d((vn,li)=>{"use strict";var lr=T(),ar=ne(),N=ar.prototype,je=class extends lr{constructor(e){super({...e,multiple:!0}),this.align=[this.options.align,"left"].find(t=>t!=null),this.emptyError="",this.values={}}dispatch(e,t){let i=this.focused,r=i.parent||{};return!i.editable&&!r.editable&&(e==="a"||e==="i")?super[e]():N.dispatch.call(this,e,t)}append(e,t){return N.append.call(this,e,t)}delete(e,t){return N.delete.call(this,e,t)}space(e){return this.focused.editable?this.append(e):super.space()}number(e){return this.focused.editable?this.append(e):super.number(e)}next(){return this.focused.editable?N.next.call(this):super.next()}prev(){return this.focused.editable?N.prev.call(this):super.prev()}async indicator(e,t){let i=e.indicator||"",r=e.editable?i:super.indicator(e,t);return await this.resolve(r,this.state,e,t)||""}indent(e){return e.role==="heading"?"":e.editable?" ":" "}async renderChoice(e,t){return e.indent="",e.editable?N.renderChoice.call(this,e,t):super.renderChoice(e,t)}error(){return""}footer(){return this.state.error}async validate(){let e=!0;for(let t of this.choices){if(typeof t.validate!="function"||t.role==="heading")continue;let i=t.parent?this.value[t.parent.name]:this.value;if(t.editable?i=t.value===t.name?t.initial||"":t.value:this.isDisabled(t)||(i=t.enabled===!0),e=await t.validate(i,this.state),e!==!0)break}return e!==!0&&(this.state.error=typeof e=="string"?e:"Invalid Input"),e}submit(){if(this.focused.newChoice===!0)return super.submit();if(this.choices.some(e=>e.newChoice))return this.alert();this.value={};for(let e of this.choices){let t=e.parent?this.value[e.parent.name]:this.value;if(e.role==="heading"){this.value[e.name]={};continue}e.editable?t[e.name]=e.value===e.name?e.initial||"":e.value:this.isDisabled(e)||(t[e.name]=e.enabled===!0)}return this.base.submit.call(this)}};li.exports=je});var z=d((xn,oi)=>{"use strict";var or=U(),hr=de(),ur=Ae(),{isPrimitive:cr}=k(),De=class extends or{constructor(e){super(e),this.initial=cr(this.initial)?String(this.initial):"",this.initial&&this.cursorHide(),this.state.prevCursor=0,this.state.clipboard=[],this.keypressTimeout=this.options.keypressTimeout!==void 0?this.options.keypressTimeout:null}async keypress(e,t=e?hr(e,{}):{}){let i=Date.now(),r=i-this.lastKeypress;this.lastKeypress=i;let n=t.name==="return"||t.name==="enter",l=this.state.prevKeypress,a;if(this.state.prevKeypress=t,this.keypressTimeout!=null&&n){if(r<this.keypressTimeout)return this.submit();this.state.multilineBuffer=this.state.multilineBuffer||"",this.state.multilineBuffer+=e,a=!0,l=null}return(a||this.options.multiline&&n)&&(!l||l.name!=="return")?this.append(`
15
15
  `,t):super.keypress(e,t)}moveCursor(e){this.cursor+=e}reset(){return this.input=this.value="",this.cursor=0,this.render()}dispatch(e,t){if(!e||t.ctrl||t.code)return this.alert();this.append(e)}append(e){let{cursor:t,input:i}=this.state;this.input=`${i}`.slice(0,t)+e+`${i}`.slice(t),this.moveCursor(String(e).length),this.render()}insert(e){this.append(e)}delete(){let{cursor:e,input:t}=this.state;if(e<=0)return this.alert();this.input=`${t}`.slice(0,e-1)+`${t}`.slice(e),this.moveCursor(-1),this.render()}deleteForward(){let{cursor:e,input:t}=this.state;if(t[e]===void 0)return this.alert();this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.render()}cutForward(){let e=this.cursor;if(this.input.length<=e)return this.alert();this.state.clipboard.push(this.input.slice(e)),this.input=this.input.slice(0,e),this.render()}cutLeft(){let e=this.cursor;if(e===0)return this.alert();let t=this.input.slice(0,e),i=this.input.slice(e),r=t.split(" ");this.state.clipboard.push(r.pop()),this.input=r.join(" "),this.cursor=this.input.length,this.input+=i,this.render()}paste(){if(!this.state.clipboard.length)return this.alert();this.insert(this.state.clipboard.pop()),this.render()}toggleCursor(){this.state.prevCursor?(this.cursor=this.state.prevCursor,this.state.prevCursor=0):(this.state.prevCursor=this.cursor,this.cursor=0),this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.input.length-1,this.render()}next(){let e=this.initial!=null?String(this.initial):"";if(!e||!e.startsWith(this.input))return this.alert();this.input=this.initial,this.cursor=this.initial.length,this.render()}prev(){if(!this.input)return this.alert();this.reset()}backward(){return this.left()}forward(){return this.right()}right(){return this.cursor>=this.input.length?this.alert():(this.moveCursor(1),this.render())}left(){return this.cursor<=0?this.alert():(this.moveCursor(-1),this.render())}isValue(e){return!!e}async format(e=this.value){let t=await this.resolve(this.initial,this.state);return this.state.submitted?this.styles.submitted(e||t):ur(this,{input:e,initial:t,pos:this.cursor})}async render(){let e=this.state.size,t=await this.prefix(),i=await this.separator(),r=await this.message(),n=[t,r,i].filter(Boolean).join(" ");this.state.prompt=n;let l=await this.header(),a=await this.format(),o=await this.error()||await this.hint(),h=await this.footer();o&&!a.includes(o)&&(a+=" "+o),n+=" "+a,this.clear(e),this.write([l,n,h].filter(Boolean).join(`
16
16
  `)),this.restore()}};oi.exports=De});var ui=d((Cn,hi)=>{"use strict";var dr=s=>s.filter((e,t)=>s.lastIndexOf(e)===t),ae=s=>dr(s).filter(Boolean);hi.exports=(s,e={},t="")=>{let{past:i=[],present:r=""}=e,n,l;switch(s){case"prev":case"undo":return n=i.slice(0,i.length-1),l=i[i.length-1]||"",{past:ae([t,...n]),present:l};case"next":case"redo":return n=i.slice(1),l=i[0]||"",{past:ae([...n,t]),present:l};case"save":return{past:ae([...i,t]),present:""};case"remove":return l=ae(i.filter(a=>a!==t)),r="",l.length&&(r=l.pop()),{past:l,present:r};default:throw new Error(`Invalid action: "${s}"`)}}});var Te=d((En,di)=>{"use strict";var pr=z(),ci=ui(),Be=class extends pr{constructor(e){super(e);let t=this.options.history;if(t&&t.store){let i=t.values||this.initial;this.autosave=!!t.autosave,this.store=t.store,this.data=this.store.get("values")||{past:[],present:i},this.initial=this.data.present||this.data.past[this.data.past.length-1]}}completion(e){return this.store?(this.data=ci(e,this.data,this.input),this.data.present?(this.input=this.data.present,this.cursor=this.input.length,this.render()):this.alert()):this.alert()}altUp(){return this.completion("prev")}altDown(){return this.completion("next")}prev(){return this.save(),super.prev()}save(){this.store&&(this.data=ci("save",this.data,this.input),this.store.set("values",this.data))}submit(){return this.store&&this.autosave===!0&&this.save(),super.submit()}};di.exports=Be});var fi=d((Sn,pi)=>{"use strict";var fr=z(),Me=class extends fr{format(){return""}};pi.exports=Me});var gi=d((Rn,mi)=>{"use strict";var mr=z(),Le=class extends mr{constructor(e={}){super(e),this.sep=this.options.separator||/, */,this.initial=e.initial||""}split(e=this.value){return e?String(e).split(this.sep):[]}format(){let e=this.state.submitted?this.styles.primary:t=>t;return this.list.map(e).join(", ")}async submit(e){let t=this.state.error||await this.validate(this.list,this.state);return t!==!0?(this.state.error=t,super.submit()):(this.value=this.list,super.submit())}get list(){return this.split()}};mi.exports=Le});var wi=d((kn,yi)=>{"use strict";var gr=T(),Ve=class extends gr{constructor(e){super({...e,multiple:!0})}};yi.exports=Ve});var Ke=d((_n,bi)=>{"use strict";var yr=z(),ze=class extends yr{constructor(e={}){super({style:"number",...e}),this.min=this.isValue(e.min)?this.toNumber(e.min):-1/0,this.max=this.isValue(e.max)?this.toNumber(e.max):1/0,this.delay=e.delay!=null?e.delay:1e3,this.float=e.float!==!1,this.round=e.round===!0||e.float===!1,this.major=e.major||10,this.minor=e.minor||1,this.initial=e.initial!=null?e.initial:"",this.input=String(this.initial),this.cursor=this.input.length,this.cursorShow()}append(e){return!/[-+.]/.test(e)||e==="."&&this.input.includes(".")?this.alert("invalid number"):super.append(e)}number(e){return super.append(e)}next(){return this.input&&this.input!==this.initial?this.alert():this.isValue(this.initial)?(this.input=this.initial,this.cursor=String(this.initial).length,this.render()):this.alert()}up(e){let t=e||this.minor,i=this.toNumber(this.input);return i>this.max+t?this.alert():(this.input=`${i+t}`,this.render())}down(e){let t=e||this.minor,i=this.toNumber(this.input);return i<this.min-t?this.alert():(this.input=`${i-t}`,this.render())}shiftDown(){return this.down(this.major)}shiftUp(){return this.up(this.major)}format(e=this.input){return typeof this.options.format=="function"?this.options.format.call(this,e):this.styles.info(e)}toNumber(e=""){return this.float?+e:Math.round(+e)}isValue(e){return/^[-+]?[0-9]+((\.)|(\.[0-9]+))?$/.test(e)}submit(){let e=[this.input,this.initial].find(t=>this.isValue(t));return this.value=this.toNumber(e||0),super.submit()}};bi.exports=ze});var xi=d((qn,vi)=>{vi.exports=Ke()});var Ei=d((An,Ci)=>{"use strict";var wr=z(),We=class extends wr{constructor(e){super(e),this.cursorShow()}format(e=this.input){return this.keypressed?(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(e.length)):""}};Ci.exports=We});var ki=d((Pn,Ri)=>{"use strict";var br=D(),vr=Z(),Si=k(),Ue=class extends vr{constructor(e={}){super(e),this.widths=[].concat(e.messageWidth||50),this.align=[].concat(e.align||"left"),this.linebreak=e.linebreak||!1,this.edgeLength=e.edgeLength||3,this.newline=e.newline||`
17
17
  `;let t=e.startNumber||1;typeof this.scale=="number"&&(this.scaleKey=!1,this.scale=Array(this.scale).fill(0).map((i,r)=>({name:r+t})))}async reset(){return this.tableized=!1,await super.reset(),this.render()}tableize(){if(this.tableized===!0)return;this.tableized=!0;let e=0;for(let t of this.choices){e=Math.max(e,t.message.length),t.scaleIndex=t.initial||2,t.scale=[];for(let i=0;i<this.scale.length;i++)t.scale.push({index:i})}this.widths[0]=Math.min(this.widths[0],e+3)}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}heading(e,t,i){return this.styles.strong(e)}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;return e.scaleIndex>=this.scale.length-1?this.alert():(e.scaleIndex++,this.render())}left(){let e=this.focused;return e.scaleIndex<=0?this.alert():(e.scaleIndex--,this.render())}indent(){return""}format(){return this.state.submitted?this.choices.map(t=>this.styles.info(t.index)).join(", "):""}pointer(){return""}renderScaleKey(){return this.scaleKey===!1||this.state.submitted?"":["",...this.scale.map(i=>` ${i.name} - ${i.message}`)].map(i=>this.styles.muted(i)).join(`
@@ -19,16 +19,16 @@ var rs=Object.create;var it=Object.defineProperty;var ns=Object.getOwnPropertyDe
19
19
  `).map(p=>l(p)+this.margin[1]);return i&&(c=this.styles.info(c),y=y.map(p=>this.styles.info(p))),y[0]+=c,this.linebreak&&y.push(""),[o+r,y.join(`
20
20
  `)].filter(Boolean)}async renderChoices(){if(this.state.submitted)return"";this.tableize();let e=this.visible.map(async(r,n)=>await this.renderChoice(r,n)),t=await Promise.all(e),i=await this.renderScaleHeading();return this.margin[0]+[i,...t.map(r=>r.join(" "))].join(`
21
21
  `)}async render(){let{submitted:e,size:t}=this.state,i=await this.prefix(),r=await this.separator(),n=await this.message(),l="";this.options.promptLine!==!1&&(l=[i,n,r,""].join(" "),this.state.prompt=l);let a=await this.header(),o=await this.format(),h=await this.renderScaleKey(),c=await this.error()||await this.hint(),u=await this.renderChoices(),v=await this.footer(),y=this.emptyError;o&&(l+=o),c&&!l.includes(c)&&(l+=" "+c),e&&!o&&!u.trim()&&this.multiple&&y!=null&&(l+=this.styles.danger(y)),this.clear(t),this.write([a,l,h,u,v].filter(Boolean).join(`
22
- `)),this.state.submitted||this.write(this.margin[2]),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIndex;return this.base.submit.call(this)}};Ri.exports=Ue});var Ai=d((On,qi)=>{"use strict";var _i=D(),xr=(s="")=>typeof s=="string"?s.replace(/^['"]|['"]$/g,""):"",Fe=class{constructor(e){this.name=e.key,this.field=e.field||{},this.value=xr(e.initial||this.field.initial||""),this.message=e.message||this.name,this.cursor=0,this.input="",this.lines=[]}},Cr=async(s={},e={},t=i=>i)=>{let i=new Set,r=s.fields||[],n=s.template,l=[],a=[],o=[],h=1;typeof n=="function"&&(n=await n());let c=-1,u=()=>n[++c],v=()=>n[c+1],y=p=>{p.line=h,l.push(p)};for(y({type:"bos",value:""});c<n.length-1;){let p=u();if(/^[^\S\n ]$/.test(p)){y({type:"text",value:p});continue}if(p===`
22
+ `)),this.state.submitted||this.write(this.margin[2]),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIndex;return this.base.submit.call(this)}};Ri.exports=Ue});var Ai=d(($n,qi)=>{"use strict";var _i=D(),xr=(s="")=>typeof s=="string"?s.replace(/^['"]|['"]$/g,""):"",Fe=class{constructor(e){this.name=e.key,this.field=e.field||{},this.value=xr(e.initial||this.field.initial||""),this.message=e.message||this.name,this.cursor=0,this.input="",this.lines=[]}},Cr=async(s={},e={},t=i=>i)=>{let i=new Set,r=s.fields||[],n=s.template,l=[],a=[],o=[],h=1;typeof n=="function"&&(n=await n());let c=-1,u=()=>n[++c],v=()=>n[c+1],y=p=>{p.line=h,l.push(p)};for(y({type:"bos",value:""});c<n.length-1;){let p=u();if(/^[^\S\n ]$/.test(p)){y({type:"text",value:p});continue}if(p===`
23
23
  `){y({type:"newline",value:p}),h++;continue}if(p==="\\"){p+=u(),y({type:"text",value:p});continue}if((p==="$"||p==="#"||p==="{")&&v()==="{"){let E=u();p+=E;let f={type:"template",open:p,inner:"",close:"",value:p},w;for(;w=u();){if(w==="}"){v()==="}"&&(w+=u()),f.value+=w,f.close=w;break}w===":"?(f.initial="",f.key=f.inner):f.initial!==void 0&&(f.initial+=w),f.value+=w,f.inner+=w}f.template=f.open+(f.initial||f.inner)+f.close,f.key=f.key||f.inner,hasOwnProperty.call(e,f.key)&&(f.initial=e[f.key]),f=t(f),y(f),o.push(f.key),i.add(f.key);let m=a.find(C=>C.name===f.key);f.field=r.find(C=>C.name===f.key),m||(m=new Fe(f),a.push(m)),m.lines.push(f.line-1);continue}let x=l[l.length-1];x.type==="text"&&x.line===h?x.value+=p:y({type:"text",value:p})}return y({type:"eos",value:""}),{input:n,tabstops:l,unique:i,keys:o,items:a}};qi.exports=async s=>{let e=s.options,t=new Set(e.required===!0?[]:e.required||[]),i={...e.values,...e.initial},{tabstops:r,items:n,keys:l}=await Cr(e,i),a=Ne("result",s,e),o=Ne("format",s,e),h=Ne("validate",s,e,!0),c=s.isValue.bind(s);return async(u={},v=!1)=>{let y=0;u.required=t,u.items=n,u.keys=l,u.output="";let p=async(w,m,C,_)=>{let A=await h(w,m,C,_);return A===!1?"Invalid field "+C.name:A};for(let w of r){let m=w.value,C=w.key;if(w.type!=="template"){m&&(u.output+=m);continue}if(w.type==="template"){let _=n.find(K=>K.name===C);e.required===!0&&u.required.add(_.name);let A=[_.input,u.values[_.value],_.value,m].find(c),F=(_.field||{}).message||w.inner;if(v){let K=await p(u.values[C],u,_,y);if(K&&typeof K=="string"||K===!1){u.invalid.set(C,K);continue}u.invalid.delete(C);let ss=await a(u.values[C],u,_,y);u.output+=_i(ss);continue}_.placeholder=!1;let is=m;m=await o(m,u,_,y),A!==m?(u.values[C]=A,m=s.styles.typing(A),u.missing.delete(F)):(u.values[C]=void 0,A=`<${F}>`,m=s.styles.primary(A),_.placeholder=!0,u.required.has(C)&&u.missing.add(F)),u.missing.has(F)&&u.validating&&(m=s.styles.warning(A)),u.invalid.has(C)&&u.validating&&(m=s.styles.danger(A)),y===u.index&&(is!==m?m=s.styles.underline(m):m=s.styles.heading(_i(m))),y++}m&&(u.output+=m)}let x=u.output.split(`
24
24
  `).map(w=>" "+w),E=n.length,f=0;for(let w of n)u.invalid.has(w.name)&&w.lines.forEach(m=>{x[m][0]===" "&&(x[m]=u.styles.danger(u.symbols.bullet)+x[m].slice(1))}),s.isValue(u.values[w.name])&&f++;return u.completed=(f/E*100).toFixed(0),u.output=x.join(`
25
- `),u.output}};function Ne(s,e,t,i){return(r,n,l,a)=>typeof l.field[s]=="function"?l.field[s].call(e,r,n,l,a):[i,r].find(o=>e.isValue(o))}});var Oi=d(($n,Pi)=>{"use strict";var Er=D(),Sr=Ai(),Rr=U(),He=class extends Rr{constructor(e){super(e),this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await Sr(this),await super.initialize()}async reset(e){this.state.keys=[],this.state.invalid=new Map,this.state.missing=new Set,this.state.completed=0,this.state.values={},e!==!0&&(await this.initialize(),await this.render())}moveCursor(e){let t=this.getItem();this.cursor+=e,t.cursor+=e}dispatch(e,t){if(!t.code&&!t.ctrl&&e!=null&&this.getItem()){this.append(e,t);return}this.alert()}append(e,t){let i=this.getItem(),r=i.input.slice(0,this.cursor),n=i.input.slice(this.cursor);this.input=i.input=`${r}${e}${n}`,this.moveCursor(1),this.render()}delete(){let e=this.getItem();if(this.cursor<=0||!e.input)return this.alert();let t=e.input.slice(this.cursor),i=e.input.slice(0,this.cursor-1);this.input=e.input=`${i}${t}`,this.moveCursor(-1),this.render()}increment(e){return e>=this.state.keys.length-1?0:e+1}decrement(e){return e<=0?this.state.keys.length-1:e-1}first(){this.state.index=0,this.render()}last(){this.state.index=this.state.keys.length-1,this.render()}right(){if(this.cursor>=this.input.length)return this.alert();this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();this.moveCursor(-1),this.render()}prev(){this.state.index=this.decrement(this.state.index),this.getItem(),this.render()}next(){this.state.index=this.increment(this.state.index),this.getItem(),this.render()}up(){this.prev()}down(){this.next()}format(e){let t=this.state.completed<100?this.styles.warning:this.styles.success;return this.state.submitted===!0&&this.state.completed!==100&&(t=this.styles.danger),t(`${this.state.completed}% completed`)}async render(){let{index:e,keys:t=[],submitted:i,size:r}=this.state,n=[this.options.newline,`
25
+ `),u.output}};function Ne(s,e,t,i){return(r,n,l,a)=>typeof l.field[s]=="function"?l.field[s].call(e,r,n,l,a):[i,r].find(o=>e.isValue(o))}});var $i=d((On,Pi)=>{"use strict";var Er=D(),Sr=Ai(),Rr=U(),He=class extends Rr{constructor(e){super(e),this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await Sr(this),await super.initialize()}async reset(e){this.state.keys=[],this.state.invalid=new Map,this.state.missing=new Set,this.state.completed=0,this.state.values={},e!==!0&&(await this.initialize(),await this.render())}moveCursor(e){let t=this.getItem();this.cursor+=e,t.cursor+=e}dispatch(e,t){if(!t.code&&!t.ctrl&&e!=null&&this.getItem()){this.append(e,t);return}this.alert()}append(e,t){let i=this.getItem(),r=i.input.slice(0,this.cursor),n=i.input.slice(this.cursor);this.input=i.input=`${r}${e}${n}`,this.moveCursor(1),this.render()}delete(){let e=this.getItem();if(this.cursor<=0||!e.input)return this.alert();let t=e.input.slice(this.cursor),i=e.input.slice(0,this.cursor-1);this.input=e.input=`${i}${t}`,this.moveCursor(-1),this.render()}increment(e){return e>=this.state.keys.length-1?0:e+1}decrement(e){return e<=0?this.state.keys.length-1:e-1}first(){this.state.index=0,this.render()}last(){this.state.index=this.state.keys.length-1,this.render()}right(){if(this.cursor>=this.input.length)return this.alert();this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();this.moveCursor(-1),this.render()}prev(){this.state.index=this.decrement(this.state.index),this.getItem(),this.render()}next(){this.state.index=this.increment(this.state.index),this.getItem(),this.render()}up(){this.prev()}down(){this.next()}format(e){let t=this.state.completed<100?this.styles.warning:this.styles.success;return this.state.submitted===!0&&this.state.completed!==100&&(t=this.styles.danger),t(`${this.state.completed}% completed`)}async render(){let{index:e,keys:t=[],submitted:i,size:r}=this.state,n=[this.options.newline,`
26
26
  `].find(w=>w!=null),l=await this.prefix(),a=await this.separator(),o=await this.message(),h=[l,o,a].filter(Boolean).join(" ");this.state.prompt=h;let c=await this.header(),u=await this.error()||"",v=await this.hint()||"",y=i?"":await this.interpolate(this.state),p=this.state.key=t[e]||"",x=await this.format(p),E=await this.footer();x&&(h+=" "+x),v&&!x&&this.state.completed===0&&(h+=" "+v),this.clear(r);let f=[c,h,y,E,u.trim()];this.write(f.filter(Boolean).join(n)),this.restore()}getItem(e){let{items:t,keys:i,index:r}=this.state,n=t.find(l=>l.name===i[r]);return n&&n.input!=null&&(this.input=n.input,this.cursor=n.cursor),n}async submit(){typeof this.interpolate!="function"&&await this.initialize(),await this.interpolate(this.state,!0);let{invalid:e,missing:t,output:i,values:r}=this.state;if(e.size){let a="";for(let[o,h]of e)a+=`Invalid ${o}: ${h}
27
27
  `;return this.state.error=a,super.submit()}if(t.size)return this.state.error="Required: "+[...t.keys()].join(", "),super.submit();let l=Er(i).split(`
28
28
  `).map(a=>a.slice(1)).join(`
29
- `);return this.value={values:r,result:l},super.submit()}};Pi.exports=He});var Ii=d((In,$i)=>{"use strict";var kr="(Use <shift>+<up/down> to sort)",_r=T(),Ge=class extends _r{constructor(e){super({...e,reorder:!1,sort:!0,multiple:!0}),this.state.hint=[this.options.hint,kr].find(this.isValue.bind(this))}indicator(){return""}async renderChoice(e,t){let i=await super.renderChoice(e,t),r=this.symbols.identicalTo+" ",n=this.index===t&&this.sorting?this.styles.muted(r):" ";return this.options.drag===!1&&(n=""),this.options.numbered===!0?n+`${t+1} - `+i:n+i}get selected(){return this.choices}submit(){return this.value=this.choices.map(e=>e.value),super.submit()}};$i.exports=Ge});var Di=d((jn,ji)=>{"use strict";var qr=Z(),Ze=class extends qr{constructor(e={}){if(super(e),this.emptyError=e.emptyError||"No items were selected",this.term=process.env.TERM_PROGRAM,!this.options.header){let t=["","4 - Strongly Agree","3 - Agree","2 - Neutral","1 - Disagree","0 - Strongly Disagree",""];t=t.map(i=>this.styles.muted(i)),this.state.header=t.join(`
29
+ `);return this.value={values:r,result:l},super.submit()}};Pi.exports=He});var Ii=d((In,Oi)=>{"use strict";var kr="(Use <shift>+<up/down> to sort)",_r=T(),Ge=class extends _r{constructor(e){super({...e,reorder:!1,sort:!0,multiple:!0}),this.state.hint=[this.options.hint,kr].find(this.isValue.bind(this))}indicator(){return""}async renderChoice(e,t){let i=await super.renderChoice(e,t),r=this.symbols.identicalTo+" ",n=this.index===t&&this.sorting?this.styles.muted(r):" ";return this.options.drag===!1&&(n=""),this.options.numbered===!0?n+`${t+1} - `+i:n+i}get selected(){return this.choices}submit(){return this.value=this.choices.map(e=>e.value),super.submit()}};Oi.exports=Ge});var Di=d((jn,ji)=>{"use strict";var qr=Z(),Ze=class extends qr{constructor(e={}){if(super(e),this.emptyError=e.emptyError||"No items were selected",this.term=process.env.TERM_PROGRAM,!this.options.header){let t=["","4 - Strongly Agree","3 - Agree","2 - Neutral","1 - Disagree","0 - Strongly Disagree",""];t=t.map(i=>this.styles.muted(i)),this.state.header=t.join(`
30
30
  `)}}async toChoices(...e){if(this.createdScales)return!1;this.createdScales=!0;let t=await super.toChoices(...e);for(let i of t)i.scale=Ar(5,this.options),i.scaleIdx=2;return t}dispatch(){this.alert()}space(){let e=this.focused,t=e.scale[e.scaleIdx],i=t.selected;return e.scale.forEach(r=>r.selected=!1),t.selected=!i,this.render()}indicator(){return""}pointer(){return""}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;return e.scaleIdx>=e.scale.length-1?this.alert():(e.scaleIdx++,this.render())}left(){let e=this.focused;return e.scaleIdx<=0?this.alert():(e.scaleIdx--,this.render())}indent(){return" "}async renderChoice(e,t){await this.onChoice(e,t);let i=this.index===t,r=this.term==="Hyper",n=r?9:8,l=r?"":" ",a=this.symbols.line.repeat(n),o=" ".repeat(n+(r?0:1)),h=m=>(m?this.styles.success("\u25C9"):"\u25EF")+l,c=t+1+".",u=i?this.styles.heading:this.styles.noop,v=await this.resolve(e.message,this.state,e,t),y=this.indent(e),p=y+e.scale.map((m,C)=>h(C===e.scaleIdx)).join(a),x=m=>m===e.scaleIdx?u(m):m,E=y+e.scale.map((m,C)=>x(C)).join(o),f=()=>[c,v].filter(Boolean).join(" "),w=()=>[f(),p,E," "].filter(Boolean).join(`
31
31
  `);return i&&(p=this.styles.cyan(p),E=this.styles.cyan(E)),w()}async renderChoices(){if(this.state.submitted)return"";let e=this.visible.map(async(i,r)=>await this.renderChoice(i,r)),t=await Promise.all(e);return t.length||t.push(this.styles.danger("No matching choices")),t.join(`
32
32
  `)}format(){return this.state.submitted?this.choices.map(t=>this.styles.info(t.scaleIdx)).join(", "):""}async render(){let{submitted:e,size:t}=this.state,i=await this.prefix(),r=await this.separator(),n=await this.message(),l=[i,n,r].filter(Boolean).join(" ");this.state.prompt=l;let a=await this.header(),o=await this.format(),h=await this.error()||await this.hint(),c=await this.renderChoices(),u=await this.footer();(o||!h)&&(l+=" "+o),h&&!l.includes(h)&&(l+=" "+h),e&&!o&&!c&&this.multiple&&this.type!=="form"&&(l+=this.styles.danger(this.emptyError)),this.clear(t),this.write([l,a,c,u].filter(Boolean).join(`
33
33
  `)),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIdx;return this.base.submit.call(this)}};function Ar(s,e={}){if(Array.isArray(e.scale))return e.scale.map(i=>({...i}));let t=[];for(let i=1;i<s+1;i++)t.push({i,selected:!1});return t}ji.exports=Ze});var Ti=d((Dn,Bi)=>{Bi.exports=Te()});var Li=d((Bn,Mi)=>{"use strict";var Pr=le(),Ye=class extends Pr{async initialize(){await super.initialize(),this.value=this.initial=this.resolve(this.options.initial),this.disabled=this.options.disabled||"no",this.enabled=this.options.enabled||"yes",await this.render()}reset(){this.value=this.initial,this.render()}delete(){this.alert()}toggle(){this.value=!this.value,this.render()}enable(){if(this.value===!0)return this.alert();this.value=!0,this.render()}disable(){if(this.value===!1)return this.alert();this.value=!1,this.render()}up(){this.toggle()}down(){this.toggle()}right(){this.toggle()}left(){this.toggle()}next(){this.toggle()}prev(){this.toggle()}dispatch(e="",t){switch(e.toLowerCase()){case" ":return this.toggle();case"1":case"y":case"t":return this.enable();case"0":case"n":case"f":return this.disable();default:return this.alert()}}format(){let e=i=>this.styles.primary.underline(i);return[this.value?this.disabled:e(this.disabled),this.value?e(this.enabled):this.enabled].join(this.styles.muted(" / "))}async render(){let{size:e}=this.state,t=await this.header(),i=await this.prefix(),r=await this.separator(),n=await this.message(),l=await this.format(),a=await this.error()||await this.hint(),o=await this.footer(),h=[i,n,r,l].join(" ");this.state.prompt=h,a&&!h.includes(a)&&(h+=" "+a),this.clear(e),this.write([t,h,o].filter(Boolean).join(`
34
- `)),this.write(this.margin[2]),this.restore()}};Mi.exports=Ye});var zi=d((Tn,Vi)=>{"use strict";var Or=T(),Je=class extends Or{constructor(e){if(super(e),typeof this.options.correctChoice!="number"||this.options.correctChoice<0)throw new Error("Please specify the index of the correct answer from the list of choices")}async toChoices(e,t){let i=await super.toChoices(e,t);if(i.length<2)throw new Error("Please give at least two choices to the user");if(this.options.correctChoice>i.length)throw new Error("Please specify the index of the correct answer from the list of choices");return i}check(e){return e.index===this.options.correctChoice}async result(e){return{selectedAnswer:e,correctAnswer:this.options.choices[this.options.correctChoice].value,correct:await this.check(this.state)}}};Vi.exports=Je});var Wi=d(Xe=>{"use strict";var Ki=k(),S=(s,e)=>{Ki.defineExport(Xe,s,e),Ki.defineExport(Xe,s.toLowerCase(),e)};S("AutoComplete",()=>Zt());S("BasicAuth",()=>ii());S("Confirm",()=>ni());S("Editable",()=>ai());S("Form",()=>ne());S("Input",()=>Te());S("Invisible",()=>fi());S("List",()=>gi());S("MultiSelect",()=>wi());S("Numeral",()=>xi());S("Password",()=>Ei());S("Scale",()=>ki());S("Select",()=>T());S("Snippet",()=>Oi());S("Sort",()=>Ii());S("Survey",()=>Di());S("Text",()=>Ti());S("Toggle",()=>Li());S("Quiz",()=>zi())});var Ni=d((Ln,Ui)=>{Ui.exports={ArrayPrompt:Z(),AuthPrompt:Oe(),BooleanPrompt:le(),NumberPrompt:Ke(),StringPrompt:z()}});var Gi=d((Vn,Hi)=>{"use strict";var Fi=J("assert"),et=J("events"),M=k(),$=class extends et{constructor(e,t){super(),this.options=M.merge({},e),this.answers={...t}}register(e,t){if(M.isObject(e)){for(let r of Object.keys(e))this.register(r,e[r]);return this}Fi.equal(typeof t,"function","expected a function");let i=e.toLowerCase();return t.prototype instanceof this.Prompt?this.prompts[i]=t:this.prompts[i]=t(this.Prompt,this),this}async prompt(e=[]){for(let t of[].concat(e))try{typeof t=="function"&&(t=await t.call(this)),await this.ask(M.merge({},this.options,t))}catch(i){return Promise.reject(i)}return this.answers}async ask(e){typeof e=="function"&&(e=await e.call(this));let t=M.merge({},this.options,e),{type:i,name:r}=e,{set:n,get:l}=M;if(typeof i=="function"&&(i=await i.call(this,e,this.answers)),!i)return this.answers[r];i==="number"&&(i="numeral"),Fi(this.prompts[i],`Prompt "${i}" is not registered`);let a=new this.prompts[i](t),o=l(this.answers,r);a.state.answers=this.answers,a.enquirer=this,r&&a.on("submit",c=>{this.emit("answer",r,c,a),n(this.answers,r,c)});let h=a.emit.bind(a);return a.emit=(...c)=>(this.emit.call(this,...c),h(...c)),this.emit("prompt",a,this),t.autofill&&o!=null?(a.value=a.input=o,t.autofill==="show"&&await a.submit()):o=a.value=await a.run(),o}use(e){return e.call(this,this),this}set Prompt(e){this._Prompt=e}get Prompt(){return this._Prompt||this.constructor.Prompt}get prompts(){return this.constructor.prompts}static set Prompt(e){this._Prompt=e}static get Prompt(){return this._Prompt||U()}static get prompts(){return Wi()}static get types(){return Ni()}static get prompt(){let e=(t,...i)=>{let r=new this(...i),n=r.emit.bind(r);return r.emit=(...l)=>(e.emit(...l),n(...l)),r.prompt(t)};return M.mixinEmitter(e,new et),e}};M.mixinEmitter($,new et);var Qe=$.prompts;for(let s of Object.keys(Qe)){let e=s.toLowerCase(),t=i=>new Qe[s](i).run();$.prompt[e]=t,$[e]=t,$[s]||Reflect.defineProperty($,s,{get:()=>Qe[s]})}var Y=s=>{M.defineExport($,s,()=>$.types[s])};Y("ArrayPrompt");Y("AuthPrompt");Y("BooleanPrompt");Y("NumberPrompt");Y("StringPrompt");Hi.exports=$});var oe=["ASSIST_REVIEW_PROVIDER","ASSIST_REVIEW_BASE_URL","ASSIST_REVIEW_CLAUDE_MODEL","ASSIST_REVIEW_CODEX_MODEL"],I="ASSIST_REVIEW_API_KEY",X=[...oe,I],Q=["litellm"];function st(s,e){if(s==="litellm")return{anthropic:e,responses:`${e}/v1`};throw new Error(`Unsupported ASSIST_REVIEW_PROVIDER "${s}" (expected one of: ${Q.join(", ")})`)}async function he(s,e,t){try{let i=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",...e},body:JSON.stringify(t),signal:AbortSignal.timeout(6e4)});if(i.ok)return;let r=(await i.text()).trim().slice(0,300);return`HTTP ${i.status}${r?`: ${r}`:""}`}catch(i){if(!(i instanceof Error))return String(i);let r=i.cause instanceof Error?i.cause.message:"";return r?`${i.message} (${r})`:i.message}}async function rt(s,e){let t={Authorization:`Bearer ${s.apiKey}`},i=`${e.anthropic}/v1/messages`,r=`${e.responses}/responses`,[n,l]=await Promise.all([he(i,{...t,"x-api-key":s.apiKey,"anthropic-version":"2023-06-01"},{model:s.claudeModel,max_tokens:1,messages:[{role:"user",content:"ping"}]}),he(r,t,{model:s.codexModel,input:"ping",max_output_tokens:16})]);return[...n?[`Claude model "${s.claudeModel}" at ${i}: ${n}`]:[],...l?[`Codex model "${s.codexModel}" at ${r}: ${l}`]:[]]}function nt(s){let e=i=>s[i]?.trim()??"",t=X.filter(i=>!e(i));return t.length>0?{config:null,missing:t}:{config:{provider:e("ASSIST_REVIEW_PROVIDER"),baseUrl:e("ASSIST_REVIEW_BASE_URL").replace(/\/+$/,""),claudeModel:e("ASSIST_REVIEW_CLAUDE_MODEL"),codexModel:e("ASSIST_REVIEW_CODEX_MODEL"),apiKey:e(I)},missing:t}}async function lt(s){let{config:e,missing:t}=nt(s);if(!e)return t.map(r=>`${r} is not set`);let i;try{i=st(e.provider,e.baseUrl)}catch(r){return[r instanceof Error?r.message:String(r)]}return rt(e,i)}var Xi=us(Gi(),1);async function Zi(s){try{return await s}catch(e){throw(e===""||e===void 0)&&process.exit(0),e}}import{parseArgs as $r}from"node:util";var Yi={provider:"ASSIST_REVIEW_PROVIDER","base-url":"ASSIST_REVIEW_BASE_URL","claude-model":"ASSIST_REVIEW_CLAUDE_MODEL","codex-model":"ASSIST_REVIEW_CODEX_MODEL"};function Ji(s){let{values:e}=$r({args:s,options:Object.fromEntries(Object.keys(Yi).map(t=>[t,{type:"string"}]))});return Object.fromEntries(Object.entries(e).map(([t,i])=>[Yi[t],i]))}var Ir={ASSIST_REVIEW_PROVIDER:{name:"value",type:"select",message:"Provider",choices:[...Q]},ASSIST_REVIEW_BASE_URL:{name:"value",type:"input",message:"Base URL"},ASSIST_REVIEW_CLAUDE_MODEL:{name:"value",type:"input",message:"Claude model"},ASSIST_REVIEW_CODEX_MODEL:{name:"value",type:"input",message:"Codex model"},ASSIST_REVIEW_API_KEY:{name:"value",type:"password",message:"API key"}};async function Qi(s,e){let t={...Ji(s),[I]:e[I]},i={};for(let r of X){let n=t[r]?.trim();if(n){i[r]=n;continue}if(!process.stdin.isTTY)throw new Error(`${r} was not given and stdin is not a terminal to prompt for it`);let l=await Zi(Xi.default.prompt(Ir[r]));i[r]=l.value.trim()}return i}import{execFileSync as es}from"node:child_process";function ts(s){for(let e of oe)es("gh",["variable","set",e,"--body",s[e]],{stdio:["ignore","inherit","inherit"]});es("gh",["secret","set",I],{input:s[I],stdio:["pipe","inherit","inherit"]})}async function jr(){let s=await Qi(process.argv.slice(2),process.env);console.log("Checking the config can reach both models...");let e=await lt(s);if(e.length>0){for(let t of e)console.error(`review-ci: ${t}`);console.error("review-ci: nothing was set on the repo"),process.exit(1)}ts(s),console.log("review-ci: repo variables and secret are set")}try{await jr()}catch(s){console.error(`review-ci: ${s instanceof Error?s.message:String(s)}`),process.exit(1)}export{jr as reviewCiInit};
34
+ `)),this.write(this.margin[2]),this.restore()}};Mi.exports=Ye});var zi=d((Tn,Vi)=>{"use strict";var $r=T(),Je=class extends $r{constructor(e){if(super(e),typeof this.options.correctChoice!="number"||this.options.correctChoice<0)throw new Error("Please specify the index of the correct answer from the list of choices")}async toChoices(e,t){let i=await super.toChoices(e,t);if(i.length<2)throw new Error("Please give at least two choices to the user");if(this.options.correctChoice>i.length)throw new Error("Please specify the index of the correct answer from the list of choices");return i}check(e){return e.index===this.options.correctChoice}async result(e){return{selectedAnswer:e,correctAnswer:this.options.choices[this.options.correctChoice].value,correct:await this.check(this.state)}}};Vi.exports=Je});var Wi=d(Xe=>{"use strict";var Ki=k(),S=(s,e)=>{Ki.defineExport(Xe,s,e),Ki.defineExport(Xe,s.toLowerCase(),e)};S("AutoComplete",()=>Zt());S("BasicAuth",()=>ii());S("Confirm",()=>ni());S("Editable",()=>ai());S("Form",()=>ne());S("Input",()=>Te());S("Invisible",()=>fi());S("List",()=>gi());S("MultiSelect",()=>wi());S("Numeral",()=>xi());S("Password",()=>Ei());S("Scale",()=>ki());S("Select",()=>T());S("Snippet",()=>$i());S("Sort",()=>Ii());S("Survey",()=>Di());S("Text",()=>Ti());S("Toggle",()=>Li());S("Quiz",()=>zi())});var Ni=d((Ln,Ui)=>{Ui.exports={ArrayPrompt:Z(),AuthPrompt:$e(),BooleanPrompt:le(),NumberPrompt:Ke(),StringPrompt:z()}});var Gi=d((Vn,Hi)=>{"use strict";var Fi=J("assert"),et=J("events"),M=k(),O=class extends et{constructor(e,t){super(),this.options=M.merge({},e),this.answers={...t}}register(e,t){if(M.isObject(e)){for(let r of Object.keys(e))this.register(r,e[r]);return this}Fi.equal(typeof t,"function","expected a function");let i=e.toLowerCase();return t.prototype instanceof this.Prompt?this.prompts[i]=t:this.prompts[i]=t(this.Prompt,this),this}async prompt(e=[]){for(let t of[].concat(e))try{typeof t=="function"&&(t=await t.call(this)),await this.ask(M.merge({},this.options,t))}catch(i){return Promise.reject(i)}return this.answers}async ask(e){typeof e=="function"&&(e=await e.call(this));let t=M.merge({},this.options,e),{type:i,name:r}=e,{set:n,get:l}=M;if(typeof i=="function"&&(i=await i.call(this,e,this.answers)),!i)return this.answers[r];i==="number"&&(i="numeral"),Fi(this.prompts[i],`Prompt "${i}" is not registered`);let a=new this.prompts[i](t),o=l(this.answers,r);a.state.answers=this.answers,a.enquirer=this,r&&a.on("submit",c=>{this.emit("answer",r,c,a),n(this.answers,r,c)});let h=a.emit.bind(a);return a.emit=(...c)=>(this.emit.call(this,...c),h(...c)),this.emit("prompt",a,this),t.autofill&&o!=null?(a.value=a.input=o,t.autofill==="show"&&await a.submit()):o=a.value=await a.run(),o}use(e){return e.call(this,this),this}set Prompt(e){this._Prompt=e}get Prompt(){return this._Prompt||this.constructor.Prompt}get prompts(){return this.constructor.prompts}static set Prompt(e){this._Prompt=e}static get Prompt(){return this._Prompt||U()}static get prompts(){return Wi()}static get types(){return Ni()}static get prompt(){let e=(t,...i)=>{let r=new this(...i),n=r.emit.bind(r);return r.emit=(...l)=>(e.emit(...l),n(...l)),r.prompt(t)};return M.mixinEmitter(e,new et),e}};M.mixinEmitter(O,new et);var Qe=O.prompts;for(let s of Object.keys(Qe)){let e=s.toLowerCase(),t=i=>new Qe[s](i).run();O.prompt[e]=t,O[e]=t,O[s]||Reflect.defineProperty(O,s,{get:()=>Qe[s]})}var Y=s=>{M.defineExport(O,s,()=>O.types[s])};Y("ArrayPrompt");Y("AuthPrompt");Y("BooleanPrompt");Y("NumberPrompt");Y("StringPrompt");Hi.exports=O});var oe=["ASSIST_REVIEW_PROVIDER","ASSIST_REVIEW_BASE_URL","ASSIST_REVIEW_CLAUDE_MODEL","ASSIST_REVIEW_CODEX_MODEL"],I="ASSIST_REVIEW_API_KEY",X=[...oe,I],Q=["litellm","foundry"];function st(s,e){if(s==="litellm")return{anthropic:e,responses:`${e}/v1`,anthropicKind:"gateway"};if(s==="foundry")return{anthropic:`${e}/anthropic`,responses:`${e}/openai/v1`,anthropicKind:"foundry"};throw new Error(`Unsupported ASSIST_REVIEW_PROVIDER "${s}" (expected one of: ${Q.join(", ")})`)}async function he(s,e,t){try{let i=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",...e},body:JSON.stringify(t),signal:AbortSignal.timeout(6e4)});if(i.ok)return;let r=(await i.text()).trim().slice(0,300);return`HTTP ${i.status}${r?`: ${r}`:""}`}catch(i){if(!(i instanceof Error))return String(i);let r=i.cause instanceof Error?i.cause.message:"";return r?`${i.message} (${r})`:i.message}}async function rt(s,e){let t={Authorization:`Bearer ${s.apiKey}`},i=`${e.anthropic}/v1/messages`,r=`${e.responses}/responses`,[n,l]=await Promise.all([he(i,{...e.anthropicKind==="gateway"?t:{},"x-api-key":s.apiKey,"anthropic-version":"2023-06-01"},{model:s.claudeModel,max_tokens:1,messages:[{role:"user",content:"ping"}]}),he(r,t,{model:s.codexModel,input:"ping",max_output_tokens:16})]);return[...n?[`Claude model "${s.claudeModel}" at ${i}: ${n}`]:[],...l?[`Codex model "${s.codexModel}" at ${r}: ${l}`]:[]]}function nt(s){let e=i=>s[i]?.trim()??"",t=X.filter(i=>!e(i));return t.length>0?{config:null,missing:t}:{config:{provider:e("ASSIST_REVIEW_PROVIDER"),baseUrl:e("ASSIST_REVIEW_BASE_URL").replace(/\/+$/,""),claudeModel:e("ASSIST_REVIEW_CLAUDE_MODEL"),codexModel:e("ASSIST_REVIEW_CODEX_MODEL"),apiKey:e(I)},missing:t}}async function lt(s){let{config:e,missing:t}=nt(s);if(!e)return t.map(r=>`${r} is not set`);let i;try{i=st(e.provider,e.baseUrl)}catch(r){return[r instanceof Error?r.message:String(r)]}return rt(e,i)}var Xi=us(Gi(),1);async function Zi(s){try{return await s}catch(e){throw(e===""||e===void 0)&&process.exit(0),e}}import{parseArgs as Or}from"node:util";var Yi={provider:"ASSIST_REVIEW_PROVIDER","base-url":"ASSIST_REVIEW_BASE_URL","claude-model":"ASSIST_REVIEW_CLAUDE_MODEL","codex-model":"ASSIST_REVIEW_CODEX_MODEL"};function Ji(s){let{values:e}=Or({args:s,options:Object.fromEntries(Object.keys(Yi).map(t=>[t,{type:"string"}]))});return Object.fromEntries(Object.entries(e).map(([t,i])=>[Yi[t],i]))}var Ir={ASSIST_REVIEW_PROVIDER:{name:"value",type:"select",message:"Provider",choices:[...Q]},ASSIST_REVIEW_BASE_URL:{name:"value",type:"input",message:"Base URL (litellm: the proxy root; foundry: https://<resource>.services.ai.azure.com)"},ASSIST_REVIEW_CLAUDE_MODEL:{name:"value",type:"input",message:"Claude model"},ASSIST_REVIEW_CODEX_MODEL:{name:"value",type:"input",message:"Codex model"},ASSIST_REVIEW_API_KEY:{name:"value",type:"password",message:"API key"}};async function Qi(s,e){let t={...Ji(s),[I]:e[I]},i={};for(let r of X){let n=t[r]?.trim();if(n){i[r]=n;continue}if(!process.stdin.isTTY)throw new Error(`${r} was not given and stdin is not a terminal to prompt for it`);let l=await Zi(Xi.default.prompt(Ir[r]));i[r]=l.value.trim()}return i}import{execFileSync as es}from"node:child_process";function ts(s){for(let e of oe)es("gh",["variable","set",e,"--body",s[e]],{stdio:["ignore","inherit","inherit"]});es("gh",["secret","set",I],{input:s[I],stdio:["pipe","inherit","inherit"]})}async function jr(){let s=await Qi(process.argv.slice(2),process.env);console.log("Checking the config can reach both models...");let e=await lt(s);if(e.length>0){for(let t of e)console.error(`review-ci: ${t}`);console.error("review-ci: nothing was set on the repo"),process.exit(1)}ts(s),console.log("review-ci: repo variables and secret are set")}try{await jr()}catch(s){console.error(`review-ci: ${s instanceof Error?s.message:String(s)}`),process.exit(1)}export{jr as reviewCiInit};