@coryrylan/cradle 1.3.1 → 1.4.1

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
@@ -1,21 +1,21 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var Rs=Object.create;var{getPrototypeOf:Ts,defineProperty:Vn,getOwnPropertyNames:Ws}=Object;var Ls=Object.prototype.hasOwnProperty;function Gs(e){return this[e]}var Vs,Hs,zs=(e,t,n)=>{var i=e!=null&&typeof e==="object";if(i){var r=t?Vs??=new WeakMap:Hs??=new WeakMap,s=r.get(e);if(s)return s}n=e!=null?Rs(Ts(e)):{};let o=t||!e||!e.__esModule?Vn(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Ws(e))if(!Ls.call(o,a))Vn(o,a,{get:Gs.bind(e,a),enumerable:!0})}if(i)r.set(e,o);return o};var Us=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ki=Us(function(uf,$i){$i.exports=function(t){if(t===void 0)t=2;if(t>=Error.stackTraceLimit)throw TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+t+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");var n=Error.prepareStackTrace;Error.prepareStackTrace=function(r,s){return s};var i=Error().stack;if(Error.prepareStackTrace=n,i!==null&&typeof i==="object")return i[t]?i[t].getFileName():void 0}});import{join as Ns}from"path";import{notStrictEqual as zo,strictEqual as Uo}from"assert";var Ys={right:qs,center:Xs};class zn{constructor(e){var t;this.width=e.width,this.wrap=(t=e.wrap)!==null&&t!==void 0?t:!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]==="string")return this.applyLayoutDSL(e[0]);let t=e.map((n)=>{if(typeof n==="string")return this.colFromString(n);return n});return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]==="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
4
- `).map((i)=>i.split("\t")),n=0;return t.forEach((i)=>{if(i.length>1&&pe.stringWidth(i[0])>n)n=Math.min(Math.floor(this.width*0.5),pe.stringWidth(i[0]))}),t.forEach((i)=>{this.div(...i.map((r,s)=>({text:r.trim(),padding:this.measurePadding(r),width:s===0&&i.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){let t=pe.stripAnsi(e);return[0,t.match(/\s*$/)[0].length,0,t.match(/^\s*/)[0].length]}toString(){let e=[];return this.rows.forEach((t)=>{this.rowToString(t,e)}),e.filter((t)=>!t.hidden).map((t)=>t.text).join(`
5
- `)}rowToString(e,t){return this.rasterize(e).forEach((n,i)=>{let r="";n.forEach((s,o)=>{let{width:a}=e[o],c=this.negatePadding(e[o]),g=s;if(c>pe.stringWidth(s))g+=" ".repeat(c-pe.stringWidth(s));if(e[o].align&&e[o].align!=="left"&&this.wrap){let h=Ys[e[o].align];if(g=h(g,c),pe.stringWidth(g)<c)g+=" ".repeat((a||0)-pe.stringWidth(g)-1)}let E=e[o].padding||[0,0,0,0];if(E[3])r+=" ".repeat(E[3]);if(r+=Hn(e[o],g,"| "),r+=g,r+=Hn(e[o],g," |"),E[1])r+=" ".repeat(E[1]);if(i===0&&t.length>0)r=this.renderInline(r,t[t.length-1])}),t.push({text:r.replace(/ +$/,""),span:e.span})}),t}renderInline(e,t){let n=e.match(/^ */),i=n?n[0].length:0,r=t.text,s=pe.stringWidth(r.trimRight());if(!t.span)return e;if(!this.wrap)return t.hidden=!0,r+e;if(i<s)return e;return t.hidden=!0,r.trimRight()+" ".repeat(i-s)+e.trimLeft()}rasterize(e){let t=[],n=this.columnWidths(e),i;return e.forEach((r,s)=>{if(r.width=n[s],this.wrap)i=pe.wrap(r.text,this.negatePadding(r),{hard:!0}).split(`
6
- `);else i=r.text.split(`
7
- `);if(r.border)i.unshift("."+"-".repeat(this.negatePadding(r)+2)+"."),i.push("'"+"-".repeat(this.negatePadding(r)+2)+"'");if(r.padding)i.unshift(...Array(r.padding[0]||0).fill("")),i.push(...Array(r.padding[2]||0).fill(""));i.forEach((o,a)=>{if(!t[a])t.push([]);let c=t[a];for(let g=0;g<s;g++)if(c[g]===void 0)c.push("");c.push(o)})}),t}negatePadding(e){let t=e.width||0;if(e.padding)t-=(e.padding[3]||0)+(e.padding[1]||0);if(e.border)t-=4;return t}columnWidths(e){if(!this.wrap)return e.map((s)=>s.width||pe.stringWidth(s.text));let t=e.length,n=this.width,i=e.map((s)=>{if(s.width)return t--,n-=s.width,s.width;return}),r=t?Math.floor(n/t):0;return i.map((s,o)=>{if(s===void 0)return Math.max(r,Js(e[o]));return s})}}function Hn(e,t,n){if(e.border){if(/[.']-+[.']/.test(t))return"";if(t.trim().length!==0)return n;return" "}return""}function Js(e){let t=e.padding||[],n=1+(t[3]||0)+(t[1]||0);if(e.border)return n+4;return n}function Ks(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function qs(e,t){e=e.trim();let n=pe.stringWidth(e);if(n<t)return" ".repeat(t-n)+e;return e}function Xs(e,t){e=e.trim();let n=pe.stringWidth(e);if(n>=t)return e;return" ".repeat(t-n>>1)+e}var pe;function Un(e,t){return pe=t,new zn({width:(e===null||e===void 0?void 0:e.width)||Ks(),wrap:e===null||e===void 0?void 0:e.wrap})}function tn({onlyFirst:e=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}var Zs=tn();function Oe(e){if(typeof e!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);if(!e.includes("\x1B")&&!e.includes("\x9B"))return e;return e.replace(Zs,"")}var Yn=161,Jn=1114109,Kn=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],qn=12288,Xn=65510,Zn=[12288,12288,65281,65376,65504,65510];var Qn=4352,ei=262141,nn=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var Pt=(e,t)=>{let n=0,i=Math.floor(e.length/2)-1;while(n<=i){let r=Math.floor((n+i)/2),s=r*2;if(t<e[s])i=r-1;else if(t>e[s+1])n=r+1;else return!0}return!1};var ti=19968,[Qs,eo]=to(nn);function to(e){let t=e[0],n=e[1];for(let i=0;i<e.length;i+=2){let r=e[i],s=e[i+1];if(ti>=r&&ti<=s)return[r,s];if(s-r>n-t)t=r,n=s}return[t,n]}var ni=(e)=>{if(e<Yn||e>Jn)return!1;return Pt(Kn,e)},ii=(e)=>{if(e<qn||e>Xn)return!1;return Pt(Zn,e)};var ri=(e)=>{if(e>=Qs&&e<=eo)return!0;if(e<Qn||e>ei)return!1;return Pt(nn,e)};function no(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Ve(e,{ambiguousAsWide:t=!1}={}){if(no(e),ii(e)||ri(e)||t&&ni(e))return 2;return 1}var si=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;var io=new Intl.Segmenter,ro=/^\p{Default_Ignorable_Code_Point}$/u;function je(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:i=!1}=t;if(!i)e=Oe(e);if(e.length===0)return 0;let r=0,s={ambiguousAsWide:!n};for(let{segment:o}of io.segment(e)){let a=o.codePointAt(0);if(a<=31||a>=127&&a<=159)continue;if(a>=8203&&a<=8207||a===65279)continue;if(a>=768&&a<=879||a>=6832&&a<=6911||a>=7616&&a<=7679||a>=8400&&a<=8447||a>=65056&&a<=65071)continue;if(a>=55296&&a<=57343)continue;if(a>=65024&&a<=65039)continue;if(ro.test(o))continue;if(si().test(o)){r+=2;continue}r+=Ve(a,s)}return r}var oi=(e=0)=>(t)=>`\x1B[${t+e}m`,ui=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,ai=(e=0)=>(t,n,i)=>`\x1B[${38+e};2;${t};${n};${i}m`,K={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]}},bc=Object.keys(K.modifier),so=Object.keys(K.color),oo=Object.keys(K.bgColor),Ec=[...so,...oo];function uo(){let e=new Map;for(let[t,n]of Object.entries(K)){for(let[i,r]of Object.entries(n))K[i]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[i]=K[i],e.set(r[0],r[1]);Object.defineProperty(K,t,{value:n,enumerable:!1})}return Object.defineProperty(K,"codes",{value:e,enumerable:!1}),K.color.close="\x1B[39m",K.bgColor.close="\x1B[49m",K.color.ansi=oi(),K.color.ansi256=ui(),K.color.ansi16m=ai(),K.bgColor.ansi=oi(10),K.bgColor.ansi256=ui(10),K.bgColor.ansi16m=ai(10),Object.defineProperties(K,{rgbToAnsi256:{value(t,n,i){if(t===n&&n===i){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(n/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[i]=n;if(i.length===3)i=[...i].map((s)=>s+s).join("");let r=Number.parseInt(i,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:(t)=>K.rgbToAnsi256(...K.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,i,r;if(t>=232)n=((t-232)*10+8)/255,i=n,r=n;else{t-=16;let a=t%36;n=Math.floor(t/36)/5,i=Math.floor(a/6)/5,r=a%6/5}let s=Math.max(n,i,r)*2;if(s===0)return 30;let o=30+(Math.round(r)<<2|Math.round(i)<<1|Math.round(n));if(s===2)o+=60;return o},enumerable:!1},rgbToAnsi:{value:(t,n,i)=>K.ansi256ToAnsi(K.rgbToAnsi256(t,n,i)),enumerable:!1},hexToAnsi:{value:(t)=>K.ansi256ToAnsi(K.hexToAnsi256(t)),enumerable:!1}}),K}var ao=uo(),li=ao;var jt=new Set(["\x1B","\x9B"]),lo=39,sn="\x07",di="[",co="]",Di="m",Ot=`${co}8;;`,ci=(e)=>`${jt.values().next().value}${di}${e}${Di}`,fi=(e)=>`${jt.values().next().value}${Ot}${e}${sn}`,fo=(e)=>e.split(" ").map((t)=>je(t)),rn=(e,t,n)=>{let i=[...t],r=!1,s=!1,o=je(Oe(e.at(-1)));for(let[a,c]of i.entries()){let g=je(c);if(o+g<=n)e[e.length-1]+=c;else e.push(c),o=0;if(jt.has(c))r=!0,s=i.slice(a+1,a+1+Ot.length).join("")===Ot;if(r){if(s){if(c===sn)r=!1,s=!1}else if(c===Di)r=!1;continue}if(o+=g,o===n&&a<i.length-1)e.push(""),o=0}if(!o&&e.at(-1).length>0&&e.length>1)e[e.length-2]+=e.pop()},Do=(e)=>{let t=e.split(" "),n=t.length;while(n>0){if(je(t[n-1])>0)break;n--}if(n===t.length)return e;return t.slice(0,n).join(" ")+t.slice(n).join("")},ho=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let i="",r,s,o=fo(e),a=[""];for(let[h,p]of e.split(" ").entries()){if(n.trim!==!1)a[a.length-1]=a.at(-1).trimStart();let m=je(a.at(-1));if(h!==0){if(m>=t&&(n.wordWrap===!1||n.trim===!1))a.push(""),m=0;if(m>0||n.trim===!1)a[a.length-1]+=" ",m++}if(n.hard&&o[h]>t){let b=t-m,D=1+Math.floor((o[h]-b-1)/t);if(Math.floor((o[h]-1)/t)<D)a.push("");rn(a,p,t);continue}if(m+o[h]>t&&m>0&&o[h]>0){if(n.wordWrap===!1&&m<t){rn(a,p,t);continue}a.push("")}if(m+o[h]>t&&n.wordWrap===!1){rn(a,p,t);continue}a[a.length-1]+=p}if(n.trim!==!1)a=a.map((h)=>Do(h));let c=a.join(`
8
- `),g=[...c],E=0;for(let[h,p]of g.entries()){if(i+=p,jt.has(p)){let{groups:b}=new RegExp(`(?:\\${di}(?<code>\\d+)m|\\${Ot}(?<uri>.*)${sn})`).exec(c.slice(E))||{groups:{}};if(b.code!==void 0){let D=Number.parseFloat(b.code);r=D===lo?void 0:D}else if(b.uri!==void 0)s=b.uri.length===0?void 0:b.uri}let m=li.codes.get(Number(r));if(g[h+1]===`
9
- `){if(s)i+=fi("");if(r&&m)i+=ci(m)}else if(p===`
10
- `){if(r&&m)i+=ci(r);if(s)i+=fi(s)}E+=p.length}return i};function on(e,t,n){return String(e).normalize().replaceAll(`\r
3
+ var Oo=Object.create;var{getPrototypeOf:$o,defineProperty:lr,getOwnPropertyNames:vo}=Object;var cr=Object.prototype.hasOwnProperty;function jo(e){return this[e]}var ko,Mo,No=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var i=t?ko??=new WeakMap:Mo??=new WeakMap,s=i.get(e);if(s)return s}n=e!=null?Oo($o(e)):{};let o=t||!e||!e.__esModule||!cr.call(e,"default")?lr(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let u of vo(e))if(!cr.call(o,u))lr(o,u,{get:jo.bind(e,u),enumerable:!0})}if(r)i.set(e,o);return o};var Ro=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ti=Ro(function(jh,ei){ei.exports=function(t){if(t===void 0)t=2;if(t>=Error.stackTraceLimit)throw TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+t+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");var n=Error.prepareStackTrace;Error.prepareStackTrace=function(i,s){return s};var r=Error().stack;if(Error.prepareStackTrace=n,r!==null&&typeof r==="object")return r[t]?r[t].getFileName():void 0}});import{join as Po}from"path";import{notStrictEqual as Ma,strictEqual as Na}from"assert";var Io={right:Wo,center:Ho};class fr{constructor(e){var t;this.width=e.width,this.wrap=(t=e.wrap)!==null&&t!==void 0?t:!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]==="string")return this.applyLayoutDSL(e[0]);let t=e.map((n)=>{if(typeof n==="string")return this.colFromString(n);return n});return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]==="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
4
+ `).map((r)=>r.split("\t")),n=0;return t.forEach((r)=>{if(r.length>1&&ge.stringWidth(r[0])>n)n=Math.min(Math.floor(this.width*0.5),ge.stringWidth(r[0]))}),t.forEach((r)=>{this.div(...r.map((i,s)=>({text:i.trim(),padding:this.measurePadding(i),width:s===0&&r.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){let t=ge.stripAnsi(e);return[0,t.match(/\s*$/)[0].length,0,t.match(/^\s*/)[0].length]}toString(){let e=[];return this.rows.forEach((t)=>{this.rowToString(t,e)}),e.filter((t)=>!t.hidden).map((t)=>t.text).join(`
5
+ `)}rowToString(e,t){return this.rasterize(e).forEach((n,r)=>{let i="";n.forEach((s,o)=>{let{width:u}=e[o],c=this.negatePadding(e[o]),p=s;if(c>ge.stringWidth(s))p+=" ".repeat(c-ge.stringWidth(s));if(e[o].align&&e[o].align!=="left"&&this.wrap){let g=Io[e[o].align];if(p=g(p,c),ge.stringWidth(p)<c)p+=" ".repeat((u||0)-ge.stringWidth(p)-1)}let b=e[o].padding||[0,0,0,0];if(b[3])i+=" ".repeat(b[3]);if(i+=dr(e[o],p,"| "),i+=p,i+=dr(e[o],p," |"),b[1])i+=" ".repeat(b[1]);if(r===0&&t.length>0)i=this.renderInline(i,t[t.length-1])}),t.push({text:i.replace(/ +$/,""),span:e.span})}),t}renderInline(e,t){let n=e.match(/^ */),r=n?n[0].length:0,i=t.text,s=ge.stringWidth(i.trimRight());if(!t.span)return e;if(!this.wrap)return t.hidden=!0,i+e;if(r<s)return e;return t.hidden=!0,i.trimRight()+" ".repeat(r-s)+e.trimLeft()}rasterize(e){let t=[],n=this.columnWidths(e),r;return e.forEach((i,s)=>{if(i.width=n[s],this.wrap)r=ge.wrap(i.text,this.negatePadding(i),{hard:!0}).split(`
6
+ `);else r=i.text.split(`
7
+ `);if(i.border)r.unshift("."+"-".repeat(this.negatePadding(i)+2)+"."),r.push("'"+"-".repeat(this.negatePadding(i)+2)+"'");if(i.padding)r.unshift(...Array(i.padding[0]||0).fill("")),r.push(...Array(i.padding[2]||0).fill(""));r.forEach((o,u)=>{if(!t[u])t.push([]);let c=t[u];for(let p=0;p<s;p++)if(c[p]===void 0)c.push("");c.push(o)})}),t}negatePadding(e){let t=e.width||0;if(e.padding)t-=(e.padding[3]||0)+(e.padding[1]||0);if(e.border)t-=4;return t}columnWidths(e){if(!this.wrap)return e.map((s)=>s.width||ge.stringWidth(s.text));let t=e.length,n=this.width,r=e.map((s)=>{if(s.width)return t--,n-=s.width,s.width;return}),i=t?Math.floor(n/t):0;return r.map((s,o)=>{if(s===void 0)return Math.max(i,To(e[o]));return s})}}function dr(e,t,n){if(e.border){if(/[.']-+[.']/.test(t))return"";if(t.trim().length!==0)return n;return" "}return""}function To(e){let t=e.padding||[],n=1+(t[3]||0)+(t[1]||0);if(e.border)return n+4;return n}function Lo(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function Wo(e,t){e=e.trim();let n=ge.stringWidth(e);if(n<t)return" ".repeat(t-n)+e;return e}function Ho(e,t){e=e.trim();let n=ge.stringWidth(e);if(n>=t)return e;return" ".repeat(t-n>>1)+e}var ge;function hr(e,t){return ge=t,new fr({width:(e===null||e===void 0?void 0:e.width)||Lo(),wrap:e===null||e===void 0?void 0:e.wrap})}function mn({onlyFirst:e=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}var Vo=mn();function je(e){if(typeof e!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);if(!e.includes("\x1B")&&!e.includes("\x9B"))return e;return e.replace(Vo,"")}var Dr=161,gr=1114109,pr=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],mr=12288,Fr=65510,yr=[12288,12288,65281,65376,65504,65510];var br=4352,Er=262141,Fn=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var Nt=(e,t)=>{let n=0,r=Math.floor(e.length/2)-1;while(n<=r){let i=Math.floor((n+r)/2),s=i*2;if(t<e[s])r=i-1;else if(t>e[s+1])n=i+1;else return!0}return!1};var Cr=19968,[zo,Go]=Uo(Fn);function Uo(e){let t=e[0],n=e[1];for(let r=0;r<e.length;r+=2){let i=e[r],s=e[r+1];if(Cr>=i&&Cr<=s)return[i,s];if(s-i>n-t)t=i,n=s}return[t,n]}var wr=(e)=>{if(e<Dr||e>gr)return!1;return Nt(pr,e)},xr=(e)=>{if(e<mr||e>Fr)return!1;return Nt(yr,e)};var Sr=(e)=>{if(e>=zo&&e<=Go)return!0;if(e<br||e>Er)return!1;return Nt(Fn,e)};function Yo(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Ye(e,{ambiguousAsWide:t=!1}={}){if(Yo(e),xr(e)||Sr(e)||t&&wr(e))return 2;return 1}var Ar=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;var Jo=new Intl.Segmenter,Ko=/^\p{Default_Ignorable_Code_Point}$/u;function ke(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t;if(!r)e=je(e);if(e.length===0)return 0;let i=0,s={ambiguousAsWide:!n};for(let{segment:o}of Jo.segment(e)){let u=o.codePointAt(0);if(u<=31||u>=127&&u<=159)continue;if(u>=8203&&u<=8207||u===65279)continue;if(u>=768&&u<=879||u>=6832&&u<=6911||u>=7616&&u<=7679||u>=8400&&u<=8447||u>=65056&&u<=65071)continue;if(u>=55296&&u<=57343)continue;if(u>=65024&&u<=65039)continue;if(Ko.test(o))continue;if(Ar().test(o)){i+=2;continue}i+=Ye(u,s)}return i}var Pr=(e=0)=>(t)=>`\x1B[${t+e}m`,_r=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,Br=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,K={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Uf=Object.keys(K.modifier),qo=Object.keys(K.color),Xo=Object.keys(K.bgColor),Yf=[...qo,...Xo];function Zo(){let e=new Map;for(let[t,n]of Object.entries(K)){for(let[r,i]of Object.entries(n))K[r]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},n[r]=K[r],e.set(i[0],i[1]);Object.defineProperty(K,t,{value:n,enumerable:!1})}return Object.defineProperty(K,"codes",{value:e,enumerable:!1}),K.color.close="\x1B[39m",K.bgColor.close="\x1B[49m",K.color.ansi=Pr(),K.color.ansi256=_r(),K.color.ansi16m=Br(),K.bgColor.ansi=Pr(10),K.bgColor.ansi256=_r(10),K.bgColor.ansi16m=Br(10),Object.defineProperties(K,{rgbToAnsi256:{value(t,n,r){if(t===n&&n===r){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(n/255*5)+Math.round(r/255*5)},enumerable:!1},hexToRgb:{value(t){let n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[r]=n;if(r.length===3)r=[...r].map((s)=>s+s).join("");let i=Number.parseInt(r,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:(t)=>K.rgbToAnsi256(...K.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,r,i;if(t>=232)n=((t-232)*10+8)/255,r=n,i=n;else{t-=16;let u=t%36;n=Math.floor(t/36)/5,r=Math.floor(u/6)/5,i=u%6/5}let s=Math.max(n,r,i)*2;if(s===0)return 30;let o=30+(Math.round(i)<<2|Math.round(r)<<1|Math.round(n));if(s===2)o+=60;return o},enumerable:!1},rgbToAnsi:{value:(t,n,r)=>K.ansi256ToAnsi(K.rgbToAnsi256(t,n,r)),enumerable:!1},hexToAnsi:{value:(t)=>K.ansi256ToAnsi(K.hexToAnsi256(t)),enumerable:!1}}),K}var Qo=Zo(),Or=Qo;var It=new Set(["\x1B","\x9B"]),ea=39,bn="\x07",jr="[",ta="]",kr="m",Rt=`${ta}8;;`,$r=(e)=>`${It.values().next().value}${jr}${e}${kr}`,vr=(e)=>`${It.values().next().value}${Rt}${e}${bn}`,na=(e)=>e.split(" ").map((t)=>ke(t)),yn=(e,t,n)=>{let r=[...t],i=!1,s=!1,o=ke(je(e.at(-1)));for(let[u,c]of r.entries()){let p=ke(c);if(o+p<=n)e[e.length-1]+=c;else e.push(c),o=0;if(It.has(c))i=!0,s=r.slice(u+1,u+1+Rt.length).join("")===Rt;if(i){if(s){if(c===bn)i=!1,s=!1}else if(c===kr)i=!1;continue}if(o+=p,o===n&&u<r.length-1)e.push(""),o=0}if(!o&&e.at(-1).length>0&&e.length>1)e[e.length-2]+=e.pop()},ra=(e)=>{let t=e.split(" "),n=t.length;while(n>0){if(ke(t[n-1])>0)break;n--}if(n===t.length)return e;return t.slice(0,n).join(" ")+t.slice(n).join("")},ia=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let r="",i,s,o=na(e),u=[""];for(let[g,D]of e.split(" ").entries()){if(n.trim!==!1)u[u.length-1]=u.at(-1).trimStart();let F=ke(u.at(-1));if(g!==0){if(F>=t&&(n.wordWrap===!1||n.trim===!1))u.push(""),F=0;if(F>0||n.trim===!1)u[u.length-1]+=" ",F++}if(n.hard&&o[g]>t){let y=t-F,h=1+Math.floor((o[g]-y-1)/t);if(Math.floor((o[g]-1)/t)<h)u.push("");yn(u,D,t);continue}if(F+o[g]>t&&F>0&&o[g]>0){if(n.wordWrap===!1&&F<t){yn(u,D,t);continue}u.push("")}if(F+o[g]>t&&n.wordWrap===!1){yn(u,D,t);continue}u[u.length-1]+=D}if(n.trim!==!1)u=u.map((g)=>ra(g));let c=u.join(`
8
+ `),p=[...c],b=0;for(let[g,D]of p.entries()){if(r+=D,It.has(D)){let{groups:y}=new RegExp(`(?:\\${jr}(?<code>\\d+)m|\\${Rt}(?<uri>.*)${bn})`).exec(c.slice(b))||{groups:{}};if(y.code!==void 0){let h=Number.parseFloat(y.code);i=h===ea?void 0:h}else if(y.uri!==void 0)s=y.uri.length===0?void 0:y.uri}let F=Or.codes.get(Number(i));if(p[g+1]===`
9
+ `){if(s)r+=vr("");if(i&&F)r+=$r(F)}else if(D===`
10
+ `){if(i&&F)r+=$r(i);if(s)r+=vr(s)}b+=D.length}return r};function En(e,t,n){return String(e).normalize().replaceAll(`\r
11
11
  `,`
12
12
  `).split(`
13
- `).map((i)=>ho(i,t,n)).join(`
14
- `)}function un(e){return Un(e,{stringWidth:je,stripAnsi:Oe,wrap:on})}import{dirname as hi,resolve as pi}from"path";import{readdirSync as po,statSync as go}from"fs";function an(e,t){let n=pi(".",e),i;if(!go(n).isDirectory())n=hi(n);while(!0){if(i=t(n,po(n)),i)return pi(n,i);if(n=hi(i=n),i===n)break}}import{inspect as Yo}from"util";import{fileURLToPath as Ni}from"url";import{format as bo}from"util";import{normalize as Eo,resolve as yo}from"path";function He(e){if(!(e!==e.toLowerCase()&&e!==e.toUpperCase()))e=e.toLowerCase();if(e.indexOf("-")===-1&&e.indexOf("_")===-1)return e;else{let n="",i=!1,r=e.match(/^-+/);for(let s=r?r[0].length:0;s<e.length;s++){let o=e.charAt(s);if(i)i=!1,o=o.toUpperCase();if(s!==0&&(o==="-"||o==="_"))i=!0;else if(o!=="-"&&o!=="_")n+=o}return n}}function vt(e,t){let n=e.toLowerCase();t=t||"-";let i="";for(let r=0;r<e.length;r++){let s=n.charAt(r),o=e.charAt(r);if(s!==o&&r>0)i+=`${t}${n.charAt(r)}`;else i+=o}return i}function $t(e){if(e===null||e===void 0)return!1;if(typeof e==="number")return!0;if(/^0x[0-9a-f]+$/i.test(e))return!0;if(/^0[^.]/.test(e))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function gi(e){if(Array.isArray(e))return e.map((o)=>typeof o!=="string"?o+"":o);e=e.trim();let t=0,n=null,i=null,r=null,s=[];for(let o=0;o<e.length;o++){if(n=i,i=e.charAt(o),i===" "&&!r){if(n!==" ")t++;continue}if(i===r)r=null;else if((i==="'"||i==='"')&&!r)r=i;if(!s[t])s[t]="";s[t]+=i}return s}var be;(function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"})(be||(be={}));var ve;class cn{constructor(e){ve=e}parse(e,t){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),i=gi(e),r=typeof e==="string",s=mo(Object.assign(Object.create(null),n.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),a=Object.assign(Object.create(null),n.default),c=n.configObjects||[],g=n.envPrefix,E=o["populate--"],h=E?"--":"_",p=Object.create(null),m=Object.create(null),b=n.__||ve.format,D={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},j=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,L=new RegExp("^--"+o["negation-prefix"]+"(.+)");if([].concat(n.array||[]).filter(Boolean).forEach(function(l){let d=typeof l==="object"?l.key:l,y=Object.keys(l).map(function(F){return{boolean:"bools",string:"strings",number:"numbers"}[F]}).filter(Boolean).pop();if(y)D[y][d]=!0;D.arrays[d]=!0,D.keys.push(d)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(l){D.bools[l]=!0,D.keys.push(l)}),[].concat(n.string||[]).filter(Boolean).forEach(function(l){D.strings[l]=!0,D.keys.push(l)}),[].concat(n.number||[]).filter(Boolean).forEach(function(l){D.numbers[l]=!0,D.keys.push(l)}),[].concat(n.count||[]).filter(Boolean).forEach(function(l){D.counts[l]=!0,D.keys.push(l)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(l){D.normalize[l]=!0,D.keys.push(l)}),typeof n.narg==="object")Object.entries(n.narg).forEach(([l,d])=>{if(typeof d==="number")D.nargs[l]=d,D.keys.push(l)});if(typeof n.coerce==="object")Object.entries(n.coerce).forEach(([l,d])=>{if(typeof d==="function")D.coercions[l]=d,D.keys.push(l)});if(typeof n.config<"u"){if(Array.isArray(n.config)||typeof n.config==="string")[].concat(n.config).filter(Boolean).forEach(function(l){D.configs[l]=!0});else if(typeof n.config==="object")Object.entries(n.config).forEach(([l,d])=>{if(typeof d==="boolean"||typeof d==="function")D.configs[l]=d})}gt(n.key,s,n.default,D.arrays),Object.keys(a).forEach(function(l){(D.aliases[l]||[]).forEach(function(d){a[d]=a[l]})});let T=null;en();let ce=[],R=Object.assign(Object.create(null),{_:[]}),Y={};for(let l=0;l<i.length;l++){let d=i[l],y=d.replace(/^-{3,}/,"---"),F,f,_,x,O,oe;if(d!=="--"&&/^-/.test(d)&&z(d))ne(d);else if(y.match(/^---+(=|$)/)){ne(d);continue}else if(d.match(/^--.+=/)||!o["short-option-groups"]&&d.match(/^-.+=/)){if(x=d.match(/^--?([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3)if(v(x[1],D.arrays))l=Ae(l,x[1],i,x[2]);else if(v(x[1],D.nargs)!==!1)l=X(l,x[1],i,x[2]);else H(x[1],x[2],!0)}else if(d.match(L)&&o["boolean-negation"]){if(x=d.match(L),x!==null&&Array.isArray(x)&&x.length>=2)f=x[1],H(f,v(f,D.arrays)?[!1]:!1)}else if(d.match(/^--.+/)||!o["short-option-groups"]&&d.match(/^-[^-]+/)){if(x=d.match(/^--?(.+)/),x!==null&&Array.isArray(x)&&x.length>=2)if(f=x[1],v(f,D.arrays))l=Ae(l,f,i);else if(v(f,D.nargs)!==!1)l=X(l,f,i);else if(O=i[l+1],O!==void 0&&(!O.match(/^-/)||O.match(j))&&!v(f,D.bools)&&!v(f,D.counts))H(f,O),l++;else if(/^(true|false)$/.test(O))H(f,O),l++;else H(f,W(f))}else if(d.match(/^-.\..+=/)){if(x=d.match(/^-([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3)H(x[1],x[2])}else if(d.match(/^-.\..+/)&&!d.match(j)){if(O=i[l+1],x=d.match(/^-(.\..+)/),x!==null&&Array.isArray(x)&&x.length>=2)if(f=x[1],O!==void 0&&!O.match(/^-/)&&!v(f,D.bools)&&!v(f,D.counts))H(f,O),l++;else H(f,W(f))}else if(d.match(/^-[^-]+/)&&!d.match(j)){_=d.slice(1,-1).split(""),F=!1;for(let de=0;de<_.length;de++){if(O=d.slice(de+2),_[de+1]&&_[de+1]==="="){if(oe=d.slice(de+3),f=_[de],v(f,D.arrays))l=Ae(l,f,i,oe);else if(v(f,D.nargs)!==!1)l=X(l,f,i,oe);else H(f,oe);F=!0;break}if(O==="-"){H(_[de],O);continue}if(/[A-Za-z]/.test(_[de])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(O)&&v(O,D.bools)===!1){H(_[de],O),F=!0;break}if(_[de+1]&&_[de+1].match(/\W/)){H(_[de],O),F=!0;break}else H(_[de],W(_[de]))}if(f=d.slice(-1)[0],!F&&f!=="-")if(v(f,D.arrays))l=Ae(l,f,i);else if(v(f,D.nargs)!==!1)l=X(l,f,i);else if(O=i[l+1],O!==void 0&&(!/^(-|--)[^-]/.test(O)||O.match(j))&&!v(f,D.bools)&&!v(f,D.counts))H(f,O),l++;else if(/^(true|false)$/.test(O))H(f,O),l++;else H(f,W(f))}else if(d.match(/^-[0-9]$/)&&d.match(j)&&v(d.slice(1),D.bools))f=d.slice(1),H(f,W(f));else if(d==="--"){ce=i.slice(l+1);break}else if(o["halt-at-non-option"]){ce=i.slice(l);break}else ne(d)}if(te(R,!0),te(R,!1),B(R),V(),ke(R,D.aliases,a,!0),G(R),o["set-placeholder-key"])ie(R);if(Object.keys(D.counts).forEach(function(l){if(!U(R,l.split(".")))H(l,0)}),E&&ce.length)R[h]=[];if(ce.forEach(function(l){R[h].push(l)}),o["camel-case-expansion"]&&o["strip-dashed"])Object.keys(R).filter((l)=>l!=="--"&&l.includes("-")).forEach((l)=>{delete R[l]});if(o["strip-aliased"])[].concat(...Object.keys(s).map((l)=>s[l])).forEach((l)=>{if(o["camel-case-expansion"]&&l.includes("-"))delete R[l.split(".").map((d)=>He(d)).join(".")];delete R[l]});function ne(l){let d=C("_",l);if(typeof d==="string"||typeof d==="number")R._.push(d)}function X(l,d,y,F){let f,_=v(d,D.nargs);if(_=typeof _!=="number"||isNaN(_)?1:_,_===0){if(!se(F))T=Error(b("Argument unexpected for: %s",d));return H(d,W(d)),l}let x=se(F)?0:1;if(o["nargs-eats-options"]){if(y.length-(l+1)+x<_)T=Error(b("Not enough arguments following: %s",d));x=_}else{for(f=l+1;f<y.length;f++)if(!y[f].match(/^-[^0-9]/)||y[f].match(j)||z(y[f]))x++;else break;if(x<_)T=Error(b("Not enough arguments following: %s",d))}let O=Math.min(x,_);if(!se(F)&&O>0)H(d,F),O--;for(f=l+1;f<O+l+1;f++)H(d,y[f]);return l+O}function Ae(l,d,y,F){let f=[],_=F||y[l+1],x=v(d,D.nargs);if(v(d,D.bools)&&!/^(true|false)$/.test(_))f.push(!0);else if(se(_)||se(F)&&/^-/.test(_)&&!j.test(_)&&!z(_)){if(a[d]!==void 0){let O=a[d];f=Array.isArray(O)?O:[O]}}else{if(!se(F))f.push(S(d,F,!0));for(let O=l+1;O<y.length;O++){if(!o["greedy-arrays"]&&f.length>0||x&&typeof x==="number"&&f.length>=x)break;if(_=y[O],/^-/.test(_)&&!j.test(_)&&!z(_))break;l=O,f.push(S(d,_,r))}}if(typeof x==="number"&&(x&&f.length<x||isNaN(x)&&f.length===0))T=Error(b("Not enough arguments following: %s",d));return H(d,f),l}function H(l,d,y=r){if(/-/.test(l)&&o["camel-case-expansion"]){let _=l.split(".").map(function(x){return He(x)}).join(".");pt(l,_)}let F=S(l,d,y),f=l.split(".");if(Pe(R,f,F),D.aliases[l])D.aliases[l].forEach(function(_){let x=_.split(".");Pe(R,x,F)});if(f.length>1&&o["dot-notation"])(D.aliases[f[0]]||[]).forEach(function(_){let x=_.split("."),O=[].concat(f);if(O.shift(),x=x.concat(O),!(D.aliases[l]||[]).includes(x.join(".")))Pe(R,x,F)});if(v(l,D.normalize)&&!v(l,D.arrays))[l].concat(D.aliases[l]||[]).forEach(function(x){Object.defineProperty(Y,x,{enumerable:!0,get(){return d},set(O){d=typeof O==="string"?ve.normalize(O):O}})})}function pt(l,d){if(!(D.aliases[l]&&D.aliases[l].length))D.aliases[l]=[d],p[d]=!0;if(!(D.aliases[d]&&D.aliases[d].length))pt(d,l)}function S(l,d,y){if(y)d=Fo(d);if(v(l,D.bools)||v(l,D.counts)){if(typeof d==="string")d=d==="true"}let F=Array.isArray(d)?d.map(function(f){return C(l,f)}):C(l,d);if(v(l,D.counts)&&(se(F)||typeof F==="boolean"))F=ln();if(v(l,D.normalize)&&v(l,D.arrays))if(Array.isArray(d))F=d.map((f)=>ve.normalize(f));else F=ve.normalize(d);return F}function C(l,d){if(!o["parse-positional-numbers"]&&l==="_")return d;if(!v(l,D.strings)&&!v(l,D.bools)&&!Array.isArray(d)){if($t(d)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${d}`)))||!se(d)&&v(l,D.numbers))d=Number(d)}return d}function B(l){let d=Object.create(null);ke(d,D.aliases,a),Object.keys(D.configs).forEach(function(y){let F=l[y]||d[y];if(F)try{let f=null,_=ve.resolve(ve.cwd(),F),x=D.configs[y];if(typeof x==="function"){try{f=x(_)}catch(O){f=O}if(f instanceof Error){T=f;return}}else f=ve.require(_);N(f)}catch(f){if(f.name==="PermissionDenied")T=f;else if(l[y])T=Error(b("Invalid JSON config file: %s",F))}})}function N(l,d){Object.keys(l).forEach(function(y){let F=l[y],f=d?d+"."+y:y;if(typeof F==="object"&&F!==null&&!Array.isArray(F)&&o["dot-notation"])N(F,f);else if(!U(R,f.split("."))||v(f,D.arrays)&&o["combine-arrays"])H(f,F)})}function V(){if(typeof c<"u")c.forEach(function(l){N(l)})}function te(l,d){if(typeof g>"u")return;let y=typeof g==="string"?g:"",F=ve.env();Object.keys(F).forEach(function(f){if(y===""||f.lastIndexOf(y,0)===0){let _=f.split("__").map(function(x,O){if(O===0)x=x.substring(y.length);return He(x)});if((d&&D.configs[_.join(".")]||!d)&&!U(l,_))H(_.join("."),F[f])}})}function G(l){let d,y=new Set;Object.keys(l).forEach(function(F){if(!y.has(F)){if(d=v(F,D.coercions),typeof d==="function")try{let f=C(F,d(l[F]));[].concat(D.aliases[F]||[],F).forEach((_)=>{y.add(_),l[_]=f})}catch(f){T=f}}})}function ie(l){return D.keys.forEach((d)=>{if(~d.indexOf("."))return;if(typeof l[d]>"u")l[d]=void 0}),l}function ke(l,d,y,F=!1){Object.keys(y).forEach(function(f){if(!U(l,f.split("."))){if(Pe(l,f.split("."),y[f]),F)m[f]=!0;(d[f]||[]).forEach(function(_){if(U(l,_.split(".")))return;Pe(l,_.split("."),y[f])})}})}function U(l,d){let y=l;if(!o["dot-notation"])d=[d.join(".")];d.slice(0,-1).forEach(function(f){y=y[f]||{}});let F=d[d.length-1];if(typeof y!=="object")return!1;else return F in y}function Pe(l,d,y){let F=l;if(!o["dot-notation"])d=[d.join(".")];d.slice(0,-1).forEach(function(oe){if(oe=mi(oe),typeof F==="object"&&F[oe]===void 0)F[oe]={};if(typeof F[oe]!=="object"||Array.isArray(F[oe])){if(Array.isArray(F[oe]))F[oe].push({});else F[oe]=[F[oe],{}];F=F[oe][F[oe].length-1]}else F=F[oe]});let f=mi(d[d.length-1]),_=v(d.join("."),D.arrays),x=Array.isArray(y),O=o["duplicate-arguments-array"];if(!O&&v(f,D.nargs)){if(O=!0,!se(F[f])&&D.nargs[f]===1||Array.isArray(F[f])&&F[f].length===D.nargs[f])F[f]=void 0}if(y===ln())F[f]=ln(F[f]);else if(Array.isArray(F[f]))if(O&&_&&x)F[f]=o["flatten-duplicate-arrays"]?F[f].concat(y):(Array.isArray(F[f][0])?F[f]:[F[f]]).concat([y]);else if(!O&&Boolean(_)===Boolean(x))F[f]=y;else F[f]=F[f].concat([y]);else if(F[f]===void 0&&_)F[f]=x?y:[y];else if(O&&!(F[f]===void 0||v(f,D.counts)||v(f,D.bools)))F[f]=[F[f],y];else F[f]=y}function gt(...l){l.forEach(function(d){Object.keys(d||{}).forEach(function(y){if(D.aliases[y])return;D.aliases[y]=[].concat(s[y]||[]),D.aliases[y].concat(y).forEach(function(F){if(/-/.test(F)&&o["camel-case-expansion"]){let f=He(F);if(f!==y&&D.aliases[y].indexOf(f)===-1)D.aliases[y].push(f),p[f]=!0}}),D.aliases[y].concat(y).forEach(function(F){if(F.length>1&&/[A-Z]/.test(F)&&o["camel-case-expansion"]){let f=vt(F,"-");if(f!==y&&D.aliases[y].indexOf(f)===-1)D.aliases[y].push(f),p[f]=!0}}),D.aliases[y].forEach(function(F){D.aliases[F]=[y].concat(D.aliases[y].filter(function(f){return F!==f}))})})})}function v(l,d){let y=[].concat(D.aliases[l]||[],l),F=Object.keys(d),f=y.find((_)=>F.includes(_));return f?d[f]:!1}function ot(l){let d=Object.keys(D);return[].concat(d.map((F)=>D[F])).some(function(F){return Array.isArray(F)?F.includes(l):F[l]})}function Gn(l,...d){return[].concat(...d).some(function(F){let f=l.match(F);return f&&ot(f[1])})}function k(l){if(l.match(j)||!l.match(/^-[^-]+/))return!1;let d=!0,y,F=l.slice(1).split("");for(let f=0;f<F.length;f++){if(y=l.slice(f+2),!ot(F[f])){d=!1;break}if(F[f+1]&&F[f+1]==="="||y==="-"||/[A-Za-z]/.test(F[f])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(y)||F[f+1]&&F[f+1].match(/\W/))break}return d}function z(l){return o["unknown-options-as-args"]&&re(l)}function re(l){if(l=l.replace(/^-{3,}/,"--"),l.match(j))return!1;if(k(l))return!1;return!Gn(l,/^-+([^=]+?)=[\s\S]*$/,L,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function W(l){if(!v(l,D.bools)&&!v(l,D.counts)&&`${l}`in a)return a[l];else return ae(Z(l))}function ae(l){return{[be.BOOLEAN]:!0,[be.STRING]:"",[be.NUMBER]:void 0,[be.ARRAY]:[]}[l]}function Z(l){let d=be.BOOLEAN;if(v(l,D.strings))d=be.STRING;else if(v(l,D.numbers))d=be.NUMBER;else if(v(l,D.bools))d=be.BOOLEAN;else if(v(l,D.arrays))d=be.ARRAY;return d}function se(l){return l===void 0}function en(){Object.keys(D.counts).find((l)=>{if(v(l,D.arrays))return T=Error(b("Invalid configuration: %s, opts.count excludes opts.array.",l)),!0;else if(v(l,D.nargs))return T=Error(b("Invalid configuration: %s, opts.count excludes opts.narg.",l)),!0;return!1})}return{aliases:Object.assign({},D.aliases),argv:Object.assign(Y,R),configuration:o,defaulted:Object.assign({},m),error:T,newAliases:Object.assign({},p)}}}function mo(e){let t=[],n=Object.create(null),i=!0;Object.keys(e).forEach(function(r){t.push([].concat(e[r],r))});while(i){i=!1;for(let r=0;r<t.length;r++)for(let s=r+1;s<t.length;s++)if(t[r].filter(function(a){return t[s].indexOf(a)!==-1}).length){t[r]=t[r].concat(t[s]),t.splice(s,1),i=!0;break}}return t.forEach(function(r){r=r.filter(function(o,a,c){return c.indexOf(o)===a});let s=r.pop();if(s!==void 0&&typeof s==="string")n[s]=r}),n}function ln(e){return e!==void 0?e+1:1}function mi(e){if(e==="__proto__")return"___proto___";return e}function Fo(e){return typeof e==="string"&&(e[0]==="'"||e[0]==='"')&&e[e.length-1]===e[0]?e.substring(1,e.length-1):e}import{readFileSync as Co}from"fs";import{createRequire as Fi}from"module";var fn,dn,Dn,bi=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Ei=(dn=(fn=process===null||process===void 0?void 0:process.versions)===null||fn===void 0?void 0:fn.node)!==null&&dn!==void 0?dn:(Dn=process===null||process===void 0?void 0:process.version)===null||Dn===void 0?void 0:Dn.slice(1);if(Ei){if(Number(Ei.match(/^([^.]+)/)[1])<bi)throw Error(`yargs parser supports a minimum Node.js version of ${bi}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var xo=process?process.env:{},yi=Fi?Fi(import.meta.url):void 0,Ci=new cn({cwd:process.cwd,env:()=>xo,format:bo,normalize:Eo,resolve:yo,require:(e)=>{if(typeof yi<"u")return yi(e);else if(e.match(/\.json$/))return JSON.parse(Co(e,"utf8"));else throw Error("only .json config files are supported in ESM")}}),mt=function(t,n){return Ci.parse(t.slice(),n).argv};mt.detailed=function(e,t){return Ci.parse(e.slice(),t)};mt.camelCase=He;mt.decamelize=vt;mt.looksLikeNumber=$t;var xi=mt;import{basename as Jo,dirname as Ko,extname as qo,relative as Xo,resolve as Mi,join as Zo}from"path";function wo(){if(Ao())return 0;return 1}function Ao(){return _o()&&!process.defaultApp}function _o(){return!!process.versions.electron}function wi(){return process.argv[wo()]}var So=new Intl.Segmenter,Ai=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v,Bo=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v,Po=/\p{Spacing_Mark}/v,Oo=/^\p{RGI_Emoji}$/v,jo=/^[\d#*]\u20E3$/,vo=/\p{Extended_Pictographic}/gu;function $o(e){if(e.length>50)return!1;if(jo.test(e))return!0;if(e.includes("\u200D")){let t=e.match(vo);return t!==null&&t.length>=2}return!1}function ko(e){return e.replace(Bo,"")}function Mo(e){return Ai.test(e)}function _i(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function Si(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function Bi(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function No(e){return _i(e)||Si(e)||Bi(e)}function Io(e,t){let n=[];for(let r of e){if(Ai.test(r))continue;n.push(r.codePointAt(0))}if(n.length===0)return;let i=0;for(let r=0;r<n.length;r++){let s=n[r];if(!No(s)){if(i===0)return;for(let o=r;o<n.length;o++)i+=Ve(n[o],t);return i}if(_i(s)&&Si(n[r+1])){i+=2,r+=Bi(n[r+2])?2:1;continue}i+=Ve(s,t)}return i}function Ro(e,t){let n=0,i=!0;for(let r of e){if(i){i=!1;continue}if(Po.test(r)||r>="\uFF00"&&r<="\uFFEF")n+=Ve(r.codePointAt(0),t)}return n}function hn(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:i=!1}=t,r=e;if(!i&&(r.includes("\x1B")||r.includes("\x9B")))r=Oe(r);if(r.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(r))return r.length;let s=0,o={ambiguousAsWide:!n};for(let{segment:a}of So.segment(r)){if(Mo(a))continue;if(Oo.test(a)||$o(a)){s+=2;continue}let c=ko(a),g=Io(c,o);if(g!==void 0){s+=g;continue}let E=c.codePointAt(0);s+=Ve(E,o),s+=Ro(c,o)}return s}import{readFileSync as To,statSync as Wo,writeFile as Lo}from"fs";import{format as Go}from"util";import{resolve as Vo}from"path";var Pi={fs:{readFileSync:To,writeFile:Lo},format:Go,resolve:Vo,exists:(e)=>{try{return Wo(e).isFile()}catch(t){return!1}}};var xe;class Oi{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles==="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage==="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let t=e.shift(),n=function(){};if(typeof e[e.length-1]==="function")n=e.pop();if(n=n||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n});else n();return xe.format.apply(xe.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),i=e.shift(),r=function(){};if(typeof e[e.length-1]==="function")r=e.pop();if(!this.cache[this.locale])this._readLocaleFile();let s=i===1?t:n;if(this.cache[this.locale][t])s=this.cache[this.locale][t][i===1?"one":"other"];if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:r});else r();let o=[s];if(~s.indexOf("%d"))o.push(i);return xe.format.apply(xe.format,o.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){if(!this.cache[this.locale])this._readLocaleFile();for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))this.cache[this.locale][t]=e[t]}_taggedLiteral(e,...t){let n="";return e.forEach(function(i,r){let s=t[r+1];if(n+=i,typeof s<"u")n+="%s"}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){if(this.writeQueue.push(e),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let e=this,t=this.writeQueue[0],n=t.directory,i=t.locale,r=t.cb,s=this._resolveLocaleFile(n,i),o=JSON.stringify(this.cache[i],null,2);xe.fs.writeFile(s,o,"utf-8",function(a){if(e.writeQueue.shift(),e.writeQueue.length>0)e._processWriteQueue();r(a)})}_readLocaleFile(){let e={},t=this._resolveLocaleFile(this.directory,this.locale);try{if(xe.fs.readFileSync)e=JSON.parse(xe.fs.readFileSync(t,"utf-8"))}catch(n){if(n instanceof SyntaxError)n.message="syntax error in "+t;if(n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=xe.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let i=xe.resolve(e,"./",t.split("_")[0]+".json");if(this._fileExistsSync(i))n=i}return n}_fileExistsSync(e){return xe.exists(e)}}function ji(e,t){xe=t;let n=new Oi(e);return{__:n.__.bind(n),__n:n.__n.bind(n),setLocale:n.setLocale.bind(n),getLocale:n.getLocale.bind(n),updateLocale:n.updateLocale.bind(n),locale:n.locale}}var Ho=(e)=>ji(e,Pi),vi=Ho;var Ii=zs(ki(),1);import{createRequire as Qo}from"module";import{readFileSync as eu,readdirSync as tu}from"fs";var pn=Ni(import.meta.url),nu=pn.substring(0,pn.lastIndexOf("node_modules")),iu=Qo(import.meta.url),Ri={assert:{notStrictEqual:zo,strictEqual:Uo},cliui:un,findUp:an,getEnv:(e)=>process.env[e],inspect:Yo,getProcessArgvBin:wi,mainFilename:nu||process.cwd(),Parser:xi,path:{basename:Jo,dirname:Ko,extname:qo,relative:Xo,resolve:Mi,join:Zo},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(e,t)=>process.emitWarning(e,t),execPath:()=>process.execPath,exit:(e)=>{process.exit(e)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:eu,readdirSync:tu,require:iu,getCallerFile:()=>{let e=Ii.default(3);return e.match(/^file:\/\//)?Ni(e):e},stringWidth:hn,y18n:vi({directory:Mi(pn,"../../../locales"),updateFiles:!1})};function De(e,t,n,i){n.assert.notStrictEqual(e,t,i)}function gn(e,t){t.assert.strictEqual(typeof e,"string")}function ut(e){return Object.keys(e)}function J(e){return!!e&&!!e.then&&typeof e.then==="function"}class Q extends Error{constructor(e){super(e||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,Q)}}function Me(e){let n=e.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),i=/\.*[\][<>]/g,r=n.shift();if(!r)throw Error(`No command found in: ${e}`);let s={cmd:r.replace(i,""),demanded:[],optional:[]};return n.forEach((o,a)=>{let c=!1;if(o=o.replace(/\s/g,""),/\.+[\]>]/.test(o)&&a===n.length-1)c=!0;if(/^\[/.test(o))s.optional.push({cmd:o.replace(i,"").split("|"),variadic:c});else s.demanded.push({cmd:o.replace(i,"").split("|"),variadic:c})}),s}var ru=["first","second","third","fourth","fifth","sixth"];function w(e,t,n){function i(){return typeof e==="object"?[{demanded:[],optional:[]},e,t]:[Me(`cmd ${e}`),t,n]}try{let r=0,[s,o,a]=i(),c=[].slice.call(o);while(c.length&&c[c.length-1]===void 0)c.pop();let g=a||c.length;if(g<s.demanded.length)throw new Q(`Not enough arguments provided. Expected ${s.demanded.length} but received ${c.length}.`);let E=s.demanded.length+s.optional.length;if(g>E)throw new Q(`Too many arguments provided. Expected max ${E} but received ${g}.`);s.demanded.forEach((h)=>{let p=c.shift(),m=Ti(p);if(h.cmd.filter((D)=>D===m||D==="*").length===0)Wi(m,h.cmd,r);r+=1}),s.optional.forEach((h)=>{if(c.length===0)return;let p=c.shift(),m=Ti(p);if(h.cmd.filter((D)=>D===m||D==="*").length===0)Wi(m,h.cmd,r);r+=1})}catch(r){console.warn(r.stack)}}function Ti(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function Wi(e,t,n){throw new Q(`Invalid ${ru[n]||"manyith"} argument. Expected ${t.join(" or ")} but received ${e}.`)}class mn{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,i=!1){if(w("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let r=0;r<e.length;r++){if(typeof e[r]!=="function")throw Error("middleware must be a function");let s=e[r];s.applyBeforeValidation=t,s.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e==="function"){let r=e;r.applyBeforeValidation=t,r.global=n,r.mutates=i,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((i)=>{let r=[...n[t]||[],t];if(!i.option)return!0;else return!r.includes(i.option)}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();if(e!==void 0)this.globalMiddleware=e}reset(){this.globalMiddleware=this.globalMiddleware.filter((e)=>e.global)}}function Li(e){if(!e)return[];return e.map((t)=>(t.applyBeforeValidation=!1,t))}function ze(e,t,n,i){return n.reduce((r,s)=>{if(s.applyBeforeValidation!==i)return r;if(s.mutates){if(s.applied)return r;s.applied=!0}if(J(r))return r.then((o)=>Promise.all([o,s(o,t)])).then(([o,a])=>Object.assign(o,a));else{let o=s(r,t);return J(o)?o.then((a)=>Object.assign(r,a)):Object.assign(r,o)}},e)}function Ue(e,t,n=(i)=>{throw i}){try{let i=su(e)?e():e;return J(i)?i.then((r)=>t(r)):t(i)}catch(i){return n(i)}}function su(e){return typeof e==="function"}var at=/(^\*)|(^\$0)/;class Vi{constructor(e,t,n,i){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=i,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,i){i=i||{},this.requireCache.add(n);let r=this.shim.path.resolve(this.shim.path.dirname(n),e),s=this.shim.readdirSync(r,{recursive:i.recurse?!0:!1});if(!Array.isArray(i.extensions))i.extensions=["js"];let o=typeof i.visit==="function"?i.visit:(a)=>a;for(let a of s){let c=a.toString();if(i.exclude){let E=!1;if(typeof i.exclude==="function")E=i.exclude(c);else E=i.exclude.test(c);if(E)continue}if(i.include){let E=!1;if(typeof i.include==="function")E=i.include(c);else E=i.include.test(c);if(!E)continue}let g=!1;for(let E of i.extensions)if(c.endsWith(E))g=!0;if(g){let E=this.shim.path.join(r,c),h=t(E),p=Object.create(null,Object.getOwnPropertyDescriptors({...h}));if(o(p,E,c)){if(this.requireCache.has(E))continue;else this.requireCache.add(E);if(!p.command)p.command=this.shim.path.basename(E,this.shim.path.extname(E));this.addHandler(p)}}}}addHandler(e,t,n,i,r,s){let o=[],a=Li(r);if(i=i||(()=>{}),Array.isArray(e))if(ou(e))[e,...o]=e;else for(let c of e)this.addHandler(c);else if(au(e)){let c=Array.isArray(e.command)||typeof e.command==="string"?e.command:null;if(c===null)throw Error(`No command name given for module: ${this.shim.inspect(e)}`);if(e.aliases)c=[].concat(c).concat(e.aliases);this.addHandler(c,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(Gi(n)){this.addHandler([e].concat(o),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e==="string"){let c=Me(e);o=o.map((h)=>Me(h).cmd);let g=!1,E=[c.cmd].concat(o).filter((h)=>{if(at.test(h))return g=!0,!1;return!0});if(E.length===0&&g)E.push("$0");if(g)c.cmd=E[0],o=E.slice(1),e=e.replace(at,c.cmd);if(o.forEach((h)=>{this.aliasMap[h]=c.cmd}),t!==!1)this.usage.command(e,t,g,o,s);if(this.handlers[c.cmd]={original:e,description:t,handler:i,builder:n||{},middlewares:a,deprecated:s,demanded:c.demanded,optional:c.optional},g)this.defaultCommand=this.handlers[c.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,i,r,s){let o=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,a=t.getInternalMethods().getContext(),c=a.commands.slice(),g=!e;if(e)a.commands.push(e),a.fullCommands.push(o.original);let E=this.applyBuilderUpdateUsageAndParse(g,o,t,n.aliases,c,i,r,s);return J(E)?E.then((h)=>this.applyMiddlewareAndGetResult(g,o,h.innerArgv,a,r,h.aliases,t)):this.applyMiddlewareAndGetResult(g,o,E.innerArgv,a,r,E.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,i,r,s,o,a){let c=t.builder,g=n;if(kt(c)){n.getInternalMethods().getUsageInstance().freeze();let E=c(n.getInternalMethods().reset(i),a);if(J(E))return E.then((h)=>(g=zi(h)?h:n,this.parseAndUpdateUsage(e,t,g,r,s,o)))}else if(uu(c))n.getInternalMethods().getUsageInstance().freeze(),g=n.getInternalMethods().reset(i),Object.keys(t.builder).forEach((E)=>{g.option(E,c[E])});return this.parseAndUpdateUsage(e,t,g,r,s,o)}parseAndUpdateUsage(e,t,n,i,r,s){if(e)n.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(n))n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(i,t),t.description);let o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,r,s);return J(o)?o.then((a)=>({aliases:n.parsed.aliases,innerArgv:a})):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=at.test(t.original)?t.original.replace(at,"").trim():t.original,i=e.filter((r)=>!at.test(r));return i.push(n),`$0 ${i.join(" ")}`}handleValidationAndGetResult(e,t,n,i,r,s,o,a){if(!s.getInternalMethods().getHasOutput()){let c=s.getInternalMethods().runValidation(r,a,s.parsed.error,e);n=Ue(n,(g)=>(c(g),g))}if(t.handler&&!s.getInternalMethods().getHasOutput()){s.getInternalMethods().setHasOutput();let c=!!s.getOptions().configuration["populate--"];if(s.getInternalMethods().postProcess(n,c,!1,!1),n=ze(n,s,o,!1),n=Ue(n,(g)=>{let E=t.handler(g);return J(E)?E.then(()=>g):g}),!e)s.getInternalMethods().getUsageInstance().cacheHelpMessage();if(J(n)&&!s.getInternalMethods().hasParseCallback())n.catch((g)=>{try{s.getInternalMethods().getUsageInstance().fail(null,g)}catch(E){}})}if(!e)i.commands.pop(),i.fullCommands.pop();return n}applyMiddlewareAndGetResult(e,t,n,i,r,s,o){let a={};if(r)return n;if(!o.getInternalMethods().getHasOutput())a=this.populatePositionals(t,n,i,o);let c=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),g=ze(n,o,c,!0);return J(g)?g.then((E)=>this.handleValidationAndGetResult(e,t,E,i,s,o,c,a)):this.handleValidationAndGetResult(e,t,g,i,s,o,c,a)}populatePositionals(e,t,n,i){t._=t._.slice(n.commands.length);let r=e.demanded.slice(0),s=e.optional.slice(0),o={};this.validation.positionalCount(r.length,t._.length);while(r.length){let a=r.shift();this.populatePositional(a,t,o)}while(s.length){let a=s.shift();this.populatePositional(a,t,o)}return t._=n.commands.concat(t._.map((a)=>""+a)),this.postProcessPositionals(t,o,this.cmdToParseOptions(e.original),i),o}populatePositional(e,t,n){let i=e.cmd[0];if(e.variadic)n[i]=t._.splice(0).map(String);else if(t._.length)n[i]=[String(t._.shift())]}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=Me(e);return n.demanded.forEach((i)=>{let[r,...s]=i.cmd;if(i.variadic)t.array.push(r),t.default[r]=[];t.alias[r]=s,t.demand[r]=!0}),n.optional.forEach((i)=>{let[r,...s]=i.cmd;if(i.variadic)t.array.push(r),t.default[r]=[];t.alias[r]=s}),t}postProcessPositionals(e,t,n,i){let r=Object.assign({},i.getOptions());r.default=Object.assign(n.default,r.default);for(let c of Object.keys(n.alias))r.alias[c]=(r.alias[c]||[]).concat(n.alias[c]);r.array=r.array.concat(n.array),r.config={};let s=[];if(Object.keys(t).forEach((c)=>{t[c].map((g)=>{if(r.configuration["unknown-options-as-args"])r.key[c]=!0;s.push(`--${c}`),s.push(g)})}),!s.length)return;let o=Object.assign({},r.configuration,{"populate--":!1}),a=this.shim.Parser.detailed(s,Object.assign({},r,{configuration:o}));if(a.error)i.getInternalMethods().getUsageInstance().fail(a.error.message,a.error);else{let c=Object.keys(t);Object.keys(t).forEach((g)=>{c.push(...a.aliases[g])}),Object.keys(a.argv).forEach((g)=>{if(c.includes(g)){if(!t[g])t[g]=a.argv[g];if(!this.isInConfigs(i,g)&&!this.isDefaulted(i,g)&&Object.prototype.hasOwnProperty.call(e,g)&&Object.prototype.hasOwnProperty.call(a.argv,g)&&(Array.isArray(e[g])||Array.isArray(a.argv[g])))e[g]=[].concat(e[g],a.argv[g]);else e[g]=a.argv[g]}})}}isDefaulted(e,t){let{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){let{configObjects:n}=e.getOptions();return n.some((i)=>Object.prototype.hasOwnProperty.call(i,t))||n.some((i)=>Object.prototype.hasOwnProperty.call(i,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=at.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let t=this.defaultCommand.builder;if(kt(t))return t(e,!0);else if(!Gi(t))Object.keys(t).forEach((n)=>{e.option(n,t[n])});return}extractDesc({describe:e,description:t,desc:n}){for(let i of[e,t,n]){if(typeof i==="string"||i===!1)return i;De(i,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();De(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function Hi(e,t,n,i){return new Vi(e,t,n,i)}function Gi(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function ou(e){return e.every((t)=>typeof t==="string")}function kt(e){return typeof e==="function"}function uu(e){return typeof e==="object"}function au(e){return typeof e==="object"&&!Array.isArray(e)}function Ne(e={},t=()=>!0){let n={};return ut(e).forEach((i)=>{if(t(i,e[i]))n[i]=e[i]}),n}function Ie(e){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((t)=>{let n=t;if(n._handle&&n.isTTY&&typeof n._handle.setBlocking==="function")n._handle.setBlocking(e)})}function lu(e){return typeof e==="boolean"}function Yi(e,t){let n=t.y18n.__,i={},r=[];i.failFn=function(C){r.push(C)};let s=null,o=null,a=!0;i.showHelpOnFail=function(C=!0,B){let[N,V]=typeof C==="string"?[!0,C]:[C,B];if(e.getInternalMethods().isGlobalContext())o=V;return s=V,a=N,i};let c=!1;i.fail=function(C,B){let N=e.getInternalMethods().getLoggerInstance();if(r.length)for(let V=r.length-1;V>=0;--V){let te=r[V];if(lu(te)){if(B)throw B;else if(C)throw Error(C)}else te(C,B,i)}else{if(e.getExitProcess())Ie(!0);if(!c){if(c=!0,a)e.showHelp("error"),N.error();if(C||B)N.error(C||B);let V=s||o;if(V){if(C||B)N.error("");N.error(V)}}if(B=B||new Q(C),e.getExitProcess())return e.exit(1);else if(e.getInternalMethods().hasParseCallback())return e.exit(1,B);else throw B}};let g=[],E=!1;i.usage=(S,C)=>{if(S===null)return E=!0,g=[],i;return E=!1,g.push([S,C||""]),i},i.getUsage=()=>g,i.getUsageDisabled=()=>E,i.getPositionalGroupName=()=>n("Positionals:");let h=[];i.example=(S,C)=>{h.push([S,C||""])};let p=[];i.command=function(C,B,N,V,te=!1){if(N)p=p.map((G)=>(G[2]=!1,G));p.push([C,B||"",N,V,te])},i.getCommands=()=>p;let m={};i.describe=function(C,B){if(Array.isArray(C))C.forEach((N)=>{i.describe(N,B)});else if(typeof C==="object")Object.keys(C).forEach((N)=>{i.describe(N,C[N])});else m[C]=B},i.getDescriptions=()=>m;let b=[];i.epilog=(S)=>{b.push(S)};let D=!1,j;i.wrap=(S)=>{D=!0,j=S},i.getWrap=()=>{if(t.getEnv("YARGS_DISABLE_WRAP"))return null;if(!D)j=Ae(),D=!0;return j};let L="__yargsString__:";i.deferY18nLookup=(S)=>L+S,i.help=function(){if(R)return R;ce();let C=e.customScriptName?e.$0:t.path.basename(e.$0),B=e.getDemandedOptions(),N=e.getDemandedCommands(),V=e.getDeprecatedOptions(),te=e.getGroups(),G=e.getOptions(),ie=[];ie=ie.concat(Object.keys(m)),ie=ie.concat(Object.keys(B)),ie=ie.concat(Object.keys(N)),ie=ie.concat(Object.keys(G.default)),ie=ie.filter(ne),ie=Object.keys(ie.reduce((k,z)=>{if(z!=="_")k[z]=!0;return k},{}));let ke=i.getWrap(),U=t.cliui({width:ke,wrap:!!ke});if(!E){if(g.length)g.forEach((k)=>{if(U.div({text:`${k[0].replace(/\$0/g,C)}`}),k[1])U.div({text:`${k[1]}`,padding:[1,0,0,0]})}),U.div();else if(p.length){let k=null;if(N._)k=`${C} <${n("command")}>
13
+ `).map((r)=>ia(r,t,n)).join(`
14
+ `)}function Cn(e){return hr(e,{stringWidth:ke,stripAnsi:je,wrap:En})}import{dirname as Mr,resolve as Nr}from"path";import{readdirSync as sa,statSync as oa}from"fs";function wn(e,t){let n=Nr(".",e),r;if(!oa(n).isDirectory())n=Mr(n);while(!0){if(r=t(n,sa(n)),r)return Nr(n,r);if(n=Mr(r=n),r===n)break}}import{inspect as Ra}from"util";import{fileURLToPath as ri}from"url";import{format as la}from"util";import{normalize as ca,resolve as da}from"path";function Je(e){if(!(e!==e.toLowerCase()&&e!==e.toUpperCase()))e=e.toLowerCase();if(e.indexOf("-")===-1&&e.indexOf("_")===-1)return e;else{let n="",r=!1,i=e.match(/^-+/);for(let s=i?i[0].length:0;s<e.length;s++){let o=e.charAt(s);if(r)r=!1,o=o.toUpperCase();if(s!==0&&(o==="-"||o==="_"))r=!0;else if(o!=="-"&&o!=="_")n+=o}return n}}function Tt(e,t){let n=e.toLowerCase();t=t||"-";let r="";for(let i=0;i<e.length;i++){let s=n.charAt(i),o=e.charAt(i);if(s!==o&&i>0)r+=`${t}${n.charAt(i)}`;else r+=o}return r}function Lt(e){if(e===null||e===void 0)return!1;if(typeof e==="number")return!0;if(/^0x[0-9a-f]+$/i.test(e))return!0;if(/^0[^.]/.test(e))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function Rr(e){if(Array.isArray(e))return e.map((o)=>typeof o!=="string"?o+"":o);e=e.trim();let t=0,n=null,r=null,i=null,s=[];for(let o=0;o<e.length;o++){if(n=r,r=e.charAt(o),r===" "&&!i){if(n!==" ")t++;continue}if(r===i)i=null;else if((r==="'"||r==='"')&&!i)i=r;if(!s[t])s[t]="";s[t]+=r}return s}var ye;(function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"})(ye||(ye={}));var Me;class Sn{constructor(e){Me=e}parse(e,t){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),r=Rr(e),i=typeof e==="string",s=aa(Object.assign(Object.create(null),n.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),u=Object.assign(Object.create(null),n.default),c=n.configObjects||[],p=n.envPrefix,b=o["populate--"],g=b?"--":"_",D=Object.create(null),F=Object.create(null),y=n.__||Me.format,h={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},v=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,W=new RegExp("^--"+o["negation-prefix"]+"(.+)");if([].concat(n.array||[]).filter(Boolean).forEach(function(l){let f=typeof l==="object"?l.key:l,E=Object.keys(l).map(function(m){return{boolean:"bools",string:"strings",number:"numbers"}[m]}).filter(Boolean).pop();if(E)h[E][f]=!0;h.arrays[f]=!0,h.keys.push(f)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(l){h.bools[l]=!0,h.keys.push(l)}),[].concat(n.string||[]).filter(Boolean).forEach(function(l){h.strings[l]=!0,h.keys.push(l)}),[].concat(n.number||[]).filter(Boolean).forEach(function(l){h.numbers[l]=!0,h.keys.push(l)}),[].concat(n.count||[]).filter(Boolean).forEach(function(l){h.counts[l]=!0,h.keys.push(l)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(l){h.normalize[l]=!0,h.keys.push(l)}),typeof n.narg==="object")Object.entries(n.narg).forEach(([l,f])=>{if(typeof f==="number")h.nargs[l]=f,h.keys.push(l)});if(typeof n.coerce==="object")Object.entries(n.coerce).forEach(([l,f])=>{if(typeof f==="function")h.coercions[l]=f,h.keys.push(l)});if(typeof n.config<"u"){if(Array.isArray(n.config)||typeof n.config==="string")[].concat(n.config).filter(Boolean).forEach(function(l){h.configs[l]=!0});else if(typeof n.config==="object")Object.entries(n.config).forEach(([l,f])=>{if(typeof f==="boolean"||typeof f==="function")h.configs[l]=f})}wt(n.key,s,n.default,h.arrays),Object.keys(u).forEach(function(l){(h.aliases[l]||[]).forEach(function(f){u[f]=u[l]})});let T=null;pn();let ce=[],I=Object.assign(Object.create(null),{_:[]}),Y={};for(let l=0;l<r.length;l++){let f=r[l],E=f.replace(/^-{3,}/,"---"),m,d,A,w,O,oe;if(f!=="--"&&/^-/.test(f)&&G(f))ne(f);else if(E.match(/^---+(=|$)/)){ne(f);continue}else if(f.match(/^--.+=/)||!o["short-option-groups"]&&f.match(/^-.+=/)){if(w=f.match(/^--?([^=]+)=([\s\S]*)$/),w!==null&&Array.isArray(w)&&w.length>=3)if(j(w[1],h.arrays))l=Pe(l,w[1],r,w[2]);else if(j(w[1],h.nargs)!==!1)l=X(l,w[1],r,w[2]);else z(w[1],w[2],!0)}else if(f.match(W)&&o["boolean-negation"]){if(w=f.match(W),w!==null&&Array.isArray(w)&&w.length>=2)d=w[1],z(d,j(d,h.arrays)?[!1]:!1)}else if(f.match(/^--.+/)||!o["short-option-groups"]&&f.match(/^-[^-]+/)){if(w=f.match(/^--?(.+)/),w!==null&&Array.isArray(w)&&w.length>=2)if(d=w[1],j(d,h.arrays))l=Pe(l,d,r);else if(j(d,h.nargs)!==!1)l=X(l,d,r);else if(O=r[l+1],O!==void 0&&(!O.match(/^-/)||O.match(v))&&!j(d,h.bools)&&!j(d,h.counts))z(d,O),l++;else if(/^(true|false)$/.test(O))z(d,O),l++;else z(d,L(d))}else if(f.match(/^-.\..+=/)){if(w=f.match(/^-([^=]+)=([\s\S]*)$/),w!==null&&Array.isArray(w)&&w.length>=3)z(w[1],w[2])}else if(f.match(/^-.\..+/)&&!f.match(v)){if(O=r[l+1],w=f.match(/^-(.\..+)/),w!==null&&Array.isArray(w)&&w.length>=2)if(d=w[1],O!==void 0&&!O.match(/^-/)&&!j(d,h.bools)&&!j(d,h.counts))z(d,O),l++;else z(d,L(d))}else if(f.match(/^-[^-]+/)&&!f.match(v)){A=f.slice(1,-1).split(""),m=!1;for(let fe=0;fe<A.length;fe++){if(O=f.slice(fe+2),A[fe+1]&&A[fe+1]==="="){if(oe=f.slice(fe+3),d=A[fe],j(d,h.arrays))l=Pe(l,d,r,oe);else if(j(d,h.nargs)!==!1)l=X(l,d,r,oe);else z(d,oe);m=!0;break}if(O==="-"){z(A[fe],O);continue}if(/[A-Za-z]/.test(A[fe])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(O)&&j(O,h.bools)===!1){z(A[fe],O),m=!0;break}if(A[fe+1]&&A[fe+1].match(/\W/)){z(A[fe],O),m=!0;break}else z(A[fe],L(A[fe]))}if(d=f.slice(-1)[0],!m&&d!=="-")if(j(d,h.arrays))l=Pe(l,d,r);else if(j(d,h.nargs)!==!1)l=X(l,d,r);else if(O=r[l+1],O!==void 0&&(!/^(-|--)[^-]/.test(O)||O.match(v))&&!j(d,h.bools)&&!j(d,h.counts))z(d,O),l++;else if(/^(true|false)$/.test(O))z(d,O),l++;else z(d,L(d))}else if(f.match(/^-[0-9]$/)&&f.match(v)&&j(f.slice(1),h.bools))d=f.slice(1),z(d,L(d));else if(f==="--"){ce=r.slice(l+1);break}else if(o["halt-at-non-option"]){ce=r.slice(l);break}else ne(f)}if(te(I,!0),te(I,!1),_(I),V(),Ne(I,h.aliases,u,!0),H(I),o["set-placeholder-key"])re(I);if(Object.keys(h.counts).forEach(function(l){if(!U(I,l.split(".")))z(l,0)}),b&&ce.length)I[g]=[];if(ce.forEach(function(l){I[g].push(l)}),o["camel-case-expansion"]&&o["strip-dashed"])Object.keys(I).filter((l)=>l!=="--"&&l.includes("-")).forEach((l)=>{delete I[l]});if(o["strip-aliased"])[].concat(...Object.keys(s).map((l)=>s[l])).forEach((l)=>{if(o["camel-case-expansion"]&&l.includes("-"))delete I[l.split(".").map((f)=>Je(f)).join(".")];delete I[l]});function ne(l){let f=C("_",l);if(typeof f==="string"||typeof f==="number")I._.push(f)}function X(l,f,E,m){let d,A=j(f,h.nargs);if(A=typeof A!=="number"||isNaN(A)?1:A,A===0){if(!se(m))T=Error(y("Argument unexpected for: %s",f));return z(f,L(f)),l}let w=se(m)?0:1;if(o["nargs-eats-options"]){if(E.length-(l+1)+w<A)T=Error(y("Not enough arguments following: %s",f));w=A}else{for(d=l+1;d<E.length;d++)if(!E[d].match(/^-[^0-9]/)||E[d].match(v)||G(E[d]))w++;else break;if(w<A)T=Error(y("Not enough arguments following: %s",f))}let O=Math.min(w,A);if(!se(m)&&O>0)z(f,m),O--;for(d=l+1;d<O+l+1;d++)z(f,E[d]);return l+O}function Pe(l,f,E,m){let d=[],A=m||E[l+1],w=j(f,h.nargs);if(j(f,h.bools)&&!/^(true|false)$/.test(A))d.push(!0);else if(se(A)||se(m)&&/^-/.test(A)&&!v.test(A)&&!G(A)){if(u[f]!==void 0){let O=u[f];d=Array.isArray(O)?O:[O]}}else{if(!se(m))d.push(P(f,m,!0));for(let O=l+1;O<E.length;O++){if(!o["greedy-arrays"]&&d.length>0||w&&typeof w==="number"&&d.length>=w)break;if(A=E[O],/^-/.test(A)&&!v.test(A)&&!G(A))break;l=O,d.push(P(f,A,i))}}if(typeof w==="number"&&(w&&d.length<w||isNaN(w)&&d.length===0))T=Error(y("Not enough arguments following: %s",f));return z(f,d),l}function z(l,f,E=i){if(/-/.test(l)&&o["camel-case-expansion"]){let A=l.split(".").map(function(w){return Je(w)}).join(".");Ct(l,A)}let m=P(l,f,E),d=l.split(".");if(ve(I,d,m),h.aliases[l])h.aliases[l].forEach(function(A){let w=A.split(".");ve(I,w,m)});if(d.length>1&&o["dot-notation"])(h.aliases[d[0]]||[]).forEach(function(A){let w=A.split("."),O=[].concat(d);if(O.shift(),w=w.concat(O),!(h.aliases[l]||[]).includes(w.join(".")))ve(I,w,m)});if(j(l,h.normalize)&&!j(l,h.arrays))[l].concat(h.aliases[l]||[]).forEach(function(w){Object.defineProperty(Y,w,{enumerable:!0,get(){return f},set(O){f=typeof O==="string"?Me.normalize(O):O}})})}function Ct(l,f){if(!(h.aliases[l]&&h.aliases[l].length))h.aliases[l]=[f],D[f]=!0;if(!(h.aliases[f]&&h.aliases[f].length))Ct(f,l)}function P(l,f,E){if(E)f=ua(f);if(j(l,h.bools)||j(l,h.counts)){if(typeof f==="string")f=f==="true"}let m=Array.isArray(f)?f.map(function(d){return C(l,d)}):C(l,f);if(j(l,h.counts)&&(se(m)||typeof m==="boolean"))m=xn();if(j(l,h.normalize)&&j(l,h.arrays))if(Array.isArray(f))m=f.map((d)=>Me.normalize(d));else m=Me.normalize(f);return m}function C(l,f){if(!o["parse-positional-numbers"]&&l==="_")return f;if(!j(l,h.strings)&&!j(l,h.bools)&&!Array.isArray(f)){if(Lt(f)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${f}`)))||!se(f)&&j(l,h.numbers))f=Number(f)}return f}function _(l){let f=Object.create(null);Ne(f,h.aliases,u),Object.keys(h.configs).forEach(function(E){let m=l[E]||f[E];if(m)try{let d=null,A=Me.resolve(Me.cwd(),m),w=h.configs[E];if(typeof w==="function"){try{d=w(A)}catch(O){d=O}if(d instanceof Error){T=d;return}}else d=Me.require(A);N(d)}catch(d){if(d.name==="PermissionDenied")T=d;else if(l[E])T=Error(y("Invalid JSON config file: %s",m))}})}function N(l,f){Object.keys(l).forEach(function(E){let m=l[E],d=f?f+"."+E:E;if(typeof m==="object"&&m!==null&&!Array.isArray(m)&&o["dot-notation"])N(m,d);else if(!U(I,d.split("."))||j(d,h.arrays)&&o["combine-arrays"])z(d,m)})}function V(){if(typeof c<"u")c.forEach(function(l){N(l)})}function te(l,f){if(typeof p>"u")return;let E=typeof p==="string"?p:"",m=Me.env();Object.keys(m).forEach(function(d){if(E===""||d.lastIndexOf(E,0)===0){let A=d.split("__").map(function(w,O){if(O===0)w=w.substring(E.length);return Je(w)});if((f&&h.configs[A.join(".")]||!f)&&!U(l,A))z(A.join("."),m[d])}})}function H(l){let f,E=new Set;Object.keys(l).forEach(function(m){if(!E.has(m)){if(f=j(m,h.coercions),typeof f==="function")try{let d=C(m,f(l[m]));[].concat(h.aliases[m]||[],m).forEach((A)=>{E.add(A),l[A]=d})}catch(d){T=d}}})}function re(l){return h.keys.forEach((f)=>{if(~f.indexOf("."))return;if(typeof l[f]>"u")l[f]=void 0}),l}function Ne(l,f,E,m=!1){Object.keys(E).forEach(function(d){if(!U(l,d.split("."))){if(ve(l,d.split("."),E[d]),m)F[d]=!0;(f[d]||[]).forEach(function(A){if(U(l,A.split(".")))return;ve(l,A.split("."),E[d])})}})}function U(l,f){let E=l;if(!o["dot-notation"])f=[f.join(".")];f.slice(0,-1).forEach(function(d){E=E[d]||{}});let m=f[f.length-1];if(typeof E!=="object")return!1;else return m in E}function ve(l,f,E){let m=l;if(!o["dot-notation"])f=[f.join(".")];f.slice(0,-1).forEach(function(oe){if(oe=Ir(oe),typeof m==="object"&&m[oe]===void 0)m[oe]={};if(typeof m[oe]!=="object"||Array.isArray(m[oe])){if(Array.isArray(m[oe]))m[oe].push({});else m[oe]=[m[oe],{}];m=m[oe][m[oe].length-1]}else m=m[oe]});let d=Ir(f[f.length-1]),A=j(f.join("."),h.arrays),w=Array.isArray(E),O=o["duplicate-arguments-array"];if(!O&&j(d,h.nargs)){if(O=!0,!se(m[d])&&h.nargs[d]===1||Array.isArray(m[d])&&m[d].length===h.nargs[d])m[d]=void 0}if(E===xn())m[d]=xn(m[d]);else if(Array.isArray(m[d]))if(O&&A&&w)m[d]=o["flatten-duplicate-arrays"]?m[d].concat(E):(Array.isArray(m[d][0])?m[d]:[m[d]]).concat([E]);else if(!O&&Boolean(A)===Boolean(w))m[d]=E;else m[d]=m[d].concat([E]);else if(m[d]===void 0&&A)m[d]=w?E:[E];else if(O&&!(m[d]===void 0||j(d,h.counts)||j(d,h.bools)))m[d]=[m[d],E];else m[d]=E}function wt(...l){l.forEach(function(f){Object.keys(f||{}).forEach(function(E){if(h.aliases[E])return;h.aliases[E]=[].concat(s[E]||[]),h.aliases[E].concat(E).forEach(function(m){if(/-/.test(m)&&o["camel-case-expansion"]){let d=Je(m);if(d!==E&&h.aliases[E].indexOf(d)===-1)h.aliases[E].push(d),D[d]=!0}}),h.aliases[E].concat(E).forEach(function(m){if(m.length>1&&/[A-Z]/.test(m)&&o["camel-case-expansion"]){let d=Tt(m,"-");if(d!==E&&h.aliases[E].indexOf(d)===-1)h.aliases[E].push(d),D[d]=!0}}),h.aliases[E].forEach(function(m){h.aliases[m]=[E].concat(h.aliases[E].filter(function(d){return m!==d}))})})})}function j(l,f){let E=[].concat(h.aliases[l]||[],l),m=Object.keys(f),d=E.find((A)=>m.includes(A));return d?f[d]:!1}function dt(l){let f=Object.keys(h);return[].concat(f.map((m)=>h[m])).some(function(m){return Array.isArray(m)?m.includes(l):m[l]})}function ur(l,...f){return[].concat(...f).some(function(m){let d=l.match(m);return d&&dt(d[1])})}function k(l){if(l.match(v)||!l.match(/^-[^-]+/))return!1;let f=!0,E,m=l.slice(1).split("");for(let d=0;d<m.length;d++){if(E=l.slice(d+2),!dt(m[d])){f=!1;break}if(m[d+1]&&m[d+1]==="="||E==="-"||/[A-Za-z]/.test(m[d])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(E)||m[d+1]&&m[d+1].match(/\W/))break}return f}function G(l){return o["unknown-options-as-args"]&&ie(l)}function ie(l){if(l=l.replace(/^-{3,}/,"--"),l.match(v))return!1;if(k(l))return!1;return!ur(l,/^-+([^=]+?)=[\s\S]*$/,W,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function L(l){if(!j(l,h.bools)&&!j(l,h.counts)&&`${l}`in u)return u[l];else return ue(Z(l))}function ue(l){return{[ye.BOOLEAN]:!0,[ye.STRING]:"",[ye.NUMBER]:void 0,[ye.ARRAY]:[]}[l]}function Z(l){let f=ye.BOOLEAN;if(j(l,h.strings))f=ye.STRING;else if(j(l,h.numbers))f=ye.NUMBER;else if(j(l,h.bools))f=ye.BOOLEAN;else if(j(l,h.arrays))f=ye.ARRAY;return f}function se(l){return l===void 0}function pn(){Object.keys(h.counts).find((l)=>{if(j(l,h.arrays))return T=Error(y("Invalid configuration: %s, opts.count excludes opts.array.",l)),!0;else if(j(l,h.nargs))return T=Error(y("Invalid configuration: %s, opts.count excludes opts.narg.",l)),!0;return!1})}return{aliases:Object.assign({},h.aliases),argv:Object.assign(Y,I),configuration:o,defaulted:Object.assign({},F),error:T,newAliases:Object.assign({},D)}}}function aa(e){let t=[],n=Object.create(null),r=!0;Object.keys(e).forEach(function(i){t.push([].concat(e[i],i))});while(r){r=!1;for(let i=0;i<t.length;i++)for(let s=i+1;s<t.length;s++)if(t[i].filter(function(u){return t[s].indexOf(u)!==-1}).length){t[i]=t[i].concat(t[s]),t.splice(s,1),r=!0;break}}return t.forEach(function(i){i=i.filter(function(o,u,c){return c.indexOf(o)===u});let s=i.pop();if(s!==void 0&&typeof s==="string")n[s]=i}),n}function xn(e){return e!==void 0?e+1:1}function Ir(e){if(e==="__proto__")return"___proto___";return e}function ua(e){return typeof e==="string"&&(e[0]==="'"||e[0]==='"')&&e[e.length-1]===e[0]?e.substring(1,e.length-1):e}import{readFileSync as fa}from"fs";import{createRequire as Tr}from"module";var An,Pn,_n,Lr=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Wr=(Pn=(An=process===null||process===void 0?void 0:process.versions)===null||An===void 0?void 0:An.node)!==null&&Pn!==void 0?Pn:(_n=process===null||process===void 0?void 0:process.version)===null||_n===void 0?void 0:_n.slice(1);if(Wr){if(Number(Wr.match(/^([^.]+)/)[1])<Lr)throw Error(`yargs parser supports a minimum Node.js version of ${Lr}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var ha=process?process.env:{},Hr=Tr?Tr(import.meta.url):void 0,Vr=new Sn({cwd:process.cwd,env:()=>ha,format:la,normalize:ca,resolve:da,require:(e)=>{if(typeof Hr<"u")return Hr(e);else if(e.match(/\.json$/))return JSON.parse(fa(e,"utf8"));else throw Error("only .json config files are supported in ESM")}}),xt=function(t,n){return Vr.parse(t.slice(),n).argv};xt.detailed=function(e,t){return Vr.parse(e.slice(),t)};xt.camelCase=Je;xt.decamelize=Tt;xt.looksLikeNumber=Lt;var zr=xt;import{basename as Ia,dirname as Ta,extname as La,relative as Wa,resolve as ni,join as Ha}from"path";function Da(){if(ga())return 0;return 1}function ga(){return pa()&&!process.defaultApp}function pa(){return!!process.versions.electron}function Gr(){return process.argv[Da()]}var ma=new Intl.Segmenter,Ur=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v,Fa=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v,ya=/\p{Spacing_Mark}/v,ba=/^\p{RGI_Emoji}$/v,Ea=/^[\d#*]\u20E3$/,Ca=/\p{Extended_Pictographic}/gu;function wa(e){if(e.length>50)return!1;if(Ea.test(e))return!0;if(e.includes("\u200D")){let t=e.match(Ca);return t!==null&&t.length>=2}return!1}function xa(e){return e.replace(Fa,"")}function Sa(e){return Ur.test(e)}function Yr(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function Jr(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function Kr(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function Aa(e){return Yr(e)||Jr(e)||Kr(e)}function Pa(e,t){let n=[];for(let i of e){if(Ur.test(i))continue;n.push(i.codePointAt(0))}if(n.length===0)return;let r=0;for(let i=0;i<n.length;i++){let s=n[i];if(!Aa(s)){if(r===0)return;for(let o=i;o<n.length;o++)r+=Ye(n[o],t);return r}if(Yr(s)&&Jr(n[i+1])){r+=2,i+=Kr(n[i+2])?2:1;continue}r+=Ye(s,t)}return r}function _a(e,t){let n=0,r=!0;for(let i of e){if(r){r=!1;continue}if(ya.test(i)||i>="\uFF00"&&i<="\uFFEF")n+=Ye(i.codePointAt(0),t)}return n}function Bn(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t,i=e;if(!r&&(i.includes("\x1B")||i.includes("\x9B")))i=je(i);if(i.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let s=0,o={ambiguousAsWide:!n};for(let{segment:u}of ma.segment(i)){if(Sa(u))continue;if(ba.test(u)||wa(u)){s+=2;continue}let c=xa(u),p=Pa(c,o);if(p!==void 0){s+=p;continue}let b=c.codePointAt(0);s+=Ye(b,o),s+=_a(c,o)}return s}import{readFileSync as Ba,statSync as Oa,writeFile as $a}from"fs";import{format as va}from"util";import{resolve as ja}from"path";var qr={fs:{readFileSync:Ba,writeFile:$a},format:va,resolve:ja,exists:(e)=>{try{return Oa(e).isFile()}catch(t){return!1}}};var xe;class Xr{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles==="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage==="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let t=e.shift(),n=function(){};if(typeof e[e.length-1]==="function")n=e.pop();if(n=n||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n});else n();return xe.format.apply(xe.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),r=e.shift(),i=function(){};if(typeof e[e.length-1]==="function")i=e.pop();if(!this.cache[this.locale])this._readLocaleFile();let s=r===1?t:n;if(this.cache[this.locale][t])s=this.cache[this.locale][t][r===1?"one":"other"];if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:i});else i();let o=[s];if(~s.indexOf("%d"))o.push(r);return xe.format.apply(xe.format,o.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){if(!this.cache[this.locale])this._readLocaleFile();for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))this.cache[this.locale][t]=e[t]}_taggedLiteral(e,...t){let n="";return e.forEach(function(r,i){let s=t[i+1];if(n+=r,typeof s<"u")n+="%s"}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){if(this.writeQueue.push(e),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let e=this,t=this.writeQueue[0],{directory:n,locale:r,cb:i}=t,s=this._resolveLocaleFile(n,r),o=JSON.stringify(this.cache[r],null,2);xe.fs.writeFile(s,o,"utf-8",function(u){if(e.writeQueue.shift(),e.writeQueue.length>0)e._processWriteQueue();i(u)})}_readLocaleFile(){let e={},t=this._resolveLocaleFile(this.directory,this.locale);try{if(xe.fs.readFileSync)e=JSON.parse(xe.fs.readFileSync(t,"utf-8"))}catch(n){if(n instanceof SyntaxError)n.message="syntax error in "+t;if(n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=xe.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let r=xe.resolve(e,"./",t.split("_")[0]+".json");if(this._fileExistsSync(r))n=r}return n}_fileExistsSync(e){return xe.exists(e)}}function Zr(e,t){xe=t;let n=new Xr(e);return{__:n.__.bind(n),__n:n.__n.bind(n),setLocale:n.setLocale.bind(n),getLocale:n.getLocale.bind(n),updateLocale:n.updateLocale.bind(n),locale:n.locale}}var ka=(e)=>Zr(e,qr),Qr=ka;var ii=No(ti(),1);import{createRequire as Va}from"module";import{readFileSync as za,readdirSync as Ga}from"fs";var On=ri(import.meta.url),Ua=On.substring(0,On.lastIndexOf("node_modules")),Ya=Va(import.meta.url),si={assert:{notStrictEqual:Ma,strictEqual:Na},cliui:Cn,findUp:wn,getEnv:(e)=>process.env[e],inspect:Ra,getProcessArgvBin:Gr,mainFilename:Ua||process.cwd(),Parser:zr,path:{basename:Ia,dirname:Ta,extname:La,relative:Wa,resolve:ni,join:Ha},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(e,t)=>process.emitWarning(e,t),execPath:()=>process.execPath,exit:(e)=>{process.exit(e)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:za,readdirSync:Ga,require:Ya,getCallerFile:()=>{let e=ii.default(3);return e.match(/^file:\/\//)?ri(e):e},stringWidth:Bn,y18n:Qr({directory:ni(On,"../../../locales"),updateFiles:!1})};function he(e,t,n,r){n.assert.notStrictEqual(e,t,r)}function $n(e,t){t.assert.strictEqual(typeof e,"string")}function ft(e){return Object.keys(e)}function J(e){return!!e&&!!e.then&&typeof e.then==="function"}class Q extends Error{constructor(e){super(e||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,Q)}}function Re(e){let n=e.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),r=/\.*[\][<>]/g,i=n.shift();if(!i)throw Error(`No command found in: ${e}`);let s={cmd:i.replace(r,""),demanded:[],optional:[]};return n.forEach((o,u)=>{let c=!1;if(o=o.replace(/\s/g,""),/\.+[\]>]/.test(o)&&u===n.length-1)c=!0;if(/^\[/.test(o))s.optional.push({cmd:o.replace(r,"").split("|"),variadic:c});else s.demanded.push({cmd:o.replace(r,"").split("|"),variadic:c})}),s}var Ja=["first","second","third","fourth","fifth","sixth"];function x(e,t,n){function r(){return typeof e==="object"?[{demanded:[],optional:[]},e,t]:[Re(`cmd ${e}`),t,n]}try{let i=0,[s,o,u]=r(),c=[].slice.call(o);while(c.length&&c[c.length-1]===void 0)c.pop();let p=u||c.length;if(p<s.demanded.length)throw new Q(`Not enough arguments provided. Expected ${s.demanded.length} but received ${c.length}.`);let b=s.demanded.length+s.optional.length;if(p>b)throw new Q(`Too many arguments provided. Expected max ${b} but received ${p}.`);s.demanded.forEach((g)=>{let D=c.shift(),F=oi(D);if(g.cmd.filter((h)=>h===F||h==="*").length===0)ai(F,g.cmd,i);i+=1}),s.optional.forEach((g)=>{if(c.length===0)return;let D=c.shift(),F=oi(D);if(g.cmd.filter((h)=>h===F||h==="*").length===0)ai(F,g.cmd,i);i+=1})}catch(i){console.warn(i.stack)}}function oi(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function ai(e,t,n){throw new Q(`Invalid ${Ja[n]||"manyith"} argument. Expected ${t.join(" or ")} but received ${e}.`)}class vn{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,r=!1){if(x("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let i=0;i<e.length;i++){if(typeof e[i]!=="function")throw Error("middleware must be a function");let s=e[i];s.applyBeforeValidation=t,s.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e==="function"){let i=e;i.applyBeforeValidation=t,i.global=n,i.mutates=r,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((r)=>{let i=[...n[t]||[],t];if(!r.option)return!0;else return!i.includes(r.option)}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();if(e!==void 0)this.globalMiddleware=e}reset(){this.globalMiddleware=this.globalMiddleware.filter((e)=>e.global)}}function ui(e){if(!e)return[];return e.map((t)=>(t.applyBeforeValidation=!1,t))}function Ke(e,t,n,r){return n.reduce((i,s)=>{if(s.applyBeforeValidation!==r)return i;if(s.mutates){if(s.applied)return i;s.applied=!0}if(J(i))return i.then((o)=>Promise.all([o,s(o,t)])).then(([o,u])=>Object.assign(o,u));else{let o=s(i,t);return J(o)?o.then((u)=>Object.assign(i,u)):Object.assign(i,o)}},e)}function qe(e,t,n=(r)=>{throw r}){try{let r=Ka(e)?e():e;return J(r)?r.then((i)=>t(i)):t(r)}catch(r){return n(r)}}function Ka(e){return typeof e==="function"}var ht=/(^\*)|(^\$0)/;class ci{constructor(e,t,n,r){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=r,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,r){r=r||{},this.requireCache.add(n);let i=this.shim.path.resolve(this.shim.path.dirname(n),e),s=this.shim.readdirSync(i,{recursive:r.recurse?!0:!1});if(!Array.isArray(r.extensions))r.extensions=["js"];let o=typeof r.visit==="function"?r.visit:(u)=>u;for(let u of s){let c=u.toString();if(r.exclude){let b=!1;if(typeof r.exclude==="function")b=r.exclude(c);else b=r.exclude.test(c);if(b)continue}if(r.include){let b=!1;if(typeof r.include==="function")b=r.include(c);else b=r.include.test(c);if(!b)continue}let p=!1;for(let b of r.extensions)if(c.endsWith(b))p=!0;if(p){let b=this.shim.path.join(i,c),g=t(b),D=Object.create(null,Object.getOwnPropertyDescriptors({...g}));if(o(D,b,c)){if(this.requireCache.has(b))continue;else this.requireCache.add(b);if(!D.command)D.command=this.shim.path.basename(b,this.shim.path.extname(b));this.addHandler(D)}}}}addHandler(e,t,n,r,i,s){let o=[],u=ui(i);if(r=r||(()=>{}),Array.isArray(e))if(qa(e))[e,...o]=e;else for(let c of e)this.addHandler(c);else if(Za(e)){let c=Array.isArray(e.command)||typeof e.command==="string"?e.command:null;if(c===null)throw Error(`No command name given for module: ${this.shim.inspect(e)}`);if(e.aliases)c=[].concat(c).concat(e.aliases);this.addHandler(c,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(li(n)){this.addHandler([e].concat(o),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e==="string"){let c=Re(e);o=o.map((g)=>Re(g).cmd);let p=!1,b=[c.cmd].concat(o).filter((g)=>{if(ht.test(g))return p=!0,!1;return!0});if(b.length===0&&p)b.push("$0");if(p)c.cmd=b[0],o=b.slice(1),e=e.replace(ht,c.cmd);if(o.forEach((g)=>{this.aliasMap[g]=c.cmd}),t!==!1)this.usage.command(e,t,p,o,s);if(this.handlers[c.cmd]={original:e,description:t,handler:r,builder:n||{},middlewares:u,deprecated:s,demanded:c.demanded,optional:c.optional},p)this.defaultCommand=this.handlers[c.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,r,i,s){let o=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,u=t.getInternalMethods().getContext(),c=u.commands.slice(),p=!e;if(e)u.commands.push(e),u.fullCommands.push(o.original);let b=this.applyBuilderUpdateUsageAndParse(p,o,t,n.aliases,c,r,i,s);return J(b)?b.then((g)=>this.applyMiddlewareAndGetResult(p,o,g.innerArgv,u,i,g.aliases,t)):this.applyMiddlewareAndGetResult(p,o,b.innerArgv,u,i,b.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,r,i,s,o,u){let c=t.builder,p=n;if(Wt(c)){n.getInternalMethods().getUsageInstance().freeze();let b=c(n.getInternalMethods().reset(r),u);if(J(b))return b.then((g)=>(p=fi(g)?g:n,this.parseAndUpdateUsage(e,t,p,i,s,o)))}else if(Xa(c))n.getInternalMethods().getUsageInstance().freeze(),p=n.getInternalMethods().reset(r),Object.keys(t.builder).forEach((b)=>{p.option(b,c[b])});return this.parseAndUpdateUsage(e,t,p,i,s,o)}parseAndUpdateUsage(e,t,n,r,i,s){if(e)n.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(n))n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(r,t),t.description);let o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,s);return J(o)?o.then((u)=>({aliases:n.parsed.aliases,innerArgv:u})):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=ht.test(t.original)?t.original.replace(ht,"").trim():t.original,r=e.filter((i)=>!ht.test(i));return r.push(n),`$0 ${r.join(" ")}`}handleValidationAndGetResult(e,t,n,r,i,s,o,u){if(!s.getInternalMethods().getHasOutput()){let c=s.getInternalMethods().runValidation(i,u,s.parsed.error,e);n=qe(n,(p)=>(c(p),p))}if(t.handler&&!s.getInternalMethods().getHasOutput()){s.getInternalMethods().setHasOutput();let c=!!s.getOptions().configuration["populate--"];if(s.getInternalMethods().postProcess(n,c,!1,!1),n=Ke(n,s,o,!1),n=qe(n,(p)=>{let b=t.handler(p);return J(b)?b.then(()=>p):p}),!e)s.getInternalMethods().getUsageInstance().cacheHelpMessage();if(J(n)&&!s.getInternalMethods().hasParseCallback())n.catch((p)=>{try{s.getInternalMethods().getUsageInstance().fail(null,p)}catch(b){}})}if(!e)r.commands.pop(),r.fullCommands.pop();return n}applyMiddlewareAndGetResult(e,t,n,r,i,s,o){let u={};if(i)return n;if(!o.getInternalMethods().getHasOutput())u=this.populatePositionals(t,n,r,o);let c=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),p=Ke(n,o,c,!0);return J(p)?p.then((b)=>this.handleValidationAndGetResult(e,t,b,r,s,o,c,u)):this.handleValidationAndGetResult(e,t,p,r,s,o,c,u)}populatePositionals(e,t,n,r){t._=t._.slice(n.commands.length);let i=e.demanded.slice(0),s=e.optional.slice(0),o={};this.validation.positionalCount(i.length,t._.length);while(i.length){let u=i.shift();this.populatePositional(u,t,o)}while(s.length){let u=s.shift();this.populatePositional(u,t,o)}return t._=n.commands.concat(t._.map((u)=>""+u)),this.postProcessPositionals(t,o,this.cmdToParseOptions(e.original),r),o}populatePositional(e,t,n){let r=e.cmd[0];if(e.variadic)n[r]=t._.splice(0).map(String);else if(t._.length)n[r]=[String(t._.shift())]}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=Re(e);return n.demanded.forEach((r)=>{let[i,...s]=r.cmd;if(r.variadic)t.array.push(i),t.default[i]=[];t.alias[i]=s,t.demand[i]=!0}),n.optional.forEach((r)=>{let[i,...s]=r.cmd;if(r.variadic)t.array.push(i),t.default[i]=[];t.alias[i]=s}),t}postProcessPositionals(e,t,n,r){let i=Object.assign({},r.getOptions());i.default=Object.assign(n.default,i.default);for(let c of Object.keys(n.alias))i.alias[c]=(i.alias[c]||[]).concat(n.alias[c]);i.array=i.array.concat(n.array),i.config={};let s=[];if(Object.keys(t).forEach((c)=>{t[c].map((p)=>{if(i.configuration["unknown-options-as-args"])i.key[c]=!0;s.push(`--${c}`),s.push(p)})}),!s.length)return;let o=Object.assign({},i.configuration,{"populate--":!1}),u=this.shim.Parser.detailed(s,Object.assign({},i,{configuration:o}));if(u.error)r.getInternalMethods().getUsageInstance().fail(u.error.message,u.error);else{let c=Object.keys(t);Object.keys(t).forEach((p)=>{c.push(...u.aliases[p])}),Object.keys(u.argv).forEach((p)=>{if(c.includes(p)){if(!t[p])t[p]=u.argv[p];if(!this.isInConfigs(r,p)&&!this.isDefaulted(r,p)&&Object.prototype.hasOwnProperty.call(e,p)&&Object.prototype.hasOwnProperty.call(u.argv,p)&&(Array.isArray(e[p])||Array.isArray(u.argv[p])))e[p]=[].concat(e[p],u.argv[p]);else e[p]=u.argv[p]}})}}isDefaulted(e,t){let{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){let{configObjects:n}=e.getOptions();return n.some((r)=>Object.prototype.hasOwnProperty.call(r,t))||n.some((r)=>Object.prototype.hasOwnProperty.call(r,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=ht.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let t=this.defaultCommand.builder;if(Wt(t))return t(e,!0);else if(!li(t))Object.keys(t).forEach((n)=>{e.option(n,t[n])});return}extractDesc({describe:e,description:t,desc:n}){for(let r of[e,t,n]){if(typeof r==="string"||r===!1)return r;he(r,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();he(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function di(e,t,n,r){return new ci(e,t,n,r)}function li(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function qa(e){return e.every((t)=>typeof t==="string")}function Wt(e){return typeof e==="function"}function Xa(e){return typeof e==="object"}function Za(e){return typeof e==="object"&&!Array.isArray(e)}function Ie(e={},t=()=>!0){let n={};return ft(e).forEach((r)=>{if(t(r,e[r]))n[r]=e[r]}),n}function Te(e){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((t)=>{let n=t;if(n._handle&&n.isTTY&&typeof n._handle.setBlocking==="function")n._handle.setBlocking(e)})}function Qa(e){return typeof e==="boolean"}function Di(e,t){let n=t.y18n.__,r={},i=[];r.failFn=function(C){i.push(C)};let s=null,o=null,u=!0;r.showHelpOnFail=function(C=!0,_){let[N,V]=typeof C==="string"?[!0,C]:[C,_];if(e.getInternalMethods().isGlobalContext())o=V;return s=V,u=N,r};let c=!1;r.fail=function(C,_){let N=e.getInternalMethods().getLoggerInstance();if(i.length)for(let V=i.length-1;V>=0;--V){let te=i[V];if(Qa(te)){if(_)throw _;else if(C)throw Error(C)}else te(C,_,r)}else{if(e.getExitProcess())Te(!0);if(!c){if(c=!0,u)e.showHelp("error"),N.error();if(C||_)N.error(C||_);let V=s||o;if(V){if(C||_)N.error("");N.error(V)}}if(_=_||new Q(C),e.getExitProcess())return e.exit(1);else if(e.getInternalMethods().hasParseCallback())return e.exit(1,_);else throw _}};let p=[],b=!1;r.usage=(P,C)=>{if(P===null)return b=!0,p=[],r;return b=!1,p.push([P,C||""]),r},r.getUsage=()=>p,r.getUsageDisabled=()=>b,r.getPositionalGroupName=()=>n("Positionals:");let g=[];r.example=(P,C)=>{g.push([P,C||""])};let D=[];r.command=function(C,_,N,V,te=!1){if(N)D=D.map((H)=>(H[2]=!1,H));D.push([C,_||"",N,V,te])},r.getCommands=()=>D;let F={};r.describe=function(C,_){if(Array.isArray(C))C.forEach((N)=>{r.describe(N,_)});else if(typeof C==="object")Object.keys(C).forEach((N)=>{r.describe(N,C[N])});else F[C]=_},r.getDescriptions=()=>F;let y=[];r.epilog=(P)=>{y.push(P)};let h=!1,v;r.wrap=(P)=>{h=!0,v=P},r.getWrap=()=>{if(t.getEnv("YARGS_DISABLE_WRAP"))return null;if(!h)v=Pe(),h=!0;return v};let W="__yargsString__:";r.deferY18nLookup=(P)=>W+P,r.help=function(){if(I)return I;ce();let C=e.customScriptName?e.$0:t.path.basename(e.$0),_=e.getDemandedOptions(),N=e.getDemandedCommands(),V=e.getDeprecatedOptions(),te=e.getGroups(),H=e.getOptions(),re=[];re=re.concat(Object.keys(F)),re=re.concat(Object.keys(_)),re=re.concat(Object.keys(N)),re=re.concat(Object.keys(H.default)),re=re.filter(ne),re=Object.keys(re.reduce((k,G)=>{if(G!=="_")k[G]=!0;return k},{}));let Ne=r.getWrap(),U=t.cliui({width:Ne,wrap:!!Ne});if(!b){if(p.length)p.forEach((k)=>{if(U.div({text:`${k[0].replace(/\$0/g,C)}`}),k[1])U.div({text:`${k[1]}`,padding:[1,0,0,0]})}),U.div();else if(D.length){let k=null;if(N._)k=`${C} <${n("command")}>
15
15
  `;else k=`${C} [${n("command")}]
16
- `;U.div(`${k}`)}}if(p.length>1||p.length===1&&!p[0][2]){U.div(n("Commands:"));let k=e.getInternalMethods().getContext(),z=k.commands.length?`${k.commands.join(" ")} `:"";if(e.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)p=p.sort((W,ae)=>W[0].localeCompare(ae[0]));let re=C?`${C} `:"";p.forEach((W)=>{let ae=`${re}${z}${W[0].replace(/^\$0 ?/,"")}`;U.span({text:ae,padding:[0,2,0,2],width:T(p,ke,`${C}${z}`)+4},{text:W[1]});let Z=[];if(W[2])Z.push(`[${n("default")}]`);if(W[3]&&W[3].length)Z.push(`[${n("aliases:")} ${W[3].join(", ")}]`);if(W[4])if(typeof W[4]==="string")Z.push(`[${n("deprecated: %s",W[4])}]`);else Z.push(`[${n("deprecated")}]`);if(Z.length)U.div({text:Z.join(" "),padding:[0,0,0,2],align:"right"});else U.div()}),U.div()}let Pe=(Object.keys(G.alias)||[]).concat(Object.keys(e.parsed.newAliases)||[]);ie=ie.filter((k)=>!e.parsed.newAliases[k]&&Pe.every((z)=>(G.alias[z]||[]).indexOf(k)===-1));let gt=n("Options:");if(!te[gt])te[gt]=[];Y(ie,G.alias,te,gt);let v=(k)=>/^--/.test(Mt(k)),ot=Object.keys(te).filter((k)=>te[k].length>0).map((k)=>{let z=te[k].filter(ne).map((re)=>{if(Pe.includes(re))return re;for(let W=0,ae;(ae=Pe[W])!==void 0;W++)if((G.alias[ae]||[]).includes(re))return ae;return re});return{groupName:k,normalizedKeys:z}}).filter(({normalizedKeys:k})=>k.length>0).map(({groupName:k,normalizedKeys:z})=>{let re=z.reduce((W,ae)=>(W[ae]=[ae].concat(G.alias[ae]||[]).map((Z)=>{if(k===i.getPositionalGroupName())return Z;else return(/^[0-9]$/.test(Z)?G.boolean.includes(ae)?"-":"--":Z.length>1?"--":"-")+Z}).sort((Z,se)=>v(Z)===v(se)?0:v(Z)?1:-1).join(", "),W),{});return{groupName:k,normalizedKeys:z,switches:re}});if(ot.filter(({groupName:k})=>k!==i.getPositionalGroupName()).some(({normalizedKeys:k,switches:z})=>!k.every((re)=>v(z[re]))))ot.filter(({groupName:k})=>k!==i.getPositionalGroupName()).forEach(({normalizedKeys:k,switches:z})=>{k.forEach((re)=>{if(v(z[re]))z[re]=cu(z[re],4)})});if(ot.forEach(({groupName:k,normalizedKeys:z,switches:re})=>{U.div(k),z.forEach((W)=>{let ae=re[W],Z=m[W]||"",se=null;if(Z.includes(L))Z=n(Z.substring(L.length));if(G.boolean.includes(W))se=`[${n("boolean")}]`;if(G.count.includes(W))se=`[${n("count")}]`;if(G.string.includes(W))se=`[${n("string")}]`;if(G.normalize.includes(W))se=`[${n("string")}]`;if(G.array.includes(W))se=`[${n("array")}]`;if(G.number.includes(W))se=`[${n("number")}]`;let en=(y)=>typeof y==="string"?`[${n("deprecated: %s",y)}]`:`[${n("deprecated")}]`,l=[W in V?en(V[W]):null,se,W in B?`[${n("required")}]`:null,G.choices&&G.choices[W]?`[${n("choices:")} ${i.stringifiedValues(G.choices[W])}]`:null,X(G.default[W],G.defaultDescription[W])].filter(Boolean).join(" ");U.span({text:Mt(ae),padding:[0,2,0,2+Ui(ae)],width:T(re,ke)+4},Z);let d=e.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(l&&!d)U.div({text:l,padding:[0,0,0,2],align:"right"});else U.div()}),U.div()}),h.length)U.div(n("Examples:")),h.forEach((k)=>{k[0]=k[0].replace(/\$0/g,C)}),h.forEach((k)=>{if(k[1]==="")U.div({text:k[0],padding:[0,2,0,2]});else U.div({text:k[0],padding:[0,2,0,2],width:T(h,ke)+4},{text:k[1]})}),U.div();if(b.length>0){let k=b.map((z)=>z.replace(/\$0/g,C)).join(`
16
+ `;U.div(`${k}`)}}if(D.length>1||D.length===1&&!D[0][2]){U.div(n("Commands:"));let k=e.getInternalMethods().getContext(),G=k.commands.length?`${k.commands.join(" ")} `:"";if(e.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)D=D.sort((L,ue)=>L[0].localeCompare(ue[0]));let ie=C?`${C} `:"";D.forEach((L)=>{let ue=`${ie}${G}${L[0].replace(/^\$0 ?/,"")}`;U.span({text:ue,padding:[0,2,0,2],width:T(D,Ne,`${C}${G}`)+4},{text:L[1]});let Z=[];if(L[2])Z.push(`[${n("default")}]`);if(L[3]&&L[3].length)Z.push(`[${n("aliases:")} ${L[3].join(", ")}]`);if(L[4])if(typeof L[4]==="string")Z.push(`[${n("deprecated: %s",L[4])}]`);else Z.push(`[${n("deprecated")}]`);if(Z.length)U.div({text:Z.join(" "),padding:[0,0,0,2],align:"right"});else U.div()}),U.div()}let ve=(Object.keys(H.alias)||[]).concat(Object.keys(e.parsed.newAliases)||[]);re=re.filter((k)=>!e.parsed.newAliases[k]&&ve.every((G)=>(H.alias[G]||[]).indexOf(k)===-1));let wt=n("Options:");if(!te[wt])te[wt]=[];Y(re,H.alias,te,wt);let j=(k)=>/^--/.test(Ht(k)),dt=Object.keys(te).filter((k)=>te[k].length>0).map((k)=>{let G=te[k].filter(ne).map((ie)=>{if(ve.includes(ie))return ie;for(let L=0,ue;(ue=ve[L])!==void 0;L++)if((H.alias[ue]||[]).includes(ie))return ue;return ie});return{groupName:k,normalizedKeys:G}}).filter(({normalizedKeys:k})=>k.length>0).map(({groupName:k,normalizedKeys:G})=>{let ie=G.reduce((L,ue)=>(L[ue]=[ue].concat(H.alias[ue]||[]).map((Z)=>{if(k===r.getPositionalGroupName())return Z;else return(/^[0-9]$/.test(Z)?H.boolean.includes(ue)?"-":"--":Z.length>1?"--":"-")+Z}).sort((Z,se)=>j(Z)===j(se)?0:j(Z)?1:-1).join(", "),L),{});return{groupName:k,normalizedKeys:G,switches:ie}});if(dt.filter(({groupName:k})=>k!==r.getPositionalGroupName()).some(({normalizedKeys:k,switches:G})=>!k.every((ie)=>j(G[ie]))))dt.filter(({groupName:k})=>k!==r.getPositionalGroupName()).forEach(({normalizedKeys:k,switches:G})=>{k.forEach((ie)=>{if(j(G[ie]))G[ie]=eu(G[ie],4)})});if(dt.forEach(({groupName:k,normalizedKeys:G,switches:ie})=>{U.div(k),G.forEach((L)=>{let ue=ie[L],Z=F[L]||"",se=null;if(Z.includes(W))Z=n(Z.substring(W.length));if(H.boolean.includes(L))se=`[${n("boolean")}]`;if(H.count.includes(L))se=`[${n("count")}]`;if(H.string.includes(L))se=`[${n("string")}]`;if(H.normalize.includes(L))se=`[${n("string")}]`;if(H.array.includes(L))se=`[${n("array")}]`;if(H.number.includes(L))se=`[${n("number")}]`;let pn=(E)=>typeof E==="string"?`[${n("deprecated: %s",E)}]`:`[${n("deprecated")}]`,l=[L in V?pn(V[L]):null,se,L in _?`[${n("required")}]`:null,H.choices&&H.choices[L]?`[${n("choices:")} ${r.stringifiedValues(H.choices[L])}]`:null,X(H.default[L],H.defaultDescription[L])].filter(Boolean).join(" ");U.span({text:Ht(ue),padding:[0,2,0,2+hi(ue)],width:T(ie,Ne)+4},Z);let f=e.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(l&&!f)U.div({text:l,padding:[0,0,0,2],align:"right"});else U.div()}),U.div()}),g.length)U.div(n("Examples:")),g.forEach((k)=>{k[0]=k[0].replace(/\$0/g,C)}),g.forEach((k)=>{if(k[1]==="")U.div({text:k[0],padding:[0,2,0,2]});else U.div({text:k[0],padding:[0,2,0,2],width:T(g,Ne)+4},{text:k[1]})}),U.div();if(y.length>0){let k=y.map((G)=>G.replace(/\$0/g,C)).join(`
17
17
  `);U.div(`${k}
18
- `)}return U.toString().replace(/\s*$/,"")};function T(S,C,B){let N=0;if(!Array.isArray(S))S=Object.values(S).map((V)=>[V]);if(S.forEach((V)=>{N=Math.max(t.stringWidth(B?`${B} ${Mt(V[0])}`:Mt(V[0]))+Ui(V[0]),N)}),C)N=Math.min(N,parseInt((C*0.5).toString(),10));return N}function ce(){let S=e.getDemandedOptions(),C=e.getOptions();(Object.keys(C.alias)||[]).forEach((B)=>{C.alias[B].forEach((N)=>{if(m[N])i.describe(B,m[N]);if(N in S)e.demandOption(B,S[N]);if(C.boolean.includes(N))e.boolean(B);if(C.count.includes(N))e.count(B);if(C.string.includes(N))e.string(B);if(C.normalize.includes(N))e.normalize(B);if(C.array.includes(N))e.array(B);if(C.number.includes(N))e.number(B)})})}let R;i.cacheHelpMessage=function(){R=this.help()},i.clearCachedHelpMessage=function(){R=void 0},i.hasCachedHelpMessage=function(){return!!R};function Y(S,C,B,N){let V=[],te=null;return Object.keys(B).forEach((G)=>{V=V.concat(B[G])}),S.forEach((G)=>{if(te=[G].concat(C[G]),!te.some((ie)=>V.indexOf(ie)!==-1))B[N].push(G)}),V}function ne(S){return e.getOptions().hiddenOptions.indexOf(S)<0||e.parsed.argv[e.getOptions().showHiddenOpt]}i.showHelp=(S)=>{let C=e.getInternalMethods().getLoggerInstance();if(!S)S="error";(typeof S==="function"?S:C[S])(i.help())},i.functionDescription=(S)=>["(",S.name?t.Parser.decamelize(S.name,"-"):n("generated-value"),")"].join(""),i.stringifiedValues=function(C,B){let N="",V=B||", ",te=[].concat(C);if(!C||!te.length)return N;return te.forEach((G)=>{if(N.length)N+=V;N+=JSON.stringify(G)}),N};function X(S,C){let B=`[${n("default:")} `;if(S===void 0&&!C)return null;if(C)B+=C;else switch(typeof S){case"string":B+=`"${S}"`;break;case"object":B+=JSON.stringify(S);break;default:B+=S}return`${B}]`}function Ae(){if(t.process.stdColumns)return Math.min(80,t.process.stdColumns);else return 80}let H=null;i.version=(S)=>{H=S},i.showVersion=(S)=>{let C=e.getInternalMethods().getLoggerInstance();if(!S)S="error";(typeof S==="function"?S:C[S])(H)},i.reset=function(C){return s=null,c=!1,g=[],E=!1,b=[],h=[],p=[],m=Ne(m,(B)=>!C[B]),i};let pt=[];return i.freeze=function(){pt.push({failMessage:s,failureOutput:c,usages:g,usageDisabled:E,epilogs:b,examples:h,commands:p,descriptions:m})},i.unfreeze=function(C=!1){let B=pt.pop();if(!B)return;if(C)m={...B.descriptions,...m},p=[...B.commands,...p],g=[...B.usages,...g],h=[...B.examples,...h],b=[...B.epilogs,...b];else({failMessage:s,failureOutput:c,usages:g,usageDisabled:E,epilogs:b,examples:h,commands:p,descriptions:m}=B)},i}function Fn(e){return typeof e==="object"}function cu(e,t){return Fn(e)?{text:e.text,indentation:e.indentation+t}:{text:e,indentation:t}}function Ui(e){return Fn(e)?e.indentation:0}function Mt(e){return Fn(e)?e.text:e}var Ji=`###-begin-{{app_name}}-completions-###
18
+ `)}return U.toString().replace(/\s*$/,"")};function T(P,C,_){let N=0;if(!Array.isArray(P))P=Object.values(P).map((V)=>[V]);if(P.forEach((V)=>{N=Math.max(t.stringWidth(_?`${_} ${Ht(V[0])}`:Ht(V[0]))+hi(V[0]),N)}),C)N=Math.min(N,parseInt((C*0.5).toString(),10));return N}function ce(){let P=e.getDemandedOptions(),C=e.getOptions();(Object.keys(C.alias)||[]).forEach((_)=>{C.alias[_].forEach((N)=>{if(F[N])r.describe(_,F[N]);if(N in P)e.demandOption(_,P[N]);if(C.boolean.includes(N))e.boolean(_);if(C.count.includes(N))e.count(_);if(C.string.includes(N))e.string(_);if(C.normalize.includes(N))e.normalize(_);if(C.array.includes(N))e.array(_);if(C.number.includes(N))e.number(_)})})}let I;r.cacheHelpMessage=function(){I=this.help()},r.clearCachedHelpMessage=function(){I=void 0},r.hasCachedHelpMessage=function(){return!!I};function Y(P,C,_,N){let V=[],te=null;return Object.keys(_).forEach((H)=>{V=V.concat(_[H])}),P.forEach((H)=>{if(te=[H].concat(C[H]),!te.some((re)=>V.indexOf(re)!==-1))_[N].push(H)}),V}function ne(P){return e.getOptions().hiddenOptions.indexOf(P)<0||e.parsed.argv[e.getOptions().showHiddenOpt]}r.showHelp=(P)=>{let C=e.getInternalMethods().getLoggerInstance();if(!P)P="error";(typeof P==="function"?P:C[P])(r.help())},r.functionDescription=(P)=>["(",P.name?t.Parser.decamelize(P.name,"-"):n("generated-value"),")"].join(""),r.stringifiedValues=function(C,_){let N="",V=_||", ",te=[].concat(C);if(!C||!te.length)return N;return te.forEach((H)=>{if(N.length)N+=V;N+=JSON.stringify(H)}),N};function X(P,C){let _=`[${n("default:")} `;if(P===void 0&&!C)return null;if(C)_+=C;else switch(typeof P){case"string":_+=`"${P}"`;break;case"object":_+=JSON.stringify(P);break;default:_+=P}return`${_}]`}function Pe(){if(t.process.stdColumns)return Math.min(80,t.process.stdColumns);else return 80}let z=null;r.version=(P)=>{z=P},r.showVersion=(P)=>{let C=e.getInternalMethods().getLoggerInstance();if(!P)P="error";(typeof P==="function"?P:C[P])(z)},r.reset=function(C){return s=null,c=!1,p=[],b=!1,y=[],g=[],D=[],F=Ie(F,(_)=>!C[_]),r};let Ct=[];return r.freeze=function(){Ct.push({failMessage:s,failureOutput:c,usages:p,usageDisabled:b,epilogs:y,examples:g,commands:D,descriptions:F})},r.unfreeze=function(C=!1){let _=Ct.pop();if(!_)return;if(C)F={..._.descriptions,...F},D=[..._.commands,...D],p=[..._.usages,...p],g=[..._.examples,...g],y=[..._.epilogs,...y];else({failMessage:s,failureOutput:c,usages:p,usageDisabled:b,epilogs:y,examples:g,commands:D,descriptions:F}=_)},r}function jn(e){return typeof e==="object"}function eu(e,t){return jn(e)?{text:e.text,indentation:e.indentation+t}:{text:e,indentation:t}}function hi(e){return jn(e)?e.indentation:0}function Ht(e){return jn(e)?e.text:e}var gi=`###-begin-{{app_name}}-completions-###
19
19
  #
20
20
  # yargs command completion script
21
21
  #
@@ -44,7 +44,7 @@ _{{app_name}}_yargs_completions()
44
44
  }
45
45
  complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
46
46
  ###-end-{{app_name}}-completions-###
47
- `,Ki=`#compdef {{app_name}}
47
+ `,pi=`#compdef {{app_name}}
48
48
  ###-begin-{{app_name}}-completions-###
49
49
  #
50
50
  # yargs command completion script
@@ -71,14 +71,14 @@ else
71
71
  compdef _{{app_name}}_yargs_completions {{app_name}}
72
72
  fi
73
73
  ###-end-{{app_name}}-completions-###
74
- `;class qi{constructor(e,t,n,i){var r,s,o;this.yargs=e,this.usage=t,this.command=n,this.shim=i,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(o=((r=this.shim.getEnv("SHELL"))===null||r===void 0?void 0:r.includes("zsh"))||((s=this.shim.getEnv("ZSH_NAME"))===null||s===void 0?void 0:s.includes("zsh")))!==null&&o!==void 0?o:!1}defaultCompletion(e,t,n,i){let r=this.command.getCommandHandlers();for(let o=0,a=e.length;o<a;++o)if(r[e[o]]&&r[e[o]].builder){let c=r[e[o]].builder;if(kt(c)){this.indexAfterLastReset=o+1;let g=this.yargs.getInternalMethods().reset();return c(g,!0),g.argv}}let s=[];this.commandCompletions(s,e,n),this.optionCompletions(s,e,t,n),this.choicesFromOptionsCompletions(s,e,t,n),this.choicesFromPositionalsCompletions(s,e,t,n),i(null,s)}commandCompletions(e,t,n){let i=this.yargs.getInternalMethods().getContext().commands;if(!n.match(/^-/)&&i[i.length-1]!==n&&!this.previousArgHasChoices(t))this.usage.getCommands().forEach((r)=>{let s=Me(r[0]).cmd;if(t.indexOf(s)===-1)if(!this.zshShell)e.push(s);else{let o=r[1]||"";e.push(s.replace(/:/g,"\\:")+":"+o)}})}optionCompletions(e,t,n,i){if((i.match(/^-/)||i===""&&e.length===0)&&!this.previousArgHasChoices(t)){let r=this.yargs.getOptions(),s=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(r.key).forEach((o)=>{let a=!!r.configuration["boolean-negation"]&&r.boolean.includes(o);if(!s.includes(o)&&!r.hiddenOptions.includes(o)&&!this.argsContainKey(t,o,a))this.completeOptionKey(o,e,i,a&&!!r.default[o])})}}choicesFromOptionsCompletions(e,t,n,i){if(this.previousArgHasChoices(t)){let r=this.getPreviousArgChoices(t);if(r&&r.length>0)e.push(...r.map((s)=>s.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,t,n,i){if(i===""&&e.length>0&&this.previousArgHasChoices(t))return;let r=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],s=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=r[n._.length-s-1];if(!o)return;let a=this.yargs.getOptions().choices[o]||[];for(let c of a)if(c.startsWith(i))e.push(c.replace(/:/g,"\\:"))}getPreviousArgChoices(e){if(e.length<1)return;let t=e[e.length-1],n="";if(!t.startsWith("-")&&e.length>1)n=t,t=e[e.length-2];if(!t.startsWith("-"))return;let i=t.replace(/^-+/,""),r=this.yargs.getOptions(),s=[i,...this.yargs.getAliases()[i]||[]],o;for(let a of s)if(Object.prototype.hasOwnProperty.call(r.key,a)&&Array.isArray(r.choices[a])){o=r.choices[a];break}if(o)return o.filter((a)=>!n||a.startsWith(n))}previousArgHasChoices(e){let t=this.getPreviousArgChoices(e);return t!==void 0&&t.length>0}argsContainKey(e,t,n){let i=(r)=>e.indexOf((/^[^0-9]$/.test(r)?"-":"--")+r)!==-1;if(i(t))return!0;if(n&&i(`no-${t}`))return!0;if(this.aliases){for(let r of this.aliases[t])if(i(r))return!0}return!1}completeOptionKey(e,t,n,i){var r,s,o,a;let c=e;if(this.zshShell){let p=this.usage.getDescriptions(),m=(s=(r=this===null||this===void 0?void 0:this.aliases)===null||r===void 0?void 0:r[e])===null||s===void 0?void 0:s.find((j)=>{let L=p[j];return typeof L==="string"&&L.length>0}),b=m?p[m]:void 0,D=(a=(o=p[e])!==null&&o!==void 0?o:b)!==null&&a!==void 0?a:"";c=`${e.replace(/:/g,"\\:")}:${D.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let g=(p)=>/^--/.test(p),E=(p)=>/^[^0-9]$/.test(p),h=!g(n)&&E(e)?"-":"--";if(t.push(h+c),i)t.push(h+"no-"+c)}customCompletion(e,t,n,i){if(De(this.customCompletionFunction,null,this.shim),du(this.customCompletionFunction)){let r=this.customCompletionFunction(n,t);if(J(r))return r.then((s)=>{this.shim.process.nextTick(()=>{i(null,s)})}).catch((s)=>{this.shim.process.nextTick(()=>{i(s,void 0)})});return i(null,r)}else if(Du(this.customCompletionFunction))return this.customCompletionFunction(n,t,(r=i)=>this.defaultCompletion(e,t,n,r),(r)=>{i(null,r)});else return this.customCompletionFunction(n,t,(r)=>{i(null,r)})}getCompletion(e,t){let n=e.length?e[e.length-1]:"",i=this.yargs.parse(e,!0),r=this.customCompletionFunction?(s)=>this.customCompletion(e,s,n,t):(s)=>this.defaultCompletion(e,s,n,t);return J(i)?i.then(r):r(i)}generateCompletionScript(e,t){let n=this.zshShell?Ki:Ji,i=this.shim.path.basename(e);if(e.match(/\.js$/))e=`./${e}`;return n=n.replace(/{{app_name}}/g,i),n=n.replace(/{{completion_command}}/g,t),n.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}}function Xi(e,t,n,i){return new qi(e,t,n,i)}function du(e){return e.length<3}function Du(e){return e.length>3}function Zi(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let n=[],i;for(i=0;i<=t.length;i++)n[i]=[i];let r;for(r=0;r<=e.length;r++)n[0][r]=r;for(i=1;i<=t.length;i++)for(r=1;r<=e.length;r++)if(t.charAt(i-1)===e.charAt(r-1))n[i][r]=n[i-1][r-1];else if(i>1&&r>1&&t.charAt(i-2)===e.charAt(r-1)&&t.charAt(i-1)===e.charAt(r-2))n[i][r]=n[i-2][r-2]+1;else n[i][r]=Math.min(n[i-1][r-1]+1,Math.min(n[i][r-1]+1,n[i-1][r]+1));return n[t.length][e.length]}var Qi=["$0","--","_"];function er(e,t,n){let i=n.y18n.__,r=n.y18n.__n,s={};s.nonOptionCount=function(h){let p=e.getDemandedCommands(),b=h._.length+(h["--"]?h["--"].length:0)-e.getInternalMethods().getContext().commands.length;if(p._&&(b<p._.min||b>p._.max)){if(b<p._.min)if(p._.minMsg!==void 0)t.fail(p._.minMsg?p._.minMsg.replace(/\$0/g,b.toString()).replace(/\$1/,p._.min.toString()):null);else t.fail(r("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",b,b.toString(),p._.min.toString()));else if(b>p._.max)if(p._.maxMsg!==void 0)t.fail(p._.maxMsg?p._.maxMsg.replace(/\$0/g,b.toString()).replace(/\$1/,p._.max.toString()):null);else t.fail(r("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",b,b.toString(),p._.max.toString()))}},s.positionalCount=function(h,p){if(p<h)t.fail(r("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",p,p+"",h+""))},s.requiredArguments=function(h,p){let m=null;for(let b of Object.keys(p))if(!Object.prototype.hasOwnProperty.call(h,b)||typeof h[b]>"u")m=m||{},m[b]=p[b];if(m){let b=[];for(let j of Object.keys(m)){let L=m[j];if(L&&b.indexOf(L)<0)b.push(L)}let D=b.length?`
75
- ${b.join(`
76
- `)}`:"";t.fail(r("Missing required argument: %s","Missing required arguments: %s",Object.keys(m).length,Object.keys(m).join(", ")+D))}},s.unknownArguments=function(h,p,m,b,D=!0){var j;let L=e.getInternalMethods().getCommandInstance().getCommands(),T=[],ce=e.getInternalMethods().getContext();if(Object.keys(h).forEach((R)=>{if(!Qi.includes(R)&&!Object.prototype.hasOwnProperty.call(m,R)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),R)&&!s.isValidAndSomeAliasIsNotNew(R,p))T.push(R)}),D&&(ce.commands.length>0||L.length>0||b))h._.slice(ce.commands.length).forEach((R)=>{if(!L.includes(""+R))T.push(""+R)});if(D){let Y=((j=e.getDemandedCommands()._)===null||j===void 0?void 0:j.max)||0,ne=ce.commands.length+Y;if(ne<h._.length)h._.slice(ne).forEach((X)=>{if(X=String(X),!ce.commands.includes(X)&&!T.includes(X))T.push(X)})}if(T.length)t.fail(r("Unknown argument: %s","Unknown arguments: %s",T.length,T.map((R)=>R.trim()?R:`"${R}"`).join(", ")))},s.unknownCommands=function(h){let p=e.getInternalMethods().getCommandInstance().getCommands(),m=[],b=e.getInternalMethods().getContext();if(b.commands.length>0||p.length>0)h._.slice(b.commands.length).forEach((D)=>{if(!p.includes(""+D))m.push(""+D)});if(m.length>0)return t.fail(r("Unknown command: %s","Unknown commands: %s",m.length,m.join(", "))),!0;else return!1},s.isValidAndSomeAliasIsNotNew=function(h,p){if(!Object.prototype.hasOwnProperty.call(p,h))return!1;let m=e.parsed.newAliases;return[h,...p[h]].some((b)=>!Object.prototype.hasOwnProperty.call(m,b)||!m[h])},s.limitedChoices=function(h){let p=e.getOptions(),m={};if(!Object.keys(p.choices).length)return;Object.keys(h).forEach((j)=>{if(Qi.indexOf(j)===-1&&Object.prototype.hasOwnProperty.call(p.choices,j))[].concat(h[j]).forEach((L)=>{if(p.choices[j].indexOf(L)===-1&&L!==void 0)m[j]=(m[j]||[]).concat(L)})});let b=Object.keys(m);if(!b.length)return;let D=i("Invalid values:");b.forEach((j)=>{D+=`
77
- ${i("Argument: %s, Given: %s, Choices: %s",j,t.stringifiedValues(m[j]),t.stringifiedValues(p.choices[j]))}`}),t.fail(D)};let o={};s.implies=function(h,p){if(w("<string|object> [array|number|string]",[h,p],arguments.length),typeof h==="object")Object.keys(h).forEach((m)=>{s.implies(m,h[m])});else{if(e.global(h),!o[h])o[h]=[];if(Array.isArray(p))p.forEach((m)=>s.implies(h,m));else De(p,void 0,n),o[h].push(p)}},s.getImplied=function(){return o};function a(E,h){let p=Number(h);if(h=isNaN(p)?h:p,typeof h==="number")h=E._.length>=h;else if(h.match(/^--no-.+/))h=h.match(/^--no-(.+)/)[1],h=!Object.prototype.hasOwnProperty.call(E,h);else h=Object.prototype.hasOwnProperty.call(E,h);return h}s.implications=function(h){let p=[];if(Object.keys(o).forEach((m)=>{let b=m;(o[m]||[]).forEach((D)=>{let j=b,L=D;if(j=a(h,j),D=a(h,D),j&&!D)p.push(` ${b} -> ${L}`)})}),p.length){let m=`${i("Implications failed:")}
78
- `;p.forEach((b)=>{m+=b}),t.fail(m)}};let c={};s.conflicts=function(h,p){if(w("<string|object> [array|string]",[h,p],arguments.length),typeof h==="object")Object.keys(h).forEach((m)=>{s.conflicts(m,h[m])});else{if(e.global(h),!c[h])c[h]=[];if(Array.isArray(p))p.forEach((m)=>s.conflicts(h,m));else c[h].push(p)}},s.getConflicting=()=>c,s.conflicting=function(h){if(Object.keys(h).forEach((p)=>{if(c[p])c[p].forEach((m)=>{if(m&&h[p]!==void 0&&h[m]!==void 0)t.fail(i("Arguments %s and %s are mutually exclusive",p,m))})}),e.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(c).forEach((p)=>{c[p].forEach((m)=>{if(m&&h[n.Parser.camelCase(p)]!==void 0&&h[n.Parser.camelCase(m)]!==void 0)t.fail(i("Arguments %s and %s are mutually exclusive",p,m))})})},s.recommendCommands=function(h,p){p=p.sort((j,L)=>L.length-j.length);let b=null,D=1/0;for(let j=0,L;(L=p[j])!==void 0;j++){let T=Zi(h,L);if(T<=3&&T<D)D=T,b=L}if(b)t.fail(i("Did you mean %s?",b))},s.reset=function(h){return o=Ne(o,(p)=>!h[p]),c=Ne(c,(p)=>!h[p]),s};let g=[];return s.freeze=function(){g.push({implied:o,conflicting:c})},s.unfreeze=function(){let h=g.pop();De(h,void 0,n),{implied:o,conflicting:c}=h},s}var bn=[],Ft;function Nt(e,t,n,i){Ft=i;let r={};if(Object.prototype.hasOwnProperty.call(e,"extends")){if(typeof e.extends!=="string")return r;let s=/\.json|\..*rc$/.test(e.extends),o=null;if(!s)try{o=import.meta.resolve(e.extends)}catch(a){return e}else o=pu(t,e.extends);hu(o),bn.push(o),r=s?JSON.parse(Ft.readFileSync(o,"utf8")):i.require(e.extends),delete e.extends,r=Nt(r,Ft.path.dirname(o),n,Ft)}return bn=[],n?tr(r,e):Object.assign({},r,e)}function hu(e){if(bn.indexOf(e)>-1)throw new Q(`Circular extended configurations: '${e}'.`)}function pu(e,t){return Ft.path.resolve(e,t)}function tr(e,t){let n={};function i(r){return r&&typeof r==="object"&&!Array.isArray(r)}Object.assign(n,e);for(let r of Object.keys(t)){if(r==="__proto__")continue;if(i(t[r])&&i(n[r]))n[r]=tr(e[r],t[r]);else n[r]=t[r]}return n}var A=function(e,t,n,i,r){if(i==="m")throw TypeError("Private method is not writable");if(i==="a"&&!r)throw TypeError("Private accessor was defined without a setter");if(typeof t==="function"?e!==t||!r:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?r.call(e,n):r?r.value=n:t.set(e,n),n},u=function(e,t,n,i){if(n==="a"&&!i)throw TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!i:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(e):i?i.value:t.get(e)},ee,Ye,bt,he,ge,It,Re,Je,Rt,Ee,Tt,ye,_e,me,Ce,Wt,Ke,ue,P,Lt,Gt,Fe,qe,lt,Xe,Te,Vt,M,Ze,Qe,et,I,Ht,Se,q;function yr(e){return(t=[],n=e.process.cwd(),i)=>{let r=new Cr(t,n,i,e);return Object.defineProperty(r,"argv",{get:()=>r.parse(),enumerable:!0}),r.help(),r.version(),r}}var nr=Symbol("copyDoubleDash"),ir=Symbol("copyDoubleDash"),En=Symbol("deleteFromParserHintObject"),rr=Symbol("emitWarning"),sr=Symbol("freeze"),or=Symbol("getDollarZero"),tt=Symbol("getParserConfiguration"),ur=Symbol("getUsageConfiguration"),yn=Symbol("guessLocale"),ar=Symbol("guessVersion"),lr=Symbol("parsePositionalNumbers"),Cn=Symbol("pkgUp"),We=Symbol("populateParserHintArray"),ct=Symbol("populateParserHintSingleValueDictionary"),xn=Symbol("populateParserHintArrayDictionary"),wn=Symbol("populateParserHintDictionary"),An=Symbol("sanitizeKey"),_n=Symbol("setKey"),Sn=Symbol("unfreeze"),cr=Symbol("validateAsync"),fr=Symbol("getCommandInstance"),dr=Symbol("getContext"),Dr=Symbol("getHasOutput"),hr=Symbol("getLoggerInstance"),pr=Symbol("getParseContext"),gr=Symbol("getUsageInstance"),mr=Symbol("getValidationInstance"),zt=Symbol("hasParseCallback"),Fr=Symbol("isGlobalContext"),nt=Symbol("postProcess"),br=Symbol("rebase"),Bn=Symbol("reset"),Et=Symbol("runYargsParserAndExecuteCommands"),Pn=Symbol("runValidation"),Er=Symbol("setHasOutput"),it=Symbol("kTrackManuallySetKeys"),gu="en_US";class Cr{constructor(e=[],t,n,i){this.customScriptName=!1,this.parsed=!1,ee.set(this,void 0),Ye.set(this,void 0),bt.set(this,{commands:[],fullCommands:[]}),he.set(this,null),ge.set(this,null),It.set(this,"show-hidden"),Re.set(this,null),Je.set(this,!0),Rt.set(this,{}),Ee.set(this,!0),Tt.set(this,[]),ye.set(this,void 0),_e.set(this,{}),me.set(this,!1),Ce.set(this,null),Wt.set(this,!0),Ke.set(this,void 0),ue.set(this,""),P.set(this,void 0),Lt.set(this,void 0),Gt.set(this,{}),Fe.set(this,null),qe.set(this,null),lt.set(this,{}),Xe.set(this,{}),Te.set(this,void 0),Vt.set(this,!1),M.set(this,void 0),Ze.set(this,!1),Qe.set(this,!1),et.set(this,!1),I.set(this,void 0),Ht.set(this,{}),Se.set(this,null),q.set(this,void 0),A(this,M,i,"f"),A(this,Te,e,"f"),A(this,Ye,t,"f"),A(this,Lt,n,"f"),A(this,ye,new mn(this),"f"),this.$0=this[or](),this[Bn](),A(this,ee,u(this,ee,"f"),"f"),A(this,I,u(this,I,"f"),"f"),A(this,q,u(this,q,"f"),"f"),A(this,P,u(this,P,"f"),"f"),u(this,P,"f").showHiddenOpt=u(this,It,"f"),A(this,Ke,this[ir](),"f"),u(this,M,"f").y18n.setLocale(gu)}addHelpOpt(e,t){if(w("[string|boolean] [string]",[e,t],arguments.length),u(this,Ce,"f"))this[En](u(this,Ce,"f")),A(this,Ce,null,"f");if(e===!1&&t===void 0)return this;return A(this,Ce,typeof e==="string"?e:"help","f"),this.boolean(u(this,Ce,"f")),this.describe(u(this,Ce,"f"),t||u(this,I,"f").deferY18nLookup("Show help")),this}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(w("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==="string"?e:u(this,It,"f");return this.boolean(n),this.describe(n,t||u(this,I,"f").deferY18nLookup("Show hidden options")),u(this,P,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return w("<object|string|array> [string|array]",[e,t],arguments.length),this[xn](this.alias.bind(this),"alias",e,t),this}array(e){return w("<array|string>",[e],arguments.length),this[We]("array",e),this[it](e),this}boolean(e){return w("<array|string>",[e],arguments.length),this[We]("boolean",e),this[it](e),this}check(e,t){return w("<function> [boolean]",[e,t],arguments.length),this.middleware((n,i)=>Ue(()=>e(n,i.getOptions()),(r)=>{if(!r)u(this,I,"f").fail(u(this,M,"f").y18n.__("Argument check failed: %s",e.toString()));else if(typeof r==="string"||r instanceof Error)u(this,I,"f").fail(r.toString(),r);return n},(r)=>(u(this,I,"f").fail(r.message?r.message:r.toString(),r),n)),!1,t),this}choices(e,t){return w("<object|string|array> [string|array]",[e,t],arguments.length),this[xn](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(w("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new Q("coerce callback must be provided");for(let i of e)this.coerce(i,t);return this}else if(typeof e==="object"){for(let i of Object.keys(e))this.coerce(i,e[i]);return this}if(!t)throw new Q("coerce callback must be provided");let n=e;return u(this,P,"f").key[n]=!0,u(this,ye,"f").addCoerceMiddleware((i,r)=>{var s;let o=(s=r.getAliases()[n])!==null&&s!==void 0?s:[],a=[n,...o].filter((c)=>Object.prototype.hasOwnProperty.call(i,c));if(a.length===0)return i;return Ue(()=>t(i[a[0]]),(c)=>(a.forEach((g)=>{i[g]=c}),i),(c)=>{throw new Q(c.message)})},n),this}conflicts(e,t){return w("<string|object> [string|array]",[e,t],arguments.length),u(this,q,"f").conflicts(e,t),this}config(e="config",t,n){if(w("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e==="object"&&!Array.isArray(e))return e=Nt(e,u(this,Ye,"f"),this[tt]()["deep-merge-config"]||!1,u(this,M,"f")),u(this,P,"f").configObjects=(u(this,P,"f").configObjects||[]).concat(e),this;if(typeof t==="function")n=t,t=void 0;return this.describe(e,t||u(this,I,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach((i)=>{u(this,P,"f").config[i]=n||!0}),this}completion(e,t,n){if(w("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t==="function")n=t,t=void 0;if(A(this,ge,e||u(this,ge,"f")||"completion","f"),!t&&t!==!1)t="generate completion script";if(this.command(u(this,ge,"f"),t),n)u(this,he,"f").registerFunction(n);return this}command(e,t,n,i,r,s){return w("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,i,r,s],arguments.length),u(this,ee,"f").addHandler(e,t,n,i,r,s),this}commands(e,t,n,i,r,s){return this.command(e,t,n,i,r,s)}commandDir(e,t){w("<string> [object]",[e,t],arguments.length);let n=u(this,Lt,"f")||u(this,M,"f").require;return u(this,ee,"f").addDirectory(e,n,u(this,M,"f").getCallerFile(),t),this}count(e){return w("<array|string>",[e],arguments.length),this[We]("count",e),this[it](e),this}default(e,t,n){if(w("<object|string|array> [*] [string]",[e,t,n],arguments.length),n)gn(e,u(this,M,"f")),u(this,P,"f").defaultDescription[e]=n;if(typeof t==="function"){if(gn(e,u(this,M,"f")),!u(this,P,"f").defaultDescription[e])u(this,P,"f").defaultDescription[e]=u(this,I,"f").functionDescription(t);t=t.call()}return this[ct](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,i){if(w("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,i],arguments.length),typeof t!=="number")n=t,t=1/0;return this.global("_",!1),u(this,P,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:i},this}demand(e,t,n){if(Array.isArray(t))t.forEach((i)=>{De(n,!0,u(this,M,"f")),this.demandOption(i,n)}),t=1/0;else if(typeof t!=="number")n=t,t=1/0;if(typeof e==="number")De(n,!0,u(this,M,"f")),this.demandCommand(e,t,n,n);else if(Array.isArray(e))e.forEach((i)=>{De(n,!0,u(this,M,"f")),this.demandOption(i,n)});else if(typeof n==="string")this.demandOption(e,n);else if(n===!0||typeof n>"u")this.demandOption(e);return this}demandOption(e,t){return w("<object|string|array> [string]",[e,t],arguments.length),this[ct](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return w("<string> [string|boolean]",[e,t],arguments.length),u(this,P,"f").deprecatedOptions[e]=t,this}describe(e,t){return w("<object|string|array> [string]",[e,t],arguments.length),this[_n](e,!0),u(this,I,"f").describe(e,t),this}detectLocale(e){return w("<boolean>",[e],arguments.length),A(this,Je,e,"f"),this}env(e){if(w("[string|boolean]",[e],arguments.length),e===!1)delete u(this,P,"f").envPrefix;else u(this,P,"f").envPrefix=e||"";return this}epilogue(e){return w("<string>",[e],arguments.length),u(this,I,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){if(w("<string|array> [string]",[e,t],arguments.length),Array.isArray(e))e.forEach((n)=>this.example(...n));else u(this,I,"f").example(e,t);return this}exit(e,t){if(A(this,me,!0,"f"),A(this,Re,t,"f"),u(this,Ee,"f"))u(this,M,"f").process.exit(e)}exitProcess(e=!0){return w("[boolean]",[e],arguments.length),A(this,Ee,e,"f"),this}fail(e){if(w("<function|boolean>",[e],arguments.length),typeof e==="boolean"&&e!==!1)throw new Q("Invalid first argument. Expected function or boolean 'false'");return u(this,I,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){if(w("<array> [function]",[e,t],arguments.length),!t)return new Promise((n,i)=>{u(this,he,"f").getCompletion(e,(r,s)=>{if(r)i(r);else n(s)})});else return u(this,he,"f").getCompletion(e,t)}getDemandedOptions(){return w([],0),u(this,P,"f").demandedOptions}getDemandedCommands(){return w([],0),u(this,P,"f").demandedCommands}getDeprecatedOptions(){return w([],0),u(this,P,"f").deprecatedOptions}getDetectLocale(){return u(this,Je,"f")}getExitProcess(){return u(this,Ee,"f")}getGroups(){return Object.assign({},u(this,_e,"f"),u(this,Xe,"f"))}getHelp(){if(A(this,me,!0,"f"),!u(this,I,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[Et](u(this,Te,"f"),void 0,void 0,0,!0);if(J(t))return t.then(()=>u(this,I,"f").help())}let e=u(this,ee,"f").runDefaultBuilderOn(this);if(J(e))return e.then(()=>u(this,I,"f").help())}return Promise.resolve(u(this,I,"f").help())}getOptions(){return u(this,P,"f")}getStrict(){return u(this,Ze,"f")}getStrictCommands(){return u(this,Qe,"f")}getStrictOptions(){return u(this,et,"f")}global(e,t){if(w("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1)u(this,P,"f").local=u(this,P,"f").local.filter((n)=>e.indexOf(n)===-1);else e.forEach((n)=>{if(!u(this,P,"f").local.includes(n))u(this,P,"f").local.push(n)});return this}group(e,t){w("<string|array> <string>",[e,t],arguments.length);let n=u(this,Xe,"f")[t]||u(this,_e,"f")[t];if(u(this,Xe,"f")[t])delete u(this,Xe,"f")[t];let i={};return u(this,_e,"f")[t]=(n||[]).concat(e).filter((r)=>{if(i[r])return!1;return i[r]=!0}),this}hide(e){return w("<string>",[e],arguments.length),u(this,P,"f").hiddenOptions.push(e),this}implies(e,t){return w("<string|object> [number|string|array]",[e,t],arguments.length),u(this,q,"f").implies(e,t),this}locale(e){if(w("[string]",[e],arguments.length),e===void 0)return this[yn](),u(this,M,"f").y18n.getLocale();return A(this,Je,!1,"f"),u(this,M,"f").y18n.setLocale(e),this}middleware(e,t,n){return u(this,ye,"f").addMiddleware(e,!!t,n)}nargs(e,t){return w("<string|object|array> [number]",[e,t],arguments.length),this[ct](this.nargs.bind(this),"narg",e,t),this}normalize(e){return w("<array|string>",[e],arguments.length),this[We]("normalize",e),this}number(e){return w("<array|string>",[e],arguments.length),this[We]("number",e),this[it](e),this}option(e,t){if(w("<string|object> [object]",[e,t],arguments.length),typeof e==="object")Object.keys(e).forEach((n)=>{this.options(n,e[n])});else{if(typeof t!=="object")t={};if(this[it](e),u(this,Se,"f")&&(e==="version"||(t===null||t===void 0?void 0:t.alias)==="version"))this[rr](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
79
- `),void 0,"versionWarning");if(u(this,P,"f").key[e]=!0,t.alias)this.alias(e,t.alias);let n=t.deprecate||t.deprecated;if(n)this.deprecateOption(e,n);let i=t.demand||t.required||t.require;if(i)this.demand(e,i);if(t.demandOption)this.demandOption(e,typeof t.demandOption==="string"?t.demandOption:void 0);if(t.conflicts)this.conflicts(e,t.conflicts);if("default"in t)this.default(e,t.default);if(t.implies!==void 0)this.implies(e,t.implies);if(t.nargs!==void 0)this.nargs(e,t.nargs);if(t.config)this.config(e,t.configParser);if(t.normalize)this.normalize(e);if(t.choices)this.choices(e,t.choices);if(t.coerce)this.coerce(e,t.coerce);if(t.group)this.group(e,t.group);if(t.boolean||t.type==="boolean"){if(this.boolean(e),t.alias)this.boolean(t.alias)}if(t.array||t.type==="array"){if(this.array(e),t.alias)this.array(t.alias)}if(t.number||t.type==="number"){if(this.number(e),t.alias)this.number(t.alias)}if(t.string||t.type==="string"){if(this.string(e),t.alias)this.string(t.alias)}if(t.count||t.type==="count")this.count(e);if(typeof t.global==="boolean")this.global(e,t.global);if(t.defaultDescription)u(this,P,"f").defaultDescription[e]=t.defaultDescription;if(t.skipValidation)this.skipValidation(e);let r=t.describe||t.description||t.desc,s=u(this,I,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(s,e)||typeof r==="string")this.describe(e,r);if(t.hidden)this.hide(e);if(t.requiresArg)this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){if(w("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[sr](),typeof e>"u")e=u(this,Te,"f");if(typeof t==="object")A(this,qe,t,"f"),t=n;if(typeof t==="function")A(this,Fe,t,"f"),t=!1;if(!t)A(this,Te,e,"f");if(u(this,Fe,"f"))A(this,Ee,!1,"f");let i=this[Et](e,!!t),r=this.parsed;if(u(this,he,"f").setParsed(this.parsed),J(i))return i.then((s)=>{if(u(this,Fe,"f"))u(this,Fe,"f").call(this,u(this,Re,"f"),s,u(this,ue,"f"));return s}).catch((s)=>{if(u(this,Fe,"f"))u(this,Fe,"f")(s,this.parsed.argv,u(this,ue,"f"));throw s}).finally(()=>{this[Sn](),this.parsed=r});else{if(u(this,Fe,"f"))u(this,Fe,"f").call(this,u(this,Re,"f"),i,u(this,ue,"f"));this[Sn](),this.parsed=r}return i}parseAsync(e,t,n){let i=this.parse(e,t,n);return!J(i)?Promise.resolve(i):i}parseSync(e,t,n){let i=this.parse(e,t,n);if(J(i))throw new Q(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return i}parserConfiguration(e){return w("<object>",[e],arguments.length),A(this,Gt,e,"f"),this}pkgConf(e,t){w("<string> [string]",[e,t],arguments.length);let n=null,i=this[Cn](t||u(this,Ye,"f"));if(i[e]&&typeof i[e]==="object")n=Nt(i[e],t||u(this,Ye,"f"),this[tt]()["deep-merge-config"]||!1,u(this,M,"f")),u(this,P,"f").configObjects=(u(this,P,"f").configObjects||[]).concat(n);return this}positional(e,t){w("<string> <object>",[e,t],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=Ne(t,(s,o)=>{if(s==="type"&&!["string","number","boolean"].includes(o))return!1;return n.includes(s)});let i=u(this,bt,"f").fullCommands[u(this,bt,"f").fullCommands.length-1],r=i?u(this,ee,"f").cmdToParseOptions(i):{array:[],alias:{},default:{},demand:{}};return ut(r).forEach((s)=>{let o=r[s];if(Array.isArray(o)){if(o.indexOf(e)!==-1)t[s]=!0}else if(o[e]&&!(s in t))t[s]=o[e]}),this.group(e,u(this,I,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return w("[boolean]",[e],arguments.length),A(this,Vt,e,"f"),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){if(w("<array|string|object> [number]",[e],arguments.length),typeof e==="string"&&u(this,P,"f").narg[e])return this;else this[ct](this.requiresArg.bind(this),"narg",e,NaN);return this}showCompletionScript(e,t){return w("[string] [string]",[e,t],arguments.length),e=e||this.$0,u(this,Ke,"f").log(u(this,he,"f").generateCompletionScript(e,t||u(this,ge,"f")||"completion")),this}showHelp(e){if(w("[string|function]",[e],arguments.length),A(this,me,!0,"f"),!u(this,I,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[Et](u(this,Te,"f"),void 0,void 0,0,!0);if(J(n))return n.then(()=>{u(this,I,"f").showHelp(e)}),this}let t=u(this,ee,"f").runDefaultBuilderOn(this);if(J(t))return t.then(()=>{u(this,I,"f").showHelp(e)}),this}return u(this,I,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return w("[boolean|string] [string]",[e,t],arguments.length),u(this,I,"f").showHelpOnFail(e,t),this}showVersion(e){return w("[string|function]",[e],arguments.length),u(this,I,"f").showVersion(e),this}skipValidation(e){return w("<array|string>",[e],arguments.length),this[We]("skipValidation",e),this}strict(e){return w("[boolean]",[e],arguments.length),A(this,Ze,e!==!1,"f"),this}strictCommands(e){return w("[boolean]",[e],arguments.length),A(this,Qe,e!==!1,"f"),this}strictOptions(e){return w("[boolean]",[e],arguments.length),A(this,et,e!==!1,"f"),this}string(e){return w("<array|string>",[e],arguments.length),this[We]("string",e),this[it](e),this}terminalWidth(){return w([],0),u(this,M,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return w("<object>",[e],arguments.length),A(this,Je,!1,"f"),u(this,M,"f").y18n.updateLocale(e),this}usage(e,t,n,i){if(w("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,i],arguments.length),t!==void 0)if(De(e,null,u(this,M,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,i);else throw new Q(".usage() description must start with $0 if being used as alias for .command()");else return u(this,I,"f").usage(e),this}usageConfiguration(e){return w("<object>",[e],arguments.length),A(this,Ht,e,"f"),this}version(e,t,n){if(w("[boolean|string] [string] [string]",[e,t,n],arguments.length),u(this,Se,"f"))this[En](u(this,Se,"f")),u(this,I,"f").version(void 0),A(this,Se,null,"f");if(arguments.length===0)n=this[ar](),e="version";else if(arguments.length===1){if(e===!1)return this;n=e,e="version"}else if(arguments.length===2)n=t,t=void 0;return A(this,Se,typeof e==="string"?e:"version","f"),t=t||u(this,I,"f").deferY18nLookup("Show version number"),u(this,I,"f").version(n||void 0),this.boolean(u(this,Se,"f")),this.describe(u(this,Se,"f"),t),this}wrap(e){return w("<number|null|undefined>",[e],arguments.length),u(this,I,"f").wrap(e),this}[(ee=new WeakMap,Ye=new WeakMap,bt=new WeakMap,he=new WeakMap,ge=new WeakMap,It=new WeakMap,Re=new WeakMap,Je=new WeakMap,Rt=new WeakMap,Ee=new WeakMap,Tt=new WeakMap,ye=new WeakMap,_e=new WeakMap,me=new WeakMap,Ce=new WeakMap,Wt=new WeakMap,Ke=new WeakMap,ue=new WeakMap,P=new WeakMap,Lt=new WeakMap,Gt=new WeakMap,Fe=new WeakMap,qe=new WeakMap,lt=new WeakMap,Xe=new WeakMap,Te=new WeakMap,Vt=new WeakMap,M=new WeakMap,Ze=new WeakMap,Qe=new WeakMap,et=new WeakMap,I=new WeakMap,Ht=new WeakMap,Se=new WeakMap,q=new WeakMap,nr)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch(t){}return e}[ir](){return{log:(...e)=>{if(!this[zt]())console.log(...e);if(A(this,me,!0,"f"),u(this,ue,"f").length)A(this,ue,u(this,ue,"f")+`
80
- `,"f");A(this,ue,u(this,ue,"f")+e.join(" "),"f")},error:(...e)=>{if(!this[zt]())console.error(...e);if(A(this,me,!0,"f"),u(this,ue,"f").length)A(this,ue,u(this,ue,"f")+`
81
- `,"f");A(this,ue,u(this,ue,"f")+e.join(" "),"f")}}}[En](e){ut(u(this,P,"f")).forEach((t)=>{if(((i)=>i==="configObjects")(t))return;let n=u(this,P,"f")[t];if(Array.isArray(n)){if(n.includes(e))n.splice(n.indexOf(e),1)}else if(typeof n==="object")delete n[e]}),delete u(this,I,"f").getDescriptions()[e]}[rr](e,t,n){if(!u(this,Rt,"f")[n])u(this,M,"f").process.emitWarning(e,t),u(this,Rt,"f")[n]=!0}[sr](){u(this,Tt,"f").push({options:u(this,P,"f"),configObjects:u(this,P,"f").configObjects.slice(0),exitProcess:u(this,Ee,"f"),groups:u(this,_e,"f"),strict:u(this,Ze,"f"),strictCommands:u(this,Qe,"f"),strictOptions:u(this,et,"f"),completionCommand:u(this,ge,"f"),output:u(this,ue,"f"),exitError:u(this,Re,"f"),hasOutput:u(this,me,"f"),parsed:this.parsed,parseFn:u(this,Fe,"f"),parseContext:u(this,qe,"f")}),u(this,I,"f").freeze(),u(this,q,"f").freeze(),u(this,ee,"f").freeze(),u(this,ye,"f").freeze()}[or](){let e="",t;if(/\b(node|iojs|electron|bun)(\.exe)?$/.test(u(this,M,"f").process.argv()[0]))t=u(this,M,"f").process.argv().slice(1,2);else t=u(this,M,"f").process.argv().slice(0,1);if(e=t.map((n)=>{let i=this[br](u(this,Ye,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),u(this,M,"f").getEnv("_")&&u(this,M,"f").getProcessArgvBin()===u(this,M,"f").getEnv("_"))e=u(this,M,"f").getEnv("_").replace(`${u(this,M,"f").path.dirname(u(this,M,"f").process.execPath())}/`,"");return e}[tt](){return u(this,Gt,"f")}[ur](){return u(this,Ht,"f")}[yn](){if(!u(this,Je,"f"))return;let e=u(this,M,"f").getEnv("LC_ALL")||u(this,M,"f").getEnv("LC_MESSAGES")||u(this,M,"f").getEnv("LANG")||u(this,M,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[ar](){return this[Cn]().version||"unknown"}[lr](e){let t=e["--"]?e["--"]:e._;for(let n=0,i;(i=t[n])!==void 0;n++)if(u(this,M,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`))))t[n]=Number(i);return e}[Cn](e){let t=e||"*";if(u(this,lt,"f")[t])return u(this,lt,"f")[t];let n={};try{let i=e||u(this,M,"f").mainFilename;if(u(this,M,"f").path.extname(i))i=u(this,M,"f").path.dirname(i);let r=u(this,M,"f").findUp(i,(s,o)=>{if(o.includes("package.json"))return"package.json";else return});De(r,void 0,u(this,M,"f")),n=JSON.parse(u(this,M,"f").readFileSync(r,"utf8"))}catch(i){}return u(this,lt,"f")[t]=n||{},u(this,lt,"f")[t]}[We](e,t){t=[].concat(t),t.forEach((n)=>{n=this[An](n),u(this,P,"f")[e].push(n)})}[ct](e,t,n,i){this[wn](e,t,n,i,(r,s,o)=>{u(this,P,"f")[r][s]=o})}[xn](e,t,n,i){this[wn](e,t,n,i,(r,s,o)=>{u(this,P,"f")[r][s]=(u(this,P,"f")[r][s]||[]).concat(o)})}[wn](e,t,n,i,r){if(Array.isArray(n))n.forEach((s)=>{e(s,i)});else if(((s)=>typeof s==="object")(n))for(let s of ut(n))e(s,n[s]);else r(t,this[An](n),i)}[An](e){if(e==="__proto__")return"___proto___";return e}[_n](e,t){return this[ct](this[_n].bind(this),"key",e,t),this}[Sn](){var e,t,n,i,r,s,o,a,c,g,E,h;let p=u(this,Tt,"f").pop();De(p,void 0,u(this,M,"f"));let m;e=this,t=this,n=this,i=this,r=this,s=this,o=this,a=this,c=this,g=this,E=this,h=this,{options:{set value(b){A(e,P,b,"f")}}.value,configObjects:m,exitProcess:{set value(b){A(t,Ee,b,"f")}}.value,groups:{set value(b){A(n,_e,b,"f")}}.value,output:{set value(b){A(i,ue,b,"f")}}.value,exitError:{set value(b){A(r,Re,b,"f")}}.value,hasOutput:{set value(b){A(s,me,b,"f")}}.value,parsed:this.parsed,strict:{set value(b){A(o,Ze,b,"f")}}.value,strictCommands:{set value(b){A(a,Qe,b,"f")}}.value,strictOptions:{set value(b){A(c,et,b,"f")}}.value,completionCommand:{set value(b){A(g,ge,b,"f")}}.value,parseFn:{set value(b){A(E,Fe,b,"f")}}.value,parseContext:{set value(b){A(h,qe,b,"f")}}.value}=p,u(this,P,"f").configObjects=m,u(this,I,"f").unfreeze(),u(this,q,"f").unfreeze(),u(this,ee,"f").unfreeze(),u(this,ye,"f").unfreeze()}[cr](e,t){return Ue(t,(n)=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[fr].bind(this),getContext:this[dr].bind(this),getHasOutput:this[Dr].bind(this),getLoggerInstance:this[hr].bind(this),getParseContext:this[pr].bind(this),getParserConfiguration:this[tt].bind(this),getUsageConfiguration:this[ur].bind(this),getUsageInstance:this[gr].bind(this),getValidationInstance:this[mr].bind(this),hasParseCallback:this[zt].bind(this),isGlobalContext:this[Fr].bind(this),postProcess:this[nt].bind(this),reset:this[Bn].bind(this),runValidation:this[Pn].bind(this),runYargsParserAndExecuteCommands:this[Et].bind(this),setHasOutput:this[Er].bind(this)}}[fr](){return u(this,ee,"f")}[dr](){return u(this,bt,"f")}[Dr](){return u(this,me,"f")}[hr](){return u(this,Ke,"f")}[pr](){return u(this,qe,"f")||{}}[gr](){return u(this,I,"f")}[mr](){return u(this,q,"f")}[zt](){return!!u(this,Fe,"f")}[Fr](){return u(this,Wt,"f")}[nt](e,t,n,i){if(n)return e;if(J(e))return e;if(!t)e=this[nr](e);if(this[tt]()["parse-positional-numbers"]||this[tt]()["parse-positional-numbers"]===void 0)e=this[lr](e);if(i)e=ze(e,this,u(this,ye,"f").getMiddleware(),!1);return e}[Bn](e={}){A(this,P,u(this,P,"f")||{},"f");let t={};t.local=u(this,P,"f").local||[],t.configObjects=u(this,P,"f").configObjects||[];let n={};t.local.forEach((s)=>{n[s]=!0,(e[s]||[]).forEach((o)=>{n[o]=!0})}),Object.assign(u(this,Xe,"f"),Object.keys(u(this,_e,"f")).reduce((s,o)=>{let a=u(this,_e,"f")[o].filter((c)=>!(c in n));if(a.length>0)s[o]=a;return s},{})),A(this,_e,{},"f");let i=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],r=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(i.forEach((s)=>{t[s]=(u(this,P,"f")[s]||[]).filter((o)=>!n[o])}),r.forEach((s)=>{t[s]=Ne(u(this,P,"f")[s],(o)=>!n[o])}),t.envPrefix=u(this,P,"f").envPrefix,A(this,P,t,"f"),A(this,I,u(this,I,"f")?u(this,I,"f").reset(n):Yi(this,u(this,M,"f")),"f"),A(this,q,u(this,q,"f")?u(this,q,"f").reset(n):er(this,u(this,I,"f"),u(this,M,"f")),"f"),A(this,ee,u(this,ee,"f")?u(this,ee,"f").reset():Hi(u(this,I,"f"),u(this,q,"f"),u(this,ye,"f"),u(this,M,"f")),"f"),!u(this,he,"f"))A(this,he,Xi(this,u(this,I,"f"),u(this,ee,"f"),u(this,M,"f")),"f");return u(this,ye,"f").reset(),A(this,ge,null,"f"),A(this,ue,"","f"),A(this,Re,null,"f"),A(this,me,!1,"f"),this.parsed=!1,this}[br](e,t){return u(this,M,"f").path.relative(e,t)}[Et](e,t,n,i=0,r=!1){var s,o,a,c;let g=!!n||r;e=e||u(this,Te,"f"),u(this,P,"f").__=u(this,M,"f").y18n.__,u(this,P,"f").configuration=this[tt]();let E=!!u(this,P,"f").configuration["populate--"],h=Object.assign({},u(this,P,"f").configuration,{"populate--":!0}),p=u(this,M,"f").Parser.detailed(e,Object.assign({},u(this,P,"f"),{configuration:{"parse-positional-numbers":!1,...h}})),m=Object.assign(p.argv,u(this,qe,"f")),b=void 0,D=p.aliases,j=!1,L=!1;if(Object.keys(m).forEach((T)=>{if(T===u(this,Ce,"f")&&m[T])j=!0;else if(T===u(this,Se,"f")&&m[T])L=!0}),m.$0=this.$0,this.parsed=p,i===0)u(this,I,"f").clearCachedHelpMessage();try{if(this[yn](),t)return this[nt](m,E,!!n,!1);if(u(this,Ce,"f")){if([u(this,Ce,"f")].concat(D[u(this,Ce,"f")]||[]).filter((ne)=>ne.length>1).includes(""+m._[m._.length-1]))m._.pop(),j=!0}A(this,Wt,!1,"f");let T=u(this,ee,"f").getCommands(),ce=((s=u(this,he,"f"))===null||s===void 0?void 0:s.completionKey)?[(o=u(this,he,"f"))===null||o===void 0?void 0:o.completionKey,...(c=this.getAliases()[(a=u(this,he,"f"))===null||a===void 0?void 0:a.completionKey])!==null&&c!==void 0?c:[]].some((Y)=>Object.prototype.hasOwnProperty.call(m,Y)):!1,R=j||ce||r;if(m._.length){if(T.length){let Y;for(let ne=i||0,X;m._[ne]!==void 0;ne++)if(X=String(m._[ne]),T.includes(X)&&X!==u(this,ge,"f")){let Ae=u(this,ee,"f").runCommand(X,this,p,ne+1,r,j||L||r);return this[nt](Ae,E,!!n,!1)}else if(!Y&&X!==u(this,ge,"f")){Y=X;break}if(!u(this,ee,"f").hasDefaultCommand()&&u(this,Vt,"f")&&Y&&!R)u(this,q,"f").recommendCommands(Y,T)}if(u(this,ge,"f")&&m._.includes(u(this,ge,"f"))&&!ce){if(u(this,Ee,"f"))Ie(!0);this.showCompletionScript(),this.exit(0)}}if(u(this,ee,"f").hasDefaultCommand()&&!R){let Y=u(this,ee,"f").runCommand(null,this,p,0,r,j||L||r);return this[nt](Y,E,!!n,!1)}if(ce){if(u(this,Ee,"f"))Ie(!0);e=[].concat(e);let Y=e.slice(e.indexOf(`--${u(this,he,"f").completionKey}`)+1);return u(this,he,"f").getCompletion(Y,(ne,X)=>{if(ne)throw new Q(ne.message);(X||[]).forEach((Ae)=>{u(this,Ke,"f").log(Ae)}),this.exit(0)}),this[nt](m,!E,!!n,!1)}if(!u(this,me,"f")){if(j){if(u(this,Ee,"f"))Ie(!0);g=!0,this.showHelp((Y)=>{u(this,Ke,"f").log(Y),this.exit(0)})}else if(L){if(u(this,Ee,"f"))Ie(!0);g=!0,u(this,I,"f").showVersion("log"),this.exit(0)}}if(!g&&u(this,P,"f").skipValidation.length>0)g=Object.keys(m).some((Y)=>u(this,P,"f").skipValidation.indexOf(Y)>=0&&m[Y]===!0);if(!g){if(p.error)throw new Q(p.error.message);if(!ce){let Y=this[Pn](D,{},p.error);if(!n)b=ze(m,this,u(this,ye,"f").getMiddleware(),!0);if(b=this[cr](Y,b!==null&&b!==void 0?b:m),J(b)&&!n)b=b.then(()=>ze(m,this,u(this,ye,"f").getMiddleware(),!1))}}}catch(T){if(T instanceof Q)u(this,I,"f").fail(T.message,T);else throw T}return this[nt](b!==null&&b!==void 0?b:m,E,!!n,!0)}[Pn](e,t,n,i){let r={...this.getDemandedOptions()};return(s)=>{if(n)throw new Q(n.message);u(this,q,"f").nonOptionCount(s),u(this,q,"f").requiredArguments(s,r);let o=!1;if(u(this,Qe,"f"))o=u(this,q,"f").unknownCommands(s);if(u(this,Ze,"f")&&!o)u(this,q,"f").unknownArguments(s,e,t,!!i);else if(u(this,et,"f"))u(this,q,"f").unknownArguments(s,e,{},!1,!1);u(this,q,"f").limitedChoices(s),u(this,q,"f").implications(s),u(this,q,"f").conflicting(s)}}[Er](){A(this,me,!0,"f")}[it](e){if(typeof e==="string")u(this,P,"f").key[e]=!0;else for(let t of e)u(this,P,"f").key[t]=!0}}function zi(e){return!!e&&typeof e.getInternalMethods==="function"}var mu=yr(Ri),xr=mu;var wr={name:"@coryrylan/cradle",version:"1.3.0",description:"A runtime for portable agents defined as folders \u2014 launches the pi coding agent configured from an agent folder, sandboxed with nono",main:"./dist/index.js",module:"./dist/index.js",types:"./dist/index.d.ts",type:"module",exports:{".":{types:"./dist/index.d.ts",default:"./dist/index.js"}},bin:{cradle:"dist/index.js"},files:["README.md","CHANGELOG.md","LICENSE","package.json","dist/index.js","dist/**/*.d.ts","!dist/**/*.test.d.ts"],repository:{type:"git",url:"git+https://github.com/coryrylan/cradle.git",directory:"projects/cli"},keywords:["pi","agents","agent-folders","sandbox","nono","cli","bun"],author:"Cory Rylan (https://coryrylan.com)",license:"MIT",bugs:{url:"https://github.com/coryrylan/cradle/issues"},homepage:"https://github.com/coryrylan/cradle/tree/main/projects/cli#readme",engines:{bun:">=1.4.0"},publishConfig:{access:"public"},scripts:{start:"wireit",ci:"wireit","ci:nocache":"bun run clean && bun run ci",clean:"rm -rf dist",test:"wireit","test:coverage":"wireit",lint:"wireit",build:"wireit","install:local":"wireit","uninstall:local":"wireit",release:"wireit"},wireit:{start:{command:"bun src/index.ts",cache:!1},ci:{dependencies:["lint","build","test:coverage"]},test:{command:"bun test",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json","bunfig.toml"],output:[]},"test:coverage":{command:"bun test --coverage",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json","bunfig.toml"],output:[]},lint:{command:"eslint .",files:["src/**/*.ts","eslint.config.js","package.json"],output:[]},build:{dependencies:["build:js","build:tsc","build:darwin-arm64","build:darwin-x64","build:linux-x64","build:linux-arm64","build:windows-x64"]},"build:js":{command:"bun build ./src/index.ts --outdir=./dist --target=bun --format=esm --minify",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/index.js"]},"build:tsc":{command:"tsc --emitDeclarationOnly --project tsconfig.types.json",files:["src/**/*.ts","src/**/*.json","tsconfig.json","tsconfig.types.json"],output:["dist/**/*.d.ts"]},"build:darwin-arm64":{command:"bun build --compile --minify src/index.ts --target=bun-darwin-arm64 --outfile dist/cradle-macos-arm64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-macos-arm64"]},"build:darwin-x64":{command:"bun build --compile --minify src/index.ts --target=bun-darwin-x64 --outfile dist/cradle-macos-x64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-macos-x64"]},"build:linux-x64":{command:"bun build --compile --minify src/index.ts --target=bun-linux-x64 --outfile dist/cradle-linux-x64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-linux-x64"]},"build:linux-arm64":{command:"bun build --compile --minify src/index.ts --target=bun-linux-arm64 --outfile dist/cradle-linux-arm64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-linux-arm64"]},"build:windows-x64":{command:"bun build --compile --minify src/index.ts --target=bun-windows-x64 --outfile dist/cradle-windows-x64.exe",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-windows-x64.exe"]},"install:local":{dependencies:["build"],command:"bash install.sh",cache:!1},"uninstall:local":{command:'rm -f "$HOME/.local/bin/cradle"',cache:!1},release:{command:"HUSKY=0 bun x semantic-release",dependencies:["ci"]}},dependencies:{yargs:"^18.1.0"},devDependencies:{"@coryrylan/tools":"1.1.1","@eslint/js":"catalog:","@eslint/json":"2.0.1","@types/bun":"catalog:","@types/yargs":"17.0.35",eslint:"catalog:","eslint-plugin-jsdoc":"64.2.1",typescript:"catalog:","typescript-eslint":"catalog:"}};import{join as _r}from"path";var Ut="agent-browser-nono-fallback.ts";function Ar(){return`// generated by cradle for sandboxed agent-browser processes \u2014 do not edit
74
+ `;class mi{constructor(e,t,n,r){var i,s,o;this.yargs=e,this.usage=t,this.command=n,this.shim=r,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(o=((i=this.shim.getEnv("SHELL"))===null||i===void 0?void 0:i.includes("zsh"))||((s=this.shim.getEnv("ZSH_NAME"))===null||s===void 0?void 0:s.includes("zsh")))!==null&&o!==void 0?o:!1}defaultCompletion(e,t,n,r){let i=this.command.getCommandHandlers();for(let o=0,u=e.length;o<u;++o)if(i[e[o]]&&i[e[o]].builder){let c=i[e[o]].builder;if(Wt(c)){this.indexAfterLastReset=o+1;let p=this.yargs.getInternalMethods().reset();return c(p,!0),p.argv}}let s=[];this.commandCompletions(s,e,n),this.optionCompletions(s,e,t,n),this.choicesFromOptionsCompletions(s,e,t,n),this.choicesFromPositionalsCompletions(s,e,t,n),r(null,s)}commandCompletions(e,t,n){let r=this.yargs.getInternalMethods().getContext().commands;if(!n.match(/^-/)&&r[r.length-1]!==n&&!this.previousArgHasChoices(t))this.usage.getCommands().forEach((i)=>{let s=Re(i[0]).cmd;if(t.indexOf(s)===-1)if(!this.zshShell)e.push(s);else{let o=i[1]||"";e.push(s.replace(/:/g,"\\:")+":"+o)}})}optionCompletions(e,t,n,r){if((r.match(/^-/)||r===""&&e.length===0)&&!this.previousArgHasChoices(t)){let i=this.yargs.getOptions(),s=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(i.key).forEach((o)=>{let u=!!i.configuration["boolean-negation"]&&i.boolean.includes(o);if(!s.includes(o)&&!i.hiddenOptions.includes(o)&&!this.argsContainKey(t,o,u))this.completeOptionKey(o,e,r,u&&!!i.default[o])})}}choicesFromOptionsCompletions(e,t,n,r){if(this.previousArgHasChoices(t)){let i=this.getPreviousArgChoices(t);if(i&&i.length>0)e.push(...i.map((s)=>s.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,t,n,r){if(r===""&&e.length>0&&this.previousArgHasChoices(t))return;let i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],s=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=i[n._.length-s-1];if(!o)return;let u=this.yargs.getOptions().choices[o]||[];for(let c of u)if(c.startsWith(r))e.push(c.replace(/:/g,"\\:"))}getPreviousArgChoices(e){if(e.length<1)return;let t=e[e.length-1],n="";if(!t.startsWith("-")&&e.length>1)n=t,t=e[e.length-2];if(!t.startsWith("-"))return;let r=t.replace(/^-+/,""),i=this.yargs.getOptions(),s=[r,...this.yargs.getAliases()[r]||[]],o;for(let u of s)if(Object.prototype.hasOwnProperty.call(i.key,u)&&Array.isArray(i.choices[u])){o=i.choices[u];break}if(o)return o.filter((u)=>!n||u.startsWith(n))}previousArgHasChoices(e){let t=this.getPreviousArgChoices(e);return t!==void 0&&t.length>0}argsContainKey(e,t,n){let r=(i)=>e.indexOf((/^[^0-9]$/.test(i)?"-":"--")+i)!==-1;if(r(t))return!0;if(n&&r(`no-${t}`))return!0;if(this.aliases){for(let i of this.aliases[t])if(r(i))return!0}return!1}completeOptionKey(e,t,n,r){var i,s,o,u;let c=e;if(this.zshShell){let D=this.usage.getDescriptions(),F=(s=(i=this===null||this===void 0?void 0:this.aliases)===null||i===void 0?void 0:i[e])===null||s===void 0?void 0:s.find((v)=>{let W=D[v];return typeof W==="string"&&W.length>0}),y=F?D[F]:void 0,h=(u=(o=D[e])!==null&&o!==void 0?o:y)!==null&&u!==void 0?u:"";c=`${e.replace(/:/g,"\\:")}:${h.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let p=(D)=>/^--/.test(D),b=(D)=>/^[^0-9]$/.test(D),g=!p(n)&&b(e)?"-":"--";if(t.push(g+c),r)t.push(g+"no-"+c)}customCompletion(e,t,n,r){if(he(this.customCompletionFunction,null,this.shim),nu(this.customCompletionFunction)){let i=this.customCompletionFunction(n,t);if(J(i))return i.then((s)=>{this.shim.process.nextTick(()=>{r(null,s)})}).catch((s)=>{this.shim.process.nextTick(()=>{r(s,void 0)})});return r(null,i)}else if(ru(this.customCompletionFunction))return this.customCompletionFunction(n,t,(i=r)=>this.defaultCompletion(e,t,n,i),(i)=>{r(null,i)});else return this.customCompletionFunction(n,t,(i)=>{r(null,i)})}getCompletion(e,t){let n=e.length?e[e.length-1]:"",r=this.yargs.parse(e,!0),i=this.customCompletionFunction?(s)=>this.customCompletion(e,s,n,t):(s)=>this.defaultCompletion(e,s,n,t);return J(r)?r.then(i):i(r)}generateCompletionScript(e,t){let n=this.zshShell?pi:gi,r=this.shim.path.basename(e);if(e.match(/\.js$/))e=`./${e}`;return n=n.replace(/{{app_name}}/g,r),n=n.replace(/{{completion_command}}/g,t),n.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}}function Fi(e,t,n,r){return new mi(e,t,n,r)}function nu(e){return e.length<3}function ru(e){return e.length>3}function yi(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let n=[],r;for(r=0;r<=t.length;r++)n[r]=[r];let i;for(i=0;i<=e.length;i++)n[0][i]=i;for(r=1;r<=t.length;r++)for(i=1;i<=e.length;i++)if(t.charAt(r-1)===e.charAt(i-1))n[r][i]=n[r-1][i-1];else if(r>1&&i>1&&t.charAt(r-2)===e.charAt(i-1)&&t.charAt(r-1)===e.charAt(i-2))n[r][i]=n[r-2][i-2]+1;else n[r][i]=Math.min(n[r-1][i-1]+1,Math.min(n[r][i-1]+1,n[r-1][i]+1));return n[t.length][e.length]}var bi=["$0","--","_"];function Ei(e,t,n){let r=n.y18n.__,i=n.y18n.__n,s={};s.nonOptionCount=function(g){let D=e.getDemandedCommands(),y=g._.length+(g["--"]?g["--"].length:0)-e.getInternalMethods().getContext().commands.length;if(D._&&(y<D._.min||y>D._.max)){if(y<D._.min)if(D._.minMsg!==void 0)t.fail(D._.minMsg?D._.minMsg.replace(/\$0/g,y.toString()).replace(/\$1/,D._.min.toString()):null);else t.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",y,y.toString(),D._.min.toString()));else if(y>D._.max)if(D._.maxMsg!==void 0)t.fail(D._.maxMsg?D._.maxMsg.replace(/\$0/g,y.toString()).replace(/\$1/,D._.max.toString()):null);else t.fail(i("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",y,y.toString(),D._.max.toString()))}},s.positionalCount=function(g,D){if(D<g)t.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",D,D+"",g+""))},s.requiredArguments=function(g,D){let F=null;for(let y of Object.keys(D))if(!Object.prototype.hasOwnProperty.call(g,y)||typeof g[y]>"u")F=F||{},F[y]=D[y];if(F){let y=[];for(let v of Object.keys(F)){let W=F[v];if(W&&y.indexOf(W)<0)y.push(W)}let h=y.length?`
75
+ ${y.join(`
76
+ `)}`:"";t.fail(i("Missing required argument: %s","Missing required arguments: %s",Object.keys(F).length,Object.keys(F).join(", ")+h))}},s.unknownArguments=function(g,D,F,y,h=!0){var v;let W=e.getInternalMethods().getCommandInstance().getCommands(),T=[],ce=e.getInternalMethods().getContext();if(Object.keys(g).forEach((I)=>{if(!bi.includes(I)&&!Object.prototype.hasOwnProperty.call(F,I)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),I)&&!s.isValidAndSomeAliasIsNotNew(I,D))T.push(I)}),h&&(ce.commands.length>0||W.length>0||y))g._.slice(ce.commands.length).forEach((I)=>{if(!W.includes(""+I))T.push(""+I)});if(h){let Y=((v=e.getDemandedCommands()._)===null||v===void 0?void 0:v.max)||0,ne=ce.commands.length+Y;if(ne<g._.length)g._.slice(ne).forEach((X)=>{if(X=String(X),!ce.commands.includes(X)&&!T.includes(X))T.push(X)})}if(T.length)t.fail(i("Unknown argument: %s","Unknown arguments: %s",T.length,T.map((I)=>I.trim()?I:`"${I}"`).join(", ")))},s.unknownCommands=function(g){let D=e.getInternalMethods().getCommandInstance().getCommands(),F=[],y=e.getInternalMethods().getContext();if(y.commands.length>0||D.length>0)g._.slice(y.commands.length).forEach((h)=>{if(!D.includes(""+h))F.push(""+h)});if(F.length>0)return t.fail(i("Unknown command: %s","Unknown commands: %s",F.length,F.join(", "))),!0;else return!1},s.isValidAndSomeAliasIsNotNew=function(g,D){if(!Object.prototype.hasOwnProperty.call(D,g))return!1;let F=e.parsed.newAliases;return[g,...D[g]].some((y)=>!Object.prototype.hasOwnProperty.call(F,y)||!F[g])},s.limitedChoices=function(g){let D=e.getOptions(),F={};if(!Object.keys(D.choices).length)return;Object.keys(g).forEach((v)=>{if(bi.indexOf(v)===-1&&Object.prototype.hasOwnProperty.call(D.choices,v))[].concat(g[v]).forEach((W)=>{if(D.choices[v].indexOf(W)===-1&&W!==void 0)F[v]=(F[v]||[]).concat(W)})});let y=Object.keys(F);if(!y.length)return;let h=r("Invalid values:");y.forEach((v)=>{h+=`
77
+ ${r("Argument: %s, Given: %s, Choices: %s",v,t.stringifiedValues(F[v]),t.stringifiedValues(D.choices[v]))}`}),t.fail(h)};let o={};s.implies=function(g,D){if(x("<string|object> [array|number|string]",[g,D],arguments.length),typeof g==="object")Object.keys(g).forEach((F)=>{s.implies(F,g[F])});else{if(e.global(g),!o[g])o[g]=[];if(Array.isArray(D))D.forEach((F)=>s.implies(g,F));else he(D,void 0,n),o[g].push(D)}},s.getImplied=function(){return o};function u(b,g){let D=Number(g);if(g=isNaN(D)?g:D,typeof g==="number")g=b._.length>=g;else if(g.match(/^--no-.+/))g=g.match(/^--no-(.+)/)[1],g=!Object.prototype.hasOwnProperty.call(b,g);else g=Object.prototype.hasOwnProperty.call(b,g);return g}s.implications=function(g){let D=[];if(Object.keys(o).forEach((F)=>{let y=F;(o[F]||[]).forEach((h)=>{let v=y,W=h;if(v=u(g,v),h=u(g,h),v&&!h)D.push(` ${y} -> ${W}`)})}),D.length){let F=`${r("Implications failed:")}
78
+ `;D.forEach((y)=>{F+=y}),t.fail(F)}};let c={};s.conflicts=function(g,D){if(x("<string|object> [array|string]",[g,D],arguments.length),typeof g==="object")Object.keys(g).forEach((F)=>{s.conflicts(F,g[F])});else{if(e.global(g),!c[g])c[g]=[];if(Array.isArray(D))D.forEach((F)=>s.conflicts(g,F));else c[g].push(D)}},s.getConflicting=()=>c,s.conflicting=function(g){if(Object.keys(g).forEach((D)=>{if(c[D])c[D].forEach((F)=>{if(F&&g[D]!==void 0&&g[F]!==void 0)t.fail(r("Arguments %s and %s are mutually exclusive",D,F))})}),e.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(c).forEach((D)=>{c[D].forEach((F)=>{if(F&&g[n.Parser.camelCase(D)]!==void 0&&g[n.Parser.camelCase(F)]!==void 0)t.fail(r("Arguments %s and %s are mutually exclusive",D,F))})})},s.recommendCommands=function(g,D){D=D.sort((v,W)=>W.length-v.length);let y=null,h=1/0;for(let v=0,W;(W=D[v])!==void 0;v++){let T=yi(g,W);if(T<=3&&T<h)h=T,y=W}if(y)t.fail(r("Did you mean %s?",y))},s.reset=function(g){return o=Ie(o,(D)=>!g[D]),c=Ie(c,(D)=>!g[D]),s};let p=[];return s.freeze=function(){p.push({implied:o,conflicting:c})},s.unfreeze=function(){let g=p.pop();he(g,void 0,n),{implied:o,conflicting:c}=g},s}var kn=[],St;function Vt(e,t,n,r){St=r;let i={};if(Object.prototype.hasOwnProperty.call(e,"extends")){if(typeof e.extends!=="string")return i;let s=/\.json|\..*rc$/.test(e.extends),o=null;if(!s)try{o=import.meta.resolve(e.extends)}catch(u){return e}else o=su(t,e.extends);iu(o),kn.push(o),i=s?JSON.parse(St.readFileSync(o,"utf8")):r.require(e.extends),delete e.extends,i=Vt(i,St.path.dirname(o),n,St)}return kn=[],n?Ci(i,e):Object.assign({},i,e)}function iu(e){if(kn.indexOf(e)>-1)throw new Q(`Circular extended configurations: '${e}'.`)}function su(e,t){return St.path.resolve(e,t)}function Ci(e,t){let n={};function r(i){return i&&typeof i==="object"&&!Array.isArray(i)}Object.assign(n,e);for(let i of Object.keys(t)){if(i==="__proto__")continue;if(r(t[i])&&r(n[i]))n[i]=Ci(e[i],t[i]);else n[i]=t[i]}return n}var S=function(e,t,n,r,i){if(r==="m")throw TypeError("Private method is not writable");if(r==="a"&&!i)throw TypeError("Private accessor was defined without a setter");if(typeof t==="function"?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?i.call(e,n):i?i.value=n:t.set(e,n),n},a=function(e,t,n,r){if(n==="a"&&!r)throw TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!r:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)},ee,Xe,At,De,pe,zt,Le,Ze,Gt,be,Ut,Ee,_e,me,Ce,Yt,Qe,ae,B,Jt,Kt,Fe,et,Dt,tt,We,qt,M,nt,rt,it,R,Xt,Be,q;function Hi(e){return(t=[],n=e.process.cwd(),r)=>{let i=new Vi(t,n,r,e);return Object.defineProperty(i,"argv",{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}var wi=Symbol("copyDoubleDash"),xi=Symbol("copyDoubleDash"),Mn=Symbol("deleteFromParserHintObject"),Si=Symbol("emitWarning"),Ai=Symbol("freeze"),Pi=Symbol("getDollarZero"),st=Symbol("getParserConfiguration"),_i=Symbol("getUsageConfiguration"),Nn=Symbol("guessLocale"),Bi=Symbol("guessVersion"),Oi=Symbol("parsePositionalNumbers"),Rn=Symbol("pkgUp"),He=Symbol("populateParserHintArray"),gt=Symbol("populateParserHintSingleValueDictionary"),In=Symbol("populateParserHintArrayDictionary"),Tn=Symbol("populateParserHintDictionary"),Ln=Symbol("sanitizeKey"),Wn=Symbol("setKey"),Hn=Symbol("unfreeze"),$i=Symbol("validateAsync"),vi=Symbol("getCommandInstance"),ji=Symbol("getContext"),ki=Symbol("getHasOutput"),Mi=Symbol("getLoggerInstance"),Ni=Symbol("getParseContext"),Ri=Symbol("getUsageInstance"),Ii=Symbol("getValidationInstance"),Zt=Symbol("hasParseCallback"),Ti=Symbol("isGlobalContext"),ot=Symbol("postProcess"),Li=Symbol("rebase"),Vn=Symbol("reset"),Pt=Symbol("runYargsParserAndExecuteCommands"),zn=Symbol("runValidation"),Wi=Symbol("setHasOutput"),at=Symbol("kTrackManuallySetKeys"),ou="en_US";class Vi{constructor(e=[],t,n,r){this.customScriptName=!1,this.parsed=!1,ee.set(this,void 0),Xe.set(this,void 0),At.set(this,{commands:[],fullCommands:[]}),De.set(this,null),pe.set(this,null),zt.set(this,"show-hidden"),Le.set(this,null),Ze.set(this,!0),Gt.set(this,{}),be.set(this,!0),Ut.set(this,[]),Ee.set(this,void 0),_e.set(this,{}),me.set(this,!1),Ce.set(this,null),Yt.set(this,!0),Qe.set(this,void 0),ae.set(this,""),B.set(this,void 0),Jt.set(this,void 0),Kt.set(this,{}),Fe.set(this,null),et.set(this,null),Dt.set(this,{}),tt.set(this,{}),We.set(this,void 0),qt.set(this,!1),M.set(this,void 0),nt.set(this,!1),rt.set(this,!1),it.set(this,!1),R.set(this,void 0),Xt.set(this,{}),Be.set(this,null),q.set(this,void 0),S(this,M,r,"f"),S(this,We,e,"f"),S(this,Xe,t,"f"),S(this,Jt,n,"f"),S(this,Ee,new vn(this),"f"),this.$0=this[Pi](),this[Vn](),S(this,ee,a(this,ee,"f"),"f"),S(this,R,a(this,R,"f"),"f"),S(this,q,a(this,q,"f"),"f"),S(this,B,a(this,B,"f"),"f"),a(this,B,"f").showHiddenOpt=a(this,zt,"f"),S(this,Qe,this[xi](),"f"),a(this,M,"f").y18n.setLocale(ou)}addHelpOpt(e,t){if(x("[string|boolean] [string]",[e,t],arguments.length),a(this,Ce,"f"))this[Mn](a(this,Ce,"f")),S(this,Ce,null,"f");if(e===!1&&t===void 0)return this;return S(this,Ce,typeof e==="string"?e:"help","f"),this.boolean(a(this,Ce,"f")),this.describe(a(this,Ce,"f"),t||a(this,R,"f").deferY18nLookup("Show help")),this}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(x("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==="string"?e:a(this,zt,"f");return this.boolean(n),this.describe(n,t||a(this,R,"f").deferY18nLookup("Show hidden options")),a(this,B,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return x("<object|string|array> [string|array]",[e,t],arguments.length),this[In](this.alias.bind(this),"alias",e,t),this}array(e){return x("<array|string>",[e],arguments.length),this[He]("array",e),this[at](e),this}boolean(e){return x("<array|string>",[e],arguments.length),this[He]("boolean",e),this[at](e),this}check(e,t){return x("<function> [boolean]",[e,t],arguments.length),this.middleware((n,r)=>qe(()=>e(n,r.getOptions()),(i)=>{if(!i)a(this,R,"f").fail(a(this,M,"f").y18n.__("Argument check failed: %s",e.toString()));else if(typeof i==="string"||i instanceof Error)a(this,R,"f").fail(i.toString(),i);return n},(i)=>(a(this,R,"f").fail(i.message?i.message:i.toString(),i),n)),!1,t),this}choices(e,t){return x("<object|string|array> [string|array]",[e,t],arguments.length),this[In](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(x("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new Q("coerce callback must be provided");for(let r of e)this.coerce(r,t);return this}else if(typeof e==="object"){for(let r of Object.keys(e))this.coerce(r,e[r]);return this}if(!t)throw new Q("coerce callback must be provided");let n=e;return a(this,B,"f").key[n]=!0,a(this,Ee,"f").addCoerceMiddleware((r,i)=>{var s;let o=(s=i.getAliases()[n])!==null&&s!==void 0?s:[],u=[n,...o].filter((c)=>Object.prototype.hasOwnProperty.call(r,c));if(u.length===0)return r;return qe(()=>t(r[u[0]]),(c)=>(u.forEach((p)=>{r[p]=c}),r),(c)=>{throw new Q(c.message)})},n),this}conflicts(e,t){return x("<string|object> [string|array]",[e,t],arguments.length),a(this,q,"f").conflicts(e,t),this}config(e="config",t,n){if(x("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e==="object"&&!Array.isArray(e))return e=Vt(e,a(this,Xe,"f"),this[st]()["deep-merge-config"]||!1,a(this,M,"f")),a(this,B,"f").configObjects=(a(this,B,"f").configObjects||[]).concat(e),this;if(typeof t==="function")n=t,t=void 0;return this.describe(e,t||a(this,R,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach((r)=>{a(this,B,"f").config[r]=n||!0}),this}completion(e,t,n){if(x("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t==="function")n=t,t=void 0;if(S(this,pe,e||a(this,pe,"f")||"completion","f"),!t&&t!==!1)t="generate completion script";if(this.command(a(this,pe,"f"),t),n)a(this,De,"f").registerFunction(n);return this}command(e,t,n,r,i,s){return x("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,r,i,s],arguments.length),a(this,ee,"f").addHandler(e,t,n,r,i,s),this}commands(e,t,n,r,i,s){return this.command(e,t,n,r,i,s)}commandDir(e,t){x("<string> [object]",[e,t],arguments.length);let n=a(this,Jt,"f")||a(this,M,"f").require;return a(this,ee,"f").addDirectory(e,n,a(this,M,"f").getCallerFile(),t),this}count(e){return x("<array|string>",[e],arguments.length),this[He]("count",e),this[at](e),this}default(e,t,n){if(x("<object|string|array> [*] [string]",[e,t,n],arguments.length),n)$n(e,a(this,M,"f")),a(this,B,"f").defaultDescription[e]=n;if(typeof t==="function"){if($n(e,a(this,M,"f")),!a(this,B,"f").defaultDescription[e])a(this,B,"f").defaultDescription[e]=a(this,R,"f").functionDescription(t);t=t.call()}return this[gt](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,r){if(x("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,r],arguments.length),typeof t!=="number")n=t,t=1/0;return this.global("_",!1),a(this,B,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:r},this}demand(e,t,n){if(Array.isArray(t))t.forEach((r)=>{he(n,!0,a(this,M,"f")),this.demandOption(r,n)}),t=1/0;else if(typeof t!=="number")n=t,t=1/0;if(typeof e==="number")he(n,!0,a(this,M,"f")),this.demandCommand(e,t,n,n);else if(Array.isArray(e))e.forEach((r)=>{he(n,!0,a(this,M,"f")),this.demandOption(r,n)});else if(typeof n==="string")this.demandOption(e,n);else if(n===!0||typeof n>"u")this.demandOption(e);return this}demandOption(e,t){return x("<object|string|array> [string]",[e,t],arguments.length),this[gt](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return x("<string> [string|boolean]",[e,t],arguments.length),a(this,B,"f").deprecatedOptions[e]=t,this}describe(e,t){return x("<object|string|array> [string]",[e,t],arguments.length),this[Wn](e,!0),a(this,R,"f").describe(e,t),this}detectLocale(e){return x("<boolean>",[e],arguments.length),S(this,Ze,e,"f"),this}env(e){if(x("[string|boolean]",[e],arguments.length),e===!1)delete a(this,B,"f").envPrefix;else a(this,B,"f").envPrefix=e||"";return this}epilogue(e){return x("<string>",[e],arguments.length),a(this,R,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){if(x("<string|array> [string]",[e,t],arguments.length),Array.isArray(e))e.forEach((n)=>this.example(...n));else a(this,R,"f").example(e,t);return this}exit(e,t){if(S(this,me,!0,"f"),S(this,Le,t,"f"),a(this,be,"f"))a(this,M,"f").process.exit(e)}exitProcess(e=!0){return x("[boolean]",[e],arguments.length),S(this,be,e,"f"),this}fail(e){if(x("<function|boolean>",[e],arguments.length),typeof e==="boolean"&&e!==!1)throw new Q("Invalid first argument. Expected function or boolean 'false'");return a(this,R,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){if(x("<array> [function]",[e,t],arguments.length),!t)return new Promise((n,r)=>{a(this,De,"f").getCompletion(e,(i,s)=>{if(i)r(i);else n(s)})});else return a(this,De,"f").getCompletion(e,t)}getDemandedOptions(){return x([],0),a(this,B,"f").demandedOptions}getDemandedCommands(){return x([],0),a(this,B,"f").demandedCommands}getDeprecatedOptions(){return x([],0),a(this,B,"f").deprecatedOptions}getDetectLocale(){return a(this,Ze,"f")}getExitProcess(){return a(this,be,"f")}getGroups(){return Object.assign({},a(this,_e,"f"),a(this,tt,"f"))}getHelp(){if(S(this,me,!0,"f"),!a(this,R,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[Pt](a(this,We,"f"),void 0,void 0,0,!0);if(J(t))return t.then(()=>a(this,R,"f").help())}let e=a(this,ee,"f").runDefaultBuilderOn(this);if(J(e))return e.then(()=>a(this,R,"f").help())}return Promise.resolve(a(this,R,"f").help())}getOptions(){return a(this,B,"f")}getStrict(){return a(this,nt,"f")}getStrictCommands(){return a(this,rt,"f")}getStrictOptions(){return a(this,it,"f")}global(e,t){if(x("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1)a(this,B,"f").local=a(this,B,"f").local.filter((n)=>e.indexOf(n)===-1);else e.forEach((n)=>{if(!a(this,B,"f").local.includes(n))a(this,B,"f").local.push(n)});return this}group(e,t){x("<string|array> <string>",[e,t],arguments.length);let n=a(this,tt,"f")[t]||a(this,_e,"f")[t];if(a(this,tt,"f")[t])delete a(this,tt,"f")[t];let r={};return a(this,_e,"f")[t]=(n||[]).concat(e).filter((i)=>{if(r[i])return!1;return r[i]=!0}),this}hide(e){return x("<string>",[e],arguments.length),a(this,B,"f").hiddenOptions.push(e),this}implies(e,t){return x("<string|object> [number|string|array]",[e,t],arguments.length),a(this,q,"f").implies(e,t),this}locale(e){if(x("[string]",[e],arguments.length),e===void 0)return this[Nn](),a(this,M,"f").y18n.getLocale();return S(this,Ze,!1,"f"),a(this,M,"f").y18n.setLocale(e),this}middleware(e,t,n){return a(this,Ee,"f").addMiddleware(e,!!t,n)}nargs(e,t){return x("<string|object|array> [number]",[e,t],arguments.length),this[gt](this.nargs.bind(this),"narg",e,t),this}normalize(e){return x("<array|string>",[e],arguments.length),this[He]("normalize",e),this}number(e){return x("<array|string>",[e],arguments.length),this[He]("number",e),this[at](e),this}option(e,t){if(x("<string|object> [object]",[e,t],arguments.length),typeof e==="object")Object.keys(e).forEach((n)=>{this.options(n,e[n])});else{if(typeof t!=="object")t={};if(this[at](e),a(this,Be,"f")&&(e==="version"||(t===null||t===void 0?void 0:t.alias)==="version"))this[Si](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
79
+ `),void 0,"versionWarning");if(a(this,B,"f").key[e]=!0,t.alias)this.alias(e,t.alias);let n=t.deprecate||t.deprecated;if(n)this.deprecateOption(e,n);let r=t.demand||t.required||t.require;if(r)this.demand(e,r);if(t.demandOption)this.demandOption(e,typeof t.demandOption==="string"?t.demandOption:void 0);if(t.conflicts)this.conflicts(e,t.conflicts);if("default"in t)this.default(e,t.default);if(t.implies!==void 0)this.implies(e,t.implies);if(t.nargs!==void 0)this.nargs(e,t.nargs);if(t.config)this.config(e,t.configParser);if(t.normalize)this.normalize(e);if(t.choices)this.choices(e,t.choices);if(t.coerce)this.coerce(e,t.coerce);if(t.group)this.group(e,t.group);if(t.boolean||t.type==="boolean"){if(this.boolean(e),t.alias)this.boolean(t.alias)}if(t.array||t.type==="array"){if(this.array(e),t.alias)this.array(t.alias)}if(t.number||t.type==="number"){if(this.number(e),t.alias)this.number(t.alias)}if(t.string||t.type==="string"){if(this.string(e),t.alias)this.string(t.alias)}if(t.count||t.type==="count")this.count(e);if(typeof t.global==="boolean")this.global(e,t.global);if(t.defaultDescription)a(this,B,"f").defaultDescription[e]=t.defaultDescription;if(t.skipValidation)this.skipValidation(e);let i=t.describe||t.description||t.desc,s=a(this,R,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(s,e)||typeof i==="string")this.describe(e,i);if(t.hidden)this.hide(e);if(t.requiresArg)this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){if(x("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[Ai](),typeof e>"u")e=a(this,We,"f");if(typeof t==="object")S(this,et,t,"f"),t=n;if(typeof t==="function")S(this,Fe,t,"f"),t=!1;if(!t)S(this,We,e,"f");if(a(this,Fe,"f"))S(this,be,!1,"f");let r=this[Pt](e,!!t),i=this.parsed;if(a(this,De,"f").setParsed(this.parsed),J(r))return r.then((s)=>{if(a(this,Fe,"f"))a(this,Fe,"f").call(this,a(this,Le,"f"),s,a(this,ae,"f"));return s}).catch((s)=>{if(a(this,Fe,"f"))a(this,Fe,"f")(s,this.parsed.argv,a(this,ae,"f"));throw s}).finally(()=>{this[Hn](),this.parsed=i});else{if(a(this,Fe,"f"))a(this,Fe,"f").call(this,a(this,Le,"f"),r,a(this,ae,"f"));this[Hn](),this.parsed=i}return r}parseAsync(e,t,n){let r=this.parse(e,t,n);return!J(r)?Promise.resolve(r):r}parseSync(e,t,n){let r=this.parse(e,t,n);if(J(r))throw new Q(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return r}parserConfiguration(e){return x("<object>",[e],arguments.length),S(this,Kt,e,"f"),this}pkgConf(e,t){x("<string> [string]",[e,t],arguments.length);let n=null,r=this[Rn](t||a(this,Xe,"f"));if(r[e]&&typeof r[e]==="object")n=Vt(r[e],t||a(this,Xe,"f"),this[st]()["deep-merge-config"]||!1,a(this,M,"f")),a(this,B,"f").configObjects=(a(this,B,"f").configObjects||[]).concat(n);return this}positional(e,t){x("<string> <object>",[e,t],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=Ie(t,(s,o)=>{if(s==="type"&&!["string","number","boolean"].includes(o))return!1;return n.includes(s)});let r=a(this,At,"f").fullCommands[a(this,At,"f").fullCommands.length-1],i=r?a(this,ee,"f").cmdToParseOptions(r):{array:[],alias:{},default:{},demand:{}};return ft(i).forEach((s)=>{let o=i[s];if(Array.isArray(o)){if(o.indexOf(e)!==-1)t[s]=!0}else if(o[e]&&!(s in t))t[s]=o[e]}),this.group(e,a(this,R,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return x("[boolean]",[e],arguments.length),S(this,qt,e,"f"),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){if(x("<array|string|object> [number]",[e],arguments.length),typeof e==="string"&&a(this,B,"f").narg[e])return this;else this[gt](this.requiresArg.bind(this),"narg",e,NaN);return this}showCompletionScript(e,t){return x("[string] [string]",[e,t],arguments.length),e=e||this.$0,a(this,Qe,"f").log(a(this,De,"f").generateCompletionScript(e,t||a(this,pe,"f")||"completion")),this}showHelp(e){if(x("[string|function]",[e],arguments.length),S(this,me,!0,"f"),!a(this,R,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[Pt](a(this,We,"f"),void 0,void 0,0,!0);if(J(n))return n.then(()=>{a(this,R,"f").showHelp(e)}),this}let t=a(this,ee,"f").runDefaultBuilderOn(this);if(J(t))return t.then(()=>{a(this,R,"f").showHelp(e)}),this}return a(this,R,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return x("[boolean|string] [string]",[e,t],arguments.length),a(this,R,"f").showHelpOnFail(e,t),this}showVersion(e){return x("[string|function]",[e],arguments.length),a(this,R,"f").showVersion(e),this}skipValidation(e){return x("<array|string>",[e],arguments.length),this[He]("skipValidation",e),this}strict(e){return x("[boolean]",[e],arguments.length),S(this,nt,e!==!1,"f"),this}strictCommands(e){return x("[boolean]",[e],arguments.length),S(this,rt,e!==!1,"f"),this}strictOptions(e){return x("[boolean]",[e],arguments.length),S(this,it,e!==!1,"f"),this}string(e){return x("<array|string>",[e],arguments.length),this[He]("string",e),this[at](e),this}terminalWidth(){return x([],0),a(this,M,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return x("<object>",[e],arguments.length),S(this,Ze,!1,"f"),a(this,M,"f").y18n.updateLocale(e),this}usage(e,t,n,r){if(x("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,r],arguments.length),t!==void 0)if(he(e,null,a(this,M,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,r);else throw new Q(".usage() description must start with $0 if being used as alias for .command()");else return a(this,R,"f").usage(e),this}usageConfiguration(e){return x("<object>",[e],arguments.length),S(this,Xt,e,"f"),this}version(e,t,n){if(x("[boolean|string] [string] [string]",[e,t,n],arguments.length),a(this,Be,"f"))this[Mn](a(this,Be,"f")),a(this,R,"f").version(void 0),S(this,Be,null,"f");if(arguments.length===0)n=this[Bi](),e="version";else if(arguments.length===1){if(e===!1)return this;n=e,e="version"}else if(arguments.length===2)n=t,t=void 0;return S(this,Be,typeof e==="string"?e:"version","f"),t=t||a(this,R,"f").deferY18nLookup("Show version number"),a(this,R,"f").version(n||void 0),this.boolean(a(this,Be,"f")),this.describe(a(this,Be,"f"),t),this}wrap(e){return x("<number|null|undefined>",[e],arguments.length),a(this,R,"f").wrap(e),this}[(ee=new WeakMap,Xe=new WeakMap,At=new WeakMap,De=new WeakMap,pe=new WeakMap,zt=new WeakMap,Le=new WeakMap,Ze=new WeakMap,Gt=new WeakMap,be=new WeakMap,Ut=new WeakMap,Ee=new WeakMap,_e=new WeakMap,me=new WeakMap,Ce=new WeakMap,Yt=new WeakMap,Qe=new WeakMap,ae=new WeakMap,B=new WeakMap,Jt=new WeakMap,Kt=new WeakMap,Fe=new WeakMap,et=new WeakMap,Dt=new WeakMap,tt=new WeakMap,We=new WeakMap,qt=new WeakMap,M=new WeakMap,nt=new WeakMap,rt=new WeakMap,it=new WeakMap,R=new WeakMap,Xt=new WeakMap,Be=new WeakMap,q=new WeakMap,wi)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch(t){}return e}[xi](){return{log:(...e)=>{if(!this[Zt]())console.log(...e);if(S(this,me,!0,"f"),a(this,ae,"f").length)S(this,ae,a(this,ae,"f")+`
80
+ `,"f");S(this,ae,a(this,ae,"f")+e.join(" "),"f")},error:(...e)=>{if(!this[Zt]())console.error(...e);if(S(this,me,!0,"f"),a(this,ae,"f").length)S(this,ae,a(this,ae,"f")+`
81
+ `,"f");S(this,ae,a(this,ae,"f")+e.join(" "),"f")}}}[Mn](e){ft(a(this,B,"f")).forEach((t)=>{if(((r)=>r==="configObjects")(t))return;let n=a(this,B,"f")[t];if(Array.isArray(n)){if(n.includes(e))n.splice(n.indexOf(e),1)}else if(typeof n==="object")delete n[e]}),delete a(this,R,"f").getDescriptions()[e]}[Si](e,t,n){if(!a(this,Gt,"f")[n])a(this,M,"f").process.emitWarning(e,t),a(this,Gt,"f")[n]=!0}[Ai](){a(this,Ut,"f").push({options:a(this,B,"f"),configObjects:a(this,B,"f").configObjects.slice(0),exitProcess:a(this,be,"f"),groups:a(this,_e,"f"),strict:a(this,nt,"f"),strictCommands:a(this,rt,"f"),strictOptions:a(this,it,"f"),completionCommand:a(this,pe,"f"),output:a(this,ae,"f"),exitError:a(this,Le,"f"),hasOutput:a(this,me,"f"),parsed:this.parsed,parseFn:a(this,Fe,"f"),parseContext:a(this,et,"f")}),a(this,R,"f").freeze(),a(this,q,"f").freeze(),a(this,ee,"f").freeze(),a(this,Ee,"f").freeze()}[Pi](){let e="",t;if(/\b(node|iojs|electron|bun)(\.exe)?$/.test(a(this,M,"f").process.argv()[0]))t=a(this,M,"f").process.argv().slice(1,2);else t=a(this,M,"f").process.argv().slice(0,1);if(e=t.map((n)=>{let r=this[Li](a(this,Xe,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&r.length<n.length?r:n}).join(" ").trim(),a(this,M,"f").getEnv("_")&&a(this,M,"f").getProcessArgvBin()===a(this,M,"f").getEnv("_"))e=a(this,M,"f").getEnv("_").replace(`${a(this,M,"f").path.dirname(a(this,M,"f").process.execPath())}/`,"");return e}[st](){return a(this,Kt,"f")}[_i](){return a(this,Xt,"f")}[Nn](){if(!a(this,Ze,"f"))return;let e=a(this,M,"f").getEnv("LC_ALL")||a(this,M,"f").getEnv("LC_MESSAGES")||a(this,M,"f").getEnv("LANG")||a(this,M,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[Bi](){return this[Rn]().version||"unknown"}[Oi](e){let t=e["--"]?e["--"]:e._;for(let n=0,r;(r=t[n])!==void 0;n++)if(a(this,M,"f").Parser.looksLikeNumber(r)&&Number.isSafeInteger(Math.floor(parseFloat(`${r}`))))t[n]=Number(r);return e}[Rn](e){let t=e||"*";if(a(this,Dt,"f")[t])return a(this,Dt,"f")[t];let n={};try{let r=e||a(this,M,"f").mainFilename;if(a(this,M,"f").path.extname(r))r=a(this,M,"f").path.dirname(r);let i=a(this,M,"f").findUp(r,(s,o)=>{if(o.includes("package.json"))return"package.json";else return});he(i,void 0,a(this,M,"f")),n=JSON.parse(a(this,M,"f").readFileSync(i,"utf8"))}catch(r){}return a(this,Dt,"f")[t]=n||{},a(this,Dt,"f")[t]}[He](e,t){t=[].concat(t),t.forEach((n)=>{n=this[Ln](n),a(this,B,"f")[e].push(n)})}[gt](e,t,n,r){this[Tn](e,t,n,r,(i,s,o)=>{a(this,B,"f")[i][s]=o})}[In](e,t,n,r){this[Tn](e,t,n,r,(i,s,o)=>{a(this,B,"f")[i][s]=(a(this,B,"f")[i][s]||[]).concat(o)})}[Tn](e,t,n,r,i){if(Array.isArray(n))n.forEach((s)=>{e(s,r)});else if(((s)=>typeof s==="object")(n))for(let s of ft(n))e(s,n[s]);else i(t,this[Ln](n),r)}[Ln](e){if(e==="__proto__")return"___proto___";return e}[Wn](e,t){return this[gt](this[Wn].bind(this),"key",e,t),this}[Hn](){var e,t,n,r,i,s,o,u,c,p,b,g;let D=a(this,Ut,"f").pop();he(D,void 0,a(this,M,"f"));let F;e=this,t=this,n=this,r=this,i=this,s=this,o=this,u=this,c=this,p=this,b=this,g=this,{options:{set value(y){S(e,B,y,"f")}}.value,configObjects:F,exitProcess:{set value(y){S(t,be,y,"f")}}.value,groups:{set value(y){S(n,_e,y,"f")}}.value,output:{set value(y){S(r,ae,y,"f")}}.value,exitError:{set value(y){S(i,Le,y,"f")}}.value,hasOutput:{set value(y){S(s,me,y,"f")}}.value,parsed:this.parsed,strict:{set value(y){S(o,nt,y,"f")}}.value,strictCommands:{set value(y){S(u,rt,y,"f")}}.value,strictOptions:{set value(y){S(c,it,y,"f")}}.value,completionCommand:{set value(y){S(p,pe,y,"f")}}.value,parseFn:{set value(y){S(b,Fe,y,"f")}}.value,parseContext:{set value(y){S(g,et,y,"f")}}.value}=D,a(this,B,"f").configObjects=F,a(this,R,"f").unfreeze(),a(this,q,"f").unfreeze(),a(this,ee,"f").unfreeze(),a(this,Ee,"f").unfreeze()}[$i](e,t){return qe(t,(n)=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[vi].bind(this),getContext:this[ji].bind(this),getHasOutput:this[ki].bind(this),getLoggerInstance:this[Mi].bind(this),getParseContext:this[Ni].bind(this),getParserConfiguration:this[st].bind(this),getUsageConfiguration:this[_i].bind(this),getUsageInstance:this[Ri].bind(this),getValidationInstance:this[Ii].bind(this),hasParseCallback:this[Zt].bind(this),isGlobalContext:this[Ti].bind(this),postProcess:this[ot].bind(this),reset:this[Vn].bind(this),runValidation:this[zn].bind(this),runYargsParserAndExecuteCommands:this[Pt].bind(this),setHasOutput:this[Wi].bind(this)}}[vi](){return a(this,ee,"f")}[ji](){return a(this,At,"f")}[ki](){return a(this,me,"f")}[Mi](){return a(this,Qe,"f")}[Ni](){return a(this,et,"f")||{}}[Ri](){return a(this,R,"f")}[Ii](){return a(this,q,"f")}[Zt](){return!!a(this,Fe,"f")}[Ti](){return a(this,Yt,"f")}[ot](e,t,n,r){if(n)return e;if(J(e))return e;if(!t)e=this[wi](e);if(this[st]()["parse-positional-numbers"]||this[st]()["parse-positional-numbers"]===void 0)e=this[Oi](e);if(r)e=Ke(e,this,a(this,Ee,"f").getMiddleware(),!1);return e}[Vn](e={}){S(this,B,a(this,B,"f")||{},"f");let t={};t.local=a(this,B,"f").local||[],t.configObjects=a(this,B,"f").configObjects||[];let n={};t.local.forEach((s)=>{n[s]=!0,(e[s]||[]).forEach((o)=>{n[o]=!0})}),Object.assign(a(this,tt,"f"),Object.keys(a(this,_e,"f")).reduce((s,o)=>{let u=a(this,_e,"f")[o].filter((c)=>!(c in n));if(u.length>0)s[o]=u;return s},{})),S(this,_e,{},"f");let r=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],i=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(r.forEach((s)=>{t[s]=(a(this,B,"f")[s]||[]).filter((o)=>!n[o])}),i.forEach((s)=>{t[s]=Ie(a(this,B,"f")[s],(o)=>!n[o])}),t.envPrefix=a(this,B,"f").envPrefix,S(this,B,t,"f"),S(this,R,a(this,R,"f")?a(this,R,"f").reset(n):Di(this,a(this,M,"f")),"f"),S(this,q,a(this,q,"f")?a(this,q,"f").reset(n):Ei(this,a(this,R,"f"),a(this,M,"f")),"f"),S(this,ee,a(this,ee,"f")?a(this,ee,"f").reset():di(a(this,R,"f"),a(this,q,"f"),a(this,Ee,"f"),a(this,M,"f")),"f"),!a(this,De,"f"))S(this,De,Fi(this,a(this,R,"f"),a(this,ee,"f"),a(this,M,"f")),"f");return a(this,Ee,"f").reset(),S(this,pe,null,"f"),S(this,ae,"","f"),S(this,Le,null,"f"),S(this,me,!1,"f"),this.parsed=!1,this}[Li](e,t){return a(this,M,"f").path.relative(e,t)}[Pt](e,t,n,r=0,i=!1){var s,o,u,c;let p=!!n||i;e=e||a(this,We,"f"),a(this,B,"f").__=a(this,M,"f").y18n.__,a(this,B,"f").configuration=this[st]();let b=!!a(this,B,"f").configuration["populate--"],g=Object.assign({},a(this,B,"f").configuration,{"populate--":!0}),D=a(this,M,"f").Parser.detailed(e,Object.assign({},a(this,B,"f"),{configuration:{"parse-positional-numbers":!1,...g}})),F=Object.assign(D.argv,a(this,et,"f")),y=void 0,h=D.aliases,v=!1,W=!1;if(Object.keys(F).forEach((T)=>{if(T===a(this,Ce,"f")&&F[T])v=!0;else if(T===a(this,Be,"f")&&F[T])W=!0}),F.$0=this.$0,this.parsed=D,r===0)a(this,R,"f").clearCachedHelpMessage();try{if(this[Nn](),t)return this[ot](F,b,!!n,!1);if(a(this,Ce,"f")){if([a(this,Ce,"f")].concat(h[a(this,Ce,"f")]||[]).filter((ne)=>ne.length>1).includes(""+F._[F._.length-1]))F._.pop(),v=!0}S(this,Yt,!1,"f");let T=a(this,ee,"f").getCommands(),ce=((s=a(this,De,"f"))===null||s===void 0?void 0:s.completionKey)?[(o=a(this,De,"f"))===null||o===void 0?void 0:o.completionKey,...(c=this.getAliases()[(u=a(this,De,"f"))===null||u===void 0?void 0:u.completionKey])!==null&&c!==void 0?c:[]].some((Y)=>Object.prototype.hasOwnProperty.call(F,Y)):!1,I=v||ce||i;if(F._.length){if(T.length){let Y;for(let ne=r||0,X;F._[ne]!==void 0;ne++)if(X=String(F._[ne]),T.includes(X)&&X!==a(this,pe,"f")){let Pe=a(this,ee,"f").runCommand(X,this,D,ne+1,i,v||W||i);return this[ot](Pe,b,!!n,!1)}else if(!Y&&X!==a(this,pe,"f")){Y=X;break}if(!a(this,ee,"f").hasDefaultCommand()&&a(this,qt,"f")&&Y&&!I)a(this,q,"f").recommendCommands(Y,T)}if(a(this,pe,"f")&&F._.includes(a(this,pe,"f"))&&!ce){if(a(this,be,"f"))Te(!0);this.showCompletionScript(),this.exit(0)}}if(a(this,ee,"f").hasDefaultCommand()&&!I){let Y=a(this,ee,"f").runCommand(null,this,D,0,i,v||W||i);return this[ot](Y,b,!!n,!1)}if(ce){if(a(this,be,"f"))Te(!0);e=[].concat(e);let Y=e.slice(e.indexOf(`--${a(this,De,"f").completionKey}`)+1);return a(this,De,"f").getCompletion(Y,(ne,X)=>{if(ne)throw new Q(ne.message);(X||[]).forEach((Pe)=>{a(this,Qe,"f").log(Pe)}),this.exit(0)}),this[ot](F,!b,!!n,!1)}if(!a(this,me,"f")){if(v){if(a(this,be,"f"))Te(!0);p=!0,this.showHelp((Y)=>{a(this,Qe,"f").log(Y),this.exit(0)})}else if(W){if(a(this,be,"f"))Te(!0);p=!0,a(this,R,"f").showVersion("log"),this.exit(0)}}if(!p&&a(this,B,"f").skipValidation.length>0)p=Object.keys(F).some((Y)=>a(this,B,"f").skipValidation.indexOf(Y)>=0&&F[Y]===!0);if(!p){if(D.error)throw new Q(D.error.message);if(!ce){let Y=this[zn](h,{},D.error);if(!n)y=Ke(F,this,a(this,Ee,"f").getMiddleware(),!0);if(y=this[$i](Y,y!==null&&y!==void 0?y:F),J(y)&&!n)y=y.then(()=>Ke(F,this,a(this,Ee,"f").getMiddleware(),!1))}}}catch(T){if(T instanceof Q)a(this,R,"f").fail(T.message,T);else throw T}return this[ot](y!==null&&y!==void 0?y:F,b,!!n,!0)}[zn](e,t,n,r){let i={...this.getDemandedOptions()};return(s)=>{if(n)throw new Q(n.message);a(this,q,"f").nonOptionCount(s),a(this,q,"f").requiredArguments(s,i);let o=!1;if(a(this,rt,"f"))o=a(this,q,"f").unknownCommands(s);if(a(this,nt,"f")&&!o)a(this,q,"f").unknownArguments(s,e,t,!!r);else if(a(this,it,"f"))a(this,q,"f").unknownArguments(s,e,{},!1,!1);a(this,q,"f").limitedChoices(s),a(this,q,"f").implications(s),a(this,q,"f").conflicting(s)}}[Wi](){S(this,me,!0,"f")}[at](e){if(typeof e==="string")a(this,B,"f").key[e]=!0;else for(let t of e)a(this,B,"f").key[t]=!0}}function fi(e){return!!e&&typeof e.getInternalMethods==="function"}var au=Hi(si),zi=au;var Gi={name:"@coryrylan/cradle",version:"1.4.0",description:"A runtime for portable agents defined as folders \u2014 launches the pi coding agent configured from an agent folder, sandboxed with nono",main:"./dist/index.js",module:"./dist/index.js",types:"./dist/index.d.ts",type:"module",exports:{".":{types:"./dist/index.d.ts",default:"./dist/index.js"}},bin:{cradle:"dist/index.js"},files:["README.md","CHANGELOG.md","LICENSE","package.json","dist/index.js","dist/**/*.d.ts","!dist/**/*.test.d.ts"],repository:{type:"git",url:"git+https://github.com/coryrylan/cradle.git",directory:"projects/cli"},keywords:["pi","agents","agent-folders","sandbox","nono","cli","bun"],author:"Cory Rylan (https://coryrylan.com)",license:"MIT",bugs:{url:"https://github.com/coryrylan/cradle/issues"},homepage:"https://github.com/coryrylan/cradle/tree/main/projects/cli#readme",engines:{bun:">=1.4.2"},publishConfig:{access:"public"},scripts:{start:"wireit",ci:"wireit","ci:nocache":"bun run clean && bun run ci",clean:"rm -rf dist",test:"wireit","test:coverage":"wireit",lint:"wireit",build:"wireit","install:local":"wireit","uninstall:local":"wireit",release:"wireit"},wireit:{start:{command:"bun src/index.ts",cache:!1},ci:{dependencies:["lint","build","test:coverage"]},test:{command:"bun test",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json","bunfig.toml"],output:[]},"test:coverage":{command:"bun test --coverage",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json","bunfig.toml"],output:[]},lint:{command:"eslint .",files:["src/**/*.ts","eslint.config.js","package.json"],output:[]},build:{dependencies:["build:js","build:tsc","build:darwin-arm64","build:darwin-x64","build:linux-x64","build:linux-arm64","build:windows-x64"]},"build:js":{command:"bun build ./src/index.ts --outdir=./dist --target=bun --format=esm --minify",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/index.js"]},"build:tsc":{command:"tsc --emitDeclarationOnly --project tsconfig.types.json",files:["src/**/*.ts","src/**/*.json","tsconfig.json","tsconfig.types.json"],output:["dist/**/*.d.ts"]},"build:darwin-arm64":{command:"bun build --compile --minify src/index.ts --target=bun-darwin-arm64 --outfile dist/cradle-macos-arm64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-macos-arm64"]},"build:darwin-x64":{command:"bun build --compile --minify src/index.ts --target=bun-darwin-x64 --outfile dist/cradle-macos-x64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-macos-x64"]},"build:linux-x64":{command:"bun build --compile --minify src/index.ts --target=bun-linux-x64 --outfile dist/cradle-linux-x64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-linux-x64"]},"build:linux-arm64":{command:"bun build --compile --minify src/index.ts --target=bun-linux-arm64 --outfile dist/cradle-linux-arm64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-linux-arm64"]},"build:windows-x64":{command:"bun build --compile --minify src/index.ts --target=bun-windows-x64 --outfile dist/cradle-windows-x64.exe",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-windows-x64.exe"]},"install:local":{dependencies:["build"],command:"bash install.sh",cache:!1},"uninstall:local":{command:'rm -f "$HOME/.local/bin/cradle"',cache:!1},release:{command:"HUSKY=0 bun x semantic-release",dependencies:["ci"]}},dependencies:{yargs:"^18.1.0"},devDependencies:{"@coryrylan/tools":"1.1.1","@eslint/js":"catalog:","@eslint/json":"2.0.1","@types/bun":"catalog:","@types/yargs":"17.0.35",eslint:"catalog:","eslint-plugin-jsdoc":"64.2.1",typescript:"catalog:","typescript-eslint":"catalog:"}};import{join as Yi}from"path";var Qt="agent-browser-nono-fallback.ts";function Ui(){return`// generated by cradle for sandboxed agent-browser processes \u2014 do not edit
82
82
  import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
83
83
 
84
84
  export default function configureAgentBrowserNonoEnvironment(_pi: ExtensionAPI): void {
@@ -95,18 +95,38 @@ export default function configureAgentBrowserNonoEnvironment(_pi: ExtensionAPI):
95
95
  process.env.AGENT_BROWSER_PROXY = nonoProxy;
96
96
  }
97
97
  }
98
- `}function bu(e){let t=[];if(e.systemFilePath!==null)t.push("--system-prompt",e.systemFilePath);if(e.appendSystemFilePath!==null)t.push("--append-system-prompt",e.appendSystemFilePath);return t}function Eu(e){let{folder:t}=e,{settings:n}=t,i=[e.piBin,...bu(t),"--no-extensions","--no-skills","--no-prompt-templates"];if(t.providersJson!==null)i.push("-e",_r(e.extensionsDir,"providers.ts"));if(e.backend==="nono")i.push("-e",_r(e.extensionsDir,Ut));for(let r of e.packageEntries??[])i.push("-e",r);for(let r of t.extensionFiles)i.push("-e",r);if(t.skillsDir!==null)i.push("--skill",t.skillsDir);if(n.defaultProvider!==void 0)i.push("--provider",n.defaultProvider);if(n.defaultModel!==void 0)i.push("--model",n.defaultModel);if(n.defaultThinkingLevel!==void 0)i.push("--thinking",n.defaultThinkingLevel);return i.push("--session-dir",e.sessionsDir),i.push(...e.passthrough),i}function On(e){return e.backend==="nono"?{MISE_CACHE_DIR:e.miseCacheDir}:{}}function ft(e){let t=Eu(e);if(e.backend!=="nono")return t;return[e.nonoBin,"run",...e.verbose===!0?[]:["--silent"],"--profile",e.profilePath,"--",...t]}import{existsSync as yu}from"fs";import{homedir as Cu}from"os";import{join as xu}from"path";function wu(e,t=Cu()){let n=xu(t,".local","share","mise","shims",e);return yu(n)?n:null}var Sr=(e)=>Bun.which(e)??wu(e);function jn(e,t=Sr){return t(e)}function Yt(e,t=Sr){let n=jn(e,t);if(!n)throw Error(`Required executable "${e}" not found on PATH \u2014 install it, then run \`cradle doctor\` to verify`);return n}var Au="recommended: the supported way to install pi/nono \u2014 cradle resolves them from mise shims and the sandbox profile assumes a mise-managed install",_u="required for sandboxed runs (a folder declaring sandbox/nono.json, or --sandbox/--offline/--allow-host); not needed otherwise",Su="required for sbx-backend runs (a folder declaring sandbox/sbx.json, or --sandbox-backend sbx); not needed otherwise";async function Br(e={}){let t=(h)=>jn(h,e.which),n=async(h,p)=>h!==null&&e.readVersion?e.readVersion(h,p):null,i=t("pi"),r=t("nono"),s=t("sbx"),o=t("mise"),[a,c,g,E]=await Promise.all([n(i),n(r),n(s,["version"]),n(o)]);return[{name:"pi",bin:"pi",required:!0,found:i,version:a},{name:"nono",bin:"nono",required:!1,found:r,version:c,...r?{}:{note:_u}},{name:"sbx",bin:"sbx",required:!1,found:s,version:g,...s?{}:{note:Su}},{name:"mise",bin:"mise",required:!1,found:o,version:E,...o?{}:{note:Au}}]}function Bu(e){let t=e.found?`\u2713 ${e.name.padEnd(8)} ${e.version??"?"} ${e.found}`:e.required?`\u2717 ${e.name.padEnd(8)} MISSING (required)`:`\u25CB ${e.name.padEnd(8)} not found (recommended)`;return e.note?`${t}
99
- \u26A0 ${e.note}`:t}function Pr(e){return e.map(Bu).join(`
100
- `)}function Or(e){return e.some((t)=>t.required&&!t.found)?1:0}import{exists as Fl,mkdir as Ln,rm as bl,writeFile as Ss}from"fs/promises";import{homedir as El}from"os";import{basename as yl,dirname as Cl,join as St}from"path";import{stat as zu}from"fs/promises";import{join as Wr,resolve as Uu}from"path";import{basename as Ou,isAbsolute as ju,join as vu,relative as $u}from"path";var yt={extends:"default",meta:{name:"cradle-pi"},groups:{include:["node_runtime","git_config","unlink_protection"]},filesystem:{read:["$HOME/.agents","$HOME/.local/share/mise","$HOME/.config/mise","$HOME/.local/state/mise","$HOME/.config/gh","/System/iOSSupport/System/Library/ExtensionKit/Extensions","/System/Library/AssetsV2/com_apple_MobileAsset_TTSAXResourceModelAssets","/System/Library/AssetsV2/com_apple_MobileAsset_UAF_Siri_TextToSpeech"],allow:["$HOME/.pi/agent"]},unsafe_macos_seatbelt_rules:['(allow user-preference-read (preference-domain "kCFPreferencesAnyApplication") (preference-domain "com.apple.speech.voice.prefs") (preference-domain "com.apple.speakselection") (preference-domain "com.apple.assistant.backedup") (preference-domain "com.apple.assistant.support") (preference-domain "com.apple.accessibility"))']};var jr="nono-profile.json";function Jt(e,t){let n=$u(e,t);return n===""||!n.startsWith("..")&&!ju(n)}function vr(e,t){let n=vu(t,".local","state","nono");return Jt(e,n)||Jt(n,e)?e:void 0}function Ct(e,t){if(e==="~"||e==="$HOME")return t;if(e.startsWith("~/"))return`${t}${e.slice(1)}`;if(e.startsWith("$HOME/"))return`${t}${e.slice(5)}`;return e}function $r(e){let t=(o)=>Ct(o,e.home),n=yt.filesystem,i=e.network!==void 0?ku(e.network):void 0,r=[...n.unix_socket_dir_bind??[],...e.grants.unixSocketDirBind.map(t)],s={...yt,meta:{...yt.meta,name:`cradle-${Ou(e.stateDir)}`},filesystem:{...n,read:[...n.read??[],e.agentDir,...e.grants.read.map(t)],write:[...n.write??[],...e.grants.write.map(t)],allow:[...n.allow??[],e.cwd,e.stateDir,...e.linkedGitDir!==void 0?[e.linkedGitDir]:[],...e.grants.allow.map(t)],...r.length>0?{unix_socket_dir_bind:r}:{}},unsafe_macos_seatbelt_rules:[...yt.unsafe_macos_seatbelt_rules,...e.rules],...i!==void 0?{network:i}:{}};return JSON.stringify(s,null,2)}function ku(e){return{...e.block!==void 0?{block:e.block}:{},...e.networkProfile!==void 0?{network_profile:e.networkProfile}:{},...e.allowDomain!==void 0?{allow_domain:e.allowDomain}:{},...e.openPort!==void 0?{open_port:e.openPort}:{},...e.listenPort!==void 0?{listen_port:e.listenPort}:{}}}import{chmod as kr,lstat as Mu,mkdir as Nu,readdir as Mr,readFile as Iu,rm as Ru,writeFile as Tu}from"fs/promises";import{dirname as Wu,join as qt,relative as Lu}from"path";function le(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function dt(e,t){try{return JSON.parse(e)}catch(n){throw Error(`${t} is not valid JSON: ${rt(n)}`,{cause:n})}}function rt(e){return e instanceof Error?e.message:String(e)}function fe(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}function Dt(e){if(/^[A-Za-z0-9_./:@%+=,-]+$/u.test(e))return e;return`'${e.replaceAll("'","'\\''")}'`}function Le(e){return Array.isArray(e)&&e.every((t)=>typeof t==="string")}function xt(e){return/^(?:\/|~(?:\/|$)|\$HOME(?:\/|$)|[A-Za-z]:[\\/]|\\\\)/.test(e)}function Be(e,t,n,i){let r=Object.keys(e).filter((s)=>!n.includes(s));if(r.length>0)i.push(`${t}: unsupported keys ignored: ${r.join(", ")}`)}function Kt(e,t,n,i){e.results.push({name:t,detail:n,status:i})}function Gu(e,t,n){e.failures.push(`${t}: ${n}`),Kt(e,t,n,"failed")}async function Nr(e,t,n,i){try{if(await Hu(n,i)){Kt(e,t,n,"unchanged");return}if(e.dryRun){Kt(e,t,`would replace ${n}`,"changed");return}await Rr(n),await Ru(n,{force:!0,recursive:!0});for(let r of i)await Vu(n,r);Kt(e,t,n,"changed")}catch(r){Gu(e,t,rt(r))}}async function Vu(e,t){let n=qt(e,t.rel);if(await Nu(Wu(n),{recursive:!0}),await Tu(n,t.content,"utf8"),t.mode!==void 0)await kr(n,t.mode)}async function Hu(e,t){let n=await Ir(e);if(n.length!==t.length)return!1;let i=new Set(n);for(let r of t){if(!i.has(r.rel))return!1;if(await $e(qt(e,r.rel))!==r.content)return!1}return!0}async function Ir(e,t=e){let n=await Tr(e);if(!n||!n.isDirectory())return[];let i=[];for(let r of await Mr(e,{withFileTypes:!0})){let s=qt(e,r.name);if(r.isDirectory())i.push(...await Ir(s,t));else i.push(Lu(t,s))}return i}async function Rr(e){let t=await Tr(e);if(!t||t.isSymbolicLink())return;if(await kr(e,t.isDirectory()?493:420),!t.isDirectory())return;let n=await Mr(e);await Promise.all(n.map((i)=>Rr(qt(e,i))))}async function $e(e){try{return await Iu(e,"utf8")}catch(t){if(fe(t,"ENOENT"))return;throw t}}async function Tr(e){try{return await Mu(e)}catch(t){if(fe(t,"ENOENT"))return;throw t}}var Yu=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function Gr(e,t){if(!Ju(e))return{dir:e,warnings:[]};let n=Wr(t.home,".cradle","settings.json"),i=[],r=await Ku(n,i),s=Wr(t.cwd,e),o=r.get(e);if(o!==void 0){let a=Uu(Ct(o,t.home));if(await Lr(s))i.push(Zu(e,a));return{dir:a,warnings:i}}if(await Lr(s))return{dir:s,warnings:i};throw Error(Qu(e,s,n,r))}function Ju(e){return Yu.test(e)}async function Lr(e){try{return(await zu(e)).isDirectory()}catch(t){if(fe(t,"ENOENT")||fe(t,"ENOTDIR"))return!1;throw t}}async function Ku(e,t){let n=await $e(e);if(n===void 0)return new Map;let i=dt(n,e);if(!le(i))return t.push(`${e}: settings must be a JSON object \u2014 ignored`),new Map;return Be(i,e,["agents"],t),qu(i,e,t)}function qu(e,t,n){let i=e.agents;if(i===void 0)return new Map;if(!le(i))return n.push(`${t}: agents must be an object \u2014 ignored`),new Map;let r=Object.entries(i).map((s)=>{let[o,a]=s,c=Xu(a,o,t,n);return c===void 0?void 0:[o,c]}).filter((s)=>s!==void 0);return new Map(r)}function Xu(e,t,n,i){if(!le(e)){i.push(`${n}: agents.${t} must be an object with a "path" \u2014 ignored`);return}let r=e.path;if(typeof r!=="string"||r.trim()===""){i.push(`${n}: agents.${t}.path must be a non-empty string \u2014 ignored`);return}if(!xt(r)){i.push(`${n}: agents.${t}.path must be an absolute, ~/, or $HOME/ path \u2014 ignored: ${r}`);return}return r}function Zu(e,t){return`started alias "${e}" (${t}) \u2014 a directory named ${e} exists in the current directory; use ./${e} to run it instead`}function Qu(e,t,n,i){let r=i.size>0?` (known agents: ${[...i.keys()].join(", ")})`:"";return`Agent folder not found: ${t} \u2014 and no "agents.${e}" entry in ${n}${r}`}import{createHash as ea}from"crypto";import{join as ta}from"path";var Hr="host.docker.internal",Vr="@earendil-works/pi-coding-agent",na=/^\d+\.\d+\.\d+\.\d+$/,ia=new Set(["localhost","127.0.0.1"]);function zr(e){let t=(i)=>Ct(i,e.home),n=[{path:e.cwd,readonly:!1},{path:e.agentDir,readonly:!0},{path:e.stateDir,readonly:!1},{path:ta(e.home,".pi","agent"),readonly:!1},...e.linkedGitDir!==void 0?[{path:e.linkedGitDir,readonly:!1}]:[],...e.grants.read.map((i)=>({path:t(i),readonly:!0})),...e.grants.write.map((i)=>({path:t(i),readonly:!1})),...e.grants.allow.map((i)=>({path:t(i),readonly:!1}))];return ra(n)}function ra(e){let t=[],n=new Map;for(let i of e){if(!n.has(i.path))t.push(i.path);if(n.get(i.path)!==!1)n.set(i.path,i.readonly)}return t.map((i)=>({path:i,readonly:n.get(i)===!0}))}function Ur(e,t){let n=t.map((r)=>`${r.path}:${r.readonly?"ro":"rw"}`).sort().join("|"),i=ea("sha256").update(n).digest("hex").slice(0,8);return`cradle-${e}-${i}`}function Yr(e){let t=e.mounts.map((n)=>n.readonly?`${n.path}:ro`:n.path);return[e.sbxBin,"create","shell",...t,"--name",e.name,"-q"]}function sa(e){let t=[],n=!1;for(let i of e)if(ia.has(i))n=!0;else if(na.test(i))t.push(i);else t.push(i,`*.${i}`);if(n)t.push(Hr);return t}function Jr(e){let{network:t,sbxBin:n,name:i}=e;if(t===void 0)return[];if(t.block===!0)return[[n,"policy","deny","network","--sandbox",i,"**"]];let r=sa(t.allowDomain??[]);return r.length>0?[[n,"policy","allow","network","--sandbox",i,r.join(",")]]:[]}function oa(e){return e.networkProfile!==void 0?"network_profile is nono-only \u2014 ignored under the sbx backend":void 0}function ua(e){return(e.openPort?.length??0)>0||(e.listenPort?.length??0)>0?"open_port/listen_port are nono-only \u2014 guest-local ports are unrestricted and host services are reachable via host.docker.internal under sbx":void 0}function aa(e){return e.block!==!0&&(e.allowDomain?.length??0)>0?"sbx allow rules add to your global sbx policy but cannot subtract from it \u2014 run `sbx policy init deny-all` for strict allowlist semantics (nono enforces the allowlist exactly)":void 0}function Kr(e){if(e===void 0)return[];return[oa(e),ua(e),aa(e)].filter((t)=>t!==void 0)}function qr(e){return e.unixSocketDirBind.length>0?["unix_socket_dir_bind is nono-only \u2014 Unix sockets cannot cross the sbx VM boundary; grant ignored"]:[]}function vn(e){let t=e.piVersion===null?`command -v pi >/dev/null 2>&1 || npm i -g ${Vr}`:`command -v pi >/dev/null 2>&1 && [ "$(pi --version 2>/dev/null)" = "${e.piVersion}" ] || npm i -g ${Vr}@${e.piVersion}`;return[e.sbxBin,"exec",e.name,"bash","-lc",t]}function Xt(e,t){return[e.sbxBin,"exec","-i",...e.tty?["-t"]:[],"-e",`HOME=${e.home}`,"-w",e.cwd,e.name,...t]}function Xr(e){return e.toLowerCase().includes("already exists")}function Zr(e){let t;try{t=new URL(e)}catch{return e}if(t.hostname!=="localhost"&&t.hostname!=="127.0.0.1")return e;return t.hostname=Hr,t.toString()}function Qr(e,t={}){return`// generated by cradle from the agent folder's models.json \u2014 do not edit
98
+ `}function lu(e){let t=[];if(e.systemFilePath!==null)t.push("--system-prompt",e.systemFilePath);if(e.appendSystemFilePath!==null)t.push("--append-system-prompt",e.appendSystemFilePath);return t}function cu(e){let{folder:t}=e,{settings:n}=t,r=[e.piBin,...lu(t),"--no-extensions","--no-skills","--no-prompt-templates"];if(t.providersJson!==null)r.push("-e",Yi(e.extensionsDir,"providers.ts"));if(e.backend==="nono")r.push("-e",Yi(e.extensionsDir,Qt));for(let i of e.packageEntries??[])r.push("-e",i);for(let i of t.extensionFiles)r.push("-e",i);if(t.skillsDir!==null)r.push("--skill",t.skillsDir);if(n.defaultProvider!==void 0)r.push("--provider",n.defaultProvider);if(n.defaultModel!==void 0)r.push("--model",n.defaultModel);if(n.defaultThinkingLevel!==void 0)r.push("--thinking",n.defaultThinkingLevel);return r.push("--session-dir",e.sessionsDir),r.push(...e.passthrough),r}function Gn(e){return e.backend==="nono"?{MISE_CACHE_DIR:e.miseCacheDir}:{}}function pt(e){let t=cu(e);if(e.backend!=="nono")return t;return[e.nonoBin,"run",...e.verbose===!0?[]:["--silent"],"--profile",e.profilePath,"--",...t]}import{existsSync as du}from"fs";import{homedir as fu}from"os";import{join as hu}from"path";function Du(e,t=fu()){let n=hu(t,".local","share","mise","shims",e);return du(n)?n:null}var Ji=(e)=>Bun.which(e)??Du(e);function _t(e,t=Ji){return t(e)}function mt(e,t=Ji){let n=_t(e,t);if(!n)throw Error(`Required executable "${e}" not found on PATH \u2014 install it, then run \`cradle doctor\` to verify`);return n}var gu="recommended: the supported way to install pi/nono \u2014 cradle resolves them from mise shims and the sandbox profile assumes a mise-managed install",pu="required for sandboxed runs (a folder declaring sandbox/nono.json, or --sandbox/--offline/--allow-host); not needed otherwise",mu="required for sbx-backend runs (a folder declaring sandbox/sbx.json, or --sandbox-backend sbx); not needed otherwise",Fu="recommended for `cradle schedule`: installs schedule/*.md tasks as launchd LaunchAgents; not needed otherwise",yu="recommended for `cradle schedule`: installs schedule/*.md tasks as systemd --user timers; not needed otherwise";function bu(e){if(e==="darwin")return"launchctl";if(e==="linux")return"systemctl";return null}function Eu(e){return e==="launchctl"?Fu:yu}function en(e,t,n,r){return{name:e,bin:e,required:!1,found:t,version:n,...t?{}:{note:r}}}function Cu(e){let t=(r)=>_t(r,e.which),n=bu(e.platform??process.platform);return{piPath:t("pi"),nonoPath:t("nono"),sbxPath:t("sbx"),misePath:t("mise"),scheduleBin:n,schedulePath:n!==null?t(n):null}}async function Ki(e={}){let t=async(c,p)=>c!==null&&e.readVersion?e.readVersion(c,p):null,n=Cu(e),[r,i,s,o,u]=await Promise.all([t(n.piPath),t(n.nonoPath),t(n.sbxPath,["version"]),t(n.misePath),t(n.schedulePath)]);return[{name:"pi",bin:"pi",required:!0,found:n.piPath,version:r},en("nono",n.nonoPath,i,pu),en("sbx",n.sbxPath,s,mu),en("mise",n.misePath,o,gu),...n.scheduleBin!==null?[en(n.scheduleBin,n.schedulePath,u,Eu(n.scheduleBin))]:[]]}var wu=8;function xu(e,t){let n=e.name.padEnd(t),r=e.version!==null?`${e.version} `:"",i=e.found?`\u2713 ${n} ${r}${e.found}`:e.required?`\u2717 ${n} MISSING (required)`:`\u25CB ${n} not found (recommended)`;return e.note?`${i}
99
+ \u26A0 ${e.note}`:i}function qi(e){let t=Math.max(wu,...e.map((n)=>n.name.length));return e.map((n)=>xu(n,t)).join(`
100
+ `)}function Xi(e){return e.some((t)=>t.required&&!t.found)?1:0}import{exists as Js,mkdir as tr,rm as Oc,writeFile as Ks}from"fs/promises";import{homedir as $c}from"os";import{basename as vc,dirname as jc,join as jt}from"path";import{stat as Wu}from"fs/promises";import{join as as,resolve as Hu}from"path";import{basename as Au,isAbsolute as Pu,join as _u,relative as Bu}from"path";var Bt={extends:"default",meta:{name:"cradle-pi"},groups:{include:["node_runtime","git_config","unlink_protection"]},filesystem:{read:["$HOME/.agents","$HOME/.local/share/mise","$HOME/.config/mise","$HOME/.local/state/mise","$HOME/.config/gh","/System/iOSSupport/System/Library/ExtensionKit/Extensions","/System/Library/AssetsV2/com_apple_MobileAsset_TTSAXResourceModelAssets","/System/Library/AssetsV2/com_apple_MobileAsset_UAF_Siri_TextToSpeech"],allow:["$HOME/.pi/agent"]},unsafe_macos_seatbelt_rules:['(allow user-preference-read (preference-domain "kCFPreferencesAnyApplication") (preference-domain "com.apple.speech.voice.prefs") (preference-domain "com.apple.speakselection") (preference-domain "com.apple.assistant.backedup") (preference-domain "com.apple.assistant.support") (preference-domain "com.apple.accessibility"))']};var Zi="nono-profile.json";function tn(e,t){let n=Bu(e,t);return n===""||!n.startsWith("..")&&!Pu(n)}function Qi(e,t){let n=_u(t,".local","state","nono");return tn(e,n)||tn(n,e)?e:void 0}function ut(e,t){if(e==="~"||e==="$HOME")return t;if(e.startsWith("~/"))return`${t}${e.slice(1)}`;if(e.startsWith("$HOME/"))return`${t}${e.slice(5)}`;return e}function es(e){let t=(o)=>ut(o,e.home),n=Bt.filesystem,r=e.network!==void 0?Ou(e.network):void 0,i=[...n.unix_socket_dir_bind??[],...e.grants.unixSocketDirBind.map(t)],s={...Bt,meta:{...Bt.meta,name:`cradle-${Au(e.stateDir)}`},filesystem:{...n,read:[...n.read??[],e.agentDir,...e.grants.read.map(t)],write:[...n.write??[],...e.grants.write.map(t)],allow:[...n.allow??[],e.cwd,e.stateDir,...e.linkedGitDir!==void 0?[e.linkedGitDir]:[],...e.grants.allow.map(t)],...i.length>0?{unix_socket_dir_bind:i}:{}},unsafe_macos_seatbelt_rules:[...Bt.unsafe_macos_seatbelt_rules,...e.rules],...r!==void 0?{network:r}:{}};return JSON.stringify(s,null,2)}function Ou(e){return{...e.block!==void 0?{block:e.block}:{},...e.networkProfile!==void 0?{network_profile:e.networkProfile}:{},...e.allowDomain!==void 0?{allow_domain:e.allowDomain}:{},...e.openPort!==void 0?{open_port:e.openPort}:{},...e.listenPort!==void 0?{listen_port:e.listenPort}:{}}}import{chmod as ts,lstat as $u,mkdir as vu,readdir as ns,readFile as ju,rm as ku,writeFile as Mu}from"fs/promises";import{dirname as Nu,join as rn,relative as Ru}from"path";function le(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Ft(e,t){try{return JSON.parse(e)}catch(n){throw Error(`${t} is not valid JSON: ${Se(n)}`,{cause:n})}}function Se(e){return e instanceof Error?e.message:String(e)}function de(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}function Ve(e){if(/^[A-Za-z0-9_./:@%+=,-]+$/u.test(e))return e;return`'${e.replaceAll("'","'\\''")}'`}function ze(e){return Array.isArray(e)&&e.every((t)=>typeof t==="string")}function lt(e){return/^(?:\/|~(?:\/|$)|\$HOME(?:\/|$)|[A-Za-z]:[\\/]|\\\\)/.test(e)}function Oe(e,t,n,r){let i=Object.keys(e).filter((s)=>!n.includes(s));if(i.length>0)r.push(`${t}: unsupported keys ignored: ${i.join(", ")}`)}function nn(e,t,n,r){e.results.push({name:t,detail:n,status:r})}function Iu(e,t,n){e.failures.push(`${t}: ${n}`),nn(e,t,n,"failed")}async function rs(e,t,n,r){try{if(await Lu(n,r)){nn(e,t,n,"unchanged");return}if(e.dryRun){nn(e,t,`would replace ${n}`,"changed");return}await ss(n),await ku(n,{force:!0,recursive:!0});for(let i of r)await Tu(n,i);nn(e,t,n,"changed")}catch(i){Iu(e,t,Se(i))}}async function Tu(e,t){let n=rn(e,t.rel);if(await vu(Nu(n),{recursive:!0}),await Mu(n,t.content,"utf8"),t.mode!==void 0)await ts(n,t.mode)}async function Lu(e,t){let n=await is(e);if(n.length!==t.length)return!1;let r=new Set(n);for(let i of t){if(!r.has(i.rel))return!1;if(await Ae(rn(e,i.rel))!==i.content)return!1}return!0}async function is(e,t=e){let n=await os(e);if(!n||!n.isDirectory())return[];let r=[];for(let i of await ns(e,{withFileTypes:!0})){let s=rn(e,i.name);if(i.isDirectory())r.push(...await is(s,t));else r.push(Ru(t,s))}return r}async function ss(e){let t=await os(e);if(!t||t.isSymbolicLink())return;if(await ts(e,t.isDirectory()?493:420),!t.isDirectory())return;let n=await ns(e);await Promise.all(n.map((r)=>ss(rn(e,r))))}async function Ae(e){try{return await ju(e,"utf8")}catch(t){if(de(t,"ENOENT"))return;throw t}}async function os(e){try{return await $u(e)}catch(t){if(de(t,"ENOENT"))return;throw t}}var Vu=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function sn(e,t){if(!zu(e))return{dir:e,warnings:[]};let n=as(t.home,".cradle","settings.json"),r=[],i=await Gu(n,r),s=as(t.cwd,e),o=i.get(e);if(o!==void 0){let u=Hu(ut(o,t.home));if(await us(s))r.push(Ju(e,u));return{dir:u,warnings:r}}if(await us(s))return{dir:s,warnings:r};throw Error(Ku(e,s,n,i))}function zu(e){return Vu.test(e)}async function us(e){try{return(await Wu(e)).isDirectory()}catch(t){if(de(t,"ENOENT")||de(t,"ENOTDIR"))return!1;throw t}}async function Gu(e,t){let n=await Ae(e);if(n===void 0)return new Map;let r=Ft(n,e);if(!le(r))return t.push(`${e}: settings must be a JSON object \u2014 ignored`),new Map;return Oe(r,e,["agents"],t),Uu(r,e,t)}function Uu(e,t,n){let r=e.agents;if(r===void 0)return new Map;if(!le(r))return n.push(`${t}: agents must be an object \u2014 ignored`),new Map;let i=Object.entries(r).map((s)=>{let[o,u]=s,c=Yu(u,o,t,n);return c===void 0?void 0:[o,c]}).filter((s)=>s!==void 0);return new Map(i)}function Yu(e,t,n,r){if(!le(e)){r.push(`${n}: agents.${t} must be an object with a "path" \u2014 ignored`);return}let i=e.path;if(typeof i!=="string"||i.trim()===""){r.push(`${n}: agents.${t}.path must be a non-empty string \u2014 ignored`);return}if(!lt(i)){r.push(`${n}: agents.${t}.path must be an absolute, ~/, or $HOME/ path \u2014 ignored: ${i}`);return}return i}function Ju(e,t){return`started alias "${e}" (${t}) \u2014 a directory named ${e} exists in the current directory; use ./${e} to run it instead`}function Ku(e,t,n,r){let i=r.size>0?` (known agents: ${[...r.keys()].join(", ")})`:"";return`Agent folder not found: ${t} \u2014 and no "agents.${e}" entry in ${n}${i}`}import{createHash as qu}from"crypto";import{join as Xu}from"path";var cs="host.docker.internal",ls="@earendil-works/pi-coding-agent",Zu=/^\d+\.\d+\.\d+\.\d+$/,Qu=new Set(["localhost","127.0.0.1"]);function ds(e){let t=(r)=>ut(r,e.home),n=[{path:e.cwd,readonly:!1},{path:e.agentDir,readonly:!0},{path:e.stateDir,readonly:!1},{path:Xu(e.home,".pi","agent"),readonly:!1},...e.linkedGitDir!==void 0?[{path:e.linkedGitDir,readonly:!1}]:[],...e.grants.read.map((r)=>({path:t(r),readonly:!0})),...e.grants.write.map((r)=>({path:t(r),readonly:!1})),...e.grants.allow.map((r)=>({path:t(r),readonly:!1}))];return el(n)}function el(e){let t=[],n=new Map;for(let r of e){if(!n.has(r.path))t.push(r.path);if(n.get(r.path)!==!1)n.set(r.path,r.readonly)}return t.map((r)=>({path:r,readonly:n.get(r)===!0}))}function fs(e,t){let n=t.map((i)=>`${i.path}:${i.readonly?"ro":"rw"}`).sort().join("|"),r=qu("sha256").update(n).digest("hex").slice(0,8);return`cradle-${e}-${r}`}function hs(e){let t=e.mounts.map((n)=>n.readonly?`${n.path}:ro`:n.path);return[e.sbxBin,"create","shell",...t,"--name",e.name,"-q"]}function tl(e){let t=[],n=!1;for(let r of e)if(Qu.has(r))n=!0;else if(Zu.test(r))t.push(r);else t.push(r,`*.${r}`);if(n)t.push(cs);return t}function Ds(e){let{network:t,sbxBin:n,name:r}=e;if(t===void 0)return[];if(t.block===!0)return[[n,"policy","deny","network","--sandbox",r,"**"]];let i=tl(t.allowDomain??[]);return i.length>0?[[n,"policy","allow","network","--sandbox",r,i.join(",")]]:[]}function nl(e){return e.networkProfile!==void 0?"network_profile is nono-only \u2014 ignored under the sbx backend":void 0}function rl(e){return(e.openPort?.length??0)>0||(e.listenPort?.length??0)>0?"open_port/listen_port are nono-only \u2014 guest-local ports are unrestricted and host services are reachable via host.docker.internal under sbx":void 0}function il(e){return e.block!==!0&&(e.allowDomain?.length??0)>0?"sbx allow rules add to your global sbx policy but cannot subtract from it \u2014 run `sbx policy init deny-all` for strict allowlist semantics (nono enforces the allowlist exactly)":void 0}function gs(e){if(e===void 0)return[];return[nl(e),rl(e),il(e)].filter((t)=>t!==void 0)}function ps(e){return e.unixSocketDirBind.length>0?["unix_socket_dir_bind is nono-only \u2014 Unix sockets cannot cross the sbx VM boundary; grant ignored"]:[]}function Un(e){let t=e.piVersion===null?`command -v pi >/dev/null 2>&1 || npm i -g ${ls}`:`command -v pi >/dev/null 2>&1 && [ "$(pi --version 2>/dev/null)" = "${e.piVersion}" ] || npm i -g ${ls}@${e.piVersion}`;return[e.sbxBin,"exec",e.name,"bash","-lc",t]}function on(e,t){return[e.sbxBin,"exec","-i",...e.tty?["-t"]:[],"-e",`HOME=${e.home}`,"-w",e.cwd,e.name,...t]}function ms(e){return e.toLowerCase().includes("already exists")}function Fs(e){let t;try{t=new URL(e)}catch{return e}if(t.hostname!=="localhost"&&t.hostname!=="127.0.0.1")return e;return t.hostname=cs,t.toString()}function ys(e,t={}){return`// generated by cradle from the agent folder's models.json \u2014 do not edit
101
101
  import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
102
102
 
103
- const providers = ${t.rewriteLocalhostBaseUrls===!0?la(e):e} as const;
103
+ const providers = ${t.rewriteLocalhostBaseUrls===!0?sl(e):e} as const;
104
104
 
105
105
  export default function (pi: ExtensionAPI): void {
106
106
  for (const [name, config] of Object.entries(providers)) {
107
107
  pi.registerProvider(name, config as never);
108
108
  }
109
109
  }
110
- `}function la(e){let t=JSON.parse(e);for(let n of Object.values(t)){if(n===null||typeof n!=="object")continue;let i=n;if(typeof i.baseUrl==="string")i.baseUrl=Zr(i.baseUrl)}return JSON.stringify(t,null,2)}import{lstat as Wa,readdir as gs,stat as La}from"fs/promises";import{join as we,resolve as Ga}from"path";import{readdir as da,stat as Da}from"fs/promises";import{join as Ge,resolve as is,sep as rs}from"path";import{basename as ca,relative as ts,sep as es}from"path";function wt(e){return e.startsWith("!")||e.startsWith("+")||e.startsWith("-")}function Nn(e,t,n){let i=t.filter((a)=>!wt(a)),r=$n(t,"!"),s=$n(t,"+"),o=$n(t,"-");return e.filter((a)=>{if(Mn(a,o,n))return!1;if(Mn(a,s,n))return!0;if(kn(a,r,n))return!1;return i.length===0||kn(a,i,n)})}function ns(e,t,n){return e.filter((i)=>{let r=t.filter((s)=>fa(i,s,n)).at(-1);return r!==void 0&&!r.startsWith("-")&&!r.startsWith("!")})}function fa(e,t,n){let i=wt(t)?t.slice(1):t;return t.startsWith("+")||t.startsWith("-")?Mn(e,[i],n):kn(e,[i],n)}function $n(e,t){return e.filter((n)=>n.startsWith(t)).map((n)=>n.slice(1))}function kn(e,t,n){let i=[ht(ts(n,e)),ca(e),ht(e)];return t.some((r)=>{let s=new Bun.Glob(ht(r));return i.some((o)=>s.match(o))})}function Mn(e,t,n){let i=ht(ts(n,e)),r=ht(e);return t.some((s)=>{let o=ht(s.startsWith("./")?s.slice(2):s);return o===i||o===r})}function ht(e){return es==="/"?e:e.split(es).join("/")}var ha=/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/,pa=/^[0-9A-Za-z.^~><=* +-]+$/,ga=/\.[tj]s$/,ma=/[*?]/;function os(e,t,n){let i=e.packages;if(i===void 0)return[];if(!Array.isArray(i))return n.push(`${t}: packages must be an array \u2014 ignored`),[];let r=Fa(i,t,n),s=xa(r,t,n);return wa(s,t,n)}function Fa(e,t,n){let i=[],r=[];for(let s of e){let o=typeof s==="string"?{source:s}:ba(s,t,n);if(o===null)r.push(JSON.stringify(s));else i.push(o)}if(r.length>0)n.push(`${t}: packages entries must be a source string or a { "source": \u2026 } object \u2014 ignored: ${r.join(", ")}`);return i}function ba(e,t,n){if(!le(e))return null;let i=e.source;if(typeof i!=="string")return null;Ca(e,i,t,n);let r=e.autoload;if(r!==void 0&&typeof r!=="boolean")n.push(`${t}: packages entry ${i}: autoload must be a boolean \u2014 ignored`);let s=Ea(e,i,t,n);return{source:i,...s!==void 0?{extensions:s}:{},...r===!1?{autoloadDisabled:!0}:{}}}function Ea(e,t,n,i){let r=e.extensions;if(r===void 0)return;if(!Le(r)){i.push(`${n}: packages entry ${t}: extensions must be an array of strings \u2014 ignored`);return}return r}var ya=new Set(["source","extensions","autoload"]),ss=new Set(["skills","prompts","themes"]);function Ca(e,t,n,i){let r=Object.keys(e).filter((a)=>!ya.has(a)),s=r.filter((a)=>ss.has(a)),o=r.filter((a)=>!ss.has(a));if(s.length>0)i.push(`${n}: packages entry ${t}: cradle loads a package's extensions and nothing else \u2014 ignored: ${s.join(", ")}`);if(o.length>0)i.push(`${n}: packages entry ${t}: unknown filter keys \u2014 ignored: ${o.join(", ")}`)}function xa(e,t,n){let i=e.filter((s)=>s.source.startsWith("npm:")),r=e.filter((s)=>!s.source.startsWith("npm:"));if(r.length>0){let s=r.map((o)=>o.source).join(", ");n.push(`${t}: only npm: package sources are supported \u2014 ignored: ${s}`)}return i}function wa(e,t,n){let i=[],r=[];for(let{source:s,...o}of e){let a=Aa(s.slice(4));if(a===null)r.push(s);else i.push({...a,...o})}if(r.length>0)n.push(`${t}: packages entries must be npm:<name>[@<version>] \u2014 ignored: ${r.join(", ")}`);return i}function Aa(e){let t=e.lastIndexOf("@"),n=t>0,i=n?e.slice(0,t):e,r=n?e.slice(t+1):"latest";if(!ha.test(i)||!pa.test(r))return null;return{name:i,version:r}}function us(e){let t=Object.fromEntries([...e].sort((n,i)=>n.name.localeCompare(i.name)).map((n)=>[n.name,n.version]));return`${JSON.stringify({name:"cradle-agent-packages",private:!0,dependencies:t},null,2)}
111
- `}async function as(e,t){let n=await Promise.all(t.map(async(i)=>{let r=[];return{entries:await _a(e,i,r),warnings:r}}));return{entries:n.flatMap((i)=>i.entries),warnings:n.flatMap((i)=>i.warnings)}}async function _a(e,t,n){let i=Ge(e,"node_modules",t.name),r=await Sa(t.name,i,n);if(r===null)return[];let s=await Ba(i,r,t.name,n);return Na(s,t,i)}async function Sa(e,t,n){let i=Ge(t,"package.json"),r=await $e(i);if(r===void 0)return n.push(`package ${e} is not installed \u2014 skipped`),null;try{let s=dt(r,i);if(!le(s))return n.push(`package ${e}: ${i} must be a JSON object \u2014 skipped`),null;return s}catch(s){return n.push(`package ${e}: ${rt(s)} \u2014 skipped`),null}}async function Ba(e,t,n,i){let r=Pa(t);if(r!==void 0)return Oa(e,r,n,i);let s=await ls(Ge(e,"extensions"));if(s.length>0)return s;return Ma(n,e,i)}function Pa(e){let t=e.pi;if(t===void 0||!le(t))return;let n=t.extensions;if(n===void 0||!Le(n)||n.length===0)return;return n}async function Oa(e,t,n,i){let r=t.filter((c)=>!wt(c)),o=(await Promise.all(r.map((c)=>ja(e,c,n,i)))).flat(),a=t.filter(wt);return a.length>0?Nn(o,a,e):o}async function ja(e,t,n,i){let r=await va(e,t),s=r.filter((a)=>Ia(e,a));if(s.length<r.length)i.push(`package ${n}: extension entry "${t}" escapes the package directory \u2014 skipped`);let o=await Promise.all(s.map(async(a)=>({files:await $a(a)})));if(o.some((a)=>a.files===null))i.push(`package ${n}: extension entry "${t}" not found \u2014 skipped`);return o.flatMap((a)=>a.files??[])}async function va(e,t){if(!ma.test(t))return[is(e,t)];let n=new Bun.Glob(t).scan({cwd:e,absolute:!0,onlyFiles:!1});return(await Array.fromAsync(n)).map((i)=>is(i)).sort()}async function $a(e){let t=await Ra(e);if(t===void 0)return null;return t.isDirectory()?ls(e):[e]}async function ls(e){let n=[...await Ta(e)].sort((r,s)=>r.name.localeCompare(s.name));return(await Promise.all(n.map((r)=>ka(e,r)))).flat()}async function ka(e,t){if(t.name.startsWith(".")||t.name==="node_modules")return[];if(t.isFile())return ga.test(t.name)?[Ge(e,t.name)]:[];if(!t.isDirectory())return[];let n=await cs([Ge(e,t.name,"index.ts"),Ge(e,t.name,"index.js")]);return n===null?[]:[n]}async function Ma(e,t,n){let i=await cs([Ge(t,"index.ts"),Ge(t,"index.js")]);if(i===null)return n.push(`package ${e} declares no pi extensions \u2014 skipped`),[];return[i]}function Na(e,t,n){if(t.autoloadDisabled===!0)return ns(e,t.extensions??[],n);if(t.extensions===void 0)return[...e];if(t.extensions.length===0)return[];return Nn(e,t.extensions,n)}function Ia(e,t){let n=e.endsWith(rs)?e:`${e}${rs}`;return t===e||t.startsWith(n)}async function cs(e){return(await Promise.all(e.map(async(n)=>await Bun.file(n).exists()?n:null))).find((n)=>n!==null)??null}async function Ra(e){try{return await Da(e)}catch(t){if(fe(t,"ENOENT")||fe(t,"ENOTDIR"))return;throw t}}async function Ta(e){try{return await da(e,{withFileTypes:!0})}catch(t){if(fe(t,"ENOENT")||fe(t,"ENOTDIR"))return[];throw t}}var fs=["off","minimal","low","medium","high","xhigh"],ds=new Set(["schedules","subagents","channels","connections"]),Va=new Set(["SYSTEM.md","APPEND_SYSTEM.md","settings.json","models.json","skills","extensions","sandbox"]),Ha=new Set([".git",".gitignore",".DS_Store","README.md","LICENSE"]),At={read:[],write:[],allow:[],unixSocketDirBind:[]},Zt={posture:"unconfigured",filesystem:At,unsafeMacosSeatbeltRules:[]};async function ms(e){let t=Ga(e),n=await za(t),i=new Map(n.map((c)=>[c.name,c])),r=i.has("SYSTEM.md"),s=i.has("APPEND_SYSTEM.md");if(!r&&!s){let c=i.has("AGENTS.md")?" \u2014 found AGENTS.md, rename it to APPEND_SYSTEM.md":"";throw Error(`Not an agent folder: ${t} (needs SYSTEM.md or APPEND_SYSTEM.md${c} \u2014 see ARCHITECTURE.md)`)}let o=[];Ua(n,o);let a=await tl(t,i.get("sandbox"),o);return{dir:t,systemFilePath:r?we(t,"SYSTEM.md"):null,appendSystemFilePath:s?we(t,"APPEND_SYSTEM.md"):null,settings:await Ya(t,i.has("settings.json"),o),providersJson:await Xa(t,i.has("models.json"),o),skillsDir:await Qa(t,i.get("skills"),o),extensionFiles:await el(t,i.get("extensions"),o),sandbox:a.nono,sbx:a.sbx,warnings:o}}async function za(e){try{return await gs(e,{withFileTypes:!0})}catch(t){if(fe(t,"ENOENT")||fe(t,"ENOTDIR"))throw Error(`Agent folder not found: ${e}`,{cause:t});throw t}}async function Rn(e,t){if(t.isDirectory())return!0;if(!t.isSymbolicLink())return!1;try{return(await La(we(e,t.name))).isDirectory()}catch(n){if(fe(n,"ENOENT"))return!1;throw n}}function Ua(e,t){let n=e.filter((r)=>ds.has(r.name)).map((r)=>r.name),i=e.map((r)=>r.name).filter((r)=>!Va.has(r)&&!ds.has(r)&&!Ha.has(r));if(n.length>0)t.push(`reserved for a future cradle release, ignored: ${n.join(", ")}`);if(i.length>0)t.push(`not part of the agent folder format, ignored: ${i.join(", ")}`)}async function Ya(e,t,n){if(!t)return{};let i=we(e,"settings.json"),r=await Wn(i);Ka(r,i,n);let s=In(r,"defaultProvider",i,n),o=In(r,"defaultModel",i,n),a=dl(r,i,n),c=os(r,i,n),g=qa(r,i,n);return{...s!==void 0?{defaultProvider:s}:{},...o!==void 0?{defaultModel:o}:{},...a!==void 0?{defaultThinkingLevel:a}:{},...c.length>0?{packages:c}:{},...g!==void 0?{npmCommand:g}:{}}}var Ja=new Set(["defaultProvider","defaultModel","defaultThinkingLevel","packages","npmCommand"]);function Ka(e,t,n){let i=Object.keys(e).filter((r)=>!Ja.has(r));if(i.length>0)n.push(`${t}: keys cradle does not map are ignored \u2014 pi reads them from ~/.pi/agent/settings.json or `+`the project's .pi/settings.json, not the agent folder: ${i.join(", ")}`)}var Ds=new Set(["npm","pnpm","yarn","bun"]);function qa(e,t,n){let i=e.npmCommand;if(i===void 0)return;let[r,...s]=Le(i)?i:[];if(r===void 0||s.length>0||!Ds.has(r)){let o=[...Ds].join(", ");n.push(`${t}: npmCommand must be a single-element array naming one of ${o} \u2014 ignored`);return}return[r]}async function Xa(e,t,n){if(!t)return null;let i=we(e,"models.json"),r=await Wn(i),s=r.providers;if(s===void 0||!le(s))throw Error(`${i} must contain a "providers" object`);return Be(r,i,["providers"],n),JSON.stringify(Za(s),null,2)}function Za(e){let t={input:0,output:0,cacheRead:0,cacheWrite:0};return Object.fromEntries(Object.entries(e).map(([n,i])=>{if(!le(i)||!Array.isArray(i.models))return[n,i];let r=i.models.map((s)=>le(s)&&s.cost===void 0?{cost:t,...s}:s);return[n,{...i,models:r}]}))}async function Qa(e,t,n){if(!t)return null;if(!await Rn(e,t))return n.push("skills must be a directory \u2014 ignored"),null;return we(e,"skills")}async function el(e,t,n){if(!t)return[];if(!await Rn(e,t))return n.push("extensions must be a directory \u2014 ignored"),[];let i=we(e,"extensions"),r=await gs(i,{withFileTypes:!0});return(await Promise.all(r.sort((o,a)=>o.name.localeCompare(a.name)).map(async(o)=>{if(o.isFile()&&o.name.endsWith(".ts")&&!o.name.startsWith("."))return we(i,o.name);if(o.isDirectory()){let a=we(i,o.name,"index.ts");return await Bun.file(a).exists()?a:null}return null}))).filter((o)=>o!==null)}async function tl(e,t,n){let i={nono:Zt,sbx:Zt};if(!t)return i;if(!await Rn(e,t))return n.push("sandbox must be a directory \u2014 ignored"),i;let r=we(e,"sandbox","nono.json"),s=we(e,"sandbox","sbx.json"),o=await hs(r),a=await hs(s);if(o===void 0&&a===void 0)return n.push("sandbox/ has no nono.json or sbx.json \u2014 sandboxing stays off unless --sandbox is passed"),i;return{nono:o===void 0?Zt:nl(o,r,n),sbx:a===void 0?Zt:il(a,s,n)}}function nl(e,t,n){let i=Qt(e,"sandbox",t,n),r=al(e,t,n);return ul(e,t,n),Be(e,t,["sandbox","network","filesystem","unsafe_macos_seatbelt_rules","net"],n),{posture:i===!1?"disabled":"enabled",...r!==void 0?{network:r}:{},filesystem:cl(e.filesystem,t,n),unsafeMacosSeatbeltRules:ll(e.unsafe_macos_seatbelt_rules,t,n)}}function il(e,t,n){let i=Qt(e,"sandbox",t,n),r=rl(e,t,n);return Tn({record:e,key:"unsafe_macos_seatbelt_rules",path:t,explanation:"the sbx VM boundary replaces Seatbelt"},n),Be(e,t,["sandbox","network","filesystem","unsafe_macos_seatbelt_rules"],n),{posture:i===!1?"disabled":"enabled",...r!==void 0?{network:r}:{},filesystem:sl(e.filesystem,t,n),unsafeMacosSeatbeltRules:[]}}function rl(e,t,n){let i=e.network;if(i===void 0)return;if(!le(i)){n.push(`${t}: network must be an object \u2014 ignored`);return}for(let c of["network_profile","open_port","listen_port"])Tn({record:i,key:c,path:t},n);let r=`${t} network`;Be(i,r,["block","allow_domain","network_profile","open_port","listen_port"],n);let s=Qt(i,"block",r,n),o=Fs(i,"allow_domain",r,n),a={...s!==void 0?{block:s}:{},...o.length>0?{allowDomain:o}:{}};return Object.keys(a).length>0?a:void 0}function sl(e,t,n){if(e===void 0)return At;if(!le(e))return n.push(`${t}: filesystem must be an object \u2014 ignored`),At;return Tn({record:e,key:"unix_socket_dir_bind",path:t,explanation:"Unix sockets cannot cross the sbx VM boundary"},n),Be(e,`${t} filesystem`,["read","write","allow","unix_socket_dir_bind"],n),{read:st(e,"read",t,n),write:st(e,"write",t,n),allow:st(e,"allow",t,n),unixSocketDirBind:[]}}function Tn({record:e,key:t,path:n,explanation:i},r){if(e[t]===void 0)return;r.push(`${n}: ${t} is nono-only \u2014 ${i!==void 0?`${i}; `:""}ignored`)}async function hs(e){return await ol(e)?Wn(e):void 0}async function ol(e){try{return await Wa(e),!0}catch(t){if(fe(t,"ENOENT"))return!1;throw t}}function ul(e,t,n){if(e.net!==void 0)n.push(`${t}: "net" was removed \u2014 use "network" instead (see ARCHITECTURE.md) \u2014 ignored`)}function al(e,t,n){let i=e.network;if(i===void 0)return;if(!le(i)){n.push(`${t}: network must be an object \u2014 ignored`);return}let r=`${t} network`;Be(i,r,["block","network_profile","allow_domain","open_port","listen_port"],n);let s=Qt(i,"block",r,n),o=In(i,"network_profile",r,n),a=Fs(i,"allow_domain",r,n),c=ps(i,"open_port",r,n),g=ps(i,"listen_port",r,n),E={...s!==void 0?{block:s}:{},...o!==void 0?{networkProfile:o}:{},...a.length>0?{allowDomain:a}:{},...c.length>0?{openPort:c}:{},...g.length>0?{listenPort:g}:{}};return Object.keys(E).length>0?E:void 0}function Fs(e,t,n,i){let r=e[t];if(r===void 0)return[];if(!Le(r))return i.push(`${n}: ${t} must be an array of strings \u2014 ignored`),[];let s=r.map((o)=>o.trim()).filter((o)=>o!=="");if(s.length!==r.length)i.push(`${n}: ${t} entries must be non-empty \u2014 blanks ignored`);return s}function ps(e,t,n,i){let r=e[t];if(r===void 0)return[];if(!Array.isArray(r))return i.push(`${n}: ${t} must be an array of port numbers \u2014 ignored`),[];let s=(a)=>typeof a==="number"&&Number.isInteger(a)&&a>=0&&a<=65535,o=r.filter((a)=>!s(a)).map((a)=>typeof a==="object"&&a!==null?JSON.stringify(a):String(a));if(o.length>0)i.push(`${n}: ${t} entries must be integers 0\u201365535 \u2014 ignored: ${o.join(", ")}`);return r.filter(s)}function ll(e,t,n){if(e===void 0)return[];if(!Le(e))return n.push(`${t}: unsafe_macos_seatbelt_rules must be an array of strings \u2014 ignored`),[];let i=(s)=>{let o=s.trim();return o.startsWith("(")&&o.endsWith(")")},r=e.filter((s)=>!i(s));if(r.length>0)n.push(`${t}: unsafe_macos_seatbelt_rules entries must be parenthesized s-expressions \u2014 ignored: ${r.join(", ")}`);return e.filter(i).map((s)=>s.trim())}function Qt(e,t,n,i){let r=e[t];if(r===void 0)return;if(typeof r!=="boolean"){i.push(`${n}: ${t} must be true or false \u2014 ignored`);return}return r}function cl(e,t,n){if(e===void 0)return At;if(!le(e))return n.push(`${t}: filesystem must be an object \u2014 ignored`),At;return Be(e,`${t} filesystem`,["read","write","allow","unix_socket_dir_bind"],n),{read:st(e,"read",t,n),write:st(e,"write",t,n),allow:st(e,"allow",t,n),unixSocketDirBind:st(e,"unix_socket_dir_bind",t,n)}}function st(e,t,n,i){let r=e[t];if(r===void 0)return[];if(!Le(r))return i.push(`${n}: ${t} must be an array of strings \u2014 ignored`),[];let s=r.filter((o)=>!xt(o));if(s.length>0)i.push(`${n}: ${t} entries must be absolute, ~/, or $HOME/ paths \u2014 ignored: ${s.join(", ")}`);return r.filter(xt)}async function Wn(e){let t=dt(await fl(e),e);if(!le(t))throw Error(`${e} must be a JSON object`);return t}async function fl(e){let t;try{t=await $e(e)}catch(n){throw Error(`${e} could not be read: ${rt(n)}`,{cause:n})}if(t===void 0)throw Error(`${e} could not be read \u2014 broken symlink?`);return t}function In(e,t,n,i){let r=e[t];if(r===void 0)return;if(typeof r!=="string"){i.push(`${n}: ${t} must be a string \u2014 ignored`);return}return r}function dl(e,t,n){let i=e.defaultThinkingLevel;if(i===void 0)return;if(typeof i!=="string"||!fs.includes(i)){n.push(`${t}: defaultThinkingLevel must be one of ${fs.join(", ")} \u2014 ignored`);return}return i}import{createHash as Dl}from"crypto";import{homedir as hl}from"os";import{basename as pl,join as _t}from"path";function gl(e){let t=pl(e).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),n=Dl("sha256").update(e).digest("hex").slice(0,8);return`${t===""?"agent":t}-${n}`}function bs(e,t=hl(),n=process.env.CRADLE_STATE_DIR){let i=n||_t(t,".cradle");return _t(i,"agents",gl(e))}function Es(e){return{extensionsDir:_t(e,"extensions"),sessionsDir:_t(e,"sessions"),miseCacheDir:_t(e,"mise-cache")}}import{readFile as ml}from"fs/promises";import{join as ys,resolve as Cs}from"path";var xs="gitdir:";async function ws(e){try{return await ml(e,"utf8")}catch{return}}async function As(e){let t=await ws(ys(e,".git"));if(t===void 0||!t.startsWith(xs))return;let n=Cs(e,t.slice(xs.length).trim()),i=await ws(ys(n,"commondir")),r=i!==void 0?Cs(n,i.trim()):n;return Jt(e,r)?void 0:r}async function Bs(e,t={}){let n=t.home??El(),i=t.cwd??process.cwd(),{dir:r,warnings:s}=await Gr(e.dir,{home:n,cwd:i}),o=await ms(r),a=bs(o.dir,n),{extensionsDir:c,sessionsDir:g,miseCacheDir:E}=Es(a),h=Al(e,o),p=e.dryRun??!1,m=Tl(h.backend,p,t.which),b=xl({folder:o,flags:e,backend:h.backend,bins:m,stateDir:a,extensionsDir:c,sessionsDir:g,miseCacheDir:E}),D=await Wl(h,o,{home:n,cwd:i,stateDir:a,profilePath:b.profilePath,sbxBin:m.sbxBin,hostPiBin:m.piBin,tty:t.tty??!1}),j=wl(o,a);return{files:Vl(o,h.backend),extensionsDir:c,sessionsDir:g,warnings:[...s,...h.warnings,...D.warnings],profile:D.profile,sbx:D.sbx,packages:j,launch:b,dryRun:p}}function xl(e){let{folder:t,flags:n,backend:i,bins:r,stateDir:s,extensionsDir:o,sessionsDir:a,miseCacheDir:c}=e;return{folder:t,stateDir:s,extensionsDir:o,sessionsDir:a,miseCacheDir:c,backend:i,passthrough:n.passthrough??[],nonoBin:r.nonoBin,piBin:i==="sbx"?"pi":r.piBin,profilePath:St(s,jr),...n.verbose?{verbose:!0}:{}}}function wl(e,t){let n=e.settings.packages;if(n===void 0||n.length===0)return null;return{npmDir:St(t,"npm"),manifest:us(n),specs:n,installCommand:[...e.settings.npmCommand??["npm"],"install","--ignore-scripts"]}}function Al(e,t){let{backend:n,warnings:i}=jl(e,t),r=[],s=_l(e,t,n,r);return{backend:n,network:s,warnings:Pl(n!==null,s,[...i,...r])}}function _l(e,t,n,i){if(e.offline)return{block:!0};let r=Sl(e.allowHost??[],i);if(r.length>0)return{allowDomain:r};return n==="sbx"?t.sbx.network:t.sandbox.network}function Sl(e,t){let n=e.map((i)=>i.trim()).filter((i)=>i!=="");if(n.length!==e.length)t.push("--allow-host entries must be non-empty \u2014 blanks ignored");return n}function Bl(e){return e!==void 0&&(e.block===!0||(e.allowDomain?.length??0)>0)}function Pl(e,t,n){if(e||!Bl(t))return n;return[...n,"network policy has no effect without the sandbox \u2014 pi runs with no network isolation (--sandbox to enforce it)"]}function Ol(e){return e.offline===!0||(e.allowHost?.length??0)>0}function jl(e,t){if(e.noSandbox===!0)return{backend:null,warnings:t.warnings};if(e.sandboxBackend!==void 0)return{backend:e.sandboxBackend,warnings:t.warnings};let n=vl(t);if(e.noSandbox===!1||n.backend!==null)return{...n,backend:n.backend??"nono"};return $l(e,t,n.warnings)}function vl(e){let t=e.sandbox.posture==="enabled",n=e.sbx.posture==="enabled";if(t&&n)return{backend:"nono",warnings:[...e.warnings,"both sandbox/nono.json and sandbox/sbx.json declare a sandbox \u2014 using nono (pass --sandbox-backend sbx to override)"]};return{backend:t?"nono":n?"sbx":null,warnings:e.warnings}}function $l(e,t,n){let i=kl(t);if(Ol(e))return{backend:"nono",warnings:[...n,`${i} \u2014 sandbox forced on to enforce the requested network policy (--no-sandbox to override)`]};return{backend:null,warnings:[...n,`${i} \u2014 agent is running without OS isolation (--sandbox to force enable)`]}}function kl(e){if(e.sandbox.posture==="disabled")return"sandbox disabled by sandbox/nono.json";if(e.sbx.posture==="disabled")return"sandbox disabled by sandbox/sbx.json";return"sandbox/nono.json or sbx.json not found"}async function Ps(e,t={}){let n={dryRun:!1,results:[],failures:[]};if(await Nr(n,"extensions",e.extensionsDir,e.files),n.failures.length>0)throw Error(`Failed to write agent extensions: ${n.failures.join("; ")}`);if(await Ln(e.sessionsDir,{recursive:!0}),e.profile!==null)await Ln(Cl(e.profile.path),{recursive:!0}),await Ss(e.profile.path,e.profile.content,"utf8");if(e.sbx!==null)await Ml(e.sbx,t);let i={...e.launch,extensionsDir:e.extensionsDir,sessionsDir:e.sessionsDir},r=e.packages===null?{argv:ft(i),warnings:[]}:await Rl(e.packages,i,t);if(e.sbx===null)return r;return{argv:Xt(e.sbx.spec,r.argv),warnings:r.warnings}}async function Ml(e,t){let n=t.run;if(n===void 0)throw Error("An sbx-backend run needs a command runner but none was provided");let i=await n(e.createArgv);if(i.exitCode!==0&&!Xr(i.stderr))throw Error(`Failed to create sbx sandbox ${e.spec.name}: ${i.stderr.trim()}`);for(let r of e.policyArgvs)await _s(n,r,`apply sbx network policy (${e.spec.name})`);await _s(n,await Nl(e,t),`provision pi in sbx sandbox ${e.spec.name}`)}async function _s(e,t,n){let i=await e(t);if(i.exitCode!==0)throw Error(`Failed to ${n}: ${i.stderr.trim()}`)}async function Nl(e,t){if(t.readPiVersion===void 0)return e.provisionArgv;let n=await t.readPiVersion(e.hostPiBin);return vn({...e.spec,piVersion:n})}async function Il(e,t){if(await $e(St(e,"package.json"))!==t)return!1;return Fl(St(e,"node_modules"))}async function Rl(e,t,n){if(await Ln(e.npmDir,{recursive:!0}),!await Il(e.npmDir,e.manifest)){if(n.install===void 0)throw Error("Packages declared but no installer provided");let s=St(e.npmDir,"package.json");await Ss(s,e.manifest,"utf8");try{await n.install(e.installCommand,e.npmDir)}catch(o){throw await bl(s,{force:!0}),o}}let{entries:i,warnings:r}=await as(e.npmDir,e.specs);return{argv:ft({...t,packageEntries:i}),warnings:r}}function Tl(e,t,n){if(t)return{nonoBin:"nono",piBin:"pi",sbxBin:"sbx"};return{nonoBin:e==="nono"?Yt("nono",n):"nono",sbxBin:e==="sbx"?Yt("sbx",n):"sbx",piBin:Yt("pi",n)}}async function Wl(e,t,n){let i=e.backend!==null?await As(n.cwd):void 0,r=Gl(e.backend==="nono",t,e.network,{home:n.home,cwd:n.cwd,stateDir:n.stateDir,profilePath:n.profilePath,...i!==void 0?{linkedGitDir:i}:{}});if(e.backend!=="sbx")return{profile:r,sbx:null,warnings:[]};let s=Ll(e.network,t,{...n,...i!==void 0?{linkedGitDir:i}:{}});return{profile:r,sbx:s,warnings:[...Kr(e.network),...qr(t.sbx.filesystem)]}}function Ll(e,t,n){let i=zr({cwd:n.cwd,agentDir:t.dir,stateDir:n.stateDir,home:n.home,grants:t.sbx.filesystem,...n.linkedGitDir!==void 0?{linkedGitDir:n.linkedGitDir}:{}}),r={sbxBin:n.sbxBin,name:Ur(yl(n.stateDir),i),cwd:n.cwd,home:n.home,mounts:i,...e!==void 0?{network:e}:{},piVersion:null,tty:n.tty};return{spec:r,hostPiBin:n.hostPiBin,createArgv:Yr(r),policyArgvs:Jr(r),provisionArgv:vn(r)}}function Gl(e,t,n,i){if(!e)return null;let r=vr(i.cwd,i.home);if(r!==void 0)throw Error(`cannot sandbox from ${r} \u2014 this directory is (or contains) nono's protected state root `+"(~/.local/state/nono) and nono refuses to start with an overlapping grant; run `cradle run` from a project directory instead");let s=$r({home:i.home,cwd:i.cwd,agentDir:t.dir,stateDir:i.stateDir,grants:t.sandbox.filesystem,rules:t.sandbox.unsafeMacosSeatbeltRules,...n!==void 0?{network:n}:{},...i.linkedGitDir!==void 0?{linkedGitDir:i.linkedGitDir}:{}});return{path:i.profilePath,content:s}}function Vl(e,t){return[...e.providersJson!==null?[{rel:"providers.ts",content:Qr(e.providersJson,{rewriteLocalhostBaseUrls:t==="sbx"})}]:[],...t==="nono"?[{rel:Ut,content:Ar()}]:[]]}function Os(e,t){return t?`\x1B[33m${e}\x1B[0m`:e}function js(e,t){return()=>{e.kill(t)}}async function vs(e,t={}){let[n,...i]=e;if(!n)throw Error("Command requires at least one argument");let r=Bun.spawn([n,...i],{stdin:"inherit",stdout:"inherit",stderr:"inherit",env:{...process.env,...t}}),s=js(r,"SIGINT"),o=js(r,"SIGTERM");process.on("SIGINT",s),process.on("SIGTERM",o);try{return await r.exited}finally{process.off("SIGINT",s),process.off("SIGTERM",o)}}async function $s(e){let[t,...n]=e;if(!t)throw Error("Command requires at least one argument");let i=Bun.spawn([t,...n],{stdin:"ignore",stdout:"ignore",stderr:"pipe",env:process.env}),[r,s]=await Promise.all([new Response(i.stderr).text(),i.exited]);return{exitCode:s,stderr:r}}async function ks(e,t){let[n,...i]=e;if(!n)throw Error("Command requires at least one argument");let s=await Bun.spawn([n,...i],{cwd:t,stdin:"ignore",stdout:"inherit",stderr:"inherit",env:process.env}).exited;if(s!==0)throw Error(`Package install failed (${e.join(" ")} exited ${String(s)})`)}var Bt=xr(process.argv.slice(2)).scriptName("cradle").version(wr.version).usage("$0 <cmd> [args]").parserConfiguration({"populate--":!0,"parse-numbers":!1,"parse-positional-numbers":!1}).strict();Bt.command("$0","show help",()=>{},async()=>{console.log(await Bt.getHelp())});Bt.command("run [dir]","run an agent folder with pi, sandboxed when sandbox/nono.json or sandbox/sbx.json is present",(e)=>e.positional("dir",{type:"string",default:".",describe:"agent folder, or a name from ~/.cradle/settings.json (default: .)"}).option("offline",{type:"boolean",description:"block all outbound network (overrides the folder network policy; implies --sandbox)"}).option("allow-host",{type:"array",string:!0,description:"restrict network to these hosts (repeatable; overrides the folder allowlist; implies --sandbox)"}).option("sandbox",{type:"boolean",description:"run sandboxed (--sandbox forces it when no sandbox/ file enables one or the folder opts out; --no-sandbox disables)"}).option("sandbox-backend",{type:"string",choices:["nono","sbx"],description:"sandbox implementation (implies --sandbox): nono (host OS policy) or sbx (Docker Sandboxes microVM)"}).option("verbose",{type:"boolean",default:!1,description:"show nono's full sandbox capabilities banner instead of the one-line status"}).option("dry-run",{type:"boolean",default:!1,description:"print the write plan + command, do not spawn"}).epilogue("Everything after `--` is forwarded to pi."),async(e)=>{let t=(e["--"]??[]).map(String),n=(e.allowHost??[]).map(String),i={dir:e.dir,dryRun:e.dryRun,...e.sandbox!==void 0?{noSandbox:!e.sandbox}:{},...e.sandboxBackend!==void 0?{sandboxBackend:e.sandboxBackend}:{},...e.offline?{offline:!0}:{},...n.length?{allowHost:n}:{},...e.verbose?{verbose:!0}:{},...t.length?{passthrough:t}:{}};await Hl(i)});Bt.command("doctor","check pi / nono / mise on PATH",()=>{},async()=>{let e=await Br({readVersion:Is});console.log(Pr(e)),process.exitCode=Or(e)});async function Hl(e){try{let t=await Bs(e,{tty:process.stdout.isTTY});if(Ms(t.warnings),t.dryRun){zl(t);return}let n=await Ps(t,{install:ks,run:$s,readPiVersion:Is});if(Ms(n.warnings),t.profile!==null&&!e.verbose)console.log("\uD83D\uDD12 Sandbox Active");if(t.sbx!==null&&!e.verbose)console.log("\uD83D\uDD12 Sandbox Active (sbx)");process.exit(await vs(n.argv,On(t.launch)))}catch(t){Jl(t)}}function zl(e){for(let i of e.files)console.log(`write: ${Ns(e.extensionsDir,i.rel)}`);if(e.profile!==null)console.log(`write: ${e.profile.path}`);if(e.sbx!==null)Ul(e.sbx);if(e.packages!==null)Yl(e.packages);let t=Object.entries(On(e.launch)).map(([i,r])=>`${i}=${Dt(r)}`),n=e.sbx!==null?Xt(e.sbx.spec,ft(e.launch)):ft(e.launch);console.log([...t,...n.map(Dt)].join(" "))}function Ul(e){console.log(`create: ${e.createArgv.map(Dt).join(" ")}`);for(let t of e.policyArgvs)console.log(`policy: ${t.map(Dt).join(" ")}`);console.log(`provision: ${e.provisionArgv.map(Dt).join(" ")}`)}function Yl(e){console.log(`write: ${Ns(e.npmDir,"package.json")}`);let t=e.specs.map((n)=>`${n.name}@${n.version}`).join(", ");console.log(`install: ${e.installCommand.join(" ")} (${e.npmDir}): ${t}`)}function Ms(e){let t=process.stderr.isTTY;for(let n of e)console.error(Os(`warning: ${n}`,t))}async function Is(e,t=["--version"]){try{let n=Bun.spawn([e,...t],{stdout:"pipe",stderr:"ignore"}),[i,r]=await Promise.all([new Response(n.stdout).text(),n.exited]);if(r!==0)return null;return i.split(`
112
- `)[0]?.match(/v?\d+\.\d+\S*/)?.[0]??null}catch{return null}}function Jl(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}Bt.parse();
110
+ `}function sl(e){let t=JSON.parse(e);for(let n of Object.values(t)){if(n===null||typeof n!=="object")continue;let r=n;if(typeof r.baseUrl==="string")r.baseUrl=Fs(r.baseUrl)}return JSON.stringify(t,null,2)}import{lstat as Nl,readdir as Ns,stat as Rl}from"fs/promises";import{join as we,resolve as Il}from"path";import{readdir as ul,stat as ll}from"fs/promises";import{join as Ge,resolve as ws,sep as xs}from"path";import{basename as ol,relative as Es,sep as bs}from"path";function Ot(e){return e.startsWith("!")||e.startsWith("+")||e.startsWith("-")}function qn(e,t,n){let r=t.filter((u)=>!Ot(u)),i=Yn(t,"!"),s=Yn(t,"+"),o=Yn(t,"-");return e.filter((u)=>{if(Kn(u,o,n))return!1;if(Kn(u,s,n))return!0;if(Jn(u,i,n))return!1;return r.length===0||Jn(u,r,n)})}function Cs(e,t,n){return e.filter((r)=>{let i=t.filter((s)=>al(r,s,n)).at(-1);return i!==void 0&&!i.startsWith("-")&&!i.startsWith("!")})}function al(e,t,n){let r=Ot(t)?t.slice(1):t;return t.startsWith("+")||t.startsWith("-")?Kn(e,[r],n):Jn(e,[r],n)}function Yn(e,t){return e.filter((n)=>n.startsWith(t)).map((n)=>n.slice(1))}function Jn(e,t,n){let r=[yt(Es(n,e)),ol(e),yt(e)];return t.some((i)=>{let s=new Bun.Glob(yt(i));return r.some((o)=>s.match(o))})}function Kn(e,t,n){let r=yt(Es(n,e)),i=yt(e);return t.some((s)=>{let o=yt(s.startsWith("./")?s.slice(2):s);return o===r||o===i})}function yt(e){return bs==="/"?e:e.split(bs).join("/")}var cl=/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/,dl=/^[0-9A-Za-z.^~><=* +-]+$/,fl=/\.[tj]s$/,hl=/[*?]/;function As(e,t,n){let r=e.packages;if(r===void 0)return[];if(!Array.isArray(r))return n.push(`${t}: packages must be an array \u2014 ignored`),[];let i=Dl(r,t,n),s=yl(i,t,n);return bl(s,t,n)}function Dl(e,t,n){let r=[],i=[];for(let s of e){let o=typeof s==="string"?{source:s}:gl(s,t,n);if(o===null)i.push(JSON.stringify(s));else r.push(o)}if(i.length>0)n.push(`${t}: packages entries must be a source string or a { "source": \u2026 } object \u2014 ignored: ${i.join(", ")}`);return r}function gl(e,t,n){if(!le(e))return null;let r=e.source;if(typeof r!=="string")return null;Fl(e,r,t,n);let i=e.autoload;if(i!==void 0&&typeof i!=="boolean")n.push(`${t}: packages entry ${r}: autoload must be a boolean \u2014 ignored`);let s=pl(e,r,t,n);return{source:r,...s!==void 0?{extensions:s}:{},...i===!1?{autoloadDisabled:!0}:{}}}function pl(e,t,n,r){let i=e.extensions;if(i===void 0)return;if(!ze(i)){r.push(`${n}: packages entry ${t}: extensions must be an array of strings \u2014 ignored`);return}return i}var ml=new Set(["source","extensions","autoload"]),Ss=new Set(["skills","prompts","themes"]);function Fl(e,t,n,r){let i=Object.keys(e).filter((u)=>!ml.has(u)),s=i.filter((u)=>Ss.has(u)),o=i.filter((u)=>!Ss.has(u));if(s.length>0)r.push(`${n}: packages entry ${t}: cradle loads a package's extensions and nothing else \u2014 ignored: ${s.join(", ")}`);if(o.length>0)r.push(`${n}: packages entry ${t}: unknown filter keys \u2014 ignored: ${o.join(", ")}`)}function yl(e,t,n){let r=e.filter((s)=>s.source.startsWith("npm:")),i=e.filter((s)=>!s.source.startsWith("npm:"));if(i.length>0){let s=i.map((o)=>o.source).join(", ");n.push(`${t}: only npm: package sources are supported \u2014 ignored: ${s}`)}return r}function bl(e,t,n){let r=[],i=[];for(let{source:s,...o}of e){let u=El(s.slice(4));if(u===null)i.push(s);else r.push({...u,...o})}if(i.length>0)n.push(`${t}: packages entries must be npm:<name>[@<version>] \u2014 ignored: ${i.join(", ")}`);return r}function El(e){let t=e.lastIndexOf("@"),n=t>0,r=n?e.slice(0,t):e,i=n?e.slice(t+1):"latest";if(!cl.test(r)||!dl.test(i))return null;return{name:r,version:i}}function Ps(e){let t=Object.fromEntries([...e].sort((n,r)=>n.name.localeCompare(r.name)).map((n)=>[n.name,n.version]));return`${JSON.stringify({name:"cradle-agent-packages",private:!0,dependencies:t},null,2)}
111
+ `}async function _s(e,t){let n=await Promise.all(t.map(async(r)=>{let i=[];return{entries:await Cl(e,r,i),warnings:i}}));return{entries:n.flatMap((r)=>r.entries),warnings:n.flatMap((r)=>r.warnings)}}async function Cl(e,t,n){let r=Ge(e,"node_modules",t.name),i=await wl(t.name,r,n);if(i===null)return[];let s=await xl(r,i,t.name,n);return vl(s,t,r)}async function wl(e,t,n){let r=Ge(t,"package.json"),i=await Ae(r);if(i===void 0)return n.push(`package ${e} is not installed \u2014 skipped`),null;try{let s=Ft(i,r);if(!le(s))return n.push(`package ${e}: ${r} must be a JSON object \u2014 skipped`),null;return s}catch(s){return n.push(`package ${e}: ${Se(s)} \u2014 skipped`),null}}async function xl(e,t,n,r){let i=Sl(t);if(i!==void 0)return Al(e,i,n,r);let s=await Bs(Ge(e,"extensions"));if(s.length>0)return s;return $l(n,e,r)}function Sl(e){let t=e.pi;if(t===void 0||!le(t))return;let n=t.extensions;if(n===void 0||!ze(n)||n.length===0)return;return n}async function Al(e,t,n,r){let i=t.filter((c)=>!Ot(c)),o=(await Promise.all(i.map((c)=>Pl(e,c,n,r)))).flat(),u=t.filter(Ot);return u.length>0?qn(o,u,e):o}async function Pl(e,t,n,r){let i=await _l(e,t),s=i.filter((u)=>jl(e,u));if(s.length<i.length)r.push(`package ${n}: extension entry "${t}" escapes the package directory \u2014 skipped`);let o=await Promise.all(s.map(async(u)=>({files:await Bl(u)})));if(o.some((u)=>u.files===null))r.push(`package ${n}: extension entry "${t}" not found \u2014 skipped`);return o.flatMap((u)=>u.files??[])}async function _l(e,t){if(!hl.test(t))return[ws(e,t)];let n=new Bun.Glob(t).scan({cwd:e,absolute:!0,onlyFiles:!1});return(await Array.fromAsync(n)).map((r)=>ws(r)).sort()}async function Bl(e){let t=await kl(e);if(t===void 0)return null;return t.isDirectory()?Bs(e):[e]}async function Bs(e){let n=[...await Ml(e)].sort((i,s)=>i.name.localeCompare(s.name));return(await Promise.all(n.map((i)=>Ol(e,i)))).flat()}async function Ol(e,t){if(t.name.startsWith(".")||t.name==="node_modules")return[];if(t.isFile())return fl.test(t.name)?[Ge(e,t.name)]:[];if(!t.isDirectory())return[];let n=await Os([Ge(e,t.name,"index.ts"),Ge(e,t.name,"index.js")]);return n===null?[]:[n]}async function $l(e,t,n){let r=await Os([Ge(t,"index.ts"),Ge(t,"index.js")]);if(r===null)return n.push(`package ${e} declares no pi extensions \u2014 skipped`),[];return[r]}function vl(e,t,n){if(t.autoloadDisabled===!0)return Cs(e,t.extensions??[],n);if(t.extensions===void 0)return[...e];if(t.extensions.length===0)return[];return qn(e,t.extensions,n)}function jl(e,t){let n=e.endsWith(xs)?e:`${e}${xs}`;return t===e||t.startsWith(n)}async function Os(e){return(await Promise.all(e.map(async(n)=>await Bun.file(n).exists()?n:null))).find((n)=>n!==null)??null}async function kl(e){try{return await ll(e)}catch(t){if(de(t,"ENOENT")||de(t,"ENOTDIR"))return;throw t}}async function Ml(e){try{return await ul(e,{withFileTypes:!0})}catch(t){if(de(t,"ENOENT")||de(t,"ENOTDIR"))return[];throw t}}var $s=["off","minimal","low","medium","high","xhigh","max"],vs=new Set(["subagents","channels","connections"]),Tl=new Set(["SYSTEM.md","APPEND_SYSTEM.md","settings.json","models.json","skills","schedule","extensions","sandbox"]),Ll=new Set([".git",".gitignore",".DS_Store","README.md","LICENSE"]),$t={read:[],write:[],allow:[],unixSocketDirBind:[]},an={posture:"unconfigured",filesystem:$t,unsafeMacosSeatbeltRules:[]};async function un(e){let t=Il(e),n=await Wl(t),r=new Map(n.map((c)=>[c.name,c])),i=r.has("SYSTEM.md"),s=r.has("APPEND_SYSTEM.md");if(!i&&!s){let c=r.has("AGENTS.md")?" \u2014 found AGENTS.md, rename it to APPEND_SYSTEM.md":"";throw Error(`Not an agent folder: ${t} (needs SYSTEM.md or APPEND_SYSTEM.md${c} \u2014 see ARCHITECTURE.md)`)}let o=[];Hl(n,o);let u=await Ql(t,r.get("sandbox"),o);return{dir:t,systemFilePath:i?we(t,"SYSTEM.md"):null,appendSystemFilePath:s?we(t,"APPEND_SYSTEM.md"):null,settings:await zl(t,r.has("settings.json"),o),providersJson:await Jl(t,r.has("models.json"),o),skillsDir:await ql(t,r.get("skills"),o),scheduleDir:await Xl(t,r.get("schedule"),o),extensionFiles:await Zl(t,r.get("extensions"),o),sandbox:u.nono,sbx:u.sbx,warnings:o}}async function Wl(e){try{return await Ns(e,{withFileTypes:!0})}catch(t){if(de(t,"ENOENT")||de(t,"ENOTDIR"))throw Error(`Agent folder not found: ${e}`,{cause:t});throw t}}async function ln(e,t){if(t.isDirectory())return!0;if(!t.isSymbolicLink())return!1;try{return(await Rl(we(e,t.name))).isDirectory()}catch(n){if(de(n,"ENOENT"))return!1;throw n}}function Hl(e,t){let n=e.filter((i)=>vs.has(i.name)).map((i)=>i.name),r=e.map((i)=>i.name).filter((i)=>!Tl.has(i)&&!vs.has(i)&&!Ll.has(i));if(n.length>0)t.push(`reserved for a future cradle release, ignored: ${n.join(", ")}`);if(r.length>0)t.push(`not part of the agent folder format, ignored: ${r.join(", ")}${Vl(r)}`)}function Vl(e){return e.includes("schedules")?" \u2014 did you mean schedule/ (singular)?":""}async function zl(e,t,n){if(!t)return{};let r=we(e,"settings.json"),i=await Qn(r);Ul(i,r,n);let s=Xn(i,"defaultProvider",r,n),o=Xn(i,"defaultModel",r,n),u=cc(i,r,n),c=As(i,r,n),p=Yl(i,r,n);return{...s!==void 0?{defaultProvider:s}:{},...o!==void 0?{defaultModel:o}:{},...u!==void 0?{defaultThinkingLevel:u}:{},...c.length>0?{packages:c}:{},...p!==void 0?{npmCommand:p}:{}}}var Gl=new Set(["defaultProvider","defaultModel","defaultThinkingLevel","packages","npmCommand"]);function Ul(e,t,n){let r=Object.keys(e).filter((i)=>!Gl.has(i));if(r.length>0)n.push(`${t}: keys cradle does not map are ignored \u2014 pi reads them from ~/.pi/agent/settings.json or `+`the project's .pi/settings.json, not the agent folder: ${r.join(", ")}`)}var js=new Set(["npm","pnpm","yarn","bun"]);function Yl(e,t,n){let r=e.npmCommand;if(r===void 0)return;let[i,...s]=ze(r)?r:[];if(i===void 0||s.length>0||!js.has(i)){let o=[...js].join(", ");n.push(`${t}: npmCommand must be a single-element array naming one of ${o} \u2014 ignored`);return}return[i]}async function Jl(e,t,n){if(!t)return null;let r=we(e,"models.json"),i=await Qn(r),s=i.providers;if(s===void 0||!le(s))throw Error(`${r} must contain a "providers" object`);return Oe(i,r,["providers"],n),JSON.stringify(Kl(s),null,2)}function Kl(e){let t={input:0,output:0,cacheRead:0,cacheWrite:0};return Object.fromEntries(Object.entries(e).map(([n,r])=>{if(!le(r)||!Array.isArray(r.models))return[n,r];let i=r.models.map((s)=>le(s)&&s.cost===void 0?{cost:t,...s}:s);return[n,{...r,models:i}]}))}async function ql(e,t,n){if(!t)return null;if(!await ln(e,t))return n.push("skills must be a directory \u2014 ignored"),null;return we(e,"skills")}async function Xl(e,t,n){if(!t)return null;if(!await ln(e,t))return n.push("schedule must be a directory \u2014 ignored"),null;return we(e,"schedule")}async function Zl(e,t,n){if(!t)return[];if(!await ln(e,t))return n.push("extensions must be a directory \u2014 ignored"),[];let r=we(e,"extensions"),i=await Ns(r,{withFileTypes:!0});return(await Promise.all(i.sort((o,u)=>o.name.localeCompare(u.name)).map(async(o)=>{if(o.isFile()&&o.name.endsWith(".ts")&&!o.name.startsWith("."))return we(r,o.name);if(o.isDirectory()){let u=we(r,o.name,"index.ts");return await Bun.file(u).exists()?u:null}return null}))).filter((o)=>o!==null)}async function Ql(e,t,n){let r={nono:an,sbx:an};if(!t)return r;if(!await ln(e,t))return n.push("sandbox must be a directory \u2014 ignored"),r;let i=we(e,"sandbox","nono.json"),s=we(e,"sandbox","sbx.json"),o=await ks(i),u=await ks(s);if(o===void 0&&u===void 0)return n.push("sandbox/ has no nono.json or sbx.json \u2014 sandboxing stays off unless --sandbox is passed"),r;return{nono:o===void 0?an:ec(o,i,n),sbx:u===void 0?an:tc(u,s,n)}}function ec(e,t,n){let r=cn(e,"sandbox",t,n),i=oc(e,t,n);return sc(e,t,n),Oe(e,t,["sandbox","network","filesystem","unsafe_macos_seatbelt_rules","net"],n),{posture:r===!1?"disabled":"enabled",...i!==void 0?{network:i}:{},filesystem:uc(e.filesystem,t,n),unsafeMacosSeatbeltRules:ac(e.unsafe_macos_seatbelt_rules,t,n)}}function tc(e,t,n){let r=cn(e,"sandbox",t,n),i=nc(e,t,n);return Zn({record:e,key:"unsafe_macos_seatbelt_rules",path:t,explanation:"the sbx VM boundary replaces Seatbelt"},n),Oe(e,t,["sandbox","network","filesystem","unsafe_macos_seatbelt_rules"],n),{posture:r===!1?"disabled":"enabled",...i!==void 0?{network:i}:{},filesystem:rc(e.filesystem,t,n),unsafeMacosSeatbeltRules:[]}}function nc(e,t,n){let r=e.network;if(r===void 0)return;if(!le(r)){n.push(`${t}: network must be an object \u2014 ignored`);return}for(let c of["network_profile","open_port","listen_port"])Zn({record:r,key:c,path:t},n);let i=`${t} network`;Oe(r,i,["block","allow_domain","network_profile","open_port","listen_port"],n);let s=cn(r,"block",i,n),o=Rs(r,"allow_domain",i,n),u={...s!==void 0?{block:s}:{},...o.length>0?{allowDomain:o}:{}};return Object.keys(u).length>0?u:void 0}function rc(e,t,n){if(e===void 0)return $t;if(!le(e))return n.push(`${t}: filesystem must be an object \u2014 ignored`),$t;return Zn({record:e,key:"unix_socket_dir_bind",path:t,explanation:"Unix sockets cannot cross the sbx VM boundary"},n),Oe(e,`${t} filesystem`,["read","write","allow","unix_socket_dir_bind"],n),{read:ct(e,"read",t,n),write:ct(e,"write",t,n),allow:ct(e,"allow",t,n),unixSocketDirBind:[]}}function Zn({record:e,key:t,path:n,explanation:r},i){if(e[t]===void 0)return;i.push(`${n}: ${t} is nono-only \u2014 ${r!==void 0?`${r}; `:""}ignored`)}async function ks(e){return await ic(e)?Qn(e):void 0}async function ic(e){try{return await Nl(e),!0}catch(t){if(de(t,"ENOENT"))return!1;throw t}}function sc(e,t,n){if(e.net!==void 0)n.push(`${t}: "net" was removed \u2014 use "network" instead (see ARCHITECTURE.md) \u2014 ignored`)}function oc(e,t,n){let r=e.network;if(r===void 0)return;if(!le(r)){n.push(`${t}: network must be an object \u2014 ignored`);return}let i=`${t} network`;Oe(r,i,["block","network_profile","allow_domain","open_port","listen_port"],n);let s=cn(r,"block",i,n),o=Xn(r,"network_profile",i,n),u=Rs(r,"allow_domain",i,n),c=Ms(r,"open_port",i,n),p=Ms(r,"listen_port",i,n),b={...s!==void 0?{block:s}:{},...o!==void 0?{networkProfile:o}:{},...u.length>0?{allowDomain:u}:{},...c.length>0?{openPort:c}:{},...p.length>0?{listenPort:p}:{}};return Object.keys(b).length>0?b:void 0}function Rs(e,t,n,r){let i=e[t];if(i===void 0)return[];if(!ze(i))return r.push(`${n}: ${t} must be an array of strings \u2014 ignored`),[];let s=i.map((o)=>o.trim()).filter((o)=>o!=="");if(s.length!==i.length)r.push(`${n}: ${t} entries must be non-empty \u2014 blanks ignored`);return s}function Ms(e,t,n,r){let i=e[t];if(i===void 0)return[];if(!Array.isArray(i))return r.push(`${n}: ${t} must be an array of port numbers \u2014 ignored`),[];let s=(u)=>typeof u==="number"&&Number.isInteger(u)&&u>=0&&u<=65535,o=i.filter((u)=>!s(u)).map((u)=>typeof u==="object"&&u!==null?JSON.stringify(u):String(u));if(o.length>0)r.push(`${n}: ${t} entries must be integers 0\u201365535 \u2014 ignored: ${o.join(", ")}`);return i.filter(s)}function ac(e,t,n){if(e===void 0)return[];if(!ze(e))return n.push(`${t}: unsafe_macos_seatbelt_rules must be an array of strings \u2014 ignored`),[];let r=(s)=>{let o=s.trim();return o.startsWith("(")&&o.endsWith(")")},i=e.filter((s)=>!r(s));if(i.length>0)n.push(`${t}: unsafe_macos_seatbelt_rules entries must be parenthesized s-expressions \u2014 ignored: ${i.join(", ")}`);return e.filter(r).map((s)=>s.trim())}function cn(e,t,n,r){let i=e[t];if(i===void 0)return;if(typeof i!=="boolean"){r.push(`${n}: ${t} must be true or false \u2014 ignored`);return}return i}function uc(e,t,n){if(e===void 0)return $t;if(!le(e))return n.push(`${t}: filesystem must be an object \u2014 ignored`),$t;return Oe(e,`${t} filesystem`,["read","write","allow","unix_socket_dir_bind"],n),{read:ct(e,"read",t,n),write:ct(e,"write",t,n),allow:ct(e,"allow",t,n),unixSocketDirBind:ct(e,"unix_socket_dir_bind",t,n)}}function ct(e,t,n,r){let i=e[t];if(i===void 0)return[];if(!ze(i))return r.push(`${n}: ${t} must be an array of strings \u2014 ignored`),[];let s=i.filter((o)=>!lt(o));if(s.length>0)r.push(`${n}: ${t} entries must be absolute, ~/, or $HOME/ paths \u2014 ignored: ${s.join(", ")}`);return i.filter(lt)}async function Qn(e){let t=Ft(await lc(e),e);if(!le(t))throw Error(`${e} must be a JSON object`);return t}async function lc(e){let t;try{t=await Ae(e)}catch(n){throw Error(`${e} could not be read: ${Se(n)}`,{cause:n})}if(t===void 0)throw Error(`${e} could not be read \u2014 broken symlink?`);return t}function Xn(e,t,n,r){let i=e[t];if(i===void 0)return;if(typeof i!=="string"){r.push(`${n}: ${t} must be a string \u2014 ignored`);return}return i}function cc(e,t,n){let r=e.defaultThinkingLevel;if(r===void 0)return;if(typeof r!=="string"||!$s.includes(r)){n.push(`${t}: defaultThinkingLevel must be one of ${$s.join(", ")} \u2014 ignored`);return}return r}import{exists as dc,readdir as fc}from"fs/promises";import{basename as hc,extname as Dc,join as Ls,resolve as gc}from"path";var pc=["name","description","cron","cwd"],Is=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function dn(e){let t=await dc(Ls(e,"schedules"))?" \u2014 found schedules/, rename it to schedule/ (singular)":"";return Error(`No schedule/ directory in ${e}${t}`)}async function fn(e,t){let n=await fc(e,{withFileTypes:!0}),r=[];return{schedules:[...(await Promise.all(n.map((o)=>mc(e,o,t,r)))).filter((o)=>o!==null)].sort((o,u)=>o.slug.localeCompare(u.slug)),warnings:r}}async function mc(e,t,n,r){let i=Ls(e,t.name);if(t.isDirectory())return r.push(`${i}: subdirectories are not supported in schedule/ \u2014 ignored`),null;if(!t.isFile()&&!t.isSymbolicLink())return r.push(`${i}: only files are read from schedule/ \u2014 ignored`),null;if(Dc(t.name)!==".md")return r.push(`${i}: only .md files are read from schedule/ \u2014 ignored`),null;return Fc(i,n,r)}async function Fc(e,t,n){let r=hc(e,".md");if(!Is.test(r))return n.push(`${e}: filename must match ${Is.source} \u2014 a schedule slug becomes a launchd label and a `+"systemd unit name \u2014 ignored"),null;let i=await Ae(e);if(i===void 0)return n.push(`${e}: could not be read \u2014 broken symlink? \u2014 ignored`),null;let s=yc(i);if(s===null)return n.push(`${e}: missing YAML frontmatter block (a file starting with "---" and a closing "---") \u2014 ignored`),null;let o=bc(s.frontmatter,e,n);if(o===null)return null;return Ec({slug:r,path:e,frontmatter:o,body:s.body,home:t,warnings:n})}function yc(e){let t=e.split(`
112
+ `).map((r)=>r.replace(/\r$/,""));if(t[0]!=="---")return null;let n=t.indexOf("---",1);if(n===-1)return null;return{frontmatter:t.slice(1,n).join(`
113
+ `),body:t.slice(n+1).join(`
114
+ `)}}function bc(e,t,n){let r;try{r=Bun.YAML.parse(e)}catch(i){return n.push(`${t}: frontmatter is not valid YAML: ${Se(i)} \u2014 ignored`),null}if(typeof r!=="object"||r===null||Array.isArray(r))return n.push(`${t}: frontmatter must be a YAML mapping \u2014 ignored`),null;return r}function Ec(e){let{slug:t,path:n,frontmatter:r,body:i,home:s,warnings:o}=e;Cc(r,n,o);let u=wc(r,n,o),c=xc(r,n,s,o),p=Ts(r,"name",n,o),b=Ts(r,"description",n,o),g=i.trim();if(u===null||c===null)return null;if(g==="")return o.push(`${n}: body is empty \u2014 a schedule with no prompt does nothing \u2014 ignored`),null;return{slug:t,name:p??t,path:n,cron:u,cwd:c,...b!==void 0?{description:b}:{},prompt:g}}function Cc(e,t,n){let r=Object.keys(e).filter((i)=>!pc.includes(i));if(r.length>0)n.push(`${t}: unsupported keys ignored: ${r.join(", ")}`)}function wc(e,t,n){let r=e.cron;if(typeof r!=="string"||r.trim()==="")return n.push(`${t}: cron must be a non-empty string \u2014 ignored`),null;return r}function xc(e,t,n,r){let i=e.cwd;if(typeof i!=="string"||!lt(i))return r.push(`${t}: cwd must be an absolute, ~/, or $HOME/ path${Sc(i)} \u2014 ignored`),null;return gc(ut(i,n))}function Sc(e){return e===null?' (a bare "~" is YAML null \u2014 quote it as "~" or write ~/some/dir)':""}function Ts(e,t,n,r){let i=e[t];if(i===void 0)return;if(typeof i!=="string"){r.push(`${n}: ${t} must be a string \u2014 ignored`);return}return i}import{createHash as Ac}from"crypto";import{homedir as Pc}from"os";import{basename as _c,join as vt}from"path";function er(e){let t=_c(e).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),n=Ac("sha256").update(e).digest("hex").slice(0,8);return`${t===""?"agent":t}-${n}`}function hn(e,t=Pc(),n=process.env.CRADLE_STATE_DIR){let r=n||vt(t,".cradle");return vt(r,"agents",er(e))}function Ws(e){return{extensionsDir:vt(e,"extensions"),sessionsDir:vt(e,"sessions"),miseCacheDir:vt(e,"mise-cache")}}import{readFile as Bc}from"fs/promises";import{join as Hs,resolve as Vs}from"path";var zs="gitdir:";async function Gs(e){try{return await Bc(e,"utf8")}catch{return}}async function Us(e){let t=await Gs(Hs(e,".git"));if(t===void 0||!t.startsWith(zs))return;let n=Vs(e,t.slice(zs.length).trim()),r=await Gs(Hs(n,"commondir")),i=r!==void 0?Vs(n,r.trim()):n;return tn(e,i)?void 0:i}async function qs(e,t={}){let n=t.home??$c(),r=t.cwd??process.cwd(),{dir:i,warnings:s}=await sn(e.dir,{home:n,cwd:r}),o=await un(i),u=await kc(e,o,n,r),c=hn(o.dir,n),{extensionsDir:p,sessionsDir:b,miseCacheDir:g}=Ws(c),D=Tc(e,o),F=e.dryRun??!1,y=Qc(D.backend,F,t.which),h=Rc({folder:o,flags:e,passthrough:u.passthrough,backend:D.backend,bins:y,stateDir:c,extensionsDir:p,sessionsDir:b,miseCacheDir:g}),v=await ed(D,o,{home:n,cwd:u.cwd,stateDir:c,profilePath:h.profilePath,sbxBin:y.sbxBin,hostPiBin:y.piBin,tty:t.tty??!1}),W=Ic(o,c);return{files:rd(o,D.backend),extensionsDir:p,sessionsDir:b,warnings:[...s,...u.warnings,...D.warnings,...v.warnings],profile:v.profile,sbx:v.sbx,packages:W,launch:h,cwd:u.cwd,dryRun:F}}async function kc(e,t,n,r){let i={cwd:r,passthrough:e.passthrough??[],warnings:[]};if(e.schedule===void 0)return i;if(t.scheduleDir===null)throw await dn(t.dir);let{schedules:s,warnings:o}=await fn(t.scheduleDir,n),u=s.find((c)=>c.slug===e.schedule);if(u===void 0)throw Error(Nc(e.schedule,s));return{cwd:u.cwd,passthrough:[...i.passthrough,"--print","--name",u.name,"--no-approve","--",u.prompt],warnings:[...o,...await Mc(u)]}}async function Mc(e){if(await Js(e.cwd))return[];return[`schedule "${e.slug}" cwd does not exist: ${e.cwd}`]}function Nc(e,t){let n=t.length>0?` (available: ${t.map((r)=>r.slug).join(", ")})`:" (schedule/ is empty)";return`Unknown schedule "${e}"${n}`}function Rc(e){let{folder:t,flags:n,passthrough:r,backend:i,bins:s,stateDir:o,extensionsDir:u,sessionsDir:c,miseCacheDir:p}=e;return{folder:t,stateDir:o,extensionsDir:u,sessionsDir:c,miseCacheDir:p,backend:i,passthrough:r,nonoBin:s.nonoBin,piBin:i==="sbx"?"pi":s.piBin,profilePath:jt(o,Zi),...n.verbose?{verbose:!0}:{}}}function Ic(e,t){let n=e.settings.packages;if(n===void 0||n.length===0)return null;return{npmDir:jt(t,"npm"),manifest:Ps(n),specs:n,installCommand:[...e.settings.npmCommand??["npm"],"install","--ignore-scripts"]}}function Tc(e,t){let{backend:n,warnings:r}=Gc(e,t),i=[],s=Lc(e,t,n,i);return{backend:n,network:s,warnings:Vc(n!==null,s,[...r,...i])}}function Lc(e,t,n,r){if(e.offline)return{block:!0};let i=Wc(e.allowHost??[],r);if(i.length>0)return{allowDomain:i};return n==="sbx"?t.sbx.network:t.sandbox.network}function Wc(e,t){let n=e.map((r)=>r.trim()).filter((r)=>r!=="");if(n.length!==e.length)t.push("--allow-host entries must be non-empty \u2014 blanks ignored");return n}function Hc(e){return e!==void 0&&(e.block===!0||(e.allowDomain?.length??0)>0)}function Vc(e,t,n){if(e||!Hc(t))return n;return[...n,"network policy has no effect without the sandbox \u2014 pi runs with no network isolation (--sandbox to enforce it)"]}function zc(e){return e.offline===!0||(e.allowHost?.length??0)>0}function Gc(e,t){if(e.noSandbox===!0)return{backend:null,warnings:t.warnings};if(e.sandboxBackend!==void 0)return{backend:e.sandboxBackend,warnings:t.warnings};let n=Uc(t);if(e.noSandbox===!1||n.backend!==null)return{...n,backend:n.backend??"nono"};return Yc(e,t,n.warnings)}function Uc(e){let t=e.sandbox.posture==="enabled",n=e.sbx.posture==="enabled";if(t&&n)return{backend:"nono",warnings:[...e.warnings,"both sandbox/nono.json and sandbox/sbx.json declare a sandbox \u2014 using nono (pass --sandbox-backend sbx to override)"]};return{backend:t?"nono":n?"sbx":null,warnings:e.warnings}}function Yc(e,t,n){let r=Jc(t);if(zc(e))return{backend:"nono",warnings:[...n,`${r} \u2014 sandbox forced on to enforce the requested network policy (--no-sandbox to override)`]};return{backend:null,warnings:[...n,`${r} \u2014 agent is running without OS isolation (--sandbox to force enable)`]}}function Jc(e){if(e.sandbox.posture==="disabled")return"sandbox disabled by sandbox/nono.json";if(e.sbx.posture==="disabled")return"sandbox disabled by sandbox/sbx.json";return"sandbox/nono.json or sbx.json not found"}async function Xs(e,t={}){let n={dryRun:!1,results:[],failures:[]};if(await rs(n,"extensions",e.extensionsDir,e.files),n.failures.length>0)throw Error(`Failed to write agent extensions: ${n.failures.join("; ")}`);if(await tr(e.sessionsDir,{recursive:!0}),e.profile!==null)await tr(jc(e.profile.path),{recursive:!0}),await Ks(e.profile.path,e.profile.content,"utf8");if(e.sbx!==null)await Kc(e.sbx,t);let r={...e.launch,extensionsDir:e.extensionsDir,sessionsDir:e.sessionsDir},i=e.packages===null?{argv:pt(r),warnings:[]}:await Zc(e.packages,r,t);if(e.sbx===null)return i;return{argv:on(e.sbx.spec,i.argv),warnings:i.warnings}}async function Kc(e,t){let n=t.run;if(n===void 0)throw Error("An sbx-backend run needs a command runner but none was provided");let r=await n(e.createArgv);if(r.exitCode!==0&&!ms(r.stderr))throw Error(`Failed to create sbx sandbox ${e.spec.name}: ${r.stderr.trim()}`);for(let i of e.policyArgvs)await Ys(n,i,`apply sbx network policy (${e.spec.name})`);await Ys(n,await qc(e,t),`provision pi in sbx sandbox ${e.spec.name}`)}async function Ys(e,t,n){let r=await e(t);if(r.exitCode!==0)throw Error(`Failed to ${n}: ${r.stderr.trim()}`)}async function qc(e,t){if(t.readPiVersion===void 0)return e.provisionArgv;let n=await t.readPiVersion(e.hostPiBin);return Un({...e.spec,piVersion:n})}async function Xc(e,t){if(await Ae(jt(e,"package.json"))!==t)return!1;return Js(jt(e,"node_modules"))}async function Zc(e,t,n){if(await tr(e.npmDir,{recursive:!0}),!await Xc(e.npmDir,e.manifest)){if(n.install===void 0)throw Error("Packages declared but no installer provided");let s=jt(e.npmDir,"package.json");await Ks(s,e.manifest,"utf8");try{await n.install(e.installCommand,e.npmDir)}catch(o){throw await Oc(s,{force:!0}),o}}let{entries:r,warnings:i}=await _s(e.npmDir,e.specs);return{argv:pt({...t,packageEntries:r}),warnings:i}}function Qc(e,t,n){if(t)return{nonoBin:"nono",piBin:"pi",sbxBin:"sbx"};return{nonoBin:e==="nono"?mt("nono",n):"nono",sbxBin:e==="sbx"?mt("sbx",n):"sbx",piBin:mt("pi",n)}}async function ed(e,t,n){let r=e.backend!==null?await Us(n.cwd):void 0,i=nd(e.backend==="nono",t,e.network,{home:n.home,cwd:n.cwd,stateDir:n.stateDir,profilePath:n.profilePath,...r!==void 0?{linkedGitDir:r}:{}});if(e.backend!=="sbx")return{profile:i,sbx:null,warnings:[]};let s=td(e.network,t,{...n,...r!==void 0?{linkedGitDir:r}:{}});return{profile:i,sbx:s,warnings:[...gs(e.network),...ps(t.sbx.filesystem)]}}function td(e,t,n){let r=ds({cwd:n.cwd,agentDir:t.dir,stateDir:n.stateDir,home:n.home,grants:t.sbx.filesystem,...n.linkedGitDir!==void 0?{linkedGitDir:n.linkedGitDir}:{}}),i={sbxBin:n.sbxBin,name:fs(vc(n.stateDir),r),cwd:n.cwd,home:n.home,mounts:r,...e!==void 0?{network:e}:{},piVersion:null,tty:n.tty};return{spec:i,hostPiBin:n.hostPiBin,createArgv:hs(i),policyArgvs:Ds(i),provisionArgv:Un(i)}}function nd(e,t,n,r){if(!e)return null;let i=Qi(r.cwd,r.home);if(i!==void 0)throw Error(`cannot sandbox from ${i} \u2014 this directory is (or contains) nono's protected state root `+"(~/.local/state/nono) and nono refuses to start with an overlapping grant; run `cradle run` from a project directory instead");let s=es({home:r.home,cwd:r.cwd,agentDir:t.dir,stateDir:r.stateDir,grants:t.sandbox.filesystem,rules:t.sandbox.unsafeMacosSeatbeltRules,...n!==void 0?{network:n}:{},...r.linkedGitDir!==void 0?{linkedGitDir:r.linkedGitDir}:{}});return{path:r.profilePath,content:s}}function rd(e,t){return[...e.providersJson!==null?[{rel:"providers.ts",content:ys(e.providersJson,{rewriteLocalhostBaseUrls:t==="sbx"})}]:[],...t==="nono"?[{rel:Qt,content:Ui()}]:[]]}import{exists as Ld,mkdir as ho,readFile as Wd,rm as Hd,writeFile as Vd}from"fs/promises";import{homedir as zd,userInfo as Gd}from"os";import{dirname as Do,join as Ud}from"path";var id={jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},sd={sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6};function od(e){return e===7?0:e}var eo={name:"minute",min:0,max:59,canonicalMax:59},to={name:"hour",min:0,max:23,canonicalMax:23},no={name:"day-of-month",min:1,max:31,canonicalMax:31},ro={name:"month",min:1,max:12,canonicalMax:12,names:id},io={name:"day-of-week",min:0,max:7,canonicalMax:6,names:sd,normalize:od},ad={"@hourly":"0 * * * *","@daily":"0 0 * * *","@midnight":"0 0 * * *","@weekly":"0 0 * * 0","@monthly":"0 0 1 * *","@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *"};function $e(e,t){return Error(`Invalid cron expression "${e}": ${t}`)}function ud(e){let t=e.trim();if(!t.startsWith("@"))return t;let n=ad[t.toLowerCase()];if(n===void 0)throw $e(e,`unknown macro "${t}"`);return n}var Zs=[eo,to,no,ro,io];function ld(e,t){let n=e.split(/\s+/).filter((r)=>r.length>0);if(n.length!==Zs.length)throw $e(t,`expected ${String(Zs.length)} space-separated fields, got ${String(n.length)}`);return n}function Qs(e,t){return Array.from({length:t-e+1},(n,r)=>e+r)}function nr(e,t,n){let i=t.names?.[e.toLowerCase()]??(/^\d+$/.test(e)?Number(e):Number.NaN);if(!Number.isInteger(i)||i<t.min||i>t.max)throw $e(n,`${t.name} field: token "${e}" is out of range (${String(t.min)}-${String(t.max)})`);return i}function cd(e,t,n){if(e==="*")return Qs(t.min,t.max);let r=e.split("-");if(r.length===1)return[nr(e,t,n)];if(r.length!==2)throw $e(n,`${t.name} field: could not parse token "${e}"`);let[i,s]=r,o=nr(i??"",t,n),u=nr(s??"",t,n);if(o>u)throw $e(n,`${t.name} field: reversed range "${e}" (start greater than end)`);return Qs(o,u)}function dd(e,t,n){if(e===void 0)return 1;let r=/^\d+$/.test(e)?Number(e):Number.NaN;if(!Number.isInteger(r)||r<1)throw $e(n,`${t.name} field: step must be a positive integer, got "${e}"`);return r}function fd(e,t,n){let r=e.split("/");if(r.length>2)throw $e(n,`${t.name} field: could not parse token "${e}"`);let[i,s]=r;if(s!==void 0&&i!=="*"&&!i?.includes("-"))throw $e(n,`${t.name} field: a step is only valid with "*" or a range, not "${e}"`);let o=cd(i??"",t,n),u=dd(s,t,n);return o.filter((c,p)=>p%u===0)}function hd(e,t){let n=t.normalize?e.map(t.normalize):e,r=Array.from(new Set(n)).sort((s,o)=>s-o),i=t.canonicalMax-t.min+1;return r.length===i?null:r}function Dd(e,t,n){if(e.length===0)throw $e(n,`${t.name} field: empty token`);let r=e.split(",").flatMap((i)=>fd(i,t,n));return hd(r,t)}function rr(e){let t=ld(ud(e),e),n=(s,o)=>Dd(t[s]??"",o,e),r=n(2,no),i=n(4,io);if(r!==null&&i!==null)throw $e(e,"day-of-month and day-of-week cannot both be restricted (cron ORs them; launchd/systemd AND them, so there is no faithful encoding)");return{minute:n(0,eo),hour:n(1,to),dayOfMonth:r,month:n(3,ro),dayOfWeek:i}}function kt(e,t){return e===null||e.includes(t)}function gd(e,t){return kt(e.month,t.getMonth()+1)&&kt(e.dayOfMonth,t.getDate())&&kt(e.dayOfWeek,t.getDay())}function pd(e,t){return kt(e.hour,t.getHours())}function md(e,t){return kt(e.minute,t.getMinutes())}function Fd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes()+1)}function yd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+1)}function bd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours()+1)}function Ed(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes()+1)}function so(e,t){let n=new Date(t.getFullYear(),t.getMonth(),t.getDate()+366,t.getHours(),t.getMinutes()),r=Fd(t);while(r.getTime()<=n.getTime()){if(!gd(e,r)){r=yd(r);continue}if(!pd(e,r)){r=bd(r);continue}if(md(e,r))return r;r=Ed(r)}return null}import{join as ir}from"path";var oo=500;class ao extends Error{constructor(e){super(`cron expression expands to ${String(e)} StartCalendarInterval dicts, over the ${String(oo)}-dict cap`);this.name="LaunchdIntervalOverflowError"}}function Cd(e){return[ir(e,".local","bin"),ir(e,".local","share","mise","shims"),"/opt/homebrew/bin","/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"].join(":")}function wd(e){return[{key:"Minute",field:e.minute},{key:"Hour",field:e.hour},{key:"Day",field:e.dayOfMonth},{key:"Month",field:e.month},{key:"Weekday",field:e.dayOfWeek}].filter((n)=>n.field!==null).map((n)=>({key:n.key,values:n.field}))}function xd(e){let t=wd(e);if(t.length===0)return Array.from({length:60},(r,i)=>({Minute:i}));let n=t.reduce((r,i)=>r.flatMap((s)=>i.values.map((o)=>({...s,[i.key]:o}))),[{}]);if(n.length>oo)throw new ao(n.length);return n}function Sd(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function bt(e){return`<string>${Sd(e)}</string>`}function Ad(e,t){let n=e.map((r)=>`${t} ${bt(r)}`).join(`
115
+ `);return`${t}<array>
116
+ ${n}
117
+ ${t}</array>`}function Pd(e,t){let n=Object.entries(e).map(([r,i])=>`${t} <key>${r}</key>
118
+ ${t} <integer>${String(i)}</integer>`).join(`
119
+ `);return`${t}<dict>
120
+ ${n}
121
+ ${t}</dict>`}function _d(e,t){let n=e.map((r)=>Pd(r,`${t} `)).join(`
122
+ `);return`${t}<array>
123
+ ${n}
124
+ ${t}</array>`}function Bd(e,t,n){let{schedule:r,cradleBin:i,agentDir:s,logPath:o,home:u}=e,c=[i,"schedule","run",s,r.slug];return['<?xml version="1.0" encoding="UTF-8"?>','<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">','<plist version="1.0">',"<dict>"," <key>ProgramArguments</key>",Ad(c," ")," <key>WorkingDirectory</key>",` ${bt(r.cwd)}`," <key>StartCalendarInterval</key>",_d(n," ")," <key>StandardOutPath</key>",` ${bt(o)}`," <key>StandardErrorPath</key>",` ${bt(o)}`," <key>EnvironmentVariables</key>"," <dict>"," <key>PATH</key>",` ${bt(Cd(u))}`," </dict>"," <key>RunAtLoad</key>"," <false/>"," <key>ProcessType</key>"," <string>Background</string>"," <key>Label</key>",` ${bt(t)}`,"</dict>","</plist>",""].join(`
125
+ `)}function Od(e){return`gui/${String(e)}`}function uo(e,t){let n=`com.cradle.${e.agentId}.${e.schedule.slug}`,r=ir(e.home,"Library","LaunchAgents",`${n}.plist`),i=xd(t),s=Bd(e,n,i),o=Od(e.uid),u=`${o}/${n}`;return{id:n,files:[{path:r,content:s}],installSteps:[{argv:["launchctl","bootout",u],ignoreFailure:!0},{argv:["launchctl","bootstrap",o,r]},{argv:["launchctl","enable",u]}],removeSteps:[{argv:["launchctl","bootout",u],ignoreFailure:!0}]}}import{join as Mt}from"path";class lo extends Error{constructor(e){super(`systemd unit values cannot contain a newline, got ${JSON.stringify(e)}`);this.name="SystemdUnitValueError"}}function Ue(e){if(e.includes(`
126
+ `))throw new lo(e);return e.replaceAll("%","%%")}function $d(e){return`"${e.replaceAll("\\","\\\\").replaceAll('"',"\\\"")}"`}function vd(e){return String(e).padStart(2,"0")}function Dn(e){return e===null?"*":e.map(vd).join(",")}var jd=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function kd(e){let t=jd[e];if(t===void 0)throw Error(`Day-of-week value out of range: ${String(e)}`);return t}function Md(e){return e===null?void 0:e.map(kd).join(",")}function Nd(e){let t=Md(e.dayOfWeek),n=`*-${Dn(e.month)}-${Dn(e.dayOfMonth)}`,r=`${Dn(e.hour)}:${Dn(e.minute)}:00`;return t===void 0?`${n} ${r}`:`${t} ${n} ${r}`}function Rd(e){return[Mt(e,".local","bin"),Mt(e,".local","share","mise","shims"),"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"].join(":")}function Id(e){let t=Ue(e.schedule.name),n=Ue(e.schedule.cwd),r=Ue(e.cradleBin),i=Ue(e.agentDir),s=Ue(e.schedule.slug),o=Ue(e.logPath);return["[Unit]",`Description=${t}`,"","[Service]","Type=oneshot",`WorkingDirectory=${n}`,`Environment=PATH=${Ue(Rd(e.home))}`,`ExecStart=${[r,"schedule","run",i,s].map($d).join(" ")}`,`StandardOutput=append:${o}`,`StandardError=append:${o}`,""].join(`
127
+ `)}function Td(e,t){let n=Ue(e.schedule.name),r=Nd(t);return["[Unit]",`Description=${n}`,"","[Timer]",`OnCalendar=${r}`,"Persistent=true","","[Install]","WantedBy=timers.target",""].join(`
128
+ `)}function co(e,t){let n=`cradle-${e.agentId}-${e.schedule.slug}`,r=Mt(e.home,".config","systemd","user"),i=Mt(r,`${n}.service`),s=Mt(r,`${n}.timer`),o=`${n}.timer`;return{id:n,files:[{path:i,content:Id(e)},{path:s,content:Td(e,t)}],installSteps:[{argv:["systemctl","--user","daemon-reload"]},{argv:["systemctl","--user","enable","--now",o]}],removeSteps:[{argv:["systemctl","--user","disable","--now",o],ignoreFailure:!0},{argv:["systemctl","--user","daemon-reload"]}]}}function fo(e){return["loginctl","show-user",e,"--property=Linger"]}var sr="systemd user timers stop firing once you log out unless lingering is enabled \u2014 run `loginctl enable-linger <user>` to keep them running";function Yd(e){if(e!=="darwin"&&e!=="linux")throw Error(`Scheduled tasks are not supported on ${e} \u2014 launchd (macOS) and systemd (Linux) are the supported timer backends`)}async function Jd(e,t,n){let{dir:r,warnings:i}=await sn(e.dir,{home:t,cwd:n}),s=await un(r);if(s.scheduleDir===null)throw await dn(s.dir);let{schedules:o,warnings:u}=await fn(s.scheduleDir,t);return{folder:s,schedules:o,warnings:[...i,...u],stateDir:hn(s.dir,t)}}function Kd(e,t){return(n)=>({schedule:n,agentId:er(e.folder.dir),agentDir:e.folder.dir,cradleBin:t.cradleBin,logPath:Ud(e.stateDir,"schedule",`${n.slug}.log`),home:t.home,uid:t.uid})}async function go(e,t={}){let n=qd(e,t),r=await Jd(e,n.home,n.cwd),i=Qd(e,n.dryRun,t.which),s=Kd(r,{cradleBin:i,home:n.home,uid:n.uid}),o={flags:e,base:r,contextFor:s,platform:n.platform,deps:t,dryRun:n.dryRun,cradleBinResolved:i!==or};return e.action==="list"?ef(o):tf(o)}function qd(e,t){let n=t.platform??process.platform;return Yd(n),{home:t.home??zd(),cwd:t.cwd??process.cwd(),platform:n,uid:t.uid??Xd(),dryRun:e.dryRun??!1}}function Xd(){return process.getuid?.()??0}function Zd(e,t){return e.action==="install"&&!t}var or="cradle";function Qd(e,t,n){if(Zd(e,t))return mt("cradle",n);if(e.action!=="list")return or;return _t("cradle",n)??or}async function ef(e){let t=e.deps.now??(()=>new Date),n=await Promise.all(e.base.schedules.map((r)=>of(r,{timer:e.contextFor(r),platform:e.platform,now:t,cradleBinResolved:e.cradleBinResolved})));return{action:"list",folder:e.base.folder,platform:e.platform,rows:n,targets:[],warnings:e.base.warnings,dryRun:e.dryRun,lingerCheckArgv:null}}function tf(e){let t=nf(e.base.schedules,e.flags).map((r)=>sf(r,e.contextFor(r),e.platform)),n=e.flags.action==="install"&&e.platform==="linux"?fo(e.deps.user??Gd().username):null;return{action:e.flags.action,folder:e.base.folder,platform:e.platform,rows:[],targets:t,warnings:e.base.warnings,dryRun:e.dryRun,lingerCheckArgv:n}}function nf(e,t){if(t.slug===void 0)return e;let n=e.find((r)=>r.slug===t.slug);if(n===void 0)throw Error(rf(t.slug,e));return[n]}function rf(e,t){let n=t.length>0?` (available: ${t.map((r)=>r.slug).join(", ")})`:" (schedule/ is empty)";return`Unknown schedule "${e}"${n}`}function sf(e,t,n){return{schedule:e,timerPlan:po(t,n,rr(e.cron)),logPath:t.logPath}}function po(e,t,n){return t==="darwin"?uo(e,n):co(e,n)}async function of(e,t){let n={slug:e.slug,name:e.name,cron:e.cron,cwd:e.cwd};try{let r=rr(e.cron),i=po(t.timer,t.platform,r);return{...n,nextFire:so(r,t.now()),status:await uf(i.files,t.cradleBinResolved)}}catch(r){return{...n,cronError:Se(r),nextFire:null,status:"not-installed"}}}async function af(e,t){if(!await Ld(e.path))return"missing";if(!t)return"matches";return await Wd(e.path,"utf8")===e.content?"matches":"differs"}async function uf(e,t){let n=await Promise.all(e.map((r)=>af(r,t)));if(n.every((r)=>r==="missing"))return"not-installed";return n.every((r)=>r==="matches")?"installed":"stale"}function mo(e){if(e.length===0)return"No schedules found.";return e.map(cf).join(`
129
+
130
+ `)}var lf={installed:"installed",stale:"stale \u2014 the installed timer predates this file; run `cradle schedule install` to update it","not-installed":"not installed"};function cf(e){return[`${e.slug} \u2014 ${e.name}`,` cron: ${e.cron} (${df(e)})`,` cwd: ${e.cwd}`,` timer: ${lf[e.status]}`].join(`
131
+ `)}function df(e){if(e.cronError!==void 0)return`INVALID: ${e.cronError}`;return`${e.status==="stale"?"next after install":"next"}: ${ff(e.nextFire)}`}function ff(e){return e===null?"never (cannot fire within the next year)":e.toLocaleString()}async function Fo(e,t={}){if(e.dryRun)throw Error("Cannot materialize a --dry-run schedule plan; it is a preview only");if(e.action==="remove")return{warnings:await gf(e,t)};if(e.action==="install")return{warnings:await hf(e,t)};return{warnings:[]}}async function hf(e,t){let n=yo(t),r=await Df(e.lingerCheckArgv,n);for(let i of e.targets)await pf(i.timerPlan.files),await ho(Do(i.logPath),{recursive:!0}),await bo(n,i.timerPlan.installSteps,`install schedule "${i.schedule.slug}"`);return r}async function Df(e,t){if(e===null)return[];try{return(await t(e)).stdout.includes("Linger=yes")?[]:[sr]}catch{return[sr]}}async function gf(e,t){let n=yo(t);for(let r of e.targets)await bo(n,r.timerPlan.removeSteps,`remove schedule "${r.schedule.slug}"`),await Promise.all(r.timerPlan.files.map((i)=>Hd(i.path,{force:!0})));return[]}async function pf(e){for(let t of e)await ho(Do(t.path),{recursive:!0}),await Vd(t.path,t.content,"utf8")}function yo(e){if(e.run===void 0)throw Error("A schedule install/remove needs a command runner but none was provided");return e.run}async function bo(e,t,n){for(let r of t){let i=await e(r.argv);if(i.exitCode!==0&&r.ignoreFailure!==!0)throw Error(`Failed to ${n} (${r.argv.join(" ")}): ${i.stderr.trim()}`)}}function Eo(e,t){return t?`\x1B[33m${e}\x1B[0m`:e}function Co(e,t){return()=>{e.kill(t)}}async function wo(e,t={},n){let[r,...i]=e;if(!r)throw Error("Command requires at least one argument");let s=Bun.spawn([r,...i],{stdin:"inherit",stdout:"inherit",stderr:"inherit",env:{...process.env,...t},...n!==void 0?{cwd:n}:{}}),o=Co(s,"SIGINT"),u=Co(s,"SIGTERM");process.on("SIGINT",o),process.on("SIGTERM",u);try{return await s.exited}finally{process.off("SIGINT",o),process.off("SIGTERM",u)}}async function xo(e){let[t,...n]=e;if(!t)throw Error("Command requires at least one argument");let r=Bun.spawn([t,...n],{stdin:"ignore",stdout:"ignore",stderr:"pipe",env:process.env}),[i,s]=await Promise.all([new Response(r.stderr).text(),r.exited]);return{exitCode:s,stderr:i}}async function So(e){let[t,...n]=e;if(!t)throw Error("Command requires at least one argument");let r=Bun.spawn([t,...n],{stdin:"ignore",stdout:"pipe",stderr:"pipe",env:process.env}),[i,s,o]=await Promise.all([new Response(r.stdout).text(),new Response(r.stderr).text(),r.exited]);return{exitCode:o,stdout:i,stderr:s}}async function Ao(e,t){let[n,...r]=e;if(!n)throw Error("Command requires at least one argument");let s=await Bun.spawn([n,...r],{cwd:t,stdin:"ignore",stdout:"inherit",stderr:"inherit",env:process.env}).exited;if(s!==0)throw Error(`Package install failed (${e.join(" ")} exited ${String(s)})`)}var Et=zi(process.argv.slice(2)).scriptName("cradle").version(Gi.version).usage("$0 <cmd> [args]").parserConfiguration({"populate--":!0,"parse-numbers":!1,"parse-positional-numbers":!1}).strict();Et.command("$0","show help",()=>{},async()=>{console.log(await Et.getHelp())});Et.command("run [dir]","run an agent folder with pi, sandboxed when sandbox/nono.json or sandbox/sbx.json is present",(e)=>e.positional("dir",{type:"string",default:".",describe:"agent folder, or a name from ~/.cradle/settings.json (default: .)"}).option("offline",{type:"boolean",description:"block all outbound network (overrides the folder network policy; implies --sandbox)"}).option("allow-host",{type:"array",string:!0,description:"restrict network to these hosts (repeatable; overrides the folder allowlist; implies --sandbox)"}).option("sandbox",{type:"boolean",description:"run sandboxed (--sandbox forces it when no sandbox/ file enables one or the folder opts out; --no-sandbox disables)"}).option("sandbox-backend",{type:"string",choices:["nono","sbx"],description:"sandbox implementation (implies --sandbox): nono (host OS policy) or sbx (Docker Sandboxes microVM)"}).option("verbose",{type:"boolean",default:!1,description:"show nono's full sandbox capabilities banner instead of the one-line status"}).option("dry-run",{type:"boolean",default:!1,description:"print the write plan + command, do not spawn"}).epilogue("Everything after `--` is forwarded to pi."),async(e)=>{let t=(e["--"]??[]).map(String),n=(e.allowHost??[]).map(String),r={dir:e.dir,dryRun:e.dryRun,...e.sandbox!==void 0?{noSandbox:!e.sandbox}:{},...e.sandboxBackend!==void 0?{sandboxBackend:e.sandboxBackend}:{},...e.offline?{offline:!0}:{},...n.length?{allowHost:n}:{},...e.verbose?{verbose:!0}:{},...t.length?{passthrough:t}:{}};await _o(r)});Et.command("schedule <action> [dir] [task]","manage schedule/*.md tasks as launchd (macOS) / systemd --user (Linux) timers",(e)=>e.positional("action",{type:"string",choices:["list","install","remove","run"],demandOption:!0,describe:"list every schedule, install/remove their timers, or run one now"}).positional("dir",{type:"string",default:".",describe:"agent folder, or a name from ~/.cradle/settings.json (default: .)"}).positional("task",{type:"string",describe:"schedule slug \u2014 required for `run`; an optional filter for `install`/`remove` (default: every schedule)"}).option("dry-run",{type:"boolean",default:!1,description:"install/remove: print what would change, touch nothing"}),async(e)=>{if(e.action==="run"){if(e.task===void 0){ar(Error("A task slug is required: cradle schedule run <dir> <task>"));return}await _o({dir:e.dir,schedule:e.task});return}await mf({dir:e.dir,action:e.action,...e.task!==void 0?{slug:e.task}:{},...e.dryRun?{dryRun:!0}:{}})});Et.command("doctor","check pi / nono / mise on PATH",()=>{},async()=>{let e=await Ki({readVersion:Bo});console.log(qi(e)),process.exitCode=Xi(e)});async function _o(e){try{let t=await qs(e,{tty:process.stdout.isTTY});if(gn(t.warnings),t.dryRun){yf(t);return}let n=await Xs(t,{install:Ao,run:xo,readPiVersion:Bo});if(gn(n.warnings),t.profile!==null&&!e.verbose)console.log("\uD83D\uDD12 Sandbox Active");if(t.sbx!==null&&!e.verbose)console.log("\uD83D\uDD12 Sandbox Active (sbx)");process.exit(await wo(n.argv,Gn(t.launch),t.cwd))}catch(t){ar(t)}}async function mf(e){try{let t=await go(e);if(gn(t.warnings),t.action==="list"){console.log(mo(t.rows));return}if(t.dryRun){Ff(t);return}let n=await Fo(t,{run:So});gn(n.warnings)}catch(t){ar(t)}}function Ff(e){for(let t of e.targets){if(e.action==="install"){for(let n of t.timerPlan.files)console.log(`write: ${n.path}`);for(let n of t.timerPlan.installSteps)console.log(`install: ${n.argv.map(Ve).join(" ")}`);continue}for(let n of t.timerPlan.removeSteps)console.log(`remove: ${n.argv.map(Ve).join(" ")}`);for(let n of t.timerPlan.files)console.log(`delete: ${n.path}`)}}function yf(e){for(let r of e.files)console.log(`write: ${Po(e.extensionsDir,r.rel)}`);if(e.profile!==null)console.log(`write: ${e.profile.path}`);if(e.sbx!==null)bf(e.sbx);if(e.packages!==null)Ef(e.packages);let t=Object.entries(Gn(e.launch)).map(([r,i])=>`${r}=${Ve(i)}`),n=e.sbx!==null?on(e.sbx.spec,pt(e.launch)):pt(e.launch);console.log([...t,...n.map(Ve)].join(" "))}function bf(e){console.log(`create: ${e.createArgv.map(Ve).join(" ")}`);for(let t of e.policyArgvs)console.log(`policy: ${t.map(Ve).join(" ")}`);console.log(`provision: ${e.provisionArgv.map(Ve).join(" ")}`)}function Ef(e){console.log(`write: ${Po(e.npmDir,"package.json")}`);let t=e.specs.map((n)=>`${n.name}@${n.version}`).join(", ");console.log(`install: ${e.installCommand.join(" ")} (${e.npmDir}): ${t}`)}function gn(e){let t=process.stderr.isTTY;for(let n of e)console.error(Eo(`warning: ${n}`,t))}async function Bo(e,t=["--version"]){try{let n=Bun.spawn([e,...t],{stdout:"pipe",stderr:"ignore"}),[r,i]=await Promise.all([new Response(n.stdout).text(),n.exited]);if(i!==0)return null;return r.split(`
132
+ `)[0]?.match(/v?\d+\.\d+\S*/)?.[0]??null}catch{return null}}function ar(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}Et.parse();