dyson-swarm-cli 1.3.1 → 1.3.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/dist/index.js CHANGED
@@ -30,7 +30,7 @@ ${E(t)} ${y(e)}`).join("")}showLongVersion(){console.log(this.getLongVersion())}
30
30
  `)[0].matchAll(new RegExp(`(?:${Vs})+|.`,"gu"))].map(([n])=>n);for(let n of i){if(e){let r=at(n);if(at(e)+r>s)break}e+=n}return e}var st=class s extends Array{options={};static from(t){let e=new this(...t);return t instanceof s&&(e.options={...t.options}),e}clone(){let t=new s(...this.map(e=>e instanceof Y?e.clone():e));return t.options={...this.options},t}border(t=!0,e=!0){return(e||typeof this.options.border>"u")&&(this.options.border=t),this}align(t,e=!0){return(e||typeof this.options.align>"u")&&(this.options.align=t),this}getBorder(){return this.options.border===!0}hasBorder(){return this.getBorder()||this.some(t=>t instanceof Y&&t.getBorder())}getAlign(){return this.options.align??"left"}};var es=class{table;options;constructor(t,e){this.table=t,this.options=e}toString(){let t=this.createLayout();return t.rows.length?this.renderRows(t):""}createLayout(){Object.keys(this.options.chars).forEach(l=>{typeof this.options.chars[l]!="string"&&(this.options.chars[l]="")});let t=this.table.getBorder()||this.table.hasBodyBorder(),e=this.table.hasHeaderBorder(),i=e||t,n=this.#t(),r=Math.max(...n.map(l=>l.length));for(let l=0;l<n.length;l++){let c=n[l],u=c.length;if(u<r){let h=r-u;for(let p=0;p<h;p++)c.push(this.createCell(null,c,l,u+p))}}let a=[],o=[];for(let l=0;l<r;l++){let c=this.options.columns.at(l),u=c?.getMinWidth()??(Array.isArray(this.options.minColWidth)?this.options.minColWidth[l]:this.options.minColWidth),h=c?.getMaxWidth()??(Array.isArray(this.options.maxColWidth)?this.options.maxColWidth[l]:this.options.maxColWidth),p=ii(l,n,h);o[l]=Math.min(h,Math.max(u,p)),a[l]=c?.getPadding()??(Array.isArray(this.options.padding)?this.options.padding[l]:this.options.padding)}return{padding:a,width:o,rows:n,columns:r,hasBorder:i,hasBodyBorder:t,hasHeaderBorder:e}}#t(){let t=this.table.getHeader(),e=t?[t,...this.table]:this.table.slice();return e.some(n=>n.some(r=>r instanceof Y&&(r.getColSpan()>1||r.getRowSpan()>1)))?this.spanRows(e):e.map((n,r)=>{let a=this.createRow(n);for(let o=0;o<n.length;o++)a[o]=this.createCell(n[o],a,r,o);return a})}spanRows(t){let e=[],i=1,n=-1;for(;n++,!(n===t.length&&e.every(o=>o===1));){let r=t[n]=this.createRow(t[n]||[]),a=-1;for(;a++,!(a===r.length&&a===e.length&&i===1);){if(i>1){i--,e[a]=e[a-1],r.splice(a,this.getDeleteCount(t,n,a),r[a-1]);continue}if(e[a]>1){e[a]--,t[n].splice(a,this.getDeleteCount(t,n,a),t[n-1][a]);continue}let o=r[a]=this.createCell(r[a]||null,r,n,a);i=o.getColSpan(),e[a]=o.getRowSpan()}}return t}getDeleteCount(t,e,i){return i<=t[e].length-1&&typeof t[e][i]>"u"?1:0}createRow(t){return st.from(t).border(this.table.getBorder(),!1).align(this.table.getAlign(),!1)}createCell(t,e,i,n){let r=this.options.columns.at(n),a=this.isHeaderRow(i);return Y.from(t??"").border((a?null:r?.getBorder())??e.getBorder(),!1).align((a?null:r?.getAlign())??e.getAlign(),!1)}isHeaderRow(t){return t===0&&this.table.getHeader()!==void 0}renderRows(t){let e="",i=new Array(t.columns).fill(1);for(let n=0;n<t.rows.length;n++)e+=this.renderRow(i,n,t);return e.slice(0,-1)}renderRow(t,e,i,n){let r=i.rows[e],a=i.rows[e-1],o=i.rows[e+1],l="",c=1;!n&&e===0&&r.hasBorder()&&(l+=this.renderBorderRow(void 0,r,t,i));let u=!1;l+=" ".repeat(this.options.indent||0);for(let h=0;h<i.columns;h++){if(c>1){c--,t[h]=t[h-1];continue}l+=this.renderCell(h,r,i),t[h]>1?n||t[h]--:(!a||a[h]!==r[h])&&(t[h]=r[h].getRowSpan()),c=r[h].getColSpan(),t[h]===1&&r[h].length&&(u=!0)}return i.columns>0&&(r[i.columns-1].getBorder()?l+=this.options.chars.right:i.hasBorder&&(l+=" ")),l+=`
31
31
  `,u?l+this.renderRow(t,e,i,u):(i.rows.length>1&&(e===0&&i.hasHeaderBorder||e<i.rows.length-1&&i.hasBodyBorder)&&(l+=this.renderBorderRow(r,o,t,i)),e===i.rows.length-1&&r.hasBorder()&&(l+=this.renderBorderRow(r,void 0,t,i)),l)}renderCell(t,e,i,n){let r="",a=e[t-1],o=e[t];n||(t===0?o.getBorder()?r+=this.options.chars.left:i.hasBorder&&(r+=" "):o.getBorder()||a?.getBorder()?r+=this.options.chars.middle:i.hasBorder&&(r+=" "));let l=i.width[t],c=o.getColSpan();if(c>1)for(let p=1;p<c;p++)l+=i.width[t+p]+i.padding[t+p],i.hasBorder&&(l+=i.padding[t+p]+1);let{current:u,next:h}=this.renderCellValue(o,l);return e[t].setValue(h),i.hasBorder&&(r+=" ".repeat(i.padding[t])),r+=u,(i.hasBorder||t<i.columns-1)&&(r+=" ".repeat(i.padding[t])),r}renderCellValue(t,e){let i=Math.min(e,at(t.toString())),n=ce(i,t.toString()),r=at(n)>i;r&&(n=ri(i,n));let a=t.toString().slice(n.length+(r?0:1));n=t.unclosedAnsiRuns+n;let{currentSuffix:o,nextPrefix:l}=ni(n);n+=o,t.unclosedAnsiRuns=l;let c=e-at(n),u=t.getAlign(),h;if(c===0)h=n;else if(u==="left")h=n+" ".repeat(c);else if(u==="center")h=" ".repeat(Math.floor(c/2))+n+" ".repeat(Math.ceil(c/2));else if(u==="right")h=" ".repeat(c)+n;else throw new Error("Unknown direction: "+u);return{current:h,next:a}}renderBorderRow(t,e,i,n){let r="",a=1;for(let o=0;o<n.columns;o++){if(i[o]>1){if(!e)throw new Error("invalid layout");if(a>1){a--;continue}}r+=this.renderBorderCell(o,t,e,i,n),a=e?.[o].getColSpan()??1}return r.length?" ".repeat(this.options.indent)+r+`
32
32
  `:""}renderBorderCell(t,e,i,n,r){let a=e?.[t-1],o=i?.[t-1],l=e?.[t],c=i?.[t],u=!!a?.getBorder(),h=!!o?.getBorder(),p=!!l?.getBorder(),g=!!c?.getBorder(),B=x=>(x?.getColSpan()??1)>1,A=x=>(x?.getRowSpan()??1)>1,f="";if(t===0)n[t]>1?p?f+=this.options.chars.left:f+=" ":p&&g?f+=this.options.chars.leftMid:p?f+=this.options.chars.bottomLeft:g?f+=this.options.chars.topLeft:f+=" ";else if(t<r.columns)if(u&&g||p&&h){let x=B(a),K=B(o),z=B(l),D=B(c),M=A(a),H=A(o),w=A(l),b=A(c),J=u&&g&&p&&h;M&&w&&H&&b&&J?f+=this.options.chars.middle:x&&z&&K&&D&&J&&a===l&&o===c?f+=this.options.chars.mid:x&&z&&a===l?f+=this.options.chars.topMid:K&&D&&o===c?f+=this.options.chars.bottomMid:M&&H&&a===o?f+=this.options.chars.leftMid:w&&b&&l===c?f+=this.options.chars.rightMid:f+=this.options.chars.midMid}else u&&p?B(a)&&B(l)&&a===l?f+=this.options.chars.bottom:f+=this.options.chars.bottomMid:p&&g?n[t]>1?f+=this.options.chars.left:f+=this.options.chars.leftMid:g&&h?B(o)&&B(c)&&o===c?f+=this.options.chars.top:f+=this.options.chars.topMid:u&&h?A(a)&&a===o?f+=this.options.chars.right:f+=this.options.chars.rightMid:u?f+=this.options.chars.bottomRight:p?f+=this.options.chars.bottomLeft:h?f+=this.options.chars.topRight:g?f+=this.options.chars.topLeft:f+=" ";let V=r.padding[t]+r.width[t]+r.padding[t];if(n[t]>1&&i){if(f+=this.renderCell(t,i,r,!0),i[t]===i[i.length-1])return p?f+=this.options.chars.right:f+=" ",f}else p&&g?f+=this.options.chars.mid.repeat(V):p?f+=this.options.chars.bottom.repeat(V):g?f+=this.options.chars.top.repeat(V):f+=" ".repeat(V);return t===r.columns-1&&(p&&g?f+=this.options.chars.rightMid:p?f+=this.options.chars.bottomRight:g?f+=this.options.chars.topRight:f+=" "),f}};var ue=class s extends Array{static _chars={...Bs};options={indent:0,border:!1,maxColWidth:1/0,minColWidth:0,padding:1,chars:{...s._chars},columns:[]};headerRow;static from(t){let e=new this(...t);return t instanceof s&&(e.options={...t.options},e.headerRow=t.headerRow?st.from(t.headerRow):void 0),e}static fromJson(t){return new this().fromJson(t)}static chars(t){return Object.assign(this._chars,t),this}static render(t){s.from(t).render()}fromJson(t){return this.header(Object.keys(t[0])),this.body(t.map(e=>Object.values(e))),this}columns(t){return this.options.columns=t.map(e=>e instanceof ft?e:ft.from(e)),this}column(t,e){return e instanceof ft?this.options.columns[t]=e:this.options.columns[t]?this.options.columns[t].options(e):this.options.columns[t]=ft.from(e),this}header(t){return this.headerRow=t instanceof st?t:st.from(t),this}body(t){return this.length=0,this.push(...t),this}clone(){let t=new s(...this.map(e=>e instanceof st?e.clone():st.from(e).clone()));return t.options={...this.options},t.headerRow=this.headerRow?.clone(),t}toString(){return new es(this,this.options).toString()}render(){return console.log(this.toString()),this}maxColWidth(t,e=!0){return(e||typeof this.options.maxColWidth>"u")&&(this.options.maxColWidth=t),this}minColWidth(t,e=!0){return(e||typeof this.options.minColWidth>"u")&&(this.options.minColWidth=t),this}indent(t,e=!0){return(e||typeof this.options.indent>"u")&&(this.options.indent=t),this}padding(t,e=!0){return(e||typeof this.options.padding>"u")&&(this.options.padding=t),this}border(t=!0,e=!0){return(e||typeof this.options.border>"u")&&(this.options.border=t),this}align(t,e=!0){return(e||typeof this.options.align>"u")&&(this.options.align=t),this}chars(t){return Object.assign(this.options.chars,t),this}getHeader(){return this.headerRow}getBody(){return[...this]}getMaxColWidth(){return this.options.maxColWidth}getMinColWidth(){return this.options.minColWidth}getIndent(){return this.options.indent}getPadding(){return this.options.padding}getBorder(){return this.options.border===!0}hasHeaderBorder(){let t=this.headerRow?.hasBorder();return t===!0||this.getBorder()&&t!==!1}hasBodyBorder(){return this.getBorder()||this.options.columns.some(t=>t.getBorder())||this.some(t=>t instanceof st?t.hasBorder():t.some(e=>e instanceof Y?e.getBorder():!1))}hasBorder(){return this.hasHeaderBorder()||this.hasBodyBorder()}getAlign(){return this.options.align??"left"}getColumns(){return this.options.columns}getColumn(t){return this.options.columns[t]??=new ft}};var ws=Object.create(null),Vr=Object.keys(Tt);for(let s of Vr){if(s==="setColorEnabled"||s==="getColorEnabled"){ws[s]=Tt[s];continue}Object.defineProperty(ws,s,{get(){return Qs([...this._stack,s])}})}var oi=Qs();function Qs(s=[]){let t=function(e,...i){if(typeof e<"u"){let r=s.length-1;return s.reduce((a,o,l)=>l===r?Tt[o](a,...i):Tt[o](a),e)}let n=s.slice();return s=[],Qs(n)};return Object.setPrototypeOf(t,ws),t._stack=s,t}function ai(s,t=0,e=[]){let i=s.getCommands();for(let n of i)e.push({cmd:n,depth:t}),ai(n,t+1,e);return e}function wr(s){if(s)return oi;let t=e=>e;return{bold:Object.assign(t,{cyan:t,yellow:t}),cyan:t,yellow:t,magenta:t,gray:t,red:t,green:t}}function Qr(s,t){let e=t?.colors??!0,i=wr(e),n=[];n.push(`${i.bold.cyan("Usage:")} ${i.bold.yellow(s.getName())} [options] [command]`),n.push(""),n.push(s.getDescription()||"");let r=ai(s);if(r.length>0){n.push(""),n.push(i.bold.cyan("Commands:"));let a=[];for(let{cmd:o,depth:l}of r){let c=o.getName(),u=o.getArguments().map(A=>A.optional?i.gray(`[${A.name}]`):i.magenta(`<${A.name}>`)).join(" "),h=l*2,p=i.bold.yellow(c);a.push([`${" ".repeat(1+h)}${p} ${u}`,o.getDescription()]);let g=o.getArguments();for(let A of g){let f=A.optional,V=f?i.gray(`[${A.name}]`):i.magenta(`<${A.name}>`),x=A.description?` ${A.description}`:"",K=f?i.gray("(Optional)"):i.red("(Required)");a.push([`${" ".repeat(2+h)}${V}`,K+(x||"")])}let B=o.getOptions();for(let A of B){let f=A,V=i.green(f.flags.join(", ")),x=A.description||"";a.push([`${" ".repeat(2+h)}${V}`,x])}a.push(["",""])}a.pop(),n.push(ue.from(a).padding(1).toString())}return n.join(`
33
- `)}function li(s){return function(){return Qr(this,s)}}function ci(s){return s instanceof Set||s instanceof Map}function xr(s,t){let e=Object.getPrototypeOf(s),i=Object.getPrototypeOf(t);return e===i||e===Object.prototype&&i===null||e===null&&i===Object.prototype}function yr(s){let t=Object.getPrototypeOf(s);return t===null||t===Object.prototype||t===Array.prototype}function fi(s){return[...Object.getOwnPropertyNames(s),...Object.getOwnPropertySymbols(s)]}function ui(s){let t=new Set;for(;s!==Object.prototype&&s!==Array.prototype&&s!=null;){for(let e of fi(s))t.add(e);s=Object.getPrototypeOf(s)}return t}var At=globalThis.Temporal??Object.create(null),Cr=new Set([Intl.Locale,RegExp,At.Duration,At.Instant,At.PlainDate,At.PlainDateTime,At.PlainTime,At.PlainYearMonth,At.PlainMonthDay,At.ZonedDateTime,URL,URLSearchParams].filter(s=>s!=null).map(s=>s.prototype));function xs(s){return typeof s=="string"||typeof s=="number"||typeof s=="boolean"||typeof s=="bigint"||typeof s=="symbol"||s==null}var br=Object.getPrototypeOf(Uint8Array);function hi(s,t){if(s.length!==t.length)return!1;for(let e=0;e<t.length;e++)if(!pi(s[e],t[e]))return!1;return!0}function pi(s,t){return s===t||Object.is(s,t)}function ys(s,t){let e=new Map;return(function i(n,r){if(pi(n,r))return!0;if(xs(n)||xs(r))return!1;if(n instanceof Date&&r instanceof Date)return Object.is(n.getTime(),r.getTime());if(n&&typeof n=="object"&&r&&typeof r=="object"){if(!xr(n,r))return!1;if(n instanceof br)return hi(n,r);if(n instanceof ArrayBuffer||globalThis.SharedArrayBuffer&&n instanceof SharedArrayBuffer)return hi(new Uint8Array(n),new Uint8Array(r));if(n instanceof WeakMap)throw new TypeError("Cannot compare WeakMap instances");if(n instanceof WeakSet)throw new TypeError("Cannot compare WeakSet instances");if(n instanceof WeakRef)return i(n.deref(),r.deref());if(e.get(n)===r)return!0;if(Object.keys(n).length!==Object.keys(r).length)return!1;if(e.set(n,r),ci(n)&&ci(r)){if(n.size!==r.size)return!1;let o=[...n.keys()];if(o.every(xs)){if(n instanceof Set)return n.symmetricDifference(r).size===0;for(let u of o)if(!r.has(u)||!i(n.get(u),r.get(u)))return!1;return!0}let c=n.size;for(let[u,h]of n.entries())for(let[p,g]of r.entries())if(i(u,p)&&(u===h&&p===g||i(h,g))){c--;break}return c===0}let a;if(yr(n))a=fi({...n,...r});else{if(Cr.has(Object.getPrototypeOf(n)))return String(n)===String(r);a=ui(n).union(ui(r))}for(let o of a)if(!i(n[o],r[o])||o in n&&!(o in r)||o in r&&!(o in n))return!1;return!0}return!1})(s,t)}function Lt(){let{Deno:s,process:t}=globalThis;if(s)return s.build.os;if(t)return t.platform;throw new Error("unsupported runtime")}var gi={ARROW_UP:"\u2191",ARROW_DOWN:"\u2193",ARROW_LEFT:"\u2190",ARROW_RIGHT:"\u2192",ARROW_UP_LEFT:"\u2196",ARROW_UP_RIGHT:"\u2197",ARROW_DOWN_RIGHT:"\u2198",ARROW_DOWN_LEFT:"\u2199",RADIO_ON:"\u25C9",RADIO_OFF:"\u25EF",TICK:"\u2714",CROSS:"\u2718",ELLIPSIS:"\u2026",POINTER_SMALL:"\u203A",POINTER_SMALL_LEFT:"\u2039",LINE:"\u2500",POINTER:"\u276F",POINTER_LEFT:"\u276E",INFO:"\u2139",TAB_LEFT:"\u21E4",TAB_RIGHT:"\u21E5",ESCAPE:"\u238B",BACKSPACE:"\u232B",PAGE_UP:"\u21DE",PAGE_DOWN:"\u21DF",ENTER:"\u21B5",SEARCH:"\u{1F50E}",FOLDER:"\u{1F4C1}",FOLDER_OPEN:"\u{1F4C2}"},Rr={...gi,RADIO_ON:"(*)",RADIO_OFF:"( )",TICK:"\u221A",CROSS:"\xD7",POINTER_SMALL:"\xBB"},P=Lt()==="windows"?Rr:gi,Or={up:"ARROW_UP",down:"ARROW_DOWN",left:"ARROW_LEFT",right:"ARROW_RIGHT",pageup:"PAGE_UP",pagedown:"PAGE_DOWN",tab:"TAB_RIGHT",enter:"ENTER",return:"ENTER"};function O(s){let t=[];for(let e of s){let i=P[Or[e]]??e;t.includes(i)||t.push(i)}return t}var{Deno:di,process:Ai,Buffer:Sr}=globalThis,{readSync:mi}=Ai?await import("fs"):{readSync:null};function Wt(s){if(di)return di.stdin.readSync(s);if(mi){let t=Sr.alloc(s.byteLength),e=mi(Ai.stdout.fd,t,0,t.length,null);for(let i=0;i<e;i++)s[i]=t[i];return e}else throw new Error("unsupported runtime")}function kt(s,{cbreak:t}={}){let{Deno:e,process:i}=globalThis;if(e)e.stdin.setRaw(s,{cbreak:t});else if(i)i.stdin.setRawMode(s);else throw new Error("unsupported runtime")}function Bt(s){let{Deno:t,process:e}=globalThis;if(t)return t.stdout.writeSync(s);if(e)return e.stdout.write(s),s.byteLength;throw new Error("unsupported runtime")}var Os={};Ms(Os,{bel:()=>is,clearScreen:()=>zr,clearTerminal:()=>Zr,cursorBackward:()=>Tr,cursorDown:()=>Fr,cursorForward:()=>Dr,cursorHide:()=>Lr,cursorLeft:()=>bi,cursorMove:()=>Pr,cursorNextLine:()=>Ir,cursorPosition:()=>Rs,cursorPrevLine:()=>$r,cursorRestore:()=>Hr,cursorSave:()=>Mr,cursorShow:()=>Wr,cursorTo:()=>Ur,cursorUp:()=>Ci,eraseDown:()=>qr,eraseLine:()=>Ri,eraseLineEnd:()=>_r,eraseLineStart:()=>Xr,eraseLines:()=>Kr,eraseScreen:()=>bs,eraseUp:()=>jr,image:()=>Jr,link:()=>Yr,scrollDown:()=>Gr,scrollUp:()=>Nr});var Bi={base64:new TextEncoder().encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),base64url:new TextEncoder().encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_")},Ei={base64:new Uint8Array(128).fill(64),base64url:new Uint8Array(128).fill(64)};Bi.base64.forEach((s,t)=>Ei.base64[s]=t);Bi.base64url.forEach((s,t)=>Ei.base64url[s]=t);function Vi(s){return((s+2)/3|0)*4}function wi(s,t,e,i,n){for(t+=2;t<s.length;t+=3){let r=s[t-2]<<16|s[t-1]<<8|s[t];s[e++]=i[r>>18],s[e++]=i[r>>12&63],s[e++]=i[r>>6&63],s[e++]=i[r&63]}switch(t){case s.length+1:{let r=s[t-2]<<16;s[e++]=i[r>>18],s[e++]=i[r>>12&63],s[e++]=n,s[e++]=n;break}case s.length:{let r=s[t-2]<<16|s[t-1]<<8;s[e++]=i[r>>18],s[e++]=i[r>>12&63],s[e++]=i[r>>6&63],s[e++]=n;break}}return e}function Qi(s,t){let e=s.length;if(s.byteOffset){let i=new Uint8Array(s.buffer);i.set(s),s=i.subarray(0,e)}return s=new Uint8Array(s.buffer.transfer(t)),s.set(s.subarray(0,e),t-e),[s,t-e]}var kr=61,xi=new TextEncoder().encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),vr=new Uint8Array(128).fill(64);xi.forEach((s,t)=>vr[s]=t);function yi(s){typeof s=="string"?s=new TextEncoder().encode(s):s instanceof ArrayBuffer?s=new Uint8Array(s).slice():s=s.slice();let[t,e]=Qi(s,Vi(s.length));return wi(t,e,0,xi,kr),new TextDecoder().decode(t)}var ns="\x1B",C=`${ns}[`,Cs=`${ns}]`,ss=";",is="\x07",Rs=`${C}6n`;function Ur(s,t){return typeof t!="number"?`${C}${s}G`:`${C}${t};${s}H`}function Pr(s,t){let e="";return s<0?e+=`${C}${-s}D`:s>0&&(e+=`${C}${s}C`),t<0?e+=`${C}${-t}A`:t>0&&(e+=`${C}${t}B`),e}function Ci(s=1){return`${C}${s}A`}function Fr(s=1){return`${C}${s}B`}function Dr(s=1){return`${C}${s}C`}function Tr(s=1){return`${C}${s}D`}function Ir(s=1){return`${C}E`.repeat(s)}function $r(s=1){return`${C}F`.repeat(s)}var bi=`${C}G`,Lr=`${C}?25l`,Wr=`${C}?25h`,Mr=`${ns}7`,Hr=`${ns}8`;function Nr(s=1){return`${C}S`.repeat(s)}function Gr(s=1){return`${C}T`.repeat(s)}var bs=`${C}2J`;function jr(s=1){return`${C}1J`.repeat(s)}function qr(s=1){return`${C}0J`.repeat(s)}var Ri=`${C}2K`,_r=`${C}0K`,Xr=`${C}1K`;function Kr(s){let t="";for(let e=0;e<s;e++)t+=Ri+(e<s-1?Ci():"");return t+=bi,t}var zr="\x1Bc",Zr=Lt()==="windows"?`${bs}${C}0f`:`${bs}${C}3J${C}H`;function Yr(s,t){return[Cs,"8",ss,ss,t,is,s,Cs,"8",ss,ss,is].join("")}function Jr(s,t){let e=`${Cs}1337;File=inline=1`;return t?.width&&(e+=`;width=${t.width}`),t?.height&&(e+=`;height=${t.height}`),t?.preserveAspectRatio===!1&&(e+=";preserveAspectRatio=0"),e+":"+yi(s)+is}var to=new TextEncoder,eo=new TextDecoder;function Oi({reader:s={readSync:Wt,setRaw:kt},writer:t={writeSync:Bt}}={}){let e=new Uint8Array(8);s.setRaw(!0),t.writeSync(to.encode(Rs)),s.readSync(e),s.setRaw(!1);let[i,n]=eo.decode(e).match(/\[(\d+);(\d+)R/)?.slice(1,3).map(Number)??[0,0];return{x:n,y:i}}var Ss=ki(),Si=new TextEncoder;function ki(s){let t="",e=[],i=s?.writer??{writeSync:Bt},n=s?.reader??{readSync:Wt,setRaw:kt},r=function(...l){return this?(o(l),i.writeSync(Si.encode(t)),this):ki(l[0]??s)};r.text=function(l){return e.push([l,[]]),o(),i.writeSync(Si.encode(t)),this},r.getCursorPosition=()=>Oi({writer:i,reader:n});let a=Object.entries(Os);for(let[l,c]of a)l!=="cursorPosition"&&Object.defineProperty(r,l,{get(){return e.push([c,[]]),this}});return r;function o(l){e.length&&(l&&(e[e.length-1][1]=l),t=e.reduce((c,[u,h])=>c+(typeof u=="string"?u:u.call(r,...h)),""),e=[])}}function vi(){switch(!0){case"Deno"in globalThis:return"deno";case"Bun"in globalThis:return"bun";case"process"in globalThis:return"node";default:throw new Error("unsupported runtime")}}var ks={"[P":"f1","[Q":"f2","[R":"f3","[S":"f4",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"},vs={"[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end","[Z":"tab"},Us={Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end"},Ps={"\r":"return","\n":"enter"," ":"tab","\b":"backspace","\x7F":"backspace","\x1B":"escape"," ":"space"};var so=65536,Ui="\x1B";function Fs(s){let t=-1,e=[],i=s instanceof Uint8Array?new TextDecoder().decode(s):s,n=()=>i.length-1>=t+1,r=()=>i[++t];return a(),e;function a(){let o=r(),l=o,c=!1,u={name:void 0,char:void 0,sequence:void 0,code:void 0,ctrl:!1,meta:!1,shift:!1};if(o===Ui&&n()&&(c=!0,l+=o=r(),o===Ui&&(l+=o=r())),c&&(o==="O"||o==="[")){let h=o,p=0;if(o==="O")l+=o=r(),o>="0"&&o<="9"&&(p=(Number(o)>>0)-1,l+=o=r()),h+=o;else if(o==="["){l+=o=r(),o==="["&&(h+=o,l+=o=r());let g=l.length-1;o>="0"&&o<="9"&&(l+=o=r(),o>="0"&&o<="9"&&(l+=o=r())),o===";"&&(l+=o=r(),o>="0"&&o<="9"&&(l+=r()));let B=l.slice(g),A;(A=B.match(/^(\d\d?)(;(\d))?([~^$])$/))?(h+=A[1]+A[4],p=(Number(A[3])||1)-1):(A=B.match(/^((\d;)?(\d))?([A-Za-z])$/))?(h+=A[4],p=(Number(A[3])||1)-1):h+=B}u.ctrl=!!(p&4),u.meta=!!(p&10),u.shift=!!(p&1),u.code=h,h in ks?u.name=ks[h]:h in vs?(u.name=vs[h],u.shift=!0):h in Us?(u.name=Us[h],u.ctrl=!0):u.name="undefined"}else o in Ps?(u.name=Ps[o],u.meta=c,u.name==="space"&&(u.char=o)):!c&&o<=""?(u.name=String.fromCharCode(o.charCodeAt(0)+97-1),u.ctrl=!0,u.char=u.name):/^[0-9A-Za-z]$/.test(o)?(u.name=o.toLowerCase(),u.shift=/^[A-Z]$/.test(o),u.meta=c,u.char=o):c?(u.name=o.length?void 0:"escape",u.meta=!0):(u.name=o,u.char=o);if(u.sequence=l,l.length!==0&&(u.name!==void 0||c)||io(l,0)===l.length)e.push(u);else throw new Error("Unrecognized or broken escape sequence");n()&&a()}}function io(s,t){let e=s.codePointAt(t);return typeof e>"u"?1:e>=so?2:1}function Pi(){try{let{Deno:s,process:t}=globalThis;if(s)return s.consoleSize().columns??null;if(t)return t.stdout.columns??null}catch{return null}throw new Error("unsupported runtime")}function Fi(){let{Deno:s,process:t}=globalThis;if(s)return s.stdin.isTerminal();if(t)return t.stdin.isTTY;throw new Error("unsupported runtime")}function Di(s){let{Deno:t,process:e}=globalThis;if(t)return t.stdin.read(s);if(e)return new Promise((i,n)=>{e.stdin.once("readable",()=>{try{let r=e.stdin.read();if(r===null)return i(null);for(let a=0;a<r.length;a++)s[a]=r[a];i(r.length)}catch(r){n(r)}})});throw new Error("unsupported runtime")}var L=class s{static injectedValue;cursor={x:0,y:0};#t;#e;#s=!0;#i=new TextEncoder;static inject(t){s.injectedValue=t}getDefaultSettings(t){return{...t,tty:Ss({reader:{readSync:Wt,setRaw:kt},writer:t.writer??{writeSync:Bt}}),cbreak:t.cbreak??!1,reader:t.reader??{read:Di,setRaw:kt,isTerminal:Fi},writer:t.writer??{writeSync:Bt},pointer:t.pointer??y(P.POINTER_SMALL),prefix:t.prefix??I("? "),indent:t.indent??"",keys:{submit:["enter","return"],...t.keys??{}}}}async prompt(){try{return await this.#n()}finally{this.settings.tty.cursorShow()}}clear(){this.settings.tty.cursorLeft.eraseDown()}#n=async()=>{if(typeof s.injectedValue<"u"&&this.#e)throw new Error(this.error());if(await this.render(),this.#e=void 0,!await this.read())return this.#n();if(typeof this.#t>"u")throw new Error("internal error: failed to read value");this.clear();let t=this.success(this.#t);return t&&this.settings.writer.writeSync(this.#i.encode(t+`
33
+ `)}function li(s){return function(){return Qr(this,s)}}import{createRequire as ta}from"module";function ci(s){return s instanceof Set||s instanceof Map}function xr(s,t){let e=Object.getPrototypeOf(s),i=Object.getPrototypeOf(t);return e===i||e===Object.prototype&&i===null||e===null&&i===Object.prototype}function yr(s){let t=Object.getPrototypeOf(s);return t===null||t===Object.prototype||t===Array.prototype}function fi(s){return[...Object.getOwnPropertyNames(s),...Object.getOwnPropertySymbols(s)]}function ui(s){let t=new Set;for(;s!==Object.prototype&&s!==Array.prototype&&s!=null;){for(let e of fi(s))t.add(e);s=Object.getPrototypeOf(s)}return t}var At=globalThis.Temporal??Object.create(null),Cr=new Set([Intl.Locale,RegExp,At.Duration,At.Instant,At.PlainDate,At.PlainDateTime,At.PlainTime,At.PlainYearMonth,At.PlainMonthDay,At.ZonedDateTime,URL,URLSearchParams].filter(s=>s!=null).map(s=>s.prototype));function xs(s){return typeof s=="string"||typeof s=="number"||typeof s=="boolean"||typeof s=="bigint"||typeof s=="symbol"||s==null}var br=Object.getPrototypeOf(Uint8Array);function hi(s,t){if(s.length!==t.length)return!1;for(let e=0;e<t.length;e++)if(!pi(s[e],t[e]))return!1;return!0}function pi(s,t){return s===t||Object.is(s,t)}function ys(s,t){let e=new Map;return(function i(n,r){if(pi(n,r))return!0;if(xs(n)||xs(r))return!1;if(n instanceof Date&&r instanceof Date)return Object.is(n.getTime(),r.getTime());if(n&&typeof n=="object"&&r&&typeof r=="object"){if(!xr(n,r))return!1;if(n instanceof br)return hi(n,r);if(n instanceof ArrayBuffer||globalThis.SharedArrayBuffer&&n instanceof SharedArrayBuffer)return hi(new Uint8Array(n),new Uint8Array(r));if(n instanceof WeakMap)throw new TypeError("Cannot compare WeakMap instances");if(n instanceof WeakSet)throw new TypeError("Cannot compare WeakSet instances");if(n instanceof WeakRef)return i(n.deref(),r.deref());if(e.get(n)===r)return!0;if(Object.keys(n).length!==Object.keys(r).length)return!1;if(e.set(n,r),ci(n)&&ci(r)){if(n.size!==r.size)return!1;let o=[...n.keys()];if(o.every(xs)){if(n instanceof Set)return n.symmetricDifference(r).size===0;for(let u of o)if(!r.has(u)||!i(n.get(u),r.get(u)))return!1;return!0}let c=n.size;for(let[u,h]of n.entries())for(let[p,g]of r.entries())if(i(u,p)&&(u===h&&p===g||i(h,g))){c--;break}return c===0}let a;if(yr(n))a=fi({...n,...r});else{if(Cr.has(Object.getPrototypeOf(n)))return String(n)===String(r);a=ui(n).union(ui(r))}for(let o of a)if(!i(n[o],r[o])||o in n&&!(o in r)||o in r&&!(o in n))return!1;return!0}return!1})(s,t)}function Lt(){let{Deno:s,process:t}=globalThis;if(s)return s.build.os;if(t)return t.platform;throw new Error("unsupported runtime")}var gi={ARROW_UP:"\u2191",ARROW_DOWN:"\u2193",ARROW_LEFT:"\u2190",ARROW_RIGHT:"\u2192",ARROW_UP_LEFT:"\u2196",ARROW_UP_RIGHT:"\u2197",ARROW_DOWN_RIGHT:"\u2198",ARROW_DOWN_LEFT:"\u2199",RADIO_ON:"\u25C9",RADIO_OFF:"\u25EF",TICK:"\u2714",CROSS:"\u2718",ELLIPSIS:"\u2026",POINTER_SMALL:"\u203A",POINTER_SMALL_LEFT:"\u2039",LINE:"\u2500",POINTER:"\u276F",POINTER_LEFT:"\u276E",INFO:"\u2139",TAB_LEFT:"\u21E4",TAB_RIGHT:"\u21E5",ESCAPE:"\u238B",BACKSPACE:"\u232B",PAGE_UP:"\u21DE",PAGE_DOWN:"\u21DF",ENTER:"\u21B5",SEARCH:"\u{1F50E}",FOLDER:"\u{1F4C1}",FOLDER_OPEN:"\u{1F4C2}"},Rr={...gi,RADIO_ON:"(*)",RADIO_OFF:"( )",TICK:"\u221A",CROSS:"\xD7",POINTER_SMALL:"\xBB"},P=Lt()==="windows"?Rr:gi,Or={up:"ARROW_UP",down:"ARROW_DOWN",left:"ARROW_LEFT",right:"ARROW_RIGHT",pageup:"PAGE_UP",pagedown:"PAGE_DOWN",tab:"TAB_RIGHT",enter:"ENTER",return:"ENTER"};function O(s){let t=[];for(let e of s){let i=P[Or[e]]??e;t.includes(i)||t.push(i)}return t}var{Deno:di,process:Ai,Buffer:Sr}=globalThis,{readSync:mi}=Ai?await import("fs"):{readSync:null};function Wt(s){if(di)return di.stdin.readSync(s);if(mi){let t=Sr.alloc(s.byteLength),e=mi(Ai.stdout.fd,t,0,t.length,null);for(let i=0;i<e;i++)s[i]=t[i];return e}else throw new Error("unsupported runtime")}function kt(s,{cbreak:t}={}){let{Deno:e,process:i}=globalThis;if(e)e.stdin.setRaw(s,{cbreak:t});else if(i)i.stdin.setRawMode(s);else throw new Error("unsupported runtime")}function Bt(s){let{Deno:t,process:e}=globalThis;if(t)return t.stdout.writeSync(s);if(e)return e.stdout.write(s),s.byteLength;throw new Error("unsupported runtime")}var Os={};Ms(Os,{bel:()=>is,clearScreen:()=>zr,clearTerminal:()=>Zr,cursorBackward:()=>Tr,cursorDown:()=>Fr,cursorForward:()=>Dr,cursorHide:()=>Lr,cursorLeft:()=>bi,cursorMove:()=>Pr,cursorNextLine:()=>Ir,cursorPosition:()=>Rs,cursorPrevLine:()=>$r,cursorRestore:()=>Hr,cursorSave:()=>Mr,cursorShow:()=>Wr,cursorTo:()=>Ur,cursorUp:()=>Ci,eraseDown:()=>qr,eraseLine:()=>Ri,eraseLineEnd:()=>_r,eraseLineStart:()=>Xr,eraseLines:()=>Kr,eraseScreen:()=>bs,eraseUp:()=>jr,image:()=>Jr,link:()=>Yr,scrollDown:()=>Gr,scrollUp:()=>Nr});var Bi={base64:new TextEncoder().encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),base64url:new TextEncoder().encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_")},Ei={base64:new Uint8Array(128).fill(64),base64url:new Uint8Array(128).fill(64)};Bi.base64.forEach((s,t)=>Ei.base64[s]=t);Bi.base64url.forEach((s,t)=>Ei.base64url[s]=t);function Vi(s){return((s+2)/3|0)*4}function wi(s,t,e,i,n){for(t+=2;t<s.length;t+=3){let r=s[t-2]<<16|s[t-1]<<8|s[t];s[e++]=i[r>>18],s[e++]=i[r>>12&63],s[e++]=i[r>>6&63],s[e++]=i[r&63]}switch(t){case s.length+1:{let r=s[t-2]<<16;s[e++]=i[r>>18],s[e++]=i[r>>12&63],s[e++]=n,s[e++]=n;break}case s.length:{let r=s[t-2]<<16|s[t-1]<<8;s[e++]=i[r>>18],s[e++]=i[r>>12&63],s[e++]=i[r>>6&63],s[e++]=n;break}}return e}function Qi(s,t){let e=s.length;if(s.byteOffset){let i=new Uint8Array(s.buffer);i.set(s),s=i.subarray(0,e)}return s=new Uint8Array(s.buffer.transfer(t)),s.set(s.subarray(0,e),t-e),[s,t-e]}var kr=61,xi=new TextEncoder().encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),vr=new Uint8Array(128).fill(64);xi.forEach((s,t)=>vr[s]=t);function yi(s){typeof s=="string"?s=new TextEncoder().encode(s):s instanceof ArrayBuffer?s=new Uint8Array(s).slice():s=s.slice();let[t,e]=Qi(s,Vi(s.length));return wi(t,e,0,xi,kr),new TextDecoder().decode(t)}var ns="\x1B",C=`${ns}[`,Cs=`${ns}]`,ss=";",is="\x07",Rs=`${C}6n`;function Ur(s,t){return typeof t!="number"?`${C}${s}G`:`${C}${t};${s}H`}function Pr(s,t){let e="";return s<0?e+=`${C}${-s}D`:s>0&&(e+=`${C}${s}C`),t<0?e+=`${C}${-t}A`:t>0&&(e+=`${C}${t}B`),e}function Ci(s=1){return`${C}${s}A`}function Fr(s=1){return`${C}${s}B`}function Dr(s=1){return`${C}${s}C`}function Tr(s=1){return`${C}${s}D`}function Ir(s=1){return`${C}E`.repeat(s)}function $r(s=1){return`${C}F`.repeat(s)}var bi=`${C}G`,Lr=`${C}?25l`,Wr=`${C}?25h`,Mr=`${ns}7`,Hr=`${ns}8`;function Nr(s=1){return`${C}S`.repeat(s)}function Gr(s=1){return`${C}T`.repeat(s)}var bs=`${C}2J`;function jr(s=1){return`${C}1J`.repeat(s)}function qr(s=1){return`${C}0J`.repeat(s)}var Ri=`${C}2K`,_r=`${C}0K`,Xr=`${C}1K`;function Kr(s){let t="";for(let e=0;e<s;e++)t+=Ri+(e<s-1?Ci():"");return t+=bi,t}var zr="\x1Bc",Zr=Lt()==="windows"?`${bs}${C}0f`:`${bs}${C}3J${C}H`;function Yr(s,t){return[Cs,"8",ss,ss,t,is,s,Cs,"8",ss,ss,is].join("")}function Jr(s,t){let e=`${Cs}1337;File=inline=1`;return t?.width&&(e+=`;width=${t.width}`),t?.height&&(e+=`;height=${t.height}`),t?.preserveAspectRatio===!1&&(e+=";preserveAspectRatio=0"),e+":"+yi(s)+is}var to=new TextEncoder,eo=new TextDecoder;function Oi({reader:s={readSync:Wt,setRaw:kt},writer:t={writeSync:Bt}}={}){let e=new Uint8Array(8);s.setRaw(!0),t.writeSync(to.encode(Rs)),s.readSync(e),s.setRaw(!1);let[i,n]=eo.decode(e).match(/\[(\d+);(\d+)R/)?.slice(1,3).map(Number)??[0,0];return{x:n,y:i}}var Ss=ki(),Si=new TextEncoder;function ki(s){let t="",e=[],i=s?.writer??{writeSync:Bt},n=s?.reader??{readSync:Wt,setRaw:kt},r=function(...l){return this?(o(l),i.writeSync(Si.encode(t)),this):ki(l[0]??s)};r.text=function(l){return e.push([l,[]]),o(),i.writeSync(Si.encode(t)),this},r.getCursorPosition=()=>Oi({writer:i,reader:n});let a=Object.entries(Os);for(let[l,c]of a)l!=="cursorPosition"&&Object.defineProperty(r,l,{get(){return e.push([c,[]]),this}});return r;function o(l){e.length&&(l&&(e[e.length-1][1]=l),t=e.reduce((c,[u,h])=>c+(typeof u=="string"?u:u.call(r,...h)),""),e=[])}}function vi(){switch(!0){case"Deno"in globalThis:return"deno";case"Bun"in globalThis:return"bun";case"process"in globalThis:return"node";default:throw new Error("unsupported runtime")}}var ks={"[P":"f1","[Q":"f2","[R":"f3","[S":"f4",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"},vs={"[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end","[Z":"tab"},Us={Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end"},Ps={"\r":"return","\n":"enter"," ":"tab","\b":"backspace","\x7F":"backspace","\x1B":"escape"," ":"space"};var so=65536,Ui="\x1B";function Fs(s){let t=-1,e=[],i=s instanceof Uint8Array?new TextDecoder().decode(s):s,n=()=>i.length-1>=t+1,r=()=>i[++t];return a(),e;function a(){let o=r(),l=o,c=!1,u={name:void 0,char:void 0,sequence:void 0,code:void 0,ctrl:!1,meta:!1,shift:!1};if(o===Ui&&n()&&(c=!0,l+=o=r(),o===Ui&&(l+=o=r())),c&&(o==="O"||o==="[")){let h=o,p=0;if(o==="O")l+=o=r(),o>="0"&&o<="9"&&(p=(Number(o)>>0)-1,l+=o=r()),h+=o;else if(o==="["){l+=o=r(),o==="["&&(h+=o,l+=o=r());let g=l.length-1;o>="0"&&o<="9"&&(l+=o=r(),o>="0"&&o<="9"&&(l+=o=r())),o===";"&&(l+=o=r(),o>="0"&&o<="9"&&(l+=r()));let B=l.slice(g),A;(A=B.match(/^(\d\d?)(;(\d))?([~^$])$/))?(h+=A[1]+A[4],p=(Number(A[3])||1)-1):(A=B.match(/^((\d;)?(\d))?([A-Za-z])$/))?(h+=A[4],p=(Number(A[3])||1)-1):h+=B}u.ctrl=!!(p&4),u.meta=!!(p&10),u.shift=!!(p&1),u.code=h,h in ks?u.name=ks[h]:h in vs?(u.name=vs[h],u.shift=!0):h in Us?(u.name=Us[h],u.ctrl=!0):u.name="undefined"}else o in Ps?(u.name=Ps[o],u.meta=c,u.name==="space"&&(u.char=o)):!c&&o<=""?(u.name=String.fromCharCode(o.charCodeAt(0)+97-1),u.ctrl=!0,u.char=u.name):/^[0-9A-Za-z]$/.test(o)?(u.name=o.toLowerCase(),u.shift=/^[A-Z]$/.test(o),u.meta=c,u.char=o):c?(u.name=o.length?void 0:"escape",u.meta=!0):(u.name=o,u.char=o);if(u.sequence=l,l.length!==0&&(u.name!==void 0||c)||io(l,0)===l.length)e.push(u);else throw new Error("Unrecognized or broken escape sequence");n()&&a()}}function io(s,t){let e=s.codePointAt(t);return typeof e>"u"?1:e>=so?2:1}function Pi(){try{let{Deno:s,process:t}=globalThis;if(s)return s.consoleSize().columns??null;if(t)return t.stdout.columns??null}catch{return null}throw new Error("unsupported runtime")}function Fi(){let{Deno:s,process:t}=globalThis;if(s)return s.stdin.isTerminal();if(t)return t.stdin.isTTY;throw new Error("unsupported runtime")}function Di(s){let{Deno:t,process:e}=globalThis;if(t)return t.stdin.read(s);if(e)return new Promise((i,n)=>{e.stdin.once("readable",()=>{try{let r=e.stdin.read();if(r===null)return i(null);for(let a=0;a<r.length;a++)s[a]=r[a];i(r.length)}catch(r){n(r)}})});throw new Error("unsupported runtime")}var L=class s{static injectedValue;cursor={x:0,y:0};#t;#e;#s=!0;#i=new TextEncoder;static inject(t){s.injectedValue=t}getDefaultSettings(t){return{...t,tty:Ss({reader:{readSync:Wt,setRaw:kt},writer:t.writer??{writeSync:Bt}}),cbreak:t.cbreak??!1,reader:t.reader??{read:Di,setRaw:kt,isTerminal:Fi},writer:t.writer??{writeSync:Bt},pointer:t.pointer??y(P.POINTER_SMALL),prefix:t.prefix??I("? "),indent:t.indent??"",keys:{submit:["enter","return"],...t.keys??{}}}}async prompt(){try{return await this.#n()}finally{this.settings.tty.cursorShow()}}clear(){this.settings.tty.cursorLeft.eraseDown()}#n=async()=>{if(typeof s.injectedValue<"u"&&this.#e)throw new Error(this.error());if(await this.render(),this.#e=void 0,!await this.read())return this.#n();if(typeof this.#t>"u")throw new Error("internal error: failed to read value");this.clear();let t=this.success(this.#t);return t&&this.settings.writer.writeSync(this.#i.encode(t+`
34
34
  `)),s.injectedValue=void 0,this.settings.tty.cursorShow(),this.#t};async render(){let e=(await Promise.all([this.message(),this.body?.(),this.footer()])).filter(Boolean).join(`
35
35
  `),i=e.split(`
36
36
  `),n=Pi(),a=(n?i.reduce((o,l)=>{let c=G(l).length;return o+(c>n?Math.ceil(c/n):1)},0):e.split(`
@@ -40,5 +40,5 @@ ${E(t)} ${y(e)}`).join("")}showLongVersion(){console.log(this.getLongVersion())}
40
40
  `)}getListItem(t,e){let i=this.settings.indent??"";return i+=e?`${this.settings.listPointer} `:" ",e?i+=rt(this.highlight(t)):i+=this.highlight(t),i}getListHeight(t=this.suggestions){return Math.min(t.length,this.settings.maxRows||t.length)}async handleEvent(t){switch(!0){case this.isKey(this.settings.keys,"next",t):this.settings.list?this.selectPreviousSuggestion():this.selectNextSuggestion();break;case this.isKey(this.settings.keys,"previous",t):this.settings.list?this.selectNextSuggestion():this.selectPreviousSuggestion();break;case this.isKey(this.settings.keys,"nextPage",t):this.settings.list?this.selectPreviousSuggestionsPage():this.selectNextSuggestionsPage();break;case this.isKey(this.settings.keys,"previousPage",t):this.settings.list?this.selectNextSuggestionsPage():this.selectPreviousSuggestionsPage();break;case this.isKey(this.settings.keys,"complete",t):await this.#i();break;case this.isKey(this.settings.keys,"moveCursorRight",t):this.inputIndex<this.inputValue.length?this.moveCursorRight():await this.#i();break;default:await super.handleEvent(t)}}deleteCharRight(){this.inputIndex<this.inputValue.length&&(super.deleteCharRight(),this.getCurrentInputValue().length||(this.suggestionsIndex=-1,this.suggestionsOffset=0))}async#i(){let t=await this.complete();this.setInputValue(t)}setInputValue(t){this.inputValue=t,this.inputIndex=this.inputValue.length,this.suggestionsIndex=0,this.suggestionsOffset=0}async complete(){let t=this.getCurrentInputValue(),e=this.suggestions[this.suggestionsIndex]?.toString();return this.settings.complete?t=await this.settings.complete(t,e):this.#s()&&t.at(-1)!==_i&&await ji(t)&&(this.getCurrentInputValue().at(-1)!=="."||this.getCurrentInputValue().endsWith(".."))?t+=_i:e&&(t=e),this.#s()?ge(t):t}selectPreviousSuggestion(){this.suggestions.length&&this.suggestionsIndex>-1&&(this.suggestionsIndex--,this.suggestionsIndex<this.suggestionsOffset&&this.suggestionsOffset--)}selectNextSuggestion(){this.suggestions.length&&this.suggestionsIndex<this.suggestions.length-1&&(this.suggestionsIndex++,this.suggestionsIndex>=this.suggestionsOffset+this.getListHeight()&&this.suggestionsOffset++)}selectPreviousSuggestionsPage(){if(this.suggestions.length){let t=this.getListHeight();this.suggestionsOffset>=t?(this.suggestionsIndex-=t,this.suggestionsOffset-=t):this.suggestionsOffset>0&&(this.suggestionsIndex-=this.suggestionsOffset,this.suggestionsOffset=0)}}selectNextSuggestionsPage(){if(this.suggestions.length){let t=this.getListHeight();if(this.suggestionsOffset+t+t<this.suggestions.length)this.suggestionsIndex+=t,this.suggestionsOffset+=t;else if(this.suggestionsOffset+t<this.suggestions.length){let e=this.suggestions.length-t;this.suggestionsIndex+=e-this.suggestionsOffset,this.suggestionsOffset=e}}}async#n(t){if(!t.startsWith("~"))return;let e=Ki();if(!await this.#r(e))return;let n=yo();n&&(t=t.replace("~",n),this.setInputValue(t))}async#r(t){if(this.#t[t])return this.#t[t];let e={name:"env",variable:t},i=await Deno.permissions.query(e);if(this.#t[t]=i.state==="granted",!this.#t[t]){this.clear();let n=await Deno.permissions.request(e);this.#t[t]=n.state==="granted"}return this.#t[t]}};function Xi(s,t,e){return typeof s<"u"&&s!==""&&e.indexOf(s)===t}async function xo(s,t){let e=[];for(let i of await qi(s)){if(t===!0&&(i.name.startsWith(".")||i.name.endsWith("~")))continue;let n=Ni(s,i.name);t instanceof RegExp&&!t.test(n)||e.push(n)}return e.sort(function(i,n){return i.toLowerCase().localeCompare(n.toLowerCase())})}function Ki(){return Deno.build.os==="windows"?"USERPROFILE":"HOME"}function yo(){return Deno.env.get(Ki())}var de=class extends wt{settings;static prompt(t){return new this(t).prompt()}static inject(t){L.inject(t)}constructor(t){super(),typeof t=="string"&&(t={message:t}),this.settings=this.getDefaultSettings(t)}getDefaultSettings(t){return{...super.getDefaultSettings(t),active:t.active||"Yes",inactive:t.inactive||"No",files:!1,complete:void 0,suggestions:[t.active||"Yes",t.inactive||"No"],list:!1,info:!1}}defaults(){let t="";return this.settings.default===!0?t+=this.settings.active[0].toUpperCase()+"/"+this.settings.inactive[0].toLowerCase():this.settings.default===!1?t+=this.settings.active[0].toLowerCase()+"/"+this.settings.inactive[0].toUpperCase():t+=this.settings.active[0].toLowerCase()+"/"+this.settings.inactive[0].toLowerCase(),t?v(` (${t})`):""}success(t){return this.saveSuggestions(this.format(t)),super.success(t)}getValue(){return this.inputValue}validate(t){return typeof t=="string"&&[this.settings.active[0].toLowerCase(),this.settings.active.toLowerCase(),this.settings.inactive[0].toLowerCase(),this.settings.inactive.toLowerCase()].indexOf(t.toLowerCase())!==-1}transform(t){switch(t.toLowerCase()){case this.settings.active[0].toLowerCase():case this.settings.active.toLowerCase():return!0;case this.settings.inactive[0].toLowerCase():case this.settings.inactive.toLowerCase():return!1}}format(t){return t?this.settings.active:this.settings.inactive}};var X=class extends wt{settings;static prompt(t){return new this(t).prompt()}static inject(t){L.inject(t)}constructor(t){super(),typeof t=="string"&&(t={message:t}),this.settings=this.getDefaultSettings(t)}getDefaultSettings(t){return{...super.getDefaultSettings(t),minLength:t.minLength??0,maxLength:t.maxLength??1/0}}success(t){return this.saveSuggestions(t),super.success(t)}getValue(){return this.settings.files&&this.inputValue?ge(this.inputValue):this.inputValue}validate(t){return typeof t!="string"?!1:t.length<this.settings.minLength?`Value must be longer than ${this.settings.minLength} but has a length of ${t.length}.`:t.length>this.settings.maxLength?`Value can't be longer than ${this.settings.maxLength} but has a length of ${t.length}.`:!0}transform(t){return t.trim()}format(t){return t}};var me=class extends he{settings;options;listIndex;listOffset;static prompt(t){return new this(t).prompt()}static inject(t){L.inject(t)}constructor(t){super(),this.settings=this.getDefaultSettings(t),this.options=this.settings.options.slice(),this.listIndex=this.getListIndex(this.settings.default),this.listOffset=this.getPageOffset(this.listIndex)}getDefaultSettings(t){return{...super.getDefaultSettings(t),options:this.mapOptions(t,t.options)}}mapOptions(t,e){return e.map(i=>bo(i)?this.mapOptionGroup(t,i):typeof i=="string"||typeof i=="number"?this.mapOption(t,{value:i}):this.mapOption(t,i))}input(){return rt(y(this.inputValue))}async submit(){if(this.isBackButton(this.selectedOption)||it(this.selectedOption)){let t=it(this.selectedOption)?` To select a group use ${O(this.settings.keys.open??[]).join(", ")}.`:"";this.setErrorMessage(`No option selected.${t}`);return}await super.submit()}getValue(){let t=this.options[this.listIndex];return Co(t),t.value}validate(t){return this.options.findIndex(e=>Et(e)&&ys(e.value,t))!==-1}transform(t){return t}format(t){return this.settings.format?.(t)??this.getOptionByValue(t)?.name??String(t)}};function Co(s){if(!Et(s))throw new Error("Expected an option but got an option group.")}function bo(s){return it(s)}import{TaskManager as Ro,NotInitializedError as Oo}from"dyson-swarm";async function So(s){let t=new Ro;try{let e=s.title??await X.prompt({message:"Enter task title:",minLength:1}),i=s.description??await X.prompt({message:"Enter task description:",minLength:1}),n=s.assignee??await X.prompt({message:"Enter assignee (optional):"}),r=s.parent??await X.prompt({message:"Enter parent task ID (optional):"}),a=await t.createTask({title:e,description:i,assignee:n||void 0,parentTaskId:r||void 0});console.log(`Created task: ${a.id}`),console.log(`Title: ${a.frontmatter.title}`),console.log(`Status: ${a.status}`),a.frontmatter.assignee&&console.log(`Assignee: ${a.frontmatter.assignee}`),r&&console.log(`Parent: ${r}`)}catch(e){e instanceof Oo&&(console.error("Error:",e.message),process.exit(1)),console.error("Failed to create task:",e instanceof Error?e.message:e),process.exit(1)}}var zi=new R().description("Create a new task.").option("-t, --title <title>","Task title.",{required:!0}).allowEmpty().option("-d, --description <description>","Task description.",{required:!0}).allowEmpty().option("-a, --assignee <assignee>","Assignee username.").option("-p, --parent <parentTaskId>","Parent task ID to create a subtask.").action(So);import{TaskManager as ko,NotInitializedError as vo}from"dyson-swarm";async function Uo(s){let t=new ko;try{let e={};s.status&&(["open","in-progress","closed"].includes(s.status)||(console.error("Invalid status. Must be one of: open, in-progress, closed"),process.exit(1)),e.status=s.status),s.assignee&&(e.assignee=s.assignee),s.task&&(e.taskId=s.task);let i=await t.listTasks(e);if(i.length===0){console.log("No tasks found.");return}console.log(`Found ${i.length} task(s):
41
41
  `);for(let n of i)console.log(`ID: ${n.id}`),console.log(`Title: ${n.frontmatter.title}`),console.log(`Status: ${n.status}`),n.frontmatter.assignee&&console.log(`Assignee: ${n.frontmatter.assignee}`),console.log("---")}catch(e){e instanceof vo&&(console.error("Error:",e.message),process.exit(1)),console.error("Failed to list tasks:",e instanceof Error?e.message:e),process.exit(1)}}var Zi=new R().description("List tasks with optional filters.").option("-s, --status <status>","Filter by status (open, in-progress, closed).").option("-a, --assignee <assignee>","Filter by assignee.").option("-t, --task <taskId>","Filter by task ID and include all subtasks (nested).").action(Uo);import{TaskManager as Po,NotInitializedError as Fo}from"dyson-swarm";async function Do(s){let t=new Po;try{let e=await t.getTask(s);e||(console.error(`Task not found: ${s}`),process.exit(1)),console.log(`ID: ${e.id}`),console.log(`Title: ${e.frontmatter.title}`),console.log(`Status: ${e.status}`),e.frontmatter.assignee&&console.log(`Assignee: ${e.frontmatter.assignee}`),console.log(`
42
42
  Description:`),console.log(e.description)}catch(e){e instanceof Fo&&(console.error("Error:",e.message),process.exit(1)),console.error("Failed to get task:",e instanceof Error?e.message:e),process.exit(1)}}var Yi=new R().name("get").description("Get a specific task by ID.").argument("<taskId>","The id of the task to get.").action(async(s,t)=>Do(t));import{TaskManager as To,NotInitializedError as Io}from"dyson-swarm";async function $o(s,t){let e=new To,i={};if(t.title!==void 0)i.title=t.title;else{let n=await X.prompt({message:"New title (optional, press Enter to skip):"});n&&(i.title=n)}if(t.description!==void 0)i.description=t.description;else{let n=await X.prompt({message:"New description (optional, press Enter to skip):"});n&&(i.description=n)}if(t.assignee!==void 0)i.assignee=t.assignee;else{let n=await X.prompt({message:"New assignee (optional, press Enter to skip):"});n&&(i.assignee=n)}if(Object.keys(i).length===0){console.log("No updates specified. Task was not modified.");return}try{let n=await e.updateTask(s,i);n||(console.error(`Task not found: ${s}`),process.exit(1)),console.log(`Updated task: ${n.id}`),console.log(`Title: ${n.frontmatter.title}`),console.log(`Status: ${n.status}`),n.frontmatter.assignee&&console.log(`Assignee: ${n.frontmatter.assignee}`)}catch(n){n instanceof Io&&(console.error("Error:",n.message),process.exit(1)),console.error("Failed to update task:",n instanceof Error?n.message:n),process.exit(1)}}var Ji=new R().name("update").description("Update a task.").argument("<taskId>","The id of the task to update.").option("-t, --title <title>","New title.").option("-d, --description <description>","New description.").option("-a, --assignee <assignee>","New assignee.").action(async(s,t)=>$o(t,s));import{TaskManager as Lo,NotInitializedError as Wo}from"dyson-swarm";async function Mo(s,t){let e=new Lo,i=t??await me.prompt({message:"Select new status:",options:[{value:"open",name:"Open"},{value:"in-progress",name:"In Progress"},{value:"closed",name:"Closed"}]});["open","in-progress","closed"].includes(i)||(console.error("Invalid status. Must be one of: open, in-progress, closed"),process.exit(1));try{let n=await e.changeTaskStatus(s,i);n||(console.error(`Task not found: ${s}`),process.exit(1)),console.log(`Changed status of task ${n.id} to: ${n.status}`),console.log(`Title: ${n.frontmatter.title}`)}catch(n){n instanceof Wo&&(console.error("Error:",n.message),process.exit(1)),console.error("Failed to change task status:",n instanceof Error?n.message:n),process.exit(1)}}var tn=new R().name("status").description("Change the status of a task.").argument("<taskId>","The id of the task to update.").argument("[status]","The new status (open, in-progress, or closed).").action(async(s,t,e)=>Mo(t,e));import{TaskManager as Ho,NotInitializedError as No}from"dyson-swarm";async function Go(s,t){let e=new Ho,i=t??await X.prompt({message:"Enter assignee username:",minLength:1});try{let n=await e.assignTask(s,i);n||(console.error(`Task not found: ${s}`),process.exit(1)),console.log(`Assigned task ${n.id} to: ${n.frontmatter.assignee}`),console.log(`Title: ${n.frontmatter.title}`),console.log(`Status: ${n.status}`)}catch(n){n instanceof No&&(console.error("Error:",n.message),process.exit(1)),console.error("Failed to assign task:",n instanceof Error?n.message:n),process.exit(1)}}var en=new R().name("assign").description("Assign a task to someone.").argument("<taskId>","The id of the task to add an assignee to.").argument("[assignee]","The assignee to assign the task to.").action(async(s,t,e)=>Go(t,e));import{TaskManager as jo,NotInitializedError as qo}from"dyson-swarm";async function _o(s){let t=new jo;try{let e=await t.unassignTask(s);e||(console.error(`Task not found: ${s}`),process.exit(1)),console.log(`Unassigned task: ${e.id}`),console.log(`Title: ${e.frontmatter.title}`),console.log(`Status: ${e.status}`)}catch(e){e instanceof qo&&(console.error("Error:",e.message),process.exit(1)),console.error("Failed to unassign task:",e instanceof Error?e.message:e),process.exit(1)}}var sn=new R().name("unassign").description("Unassign a task.").argument("<taskId>","The id of the task to unassign.").action(async(s,t)=>_o(t));import{TaskManager as Xo,NotInitializedError as Ko}from"dyson-swarm";async function zo(s,t){let e=new Xo;if(!(t.force??await de.prompt({message:`Are you sure you want to delete task ${s}?`,default:!1}))){console.log("Deletion cancelled.");return}try{await e.deleteTask(s)||(console.error(`Task not found: ${s}`),process.exit(1)),console.log(`Deleted task: ${s}`)}catch(n){n instanceof Ko&&(console.error("Error:",n.message),process.exit(1)),console.error("Failed to delete task:",n instanceof Error?n.message:n),process.exit(1)}}var nn=new R().name("delete").description("Delete a task.").argument("<taskId>","The id of the task to delete.").option("-f, --force","Force deletion without confirmation.").action(async(s,t)=>zo(t,s));import{initialize as Zo,checkInitialization as Yo}from"dyson-swarm";async function Jo(){let{isInitialized:s,missingComponents:t}=await Yo();s&&(console.warn("Warning: This directory is already initialized for dyson-swarm."),console.warn("If you want to reinitialize, remove the .swarm directory first."),process.exit(1));try{await Zo(),console.log("\u2713 Initialized dyson-swarm in the current directory"),console.log(" Created .swarm/ directory with:"),console.log(" - version file (schema version 2)"),console.log(" - tasks/ directory"),console.log(" - statuses/ directory with status files (draft, open, in-progress, closed)"),console.log(" - lockfile for concurrent access"),console.log(`
43
- You can now create and manage tasks with commands like:`),console.log(' swarm create -t "My task" -d "Task description"')}catch(e){console.error("Failed to initialize:",e instanceof Error?e.message:e),process.exit(1)}}var rn=new R().description("Initialize dyson-swarm in the current directory.").action(Jo);await new R().help(li()).name("swarm").description("A markdown-based issue tracking system CLI").version("1.0.0").action(function(){this.showHelp()}).command("init",rn).command("create",zi).command("list",Zi).command("get",Yi).command("update",Ji).command("status",tn).command("assign",en).command("unassign",sn).command("delete",nn).parse();
43
+ You can now create and manage tasks with commands like:`),console.log(' swarm create -t "My task" -d "Task description"')}catch(e){console.error("Failed to initialize:",e instanceof Error?e.message:e),process.exit(1)}}var rn=new R().description("Initialize dyson-swarm in the current directory.").action(Jo);var ea=ta(import.meta.url),{version:sa}=ea("../package.json");await new R().help(li()).name("swarm").description("A markdown-based issue tracking system CLI").version(sa).action(function(){this.showHelp()}).command("init",rn).command("create",zi).command("list",Zi).command("get",Yi).command("update",Ji).command("status",tn).command("assign",en).command("unassign",sn).command("delete",nn).parse();
44
44
  //# sourceMappingURL=index.js.map