slack-term 1.26.0 → 1.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +62 -62
- package/package.json +2 -1
- package/ts/cli.ts +33 -16
package/dist/cli.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{createRequire as r3}from"node:module";var k3=Object.create;var{getPrototypeOf:i3,defineProperty:O2,getOwnPropertyNames:l3}=Object;var n3=Object.prototype.hasOwnProperty;function t3(D){return this[D]}var o3,s3,U2=(D,u,F)=>{var B=D!=null&&typeof D==="object";if(B){var E=u?o3??=new WeakMap:s3??=new WeakMap,C=E.get(D);if(C)return C}F=D!=null?k3(i3(D)):{};let $=u||!D||!D.__esModule?O2(F,"default",{value:D,enumerable:!0}):F;for(let z of l3(D))if(!n3.call($,z))O2($,z,{get:t3.bind(D,z),enumerable:!0});if(B)E.set(D,$);return $};var j2=(D,u)=>()=>(u||D((u={exports:{}}).exports,u),u.exports);var xD=r3(import.meta.url);var p2=j2((TE,y2)=>{y2.exports=()=>{return/[#*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 X8=j2((V4,G8)=>{G8.exports=function(u){if(u===void 0)u=2;if(u>=Error.stackTraceLimit)throw TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+u+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");var F=Error.prepareStackTrace;Error.prepareStackTrace=function(E,C){return C};var B=Error().stack;if(Error.prepareStackTrace=F,B!==null&&typeof B==="object")return B[u]?B[u].getFileName():void 0}});import{createHash as H9}from"crypto";import{existsSync as f3,readFileSync as q9,mkdirSync as K9,writeFileSync as h3}from"fs";import{homedir as x3}from"os";import{join as eD}from"path";import{notStrictEqual as h6,strictEqual as v6}from"assert";var a3={right:u6,center:F6};class _2{constructor(D){var u;this.width=D.width,this.wrap=(u=D.wrap)!==null&&u!==void 0?u:!0,this.rows=[]}span(...D){let u=this.div(...D);u.span=!0}resetOutput(){this.rows=[]}div(...D){if(D.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...D)&&typeof D[0]==="string")return this.applyLayoutDSL(D[0]);let u=D.map((F)=>{if(typeof F==="string")return this.colFromString(F);return F});return this.rows.push(u),u}shouldApplyLayoutDSL(...D){return D.length===1&&typeof D[0]==="string"&&/[\t\n]/.test(D[0])}applyLayoutDSL(D){let u=D.split(`
|
|
3
|
+
import{createRequire as r3}from"node:module";var k3=Object.create;var{getPrototypeOf:i3,defineProperty:K2,getOwnPropertyNames:l3}=Object;var n3=Object.prototype.hasOwnProperty;function t3(D){return this[D]}var o3,s3,O2=(D,u,F)=>{var B=D!=null&&typeof D==="object";if(B){var E=u?o3??=new WeakMap:s3??=new WeakMap,C=E.get(D);if(C)return C}F=D!=null?k3(i3(D)):{};let $=u||!D||!D.__esModule?K2(F,"default",{value:D,enumerable:!0}):F;for(let z of l3(D))if(!n3.call($,z))K2($,z,{get:t3.bind(D,z),enumerable:!0});if(B)E.set(D,$);return $};var U2=(D,u)=>()=>(u||D((u={exports:{}}).exports,u),u.exports);var xD=r3(import.meta.url);var y2=U2((TE,v2)=>{v2.exports=()=>{return/[#*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 G8=U2((V4,J8)=>{J8.exports=function(u){if(u===void 0)u=2;if(u>=Error.stackTraceLimit)throw TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+u+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");var F=Error.prepareStackTrace;Error.prepareStackTrace=function(E,C){return C};var B=Error().stack;if(Error.prepareStackTrace=F,B!==null&&typeof B==="object")return B[u]?B[u].getFileName():void 0}});import{createHash as H9}from"crypto";import{existsSync as f3,readFileSync as q9,mkdirSync as K9,writeFileSync as h3}from"fs";import{homedir as x3}from"os";import{join as eD}from"path";import{notStrictEqual as h6,strictEqual as v6}from"assert";var a3={right:u6,center:F6};class M2{constructor(D){var u;this.width=D.width,this.wrap=(u=D.wrap)!==null&&u!==void 0?u:!0,this.rows=[]}span(...D){let u=this.div(...D);u.span=!0}resetOutput(){this.rows=[]}div(...D){if(D.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...D)&&typeof D[0]==="string")return this.applyLayoutDSL(D[0]);let u=D.map((F)=>{if(typeof F==="string")return this.colFromString(F);return F});return this.rows.push(u),u}shouldApplyLayoutDSL(...D){return D.length===1&&typeof D[0]==="string"&&/[\t\n]/.test(D[0])}applyLayoutDSL(D){let u=D.split(`
|
|
4
4
|
`).map((B)=>B.split("\t")),F=0;return u.forEach((B)=>{if(B.length>1&&OD.stringWidth(B[0])>F)F=Math.min(Math.floor(this.width*0.5),OD.stringWidth(B[0]))}),u.forEach((B)=>{this.div(...B.map((E,C)=>{return{text:E.trim(),padding:this.measurePadding(E),width:C===0&&B.length>1?F:void 0}}))}),this.rows[this.rows.length-1]}colFromString(D){return{text:D,padding:this.measurePadding(D)}}measurePadding(D){let u=OD.stripAnsi(D);return[0,u.match(/\s*$/)[0].length,0,u.match(/^\s*/)[0].length]}toString(){let D=[];return this.rows.forEach((u)=>{this.rowToString(u,D)}),D.filter((u)=>!u.hidden).map((u)=>u.text).join(`
|
|
5
|
-
`)}rowToString(D,u){return this.rasterize(D).forEach((F,B)=>{let E="";F.forEach((C,$)=>{let{width:z}=D[$],Z=this.negatePadding(D[$]),J=C;if(Z>OD.stringWidth(C))J+=" ".repeat(Z-OD.stringWidth(C));if(D[$].align&&D[$].align!=="left"&&this.wrap){let G=a3[D[$].align];if(J=G(J,Z),OD.stringWidth(J)<Z)J+=" ".repeat((z||0)-OD.stringWidth(J)-1)}let Q=D[$].padding||[0,0,0,0];if(Q[3])E+=" ".repeat(Q[3]);if(E+=
|
|
5
|
+
`)}rowToString(D,u){return this.rasterize(D).forEach((F,B)=>{let E="";F.forEach((C,$)=>{let{width:z}=D[$],Z=this.negatePadding(D[$]),J=C;if(Z>OD.stringWidth(C))J+=" ".repeat(Z-OD.stringWidth(C));if(D[$].align&&D[$].align!=="left"&&this.wrap){let G=a3[D[$].align];if(J=G(J,Z),OD.stringWidth(J)<Z)J+=" ".repeat((z||0)-OD.stringWidth(J)-1)}let Q=D[$].padding||[0,0,0,0];if(Q[3])E+=" ".repeat(Q[3]);if(E+=j2(D[$],J,"| "),E+=J,E+=j2(D[$],J," |"),Q[1])E+=" ".repeat(Q[1]);if(B===0&&u.length>0)E=this.renderInline(E,u[u.length-1])}),u.push({text:E.replace(/ +$/,""),span:D.span})}),u}renderInline(D,u){let F=D.match(/^ */),B=F?F[0].length:0,E=u.text,C=OD.stringWidth(E.trimRight());if(!u.span)return D;if(!this.wrap)return u.hidden=!0,E+D;if(B<C)return D;return u.hidden=!0,E.trimRight()+" ".repeat(B-C)+D.trimLeft()}rasterize(D){let u=[],F=this.columnWidths(D),B;return D.forEach((E,C)=>{if(E.width=F[C],this.wrap)B=OD.wrap(E.text,this.negatePadding(E),{hard:!0}).split(`
|
|
6
6
|
`);else B=E.text.split(`
|
|
7
|
-
`);if(E.border)B.unshift("."+"-".repeat(this.negatePadding(E)+2)+"."),B.push("'"+"-".repeat(this.negatePadding(E)+2)+"'");if(E.padding)B.unshift(...Array(E.padding[0]||0).fill("")),B.push(...Array(E.padding[2]||0).fill(""));B.forEach(($,z)=>{if(!u[z])u.push([]);let Z=u[z];for(let J=0;J<C;J++)if(Z[J]===void 0)Z.push("");Z.push($)})}),u}negatePadding(D){let u=D.width||0;if(D.padding)u-=(D.padding[3]||0)+(D.padding[1]||0);if(D.border)u-=4;return u}columnWidths(D){if(!this.wrap)return D.map((C)=>{return C.width||OD.stringWidth(C.text)});let u=D.length,F=this.width,B=D.map((C)=>{if(C.width)return u--,F-=C.width,C.width;return}),E=u?Math.floor(F/u):0;return B.map((C,$)=>{if(C===void 0)return Math.max(E,e3(D[$]));return C})}}function M2(D,u,F){if(D.border){if(/[.']-+[.']/.test(u))return"";if(u.trim().length!==0)return F;return" "}return""}function e3(D){let u=D.padding||[],F=1+(u[3]||0)+(u[1]||0);if(D.border)return F+4;return F}function D6(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function u6(D,u){D=D.trim();let F=OD.stringWidth(D);if(F<u)return" ".repeat(u-F)+D;return D}function F6(D,u){D=D.trim();let F=OD.stringWidth(D);if(F>=u)return D;return" ".repeat(u-F>>1)+D}var OD;function N2(D,u){return OD=u,new _2({width:(D===null||D===void 0?void 0:D.width)||D6(),wrap:D===null||D===void 0?void 0:D.wrap})}function iF({onlyFirst:D=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",D?void 0:"g")}var E6=iF();function uu(D){if(typeof D!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof D}\``);if(!D.includes("\x1B")&&!D.includes(""))return D;return D.replace(E6,"")}var A2=161,L2=1114109,T2=[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],R2=12288,P2=65510,S2=[12288,12288,65281,65376,65504,65510];var w2=4352,x2=262141,lF=[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 EF=(D,u)=>{let F=0,B=Math.floor(D.length/2)-1;while(F<=B){let E=Math.floor((F+B)/2),C=E*2;if(u<D[C])B=E-1;else if(u>D[C+1])F=E+1;else return!0}return!1};var I2=19968,[B6,C6]=$6(lF);function $6(D){let u=D[0],F=D[1];for(let B=0;B<D.length;B+=2){let E=D[B],C=D[B+1];if(I2>=E&&I2<=C)return[E,C];if(C-E>F-u)u=E,F=C}return[u,F]}var b2=(D)=>{if(D<A2||D>L2)return!1;return EF(T2,D)},f2=(D)=>{if(D<R2||D>P2)return!1;return EF(S2,D)};var h2=(D)=>{if(D>=B6&&D<=C6)return!0;if(D<w2||D>x2)return!1;return EF(lF,D)};function z6(D){if(!Number.isSafeInteger(D))throw TypeError(`Expected a code point, got \`${typeof D}\`.`)}function v2(D,{ambiguousAsWide:u=!1}={}){if(z6(D),f2(D)||h2(D)||u&&b2(D))return 2;return 1}var m2=U2(p2(),1),Z6=new Intl.Segmenter,J6=/^\p{Default_Ignorable_Code_Point}$/u;function RD(D,u={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:F=!0,countAnsiEscapeCodes:B=!1}=u;if(!B)D=uu(D);if(D.length===0)return 0;let E=0,C={ambiguousAsWide:!F};for(let{segment:$}of Z6.segment(D)){let z=$.codePointAt(0);if(z<=31||z>=127&&z<=159)continue;if(z>=8203&&z<=8207||z===65279)continue;if(z>=768&&z<=879||z>=6832&&z<=6911||z>=7616&&z<=7679||z>=8400&&z<=8447||z>=65056&&z<=65071)continue;if(z>=55296&&z<=57343)continue;if(z>=65024&&z<=65039)continue;if(J6.test($))continue;if(m2.default().test($)){E+=2;continue}E+=v2(z,C)}return E}var g2=(D=0)=>(u)=>`\x1B[${u+D}m`,c2=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,d2=(D=0)=>(u,F,B)=>`\x1B[${38+D};2;${u};${F};${B}m`,e={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]}},wE=Object.keys(e.modifier),G6=Object.keys(e.color),X6=Object.keys(e.bgColor),xE=[...G6,...X6];function Q6(){let D=new Map;for(let[u,F]of Object.entries(e)){for(let[B,E]of Object.entries(F))e[B]={open:`\x1B[${E[0]}m`,close:`\x1B[${E[1]}m`},F[B]=e[B],D.set(E[0],E[1]);Object.defineProperty(e,u,{value:F,enumerable:!1})}return Object.defineProperty(e,"codes",{value:D,enumerable:!1}),e.color.close="\x1B[39m",e.bgColor.close="\x1B[49m",e.color.ansi=g2(),e.color.ansi256=c2(),e.color.ansi16m=d2(),e.bgColor.ansi=g2(10),e.bgColor.ansi256=c2(10),e.bgColor.ansi16m=d2(10),Object.defineProperties(e,{rgbToAnsi256:{value(u,F,B){if(u===F&&F===B){if(u<8)return 16;if(u>248)return 231;return Math.round((u-8)/247*24)+232}return 16+36*Math.round(u/255*5)+6*Math.round(F/255*5)+Math.round(B/255*5)},enumerable:!1},hexToRgb:{value(u){let F=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!F)return[0,0,0];let[B]=F;if(B.length===3)B=[...B].map((C)=>C+C).join("");let E=Number.parseInt(B,16);return[E>>16&255,E>>8&255,E&255]},enumerable:!1},hexToAnsi256:{value:(u)=>e.rgbToAnsi256(...e.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value(u){if(u<8)return 30+u;if(u<16)return 90+(u-8);let F,B,E;if(u>=232)F=((u-232)*10+8)/255,B=F,E=F;else{u-=16;let z=u%36;F=Math.floor(u/36)/5,B=Math.floor(z/6)/5,E=z%6/5}let C=Math.max(F,B,E)*2;if(C===0)return 30;let $=30+(Math.round(E)<<2|Math.round(B)<<1|Math.round(F));if(C===2)$+=60;return $},enumerable:!1},rgbToAnsi:{value:(u,F,B)=>e.ansi256ToAnsi(e.rgbToAnsi256(u,F,B)),enumerable:!1},hexToAnsi:{value:(u)=>e.ansi256ToAnsi(e.hexToAnsi256(u)),enumerable:!1}}),e}var Y6=Q6(),k2=Y6;var CF=new Set(["\x1B",""]),W6=39,tF="\x07",n2="[",V6="]",t2="m",BF=`${V6}8;;`,i2=(D)=>`${CF.values().next().value}${n2}${D}${t2}`,l2=(D)=>`${CF.values().next().value}${BF}${D}${tF}`,H6=(D)=>D.split(" ").map((u)=>RD(u)),nF=(D,u,F)=>{let B=[...u],E=!1,C=!1,$=RD(uu(D.at(-1)));for(let[z,Z]of B.entries()){let J=RD(Z);if($+J<=F)D[D.length-1]+=Z;else D.push(Z),$=0;if(CF.has(Z))E=!0,C=B.slice(z+1,z+1+BF.length).join("")===BF;if(E){if(C){if(Z===tF)E=!1,C=!1}else if(Z===t2)E=!1;continue}if($+=J,$===F&&z<B.length-1)D.push(""),$=0}if(!$&&D.at(-1).length>0&&D.length>1)D[D.length-2]+=D.pop()},q6=(D)=>{let u=D.split(" "),F=u.length;while(F>0){if(RD(u[F-1])>0)break;F--}if(F===u.length)return D;return u.slice(0,F).join(" ")+u.slice(F).join("")},K6=(D,u,F={})=>{if(F.trim!==!1&&D.trim()==="")return"";let B="",E,C,$=H6(D),z=[""];for(let[G,Y]of D.split(" ").entries()){if(F.trim!==!1)z[z.length-1]=z.at(-1).trimStart();let V=RD(z.at(-1));if(G!==0){if(V>=u&&(F.wordWrap===!1||F.trim===!1))z.push(""),V=0;if(V>0||F.trim===!1)z[z.length-1]+=" ",V++}if(F.hard&&$[G]>u){let H=u-V,W=1+Math.floor(($[G]-H-1)/u);if(Math.floor(($[G]-1)/u)<W)z.push("");nF(z,Y,u);continue}if(V+$[G]>u&&V>0&&$[G]>0){if(F.wordWrap===!1&&V<u){nF(z,Y,u);continue}z.push("")}if(V+$[G]>u&&F.wordWrap===!1){nF(z,Y,u);continue}z[z.length-1]+=Y}if(F.trim!==!1)z=z.map((G)=>q6(G));let Z=z.join(`
|
|
8
|
-
`),J=[...Z],Q=0;for(let[G,Y]of J.entries()){if(B+=Y,CF.has(Y)){let{groups:H}=new RegExp(`(?:\\${
|
|
9
|
-
`){if(C)B+=
|
|
10
|
-
`){if(E&&V)B+=
|
|
7
|
+
`);if(E.border)B.unshift("."+"-".repeat(this.negatePadding(E)+2)+"."),B.push("'"+"-".repeat(this.negatePadding(E)+2)+"'");if(E.padding)B.unshift(...Array(E.padding[0]||0).fill("")),B.push(...Array(E.padding[2]||0).fill(""));B.forEach(($,z)=>{if(!u[z])u.push([]);let Z=u[z];for(let J=0;J<C;J++)if(Z[J]===void 0)Z.push("");Z.push($)})}),u}negatePadding(D){let u=D.width||0;if(D.padding)u-=(D.padding[3]||0)+(D.padding[1]||0);if(D.border)u-=4;return u}columnWidths(D){if(!this.wrap)return D.map((C)=>{return C.width||OD.stringWidth(C.text)});let u=D.length,F=this.width,B=D.map((C)=>{if(C.width)return u--,F-=C.width,C.width;return}),E=u?Math.floor(F/u):0;return B.map((C,$)=>{if(C===void 0)return Math.max(E,e3(D[$]));return C})}}function j2(D,u,F){if(D.border){if(/[.']-+[.']/.test(u))return"";if(u.trim().length!==0)return F;return" "}return""}function e3(D){let u=D.padding||[],F=1+(u[3]||0)+(u[1]||0);if(D.border)return F+4;return F}function D6(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function u6(D,u){D=D.trim();let F=OD.stringWidth(D);if(F<u)return" ".repeat(u-F)+D;return D}function F6(D,u){D=D.trim();let F=OD.stringWidth(D);if(F>=u)return D;return" ".repeat(u-F>>1)+D}var OD;function _2(D,u){return OD=u,new M2({width:(D===null||D===void 0?void 0:D.width)||D6(),wrap:D===null||D===void 0?void 0:D.wrap})}function lF({onlyFirst:D=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",D?void 0:"g")}var E6=lF();function uu(D){if(typeof D!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof D}\``);if(!D.includes("\x1B")&&!D.includes(""))return D;return D.replace(E6,"")}var N2=161,A2=1114109,L2=[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],T2=12288,R2=65510,P2=[12288,12288,65281,65376,65504,65510];var S2=4352,w2=262141,nF=[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 EF=(D,u)=>{let F=0,B=Math.floor(D.length/2)-1;while(F<=B){let E=Math.floor((F+B)/2),C=E*2;if(u<D[C])B=E-1;else if(u>D[C+1])F=E+1;else return!0}return!1};var x2=19968,[B6,C6]=$6(nF);function $6(D){let u=D[0],F=D[1];for(let B=0;B<D.length;B+=2){let E=D[B],C=D[B+1];if(x2>=E&&x2<=C)return[E,C];if(C-E>F-u)u=E,F=C}return[u,F]}var I2=(D)=>{if(D<N2||D>A2)return!1;return EF(L2,D)},b2=(D)=>{if(D<T2||D>R2)return!1;return EF(P2,D)};var f2=(D)=>{if(D>=B6&&D<=C6)return!0;if(D<S2||D>w2)return!1;return EF(nF,D)};function z6(D){if(!Number.isSafeInteger(D))throw TypeError(`Expected a code point, got \`${typeof D}\`.`)}function h2(D,{ambiguousAsWide:u=!1}={}){if(z6(D),b2(D)||f2(D)||u&&I2(D))return 2;return 1}var p2=O2(y2(),1),Z6=new Intl.Segmenter,J6=/^\p{Default_Ignorable_Code_Point}$/u;function RD(D,u={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:F=!0,countAnsiEscapeCodes:B=!1}=u;if(!B)D=uu(D);if(D.length===0)return 0;let E=0,C={ambiguousAsWide:!F};for(let{segment:$}of Z6.segment(D)){let z=$.codePointAt(0);if(z<=31||z>=127&&z<=159)continue;if(z>=8203&&z<=8207||z===65279)continue;if(z>=768&&z<=879||z>=6832&&z<=6911||z>=7616&&z<=7679||z>=8400&&z<=8447||z>=65056&&z<=65071)continue;if(z>=55296&&z<=57343)continue;if(z>=65024&&z<=65039)continue;if(J6.test($))continue;if(p2.default().test($)){E+=2;continue}E+=h2(z,C)}return E}var m2=(D=0)=>(u)=>`\x1B[${u+D}m`,g2=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,c2=(D=0)=>(u,F,B)=>`\x1B[${38+D};2;${u};${F};${B}m`,e={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]}},wE=Object.keys(e.modifier),G6=Object.keys(e.color),X6=Object.keys(e.bgColor),xE=[...G6,...X6];function Q6(){let D=new Map;for(let[u,F]of Object.entries(e)){for(let[B,E]of Object.entries(F))e[B]={open:`\x1B[${E[0]}m`,close:`\x1B[${E[1]}m`},F[B]=e[B],D.set(E[0],E[1]);Object.defineProperty(e,u,{value:F,enumerable:!1})}return Object.defineProperty(e,"codes",{value:D,enumerable:!1}),e.color.close="\x1B[39m",e.bgColor.close="\x1B[49m",e.color.ansi=m2(),e.color.ansi256=g2(),e.color.ansi16m=c2(),e.bgColor.ansi=m2(10),e.bgColor.ansi256=g2(10),e.bgColor.ansi16m=c2(10),Object.defineProperties(e,{rgbToAnsi256:{value(u,F,B){if(u===F&&F===B){if(u<8)return 16;if(u>248)return 231;return Math.round((u-8)/247*24)+232}return 16+36*Math.round(u/255*5)+6*Math.round(F/255*5)+Math.round(B/255*5)},enumerable:!1},hexToRgb:{value(u){let F=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!F)return[0,0,0];let[B]=F;if(B.length===3)B=[...B].map((C)=>C+C).join("");let E=Number.parseInt(B,16);return[E>>16&255,E>>8&255,E&255]},enumerable:!1},hexToAnsi256:{value:(u)=>e.rgbToAnsi256(...e.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value(u){if(u<8)return 30+u;if(u<16)return 90+(u-8);let F,B,E;if(u>=232)F=((u-232)*10+8)/255,B=F,E=F;else{u-=16;let z=u%36;F=Math.floor(u/36)/5,B=Math.floor(z/6)/5,E=z%6/5}let C=Math.max(F,B,E)*2;if(C===0)return 30;let $=30+(Math.round(E)<<2|Math.round(B)<<1|Math.round(F));if(C===2)$+=60;return $},enumerable:!1},rgbToAnsi:{value:(u,F,B)=>e.ansi256ToAnsi(e.rgbToAnsi256(u,F,B)),enumerable:!1},hexToAnsi:{value:(u)=>e.ansi256ToAnsi(e.hexToAnsi256(u)),enumerable:!1}}),e}var Y6=Q6(),d2=Y6;var CF=new Set(["\x1B",""]),W6=39,oF="\x07",l2="[",V6="]",n2="m",BF=`${V6}8;;`,k2=(D)=>`${CF.values().next().value}${l2}${D}${n2}`,i2=(D)=>`${CF.values().next().value}${BF}${D}${oF}`,H6=(D)=>D.split(" ").map((u)=>RD(u)),tF=(D,u,F)=>{let B=[...u],E=!1,C=!1,$=RD(uu(D.at(-1)));for(let[z,Z]of B.entries()){let J=RD(Z);if($+J<=F)D[D.length-1]+=Z;else D.push(Z),$=0;if(CF.has(Z))E=!0,C=B.slice(z+1,z+1+BF.length).join("")===BF;if(E){if(C){if(Z===oF)E=!1,C=!1}else if(Z===n2)E=!1;continue}if($+=J,$===F&&z<B.length-1)D.push(""),$=0}if(!$&&D.at(-1).length>0&&D.length>1)D[D.length-2]+=D.pop()},q6=(D)=>{let u=D.split(" "),F=u.length;while(F>0){if(RD(u[F-1])>0)break;F--}if(F===u.length)return D;return u.slice(0,F).join(" ")+u.slice(F).join("")},K6=(D,u,F={})=>{if(F.trim!==!1&&D.trim()==="")return"";let B="",E,C,$=H6(D),z=[""];for(let[G,Y]of D.split(" ").entries()){if(F.trim!==!1)z[z.length-1]=z.at(-1).trimStart();let V=RD(z.at(-1));if(G!==0){if(V>=u&&(F.wordWrap===!1||F.trim===!1))z.push(""),V=0;if(V>0||F.trim===!1)z[z.length-1]+=" ",V++}if(F.hard&&$[G]>u){let H=u-V,W=1+Math.floor(($[G]-H-1)/u);if(Math.floor(($[G]-1)/u)<W)z.push("");tF(z,Y,u);continue}if(V+$[G]>u&&V>0&&$[G]>0){if(F.wordWrap===!1&&V<u){tF(z,Y,u);continue}z.push("")}if(V+$[G]>u&&F.wordWrap===!1){tF(z,Y,u);continue}z[z.length-1]+=Y}if(F.trim!==!1)z=z.map((G)=>q6(G));let Z=z.join(`
|
|
8
|
+
`),J=[...Z],Q=0;for(let[G,Y]of J.entries()){if(B+=Y,CF.has(Y)){let{groups:H}=new RegExp(`(?:\\${l2}(?<code>\\d+)m|\\${BF}(?<uri>.*)${oF})`).exec(Z.slice(Q))||{groups:{}};if(H.code!==void 0){let W=Number.parseFloat(H.code);E=W===W6?void 0:W}else if(H.uri!==void 0)C=H.uri.length===0?void 0:H.uri}let V=d2.codes.get(Number(E));if(J[G+1]===`
|
|
9
|
+
`){if(C)B+=i2("");if(E&&V)B+=k2(V)}else if(Y===`
|
|
10
|
+
`){if(E&&V)B+=k2(E);if(C)B+=i2(C)}Q+=Y.length}return B};function sF(D,u,F){return String(D).normalize().replaceAll(`\r
|
|
11
11
|
`,`
|
|
12
12
|
`).split(`
|
|
13
13
|
`).map((B)=>K6(B,u,F)).join(`
|
|
14
|
-
`)}function sF(D){return N2(D,{stringWidth:RD,stripAnsi:uu,wrap:oF})}import{dirname as o2,resolve as s2}from"path";import{readdirSync as O6,statSync as U6}from"fs";function rF(D,u){let F=s2(".",D),B;if(!U6(F).isDirectory())F=o2(F);while(!0){if(B=u(F,O6(F)),B)return s2(F,B);if(F=o2(B=F),B===F)break}}import{inspect as y6}from"util";import{fileURLToPath as Y8}from"url";import{format as _6}from"util";import{normalize as N6,resolve as A6}from"path";function Fu(D){if(!(D!==D.toLowerCase()&&D!==D.toUpperCase()))D=D.toLowerCase();if(D.indexOf("-")===-1&&D.indexOf("_")===-1)return D;else{let F="",B=!1,E=D.match(/^-+/);for(let C=E?E[0].length:0;C<D.length;C++){let $=D.charAt(C);if(B)B=!1,$=$.toUpperCase();if(C!==0&&($==="-"||$==="_"))B=!0;else if($!=="-"&&$!=="_")F+=$}return F}}function $F(D,u){let F=D.toLowerCase();u=u||"-";let B="";for(let E=0;E<D.length;E++){let C=F.charAt(E),$=D.charAt(E);if(C!==$&&E>0)B+=`${u}${F.charAt(E)}`;else B+=$}return B}function zF(D){if(D===null||D===void 0)return!1;if(typeof D==="number")return!0;if(/^0x[0-9a-f]+$/i.test(D))return!0;if(/^0[^.]/.test(D))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(D)}function r2(D){if(Array.isArray(D))return D.map(($)=>typeof $!=="string"?$+"":$);D=D.trim();let u=0,F=null,B=null,E=null,C=[];for(let $=0;$<D.length;$++){if(F=B,B=D.charAt($),B===" "&&!E){if(F!==" ")u++;continue}if(B===E)E=null;else if((B==="'"||B==='"')&&!E)E=B;if(!C[u])C[u]="";C[u]+=B}return C}var ND;(function(D){D.BOOLEAN="boolean",D.STRING="string",D.NUMBER="number",D.ARRAY="array"})(ND||(ND={}));var mD;class eF{constructor(D){mD=D}parse(D,u){let F=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},u),B=r2(D),E=typeof D==="string",C=j6(Object.assign(Object.create(null),F.alias)),$=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},F.configuration),z=Object.assign(Object.create(null),F.default),Z=F.configObjects||[],J=F.envPrefix,Q=$["populate--"],G=Q?"--":"_",Y=Object.create(null),V=Object.create(null),H=F.__||mD.format,W={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:[]},K=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,N=new RegExp("^--"+$["negation-prefix"]+"(.+)");if([].concat(F.array||[]).filter(Boolean).forEach(function(q){let U=typeof q==="object"?q.key:q,A=Object.keys(q).map(function(_){return{boolean:"bools",string:"strings",number:"numbers"}[_]}).filter(Boolean).pop();if(A)W[A][U]=!0;W.arrays[U]=!0,W.keys.push(U)}),[].concat(F.boolean||[]).filter(Boolean).forEach(function(q){W.bools[q]=!0,W.keys.push(q)}),[].concat(F.string||[]).filter(Boolean).forEach(function(q){W.strings[q]=!0,W.keys.push(q)}),[].concat(F.number||[]).filter(Boolean).forEach(function(q){W.numbers[q]=!0,W.keys.push(q)}),[].concat(F.count||[]).filter(Boolean).forEach(function(q){W.counts[q]=!0,W.keys.push(q)}),[].concat(F.normalize||[]).filter(Boolean).forEach(function(q){W.normalize[q]=!0,W.keys.push(q)}),typeof F.narg==="object")Object.entries(F.narg).forEach(([q,U])=>{if(typeof U==="number")W.nargs[q]=U,W.keys.push(q)});if(typeof F.coerce==="object")Object.entries(F.coerce).forEach(([q,U])=>{if(typeof U==="function")W.coercions[q]=U,W.keys.push(q)});if(typeof F.config<"u"){if(Array.isArray(F.config)||typeof F.config==="string")[].concat(F.config).filter(Boolean).forEach(function(q){W.configs[q]=!0});else if(typeof F.config==="object")Object.entries(F.config).forEach(([q,U])=>{if(typeof U==="boolean"||typeof U==="function")W.configs[q]=U})}fu(F.key,C,F.default,W.arrays),Object.keys(z).forEach(function(q){(W.aliases[q]||[]).forEach(function(U){z[U]=z[q]})});let j=null;kF();let L=[],M=Object.assign(Object.create(null),{_:[]}),T={};for(let q=0;q<B.length;q++){let U=B[q],A=U.replace(/^-{3,}/,"---"),_,O,x,P,y,XD;if(U!=="--"&&/^-/.test(U)&&s(U))f(U);else if(A.match(/^---+(=|$)/)){f(U);continue}else if(U.match(/^--.+=/)||!$["short-option-groups"]&&U.match(/^-.+=/)){if(P=U.match(/^--?([^=]+)=([\s\S]*)$/),P!==null&&Array.isArray(P)&&P.length>=3)if(m(P[1],W.arrays))q=$D(q,P[1],B,P[2]);else if(m(P[1],W.nargs)!==!1)q=p(q,P[1],B,P[2]);else l(P[1],P[2],!0)}else if(U.match(N)&&$["boolean-negation"]){if(P=U.match(N),P!==null&&Array.isArray(P)&&P.length>=2)O=P[1],l(O,m(O,W.arrays)?[!1]:!1)}else if(U.match(/^--.+/)||!$["short-option-groups"]&&U.match(/^-[^-]+/)){if(P=U.match(/^--?(.+)/),P!==null&&Array.isArray(P)&&P.length>=2)if(O=P[1],m(O,W.arrays))q=$D(q,O,B);else if(m(O,W.nargs)!==!1)q=p(q,O,B);else if(y=B[q+1],y!==void 0&&(!y.match(/^-/)||y.match(K))&&!m(O,W.bools)&&!m(O,W.counts))l(O,y),q++;else if(/^(true|false)$/.test(y))l(O,y),q++;else l(O,i(O))}else if(U.match(/^-.\..+=/)){if(P=U.match(/^-([^=]+)=([\s\S]*)$/),P!==null&&Array.isArray(P)&&P.length>=3)l(P[1],P[2])}else if(U.match(/^-.\..+/)&&!U.match(K)){if(y=B[q+1],P=U.match(/^-(.\..+)/),P!==null&&Array.isArray(P)&&P.length>=2)if(O=P[1],y!==void 0&&!y.match(/^-/)&&!m(O,W.bools)&&!m(O,W.counts))l(O,y),q++;else l(O,i(O))}else if(U.match(/^-[^-]+/)&&!U.match(K)){x=U.slice(1,-1).split(""),_=!1;for(let HD=0;HD<x.length;HD++){if(y=U.slice(HD+2),x[HD+1]&&x[HD+1]==="="){if(XD=U.slice(HD+3),O=x[HD],m(O,W.arrays))q=$D(q,O,B,XD);else if(m(O,W.nargs)!==!1)q=p(q,O,B,XD);else l(O,XD);_=!0;break}if(y==="-"){l(x[HD],y);continue}if(/[A-Za-z]/.test(x[HD])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(y)&&m(y,W.bools)===!1){l(x[HD],y),_=!0;break}if(x[HD+1]&&x[HD+1].match(/\W/)){l(x[HD],y),_=!0;break}else l(x[HD],i(x[HD]))}if(O=U.slice(-1)[0],!_&&O!=="-")if(m(O,W.arrays))q=$D(q,O,B);else if(m(O,W.nargs)!==!1)q=p(q,O,B);else if(y=B[q+1],y!==void 0&&(!/^(-|--)[^-]/.test(y)||y.match(K))&&!m(O,W.bools)&&!m(O,W.counts))l(O,y),q++;else if(/^(true|false)$/.test(y))l(O,y),q++;else l(O,i(O))}else if(U.match(/^-[0-9]$/)&&U.match(K)&&m(U.slice(1),W.bools))O=U.slice(1),l(O,i(O));else if(U==="--"){L=B.slice(q+1);break}else if($["halt-at-non-option"]){L=B.slice(q);break}else f(U)}if(CD(M,!0),CD(M,!1),b(M),o(),kD(M,W.aliases,z,!0),n(M),$["set-placeholder-key"])zD(M);if(Object.keys(W.counts).forEach(function(q){if(!r(M,q.split(".")))l(q,0)}),Q&&L.length)M[G]=[];if(L.forEach(function(q){M[G].push(q)}),$["camel-case-expansion"]&&$["strip-dashed"])Object.keys(M).filter((q)=>q!=="--"&&q.includes("-")).forEach((q)=>{delete M[q]});if($["strip-aliased"])[].concat(...Object.keys(C).map((q)=>C[q])).forEach((q)=>{if($["camel-case-expansion"]&&q.includes("-"))delete M[q.split(".").map((U)=>Fu(U)).join(".")];delete M[q]});function f(q){let U=R("_",q);if(typeof U==="string"||typeof U==="number")M._.push(U)}function p(q,U,A,_){let O,x=m(U,W.nargs);if(x=typeof x!=="number"||isNaN(x)?1:x,x===0){if(!JD(_))j=Error(H("Argument unexpected for: %s",U));return l(U,i(U)),q}let P=JD(_)?0:1;if($["nargs-eats-options"]){if(A.length-(q+1)+P<x)j=Error(H("Not enough arguments following: %s",U));P=x}else{for(O=q+1;O<A.length;O++)if(!A[O].match(/^-[^0-9]/)||A[O].match(K)||s(A[O]))P++;else break;if(P<x)j=Error(H("Not enough arguments following: %s",U))}let y=Math.min(P,x);if(!JD(_)&&y>0)l(U,_),y--;for(O=q+1;O<y+q+1;O++)l(U,A[O]);return q+y}function $D(q,U,A,_){let O=[],x=_||A[q+1],P=m(U,W.nargs);if(m(U,W.bools)&&!/^(true|false)$/.test(x))O.push(!0);else if(JD(x)||JD(_)&&/^-/.test(x)&&!K.test(x)&&!s(x)){if(z[U]!==void 0){let y=z[U];O=Array.isArray(y)?y:[y]}}else{if(!JD(_))O.push(I(U,_,!0));for(let y=q+1;y<A.length;y++){if(!$["greedy-arrays"]&&O.length>0||P&&typeof P==="number"&&O.length>=P)break;if(x=A[y],/^-/.test(x)&&!K.test(x)&&!s(x))break;q=y,O.push(I(U,x,E))}}if(typeof P==="number"&&(P&&O.length<P||isNaN(P)&&O.length===0))j=Error(H("Not enough arguments following: %s",U));return l(U,O),q}function l(q,U,A=E){if(/-/.test(q)&&$["camel-case-expansion"]){let x=q.split(".").map(function(P){return Fu(P)}).join(".");Du(q,x)}let _=I(q,U,A),O=q.split(".");if(pD(M,O,_),W.aliases[q])W.aliases[q].forEach(function(x){let P=x.split(".");pD(M,P,_)});if(O.length>1&&$["dot-notation"])(W.aliases[O[0]]||[]).forEach(function(x){let P=x.split("."),y=[].concat(O);if(y.shift(),P=P.concat(y),!(W.aliases[q]||[]).includes(P.join(".")))pD(M,P,_)});if(m(q,W.normalize)&&!m(q,W.arrays))[q].concat(W.aliases[q]||[]).forEach(function(P){Object.defineProperty(T,P,{enumerable:!0,get(){return U},set(y){U=typeof y==="string"?mD.normalize(y):y}})})}function Du(q,U){if(!(W.aliases[q]&&W.aliases[q].length))W.aliases[q]=[U],Y[U]=!0;if(!(W.aliases[U]&&W.aliases[U].length))Du(U,q)}function I(q,U,A){if(A)U=M6(U);if(m(q,W.bools)||m(q,W.counts)){if(typeof U==="string")U=U==="true"}let _=Array.isArray(U)?U.map(function(O){return R(q,O)}):R(q,U);if(m(q,W.counts)&&(JD(_)||typeof _==="boolean"))_=aF();if(m(q,W.normalize)&&m(q,W.arrays))if(Array.isArray(U))_=U.map((O)=>{return mD.normalize(O)});else _=mD.normalize(U);return _}function R(q,U){if(!$["parse-positional-numbers"]&&q==="_")return U;if(!m(q,W.strings)&&!m(q,W.bools)&&!Array.isArray(U)){if(zF(U)&&$["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${U}`)))||!JD(U)&&m(q,W.numbers))U=Number(U)}return U}function b(q){let U=Object.create(null);kD(U,W.aliases,z),Object.keys(W.configs).forEach(function(A){let _=q[A]||U[A];if(_)try{let O=null,x=mD.resolve(mD.cwd(),_),P=W.configs[A];if(typeof P==="function"){try{O=P(x)}catch(y){O=y}if(O instanceof Error){j=O;return}}else O=mD.require(x);d(O)}catch(O){if(O.name==="PermissionDenied")j=O;else if(q[A])j=Error(H("Invalid JSON config file: %s",_))}})}function d(q,U){Object.keys(q).forEach(function(A){let _=q[A],O=U?U+"."+A:A;if(typeof _==="object"&&_!==null&&!Array.isArray(_)&&$["dot-notation"])d(_,O);else if(!r(M,O.split("."))||m(O,W.arrays)&&$["combine-arrays"])l(O,_)})}function o(){if(typeof Z<"u")Z.forEach(function(q){d(q)})}function CD(q,U){if(typeof J>"u")return;let A=typeof J==="string"?J:"",_=mD.env();Object.keys(_).forEach(function(O){if(A===""||O.lastIndexOf(A,0)===0){let x=O.split("__").map(function(P,y){if(y===0)P=P.substring(A.length);return Fu(P)});if((U&&W.configs[x.join(".")]||!U)&&!r(q,x))l(x.join("."),_[O])}})}function n(q){let U,A=new Set;Object.keys(q).forEach(function(_){if(!A.has(_)){if(U=m(_,W.coercions),typeof U==="function")try{let O=R(_,U(q[_]));[].concat(W.aliases[_]||[],_).forEach((x)=>{A.add(x),q[x]=O})}catch(O){j=O}}})}function zD(q){return W.keys.forEach((U)=>{if(~U.indexOf("."))return;if(typeof q[U]>"u")q[U]=void 0}),q}function kD(q,U,A,_=!1){Object.keys(A).forEach(function(O){if(!r(q,O.split("."))){if(pD(q,O.split("."),A[O]),_)V[O]=!0;(U[O]||[]).forEach(function(x){if(r(q,x.split(".")))return;pD(q,x.split("."),A[O])})}})}function r(q,U){let A=q;if(!$["dot-notation"])U=[U.join(".")];U.slice(0,-1).forEach(function(O){A=A[O]||{}});let _=U[U.length-1];if(typeof A!=="object")return!1;else return _ in A}function pD(q,U,A){let _=q;if(!$["dot-notation"])U=[U.join(".")];U.slice(0,-1).forEach(function(XD){if(XD=a2(XD),typeof _==="object"&&_[XD]===void 0)_[XD]={};if(typeof _[XD]!=="object"||Array.isArray(_[XD])){if(Array.isArray(_[XD]))_[XD].push({});else _[XD]=[_[XD],{}];_=_[XD][_[XD].length-1]}else _=_[XD]});let O=a2(U[U.length-1]),x=m(U.join("."),W.arrays),P=Array.isArray(A),y=$["duplicate-arguments-array"];if(!y&&m(O,W.nargs)){if(y=!0,!JD(_[O])&&W.nargs[O]===1||Array.isArray(_[O])&&_[O].length===W.nargs[O])_[O]=void 0}if(A===aF())_[O]=aF(_[O]);else if(Array.isArray(_[O]))if(y&&x&&P)_[O]=$["flatten-duplicate-arrays"]?_[O].concat(A):(Array.isArray(_[O][0])?_[O]:[_[O]]).concat([A]);else if(!y&&Boolean(x)===Boolean(P))_[O]=A;else _[O]=_[O].concat([A]);else if(_[O]===void 0&&x)_[O]=P?A:[A];else if(y&&!(_[O]===void 0||m(O,W.counts)||m(O,W.bools)))_[O]=[_[O],A];else _[O]=A}function fu(...q){q.forEach(function(U){Object.keys(U||{}).forEach(function(A){if(W.aliases[A])return;W.aliases[A]=[].concat(C[A]||[]),W.aliases[A].concat(A).forEach(function(_){if(/-/.test(_)&&$["camel-case-expansion"]){let O=Fu(_);if(O!==A&&W.aliases[A].indexOf(O)===-1)W.aliases[A].push(O),Y[O]=!0}}),W.aliases[A].concat(A).forEach(function(_){if(_.length>1&&/[A-Z]/.test(_)&&$["camel-case-expansion"]){let O=$F(_,"-");if(O!==A&&W.aliases[A].indexOf(O)===-1)W.aliases[A].push(O),Y[O]=!0}}),W.aliases[A].forEach(function(_){W.aliases[_]=[A].concat(W.aliases[A].filter(function(O){return _!==O}))})})})}function m(q,U){let A=[].concat(W.aliases[q]||[],q),_=Object.keys(U),O=A.find((x)=>_.includes(x));return O?U[O]:!1}function Nu(q){let U=Object.keys(W);return[].concat(U.map((_)=>W[_])).some(function(_){return Array.isArray(_)?_.includes(q):_[q]})}function K2(q,...U){return[].concat(...U).some(function(_){let O=q.match(_);return O&&Nu(O[1])})}function g(q){if(q.match(K)||!q.match(/^-[^-]+/))return!1;let U=!0,A,_=q.slice(1).split("");for(let O=0;O<_.length;O++){if(A=q.slice(O+2),!Nu(_[O])){U=!1;break}if(_[O+1]&&_[O+1]==="="||A==="-"||/[A-Za-z]/.test(_[O])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(A)||_[O+1]&&_[O+1].match(/\W/))break}return U}function s(q){return $["unknown-options-as-args"]&&ZD(q)}function ZD(q){if(q=q.replace(/^-{3,}/,"--"),q.match(K))return!1;if(g(q))return!1;return!K2(q,/^-+([^=]+?)=[\s\S]*$/,N,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function i(q){if(!m(q,W.bools)&&!m(q,W.counts)&&`${q}`in z)return z[q];else return YD(FD(q))}function YD(q){return{[ND.BOOLEAN]:!0,[ND.STRING]:"",[ND.NUMBER]:void 0,[ND.ARRAY]:[]}[q]}function FD(q){let U=ND.BOOLEAN;if(m(q,W.strings))U=ND.STRING;else if(m(q,W.numbers))U=ND.NUMBER;else if(m(q,W.bools))U=ND.BOOLEAN;else if(m(q,W.arrays))U=ND.ARRAY;return U}function JD(q){return q===void 0}function kF(){Object.keys(W.counts).find((q)=>{if(m(q,W.arrays))return j=Error(H("Invalid configuration: %s, opts.count excludes opts.array.",q)),!0;else if(m(q,W.nargs))return j=Error(H("Invalid configuration: %s, opts.count excludes opts.narg.",q)),!0;return!1})}return{aliases:Object.assign({},W.aliases),argv:Object.assign(T,M),configuration:$,defaulted:Object.assign({},V),error:j,newAliases:Object.assign({},Y)}}}function j6(D){let u=[],F=Object.create(null),B=!0;Object.keys(D).forEach(function(E){u.push([].concat(D[E],E))});while(B){B=!1;for(let E=0;E<u.length;E++)for(let C=E+1;C<u.length;C++)if(u[E].filter(function(z){return u[C].indexOf(z)!==-1}).length){u[E]=u[E].concat(u[C]),u.splice(C,1),B=!0;break}}return u.forEach(function(E){E=E.filter(function($,z,Z){return Z.indexOf($)===z});let C=E.pop();if(C!==void 0&&typeof C==="string")F[C]=E}),F}function aF(D){return D!==void 0?D+1:1}function a2(D){if(D==="__proto__")return"___proto___";return D}function M6(D){return typeof D==="string"&&(D[0]==="'"||D[0]==='"')&&D[D.length-1]===D[0]?D.substring(1,D.length-1):D}import{readFileSync as L6}from"fs";import{createRequire as e2}from"node:module";var D0,u0,F0,D8=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,u8=(u0=(D0=process===null||process===void 0?void 0:process.versions)===null||D0===void 0?void 0:D0.node)!==null&&u0!==void 0?u0:(F0=process===null||process===void 0?void 0:process.version)===null||F0===void 0?void 0:F0.slice(1);if(u8){if(Number(u8.match(/^([^.]+)/)[1])<D8)throw Error(`yargs parser supports a minimum Node.js version of ${D8}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var T6=process?process.env:{},F8=e2?e2(import.meta.url):void 0,E8=new eF({cwd:process.cwd,env:()=>{return T6},format:_6,normalize:N6,resolve:A6,require:(D)=>{if(typeof F8<"u")return F8(D);else if(D.match(/\.json$/))return JSON.parse(L6(D,"utf8"));else throw Error("only .json config files are supported in ESM")}}),hu=function(u,F){return E8.parse(u.slice(),F).argv};hu.detailed=function(D,u){return E8.parse(D.slice(),u)};hu.camelCase=Fu;hu.decamelize=$F;hu.looksLikeNumber=zF;var E0=hu;import{basename as p6,dirname as m6,extname as g6,relative as c6,resolve as Q8,join as d6}from"path";function B8(){if(R6())return 0;return 1}function R6(){return P6()&&!process.defaultApp}function P6(){return!!process.versions.electron}function B0(D){return D.slice(B8()+1)}function C8(){return process.argv[B8()]}import{readFileSync as S6,statSync as w6,writeFile as x6}from"fs";import{format as I6}from"util";import{resolve as b6}from"path";var $8={fs:{readFileSync:S6,writeFile:x6},format:I6,resolve:b6,exists:(D)=>{try{return w6(D).isFile()}catch(u){return!1}}};var PD;class z8{constructor(D){D=D||{},this.directory=D.directory||"./locales",this.updateFiles=typeof D.updateFiles==="boolean"?D.updateFiles:!0,this.locale=D.locale||"en",this.fallbackToLanguage=typeof D.fallbackToLanguage==="boolean"?D.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...D){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let u=D.shift(),F=function(){};if(typeof D[D.length-1]==="function")F=D.pop();if(F=F||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][u]&&this.updateFiles)this.cache[this.locale][u]=u,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:F});else F();return PD.format.apply(PD.format,[this.cache[this.locale][u]||u].concat(D))}__n(){let D=Array.prototype.slice.call(arguments),u=D.shift(),F=D.shift(),B=D.shift(),E=function(){};if(typeof D[D.length-1]==="function")E=D.pop();if(!this.cache[this.locale])this._readLocaleFile();let C=B===1?u:F;if(this.cache[this.locale][u])C=this.cache[this.locale][u][B===1?"one":"other"];if(!this.cache[this.locale][u]&&this.updateFiles)this.cache[this.locale][u]={one:u,other:F},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:E});else E();let $=[C];if(~C.indexOf("%d"))$.push(B);return PD.format.apply(PD.format,$.concat(D))}setLocale(D){this.locale=D}getLocale(){return this.locale}updateLocale(D){if(!this.cache[this.locale])this._readLocaleFile();for(let u in D)if(Object.prototype.hasOwnProperty.call(D,u))this.cache[this.locale][u]=D[u]}_taggedLiteral(D,...u){let F="";return D.forEach(function(B,E){let C=u[E+1];if(F+=B,typeof C<"u")F+="%s"}),this.__.apply(this,[F].concat([].slice.call(u,1)))}_enqueueWrite(D){if(this.writeQueue.push(D),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let D=this,u=this.writeQueue[0],F=u.directory,B=u.locale,E=u.cb,C=this._resolveLocaleFile(F,B),$=JSON.stringify(this.cache[B],null,2);PD.fs.writeFile(C,$,"utf-8",function(z){if(D.writeQueue.shift(),D.writeQueue.length>0)D._processWriteQueue();E(z)})}_readLocaleFile(){let D={},u=this._resolveLocaleFile(this.directory,this.locale);try{if(PD.fs.readFileSync)D=JSON.parse(PD.fs.readFileSync(u,"utf-8"))}catch(F){if(F instanceof SyntaxError)F.message="syntax error in "+u;if(F.code==="ENOENT")D={};else throw F}this.cache[this.locale]=D}_resolveLocaleFile(D,u){let F=PD.resolve(D,"./",u+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(F)&&~u.lastIndexOf("_")){let B=PD.resolve(D,"./",u.split("_")[0]+".json");if(this._fileExistsSync(B))F=B}return F}_fileExistsSync(D){return PD.exists(D)}}function Z8(D,u){PD=u;let F=new z8(D);return{__:F.__.bind(F),__n:F.__n.bind(F),setLocale:F.setLocale.bind(F),getLocale:F.getLocale.bind(F),updateLocale:F.updateLocale.bind(F),locale:F.locale}}var f6=(D)=>{return Z8(D,$8)},J8=f6;var W8=U2(X8(),1);import{createRequire as k6}from"node:module";import{readFileSync as i6,readdirSync as l6}from"node:fs";var C0=Y8(import.meta.url),n6=C0.substring(0,C0.lastIndexOf("node_modules")),t6=k6(import.meta.url),$0={assert:{notStrictEqual:h6,strictEqual:v6},cliui:sF,findUp:rF,getEnv:(D)=>{return process.env[D]},inspect:y6,getProcessArgvBin:C8,mainFilename:n6||process.cwd(),Parser:E0,path:{basename:p6,dirname:m6,extname:g6,relative:c6,resolve:Q8,join:d6},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(D,u)=>process.emitWarning(D,u),execPath:()=>process.execPath,exit:(D)=>{process.exit(D)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:i6,readdirSync:l6,require:t6,getCallerFile:()=>{let D=W8.default(3);return D.match(/^file:\/\//)?Y8(D):D},stringWidth:RD,y18n:J8({directory:Q8(C0,"../../../locales"),updateFiles:!1})};function qD(D,u,F,B){F.assert.notStrictEqual(D,u,B)}function z0(D,u){u.assert.strictEqual(typeof D,"string")}function Au(D){return Object.keys(D)}function a(D){return!!D&&!!D.then&&typeof D.then==="function"}class ED extends Error{constructor(D){super(D||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,ED)}}function iD(D){let F=D.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),B=/\.*[\][<>]/g,E=F.shift();if(!E)throw Error(`No command found in: ${D}`);let C={cmd:E.replace(B,""),demanded:[],optional:[]};return F.forEach(($,z)=>{let Z=!1;if($=$.replace(/\s/g,""),/\.+[\]>]/.test($)&&z===F.length-1)Z=!0;if(/^\[/.test($))C.optional.push({cmd:$.replace(B,"").split("|"),variadic:Z});else C.demanded.push({cmd:$.replace(B,"").split("|"),variadic:Z})}),C}var o6=["first","second","third","fourth","fifth","sixth"];function S(D,u,F){function B(){return typeof D==="object"?[{demanded:[],optional:[]},D,u]:[iD(`cmd ${D}`),u,F]}try{let E=0,[C,$,z]=B(),Z=[].slice.call($);while(Z.length&&Z[Z.length-1]===void 0)Z.pop();let J=z||Z.length;if(J<C.demanded.length)throw new ED(`Not enough arguments provided. Expected ${C.demanded.length} but received ${Z.length}.`);let Q=C.demanded.length+C.optional.length;if(J>Q)throw new ED(`Too many arguments provided. Expected max ${Q} but received ${J}.`);C.demanded.forEach((G)=>{let Y=Z.shift(),V=V8(Y);if(G.cmd.filter((W)=>W===V||W==="*").length===0)H8(V,G.cmd,E);E+=1}),C.optional.forEach((G)=>{if(Z.length===0)return;let Y=Z.shift(),V=V8(Y);if(G.cmd.filter((W)=>W===V||W==="*").length===0)H8(V,G.cmd,E);E+=1})}catch(E){console.warn(E.stack)}}function V8(D){if(Array.isArray(D))return"array";else if(D===null)return"null";return typeof D}function H8(D,u,F){throw new ED(`Invalid ${o6[F]||"manyith"} argument. Expected ${u.join(" or ")} but received ${D}.`)}class Z0{constructor(D){this.globalMiddleware=[],this.frozens=[],this.yargs=D}addMiddleware(D,u,F=!0,B=!1){if(S("<array|function> [boolean] [boolean] [boolean]",[D,u,F],arguments.length),Array.isArray(D)){for(let E=0;E<D.length;E++){if(typeof D[E]!=="function")throw Error("middleware must be a function");let C=D[E];C.applyBeforeValidation=u,C.global=F}Array.prototype.push.apply(this.globalMiddleware,D)}else if(typeof D==="function"){let E=D;E.applyBeforeValidation=u,E.global=F,E.mutates=B,this.globalMiddleware.push(D)}return this.yargs}addCoerceMiddleware(D,u){let F=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((B)=>{let E=[...F[u]||[],u];if(!B.option)return!0;else return!E.includes(B.option)}),D.option=u,this.addMiddleware(D,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let D=this.frozens.pop();if(D!==void 0)this.globalMiddleware=D}reset(){this.globalMiddleware=this.globalMiddleware.filter((D)=>D.global)}}function q8(D){if(!D)return[];return D.map((u)=>{return u.applyBeforeValidation=!1,u})}function Eu(D,u,F,B){return F.reduce((E,C)=>{if(C.applyBeforeValidation!==B)return E;if(C.mutates){if(C.applied)return E;C.applied=!0}if(a(E))return E.then(($)=>Promise.all([$,C($,u)])).then(([$,z])=>Object.assign($,z));else{let $=C(E,u);return a($)?$.then((z)=>Object.assign(E,z)):Object.assign(E,$)}},D)}function Bu(D,u,F=(B)=>{throw B}){try{let B=s6(D)?D():D;return a(B)?B.then((E)=>u(E)):u(B)}catch(B){return F(B)}}function s6(D){return typeof D==="function"}var Lu=/(^\*)|(^\$0)/;class O8{constructor(D,u,F,B){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=B,this.usage=D,this.globalMiddleware=F,this.validation=u}addDirectory(D,u,F,B){B=B||{},this.requireCache.add(F);let E=this.shim.path.resolve(this.shim.path.dirname(F),D),C=this.shim.readdirSync(E,{recursive:B.recurse?!0:!1});if(!Array.isArray(B.extensions))B.extensions=["js"];let $=typeof B.visit==="function"?B.visit:(z)=>z;for(let z of C){let Z=z.toString();if(B.exclude){let Q=!1;if(typeof B.exclude==="function")Q=B.exclude(Z);else Q=B.exclude.test(Z);if(Q)continue}if(B.include){let Q=!1;if(typeof B.include==="function")Q=B.include(Z);else Q=B.include.test(Z);if(!Q)continue}let J=!1;for(let Q of B.extensions)if(Z.endsWith(Q))J=!0;if(J){let Q=this.shim.path.join(E,Z),G=u(Q),Y=Object.create(null,Object.getOwnPropertyDescriptors({...G}));if($(Y,Q,Z)){if(this.requireCache.has(Q))continue;else this.requireCache.add(Q);if(!Y.command)Y.command=this.shim.path.basename(Q,this.shim.path.extname(Q));this.addHandler(Y)}}}}addHandler(D,u,F,B,E,C){let $=[],z=q8(E);if(B=B||(()=>{}),Array.isArray(D))if(r6(D))[D,...$]=D;else for(let Z of D)this.addHandler(Z);else if(e6(D)){let Z=Array.isArray(D.command)||typeof D.command==="string"?D.command:null;if(Z===null)throw Error(`No command name given for module: ${this.shim.inspect(D)}`);if(D.aliases)Z=[].concat(Z).concat(D.aliases);this.addHandler(Z,this.extractDesc(D),D.builder,D.handler,D.middlewares,D.deprecated);return}else if(K8(F)){this.addHandler([D].concat($),u,F.builder,F.handler,F.middlewares,F.deprecated);return}if(typeof D==="string"){let Z=iD(D);$=$.map((G)=>iD(G).cmd);let J=!1,Q=[Z.cmd].concat($).filter((G)=>{if(Lu.test(G))return J=!0,!1;return!0});if(Q.length===0&&J)Q.push("$0");if(J)Z.cmd=Q[0],$=Q.slice(1),D=D.replace(Lu,Z.cmd);if($.forEach((G)=>{this.aliasMap[G]=Z.cmd}),u!==!1)this.usage.command(D,u,J,$,C);if(this.handlers[Z.cmd]={original:D,description:u,handler:B,builder:F||{},middlewares:z,deprecated:C,demanded:Z.demanded,optional:Z.optional},J)this.defaultCommand=this.handlers[Z.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(D,u,F,B,E,C){let $=this.handlers[D]||this.handlers[this.aliasMap[D]]||this.defaultCommand,z=u.getInternalMethods().getContext(),Z=z.commands.slice(),J=!D;if(D)z.commands.push(D),z.fullCommands.push($.original);let Q=this.applyBuilderUpdateUsageAndParse(J,$,u,F.aliases,Z,B,E,C);return a(Q)?Q.then((G)=>this.applyMiddlewareAndGetResult(J,$,G.innerArgv,z,E,G.aliases,u)):this.applyMiddlewareAndGetResult(J,$,Q.innerArgv,z,E,Q.aliases,u)}applyBuilderUpdateUsageAndParse(D,u,F,B,E,C,$,z){let Z=u.builder,J=F;if(ZF(Z)){F.getInternalMethods().getUsageInstance().freeze();let Q=Z(F.getInternalMethods().reset(B),z);if(a(Q))return Q.then((G)=>{return J=j8(G)?G:F,this.parseAndUpdateUsage(D,u,J,E,C,$)})}else if(a6(Z))F.getInternalMethods().getUsageInstance().freeze(),J=F.getInternalMethods().reset(B),Object.keys(u.builder).forEach((Q)=>{J.option(Q,Z[Q])});return this.parseAndUpdateUsage(D,u,J,E,C,$)}parseAndUpdateUsage(D,u,F,B,E,C){if(D)F.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(F))F.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(B,u),u.description);let $=F.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,E,C);return a($)?$.then((z)=>({aliases:F.parsed.aliases,innerArgv:z})):{aliases:F.parsed.aliases,innerArgv:$}}shouldUpdateUsage(D){return!D.getInternalMethods().getUsageInstance().getUsageDisabled()&&D.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(D,u){let F=Lu.test(u.original)?u.original.replace(Lu,"").trim():u.original,B=D.filter((E)=>{return!Lu.test(E)});return B.push(F),`$0 ${B.join(" ")}`}handleValidationAndGetResult(D,u,F,B,E,C,$,z){if(!C.getInternalMethods().getHasOutput()){let Z=C.getInternalMethods().runValidation(E,z,C.parsed.error,D);F=Bu(F,(J)=>{return Z(J),J})}if(u.handler&&!C.getInternalMethods().getHasOutput()){C.getInternalMethods().setHasOutput();let Z=!!C.getOptions().configuration["populate--"];if(C.getInternalMethods().postProcess(F,Z,!1,!1),F=Eu(F,C,$,!1),F=Bu(F,(J)=>{let Q=u.handler(J);return a(Q)?Q.then(()=>J):J}),!D)C.getInternalMethods().getUsageInstance().cacheHelpMessage();if(a(F)&&!C.getInternalMethods().hasParseCallback())F.catch((J)=>{try{C.getInternalMethods().getUsageInstance().fail(null,J)}catch(Q){}})}if(!D)B.commands.pop(),B.fullCommands.pop();return F}applyMiddlewareAndGetResult(D,u,F,B,E,C,$){let z={};if(E)return F;if(!$.getInternalMethods().getHasOutput())z=this.populatePositionals(u,F,B,$);let Z=this.globalMiddleware.getMiddleware().slice(0).concat(u.middlewares),J=Eu(F,$,Z,!0);return a(J)?J.then((Q)=>this.handleValidationAndGetResult(D,u,Q,B,C,$,Z,z)):this.handleValidationAndGetResult(D,u,J,B,C,$,Z,z)}populatePositionals(D,u,F,B){u._=u._.slice(F.commands.length);let E=D.demanded.slice(0),C=D.optional.slice(0),$={};this.validation.positionalCount(E.length,u._.length);while(E.length){let z=E.shift();this.populatePositional(z,u,$)}while(C.length){let z=C.shift();this.populatePositional(z,u,$)}return u._=F.commands.concat(u._.map((z)=>""+z)),this.postProcessPositionals(u,$,this.cmdToParseOptions(D.original),B),$}populatePositional(D,u,F){let B=D.cmd[0];if(D.variadic)F[B]=u._.splice(0).map(String);else if(u._.length)F[B]=[String(u._.shift())]}cmdToParseOptions(D){let u={array:[],default:{},alias:{},demand:{}},F=iD(D);return F.demanded.forEach((B)=>{let[E,...C]=B.cmd;if(B.variadic)u.array.push(E),u.default[E]=[];u.alias[E]=C,u.demand[E]=!0}),F.optional.forEach((B)=>{let[E,...C]=B.cmd;if(B.variadic)u.array.push(E),u.default[E]=[];u.alias[E]=C}),u}postProcessPositionals(D,u,F,B){let E=Object.assign({},B.getOptions());E.default=Object.assign(F.default,E.default);for(let Z of Object.keys(F.alias))E.alias[Z]=(E.alias[Z]||[]).concat(F.alias[Z]);E.array=E.array.concat(F.array),E.config={};let C=[];if(Object.keys(u).forEach((Z)=>{u[Z].map((J)=>{if(E.configuration["unknown-options-as-args"])E.key[Z]=!0;C.push(`--${Z}`),C.push(J)})}),!C.length)return;let $=Object.assign({},E.configuration,{"populate--":!1}),z=this.shim.Parser.detailed(C,Object.assign({},E,{configuration:$}));if(z.error)B.getInternalMethods().getUsageInstance().fail(z.error.message,z.error);else{let Z=Object.keys(u);Object.keys(u).forEach((J)=>{Z.push(...z.aliases[J])}),Object.keys(z.argv).forEach((J)=>{if(Z.includes(J)){if(!u[J])u[J]=z.argv[J];if(!this.isInConfigs(B,J)&&!this.isDefaulted(B,J)&&Object.prototype.hasOwnProperty.call(D,J)&&Object.prototype.hasOwnProperty.call(z.argv,J)&&(Array.isArray(D[J])||Array.isArray(z.argv[J])))D[J]=[].concat(D[J],z.argv[J]);else D[J]=z.argv[J]}})}}isDefaulted(D,u){let{default:F}=D.getOptions();return Object.prototype.hasOwnProperty.call(F,u)||Object.prototype.hasOwnProperty.call(F,this.shim.Parser.camelCase(u))}isInConfigs(D,u){let{configObjects:F}=D.getOptions();return F.some((B)=>Object.prototype.hasOwnProperty.call(B,u))||F.some((B)=>Object.prototype.hasOwnProperty.call(B,this.shim.Parser.camelCase(u)))}runDefaultBuilderOn(D){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(D)){let F=Lu.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");D.getInternalMethods().getUsageInstance().usage(F,this.defaultCommand.description)}let u=this.defaultCommand.builder;if(ZF(u))return u(D,!0);else if(!K8(u))Object.keys(u).forEach((F)=>{D.option(F,u[F])});return}extractDesc({describe:D,description:u,desc:F}){for(let B of[D,u,F]){if(typeof B==="string"||B===!1)return B;qD(B,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let D=this.frozens.pop();qD(D,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=D}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function U8(D,u,F,B){return new O8(D,u,F,B)}function K8(D){return typeof D==="object"&&!!D.builder&&typeof D.handler==="function"}function r6(D){return D.every((u)=>typeof u==="string")}function ZF(D){return typeof D==="function"}function a6(D){return typeof D==="object"}function e6(D){return typeof D==="object"&&!Array.isArray(D)}function lD(D={},u=()=>!0){let F={};return Au(D).forEach((B)=>{if(u(B,D[B]))F[B]=D[B]}),F}function nD(D){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((u)=>{let F=u;if(F._handle&&F.isTTY&&typeof F._handle.setBlocking==="function")F._handle.setBlocking(D)})}function D7(D){return typeof D==="boolean"}function _8(D,u){let F=u.y18n.__,B={},E=[];B.failFn=function(R){E.push(R)};let C=null,$=null,z=!0;B.showHelpOnFail=function(R=!0,b){let[d,o]=typeof R==="string"?[!0,R]:[R,b];if(D.getInternalMethods().isGlobalContext())$=o;return C=o,z=d,B};let Z=!1;B.fail=function(R,b){let d=D.getInternalMethods().getLoggerInstance();if(E.length)for(let o=E.length-1;o>=0;--o){let CD=E[o];if(D7(CD)){if(b)throw b;else if(R)throw Error(R)}else CD(R,b,B)}else{if(D.getExitProcess())nD(!0);if(!Z){if(Z=!0,z)D.showHelp("error"),d.error();if(R||b)d.error(R||b);let o=C||$;if(o){if(R||b)d.error("");d.error(o)}}if(b=b||new ED(R),D.getExitProcess())return D.exit(1);else if(D.getInternalMethods().hasParseCallback())return D.exit(1,b);else throw b}};let J=[],Q=!1;B.usage=(I,R)=>{if(I===null)return Q=!0,J=[],B;return Q=!1,J.push([I,R||""]),B},B.getUsage=()=>{return J},B.getUsageDisabled=()=>{return Q},B.getPositionalGroupName=()=>{return F("Positionals:")};let G=[];B.example=(I,R)=>{G.push([I,R||""])};let Y=[];B.command=function(R,b,d,o,CD=!1){if(d)Y=Y.map((n)=>{return n[2]=!1,n});Y.push([R,b||"",d,o,CD])},B.getCommands=()=>Y;let V={};B.describe=function(R,b){if(Array.isArray(R))R.forEach((d)=>{B.describe(d,b)});else if(typeof R==="object")Object.keys(R).forEach((d)=>{B.describe(d,R[d])});else V[R]=b},B.getDescriptions=()=>V;let H=[];B.epilog=(I)=>{H.push(I)};let W=!1,K;B.wrap=(I)=>{W=!0,K=I},B.getWrap=()=>{if(u.getEnv("YARGS_DISABLE_WRAP"))return null;if(!W)K=$D(),W=!0;return K};let N="__yargsString__:";B.deferY18nLookup=(I)=>N+I,B.help=function(){if(M)return M;L();let R=D.customScriptName?D.$0:u.path.basename(D.$0),b=D.getDemandedOptions(),d=D.getDemandedCommands(),o=D.getDeprecatedOptions(),CD=D.getGroups(),n=D.getOptions(),zD=[];zD=zD.concat(Object.keys(V)),zD=zD.concat(Object.keys(b)),zD=zD.concat(Object.keys(d)),zD=zD.concat(Object.keys(n.default)),zD=zD.filter(f),zD=Object.keys(zD.reduce((g,s)=>{if(s!=="_")g[s]=!0;return g},{}));let kD=B.getWrap(),r=u.cliui({width:kD,wrap:!!kD});if(!Q){if(J.length)J.forEach((g)=>{if(r.div({text:`${g[0].replace(/\$0/g,R)}`}),g[1])r.div({text:`${g[1]}`,padding:[1,0,0,0]})}),r.div();else if(Y.length){let g=null;if(d._)g=`${R} <${F("command")}>
|
|
14
|
+
`)}function rF(D){return _2(D,{stringWidth:RD,stripAnsi:uu,wrap:sF})}import{dirname as t2,resolve as o2}from"path";import{readdirSync as O6,statSync as U6}from"fs";function aF(D,u){let F=o2(".",D),B;if(!U6(F).isDirectory())F=t2(F);while(!0){if(B=u(F,O6(F)),B)return o2(F,B);if(F=t2(B=F),B===F)break}}import{inspect as y6}from"util";import{fileURLToPath as Q8}from"url";import{format as _6}from"util";import{normalize as N6,resolve as A6}from"path";function Fu(D){if(!(D!==D.toLowerCase()&&D!==D.toUpperCase()))D=D.toLowerCase();if(D.indexOf("-")===-1&&D.indexOf("_")===-1)return D;else{let F="",B=!1,E=D.match(/^-+/);for(let C=E?E[0].length:0;C<D.length;C++){let $=D.charAt(C);if(B)B=!1,$=$.toUpperCase();if(C!==0&&($==="-"||$==="_"))B=!0;else if($!=="-"&&$!=="_")F+=$}return F}}function $F(D,u){let F=D.toLowerCase();u=u||"-";let B="";for(let E=0;E<D.length;E++){let C=F.charAt(E),$=D.charAt(E);if(C!==$&&E>0)B+=`${u}${F.charAt(E)}`;else B+=$}return B}function zF(D){if(D===null||D===void 0)return!1;if(typeof D==="number")return!0;if(/^0x[0-9a-f]+$/i.test(D))return!0;if(/^0[^.]/.test(D))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(D)}function s2(D){if(Array.isArray(D))return D.map(($)=>typeof $!=="string"?$+"":$);D=D.trim();let u=0,F=null,B=null,E=null,C=[];for(let $=0;$<D.length;$++){if(F=B,B=D.charAt($),B===" "&&!E){if(F!==" ")u++;continue}if(B===E)E=null;else if((B==="'"||B==='"')&&!E)E=B;if(!C[u])C[u]="";C[u]+=B}return C}var ND;(function(D){D.BOOLEAN="boolean",D.STRING="string",D.NUMBER="number",D.ARRAY="array"})(ND||(ND={}));var mD;class D0{constructor(D){mD=D}parse(D,u){let F=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},u),B=s2(D),E=typeof D==="string",C=j6(Object.assign(Object.create(null),F.alias)),$=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},F.configuration),z=Object.assign(Object.create(null),F.default),Z=F.configObjects||[],J=F.envPrefix,Q=$["populate--"],G=Q?"--":"_",Y=Object.create(null),V=Object.create(null),H=F.__||mD.format,W={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:[]},K=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,N=new RegExp("^--"+$["negation-prefix"]+"(.+)");if([].concat(F.array||[]).filter(Boolean).forEach(function(q){let U=typeof q==="object"?q.key:q,A=Object.keys(q).map(function(_){return{boolean:"bools",string:"strings",number:"numbers"}[_]}).filter(Boolean).pop();if(A)W[A][U]=!0;W.arrays[U]=!0,W.keys.push(U)}),[].concat(F.boolean||[]).filter(Boolean).forEach(function(q){W.bools[q]=!0,W.keys.push(q)}),[].concat(F.string||[]).filter(Boolean).forEach(function(q){W.strings[q]=!0,W.keys.push(q)}),[].concat(F.number||[]).filter(Boolean).forEach(function(q){W.numbers[q]=!0,W.keys.push(q)}),[].concat(F.count||[]).filter(Boolean).forEach(function(q){W.counts[q]=!0,W.keys.push(q)}),[].concat(F.normalize||[]).filter(Boolean).forEach(function(q){W.normalize[q]=!0,W.keys.push(q)}),typeof F.narg==="object")Object.entries(F.narg).forEach(([q,U])=>{if(typeof U==="number")W.nargs[q]=U,W.keys.push(q)});if(typeof F.coerce==="object")Object.entries(F.coerce).forEach(([q,U])=>{if(typeof U==="function")W.coercions[q]=U,W.keys.push(q)});if(typeof F.config<"u"){if(Array.isArray(F.config)||typeof F.config==="string")[].concat(F.config).filter(Boolean).forEach(function(q){W.configs[q]=!0});else if(typeof F.config==="object")Object.entries(F.config).forEach(([q,U])=>{if(typeof U==="boolean"||typeof U==="function")W.configs[q]=U})}fu(F.key,C,F.default,W.arrays),Object.keys(z).forEach(function(q){(W.aliases[q]||[]).forEach(function(U){z[U]=z[q]})});let j=null;iF();let L=[],M=Object.assign(Object.create(null),{_:[]}),T={};for(let q=0;q<B.length;q++){let U=B[q],A=U.replace(/^-{3,}/,"---"),_,O,x,P,y,XD;if(U!=="--"&&/^-/.test(U)&&s(U))h(U);else if(A.match(/^---+(=|$)/)){h(U);continue}else if(U.match(/^--.+=/)||!$["short-option-groups"]&&U.match(/^-.+=/)){if(P=U.match(/^--?([^=]+)=([\s\S]*)$/),P!==null&&Array.isArray(P)&&P.length>=3)if(m(P[1],W.arrays))q=$D(q,P[1],B,P[2]);else if(m(P[1],W.nargs)!==!1)q=p(q,P[1],B,P[2]);else l(P[1],P[2],!0)}else if(U.match(N)&&$["boolean-negation"]){if(P=U.match(N),P!==null&&Array.isArray(P)&&P.length>=2)O=P[1],l(O,m(O,W.arrays)?[!1]:!1)}else if(U.match(/^--.+/)||!$["short-option-groups"]&&U.match(/^-[^-]+/)){if(P=U.match(/^--?(.+)/),P!==null&&Array.isArray(P)&&P.length>=2)if(O=P[1],m(O,W.arrays))q=$D(q,O,B);else if(m(O,W.nargs)!==!1)q=p(q,O,B);else if(y=B[q+1],y!==void 0&&(!y.match(/^-/)||y.match(K))&&!m(O,W.bools)&&!m(O,W.counts))l(O,y),q++;else if(/^(true|false)$/.test(y))l(O,y),q++;else l(O,i(O))}else if(U.match(/^-.\..+=/)){if(P=U.match(/^-([^=]+)=([\s\S]*)$/),P!==null&&Array.isArray(P)&&P.length>=3)l(P[1],P[2])}else if(U.match(/^-.\..+/)&&!U.match(K)){if(y=B[q+1],P=U.match(/^-(.\..+)/),P!==null&&Array.isArray(P)&&P.length>=2)if(O=P[1],y!==void 0&&!y.match(/^-/)&&!m(O,W.bools)&&!m(O,W.counts))l(O,y),q++;else l(O,i(O))}else if(U.match(/^-[^-]+/)&&!U.match(K)){x=U.slice(1,-1).split(""),_=!1;for(let HD=0;HD<x.length;HD++){if(y=U.slice(HD+2),x[HD+1]&&x[HD+1]==="="){if(XD=U.slice(HD+3),O=x[HD],m(O,W.arrays))q=$D(q,O,B,XD);else if(m(O,W.nargs)!==!1)q=p(q,O,B,XD);else l(O,XD);_=!0;break}if(y==="-"){l(x[HD],y);continue}if(/[A-Za-z]/.test(x[HD])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(y)&&m(y,W.bools)===!1){l(x[HD],y),_=!0;break}if(x[HD+1]&&x[HD+1].match(/\W/)){l(x[HD],y),_=!0;break}else l(x[HD],i(x[HD]))}if(O=U.slice(-1)[0],!_&&O!=="-")if(m(O,W.arrays))q=$D(q,O,B);else if(m(O,W.nargs)!==!1)q=p(q,O,B);else if(y=B[q+1],y!==void 0&&(!/^(-|--)[^-]/.test(y)||y.match(K))&&!m(O,W.bools)&&!m(O,W.counts))l(O,y),q++;else if(/^(true|false)$/.test(y))l(O,y),q++;else l(O,i(O))}else if(U.match(/^-[0-9]$/)&&U.match(K)&&m(U.slice(1),W.bools))O=U.slice(1),l(O,i(O));else if(U==="--"){L=B.slice(q+1);break}else if($["halt-at-non-option"]){L=B.slice(q);break}else h(U)}if(CD(M,!0),CD(M,!1),f(M),o(),kD(M,W.aliases,z,!0),n(M),$["set-placeholder-key"])zD(M);if(Object.keys(W.counts).forEach(function(q){if(!r(M,q.split(".")))l(q,0)}),Q&&L.length)M[G]=[];if(L.forEach(function(q){M[G].push(q)}),$["camel-case-expansion"]&&$["strip-dashed"])Object.keys(M).filter((q)=>q!=="--"&&q.includes("-")).forEach((q)=>{delete M[q]});if($["strip-aliased"])[].concat(...Object.keys(C).map((q)=>C[q])).forEach((q)=>{if($["camel-case-expansion"]&&q.includes("-"))delete M[q.split(".").map((U)=>Fu(U)).join(".")];delete M[q]});function h(q){let U=R("_",q);if(typeof U==="string"||typeof U==="number")M._.push(U)}function p(q,U,A,_){let O,x=m(U,W.nargs);if(x=typeof x!=="number"||isNaN(x)?1:x,x===0){if(!JD(_))j=Error(H("Argument unexpected for: %s",U));return l(U,i(U)),q}let P=JD(_)?0:1;if($["nargs-eats-options"]){if(A.length-(q+1)+P<x)j=Error(H("Not enough arguments following: %s",U));P=x}else{for(O=q+1;O<A.length;O++)if(!A[O].match(/^-[^0-9]/)||A[O].match(K)||s(A[O]))P++;else break;if(P<x)j=Error(H("Not enough arguments following: %s",U))}let y=Math.min(P,x);if(!JD(_)&&y>0)l(U,_),y--;for(O=q+1;O<y+q+1;O++)l(U,A[O]);return q+y}function $D(q,U,A,_){let O=[],x=_||A[q+1],P=m(U,W.nargs);if(m(U,W.bools)&&!/^(true|false)$/.test(x))O.push(!0);else if(JD(x)||JD(_)&&/^-/.test(x)&&!K.test(x)&&!s(x)){if(z[U]!==void 0){let y=z[U];O=Array.isArray(y)?y:[y]}}else{if(!JD(_))O.push(I(U,_,!0));for(let y=q+1;y<A.length;y++){if(!$["greedy-arrays"]&&O.length>0||P&&typeof P==="number"&&O.length>=P)break;if(x=A[y],/^-/.test(x)&&!K.test(x)&&!s(x))break;q=y,O.push(I(U,x,E))}}if(typeof P==="number"&&(P&&O.length<P||isNaN(P)&&O.length===0))j=Error(H("Not enough arguments following: %s",U));return l(U,O),q}function l(q,U,A=E){if(/-/.test(q)&&$["camel-case-expansion"]){let x=q.split(".").map(function(P){return Fu(P)}).join(".");Du(q,x)}let _=I(q,U,A),O=q.split(".");if(pD(M,O,_),W.aliases[q])W.aliases[q].forEach(function(x){let P=x.split(".");pD(M,P,_)});if(O.length>1&&$["dot-notation"])(W.aliases[O[0]]||[]).forEach(function(x){let P=x.split("."),y=[].concat(O);if(y.shift(),P=P.concat(y),!(W.aliases[q]||[]).includes(P.join(".")))pD(M,P,_)});if(m(q,W.normalize)&&!m(q,W.arrays))[q].concat(W.aliases[q]||[]).forEach(function(P){Object.defineProperty(T,P,{enumerable:!0,get(){return U},set(y){U=typeof y==="string"?mD.normalize(y):y}})})}function Du(q,U){if(!(W.aliases[q]&&W.aliases[q].length))W.aliases[q]=[U],Y[U]=!0;if(!(W.aliases[U]&&W.aliases[U].length))Du(U,q)}function I(q,U,A){if(A)U=M6(U);if(m(q,W.bools)||m(q,W.counts)){if(typeof U==="string")U=U==="true"}let _=Array.isArray(U)?U.map(function(O){return R(q,O)}):R(q,U);if(m(q,W.counts)&&(JD(_)||typeof _==="boolean"))_=eF();if(m(q,W.normalize)&&m(q,W.arrays))if(Array.isArray(U))_=U.map((O)=>{return mD.normalize(O)});else _=mD.normalize(U);return _}function R(q,U){if(!$["parse-positional-numbers"]&&q==="_")return U;if(!m(q,W.strings)&&!m(q,W.bools)&&!Array.isArray(U)){if(zF(U)&&$["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${U}`)))||!JD(U)&&m(q,W.numbers))U=Number(U)}return U}function f(q){let U=Object.create(null);kD(U,W.aliases,z),Object.keys(W.configs).forEach(function(A){let _=q[A]||U[A];if(_)try{let O=null,x=mD.resolve(mD.cwd(),_),P=W.configs[A];if(typeof P==="function"){try{O=P(x)}catch(y){O=y}if(O instanceof Error){j=O;return}}else O=mD.require(x);d(O)}catch(O){if(O.name==="PermissionDenied")j=O;else if(q[A])j=Error(H("Invalid JSON config file: %s",_))}})}function d(q,U){Object.keys(q).forEach(function(A){let _=q[A],O=U?U+"."+A:A;if(typeof _==="object"&&_!==null&&!Array.isArray(_)&&$["dot-notation"])d(_,O);else if(!r(M,O.split("."))||m(O,W.arrays)&&$["combine-arrays"])l(O,_)})}function o(){if(typeof Z<"u")Z.forEach(function(q){d(q)})}function CD(q,U){if(typeof J>"u")return;let A=typeof J==="string"?J:"",_=mD.env();Object.keys(_).forEach(function(O){if(A===""||O.lastIndexOf(A,0)===0){let x=O.split("__").map(function(P,y){if(y===0)P=P.substring(A.length);return Fu(P)});if((U&&W.configs[x.join(".")]||!U)&&!r(q,x))l(x.join("."),_[O])}})}function n(q){let U,A=new Set;Object.keys(q).forEach(function(_){if(!A.has(_)){if(U=m(_,W.coercions),typeof U==="function")try{let O=R(_,U(q[_]));[].concat(W.aliases[_]||[],_).forEach((x)=>{A.add(x),q[x]=O})}catch(O){j=O}}})}function zD(q){return W.keys.forEach((U)=>{if(~U.indexOf("."))return;if(typeof q[U]>"u")q[U]=void 0}),q}function kD(q,U,A,_=!1){Object.keys(A).forEach(function(O){if(!r(q,O.split("."))){if(pD(q,O.split("."),A[O]),_)V[O]=!0;(U[O]||[]).forEach(function(x){if(r(q,x.split(".")))return;pD(q,x.split("."),A[O])})}})}function r(q,U){let A=q;if(!$["dot-notation"])U=[U.join(".")];U.slice(0,-1).forEach(function(O){A=A[O]||{}});let _=U[U.length-1];if(typeof A!=="object")return!1;else return _ in A}function pD(q,U,A){let _=q;if(!$["dot-notation"])U=[U.join(".")];U.slice(0,-1).forEach(function(XD){if(XD=r2(XD),typeof _==="object"&&_[XD]===void 0)_[XD]={};if(typeof _[XD]!=="object"||Array.isArray(_[XD])){if(Array.isArray(_[XD]))_[XD].push({});else _[XD]=[_[XD],{}];_=_[XD][_[XD].length-1]}else _=_[XD]});let O=r2(U[U.length-1]),x=m(U.join("."),W.arrays),P=Array.isArray(A),y=$["duplicate-arguments-array"];if(!y&&m(O,W.nargs)){if(y=!0,!JD(_[O])&&W.nargs[O]===1||Array.isArray(_[O])&&_[O].length===W.nargs[O])_[O]=void 0}if(A===eF())_[O]=eF(_[O]);else if(Array.isArray(_[O]))if(y&&x&&P)_[O]=$["flatten-duplicate-arrays"]?_[O].concat(A):(Array.isArray(_[O][0])?_[O]:[_[O]]).concat([A]);else if(!y&&Boolean(x)===Boolean(P))_[O]=A;else _[O]=_[O].concat([A]);else if(_[O]===void 0&&x)_[O]=P?A:[A];else if(y&&!(_[O]===void 0||m(O,W.counts)||m(O,W.bools)))_[O]=[_[O],A];else _[O]=A}function fu(...q){q.forEach(function(U){Object.keys(U||{}).forEach(function(A){if(W.aliases[A])return;W.aliases[A]=[].concat(C[A]||[]),W.aliases[A].concat(A).forEach(function(_){if(/-/.test(_)&&$["camel-case-expansion"]){let O=Fu(_);if(O!==A&&W.aliases[A].indexOf(O)===-1)W.aliases[A].push(O),Y[O]=!0}}),W.aliases[A].concat(A).forEach(function(_){if(_.length>1&&/[A-Z]/.test(_)&&$["camel-case-expansion"]){let O=$F(_,"-");if(O!==A&&W.aliases[A].indexOf(O)===-1)W.aliases[A].push(O),Y[O]=!0}}),W.aliases[A].forEach(function(_){W.aliases[_]=[A].concat(W.aliases[A].filter(function(O){return _!==O}))})})})}function m(q,U){let A=[].concat(W.aliases[q]||[],q),_=Object.keys(U),O=A.find((x)=>_.includes(x));return O?U[O]:!1}function Nu(q){let U=Object.keys(W);return[].concat(U.map((_)=>W[_])).some(function(_){return Array.isArray(_)?_.includes(q):_[q]})}function q2(q,...U){return[].concat(...U).some(function(_){let O=q.match(_);return O&&Nu(O[1])})}function g(q){if(q.match(K)||!q.match(/^-[^-]+/))return!1;let U=!0,A,_=q.slice(1).split("");for(let O=0;O<_.length;O++){if(A=q.slice(O+2),!Nu(_[O])){U=!1;break}if(_[O+1]&&_[O+1]==="="||A==="-"||/[A-Za-z]/.test(_[O])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(A)||_[O+1]&&_[O+1].match(/\W/))break}return U}function s(q){return $["unknown-options-as-args"]&&ZD(q)}function ZD(q){if(q=q.replace(/^-{3,}/,"--"),q.match(K))return!1;if(g(q))return!1;return!q2(q,/^-+([^=]+?)=[\s\S]*$/,N,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function i(q){if(!m(q,W.bools)&&!m(q,W.counts)&&`${q}`in z)return z[q];else return YD(FD(q))}function YD(q){return{[ND.BOOLEAN]:!0,[ND.STRING]:"",[ND.NUMBER]:void 0,[ND.ARRAY]:[]}[q]}function FD(q){let U=ND.BOOLEAN;if(m(q,W.strings))U=ND.STRING;else if(m(q,W.numbers))U=ND.NUMBER;else if(m(q,W.bools))U=ND.BOOLEAN;else if(m(q,W.arrays))U=ND.ARRAY;return U}function JD(q){return q===void 0}function iF(){Object.keys(W.counts).find((q)=>{if(m(q,W.arrays))return j=Error(H("Invalid configuration: %s, opts.count excludes opts.array.",q)),!0;else if(m(q,W.nargs))return j=Error(H("Invalid configuration: %s, opts.count excludes opts.narg.",q)),!0;return!1})}return{aliases:Object.assign({},W.aliases),argv:Object.assign(T,M),configuration:$,defaulted:Object.assign({},V),error:j,newAliases:Object.assign({},Y)}}}function j6(D){let u=[],F=Object.create(null),B=!0;Object.keys(D).forEach(function(E){u.push([].concat(D[E],E))});while(B){B=!1;for(let E=0;E<u.length;E++)for(let C=E+1;C<u.length;C++)if(u[E].filter(function(z){return u[C].indexOf(z)!==-1}).length){u[E]=u[E].concat(u[C]),u.splice(C,1),B=!0;break}}return u.forEach(function(E){E=E.filter(function($,z,Z){return Z.indexOf($)===z});let C=E.pop();if(C!==void 0&&typeof C==="string")F[C]=E}),F}function eF(D){return D!==void 0?D+1:1}function r2(D){if(D==="__proto__")return"___proto___";return D}function M6(D){return typeof D==="string"&&(D[0]==="'"||D[0]==='"')&&D[D.length-1]===D[0]?D.substring(1,D.length-1):D}import{readFileSync as L6}from"fs";import{createRequire as a2}from"node:module";var u0,F0,E0,e2=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,D8=(F0=(u0=process===null||process===void 0?void 0:process.versions)===null||u0===void 0?void 0:u0.node)!==null&&F0!==void 0?F0:(E0=process===null||process===void 0?void 0:process.version)===null||E0===void 0?void 0:E0.slice(1);if(D8){if(Number(D8.match(/^([^.]+)/)[1])<e2)throw Error(`yargs parser supports a minimum Node.js version of ${e2}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var T6=process?process.env:{},u8=a2?a2(import.meta.url):void 0,F8=new D0({cwd:process.cwd,env:()=>{return T6},format:_6,normalize:N6,resolve:A6,require:(D)=>{if(typeof u8<"u")return u8(D);else if(D.match(/\.json$/))return JSON.parse(L6(D,"utf8"));else throw Error("only .json config files are supported in ESM")}}),hu=function(u,F){return F8.parse(u.slice(),F).argv};hu.detailed=function(D,u){return F8.parse(D.slice(),u)};hu.camelCase=Fu;hu.decamelize=$F;hu.looksLikeNumber=zF;var B0=hu;import{basename as p6,dirname as m6,extname as g6,relative as c6,resolve as X8,join as d6}from"path";function E8(){if(R6())return 0;return 1}function R6(){return P6()&&!process.defaultApp}function P6(){return!!process.versions.electron}function C0(D){return D.slice(E8()+1)}function B8(){return process.argv[E8()]}import{readFileSync as S6,statSync as w6,writeFile as x6}from"fs";import{format as I6}from"util";import{resolve as b6}from"path";var C8={fs:{readFileSync:S6,writeFile:x6},format:I6,resolve:b6,exists:(D)=>{try{return w6(D).isFile()}catch(u){return!1}}};var PD;class $8{constructor(D){D=D||{},this.directory=D.directory||"./locales",this.updateFiles=typeof D.updateFiles==="boolean"?D.updateFiles:!0,this.locale=D.locale||"en",this.fallbackToLanguage=typeof D.fallbackToLanguage==="boolean"?D.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...D){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let u=D.shift(),F=function(){};if(typeof D[D.length-1]==="function")F=D.pop();if(F=F||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][u]&&this.updateFiles)this.cache[this.locale][u]=u,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:F});else F();return PD.format.apply(PD.format,[this.cache[this.locale][u]||u].concat(D))}__n(){let D=Array.prototype.slice.call(arguments),u=D.shift(),F=D.shift(),B=D.shift(),E=function(){};if(typeof D[D.length-1]==="function")E=D.pop();if(!this.cache[this.locale])this._readLocaleFile();let C=B===1?u:F;if(this.cache[this.locale][u])C=this.cache[this.locale][u][B===1?"one":"other"];if(!this.cache[this.locale][u]&&this.updateFiles)this.cache[this.locale][u]={one:u,other:F},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:E});else E();let $=[C];if(~C.indexOf("%d"))$.push(B);return PD.format.apply(PD.format,$.concat(D))}setLocale(D){this.locale=D}getLocale(){return this.locale}updateLocale(D){if(!this.cache[this.locale])this._readLocaleFile();for(let u in D)if(Object.prototype.hasOwnProperty.call(D,u))this.cache[this.locale][u]=D[u]}_taggedLiteral(D,...u){let F="";return D.forEach(function(B,E){let C=u[E+1];if(F+=B,typeof C<"u")F+="%s"}),this.__.apply(this,[F].concat([].slice.call(u,1)))}_enqueueWrite(D){if(this.writeQueue.push(D),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let D=this,u=this.writeQueue[0],F=u.directory,B=u.locale,E=u.cb,C=this._resolveLocaleFile(F,B),$=JSON.stringify(this.cache[B],null,2);PD.fs.writeFile(C,$,"utf-8",function(z){if(D.writeQueue.shift(),D.writeQueue.length>0)D._processWriteQueue();E(z)})}_readLocaleFile(){let D={},u=this._resolveLocaleFile(this.directory,this.locale);try{if(PD.fs.readFileSync)D=JSON.parse(PD.fs.readFileSync(u,"utf-8"))}catch(F){if(F instanceof SyntaxError)F.message="syntax error in "+u;if(F.code==="ENOENT")D={};else throw F}this.cache[this.locale]=D}_resolveLocaleFile(D,u){let F=PD.resolve(D,"./",u+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(F)&&~u.lastIndexOf("_")){let B=PD.resolve(D,"./",u.split("_")[0]+".json");if(this._fileExistsSync(B))F=B}return F}_fileExistsSync(D){return PD.exists(D)}}function z8(D,u){PD=u;let F=new $8(D);return{__:F.__.bind(F),__n:F.__n.bind(F),setLocale:F.setLocale.bind(F),getLocale:F.getLocale.bind(F),updateLocale:F.updateLocale.bind(F),locale:F.locale}}var f6=(D)=>{return z8(D,C8)},Z8=f6;var Y8=O2(G8(),1);import{createRequire as k6}from"node:module";import{readFileSync as i6,readdirSync as l6}from"node:fs";var $0=Q8(import.meta.url),n6=$0.substring(0,$0.lastIndexOf("node_modules")),t6=k6(import.meta.url),z0={assert:{notStrictEqual:h6,strictEqual:v6},cliui:rF,findUp:aF,getEnv:(D)=>{return process.env[D]},inspect:y6,getProcessArgvBin:B8,mainFilename:n6||process.cwd(),Parser:B0,path:{basename:p6,dirname:m6,extname:g6,relative:c6,resolve:X8,join:d6},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(D,u)=>process.emitWarning(D,u),execPath:()=>process.execPath,exit:(D)=>{process.exit(D)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:i6,readdirSync:l6,require:t6,getCallerFile:()=>{let D=Y8.default(3);return D.match(/^file:\/\//)?Q8(D):D},stringWidth:RD,y18n:Z8({directory:X8($0,"../../../locales"),updateFiles:!1})};function qD(D,u,F,B){F.assert.notStrictEqual(D,u,B)}function Z0(D,u){u.assert.strictEqual(typeof D,"string")}function Au(D){return Object.keys(D)}function a(D){return!!D&&!!D.then&&typeof D.then==="function"}class ED extends Error{constructor(D){super(D||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,ED)}}function iD(D){let F=D.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),B=/\.*[\][<>]/g,E=F.shift();if(!E)throw Error(`No command found in: ${D}`);let C={cmd:E.replace(B,""),demanded:[],optional:[]};return F.forEach(($,z)=>{let Z=!1;if($=$.replace(/\s/g,""),/\.+[\]>]/.test($)&&z===F.length-1)Z=!0;if(/^\[/.test($))C.optional.push({cmd:$.replace(B,"").split("|"),variadic:Z});else C.demanded.push({cmd:$.replace(B,"").split("|"),variadic:Z})}),C}var o6=["first","second","third","fourth","fifth","sixth"];function S(D,u,F){function B(){return typeof D==="object"?[{demanded:[],optional:[]},D,u]:[iD(`cmd ${D}`),u,F]}try{let E=0,[C,$,z]=B(),Z=[].slice.call($);while(Z.length&&Z[Z.length-1]===void 0)Z.pop();let J=z||Z.length;if(J<C.demanded.length)throw new ED(`Not enough arguments provided. Expected ${C.demanded.length} but received ${Z.length}.`);let Q=C.demanded.length+C.optional.length;if(J>Q)throw new ED(`Too many arguments provided. Expected max ${Q} but received ${J}.`);C.demanded.forEach((G)=>{let Y=Z.shift(),V=W8(Y);if(G.cmd.filter((W)=>W===V||W==="*").length===0)V8(V,G.cmd,E);E+=1}),C.optional.forEach((G)=>{if(Z.length===0)return;let Y=Z.shift(),V=W8(Y);if(G.cmd.filter((W)=>W===V||W==="*").length===0)V8(V,G.cmd,E);E+=1})}catch(E){console.warn(E.stack)}}function W8(D){if(Array.isArray(D))return"array";else if(D===null)return"null";return typeof D}function V8(D,u,F){throw new ED(`Invalid ${o6[F]||"manyith"} argument. Expected ${u.join(" or ")} but received ${D}.`)}class J0{constructor(D){this.globalMiddleware=[],this.frozens=[],this.yargs=D}addMiddleware(D,u,F=!0,B=!1){if(S("<array|function> [boolean] [boolean] [boolean]",[D,u,F],arguments.length),Array.isArray(D)){for(let E=0;E<D.length;E++){if(typeof D[E]!=="function")throw Error("middleware must be a function");let C=D[E];C.applyBeforeValidation=u,C.global=F}Array.prototype.push.apply(this.globalMiddleware,D)}else if(typeof D==="function"){let E=D;E.applyBeforeValidation=u,E.global=F,E.mutates=B,this.globalMiddleware.push(D)}return this.yargs}addCoerceMiddleware(D,u){let F=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((B)=>{let E=[...F[u]||[],u];if(!B.option)return!0;else return!E.includes(B.option)}),D.option=u,this.addMiddleware(D,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let D=this.frozens.pop();if(D!==void 0)this.globalMiddleware=D}reset(){this.globalMiddleware=this.globalMiddleware.filter((D)=>D.global)}}function H8(D){if(!D)return[];return D.map((u)=>{return u.applyBeforeValidation=!1,u})}function Eu(D,u,F,B){return F.reduce((E,C)=>{if(C.applyBeforeValidation!==B)return E;if(C.mutates){if(C.applied)return E;C.applied=!0}if(a(E))return E.then(($)=>Promise.all([$,C($,u)])).then(([$,z])=>Object.assign($,z));else{let $=C(E,u);return a($)?$.then((z)=>Object.assign(E,z)):Object.assign(E,$)}},D)}function Bu(D,u,F=(B)=>{throw B}){try{let B=s6(D)?D():D;return a(B)?B.then((E)=>u(E)):u(B)}catch(B){return F(B)}}function s6(D){return typeof D==="function"}var Lu=/(^\*)|(^\$0)/;class K8{constructor(D,u,F,B){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=B,this.usage=D,this.globalMiddleware=F,this.validation=u}addDirectory(D,u,F,B){B=B||{},this.requireCache.add(F);let E=this.shim.path.resolve(this.shim.path.dirname(F),D),C=this.shim.readdirSync(E,{recursive:B.recurse?!0:!1});if(!Array.isArray(B.extensions))B.extensions=["js"];let $=typeof B.visit==="function"?B.visit:(z)=>z;for(let z of C){let Z=z.toString();if(B.exclude){let Q=!1;if(typeof B.exclude==="function")Q=B.exclude(Z);else Q=B.exclude.test(Z);if(Q)continue}if(B.include){let Q=!1;if(typeof B.include==="function")Q=B.include(Z);else Q=B.include.test(Z);if(!Q)continue}let J=!1;for(let Q of B.extensions)if(Z.endsWith(Q))J=!0;if(J){let Q=this.shim.path.join(E,Z),G=u(Q),Y=Object.create(null,Object.getOwnPropertyDescriptors({...G}));if($(Y,Q,Z)){if(this.requireCache.has(Q))continue;else this.requireCache.add(Q);if(!Y.command)Y.command=this.shim.path.basename(Q,this.shim.path.extname(Q));this.addHandler(Y)}}}}addHandler(D,u,F,B,E,C){let $=[],z=H8(E);if(B=B||(()=>{}),Array.isArray(D))if(r6(D))[D,...$]=D;else for(let Z of D)this.addHandler(Z);else if(e6(D)){let Z=Array.isArray(D.command)||typeof D.command==="string"?D.command:null;if(Z===null)throw Error(`No command name given for module: ${this.shim.inspect(D)}`);if(D.aliases)Z=[].concat(Z).concat(D.aliases);this.addHandler(Z,this.extractDesc(D),D.builder,D.handler,D.middlewares,D.deprecated);return}else if(q8(F)){this.addHandler([D].concat($),u,F.builder,F.handler,F.middlewares,F.deprecated);return}if(typeof D==="string"){let Z=iD(D);$=$.map((G)=>iD(G).cmd);let J=!1,Q=[Z.cmd].concat($).filter((G)=>{if(Lu.test(G))return J=!0,!1;return!0});if(Q.length===0&&J)Q.push("$0");if(J)Z.cmd=Q[0],$=Q.slice(1),D=D.replace(Lu,Z.cmd);if($.forEach((G)=>{this.aliasMap[G]=Z.cmd}),u!==!1)this.usage.command(D,u,J,$,C);if(this.handlers[Z.cmd]={original:D,description:u,handler:B,builder:F||{},middlewares:z,deprecated:C,demanded:Z.demanded,optional:Z.optional},J)this.defaultCommand=this.handlers[Z.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(D,u,F,B,E,C){let $=this.handlers[D]||this.handlers[this.aliasMap[D]]||this.defaultCommand,z=u.getInternalMethods().getContext(),Z=z.commands.slice(),J=!D;if(D)z.commands.push(D),z.fullCommands.push($.original);let Q=this.applyBuilderUpdateUsageAndParse(J,$,u,F.aliases,Z,B,E,C);return a(Q)?Q.then((G)=>this.applyMiddlewareAndGetResult(J,$,G.innerArgv,z,E,G.aliases,u)):this.applyMiddlewareAndGetResult(J,$,Q.innerArgv,z,E,Q.aliases,u)}applyBuilderUpdateUsageAndParse(D,u,F,B,E,C,$,z){let Z=u.builder,J=F;if(ZF(Z)){F.getInternalMethods().getUsageInstance().freeze();let Q=Z(F.getInternalMethods().reset(B),z);if(a(Q))return Q.then((G)=>{return J=U8(G)?G:F,this.parseAndUpdateUsage(D,u,J,E,C,$)})}else if(a6(Z))F.getInternalMethods().getUsageInstance().freeze(),J=F.getInternalMethods().reset(B),Object.keys(u.builder).forEach((Q)=>{J.option(Q,Z[Q])});return this.parseAndUpdateUsage(D,u,J,E,C,$)}parseAndUpdateUsage(D,u,F,B,E,C){if(D)F.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(F))F.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(B,u),u.description);let $=F.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,E,C);return a($)?$.then((z)=>({aliases:F.parsed.aliases,innerArgv:z})):{aliases:F.parsed.aliases,innerArgv:$}}shouldUpdateUsage(D){return!D.getInternalMethods().getUsageInstance().getUsageDisabled()&&D.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(D,u){let F=Lu.test(u.original)?u.original.replace(Lu,"").trim():u.original,B=D.filter((E)=>{return!Lu.test(E)});return B.push(F),`$0 ${B.join(" ")}`}handleValidationAndGetResult(D,u,F,B,E,C,$,z){if(!C.getInternalMethods().getHasOutput()){let Z=C.getInternalMethods().runValidation(E,z,C.parsed.error,D);F=Bu(F,(J)=>{return Z(J),J})}if(u.handler&&!C.getInternalMethods().getHasOutput()){C.getInternalMethods().setHasOutput();let Z=!!C.getOptions().configuration["populate--"];if(C.getInternalMethods().postProcess(F,Z,!1,!1),F=Eu(F,C,$,!1),F=Bu(F,(J)=>{let Q=u.handler(J);return a(Q)?Q.then(()=>J):J}),!D)C.getInternalMethods().getUsageInstance().cacheHelpMessage();if(a(F)&&!C.getInternalMethods().hasParseCallback())F.catch((J)=>{try{C.getInternalMethods().getUsageInstance().fail(null,J)}catch(Q){}})}if(!D)B.commands.pop(),B.fullCommands.pop();return F}applyMiddlewareAndGetResult(D,u,F,B,E,C,$){let z={};if(E)return F;if(!$.getInternalMethods().getHasOutput())z=this.populatePositionals(u,F,B,$);let Z=this.globalMiddleware.getMiddleware().slice(0).concat(u.middlewares),J=Eu(F,$,Z,!0);return a(J)?J.then((Q)=>this.handleValidationAndGetResult(D,u,Q,B,C,$,Z,z)):this.handleValidationAndGetResult(D,u,J,B,C,$,Z,z)}populatePositionals(D,u,F,B){u._=u._.slice(F.commands.length);let E=D.demanded.slice(0),C=D.optional.slice(0),$={};this.validation.positionalCount(E.length,u._.length);while(E.length){let z=E.shift();this.populatePositional(z,u,$)}while(C.length){let z=C.shift();this.populatePositional(z,u,$)}return u._=F.commands.concat(u._.map((z)=>""+z)),this.postProcessPositionals(u,$,this.cmdToParseOptions(D.original),B),$}populatePositional(D,u,F){let B=D.cmd[0];if(D.variadic)F[B]=u._.splice(0).map(String);else if(u._.length)F[B]=[String(u._.shift())]}cmdToParseOptions(D){let u={array:[],default:{},alias:{},demand:{}},F=iD(D);return F.demanded.forEach((B)=>{let[E,...C]=B.cmd;if(B.variadic)u.array.push(E),u.default[E]=[];u.alias[E]=C,u.demand[E]=!0}),F.optional.forEach((B)=>{let[E,...C]=B.cmd;if(B.variadic)u.array.push(E),u.default[E]=[];u.alias[E]=C}),u}postProcessPositionals(D,u,F,B){let E=Object.assign({},B.getOptions());E.default=Object.assign(F.default,E.default);for(let Z of Object.keys(F.alias))E.alias[Z]=(E.alias[Z]||[]).concat(F.alias[Z]);E.array=E.array.concat(F.array),E.config={};let C=[];if(Object.keys(u).forEach((Z)=>{u[Z].map((J)=>{if(E.configuration["unknown-options-as-args"])E.key[Z]=!0;C.push(`--${Z}`),C.push(J)})}),!C.length)return;let $=Object.assign({},E.configuration,{"populate--":!1}),z=this.shim.Parser.detailed(C,Object.assign({},E,{configuration:$}));if(z.error)B.getInternalMethods().getUsageInstance().fail(z.error.message,z.error);else{let Z=Object.keys(u);Object.keys(u).forEach((J)=>{Z.push(...z.aliases[J])}),Object.keys(z.argv).forEach((J)=>{if(Z.includes(J)){if(!u[J])u[J]=z.argv[J];if(!this.isInConfigs(B,J)&&!this.isDefaulted(B,J)&&Object.prototype.hasOwnProperty.call(D,J)&&Object.prototype.hasOwnProperty.call(z.argv,J)&&(Array.isArray(D[J])||Array.isArray(z.argv[J])))D[J]=[].concat(D[J],z.argv[J]);else D[J]=z.argv[J]}})}}isDefaulted(D,u){let{default:F}=D.getOptions();return Object.prototype.hasOwnProperty.call(F,u)||Object.prototype.hasOwnProperty.call(F,this.shim.Parser.camelCase(u))}isInConfigs(D,u){let{configObjects:F}=D.getOptions();return F.some((B)=>Object.prototype.hasOwnProperty.call(B,u))||F.some((B)=>Object.prototype.hasOwnProperty.call(B,this.shim.Parser.camelCase(u)))}runDefaultBuilderOn(D){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(D)){let F=Lu.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");D.getInternalMethods().getUsageInstance().usage(F,this.defaultCommand.description)}let u=this.defaultCommand.builder;if(ZF(u))return u(D,!0);else if(!q8(u))Object.keys(u).forEach((F)=>{D.option(F,u[F])});return}extractDesc({describe:D,description:u,desc:F}){for(let B of[D,u,F]){if(typeof B==="string"||B===!1)return B;qD(B,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let D=this.frozens.pop();qD(D,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=D}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function O8(D,u,F,B){return new K8(D,u,F,B)}function q8(D){return typeof D==="object"&&!!D.builder&&typeof D.handler==="function"}function r6(D){return D.every((u)=>typeof u==="string")}function ZF(D){return typeof D==="function"}function a6(D){return typeof D==="object"}function e6(D){return typeof D==="object"&&!Array.isArray(D)}function lD(D={},u=()=>!0){let F={};return Au(D).forEach((B)=>{if(u(B,D[B]))F[B]=D[B]}),F}function nD(D){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((u)=>{let F=u;if(F._handle&&F.isTTY&&typeof F._handle.setBlocking==="function")F._handle.setBlocking(D)})}function D7(D){return typeof D==="boolean"}function M8(D,u){let F=u.y18n.__,B={},E=[];B.failFn=function(R){E.push(R)};let C=null,$=null,z=!0;B.showHelpOnFail=function(R=!0,f){let[d,o]=typeof R==="string"?[!0,R]:[R,f];if(D.getInternalMethods().isGlobalContext())$=o;return C=o,z=d,B};let Z=!1;B.fail=function(R,f){let d=D.getInternalMethods().getLoggerInstance();if(E.length)for(let o=E.length-1;o>=0;--o){let CD=E[o];if(D7(CD)){if(f)throw f;else if(R)throw Error(R)}else CD(R,f,B)}else{if(D.getExitProcess())nD(!0);if(!Z){if(Z=!0,z)D.showHelp("error"),d.error();if(R||f)d.error(R||f);let o=C||$;if(o){if(R||f)d.error("");d.error(o)}}if(f=f||new ED(R),D.getExitProcess())return D.exit(1);else if(D.getInternalMethods().hasParseCallback())return D.exit(1,f);else throw f}};let J=[],Q=!1;B.usage=(I,R)=>{if(I===null)return Q=!0,J=[],B;return Q=!1,J.push([I,R||""]),B},B.getUsage=()=>{return J},B.getUsageDisabled=()=>{return Q},B.getPositionalGroupName=()=>{return F("Positionals:")};let G=[];B.example=(I,R)=>{G.push([I,R||""])};let Y=[];B.command=function(R,f,d,o,CD=!1){if(d)Y=Y.map((n)=>{return n[2]=!1,n});Y.push([R,f||"",d,o,CD])},B.getCommands=()=>Y;let V={};B.describe=function(R,f){if(Array.isArray(R))R.forEach((d)=>{B.describe(d,f)});else if(typeof R==="object")Object.keys(R).forEach((d)=>{B.describe(d,R[d])});else V[R]=f},B.getDescriptions=()=>V;let H=[];B.epilog=(I)=>{H.push(I)};let W=!1,K;B.wrap=(I)=>{W=!0,K=I},B.getWrap=()=>{if(u.getEnv("YARGS_DISABLE_WRAP"))return null;if(!W)K=$D(),W=!0;return K};let N="__yargsString__:";B.deferY18nLookup=(I)=>N+I,B.help=function(){if(M)return M;L();let R=D.customScriptName?D.$0:u.path.basename(D.$0),f=D.getDemandedOptions(),d=D.getDemandedCommands(),o=D.getDeprecatedOptions(),CD=D.getGroups(),n=D.getOptions(),zD=[];zD=zD.concat(Object.keys(V)),zD=zD.concat(Object.keys(f)),zD=zD.concat(Object.keys(d)),zD=zD.concat(Object.keys(n.default)),zD=zD.filter(h),zD=Object.keys(zD.reduce((g,s)=>{if(s!=="_")g[s]=!0;return g},{}));let kD=B.getWrap(),r=u.cliui({width:kD,wrap:!!kD});if(!Q){if(J.length)J.forEach((g)=>{if(r.div({text:`${g[0].replace(/\$0/g,R)}`}),g[1])r.div({text:`${g[1]}`,padding:[1,0,0,0]})}),r.div();else if(Y.length){let g=null;if(d._)g=`${R} <${F("command")}>
|
|
15
15
|
`;else g=`${R} [${F("command")}]
|
|
16
|
-
`;r.div(`${g}`)}}if(Y.length>1||Y.length===1&&!Y[0][2]){r.div(F("Commands:"));let g=D.getInternalMethods().getContext(),s=g.commands.length?`${g.commands.join(" ")} `:"";if(D.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)Y=Y.sort((i,YD)=>i[0].localeCompare(YD[0]));let ZD=R?`${R} `:"";Y.forEach((i)=>{let YD=`${ZD}${s}${i[0].replace(/^\$0 ?/,"")}`;r.span({text:YD,padding:[0,2,0,2],width:j(Y,kD,`${R}${s}`)+4},{text:i[1]});let FD=[];if(i[2])FD.push(`[${F("default")}]`);if(i[3]&&i[3].length)FD.push(`[${F("aliases:")} ${i[3].join(", ")}]`);if(i[4])if(typeof i[4]==="string")FD.push(`[${F("deprecated: %s",i[4])}]`);else FD.push(`[${F("deprecated")}]`);if(FD.length)r.div({text:FD.join(" "),padding:[0,0,0,2],align:"right"});else r.div()}),r.div()}let pD=(Object.keys(n.alias)||[]).concat(Object.keys(D.parsed.newAliases)||[]);zD=zD.filter((g)=>!D.parsed.newAliases[g]&&pD.every((s)=>(n.alias[s]||[]).indexOf(g)===-1));let fu=F("Options:");if(!CD[fu])CD[fu]=[];T(zD,n.alias,CD,fu);let m=(g)=>/^--/.test(JF(g)),Nu=Object.keys(CD).filter((g)=>CD[g].length>0).map((g)=>{let s=CD[g].filter(
|
|
16
|
+
`;r.div(`${g}`)}}if(Y.length>1||Y.length===1&&!Y[0][2]){r.div(F("Commands:"));let g=D.getInternalMethods().getContext(),s=g.commands.length?`${g.commands.join(" ")} `:"";if(D.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)Y=Y.sort((i,YD)=>i[0].localeCompare(YD[0]));let ZD=R?`${R} `:"";Y.forEach((i)=>{let YD=`${ZD}${s}${i[0].replace(/^\$0 ?/,"")}`;r.span({text:YD,padding:[0,2,0,2],width:j(Y,kD,`${R}${s}`)+4},{text:i[1]});let FD=[];if(i[2])FD.push(`[${F("default")}]`);if(i[3]&&i[3].length)FD.push(`[${F("aliases:")} ${i[3].join(", ")}]`);if(i[4])if(typeof i[4]==="string")FD.push(`[${F("deprecated: %s",i[4])}]`);else FD.push(`[${F("deprecated")}]`);if(FD.length)r.div({text:FD.join(" "),padding:[0,0,0,2],align:"right"});else r.div()}),r.div()}let pD=(Object.keys(n.alias)||[]).concat(Object.keys(D.parsed.newAliases)||[]);zD=zD.filter((g)=>!D.parsed.newAliases[g]&&pD.every((s)=>(n.alias[s]||[]).indexOf(g)===-1));let fu=F("Options:");if(!CD[fu])CD[fu]=[];T(zD,n.alias,CD,fu);let m=(g)=>/^--/.test(JF(g)),Nu=Object.keys(CD).filter((g)=>CD[g].length>0).map((g)=>{let s=CD[g].filter(h).map((ZD)=>{if(pD.includes(ZD))return ZD;for(let i=0,YD;(YD=pD[i])!==void 0;i++)if((n.alias[YD]||[]).includes(ZD))return YD;return ZD});return{groupName:g,normalizedKeys:s}}).filter(({normalizedKeys:g})=>g.length>0).map(({groupName:g,normalizedKeys:s})=>{let ZD=s.reduce((i,YD)=>{return i[YD]=[YD].concat(n.alias[YD]||[]).map((FD)=>{if(g===B.getPositionalGroupName())return FD;else return(/^[0-9]$/.test(FD)?n.boolean.includes(YD)?"-":"--":FD.length>1?"--":"-")+FD}).sort((FD,JD)=>m(FD)===m(JD)?0:m(FD)?1:-1).join(", "),i},{});return{groupName:g,normalizedKeys:s,switches:ZD}});if(Nu.filter(({groupName:g})=>g!==B.getPositionalGroupName()).some(({normalizedKeys:g,switches:s})=>!g.every((ZD)=>m(s[ZD]))))Nu.filter(({groupName:g})=>g!==B.getPositionalGroupName()).forEach(({normalizedKeys:g,switches:s})=>{g.forEach((ZD)=>{if(m(s[ZD]))s[ZD]=u7(s[ZD],4)})});if(Nu.forEach(({groupName:g,normalizedKeys:s,switches:ZD})=>{r.div(g),s.forEach((i)=>{let YD=ZD[i],FD=V[i]||"",JD=null;if(FD.includes(N))FD=F(FD.substring(N.length));if(n.boolean.includes(i))JD=`[${F("boolean")}]`;if(n.count.includes(i))JD=`[${F("count")}]`;if(n.string.includes(i))JD=`[${F("string")}]`;if(n.normalize.includes(i))JD=`[${F("string")}]`;if(n.array.includes(i))JD=`[${F("array")}]`;if(n.number.includes(i))JD=`[${F("number")}]`;let iF=(A)=>typeof A==="string"?`[${F("deprecated: %s",A)}]`:`[${F("deprecated")}]`,q=[i in o?iF(o[i]):null,JD,i in f?`[${F("required")}]`:null,n.choices&&n.choices[i]?`[${F("choices:")} ${B.stringifiedValues(n.choices[i])}]`:null,p(n.default[i],n.defaultDescription[i])].filter(Boolean).join(" ");r.span({text:JF(YD),padding:[0,2,0,2+j8(YD)],width:j(ZD,kD)+4},FD);let U=D.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(q&&!U)r.div({text:q,padding:[0,0,0,2],align:"right"});else r.div()}),r.div()}),G.length)r.div(F("Examples:")),G.forEach((g)=>{g[0]=g[0].replace(/\$0/g,R)}),G.forEach((g)=>{if(g[1]==="")r.div({text:g[0],padding:[0,2,0,2]});else r.div({text:g[0],padding:[0,2,0,2],width:j(G,kD)+4},{text:g[1]})}),r.div();if(H.length>0){let g=H.map((s)=>s.replace(/\$0/g,R)).join(`
|
|
17
17
|
`);r.div(`${g}
|
|
18
|
-
`)}return r.toString().replace(/\s*$/,"")};function j(I,R,
|
|
18
|
+
`)}return r.toString().replace(/\s*$/,"")};function j(I,R,f){let d=0;if(!Array.isArray(I))I=Object.values(I).map((o)=>[o]);if(I.forEach((o)=>{d=Math.max(u.stringWidth(f?`${f} ${JF(o[0])}`:JF(o[0]))+j8(o[0]),d)}),R)d=Math.min(d,parseInt((R*0.5).toString(),10));return d}function L(){let I=D.getDemandedOptions(),R=D.getOptions();(Object.keys(R.alias)||[]).forEach((f)=>{R.alias[f].forEach((d)=>{if(V[d])B.describe(f,V[d]);if(d in I)D.demandOption(f,I[d]);if(R.boolean.includes(d))D.boolean(f);if(R.count.includes(d))D.count(f);if(R.string.includes(d))D.string(f);if(R.normalize.includes(d))D.normalize(f);if(R.array.includes(d))D.array(f);if(R.number.includes(d))D.number(f)})})}let M;B.cacheHelpMessage=function(){M=this.help()},B.clearCachedHelpMessage=function(){M=void 0},B.hasCachedHelpMessage=function(){return!!M};function T(I,R,f,d){let o=[],CD=null;return Object.keys(f).forEach((n)=>{o=o.concat(f[n])}),I.forEach((n)=>{if(CD=[n].concat(R[n]),!CD.some((zD)=>o.indexOf(zD)!==-1))f[d].push(n)}),o}function h(I){return D.getOptions().hiddenOptions.indexOf(I)<0||D.parsed.argv[D.getOptions().showHiddenOpt]}B.showHelp=(I)=>{let R=D.getInternalMethods().getLoggerInstance();if(!I)I="error";(typeof I==="function"?I:R[I])(B.help())},B.functionDescription=(I)=>{return["(",I.name?u.Parser.decamelize(I.name,"-"):F("generated-value"),")"].join("")},B.stringifiedValues=function(R,f){let d="",o=f||", ",CD=[].concat(R);if(!R||!CD.length)return d;return CD.forEach((n)=>{if(d.length)d+=o;d+=JSON.stringify(n)}),d};function p(I,R){let f=`[${F("default:")} `;if(I===void 0&&!R)return null;if(R)f+=R;else switch(typeof I){case"string":f+=`"${I}"`;break;case"object":f+=JSON.stringify(I);break;default:f+=I}return`${f}]`}function $D(){if(u.process.stdColumns)return Math.min(80,u.process.stdColumns);else return 80}let l=null;B.version=(I)=>{l=I},B.showVersion=(I)=>{let R=D.getInternalMethods().getLoggerInstance();if(!I)I="error";(typeof I==="function"?I:R[I])(l)},B.reset=function(R){return C=null,Z=!1,J=[],Q=!1,H=[],G=[],Y=[],V=lD(V,(f)=>!R[f]),B};let Du=[];return B.freeze=function(){Du.push({failMessage:C,failureOutput:Z,usages:J,usageDisabled:Q,epilogs:H,examples:G,commands:Y,descriptions:V})},B.unfreeze=function(R=!1){let f=Du.pop();if(!f)return;if(R)V={...f.descriptions,...V},Y=[...f.commands,...Y],J=[...f.usages,...J],G=[...f.examples,...G],H=[...f.epilogs,...H];else({failMessage:C,failureOutput:Z,usages:J,usageDisabled:Q,epilogs:H,examples:G,commands:Y,descriptions:V}=f)},B}function G0(D){return typeof D==="object"}function u7(D,u){return G0(D)?{text:D.text,indentation:D.indentation+u}:{text:D,indentation:u}}function j8(D){return G0(D)?D.indentation:0}function JF(D){return G0(D)?D.text:D}var _8=`###-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
|
+
`,N8=`#compdef {{app_name}}
|
|
48
48
|
###-begin-{{app_name}}-completions-###
|
|
49
49
|
#
|
|
50
50
|
# yargs command completion script
|
|
@@ -71,103 +71,103 @@ else
|
|
|
71
71
|
compdef _{{app_name}}_yargs_completions {{app_name}}
|
|
72
72
|
fi
|
|
73
73
|
###-end-{{app_name}}-completions-###
|
|
74
|
-
`;class
|
|
74
|
+
`;class A8{constructor(D,u,F,B){var E,C,$;this.yargs=D,this.usage=u,this.command=F,this.shim=B,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=($=((E=this.shim.getEnv("SHELL"))===null||E===void 0?void 0:E.includes("zsh"))||((C=this.shim.getEnv("ZSH_NAME"))===null||C===void 0?void 0:C.includes("zsh")))!==null&&$!==void 0?$:!1}defaultCompletion(D,u,F,B){let E=this.command.getCommandHandlers();for(let $=0,z=D.length;$<z;++$)if(E[D[$]]&&E[D[$]].builder){let Z=E[D[$]].builder;if(ZF(Z)){this.indexAfterLastReset=$+1;let J=this.yargs.getInternalMethods().reset();return Z(J,!0),J.argv}}let C=[];this.commandCompletions(C,D,F),this.optionCompletions(C,D,u,F),this.choicesFromOptionsCompletions(C,D,u,F),this.choicesFromPositionalsCompletions(C,D,u,F),B(null,C)}commandCompletions(D,u,F){let B=this.yargs.getInternalMethods().getContext().commands;if(!F.match(/^-/)&&B[B.length-1]!==F&&!this.previousArgHasChoices(u))this.usage.getCommands().forEach((E)=>{let C=iD(E[0]).cmd;if(u.indexOf(C)===-1)if(!this.zshShell)D.push(C);else{let $=E[1]||"";D.push(C.replace(/:/g,"\\:")+":"+$)}})}optionCompletions(D,u,F,B){if((B.match(/^-/)||B===""&&D.length===0)&&!this.previousArgHasChoices(u)){let E=this.yargs.getOptions(),C=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(E.key).forEach(($)=>{let z=!!E.configuration["boolean-negation"]&&E.boolean.includes($);if(!C.includes($)&&!E.hiddenOptions.includes($)&&!this.argsContainKey(u,$,z))this.completeOptionKey($,D,B,z&&!!E.default[$])})}}choicesFromOptionsCompletions(D,u,F,B){if(this.previousArgHasChoices(u)){let E=this.getPreviousArgChoices(u);if(E&&E.length>0)D.push(...E.map((C)=>C.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(D,u,F,B){if(B===""&&D.length>0&&this.previousArgHasChoices(u))return;let E=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],C=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),$=E[F._.length-C-1];if(!$)return;let z=this.yargs.getOptions().choices[$]||[];for(let Z of z)if(Z.startsWith(B))D.push(Z.replace(/:/g,"\\:"))}getPreviousArgChoices(D){if(D.length<1)return;let u=D[D.length-1],F="";if(!u.startsWith("-")&&D.length>1)F=u,u=D[D.length-2];if(!u.startsWith("-"))return;let B=u.replace(/^-+/,""),E=this.yargs.getOptions(),C=[B,...this.yargs.getAliases()[B]||[]],$;for(let z of C)if(Object.prototype.hasOwnProperty.call(E.key,z)&&Array.isArray(E.choices[z])){$=E.choices[z];break}if($)return $.filter((z)=>!F||z.startsWith(F))}previousArgHasChoices(D){let u=this.getPreviousArgChoices(D);return u!==void 0&&u.length>0}argsContainKey(D,u,F){let B=(E)=>D.indexOf((/^[^0-9]$/.test(E)?"-":"--")+E)!==-1;if(B(u))return!0;if(F&&B(`no-${u}`))return!0;if(this.aliases){for(let E of this.aliases[u])if(B(E))return!0}return!1}completeOptionKey(D,u,F,B){var E,C,$,z;let Z=D;if(this.zshShell){let Y=this.usage.getDescriptions(),V=(C=(E=this===null||this===void 0?void 0:this.aliases)===null||E===void 0?void 0:E[D])===null||C===void 0?void 0:C.find((K)=>{let N=Y[K];return typeof N==="string"&&N.length>0}),H=V?Y[V]:void 0,W=(z=($=Y[D])!==null&&$!==void 0?$:H)!==null&&z!==void 0?z:"";Z=`${D.replace(/:/g,"\\:")}:${W.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let J=(Y)=>/^--/.test(Y),Q=(Y)=>/^[^0-9]$/.test(Y),G=!J(F)&&Q(D)?"-":"--";if(u.push(G+Z),B)u.push(G+"no-"+Z)}customCompletion(D,u,F,B){if(qD(this.customCompletionFunction,null,this.shim),E7(this.customCompletionFunction)){let E=this.customCompletionFunction(F,u);if(a(E))return E.then((C)=>{this.shim.process.nextTick(()=>{B(null,C)})}).catch((C)=>{this.shim.process.nextTick(()=>{B(C,void 0)})});return B(null,E)}else if(B7(this.customCompletionFunction))return this.customCompletionFunction(F,u,(E=B)=>this.defaultCompletion(D,u,F,E),(E)=>{B(null,E)});else return this.customCompletionFunction(F,u,(E)=>{B(null,E)})}getCompletion(D,u){let F=D.length?D[D.length-1]:"",B=this.yargs.parse(D,!0),E=this.customCompletionFunction?(C)=>this.customCompletion(D,C,F,u):(C)=>this.defaultCompletion(D,C,F,u);return a(B)?B.then(E):E(B)}generateCompletionScript(D,u){let F=this.zshShell?N8:_8,B=this.shim.path.basename(D);if(D.match(/\.js$/))D=`./${D}`;return F=F.replace(/{{app_name}}/g,B),F=F.replace(/{{completion_command}}/g,u),F.replace(/{{app_path}}/g,D)}registerFunction(D){this.customCompletionFunction=D}setParsed(D){this.aliases=D.aliases}}function L8(D,u,F,B){return new A8(D,u,F,B)}function E7(D){return D.length<3}function B7(D){return D.length>3}function T8(D,u){if(D.length===0)return u.length;if(u.length===0)return D.length;let F=[],B;for(B=0;B<=u.length;B++)F[B]=[B];let E;for(E=0;E<=D.length;E++)F[0][E]=E;for(B=1;B<=u.length;B++)for(E=1;E<=D.length;E++)if(u.charAt(B-1)===D.charAt(E-1))F[B][E]=F[B-1][E-1];else if(B>1&&E>1&&u.charAt(B-2)===D.charAt(E-1)&&u.charAt(B-1)===D.charAt(E-2))F[B][E]=F[B-2][E-2]+1;else F[B][E]=Math.min(F[B-1][E-1]+1,Math.min(F[B][E-1]+1,F[B-1][E]+1));return F[u.length][D.length]}var R8=["$0","--","_"];function P8(D,u,F){let B=F.y18n.__,E=F.y18n.__n,C={};C.nonOptionCount=function(G){let Y=D.getDemandedCommands(),H=G._.length+(G["--"]?G["--"].length:0)-D.getInternalMethods().getContext().commands.length;if(Y._&&(H<Y._.min||H>Y._.max)){if(H<Y._.min)if(Y._.minMsg!==void 0)u.fail(Y._.minMsg?Y._.minMsg.replace(/\$0/g,H.toString()).replace(/\$1/,Y._.min.toString()):null);else u.fail(E("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",H,H.toString(),Y._.min.toString()));else if(H>Y._.max)if(Y._.maxMsg!==void 0)u.fail(Y._.maxMsg?Y._.maxMsg.replace(/\$0/g,H.toString()).replace(/\$1/,Y._.max.toString()):null);else u.fail(E("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",H,H.toString(),Y._.max.toString()))}},C.positionalCount=function(G,Y){if(Y<G)u.fail(E("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",Y,Y+"",G+""))},C.requiredArguments=function(G,Y){let V=null;for(let H of Object.keys(Y))if(!Object.prototype.hasOwnProperty.call(G,H)||typeof G[H]>"u")V=V||{},V[H]=Y[H];if(V){let H=[];for(let K of Object.keys(V)){let N=V[K];if(N&&H.indexOf(N)<0)H.push(N)}let W=H.length?`
|
|
75
75
|
${H.join(`
|
|
76
|
-
`)}`:"";u.fail(E("Missing required argument: %s","Missing required arguments: %s",Object.keys(V).length,Object.keys(V).join(", ")+W))}},C.unknownArguments=function(G,Y,V,H,W=!0){var K;let N=D.getInternalMethods().getCommandInstance().getCommands(),j=[],L=D.getInternalMethods().getContext();if(Object.keys(G).forEach((M)=>{if(!
|
|
76
|
+
`)}`:"";u.fail(E("Missing required argument: %s","Missing required arguments: %s",Object.keys(V).length,Object.keys(V).join(", ")+W))}},C.unknownArguments=function(G,Y,V,H,W=!0){var K;let N=D.getInternalMethods().getCommandInstance().getCommands(),j=[],L=D.getInternalMethods().getContext();if(Object.keys(G).forEach((M)=>{if(!R8.includes(M)&&!Object.prototype.hasOwnProperty.call(V,M)&&!Object.prototype.hasOwnProperty.call(D.getInternalMethods().getParseContext(),M)&&!C.isValidAndSomeAliasIsNotNew(M,Y))j.push(M)}),W&&(L.commands.length>0||N.length>0||H))G._.slice(L.commands.length).forEach((M)=>{if(!N.includes(""+M))j.push(""+M)});if(W){let T=((K=D.getDemandedCommands()._)===null||K===void 0?void 0:K.max)||0,h=L.commands.length+T;if(h<G._.length)G._.slice(h).forEach((p)=>{if(p=String(p),!L.commands.includes(p)&&!j.includes(p))j.push(p)})}if(j.length)u.fail(E("Unknown argument: %s","Unknown arguments: %s",j.length,j.map((M)=>M.trim()?M:`"${M}"`).join(", ")))},C.unknownCommands=function(G){let Y=D.getInternalMethods().getCommandInstance().getCommands(),V=[],H=D.getInternalMethods().getContext();if(H.commands.length>0||Y.length>0)G._.slice(H.commands.length).forEach((W)=>{if(!Y.includes(""+W))V.push(""+W)});if(V.length>0)return u.fail(E("Unknown command: %s","Unknown commands: %s",V.length,V.join(", "))),!0;else return!1},C.isValidAndSomeAliasIsNotNew=function(G,Y){if(!Object.prototype.hasOwnProperty.call(Y,G))return!1;let V=D.parsed.newAliases;return[G,...Y[G]].some((H)=>!Object.prototype.hasOwnProperty.call(V,H)||!V[G])},C.limitedChoices=function(G){let Y=D.getOptions(),V={};if(!Object.keys(Y.choices).length)return;Object.keys(G).forEach((K)=>{if(R8.indexOf(K)===-1&&Object.prototype.hasOwnProperty.call(Y.choices,K))[].concat(G[K]).forEach((N)=>{if(Y.choices[K].indexOf(N)===-1&&N!==void 0)V[K]=(V[K]||[]).concat(N)})});let H=Object.keys(V);if(!H.length)return;let W=B("Invalid values:");H.forEach((K)=>{W+=`
|
|
77
77
|
${B("Argument: %s, Given: %s, Choices: %s",K,u.stringifiedValues(V[K]),u.stringifiedValues(Y.choices[K]))}`}),u.fail(W)};let $={};C.implies=function(G,Y){if(S("<string|object> [array|number|string]",[G,Y],arguments.length),typeof G==="object")Object.keys(G).forEach((V)=>{C.implies(V,G[V])});else{if(D.global(G),!$[G])$[G]=[];if(Array.isArray(Y))Y.forEach((V)=>C.implies(G,V));else qD(Y,void 0,F),$[G].push(Y)}},C.getImplied=function(){return $};function z(Q,G){let Y=Number(G);if(G=isNaN(Y)?G:Y,typeof G==="number")G=Q._.length>=G;else if(G.match(/^--no-.+/))G=G.match(/^--no-(.+)/)[1],G=!Object.prototype.hasOwnProperty.call(Q,G);else G=Object.prototype.hasOwnProperty.call(Q,G);return G}C.implications=function(G){let Y=[];if(Object.keys($).forEach((V)=>{let H=V;($[V]||[]).forEach((W)=>{let K=H,N=W;if(K=z(G,K),W=z(G,W),K&&!W)Y.push(` ${H} -> ${N}`)})}),Y.length){let V=`${B("Implications failed:")}
|
|
78
|
-
`;Y.forEach((H)=>{V+=H}),u.fail(V)}};let Z={};C.conflicts=function(G,Y){if(S("<string|object> [array|string]",[G,Y],arguments.length),typeof G==="object")Object.keys(G).forEach((V)=>{C.conflicts(V,G[V])});else{if(D.global(G),!Z[G])Z[G]=[];if(Array.isArray(Y))Y.forEach((V)=>C.conflicts(G,V));else Z[G].push(Y)}},C.getConflicting=()=>Z,C.conflicting=function(G){if(Object.keys(G).forEach((Y)=>{if(Z[Y])Z[Y].forEach((V)=>{if(V&&G[Y]!==void 0&&G[V]!==void 0)u.fail(B("Arguments %s and %s are mutually exclusive",Y,V))})}),D.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(Z).forEach((Y)=>{Z[Y].forEach((V)=>{if(V&&G[F.Parser.camelCase(Y)]!==void 0&&G[F.Parser.camelCase(V)]!==void 0)u.fail(B("Arguments %s and %s are mutually exclusive",Y,V))})})},C.recommendCommands=function(G,Y){Y=Y.sort((K,N)=>N.length-K.length);let H=null,W=1/0;for(let K=0,N;(N=Y[K])!==void 0;K++){let j=R8(G,N);if(j<=3&&j<W)W=j,H=N}if(H)u.fail(B("Did you mean %s?",H))},C.reset=function(G){return $=lD($,(Y)=>!G[Y]),Z=lD(Z,(Y)=>!G[Y]),C};let J=[];return C.freeze=function(){J.push({implied:$,conflicting:Z})},C.unfreeze=function(){let G=J.pop();qD(G,void 0,F),{implied:$,conflicting:Z}=G},C}var G0=[],vu;function yu(D,u,F,B){vu=B;let E={};if(Object.prototype.hasOwnProperty.call(D,"extends")){if(typeof D.extends!=="string")return E;let C=/\.json|\..*rc$/.test(D.extends),$=null;if(!C)try{$=import.meta.resolve(D.extends)}catch(z){return D}else $=$7(u,D.extends);C7($),G0.push($),E=C?JSON.parse(vu.readFileSync($,"utf8")):B.require(D.extends),delete D.extends,E=yu(E,vu.path.dirname($),F,vu)}return G0=[],F?w8(E,D):Object.assign({},E,D)}function C7(D){if(G0.indexOf(D)>-1)throw new ED(`Circular extended configurations: '${D}'.`)}function $7(D,u){return vu.path.resolve(D,u)}function w8(D,u){let F={};function B(E){return E&&typeof E==="object"&&!Array.isArray(E)}Object.assign(F,D);for(let E of Object.keys(u))if(B(u[E])&&B(F[E]))F[E]=w8(D[E],u[E]);else F[E]=u[E];return F}var w=function(D,u,F,B,E){if(B==="m")throw TypeError("Private method is not writable");if(B==="a"&&!E)throw TypeError("Private accessor was defined without a setter");if(typeof u==="function"?D!==u||!E:!u.has(D))throw TypeError("Cannot write private member to an object whose class did not declare it");return B==="a"?E.call(D,F):E?E.value=F:u.set(D,F),F},X=function(D,u,F,B){if(F==="a"&&!B)throw TypeError("Private accessor was defined without a getter");if(typeof u==="function"?D!==u||!B:!u.has(D))throw TypeError("Cannot read private member from an object whose class did not declare it");return F==="m"?B:F==="a"?B.call(D):B?B.value:u.get(D)},BD,Cu,pu,KD,UD,GF,tD,$u,XF,AD,QF,LD,ID,jD,TD,YF,zu,QD,h,WF,VF,MD,Zu,Tu,Ju,oD,HF,c,Gu,Xu,Qu,k,qF,bD,DD;function r8(D){return(u=[],F=D.process.cwd(),B)=>{let E=new a8(u,F,B,D);return Object.defineProperty(E,"argv",{get:()=>{return E.parse()},enumerable:!0}),E.help(),E.version(),E}}var x8=Symbol("copyDoubleDash"),I8=Symbol("copyDoubleDash"),X0=Symbol("deleteFromParserHintObject"),b8=Symbol("emitWarning"),f8=Symbol("freeze"),h8=Symbol("getDollarZero"),Yu=Symbol("getParserConfiguration"),v8=Symbol("getUsageConfiguration"),Q0=Symbol("guessLocale"),y8=Symbol("guessVersion"),p8=Symbol("parsePositionalNumbers"),Y0=Symbol("pkgUp"),sD=Symbol("populateParserHintArray"),Ru=Symbol("populateParserHintSingleValueDictionary"),W0=Symbol("populateParserHintArrayDictionary"),V0=Symbol("populateParserHintDictionary"),H0=Symbol("sanitizeKey"),q0=Symbol("setKey"),K0=Symbol("unfreeze"),m8=Symbol("validateAsync"),g8=Symbol("getCommandInstance"),c8=Symbol("getContext"),d8=Symbol("getHasOutput"),k8=Symbol("getLoggerInstance"),i8=Symbol("getParseContext"),l8=Symbol("getUsageInstance"),n8=Symbol("getValidationInstance"),KF=Symbol("hasParseCallback"),t8=Symbol("isGlobalContext"),Wu=Symbol("postProcess"),o8=Symbol("rebase"),O0=Symbol("reset"),mu=Symbol("runYargsParserAndExecuteCommands"),U0=Symbol("runValidation"),s8=Symbol("setHasOutput"),Vu=Symbol("kTrackManuallySetKeys"),z7="en_US";class a8{constructor(D=[],u,F,B){this.customScriptName=!1,this.parsed=!1,BD.set(this,void 0),Cu.set(this,void 0),pu.set(this,{commands:[],fullCommands:[]}),KD.set(this,null),UD.set(this,null),GF.set(this,"show-hidden"),tD.set(this,null),$u.set(this,!0),XF.set(this,{}),AD.set(this,!0),QF.set(this,[]),LD.set(this,void 0),ID.set(this,{}),jD.set(this,!1),TD.set(this,null),YF.set(this,!0),zu.set(this,void 0),QD.set(this,""),h.set(this,void 0),WF.set(this,void 0),VF.set(this,{}),MD.set(this,null),Zu.set(this,null),Tu.set(this,{}),Ju.set(this,{}),oD.set(this,void 0),HF.set(this,!1),c.set(this,void 0),Gu.set(this,!1),Xu.set(this,!1),Qu.set(this,!1),k.set(this,void 0),qF.set(this,{}),bD.set(this,null),DD.set(this,void 0),w(this,c,B,"f"),w(this,oD,D,"f"),w(this,Cu,u,"f"),w(this,WF,F,"f"),w(this,LD,new Z0(this),"f"),this.$0=this[h8](),this[O0](),w(this,BD,X(this,BD,"f"),"f"),w(this,k,X(this,k,"f"),"f"),w(this,DD,X(this,DD,"f"),"f"),w(this,h,X(this,h,"f"),"f"),X(this,h,"f").showHiddenOpt=X(this,GF,"f"),w(this,zu,this[I8](),"f"),X(this,c,"f").y18n.setLocale(z7)}addHelpOpt(D,u){if(S("[string|boolean] [string]",[D,u],arguments.length),X(this,TD,"f"))this[X0](X(this,TD,"f")),w(this,TD,null,"f");if(D===!1&&u===void 0)return this;return w(this,TD,typeof D==="string"?D:"help","f"),this.boolean(X(this,TD,"f")),this.describe(X(this,TD,"f"),u||X(this,k,"f").deferY18nLookup("Show help")),this}help(D,u){return this.addHelpOpt(D,u)}addShowHiddenOpt(D,u){if(S("[string|boolean] [string]",[D,u],arguments.length),D===!1&&u===void 0)return this;let F=typeof D==="string"?D:X(this,GF,"f");return this.boolean(F),this.describe(F,u||X(this,k,"f").deferY18nLookup("Show hidden options")),X(this,h,"f").showHiddenOpt=F,this}showHidden(D,u){return this.addShowHiddenOpt(D,u)}alias(D,u){return S("<object|string|array> [string|array]",[D,u],arguments.length),this[W0](this.alias.bind(this),"alias",D,u),this}array(D){return S("<array|string>",[D],arguments.length),this[sD]("array",D),this[Vu](D),this}boolean(D){return S("<array|string>",[D],arguments.length),this[sD]("boolean",D),this[Vu](D),this}check(D,u){return S("<function> [boolean]",[D,u],arguments.length),this.middleware((F,B)=>{return Bu(()=>{return D(F,B.getOptions())},(E)=>{if(!E)X(this,k,"f").fail(X(this,c,"f").y18n.__("Argument check failed: %s",D.toString()));else if(typeof E==="string"||E instanceof Error)X(this,k,"f").fail(E.toString(),E);return F},(E)=>{return X(this,k,"f").fail(E.message?E.message:E.toString(),E),F})},!1,u),this}choices(D,u){return S("<object|string|array> [string|array]",[D,u],arguments.length),this[W0](this.choices.bind(this),"choices",D,u),this}coerce(D,u){if(S("<object|string|array> [function]",[D,u],arguments.length),Array.isArray(D)){if(!u)throw new ED("coerce callback must be provided");for(let B of D)this.coerce(B,u);return this}else if(typeof D==="object"){for(let B of Object.keys(D))this.coerce(B,D[B]);return this}if(!u)throw new ED("coerce callback must be provided");let F=D;return X(this,h,"f").key[F]=!0,X(this,LD,"f").addCoerceMiddleware((B,E)=>{var C;let $=(C=E.getAliases()[F])!==null&&C!==void 0?C:[],z=[F,...$].filter((Z)=>Object.prototype.hasOwnProperty.call(B,Z));if(z.length===0)return B;return Bu(()=>{return u(B[z[0]])},(Z)=>{return z.forEach((J)=>{B[J]=Z}),B},(Z)=>{throw new ED(Z.message)})},F),this}conflicts(D,u){return S("<string|object> [string|array]",[D,u],arguments.length),X(this,DD,"f").conflicts(D,u),this}config(D="config",u,F){if(S("[object|string] [string|function] [function]",[D,u,F],arguments.length),typeof D==="object"&&!Array.isArray(D))return D=yu(D,X(this,Cu,"f"),this[Yu]()["deep-merge-config"]||!1,X(this,c,"f")),X(this,h,"f").configObjects=(X(this,h,"f").configObjects||[]).concat(D),this;if(typeof u==="function")F=u,u=void 0;return this.describe(D,u||X(this,k,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(D)?D:[D]).forEach((B)=>{X(this,h,"f").config[B]=F||!0}),this}completion(D,u,F){if(S("[string] [string|boolean|function] [function]",[D,u,F],arguments.length),typeof u==="function")F=u,u=void 0;if(w(this,UD,D||X(this,UD,"f")||"completion","f"),!u&&u!==!1)u="generate completion script";if(this.command(X(this,UD,"f"),u),F)X(this,KD,"f").registerFunction(F);return this}command(D,u,F,B,E,C){return S("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[D,u,F,B,E,C],arguments.length),X(this,BD,"f").addHandler(D,u,F,B,E,C),this}commands(D,u,F,B,E,C){return this.command(D,u,F,B,E,C)}commandDir(D,u){S("<string> [object]",[D,u],arguments.length);let F=X(this,WF,"f")||X(this,c,"f").require;return X(this,BD,"f").addDirectory(D,F,X(this,c,"f").getCallerFile(),u),this}count(D){return S("<array|string>",[D],arguments.length),this[sD]("count",D),this[Vu](D),this}default(D,u,F){if(S("<object|string|array> [*] [string]",[D,u,F],arguments.length),F)z0(D,X(this,c,"f")),X(this,h,"f").defaultDescription[D]=F;if(typeof u==="function"){if(z0(D,X(this,c,"f")),!X(this,h,"f").defaultDescription[D])X(this,h,"f").defaultDescription[D]=X(this,k,"f").functionDescription(u);u=u.call()}return this[Ru](this.default.bind(this),"default",D,u),this}defaults(D,u,F){return this.default(D,u,F)}demandCommand(D=1,u,F,B){if(S("[number] [number|string] [string|null|undefined] [string|null|undefined]",[D,u,F,B],arguments.length),typeof u!=="number")F=u,u=1/0;return this.global("_",!1),X(this,h,"f").demandedCommands._={min:D,max:u,minMsg:F,maxMsg:B},this}demand(D,u,F){if(Array.isArray(u))u.forEach((B)=>{qD(F,!0,X(this,c,"f")),this.demandOption(B,F)}),u=1/0;else if(typeof u!=="number")F=u,u=1/0;if(typeof D==="number")qD(F,!0,X(this,c,"f")),this.demandCommand(D,u,F,F);else if(Array.isArray(D))D.forEach((B)=>{qD(F,!0,X(this,c,"f")),this.demandOption(B,F)});else if(typeof F==="string")this.demandOption(D,F);else if(F===!0||typeof F>"u")this.demandOption(D);return this}demandOption(D,u){return S("<object|string|array> [string]",[D,u],arguments.length),this[Ru](this.demandOption.bind(this),"demandedOptions",D,u),this}deprecateOption(D,u){return S("<string> [string|boolean]",[D,u],arguments.length),X(this,h,"f").deprecatedOptions[D]=u,this}describe(D,u){return S("<object|string|array> [string]",[D,u],arguments.length),this[q0](D,!0),X(this,k,"f").describe(D,u),this}detectLocale(D){return S("<boolean>",[D],arguments.length),w(this,$u,D,"f"),this}env(D){if(S("[string|boolean]",[D],arguments.length),D===!1)delete X(this,h,"f").envPrefix;else X(this,h,"f").envPrefix=D||"";return this}epilogue(D){return S("<string>",[D],arguments.length),X(this,k,"f").epilog(D),this}epilog(D){return this.epilogue(D)}example(D,u){if(S("<string|array> [string]",[D,u],arguments.length),Array.isArray(D))D.forEach((F)=>this.example(...F));else X(this,k,"f").example(D,u);return this}exit(D,u){if(w(this,jD,!0,"f"),w(this,tD,u,"f"),X(this,AD,"f"))X(this,c,"f").process.exit(D)}exitProcess(D=!0){return S("[boolean]",[D],arguments.length),w(this,AD,D,"f"),this}fail(D){if(S("<function|boolean>",[D],arguments.length),typeof D==="boolean"&&D!==!1)throw new ED("Invalid first argument. Expected function or boolean 'false'");return X(this,k,"f").failFn(D),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(D,u){if(S("<array> [function]",[D,u],arguments.length),!u)return new Promise((F,B)=>{X(this,KD,"f").getCompletion(D,(E,C)=>{if(E)B(E);else F(C)})});else return X(this,KD,"f").getCompletion(D,u)}getDemandedOptions(){return S([],0),X(this,h,"f").demandedOptions}getDemandedCommands(){return S([],0),X(this,h,"f").demandedCommands}getDeprecatedOptions(){return S([],0),X(this,h,"f").deprecatedOptions}getDetectLocale(){return X(this,$u,"f")}getExitProcess(){return X(this,AD,"f")}getGroups(){return Object.assign({},X(this,ID,"f"),X(this,Ju,"f"))}getHelp(){if(w(this,jD,!0,"f"),!X(this,k,"f").hasCachedHelpMessage()){if(!this.parsed){let u=this[mu](X(this,oD,"f"),void 0,void 0,0,!0);if(a(u))return u.then(()=>{return X(this,k,"f").help()})}let D=X(this,BD,"f").runDefaultBuilderOn(this);if(a(D))return D.then(()=>{return X(this,k,"f").help()})}return Promise.resolve(X(this,k,"f").help())}getOptions(){return X(this,h,"f")}getStrict(){return X(this,Gu,"f")}getStrictCommands(){return X(this,Xu,"f")}getStrictOptions(){return X(this,Qu,"f")}global(D,u){if(S("<string|array> [boolean]",[D,u],arguments.length),D=[].concat(D),u!==!1)X(this,h,"f").local=X(this,h,"f").local.filter((F)=>D.indexOf(F)===-1);else D.forEach((F)=>{if(!X(this,h,"f").local.includes(F))X(this,h,"f").local.push(F)});return this}group(D,u){S("<string|array> <string>",[D,u],arguments.length);let F=X(this,Ju,"f")[u]||X(this,ID,"f")[u];if(X(this,Ju,"f")[u])delete X(this,Ju,"f")[u];let B={};return X(this,ID,"f")[u]=(F||[]).concat(D).filter((E)=>{if(B[E])return!1;return B[E]=!0}),this}hide(D){return S("<string>",[D],arguments.length),X(this,h,"f").hiddenOptions.push(D),this}implies(D,u){return S("<string|object> [number|string|array]",[D,u],arguments.length),X(this,DD,"f").implies(D,u),this}locale(D){if(S("[string]",[D],arguments.length),D===void 0)return this[Q0](),X(this,c,"f").y18n.getLocale();return w(this,$u,!1,"f"),X(this,c,"f").y18n.setLocale(D),this}middleware(D,u,F){return X(this,LD,"f").addMiddleware(D,!!u,F)}nargs(D,u){return S("<string|object|array> [number]",[D,u],arguments.length),this[Ru](this.nargs.bind(this),"narg",D,u),this}normalize(D){return S("<array|string>",[D],arguments.length),this[sD]("normalize",D),this}number(D){return S("<array|string>",[D],arguments.length),this[sD]("number",D),this[Vu](D),this}option(D,u){if(S("<string|object> [object]",[D,u],arguments.length),typeof D==="object")Object.keys(D).forEach((F)=>{this.options(F,D[F])});else{if(typeof u!=="object")u={};if(this[Vu](D),X(this,bD,"f")&&(D==="version"||(u===null||u===void 0?void 0:u.alias)==="version"))this[b8](['"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(X(this,
|
|
78
|
+
`;Y.forEach((H)=>{V+=H}),u.fail(V)}};let Z={};C.conflicts=function(G,Y){if(S("<string|object> [array|string]",[G,Y],arguments.length),typeof G==="object")Object.keys(G).forEach((V)=>{C.conflicts(V,G[V])});else{if(D.global(G),!Z[G])Z[G]=[];if(Array.isArray(Y))Y.forEach((V)=>C.conflicts(G,V));else Z[G].push(Y)}},C.getConflicting=()=>Z,C.conflicting=function(G){if(Object.keys(G).forEach((Y)=>{if(Z[Y])Z[Y].forEach((V)=>{if(V&&G[Y]!==void 0&&G[V]!==void 0)u.fail(B("Arguments %s and %s are mutually exclusive",Y,V))})}),D.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(Z).forEach((Y)=>{Z[Y].forEach((V)=>{if(V&&G[F.Parser.camelCase(Y)]!==void 0&&G[F.Parser.camelCase(V)]!==void 0)u.fail(B("Arguments %s and %s are mutually exclusive",Y,V))})})},C.recommendCommands=function(G,Y){Y=Y.sort((K,N)=>N.length-K.length);let H=null,W=1/0;for(let K=0,N;(N=Y[K])!==void 0;K++){let j=T8(G,N);if(j<=3&&j<W)W=j,H=N}if(H)u.fail(B("Did you mean %s?",H))},C.reset=function(G){return $=lD($,(Y)=>!G[Y]),Z=lD(Z,(Y)=>!G[Y]),C};let J=[];return C.freeze=function(){J.push({implied:$,conflicting:Z})},C.unfreeze=function(){let G=J.pop();qD(G,void 0,F),{implied:$,conflicting:Z}=G},C}var X0=[],vu;function yu(D,u,F,B){vu=B;let E={};if(Object.prototype.hasOwnProperty.call(D,"extends")){if(typeof D.extends!=="string")return E;let C=/\.json|\..*rc$/.test(D.extends),$=null;if(!C)try{$=import.meta.resolve(D.extends)}catch(z){return D}else $=$7(u,D.extends);C7($),X0.push($),E=C?JSON.parse(vu.readFileSync($,"utf8")):B.require(D.extends),delete D.extends,E=yu(E,vu.path.dirname($),F,vu)}return X0=[],F?S8(E,D):Object.assign({},E,D)}function C7(D){if(X0.indexOf(D)>-1)throw new ED(`Circular extended configurations: '${D}'.`)}function $7(D,u){return vu.path.resolve(D,u)}function S8(D,u){let F={};function B(E){return E&&typeof E==="object"&&!Array.isArray(E)}Object.assign(F,D);for(let E of Object.keys(u))if(B(u[E])&&B(F[E]))F[E]=S8(D[E],u[E]);else F[E]=u[E];return F}var w=function(D,u,F,B,E){if(B==="m")throw TypeError("Private method is not writable");if(B==="a"&&!E)throw TypeError("Private accessor was defined without a setter");if(typeof u==="function"?D!==u||!E:!u.has(D))throw TypeError("Cannot write private member to an object whose class did not declare it");return B==="a"?E.call(D,F):E?E.value=F:u.set(D,F),F},X=function(D,u,F,B){if(F==="a"&&!B)throw TypeError("Private accessor was defined without a getter");if(typeof u==="function"?D!==u||!B:!u.has(D))throw TypeError("Cannot read private member from an object whose class did not declare it");return F==="m"?B:F==="a"?B.call(D):B?B.value:u.get(D)},BD,Cu,pu,KD,UD,GF,tD,$u,XF,AD,QF,LD,ID,jD,TD,YF,zu,QD,v,WF,VF,MD,Zu,Tu,Ju,oD,HF,c,Gu,Xu,Qu,k,qF,bD,DD;function s8(D){return(u=[],F=D.process.cwd(),B)=>{let E=new r8(u,F,B,D);return Object.defineProperty(E,"argv",{get:()=>{return E.parse()},enumerable:!0}),E.help(),E.version(),E}}var w8=Symbol("copyDoubleDash"),x8=Symbol("copyDoubleDash"),Q0=Symbol("deleteFromParserHintObject"),I8=Symbol("emitWarning"),b8=Symbol("freeze"),f8=Symbol("getDollarZero"),Yu=Symbol("getParserConfiguration"),h8=Symbol("getUsageConfiguration"),Y0=Symbol("guessLocale"),v8=Symbol("guessVersion"),y8=Symbol("parsePositionalNumbers"),W0=Symbol("pkgUp"),sD=Symbol("populateParserHintArray"),Ru=Symbol("populateParserHintSingleValueDictionary"),V0=Symbol("populateParserHintArrayDictionary"),H0=Symbol("populateParserHintDictionary"),q0=Symbol("sanitizeKey"),K0=Symbol("setKey"),O0=Symbol("unfreeze"),p8=Symbol("validateAsync"),m8=Symbol("getCommandInstance"),g8=Symbol("getContext"),c8=Symbol("getHasOutput"),d8=Symbol("getLoggerInstance"),k8=Symbol("getParseContext"),i8=Symbol("getUsageInstance"),l8=Symbol("getValidationInstance"),KF=Symbol("hasParseCallback"),n8=Symbol("isGlobalContext"),Wu=Symbol("postProcess"),t8=Symbol("rebase"),U0=Symbol("reset"),mu=Symbol("runYargsParserAndExecuteCommands"),j0=Symbol("runValidation"),o8=Symbol("setHasOutput"),Vu=Symbol("kTrackManuallySetKeys"),z7="en_US";class r8{constructor(D=[],u,F,B){this.customScriptName=!1,this.parsed=!1,BD.set(this,void 0),Cu.set(this,void 0),pu.set(this,{commands:[],fullCommands:[]}),KD.set(this,null),UD.set(this,null),GF.set(this,"show-hidden"),tD.set(this,null),$u.set(this,!0),XF.set(this,{}),AD.set(this,!0),QF.set(this,[]),LD.set(this,void 0),ID.set(this,{}),jD.set(this,!1),TD.set(this,null),YF.set(this,!0),zu.set(this,void 0),QD.set(this,""),v.set(this,void 0),WF.set(this,void 0),VF.set(this,{}),MD.set(this,null),Zu.set(this,null),Tu.set(this,{}),Ju.set(this,{}),oD.set(this,void 0),HF.set(this,!1),c.set(this,void 0),Gu.set(this,!1),Xu.set(this,!1),Qu.set(this,!1),k.set(this,void 0),qF.set(this,{}),bD.set(this,null),DD.set(this,void 0),w(this,c,B,"f"),w(this,oD,D,"f"),w(this,Cu,u,"f"),w(this,WF,F,"f"),w(this,LD,new J0(this),"f"),this.$0=this[f8](),this[U0](),w(this,BD,X(this,BD,"f"),"f"),w(this,k,X(this,k,"f"),"f"),w(this,DD,X(this,DD,"f"),"f"),w(this,v,X(this,v,"f"),"f"),X(this,v,"f").showHiddenOpt=X(this,GF,"f"),w(this,zu,this[x8](),"f"),X(this,c,"f").y18n.setLocale(z7)}addHelpOpt(D,u){if(S("[string|boolean] [string]",[D,u],arguments.length),X(this,TD,"f"))this[Q0](X(this,TD,"f")),w(this,TD,null,"f");if(D===!1&&u===void 0)return this;return w(this,TD,typeof D==="string"?D:"help","f"),this.boolean(X(this,TD,"f")),this.describe(X(this,TD,"f"),u||X(this,k,"f").deferY18nLookup("Show help")),this}help(D,u){return this.addHelpOpt(D,u)}addShowHiddenOpt(D,u){if(S("[string|boolean] [string]",[D,u],arguments.length),D===!1&&u===void 0)return this;let F=typeof D==="string"?D:X(this,GF,"f");return this.boolean(F),this.describe(F,u||X(this,k,"f").deferY18nLookup("Show hidden options")),X(this,v,"f").showHiddenOpt=F,this}showHidden(D,u){return this.addShowHiddenOpt(D,u)}alias(D,u){return S("<object|string|array> [string|array]",[D,u],arguments.length),this[V0](this.alias.bind(this),"alias",D,u),this}array(D){return S("<array|string>",[D],arguments.length),this[sD]("array",D),this[Vu](D),this}boolean(D){return S("<array|string>",[D],arguments.length),this[sD]("boolean",D),this[Vu](D),this}check(D,u){return S("<function> [boolean]",[D,u],arguments.length),this.middleware((F,B)=>{return Bu(()=>{return D(F,B.getOptions())},(E)=>{if(!E)X(this,k,"f").fail(X(this,c,"f").y18n.__("Argument check failed: %s",D.toString()));else if(typeof E==="string"||E instanceof Error)X(this,k,"f").fail(E.toString(),E);return F},(E)=>{return X(this,k,"f").fail(E.message?E.message:E.toString(),E),F})},!1,u),this}choices(D,u){return S("<object|string|array> [string|array]",[D,u],arguments.length),this[V0](this.choices.bind(this),"choices",D,u),this}coerce(D,u){if(S("<object|string|array> [function]",[D,u],arguments.length),Array.isArray(D)){if(!u)throw new ED("coerce callback must be provided");for(let B of D)this.coerce(B,u);return this}else if(typeof D==="object"){for(let B of Object.keys(D))this.coerce(B,D[B]);return this}if(!u)throw new ED("coerce callback must be provided");let F=D;return X(this,v,"f").key[F]=!0,X(this,LD,"f").addCoerceMiddleware((B,E)=>{var C;let $=(C=E.getAliases()[F])!==null&&C!==void 0?C:[],z=[F,...$].filter((Z)=>Object.prototype.hasOwnProperty.call(B,Z));if(z.length===0)return B;return Bu(()=>{return u(B[z[0]])},(Z)=>{return z.forEach((J)=>{B[J]=Z}),B},(Z)=>{throw new ED(Z.message)})},F),this}conflicts(D,u){return S("<string|object> [string|array]",[D,u],arguments.length),X(this,DD,"f").conflicts(D,u),this}config(D="config",u,F){if(S("[object|string] [string|function] [function]",[D,u,F],arguments.length),typeof D==="object"&&!Array.isArray(D))return D=yu(D,X(this,Cu,"f"),this[Yu]()["deep-merge-config"]||!1,X(this,c,"f")),X(this,v,"f").configObjects=(X(this,v,"f").configObjects||[]).concat(D),this;if(typeof u==="function")F=u,u=void 0;return this.describe(D,u||X(this,k,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(D)?D:[D]).forEach((B)=>{X(this,v,"f").config[B]=F||!0}),this}completion(D,u,F){if(S("[string] [string|boolean|function] [function]",[D,u,F],arguments.length),typeof u==="function")F=u,u=void 0;if(w(this,UD,D||X(this,UD,"f")||"completion","f"),!u&&u!==!1)u="generate completion script";if(this.command(X(this,UD,"f"),u),F)X(this,KD,"f").registerFunction(F);return this}command(D,u,F,B,E,C){return S("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[D,u,F,B,E,C],arguments.length),X(this,BD,"f").addHandler(D,u,F,B,E,C),this}commands(D,u,F,B,E,C){return this.command(D,u,F,B,E,C)}commandDir(D,u){S("<string> [object]",[D,u],arguments.length);let F=X(this,WF,"f")||X(this,c,"f").require;return X(this,BD,"f").addDirectory(D,F,X(this,c,"f").getCallerFile(),u),this}count(D){return S("<array|string>",[D],arguments.length),this[sD]("count",D),this[Vu](D),this}default(D,u,F){if(S("<object|string|array> [*] [string]",[D,u,F],arguments.length),F)Z0(D,X(this,c,"f")),X(this,v,"f").defaultDescription[D]=F;if(typeof u==="function"){if(Z0(D,X(this,c,"f")),!X(this,v,"f").defaultDescription[D])X(this,v,"f").defaultDescription[D]=X(this,k,"f").functionDescription(u);u=u.call()}return this[Ru](this.default.bind(this),"default",D,u),this}defaults(D,u,F){return this.default(D,u,F)}demandCommand(D=1,u,F,B){if(S("[number] [number|string] [string|null|undefined] [string|null|undefined]",[D,u,F,B],arguments.length),typeof u!=="number")F=u,u=1/0;return this.global("_",!1),X(this,v,"f").demandedCommands._={min:D,max:u,minMsg:F,maxMsg:B},this}demand(D,u,F){if(Array.isArray(u))u.forEach((B)=>{qD(F,!0,X(this,c,"f")),this.demandOption(B,F)}),u=1/0;else if(typeof u!=="number")F=u,u=1/0;if(typeof D==="number")qD(F,!0,X(this,c,"f")),this.demandCommand(D,u,F,F);else if(Array.isArray(D))D.forEach((B)=>{qD(F,!0,X(this,c,"f")),this.demandOption(B,F)});else if(typeof F==="string")this.demandOption(D,F);else if(F===!0||typeof F>"u")this.demandOption(D);return this}demandOption(D,u){return S("<object|string|array> [string]",[D,u],arguments.length),this[Ru](this.demandOption.bind(this),"demandedOptions",D,u),this}deprecateOption(D,u){return S("<string> [string|boolean]",[D,u],arguments.length),X(this,v,"f").deprecatedOptions[D]=u,this}describe(D,u){return S("<object|string|array> [string]",[D,u],arguments.length),this[K0](D,!0),X(this,k,"f").describe(D,u),this}detectLocale(D){return S("<boolean>",[D],arguments.length),w(this,$u,D,"f"),this}env(D){if(S("[string|boolean]",[D],arguments.length),D===!1)delete X(this,v,"f").envPrefix;else X(this,v,"f").envPrefix=D||"";return this}epilogue(D){return S("<string>",[D],arguments.length),X(this,k,"f").epilog(D),this}epilog(D){return this.epilogue(D)}example(D,u){if(S("<string|array> [string]",[D,u],arguments.length),Array.isArray(D))D.forEach((F)=>this.example(...F));else X(this,k,"f").example(D,u);return this}exit(D,u){if(w(this,jD,!0,"f"),w(this,tD,u,"f"),X(this,AD,"f"))X(this,c,"f").process.exit(D)}exitProcess(D=!0){return S("[boolean]",[D],arguments.length),w(this,AD,D,"f"),this}fail(D){if(S("<function|boolean>",[D],arguments.length),typeof D==="boolean"&&D!==!1)throw new ED("Invalid first argument. Expected function or boolean 'false'");return X(this,k,"f").failFn(D),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(D,u){if(S("<array> [function]",[D,u],arguments.length),!u)return new Promise((F,B)=>{X(this,KD,"f").getCompletion(D,(E,C)=>{if(E)B(E);else F(C)})});else return X(this,KD,"f").getCompletion(D,u)}getDemandedOptions(){return S([],0),X(this,v,"f").demandedOptions}getDemandedCommands(){return S([],0),X(this,v,"f").demandedCommands}getDeprecatedOptions(){return S([],0),X(this,v,"f").deprecatedOptions}getDetectLocale(){return X(this,$u,"f")}getExitProcess(){return X(this,AD,"f")}getGroups(){return Object.assign({},X(this,ID,"f"),X(this,Ju,"f"))}getHelp(){if(w(this,jD,!0,"f"),!X(this,k,"f").hasCachedHelpMessage()){if(!this.parsed){let u=this[mu](X(this,oD,"f"),void 0,void 0,0,!0);if(a(u))return u.then(()=>{return X(this,k,"f").help()})}let D=X(this,BD,"f").runDefaultBuilderOn(this);if(a(D))return D.then(()=>{return X(this,k,"f").help()})}return Promise.resolve(X(this,k,"f").help())}getOptions(){return X(this,v,"f")}getStrict(){return X(this,Gu,"f")}getStrictCommands(){return X(this,Xu,"f")}getStrictOptions(){return X(this,Qu,"f")}global(D,u){if(S("<string|array> [boolean]",[D,u],arguments.length),D=[].concat(D),u!==!1)X(this,v,"f").local=X(this,v,"f").local.filter((F)=>D.indexOf(F)===-1);else D.forEach((F)=>{if(!X(this,v,"f").local.includes(F))X(this,v,"f").local.push(F)});return this}group(D,u){S("<string|array> <string>",[D,u],arguments.length);let F=X(this,Ju,"f")[u]||X(this,ID,"f")[u];if(X(this,Ju,"f")[u])delete X(this,Ju,"f")[u];let B={};return X(this,ID,"f")[u]=(F||[]).concat(D).filter((E)=>{if(B[E])return!1;return B[E]=!0}),this}hide(D){return S("<string>",[D],arguments.length),X(this,v,"f").hiddenOptions.push(D),this}implies(D,u){return S("<string|object> [number|string|array]",[D,u],arguments.length),X(this,DD,"f").implies(D,u),this}locale(D){if(S("[string]",[D],arguments.length),D===void 0)return this[Y0](),X(this,c,"f").y18n.getLocale();return w(this,$u,!1,"f"),X(this,c,"f").y18n.setLocale(D),this}middleware(D,u,F){return X(this,LD,"f").addMiddleware(D,!!u,F)}nargs(D,u){return S("<string|object|array> [number]",[D,u],arguments.length),this[Ru](this.nargs.bind(this),"narg",D,u),this}normalize(D){return S("<array|string>",[D],arguments.length),this[sD]("normalize",D),this}number(D){return S("<array|string>",[D],arguments.length),this[sD]("number",D),this[Vu](D),this}option(D,u){if(S("<string|object> [object]",[D,u],arguments.length),typeof D==="object")Object.keys(D).forEach((F)=>{this.options(F,D[F])});else{if(typeof u!=="object")u={};if(this[Vu](D),X(this,bD,"f")&&(D==="version"||(u===null||u===void 0?void 0:u.alias)==="version"))this[I8](['"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(X(this,v,"f").key[D]=!0,u.alias)this.alias(D,u.alias);let F=u.deprecate||u.deprecated;if(F)this.deprecateOption(D,F);let B=u.demand||u.required||u.require;if(B)this.demand(D,B);if(u.demandOption)this.demandOption(D,typeof u.demandOption==="string"?u.demandOption:void 0);if(u.conflicts)this.conflicts(D,u.conflicts);if("default"in u)this.default(D,u.default);if(u.implies!==void 0)this.implies(D,u.implies);if(u.nargs!==void 0)this.nargs(D,u.nargs);if(u.config)this.config(D,u.configParser);if(u.normalize)this.normalize(D);if(u.choices)this.choices(D,u.choices);if(u.coerce)this.coerce(D,u.coerce);if(u.group)this.group(D,u.group);if(u.boolean||u.type==="boolean"){if(this.boolean(D),u.alias)this.boolean(u.alias)}if(u.array||u.type==="array"){if(this.array(D),u.alias)this.array(u.alias)}if(u.number||u.type==="number"){if(this.number(D),u.alias)this.number(u.alias)}if(u.string||u.type==="string"){if(this.string(D),u.alias)this.string(u.alias)}if(u.count||u.type==="count")this.count(D);if(typeof u.global==="boolean")this.global(D,u.global);if(u.defaultDescription)X(this,v,"f").defaultDescription[D]=u.defaultDescription;if(u.skipValidation)this.skipValidation(D);let E=u.describe||u.description||u.desc,C=X(this,k,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(C,D)||typeof E==="string")this.describe(D,E);if(u.hidden)this.hide(D);if(u.requiresArg)this.requiresArg(D)}return this}options(D,u){return this.option(D,u)}parse(D,u,F){if(S("[string|array] [function|boolean|object] [function]",[D,u,F],arguments.length),this[b8](),typeof D>"u")D=X(this,oD,"f");if(typeof u==="object")w(this,Zu,u,"f"),u=F;if(typeof u==="function")w(this,MD,u,"f"),u=!1;if(!u)w(this,oD,D,"f");if(X(this,MD,"f"))w(this,AD,!1,"f");let B=this[mu](D,!!u),E=this.parsed;if(X(this,KD,"f").setParsed(this.parsed),a(B))return B.then((C)=>{if(X(this,MD,"f"))X(this,MD,"f").call(this,X(this,tD,"f"),C,X(this,QD,"f"));return C}).catch((C)=>{if(X(this,MD,"f"))X(this,MD,"f")(C,this.parsed.argv,X(this,QD,"f"));throw C}).finally(()=>{this[O0](),this.parsed=E});else{if(X(this,MD,"f"))X(this,MD,"f").call(this,X(this,tD,"f"),B,X(this,QD,"f"));this[O0](),this.parsed=E}return B}parseAsync(D,u,F){let B=this.parse(D,u,F);return!a(B)?Promise.resolve(B):B}parseSync(D,u,F){let B=this.parse(D,u,F);if(a(B))throw new ED(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return B}parserConfiguration(D){return S("<object>",[D],arguments.length),w(this,VF,D,"f"),this}pkgConf(D,u){S("<string> [string]",[D,u],arguments.length);let F=null,B=this[W0](u||X(this,Cu,"f"));if(B[D]&&typeof B[D]==="object")F=yu(B[D],u||X(this,Cu,"f"),this[Yu]()["deep-merge-config"]||!1,X(this,c,"f")),X(this,v,"f").configObjects=(X(this,v,"f").configObjects||[]).concat(F);return this}positional(D,u){S("<string> <object>",[D,u],arguments.length);let F=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];u=lD(u,(C,$)=>{if(C==="type"&&!["string","number","boolean"].includes($))return!1;return F.includes(C)});let B=X(this,pu,"f").fullCommands[X(this,pu,"f").fullCommands.length-1],E=B?X(this,BD,"f").cmdToParseOptions(B):{array:[],alias:{},default:{},demand:{}};return Au(E).forEach((C)=>{let $=E[C];if(Array.isArray($)){if($.indexOf(D)!==-1)u[C]=!0}else if($[D]&&!(C in u))u[C]=$[D]}),this.group(D,X(this,k,"f").getPositionalGroupName()),this.option(D,u)}recommendCommands(D=!0){return S("[boolean]",[D],arguments.length),w(this,HF,D,"f"),this}required(D,u,F){return this.demand(D,u,F)}require(D,u,F){return this.demand(D,u,F)}requiresArg(D){if(S("<array|string|object> [number]",[D],arguments.length),typeof D==="string"&&X(this,v,"f").narg[D])return this;else this[Ru](this.requiresArg.bind(this),"narg",D,NaN);return this}showCompletionScript(D,u){return S("[string] [string]",[D,u],arguments.length),D=D||this.$0,X(this,zu,"f").log(X(this,KD,"f").generateCompletionScript(D,u||X(this,UD,"f")||"completion")),this}showHelp(D){if(S("[string|function]",[D],arguments.length),w(this,jD,!0,"f"),!X(this,k,"f").hasCachedHelpMessage()){if(!this.parsed){let F=this[mu](X(this,oD,"f"),void 0,void 0,0,!0);if(a(F))return F.then(()=>{X(this,k,"f").showHelp(D)}),this}let u=X(this,BD,"f").runDefaultBuilderOn(this);if(a(u))return u.then(()=>{X(this,k,"f").showHelp(D)}),this}return X(this,k,"f").showHelp(D),this}scriptName(D){return this.customScriptName=!0,this.$0=D,this}showHelpOnFail(D,u){return S("[boolean|string] [string]",[D,u],arguments.length),X(this,k,"f").showHelpOnFail(D,u),this}showVersion(D){return S("[string|function]",[D],arguments.length),X(this,k,"f").showVersion(D),this}skipValidation(D){return S("<array|string>",[D],arguments.length),this[sD]("skipValidation",D),this}strict(D){return S("[boolean]",[D],arguments.length),w(this,Gu,D!==!1,"f"),this}strictCommands(D){return S("[boolean]",[D],arguments.length),w(this,Xu,D!==!1,"f"),this}strictOptions(D){return S("[boolean]",[D],arguments.length),w(this,Qu,D!==!1,"f"),this}string(D){return S("<array|string>",[D],arguments.length),this[sD]("string",D),this[Vu](D),this}terminalWidth(){return S([],0),X(this,c,"f").process.stdColumns}updateLocale(D){return this.updateStrings(D)}updateStrings(D){return S("<object>",[D],arguments.length),w(this,$u,!1,"f"),X(this,c,"f").y18n.updateLocale(D),this}usage(D,u,F,B){if(S("<string|null|undefined> [string|boolean] [function|object] [function]",[D,u,F,B],arguments.length),u!==void 0)if(qD(D,null,X(this,c,"f")),(D||"").match(/^\$0( |$)/))return this.command(D,u,F,B);else throw new ED(".usage() description must start with $0 if being used as alias for .command()");else return X(this,k,"f").usage(D),this}usageConfiguration(D){return S("<object>",[D],arguments.length),w(this,qF,D,"f"),this}version(D,u,F){if(S("[boolean|string] [string] [string]",[D,u,F],arguments.length),X(this,bD,"f"))this[Q0](X(this,bD,"f")),X(this,k,"f").version(void 0),w(this,bD,null,"f");if(arguments.length===0)F=this[v8](),D="version";else if(arguments.length===1){if(D===!1)return this;F=D,D="version"}else if(arguments.length===2)F=u,u=void 0;return w(this,bD,typeof D==="string"?D:"version","f"),u=u||X(this,k,"f").deferY18nLookup("Show version number"),X(this,k,"f").version(F||void 0),this.boolean(X(this,bD,"f")),this.describe(X(this,bD,"f"),u),this}wrap(D){return S("<number|null|undefined>",[D],arguments.length),X(this,k,"f").wrap(D),this}[(BD=new WeakMap,Cu=new WeakMap,pu=new WeakMap,KD=new WeakMap,UD=new WeakMap,GF=new WeakMap,tD=new WeakMap,$u=new WeakMap,XF=new WeakMap,AD=new WeakMap,QF=new WeakMap,LD=new WeakMap,ID=new WeakMap,jD=new WeakMap,TD=new WeakMap,YF=new WeakMap,zu=new WeakMap,QD=new WeakMap,v=new WeakMap,WF=new WeakMap,VF=new WeakMap,MD=new WeakMap,Zu=new WeakMap,Tu=new WeakMap,Ju=new WeakMap,oD=new WeakMap,HF=new WeakMap,c=new WeakMap,Gu=new WeakMap,Xu=new WeakMap,Qu=new WeakMap,k=new WeakMap,qF=new WeakMap,bD=new WeakMap,DD=new WeakMap,w8)](D){if(!D._||!D["--"])return D;D._.push.apply(D._,D["--"]);try{delete D["--"]}catch(u){}return D}[x8](){return{log:(...D)=>{if(!this[KF]())console.log(...D);if(w(this,jD,!0,"f"),X(this,QD,"f").length)w(this,QD,X(this,QD,"f")+`
|
|
80
80
|
`,"f");w(this,QD,X(this,QD,"f")+D.join(" "),"f")},error:(...D)=>{if(!this[KF]())console.error(...D);if(w(this,jD,!0,"f"),X(this,QD,"f").length)w(this,QD,X(this,QD,"f")+`
|
|
81
|
-
`,"f");w(this,QD,X(this,QD,"f")+D.join(" "),"f")}}}[X0](D){Au(X(this,h,"f")).forEach((u)=>{if(((B)=>B==="configObjects")(u))return;let F=X(this,h,"f")[u];if(Array.isArray(F)){if(F.includes(D))F.splice(F.indexOf(D),1)}else if(typeof F==="object")delete F[D]}),delete X(this,k,"f").getDescriptions()[D]}[b8](D,u,F){if(!X(this,XF,"f")[F])X(this,c,"f").process.emitWarning(D,u),X(this,XF,"f")[F]=!0}[f8](){X(this,QF,"f").push({options:X(this,h,"f"),configObjects:X(this,h,"f").configObjects.slice(0),exitProcess:X(this,AD,"f"),groups:X(this,ID,"f"),strict:X(this,Gu,"f"),strictCommands:X(this,Xu,"f"),strictOptions:X(this,Qu,"f"),completionCommand:X(this,UD,"f"),output:X(this,QD,"f"),exitError:X(this,tD,"f"),hasOutput:X(this,jD,"f"),parsed:this.parsed,parseFn:X(this,MD,"f"),parseContext:X(this,Zu,"f")}),X(this,k,"f").freeze(),X(this,DD,"f").freeze(),X(this,BD,"f").freeze(),X(this,LD,"f").freeze()}[h8](){let D="",u;if(/\b(node|iojs|electron)(\.exe)?$/.test(X(this,c,"f").process.argv()[0]))u=X(this,c,"f").process.argv().slice(1,2);else u=X(this,c,"f").process.argv().slice(0,1);if(D=u.map((F)=>{let B=this[o8](X(this,Cu,"f"),F);return F.match(/^(\/|([a-zA-Z]:)?\\)/)&&B.length<F.length?B:F}).join(" ").trim(),X(this,c,"f").getEnv("_")&&X(this,c,"f").getProcessArgvBin()===X(this,c,"f").getEnv("_"))D=X(this,c,"f").getEnv("_").replace(`${X(this,c,"f").path.dirname(X(this,c,"f").process.execPath())}/`,"");return D}[Yu](){return X(this,VF,"f")}[v8](){return X(this,qF,"f")}[Q0](){if(!X(this,$u,"f"))return;let D=X(this,c,"f").getEnv("LC_ALL")||X(this,c,"f").getEnv("LC_MESSAGES")||X(this,c,"f").getEnv("LANG")||X(this,c,"f").getEnv("LANGUAGE")||"en_US";this.locale(D.replace(/[.:].*/,""))}[y8](){return this[Y0]().version||"unknown"}[p8](D){let u=D["--"]?D["--"]:D._;for(let F=0,B;(B=u[F])!==void 0;F++)if(X(this,c,"f").Parser.looksLikeNumber(B)&&Number.isSafeInteger(Math.floor(parseFloat(`${B}`))))u[F]=Number(B);return D}[Y0](D){let u=D||"*";if(X(this,Tu,"f")[u])return X(this,Tu,"f")[u];let F={};try{let B=D||X(this,c,"f").mainFilename;if(X(this,c,"f").path.extname(B))B=X(this,c,"f").path.dirname(B);let E=X(this,c,"f").findUp(B,(C,$)=>{if($.includes("package.json"))return"package.json";else return});qD(E,void 0,X(this,c,"f")),F=JSON.parse(X(this,c,"f").readFileSync(E,"utf8"))}catch(B){}return X(this,Tu,"f")[u]=F||{},X(this,Tu,"f")[u]}[sD](D,u){u=[].concat(u),u.forEach((F)=>{F=this[H0](F),X(this,h,"f")[D].push(F)})}[Ru](D,u,F,B){this[V0](D,u,F,B,(E,C,$)=>{X(this,h,"f")[E][C]=$})}[W0](D,u,F,B){this[V0](D,u,F,B,(E,C,$)=>{X(this,h,"f")[E][C]=(X(this,h,"f")[E][C]||[]).concat($)})}[V0](D,u,F,B,E){if(Array.isArray(F))F.forEach((C)=>{D(C,B)});else if(((C)=>typeof C==="object")(F))for(let C of Au(F))D(C,F[C]);else E(u,this[H0](F),B)}[H0](D){if(D==="__proto__")return"___proto___";return D}[q0](D,u){return this[Ru](this[q0].bind(this),"key",D,u),this}[K0](){var D,u,F,B,E,C,$,z,Z,J,Q,G;let Y=X(this,QF,"f").pop();qD(Y,void 0,X(this,c,"f"));let V;D=this,u=this,F=this,B=this,E=this,C=this,$=this,z=this,Z=this,J=this,Q=this,G=this,{options:{set value(H){w(D,h,H,"f")}}.value,configObjects:V,exitProcess:{set value(H){w(u,AD,H,"f")}}.value,groups:{set value(H){w(F,ID,H,"f")}}.value,output:{set value(H){w(B,QD,H,"f")}}.value,exitError:{set value(H){w(E,tD,H,"f")}}.value,hasOutput:{set value(H){w(C,jD,H,"f")}}.value,parsed:this.parsed,strict:{set value(H){w($,Gu,H,"f")}}.value,strictCommands:{set value(H){w(z,Xu,H,"f")}}.value,strictOptions:{set value(H){w(Z,Qu,H,"f")}}.value,completionCommand:{set value(H){w(J,UD,H,"f")}}.value,parseFn:{set value(H){w(Q,MD,H,"f")}}.value,parseContext:{set value(H){w(G,Zu,H,"f")}}.value}=Y,X(this,h,"f").configObjects=V,X(this,k,"f").unfreeze(),X(this,DD,"f").unfreeze(),X(this,BD,"f").unfreeze(),X(this,LD,"f").unfreeze()}[m8](D,u){return Bu(u,(F)=>{return D(F),F})}getInternalMethods(){return{getCommandInstance:this[g8].bind(this),getContext:this[c8].bind(this),getHasOutput:this[d8].bind(this),getLoggerInstance:this[k8].bind(this),getParseContext:this[i8].bind(this),getParserConfiguration:this[Yu].bind(this),getUsageConfiguration:this[v8].bind(this),getUsageInstance:this[l8].bind(this),getValidationInstance:this[n8].bind(this),hasParseCallback:this[KF].bind(this),isGlobalContext:this[t8].bind(this),postProcess:this[Wu].bind(this),reset:this[O0].bind(this),runValidation:this[U0].bind(this),runYargsParserAndExecuteCommands:this[mu].bind(this),setHasOutput:this[s8].bind(this)}}[g8](){return X(this,BD,"f")}[c8](){return X(this,pu,"f")}[d8](){return X(this,jD,"f")}[k8](){return X(this,zu,"f")}[i8](){return X(this,Zu,"f")||{}}[l8](){return X(this,k,"f")}[n8](){return X(this,DD,"f")}[KF](){return!!X(this,MD,"f")}[t8](){return X(this,YF,"f")}[Wu](D,u,F,B){if(F)return D;if(a(D))return D;if(!u)D=this[x8](D);if(this[Yu]()["parse-positional-numbers"]||this[Yu]()["parse-positional-numbers"]===void 0)D=this[p8](D);if(B)D=Eu(D,this,X(this,LD,"f").getMiddleware(),!1);return D}[O0](D={}){w(this,h,X(this,h,"f")||{},"f");let u={};u.local=X(this,h,"f").local||[],u.configObjects=X(this,h,"f").configObjects||[];let F={};u.local.forEach((C)=>{F[C]=!0,(D[C]||[]).forEach(($)=>{F[$]=!0})}),Object.assign(X(this,Ju,"f"),Object.keys(X(this,ID,"f")).reduce((C,$)=>{let z=X(this,ID,"f")[$].filter((Z)=>!(Z in F));if(z.length>0)C[$]=z;return C},{})),w(this,ID,{},"f");let B=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],E=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(B.forEach((C)=>{u[C]=(X(this,h,"f")[C]||[]).filter(($)=>!F[$])}),E.forEach((C)=>{u[C]=lD(X(this,h,"f")[C],($)=>!F[$])}),u.envPrefix=X(this,h,"f").envPrefix,w(this,h,u,"f"),w(this,k,X(this,k,"f")?X(this,k,"f").reset(F):_8(this,X(this,c,"f")),"f"),w(this,DD,X(this,DD,"f")?X(this,DD,"f").reset(F):S8(this,X(this,k,"f"),X(this,c,"f")),"f"),w(this,BD,X(this,BD,"f")?X(this,BD,"f").reset():U8(X(this,k,"f"),X(this,DD,"f"),X(this,LD,"f"),X(this,c,"f")),"f"),!X(this,KD,"f"))w(this,KD,T8(this,X(this,k,"f"),X(this,BD,"f"),X(this,c,"f")),"f");return X(this,LD,"f").reset(),w(this,UD,null,"f"),w(this,QD,"","f"),w(this,tD,null,"f"),w(this,jD,!1,"f"),this.parsed=!1,this}[o8](D,u){return X(this,c,"f").path.relative(D,u)}[mu](D,u,F,B=0,E=!1){var C,$,z,Z;let J=!!F||E;D=D||X(this,oD,"f"),X(this,h,"f").__=X(this,c,"f").y18n.__,X(this,h,"f").configuration=this[Yu]();let Q=!!X(this,h,"f").configuration["populate--"],G=Object.assign({},X(this,h,"f").configuration,{"populate--":!0}),Y=X(this,c,"f").Parser.detailed(D,Object.assign({},X(this,h,"f"),{configuration:{"parse-positional-numbers":!1,...G}})),V=Object.assign(Y.argv,X(this,Zu,"f")),H=void 0,W=Y.aliases,K=!1,N=!1;if(Object.keys(V).forEach((j)=>{if(j===X(this,TD,"f")&&V[j])K=!0;else if(j===X(this,bD,"f")&&V[j])N=!0}),V.$0=this.$0,this.parsed=Y,B===0)X(this,k,"f").clearCachedHelpMessage();try{if(this[Q0](),u)return this[Wu](V,Q,!!F,!1);if(X(this,TD,"f")){if([X(this,TD,"f")].concat(W[X(this,TD,"f")]||[]).filter((f)=>f.length>1).includes(""+V._[V._.length-1]))V._.pop(),K=!0}w(this,YF,!1,"f");let j=X(this,BD,"f").getCommands(),L=((C=X(this,KD,"f"))===null||C===void 0?void 0:C.completionKey)?[($=X(this,KD,"f"))===null||$===void 0?void 0:$.completionKey,...(Z=this.getAliases()[(z=X(this,KD,"f"))===null||z===void 0?void 0:z.completionKey])!==null&&Z!==void 0?Z:[]].some((T)=>Object.prototype.hasOwnProperty.call(V,T)):!1,M=K||L||E;if(V._.length){if(j.length){let T;for(let f=B||0,p;V._[f]!==void 0;f++)if(p=String(V._[f]),j.includes(p)&&p!==X(this,UD,"f")){let $D=X(this,BD,"f").runCommand(p,this,Y,f+1,E,K||N||E);return this[Wu]($D,Q,!!F,!1)}else if(!T&&p!==X(this,UD,"f")){T=p;break}if(!X(this,BD,"f").hasDefaultCommand()&&X(this,HF,"f")&&T&&!M)X(this,DD,"f").recommendCommands(T,j)}if(X(this,UD,"f")&&V._.includes(X(this,UD,"f"))&&!L){if(X(this,AD,"f"))nD(!0);this.showCompletionScript(),this.exit(0)}}if(X(this,BD,"f").hasDefaultCommand()&&!M){let T=X(this,BD,"f").runCommand(null,this,Y,0,E,K||N||E);return this[Wu](T,Q,!!F,!1)}if(L){if(X(this,AD,"f"))nD(!0);D=[].concat(D);let T=D.slice(D.indexOf(`--${X(this,KD,"f").completionKey}`)+1);return X(this,KD,"f").getCompletion(T,(f,p)=>{if(f)throw new ED(f.message);(p||[]).forEach(($D)=>{X(this,zu,"f").log($D)}),this.exit(0)}),this[Wu](V,!Q,!!F,!1)}if(!X(this,jD,"f")){if(K){if(X(this,AD,"f"))nD(!0);J=!0,this.showHelp((T)=>{X(this,zu,"f").log(T),this.exit(0)})}else if(N){if(X(this,AD,"f"))nD(!0);J=!0,X(this,k,"f").showVersion("log"),this.exit(0)}}if(!J&&X(this,h,"f").skipValidation.length>0)J=Object.keys(V).some((T)=>X(this,h,"f").skipValidation.indexOf(T)>=0&&V[T]===!0);if(!J){if(Y.error)throw new ED(Y.error.message);if(!L){let T=this[U0](W,{},Y.error);if(!F)H=Eu(V,this,X(this,LD,"f").getMiddleware(),!0);if(H=this[m8](T,H!==null&&H!==void 0?H:V),a(H)&&!F)H=H.then(()=>{return Eu(V,this,X(this,LD,"f").getMiddleware(),!1)})}}}catch(j){if(j instanceof ED)X(this,k,"f").fail(j.message,j);else throw j}return this[Wu](H!==null&&H!==void 0?H:V,Q,!!F,!0)}[U0](D,u,F,B){let E={...this.getDemandedOptions()};return(C)=>{if(F)throw new ED(F.message);X(this,DD,"f").nonOptionCount(C),X(this,DD,"f").requiredArguments(C,E);let $=!1;if(X(this,Xu,"f"))$=X(this,DD,"f").unknownCommands(C);if(X(this,Gu,"f")&&!$)X(this,DD,"f").unknownArguments(C,D,u,!!B);else if(X(this,Qu,"f"))X(this,DD,"f").unknownArguments(C,D,{},!1,!1);X(this,DD,"f").limitedChoices(C),X(this,DD,"f").implications(C),X(this,DD,"f").conflicting(C)}}[s8](){w(this,jD,!0,"f")}[Vu](D){if(typeof D==="string")X(this,h,"f").key[D]=!0;else for(let u of D)X(this,h,"f").key[u]=!0}}function j8(D){return!!D&&typeof D.getInternalMethods==="function"}var Z7=r8($0),e8=Z7;import{existsSync as OF,readFileSync as _0,writeFileSync as j0,mkdirSync as F1}from"node:fs";import{homedir as J7}from"node:os";import{join as Hu,dirname as N0}from"node:path";function A0(){return process.env.HOME||J7()}function E1(){return Hu(A0(),".config","slack-cli","profiles.json")}function UF(){return Hu(process.cwd(),".slack-cli","workspace")}function jF(){return Hu(A0(),".slack-cli","workspace")}function gu(){let D=E1();if(!OF(D))return{profiles:{}};return JSON.parse(_0(D,"utf8"))}function G7(D){let u=E1();F1(N0(u),{recursive:!0}),j0(u,JSON.stringify(D,null,2)+`
|
|
82
|
-
`)}function Pu(D){if(!OF(D))return;return
|
|
83
|
-
`);
|
|
81
|
+
`,"f");w(this,QD,X(this,QD,"f")+D.join(" "),"f")}}}[Q0](D){Au(X(this,v,"f")).forEach((u)=>{if(((B)=>B==="configObjects")(u))return;let F=X(this,v,"f")[u];if(Array.isArray(F)){if(F.includes(D))F.splice(F.indexOf(D),1)}else if(typeof F==="object")delete F[D]}),delete X(this,k,"f").getDescriptions()[D]}[I8](D,u,F){if(!X(this,XF,"f")[F])X(this,c,"f").process.emitWarning(D,u),X(this,XF,"f")[F]=!0}[b8](){X(this,QF,"f").push({options:X(this,v,"f"),configObjects:X(this,v,"f").configObjects.slice(0),exitProcess:X(this,AD,"f"),groups:X(this,ID,"f"),strict:X(this,Gu,"f"),strictCommands:X(this,Xu,"f"),strictOptions:X(this,Qu,"f"),completionCommand:X(this,UD,"f"),output:X(this,QD,"f"),exitError:X(this,tD,"f"),hasOutput:X(this,jD,"f"),parsed:this.parsed,parseFn:X(this,MD,"f"),parseContext:X(this,Zu,"f")}),X(this,k,"f").freeze(),X(this,DD,"f").freeze(),X(this,BD,"f").freeze(),X(this,LD,"f").freeze()}[f8](){let D="",u;if(/\b(node|iojs|electron)(\.exe)?$/.test(X(this,c,"f").process.argv()[0]))u=X(this,c,"f").process.argv().slice(1,2);else u=X(this,c,"f").process.argv().slice(0,1);if(D=u.map((F)=>{let B=this[t8](X(this,Cu,"f"),F);return F.match(/^(\/|([a-zA-Z]:)?\\)/)&&B.length<F.length?B:F}).join(" ").trim(),X(this,c,"f").getEnv("_")&&X(this,c,"f").getProcessArgvBin()===X(this,c,"f").getEnv("_"))D=X(this,c,"f").getEnv("_").replace(`${X(this,c,"f").path.dirname(X(this,c,"f").process.execPath())}/`,"");return D}[Yu](){return X(this,VF,"f")}[h8](){return X(this,qF,"f")}[Y0](){if(!X(this,$u,"f"))return;let D=X(this,c,"f").getEnv("LC_ALL")||X(this,c,"f").getEnv("LC_MESSAGES")||X(this,c,"f").getEnv("LANG")||X(this,c,"f").getEnv("LANGUAGE")||"en_US";this.locale(D.replace(/[.:].*/,""))}[v8](){return this[W0]().version||"unknown"}[y8](D){let u=D["--"]?D["--"]:D._;for(let F=0,B;(B=u[F])!==void 0;F++)if(X(this,c,"f").Parser.looksLikeNumber(B)&&Number.isSafeInteger(Math.floor(parseFloat(`${B}`))))u[F]=Number(B);return D}[W0](D){let u=D||"*";if(X(this,Tu,"f")[u])return X(this,Tu,"f")[u];let F={};try{let B=D||X(this,c,"f").mainFilename;if(X(this,c,"f").path.extname(B))B=X(this,c,"f").path.dirname(B);let E=X(this,c,"f").findUp(B,(C,$)=>{if($.includes("package.json"))return"package.json";else return});qD(E,void 0,X(this,c,"f")),F=JSON.parse(X(this,c,"f").readFileSync(E,"utf8"))}catch(B){}return X(this,Tu,"f")[u]=F||{},X(this,Tu,"f")[u]}[sD](D,u){u=[].concat(u),u.forEach((F)=>{F=this[q0](F),X(this,v,"f")[D].push(F)})}[Ru](D,u,F,B){this[H0](D,u,F,B,(E,C,$)=>{X(this,v,"f")[E][C]=$})}[V0](D,u,F,B){this[H0](D,u,F,B,(E,C,$)=>{X(this,v,"f")[E][C]=(X(this,v,"f")[E][C]||[]).concat($)})}[H0](D,u,F,B,E){if(Array.isArray(F))F.forEach((C)=>{D(C,B)});else if(((C)=>typeof C==="object")(F))for(let C of Au(F))D(C,F[C]);else E(u,this[q0](F),B)}[q0](D){if(D==="__proto__")return"___proto___";return D}[K0](D,u){return this[Ru](this[K0].bind(this),"key",D,u),this}[O0](){var D,u,F,B,E,C,$,z,Z,J,Q,G;let Y=X(this,QF,"f").pop();qD(Y,void 0,X(this,c,"f"));let V;D=this,u=this,F=this,B=this,E=this,C=this,$=this,z=this,Z=this,J=this,Q=this,G=this,{options:{set value(H){w(D,v,H,"f")}}.value,configObjects:V,exitProcess:{set value(H){w(u,AD,H,"f")}}.value,groups:{set value(H){w(F,ID,H,"f")}}.value,output:{set value(H){w(B,QD,H,"f")}}.value,exitError:{set value(H){w(E,tD,H,"f")}}.value,hasOutput:{set value(H){w(C,jD,H,"f")}}.value,parsed:this.parsed,strict:{set value(H){w($,Gu,H,"f")}}.value,strictCommands:{set value(H){w(z,Xu,H,"f")}}.value,strictOptions:{set value(H){w(Z,Qu,H,"f")}}.value,completionCommand:{set value(H){w(J,UD,H,"f")}}.value,parseFn:{set value(H){w(Q,MD,H,"f")}}.value,parseContext:{set value(H){w(G,Zu,H,"f")}}.value}=Y,X(this,v,"f").configObjects=V,X(this,k,"f").unfreeze(),X(this,DD,"f").unfreeze(),X(this,BD,"f").unfreeze(),X(this,LD,"f").unfreeze()}[p8](D,u){return Bu(u,(F)=>{return D(F),F})}getInternalMethods(){return{getCommandInstance:this[m8].bind(this),getContext:this[g8].bind(this),getHasOutput:this[c8].bind(this),getLoggerInstance:this[d8].bind(this),getParseContext:this[k8].bind(this),getParserConfiguration:this[Yu].bind(this),getUsageConfiguration:this[h8].bind(this),getUsageInstance:this[i8].bind(this),getValidationInstance:this[l8].bind(this),hasParseCallback:this[KF].bind(this),isGlobalContext:this[n8].bind(this),postProcess:this[Wu].bind(this),reset:this[U0].bind(this),runValidation:this[j0].bind(this),runYargsParserAndExecuteCommands:this[mu].bind(this),setHasOutput:this[o8].bind(this)}}[m8](){return X(this,BD,"f")}[g8](){return X(this,pu,"f")}[c8](){return X(this,jD,"f")}[d8](){return X(this,zu,"f")}[k8](){return X(this,Zu,"f")||{}}[i8](){return X(this,k,"f")}[l8](){return X(this,DD,"f")}[KF](){return!!X(this,MD,"f")}[n8](){return X(this,YF,"f")}[Wu](D,u,F,B){if(F)return D;if(a(D))return D;if(!u)D=this[w8](D);if(this[Yu]()["parse-positional-numbers"]||this[Yu]()["parse-positional-numbers"]===void 0)D=this[y8](D);if(B)D=Eu(D,this,X(this,LD,"f").getMiddleware(),!1);return D}[U0](D={}){w(this,v,X(this,v,"f")||{},"f");let u={};u.local=X(this,v,"f").local||[],u.configObjects=X(this,v,"f").configObjects||[];let F={};u.local.forEach((C)=>{F[C]=!0,(D[C]||[]).forEach(($)=>{F[$]=!0})}),Object.assign(X(this,Ju,"f"),Object.keys(X(this,ID,"f")).reduce((C,$)=>{let z=X(this,ID,"f")[$].filter((Z)=>!(Z in F));if(z.length>0)C[$]=z;return C},{})),w(this,ID,{},"f");let B=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],E=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(B.forEach((C)=>{u[C]=(X(this,v,"f")[C]||[]).filter(($)=>!F[$])}),E.forEach((C)=>{u[C]=lD(X(this,v,"f")[C],($)=>!F[$])}),u.envPrefix=X(this,v,"f").envPrefix,w(this,v,u,"f"),w(this,k,X(this,k,"f")?X(this,k,"f").reset(F):M8(this,X(this,c,"f")),"f"),w(this,DD,X(this,DD,"f")?X(this,DD,"f").reset(F):P8(this,X(this,k,"f"),X(this,c,"f")),"f"),w(this,BD,X(this,BD,"f")?X(this,BD,"f").reset():O8(X(this,k,"f"),X(this,DD,"f"),X(this,LD,"f"),X(this,c,"f")),"f"),!X(this,KD,"f"))w(this,KD,L8(this,X(this,k,"f"),X(this,BD,"f"),X(this,c,"f")),"f");return X(this,LD,"f").reset(),w(this,UD,null,"f"),w(this,QD,"","f"),w(this,tD,null,"f"),w(this,jD,!1,"f"),this.parsed=!1,this}[t8](D,u){return X(this,c,"f").path.relative(D,u)}[mu](D,u,F,B=0,E=!1){var C,$,z,Z;let J=!!F||E;D=D||X(this,oD,"f"),X(this,v,"f").__=X(this,c,"f").y18n.__,X(this,v,"f").configuration=this[Yu]();let Q=!!X(this,v,"f").configuration["populate--"],G=Object.assign({},X(this,v,"f").configuration,{"populate--":!0}),Y=X(this,c,"f").Parser.detailed(D,Object.assign({},X(this,v,"f"),{configuration:{"parse-positional-numbers":!1,...G}})),V=Object.assign(Y.argv,X(this,Zu,"f")),H=void 0,W=Y.aliases,K=!1,N=!1;if(Object.keys(V).forEach((j)=>{if(j===X(this,TD,"f")&&V[j])K=!0;else if(j===X(this,bD,"f")&&V[j])N=!0}),V.$0=this.$0,this.parsed=Y,B===0)X(this,k,"f").clearCachedHelpMessage();try{if(this[Y0](),u)return this[Wu](V,Q,!!F,!1);if(X(this,TD,"f")){if([X(this,TD,"f")].concat(W[X(this,TD,"f")]||[]).filter((h)=>h.length>1).includes(""+V._[V._.length-1]))V._.pop(),K=!0}w(this,YF,!1,"f");let j=X(this,BD,"f").getCommands(),L=((C=X(this,KD,"f"))===null||C===void 0?void 0:C.completionKey)?[($=X(this,KD,"f"))===null||$===void 0?void 0:$.completionKey,...(Z=this.getAliases()[(z=X(this,KD,"f"))===null||z===void 0?void 0:z.completionKey])!==null&&Z!==void 0?Z:[]].some((T)=>Object.prototype.hasOwnProperty.call(V,T)):!1,M=K||L||E;if(V._.length){if(j.length){let T;for(let h=B||0,p;V._[h]!==void 0;h++)if(p=String(V._[h]),j.includes(p)&&p!==X(this,UD,"f")){let $D=X(this,BD,"f").runCommand(p,this,Y,h+1,E,K||N||E);return this[Wu]($D,Q,!!F,!1)}else if(!T&&p!==X(this,UD,"f")){T=p;break}if(!X(this,BD,"f").hasDefaultCommand()&&X(this,HF,"f")&&T&&!M)X(this,DD,"f").recommendCommands(T,j)}if(X(this,UD,"f")&&V._.includes(X(this,UD,"f"))&&!L){if(X(this,AD,"f"))nD(!0);this.showCompletionScript(),this.exit(0)}}if(X(this,BD,"f").hasDefaultCommand()&&!M){let T=X(this,BD,"f").runCommand(null,this,Y,0,E,K||N||E);return this[Wu](T,Q,!!F,!1)}if(L){if(X(this,AD,"f"))nD(!0);D=[].concat(D);let T=D.slice(D.indexOf(`--${X(this,KD,"f").completionKey}`)+1);return X(this,KD,"f").getCompletion(T,(h,p)=>{if(h)throw new ED(h.message);(p||[]).forEach(($D)=>{X(this,zu,"f").log($D)}),this.exit(0)}),this[Wu](V,!Q,!!F,!1)}if(!X(this,jD,"f")){if(K){if(X(this,AD,"f"))nD(!0);J=!0,this.showHelp((T)=>{X(this,zu,"f").log(T),this.exit(0)})}else if(N){if(X(this,AD,"f"))nD(!0);J=!0,X(this,k,"f").showVersion("log"),this.exit(0)}}if(!J&&X(this,v,"f").skipValidation.length>0)J=Object.keys(V).some((T)=>X(this,v,"f").skipValidation.indexOf(T)>=0&&V[T]===!0);if(!J){if(Y.error)throw new ED(Y.error.message);if(!L){let T=this[j0](W,{},Y.error);if(!F)H=Eu(V,this,X(this,LD,"f").getMiddleware(),!0);if(H=this[p8](T,H!==null&&H!==void 0?H:V),a(H)&&!F)H=H.then(()=>{return Eu(V,this,X(this,LD,"f").getMiddleware(),!1)})}}}catch(j){if(j instanceof ED)X(this,k,"f").fail(j.message,j);else throw j}return this[Wu](H!==null&&H!==void 0?H:V,Q,!!F,!0)}[j0](D,u,F,B){let E={...this.getDemandedOptions()};return(C)=>{if(F)throw new ED(F.message);X(this,DD,"f").nonOptionCount(C),X(this,DD,"f").requiredArguments(C,E);let $=!1;if(X(this,Xu,"f"))$=X(this,DD,"f").unknownCommands(C);if(X(this,Gu,"f")&&!$)X(this,DD,"f").unknownArguments(C,D,u,!!B);else if(X(this,Qu,"f"))X(this,DD,"f").unknownArguments(C,D,{},!1,!1);X(this,DD,"f").limitedChoices(C),X(this,DD,"f").implications(C),X(this,DD,"f").conflicting(C)}}[o8](){w(this,jD,!0,"f")}[Vu](D){if(typeof D==="string")X(this,v,"f").key[D]=!0;else for(let u of D)X(this,v,"f").key[u]=!0}}function U8(D){return!!D&&typeof D.getInternalMethods==="function"}var Z7=s8(z0),a8=Z7;import{existsSync as OF,readFileSync as N0,writeFileSync as M0,mkdirSync as u1}from"node:fs";import{homedir as J7}from"node:os";import{join as Hu,dirname as A0}from"node:path";function L0(){return process.env.HOME||J7()}function F1(){return Hu(L0(),".config","slack-cli","profiles.json")}function UF(){return Hu(process.cwd(),".slack-cli","workspace")}function jF(){return Hu(L0(),".slack-cli","workspace")}function gu(){let D=F1();if(!OF(D))return{profiles:{}};return JSON.parse(N0(D,"utf8"))}function G7(D){let u=F1();u1(A0(u),{recursive:!0}),M0(u,JSON.stringify(D,null,2)+`
|
|
82
|
+
`)}function Pu(D){if(!OF(D))return;return N0(D,"utf8").trim()||void 0}function e8(D,u){let F=A0(D);u1(F,{recursive:!0});let B=Hu(F,".gitignore");if(!OF(B))M0(B,`*
|
|
83
|
+
`);M0(D,u+`
|
|
84
84
|
`)}function X7(D){let u={};for(let F of D.split(`
|
|
85
|
-
`)){let B=F.trim();if(!B||B.startsWith("#"))continue;let E=B.indexOf("=");if(E===-1)continue;let C=B.slice(0,E).trim(),$=B.slice(E+1).trim();if($.startsWith('"')&&$.endsWith('"')||$.startsWith("'")&&$.endsWith("'"))$=$.slice(1,-1);u[C]=$}return u}function
|
|
86
|
-
`+" Migrate to SLACK_TOKEN=... or remove from your shell config.")}}let C=
|
|
85
|
+
`)){let B=F.trim();if(!B||B.startsWith("#"))continue;let E=B.indexOf("=");if(E===-1)continue;let C=B.slice(0,E).trim(),$=B.slice(E+1).trim();if($.startsWith('"')&&$.endsWith('"')||$.startsWith("'")&&$.endsWith("'"))$=$.slice(1,-1);u[C]=$}return u}function D1(D){if(!OF(D))return{};try{return X7(N0(D,"utf8"))}catch{return{}}}function _0(D,u){let F=L0(),B=D;while(!0){for(let $ of[Hu(B,".slack-term",".env.local"),Hu(B,".env.local")]){let z=D1($);for(let Z of u)if(z[Z])return z[Z]}if(B===F)break;let C=A0(B);if(C===B)break;B=C}let E=D1(Hu(F,".slack-term",".env.local"));for(let C of u)if(E[C])return E[C];return}function T0(){let D=gu(),u=Pu(UF()),F=Pu(jF()),B=u??F;return Object.entries(D.profiles).map(([E,C])=>({name:E,profile:C,current:E===B}))}function E1(D){let u=gu();if(!(D in u.profiles))throw Error(`Profile not found: ${D}`);delete u.profiles[D],G7(u)}function B1(D,u=!1){let F=gu();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);if(u)e8(jF(),D);else e8(UF(),D)}function R0(D){let F=gu().profiles,B=Object.keys(F);if(D){let J=F[D];if(!J)throw Error(`Workspace "${D}" not found. Available: ${B.join(", ")||"(none)"}`);return J.token}if(process.env.SLACK_TOKEN)return process.env.SLACK_TOKEN;let E=process.env.SLACK_BOT_TOKEN??process.env.SLACK_MCP_XOXP_TOKEN;if(E&&B.length===0)return E;if(E&&B.length>0){let J=_0(process.cwd(),["SLACK_BOT_TOKEN","SLACK_MCP_XOXP_TOKEN"]);if(E!==J){if(!globalThis.__slackEnvWarnShown)globalThis.__slackEnvWarnShown=!0,console.error(`Warning: SLACK_MCP_XOXP_TOKEN / SLACK_BOT_TOKEN is set but workspace profiles exist — using profiles.
|
|
86
|
+
`+" Migrate to SLACK_TOKEN=... or remove from your shell config.")}}let C=_0(process.cwd(),["SLACK_TOKEN"]);if(C)return C;let $=process.env.SLACK_WORKSPACE;if($){let J=F[$];if(!J)throw Error(`Workspace "${$}" not found. Available: ${B.join(", ")||"(none)"}`);return J.token}let z=Pu(UF());if(z){let J=F[z];if(!J)throw Error(`Workspace "${z}" (from .slack-cli/workspace) not found in profiles.`);return J.token}let Z=Pu(jF());if(Z){let J=F[Z];if(!J)throw Error(`Workspace "${Z}" (from ~/.slack-cli/workspace) not found in profiles.`);return J.token}if(B.length>0)throw Error(`Workspace not selected (${B.join(", ")} available).
|
|
87
87
|
Select locally: slack auth use <name> (writes .slack-cli/workspace)
|
|
88
88
|
Select globally: slack auth use -g <name> (writes ~/.slack-cli/workspace)`);throw Error(`No Slack token found.
|
|
89
89
|
Run one of:
|
|
90
90
|
`+` slack auth token — paste an existing xoxp-/xoxb- token
|
|
91
91
|
`+` slack auth chrome — import from Chrome browser (macOS)
|
|
92
92
|
`+` slack auth app — guided Slack app creation
|
|
93
|
-
`+" Or set SLACK_TOKEN=xoxp-... in .slack-term/.env.local")}function
|
|
93
|
+
`+" Or set SLACK_TOKEN=xoxp-... in .slack-term/.env.local")}function P0(){let D=process.env.SLACK_BOT_TOKEN;return D&&D.startsWith("xoxb-")?D:void 0}function C1(D){let F=gu().profiles;if(D)return F[D]?.cookie;if(process.env.SLACK_COOKIE)return process.env.SLACK_COOKIE;if(process.env.SLACK_MCP_XOXD_COOKIE)return process.env.SLACK_MCP_XOXD_COOKIE;if(process.env.SLACK_MCP_XOXP_TOKEN&&Object.keys(F).length===0)return process.env.SLACK_MCP_XOXD_COOKIE;let E=_0(process.cwd(),["SLACK_COOKIE"]);if(E)return E;let C=process.env.SLACK_WORKSPACE;if(C)return F[C]?.cookie;let $=Pu(UF());if($)return F[$]?.cookie;let z=Pu(jF());if(z)return F[z]?.cookie;return}class fD extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function S0(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function $1(D,u,F,B){let E={};if(B)E.Cookie=`d=${B}`;let C=await fetch(`${S0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...E}});if(C.status===429){let z=parseInt(C.headers.get("retry-after")??"60",10);throw new fD(isNaN(z)?60:z)}let $=await C.json();if($.ok!==!0){let z=$.error??"unknown";if(z==="ratelimited")throw new fD(60);if(z==="invalid_auth"&&D.startsWith("xoxc-")&&!B)throw Error(`Desktop app token (xoxc-) needs its session cookie to be accepted by the public Slack API.
|
|
94
94
|
Attach it: slack auth chrome (macOS) or slack auth firefox
|
|
95
95
|
Or replace the token with an xoxp- user token:
|
|
96
96
|
slack auth token`);if((z==="missing_scope"||z==="cannot_dm_bot")&&D.startsWith("xoxb-"))throw Error(`Slack error on ${u}: ${z} — ${z==="cannot_dm_bot"?`you're authenticated as a bot, so "@you" is the bot itself and it can't DM itself`:"this bot token lacks the user scope this action needs"}.
|
|
97
97
|
Tailing/DMing people and listing users need a user session, not a bot token.
|
|
98
98
|
Switch workspace: slack auth ls then slack auth use <name>
|
|
99
|
-
Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${u}: ${z}`)}return $}async function Q7(D,u,F,B){let E={};if(B)E.Cookie=`d=${B}`;let C=await fetch(`${
|
|
99
|
+
Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${u}: ${z}`)}return $}async function Q7(D,u,F,B){let E={};if(B)E.Cookie=`d=${B}`;let C=await fetch(`${S0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...E}});if(C.status===429){let z=parseInt(C.headers.get("retry-after")??"60",10);throw new fD(isNaN(z)?60:z)}let $=await C.json();if($.ok!==!0){let z=$.error??"unknown";if(z==="ratelimited")throw new fD(60);if((z==="invalid_auth"||z==="not_authed")&&!D.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
|
|
100
100
|
Import from Slack desktop: slack auth login`);if((z==="invalid_auth"||z==="not_authed")&&!B)throw Error(`drafts.list also requires the xoxd session cookie.
|
|
101
|
-
Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${u}: ${z}`)}return $}function Y7(D,u,F={},B){let E=new URLSearchParams({token:D,...F});return Q7(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E.toString()},B)}function WD(D,u,F,B){let E=new URLSearchParams(F).toString();return
|
|
102
|
-
`)}function
|
|
103
|
-
`):[];for(let[E,C]of Object.entries(u)){let $=B.findIndex((Z)=>{let J=Z.trim();return J.startsWith(E+"=")||J.startsWith(E+" =")}),z=`${E}=${C}`;if($!==-1)B[$]=z;else B.push(z)}
|
|
101
|
+
Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${u}: ${z}`)}return $}function Y7(D,u,F={},B){let E=new URLSearchParams({token:D,...F});return Q7(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E.toString()},B)}function WD(D,u,F,B){let E=new URLSearchParams(F).toString();return $1(D,`${u}?${E}`,{method:"GET"},B)}function w0(D,u,F,B){return $1(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)},B)}async function Su(D,u){let F=await WD(D,"auth.test",{},u);return{team:F.team??"",teamId:F.team_id??"",url:F.url??"",user:F.user??"",userId:F.user_id??""}}async function z1(D,u){let F={Authorization:`Bearer ${D}`};if(u)F.Cookie=`d=${u}`;let B=await fetch(`${S0()}/auth.test`,{method:"GET",headers:F});if(B.status===429){let $=parseInt(B.headers.get("retry-after")??"60",10);throw new fD(isNaN($)?60:$)}let E=B.headers.get("x-oauth-scopes")??"",C=await B.json();if(C.ok!==!0)throw Error(`Slack error on auth.test: ${C.error??"unknown"}`);return{userId:C.user_id??"",user:C.user??"",botId:C.bot_id??"",team:C.team??"",url:C.url??"",scopes:E.split(",").map(($)=>$.trim()).filter(Boolean)}}async function Z1(D,u,F){let B=await WD(D,"bots.info",{bot:u},F);return{appId:B.bot?.app_id??"",userId:B.bot?.user_id??""}}async function du(D,u,F=20,B,E,C){let $={channel:u,limit:String(F)};if(B!==void 0)$.oldest=B;if(E!==void 0)$.cursor=E;return WD(D,"conversations.history",$,C)}async function J1(D,u,F,B=50,E){return WD(D,"conversations.replies",{channel:u,ts:F,limit:String(B)},E)}async function MF(D,u,F,B,E){await w0(D,"reactions.add",{channel:u,timestamp:F,name:B},E)}async function G1(D,u,F,B){return((await WD(D,"reactions.get",{channel:u,timestamp:F,full:"true"},B)).message?.reactions??[]).map((C)=>({name:String(C.name??""),users:Array.isArray(C.users)?C.users.map(String):[]}))}async function _F(D,u,F,B,E){await w0(D,"reactions.remove",{channel:u,timestamp:F,name:B},E)}async function W7(D,u,F){let E=(await w0(D,"conversations.open",{users:u},F)).channel?.id;if(!E)throw Error(`Failed to open DM with user ${u}`);return E}function cu(D){return D.toLowerCase().replace(/[-_\s]/g,"")}function x0(D){let u=D.match(/(?:app\.slack\.com\/client\/T[A-Za-z0-9]+|[A-Za-z0-9-]+\.slack\.com\/archives)\/([A-Za-z0-9]+)(?:\/p(\d{10})(\d{6}))?/);if(!u)return;let F=u[1],B=u[2]&&u[3]?`${u[2]}.${u[3]}`:void 0,E=D.indexOf("?"),C=E>=0?new URLSearchParams(D.slice(E)):void 0,$=C?.get("thread_ts")??void 0,J={channel:C?.get("cid")??void 0??F};if(B)J.ts=B;if($)J.threadTs=$;return J}function V7(D){return x0(D)?.channel}async function X1(D,u,F){let B=V7(u);if(B)return B;if(!u.startsWith("@")&&!u.startsWith("#")){if(/^[A-Za-z0-9]{9,}$/.test(u))return u;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${u}`)}let E=u.startsWith("@"),C=u.slice(1),$=cu(C);if(E){let J=await WD(D,"auth.test",{},F);if($==="you"||$==="me"||cu(J.user??"")===$){let H=J.user_id;if(!H)throw Error("auth.test did not return user_id");let K=((await WD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((N)=>N.user===H);if(K?.id)return String(K.id);return W7(D,H,F)}let G="",Y="";while(!0){let H={limit:"200"};if(Y)H.cursor=Y;let W=await WD(D,"users.list",H,F);for(let K of W.members??[]){let N=cu(K.name??""),j=cu(K.real_name??""),L=cu(K.profile?.display_name??"");if(N===$||j===$||L&&L===$){G=K.id??"";break}}if(G)break;if(Y=W.response_metadata?.next_cursor??"",!Y)break}if(!G)throw Error(`User not found: ${u}`);let V="";while(!0){let H={types:"im",limit:"200"};if(V)H.cursor=V;let W=await WD(D,"conversations.list",H,F);for(let K of W.channels??[])if(K.user===G)return String(K.id??"");if(V=W.response_metadata?.next_cursor??"",!V)break}throw Error(`No existing DM with ${u} (${G}). Open it once in Slack first.`)}let z=C.toLowerCase(),Z="";while(!0){let J={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(Z)J.cursor=Z;let Q=await WD(D,"conversations.list",J,F);for(let G of Q.channels??[])if(String(G.name??"").toLowerCase()===z)return String(G.id??"");if(Z=Q.response_metadata?.next_cursor??"",!Z)break}throw Error(`channel not found: ${u}`)}async function NF(D,u,F){try{let B=await WD(D,"users.info",{user:u},F),E=B.user?.profile?.display_name,C=E&&E.length>0?E:B.user?.real_name??B.user?.name??u,$=B.user?.name??u;return[C,$]}catch{return[u,u]}}async function AF(D,u,F){try{let B=await WD(D,"users.info",{user:u},F),E=B.user?.profile?.display_name;if(E&&E.length>0)return E;return B.user?.real_name??B.user?.name??u}catch{return u}}async function LF(D,u){let F=[],B="";while(!0){let E={limit:"200"};if(B)E.cursor=B;let C=await WD(D,"users.list",E,u);if(F.push(...C.members??[]),B=C.response_metadata?.next_cursor??"",!B)break}return{members:F}}async function I0(D,u,F){let B=[],E="";while(!0){let C={channel:u,limit:"200"};if(E)C.cursor=E;let $=await WD(D,"conversations.members",C,F);if(B.push(...$.members??[]),E=$.response_metadata?.next_cursor??"",!E)break}return B}async function b0(D,u,F){return WD(D,"users.info",{user:u},F)}async function Q1(D,u,F){return WD(D,"conversations.info",{channel:u},F)}async function Y1(D,u){let F=await Y7(D,"client.boot",{},u),B=typeof F.url==="string"?F.url:void 0;if(!B){let C=Object.keys(F).join(", ");throw Error(`client.boot did not return a WebSocket URL. Keys: ${C}`)}let E=F.self&&typeof F.self==="object"&&!Array.isArray(F.self)?F.self:{};return{wsUrl:B,selfId:typeof E.id==="string"?E.id:""}}var H7=["chat:write","im:write"],q7=["im:history","im:read"];async function f0(D){let{userId:u,botId:F,team:B,scopes:E}=await z1(D),C="";if(F)try{C=(await Z1(D,F)).appId}catch{C=""}let $=(J)=>E.includes(J),z=H7.filter((J)=>!$(J)),Z=q7.filter((J)=>!$(J));return{canSend:z.length===0,canReceiveReplies:Z.length===0,ok:z.length===0&&Z.length===0,botUserId:u,appId:C,team:B,grantedScopes:E,missingSendScopes:z,missingReplyScopes:Z}}function W1(D){return["",` Bot user: ${D.botUserId||"(unknown)"}`,` App ID: ${D.appId||"(unknown — bots.info unavailable)"}`,` Granted scopes: ${D.grantedScopes.join(", ")||"(none reported)"}`]}function h0(D,u=!1){let F=D.appId?`https://api.slack.com/apps/${D.appId}`:"https://api.slack.com/apps";if(D.ok){let E=["✓ Bot DM scopes are complete (send + read replies)."," Two-way replies also require the Messages Tab, which is not API-detectable.",' If recipients see "Sending messages to this app is turned off", enable it:',` ${F} → App Home → "Messages Tab" ON + "Allow users to send messages".`];return u?E:[...E,...W1(D)]}let B=[];if(!D.canSend)B.push(`⚠ This bot CANNOT send DMs — missing scope(s): ${D.missingSendScopes.join(", ")}.`);else B.push("⚠ This bot can send DMs, but the user's replies will NOT be readable.");return B.push(" Make escalation DMs two-way:"),B.push(` 1. ${F} → App Home → enable "Messages Tab" and check`),B.push(' "Allow users to send Slash commands and messages".'),B.push(` 2. OAuth & Permissions → add Bot Token Scopes: ${[...D.missingSendScopes,...D.missingReplyScopes].join(", ")}`),B.push(" 3. Reinstall the app to apply the new scopes."),u?B:[...B,...W1(D)]}import{createInterface as Ku}from"node:readline/promises";import{join as d0}from"node:path";import{homedir as S7}from"node:os";import{existsSync as v0,readFileSync as y0,writeFileSync as H1,mkdirSync as q1}from"node:fs";import{homedir as K7}from"node:os";import{join as p0,dirname as K1}from"node:path";function O1(){return process.env.HOME||K7()}function U1(){return p0(O1(),".config","slack-cli","profiles.json")}function O7(){return p0(process.cwd(),".slack-cli","workspace")}function U7(){return p0(O1(),".slack-cli","workspace")}function m0(){let D=U1();if(!v0(D))return{profiles:{}};return JSON.parse(y0(D,"utf8"))}function j1(D){let u=U1();q1(K1(u),{recursive:!0}),H1(u,JSON.stringify(D,null,2)+`
|
|
102
|
+
`)}function V1(D){if(!v0(D))return;return y0(D,"utf8").trim()||void 0}function M1(D,u){q1(K1(D),{recursive:!0});let F=v0(D)?y0(D,"utf8"):"",B=F?F.split(`
|
|
103
|
+
`):[];for(let[E,C]of Object.entries(u)){let $=B.findIndex((Z)=>{let J=Z.trim();return J.startsWith(E+"=")||J.startsWith(E+" =")}),z=`${E}=${C}`;if($!==-1)B[$]=z;else B.push(z)}H1(D,B.join(`
|
|
104
104
|
`).trimEnd()+`
|
|
105
|
-
`)}function TF(){let D=
|
|
105
|
+
`)}function TF(){let D=m0(),u=V1(O7()),F=V1(U7()),B=u??F;return Object.entries(D.profiles).map(([E,C])=>({name:E,profile:C,current:E===B}))}function g0(D,u){let F=m0();F.profiles[D]=u,j1(F)}function c0(D,u){let F=m0();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);F.profiles[D].cookie=u,j1(F)}import{readdirSync as RF,readFileSync as ku,existsSync as qu,copyFileSync as _1,unlinkSync as N1}from"node:fs";import{homedir as PF,tmpdir as A1}from"node:os";import{join as GD,dirname as j7}from"node:path";import{pbkdf2Sync as L1,createDecipheriv as T1}from"node:crypto";import{execSync as R1}from"node:child_process";function M7(){let D=PF();if(process.platform==="darwin")return GD(D,"Library","Application Support","Slack","Local Storage","leveldb");if(process.platform==="linux")return GD(D,".config","Slack","Local Storage","leveldb");if(process.platform==="win32"){let u=process.env.APPDATA??GD(D,"AppData","Roaming");return GD(u,"Slack","Local Storage","leveldb")}throw Error(`Unsupported platform: ${process.platform}`)}function _7(){let D=PF();if(process.platform==="darwin")return GD(D,"Library","Application Support","Slack","Cookies");return""}function N7(D,u){if(D.length<35||D.slice(0,3).toString()!=="v10")throw Error("Not a v10 encrypted cookie");let F=D.slice(19,35),B=D.slice(35),E=T1("aes-128-cbc",u,F);return E.setAutoPadding(!0),Buffer.concat([E.update(B),E.final()]).toString("utf8")}function A7(){if(process.platform!=="darwin")return;let D=_7();if(!qu(D))return;let u;try{u=R1('security find-generic-password -w -s "Slack Safe Storage" -a "Slack Key"',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}let F=L1(u,"saltysalt",1003,16,"sha1");try{let{default:B}=xD("bun:sqlite"),E=new B(D,{readonly:!0}),C=E.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(E.close(),!C)return;return N7(Buffer.from(C.encrypted_value),F)}catch{return}}async function P1(){let D=M7();if(!qu(D))throw Error(`Slack desktop app LevelDB not found at:
|
|
106
106
|
${D}
|
|
107
|
-
Is Slack installed and opened at least once?`);let u=RF(D).filter((z)=>z.endsWith(".ldb")||z.endsWith(".log"));if(u.length===0)throw Error(`No LevelDB data files found in ${D}`);let F=new Map;for(let z of u){let Z;try{Z=ku(GD(D,z),"latin1")}catch{continue}if(z.endsWith(".log"))for(let J of Z.matchAll(/"token":"(xoxc-[^"]+)"/g)){let Q=J[1],G=Q.split("-")[1]??"";if(!G||Q.length<40)continue;let Y=Math.max(0,J.index-2000),V=Math.min(Z.length,J.index+2000),H=Z.slice(Y,V),W=H.match(/"url":"(https:\/\/[a-z0-9-]+\.slack\.com\/)"/),K=H.match(/"(?:team_name|name)":"([^"]{2,60})"/),N=F.get(G);if(!N||Q.length>N.token.length){let j={token:Q,teamId:G},L=W?.[1]??N?.url,M=K?.[1]??N?.teamName;if(L)j.url=L;if(M)j.teamName=M;F.set(G,j)}}else for(let J of Z.matchAll(/xoxc-(\d+)-(\d+)-(\d+)/g)){let Q=J[1];if(F.has(Q))continue;let G=J.index+J[0].length,Y=Math.min(G+10,Z.length);while(G<Y&&(Z.charCodeAt(G)<48||Z.charCodeAt(G)>57))G++;let V="";while(G<Z.length&&Z.charCodeAt(G)>=48&&Z.charCodeAt(G)<=57)V+=Z[G++];if(Z[G]!=="-")continue;G++;let H="";while(G<Z.length){let K=Z.charCodeAt(G);if(K>=48&&K<=57||K>=97&&K<=102)H+=Z[G++];else break}if(H.length<20)continue;let W=`${J[0]}${V}-${H}`;F.set(Q,{token:W,teamId:Q})}}let E=RF(D).filter((z)=>z.endsWith(".ldb")||z.endsWith(".log")).map((z)=>{try{return ku(GD(D,z),"latin1").replace(/[^\x20-\x7e]/g," ")}catch{return""}}).join(" ");for(let z of F.values()){if(z.teamName)continue;let Z=E.indexOf(z.teamId);if(Z!==-1){let J=Math.max(0,Z-500),Q=Math.min(E.length,Z+500),Y=E.slice(J,Q).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(Y?.[1]){z.teamName=Y[1];continue}}if(!z.teamName&&z.url){let J=z.url.match(/https:\/\/([a-z0-9-]+)\.slack\.com\//)?.[1];if(J){let Q=E.indexOf(J);if(Q!==-1){let G=Math.max(0,Q-500),Y=Math.min(E.length,Q+500),H=E.slice(G,Y).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(H?.[1]){z.teamName=H[1];continue}}z.teamName=J.split("-").map((G)=>G.charAt(0).toUpperCase()+G.slice(1)).join(" ")}}}let C=A7(),$=[...F.values()];if(C)for(let z of $)z.cookie=C;return $}function L7(D,u){let F=(B,E)=>{try{let C=
|
|
108
|
-
`)){let z=$.trim();if(z.startsWith("[")){E="",C="";continue}let Z=z.indexOf("=");if(Z===-1)continue;let J=z.slice(0,Z).trim().toLowerCase(),Q=z.slice(Z+1).trim();if(J==="name")E=Q;if(J==="path")C=Q.split(/[\\/]/).pop()??Q;if(E&&C)F[C]=E,E="",C=""}}catch{}return F}function
|
|
107
|
+
Is Slack installed and opened at least once?`);let u=RF(D).filter((z)=>z.endsWith(".ldb")||z.endsWith(".log"));if(u.length===0)throw Error(`No LevelDB data files found in ${D}`);let F=new Map;for(let z of u){let Z;try{Z=ku(GD(D,z),"latin1")}catch{continue}if(z.endsWith(".log"))for(let J of Z.matchAll(/"token":"(xoxc-[^"]+)"/g)){let Q=J[1],G=Q.split("-")[1]??"";if(!G||Q.length<40)continue;let Y=Math.max(0,J.index-2000),V=Math.min(Z.length,J.index+2000),H=Z.slice(Y,V),W=H.match(/"url":"(https:\/\/[a-z0-9-]+\.slack\.com\/)"/),K=H.match(/"(?:team_name|name)":"([^"]{2,60})"/),N=F.get(G);if(!N||Q.length>N.token.length){let j={token:Q,teamId:G},L=W?.[1]??N?.url,M=K?.[1]??N?.teamName;if(L)j.url=L;if(M)j.teamName=M;F.set(G,j)}}else for(let J of Z.matchAll(/xoxc-(\d+)-(\d+)-(\d+)/g)){let Q=J[1];if(F.has(Q))continue;let G=J.index+J[0].length,Y=Math.min(G+10,Z.length);while(G<Y&&(Z.charCodeAt(G)<48||Z.charCodeAt(G)>57))G++;let V="";while(G<Z.length&&Z.charCodeAt(G)>=48&&Z.charCodeAt(G)<=57)V+=Z[G++];if(Z[G]!=="-")continue;G++;let H="";while(G<Z.length){let K=Z.charCodeAt(G);if(K>=48&&K<=57||K>=97&&K<=102)H+=Z[G++];else break}if(H.length<20)continue;let W=`${J[0]}${V}-${H}`;F.set(Q,{token:W,teamId:Q})}}let E=RF(D).filter((z)=>z.endsWith(".ldb")||z.endsWith(".log")).map((z)=>{try{return ku(GD(D,z),"latin1").replace(/[^\x20-\x7e]/g," ")}catch{return""}}).join(" ");for(let z of F.values()){if(z.teamName)continue;let Z=E.indexOf(z.teamId);if(Z!==-1){let J=Math.max(0,Z-500),Q=Math.min(E.length,Z+500),Y=E.slice(J,Q).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(Y?.[1]){z.teamName=Y[1];continue}}if(!z.teamName&&z.url){let J=z.url.match(/https:\/\/([a-z0-9-]+)\.slack\.com\//)?.[1];if(J){let Q=E.indexOf(J);if(Q!==-1){let G=Math.max(0,Q-500),Y=Math.min(E.length,Q+500),H=E.slice(G,Y).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(H?.[1]){z.teamName=H[1];continue}}z.teamName=J.split("-").map((G)=>G.charAt(0).toUpperCase()+G.slice(1)).join(" ")}}}let C=A7(),$=[...F.values()];if(C)for(let z of $)z.cookie=C;return $}function L7(D,u){let F=(B,E)=>{try{let C=T1("aes-128-cbc",u,B);C.setAutoPadding(!0);let $=Buffer.concat([C.update(E),C.final()]).toString("utf8");return $.startsWith("xoxd-")?$:void 0}catch{return}};return F(Buffer.alloc(16,32),D.slice(3))??(D.length>=35?F(D.slice(19,35),D.slice(35)):void 0)}function T7(D,u){let F=(B,E)=>{if(B&&E)return`${B} (${E})`;return B||E||u};try{let E=JSON.parse(ku(GD(D,"Local State"),"utf8")).profile?.info_cache?.[u];if(E&&(E.name||E.user_name))return F(E.name??"",E.user_name??"")}catch{}try{let E=JSON.parse(ku(GD(D,u,"Preferences"),"utf8")).profile;return F(E?.name??"",E?.user_name??"")}catch{return u}}function S1(){if(process.platform!=="darwin")return{candidates:[],totalProfiles:0};let D=GD(PF(),"Library","Application Support","Google","Chrome");if(!qu(D))return{candidates:[],totalProfiles:0};let u;try{u=R1('security find-generic-password -a Chrome -s "Chrome Safe Storage" -w',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return{candidates:[],totalProfiles:0}}if(!u)return{candidates:[],totalProfiles:0};let F=L1(u,"saltysalt",1003,16,"sha1"),B=["Default",...RF(D).filter((C)=>C.startsWith("Profile "))],E=[];for(let C of B){let $=GD(D,C,"Cookies");if(!qu($))continue;let z=GD(A1(),`slack-chrome-cookies-${Date.now()}-${C}.db`);try{_1($,z);let{default:Z}=xD("bun:sqlite"),J=new Z(z,{readonly:!0}),Q=J.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(J.close(),!Q)continue;let G=Buffer.from(Q.encrypted_value),Y=G.slice(0,3).toString();if(Y==="v10"){let V=L7(G,F);if(!V)continue;E.push({profileDir:C,profileName:T7(D,C),cookie:V})}else if(Y==="v20")throw Error(`Chrome cookie uses v20 (app-bound AES-256-GCM) which is not supported yet. Prefix found: ${G.slice(0,4).toString("hex")}`);else throw Error(`Unknown cookie encryption prefix: ${G.slice(0,4).toString("hex")}`)}catch(Z){if(Z instanceof Error&&(Z.message.includes("app-bound")||Z.message.includes("Unknown cookie")))throw Z}finally{try{N1(z)}catch{}}}return{candidates:E,totalProfiles:B.length}}function R7(){let D=PF();if(process.platform==="darwin")return GD(D,"Library","Application Support","Firefox","Profiles");if(process.platform==="linux")return GD(D,".mozilla","firefox");if(process.platform==="win32")return GD(process.env.APPDATA??GD(D,"AppData","Roaming"),"Mozilla","Firefox","Profiles");return""}function P7(D){let u=GD(j7(D),"profiles.ini"),F={};if(!qu(u))return F;try{let B=ku(u,"utf8"),E="",C="";for(let $ of B.split(`
|
|
108
|
+
`)){let z=$.trim();if(z.startsWith("[")){E="",C="";continue}let Z=z.indexOf("=");if(Z===-1)continue;let J=z.slice(0,Z).trim().toLowerCase(),Q=z.slice(Z+1).trim();if(J==="name")E=Q;if(J==="path")C=Q.split(/[\\/]/).pop()??Q;if(E&&C)F[C]=E,E="",C=""}}catch{}return F}function w1(){let D=R7();if(!D||!qu(D))return[];let u=P7(D),F=[],B;try{B=RF(D)}catch{return[]}for(let E of B){let C=GD(D,E,"cookies.sqlite");if(!qu(C))continue;let $=GD(A1(),`slack-firefox-cookies-${Date.now()}-${E}.db`);try{_1(C,$);let{default:z}=xD("bun:sqlite"),Z=new z($,{readonly:!0}),J=Z.prepare("SELECT value FROM moz_cookies WHERE name='d' AND host LIKE '%slack%' LIMIT 1").get();if(Z.close(),!J?.value||!J.value.startsWith("xoxd-"))continue;let Q=u[E]??E;F.push({profileDir:E,profileName:Q,cookie:J.value})}catch{}finally{try{N1($)}catch{}}}return F}var w7=["search:read","channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"],x7=["channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"];function SF(D){return D.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function I7(){return JSON.stringify({display_information:{name:"slack-term"},oauth_config:{scopes:{user:w7}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}function b7(){return JSON.stringify({display_information:{name:"slack-term"},features:{bot_user:{display_name:"slack-term",always_online:!1}},oauth_config:{scopes:{bot:x7}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}async function Ou(D,u){return(await D.question(u)).trim()}async function Uu(D,u,F,B){console.error("Verifying token...");let E=await Su(u),C=SF(E.team),$;if(F)$=F;else if(D)$=await Ou(D,`Workspace name [${C}]: `)||C;else $=C;let z=null;if(D){console.log(""),console.log("Where to save the token?"),console.log(" 1) ./.env.local (current directory) [default]"),console.log(" 2) ./.slack-term/.env.local (current directory, slack-specific)"),console.log(" 3) ~/.slack-term/.env.local (global, available everywhere)"),console.log(" 4) profiles.json (multi-workspace: slack auth use)"),console.log("");let Z=await Ou(D,"Choice [1/2/3/4, Enter=1]: ");if(Z==="2")z=d0(process.cwd(),".slack-term",".env.local");else if(Z==="3")z=d0(S7(),".slack-term",".env.local");else if(Z==="4")z=null;else z=d0(process.cwd(),".env.local")}if(z===null)if(g0($,{token:u,...E,...B?{cookie:B}:{}}),console.log(`Saved workspace "${$}" to profiles.json: ${E.team} (${E.user})`),process.env.SLACK_MCP_XOXP_TOKEN)console.log(""),console.log("Warning: SLACK_MCP_XOXP_TOKEN is set — it conflicts with profiles."),console.log(" Unset it: unset SLACK_MCP_XOXP_TOKEN (and remove from ~/.zshrc / ~/.bashrc)");else console.log(` Run: slack auth use -g ${$}`);else{let Z={SLACK_TOKEN:u};if(B)Z.SLACK_COOKIE=B;M1(z,Z),console.log(`Saved token to ${z}`),console.log(" SLACK_TOKEN will be picked up automatically in this directory tree.")}return $}async function f7(D){console.error("Scanning Slack desktop app...");let u=await P1();if(u.length===0)console.error("No sessions found. Make sure Slack is installed and you have signed in at least once."),process.exit(1);if(u.length===1&&D){let F=u[0],B=F.teamName??F.teamId;console.log(`Found workspace: ${B}${F.cookie?" (+ xoxd cookie)":""}`),await Uu(D,F.token,SF(B),F.cookie),console.log(""),console.log("Note: desktop app tokens (xoxc-) are internal Slack tokens."),console.log("If API calls fail, replace with an xoxp- token: slack auth login");return}for(let F of u){let B=F.teamName??F.teamId,E=SF(B);g0(E,{token:F.token,team:B,teamId:F.teamId,url:F.url??"",user:"",...F.cookie?{cookie:F.cookie}:{}}),console.log(`Added workspace "${E}": ${B}${F.cookie?" + xoxd cookie":""}`)}if(console.log(""),u.length===1){let F=SF(u[0].teamName??u[0].teamId);console.log(`Run: slack auth use -g ${F}`)}else console.log("Run: slack auth ls then: slack auth use -g <name>");console.log(""),console.log("Note: desktop app tokens (xoxc-) are internal Slack tokens."),console.log("If API calls fail, replace with an xoxp- user token by re-running: slack auth login")}async function x1(D){console.log("Which token type does your app use?"),console.log(""),console.log(" 1) User token (xoxp-) -full access including search [recommended]"),console.log(" 2) Bot token (xoxb-) -search and news unavailable"),console.log("");let F=await Ou(D,"Choice [1/2]: ")==="2"?"bot":"user",B=F==="user"?"xoxp-":"xoxb-",E=F==="user"?"User OAuth Token":"Bot User OAuth Token";console.log(""),console.log("Find your token here:"),console.log(" https://api.slack.com/apps"),console.log(" -> Select your app -> OAuth & Permissions"),console.log(` -> Copy the "${E}" (starts with ${B})`),console.log("");let C=await Ou(D,"Paste your token: ");if(!C)console.error("No token provided."),process.exit(1);if(!C.startsWith(B))console.error(`Expected a ${B} token, got: ${C.slice(0,10)}...`),process.exit(1);await Uu(D,C)}async function wF(D,u){let F=u==="user"?I7():b7(),B=u==="user"?"User OAuth Token (xoxp-...)":"Bot User OAuth Token (xoxb-...)",E=u==="user"?"xoxp-":"xoxb-";if(u==="bot")console.log("Note: bot tokens cannot use search:read (user-only scope)."),console.log(" The news and search commands will not work with a bot token."),console.log("");console.log("Step 1 -Create your Slack app:"),console.log(" Open: https://api.slack.com/apps"),console.log(' Click "Create New App" -> "From a manifest" -> select your workspace'),console.log(" Paste this manifest (JSON tab):"),console.log(""),console.log("-------------------------------------------------------------"),console.log(F),console.log("-------------------------------------------------------------"),console.log(""),console.log('Step 2 -Install: "Install App" -> "Install to Workspace" -> Authorize'),console.log(""),console.log("Step 3 -Copy your token:"),console.log(` OAuth & Permissions -> ${B}`),console.log("");let C=await Ou(D,"Paste your token: ");if(!C)console.error("No token provided."),process.exit(1);if(!C.startsWith(E))console.error(`Expected a ${E} token, got: ${C.slice(0,10)}...`),process.exit(1);await Uu(D,C)}async function I1(D={}){if(process.platform!=="darwin")console.error("Chrome cookie extraction is only supported on macOS."),process.exit(1);let u=TF();if(u.length===0)console.error("No workspaces configured. Run: slack auth login"),process.exit(1);let F;if(D.workspace){if(!u.find((Z)=>Z.name===D.workspace))console.error(`Workspace "${D.workspace}" not found. Available: ${u.map((Z)=>Z.name).join(", ")}`),process.exit(1);F=D.workspace}else if(u.length===1)F=u[0].name;else{let z=u.find((Z)=>Z.current);if(z)F=z.name,console.log(`Using active workspace: ${F}`);else{console.log("Multiple workspaces found. Choose one:"),u.forEach((G,Y)=>console.log(` ${Y+1}) ${G.name} (${G.profile.team})`));let Z=Ku({input:process.stdin,output:process.stdout}),J=(await Z.question("Choice: ")).trim();Z.close();let Q=parseInt(J,10)-1;if(isNaN(Q)||Q<0||Q>=u.length)console.error("Invalid choice."),process.exit(1);F=u[Q].name}}if(u.find((z)=>z.name===F).profile.token.startsWith("xoxb-")){console.error(`
|
|
109
109
|
Workspace "${F}" uses a bot token (xoxb-). A Chrome session cookie only
|
|
110
110
|
`+`augments a user session token (xoxc-) — it has no effect on a bot token, so user-level
|
|
111
|
-
`+"actions (tail @user, DMs, listing users) would still fail.");let z=u.filter((Z)=>Z.profile.token.startsWith("xoxc-")||Z.profile.token.startsWith("xoxp-"));if(z.length>0)console.error(` Target a user-token workspace instead: ${z.map((Z)=>Z.name).join(", ")}`),console.error(` slack auth chrome -w ${z[0].name}`);else console.error(" Import your Slack desktop user session instead: slack auth login");process.exit(1)}console.log("Scanning Chrome profiles for Slack session..."),console.log("macOS may show a dialog asking for your login password — click Allow.");let E,C;try{({candidates:E,totalProfiles:C}=
|
|
111
|
+
`+"actions (tail @user, DMs, listing users) would still fail.");let z=u.filter((Z)=>Z.profile.token.startsWith("xoxc-")||Z.profile.token.startsWith("xoxp-"));if(z.length>0)console.error(` Target a user-token workspace instead: ${z.map((Z)=>Z.name).join(", ")}`),console.error(` slack auth chrome -w ${z[0].name}`);else console.error(" Import your Slack desktop user session instead: slack auth login");process.exit(1)}console.log("Scanning Chrome profiles for Slack session..."),console.log("macOS may show a dialog asking for your login password — click Allow.");let E,C;try{({candidates:E,totalProfiles:C}=S1())}catch(z){console.error(`Failed: ${z instanceof Error?z.message:String(z)}`),process.exit(1)}if(E.length===0)console.error(`No Slack session found in Chrome (scanned ${C} profile${C!==1?"s":""}). Possible reasons:`),console.error(" - You denied the keychain dialog (try running again and click Allow)"),console.error(" - Chrome is not installed or has no Slack session"),console.error(" - You're not logged in to Slack in Chrome"),process.exit(1);let $;if(E.length===1&&C<=1)$=E[0].cookie,console.log(`Found session in Chrome profile: ${E[0].profileName}`);else{let z=E.length===1?`Found 1 Slack session across ${C} Chrome profiles:`:`Found ${E.length} Slack sessions across ${C} Chrome profiles:`;console.log(z),E.forEach((Y,V)=>console.log(` ${V+1}) ${Y.profileName} [${Y.profileDir}]`)),console.log("");let Z=Ku({input:process.stdin,output:process.stdout}),J=E.length===1?" [Enter=1]":"",Q=(await Z.question(`Choice [1-${E.length}]${J}: `)).trim();Z.close();let G=Q===""&&E.length===1?0:parseInt(Q,10)-1;if(isNaN(G)||G<0||G>=E.length)console.error("Invalid choice."),process.exit(1);$=E[G].cookie}c0(F,$),console.log(`Saved xoxd cookie to workspace "${F}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function b1(D={}){let u=TF();if(u.length===0)console.error("No workspaces configured. Run: slack auth token"),process.exit(1);let F;if(D.workspace){if(!u.find(($)=>$.name===D.workspace))console.error(`Workspace "${D.workspace}" not found. Available: ${u.map(($)=>$.name).join(", ")}`),process.exit(1);F=D.workspace}else if(u.length===1)F=u[0].name;else{let C=u.find(($)=>$.current);if(C)F=C.name,console.log(`Using active workspace: ${F}`);else{console.log("Multiple workspaces found. Choose one:"),u.forEach((J,Q)=>console.log(` ${Q+1}) ${J.name} (${J.profile.team})`));let $=Ku({input:process.stdin,output:process.stdout}),z=(await $.question("Choice: ")).trim();$.close();let Z=parseInt(z,10)-1;if(isNaN(Z)||Z<0||Z>=u.length)console.error("Invalid choice."),process.exit(1);F=u[Z].name}}console.log("Scanning Firefox profiles for Slack session...");let B=w1();if(B.length===0)console.error("No Slack session found in Firefox. Possible reasons:"),console.error(" - Firefox is not installed"),console.error(" - You are not logged in to Slack in Firefox"),process.exit(1);let E;if(B.length===1)E=B[0].cookie,console.log(`Found session in Firefox profile: ${B[0].profileName}`);else{console.log("Multiple Firefox profiles have a Slack session. Choose one:"),B.forEach((Z,J)=>console.log(` ${J+1}) ${Z.profileName} [${Z.profileDir}]`));let C=Ku({input:process.stdin,output:process.stdout}),$=(await C.question("Choice: ")).trim();C.close();let z=parseInt($,10)-1;if(isNaN(z)||z<0||z>=B.length)console.error("Invalid choice."),process.exit(1);E=B[z].cookie}c0(F,E),console.log(`Saved xoxd cookie to workspace "${F}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function f1(D={}){if(D.token){await Uu(null,D.token,D.name);return}if(!process.stdin.isTTY){let F=[];for await(let E of process.stdin)F.push(E);let B=Buffer.concat(F).toString("utf8").trim();if(!B)console.error("No token provided on stdin."),process.exit(1);await Uu(null,B,D.name);return}let u=Ku({input:process.stdin,output:process.stdout});try{await x1(u)}finally{u.close()}}async function h1(D={}){let u=Ku({input:process.stdin,output:process.stdout});try{if(D.bot!==void 0){await wF(u,D.bot?"bot":"user");return}console.log("Which token type?"),console.log(" 1) User token (xoxp-) -full access including search [default]"),console.log(" 2) Bot token (xoxb-) -search and news unavailable"),console.log("");let F=await Ou(u,"Choice [1/2, Enter=1]: ");await wF(u,F==="2"?"bot":"user")}finally{u.close()}}async function xF(D={}){let u=TF();if(u.length>0){console.log("Currently logged in:");for(let{name:B,profile:E,current:C}of u)console.log(` ${C?"*":" "} ${B} ${E.team} (${E.user||"unknown"})`);console.log(""),console.log("Adding another workspace:"),console.log("")}if(D.token){await Uu(null,D.token,D.name);return}if(!process.stdin.isTTY){let B=[];for await(let C of process.stdin)B.push(C);let E=Buffer.concat(B).toString("utf8").trim();if(!E)console.error("No token provided on stdin."),process.exit(1);await Uu(null,E,D.name);return}console.log("How would you like to authenticate with Slack?"),console.log(""),console.log(" 1) Slack desktop app - import session token"),console.log(" Reads the xoxc- token directly from the installed app."),console.log(" Token: all platforms | xoxd cookie: macOS only"),console.log(""),console.log(" 2) Connect existing Slack app [recommended if you have one]"),console.log(" Paste a token from an app you already created."),console.log(""),console.log(" 3) Create new Slack app - user token (xoxp-)"),console.log(" Guided setup with manifest. Full access including search."),console.log(""),console.log(" 4) Create new Slack app - bot token (xoxb-)"),console.log(" Bot is invited to channels. Search and news unavailable."),console.log("");let F=Ku({input:process.stdin,output:process.stdout});try{let B=await Ou(F,"Choice [1/2/3/4]: ");if(console.log(""),B==="1")await f7(F);else if(B==="2")await x1(F);else if(B==="3")await wF(F,"user");else if(B==="4")await wF(F,"bot");else console.error(`Invalid choice: "${B}". Enter 1, 2, 3, or 4.`),process.exit(1)}finally{F.close()}}async function IF(D,u,F,B){let E=u,C=[],$=E,z=0;while(!0){let Z=$.indexOf("<@U",z);if(Z===-1)break;let J=$.slice(Z+2),Q=J.search(/[>|]/),G=Q===-1?J:J.slice(0,Q);if(G.length>=9)C.push(G);z=Z+1}for(let Z of C){if(!F.has(Z))F.set(Z,await AF(D,Z,B));let J=F.get(Z)??Z;E=E.replaceAll(`<@${Z}>`,`@${J}`),E=E.replace(new RegExp(`<@${Z}\\|[^>]*>`,"g"),`@${J}`)}return E}function bF(D){return D.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(u,F,B)=>{let E=Number(F);if(!Number.isFinite(E))return B??"date";let C=new Date(E*1000);if(Number.isNaN(C.getTime()))return B??"date";let $=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],z=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Z=$[C.getUTCDay()]??"",J=z[C.getUTCMonth()]??"";return`${Z}, ${J} ${String(C.getUTCDate()).padStart(2,"0")}, ${C.getUTCFullYear()}`})}function y1(D){let u=typeof D.ts==="string"?D.ts:"",F=typeof D.thread_ts==="string"?D.thread_ts:"";return F!==""&&F!==u}function h7(D){let[u,F="000000"]=D.split("."),B=new Date(Number(u)*1000),E=B.getUTCFullYear(),C=String(B.getUTCMonth()+1).padStart(2,"0"),$=String(B.getUTCDate()).padStart(2,"0"),z=String(B.getUTCHours()).padStart(2,"0"),Z=String(B.getUTCMinutes()).padStart(2,"0"),J=String(B.getUTCSeconds()).padStart(2,"0"),Q=F.padEnd(6,"0").slice(0,6);return`${E}-${C}-${$}T${z}:${Z}:${J}.${Q}`}async function v7(D,u,F){let B=typeof u.ts==="string"?u.ts:"0.000000",E=h7(B),C="?";if(typeof u.user==="string"){let G=u.user,Y="@"+G;if(!F.has(Y)){let[,V]=await NF(D,G);F.set(Y,V)}C=F.get(Y)??G}else if(typeof u.username==="string")C=u.username;let $=typeof u.text==="string"?u.text:"",Z=bF(await IF(D,$,F)).split(`
|
|
112
112
|
`),J=Z[0]+(Z.length>1?`
|
|
113
113
|
`+Z.slice(1).map((G)=>` ${G}`).join(`
|
|
114
|
-
`):""),Q=
|
|
115
|
-
`)}),J.addEventListener("close",()=>Z()),J.addEventListener("error",()=>Z()),J.addEventListener("message",(Q)=>{(async()=>{try{let G;try{G=JSON.parse(String(Q.data))}catch{return}let Y=typeof G.type==="string"?G.type:"";if(Y==="ping"){J.send(JSON.stringify({type:"pong",reply_to:G.id??0}));return}if(Y!=="message")return;if((typeof G.channel==="string"?G.channel:"")!==B)return;let H=typeof G.ts==="string"?G.ts:"";if(!H||C.has(H))return;let W=typeof G.subtype==="string"?G.subtype:"";if(W==="message_changed"||W==="message_deleted")return;if(E.thread){if((typeof G.thread_ts==="string"?G.thread_ts:H)!==E.thread&&H!==E.thread)return}if(E.watchThread&&
|
|
114
|
+
`):""),Q=y1(u)?"↳ ":"";return`${E} ${Q}@${C}: ${J}`}async function y7(D,u,F,B,E,C,$,z){if(z?.aborted)return;return new Promise((Z)=>{let J=new D(F);z?.addEventListener("abort",()=>{J.close(),Z()},{once:!0}),J.addEventListener("open",()=>{process.stderr.write(`Connected via RTM (experimental).
|
|
115
|
+
`)}),J.addEventListener("close",()=>Z()),J.addEventListener("error",()=>Z()),J.addEventListener("message",(Q)=>{(async()=>{try{let G;try{G=JSON.parse(String(Q.data))}catch{return}let Y=typeof G.type==="string"?G.type:"";if(Y==="ping"){J.send(JSON.stringify({type:"pong",reply_to:G.id??0}));return}if(Y!=="message")return;if((typeof G.channel==="string"?G.channel:"")!==B)return;let H=typeof G.ts==="string"?G.ts:"";if(!H||C.has(H))return;let W=typeof G.subtype==="string"?G.subtype:"";if(W==="message_changed"||W==="message_deleted")return;if(E.thread){if((typeof G.thread_ts==="string"?G.thread_ts:H)!==E.thread&&H!==E.thread)return}if(E.watchThread&&y1(G)){if((typeof G.thread_ts==="string"?G.thread_ts:"")!==E.watchThread)return}if(E.me&&E.myUserId){if(!(typeof G.text==="string"?G.text:"").includes(`<@${E.myUserId}>`))return}if(C.add(H),C.size>1000){let N=C.values().next().value;if(N!==void 0)C.delete(N)}let K=await v7(u,G,$);process.stdout.write(K+`
|
|
116
116
|
`)}catch(G){process.stderr.write(`RTM message error: ${G instanceof Error?G.message:String(G)}
|
|
117
|
-
`)}})()})})}var
|
|
117
|
+
`)}})()})})}var v1=3,p7=2000,k0={sleep:(D)=>new Promise((u)=>setTimeout(u,D)),clientBoot:Y1,getWebSocket:()=>{let D=globalThis.WebSocket;return typeof D==="function"?D:void 0}};async function p1(D,u,F,B,E,C,$){let z=k0.getWebSocket();if(!z)return;for(let Z=0;Z<v1;Z++){if($?.aborted)return;try{let{wsUrl:J}=await k0.clientBoot(D,u);await y7(z,D,J,F,B,E,C,$)}catch{}if($?.aborted)return;if(Z<v1-1)await k0.sleep(p7)}}function m1(D){let u=D.match(/^(\d+(?:\.\d+)?)(s|m|h|d)$/);if(!u)throw Error(`Invalid --since format: "${D}" (expected e.g. 10m, 2h, 1d)`);let F=parseFloat(u[1]);switch(u[2]){case"s":return F;case"m":return F*60;case"h":return F*3600;case"d":return F*86400}}var SD={sleep:(D)=>new Promise((u)=>setTimeout(u,D)),now:()=>Date.now(),tailRTM:p1};function gD(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function i0(D){return Array.isArray(D)?D:[]}function g1(D){return Number(D)||0}function c1(D){let u=typeof D.ts==="string"?D.ts:"",F=typeof D.thread_ts==="string"?D.thread_ts:"";return F!==""&&F!==u}function m7(D){let[u,F="000000"]=D.split("."),B=new Date(Number(u)*1000),E=B.getUTCFullYear(),C=String(B.getUTCMonth()+1).padStart(2,"0"),$=String(B.getUTCDate()).padStart(2,"0"),z=String(B.getUTCHours()).padStart(2,"0"),Z=String(B.getUTCMinutes()).padStart(2,"0"),J=String(B.getUTCSeconds()).padStart(2,"0"),Q=F.padEnd(6,"0").slice(0,6);return`${E}-${C}-${$}T${z}:${Z}:${J}.${Q}`}async function g7(D,u,F,B,E){let C=typeof u.ts==="string"?u.ts:"0.000000",$=m7(C),z="?";if(typeof u.user==="string"){let H=u.user,W="@"+H;if(!F.has(W)){let[,K]=await NF(D,H,E);F.set(W,K)}z=F.get(W)??H}else if(typeof u.username==="string")z=u.username;let Z=typeof u.text==="string"?u.text:"",Q=bF(await IF(D,Z,F,E)).split(`
|
|
118
118
|
`),G=Q[0]+(Q.length>1?`
|
|
119
119
|
`+Q.slice(1).map((H)=>` ${H}`).join(`
|
|
120
|
-
`):""),Y=
|
|
120
|
+
`):""),Y=c1(u)?"↳ ":"",V=B?`${B} @${z}`:`@${z}`;return`${$} ${Y}${V}: ${G}`}async function c7(D,u,F,B,E,C,$){let z=gD(await du(D,u,20,$?void 0:F||void 0,$,B.cookie)),Z=i0(z.messages).map(gD).reverse(),J=gD(z.response_metadata),Q=z.has_more===!0&&typeof J.next_cursor==="string"?J.next_cursor:void 0,G=[];if(B.watchThread&&!$){let K=gD(await J1(D,u,B.watchThread,50,B.cookie));G=i0(K.messages).map(gD).filter((N)=>(typeof N.ts==="string"?N.ts:"")!==B.watchThread)}let Y=[...Z.map((K)=>({m:K,fromHistory:!0})),...G.map((K)=>({m:K,fromHistory:!1}))].sort((K,N)=>g1(typeof K.m.ts==="string"?K.m.ts:"")-g1(typeof N.m.ts==="string"?N.m.ts:"")),V=[],H=F,W=!1;for(let{m:K,fromHistory:N}of Y){let j=typeof K.ts==="string"?K.ts:"";if(!j||E.has(j))continue;let L=typeof K.subtype==="string"?K.subtype:"";if(L==="message_changed"||L==="message_deleted")continue;if(B.thread){if((typeof K.thread_ts==="string"?K.thread_ts:j)!==B.thread&&j!==B.thread)continue}if(B.watchThread&&c1(K)){if((typeof K.thread_ts==="string"?K.thread_ts:"")!==B.watchThread)continue}if(B.me&&B.myUserId){if(!(typeof K.text==="string"?K.text:"").includes(`<@${B.myUserId}>`))continue}if(E.add(j),E.size>1000){let T=E.values().next().value;if(T!==void 0)E.delete(T)}if(V.push(await g7(D,K,C,void 0,B.cookie)),N)H=j;let M=typeof K.user==="string"?K.user:"";if(!B.myUserId||M!==B.myUserId)W=!0}return{newCursor:H,lines:V,hasMore:z.has_more===!0,nextPageCursor:Q,emittedOther:W}}function d7(D){if(D.includes("slack.com")){let u=x0(D),F=u?.threadTs??u?.ts;if(F)return F;throw Error(`--watch-thread: could not extract a timestamp from "${D}"`)}if(/^\d{10}\.\d{6}$/.test(D))return D;if(/^\d{16}$/.test(D))return`${D.slice(0,10)}.${D.slice(10)}`;throw Error(`--watch-thread: "${D}" is not a valid ts or permalink`)}async function d1(D,u,F={},B){if(F.me&&!u)console.error(`slack tail --me requires a <target> channel.
|
|
121
121
|
Cross-channel mention streaming is not yet supported.
|
|
122
|
-
Use: slack tail "#channel" --me`),process.exit(1);if(!u)console.error("Usage: slack tail <#channel|@user>\n Run `slack tail --help` for details."),process.exit(1);let E=await
|
|
122
|
+
Use: slack tail "#channel" --me`),process.exit(1);if(!u)console.error("Usage: slack tail <#channel|@user>\n Run `slack tail --help` for details."),process.exit(1);let E=await X1(D,u),C=F.interval??60000,$=F.timeout?SD.now()+m1(F.timeout)*1000:1/0,z=new Map,Z=new Set;try{let W=gD(await Q1(D,E,F.cookie));if(gD(W.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(W){let K=W instanceof Error?W.message:String(W);if(K.includes("not_in_channel"))console.error("Error: you are not a member of that channel. Join it in Slack first, then retry."),process.exit(1);if(K.includes("missing_scope"))console.error("Error: token lacks the required history scope. Check your token's channels:history (or groups:history) permission."),process.exit(1);if(K.includes("channel_not_found"))console.error("Error: channel not found — it may be a private channel inaccessible with your token."),process.exit(1);console.error(`Warning: preflight check failed: ${K}`)}let J="";if(F.since){let W=m1(F.since);J=(SD.now()/1000-W).toFixed(6)}else{let W=gD(await du(D,E,1,void 0,void 0,F.cookie)),K=i0(W.messages).map(gD);if(K.length>0&&typeof K[0]?.ts==="string")J=K[0].ts,Z.add(J);else J=(SD.now()/1000).toFixed(6)}let Q;if(F.me||F.exitOnMessage)Q=(await Su(D,F.cookie)).userId||void 0;let G;if(F.watchThread!==void 0)try{G=d7(F.watchThread)}catch(W){console.error(W instanceof Error?W.message:String(W)),process.exit(1)}let Y={...F.thread!==void 0?{thread:F.thread}:{},...G!==void 0?{watchThread:G}:{},...F.me!==void 0?{me:F.me}:{},...Q!==void 0?{myUserId:Q}:{},...F.cookie!==void 0?{cookie:F.cookie}:{}};if(D.startsWith("xoxc-")&&F.cookie!==void 0&&F.noRtm!==!0&&F.since===void 0&&F.timeout===void 0&&F.exitOnMessage!==!0){if(await SD.tailRTM(D,F.cookie,E,Y,Z,z,B),B?.aborted)return;console.error("RTM unavailable — switching to polling.")}let V=!0,H=SD.now();while(!B?.aborted){if(SD.now()>=$)return;let W=!1;try{let j=SD.now()-H,L=C>0&&j>C*5,M,T=!0;do{let{newCursor:h,lines:p,nextPageCursor:$D,emittedOther:l}=await c7(D,E,J,Y,Z,z,M);if(J=h,V&&T&&F.since&&p.length===0)process.stdout.write(`(no messages in the last ${F.since} — watching for new)
|
|
123
123
|
`);T=!1;for(let Du of p)process.stdout.write(Du+`
|
|
124
|
-
`);if(l)W=!0;M=L?$D:void 0}while(M);V=!1}catch(N){if(N instanceof fD){console.error(`Warning: Slack rate limit hit — backing off for ${N.retryAfter}s`),await SD.sleep(N.retryAfter*1000);continue}throw N}if(F.exitOnMessage&&W)return;H=SD.now();let K=$-SD.now();if(K<=0)return;await SD.sleep(Math.min(C,K))}}class wu extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function
|
|
124
|
+
`);if(l)W=!0;M=L?$D:void 0}while(M);V=!1}catch(N){if(N instanceof fD){console.error(`Warning: Slack rate limit hit — backing off for ${N.retryAfter}s`),await SD.sleep(N.retryAfter*1000);continue}throw N}if(F.exitOnMessage&&W)return;H=SD.now();let K=$-SD.now();if(K<=0)return;await SD.sleep(Math.min(C,K))}}class wu extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function l0(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function k1(D,u,F,B){let E={};if(B)E.Cookie=`d=${B}`;let C=await fetch(`${l0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...E}});if(C.status===429){let z=parseInt(C.headers.get("retry-after")??"60",10);throw new wu(isNaN(z)?60:z)}let $=await C.json();if($.ok!==!0){let z=$.error??"unknown";if(z==="ratelimited")throw new wu(60);if(z==="invalid_auth"&&D.startsWith("xoxc-")&&!B)throw Error(`Desktop app token (xoxc-) needs its session cookie to be accepted by the public Slack API.
|
|
125
125
|
Attach it: slack auth chrome (macOS) or slack auth firefox
|
|
126
126
|
Or replace the token with an xoxp- user token:
|
|
127
127
|
slack auth token`);if((z==="missing_scope"||z==="cannot_dm_bot")&&D.startsWith("xoxb-"))throw Error(`Slack error on ${u}: ${z} — ${z==="cannot_dm_bot"?`you're authenticated as a bot, so "@you" is the bot itself and it can't DM itself`:"this bot token lacks the user scope this action needs"}.
|
|
128
128
|
Tailing/DMing people and listing users need a user session, not a bot token.
|
|
129
129
|
Switch workspace: slack auth ls then slack auth use <name>
|
|
130
|
-
Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${u}: ${z}`)}return $}async function k7(D,u,F,B){let E={};if(B)E.Cookie=`d=${B}`;let C=await fetch(`${
|
|
130
|
+
Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${u}: ${z}`)}return $}async function k7(D,u,F,B){let E={};if(B)E.Cookie=`d=${B}`;let C=await fetch(`${l0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...E}});if(C.status===429){let z=parseInt(C.headers.get("retry-after")??"60",10);throw new wu(isNaN(z)?60:z)}let $=await C.json();if($.ok!==!0){let z=$.error??"unknown";if(z==="ratelimited")throw new wu(60);if((z==="invalid_auth"||z==="not_authed")&&!D.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
|
|
131
131
|
Import from Slack desktop: slack auth login`);if((z==="invalid_auth"||z==="not_authed")&&!B)throw Error(`drafts.list also requires the xoxd session cookie.
|
|
132
|
-
Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${u}: ${z}`)}return $}function ju(D,u,F={},B){let E=new URLSearchParams({token:D,...F});return k7(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E.toString()},B)}function uD(D,u,F,B){let E=new URLSearchParams(F).toString();return i1(D,`${u}?${E}`,{method:"GET"},B)}function wD(D,u,F,B){return i1(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)},B)}async function l0(D,u){let F=await uD(D,"auth.test",{},u);return{team:F.team??"",teamId:F.team_id??"",url:F.url??"",user:F.user??"",userId:F.user_id??""}}async function l1(D,u){let F={Authorization:`Bearer ${D}`};if(u)F.Cookie=`d=${u}`;let B=await fetch(`${i0()}/auth.test`,{method:"GET",headers:F});if(B.status===429){let $=parseInt(B.headers.get("retry-after")??"60",10);throw new wu(isNaN($)?60:$)}let E=B.headers.get("x-oauth-scopes")??"",C=await B.json();if(C.ok!==!0)throw Error(`Slack error on auth.test: ${C.error??"unknown"}`);return{userId:C.user_id??"",user:C.user??"",botId:C.bot_id??"",team:C.team??"",url:C.url??"",scopes:E.split(",").map(($)=>$.trim()).filter(Boolean)}}async function lu(D,u,F=20,B,E,C){let $={channel:u,limit:String(F)};if(B!==void 0)$.oldest=B;if(E!==void 0)$.cursor=E;return uD(D,"conversations.history",$,C)}async function Mu(D,u,F,B=50,E){return uD(D,"conversations.replies",{channel:u,ts:F,limit:String(B)},E)}async function n1(D,u,F){return uD(D,"files.info",{file:u},F)}async function t1(D,u={},F){let B={count:String(Math.min(Math.max(u.count??100,1),200)),page:String(Math.max(u.page??1,1))};if(u.types)B.types=u.types;if(u.channel)B.channel=u.channel;if(u.user)B.user=u.user;return uD(D,"files.list",B,F)}async function o1(D,u,F={},B){let E={list_id:u};if(F.limit)E.limit=String(F.limit);if(F.cursor)E.cursor=F.cursor;return ju(D,"lists.records.list",E,B)}async function s1(D,u,F,B,E){return uD(D,"search.messages",{query:u,sort:"timestamp",sort_dir:"desc",count:String(Math.min(Math.max(F,1),100)),page:String(Math.max(B,1))},E)}async function r1(D,u,F){return s1(D,u,100,1,F)}async function n0(D,u,F,B){let C=1,$=[],z={ok:!0,messages:{}};while(!0){let J=await s1(D,u,100,C,B),Q=iu(J,["messages","matches"]),G=Array.isArray(Q)?Q:[];$.push(...G);let Y=Number(iu(J,["messages","paging","pages"])??1);if(z=J,G.length===0||C>=Y||$.length>=F)break;C+=1}let Z=z;if(!Z.messages)Z.messages={};return Z.messages.matches=$.slice(0,F),Z}async function a1(D,u,F,B,E,C){let $={channel:u,text:F,blocks:[{type:"markdown",text:F}]};if(B!==void 0)$.thread_ts=B;if(E&&B!==void 0)$.reply_broadcast=!0;return(await wD(D,"chat.postMessage",$,C)).ts??""}async function e1(D,u,F,B,E,C){let $={channel:u,text:F,post_at:B,blocks:[{type:"markdown",text:F}]};if(E!==void 0)$.thread_ts=E;return(await wD(D,"chat.scheduleMessage",$,C)).scheduled_message_id??""}async function D3(D,u,F){let B={};if(u)B.channel=u;return uD(D,"chat.scheduledMessages.list",B,F)}async function u3(D,u,F,B){await wD(D,"chat.deleteScheduledMessage",{channel:u,scheduled_message_id:F},B)}async function t0(D,u,F,B){return(await uD(D,"chat.getPermalink",{channel:u,message_ts:F},B)).permalink??""}async function F3(D,u,F,B,E){return(await wD(D,"chat.update",{channel:u,ts:F,text:B,blocks:[{type:"markdown",text:B}]},E)).ts??F}async function E3(D,u,F,B){await wD(D,"chat.delete",{channel:u,ts:F},B)}async function B3(D,u,F,B,E){await wD(D,"reactions.add",{channel:u,timestamp:F,name:B},E)}async function C3(D,u,F,B,E){await wD(D,"reactions.remove",{channel:u,timestamp:F,name:B},E)}async function $3(D,u,F=!1,B){let E=await wD(D,"conversations.create",{name:u,is_private:F},B);return{id:E.channel?.id??"",name:E.channel?.name??u}}async function z3(D,u,F,B){await wD(D,"conversations.invite",{channel:u,users:F.join(",")},B)}async function fF(D,u){let F=[],B="";while(!0){let E={limit:"200",types:"public_channel,private_channel,im,mpim"};if(B)E.cursor=B;let C=await uD(D,"conversations.list",E,u);if(F.push(...C.channels??[]),B=C.response_metadata?.next_cursor??"",!B)break}return{channels:F}}async function nu(D,u,F){let E=(await wD(D,"conversations.open",{users:u},F)).channel?.id;if(!E)throw Error(`Failed to open DM with user ${u}`);return E}function hD(D){return D.toLowerCase().replace(/[-_\s]/g,"")}async function o0(D,u,F){if(!u.startsWith("@")){if(/^[UW][A-Za-z0-9]{6,}$/.test(u))return u;throw Error(`Expected @user or a user ID, got: ${u}`)}let B=hD(u.slice(1)),E=await uD(D,"auth.test",{},F);if(B==="you"||B==="me"||hD(E.user??"")===B){if(!E.user_id)throw Error("auth.test did not return user_id");return E.user_id}let C="";while(!0){let $={limit:"200"};if(C)$.cursor=C;let z=await uD(D,"users.list",$,F);for(let Z of z.members??[]){let J=hD(Z.name??""),Q=hD(Z.real_name??""),G=hD(Z.profile?.display_name??"");if(J===B||Q===B||G&&G===B)return Z.id??""}if(C=z.response_metadata?.next_cursor??"",!C)break}throw Error(`User not found: ${u}`)}function tu(D){let u=D.match(/(?:app\.slack\.com\/client\/T[A-Za-z0-9]+|[A-Za-z0-9-]+\.slack\.com\/archives)\/([A-Za-z0-9]+)(?:\/p(\d{10})(\d{6}))?/);if(!u)return;let F=u[1],B=u[2]&&u[3]?`${u[2]}.${u[3]}`:void 0,E=D.indexOf("?"),C=E>=0?new URLSearchParams(D.slice(E)):void 0,$=C?.get("thread_ts")??void 0,J={channel:C?.get("cid")??void 0??F};if(B)J.ts=B;if($)J.threadTs=$;return J}function i7(D){return tu(D)?.channel}async function VD(D,u,F){let B=i7(u);if(B)return B;if(!u.startsWith("@")&&!u.startsWith("#")){if(/^[A-Za-z0-9]{9,}$/.test(u))return u;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${u}`)}let E=u.startsWith("@"),C=u.slice(1),$=hD(C);if(E){let J=await uD(D,"auth.test",{},F);if($==="you"||$==="me"||hD(J.user??"")===$){let H=J.user_id;if(!H)throw Error("auth.test did not return user_id");let K=((await uD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((N)=>N.user===H);if(K?.id)return String(K.id);return nu(D,H,F)}let G="",Y="";while(!0){let H={limit:"200"};if(Y)H.cursor=Y;let W=await uD(D,"users.list",H,F);for(let K of W.members??[]){let N=hD(K.name??""),j=hD(K.real_name??""),L=hD(K.profile?.display_name??"");if(N===$||j===$||L&&L===$){G=K.id??"";break}}if(G)break;if(Y=W.response_metadata?.next_cursor??"",!Y)break}if(!G)throw Error(`User not found: ${u}`);let V="";while(!0){let H={types:"im",limit:"200"};if(V)H.cursor=V;let W=await uD(D,"conversations.list",H,F);for(let K of W.channels??[])if(K.user===G)return String(K.id??"");if(V=W.response_metadata?.next_cursor??"",!V)break}throw Error(`No existing DM with ${u} (${G}). Open it once in Slack first.`)}let z=C.toLowerCase(),Z="";while(!0){let J={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(Z)J.cursor=Z;let Q=await uD(D,"conversations.list",J,F);for(let G of Q.channels??[])if(String(G.name??"").toLowerCase()===z)return String(G.id??"");if(Z=Q.response_metadata?.next_cursor??"",!Z)break}throw Error(`channel not found: ${u}`)}async function ou(D,u,F){try{let B=await uD(D,"users.info",{user:u},F),E=B.user?.profile?.display_name,C=E&&E.length>0?E:B.user?.real_name??B.user?.name??u,$=B.user?.name??u;return[C,$]}catch{return[u,u]}}async function su(D,u,F){try{let B=await uD(D,"users.info",{user:u},F),E=B.user?.profile?.display_name;if(E&&E.length>0)return E;return B.user?.real_name??B.user?.name??u}catch{return u}}async function s0(D,u){let F=[],B="";while(!0){let E={limit:"200"};if(B)E.cursor=B;let C=await uD(D,"users.list",E,u);if(F.push(...C.members??[]),B=C.response_metadata?.next_cursor??"",!B)break}return{members:F}}async function ru(D,u){return ju(D,"drafts.list",{},u)}async function Z3(D,u,F,B){let{randomUUID:E}=await import("node:crypto"),C=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:F}]}]}]);return ju(D,"drafts.create",{client_msg_id:E(),destinations:JSON.stringify([{channel_id:u}]),blocks:C,file_ids:JSON.stringify([]),is_from_composer:"true"},B)}async function J3(D,u,F,B,E){let C=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:B}]}]}]),$=(Date.now()/1000).toFixed(6);return ju(D,"drafts.update",{draft_id:u,client_last_updated_ts:$,destinations:JSON.stringify([{channel_id:F}]),blocks:C,file_ids:JSON.stringify([])},E)}async function G3(D,u,F){return ju(D,"conversations.info",{channel:u},F)}async function r0(D,u,F){return uD(D,"users.info",{user:u},F)}async function a0(D,u,F){return uD(D,"conversations.info",{channel:u},F)}async function X3(D,u,F){let B=(Date.now()/1000).toFixed(6);return ju(D,"drafts.delete",{draft_id:u,client_last_updated_ts:B},F)}async function e0(D,u){let F=await ju(D,"auth.test",{},u);return{userId:String(F.user_id??""),teamId:String(F.team_id??"")}}async function Q3(D,u,F,B={},E){let{statSync:C,readFileSync:$}=await import("node:fs"),{basename:z}=await import("node:path"),Z=C(F),J=z(F),Q=await uD(D,"files.getUploadURLExternal",{filename:J,length:String(Z.size)},E),G=Q.upload_url,Y=Q.file_id;if(!G||!Y)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let V=$(F),H=await fetch(G,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:V});if(!H.ok)throw Error(`Upload PUT failed: ${H.status} ${H.statusText}`);let W={files:[{id:Y,title:B.title??J}],channel_id:u};if(B.threadTs)W.thread_ts=B.threadTs;if(B.initialComment)W.initial_comment=B.initialComment;let K=await wD(D,"files.completeUploadExternal",W,E),N={fileId:Y},j=K.files?.[0]?.permalink;if(j)N.permalink=j;return N}function iu(D,u){let F=D;for(let B of u){if(F===void 0||F===null)return;if(typeof B==="number"){if(!Array.isArray(F))return;F=F[B]??void 0}else{if(typeof F!=="object"||Array.isArray(F))return;F=F[B]}}return F}import{existsSync as u9,readFileSync as F9}from"node:fs";import{homedir as E9}from"node:os";import{join as B9}from"node:path";import{existsSync as l7,mkdirSync as n7,readFileSync as t7,writeFileSync as o7}from"node:fs";import{homedir as s7}from"node:os";import{dirname as r7,join as a7}from"node:path";var e7=3600000,hF={now:()=>Date.now(),path:()=>a7(process.env.HOME||s7(),".config","slack-cli","cache.json")},vF=!0,rD;function Y3(){return{channels:{},users:{}}}function D2(){if(rD)return rD;if(rD=Y3(),!vF)return rD;try{let D=hF.path();if(!l7(D))return rD;let u=JSON.parse(t7(D,"utf8"));for(let F of["channels","users"]){let B=u?.[F];if(!B||typeof B!=="object"||Array.isArray(B))continue;for(let[E,C]of Object.entries(B))if(C&&typeof C==="object"&&typeof C.value==="string"&&typeof C.expires==="number")rD[F][E]={value:C.value,expires:C.expires}}}catch{rD=Y3()}return rD}function D9(D){if(!vF)return;try{let u=hF.path();n7(r7(u),{recursive:!0}),o7(u,JSON.stringify(D,null,2)+`
|
|
133
|
-
`)}catch{}}function W3(D,u){return D?`${D} ${u}`:void 0}function
|
|
134
|
-
`)[0]??"",emoji:j,keep:j[0]})}if(Q=V.response_metadata?.next_cursor||void 0,!Q||H.length===0)break;if(J>=E){G=!0;break}}if(B.fix)for(let Y of Z)try{try{await _D("reactions.add",()=>MF(D,u,Y.ts,Y.keep,C))}catch(V){if(!(V instanceof Error)||!/already_reacted/.test(V.message))throw V}for(let V of Y.emoji){if(V===Y.keep)continue;await _D("reactions.remove",()=>_F(D,u,Y.ts,V,C))}Y.fixed=!0}catch(V){Y.fixed=!1,Y.error=V instanceof Error?V.message:String(V)}return{scanned:J,findings:Z,truncated:G}}var Z9=!0,J9;function
|
|
135
|
-
`)),C=await
|
|
132
|
+
Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${u}: ${z}`)}return $}function ju(D,u,F={},B){let E=new URLSearchParams({token:D,...F});return k7(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E.toString()},B)}function uD(D,u,F,B){let E=new URLSearchParams(F).toString();return k1(D,`${u}?${E}`,{method:"GET"},B)}function wD(D,u,F,B){return k1(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)},B)}async function i1(D,u){let F=await uD(D,"auth.test",{},u);return{team:F.team??"",teamId:F.team_id??"",url:F.url??"",user:F.user??"",userId:F.user_id??""}}async function l1(D,u){let F={Authorization:`Bearer ${D}`};if(u)F.Cookie=`d=${u}`;let B=await fetch(`${l0()}/auth.test`,{method:"GET",headers:F});if(B.status===429){let $=parseInt(B.headers.get("retry-after")??"60",10);throw new wu(isNaN($)?60:$)}let E=B.headers.get("x-oauth-scopes")??"",C=await B.json();if(C.ok!==!0)throw Error(`Slack error on auth.test: ${C.error??"unknown"}`);return{userId:C.user_id??"",user:C.user??"",botId:C.bot_id??"",team:C.team??"",url:C.url??"",scopes:E.split(",").map(($)=>$.trim()).filter(Boolean)}}async function lu(D,u,F=20,B,E,C){let $={channel:u,limit:String(F)};if(B!==void 0)$.oldest=B;if(E!==void 0)$.cursor=E;return uD(D,"conversations.history",$,C)}async function Mu(D,u,F,B=50,E){return uD(D,"conversations.replies",{channel:u,ts:F,limit:String(B)},E)}async function n1(D,u,F){return uD(D,"files.info",{file:u},F)}async function t1(D,u={},F){let B={count:String(Math.min(Math.max(u.count??100,1),200)),page:String(Math.max(u.page??1,1))};if(u.types)B.types=u.types;if(u.channel)B.channel=u.channel;if(u.user)B.user=u.user;return uD(D,"files.list",B,F)}async function o1(D,u,F={},B){let E={list_id:u};if(F.limit)E.limit=String(F.limit);if(F.cursor)E.cursor=F.cursor;return ju(D,"lists.records.list",E,B)}async function s1(D,u,F,B,E){return uD(D,"search.messages",{query:u,sort:"timestamp",sort_dir:"desc",count:String(Math.min(Math.max(F,1),100)),page:String(Math.max(B,1))},E)}async function r1(D,u,F){return s1(D,u,100,1,F)}async function n0(D,u,F,B){let C=1,$=[],z={ok:!0,messages:{}};while(!0){let J=await s1(D,u,100,C,B),Q=iu(J,["messages","matches"]),G=Array.isArray(Q)?Q:[];$.push(...G);let Y=Number(iu(J,["messages","paging","pages"])??1);if(z=J,G.length===0||C>=Y||$.length>=F)break;C+=1}let Z=z;if(!Z.messages)Z.messages={};return Z.messages.matches=$.slice(0,F),Z}async function a1(D,u,F,B,E,C){let $={channel:u,text:F,blocks:[{type:"markdown",text:F}]};if(B!==void 0)$.thread_ts=B;if(E&&B!==void 0)$.reply_broadcast=!0;return(await wD(D,"chat.postMessage",$,C)).ts??""}async function e1(D,u,F,B,E,C){let $={channel:u,text:F,post_at:B,blocks:[{type:"markdown",text:F}]};if(E!==void 0)$.thread_ts=E;return(await wD(D,"chat.scheduleMessage",$,C)).scheduled_message_id??""}async function D3(D,u,F){let B={};if(u)B.channel=u;return uD(D,"chat.scheduledMessages.list",B,F)}async function u3(D,u,F,B){await wD(D,"chat.deleteScheduledMessage",{channel:u,scheduled_message_id:F},B)}async function t0(D,u,F,B){return(await uD(D,"chat.getPermalink",{channel:u,message_ts:F},B)).permalink??""}async function F3(D,u,F,B,E){return(await wD(D,"chat.update",{channel:u,ts:F,text:B,blocks:[{type:"markdown",text:B}]},E)).ts??F}async function E3(D,u,F,B){await wD(D,"chat.delete",{channel:u,ts:F},B)}async function B3(D,u,F,B,E){await wD(D,"reactions.add",{channel:u,timestamp:F,name:B},E)}async function C3(D,u,F,B,E){await wD(D,"reactions.remove",{channel:u,timestamp:F,name:B},E)}async function $3(D,u,F=!1,B){let E=await wD(D,"conversations.create",{name:u,is_private:F},B);return{id:E.channel?.id??"",name:E.channel?.name??u}}async function z3(D,u,F,B){await wD(D,"conversations.invite",{channel:u,users:F.join(",")},B)}async function fF(D,u){let F=[],B="";while(!0){let E={limit:"200",types:"public_channel,private_channel,im,mpim"};if(B)E.cursor=B;let C=await uD(D,"conversations.list",E,u);if(F.push(...C.channels??[]),B=C.response_metadata?.next_cursor??"",!B)break}return{channels:F}}async function nu(D,u,F){let E=(await wD(D,"conversations.open",{users:u},F)).channel?.id;if(!E)throw Error(`Failed to open DM with user ${u}`);return E}function hD(D){return D.toLowerCase().replace(/[-_\s]/g,"")}async function o0(D,u,F){if(!u.startsWith("@")){if(/^[UW][A-Za-z0-9]{6,}$/.test(u))return u;throw Error(`Expected @user or a user ID, got: ${u}`)}let B=hD(u.slice(1)),E=await uD(D,"auth.test",{},F);if(B==="you"||B==="me"||hD(E.user??"")===B){if(!E.user_id)throw Error("auth.test did not return user_id");return E.user_id}let C="";while(!0){let $={limit:"200"};if(C)$.cursor=C;let z=await uD(D,"users.list",$,F);for(let Z of z.members??[]){let J=hD(Z.name??""),Q=hD(Z.real_name??""),G=hD(Z.profile?.display_name??"");if(J===B||Q===B||G&&G===B)return Z.id??""}if(C=z.response_metadata?.next_cursor??"",!C)break}throw Error(`User not found: ${u}`)}function tu(D){let u=D.match(/(?:app\.slack\.com\/client\/T[A-Za-z0-9]+|[A-Za-z0-9-]+\.slack\.com\/archives)\/([A-Za-z0-9]+)(?:\/p(\d{10})(\d{6}))?/);if(!u)return;let F=u[1],B=u[2]&&u[3]?`${u[2]}.${u[3]}`:void 0,E=D.indexOf("?"),C=E>=0?new URLSearchParams(D.slice(E)):void 0,$=C?.get("thread_ts")??void 0,J={channel:C?.get("cid")??void 0??F};if(B)J.ts=B;if($)J.threadTs=$;return J}function i7(D){return tu(D)?.channel}async function VD(D,u,F){let B=i7(u);if(B)return B;if(!u.startsWith("@")&&!u.startsWith("#")){if(/^[A-Za-z0-9]{9,}$/.test(u))return u;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${u}`)}let E=u.startsWith("@"),C=u.slice(1),$=hD(C);if(E){let J=await uD(D,"auth.test",{},F);if($==="you"||$==="me"||hD(J.user??"")===$){let H=J.user_id;if(!H)throw Error("auth.test did not return user_id");let K=((await uD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((N)=>N.user===H);if(K?.id)return String(K.id);return nu(D,H,F)}let G="",Y="";while(!0){let H={limit:"200"};if(Y)H.cursor=Y;let W=await uD(D,"users.list",H,F);for(let K of W.members??[]){let N=hD(K.name??""),j=hD(K.real_name??""),L=hD(K.profile?.display_name??"");if(N===$||j===$||L&&L===$){G=K.id??"";break}}if(G)break;if(Y=W.response_metadata?.next_cursor??"",!Y)break}if(!G)throw Error(`User not found: ${u}`);let V="";while(!0){let H={types:"im",limit:"200"};if(V)H.cursor=V;let W=await uD(D,"conversations.list",H,F);for(let K of W.channels??[])if(K.user===G)return String(K.id??"");if(V=W.response_metadata?.next_cursor??"",!V)break}throw Error(`No existing DM with ${u} (${G}). Open it once in Slack first.`)}let z=C.toLowerCase(),Z="";while(!0){let J={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(Z)J.cursor=Z;let Q=await uD(D,"conversations.list",J,F);for(let G of Q.channels??[])if(String(G.name??"").toLowerCase()===z)return String(G.id??"");if(Z=Q.response_metadata?.next_cursor??"",!Z)break}throw Error(`channel not found: ${u}`)}async function ou(D,u,F){try{let B=await uD(D,"users.info",{user:u},F),E=B.user?.profile?.display_name,C=E&&E.length>0?E:B.user?.real_name??B.user?.name??u,$=B.user?.name??u;return[C,$]}catch{return[u,u]}}async function su(D,u,F){try{let B=await uD(D,"users.info",{user:u},F),E=B.user?.profile?.display_name;if(E&&E.length>0)return E;return B.user?.real_name??B.user?.name??u}catch{return u}}async function s0(D,u){let F=[],B="";while(!0){let E={limit:"200"};if(B)E.cursor=B;let C=await uD(D,"users.list",E,u);if(F.push(...C.members??[]),B=C.response_metadata?.next_cursor??"",!B)break}return{members:F}}async function ru(D,u){return ju(D,"drafts.list",{},u)}async function Z3(D,u,F,B){let{randomUUID:E}=await import("node:crypto"),C=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:F}]}]}]);return ju(D,"drafts.create",{client_msg_id:E(),destinations:JSON.stringify([{channel_id:u}]),blocks:C,file_ids:JSON.stringify([]),is_from_composer:"true"},B)}async function J3(D,u,F,B,E){let C=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:B}]}]}]),$=(Date.now()/1000).toFixed(6);return ju(D,"drafts.update",{draft_id:u,client_last_updated_ts:$,destinations:JSON.stringify([{channel_id:F}]),blocks:C,file_ids:JSON.stringify([])},E)}async function G3(D,u,F){return ju(D,"conversations.info",{channel:u},F)}async function r0(D,u,F){return uD(D,"users.info",{user:u},F)}async function hF(D,u,F){return uD(D,"conversations.info",{channel:u},F)}async function X3(D,u,F){let B=(Date.now()/1000).toFixed(6);return ju(D,"drafts.delete",{draft_id:u,client_last_updated_ts:B},F)}async function a0(D,u){let F=await ju(D,"auth.test",{},u);return{userId:String(F.user_id??""),teamId:String(F.team_id??"")}}async function Q3(D,u,F,B={},E){let{statSync:C,readFileSync:$}=await import("node:fs"),{basename:z}=await import("node:path"),Z=C(F),J=z(F),Q=await uD(D,"files.getUploadURLExternal",{filename:J,length:String(Z.size)},E),G=Q.upload_url,Y=Q.file_id;if(!G||!Y)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let V=$(F),H=await fetch(G,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:V});if(!H.ok)throw Error(`Upload PUT failed: ${H.status} ${H.statusText}`);let W={files:[{id:Y,title:B.title??J}],channel_id:u};if(B.threadTs)W.thread_ts=B.threadTs;if(B.initialComment)W.initial_comment=B.initialComment;let K=await wD(D,"files.completeUploadExternal",W,E),N={fileId:Y},j=K.files?.[0]?.permalink;if(j)N.permalink=j;return N}function iu(D,u){let F=D;for(let B of u){if(F===void 0||F===null)return;if(typeof B==="number"){if(!Array.isArray(F))return;F=F[B]??void 0}else{if(typeof F!=="object"||Array.isArray(F))return;F=F[B]}}return F}import{existsSync as u9,readFileSync as F9}from"node:fs";import{homedir as E9}from"node:os";import{join as B9}from"node:path";import{existsSync as l7,mkdirSync as n7,readFileSync as t7,writeFileSync as o7}from"node:fs";import{homedir as s7}from"node:os";import{dirname as r7,join as a7}from"node:path";var e7=3600000,vF={now:()=>Date.now(),path:()=>a7(process.env.HOME||s7(),".config","slack-cli","cache.json")},yF=!0,rD;function Y3(){return{channels:{},users:{}}}function e0(){if(rD)return rD;if(rD=Y3(),!yF)return rD;try{let D=vF.path();if(!l7(D))return rD;let u=JSON.parse(t7(D,"utf8"));for(let F of["channels","users"]){let B=u?.[F];if(!B||typeof B!=="object"||Array.isArray(B))continue;for(let[E,C]of Object.entries(B))if(C&&typeof C==="object"&&typeof C.value==="string"&&typeof C.expires==="number")rD[F][E]={value:C.value,expires:C.expires}}}catch{rD=Y3()}return rD}function D9(D){if(!yF)return;try{let u=vF.path();n7(r7(u),{recursive:!0}),o7(u,JSON.stringify(D,null,2)+`
|
|
133
|
+
`)}catch{}}function W3(D,u){return D?`${D} ${u}`:void 0}function D2(D,u,F){if(!yF)return;let B=W3(u,F);if(!B)return;let E=e0()[D][B];if(!E)return;if(E.expires<=vF.now()){delete e0()[D][B];return}return E.value}function u2(D,u,F,B,E=e7){if(!yF)return;let C=W3(u,F);if(!C)return;let $=e0();$[D][C]={value:B,expires:vF.now()+E},D9($)}var F2={marker:"pushpin",progress:{done:"white_check_mark",dropped:"no_entry_sign",doing:"eyes",pending:"hourglass_flowing_sand"},flags:{alert:"exclamation","needs-discussion":"question",waiting:"speech_balloon",blocked:"lock"}},xu=["done","dropped","doing","pending"],q3=["alert","needs-discussion","waiting","blocked"];function C9(){return B9(process.env.HOME||E9(),".config","slack-cli","todo.json")}function pF(D){return D.replace(/^:+|:+$/g,"")}function au(D=C9()){let u={marker:F2.marker,progress:{...F2.progress},flags:{...F2.flags}};try{if(!u9(D))return u;let F=JSON.parse(F9(D,"utf8"));if(typeof F.marker==="string"&&F.marker.trim())u.marker=pF(F.marker.trim());for(let B of xu){let E=F.progress?.[B];if(typeof E==="string"&&E.trim())u.progress[B]=pF(E.trim())}for(let B of q3){let E=F.flags?.[B];if(typeof E==="string"&&E.trim())u.flags[B]=pF(E.trim())}}catch{}return u}function V3(D,u,F=!1){return`${F?"-":""}${u?"has":"hasmy"}::${pF(D)}:`}function K3(D,u,F={}){let B=F.shared===!0,E=(z)=>V3(z,B),C=(z)=>V3(z,B,!0),$=[];if(D==="untriaged")$.push(E(u.marker),...xu.map((z)=>C(u.progress[z])));else if(D==="stuck")$.push(E(u.marker),C(u.progress.done),C(u.progress.dropped),`(${q3.map((z)=>E(u.flags[z])).join(" OR ")})`);else if(D==="open")$.push(E(u.marker),C(u.progress.done),C(u.progress.dropped));else{let z=xu.indexOf(D);$.push(E(u.progress[D]));for(let Z of xu.slice(0,z))$.push(C(u.progress[Z]))}if(F.in){let z=F.in.startsWith("#")||F.in.startsWith("@")?F.in:`#${F.in}`;$.push(`in:${z}`)}if(F.from){let z=F.from==="me"||F.from.startsWith("@")?F.from:`@${F.from}`;$.push(`from:${z}`)}return $.join(" ")}var $9=3,z9={sleep:(D)=>new Promise((u)=>setTimeout(u,D))};async function _D(D,u,F=$9){for(let B=0;;B++)try{return await u()}catch(E){if(!(E instanceof fD))throw E;if(B>=F)throw Error(`Slack rate limit hit on ${D} — gave up after ${F} retries. Try again in a minute.`);console.error(`Warning: Slack rate limit hit on ${D} — backing off for ${E.retryAfter}s`),await z9.sleep(E.retryAfter*1000)}}var H3=new Map;async function O3(D,u){let F=H3.get(D);if(F)return F;let B=await _D("auth.test",()=>Su(D,u)),E={userId:B.userId,teamId:B.teamId};return H3.set(D,E),E}async function U3(D,u){return(await O3(D,u)).userId}async function j3(D,u){try{return(await O3(D,u)).teamId}catch{return""}}async function E2(D,u,F,B){if(!u.startsWith("#"))return F(D,u,B);let E=await j3(D,B),C=D2("channels",E,u);if(C)return C;let $=await _D("resolveChannel",()=>F(D,u,B));return u2("channels",E,u,$),$}async function M3(D,u,F,B){let E=await j3(D,B),C=D2("users",E,u);if(C)return C;let $=await _D("users.info",()=>F(D,u,B));if($&&$!==u)u2("users",E,u,$);return $}async function _3(D,u,F,B,E,C){let $=E.progress[B],z=await U3(D,C),Z=await _D("reactions.get",()=>G1(D,u,F,C)),J=new Set(Z.filter((V)=>V.users.includes(z)).map((V)=>V.name)),Q=xu.map((V)=>E.progress[V]).filter((V)=>J.has(V));if(Q.length===1&&Q[0]===$)return{noop:!0,removed:[],leftover:[]};if(!J.has($))await _D("reactions.add",()=>MF(D,u,F,$,C));let G=[],Y=[];for(let V of Q){if(V===$)continue;try{await _D("reactions.remove",()=>_F(D,u,F,V,C)),G.push(V)}catch{Y.push(V)}}return{noop:!1,added:B,removed:G,leftover:Y}}async function N3(D,u,F,B,E,C,$){let z=E.flags[B];if(C)await _D("reactions.remove",()=>_F(D,u,F,z,$));else await _D("reactions.add",()=>MF(D,u,F,z,$));return z}var B2=1000;async function A3(D,u,F,B={}){let E=B.limit??B2,C=B.cookie,$=await U3(D,C),z=xu.map((Y)=>F.progress[Y]),Z=[],J=0,Q,G=!1;while(J<E){let Y=Math.min(200,E-J),V=await _D("conversations.history",()=>du(D,u,Y,void 0,Q,C)),H=V.messages??[];J+=H.length;for(let W of H){let K=String(W.ts??"");if(!K)continue;let N=new Set((W.reactions??[]).filter((L)=>(L.users??[]).map(String).includes($)).map((L)=>String(L.name??""))),j=z.filter((L)=>N.has(L));if(j.length<2)continue;Z.push({ts:K,text:String(W.text??"").split(`
|
|
134
|
+
`)[0]??"",emoji:j,keep:j[0]})}if(Q=V.response_metadata?.next_cursor||void 0,!Q||H.length===0)break;if(J>=E){G=!0;break}}if(B.fix)for(let Y of Z)try{try{await _D("reactions.add",()=>MF(D,u,Y.ts,Y.keep,C))}catch(V){if(!(V instanceof Error)||!/already_reacted/.test(V.message))throw V}for(let V of Y.emoji){if(V===Y.keep)continue;await _D("reactions.remove",()=>_F(D,u,Y.ts,V,C))}Y.fixed=!0}catch(V){Y.fixed=!1,Y.error=V instanceof Error?V.message:String(V)}return{scanned:J,findings:Z,truncated:G}}var Z9=!0,J9;function C2(D){if(Z9=D,!D)J9=void 0}function _u(D){return D.toLowerCase().replace(/[-_\s]/g,"")}function aD(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function G9(D,u){let F=_u(u),B=aD(D.profile);for(let C of[D.name,D.real_name,B.display_name,B.real_name])if(typeof C==="string"&&C&&_u(C)===F)return!0;let E=typeof B.email==="string"?B.email.toLowerCase():"";return E!==""&&E===u.toLowerCase()}function X9(D){let u=aD(D.profile),F=new Set;for(let B of[u.display_name,D.real_name,D.name,u.real_name])if(typeof B==="string"&&B){let E=_u(B);if(E.length>=2)F.add(E)}return[...F]}function Q9(D,u){let F=_u(D),B,E=!1;for(let C of u){let $=typeof C.id==="string"?C.id:"";if(!$)continue;for(let z of X9(C)){let Z=-1;if(F===z)Z=D.length;else for(let J of T3)if(D.length>J.length&&D.endsWith(J)&&_u(D.slice(0,D.length-J.length))===z){Z=D.length-J.length;break}if(Z<0)continue;if(!B||z.length>B.formLen)B={userId:$,matchLen:Z,formLen:z.length,display:G2(C)},E=!1;else if(z.length===B.formLen&&B.userId!==$)E=!0}}if(!B)return;return E?"ambiguous":{userId:B.userId,matchLen:B.matchLen,display:B.display}}async function z2(D,u,F,B){let E=`[${R3}ー]+`,C=`${E}(?:[._-]+${E})*`,$=new RegExp(`(?<![A-Za-z0-9._@<-])@(${C})`,"gu"),z=new Set;for(let j of u.matchAll($))z.add(j[1]);if(z.size===0)return{text:u,resolved:[],unresolved:[]};let Z=new Map;for(let j of z)Z.set(j,{status:"pending"});let J=(j)=>{for(let L of z){if(Z.get(L).status!=="pending")continue;if(J2(L)){let M=Q9(L,j);if(M==="ambiguous")Z.set(L,{status:"ambiguous"});else if(M)Z.set(L,{status:"resolved",userId:M.userId,matchLen:M.matchLen,display:M.display})}else{let M=j.filter((h)=>G9(h,L)),T=new Set(M.map((h)=>typeof h.id==="string"?h.id:"").filter(Boolean));if(T.size===1){let h=M.find((p)=>typeof p.id==="string");Z.set(L,{status:"resolved",userId:h.id,matchLen:L.length,display:G2(h)})}else if(T.size>1)Z.set(L,{status:"ambiguous"})}}},Q=!1;try{let j=await LF(D,B);J((j.members??[]).map(aD)),Q=!0}catch{Q=!1}let G=[...z].some((j)=>Z.get(j).status==="pending"),Y=!1,V=!0;if(G&&F){Y=!0;try{let j=await I0(D,F,B),L=[];for(let M of j){let T=aD(await b0(D,M,B)),h=aD(T.user);if(typeof h.id!=="string")h.id=M;L.push(h)}J(L)}catch{V=!1}}let H=Q&&(F?Y&&V:!0),W=[],K=[];for(let j of z){let L=Z.get(j);if(L.status==="resolved")W.push({surface:`@${j.slice(0,L.matchLen)}`,display:L.display,userId:L.userId});else if(L.status==="ambiguous")K.push({surface:`@${j}`,reason:"ambiguous"});else K.push({surface:`@${j}`,reason:H?"no-match":"unavailable"})}return{text:u.replace($,(j,L)=>{let M=Z.get(L);if(M&&M.status==="resolved")return`<@${M.userId}>${L.slice(M.matchLen)}`;return j}),resolved:W,unresolved:K}}function Z2(D){let u=[],F=!1;for(let B of D)if(B.reason==="ambiguous")u.push(`${B.surface} matches multiple people — not tagged, sent as plain text (use <@USERID> to tag)`);else if(B.reason==="unavailable"){if(F)continue;u.push("could not fetch the user list (users:read missing or an API/connection error) — @mentions not tagged, sent as plain text"),F=!0}else u.push(`${B.surface} matched no one — not tagged, sent as plain text`);return u}async function L3(D,u,F,B={}){let E=B.warn??(($)=>process.stderr.write(`${$}
|
|
135
|
+
`)),C=await z2(D,u,F,B.cookie);for(let $ of Z2(C.unresolved))E(`warn: ${$}`);return C.text}var T3=["さん","さま","様","君","くん","ちゃん","氏","先生","先輩","殿","老师","老師","兄","姐","哥","姐妹"],R3="\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}A-Za-z0-9";function J2(D){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u.test(D)}function Y9(D){let u=[],F=new RegExp(`([${R3}]{1,12})(${T3.join("|")})`,"gu");for(let B of D.matchAll(F))u.push({ref:B[1],honorific:B[2]});for(let B of D.matchAll(/\b(?:dear|hi|hello|hey)\b[ \t]+([A-Z][A-Za-z'’-]{1,20})/gi))u.push({ref:B[1],honorific:""});for(let B of D.matchAll(/(?:^|\n)[ \t]*([A-Z][A-Za-z'’-]{1,20}),/g))u.push({ref:B[1],honorific:""});return u}function W9(D){let u=aD(D.profile),F=new Set;for(let B of[D.name,D.real_name,u.display_name,u.real_name]){if(typeof B!=="string"||!B)continue;for(let E of[B,...B.split(/\s+/)]){let C=_u(E);if(C.length>=2)F.add(C)}}return[...F]}function V9(D,u){let F=_u(D);if(F.length<2)return;for(let B of u)if(F===B)return B;if(J2(D)){for(let B of u)if(F.includes(B)||B.includes(F))return B}return}function G2(D){return[aD(D.profile).display_name,D.real_name,D.name].filter((B)=>typeof B==="string"&&B!=="")[0]??String(D.id??"?")}async function P3(D,u,F){let B=Y9(u);if(B.length===0)return[];let E=new Set;for(let J of u.matchAll(/<@([A-Z0-9]+)(?:\|[^>]*)?>/g))E.add(J[1]);let $=((await LF(D,F)).members??[]).map(aD).filter((J)=>J.deleted!==!0&&J.is_bot!==!0&&J.id!=="USLACKBOT").map((J)=>({id:typeof J.id==="string"?J.id:"",forms:W9(J),display:G2(J)})).filter((J)=>J.id!==""),z=[],Z=new Set;for(let{ref:J,honorific:Q}of B)for(let G of $){let Y=V9(J,G.forms);if(!Y)continue;if(E.has(G.id)||Z.has(G.id))break;Z.add(G.id),z.push({surface:J2(J)?`${Y}${Q}`:J,display:G.display,userId:G.id});break}return z}async function Iu(D,u,F,B){let E=u,C=[],$=E,z=0;while(!0){let Z=$.indexOf("<@U",z);if(Z===-1)break;let J=$.slice(Z+2),Q=J.search(/[>|]/),G=Q===-1?J:J.slice(0,Q);if(G.length>=9)C.push(G);z=Z+1}for(let Z of C){if(!F.has(Z))F.set(Z,await AF(D,Z,B));let J=F.get(Z)??Z;E=E.replaceAll(`<@${Z}>`,`@${J}`),E=E.replace(new RegExp(`<@${Z}\\|[^>]*>`,"g"),`@${J}`)}return E}function eu(D){return D.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(u,F,B)=>{let E=Number(F);if(!Number.isFinite(E))return B??"date";let C=new Date(E*1000);if(Number.isNaN(C.getTime()))return B??"date";let $=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],z=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Z=$[C.getUTCDay()]??"",J=z[C.getUTCMonth()]??"";return`${Z}, ${J} ${String(C.getUTCDate()).padStart(2,"0")}, ${C.getUTCFullYear()}`})}function S3(D,u=new Date){let F=new Date(D*1000),B=$2(u),E=$2(new Date(u.getTime()-86400000)),C=$2(F);if(C===B)return"Today";if(C===E)return"Yesterday";let $=F.toLocaleDateString("en-US",{weekday:"long"}),z=F.toLocaleDateString("en-US",{month:"short"});return`${$}, ${z} ${String(F.getDate()).padStart(2,"0")}`}function $2(D){return`${D.getFullYear()}-${D.getMonth()}-${D.getDate()}`}function w3(D){let u=new Date(D*1000),F=u.getFullYear(),B=String(u.getMonth()+1).padStart(2,"0"),E=String(u.getDate()).padStart(2,"0"),C=String(u.getHours()).padStart(2,"0"),$=String(u.getMinutes()).padStart(2,"0");return`${F}-${B}-${E} ${C}:${$}`}function DF(D){if(!f3(D))return;let u=q9(D,"utf8");for(let F of u.split(`
|
|
136
136
|
`)){let B=F.trim();if(!B||B.startsWith("#"))continue;let E=B.indexOf("=");if(E===-1)continue;let C=B.slice(0,E).trim(),$=B.slice(E+1).trim();if($.startsWith('"')&&$.endsWith('"')||$.startsWith("'")&&$.endsWith("'"))$=$.slice(1,-1);if(!(C in process.env))process.env[C]=$}}function O9(D){K9(D,{recursive:!0});let u=eD(D,".gitignore");if(!f3(u))h3(u,`*
|
|
137
|
-
`)}function U9(){DF(eD(x3(),".slack-cli",".env.local")),DF(eD(x3(),".config/slack-cli",".env")),DF(eD(process.cwd(),".slack-cli",".env.local")),DF(eD(process.cwd(),".env.local")),DF(eD(process.cwd(),".env"))}function j9(D){return H9("sha256").update(D).digest("hex")}function
|
|
137
|
+
`)}function U9(){DF(eD(x3(),".slack-cli",".env.local")),DF(eD(x3(),".config/slack-cli",".env")),DF(eD(process.cwd(),".slack-cli",".env.local")),DF(eD(process.cwd(),".env.local")),DF(eD(process.cwd(),".env"))}function j9(D){return H9("sha256").update(D).digest("hex")}function b(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function t(D){return Array.isArray(D)?D:[]}function mF(D){return Number(D.ts??0)}async function v3(D,u,F){let B=u.user;if(typeof B==="string"){if(!F.has(B))F.set(B,await su(D,B));return F.get(B)??B}return typeof u.username==="string"?u.username:"bot"}function X2(D){let u=new Date(D*1000),F=u.getUTCFullYear(),B=String(u.getUTCMonth()+1).padStart(2,"0"),E=String(u.getUTCDate()).padStart(2,"0"),C=String(u.getUTCHours()).padStart(2,"0"),$=String(u.getUTCMinutes()).padStart(2,"0"),z=String(u.getUTCSeconds()).padStart(2,"0");return`${F}-${B}-${E} ${C}:${$}:${z}`}function Y2(D){let[u,F="000000"]=D.split("."),B=Number(u),E=new Date(B*1000),C=E.getUTCFullYear(),$=String(E.getUTCMonth()+1).padStart(2,"0"),z=String(E.getUTCDate()).padStart(2,"0"),Z=String(E.getUTCHours()).padStart(2,"0"),J=String(E.getUTCMinutes()).padStart(2,"0"),Q=String(E.getUTCSeconds()).padStart(2,"0"),G=F.padEnd(6,"0").slice(0,6);return`${C}-${$}-${z}T${Z}:${J}:${Q}.${G}`}function W2(D){let u=D.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\.(\d{6})$/);if(!u)throw Error(`Invalid message timestamp "${D}" \u2014 expected 2026-05-11T06:01:04.000100`);let F=Date.parse(u[1]+"Z");if(isNaN(F))throw Error(`Cannot parse date in "${D}"`);return`${Math.floor(F/1000)}.${u[2]}`}function M9(D){return/^\d{4}-\d{2}-\d{2}T/.test(D)?W2(D):D}async function cF(D,u,F,B,E){let C=typeof u.ts==="string"?u.ts:`${mF(u)}.000000`,$=Y2(C),z="?";if(typeof u.user==="string"){let j=u.user,L="@"+j;if(!F.has(L)){let M=await M3(D,j,async(T,h,p)=>(await ou(T,h,p))[1],E);F.set(L,M)}z=F.get(L)??j}else if(typeof u.username==="string")z=u.username;let Z=typeof u.text==="string"?u.text:"",Q=eu(await Iu(D,Z,F,E)).split(`
|
|
138
138
|
`),G=Q[0]+(Q.length>1?`
|
|
139
139
|
`+Q.slice(1).map((j)=>` ${j}`).join(`
|
|
140
|
-
`):""),Y=B?`${B} @${z}`:`@${z}`,V=t(u.reactions).map(
|
|
140
|
+
`):""),Y=B?`${B} @${z}`:`@${z}`,V=t(u.reactions).map(b).map((j)=>{let L=typeof j.name==="string"?j.name:"",M=Number(j.count??t(j.users).length??0);return L?`:${L}:\xD7${M}`:""}).filter(Boolean).join(" "),H=t(u.files).map(b).map((j)=>{let L=typeof j.name==="string"?j.name:typeof j.title==="string"?j.title:"(file)",M=typeof j.size==="number"?` (${dF(j.size)})`:"",T=typeof j.id==="string"?` [${j.id}]`:"";return`
|
|
141
141
|
\uD83D\uDCCE ${L}${M}${T}`}).join(""),W=Number(u.reply_count??0),K=W>0?` [+${W} ${W===1?"reply":"replies"}]`:"",N=(V?`
|
|
142
|
-
${V}`:"")+H;return`${$} ${Y}: ${G}${K}${N}`}function
|
|
143
|
-
`)[0]??"",Y=await Iu(D,G,B);console.log(` ${Q}: ${Y}`)}}}async function R9(D,u){let F=await r1(D,"to:me"),B=t(iu(F,["messages","matches"])).map(
|
|
144
|
-
`)[0]?.slice(0,60)}`:"";console.log(`${Y}${J} ${Z}${V}${W}`)}}function S9(D){let u=(E)=>E.startsWith("xoxp-")||E.startsWith("xoxc-"),F=
|
|
142
|
+
${V}`:"")+H;return`${$} ${Y}: ${G}${K}${N}`}function dF(D){return D<1024?`${D} B`:D<1048576?`${(D/1024).toFixed(1)} KB`:`${(D/1048576).toFixed(1)} MB`}function _9(D){return t(D.files).map(b).map((u)=>({id:u.id??null,name:u.name??u.title??null,mimetype:u.mimetype??null,size:u.size??null,url_private_download:u.url_private_download??u.url_private??null,permalink:u.permalink??null}))}function y3(D){let u=_9(D);return{ts:D.ts??null,user:D.user??null,username:D.username??null,bot_id:D.bot_id??null,thread_ts:D.thread_ts??null,text:typeof D.text==="string"?D.text:"",...D.reply_count!==void 0?{reply_count:D.reply_count}:{},...D.reply_users_count!==void 0?{reply_users_count:D.reply_users_count}:{},...D.latest_reply!==void 0?{latest_reply:D.latest_reply}:{},...u.length>0?{files:u}:{}}}async function N9(D,u,F,B,E){let C=[];for(let $ of F){let z=$;if(Number($.reply_count??0)>0&&typeof $.ts==="string"){let Z=await Mu(D,u,$.ts,200,E),J=t(Z.messages).map(b);z=J[J.length-1]??$}if(z.user!==B)C.push($)}return C}async function A9(D,u,F,B="text",E=!1,C){let $=tu(u),z=await VD(D,u,C),Z=new Map,Q=await(async()=>{if($?.threadTs){let Y=await Mu(D,z,$.threadTs,F,C);return t(Y.messages).map(b)}let G=await lu(D,z,F,void 0,void 0,C);return t(G.messages).map(b).reverse()})();if(E){let{userId:G}=await i1(D,C);Q=await N9(D,z,Q,G,C)}if(B==="jsonl"){for(let G of Q)console.log(JSON.stringify(y3(G)));return}for(let G of Q)console.log(await cF(D,G,Z,void 0,C))}async function L9(D,u,F,B,E="text",C){let $=await VD(D,u,C),z=await Mu(D,$,M9(F),B,C),Z=t(z.messages).map(b);if(E==="jsonl"){for(let Q of Z)console.log(JSON.stringify(y3(Q)));return}let J=new Map;for(let Q of Z)console.log(await cF(D,Q,J,void 0,C))}async function T9(D){let u=await fF(D),F=t(u.channels).map(b).filter((E)=>E.is_member===!0).sort((E,C)=>Number(C.updated??0)-Number(E.updated??0)).slice(0,10),B=new Map;for(let E of F){let C=String(E.id??""),$=typeof E.name==="string"?E.name:typeof E.user==="string"?E.user:C,z=await lu(D,C,5),Z=t(z.messages).map(b).filter((J)=>J.subtype===void 0||J.subtype===null).filter((J)=>{let Q=typeof J.text==="string"?J.text:"";return Q.length>0&&!Q.startsWith("<@")}).slice(0,3).reverse();if(Z.length===0)continue;console.log(`-- #${$} --------------------------------`);for(let J of Z){let Q=await v3(D,J,B),G=(typeof J.text==="string"?J.text:"").split(`
|
|
143
|
+
`)[0]??"",Y=await Iu(D,G,B);console.log(` ${Q}: ${Y}`)}}}async function R9(D,u){let F=await r1(D,"to:me"),B=t(iu(F,["messages","matches"])).map(b).slice(0,u),E=new Map,C=[];for(let $ of B){let z=S3(mF($)),Z=C[C.length-1];if(Z?.label===z)Z.msgs.push($);else C.push({label:z,msgs:[$]})}for(let $=0;$<C.length;$++){let{label:z,msgs:Z}=C[$];if($>0)console.log("");console.log(` ${z}`),console.log(" ----------------------------");for(let J of[...Z].reverse()){let Q=b(J.channel),G=Q.is_im===!0,Y=typeof Q.name==="string"?Q.name:"dm",V;if(G&&Y.startsWith("U")){let H="@"+Y;if(!E.has(H)){let[,W]=await ou(D,Y);E.set(H,W)}V=`@${E.get(H)??Y}`}else if(G)V=`@${Y}`;else V=`#${Y}`;console.log(await cF(D,J,E,V))}}}async function P9(D,u,F,B,E="text"){let C=await fF(D),$=t(C.channels).map(b).filter((z)=>B||z.is_member===!0).filter((z)=>{if(!F)return!0;return(typeof z.name==="string"?z.name:"").toLowerCase().includes(F.toLowerCase())}).sort((z,Z)=>Number(Z.updated??0)-Number(z.updated??0)).slice(0,u);if(E==="jsonl"){for(let z of $)console.log(JSON.stringify(z));return}for(let z of $){let Z=String(z.id??""),J=typeof z.name==="string"?z.name:typeof z.user==="string"?z.user:Z,Q=z.is_im===!0,G=z.is_mpim===!0,Y=Q||G?"@":"#",V=z.is_member===!0?"":" (not joined)",H=typeof b(z.purpose).value==="string"?String(b(z.purpose).value):"",W=H?` ${H.split(`
|
|
144
|
+
`)[0]?.slice(0,60)}`:"";console.log(`${Y}${J} ${Z}${V}${W}`)}}function S9(D){let u=(E)=>E.startsWith("xoxp-")||E.startsWith("xoxc-"),F=T0(),B=F.find((E)=>E.profile.token===D);if(!B)return;return F.find((E)=>u(E.profile.token)&&E.profile.teamId===B.profile.teamId)}async function p3(D,u,F,B,E){let C=D,$=E,z;try{z=await n0(C,u,F,$)}catch(Q){let G=Q instanceof Error?Q.message:String(Q);if(D.startsWith("xoxb-")&&G.includes("not_allowed_token_type")){let Y=S9(D);if(Y)console.error(`Note: search.messages needs a user token \u2014 the active profile is a bot token (xoxb-); falling back to profile "${Y.name}".`),C=Y.profile.token,$=Y.profile.cookie,z=await n0(C,u,F,$);else console.error(`Error: search requires a user token (xoxp-/xoxc-) \u2014 the active profile is a bot token (xoxb-), which Slack rejects for search.messages.
|
|
145
145
|
`+` Add a user-token profile: slack auth login (or slack auth token)
|
|
146
|
-
Then select it: slack auth use <name> (or pass --workspace <name>)`),process.exit(1)}else throw Q}if(B){console.log(JSON.stringify(z,null,2));return}let Z=t(iu(z,["messages","matches"])).map(
|
|
146
|
+
Then select it: slack auth use <name> (or pass --workspace <name>)`),process.exit(1)}else throw Q}if(B){console.log(JSON.stringify(z,null,2));return}let Z=t(iu(z,["messages","matches"])).map(b),J=new Map;for(let Q of Z){let G=b(Q.channel),Y=G.is_im===!0,V=typeof G.name==="string"?G.name:"dm",H;if(Y&&V.startsWith("U")){let W="@"+V;if(!J.has(W)){let[,K]=await ou(C,V,$);J.set(W,K)}H=`@${J.get(W)??V}`}else if(Y)H=`@${V}`;else H=`#${V}`;console.log(await cF(C,Q,J,H,$))}}async function m3(D,u,F,B){let{ref:E,ts:C}=kF(u);if(!C)console.error("Error: target must embed a message ts (e.g. #chan:1700000000.000100 or a Slack permalink URL)"),process.exit(2);return{channelId:F??await E2(D,E,VD,B),ts:C}}async function w9(D,u){let F=au(),B={};if(!u.mine)B.shared=!0;if(u.in)B.in=u.in;if(u.from)B.from=u.from;let E=K3(u.state,F,B);if(!u.json){let C=await bu(D,u.cookie),$=u.mine?"your reactions only [hasmy:]":"anyone's reactions [has:]";console.error(`(From: ${d3(C)} \xB7 matching ${$})`),console.error(`(query: ${E})`)}await _D("search.messages",()=>p3(D,E,u.count,u.json,u.cookie))}async function x9(D,u){let F=au(),{channelId:B,ts:E}=await m3(D,u.target,u.channelId,u.cookie),C=await _3(D,B,E,u.state,F,u.cookie);if(C.noop){console.log(`= Already ${u.state} (ts: ${E})`);return}let $=C.removed.length?`, removed ${C.removed.map((z)=>`:${z}:`).join(" ")}`:"";if(console.log(`\u2713 ${u.state} :${F.progress[u.state]}: (ts: ${E})${$}`),C.leftover.length)console.error(`\u26A0 ${C.leftover.map((z)=>`:${z}:`).join(" ")} could not be removed \u2014 this message now carries more than one `+"progress reaction. Readers collapse by priority so nothing is lost; repair with: slack todo doctor --in <#chan> --fix")}async function I9(D,u){let F=au(),{channelId:B,ts:E}=await m3(D,u.target,u.channelId,u.cookie),C=await N3(D,B,E,u.flag,F,u.remove===!0,u.cookie);console.log(`\u2713 ${u.remove?"Cleared":"Flagged"} ${u.flag} :${C}: (ts: ${E})`)}async function b9(D,u){let F=au(),B=u.channelId??await E2(D,u.channel,VD,u.cookie),E={limit:u.limit};if(u.fix)E.fix=!0;if(u.cookie)E.cookie=u.cookie;let C=await A3(D,B,F,E);if(C.findings.length===0)console.log(`\u2713 No multi-state tasks in ${C.scanned} message(s).`);else{for(let $ of C.findings){let z=$.fixed===!0?"fixed":$.fixed===!1?`FAILED: ${$.error??"?"}`:"needs --fix";console.log(`${$.ts} ${$.emoji.map((Z)=>`:${Z}:`).join(" ")} \u2192 keep :${$.keep}: [${z}] ${cD($.text).slice(0,60)}`)}console.log(`${C.findings.length} multi-state task(s) in ${C.scanned} message(s).`)}if(C.truncated)console.error(`\u26A0 Scan limit reached (${u.limit} messages) \u2014 older history was NOT checked. Raise it with --limit N.`)}async function f9(D,u,F,B){let E=Math.floor(Date.now()/1000)-u*86400,C=await fF(D),$=t(C.channels).map(b).filter((Q)=>Q.is_member===!0&&Q.is_im!==!0&&Q.is_mpim!==!0).filter((Q)=>{if(!B)return!0;return(typeof Q.name==="string"?Q.name:"").toLowerCase().includes(B.toLowerCase())}).sort((Q,G)=>Number(G.updated??0)-Number(Q.updated??0)),z=new Map,Z=0,J=0;for(let Q of $){let G=String(Q.id??""),Y=typeof Q.name==="string"?Q.name:G,V;try{V=await lu(D,G,F)}catch(W){console.error(` SKIP #${Y}: ${W.message}`);continue}let H=t(V.messages).map(b).filter((W)=>(W.subtype===void 0||W.subtype===null)&&mF(W)>=E);if(H.length===0)continue;J+=1,Z+=H.length,console.log(`## #${Y} (${H.length} msgs)
|
|
147
147
|
`);for(let W of[...H].reverse()){let K=await v3(D,W,z),N=typeof W.text==="string"?W.text:"",L=eu(await Iu(D,N,z)).split(`
|
|
148
|
-
`).join(" \u21B5 ");console.log(`[${w3(
|
|
149
|
-
`))console.log(` ${j}`)}}async function y9(D,u,F){let B=await ru(D,u),E=t(B.drafts).map(
|
|
150
|
-
`)).slice(0,4)}function cD(D){return D.replace(/\x1b\[[0-9;:?]*[ -/]*[@-~]/g,"").replace(/[\x00-\x1f\x7f-\x9f]/g,"").replace(/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g,"")}var p9={"reactions.add":"reactions:write","reactions.remove":"reactions:write","chat.postMessage":"chat:write","chat.update":"chat:write","chat.delete":"chat:write","conversations.replies":"channels:history (or groups:history)","conversations.history":"channels:history (or groups:history)"};function uF(D){let u=D instanceof Error?D.message:String(D),F=u.match(/Slack error on (\S+): (\w+)/);if(!F)return u;let[,B,E]=F;switch(E){case"missing_scope":return`Error: token lacks the ${p9[B]??"the required"} scope (needed for ${B}). Add it to your Slack App's User Token Scopes (or Bot Token Scopes if you use a bot token / --as-bot) \u2014 it must be on the token type the CLI actually uses \u2014 then reinstall to the workspace.`;case"invalid_name":return"Error: not a valid emoji shortcode \u2014 use the name without colons (e.g. white_check_mark), and make sure it exists in the workspace.";case"already_reacted":return"Error: you've already added that reaction to the message.";case"no_reaction":return"Error: that reaction isn't on the message \u2014 nothing to remove.";case"message_not_found":return"Error: no message found at that timestamp in the channel \u2014 check the target ts/permalink.";case"channel_not_found":return"Error: channel not found \u2014 check the target.";default:return u}}function vD(D,u,F){for(let B of F)console.log(B);if(D!==void 0)console.error(`Code mismatch (got ${D}, expected ${u})`);console.error(`Rerun with --code=${u}`),process.exit(1)}function
|
|
151
|
-
`)[0]??"",$=C.length>F?`${C.slice(0,F)}\u2026`:C,z=typeof u.ts==="string"?u.ts:"";return`${z?
|
|
148
|
+
`).join(" \u21B5 ");console.log(`[${w3(mF(W))}] ${K}: ${L}`)}console.log("")}console.error(`Dumped ${Z} messages across ${J} channels (cutoff: ${u}d)`)}function h9(D){let u=[];function F(B){if(typeof B==="string"){u.push(B);return}if(Array.isArray(B)){for(let E of B)F(E);return}if(B&&typeof B==="object"){let E=B;if(typeof E.text==="string"){u.push(E.text);return}if(Array.isArray(E.elements))F(E.elements);else if(Array.isArray(E.content))F(E.content)}}for(let B of D)F(B);return u.join("").trim()}async function g3(D,u,F){let B=new Map;return async(E)=>{if(!E)return"(unknown)";if(B.has(E))return B.get(E);try{let C=await G3(D,E,u),$=b(C.channel),z;if($.is_im===!0){let Z=typeof $.user==="string"?$.user:"";if(!Z||Z===F)z="@self";else{let[J]=await ou(D,Z);z=`@${J}`}}else z=`#${typeof $.name==="string"?$.name:E}`;return B.set(E,z),z}catch{return E}}}function V2(D){let u=b(t(D.destinations)[0]);return String(u.channel_id??D.channel_id??D.channel??"")}function gF(D){return h9(t(D.blocks))||(typeof D.text==="string"?D.text:"(no text)")}async function v9(D,u,F=!1){let B=await ru(D,u),E=t(B.drafts??B.messages??[]).map(b).filter((J)=>J.is_deleted!==!0),C=F?E:E.filter((J)=>J.is_sent!==!0);if(C.length===0){console.log(F?"No drafts.":"No pending drafts. Run with --all to include sent.");return}let $="";try{({userId:$}=await a0(D,u))}catch{}let z=await g3(D,u,$),Z=new Map;for(let J of C){let Q=V2(J),G=gF(J),Y=Number(J.date_created??J.date_create??0),V=Y?X2(Y):"?",H=await z(Q),W=typeof J.id==="string"?J.id:"",K=J.is_sent===!0?" [SENT]":"",N=eu(await Iu(D,G,Z));console.log(`-- ${W} ${H} [${V}]${K}`);for(let j of N.split(`
|
|
149
|
+
`))console.log(` ${j}`)}}async function y9(D,u,F){let B=await ru(D,u),E=t(B.drafts).map(b).find((H)=>String(H.id)===F);if(!E)console.error(`Draft not found: ${F}`),process.exit(1);let C="";try{({userId:C}=await a0(D,u))}catch{}let $=await g3(D,u,C),z=V2(E),Z=gF(E),J=Number(E.date_created??0),Q=String(E.last_updated_ts??"?"),G=await $(z),V=eu(await Iu(D,Z,new Map));console.log(`id: ${E.id}`),console.log(`channel: ${G} (${z})`),console.log(`created: ${J?X2(J):"?"}`),console.log(`updated: ${X2(Number(Q.split(".")[0]))}`),console.log(`status: ${E.is_sent===!0?"sent":"pending"}`),console.log("---"),console.log(V)}function dD(...D){return j9(D.join(`
|
|
150
|
+
`)).slice(0,4)}function cD(D){return D.replace(/\x1b\[[0-9;:?]*[ -/]*[@-~]/g,"").replace(/[\x00-\x1f\x7f-\x9f]/g,"").replace(/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g,"")}var p9={"reactions.add":"reactions:write","reactions.remove":"reactions:write","chat.postMessage":"chat:write","chat.update":"chat:write","chat.delete":"chat:write","conversations.replies":"channels:history (or groups:history)","conversations.history":"channels:history (or groups:history)"};function uF(D){let u=D instanceof Error?D.message:String(D),F=u.match(/Slack error on (\S+): (\w+)/);if(!F)return u;let[,B,E]=F;switch(E){case"missing_scope":return`Error: token lacks the ${p9[B]??"the required"} scope (needed for ${B}). Add it to your Slack App's User Token Scopes (or Bot Token Scopes if you use a bot token / --as-bot) \u2014 it must be on the token type the CLI actually uses \u2014 then reinstall to the workspace.`;case"invalid_name":return"Error: not a valid emoji shortcode \u2014 use the name without colons (e.g. white_check_mark), and make sure it exists in the workspace.";case"already_reacted":return"Error: you've already added that reaction to the message.";case"no_reaction":return"Error: that reaction isn't on the message \u2014 nothing to remove.";case"message_not_found":return"Error: no message found at that timestamp in the channel \u2014 check the target ts/permalink.";case"channel_not_found":return"Error: channel not found \u2014 check the target.";default:return u}}function vD(D,u,F){for(let B of F)console.log(B);if(D!==void 0)console.error(`Code mismatch (got ${D}, expected ${u})`);console.error(`Rerun with --code=${u}`),process.exit(1)}function kF(D){let u=tu(D);if(u)return u.ts?{ref:u.channel,ts:u.ts}:{ref:u.channel};if(D.startsWith("#")||D.startsWith("@")){let F=D.indexOf(":");if(F>0){let B=D.slice(F+1);if(/^\d{10}\.\d{6}$/.test(B))return{ref:D.slice(0,F),ts:B};if(/^\d{4}-\d{2}-\d{2}T/.test(B))return{ref:D.slice(0,F),ts:W2(B)}}}return{ref:D}}function H2(D){let u=tu(D);if(u){let B=u.threadTs??u.ts;return B?{ref:u.channel,threadTs:B}:{ref:u.channel}}let F=D.indexOf(":");if(F>0){let B=D.slice(F+1);if(/^\d{10}\.\d{6}$/.test(B))return{ref:D.slice(0,F),threadTs:B};if(/^\d{4}-\d{2}-\d{2}T/.test(B))return{ref:D.slice(0,F),threadTs:W2(B)}}return{ref:D}}async function c3(D,u,F,B){let E=F;if(!F.startsWith("#")&&!F.startsWith("@"))try{let C=b(await hF(D,u,B)),$=b(C.channel);if($.is_im===!0){let z=typeof $.user==="string"?$.user:"";E=z?`@${await su(D,z,B)}`:u}else E=typeof $.name==="string"?`#${$.name}`:u}catch{E=u}return E===u?u:`${E} (${u})`}async function bu(D,u){try{return await l1(D,u)}catch{return null}}function FF(D,u){let F;return async()=>{if(F===void 0)F=await bu(D,u);return F}}function d3(D,u){let F=u?" [as bot]":"";if(!D)return`(unknown \u2014 auth.test failed)${F}`;let B=cD(D.user||D.userId||"?"),E=D.userId?` (${D.userId})`:"",C=D.team?` \u2014 ${cD(D.team)}`:"";return`@${B}${E}${C}${F}`}function yD(D,u={}){return` ${"From:".padEnd(u.pad??6)}${d3(D,u.asBot)}`}async function Q2(D,u,F=60,B){let E=typeof u.user==="string"?await su(D,u.user,B):typeof u.username==="string"?u.username:"?",C=(typeof u.text==="string"?u.text:"").split(`
|
|
151
|
+
`)[0]??"",$=C.length>F?`${C.slice(0,F)}\u2026`:C,z=typeof u.ts==="string"?u.ts:"";return`${z?Y2(z).slice(0,16).replace("T"," "):""} @${E}${$?`: ${$}`:""}`}async function m9(D,u,F,B){let E=F.find((C)=>String(C.ts)===u)??F[0];if(!E)return u;return Q2(D,E,40,B)}function I3(D){return D.toLowerCase().replace(/<[@#!][^>]+>/g," ").replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function g9(D,u){let F=I3(D),B=I3(u);if(!F||!B)return 0;if(F===B)return 1;let E=(J)=>{let Q=new Map;for(let G=0;G<J.length-1;G++){let Y=J.slice(G,G+2);Q.set(Y,(Q.get(Y)??0)+1)}return Q},C=E(F),$=E(B);if(C.size===0||$.size===0)return 0;let z=0;for(let[J,Q]of C){let G=$.get(J);if(G)z+=Math.min(Q,G)}let Z=b3(C)+b3($);return Z===0?0:2*z/Z}function b3(D){let u=0;for(let F of D.values())u+=F;return u}async function c9(D,u){let F=FF(D,u.cookie),{ref:B,ts:E}=kF(u.target);if(!E)console.error("Error: target must embed a message ts (e.g. #chan:2026-05-11T06:01:04.000100 or a Slack permalink URL)"),process.exit(2);let C;if(u.channelId)C=u.channelId;else C=await VD(D,B,u.cookie);let $=await Mu(D,C,E,1,u.cookie),Z=t($.messages).map(b).find((H)=>String(H.ts)===E);if(!Z)console.error(`Message not found at ts=${E} in channel ${C}`),process.exit(1);let J=typeof Z.text==="string"?Z.text:"",Q=u.mentions?await L3(D,u.newText,C,u.cookie?{cookie:u.cookie}:{}):u.newText,G=await F(),Y=dD(J,Q,G?.userId??"");if(u.code!==Y)vD(u.code,Y,["--- Editing as -------------------------------",yD(G),"--- Original message -------------------------",...J.split(`
|
|
152
152
|
`).map((H)=>` ${H}`),"--- Replacing with ---------------------------",...Q.split(`
|
|
153
|
-
`).map((H)=>` ${H}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let V=await F3(D,C,E,Q,u.cookie);console.log(`\u2713 Edited (ts: ${V})`)}async function d9(D,u){let F=FF(D,u.cookie),{ref:B,ts:E}=
|
|
154
|
-
`).map((V)=>` ${V}`),"---------------------------------------------"])}await E3(D,C,E,u.cookie),console.log(`\u2713 Deleted (ts: ${E})`)}async function k9(D,u){let{ref:F,ts:B}=
|
|
155
|
-
`+` To reach yourself with a notification, send as the bot: slack send '${
|
|
156
|
-
`)[0]?.slice(0,100)??"(empty)"}`,...J,"--- Sending ----------------------------------",T,` \u2192 ${M} \u2014 NEW top-level message`,` Message: ${z}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}let j=await a1(D,$,z,B,u.broadcast,E),L="";try{L=await t0(D,$,j,E)}catch{}if(L)console.log(`\u2713 Sent: ${L}`);else console.log(`\u2713 Sent (ts: ${j})`);if(u.asBot&&$.startsWith("D"))try{let M=await
|
|
157
|
-
`)[0]?.slice(0,80)??""}`)}}async function a9(D,u){let F;if(u.channelId)F=u.channelId;else F=await VD(D,u.target,u.cookie);let B=await bu(D,u.cookie),E=dD(F,u.id,B?.userId??"");if(u.code!==E)vD(u.code,E,["--- Deleting scheduled message ---------------",yD(B,{pad:9}),` Channel: ${u.target}`,` ID: ${u.id}`,"---------------------------------------------"]);await u3(D,F,u.id,u.cookie),console.log(`\u2713 Deleted scheduled message ${u.id}`)}async function e9(D,u){let F=FF(D,u.cookie),{statSync:B,existsSync:E}=await import("fs"),{basename:C}=await import("path");for(let H of u.filePaths)if(!E(H))console.error(`Error: file not found: ${H}`),process.exit(1);let{ref:$,threadTs:z}=
|
|
158
|
-
`+"Expected F\u2026 or https://<ws>.slack.com/lists/<TEAM>/<F-id>");let C=[],$;do{let Z={limit:200};if($)Z.cursor=$;let J=
|
|
159
|
-
`+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let C=
|
|
160
|
-
`),await xF(),process.exit(0);throw $}},!0).command(["read [target]","msgs [target]"],"Browse messages",(E)=>E.positional("target",{type:"string",describe:"#channel, @user, or URL"}).option("limit",{alias:"n",type:"number",default:20,describe:"Number of messages"}).option("format",{type:"string",choices:["text","jsonl"],default:"text",describe:"jsonl exposes raw ts/user/text (incl. external-guest user IDs)"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}).option("unreplied",{type:"boolean",default:!1,describe:"Only messages whose last word (incl. thread replies) is not yours \u2014 i.e. awaiting your answer"}),async(E)=>{let C=D(E),$=E.json?"jsonl":E.format;if(E.target)await A9(C,E.target,E.limit,$,E.unreplied,u(E));else await T9(C)}).command("thread <target> <ts>","Show thread messages",(E)=>E.positional("target",{type:"string",demandOption:!0}).positional("ts",{type:"string",demandOption:!0}).option("limit",{alias:"n",type:"number",default:100}).option("format",{type:"string",choices:["text","jsonl"],default:"text",describe:"jsonl exposes raw ts/user/text (incl. external-guest user IDs)"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(E)=>{let C=E.json?"jsonl":E.format;await L9(D(E),E.target,E.ts,E.limit,C,u(E))}).command(["channel","channels","ch"],"Channel commands",(E)=>E.command(["ls","list"],"List channels",(C)=>C.option("limit",{alias:"n",type:"number",default:200}).option("filter",{alias:"f",type:"string"}).option("all",{type:"boolean",default:!1}).option("format",{type:"string",choices:["text","jsonl"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(C)=>{await P9(D(C),C.limit,C.filter,C.all,C.json?"jsonl":C.format)}).command("get <channel>","Show channel details",(C)=>C.positional("channel",{type:"string",demandOption:!0,describe:"#name or channel ID"}),async(C)=>{let $=D(C),z=u(C),Z=C.channel,J=Z.startsWith("#")||Z.startsWith("@")||Z.startsWith("C")||Z.startsWith("G")||Z.startsWith("D")?Z:`#${Z}`,Q=await VD($,J,z),G=
|
|
153
|
+
`).map((H)=>` ${H}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let V=await F3(D,C,E,Q,u.cookie);console.log(`\u2713 Edited (ts: ${V})`)}async function d9(D,u){let F=FF(D,u.cookie),{ref:B,ts:E}=kF(u.target);if(!E)console.error("Error: target must embed a message ts (e.g. #chan:2026-05-11T06:01:04.000100 or a Slack permalink URL)"),process.exit(2);let C;if(u.channelId)C=u.channelId;else C=await VD(D,B,u.cookie);let $=await Mu(D,C,E,1,u.cookie),Z=t($.messages).map(b).find((Y)=>String(Y.ts)===E);if(!Z)console.error(`Message not found at ts=${E} in channel ${C}`),process.exit(1);let J=typeof Z.text==="string"?Z.text:"",Q=await F(),G=dD(C,E,J,Q?.userId??"");if(u.code!==G){let Y=await c3(D,C,B,u.cookie);vD(u.code,G,["--- Deleting message -------------------------",yD(Q),` \u2192 ${Y} at ${Y2(E)}`,...J.split(`
|
|
154
|
+
`).map((V)=>` ${V}`),"---------------------------------------------"])}await E3(D,C,E,u.cookie),console.log(`\u2713 Deleted (ts: ${E})`)}async function k9(D,u){let{ref:F,ts:B}=kF(u.target);if(!B)console.error("Error: target must embed a message ts (e.g. #chan:2026-05-11T06:01:04.000100 or a Slack permalink URL)"),process.exit(2);let E=u.emoji.replace(/^:|:$/g,""),C;if(u.channelId)C=u.channelId;else C=await VD(D,F,u.cookie);if(u.remove)await C3(D,C,B,E,u.cookie),console.log(`\u2713 Removed :${E}: (ts: ${B})`);else await B3(D,C,B,E,u.cookie),console.log(`\u2713 Reacted :${E}: (ts: ${B})`)}async function i9(D,u,F,B){if(!F||!u.startsWith("D"))return!1;try{let E=b(await hF(D,u,B)),C=b(E.channel);return C.is_im===!0&&C.user===F}catch{return!1}}async function l9(D,u){let{ref:F,threadTs:B}=H2(u.target),E=u.cookie,C=FF(D,E),$;if(u.channelId)$=u.channelId;else if(u.userId)$=await nu(D,u.userId,E);else $=await VD(D,F,E);if(!u.asBot&&await i9(D,$,(await C())?.userId,E))console.error(`Warning: "${u.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
|
|
155
|
+
`+` To reach yourself with a notification, send as the bot: slack send '${u.target}' '...' --as-bot`);let z=u.message,Z=null;if(u.mentions){Z=await z2(u.mentionToken??D,u.message,$,u.mentionCookie),z=Z.text;for(let M of Z2(Z.unresolved))console.error(`\u26A0 ${cD(M)}`)}try{for(let M of await P3(u.mentionToken??D,z,u.mentionCookie))console.error(`\u26A0 possible untagged mention: ${cD(M.surface)} \u2014 @${cD(M.display)} won't be notified (did you mean <@${M.userId}>?)`)}catch{}let J=[];if(Z&&(Z.resolved.length>0||Z.unresolved.length>0)){J.push("--- Mentions ---------------------------------");for(let M of Z.resolved)J.push(` \u2713 ${cD(M.surface)} \u2192 @${cD(M.display)} (${M.userId}) \u2014 will notify`);for(let M of Z.unresolved){let T=M.reason==="ambiguous"?"ambiguous":M.reason==="unavailable"?"lookup unavailable":"no match";J.push(` \u26A0 ${cD(M.surface)} \u2014 plain text, NOT notified (${T})`)}}let Q="",G="?",Y=[],V,H,W;if(B)try{let M=await Mu(D,$,B,100,E);Y=t(M.messages).map(b);let T=Y[Y.length-1];Q=typeof T?.text==="string"?T.text:"",V=typeof T?.user==="string"?T.user:void 0,H=typeof T?.bot_id==="string"?T.bot_id:void 0,W=typeof T?.ts==="string"?T.ts:void 0}catch{}else try{let M=await lu(D,$,1,void 0,void 0,E),T=t(M.messages).map(b),h=T.filter(($D)=>$D.subtype===void 0||$D.subtype===null)[0];Q=typeof h?.text==="string"?h.text:"",G=typeof h?.user==="string"?await su(D,h.user,E):typeof h?.username==="string"?h.username:"?";let p=T[0];V=typeof p?.user==="string"?p.user:void 0,H=typeof p?.bot_id==="string"?p.bot_id:void 0,W=typeof p?.ts==="string"?p.ts:void 0}catch{}if(process.env.SLACK_UNREPLIED_WARN!=="0"&&W&&(V||H))try{let M=await C();if(!!M&&(!!V&&!!M.userId&&M.userId===V||!!H&&!!M.botId&&M.botId===H)){let h=`slack edit "#${$}:${W}" "<\u65B0\u3057\u3044\u672C\u6587>" --channel-id ${$}`;try{let p=await t0(D,$,W,E);if(p)h=`slack edit "${p}" "<\u65B0\u3057\u3044\u672C\u6587>"`}catch{}console.error("\u26A0 \u76F8\u624B\u306F\u307E\u3060\u8FD4\u4FE1\u3057\u3066\u3044\u307E\u305B\u3093(\u6700\u5F8C\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u306F\u3042\u306A\u305F\u306E\u3082\u306E\u3067\u3059)\u3002"),console.error(" \u9023\u6295\u3092\u907F\u3051\u308B\u305F\u3081\u3001\u65B0\u898F\u9001\u4FE1\u3067\u306A\u304F\u76F4\u524D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u306E edit \u3092\u691C\u8A0E\u3057\u3066\u304F\u3060\u3055\u3044:"),console.error(` ${h}`),console.error(" \u3053\u306E\u307E\u307E\u9001\u4FE1\u3059\u308B\u5834\u5408\u306F --code=XXXX \u3067\u78BA\u5B9A\u3002")}}catch{}if(B&&Y.length){let M={sim:0,msg:null};for(let T of Y){let h=typeof T.text==="string"?T.text:"";if(!h)continue;let p=g9(z,h);if(p>M.sim)M={sim:p,msg:T}}if(M.msg&&M.sim>=0.82){let T=Math.round(M.sim*100);console.error(`\u26A0 possible duplicate: ${T}% similar to an existing thread message \u2014 ${await Q2(D,M.msg,60,E)}`)}}let K=await C(),N=dD($,B??"",Q,z,K?.userId??"");if(u.code!==N){let M=await c3(D,$,F,E),T=yD(K,{asBot:u.asBot});if(B){let h=await m9(D,B,Y,E),p=Y.slice(-3),$D=p.length?await Promise.all(p.map(async(l)=>` ${await Q2(D,l,60,E)}`)):[" (thread context unavailable)"];vD(u.code,N,["--- Recent messages in thread ----------------",...$D,...J,"--- Sending ----------------------------------",T,` \u2192 ${M} thread of ${h} \u2014 THREAD REPLY`,` Message: ${z}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}else vD(u.code,N,["--- Last message in channel ------------------",` ${G}: ${Q.split(`
|
|
156
|
+
`)[0]?.slice(0,100)??"(empty)"}`,...J,"--- Sending ----------------------------------",T,` \u2192 ${M} \u2014 NEW top-level message`,` Message: ${z}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}let j=await a1(D,$,z,B,u.broadcast,E),L="";try{L=await t0(D,$,j,E)}catch{}if(L)console.log(`\u2713 Sent: ${L}`);else console.log(`\u2713 Sent (ts: ${j})`);if(u.asBot&&$.startsWith("D"))try{let M=await f0(D);if(!M.ok)for(let T of h0(M,!0))console.error(T);else{let T=M.appId?`https://api.slack.com/apps/${M.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${u.target} can't reply (app messaging may be off), enable Messages Tab: ${T} \u2192 App Home.`)}}catch{}}async function n9(D){let u=await f0(D);for(let F of h0(u,!1))console.log(F);if(!u.ok)process.exit(1)}function t9(D){if(/^\d{10,}$/.test(D))return parseInt(D,10);let u=new Date(D.replace(" ","T"));if(isNaN(u.getTime()))throw Error(`Cannot parse time: ${D}`);return Math.floor(u.getTime()/1000)}function o9(D){let u=new Date(D*1000);return`${new Intl.DateTimeFormat("sv-SE",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZoneName:"short"}).format(u).replace(/\u2212/g,"-")} (local) / ${u.toISOString()} (Unix: ${D})`}async function s9(D,u){let F=FF(D,u.cookie),{ref:B,threadTs:E}=H2(u.target),C;if(u.channelId)C=u.channelId;else if(u.userId)C=await nu(D,u.userId,u.cookie);else C=await VD(D,B,u.cookie);let $=t9(u.at),z=new Date($*1000).toISOString(),Z=await F(),J=dD(C,u.message,String($),Z?.userId??"");if(u.code!==J)vD(u.code,J,["--- Scheduling message -----------------------",yD(Z,{pad:9}),` To: ${B}${E?` (thread ${E})`:""}`,` At: ${o9($)}`,` Message: ${u.message}`,"---------------------------------------------"]);let Q=await e1(D,C,u.message,$,E,u.cookie);console.log(`\u2713 Scheduled (id: ${Q}, at: ${z})`)}async function r9(D,u,F,B){let E;if(F)E=F;else if(u)E=await VD(D,u,B);let $=(await D3(D,E,B)).scheduled_messages??[];if($.length===0){console.log("(no scheduled messages)");return}for(let z of $){let Z=new Date(z.post_at*1000).toISOString();console.log(`${z.id} ${Z} [${z.channel_id}] ${z.text.split(`
|
|
157
|
+
`)[0]?.slice(0,80)??""}`)}}async function a9(D,u){let F;if(u.channelId)F=u.channelId;else F=await VD(D,u.target,u.cookie);let B=await bu(D,u.cookie),E=dD(F,u.id,B?.userId??"");if(u.code!==E)vD(u.code,E,["--- Deleting scheduled message ---------------",yD(B,{pad:9}),` Channel: ${u.target}`,` ID: ${u.id}`,"---------------------------------------------"]);await u3(D,F,u.id,u.cookie),console.log(`\u2713 Deleted scheduled message ${u.id}`)}async function e9(D,u){let F=FF(D,u.cookie),{statSync:B,existsSync:E}=await import("fs"),{basename:C}=await import("path");for(let H of u.filePaths)if(!E(H))console.error(`Error: file not found: ${H}`),process.exit(1);let{ref:$,threadTs:z}=H2(u.target),Z;if(u.channelId)Z=u.channelId;else if(u.userId)Z=await nu(D,u.userId,u.cookie);else Z=await VD(D,$,u.cookie);let J=u.filePaths.length>1,Q=u.filePaths.map((H)=>{let W=C(H),K=J?W:u.title??W;return{fp:H,filename:W,title:K,sizeFmt:dF(B(H).size)}}),G=await F(),Y=dD(Z,...Q.flatMap((H)=>[H.fp,H.title]),G?.userId??"");if(u.code!==Y){let H=` To: ${$}${z?` (thread ${z})`:""}`,W=J?[`--- Uploading ${Q.length} files ------------------------`,yD(G,{pad:7}),H,...Q.map((K)=>` ${K.filename} (${K.sizeFmt})`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]:["--- Uploading file ---------------------------",yD(G,{pad:7}),H,` File: ${Q[0].fp}`,` Title: ${Q[0].title}`,` Size: ${Q[0].sizeFmt}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];vD(u.code,Y,W)}let V=Q.length;for(let H=0;H<V;H++){let W=Q[H],K={title:W.title};if(z!==void 0)K.threadTs=z;if(u.comment!==void 0&&H===0)K.initialComment=u.comment;let{fileId:N,permalink:j}=await Q3(D,Z,W.fp,K,u.cookie),L=V>1?`[${H+1}/${V}] `:"";console.log(`${L}\u2713 Uploaded (file_id: ${N}${j?`, url: ${j}`:""})`)}}async function DE(D,u,F){let B=F.channel?await VD(D,F.channel,u):void 0,E=[],C=1,$=1;do{let Z={page:C,count:200};if(F.types)Z.types=F.types;if(B)Z.channel=B;if(F.user)Z.user=F.user;let J=b(await t1(D,Z,u));for(let Q of t(J.files))E.push(b(Q));$=Number(b(J.paging).pages??1),C++}while(E.length<F.limit&&C<=$);let z=E.slice(0,F.limit);if(F.format==="jsonl"){for(let Z of z)console.log(JSON.stringify({id:Z.id??null,name:Z.name??Z.title??null,filetype:Z.filetype??null,size:Z.size??null,user:Z.user??null,created:Z.created??null,permalink:Z.permalink??null}));return}for(let Z of z){let J=String(Z.id??""),Q=typeof Z.name==="string"?Z.name:typeof Z.title==="string"?Z.title:J,G=typeof Z.filetype==="string"?Z.filetype:"?",Y=typeof Z.size==="number"?dF(Z.size):"";console.log(`${J} ${G.padEnd(7)} ${Y.padStart(9)} ${Q}`)}}function uE(D){if(/^F[A-Z0-9]+$/i.test(D))return D;return D.match(/\/lists\/[A-Za-z0-9]+\/(F[A-Za-z0-9]+)/i)?.[1]??D.match(/\/lists\/(F[A-Za-z0-9]+)/i)?.[1]}function FE(D){if(typeof D.text==="string"&&D.text)return D.text;let u=D.value;if(typeof u==="string"||typeof u==="number"||typeof u==="boolean")return String(u);if(Array.isArray(u))return u.map((F)=>typeof F==="string"?F:String(b(F).text??b(F).name??b(F).value??"")).filter(Boolean).join(", ");for(let F of["rich_text","select","user","date","number","checkbox","email","phone"]){let B=D[F];if(B!=null)return typeof B==="object"?JSON.stringify(B):String(B)}return""}async function EE(D,u,F,B){let E=uE(F);if(!E)throw Error(`Not a list ID or list URL: ${F}
|
|
158
|
+
`+"Expected F\u2026 or https://<ws>.slack.com/lists/<TEAM>/<F-id>");let C=[],$;do{let Z={limit:200};if($)Z.cursor=$;let J=b(await o1(D,E,Z,u));for(let G of t(J.items??J.records))C.push(b(G));let Q=b(J.response_metadata).next_cursor;$=typeof Q==="string"&&Q?Q:void 0}while($&&C.length<B.limit);let z=C.slice(0,B.limit);if(B.format==="jsonl"){for(let Z of z)console.log(JSON.stringify(Z));return}for(let Z of z){let J=String(Z.id??""),Q=t(Z.fields).map(b).map((G)=>{let Y=String(G.key??G.column_id??"?"),V=FE(G);return V?`${Y}=${V}`:""}).filter(Boolean);console.log(`${J} ${Q.join(" | ")}`)}}function BE(D){if(/^F[A-Z0-9]+$/i.test(D))return D;return D.match(/\/files\/[A-Za-z0-9]+\/(F[A-Za-z0-9]+)/)?.[1]}async function CE(D,u,F,B){let E=BE(F);if(!E)throw Error(`Not a file ID or file permalink: ${F}
|
|
159
|
+
`+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let C=b(await n1(D,E,u)),$=b(C.file),z=typeof $.name==="string"?$.name:typeof $.title==="string"?$.title:E,Z=typeof $.url_private_download==="string"?$.url_private_download:typeof $.url_private==="string"?$.url_private:"";if(!Z)throw Error(`files.info returned no download URL for ${E}`);let J={Authorization:`Bearer ${D}`};if(u)J.Cookie=`d=${u}`;let Q=await fetch(Z,{headers:J});if(!Q.ok)throw Error(`Download failed: HTTP ${Q.status} ${Q.statusText}`);let G=Buffer.from(await Q.arrayBuffer()),{statSync:Y,existsSync:V}=await import("fs"),{basename:H}=await import("path"),W=B??z;if(B&&V(B)&&Y(B).isDirectory())W=eD(B,H(z));h3(W,G),console.log(`\u2713 Downloaded ${z} (${dF(G.length)}) \u2192 ${W}`)}async function $E(){U9();let D=(E)=>R0(E.workspace),u=(E)=>C1(E.workspace),F={state:{type:"string",choices:["open","untriaged","pending","doing","done","dropped","stuck"],default:"open",describe:"open (default) = marked and not done/dropped; untriaged = marked with no progress; stuck = unfinished with a reason flag"},in:{type:"string",describe:"Limit to a channel (#chan)"},from:{type:"string",describe:"Limit to a sender (@user, or 'me') \u2014 usually the person a task is waiting on"},n:{alias:"count",type:"number",default:50,describe:"Max results"},json:{type:"boolean",default:!1}},B=async(E,C)=>{let $={state:E.state??"open",mine:C||E.mine===!0,count:E.n??50,json:E.json===!0};if(E.in)$.in=E.in;if(E.from)$.from=E.from;let z=u(E);if(z)$.cookie=z;await w9(D(E),$)};await a8(C0(process.argv)).scriptName("slack").showHelpOnFail(!1).fail((E,C,$)=>{if(C)console.error(C.message),process.exit(1);console.error(E),console.error(""),$.showHelp(),process.exit(1)}).option("workspace",{alias:"w",type:"string",describe:"Workspace name"}).middleware(async(E)=>{let C=String((E._??[])[0]??"");if(!C||C==="auth"||C==="login")return;try{R0(E.workspace)}catch($){if(($ instanceof Error?$.message:String($)).startsWith("No profiles configured"))console.log(`No workspace configured. Let's set that up:
|
|
160
|
+
`),await xF(),process.exit(0);throw $}},!0).command(["read [target]","msgs [target]"],"Browse messages",(E)=>E.positional("target",{type:"string",describe:"#channel, @user, or URL"}).option("limit",{alias:"n",type:"number",default:20,describe:"Number of messages"}).option("format",{type:"string",choices:["text","jsonl"],default:"text",describe:"jsonl exposes raw ts/user/text (incl. external-guest user IDs)"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}).option("unreplied",{type:"boolean",default:!1,describe:"Only messages whose last word (incl. thread replies) is not yours \u2014 i.e. awaiting your answer"}),async(E)=>{let C=D(E),$=E.json?"jsonl":E.format;if(E.target)await A9(C,E.target,E.limit,$,E.unreplied,u(E));else await T9(C)}).command("thread <target> <ts>","Show thread messages",(E)=>E.positional("target",{type:"string",demandOption:!0}).positional("ts",{type:"string",demandOption:!0}).option("limit",{alias:"n",type:"number",default:100}).option("format",{type:"string",choices:["text","jsonl"],default:"text",describe:"jsonl exposes raw ts/user/text (incl. external-guest user IDs)"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(E)=>{let C=E.json?"jsonl":E.format;await L9(D(E),E.target,E.ts,E.limit,C,u(E))}).command(["channel","channels","ch"],"Channel commands",(E)=>E.command(["ls","list"],"List channels",(C)=>C.option("limit",{alias:"n",type:"number",default:200}).option("filter",{alias:"f",type:"string"}).option("all",{type:"boolean",default:!1}).option("format",{type:"string",choices:["text","jsonl"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(C)=>{await P9(D(C),C.limit,C.filter,C.all,C.json?"jsonl":C.format)}).command("get <channel>","Show channel details",(C)=>C.positional("channel",{type:"string",demandOption:!0,describe:"#name or channel ID"}),async(C)=>{let $=D(C),z=u(C),Z=C.channel,J=Z.startsWith("#")||Z.startsWith("@")||Z.startsWith("C")||Z.startsWith("G")||Z.startsWith("D")?Z:`#${Z}`,Q=await VD($,J,z),G=b(await hF($,Q,z)),Y=b(G.channel),V=typeof Y.name==="string"?Y.name:Q,W=Y.is_im===!0?"@":"#",K=String(b(Y.purpose).value??""),N=String(b(Y.topic).value??""),j=Y.num_members??Y.member_count??"";if(console.log(`${W}${V} ${Q}`),N)console.log(`topic: ${N}`);if(K)console.log(`purpose: ${K}`);if(j)console.log(`members: ${j}`);console.log(`private: ${Y.is_private===!0}`)}).command(["create <name>","new <name>"],"Create a channel (confirm-hash safety gate)",(C)=>C.positional("name",{type:"string",demandOption:!0,describe:"Channel name (Slack lowercases it; no spaces)"}).option("private",{type:"boolean",default:!1,describe:"Create a private channel"}).option("invite",{type:"string",array:!0,default:[],describe:"Users to invite after creating (@handle or Uxxxx, repeatable)"}).option("code",{type:"string",describe:"Safety hash to confirm create"}),async(C)=>{let $=D(C),z=u(C),Z=C.name.replace(/^#/,"").toLowerCase(),J=C.private===!0,Q=C.invite.filter(Boolean),G=await bu($,z),Y=dD(Z,String(J),Q.join(","),G?.userId??"");if(C.code!==Y)vD(C.code,Y,["--- Creating channel -------------------------",yD(G,{pad:9}),` name: ${J?"\uD83D\uDD12 ":"#"}${Z}`,` private: ${J}`,...Q.length?[` invite: ${Q.join(", ")}`]:[],"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let V;try{V=await $3($,Z,J,z)}catch(H){console.error(H instanceof Error?H.message:String(H)),process.exit(1)}if(console.log(`\u2713 Created ${J?"\uD83D\uDD12 ":"#"}${V.name} (${V.id})`),Q.length){let H=[];for(let W of Q)try{H.push(W.startsWith("U")||W.startsWith("W")?W:await o0($,W,z))}catch(K){console.error(` ! could not resolve ${W}: ${K instanceof Error?K.message:String(K)}`)}for(let W of H)try{let K=b(await r0($,W,z)),N=b(K.user);if(N.is_ultra_restricted===!0)console.error(`\u26A0 ${W} is a single-channel guest \u2014 Slack restricts them to their one existing channel; this invite will likely report success but not actually add them.`);else if(N.is_restricted===!0)console.error(`\u26A0 ${W} is a multi-channel guest \u2014 double-check they were actually added (guest invites can silently no-op depending on workspace restrictions).`)}catch{}if(H.length)try{await z3($,V.id,H,z),console.log(`\u2713 Invited ${H.length} member${H.length===1?"":"s"}`)}catch(W){console.error(` ! invite failed: ${W instanceof Error?W.message:String(W)}`)}}}).demandCommand(1,"").showHelpOnFail(!0)).command(["user","usr"],"User commands",(E)=>E.command(["ls","list"],"List workspace members",(C)=>C.option("limit",{alias:"n",type:"number",default:200}).option("filter",{alias:"f",type:"string"}).option("format",{type:"string",choices:["text","jsonl","yaml"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(C)=>{let $=C.json?"jsonl":C.format,z=await s0(D(C)),Z=C.filter?.toLowerCase(),J=t(z.members).map(b).filter((G)=>G.deleted!==!0&&G.is_bot!==!0&&String(G.id)!=="USLACKBOT").filter((G)=>{if(!Z)return!0;let Y=String(G.name??"").toLowerCase(),V=String(b(G.profile).real_name??"").toLowerCase(),H=String(b(G.profile).email??"").toLowerCase();return Y.includes(Z)||V.includes(Z)||H.includes(Z)}).slice(0,C.limit);if($==="jsonl"){for(let G of J)console.log(JSON.stringify(G));return}if($==="yaml"){for(let G of J){let Y=function(V,H=""){if(V===null)return"null";if(typeof V==="string")return V.includes(`
|
|
161
161
|
`)?`|
|
|
162
162
|
${V.split(`
|
|
163
163
|
`).join(`
|
|
164
164
|
`)}`:V;if(typeof V!=="object")return String(V);if(Array.isArray(V))return V.map((W)=>`
|
|
165
165
|
${H} - ${Y(W,H+" ")}`).join("");return Object.entries(V).map(([W,K])=>`
|
|
166
|
-
${H} ${W}: ${Y(K,H+" ")}`).join("")};console.log("---");for(let[V,H]of Object.entries(G))console.log(`${V}: ${Y(H)}`)}return}let Q=Intl.DateTimeFormat().resolvedOptions().timeZone;for(let G of J){let Y=
|
|
166
|
+
${H} ${W}: ${Y(K,H+" ")}`).join("")};console.log("---");for(let[V,H]of Object.entries(G))console.log(`${V}: ${Y(H)}`)}return}let Q=Intl.DateTimeFormat().resolvedOptions().timeZone;for(let G of J){let Y=b(G.profile),V=String(G.name??G.id),H=String(G.id??""),W=String(Y.display_name||""),K=String(Y.real_name||""),N=String(Y.email||""),j=String(G.tz??""),M=[...new Set([W,K].filter((p)=>p&&p!==V))].join(" / "),h=[N,j&&j!==Q?j:""].filter(Boolean).join(" ");console.log(`@${V} ${H} ${M}${h?" "+h:""}`)}}).command("get <user>","Show user details",(C)=>C.positional("user",{type:"string",demandOption:!0,describe:"@handle or user ID"}),async(C)=>{let $=D(C),z=C.user.startsWith("@")?C.user.slice(1):C.user,Z=z;if(!/^U[A-Z0-9]+$/.test(z)){let h=await s0($),p=t(h.members).map(b).find(($D)=>String($D.name??"")===z);if(!p)console.error(`User not found: @${z}`),process.exit(1);Z=String(p.id)}let J=b(await r0($,Z)),Q=b(J.user),G=b(Q.profile),Y=Intl.DateTimeFormat().resolvedOptions().timeZone,V=String(Q.name??Z),H=String(Q.id??Z),W=String(G.display_name||""),K=String(G.real_name||""),N=String(G.email||""),j=String(Q.tz??""),L=String(G.phone||""),M=String(G.title||"");console.log(`@${V} ${H}`);let T=[...new Set([W,K].filter((h)=>h&&h!==V))];if(T.length)console.log(`name: ${T.join(" / ")}`);if(N)console.log(`email: ${N}`);if(L)console.log(`phone: ${L}`);if(M)console.log(`title: ${M}`);if(j&&j!==Y)console.log(`tz: ${j}`)}).demandCommand(1,"").showHelpOnFail(!0)).command("news","Activity feed (mentions to you)",(E)=>E.option("limit",{alias:"l",type:"number",default:20}),async(E)=>{await R9(D(E),E.limit)}).command("search <query>","Full-text search",(E)=>E.positional("query",{type:"string",demandOption:!0}).option("count",{alias:"n",type:"number",default:100}).option("json",{type:"boolean",default:!1,describe:"Output raw JSON"}),async(E)=>{await p3(D(E),E.query,E.count,E.json,u(E))}).command("send <target> <message>","Send a message (confirm-hash safety gate)",(E)=>E.positional("target",{type:"string",demandOption:!0,describe:"#chan, @user, #chan:thread_ts, or permalink (a message permalink replies in its thread)"}).positional("message",{type:"string",demandOption:!0}).option("code",{type:"string",describe:"Safety hash to confirm send"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("user-id",{type:"string",describe:"Raw user ID (opens DM)"}).option("as-bot",{type:"boolean",default:!1,describe:"Send via the bot token (xoxb / SLACK_BOT_TOKEN) so a DM notifies the recipient and can be two-way"}).option("broadcast",{type:"boolean",default:!1,describe:`Also send to channel: broadcast a threaded reply back to the channel (Slack's "Also send to #channel" checkbox). Only effective with a thread target.`}).option("mentions",{type:"boolean",default:!0,describe:"Convert @handle tokens to real <@USERID> mentions (on by default; resolves via users.list, then channel members for Slack Connect guests). Unresolved handles stay as plain text. The confirm preview shows the converted message before sending. Disable with --no-mentions for literal @text."}),async(E)=>{let C={target:E.target,message:E.message};if(E.code)C.code=E.code;if(E["channel-id"])C.channelId=E["channel-id"];if(E["user-id"])C.userId=E["user-id"];if(E.broadcast)C.broadcast=!0;if(E.mentions!==!1){C.mentions=!0,C.mentionToken=D(E);let z=u(E);if(z)C.mentionCookie=z}let $;if(E["as-bot"]){let z=P0();if(!z)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
|
|
167
167
|
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);if(!C.channelId&&!C.userId&&C.target.startsWith("@"))try{C.userId=await o0(D(E),C.target,u(E))}catch(Z){console.error(`Error: could not resolve ${C.target} to a user for the bot DM.
|
|
168
168
|
${Z instanceof Error?Z.message:String(Z)}
|
|
169
|
-
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}$=z,C.asBot=!0}else{$=D(E);let z=u(E);if(z)C.cookie=z}try{await l9($,C)}catch(z){console.error(uF(z)),process.exit(1)}}).command("doctor","Check the bot token (xoxb) can carry a two-way DM (scopes + Messages Tab)",(E)=>E,async()=>{let E=
|
|
170
|
-
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await n9(E)}).command("schedule","Manage scheduled messages",(E)=>E.command("send <target> <message>","Schedule a message for later delivery",(C)=>C.positional("target",{type:"string",demandOption:!0,describe:"#chan, @user, #chan:thread_ts, or permalink (a message permalink replies in its thread)"}).positional("message",{type:"string",demandOption:!0}).option("at",{type:"string",demandOption:!0,describe:"Delivery time (ISO datetime or Unix ts)"}).option("code",{type:"string",describe:"Safety hash to confirm"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("user-id",{type:"string",describe:"Raw user ID (opens DM)"}),async(C)=>{let $={target:C.target,message:C.message,at:C.at};if(C.code)$.code=C.code;if(C["channel-id"])$.channelId=C["channel-id"];if(C["user-id"])$.userId=C["user-id"];let z=u(C);if(z)$.cookie=z;await s9(D(C),$)}).command(["ls","list"],"List pending scheduled messages",(C)=>C.positional("target",{type:"string",describe:"#channel to filter by"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(C)=>{await r9(D(C),C.target,C["channel-id"],u(C))}).command("rm <target> <id>","Delete a scheduled message",(C)=>C.positional("target",{type:"string",demandOption:!0,describe:"#channel or @user"}).positional("id",{type:"string",demandOption:!0,describe:"Scheduled message ID"}).option("code",{type:"string",describe:"Safety hash to confirm"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(C)=>{let $={target:C.target,id:C.id};if(C.code)$.code=C.code;let z=u(C);if(z)$.cookie=z;if(C["channel-id"])$.channelId=C["channel-id"];await a9(D(C),$)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("edit <target> <newText>","Edit a sent message",(E)=>E.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).positional("newText",{type:"string",demandOption:!0}).option("code",{type:"string",describe:"Safety hash to confirm edit"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("mentions",{type:"boolean",default:!0,describe:"Convert @handle tokens in the new text to real <@USERID> mentions (on by default). Unresolved handles stay as plain text. Disable with --no-mentions for literal @text."}),async(E)=>{let C={target:E.target,newText:E.newText};if(E.code)C.code=E.code;if(E["channel-id"])C.channelId=E["channel-id"];if(E.mentions!==!1)C.mentions=!0;let $=u(E);if($)C.cookie=$;await c9(D(E),C)}).command("delete <target>","Delete a sent message (confirm-hash safety gate)",(E)=>E.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).option("code",{type:"string",describe:"Safety hash to confirm delete"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(E)=>{let C={target:E.target};if(E.code)C.code=E.code;if(E["channel-id"])C.channelId=E["channel-id"];let $=u(E);if($)C.cookie=$;await d9(D(E),C)}).command("react <target> <emoji>","Add (or --remove) an emoji reaction \u2014 a lightweight ack that doesn't grow the thread",(E)=>E.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).positional("emoji",{type:"string",demandOption:!0,describe:"Emoji shortcode without colons (e.g. eyes, white_check_mark, hourglass)"}).option("remove",{type:"boolean",default:!1,describe:"Remove the reaction instead of adding it"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(E)=>{let C={target:E.target,emoji:E.emoji};if(E.remove)C.remove=!0;if(E["channel-id"])C.channelId=E["channel-id"];let $=u(E);if($)C.cookie=$;try{await k9(D(E),C)}catch(z){console.error(uF(z)),process.exit(1)}}).command("todo","Reaction-backed task tracking (:pushpin: marks a task, progress lives in a second reaction)",(E)=>E.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((C)=>{if(C.cache===!1)$2(!1)}).command(["ls","list"],"List everyone's tasks (has: \u2014 read-only, one search per run)",(C)=>C.options(F).option("mine",{type:"boolean",default:!1,describe:"Only your own reactions (hasmy:) \u2014 same as `slack mytodo ls`"}).option("shared",{type:"boolean",default:!1,hidden:!0,describe:"Deprecated \u2014 anyone's reactions is the default for `todo ls`"}),async(C)=>{await B(C,!1)}).command("set <target> <state>","Move a task to a progress state (adds the new reaction before removing the old one)",(C)=>C.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts or permalink"}).positional("state",{type:"string",demandOption:!0,choices:["pending","doing","done","dropped"]}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(C)=>{let $={target:C.target,state:C.state};if(C["channel-id"])$.channelId=C["channel-id"];let z=u(C);if(z)$.cookie=z;try{await x9(D(C),$)}catch(Z){console.error(uF(Z)),process.exit(1)}}).command("flag <target> <flag>","Add (or --remove) a reason flag (alert | needs-discussion | waiting | blocked) \u2014 flags stack, independent of progress",(C)=>C.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts or permalink"}).positional("flag",{type:"string",demandOption:!0,choices:["alert","needs-discussion","waiting","blocked"],describe:"waiting = the other party in this conversation owes a reply; blocked = stuck on something outside it"}).option("remove",{type:"boolean",default:!1,describe:"Remove the flag instead of adding it"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(C)=>{let $={target:C.target,flag:C.flag};if(C.remove)$.remove=!0;if(C["channel-id"])$.channelId=C["channel-id"];let z=u(C);if(z)$.cookie=z;try{await I9(D(C),$)}catch(Z){console.error(uF(Z)),process.exit(1)}}).command("doctor","Find messages carrying two or more progress reactions (--fix repairs them)",(C)=>C.option("in",{type:"string",demandOption:!0,describe:"Channel to scan (#chan)"}).option("fix",{type:"boolean",default:!1,describe:"Repair findings (keeps the highest-priority state)"}).option("limit",{type:"number",default:C2,describe:"Max messages to scan"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(C)=>{let $={channel:C.in,limit:C.limit};if(C.fix)$.fix=!0;if(C["channel-id"])$.channelId=C["channel-id"];let z=u(C);if(z)$.cookie=z;await b9(D(C),$)}).demandCommand(1,"Specify a todo subcommand (ls, set, flag, doctor)"),()=>{}).command("mytodo","Tasks carrying YOUR reactions (hasmy:) \u2014 the my-only half of `todo`",(E)=>E.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((C)=>{if(C.cache===!1)$2(!1)}).command(["ls","list"],"List tasks you have reacted to (hasmy: \u2014 read-only, one search per run)",(C)=>C.options(F),async(C)=>{await B(C,!0)}).demandCommand(1,"Specify a mytodo subcommand (ls)"),()=>{}).command("upload <target> <file..>","Upload one or more files to a channel or DM",(E)=>E.positional("target",{type:"string",demandOption:!0,describe:"#chan, @user, #chan:thread_ts, or permalink (a message permalink replies in its thread)"}).positional("file",{type:"string",array:!0,demandOption:!0,describe:"Path(s) to file(s)"}).option("title",{type:"string",describe:"Title (single file only)"}).option("comment",{type:"string",describe:"Initial comment (first file)"}).option("code",{type:"string",describe:"4-hex safety code to confirm upload"}).option("channel-id",{type:"string"}).option("user-id",{type:"string"}),async(E)=>{let C={target:E.target,filePaths:E.file};if(E.title)C.title=E.title;if(E.comment)C.comment=E.comment;if(E.code)C.code=E.code;if(E["channel-id"])C.channelId=E["channel-id"];if(E["user-id"])C.userId=E["user-id"];let $=u(E);if($)C.cookie=$;await e9(D(E),C)}).command("files","File commands",(E)=>E.command(["ls","list"],"List files visible to you (files.list)",(C)=>C.option("limit",{alias:"l",type:"number",default:100,describe:"Max files to list"}).option("type",{alias:"t",type:"string",describe:"Slack type filter: images, pdfs, gdocs, snippets, zips, spaces, all"}).option("channel",{alias:"c",type:"string",describe:"Only files in this channel (#name, @user, ID, or permalink)"}).option("user",{alias:"u",type:"string",describe:"Only files from this raw user ID"}).option("format",{type:"string",choices:["text","jsonl"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(C)=>{let $={limit:C.limit,format:C.json?"jsonl":C.format};if(C.type)$.types=C.type;if(C.channel)$.channel=C.channel;if(C.user)$.user=C.user;await DE(D(C),u(C),$)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("lists <ref>","Read a Slack List's rows (by list URL or F-id) \u2014 read-only",(E)=>E.positional("ref",{type:"string",demandOption:!0,describe:"List URL (\u2026/lists/<TEAM>/<F-id>) or bare F-id"}).option("limit",{alias:"l",type:"number",default:100,describe:"Max rows to show"}).option("format",{type:"string",choices:["text","jsonl"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl (raw records)"}),async(E)=>{let C=E.json?"jsonl":E.format;try{await EE(D(E),u(E),E.ref,{limit:E.limit,format:C})}catch($){console.error(uF($)),process.exit(1)}}).command("download <ref> [dest]","Download a file attachment (by file ID or file permalink) to disk",(E)=>E.positional("ref",{type:"string",demandOption:!0,describe:"File ID (F\u2026) or Slack file permalink"}).positional("dest",{type:"string",describe:"Output path or directory (default: ./<filename>)"}),async(E)=>{await CE(D(E),u(E),E.ref,E.dest)}).command("dump","Bulk export channel history as markdown",(E)=>E.option("days",{alias:"d",type:"number",default:7,describe:"Days of history"}).option("limit",{alias:"l",type:"number",default:200}).option("filter",{alias:"f",type:"string",describe:"Filter channel names"}),async(E)=>{await f9(D(E),E.days,E.limit,E.filter)}).command("drafts","Manage message drafts (requires xoxc desktop token)",(E)=>E.command(["$0","ls","list"],"List pending drafts",(C)=>C.option("all",{alias:"a",type:"boolean",default:!1,describe:"Include sent drafts"}),async(C)=>{await v9(D(C),u(C),C.all)}).command(["new <channel> [text..]","save <channel> [text..]"],"Create a draft",(C)=>C.positional("channel",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}),async(C)=>{let $=D(C),z=u(C),Z=C.text.join(" ");if(!Z)console.error("Usage: slack drafts new <#channel|@user> <text>"),process.exit(2);let J=await VD($,C.channel,z),Q=await Z3($,J,Z,z);console.log(`\u2713 Draft created (id: ${v(Q.draft).id??"?"})`)}).command("get <id>","Show a draft",(C)=>C.positional("id",{type:"string",demandOption:!0}),async(C)=>{await y9(D(C),u(C),C.id)}).command(["edit <id> [text..]","update <id> [text..]"],"Edit a draft",(C)=>C.positional("id",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}).option("code",{type:"string"}),async(C)=>{let $=D(C),z=u(C),Z=C.text.join(" ");if(!Z)console.error("Usage: slack drafts edit <id> <new-text>"),process.exit(2);let J=await ru($,z),Q=t(J.drafts).map(v).find((W)=>String(W.id)===C.id);if(!Q)console.error(`Draft not found: ${C.id}`),process.exit(1);let G=mF(Q),Y=await bu($,z),V=dD(G,Z,Y?.userId??"");if(C.code!==V)vD(C.code,V,["--- Editing draft as -------------------------",yD(Y),"--- Current draft ----------------------------",...G.split(`
|
|
169
|
+
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}$=z,C.asBot=!0}else{$=D(E);let z=u(E);if(z)C.cookie=z}try{await l9($,C)}catch(z){console.error(uF(z)),process.exit(1)}}).command("doctor","Check the bot token (xoxb) can carry a two-way DM (scopes + Messages Tab)",(E)=>E,async()=>{let E=P0();if(!E)console.error(`Error: slack doctor checks the bot token, but no xoxb- token was found.
|
|
170
|
+
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await n9(E)}).command("schedule","Manage scheduled messages",(E)=>E.command("send <target> <message>","Schedule a message for later delivery",(C)=>C.positional("target",{type:"string",demandOption:!0,describe:"#chan, @user, #chan:thread_ts, or permalink (a message permalink replies in its thread)"}).positional("message",{type:"string",demandOption:!0}).option("at",{type:"string",demandOption:!0,describe:"Delivery time (ISO datetime or Unix ts)"}).option("code",{type:"string",describe:"Safety hash to confirm"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("user-id",{type:"string",describe:"Raw user ID (opens DM)"}),async(C)=>{let $={target:C.target,message:C.message,at:C.at};if(C.code)$.code=C.code;if(C["channel-id"])$.channelId=C["channel-id"];if(C["user-id"])$.userId=C["user-id"];let z=u(C);if(z)$.cookie=z;await s9(D(C),$)}).command(["ls","list"],"List pending scheduled messages",(C)=>C.positional("target",{type:"string",describe:"#channel to filter by"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(C)=>{await r9(D(C),C.target,C["channel-id"],u(C))}).command("rm <target> <id>","Delete a scheduled message",(C)=>C.positional("target",{type:"string",demandOption:!0,describe:"#channel or @user"}).positional("id",{type:"string",demandOption:!0,describe:"Scheduled message ID"}).option("code",{type:"string",describe:"Safety hash to confirm"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(C)=>{let $={target:C.target,id:C.id};if(C.code)$.code=C.code;let z=u(C);if(z)$.cookie=z;if(C["channel-id"])$.channelId=C["channel-id"];await a9(D(C),$)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("edit <target> <newText>","Edit a sent message",(E)=>E.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).positional("newText",{type:"string",demandOption:!0}).option("code",{type:"string",describe:"Safety hash to confirm edit"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("mentions",{type:"boolean",default:!0,describe:"Convert @handle tokens in the new text to real <@USERID> mentions (on by default). Unresolved handles stay as plain text. Disable with --no-mentions for literal @text."}),async(E)=>{let C={target:E.target,newText:E.newText};if(E.code)C.code=E.code;if(E["channel-id"])C.channelId=E["channel-id"];if(E.mentions!==!1)C.mentions=!0;let $=u(E);if($)C.cookie=$;await c9(D(E),C)}).command("delete <target>","Delete a sent message (confirm-hash safety gate)",(E)=>E.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).option("code",{type:"string",describe:"Safety hash to confirm delete"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(E)=>{let C={target:E.target};if(E.code)C.code=E.code;if(E["channel-id"])C.channelId=E["channel-id"];let $=u(E);if($)C.cookie=$;await d9(D(E),C)}).command("react <target> <emoji>","Add (or --remove) an emoji reaction \u2014 a lightweight ack that doesn't grow the thread",(E)=>E.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).positional("emoji",{type:"string",demandOption:!0,describe:"Emoji shortcode without colons (e.g. eyes, white_check_mark, hourglass)"}).option("remove",{type:"boolean",default:!1,describe:"Remove the reaction instead of adding it"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(E)=>{let C={target:E.target,emoji:E.emoji};if(E.remove)C.remove=!0;if(E["channel-id"])C.channelId=E["channel-id"];let $=u(E);if($)C.cookie=$;try{await k9(D(E),C)}catch(z){console.error(uF(z)),process.exit(1)}}).command("todo","Reaction-backed task tracking (:pushpin: marks a task, progress lives in a second reaction)",(E)=>E.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((C)=>{if(C.cache===!1)C2(!1)}).command(["ls","list"],"List everyone's tasks (has: \u2014 read-only, one search per run)",(C)=>C.options(F).option("mine",{type:"boolean",default:!1,describe:"Only your own reactions (hasmy:) \u2014 same as `slack mytodo ls`"}).option("shared",{type:"boolean",default:!1,hidden:!0,describe:"Deprecated \u2014 anyone's reactions is the default for `todo ls`"}),async(C)=>{await B(C,!1)}).command("set <target> <state>","Move a task to a progress state (adds the new reaction before removing the old one)",(C)=>C.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts or permalink"}).positional("state",{type:"string",demandOption:!0,choices:["pending","doing","done","dropped"]}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(C)=>{let $={target:C.target,state:C.state};if(C["channel-id"])$.channelId=C["channel-id"];let z=u(C);if(z)$.cookie=z;try{await x9(D(C),$)}catch(Z){console.error(uF(Z)),process.exit(1)}}).command("flag <target> <flag>","Add (or --remove) a reason flag (alert | needs-discussion | waiting | blocked) \u2014 flags stack, independent of progress",(C)=>C.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts or permalink"}).positional("flag",{type:"string",demandOption:!0,choices:["alert","needs-discussion","waiting","blocked"],describe:"waiting = the other party in this conversation owes a reply; blocked = stuck on something outside it"}).option("remove",{type:"boolean",default:!1,describe:"Remove the flag instead of adding it"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(C)=>{let $={target:C.target,flag:C.flag};if(C.remove)$.remove=!0;if(C["channel-id"])$.channelId=C["channel-id"];let z=u(C);if(z)$.cookie=z;try{await I9(D(C),$)}catch(Z){console.error(uF(Z)),process.exit(1)}}).command("doctor","Find messages carrying two or more progress reactions (--fix repairs them)",(C)=>C.option("in",{type:"string",demandOption:!0,describe:"Channel to scan (#chan)"}).option("fix",{type:"boolean",default:!1,describe:"Repair findings (keeps the highest-priority state)"}).option("limit",{type:"number",default:B2,describe:"Max messages to scan"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(C)=>{let $={channel:C.in,limit:C.limit};if(C.fix)$.fix=!0;if(C["channel-id"])$.channelId=C["channel-id"];let z=u(C);if(z)$.cookie=z;await b9(D(C),$)}).demandCommand(1,"Specify a todo subcommand (ls, set, flag, doctor)"),()=>{}).command("mytodo","Tasks carrying YOUR reactions (hasmy:) \u2014 the my-only half of `todo`",(E)=>E.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((C)=>{if(C.cache===!1)C2(!1)}).command(["ls","list"],"List tasks you have reacted to (hasmy: \u2014 read-only, one search per run)",(C)=>C.options(F),async(C)=>{await B(C,!0)}).demandCommand(1,"Specify a mytodo subcommand (ls)"),()=>{}).command("upload <target> <file..>","Upload one or more files to a channel or DM",(E)=>E.positional("target",{type:"string",demandOption:!0,describe:"#chan, @user, #chan:thread_ts, or permalink (a message permalink replies in its thread)"}).positional("file",{type:"string",array:!0,demandOption:!0,describe:"Path(s) to file(s)"}).option("title",{type:"string",describe:"Title (single file only)"}).option("comment",{type:"string",describe:"Initial comment (first file)"}).option("code",{type:"string",describe:"4-hex safety code to confirm upload"}).option("channel-id",{type:"string"}).option("user-id",{type:"string"}),async(E)=>{let C={target:E.target,filePaths:E.file};if(E.title)C.title=E.title;if(E.comment)C.comment=E.comment;if(E.code)C.code=E.code;if(E["channel-id"])C.channelId=E["channel-id"];if(E["user-id"])C.userId=E["user-id"];let $=u(E);if($)C.cookie=$;await e9(D(E),C)}).command("files","File commands",(E)=>E.command(["ls","list"],"List files visible to you (files.list)",(C)=>C.option("limit",{alias:"l",type:"number",default:100,describe:"Max files to list"}).option("type",{alias:"t",type:"string",describe:"Slack type filter: images, pdfs, gdocs, snippets, zips, spaces, all"}).option("channel",{alias:"c",type:"string",describe:"Only files in this channel (#name, @user, ID, or permalink)"}).option("user",{alias:"u",type:"string",describe:"Only files from this raw user ID"}).option("format",{type:"string",choices:["text","jsonl"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(C)=>{let $={limit:C.limit,format:C.json?"jsonl":C.format};if(C.type)$.types=C.type;if(C.channel)$.channel=C.channel;if(C.user)$.user=C.user;await DE(D(C),u(C),$)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("lists <ref>","Read a Slack List's rows (by list URL or F-id) \u2014 read-only",(E)=>E.positional("ref",{type:"string",demandOption:!0,describe:"List URL (\u2026/lists/<TEAM>/<F-id>) or bare F-id"}).option("limit",{alias:"l",type:"number",default:100,describe:"Max rows to show"}).option("format",{type:"string",choices:["text","jsonl"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl (raw records)"}),async(E)=>{let C=E.json?"jsonl":E.format;try{await EE(D(E),u(E),E.ref,{limit:E.limit,format:C})}catch($){console.error(uF($)),process.exit(1)}}).command("download <ref> [dest]","Download a file attachment (by file ID or file permalink) to disk",(E)=>E.positional("ref",{type:"string",demandOption:!0,describe:"File ID (F\u2026) or Slack file permalink"}).positional("dest",{type:"string",describe:"Output path or directory (default: ./<filename>)"}),async(E)=>{await CE(D(E),u(E),E.ref,E.dest)}).command("dump","Bulk export channel history as markdown",(E)=>E.option("days",{alias:"d",type:"number",default:7,describe:"Days of history"}).option("limit",{alias:"l",type:"number",default:200}).option("filter",{alias:"f",type:"string",describe:"Filter channel names"}),async(E)=>{await f9(D(E),E.days,E.limit,E.filter)}).command("drafts","Manage message drafts (requires xoxc desktop token)",(E)=>E.command(["$0","ls","list"],"List pending drafts",(C)=>C.option("all",{alias:"a",type:"boolean",default:!1,describe:"Include sent drafts"}),async(C)=>{await v9(D(C),u(C),C.all)}).command(["new <channel> [text..]","save <channel> [text..]"],"Create a draft",(C)=>C.positional("channel",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}),async(C)=>{let $=D(C),z=u(C),Z=C.text.join(" ");if(!Z)console.error("Usage: slack drafts new <#channel|@user> <text>"),process.exit(2);let J=await VD($,C.channel,z),Q=await Z3($,J,Z,z);console.log(`\u2713 Draft created (id: ${b(Q.draft).id??"?"})`)}).command("get <id>","Show a draft",(C)=>C.positional("id",{type:"string",demandOption:!0}),async(C)=>{await y9(D(C),u(C),C.id)}).command(["edit <id> [text..]","update <id> [text..]"],"Edit a draft",(C)=>C.positional("id",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}).option("code",{type:"string"}),async(C)=>{let $=D(C),z=u(C),Z=C.text.join(" ");if(!Z)console.error("Usage: slack drafts edit <id> <new-text>"),process.exit(2);let J=await ru($,z),Q=t(J.drafts).map(b).find((W)=>String(W.id)===C.id);if(!Q)console.error(`Draft not found: ${C.id}`),process.exit(1);let G=gF(Q),Y=await bu($,z),V=dD(G,Z,Y?.userId??"");if(C.code!==V)vD(C.code,V,["--- Editing draft as -------------------------",yD(Y),"--- Current draft ----------------------------",...G.split(`
|
|
171
171
|
`).map((W)=>` ${W}`),"--- Replacing with ---------------------------",...Z.split(`
|
|
172
|
-
`).map((W)=>` ${W}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let H=await J3($,C.id,
|
|
173
|
-
`).map((V)=>` ${V}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await X3($,C.id,z),console.log(`\u2713 Draft deleted (id: ${C.id})`)})).command("auth","Authentication and workspace management",(E)=>E.command("token","Add a workspace \u2014 paste an existing xoxp-/xoxb- token",(C)=>C.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(C)=>{await
|
|
172
|
+
`).map((W)=>` ${W}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let H=await J3($,C.id,V2(Q),Z,z);console.log(`\u2713 Draft updated (id: ${b(H.draft).id??"?"})`)}).command(["delete <id>","rm <id>"],"Delete a draft",(C)=>C.positional("id",{type:"string",demandOption:!0}).option("code",{type:"string"}),async(C)=>{let $=D(C),z=u(C),Z=await ru($,z),J=t(Z.drafts).map(b).find((V)=>String(V.id)===C.id);if(!J)console.error(`Draft not found: ${C.id}`),process.exit(1);let Q=gF(J),G=await bu($,z),Y=dD(C.id,Q,G?.userId??"");if(C.code!==Y)vD(C.code,Y,["\u2500-- Deleting draft \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",yD(G),` id: ${C.id}`,...Q.split(`
|
|
173
|
+
`).map((V)=>` ${V}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await X3($,C.id,z),console.log(`\u2713 Draft deleted (id: ${C.id})`)})).command("auth","Authentication and workspace management",(E)=>E.command("token","Add a workspace \u2014 paste an existing xoxp-/xoxb- token",(C)=>C.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(C)=>{await f1({...C.token!==void 0?{token:C.token}:{},...C.name!==void 0?{name:C.name}:{}})}).command("app","Create a new Slack app and obtain a token (guided wizard)",(C)=>C.option("bot",{type:"boolean",describe:"Create a bot token (xoxb-) instead of user (xoxp-)"}),async(C)=>{await h1({...C.bot!==void 0?{bot:C.bot}:{}})}).command("login","Interactive auth wizard (all auth methods: desktop app, token, new app)",(C)=>C.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(C)=>{await xF({...C.token!==void 0?{token:C.token}:{},...C.name!==void 0?{name:C.name}:{}})}).command(["ls","status"],"Show auth status",()=>{},()=>{let C=T0();if(C.length===0){console.log("No workspaces configured. Run: slack auth login");return}for(let{name:$,profile:z,current:Z}of C)console.log(`${Z?"* ":" "}${$} ${z.team} (${z.user}) ${z.url??""}`)}).command("use <name>","Switch active workspace",(C)=>C.positional("name",{type:"string",demandOption:!0}).option("g",{type:"boolean",default:!1,describe:"Write global lockfile (~/.slack-cli/workspace)"}),(C)=>{if(!C.g)O9(eD(process.cwd(),".slack-cli"));B1(C.name,C.g),console.log(`Switched to workspace "${C.name}" ${C.g?"globally":"locally"}`)}).command(["logout <name>","rm <name>","remove <name>"],"Remove a workspace",(C)=>C.positional("name",{type:"string",demandOption:!0}),(C)=>{E1(C.name),console.log(`Removed workspace "${C.name}"`)}).command(["chrome","cookie"],"Attach Chrome browser xoxd cookie to a workspace (macOS, interactive)",(C)=>C.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(C)=>{await I1({...C.workspace!==void 0?{workspace:C.workspace}:{}})}).command("firefox","Attach Firefox browser xoxd cookie to a workspace (all platforms)",(C)=>C.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(C)=>{await b1({...C.workspace!==void 0?{workspace:C.workspace}:{}})}).command("$0",!1,()=>{},()=>{E.showHelp(),process.exit(0)})).command("tail [target]","Stream new messages in real time (like tail -f)",(E)=>E.positional("target",{type:"string",describe:"#channel or @user to follow"}).option("since",{type:"string",describe:"Backfill from N ago (e.g. 10m, 2h, 1d)"}).option("thread",{type:"string",describe:"Follow a single thread by timestamp"}).option("watch-thread",{type:"string",describe:"Watch the channel's top-level timeline AND one thread's replies together (ts or permalink)"}).option("me",{type:"boolean",default:!1,describe:"Filter to messages that mention you"}).option("interval",{type:"number",default:60000,describe:"Poll interval in ms (default 60s; use --interval=3000 for near-real-time)"}).option("timeout",{type:"string",describe:"Auto-stop after this long (e.g. 30m, 2h). Exit code 0 even if nothing arrived."}).option("exit-on-message",{type:"boolean",default:!1,describe:"Stop as soon as the first new message from someone else arrives (wait-for-reply)"}).option("rtm",{type:"boolean",default:!0,describe:"Use RTM WebSocket when available (xoxc + cookie); pass --no-rtm to force polling"}),async(E)=>{let C=D(E),$=u(E),z=new AbortController;process.on("SIGINT",()=>{z.abort(),process.exit(0)}),await d1(C,E.target,{...E.since!==void 0?{since:E.since}:{},...E.thread!==void 0?{thread:E.thread}:{},...E["watch-thread"]!==void 0?{watchThread:E["watch-thread"]}:{},me:E.me,interval:E.interval,...E.timeout!==void 0?{timeout:E.timeout}:{},...E["exit-on-message"]===!0?{exitOnMessage:!0}:{},...$!==void 0?{cookie:$}:{},...E.rtm===!1?{noRtm:!0}:{}},z.signal)}).command("login",!1,(E)=>E.option("token",{type:"string"}).option("name",{type:"string"}),async(E)=>{await xF({...E.token!==void 0?{token:E.token}:{},...E.name!==void 0?{name:E.name}:{}})}).demandCommand(1,"Specify a command. Run with --help for usage.").strict().help().alias("help","h").parseAsync()}$E().catch((D)=>{console.error(D instanceof Error?D.message:String(D)),process.exit(1)});
|