@staff0rd/assist 0.853.1 → 0.854.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 lP=Object.create;var _l=Object.defineProperty;var cP=Object.getOwnPropertyDescriptor;var uP=Object.getOwnPropertyNames;var dP=Object.getPrototypeOf,fP=Object.prototype.hasOwnProperty;var Xe=(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),De=(e,t)=>{for(var r in t)_l(e,r,{get:t[r],enumerable:!0})},pP=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of uP(t))!fP.call(e,n)&&n!==r&&_l(e,n,{get:()=>t[n],enumerable:!(i=cP(t,n))||i.enumerable});return e};var kl=(e,t,r)=>(r=e!=null?lP(dP(e)):{},pP(t||!e||!e.__esModule?_l(r,"default",{value:e,enumerable:!0}):r,e));var Qy=w((SF,xn)=>{"use strict";var YE=typeof process<"u"&&process.env.TERM_PROGRAM==="Hyper",XE=typeof process<"u"&&process.platform==="win32",Hy=typeof process<"u"&&process.platform==="linux",oc={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"},Yy=Object.assign({},oc,{check:"\u221A",cross:"\xD7",ellipsisLarge:"...",ellipsis:"...",info:"i",questionSmall:"?",pointer:">",pointerSmall:"\xBB",radioOff:"( )",radioOn:"(*)",warning:"\u203C"}),Xy=Object.assign({},oc,{ballotCross:"\u2718",check:"\u2714",cross:"\u2716",ellipsisLarge:"\u22EF",ellipsis:"\u2026",info:"\u2139",questionFull:"\uFF1F",questionSmall:"\uFE56",pointer:Hy?"\u25B8":"\u276F",pointerSmall:Hy?"\u2023":"\u203A",radioOff:"\u25EF",radioOn:"\u25C9",warning:"\u26A0"});xn.exports=XE&&!YE?Yy:Xy;Reflect.defineProperty(xn.exports,"common",{enumerable:!1,value:oc});Reflect.defineProperty(xn.exports,"windows",{enumerable:!1,value:Yy});Reflect.defineProperty(xn.exports,"other",{enumerable:!1,value:Xy})});var ho=w((_F,sc)=>{"use strict";var QE=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),eT=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,tT=()=>typeof process<"u"?process.env.FORCE_COLOR!=="0":!1,eb=()=>{let e={enabled:tT(),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 lP=Object.create;var _l=Object.defineProperty;var cP=Object.getOwnPropertyDescriptor;var uP=Object.getOwnPropertyNames;var dP=Object.getPrototypeOf,fP=Object.prototype.hasOwnProperty;var Xe=(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),De=(e,t)=>{for(var r in t)_l(e,r,{get:t[r],enumerable:!0})},pP=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of uP(t))!fP.call(e,n)&&n!==r&&_l(e,n,{get:()=>t[n],enumerable:!(i=cP(t,n))||i.enumerable});return e};var kl=(e,t,r)=>(r=e!=null?lP(dP(e)):{},pP(t||!e||!e.__esModule?_l(r,"default",{value:e,enumerable:!0}):r,e));var Qy=w((bF,xn)=>{"use strict";var YE=typeof process<"u"&&process.env.TERM_PROGRAM==="Hyper",XE=typeof process<"u"&&process.platform==="win32",Hy=typeof process<"u"&&process.platform==="linux",oc={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"},Yy=Object.assign({},oc,{check:"\u221A",cross:"\xD7",ellipsisLarge:"...",ellipsis:"...",info:"i",questionSmall:"?",pointer:">",pointerSmall:"\xBB",radioOff:"( )",radioOn:"(*)",warning:"\u203C"}),Xy=Object.assign({},oc,{ballotCross:"\u2718",check:"\u2714",cross:"\u2716",ellipsisLarge:"\u22EF",ellipsis:"\u2026",info:"\u2139",questionFull:"\uFF1F",questionSmall:"\uFE56",pointer:Hy?"\u25B8":"\u276F",pointerSmall:Hy?"\u2023":"\u203A",radioOff:"\u25EF",radioOn:"\u25C9",warning:"\u26A0"});xn.exports=XE&&!YE?Yy:Xy;Reflect.defineProperty(xn.exports,"common",{enumerable:!1,value:oc});Reflect.defineProperty(xn.exports,"windows",{enumerable:!1,value:Yy});Reflect.defineProperty(xn.exports,"other",{enumerable:!1,value:Xy})});var ho=w((wF,sc)=>{"use strict";var QE=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),eT=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,tT=()=>typeof process<"u"?process.env.FORCE_COLOR!=="0":!1,eb=()=>{let e={enabled:tT(),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=eT,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(!QE(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=Qy(),e.define=n,e};sc.exports=eb();sc.exports.create=eb});var oe=w(D=>{"use strict";var rT=Object.prototype.toString,Se=ho(),tb=!1,Sn=new Set,rb={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&&Se.hasColor(e);var go=D.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);D.nativeType=e=>rT.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=>Se.keys.color.includes(i));return t?Se[t]:e.stack.find(i=>i.slice(2)==="bg")?Se[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=>Se.keys.color.includes(i));if(t){let i=Se["bg"+D.pascal(t)];return i?i.black:e}let r=e.stack.find(i=>i.slice(0,2)==="bg");return r?Se[r.slice(2).toLowerCase()]||e:Se.none};D.complement=e=>{if(!e||!e.stack)return e;let t=e.stack.find(i=>Se.keys.color.includes(i)),r=e.stack.find(i=>i.slice(0,2)==="bg");if(t&&!r)return Se[rb[t]||t];if(r){let i=r.slice(2).toLowerCase(),n=rb[i];return n&&Se["bg"+D.pascal(n)]||e}return Se.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(!go(e))return t;if(!go(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)&&go(i.value)){let n=Object.getOwnPropertyDescriptor(e,r);go(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 vo=(e,t)=>{tb||(tb=!0,Sn.forEach(r=>r()),e===!0&&process.exit(128+t))},nb=vo.bind(null,!0,15),ib=vo.bind(null,!0,2);D.onExit=e=>(Sn.size===0&&(process.once("SIGTERM",nb),process.once("SIGINT",ib),process.once("exit",vo)),Sn.add(e),()=>{Sn.delete(e),Sn.size===0&&(process.off("SIGTERM",nb),process.off("SIGINT",ib),process.off("exit",vo))});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 sb=w((IF,ob)=>{"use strict";ob.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 nt=w((PF,ab)=>{"use strict";var nT=sb();ab.exports=e=>typeof e=="string"?e.replace(nT(),""):e});var lb=w(ur=>{"use strict";ur.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"};ur.shift={up:"shiftUp",down:"shiftDown",left:"shiftLeft",right:"shiftRight",tab:"prev"};ur.fn={up:"pageUp",down:"pageDown",left:"pageLeft",right:"pageRight",delete:"deleteForward"};ur.option={b:"backward",f:"forward",d:"cutRight",left:"cutLeft",up:"altUp",down:"altDown"};ur.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 ub=w((EF,cb)=>{"use strict";cb.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 ac=w((TF,fb)=>{"use strict";var db=Xe("readline"),iT=lb(),oT=ub(),sT=/^(?:\x1b)([a-zA-Z0-9])$/,aT=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,lT={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 cT(e){return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(e)}function uT(e){return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(e)}var yo=(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=sT.exec(e))i.meta=!0,i.shift=/^[A-Z]$/.test(r[1]);else if(r=aT.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=lT[o],i.shift=cT(o)||i.shift,i.ctrl=uT(o)||i.ctrl}return i};yo.listen=(e={},t)=>{let{stdin:r}=e;if(!r||r!==process.stdin&&!r.isTTY)throw new Error("Invalid stream passed");let i=db.createInterface({terminal:!0,input:r});db.emitKeypressEvents(r,i);let n=new oT((a,l)=>t(a,yo(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()}};yo.action=(e,t,r)=>{let i={...iT,...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)};fb.exports=yo});var mb=w((RF,pb)=>{"use strict";pb.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}),dT(e,r,i)}};function dT(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 gb=w((NF,hb)=>{"use strict";var{define:fT,width:pT}=oe(),lc=class{constructor(t){let r=t.options;fT(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=pT(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"}};hb.exports=lc});var yb=w((AF,vb)=>{"use strict";var cc=oe(),re=ho(),uc={default:re.noop,noop:re.noop,set inverse(e){this._inverse=e},get inverse(){return this._inverse||cc.inverse(this.primary)},set complement(e){this._complement=e},get complement(){return this._complement||cc.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}};uc.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=cc.merge({},uc,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};vb.exports=uc});var wb=w((zF,bb)=>{"use strict";var dc=process.platform==="win32",Be=ho(),mT=oe(),fc={...Be.symbols,upDownDoubleArrow:"\u21D5",upDownDoubleArrow2:"\u2B0D",upDownArrow:"\u2195",asterisk:"*",asterism:"\u2042",bulletWhite:"\u25E6",electricArrow:"\u2301",ellipsisLarge:"\u22EF",ellipsisSmall:"\u2026",fullBlock:"\u2588",identicalTo:"\u2261",indicator:Be.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:Be.symbols.question,submitted:Be.symbols.check,cancelled:Be.symbols.cross},separator:{pending:Be.symbols.pointerSmall,submitted:Be.symbols.middot,cancelled:Be.symbols.middot},radio:{off:dc?"( )":"\u25EF",on:dc?"(*)":"\u25C9",disabled:dc?"(|)":"\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"]};fc.merge=e=>{let t=mT.merge({},Be.symbols,fc,e.symbols);return delete t.merge,t};bb.exports=fc});var xb=w((DF,$b)=>{"use strict";var hT=yb(),gT=wb(),vT=oe();$b.exports=e=>{e.options=vT.merge({},e.options.theme,e.options),e.symbols=gT.merge(e.options),e.styles=hT.merge(e.options)}});var Pb=w((kb,Ib)=>{"use strict";var Sb=process.env.TERM_PROGRAM==="Apple_Terminal",yT=nt(),pc=oe(),Ee=Ib.exports=kb,J="\x1B[",_b="\x07",mc=!1,it=Ee.code={bell:_b,beep:_b,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+(Sb?"8":"u"),savePosition:J+(Sb?"7":"s"),screen:`${J}2J`,show:`${J}?25h`,up:`${J}1J`},At=Ee.cursor={get hidden(){return mc},hide(){return mc=!0,it.hide},show(){return mc=!1,it.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?At.left(-e):e>0?At.right(e):"",r+=t<0?At.up(-t):t>0?At.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=pc.isPrimitive(i)?String(i):"",n=pc.isPrimitive(n)?String(n):"",a=pc.isPrimitive(a)?String(a):"",s){let l=Ee.cursor.up(s)+Ee.cursor.to(this.strLen(o)),c=n.length-r;return c>0&&(l+=Ee.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)),Ee.cursor.move(l)}}},hc=Ee.erase={screen:it.screen,up:it.up,down:it.down,line:it.line,lineEnd:it.lineEnd,lineStart:it.lineStart,lines(e){let t="";for(let r=0;r<e;r++)t+=Ee.erase.line+(r<e-1?Ee.cursor.up(1):"");return e&&(t+=Ee.code.beginning),t}};Ee.clear=(e="",t=process.stdout.columns)=>{if(!t)return hc.line+At.to(0);let r=o=>[...yT(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(hc.line+At.prevLine()).repeat(n-1)+hc.line+At.to(0)}});var dr=w((jF,Ob)=>{"use strict";var bT=Xe("events"),Cb=nt(),gc=ac(),wT=mb(),$T=gb(),xT=xb(),fe=oe(),zt=Pb(),vc=class e extends bT{constructor(t={}){super(),this.name=t.name,this.type=t.type,this.options=t,xT(this),wT(this),this.state=new $T(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=_T(this.options.margin),this.setMaxListeners(0),ST(this)}async keypress(t,r={}){this.keypressed=!0;let i=gc.action(t,gc(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(zt.code.beep)}cursorHide(){this.stdout.write(zt.cursor.hide());let t=fe.onExit(()=>this.cursorShow());this.on("close",()=>{this.cursorShow(),t()})}cursorShow(){this.stdout.write(zt.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(zt.cursor.down(t)+zt.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=zt.cursor.restore(c);u&&this.stdout.write(u)}sections(){let{buffer:t,input:r,prompt:i}=this.state;i=Cb(i);let n=Cb(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=>Se.keys.color.includes(i));return t?Se[t]:e.stack.find(i=>i.slice(2)==="bg")?Se[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=>Se.keys.color.includes(i));if(t){let i=Se["bg"+D.pascal(t)];return i?i.black:e}let r=e.stack.find(i=>i.slice(0,2)==="bg");return r?Se[r.slice(2).toLowerCase()]||e:Se.none};D.complement=e=>{if(!e||!e.stack)return e;let t=e.stack.find(i=>Se.keys.color.includes(i)),r=e.stack.find(i=>i.slice(0,2)==="bg");if(t&&!r)return Se[rb[t]||t];if(r){let i=r.slice(2).toLowerCase(),n=rb[i];return n&&Se["bg"+D.pascal(n)]||e}return Se.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(!go(e))return t;if(!go(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)&&go(i.value)){let n=Object.getOwnPropertyDescriptor(e,r);go(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 vo=(e,t)=>{tb||(tb=!0,Sn.forEach(r=>r()),e===!0&&process.exit(128+t))},nb=vo.bind(null,!0,15),ib=vo.bind(null,!0,2);D.onExit=e=>(Sn.size===0&&(process.once("SIGTERM",nb),process.once("SIGINT",ib),process.once("exit",vo)),Sn.add(e),()=>{Sn.delete(e),Sn.size===0&&(process.off("SIGTERM",nb),process.off("SIGINT",ib),process.off("exit",vo))});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 sb=w((xF,ob)=>{"use strict";ob.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 nt=w((SF,ab)=>{"use strict";var nT=sb();ab.exports=e=>typeof e=="string"?e.replace(nT(),""):e});var lb=w(ur=>{"use strict";ur.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"};ur.shift={up:"shiftUp",down:"shiftDown",left:"shiftLeft",right:"shiftRight",tab:"prev"};ur.fn={up:"pageUp",down:"pageDown",left:"pageLeft",right:"pageRight",delete:"deleteForward"};ur.option={b:"backward",f:"forward",d:"cutRight",left:"cutLeft",up:"altUp",down:"altDown"};ur.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 ub=w((IF,cb)=>{"use strict";cb.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 ac=w((PF,fb)=>{"use strict";var db=Xe("readline"),iT=lb(),oT=ub(),sT=/^(?:\x1b)([a-zA-Z0-9])$/,aT=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,lT={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 cT(e){return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(e)}function uT(e){return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(e)}var yo=(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=sT.exec(e))i.meta=!0,i.shift=/^[A-Z]$/.test(r[1]);else if(r=aT.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=lT[o],i.shift=cT(o)||i.shift,i.ctrl=uT(o)||i.ctrl}return i};yo.listen=(e={},t)=>{let{stdin:r}=e;if(!r||r!==process.stdin&&!r.isTTY)throw new Error("Invalid stream passed");let i=db.createInterface({terminal:!0,input:r});db.emitKeypressEvents(r,i);let n=new oT((a,l)=>t(a,yo(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()}};yo.action=(e,t,r)=>{let i={...iT,...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)};fb.exports=yo});var mb=w((CF,pb)=>{"use strict";pb.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}),dT(e,r,i)}};function dT(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 gb=w((OF,hb)=>{"use strict";var{define:fT,width:pT}=oe(),lc=class{constructor(t){let r=t.options;fT(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=pT(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"}};hb.exports=lc});var yb=w((EF,vb)=>{"use strict";var cc=oe(),re=ho(),uc={default:re.noop,noop:re.noop,set inverse(e){this._inverse=e},get inverse(){return this._inverse||cc.inverse(this.primary)},set complement(e){this._complement=e},get complement(){return this._complement||cc.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}};uc.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=cc.merge({},uc,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};vb.exports=uc});var wb=w((TF,bb)=>{"use strict";var dc=process.platform==="win32",Be=ho(),mT=oe(),fc={...Be.symbols,upDownDoubleArrow:"\u21D5",upDownDoubleArrow2:"\u2B0D",upDownArrow:"\u2195",asterisk:"*",asterism:"\u2042",bulletWhite:"\u25E6",electricArrow:"\u2301",ellipsisLarge:"\u22EF",ellipsisSmall:"\u2026",fullBlock:"\u2588",identicalTo:"\u2261",indicator:Be.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:Be.symbols.question,submitted:Be.symbols.check,cancelled:Be.symbols.cross},separator:{pending:Be.symbols.pointerSmall,submitted:Be.symbols.middot,cancelled:Be.symbols.middot},radio:{off:dc?"( )":"\u25EF",on:dc?"(*)":"\u25C9",disabled:dc?"(|)":"\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"]};fc.merge=e=>{let t=mT.merge({},Be.symbols,fc,e.symbols);return delete t.merge,t};bb.exports=fc});var xb=w((RF,$b)=>{"use strict";var hT=yb(),gT=wb(),vT=oe();$b.exports=e=>{e.options=vT.merge({},e.options.theme,e.options),e.symbols=gT.merge(e.options),e.styles=hT.merge(e.options)}});var Pb=w((kb,Ib)=>{"use strict";var Sb=process.env.TERM_PROGRAM==="Apple_Terminal",yT=nt(),pc=oe(),Ee=Ib.exports=kb,J="\x1B[",_b="\x07",mc=!1,it=Ee.code={bell:_b,beep:_b,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+(Sb?"8":"u"),savePosition:J+(Sb?"7":"s"),screen:`${J}2J`,show:`${J}?25h`,up:`${J}1J`},At=Ee.cursor={get hidden(){return mc},hide(){return mc=!0,it.hide},show(){return mc=!1,it.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?At.left(-e):e>0?At.right(e):"",r+=t<0?At.up(-t):t>0?At.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=pc.isPrimitive(i)?String(i):"",n=pc.isPrimitive(n)?String(n):"",a=pc.isPrimitive(a)?String(a):"",s){let l=Ee.cursor.up(s)+Ee.cursor.to(this.strLen(o)),c=n.length-r;return c>0&&(l+=Ee.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)),Ee.cursor.move(l)}}},hc=Ee.erase={screen:it.screen,up:it.up,down:it.down,line:it.line,lineEnd:it.lineEnd,lineStart:it.lineStart,lines(e){let t="";for(let r=0;r<e;r++)t+=Ee.erase.line+(r<e-1?Ee.cursor.up(1):"");return e&&(t+=Ee.code.beginning),t}};Ee.clear=(e="",t=process.stdout.columns)=>{if(!t)return hc.line+At.to(0);let r=o=>[...yT(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(hc.line+At.prevLine()).repeat(n-1)+hc.line+At.to(0)}});var dr=w((NF,Ob)=>{"use strict";var bT=Xe("events"),Cb=nt(),gc=ac(),wT=mb(),$T=gb(),xT=xb(),fe=oe(),zt=Pb(),vc=class e extends bT{constructor(t={}){super(),this.name=t.name,this.type=t.type,this.options=t,xT(this),wT(this),this.state=new $T(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=_T(this.options.margin),this.setMaxListeners(0),ST(this)}async keypress(t,r={}){this.keypressed=!0;let i=gc.action(t,gc(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(zt.code.beep)}cursorHide(){this.stdout.write(zt.cursor.hide());let t=fe.onExit(()=>this.cursorShow());this.on("close",()=>{this.cursorShow(),t()})}cursorShow(){this.stdout.write(zt.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(zt.cursor.down(t)+zt.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=zt.cursor.restore(c);u&&this.stdout.write(u)}sections(){let{buffer:t,input:r,prompt:i}=this.state;i=Cb(i);let n=Cb(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(zt.cursor.down(t.rest.length)),this.write(`
9
9
  `.repeat(r))}catch{}this.emit("close")}start(){!this.stop&&this.options.show!==!1&&(this.stop=gc.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,fe.isObject(t)&&(t=t[i.status]||t.pending),fe.hasColor(t)?t:(this.styles[i.status]||this.styles.pending)(t)}async message(){let t=await this.element("message");return fe.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 fe.isObject(o)&&(o=o[i.status]||o.pending),fe.hasColor(o)?o:this.styles.muted(o)}async pointer(t,r){let i=await this.element("pointer",t,r);if(typeof i=="string"&&fe.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=fe.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"&&fe.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 fe.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 fe.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 fe.resolve(this,t,...r)}get base(){return e.prototype}get style(){return this.styles[this.state.status]}get height(){return this.options.rows||fe.height(this.stdout,25)}get width(){return this.options.columns||fe.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 ST(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 _T(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}Ob.exports=vc});var Rb=w((UF,Tb)=>{"use strict";var kT=oe(),Eb={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 Eb.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}};Tb.exports=(e,t={})=>{let r=kT.merge({},Eb,t.roles);return r[e]||r.default}});var _n=w((LF,zb)=>{"use strict";var IT=nt(),PT=dr(),CT=Rb(),bo=oe(),{reorder:yc,scrollUp:OT,scrollDown:ET,isObject:Nb,swap:TT}=bo,bc=class extends PT{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");Nb(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=CT(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,bo.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,IT(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 Ab(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=yc(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=yc(this.choices),this.index=0,this.render()}end(){let t=this.choices.length-this.limit,r=yc(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=OT(this.choices),this.index=t,this.isDisabled()?this.up():this.render()}scrollDown(t=this.visible.length-1){return this.choices=ET(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){TT(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(Nb(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=bo.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 Ab(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 Ab(e,t){if(t instanceof Promise)return t;if(typeof t=="function"){if(bo.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}zb.exports=bc});var ot=w((MF,Db)=>{"use strict";var RT=_n(),wc=oe(),$c=class extends RT{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"&&!wc.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&&!wc.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?(wc.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}Ob.exports=vc});var Rb=w((AF,Tb)=>{"use strict";var kT=oe(),Eb={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 Eb.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}};Tb.exports=(e,t={})=>{let r=kT.merge({},Eb,t.roles);return r[e]||r.default}});var _n=w((zF,zb)=>{"use strict";var IT=nt(),PT=dr(),CT=Rb(),bo=oe(),{reorder:yc,scrollUp:OT,scrollDown:ET,isObject:Nb,swap:TT}=bo,bc=class extends PT{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");Nb(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=CT(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,bo.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,IT(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 Ab(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=yc(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=yc(this.choices),this.index=0,this.render()}end(){let t=this.choices.length-this.limit,r=yc(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=OT(this.choices),this.index=t,this.isDisabled()?this.up():this.render()}scrollDown(t=this.visible.length-1){return this.choices=ET(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){TT(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(Nb(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=bo.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 Ab(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 Ab(e,t){if(t instanceof Promise)return t;if(typeof t=="function"){if(bo.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}zb.exports=bc});var ot=w((DF,Db)=>{"use strict";var RT=_n(),wc=oe(),$c=class extends RT{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"&&!wc.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&&!wc.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?(wc.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()}};Db.exports=$c});var Ub=w((FF,jb)=>{"use strict";var NT=ot(),AT=(e,t)=>{let r=e?new RegExp(e,"ig"):/$^/;return i=>e?i.replace(r,n=>t(n)):i},xc=class extends NT{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=AT(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()}};jb.exports=xc});var _c=w((qF,Lb)=>{"use strict";var Sc=oe();Lb.exports=(e,t={})=>{e.cursorHide();let{input:r="",initial:i="",pos:n,showCursor:o=!0,color:s}=t,a=s||e.styles.placeholder,l=Sc.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=Sc.isPrimitive(i)?`${i}`:"",r=Sc.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 wo=w((ZF,Mb)=>{"use strict";var zT=nt(),DT=ot(),jT=_c(),kc=class extends DT{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,_=l?"success":"dark";await v.call(t,$,this.state)!==!0&&(_="danger");let x=n[_],C=x(await this.indicator(t,r))+(t.pad||""),E=this.indent(t),R=()=>[E,C,b+h,l].filter(Boolean).join(" ");if(i.submitted)return b=zT(b),l=u(l),R();if(t.format)l=await t.format.call(this,l,t,r);else{let L=this.styles.muted;l=jT(this,{input:l,initial:s,pos:o,showCursor:m,color:L})}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())),R()}async submit(){return this.value=this.values,super.base.submit.call(this)}};Mb.exports=kc});var Ic=w((BF,qb)=>{"use strict";var UT=wo(),LT=()=>{throw new Error("expected prompt to have a custom authenticate method")},Fb=(e=LT)=>{class t extends UT{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 Fb(i)}}return t};qb.exports=Fb()});var Vb=w((VF,Bb)=>{"use strict";var MT=Ic();function FT(e,t){return e.username===this.options.username&&e.password===this.options.password}var Zb=(e=FT)=>{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 MT.create(e){constructor(n){super({...n,choices:t})}static create(n){return Zb(n)}}return r};Bb.exports=Zb()});var $o=w((KF,Kb)=>{"use strict";var qT=dr(),{isPrimitive:ZT,hasColor:BT}=oe(),Pc=class extends qT{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 ZT(t)&&(this.isTrue(t)||this.isFalse(t))}async hint(){if(this.state.status==="pending"){let t=await this.element("hint");return BT(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)}};Kb.exports=Pc});var Jb=w((GF,Gb)=>{"use strict";var VT=$o(),Cc=class extends VT{constructor(t){super(t),this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}};Gb.exports=Cc});var Hb=w((JF,Wb)=>{"use strict";var KT=ot(),GT=wo(),fr=GT.prototype,Oc=class extends KT{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]():fr.dispatch.call(this,t,r)}append(t,r){return fr.append.call(this,t,r)}delete(t,r){return fr.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?fr.next.call(this):super.next()}prev(){return this.focused.editable?fr.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?fr.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)}};Wb.exports=Oc});var Dt=w((WF,Yb)=>{"use strict";var JT=dr(),WT=ac(),HT=_c(),{isPrimitive:YT}=oe(),Ec=class extends JT{constructor(t){super(t),this.initial=YT(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?WT(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()}};Db.exports=$c});var Ub=w((jF,jb)=>{"use strict";var NT=ot(),AT=(e,t)=>{let r=e?new RegExp(e,"ig"):/$^/;return i=>e?i.replace(r,n=>t(n)):i},xc=class extends NT{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=AT(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()}};jb.exports=xc});var _c=w((UF,Lb)=>{"use strict";var Sc=oe();Lb.exports=(e,t={})=>{e.cursorHide();let{input:r="",initial:i="",pos:n,showCursor:o=!0,color:s}=t,a=s||e.styles.placeholder,l=Sc.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=Sc.isPrimitive(i)?`${i}`:"",r=Sc.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 wo=w((LF,Mb)=>{"use strict";var zT=nt(),DT=ot(),jT=_c(),kc=class extends DT{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,_=l?"success":"dark";await v.call(t,$,this.state)!==!0&&(_="danger");let x=n[_],C=x(await this.indicator(t,r))+(t.pad||""),E=this.indent(t),R=()=>[E,C,b+h,l].filter(Boolean).join(" ");if(i.submitted)return b=zT(b),l=u(l),R();if(t.format)l=await t.format.call(this,l,t,r);else{let L=this.styles.muted;l=jT(this,{input:l,initial:s,pos:o,showCursor:m,color:L})}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())),R()}async submit(){return this.value=this.values,super.base.submit.call(this)}};Mb.exports=kc});var Ic=w((MF,qb)=>{"use strict";var UT=wo(),LT=()=>{throw new Error("expected prompt to have a custom authenticate method")},Fb=(e=LT)=>{class t extends UT{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 Fb(i)}}return t};qb.exports=Fb()});var Vb=w((FF,Bb)=>{"use strict";var MT=Ic();function FT(e,t){return e.username===this.options.username&&e.password===this.options.password}var Zb=(e=FT)=>{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 MT.create(e){constructor(n){super({...n,choices:t})}static create(n){return Zb(n)}}return r};Bb.exports=Zb()});var $o=w((qF,Kb)=>{"use strict";var qT=dr(),{isPrimitive:ZT,hasColor:BT}=oe(),Pc=class extends qT{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 ZT(t)&&(this.isTrue(t)||this.isFalse(t))}async hint(){if(this.state.status==="pending"){let t=await this.element("hint");return BT(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)}};Kb.exports=Pc});var Jb=w((ZF,Gb)=>{"use strict";var VT=$o(),Cc=class extends VT{constructor(t){super(t),this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}};Gb.exports=Cc});var Hb=w((BF,Wb)=>{"use strict";var KT=ot(),GT=wo(),fr=GT.prototype,Oc=class extends KT{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]():fr.dispatch.call(this,t,r)}append(t,r){return fr.append.call(this,t,r)}delete(t,r){return fr.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?fr.next.call(this):super.next()}prev(){return this.focused.editable?fr.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?fr.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)}};Wb.exports=Oc});var Dt=w((VF,Yb)=>{"use strict";var JT=dr(),WT=ac(),HT=_c(),{isPrimitive:YT}=oe(),Ec=class extends JT{constructor(t){super(t),this.initial=YT(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?WT(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):HT(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()}};Yb.exports=Ec});var Qb=w((HF,Xb)=>{"use strict";var XT=e=>e.filter((t,r)=>e.lastIndexOf(t)===r),xo=e=>XT(e).filter(Boolean);Xb.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:xo([r,...o]),present:s};case"next":case"redo":return o=i.slice(1),s=i[0]||"",{past:xo([...o,r]),present:s};case"save":return{past:xo([...i,r]),present:""};case"remove":return s=xo(i.filter(a=>a!==r)),n="",s.length&&(n=s.pop()),{past:s,present:n};default:throw new Error(`Invalid action: "${e}"`)}}});var Rc=w((YF,tw)=>{"use strict";var QT=Dt(),ew=Qb(),Tc=class extends QT{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=ew(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=ew("save",this.data,this.input),this.store.set("values",this.data))}submit(){return this.store&&this.autosave===!0&&this.save(),super.submit()}};tw.exports=Tc});var nw=w((XF,rw)=>{"use strict";var eR=Dt(),Nc=class extends eR{format(){return""}};rw.exports=Nc});var ow=w((QF,iw)=>{"use strict";var tR=Dt(),Ac=class extends tR{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()}};iw.exports=Ac});var aw=w((eq,sw)=>{"use strict";var rR=ot(),zc=class extends rR{constructor(t){super({...t,multiple:!0})}};sw.exports=zc});var jc=w((tq,lw)=>{"use strict";var nR=Dt(),Dc=class extends nR{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()}};lw.exports=Dc});var uw=w((rq,cw)=>{cw.exports=jc()});var fw=w((nq,dw)=>{"use strict";var iR=Dt(),Uc=class extends iR{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)):""}};dw.exports=Uc});var hw=w((iq,mw)=>{"use strict";var oR=nt(),sR=_n(),pw=oe(),Lc=class extends sR{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()}};Yb.exports=Ec});var Qb=w((KF,Xb)=>{"use strict";var XT=e=>e.filter((t,r)=>e.lastIndexOf(t)===r),xo=e=>XT(e).filter(Boolean);Xb.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:xo([r,...o]),present:s};case"next":case"redo":return o=i.slice(1),s=i[0]||"",{past:xo([...o,r]),present:s};case"save":return{past:xo([...i,r]),present:""};case"remove":return s=xo(i.filter(a=>a!==r)),n="",s.length&&(n=s.pop()),{past:s,present:n};default:throw new Error(`Invalid action: "${e}"`)}}});var Rc=w((GF,tw)=>{"use strict";var QT=Dt(),ew=Qb(),Tc=class extends QT{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=ew(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=ew("save",this.data,this.input),this.store.set("values",this.data))}submit(){return this.store&&this.autosave===!0&&this.save(),super.submit()}};tw.exports=Tc});var nw=w((JF,rw)=>{"use strict";var eR=Dt(),Nc=class extends eR{format(){return""}};rw.exports=Nc});var ow=w((WF,iw)=>{"use strict";var tR=Dt(),Ac=class extends tR{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()}};iw.exports=Ac});var aw=w((HF,sw)=>{"use strict";var rR=ot(),zc=class extends rR{constructor(t){super({...t,multiple:!0})}};sw.exports=zc});var jc=w((YF,lw)=>{"use strict";var nR=Dt(),Dc=class extends nR{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()}};lw.exports=Dc});var uw=w((XF,cw)=>{cw.exports=jc()});var fw=w((QF,dw)=>{"use strict";var iR=Dt(),Uc=class extends iR{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)):""}};dw.exports=Uc});var hw=w((eq,mw)=>{"use strict";var oR=nt(),sR=_n(),pw=oe(),Lc=class extends sR{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&&!pw.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=oR(u).length,this.widths[0]=Math.min(this.widths[0],this.width-this.scaleLength-d.length);let m=pw.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)}};mw.exports=Lc});var yw=w((oq,vw)=>{"use strict";var gw=nt(),aR=(e="")=>typeof e=="string"?e.replace(/^['"]|['"]$/g,""):"",Fc=class{constructor(t){this.name=t.key,this.field=t.field||{},this.value=aR(t.initial||this.field.initial||""),this.message=t.message||this.name,this.cursor=0,this.input="",this.lines=[]}},lR=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)}};mw.exports=Lc});var yw=w((tq,vw)=>{"use strict";var gw=nt(),aR=(e="")=>typeof e=="string"?e.replace(/^['"]|['"]$/g,""):"",Fc=class{constructor(t){this.name=t.key,this.field=t.field||{},this.value=aR(t.initial||this.field.initial||""),this.message=t.message||this.name,this.cursor=0,this.input="",this.lines=[]}},lR=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},_;for(;_=d();){if(_==="}"){f()==="}"&&(_+=d()),$.value+=_,$.close=_;break}_===":"?($.initial="",$.key=$.inner):$.initial!==void 0&&($.initial+=_),$.value+=_,$.inner+=_}$.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(C=>C.name===$.key);$.field=n.find(C=>C.name===$.key),x||(x=new Fc($),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}};vw.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 lR(t,i),a=Mc("result",e,t),l=Mc("format",e,t),c=Mc("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(_,x,C,E)=>{let R=await c(_,x,C,E);return R===!1?"Invalid field "+C.name:R};for(let _ of n){let x=_.value,C=_.key;if(_.type!=="template"){x&&(d.output+=x);continue}if(_.type==="template"){let E=o.find(ae=>ae.name===C);t.required===!0&&d.required.add(E.name);let R=[E.input,d.values[E.value],E.value,x].find(u),T=(E.field||{}).message||_.inner;if(f){let ae=await v(d.values[C],d,E,m);if(ae&&typeof ae=="string"||ae===!1){d.invalid.set(C,ae);continue}d.invalid.delete(C);let Ye=await a(d.values[C],d,E,m);d.output+=gw(Ye);continue}E.placeholder=!1;let H=x;x=await l(x,d,E,m),R!==x?(d.values[C]=R,x=e.styles.typing(R),d.missing.delete(T)):(d.values[C]=void 0,R=`<${T}>`,x=e.styles.primary(R),E.placeholder=!0,d.required.has(C)&&d.missing.add(T)),d.missing.has(T)&&d.validating&&(x=e.styles.warning(R)),d.invalid.has(C)&&d.validating&&(x=e.styles.danger(R)),m===d.index&&(H!==x?x=e.styles.underline(x):x=e.styles.heading(gw(x))),m++}x&&(d.output+=x)}let h=d.output.split(`
24
24
  `).map(_=>" "+_),b=o.length,$=0;for(let _ of o)d.invalid.has(_.name)&&_.lines.forEach(x=>{h[x][0]===" "&&(h[x]=d.styles.danger(d.symbols.bullet)+h[x].slice(1))}),e.isValue(d.values[_.name])&&$++;return d.completed=($/b*100).toFixed(0),d.output=h.join(`
25
- `),d.output}};function Mc(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 ww=w((sq,bw)=>{"use strict";var cR=nt(),uR=yw(),dR=dr(),qc=class extends dR{constructor(t){super(t),this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await uR(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 Mc(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 ww=w((rq,bw)=>{"use strict";var cR=nt(),uR=yw(),dR=dr(),qc=class extends dR{constructor(t){super(t),this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await uR(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(_=>_!=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=cR(i).split(`
28
28
  `).map(a=>a.slice(1)).join(`
29
- `);return this.value={values:n,result:s},super.submit()}};bw.exports=qc});var xw=w((aq,$w)=>{"use strict";var fR="(Use <shift>+<up/down> to sort)",pR=ot(),Zc=class extends pR{constructor(t){super({...t,reorder:!1,sort:!0,multiple:!0}),this.state.hint=[this.options.hint,fR].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()}};$w.exports=Zc});var _w=w((lq,Sw)=>{"use strict";var mR=_n(),Bc=class extends mR{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()}};bw.exports=qc});var xw=w((nq,$w)=>{"use strict";var fR="(Use <shift>+<up/down> to sort)",pR=ot(),Zc=class extends pR{constructor(t){super({...t,reorder:!1,sort:!0,multiple:!0}),this.state.hint=[this.options.hint,fR].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()}};$w.exports=Zc});var _w=w((iq,Sw)=>{"use strict";var mR=_n(),Bc=class extends mR{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=hR(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,C)=>c(C===t.scaleIdx)).join(a),h=x=>x===t.scaleIdx?d(x):x,b=m+t.scale.map((x,C)=>h(C)).join(l),$=()=>[u,f].filter(Boolean).join(" "),_=()=>[$(),v,b," "].filter(Boolean).join(`
31
31
  `);return i&&(v=this.styles.cyan(v),b=this.styles.cyan(b)),_()}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 hR(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}Sw.exports=Bc});var Iw=w((cq,kw)=>{kw.exports=Rc()});var Cw=w((uq,Pw)=>{"use strict";var gR=$o(),Vc=class extends gR{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()}};Pw.exports=Vc});var Ew=w((dq,Ow)=>{"use strict";var vR=ot(),Kc=class extends vR{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)}}};Ow.exports=Kc});var Rw=w(Gc=>{"use strict";var Tw=oe(),Q=(e,t)=>{Tw.defineExport(Gc,e,t),Tw.defineExport(Gc,e.toLowerCase(),t)};Q("AutoComplete",()=>Ub());Q("BasicAuth",()=>Vb());Q("Confirm",()=>Jb());Q("Editable",()=>Hb());Q("Form",()=>wo());Q("Input",()=>Rc());Q("Invisible",()=>nw());Q("List",()=>ow());Q("MultiSelect",()=>aw());Q("Numeral",()=>uw());Q("Password",()=>fw());Q("Scale",()=>hw());Q("Select",()=>ot());Q("Snippet",()=>ww());Q("Sort",()=>xw());Q("Survey",()=>_w());Q("Text",()=>Iw());Q("Toggle",()=>Cw());Q("Quiz",()=>Ew())});var Aw=w((pq,Nw)=>{Nw.exports={ArrayPrompt:_n(),AuthPrompt:Ic(),BooleanPrompt:$o(),NumberPrompt:jc(),StringPrompt:Dt()}});var jw=w((mq,Dw)=>{"use strict";var zw=Xe("assert"),Wc=Xe("events"),st=oe(),Te=class extends Wc{constructor(t,r){super(),this.options=st.merge({},t),this.answers={...r}}register(t,r){if(st.isObject(t)){for(let n of Object.keys(t))this.register(n,t[n]);return this}zw.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(st.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=st.merge({},this.options,t),{type:i,name:n}=t,{set:o,get:s}=st;if(typeof i=="function"&&(i=await i.call(this,t,this.answers)),!i)return this.answers[n];i==="number"&&(i="numeral"),zw(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||dr()}static get prompts(){return Rw()}static get types(){return Aw()}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 st.mixinEmitter(t,new Wc),t}};st.mixinEmitter(Te,new Wc);var Jc=Te.prompts;for(let e of Object.keys(Jc)){let t=e.toLowerCase(),r=i=>new Jc[e](i).run();Te.prompt[t]=r,Te[t]=r,Te[e]||Reflect.defineProperty(Te,e,{get:()=>Jc[e]})}var kn=e=>{st.defineExport(Te,e,()=>Te.types[e])};kn("ArrayPrompt");kn("AuthPrompt");kn("BooleanPrompt");kn("NumberPrompt");kn("StringPrompt");Dw.exports=Te});var U=w(ne=>{"use strict";var Hc=Symbol.for("yaml.alias"),Bw=Symbol.for("yaml.document"),So=Symbol.for("yaml.map"),Vw=Symbol.for("yaml.pair"),Yc=Symbol.for("yaml.scalar"),_o=Symbol.for("yaml.seq"),Ve=Symbol.for("yaml.node.type"),$R=e=>!!e&&typeof e=="object"&&e[Ve]===Hc,xR=e=>!!e&&typeof e=="object"&&e[Ve]===Bw,SR=e=>!!e&&typeof e=="object"&&e[Ve]===So,_R=e=>!!e&&typeof e=="object"&&e[Ve]===Vw,Kw=e=>!!e&&typeof e=="object"&&e[Ve]===Yc,kR=e=>!!e&&typeof e=="object"&&e[Ve]===_o;function Gw(e){if(e&&typeof e=="object")switch(e[Ve]){case So:case _o:return!0}return!1}function IR(e){if(e&&typeof e=="object")switch(e[Ve]){case Hc:case So:case Yc:case _o:return!0}return!1}var PR=e=>(Kw(e)||Gw(e))&&!!e.anchor;ne.ALIAS=Hc;ne.DOC=Bw;ne.MAP=So;ne.NODE_TYPE=Ve;ne.PAIR=Vw;ne.SCALAR=Yc;ne.SEQ=_o;ne.hasAnchor=PR;ne.isAlias=$R;ne.isCollection=Gw;ne.isDocument=xR;ne.isMap=SR;ne.isNode=IR;ne.isPair=_R;ne.isScalar=Kw;ne.isSeq=kR});var In=w(Xc=>{"use strict";var ee=U(),me=Symbol("break visit"),Jw=Symbol("skip children"),Ue=Symbol("remove node");function ko(e,t){let r=Ww(t);ee.isDocument(e)?mr(null,e.contents,r,Object.freeze([e]))===Ue&&(e.contents=null):mr(null,e,r,Object.freeze([]))}ko.BREAK=me;ko.SKIP=Jw;ko.REMOVE=Ue;function mr(e,t,r,i){let n=Hw(e,t,r,i);if(ee.isNode(n)||ee.isPair(n))return Yw(e,i,n),mr(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=mr(o,t.items[o],r,i);if(typeof s=="number")o=s-1;else{if(s===me)return me;s===Ue&&(t.items.splice(o,1),o-=1)}}}else if(ee.isPair(t)){i=Object.freeze(i.concat(t));let o=mr("key",t.key,r,i);if(o===me)return me;o===Ue&&(t.key=null);let s=mr("value",t.value,r,i);if(s===me)return me;s===Ue&&(t.value=null)}}return n}async function Io(e,t){let r=Ww(t);ee.isDocument(e)?await hr(null,e.contents,r,Object.freeze([e]))===Ue&&(e.contents=null):await hr(null,e,r,Object.freeze([]))}Io.BREAK=me;Io.SKIP=Jw;Io.REMOVE=Ue;async function hr(e,t,r,i){let n=await Hw(e,t,r,i);if(ee.isNode(n)||ee.isPair(n))return Yw(e,i,n),hr(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 hr(o,t.items[o],r,i);if(typeof s=="number")o=s-1;else{if(s===me)return me;s===Ue&&(t.items.splice(o,1),o-=1)}}}else if(ee.isPair(t)){i=Object.freeze(i.concat(t));let o=await hr("key",t.key,r,i);if(o===me)return me;o===Ue&&(t.key=null);let s=await hr("value",t.value,r,i);if(s===me)return me;s===Ue&&(t.value=null)}}return n}function Ww(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 Hw(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 Yw(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`)}}Xc.visit=ko;Xc.visitAsync=Io});var Qc=w(Qw=>{"use strict";var Xw=U(),CR=In(),OR={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},ER=e=>e.replace(/[!,[\]{}]/g,t=>OR[t]),Pn=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+ER(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&&Xw.isNode(t.contents)){let o={};CR.visit(t.contents,(s,a)=>{Xw.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 hR(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}Sw.exports=Bc});var Iw=w((oq,kw)=>{kw.exports=Rc()});var Cw=w((sq,Pw)=>{"use strict";var gR=$o(),Vc=class extends gR{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()}};Pw.exports=Vc});var Ew=w((aq,Ow)=>{"use strict";var vR=ot(),Kc=class extends vR{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)}}};Ow.exports=Kc});var Rw=w(Gc=>{"use strict";var Tw=oe(),Q=(e,t)=>{Tw.defineExport(Gc,e,t),Tw.defineExport(Gc,e.toLowerCase(),t)};Q("AutoComplete",()=>Ub());Q("BasicAuth",()=>Vb());Q("Confirm",()=>Jb());Q("Editable",()=>Hb());Q("Form",()=>wo());Q("Input",()=>Rc());Q("Invisible",()=>nw());Q("List",()=>ow());Q("MultiSelect",()=>aw());Q("Numeral",()=>uw());Q("Password",()=>fw());Q("Scale",()=>hw());Q("Select",()=>ot());Q("Snippet",()=>ww());Q("Sort",()=>xw());Q("Survey",()=>_w());Q("Text",()=>Iw());Q("Toggle",()=>Cw());Q("Quiz",()=>Ew())});var Aw=w((cq,Nw)=>{Nw.exports={ArrayPrompt:_n(),AuthPrompt:Ic(),BooleanPrompt:$o(),NumberPrompt:jc(),StringPrompt:Dt()}});var jw=w((uq,Dw)=>{"use strict";var zw=Xe("assert"),Wc=Xe("events"),st=oe(),Te=class extends Wc{constructor(t,r){super(),this.options=st.merge({},t),this.answers={...r}}register(t,r){if(st.isObject(t)){for(let n of Object.keys(t))this.register(n,t[n]);return this}zw.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(st.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=st.merge({},this.options,t),{type:i,name:n}=t,{set:o,get:s}=st;if(typeof i=="function"&&(i=await i.call(this,t,this.answers)),!i)return this.answers[n];i==="number"&&(i="numeral"),zw(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||dr()}static get prompts(){return Rw()}static get types(){return Aw()}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 st.mixinEmitter(t,new Wc),t}};st.mixinEmitter(Te,new Wc);var Jc=Te.prompts;for(let e of Object.keys(Jc)){let t=e.toLowerCase(),r=i=>new Jc[e](i).run();Te.prompt[t]=r,Te[t]=r,Te[e]||Reflect.defineProperty(Te,e,{get:()=>Jc[e]})}var kn=e=>{st.defineExport(Te,e,()=>Te.types[e])};kn("ArrayPrompt");kn("AuthPrompt");kn("BooleanPrompt");kn("NumberPrompt");kn("StringPrompt");Dw.exports=Te});var U=w(ne=>{"use strict";var Hc=Symbol.for("yaml.alias"),Bw=Symbol.for("yaml.document"),So=Symbol.for("yaml.map"),Vw=Symbol.for("yaml.pair"),Yc=Symbol.for("yaml.scalar"),_o=Symbol.for("yaml.seq"),Ve=Symbol.for("yaml.node.type"),$R=e=>!!e&&typeof e=="object"&&e[Ve]===Hc,xR=e=>!!e&&typeof e=="object"&&e[Ve]===Bw,SR=e=>!!e&&typeof e=="object"&&e[Ve]===So,_R=e=>!!e&&typeof e=="object"&&e[Ve]===Vw,Kw=e=>!!e&&typeof e=="object"&&e[Ve]===Yc,kR=e=>!!e&&typeof e=="object"&&e[Ve]===_o;function Gw(e){if(e&&typeof e=="object")switch(e[Ve]){case So:case _o:return!0}return!1}function IR(e){if(e&&typeof e=="object")switch(e[Ve]){case Hc:case So:case Yc:case _o:return!0}return!1}var PR=e=>(Kw(e)||Gw(e))&&!!e.anchor;ne.ALIAS=Hc;ne.DOC=Bw;ne.MAP=So;ne.NODE_TYPE=Ve;ne.PAIR=Vw;ne.SCALAR=Yc;ne.SEQ=_o;ne.hasAnchor=PR;ne.isAlias=$R;ne.isCollection=Gw;ne.isDocument=xR;ne.isMap=SR;ne.isNode=IR;ne.isPair=_R;ne.isScalar=Kw;ne.isSeq=kR});var In=w(Xc=>{"use strict";var ee=U(),me=Symbol("break visit"),Jw=Symbol("skip children"),Ue=Symbol("remove node");function ko(e,t){let r=Ww(t);ee.isDocument(e)?mr(null,e.contents,r,Object.freeze([e]))===Ue&&(e.contents=null):mr(null,e,r,Object.freeze([]))}ko.BREAK=me;ko.SKIP=Jw;ko.REMOVE=Ue;function mr(e,t,r,i){let n=Hw(e,t,r,i);if(ee.isNode(n)||ee.isPair(n))return Yw(e,i,n),mr(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=mr(o,t.items[o],r,i);if(typeof s=="number")o=s-1;else{if(s===me)return me;s===Ue&&(t.items.splice(o,1),o-=1)}}}else if(ee.isPair(t)){i=Object.freeze(i.concat(t));let o=mr("key",t.key,r,i);if(o===me)return me;o===Ue&&(t.key=null);let s=mr("value",t.value,r,i);if(s===me)return me;s===Ue&&(t.value=null)}}return n}async function Io(e,t){let r=Ww(t);ee.isDocument(e)?await hr(null,e.contents,r,Object.freeze([e]))===Ue&&(e.contents=null):await hr(null,e,r,Object.freeze([]))}Io.BREAK=me;Io.SKIP=Jw;Io.REMOVE=Ue;async function hr(e,t,r,i){let n=await Hw(e,t,r,i);if(ee.isNode(n)||ee.isPair(n))return Yw(e,i,n),hr(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 hr(o,t.items[o],r,i);if(typeof s=="number")o=s-1;else{if(s===me)return me;s===Ue&&(t.items.splice(o,1),o-=1)}}}else if(ee.isPair(t)){i=Object.freeze(i.concat(t));let o=await hr("key",t.key,r,i);if(o===me)return me;o===Ue&&(t.key=null);let s=await hr("value",t.value,r,i);if(s===me)return me;s===Ue&&(t.value=null)}}return n}function Ww(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 Hw(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 Yw(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`)}}Xc.visit=ko;Xc.visitAsync=Io});var Qc=w(Qw=>{"use strict";var Xw=U(),CR=In(),OR={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},ER=e=>e.replace(/[!,[\]{}]/g,t=>OR[t]),Pn=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+ER(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&&Xw.isNode(t.contents)){let o={};CR.visit(t.contents,(s,a)=>{Xw.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
  `)}};Pn.defaultYaml={explicit:!1,version:"1.2"};Pn.defaultTags={"!!":"tag:yaml.org,2002:"};Qw.Directives=Pn});var Po=w(Cn=>{"use strict";var e$=U(),TR=In();function RR(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 t$(e){let t=new Set;return TR.visit(e,{Value(r,i){i.anchor&&t.add(i.anchor)}}),t}function r$(e,t){for(let r=1;;++r){let i=`${e}${r}`;if(!t.has(i))return i}}function NR(e,t){let r=[],i=new Map,n=null;return{onAnchor:o=>{r.push(o),n??(n=t$(e));let s=r$(t,n);return n.add(s),s},setAnchors:()=>{for(let o of r){let s=i.get(o);if(typeof s=="object"&&s.anchor&&(e$.isScalar(s.node)||e$.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}}Cn.anchorIsValid=RR;Cn.anchorNames=t$;Cn.createNodeAnchors=NR;Cn.findNewAnchor=r$});var eu=w(n$=>{"use strict";function On(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=On(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=On(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=On(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=On(e,i,n,o);s===void 0?delete i[n]:s!==o&&(i[n]=s)}return e.call(t,r,i)}n$.applyReviver=On});var at=w(o$=>{"use strict";var AR=U();function i$(e,t,r){if(Array.isArray(e))return e.map((i,n)=>i$(i,String(n),r));if(e&&typeof e.toJSON=="function"){if(!r||!AR.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}o$.toJS=i$});var Co=w(a$=>{"use strict";var zR=eu(),s$=U(),DR=at(),tu=class{constructor(t){Object.defineProperty(this,s$.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(!s$.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=DR.toJS(this,"",s);if(typeof n=="function")for(let{count:l,res:c}of s.anchors.values())n(c,l);return typeof o=="function"?zR.applyReviver(o,{"":a},"",a):a}};a$.NodeBase=tu});var En=w(l$=>{"use strict";var jR=Po(),UR=In(),gr=U(),LR=Co(),MR=at(),ru=class extends LR.NodeBase{constructor(t){super(gr.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=[],UR.visit(t,{Node:(o,s)=>{(gr.isAlias(s)||gr.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||(MR.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=Oo(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(jR.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 Oo(e,t,r){if(gr.isAlias(t)){let i=t.resolve(e),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(gr.isCollection(t)){let i=0;for(let n of t.items){let o=Oo(e,n,r);o>i&&(i=o)}return i}else if(gr.isPair(t)){let i=Oo(e,t.key,r),n=Oo(e,t.value,r);return Math.max(i,n)}return 1}l$.Alias=ru});var Y=w(nu=>{"use strict";var FR=U(),qR=Co(),ZR=at(),BR=e=>!e||typeof e!="function"&&typeof e!="object",lt=class extends qR.NodeBase{constructor(t){super(FR.SCALAR),this.value=t}toJSON(t,r){return r?.keep?this.value:ZR.toJS(this.value,t,r)}toString(){return String(this.value)}};lt.BLOCK_FOLDED="BLOCK_FOLDED";lt.BLOCK_LITERAL="BLOCK_LITERAL";lt.PLAIN="PLAIN";lt.QUOTE_DOUBLE="QUOTE_DOUBLE";lt.QUOTE_SINGLE="QUOTE_SINGLE";nu.Scalar=lt;nu.isScalarValue=BR});var Tn=w(u$=>{"use strict";var VR=En(),jt=U(),c$=Y(),KR="tag:yaml.org,2002:";function GR(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 JR(e,t,r){if(jt.isDocument(e)&&(e=e.contents),jt.isNode(e))return e;if(jt.isPair(e)){let d=r.schema[jt.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 VR.Alias(l.anchor);l={anchor:null,node:null},a.set(e,l)}t?.startsWith("!!")&&(t=KR+t.slice(2));let c=GR(e,t,s.tags);if(!c){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let d=new c$.Scalar(e);return l&&(l.node=d),d}c=e instanceof Map?s[jt.MAP]:Symbol.iterator in Object(e)?s[jt.SEQ]:s[jt.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 c$.Scalar(e);return t?u.tag=t:c.default||(u.tag=c.tag),l&&(l.node=u),u}u$.createNode=JR});var To=w(Eo=>{"use strict";var WR=Tn(),Le=U(),HR=Co();function iu(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 WR.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 d$=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,ou=class extends HR.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=>Le.isNode(i)||Le.isPair(i)?i.clone(t):i),this.range&&(r.range=this.range.slice()),r}addIn(t,r){if(d$(t))this.add(r);else{let[i,...n]=t,o=this.get(i,!0);if(Le.isCollection(o))o.addIn(n,r);else if(o===void 0&&this.schema)this.set(i,iu(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(Le.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&&Le.isScalar(o)?o.value:o:Le.isCollection(o)?o.getIn(n,r):void 0}hasAllNullValues(t){return this.items.every(r=>{if(!Le.isPair(r))return!1;let i=r.value;return i==null||t&&Le.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 Le.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(Le.isCollection(o))o.setIn(n,r);else if(o===void 0&&this.schema)this.set(i,iu(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};Eo.Collection=ou;Eo.collectionFromPath=iu;Eo.isEmptyPath=d$});var Rn=w(Ro=>{"use strict";var YR=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function su(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var XR=(e,t,r)=>e.endsWith(`
36
36
  `)?su(r,t):r.includes(`
37
37
  `)?`
@@ -174,19 +174,19 @@ ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.pus
174
174
  `)}var _P={"out-of-diff":"its line falls outside the PR diff",unlocated:"it has no parseable file:line"};function tv(e){return`- **${e.severity??"finding"}: ${e.title}**`}function kP(e){let t=e.location.trim();return!t||t.toLowerCase()==="n/a"?"no location":`\`${t}\``}function IP(e){let t=[`${tv(e)} \u2014 ${kP(e)}`,` - Not anchored: ${_P[e.reason]}`];return e.impact&&t.push(` - Impact: ${e.impact}`),e.recommendation&&t.push(` - Recommendation: ${e.recommendation}`),t}function Qe(e,t=[]){let r=Qg(e),i=Li(e),n=["## Code review summary","",ev(r)];if(i.length>0){n.push("","### Findings","");for(let s of i)n.push(tv(s))}let o=Xt(t);if(o.length>0){n.push("","### Findings not anchored to the diff","","No line comment could be attached to these, so the detail is here instead.","");for(let s of o)n.push(...IP(s))}return n.join(`
175
175
  `)}function rv(e){return Number.isInteger(e)&&e>=1}function PP(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(!rv(r)||!rv(i)||i<r)return null;let n={...e,file:t[1],line:i};return r===i?n:{...n,startLine:r}}function nv(e){let t=[],r=[],i=[];for(let n of e){if(n.source==="already-raised"){i.push(n);continue}let o=PP(n);o?t.push(o):r.push(n)}return{lineBound:t,unlocated:r,alreadyRaised:i}}var CP=/^\+\+\+ (?:b\/)?(.+)$/,OP=/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function iv(e){let t=new Map,r=null,i=0;for(let n of e.split(`
176
176
  `)){let o=n.match(CP);if(o){r=o[1]==="/dev/null"?null:o[1];continue}let s=n.match(OP);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}import{execSync as Cl}from"node:child_process";import{execSync as Pl}from"node:child_process";import{execSync as Il}from"node:child_process";var EP=/(?:git@github\.com:|https:\/\/github\.com\/)([^/]+)\/([^/]+?)(?:\.git)?\/?$/;function ov(e){let t=e.match(EP);return t?{org:t[1],repo:t[2]}:null}function TP(e,t){try{return Il(`git remote get-url ${e}`,{encoding:"utf8",stdio:["pipe","pipe","pipe"],windowsHide:!0,cwd:t}).trim()}catch{return null}}function RP(e){try{let t=Il("git rev-parse --abbrev-ref --symbolic-full-name @{u}",{encoding:"utf8",stdio:["pipe","pipe","pipe"],windowsHide:!0,cwd:e}).trim(),[r]=t.split("/",1);return r||null}catch{return null}}function NP(e){try{return Il("git remote",{encoding:"utf8",stdio:["pipe","pipe","pipe"],windowsHide:!0,cwd:e}).trim().split(`
177
- `).filter(Boolean)}catch{return[]}}function sv(e){let t=[],r=RP(e);r&&t.push(r),t.includes("origin")||t.push("origin");for(let i of NP(e))i!=="upstream"&&!t.includes(i)&&t.push(i);for(let i of t){let n=TP(i,e);if(!n)continue;let o=ov(n);if(o)return o}return null}function Mi(e){if(e instanceof Error){let t=e.message.toLowerCase();return t.includes("enoent")||t.includes("command not found")}return!1}function et(){let e=sv();if(e)return e;let t=JSON.parse(Pl("gh repo view --json owner,name",{encoding:"utf8"}));return{org:t.owner.login,repo:t.name}}function AP(){return Pl("git rev-parse --abbrev-ref HEAD",{encoding:"utf8"}).trim()}function av(e){let{org:t,repo:r}=et();return JSON.parse(Pl(`gh pr view ${Xg(AP)} --json ${e} -R ${t}/${r}`,{encoding:"utf8"}))}function Fi(){try{return av("id").id}catch(e){throw e instanceof Error&&e.message.includes("no pull requests")&&(console.error("Error: No pull request found for the current branch."),process.exit(1)),e}}function qi(){try{return av("number").number}catch(e){if(e instanceof Error&&e.message.includes("no pull requests"))return null;throw e}}function Zi(e,t,r){let{org:i,repo:n}=et();try{return Cl(`gh pr diff ${e} -R ${i}/${n}`,{encoding:"utf8",maxBuffer:256*1024*1024,stdio:["ignore","pipe","pipe"]})}catch(o){if(!zP(o))throw o;return DP(t,r)}}function zP(e){return e instanceof Error&&(e.message.includes("too_large")||e.message.includes("maximum number of files"))}function DP(e,t){try{Cl(`git fetch origin ${e} ${t}`,{stdio:"ignore"})}catch{}return Cl(`git diff ${e}...${t}`,{encoding:"utf8",maxBuffer:256*1024*1024})}function jP(e,t){let r=t.get(e.file);return!(!r||!r.has(e.line)||e.startLine!==void 0&&!r.has(e.startLine))}function lv(e,t){let r=[],i=[];for(let n of e)jP(n,t)?r.push(n):i.push(n);return{inDiff:r,outOfDiff:i}}var cv=(e=0)=>t=>`\x1B[${t+e}m`,uv=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,dv=(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]}},ML=Object.keys(V.modifier),UP=Object.keys(V.color),LP=Object.keys(V.bgColor),FL=[...UP,...LP];function MP(){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=cv(),V.color.ansi256=uv(),V.color.ansi16m=dv(),V.bgColor.ansi=cv(10),V.bgColor.ansi256=uv(10),V.bgColor.ansi16m=dv(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 FP=MP(),Pe=FP;import Ol from"node:process";import qP from"node:os";import fv from"node:tty";function $e(e,t=globalThis.Deno?globalThis.Deno.args:Ol.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}=Ol,Bi;$e("no-color")||$e("no-colors")||$e("color=false")||$e("color=never")?Bi=0:($e("color")||$e("colors")||$e("color=true")||$e("color=always"))&&(Bi=1);function ZP(){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 BP(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function VP(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let i=ZP();i!==void 0&&(Bi=i);let n=r?Bi: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(Ol.platform==="win32"){let s=qP.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 pv(e,t={}){let r=VP(e,{streamIsTTY:e&&e.isTTY,...t});return BP(r)}var KP={stdout:pv({isTTY:fv.isatty(1)}),stderr:pv({isTTY:fv.isatty(2)})},mv=KP;function hv(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 gv(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
177
+ `).filter(Boolean)}catch{return[]}}function sv(e){let t=[],r=RP(e);r&&t.push(r),t.includes("origin")||t.push("origin");for(let i of NP(e))i!=="upstream"&&!t.includes(i)&&t.push(i);for(let i of t){let n=TP(i,e);if(!n)continue;let o=ov(n);if(o)return o}return null}function Mi(e){if(e instanceof Error){let t=e.message.toLowerCase();return t.includes("enoent")||t.includes("command not found")}return!1}function et(){let e=sv();if(e)return e;let t=JSON.parse(Pl("gh repo view --json owner,name",{encoding:"utf8"}));return{org:t.owner.login,repo:t.name}}function AP(){return Pl("git rev-parse --abbrev-ref HEAD",{encoding:"utf8"}).trim()}function av(e){let{org:t,repo:r}=et();return JSON.parse(Pl(`gh pr view ${Xg(AP)} --json ${e} -R ${t}/${r}`,{encoding:"utf8"}))}function Fi(){try{return av("id").id}catch(e){throw e instanceof Error&&e.message.includes("no pull requests")&&(console.error("Error: No pull request found for the current branch."),process.exit(1)),e}}function qi(){try{return av("number").number}catch(e){if(e instanceof Error&&e.message.includes("no pull requests"))return null;throw e}}function Zi(e,t,r){let{org:i,repo:n}=et();try{return Cl(`gh pr diff ${e} -R ${i}/${n}`,{encoding:"utf8",maxBuffer:256*1024*1024,stdio:["ignore","pipe","pipe"]})}catch(o){if(!zP(o))throw o;return DP(t,r)}}function zP(e){return e instanceof Error&&(e.message.includes("too_large")||e.message.includes("maximum number of files"))}function DP(e,t){try{Cl(`git fetch origin ${e} ${t}`,{stdio:"ignore"})}catch{}return Cl(`git diff ${e}...${t}`,{encoding:"utf8",maxBuffer:256*1024*1024})}function jP(e,t){let r=t.get(e.file);return!(!r||!r.has(e.line)||e.startLine!==void 0&&!r.has(e.startLine))}function lv(e,t){let r=[],i=[];for(let n of e)jP(n,t)?r.push(n):i.push(n);return{inDiff:r,outOfDiff:i}}var cv=(e=0)=>t=>`\x1B[${t+e}m`,uv=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,dv=(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]}},DL=Object.keys(V.modifier),UP=Object.keys(V.color),LP=Object.keys(V.bgColor),jL=[...UP,...LP];function MP(){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=cv(),V.color.ansi256=uv(),V.color.ansi16m=dv(),V.bgColor.ansi=cv(10),V.bgColor.ansi256=uv(10),V.bgColor.ansi16m=dv(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 FP=MP(),Pe=FP;import Ol from"node:process";import qP from"node:os";import fv from"node:tty";function $e(e,t=globalThis.Deno?globalThis.Deno.args:Ol.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}=Ol,Bi;$e("no-color")||$e("no-colors")||$e("color=false")||$e("color=never")?Bi=0:($e("color")||$e("colors")||$e("color=true")||$e("color=always"))&&(Bi=1);function ZP(){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 BP(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function VP(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let i=ZP();i!==void 0&&(Bi=i);let n=r?Bi: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(Ol.platform==="win32"){let s=qP.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 pv(e,t={}){let r=VP(e,{streamIsTTY:e&&e.isTTY,...t});return BP(r)}var KP={stdout:pv({isTTY:fv.isatty(1)}),stderr:pv({isTTY:fv.isatty(2)})},mv=KP;function hv(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 gv(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
178
178
  `:`
179
179
  `)+r,n=i+1,i=e.indexOf(`
180
180
  `,n)}while(i!==-1);return o+=e.slice(n),o}var{stdout:vv,stderr:yv}=mv,El=Symbol("GENERATOR"),Qt=Symbol("STYLER"),cn=Symbol("IS_EMPTY"),bv=["ansi","ansi","ansi256","ansi16m"],er=Object.create(null),GP=(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=vv?vv.level:0;e.level=t.level===void 0?r:t.level};var JP=e=>{let t=(...r)=>r.join(" ");return GP(t,e),Object.setPrototypeOf(t,un.prototype),t};function un(e){return JP(e)}Object.setPrototypeOf(un.prototype,Function.prototype);for(let[e,t]of Object.entries(Pe))er[e]={get(){let r=Vi(this,Rl(t.open,t.close,this[Qt]),this[cn]);return Object.defineProperty(this,e,{value:r}),r}};er.visible={get(){let e=Vi(this,this[Qt],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var Tl=(e,t,r,...i)=>e==="rgb"?t==="ansi16m"?Pe[r].ansi16m(...i):t==="ansi256"?Pe[r].ansi256(Pe.rgbToAnsi256(...i)):Pe[r].ansi(Pe.rgbToAnsi(...i)):e==="hex"?Tl("rgb",t,r,...Pe.hexToRgb(...i)):Pe[r][e](...i),WP=["rgb","hex","ansi256"];for(let e of WP){er[e]={get(){let{level:r}=this;return function(...i){let n=Rl(Tl(e,bv[r],"color",...i),Pe.color.close,this[Qt]);return Vi(this,n,this[cn])}}};let t="bg"+e[0].toUpperCase()+e.slice(1);er[t]={get(){let{level:r}=this;return function(...i){let n=Rl(Tl(e,bv[r],"bgColor",...i),Pe.bgColor.close,this[Qt]);return Vi(this,n,this[cn])}}}}var HP=Object.defineProperties(()=>{},{...er,level:{enumerable:!0,get(){return this[El].level},set(e){this[El].level=e}}}),Rl=(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}},Vi=(e,t,r)=>{let i=(...n)=>YP(i,n.length===1?""+n[0]:n.join(" "));return Object.setPrototypeOf(i,HP),i[El]=e,i[Qt]=t,i[cn]=r,i},YP=(e,t)=>{if(e.level<=0||!t)return e[cn]?"":t;let r=e[Qt];if(r===void 0)return t;let{openAll:i,closeAll:n}=r;if(t.includes("\x1B"))for(;r!==void 0;)t=hv(t,r.close,r.open),r=r.parent;let o=t.indexOf(`
181
- `);return o!==-1&&(t=gv(t,n,i,o)),i+t+n};Object.defineProperties(un.prototype,er);var XP=un(),YL=un({level:yv?yv.level:0});var Ce=XP;function wv(e){if(e.length!==0){console.warn(Ce.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(` ${Ce.yellow("\xB7")} ${t.title} ${Ce.dim(`(${t.file}:${r})`)}`)}}}function $v(e,t){let r=Zi(t.prNumber,t.baseSha,t.headSha),{inDiff:i,outOfDiff:n}=lv(e,iv(r));return wv(n),{inDiff:i,unanchored:n.map(o=>({...o,reason:"out-of-diff"}))}}function xv(e){if(e.length!==0){console.warn(Ce.yellow(`Moved ${e.length} finding(s) without a parseable file:line into the review body:`));for(let t of e){let r=t.location||Ce.dim("missing");console.warn(` ${Ce.yellow("\xB7")} ${t.title} ${Ce.dim(`(${r})`)}`)}}}function Ki(e,t){let r=Li(e);if(r.length===0)return console.log("Synthesis contains no findings; nothing to post."),{inDiff:[],unanchored:[]};let{lineBound:i,unlocated:n,alreadyRaised:o}=nv(r);xv(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}=$v(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]}}var QP=["Reviewer 1","Reviewer 2","Synthesis"];function tt(e){return e===void 0?"\u2014":e.toLocaleString("en-US")}function eC(e){return e?[tt(e.input),tt(e.output),tt(e.cacheRead),tt(e.cacheWrite)]:["\u2014","\u2014","\u2014","\u2014"]}function Gi(e,t){let r=e.map(t).filter(i=>i!==void 0);return r.length===0?void 0:r.reduce((i,n)=>i+n,0)}function tC(e){let t=e.filter(r=>r!==void 0);return[tt(Gi(t,r=>r.input)),tt(Gi(t,r=>r.output)),tt(Gi(t,r=>r.cacheRead)),tt(Gi(t,r=>r.cacheWrite))]}function Sv(e,t){return`| ${e} | ${t.join(" | ")} |`}function _v(e){return["## Token usage","","| Slot | Input | Output | Cache read | Cache write |","| --- | ---: | ---: | ---: | ---: |",...e.map((t,r)=>Sv(QP[r]??`Slot ${r+1}`,eC(t))),Sv("**Total**",tC(e))].join(`
181
+ `);return o!==-1&&(t=gv(t,n,i,o)),i+t+n};Object.defineProperties(un.prototype,er);var XP=un(),GL=un({level:yv?yv.level:0});var Ce=XP;function wv(e){if(e.length!==0){console.warn(Ce.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(` ${Ce.yellow("\xB7")} ${t.title} ${Ce.dim(`(${t.file}:${r})`)}`)}}}function $v(e,t){let r=Zi(t.prNumber,t.baseSha,t.headSha),{inDiff:i,outOfDiff:n}=lv(e,iv(r));return wv(n),{inDiff:i,unanchored:n.map(o=>({...o,reason:"out-of-diff"}))}}function xv(e){if(e.length!==0){console.warn(Ce.yellow(`Moved ${e.length} finding(s) without a parseable file:line into the review body:`));for(let t of e){let r=t.location||Ce.dim("missing");console.warn(` ${Ce.yellow("\xB7")} ${t.title} ${Ce.dim(`(${r})`)}`)}}}function Ki(e,t){let r=Li(e);if(r.length===0)return console.log("Synthesis contains no findings; nothing to post."),{inDiff:[],unanchored:[]};let{lineBound:i,unlocated:n,alreadyRaised:o}=nv(r);xv(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}=$v(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]}}var QP=["Reviewer 1","Reviewer 2","Synthesis"];function tt(e){return e===void 0?"\u2014":e.toLocaleString("en-US")}function eC(e){return e?[tt(e.input),tt(e.output),tt(e.cacheRead),tt(e.cacheWrite)]:["\u2014","\u2014","\u2014","\u2014"]}function Gi(e,t){let r=e.map(t).filter(i=>i!==void 0);return r.length===0?void 0:r.reduce((i,n)=>i+n,0)}function tC(e){let t=e.filter(r=>r!==void 0);return[tt(Gi(t,r=>r.input)),tt(Gi(t,r=>r.output)),tt(Gi(t,r=>r.cacheRead)),tt(Gi(t,r=>r.cacheWrite))]}function Sv(e,t){return`| ${e} | ${t.join(" | ")} |`}function _v(e){return["## Token usage","","| Slot | Input | Output | Cache read | Cache write |","| --- | ---: | ---: | ---: | ---: |",...e.map((t,r)=>Sv(QP[r]??`Slot ${r+1}`,eC(t))),Sv("**Total**",tC(e))].join(`
182
182
  `)}function kv(e,t,r,i){if(!r)return;let n=nC(e,"utf8"),{unanchored:o}=Ki(n,t),s=_v(i.map(a=>a.usage));rC(r,`${Qe(n,o)}
183
183
 
184
184
  ${s}
185
185
  `)}function tr(e,t){return t?`${e}
186
186
 
187
187
  ${t}`:e}import{spawnSync as iC}from"node:child_process";import{unlinkSync as oC,writeFileSync as sC}from"node:fs";import{tmpdir as aC}from"node:os";import{join as lC}from"node:path";function Iv(e){let t;try{t=JSON.parse(e)}catch{return}if(!t||typeof t!="object")return;let r=t.errors;if(!Array.isArray(r)||r.length===0)return;let i=r.map(n=>n&&typeof n=="object"&&"message"in n?String(n.message):String(n)).join("; ");throw new Error(i||"GraphQL request returned errors")}function cC(e,t){let r=["api","graphql","-F",`query=@${e}`];for(let[i,n]of Object.entries(t)){let o=typeof n=="number"?"-F":"-f";r.push(o,`${i}=${n}`)}return r}function dn(e,t){let r=lC(aC(),`gh-query-${Date.now()}.graphql`);sC(r,e);try{let i=iC("gh",cC(r,t),{encoding:"utf8",windowsHide:!0});if(i.status!==0)throw new Error(i.stderr||i.stdout);return Iv(i.stdout),i.stdout}finally{oC(r)}}function Ji(e,t){try{let r=Fi();return dn(e,{prId:r,body:t}),console.log("Submitted review."),!0}catch(r){if(Mi(r))return console.error("Error: GitHub CLI (gh) is not installed."),!1;let i=r instanceof Error?r.message:String(r);return console.error(`Failed to submit review: ${i}`),!1}}var uC="mutation($prId: ID!, $body: String) { addPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }";function rr(e){return Ji(uC,e)}function dC(e){return e.length===0?"The review did not complete.":`The review did not complete: ${e.map(r=>r.name.replace("-"," ")).join(" and ")} failed.`}function Pv(e,t,r){let i=["## Code review failed","",`${dC(e)} No findings were posted.`];r&&i.push("",`See the [workflow run](${r}) for details.`),rr(tr(i.join(`
188
- `),t))}function Cv(e,t){console.error("Review failed; no findings were posted."),Pv(e,t.footer,t.runUrl),process.exit(1)}import{statSync as fC}from"node:fs";function nr(e,t){let r;try{r=fC(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 qy from"node:process";var te={};De(te,{ConEmu:()=>Dv,beep:()=>qC,beginSynchronizedOutput:()=>Nv,clearScreen:()=>zC,clearTerminal:()=>UC,clearViewport:()=>DC,cursorBackward:()=>wC,cursorDown:()=>yC,cursorForward:()=>bC,cursorGetPosition:()=>SC,cursorHide:()=>IC,cursorLeft:()=>Tv,cursorMove:()=>vC,cursorNextLine:()=>_C,cursorPrevLine:()=>kC,cursorRestorePosition:()=>xC,cursorSavePosition:()=>$C,cursorShow:()=>PC,cursorTo:()=>gC,cursorUp:()=>Ev,endSynchronizedOutput:()=>Av,enterAlternativeScreen:()=>LC,eraseDown:()=>TC,eraseEndLine:()=>OC,eraseLine:()=>Rv,eraseLines:()=>CC,eraseScreen:()=>Wi,eraseStartLine:()=>EC,eraseUp:()=>RC,exitAlternativeScreen:()=>MC,iTerm:()=>zv,image:()=>BC,link:()=>ZC,scrollDown:()=>AC,scrollUp:()=>NC,setCwd:()=>VC,synchronizedOutput:()=>FC});import or from"node:process";import pC from"node:os";var ir=globalThis.window?.document!==void 0,LM=globalThis.process?.versions?.node!==void 0,MM=globalThis.process?.versions?.bun!==void 0,FM=globalThis.Deno?.version?.deno!==void 0,qM=globalThis.process?.versions?.electron!==void 0,ZM=globalThis.navigator?.userAgent?.includes("jsdom")===!0,BM=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,VM=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,KM=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,GM=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,fn=globalThis.navigator?.userAgentData?.platform,JM=fn==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",WM=fn==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",HM=fn==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",YM=fn==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),XM=fn==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android";var j="\x1B[",sr="\x1B]",Tt="\x07",pn=";",Ov=!ir&&or.env.TERM_PROGRAM==="Apple_Terminal",mC=!ir&&or.platform==="win32",hC=!ir&&(or.env.TERM?.startsWith("screen")||or.env.TERM?.startsWith("tmux")||or.env.TMUX!==void 0),Nl=ir?()=>{throw new Error("`process.cwd()` only works in Node.js, not the browser.")}:or.cwd,ar=e=>hC?"\x1BPtmux;"+e.replaceAll("\x1B","\x1B\x1B")+"\x1B\\":e,gC=(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)+pn+(e+1)+"H"},vC=(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},Ev=(e=1)=>j+e+"A",yC=(e=1)=>j+e+"B",bC=(e=1)=>j+e+"C",wC=(e=1)=>j+e+"D",Tv=j+"G",$C=Ov?"\x1B7":j+"s",xC=Ov?"\x1B8":j+"u",SC=j+"6n",_C=j+"E",kC=j+"F",IC=j+"?25l",PC=j+"?25h",CC=e=>{let t="";for(let r=0;r<e;r++)t+=Rv+(r<e-1?Ev():"");return e&&(t+=Tv),t},OC=j+"K",EC=j+"1K",Rv=j+"2K",TC=j+"J",RC=j+"1J",Wi=j+"2J",NC=j+"S",AC=j+"T",zC="\x1Bc",DC=`${Wi}${j}H`,jC=()=>{if(ir||!mC)return!1;let e=pC.release().split("."),t=Number(e[0]),r=Number(e[2]??0);return t<10||t===10&&r<10586},UC=jC()?`${Wi}${j}0f`:`${Wi}${j}3J${j}H`,LC=j+"?1049h",MC=j+"?1049l",Nv=j+"?2026h",Av=j+"?2026l",FC=e=>Nv+e+Av,qC=Tt,ZC=(e,t)=>{let r=ar(`${sr}8${pn}${pn}${t}${Tt}`),i=ar(`${sr}8${pn}${pn}${Tt}`);return r+e+i},BC=(e,t={})=>{let r=`${sr}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 ar(r+`;size=${i.byteLength}:`+i.toString("base64")+Tt)},zv={setCwd:(e=Nl())=>ar(`${sr}50;CurrentDir=${e}${Tt}`),annotation(e,t={}){let r=`${sr}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,ar(r+Tt)}},Dv={setCwd:(e=Nl())=>ar(`${sr}9;9;${e}${Tt}`)},VC=(e=Nl())=>zv.setCwd(e)+Dv.setCwd(e);import qv from"node:process";import Qi from"node:process";var KC=(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);!GC(n,o)&&i||Object.defineProperty(e,r,o)},GC=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)},JC=(e,t)=>{let r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},WC=(e,t)=>`/* Wrapped ${e}*/
189
- ${t}`,HC=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),YC=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),XC=(e,t,r)=>{let i=r===""?"":`with ${r.trim()}() `,n=WC.bind(null,i,t.toString());Object.defineProperty(n,"name",YC);let{writable:o,enumerable:s,configurable:a}=HC;Object.defineProperty(e,"toString",{value:n,writable:o,enumerable:s,configurable:a})};function Al(e,t,{ignoreNonConfigurable:r=!1}={}){let{name:i}=e;for(let n of Reflect.ownKeys(t))KC(e,t,n,r);return JC(e,t),XC(e,t,i),e}var Hi=new WeakMap,jv=(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(Hi.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 Al(o,e),Hi.set(o,i),o};jv.callCount=e=>{if(!Hi.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return Hi.get(e)};var Uv=jv;var Rt=[];Rt.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Rt.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Rt.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Yi=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",zl=Symbol.for("signal-exit emitter"),Dl=globalThis,QC=Object.defineProperty.bind(Object),jl=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Dl[zl])return Dl[zl];QC(Dl,zl,{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}},Xi=class{},eO=e=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}}),Ul=class extends Xi{onExit(){return()=>{}}load(){}unload(){}},Ll=class extends Xi{#s=Ml.platform==="win32"?"SIGINT":"SIGHUP";#t=new jl;#e;#i;#o;#n={};#r=!1;constructor(t){super(),this.#e=t,this.#n={};for(let r of Rt)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(!Yi(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 Rt)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,Rt.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 Yi(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"&&Yi(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)}},Ml=globalThis.process,{onExit:Lv,load:u9,unload:d9}=eO(Yi(Ml)?new Ll(Ml):new Ul);var Mv=Qi.stderr.isTTY?Qi.stderr:Qi.stdout.isTTY?Qi.stdout:void 0,tO=Mv?Uv(()=>{Lv(()=>{Mv.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},Fv=tO;var eo=!1,lr={};lr.show=(e=qv.stderr)=>{e.isTTY&&(eo=!1,e.write("\x1B[?25h"))};lr.hide=(e=qv.stderr)=>{e.isTTY&&(Fv(),eo=!0,e.write("\x1B[?25l"))};lr.toggle=(e,t)=>{e!==void 0&&(eo=e),eo?lr.show(t):lr.hide(t)};var Fl=lr;function ql({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 rO=ql();function rt(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes("\x1B")&&!e.includes("\x9B")?e:e.replace(rO,"")}var Zv=[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],Bv=12288,Vv=65510,Kv=[12288,12288,65281,65376,65504,65510];var Gv=4352,Jv=262141,Zl=[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 to=(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 Wv=19968,[oO,sO]=aO(Zl);function aO(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(Wv>=n&&Wv<=o)return[n,o];o-n>r-t&&(t=n,r=o)}return[t,r]}var Hv=e=>e<161||e>1114109?!1:to(Zv,e),mn=e=>e<Bv||e>Vv?!1:to(Kv,e);var hn=e=>e>=oO&&e<=sO?!0:e<Gv||e>Jv?!1:to(Zl,e);function lO(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function gn(e,{ambiguousAsWide:t=!1}={}){return lO(e),mn(e)||hn(e)||t&&Hv(e)?2:1}var cO=new Intl.Segmenter,Yv=new RegExp("^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Format}|\\p{Mark}|\\p{Surrogate})+$","v"),uO=new RegExp("^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}\\p{Surrogate}]+","v"),dO=new RegExp("^\\p{RGI_Emoji}$","v"),fO=/^[\d#*]\u20E3$/,pO=new RegExp("\\p{Extended_Pictographic}","gu");function mO(e){if(e.length>50)return!1;if(fO.test(e))return!0;if(e.includes("\u200D")){let t=e.match(pO);return t!==null&&t.length>=2}return!1}function hO(e){return e.replace(uO,"")}function gO(e){return Yv.test(e)}function Xv(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function Qv(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function ey(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function vO(e){return Xv(e)||Qv(e)||ey(e)}function yO(e,t){let r=[];for(let n of e)Yv.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(!vO(o)){if(i===0)return;for(let s=n;s<r.length;s++)i+=gn(r[s],t);return i}if(Xv(o)&&Qv(r[n+1])){i+=2,n+=ey(r[n+2])?2:1;continue}i+=gn(o,t)}return i}function bO(e,t){let r=0,i=!0;for(let n of e){if(i){i=!1;continue}n>="\uFF00"&&n<="\uFFEF"&&(r+=gn(n.codePointAt(0),t))}return r}function je(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=rt(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 cO.segment(n)){if(gO(a))continue;if(dO.test(a)||mO(a)){o+=2;continue}let l=hO(a),c=yO(l,s);if(c!==void 0){o+=c;continue}let u=l.codePointAt(0);o+=gn(u,s),o+=bO(l,s)}return o}var ty=(e=0)=>t=>`\x1B[${t+e}m`,ry=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,ny=(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]}},F9=Object.keys(G.modifier),wO=Object.keys(G.color),$O=Object.keys(G.bgColor),q9=[...wO,...$O];function xO(){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=ty(),G.color.ansi256=ry(),G.color.ansi16m=ny(),G.bgColor.ansi=ty(10),G.bgColor.ansi256=ry(10),G.bgColor.ansi16m=ny(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 SO=xO(),xe=SO;var Nt="\x1B",Vl="\x9B",_O=new Set([Nt,Vl]),cy="\x07",uy="[",kO="]",io="m",oo=0,dy=39,fy=49,py=59,my=38,hy=48,gy=58,IO=5,PO=2,no=`${kO}8;;`,vy=new RegExp(`^\\u001B(?:\\${uy}(?<sgr>[0-9;]*)${io}|${no}(?<uri>[^\\u0007\\u001B]*)(?:\\u0007|\\u001B\\\\))`),yy=new RegExp(`^\\u009B(?<sgr>[0-9;]*)${io}`),by=new Set(xe.codes.values());by.delete(oo);var CO=new Intl.Segmenter,wy=e=>Array.from(CO.segment(e),({segment:t})=>t),iy=8,$y=e=>`${Nt}${uy}${e}${io}`,oy=e=>`${Nt}${no}${e}${cy}`,xy=e=>{let t=e.split(";").map(i=>i===""?oo:Number.parseInt(i,10)),r=[];for(let i=0;i<t.length;i++){let n=t[i];if(Number.isFinite(n)){if(n===my||n===hy||n===gy){if(i+1>=t.length)break;let o=t[i+1];if(o===IO&&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===PO&&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},ro=(e,t)=>{let r=e.findIndex(i=>i.family===t);r!==-1&&e.splice(r,1)},sy=(e,t)=>{ro(e,t.family),e.push(t)},OO=(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)}},EO=(e,t)=>{if(e>=30&&e<=37||e>=90&&e<=97||e===my&&t.length>1)return{family:"foreground",open:t.join(";"),close:dy};if(e>=40&&e<=47||e>=100&&e<=107||e===hy&&t.length>1)return{family:"background",open:t.join(";"),close:fy};if(e===gy&&t.length>1)return{family:"underlineColor",open:t.join(";"),close:py}},Sy=(e,t)=>e===oo?(t.length=0,!0):e===dy?(ro(t,"foreground"),!0):e===fy?(ro(t,"background"),!0):e===py?(ro(t,"underlineColor"),!0):by.has(e)?(OO(t,e),!0):!1,TO=(e,t)=>{let[r]=e;if(Sy(r,t))return;let i=EO(r,e);if(i){sy(t,i);return}let n=xe.codes.get(r);n!==void 0&&n!==oo&&sy(t,{family:`modifier-${r}`,open:e.join(";"),close:n})},ay=(e,t)=>{for(let r of xy(e))TO(r,t)},ly=(e,t)=>{for(let r of xy(e)){let[i]=r;Sy(i,t)}},RO=(e,t)=>{let r=e;for(;r.length>0;){if(r.startsWith(Nt)&&r[1]!=="\\"){let i=vy.exec(r);if(!i)break;i.groups.sgr!==void 0&&ly(i.groups.sgr,t),r=r.slice(i[0].length);continue}if(r.startsWith(Vl)){let i=yy.exec(r);if(!i||i.groups.sgr===void 0)break;ly(i.groups.sgr,t),r=r.slice(i[0].length);continue}break}},NO=e=>[...e].reverse().map(t=>$y(t.close)).join(""),AO=e=>e.map(t=>$y(t.open)).join(""),zO=e=>e.split(" ").map(t=>je(t)),Bl=(e,t,r)=>{let i=wy(t),n=!1,o=!1,s=je(rt(e.at(-1)));for(let[a,l]of i.entries()){let c=je(l);if(s+c<=r?e[e.length-1]+=l:(e.push(l),s=0),_O.has(l)&&!(o&&l===Nt&&i[a+1]==="\\")&&(n=!0,o=i.slice(a+1,a+1+no.length).join("")===no),n){o?(l===cy||l==="\\"&&a>0&&i[a-1]===Nt)&&(n=!1,o=!1):l===io&&(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())},DO=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(je(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},jO=e=>{if(!e.includes(" "))return e;let t=e.split(" "),r=0,i="";for(let[n,o]of t.entries())if(i+=o,r+=je(o),n<t.length-1){let s=iy-r%iy;i+=" ".repeat(s),r+=s}return i},UO=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let i="",n,o=[],s=zO(e),a=[""];for(let[d,f]of e.split(" ").entries()){r.trim!==!1&&(a[a.length-1]=a.at(-1).trimStart());let m=je(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(""),Bl(a,f,t);continue}if(m+s[d]>t&&m>0&&s[d]>0){if(r.wordWrap===!1&&m<t){Bl(a,f,t);continue}a.push("")}if(m+s[d]>t&&r.wordWrap===!1){Bl(a,f,t);continue}a[a.length-1]+=f}r.trim!==!1&&(a=a.map(d=>DO(d)));let l=a.join(`
188
+ `),t))}function Cv(e,t){console.error("Review failed; no findings were posted."),Pv(e,t.footer,t.runUrl),process.exit(1)}import{statSync as fC}from"node:fs";function nr(e,t){let r;try{r=fC(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 qy from"node:process";var te={};De(te,{ConEmu:()=>Dv,beep:()=>qC,beginSynchronizedOutput:()=>Nv,clearScreen:()=>zC,clearTerminal:()=>UC,clearViewport:()=>DC,cursorBackward:()=>wC,cursorDown:()=>yC,cursorForward:()=>bC,cursorGetPosition:()=>SC,cursorHide:()=>IC,cursorLeft:()=>Tv,cursorMove:()=>vC,cursorNextLine:()=>_C,cursorPrevLine:()=>kC,cursorRestorePosition:()=>xC,cursorSavePosition:()=>$C,cursorShow:()=>PC,cursorTo:()=>gC,cursorUp:()=>Ev,endSynchronizedOutput:()=>Av,enterAlternativeScreen:()=>LC,eraseDown:()=>TC,eraseEndLine:()=>OC,eraseLine:()=>Rv,eraseLines:()=>CC,eraseScreen:()=>Wi,eraseStartLine:()=>EC,eraseUp:()=>RC,exitAlternativeScreen:()=>MC,iTerm:()=>zv,image:()=>BC,link:()=>ZC,scrollDown:()=>AC,scrollUp:()=>NC,setCwd:()=>VC,synchronizedOutput:()=>FC});import or from"node:process";import pC from"node:os";var ir=globalThis.window?.document!==void 0,zM=globalThis.process?.versions?.node!==void 0,DM=globalThis.process?.versions?.bun!==void 0,jM=globalThis.Deno?.version?.deno!==void 0,UM=globalThis.process?.versions?.electron!==void 0,LM=globalThis.navigator?.userAgent?.includes("jsdom")===!0,MM=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,FM=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,qM=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,ZM=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,fn=globalThis.navigator?.userAgentData?.platform,BM=fn==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",VM=fn==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",KM=fn==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",GM=fn==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),JM=fn==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android";var j="\x1B[",sr="\x1B]",Tt="\x07",pn=";",Ov=!ir&&or.env.TERM_PROGRAM==="Apple_Terminal",mC=!ir&&or.platform==="win32",hC=!ir&&(or.env.TERM?.startsWith("screen")||or.env.TERM?.startsWith("tmux")||or.env.TMUX!==void 0),Nl=ir?()=>{throw new Error("`process.cwd()` only works in Node.js, not the browser.")}:or.cwd,ar=e=>hC?"\x1BPtmux;"+e.replaceAll("\x1B","\x1B\x1B")+"\x1B\\":e,gC=(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)+pn+(e+1)+"H"},vC=(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},Ev=(e=1)=>j+e+"A",yC=(e=1)=>j+e+"B",bC=(e=1)=>j+e+"C",wC=(e=1)=>j+e+"D",Tv=j+"G",$C=Ov?"\x1B7":j+"s",xC=Ov?"\x1B8":j+"u",SC=j+"6n",_C=j+"E",kC=j+"F",IC=j+"?25l",PC=j+"?25h",CC=e=>{let t="";for(let r=0;r<e;r++)t+=Rv+(r<e-1?Ev():"");return e&&(t+=Tv),t},OC=j+"K",EC=j+"1K",Rv=j+"2K",TC=j+"J",RC=j+"1J",Wi=j+"2J",NC=j+"S",AC=j+"T",zC="\x1Bc",DC=`${Wi}${j}H`,jC=()=>{if(ir||!mC)return!1;let e=pC.release().split("."),t=Number(e[0]),r=Number(e[2]??0);return t<10||t===10&&r<10586},UC=jC()?`${Wi}${j}0f`:`${Wi}${j}3J${j}H`,LC=j+"?1049h",MC=j+"?1049l",Nv=j+"?2026h",Av=j+"?2026l",FC=e=>Nv+e+Av,qC=Tt,ZC=(e,t)=>{let r=ar(`${sr}8${pn}${pn}${t}${Tt}`),i=ar(`${sr}8${pn}${pn}${Tt}`);return r+e+i},BC=(e,t={})=>{let r=`${sr}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 ar(r+`;size=${i.byteLength}:`+i.toString("base64")+Tt)},zv={setCwd:(e=Nl())=>ar(`${sr}50;CurrentDir=${e}${Tt}`),annotation(e,t={}){let r=`${sr}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,ar(r+Tt)}},Dv={setCwd:(e=Nl())=>ar(`${sr}9;9;${e}${Tt}`)},VC=(e=Nl())=>zv.setCwd(e)+Dv.setCwd(e);import qv from"node:process";import Qi from"node:process";var KC=(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);!GC(n,o)&&i||Object.defineProperty(e,r,o)},GC=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)},JC=(e,t)=>{let r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},WC=(e,t)=>`/* Wrapped ${e}*/
189
+ ${t}`,HC=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),YC=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),XC=(e,t,r)=>{let i=r===""?"":`with ${r.trim()}() `,n=WC.bind(null,i,t.toString());Object.defineProperty(n,"name",YC);let{writable:o,enumerable:s,configurable:a}=HC;Object.defineProperty(e,"toString",{value:n,writable:o,enumerable:s,configurable:a})};function Al(e,t,{ignoreNonConfigurable:r=!1}={}){let{name:i}=e;for(let n of Reflect.ownKeys(t))KC(e,t,n,r);return JC(e,t),XC(e,t,i),e}var Hi=new WeakMap,jv=(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(Hi.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 Al(o,e),Hi.set(o,i),o};jv.callCount=e=>{if(!Hi.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return Hi.get(e)};var Uv=jv;var Rt=[];Rt.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Rt.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Rt.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Yi=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",zl=Symbol.for("signal-exit emitter"),Dl=globalThis,QC=Object.defineProperty.bind(Object),jl=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Dl[zl])return Dl[zl];QC(Dl,zl,{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}},Xi=class{},eO=e=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}}),Ul=class extends Xi{onExit(){return()=>{}}load(){}unload(){}},Ll=class extends Xi{#s=Ml.platform==="win32"?"SIGINT":"SIGHUP";#t=new jl;#e;#i;#o;#n={};#r=!1;constructor(t){super(),this.#e=t,this.#n={};for(let r of Rt)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(!Yi(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 Rt)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,Rt.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 Yi(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"&&Yi(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)}},Ml=globalThis.process,{onExit:Lv,load:s9,unload:a9}=eO(Yi(Ml)?new Ll(Ml):new Ul);var Mv=Qi.stderr.isTTY?Qi.stderr:Qi.stdout.isTTY?Qi.stdout:void 0,tO=Mv?Uv(()=>{Lv(()=>{Mv.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},Fv=tO;var eo=!1,lr={};lr.show=(e=qv.stderr)=>{e.isTTY&&(eo=!1,e.write("\x1B[?25h"))};lr.hide=(e=qv.stderr)=>{e.isTTY&&(Fv(),eo=!0,e.write("\x1B[?25l"))};lr.toggle=(e,t)=>{e!==void 0&&(eo=e),eo?lr.show(t):lr.hide(t)};var Fl=lr;function ql({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 rO=ql();function rt(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes("\x1B")&&!e.includes("\x9B")?e:e.replace(rO,"")}var Zv=[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],Bv=12288,Vv=65510,Kv=[12288,12288,65281,65376,65504,65510];var Gv=4352,Jv=262141,Zl=[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 to=(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 Wv=19968,[oO,sO]=aO(Zl);function aO(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(Wv>=n&&Wv<=o)return[n,o];o-n>r-t&&(t=n,r=o)}return[t,r]}var Hv=e=>e<161||e>1114109?!1:to(Zv,e),mn=e=>e<Bv||e>Vv?!1:to(Kv,e);var hn=e=>e>=oO&&e<=sO?!0:e<Gv||e>Jv?!1:to(Zl,e);function lO(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function gn(e,{ambiguousAsWide:t=!1}={}){return lO(e),mn(e)||hn(e)||t&&Hv(e)?2:1}var cO=new Intl.Segmenter,Yv=new RegExp("^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Format}|\\p{Mark}|\\p{Surrogate})+$","v"),uO=new RegExp("^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}\\p{Surrogate}]+","v"),dO=new RegExp("^\\p{RGI_Emoji}$","v"),fO=/^[\d#*]\u20E3$/,pO=new RegExp("\\p{Extended_Pictographic}","gu");function mO(e){if(e.length>50)return!1;if(fO.test(e))return!0;if(e.includes("\u200D")){let t=e.match(pO);return t!==null&&t.length>=2}return!1}function hO(e){return e.replace(uO,"")}function gO(e){return Yv.test(e)}function Xv(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function Qv(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function ey(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function vO(e){return Xv(e)||Qv(e)||ey(e)}function yO(e,t){let r=[];for(let n of e)Yv.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(!vO(o)){if(i===0)return;for(let s=n;s<r.length;s++)i+=gn(r[s],t);return i}if(Xv(o)&&Qv(r[n+1])){i+=2,n+=ey(r[n+2])?2:1;continue}i+=gn(o,t)}return i}function bO(e,t){let r=0,i=!0;for(let n of e){if(i){i=!1;continue}n>="\uFF00"&&n<="\uFFEF"&&(r+=gn(n.codePointAt(0),t))}return r}function je(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=rt(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 cO.segment(n)){if(gO(a))continue;if(dO.test(a)||mO(a)){o+=2;continue}let l=hO(a),c=yO(l,s);if(c!==void 0){o+=c;continue}let u=l.codePointAt(0);o+=gn(u,s),o+=bO(l,s)}return o}var ty=(e=0)=>t=>`\x1B[${t+e}m`,ry=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,ny=(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]}},j9=Object.keys(G.modifier),wO=Object.keys(G.color),$O=Object.keys(G.bgColor),U9=[...wO,...$O];function xO(){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=ty(),G.color.ansi256=ry(),G.color.ansi16m=ny(),G.bgColor.ansi=ty(10),G.bgColor.ansi256=ry(10),G.bgColor.ansi16m=ny(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 SO=xO(),xe=SO;var Nt="\x1B",Vl="\x9B",_O=new Set([Nt,Vl]),cy="\x07",uy="[",kO="]",io="m",oo=0,dy=39,fy=49,py=59,my=38,hy=48,gy=58,IO=5,PO=2,no=`${kO}8;;`,vy=new RegExp(`^\\u001B(?:\\${uy}(?<sgr>[0-9;]*)${io}|${no}(?<uri>[^\\u0007\\u001B]*)(?:\\u0007|\\u001B\\\\))`),yy=new RegExp(`^\\u009B(?<sgr>[0-9;]*)${io}`),by=new Set(xe.codes.values());by.delete(oo);var CO=new Intl.Segmenter,wy=e=>Array.from(CO.segment(e),({segment:t})=>t),iy=8,$y=e=>`${Nt}${uy}${e}${io}`,oy=e=>`${Nt}${no}${e}${cy}`,xy=e=>{let t=e.split(";").map(i=>i===""?oo:Number.parseInt(i,10)),r=[];for(let i=0;i<t.length;i++){let n=t[i];if(Number.isFinite(n)){if(n===my||n===hy||n===gy){if(i+1>=t.length)break;let o=t[i+1];if(o===IO&&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===PO&&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},ro=(e,t)=>{let r=e.findIndex(i=>i.family===t);r!==-1&&e.splice(r,1)},sy=(e,t)=>{ro(e,t.family),e.push(t)},OO=(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)}},EO=(e,t)=>{if(e>=30&&e<=37||e>=90&&e<=97||e===my&&t.length>1)return{family:"foreground",open:t.join(";"),close:dy};if(e>=40&&e<=47||e>=100&&e<=107||e===hy&&t.length>1)return{family:"background",open:t.join(";"),close:fy};if(e===gy&&t.length>1)return{family:"underlineColor",open:t.join(";"),close:py}},Sy=(e,t)=>e===oo?(t.length=0,!0):e===dy?(ro(t,"foreground"),!0):e===fy?(ro(t,"background"),!0):e===py?(ro(t,"underlineColor"),!0):by.has(e)?(OO(t,e),!0):!1,TO=(e,t)=>{let[r]=e;if(Sy(r,t))return;let i=EO(r,e);if(i){sy(t,i);return}let n=xe.codes.get(r);n!==void 0&&n!==oo&&sy(t,{family:`modifier-${r}`,open:e.join(";"),close:n})},ay=(e,t)=>{for(let r of xy(e))TO(r,t)},ly=(e,t)=>{for(let r of xy(e)){let[i]=r;Sy(i,t)}},RO=(e,t)=>{let r=e;for(;r.length>0;){if(r.startsWith(Nt)&&r[1]!=="\\"){let i=vy.exec(r);if(!i)break;i.groups.sgr!==void 0&&ly(i.groups.sgr,t),r=r.slice(i[0].length);continue}if(r.startsWith(Vl)){let i=yy.exec(r);if(!i||i.groups.sgr===void 0)break;ly(i.groups.sgr,t),r=r.slice(i[0].length);continue}break}},NO=e=>[...e].reverse().map(t=>$y(t.close)).join(""),AO=e=>e.map(t=>$y(t.open)).join(""),zO=e=>e.split(" ").map(t=>je(t)),Bl=(e,t,r)=>{let i=wy(t),n=!1,o=!1,s=je(rt(e.at(-1)));for(let[a,l]of i.entries()){let c=je(l);if(s+c<=r?e[e.length-1]+=l:(e.push(l),s=0),_O.has(l)&&!(o&&l===Nt&&i[a+1]==="\\")&&(n=!0,o=i.slice(a+1,a+1+no.length).join("")===no),n){o?(l===cy||l==="\\"&&a>0&&i[a-1]===Nt)&&(n=!1,o=!1):l===io&&(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())},DO=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(je(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},jO=e=>{if(!e.includes(" "))return e;let t=e.split(" "),r=0,i="";for(let[n,o]of t.entries())if(i+=o,r+=je(o),n<t.length-1){let s=iy-r%iy;i+=" ".repeat(s),r+=s}return i},UO=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let i="",n,o=[],s=zO(e),a=[""];for(let[d,f]of e.split(" ").entries()){r.trim!==!1&&(a[a.length-1]=a.at(-1).trimStart());let m=je(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(""),Bl(a,f,t);continue}if(m+s[d]>t&&m>0&&s[d]>0){if(r.wordWrap===!1&&m<t){Bl(a,f,t);continue}a.push("")}if(m+s[d]>t&&r.wordWrap===!1){Bl(a,f,t);continue}a[a.length-1]+=f}r.trim!==!1&&(a=a.map(d=>DO(d)));let l=a.join(`
190
190
  `),c=wy(l),u=0;for(let[d,f]of c.entries()){if(i+=f,f===Nt&&c[d+1]!=="\\"){let{groups:m}=vy.exec(l.slice(u))||{groups:{}};m.sgr!==void 0?ay(m.sgr,o):m.uri!==void 0&&(n=m.uri.length===0?void 0:m.uri)}else if(f===Vl){let{groups:m}=yy.exec(l.slice(u))||{groups:{}};m.sgr!==void 0&&ay(m.sgr,o)}if(c[d+1]===`
191
191
  `)n&&(i+=oy("")),i+=NO(o);else if(f===`
192
192
  `){let m=[...o];RO(l.slice(u+1),m),i+=AO(m),n&&(i+=oy(n))}u+=f.length}return i};function Kl(e,t,r){return String(e).normalize().replaceAll(`\r
@@ -204,7 +204,7 @@ ${t}`,HC=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),YC=Objec
204
204
  `,$=Kl(b,m,{trim:!1,hard:!0,wordWrap:!1}),{text:_,wasClipped:x}=v?qE(e,$,i):{text:$,wasClipped:!1},C=_===""?[]:_.split(`
205
205
  `);return{wrapped:_,lines:C,wasClipped:x}},u=()=>{s="",o=fo(e,r),n=0},d=(...f)=>{t||Fl.hide();let m=fo(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(`
206
206
  `),{start:_,endPrevious:x,endNext:C}=ZE($,h);if($.length!==h.length&&(x=$.length-1,C=h.length-1),_===h.length&&n===h.length)return;if(_===0){l(te.eraseLines(n)+v),s=v,o=m,n=h.length;return}let E=BE({prevCount:n,start:_,endPrevious:x,endNext:C,nextLines:h,nextWrappedEndsWithNewline:v.endsWith(`
207
- `)});l(E),s=v,o=m,n=h.length};return d.clear=()=>{l(te.eraseLines(n)),u()},d.done=()=>{u(),t||Fl.show()},d.persist=(...f)=>{let m=n>0?te.eraseLines(n):"",v=fo(e,r),{wrapped:h}=c(f.join(" "),v,!1);l(m+h),u()},d}var lF=po(qy.stdout);var cF=po(qy.stderr);var nc=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function VE(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 Zy(e,t){let r=[...e].sort((i,n)=>+!!i.footer-+!!n.footer);for(let i of r)VE(i);return r.map(i=>ic(i,t)).join(`
207
+ `)});l(E),s=v,o=m,n=h.length};return d.clear=()=>{l(te.eraseLines(n)),u()},d.done=()=>{u(),t||Fl.show()},d.persist=(...f)=>{let m=n>0?te.eraseLines(n):"",v=fo(e,r),{wrapped:h}=c(f.join(" "),v,!1);l(m+h),u()},d}var iF=po(qy.stdout);var oF=po(qy.stderr);var nc=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function VE(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 Zy(e,t){let r=[...e].sort((i,n)=>+!!i.footer-+!!n.footer);for(let i of r)VE(i);return r.map(i=>ic(i,t)).join(`
208
208
  `)}function ic(e,t){return e.state==="succeeded"?`\u2714 ${e.text}`:e.state==="failed"?`\u2716 ${e.text}`:`${nc[t]} ${e.text}`}import{appendFileSync as Vy,mkdirSync as GE}from"node:fs";import{join as JE}from"node:path";var KE=new RegExp("\x1B\\[[0-9;?]*[ -/]*[@-~]","g");function By(e){return e.replace(KE,"")}var WE="review.log";function Ky(){let e,t=[];return{append(r){let i=By(r);if(!e){t.push(i);return}Vy(e,`${i}
209
209
  `)},attach(r){GE(r,{recursive:!0}),e=JE(r,WE);let i=["",`=== ${new Date().toISOString()} ===`,`$ ${process.argv.slice(1).join(" ")}`,...t];t=[],Vy(e,`${i.join(`
210
210
  `)}
@@ -421,25 +421,25 @@ Each added or context line is prefixed with a left gutter showing its line numbe
421
421
  \`\`\`diff
422
422
  ${BI(e.diff.trimEnd())}
423
423
  \`\`\`
424
- `}import{homedir as rU}from"node:os";import{basename as nU,join as Di}from"node:path";function GI(e,t){let r=Di(rU(),".assist","reviews",nU(e),t);return{reviewDir:r,requestPath:Di(r,"request.md"),claudePath:Di(r,"claude.md"),codexPath:Di(r,"codex.md"),synthesisPath:Di(r,"synthesis.md")}}import{execSync as uU}from"node:child_process";import{execSync as iU}from"node:child_process";import{unlinkSync as oU,writeFileSync as sU}from"node:fs";import{tmpdir as aU}from"node:os";import{join as lU}from"node:path";var cU="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 JI(e,t,r){let i=lU(aU(),`gh-query-${Date.now()}.graphql`);sU(i,cU);try{let n=iU(`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{oU(i)}}function dU(e,t,r){let i=uU(`gh api --paginate repos/${e}/${t}/pulls/${r}/comments`,{encoding:"utf8",maxBuffer:67108864});return i.trim()?JSON.parse(i):[]}function WI(){let e=qi();if(e===null)return null;let{org:t,repo:r}=et(),i=dU(t,r,e);if(i.length===0)return[];let n=JI(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 fU,mkdirSync as pU,unlinkSync as mU,writeFileSync as hU}from"node:fs";function gU(e){for(let t of[e.claudePath,e.codexPath,e.synthesisPath])fU(t)&&mU(t)}function HI(e,t,r){pU(e.reviewDir,{recursive:!0}),r&&gU(e),hU(e.requestPath,t)}function YI(e,t,r){let i=GI(e,`${t.branch}-${t.shortSha}`),n=WI();return vU(n?.length??0),HI(i,KI(t,n),r),console.log(`Review folder: ${i.reviewDir}`),i}function vU(e){e!==0&&console.log(`Including ${e} prior review comment(s) in request.md.`)}import{execSync as Lg}from"node:child_process";import{execSync as Ug}from"node:child_process";function yU(){return Ug("git rev-parse --abbrev-ref HEAD",{encoding:"utf8"}).trim()}var XI="number,baseRefName,baseRefOid,headRefName,headRefOid";function QI(e){return Ug(e,{encoding:"utf8",stdio:["ignore","pipe","pipe"]})}function bU(e,t,r){let i=Yg();return i!==void 0?JSON.parse(QI(`gh pr view ${i} --json ${XI} -R ${e}/${t}`)):JSON.parse(QI(`gh pr list --state open --head ${r} --json ${XI} -R ${e}/${t}`))[0]}function e1(){let{org:e,repo:t}=et(),r=yU(),i=bU(e,t,r);return i||(console.error(`Error: No open pull request found for branch \`${r}\`. Open a PR for this branch before running \`assist review\`.`),process.exit(1)),{prNumber:i.number,baseRef:i.baseRefName,baseSha:i.baseRefOid,headRef:i.headRefName,headSha:i.headRefOid}}function t1(e){let{org:t,repo:r}=et();return Ug(`gh api repos/${t}/${r}/pulls/${e}/files --paginate --jq ".[].filename"`,{encoding:"utf8",maxBuffer:64*1024*1024}).trim().split(`
425
- `).filter(Boolean)}function r1(){let e=Lg("git rev-parse --abbrev-ref HEAD",{encoding:"utf8"}).trim(),t=Lg("git rev-parse HEAD",{encoding:"utf8"}).trim(),r=Lg("git rev-parse --short=7 HEAD",{encoding:"utf8"}).trim(),i=e1(),n=t1(i.prNumber),o=Zi(i.prNumber,i.baseSha,i.headSha);return{branch:e,sha:t,shortSha:r,prNumber:i.prNumber,baseRef:i.baseRef,baseSha:i.baseSha,headRef:i.headRef,headSha:i.headSha,changedFiles:n,diff:o}}function n1(){let e=r1();if(e.changedFiles.length>0)return e;console.error(`Error: PR #${e.prNumber} has no changed files \u2014 nothing to review.`),process.exit(1)}import*as o1 from"node:net";import{homedir as i1}from"node:os";import{basename as wU,join as Ot}from"node:path";var Ct=Ot(i1(),".assist","daemon");function $U(){let e=wU(i1()).replace(/[^\w.-]/g,"_");return String.raw`\\.\pipe\assist-sessions-daemon-${e}`}var rn={dir:Ct,socket:process.platform==="win32"?$U():Ot(Ct,"daemon.sock"),log:Ot(Ct,"daemon.log"),pid:Ot(Ct,"daemon.pid"),autoUpdatePaused:Ot(Ct,"auto-update-paused"),spawnLock:Ot(Ct,"spawn.lock"),hooksSettings:Ot(Ct,"hooks-settings.json"),viewerSize:Ot(Ct,"viewer-size.json")};function Et(){return new Promise((e,t)=>{let r=o1.connect(rn.socket);r.once("connect",()=>e(r)),r.once("error",t)})}function nn(e,t){let r="";e.on("data",i=>{r+=i.toString("utf8");let n=r.indexOf(`
424
+ `}import{homedir as rU}from"node:os";import{basename as nU,join as Di}from"node:path";function GI(e,t){let r=Di(rU(),".assist","reviews",nU(e),t);return{reviewDir:r,requestPath:Di(r,"request.md"),claudePath:Di(r,"claude.md"),codexPath:Di(r,"codex.md"),synthesisPath:Di(r,"synthesis.md")}}import{execSync as sU}from"node:child_process";import{execFileSync as iU}from"node:child_process";var oU="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 JI(e,t,r){let i=iU("gh",["api","graphql","-f",`query=${oU}`,"-F",`owner=${e}`,"-F",`repo=${t}`,"-F",`prNumber=${r}`],{encoding:"utf8"}),n=JSON.parse(i),o=new Map,s=new Set;for(let a of n.data.repository.pullRequest.reviewThreads.nodes){a.isResolved&&s.add(a.id);for(let l of a.comments.nodes)o.set(l.databaseId,a.id)}return{threadMap:o,resolvedThreadIds:s}}function aU(e,t,r){let i=sU(`gh api --paginate repos/${e}/${t}/pulls/${r}/comments`,{encoding:"utf8",maxBuffer:67108864});return i.trim()?JSON.parse(i):[]}function WI(){let e=qi();if(e===null)return null;let{org:t,repo:r}=et(),i=aU(t,r,e);if(i.length===0)return[];let n=JI(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 lU,mkdirSync as cU,unlinkSync as uU,writeFileSync as dU}from"node:fs";function fU(e){for(let t of[e.claudePath,e.codexPath,e.synthesisPath])lU(t)&&uU(t)}function HI(e,t,r){cU(e.reviewDir,{recursive:!0}),r&&fU(e),dU(e.requestPath,t)}function YI(e,t,r){let i=GI(e,`${t.branch}-${t.shortSha}`),n=WI();return pU(n?.length??0),HI(i,KI(t,n),r),console.log(`Review folder: ${i.reviewDir}`),i}function pU(e){e!==0&&console.log(`Including ${e} prior review comment(s) in request.md.`)}import{execSync as Lg}from"node:child_process";import{execSync as Ug}from"node:child_process";function mU(){return Ug("git rev-parse --abbrev-ref HEAD",{encoding:"utf8"}).trim()}var XI="number,baseRefName,baseRefOid,headRefName,headRefOid";function QI(e){return Ug(e,{encoding:"utf8",stdio:["ignore","pipe","pipe"]})}function hU(e,t,r){let i=Yg();return i!==void 0?JSON.parse(QI(`gh pr view ${i} --json ${XI} -R ${e}/${t}`)):JSON.parse(QI(`gh pr list --state open --head ${r} --json ${XI} -R ${e}/${t}`))[0]}function e1(){let{org:e,repo:t}=et(),r=mU(),i=hU(e,t,r);return i||(console.error(`Error: No open pull request found for branch \`${r}\`. Open a PR for this branch before running \`assist review\`.`),process.exit(1)),{prNumber:i.number,baseRef:i.baseRefName,baseSha:i.baseRefOid,headRef:i.headRefName,headSha:i.headRefOid}}function t1(e){let{org:t,repo:r}=et();return Ug(`gh api repos/${t}/${r}/pulls/${e}/files --paginate --jq ".[].filename"`,{encoding:"utf8",maxBuffer:64*1024*1024}).trim().split(`
425
+ `).filter(Boolean)}function r1(){let e=Lg("git rev-parse --abbrev-ref HEAD",{encoding:"utf8"}).trim(),t=Lg("git rev-parse HEAD",{encoding:"utf8"}).trim(),r=Lg("git rev-parse --short=7 HEAD",{encoding:"utf8"}).trim(),i=e1(),n=t1(i.prNumber),o=Zi(i.prNumber,i.baseSha,i.headSha);return{branch:e,sha:t,shortSha:r,prNumber:i.prNumber,baseRef:i.baseRef,baseSha:i.baseSha,headRef:i.headRef,headSha:i.headSha,changedFiles:n,diff:o}}function n1(){let e=r1();if(e.changedFiles.length>0)return e;console.error(`Error: PR #${e.prNumber} has no changed files \u2014 nothing to review.`),process.exit(1)}import*as o1 from"node:net";import{homedir as i1}from"node:os";import{basename as gU,join as Ot}from"node:path";var Ct=Ot(i1(),".assist","daemon");function vU(){let e=gU(i1()).replace(/[^\w.-]/g,"_");return String.raw`\\.\pipe\assist-sessions-daemon-${e}`}var rn={dir:Ct,socket:process.platform==="win32"?vU():Ot(Ct,"daemon.sock"),log:Ot(Ct,"daemon.log"),pid:Ot(Ct,"daemon.pid"),autoUpdatePaused:Ot(Ct,"auto-update-paused"),spawnLock:Ot(Ct,"spawn.lock"),hooksSettings:Ot(Ct,"hooks-settings.json"),viewerSize:Ot(Ct,"viewer-size.json")};function Et(){return new Promise((e,t)=>{let r=o1.connect(rn.socket);r.once("connect",()=>e(r)),r.once("error",t)})}function nn(e,t){let r="";e.on("data",i=>{r+=i.toString("utf8");let n=r.indexOf(`
426
426
  `);for(;n!==-1;)t(r.slice(0,n)),r=r.slice(n+1),n=r.indexOf(`
427
- `)})}function xU(e,t){try{let r=JSON.parse(e);return r.type==="error"&&(r.message??"").includes(t)?{kind:"error",message:r.message??`${t} failed`}:r.type!=="created"||!r.sessionId?null:{kind:"created",sessionId:r.sessionId}}catch{return null}}function yl(e){return new Promise((t,r)=>{Et().then(i=>{let n=!1,o=(s,a)=>{n||(n=!0,i.destroy(),s?r(s):t(a))};nn(i,s=>{let a=xU(s,e.type);a&&(a.kind==="error"?o(new Error(a.message)):o(void 0,a.sessionId))}),i.on("error",s=>o(s)),i.on("close",()=>o(new Error("daemon closed before the session was created"))),i.write(`${JSON.stringify(e)}
428
- `)},r)})}function s1(e,t,r){return yl({type:"create",prompt:e,cwd:t,inPlace:r?.inPlace===!0,launchedFrom:r?.launchedFrom??process.env.ASSIST_SESSION_ID})}async function bl(e,t){if(process.env.ASSIST_SESSION==="1")try{await t(),console.log(`Started ${e}.`)}catch(r){console.error(`Warning: could not start ${e}: ${r instanceof Error?r.message:String(r)}`)}}function wl(e){return bl(`a Slack announce session for PR #${e}`,()=>s1(`/prs-slack ${e} --no-confirm`,process.cwd(),{inPlace:!0}))}import{readFileSync as VU}from"node:fs";function a1(e,t,r){return yl({type:"create-assist",assistArgs:e,cwd:t,inPlace:r?.inPlace===!0,launchedFrom:r?.launchedFrom??process.env.ASSIST_SESSION_ID})}function l1(e,t){let r=["review-pr-comments",String(e)];return t&&r.push("--announce"),bl(`an Address Comments session for PR #${e}`,()=>a1(r,process.cwd(),{inPlace:!0}))}async function c1(e,t,r){let i=t.posted>0&&t.submitted;if(r.addressComments&&i){await l1(e,r.announce);return}r.announce&&await wl(e)}import{appendFileSync as SU}from"node:fs";function $l(e){let t=`${new Date().toISOString()} [${process.pid}] ${e}`;try{SU(rn.log,`${t}
429
- `)}catch{}}var _U=500;function u1(e){return new Promise((t,r)=>{Et().then(i=>{let n=setTimeout(()=>{i.destroy(),r(new Error("timed out writing to daemon socket"))},_U);i.on("error",o=>{clearTimeout(n),r(o)}),i.write(`${JSON.stringify(e)}
430
- `,()=>{clearTimeout(n),i.end(),t()})},r)})}var kU=1e3;function d1(e){return new Promise((t,r)=>{Et().then(i=>{let n=!1,o=a=>{n||(n=!0,clearTimeout(s),i.destroy(),a?r(a):t())},s=setTimeout(()=>o(new Error("timed out awaiting daemon ack")),kU);nn(i,a=>{IU(a)&&o()}),i.on("error",a=>o(a)),i.on("close",()=>o(new Error("daemon closed before acknowledging"))),i.write(`${JSON.stringify(e)}
431
- `)},r)})}function IU(e){try{return JSON.parse(e).type==="ack"}catch{return!1}}import*as f1 from"node:readline";async function p1(){let e=f1.createInterface({input:process.stdin,output:process.stdout,terminal:!1}),t="";for await(let r of e)t+=r;return t}async function m1(){if(!process.stdin.isTTY)try{return JSON.parse(await p1()).session_id}catch{return}}var Mg=3,PU=100;async function Fg(e,t={}){let r=process.env.ASSIST_SESSION_ID;if(RU(e,r,t.source),!r)return;let i=CU(r,e,t,await m1());t.ack?await EU(r,e,i):await OU(r,e,i)}function CU(e,t,r,i){let n={type:"set-status",sessionId:e,status:t};return i&&(n.claudeSessionId=i),r.source&&(n.source=r.source),r.ack&&(n.ack=!0),n}async function OU(e,t,r){try{await u1(r)}catch(i){$l(`set-status best-effort send failed: id=${e} status=${t}: ${h1(i)}`)}}async function EU(e,t,r){for(let i=1;i<=Mg;i++)try{await d1(r);return}catch(n){if(i<Mg){await TU(PU);continue}$l(`set-status ack'd delivery failed after ${Mg} attempts: id=${e} status=${t}: ${h1(n)}`)}}function TU(e){return new Promise(t=>setTimeout(t,e))}function h1(e){return e instanceof Error?e.message:String(e)}function RU(e,t,r){$l(`set-status hook fired: id=${t??"none"} status=${e}${r?` source=${r}`:""}`)}var NU="mutation($prId: ID!, $body: String!, $path: String!, $line: Int!) { addPullRequestReviewThread(input: { pullRequestId: $prId, body: $body, path: $path, line: $line, side: RIGHT }) { thread { id } } }",AU="mutation($prId: ID!, $body: String!, $path: String!, $line: Int!, $startLine: Int!) { addPullRequestReviewThread(input: { pullRequestId: $prId, body: $body, path: $path, line: $line, startLine: $startLine, side: RIGHT, startSide: RIGHT }) { thread { id } } }";function zU(e){let t;try{t=JSON.parse(e)}catch{throw new Error(`GitHub returned an unparseable response: ${e}`)}let r=t.data?.addPullRequestReviewThread?.thread?.id;if(typeof r!="string"||r.length===0)throw new Error("GitHub did not create a review thread (no thread id returned); the line is likely outside the PR diff.")}function g1(e){let{startLine:t,...r}=e,i=t===void 0?dn(NU,r):dn(AU,{...r,startLine:t});zU(i)}import{randomUUID as UU}from"node:crypto";function v1(e){return e.map((t,r)=>{let i=t.quote.split(`
427
+ `)})}function yU(e,t){try{let r=JSON.parse(e);return r.type==="error"&&(r.message??"").includes(t)?{kind:"error",message:r.message??`${t} failed`}:r.type!=="created"||!r.sessionId?null:{kind:"created",sessionId:r.sessionId}}catch{return null}}function yl(e){return new Promise((t,r)=>{Et().then(i=>{let n=!1,o=(s,a)=>{n||(n=!0,i.destroy(),s?r(s):t(a))};nn(i,s=>{let a=yU(s,e.type);a&&(a.kind==="error"?o(new Error(a.message)):o(void 0,a.sessionId))}),i.on("error",s=>o(s)),i.on("close",()=>o(new Error("daemon closed before the session was created"))),i.write(`${JSON.stringify(e)}
428
+ `)},r)})}function s1(e,t,r){return yl({type:"create",prompt:e,cwd:t,inPlace:r?.inPlace===!0,launchedFrom:r?.launchedFrom??process.env.ASSIST_SESSION_ID})}async function bl(e,t){if(process.env.ASSIST_SESSION==="1")try{await t(),console.log(`Started ${e}.`)}catch(r){console.error(`Warning: could not start ${e}: ${r instanceof Error?r.message:String(r)}`)}}function wl(e){return bl(`a Slack announce session for PR #${e}`,()=>s1(`/prs-slack ${e} --no-confirm`,process.cwd(),{inPlace:!0}))}import{readFileSync as FU}from"node:fs";function a1(e,t,r){return yl({type:"create-assist",assistArgs:e,cwd:t,inPlace:r?.inPlace===!0,launchedFrom:r?.launchedFrom??process.env.ASSIST_SESSION_ID})}function l1(e,t){let r=["review-pr-comments",String(e)];return t&&r.push("--announce"),bl(`an Address Comments session for PR #${e}`,()=>a1(r,process.cwd(),{inPlace:!0}))}async function c1(e,t,r){let i=t.posted>0&&t.submitted;if(r.addressComments&&i){await l1(e,r.announce);return}r.announce&&await wl(e)}import{appendFileSync as bU}from"node:fs";function $l(e){let t=`${new Date().toISOString()} [${process.pid}] ${e}`;try{bU(rn.log,`${t}
429
+ `)}catch{}}var wU=500;function u1(e){return new Promise((t,r)=>{Et().then(i=>{let n=setTimeout(()=>{i.destroy(),r(new Error("timed out writing to daemon socket"))},wU);i.on("error",o=>{clearTimeout(n),r(o)}),i.write(`${JSON.stringify(e)}
430
+ `,()=>{clearTimeout(n),i.end(),t()})},r)})}var $U=1e3;function d1(e){return new Promise((t,r)=>{Et().then(i=>{let n=!1,o=a=>{n||(n=!0,clearTimeout(s),i.destroy(),a?r(a):t())},s=setTimeout(()=>o(new Error("timed out awaiting daemon ack")),$U);nn(i,a=>{xU(a)&&o()}),i.on("error",a=>o(a)),i.on("close",()=>o(new Error("daemon closed before acknowledging"))),i.write(`${JSON.stringify(e)}
431
+ `)},r)})}function xU(e){try{return JSON.parse(e).type==="ack"}catch{return!1}}import*as f1 from"node:readline";async function p1(){let e=f1.createInterface({input:process.stdin,output:process.stdout,terminal:!1}),t="";for await(let r of e)t+=r;return t}async function m1(){if(!process.stdin.isTTY)try{return JSON.parse(await p1()).session_id}catch{return}}var Mg=3,SU=100;async function Fg(e,t={}){let r=process.env.ASSIST_SESSION_ID;if(CU(e,r,t.source),!r)return;let i=_U(r,e,t,await m1());t.ack?await IU(r,e,i):await kU(r,e,i)}function _U(e,t,r,i){let n={type:"set-status",sessionId:e,status:t};return i&&(n.claudeSessionId=i),r.source&&(n.source=r.source),r.ack&&(n.ack=!0),n}async function kU(e,t,r){try{await u1(r)}catch(i){$l(`set-status best-effort send failed: id=${e} status=${t}: ${h1(i)}`)}}async function IU(e,t,r){for(let i=1;i<=Mg;i++)try{await d1(r);return}catch(n){if(i<Mg){await PU(SU);continue}$l(`set-status ack'd delivery failed after ${Mg} attempts: id=${e} status=${t}: ${h1(n)}`)}}function PU(e){return new Promise(t=>setTimeout(t,e))}function h1(e){return e instanceof Error?e.message:String(e)}function CU(e,t,r){$l(`set-status hook fired: id=${t??"none"} status=${e}${r?` source=${r}`:""}`)}var OU="mutation($prId: ID!, $body: String!, $path: String!, $line: Int!) { addPullRequestReviewThread(input: { pullRequestId: $prId, body: $body, path: $path, line: $line, side: RIGHT }) { thread { id } } }",EU="mutation($prId: ID!, $body: String!, $path: String!, $line: Int!, $startLine: Int!) { addPullRequestReviewThread(input: { pullRequestId: $prId, body: $body, path: $path, line: $line, startLine: $startLine, side: RIGHT, startSide: RIGHT }) { thread { id } } }";function TU(e){let t;try{t=JSON.parse(e)}catch{throw new Error(`GitHub returned an unparseable response: ${e}`)}let r=t.data?.addPullRequestReviewThread?.thread?.id;if(typeof r!="string"||r.length===0)throw new Error("GitHub did not create a review thread (no thread id returned); the line is likely outside the PR diff.")}function g1(e){let{startLine:t,...r}=e,i=t===void 0?dn(OU,r):dn(EU,{...r,startLine:t});TU(i)}import{randomUUID as AU}from"node:crypto";function v1(e){return e.map((t,r)=>{let i=t.quote.split(`
432
432
  `).map(n=>` > ${n}`).join(`
433
433
  `);return`${r+1}. On:
434
434
  ${i}
435
435
  Comment: ${t.note}
436
436
  `})}function y1(e,t,r){console.error(`${e} rejected${t.reason?`: ${t.reason}`:"."}`);let i=t.comments??[];if(i.length>0){console.error(`
437
437
  The reviewer left ${i.length} comment${i.length===1?"":"s"} on the preview. Address each one, then re-run this command:
438
- `);for(let n of v1(i))console.error(n)}r&&console.error(r),process.exit(1)}function b1(e){if(Array.isArray(e))return e.flatMap(t=>{let{path:r,alt:i,group:n}=t??{};if(typeof r!="string"||r==="")return[];let o={path:r,alt:typeof i=="string"?i:""};return[typeof n=="string"&&n!==""?{...o,group:n}:o]})}function w1(e){if(Array.isArray(e))return e.flatMap(t=>{let{id:r,ticked:i,comment:n,notes:o}=t??{};if(typeof r!="string")return[];let s=DU(o);return[{id:r,ticked:i===!0,...typeof n=="string"&&n!==""?{comment:n}:{},...s.length>0?{notes:s}:{}}]})}function DU(e){return Array.isArray(e)?e.flatMap(t=>{let{id:r,comment:i}=t??{};return typeof r!="string"||typeof i!="string"||!i?[]:[{id:r,comment:i}]}):[]}function jU(e){let t=e;if(!(typeof t?.topLeft!="string"||typeof t.bottomRight!="string"))return{topLeft:t.topLeft,bottomRight:t.bottomRight}}function $1(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:b1(e.screenshots),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,autostart:e.autostart===!0,selection:jU(e.selection),checklist:w1(e.checklist),dismissed:e.dismissed===!0}}function x1(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=$1(r);return i?{kind:"decision",decision:i}:null}catch{return null}}function S1(e){return new Promise((t,r)=>{Et().then(i=>{let n=!1,o=(s,a)=>{n||(n=!0,i.destroy(),s?r(s):t(a))};nn(i,s=>{let a=x1(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})}
439
- `)},r)})}async function _1(e,t,r={}){console.log("Awaiting your approval in the assist web UI preview pane\u2026");let i;try{i=await S1(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&&y1(e,i,r.rejectionAdvice),i}async function k1(e,t,r){let i=process.env.ASSIST_SESSION_ID;process.env.ASSIST_SESSION!=="1"||!i||await _1("PR comment preview",{sessionId:i,requestId:UU(),title:e,body:t,prNumber:r,kind:"pr-comment"})}function LU(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 I1(e){(!Number.isInteger(e)||e<1)&&(console.error("Error: Line must be a positive integer"),process.exit(1))}async function P1(e,t,r,i={}){let{startLine:n,skipPreview:o}=i;LU(r),I1(t),n!==void 0&&I1(n);let s=n!==void 0?`${n}-${t}`:`${t}`;o||await k1(`Comment on ${e}:${s}`,r,null);try{let a=Fi();g1({prId:a,body:r,path:e,line:t,startLine:n}),console.log(`Added review comment on ${e}:${s}`)}catch(a){throw Mi(a)&&(console.error("Error: GitHub CLI (gh) is not installed."),console.error("Install it from https://cli.github.com/"),process.exit(1)),a}}var C1="the reviewer";function on(e){return e.replace(/\bclaude\b/gi,C1).replace(/\bopus\b/gi,C1)}function MU(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}`),on(t.join(`
440
- `))}async function O1(e){let t=0,r=0;for(let i of e){let n=MU(i);try{await P1(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 E1(e,t,r){return tr(on(Qe(e,t)),r)}var FU="mutation($prId: ID!, $body: String) { submitPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }";function qg(e){return Ji(FU,e)}function T1(e,t){return t.posted>0?qg(e):qU(e,t)?!0:rr(e)}function qU(e,t){return t.failed>0&&qg(e)}async function ZU(e){if(!e.prompt)return e.submit;await Fg("waiting");try{return await pr("Submit the pending review?",e.submit)}finally{await Fg("running")}}async function R1(e,t,r,i){let n=await O1(e),o=n.failed>0?`, ${n.failed} failed`:"";console.log(`Posted ${n.posted} comment(s)${o}.`);let s=Xt(t);if(n.posted===0&&s.length===0&&!i.ciFooter)return{posted:0,submitted:!1};if(await ZU(i)){let l=T1(E1(r,t,i.ciFooter),n);if(!l&&i.ciFooter)throw new Error("the review could not be submitted to the PR");return{posted:n.posted,submitted:l}}return console.log("Leaving the review unsubmitted."),{posted:n.posted,submitted:!1}}function BU(){try{return qi()}catch(e){return console.error(`Error: could not confirm which PR this tree is on: ${e instanceof Error?e.message:String(e)}`),null}}function N1(e){let t=BU();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)}function A1(e,t){let r=on(`${Qe(e)}
438
+ `);for(let n of v1(i))console.error(n)}r&&console.error(r),process.exit(1)}function b1(e){if(Array.isArray(e))return e.flatMap(t=>{let{path:r,alt:i,group:n}=t??{};if(typeof r!="string"||r==="")return[];let o={path:r,alt:typeof i=="string"?i:""};return[typeof n=="string"&&n!==""?{...o,group:n}:o]})}function w1(e){if(Array.isArray(e))return e.flatMap(t=>{let{id:r,ticked:i,comment:n,notes:o}=t??{};if(typeof r!="string")return[];let s=RU(o);return[{id:r,ticked:i===!0,...typeof n=="string"&&n!==""?{comment:n}:{},...s.length>0?{notes:s}:{}}]})}function RU(e){return Array.isArray(e)?e.flatMap(t=>{let{id:r,comment:i}=t??{};return typeof r!="string"||typeof i!="string"||!i?[]:[{id:r,comment:i}]}):[]}function NU(e){let t=e;if(!(typeof t?.topLeft!="string"||typeof t.bottomRight!="string"))return{topLeft:t.topLeft,bottomRight:t.bottomRight}}function $1(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:b1(e.screenshots),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,autostart:e.autostart===!0,selection:NU(e.selection),checklist:w1(e.checklist),dismissed:e.dismissed===!0}}function x1(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=$1(r);return i?{kind:"decision",decision:i}:null}catch{return null}}function S1(e){return new Promise((t,r)=>{Et().then(i=>{let n=!1,o=(s,a)=>{n||(n=!0,i.destroy(),s?r(s):t(a))};nn(i,s=>{let a=x1(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})}
439
+ `)},r)})}async function _1(e,t,r={}){console.log("Awaiting your approval in the assist web UI preview pane\u2026");let i;try{i=await S1(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&&y1(e,i,r.rejectionAdvice),i}async function k1(e,t,r){let i=process.env.ASSIST_SESSION_ID;process.env.ASSIST_SESSION!=="1"||!i||await _1("PR comment preview",{sessionId:i,requestId:AU(),title:e,body:t,prNumber:r,kind:"pr-comment"})}function zU(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 I1(e){(!Number.isInteger(e)||e<1)&&(console.error("Error: Line must be a positive integer"),process.exit(1))}async function P1(e,t,r,i={}){let{startLine:n,skipPreview:o}=i;zU(r),I1(t),n!==void 0&&I1(n);let s=n!==void 0?`${n}-${t}`:`${t}`;o||await k1(`Comment on ${e}:${s}`,r,null);try{let a=Fi();g1({prId:a,body:r,path:e,line:t,startLine:n}),console.log(`Added review comment on ${e}:${s}`)}catch(a){throw Mi(a)&&(console.error("Error: GitHub CLI (gh) is not installed."),console.error("Install it from https://cli.github.com/"),process.exit(1)),a}}var C1="the reviewer";function on(e){return e.replace(/\bclaude\b/gi,C1).replace(/\bopus\b/gi,C1)}function DU(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}`),on(t.join(`
440
+ `))}async function O1(e){let t=0,r=0;for(let i of e){let n=DU(i);try{await P1(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 E1(e,t,r){return tr(on(Qe(e,t)),r)}var jU="mutation($prId: ID!, $body: String) { submitPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }";function qg(e){return Ji(jU,e)}function T1(e,t){return t.posted>0?qg(e):UU(e,t)?!0:rr(e)}function UU(e,t){return t.failed>0&&qg(e)}async function LU(e){if(!e.prompt)return e.submit;await Fg("waiting");try{return await pr("Submit the pending review?",e.submit)}finally{await Fg("running")}}async function R1(e,t,r,i){let n=await O1(e),o=n.failed>0?`, ${n.failed} failed`:"";console.log(`Posted ${n.posted} comment(s)${o}.`);let s=Xt(t);if(n.posted===0&&s.length===0&&!i.ciFooter)return{posted:0,submitted:!1};if(await LU(i)){let l=T1(E1(r,t,i.ciFooter),n);if(!l&&i.ciFooter)throw new Error("the review could not be submitted to the PR");return{posted:n.posted,submitted:l}}return console.log("Leaving the review unsubmitted."),{posted:n.posted,submitted:!1}}function MU(){try{return qi()}catch(e){return console.error(`Error: could not confirm which PR this tree is on: ${e instanceof Error?e.message:String(e)}`),null}}function N1(e){let t=MU();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)}function A1(e,t){let r=on(`${Qe(e)}
441
441
 
442
- No findings were raised.`);rr(tr(r,t))}function z1(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 ")}var D1={posted:0,submitted:!1};async function KU(e,t,r){return r.prompt?pr(`Post ${t} to PR #${e}?`,!1):!0}async function GU(e,t,r){let i=VU(t,"utf8"),{inDiff:n,unanchored:o}=Ki(i,e),s=Xt(o);if(n.length===0&&s.length===0)return r.ciFooter?(A1(i,r.ciFooter),{posted:0,submitted:!0}):D1;let a=z1(n.length,s.length);return console.log(`Found PR #${e.prNumber} with ${a} to post.`),await KU(e.prNumber,a,r)?R1(n,o,i,r):(console.log("Skipped posting."),D1)}async function j1(e,t,r){if(!N1(t.prNumber))return;let i=await GU(t,e,r);await c1(t.prNumber,i,r)}import{mkdirSync as JU,writeFileSync as WU}from"node:fs";import{dirname as HU}from"node:path";var Vg="assist sessions set-status";function Zg(e){return`${Vg} running --source ${e}`}function YU(e){return`${Vg} waiting --source ${e}`}function Bg(e){return`${Vg} waiting --source ${e} --ack`}function Yt(e,t){let r=[{type:"command",command:e}];return[t==null?{hooks:r}:{matcher:t,hooks:r}]}var U1="AskUserQuestion",XU=`^(?!${U1}$).*`,QU={hooks:{UserPromptSubmit:Yt(Zg("prompt")),PreToolUse:[...Yt(YU("pretool"),U1),...Yt(Zg("pretool"),XU)],PostToolUse:Yt(Zg("posttool")),Stop:Yt(Bg("stop")),Notification:Yt(Bg("notification")),PermissionRequest:Yt(Bg("permission"))}};function L1(){let e=rn.hooksSettings;return JU(HU(e),{recursive:!0}),WU(e,JSON.stringify(QU,null,2)),e}import{spawn as eL}from"node:child_process";function M1(e,t,r={}){let{ASSIST_ACTIVITY_ID:i,CLAUDE_CODE_CHILD_SESSION:n,...o}=process.env,s=eL(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 sn(e,t={}){let r=["--settings",L1(),...tL(e,t)],i=t.permissionMode??(t.allowEdits?"auto":void 0);return i&&r.push("--permission-mode",i),M1("claude",r)}function tL(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 rL(e){return`You are helping the user apply fixes for a code review with each finding decided one at a time.
442
+ No findings were raised.`);rr(tr(r,t))}function z1(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 ")}var D1={posted:0,submitted:!1};async function qU(e,t,r){return r.prompt?pr(`Post ${t} to PR #${e}?`,!1):!0}async function ZU(e,t,r){let i=FU(t,"utf8"),{inDiff:n,unanchored:o}=Ki(i,e),s=Xt(o);if(n.length===0&&s.length===0)return r.ciFooter?(A1(i,r.ciFooter),{posted:0,submitted:!0}):D1;let a=z1(n.length,s.length);return console.log(`Found PR #${e.prNumber} with ${a} to post.`),await qU(e.prNumber,a,r)?R1(n,o,i,r):(console.log("Skipped posting."),D1)}async function j1(e,t,r){if(!N1(t.prNumber))return;let i=await ZU(t,e,r);await c1(t.prNumber,i,r)}import{mkdirSync as BU,writeFileSync as VU}from"node:fs";import{dirname as KU}from"node:path";var Vg="assist sessions set-status";function Zg(e){return`${Vg} running --source ${e}`}function GU(e){return`${Vg} waiting --source ${e}`}function Bg(e){return`${Vg} waiting --source ${e} --ack`}function Yt(e,t){let r=[{type:"command",command:e}];return[t==null?{hooks:r}:{matcher:t,hooks:r}]}var U1="AskUserQuestion",JU=`^(?!${U1}$).*`,WU={hooks:{UserPromptSubmit:Yt(Zg("prompt")),PreToolUse:[...Yt(GU("pretool"),U1),...Yt(Zg("pretool"),JU)],PostToolUse:Yt(Zg("posttool")),Stop:Yt(Bg("stop")),Notification:Yt(Bg("notification")),PermissionRequest:Yt(Bg("permission"))}};function L1(){let e=rn.hooksSettings;return BU(KU(e),{recursive:!0}),VU(e,JSON.stringify(WU,null,2)),e}import{spawn as HU}from"node:child_process";function M1(e,t,r={}){let{ASSIST_ACTIVITY_ID:i,CLAUDE_CODE_CHILD_SESSION:n,...o}=process.env,s=HU(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 sn(e,t={}){let r=["--settings",L1(),...YU(e,t)],i=t.permissionMode??(t.allowEdits?"auto":void 0);return i&&r.push("--permission-mode",i),M1("claude",r)}function YU(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 XU(e){return`You are helping the user apply fixes for a code review with each finding decided one at a time.
443
443
 
444
444
  Read ${e}. It contains a list of findings under the \`## Findings\` heading. Each finding is a block in this exact format:
445
445
 
@@ -463,7 +463,7 @@ Important constraints:
463
463
  - Do not stage, commit, or push any changes. Leave all code edits unstaged in the working tree.
464
464
  - Do not post anything to a PR.
465
465
  - Only modify ${e} by removing the blocks for findings the user chose to apply. Do not edit the wording of any remaining finding block.
466
- - When every non-already-raised finding has been decided, briefly summarise what was applied vs skipped and exit.`}async function F1(e){let{done:t}=sn(rL(e),{allowEdits:!0});await t}function nL(e){return`/bug add each finding in ${e} as a phase
466
+ - When every non-already-raised finding has been decided, briefly summarise what was applied vs skipped and exit.`}async function F1(e){let{done:t}=sn(XU(e),{allowEdits:!0});await t}function QU(e){return`/bug add each finding in ${e} as a phase
467
467
 
468
468
  Read ${e}. It contains a list of findings under the \`## Findings\` heading, each in a \`### Finding:\` block with Severity, Source, Location, Impact, and Recommendation fields.
469
469
 
@@ -475,7 +475,7 @@ File ONE bug backlog item covering the review findings:
475
475
  Important constraints:
476
476
  - Do not edit ${e} \u2014 leave it untouched.
477
477
  - Do not post anything to a PR.
478
- - Do not stage, commit, or push any changes.`}async function q1(e){let{done:t}=sn(nL(e),{allowEdits:!0});await t}function iL(e){return`You are refining a code review synthesis with the user.
478
+ - Do not stage, commit, or push any changes.`}async function q1(e){let{done:t}=sn(QU(e),{allowEdits:!0});await t}function eL(e){return`You are refining a code review synthesis with the user.
479
479
 
480
480
  Read ${e} and walk the user through each finding one at a time. Before asking the user what to do with a finding, do some investigation so you can give an informed opinion:
481
481
  - Read the referenced file/lines (use the Location field) to confirm the issue is real and current.
@@ -500,5 +500,5 @@ Each finding block must use this exact format so it parses correctly:
500
500
 
501
501
  User-supplied findings should use Source: \`confirmed\`. Use Location \`n/a\` only when the finding is not tied to a specific line.
502
502
 
503
- Do not post anything to a PR; only edit ${e}. When the user is done, exit.`}async function Z1(e){let{done:t}=sn(iL(e),{allowEdits:!0});await t}function oL(e){return e.backlog?q1:e.apply?F1:e.refine?Z1:null}async function B1(e,t,r){let i=oL(r);if(!i){await j1(e,t,{prompt:r.prompt,submit:r.submit,addressComments:r.addressComments,announce:r.announce,ciFooter:r.ciFooter});return}await i(e),r.announce&&await wl(t.prNumber)}function V1(e,t,r){return B1(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,ciFooter:r.ci?.footer})}async function K1(e,t){let r=n1(),i=YI(e,r,t.force??!1);Wy(i.reviewDir);let n=await ZI(i,{verbose:t.verbose??!1,models:t.ci?.models,strict:t.ci!==void 0}),o=n.ok;!o&&t.ci&&Cv(n.failures,t.ci),o&&t.ci&&kv(i.synthesisPath,r,t.ci.summaryPath,n.slots),o&&await V1(i.synthesisPath,r,t),console.log(`Done. Review folder: ${i.reviewDir}`)}function Kg(e){return`\`${e.harness}:${e.model}\``}function G1(e){return["---","",`Models: reviewer 1 ${Kg(e.claude)}, reviewer 2 ${Kg(e.codex)}, synthesis ${Kg(e.synthesis)}.`,"","To re-run this review, mark the PR as draft and then ready for review again."].join(`
504
- `)}function J1(e){let{GITHUB_SERVER_URL:t,GITHUB_REPOSITORY:r,GITHUB_RUN_ID:i}=e;if(!(!t||!r||!i))return`${t}/${r}/actions/runs/${i}`}function sL(e){return{ANTHROPIC_DEFAULT_OPUS_MODEL:e,ANTHROPIC_DEFAULT_SONNET_MODEL:e,ANTHROPIC_DEFAULT_HAIKU_MODEL:e,CLAUDE_CODE_SUBAGENT_MODEL:e}}function aL(e,t,r){return e.anthropicKind==="foundry"&&t.auth.kind==="key"?{CLAUDE_CODE_USE_FOUNDRY:"1",ANTHROPIC_FOUNDRY_BASE_URL:e.anthropic,ANTHROPIC_FOUNDRY_API_KEY:r}:{ANTHROPIC_BASE_URL:e.anthropic,ANTHROPIC_AUTH_TOKEN:r}}function lL(e,t,r,i){return e.harness==="codex"?ul(r.responses,i,e.model):{args:["--model",e.model],env:{...aL(r,t,i),CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:"1",...sL(e.model)},model:e.model}}function W1(e,t,r){let i=(n,o)=>({harness:n.harness,label:o,override:lL(n,e,t,r)});return{claude:i(e.slots.claude,"reviewer-1"),codex:i(e.slots.codex,"reviewer-2"),synthesis:i(e.slots.synthesis,"synthesis")}}var H1=["REVIEW_CI_PROVIDER","REVIEW_CI_BASE_URL","REVIEW_CI_REVIEWER_1","REVIEW_CI_REVIEWER_2","REVIEW_CI_SYNTHESIS"];var ji="REVIEW_CI_API_KEY",Y1=["litellm","foundry"],Gg=["claude","codex"];function X1(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 REVIEW_CI_PROVIDER "${e}" (expected one of: ${Y1.join(", ")})`)}import{readFileSync as cL}from"node:fs";function Q1(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(cL(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 uL(e){return Gg.includes(e)}function eP(e,t){let r=t.indexOf(":"),i=t.slice(0,r).trim(),n=t.slice(r+1).trim();return r===-1||!uL(i)||!n?`${e} "${t}" must be ${Gg.map(o=>`${o}:<model>`).join(" or ")}`:{harness:i,model:n}}function xl(e,t){return e==="foundry"&&t("REVIEW_CI_AZURE_CLIENT_ID")?["REVIEW_CI_AZURE_CLIENT_ID","REVIEW_CI_AZURE_TENANT_ID"]:[ji]}function tP(e,t){return xl(e,t).includes(ji)?{kind:"key",apiKey:t(ji)}:{kind:"entra",clientId:t("REVIEW_CI_AZURE_CLIENT_ID"),tenantId:t("REVIEW_CI_AZURE_TENANT_ID")}}var dL={claude:"REVIEW_CI_REVIEWER_1",codex:"REVIEW_CI_REVIEWER_2",synthesis:"REVIEW_CI_SYNTHESIS"};function rP(e){let t=s=>e[s]?.trim()??"",r=t("REVIEW_CI_PROVIDER"),i=[...H1,...xl(r,t)].filter(s=>!t(s));if(i.length>0)return{config:null,errors:i.map(s=>`${s} is not set`)};let n=Object.entries(dL).map(([s,a])=>[s,eP(a,t(a))]),o=n.flatMap(([,s])=>typeof s=="string"?[s]:[]);return o.length>0?{config:null,errors:o}:{config:{provider:r,baseUrl:t("REVIEW_CI_BASE_URL").replace(/\/+$/,""),slots:Object.fromEntries(n),auth:tP(r,t)},errors:o}}var Sl="https://cognitiveservices.azure.com";var nP=3e4;async function iP(e,t){if(!e.ok){let r=(await e.text()).trim().slice(0,300);throw new Error(`${t}: HTTP ${e.status}${r?`: ${r}`:""}`)}return await e.json()}async function fL(e,t){let r=new URL(e);r.searchParams.set("audience","api://AzureADTokenExchange");let i=await fetch(r,{headers:{Authorization:`bearer ${t}`},signal:AbortSignal.timeout(nP)}),n=await iP(i,"GitHub OIDC token request failed");if(!n.value)throw new Error("GitHub OIDC token response had no value");return n.value}async function oP(e,t,r){let i=await fL(r.requestUrl,r.requestToken),n=await fetch(`https://login.microsoftonline.com/${encodeURIComponent(t)}/oauth2/v2.0/token`,{method:"POST",body:new URLSearchParams({grant_type:"client_credentials",client_id:e,scope:`${Sl}/.default`,client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer",client_assertion:i}),signal:AbortSignal.timeout(nP)}),o=await iP(n,`Entra token exchange for client ${e} failed`);if(!o.access_token)throw new Error("Entra token response had no access_token");return o.access_token}import{execFileSync as pL}from"node:child_process";function sP(e){try{return pL("az",["account","get-access-token","--resource",Sl,"--tenant",e,"--query","accessToken","-o","tsv"],{encoding:"utf8",stdio:["ignore","pipe","pipe"],shell:process.platform==="win32"}).trim()}catch(t){let r=t.stderr?.trim();throw new Error(`az account get-access-token failed for tenant ${e}${r?`: ${r}`:""}; run az login --tenant ${e}`)}}async function aP(e,t){if(e.kind==="key")return e.apiKey;let r=t.ACTIONS_ID_TOKEN_REQUEST_URL,i=t.ACTIONS_ID_TOKEN_REQUEST_TOKEN;if(r&&i){let n=await oP(e.clientId,e.tenantId,{requestUrl:r,requestToken:i});return console.log(`::add-mask::${n}`),n}if(t.GITHUB_ACTIONS)throw new Error("No GitHub OIDC token endpoint; give the job the id-token: write permission");return sP(e.tenantId)}async function mL(e){let{config:t,errors:r}=rP(e);if(!t)throw new Error(r.join("; "));let i=X1(t.provider,t.baseUrl),n=new Set(Object.values(t.slots).map(s=>s.harness));for(let s of n)if(!an(s))throw new Error(`${s} is not on PATH`);let o=await aP(t.auth,e);Hg(Q1(e)),await K1(process.cwd(),{prompt:!1,submit:!0,force:!0,verbose:!0,ci:{models:W1(t,i,o),summaryPath:e.GITHUB_STEP_SUMMARY,footer:G1(t.slots),runUrl:J1(e)}})}try{await mL(process.env)}catch(e){console.error(`review-ci: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}export{mL as reviewCiReview};
503
+ Do not post anything to a PR; only edit ${e}. When the user is done, exit.`}async function Z1(e){let{done:t}=sn(eL(e),{allowEdits:!0});await t}function tL(e){return e.backlog?q1:e.apply?F1:e.refine?Z1:null}async function B1(e,t,r){let i=tL(r);if(!i){await j1(e,t,{prompt:r.prompt,submit:r.submit,addressComments:r.addressComments,announce:r.announce,ciFooter:r.ciFooter});return}await i(e),r.announce&&await wl(t.prNumber)}function V1(e,t,r){return B1(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,ciFooter:r.ci?.footer})}async function K1(e,t){let r=n1(),i=YI(e,r,t.force??!1);Wy(i.reviewDir);let n=await ZI(i,{verbose:t.verbose??!1,models:t.ci?.models,strict:t.ci!==void 0}),o=n.ok;!o&&t.ci&&Cv(n.failures,t.ci),o&&t.ci&&kv(i.synthesisPath,r,t.ci.summaryPath,n.slots),o&&await V1(i.synthesisPath,r,t),console.log(`Done. Review folder: ${i.reviewDir}`)}function Kg(e){return`\`${e.harness}:${e.model}\``}function G1(e){return["---","",`Models: reviewer 1 ${Kg(e.claude)}, reviewer 2 ${Kg(e.codex)}, synthesis ${Kg(e.synthesis)}.`,"","To re-run this review, mark the PR as draft and then ready for review again."].join(`
504
+ `)}function J1(e){let{GITHUB_SERVER_URL:t,GITHUB_REPOSITORY:r,GITHUB_RUN_ID:i}=e;if(!(!t||!r||!i))return`${t}/${r}/actions/runs/${i}`}function rL(e){return{ANTHROPIC_DEFAULT_OPUS_MODEL:e,ANTHROPIC_DEFAULT_SONNET_MODEL:e,ANTHROPIC_DEFAULT_HAIKU_MODEL:e,CLAUDE_CODE_SUBAGENT_MODEL:e}}function nL(e,t,r){return e.anthropicKind==="foundry"&&t.auth.kind==="key"?{CLAUDE_CODE_USE_FOUNDRY:"1",ANTHROPIC_FOUNDRY_BASE_URL:e.anthropic,ANTHROPIC_FOUNDRY_API_KEY:r}:{ANTHROPIC_BASE_URL:e.anthropic,ANTHROPIC_AUTH_TOKEN:r}}function iL(e,t,r,i){return e.harness==="codex"?ul(r.responses,i,e.model):{args:["--model",e.model],env:{...nL(r,t,i),CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:"1",...rL(e.model)},model:e.model}}function W1(e,t,r){let i=(n,o)=>({harness:n.harness,label:o,override:iL(n,e,t,r)});return{claude:i(e.slots.claude,"reviewer-1"),codex:i(e.slots.codex,"reviewer-2"),synthesis:i(e.slots.synthesis,"synthesis")}}var H1=["REVIEW_CI_PROVIDER","REVIEW_CI_BASE_URL","REVIEW_CI_REVIEWER_1","REVIEW_CI_REVIEWER_2","REVIEW_CI_SYNTHESIS"];var ji="REVIEW_CI_API_KEY",Y1=["litellm","foundry"],Gg=["claude","codex"];function X1(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 REVIEW_CI_PROVIDER "${e}" (expected one of: ${Y1.join(", ")})`)}import{readFileSync as oL}from"node:fs";function Q1(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(oL(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 sL(e){return Gg.includes(e)}function eP(e,t){let r=t.indexOf(":"),i=t.slice(0,r).trim(),n=t.slice(r+1).trim();return r===-1||!sL(i)||!n?`${e} "${t}" must be ${Gg.map(o=>`${o}:<model>`).join(" or ")}`:{harness:i,model:n}}function xl(e,t){return e==="foundry"&&t("REVIEW_CI_AZURE_CLIENT_ID")?["REVIEW_CI_AZURE_CLIENT_ID","REVIEW_CI_AZURE_TENANT_ID"]:[ji]}function tP(e,t){return xl(e,t).includes(ji)?{kind:"key",apiKey:t(ji)}:{kind:"entra",clientId:t("REVIEW_CI_AZURE_CLIENT_ID"),tenantId:t("REVIEW_CI_AZURE_TENANT_ID")}}var aL={claude:"REVIEW_CI_REVIEWER_1",codex:"REVIEW_CI_REVIEWER_2",synthesis:"REVIEW_CI_SYNTHESIS"};function rP(e){let t=s=>e[s]?.trim()??"",r=t("REVIEW_CI_PROVIDER"),i=[...H1,...xl(r,t)].filter(s=>!t(s));if(i.length>0)return{config:null,errors:i.map(s=>`${s} is not set`)};let n=Object.entries(aL).map(([s,a])=>[s,eP(a,t(a))]),o=n.flatMap(([,s])=>typeof s=="string"?[s]:[]);return o.length>0?{config:null,errors:o}:{config:{provider:r,baseUrl:t("REVIEW_CI_BASE_URL").replace(/\/+$/,""),slots:Object.fromEntries(n),auth:tP(r,t)},errors:o}}var Sl="https://cognitiveservices.azure.com";var nP=3e4;async function iP(e,t){if(!e.ok){let r=(await e.text()).trim().slice(0,300);throw new Error(`${t}: HTTP ${e.status}${r?`: ${r}`:""}`)}return await e.json()}async function lL(e,t){let r=new URL(e);r.searchParams.set("audience","api://AzureADTokenExchange");let i=await fetch(r,{headers:{Authorization:`bearer ${t}`},signal:AbortSignal.timeout(nP)}),n=await iP(i,"GitHub OIDC token request failed");if(!n.value)throw new Error("GitHub OIDC token response had no value");return n.value}async function oP(e,t,r){let i=await lL(r.requestUrl,r.requestToken),n=await fetch(`https://login.microsoftonline.com/${encodeURIComponent(t)}/oauth2/v2.0/token`,{method:"POST",body:new URLSearchParams({grant_type:"client_credentials",client_id:e,scope:`${Sl}/.default`,client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer",client_assertion:i}),signal:AbortSignal.timeout(nP)}),o=await iP(n,`Entra token exchange for client ${e} failed`);if(!o.access_token)throw new Error("Entra token response had no access_token");return o.access_token}import{execFileSync as cL}from"node:child_process";function sP(e){try{return cL("az",["account","get-access-token","--resource",Sl,"--tenant",e,"--query","accessToken","-o","tsv"],{encoding:"utf8",stdio:["ignore","pipe","pipe"],shell:process.platform==="win32"}).trim()}catch(t){let r=t.stderr?.trim();throw new Error(`az account get-access-token failed for tenant ${e}${r?`: ${r}`:""}; run az login --tenant ${e}`)}}async function aP(e,t){if(e.kind==="key")return e.apiKey;let r=t.ACTIONS_ID_TOKEN_REQUEST_URL,i=t.ACTIONS_ID_TOKEN_REQUEST_TOKEN;if(r&&i){let n=await oP(e.clientId,e.tenantId,{requestUrl:r,requestToken:i});return console.log(`::add-mask::${n}`),n}if(t.GITHUB_ACTIONS)throw new Error("No GitHub OIDC token endpoint; give the job the id-token: write permission");return sP(e.tenantId)}async function uL(e){let{config:t,errors:r}=rP(e);if(!t)throw new Error(r.join("; "));let i=X1(t.provider,t.baseUrl),n=new Set(Object.values(t.slots).map(s=>s.harness));for(let s of n)if(!an(s))throw new Error(`${s} is not on PATH`);let o=await aP(t.auth,e);Hg(Q1(e)),await K1(process.cwd(),{prompt:!1,submit:!0,force:!0,verbose:!0,ci:{models:W1(t,i,o),summaryPath:e.GITHUB_STEP_SUMMARY,footer:G1(t.slots),runUrl:J1(e)}})}try{await uL(process.env)}catch(e){console.error(`review-ci: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}export{uL as reviewCiReview};