@staff0rd/assist 0.740.0 → 0.742.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.
@@ -1,37 +1,37 @@
1
1
  import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
2
- var u1=Object.create;var dl=Object.defineProperty;var d1=Object.getOwnPropertyDescriptor;var f1=Object.getOwnPropertyNames;var p1=Object.getPrototypeOf,m1=Object.prototype.hasOwnProperty;var Ye=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var w=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ze=(e,t)=>{for(var r in t)dl(e,r,{get:t[r],enumerable:!0})},h1=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of f1(t))!m1.call(e,n)&&n!==r&&dl(e,n,{get:()=>t[n],enumerable:!(i=d1(t,n))||i.enumerable});return e};var fl=(e,t,r)=>(r=e!=null?u1(p1(e)):{},h1(t||!e||!e.__esModule?dl(r,"default",{value:e,enumerable:!0}):r,e));var Yg=w((zL,en)=>{"use strict";var P1=typeof process<"u"&&process.env.TERM_PROGRAM==="Hyper",O1=typeof process<"u"&&process.platform==="win32",Jg=typeof process<"u"&&process.platform==="linux",yl={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"},Wg=Object.assign({},yl,{check:"\u221A",cross:"\xD7",ellipsisLarge:"...",ellipsis:"...",info:"i",questionSmall:"?",pointer:">",pointerSmall:"\xBB",radioOff:"( )",radioOn:"(*)",warning:"\u203C"}),Hg=Object.assign({},yl,{ballotCross:"\u2718",check:"\u2714",cross:"\u2716",ellipsisLarge:"\u22EF",ellipsis:"\u2026",info:"\u2139",questionFull:"\uFF1F",questionSmall:"\uFE56",pointer:Jg?"\u25B8":"\u276F",pointerSmall:Jg?"\u2023":"\u203A",radioOff:"\u25EF",radioOn:"\u25C9",warning:"\u26A0"});en.exports=O1&&!P1?Wg:Hg;Reflect.defineProperty(en.exports,"common",{enumerable:!1,value:yl});Reflect.defineProperty(en.exports,"windows",{enumerable:!1,value:Wg});Reflect.defineProperty(en.exports,"other",{enumerable:!1,value:Hg})});var Li=w((RL,bl)=>{"use strict";var E1=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),C1=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,T1=()=>typeof process<"u"?process.env.FORCE_COLOR!=="0":!1,Xg=()=>{let e={enabled:T1(),visible:!0,styles:{},keys:{}},t=o=>{let s=o.open=`\x1B[${o.codes[0]}m`,a=o.close=`\x1B[${o.codes[1]}m`,l=o.regex=new RegExp(`\\u001b\\[${o.codes[1]}m`,"g");return o.wrap=(c,u)=>{c.includes(a)&&(c=c.replace(l,a+s));let d=s+c+a;return u?d.replace(/\r*\n/g,`${a}$&${s}`):d},o},r=(o,s,a)=>typeof o=="function"?o(s):o.wrap(s,a),i=(o,s)=>{if(o===""||o==null)return"";if(e.enabled===!1)return o;if(e.visible===!1)return"";let a=""+o,l=a.includes(`
2
+ var u1=Object.create;var dl=Object.defineProperty;var d1=Object.getOwnPropertyDescriptor;var f1=Object.getOwnPropertyNames;var p1=Object.getPrototypeOf,m1=Object.prototype.hasOwnProperty;var Ye=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var w=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ze=(e,t)=>{for(var r in t)dl(e,r,{get:t[r],enumerable:!0})},h1=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of f1(t))!m1.call(e,n)&&n!==r&&dl(e,n,{get:()=>t[n],enumerable:!(i=d1(t,n))||i.enumerable});return e};var fl=(e,t,r)=>(r=e!=null?u1(p1(e)):{},h1(t||!e||!e.__esModule?dl(r,"default",{value:e,enumerable:!0}):r,e));var Yg=w((RL,en)=>{"use strict";var P1=typeof process<"u"&&process.env.TERM_PROGRAM==="Hyper",O1=typeof process<"u"&&process.platform==="win32",Jg=typeof process<"u"&&process.platform==="linux",yl={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"},Wg=Object.assign({},yl,{check:"\u221A",cross:"\xD7",ellipsisLarge:"...",ellipsis:"...",info:"i",questionSmall:"?",pointer:">",pointerSmall:"\xBB",radioOff:"( )",radioOn:"(*)",warning:"\u203C"}),Hg=Object.assign({},yl,{ballotCross:"\u2718",check:"\u2714",cross:"\u2716",ellipsisLarge:"\u22EF",ellipsis:"\u2026",info:"\u2139",questionFull:"\uFF1F",questionSmall:"\uFE56",pointer:Jg?"\u25B8":"\u276F",pointerSmall:Jg?"\u2023":"\u203A",radioOff:"\u25EF",radioOn:"\u25C9",warning:"\u26A0"});en.exports=O1&&!P1?Wg:Hg;Reflect.defineProperty(en.exports,"common",{enumerable:!1,value:yl});Reflect.defineProperty(en.exports,"windows",{enumerable:!1,value:Wg});Reflect.defineProperty(en.exports,"other",{enumerable:!1,value:Hg})});var Li=w((DL,bl)=>{"use strict";var E1=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),C1=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,T1=()=>typeof process<"u"?process.env.FORCE_COLOR!=="0":!1,Xg=()=>{let e={enabled:T1(),visible:!0,styles:{},keys:{}},t=o=>{let s=o.open=`\x1B[${o.codes[0]}m`,a=o.close=`\x1B[${o.codes[1]}m`,l=o.regex=new RegExp(`\\u001b\\[${o.codes[1]}m`,"g");return o.wrap=(c,u)=>{c.includes(a)&&(c=c.replace(l,a+s));let d=s+c+a;return u?d.replace(/\r*\n/g,`${a}$&${s}`):d},o},r=(o,s,a)=>typeof o=="function"?o(s):o.wrap(s,a),i=(o,s)=>{if(o===""||o==null)return"";if(e.enabled===!1)return o;if(e.visible===!1)return"";let a=""+o,l=a.includes(`
3
3
  `),c=s.length;for(c>0&&s.includes("unstyle")&&(s=[...new Set(["unstyle",...s])].reverse());c-- >0;)a=r(e.styles[s[c]],a,l);return a},n=(o,s,a)=>{e.styles[o]=t({name:o,codes:s}),(e.keys[a]||(e.keys[a]=[])).push(o),Reflect.defineProperty(e,o,{configurable:!0,enumerable:!0,set(c){e.alias(o,c)},get(){let c=u=>i(u,c.stack);return Reflect.setPrototypeOf(c,e),c.stack=this.stack?this.stack.concat(o):[o],c}})};return n("reset",[0,0],"modifier"),n("bold",[1,22],"modifier"),n("dim",[2,22],"modifier"),n("italic",[3,23],"modifier"),n("underline",[4,24],"modifier"),n("inverse",[7,27],"modifier"),n("hidden",[8,28],"modifier"),n("strikethrough",[9,29],"modifier"),n("black",[30,39],"color"),n("red",[31,39],"color"),n("green",[32,39],"color"),n("yellow",[33,39],"color"),n("blue",[34,39],"color"),n("magenta",[35,39],"color"),n("cyan",[36,39],"color"),n("white",[37,39],"color"),n("gray",[90,39],"color"),n("grey",[90,39],"color"),n("bgBlack",[40,49],"bg"),n("bgRed",[41,49],"bg"),n("bgGreen",[42,49],"bg"),n("bgYellow",[43,49],"bg"),n("bgBlue",[44,49],"bg"),n("bgMagenta",[45,49],"bg"),n("bgCyan",[46,49],"bg"),n("bgWhite",[47,49],"bg"),n("blackBright",[90,39],"bright"),n("redBright",[91,39],"bright"),n("greenBright",[92,39],"bright"),n("yellowBright",[93,39],"bright"),n("blueBright",[94,39],"bright"),n("magentaBright",[95,39],"bright"),n("cyanBright",[96,39],"bright"),n("whiteBright",[97,39],"bright"),n("bgBlackBright",[100,49],"bgBright"),n("bgRedBright",[101,49],"bgBright"),n("bgGreenBright",[102,49],"bgBright"),n("bgYellowBright",[103,49],"bgBright"),n("bgBlueBright",[104,49],"bgBright"),n("bgMagentaBright",[105,49],"bgBright"),n("bgCyanBright",[106,49],"bgBright"),n("bgWhiteBright",[107,49],"bgBright"),e.ansiRegex=C1,e.hasColor=e.hasAnsi=o=>(e.ansiRegex.lastIndex=0,typeof o=="string"&&o!==""&&e.ansiRegex.test(o)),e.alias=(o,s)=>{let a=typeof s=="string"?e[s]:s;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:o}),e.styles[o]=a,a.stack=[o]),Reflect.defineProperty(e,o,{configurable:!0,enumerable:!0,set(l){e.alias(o,l)},get(){let l=c=>i(c,l.stack);return Reflect.setPrototypeOf(l,e),l.stack=this.stack?this.stack.concat(a.stack):a.stack,l}})},e.theme=o=>{if(!E1(o))throw new TypeError("Expected theme to be an object");for(let s of Object.keys(o))e.alias(s,o[s]);return e},e.alias("unstyle",o=>typeof o=="string"&&o!==""?(e.ansiRegex.lastIndex=0,o.replace(e.ansiRegex,"")):""),e.alias("noop",o=>o),e.none=e.clear=e.noop,e.stripColor=e.unstyle,e.symbols=Yg(),e.define=n,e};bl.exports=Xg();bl.exports.create=Xg});var oe=w(D=>{"use strict";var N1=Object.prototype.toString,we=Li(),Qg=!1,tn=new Set,ev={yellow:"blue",cyan:"red",green:"magenta",black:"white",blue:"yellow",red:"cyan",magenta:"green",white:"black"};D.longest=(e,t)=>e.reduce((r,i)=>Math.max(r,t?i[t].length:i.length),0);D.hasColor=e=>!!e&&we.hasColor(e);var Ui=D.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);D.nativeType=e=>N1.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"");D.isAsyncFn=e=>D.nativeType(e)==="asyncfunction";D.isPrimitive=e=>e!=null&&typeof e!="object"&&typeof e!="function";D.resolve=(e,t,...r)=>typeof t=="function"?t.call(e,...r):t;D.scrollDown=(e=[])=>[...e.slice(1),e[0]];D.scrollUp=(e=[])=>[e.pop(),...e];D.reorder=(e=[])=>{let t=e.slice();return t.sort((r,i)=>r.index>i.index?1:r.index<i.index?-1:0),t};D.swap=(e,t,r)=>{let i=e.length,n=r===i?0:r<0?i-1:r,o=e[t];e[t]=e[n],e[n]=o};D.width=(e,t=80)=>{let r=e&&e.columns?e.columns:t;return e&&typeof e.getWindowSize=="function"&&(r=e.getWindowSize()[0]),process.platform==="win32"?r-1:r};D.height=(e,t=20)=>{let r=e&&e.rows?e.rows:t;return e&&typeof e.getWindowSize=="function"&&(r=e.getWindowSize()[1]),r};D.wordWrap=(e,t={})=>{if(!e)return e;typeof t=="number"&&(t={width:t});let{indent:r="",newline:i=`
4
- `+r,width:n=80}=t,o=(i+r).match(/[^\S\n]/g)||[];n-=o.length;let s=`.{1,${n}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,a=e.trim(),l=new RegExp(s,"g"),c=a.match(l)||[];return c=c.map(u=>u.replace(/\n$/,"")),t.padEnd&&(c=c.map(u=>u.padEnd(n," "))),t.padStart&&(c=c.map(u=>u.padStart(n," "))),r+c.join(i)};D.unmute=e=>{let t=e.stack.find(i=>we.keys.color.includes(i));return t?we[t]:e.stack.find(i=>i.slice(2)==="bg")?we[t.slice(2)]:i=>i};D.pascal=e=>e?e[0].toUpperCase()+e.slice(1):"";D.inverse=e=>{if(!e||!e.stack)return e;let t=e.stack.find(i=>we.keys.color.includes(i));if(t){let i=we["bg"+D.pascal(t)];return i?i.black:e}let r=e.stack.find(i=>i.slice(0,2)==="bg");return r?we[r.slice(2).toLowerCase()]||e:we.none};D.complement=e=>{if(!e||!e.stack)return e;let t=e.stack.find(i=>we.keys.color.includes(i)),r=e.stack.find(i=>i.slice(0,2)==="bg");if(t&&!r)return we[ev[t]||t];if(r){let i=r.slice(2).toLowerCase(),n=ev[i];return n&&we["bg"+D.pascal(n)]||e}return we.none};D.meridiem=e=>{let t=e.getHours(),r=e.getMinutes(),i=t>=12?"pm":"am";t=t%12;let n=t===0?12:t,o=r<10?"0"+r:r;return n+":"+o+" "+i};D.set=(e={},t="",r)=>t.split(".").reduce((i,n,o,s)=>{let a=s.length-1>o?i[n]||{}:r;return!D.isObject(a)&&o<s.length-1&&(a={}),i[n]=a},e);D.get=(e={},t="",r)=>{let i=e[t]==null?t.split(".").reduce((n,o)=>n&&n[o],e):e[t];return i??r};D.mixin=(e,t)=>{if(!Ui(e))return t;if(!Ui(t))return e;for(let r of Object.keys(t)){let i=Object.getOwnPropertyDescriptor(t,r);if(hasOwnProperty.call(i,"value"))if(hasOwnProperty.call(e,r)&&Ui(i.value)){let n=Object.getOwnPropertyDescriptor(e,r);Ui(n.value)&&n.value!==i.value?e[r]=D.merge({},e[r],t[r]):Reflect.defineProperty(e,r,i)}else Reflect.defineProperty(e,r,i);else Reflect.defineProperty(e,r,i)}return e};D.merge=(...e)=>{let t={};for(let r of e)D.mixin(t,r);return t};D.mixinEmitter=(e,t)=>{let r=t.constructor.prototype;for(let i of Object.keys(r)){let n=r[i];typeof n=="function"?D.define(e,i,n.bind(t)):D.define(e,i,n)}};var Mi=(e,t)=>{Qg||(Qg=!0,tn.forEach(r=>r()),e===!0&&process.exit(128+t))},tv=Mi.bind(null,!0,15),rv=Mi.bind(null,!0,2);D.onExit=e=>(tn.size===0&&(process.once("SIGTERM",tv),process.once("SIGINT",rv),process.once("exit",Mi)),tn.add(e),()=>{tn.delete(e),tn.size===0&&(process.off("SIGTERM",tv),process.off("SIGINT",rv),process.off("exit",Mi))});D.define=(e,t,r)=>{Reflect.defineProperty(e,t,{value:r})};D.defineExport=(e,t,r)=>{let i;Reflect.defineProperty(e,t,{enumerable:!0,configurable:!0,set(n){i=n},get(){return i?i():r()}})}});var iv=w((jL,nv)=>{"use strict";nv.exports=({onlyFirst:e=!1}={})=>{let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}});var et=w((LL,ov)=>{"use strict";var A1=iv();ov.exports=e=>typeof e=="string"?e.replace(A1(),""):e});var sv=w(Yt=>{"use strict";Yt.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"};Yt.shift={up:"shiftUp",down:"shiftDown",left:"shiftLeft",right:"shiftRight",tab:"prev"};Yt.fn={up:"pageUp",down:"pageDown",left:"pageLeft",right:"pageRight",delete:"deleteForward"};Yt.option={b:"backward",f:"forward",d:"cutRight",left:"cutLeft",up:"altUp",down:"altDown"};Yt.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 lv=w((qL,av)=>{"use strict";av.exports=class{_queue=[];_executing=!1;_jobRunner=null;constructor(t){this._jobRunner=t}enqueue=(...t)=>{this._queue.push(t),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 wl=w((FL,uv)=>{"use strict";var cv=Ye("readline"),z1=sv(),R1=lv(),D1=/^(?:\x1b)([a-zA-Z0-9])$/,j1=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,L1={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 U1(e){return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(e)}function M1(e){return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(e)}var qi=(e="",t={})=>{let r,i={name:t.name,ctrl:!1,meta:!1,shift:!1,option:!1,sequence:e,raw:e,...t};if(Buffer.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e="\x1B"+String(e)):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e=i.sequence||""),i.sequence=i.sequence||e||i.name,e==="\r")i.raw=void 0,i.name="return";else if(e===`
5
- `)i.name="enter";else if(e===" ")i.name="tab";else if(e==="\b"||e==="\x7F"||e==="\x1B\x7F"||e==="\x1B\b")i.name="backspace",i.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")i.name="escape",i.meta=e.length===2;else if(e===" "||e==="\x1B ")i.name="space",i.meta=e.length===2;else if(e<="")i.name=String.fromCharCode(e.charCodeAt(0)+97-1),i.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")i.name="number";else if(e.length===1&&e>="a"&&e<="z")i.name=e;else if(e.length===1&&e>="A"&&e<="Z")i.name=e.toLowerCase(),i.shift=!0;else if(r=D1.exec(e))i.meta=!0,i.shift=/^[A-Z]$/.test(r[1]);else if(r=j1.exec(e)){let n=[...e];n[0]==="\x1B"&&n[1]==="\x1B"&&(i.option=!0);let o=[r[1],r[2],r[4],r[6]].filter(Boolean).join(""),s=(r[3]||r[5]||1)-1;i.ctrl=!!(s&4),i.meta=!!(s&10),i.shift=!!(s&1),i.code=o,i.name=L1[o],i.shift=U1(o)||i.shift,i.ctrl=M1(o)||i.ctrl}return i};qi.listen=(e={},t)=>{let{stdin:r}=e;if(!r||r!==process.stdin&&!r.isTTY)throw new Error("Invalid stream passed");let i=cv.createInterface({terminal:!0,input:r});cv.emitKeypressEvents(r,i);let n=new R1((a,l)=>t(a,qi(a,l),i)),o=r.isRaw;return r.isTTY&&r.setRawMode(!0),r.on("keypress",n.enqueue),i.resume(),()=>{r.isTTY&&r.setRawMode(o),r.removeListener("keypress",n.enqueue),n.destroy(),i.pause(),i.close()}};qi.action=(e,t,r)=>{let i={...z1,...r};return t.ctrl?(t.action=i.ctrl[t.name],t):t.option&&i.option?(t.action=i.option[t.name],t):t.shift?(t.action=i.shift[t.name],t):(t.action=i.keys[t.name],t)};uv.exports=qi});var fv=w((ZL,dv)=>{"use strict";dv.exports=e=>{e.timers=e.timers||{};let t=e.options.timers;if(t)for(let r of Object.keys(t)){let i=t[r];typeof i=="number"&&(i={interval:i}),q1(e,r,i)}};function q1(e,t,r={}){let i=e.timers[t]={name:t,start:Date.now(),ms:0,tick:0},n=r.interval||120;i.frames=r.frames||[],i.loading=!0;let o=setInterval(()=>{i.ms=Date.now()-i.start,i.tick++,e.render()},n);return i.stop=()=>{i.loading=!1,clearInterval(o)},Reflect.defineProperty(i,"interval",{value:o}),e.once("close",()=>i.stop()),i.stop}});var mv=w((BL,pv)=>{"use strict";var{define:F1,width:Z1}=oe(),$l=class{constructor(t){let r=t.options;F1(this,"_prompt",t),this.type=t.type,this.name=t.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=Z1(r.stdout||process.stdout),Object.assign(this,r),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=t.symbols,this.styles=t.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let t={...this};return t.status=this.status,t.buffer=Buffer.from(t.buffer),delete t.clone,t}set color(t){this._color=t}get color(){let t=this.prompt.styles;if(this.cancelled)return t.cancelled;if(this.submitted)return t.submitted;let r=this._color||t[this.status];return typeof r=="function"?r:t.pending}set loading(t){this._loading=t}get loading(){return typeof this._loading=="boolean"?this._loading:this.loadingChoices?"choices":!1}get status(){return this.cancelled?"cancelled":this.submitted?"submitted":"pending"}};pv.exports=$l});var gv=w((VL,hv)=>{"use strict";var xl=oe(),re=Li(),_l={default:re.noop,noop:re.noop,set inverse(e){this._inverse=e},get inverse(){return this._inverse||xl.inverse(this.primary)},set complement(e){this._complement=e},get complement(){return this._complement||xl.complement(this.primary)},primary:re.cyan,success:re.green,danger:re.magenta,strong:re.bold,warning:re.yellow,muted:re.dim,disabled:re.gray,dark:re.dim.gray,underline:re.underline,set info(e){this._info=e},get info(){return this._info||this.primary},set em(e){this._em=e},get em(){return this._em||this.primary.underline},set heading(e){this._heading=e},get heading(){return this._heading||this.muted.underline},set pending(e){this._pending=e},get pending(){return this._pending||this.primary},set submitted(e){this._submitted=e},get submitted(){return this._submitted||this.success},set cancelled(e){this._cancelled=e},get cancelled(){return this._cancelled||this.danger},set typing(e){this._typing=e},get typing(){return this._typing||this.dim},set placeholder(e){this._placeholder=e},get placeholder(){return this._placeholder||this.primary.dim},set highlight(e){this._highlight=e},get highlight(){return this._highlight||this.inverse}};_l.merge=(e={})=>{e.styles&&typeof e.styles.enabled=="boolean"&&(re.enabled=e.styles.enabled),e.styles&&typeof e.styles.visible=="boolean"&&(re.visible=e.styles.visible);let t=xl.merge({},_l,e.styles);delete t.merge;for(let r of Object.keys(re))hasOwnProperty.call(t,r)||Reflect.defineProperty(t,r,{get:()=>re[r]});for(let r of Object.keys(re.styles))hasOwnProperty.call(t,r)||Reflect.defineProperty(t,r,{get:()=>re[r]});return t};hv.exports=_l});var yv=w((KL,vv)=>{"use strict";var Sl=process.platform==="win32",Fe=Li(),B1=oe(),kl={...Fe.symbols,upDownDoubleArrow:"\u21D5",upDownDoubleArrow2:"\u2B0D",upDownArrow:"\u2195",asterisk:"*",asterism:"\u2042",bulletWhite:"\u25E6",electricArrow:"\u2301",ellipsisLarge:"\u22EF",ellipsisSmall:"\u2026",fullBlock:"\u2588",identicalTo:"\u2261",indicator:Fe.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:Fe.symbols.question,submitted:Fe.symbols.check,cancelled:Fe.symbols.cross},separator:{pending:Fe.symbols.pointerSmall,submitted:Fe.symbols.middot,cancelled:Fe.symbols.middot},radio:{off:Sl?"( )":"\u25EF",on:Sl?"(*)":"\u25C9",disabled:Sl?"(|)":"\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"]};kl.merge=e=>{let t=B1.merge({},Fe.symbols,kl,e.symbols);return delete t.merge,t};vv.exports=kl});var wv=w((GL,bv)=>{"use strict";var V1=gv(),K1=yv(),G1=oe();bv.exports=e=>{e.options=G1.merge({},e.options.theme,e.options),e.symbols=K1.merge(e.options),e.styles=V1.merge(e.options)}});var kv=w((_v,Sv)=>{"use strict";var $v=process.env.TERM_PROGRAM==="Apple_Terminal",J1=et(),Il=oe(),Ie=Sv.exports=_v,J="\x1B[",xv="\x07",Pl=!1,tt=Ie.code={bell:xv,beep:xv,beginning:`${J}G`,down:`${J}J`,esc:J,getPosition:`${J}6n`,hide:`${J}?25l`,line:`${J}2K`,lineEnd:`${J}K`,lineStart:`${J}1K`,restorePosition:J+($v?"8":"u"),savePosition:J+($v?"7":"s"),screen:`${J}2J`,show:`${J}?25h`,up:`${J}1J`},It=Ie.cursor={get hidden(){return Pl},hide(){return Pl=!0,tt.hide},show(){return Pl=!1,tt.show},forward:(e=1)=>`${J}${e}C`,backward:(e=1)=>`${J}${e}D`,nextLine:(e=1)=>`${J}E`.repeat(e),prevLine:(e=1)=>`${J}F`.repeat(e),up:(e=1)=>e?`${J}${e}A`:"",down:(e=1)=>e?`${J}${e}B`:"",right:(e=1)=>e?`${J}${e}C`:"",left:(e=1)=>e?`${J}${e}D`:"",to(e,t){return t?`${J}${t+1};${e+1}H`:`${J}${e+1}G`},move(e=0,t=0){let r="";return r+=e<0?It.left(-e):e>0?It.right(e):"",r+=t<0?It.up(-t):t>0?It.down(t):"",r},strLen(e){for(var t=0,r=e.length,i=-1,n=0;n<r;n++)i=e.charCodeAt(n),i>=0&&i<=128?t+=1:t+=2;return t},restore(e={}){let{after:t,cursor:r,initial:i,input:n,prompt:o,size:s,value:a}=e;if(i=Il.isPrimitive(i)?String(i):"",n=Il.isPrimitive(n)?String(n):"",a=Il.isPrimitive(a)?String(a):"",s){let l=Ie.cursor.up(s)+Ie.cursor.to(this.strLen(o)),c=n.length-r;return c>0&&(l+=Ie.cursor.left(c)),l}if(a||t){let l=!n&&i?-this.strLen(i):-this.strLen(n)+r;return t&&(l-=this.strLen(t)),n===""&&i&&!o.includes(i)&&(l+=this.strLen(i)),Ie.cursor.move(l)}}},Ol=Ie.erase={screen:tt.screen,up:tt.up,down:tt.down,line:tt.line,lineEnd:tt.lineEnd,lineStart:tt.lineStart,lines(e){let t="";for(let r=0;r<e;r++)t+=Ie.erase.line+(r<e-1?Ie.cursor.up(1):"");return e&&(t+=Ie.code.beginning),t}};Ie.clear=(e="",t=process.stdout.columns)=>{if(!t)return Ol.line+It.to(0);let r=o=>[...J1(o)].length,i=e.split(/\r?\n/),n=0;for(let o of i)n+=1+Math.floor(Math.max(r(o)-1,0)/t);return(Ol.line+It.prevLine()).repeat(n-1)+Ol.line+It.to(0)}});var Xt=w((JL,Pv)=>{"use strict";var W1=Ye("events"),Iv=et(),El=wl(),H1=fv(),Y1=mv(),X1=wv(),de=oe(),Pt=kv(),Cl=class e extends W1{constructor(t={}){super(),this.name=t.name,this.type=t.type,this.options=t,X1(this),H1(this),this.state=new Y1(this),this.initial=[t.initial,t.default].find(r=>r!=null),this.stdout=t.stdout||process.stdout,this.stdin=t.stdin||process.stdin,this.scale=t.scale||1,this.term=this.options.term||process.env.TERM_PROGRAM,this.margin=eP(this.options.margin),this.setMaxListeners(0),Q1(this)}async keypress(t,r={}){this.keypressed=!0;let i=El.action(t,El(t,r),this.options.actions);this.state.keypress=i,this.emit("keypress",t,i),this.emit("state",this.state.clone());let n=this.options[i.action]||this[i.action]||this.dispatch;if(typeof n=="function")return await n.call(this,t,i);this.alert()}alert(){delete this.state.alert,this.options.show===!1?this.emit("alert"):this.stdout.write(Pt.code.beep)}cursorHide(){this.stdout.write(Pt.cursor.hide());let t=de.onExit(()=>this.cursorShow());this.on("close",()=>{this.cursorShow(),t()})}cursorShow(){this.stdout.write(Pt.cursor.show())}write(t){t&&(this.stdout&&this.state.show!==!1&&this.stdout.write(t),this.state.buffer+=t)}clear(t=0){let r=this.state.buffer;this.state.buffer="",!(!r&&!t||this.options.show===!1)&&this.stdout.write(Pt.cursor.down(t)+Pt.clear(r,this.width))}restore(){if(this.state.closed||this.options.show===!1)return;let{prompt:t,after:r,rest:i}=this.sections(),{cursor:n,initial:o="",input:s="",value:a=""}=this,l=this.state.size=i.length,c={after:r,cursor:n,initial:o,input:s,prompt:t,size:l,value:a},u=Pt.cursor.restore(c);u&&this.stdout.write(u)}sections(){let{buffer:t,input:r,prompt:i}=this.state;i=Iv(i);let n=Iv(t),o=n.indexOf(i),s=n.slice(0,o),l=n.slice(o).split(`
4
+ `+r,width:n=80}=t,o=(i+r).match(/[^\S\n]/g)||[];n-=o.length;let s=`.{1,${n}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,a=e.trim(),l=new RegExp(s,"g"),c=a.match(l)||[];return c=c.map(u=>u.replace(/\n$/,"")),t.padEnd&&(c=c.map(u=>u.padEnd(n," "))),t.padStart&&(c=c.map(u=>u.padStart(n," "))),r+c.join(i)};D.unmute=e=>{let t=e.stack.find(i=>we.keys.color.includes(i));return t?we[t]:e.stack.find(i=>i.slice(2)==="bg")?we[t.slice(2)]:i=>i};D.pascal=e=>e?e[0].toUpperCase()+e.slice(1):"";D.inverse=e=>{if(!e||!e.stack)return e;let t=e.stack.find(i=>we.keys.color.includes(i));if(t){let i=we["bg"+D.pascal(t)];return i?i.black:e}let r=e.stack.find(i=>i.slice(0,2)==="bg");return r?we[r.slice(2).toLowerCase()]||e:we.none};D.complement=e=>{if(!e||!e.stack)return e;let t=e.stack.find(i=>we.keys.color.includes(i)),r=e.stack.find(i=>i.slice(0,2)==="bg");if(t&&!r)return we[ev[t]||t];if(r){let i=r.slice(2).toLowerCase(),n=ev[i];return n&&we["bg"+D.pascal(n)]||e}return we.none};D.meridiem=e=>{let t=e.getHours(),r=e.getMinutes(),i=t>=12?"pm":"am";t=t%12;let n=t===0?12:t,o=r<10?"0"+r:r;return n+":"+o+" "+i};D.set=(e={},t="",r)=>t.split(".").reduce((i,n,o,s)=>{let a=s.length-1>o?i[n]||{}:r;return!D.isObject(a)&&o<s.length-1&&(a={}),i[n]=a},e);D.get=(e={},t="",r)=>{let i=e[t]==null?t.split(".").reduce((n,o)=>n&&n[o],e):e[t];return i??r};D.mixin=(e,t)=>{if(!Ui(e))return t;if(!Ui(t))return e;for(let r of Object.keys(t)){let i=Object.getOwnPropertyDescriptor(t,r);if(hasOwnProperty.call(i,"value"))if(hasOwnProperty.call(e,r)&&Ui(i.value)){let n=Object.getOwnPropertyDescriptor(e,r);Ui(n.value)&&n.value!==i.value?e[r]=D.merge({},e[r],t[r]):Reflect.defineProperty(e,r,i)}else Reflect.defineProperty(e,r,i);else Reflect.defineProperty(e,r,i)}return e};D.merge=(...e)=>{let t={};for(let r of e)D.mixin(t,r);return t};D.mixinEmitter=(e,t)=>{let r=t.constructor.prototype;for(let i of Object.keys(r)){let n=r[i];typeof n=="function"?D.define(e,i,n.bind(t)):D.define(e,i,n)}};var Mi=(e,t)=>{Qg||(Qg=!0,tn.forEach(r=>r()),e===!0&&process.exit(128+t))},tv=Mi.bind(null,!0,15),rv=Mi.bind(null,!0,2);D.onExit=e=>(tn.size===0&&(process.once("SIGTERM",tv),process.once("SIGINT",rv),process.once("exit",Mi)),tn.add(e),()=>{tn.delete(e),tn.size===0&&(process.off("SIGTERM",tv),process.off("SIGINT",rv),process.off("exit",Mi))});D.define=(e,t,r)=>{Reflect.defineProperty(e,t,{value:r})};D.defineExport=(e,t,r)=>{let i;Reflect.defineProperty(e,t,{enumerable:!0,configurable:!0,set(n){i=n},get(){return i?i():r()}})}});var iv=w((LL,nv)=>{"use strict";nv.exports=({onlyFirst:e=!1}={})=>{let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}});var et=w((UL,ov)=>{"use strict";var A1=iv();ov.exports=e=>typeof e=="string"?e.replace(A1(),""):e});var sv=w(Yt=>{"use strict";Yt.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"};Yt.shift={up:"shiftUp",down:"shiftDown",left:"shiftLeft",right:"shiftRight",tab:"prev"};Yt.fn={up:"pageUp",down:"pageDown",left:"pageLeft",right:"pageRight",delete:"deleteForward"};Yt.option={b:"backward",f:"forward",d:"cutRight",left:"cutLeft",up:"altUp",down:"altDown"};Yt.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 lv=w((FL,av)=>{"use strict";av.exports=class{_queue=[];_executing=!1;_jobRunner=null;constructor(t){this._jobRunner=t}enqueue=(...t)=>{this._queue.push(t),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 wl=w((ZL,uv)=>{"use strict";var cv=Ye("readline"),z1=sv(),R1=lv(),D1=/^(?:\x1b)([a-zA-Z0-9])$/,j1=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,L1={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 U1(e){return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(e)}function M1(e){return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(e)}var qi=(e="",t={})=>{let r,i={name:t.name,ctrl:!1,meta:!1,shift:!1,option:!1,sequence:e,raw:e,...t};if(Buffer.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e="\x1B"+String(e)):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e=i.sequence||""),i.sequence=i.sequence||e||i.name,e==="\r")i.raw=void 0,i.name="return";else if(e===`
5
+ `)i.name="enter";else if(e===" ")i.name="tab";else if(e==="\b"||e==="\x7F"||e==="\x1B\x7F"||e==="\x1B\b")i.name="backspace",i.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")i.name="escape",i.meta=e.length===2;else if(e===" "||e==="\x1B ")i.name="space",i.meta=e.length===2;else if(e<="")i.name=String.fromCharCode(e.charCodeAt(0)+97-1),i.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")i.name="number";else if(e.length===1&&e>="a"&&e<="z")i.name=e;else if(e.length===1&&e>="A"&&e<="Z")i.name=e.toLowerCase(),i.shift=!0;else if(r=D1.exec(e))i.meta=!0,i.shift=/^[A-Z]$/.test(r[1]);else if(r=j1.exec(e)){let n=[...e];n[0]==="\x1B"&&n[1]==="\x1B"&&(i.option=!0);let o=[r[1],r[2],r[4],r[6]].filter(Boolean).join(""),s=(r[3]||r[5]||1)-1;i.ctrl=!!(s&4),i.meta=!!(s&10),i.shift=!!(s&1),i.code=o,i.name=L1[o],i.shift=U1(o)||i.shift,i.ctrl=M1(o)||i.ctrl}return i};qi.listen=(e={},t)=>{let{stdin:r}=e;if(!r||r!==process.stdin&&!r.isTTY)throw new Error("Invalid stream passed");let i=cv.createInterface({terminal:!0,input:r});cv.emitKeypressEvents(r,i);let n=new R1((a,l)=>t(a,qi(a,l),i)),o=r.isRaw;return r.isTTY&&r.setRawMode(!0),r.on("keypress",n.enqueue),i.resume(),()=>{r.isTTY&&r.setRawMode(o),r.removeListener("keypress",n.enqueue),n.destroy(),i.pause(),i.close()}};qi.action=(e,t,r)=>{let i={...z1,...r};return t.ctrl?(t.action=i.ctrl[t.name],t):t.option&&i.option?(t.action=i.option[t.name],t):t.shift?(t.action=i.shift[t.name],t):(t.action=i.keys[t.name],t)};uv.exports=qi});var fv=w((BL,dv)=>{"use strict";dv.exports=e=>{e.timers=e.timers||{};let t=e.options.timers;if(t)for(let r of Object.keys(t)){let i=t[r];typeof i=="number"&&(i={interval:i}),q1(e,r,i)}};function q1(e,t,r={}){let i=e.timers[t]={name:t,start:Date.now(),ms:0,tick:0},n=r.interval||120;i.frames=r.frames||[],i.loading=!0;let o=setInterval(()=>{i.ms=Date.now()-i.start,i.tick++,e.render()},n);return i.stop=()=>{i.loading=!1,clearInterval(o)},Reflect.defineProperty(i,"interval",{value:o}),e.once("close",()=>i.stop()),i.stop}});var mv=w((VL,pv)=>{"use strict";var{define:F1,width:Z1}=oe(),$l=class{constructor(t){let r=t.options;F1(this,"_prompt",t),this.type=t.type,this.name=t.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=Z1(r.stdout||process.stdout),Object.assign(this,r),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=t.symbols,this.styles=t.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let t={...this};return t.status=this.status,t.buffer=Buffer.from(t.buffer),delete t.clone,t}set color(t){this._color=t}get color(){let t=this.prompt.styles;if(this.cancelled)return t.cancelled;if(this.submitted)return t.submitted;let r=this._color||t[this.status];return typeof r=="function"?r:t.pending}set loading(t){this._loading=t}get loading(){return typeof this._loading=="boolean"?this._loading:this.loadingChoices?"choices":!1}get status(){return this.cancelled?"cancelled":this.submitted?"submitted":"pending"}};pv.exports=$l});var gv=w((KL,hv)=>{"use strict";var xl=oe(),re=Li(),_l={default:re.noop,noop:re.noop,set inverse(e){this._inverse=e},get inverse(){return this._inverse||xl.inverse(this.primary)},set complement(e){this._complement=e},get complement(){return this._complement||xl.complement(this.primary)},primary:re.cyan,success:re.green,danger:re.magenta,strong:re.bold,warning:re.yellow,muted:re.dim,disabled:re.gray,dark:re.dim.gray,underline:re.underline,set info(e){this._info=e},get info(){return this._info||this.primary},set em(e){this._em=e},get em(){return this._em||this.primary.underline},set heading(e){this._heading=e},get heading(){return this._heading||this.muted.underline},set pending(e){this._pending=e},get pending(){return this._pending||this.primary},set submitted(e){this._submitted=e},get submitted(){return this._submitted||this.success},set cancelled(e){this._cancelled=e},get cancelled(){return this._cancelled||this.danger},set typing(e){this._typing=e},get typing(){return this._typing||this.dim},set placeholder(e){this._placeholder=e},get placeholder(){return this._placeholder||this.primary.dim},set highlight(e){this._highlight=e},get highlight(){return this._highlight||this.inverse}};_l.merge=(e={})=>{e.styles&&typeof e.styles.enabled=="boolean"&&(re.enabled=e.styles.enabled),e.styles&&typeof e.styles.visible=="boolean"&&(re.visible=e.styles.visible);let t=xl.merge({},_l,e.styles);delete t.merge;for(let r of Object.keys(re))hasOwnProperty.call(t,r)||Reflect.defineProperty(t,r,{get:()=>re[r]});for(let r of Object.keys(re.styles))hasOwnProperty.call(t,r)||Reflect.defineProperty(t,r,{get:()=>re[r]});return t};hv.exports=_l});var yv=w((GL,vv)=>{"use strict";var Sl=process.platform==="win32",Fe=Li(),B1=oe(),kl={...Fe.symbols,upDownDoubleArrow:"\u21D5",upDownDoubleArrow2:"\u2B0D",upDownArrow:"\u2195",asterisk:"*",asterism:"\u2042",bulletWhite:"\u25E6",electricArrow:"\u2301",ellipsisLarge:"\u22EF",ellipsisSmall:"\u2026",fullBlock:"\u2588",identicalTo:"\u2261",indicator:Fe.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:Fe.symbols.question,submitted:Fe.symbols.check,cancelled:Fe.symbols.cross},separator:{pending:Fe.symbols.pointerSmall,submitted:Fe.symbols.middot,cancelled:Fe.symbols.middot},radio:{off:Sl?"( )":"\u25EF",on:Sl?"(*)":"\u25C9",disabled:Sl?"(|)":"\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"]};kl.merge=e=>{let t=B1.merge({},Fe.symbols,kl,e.symbols);return delete t.merge,t};vv.exports=kl});var wv=w((JL,bv)=>{"use strict";var V1=gv(),K1=yv(),G1=oe();bv.exports=e=>{e.options=G1.merge({},e.options.theme,e.options),e.symbols=K1.merge(e.options),e.styles=V1.merge(e.options)}});var kv=w((_v,Sv)=>{"use strict";var $v=process.env.TERM_PROGRAM==="Apple_Terminal",J1=et(),Il=oe(),Ie=Sv.exports=_v,J="\x1B[",xv="\x07",Pl=!1,tt=Ie.code={bell:xv,beep:xv,beginning:`${J}G`,down:`${J}J`,esc:J,getPosition:`${J}6n`,hide:`${J}?25l`,line:`${J}2K`,lineEnd:`${J}K`,lineStart:`${J}1K`,restorePosition:J+($v?"8":"u"),savePosition:J+($v?"7":"s"),screen:`${J}2J`,show:`${J}?25h`,up:`${J}1J`},It=Ie.cursor={get hidden(){return Pl},hide(){return Pl=!0,tt.hide},show(){return Pl=!1,tt.show},forward:(e=1)=>`${J}${e}C`,backward:(e=1)=>`${J}${e}D`,nextLine:(e=1)=>`${J}E`.repeat(e),prevLine:(e=1)=>`${J}F`.repeat(e),up:(e=1)=>e?`${J}${e}A`:"",down:(e=1)=>e?`${J}${e}B`:"",right:(e=1)=>e?`${J}${e}C`:"",left:(e=1)=>e?`${J}${e}D`:"",to(e,t){return t?`${J}${t+1};${e+1}H`:`${J}${e+1}G`},move(e=0,t=0){let r="";return r+=e<0?It.left(-e):e>0?It.right(e):"",r+=t<0?It.up(-t):t>0?It.down(t):"",r},strLen(e){for(var t=0,r=e.length,i=-1,n=0;n<r;n++)i=e.charCodeAt(n),i>=0&&i<=128?t+=1:t+=2;return t},restore(e={}){let{after:t,cursor:r,initial:i,input:n,prompt:o,size:s,value:a}=e;if(i=Il.isPrimitive(i)?String(i):"",n=Il.isPrimitive(n)?String(n):"",a=Il.isPrimitive(a)?String(a):"",s){let l=Ie.cursor.up(s)+Ie.cursor.to(this.strLen(o)),c=n.length-r;return c>0&&(l+=Ie.cursor.left(c)),l}if(a||t){let l=!n&&i?-this.strLen(i):-this.strLen(n)+r;return t&&(l-=this.strLen(t)),n===""&&i&&!o.includes(i)&&(l+=this.strLen(i)),Ie.cursor.move(l)}}},Ol=Ie.erase={screen:tt.screen,up:tt.up,down:tt.down,line:tt.line,lineEnd:tt.lineEnd,lineStart:tt.lineStart,lines(e){let t="";for(let r=0;r<e;r++)t+=Ie.erase.line+(r<e-1?Ie.cursor.up(1):"");return e&&(t+=Ie.code.beginning),t}};Ie.clear=(e="",t=process.stdout.columns)=>{if(!t)return Ol.line+It.to(0);let r=o=>[...J1(o)].length,i=e.split(/\r?\n/),n=0;for(let o of i)n+=1+Math.floor(Math.max(r(o)-1,0)/t);return(Ol.line+It.prevLine()).repeat(n-1)+Ol.line+It.to(0)}});var Xt=w((WL,Pv)=>{"use strict";var W1=Ye("events"),Iv=et(),El=wl(),H1=fv(),Y1=mv(),X1=wv(),de=oe(),Pt=kv(),Cl=class e extends W1{constructor(t={}){super(),this.name=t.name,this.type=t.type,this.options=t,X1(this),H1(this),this.state=new Y1(this),this.initial=[t.initial,t.default].find(r=>r!=null),this.stdout=t.stdout||process.stdout,this.stdin=t.stdin||process.stdin,this.scale=t.scale||1,this.term=this.options.term||process.env.TERM_PROGRAM,this.margin=eP(this.options.margin),this.setMaxListeners(0),Q1(this)}async keypress(t,r={}){this.keypressed=!0;let i=El.action(t,El(t,r),this.options.actions);this.state.keypress=i,this.emit("keypress",t,i),this.emit("state",this.state.clone());let n=this.options[i.action]||this[i.action]||this.dispatch;if(typeof n=="function")return await n.call(this,t,i);this.alert()}alert(){delete this.state.alert,this.options.show===!1?this.emit("alert"):this.stdout.write(Pt.code.beep)}cursorHide(){this.stdout.write(Pt.cursor.hide());let t=de.onExit(()=>this.cursorShow());this.on("close",()=>{this.cursorShow(),t()})}cursorShow(){this.stdout.write(Pt.cursor.show())}write(t){t&&(this.stdout&&this.state.show!==!1&&this.stdout.write(t),this.state.buffer+=t)}clear(t=0){let r=this.state.buffer;this.state.buffer="",!(!r&&!t||this.options.show===!1)&&this.stdout.write(Pt.cursor.down(t)+Pt.clear(r,this.width))}restore(){if(this.state.closed||this.options.show===!1)return;let{prompt:t,after:r,rest:i}=this.sections(),{cursor:n,initial:o="",input:s="",value:a=""}=this,l=this.state.size=i.length,c={after:r,cursor:n,initial:o,input:s,prompt:t,size:l,value:a},u=Pt.cursor.restore(c);u&&this.stdout.write(u)}sections(){let{buffer:t,input:r,prompt:i}=this.state;i=Iv(i);let n=Iv(t),o=n.indexOf(i),s=n.slice(0,o),l=n.slice(o).split(`
6
6
  `),c=l[0],u=l[l.length-1],f=(i+(r?" "+r:"")).length,m=f<c.length?c.slice(f+1):"";return{header:s,prompt:c,after:m,rest:l.slice(1),last:u}}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 t=this.state.error||await this.validate(this.value,this.state);if(t!==!0){let r=`
7
7
  `+this.symbols.pointer+" ";typeof t=="string"?r+=t.trim():r+="Invalid input",this.state.error=`
8
8
  `+this.styles.danger(r),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(t){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(t))}async close(){this.state.closed=!0;try{let t=this.sections(),r=Math.ceil(t.prompt.length/this.width);t.rest&&this.write(Pt.cursor.down(t.rest.length)),this.write(`
9
9
  `.repeat(r))}catch{}this.emit("close")}start(){!this.stop&&this.options.show!==!1&&(this.stop=El.listen(this,this.keypress.bind(this)),this.once("close",this.stop),this.emit("start",this))}async skip(){return this.skipped=this.options.skip===!0,typeof this.options.skip=="function"&&(this.skipped=await this.options.skip.call(this,this.name,this.value)),this.skipped}async initialize(){let{format:t,options:r,result:i}=this;if(this.format=()=>t.call(this,this.value),this.result=()=>i.call(this,this.value),typeof r.initial=="function"&&(this.initial=await r.initial.call(this,this)),typeof r.onRun=="function"&&await r.onRun.call(this,this),typeof r.onSubmit=="function"){let n=r.onSubmit.bind(this),o=this.submit.bind(this);delete this.options.onSubmit,this.submit=async()=>(await n(this.name,this.value,this),o())}await this.start(),await this.render()}render(){throw new Error("expected prompt to have a custom render method")}run(){return new Promise(async(t,r)=>{if(this.once("submit",t),this.once("cancel",r),await this.skip())return this.render=()=>{},this.submit();await this.initialize(),this.emit("run")})}async element(t,r,i){let{options:n,state:o,symbols:s,timers:a}=this,l=a&&a[t];o.timer=l;let c=n[t]||o[t]||s[t],u=r&&r[t]!=null?r[t]:await c;if(u==="")return u;let d=await this.resolve(u,o,r,i);return!d&&r&&r[t]?this.resolve(c,o,r,i):d}async prefix(){let t=await this.element("prefix")||this.symbols,r=this.timers&&this.timers.prefix,i=this.state;return i.timer=r,de.isObject(t)&&(t=t[i.status]||t.pending),de.hasColor(t)?t:(this.styles[i.status]||this.styles.pending)(t)}async message(){let t=await this.element("message");return de.hasColor(t)?t:this.styles.strong(t)}async separator(){let t=await this.element("separator")||this.symbols,r=this.timers&&this.timers.separator,i=this.state;i.timer=r;let n=t[i.status]||t.pending||i.separator,o=await this.resolve(n,i);return de.isObject(o)&&(o=o[i.status]||o.pending),de.hasColor(o)?o:this.styles.muted(o)}async pointer(t,r){let i=await this.element("pointer",t,r);if(typeof i=="string"&&de.hasColor(i))return i;if(i){let n=this.styles,o=this.index===r,s=o?n.primary:c=>c,a=await this.resolve(i[o?"on":"off"]||i,this.state),l=de.hasColor(a)?a:s(a);return o?l:" ".repeat(a.length)}}async indicator(t,r){let i=await this.element("indicator",t,r);if(typeof i=="string"&&de.hasColor(i))return i;if(i){let n=this.styles,o=t.enabled===!0,s=o?n.success:n.dark,a=i[o?"on":"off"]||i;return de.hasColor(a)?a:s(a)}return""}body(){return null}footer(){if(this.state.status==="pending")return this.element("footer")}header(){if(this.state.status==="pending")return this.element("header")}async hint(){if(this.state.status==="pending"&&!this.isValue(this.state.input)){let t=await this.element("hint");return de.hasColor(t)?t:this.styles.muted(t)}}error(t){return this.state.submitted?"":t||this.state.error}format(t){return t}result(t){return t}validate(t){return this.options.required===!0?this.isValue(t):!0}isValue(t){return t!=null&&t!==""}resolve(t,...r){return de.resolve(this,t,...r)}get base(){return e.prototype}get style(){return this.styles[this.state.status]}get height(){return this.options.rows||de.height(this.stdout,25)}get width(){return this.options.columns||de.width(this.stdout,80)}get size(){return{width:this.width,height:this.height}}set cursor(t){this.state.cursor=t}get cursor(){return this.state.cursor}set input(t){this.state.input=t}get input(){return this.state.input}set value(t){this.state.value=t}get value(){let{input:t,value:r}=this.state,i=[r,t].find(this.isValue.bind(this));return this.isValue(i)?i:this.initial}static get prompt(){return t=>new this(t).run()}};function Q1(e){let t=n=>e[n]===void 0||typeof e[n]=="function",r=["actions","choices","initial","margin","roles","styles","symbols","theme","timers","value"],i=["body","footer","error","header","hint","indicator","message","prefix","separator","skip"];for(let n of Object.keys(e.options)){if(r.includes(n)||/^on[A-Z]/.test(n))continue;let o=e.options[n];typeof o=="function"&&t(n)?i.includes(n)||(e[n]=o.bind(e)):typeof e[n]!="function"&&(e[n]=o)}}function eP(e){typeof e=="number"&&(e=[e,e,e,e]);let t=[].concat(e||[]),r=n=>n%2===0?`
10
- `:" ",i=[];for(let n=0;n<4;n++){let o=r(n);t[n]?i.push(o.repeat(t[n])):i.push("")}return i}Pv.exports=Cl});var Cv=w((WL,Ev)=>{"use strict";var tP=oe(),Ov={default(e,t){return t},checkbox(e,t){throw new Error("checkbox role is not implemented yet")},editable(e,t){throw new Error("editable role is not implemented yet")},expandable(e,t){throw new Error("expandable role is not implemented yet")},heading(e,t){return t.disabled="",t.indicator=[t.indicator," "].find(r=>r!=null),t.message=t.message||"",t},input(e,t){throw new Error("input role is not implemented yet")},option(e,t){return Ov.default(e,t)},radio(e,t){throw new Error("radio role is not implemented yet")},separator(e,t){return t.disabled="",t.indicator=[t.indicator," "].find(r=>r!=null),t.message=t.message||e.symbols.line.repeat(5),t},spacer(e,t){return t}};Ev.exports=(e,t={})=>{let r=tP.merge({},Ov,t.roles);return r[e]||r.default}});var rn=w((HL,Av)=>{"use strict";var rP=et(),nP=Xt(),iP=Cv(),Fi=oe(),{reorder:Tl,scrollUp:oP,scrollDown:sP,isObject:Tv,swap:aP}=Fi,Nl=class extends nP{constructor(t){super(t),this.cursorHide(),this.maxSelected=t.maxSelected||1/0,this.multiple=t.multiple||!1,this.initial=t.initial||0,this.delay=t.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:t,initial:r,autofocus:i,suggest:n}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(t)),this.choices.forEach(o=>o.enabled=!1),typeof n!="function"&&this.selectable.length===0)throw new Error("At least one choice must be selectable");Tv(r)&&(r=Object.keys(r)),Array.isArray(r)?(i!=null&&(this.index=this.findIndex(i)),r.forEach(o=>this.enable(this.find(o))),await this.render()):(i!=null&&(r=i),typeof r=="string"&&(r=this.findIndex(r)),typeof r=="number"&&r>-1&&(this.index=Math.max(0,Math.min(r,this.choices.length)),this.enable(this.find(this.index)))),this.isDisabled(this.focused)&&await this.down()}async toChoices(t,r){this.state.loadingChoices=!0;let i=[],n=0,o=async(s,a)=>{typeof s=="function"&&(s=await s.call(this)),s instanceof Promise&&(s=await s);for(let l=0;l<s.length;l++){let c=s[l]=await this.toChoice(s[l],n++,a);i.push(c),c.choices&&await o(c.choices,c)}return i};return o(t,r).then(s=>(this.state.loadingChoices=!1,s))}async toChoice(t,r,i){if(typeof t=="function"&&(t=await t.call(this,this)),t instanceof Promise&&(t=await t),typeof t=="string"&&(t={name:t}),t.normalized)return t;t.normalized=!0;let n=t.value;if(t=iP(t.role,this.options)(this,t),typeof t.disabled=="string"&&!t.hint&&(t.hint=t.disabled,t.disabled=!0),t.disabled===!0&&t.hint==null&&(t.hint="(disabled)"),t.index!=null)return t;t.name=t.name||t.key||t.title||t.value||t.message,t.message=t.message||t.name||"",t.value=[t.value,t.name].find(this.isValue.bind(this)),t.input="",t.index=r,t.cursor=0,Fi.define(t,"parent",i),t.level=i?i.level+1:1,t.indent==null&&(t.indent=i?i.indent+" ":t.indent||""),t.path=i?i.path+"."+t.name:t.name,t.enabled=!!(this.multiple&&!this.isDisabled(t)&&(t.enabled||this.isSelected(t))),this.isDisabled(t)||(this.longest=Math.max(this.longest,rP(t.message).length));let s={...t};return t.reset=(a=s.input,l=s.value)=>{for(let c of Object.keys(s))t[c]=s[c];t.input=a,t.value=l},n==null&&typeof t.initial=="function"&&(t.input=await t.initial.call(this,this.state,t,r)),t}async onChoice(t,r){this.emit("choice",t,r,this),typeof t.onChoice=="function"&&await t.onChoice.call(this,this.state,t,r)}async addChoice(t,r,i){let n=await this.toChoice(t,r,i);return this.choices.push(n),this.index=this.choices.length-1,this.limit=this.choices.length,n}async newItem(t,r,i){let n={name:"New choice name?",editable:!0,newChoice:!0,...t},o=await this.addChoice(n,r,i);return o.updateChoice=()=>{delete o.newChoice,o.name=o.message=o.input,o.input="",o.cursor=0},this.render()}indent(t){return t.indent==null?t.level>1?" ".repeat(t.level-1):"":t.indent}dispatch(t,r){if(this.multiple&&this[r.name])return this[r.name]();this.alert()}focus(t,r){return typeof r!="boolean"&&(r=t.enabled),r&&!t.enabled&&this.selected.length>=this.maxSelected?this.alert():(this.index=t.index,t.enabled=r&&!this.isDisabled(t),t)}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 t=this.selectable.every(r=>r.enabled);return this.choices.forEach(r=>r.enabled=!t),this.render()}i(){return this.choices.length-this.selected.length>this.maxSelected?this.alert():(this.choices.forEach(t=>t.enabled=!t.enabled),this.render())}g(){if(!this.choices.some(r=>!!r.parent))return this.a();let t=this.focused;return this.toggle(t.parent&&!t.choices?t.parent:t),this.render()}toggle(t,r){if(!t.enabled&&this.selected.length>=this.maxSelected)return this.alert();typeof r!="boolean"&&(r=!t.enabled),t.enabled=r,t.choices&&t.choices.forEach(n=>this.toggle(n,r));let i=t.parent;for(;i;){let n=i.choices.filter(o=>this.isDisabled(o));i.enabled=n.every(o=>o.enabled===!0),i=i.parent}return Nv(this,this.choices),this.emit("toggle",t,this),t}enable(t){return this.selected.length>=this.maxSelected?this.alert():(t.enabled=!this.isDisabled(t),t.choices&&t.choices.forEach(this.enable.bind(this)),t)}disable(t){return t.enabled=!1,t.choices&&t.choices.forEach(this.disable.bind(this)),t}number(t){this.num+=t;let r=i=>{let n=Number(i);if(n>this.choices.length-1)return this.alert();let o=this.focused,s=this.choices.find(a=>n===a.index);if(!s.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(this.visible.indexOf(s)===-1){let a=Tl(this.choices),l=a.indexOf(s);if(o.index>l){let c=a.slice(l,l+this.limit),u=a.filter(d=>!c.includes(d));this.choices=c.concat(u)}else{let c=l-this.limit+1;this.choices=a.slice(c).concat(a.slice(0,c))}}return this.index=this.choices.indexOf(s),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise(i=>{let n=this.choices.length,o=this.num,s=(a=!1,l)=>{clearTimeout(this.numberTimeout),a&&(l=r(o)),this.num="",i(l)};if(o==="0"||o.length===1&&+(o+"0")>n)return s(!0);if(Number(o)>n)return s(!1,this.alert());this.numberTimeout=setTimeout(()=>s(!0),this.delay)})}home(){return this.choices=Tl(this.choices),this.index=0,this.render()}end(){let t=this.choices.length-this.limit,r=Tl(this.choices);return this.choices=r.slice(t).concat(r.slice(0,t)),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 t=this.choices.length,r=this.visible.length,i=this.index;return this.options.scroll===!1&&i===0?this.alert():t>r&&i===0?this.scrollUp():(this.index=(i-1%t+t)%t,this.isDisabled()&&!this.allChoicesAreDisabled()?this.up():this.render())}down(){let t=this.choices.length,r=this.visible.length,i=this.index;return this.options.scroll===!1&&i===r-1?this.alert():t>r&&i===r-1?this.scrollDown():(this.index=(i+1)%t,this.isDisabled()&&!this.allChoicesAreDisabled()?this.down():this.render())}scrollUp(t=0){return this.choices=oP(this.choices),this.index=t,this.isDisabled()?this.up():this.render()}scrollDown(t=this.visible.length-1){return this.choices=sP(this.choices),this.index=t,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(t){aP(this.choices,this.index,t)}allChoicesAreDisabled(t=this.choices){return t.every(r=>this.isDisabled(r))}isDisabled(t=this.focused){return t&&["disabled","collapsed","hidden","completing","readonly"].some(i=>t[i]===!0)?!0:t&&t.role==="heading"}isEnabled(t=this.focused){if(Array.isArray(t))return t.every(r=>this.isEnabled(r));if(t.choices){let r=t.choices.filter(i=>!this.isDisabled(i));return t.enabled&&r.every(i=>this.isEnabled(i))}return t.enabled&&!this.isDisabled(t)}isChoice(t,r){return t.name===r||t.index===Number(r)}isSelected(t){return Array.isArray(this.initial)?this.initial.some(r=>this.isChoice(t,r)):this.isChoice(t,this.initial)}map(t=[],r="value"){return[].concat(t||[]).reduce((i,n)=>(i[n]=this.find(n,r),i),{})}filter(t,r){let n=typeof t=="function"?t:(a,l)=>[a.name,l].includes(t),s=(this.options.multiple?this.state._choices:this.choices).filter(n);return r?s.map(a=>a[r]):s}find(t,r){if(Tv(t))return r?t[r]:t;let n=typeof t=="function"?t:(s,a)=>[s.name,a].includes(t),o=this.choices.find(n);if(o)return r?o[r]:o}findIndex(t){return this.choices.indexOf(this.find(t))}async submit(){let t=this.focused;if(!t)return this.alert();if(t.newChoice)return t.input?(t.updateChoice(),this.render()):this.alert();if(this.choices.some(s=>s.newChoice))return this.alert();let{reorder:r,sort:i}=this.options,n=this.multiple===!0,o=this.selected;return o===void 0?this.alert():(Array.isArray(o)&&r!==!1&&i!==!0&&(o=Fi.reorder(o)),this.value=n?o.map(s=>s.name):o.name,super.submit())}set choices(t=[]){this.state._choices=this.state._choices||[],this.state.choices=t;for(let r of t)this.state._choices.some(i=>i.name===r.name)||this.state._choices.push(r);if(!this._initial&&this.options.initial){this._initial=!0;let r=this.initial;if(typeof r=="string"||typeof r=="number"){let i=this.find(r);i&&(this.initial=i.index,this.focus(i,!0))}}}get choices(){return Nv(this,this.state.choices||[])}set visible(t){this.state.visible=t}get visible(){return(this.state.visible||this.choices).slice(0,this.limit)}set limit(t){this.state.limit=t}get limit(){let{state:t,options:r,choices:i}=this,n=t.limit||this._limit||r.limit||i.length;return Math.min(n,this.height)}set value(t){super.value=t}get value(){return typeof super.value!="string"&&super.value===this.initial?this.input:super.value}set index(t){this.state.index=t}get index(){return Math.max(0,this.state?this.state.index:0)}get enabled(){return this.filter(this.isEnabled.bind(this))}get focused(){let t=this.choices[this.index];return t&&this.state.submitted&&this.multiple!==!0&&(t.enabled=!0),t}get selectable(){return this.choices.filter(t=>!this.isDisabled(t))}get selected(){return this.multiple?this.enabled:this.focused}};function Nv(e,t){if(t instanceof Promise)return t;if(typeof t=="function"){if(Fi.isAsyncFn(t))return t;t=t.call(e,e)}for(let r of t){if(Array.isArray(r.choices)){let i=r.choices.filter(n=>!e.isDisabled(n));r.enabled=i.every(n=>n.enabled===!0)}e.isDisabled(r)===!0&&delete r.enabled}return t}Av.exports=Nl});var rt=w((YL,zv)=>{"use strict";var lP=rn(),Al=oe(),zl=class extends lP{constructor(t){super(t),this.emptyError=this.options.emptyError||"No items were selected"}async dispatch(t,r){if(this.multiple)return this[r.name]?await this[r.name](t,r):await super.dispatch(t,r);this.alert()}separator(){if(this.options.separator)return super.separator();let t=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():t}pointer(t,r){return!this.multiple||this.options.pointer?super.pointer(t,r):""}indicator(t,r){return this.multiple?super.indicator(t,r):""}choiceMessage(t,r){let i=this.resolve(t.message,this.state,t,r);return t.role==="heading"&&!Al.hasColor(i)&&(i=this.styles.strong(i)),this.resolve(i,this.state,t,r)}choiceSeparator(){return":"}async renderChoice(t,r){await this.onChoice(t,r);let i=this.index===r,n=await this.pointer(t,r),o=await this.indicator(t,r)+(t.pad||""),s=await this.resolve(t.hint,this.state,t,r);s&&!Al.hasColor(s)&&(s=this.styles.muted(s));let a=this.indent(t),l=await this.choiceMessage(t,r),c=()=>[this.margin[3],a+n+o,l,this.margin[1],s].filter(Boolean).join(" ");return t.role==="heading"?c():t.disabled?(Al.hasColor(l)||(l=this.styles.disabled(l)),c()):(i&&(l=this.styles.em(l)),c())}async renderChoices(){if(this.state.loading==="choices")return this.styles.warning("Loading choices");if(this.state.submitted)return"";let t=this.visible.map(async(o,s)=>await this.renderChoice(o,s)),r=await Promise.all(t);r.length||r.push(this.styles.danger("No matching choices"));let i=this.margin[0]+r.join(`
10
+ `:" ",i=[];for(let n=0;n<4;n++){let o=r(n);t[n]?i.push(o.repeat(t[n])):i.push("")}return i}Pv.exports=Cl});var Cv=w((HL,Ev)=>{"use strict";var tP=oe(),Ov={default(e,t){return t},checkbox(e,t){throw new Error("checkbox role is not implemented yet")},editable(e,t){throw new Error("editable role is not implemented yet")},expandable(e,t){throw new Error("expandable role is not implemented yet")},heading(e,t){return t.disabled="",t.indicator=[t.indicator," "].find(r=>r!=null),t.message=t.message||"",t},input(e,t){throw new Error("input role is not implemented yet")},option(e,t){return Ov.default(e,t)},radio(e,t){throw new Error("radio role is not implemented yet")},separator(e,t){return t.disabled="",t.indicator=[t.indicator," "].find(r=>r!=null),t.message=t.message||e.symbols.line.repeat(5),t},spacer(e,t){return t}};Ev.exports=(e,t={})=>{let r=tP.merge({},Ov,t.roles);return r[e]||r.default}});var rn=w((YL,Av)=>{"use strict";var rP=et(),nP=Xt(),iP=Cv(),Fi=oe(),{reorder:Tl,scrollUp:oP,scrollDown:sP,isObject:Tv,swap:aP}=Fi,Nl=class extends nP{constructor(t){super(t),this.cursorHide(),this.maxSelected=t.maxSelected||1/0,this.multiple=t.multiple||!1,this.initial=t.initial||0,this.delay=t.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:t,initial:r,autofocus:i,suggest:n}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(t)),this.choices.forEach(o=>o.enabled=!1),typeof n!="function"&&this.selectable.length===0)throw new Error("At least one choice must be selectable");Tv(r)&&(r=Object.keys(r)),Array.isArray(r)?(i!=null&&(this.index=this.findIndex(i)),r.forEach(o=>this.enable(this.find(o))),await this.render()):(i!=null&&(r=i),typeof r=="string"&&(r=this.findIndex(r)),typeof r=="number"&&r>-1&&(this.index=Math.max(0,Math.min(r,this.choices.length)),this.enable(this.find(this.index)))),this.isDisabled(this.focused)&&await this.down()}async toChoices(t,r){this.state.loadingChoices=!0;let i=[],n=0,o=async(s,a)=>{typeof s=="function"&&(s=await s.call(this)),s instanceof Promise&&(s=await s);for(let l=0;l<s.length;l++){let c=s[l]=await this.toChoice(s[l],n++,a);i.push(c),c.choices&&await o(c.choices,c)}return i};return o(t,r).then(s=>(this.state.loadingChoices=!1,s))}async toChoice(t,r,i){if(typeof t=="function"&&(t=await t.call(this,this)),t instanceof Promise&&(t=await t),typeof t=="string"&&(t={name:t}),t.normalized)return t;t.normalized=!0;let n=t.value;if(t=iP(t.role,this.options)(this,t),typeof t.disabled=="string"&&!t.hint&&(t.hint=t.disabled,t.disabled=!0),t.disabled===!0&&t.hint==null&&(t.hint="(disabled)"),t.index!=null)return t;t.name=t.name||t.key||t.title||t.value||t.message,t.message=t.message||t.name||"",t.value=[t.value,t.name].find(this.isValue.bind(this)),t.input="",t.index=r,t.cursor=0,Fi.define(t,"parent",i),t.level=i?i.level+1:1,t.indent==null&&(t.indent=i?i.indent+" ":t.indent||""),t.path=i?i.path+"."+t.name:t.name,t.enabled=!!(this.multiple&&!this.isDisabled(t)&&(t.enabled||this.isSelected(t))),this.isDisabled(t)||(this.longest=Math.max(this.longest,rP(t.message).length));let s={...t};return t.reset=(a=s.input,l=s.value)=>{for(let c of Object.keys(s))t[c]=s[c];t.input=a,t.value=l},n==null&&typeof t.initial=="function"&&(t.input=await t.initial.call(this,this.state,t,r)),t}async onChoice(t,r){this.emit("choice",t,r,this),typeof t.onChoice=="function"&&await t.onChoice.call(this,this.state,t,r)}async addChoice(t,r,i){let n=await this.toChoice(t,r,i);return this.choices.push(n),this.index=this.choices.length-1,this.limit=this.choices.length,n}async newItem(t,r,i){let n={name:"New choice name?",editable:!0,newChoice:!0,...t},o=await this.addChoice(n,r,i);return o.updateChoice=()=>{delete o.newChoice,o.name=o.message=o.input,o.input="",o.cursor=0},this.render()}indent(t){return t.indent==null?t.level>1?" ".repeat(t.level-1):"":t.indent}dispatch(t,r){if(this.multiple&&this[r.name])return this[r.name]();this.alert()}focus(t,r){return typeof r!="boolean"&&(r=t.enabled),r&&!t.enabled&&this.selected.length>=this.maxSelected?this.alert():(this.index=t.index,t.enabled=r&&!this.isDisabled(t),t)}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 t=this.selectable.every(r=>r.enabled);return this.choices.forEach(r=>r.enabled=!t),this.render()}i(){return this.choices.length-this.selected.length>this.maxSelected?this.alert():(this.choices.forEach(t=>t.enabled=!t.enabled),this.render())}g(){if(!this.choices.some(r=>!!r.parent))return this.a();let t=this.focused;return this.toggle(t.parent&&!t.choices?t.parent:t),this.render()}toggle(t,r){if(!t.enabled&&this.selected.length>=this.maxSelected)return this.alert();typeof r!="boolean"&&(r=!t.enabled),t.enabled=r,t.choices&&t.choices.forEach(n=>this.toggle(n,r));let i=t.parent;for(;i;){let n=i.choices.filter(o=>this.isDisabled(o));i.enabled=n.every(o=>o.enabled===!0),i=i.parent}return Nv(this,this.choices),this.emit("toggle",t,this),t}enable(t){return this.selected.length>=this.maxSelected?this.alert():(t.enabled=!this.isDisabled(t),t.choices&&t.choices.forEach(this.enable.bind(this)),t)}disable(t){return t.enabled=!1,t.choices&&t.choices.forEach(this.disable.bind(this)),t}number(t){this.num+=t;let r=i=>{let n=Number(i);if(n>this.choices.length-1)return this.alert();let o=this.focused,s=this.choices.find(a=>n===a.index);if(!s.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(this.visible.indexOf(s)===-1){let a=Tl(this.choices),l=a.indexOf(s);if(o.index>l){let c=a.slice(l,l+this.limit),u=a.filter(d=>!c.includes(d));this.choices=c.concat(u)}else{let c=l-this.limit+1;this.choices=a.slice(c).concat(a.slice(0,c))}}return this.index=this.choices.indexOf(s),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise(i=>{let n=this.choices.length,o=this.num,s=(a=!1,l)=>{clearTimeout(this.numberTimeout),a&&(l=r(o)),this.num="",i(l)};if(o==="0"||o.length===1&&+(o+"0")>n)return s(!0);if(Number(o)>n)return s(!1,this.alert());this.numberTimeout=setTimeout(()=>s(!0),this.delay)})}home(){return this.choices=Tl(this.choices),this.index=0,this.render()}end(){let t=this.choices.length-this.limit,r=Tl(this.choices);return this.choices=r.slice(t).concat(r.slice(0,t)),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 t=this.choices.length,r=this.visible.length,i=this.index;return this.options.scroll===!1&&i===0?this.alert():t>r&&i===0?this.scrollUp():(this.index=(i-1%t+t)%t,this.isDisabled()&&!this.allChoicesAreDisabled()?this.up():this.render())}down(){let t=this.choices.length,r=this.visible.length,i=this.index;return this.options.scroll===!1&&i===r-1?this.alert():t>r&&i===r-1?this.scrollDown():(this.index=(i+1)%t,this.isDisabled()&&!this.allChoicesAreDisabled()?this.down():this.render())}scrollUp(t=0){return this.choices=oP(this.choices),this.index=t,this.isDisabled()?this.up():this.render()}scrollDown(t=this.visible.length-1){return this.choices=sP(this.choices),this.index=t,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(t){aP(this.choices,this.index,t)}allChoicesAreDisabled(t=this.choices){return t.every(r=>this.isDisabled(r))}isDisabled(t=this.focused){return t&&["disabled","collapsed","hidden","completing","readonly"].some(i=>t[i]===!0)?!0:t&&t.role==="heading"}isEnabled(t=this.focused){if(Array.isArray(t))return t.every(r=>this.isEnabled(r));if(t.choices){let r=t.choices.filter(i=>!this.isDisabled(i));return t.enabled&&r.every(i=>this.isEnabled(i))}return t.enabled&&!this.isDisabled(t)}isChoice(t,r){return t.name===r||t.index===Number(r)}isSelected(t){return Array.isArray(this.initial)?this.initial.some(r=>this.isChoice(t,r)):this.isChoice(t,this.initial)}map(t=[],r="value"){return[].concat(t||[]).reduce((i,n)=>(i[n]=this.find(n,r),i),{})}filter(t,r){let n=typeof t=="function"?t:(a,l)=>[a.name,l].includes(t),s=(this.options.multiple?this.state._choices:this.choices).filter(n);return r?s.map(a=>a[r]):s}find(t,r){if(Tv(t))return r?t[r]:t;let n=typeof t=="function"?t:(s,a)=>[s.name,a].includes(t),o=this.choices.find(n);if(o)return r?o[r]:o}findIndex(t){return this.choices.indexOf(this.find(t))}async submit(){let t=this.focused;if(!t)return this.alert();if(t.newChoice)return t.input?(t.updateChoice(),this.render()):this.alert();if(this.choices.some(s=>s.newChoice))return this.alert();let{reorder:r,sort:i}=this.options,n=this.multiple===!0,o=this.selected;return o===void 0?this.alert():(Array.isArray(o)&&r!==!1&&i!==!0&&(o=Fi.reorder(o)),this.value=n?o.map(s=>s.name):o.name,super.submit())}set choices(t=[]){this.state._choices=this.state._choices||[],this.state.choices=t;for(let r of t)this.state._choices.some(i=>i.name===r.name)||this.state._choices.push(r);if(!this._initial&&this.options.initial){this._initial=!0;let r=this.initial;if(typeof r=="string"||typeof r=="number"){let i=this.find(r);i&&(this.initial=i.index,this.focus(i,!0))}}}get choices(){return Nv(this,this.state.choices||[])}set visible(t){this.state.visible=t}get visible(){return(this.state.visible||this.choices).slice(0,this.limit)}set limit(t){this.state.limit=t}get limit(){let{state:t,options:r,choices:i}=this,n=t.limit||this._limit||r.limit||i.length;return Math.min(n,this.height)}set value(t){super.value=t}get value(){return typeof super.value!="string"&&super.value===this.initial?this.input:super.value}set index(t){this.state.index=t}get index(){return Math.max(0,this.state?this.state.index:0)}get enabled(){return this.filter(this.isEnabled.bind(this))}get focused(){let t=this.choices[this.index];return t&&this.state.submitted&&this.multiple!==!0&&(t.enabled=!0),t}get selectable(){return this.choices.filter(t=>!this.isDisabled(t))}get selected(){return this.multiple?this.enabled:this.focused}};function Nv(e,t){if(t instanceof Promise)return t;if(typeof t=="function"){if(Fi.isAsyncFn(t))return t;t=t.call(e,e)}for(let r of t){if(Array.isArray(r.choices)){let i=r.choices.filter(n=>!e.isDisabled(n));r.enabled=i.every(n=>n.enabled===!0)}e.isDisabled(r)===!0&&delete r.enabled}return t}Av.exports=Nl});var rt=w((XL,zv)=>{"use strict";var lP=rn(),Al=oe(),zl=class extends lP{constructor(t){super(t),this.emptyError=this.options.emptyError||"No items were selected"}async dispatch(t,r){if(this.multiple)return this[r.name]?await this[r.name](t,r):await super.dispatch(t,r);this.alert()}separator(){if(this.options.separator)return super.separator();let t=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():t}pointer(t,r){return!this.multiple||this.options.pointer?super.pointer(t,r):""}indicator(t,r){return this.multiple?super.indicator(t,r):""}choiceMessage(t,r){let i=this.resolve(t.message,this.state,t,r);return t.role==="heading"&&!Al.hasColor(i)&&(i=this.styles.strong(i)),this.resolve(i,this.state,t,r)}choiceSeparator(){return":"}async renderChoice(t,r){await this.onChoice(t,r);let i=this.index===r,n=await this.pointer(t,r),o=await this.indicator(t,r)+(t.pad||""),s=await this.resolve(t.hint,this.state,t,r);s&&!Al.hasColor(s)&&(s=this.styles.muted(s));let a=this.indent(t),l=await this.choiceMessage(t,r),c=()=>[this.margin[3],a+n+o,l,this.margin[1],s].filter(Boolean).join(" ");return t.role==="heading"?c():t.disabled?(Al.hasColor(l)||(l=this.styles.disabled(l)),c()):(i&&(l=this.styles.em(l)),c())}async renderChoices(){if(this.state.loading==="choices")return this.styles.warning("Loading choices");if(this.state.submitted)return"";let t=this.visible.map(async(o,s)=>await this.renderChoice(o,s)),r=await Promise.all(t);r.length||r.push(this.styles.danger("No matching choices"));let i=this.margin[0]+r.join(`
11
11
  `),n;return this.options.choicesHeader&&(n=await this.resolve(this.options.choicesHeader,this.state)),[n,i].filter(Boolean).join(`
12
12
  `)}format(){return!this.state.submitted||this.state.cancelled?"":Array.isArray(this.selected)?this.selected.map(t=>this.styles.primary(t.name)).join(", "):this.styles.primary(this.selected.name)}async render(){let{submitted:t,size:r}=this.state,i="",n=await this.header(),o=await this.prefix(),s=await this.separator(),a=await this.message();this.options.promptLine!==!1&&(i=[o,a,s,""].join(" "),this.state.prompt=i);let l=await this.format(),c=await this.error()||await this.hint(),u=await this.renderChoices(),d=await this.footer();l&&(i+=l),c&&!i.includes(c)&&(i+=" "+c),t&&!l&&!u.trim()&&this.multiple&&this.emptyError!=null&&(i+=this.styles.danger(this.emptyError)),this.clear(r),this.write([n,i,u,d].filter(Boolean).join(`
13
- `)),this.write(this.margin[2]),this.restore()}};zv.exports=zl});var Dv=w((XL,Rv)=>{"use strict";var cP=rt(),uP=(e,t)=>{let r=e?new RegExp(e,"ig"):/$^/;return i=>e?i.replace(r,n=>t(n)):i},Rl=class extends cP{constructor(t){super(t),this.cursorShow()}moveCursor(t){this.state.cursor+=t}dispatch(t){return this.append(t)}space(t){return this.options.multiple?super.space(t):this.append(t)}append(t){let{cursor:r,input:i}=this.state;return this.input=i.slice(0,r)+t+i.slice(r),this.moveCursor(1),this.complete()}delete(){let{cursor:t,input:r}=this.state;return r?(this.input=r.slice(0,t-1)+r.slice(t),this.moveCursor(-1),this.complete()):this.alert()}deleteForward(){let{cursor:t,input:r}=this.state;return r[t]===void 0?this.alert():(this.input=`${r}`.slice(0,t)+`${r}`.slice(t+1),this.complete())}number(t){return this.append(t)}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(t=this.input,r=this.state._choices){if(typeof this.options.suggest=="function")return this.options.suggest.call(this,t,r);let i=t.toLowerCase();return r.filter(n=>n.message.toLowerCase().includes(i))}pointer(){return""}format(){if(!this.focused)return this.input;if(this.options.multiple&&this.state.submitted)return this.selected.map(t=>this.styles.primary(t.message)).join(", ");if(this.state.submitted){let t=this.value=this.input=this.focused.value;return this.styles.primary(t)}return this.input}async render(){if(this.state.status!=="pending")return super.render();let t=this.options.highlight||this.styles.complement,r=(o,s)=>o&&(t.stack?t(o):t.call(this,o)),i=uP(this.input,r),n=this.choices;this.choices=n.map(o=>({...o,message:i(o.message)})),await super.render(),this.choices=n}submit(){return this.options.multiple&&(this.value=this.selected.map(t=>t.name)),super.submit()}};Rv.exports=Rl});var jl=w((QL,jv)=>{"use strict";var Dl=oe();jv.exports=(e,t={})=>{e.cursorHide();let{input:r="",initial:i="",pos:n,showCursor:o=!0,color:s}=t,a=s||e.styles.placeholder,l=Dl.inverse(e.styles.primary),c=h=>l(e.styles.black(h)),u=r,d=" ",f=c(d);if(e.blink&&e.blink.off===!0&&(c=h=>h,f=""),o&&n===0&&i===""&&r==="")return c(d);if(o&&n===0&&(r===i||r===""))return c(i[0])+a(i.slice(1));i=Dl.isPrimitive(i)?`${i}`:"",r=Dl.isPrimitive(r)?`${r}`:"";let m=i&&i.startsWith(r)&&i!==r,v=m?c(i[r.length]):f;if(n!==r.length&&o===!0&&(u=r.slice(0,n)+c(r[n])+r.slice(n+1),v=""),o===!1&&(v=""),m){let h=e.styles.unstyle(u+v);return u+v+a(i.slice(h.length))}return u+v}});var Zi=w((eU,Lv)=>{"use strict";var dP=et(),fP=rt(),pP=jl(),Ll=class extends fP{constructor(t){super({...t,multiple:!0}),this.type="form",this.initial=this.options.initial,this.align=[this.options.align,"right"].find(r=>r!=null),this.emptyError="",this.values={}}async reset(t){return await super.reset(),t===!0&&(this._index=this.index),this.index=this._index,this.values={},this.choices.forEach(r=>r.reset&&r.reset()),this.render()}dispatch(t){return!!t&&this.append(t)}append(t){let r=this.focused;if(!r)return this.alert();let{cursor:i,input:n}=r;return r.value=r.input=n.slice(0,i)+t+n.slice(i),r.cursor++,this.render()}delete(){let t=this.focused;if(!t||t.cursor<=0)return this.alert();let{cursor:r,input:i}=t;return t.value=t.input=i.slice(0,r-1)+i.slice(r),t.cursor--,this.render()}deleteForward(){let t=this.focused;if(!t)return this.alert();let{cursor:r,input:i}=t;if(i[r]===void 0)return this.alert();let n=`${i}`.slice(0,r)+`${i}`.slice(r+1);return t.value=t.input=n,this.render()}right(){let t=this.focused;return t?t.cursor>=t.input.length?this.alert():(t.cursor++,this.render()):this.alert()}left(){let t=this.focused;return t?t.cursor<=0?this.alert():(t.cursor--,this.render()):this.alert()}space(t,r){return this.dispatch(t,r)}number(t,r){return this.dispatch(t,r)}next(){let t=this.focused;if(!t)return this.alert();let{initial:r,input:i}=t;return r&&r.startsWith(i)&&i!==r?(t.value=t.input=r,t.cursor=t.value.length,this.render()):super.next()}prev(){let t=this.focused;return t?t.cursor===0?super.prev():(t.value=t.input="",t.cursor=0,this.render()):this.alert()}separator(){return""}format(t){return this.state.submitted?"":super.format(t)}pointer(){return""}indicator(t){return t.input?"\u29BF":"\u2299"}async choiceSeparator(t,r){let i=await this.resolve(t.separator,this.state,t,r)||":";return i?" "+this.styles.disabled(i):""}async renderChoice(t,r){await this.onChoice(t,r);let{state:i,styles:n}=this,{cursor:o,initial:s="",name:a,input:l=""}=t,{muted:c,submitted:u,primary:d,danger:f}=n,m=this.index===r,v=t.validate||(()=>!0),h=await this.choiceSeparator(t,r),b=t.message;this.align==="right"&&(b=b.padStart(this.longest+1," ")),this.align==="left"&&(b=b.padEnd(this.longest+1," "));let $=this.values[a]=l||s,S=l?"success":"dark";await v.call(t,$,this.state)!==!0&&(S="danger");let x=n[S],O=x(await this.indicator(t,r))+(t.pad||""),C=this.indent(t),N=()=>[C,O,b+h,l].filter(Boolean).join(" ");if(i.submitted)return b=dP(b),l=u(l),N();if(t.format)l=await t.format.call(this,l,t,r);else{let U=this.styles.muted;l=pP(this,{input:l,initial:s,pos:o,showCursor:m,color:U})}return this.isValue(l)||(l=this.styles.muted(this.symbols.ellipsis)),t.result&&(this.values[a]=await t.result.call(this,$,t,r)),m&&(b=d(b)),t.error?l+=(l?" ":"")+f(t.error.trim()):t.hint&&(l+=(l?" ":"")+c(t.hint.trim())),N()}async submit(){return this.value=this.values,super.base.submit.call(this)}};Lv.exports=Ll});var Ul=w((tU,Mv)=>{"use strict";var mP=Zi(),hP=()=>{throw new Error("expected prompt to have a custom authenticate method")},Uv=(e=hP)=>{class t extends mP{constructor(i){super(i)}async submit(){this.value=await e.call(this,this.values,this.state),super.base.submit.call(this)}static create(i){return Uv(i)}}return t};Mv.exports=Uv()});var Zv=w((rU,Fv)=>{"use strict";var gP=Ul();function vP(e,t){return e.username===this.options.username&&e.password===this.options.password}var qv=(e=vP)=>{let t=[{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 r extends gP.create(e){constructor(n){super({...n,choices:t})}static create(n){return qv(n)}}return r};Fv.exports=qv()});var Bi=w((nU,Bv)=>{"use strict";var yP=Xt(),{isPrimitive:bP,hasColor:wP}=oe(),Ml=class extends yP{constructor(t){super(t),this.cursorHide()}async initialize(){let t=await this.resolve(this.initial,this.state);this.input=await this.cast(t),await super.initialize()}dispatch(t){return this.isValue(t)?(this.input=t,this.submit()):this.alert()}format(t){let{styles:r,state:i}=this;return i.submitted?r.success(t):r.primary(t)}cast(t){return this.isTrue(t)}isTrue(t){return/^[ty1]/i.test(t)}isFalse(t){return/^[fn0]/i.test(t)}isValue(t){return bP(t)&&(this.isTrue(t)||this.isFalse(t))}async hint(){if(this.state.status==="pending"){let t=await this.element("hint");return wP(t)?t:this.styles.muted(t)}}async render(){let{input:t,size:r}=this.state,i=await this.prefix(),n=await this.separator(),o=await this.message(),s=this.styles.muted(this.default),a=[i,o,s,n].filter(Boolean).join(" ");this.state.prompt=a;let l=await this.header(),c=this.value=this.cast(t),u=await this.format(c),d=await this.error()||await this.hint(),f=await this.footer();d&&!a.includes(d)&&(u+=" "+d),a+=" "+u,this.clear(r),this.write([l,a,f].filter(Boolean).join(`
14
- `)),this.restore()}set value(t){super.value=t}get value(){return this.cast(super.value)}};Bv.exports=Ml});var Kv=w((iU,Vv)=>{"use strict";var $P=Bi(),ql=class extends $P{constructor(t){super(t),this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}};Vv.exports=ql});var Jv=w((oU,Gv)=>{"use strict";var xP=rt(),_P=Zi(),Qt=_P.prototype,Fl=class extends xP{constructor(t){super({...t,multiple:!0}),this.align=[this.options.align,"left"].find(r=>r!=null),this.emptyError="",this.values={}}dispatch(t,r){let i=this.focused,n=i.parent||{};return!i.editable&&!n.editable&&(t==="a"||t==="i")?super[t]():Qt.dispatch.call(this,t,r)}append(t,r){return Qt.append.call(this,t,r)}delete(t,r){return Qt.delete.call(this,t,r)}space(t){return this.focused.editable?this.append(t):super.space()}number(t){return this.focused.editable?this.append(t):super.number(t)}next(){return this.focused.editable?Qt.next.call(this):super.next()}prev(){return this.focused.editable?Qt.prev.call(this):super.prev()}async indicator(t,r){let i=t.indicator||"",n=t.editable?i:super.indicator(t,r);return await this.resolve(n,this.state,t,r)||""}indent(t){return t.role==="heading"?"":t.editable?" ":" "}async renderChoice(t,r){return t.indent="",t.editable?Qt.renderChoice.call(this,t,r):super.renderChoice(t,r)}error(){return""}footer(){return this.state.error}async validate(){let t=!0;for(let r of this.choices){if(typeof r.validate!="function"||r.role==="heading")continue;let i=r.parent?this.value[r.parent.name]:this.value;if(r.editable?i=r.value===r.name?r.initial||"":r.value:this.isDisabled(r)||(i=r.enabled===!0),t=await r.validate(i,this.state),t!==!0)break}return t!==!0&&(this.state.error=typeof t=="string"?t:"Invalid Input"),t}submit(){if(this.focused.newChoice===!0)return super.submit();if(this.choices.some(t=>t.newChoice))return this.alert();this.value={};for(let t of this.choices){let r=t.parent?this.value[t.parent.name]:this.value;if(t.role==="heading"){this.value[t.name]={};continue}t.editable?r[t.name]=t.value===t.name?t.initial||"":t.value:this.isDisabled(t)||(r[t.name]=t.enabled===!0)}return this.base.submit.call(this)}};Gv.exports=Fl});var Ot=w((sU,Wv)=>{"use strict";var SP=Xt(),kP=wl(),IP=jl(),{isPrimitive:PP}=oe(),Zl=class extends SP{constructor(t){super(t),this.initial=PP(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(t,r=t?kP(t,{}):{}){let i=Date.now(),n=i-this.lastKeypress;this.lastKeypress=i;let o=r.name==="return"||r.name==="enter",s=this.state.prevKeypress,a;if(this.state.prevKeypress=r,this.keypressTimeout!=null&&o){if(n<this.keypressTimeout)return this.submit();this.state.multilineBuffer=this.state.multilineBuffer||"",this.state.multilineBuffer+=t,a=!0,s=null}return(a||this.options.multiline&&o)&&(!s||s.name!=="return")?this.append(`
13
+ `)),this.write(this.margin[2]),this.restore()}};zv.exports=zl});var Dv=w((QL,Rv)=>{"use strict";var cP=rt(),uP=(e,t)=>{let r=e?new RegExp(e,"ig"):/$^/;return i=>e?i.replace(r,n=>t(n)):i},Rl=class extends cP{constructor(t){super(t),this.cursorShow()}moveCursor(t){this.state.cursor+=t}dispatch(t){return this.append(t)}space(t){return this.options.multiple?super.space(t):this.append(t)}append(t){let{cursor:r,input:i}=this.state;return this.input=i.slice(0,r)+t+i.slice(r),this.moveCursor(1),this.complete()}delete(){let{cursor:t,input:r}=this.state;return r?(this.input=r.slice(0,t-1)+r.slice(t),this.moveCursor(-1),this.complete()):this.alert()}deleteForward(){let{cursor:t,input:r}=this.state;return r[t]===void 0?this.alert():(this.input=`${r}`.slice(0,t)+`${r}`.slice(t+1),this.complete())}number(t){return this.append(t)}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(t=this.input,r=this.state._choices){if(typeof this.options.suggest=="function")return this.options.suggest.call(this,t,r);let i=t.toLowerCase();return r.filter(n=>n.message.toLowerCase().includes(i))}pointer(){return""}format(){if(!this.focused)return this.input;if(this.options.multiple&&this.state.submitted)return this.selected.map(t=>this.styles.primary(t.message)).join(", ");if(this.state.submitted){let t=this.value=this.input=this.focused.value;return this.styles.primary(t)}return this.input}async render(){if(this.state.status!=="pending")return super.render();let t=this.options.highlight||this.styles.complement,r=(o,s)=>o&&(t.stack?t(o):t.call(this,o)),i=uP(this.input,r),n=this.choices;this.choices=n.map(o=>({...o,message:i(o.message)})),await super.render(),this.choices=n}submit(){return this.options.multiple&&(this.value=this.selected.map(t=>t.name)),super.submit()}};Rv.exports=Rl});var jl=w((eU,jv)=>{"use strict";var Dl=oe();jv.exports=(e,t={})=>{e.cursorHide();let{input:r="",initial:i="",pos:n,showCursor:o=!0,color:s}=t,a=s||e.styles.placeholder,l=Dl.inverse(e.styles.primary),c=h=>l(e.styles.black(h)),u=r,d=" ",f=c(d);if(e.blink&&e.blink.off===!0&&(c=h=>h,f=""),o&&n===0&&i===""&&r==="")return c(d);if(o&&n===0&&(r===i||r===""))return c(i[0])+a(i.slice(1));i=Dl.isPrimitive(i)?`${i}`:"",r=Dl.isPrimitive(r)?`${r}`:"";let m=i&&i.startsWith(r)&&i!==r,v=m?c(i[r.length]):f;if(n!==r.length&&o===!0&&(u=r.slice(0,n)+c(r[n])+r.slice(n+1),v=""),o===!1&&(v=""),m){let h=e.styles.unstyle(u+v);return u+v+a(i.slice(h.length))}return u+v}});var Zi=w((tU,Lv)=>{"use strict";var dP=et(),fP=rt(),pP=jl(),Ll=class extends fP{constructor(t){super({...t,multiple:!0}),this.type="form",this.initial=this.options.initial,this.align=[this.options.align,"right"].find(r=>r!=null),this.emptyError="",this.values={}}async reset(t){return await super.reset(),t===!0&&(this._index=this.index),this.index=this._index,this.values={},this.choices.forEach(r=>r.reset&&r.reset()),this.render()}dispatch(t){return!!t&&this.append(t)}append(t){let r=this.focused;if(!r)return this.alert();let{cursor:i,input:n}=r;return r.value=r.input=n.slice(0,i)+t+n.slice(i),r.cursor++,this.render()}delete(){let t=this.focused;if(!t||t.cursor<=0)return this.alert();let{cursor:r,input:i}=t;return t.value=t.input=i.slice(0,r-1)+i.slice(r),t.cursor--,this.render()}deleteForward(){let t=this.focused;if(!t)return this.alert();let{cursor:r,input:i}=t;if(i[r]===void 0)return this.alert();let n=`${i}`.slice(0,r)+`${i}`.slice(r+1);return t.value=t.input=n,this.render()}right(){let t=this.focused;return t?t.cursor>=t.input.length?this.alert():(t.cursor++,this.render()):this.alert()}left(){let t=this.focused;return t?t.cursor<=0?this.alert():(t.cursor--,this.render()):this.alert()}space(t,r){return this.dispatch(t,r)}number(t,r){return this.dispatch(t,r)}next(){let t=this.focused;if(!t)return this.alert();let{initial:r,input:i}=t;return r&&r.startsWith(i)&&i!==r?(t.value=t.input=r,t.cursor=t.value.length,this.render()):super.next()}prev(){let t=this.focused;return t?t.cursor===0?super.prev():(t.value=t.input="",t.cursor=0,this.render()):this.alert()}separator(){return""}format(t){return this.state.submitted?"":super.format(t)}pointer(){return""}indicator(t){return t.input?"\u29BF":"\u2299"}async choiceSeparator(t,r){let i=await this.resolve(t.separator,this.state,t,r)||":";return i?" "+this.styles.disabled(i):""}async renderChoice(t,r){await this.onChoice(t,r);let{state:i,styles:n}=this,{cursor:o,initial:s="",name:a,input:l=""}=t,{muted:c,submitted:u,primary:d,danger:f}=n,m=this.index===r,v=t.validate||(()=>!0),h=await this.choiceSeparator(t,r),b=t.message;this.align==="right"&&(b=b.padStart(this.longest+1," ")),this.align==="left"&&(b=b.padEnd(this.longest+1," "));let $=this.values[a]=l||s,S=l?"success":"dark";await v.call(t,$,this.state)!==!0&&(S="danger");let x=n[S],O=x(await this.indicator(t,r))+(t.pad||""),C=this.indent(t),N=()=>[C,O,b+h,l].filter(Boolean).join(" ");if(i.submitted)return b=dP(b),l=u(l),N();if(t.format)l=await t.format.call(this,l,t,r);else{let U=this.styles.muted;l=pP(this,{input:l,initial:s,pos:o,showCursor:m,color:U})}return this.isValue(l)||(l=this.styles.muted(this.symbols.ellipsis)),t.result&&(this.values[a]=await t.result.call(this,$,t,r)),m&&(b=d(b)),t.error?l+=(l?" ":"")+f(t.error.trim()):t.hint&&(l+=(l?" ":"")+c(t.hint.trim())),N()}async submit(){return this.value=this.values,super.base.submit.call(this)}};Lv.exports=Ll});var Ul=w((rU,Mv)=>{"use strict";var mP=Zi(),hP=()=>{throw new Error("expected prompt to have a custom authenticate method")},Uv=(e=hP)=>{class t extends mP{constructor(i){super(i)}async submit(){this.value=await e.call(this,this.values,this.state),super.base.submit.call(this)}static create(i){return Uv(i)}}return t};Mv.exports=Uv()});var Zv=w((nU,Fv)=>{"use strict";var gP=Ul();function vP(e,t){return e.username===this.options.username&&e.password===this.options.password}var qv=(e=vP)=>{let t=[{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 r extends gP.create(e){constructor(n){super({...n,choices:t})}static create(n){return qv(n)}}return r};Fv.exports=qv()});var Bi=w((iU,Bv)=>{"use strict";var yP=Xt(),{isPrimitive:bP,hasColor:wP}=oe(),Ml=class extends yP{constructor(t){super(t),this.cursorHide()}async initialize(){let t=await this.resolve(this.initial,this.state);this.input=await this.cast(t),await super.initialize()}dispatch(t){return this.isValue(t)?(this.input=t,this.submit()):this.alert()}format(t){let{styles:r,state:i}=this;return i.submitted?r.success(t):r.primary(t)}cast(t){return this.isTrue(t)}isTrue(t){return/^[ty1]/i.test(t)}isFalse(t){return/^[fn0]/i.test(t)}isValue(t){return bP(t)&&(this.isTrue(t)||this.isFalse(t))}async hint(){if(this.state.status==="pending"){let t=await this.element("hint");return wP(t)?t:this.styles.muted(t)}}async render(){let{input:t,size:r}=this.state,i=await this.prefix(),n=await this.separator(),o=await this.message(),s=this.styles.muted(this.default),a=[i,o,s,n].filter(Boolean).join(" ");this.state.prompt=a;let l=await this.header(),c=this.value=this.cast(t),u=await this.format(c),d=await this.error()||await this.hint(),f=await this.footer();d&&!a.includes(d)&&(u+=" "+d),a+=" "+u,this.clear(r),this.write([l,a,f].filter(Boolean).join(`
14
+ `)),this.restore()}set value(t){super.value=t}get value(){return this.cast(super.value)}};Bv.exports=Ml});var Kv=w((oU,Vv)=>{"use strict";var $P=Bi(),ql=class extends $P{constructor(t){super(t),this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}};Vv.exports=ql});var Jv=w((sU,Gv)=>{"use strict";var xP=rt(),_P=Zi(),Qt=_P.prototype,Fl=class extends xP{constructor(t){super({...t,multiple:!0}),this.align=[this.options.align,"left"].find(r=>r!=null),this.emptyError="",this.values={}}dispatch(t,r){let i=this.focused,n=i.parent||{};return!i.editable&&!n.editable&&(t==="a"||t==="i")?super[t]():Qt.dispatch.call(this,t,r)}append(t,r){return Qt.append.call(this,t,r)}delete(t,r){return Qt.delete.call(this,t,r)}space(t){return this.focused.editable?this.append(t):super.space()}number(t){return this.focused.editable?this.append(t):super.number(t)}next(){return this.focused.editable?Qt.next.call(this):super.next()}prev(){return this.focused.editable?Qt.prev.call(this):super.prev()}async indicator(t,r){let i=t.indicator||"",n=t.editable?i:super.indicator(t,r);return await this.resolve(n,this.state,t,r)||""}indent(t){return t.role==="heading"?"":t.editable?" ":" "}async renderChoice(t,r){return t.indent="",t.editable?Qt.renderChoice.call(this,t,r):super.renderChoice(t,r)}error(){return""}footer(){return this.state.error}async validate(){let t=!0;for(let r of this.choices){if(typeof r.validate!="function"||r.role==="heading")continue;let i=r.parent?this.value[r.parent.name]:this.value;if(r.editable?i=r.value===r.name?r.initial||"":r.value:this.isDisabled(r)||(i=r.enabled===!0),t=await r.validate(i,this.state),t!==!0)break}return t!==!0&&(this.state.error=typeof t=="string"?t:"Invalid Input"),t}submit(){if(this.focused.newChoice===!0)return super.submit();if(this.choices.some(t=>t.newChoice))return this.alert();this.value={};for(let t of this.choices){let r=t.parent?this.value[t.parent.name]:this.value;if(t.role==="heading"){this.value[t.name]={};continue}t.editable?r[t.name]=t.value===t.name?t.initial||"":t.value:this.isDisabled(t)||(r[t.name]=t.enabled===!0)}return this.base.submit.call(this)}};Gv.exports=Fl});var Ot=w((aU,Wv)=>{"use strict";var SP=Xt(),kP=wl(),IP=jl(),{isPrimitive:PP}=oe(),Zl=class extends SP{constructor(t){super(t),this.initial=PP(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(t,r=t?kP(t,{}):{}){let i=Date.now(),n=i-this.lastKeypress;this.lastKeypress=i;let o=r.name==="return"||r.name==="enter",s=this.state.prevKeypress,a;if(this.state.prevKeypress=r,this.keypressTimeout!=null&&o){if(n<this.keypressTimeout)return this.submit();this.state.multilineBuffer=this.state.multilineBuffer||"",this.state.multilineBuffer+=t,a=!0,s=null}return(a||this.options.multiline&&o)&&(!s||s.name!=="return")?this.append(`
15
15
  `,r):super.keypress(t,r)}moveCursor(t){this.cursor+=t}reset(){return this.input=this.value="",this.cursor=0,this.render()}dispatch(t,r){if(!t||r.ctrl||r.code)return this.alert();this.append(t)}append(t){let{cursor:r,input:i}=this.state;this.input=`${i}`.slice(0,r)+t+`${i}`.slice(r),this.moveCursor(String(t).length),this.render()}insert(t){this.append(t)}delete(){let{cursor:t,input:r}=this.state;if(t<=0)return this.alert();this.input=`${r}`.slice(0,t-1)+`${r}`.slice(t),this.moveCursor(-1),this.render()}deleteForward(){let{cursor:t,input:r}=this.state;if(r[t]===void 0)return this.alert();this.input=`${r}`.slice(0,t)+`${r}`.slice(t+1),this.render()}cutForward(){let t=this.cursor;if(this.input.length<=t)return this.alert();this.state.clipboard.push(this.input.slice(t)),this.input=this.input.slice(0,t),this.render()}cutLeft(){let t=this.cursor;if(t===0)return this.alert();let r=this.input.slice(0,t),i=this.input.slice(t),n=r.split(" ");this.state.clipboard.push(n.pop()),this.input=n.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 t=this.initial!=null?String(this.initial):"";if(!t||!t.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(t){return!!t}async format(t=this.value){let r=await this.resolve(this.initial,this.state);return this.state.submitted?this.styles.submitted(t||r):IP(this,{input:t,initial:r,pos:this.cursor})}async render(){let t=this.state.size,r=await this.prefix(),i=await this.separator(),n=await this.message(),o=[r,n,i].filter(Boolean).join(" ");this.state.prompt=o;let s=await this.header(),a=await this.format(),l=await this.error()||await this.hint(),c=await this.footer();l&&!a.includes(l)&&(a+=" "+l),o+=" "+a,this.clear(t),this.write([s,o,c].filter(Boolean).join(`
16
- `)),this.restore()}};Wv.exports=Zl});var Yv=w((aU,Hv)=>{"use strict";var OP=e=>e.filter((t,r)=>e.lastIndexOf(t)===r),Vi=e=>OP(e).filter(Boolean);Hv.exports=(e,t={},r="")=>{let{past:i=[],present:n=""}=t,o,s;switch(e){case"prev":case"undo":return o=i.slice(0,i.length-1),s=i[i.length-1]||"",{past:Vi([r,...o]),present:s};case"next":case"redo":return o=i.slice(1),s=i[0]||"",{past:Vi([...o,r]),present:s};case"save":return{past:Vi([...i,r]),present:""};case"remove":return s=Vi(i.filter(a=>a!==r)),n="",s.length&&(n=s.pop()),{past:s,present:n};default:throw new Error(`Invalid action: "${e}"`)}}});var Vl=w((lU,Qv)=>{"use strict";var EP=Ot(),Xv=Yv(),Bl=class extends EP{constructor(t){super(t);let r=this.options.history;if(r&&r.store){let i=r.values||this.initial;this.autosave=!!r.autosave,this.store=r.store,this.data=this.store.get("values")||{past:[],present:i},this.initial=this.data.present||this.data.past[this.data.past.length-1]}}completion(t){return this.store?(this.data=Xv(t,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=Xv("save",this.data,this.input),this.store.set("values",this.data))}submit(){return this.store&&this.autosave===!0&&this.save(),super.submit()}};Qv.exports=Bl});var ty=w((cU,ey)=>{"use strict";var CP=Ot(),Kl=class extends CP{format(){return""}};ey.exports=Kl});var ny=w((uU,ry)=>{"use strict";var TP=Ot(),Gl=class extends TP{constructor(t={}){super(t),this.sep=this.options.separator||/, */,this.initial=t.initial||""}split(t=this.value){return t?String(t).split(this.sep):[]}format(){let t=this.state.submitted?this.styles.primary:r=>r;return this.list.map(t).join(", ")}async submit(t){let r=this.state.error||await this.validate(this.list,this.state);return r!==!0?(this.state.error=r,super.submit()):(this.value=this.list,super.submit())}get list(){return this.split()}};ry.exports=Gl});var oy=w((dU,iy)=>{"use strict";var NP=rt(),Jl=class extends NP{constructor(t){super({...t,multiple:!0})}};iy.exports=Jl});var Hl=w((fU,sy)=>{"use strict";var AP=Ot(),Wl=class extends AP{constructor(t={}){super({style:"number",...t}),this.min=this.isValue(t.min)?this.toNumber(t.min):-1/0,this.max=this.isValue(t.max)?this.toNumber(t.max):1/0,this.delay=t.delay!=null?t.delay:1e3,this.float=t.float!==!1,this.round=t.round===!0||t.float===!1,this.major=t.major||10,this.minor=t.minor||1,this.initial=t.initial!=null?t.initial:"",this.input=String(this.initial),this.cursor=this.input.length,this.cursorShow()}append(t){return!/[-+.]/.test(t)||t==="."&&this.input.includes(".")?this.alert("invalid number"):super.append(t)}number(t){return super.append(t)}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(t){let r=t||this.minor,i=this.toNumber(this.input);return i>this.max+r?this.alert():(this.input=`${i+r}`,this.render())}down(t){let r=t||this.minor,i=this.toNumber(this.input);return i<this.min-r?this.alert():(this.input=`${i-r}`,this.render())}shiftDown(){return this.down(this.major)}shiftUp(){return this.up(this.major)}format(t=this.input){return typeof this.options.format=="function"?this.options.format.call(this,t):this.styles.info(t)}toNumber(t=""){return this.float?+t:Math.round(+t)}isValue(t){return/^[-+]?[0-9]+((\.)|(\.[0-9]+))?$/.test(t)}submit(){let t=[this.input,this.initial].find(r=>this.isValue(r));return this.value=this.toNumber(t||0),super.submit()}};sy.exports=Wl});var ly=w((pU,ay)=>{ay.exports=Hl()});var uy=w((mU,cy)=>{"use strict";var zP=Ot(),Yl=class extends zP{constructor(t){super(t),this.cursorShow()}format(t=this.input){return this.keypressed?(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(t.length)):""}};cy.exports=Yl});var py=w((hU,fy)=>{"use strict";var RP=et(),DP=rn(),dy=oe(),Xl=class extends DP{constructor(t={}){super(t),this.widths=[].concat(t.messageWidth||50),this.align=[].concat(t.align||"left"),this.linebreak=t.linebreak||!1,this.edgeLength=t.edgeLength||3,this.newline=t.newline||`
16
+ `)),this.restore()}};Wv.exports=Zl});var Yv=w((lU,Hv)=>{"use strict";var OP=e=>e.filter((t,r)=>e.lastIndexOf(t)===r),Vi=e=>OP(e).filter(Boolean);Hv.exports=(e,t={},r="")=>{let{past:i=[],present:n=""}=t,o,s;switch(e){case"prev":case"undo":return o=i.slice(0,i.length-1),s=i[i.length-1]||"",{past:Vi([r,...o]),present:s};case"next":case"redo":return o=i.slice(1),s=i[0]||"",{past:Vi([...o,r]),present:s};case"save":return{past:Vi([...i,r]),present:""};case"remove":return s=Vi(i.filter(a=>a!==r)),n="",s.length&&(n=s.pop()),{past:s,present:n};default:throw new Error(`Invalid action: "${e}"`)}}});var Vl=w((cU,Qv)=>{"use strict";var EP=Ot(),Xv=Yv(),Bl=class extends EP{constructor(t){super(t);let r=this.options.history;if(r&&r.store){let i=r.values||this.initial;this.autosave=!!r.autosave,this.store=r.store,this.data=this.store.get("values")||{past:[],present:i},this.initial=this.data.present||this.data.past[this.data.past.length-1]}}completion(t){return this.store?(this.data=Xv(t,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=Xv("save",this.data,this.input),this.store.set("values",this.data))}submit(){return this.store&&this.autosave===!0&&this.save(),super.submit()}};Qv.exports=Bl});var ty=w((uU,ey)=>{"use strict";var CP=Ot(),Kl=class extends CP{format(){return""}};ey.exports=Kl});var ny=w((dU,ry)=>{"use strict";var TP=Ot(),Gl=class extends TP{constructor(t={}){super(t),this.sep=this.options.separator||/, */,this.initial=t.initial||""}split(t=this.value){return t?String(t).split(this.sep):[]}format(){let t=this.state.submitted?this.styles.primary:r=>r;return this.list.map(t).join(", ")}async submit(t){let r=this.state.error||await this.validate(this.list,this.state);return r!==!0?(this.state.error=r,super.submit()):(this.value=this.list,super.submit())}get list(){return this.split()}};ry.exports=Gl});var oy=w((fU,iy)=>{"use strict";var NP=rt(),Jl=class extends NP{constructor(t){super({...t,multiple:!0})}};iy.exports=Jl});var Hl=w((pU,sy)=>{"use strict";var AP=Ot(),Wl=class extends AP{constructor(t={}){super({style:"number",...t}),this.min=this.isValue(t.min)?this.toNumber(t.min):-1/0,this.max=this.isValue(t.max)?this.toNumber(t.max):1/0,this.delay=t.delay!=null?t.delay:1e3,this.float=t.float!==!1,this.round=t.round===!0||t.float===!1,this.major=t.major||10,this.minor=t.minor||1,this.initial=t.initial!=null?t.initial:"",this.input=String(this.initial),this.cursor=this.input.length,this.cursorShow()}append(t){return!/[-+.]/.test(t)||t==="."&&this.input.includes(".")?this.alert("invalid number"):super.append(t)}number(t){return super.append(t)}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(t){let r=t||this.minor,i=this.toNumber(this.input);return i>this.max+r?this.alert():(this.input=`${i+r}`,this.render())}down(t){let r=t||this.minor,i=this.toNumber(this.input);return i<this.min-r?this.alert():(this.input=`${i-r}`,this.render())}shiftDown(){return this.down(this.major)}shiftUp(){return this.up(this.major)}format(t=this.input){return typeof this.options.format=="function"?this.options.format.call(this,t):this.styles.info(t)}toNumber(t=""){return this.float?+t:Math.round(+t)}isValue(t){return/^[-+]?[0-9]+((\.)|(\.[0-9]+))?$/.test(t)}submit(){let t=[this.input,this.initial].find(r=>this.isValue(r));return this.value=this.toNumber(t||0),super.submit()}};sy.exports=Wl});var ly=w((mU,ay)=>{ay.exports=Hl()});var uy=w((hU,cy)=>{"use strict";var zP=Ot(),Yl=class extends zP{constructor(t){super(t),this.cursorShow()}format(t=this.input){return this.keypressed?(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(t.length)):""}};cy.exports=Yl});var py=w((gU,fy)=>{"use strict";var RP=et(),DP=rn(),dy=oe(),Xl=class extends DP{constructor(t={}){super(t),this.widths=[].concat(t.messageWidth||50),this.align=[].concat(t.align||"left"),this.linebreak=t.linebreak||!1,this.edgeLength=t.edgeLength||3,this.newline=t.newline||`
17
17
  `;let r=t.startNumber||1;typeof this.scale=="number"&&(this.scaleKey=!1,this.scale=Array(this.scale).fill(0).map((i,n)=>({name:n+r})))}async reset(){return this.tableized=!1,await super.reset(),this.render()}tableize(){if(this.tableized===!0)return;this.tableized=!0;let t=0;for(let r of this.choices){t=Math.max(t,r.message.length),r.scaleIndex=r.initial||2,r.scale=[];for(let i=0;i<this.scale.length;i++)r.scale.push({index:i})}this.widths[0]=Math.min(this.widths[0],t+3)}async dispatch(t,r){if(this.multiple)return this[r.name]?await this[r.name](t,r):await super.dispatch(t,r);this.alert()}heading(t,r,i){return this.styles.strong(t)}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let t=this.focused;return t.scaleIndex>=this.scale.length-1?this.alert():(t.scaleIndex++,this.render())}left(){let t=this.focused;return t.scaleIndex<=0?this.alert():(t.scaleIndex--,this.render())}indent(){return""}format(){return this.state.submitted?this.choices.map(r=>this.styles.info(r.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(`
18
18
  `)}renderScaleHeading(t){let r=this.scale.map(l=>l.name);typeof this.options.renderScaleHeading=="function"&&(r=this.options.renderScaleHeading.call(this,t));let i=this.scaleLength-r.join("").length,n=Math.round(i/(r.length-1)),s=r.map(l=>this.styles.strong(l)).join(" ".repeat(n)),a=" ".repeat(this.widths[0]);return this.margin[3]+a+this.margin[1]+s}scaleIndicator(t,r,i){if(typeof this.options.scaleIndicator=="function")return this.options.scaleIndicator.call(this,t,r,i);let n=t.scaleIndex===r.index;return r.disabled?this.styles.hint(this.symbols.radio.disabled):n?this.styles.success(this.symbols.radio.on):this.symbols.radio.off}renderScale(t,r){let i=t.scale.map(o=>this.scaleIndicator(t,o,r)),n=this.term==="Hyper"?"":" ";return i.join(n+this.symbols.line.repeat(this.edgeLength))}async renderChoice(t,r){await this.onChoice(t,r);let i=this.index===r,n=await this.pointer(t,r),o=await t.hint;o&&!dy.hasColor(o)&&(o=this.styles.muted(o));let s=v=>this.margin[3]+v.replace(/\s+$/,"").padEnd(this.widths[0]," "),a=this.newline,l=this.indent(t),c=await this.resolve(t.message,this.state,t,r),u=await this.renderScale(t,r),d=this.margin[1]+this.margin[3];this.scaleLength=RP(u).length,this.widths[0]=Math.min(this.widths[0],this.width-this.scaleLength-d.length);let m=dy.wordWrap(c,{width:this.widths[0],newline:a}).split(`
19
19
  `).map(v=>s(v)+this.margin[1]);return i&&(u=this.styles.info(u),m=m.map(v=>this.styles.info(v))),m[0]+=u,this.linebreak&&m.push(""),[l+n,m.join(`
20
20
  `)].filter(Boolean)}async renderChoices(){if(this.state.submitted)return"";this.tableize();let t=this.visible.map(async(n,o)=>await this.renderChoice(n,o)),r=await Promise.all(t),i=await this.renderScaleHeading();return this.margin[0]+[i,...r.map(n=>n.join(" "))].join(`
21
21
  `)}async render(){let{submitted:t,size:r}=this.state,i=await this.prefix(),n=await this.separator(),o=await this.message(),s="";this.options.promptLine!==!1&&(s=[i,o,n,""].join(" "),this.state.prompt=s);let a=await this.header(),l=await this.format(),c=await this.renderScaleKey(),u=await this.error()||await this.hint(),d=await this.renderChoices(),f=await this.footer(),m=this.emptyError;l&&(s+=l),u&&!s.includes(u)&&(s+=" "+u),t&&!l&&!d.trim()&&this.multiple&&m!=null&&(s+=this.styles.danger(m)),this.clear(r),this.write([a,s,c,d,f].filter(Boolean).join(`
22
- `)),this.state.submitted||this.write(this.margin[2]),this.restore()}submit(){this.value={};for(let t of this.choices)this.value[t.name]=t.scaleIndex;return this.base.submit.call(this)}};fy.exports=Xl});var gy=w((gU,hy)=>{"use strict";var my=et(),jP=(e="")=>typeof e=="string"?e.replace(/^['"]|['"]$/g,""):"",ec=class{constructor(t){this.name=t.key,this.field=t.field||{},this.value=jP(t.initial||this.field.initial||""),this.message=t.message||this.name,this.cursor=0,this.input="",this.lines=[]}},LP=async(e={},t={},r=i=>i)=>{let i=new Set,n=e.fields||[],o=e.template,s=[],a=[],l=[],c=1;typeof o=="function"&&(o=await o());let u=-1,d=()=>o[++u],f=()=>o[u+1],m=v=>{v.line=c,s.push(v)};for(m({type:"bos",value:""});u<o.length-1;){let v=d();if(/^[^\S\n ]$/.test(v)){m({type:"text",value:v});continue}if(v===`
22
+ `)),this.state.submitted||this.write(this.margin[2]),this.restore()}submit(){this.value={};for(let t of this.choices)this.value[t.name]=t.scaleIndex;return this.base.submit.call(this)}};fy.exports=Xl});var gy=w((vU,hy)=>{"use strict";var my=et(),jP=(e="")=>typeof e=="string"?e.replace(/^['"]|['"]$/g,""):"",ec=class{constructor(t){this.name=t.key,this.field=t.field||{},this.value=jP(t.initial||this.field.initial||""),this.message=t.message||this.name,this.cursor=0,this.input="",this.lines=[]}},LP=async(e={},t={},r=i=>i)=>{let i=new Set,n=e.fields||[],o=e.template,s=[],a=[],l=[],c=1;typeof o=="function"&&(o=await o());let u=-1,d=()=>o[++u],f=()=>o[u+1],m=v=>{v.line=c,s.push(v)};for(m({type:"bos",value:""});u<o.length-1;){let v=d();if(/^[^\S\n ]$/.test(v)){m({type:"text",value:v});continue}if(v===`
23
23
  `){m({type:"newline",value:v}),c++;continue}if(v==="\\"){v+=d(),m({type:"text",value:v});continue}if((v==="$"||v==="#"||v==="{")&&f()==="{"){let b=d();v+=b;let $={type:"template",open:v,inner:"",close:"",value:v},S;for(;S=d();){if(S==="}"){f()==="}"&&(S+=d()),$.value+=S,$.close=S;break}S===":"?($.initial="",$.key=$.inner):$.initial!==void 0&&($.initial+=S),$.value+=S,$.inner+=S}$.template=$.open+($.initial||$.inner)+$.close,$.key=$.key||$.inner,hasOwnProperty.call(t,$.key)&&($.initial=t[$.key]),$=r($),m($),l.push($.key),i.add($.key);let x=a.find(O=>O.name===$.key);$.field=n.find(O=>O.name===$.key),x||(x=new ec($),a.push(x)),x.lines.push($.line-1);continue}let h=s[s.length-1];h.type==="text"&&h.line===c?h.value+=v:m({type:"text",value:v})}return m({type:"eos",value:""}),{input:o,tabstops:s,unique:i,keys:l,items:a}};hy.exports=async e=>{let t=e.options,r=new Set(t.required===!0?[]:t.required||[]),i={...t.values,...t.initial},{tabstops:n,items:o,keys:s}=await LP(t,i),a=Ql("result",e,t),l=Ql("format",e,t),c=Ql("validate",e,t,!0),u=e.isValue.bind(e);return async(d={},f=!1)=>{let m=0;d.required=r,d.items=o,d.keys=s,d.output="";let v=async(S,x,O,C)=>{let N=await c(S,x,O,C);return N===!1?"Invalid field "+O.name:N};for(let S of n){let x=S.value,O=S.key;if(S.type!=="template"){x&&(d.output+=x);continue}if(S.type==="template"){let C=o.find(ae=>ae.name===O);t.required===!0&&d.required.add(C.name);let N=[C.input,d.values[C.value],C.value,x].find(u),T=(C.field||{}).message||S.inner;if(f){let ae=await v(d.values[O],d,C,m);if(ae&&typeof ae=="string"||ae===!1){d.invalid.set(O,ae);continue}d.invalid.delete(O);let He=await a(d.values[O],d,C,m);d.output+=my(He);continue}C.placeholder=!1;let H=x;x=await l(x,d,C,m),N!==x?(d.values[O]=N,x=e.styles.typing(N),d.missing.delete(T)):(d.values[O]=void 0,N=`<${T}>`,x=e.styles.primary(N),C.placeholder=!0,d.required.has(O)&&d.missing.add(T)),d.missing.has(T)&&d.validating&&(x=e.styles.warning(N)),d.invalid.has(O)&&d.validating&&(x=e.styles.danger(N)),m===d.index&&(H!==x?x=e.styles.underline(x):x=e.styles.heading(my(x))),m++}x&&(d.output+=x)}let h=d.output.split(`
24
24
  `).map(S=>" "+S),b=o.length,$=0;for(let S of o)d.invalid.has(S.name)&&S.lines.forEach(x=>{h[x][0]===" "&&(h[x]=d.styles.danger(d.symbols.bullet)+h[x].slice(1))}),e.isValue(d.values[S.name])&&$++;return d.completed=($/b*100).toFixed(0),d.output=h.join(`
25
- `),d.output}};function Ql(e,t,r,i){return(n,o,s,a)=>typeof s.field[e]=="function"?s.field[e].call(t,n,o,s,a):[i,n].find(l=>t.isValue(l))}});var yy=w((vU,vy)=>{"use strict";var UP=et(),MP=gy(),qP=Xt(),tc=class extends qP{constructor(t){super(t),this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await MP(this),await super.initialize()}async reset(t){this.state.keys=[],this.state.invalid=new Map,this.state.missing=new Set,this.state.completed=0,this.state.values={},t!==!0&&(await this.initialize(),await this.render())}moveCursor(t){let r=this.getItem();this.cursor+=t,r.cursor+=t}dispatch(t,r){if(!r.code&&!r.ctrl&&t!=null&&this.getItem()){this.append(t,r);return}this.alert()}append(t,r){let i=this.getItem(),n=i.input.slice(0,this.cursor),o=i.input.slice(this.cursor);this.input=i.input=`${n}${t}${o}`,this.moveCursor(1),this.render()}delete(){let t=this.getItem();if(this.cursor<=0||!t.input)return this.alert();let r=t.input.slice(this.cursor),i=t.input.slice(0,this.cursor-1);this.input=t.input=`${i}${r}`,this.moveCursor(-1),this.render()}increment(t){return t>=this.state.keys.length-1?0:t+1}decrement(t){return t<=0?this.state.keys.length-1:t-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(t){let r=this.state.completed<100?this.styles.warning:this.styles.success;return this.state.submitted===!0&&this.state.completed!==100&&(r=this.styles.danger),r(`${this.state.completed}% completed`)}async render(){let{index:t,keys:r=[],submitted:i,size:n}=this.state,o=[this.options.newline,`
25
+ `),d.output}};function Ql(e,t,r,i){return(n,o,s,a)=>typeof s.field[e]=="function"?s.field[e].call(t,n,o,s,a):[i,n].find(l=>t.isValue(l))}});var yy=w((yU,vy)=>{"use strict";var UP=et(),MP=gy(),qP=Xt(),tc=class extends qP{constructor(t){super(t),this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await MP(this),await super.initialize()}async reset(t){this.state.keys=[],this.state.invalid=new Map,this.state.missing=new Set,this.state.completed=0,this.state.values={},t!==!0&&(await this.initialize(),await this.render())}moveCursor(t){let r=this.getItem();this.cursor+=t,r.cursor+=t}dispatch(t,r){if(!r.code&&!r.ctrl&&t!=null&&this.getItem()){this.append(t,r);return}this.alert()}append(t,r){let i=this.getItem(),n=i.input.slice(0,this.cursor),o=i.input.slice(this.cursor);this.input=i.input=`${n}${t}${o}`,this.moveCursor(1),this.render()}delete(){let t=this.getItem();if(this.cursor<=0||!t.input)return this.alert();let r=t.input.slice(this.cursor),i=t.input.slice(0,this.cursor-1);this.input=t.input=`${i}${r}`,this.moveCursor(-1),this.render()}increment(t){return t>=this.state.keys.length-1?0:t+1}decrement(t){return t<=0?this.state.keys.length-1:t-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(t){let r=this.state.completed<100?this.styles.warning:this.styles.success;return this.state.submitted===!0&&this.state.completed!==100&&(r=this.styles.danger),r(`${this.state.completed}% completed`)}async render(){let{index:t,keys:r=[],submitted:i,size:n}=this.state,o=[this.options.newline,`
26
26
  `].find(S=>S!=null),s=await this.prefix(),a=await this.separator(),l=await this.message(),c=[s,l,a].filter(Boolean).join(" ");this.state.prompt=c;let u=await this.header(),d=await this.error()||"",f=await this.hint()||"",m=i?"":await this.interpolate(this.state),v=this.state.key=r[t]||"",h=await this.format(v),b=await this.footer();h&&(c+=" "+h),f&&!h&&this.state.completed===0&&(c+=" "+f),this.clear(n);let $=[u,c,m,b,d.trim()];this.write($.filter(Boolean).join(o)),this.restore()}getItem(t){let{items:r,keys:i,index:n}=this.state,o=r.find(s=>s.name===i[n]);return o&&o.input!=null&&(this.input=o.input,this.cursor=o.cursor),o}async submit(){typeof this.interpolate!="function"&&await this.initialize(),await this.interpolate(this.state,!0);let{invalid:t,missing:r,output:i,values:n}=this.state;if(t.size){let a="";for(let[l,c]of t)a+=`Invalid ${l}: ${c}
27
27
  `;return this.state.error=a,super.submit()}if(r.size)return this.state.error="Required: "+[...r.keys()].join(", "),super.submit();let s=UP(i).split(`
28
28
  `).map(a=>a.slice(1)).join(`
29
- `);return this.value={values:n,result:s},super.submit()}};vy.exports=tc});var wy=w((yU,by)=>{"use strict";var FP="(Use <shift>+<up/down> to sort)",ZP=rt(),rc=class extends ZP{constructor(t){super({...t,reorder:!1,sort:!0,multiple:!0}),this.state.hint=[this.options.hint,FP].find(this.isValue.bind(this))}indicator(){return""}async renderChoice(t,r){let i=await super.renderChoice(t,r),n=this.symbols.identicalTo+" ",o=this.index===r&&this.sorting?this.styles.muted(n):" ";return this.options.drag===!1&&(o=""),this.options.numbered===!0?o+`${r+1} - `+i:o+i}get selected(){return this.choices}submit(){return this.value=this.choices.map(t=>t.value),super.submit()}};by.exports=rc});var xy=w((bU,$y)=>{"use strict";var BP=rn(),nc=class extends BP{constructor(t={}){if(super(t),this.emptyError=t.emptyError||"No items were selected",this.term=process.env.TERM_PROGRAM,!this.options.header){let r=["","4 - Strongly Agree","3 - Agree","2 - Neutral","1 - Disagree","0 - Strongly Disagree",""];r=r.map(i=>this.styles.muted(i)),this.state.header=r.join(`
29
+ `);return this.value={values:n,result:s},super.submit()}};vy.exports=tc});var wy=w((bU,by)=>{"use strict";var FP="(Use <shift>+<up/down> to sort)",ZP=rt(),rc=class extends ZP{constructor(t){super({...t,reorder:!1,sort:!0,multiple:!0}),this.state.hint=[this.options.hint,FP].find(this.isValue.bind(this))}indicator(){return""}async renderChoice(t,r){let i=await super.renderChoice(t,r),n=this.symbols.identicalTo+" ",o=this.index===r&&this.sorting?this.styles.muted(n):" ";return this.options.drag===!1&&(o=""),this.options.numbered===!0?o+`${r+1} - `+i:o+i}get selected(){return this.choices}submit(){return this.value=this.choices.map(t=>t.value),super.submit()}};by.exports=rc});var xy=w((wU,$y)=>{"use strict";var BP=rn(),nc=class extends BP{constructor(t={}){if(super(t),this.emptyError=t.emptyError||"No items were selected",this.term=process.env.TERM_PROGRAM,!this.options.header){let r=["","4 - Strongly Agree","3 - Agree","2 - Neutral","1 - Disagree","0 - Strongly Disagree",""];r=r.map(i=>this.styles.muted(i)),this.state.header=r.join(`
30
30
  `)}}async toChoices(...t){if(this.createdScales)return!1;this.createdScales=!0;let r=await super.toChoices(...t);for(let i of r)i.scale=VP(5,this.options),i.scaleIdx=2;return r}dispatch(){this.alert()}space(){let t=this.focused,r=t.scale[t.scaleIdx],i=r.selected;return t.scale.forEach(n=>n.selected=!1),r.selected=!i,this.render()}indicator(){return""}pointer(){return""}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let t=this.focused;return t.scaleIdx>=t.scale.length-1?this.alert():(t.scaleIdx++,this.render())}left(){let t=this.focused;return t.scaleIdx<=0?this.alert():(t.scaleIdx--,this.render())}indent(){return" "}async renderChoice(t,r){await this.onChoice(t,r);let i=this.index===r,n=this.term==="Hyper",o=n?9:8,s=n?"":" ",a=this.symbols.line.repeat(o),l=" ".repeat(o+(n?0:1)),c=x=>(x?this.styles.success("\u25C9"):"\u25EF")+s,u=r+1+".",d=i?this.styles.heading:this.styles.noop,f=await this.resolve(t.message,this.state,t,r),m=this.indent(t),v=m+t.scale.map((x,O)=>c(O===t.scaleIdx)).join(a),h=x=>x===t.scaleIdx?d(x):x,b=m+t.scale.map((x,O)=>h(O)).join(l),$=()=>[u,f].filter(Boolean).join(" "),S=()=>[$(),v,b," "].filter(Boolean).join(`
31
31
  `);return i&&(v=this.styles.cyan(v),b=this.styles.cyan(b)),S()}async renderChoices(){if(this.state.submitted)return"";let t=this.visible.map(async(i,n)=>await this.renderChoice(i,n)),r=await Promise.all(t);return r.length||r.push(this.styles.danger("No matching choices")),r.join(`
32
32
  `)}format(){return this.state.submitted?this.choices.map(r=>this.styles.info(r.scaleIdx)).join(", "):""}async render(){let{submitted:t,size:r}=this.state,i=await this.prefix(),n=await this.separator(),o=await this.message(),s=[i,o,n].filter(Boolean).join(" ");this.state.prompt=s;let a=await this.header(),l=await this.format(),c=await this.error()||await this.hint(),u=await this.renderChoices(),d=await this.footer();(l||!c)&&(s+=" "+l),c&&!s.includes(c)&&(s+=" "+c),t&&!l&&!u&&this.multiple&&this.type!=="form"&&(s+=this.styles.danger(this.emptyError)),this.clear(r),this.write([s,a,u,d].filter(Boolean).join(`
33
- `)),this.restore()}submit(){this.value={};for(let t of this.choices)this.value[t.name]=t.scaleIdx;return this.base.submit.call(this)}};function VP(e,t={}){if(Array.isArray(t.scale))return t.scale.map(i=>({...i}));let r=[];for(let i=1;i<e+1;i++)r.push({i,selected:!1});return r}$y.exports=nc});var Sy=w((wU,_y)=>{_y.exports=Vl()});var Iy=w(($U,ky)=>{"use strict";var KP=Bi(),ic=class extends KP{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(t="",r){switch(t.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 t=i=>this.styles.primary.underline(i);return[this.value?this.disabled:t(this.disabled),this.value?t(this.enabled):this.enabled].join(this.styles.muted(" / "))}async render(){let{size:t}=this.state,r=await this.header(),i=await this.prefix(),n=await this.separator(),o=await this.message(),s=await this.format(),a=await this.error()||await this.hint(),l=await this.footer(),c=[i,o,n,s].join(" ");this.state.prompt=c,a&&!c.includes(a)&&(c+=" "+a),this.clear(t),this.write([r,c,l].filter(Boolean).join(`
34
- `)),this.write(this.margin[2]),this.restore()}};ky.exports=ic});var Oy=w((xU,Py)=>{"use strict";var GP=rt(),oc=class extends GP{constructor(t){if(super(t),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(t,r){let i=await super.toChoices(t,r);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(t){return t.index===this.options.correctChoice}async result(t){return{selectedAnswer:t,correctAnswer:this.options.choices[this.options.correctChoice].value,correct:await this.check(this.state)}}};Py.exports=oc});var Cy=w(sc=>{"use strict";var Ey=oe(),Q=(e,t)=>{Ey.defineExport(sc,e,t),Ey.defineExport(sc,e.toLowerCase(),t)};Q("AutoComplete",()=>Dv());Q("BasicAuth",()=>Zv());Q("Confirm",()=>Kv());Q("Editable",()=>Jv());Q("Form",()=>Zi());Q("Input",()=>Vl());Q("Invisible",()=>ty());Q("List",()=>ny());Q("MultiSelect",()=>oy());Q("Numeral",()=>ly());Q("Password",()=>uy());Q("Scale",()=>py());Q("Select",()=>rt());Q("Snippet",()=>yy());Q("Sort",()=>wy());Q("Survey",()=>xy());Q("Text",()=>Sy());Q("Toggle",()=>Iy());Q("Quiz",()=>Oy())});var Ny=w((SU,Ty)=>{Ty.exports={ArrayPrompt:rn(),AuthPrompt:Ul(),BooleanPrompt:Bi(),NumberPrompt:Hl(),StringPrompt:Ot()}});var Ry=w((kU,zy)=>{"use strict";var Ay=Ye("assert"),lc=Ye("events"),nt=oe(),Pe=class extends lc{constructor(t,r){super(),this.options=nt.merge({},t),this.answers={...r}}register(t,r){if(nt.isObject(t)){for(let n of Object.keys(t))this.register(n,t[n]);return this}Ay.equal(typeof r,"function","expected a function");let i=t.toLowerCase();return r.prototype instanceof this.Prompt?this.prompts[i]=r:this.prompts[i]=r(this.Prompt,this),this}async prompt(t=[]){for(let r of[].concat(t))try{typeof r=="function"&&(r=await r.call(this)),await this.ask(nt.merge({},this.options,r))}catch(i){return Promise.reject(i)}return this.answers}async ask(t){typeof t=="function"&&(t=await t.call(this));let r=nt.merge({},this.options,t),{type:i,name:n}=t,{set:o,get:s}=nt;if(typeof i=="function"&&(i=await i.call(this,t,this.answers)),!i)return this.answers[n];i==="number"&&(i="numeral"),Ay(this.prompts[i],`Prompt "${i}" is not registered`);let a=new this.prompts[i](r),l=s(this.answers,n);a.state.answers=this.answers,a.enquirer=this,n&&a.on("submit",u=>{this.emit("answer",n,u,a),o(this.answers,n,u)});let c=a.emit.bind(a);return a.emit=(...u)=>(this.emit.call(this,...u),c(...u)),this.emit("prompt",a,this),r.autofill&&l!=null?(a.value=a.input=l,r.autofill==="show"&&await a.submit()):l=a.value=await a.run(),l}use(t){return t.call(this,this),this}set Prompt(t){this._Prompt=t}get Prompt(){return this._Prompt||this.constructor.Prompt}get prompts(){return this.constructor.prompts}static set Prompt(t){this._Prompt=t}static get Prompt(){return this._Prompt||Xt()}static get prompts(){return Cy()}static get types(){return Ny()}static get prompt(){let t=(r,...i)=>{let n=new this(...i),o=n.emit.bind(n);return n.emit=(...s)=>(t.emit(...s),o(...s)),n.prompt(r)};return nt.mixinEmitter(t,new lc),t}};nt.mixinEmitter(Pe,new lc);var ac=Pe.prompts;for(let e of Object.keys(ac)){let t=e.toLowerCase(),r=i=>new ac[e](i).run();Pe.prompt[t]=r,Pe[t]=r,Pe[e]||Reflect.defineProperty(Pe,e,{get:()=>ac[e]})}var nn=e=>{nt.defineExport(Pe,e,()=>Pe.types[e])};nn("ArrayPrompt");nn("AuthPrompt");nn("BooleanPrompt");nn("NumberPrompt");nn("StringPrompt");zy.exports=Pe});var L=w(ne=>{"use strict";var Vc=Symbol.for("yaml.alias"),E$=Symbol.for("yaml.document"),So=Symbol.for("yaml.map"),C$=Symbol.for("yaml.pair"),Kc=Symbol.for("yaml.scalar"),ko=Symbol.for("yaml.seq"),Be=Symbol.for("yaml.node.type"),_N=e=>!!e&&typeof e=="object"&&e[Be]===Vc,SN=e=>!!e&&typeof e=="object"&&e[Be]===E$,kN=e=>!!e&&typeof e=="object"&&e[Be]===So,IN=e=>!!e&&typeof e=="object"&&e[Be]===C$,T$=e=>!!e&&typeof e=="object"&&e[Be]===Kc,PN=e=>!!e&&typeof e=="object"&&e[Be]===ko;function N$(e){if(e&&typeof e=="object")switch(e[Be]){case So:case ko:return!0}return!1}function ON(e){if(e&&typeof e=="object")switch(e[Be]){case Vc:case So:case Kc:case ko:return!0}return!1}var EN=e=>(T$(e)||N$(e))&&!!e.anchor;ne.ALIAS=Vc;ne.DOC=E$;ne.MAP=So;ne.NODE_TYPE=Be;ne.PAIR=C$;ne.SCALAR=Kc;ne.SEQ=ko;ne.hasAnchor=EN;ne.isAlias=_N;ne.isCollection=N$;ne.isDocument=SN;ne.isMap=kN;ne.isNode=ON;ne.isPair=IN;ne.isScalar=T$;ne.isSeq=PN});var bn=w(Gc=>{"use strict";var ee=L(),pe=Symbol("break visit"),A$=Symbol("skip children"),De=Symbol("remove node");function Io(e,t){let r=z$(t);ee.isDocument(e)?fr(null,e.contents,r,Object.freeze([e]))===De&&(e.contents=null):fr(null,e,r,Object.freeze([]))}Io.BREAK=pe;Io.SKIP=A$;Io.REMOVE=De;function fr(e,t,r,i){let n=R$(e,t,r,i);if(ee.isNode(n)||ee.isPair(n))return D$(e,i,n),fr(e,n,r,i);if(typeof n!="symbol"){if(ee.isCollection(t)){i=Object.freeze(i.concat(t));for(let o=0;o<t.items.length;++o){let s=fr(o,t.items[o],r,i);if(typeof s=="number")o=s-1;else{if(s===pe)return pe;s===De&&(t.items.splice(o,1),o-=1)}}}else if(ee.isPair(t)){i=Object.freeze(i.concat(t));let o=fr("key",t.key,r,i);if(o===pe)return pe;o===De&&(t.key=null);let s=fr("value",t.value,r,i);if(s===pe)return pe;s===De&&(t.value=null)}}return n}async function Po(e,t){let r=z$(t);ee.isDocument(e)?await pr(null,e.contents,r,Object.freeze([e]))===De&&(e.contents=null):await pr(null,e,r,Object.freeze([]))}Po.BREAK=pe;Po.SKIP=A$;Po.REMOVE=De;async function pr(e,t,r,i){let n=await R$(e,t,r,i);if(ee.isNode(n)||ee.isPair(n))return D$(e,i,n),pr(e,n,r,i);if(typeof n!="symbol"){if(ee.isCollection(t)){i=Object.freeze(i.concat(t));for(let o=0;o<t.items.length;++o){let s=await pr(o,t.items[o],r,i);if(typeof s=="number")o=s-1;else{if(s===pe)return pe;s===De&&(t.items.splice(o,1),o-=1)}}}else if(ee.isPair(t)){i=Object.freeze(i.concat(t));let o=await pr("key",t.key,r,i);if(o===pe)return pe;o===De&&(t.key=null);let s=await pr("value",t.value,r,i);if(s===pe)return pe;s===De&&(t.value=null)}}return n}function z$(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function R$(e,t,r,i){if(typeof r=="function")return r(e,t,i);if(ee.isMap(t))return r.Map?.(e,t,i);if(ee.isSeq(t))return r.Seq?.(e,t,i);if(ee.isPair(t))return r.Pair?.(e,t,i);if(ee.isScalar(t))return r.Scalar?.(e,t,i);if(ee.isAlias(t))return r.Alias?.(e,t,i)}function D$(e,t,r){let i=t[t.length-1];if(ee.isCollection(i))i.items[e]=r;else if(ee.isPair(i))e==="key"?i.key=r:i.value=r;else if(ee.isDocument(i))i.contents=r;else{let n=ee.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}Gc.visit=Io;Gc.visitAsync=Po});var Jc=w(L$=>{"use strict";var j$=L(),CN=bn(),TN={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},NN=e=>e.replace(/[!,[\]{}]/g,t=>TN[t]),wn=class e{constructor(t,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,r)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,r){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let i=t.trim().split(/[ \t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[o,s]=i;return this.tags[o]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[o]=i;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let s=/^\d+\.\d+$/.test(o);return r(6,`Unsupported YAML version ${o}`,s),!1}}default:return r(0,`Unknown directive ${n}`,!0),!1}}tagName(t,r){if(t==="!")return"!";if(t[0]!=="!")return r(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let s=t.slice(2,-1);return s==="!"||s==="!!"?(r(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&r("Verbatim tags must end with a >"),s)}let[,i,n]=t.match(/^(.*!)([^!]*)$/s);n||r(`The ${t} tag has no suffix`);let o=this.tags[i];if(o)try{return o+decodeURIComponent(n)}catch(s){return r(String(s)),null}return i==="!"?t:(r(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[r,i]of Object.entries(this.tags))if(t.startsWith(i))return r+NN(t.substring(i.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),n;if(t&&i.length>0&&j$.isNode(t.contents)){let o={};CN.visit(t.contents,(s,a)=>{j$.isNode(a)&&a.tag&&(o[a.tag]=!0)}),n=Object.keys(o)}else n=[];for(let[o,s]of i)o==="!!"&&s==="tag:yaml.org,2002:"||(!t||n.some(a=>a.startsWith(s)))&&r.push(`%TAG ${o} ${s}`);return r.join(`
33
+ `)),this.restore()}submit(){this.value={};for(let t of this.choices)this.value[t.name]=t.scaleIdx;return this.base.submit.call(this)}};function VP(e,t={}){if(Array.isArray(t.scale))return t.scale.map(i=>({...i}));let r=[];for(let i=1;i<e+1;i++)r.push({i,selected:!1});return r}$y.exports=nc});var Sy=w(($U,_y)=>{_y.exports=Vl()});var Iy=w((xU,ky)=>{"use strict";var KP=Bi(),ic=class extends KP{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(t="",r){switch(t.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 t=i=>this.styles.primary.underline(i);return[this.value?this.disabled:t(this.disabled),this.value?t(this.enabled):this.enabled].join(this.styles.muted(" / "))}async render(){let{size:t}=this.state,r=await this.header(),i=await this.prefix(),n=await this.separator(),o=await this.message(),s=await this.format(),a=await this.error()||await this.hint(),l=await this.footer(),c=[i,o,n,s].join(" ");this.state.prompt=c,a&&!c.includes(a)&&(c+=" "+a),this.clear(t),this.write([r,c,l].filter(Boolean).join(`
34
+ `)),this.write(this.margin[2]),this.restore()}};ky.exports=ic});var Oy=w((_U,Py)=>{"use strict";var GP=rt(),oc=class extends GP{constructor(t){if(super(t),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(t,r){let i=await super.toChoices(t,r);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(t){return t.index===this.options.correctChoice}async result(t){return{selectedAnswer:t,correctAnswer:this.options.choices[this.options.correctChoice].value,correct:await this.check(this.state)}}};Py.exports=oc});var Cy=w(sc=>{"use strict";var Ey=oe(),Q=(e,t)=>{Ey.defineExport(sc,e,t),Ey.defineExport(sc,e.toLowerCase(),t)};Q("AutoComplete",()=>Dv());Q("BasicAuth",()=>Zv());Q("Confirm",()=>Kv());Q("Editable",()=>Jv());Q("Form",()=>Zi());Q("Input",()=>Vl());Q("Invisible",()=>ty());Q("List",()=>ny());Q("MultiSelect",()=>oy());Q("Numeral",()=>ly());Q("Password",()=>uy());Q("Scale",()=>py());Q("Select",()=>rt());Q("Snippet",()=>yy());Q("Sort",()=>wy());Q("Survey",()=>xy());Q("Text",()=>Sy());Q("Toggle",()=>Iy());Q("Quiz",()=>Oy())});var Ny=w((kU,Ty)=>{Ty.exports={ArrayPrompt:rn(),AuthPrompt:Ul(),BooleanPrompt:Bi(),NumberPrompt:Hl(),StringPrompt:Ot()}});var Ry=w((IU,zy)=>{"use strict";var Ay=Ye("assert"),lc=Ye("events"),nt=oe(),Pe=class extends lc{constructor(t,r){super(),this.options=nt.merge({},t),this.answers={...r}}register(t,r){if(nt.isObject(t)){for(let n of Object.keys(t))this.register(n,t[n]);return this}Ay.equal(typeof r,"function","expected a function");let i=t.toLowerCase();return r.prototype instanceof this.Prompt?this.prompts[i]=r:this.prompts[i]=r(this.Prompt,this),this}async prompt(t=[]){for(let r of[].concat(t))try{typeof r=="function"&&(r=await r.call(this)),await this.ask(nt.merge({},this.options,r))}catch(i){return Promise.reject(i)}return this.answers}async ask(t){typeof t=="function"&&(t=await t.call(this));let r=nt.merge({},this.options,t),{type:i,name:n}=t,{set:o,get:s}=nt;if(typeof i=="function"&&(i=await i.call(this,t,this.answers)),!i)return this.answers[n];i==="number"&&(i="numeral"),Ay(this.prompts[i],`Prompt "${i}" is not registered`);let a=new this.prompts[i](r),l=s(this.answers,n);a.state.answers=this.answers,a.enquirer=this,n&&a.on("submit",u=>{this.emit("answer",n,u,a),o(this.answers,n,u)});let c=a.emit.bind(a);return a.emit=(...u)=>(this.emit.call(this,...u),c(...u)),this.emit("prompt",a,this),r.autofill&&l!=null?(a.value=a.input=l,r.autofill==="show"&&await a.submit()):l=a.value=await a.run(),l}use(t){return t.call(this,this),this}set Prompt(t){this._Prompt=t}get Prompt(){return this._Prompt||this.constructor.Prompt}get prompts(){return this.constructor.prompts}static set Prompt(t){this._Prompt=t}static get Prompt(){return this._Prompt||Xt()}static get prompts(){return Cy()}static get types(){return Ny()}static get prompt(){let t=(r,...i)=>{let n=new this(...i),o=n.emit.bind(n);return n.emit=(...s)=>(t.emit(...s),o(...s)),n.prompt(r)};return nt.mixinEmitter(t,new lc),t}};nt.mixinEmitter(Pe,new lc);var ac=Pe.prompts;for(let e of Object.keys(ac)){let t=e.toLowerCase(),r=i=>new ac[e](i).run();Pe.prompt[t]=r,Pe[t]=r,Pe[e]||Reflect.defineProperty(Pe,e,{get:()=>ac[e]})}var nn=e=>{nt.defineExport(Pe,e,()=>Pe.types[e])};nn("ArrayPrompt");nn("AuthPrompt");nn("BooleanPrompt");nn("NumberPrompt");nn("StringPrompt");zy.exports=Pe});var L=w(ne=>{"use strict";var Vc=Symbol.for("yaml.alias"),E$=Symbol.for("yaml.document"),So=Symbol.for("yaml.map"),C$=Symbol.for("yaml.pair"),Kc=Symbol.for("yaml.scalar"),ko=Symbol.for("yaml.seq"),Be=Symbol.for("yaml.node.type"),_N=e=>!!e&&typeof e=="object"&&e[Be]===Vc,SN=e=>!!e&&typeof e=="object"&&e[Be]===E$,kN=e=>!!e&&typeof e=="object"&&e[Be]===So,IN=e=>!!e&&typeof e=="object"&&e[Be]===C$,T$=e=>!!e&&typeof e=="object"&&e[Be]===Kc,PN=e=>!!e&&typeof e=="object"&&e[Be]===ko;function N$(e){if(e&&typeof e=="object")switch(e[Be]){case So:case ko:return!0}return!1}function ON(e){if(e&&typeof e=="object")switch(e[Be]){case Vc:case So:case Kc:case ko:return!0}return!1}var EN=e=>(T$(e)||N$(e))&&!!e.anchor;ne.ALIAS=Vc;ne.DOC=E$;ne.MAP=So;ne.NODE_TYPE=Be;ne.PAIR=C$;ne.SCALAR=Kc;ne.SEQ=ko;ne.hasAnchor=EN;ne.isAlias=_N;ne.isCollection=N$;ne.isDocument=SN;ne.isMap=kN;ne.isNode=ON;ne.isPair=IN;ne.isScalar=T$;ne.isSeq=PN});var bn=w(Gc=>{"use strict";var ee=L(),pe=Symbol("break visit"),A$=Symbol("skip children"),De=Symbol("remove node");function Io(e,t){let r=z$(t);ee.isDocument(e)?fr(null,e.contents,r,Object.freeze([e]))===De&&(e.contents=null):fr(null,e,r,Object.freeze([]))}Io.BREAK=pe;Io.SKIP=A$;Io.REMOVE=De;function fr(e,t,r,i){let n=R$(e,t,r,i);if(ee.isNode(n)||ee.isPair(n))return D$(e,i,n),fr(e,n,r,i);if(typeof n!="symbol"){if(ee.isCollection(t)){i=Object.freeze(i.concat(t));for(let o=0;o<t.items.length;++o){let s=fr(o,t.items[o],r,i);if(typeof s=="number")o=s-1;else{if(s===pe)return pe;s===De&&(t.items.splice(o,1),o-=1)}}}else if(ee.isPair(t)){i=Object.freeze(i.concat(t));let o=fr("key",t.key,r,i);if(o===pe)return pe;o===De&&(t.key=null);let s=fr("value",t.value,r,i);if(s===pe)return pe;s===De&&(t.value=null)}}return n}async function Po(e,t){let r=z$(t);ee.isDocument(e)?await pr(null,e.contents,r,Object.freeze([e]))===De&&(e.contents=null):await pr(null,e,r,Object.freeze([]))}Po.BREAK=pe;Po.SKIP=A$;Po.REMOVE=De;async function pr(e,t,r,i){let n=await R$(e,t,r,i);if(ee.isNode(n)||ee.isPair(n))return D$(e,i,n),pr(e,n,r,i);if(typeof n!="symbol"){if(ee.isCollection(t)){i=Object.freeze(i.concat(t));for(let o=0;o<t.items.length;++o){let s=await pr(o,t.items[o],r,i);if(typeof s=="number")o=s-1;else{if(s===pe)return pe;s===De&&(t.items.splice(o,1),o-=1)}}}else if(ee.isPair(t)){i=Object.freeze(i.concat(t));let o=await pr("key",t.key,r,i);if(o===pe)return pe;o===De&&(t.key=null);let s=await pr("value",t.value,r,i);if(s===pe)return pe;s===De&&(t.value=null)}}return n}function z$(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function R$(e,t,r,i){if(typeof r=="function")return r(e,t,i);if(ee.isMap(t))return r.Map?.(e,t,i);if(ee.isSeq(t))return r.Seq?.(e,t,i);if(ee.isPair(t))return r.Pair?.(e,t,i);if(ee.isScalar(t))return r.Scalar?.(e,t,i);if(ee.isAlias(t))return r.Alias?.(e,t,i)}function D$(e,t,r){let i=t[t.length-1];if(ee.isCollection(i))i.items[e]=r;else if(ee.isPair(i))e==="key"?i.key=r:i.value=r;else if(ee.isDocument(i))i.contents=r;else{let n=ee.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}Gc.visit=Io;Gc.visitAsync=Po});var Jc=w(L$=>{"use strict";var j$=L(),CN=bn(),TN={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},NN=e=>e.replace(/[!,[\]{}]/g,t=>TN[t]),wn=class e{constructor(t,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,r)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,r){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let i=t.trim().split(/[ \t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[o,s]=i;return this.tags[o]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[o]=i;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let s=/^\d+\.\d+$/.test(o);return r(6,`Unsupported YAML version ${o}`,s),!1}}default:return r(0,`Unknown directive ${n}`,!0),!1}}tagName(t,r){if(t==="!")return"!";if(t[0]!=="!")return r(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let s=t.slice(2,-1);return s==="!"||s==="!!"?(r(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&r("Verbatim tags must end with a >"),s)}let[,i,n]=t.match(/^(.*!)([^!]*)$/s);n||r(`The ${t} tag has no suffix`);let o=this.tags[i];if(o)try{return o+decodeURIComponent(n)}catch(s){return r(String(s)),null}return i==="!"?t:(r(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[r,i]of Object.entries(this.tags))if(t.startsWith(i))return r+NN(t.substring(i.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),n;if(t&&i.length>0&&j$.isNode(t.contents)){let o={};CN.visit(t.contents,(s,a)=>{j$.isNode(a)&&a.tag&&(o[a.tag]=!0)}),n=Object.keys(o)}else n=[];for(let[o,s]of i)o==="!!"&&s==="tag:yaml.org,2002:"||(!t||n.some(a=>a.startsWith(s)))&&r.push(`%TAG ${o} ${s}`);return r.join(`
35
35
  `)}};wn.defaultYaml={explicit:!1,version:"1.2"};wn.defaultTags={"!!":"tag:yaml.org,2002:"};L$.Directives=wn});var Oo=w($n=>{"use strict";var U$=L(),AN=bn();function zN(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(r)}return!0}function M$(e){let t=new Set;return AN.visit(e,{Value(r,i){i.anchor&&t.add(i.anchor)}}),t}function q$(e,t){for(let r=1;;++r){let i=`${e}${r}`;if(!t.has(i))return i}}function RN(e,t){let r=[],i=new Map,n=null;return{onAnchor:o=>{r.push(o),n??(n=M$(e));let s=q$(t,n);return n.add(s),s},setAnchors:()=>{for(let o of r){let s=i.get(o);if(typeof s=="object"&&s.anchor&&(U$.isScalar(s.node)||U$.isCollection(s.node)))s.node.anchor=s.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:i}}$n.anchorIsValid=zN;$n.anchorNames=M$;$n.createNodeAnchors=RN;$n.findNewAnchor=q$});var Wc=w(F$=>{"use strict";function xn(e,t,r,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,o=i.length;n<o;++n){let s=i[n],a=xn(e,i,String(n),s);a===void 0?delete i[n]:a!==s&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let o=i.get(n),s=xn(e,i,n,o);s===void 0?i.delete(n):s!==o&&i.set(n,s)}else if(i instanceof Set)for(let n of Array.from(i)){let o=xn(e,i,n,n);o===void 0?i.delete(n):o!==n&&(i.delete(n),i.add(o))}else for(let[n,o]of Object.entries(i)){let s=xn(e,i,n,o);s===void 0?delete i[n]:s!==o&&(i[n]=s)}return e.call(t,r,i)}F$.applyReviver=xn});var st=w(B$=>{"use strict";var DN=L();function Z$(e,t,r){if(Array.isArray(e))return e.map((i,n)=>Z$(i,String(n),r));if(e&&typeof e.toJSON=="function"){if(!r||!DN.hasAnchor(e))return e.toJSON(t,r);let i={aliasCount:0,count:1,res:void 0};r.anchors.set(e,i),r.onCreate=o=>{i.res=o,delete r.onCreate};let n=e.toJSON(t,r);return r.onCreate&&r.onCreate(n),n}return typeof e=="bigint"&&!r?.keep?Number(e):e}B$.toJS=Z$});var Eo=w(K$=>{"use strict";var jN=Wc(),V$=L(),LN=st(),Hc=class{constructor(t){Object.defineProperty(this,V$.NODE_TYPE,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:r,maxAliasCount:i,onAnchor:n,reviver:o}={}){if(!V$.isDocument(t))throw new TypeError("A document argument is required");let s={anchors:new Map,doc:t,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},a=LN.toJS(this,"",s);if(typeof n=="function")for(let{count:l,res:c}of s.anchors.values())n(c,l);return typeof o=="function"?jN.applyReviver(o,{"":a},"",a):a}};K$.NodeBase=Hc});var _n=w(G$=>{"use strict";var UN=Oo(),MN=bn(),mr=L(),qN=Eo(),FN=st(),Yc=class extends qN.NodeBase{constructor(t){super(mr.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,r){let i;r?.aliasResolveCache?i=r.aliasResolveCache:(i=[],MN.visit(t,{Node:(o,s)=>{(mr.isAlias(s)||mr.hasAnchor(s))&&i.push(s)}}),r&&(r.aliasResolveCache=i));let n;for(let o of i){if(o===this)break;o.anchor===this.source&&(n=o)}return n}toJSON(t,r){if(!r)return{source:this.source};let{anchors:i,doc:n,maxAliasCount:o}=r,s=this.resolve(n,r);if(!s){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=i.get(s);if(a||(FN.toJS(s,null,r),a=i.get(s)),a?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(o>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Co(n,s,i)),a.count*a.aliasCount>o)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(t,r,i){let n=`*${this.source}`;if(t){if(UN.anchorIsValid(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let o=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(o)}if(t.implicitKey)return`${n} `}return n}};function Co(e,t,r){if(mr.isAlias(t)){let i=t.resolve(e),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(mr.isCollection(t)){let i=0;for(let n of t.items){let o=Co(e,n,r);o>i&&(i=o)}return i}else if(mr.isPair(t)){let i=Co(e,t.key,r),n=Co(e,t.value,r);return Math.max(i,n)}return 1}G$.Alias=Yc});var Y=w(Xc=>{"use strict";var ZN=L(),BN=Eo(),VN=st(),KN=e=>!e||typeof e!="function"&&typeof e!="object",at=class extends BN.NodeBase{constructor(t){super(ZN.SCALAR),this.value=t}toJSON(t,r){return r?.keep?this.value:VN.toJS(this.value,t,r)}toString(){return String(this.value)}};at.BLOCK_FOLDED="BLOCK_FOLDED";at.BLOCK_LITERAL="BLOCK_LITERAL";at.PLAIN="PLAIN";at.QUOTE_DOUBLE="QUOTE_DOUBLE";at.QUOTE_SINGLE="QUOTE_SINGLE";Xc.Scalar=at;Xc.isScalarValue=KN});var Sn=w(W$=>{"use strict";var GN=_n(),At=L(),J$=Y(),JN="tag:yaml.org,2002:";function WN(e,t,r){if(t){let i=r.filter(o=>o.tag===t),n=i.find(o=>!o.format)??i[0];if(!n)throw new Error(`Tag ${t} not found`);return n}return r.find(i=>i.identify?.(e)&&!i.format)}function HN(e,t,r){if(At.isDocument(e)&&(e=e.contents),At.isNode(e))return e;if(At.isPair(e)){let d=r.schema[At.MAP].createNode?.(r.schema,null,r);return d.items.push(e),d}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:o,schema:s,sourceObjects:a}=r,l;if(i&&e&&typeof e=="object"){if(l=a.get(e),l)return l.anchor??(l.anchor=n(e)),new GN.Alias(l.anchor);l={anchor:null,node:null},a.set(e,l)}t?.startsWith("!!")&&(t=JN+t.slice(2));let c=WN(e,t,s.tags);if(!c){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let d=new J$.Scalar(e);return l&&(l.node=d),d}c=e instanceof Map?s[At.MAP]:Symbol.iterator in Object(e)?s[At.SEQ]:s[At.MAP]}o&&(o(c),delete r.onTagObj);let u=c?.createNode?c.createNode(r.schema,e,r):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(r.schema,e,r):new J$.Scalar(e);return t?u.tag=t:c.default||(u.tag=c.tag),l&&(l.node=u),u}W$.createNode=HN});var No=w(To=>{"use strict";var YN=Sn(),je=L(),XN=Eo();function Qc(e,t,r){let i=r;for(let n=t.length-1;n>=0;--n){let o=t[n];if(typeof o=="number"&&Number.isInteger(o)&&o>=0){let s=[];s[o]=i,i=s}else i=new Map([[o,i]])}return YN.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var H$=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,eu=class extends XN.NodeBase{constructor(t,r){super(t),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(t){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(r.schema=t),r.items=r.items.map(i=>je.isNode(i)||je.isPair(i)?i.clone(t):i),this.range&&(r.range=this.range.slice()),r}addIn(t,r){if(H$(t))this.add(r);else{let[i,...n]=t,o=this.get(i,!0);if(je.isCollection(o))o.addIn(n,r);else if(o===void 0&&this.schema)this.set(i,Qc(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}deleteIn(t){let[r,...i]=t;if(i.length===0)return this.delete(r);let n=this.get(r,!0);if(je.isCollection(n))return n.deleteIn(i);throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}getIn(t,r){let[i,...n]=t,o=this.get(i,!0);return n.length===0?!r&&je.isScalar(o)?o.value:o:je.isCollection(o)?o.getIn(n,r):void 0}hasAllNullValues(t){return this.items.every(r=>{if(!je.isPair(r))return!1;let i=r.value;return i==null||t&&je.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(t){let[r,...i]=t;if(i.length===0)return this.has(r);let n=this.get(r,!0);return je.isCollection(n)?n.hasIn(i):!1}setIn(t,r){let[i,...n]=t;if(n.length===0)this.set(i,r);else{let o=this.get(i,!0);if(je.isCollection(o))o.setIn(n,r);else if(o===void 0&&this.schema)this.set(i,Qc(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};To.Collection=eu;To.collectionFromPath=Qc;To.isEmptyPath=H$});var kn=w(Ao=>{"use strict";var QN=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function tu(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var eA=(e,t,r)=>e.endsWith(`
36
36
  `)?tu(r,t):r.includes(`
37
37
  `)?`
@@ -190,11 +190,11 @@ ${s}
190
190
  `)}}r&&console.error(r),process.exit(1)}function IO(e){let t=e;if(!(typeof t?.topLeft!="string"||typeof t.bottomRight!="string"))return{topLeft:t.topLeft,bottomRight:t.bottomRight}}function PO(e){if(Array.isArray(e))return e.flatMap(t=>{let{id:r,ticked:i,comment:n}=t??{};return typeof r!="string"?[]:[{id:r,ticked:i===!0,...typeof n=="string"&&n!==""?{comment:n}:{}}]})}function Qy(e){return e.decision!=="approve"&&e.decision!=="reject"?null:{decision:e.decision,reason:e.reason,comments:Array.isArray(e.comments)?e.comments:void 0,screenshots:Array.isArray(e.screenshots)?e.screenshots:void 0,body:typeof e.body=="string"?e.body:void 0,reviewAfter:e.reviewAfter===!0,announceAfter:e.announceAfter===!0,draft:typeof e.draft=="boolean"?e.draft:void 0,autoMerge:e.autoMerge===!0,selection:IO(e.selection),checklist:PO(e.checklist)}}function eb(e,t){try{let r=JSON.parse(e);if(r.type==="error"&&(r.message??"").includes("pr-preview"))return{kind:"error",message:r.message??"pr-preview failed"};if(r.type!=="pr-decision"||r.requestId!==t)return null;let i=Qy(r);return i?{kind:"decision",decision:i}:null}catch{return null}}function tb(e){return new Promise((t,r)=>{Qe().then(i=>{let n=!1,o=(s,a)=>{n||(n=!0,i.destroy(),s?r(s):t(a))};Ht(i,s=>{let a=eb(s,e.requestId);a&&(a.kind==="error"?o(new Error(a.message)):o(void 0,a.decision))}),i.on("error",s=>o(s)),i.on("close",()=>o(new Error("daemon closed before a decision was made"))),i.write(`${JSON.stringify({type:"pr-preview",...e})}
191
191
  `)},r)})}async function rb(e,t,r={}){console.log("Awaiting your approval in the assist web UI preview pane\u2026");let i;try{i=await tb(t)}catch(n){console.error(`Error: ${n instanceof Error?n.message:String(n)}`),process.exit(1)}return i.body!==void 0&&r.saveEditedBody?.(i.body),i.decision==="reject"&&!r.rejectIsOutcome&&Xy(e,i,r.rejectionAdvice),i}async function nb(e,t,r){let i=process.env.ASSIST_SESSION_ID;process.env.ASSIST_SESSION!=="1"||!i||await rb("PR comment preview",{sessionId:i,requestId:OO(),title:e,body:t,prNumber:r,kind:"pr-comment"})}function EO(e){let t=e.toLowerCase();(t.includes("claude")||t.includes("opus"))&&(console.error('Error: Body must not contain "claude" or "opus"'),process.exit(1))}function ib(e){(!Number.isInteger(e)||e<1)&&(console.error("Error: Line must be a positive integer"),process.exit(1))}async function ob(e,t,r,i={}){let{startLine:n,skipPreview:o}=i;EO(r),ib(t),n!==void 0&&ib(n);let s=n!==void 0?`${n}-${t}`:`${t}`;o||await nb(`Comment on ${e}:${s}`,r,null);try{let a=Ni();Yy({prId:a,body:r,path:e,line:t,startLine:n}),console.log(`Added review comment on ${e}:${s}`)}catch(a){throw Ti(a)&&(console.error("Error: GitHub CLI (gh) is not installed."),console.error("Install it from https://cli.github.com/"),process.exit(1)),a}}var sb="the reviewer";function Wi(e){return e.replace(/\bclaude\b/gi,sb).replace(/\bopus\b/gi,sb)}function CO(e){let t=[],r=e.severity??"finding";return t.push(`**${r}: ${e.title}**`),e.impact&&t.push("",`Impact: ${e.impact}`),e.recommendation&&t.push("",`Recommendation: ${e.recommendation}`),Wi(t.join(`
192
192
  `))}async function ab(e){let t=0,r=0;for(let i of e){let n=CO(i);try{await ob(i.file,i.line,n,{startLine:i.startLine,skipPreview:!0}),t++}catch(o){r++;let s=o instanceof Error?o.message:String(o);console.error(`Failed to post comment on ${i.file}:${i.line}: ${s}`)}}return{posted:t,failed:r}}function Hi(e,t){try{let r=Ni();sn(e,{prId:r,body:t}),console.log("Submitted review.")}catch(r){if(Ti(r)){console.error("Error: GitHub CLI (gh) is not installed.");return}let i=r instanceof Error?r.message:String(r);console.error(`Failed to submit review: ${i}`)}}var TO="mutation($prId: ID!, $body: String) { addPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }";function lb(e){Hi(TO,e)}var NO="mutation($prId: ID!, $body: String) { submitPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }";function cb(e){Hi(NO,e)}function AO(e,t){return Wi(Ji(e,t))}function zO(e,t){t>0?cb(e):lb(e)}async function RO(e){if(!e.prompt)return e.submit;await uc("waiting");try{return await er("Submit the pending review?",e.submit)}finally{await uc("running")}}async function ub(e,t,r,i){let n=await ab(e),o=n.failed>0?`, ${n.failed} failed`:"";console.log(`Posted ${n.posted} comment(s)${o}.`);let s=tr(t);return n.posted===0&&s.length===0?{posted:0,submitted:!1}:await RO(i)?(zO(AO(r,t),n.posted),{posted:n.posted,submitted:!0}):(console.log("Leaving the review unsubmitted."),{posted:n.posted,submitted:!1})}function db(e){return Number.isInteger(e)&&e>=1}function DO(e){if(!e.location||e.location.toLowerCase()==="n/a")return null;let t=e.location.match(/^(.+):(\d+)(?:-(\d+))?$/);if(!t)return null;let r=Number.parseInt(t[2],10),i=t[3]?Number.parseInt(t[3],10):r;if(!db(r)||!db(i)||i<r)return null;let n={...e,file:t[1],line:i};return r===i?n:{...n,startLine:r}}function fb(e){let t=[],r=[],i=[];for(let n of e){if(n.source==="already-raised"){i.push(n);continue}let o=DO(n);o?t.push(o):r.push(n)}return{lineBound:t,unlocated:r,alreadyRaised:i}}var jO=/^\+\+\+ (?:b\/)?(.+)$/,LO=/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function pb(e){let t=new Map,r=null,i=0;for(let n of e.split(`
193
- `)){let o=n.match(jO);if(o){r=o[1]==="/dev/null"?null:o[1];continue}let s=n.match(LO);if(s){i=Number(s[1]);continue}if(r!==null&&!n.startsWith("-")&&(n.startsWith("+")||n.startsWith(" "))){let a=t.get(r);a||(a=new Set,t.set(r,a)),a.add(i),i++}}return t}function UO(e,t){let r=t.get(e.file);return!(!r||!r.has(e.line)||e.startLine!==void 0&&!r.has(e.startLine))}function mb(e,t){let r=[],i=[];for(let n of e)UO(n,t)?r.push(n):i.push(n);return{inDiff:r,outOfDiff:i}}var hb=(e=0)=>t=>`\x1B[${t+e}m`,gb=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,vb=(e=0)=>(t,r,i)=>`\x1B[${38+e};2;${t};${r};${i}m`,V={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},rM=Object.keys(V.modifier),MO=Object.keys(V.color),qO=Object.keys(V.bgColor),nM=[...MO,...qO];function FO(){let e=new Map;for(let[t,r]of Object.entries(V)){for(let[i,n]of Object.entries(r))V[i]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},r[i]=V[i],e.set(n[0],n[1]);Object.defineProperty(V,t,{value:r,enumerable:!1})}return Object.defineProperty(V,"codes",{value:e,enumerable:!1}),V.color.close="\x1B[39m",V.bgColor.close="\x1B[49m",V.color.ansi=hb(),V.color.ansi256=gb(),V.color.ansi16m=vb(),V.bgColor.ansi=hb(10),V.bgColor.ansi256=gb(10),V.bgColor.ansi16m=vb(10),Object.defineProperties(V,{rgbToAnsi256:{value(t,r,i){return t===r&&r===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[i]=r;i.length===3&&(i=[...i].map(o=>o+o).join(""));let n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:t=>V.rgbToAnsi256(...V.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,i,n;if(t>=232)r=((t-232)*10+8)/255,i=r,n=r;else{t-=16;let a=t%36;r=Math.floor(t/36)/5,i=Math.floor(a/6)/5,n=a%6/5}let o=Math.max(r,i,n)*2;if(o===0)return 30;let s=30+(Math.round(n)<<2|Math.round(i)<<1|Math.round(r));return o===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(t,r,i)=>V.ansi256ToAnsi(V.rgbToAnsi256(t,r,i)),enumerable:!1},hexToAnsi:{value:t=>V.ansi256ToAnsi(V.hexToAnsi256(t)),enumerable:!1}}),V}var ZO=FO(),Oe=ZO;import dc from"node:process";import BO from"node:os";import yb from"node:tty";function $e(e,t=globalThis.Deno?globalThis.Deno.args:dc.argv){let r=e.startsWith("-")?"":e.length===1?"-":"--",i=t.indexOf(r+e),n=t.indexOf("--");return i!==-1&&(n===-1||i<n)}var{env:K}=dc,Yi;$e("no-color")||$e("no-colors")||$e("color=false")||$e("color=never")?Yi=0:($e("color")||$e("colors")||$e("color=true")||$e("color=always"))&&(Yi=1);function VO(){if("FORCE_COLOR"in K)return K.FORCE_COLOR==="true"?1:K.FORCE_COLOR==="false"?0:K.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(K.FORCE_COLOR,10),3)}function KO(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function GO(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let i=VO();i!==void 0&&(Yi=i);let n=r?Yi:i;if(n===0)return 0;if(r){if($e("color=16m")||$e("color=full")||$e("color=truecolor"))return 3;if($e("color=256"))return 2}if("TF_BUILD"in K&&"AGENT_NAME"in K)return 1;if(e&&!t&&n===void 0)return 0;let o=n||0;if(K.TERM==="dumb")return o;if(dc.platform==="win32"){let s=BO.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in K)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in K)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in K)||K.CI_NAME==="codeship"?1:o;if("TEAMCITY_VERSION"in K)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(K.TEAMCITY_VERSION)?1:0;if(K.COLORTERM==="truecolor"||K.TERM==="xterm-kitty"||K.TERM==="xterm-ghostty"||K.TERM==="wezterm")return 3;if("TERM_PROGRAM"in K){let s=Number.parseInt((K.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(K.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(K.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(K.TERM)||"COLORTERM"in K?1:o}function bb(e,t={}){let r=GO(e,{streamIsTTY:e&&e.isTTY,...t});return KO(r)}var JO={stdout:bb({isTTY:yb.isatty(1)}),stderr:bb({isTTY:yb.isatty(2)})},wb=JO;function $b(e,t,r){let i=e.indexOf(t);if(i===-1)return e;let n=t.length,o=0,s="";do s+=e.slice(o,i)+t+r,o=i+n,i=e.indexOf(t,o);while(i!==-1);return s+=e.slice(o),s}function xb(e,t,r,i){let n=0,o="";do{let s=e[i-1]==="\r";o+=e.slice(n,s?i-1:i)+t+(s?`\r
193
+ `)){let o=n.match(jO);if(o){r=o[1]==="/dev/null"?null:o[1];continue}let s=n.match(LO);if(s){i=Number(s[1]);continue}if(r!==null&&!n.startsWith("-")&&(n.startsWith("+")||n.startsWith(" "))){let a=t.get(r);a||(a=new Set,t.set(r,a)),a.add(i),i++}}return t}function UO(e,t){let r=t.get(e.file);return!(!r||!r.has(e.line)||e.startLine!==void 0&&!r.has(e.startLine))}function mb(e,t){let r=[],i=[];for(let n of e)UO(n,t)?r.push(n):i.push(n);return{inDiff:r,outOfDiff:i}}var hb=(e=0)=>t=>`\x1B[${t+e}m`,gb=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,vb=(e=0)=>(t,r,i)=>`\x1B[${38+e};2;${t};${r};${i}m`,V={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},nM=Object.keys(V.modifier),MO=Object.keys(V.color),qO=Object.keys(V.bgColor),iM=[...MO,...qO];function FO(){let e=new Map;for(let[t,r]of Object.entries(V)){for(let[i,n]of Object.entries(r))V[i]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},r[i]=V[i],e.set(n[0],n[1]);Object.defineProperty(V,t,{value:r,enumerable:!1})}return Object.defineProperty(V,"codes",{value:e,enumerable:!1}),V.color.close="\x1B[39m",V.bgColor.close="\x1B[49m",V.color.ansi=hb(),V.color.ansi256=gb(),V.color.ansi16m=vb(),V.bgColor.ansi=hb(10),V.bgColor.ansi256=gb(10),V.bgColor.ansi16m=vb(10),Object.defineProperties(V,{rgbToAnsi256:{value(t,r,i){return t===r&&r===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[i]=r;i.length===3&&(i=[...i].map(o=>o+o).join(""));let n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:t=>V.rgbToAnsi256(...V.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,i,n;if(t>=232)r=((t-232)*10+8)/255,i=r,n=r;else{t-=16;let a=t%36;r=Math.floor(t/36)/5,i=Math.floor(a/6)/5,n=a%6/5}let o=Math.max(r,i,n)*2;if(o===0)return 30;let s=30+(Math.round(n)<<2|Math.round(i)<<1|Math.round(r));return o===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(t,r,i)=>V.ansi256ToAnsi(V.rgbToAnsi256(t,r,i)),enumerable:!1},hexToAnsi:{value:t=>V.ansi256ToAnsi(V.hexToAnsi256(t)),enumerable:!1}}),V}var ZO=FO(),Oe=ZO;import dc from"node:process";import BO from"node:os";import yb from"node:tty";function $e(e,t=globalThis.Deno?globalThis.Deno.args:dc.argv){let r=e.startsWith("-")?"":e.length===1?"-":"--",i=t.indexOf(r+e),n=t.indexOf("--");return i!==-1&&(n===-1||i<n)}var{env:K}=dc,Yi;$e("no-color")||$e("no-colors")||$e("color=false")||$e("color=never")?Yi=0:($e("color")||$e("colors")||$e("color=true")||$e("color=always"))&&(Yi=1);function VO(){if("FORCE_COLOR"in K)return K.FORCE_COLOR==="true"?1:K.FORCE_COLOR==="false"?0:K.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(K.FORCE_COLOR,10),3)}function KO(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function GO(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let i=VO();i!==void 0&&(Yi=i);let n=r?Yi:i;if(n===0)return 0;if(r){if($e("color=16m")||$e("color=full")||$e("color=truecolor"))return 3;if($e("color=256"))return 2}if("TF_BUILD"in K&&"AGENT_NAME"in K)return 1;if(e&&!t&&n===void 0)return 0;let o=n||0;if(K.TERM==="dumb")return o;if(dc.platform==="win32"){let s=BO.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in K)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in K)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in K)||K.CI_NAME==="codeship"?1:o;if("TEAMCITY_VERSION"in K)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(K.TEAMCITY_VERSION)?1:0;if(K.COLORTERM==="truecolor"||K.TERM==="xterm-kitty"||K.TERM==="xterm-ghostty"||K.TERM==="wezterm")return 3;if("TERM_PROGRAM"in K){let s=Number.parseInt((K.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(K.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(K.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(K.TERM)||"COLORTERM"in K?1:o}function bb(e,t={}){let r=GO(e,{streamIsTTY:e&&e.isTTY,...t});return KO(r)}var JO={stdout:bb({isTTY:yb.isatty(1)}),stderr:bb({isTTY:yb.isatty(2)})},wb=JO;function $b(e,t,r){let i=e.indexOf(t);if(i===-1)return e;let n=t.length,o=0,s="";do s+=e.slice(o,i)+t+r,o=i+n,i=e.indexOf(t,o);while(i!==-1);return s+=e.slice(o),s}function xb(e,t,r,i){let n=0,o="";do{let s=e[i-1]==="\r";o+=e.slice(n,s?i-1:i)+t+(s?`\r
194
194
  `:`
195
195
  `)+r,n=i+1,i=e.indexOf(`
196
196
  `,n)}while(i!==-1);return o+=e.slice(n),o}var{stdout:_b,stderr:Sb}=wb,fc=Symbol("GENERATOR"),rr=Symbol("STYLER"),an=Symbol("IS_EMPTY"),kb=["ansi","ansi","ansi256","ansi16m"],nr=Object.create(null),WO=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=_b?_b.level:0;e.level=t.level===void 0?r:t.level};var HO=e=>{let t=(...r)=>r.join(" ");return WO(t,e),Object.setPrototypeOf(t,ln.prototype),t};function ln(e){return HO(e)}Object.setPrototypeOf(ln.prototype,Function.prototype);for(let[e,t]of Object.entries(Oe))nr[e]={get(){let r=Xi(this,mc(t.open,t.close,this[rr]),this[an]);return Object.defineProperty(this,e,{value:r}),r}};nr.visible={get(){let e=Xi(this,this[rr],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var pc=(e,t,r,...i)=>e==="rgb"?t==="ansi16m"?Oe[r].ansi16m(...i):t==="ansi256"?Oe[r].ansi256(Oe.rgbToAnsi256(...i)):Oe[r].ansi(Oe.rgbToAnsi(...i)):e==="hex"?pc("rgb",t,r,...Oe.hexToRgb(...i)):Oe[r][e](...i),YO=["rgb","hex","ansi256"];for(let e of YO){nr[e]={get(){let{level:r}=this;return function(...i){let n=mc(pc(e,kb[r],"color",...i),Oe.color.close,this[rr]);return Xi(this,n,this[an])}}};let t="bg"+e[0].toUpperCase()+e.slice(1);nr[t]={get(){let{level:r}=this;return function(...i){let n=mc(pc(e,kb[r],"bgColor",...i),Oe.bgColor.close,this[rr]);return Xi(this,n,this[an])}}}}var XO=Object.defineProperties(()=>{},{...nr,level:{enumerable:!0,get(){return this[fc].level},set(e){this[fc].level=e}}}),mc=(e,t,r)=>{let i,n;return r===void 0?(i=e,n=t):(i=r.openAll+e,n=t+r.closeAll),{open:e,close:t,openAll:i,closeAll:n,parent:r}},Xi=(e,t,r)=>{let i=(...n)=>QO(i,n.length===1?""+n[0]:n.join(" "));return Object.setPrototypeOf(i,XO),i[fc]=e,i[rr]=t,i[an]=r,i},QO=(e,t)=>{if(e.level<=0||!t)return e[an]?"":t;let r=e[rr];if(r===void 0)return t;let{openAll:i,closeAll:n}=r;if(t.includes("\x1B"))for(;r!==void 0;)t=$b(t,r.close,r.open),r=r.parent;let o=t.indexOf(`
197
- `);return o!==-1&&(t=xb(t,n,i,o)),i+t+n};Object.defineProperties(ln.prototype,nr);var eE=ln(),pM=ln({level:Sb?Sb.level:0});var Ze=eE;function Ib(e){if(e.length!==0){console.warn(Ze.yellow(`Moved ${e.length} finding(s) whose lines fall outside the PR diff into the review body (GitHub cannot anchor a comment on these):`));for(let t of e){let r=t.startLine!==void 0?`${t.startLine}-${t.line}`:`${t.line}`;console.warn(` ${Ze.yellow("\xB7")} ${t.title} ${Ze.dim(`(${t.file}:${r})`)}`)}}}function Pb(e,t){let r=zi(t.prNumber,t.baseSha,t.headSha),{inDiff:i,outOfDiff:n}=mb(e,pb(r));return Ib(n),{inDiff:i,unanchored:n.map(o=>({...o,reason:"out-of-diff"}))}}function Ob(e){if(e.length!==0){console.warn(Ze.yellow(`Moved ${e.length} finding(s) without a parseable file:line into the review body:`));for(let t of e){let r=t.location||Ze.dim("missing");console.warn(` ${Ze.yellow("\xB7")} ${t.title} ${Ze.dim(`(${r})`)}`)}}}function Eb(e,t){let r=Gi(e);if(r.length===0)return console.log("Synthesis contains no findings; nothing to post."),{inDiff:[],unanchored:[]};let{lineBound:i,unlocated:n,alreadyRaised:o}=fb(r);Ob(n),o.length>0&&console.log(`Skipped ${o.length} finding(s) already raised by prior comments.`);let s=n.map(c=>({...c,reason:"unlocated"}));if(i.length===0)return console.log("No line-bound findings to comment on."),{inDiff:[],unanchored:s};let{inDiff:a,unanchored:l}=Pb(i,t);return a.length===0&&console.log("No findings fall within the PR diff; no line comments to post."),{inDiff:a,unanchored:[...s,...l]}}function tE(){try{return Ai()}catch(e){return console.error(`Error: could not confirm which PR this tree is on: ${e instanceof Error?e.message:String(e)}`),null}}function Cb(e){let t=tE();return t===e?!0:(console.error(`Error: this tree is now on ${t===null?"a branch with no open PR":`PR #${t}`}, not the reviewed PR #${e}; skipping the post and any chained sessions.`),!1)}var Tb={posted:0,submitted:!1};function nE(e,t){let r=[];return e>0&&r.push(`${e} line comment(s)`),t>0&&r.push(`${t} finding(s) in the review body`),r.join(" and ")}async function iE(e,t,r){return r.prompt?er(`Post ${t} to PR #${e}?`,!1):!0}async function oE(e,t,r){let i=rE(t,"utf8"),{inDiff:n,unanchored:o}=Eb(i,e),s=tr(o);if(n.length===0&&s.length===0)return Tb;let a=nE(n.length,s.length);return console.log(`Found PR #${e.prNumber} with ${a} to post.`),await iE(e.prNumber,a,r)?ub(n,o,i,r):(console.log("Skipped posting."),Tb)}async function Nb(e,t,r){if(!Cb(t.prNumber))return;let i=await oE(t,e,r);await My(t.prNumber,i,r)}import{mkdirSync as sE,writeFileSync as aE}from"node:fs";import{dirname as lE}from"node:path";var vc="assist sessions set-status";function hc(e){return`${vc} running --source ${e}`}function cE(e){return`${vc} waiting --source ${e}`}function gc(e){return`${vc} waiting --source ${e} --ack`}function Et(e,t){let r=[{type:"command",command:e}];return[t==null?{hooks:r}:{matcher:t,hooks:r}]}var Ab="AskUserQuestion",uE=`^(?!${Ab}$).*`,dE={hooks:{UserPromptSubmit:Et(hc("prompt")),PreToolUse:[...Et(cE("pretool"),Ab),...Et(hc("pretool"),uE)],PostToolUse:Et(hc("posttool")),Stop:Et(gc("stop")),Notification:Et(gc("notification")),PermissionRequest:Et(gc("permission"))}};function zb(){let e=Wt.hooksSettings;return sE(lE(e),{recursive:!0}),aE(e,JSON.stringify(dE,null,2)),e}import{spawn as fE}from"node:child_process";function Rb(e,t,r={}){let{ASSIST_ACTIVITY_ID:i,CLAUDE_CODE_CHILD_SESSION:n,...o}=process.env,s=fE(e,t,{stdio:"inherit",env:{...o,...r.env},cwd:r.cwd}),a=new Promise((l,c)=>{s.on("close",u=>l(u??0)),s.on("error",c)});return{child:s,done:a}}function ir(e,t={}){let r=["--settings",zb(),...pE(e,t)],i=t.permissionMode??(t.allowEdits?"auto":void 0);return i&&r.push("--permission-mode",i),Rb("claude",r)}function pE(e,t){return t.resumeSessionId?e?["--resume",t.resumeSessionId,e]:["--resume",t.resumeSessionId]:t.sessionId?e?["--session-id",t.sessionId,e]:["--session-id",t.sessionId]:e?[e]:[]}function mE(e){return`You are helping the user apply fixes for a code review with each finding decided one at a time.
197
+ `);return o!==-1&&(t=xb(t,n,i,o)),i+t+n};Object.defineProperties(ln.prototype,nr);var eE=ln(),mM=ln({level:Sb?Sb.level:0});var Ze=eE;function Ib(e){if(e.length!==0){console.warn(Ze.yellow(`Moved ${e.length} finding(s) whose lines fall outside the PR diff into the review body (GitHub cannot anchor a comment on these):`));for(let t of e){let r=t.startLine!==void 0?`${t.startLine}-${t.line}`:`${t.line}`;console.warn(` ${Ze.yellow("\xB7")} ${t.title} ${Ze.dim(`(${t.file}:${r})`)}`)}}}function Pb(e,t){let r=zi(t.prNumber,t.baseSha,t.headSha),{inDiff:i,outOfDiff:n}=mb(e,pb(r));return Ib(n),{inDiff:i,unanchored:n.map(o=>({...o,reason:"out-of-diff"}))}}function Ob(e){if(e.length!==0){console.warn(Ze.yellow(`Moved ${e.length} finding(s) without a parseable file:line into the review body:`));for(let t of e){let r=t.location||Ze.dim("missing");console.warn(` ${Ze.yellow("\xB7")} ${t.title} ${Ze.dim(`(${r})`)}`)}}}function Eb(e,t){let r=Gi(e);if(r.length===0)return console.log("Synthesis contains no findings; nothing to post."),{inDiff:[],unanchored:[]};let{lineBound:i,unlocated:n,alreadyRaised:o}=fb(r);Ob(n),o.length>0&&console.log(`Skipped ${o.length} finding(s) already raised by prior comments.`);let s=n.map(c=>({...c,reason:"unlocated"}));if(i.length===0)return console.log("No line-bound findings to comment on."),{inDiff:[],unanchored:s};let{inDiff:a,unanchored:l}=Pb(i,t);return a.length===0&&console.log("No findings fall within the PR diff; no line comments to post."),{inDiff:a,unanchored:[...s,...l]}}function tE(){try{return Ai()}catch(e){return console.error(`Error: could not confirm which PR this tree is on: ${e instanceof Error?e.message:String(e)}`),null}}function Cb(e){let t=tE();return t===e?!0:(console.error(`Error: this tree is now on ${t===null?"a branch with no open PR":`PR #${t}`}, not the reviewed PR #${e}; skipping the post and any chained sessions.`),!1)}var Tb={posted:0,submitted:!1};function nE(e,t){let r=[];return e>0&&r.push(`${e} line comment(s)`),t>0&&r.push(`${t} finding(s) in the review body`),r.join(" and ")}async function iE(e,t,r){return r.prompt?er(`Post ${t} to PR #${e}?`,!1):!0}async function oE(e,t,r){let i=rE(t,"utf8"),{inDiff:n,unanchored:o}=Eb(i,e),s=tr(o);if(n.length===0&&s.length===0)return Tb;let a=nE(n.length,s.length);return console.log(`Found PR #${e.prNumber} with ${a} to post.`),await iE(e.prNumber,a,r)?ub(n,o,i,r):(console.log("Skipped posting."),Tb)}async function Nb(e,t,r){if(!Cb(t.prNumber))return;let i=await oE(t,e,r);await My(t.prNumber,i,r)}import{mkdirSync as sE,writeFileSync as aE}from"node:fs";import{dirname as lE}from"node:path";var vc="assist sessions set-status";function hc(e){return`${vc} running --source ${e}`}function cE(e){return`${vc} waiting --source ${e}`}function gc(e){return`${vc} waiting --source ${e} --ack`}function Et(e,t){let r=[{type:"command",command:e}];return[t==null?{hooks:r}:{matcher:t,hooks:r}]}var Ab="AskUserQuestion",uE=`^(?!${Ab}$).*`,dE={hooks:{UserPromptSubmit:Et(hc("prompt")),PreToolUse:[...Et(cE("pretool"),Ab),...Et(hc("pretool"),uE)],PostToolUse:Et(hc("posttool")),Stop:Et(gc("stop")),Notification:Et(gc("notification")),PermissionRequest:Et(gc("permission"))}};function zb(){let e=Wt.hooksSettings;return sE(lE(e),{recursive:!0}),aE(e,JSON.stringify(dE,null,2)),e}import{spawn as fE}from"node:child_process";function Rb(e,t,r={}){let{ASSIST_ACTIVITY_ID:i,CLAUDE_CODE_CHILD_SESSION:n,...o}=process.env,s=fE(e,t,{stdio:"inherit",env:{...o,...r.env},cwd:r.cwd}),a=new Promise((l,c)=>{s.on("close",u=>l(u??0)),s.on("error",c)});return{child:s,done:a}}function ir(e,t={}){let r=["--settings",zb(),...pE(e,t)],i=t.permissionMode??(t.allowEdits?"auto":void 0);return i&&r.push("--permission-mode",i),Rb("claude",r)}function pE(e,t){return t.resumeSessionId?e?["--resume",t.resumeSessionId,e]:["--resume",t.resumeSessionId]:t.sessionId?e?["--session-id",t.sessionId,e]:["--session-id",t.sessionId]:e?[e]:[]}function mE(e){return`You are helping the user apply fixes for a code review with each finding decided one at a time.
198
198
 
199
199
  Read ${e}. It contains a list of findings under the \`## Findings\` heading. Each finding is a block in this exact format:
200
200
 
@@ -255,8 +255,8 @@ Each finding block must use this exact format so it parses correctly:
255
255
 
256
256
  User-supplied findings should use Source: \`confirmed\`. Use Location \`n/a\` only when the finding is not tied to a specific line.
257
257
 
258
- Do not post anything to a PR; only edit ${e}. When the user is done, exit.`}async function Lb(e){let{done:t}=ir(gE(e),{allowEdits:!0});await t}function vE(e){return e.backlog?jb:e.apply?Db:e.refine?Lb:null}async function Ub(e,t,r){let i=vE(r);if(!i){await Nb(e,t,{prompt:r.prompt,submit:r.submit,addressComments:r.addressComments,announce:r.announce});return}await i(e),r.announce&&await ji(t.prNumber)}import{statSync as yE}from"node:fs";function or(e,t){let r;try{r=yE(t).size}catch{return null}return r===0?null:(console.log(`[${e}] cached \u2192 ${t} (${r} bytes)`),{name:e,outputPath:t,exitCode:0,stderr:""})}import Qw from"node:process";var te={};ze(te,{ConEmu:()=>Gb,beep:()=>JE,beginSynchronizedOutput:()=>Bb,clearScreen:()=>qE,clearTerminal:()=>BE,clearViewport:()=>FE,cursorBackward:()=>IE,cursorDown:()=>SE,cursorForward:()=>kE,cursorGetPosition:()=>EE,cursorHide:()=>NE,cursorLeft:()=>Fb,cursorMove:()=>_E,cursorNextLine:()=>CE,cursorPrevLine:()=>TE,cursorRestorePosition:()=>OE,cursorSavePosition:()=>PE,cursorShow:()=>AE,cursorTo:()=>xE,cursorUp:()=>qb,endSynchronizedOutput:()=>Vb,enterAlternativeScreen:()=>VE,eraseDown:()=>jE,eraseEndLine:()=>RE,eraseLine:()=>Zb,eraseLines:()=>zE,eraseScreen:()=>Qi,eraseStartLine:()=>DE,eraseUp:()=>LE,exitAlternativeScreen:()=>KE,iTerm:()=>Kb,image:()=>HE,link:()=>WE,scrollDown:()=>ME,scrollUp:()=>UE,setCwd:()=>YE,synchronizedOutput:()=>GE});import ar from"node:process";import bE from"node:os";var sr=globalThis.window?.document!==void 0,lq=globalThis.process?.versions?.node!==void 0,cq=globalThis.process?.versions?.bun!==void 0,uq=globalThis.Deno?.version?.deno!==void 0,dq=globalThis.process?.versions?.electron!==void 0,fq=globalThis.navigator?.userAgent?.includes("jsdom")===!0,pq=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,mq=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,hq=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,gq=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,cn=globalThis.navigator?.userAgentData?.platform,vq=cn==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",yq=cn==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",bq=cn==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",wq=cn==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),$q=cn==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android";var j="\x1B[",lr="\x1B]",Ct="\x07",un=";",Mb=!sr&&ar.env.TERM_PROGRAM==="Apple_Terminal",wE=!sr&&ar.platform==="win32",$E=!sr&&(ar.env.TERM?.startsWith("screen")||ar.env.TERM?.startsWith("tmux")||ar.env.TMUX!==void 0),yc=sr?()=>{throw new Error("`process.cwd()` only works in Node.js, not the browser.")}:ar.cwd,cr=e=>$E?"\x1BPtmux;"+e.replaceAll("\x1B","\x1B\x1B")+"\x1B\\":e,xE=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");return typeof t!="number"?j+(e+1)+"G":j+(t+1)+un+(e+1)+"H"},_E=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");let r="";return e<0?r+=j+-e+"D":e>0&&(r+=j+e+"C"),t<0?r+=j+-t+"A":t>0&&(r+=j+t+"B"),r},qb=(e=1)=>j+e+"A",SE=(e=1)=>j+e+"B",kE=(e=1)=>j+e+"C",IE=(e=1)=>j+e+"D",Fb=j+"G",PE=Mb?"\x1B7":j+"s",OE=Mb?"\x1B8":j+"u",EE=j+"6n",CE=j+"E",TE=j+"F",NE=j+"?25l",AE=j+"?25h",zE=e=>{let t="";for(let r=0;r<e;r++)t+=Zb+(r<e-1?qb():"");return e&&(t+=Fb),t},RE=j+"K",DE=j+"1K",Zb=j+"2K",jE=j+"J",LE=j+"1J",Qi=j+"2J",UE=j+"S",ME=j+"T",qE="\x1Bc",FE=`${Qi}${j}H`,ZE=()=>{if(sr||!wE)return!1;let e=bE.release().split("."),t=Number(e[0]),r=Number(e[2]??0);return t<10||t===10&&r<10586},BE=ZE()?`${Qi}${j}0f`:`${Qi}${j}3J${j}H`,VE=j+"?1049h",KE=j+"?1049l",Bb=j+"?2026h",Vb=j+"?2026l",GE=e=>Bb+e+Vb,JE=Ct,WE=(e,t)=>{let r=cr(`${lr}8${un}${un}${t}${Ct}`),i=cr(`${lr}8${un}${un}${Ct}`);return r+e+i},HE=(e,t={})=>{let r=`${lr}1337;File=inline=1`;t.width&&(r+=`;width=${t.width}`),t.height&&(r+=`;height=${t.height}`),t.preserveAspectRatio===!1&&(r+=";preserveAspectRatio=0");let i=Buffer.from(e);return cr(r+`;size=${i.byteLength}:`+i.toString("base64")+Ct)},Kb={setCwd:(e=yc())=>cr(`${lr}50;CurrentDir=${e}${Ct}`),annotation(e,t={}){let r=`${lr}1337;`,i=t.x!==void 0,n=t.y!==void 0;if((i||n)&&!(i&&n&&t.length!==void 0))throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return e=e.replaceAll("|",""),r+=t.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",t.length>0?r+=(i?[e,t.length,t.x,t.y]:[t.length,e]).join("|"):r+=e,cr(r+Ct)}},Gb={setCwd:(e=yc())=>cr(`${lr}9;9;${e}${Ct}`)},YE=(e=yc())=>Kb.setCwd(e)+Gb.setCwd(e);import Qb from"node:process";import no from"node:process";var XE=(e,t,r,i)=>{if(r==="length"||r==="prototype"||r==="arguments"||r==="caller")return;let n=Object.getOwnPropertyDescriptor(e,r),o=Object.getOwnPropertyDescriptor(t,r);!QE(n,o)&&i||Object.defineProperty(e,r,o)},QE=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},eC=(e,t)=>{let r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},tC=(e,t)=>`/* Wrapped ${e}*/
259
- ${t}`,rC=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),nC=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),iC=(e,t,r)=>{let i=r===""?"":`with ${r.trim()}() `,n=tC.bind(null,i,t.toString());Object.defineProperty(n,"name",nC);let{writable:o,enumerable:s,configurable:a}=rC;Object.defineProperty(e,"toString",{value:n,writable:o,enumerable:s,configurable:a})};function bc(e,t,{ignoreNonConfigurable:r=!1}={}){let{name:i}=e;for(let n of Reflect.ownKeys(t))XE(e,t,n,r);return eC(e,t),iC(e,t,i),e}var eo=new WeakMap,Jb=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let r,i=0,n=e.displayName||e.name||"<anonymous>",o=function(...s){if(eo.set(o,++i),i===1)r=e.apply(this,s),e=void 0;else if(t.throw===!0)throw new Error(`Function \`${n}\` can only be called once`);return r};return bc(o,e),eo.set(o,i),o};Jb.callCount=e=>{if(!eo.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return eo.get(e)};var Wb=Jb;var Tt=[];Tt.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Tt.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Tt.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var to=e=>!!e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function",wc=Symbol.for("signal-exit emitter"),$c=globalThis,oC=Object.defineProperty.bind(Object),xc=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if($c[wc])return $c[wc];oC($c,wc,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,r){this.listeners[t].push(r)}removeListener(t,r){let i=this.listeners[t],n=i.indexOf(r);n!==-1&&(n===0&&i.length===1?i.length=0:i.splice(n,1))}emit(t,r,i){if(this.emitted[t])return!1;this.emitted[t]=!0;let n=!1;for(let o of this.listeners[t])n=o(r,i)===!0||n;return t==="exit"&&(n=this.emit("afterExit",r,i)||n),n}},ro=class{},sC=e=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}}),_c=class extends ro{onExit(){return()=>{}}load(){}unload(){}},Sc=class extends ro{#s=kc.platform==="win32"?"SIGINT":"SIGHUP";#t=new xc;#e;#i;#o;#n={};#r=!1;constructor(t){super(),this.#e=t,this.#n={};for(let r of Tt)this.#n[r]=()=>{let i=this.#e.listeners(r),{count:n}=this.#t,o=t;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(n+=o.__signal_exit_emitter__.count),i.length===n){this.unload();let s=this.#t.emit("exit",null,r),a=r==="SIGHUP"?this.#s:r;s||t.kill(t.pid,a)}};this.#o=t.reallyExit,this.#i=t.emit}onExit(t,r){if(!to(this.#e))return()=>{};this.#r===!1&&this.load();let i=r?.alwaysLast?"afterExit":"exit";return this.#t.on(i,t),()=>{this.#t.removeListener(i,t),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#r){this.#r=!0,this.#t.count+=1;for(let t of Tt)try{let r=this.#n[t];r&&this.#e.on(t,r)}catch{}this.#e.emit=(t,...r)=>this.#l(t,...r),this.#e.reallyExit=t=>this.#a(t)}}unload(){this.#r&&(this.#r=!1,Tt.forEach(t=>{let r=this.#n[t];if(!r)throw new Error("Listener not defined for signal: "+t);try{this.#e.removeListener(t,r)}catch{}}),this.#e.emit=this.#i,this.#e.reallyExit=this.#o,this.#t.count-=1)}#a(t){return to(this.#e)?(this.#e.exitCode=t||0,this.#t.emit("exit",this.#e.exitCode,null),this.#o.call(this.#e,this.#e.exitCode)):0}#l(t,...r){let i=this.#i;if(t==="exit"&&to(this.#e)){typeof r[0]=="number"&&(this.#e.exitCode=r[0]);let n=i.call(this.#e,t,...r);return this.#t.emit("exit",this.#e.exitCode,null),n}else return i.call(this.#e,t,...r)}},kc=globalThis.process,{onExit:Hb,load:Aq,unload:zq}=sC(to(kc)?new Sc(kc):new _c);var Yb=no.stderr.isTTY?no.stderr:no.stdout.isTTY?no.stdout:void 0,aC=Yb?Wb(()=>{Hb(()=>{Yb.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},Xb=aC;var io=!1,ur={};ur.show=(e=Qb.stderr)=>{e.isTTY&&(io=!1,e.write("\x1B[?25h"))};ur.hide=(e=Qb.stderr)=>{e.isTTY&&(Xb(),io=!0,e.write("\x1B[?25l"))};ur.toggle=(e,t)=>{e!==void 0&&(io=e),io?ur.show(t):ur.hide(t)};var Ic=ur;function Pc({onlyFirst:e=!1}={}){let n="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(n,e?void 0:"g")}var lC=Pc();function it(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes("\x1B")&&!e.includes("\x9B")?e:e.replace(lC,"")}var ew=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],tw=12288,rw=65510,nw=[12288,12288,65281,65376,65504,65510];var iw=4352,ow=262141,Oc=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var oo=(e,t)=>{let r=0,i=Math.floor(e.length/2)-1;for(;r<=i;){let n=Math.floor((r+i)/2),o=n*2;if(t<e[o])i=n-1;else if(t>e[o+1])r=n+1;else return!0}return!1};var sw=19968,[dC,fC]=pC(Oc);function pC(e){let t=e[0],r=e[1];for(let i=0;i<e.length;i+=2){let n=e[i],o=e[i+1];if(sw>=n&&sw<=o)return[n,o];o-n>r-t&&(t=n,r=o)}return[t,r]}var aw=e=>e<161||e>1114109?!1:oo(ew,e),dn=e=>e<tw||e>rw?!1:oo(nw,e);var fn=e=>e>=dC&&e<=fC?!0:e<iw||e>ow?!1:oo(Oc,e);function mC(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function pn(e,{ambiguousAsWide:t=!1}={}){return mC(e),dn(e)||fn(e)||t&&aw(e)?2:1}var hC=new Intl.Segmenter,lw=new RegExp("^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Format}|\\p{Mark}|\\p{Surrogate})+$","v"),gC=new RegExp("^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}\\p{Surrogate}]+","v"),vC=new RegExp("^\\p{RGI_Emoji}$","v"),yC=/^[\d#*]\u20E3$/,bC=new RegExp("\\p{Extended_Pictographic}","gu");function wC(e){if(e.length>50)return!1;if(yC.test(e))return!0;if(e.includes("\u200D")){let t=e.match(bC);return t!==null&&t.length>=2}return!1}function $C(e){return e.replace(gC,"")}function xC(e){return lw.test(e)}function cw(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function uw(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function dw(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function _C(e){return cw(e)||uw(e)||dw(e)}function SC(e,t){let r=[];for(let n of e)lw.test(n)||r.push(n.codePointAt(0));if(r.length===0)return;let i=0;for(let n=0;n<r.length;n++){let o=r[n];if(!_C(o)){if(i===0)return;for(let s=n;s<r.length;s++)i+=pn(r[s],t);return i}if(cw(o)&&uw(r[n+1])){i+=2,n+=dw(r[n+2])?2:1;continue}i+=pn(o,t)}return i}function kC(e,t){let r=0,i=!0;for(let n of e){if(i){i=!1;continue}n>="\uFF00"&&n<="\uFFEF"&&(r+=pn(n.codePointAt(0),t))}return r}function Re(e,t={}){if(typeof e!="string"||e.length===0)return 0;let{ambiguousIsNarrow:r=!0,countAnsiEscapeCodes:i=!1}=t,n=e;if(!i&&(n.includes("\x1B")||n.includes("\x9B"))&&(n=it(n)),n.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(n))return n.length;let o=0,s={ambiguousAsWide:!r};for(let{segment:a}of hC.segment(n)){if(xC(a))continue;if(vC.test(a)||wC(a)){o+=2;continue}let l=$C(a),c=SC(l,s);if(c!==void 0){o+=c;continue}let u=l.codePointAt(0);o+=pn(u,s),o+=kC(l,s)}return o}var fw=(e=0)=>t=>`\x1B[${t+e}m`,pw=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,mw=(e=0)=>(t,r,i)=>`\x1B[${38+e};2;${t};${r};${i}m`,G={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},uF=Object.keys(G.modifier),IC=Object.keys(G.color),PC=Object.keys(G.bgColor),dF=[...IC,...PC];function OC(){let e=new Map;for(let[t,r]of Object.entries(G)){for(let[i,n]of Object.entries(r))G[i]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},r[i]=G[i],e.set(n[0],n[1]);Object.defineProperty(G,t,{value:r,enumerable:!1})}return Object.defineProperty(G,"codes",{value:e,enumerable:!1}),G.color.close="\x1B[39m",G.bgColor.close="\x1B[49m",G.color.ansi=fw(),G.color.ansi256=pw(),G.color.ansi16m=mw(),G.bgColor.ansi=fw(10),G.bgColor.ansi256=pw(10),G.bgColor.ansi16m=mw(10),Object.defineProperties(G,{rgbToAnsi256:{value(t,r,i){return t===r&&r===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[i]=r;i.length===3&&(i=[...i].map(o=>o+o).join(""));let n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:t=>G.rgbToAnsi256(...G.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,i,n;if(t>=232)r=((t-232)*10+8)/255,i=r,n=r;else{t-=16;let a=t%36;r=Math.floor(t/36)/5,i=Math.floor(a/6)/5,n=a%6/5}let o=Math.max(r,i,n)*2;if(o===0)return 30;let s=30+(Math.round(n)<<2|Math.round(i)<<1|Math.round(r));return o===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(t,r,i)=>G.ansi256ToAnsi(G.rgbToAnsi256(t,r,i)),enumerable:!1},hexToAnsi:{value:t=>G.ansi256ToAnsi(G.hexToAnsi256(t)),enumerable:!1}}),G}var EC=OC(),xe=EC;var Nt="\x1B",Cc="\x9B",CC=new Set([Nt,Cc]),ww="\x07",$w="[",TC="]",lo="m",co=0,xw=39,_w=49,Sw=59,kw=38,Iw=48,Pw=58,NC=5,AC=2,ao=`${TC}8;;`,Ow=new RegExp(`^\\u001B(?:\\${$w}(?<sgr>[0-9;]*)${lo}|${ao}(?<uri>[^\\u0007\\u001B]*)(?:\\u0007|\\u001B\\\\))`),Ew=new RegExp(`^\\u009B(?<sgr>[0-9;]*)${lo}`),Cw=new Set(xe.codes.values());Cw.delete(co);var zC=new Intl.Segmenter,Tw=e=>Array.from(zC.segment(e),({segment:t})=>t),hw=8,Nw=e=>`${Nt}${$w}${e}${lo}`,gw=e=>`${Nt}${ao}${e}${ww}`,Aw=e=>{let t=e.split(";").map(i=>i===""?co:Number.parseInt(i,10)),r=[];for(let i=0;i<t.length;i++){let n=t[i];if(Number.isFinite(n)){if(n===kw||n===Iw||n===Pw){if(i+1>=t.length)break;let o=t[i+1];if(o===NC&&Number.isFinite(t[i+2])){r.push([n,o,t[i+2]]),i+=2;continue}let s=t[i+2],a=t[i+3],l=t[i+4];if(o===AC&&Number.isFinite(s)&&Number.isFinite(a)&&Number.isFinite(l)){r.push([n,o,s,a,l]),i+=4;continue}break}r.push([n])}}return r},so=(e,t)=>{let r=e.findIndex(i=>i.family===t);r!==-1&&e.splice(r,1)},vw=(e,t)=>{so(e,t.family),e.push(t)},RC=(e,t)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];i.family.startsWith("modifier-")&&i.close===t&&e.splice(r,1)}},DC=(e,t)=>{if(e>=30&&e<=37||e>=90&&e<=97||e===kw&&t.length>1)return{family:"foreground",open:t.join(";"),close:xw};if(e>=40&&e<=47||e>=100&&e<=107||e===Iw&&t.length>1)return{family:"background",open:t.join(";"),close:_w};if(e===Pw&&t.length>1)return{family:"underlineColor",open:t.join(";"),close:Sw}},zw=(e,t)=>e===co?(t.length=0,!0):e===xw?(so(t,"foreground"),!0):e===_w?(so(t,"background"),!0):e===Sw?(so(t,"underlineColor"),!0):Cw.has(e)?(RC(t,e),!0):!1,jC=(e,t)=>{let[r]=e;if(zw(r,t))return;let i=DC(r,e);if(i){vw(t,i);return}let n=xe.codes.get(r);n!==void 0&&n!==co&&vw(t,{family:`modifier-${r}`,open:e.join(";"),close:n})},yw=(e,t)=>{for(let r of Aw(e))jC(r,t)},bw=(e,t)=>{for(let r of Aw(e)){let[i]=r;zw(i,t)}},LC=(e,t)=>{let r=e;for(;r.length>0;){if(r.startsWith(Nt)&&r[1]!=="\\"){let i=Ow.exec(r);if(!i)break;i.groups.sgr!==void 0&&bw(i.groups.sgr,t),r=r.slice(i[0].length);continue}if(r.startsWith(Cc)){let i=Ew.exec(r);if(!i||i.groups.sgr===void 0)break;bw(i.groups.sgr,t),r=r.slice(i[0].length);continue}break}},UC=e=>[...e].reverse().map(t=>Nw(t.close)).join(""),MC=e=>e.map(t=>Nw(t.open)).join(""),qC=e=>e.split(" ").map(t=>Re(t)),Ec=(e,t,r)=>{let i=Tw(t),n=!1,o=!1,s=Re(it(e.at(-1)));for(let[a,l]of i.entries()){let c=Re(l);if(s+c<=r?e[e.length-1]+=l:(e.push(l),s=0),CC.has(l)&&!(o&&l===Nt&&i[a+1]==="\\")&&(n=!0,o=i.slice(a+1,a+1+ao.length).join("")===ao),n){o?(l===ww||l==="\\"&&a>0&&i[a-1]===Nt)&&(n=!1,o=!1):l===lo&&(n=!1);continue}s+=c,s===r&&a<i.length-1&&(e.push(""),s=0)}!s&&e.at(-1).length>0&&e.length>1&&(e[e.length-2]+=e.pop())},FC=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(Re(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},ZC=e=>{if(!e.includes(" "))return e;let t=e.split(" "),r=0,i="";for(let[n,o]of t.entries())if(i+=o,r+=Re(o),n<t.length-1){let s=hw-r%hw;i+=" ".repeat(s),r+=s}return i},BC=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let i="",n,o=[],s=qC(e),a=[""];for(let[d,f]of e.split(" ").entries()){r.trim!==!1&&(a[a.length-1]=a.at(-1).trimStart());let m=Re(a.at(-1));if(d!==0&&(m>=t&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),m=0),(m>0||r.trim===!1)&&(a[a.length-1]+=" ",m++)),r.hard&&r.wordWrap!==!1&&s[d]>t){let v=t-m,h=1+Math.floor((s[d]-v-1)/t);Math.floor((s[d]-1)/t)<h&&a.push(""),Ec(a,f,t);continue}if(m+s[d]>t&&m>0&&s[d]>0){if(r.wordWrap===!1&&m<t){Ec(a,f,t);continue}a.push("")}if(m+s[d]>t&&r.wordWrap===!1){Ec(a,f,t);continue}a[a.length-1]+=f}r.trim!==!1&&(a=a.map(d=>FC(d)));let l=a.join(`
258
+ Do not post anything to a PR; only edit ${e}. When the user is done, exit.`}async function Lb(e){let{done:t}=ir(gE(e),{allowEdits:!0});await t}function vE(e){return e.backlog?jb:e.apply?Db:e.refine?Lb:null}async function Ub(e,t,r){let i=vE(r);if(!i){await Nb(e,t,{prompt:r.prompt,submit:r.submit,addressComments:r.addressComments,announce:r.announce});return}await i(e),r.announce&&await ji(t.prNumber)}import{statSync as yE}from"node:fs";function or(e,t){let r;try{r=yE(t).size}catch{return null}return r===0?null:(console.log(`[${e}] cached \u2192 ${t} (${r} bytes)`),{name:e,outputPath:t,exitCode:0,stderr:""})}import Qw from"node:process";var te={};ze(te,{ConEmu:()=>Gb,beep:()=>JE,beginSynchronizedOutput:()=>Bb,clearScreen:()=>qE,clearTerminal:()=>BE,clearViewport:()=>FE,cursorBackward:()=>IE,cursorDown:()=>SE,cursorForward:()=>kE,cursorGetPosition:()=>EE,cursorHide:()=>NE,cursorLeft:()=>Fb,cursorMove:()=>_E,cursorNextLine:()=>CE,cursorPrevLine:()=>TE,cursorRestorePosition:()=>OE,cursorSavePosition:()=>PE,cursorShow:()=>AE,cursorTo:()=>xE,cursorUp:()=>qb,endSynchronizedOutput:()=>Vb,enterAlternativeScreen:()=>VE,eraseDown:()=>jE,eraseEndLine:()=>RE,eraseLine:()=>Zb,eraseLines:()=>zE,eraseScreen:()=>Qi,eraseStartLine:()=>DE,eraseUp:()=>LE,exitAlternativeScreen:()=>KE,iTerm:()=>Kb,image:()=>HE,link:()=>WE,scrollDown:()=>ME,scrollUp:()=>UE,setCwd:()=>YE,synchronizedOutput:()=>GE});import ar from"node:process";import bE from"node:os";var sr=globalThis.window?.document!==void 0,cq=globalThis.process?.versions?.node!==void 0,uq=globalThis.process?.versions?.bun!==void 0,dq=globalThis.Deno?.version?.deno!==void 0,fq=globalThis.process?.versions?.electron!==void 0,pq=globalThis.navigator?.userAgent?.includes("jsdom")===!0,mq=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,hq=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,gq=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,vq=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,cn=globalThis.navigator?.userAgentData?.platform,yq=cn==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",bq=cn==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",wq=cn==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",$q=cn==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),xq=cn==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android";var j="\x1B[",lr="\x1B]",Ct="\x07",un=";",Mb=!sr&&ar.env.TERM_PROGRAM==="Apple_Terminal",wE=!sr&&ar.platform==="win32",$E=!sr&&(ar.env.TERM?.startsWith("screen")||ar.env.TERM?.startsWith("tmux")||ar.env.TMUX!==void 0),yc=sr?()=>{throw new Error("`process.cwd()` only works in Node.js, not the browser.")}:ar.cwd,cr=e=>$E?"\x1BPtmux;"+e.replaceAll("\x1B","\x1B\x1B")+"\x1B\\":e,xE=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");return typeof t!="number"?j+(e+1)+"G":j+(t+1)+un+(e+1)+"H"},_E=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");let r="";return e<0?r+=j+-e+"D":e>0&&(r+=j+e+"C"),t<0?r+=j+-t+"A":t>0&&(r+=j+t+"B"),r},qb=(e=1)=>j+e+"A",SE=(e=1)=>j+e+"B",kE=(e=1)=>j+e+"C",IE=(e=1)=>j+e+"D",Fb=j+"G",PE=Mb?"\x1B7":j+"s",OE=Mb?"\x1B8":j+"u",EE=j+"6n",CE=j+"E",TE=j+"F",NE=j+"?25l",AE=j+"?25h",zE=e=>{let t="";for(let r=0;r<e;r++)t+=Zb+(r<e-1?qb():"");return e&&(t+=Fb),t},RE=j+"K",DE=j+"1K",Zb=j+"2K",jE=j+"J",LE=j+"1J",Qi=j+"2J",UE=j+"S",ME=j+"T",qE="\x1Bc",FE=`${Qi}${j}H`,ZE=()=>{if(sr||!wE)return!1;let e=bE.release().split("."),t=Number(e[0]),r=Number(e[2]??0);return t<10||t===10&&r<10586},BE=ZE()?`${Qi}${j}0f`:`${Qi}${j}3J${j}H`,VE=j+"?1049h",KE=j+"?1049l",Bb=j+"?2026h",Vb=j+"?2026l",GE=e=>Bb+e+Vb,JE=Ct,WE=(e,t)=>{let r=cr(`${lr}8${un}${un}${t}${Ct}`),i=cr(`${lr}8${un}${un}${Ct}`);return r+e+i},HE=(e,t={})=>{let r=`${lr}1337;File=inline=1`;t.width&&(r+=`;width=${t.width}`),t.height&&(r+=`;height=${t.height}`),t.preserveAspectRatio===!1&&(r+=";preserveAspectRatio=0");let i=Buffer.from(e);return cr(r+`;size=${i.byteLength}:`+i.toString("base64")+Ct)},Kb={setCwd:(e=yc())=>cr(`${lr}50;CurrentDir=${e}${Ct}`),annotation(e,t={}){let r=`${lr}1337;`,i=t.x!==void 0,n=t.y!==void 0;if((i||n)&&!(i&&n&&t.length!==void 0))throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return e=e.replaceAll("|",""),r+=t.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",t.length>0?r+=(i?[e,t.length,t.x,t.y]:[t.length,e]).join("|"):r+=e,cr(r+Ct)}},Gb={setCwd:(e=yc())=>cr(`${lr}9;9;${e}${Ct}`)},YE=(e=yc())=>Kb.setCwd(e)+Gb.setCwd(e);import Qb from"node:process";import no from"node:process";var XE=(e,t,r,i)=>{if(r==="length"||r==="prototype"||r==="arguments"||r==="caller")return;let n=Object.getOwnPropertyDescriptor(e,r),o=Object.getOwnPropertyDescriptor(t,r);!QE(n,o)&&i||Object.defineProperty(e,r,o)},QE=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},eC=(e,t)=>{let r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},tC=(e,t)=>`/* Wrapped ${e}*/
259
+ ${t}`,rC=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),nC=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),iC=(e,t,r)=>{let i=r===""?"":`with ${r.trim()}() `,n=tC.bind(null,i,t.toString());Object.defineProperty(n,"name",nC);let{writable:o,enumerable:s,configurable:a}=rC;Object.defineProperty(e,"toString",{value:n,writable:o,enumerable:s,configurable:a})};function bc(e,t,{ignoreNonConfigurable:r=!1}={}){let{name:i}=e;for(let n of Reflect.ownKeys(t))XE(e,t,n,r);return eC(e,t),iC(e,t,i),e}var eo=new WeakMap,Jb=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let r,i=0,n=e.displayName||e.name||"<anonymous>",o=function(...s){if(eo.set(o,++i),i===1)r=e.apply(this,s),e=void 0;else if(t.throw===!0)throw new Error(`Function \`${n}\` can only be called once`);return r};return bc(o,e),eo.set(o,i),o};Jb.callCount=e=>{if(!eo.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return eo.get(e)};var Wb=Jb;var Tt=[];Tt.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Tt.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Tt.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var to=e=>!!e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function",wc=Symbol.for("signal-exit emitter"),$c=globalThis,oC=Object.defineProperty.bind(Object),xc=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if($c[wc])return $c[wc];oC($c,wc,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,r){this.listeners[t].push(r)}removeListener(t,r){let i=this.listeners[t],n=i.indexOf(r);n!==-1&&(n===0&&i.length===1?i.length=0:i.splice(n,1))}emit(t,r,i){if(this.emitted[t])return!1;this.emitted[t]=!0;let n=!1;for(let o of this.listeners[t])n=o(r,i)===!0||n;return t==="exit"&&(n=this.emit("afterExit",r,i)||n),n}},ro=class{},sC=e=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}}),_c=class extends ro{onExit(){return()=>{}}load(){}unload(){}},Sc=class extends ro{#s=kc.platform==="win32"?"SIGINT":"SIGHUP";#t=new xc;#e;#i;#o;#n={};#r=!1;constructor(t){super(),this.#e=t,this.#n={};for(let r of Tt)this.#n[r]=()=>{let i=this.#e.listeners(r),{count:n}=this.#t,o=t;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(n+=o.__signal_exit_emitter__.count),i.length===n){this.unload();let s=this.#t.emit("exit",null,r),a=r==="SIGHUP"?this.#s:r;s||t.kill(t.pid,a)}};this.#o=t.reallyExit,this.#i=t.emit}onExit(t,r){if(!to(this.#e))return()=>{};this.#r===!1&&this.load();let i=r?.alwaysLast?"afterExit":"exit";return this.#t.on(i,t),()=>{this.#t.removeListener(i,t),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#r){this.#r=!0,this.#t.count+=1;for(let t of Tt)try{let r=this.#n[t];r&&this.#e.on(t,r)}catch{}this.#e.emit=(t,...r)=>this.#l(t,...r),this.#e.reallyExit=t=>this.#a(t)}}unload(){this.#r&&(this.#r=!1,Tt.forEach(t=>{let r=this.#n[t];if(!r)throw new Error("Listener not defined for signal: "+t);try{this.#e.removeListener(t,r)}catch{}}),this.#e.emit=this.#i,this.#e.reallyExit=this.#o,this.#t.count-=1)}#a(t){return to(this.#e)?(this.#e.exitCode=t||0,this.#t.emit("exit",this.#e.exitCode,null),this.#o.call(this.#e,this.#e.exitCode)):0}#l(t,...r){let i=this.#i;if(t==="exit"&&to(this.#e)){typeof r[0]=="number"&&(this.#e.exitCode=r[0]);let n=i.call(this.#e,t,...r);return this.#t.emit("exit",this.#e.exitCode,null),n}else return i.call(this.#e,t,...r)}},kc=globalThis.process,{onExit:Hb,load:zq,unload:Rq}=sC(to(kc)?new Sc(kc):new _c);var Yb=no.stderr.isTTY?no.stderr:no.stdout.isTTY?no.stdout:void 0,aC=Yb?Wb(()=>{Hb(()=>{Yb.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},Xb=aC;var io=!1,ur={};ur.show=(e=Qb.stderr)=>{e.isTTY&&(io=!1,e.write("\x1B[?25h"))};ur.hide=(e=Qb.stderr)=>{e.isTTY&&(Xb(),io=!0,e.write("\x1B[?25l"))};ur.toggle=(e,t)=>{e!==void 0&&(io=e),io?ur.show(t):ur.hide(t)};var Ic=ur;function Pc({onlyFirst:e=!1}={}){let n="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(n,e?void 0:"g")}var lC=Pc();function it(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes("\x1B")&&!e.includes("\x9B")?e:e.replace(lC,"")}var ew=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],tw=12288,rw=65510,nw=[12288,12288,65281,65376,65504,65510];var iw=4352,ow=262141,Oc=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var oo=(e,t)=>{let r=0,i=Math.floor(e.length/2)-1;for(;r<=i;){let n=Math.floor((r+i)/2),o=n*2;if(t<e[o])i=n-1;else if(t>e[o+1])r=n+1;else return!0}return!1};var sw=19968,[dC,fC]=pC(Oc);function pC(e){let t=e[0],r=e[1];for(let i=0;i<e.length;i+=2){let n=e[i],o=e[i+1];if(sw>=n&&sw<=o)return[n,o];o-n>r-t&&(t=n,r=o)}return[t,r]}var aw=e=>e<161||e>1114109?!1:oo(ew,e),dn=e=>e<tw||e>rw?!1:oo(nw,e);var fn=e=>e>=dC&&e<=fC?!0:e<iw||e>ow?!1:oo(Oc,e);function mC(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function pn(e,{ambiguousAsWide:t=!1}={}){return mC(e),dn(e)||fn(e)||t&&aw(e)?2:1}var hC=new Intl.Segmenter,lw=new RegExp("^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Format}|\\p{Mark}|\\p{Surrogate})+$","v"),gC=new RegExp("^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}\\p{Surrogate}]+","v"),vC=new RegExp("^\\p{RGI_Emoji}$","v"),yC=/^[\d#*]\u20E3$/,bC=new RegExp("\\p{Extended_Pictographic}","gu");function wC(e){if(e.length>50)return!1;if(yC.test(e))return!0;if(e.includes("\u200D")){let t=e.match(bC);return t!==null&&t.length>=2}return!1}function $C(e){return e.replace(gC,"")}function xC(e){return lw.test(e)}function cw(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function uw(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function dw(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function _C(e){return cw(e)||uw(e)||dw(e)}function SC(e,t){let r=[];for(let n of e)lw.test(n)||r.push(n.codePointAt(0));if(r.length===0)return;let i=0;for(let n=0;n<r.length;n++){let o=r[n];if(!_C(o)){if(i===0)return;for(let s=n;s<r.length;s++)i+=pn(r[s],t);return i}if(cw(o)&&uw(r[n+1])){i+=2,n+=dw(r[n+2])?2:1;continue}i+=pn(o,t)}return i}function kC(e,t){let r=0,i=!0;for(let n of e){if(i){i=!1;continue}n>="\uFF00"&&n<="\uFFEF"&&(r+=pn(n.codePointAt(0),t))}return r}function Re(e,t={}){if(typeof e!="string"||e.length===0)return 0;let{ambiguousIsNarrow:r=!0,countAnsiEscapeCodes:i=!1}=t,n=e;if(!i&&(n.includes("\x1B")||n.includes("\x9B"))&&(n=it(n)),n.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(n))return n.length;let o=0,s={ambiguousAsWide:!r};for(let{segment:a}of hC.segment(n)){if(xC(a))continue;if(vC.test(a)||wC(a)){o+=2;continue}let l=$C(a),c=SC(l,s);if(c!==void 0){o+=c;continue}let u=l.codePointAt(0);o+=pn(u,s),o+=kC(l,s)}return o}var fw=(e=0)=>t=>`\x1B[${t+e}m`,pw=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,mw=(e=0)=>(t,r,i)=>`\x1B[${38+e};2;${t};${r};${i}m`,G={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},dF=Object.keys(G.modifier),IC=Object.keys(G.color),PC=Object.keys(G.bgColor),fF=[...IC,...PC];function OC(){let e=new Map;for(let[t,r]of Object.entries(G)){for(let[i,n]of Object.entries(r))G[i]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},r[i]=G[i],e.set(n[0],n[1]);Object.defineProperty(G,t,{value:r,enumerable:!1})}return Object.defineProperty(G,"codes",{value:e,enumerable:!1}),G.color.close="\x1B[39m",G.bgColor.close="\x1B[49m",G.color.ansi=fw(),G.color.ansi256=pw(),G.color.ansi16m=mw(),G.bgColor.ansi=fw(10),G.bgColor.ansi256=pw(10),G.bgColor.ansi16m=mw(10),Object.defineProperties(G,{rgbToAnsi256:{value(t,r,i){return t===r&&r===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[i]=r;i.length===3&&(i=[...i].map(o=>o+o).join(""));let n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:t=>G.rgbToAnsi256(...G.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,i,n;if(t>=232)r=((t-232)*10+8)/255,i=r,n=r;else{t-=16;let a=t%36;r=Math.floor(t/36)/5,i=Math.floor(a/6)/5,n=a%6/5}let o=Math.max(r,i,n)*2;if(o===0)return 30;let s=30+(Math.round(n)<<2|Math.round(i)<<1|Math.round(r));return o===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(t,r,i)=>G.ansi256ToAnsi(G.rgbToAnsi256(t,r,i)),enumerable:!1},hexToAnsi:{value:t=>G.ansi256ToAnsi(G.hexToAnsi256(t)),enumerable:!1}}),G}var EC=OC(),xe=EC;var Nt="\x1B",Cc="\x9B",CC=new Set([Nt,Cc]),ww="\x07",$w="[",TC="]",lo="m",co=0,xw=39,_w=49,Sw=59,kw=38,Iw=48,Pw=58,NC=5,AC=2,ao=`${TC}8;;`,Ow=new RegExp(`^\\u001B(?:\\${$w}(?<sgr>[0-9;]*)${lo}|${ao}(?<uri>[^\\u0007\\u001B]*)(?:\\u0007|\\u001B\\\\))`),Ew=new RegExp(`^\\u009B(?<sgr>[0-9;]*)${lo}`),Cw=new Set(xe.codes.values());Cw.delete(co);var zC=new Intl.Segmenter,Tw=e=>Array.from(zC.segment(e),({segment:t})=>t),hw=8,Nw=e=>`${Nt}${$w}${e}${lo}`,gw=e=>`${Nt}${ao}${e}${ww}`,Aw=e=>{let t=e.split(";").map(i=>i===""?co:Number.parseInt(i,10)),r=[];for(let i=0;i<t.length;i++){let n=t[i];if(Number.isFinite(n)){if(n===kw||n===Iw||n===Pw){if(i+1>=t.length)break;let o=t[i+1];if(o===NC&&Number.isFinite(t[i+2])){r.push([n,o,t[i+2]]),i+=2;continue}let s=t[i+2],a=t[i+3],l=t[i+4];if(o===AC&&Number.isFinite(s)&&Number.isFinite(a)&&Number.isFinite(l)){r.push([n,o,s,a,l]),i+=4;continue}break}r.push([n])}}return r},so=(e,t)=>{let r=e.findIndex(i=>i.family===t);r!==-1&&e.splice(r,1)},vw=(e,t)=>{so(e,t.family),e.push(t)},RC=(e,t)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];i.family.startsWith("modifier-")&&i.close===t&&e.splice(r,1)}},DC=(e,t)=>{if(e>=30&&e<=37||e>=90&&e<=97||e===kw&&t.length>1)return{family:"foreground",open:t.join(";"),close:xw};if(e>=40&&e<=47||e>=100&&e<=107||e===Iw&&t.length>1)return{family:"background",open:t.join(";"),close:_w};if(e===Pw&&t.length>1)return{family:"underlineColor",open:t.join(";"),close:Sw}},zw=(e,t)=>e===co?(t.length=0,!0):e===xw?(so(t,"foreground"),!0):e===_w?(so(t,"background"),!0):e===Sw?(so(t,"underlineColor"),!0):Cw.has(e)?(RC(t,e),!0):!1,jC=(e,t)=>{let[r]=e;if(zw(r,t))return;let i=DC(r,e);if(i){vw(t,i);return}let n=xe.codes.get(r);n!==void 0&&n!==co&&vw(t,{family:`modifier-${r}`,open:e.join(";"),close:n})},yw=(e,t)=>{for(let r of Aw(e))jC(r,t)},bw=(e,t)=>{for(let r of Aw(e)){let[i]=r;zw(i,t)}},LC=(e,t)=>{let r=e;for(;r.length>0;){if(r.startsWith(Nt)&&r[1]!=="\\"){let i=Ow.exec(r);if(!i)break;i.groups.sgr!==void 0&&bw(i.groups.sgr,t),r=r.slice(i[0].length);continue}if(r.startsWith(Cc)){let i=Ew.exec(r);if(!i||i.groups.sgr===void 0)break;bw(i.groups.sgr,t),r=r.slice(i[0].length);continue}break}},UC=e=>[...e].reverse().map(t=>Nw(t.close)).join(""),MC=e=>e.map(t=>Nw(t.open)).join(""),qC=e=>e.split(" ").map(t=>Re(t)),Ec=(e,t,r)=>{let i=Tw(t),n=!1,o=!1,s=Re(it(e.at(-1)));for(let[a,l]of i.entries()){let c=Re(l);if(s+c<=r?e[e.length-1]+=l:(e.push(l),s=0),CC.has(l)&&!(o&&l===Nt&&i[a+1]==="\\")&&(n=!0,o=i.slice(a+1,a+1+ao.length).join("")===ao),n){o?(l===ww||l==="\\"&&a>0&&i[a-1]===Nt)&&(n=!1,o=!1):l===lo&&(n=!1);continue}s+=c,s===r&&a<i.length-1&&(e.push(""),s=0)}!s&&e.at(-1).length>0&&e.length>1&&(e[e.length-2]+=e.pop())},FC=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(Re(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},ZC=e=>{if(!e.includes(" "))return e;let t=e.split(" "),r=0,i="";for(let[n,o]of t.entries())if(i+=o,r+=Re(o),n<t.length-1){let s=hw-r%hw;i+=" ".repeat(s),r+=s}return i},BC=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let i="",n,o=[],s=qC(e),a=[""];for(let[d,f]of e.split(" ").entries()){r.trim!==!1&&(a[a.length-1]=a.at(-1).trimStart());let m=Re(a.at(-1));if(d!==0&&(m>=t&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),m=0),(m>0||r.trim===!1)&&(a[a.length-1]+=" ",m++)),r.hard&&r.wordWrap!==!1&&s[d]>t){let v=t-m,h=1+Math.floor((s[d]-v-1)/t);Math.floor((s[d]-1)/t)<h&&a.push(""),Ec(a,f,t);continue}if(m+s[d]>t&&m>0&&s[d]>0){if(r.wordWrap===!1&&m<t){Ec(a,f,t);continue}a.push("")}if(m+s[d]>t&&r.wordWrap===!1){Ec(a,f,t);continue}a[a.length-1]+=f}r.trim!==!1&&(a=a.map(d=>FC(d)));let l=a.join(`
260
260
  `),c=Tw(l),u=0;for(let[d,f]of c.entries()){if(i+=f,f===Nt&&c[d+1]!=="\\"){let{groups:m}=Ow.exec(l.slice(u))||{groups:{}};m.sgr!==void 0?yw(m.sgr,o):m.uri!==void 0&&(n=m.uri.length===0?void 0:m.uri)}else if(f===Cc){let{groups:m}=Ew.exec(l.slice(u))||{groups:{}};m.sgr!==void 0&&yw(m.sgr,o)}if(c[d+1]===`
261
261
  `)n&&(i+=gw("")),i+=UC(o);else if(f===`
262
262
  `){let m=[...o];LC(l.slice(u+1),m),i+=MC(m),n&&(i+=gw(n))}u+=f.length}return i};function Tc(e,t,r){return String(e).normalize().replaceAll(`\r
@@ -274,7 +274,7 @@ ${t}`,rC=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),nC=Objec
274
274
  `,$=Tc(b,m,{trim:!1,hard:!0,wordWrap:!1}),{text:S,wasClipped:x}=v?JT(e,$,i):{text:$,wasClipped:!1},O=S===""?[]:S.split(`
275
275
  `);return{wrapped:S,lines:O,wasClipped:x}},u=()=>{s="",o=go(e,r),n=0},d=(...f)=>{t||Ic.hide();let m=go(e,r),{wrapped:v,lines:h,wasClipped:b}=c(f.join(" "),m);if(h.length===0){n>0&&l(te.eraseLines(n)),s=v,o=m,n=0;return}if(v===s&&o===m)return;if(n===0){l(v),s=v,o=m,n=h.length;return}if(o!==m||b){l(te.eraseLines(n)+v),s=v,o=m,n=h.length;return}let $=s===""?[]:s.split(`
276
276
  `),{start:S,endPrevious:x,endNext:O}=WT($,h);if($.length!==h.length&&(x=$.length-1,O=h.length-1),S===h.length&&n===h.length)return;if(S===0){l(te.eraseLines(n)+v),s=v,o=m,n=h.length;return}let C=HT({prevCount:n,start:S,endPrevious:x,endNext:O,nextLines:h,nextWrappedEndsWithNewline:v.endsWith(`
277
- `)});l(C),s=v,o=m,n=h.length};return d.clear=()=>{l(te.eraseLines(n)),u()},d.done=()=>{u(),t||Ic.show()},d.persist=(...f)=>{let m=n>0?te.eraseLines(n):"",v=go(e,r),{wrapped:h}=c(f.join(" "),v,!1);l(m+h),u()},d}var TF=vo(Qw.stdout);var NF=vo(Qw.stderr);var Fc=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function YT(e){if(e.elapsedStart===void 0||e.state!=="running")return;let t=Math.round((Date.now()-e.elapsedStart)/1e3);e.text=`${e.elapsedPrefix??"elapsed"}: ${t}s`}function e$(e,t){let r=[...e].sort((i,n)=>+!!i.footer-+!!n.footer);for(let i of r)YT(i);return r.map(i=>Zc(i,t)).join(`
277
+ `)});l(C),s=v,o=m,n=h.length};return d.clear=()=>{l(te.eraseLines(n)),u()},d.done=()=>{u(),t||Ic.show()},d.persist=(...f)=>{let m=n>0?te.eraseLines(n):"",v=go(e,r),{wrapped:h}=c(f.join(" "),v,!1);l(m+h),u()},d}var NF=vo(Qw.stdout);var AF=vo(Qw.stderr);var Fc=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function YT(e){if(e.elapsedStart===void 0||e.state!=="running")return;let t=Math.round((Date.now()-e.elapsedStart)/1e3);e.text=`${e.elapsedPrefix??"elapsed"}: ${t}s`}function e$(e,t){let r=[...e].sort((i,n)=>+!!i.footer-+!!n.footer);for(let i of r)YT(i);return r.map(i=>Zc(i,t)).join(`
278
278
  `)}function Zc(e,t){return e.state==="succeeded"?`\u2714 ${e.text}`:e.state==="failed"?`\u2716 ${e.text}`:`${Fc[t]} ${e.text}`}import{appendFileSync as r$,mkdirSync as QT}from"node:fs";import{join as eN}from"node:path";var XT=new RegExp("\x1B\\[[0-9;?]*[ -/]*[@-~]","g");function t$(e){return e.replace(XT,"")}var tN="review.log";function n$(){let e,t=[];return{append(r){let i=t$(r);if(!e){t.push(i);return}r$(e,`${i}
279
279
  `)},attach(r){QT(r,{recursive:!0}),e=eN(r,tN);let i=["",`=== ${new Date().toISOString()} ===`,`$ ${process.argv.slice(1).join(" ")}`,...t];t=[],r$(e,`${i.join(`
280
280
  `)}
@@ -474,4 +474,4 @@ Each added or context line is prefixed with a left gutter showing its line numbe
474
474
  \`\`\`diff
475
475
  ${WI(e.diff.trimEnd())}
476
476
  \`\`\`
477
- `}import{homedir as O2}from"node:os";import{basename as E2,join as Ei}from"node:path";function XI(e,t){let r=Ei(O2(),".assist","reviews",E2(e),t);return{reviewDir:r,requestPath:Ei(r,"request.md"),claudePath:Ei(r,"claude.md"),codexPath:Ei(r,"codex.md"),synthesisPath:Ei(r,"synthesis.md")}}import{execSync as D2}from"node:child_process";import{execSync as C2}from"node:child_process";import{unlinkSync as T2,writeFileSync as N2}from"node:fs";import{tmpdir as A2}from"node:os";import{join as z2}from"node:path";var R2="query($owner: String!, $repo: String!, $prNumber: Int!) { repository(owner: $owner, name: $repo) { pullRequest(number: $prNumber) { reviewThreads(first: 100) { nodes { id isResolved comments(first: 100) { nodes { databaseId } } } } } } }";function QI(e,t,r){let i=z2(A2(),`gh-query-${Date.now()}.graphql`);N2(i,R2);try{let n=C2(`gh api graphql -F query=@${i} -F owner="${e}" -F repo="${t}" -F prNumber=${r}`,{encoding:"utf8"}),o=JSON.parse(n),s=new Map,a=new Set;for(let l of o.data.repository.pullRequest.reviewThreads.nodes){l.isResolved&&a.add(l.id);for(let c of l.comments.nodes)s.set(c.databaseId,l.id)}return{threadMap:s,resolvedThreadIds:a}}finally{T2(i)}}function j2(e,t,r){let i=D2(`gh api --paginate repos/${e}/${t}/pulls/${r}/comments`,{encoding:"utf8",maxBuffer:67108864});return i.trim()?JSON.parse(i):[]}function e1(){let e=Ai();if(e===null)return null;let{org:t,repo:r}=Xe(),i=j2(t,r,e);if(i.length===0)return[];let n=QI(t,r,e);return i.map(o=>{let s=n.threadMap.get(o.id)??"";return{id:o.id,threadId:s,file:o.path,line:o.line??o.original_line??null,author:o.user.login,body:o.body,inReplyToId:o.in_reply_to_id??null,resolved:s!==""&&n.resolvedThreadIds.has(s),outdated:o.position===null}})}import{existsSync as L2,mkdirSync as U2,unlinkSync as M2,writeFileSync as q2}from"node:fs";function F2(e){for(let t of[e.claudePath,e.codexPath,e.synthesisPath])L2(t)&&M2(t)}function t1(e,t,r){U2(e.reviewDir,{recursive:!0}),r&&F2(e),q2(e.requestPath,t)}function r1(e,t,r){let i=XI(e,`${t.branch}-${t.shortSha}`),n=e1();return Z2(n?.length??0),t1(i,YI(t,n),r),console.log(`Review folder: ${i.reviewDir}`),i}function Z2(e){e!==0&&console.log(`Including ${e} prior review comment(s) in request.md.`)}function B2(){let e=Vg();if(e.changedFiles.length>0)return e;console.error(`Error: PR #${e.prNumber} has no changed files \u2014 nothing to review.`),process.exit(1)}function V2(e,t,r){return Ub(e,t,{refine:r.refine??!1,apply:r.apply??!1,backlog:r.backlog??!1,prompt:r.prompt??!0,submit:r.submit??!1,addressComments:r.addressComments??!1,announce:r.announce??!1})}async function n1(e,t){let r=B2(),i=r1(e,r,t.force??!1);s$(i.reviewDir);let n=await JI(i,{verbose:t.verbose??!1,models:t.ci?.models,strict:t.ci!==void 0});!n&&t.ci&&(console.error("Review failed; nothing was posted."),process.exit(1)),n&&await V2(i.synthesisPath,r,t),console.log(`Done. Review folder: ${i.reviewDir}`)}function K2(e){return{ANTHROPIC_DEFAULT_OPUS_MODEL:e,ANTHROPIC_DEFAULT_SONNET_MODEL:e,ANTHROPIC_DEFAULT_HAIKU_MODEL:e,CLAUDE_CODE_SUBAGENT_MODEL:e}}function i1(e,t){let r=e.claudeModel;return{claude:{args:["--model",r],env:{ANTHROPIC_BASE_URL:t.anthropic,ANTHROPIC_AUTH_TOKEN:e.apiKey,CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:"1",...K2(r)},model:r},codex:ul(t.responses,e.apiKey,e.codexModel)}}var G2=["ASSIST_REVIEW_PROVIDER","ASSIST_REVIEW_BASE_URL","ASSIST_REVIEW_CLAUDE_MODEL","ASSIST_REVIEW_CODEX_MODEL"],Ng="ASSIST_REVIEW_API_KEY",o1=[...G2,Ng],s1=["litellm"];function a1(e,t){if(e==="litellm")return{anthropic:t,responses:`${t}/v1`};throw new Error(`Unsupported ASSIST_REVIEW_PROVIDER "${e}" (expected one of: ${s1.join(", ")})`)}import{readFileSync as J2}from"node:fs";function l1(e){let t=e.GITHUB_EVENT_PATH;if(!t)throw new Error("GITHUB_EVENT_PATH is not set; run this from a workflow");let i=JSON.parse(J2(t,"utf8")).pull_request?.number;if(!i)throw new Error("The workflow event has no pull_request; trigger it on pull_request");return i}function c1(e){let t=i=>e[i]?.trim()??"",r=o1.filter(i=>!t(i));return r.length>0?{config:null,missing:r}:{config:{provider:t("ASSIST_REVIEW_PROVIDER"),baseUrl:t("ASSIST_REVIEW_BASE_URL").replace(/\/+$/,""),claudeModel:t("ASSIST_REVIEW_CLAUDE_MODEL"),codexModel:t("ASSIST_REVIEW_CODEX_MODEL"),apiKey:t(Ng)},missing:r}}async function W2(e){let{config:t,missing:r}=c1(e);if(!t)throw new Error(`${r.join(", ")} not set`);let i=a1(t.provider,t.baseUrl);for(let n of["claude","codex"])if(!Qr(n))throw new Error(`${n} is not on PATH`);Rg(l1(e)),await n1(process.cwd(),{prompt:!1,submit:!0,force:!0,verbose:!0,ci:{models:i1(t,i)}})}try{await W2(process.env)}catch(e){console.error(`review-ci: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}export{W2 as reviewCiReview};
477
+ `}import{homedir as O2}from"node:os";import{basename as E2,join as Ei}from"node:path";function XI(e,t){let r=Ei(O2(),".assist","reviews",E2(e),t);return{reviewDir:r,requestPath:Ei(r,"request.md"),claudePath:Ei(r,"claude.md"),codexPath:Ei(r,"codex.md"),synthesisPath:Ei(r,"synthesis.md")}}import{execSync as D2}from"node:child_process";import{execSync as C2}from"node:child_process";import{unlinkSync as T2,writeFileSync as N2}from"node:fs";import{tmpdir as A2}from"node:os";import{join as z2}from"node:path";var R2="query($owner: String!, $repo: String!, $prNumber: Int!) { repository(owner: $owner, name: $repo) { pullRequest(number: $prNumber) { reviewThreads(first: 100) { nodes { id isResolved comments(first: 100) { nodes { databaseId } } } } } } }";function QI(e,t,r){let i=z2(A2(),`gh-query-${Date.now()}.graphql`);N2(i,R2);try{let n=C2(`gh api graphql -F query=@${i} -F owner="${e}" -F repo="${t}" -F prNumber=${r}`,{encoding:"utf8"}),o=JSON.parse(n),s=new Map,a=new Set;for(let l of o.data.repository.pullRequest.reviewThreads.nodes){l.isResolved&&a.add(l.id);for(let c of l.comments.nodes)s.set(c.databaseId,l.id)}return{threadMap:s,resolvedThreadIds:a}}finally{T2(i)}}function j2(e,t,r){let i=D2(`gh api --paginate repos/${e}/${t}/pulls/${r}/comments`,{encoding:"utf8",maxBuffer:67108864});return i.trim()?JSON.parse(i):[]}function e1(){let e=Ai();if(e===null)return null;let{org:t,repo:r}=Xe(),i=j2(t,r,e);if(i.length===0)return[];let n=QI(t,r,e);return i.map(o=>{let s=n.threadMap.get(o.id)??"";return{id:o.id,threadId:s,file:o.path,line:o.line??o.original_line??null,author:o.user.login,body:o.body,inReplyToId:o.in_reply_to_id??null,resolved:s!==""&&n.resolvedThreadIds.has(s),outdated:o.position===null}})}import{existsSync as L2,mkdirSync as U2,unlinkSync as M2,writeFileSync as q2}from"node:fs";function F2(e){for(let t of[e.claudePath,e.codexPath,e.synthesisPath])L2(t)&&M2(t)}function t1(e,t,r){U2(e.reviewDir,{recursive:!0}),r&&F2(e),q2(e.requestPath,t)}function r1(e,t,r){let i=XI(e,`${t.branch}-${t.shortSha}`),n=e1();return Z2(n?.length??0),t1(i,YI(t,n),r),console.log(`Review folder: ${i.reviewDir}`),i}function Z2(e){e!==0&&console.log(`Including ${e} prior review comment(s) in request.md.`)}function B2(){let e=Vg();if(e.changedFiles.length>0)return e;console.error(`Error: PR #${e.prNumber} has no changed files \u2014 nothing to review.`),process.exit(1)}function V2(e,t,r){return Ub(e,t,{refine:r.refine??!1,apply:r.apply??!1,backlog:r.backlog??!1,prompt:r.prompt??!0,submit:r.submit??!1,addressComments:r.addressComments??!1,announce:r.announce??!1})}async function n1(e,t){let r=B2(),i=r1(e,r,t.force??!1);s$(i.reviewDir);let n=await JI(i,{verbose:t.verbose??!1,models:t.ci?.models,strict:t.ci!==void 0});!n&&t.ci&&(console.error("Review failed; nothing was posted."),process.exit(1)),n&&await V2(i.synthesisPath,r,t),console.log(`Done. Review folder: ${i.reviewDir}`)}function K2(e){return{ANTHROPIC_DEFAULT_OPUS_MODEL:e,ANTHROPIC_DEFAULT_SONNET_MODEL:e,ANTHROPIC_DEFAULT_HAIKU_MODEL:e,CLAUDE_CODE_SUBAGENT_MODEL:e}}function G2(e,t){return e.anthropicKind==="foundry"?{CLAUDE_CODE_USE_FOUNDRY:"1",ANTHROPIC_FOUNDRY_BASE_URL:e.anthropic,ANTHROPIC_FOUNDRY_API_KEY:t}:{ANTHROPIC_BASE_URL:e.anthropic,ANTHROPIC_AUTH_TOKEN:t}}function i1(e,t){let r=e.claudeModel;return{claude:{args:["--model",r],env:{...G2(t,e.apiKey),CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:"1",...K2(r)},model:r},codex:ul(t.responses,e.apiKey,e.codexModel)}}var J2=["ASSIST_REVIEW_PROVIDER","ASSIST_REVIEW_BASE_URL","ASSIST_REVIEW_CLAUDE_MODEL","ASSIST_REVIEW_CODEX_MODEL"],Ng="ASSIST_REVIEW_API_KEY",o1=[...J2,Ng],s1=["litellm","foundry"];function a1(e,t){if(e==="litellm")return{anthropic:t,responses:`${t}/v1`,anthropicKind:"gateway"};if(e==="foundry")return{anthropic:`${t}/anthropic`,responses:`${t}/openai/v1`,anthropicKind:"foundry"};throw new Error(`Unsupported ASSIST_REVIEW_PROVIDER "${e}" (expected one of: ${s1.join(", ")})`)}import{readFileSync as W2}from"node:fs";function l1(e){let t=e.GITHUB_EVENT_PATH;if(!t)throw new Error("GITHUB_EVENT_PATH is not set; run this from a workflow");let i=JSON.parse(W2(t,"utf8")).pull_request?.number;if(!i)throw new Error("The workflow event has no pull_request; trigger it on pull_request");return i}function c1(e){let t=i=>e[i]?.trim()??"",r=o1.filter(i=>!t(i));return r.length>0?{config:null,missing:r}:{config:{provider:t("ASSIST_REVIEW_PROVIDER"),baseUrl:t("ASSIST_REVIEW_BASE_URL").replace(/\/+$/,""),claudeModel:t("ASSIST_REVIEW_CLAUDE_MODEL"),codexModel:t("ASSIST_REVIEW_CODEX_MODEL"),apiKey:t(Ng)},missing:r}}async function H2(e){let{config:t,missing:r}=c1(e);if(!t)throw new Error(`${r.join(", ")} not set`);let i=a1(t.provider,t.baseUrl);for(let n of["claude","codex"])if(!Qr(n))throw new Error(`${n} is not on PATH`);Rg(l1(e)),await n1(process.cwd(),{prompt:!1,submit:!0,force:!0,verbose:!0,ci:{models:i1(t,i)}})}try{await H2(process.env)}catch(e){console.error(`review-ci: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}export{H2 as reviewCiReview};