@coryrylan/cradle 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +22 -0
- package/dist/agent/folder.d.ts +3 -1
- package/dist/agent/schedules.d.ts +27 -0
- package/dist/commands/doctor.d.ts +6 -2
- package/dist/commands/run.d.ts +19 -0
- package/dist/commands/schedule.d.ts +85 -0
- package/dist/index.js +49 -29
- package/dist/schedule/cron.d.ts +22 -0
- package/dist/schedule/launchd.d.ts +12 -0
- package/dist/schedule/systemd.d.ts +17 -0
- package/dist/schedule/timer.d.ts +34 -0
- package/dist/util/proc.d.ts +17 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
4
|
-
`).map((
|
|
5
|
-
`)}rowToString(e,
|
|
6
|
-
`);else i
|
|
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
|
-
`),
|
|
9
|
-
`){if(s)
|
|
10
|
-
`){if(
|
|
3
|
+
var _o=Object.create;var{getPrototypeOf:Bo,defineProperty:ur,getOwnPropertyNames:Oo}=Object;var $o=Object.prototype.hasOwnProperty;function vo(e){return this[e]}var jo,ko,Mo=(e,n,t)=>{var r=e!=null&&typeof e==="object";if(r){var i=n?jo??=new WeakMap:ko??=new WeakMap,s=i.get(e);if(s)return s}t=e!=null?_o(Bo(e)):{};let o=n||!e||!e.__esModule?ur(t,"default",{value:e,enumerable:!0}):t;if(e&&typeof e==="object"||typeof e==="function"){for(let u of Oo(e))if(!$o.call(o,u))ur(o,u,{get:vo.bind(e,u),enumerable:!0})}if(r)i.set(e,o);return o};var No=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var Qr=No(function(Ph,Zr){Zr.exports=function(n){if(n===void 0)n=2;if(n>=Error.stackTraceLimit)throw TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+n+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");var t=Error.prepareStackTrace;Error.prepareStackTrace=function(i,s){return s};var r=Error().stack;if(Error.prepareStackTrace=t,r!==null&&typeof r==="object")return r[n]?r[n].getFileName():void 0}});import{join as So}from"path";import{notStrictEqual as ka,strictEqual as Ma}from"assert";var Ro={right:Lo,center:Wo};class cr{constructor(e){var n;this.width=e.width,this.wrap=(n=e.wrap)!==null&&n!==void 0?n:!0,this.rows=[]}span(...e){let n=this.div(...e);n.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 n=e.map((t)=>{if(typeof t==="string")return this.colFromString(t);return t});return this.rows.push(n),n}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]==="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let n=e.split(`
|
|
4
|
+
`).map((r)=>r.split("\t")),t=0;return n.forEach((r)=>{if(r.length>1&&ge.stringWidth(r[0])>t)t=Math.min(Math.floor(this.width*0.5),ge.stringWidth(r[0]))}),n.forEach((r)=>{this.div(...r.map((i,s)=>({text:i.trim(),padding:this.measurePadding(i),width:s===0&&r.length>1?t:void 0})))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){let n=ge.stripAnsi(e);return[0,n.match(/\s*$/)[0].length,0,n.match(/^\s*/)[0].length]}toString(){let e=[];return this.rows.forEach((n)=>{this.rowToString(n,e)}),e.filter((n)=>!n.hidden).map((n)=>n.text).join(`
|
|
5
|
+
`)}rowToString(e,n){return this.rasterize(e).forEach((t,r)=>{let i="";t.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=Ro[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+=lr(e[o],p,"| "),i+=p,i+=lr(e[o],p," |"),b[1])i+=" ".repeat(b[1]);if(r===0&&n.length>0)i=this.renderInline(i,n[n.length-1])}),n.push({text:i.replace(/ +$/,""),span:e.span})}),n}renderInline(e,n){let t=e.match(/^ */),r=t?t[0].length:0,i=n.text,s=ge.stringWidth(i.trimRight());if(!n.span)return e;if(!this.wrap)return n.hidden=!0,i+e;if(r<s)return e;return n.hidden=!0,i.trimRight()+" ".repeat(r-s)+e.trimLeft()}rasterize(e){let n=[],t=this.columnWidths(e),r;return e.forEach((i,s)=>{if(i.width=t[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(!n[u])n.push([]);let c=n[u];for(let p=0;p<s;p++)if(c[p]===void 0)c.push("");c.push(o)})}),n}negatePadding(e){let n=e.width||0;if(e.padding)n-=(e.padding[3]||0)+(e.padding[1]||0);if(e.border)n-=4;return n}columnWidths(e){if(!this.wrap)return e.map((s)=>s.width||ge.stringWidth(s.text));let n=e.length,t=this.width,r=e.map((s)=>{if(s.width)return n--,t-=s.width,s.width;return}),i=n?Math.floor(t/n):0;return r.map((s,o)=>{if(s===void 0)return Math.max(i,Io(e[o]));return s})}}function lr(e,n,t){if(e.border){if(/[.']-+[.']/.test(n))return"";if(n.trim().length!==0)return t;return" "}return""}function Io(e){let n=e.padding||[],t=1+(n[3]||0)+(n[1]||0);if(e.border)return t+4;return t}function To(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function Lo(e,n){e=e.trim();let t=ge.stringWidth(e);if(t<n)return" ".repeat(n-t)+e;return e}function Wo(e,n){e=e.trim();let t=ge.stringWidth(e);if(t>=n)return e;return" ".repeat(n-t>>1)+e}var ge;function dr(e,n){return ge=n,new cr({width:(e===null||e===void 0?void 0:e.width)||To(),wrap:e===null||e===void 0?void 0:e.wrap})}function pt({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 Ho=pt();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(Ho,"")}var fr=161,hr=1114109,Dr=[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],gr=12288,pr=65510,mr=[12288,12288,65281,65376,65504,65510];var Fr=4352,yr=262141,mt=[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 Nn=(e,n)=>{let t=0,r=Math.floor(e.length/2)-1;while(t<=r){let i=Math.floor((t+r)/2),s=i*2;if(n<e[s])r=i-1;else if(n>e[s+1])t=i+1;else return!0}return!1};var br=19968,[Vo,zo]=Go(mt);function Go(e){let n=e[0],t=e[1];for(let r=0;r<e.length;r+=2){let i=e[r],s=e[r+1];if(br>=i&&br<=s)return[i,s];if(s-i>t-n)n=i,t=s}return[n,t]}var Er=(e)=>{if(e<fr||e>hr)return!1;return Nn(Dr,e)},Cr=(e)=>{if(e<gr||e>pr)return!1;return Nn(mr,e)};var wr=(e)=>{if(e>=Vo&&e<=zo)return!0;if(e<Fr||e>yr)return!1;return Nn(mt,e)};function Uo(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Ye(e,{ambiguousAsWide:n=!1}={}){if(Uo(e),Cr(e)||wr(e)||n&&Er(e))return 2;return 1}var xr=()=>/[#*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 Yo=new Intl.Segmenter,Jo=/^\p{Default_Ignorable_Code_Point}$/u;function ke(e,n={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:t=!0,countAnsiEscapeCodes:r=!1}=n;if(!r)e=je(e);if(e.length===0)return 0;let i=0,s={ambiguousAsWide:!t};for(let{segment:o}of Yo.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(Jo.test(o))continue;if(xr().test(o)){i+=2;continue}i+=Ye(u,s)}return i}var Sr=(e=0)=>(n)=>`\x1B[${n+e}m`,Ar=(e=0)=>(n)=>`\x1B[${38+e};5;${n}m`,Pr=(e=0)=>(n,t,r)=>`\x1B[${38+e};2;${n};${t};${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]}},Lf=Object.keys(K.modifier),Ko=Object.keys(K.color),qo=Object.keys(K.bgColor),Wf=[...Ko,...qo];function Xo(){let e=new Map;for(let[n,t]of Object.entries(K)){for(let[r,i]of Object.entries(t))K[r]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},t[r]=K[r],e.set(i[0],i[1]);Object.defineProperty(K,n,{value:t,enumerable:!1})}return Object.defineProperty(K,"codes",{value:e,enumerable:!1}),K.color.close="\x1B[39m",K.bgColor.close="\x1B[49m",K.color.ansi=Sr(),K.color.ansi256=Ar(),K.color.ansi16m=Pr(),K.bgColor.ansi=Sr(10),K.bgColor.ansi256=Ar(10),K.bgColor.ansi16m=Pr(10),Object.defineProperties(K,{rgbToAnsi256:{value(n,t,r){if(n===t&&t===r){if(n<8)return 16;if(n>248)return 231;return Math.round((n-8)/247*24)+232}return 16+36*Math.round(n/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5)},enumerable:!1},hexToRgb:{value(n){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(n.toString(16));if(!t)return[0,0,0];let[r]=t;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:(n)=>K.rgbToAnsi256(...K.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value(n){if(n<8)return 30+n;if(n<16)return 90+(n-8);let t,r,i;if(n>=232)t=((n-232)*10+8)/255,r=t,i=t;else{n-=16;let u=n%36;t=Math.floor(n/36)/5,r=Math.floor(u/6)/5,i=u%6/5}let s=Math.max(t,r,i)*2;if(s===0)return 30;let o=30+(Math.round(i)<<2|Math.round(r)<<1|Math.round(t));if(s===2)o+=60;return o},enumerable:!1},rgbToAnsi:{value:(n,t,r)=>K.ansi256ToAnsi(K.rgbToAnsi256(n,t,r)),enumerable:!1},hexToAnsi:{value:(n)=>K.ansi256ToAnsi(K.hexToAnsi256(n)),enumerable:!1}}),K}var Zo=Xo(),_r=Zo;var In=new Set(["\x1B","\x9B"]),Qo=39,yt="\x07",$r="[",ea="]",vr="m",Rn=`${ea}8;;`,Br=(e)=>`${In.values().next().value}${$r}${e}${vr}`,Or=(e)=>`${In.values().next().value}${Rn}${e}${yt}`,na=(e)=>e.split(" ").map((n)=>ke(n)),Ft=(e,n,t)=>{let r=[...n],i=!1,s=!1,o=ke(je(e.at(-1)));for(let[u,c]of r.entries()){let p=ke(c);if(o+p<=t)e[e.length-1]+=c;else e.push(c),o=0;if(In.has(c))i=!0,s=r.slice(u+1,u+1+Rn.length).join("")===Rn;if(i){if(s){if(c===yt)i=!1,s=!1}else if(c===vr)i=!1;continue}if(o+=p,o===t&&u<r.length-1)e.push(""),o=0}if(!o&&e.at(-1).length>0&&e.length>1)e[e.length-2]+=e.pop()},ta=(e)=>{let n=e.split(" "),t=n.length;while(t>0){if(ke(n[t-1])>0)break;t--}if(t===n.length)return e;return n.slice(0,t).join(" ")+n.slice(t).join("")},ra=(e,n,t={})=>{if(t.trim!==!1&&e.trim()==="")return"";let r="",i,s,o=na(e),u=[""];for(let[g,D]of e.split(" ").entries()){if(t.trim!==!1)u[u.length-1]=u.at(-1).trimStart();let F=ke(u.at(-1));if(g!==0){if(F>=n&&(t.wordWrap===!1||t.trim===!1))u.push(""),F=0;if(F>0||t.trim===!1)u[u.length-1]+=" ",F++}if(t.hard&&o[g]>n){let y=n-F,h=1+Math.floor((o[g]-y-1)/n);if(Math.floor((o[g]-1)/n)<h)u.push("");Ft(u,D,n);continue}if(F+o[g]>n&&F>0&&o[g]>0){if(t.wordWrap===!1&&F<n){Ft(u,D,n);continue}u.push("")}if(F+o[g]>n&&t.wordWrap===!1){Ft(u,D,n);continue}u[u.length-1]+=D}if(t.trim!==!1)u=u.map((g)=>ta(g));let c=u.join(`
|
|
8
|
+
`),p=[...c],b=0;for(let[g,D]of p.entries()){if(r+=D,In.has(D)){let{groups:y}=new RegExp(`(?:\\${$r}(?<code>\\d+)m|\\${Rn}(?<uri>.*)${yt})`).exec(c.slice(b))||{groups:{}};if(y.code!==void 0){let h=Number.parseFloat(y.code);i=h===Qo?void 0:h}else if(y.uri!==void 0)s=y.uri.length===0?void 0:y.uri}let F=_r.codes.get(Number(i));if(p[g+1]===`
|
|
9
|
+
`){if(s)r+=Or("");if(i&&F)r+=Br(F)}else if(D===`
|
|
10
|
+
`){if(i&&F)r+=Br(i);if(s)r+=Or(s)}b+=D.length}return r};function bt(e,n,t){return String(e).normalize().replaceAll(`\r
|
|
11
11
|
`,`
|
|
12
12
|
`).split(`
|
|
13
|
-
`).map((
|
|
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")}>
|
|
15
|
-
`;else k=`${C} [${
|
|
16
|
-
`;U.div(`${k}`)}}if(
|
|
13
|
+
`).map((r)=>ra(r,n,t)).join(`
|
|
14
|
+
`)}function Et(e){return dr(e,{stringWidth:ke,stripAnsi:je,wrap:bt})}import{dirname as jr,resolve as kr}from"path";import{readdirSync as ia,statSync as sa}from"fs";function Ct(e,n){let t=kr(".",e),r;if(!sa(t).isDirectory())t=jr(t);while(!0){if(r=n(t,ia(t)),r)return kr(t,r);if(t=jr(r=t),r===t)break}}import{inspect as Na}from"util";import{fileURLToPath as ni}from"url";import{format as ua}from"util";import{normalize as la,resolve as ca}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 t="",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!=="_")t+=o}return t}}function Tn(e,n){let t=e.toLowerCase();n=n||"-";let r="";for(let i=0;i<e.length;i++){let s=t.charAt(i),o=e.charAt(i);if(s!==o&&i>0)r+=`${n}${t.charAt(i)}`;else r+=o}return r}function Ln(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 Mr(e){if(Array.isArray(e))return e.map((o)=>typeof o!=="string"?o+"":o);e=e.trim();let n=0,t=null,r=null,i=null,s=[];for(let o=0;o<e.length;o++){if(t=r,r=e.charAt(o),r===" "&&!i){if(t!==" ")n++;continue}if(r===i)i=null;else if((r==="'"||r==='"')&&!i)i=r;if(!s[n])s[n]="";s[n]+=r}return s}var ye;(function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"})(ye||(ye={}));var Me;class xt{constructor(e){Me=e}parse(e,n){let t=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},n),r=Mr(e),i=typeof e==="string",s=oa(Object.assign(Object.create(null),t.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},t.configuration),u=Object.assign(Object.create(null),t.default),c=t.configObjects||[],p=t.envPrefix,b=o["populate--"],g=b?"--":"_",D=Object.create(null),F=Object.create(null),y=t.__||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(t.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(t.boolean||[]).filter(Boolean).forEach(function(l){h.bools[l]=!0,h.keys.push(l)}),[].concat(t.string||[]).filter(Boolean).forEach(function(l){h.strings[l]=!0,h.keys.push(l)}),[].concat(t.number||[]).filter(Boolean).forEach(function(l){h.numbers[l]=!0,h.keys.push(l)}),[].concat(t.count||[]).filter(Boolean).forEach(function(l){h.counts[l]=!0,h.keys.push(l)}),[].concat(t.normalize||[]).filter(Boolean).forEach(function(l){h.normalize[l]=!0,h.keys.push(l)}),typeof t.narg==="object")Object.entries(t.narg).forEach(([l,f])=>{if(typeof f==="number")h.nargs[l]=f,h.keys.push(l)});if(typeof t.coerce==="object")Object.entries(t.coerce).forEach(([l,f])=>{if(typeof f==="function")h.coercions[l]=f,h.keys.push(l)});if(typeof t.config<"u"){if(Array.isArray(t.config)||typeof t.config==="string")[].concat(t.config).filter(Boolean).forEach(function(l){h.configs[l]=!0});else if(typeof t.config==="object")Object.entries(t.config).forEach(([l,f])=>{if(typeof f==="boolean"||typeof f==="function")h.configs[l]=f})}xn(t.key,s,t.default,h.arrays),Object.keys(u).forEach(function(l){(h.aliases[l]||[]).forEach(function(f){u[f]=u[l]})});let T=null;gt();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))te(f);else if(E.match(/^---+(=|$)/)){te(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 te(f)}if(ne(I,!0),ne(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 te(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(".");wn(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 wn(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))wn(f,l)}function P(l,f,E){if(E)f=aa(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=wt();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(Ln(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 ne(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=Nr(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=Nr(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===wt())m[d]=wt(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 xn(...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=Tn(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 fn(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 ar(l,...f){return[].concat(...f).some(function(m){let d=l.match(m);return d&&fn(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),!fn(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!ar(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 gt(){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 oa(e){let n=[],t=Object.create(null),r=!0;Object.keys(e).forEach(function(i){n.push([].concat(e[i],i))});while(r){r=!1;for(let i=0;i<n.length;i++)for(let s=i+1;s<n.length;s++)if(n[i].filter(function(u){return n[s].indexOf(u)!==-1}).length){n[i]=n[i].concat(n[s]),n.splice(s,1),r=!0;break}}return n.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")t[s]=i}),t}function wt(e){return e!==void 0?e+1:1}function Nr(e){if(e==="__proto__")return"___proto___";return e}function aa(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 da}from"fs";import{createRequire as Rr}from"module";var St,At,Pt,Ir=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Tr=(At=(St=process===null||process===void 0?void 0:process.versions)===null||St===void 0?void 0:St.node)!==null&&At!==void 0?At:(Pt=process===null||process===void 0?void 0:process.version)===null||Pt===void 0?void 0:Pt.slice(1);if(Tr){if(Number(Tr.match(/^([^.]+)/)[1])<Ir)throw Error(`yargs parser supports a minimum Node.js version of ${Ir}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var fa=process?process.env:{},Lr=Rr?Rr(import.meta.url):void 0,Wr=new xt({cwd:process.cwd,env:()=>fa,format:ua,normalize:la,resolve:ca,require:(e)=>{if(typeof Lr<"u")return Lr(e);else if(e.match(/\.json$/))return JSON.parse(da(e,"utf8"));else throw Error("only .json config files are supported in ESM")}}),Sn=function(n,t){return Wr.parse(n.slice(),t).argv};Sn.detailed=function(e,n){return Wr.parse(e.slice(),n)};Sn.camelCase=Je;Sn.decamelize=Tn;Sn.looksLikeNumber=Ln;var Hr=Sn;import{basename as Ra,dirname as Ia,extname as Ta,relative as La,resolve as ei,join as Wa}from"path";function ha(){if(Da())return 0;return 1}function Da(){return ga()&&!process.defaultApp}function ga(){return!!process.versions.electron}function Vr(){return process.argv[ha()]}var pa=new Intl.Segmenter,zr=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v,ma=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v,Fa=/\p{Spacing_Mark}/v,ya=/^\p{RGI_Emoji}$/v,ba=/^[\d#*]\u20E3$/,Ea=/\p{Extended_Pictographic}/gu;function Ca(e){if(e.length>50)return!1;if(ba.test(e))return!0;if(e.includes("\u200D")){let n=e.match(Ea);return n!==null&&n.length>=2}return!1}function wa(e){return e.replace(ma,"")}function xa(e){return zr.test(e)}function Gr(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function Ur(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function Yr(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function Sa(e){return Gr(e)||Ur(e)||Yr(e)}function Aa(e,n){let t=[];for(let i of e){if(zr.test(i))continue;t.push(i.codePointAt(0))}if(t.length===0)return;let r=0;for(let i=0;i<t.length;i++){let s=t[i];if(!Sa(s)){if(r===0)return;for(let o=i;o<t.length;o++)r+=Ye(t[o],n);return r}if(Gr(s)&&Ur(t[i+1])){r+=2,i+=Yr(t[i+2])?2:1;continue}r+=Ye(s,n)}return r}function Pa(e,n){let t=0,r=!0;for(let i of e){if(r){r=!1;continue}if(Fa.test(i)||i>="\uFF00"&&i<="\uFFEF")t+=Ye(i.codePointAt(0),n)}return t}function _t(e,n={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:t=!0,countAnsiEscapeCodes:r=!1}=n,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:!t};for(let{segment:u}of pa.segment(i)){if(xa(u))continue;if(ya.test(u)||Ca(u)){s+=2;continue}let c=wa(u),p=Aa(c,o);if(p!==void 0){s+=p;continue}let b=c.codePointAt(0);s+=Ye(b,o),s+=Pa(c,o)}return s}import{readFileSync as _a,statSync as Ba,writeFile as Oa}from"fs";import{format as $a}from"util";import{resolve as va}from"path";var Jr={fs:{readFileSync:_a,writeFile:Oa},format:$a,resolve:va,exists:(e)=>{try{return Ba(e).isFile()}catch(n){return!1}}};var xe;class Kr{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 n=e.shift(),t=function(){};if(typeof e[e.length-1]==="function")t=e.pop();if(t=t||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][n]&&this.updateFiles)this.cache[this.locale][n]=n,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:t});else t();return xe.format.apply(xe.format,[this.cache[this.locale][n]||n].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),n=e.shift(),t=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?n:t;if(this.cache[this.locale][n])s=this.cache[this.locale][n][r===1?"one":"other"];if(!this.cache[this.locale][n]&&this.updateFiles)this.cache[this.locale][n]={one:n,other:t},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 n in e)if(Object.prototype.hasOwnProperty.call(e,n))this.cache[this.locale][n]=e[n]}_taggedLiteral(e,...n){let t="";return e.forEach(function(r,i){let s=n[i+1];if(t+=r,typeof s<"u")t+="%s"}),this.__.apply(this,[t].concat([].slice.call(n,1)))}_enqueueWrite(e){if(this.writeQueue.push(e),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let e=this,n=this.writeQueue[0],t=n.directory,r=n.locale,i=n.cb,s=this._resolveLocaleFile(t,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={},n=this._resolveLocaleFile(this.directory,this.locale);try{if(xe.fs.readFileSync)e=JSON.parse(xe.fs.readFileSync(n,"utf-8"))}catch(t){if(t instanceof SyntaxError)t.message="syntax error in "+n;if(t.code==="ENOENT")e={};else throw t}this.cache[this.locale]=e}_resolveLocaleFile(e,n){let t=xe.resolve(e,"./",n+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(t)&&~n.lastIndexOf("_")){let r=xe.resolve(e,"./",n.split("_")[0]+".json");if(this._fileExistsSync(r))t=r}return t}_fileExistsSync(e){return xe.exists(e)}}function qr(e,n){xe=n;let t=new Kr(e);return{__:t.__.bind(t),__n:t.__n.bind(t),setLocale:t.setLocale.bind(t),getLocale:t.getLocale.bind(t),updateLocale:t.updateLocale.bind(t),locale:t.locale}}var ja=(e)=>qr(e,Jr),Xr=ja;var ti=Mo(Qr(),1);import{createRequire as Ha}from"module";import{readFileSync as Va,readdirSync as za}from"fs";var Bt=ni(import.meta.url),Ga=Bt.substring(0,Bt.lastIndexOf("node_modules")),Ua=Ha(import.meta.url),ri={assert:{notStrictEqual:ka,strictEqual:Ma},cliui:Et,findUp:Ct,getEnv:(e)=>process.env[e],inspect:Na,getProcessArgvBin:Vr,mainFilename:Ga||process.cwd(),Parser:Hr,path:{basename:Ra,dirname:Ia,extname:Ta,relative:La,resolve:ei,join:Wa},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(e,n)=>process.emitWarning(e,n),execPath:()=>process.execPath,exit:(e)=>{process.exit(e)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:Va,readdirSync:za,require:Ua,getCallerFile:()=>{let e=ti.default(3);return e.match(/^file:\/\//)?ni(e):e},stringWidth:_t,y18n:Xr({directory:ei(Bt,"../../../locales"),updateFiles:!1})};function he(e,n,t,r){t.assert.notStrictEqual(e,n,r)}function Ot(e,n){n.assert.strictEqual(typeof e,"string")}function hn(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 t=e.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),r=/\.*[\][<>]/g,i=t.shift();if(!i)throw Error(`No command found in: ${e}`);let s={cmd:i.replace(r,""),demanded:[],optional:[]};return t.forEach((o,u)=>{let c=!1;if(o=o.replace(/\s/g,""),/\.+[\]>]/.test(o)&&u===t.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 Ya=["first","second","third","fourth","fifth","sixth"];function x(e,n,t){function r(){return typeof e==="object"?[{demanded:[],optional:[]},e,n]:[Re(`cmd ${e}`),n,t]}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=ii(D);if(g.cmd.filter((h)=>h===F||h==="*").length===0)si(F,g.cmd,i);i+=1}),s.optional.forEach((g)=>{if(c.length===0)return;let D=c.shift(),F=ii(D);if(g.cmd.filter((h)=>h===F||h==="*").length===0)si(F,g.cmd,i);i+=1})}catch(i){console.warn(i.stack)}}function ii(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function si(e,n,t){throw new Q(`Invalid ${Ya[t]||"manyith"} argument. Expected ${n.join(" or ")} but received ${e}.`)}class $t{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,n,t=!0,r=!1){if(x("<array|function> [boolean] [boolean] [boolean]",[e,n,t],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=n,s.global=t}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e==="function"){let i=e;i.applyBeforeValidation=n,i.global=t,i.mutates=r,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,n){let t=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((r)=>{let i=[...t[n]||[],n];if(!r.option)return!0;else return!i.includes(r.option)}),e.option=n,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 oi(e){if(!e)return[];return e.map((n)=>(n.applyBeforeValidation=!1,n))}function Ke(e,n,t,r){return t.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,n)])).then(([o,u])=>Object.assign(o,u));else{let o=s(i,n);return J(o)?o.then((u)=>Object.assign(i,u)):Object.assign(i,o)}},e)}function qe(e,n,t=(r)=>{throw r}){try{let r=Ja(e)?e():e;return J(r)?r.then((i)=>n(i)):n(r)}catch(r){return t(r)}}function Ja(e){return typeof e==="function"}var Dn=/(^\*)|(^\$0)/;class ui{constructor(e,n,t,r){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=r,this.usage=e,this.globalMiddleware=t,this.validation=n}addDirectory(e,n,t,r){r=r||{},this.requireCache.add(t);let i=this.shim.path.resolve(this.shim.path.dirname(t),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=n(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,n,t,r,i,s){let o=[],u=oi(i);if(r=r||(()=>{}),Array.isArray(e))if(Ka(e))[e,...o]=e;else for(let c of e)this.addHandler(c);else if(Xa(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(ai(t)){this.addHandler([e].concat(o),n,t.builder,t.handler,t.middlewares,t.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(Dn.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(Dn,c.cmd);if(o.forEach((g)=>{this.aliasMap[g]=c.cmd}),n!==!1)this.usage.command(e,n,p,o,s);if(this.handlers[c.cmd]={original:e,description:n,handler:r,builder:t||{},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,n,t,r,i,s){let o=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,u=n.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,n,t.aliases,c,r,i,s);return J(b)?b.then((g)=>this.applyMiddlewareAndGetResult(p,o,g.innerArgv,u,i,g.aliases,n)):this.applyMiddlewareAndGetResult(p,o,b.innerArgv,u,i,b.aliases,n)}applyBuilderUpdateUsageAndParse(e,n,t,r,i,s,o,u){let c=n.builder,p=t;if(Wn(c)){t.getInternalMethods().getUsageInstance().freeze();let b=c(t.getInternalMethods().reset(r),u);if(J(b))return b.then((g)=>(p=ci(g)?g:t,this.parseAndUpdateUsage(e,n,p,i,s,o)))}else if(qa(c))t.getInternalMethods().getUsageInstance().freeze(),p=t.getInternalMethods().reset(r),Object.keys(n.builder).forEach((b)=>{p.option(b,c[b])});return this.parseAndUpdateUsage(e,n,p,i,s,o)}parseAndUpdateUsage(e,n,t,r,i,s){if(e)t.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(t))t.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(r,n),n.description);let o=t.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,s);return J(o)?o.then((u)=>({aliases:t.parsed.aliases,innerArgv:u})):{aliases:t.parsed.aliases,innerArgv:o}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,n){let t=Dn.test(n.original)?n.original.replace(Dn,"").trim():n.original,r=e.filter((i)=>!Dn.test(i));return r.push(t),`$0 ${r.join(" ")}`}handleValidationAndGetResult(e,n,t,r,i,s,o,u){if(!s.getInternalMethods().getHasOutput()){let c=s.getInternalMethods().runValidation(i,u,s.parsed.error,e);t=qe(t,(p)=>(c(p),p))}if(n.handler&&!s.getInternalMethods().getHasOutput()){s.getInternalMethods().setHasOutput();let c=!!s.getOptions().configuration["populate--"];if(s.getInternalMethods().postProcess(t,c,!1,!1),t=Ke(t,s,o,!1),t=qe(t,(p)=>{let b=n.handler(p);return J(b)?b.then(()=>p):p}),!e)s.getInternalMethods().getUsageInstance().cacheHelpMessage();if(J(t)&&!s.getInternalMethods().hasParseCallback())t.catch((p)=>{try{s.getInternalMethods().getUsageInstance().fail(null,p)}catch(b){}})}if(!e)r.commands.pop(),r.fullCommands.pop();return t}applyMiddlewareAndGetResult(e,n,t,r,i,s,o){let u={};if(i)return t;if(!o.getInternalMethods().getHasOutput())u=this.populatePositionals(n,t,r,o);let c=this.globalMiddleware.getMiddleware().slice(0).concat(n.middlewares),p=Ke(t,o,c,!0);return J(p)?p.then((b)=>this.handleValidationAndGetResult(e,n,b,r,s,o,c,u)):this.handleValidationAndGetResult(e,n,p,r,s,o,c,u)}populatePositionals(e,n,t,r){n._=n._.slice(t.commands.length);let i=e.demanded.slice(0),s=e.optional.slice(0),o={};this.validation.positionalCount(i.length,n._.length);while(i.length){let u=i.shift();this.populatePositional(u,n,o)}while(s.length){let u=s.shift();this.populatePositional(u,n,o)}return n._=t.commands.concat(n._.map((u)=>""+u)),this.postProcessPositionals(n,o,this.cmdToParseOptions(e.original),r),o}populatePositional(e,n,t){let r=e.cmd[0];if(e.variadic)t[r]=n._.splice(0).map(String);else if(n._.length)t[r]=[String(n._.shift())]}cmdToParseOptions(e){let n={array:[],default:{},alias:{},demand:{}},t=Re(e);return t.demanded.forEach((r)=>{let[i,...s]=r.cmd;if(r.variadic)n.array.push(i),n.default[i]=[];n.alias[i]=s,n.demand[i]=!0}),t.optional.forEach((r)=>{let[i,...s]=r.cmd;if(r.variadic)n.array.push(i),n.default[i]=[];n.alias[i]=s}),n}postProcessPositionals(e,n,t,r){let i=Object.assign({},r.getOptions());i.default=Object.assign(t.default,i.default);for(let c of Object.keys(t.alias))i.alias[c]=(i.alias[c]||[]).concat(t.alias[c]);i.array=i.array.concat(t.array),i.config={};let s=[];if(Object.keys(n).forEach((c)=>{n[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(n);Object.keys(n).forEach((p)=>{c.push(...u.aliases[p])}),Object.keys(u.argv).forEach((p)=>{if(c.includes(p)){if(!n[p])n[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,n){let{default:t}=e.getOptions();return Object.prototype.hasOwnProperty.call(t,n)||Object.prototype.hasOwnProperty.call(t,this.shim.Parser.camelCase(n))}isInConfigs(e,n){let{configObjects:t}=e.getOptions();return t.some((r)=>Object.prototype.hasOwnProperty.call(r,n))||t.some((r)=>Object.prototype.hasOwnProperty.call(r,this.shim.Parser.camelCase(n)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let t=Dn.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(t,this.defaultCommand.description)}let n=this.defaultCommand.builder;if(Wn(n))return n(e,!0);else if(!ai(n))Object.keys(n).forEach((t)=>{e.option(t,n[t])});return}extractDesc({describe:e,description:n,desc:t}){for(let r of[e,n,t]){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 li(e,n,t,r){return new ui(e,n,t,r)}function ai(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function Ka(e){return e.every((n)=>typeof n==="string")}function Wn(e){return typeof e==="function"}function qa(e){return typeof e==="object"}function Xa(e){return typeof e==="object"&&!Array.isArray(e)}function Ie(e={},n=()=>!0){let t={};return hn(e).forEach((r)=>{if(n(r,e[r]))t[r]=e[r]}),t}function Te(e){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((n)=>{let t=n;if(t._handle&&t.isTTY&&typeof t._handle.setBlocking==="function")t._handle.setBlocking(e)})}function Za(e){return typeof e==="boolean"}function fi(e,n){let t=n.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 ne=i[V];if(Za(ne)){if(_)throw _;else if(C)throw Error(C)}else ne(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=()=>t("Positionals:");let g=[];r.example=(P,C)=>{g.push([P,C||""])};let D=[];r.command=function(C,_,N,V,ne=!1){if(N)D=D.map((H)=>(H[2]=!1,H));D.push([C,_||"",N,V,ne])},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(n.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:n.path.basename(e.$0),_=e.getDemandedOptions(),N=e.getDemandedCommands(),V=e.getDeprecatedOptions(),ne=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(te),re=Object.keys(re.reduce((k,G)=>{if(G!=="_")k[G]=!0;return k},{}));let Ne=r.getWrap(),U=n.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} <${t("command")}>
|
|
15
|
+
`;else k=`${C} [${t("command")}]
|
|
16
|
+
`;U.div(`${k}`)}}if(D.length>1||D.length===1&&!D[0][2]){U.div(t("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(`[${t("default")}]`);if(L[3]&&L[3].length)Z.push(`[${t("aliases:")} ${L[3].join(", ")}]`);if(L[4])if(typeof L[4]==="string")Z.push(`[${t("deprecated: %s",L[4])}]`);else Z.push(`[${t("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 xn=t("Options:");if(!ne[xn])ne[xn]=[];Y(re,H.alias,ne,xn);let j=(k)=>/^--/.test(Hn(k)),fn=Object.keys(ne).filter((k)=>ne[k].length>0).map((k)=>{let G=ne[k].filter(te).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(fn.filter(({groupName:k})=>k!==r.getPositionalGroupName()).some(({normalizedKeys:k,switches:G})=>!k.every((ie)=>j(G[ie]))))fn.filter(({groupName:k})=>k!==r.getPositionalGroupName()).forEach(({normalizedKeys:k,switches:G})=>{k.forEach((ie)=>{if(j(G[ie]))G[ie]=Qa(G[ie],4)})});if(fn.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=t(Z.substring(W.length));if(H.boolean.includes(L))se=`[${t("boolean")}]`;if(H.count.includes(L))se=`[${t("count")}]`;if(H.string.includes(L))se=`[${t("string")}]`;if(H.normalize.includes(L))se=`[${t("string")}]`;if(H.array.includes(L))se=`[${t("array")}]`;if(H.number.includes(L))se=`[${t("number")}]`;let gt=(E)=>typeof E==="string"?`[${t("deprecated: %s",E)}]`:`[${t("deprecated")}]`,l=[L in V?gt(V[L]):null,se,L in _?`[${t("required")}]`:null,H.choices&&H.choices[L]?`[${t("choices:")} ${r.stringifiedValues(H.choices[L])}]`:null,X(H.default[L],H.defaultDescription[L])].filter(Boolean).join(" ");U.span({text:Hn(ue),padding:[0,2,0,2+di(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(t("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(
|
|
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(n.stringWidth(_?`${_} ${Hn(V[0])}`:Hn(V[0]))+di(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=[],ne=null;return Object.keys(_).forEach((H)=>{V=V.concat(_[H])}),P.forEach((H)=>{if(ne=[H].concat(C[H]),!ne.some((re)=>V.indexOf(re)!==-1))_[N].push(H)}),V}function te(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?n.Parser.decamelize(P.name,"-"):t("generated-value"),")"].join(""),r.stringifiedValues=function(C,_){let N="",V=_||", ",ne=[].concat(C);if(!C||!ne.length)return N;return ne.forEach((H)=>{if(N.length)N+=V;N+=JSON.stringify(H)}),N};function X(P,C){let _=`[${t("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(n.process.stdColumns)return Math.min(80,n.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 wn=[];return r.freeze=function(){wn.push({failMessage:s,failureOutput:c,usages:p,usageDisabled:b,epilogs:y,examples:g,commands:D,descriptions:F})},r.unfreeze=function(C=!1){let _=wn.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 vt(e){return typeof e==="object"}function Qa(e,n){return vt(e)?{text:e.text,indentation:e.indentation+n}:{text:e,indentation:n}}function di(e){return vt(e)?e.indentation:0}function Hn(e){return vt(e)?e.text:e}var hi=`###-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
|
-
`,
|
|
47
|
+
`,Di=`#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
|
|
75
|
-
${
|
|
76
|
-
`)}`:"";
|
|
77
|
-
${
|
|
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(
|
|
80
|
-
`,"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 gi{constructor(e,n,t,r){var i,s,o;this.yargs=e,this.usage=n,this.command=t,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,n,t,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(Wn(c)){this.indexAfterLastReset=o+1;let p=this.yargs.getInternalMethods().reset();return c(p,!0),p.argv}}let s=[];this.commandCompletions(s,e,t),this.optionCompletions(s,e,n,t),this.choicesFromOptionsCompletions(s,e,n,t),this.choicesFromPositionalsCompletions(s,e,n,t),r(null,s)}commandCompletions(e,n,t){let r=this.yargs.getInternalMethods().getContext().commands;if(!t.match(/^-/)&&r[r.length-1]!==t&&!this.previousArgHasChoices(n))this.usage.getCommands().forEach((i)=>{let s=Re(i[0]).cmd;if(n.indexOf(s)===-1)if(!this.zshShell)e.push(s);else{let o=i[1]||"";e.push(s.replace(/:/g,"\\:")+":"+o)}})}optionCompletions(e,n,t,r){if((r.match(/^-/)||r===""&&e.length===0)&&!this.previousArgHasChoices(n)){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(n,o,u))this.completeOptionKey(o,e,r,u&&!!i.default[o])})}}choicesFromOptionsCompletions(e,n,t,r){if(this.previousArgHasChoices(n)){let i=this.getPreviousArgChoices(n);if(i&&i.length>0)e.push(...i.map((s)=>s.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,n,t,r){if(r===""&&e.length>0&&this.previousArgHasChoices(n))return;let i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],s=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=i[t._.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 n=e[e.length-1],t="";if(!n.startsWith("-")&&e.length>1)t=n,n=e[e.length-2];if(!n.startsWith("-"))return;let r=n.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)=>!t||u.startsWith(t))}previousArgHasChoices(e){let n=this.getPreviousArgChoices(e);return n!==void 0&&n.length>0}argsContainKey(e,n,t){let r=(i)=>e.indexOf((/^[^0-9]$/.test(i)?"-":"--")+i)!==-1;if(r(n))return!0;if(t&&r(`no-${n}`))return!0;if(this.aliases){for(let i of this.aliases[n])if(r(i))return!0}return!1}completeOptionKey(e,n,t,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(t)&&b(e)?"-":"--";if(n.push(g+c),r)n.push(g+"no-"+c)}customCompletion(e,n,t,r){if(he(this.customCompletionFunction,null,this.shim),nu(this.customCompletionFunction)){let i=this.customCompletionFunction(t,n);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(tu(this.customCompletionFunction))return this.customCompletionFunction(t,n,(i=r)=>this.defaultCompletion(e,n,t,i),(i)=>{r(null,i)});else return this.customCompletionFunction(t,n,(i)=>{r(null,i)})}getCompletion(e,n){let t=e.length?e[e.length-1]:"",r=this.yargs.parse(e,!0),i=this.customCompletionFunction?(s)=>this.customCompletion(e,s,t,n):(s)=>this.defaultCompletion(e,s,t,n);return J(r)?r.then(i):i(r)}generateCompletionScript(e,n){let t=this.zshShell?Di:hi,r=this.shim.path.basename(e);if(e.match(/\.js$/))e=`./${e}`;return t=t.replace(/{{app_name}}/g,r),t=t.replace(/{{completion_command}}/g,n),t.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}}function pi(e,n,t,r){return new gi(e,n,t,r)}function nu(e){return e.length<3}function tu(e){return e.length>3}function mi(e,n){if(e.length===0)return n.length;if(n.length===0)return e.length;let t=[],r;for(r=0;r<=n.length;r++)t[r]=[r];let i;for(i=0;i<=e.length;i++)t[0][i]=i;for(r=1;r<=n.length;r++)for(i=1;i<=e.length;i++)if(n.charAt(r-1)===e.charAt(i-1))t[r][i]=t[r-1][i-1];else if(r>1&&i>1&&n.charAt(r-2)===e.charAt(i-1)&&n.charAt(r-1)===e.charAt(i-2))t[r][i]=t[r-2][i-2]+1;else t[r][i]=Math.min(t[r-1][i-1]+1,Math.min(t[r][i-1]+1,t[r-1][i]+1));return t[n.length][e.length]}var Fi=["$0","--","_"];function yi(e,n,t){let r=t.y18n.__,i=t.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)n.fail(D._.minMsg?D._.minMsg.replace(/\$0/g,y.toString()).replace(/\$1/,D._.min.toString()):null);else n.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)n.fail(D._.maxMsg?D._.maxMsg.replace(/\$0/g,y.toString()).replace(/\$1/,D._.max.toString()):null);else n.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)n.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
|
+
`)}`:"";n.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(!Fi.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,te=ce.commands.length+Y;if(te<g._.length)g._.slice(te).forEach((X)=>{if(X=String(X),!ce.commands.includes(X)&&!T.includes(X))T.push(X)})}if(T.length)n.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 n.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(Fi.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,n.stringifiedValues(F[v]),n.stringifiedValues(D.choices[v]))}`}),n.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,t),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}),n.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)n.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[t.Parser.camelCase(D)]!==void 0&&g[t.Parser.camelCase(F)]!==void 0)n.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=mi(g,W);if(T<=3&&T<h)h=T,y=W}if(y)n.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,t),{implied:o,conflicting:c}=g},s}var jt=[],An;function Vn(e,n,t,r){An=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=iu(n,e.extends);ru(o),jt.push(o),i=s?JSON.parse(An.readFileSync(o,"utf8")):r.require(e.extends),delete e.extends,i=Vn(i,An.path.dirname(o),t,An)}return jt=[],t?bi(i,e):Object.assign({},i,e)}function ru(e){if(jt.indexOf(e)>-1)throw new Q(`Circular extended configurations: '${e}'.`)}function iu(e,n){return An.path.resolve(e,n)}function bi(e,n){let t={};function r(i){return i&&typeof i==="object"&&!Array.isArray(i)}Object.assign(t,e);for(let i of Object.keys(n)){if(i==="__proto__")continue;if(r(n[i])&&r(t[i]))t[i]=bi(e[i],n[i]);else t[i]=n[i]}return t}var S=function(e,n,t,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 n==="function"?e!==n||!i:!n.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?i.call(e,t):i?i.value=t:n.set(e,t),t},a=function(e,n,t,r){if(t==="a"&&!r)throw TypeError("Private accessor was defined without a getter");if(typeof n==="function"?e!==n||!r:!n.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(e):r?r.value:n.get(e)},ee,Xe,Pn,De,pe,zn,Le,Ze,Gn,be,Un,Ee,_e,me,Ce,Yn,Qe,ae,B,Jn,Kn,Fe,en,gn,nn,We,qn,M,tn,rn,sn,R,Xn,Be,q;function Li(e){return(n=[],t=e.process.cwd(),r)=>{let i=new Wi(n,t,r,e);return Object.defineProperty(i,"argv",{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}var Ei=Symbol("copyDoubleDash"),Ci=Symbol("copyDoubleDash"),kt=Symbol("deleteFromParserHintObject"),wi=Symbol("emitWarning"),xi=Symbol("freeze"),Si=Symbol("getDollarZero"),on=Symbol("getParserConfiguration"),Ai=Symbol("getUsageConfiguration"),Mt=Symbol("guessLocale"),Pi=Symbol("guessVersion"),_i=Symbol("parsePositionalNumbers"),Nt=Symbol("pkgUp"),He=Symbol("populateParserHintArray"),pn=Symbol("populateParserHintSingleValueDictionary"),Rt=Symbol("populateParserHintArrayDictionary"),It=Symbol("populateParserHintDictionary"),Tt=Symbol("sanitizeKey"),Lt=Symbol("setKey"),Wt=Symbol("unfreeze"),Bi=Symbol("validateAsync"),Oi=Symbol("getCommandInstance"),$i=Symbol("getContext"),vi=Symbol("getHasOutput"),ji=Symbol("getLoggerInstance"),ki=Symbol("getParseContext"),Mi=Symbol("getUsageInstance"),Ni=Symbol("getValidationInstance"),Zn=Symbol("hasParseCallback"),Ri=Symbol("isGlobalContext"),an=Symbol("postProcess"),Ii=Symbol("rebase"),Ht=Symbol("reset"),_n=Symbol("runYargsParserAndExecuteCommands"),Vt=Symbol("runValidation"),Ti=Symbol("setHasOutput"),un=Symbol("kTrackManuallySetKeys"),su="en_US";class Wi{constructor(e=[],n,t,r){this.customScriptName=!1,this.parsed=!1,ee.set(this,void 0),Xe.set(this,void 0),Pn.set(this,{commands:[],fullCommands:[]}),De.set(this,null),pe.set(this,null),zn.set(this,"show-hidden"),Le.set(this,null),Ze.set(this,!0),Gn.set(this,{}),be.set(this,!0),Un.set(this,[]),Ee.set(this,void 0),_e.set(this,{}),me.set(this,!1),Ce.set(this,null),Yn.set(this,!0),Qe.set(this,void 0),ae.set(this,""),B.set(this,void 0),Jn.set(this,void 0),Kn.set(this,{}),Fe.set(this,null),en.set(this,null),gn.set(this,{}),nn.set(this,{}),We.set(this,void 0),qn.set(this,!1),M.set(this,void 0),tn.set(this,!1),rn.set(this,!1),sn.set(this,!1),R.set(this,void 0),Xn.set(this,{}),Be.set(this,null),q.set(this,void 0),S(this,M,r,"f"),S(this,We,e,"f"),S(this,Xe,n,"f"),S(this,Jn,t,"f"),S(this,Ee,new $t(this),"f"),this.$0=this[Si](),this[Ht](),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,zn,"f"),S(this,Qe,this[Ci](),"f"),a(this,M,"f").y18n.setLocale(su)}addHelpOpt(e,n){if(x("[string|boolean] [string]",[e,n],arguments.length),a(this,Ce,"f"))this[kt](a(this,Ce,"f")),S(this,Ce,null,"f");if(e===!1&&n===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"),n||a(this,R,"f").deferY18nLookup("Show help")),this}help(e,n){return this.addHelpOpt(e,n)}addShowHiddenOpt(e,n){if(x("[string|boolean] [string]",[e,n],arguments.length),e===!1&&n===void 0)return this;let t=typeof e==="string"?e:a(this,zn,"f");return this.boolean(t),this.describe(t,n||a(this,R,"f").deferY18nLookup("Show hidden options")),a(this,B,"f").showHiddenOpt=t,this}showHidden(e,n){return this.addShowHiddenOpt(e,n)}alias(e,n){return x("<object|string|array> [string|array]",[e,n],arguments.length),this[Rt](this.alias.bind(this),"alias",e,n),this}array(e){return x("<array|string>",[e],arguments.length),this[He]("array",e),this[un](e),this}boolean(e){return x("<array|string>",[e],arguments.length),this[He]("boolean",e),this[un](e),this}check(e,n){return x("<function> [boolean]",[e,n],arguments.length),this.middleware((t,r)=>qe(()=>e(t,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 t},(i)=>(a(this,R,"f").fail(i.message?i.message:i.toString(),i),t)),!1,n),this}choices(e,n){return x("<object|string|array> [string|array]",[e,n],arguments.length),this[Rt](this.choices.bind(this),"choices",e,n),this}coerce(e,n){if(x("<object|string|array> [function]",[e,n],arguments.length),Array.isArray(e)){if(!n)throw new Q("coerce callback must be provided");for(let r of e)this.coerce(r,n);return this}else if(typeof e==="object"){for(let r of Object.keys(e))this.coerce(r,e[r]);return this}if(!n)throw new Q("coerce callback must be provided");let t=e;return a(this,B,"f").key[t]=!0,a(this,Ee,"f").addCoerceMiddleware((r,i)=>{var s;let o=(s=i.getAliases()[t])!==null&&s!==void 0?s:[],u=[t,...o].filter((c)=>Object.prototype.hasOwnProperty.call(r,c));if(u.length===0)return r;return qe(()=>n(r[u[0]]),(c)=>(u.forEach((p)=>{r[p]=c}),r),(c)=>{throw new Q(c.message)})},t),this}conflicts(e,n){return x("<string|object> [string|array]",[e,n],arguments.length),a(this,q,"f").conflicts(e,n),this}config(e="config",n,t){if(x("[object|string] [string|function] [function]",[e,n,t],arguments.length),typeof e==="object"&&!Array.isArray(e))return e=Vn(e,a(this,Xe,"f"),this[on]()["deep-merge-config"]||!1,a(this,M,"f")),a(this,B,"f").configObjects=(a(this,B,"f").configObjects||[]).concat(e),this;if(typeof n==="function")t=n,n=void 0;return this.describe(e,n||a(this,R,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach((r)=>{a(this,B,"f").config[r]=t||!0}),this}completion(e,n,t){if(x("[string] [string|boolean|function] [function]",[e,n,t],arguments.length),typeof n==="function")t=n,n=void 0;if(S(this,pe,e||a(this,pe,"f")||"completion","f"),!n&&n!==!1)n="generate completion script";if(this.command(a(this,pe,"f"),n),t)a(this,De,"f").registerFunction(t);return this}command(e,n,t,r,i,s){return x("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,n,t,r,i,s],arguments.length),a(this,ee,"f").addHandler(e,n,t,r,i,s),this}commands(e,n,t,r,i,s){return this.command(e,n,t,r,i,s)}commandDir(e,n){x("<string> [object]",[e,n],arguments.length);let t=a(this,Jn,"f")||a(this,M,"f").require;return a(this,ee,"f").addDirectory(e,t,a(this,M,"f").getCallerFile(),n),this}count(e){return x("<array|string>",[e],arguments.length),this[He]("count",e),this[un](e),this}default(e,n,t){if(x("<object|string|array> [*] [string]",[e,n,t],arguments.length),t)Ot(e,a(this,M,"f")),a(this,B,"f").defaultDescription[e]=t;if(typeof n==="function"){if(Ot(e,a(this,M,"f")),!a(this,B,"f").defaultDescription[e])a(this,B,"f").defaultDescription[e]=a(this,R,"f").functionDescription(n);n=n.call()}return this[pn](this.default.bind(this),"default",e,n),this}defaults(e,n,t){return this.default(e,n,t)}demandCommand(e=1,n,t,r){if(x("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,n,t,r],arguments.length),typeof n!=="number")t=n,n=1/0;return this.global("_",!1),a(this,B,"f").demandedCommands._={min:e,max:n,minMsg:t,maxMsg:r},this}demand(e,n,t){if(Array.isArray(n))n.forEach((r)=>{he(t,!0,a(this,M,"f")),this.demandOption(r,t)}),n=1/0;else if(typeof n!=="number")t=n,n=1/0;if(typeof e==="number")he(t,!0,a(this,M,"f")),this.demandCommand(e,n,t,t);else if(Array.isArray(e))e.forEach((r)=>{he(t,!0,a(this,M,"f")),this.demandOption(r,t)});else if(typeof t==="string")this.demandOption(e,t);else if(t===!0||typeof t>"u")this.demandOption(e);return this}demandOption(e,n){return x("<object|string|array> [string]",[e,n],arguments.length),this[pn](this.demandOption.bind(this),"demandedOptions",e,n),this}deprecateOption(e,n){return x("<string> [string|boolean]",[e,n],arguments.length),a(this,B,"f").deprecatedOptions[e]=n,this}describe(e,n){return x("<object|string|array> [string]",[e,n],arguments.length),this[Lt](e,!0),a(this,R,"f").describe(e,n),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,n){if(x("<string|array> [string]",[e,n],arguments.length),Array.isArray(e))e.forEach((t)=>this.example(...t));else a(this,R,"f").example(e,n);return this}exit(e,n){if(S(this,me,!0,"f"),S(this,Le,n,"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,n){if(x("<array> [function]",[e,n],arguments.length),!n)return new Promise((t,r)=>{a(this,De,"f").getCompletion(e,(i,s)=>{if(i)r(i);else t(s)})});else return a(this,De,"f").getCompletion(e,n)}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,nn,"f"))}getHelp(){if(S(this,me,!0,"f"),!a(this,R,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[_n](a(this,We,"f"),void 0,void 0,0,!0);if(J(n))return n.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,tn,"f")}getStrictCommands(){return a(this,rn,"f")}getStrictOptions(){return a(this,sn,"f")}global(e,n){if(x("<string|array> [boolean]",[e,n],arguments.length),e=[].concat(e),n!==!1)a(this,B,"f").local=a(this,B,"f").local.filter((t)=>e.indexOf(t)===-1);else e.forEach((t)=>{if(!a(this,B,"f").local.includes(t))a(this,B,"f").local.push(t)});return this}group(e,n){x("<string|array> <string>",[e,n],arguments.length);let t=a(this,nn,"f")[n]||a(this,_e,"f")[n];if(a(this,nn,"f")[n])delete a(this,nn,"f")[n];let r={};return a(this,_e,"f")[n]=(t||[]).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,n){return x("<string|object> [number|string|array]",[e,n],arguments.length),a(this,q,"f").implies(e,n),this}locale(e){if(x("[string]",[e],arguments.length),e===void 0)return this[Mt](),a(this,M,"f").y18n.getLocale();return S(this,Ze,!1,"f"),a(this,M,"f").y18n.setLocale(e),this}middleware(e,n,t){return a(this,Ee,"f").addMiddleware(e,!!n,t)}nargs(e,n){return x("<string|object|array> [number]",[e,n],arguments.length),this[pn](this.nargs.bind(this),"narg",e,n),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[un](e),this}option(e,n){if(x("<string|object> [object]",[e,n],arguments.length),typeof e==="object")Object.keys(e).forEach((t)=>{this.options(t,e[t])});else{if(typeof n!=="object")n={};if(this[un](e),a(this,Be,"f")&&(e==="version"||(n===null||n===void 0?void 0:n.alias)==="version"))this[wi](['"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,n.alias)this.alias(e,n.alias);let t=n.deprecate||n.deprecated;if(t)this.deprecateOption(e,t);let r=n.demand||n.required||n.require;if(r)this.demand(e,r);if(n.demandOption)this.demandOption(e,typeof n.demandOption==="string"?n.demandOption:void 0);if(n.conflicts)this.conflicts(e,n.conflicts);if("default"in n)this.default(e,n.default);if(n.implies!==void 0)this.implies(e,n.implies);if(n.nargs!==void 0)this.nargs(e,n.nargs);if(n.config)this.config(e,n.configParser);if(n.normalize)this.normalize(e);if(n.choices)this.choices(e,n.choices);if(n.coerce)this.coerce(e,n.coerce);if(n.group)this.group(e,n.group);if(n.boolean||n.type==="boolean"){if(this.boolean(e),n.alias)this.boolean(n.alias)}if(n.array||n.type==="array"){if(this.array(e),n.alias)this.array(n.alias)}if(n.number||n.type==="number"){if(this.number(e),n.alias)this.number(n.alias)}if(n.string||n.type==="string"){if(this.string(e),n.alias)this.string(n.alias)}if(n.count||n.type==="count")this.count(e);if(typeof n.global==="boolean")this.global(e,n.global);if(n.defaultDescription)a(this,B,"f").defaultDescription[e]=n.defaultDescription;if(n.skipValidation)this.skipValidation(e);let i=n.describe||n.description||n.desc,s=a(this,R,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(s,e)||typeof i==="string")this.describe(e,i);if(n.hidden)this.hide(e);if(n.requiresArg)this.requiresArg(e)}return this}options(e,n){return this.option(e,n)}parse(e,n,t){if(x("[string|array] [function|boolean|object] [function]",[e,n,t],arguments.length),this[xi](),typeof e>"u")e=a(this,We,"f");if(typeof n==="object")S(this,en,n,"f"),n=t;if(typeof n==="function")S(this,Fe,n,"f"),n=!1;if(!n)S(this,We,e,"f");if(a(this,Fe,"f"))S(this,be,!1,"f");let r=this[_n](e,!!n),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[Wt](),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[Wt](),this.parsed=i}return r}parseAsync(e,n,t){let r=this.parse(e,n,t);return!J(r)?Promise.resolve(r):r}parseSync(e,n,t){let r=this.parse(e,n,t);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,Kn,e,"f"),this}pkgConf(e,n){x("<string> [string]",[e,n],arguments.length);let t=null,r=this[Nt](n||a(this,Xe,"f"));if(r[e]&&typeof r[e]==="object")t=Vn(r[e],n||a(this,Xe,"f"),this[on]()["deep-merge-config"]||!1,a(this,M,"f")),a(this,B,"f").configObjects=(a(this,B,"f").configObjects||[]).concat(t);return this}positional(e,n){x("<string> <object>",[e,n],arguments.length);let t=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];n=Ie(n,(s,o)=>{if(s==="type"&&!["string","number","boolean"].includes(o))return!1;return t.includes(s)});let r=a(this,Pn,"f").fullCommands[a(this,Pn,"f").fullCommands.length-1],i=r?a(this,ee,"f").cmdToParseOptions(r):{array:[],alias:{},default:{},demand:{}};return hn(i).forEach((s)=>{let o=i[s];if(Array.isArray(o)){if(o.indexOf(e)!==-1)n[s]=!0}else if(o[e]&&!(s in n))n[s]=o[e]}),this.group(e,a(this,R,"f").getPositionalGroupName()),this.option(e,n)}recommendCommands(e=!0){return x("[boolean]",[e],arguments.length),S(this,qn,e,"f"),this}required(e,n,t){return this.demand(e,n,t)}require(e,n,t){return this.demand(e,n,t)}requiresArg(e){if(x("<array|string|object> [number]",[e],arguments.length),typeof e==="string"&&a(this,B,"f").narg[e])return this;else this[pn](this.requiresArg.bind(this),"narg",e,NaN);return this}showCompletionScript(e,n){return x("[string] [string]",[e,n],arguments.length),e=e||this.$0,a(this,Qe,"f").log(a(this,De,"f").generateCompletionScript(e,n||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 t=this[_n](a(this,We,"f"),void 0,void 0,0,!0);if(J(t))return t.then(()=>{a(this,R,"f").showHelp(e)}),this}let n=a(this,ee,"f").runDefaultBuilderOn(this);if(J(n))return n.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,n){return x("[boolean|string] [string]",[e,n],arguments.length),a(this,R,"f").showHelpOnFail(e,n),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,tn,e!==!1,"f"),this}strictCommands(e){return x("[boolean]",[e],arguments.length),S(this,rn,e!==!1,"f"),this}strictOptions(e){return x("[boolean]",[e],arguments.length),S(this,sn,e!==!1,"f"),this}string(e){return x("<array|string>",[e],arguments.length),this[He]("string",e),this[un](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,n,t,r){if(x("<string|null|undefined> [string|boolean] [function|object] [function]",[e,n,t,r],arguments.length),n!==void 0)if(he(e,null,a(this,M,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,n,t,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,Xn,e,"f"),this}version(e,n,t){if(x("[boolean|string] [string] [string]",[e,n,t],arguments.length),a(this,Be,"f"))this[kt](a(this,Be,"f")),a(this,R,"f").version(void 0),S(this,Be,null,"f");if(arguments.length===0)t=this[Pi](),e="version";else if(arguments.length===1){if(e===!1)return this;t=e,e="version"}else if(arguments.length===2)t=n,n=void 0;return S(this,Be,typeof e==="string"?e:"version","f"),n=n||a(this,R,"f").deferY18nLookup("Show version number"),a(this,R,"f").version(t||void 0),this.boolean(a(this,Be,"f")),this.describe(a(this,Be,"f"),n),this}wrap(e){return x("<number|null|undefined>",[e],arguments.length),a(this,R,"f").wrap(e),this}[(ee=new WeakMap,Xe=new WeakMap,Pn=new WeakMap,De=new WeakMap,pe=new WeakMap,zn=new WeakMap,Le=new WeakMap,Ze=new WeakMap,Gn=new WeakMap,be=new WeakMap,Un=new WeakMap,Ee=new WeakMap,_e=new WeakMap,me=new WeakMap,Ce=new WeakMap,Yn=new WeakMap,Qe=new WeakMap,ae=new WeakMap,B=new WeakMap,Jn=new WeakMap,Kn=new WeakMap,Fe=new WeakMap,en=new WeakMap,gn=new WeakMap,nn=new WeakMap,We=new WeakMap,qn=new WeakMap,M=new WeakMap,tn=new WeakMap,rn=new WeakMap,sn=new WeakMap,R=new WeakMap,Xn=new WeakMap,Be=new WeakMap,q=new WeakMap,Ei)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch(n){}return e}[Ci](){return{log:(...e)=>{if(!this[Zn]())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[Zn]())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")}}}[kt](e){hn(a(this,B,"f")).forEach((n)=>{if(((r)=>r==="configObjects")(n))return;let t=a(this,B,"f")[n];if(Array.isArray(t)){if(t.includes(e))t.splice(t.indexOf(e),1)}else if(typeof t==="object")delete t[e]}),delete a(this,R,"f").getDescriptions()[e]}[wi](e,n,t){if(!a(this,Gn,"f")[t])a(this,M,"f").process.emitWarning(e,n),a(this,Gn,"f")[t]=!0}[xi](){a(this,Un,"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,tn,"f"),strictCommands:a(this,rn,"f"),strictOptions:a(this,sn,"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,en,"f")}),a(this,R,"f").freeze(),a(this,q,"f").freeze(),a(this,ee,"f").freeze(),a(this,Ee,"f").freeze()}[Si](){let e="",n;if(/\b(node|iojs|electron|bun)(\.exe)?$/.test(a(this,M,"f").process.argv()[0]))n=a(this,M,"f").process.argv().slice(1,2);else n=a(this,M,"f").process.argv().slice(0,1);if(e=n.map((t)=>{let r=this[Ii](a(this,Xe,"f"),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&r.length<t.length?r:t}).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}[on](){return a(this,Kn,"f")}[Ai](){return a(this,Xn,"f")}[Mt](){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(/[.:].*/,""))}[Pi](){return this[Nt]().version||"unknown"}[_i](e){let n=e["--"]?e["--"]:e._;for(let t=0,r;(r=n[t])!==void 0;t++)if(a(this,M,"f").Parser.looksLikeNumber(r)&&Number.isSafeInteger(Math.floor(parseFloat(`${r}`))))n[t]=Number(r);return e}[Nt](e){let n=e||"*";if(a(this,gn,"f")[n])return a(this,gn,"f")[n];let t={};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")),t=JSON.parse(a(this,M,"f").readFileSync(i,"utf8"))}catch(r){}return a(this,gn,"f")[n]=t||{},a(this,gn,"f")[n]}[He](e,n){n=[].concat(n),n.forEach((t)=>{t=this[Tt](t),a(this,B,"f")[e].push(t)})}[pn](e,n,t,r){this[It](e,n,t,r,(i,s,o)=>{a(this,B,"f")[i][s]=o})}[Rt](e,n,t,r){this[It](e,n,t,r,(i,s,o)=>{a(this,B,"f")[i][s]=(a(this,B,"f")[i][s]||[]).concat(o)})}[It](e,n,t,r,i){if(Array.isArray(t))t.forEach((s)=>{e(s,r)});else if(((s)=>typeof s==="object")(t))for(let s of hn(t))e(s,t[s]);else i(n,this[Tt](t),r)}[Tt](e){if(e==="__proto__")return"___proto___";return e}[Lt](e,n){return this[pn](this[Lt].bind(this),"key",e,n),this}[Wt](){var e,n,t,r,i,s,o,u,c,p,b,g;let D=a(this,Un,"f").pop();he(D,void 0,a(this,M,"f"));let F;e=this,n=this,t=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(n,be,y,"f")}}.value,groups:{set value(y){S(t,_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,tn,y,"f")}}.value,strictCommands:{set value(y){S(u,rn,y,"f")}}.value,strictOptions:{set value(y){S(c,sn,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,en,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()}[Bi](e,n){return qe(n,(t)=>(e(t),t))}getInternalMethods(){return{getCommandInstance:this[Oi].bind(this),getContext:this[$i].bind(this),getHasOutput:this[vi].bind(this),getLoggerInstance:this[ji].bind(this),getParseContext:this[ki].bind(this),getParserConfiguration:this[on].bind(this),getUsageConfiguration:this[Ai].bind(this),getUsageInstance:this[Mi].bind(this),getValidationInstance:this[Ni].bind(this),hasParseCallback:this[Zn].bind(this),isGlobalContext:this[Ri].bind(this),postProcess:this[an].bind(this),reset:this[Ht].bind(this),runValidation:this[Vt].bind(this),runYargsParserAndExecuteCommands:this[_n].bind(this),setHasOutput:this[Ti].bind(this)}}[Oi](){return a(this,ee,"f")}[$i](){return a(this,Pn,"f")}[vi](){return a(this,me,"f")}[ji](){return a(this,Qe,"f")}[ki](){return a(this,en,"f")||{}}[Mi](){return a(this,R,"f")}[Ni](){return a(this,q,"f")}[Zn](){return!!a(this,Fe,"f")}[Ri](){return a(this,Yn,"f")}[an](e,n,t,r){if(t)return e;if(J(e))return e;if(!n)e=this[Ei](e);if(this[on]()["parse-positional-numbers"]||this[on]()["parse-positional-numbers"]===void 0)e=this[_i](e);if(r)e=Ke(e,this,a(this,Ee,"f").getMiddleware(),!1);return e}[Ht](e={}){S(this,B,a(this,B,"f")||{},"f");let n={};n.local=a(this,B,"f").local||[],n.configObjects=a(this,B,"f").configObjects||[];let t={};n.local.forEach((s)=>{t[s]=!0,(e[s]||[]).forEach((o)=>{t[o]=!0})}),Object.assign(a(this,nn,"f"),Object.keys(a(this,_e,"f")).reduce((s,o)=>{let u=a(this,_e,"f")[o].filter((c)=>!(c in t));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)=>{n[s]=(a(this,B,"f")[s]||[]).filter((o)=>!t[o])}),i.forEach((s)=>{n[s]=Ie(a(this,B,"f")[s],(o)=>!t[o])}),n.envPrefix=a(this,B,"f").envPrefix,S(this,B,n,"f"),S(this,R,a(this,R,"f")?a(this,R,"f").reset(t):fi(this,a(this,M,"f")),"f"),S(this,q,a(this,q,"f")?a(this,q,"f").reset(t):yi(this,a(this,R,"f"),a(this,M,"f")),"f"),S(this,ee,a(this,ee,"f")?a(this,ee,"f").reset():li(a(this,R,"f"),a(this,q,"f"),a(this,Ee,"f"),a(this,M,"f")),"f"),!a(this,De,"f"))S(this,De,pi(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}[Ii](e,n){return a(this,M,"f").path.relative(e,n)}[_n](e,n,t,r=0,i=!1){var s,o,u,c;let p=!!t||i;e=e||a(this,We,"f"),a(this,B,"f").__=a(this,M,"f").y18n.__,a(this,B,"f").configuration=this[on]();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,en,"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[Mt](),n)return this[an](F,b,!!t,!1);if(a(this,Ce,"f")){if([a(this,Ce,"f")].concat(h[a(this,Ce,"f")]||[]).filter((te)=>te.length>1).includes(""+F._[F._.length-1]))F._.pop(),v=!0}S(this,Yn,!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 te=r||0,X;F._[te]!==void 0;te++)if(X=String(F._[te]),T.includes(X)&&X!==a(this,pe,"f")){let Pe=a(this,ee,"f").runCommand(X,this,D,te+1,i,v||W||i);return this[an](Pe,b,!!t,!1)}else if(!Y&&X!==a(this,pe,"f")){Y=X;break}if(!a(this,ee,"f").hasDefaultCommand()&&a(this,qn,"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[an](Y,b,!!t,!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,(te,X)=>{if(te)throw new Q(te.message);(X||[]).forEach((Pe)=>{a(this,Qe,"f").log(Pe)}),this.exit(0)}),this[an](F,!b,!!t,!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[Vt](h,{},D.error);if(!t)y=Ke(F,this,a(this,Ee,"f").getMiddleware(),!0);if(y=this[Bi](Y,y!==null&&y!==void 0?y:F),J(y)&&!t)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[an](y!==null&&y!==void 0?y:F,b,!!t,!0)}[Vt](e,n,t,r){let i={...this.getDemandedOptions()};return(s)=>{if(t)throw new Q(t.message);a(this,q,"f").nonOptionCount(s),a(this,q,"f").requiredArguments(s,i);let o=!1;if(a(this,rn,"f"))o=a(this,q,"f").unknownCommands(s);if(a(this,tn,"f")&&!o)a(this,q,"f").unknownArguments(s,e,n,!!r);else if(a(this,sn,"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)}}[Ti](){S(this,me,!0,"f")}[un](e){if(typeof e==="string")a(this,B,"f").key[e]=!0;else for(let n of e)a(this,B,"f").key[n]=!0}}function ci(e){return!!e&&typeof e.getInternalMethods==="function"}var ou=Li(ri),Hi=ou;var Vi={name:"@coryrylan/cradle",version:"1.3.1",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 Gi}from"path";var Qn="agent-browser-nono-fallback.ts";function zi(){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
|
|
99
|
-
\u26A0 ${e.note}`:
|
|
100
|
-
`)}function
|
|
98
|
+
`}function uu(e){let n=[];if(e.systemFilePath!==null)n.push("--system-prompt",e.systemFilePath);if(e.appendSystemFilePath!==null)n.push("--append-system-prompt",e.appendSystemFilePath);return n}function lu(e){let{folder:n}=e,{settings:t}=n,r=[e.piBin,...uu(n),"--no-extensions","--no-skills","--no-prompt-templates"];if(n.providersJson!==null)r.push("-e",Gi(e.extensionsDir,"providers.ts"));if(e.backend==="nono")r.push("-e",Gi(e.extensionsDir,Qn));for(let i of e.packageEntries??[])r.push("-e",i);for(let i of n.extensionFiles)r.push("-e",i);if(n.skillsDir!==null)r.push("--skill",n.skillsDir);if(t.defaultProvider!==void 0)r.push("--provider",t.defaultProvider);if(t.defaultModel!==void 0)r.push("--model",t.defaultModel);if(t.defaultThinkingLevel!==void 0)r.push("--thinking",t.defaultThinkingLevel);return r.push("--session-dir",e.sessionsDir),r.push(...e.passthrough),r}function zt(e){return e.backend==="nono"?{MISE_CACHE_DIR:e.miseCacheDir}:{}}function mn(e){let n=lu(e);if(e.backend!=="nono")return n;return[e.nonoBin,"run",...e.verbose===!0?[]:["--silent"],"--profile",e.profilePath,"--",...n]}import{existsSync as cu}from"fs";import{homedir as du}from"os";import{join as fu}from"path";function hu(e,n=du()){let t=fu(n,".local","share","mise","shims",e);return cu(t)?t:null}var Ui=(e)=>Bun.which(e)??hu(e);function Gt(e,n=Ui){return n(e)}function Fn(e,n=Ui){let t=Gt(e,n);if(!t)throw Error(`Required executable "${e}" not found on PATH \u2014 install it, then run \`cradle doctor\` to verify`);return t}var Du="recommended: the supported way to install pi/nono \u2014 cradle resolves them from mise shims and the sandbox profile assumes a mise-managed install",gu="required for sandboxed runs (a folder declaring sandbox/nono.json, or --sandbox/--offline/--allow-host); not needed otherwise",pu="required for sbx-backend runs (a folder declaring sandbox/sbx.json, or --sandbox-backend sbx); not needed otherwise",mu="recommended for `cradle schedule`: installs schedule/*.md tasks as launchd LaunchAgents; not needed otherwise",Fu="recommended for `cradle schedule`: installs schedule/*.md tasks as systemd --user timers; not needed otherwise";function yu(e){if(e==="darwin")return"launchctl";if(e==="linux")return"systemctl";return null}function bu(e){return e==="launchctl"?mu:Fu}function et(e,n,t,r){return{name:e,bin:e,required:!1,found:n,version:t,...n?{}:{note:r}}}function Eu(e){let n=(r)=>Gt(r,e.which),t=yu(e.platform??process.platform);return{piPath:n("pi"),nonoPath:n("nono"),sbxPath:n("sbx"),misePath:n("mise"),scheduleBin:t,schedulePath:t!==null?n(t):null}}async function Yi(e={}){let n=async(c,p)=>c!==null&&e.readVersion?e.readVersion(c,p):null,t=Eu(e),[r,i,s,o,u]=await Promise.all([n(t.piPath),n(t.nonoPath),n(t.sbxPath,["version"]),n(t.misePath),n(t.schedulePath)]);return[{name:"pi",bin:"pi",required:!0,found:t.piPath,version:r},et("nono",t.nonoPath,i,gu),et("sbx",t.sbxPath,s,pu),et("mise",t.misePath,o,Du),...t.scheduleBin!==null?[et(t.scheduleBin,t.schedulePath,u,bu(t.scheduleBin))]:[]]}var Cu=8;function wu(e,n){let t=e.name.padEnd(n),r=e.version!==null?`${e.version} `:"",i=e.found?`\u2713 ${t} ${r}${e.found}`:e.required?`\u2717 ${t} MISSING (required)`:`\u25CB ${t} not found (recommended)`;return e.note?`${i}
|
|
99
|
+
\u26A0 ${e.note}`:i}function Ji(e){let n=Math.max(Cu,...e.map((t)=>t.name.length));return e.map((t)=>wu(t,n)).join(`
|
|
100
|
+
`)}function Ki(e){return e.some((n)=>n.required&&!n.found)?1:0}import{exists as Us,mkdir as nr,rm as Bc,writeFile as Ys}from"fs/promises";import{homedir as Oc}from"os";import{basename as $c,dirname as vc,join as jn}from"path";import{stat as Lu}from"fs/promises";import{join as ss,resolve as Wu}from"path";import{basename as Su,isAbsolute as Au,join as Pu,relative as _u}from"path";var Bn={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 qi="nono-profile.json";function nt(e,n){let t=_u(e,n);return t===""||!t.startsWith("..")&&!Au(t)}function Xi(e,n){let t=Pu(n,".local","state","nono");return nt(e,t)||nt(t,e)?e:void 0}function ln(e,n){if(e==="~"||e==="$HOME")return n;if(e.startsWith("~/"))return`${n}${e.slice(1)}`;if(e.startsWith("$HOME/"))return`${n}${e.slice(5)}`;return e}function Zi(e){let n=(o)=>ln(o,e.home),t=Bn.filesystem,r=e.network!==void 0?Bu(e.network):void 0,i=[...t.unix_socket_dir_bind??[],...e.grants.unixSocketDirBind.map(n)],s={...Bn,meta:{...Bn.meta,name:`cradle-${Su(e.stateDir)}`},filesystem:{...t,read:[...t.read??[],e.agentDir,...e.grants.read.map(n)],write:[...t.write??[],...e.grants.write.map(n)],allow:[...t.allow??[],e.cwd,e.stateDir,...e.linkedGitDir!==void 0?[e.linkedGitDir]:[],...e.grants.allow.map(n)],...i.length>0?{unix_socket_dir_bind:i}:{}},unsafe_macos_seatbelt_rules:[...Bn.unsafe_macos_seatbelt_rules,...e.rules],...r!==void 0?{network:r}:{}};return JSON.stringify(s,null,2)}function Bu(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 Qi,lstat as Ou,mkdir as $u,readdir as es,readFile as vu,rm as ju,writeFile as ku}from"fs/promises";import{dirname as Mu,join as rt,relative as Nu}from"path";function le(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function yn(e,n){try{return JSON.parse(e)}catch(t){throw Error(`${n} is not valid JSON: ${Se(t)}`,{cause:t})}}function Se(e){return e instanceof Error?e.message:String(e)}function de(e,n){return typeof e==="object"&&e!==null&&"code"in e&&e.code===n}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((n)=>typeof n==="string")}function cn(e){return/^(?:\/|~(?:\/|$)|\$HOME(?:\/|$)|[A-Za-z]:[\\/]|\\\\)/.test(e)}function Oe(e,n,t,r){let i=Object.keys(e).filter((s)=>!t.includes(s));if(i.length>0)r.push(`${n}: unsupported keys ignored: ${i.join(", ")}`)}function tt(e,n,t,r){e.results.push({name:n,detail:t,status:r})}function Ru(e,n,t){e.failures.push(`${n}: ${t}`),tt(e,n,t,"failed")}async function ns(e,n,t,r){try{if(await Tu(t,r)){tt(e,n,t,"unchanged");return}if(e.dryRun){tt(e,n,`would replace ${t}`,"changed");return}await rs(t),await ju(t,{force:!0,recursive:!0});for(let i of r)await Iu(t,i);tt(e,n,t,"changed")}catch(i){Ru(e,n,Se(i))}}async function Iu(e,n){let t=rt(e,n.rel);if(await $u(Mu(t),{recursive:!0}),await ku(t,n.content,"utf8"),n.mode!==void 0)await Qi(t,n.mode)}async function Tu(e,n){let t=await ts(e);if(t.length!==n.length)return!1;let r=new Set(t);for(let i of n){if(!r.has(i.rel))return!1;if(await Ae(rt(e,i.rel))!==i.content)return!1}return!0}async function ts(e,n=e){let t=await is(e);if(!t||!t.isDirectory())return[];let r=[];for(let i of await es(e,{withFileTypes:!0})){let s=rt(e,i.name);if(i.isDirectory())r.push(...await ts(s,n));else r.push(Nu(n,s))}return r}async function rs(e){let n=await is(e);if(!n||n.isSymbolicLink())return;if(await Qi(e,n.isDirectory()?493:420),!n.isDirectory())return;let t=await es(e);await Promise.all(t.map((r)=>rs(rt(e,r))))}async function Ae(e){try{return await vu(e,"utf8")}catch(n){if(de(n,"ENOENT"))return;throw n}}async function is(e){try{return await Ou(e)}catch(n){if(de(n,"ENOENT"))return;throw n}}var Hu=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function it(e,n){if(!Vu(e))return{dir:e,warnings:[]};let t=ss(n.home,".cradle","settings.json"),r=[],i=await zu(t,r),s=ss(n.cwd,e),o=i.get(e);if(o!==void 0){let u=Wu(ln(o,n.home));if(await os(s))r.push(Yu(e,u));return{dir:u,warnings:r}}if(await os(s))return{dir:s,warnings:r};throw Error(Ju(e,s,t,i))}function Vu(e){return Hu.test(e)}async function os(e){try{return(await Lu(e)).isDirectory()}catch(n){if(de(n,"ENOENT")||de(n,"ENOTDIR"))return!1;throw n}}async function zu(e,n){let t=await Ae(e);if(t===void 0)return new Map;let r=yn(t,e);if(!le(r))return n.push(`${e}: settings must be a JSON object \u2014 ignored`),new Map;return Oe(r,e,["agents"],n),Gu(r,e,n)}function Gu(e,n,t){let r=e.agents;if(r===void 0)return new Map;if(!le(r))return t.push(`${n}: agents must be an object \u2014 ignored`),new Map;let i=Object.entries(r).map((s)=>{let[o,u]=s,c=Uu(u,o,n,t);return c===void 0?void 0:[o,c]}).filter((s)=>s!==void 0);return new Map(i)}function Uu(e,n,t,r){if(!le(e)){r.push(`${t}: agents.${n} must be an object with a "path" \u2014 ignored`);return}let i=e.path;if(typeof i!=="string"||i.trim()===""){r.push(`${t}: agents.${n}.path must be a non-empty string \u2014 ignored`);return}if(!cn(i)){r.push(`${t}: agents.${n}.path must be an absolute, ~/, or $HOME/ path \u2014 ignored: ${i}`);return}return i}function Yu(e,n){return`started alias "${e}" (${n}) \u2014 a directory named ${e} exists in the current directory; use ./${e} to run it instead`}function Ju(e,n,t,r){let i=r.size>0?` (known agents: ${[...r.keys()].join(", ")})`:"";return`Agent folder not found: ${n} \u2014 and no "agents.${e}" entry in ${t}${i}`}import{createHash as Ku}from"crypto";import{join as qu}from"path";var us="host.docker.internal",as="@earendil-works/pi-coding-agent",Xu=/^\d+\.\d+\.\d+\.\d+$/,Zu=new Set(["localhost","127.0.0.1"]);function ls(e){let n=(r)=>ln(r,e.home),t=[{path:e.cwd,readonly:!1},{path:e.agentDir,readonly:!0},{path:e.stateDir,readonly:!1},{path:qu(e.home,".pi","agent"),readonly:!1},...e.linkedGitDir!==void 0?[{path:e.linkedGitDir,readonly:!1}]:[],...e.grants.read.map((r)=>({path:n(r),readonly:!0})),...e.grants.write.map((r)=>({path:n(r),readonly:!1})),...e.grants.allow.map((r)=>({path:n(r),readonly:!1}))];return Qu(t)}function Qu(e){let n=[],t=new Map;for(let r of e){if(!t.has(r.path))n.push(r.path);if(t.get(r.path)!==!1)t.set(r.path,r.readonly)}return n.map((r)=>({path:r,readonly:t.get(r)===!0}))}function cs(e,n){let t=n.map((i)=>`${i.path}:${i.readonly?"ro":"rw"}`).sort().join("|"),r=Ku("sha256").update(t).digest("hex").slice(0,8);return`cradle-${e}-${r}`}function ds(e){let n=e.mounts.map((t)=>t.readonly?`${t.path}:ro`:t.path);return[e.sbxBin,"create","shell",...n,"--name",e.name,"-q"]}function el(e){let n=[],t=!1;for(let r of e)if(Zu.has(r))t=!0;else if(Xu.test(r))n.push(r);else n.push(r,`*.${r}`);if(t)n.push(us);return n}function fs(e){let{network:n,sbxBin:t,name:r}=e;if(n===void 0)return[];if(n.block===!0)return[[t,"policy","deny","network","--sandbox",r,"**"]];let i=el(n.allowDomain??[]);return i.length>0?[[t,"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 tl(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 rl(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 hs(e){if(e===void 0)return[];return[nl(e),tl(e),rl(e)].filter((n)=>n!==void 0)}function Ds(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 Ut(e){let n=e.piVersion===null?`command -v pi >/dev/null 2>&1 || npm i -g ${as}`:`command -v pi >/dev/null 2>&1 && [ "$(pi --version 2>/dev/null)" = "${e.piVersion}" ] || npm i -g ${as}@${e.piVersion}`;return[e.sbxBin,"exec",e.name,"bash","-lc",n]}function st(e,n){return[e.sbxBin,"exec","-i",...e.tty?["-t"]:[],"-e",`HOME=${e.home}`,"-w",e.cwd,e.name,...n]}function gs(e){return e.toLowerCase().includes("already exists")}function ps(e){let n;try{n=new URL(e)}catch{return e}if(n.hostname!=="localhost"&&n.hostname!=="127.0.0.1")return e;return n.hostname=us,n.toString()}function ms(e,n={}){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 = ${
|
|
103
|
+
const providers = ${n.rewriteLocalhostBaseUrls===!0?il(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
|
|
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
|
-
`)
|
|
110
|
+
`}function il(e){let n=JSON.parse(e);for(let t of Object.values(n)){if(t===null||typeof t!=="object")continue;let r=t;if(typeof r.baseUrl==="string")r.baseUrl=ps(r.baseUrl)}return JSON.stringify(n,null,2)}import{lstat as Ml,readdir as ks,stat as Nl}from"fs/promises";import{join as we,resolve as Rl}from"path";import{readdir as al,stat as ul}from"fs/promises";import{join as Ge,resolve as Es,sep as Cs}from"path";import{basename as sl,relative as ys,sep as Fs}from"path";function On(e){return e.startsWith("!")||e.startsWith("+")||e.startsWith("-")}function qt(e,n,t){let r=n.filter((u)=>!On(u)),i=Yt(n,"!"),s=Yt(n,"+"),o=Yt(n,"-");return e.filter((u)=>{if(Kt(u,o,t))return!1;if(Kt(u,s,t))return!0;if(Jt(u,i,t))return!1;return r.length===0||Jt(u,r,t)})}function bs(e,n,t){return e.filter((r)=>{let i=n.filter((s)=>ol(r,s,t)).at(-1);return i!==void 0&&!i.startsWith("-")&&!i.startsWith("!")})}function ol(e,n,t){let r=On(n)?n.slice(1):n;return n.startsWith("+")||n.startsWith("-")?Kt(e,[r],t):Jt(e,[r],t)}function Yt(e,n){return e.filter((t)=>t.startsWith(n)).map((t)=>t.slice(1))}function Jt(e,n,t){let r=[bn(ys(t,e)),sl(e),bn(e)];return n.some((i)=>{let s=new Bun.Glob(bn(i));return r.some((o)=>s.match(o))})}function Kt(e,n,t){let r=bn(ys(t,e)),i=bn(e);return n.some((s)=>{let o=bn(s.startsWith("./")?s.slice(2):s);return o===r||o===i})}function bn(e){return Fs==="/"?e:e.split(Fs).join("/")}var ll=/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/,cl=/^[0-9A-Za-z.^~><=* +-]+$/,dl=/\.[tj]s$/,fl=/[*?]/;function xs(e,n,t){let r=e.packages;if(r===void 0)return[];if(!Array.isArray(r))return t.push(`${n}: packages must be an array \u2014 ignored`),[];let i=hl(r,n,t),s=Fl(i,n,t);return yl(s,n,t)}function hl(e,n,t){let r=[],i=[];for(let s of e){let o=typeof s==="string"?{source:s}:Dl(s,n,t);if(o===null)i.push(JSON.stringify(s));else r.push(o)}if(i.length>0)t.push(`${n}: packages entries must be a source string or a { "source": \u2026 } object \u2014 ignored: ${i.join(", ")}`);return r}function Dl(e,n,t){if(!le(e))return null;let r=e.source;if(typeof r!=="string")return null;ml(e,r,n,t);let i=e.autoload;if(i!==void 0&&typeof i!=="boolean")t.push(`${n}: packages entry ${r}: autoload must be a boolean \u2014 ignored`);let s=gl(e,r,n,t);return{source:r,...s!==void 0?{extensions:s}:{},...i===!1?{autoloadDisabled:!0}:{}}}function gl(e,n,t,r){let i=e.extensions;if(i===void 0)return;if(!ze(i)){r.push(`${t}: packages entry ${n}: extensions must be an array of strings \u2014 ignored`);return}return i}var pl=new Set(["source","extensions","autoload"]),ws=new Set(["skills","prompts","themes"]);function ml(e,n,t,r){let i=Object.keys(e).filter((u)=>!pl.has(u)),s=i.filter((u)=>ws.has(u)),o=i.filter((u)=>!ws.has(u));if(s.length>0)r.push(`${t}: packages entry ${n}: cradle loads a package's extensions and nothing else \u2014 ignored: ${s.join(", ")}`);if(o.length>0)r.push(`${t}: packages entry ${n}: unknown filter keys \u2014 ignored: ${o.join(", ")}`)}function Fl(e,n,t){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(", ");t.push(`${n}: only npm: package sources are supported \u2014 ignored: ${s}`)}return r}function yl(e,n,t){let r=[],i=[];for(let{source:s,...o}of e){let u=bl(s.slice(4));if(u===null)i.push(s);else r.push({...u,...o})}if(i.length>0)t.push(`${n}: packages entries must be npm:<name>[@<version>] \u2014 ignored: ${i.join(", ")}`);return r}function bl(e){let n=e.lastIndexOf("@"),t=n>0,r=t?e.slice(0,n):e,i=t?e.slice(n+1):"latest";if(!ll.test(r)||!cl.test(i))return null;return{name:r,version:i}}function Ss(e){let n=Object.fromEntries([...e].sort((t,r)=>t.name.localeCompare(r.name)).map((t)=>[t.name,t.version]));return`${JSON.stringify({name:"cradle-agent-packages",private:!0,dependencies:n},null,2)}
|
|
111
|
+
`}async function As(e,n){let t=await Promise.all(n.map(async(r)=>{let i=[];return{entries:await El(e,r,i),warnings:i}}));return{entries:t.flatMap((r)=>r.entries),warnings:t.flatMap((r)=>r.warnings)}}async function El(e,n,t){let r=Ge(e,"node_modules",n.name),i=await Cl(n.name,r,t);if(i===null)return[];let s=await wl(r,i,n.name,t);return $l(s,n,r)}async function Cl(e,n,t){let r=Ge(n,"package.json"),i=await Ae(r);if(i===void 0)return t.push(`package ${e} is not installed \u2014 skipped`),null;try{let s=yn(i,r);if(!le(s))return t.push(`package ${e}: ${r} must be a JSON object \u2014 skipped`),null;return s}catch(s){return t.push(`package ${e}: ${Se(s)} \u2014 skipped`),null}}async function wl(e,n,t,r){let i=xl(n);if(i!==void 0)return Sl(e,i,t,r);let s=await Ps(Ge(e,"extensions"));if(s.length>0)return s;return Ol(t,e,r)}function xl(e){let n=e.pi;if(n===void 0||!le(n))return;let t=n.extensions;if(t===void 0||!ze(t)||t.length===0)return;return t}async function Sl(e,n,t,r){let i=n.filter((c)=>!On(c)),o=(await Promise.all(i.map((c)=>Al(e,c,t,r)))).flat(),u=n.filter(On);return u.length>0?qt(o,u,e):o}async function Al(e,n,t,r){let i=await Pl(e,n),s=i.filter((u)=>vl(e,u));if(s.length<i.length)r.push(`package ${t}: extension entry "${n}" escapes the package directory \u2014 skipped`);let o=await Promise.all(s.map(async(u)=>({files:await _l(u)})));if(o.some((u)=>u.files===null))r.push(`package ${t}: extension entry "${n}" not found \u2014 skipped`);return o.flatMap((u)=>u.files??[])}async function Pl(e,n){if(!fl.test(n))return[Es(e,n)];let t=new Bun.Glob(n).scan({cwd:e,absolute:!0,onlyFiles:!1});return(await Array.fromAsync(t)).map((r)=>Es(r)).sort()}async function _l(e){let n=await jl(e);if(n===void 0)return null;return n.isDirectory()?Ps(e):[e]}async function Ps(e){let t=[...await kl(e)].sort((i,s)=>i.name.localeCompare(s.name));return(await Promise.all(t.map((i)=>Bl(e,i)))).flat()}async function Bl(e,n){if(n.name.startsWith(".")||n.name==="node_modules")return[];if(n.isFile())return dl.test(n.name)?[Ge(e,n.name)]:[];if(!n.isDirectory())return[];let t=await _s([Ge(e,n.name,"index.ts"),Ge(e,n.name,"index.js")]);return t===null?[]:[t]}async function Ol(e,n,t){let r=await _s([Ge(n,"index.ts"),Ge(n,"index.js")]);if(r===null)return t.push(`package ${e} declares no pi extensions \u2014 skipped`),[];return[r]}function $l(e,n,t){if(n.autoloadDisabled===!0)return bs(e,n.extensions??[],t);if(n.extensions===void 0)return[...e];if(n.extensions.length===0)return[];return qt(e,n.extensions,t)}function vl(e,n){let t=e.endsWith(Cs)?e:`${e}${Cs}`;return n===e||n.startsWith(t)}async function _s(e){return(await Promise.all(e.map(async(t)=>await Bun.file(t).exists()?t:null))).find((t)=>t!==null)??null}async function jl(e){try{return await ul(e)}catch(n){if(de(n,"ENOENT")||de(n,"ENOTDIR"))return;throw n}}async function kl(e){try{return await al(e,{withFileTypes:!0})}catch(n){if(de(n,"ENOENT")||de(n,"ENOTDIR"))return[];throw n}}var Bs=["off","minimal","low","medium","high","xhigh","max"],Os=new Set(["subagents","channels","connections"]),Il=new Set(["SYSTEM.md","APPEND_SYSTEM.md","settings.json","models.json","skills","schedule","extensions","sandbox"]),Tl=new Set([".git",".gitignore",".DS_Store","README.md","LICENSE"]),$n={read:[],write:[],allow:[],unixSocketDirBind:[]},ot={posture:"unconfigured",filesystem:$n,unsafeMacosSeatbeltRules:[]};async function at(e){let n=Rl(e),t=await Ll(n),r=new Map(t.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: ${n} (needs SYSTEM.md or APPEND_SYSTEM.md${c} \u2014 see ARCHITECTURE.md)`)}let o=[];Wl(t,o);let u=await Zl(n,r.get("sandbox"),o);return{dir:n,systemFilePath:i?we(n,"SYSTEM.md"):null,appendSystemFilePath:s?we(n,"APPEND_SYSTEM.md"):null,settings:await Vl(n,r.has("settings.json"),o),providersJson:await Yl(n,r.has("models.json"),o),skillsDir:await Kl(n,r.get("skills"),o),scheduleDir:await ql(n,r.get("schedule"),o),extensionFiles:await Xl(n,r.get("extensions"),o),sandbox:u.nono,sbx:u.sbx,warnings:o}}async function Ll(e){try{return await ks(e,{withFileTypes:!0})}catch(n){if(de(n,"ENOENT")||de(n,"ENOTDIR"))throw Error(`Agent folder not found: ${e}`,{cause:n});throw n}}async function ut(e,n){if(n.isDirectory())return!0;if(!n.isSymbolicLink())return!1;try{return(await Nl(we(e,n.name))).isDirectory()}catch(t){if(de(t,"ENOENT"))return!1;throw t}}function Wl(e,n){let t=e.filter((i)=>Os.has(i.name)).map((i)=>i.name),r=e.map((i)=>i.name).filter((i)=>!Il.has(i)&&!Os.has(i)&&!Tl.has(i));if(t.length>0)n.push(`reserved for a future cradle release, ignored: ${t.join(", ")}`);if(r.length>0)n.push(`not part of the agent folder format, ignored: ${r.join(", ")}${Hl(r)}`)}function Hl(e){return e.includes("schedules")?" \u2014 did you mean schedule/ (singular)?":""}async function Vl(e,n,t){if(!n)return{};let r=we(e,"settings.json"),i=await Qt(r);Gl(i,r,t);let s=Xt(i,"defaultProvider",r,t),o=Xt(i,"defaultModel",r,t),u=lc(i,r,t),c=xs(i,r,t),p=Ul(i,r,t);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 zl=new Set(["defaultProvider","defaultModel","defaultThinkingLevel","packages","npmCommand"]);function Gl(e,n,t){let r=Object.keys(e).filter((i)=>!zl.has(i));if(r.length>0)t.push(`${n}: 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 $s=new Set(["npm","pnpm","yarn","bun"]);function Ul(e,n,t){let r=e.npmCommand;if(r===void 0)return;let[i,...s]=ze(r)?r:[];if(i===void 0||s.length>0||!$s.has(i)){let o=[...$s].join(", ");t.push(`${n}: npmCommand must be a single-element array naming one of ${o} \u2014 ignored`);return}return[i]}async function Yl(e,n,t){if(!n)return null;let r=we(e,"models.json"),i=await Qt(r),s=i.providers;if(s===void 0||!le(s))throw Error(`${r} must contain a "providers" object`);return Oe(i,r,["providers"],t),JSON.stringify(Jl(s),null,2)}function Jl(e){let n={input:0,output:0,cacheRead:0,cacheWrite:0};return Object.fromEntries(Object.entries(e).map(([t,r])=>{if(!le(r)||!Array.isArray(r.models))return[t,r];let i=r.models.map((s)=>le(s)&&s.cost===void 0?{cost:n,...s}:s);return[t,{...r,models:i}]}))}async function Kl(e,n,t){if(!n)return null;if(!await ut(e,n))return t.push("skills must be a directory \u2014 ignored"),null;return we(e,"skills")}async function ql(e,n,t){if(!n)return null;if(!await ut(e,n))return t.push("schedule must be a directory \u2014 ignored"),null;return we(e,"schedule")}async function Xl(e,n,t){if(!n)return[];if(!await ut(e,n))return t.push("extensions must be a directory \u2014 ignored"),[];let r=we(e,"extensions"),i=await ks(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 Zl(e,n,t){let r={nono:ot,sbx:ot};if(!n)return r;if(!await ut(e,n))return t.push("sandbox must be a directory \u2014 ignored"),r;let i=we(e,"sandbox","nono.json"),s=we(e,"sandbox","sbx.json"),o=await vs(i),u=await vs(s);if(o===void 0&&u===void 0)return t.push("sandbox/ has no nono.json or sbx.json \u2014 sandboxing stays off unless --sandbox is passed"),r;return{nono:o===void 0?ot:Ql(o,i,t),sbx:u===void 0?ot:ec(u,s,t)}}function Ql(e,n,t){let r=lt(e,"sandbox",n,t),i=sc(e,n,t);return ic(e,n,t),Oe(e,n,["sandbox","network","filesystem","unsafe_macos_seatbelt_rules","net"],t),{posture:r===!1?"disabled":"enabled",...i!==void 0?{network:i}:{},filesystem:ac(e.filesystem,n,t),unsafeMacosSeatbeltRules:oc(e.unsafe_macos_seatbelt_rules,n,t)}}function ec(e,n,t){let r=lt(e,"sandbox",n,t),i=nc(e,n,t);return Zt({record:e,key:"unsafe_macos_seatbelt_rules",path:n,explanation:"the sbx VM boundary replaces Seatbelt"},t),Oe(e,n,["sandbox","network","filesystem","unsafe_macos_seatbelt_rules"],t),{posture:r===!1?"disabled":"enabled",...i!==void 0?{network:i}:{},filesystem:tc(e.filesystem,n,t),unsafeMacosSeatbeltRules:[]}}function nc(e,n,t){let r=e.network;if(r===void 0)return;if(!le(r)){t.push(`${n}: network must be an object \u2014 ignored`);return}for(let c of["network_profile","open_port","listen_port"])Zt({record:r,key:c,path:n},t);let i=`${n} network`;Oe(r,i,["block","allow_domain","network_profile","open_port","listen_port"],t);let s=lt(r,"block",i,t),o=Ms(r,"allow_domain",i,t),u={...s!==void 0?{block:s}:{},...o.length>0?{allowDomain:o}:{}};return Object.keys(u).length>0?u:void 0}function tc(e,n,t){if(e===void 0)return $n;if(!le(e))return t.push(`${n}: filesystem must be an object \u2014 ignored`),$n;return Zt({record:e,key:"unix_socket_dir_bind",path:n,explanation:"Unix sockets cannot cross the sbx VM boundary"},t),Oe(e,`${n} filesystem`,["read","write","allow","unix_socket_dir_bind"],t),{read:dn(e,"read",n,t),write:dn(e,"write",n,t),allow:dn(e,"allow",n,t),unixSocketDirBind:[]}}function Zt({record:e,key:n,path:t,explanation:r},i){if(e[n]===void 0)return;i.push(`${t}: ${n} is nono-only \u2014 ${r!==void 0?`${r}; `:""}ignored`)}async function vs(e){return await rc(e)?Qt(e):void 0}async function rc(e){try{return await Ml(e),!0}catch(n){if(de(n,"ENOENT"))return!1;throw n}}function ic(e,n,t){if(e.net!==void 0)t.push(`${n}: "net" was removed \u2014 use "network" instead (see ARCHITECTURE.md) \u2014 ignored`)}function sc(e,n,t){let r=e.network;if(r===void 0)return;if(!le(r)){t.push(`${n}: network must be an object \u2014 ignored`);return}let i=`${n} network`;Oe(r,i,["block","network_profile","allow_domain","open_port","listen_port"],t);let s=lt(r,"block",i,t),o=Xt(r,"network_profile",i,t),u=Ms(r,"allow_domain",i,t),c=js(r,"open_port",i,t),p=js(r,"listen_port",i,t),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 Ms(e,n,t,r){let i=e[n];if(i===void 0)return[];if(!ze(i))return r.push(`${t}: ${n} 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(`${t}: ${n} entries must be non-empty \u2014 blanks ignored`);return s}function js(e,n,t,r){let i=e[n];if(i===void 0)return[];if(!Array.isArray(i))return r.push(`${t}: ${n} 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(`${t}: ${n} entries must be integers 0\u201365535 \u2014 ignored: ${o.join(", ")}`);return i.filter(s)}function oc(e,n,t){if(e===void 0)return[];if(!ze(e))return t.push(`${n}: 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)t.push(`${n}: unsafe_macos_seatbelt_rules entries must be parenthesized s-expressions \u2014 ignored: ${i.join(", ")}`);return e.filter(r).map((s)=>s.trim())}function lt(e,n,t,r){let i=e[n];if(i===void 0)return;if(typeof i!=="boolean"){r.push(`${t}: ${n} must be true or false \u2014 ignored`);return}return i}function ac(e,n,t){if(e===void 0)return $n;if(!le(e))return t.push(`${n}: filesystem must be an object \u2014 ignored`),$n;return Oe(e,`${n} filesystem`,["read","write","allow","unix_socket_dir_bind"],t),{read:dn(e,"read",n,t),write:dn(e,"write",n,t),allow:dn(e,"allow",n,t),unixSocketDirBind:dn(e,"unix_socket_dir_bind",n,t)}}function dn(e,n,t,r){let i=e[n];if(i===void 0)return[];if(!ze(i))return r.push(`${t}: ${n} must be an array of strings \u2014 ignored`),[];let s=i.filter((o)=>!cn(o));if(s.length>0)r.push(`${t}: ${n} entries must be absolute, ~/, or $HOME/ paths \u2014 ignored: ${s.join(", ")}`);return i.filter(cn)}async function Qt(e){let n=yn(await uc(e),e);if(!le(n))throw Error(`${e} must be a JSON object`);return n}async function uc(e){let n;try{n=await Ae(e)}catch(t){throw Error(`${e} could not be read: ${Se(t)}`,{cause:t})}if(n===void 0)throw Error(`${e} could not be read \u2014 broken symlink?`);return n}function Xt(e,n,t,r){let i=e[n];if(i===void 0)return;if(typeof i!=="string"){r.push(`${t}: ${n} must be a string \u2014 ignored`);return}return i}function lc(e,n,t){let r=e.defaultThinkingLevel;if(r===void 0)return;if(typeof r!=="string"||!Bs.includes(r)){t.push(`${n}: defaultThinkingLevel must be one of ${Bs.join(", ")} \u2014 ignored`);return}return r}import{exists as cc,readdir as dc}from"fs/promises";import{basename as fc,extname as hc,join as Is,resolve as Dc}from"path";var gc=["name","description","cron","cwd"],Ns=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function ct(e){let n=await cc(Is(e,"schedules"))?" \u2014 found schedules/, rename it to schedule/ (singular)":"";return Error(`No schedule/ directory in ${e}${n}`)}async function dt(e,n){let t=await dc(e,{withFileTypes:!0}),r=[];return{schedules:[...(await Promise.all(t.map((o)=>pc(e,o,n,r)))).filter((o)=>o!==null)].sort((o,u)=>o.slug.localeCompare(u.slug)),warnings:r}}async function pc(e,n,t,r){let i=Is(e,n.name);if(n.isDirectory())return r.push(`${i}: subdirectories are not supported in schedule/ \u2014 ignored`),null;if(!n.isFile()&&!n.isSymbolicLink())return r.push(`${i}: only files are read from schedule/ \u2014 ignored`),null;if(hc(n.name)!==".md")return r.push(`${i}: only .md files are read from schedule/ \u2014 ignored`),null;return mc(i,t,r)}async function mc(e,n,t){let r=fc(e,".md");if(!Ns.test(r))return t.push(`${e}: filename must match ${Ns.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 t.push(`${e}: could not be read \u2014 broken symlink? \u2014 ignored`),null;let s=Fc(i);if(s===null)return t.push(`${e}: missing YAML frontmatter block (a file starting with "---" and a closing "---") \u2014 ignored`),null;let o=yc(s.frontmatter,e,t);if(o===null)return null;return bc({slug:r,path:e,frontmatter:o,body:s.body,home:n,warnings:t})}function Fc(e){let n=e.split(`
|
|
112
|
+
`).map((r)=>r.replace(/\r$/,""));if(n[0]!=="---")return null;let t=n.indexOf("---",1);if(t===-1)return null;return{frontmatter:n.slice(1,t).join(`
|
|
113
|
+
`),body:n.slice(t+1).join(`
|
|
114
|
+
`)}}function yc(e,n,t){let r;try{r=Bun.YAML.parse(e)}catch(i){return t.push(`${n}: frontmatter is not valid YAML: ${Se(i)} \u2014 ignored`),null}if(typeof r!=="object"||r===null||Array.isArray(r))return t.push(`${n}: frontmatter must be a YAML mapping \u2014 ignored`),null;return r}function bc(e){let{slug:n,path:t,frontmatter:r,body:i,home:s,warnings:o}=e;Ec(r,t,o);let u=Cc(r,t,o),c=wc(r,t,s,o),p=Rs(r,"name",t,o),b=Rs(r,"description",t,o),g=i.trim();if(u===null||c===null)return null;if(g==="")return o.push(`${t}: body is empty \u2014 a schedule with no prompt does nothing \u2014 ignored`),null;return{slug:n,name:p??n,path:t,cron:u,cwd:c,...b!==void 0?{description:b}:{},prompt:g}}function Ec(e,n,t){let r=Object.keys(e).filter((i)=>!gc.includes(i));if(r.length>0)t.push(`${n}: unsupported keys ignored: ${r.join(", ")}`)}function Cc(e,n,t){let r=e.cron;if(typeof r!=="string"||r.trim()==="")return t.push(`${n}: cron must be a non-empty string \u2014 ignored`),null;return r}function wc(e,n,t,r){let i=e.cwd;if(typeof i!=="string"||!cn(i))return r.push(`${n}: cwd must be an absolute, ~/, or $HOME/ path${xc(i)} \u2014 ignored`),null;return Dc(ln(i,t))}function xc(e){return e===null?' (a bare "~" is YAML null \u2014 quote it as "~" or write ~/some/dir)':""}function Rs(e,n,t,r){let i=e[n];if(i===void 0)return;if(typeof i!=="string"){r.push(`${t}: ${n} must be a string \u2014 ignored`);return}return i}import{createHash as Sc}from"crypto";import{homedir as Ac}from"os";import{basename as Pc,join as vn}from"path";function er(e){let n=Pc(e).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),t=Sc("sha256").update(e).digest("hex").slice(0,8);return`${n===""?"agent":n}-${t}`}function ft(e,n=Ac(),t=process.env.CRADLE_STATE_DIR){let r=t||vn(n,".cradle");return vn(r,"agents",er(e))}function Ts(e){return{extensionsDir:vn(e,"extensions"),sessionsDir:vn(e,"sessions"),miseCacheDir:vn(e,"mise-cache")}}import{readFile as _c}from"fs/promises";import{join as Ls,resolve as Ws}from"path";var Hs="gitdir:";async function Vs(e){try{return await _c(e,"utf8")}catch{return}}async function zs(e){let n=await Vs(Ls(e,".git"));if(n===void 0||!n.startsWith(Hs))return;let t=Ws(e,n.slice(Hs.length).trim()),r=await Vs(Ls(t,"commondir")),i=r!==void 0?Ws(t,r.trim()):t;return nt(e,i)?void 0:i}async function Js(e,n={}){let t=n.home??Oc(),r=n.cwd??process.cwd(),{dir:i,warnings:s}=await it(e.dir,{home:t,cwd:r}),o=await at(i),u=await jc(e,o,t,r),c=ft(o.dir,t),{extensionsDir:p,sessionsDir:b,miseCacheDir:g}=Ts(c),D=Ic(e,o),F=e.dryRun??!1,y=Zc(D.backend,F,n.which),h=Nc({folder:o,flags:e,passthrough:u.passthrough,backend:D.backend,bins:y,stateDir:c,extensionsDir:p,sessionsDir:b,miseCacheDir:g}),v=await Qc(D,o,{home:t,cwd:u.cwd,stateDir:c,profilePath:h.profilePath,sbxBin:y.sbxBin,hostPiBin:y.piBin,tty:n.tty??!1}),W=Rc(o,c);return{files:td(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 jc(e,n,t,r){let i={cwd:r,passthrough:e.passthrough??[],warnings:[]};if(e.schedule===void 0)return i;if(n.scheduleDir===null)throw await ct(n.dir);let{schedules:s,warnings:o}=await dt(n.scheduleDir,t),u=s.find((c)=>c.slug===e.schedule);if(u===void 0)throw Error(Mc(e.schedule,s));return{cwd:u.cwd,passthrough:[...i.passthrough,"--print","--name",u.name,"--no-approve","--",u.prompt],warnings:[...o,...await kc(u)]}}async function kc(e){if(await Us(e.cwd))return[];return[`schedule "${e.slug}" cwd does not exist: ${e.cwd}`]}function Mc(e,n){let t=n.length>0?` (available: ${n.map((r)=>r.slug).join(", ")})`:" (schedule/ is empty)";return`Unknown schedule "${e}"${t}`}function Nc(e){let{folder:n,flags:t,passthrough:r,backend:i,bins:s,stateDir:o,extensionsDir:u,sessionsDir:c,miseCacheDir:p}=e;return{folder:n,stateDir:o,extensionsDir:u,sessionsDir:c,miseCacheDir:p,backend:i,passthrough:r,nonoBin:s.nonoBin,piBin:i==="sbx"?"pi":s.piBin,profilePath:jn(o,qi),...t.verbose?{verbose:!0}:{}}}function Rc(e,n){let t=e.settings.packages;if(t===void 0||t.length===0)return null;return{npmDir:jn(n,"npm"),manifest:Ss(t),specs:t,installCommand:[...e.settings.npmCommand??["npm"],"install","--ignore-scripts"]}}function Ic(e,n){let{backend:t,warnings:r}=zc(e,n),i=[],s=Tc(e,n,t,i);return{backend:t,network:s,warnings:Hc(t!==null,s,[...r,...i])}}function Tc(e,n,t,r){if(e.offline)return{block:!0};let i=Lc(e.allowHost??[],r);if(i.length>0)return{allowDomain:i};return t==="sbx"?n.sbx.network:n.sandbox.network}function Lc(e,n){let t=e.map((r)=>r.trim()).filter((r)=>r!=="");if(t.length!==e.length)n.push("--allow-host entries must be non-empty \u2014 blanks ignored");return t}function Wc(e){return e!==void 0&&(e.block===!0||(e.allowDomain?.length??0)>0)}function Hc(e,n,t){if(e||!Wc(n))return t;return[...t,"network policy has no effect without the sandbox \u2014 pi runs with no network isolation (--sandbox to enforce it)"]}function Vc(e){return e.offline===!0||(e.allowHost?.length??0)>0}function zc(e,n){if(e.noSandbox===!0)return{backend:null,warnings:n.warnings};if(e.sandboxBackend!==void 0)return{backend:e.sandboxBackend,warnings:n.warnings};let t=Gc(n);if(e.noSandbox===!1||t.backend!==null)return{...t,backend:t.backend??"nono"};return Uc(e,n,t.warnings)}function Gc(e){let n=e.sandbox.posture==="enabled",t=e.sbx.posture==="enabled";if(n&&t)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:n?"nono":t?"sbx":null,warnings:e.warnings}}function Uc(e,n,t){let r=Yc(n);if(Vc(e))return{backend:"nono",warnings:[...t,`${r} \u2014 sandbox forced on to enforce the requested network policy (--no-sandbox to override)`]};return{backend:null,warnings:[...t,`${r} \u2014 agent is running without OS isolation (--sandbox to force enable)`]}}function Yc(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 Ks(e,n={}){let t={dryRun:!1,results:[],failures:[]};if(await ns(t,"extensions",e.extensionsDir,e.files),t.failures.length>0)throw Error(`Failed to write agent extensions: ${t.failures.join("; ")}`);if(await nr(e.sessionsDir,{recursive:!0}),e.profile!==null)await nr(vc(e.profile.path),{recursive:!0}),await Ys(e.profile.path,e.profile.content,"utf8");if(e.sbx!==null)await Jc(e.sbx,n);let r={...e.launch,extensionsDir:e.extensionsDir,sessionsDir:e.sessionsDir},i=e.packages===null?{argv:mn(r),warnings:[]}:await Xc(e.packages,r,n);if(e.sbx===null)return i;return{argv:st(e.sbx.spec,i.argv),warnings:i.warnings}}async function Jc(e,n){let t=n.run;if(t===void 0)throw Error("An sbx-backend run needs a command runner but none was provided");let r=await t(e.createArgv);if(r.exitCode!==0&&!gs(r.stderr))throw Error(`Failed to create sbx sandbox ${e.spec.name}: ${r.stderr.trim()}`);for(let i of e.policyArgvs)await Gs(t,i,`apply sbx network policy (${e.spec.name})`);await Gs(t,await Kc(e,n),`provision pi in sbx sandbox ${e.spec.name}`)}async function Gs(e,n,t){let r=await e(n);if(r.exitCode!==0)throw Error(`Failed to ${t}: ${r.stderr.trim()}`)}async function Kc(e,n){if(n.readPiVersion===void 0)return e.provisionArgv;let t=await n.readPiVersion(e.hostPiBin);return Ut({...e.spec,piVersion:t})}async function qc(e,n){if(await Ae(jn(e,"package.json"))!==n)return!1;return Us(jn(e,"node_modules"))}async function Xc(e,n,t){if(await nr(e.npmDir,{recursive:!0}),!await qc(e.npmDir,e.manifest)){if(t.install===void 0)throw Error("Packages declared but no installer provided");let s=jn(e.npmDir,"package.json");await Ys(s,e.manifest,"utf8");try{await t.install(e.installCommand,e.npmDir)}catch(o){throw await Bc(s,{force:!0}),o}}let{entries:r,warnings:i}=await As(e.npmDir,e.specs);return{argv:mn({...n,packageEntries:r}),warnings:i}}function Zc(e,n,t){if(n)return{nonoBin:"nono",piBin:"pi",sbxBin:"sbx"};return{nonoBin:e==="nono"?Fn("nono",t):"nono",sbxBin:e==="sbx"?Fn("sbx",t):"sbx",piBin:Fn("pi",t)}}async function Qc(e,n,t){let r=e.backend!==null?await zs(t.cwd):void 0,i=nd(e.backend==="nono",n,e.network,{home:t.home,cwd:t.cwd,stateDir:t.stateDir,profilePath:t.profilePath,...r!==void 0?{linkedGitDir:r}:{}});if(e.backend!=="sbx")return{profile:i,sbx:null,warnings:[]};let s=ed(e.network,n,{...t,...r!==void 0?{linkedGitDir:r}:{}});return{profile:i,sbx:s,warnings:[...hs(e.network),...Ds(n.sbx.filesystem)]}}function ed(e,n,t){let r=ls({cwd:t.cwd,agentDir:n.dir,stateDir:t.stateDir,home:t.home,grants:n.sbx.filesystem,...t.linkedGitDir!==void 0?{linkedGitDir:t.linkedGitDir}:{}}),i={sbxBin:t.sbxBin,name:cs($c(t.stateDir),r),cwd:t.cwd,home:t.home,mounts:r,...e!==void 0?{network:e}:{},piVersion:null,tty:t.tty};return{spec:i,hostPiBin:t.hostPiBin,createArgv:ds(i),policyArgvs:fs(i),provisionArgv:Ut(i)}}function nd(e,n,t,r){if(!e)return null;let i=Xi(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=Zi({home:r.home,cwd:r.cwd,agentDir:n.dir,stateDir:r.stateDir,grants:n.sandbox.filesystem,rules:n.sandbox.unsafeMacosSeatbeltRules,...t!==void 0?{network:t}:{},...r.linkedGitDir!==void 0?{linkedGitDir:r.linkedGitDir}:{}});return{path:r.profilePath,content:s}}function td(e,n){return[...e.providersJson!==null?[{rel:"providers.ts",content:ms(e.providersJson,{rewriteLocalhostBaseUrls:n==="sbx"})}]:[],...n==="nono"?[{rel:Qn,content:zi()}]:[]]}import{exists as Td,mkdir as co,rm as Ld,writeFile as Wd}from"fs/promises";import{homedir as Hd,userInfo as Vd}from"os";import{dirname as fo,join as zd}from"path";var rd={jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},id={sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6};function sd(e){return e===7?0:e}var Zs={name:"minute",min:0,max:59,canonicalMax:59},Qs={name:"hour",min:0,max:23,canonicalMax:23},eo={name:"day-of-month",min:1,max:31,canonicalMax:31},no={name:"month",min:1,max:12,canonicalMax:12,names:rd},to={name:"day-of-week",min:0,max:7,canonicalMax:6,names:id,normalize:sd},od={"@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,n){return Error(`Invalid cron expression "${e}": ${n}`)}function ad(e){let n=e.trim();if(!n.startsWith("@"))return n;let t=od[n.toLowerCase()];if(t===void 0)throw $e(e,`unknown macro "${n}"`);return t}var qs=[Zs,Qs,eo,no,to];function ud(e,n){let t=e.split(/\s+/).filter((r)=>r.length>0);if(t.length!==qs.length)throw $e(n,`expected ${String(qs.length)} space-separated fields, got ${String(t.length)}`);return t}function Xs(e,n){return Array.from({length:n-e+1},(t,r)=>e+r)}function tr(e,n,t){let i=n.names?.[e.toLowerCase()]??(/^\d+$/.test(e)?Number(e):Number.NaN);if(!Number.isInteger(i)||i<n.min||i>n.max)throw $e(t,`${n.name} field: token "${e}" is out of range (${String(n.min)}-${String(n.max)})`);return i}function ld(e,n,t){if(e==="*")return Xs(n.min,n.max);let r=e.split("-");if(r.length===1)return[tr(e,n,t)];if(r.length!==2)throw $e(t,`${n.name} field: could not parse token "${e}"`);let[i,s]=r,o=tr(i??"",n,t),u=tr(s??"",n,t);if(o>u)throw $e(t,`${n.name} field: reversed range "${e}" (start greater than end)`);return Xs(o,u)}function cd(e,n,t){if(e===void 0)return 1;let r=/^\d+$/.test(e)?Number(e):Number.NaN;if(!Number.isInteger(r)||r<1)throw $e(t,`${n.name} field: step must be a positive integer, got "${e}"`);return r}function dd(e,n,t){let r=e.split("/");if(r.length>2)throw $e(t,`${n.name} field: could not parse token "${e}"`);let[i,s]=r;if(s!==void 0&&i!=="*"&&!i?.includes("-"))throw $e(t,`${n.name} field: a step is only valid with "*" or a range, not "${e}"`);let o=ld(i??"",n,t),u=cd(s,n,t);return o.filter((c,p)=>p%u===0)}function fd(e,n){let t=n.normalize?e.map(n.normalize):e,r=Array.from(new Set(t)).sort((s,o)=>s-o),i=n.canonicalMax-n.min+1;return r.length===i?null:r}function hd(e,n,t){if(e.length===0)throw $e(t,`${n.name} field: empty token`);let r=e.split(",").flatMap((i)=>dd(i,n,t));return fd(r,n)}function rr(e){let n=ud(ad(e),e),t=(s,o)=>hd(n[s]??"",o,e),r=t(2,eo),i=t(4,to);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:t(0,Zs),hour:t(1,Qs),dayOfMonth:r,month:t(3,no),dayOfWeek:i}}function kn(e,n){return e===null||e.includes(n)}function Dd(e,n){return kn(e.month,n.getMonth()+1)&&kn(e.dayOfMonth,n.getDate())&&kn(e.dayOfWeek,n.getDay())}function gd(e,n){return kn(e.hour,n.getHours())}function pd(e,n){return kn(e.minute,n.getMinutes())}function md(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes()+1)}function Fd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+1)}function yd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours()+1)}function bd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes()+1)}function ro(e,n){let t=new Date(n.getFullYear(),n.getMonth(),n.getDate()+366,n.getHours(),n.getMinutes()),r=md(n);while(r.getTime()<=t.getTime()){if(!Dd(e,r)){r=Fd(r);continue}if(!gd(e,r)){r=yd(r);continue}if(pd(e,r))return r;r=bd(r)}return null}import{join as ir}from"path";var io=500;class so extends Error{constructor(e){super(`cron expression expands to ${String(e)} StartCalendarInterval dicts, over the ${String(io)}-dict cap`);this.name="LaunchdIntervalOverflowError"}}function Ed(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 Cd(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((t)=>t.field!==null).map((t)=>({key:t.key,values:t.field}))}function wd(e){let n=Cd(e);if(n.length===0)return Array.from({length:60},(r,i)=>({Minute:i}));let t=n.reduce((r,i)=>r.flatMap((s)=>i.values.map((o)=>({...s,[i.key]:o}))),[{}]);if(t.length>io)throw new so(t.length);return t}function xd(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function En(e){return`<string>${xd(e)}</string>`}function Sd(e,n){let t=e.map((r)=>`${n} ${En(r)}`).join(`
|
|
115
|
+
`);return`${n}<array>
|
|
116
|
+
${t}
|
|
117
|
+
${n}</array>`}function Ad(e,n){let t=Object.entries(e).map(([r,i])=>`${n} <key>${r}</key>
|
|
118
|
+
${n} <integer>${String(i)}</integer>`).join(`
|
|
119
|
+
`);return`${n}<dict>
|
|
120
|
+
${t}
|
|
121
|
+
${n}</dict>`}function Pd(e,n){let t=e.map((r)=>Ad(r,`${n} `)).join(`
|
|
122
|
+
`);return`${n}<array>
|
|
123
|
+
${t}
|
|
124
|
+
${n}</array>`}function _d(e,n,t){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>",Sd(c," ")," <key>WorkingDirectory</key>",` ${En(r.cwd)}`," <key>StartCalendarInterval</key>",Pd(t," ")," <key>StandardOutPath</key>",` ${En(o)}`," <key>StandardErrorPath</key>",` ${En(o)}`," <key>EnvironmentVariables</key>"," <dict>"," <key>PATH</key>",` ${En(Ed(u))}`," </dict>"," <key>RunAtLoad</key>"," <false/>"," <key>ProcessType</key>"," <string>Background</string>"," <key>Label</key>",` ${En(n)}`,"</dict>","</plist>",""].join(`
|
|
125
|
+
`)}function Bd(e){return`gui/${String(e)}`}function oo(e,n){let t=`com.cradle.${e.agentId}.${e.schedule.slug}`,r=ir(e.home,"Library","LaunchAgents",`${t}.plist`),i=wd(n),s=_d(e,t,i),o=Bd(e.uid),u=`${o}/${t}`;return{id:t,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 Mn}from"path";class ao 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 ao(e);return e.replaceAll("%","%%")}function Od(e){return`"${e.replaceAll("\\","\\\\").replaceAll('"',"\\\"")}"`}function $d(e){return String(e).padStart(2,"0")}function ht(e){return e===null?"*":e.map($d).join(",")}var vd=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function jd(e){let n=vd[e];if(n===void 0)throw Error(`Day-of-week value out of range: ${String(e)}`);return n}function kd(e){return e===null?void 0:e.map(jd).join(",")}function Md(e){let n=kd(e.dayOfWeek),t=`*-${ht(e.month)}-${ht(e.dayOfMonth)}`,r=`${ht(e.hour)}:${ht(e.minute)}:00`;return n===void 0?`${t} ${r}`:`${n} ${t} ${r}`}function Nd(e){return[Mn(e,".local","bin"),Mn(e,".local","share","mise","shims"),"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"].join(":")}function Rd(e){let n=Ue(e.schedule.name),t=Ue(e.schedule.cwd),r=Ue(e.cradleBin),i=Ue(e.agentDir),s=Ue(e.schedule.slug),o=Ue(e.logPath);return["[Unit]",`Description=${n}`,"","[Service]","Type=oneshot",`WorkingDirectory=${t}`,`Environment=PATH=${Ue(Nd(e.home))}`,`ExecStart=${[r,"schedule","run",i,s].map(Od).join(" ")}`,`StandardOutput=append:${o}`,`StandardError=append:${o}`,""].join(`
|
|
127
|
+
`)}function Id(e,n){let t=Ue(e.schedule.name),r=Md(n);return["[Unit]",`Description=${t}`,"","[Timer]",`OnCalendar=${r}`,"Persistent=true","","[Install]","WantedBy=timers.target",""].join(`
|
|
128
|
+
`)}function uo(e,n){let t=`cradle-${e.agentId}-${e.schedule.slug}`,r=Mn(e.home,".config","systemd","user"),i=Mn(r,`${t}.service`),s=Mn(r,`${t}.timer`),o=`${t}.timer`;return{id:t,files:[{path:i,content:Rd(e)},{path:s,content:Id(e,n)}],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 lo(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 Gd(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 Ud(e,n,t){let{dir:r,warnings:i}=await it(e.dir,{home:n,cwd:t}),s=await at(r);if(s.scheduleDir===null)throw await ct(s.dir);let{schedules:o,warnings:u}=await dt(s.scheduleDir,n);return{folder:s,schedules:o,warnings:[...i,...u],stateDir:ft(s.dir,n)}}function Yd(e,n){return(t)=>({schedule:t,agentId:er(e.folder.dir),agentDir:e.folder.dir,cradleBin:n.cradleBin,logPath:zd(e.stateDir,"schedule",`${t.slug}.log`),home:n.home,uid:n.uid})}async function ho(e,n={}){let t=Jd(e,n),r=await Ud(e,t.home,t.cwd),i=qd(e,t.dryRun)?Fn("cradle",n.which):"cradle",s=Yd(r,{cradleBin:i,home:t.home,uid:t.uid}),o={flags:e,base:r,contextFor:s,platform:t.platform,deps:n,dryRun:t.dryRun};return e.action==="list"?Xd(o):Zd(o)}function Jd(e,n){let t=n.platform??process.platform;return Gd(t),{home:n.home??Hd(),cwd:n.cwd??process.cwd(),platform:t,uid:n.uid??Kd(),dryRun:e.dryRun??!1}}function Kd(){return process.getuid?.()??0}function qd(e,n){return e.action==="install"&&!n}async function Xd(e){let n=e.deps.now??(()=>new Date),t=await Promise.all(e.base.schedules.map((r)=>tf(r,e.contextFor(r),e.platform,n)));return{action:"list",folder:e.base.folder,platform:e.platform,rows:t,targets:[],warnings:e.base.warnings,dryRun:e.dryRun,lingerCheckArgv:null}}function Zd(e){let n=Qd(e.base.schedules,e.flags).map((r)=>nf(r,e.contextFor(r),e.platform)),t=e.flags.action==="install"&&e.platform==="linux"?lo(e.deps.user??Vd().username):null;return{action:e.flags.action,folder:e.base.folder,platform:e.platform,rows:[],targets:n,warnings:e.base.warnings,dryRun:e.dryRun,lingerCheckArgv:t}}function Qd(e,n){if(n.slug===void 0)return e;let t=e.find((r)=>r.slug===n.slug);if(t===void 0)throw Error(ef(n.slug,e));return[t]}function ef(e,n){let t=n.length>0?` (available: ${n.map((r)=>r.slug).join(", ")})`:" (schedule/ is empty)";return`Unknown schedule "${e}"${t}`}function nf(e,n,t){return{schedule:e,timerPlan:Do(n,t,rr(e.cron)),logPath:n.logPath}}function Do(e,n,t){return n==="darwin"?oo(e,t):uo(e,t)}async function tf(e,n,t,r){let i={slug:e.slug,name:e.name,cron:e.cron,cwd:e.cwd};try{let s=rr(e.cron),o=Do(n,t,s);return{...i,nextFire:ro(s,r()),installed:await rf(o.files)}}catch(s){return{...i,cronError:Se(s),nextFire:null,installed:!1}}}async function rf(e){return(await Promise.all(e.map((t)=>Td(t.path)))).every(Boolean)}function go(e){if(e.length===0)return"No schedules found.";return e.map(sf).join(`
|
|
129
|
+
|
|
130
|
+
`)}function sf(e){let n=e.installed?"installed":"not installed",t=e.cronError!==void 0?`INVALID: ${e.cronError}`:`next: ${of(e.nextFire)}`;return[`${e.slug} \u2014 ${e.name}`,` cron: ${e.cron} (${t})`,` cwd: ${e.cwd}`,` timer: ${n}`].join(`
|
|
131
|
+
`)}function of(e){return e===null?"never (cannot fire within the next year)":e.toLocaleString()}async function po(e,n={}){if(e.dryRun)throw Error("Cannot materialize a --dry-run schedule plan; it is a preview only");if(e.action==="remove")return{warnings:await lf(e,n)};if(e.action==="install")return{warnings:await af(e,n)};return{warnings:[]}}async function af(e,n){let t=mo(n),r=await uf(e.lingerCheckArgv,t);for(let i of e.targets)await cf(i.timerPlan.files),await co(fo(i.logPath),{recursive:!0}),await Fo(t,i.timerPlan.installSteps,`install schedule "${i.schedule.slug}"`);return r}async function uf(e,n){if(e===null)return[];try{return(await n(e)).stdout.includes("Linger=yes")?[]:[sr]}catch{return[sr]}}async function lf(e,n){let t=mo(n);for(let r of e.targets)await Fo(t,r.timerPlan.removeSteps,`remove schedule "${r.schedule.slug}"`),await Promise.all(r.timerPlan.files.map((i)=>Ld(i.path,{force:!0})));return[]}async function cf(e){for(let n of e)await co(fo(n.path),{recursive:!0}),await Wd(n.path,n.content,"utf8")}function mo(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 Fo(e,n,t){for(let r of n){let i=await e(r.argv);if(i.exitCode!==0&&r.ignoreFailure!==!0)throw Error(`Failed to ${t} (${r.argv.join(" ")}): ${i.stderr.trim()}`)}}function yo(e,n){return n?`\x1B[33m${e}\x1B[0m`:e}function bo(e,n){return()=>{e.kill(n)}}async function Eo(e,n={},t){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,...n},...t!==void 0?{cwd:t}:{}}),o=bo(s,"SIGINT"),u=bo(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 Co(e){let[n,...t]=e;if(!n)throw Error("Command requires at least one argument");let r=Bun.spawn([n,...t],{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 wo(e){let[n,...t]=e;if(!n)throw Error("Command requires at least one argument");let r=Bun.spawn([n,...t],{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 xo(e,n){let[t,...r]=e;if(!t)throw Error("Command requires at least one argument");let s=await Bun.spawn([t,...r],{cwd:n,stdin:"ignore",stdout:"inherit",stderr:"inherit",env:process.env}).exited;if(s!==0)throw Error(`Package install failed (${e.join(" ")} exited ${String(s)})`)}var Cn=Hi(process.argv.slice(2)).scriptName("cradle").version(Vi.version).usage("$0 <cmd> [args]").parserConfiguration({"populate--":!0,"parse-numbers":!1,"parse-positional-numbers":!1}).strict();Cn.command("$0","show help",()=>{},async()=>{console.log(await Cn.getHelp())});Cn.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 n=(e["--"]??[]).map(String),t=(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}:{},...t.length?{allowHost:t}:{},...e.verbose?{verbose:!0}:{},...n.length?{passthrough:n}:{}};await Ao(r)});Cn.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){or(Error("A task slug is required: cradle schedule run <dir> <task>"));return}await Ao({dir:e.dir,schedule:e.task});return}await df({dir:e.dir,action:e.action,...e.task!==void 0?{slug:e.task}:{},...e.dryRun?{dryRun:!0}:{}})});Cn.command("doctor","check pi / nono / mise on PATH",()=>{},async()=>{let e=await Yi({readVersion:Po});console.log(Ji(e)),process.exitCode=Ki(e)});async function Ao(e){try{let n=await Js(e,{tty:process.stdout.isTTY});if(Dt(n.warnings),n.dryRun){hf(n);return}let t=await Ks(n,{install:xo,run:Co,readPiVersion:Po});if(Dt(t.warnings),n.profile!==null&&!e.verbose)console.log("\uD83D\uDD12 Sandbox Active");if(n.sbx!==null&&!e.verbose)console.log("\uD83D\uDD12 Sandbox Active (sbx)");process.exit(await Eo(t.argv,zt(n.launch),n.cwd))}catch(n){or(n)}}async function df(e){try{let n=await ho(e);if(Dt(n.warnings),n.action==="list"){console.log(go(n.rows));return}if(n.dryRun){ff(n);return}let t=await po(n,{run:wo});Dt(t.warnings)}catch(n){or(n)}}function ff(e){for(let n of e.targets){if(e.action==="install"){for(let t of n.timerPlan.files)console.log(`write: ${t.path}`);for(let t of n.timerPlan.installSteps)console.log(`install: ${t.argv.map(Ve).join(" ")}`);continue}for(let t of n.timerPlan.removeSteps)console.log(`remove: ${t.argv.map(Ve).join(" ")}`);for(let t of n.timerPlan.files)console.log(`delete: ${t.path}`)}}function hf(e){for(let r of e.files)console.log(`write: ${So(e.extensionsDir,r.rel)}`);if(e.profile!==null)console.log(`write: ${e.profile.path}`);if(e.sbx!==null)Df(e.sbx);if(e.packages!==null)gf(e.packages);let n=Object.entries(zt(e.launch)).map(([r,i])=>`${r}=${Ve(i)}`),t=e.sbx!==null?st(e.sbx.spec,mn(e.launch)):mn(e.launch);console.log([...n,...t.map(Ve)].join(" "))}function Df(e){console.log(`create: ${e.createArgv.map(Ve).join(" ")}`);for(let n of e.policyArgvs)console.log(`policy: ${n.map(Ve).join(" ")}`);console.log(`provision: ${e.provisionArgv.map(Ve).join(" ")}`)}function gf(e){console.log(`write: ${So(e.npmDir,"package.json")}`);let n=e.specs.map((t)=>`${t.name}@${t.version}`).join(", ");console.log(`install: ${e.installCommand.join(" ")} (${e.npmDir}): ${n}`)}function Dt(e){let n=process.stderr.isTTY;for(let t of e)console.error(yo(`warning: ${t}`,n))}async function Po(e,n=["--version"]){try{let t=Bun.spawn([e,...n],{stdout:"pipe",stderr:"ignore"}),[r,i]=await Promise.all([new Response(t.stdout).text(),t.exited]);if(i!==0)return null;return r.split(`
|
|
132
|
+
`)[0]?.match(/v?\d+\.\d+\S*/)?.[0]??null}catch{return null}}function or(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}Cn.parse();
|