@prismatic-io/prism 7.1.1 → 7.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -32142,6 +32142,16 @@ type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "js
32142
32142
  nodes {
32143
32143
  requiredConfigVariable {
32144
32144
  key
32145
+ connectionTemplate {
32146
+ inputFieldTemplates {
32147
+ nodes {
32148
+ inputField {
32149
+ key
32150
+ }
32151
+ value
32152
+ }
32153
+ }
32154
+ }
32145
32155
  }
32146
32156
  inputs {
32147
32157
  nodes {
@@ -32154,7 +32164,7 @@ type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "js
32154
32164
  }
32155
32165
  }
32156
32166
  }
32157
- `,variables:{id:t}})).integration.testConfigVariables.nodes,[c]=o.filter(({requiredConfigVariable:{key:T}})=>T===r);if(!c)Tu0.ux.error("Failed to find active connection.",{exit:1});const{meta:f,inputs:x}=c,A=x.nodes.reduce((T,{name:P,value:I})=>({...T,[P]:I}),{}),E=JSON.stringify({...JSON.parse(f),fields:A});await HQ0(e,{PRISMATIC_CONNECTION_VALUE:E})}}var Hbt=U_(Pyt(),1),uJ=U_(d6(),1),Gbt=U_(wz0(),1);import{promisify as Fia} from"util";var aPr=function(){const e=new Map;for(let[t,r]of Object.entries(fX)){for(let[a,o]of Object.entries(r))fX[a]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},r[a]=fX[a],e.set(o[0],o[1]);Object.defineProperty(fX,t,{value:r,enumerable:!1})}return Object.defineProperty(fX,"codes",{value:e,enumerable:!1}),fX.color.close="\x1B[39m",fX.bgColor.close="\x1B[49m",fX.color.ansi=Byt(),fX.color.ansi256=Nyt(),fX.color.ansi16m=Myt(),fX.bgColor.ansi=Byt(10),fX.bgColor.ansi256=Nyt(10),fX.bgColor.ansi16m=Myt(10),Object.defineProperties(fX,{rgbToAnsi256:{value(t,r,a){if(t===r&&r===a){if(t<8)return 16;if(t>248)return 231;return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(a/255*5)},enumerable:!1},hexToRgb:{value(t){const r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[a]=r;if(a.length===3)a=[...a].map((c)=>c+c).join("");const o=Number.parseInt(a,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:(t)=>fX.rgbToAnsi256(...fX.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,a,o;if(t>=232)r=((t-232)*10+8)/255,a=r,o=r;else{t-=16;const x=t%36;r=Math.floor(t/36)/5,a=Math.floor(x/6)/5,o=x%6/5}const c=Math.max(r,a,o)*2;if(c===0)return 30;let f=30+(Math.round(o)<<2|Math.round(a)<<1|Math.round(r));if(c===2)f+=60;return f},enumerable:!1},rgbToAnsi:{value:(t,r,a)=>fX.ansi256ToAnsi(fX.rgbToAnsi256(t,r,a)),enumerable:!1},hexToAnsi:{value:(t)=>fX.ansi256ToAnsi(fX.hexToAnsi256(t)),enumerable:!1}}),fX};var Byt=(e=0)=>(t)=>`\x1B[${t+e}m`,Nyt=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,Myt=(e=0)=>(t,r,a)=>`\x1B[${38+e};2;${t};${r};${a}m`,fX={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]}},Nd1=Object.keys(fX.modifier),iPr=Object.keys(fX.color),rPr=Object.keys(fX.bgColor),Md1=[...iPr,...rPr],uPr=aPr(),eTe=uPr;import r9n from"node:process";import oPr from"node:os";import Iyt from"node:tty";var Kme=function(e,t=globalThis.Deno?globalThis.Deno.args:r9n.argv){const r=e.startsWith("-")?"":e.length===1?"-":"--",a=t.indexOf(r+e),o=t.indexOf("--");return a!==-1&&(o===-1||a<o)},sPr=function(){if("FORCE_COLOR"in SU){if(SU.FORCE_COLOR==="true")return 1;if(SU.FORCE_COLOR==="false")return 0;return SU.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(SU.FORCE_COLOR,10),3)}},_Pr=function(e){if(e===0)return!1;return{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}},lPr=function(e,{streamIsTTY:t,sniffFlags:r=!0}={}){const a=sPr();if(a!==void 0)jQ0=a;const o=r?jQ0:a;if(o===0)return 0;if(r){if(Kme("color=16m")||Kme("color=full")||Kme("color=truecolor"))return 3;if(Kme("color=256"))return 2}if("TF_BUILD"in SU&&"AGENT_NAME"in SU)return 1;if(e&&!t&&o===void 0)return 0;const c=o||0;if(SU.TERM==="dumb")return c;if(r9n.platform==="win32"){const f=oPr.release().split(".");if(Number(f[0])>=10&&Number(f[2])>=10586)return Number(f[2])>=14931?3:2;return 1}if("CI"in SU){if("GITHUB_ACTIONS"in SU||"GITEA_ACTIONS"in SU)return 3;if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((f)=>(f in SU))||SU.CI_NAME==="codeship")return 1;return c}if("TEAMCITY_VERSION"in SU)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(SU.TEAMCITY_VERSION)?1:0;if(SU.COLORTERM==="truecolor")return 3;if(SU.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in SU){const f=Number.parseInt((SU.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(SU.TERM_PROGRAM){case"iTerm.app":return f>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(SU.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(SU.TERM))return 1;if("COLORTERM"in SU)return 1;return c};function Jyt(e,t={}){const r=lPr(e,{streamIsTTY:e&&e.isTTY,...t});return _Pr(r)}var{env:SU}=r9n,jQ0;if(Kme("no-color")||Kme("no-colors")||Kme("color=false")||Kme("color=never"))jQ0=0;else if(Kme("color")||Kme("colors")||Kme("color=true")||Kme("color=always"))jQ0=1;var cPr={stdout:Jyt({isTTY:Iyt.isatty(1)}),stderr:Jyt({isTTY:Iyt.isatty(2)})},kyt=cPr;function qyt(e,t,r){let a=e.indexOf(t);if(a===-1)return e;const o=t.length;let c=0,f="";do f+=e.slice(c,a)+t+r,c=a+o,a=e.indexOf(t,c);while(a!==-1);return f+=e.slice(c),f}function Oyt(e,t,r,a){let o=0,c="";do{const f=e[a-1]==="\r";c+=e.slice(o,f?a-1:a)+t+(f?"\r\n":"\n")+r,o=a+1,a=e.indexOf("\n",o)}while(a!==-1);return c+=e.slice(o),c}var uB0=function(e){return fPr(e)};var{stdout:byt,stderr:$yt}=kyt,a9n=Symbol("GENERATOR"),qf0=Symbol("STYLER"),aB0=Symbol("IS_EMPTY"),Lyt=["ansi","ansi","ansi256","ansi16m"],Of0=Object.create(null),pPr=(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");const r=byt?byt.level:0;e.level=t.level===void 0?r:t.level};var fPr=(e)=>{const t=(...r)=>r.join(" ");return pPr(t,e),Object.setPrototypeOf(t,uB0.prototype),t};Object.setPrototypeOf(uB0.prototype,Function.prototype);for(let[e,t]of Object.entries(eTe))Of0[e]={get(){const r=eZ0(this,o9n(t.open,t.close,this[qf0]),this[aB0]);return Object.defineProperty(this,e,{value:r}),r}};Of0.visible={get(){const e=eZ0(this,this[qf0],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var u9n=(e,t,r,...a)=>{if(e==="rgb"){if(t==="ansi16m")return eTe[r].ansi16m(...a);if(t==="ansi256")return eTe[r].ansi256(eTe.rgbToAnsi256(...a));return eTe[r].ansi(eTe.rgbToAnsi(...a))}if(e==="hex")return u9n("rgb",t,r,...eTe.hexToRgb(...a));return eTe[r][e](...a)},dPr=["rgb","hex","ansi256"];for(let e of dPr){Of0[e]={get(){const{level:r}=this;return function(...a){const o=o9n(u9n(e,Lyt[r],"color",...a),eTe.color.close,this[qf0]);return eZ0(this,o,this[aB0])}}};const t="bg"+e[0].toUpperCase()+e.slice(1);Of0[t]={get(){const{level:r}=this;return function(...a){const o=o9n(u9n(e,Lyt[r],"bgColor",...a),eTe.bgColor.close,this[qf0]);return eZ0(this,o,this[aB0])}}}}var mPr=Object.defineProperties(()=>{},{...Of0,level:{enumerable:!0,get(){return this[a9n].level},set(e){this[a9n].level=e}}}),o9n=(e,t,r)=>{let a,o;if(r===void 0)a=e,o=t;else a=r.openAll+e,o=t+r.closeAll;return{open:e,close:t,openAll:a,closeAll:o,parent:r}},eZ0=(e,t,r)=>{const a=(...o)=>hPr(a,o.length===1?""+o[0]:o.join(" "));return Object.setPrototypeOf(a,mPr),a[a9n]=e,a[qf0]=t,a[aB0]=r,a},hPr=(e,t)=>{if(e.level<=0||!t)return e[aB0]?"":t;let r=e[qf0];if(r===void 0)return t;const{openAll:a,closeAll:o}=r;if(t.includes("\x1B"))while(r!==void 0)t=qyt(t,r.close,r.open),r=r.parent;const c=t.indexOf("\n");if(c!==-1)t=Oyt(t,o,a,c);return a+t+o};Object.defineProperties(uB0.prototype,Of0);var yPr=uB0(),Xd1=uB0({level:$yt?$yt.level:0});var XD=yPr;var uJt=U_(iZ0(),1),xhn=U_(cZ0(),1),oJt=U_(sB0(),1),TBe=U_(_de(),1);var PU=U_(_de(),1),jVr=function(e,t){return{value:e,key:t||{}}};function Cae(e){const t=PU.fromEvent(e.input,"keypress",jVr).pipe(PU.takeUntil(PU.fromEvent(e,"close"))).pipe(PU.filter(({key:r})=>r.name!=="enter"&&r.name!=="return"));return{line:PU.fromEvent(e,"line"),keypress:t,normalizedUpKey:t.pipe(PU.filter(({key:r})=>r.name==="up"||r.name==="k"||r.name==="p"&&r.ctrl),PU.share()),normalizedDownKey:t.pipe(PU.filter(({key:r})=>r.name==="down"||r.name==="j"||r.name==="n"&&r.ctrl),PU.share()),numberKey:t.pipe(PU.filter((r)=>r.value&&"123456789".indexOf(r.value)>=0),PU.map((r)=>Number(r.value)),PU.share()),spaceKey:t.pipe(PU.filter(({key:r})=>r&&r.name==="space"),PU.share()),aKey:t.pipe(PU.filter(({key:r})=>r&&r.name==="a"),PU.share()),iKey:t.pipe(PU.filter(({key:r})=>r&&r.name==="i"),PU.share())}}class EBe{constructor(e,t={}){const{isInfinite:r=!0}=t;this.lastIndex=0,this.screen=e,this.isInfinite=r}paginate(e,t,r){r||=7;let a=e.split("\n");if(this.screen)a=this.screen.breakLines(a),t=a.map((c)=>c.length).splice(0,t).reduce((c,f)=>c+f,0),a=a.flat();if(a.length<=r)return e;const o=this.isInfinite?this.getInfiniteLines(a,t,r):this.getFiniteLines(a,t,r);return this.lastIndex=t,o.join("\n")+"\n"+XD.dim("(Move up and down to reveal more choices)")}getInfiniteLines(e,t,r){if(this.pointer===void 0)this.pointer=0;const a=Math.floor(r/2);if(this.pointer<a&&this.lastIndex<t&&t-this.lastIndex<r)this.pointer=Math.min(a,this.pointer+t-this.lastIndex);const o=[e,e,e].flat(),c=Math.max(0,t+e.length-this.pointer);return o.splice(c,r)}getFiniteLines(e,t,r){let a=t-r/2;if(a<0)a=0;else if(a+r>e.length)a=e.length-r;return e.splice(a,r)}}function vLe(e,t,r){const a=r.choices.realLength,o="loop"in r?Boolean(r.loop):!0;if(t==="up"){if(e>0)return e-1;return o?a-1:e}if(t==="down"){if(e<a-1)return e+1;return o?0:e}throw new Error("dir must be up or down")}var rJt=U_(R8n(),1),aJt=U_(eNt(),1);var Dhn=U_(sB0(),1),aTe=U_(_de(),1);var JMt=U_(FMt(),1),kMt=U_(NMt(),1);import IMt from"node:assert";var MMt=U_(iZ0(),1);class lde{constructor(e){this.type="separator",this.line=XD.dim(e||new Array(15).join(MMt.default.line))}static exclude(e){return e.type!=="separator"}toString(){return this.line}}class x60{constructor(e,t){if(e instanceof x60||e.type==="separator")return e;if(typeof e==="string"||typeof e==="number")this.name=String(e),this.value=e,this.short=String(e);else Object.assign(this,e,{name:e.name||e.value,value:"value"in e?e.value:e.name,short:e.short||e.name||e.value});if(typeof e.disabled==="function")this.disabled=e.disabled(t);else this.disabled=e.disabled}}class YZ0{constructor(e,t){this.choices=e.map((r)=>{if(r.type==="separator"){if(!(r instanceof lde))r=new lde(r.line);return r}return new x60(r,t)}),this.realChoices=this.choices.filter(lde.exclude).filter((r)=>!r.disabled),Object.defineProperty(this,"length",{get(){return this.choices.length},set(r){this.choices.length=r}}),Object.defineProperty(this,"realLength",{get(){return this.realChoices.length},set(){throw new Error("Cannot set `realLength` of a Choices collection")}})}getChoice(e){return IMt(typeof e==="number"),this.realChoices[e]}get(e){return IMt(typeof e==="number"),this.choices[e]}where(e){return JMt.default(this.realChoices,e)}pluck(e){return kMt.default(this.realChoices,e)}indexOf(...e){return this.choices.indexOf(...e)}forEach(...e){return this.choices.forEach(...e)}filter(...e){return this.choices.filter(...e)}reduce(...e){return this.choices.reduce(...e)}find(e){return this.choices.find(e)}push(...e){const t=e.map((r)=>new x60(r));return this.choices.push(...t),this.realChoices=this.choices.filter(lde.exclude).filter((r)=>!r.disabled),this.choices}}var jIt=U_(OMt(),1),eJt=U_(LMt(),1),nJt=U_(wme(),1),tJt=U_(Eze(),1),vhn=U_(QIt(),1);var g60=U_(fC0(),1),tK0=function(e,t){e.output.write(g60.default.cursorBackward(t))},ZIt=function(e,t){e.output.write(g60.default.cursorForward(t))},KIt=function(e,t){e.output.write(g60.default.cursorUp(t))},yhn=function(e,t){e.output.write(g60.default.cursorDown(t))},BB0=function(e,t){e.output.write(g60.default.eraseLines(t))};var GIt=function(e){return e.split("\n").length},RIt=function(e){return e.split("\n").pop()};class iK0{constructor(e){this.height=0,this.extraLinesUnderPrompt=0,this.rl=e}renderWithSpinner(e,t){if(this.spinnerId)clearInterval(this.spinnerId);let r,a,o;if(t)r=vhn.default(t),a=()=>e,o=()=>r.frame();else r=vhn.default(e),a=()=>r.frame(),o=()=>"";this.spinnerId=setInterval(()=>this.render(a(),o(),!0),r.interval)}render(e,t,r=!1){if(this.spinnerId&&!r)clearInterval(this.spinnerId);this.rl.output.unmute(),this.clean(this.extraLinesUnderPrompt);const a=RIt(e),o=nJt.default(a);let c=o;if(this.rl.line.length)c=c.slice(0,-this.rl.line.length);this.rl.setPrompt(c);const f=this.rl._getCursorPos(),x=this.normalizedCliWidth();if(e=this.forceLineReturn(e,x),t&&=this.forceLineReturn(t,x),o.length%x===0)e+="\n";const A=e+(t?"\n"+t:"");this.rl.output.write(A);const T=Math.floor(o.length/x)-f.rows+(t?GIt(t):0);if(T>0)KIt(this.rl,T);if(tK0(this.rl,tJt.default(RIt(A))),f.cols>0)ZIt(this.rl,f.cols);this.extraLinesUnderPrompt=T,this.height=GIt(A),this.rl.output.mute()}clean(e){if(e>0)yhn(this.rl,e);BB0(this.rl,this.height)}done(){this.rl.setPrompt(""),this.rl.output.unmute(),this.rl.output.write("\n")}releaseCursor(){if(this.extraLinesUnderPrompt>0)yhn(this.rl,this.extraLinesUnderPrompt)}normalizedCliWidth(){return jIt.default({defaultWidth:80,output:this.rl.output})}breakLines(e,t=this.normalizedCliWidth()){return e.map((r)=>eJt.default(r,t,{trim:!1,hard:!0}).split("\n"))}forceLineReturn(e,t=this.normalizedCliWidth()){return this.breakLines(e.split("\n"),t).flat().join("\n")}}var iJt={defaults:rJt.default,clone:aJt.default};class ste{constructor(e,t,r){if(Object.assign(this,{answers:r,status:"pending"}),this.opt=iJt.defaults(iJt.clone(e),{validate:()=>!0,validatingText:"",filter:(a)=>a,filteringText:"",when:()=>!0,suffix:"",prefix:XD.green("?"),transformer:(a)=>a}),!this.opt.name)this.throwParamError("name");if(this.opt.message||=this.opt.name+":",Array.isArray(this.opt.choices))this.opt.choices=new YZ0(this.opt.choices,r);this.rl=t,this.screen=new iK0(this.rl)}run(){return new Promise((e,t)=>{this._run((r)=>e(r),(r)=>t(r))})}_run(e){e()}throwParamError(e){throw new Error("You must provide a `"+e+"` parameter")}close(){this.screen.releaseCursor()}handleSubmitEvents(e){const t=this,r=Dhn.default(this.opt.validate),a=Dhn.default(this.opt.filter),o=e.pipe(aTe.flatMap((x)=>{return this.startSpinner(x,this.opt.filteringText),a(x,t.answers).then((A)=>{return this.startSpinner(A,this.opt.validatingText),r(A,t.answers).then((E)=>({isValid:E,value:A}),(E)=>({isValid:E,value:A}))},(A)=>({isValid:A}))}),aTe.share()),c=o.pipe(aTe.filter((x)=>x.isValid===!0),aTe.take(1)),f=o.pipe(aTe.filter((x)=>x.isValid!==!0),aTe.takeUntil(c));return{success:c,error:f}}startSpinner(e,t){e=this.getSpinningValue(e);const r=t?this.getQuestion()+e:this.getQuestion().slice(this.opt.prefix.length+1)+e;this.screen.renderWithSpinner(r,t)}getSpinningValue(e){return e}getQuestion(){let e=(this.opt.prefix?this.opt.prefix+" ":"")+XD.bold(this.opt.message)+this.opt.suffix+XD.reset(" ");if(this.opt.default!=null&&this.status!=="touched"&&this.status!=="answered")if(this.opt.type==="password")e+=XD.italic.dim("[hidden] ");else e+=XD.dim("("+this.opt.default+") ");return e}}var Tea=function(e,t){let r="",a=0;return e.forEach((o,c)=>{if(o.type==="separator"){a++,r+=" "+o+"\n";return}if(o.disabled){a++,r+=" - "+o.name,r+=` (${typeof o.disabled==="string"?o.disabled:"Disabled"})`,r+="\n";return}const f=c-a===t;let x=(f?uJt.default.pointer+" ":" ")+o.name;if(f)x=XD.cyan(x);r+=x+" \n"}),r.replace(/\n$/,"")};class rK0 extends ste{constructor(e,t,r){super(e,t,r);if(!this.opt.choices)this.throwParamError("choices");this.firstRender=!0,this.selected=0;const a=this.opt.default;if(typeof a==="number"&&a>=0&&a<this.opt.choices.realLength)this.selected=a;else if(typeof a!=="number"&&a!=null){const c=this.opt.choices.realChoices.findIndex(({value:f})=>f===a);this.selected=Math.max(c,0)}this.opt.default=null;const o=this.opt.loop===void 0?!0:this.opt.loop;this.paginator=new EBe(this.screen,{isInfinite:o})}_run(e){this.done=e;const t=this,r=Cae(this.rl);return r.normalizedUpKey.pipe(TBe.takeUntil(r.line)).forEach(this.onUpKey.bind(this)),r.normalizedDownKey.pipe(TBe.takeUntil(r.line)).forEach(this.onDownKey.bind(this)),r.numberKey.pipe(TBe.takeUntil(r.line)).forEach(this.onNumberKey.bind(this)),r.line.pipe(TBe.take(1),TBe.map(this.getCurrentValue.bind(this)),TBe.flatMap((a)=>oJt.default(t.opt.filter)(a,t.answers).catch((o)=>o))).forEach(this.onSubmit.bind(this)),xhn.default.hide(),this.render(),this}render(){let e=this.getQuestion();if(this.firstRender)e+=XD.dim("(Use arrow keys)");if(this.status==="answered")e+=XD.cyan(this.opt.choices.getChoice(this.selected).short);else{const t=Tea(this.opt.choices,this.selected),r=this.opt.choices.indexOf(this.opt.choices.getChoice(this.selected)),a=this.opt.choices.reduce((o,c,f)=>{if(f>r)return o;if(c.type==="separator")return o+1;let x=c.name;if(typeof x!=="string")return o+1;return x=x.split("\n"),o+x.length},0)-1;e+="\n"+this.paginator.paginate(t,a,this.opt.pageSize)}this.firstRender=!1,this.screen.render(e)}onSubmit(e){this.status="answered",this.render(),this.screen.done(),xhn.default.show(),this.done(e)}getCurrentValue(){return this.opt.choices.getChoice(this.selected).value}onUpKey(){this.selected=vLe(this.selected,"up",this.opt),this.render()}onDownKey(){this.selected=vLe(this.selected,"down",this.opt),this.render()}onNumberKey(e){if(e<=this.opt.choices.realLength)this.selected=e-1;this.render()}}var aK0=U_(_de(),1);class E60 extends ste{_run(e){this.done=e;const t=Cae(this.rl),r=t.line.pipe(aK0.map(this.filterInput.bind(this))),a=this.handleSubmitEvents(r);return a.success.forEach(this.onEnd.bind(this)),a.error.forEach(this.onError.bind(this)),t.keypress.pipe(aK0.takeUntil(a.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(e){let t="",r="",a=this.getQuestion();const{transformer:o}=this.opt,c=this.status==="answered";if(c)r=this.answer;else r=this.rl.line;if(o)a+=o(r,this.answers,{isFinal:c});else a+=c?XD.cyan(r):r;if(e)t=XD.red(">> ")+e;this.screen.render(a,t)}filterInput(e){if(!e)return this.opt.default==null?"":this.opt.default;return e}onEnd(e){this.answer=e.value,this.status="answered",this.render(),this.screen.done(),this.done(e.value)}onError({value:e="",isValid:t}){this.rl.line+=e,this.rl.cursor+=e.length,this.render(t)}onKeypress(){this.status="touched",this.render()}}class uK0 extends E60{filterInput(e){if(e&&typeof e==="string"){e=e.trim();const t=e.match(/(^-?\d+|^-?\d+\.\d*|^\d*\.\d+)(e\d+)?$/);if(t)return Number(t[0])}return this.opt.default==null?NaN:this.opt.default}}var oK0=U_(_de(),1);class sK0 extends ste{constructor(e,t,r){super(e,t,r);let a=!0;if(Object.assign(this.opt,{filter(o){if(o!=null&&o!==""){if(/^y(es)?/i.test(o))return!0;if(/^n(o)?/i.test(o))return!1}return a}}),this.opt.default!=null)a=Boolean(this.opt.default);this.opt.default=a?"Y/n":"y/N"}_run(e){this.done=e;const t=Cae(this.rl);return t.keypress.pipe(oK0.takeUntil(t.line)).forEach(this.onKeypress.bind(this)),t.line.pipe(oK0.take(1)).forEach(this.onEnd.bind(this)),this.render(),this}render(e){let t=this.getQuestion();if(typeof e==="boolean")t+=XD.cyan(e?"Yes":"No");else if(e)t+=e;else t+=this.rl.line;return this.screen.render(t),this}onEnd(e){this.status="answered";let t=this.opt.filter(e);if(this.opt.transformer)t=this.opt.transformer(t);this.render(t),this.screen.done(),this.done(t)}onKeypress(){this.render()}}var T60=U_(_de(),1);var Cea=function(e,t){let r="",a=0;return e.forEach((o,c)=>{if(r+=r?"\n ":" ",o.type==="separator"){a++,r+=" "+o;return}const f=c-a;let x=f+1+") "+o.name;if(f===t)x=XD.cyan(x);r+=x}),r};class _K0 extends ste{constructor(e,t,r){super(e,t,r);if(this.hiddenLine="",this.lastKey="",!this.opt.choices)this.throwParamError("choices");this.opt.validChoices=this.opt.choices.filter(lde.exclude),this.selected=0,this.rawDefault=0,Object.assign(this.opt,{validate(c){return c!=null}});const a=this.opt.default;if(typeof a==="number"&&a>=0&&a<this.opt.choices.realLength)this.selected=a,this.rawDefault=a;else if(typeof a!=="number"&&a!=null){const c=this.opt.choices.realChoices.findIndex(({value:x})=>x===a),f=Math.max(c,0);this.selected=f,this.rawDefault=f}this.opt.default=null;const o=this.opt.loop===void 0?!0:this.opt.loop;this.paginator=new EBe(void 0,{isInfinite:o})}_run(e){this.done=e;const t=Cae(this.rl),r=t.line.pipe(T60.map(this.getCurrentValue.bind(this))),a=this.handleSubmitEvents(r);return a.success.forEach(this.onEnd.bind(this)),a.error.forEach(this.onError.bind(this)),t.normalizedUpKey.pipe(T60.takeUntil(a.success)).forEach(this.onUpKey.bind(this)),t.normalizedDownKey.pipe(T60.takeUntil(a.success)).forEach(this.onDownKey.bind(this)),t.keypress.pipe(T60.takeUntil(a.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(e){let t=this.getQuestion(),r="";if(this.status==="answered")t+=XD.cyan(this.opt.choices.getChoice(this.selected).short);else{const a=Cea(this.opt.choices,this.selected);t+="\n"+this.paginator.paginate(a,this.selected,this.opt.pageSize),t+="\n Answer: "}if(t+=this.rl.line,e)r="\n"+XD.red(">> ")+e;this.screen.render(t,r)}getCurrentValue(e){if(e==null)e=this.rawDefault;else if(e==="")this.selected=this.selected===void 0?-1:this.selected,e=this.selected;else e-=1;const t=this.opt.choices.getChoice(e);return t?t.value:null}onEnd(e){this.status="answered",this.answer=e.value,this.render(),this.screen.done(),this.done(e.value)}onError(){this.render("Please enter a valid index")}onKeypress(){let e;if(this.lastKey==="arrow")e=this.hiddenLine.length?Number(this.hiddenLine)-1:0;else e=this.rl.line.length?Number(this.rl.line)-1:0;if(this.lastKey="",this.opt.choices.getChoice(e))this.selected=e;else this.selected=void 0;this.render()}onUpKey(){this.onArrowKey("up")}onDownKey(){this.onArrowKey("down")}onArrowKey(e){this.selected=vLe(this.selected,e,this.opt)||0,this.hiddenLine=String(this.selected+1),this.rl.line="",this.lastKey="arrow"}}var lK0=U_(_de(),1);var Fea=function(e,t){let r="";return e.forEach((a)=>{if(r+="\n ",a.type==="separator"){r+=" "+a;return}let o=a.key+") "+a.name;if(t===a.key)o=XD.cyan(o);r+=o}),r};class cK0 extends ste{constructor(e,t,r){super(e,t,r);if(!this.opt.choices)this.throwParamError("choices");this.validateChoices(this.opt.choices),this.opt.choices.push({key:"h",name:"Help, list all options",value:"help"}),this.opt.validate=(a)=>{if(a==null)return"Please enter a valid command";return a!=="help"},this.opt.default=this.generateChoicesString(this.opt.choices,this.opt.default),this.paginator=new EBe(this.screen)}_run(e){this.done=e;const t=Cae(this.rl),r=this.handleSubmitEvents(t.line.pipe(lK0.map(this.getCurrentValue.bind(this))));return r.success.forEach(this.onSubmit.bind(this)),r.error.forEach(this.onError.bind(this)),this.keypressObs=t.keypress.pipe(lK0.takeUntil(r.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(e,t){let r=this.getQuestion(),a="";if(this.status==="answered")r+=XD.cyan(this.answer);else if(this.status==="expanded"){const o=Fea(this.opt.choices,this.selectedKey);r+=this.paginator.paginate(o,this.selectedKey,this.opt.pageSize),r+="\n Answer: "}if(r+=this.rl.line,e)a=XD.red(">> ")+e;if(t)a=XD.cyan(">> ")+t;this.screen.render(r,a)}getCurrentValue(e){e||=this.rawDefault;const t=this.opt.choices.where({key:e.toLowerCase().trim()})[0];if(!t)return null;return t.value}getChoices(){let e="";return this.opt.choices.forEach((t)=>{if(e+="\n ",t.type==="separator"){e+=" "+t;return}let r=t.key+") "+t.name;if(this.selectedKey===t.key)r=XD.cyan(r);e+=r}),e}onError(e){if(e.value==="help"){this.selectedKey="",this.status="expanded",this.render();return}this.render(e.isValid)}onSubmit(e){this.status="answered";const t=this.opt.choices.where({value:e.value})[0];this.answer=t.short||t.name,this.render(),this.screen.done(),this.done(e.value)}onKeypress(){this.selectedKey=this.rl.line.toLowerCase();const e=this.opt.choices.where({key:this.selectedKey})[0];if(this.status==="expanded")this.render();else this.render(null,e?e.name:null)}validateChoices(e){let t;const r=[],a={};if(e.filter(lde.exclude).forEach((o)=>{if(!o.key||o.key.length!==1)t=!0;if(o.key=String(o.key).toLowerCase(),a[o.key])r.push(o.key);a[o.key]=!0}),t)throw new Error("Format error: `key` param must be a single letter and is required.");if(a.h)throw new Error("Reserved key error: `key` param cannot be `h` - this value is reserved.");if(r.length)throw new Error("Duplicate key error: `key` param must be unique. Duplicates: "+[...new Set(r)].join(","))}generateChoicesString(e,t){let r=e.realLength-1;if(typeof t==="number"&&this.opt.choices.getChoice(t))r=t;else if(typeof t==="string"){const o=e.realChoices.findIndex(({value:c})=>c===t);r=o===-1?r:o}const a=this.opt.choices.pluck("key");return this.rawDefault=a[r],a[r]=String(a[r]).toUpperCase(),a.join("")}}var whn=U_(cZ0(),1),pK0=U_(iZ0(),1),DLe=U_(_de(),1);var Sea=function(e,t){let r="",a=0;return e.forEach((o,c)=>{if(o.type==="separator"){a++,r+=" "+o+"\n";return}if(o.disabled)a++,r+=" - "+o.name,r+=` (${typeof o.disabled==="string"?o.disabled:"Disabled"})`;else{const f=Pea(o.checked)+" "+o.name;if(c-a===t)r+=XD.cyan(pK0.default.pointer+f);else r+=" "+f}r+="\n"}),r.replace(/\n$/,"")},Pea=function(e){return e?XD.green(pK0.default.radioOn):pK0.default.radioOff};class fK0 extends ste{constructor(e,t,r){super(e,t,r);if(!this.opt.choices)this.throwParamError("choices");if(Array.isArray(this.opt.default))this.opt.choices.forEach(function(o){if(this.opt.default.indexOf(o.value)>=0)o.checked=!0},this);this.pointer=0,this.opt.default=null;const a=this.opt.loop===void 0?!0:this.opt.loop;this.paginator=new EBe(this.screen,{isInfinite:a})}_run(e){this.done=e;const t=Cae(this.rl),r=this.handleSubmitEvents(t.line.pipe(DLe.map(this.getCurrentValue.bind(this))));return r.success.forEach(this.onEnd.bind(this)),r.error.forEach(this.onError.bind(this)),t.normalizedUpKey.pipe(DLe.takeUntil(r.success)).forEach(this.onUpKey.bind(this)),t.normalizedDownKey.pipe(DLe.takeUntil(r.success)).forEach(this.onDownKey.bind(this)),t.numberKey.pipe(DLe.takeUntil(r.success)).forEach(this.onNumberKey.bind(this)),t.spaceKey.pipe(DLe.takeUntil(r.success)).forEach(this.onSpaceKey.bind(this)),t.aKey.pipe(DLe.takeUntil(r.success)).forEach(this.onAllKey.bind(this)),t.iKey.pipe(DLe.takeUntil(r.success)).forEach(this.onInverseKey.bind(this)),whn.default.hide(),this.render(),this.firstRender=!1,this}render(e){let t=this.getQuestion(),r="";if(!this.dontShowHints)t+="(Press "+XD.cyan.bold("<space>")+" to select, "+XD.cyan.bold("<a>")+" to toggle all, "+XD.cyan.bold("<i>")+" to invert selection, and "+XD.cyan.bold("<enter>")+" to proceed)";if(this.status==="answered")t+=XD.cyan(this.selection.join(", "));else{const a=Sea(this.opt.choices,this.pointer),o=this.opt.choices.indexOf(this.opt.choices.getChoice(this.pointer)),c=this.opt.choices.reduce((f,x,A)=>{if(A>o)return f;if(x.type==="separator")return f+1;let E=x.name;if(typeof E!=="string")return f+1;return E=E.split("\n"),f+E.length},0)-1;t+="\n"+this.paginator.paginate(a,c,this.opt.pageSize)}if(e)r=XD.red(">> ")+e;this.screen.render(t,r)}onEnd(e){this.status="answered",this.dontShowHints=!0,this.render(),this.screen.done(),whn.default.show(),this.done(e.value)}onError(e){this.render(e.isValid)}getCurrentValue(){const e=this.opt.choices.filter((t)=>Boolean(t.checked)&&!t.disabled);return this.selection=e.map((t)=>t.short),e.map((t)=>t.value)}onUpKey(){this.pointer=vLe(this.pointer,"up",this.opt),this.render()}onDownKey(){this.pointer=vLe(this.pointer,"down",this.opt),this.render()}onNumberKey(e){if(e<=this.opt.choices.realLength)this.pointer=e-1,this.toggleChoice(this.pointer);this.render()}onSpaceKey(){this.toggleChoice(this.pointer),this.render()}onAllKey(){const e=Boolean(this.opt.choices.find((t)=>t.type!=="separator"&&!t.checked));this.opt.choices.forEach((t)=>{if(t.type!=="separator")t.checked=e}),this.render()}onInverseKey(){this.opt.choices.forEach((e)=>{if(e.type!=="separator")e.checked=!e.checked}),this.render()}toggleChoice(e){const t=this.opt.choices.getChoice(e);if(t!==void 0)this.opt.choices.getChoice(e).checked=!t.checked}}var dK0=U_(_de(),1);var sJt=function(e,t){if(e=String(e),t=typeof t==="string"?t:"*",e.length===0)return"";return new Array(e.length+1).join(t)};class mK0 extends ste{_run(e){this.done=e;const t=Cae(this.rl),r=t.line.pipe(dK0.map(this.filterInput.bind(this))),a=this.handleSubmitEvents(r);return a.success.forEach(this.onEnd.bind(this)),a.error.forEach(this.onError.bind(this)),t.keypress.pipe(dK0.takeUntil(a.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(e){let t=this.getQuestion(),r="";if(this.status==="answered")t+=this.getMaskedValue(this.answer);else t+=this.getMaskedValue(this.rl.line||"");if(e)r="\n"+XD.red(">> ")+e;this.screen.render(t,r)}getMaskedValue(e){if(this.status==="answered")return this.opt.mask?XD.cyan(sJt(e,this.opt.mask)):XD.italic.dim("[hidden]");return this.opt.mask?sJt(e,this.opt.mask):XD.italic.dim("[input is hidden] ")}getSpinningValue(e){return this.getMaskedValue(e)}filterInput(e){if(!e)return this.opt.default==null?"":this.opt.default;return e}onEnd(e){this.status="answered",this.answer=e.value,this.render(),this.screen.done(),this.done(e.value)}onError(e){this.render(e.isValid)}onKeypress(){this.opt.default&&=void 0,this.render()}}var Kkt=U_(Zkt(),1),Hkt=U_(_de(),1);class MK0 extends ste{_run(e){this.done=e,this.editorResult=new Hkt.Subject;const t=Cae(this.rl);if(this.lineSubscription=t.line.subscribe(this.startExternalEditor.bind(this)),!(this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput))this.startExternalEditor();const a=this.handleSubmitEvents(this.editorResult);return a.success.forEach(this.onEnd.bind(this)),a.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,this.render(),this}render(e){let t="",r=this.getQuestion();if(this.status==="answered")r+=XD.dim("Received");else r+=XD.dim("Press <enter> to launch your preferred editor.");if(e)t=XD.red(">> ")+e;this.screen.render(r,t)}startExternalEditor(){this.rl.pause(),Kkt.editAsync(this.currentText,this.endExternalEditor.bind(this),{postfix:this.opt.postfix??".txt"})}endExternalEditor(e,t){if(this.rl.resume(),e)this.editorResult.error(e);else this.editorResult.next(t)}onEnd(e){this.editorResult.unsubscribe(),this.lineSubscription.unsubscribe(),this.answer=e.value,this.status="answered",this.render(),this.screen.done(),this.done(this.answer)}onError(e){this.render(e.isValid)}}var eOt=U_(Kqt(),1);var jqt=U_(Rqt(),1);import bna from"node:readline";var $na=function(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;const t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){const o=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw o.isTtyError=!0,o}const r=new jqt.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}};class b60{constructor(e){this.rl||=bna.createInterface($na(e)),this.rl.resume(),this.onForceClose=this.onForceClose.bind(this),process.on("exit",this.onForceClose),this.rl.on("SIGINT",this.onForceClose)}onForceClose(){this.close(),process.kill(process.pid,"SIGINT"),console.log("")}close(){if(this.rl.removeListener("SIGINT",this.onForceClose),process.removeListener("exit",this.onForceClose),this.rl.output.unmute(),this.activePrompt&&typeof this.activePrompt.close==="function")this.activePrompt.close();this.rl.output.end(),this.rl.pause(),this.rl.close()}}class YK0 extends b60{constructor(e={}){super(e);this.log=eOt.default(this.writeLog.bind(this)),this.bottomBar=e.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return BB0(this.rl,this.bottomBar.split("\n").length),this}updateBottomBar(e){return BB0(this.rl,1),this.rl.output.unmute(),this.clean(),this.bottomBar=e,this.render(),this.rl.output.mute(),this}writeLog(e){return this.rl.output.unmute(),this.clean(),this.rl.output.write(this.enforceLF(e.toString())),this.render(),this.rl.output.mute(),this}enforceLF(e){return e.match(/[\r\n]$/)?e:e+"\n"}write(e){const t=e.split(/\n/);if(this.height=t.length,this.rl.setPrompt(t[t.length-1]),this.rl.output.rows===0&&this.rl.output.columns===0)tK0(this.rl,e.length+this.rl.line.length);this.rl.output.write(e)}}var oOt=U_(Fdn(),1),sOt=U_(Zmn(),1),_Ot=U_(aOt(),1),UM=U_(_de(),1),lOt=U_(sB0(),1);var XK0=U_(_de(),1),uOt=U_(sB0(),1),WK0=function(e,t,r){if(typeof e[t]!=="function")return XK0.of(e);return XK0.from(uOt.default(e[t])(r).then((a)=>{return e[t]=a,e}))};var WB0={isPlainObject:oOt.default,set:_Ot.default,get:sOt.default};class UB0 extends b60{constructor(e,t){super(t);this.prompts=e}run(e,t){if(WB0.isPlainObject(t))this.answers={...t};else this.answers={};if(WB0.isPlainObject(e))e=Object.values(e).every((a)=>WB0.isPlainObject(a)&&a.name===void 0)?Object.entries(e).map(([a,o])=>({name:a,...o})):[e];const r=Array.isArray(e)?UM.from(e):e;return this.process=r.pipe(UM.concatMap(this.processQuestion.bind(this)),UM.publish()),this.process.connect(),this.process.pipe(UM.reduce((a,o)=>{return WB0.set(a,o.name,o.answer),a},this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(e){return this.close(),Promise.reject(e)}processQuestion(e){return e={...e},UM.defer(()=>{return UM.of(e).pipe(UM.concatMap(this.setDefaultType.bind(this)),UM.concatMap(this.filterIfRunnable.bind(this)),UM.concatMap(()=>WK0(e,"message",this.answers)),UM.concatMap(()=>WK0(e,"default",this.answers)),UM.concatMap(()=>WK0(e,"choices",this.answers)),UM.concatMap(this.fetchAnswer.bind(this)))})}fetchAnswer(e){const t=this.prompts[e.type];return this.activePrompt=new t(e,this.rl,this.answers),UM.defer(()=>UM.from(this.activePrompt.run().then((r)=>({name:e.name,answer:r}))))}setDefaultType(e){if(!this.prompts[e.type])e.type="input";return UM.defer(()=>UM.of(e))}filterIfRunnable(e){if(e.askAnswered!==!0&&WB0.get(this.answers,e.name)!==void 0)return UM.empty();if(e.when===!1)return UM.empty();if(typeof e.when!=="function")return UM.of(e);const{answers:t}=this;return UM.defer(()=>UM.from(lOt.default(e.when)(t).then((r)=>{if(r)return e})).pipe(UM.filter((r)=>r!=null)))}}function cOt(e){const t=function(r,a){let o;try{o=new UB0(t.prompts,e)}catch(f){return Promise.reject(f)}const c=o.run(r,a);return c.ui=o,c};return t.prompts={},t.registerPrompt=function(r,a){return t.prompts[r]=a,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",rK0),this.registerPrompt("input",E60),this.registerPrompt("number",uK0),this.registerPrompt("confirm",sK0),this.registerPrompt("rawlist",_K0),this.registerPrompt("expand",cK0),this.registerPrompt("checkbox",fK0),this.registerPrompt("password",mK0),this.registerPrompt("editor",MK0)},t.restoreDefaultPrompts(),t}var Zna=function(e,t){hyn.registerPrompt(e,t)},Kna=function(){hyn.restoreDefaultPrompts()},hyn=cOt(),Hna={prompt:hyn,ui:{BottomBar:YK0,Prompt:UB0},createPromptModule:cOt,registerPrompt:Zna,restoreDefaultPrompts:Kna,Separator:lde},Ree=Hna;var IOt=U_(d6(),1),QK0=U_(FOt(),1);var VK0=U_(u8n(),1),BOt=U_(SOt(),1),NOt=U_(POt(),1);VK0.default.extend(BOt.default);VK0.default.extend(NOt.default);var MOt=(e)=>VK0.default(e,"YYYY-MM-DDTHH:mm:ss.SSS000+Z",!0).format("HH:mm:ss.SSS");import{promisify as fta} from"util";var dta=fta(setTimeout),mta=(e)=>{return new Promise((t,r)=>{const a=setInterval(async()=>{try{const o=await q_({document:I_`
32167
+ `,variables:{id:t}})).integration.testConfigVariables.nodes,[c]=o.filter(({requiredConfigVariable:{key:P}})=>P===r);if(!c)Tu0.ux.error("Failed to find active connection with that name.",{exit:1});const{meta:f,inputs:x,requiredConfigVariable:A}=c,E={...A.connectionTemplate?.inputFieldTemplates.nodes.reduce((P,{inputField:I,value:B})=>({...P,[I.key]:B}),{}),...x.nodes.reduce((P,{name:I,value:B})=>({...P,[I]:B}),{})},T=JSON.stringify({...JSON.parse(f),fields:E});await HQ0(e,{PRISMATIC_CONNECTION_VALUE:T})}}var Hbt=U_(Pyt(),1),uJ=U_(d6(),1),Gbt=U_(wz0(),1);import{promisify as Fia} from"util";var aPr=function(){const e=new Map;for(let[t,r]of Object.entries(fX)){for(let[a,o]of Object.entries(r))fX[a]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},r[a]=fX[a],e.set(o[0],o[1]);Object.defineProperty(fX,t,{value:r,enumerable:!1})}return Object.defineProperty(fX,"codes",{value:e,enumerable:!1}),fX.color.close="\x1B[39m",fX.bgColor.close="\x1B[49m",fX.color.ansi=Byt(),fX.color.ansi256=Nyt(),fX.color.ansi16m=Myt(),fX.bgColor.ansi=Byt(10),fX.bgColor.ansi256=Nyt(10),fX.bgColor.ansi16m=Myt(10),Object.defineProperties(fX,{rgbToAnsi256:{value(t,r,a){if(t===r&&r===a){if(t<8)return 16;if(t>248)return 231;return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(a/255*5)},enumerable:!1},hexToRgb:{value(t){const r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[a]=r;if(a.length===3)a=[...a].map((c)=>c+c).join("");const o=Number.parseInt(a,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:(t)=>fX.rgbToAnsi256(...fX.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,a,o;if(t>=232)r=((t-232)*10+8)/255,a=r,o=r;else{t-=16;const x=t%36;r=Math.floor(t/36)/5,a=Math.floor(x/6)/5,o=x%6/5}const c=Math.max(r,a,o)*2;if(c===0)return 30;let f=30+(Math.round(o)<<2|Math.round(a)<<1|Math.round(r));if(c===2)f+=60;return f},enumerable:!1},rgbToAnsi:{value:(t,r,a)=>fX.ansi256ToAnsi(fX.rgbToAnsi256(t,r,a)),enumerable:!1},hexToAnsi:{value:(t)=>fX.ansi256ToAnsi(fX.hexToAnsi256(t)),enumerable:!1}}),fX};var Byt=(e=0)=>(t)=>`\x1B[${t+e}m`,Nyt=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,Myt=(e=0)=>(t,r,a)=>`\x1B[${38+e};2;${t};${r};${a}m`,fX={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]}},Nd1=Object.keys(fX.modifier),iPr=Object.keys(fX.color),rPr=Object.keys(fX.bgColor),Md1=[...iPr,...rPr],uPr=aPr(),eTe=uPr;import r9n from"node:process";import oPr from"node:os";import Iyt from"node:tty";var Kme=function(e,t=globalThis.Deno?globalThis.Deno.args:r9n.argv){const r=e.startsWith("-")?"":e.length===1?"-":"--",a=t.indexOf(r+e),o=t.indexOf("--");return a!==-1&&(o===-1||a<o)},sPr=function(){if("FORCE_COLOR"in SU){if(SU.FORCE_COLOR==="true")return 1;if(SU.FORCE_COLOR==="false")return 0;return SU.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(SU.FORCE_COLOR,10),3)}},_Pr=function(e){if(e===0)return!1;return{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}},lPr=function(e,{streamIsTTY:t,sniffFlags:r=!0}={}){const a=sPr();if(a!==void 0)jQ0=a;const o=r?jQ0:a;if(o===0)return 0;if(r){if(Kme("color=16m")||Kme("color=full")||Kme("color=truecolor"))return 3;if(Kme("color=256"))return 2}if("TF_BUILD"in SU&&"AGENT_NAME"in SU)return 1;if(e&&!t&&o===void 0)return 0;const c=o||0;if(SU.TERM==="dumb")return c;if(r9n.platform==="win32"){const f=oPr.release().split(".");if(Number(f[0])>=10&&Number(f[2])>=10586)return Number(f[2])>=14931?3:2;return 1}if("CI"in SU){if("GITHUB_ACTIONS"in SU||"GITEA_ACTIONS"in SU)return 3;if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((f)=>(f in SU))||SU.CI_NAME==="codeship")return 1;return c}if("TEAMCITY_VERSION"in SU)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(SU.TEAMCITY_VERSION)?1:0;if(SU.COLORTERM==="truecolor")return 3;if(SU.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in SU){const f=Number.parseInt((SU.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(SU.TERM_PROGRAM){case"iTerm.app":return f>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(SU.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(SU.TERM))return 1;if("COLORTERM"in SU)return 1;return c};function Jyt(e,t={}){const r=lPr(e,{streamIsTTY:e&&e.isTTY,...t});return _Pr(r)}var{env:SU}=r9n,jQ0;if(Kme("no-color")||Kme("no-colors")||Kme("color=false")||Kme("color=never"))jQ0=0;else if(Kme("color")||Kme("colors")||Kme("color=true")||Kme("color=always"))jQ0=1;var cPr={stdout:Jyt({isTTY:Iyt.isatty(1)}),stderr:Jyt({isTTY:Iyt.isatty(2)})},kyt=cPr;function qyt(e,t,r){let a=e.indexOf(t);if(a===-1)return e;const o=t.length;let c=0,f="";do f+=e.slice(c,a)+t+r,c=a+o,a=e.indexOf(t,c);while(a!==-1);return f+=e.slice(c),f}function Oyt(e,t,r,a){let o=0,c="";do{const f=e[a-1]==="\r";c+=e.slice(o,f?a-1:a)+t+(f?"\r\n":"\n")+r,o=a+1,a=e.indexOf("\n",o)}while(a!==-1);return c+=e.slice(o),c}var uB0=function(e){return fPr(e)};var{stdout:byt,stderr:$yt}=kyt,a9n=Symbol("GENERATOR"),qf0=Symbol("STYLER"),aB0=Symbol("IS_EMPTY"),Lyt=["ansi","ansi","ansi256","ansi16m"],Of0=Object.create(null),pPr=(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");const r=byt?byt.level:0;e.level=t.level===void 0?r:t.level};var fPr=(e)=>{const t=(...r)=>r.join(" ");return pPr(t,e),Object.setPrototypeOf(t,uB0.prototype),t};Object.setPrototypeOf(uB0.prototype,Function.prototype);for(let[e,t]of Object.entries(eTe))Of0[e]={get(){const r=eZ0(this,o9n(t.open,t.close,this[qf0]),this[aB0]);return Object.defineProperty(this,e,{value:r}),r}};Of0.visible={get(){const e=eZ0(this,this[qf0],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var u9n=(e,t,r,...a)=>{if(e==="rgb"){if(t==="ansi16m")return eTe[r].ansi16m(...a);if(t==="ansi256")return eTe[r].ansi256(eTe.rgbToAnsi256(...a));return eTe[r].ansi(eTe.rgbToAnsi(...a))}if(e==="hex")return u9n("rgb",t,r,...eTe.hexToRgb(...a));return eTe[r][e](...a)},dPr=["rgb","hex","ansi256"];for(let e of dPr){Of0[e]={get(){const{level:r}=this;return function(...a){const o=o9n(u9n(e,Lyt[r],"color",...a),eTe.color.close,this[qf0]);return eZ0(this,o,this[aB0])}}};const t="bg"+e[0].toUpperCase()+e.slice(1);Of0[t]={get(){const{level:r}=this;return function(...a){const o=o9n(u9n(e,Lyt[r],"bgColor",...a),eTe.bgColor.close,this[qf0]);return eZ0(this,o,this[aB0])}}}}var mPr=Object.defineProperties(()=>{},{...Of0,level:{enumerable:!0,get(){return this[a9n].level},set(e){this[a9n].level=e}}}),o9n=(e,t,r)=>{let a,o;if(r===void 0)a=e,o=t;else a=r.openAll+e,o=t+r.closeAll;return{open:e,close:t,openAll:a,closeAll:o,parent:r}},eZ0=(e,t,r)=>{const a=(...o)=>hPr(a,o.length===1?""+o[0]:o.join(" "));return Object.setPrototypeOf(a,mPr),a[a9n]=e,a[qf0]=t,a[aB0]=r,a},hPr=(e,t)=>{if(e.level<=0||!t)return e[aB0]?"":t;let r=e[qf0];if(r===void 0)return t;const{openAll:a,closeAll:o}=r;if(t.includes("\x1B"))while(r!==void 0)t=qyt(t,r.close,r.open),r=r.parent;const c=t.indexOf("\n");if(c!==-1)t=Oyt(t,o,a,c);return a+t+o};Object.defineProperties(uB0.prototype,Of0);var yPr=uB0(),Xd1=uB0({level:$yt?$yt.level:0});var XD=yPr;var uJt=U_(iZ0(),1),xhn=U_(cZ0(),1),oJt=U_(sB0(),1),TBe=U_(_de(),1);var PU=U_(_de(),1),jVr=function(e,t){return{value:e,key:t||{}}};function Cae(e){const t=PU.fromEvent(e.input,"keypress",jVr).pipe(PU.takeUntil(PU.fromEvent(e,"close"))).pipe(PU.filter(({key:r})=>r.name!=="enter"&&r.name!=="return"));return{line:PU.fromEvent(e,"line"),keypress:t,normalizedUpKey:t.pipe(PU.filter(({key:r})=>r.name==="up"||r.name==="k"||r.name==="p"&&r.ctrl),PU.share()),normalizedDownKey:t.pipe(PU.filter(({key:r})=>r.name==="down"||r.name==="j"||r.name==="n"&&r.ctrl),PU.share()),numberKey:t.pipe(PU.filter((r)=>r.value&&"123456789".indexOf(r.value)>=0),PU.map((r)=>Number(r.value)),PU.share()),spaceKey:t.pipe(PU.filter(({key:r})=>r&&r.name==="space"),PU.share()),aKey:t.pipe(PU.filter(({key:r})=>r&&r.name==="a"),PU.share()),iKey:t.pipe(PU.filter(({key:r})=>r&&r.name==="i"),PU.share())}}class EBe{constructor(e,t={}){const{isInfinite:r=!0}=t;this.lastIndex=0,this.screen=e,this.isInfinite=r}paginate(e,t,r){r||=7;let a=e.split("\n");if(this.screen)a=this.screen.breakLines(a),t=a.map((c)=>c.length).splice(0,t).reduce((c,f)=>c+f,0),a=a.flat();if(a.length<=r)return e;const o=this.isInfinite?this.getInfiniteLines(a,t,r):this.getFiniteLines(a,t,r);return this.lastIndex=t,o.join("\n")+"\n"+XD.dim("(Move up and down to reveal more choices)")}getInfiniteLines(e,t,r){if(this.pointer===void 0)this.pointer=0;const a=Math.floor(r/2);if(this.pointer<a&&this.lastIndex<t&&t-this.lastIndex<r)this.pointer=Math.min(a,this.pointer+t-this.lastIndex);const o=[e,e,e].flat(),c=Math.max(0,t+e.length-this.pointer);return o.splice(c,r)}getFiniteLines(e,t,r){let a=t-r/2;if(a<0)a=0;else if(a+r>e.length)a=e.length-r;return e.splice(a,r)}}function vLe(e,t,r){const a=r.choices.realLength,o="loop"in r?Boolean(r.loop):!0;if(t==="up"){if(e>0)return e-1;return o?a-1:e}if(t==="down"){if(e<a-1)return e+1;return o?0:e}throw new Error("dir must be up or down")}var rJt=U_(R8n(),1),aJt=U_(eNt(),1);var Dhn=U_(sB0(),1),aTe=U_(_de(),1);var JMt=U_(FMt(),1),kMt=U_(NMt(),1);import IMt from"node:assert";var MMt=U_(iZ0(),1);class lde{constructor(e){this.type="separator",this.line=XD.dim(e||new Array(15).join(MMt.default.line))}static exclude(e){return e.type!=="separator"}toString(){return this.line}}class x60{constructor(e,t){if(e instanceof x60||e.type==="separator")return e;if(typeof e==="string"||typeof e==="number")this.name=String(e),this.value=e,this.short=String(e);else Object.assign(this,e,{name:e.name||e.value,value:"value"in e?e.value:e.name,short:e.short||e.name||e.value});if(typeof e.disabled==="function")this.disabled=e.disabled(t);else this.disabled=e.disabled}}class YZ0{constructor(e,t){this.choices=e.map((r)=>{if(r.type==="separator"){if(!(r instanceof lde))r=new lde(r.line);return r}return new x60(r,t)}),this.realChoices=this.choices.filter(lde.exclude).filter((r)=>!r.disabled),Object.defineProperty(this,"length",{get(){return this.choices.length},set(r){this.choices.length=r}}),Object.defineProperty(this,"realLength",{get(){return this.realChoices.length},set(){throw new Error("Cannot set `realLength` of a Choices collection")}})}getChoice(e){return IMt(typeof e==="number"),this.realChoices[e]}get(e){return IMt(typeof e==="number"),this.choices[e]}where(e){return JMt.default(this.realChoices,e)}pluck(e){return kMt.default(this.realChoices,e)}indexOf(...e){return this.choices.indexOf(...e)}forEach(...e){return this.choices.forEach(...e)}filter(...e){return this.choices.filter(...e)}reduce(...e){return this.choices.reduce(...e)}find(e){return this.choices.find(e)}push(...e){const t=e.map((r)=>new x60(r));return this.choices.push(...t),this.realChoices=this.choices.filter(lde.exclude).filter((r)=>!r.disabled),this.choices}}var jIt=U_(OMt(),1),eJt=U_(LMt(),1),nJt=U_(wme(),1),tJt=U_(Eze(),1),vhn=U_(QIt(),1);var g60=U_(fC0(),1),tK0=function(e,t){e.output.write(g60.default.cursorBackward(t))},ZIt=function(e,t){e.output.write(g60.default.cursorForward(t))},KIt=function(e,t){e.output.write(g60.default.cursorUp(t))},yhn=function(e,t){e.output.write(g60.default.cursorDown(t))},BB0=function(e,t){e.output.write(g60.default.eraseLines(t))};var GIt=function(e){return e.split("\n").length},RIt=function(e){return e.split("\n").pop()};class iK0{constructor(e){this.height=0,this.extraLinesUnderPrompt=0,this.rl=e}renderWithSpinner(e,t){if(this.spinnerId)clearInterval(this.spinnerId);let r,a,o;if(t)r=vhn.default(t),a=()=>e,o=()=>r.frame();else r=vhn.default(e),a=()=>r.frame(),o=()=>"";this.spinnerId=setInterval(()=>this.render(a(),o(),!0),r.interval)}render(e,t,r=!1){if(this.spinnerId&&!r)clearInterval(this.spinnerId);this.rl.output.unmute(),this.clean(this.extraLinesUnderPrompt);const a=RIt(e),o=nJt.default(a);let c=o;if(this.rl.line.length)c=c.slice(0,-this.rl.line.length);this.rl.setPrompt(c);const f=this.rl._getCursorPos(),x=this.normalizedCliWidth();if(e=this.forceLineReturn(e,x),t&&=this.forceLineReturn(t,x),o.length%x===0)e+="\n";const A=e+(t?"\n"+t:"");this.rl.output.write(A);const T=Math.floor(o.length/x)-f.rows+(t?GIt(t):0);if(T>0)KIt(this.rl,T);if(tK0(this.rl,tJt.default(RIt(A))),f.cols>0)ZIt(this.rl,f.cols);this.extraLinesUnderPrompt=T,this.height=GIt(A),this.rl.output.mute()}clean(e){if(e>0)yhn(this.rl,e);BB0(this.rl,this.height)}done(){this.rl.setPrompt(""),this.rl.output.unmute(),this.rl.output.write("\n")}releaseCursor(){if(this.extraLinesUnderPrompt>0)yhn(this.rl,this.extraLinesUnderPrompt)}normalizedCliWidth(){return jIt.default({defaultWidth:80,output:this.rl.output})}breakLines(e,t=this.normalizedCliWidth()){return e.map((r)=>eJt.default(r,t,{trim:!1,hard:!0}).split("\n"))}forceLineReturn(e,t=this.normalizedCliWidth()){return this.breakLines(e.split("\n"),t).flat().join("\n")}}var iJt={defaults:rJt.default,clone:aJt.default};class ste{constructor(e,t,r){if(Object.assign(this,{answers:r,status:"pending"}),this.opt=iJt.defaults(iJt.clone(e),{validate:()=>!0,validatingText:"",filter:(a)=>a,filteringText:"",when:()=>!0,suffix:"",prefix:XD.green("?"),transformer:(a)=>a}),!this.opt.name)this.throwParamError("name");if(this.opt.message||=this.opt.name+":",Array.isArray(this.opt.choices))this.opt.choices=new YZ0(this.opt.choices,r);this.rl=t,this.screen=new iK0(this.rl)}run(){return new Promise((e,t)=>{this._run((r)=>e(r),(r)=>t(r))})}_run(e){e()}throwParamError(e){throw new Error("You must provide a `"+e+"` parameter")}close(){this.screen.releaseCursor()}handleSubmitEvents(e){const t=this,r=Dhn.default(this.opt.validate),a=Dhn.default(this.opt.filter),o=e.pipe(aTe.flatMap((x)=>{return this.startSpinner(x,this.opt.filteringText),a(x,t.answers).then((A)=>{return this.startSpinner(A,this.opt.validatingText),r(A,t.answers).then((E)=>({isValid:E,value:A}),(E)=>({isValid:E,value:A}))},(A)=>({isValid:A}))}),aTe.share()),c=o.pipe(aTe.filter((x)=>x.isValid===!0),aTe.take(1)),f=o.pipe(aTe.filter((x)=>x.isValid!==!0),aTe.takeUntil(c));return{success:c,error:f}}startSpinner(e,t){e=this.getSpinningValue(e);const r=t?this.getQuestion()+e:this.getQuestion().slice(this.opt.prefix.length+1)+e;this.screen.renderWithSpinner(r,t)}getSpinningValue(e){return e}getQuestion(){let e=(this.opt.prefix?this.opt.prefix+" ":"")+XD.bold(this.opt.message)+this.opt.suffix+XD.reset(" ");if(this.opt.default!=null&&this.status!=="touched"&&this.status!=="answered")if(this.opt.type==="password")e+=XD.italic.dim("[hidden] ");else e+=XD.dim("("+this.opt.default+") ");return e}}var Tea=function(e,t){let r="",a=0;return e.forEach((o,c)=>{if(o.type==="separator"){a++,r+=" "+o+"\n";return}if(o.disabled){a++,r+=" - "+o.name,r+=` (${typeof o.disabled==="string"?o.disabled:"Disabled"})`,r+="\n";return}const f=c-a===t;let x=(f?uJt.default.pointer+" ":" ")+o.name;if(f)x=XD.cyan(x);r+=x+" \n"}),r.replace(/\n$/,"")};class rK0 extends ste{constructor(e,t,r){super(e,t,r);if(!this.opt.choices)this.throwParamError("choices");this.firstRender=!0,this.selected=0;const a=this.opt.default;if(typeof a==="number"&&a>=0&&a<this.opt.choices.realLength)this.selected=a;else if(typeof a!=="number"&&a!=null){const c=this.opt.choices.realChoices.findIndex(({value:f})=>f===a);this.selected=Math.max(c,0)}this.opt.default=null;const o=this.opt.loop===void 0?!0:this.opt.loop;this.paginator=new EBe(this.screen,{isInfinite:o})}_run(e){this.done=e;const t=this,r=Cae(this.rl);return r.normalizedUpKey.pipe(TBe.takeUntil(r.line)).forEach(this.onUpKey.bind(this)),r.normalizedDownKey.pipe(TBe.takeUntil(r.line)).forEach(this.onDownKey.bind(this)),r.numberKey.pipe(TBe.takeUntil(r.line)).forEach(this.onNumberKey.bind(this)),r.line.pipe(TBe.take(1),TBe.map(this.getCurrentValue.bind(this)),TBe.flatMap((a)=>oJt.default(t.opt.filter)(a,t.answers).catch((o)=>o))).forEach(this.onSubmit.bind(this)),xhn.default.hide(),this.render(),this}render(){let e=this.getQuestion();if(this.firstRender)e+=XD.dim("(Use arrow keys)");if(this.status==="answered")e+=XD.cyan(this.opt.choices.getChoice(this.selected).short);else{const t=Tea(this.opt.choices,this.selected),r=this.opt.choices.indexOf(this.opt.choices.getChoice(this.selected)),a=this.opt.choices.reduce((o,c,f)=>{if(f>r)return o;if(c.type==="separator")return o+1;let x=c.name;if(typeof x!=="string")return o+1;return x=x.split("\n"),o+x.length},0)-1;e+="\n"+this.paginator.paginate(t,a,this.opt.pageSize)}this.firstRender=!1,this.screen.render(e)}onSubmit(e){this.status="answered",this.render(),this.screen.done(),xhn.default.show(),this.done(e)}getCurrentValue(){return this.opt.choices.getChoice(this.selected).value}onUpKey(){this.selected=vLe(this.selected,"up",this.opt),this.render()}onDownKey(){this.selected=vLe(this.selected,"down",this.opt),this.render()}onNumberKey(e){if(e<=this.opt.choices.realLength)this.selected=e-1;this.render()}}var aK0=U_(_de(),1);class E60 extends ste{_run(e){this.done=e;const t=Cae(this.rl),r=t.line.pipe(aK0.map(this.filterInput.bind(this))),a=this.handleSubmitEvents(r);return a.success.forEach(this.onEnd.bind(this)),a.error.forEach(this.onError.bind(this)),t.keypress.pipe(aK0.takeUntil(a.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(e){let t="",r="",a=this.getQuestion();const{transformer:o}=this.opt,c=this.status==="answered";if(c)r=this.answer;else r=this.rl.line;if(o)a+=o(r,this.answers,{isFinal:c});else a+=c?XD.cyan(r):r;if(e)t=XD.red(">> ")+e;this.screen.render(a,t)}filterInput(e){if(!e)return this.opt.default==null?"":this.opt.default;return e}onEnd(e){this.answer=e.value,this.status="answered",this.render(),this.screen.done(),this.done(e.value)}onError({value:e="",isValid:t}){this.rl.line+=e,this.rl.cursor+=e.length,this.render(t)}onKeypress(){this.status="touched",this.render()}}class uK0 extends E60{filterInput(e){if(e&&typeof e==="string"){e=e.trim();const t=e.match(/(^-?\d+|^-?\d+\.\d*|^\d*\.\d+)(e\d+)?$/);if(t)return Number(t[0])}return this.opt.default==null?NaN:this.opt.default}}var oK0=U_(_de(),1);class sK0 extends ste{constructor(e,t,r){super(e,t,r);let a=!0;if(Object.assign(this.opt,{filter(o){if(o!=null&&o!==""){if(/^y(es)?/i.test(o))return!0;if(/^n(o)?/i.test(o))return!1}return a}}),this.opt.default!=null)a=Boolean(this.opt.default);this.opt.default=a?"Y/n":"y/N"}_run(e){this.done=e;const t=Cae(this.rl);return t.keypress.pipe(oK0.takeUntil(t.line)).forEach(this.onKeypress.bind(this)),t.line.pipe(oK0.take(1)).forEach(this.onEnd.bind(this)),this.render(),this}render(e){let t=this.getQuestion();if(typeof e==="boolean")t+=XD.cyan(e?"Yes":"No");else if(e)t+=e;else t+=this.rl.line;return this.screen.render(t),this}onEnd(e){this.status="answered";let t=this.opt.filter(e);if(this.opt.transformer)t=this.opt.transformer(t);this.render(t),this.screen.done(),this.done(t)}onKeypress(){this.render()}}var T60=U_(_de(),1);var Cea=function(e,t){let r="",a=0;return e.forEach((o,c)=>{if(r+=r?"\n ":" ",o.type==="separator"){a++,r+=" "+o;return}const f=c-a;let x=f+1+") "+o.name;if(f===t)x=XD.cyan(x);r+=x}),r};class _K0 extends ste{constructor(e,t,r){super(e,t,r);if(this.hiddenLine="",this.lastKey="",!this.opt.choices)this.throwParamError("choices");this.opt.validChoices=this.opt.choices.filter(lde.exclude),this.selected=0,this.rawDefault=0,Object.assign(this.opt,{validate(c){return c!=null}});const a=this.opt.default;if(typeof a==="number"&&a>=0&&a<this.opt.choices.realLength)this.selected=a,this.rawDefault=a;else if(typeof a!=="number"&&a!=null){const c=this.opt.choices.realChoices.findIndex(({value:x})=>x===a),f=Math.max(c,0);this.selected=f,this.rawDefault=f}this.opt.default=null;const o=this.opt.loop===void 0?!0:this.opt.loop;this.paginator=new EBe(void 0,{isInfinite:o})}_run(e){this.done=e;const t=Cae(this.rl),r=t.line.pipe(T60.map(this.getCurrentValue.bind(this))),a=this.handleSubmitEvents(r);return a.success.forEach(this.onEnd.bind(this)),a.error.forEach(this.onError.bind(this)),t.normalizedUpKey.pipe(T60.takeUntil(a.success)).forEach(this.onUpKey.bind(this)),t.normalizedDownKey.pipe(T60.takeUntil(a.success)).forEach(this.onDownKey.bind(this)),t.keypress.pipe(T60.takeUntil(a.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(e){let t=this.getQuestion(),r="";if(this.status==="answered")t+=XD.cyan(this.opt.choices.getChoice(this.selected).short);else{const a=Cea(this.opt.choices,this.selected);t+="\n"+this.paginator.paginate(a,this.selected,this.opt.pageSize),t+="\n Answer: "}if(t+=this.rl.line,e)r="\n"+XD.red(">> ")+e;this.screen.render(t,r)}getCurrentValue(e){if(e==null)e=this.rawDefault;else if(e==="")this.selected=this.selected===void 0?-1:this.selected,e=this.selected;else e-=1;const t=this.opt.choices.getChoice(e);return t?t.value:null}onEnd(e){this.status="answered",this.answer=e.value,this.render(),this.screen.done(),this.done(e.value)}onError(){this.render("Please enter a valid index")}onKeypress(){let e;if(this.lastKey==="arrow")e=this.hiddenLine.length?Number(this.hiddenLine)-1:0;else e=this.rl.line.length?Number(this.rl.line)-1:0;if(this.lastKey="",this.opt.choices.getChoice(e))this.selected=e;else this.selected=void 0;this.render()}onUpKey(){this.onArrowKey("up")}onDownKey(){this.onArrowKey("down")}onArrowKey(e){this.selected=vLe(this.selected,e,this.opt)||0,this.hiddenLine=String(this.selected+1),this.rl.line="",this.lastKey="arrow"}}var lK0=U_(_de(),1);var Fea=function(e,t){let r="";return e.forEach((a)=>{if(r+="\n ",a.type==="separator"){r+=" "+a;return}let o=a.key+") "+a.name;if(t===a.key)o=XD.cyan(o);r+=o}),r};class cK0 extends ste{constructor(e,t,r){super(e,t,r);if(!this.opt.choices)this.throwParamError("choices");this.validateChoices(this.opt.choices),this.opt.choices.push({key:"h",name:"Help, list all options",value:"help"}),this.opt.validate=(a)=>{if(a==null)return"Please enter a valid command";return a!=="help"},this.opt.default=this.generateChoicesString(this.opt.choices,this.opt.default),this.paginator=new EBe(this.screen)}_run(e){this.done=e;const t=Cae(this.rl),r=this.handleSubmitEvents(t.line.pipe(lK0.map(this.getCurrentValue.bind(this))));return r.success.forEach(this.onSubmit.bind(this)),r.error.forEach(this.onError.bind(this)),this.keypressObs=t.keypress.pipe(lK0.takeUntil(r.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(e,t){let r=this.getQuestion(),a="";if(this.status==="answered")r+=XD.cyan(this.answer);else if(this.status==="expanded"){const o=Fea(this.opt.choices,this.selectedKey);r+=this.paginator.paginate(o,this.selectedKey,this.opt.pageSize),r+="\n Answer: "}if(r+=this.rl.line,e)a=XD.red(">> ")+e;if(t)a=XD.cyan(">> ")+t;this.screen.render(r,a)}getCurrentValue(e){e||=this.rawDefault;const t=this.opt.choices.where({key:e.toLowerCase().trim()})[0];if(!t)return null;return t.value}getChoices(){let e="";return this.opt.choices.forEach((t)=>{if(e+="\n ",t.type==="separator"){e+=" "+t;return}let r=t.key+") "+t.name;if(this.selectedKey===t.key)r=XD.cyan(r);e+=r}),e}onError(e){if(e.value==="help"){this.selectedKey="",this.status="expanded",this.render();return}this.render(e.isValid)}onSubmit(e){this.status="answered";const t=this.opt.choices.where({value:e.value})[0];this.answer=t.short||t.name,this.render(),this.screen.done(),this.done(e.value)}onKeypress(){this.selectedKey=this.rl.line.toLowerCase();const e=this.opt.choices.where({key:this.selectedKey})[0];if(this.status==="expanded")this.render();else this.render(null,e?e.name:null)}validateChoices(e){let t;const r=[],a={};if(e.filter(lde.exclude).forEach((o)=>{if(!o.key||o.key.length!==1)t=!0;if(o.key=String(o.key).toLowerCase(),a[o.key])r.push(o.key);a[o.key]=!0}),t)throw new Error("Format error: `key` param must be a single letter and is required.");if(a.h)throw new Error("Reserved key error: `key` param cannot be `h` - this value is reserved.");if(r.length)throw new Error("Duplicate key error: `key` param must be unique. Duplicates: "+[...new Set(r)].join(","))}generateChoicesString(e,t){let r=e.realLength-1;if(typeof t==="number"&&this.opt.choices.getChoice(t))r=t;else if(typeof t==="string"){const o=e.realChoices.findIndex(({value:c})=>c===t);r=o===-1?r:o}const a=this.opt.choices.pluck("key");return this.rawDefault=a[r],a[r]=String(a[r]).toUpperCase(),a.join("")}}var whn=U_(cZ0(),1),pK0=U_(iZ0(),1),DLe=U_(_de(),1);var Sea=function(e,t){let r="",a=0;return e.forEach((o,c)=>{if(o.type==="separator"){a++,r+=" "+o+"\n";return}if(o.disabled)a++,r+=" - "+o.name,r+=` (${typeof o.disabled==="string"?o.disabled:"Disabled"})`;else{const f=Pea(o.checked)+" "+o.name;if(c-a===t)r+=XD.cyan(pK0.default.pointer+f);else r+=" "+f}r+="\n"}),r.replace(/\n$/,"")},Pea=function(e){return e?XD.green(pK0.default.radioOn):pK0.default.radioOff};class fK0 extends ste{constructor(e,t,r){super(e,t,r);if(!this.opt.choices)this.throwParamError("choices");if(Array.isArray(this.opt.default))this.opt.choices.forEach(function(o){if(this.opt.default.indexOf(o.value)>=0)o.checked=!0},this);this.pointer=0,this.opt.default=null;const a=this.opt.loop===void 0?!0:this.opt.loop;this.paginator=new EBe(this.screen,{isInfinite:a})}_run(e){this.done=e;const t=Cae(this.rl),r=this.handleSubmitEvents(t.line.pipe(DLe.map(this.getCurrentValue.bind(this))));return r.success.forEach(this.onEnd.bind(this)),r.error.forEach(this.onError.bind(this)),t.normalizedUpKey.pipe(DLe.takeUntil(r.success)).forEach(this.onUpKey.bind(this)),t.normalizedDownKey.pipe(DLe.takeUntil(r.success)).forEach(this.onDownKey.bind(this)),t.numberKey.pipe(DLe.takeUntil(r.success)).forEach(this.onNumberKey.bind(this)),t.spaceKey.pipe(DLe.takeUntil(r.success)).forEach(this.onSpaceKey.bind(this)),t.aKey.pipe(DLe.takeUntil(r.success)).forEach(this.onAllKey.bind(this)),t.iKey.pipe(DLe.takeUntil(r.success)).forEach(this.onInverseKey.bind(this)),whn.default.hide(),this.render(),this.firstRender=!1,this}render(e){let t=this.getQuestion(),r="";if(!this.dontShowHints)t+="(Press "+XD.cyan.bold("<space>")+" to select, "+XD.cyan.bold("<a>")+" to toggle all, "+XD.cyan.bold("<i>")+" to invert selection, and "+XD.cyan.bold("<enter>")+" to proceed)";if(this.status==="answered")t+=XD.cyan(this.selection.join(", "));else{const a=Sea(this.opt.choices,this.pointer),o=this.opt.choices.indexOf(this.opt.choices.getChoice(this.pointer)),c=this.opt.choices.reduce((f,x,A)=>{if(A>o)return f;if(x.type==="separator")return f+1;let E=x.name;if(typeof E!=="string")return f+1;return E=E.split("\n"),f+E.length},0)-1;t+="\n"+this.paginator.paginate(a,c,this.opt.pageSize)}if(e)r=XD.red(">> ")+e;this.screen.render(t,r)}onEnd(e){this.status="answered",this.dontShowHints=!0,this.render(),this.screen.done(),whn.default.show(),this.done(e.value)}onError(e){this.render(e.isValid)}getCurrentValue(){const e=this.opt.choices.filter((t)=>Boolean(t.checked)&&!t.disabled);return this.selection=e.map((t)=>t.short),e.map((t)=>t.value)}onUpKey(){this.pointer=vLe(this.pointer,"up",this.opt),this.render()}onDownKey(){this.pointer=vLe(this.pointer,"down",this.opt),this.render()}onNumberKey(e){if(e<=this.opt.choices.realLength)this.pointer=e-1,this.toggleChoice(this.pointer);this.render()}onSpaceKey(){this.toggleChoice(this.pointer),this.render()}onAllKey(){const e=Boolean(this.opt.choices.find((t)=>t.type!=="separator"&&!t.checked));this.opt.choices.forEach((t)=>{if(t.type!=="separator")t.checked=e}),this.render()}onInverseKey(){this.opt.choices.forEach((e)=>{if(e.type!=="separator")e.checked=!e.checked}),this.render()}toggleChoice(e){const t=this.opt.choices.getChoice(e);if(t!==void 0)this.opt.choices.getChoice(e).checked=!t.checked}}var dK0=U_(_de(),1);var sJt=function(e,t){if(e=String(e),t=typeof t==="string"?t:"*",e.length===0)return"";return new Array(e.length+1).join(t)};class mK0 extends ste{_run(e){this.done=e;const t=Cae(this.rl),r=t.line.pipe(dK0.map(this.filterInput.bind(this))),a=this.handleSubmitEvents(r);return a.success.forEach(this.onEnd.bind(this)),a.error.forEach(this.onError.bind(this)),t.keypress.pipe(dK0.takeUntil(a.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(e){let t=this.getQuestion(),r="";if(this.status==="answered")t+=this.getMaskedValue(this.answer);else t+=this.getMaskedValue(this.rl.line||"");if(e)r="\n"+XD.red(">> ")+e;this.screen.render(t,r)}getMaskedValue(e){if(this.status==="answered")return this.opt.mask?XD.cyan(sJt(e,this.opt.mask)):XD.italic.dim("[hidden]");return this.opt.mask?sJt(e,this.opt.mask):XD.italic.dim("[input is hidden] ")}getSpinningValue(e){return this.getMaskedValue(e)}filterInput(e){if(!e)return this.opt.default==null?"":this.opt.default;return e}onEnd(e){this.status="answered",this.answer=e.value,this.render(),this.screen.done(),this.done(e.value)}onError(e){this.render(e.isValid)}onKeypress(){this.opt.default&&=void 0,this.render()}}var Kkt=U_(Zkt(),1),Hkt=U_(_de(),1);class MK0 extends ste{_run(e){this.done=e,this.editorResult=new Hkt.Subject;const t=Cae(this.rl);if(this.lineSubscription=t.line.subscribe(this.startExternalEditor.bind(this)),!(this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput))this.startExternalEditor();const a=this.handleSubmitEvents(this.editorResult);return a.success.forEach(this.onEnd.bind(this)),a.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,this.render(),this}render(e){let t="",r=this.getQuestion();if(this.status==="answered")r+=XD.dim("Received");else r+=XD.dim("Press <enter> to launch your preferred editor.");if(e)t=XD.red(">> ")+e;this.screen.render(r,t)}startExternalEditor(){this.rl.pause(),Kkt.editAsync(this.currentText,this.endExternalEditor.bind(this),{postfix:this.opt.postfix??".txt"})}endExternalEditor(e,t){if(this.rl.resume(),e)this.editorResult.error(e);else this.editorResult.next(t)}onEnd(e){this.editorResult.unsubscribe(),this.lineSubscription.unsubscribe(),this.answer=e.value,this.status="answered",this.render(),this.screen.done(),this.done(this.answer)}onError(e){this.render(e.isValid)}}var eOt=U_(Kqt(),1);var jqt=U_(Rqt(),1);import bna from"node:readline";var $na=function(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;const t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){const o=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw o.isTtyError=!0,o}const r=new jqt.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}};class b60{constructor(e){this.rl||=bna.createInterface($na(e)),this.rl.resume(),this.onForceClose=this.onForceClose.bind(this),process.on("exit",this.onForceClose),this.rl.on("SIGINT",this.onForceClose)}onForceClose(){this.close(),process.kill(process.pid,"SIGINT"),console.log("")}close(){if(this.rl.removeListener("SIGINT",this.onForceClose),process.removeListener("exit",this.onForceClose),this.rl.output.unmute(),this.activePrompt&&typeof this.activePrompt.close==="function")this.activePrompt.close();this.rl.output.end(),this.rl.pause(),this.rl.close()}}class YK0 extends b60{constructor(e={}){super(e);this.log=eOt.default(this.writeLog.bind(this)),this.bottomBar=e.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return BB0(this.rl,this.bottomBar.split("\n").length),this}updateBottomBar(e){return BB0(this.rl,1),this.rl.output.unmute(),this.clean(),this.bottomBar=e,this.render(),this.rl.output.mute(),this}writeLog(e){return this.rl.output.unmute(),this.clean(),this.rl.output.write(this.enforceLF(e.toString())),this.render(),this.rl.output.mute(),this}enforceLF(e){return e.match(/[\r\n]$/)?e:e+"\n"}write(e){const t=e.split(/\n/);if(this.height=t.length,this.rl.setPrompt(t[t.length-1]),this.rl.output.rows===0&&this.rl.output.columns===0)tK0(this.rl,e.length+this.rl.line.length);this.rl.output.write(e)}}var oOt=U_(Fdn(),1),sOt=U_(Zmn(),1),_Ot=U_(aOt(),1),UM=U_(_de(),1),lOt=U_(sB0(),1);var XK0=U_(_de(),1),uOt=U_(sB0(),1),WK0=function(e,t,r){if(typeof e[t]!=="function")return XK0.of(e);return XK0.from(uOt.default(e[t])(r).then((a)=>{return e[t]=a,e}))};var WB0={isPlainObject:oOt.default,set:_Ot.default,get:sOt.default};class UB0 extends b60{constructor(e,t){super(t);this.prompts=e}run(e,t){if(WB0.isPlainObject(t))this.answers={...t};else this.answers={};if(WB0.isPlainObject(e))e=Object.values(e).every((a)=>WB0.isPlainObject(a)&&a.name===void 0)?Object.entries(e).map(([a,o])=>({name:a,...o})):[e];const r=Array.isArray(e)?UM.from(e):e;return this.process=r.pipe(UM.concatMap(this.processQuestion.bind(this)),UM.publish()),this.process.connect(),this.process.pipe(UM.reduce((a,o)=>{return WB0.set(a,o.name,o.answer),a},this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(e){return this.close(),Promise.reject(e)}processQuestion(e){return e={...e},UM.defer(()=>{return UM.of(e).pipe(UM.concatMap(this.setDefaultType.bind(this)),UM.concatMap(this.filterIfRunnable.bind(this)),UM.concatMap(()=>WK0(e,"message",this.answers)),UM.concatMap(()=>WK0(e,"default",this.answers)),UM.concatMap(()=>WK0(e,"choices",this.answers)),UM.concatMap(this.fetchAnswer.bind(this)))})}fetchAnswer(e){const t=this.prompts[e.type];return this.activePrompt=new t(e,this.rl,this.answers),UM.defer(()=>UM.from(this.activePrompt.run().then((r)=>({name:e.name,answer:r}))))}setDefaultType(e){if(!this.prompts[e.type])e.type="input";return UM.defer(()=>UM.of(e))}filterIfRunnable(e){if(e.askAnswered!==!0&&WB0.get(this.answers,e.name)!==void 0)return UM.empty();if(e.when===!1)return UM.empty();if(typeof e.when!=="function")return UM.of(e);const{answers:t}=this;return UM.defer(()=>UM.from(lOt.default(e.when)(t).then((r)=>{if(r)return e})).pipe(UM.filter((r)=>r!=null)))}}function cOt(e){const t=function(r,a){let o;try{o=new UB0(t.prompts,e)}catch(f){return Promise.reject(f)}const c=o.run(r,a);return c.ui=o,c};return t.prompts={},t.registerPrompt=function(r,a){return t.prompts[r]=a,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",rK0),this.registerPrompt("input",E60),this.registerPrompt("number",uK0),this.registerPrompt("confirm",sK0),this.registerPrompt("rawlist",_K0),this.registerPrompt("expand",cK0),this.registerPrompt("checkbox",fK0),this.registerPrompt("password",mK0),this.registerPrompt("editor",MK0)},t.restoreDefaultPrompts(),t}var Zna=function(e,t){hyn.registerPrompt(e,t)},Kna=function(){hyn.restoreDefaultPrompts()},hyn=cOt(),Hna={prompt:hyn,ui:{BottomBar:YK0,Prompt:UB0},createPromptModule:cOt,registerPrompt:Zna,restoreDefaultPrompts:Kna,Separator:lde},Ree=Hna;var IOt=U_(d6(),1),QK0=U_(FOt(),1);var VK0=U_(u8n(),1),BOt=U_(SOt(),1),NOt=U_(POt(),1);VK0.default.extend(BOt.default);VK0.default.extend(NOt.default);var MOt=(e)=>VK0.default(e,"YYYY-MM-DDTHH:mm:ss.SSS000+Z",!0).format("HH:mm:ss.SSS");import{promisify as fta} from"util";var dta=fta(setTimeout),mta=(e)=>{return new Promise((t,r)=>{const a=setInterval(async()=>{try{const o=await q_({document:I_`
32158
32168
  query pollExecution($executionId: ID!) {
32159
32169
  executionResult(id: $executionId) {
32160
32170
  endedAt
@@ -4983,5 +4983,5 @@
4983
4983
  "enableJsonFlag": false
4984
4984
  }
4985
4985
  },
4986
- "version": "7.1.1"
4986
+ "version": "7.1.2"
4987
4987
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/prism",
3
- "version": "7.1.1",
3
+ "version": "7.1.2",
4
4
  "description": "Build, deploy, and support integrations in Prismatic from the comfort of your command line",
5
5
  "keywords": ["prismatic", "cli"],
6
6
  "homepage": "https://prismatic.io",