slack-term 1.31.0 → 1.31.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 +97 -94
- package/package.json +1 -1
- package/ts/ask.ts +65 -5
- package/ts/cli.ts +18 -2
package/dist/cli.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{createRequire as Gc}from"node:module";var Jc=Object.create;var{getPrototypeOf:Kc,defineProperty:Qi,getOwnPropertyNames:zc}=Object;var Hc=Object.prototype.hasOwnProperty;function qc(e){return this[e]}var Yc,Xc,er=(e,t,n)=>{var i=e!=null&&typeof e==="object";if(i){var s=t?Yc??=new WeakMap:Xc??=new WeakMap,r=s.get(e);if(r)return r}n=e!=null?Jc(Kc(e)):{};let o=t||!e||!e.__esModule?Qi(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of zc(e))if(!Hc.call(o,a))Qi(o,a,{get:qc.bind(e,a),enumerable:!0})}if(i)s.set(e,o);return o};var tr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ye=Gc(import.meta.url);var wr=tr(function(Jd,yr){yr.exports=()=>/[#*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 zr=tr(function(Ip,Kr){Kr.exports=function(t){if(t===void 0)t=2;if(t>=Error.stackTraceLimit)throw TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+t+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");var n=Error.prepareStackTrace;Error.prepareStackTrace=function(s,r){return r};var i=Error().stack;if(Error.prepareStackTrace=n,i!==null&&typeof i==="object")return i[t]?i[t].getFileName():void 0}});import{createHash as bf}from"crypto";import{existsSync as Pc,readFileSync as Ff,mkdirSync as Cf,writeFileSync as Rc}from"fs";import{homedir as Ac}from"os";import{join as pt}from"path";import{notStrictEqual as Mu,strictEqual as Bu}from"assert";var Vc={right:eu,center:tu};class sr{constructor(e){var t;this.width=e.width,this.wrap=(t=e.wrap)!==null&&t!==void 0?t:!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]==="string")return this.applyLayoutDSL(e[0]);let t=e.map((n)=>{if(typeof n==="string")return this.colFromString(n);return n});return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]==="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
|
|
3
|
+
import{createRequire as Qc}from"node:module";var Hc=Object.create;var{getPrototypeOf:qc,defineProperty:Qi,getOwnPropertyNames:Yc}=Object;var Xc=Object.prototype.hasOwnProperty;function Gc(e){return this[e]}var Vc,Zc,er=(e,t,n)=>{var i=e!=null&&typeof e==="object";if(i){var s=t?Vc??=new WeakMap:Zc??=new WeakMap,r=s.get(e);if(r)return r}n=e!=null?Hc(qc(e)):{};let o=t||!e||!e.__esModule?Qi(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Yc(e))if(!Xc.call(o,a))Qi(o,a,{get:Gc.bind(e,a),enumerable:!0})}if(i)s.set(e,o);return o};var tr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ye=Qc(import.meta.url);var wr=tr(function(qd,yr){yr.exports=()=>/[#*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 zr=tr(function(Mp,Jr){Jr.exports=function(t){if(t===void 0)t=2;if(t>=Error.stackTraceLimit)throw TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+t+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");var n=Error.prepareStackTrace;Error.prepareStackTrace=function(s,r){return r};var i=Error().stack;if(Error.prepareStackTrace=n,i!==null&&typeof i==="object")return i[t]?i[t].getFileName():void 0}});import{createHash as xf}from"crypto";import{existsSync as Bc,readFileSync as _f,mkdirSync as Sf,writeFileSync as Nc}from"fs";import{homedir as Ic}from"os";import{join as pt}from"path";import{notStrictEqual as vu,strictEqual as ju}from"assert";var eu={right:su,center:iu};class sr{constructor(e){var t;this.width=e.width,this.wrap=(t=e.wrap)!==null&&t!==void 0?t:!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]==="string")return this.applyLayoutDSL(e[0]);let t=e.map((n)=>{if(typeof n==="string")return this.colFromString(n);return n});return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]==="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
|
|
4
4
|
`).map((i)=>i.split("\t")),n=0;return t.forEach((i)=>{if(i.length>1&&ke.stringWidth(i[0])>n)n=Math.min(Math.floor(this.width*0.5),ke.stringWidth(i[0]))}),t.forEach((i)=>{this.div(...i.map((s,r)=>({text:s.trim(),padding:this.measurePadding(s),width:r===0&&i.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){let t=ke.stripAnsi(e);return[0,t.match(/\s*$/)[0].length,0,t.match(/^\s*/)[0].length]}toString(){let e=[];return this.rows.forEach((t)=>{this.rowToString(t,e)}),e.filter((t)=>!t.hidden).map((t)=>t.text).join(`
|
|
5
|
-
`)}rowToString(e,t){return this.rasterize(e).forEach((n,i)=>{let s="";n.forEach((r,o)=>{let{width:a}=e[o],c=this.negatePadding(e[o]),u=r;if(c>ke.stringWidth(r))u+=" ".repeat(c-ke.stringWidth(r));if(e[o].align&&e[o].align!=="left"&&this.wrap){let l=
|
|
5
|
+
`)}rowToString(e,t){return this.rasterize(e).forEach((n,i)=>{let s="";n.forEach((r,o)=>{let{width:a}=e[o],c=this.negatePadding(e[o]),u=r;if(c>ke.stringWidth(r))u+=" ".repeat(c-ke.stringWidth(r));if(e[o].align&&e[o].align!=="left"&&this.wrap){let l=eu[e[o].align];if(u=l(u,c),ke.stringWidth(u)<c)u+=" ".repeat((a||0)-ke.stringWidth(u)-1)}let f=e[o].padding||[0,0,0,0];if(f[3])s+=" ".repeat(f[3]);if(s+=nr(e[o],u,"| "),s+=u,s+=nr(e[o],u," |"),f[1])s+=" ".repeat(f[1]);if(i===0&&t.length>0)s=this.renderInline(s,t[t.length-1])}),t.push({text:s.replace(/ +$/,""),span:e.span})}),t}renderInline(e,t){let n=e.match(/^ */),i=n?n[0].length:0,s=t.text,r=ke.stringWidth(s.trimRight());if(!t.span)return e;if(!this.wrap)return t.hidden=!0,s+e;if(i<r)return e;return t.hidden=!0,s.trimRight()+" ".repeat(i-r)+e.trimLeft()}rasterize(e){let t=[],n=this.columnWidths(e),i;return e.forEach((s,r)=>{if(s.width=n[r],this.wrap)i=ke.wrap(s.text,this.negatePadding(s),{hard:!0}).split(`
|
|
6
6
|
`);else i=s.text.split(`
|
|
7
|
-
`);if(s.border)i.unshift("."+"-".repeat(this.negatePadding(s)+2)+"."),i.push("'"+"-".repeat(this.negatePadding(s)+2)+"'");if(s.padding)i.unshift(...Array(s.padding[0]||0).fill("")),i.push(...Array(s.padding[2]||0).fill(""));i.forEach((o,a)=>{if(!t[a])t.push([]);let c=t[a];for(let u=0;u<r;u++)if(c[u]===void 0)c.push("");c.push(o)})}),t}negatePadding(e){let t=e.width||0;if(e.padding)t-=(e.padding[3]||0)+(e.padding[1]||0);if(e.border)t-=4;return t}columnWidths(e){if(!this.wrap)return e.map((r)=>r.width||ke.stringWidth(r.text));let t=e.length,n=this.width,i=e.map((r)=>{if(r.width)return t--,n-=r.width,r.width;return}),s=t?Math.floor(n/t):0;return i.map((r,o)=>{if(r===void 0)return Math.max(s,Zc(e[o]));return r})}}function nr(e,t,n){if(e.border){if(/[.']-+[.']/.test(t))return"";if(t.trim().length!==0)return n;return" "}return""}function Zc(e){let t=e.padding||[],n=1+(t[3]||0)+(t[1]||0);if(e.border)return n+4;return n}function Qc(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function eu(e,t){e=e.trim();let n=ke.stringWidth(e);if(n<t)return" ".repeat(t-n)+e;return e}function tu(e,t){e=e.trim();let n=ke.stringWidth(e);if(n>=t)return e;return" ".repeat(t-n>>1)+e}var ke;function ir(e,t){return ke=t,new sr({width:(e===null||e===void 0?void 0:e.width)||Qc(),wrap:e===null||e===void 0?void 0:e.wrap})}function _s({onlyFirst:e=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}var nu=_s();function ht(e){if(typeof e!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);if(!e.includes("\x1B")&&!e.includes(""))return e;return e.replace(nu,"")}var rr=161,or=1114109,ar=[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],cr=12288,ur=65510,lr=[12288,12288,65281,65376,65504,65510];var fr=4352,dr=262141,Ss=[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 kn=(e,t)=>{let n=0,i=Math.floor(e.length/2)-1;while(n<=i){let s=Math.floor((n+i)/2),r=s*2;if(t<e[r])i=s-1;else if(t>e[r+1])n=s+1;else return!0}return!1};var pr=19968,[su,iu]=ru(Ss);function ru(e){let t=e[0],n=e[1];for(let i=0;i<e.length;i+=2){let s=e[i],r=e[i+1];if(pr>=s&&pr<=r)return[s,r];if(r-s>n-t)t=s,n=r}return[t,n]}var hr=(e)=>{if(e<rr||e>or)return!1;return kn(ar,e)},gr=(e)=>{if(e<cr||e>ur)return!1;return kn(lr,e)};var mr=(e)=>{if(e>=su&&e<=iu)return!0;if(e<fr||e>dr)return!1;return kn(Ss,e)};function ou(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Dr(e,{ambiguousAsWide:t=!1}={}){if(ou(e),gr(e)||mr(e)||t&&hr(e))return 2;return 1}var br=er(wr(),1),au=new Intl.Segmenter,cu=/^\p{Default_Ignorable_Code_Point}$/u;function We(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:i=!1}=t;if(!i)e=ht(e);if(e.length===0)return 0;let s=0,r={ambiguousAsWide:!n};for(let{segment:o}of au.segment(e)){let a=o.codePointAt(0);if(a<=31||a>=127&&a<=159)continue;if(a>=8203&&a<=8207||a===65279)continue;if(a>=768&&a<=879||a>=6832&&a<=6911||a>=7616&&a<=7679||a>=8400&&a<=8447||a>=65056&&a<=65071)continue;if(a>=55296&&a<=57343)continue;if(a>=65024&&a<=65039)continue;if(cu.test(o))continue;if(br.default().test(o)){s+=2;continue}s+=Dr(a,r)}return s}var Fr=(e=0)=>(t)=>`\x1B[${t+e}m`,Cr=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,Er=(e=0)=>(t,n,i)=>`\x1B[${38+e};2;${t};${n};${i}m`,ie={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]}},qd=Object.keys(ie.modifier),uu=Object.keys(ie.color),lu=Object.keys(ie.bgColor),Yd=[...uu,...lu];function fu(){let e=new Map;for(let[t,n]of Object.entries(ie)){for(let[i,s]of Object.entries(n))ie[i]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[i]=ie[i],e.set(s[0],s[1]);Object.defineProperty(ie,t,{value:n,enumerable:!1})}return Object.defineProperty(ie,"codes",{value:e,enumerable:!1}),ie.color.close="\x1B[39m",ie.bgColor.close="\x1B[49m",ie.color.ansi=Fr(),ie.color.ansi256=Cr(),ie.color.ansi16m=Er(),ie.bgColor.ansi=Fr(10),ie.bgColor.ansi256=Cr(10),ie.bgColor.ansi16m=Er(10),Object.defineProperties(ie,{rgbToAnsi256:{value(t,n,i){if(t===n&&n===i){if(t<8)return 16;if(t>248)return 231;return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[i]=n;if(i.length===3)i=[...i].map((r)=>r+r).join("");let s=Number.parseInt(i,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:(t)=>ie.rgbToAnsi256(...ie.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,i,s;if(t>=232)n=((t-232)*10+8)/255,i=n,s=n;else{t-=16;let a=t%36;n=Math.floor(t/36)/5,i=Math.floor(a/6)/5,s=a%6/5}let r=Math.max(n,i,s)*2;if(r===0)return 30;let o=30+(Math.round(s)<<2|Math.round(i)<<1|Math.round(n));if(r===2)o+=60;return o},enumerable:!1},rgbToAnsi:{value:(t,n,i)=>ie.ansi256ToAnsi(ie.rgbToAnsi256(t,n,i)),enumerable:!1},hexToAnsi:{value:(t)=>ie.ansi256ToAnsi(ie.hexToAnsi256(t)),enumerable:!1}}),ie}var du=fu(),xr=du;var $n=new Set(["\x1B",""]),pu=39,As="\x07",kr="[",hu="]",Ar="m",An=`${hu}8;;`,_r=(e)=>`${$n.values().next().value}${kr}${e}${Ar}`,Sr=(e)=>`${$n.values().next().value}${An}${e}${As}`,gu=(e)=>e.split(" ").map((t)=>We(t)),ks=(e,t,n)=>{let i=[...t],s=!1,r=!1,o=We(ht(e.at(-1)));for(let[a,c]of i.entries()){let u=We(c);if(o+u<=n)e[e.length-1]+=c;else e.push(c),o=0;if($n.has(c))s=!0,r=i.slice(a+1,a+1+An.length).join("")===An;if(s){if(r){if(c===As)s=!1,r=!1}else if(c===Ar)s=!1;continue}if(o+=u,o===n&&a<i.length-1)e.push(""),o=0}if(!o&&e.at(-1).length>0&&e.length>1)e[e.length-2]+=e.pop()},mu=(e)=>{let t=e.split(" "),n=t.length;while(n>0){if(We(t[n-1])>0)break;n--}if(n===t.length)return e;return t.slice(0,n).join(" ")+t.slice(n).join("")},Du=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let i="",s,r,o=gu(e),a=[""];for(let[l,d]of e.split(" ").entries()){if(n.trim!==!1)a[a.length-1]=a.at(-1).trimStart();let p=We(a.at(-1));if(l!==0){if(p>=t&&(n.wordWrap===!1||n.trim===!1))a.push(""),p=0;if(p>0||n.trim===!1)a[a.length-1]+=" ",p++}if(n.hard&&o[l]>t){let m=t-p,h=1+Math.floor((o[l]-m-1)/t);if(Math.floor((o[l]-1)/t)<h)a.push("");ks(a,d,t);continue}if(p+o[l]>t&&p>0&&o[l]>0){if(n.wordWrap===!1&&p<t){ks(a,d,t);continue}a.push("")}if(p+o[l]>t&&n.wordWrap===!1){ks(a,d,t);continue}a[a.length-1]+=d}if(n.trim!==!1)a=a.map((l)=>mu(l));let c=a.join(`
|
|
8
|
-
`),u=[...c],f=0;for(let[l,d]of u.entries()){if(i+=d,$n.has(d)){let{groups:m}=new RegExp(`(?:\\${kr}(?<code>\\d+)m|\\${An}(?<uri>.*)${
|
|
9
|
-
`){if(r)i+=Sr("");if(s&&
|
|
10
|
-
`){if(s&&
|
|
7
|
+
`);if(s.border)i.unshift("."+"-".repeat(this.negatePadding(s)+2)+"."),i.push("'"+"-".repeat(this.negatePadding(s)+2)+"'");if(s.padding)i.unshift(...Array(s.padding[0]||0).fill("")),i.push(...Array(s.padding[2]||0).fill(""));i.forEach((o,a)=>{if(!t[a])t.push([]);let c=t[a];for(let u=0;u<r;u++)if(c[u]===void 0)c.push("");c.push(o)})}),t}negatePadding(e){let t=e.width||0;if(e.padding)t-=(e.padding[3]||0)+(e.padding[1]||0);if(e.border)t-=4;return t}columnWidths(e){if(!this.wrap)return e.map((r)=>r.width||ke.stringWidth(r.text));let t=e.length,n=this.width,i=e.map((r)=>{if(r.width)return t--,n-=r.width,r.width;return}),s=t?Math.floor(n/t):0;return i.map((r,o)=>{if(r===void 0)return Math.max(s,tu(e[o]));return r})}}function nr(e,t,n){if(e.border){if(/[.']-+[.']/.test(t))return"";if(t.trim().length!==0)return n;return" "}return""}function tu(e){let t=e.padding||[],n=1+(t[3]||0)+(t[1]||0);if(e.border)return n+4;return n}function nu(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function su(e,t){e=e.trim();let n=ke.stringWidth(e);if(n<t)return" ".repeat(t-n)+e;return e}function iu(e,t){e=e.trim();let n=ke.stringWidth(e);if(n>=t)return e;return" ".repeat(t-n>>1)+e}var ke;function ir(e,t){return ke=t,new sr({width:(e===null||e===void 0?void 0:e.width)||nu(),wrap:e===null||e===void 0?void 0:e.wrap})}function Ss({onlyFirst:e=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}var ru=Ss();function ht(e){if(typeof e!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);if(!e.includes("\x1B")&&!e.includes(""))return e;return e.replace(ru,"")}var rr=161,or=1114109,ar=[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],cr=12288,ur=65510,lr=[12288,12288,65281,65376,65504,65510];var fr=4352,dr=262141,ks=[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 kn=(e,t)=>{let n=0,i=Math.floor(e.length/2)-1;while(n<=i){let s=Math.floor((n+i)/2),r=s*2;if(t<e[r])i=s-1;else if(t>e[r+1])n=s+1;else return!0}return!1};var pr=19968,[ou,au]=cu(ks);function cu(e){let t=e[0],n=e[1];for(let i=0;i<e.length;i+=2){let s=e[i],r=e[i+1];if(pr>=s&&pr<=r)return[s,r];if(r-s>n-t)t=s,n=r}return[t,n]}var hr=(e)=>{if(e<rr||e>or)return!1;return kn(ar,e)},gr=(e)=>{if(e<cr||e>ur)return!1;return kn(lr,e)};var mr=(e)=>{if(e>=ou&&e<=au)return!0;if(e<fr||e>dr)return!1;return kn(ks,e)};function uu(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Dr(e,{ambiguousAsWide:t=!1}={}){if(uu(e),gr(e)||mr(e)||t&&hr(e))return 2;return 1}var br=er(wr(),1),lu=new Intl.Segmenter,fu=/^\p{Default_Ignorable_Code_Point}$/u;function We(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:i=!1}=t;if(!i)e=ht(e);if(e.length===0)return 0;let s=0,r={ambiguousAsWide:!n};for(let{segment:o}of lu.segment(e)){let a=o.codePointAt(0);if(a<=31||a>=127&&a<=159)continue;if(a>=8203&&a<=8207||a===65279)continue;if(a>=768&&a<=879||a>=6832&&a<=6911||a>=7616&&a<=7679||a>=8400&&a<=8447||a>=65056&&a<=65071)continue;if(a>=55296&&a<=57343)continue;if(a>=65024&&a<=65039)continue;if(fu.test(o))continue;if(br.default().test(o)){s+=2;continue}s+=Dr(a,r)}return s}var Fr=(e=0)=>(t)=>`\x1B[${t+e}m`,Cr=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,Er=(e=0)=>(t,n,i)=>`\x1B[${38+e};2;${t};${n};${i}m`,ie={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]}},Vd=Object.keys(ie.modifier),du=Object.keys(ie.color),pu=Object.keys(ie.bgColor),Zd=[...du,...pu];function hu(){let e=new Map;for(let[t,n]of Object.entries(ie)){for(let[i,s]of Object.entries(n))ie[i]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[i]=ie[i],e.set(s[0],s[1]);Object.defineProperty(ie,t,{value:n,enumerable:!1})}return Object.defineProperty(ie,"codes",{value:e,enumerable:!1}),ie.color.close="\x1B[39m",ie.bgColor.close="\x1B[49m",ie.color.ansi=Fr(),ie.color.ansi256=Cr(),ie.color.ansi16m=Er(),ie.bgColor.ansi=Fr(10),ie.bgColor.ansi256=Cr(10),ie.bgColor.ansi16m=Er(10),Object.defineProperties(ie,{rgbToAnsi256:{value(t,n,i){if(t===n&&n===i){if(t<8)return 16;if(t>248)return 231;return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[i]=n;if(i.length===3)i=[...i].map((r)=>r+r).join("");let s=Number.parseInt(i,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:(t)=>ie.rgbToAnsi256(...ie.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,i,s;if(t>=232)n=((t-232)*10+8)/255,i=n,s=n;else{t-=16;let a=t%36;n=Math.floor(t/36)/5,i=Math.floor(a/6)/5,s=a%6/5}let r=Math.max(n,i,s)*2;if(r===0)return 30;let o=30+(Math.round(s)<<2|Math.round(i)<<1|Math.round(n));if(r===2)o+=60;return o},enumerable:!1},rgbToAnsi:{value:(t,n,i)=>ie.ansi256ToAnsi(ie.rgbToAnsi256(t,n,i)),enumerable:!1},hexToAnsi:{value:(t)=>ie.ansi256ToAnsi(ie.hexToAnsi256(t)),enumerable:!1}}),ie}var gu=hu(),xr=gu;var $n=new Set(["\x1B",""]),mu=39,$s="\x07",kr="[",Du="]",Ar="m",An=`${Du}8;;`,_r=(e)=>`${$n.values().next().value}${kr}${e}${Ar}`,Sr=(e)=>`${$n.values().next().value}${An}${e}${$s}`,yu=(e)=>e.split(" ").map((t)=>We(t)),As=(e,t,n)=>{let i=[...t],s=!1,r=!1,o=We(ht(e.at(-1)));for(let[a,c]of i.entries()){let u=We(c);if(o+u<=n)e[e.length-1]+=c;else e.push(c),o=0;if($n.has(c))s=!0,r=i.slice(a+1,a+1+An.length).join("")===An;if(s){if(r){if(c===$s)s=!1,r=!1}else if(c===Ar)s=!1;continue}if(o+=u,o===n&&a<i.length-1)e.push(""),o=0}if(!o&&e.at(-1).length>0&&e.length>1)e[e.length-2]+=e.pop()},wu=(e)=>{let t=e.split(" "),n=t.length;while(n>0){if(We(t[n-1])>0)break;n--}if(n===t.length)return e;return t.slice(0,n).join(" ")+t.slice(n).join("")},bu=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let i="",s,r,o=yu(e),a=[""];for(let[l,d]of e.split(" ").entries()){if(n.trim!==!1)a[a.length-1]=a.at(-1).trimStart();let h=We(a.at(-1));if(l!==0){if(h>=t&&(n.wordWrap===!1||n.trim===!1))a.push(""),h=0;if(h>0||n.trim===!1)a[a.length-1]+=" ",h++}if(n.hard&&o[l]>t){let m=t-h,p=1+Math.floor((o[l]-m-1)/t);if(Math.floor((o[l]-1)/t)<p)a.push("");As(a,d,t);continue}if(h+o[l]>t&&h>0&&o[l]>0){if(n.wordWrap===!1&&h<t){As(a,d,t);continue}a.push("")}if(h+o[l]>t&&n.wordWrap===!1){As(a,d,t);continue}a[a.length-1]+=d}if(n.trim!==!1)a=a.map((l)=>wu(l));let c=a.join(`
|
|
8
|
+
`),u=[...c],f=0;for(let[l,d]of u.entries()){if(i+=d,$n.has(d)){let{groups:m}=new RegExp(`(?:\\${kr}(?<code>\\d+)m|\\${An}(?<uri>.*)${$s})`).exec(c.slice(f))||{groups:{}};if(m.code!==void 0){let p=Number.parseFloat(m.code);s=p===mu?void 0:p}else if(m.uri!==void 0)r=m.uri.length===0?void 0:m.uri}let h=xr.codes.get(Number(s));if(u[l+1]===`
|
|
9
|
+
`){if(r)i+=Sr("");if(s&&h)i+=_r(h)}else if(d===`
|
|
10
|
+
`){if(s&&h)i+=_r(s);if(r)i+=Sr(r)}f+=d.length}return i};function Os(e,t,n){return String(e).normalize().replaceAll(`\r
|
|
11
11
|
`,`
|
|
12
12
|
`).split(`
|
|
13
|
-
`).map((i)=>
|
|
14
|
-
`)}function Os(e){return ir(e,{stringWidth:We,stripAnsi:ht,wrap:$s})}import{dirname as $r,resolve as Or}from"path";import{readdirSync as yu,statSync as wu}from"fs";function Is(e,t){let n=Or(".",e),i;if(!wu(n).isDirectory())n=$r(n);while(!0){if(i=t(n,yu(n)),i)return Or(n,i);if(n=$r(i=n),i===n)break}}import{inspect as Nu}from"util";import{fileURLToPath as qr}from"url";import{format as Cu}from"util";import{normalize as Eu,resolve as xu}from"path";function gt(e){if(!(e!==e.toLowerCase()&&e!==e.toUpperCase()))e=e.toLowerCase();if(e.indexOf("-")===-1&&e.indexOf("_")===-1)return e;else{let n="",i=!1,s=e.match(/^-+/);for(let r=s?s[0].length:0;r<e.length;r++){let o=e.charAt(r);if(i)i=!1,o=o.toUpperCase();if(r!==0&&(o==="-"||o==="_"))i=!0;else if(o!=="-"&&o!=="_")n+=o}return n}}function On(e,t){let n=e.toLowerCase();t=t||"-";let i="";for(let s=0;s<e.length;s++){let r=n.charAt(s),o=e.charAt(s);if(r!==o&&s>0)i+=`${t}${n.charAt(s)}`;else i+=o}return i}function In(e){if(e===null||e===void 0)return!1;if(typeof e==="number")return!0;if(/^0x[0-9a-f]+$/i.test(e))return!0;if(/^0[^.]/.test(e))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function Ir(e){if(Array.isArray(e))return e.map((o)=>typeof o!=="string"?o+"":o);e=e.trim();let t=0,n=null,i=null,s=null,r=[];for(let o=0;o<e.length;o++){if(n=i,i=e.charAt(o),i===" "&&!s){if(n!==" ")t++;continue}if(i===s)s=null;else if((i==="'"||i==='"')&&!s)s=i;if(!r[t])r[t]="";r[t]+=i}return r}var Te;(function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"})(Te||(Te={}));var et;class Ps{constructor(e){et=e}parse(e,t){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),i=Ir(e),s=typeof e==="string",r=bu(Object.assign(Object.create(null),n.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),a=Object.assign(Object.create(null),n.default),c=n.configObjects||[],u=n.envPrefix,f=o["populate--"],l=f?"--":"_",d=Object.create(null),p=Object.create(null),m=n.__||et.format,h={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},y=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,C=new RegExp("^--"+o["negation-prefix"]+"(.+)");if([].concat(n.array||[]).filter(Boolean).forEach(function(D){let b=typeof D==="object"?D.key:D,T=Object.keys(D).map(function(x){return{boolean:"bools",string:"strings",number:"numbers"}[x]}).filter(Boolean).pop();if(T)h[T][b]=!0;h.arrays[b]=!0,h.keys.push(b)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(D){h.bools[D]=!0,h.keys.push(D)}),[].concat(n.string||[]).filter(Boolean).forEach(function(D){h.strings[D]=!0,h.keys.push(D)}),[].concat(n.number||[]).filter(Boolean).forEach(function(D){h.numbers[D]=!0,h.keys.push(D)}),[].concat(n.count||[]).filter(Boolean).forEach(function(D){h.counts[D]=!0,h.keys.push(D)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(D){h.normalize[D]=!0,h.keys.push(D)}),typeof n.narg==="object")Object.entries(n.narg).forEach(([D,b])=>{if(typeof b==="number")h.nargs[D]=b,h.keys.push(D)});if(typeof n.coerce==="object")Object.entries(n.coerce).forEach(([D,b])=>{if(typeof b==="function")h.coercions[D]=b,h.keys.push(D)});if(typeof n.config<"u"){if(Array.isArray(n.config)||typeof n.config==="string")[].concat(n.config).filter(Boolean).forEach(function(D){h.configs[D]=!0});else if(typeof n.config==="object")Object.entries(n.config).forEach(([D,b])=>{if(typeof b==="boolean"||typeof b==="function")h.configs[D]=b})}Z(n.key,r,n.default,h.arrays),Object.keys(a).forEach(function(D){(h.aliases[D]||[]).forEach(function(b){a[b]=a[D]})});let F=null;xs();let S=[],k=Object.assign(Object.create(null),{_:[]}),j={};for(let D=0;D<i.length;D++){let b=i[D],T=b.replace(/^-{3,}/,"---"),x,w,U,B,K,ge;if(b!=="--"&&/^-/.test(b)&&te(b))A(b);else if(T.match(/^---+(=|$)/)){A(b);continue}else if(b.match(/^--.+=/)||!o["short-option-groups"]&&b.match(/^-.+=/)){if(B=b.match(/^--?([^=]+)=([\s\S]*)$/),B!==null&&Array.isArray(B)&&B.length>=3)if(W(B[1],h.arrays))D=R(D,B[1],i,B[2]);else if(W(B[1],h.nargs)!==!1)D=M(D,B[1],i,B[2]);else I(B[1],B[2],!0)}else if(b.match(C)&&o["boolean-negation"]){if(B=b.match(C),B!==null&&Array.isArray(B)&&B.length>=2)w=B[1],I(w,W(w,h.arrays)?[!1]:!1)}else if(b.match(/^--.+/)||!o["short-option-groups"]&&b.match(/^-[^-]+/)){if(B=b.match(/^--?(.+)/),B!==null&&Array.isArray(B)&&B.length>=2)if(w=B[1],W(w,h.arrays))D=R(D,w,i);else if(W(w,h.nargs)!==!1)D=M(D,w,i);else if(K=i[D+1],K!==void 0&&(!K.match(/^-/)||K.match(y))&&!W(w,h.bools)&&!W(w,h.counts))I(w,K),D++;else if(/^(true|false)$/.test(K))I(w,K),D++;else I(w,G(w))}else if(b.match(/^-.\..+=/)){if(B=b.match(/^-([^=]+)=([\s\S]*)$/),B!==null&&Array.isArray(B)&&B.length>=3)I(B[1],B[2])}else if(b.match(/^-.\..+/)&&!b.match(y)){if(K=i[D+1],B=b.match(/^-(.\..+)/),B!==null&&Array.isArray(B)&&B.length>=2)if(w=B[1],K!==void 0&&!K.match(/^-/)&&!W(w,h.bools)&&!W(w,h.counts))I(w,K),D++;else I(w,G(w))}else if(b.match(/^-[^-]+/)&&!b.match(y)){U=b.slice(1,-1).split(""),x=!1;for(let be=0;be<U.length;be++){if(K=b.slice(be+2),U[be+1]&&U[be+1]==="="){if(ge=b.slice(be+3),w=U[be],W(w,h.arrays))D=R(D,w,i,ge);else if(W(w,h.nargs)!==!1)D=M(D,w,i,ge);else I(w,ge);x=!0;break}if(K==="-"){I(U[be],K);continue}if(/[A-Za-z]/.test(U[be])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(K)&&W(K,h.bools)===!1){I(U[be],K),x=!0;break}if(U[be+1]&&U[be+1].match(/\W/)){I(U[be],K),x=!0;break}else I(U[be],G(U[be]))}if(w=b.slice(-1)[0],!x&&w!=="-")if(W(w,h.arrays))D=R(D,w,i);else if(W(w,h.nargs)!==!1)D=M(D,w,i);else if(K=i[D+1],K!==void 0&&(!/^(-|--)[^-]/.test(K)||K.match(y))&&!W(w,h.bools)&&!W(w,h.counts))I(w,K),D++;else if(/^(true|false)$/.test(K))I(w,K),D++;else I(w,G(w))}else if(b.match(/^-[0-9]$/)&&b.match(y)&&W(b.slice(1),h.bools))w=b.slice(1),I(w,G(w));else if(b==="--"){S=i.slice(D+1);break}else if(o["halt-at-non-option"]){S=i.slice(D);break}else A(b)}if(oe(k,!0),oe(k,!1),O(k),Q(),Ie(k,h.aliases,a,!0),V(k),o["set-placeholder-key"])ae(k);if(Object.keys(h.counts).forEach(function(D){if(!ee(k,D.split(".")))I(D,0)}),f&&S.length)k[l]=[];if(S.forEach(function(D){k[l].push(D)}),o["camel-case-expansion"]&&o["strip-dashed"])Object.keys(k).filter((D)=>D!=="--"&&D.includes("-")).forEach((D)=>{delete k[D]});if(o["strip-aliased"])[].concat(...Object.keys(r).map((D)=>r[D])).forEach((D)=>{if(o["camel-case-expansion"]&&D.includes("-"))delete k[D.split(".").map((b)=>gt(b)).join(".")];delete k[D]});function A(D){let b=E("_",D);if(typeof b==="string"||typeof b==="number")k._.push(b)}function M(D,b,T,x){let w,U=W(b,h.nargs);if(U=typeof U!=="number"||isNaN(U)?1:U,U===0){if(!pe(x))F=Error(m("Argument unexpected for: %s",b));return I(b,G(b)),D}let B=pe(x)?0:1;if(o["nargs-eats-options"]){if(T.length-(D+1)+B<U)F=Error(m("Not enough arguments following: %s",b));B=U}else{for(w=D+1;w<T.length;w++)if(!T[w].match(/^-[^0-9]/)||T[w].match(y)||te(T[w]))B++;else break;if(B<U)F=Error(m("Not enough arguments following: %s",b))}let K=Math.min(B,U);if(!pe(x)&&K>0)I(b,x),K--;for(w=D+1;w<K+D+1;w++)I(b,T[w]);return D+K}function R(D,b,T,x){let w=[],U=x||T[D+1],B=W(b,h.nargs);if(W(b,h.bools)&&!/^(true|false)$/.test(U))w.push(!0);else if(pe(U)||pe(x)&&/^-/.test(U)&&!y.test(U)&&!te(U)){if(a[b]!==void 0){let K=a[b];w=Array.isArray(K)?K:[K]}}else{if(!pe(x))w.push(_(b,x,!0));for(let K=D+1;K<T.length;K++){if(!o["greedy-arrays"]&&w.length>0||B&&typeof B==="number"&&w.length>=B)break;if(U=T[K],/^-/.test(U)&&!y.test(U)&&!te(U))break;D=K,w.push(_(b,U,s))}}if(typeof B==="number"&&(B&&w.length<B||isNaN(B)&&w.length===0))F=Error(m("Not enough arguments following: %s",b));return I(b,w),D}function I(D,b,T=s){if(/-/.test(D)&&o["camel-case-expansion"]){let U=D.split(".").map(function(B){return gt(B)}).join(".");q(D,U)}let x=_(D,b,T),w=D.split(".");if(_e(k,w,x),h.aliases[D])h.aliases[D].forEach(function(U){let B=U.split(".");_e(k,B,x)});if(w.length>1&&o["dot-notation"])(h.aliases[w[0]]||[]).forEach(function(U){let B=U.split("."),K=[].concat(w);if(K.shift(),B=B.concat(K),!(h.aliases[D]||[]).includes(B.join(".")))_e(k,B,x)});if(W(D,h.normalize)&&!W(D,h.arrays))[D].concat(h.aliases[D]||[]).forEach(function(B){Object.defineProperty(j,B,{enumerable:!0,get(){return b},set(K){b=typeof K==="string"?et.normalize(K):K}})})}function q(D,b){if(!(h.aliases[D]&&h.aliases[D].length))h.aliases[D]=[b],d[b]=!0;if(!(h.aliases[b]&&h.aliases[b].length))q(b,D)}function _(D,b,T){if(T)b=Fu(b);if(W(D,h.bools)||W(D,h.counts)){if(typeof b==="string")b=b==="true"}let x=Array.isArray(b)?b.map(function(w){return E(D,w)}):E(D,b);if(W(D,h.counts)&&(pe(x)||typeof x==="boolean"))x=Ts();if(W(D,h.normalize)&&W(D,h.arrays))if(Array.isArray(b))x=b.map((w)=>et.normalize(w));else x=et.normalize(b);return x}function E(D,b){if(!o["parse-positional-numbers"]&&D==="_")return b;if(!W(D,h.strings)&&!W(D,h.bools)&&!Array.isArray(b)){if(In(b)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${b}`)))||!pe(b)&&W(D,h.numbers))b=Number(b)}return b}function O(D){let b=Object.create(null);Ie(b,h.aliases,a),Object.keys(h.configs).forEach(function(T){let x=D[T]||b[T];if(x)try{let w=null,U=et.resolve(et.cwd(),x),B=h.configs[T];if(typeof B==="function"){try{w=B(U)}catch(K){w=K}if(w instanceof Error){F=w;return}}else w=et.require(U);N(w)}catch(w){if(w.name==="PermissionDenied")F=w;else if(D[T])F=Error(m("Invalid JSON config file: %s",x))}})}function N(D,b){Object.keys(D).forEach(function(T){let x=D[T],w=b?b+"."+T:T;if(typeof x==="object"&&x!==null&&!Array.isArray(x)&&o["dot-notation"])N(x,w);else if(!ee(k,w.split("."))||W(w,h.arrays)&&o["combine-arrays"])I(w,x)})}function Q(){if(typeof c<"u")c.forEach(function(D){N(D)})}function oe(D,b){if(typeof u>"u")return;let T=typeof u==="string"?u:"",x=et.env();Object.keys(x).forEach(function(w){if(T===""||w.lastIndexOf(T,0)===0){let U=w.split("__").map(function(B,K){if(K===0)B=B.substring(T.length);return gt(B)});if((b&&h.configs[U.join(".")]||!b)&&!ee(D,U))I(U.join("."),x[w])}})}function V(D){let b,T=new Set;Object.keys(D).forEach(function(x){if(!T.has(x)){if(b=W(x,h.coercions),typeof b==="function")try{let w=E(x,b(D[x]));[].concat(h.aliases[x]||[],x).forEach((U)=>{T.add(U),D[U]=w})}catch(w){F=w}}})}function ae(D){return h.keys.forEach((b)=>{if(~b.indexOf("."))return;if(typeof D[b]>"u")D[b]=void 0}),D}function Ie(D,b,T,x=!1){Object.keys(T).forEach(function(w){if(!ee(D,w.split("."))){if(_e(D,w.split("."),T[w]),x)p[w]=!0;(b[w]||[]).forEach(function(U){if(ee(D,U.split(".")))return;_e(D,U.split("."),T[w])})}})}function ee(D,b){let T=D;if(!o["dot-notation"])b=[b.join(".")];b.slice(0,-1).forEach(function(w){T=T[w]||{}});let x=b[b.length-1];if(typeof T!=="object")return!1;else return x in T}function _e(D,b,T){let x=D;if(!o["dot-notation"])b=[b.join(".")];b.slice(0,-1).forEach(function(ge){if(ge=Tr(ge),typeof x==="object"&&x[ge]===void 0)x[ge]={};if(typeof x[ge]!=="object"||Array.isArray(x[ge])){if(Array.isArray(x[ge]))x[ge].push({});else x[ge]=[x[ge],{}];x=x[ge][x[ge].length-1]}else x=x[ge]});let w=Tr(b[b.length-1]),U=W(b.join("."),h.arrays),B=Array.isArray(T),K=o["duplicate-arguments-array"];if(!K&&W(w,h.nargs)){if(K=!0,!pe(x[w])&&h.nargs[w]===1||Array.isArray(x[w])&&x[w].length===h.nargs[w])x[w]=void 0}if(T===Ts())x[w]=Ts(x[w]);else if(Array.isArray(x[w]))if(K&&U&&B)x[w]=o["flatten-duplicate-arrays"]?x[w].concat(T):(Array.isArray(x[w][0])?x[w]:[x[w]]).concat([T]);else if(!K&&Boolean(U)===Boolean(B))x[w]=T;else x[w]=x[w].concat([T]);else if(x[w]===void 0&&U)x[w]=B?T:[T];else if(K&&!(x[w]===void 0||W(w,h.counts)||W(w,h.bools)))x[w]=[x[w],T];else x[w]=T}function Z(...D){D.forEach(function(b){Object.keys(b||{}).forEach(function(T){if(h.aliases[T])return;h.aliases[T]=[].concat(r[T]||[]),h.aliases[T].concat(T).forEach(function(x){if(/-/.test(x)&&o["camel-case-expansion"]){let w=gt(x);if(w!==T&&h.aliases[T].indexOf(w)===-1)h.aliases[T].push(w),d[w]=!0}}),h.aliases[T].concat(T).forEach(function(x){if(x.length>1&&/[A-Z]/.test(x)&&o["camel-case-expansion"]){let w=On(x,"-");if(w!==T&&h.aliases[T].indexOf(w)===-1)h.aliases[T].push(w),d[w]=!0}}),h.aliases[T].forEach(function(x){h.aliases[x]=[T].concat(h.aliases[T].filter(function(w){return x!==w}))})})})}function W(D,b){let T=[].concat(h.aliases[D]||[],D),x=Object.keys(b),w=T.find((U)=>x.includes(U));return w?b[w]:!1}function Se(D){let b=Object.keys(h);return[].concat(b.map((x)=>h[x])).some(function(x){return Array.isArray(x)?x.includes(D):x[D]})}function Lt(D,...b){return[].concat(...b).some(function(x){let w=D.match(x);return w&&Se(w[1])})}function z(D){if(D.match(y)||!D.match(/^-[^-]+/))return!1;let b=!0,T,x=D.slice(1).split("");for(let w=0;w<x.length;w++){if(T=D.slice(w+2),!Se(x[w])){b=!1;break}if(x[w+1]&&x[w+1]==="="||T==="-"||/[A-Za-z]/.test(x[w])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(T)||x[w+1]&&x[w+1].match(/\W/))break}return b}function te(D){return o["unknown-options-as-args"]&&de(D)}function de(D){if(D=D.replace(/^-{3,}/,"--"),D.match(y))return!1;if(z(D))return!1;return!Lt(D,/^-+([^=]+?)=[\s\S]*$/,C,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function G(D){if(!W(D,h.bools)&&!W(D,h.counts)&&`${D}`in a)return a[D];else return ye(ue(D))}function ye(D){return{[Te.BOOLEAN]:!0,[Te.STRING]:"",[Te.NUMBER]:void 0,[Te.ARRAY]:[]}[D]}function ue(D){let b=Te.BOOLEAN;if(W(D,h.strings))b=Te.STRING;else if(W(D,h.numbers))b=Te.NUMBER;else if(W(D,h.bools))b=Te.BOOLEAN;else if(W(D,h.arrays))b=Te.ARRAY;return b}function pe(D){return D===void 0}function xs(){Object.keys(h.counts).find((D)=>{if(W(D,h.arrays))return F=Error(m("Invalid configuration: %s, opts.count excludes opts.array.",D)),!0;else if(W(D,h.nargs))return F=Error(m("Invalid configuration: %s, opts.count excludes opts.narg.",D)),!0;return!1})}return{aliases:Object.assign({},h.aliases),argv:Object.assign(j,k),configuration:o,defaulted:Object.assign({},p),error:F,newAliases:Object.assign({},d)}}}function bu(e){let t=[],n=Object.create(null),i=!0;Object.keys(e).forEach(function(s){t.push([].concat(e[s],s))});while(i){i=!1;for(let s=0;s<t.length;s++)for(let r=s+1;r<t.length;r++)if(t[s].filter(function(a){return t[r].indexOf(a)!==-1}).length){t[s]=t[s].concat(t[r]),t.splice(r,1),i=!0;break}}return t.forEach(function(s){s=s.filter(function(o,a,c){return c.indexOf(o)===a});let r=s.pop();if(r!==void 0&&typeof r==="string")n[r]=s}),n}function Ts(e){return e!==void 0?e+1:1}function Tr(e){if(e==="__proto__")return"___proto___";return e}function Fu(e){return typeof e==="string"&&(e[0]==="'"||e[0]==='"')&&e[e.length-1]===e[0]?e.substring(1,e.length-1):e}import{readFileSync as _u}from"fs";import{createRequire as Pr}from"node:module";var Rs,Ms,Bs,Rr=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Mr=(Ms=(Rs=process===null||process===void 0?void 0:process.versions)===null||Rs===void 0?void 0:Rs.node)!==null&&Ms!==void 0?Ms:(Bs=process===null||process===void 0?void 0:process.version)===null||Bs===void 0?void 0:Bs.slice(1);if(Mr){if(Number(Mr.match(/^([^.]+)/)[1])<Rr)throw Error(`yargs parser supports a minimum Node.js version of ${Rr}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var Su=process?process.env:{},Br=Pr?Pr(import.meta.url):void 0,Nr=new Ps({cwd:process.cwd,env:()=>Su,format:Cu,normalize:Eu,resolve:xu,require:(e)=>{if(typeof Br<"u")return Br(e);else if(e.match(/\.json$/))return JSON.parse(_u(e,"utf8"));else throw Error("only .json config files are supported in ESM")}}),en=function(t,n){return Nr.parse(t.slice(),n).argv};en.detailed=function(e,t){return Nr.parse(e.slice(),t)};en.camelCase=gt;en.decamelize=On;en.looksLikeNumber=In;var Ns=en;import{basename as vu,dirname as ju,extname as Lu,relative as Wu,resolve as Hr,join as Uu}from"path";function vr(){if(ku())return 0;return 1}function ku(){return Au()&&!process.defaultApp}function Au(){return!!process.versions.electron}function vs(e){return e.slice(vr()+1)}function jr(){return process.argv[vr()]}import{readFileSync as $u,statSync as Ou,writeFile as Iu}from"fs";import{format as Tu}from"util";import{resolve as Pu}from"path";var Lr={fs:{readFileSync:$u,writeFile:Iu},format:Tu,resolve:Pu,exists:(e)=>{try{return Ou(e).isFile()}catch(t){return!1}}};var Ue;class Wr{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles==="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage==="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let t=e.shift(),n=function(){};if(typeof e[e.length-1]==="function")n=e.pop();if(n=n||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n});else n();return Ue.format.apply(Ue.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),i=e.shift(),s=function(){};if(typeof e[e.length-1]==="function")s=e.pop();if(!this.cache[this.locale])this._readLocaleFile();let r=i===1?t:n;if(this.cache[this.locale][t])r=this.cache[this.locale][t][i===1?"one":"other"];if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:s});else s();let o=[r];if(~r.indexOf("%d"))o.push(i);return Ue.format.apply(Ue.format,o.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){if(!this.cache[this.locale])this._readLocaleFile();for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))this.cache[this.locale][t]=e[t]}_taggedLiteral(e,...t){let n="";return e.forEach(function(i,s){let r=t[s+1];if(n+=i,typeof r<"u")n+="%s"}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){if(this.writeQueue.push(e),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let e=this,t=this.writeQueue[0],n=t.directory,i=t.locale,s=t.cb,r=this._resolveLocaleFile(n,i),o=JSON.stringify(this.cache[i],null,2);Ue.fs.writeFile(r,o,"utf-8",function(a){if(e.writeQueue.shift(),e.writeQueue.length>0)e._processWriteQueue();s(a)})}_readLocaleFile(){let e={},t=this._resolveLocaleFile(this.directory,this.locale);try{if(Ue.fs.readFileSync)e=JSON.parse(Ue.fs.readFileSync(t,"utf-8"))}catch(n){if(n instanceof SyntaxError)n.message="syntax error in "+t;if(n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=Ue.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let i=Ue.resolve(e,"./",t.split("_")[0]+".json");if(this._fileExistsSync(i))n=i}return n}_fileExistsSync(e){return Ue.exists(e)}}function Ur(e,t){Ue=t;let n=new Wr(e);return{__:n.__.bind(n),__n:n.__n.bind(n),setLocale:n.setLocale.bind(n),getLocale:n.getLocale.bind(n),updateLocale:n.updateLocale.bind(n),locale:n.locale}}var Ru=(e)=>Ur(e,Lr),Jr=Ru;var Yr=er(zr(),1);import{createRequire as Ju}from"node:module";import{readFileSync as Ku,readdirSync as zu}from"node:fs";var js=qr(import.meta.url),Hu=js.substring(0,js.lastIndexOf("node_modules")),qu=Ju(import.meta.url),Ls={assert:{notStrictEqual:Mu,strictEqual:Bu},cliui:Os,findUp:Is,getEnv:(e)=>process.env[e],inspect:Nu,getProcessArgvBin:jr,mainFilename:Hu||process.cwd(),Parser:Ns,path:{basename:vu,dirname:ju,extname:Lu,relative:Wu,resolve:Hr,join:Uu},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(e,t)=>process.emitWarning(e,t),execPath:()=>process.execPath,exit:(e)=>{process.exit(e)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:Ku,readdirSync:zu,require:qu,getCallerFile:()=>{let e=Yr.default(3);return e.match(/^file:\/\//)?qr(e):e},stringWidth:We,y18n:Jr({directory:Hr(js,"../../../locales"),updateFiles:!1})};function Fe(e,t,n,i){n.assert.notStrictEqual(e,t,i)}function Ws(e,t){t.assert.strictEqual(typeof e,"string")}function Wt(e){return Object.keys(e)}function se(e){return!!e&&!!e.then&&typeof e.then==="function"}class le extends Error{constructor(e){super(e||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,le)}}function st(e){let n=e.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),i=/\.*[\][<>]/g,s=n.shift();if(!s)throw Error(`No command found in: ${e}`);let r={cmd:s.replace(i,""),demanded:[],optional:[]};return n.forEach((o,a)=>{let c=!1;if(o=o.replace(/\s/g,""),/\.+[\]>]/.test(o)&&a===n.length-1)c=!0;if(/^\[/.test(o))r.optional.push({cmd:o.replace(i,"").split("|"),variadic:c});else r.demanded.push({cmd:o.replace(i,"").split("|"),variadic:c})}),r}var Yu=["first","second","third","fourth","fifth","sixth"];function v(e,t,n){function i(){return typeof e==="object"?[{demanded:[],optional:[]},e,t]:[st(`cmd ${e}`),t,n]}try{let s=0,[r,o,a]=i(),c=[].slice.call(o);while(c.length&&c[c.length-1]===void 0)c.pop();let u=a||c.length;if(u<r.demanded.length)throw new le(`Not enough arguments provided. Expected ${r.demanded.length} but received ${c.length}.`);let f=r.demanded.length+r.optional.length;if(u>f)throw new le(`Too many arguments provided. Expected max ${f} but received ${u}.`);r.demanded.forEach((l)=>{let d=c.shift(),p=Xr(d);if(l.cmd.filter((h)=>h===p||h==="*").length===0)Gr(p,l.cmd,s);s+=1}),r.optional.forEach((l)=>{if(c.length===0)return;let d=c.shift(),p=Xr(d);if(l.cmd.filter((h)=>h===p||h==="*").length===0)Gr(p,l.cmd,s);s+=1})}catch(s){console.warn(s.stack)}}function Xr(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function Gr(e,t,n){throw new le(`Invalid ${Yu[n]||"manyith"} argument. Expected ${t.join(" or ")} but received ${e}.`)}class Us{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,i=!1){if(v("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let s=0;s<e.length;s++){if(typeof e[s]!=="function")throw Error("middleware must be a function");let r=e[s];r.applyBeforeValidation=t,r.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e==="function"){let s=e;s.applyBeforeValidation=t,s.global=n,s.mutates=i,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((i)=>{let s=[...n[t]||[],t];if(!i.option)return!0;else return!s.includes(i.option)}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();if(e!==void 0)this.globalMiddleware=e}reset(){this.globalMiddleware=this.globalMiddleware.filter((e)=>e.global)}}function Vr(e){if(!e)return[];return e.map((t)=>(t.applyBeforeValidation=!1,t))}function mt(e,t,n,i){return n.reduce((s,r)=>{if(r.applyBeforeValidation!==i)return s;if(r.mutates){if(r.applied)return s;r.applied=!0}if(se(s))return s.then((o)=>Promise.all([o,r(o,t)])).then(([o,a])=>Object.assign(o,a));else{let o=r(s,t);return se(o)?o.then((a)=>Object.assign(s,a)):Object.assign(s,o)}},e)}function Dt(e,t,n=(i)=>{throw i}){try{let i=Xu(e)?e():e;return se(i)?i.then((s)=>t(s)):t(i)}catch(i){return n(i)}}function Xu(e){return typeof e==="function"}var Ut=/(^\*)|(^\$0)/;class Qr{constructor(e,t,n,i){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=i,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,i){i=i||{},this.requireCache.add(n);let s=this.shim.path.resolve(this.shim.path.dirname(n),e),r=this.shim.readdirSync(s,{recursive:i.recurse?!0:!1});if(!Array.isArray(i.extensions))i.extensions=["js"];let o=typeof i.visit==="function"?i.visit:(a)=>a;for(let a of r){let c=a.toString();if(i.exclude){let f=!1;if(typeof i.exclude==="function")f=i.exclude(c);else f=i.exclude.test(c);if(f)continue}if(i.include){let f=!1;if(typeof i.include==="function")f=i.include(c);else f=i.include.test(c);if(!f)continue}let u=!1;for(let f of i.extensions)if(c.endsWith(f))u=!0;if(u){let f=this.shim.path.join(s,c),l=t(f),d=Object.create(null,Object.getOwnPropertyDescriptors({...l}));if(o(d,f,c)){if(this.requireCache.has(f))continue;else this.requireCache.add(f);if(!d.command)d.command=this.shim.path.basename(f,this.shim.path.extname(f));this.addHandler(d)}}}}addHandler(e,t,n,i,s,r){let o=[],a=Vr(s);if(i=i||(()=>{}),Array.isArray(e))if(Gu(e))[e,...o]=e;else for(let c of e)this.addHandler(c);else if(Zu(e)){let c=Array.isArray(e.command)||typeof e.command==="string"?e.command:null;if(c===null)throw Error(`No command name given for module: ${this.shim.inspect(e)}`);if(e.aliases)c=[].concat(c).concat(e.aliases);this.addHandler(c,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(Zr(n)){this.addHandler([e].concat(o),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e==="string"){let c=st(e);o=o.map((l)=>st(l).cmd);let u=!1,f=[c.cmd].concat(o).filter((l)=>{if(Ut.test(l))return u=!0,!1;return!0});if(f.length===0&&u)f.push("$0");if(u)c.cmd=f[0],o=f.slice(1),e=e.replace(Ut,c.cmd);if(o.forEach((l)=>{this.aliasMap[l]=c.cmd}),t!==!1)this.usage.command(e,t,u,o,r);if(this.handlers[c.cmd]={original:e,description:t,handler:i,builder:n||{},middlewares:a,deprecated:r,demanded:c.demanded,optional:c.optional},u)this.defaultCommand=this.handlers[c.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,i,s,r){let o=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,a=t.getInternalMethods().getContext(),c=a.commands.slice(),u=!e;if(e)a.commands.push(e),a.fullCommands.push(o.original);let f=this.applyBuilderUpdateUsageAndParse(u,o,t,n.aliases,c,i,s,r);return se(f)?f.then((l)=>this.applyMiddlewareAndGetResult(u,o,l.innerArgv,a,s,l.aliases,t)):this.applyMiddlewareAndGetResult(u,o,f.innerArgv,a,s,f.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,i,s,r,o,a){let c=t.builder,u=n;if(Tn(c)){n.getInternalMethods().getUsageInstance().freeze();let f=c(n.getInternalMethods().reset(i),a);if(se(f))return f.then((l)=>(u=to(l)?l:n,this.parseAndUpdateUsage(e,t,u,s,r,o)))}else if(Vu(c))n.getInternalMethods().getUsageInstance().freeze(),u=n.getInternalMethods().reset(i),Object.keys(t.builder).forEach((f)=>{u.option(f,c[f])});return this.parseAndUpdateUsage(e,t,u,s,r,o)}parseAndUpdateUsage(e,t,n,i,s,r){if(e)n.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(n))n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(i,t),t.description);let o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,s,r);return se(o)?o.then((a)=>({aliases:n.parsed.aliases,innerArgv:a})):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=Ut.test(t.original)?t.original.replace(Ut,"").trim():t.original,i=e.filter((s)=>!Ut.test(s));return i.push(n),`$0 ${i.join(" ")}`}handleValidationAndGetResult(e,t,n,i,s,r,o,a){if(!r.getInternalMethods().getHasOutput()){let c=r.getInternalMethods().runValidation(s,a,r.parsed.error,e);n=Dt(n,(u)=>(c(u),u))}if(t.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();let c=!!r.getOptions().configuration["populate--"];if(r.getInternalMethods().postProcess(n,c,!1,!1),n=mt(n,r,o,!1),n=Dt(n,(u)=>{let f=t.handler(u);return se(f)?f.then(()=>u):u}),!e)r.getInternalMethods().getUsageInstance().cacheHelpMessage();if(se(n)&&!r.getInternalMethods().hasParseCallback())n.catch((u)=>{try{r.getInternalMethods().getUsageInstance().fail(null,u)}catch(f){}})}if(!e)i.commands.pop(),i.fullCommands.pop();return n}applyMiddlewareAndGetResult(e,t,n,i,s,r,o){let a={};if(s)return n;if(!o.getInternalMethods().getHasOutput())a=this.populatePositionals(t,n,i,o);let c=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),u=mt(n,o,c,!0);return se(u)?u.then((f)=>this.handleValidationAndGetResult(e,t,f,i,r,o,c,a)):this.handleValidationAndGetResult(e,t,u,i,r,o,c,a)}populatePositionals(e,t,n,i){t._=t._.slice(n.commands.length);let s=e.demanded.slice(0),r=e.optional.slice(0),o={};this.validation.positionalCount(s.length,t._.length);while(s.length){let a=s.shift();this.populatePositional(a,t,o)}while(r.length){let a=r.shift();this.populatePositional(a,t,o)}return t._=n.commands.concat(t._.map((a)=>""+a)),this.postProcessPositionals(t,o,this.cmdToParseOptions(e.original),i),o}populatePositional(e,t,n){let i=e.cmd[0];if(e.variadic)n[i]=t._.splice(0).map(String);else if(t._.length)n[i]=[String(t._.shift())]}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=st(e);return n.demanded.forEach((i)=>{let[s,...r]=i.cmd;if(i.variadic)t.array.push(s),t.default[s]=[];t.alias[s]=r,t.demand[s]=!0}),n.optional.forEach((i)=>{let[s,...r]=i.cmd;if(i.variadic)t.array.push(s),t.default[s]=[];t.alias[s]=r}),t}postProcessPositionals(e,t,n,i){let s=Object.assign({},i.getOptions());s.default=Object.assign(n.default,s.default);for(let c of Object.keys(n.alias))s.alias[c]=(s.alias[c]||[]).concat(n.alias[c]);s.array=s.array.concat(n.array),s.config={};let r=[];if(Object.keys(t).forEach((c)=>{t[c].map((u)=>{if(s.configuration["unknown-options-as-args"])s.key[c]=!0;r.push(`--${c}`),r.push(u)})}),!r.length)return;let o=Object.assign({},s.configuration,{"populate--":!1}),a=this.shim.Parser.detailed(r,Object.assign({},s,{configuration:o}));if(a.error)i.getInternalMethods().getUsageInstance().fail(a.error.message,a.error);else{let c=Object.keys(t);Object.keys(t).forEach((u)=>{c.push(...a.aliases[u])}),Object.keys(a.argv).forEach((u)=>{if(c.includes(u)){if(!t[u])t[u]=a.argv[u];if(!this.isInConfigs(i,u)&&!this.isDefaulted(i,u)&&Object.prototype.hasOwnProperty.call(e,u)&&Object.prototype.hasOwnProperty.call(a.argv,u)&&(Array.isArray(e[u])||Array.isArray(a.argv[u])))e[u]=[].concat(e[u],a.argv[u]);else e[u]=a.argv[u]}})}}isDefaulted(e,t){let{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){let{configObjects:n}=e.getOptions();return n.some((i)=>Object.prototype.hasOwnProperty.call(i,t))||n.some((i)=>Object.prototype.hasOwnProperty.call(i,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=Ut.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let t=this.defaultCommand.builder;if(Tn(t))return t(e,!0);else if(!Zr(t))Object.keys(t).forEach((n)=>{e.option(n,t[n])});return}extractDesc({describe:e,description:t,desc:n}){for(let i of[e,t,n]){if(typeof i==="string"||i===!1)return i;Fe(i,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();Fe(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function eo(e,t,n,i){return new Qr(e,t,n,i)}function Zr(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function Gu(e){return e.every((t)=>typeof t==="string")}function Tn(e){return typeof e==="function"}function Vu(e){return typeof e==="object"}function Zu(e){return typeof e==="object"&&!Array.isArray(e)}function it(e={},t=()=>!0){let n={};return Wt(e).forEach((i)=>{if(t(i,e[i]))n[i]=e[i]}),n}function rt(e){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((t)=>{let n=t;if(n._handle&&n.isTTY&&typeof n._handle.setBlocking==="function")n._handle.setBlocking(e)})}function Qu(e){return typeof e==="boolean"}function so(e,t){let n=t.y18n.__,i={},s=[];i.failFn=function(E){s.push(E)};let r=null,o=null,a=!0;i.showHelpOnFail=function(E=!0,O){let[N,Q]=typeof E==="string"?[!0,E]:[E,O];if(e.getInternalMethods().isGlobalContext())o=Q;return r=Q,a=N,i};let c=!1;i.fail=function(E,O){let N=e.getInternalMethods().getLoggerInstance();if(s.length)for(let Q=s.length-1;Q>=0;--Q){let oe=s[Q];if(Qu(oe)){if(O)throw O;else if(E)throw Error(E)}else oe(E,O,i)}else{if(e.getExitProcess())rt(!0);if(!c){if(c=!0,a)e.showHelp("error"),N.error();if(E||O)N.error(E||O);let Q=r||o;if(Q){if(E||O)N.error("");N.error(Q)}}if(O=O||new le(E),e.getExitProcess())return e.exit(1);else if(e.getInternalMethods().hasParseCallback())return e.exit(1,O);else throw O}};let u=[],f=!1;i.usage=(_,E)=>{if(_===null)return f=!0,u=[],i;return f=!1,u.push([_,E||""]),i},i.getUsage=()=>u,i.getUsageDisabled=()=>f,i.getPositionalGroupName=()=>n("Positionals:");let l=[];i.example=(_,E)=>{l.push([_,E||""])};let d=[];i.command=function(E,O,N,Q,oe=!1){if(N)d=d.map((V)=>(V[2]=!1,V));d.push([E,O||"",N,Q,oe])},i.getCommands=()=>d;let p={};i.describe=function(E,O){if(Array.isArray(E))E.forEach((N)=>{i.describe(N,O)});else if(typeof E==="object")Object.keys(E).forEach((N)=>{i.describe(N,E[N])});else p[E]=O},i.getDescriptions=()=>p;let m=[];i.epilog=(_)=>{m.push(_)};let h=!1,y;i.wrap=(_)=>{h=!0,y=_},i.getWrap=()=>{if(t.getEnv("YARGS_DISABLE_WRAP"))return null;if(!h)y=R(),h=!0;return y};let C="__yargsString__:";i.deferY18nLookup=(_)=>C+_,i.help=function(){if(k)return k;S();let E=e.customScriptName?e.$0:t.path.basename(e.$0),O=e.getDemandedOptions(),N=e.getDemandedCommands(),Q=e.getDeprecatedOptions(),oe=e.getGroups(),V=e.getOptions(),ae=[];ae=ae.concat(Object.keys(p)),ae=ae.concat(Object.keys(O)),ae=ae.concat(Object.keys(N)),ae=ae.concat(Object.keys(V.default)),ae=ae.filter(A),ae=Object.keys(ae.reduce((z,te)=>{if(te!=="_")z[te]=!0;return z},{}));let Ie=i.getWrap(),ee=t.cliui({width:Ie,wrap:!!Ie});if(!f){if(u.length)u.forEach((z)=>{if(ee.div({text:`${z[0].replace(/\$0/g,E)}`}),z[1])ee.div({text:`${z[1]}`,padding:[1,0,0,0]})}),ee.div();else if(d.length){let z=null;if(N._)z=`${E} <${n("command")}>
|
|
13
|
+
`).map((i)=>bu(i,t,n)).join(`
|
|
14
|
+
`)}function Is(e){return ir(e,{stringWidth:We,stripAnsi:ht,wrap:Os})}import{dirname as $r,resolve as Or}from"path";import{readdirSync as Fu,statSync as Cu}from"fs";function Ps(e,t){let n=Or(".",e),i;if(!Cu(n).isDirectory())n=$r(n);while(!0){if(i=t(n,Fu(n)),i)return Or(n,i);if(n=$r(i=n),i===n)break}}import{inspect as Lu}from"util";import{fileURLToPath as qr}from"url";import{format as _u}from"util";import{normalize as Su,resolve as ku}from"path";function gt(e){if(!(e!==e.toLowerCase()&&e!==e.toUpperCase()))e=e.toLowerCase();if(e.indexOf("-")===-1&&e.indexOf("_")===-1)return e;else{let n="",i=!1,s=e.match(/^-+/);for(let r=s?s[0].length:0;r<e.length;r++){let o=e.charAt(r);if(i)i=!1,o=o.toUpperCase();if(r!==0&&(o==="-"||o==="_"))i=!0;else if(o!=="-"&&o!=="_")n+=o}return n}}function On(e,t){let n=e.toLowerCase();t=t||"-";let i="";for(let s=0;s<e.length;s++){let r=n.charAt(s),o=e.charAt(s);if(r!==o&&s>0)i+=`${t}${n.charAt(s)}`;else i+=o}return i}function In(e){if(e===null||e===void 0)return!1;if(typeof e==="number")return!0;if(/^0x[0-9a-f]+$/i.test(e))return!0;if(/^0[^.]/.test(e))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function Ir(e){if(Array.isArray(e))return e.map((o)=>typeof o!=="string"?o+"":o);e=e.trim();let t=0,n=null,i=null,s=null,r=[];for(let o=0;o<e.length;o++){if(n=i,i=e.charAt(o),i===" "&&!s){if(n!==" ")t++;continue}if(i===s)s=null;else if((i==="'"||i==='"')&&!s)s=i;if(!r[t])r[t]="";r[t]+=i}return r}var Pe;(function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"})(Pe||(Pe={}));var et;class Rs{constructor(e){et=e}parse(e,t){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),i=Ir(e),s=typeof e==="string",r=Eu(Object.assign(Object.create(null),n.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),a=Object.assign(Object.create(null),n.default),c=n.configObjects||[],u=n.envPrefix,f=o["populate--"],l=f?"--":"_",d=Object.create(null),h=Object.create(null),m=n.__||et.format,p={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:[]},y=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,C=new RegExp("^--"+o["negation-prefix"]+"(.+)");if([].concat(n.array||[]).filter(Boolean).forEach(function(D){let b=typeof D==="object"?D.key:D,T=Object.keys(D).map(function(x){return{boolean:"bools",string:"strings",number:"numbers"}[x]}).filter(Boolean).pop();if(T)p[T][b]=!0;p.arrays[b]=!0,p.keys.push(b)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(D){p.bools[D]=!0,p.keys.push(D)}),[].concat(n.string||[]).filter(Boolean).forEach(function(D){p.strings[D]=!0,p.keys.push(D)}),[].concat(n.number||[]).filter(Boolean).forEach(function(D){p.numbers[D]=!0,p.keys.push(D)}),[].concat(n.count||[]).filter(Boolean).forEach(function(D){p.counts[D]=!0,p.keys.push(D)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(D){p.normalize[D]=!0,p.keys.push(D)}),typeof n.narg==="object")Object.entries(n.narg).forEach(([D,b])=>{if(typeof b==="number")p.nargs[D]=b,p.keys.push(D)});if(typeof n.coerce==="object")Object.entries(n.coerce).forEach(([D,b])=>{if(typeof b==="function")p.coercions[D]=b,p.keys.push(D)});if(typeof n.config<"u"){if(Array.isArray(n.config)||typeof n.config==="string")[].concat(n.config).filter(Boolean).forEach(function(D){p.configs[D]=!0});else if(typeof n.config==="object")Object.entries(n.config).forEach(([D,b])=>{if(typeof b==="boolean"||typeof b==="function")p.configs[D]=b})}Z(n.key,r,n.default,p.arrays),Object.keys(a).forEach(function(D){(p.aliases[D]||[]).forEach(function(b){a[b]=a[D]})});let F=null;_s();let S=[],k=Object.assign(Object.create(null),{_:[]}),j={};for(let D=0;D<i.length;D++){let b=i[D],T=b.replace(/^-{3,}/,"---"),x,w,U,B,J,ge;if(b!=="--"&&/^-/.test(b)&&ne(b))A(b);else if(T.match(/^---+(=|$)/)){A(b);continue}else if(b.match(/^--.+=/)||!o["short-option-groups"]&&b.match(/^-.+=/)){if(B=b.match(/^--?([^=]+)=([\s\S]*)$/),B!==null&&Array.isArray(B)&&B.length>=3)if(W(B[1],p.arrays))D=R(D,B[1],i,B[2]);else if(W(B[1],p.nargs)!==!1)D=M(D,B[1],i,B[2]);else P(B[1],B[2],!0)}else if(b.match(C)&&o["boolean-negation"]){if(B=b.match(C),B!==null&&Array.isArray(B)&&B.length>=2)w=B[1],P(w,W(w,p.arrays)?[!1]:!1)}else if(b.match(/^--.+/)||!o["short-option-groups"]&&b.match(/^-[^-]+/)){if(B=b.match(/^--?(.+)/),B!==null&&Array.isArray(B)&&B.length>=2)if(w=B[1],W(w,p.arrays))D=R(D,w,i);else if(W(w,p.nargs)!==!1)D=M(D,w,i);else if(J=i[D+1],J!==void 0&&(!J.match(/^-/)||J.match(y))&&!W(w,p.bools)&&!W(w,p.counts))P(w,J),D++;else if(/^(true|false)$/.test(J))P(w,J),D++;else P(w,G(w))}else if(b.match(/^-.\..+=/)){if(B=b.match(/^-([^=]+)=([\s\S]*)$/),B!==null&&Array.isArray(B)&&B.length>=3)P(B[1],B[2])}else if(b.match(/^-.\..+/)&&!b.match(y)){if(J=i[D+1],B=b.match(/^-(.\..+)/),B!==null&&Array.isArray(B)&&B.length>=2)if(w=B[1],J!==void 0&&!J.match(/^-/)&&!W(w,p.bools)&&!W(w,p.counts))P(w,J),D++;else P(w,G(w))}else if(b.match(/^-[^-]+/)&&!b.match(y)){U=b.slice(1,-1).split(""),x=!1;for(let be=0;be<U.length;be++){if(J=b.slice(be+2),U[be+1]&&U[be+1]==="="){if(ge=b.slice(be+3),w=U[be],W(w,p.arrays))D=R(D,w,i,ge);else if(W(w,p.nargs)!==!1)D=M(D,w,i,ge);else P(w,ge);x=!0;break}if(J==="-"){P(U[be],J);continue}if(/[A-Za-z]/.test(U[be])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(J)&&W(J,p.bools)===!1){P(U[be],J),x=!0;break}if(U[be+1]&&U[be+1].match(/\W/)){P(U[be],J),x=!0;break}else P(U[be],G(U[be]))}if(w=b.slice(-1)[0],!x&&w!=="-")if(W(w,p.arrays))D=R(D,w,i);else if(W(w,p.nargs)!==!1)D=M(D,w,i);else if(J=i[D+1],J!==void 0&&(!/^(-|--)[^-]/.test(J)||J.match(y))&&!W(w,p.bools)&&!W(w,p.counts))P(w,J),D++;else if(/^(true|false)$/.test(J))P(w,J),D++;else P(w,G(w))}else if(b.match(/^-[0-9]$/)&&b.match(y)&&W(b.slice(1),p.bools))w=b.slice(1),P(w,G(w));else if(b==="--"){S=i.slice(D+1);break}else if(o["halt-at-non-option"]){S=i.slice(D);break}else A(b)}if(oe(k,!0),oe(k,!1),O(k),Q(),Ie(k,p.aliases,a,!0),V(k),o["set-placeholder-key"])ae(k);if(Object.keys(p.counts).forEach(function(D){if(!ee(k,D.split(".")))P(D,0)}),f&&S.length)k[l]=[];if(S.forEach(function(D){k[l].push(D)}),o["camel-case-expansion"]&&o["strip-dashed"])Object.keys(k).filter((D)=>D!=="--"&&D.includes("-")).forEach((D)=>{delete k[D]});if(o["strip-aliased"])[].concat(...Object.keys(r).map((D)=>r[D])).forEach((D)=>{if(o["camel-case-expansion"]&&D.includes("-"))delete k[D.split(".").map((b)=>gt(b)).join(".")];delete k[D]});function A(D){let b=E("_",D);if(typeof b==="string"||typeof b==="number")k._.push(b)}function M(D,b,T,x){let w,U=W(b,p.nargs);if(U=typeof U!=="number"||isNaN(U)?1:U,U===0){if(!pe(x))F=Error(m("Argument unexpected for: %s",b));return P(b,G(b)),D}let B=pe(x)?0:1;if(o["nargs-eats-options"]){if(T.length-(D+1)+B<U)F=Error(m("Not enough arguments following: %s",b));B=U}else{for(w=D+1;w<T.length;w++)if(!T[w].match(/^-[^0-9]/)||T[w].match(y)||ne(T[w]))B++;else break;if(B<U)F=Error(m("Not enough arguments following: %s",b))}let J=Math.min(B,U);if(!pe(x)&&J>0)P(b,x),J--;for(w=D+1;w<J+D+1;w++)P(b,T[w]);return D+J}function R(D,b,T,x){let w=[],U=x||T[D+1],B=W(b,p.nargs);if(W(b,p.bools)&&!/^(true|false)$/.test(U))w.push(!0);else if(pe(U)||pe(x)&&/^-/.test(U)&&!y.test(U)&&!ne(U)){if(a[b]!==void 0){let J=a[b];w=Array.isArray(J)?J:[J]}}else{if(!pe(x))w.push(_(b,x,!0));for(let J=D+1;J<T.length;J++){if(!o["greedy-arrays"]&&w.length>0||B&&typeof B==="number"&&w.length>=B)break;if(U=T[J],/^-/.test(U)&&!y.test(U)&&!ne(U))break;D=J,w.push(_(b,U,s))}}if(typeof B==="number"&&(B&&w.length<B||isNaN(B)&&w.length===0))F=Error(m("Not enough arguments following: %s",b));return P(b,w),D}function P(D,b,T=s){if(/-/.test(D)&&o["camel-case-expansion"]){let U=D.split(".").map(function(B){return gt(B)}).join(".");q(D,U)}let x=_(D,b,T),w=D.split(".");if(_e(k,w,x),p.aliases[D])p.aliases[D].forEach(function(U){let B=U.split(".");_e(k,B,x)});if(w.length>1&&o["dot-notation"])(p.aliases[w[0]]||[]).forEach(function(U){let B=U.split("."),J=[].concat(w);if(J.shift(),B=B.concat(J),!(p.aliases[D]||[]).includes(B.join(".")))_e(k,B,x)});if(W(D,p.normalize)&&!W(D,p.arrays))[D].concat(p.aliases[D]||[]).forEach(function(B){Object.defineProperty(j,B,{enumerable:!0,get(){return b},set(J){b=typeof J==="string"?et.normalize(J):J}})})}function q(D,b){if(!(p.aliases[D]&&p.aliases[D].length))p.aliases[D]=[b],d[b]=!0;if(!(p.aliases[b]&&p.aliases[b].length))q(b,D)}function _(D,b,T){if(T)b=xu(b);if(W(D,p.bools)||W(D,p.counts)){if(typeof b==="string")b=b==="true"}let x=Array.isArray(b)?b.map(function(w){return E(D,w)}):E(D,b);if(W(D,p.counts)&&(pe(x)||typeof x==="boolean"))x=Ts();if(W(D,p.normalize)&&W(D,p.arrays))if(Array.isArray(b))x=b.map((w)=>et.normalize(w));else x=et.normalize(b);return x}function E(D,b){if(!o["parse-positional-numbers"]&&D==="_")return b;if(!W(D,p.strings)&&!W(D,p.bools)&&!Array.isArray(b)){if(In(b)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${b}`)))||!pe(b)&&W(D,p.numbers))b=Number(b)}return b}function O(D){let b=Object.create(null);Ie(b,p.aliases,a),Object.keys(p.configs).forEach(function(T){let x=D[T]||b[T];if(x)try{let w=null,U=et.resolve(et.cwd(),x),B=p.configs[T];if(typeof B==="function"){try{w=B(U)}catch(J){w=J}if(w instanceof Error){F=w;return}}else w=et.require(U);N(w)}catch(w){if(w.name==="PermissionDenied")F=w;else if(D[T])F=Error(m("Invalid JSON config file: %s",x))}})}function N(D,b){Object.keys(D).forEach(function(T){let x=D[T],w=b?b+"."+T:T;if(typeof x==="object"&&x!==null&&!Array.isArray(x)&&o["dot-notation"])N(x,w);else if(!ee(k,w.split("."))||W(w,p.arrays)&&o["combine-arrays"])P(w,x)})}function Q(){if(typeof c<"u")c.forEach(function(D){N(D)})}function oe(D,b){if(typeof u>"u")return;let T=typeof u==="string"?u:"",x=et.env();Object.keys(x).forEach(function(w){if(T===""||w.lastIndexOf(T,0)===0){let U=w.split("__").map(function(B,J){if(J===0)B=B.substring(T.length);return gt(B)});if((b&&p.configs[U.join(".")]||!b)&&!ee(D,U))P(U.join("."),x[w])}})}function V(D){let b,T=new Set;Object.keys(D).forEach(function(x){if(!T.has(x)){if(b=W(x,p.coercions),typeof b==="function")try{let w=E(x,b(D[x]));[].concat(p.aliases[x]||[],x).forEach((U)=>{T.add(U),D[U]=w})}catch(w){F=w}}})}function ae(D){return p.keys.forEach((b)=>{if(~b.indexOf("."))return;if(typeof D[b]>"u")D[b]=void 0}),D}function Ie(D,b,T,x=!1){Object.keys(T).forEach(function(w){if(!ee(D,w.split("."))){if(_e(D,w.split("."),T[w]),x)h[w]=!0;(b[w]||[]).forEach(function(U){if(ee(D,U.split(".")))return;_e(D,U.split("."),T[w])})}})}function ee(D,b){let T=D;if(!o["dot-notation"])b=[b.join(".")];b.slice(0,-1).forEach(function(w){T=T[w]||{}});let x=b[b.length-1];if(typeof T!=="object")return!1;else return x in T}function _e(D,b,T){let x=D;if(!o["dot-notation"])b=[b.join(".")];b.slice(0,-1).forEach(function(ge){if(ge=Pr(ge),typeof x==="object"&&x[ge]===void 0)x[ge]={};if(typeof x[ge]!=="object"||Array.isArray(x[ge])){if(Array.isArray(x[ge]))x[ge].push({});else x[ge]=[x[ge],{}];x=x[ge][x[ge].length-1]}else x=x[ge]});let w=Pr(b[b.length-1]),U=W(b.join("."),p.arrays),B=Array.isArray(T),J=o["duplicate-arguments-array"];if(!J&&W(w,p.nargs)){if(J=!0,!pe(x[w])&&p.nargs[w]===1||Array.isArray(x[w])&&x[w].length===p.nargs[w])x[w]=void 0}if(T===Ts())x[w]=Ts(x[w]);else if(Array.isArray(x[w]))if(J&&U&&B)x[w]=o["flatten-duplicate-arrays"]?x[w].concat(T):(Array.isArray(x[w][0])?x[w]:[x[w]]).concat([T]);else if(!J&&Boolean(U)===Boolean(B))x[w]=T;else x[w]=x[w].concat([T]);else if(x[w]===void 0&&U)x[w]=B?T:[T];else if(J&&!(x[w]===void 0||W(w,p.counts)||W(w,p.bools)))x[w]=[x[w],T];else x[w]=T}function Z(...D){D.forEach(function(b){Object.keys(b||{}).forEach(function(T){if(p.aliases[T])return;p.aliases[T]=[].concat(r[T]||[]),p.aliases[T].concat(T).forEach(function(x){if(/-/.test(x)&&o["camel-case-expansion"]){let w=gt(x);if(w!==T&&p.aliases[T].indexOf(w)===-1)p.aliases[T].push(w),d[w]=!0}}),p.aliases[T].concat(T).forEach(function(x){if(x.length>1&&/[A-Z]/.test(x)&&o["camel-case-expansion"]){let w=On(x,"-");if(w!==T&&p.aliases[T].indexOf(w)===-1)p.aliases[T].push(w),d[w]=!0}}),p.aliases[T].forEach(function(x){p.aliases[x]=[T].concat(p.aliases[T].filter(function(w){return x!==w}))})})})}function W(D,b){let T=[].concat(p.aliases[D]||[],D),x=Object.keys(b),w=T.find((U)=>x.includes(U));return w?b[w]:!1}function Se(D){let b=Object.keys(p);return[].concat(b.map((x)=>p[x])).some(function(x){return Array.isArray(x)?x.includes(D):x[D]})}function Lt(D,...b){return[].concat(...b).some(function(x){let w=D.match(x);return w&&Se(w[1])})}function z(D){if(D.match(y)||!D.match(/^-[^-]+/))return!1;let b=!0,T,x=D.slice(1).split("");for(let w=0;w<x.length;w++){if(T=D.slice(w+2),!Se(x[w])){b=!1;break}if(x[w+1]&&x[w+1]==="="||T==="-"||/[A-Za-z]/.test(x[w])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(T)||x[w+1]&&x[w+1].match(/\W/))break}return b}function ne(D){return o["unknown-options-as-args"]&&de(D)}function de(D){if(D=D.replace(/^-{3,}/,"--"),D.match(y))return!1;if(z(D))return!1;return!Lt(D,/^-+([^=]+?)=[\s\S]*$/,C,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function G(D){if(!W(D,p.bools)&&!W(D,p.counts)&&`${D}`in a)return a[D];else return ye(ue(D))}function ye(D){return{[Pe.BOOLEAN]:!0,[Pe.STRING]:"",[Pe.NUMBER]:void 0,[Pe.ARRAY]:[]}[D]}function ue(D){let b=Pe.BOOLEAN;if(W(D,p.strings))b=Pe.STRING;else if(W(D,p.numbers))b=Pe.NUMBER;else if(W(D,p.bools))b=Pe.BOOLEAN;else if(W(D,p.arrays))b=Pe.ARRAY;return b}function pe(D){return D===void 0}function _s(){Object.keys(p.counts).find((D)=>{if(W(D,p.arrays))return F=Error(m("Invalid configuration: %s, opts.count excludes opts.array.",D)),!0;else if(W(D,p.nargs))return F=Error(m("Invalid configuration: %s, opts.count excludes opts.narg.",D)),!0;return!1})}return{aliases:Object.assign({},p.aliases),argv:Object.assign(j,k),configuration:o,defaulted:Object.assign({},h),error:F,newAliases:Object.assign({},d)}}}function Eu(e){let t=[],n=Object.create(null),i=!0;Object.keys(e).forEach(function(s){t.push([].concat(e[s],s))});while(i){i=!1;for(let s=0;s<t.length;s++)for(let r=s+1;r<t.length;r++)if(t[s].filter(function(a){return t[r].indexOf(a)!==-1}).length){t[s]=t[s].concat(t[r]),t.splice(r,1),i=!0;break}}return t.forEach(function(s){s=s.filter(function(o,a,c){return c.indexOf(o)===a});let r=s.pop();if(r!==void 0&&typeof r==="string")n[r]=s}),n}function Ts(e){return e!==void 0?e+1:1}function Pr(e){if(e==="__proto__")return"___proto___";return e}function xu(e){return typeof e==="string"&&(e[0]==="'"||e[0]==='"')&&e[e.length-1]===e[0]?e.substring(1,e.length-1):e}import{readFileSync as Au}from"fs";import{createRequire as Tr}from"node:module";var Ms,Bs,Ns,Rr=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Mr=(Bs=(Ms=process===null||process===void 0?void 0:process.versions)===null||Ms===void 0?void 0:Ms.node)!==null&&Bs!==void 0?Bs:(Ns=process===null||process===void 0?void 0:process.version)===null||Ns===void 0?void 0:Ns.slice(1);if(Mr){if(Number(Mr.match(/^([^.]+)/)[1])<Rr)throw Error(`yargs parser supports a minimum Node.js version of ${Rr}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var $u=process?process.env:{},Br=Tr?Tr(import.meta.url):void 0,Nr=new Rs({cwd:process.cwd,env:()=>$u,format:_u,normalize:Su,resolve:ku,require:(e)=>{if(typeof Br<"u")return Br(e);else if(e.match(/\.json$/))return JSON.parse(Au(e,"utf8"));else throw Error("only .json config files are supported in ESM")}}),en=function(t,n){return Nr.parse(t.slice(),n).argv};en.detailed=function(e,t){return Nr.parse(e.slice(),t)};en.camelCase=gt;en.decamelize=On;en.looksLikeNumber=In;var vs=en;import{basename as Wu,dirname as Uu,extname as Ku,relative as Ju,resolve as Hr,join as zu}from"path";function vr(){if(Ou())return 0;return 1}function Ou(){return Iu()&&!process.defaultApp}function Iu(){return!!process.versions.electron}function js(e){return e.slice(vr()+1)}function jr(){return process.argv[vr()]}import{readFileSync as Pu,statSync as Tu,writeFile as Ru}from"fs";import{format as Mu}from"util";import{resolve as Bu}from"path";var Lr={fs:{readFileSync:Pu,writeFile:Ru},format:Mu,resolve:Bu,exists:(e)=>{try{return Tu(e).isFile()}catch(t){return!1}}};var Ue;class Wr{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles==="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage==="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let t=e.shift(),n=function(){};if(typeof e[e.length-1]==="function")n=e.pop();if(n=n||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n});else n();return Ue.format.apply(Ue.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),i=e.shift(),s=function(){};if(typeof e[e.length-1]==="function")s=e.pop();if(!this.cache[this.locale])this._readLocaleFile();let r=i===1?t:n;if(this.cache[this.locale][t])r=this.cache[this.locale][t][i===1?"one":"other"];if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:s});else s();let o=[r];if(~r.indexOf("%d"))o.push(i);return Ue.format.apply(Ue.format,o.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){if(!this.cache[this.locale])this._readLocaleFile();for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))this.cache[this.locale][t]=e[t]}_taggedLiteral(e,...t){let n="";return e.forEach(function(i,s){let r=t[s+1];if(n+=i,typeof r<"u")n+="%s"}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){if(this.writeQueue.push(e),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let e=this,t=this.writeQueue[0],n=t.directory,i=t.locale,s=t.cb,r=this._resolveLocaleFile(n,i),o=JSON.stringify(this.cache[i],null,2);Ue.fs.writeFile(r,o,"utf-8",function(a){if(e.writeQueue.shift(),e.writeQueue.length>0)e._processWriteQueue();s(a)})}_readLocaleFile(){let e={},t=this._resolveLocaleFile(this.directory,this.locale);try{if(Ue.fs.readFileSync)e=JSON.parse(Ue.fs.readFileSync(t,"utf-8"))}catch(n){if(n instanceof SyntaxError)n.message="syntax error in "+t;if(n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=Ue.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let i=Ue.resolve(e,"./",t.split("_")[0]+".json");if(this._fileExistsSync(i))n=i}return n}_fileExistsSync(e){return Ue.exists(e)}}function Ur(e,t){Ue=t;let n=new Wr(e);return{__:n.__.bind(n),__n:n.__n.bind(n),setLocale:n.setLocale.bind(n),getLocale:n.getLocale.bind(n),updateLocale:n.updateLocale.bind(n),locale:n.locale}}var Nu=(e)=>Ur(e,Lr),Kr=Nu;var Yr=er(zr(),1);import{createRequire as Hu}from"node:module";import{readFileSync as qu,readdirSync as Yu}from"node:fs";var Ls=qr(import.meta.url),Xu=Ls.substring(0,Ls.lastIndexOf("node_modules")),Gu=Hu(import.meta.url),Ws={assert:{notStrictEqual:vu,strictEqual:ju},cliui:Is,findUp:Ps,getEnv:(e)=>process.env[e],inspect:Lu,getProcessArgvBin:jr,mainFilename:Xu||process.cwd(),Parser:vs,path:{basename:Wu,dirname:Uu,extname:Ku,relative:Ju,resolve:Hr,join:zu},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(e,t)=>process.emitWarning(e,t),execPath:()=>process.execPath,exit:(e)=>{process.exit(e)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:qu,readdirSync:Yu,require:Gu,getCallerFile:()=>{let e=Yr.default(3);return e.match(/^file:\/\//)?qr(e):e},stringWidth:We,y18n:Kr({directory:Hr(Ls,"../../../locales"),updateFiles:!1})};function Fe(e,t,n,i){n.assert.notStrictEqual(e,t,i)}function Us(e,t){t.assert.strictEqual(typeof e,"string")}function Wt(e){return Object.keys(e)}function se(e){return!!e&&!!e.then&&typeof e.then==="function"}class le extends Error{constructor(e){super(e||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,le)}}function st(e){let n=e.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),i=/\.*[\][<>]/g,s=n.shift();if(!s)throw Error(`No command found in: ${e}`);let r={cmd:s.replace(i,""),demanded:[],optional:[]};return n.forEach((o,a)=>{let c=!1;if(o=o.replace(/\s/g,""),/\.+[\]>]/.test(o)&&a===n.length-1)c=!0;if(/^\[/.test(o))r.optional.push({cmd:o.replace(i,"").split("|"),variadic:c});else r.demanded.push({cmd:o.replace(i,"").split("|"),variadic:c})}),r}var Vu=["first","second","third","fourth","fifth","sixth"];function v(e,t,n){function i(){return typeof e==="object"?[{demanded:[],optional:[]},e,t]:[st(`cmd ${e}`),t,n]}try{let s=0,[r,o,a]=i(),c=[].slice.call(o);while(c.length&&c[c.length-1]===void 0)c.pop();let u=a||c.length;if(u<r.demanded.length)throw new le(`Not enough arguments provided. Expected ${r.demanded.length} but received ${c.length}.`);let f=r.demanded.length+r.optional.length;if(u>f)throw new le(`Too many arguments provided. Expected max ${f} but received ${u}.`);r.demanded.forEach((l)=>{let d=c.shift(),h=Xr(d);if(l.cmd.filter((p)=>p===h||p==="*").length===0)Gr(h,l.cmd,s);s+=1}),r.optional.forEach((l)=>{if(c.length===0)return;let d=c.shift(),h=Xr(d);if(l.cmd.filter((p)=>p===h||p==="*").length===0)Gr(h,l.cmd,s);s+=1})}catch(s){console.warn(s.stack)}}function Xr(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function Gr(e,t,n){throw new le(`Invalid ${Vu[n]||"manyith"} argument. Expected ${t.join(" or ")} but received ${e}.`)}class Ks{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,i=!1){if(v("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let s=0;s<e.length;s++){if(typeof e[s]!=="function")throw Error("middleware must be a function");let r=e[s];r.applyBeforeValidation=t,r.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e==="function"){let s=e;s.applyBeforeValidation=t,s.global=n,s.mutates=i,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((i)=>{let s=[...n[t]||[],t];if(!i.option)return!0;else return!s.includes(i.option)}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();if(e!==void 0)this.globalMiddleware=e}reset(){this.globalMiddleware=this.globalMiddleware.filter((e)=>e.global)}}function Vr(e){if(!e)return[];return e.map((t)=>(t.applyBeforeValidation=!1,t))}function mt(e,t,n,i){return n.reduce((s,r)=>{if(r.applyBeforeValidation!==i)return s;if(r.mutates){if(r.applied)return s;r.applied=!0}if(se(s))return s.then((o)=>Promise.all([o,r(o,t)])).then(([o,a])=>Object.assign(o,a));else{let o=r(s,t);return se(o)?o.then((a)=>Object.assign(s,a)):Object.assign(s,o)}},e)}function Dt(e,t,n=(i)=>{throw i}){try{let i=Zu(e)?e():e;return se(i)?i.then((s)=>t(s)):t(i)}catch(i){return n(i)}}function Zu(e){return typeof e==="function"}var Ut=/(^\*)|(^\$0)/;class Qr{constructor(e,t,n,i){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=i,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,i){i=i||{},this.requireCache.add(n);let s=this.shim.path.resolve(this.shim.path.dirname(n),e),r=this.shim.readdirSync(s,{recursive:i.recurse?!0:!1});if(!Array.isArray(i.extensions))i.extensions=["js"];let o=typeof i.visit==="function"?i.visit:(a)=>a;for(let a of r){let c=a.toString();if(i.exclude){let f=!1;if(typeof i.exclude==="function")f=i.exclude(c);else f=i.exclude.test(c);if(f)continue}if(i.include){let f=!1;if(typeof i.include==="function")f=i.include(c);else f=i.include.test(c);if(!f)continue}let u=!1;for(let f of i.extensions)if(c.endsWith(f))u=!0;if(u){let f=this.shim.path.join(s,c),l=t(f),d=Object.create(null,Object.getOwnPropertyDescriptors({...l}));if(o(d,f,c)){if(this.requireCache.has(f))continue;else this.requireCache.add(f);if(!d.command)d.command=this.shim.path.basename(f,this.shim.path.extname(f));this.addHandler(d)}}}}addHandler(e,t,n,i,s,r){let o=[],a=Vr(s);if(i=i||(()=>{}),Array.isArray(e))if(Qu(e))[e,...o]=e;else for(let c of e)this.addHandler(c);else if(tl(e)){let c=Array.isArray(e.command)||typeof e.command==="string"?e.command:null;if(c===null)throw Error(`No command name given for module: ${this.shim.inspect(e)}`);if(e.aliases)c=[].concat(c).concat(e.aliases);this.addHandler(c,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(Zr(n)){this.addHandler([e].concat(o),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e==="string"){let c=st(e);o=o.map((l)=>st(l).cmd);let u=!1,f=[c.cmd].concat(o).filter((l)=>{if(Ut.test(l))return u=!0,!1;return!0});if(f.length===0&&u)f.push("$0");if(u)c.cmd=f[0],o=f.slice(1),e=e.replace(Ut,c.cmd);if(o.forEach((l)=>{this.aliasMap[l]=c.cmd}),t!==!1)this.usage.command(e,t,u,o,r);if(this.handlers[c.cmd]={original:e,description:t,handler:i,builder:n||{},middlewares:a,deprecated:r,demanded:c.demanded,optional:c.optional},u)this.defaultCommand=this.handlers[c.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,i,s,r){let o=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,a=t.getInternalMethods().getContext(),c=a.commands.slice(),u=!e;if(e)a.commands.push(e),a.fullCommands.push(o.original);let f=this.applyBuilderUpdateUsageAndParse(u,o,t,n.aliases,c,i,s,r);return se(f)?f.then((l)=>this.applyMiddlewareAndGetResult(u,o,l.innerArgv,a,s,l.aliases,t)):this.applyMiddlewareAndGetResult(u,o,f.innerArgv,a,s,f.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,i,s,r,o,a){let c=t.builder,u=n;if(Pn(c)){n.getInternalMethods().getUsageInstance().freeze();let f=c(n.getInternalMethods().reset(i),a);if(se(f))return f.then((l)=>(u=to(l)?l:n,this.parseAndUpdateUsage(e,t,u,s,r,o)))}else if(el(c))n.getInternalMethods().getUsageInstance().freeze(),u=n.getInternalMethods().reset(i),Object.keys(t.builder).forEach((f)=>{u.option(f,c[f])});return this.parseAndUpdateUsage(e,t,u,s,r,o)}parseAndUpdateUsage(e,t,n,i,s,r){if(e)n.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(n))n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(i,t),t.description);let o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,s,r);return se(o)?o.then((a)=>({aliases:n.parsed.aliases,innerArgv:a})):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=Ut.test(t.original)?t.original.replace(Ut,"").trim():t.original,i=e.filter((s)=>!Ut.test(s));return i.push(n),`$0 ${i.join(" ")}`}handleValidationAndGetResult(e,t,n,i,s,r,o,a){if(!r.getInternalMethods().getHasOutput()){let c=r.getInternalMethods().runValidation(s,a,r.parsed.error,e);n=Dt(n,(u)=>(c(u),u))}if(t.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();let c=!!r.getOptions().configuration["populate--"];if(r.getInternalMethods().postProcess(n,c,!1,!1),n=mt(n,r,o,!1),n=Dt(n,(u)=>{let f=t.handler(u);return se(f)?f.then(()=>u):u}),!e)r.getInternalMethods().getUsageInstance().cacheHelpMessage();if(se(n)&&!r.getInternalMethods().hasParseCallback())n.catch((u)=>{try{r.getInternalMethods().getUsageInstance().fail(null,u)}catch(f){}})}if(!e)i.commands.pop(),i.fullCommands.pop();return n}applyMiddlewareAndGetResult(e,t,n,i,s,r,o){let a={};if(s)return n;if(!o.getInternalMethods().getHasOutput())a=this.populatePositionals(t,n,i,o);let c=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),u=mt(n,o,c,!0);return se(u)?u.then((f)=>this.handleValidationAndGetResult(e,t,f,i,r,o,c,a)):this.handleValidationAndGetResult(e,t,u,i,r,o,c,a)}populatePositionals(e,t,n,i){t._=t._.slice(n.commands.length);let s=e.demanded.slice(0),r=e.optional.slice(0),o={};this.validation.positionalCount(s.length,t._.length);while(s.length){let a=s.shift();this.populatePositional(a,t,o)}while(r.length){let a=r.shift();this.populatePositional(a,t,o)}return t._=n.commands.concat(t._.map((a)=>""+a)),this.postProcessPositionals(t,o,this.cmdToParseOptions(e.original),i),o}populatePositional(e,t,n){let i=e.cmd[0];if(e.variadic)n[i]=t._.splice(0).map(String);else if(t._.length)n[i]=[String(t._.shift())]}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=st(e);return n.demanded.forEach((i)=>{let[s,...r]=i.cmd;if(i.variadic)t.array.push(s),t.default[s]=[];t.alias[s]=r,t.demand[s]=!0}),n.optional.forEach((i)=>{let[s,...r]=i.cmd;if(i.variadic)t.array.push(s),t.default[s]=[];t.alias[s]=r}),t}postProcessPositionals(e,t,n,i){let s=Object.assign({},i.getOptions());s.default=Object.assign(n.default,s.default);for(let c of Object.keys(n.alias))s.alias[c]=(s.alias[c]||[]).concat(n.alias[c]);s.array=s.array.concat(n.array),s.config={};let r=[];if(Object.keys(t).forEach((c)=>{t[c].map((u)=>{if(s.configuration["unknown-options-as-args"])s.key[c]=!0;r.push(`--${c}`),r.push(u)})}),!r.length)return;let o=Object.assign({},s.configuration,{"populate--":!1}),a=this.shim.Parser.detailed(r,Object.assign({},s,{configuration:o}));if(a.error)i.getInternalMethods().getUsageInstance().fail(a.error.message,a.error);else{let c=Object.keys(t);Object.keys(t).forEach((u)=>{c.push(...a.aliases[u])}),Object.keys(a.argv).forEach((u)=>{if(c.includes(u)){if(!t[u])t[u]=a.argv[u];if(!this.isInConfigs(i,u)&&!this.isDefaulted(i,u)&&Object.prototype.hasOwnProperty.call(e,u)&&Object.prototype.hasOwnProperty.call(a.argv,u)&&(Array.isArray(e[u])||Array.isArray(a.argv[u])))e[u]=[].concat(e[u],a.argv[u]);else e[u]=a.argv[u]}})}}isDefaulted(e,t){let{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){let{configObjects:n}=e.getOptions();return n.some((i)=>Object.prototype.hasOwnProperty.call(i,t))||n.some((i)=>Object.prototype.hasOwnProperty.call(i,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=Ut.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let t=this.defaultCommand.builder;if(Pn(t))return t(e,!0);else if(!Zr(t))Object.keys(t).forEach((n)=>{e.option(n,t[n])});return}extractDesc({describe:e,description:t,desc:n}){for(let i of[e,t,n]){if(typeof i==="string"||i===!1)return i;Fe(i,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();Fe(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function eo(e,t,n,i){return new Qr(e,t,n,i)}function Zr(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function Qu(e){return e.every((t)=>typeof t==="string")}function Pn(e){return typeof e==="function"}function el(e){return typeof e==="object"}function tl(e){return typeof e==="object"&&!Array.isArray(e)}function it(e={},t=()=>!0){let n={};return Wt(e).forEach((i)=>{if(t(i,e[i]))n[i]=e[i]}),n}function rt(e){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((t)=>{let n=t;if(n._handle&&n.isTTY&&typeof n._handle.setBlocking==="function")n._handle.setBlocking(e)})}function nl(e){return typeof e==="boolean"}function so(e,t){let n=t.y18n.__,i={},s=[];i.failFn=function(E){s.push(E)};let r=null,o=null,a=!0;i.showHelpOnFail=function(E=!0,O){let[N,Q]=typeof E==="string"?[!0,E]:[E,O];if(e.getInternalMethods().isGlobalContext())o=Q;return r=Q,a=N,i};let c=!1;i.fail=function(E,O){let N=e.getInternalMethods().getLoggerInstance();if(s.length)for(let Q=s.length-1;Q>=0;--Q){let oe=s[Q];if(nl(oe)){if(O)throw O;else if(E)throw Error(E)}else oe(E,O,i)}else{if(e.getExitProcess())rt(!0);if(!c){if(c=!0,a)e.showHelp("error"),N.error();if(E||O)N.error(E||O);let Q=r||o;if(Q){if(E||O)N.error("");N.error(Q)}}if(O=O||new le(E),e.getExitProcess())return e.exit(1);else if(e.getInternalMethods().hasParseCallback())return e.exit(1,O);else throw O}};let u=[],f=!1;i.usage=(_,E)=>{if(_===null)return f=!0,u=[],i;return f=!1,u.push([_,E||""]),i},i.getUsage=()=>u,i.getUsageDisabled=()=>f,i.getPositionalGroupName=()=>n("Positionals:");let l=[];i.example=(_,E)=>{l.push([_,E||""])};let d=[];i.command=function(E,O,N,Q,oe=!1){if(N)d=d.map((V)=>(V[2]=!1,V));d.push([E,O||"",N,Q,oe])},i.getCommands=()=>d;let h={};i.describe=function(E,O){if(Array.isArray(E))E.forEach((N)=>{i.describe(N,O)});else if(typeof E==="object")Object.keys(E).forEach((N)=>{i.describe(N,E[N])});else h[E]=O},i.getDescriptions=()=>h;let m=[];i.epilog=(_)=>{m.push(_)};let p=!1,y;i.wrap=(_)=>{p=!0,y=_},i.getWrap=()=>{if(t.getEnv("YARGS_DISABLE_WRAP"))return null;if(!p)y=R(),p=!0;return y};let C="__yargsString__:";i.deferY18nLookup=(_)=>C+_,i.help=function(){if(k)return k;S();let E=e.customScriptName?e.$0:t.path.basename(e.$0),O=e.getDemandedOptions(),N=e.getDemandedCommands(),Q=e.getDeprecatedOptions(),oe=e.getGroups(),V=e.getOptions(),ae=[];ae=ae.concat(Object.keys(h)),ae=ae.concat(Object.keys(O)),ae=ae.concat(Object.keys(N)),ae=ae.concat(Object.keys(V.default)),ae=ae.filter(A),ae=Object.keys(ae.reduce((z,ne)=>{if(ne!=="_")z[ne]=!0;return z},{}));let Ie=i.getWrap(),ee=t.cliui({width:Ie,wrap:!!Ie});if(!f){if(u.length)u.forEach((z)=>{if(ee.div({text:`${z[0].replace(/\$0/g,E)}`}),z[1])ee.div({text:`${z[1]}`,padding:[1,0,0,0]})}),ee.div();else if(d.length){let z=null;if(N._)z=`${E} <${n("command")}>
|
|
15
15
|
`;else z=`${E} [${n("command")}]
|
|
16
|
-
`;ee.div(`${z}`)}}if(d.length>1||d.length===1&&!d[0][2]){ee.div(n("Commands:"));let z=e.getInternalMethods().getContext(),
|
|
16
|
+
`;ee.div(`${z}`)}}if(d.length>1||d.length===1&&!d[0][2]){ee.div(n("Commands:"));let z=e.getInternalMethods().getContext(),ne=z.commands.length?`${z.commands.join(" ")} `:"";if(e.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)d=d.sort((G,ye)=>G[0].localeCompare(ye[0]));let de=E?`${E} `:"";d.forEach((G)=>{let ye=`${de}${ne}${G[0].replace(/^\$0 ?/,"")}`;ee.span({text:ye,padding:[0,2,0,2],width:F(d,Ie,`${E}${ne}`)+4},{text:G[1]});let ue=[];if(G[2])ue.push(`[${n("default")}]`);if(G[3]&&G[3].length)ue.push(`[${n("aliases:")} ${G[3].join(", ")}]`);if(G[4])if(typeof G[4]==="string")ue.push(`[${n("deprecated: %s",G[4])}]`);else ue.push(`[${n("deprecated")}]`);if(ue.length)ee.div({text:ue.join(" "),padding:[0,0,0,2],align:"right"});else ee.div()}),ee.div()}let _e=(Object.keys(V.alias)||[]).concat(Object.keys(e.parsed.newAliases)||[]);ae=ae.filter((z)=>!e.parsed.newAliases[z]&&_e.every((ne)=>(V.alias[ne]||[]).indexOf(z)===-1));let Z=n("Options:");if(!oe[Z])oe[Z]=[];j(ae,V.alias,oe,Z);let W=(z)=>/^--/.test(Tn(z)),Se=Object.keys(oe).filter((z)=>oe[z].length>0).map((z)=>{let ne=oe[z].filter(A).map((de)=>{if(_e.includes(de))return de;for(let G=0,ye;(ye=_e[G])!==void 0;G++)if((V.alias[ye]||[]).includes(de))return ye;return de});return{groupName:z,normalizedKeys:ne}}).filter(({normalizedKeys:z})=>z.length>0).map(({groupName:z,normalizedKeys:ne})=>{let de=ne.reduce((G,ye)=>(G[ye]=[ye].concat(V.alias[ye]||[]).map((ue)=>{if(z===i.getPositionalGroupName())return ue;else return(/^[0-9]$/.test(ue)?V.boolean.includes(ye)?"-":"--":ue.length>1?"--":"-")+ue}).sort((ue,pe)=>W(ue)===W(pe)?0:W(ue)?1:-1).join(", "),G),{});return{groupName:z,normalizedKeys:ne,switches:de}});if(Se.filter(({groupName:z})=>z!==i.getPositionalGroupName()).some(({normalizedKeys:z,switches:ne})=>!z.every((de)=>W(ne[de]))))Se.filter(({groupName:z})=>z!==i.getPositionalGroupName()).forEach(({normalizedKeys:z,switches:ne})=>{z.forEach((de)=>{if(W(ne[de]))ne[de]=sl(ne[de],4)})});if(Se.forEach(({groupName:z,normalizedKeys:ne,switches:de})=>{ee.div(z),ne.forEach((G)=>{let ye=de[G],ue=h[G]||"",pe=null;if(ue.includes(C))ue=n(ue.substring(C.length));if(V.boolean.includes(G))pe=`[${n("boolean")}]`;if(V.count.includes(G))pe=`[${n("count")}]`;if(V.string.includes(G))pe=`[${n("string")}]`;if(V.normalize.includes(G))pe=`[${n("string")}]`;if(V.array.includes(G))pe=`[${n("array")}]`;if(V.number.includes(G))pe=`[${n("number")}]`;let _s=(T)=>typeof T==="string"?`[${n("deprecated: %s",T)}]`:`[${n("deprecated")}]`,D=[G in Q?_s(Q[G]):null,pe,G in O?`[${n("required")}]`:null,V.choices&&V.choices[G]?`[${n("choices:")} ${i.stringifiedValues(V.choices[G])}]`:null,M(V.default[G],V.defaultDescription[G])].filter(Boolean).join(" ");ee.span({text:Tn(ye),padding:[0,2,0,2+no(ye)],width:F(de,Ie)+4},ue);let b=e.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(D&&!b)ee.div({text:D,padding:[0,0,0,2],align:"right"});else ee.div()}),ee.div()}),l.length)ee.div(n("Examples:")),l.forEach((z)=>{z[0]=z[0].replace(/\$0/g,E)}),l.forEach((z)=>{if(z[1]==="")ee.div({text:z[0],padding:[0,2,0,2]});else ee.div({text:z[0],padding:[0,2,0,2],width:F(l,Ie)+4},{text:z[1]})}),ee.div();if(m.length>0){let z=m.map((ne)=>ne.replace(/\$0/g,E)).join(`
|
|
17
17
|
`);ee.div(`${z}
|
|
18
|
-
`)}return ee.toString().replace(/\s*$/,"")};function F(_,E,O){let N=0;if(!Array.isArray(_))_=Object.values(_).map((Q)=>[Q]);if(_.forEach((Q)=>{N=Math.max(t.stringWidth(O?`${O} ${
|
|
18
|
+
`)}return ee.toString().replace(/\s*$/,"")};function F(_,E,O){let N=0;if(!Array.isArray(_))_=Object.values(_).map((Q)=>[Q]);if(_.forEach((Q)=>{N=Math.max(t.stringWidth(O?`${O} ${Tn(Q[0])}`:Tn(Q[0]))+no(Q[0]),N)}),E)N=Math.min(N,parseInt((E*0.5).toString(),10));return N}function S(){let _=e.getDemandedOptions(),E=e.getOptions();(Object.keys(E.alias)||[]).forEach((O)=>{E.alias[O].forEach((N)=>{if(h[N])i.describe(O,h[N]);if(N in _)e.demandOption(O,_[N]);if(E.boolean.includes(N))e.boolean(O);if(E.count.includes(N))e.count(O);if(E.string.includes(N))e.string(O);if(E.normalize.includes(N))e.normalize(O);if(E.array.includes(N))e.array(O);if(E.number.includes(N))e.number(O)})})}let k;i.cacheHelpMessage=function(){k=this.help()},i.clearCachedHelpMessage=function(){k=void 0},i.hasCachedHelpMessage=function(){return!!k};function j(_,E,O,N){let Q=[],oe=null;return Object.keys(O).forEach((V)=>{Q=Q.concat(O[V])}),_.forEach((V)=>{if(oe=[V].concat(E[V]),!oe.some((ae)=>Q.indexOf(ae)!==-1))O[N].push(V)}),Q}function A(_){return e.getOptions().hiddenOptions.indexOf(_)<0||e.parsed.argv[e.getOptions().showHiddenOpt]}i.showHelp=(_)=>{let E=e.getInternalMethods().getLoggerInstance();if(!_)_="error";(typeof _==="function"?_:E[_])(i.help())},i.functionDescription=(_)=>["(",_.name?t.Parser.decamelize(_.name,"-"):n("generated-value"),")"].join(""),i.stringifiedValues=function(E,O){let N="",Q=O||", ",oe=[].concat(E);if(!E||!oe.length)return N;return oe.forEach((V)=>{if(N.length)N+=Q;N+=JSON.stringify(V)}),N};function M(_,E){let O=`[${n("default:")} `;if(_===void 0&&!E)return null;if(E)O+=E;else switch(typeof _){case"string":O+=`"${_}"`;break;case"object":O+=JSON.stringify(_);break;default:O+=_}return`${O}]`}function R(){if(t.process.stdColumns)return Math.min(80,t.process.stdColumns);else return 80}let P=null;i.version=(_)=>{P=_},i.showVersion=(_)=>{let E=e.getInternalMethods().getLoggerInstance();if(!_)_="error";(typeof _==="function"?_:E[_])(P)},i.reset=function(E){return r=null,c=!1,u=[],f=!1,m=[],l=[],d=[],h=it(h,(O)=>!E[O]),i};let q=[];return i.freeze=function(){q.push({failMessage:r,failureOutput:c,usages:u,usageDisabled:f,epilogs:m,examples:l,commands:d,descriptions:h})},i.unfreeze=function(E=!1){let O=q.pop();if(!O)return;if(E)h={...O.descriptions,...h},d=[...O.commands,...d],u=[...O.usages,...u],l=[...O.examples,...l],m=[...O.epilogs,...m];else({failMessage:r,failureOutput:c,usages:u,usageDisabled:f,epilogs:m,examples:l,commands:d,descriptions:h}=O)},i}function Js(e){return typeof e==="object"}function sl(e,t){return Js(e)?{text:e.text,indentation:e.indentation+t}:{text:e,indentation:t}}function no(e){return Js(e)?e.indentation:0}function Tn(e){return Js(e)?e.text:e}var io=`###-begin-{{app_name}}-completions-###
|
|
19
19
|
#
|
|
20
20
|
# yargs command completion script
|
|
21
21
|
#
|
|
@@ -71,141 +71,144 @@ else
|
|
|
71
71
|
compdef _{{app_name}}_yargs_completions {{app_name}}
|
|
72
72
|
fi
|
|
73
73
|
###-end-{{app_name}}-completions-###
|
|
74
|
-
`;class oo{constructor(e,t,n,i){var s,r,o;this.yargs=e,this.usage=t,this.command=n,this.shim=i,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(o=((s=this.shim.getEnv("SHELL"))===null||s===void 0?void 0:s.includes("zsh"))||((r=this.shim.getEnv("ZSH_NAME"))===null||r===void 0?void 0:r.includes("zsh")))!==null&&o!==void 0?o:!1}defaultCompletion(e,t,n,i){let s=this.command.getCommandHandlers();for(let o=0,a=e.length;o<a;++o)if(s[e[o]]&&s[e[o]].builder){let c=s[e[o]].builder;if(
|
|
74
|
+
`;class oo{constructor(e,t,n,i){var s,r,o;this.yargs=e,this.usage=t,this.command=n,this.shim=i,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(o=((s=this.shim.getEnv("SHELL"))===null||s===void 0?void 0:s.includes("zsh"))||((r=this.shim.getEnv("ZSH_NAME"))===null||r===void 0?void 0:r.includes("zsh")))!==null&&o!==void 0?o:!1}defaultCompletion(e,t,n,i){let s=this.command.getCommandHandlers();for(let o=0,a=e.length;o<a;++o)if(s[e[o]]&&s[e[o]].builder){let c=s[e[o]].builder;if(Pn(c)){this.indexAfterLastReset=o+1;let u=this.yargs.getInternalMethods().reset();return c(u,!0),u.argv}}let r=[];this.commandCompletions(r,e,n),this.optionCompletions(r,e,t,n),this.choicesFromOptionsCompletions(r,e,t,n),this.choicesFromPositionalsCompletions(r,e,t,n),i(null,r)}commandCompletions(e,t,n){let i=this.yargs.getInternalMethods().getContext().commands;if(!n.match(/^-/)&&i[i.length-1]!==n&&!this.previousArgHasChoices(t))this.usage.getCommands().forEach((s)=>{let r=st(s[0]).cmd;if(t.indexOf(r)===-1)if(!this.zshShell)e.push(r);else{let o=s[1]||"";e.push(r.replace(/:/g,"\\:")+":"+o)}})}optionCompletions(e,t,n,i){if((i.match(/^-/)||i===""&&e.length===0)&&!this.previousArgHasChoices(t)){let s=this.yargs.getOptions(),r=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(s.key).forEach((o)=>{let a=!!s.configuration["boolean-negation"]&&s.boolean.includes(o);if(!r.includes(o)&&!s.hiddenOptions.includes(o)&&!this.argsContainKey(t,o,a))this.completeOptionKey(o,e,i,a&&!!s.default[o])})}}choicesFromOptionsCompletions(e,t,n,i){if(this.previousArgHasChoices(t)){let s=this.getPreviousArgChoices(t);if(s&&s.length>0)e.push(...s.map((r)=>r.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,t,n,i){if(i===""&&e.length>0&&this.previousArgHasChoices(t))return;let s=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],r=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=s[n._.length-r-1];if(!o)return;let a=this.yargs.getOptions().choices[o]||[];for(let c of a)if(c.startsWith(i))e.push(c.replace(/:/g,"\\:"))}getPreviousArgChoices(e){if(e.length<1)return;let t=e[e.length-1],n="";if(!t.startsWith("-")&&e.length>1)n=t,t=e[e.length-2];if(!t.startsWith("-"))return;let i=t.replace(/^-+/,""),s=this.yargs.getOptions(),r=[i,...this.yargs.getAliases()[i]||[]],o;for(let a of r)if(Object.prototype.hasOwnProperty.call(s.key,a)&&Array.isArray(s.choices[a])){o=s.choices[a];break}if(o)return o.filter((a)=>!n||a.startsWith(n))}previousArgHasChoices(e){let t=this.getPreviousArgChoices(e);return t!==void 0&&t.length>0}argsContainKey(e,t,n){let i=(s)=>e.indexOf((/^[^0-9]$/.test(s)?"-":"--")+s)!==-1;if(i(t))return!0;if(n&&i(`no-${t}`))return!0;if(this.aliases){for(let s of this.aliases[t])if(i(s))return!0}return!1}completeOptionKey(e,t,n,i){var s,r,o,a;let c=e;if(this.zshShell){let d=this.usage.getDescriptions(),h=(r=(s=this===null||this===void 0?void 0:this.aliases)===null||s===void 0?void 0:s[e])===null||r===void 0?void 0:r.find((y)=>{let C=d[y];return typeof C==="string"&&C.length>0}),m=h?d[h]:void 0,p=(a=(o=d[e])!==null&&o!==void 0?o:m)!==null&&a!==void 0?a:"";c=`${e.replace(/:/g,"\\:")}:${p.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let u=(d)=>/^--/.test(d),f=(d)=>/^[^0-9]$/.test(d),l=!u(n)&&f(e)?"-":"--";if(t.push(l+c),i)t.push(l+"no-"+c)}customCompletion(e,t,n,i){if(Fe(this.customCompletionFunction,null,this.shim),rl(this.customCompletionFunction)){let s=this.customCompletionFunction(n,t);if(se(s))return s.then((r)=>{this.shim.process.nextTick(()=>{i(null,r)})}).catch((r)=>{this.shim.process.nextTick(()=>{i(r,void 0)})});return i(null,s)}else if(ol(this.customCompletionFunction))return this.customCompletionFunction(n,t,(s=i)=>this.defaultCompletion(e,t,n,s),(s)=>{i(null,s)});else return this.customCompletionFunction(n,t,(s)=>{i(null,s)})}getCompletion(e,t){let n=e.length?e[e.length-1]:"",i=this.yargs.parse(e,!0),s=this.customCompletionFunction?(r)=>this.customCompletion(e,r,n,t):(r)=>this.defaultCompletion(e,r,n,t);return se(i)?i.then(s):s(i)}generateCompletionScript(e,t){let n=this.zshShell?ro:io,i=this.shim.path.basename(e);if(e.match(/\.js$/))e=`./${e}`;return n=n.replace(/{{app_name}}/g,i),n=n.replace(/{{completion_command}}/g,t),n.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}}function ao(e,t,n,i){return new oo(e,t,n,i)}function rl(e){return e.length<3}function ol(e){return e.length>3}function co(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let n=[],i;for(i=0;i<=t.length;i++)n[i]=[i];let s;for(s=0;s<=e.length;s++)n[0][s]=s;for(i=1;i<=t.length;i++)for(s=1;s<=e.length;s++)if(t.charAt(i-1)===e.charAt(s-1))n[i][s]=n[i-1][s-1];else if(i>1&&s>1&&t.charAt(i-2)===e.charAt(s-1)&&t.charAt(i-1)===e.charAt(s-2))n[i][s]=n[i-2][s-2]+1;else n[i][s]=Math.min(n[i-1][s-1]+1,Math.min(n[i][s-1]+1,n[i-1][s]+1));return n[t.length][e.length]}var uo=["$0","--","_"];function lo(e,t,n){let i=n.y18n.__,s=n.y18n.__n,r={};r.nonOptionCount=function(l){let d=e.getDemandedCommands(),m=l._.length+(l["--"]?l["--"].length:0)-e.getInternalMethods().getContext().commands.length;if(d._&&(m<d._.min||m>d._.max)){if(m<d._.min)if(d._.minMsg!==void 0)t.fail(d._.minMsg?d._.minMsg.replace(/\$0/g,m.toString()).replace(/\$1/,d._.min.toString()):null);else t.fail(s("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",m,m.toString(),d._.min.toString()));else if(m>d._.max)if(d._.maxMsg!==void 0)t.fail(d._.maxMsg?d._.maxMsg.replace(/\$0/g,m.toString()).replace(/\$1/,d._.max.toString()):null);else t.fail(s("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",m,m.toString(),d._.max.toString()))}},r.positionalCount=function(l,d){if(d<l)t.fail(s("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",d,d+"",l+""))},r.requiredArguments=function(l,d){let h=null;for(let m of Object.keys(d))if(!Object.prototype.hasOwnProperty.call(l,m)||typeof l[m]>"u")h=h||{},h[m]=d[m];if(h){let m=[];for(let y of Object.keys(h)){let C=h[y];if(C&&m.indexOf(C)<0)m.push(C)}let p=m.length?`
|
|
75
75
|
${m.join(`
|
|
76
|
-
`)}`:"";t.fail(s("Missing required argument: %s","Missing required arguments: %s",Object.keys(
|
|
77
|
-
${i("Argument: %s, Given: %s, Choices: %s",y,t.stringifiedValues(
|
|
78
|
-
`;d.forEach((m)=>{p+=m}),t.fail(p)}};let c={};r.conflicts=function(l,d){if(v("<string|object> [array|string]",[l,d],arguments.length),typeof l==="object")Object.keys(l).forEach((p)=>{r.conflicts(p,l[p])});else{if(e.global(l),!c[l])c[l]=[];if(Array.isArray(d))d.forEach((p)=>r.conflicts(l,p));else c[l].push(d)}},r.getConflicting=()=>c,r.conflicting=function(l){if(Object.keys(l).forEach((d)=>{if(c[d])c[d].forEach((p)=>{if(p&&l[d]!==void 0&&l[p]!==void 0)t.fail(i("Arguments %s and %s are mutually exclusive",d,p))})}),e.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(c).forEach((d)=>{c[d].forEach((p)=>{if(p&&l[n.Parser.camelCase(d)]!==void 0&&l[n.Parser.camelCase(p)]!==void 0)t.fail(i("Arguments %s and %s are mutually exclusive",d,p))})})},r.recommendCommands=function(l,d){d=d.sort((y,C)=>C.length-y.length);let m=null,h=1/0;for(let y=0,C;(C=d[y])!==void 0;y++){let F=co(l,C);if(F<=3&&F<h)h=F,m=C}if(m)t.fail(i("Did you mean %s?",m))},r.reset=function(l){return o=it(o,(d)=>!l[d]),c=it(c,(d)=>!l[d]),r};let u=[];return r.freeze=function(){u.push({implied:o,conflicting:c})},r.unfreeze=function(){let l=u.pop();Fe(l,void 0,n),{implied:o,conflicting:c}=l},r}var Ks=[],tn;function nn(e,t,n,i){tn=i;let s={};if(Object.prototype.hasOwnProperty.call(e,"extends")){if(typeof e.extends!=="string")return s;let r=/\.json|\..*rc$/.test(e.extends),o=null;if(!r)try{o=import.meta.resolve(e.extends)}catch(a){return e}else o=rl(t,e.extends);il(o),Ks.push(o),s=r?JSON.parse(tn.readFileSync(o,"utf8")):i.require(e.extends),delete e.extends,s=nn(s,tn.path.dirname(o),n,tn)}return Ks=[],n?fo(s,e):Object.assign({},s,e)}function il(e){if(Ks.indexOf(e)>-1)throw new le(`Circular extended configurations: '${e}'.`)}function rl(e,t){return tn.path.resolve(e,t)}function fo(e,t){let n={};function i(s){return s&&typeof s==="object"&&!Array.isArray(s)}Object.assign(n,e);for(let s of Object.keys(t))if(i(t[s])&&i(n[s]))n[s]=fo(e[s],t[s]);else n[s]=t[s];return n}var L=function(e,t,n,i,s){if(i==="m")throw TypeError("Private method is not writable");if(i==="a"&&!s)throw TypeError("Private accessor was defined without a setter");if(typeof t==="function"?e!==t||!s:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(e,n):s?s.value=n:t.set(e,n),n},g=function(e,t,n,i){if(n==="a"&&!i)throw TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!i:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(e):i?i.value:t.get(e)},fe,yt,sn,Ee,Ae,Rn,ot,wt,Mn,Pe,Bn,Re,Xe,$e,Me,Nn,bt,me,J,vn,jn,Oe,Ft,Jt,Ct,at,Ln,H,Et,xt,_t,Y,Wn,Ge,ce;function To(e){return(t=[],n=e.process.cwd(),i)=>{let s=new Po(t,n,i,e);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s}}var po=Symbol("copyDoubleDash"),ho=Symbol("copyDoubleDash"),zs=Symbol("deleteFromParserHintObject"),go=Symbol("emitWarning"),mo=Symbol("freeze"),Do=Symbol("getDollarZero"),St=Symbol("getParserConfiguration"),yo=Symbol("getUsageConfiguration"),Hs=Symbol("guessLocale"),wo=Symbol("guessVersion"),bo=Symbol("parsePositionalNumbers"),qs=Symbol("pkgUp"),ct=Symbol("populateParserHintArray"),Kt=Symbol("populateParserHintSingleValueDictionary"),Ys=Symbol("populateParserHintArrayDictionary"),Xs=Symbol("populateParserHintDictionary"),Gs=Symbol("sanitizeKey"),Vs=Symbol("setKey"),Zs=Symbol("unfreeze"),Fo=Symbol("validateAsync"),Co=Symbol("getCommandInstance"),Eo=Symbol("getContext"),xo=Symbol("getHasOutput"),_o=Symbol("getLoggerInstance"),So=Symbol("getParseContext"),ko=Symbol("getUsageInstance"),Ao=Symbol("getValidationInstance"),Un=Symbol("hasParseCallback"),$o=Symbol("isGlobalContext"),kt=Symbol("postProcess"),Oo=Symbol("rebase"),Qs=Symbol("reset"),rn=Symbol("runYargsParserAndExecuteCommands"),ei=Symbol("runValidation"),Io=Symbol("setHasOutput"),At=Symbol("kTrackManuallySetKeys"),ol="en_US";class Po{constructor(e=[],t,n,i){this.customScriptName=!1,this.parsed=!1,fe.set(this,void 0),yt.set(this,void 0),sn.set(this,{commands:[],fullCommands:[]}),Ee.set(this,null),Ae.set(this,null),Rn.set(this,"show-hidden"),ot.set(this,null),wt.set(this,!0),Mn.set(this,{}),Pe.set(this,!0),Bn.set(this,[]),Re.set(this,void 0),Xe.set(this,{}),$e.set(this,!1),Me.set(this,null),Nn.set(this,!0),bt.set(this,void 0),me.set(this,""),J.set(this,void 0),vn.set(this,void 0),jn.set(this,{}),Oe.set(this,null),Ft.set(this,null),Jt.set(this,{}),Ct.set(this,{}),at.set(this,void 0),Ln.set(this,!1),H.set(this,void 0),Et.set(this,!1),xt.set(this,!1),_t.set(this,!1),Y.set(this,void 0),Wn.set(this,{}),Ge.set(this,null),ce.set(this,void 0),L(this,H,i,"f"),L(this,at,e,"f"),L(this,yt,t,"f"),L(this,vn,n,"f"),L(this,Re,new Us(this),"f"),this.$0=this[Do](),this[Qs](),L(this,fe,g(this,fe,"f"),"f"),L(this,Y,g(this,Y,"f"),"f"),L(this,ce,g(this,ce,"f"),"f"),L(this,J,g(this,J,"f"),"f"),g(this,J,"f").showHiddenOpt=g(this,Rn,"f"),L(this,bt,this[ho](),"f"),g(this,H,"f").y18n.setLocale(ol)}addHelpOpt(e,t){if(v("[string|boolean] [string]",[e,t],arguments.length),g(this,Me,"f"))this[zs](g(this,Me,"f")),L(this,Me,null,"f");if(e===!1&&t===void 0)return this;return L(this,Me,typeof e==="string"?e:"help","f"),this.boolean(g(this,Me,"f")),this.describe(g(this,Me,"f"),t||g(this,Y,"f").deferY18nLookup("Show help")),this}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(v("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==="string"?e:g(this,Rn,"f");return this.boolean(n),this.describe(n,t||g(this,Y,"f").deferY18nLookup("Show hidden options")),g(this,J,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return v("<object|string|array> [string|array]",[e,t],arguments.length),this[Ys](this.alias.bind(this),"alias",e,t),this}array(e){return v("<array|string>",[e],arguments.length),this[ct]("array",e),this[At](e),this}boolean(e){return v("<array|string>",[e],arguments.length),this[ct]("boolean",e),this[At](e),this}check(e,t){return v("<function> [boolean]",[e,t],arguments.length),this.middleware((n,i)=>Dt(()=>e(n,i.getOptions()),(s)=>{if(!s)g(this,Y,"f").fail(g(this,H,"f").y18n.__("Argument check failed: %s",e.toString()));else if(typeof s==="string"||s instanceof Error)g(this,Y,"f").fail(s.toString(),s);return n},(s)=>(g(this,Y,"f").fail(s.message?s.message:s.toString(),s),n)),!1,t),this}choices(e,t){return v("<object|string|array> [string|array]",[e,t],arguments.length),this[Ys](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(v("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new le("coerce callback must be provided");for(let i of e)this.coerce(i,t);return this}else if(typeof e==="object"){for(let i of Object.keys(e))this.coerce(i,e[i]);return this}if(!t)throw new le("coerce callback must be provided");let n=e;return g(this,J,"f").key[n]=!0,g(this,Re,"f").addCoerceMiddleware((i,s)=>{var r;let o=(r=s.getAliases()[n])!==null&&r!==void 0?r:[],a=[n,...o].filter((c)=>Object.prototype.hasOwnProperty.call(i,c));if(a.length===0)return i;return Dt(()=>t(i[a[0]]),(c)=>(a.forEach((u)=>{i[u]=c}),i),(c)=>{throw new le(c.message)})},n),this}conflicts(e,t){return v("<string|object> [string|array]",[e,t],arguments.length),g(this,ce,"f").conflicts(e,t),this}config(e="config",t,n){if(v("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e==="object"&&!Array.isArray(e))return e=nn(e,g(this,yt,"f"),this[St]()["deep-merge-config"]||!1,g(this,H,"f")),g(this,J,"f").configObjects=(g(this,J,"f").configObjects||[]).concat(e),this;if(typeof t==="function")n=t,t=void 0;return this.describe(e,t||g(this,Y,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach((i)=>{g(this,J,"f").config[i]=n||!0}),this}completion(e,t,n){if(v("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t==="function")n=t,t=void 0;if(L(this,Ae,e||g(this,Ae,"f")||"completion","f"),!t&&t!==!1)t="generate completion script";if(this.command(g(this,Ae,"f"),t),n)g(this,Ee,"f").registerFunction(n);return this}command(e,t,n,i,s,r){return v("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,i,s,r],arguments.length),g(this,fe,"f").addHandler(e,t,n,i,s,r),this}commands(e,t,n,i,s,r){return this.command(e,t,n,i,s,r)}commandDir(e,t){v("<string> [object]",[e,t],arguments.length);let n=g(this,vn,"f")||g(this,H,"f").require;return g(this,fe,"f").addDirectory(e,n,g(this,H,"f").getCallerFile(),t),this}count(e){return v("<array|string>",[e],arguments.length),this[ct]("count",e),this[At](e),this}default(e,t,n){if(v("<object|string|array> [*] [string]",[e,t,n],arguments.length),n)Ws(e,g(this,H,"f")),g(this,J,"f").defaultDescription[e]=n;if(typeof t==="function"){if(Ws(e,g(this,H,"f")),!g(this,J,"f").defaultDescription[e])g(this,J,"f").defaultDescription[e]=g(this,Y,"f").functionDescription(t);t=t.call()}return this[Kt](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,i){if(v("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,i],arguments.length),typeof t!=="number")n=t,t=1/0;return this.global("_",!1),g(this,J,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:i},this}demand(e,t,n){if(Array.isArray(t))t.forEach((i)=>{Fe(n,!0,g(this,H,"f")),this.demandOption(i,n)}),t=1/0;else if(typeof t!=="number")n=t,t=1/0;if(typeof e==="number")Fe(n,!0,g(this,H,"f")),this.demandCommand(e,t,n,n);else if(Array.isArray(e))e.forEach((i)=>{Fe(n,!0,g(this,H,"f")),this.demandOption(i,n)});else if(typeof n==="string")this.demandOption(e,n);else if(n===!0||typeof n>"u")this.demandOption(e);return this}demandOption(e,t){return v("<object|string|array> [string]",[e,t],arguments.length),this[Kt](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return v("<string> [string|boolean]",[e,t],arguments.length),g(this,J,"f").deprecatedOptions[e]=t,this}describe(e,t){return v("<object|string|array> [string]",[e,t],arguments.length),this[Vs](e,!0),g(this,Y,"f").describe(e,t),this}detectLocale(e){return v("<boolean>",[e],arguments.length),L(this,wt,e,"f"),this}env(e){if(v("[string|boolean]",[e],arguments.length),e===!1)delete g(this,J,"f").envPrefix;else g(this,J,"f").envPrefix=e||"";return this}epilogue(e){return v("<string>",[e],arguments.length),g(this,Y,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){if(v("<string|array> [string]",[e,t],arguments.length),Array.isArray(e))e.forEach((n)=>this.example(...n));else g(this,Y,"f").example(e,t);return this}exit(e,t){if(L(this,$e,!0,"f"),L(this,ot,t,"f"),g(this,Pe,"f"))g(this,H,"f").process.exit(e)}exitProcess(e=!0){return v("[boolean]",[e],arguments.length),L(this,Pe,e,"f"),this}fail(e){if(v("<function|boolean>",[e],arguments.length),typeof e==="boolean"&&e!==!1)throw new le("Invalid first argument. Expected function or boolean 'false'");return g(this,Y,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){if(v("<array> [function]",[e,t],arguments.length),!t)return new Promise((n,i)=>{g(this,Ee,"f").getCompletion(e,(s,r)=>{if(s)i(s);else n(r)})});else return g(this,Ee,"f").getCompletion(e,t)}getDemandedOptions(){return v([],0),g(this,J,"f").demandedOptions}getDemandedCommands(){return v([],0),g(this,J,"f").demandedCommands}getDeprecatedOptions(){return v([],0),g(this,J,"f").deprecatedOptions}getDetectLocale(){return g(this,wt,"f")}getExitProcess(){return g(this,Pe,"f")}getGroups(){return Object.assign({},g(this,Xe,"f"),g(this,Ct,"f"))}getHelp(){if(L(this,$e,!0,"f"),!g(this,Y,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[rn](g(this,at,"f"),void 0,void 0,0,!0);if(se(t))return t.then(()=>g(this,Y,"f").help())}let e=g(this,fe,"f").runDefaultBuilderOn(this);if(se(e))return e.then(()=>g(this,Y,"f").help())}return Promise.resolve(g(this,Y,"f").help())}getOptions(){return g(this,J,"f")}getStrict(){return g(this,Et,"f")}getStrictCommands(){return g(this,xt,"f")}getStrictOptions(){return g(this,_t,"f")}global(e,t){if(v("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1)g(this,J,"f").local=g(this,J,"f").local.filter((n)=>e.indexOf(n)===-1);else e.forEach((n)=>{if(!g(this,J,"f").local.includes(n))g(this,J,"f").local.push(n)});return this}group(e,t){v("<string|array> <string>",[e,t],arguments.length);let n=g(this,Ct,"f")[t]||g(this,Xe,"f")[t];if(g(this,Ct,"f")[t])delete g(this,Ct,"f")[t];let i={};return g(this,Xe,"f")[t]=(n||[]).concat(e).filter((s)=>{if(i[s])return!1;return i[s]=!0}),this}hide(e){return v("<string>",[e],arguments.length),g(this,J,"f").hiddenOptions.push(e),this}implies(e,t){return v("<string|object> [number|string|array]",[e,t],arguments.length),g(this,ce,"f").implies(e,t),this}locale(e){if(v("[string]",[e],arguments.length),e===void 0)return this[Hs](),g(this,H,"f").y18n.getLocale();return L(this,wt,!1,"f"),g(this,H,"f").y18n.setLocale(e),this}middleware(e,t,n){return g(this,Re,"f").addMiddleware(e,!!t,n)}nargs(e,t){return v("<string|object|array> [number]",[e,t],arguments.length),this[Kt](this.nargs.bind(this),"narg",e,t),this}normalize(e){return v("<array|string>",[e],arguments.length),this[ct]("normalize",e),this}number(e){return v("<array|string>",[e],arguments.length),this[ct]("number",e),this[At](e),this}option(e,t){if(v("<string|object> [object]",[e,t],arguments.length),typeof e==="object")Object.keys(e).forEach((n)=>{this.options(n,e[n])});else{if(typeof t!=="object")t={};if(this[At](e),g(this,Ge,"f")&&(e==="version"||(t===null||t===void 0?void 0:t.alias)==="version"))this[go](['"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(g(this,
|
|
76
|
+
`)}`:"";t.fail(s("Missing required argument: %s","Missing required arguments: %s",Object.keys(h).length,Object.keys(h).join(", ")+p))}},r.unknownArguments=function(l,d,h,m,p=!0){var y;let C=e.getInternalMethods().getCommandInstance().getCommands(),F=[],S=e.getInternalMethods().getContext();if(Object.keys(l).forEach((k)=>{if(!uo.includes(k)&&!Object.prototype.hasOwnProperty.call(h,k)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),k)&&!r.isValidAndSomeAliasIsNotNew(k,d))F.push(k)}),p&&(S.commands.length>0||C.length>0||m))l._.slice(S.commands.length).forEach((k)=>{if(!C.includes(""+k))F.push(""+k)});if(p){let j=((y=e.getDemandedCommands()._)===null||y===void 0?void 0:y.max)||0,A=S.commands.length+j;if(A<l._.length)l._.slice(A).forEach((M)=>{if(M=String(M),!S.commands.includes(M)&&!F.includes(M))F.push(M)})}if(F.length)t.fail(s("Unknown argument: %s","Unknown arguments: %s",F.length,F.map((k)=>k.trim()?k:`"${k}"`).join(", ")))},r.unknownCommands=function(l){let d=e.getInternalMethods().getCommandInstance().getCommands(),h=[],m=e.getInternalMethods().getContext();if(m.commands.length>0||d.length>0)l._.slice(m.commands.length).forEach((p)=>{if(!d.includes(""+p))h.push(""+p)});if(h.length>0)return t.fail(s("Unknown command: %s","Unknown commands: %s",h.length,h.join(", "))),!0;else return!1},r.isValidAndSomeAliasIsNotNew=function(l,d){if(!Object.prototype.hasOwnProperty.call(d,l))return!1;let h=e.parsed.newAliases;return[l,...d[l]].some((m)=>!Object.prototype.hasOwnProperty.call(h,m)||!h[l])},r.limitedChoices=function(l){let d=e.getOptions(),h={};if(!Object.keys(d.choices).length)return;Object.keys(l).forEach((y)=>{if(uo.indexOf(y)===-1&&Object.prototype.hasOwnProperty.call(d.choices,y))[].concat(l[y]).forEach((C)=>{if(d.choices[y].indexOf(C)===-1&&C!==void 0)h[y]=(h[y]||[]).concat(C)})});let m=Object.keys(h);if(!m.length)return;let p=i("Invalid values:");m.forEach((y)=>{p+=`
|
|
77
|
+
${i("Argument: %s, Given: %s, Choices: %s",y,t.stringifiedValues(h[y]),t.stringifiedValues(d.choices[y]))}`}),t.fail(p)};let o={};r.implies=function(l,d){if(v("<string|object> [array|number|string]",[l,d],arguments.length),typeof l==="object")Object.keys(l).forEach((h)=>{r.implies(h,l[h])});else{if(e.global(l),!o[l])o[l]=[];if(Array.isArray(d))d.forEach((h)=>r.implies(l,h));else Fe(d,void 0,n),o[l].push(d)}},r.getImplied=function(){return o};function a(f,l){let d=Number(l);if(l=isNaN(d)?l:d,typeof l==="number")l=f._.length>=l;else if(l.match(/^--no-.+/))l=l.match(/^--no-(.+)/)[1],l=!Object.prototype.hasOwnProperty.call(f,l);else l=Object.prototype.hasOwnProperty.call(f,l);return l}r.implications=function(l){let d=[];if(Object.keys(o).forEach((h)=>{let m=h;(o[h]||[]).forEach((p)=>{let y=m,C=p;if(y=a(l,y),p=a(l,p),y&&!p)d.push(` ${m} -> ${C}`)})}),d.length){let h=`${i("Implications failed:")}
|
|
78
|
+
`;d.forEach((m)=>{h+=m}),t.fail(h)}};let c={};r.conflicts=function(l,d){if(v("<string|object> [array|string]",[l,d],arguments.length),typeof l==="object")Object.keys(l).forEach((h)=>{r.conflicts(h,l[h])});else{if(e.global(l),!c[l])c[l]=[];if(Array.isArray(d))d.forEach((h)=>r.conflicts(l,h));else c[l].push(d)}},r.getConflicting=()=>c,r.conflicting=function(l){if(Object.keys(l).forEach((d)=>{if(c[d])c[d].forEach((h)=>{if(h&&l[d]!==void 0&&l[h]!==void 0)t.fail(i("Arguments %s and %s are mutually exclusive",d,h))})}),e.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(c).forEach((d)=>{c[d].forEach((h)=>{if(h&&l[n.Parser.camelCase(d)]!==void 0&&l[n.Parser.camelCase(h)]!==void 0)t.fail(i("Arguments %s and %s are mutually exclusive",d,h))})})},r.recommendCommands=function(l,d){d=d.sort((y,C)=>C.length-y.length);let m=null,p=1/0;for(let y=0,C;(C=d[y])!==void 0;y++){let F=co(l,C);if(F<=3&&F<p)p=F,m=C}if(m)t.fail(i("Did you mean %s?",m))},r.reset=function(l){return o=it(o,(d)=>!l[d]),c=it(c,(d)=>!l[d]),r};let u=[];return r.freeze=function(){u.push({implied:o,conflicting:c})},r.unfreeze=function(){let l=u.pop();Fe(l,void 0,n),{implied:o,conflicting:c}=l},r}var zs=[],tn;function nn(e,t,n,i){tn=i;let s={};if(Object.prototype.hasOwnProperty.call(e,"extends")){if(typeof e.extends!=="string")return s;let r=/\.json|\..*rc$/.test(e.extends),o=null;if(!r)try{o=import.meta.resolve(e.extends)}catch(a){return e}else o=cl(t,e.extends);al(o),zs.push(o),s=r?JSON.parse(tn.readFileSync(o,"utf8")):i.require(e.extends),delete e.extends,s=nn(s,tn.path.dirname(o),n,tn)}return zs=[],n?fo(s,e):Object.assign({},s,e)}function al(e){if(zs.indexOf(e)>-1)throw new le(`Circular extended configurations: '${e}'.`)}function cl(e,t){return tn.path.resolve(e,t)}function fo(e,t){let n={};function i(s){return s&&typeof s==="object"&&!Array.isArray(s)}Object.assign(n,e);for(let s of Object.keys(t))if(i(t[s])&&i(n[s]))n[s]=fo(e[s],t[s]);else n[s]=t[s];return n}var L=function(e,t,n,i,s){if(i==="m")throw TypeError("Private method is not writable");if(i==="a"&&!s)throw TypeError("Private accessor was defined without a setter");if(typeof t==="function"?e!==t||!s:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(e,n):s?s.value=n:t.set(e,n),n},g=function(e,t,n,i){if(n==="a"&&!i)throw TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!i:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(e):i?i.value:t.get(e)},fe,yt,sn,Ee,Ae,Rn,ot,wt,Mn,Te,Bn,Re,Xe,$e,Me,Nn,bt,me,K,vn,jn,Oe,Ft,Kt,Ct,at,Ln,H,Et,xt,_t,Y,Wn,Ge,ce;function Po(e){return(t=[],n=e.process.cwd(),i)=>{let s=new To(t,n,i,e);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s}}var po=Symbol("copyDoubleDash"),ho=Symbol("copyDoubleDash"),Hs=Symbol("deleteFromParserHintObject"),go=Symbol("emitWarning"),mo=Symbol("freeze"),Do=Symbol("getDollarZero"),St=Symbol("getParserConfiguration"),yo=Symbol("getUsageConfiguration"),qs=Symbol("guessLocale"),wo=Symbol("guessVersion"),bo=Symbol("parsePositionalNumbers"),Ys=Symbol("pkgUp"),ct=Symbol("populateParserHintArray"),Jt=Symbol("populateParserHintSingleValueDictionary"),Xs=Symbol("populateParserHintArrayDictionary"),Gs=Symbol("populateParserHintDictionary"),Vs=Symbol("sanitizeKey"),Zs=Symbol("setKey"),Qs=Symbol("unfreeze"),Fo=Symbol("validateAsync"),Co=Symbol("getCommandInstance"),Eo=Symbol("getContext"),xo=Symbol("getHasOutput"),_o=Symbol("getLoggerInstance"),So=Symbol("getParseContext"),ko=Symbol("getUsageInstance"),Ao=Symbol("getValidationInstance"),Un=Symbol("hasParseCallback"),$o=Symbol("isGlobalContext"),kt=Symbol("postProcess"),Oo=Symbol("rebase"),ei=Symbol("reset"),rn=Symbol("runYargsParserAndExecuteCommands"),ti=Symbol("runValidation"),Io=Symbol("setHasOutput"),At=Symbol("kTrackManuallySetKeys"),ul="en_US";class To{constructor(e=[],t,n,i){this.customScriptName=!1,this.parsed=!1,fe.set(this,void 0),yt.set(this,void 0),sn.set(this,{commands:[],fullCommands:[]}),Ee.set(this,null),Ae.set(this,null),Rn.set(this,"show-hidden"),ot.set(this,null),wt.set(this,!0),Mn.set(this,{}),Te.set(this,!0),Bn.set(this,[]),Re.set(this,void 0),Xe.set(this,{}),$e.set(this,!1),Me.set(this,null),Nn.set(this,!0),bt.set(this,void 0),me.set(this,""),K.set(this,void 0),vn.set(this,void 0),jn.set(this,{}),Oe.set(this,null),Ft.set(this,null),Kt.set(this,{}),Ct.set(this,{}),at.set(this,void 0),Ln.set(this,!1),H.set(this,void 0),Et.set(this,!1),xt.set(this,!1),_t.set(this,!1),Y.set(this,void 0),Wn.set(this,{}),Ge.set(this,null),ce.set(this,void 0),L(this,H,i,"f"),L(this,at,e,"f"),L(this,yt,t,"f"),L(this,vn,n,"f"),L(this,Re,new Ks(this),"f"),this.$0=this[Do](),this[ei](),L(this,fe,g(this,fe,"f"),"f"),L(this,Y,g(this,Y,"f"),"f"),L(this,ce,g(this,ce,"f"),"f"),L(this,K,g(this,K,"f"),"f"),g(this,K,"f").showHiddenOpt=g(this,Rn,"f"),L(this,bt,this[ho](),"f"),g(this,H,"f").y18n.setLocale(ul)}addHelpOpt(e,t){if(v("[string|boolean] [string]",[e,t],arguments.length),g(this,Me,"f"))this[Hs](g(this,Me,"f")),L(this,Me,null,"f");if(e===!1&&t===void 0)return this;return L(this,Me,typeof e==="string"?e:"help","f"),this.boolean(g(this,Me,"f")),this.describe(g(this,Me,"f"),t||g(this,Y,"f").deferY18nLookup("Show help")),this}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(v("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==="string"?e:g(this,Rn,"f");return this.boolean(n),this.describe(n,t||g(this,Y,"f").deferY18nLookup("Show hidden options")),g(this,K,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return v("<object|string|array> [string|array]",[e,t],arguments.length),this[Xs](this.alias.bind(this),"alias",e,t),this}array(e){return v("<array|string>",[e],arguments.length),this[ct]("array",e),this[At](e),this}boolean(e){return v("<array|string>",[e],arguments.length),this[ct]("boolean",e),this[At](e),this}check(e,t){return v("<function> [boolean]",[e,t],arguments.length),this.middleware((n,i)=>Dt(()=>e(n,i.getOptions()),(s)=>{if(!s)g(this,Y,"f").fail(g(this,H,"f").y18n.__("Argument check failed: %s",e.toString()));else if(typeof s==="string"||s instanceof Error)g(this,Y,"f").fail(s.toString(),s);return n},(s)=>(g(this,Y,"f").fail(s.message?s.message:s.toString(),s),n)),!1,t),this}choices(e,t){return v("<object|string|array> [string|array]",[e,t],arguments.length),this[Xs](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(v("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new le("coerce callback must be provided");for(let i of e)this.coerce(i,t);return this}else if(typeof e==="object"){for(let i of Object.keys(e))this.coerce(i,e[i]);return this}if(!t)throw new le("coerce callback must be provided");let n=e;return g(this,K,"f").key[n]=!0,g(this,Re,"f").addCoerceMiddleware((i,s)=>{var r;let o=(r=s.getAliases()[n])!==null&&r!==void 0?r:[],a=[n,...o].filter((c)=>Object.prototype.hasOwnProperty.call(i,c));if(a.length===0)return i;return Dt(()=>t(i[a[0]]),(c)=>(a.forEach((u)=>{i[u]=c}),i),(c)=>{throw new le(c.message)})},n),this}conflicts(e,t){return v("<string|object> [string|array]",[e,t],arguments.length),g(this,ce,"f").conflicts(e,t),this}config(e="config",t,n){if(v("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e==="object"&&!Array.isArray(e))return e=nn(e,g(this,yt,"f"),this[St]()["deep-merge-config"]||!1,g(this,H,"f")),g(this,K,"f").configObjects=(g(this,K,"f").configObjects||[]).concat(e),this;if(typeof t==="function")n=t,t=void 0;return this.describe(e,t||g(this,Y,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach((i)=>{g(this,K,"f").config[i]=n||!0}),this}completion(e,t,n){if(v("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t==="function")n=t,t=void 0;if(L(this,Ae,e||g(this,Ae,"f")||"completion","f"),!t&&t!==!1)t="generate completion script";if(this.command(g(this,Ae,"f"),t),n)g(this,Ee,"f").registerFunction(n);return this}command(e,t,n,i,s,r){return v("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,i,s,r],arguments.length),g(this,fe,"f").addHandler(e,t,n,i,s,r),this}commands(e,t,n,i,s,r){return this.command(e,t,n,i,s,r)}commandDir(e,t){v("<string> [object]",[e,t],arguments.length);let n=g(this,vn,"f")||g(this,H,"f").require;return g(this,fe,"f").addDirectory(e,n,g(this,H,"f").getCallerFile(),t),this}count(e){return v("<array|string>",[e],arguments.length),this[ct]("count",e),this[At](e),this}default(e,t,n){if(v("<object|string|array> [*] [string]",[e,t,n],arguments.length),n)Us(e,g(this,H,"f")),g(this,K,"f").defaultDescription[e]=n;if(typeof t==="function"){if(Us(e,g(this,H,"f")),!g(this,K,"f").defaultDescription[e])g(this,K,"f").defaultDescription[e]=g(this,Y,"f").functionDescription(t);t=t.call()}return this[Jt](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,i){if(v("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,i],arguments.length),typeof t!=="number")n=t,t=1/0;return this.global("_",!1),g(this,K,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:i},this}demand(e,t,n){if(Array.isArray(t))t.forEach((i)=>{Fe(n,!0,g(this,H,"f")),this.demandOption(i,n)}),t=1/0;else if(typeof t!=="number")n=t,t=1/0;if(typeof e==="number")Fe(n,!0,g(this,H,"f")),this.demandCommand(e,t,n,n);else if(Array.isArray(e))e.forEach((i)=>{Fe(n,!0,g(this,H,"f")),this.demandOption(i,n)});else if(typeof n==="string")this.demandOption(e,n);else if(n===!0||typeof n>"u")this.demandOption(e);return this}demandOption(e,t){return v("<object|string|array> [string]",[e,t],arguments.length),this[Jt](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return v("<string> [string|boolean]",[e,t],arguments.length),g(this,K,"f").deprecatedOptions[e]=t,this}describe(e,t){return v("<object|string|array> [string]",[e,t],arguments.length),this[Zs](e,!0),g(this,Y,"f").describe(e,t),this}detectLocale(e){return v("<boolean>",[e],arguments.length),L(this,wt,e,"f"),this}env(e){if(v("[string|boolean]",[e],arguments.length),e===!1)delete g(this,K,"f").envPrefix;else g(this,K,"f").envPrefix=e||"";return this}epilogue(e){return v("<string>",[e],arguments.length),g(this,Y,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){if(v("<string|array> [string]",[e,t],arguments.length),Array.isArray(e))e.forEach((n)=>this.example(...n));else g(this,Y,"f").example(e,t);return this}exit(e,t){if(L(this,$e,!0,"f"),L(this,ot,t,"f"),g(this,Te,"f"))g(this,H,"f").process.exit(e)}exitProcess(e=!0){return v("[boolean]",[e],arguments.length),L(this,Te,e,"f"),this}fail(e){if(v("<function|boolean>",[e],arguments.length),typeof e==="boolean"&&e!==!1)throw new le("Invalid first argument. Expected function or boolean 'false'");return g(this,Y,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){if(v("<array> [function]",[e,t],arguments.length),!t)return new Promise((n,i)=>{g(this,Ee,"f").getCompletion(e,(s,r)=>{if(s)i(s);else n(r)})});else return g(this,Ee,"f").getCompletion(e,t)}getDemandedOptions(){return v([],0),g(this,K,"f").demandedOptions}getDemandedCommands(){return v([],0),g(this,K,"f").demandedCommands}getDeprecatedOptions(){return v([],0),g(this,K,"f").deprecatedOptions}getDetectLocale(){return g(this,wt,"f")}getExitProcess(){return g(this,Te,"f")}getGroups(){return Object.assign({},g(this,Xe,"f"),g(this,Ct,"f"))}getHelp(){if(L(this,$e,!0,"f"),!g(this,Y,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[rn](g(this,at,"f"),void 0,void 0,0,!0);if(se(t))return t.then(()=>g(this,Y,"f").help())}let e=g(this,fe,"f").runDefaultBuilderOn(this);if(se(e))return e.then(()=>g(this,Y,"f").help())}return Promise.resolve(g(this,Y,"f").help())}getOptions(){return g(this,K,"f")}getStrict(){return g(this,Et,"f")}getStrictCommands(){return g(this,xt,"f")}getStrictOptions(){return g(this,_t,"f")}global(e,t){if(v("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1)g(this,K,"f").local=g(this,K,"f").local.filter((n)=>e.indexOf(n)===-1);else e.forEach((n)=>{if(!g(this,K,"f").local.includes(n))g(this,K,"f").local.push(n)});return this}group(e,t){v("<string|array> <string>",[e,t],arguments.length);let n=g(this,Ct,"f")[t]||g(this,Xe,"f")[t];if(g(this,Ct,"f")[t])delete g(this,Ct,"f")[t];let i={};return g(this,Xe,"f")[t]=(n||[]).concat(e).filter((s)=>{if(i[s])return!1;return i[s]=!0}),this}hide(e){return v("<string>",[e],arguments.length),g(this,K,"f").hiddenOptions.push(e),this}implies(e,t){return v("<string|object> [number|string|array]",[e,t],arguments.length),g(this,ce,"f").implies(e,t),this}locale(e){if(v("[string]",[e],arguments.length),e===void 0)return this[qs](),g(this,H,"f").y18n.getLocale();return L(this,wt,!1,"f"),g(this,H,"f").y18n.setLocale(e),this}middleware(e,t,n){return g(this,Re,"f").addMiddleware(e,!!t,n)}nargs(e,t){return v("<string|object|array> [number]",[e,t],arguments.length),this[Jt](this.nargs.bind(this),"narg",e,t),this}normalize(e){return v("<array|string>",[e],arguments.length),this[ct]("normalize",e),this}number(e){return v("<array|string>",[e],arguments.length),this[ct]("number",e),this[At](e),this}option(e,t){if(v("<string|object> [object]",[e,t],arguments.length),typeof e==="object")Object.keys(e).forEach((n)=>{this.options(n,e[n])});else{if(typeof t!=="object")t={};if(this[At](e),g(this,Ge,"f")&&(e==="version"||(t===null||t===void 0?void 0:t.alias)==="version"))this[go](['"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(g(this,K,"f").key[e]=!0,t.alias)this.alias(e,t.alias);let n=t.deprecate||t.deprecated;if(n)this.deprecateOption(e,n);let i=t.demand||t.required||t.require;if(i)this.demand(e,i);if(t.demandOption)this.demandOption(e,typeof t.demandOption==="string"?t.demandOption:void 0);if(t.conflicts)this.conflicts(e,t.conflicts);if("default"in t)this.default(e,t.default);if(t.implies!==void 0)this.implies(e,t.implies);if(t.nargs!==void 0)this.nargs(e,t.nargs);if(t.config)this.config(e,t.configParser);if(t.normalize)this.normalize(e);if(t.choices)this.choices(e,t.choices);if(t.coerce)this.coerce(e,t.coerce);if(t.group)this.group(e,t.group);if(t.boolean||t.type==="boolean"){if(this.boolean(e),t.alias)this.boolean(t.alias)}if(t.array||t.type==="array"){if(this.array(e),t.alias)this.array(t.alias)}if(t.number||t.type==="number"){if(this.number(e),t.alias)this.number(t.alias)}if(t.string||t.type==="string"){if(this.string(e),t.alias)this.string(t.alias)}if(t.count||t.type==="count")this.count(e);if(typeof t.global==="boolean")this.global(e,t.global);if(t.defaultDescription)g(this,K,"f").defaultDescription[e]=t.defaultDescription;if(t.skipValidation)this.skipValidation(e);let s=t.describe||t.description||t.desc,r=g(this,Y,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(r,e)||typeof s==="string")this.describe(e,s);if(t.hidden)this.hide(e);if(t.requiresArg)this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){if(v("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[mo](),typeof e>"u")e=g(this,at,"f");if(typeof t==="object")L(this,Ft,t,"f"),t=n;if(typeof t==="function")L(this,Oe,t,"f"),t=!1;if(!t)L(this,at,e,"f");if(g(this,Oe,"f"))L(this,Te,!1,"f");let i=this[rn](e,!!t),s=this.parsed;if(g(this,Ee,"f").setParsed(this.parsed),se(i))return i.then((r)=>{if(g(this,Oe,"f"))g(this,Oe,"f").call(this,g(this,ot,"f"),r,g(this,me,"f"));return r}).catch((r)=>{if(g(this,Oe,"f"))g(this,Oe,"f")(r,this.parsed.argv,g(this,me,"f"));throw r}).finally(()=>{this[Qs](),this.parsed=s});else{if(g(this,Oe,"f"))g(this,Oe,"f").call(this,g(this,ot,"f"),i,g(this,me,"f"));this[Qs](),this.parsed=s}return i}parseAsync(e,t,n){let i=this.parse(e,t,n);return!se(i)?Promise.resolve(i):i}parseSync(e,t,n){let i=this.parse(e,t,n);if(se(i))throw new le(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return i}parserConfiguration(e){return v("<object>",[e],arguments.length),L(this,jn,e,"f"),this}pkgConf(e,t){v("<string> [string]",[e,t],arguments.length);let n=null,i=this[Ys](t||g(this,yt,"f"));if(i[e]&&typeof i[e]==="object")n=nn(i[e],t||g(this,yt,"f"),this[St]()["deep-merge-config"]||!1,g(this,H,"f")),g(this,K,"f").configObjects=(g(this,K,"f").configObjects||[]).concat(n);return this}positional(e,t){v("<string> <object>",[e,t],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=it(t,(r,o)=>{if(r==="type"&&!["string","number","boolean"].includes(o))return!1;return n.includes(r)});let i=g(this,sn,"f").fullCommands[g(this,sn,"f").fullCommands.length-1],s=i?g(this,fe,"f").cmdToParseOptions(i):{array:[],alias:{},default:{},demand:{}};return Wt(s).forEach((r)=>{let o=s[r];if(Array.isArray(o)){if(o.indexOf(e)!==-1)t[r]=!0}else if(o[e]&&!(r in t))t[r]=o[e]}),this.group(e,g(this,Y,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return v("[boolean]",[e],arguments.length),L(this,Ln,e,"f"),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){if(v("<array|string|object> [number]",[e],arguments.length),typeof e==="string"&&g(this,K,"f").narg[e])return this;else this[Jt](this.requiresArg.bind(this),"narg",e,NaN);return this}showCompletionScript(e,t){return v("[string] [string]",[e,t],arguments.length),e=e||this.$0,g(this,bt,"f").log(g(this,Ee,"f").generateCompletionScript(e,t||g(this,Ae,"f")||"completion")),this}showHelp(e){if(v("[string|function]",[e],arguments.length),L(this,$e,!0,"f"),!g(this,Y,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[rn](g(this,at,"f"),void 0,void 0,0,!0);if(se(n))return n.then(()=>{g(this,Y,"f").showHelp(e)}),this}let t=g(this,fe,"f").runDefaultBuilderOn(this);if(se(t))return t.then(()=>{g(this,Y,"f").showHelp(e)}),this}return g(this,Y,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return v("[boolean|string] [string]",[e,t],arguments.length),g(this,Y,"f").showHelpOnFail(e,t),this}showVersion(e){return v("[string|function]",[e],arguments.length),g(this,Y,"f").showVersion(e),this}skipValidation(e){return v("<array|string>",[e],arguments.length),this[ct]("skipValidation",e),this}strict(e){return v("[boolean]",[e],arguments.length),L(this,Et,e!==!1,"f"),this}strictCommands(e){return v("[boolean]",[e],arguments.length),L(this,xt,e!==!1,"f"),this}strictOptions(e){return v("[boolean]",[e],arguments.length),L(this,_t,e!==!1,"f"),this}string(e){return v("<array|string>",[e],arguments.length),this[ct]("string",e),this[At](e),this}terminalWidth(){return v([],0),g(this,H,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return v("<object>",[e],arguments.length),L(this,wt,!1,"f"),g(this,H,"f").y18n.updateLocale(e),this}usage(e,t,n,i){if(v("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,i],arguments.length),t!==void 0)if(Fe(e,null,g(this,H,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,i);else throw new le(".usage() description must start with $0 if being used as alias for .command()");else return g(this,Y,"f").usage(e),this}usageConfiguration(e){return v("<object>",[e],arguments.length),L(this,Wn,e,"f"),this}version(e,t,n){if(v("[boolean|string] [string] [string]",[e,t,n],arguments.length),g(this,Ge,"f"))this[Hs](g(this,Ge,"f")),g(this,Y,"f").version(void 0),L(this,Ge,null,"f");if(arguments.length===0)n=this[wo](),e="version";else if(arguments.length===1){if(e===!1)return this;n=e,e="version"}else if(arguments.length===2)n=t,t=void 0;return L(this,Ge,typeof e==="string"?e:"version","f"),t=t||g(this,Y,"f").deferY18nLookup("Show version number"),g(this,Y,"f").version(n||void 0),this.boolean(g(this,Ge,"f")),this.describe(g(this,Ge,"f"),t),this}wrap(e){return v("<number|null|undefined>",[e],arguments.length),g(this,Y,"f").wrap(e),this}[(fe=new WeakMap,yt=new WeakMap,sn=new WeakMap,Ee=new WeakMap,Ae=new WeakMap,Rn=new WeakMap,ot=new WeakMap,wt=new WeakMap,Mn=new WeakMap,Te=new WeakMap,Bn=new WeakMap,Re=new WeakMap,Xe=new WeakMap,$e=new WeakMap,Me=new WeakMap,Nn=new WeakMap,bt=new WeakMap,me=new WeakMap,K=new WeakMap,vn=new WeakMap,jn=new WeakMap,Oe=new WeakMap,Ft=new WeakMap,Kt=new WeakMap,Ct=new WeakMap,at=new WeakMap,Ln=new WeakMap,H=new WeakMap,Et=new WeakMap,xt=new WeakMap,_t=new WeakMap,Y=new WeakMap,Wn=new WeakMap,Ge=new WeakMap,ce=new WeakMap,po)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch(t){}return e}[ho](){return{log:(...e)=>{if(!this[Un]())console.log(...e);if(L(this,$e,!0,"f"),g(this,me,"f").length)L(this,me,g(this,me,"f")+`
|
|
80
80
|
`,"f");L(this,me,g(this,me,"f")+e.join(" "),"f")},error:(...e)=>{if(!this[Un]())console.error(...e);if(L(this,$e,!0,"f"),g(this,me,"f").length)L(this,me,g(this,me,"f")+`
|
|
81
|
-
`,"f");L(this,me,g(this,me,"f")+e.join(" "),"f")}}}[zs](e){Wt(g(this,J,"f")).forEach((t)=>{if(((i)=>i==="configObjects")(t))return;let n=g(this,J,"f")[t];if(Array.isArray(n)){if(n.includes(e))n.splice(n.indexOf(e),1)}else if(typeof n==="object")delete n[e]}),delete g(this,Y,"f").getDescriptions()[e]}[go](e,t,n){if(!g(this,Mn,"f")[n])g(this,H,"f").process.emitWarning(e,t),g(this,Mn,"f")[n]=!0}[mo](){g(this,Bn,"f").push({options:g(this,J,"f"),configObjects:g(this,J,"f").configObjects.slice(0),exitProcess:g(this,Pe,"f"),groups:g(this,Xe,"f"),strict:g(this,Et,"f"),strictCommands:g(this,xt,"f"),strictOptions:g(this,_t,"f"),completionCommand:g(this,Ae,"f"),output:g(this,me,"f"),exitError:g(this,ot,"f"),hasOutput:g(this,$e,"f"),parsed:this.parsed,parseFn:g(this,Oe,"f"),parseContext:g(this,Ft,"f")}),g(this,Y,"f").freeze(),g(this,ce,"f").freeze(),g(this,fe,"f").freeze(),g(this,Re,"f").freeze()}[Do](){let e="",t;if(/\b(node|iojs|electron)(\.exe)?$/.test(g(this,H,"f").process.argv()[0]))t=g(this,H,"f").process.argv().slice(1,2);else t=g(this,H,"f").process.argv().slice(0,1);if(e=t.map((n)=>{let i=this[Oo](g(this,yt,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),g(this,H,"f").getEnv("_")&&g(this,H,"f").getProcessArgvBin()===g(this,H,"f").getEnv("_"))e=g(this,H,"f").getEnv("_").replace(`${g(this,H,"f").path.dirname(g(this,H,"f").process.execPath())}/`,"");return e}[St](){return g(this,jn,"f")}[yo](){return g(this,Wn,"f")}[Hs](){if(!g(this,wt,"f"))return;let e=g(this,H,"f").getEnv("LC_ALL")||g(this,H,"f").getEnv("LC_MESSAGES")||g(this,H,"f").getEnv("LANG")||g(this,H,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[wo](){return this[qs]().version||"unknown"}[bo](e){let t=e["--"]?e["--"]:e._;for(let n=0,i;(i=t[n])!==void 0;n++)if(g(this,H,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`))))t[n]=Number(i);return e}[qs](e){let t=e||"*";if(g(this,Jt,"f")[t])return g(this,Jt,"f")[t];let n={};try{let i=e||g(this,H,"f").mainFilename;if(g(this,H,"f").path.extname(i))i=g(this,H,"f").path.dirname(i);let s=g(this,H,"f").findUp(i,(r,o)=>{if(o.includes("package.json"))return"package.json";else return});Fe(s,void 0,g(this,H,"f")),n=JSON.parse(g(this,H,"f").readFileSync(s,"utf8"))}catch(i){}return g(this,Jt,"f")[t]=n||{},g(this,Jt,"f")[t]}[ct](e,t){t=[].concat(t),t.forEach((n)=>{n=this[Gs](n),g(this,J,"f")[e].push(n)})}[Kt](e,t,n,i){this[Xs](e,t,n,i,(s,r,o)=>{g(this,J,"f")[s][r]=o})}[Ys](e,t,n,i){this[Xs](e,t,n,i,(s,r,o)=>{g(this,J,"f")[s][r]=(g(this,J,"f")[s][r]||[]).concat(o)})}[Xs](e,t,n,i,s){if(Array.isArray(n))n.forEach((r)=>{e(r,i)});else if(((r)=>typeof r==="object")(n))for(let r of Wt(n))e(r,n[r]);else s(t,this[Gs](n),i)}[Gs](e){if(e==="__proto__")return"___proto___";return e}[Vs](e,t){return this[Kt](this[Vs].bind(this),"key",e,t),this}[Zs](){var e,t,n,i,s,r,o,a,c,u,f,l;let d=g(this,Bn,"f").pop();Fe(d,void 0,g(this,H,"f"));let p;e=this,t=this,n=this,i=this,s=this,r=this,o=this,a=this,c=this,u=this,f=this,l=this,{options:{set value(m){L(e,J,m,"f")}}.value,configObjects:p,exitProcess:{set value(m){L(t,Pe,m,"f")}}.value,groups:{set value(m){L(n,Xe,m,"f")}}.value,output:{set value(m){L(i,me,m,"f")}}.value,exitError:{set value(m){L(s,ot,m,"f")}}.value,hasOutput:{set value(m){L(r,$e,m,"f")}}.value,parsed:this.parsed,strict:{set value(m){L(o,Et,m,"f")}}.value,strictCommands:{set value(m){L(a,xt,m,"f")}}.value,strictOptions:{set value(m){L(c,_t,m,"f")}}.value,completionCommand:{set value(m){L(u,Ae,m,"f")}}.value,parseFn:{set value(m){L(f,Oe,m,"f")}}.value,parseContext:{set value(m){L(l,Ft,m,"f")}}.value}=d,g(this,J,"f").configObjects=p,g(this,Y,"f").unfreeze(),g(this,ce,"f").unfreeze(),g(this,fe,"f").unfreeze(),g(this,Re,"f").unfreeze()}[Fo](e,t){return Dt(t,(n)=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[Co].bind(this),getContext:this[Eo].bind(this),getHasOutput:this[xo].bind(this),getLoggerInstance:this[_o].bind(this),getParseContext:this[So].bind(this),getParserConfiguration:this[St].bind(this),getUsageConfiguration:this[yo].bind(this),getUsageInstance:this[ko].bind(this),getValidationInstance:this[Ao].bind(this),hasParseCallback:this[Un].bind(this),isGlobalContext:this[$o].bind(this),postProcess:this[kt].bind(this),reset:this[Qs].bind(this),runValidation:this[ei].bind(this),runYargsParserAndExecuteCommands:this[rn].bind(this),setHasOutput:this[Io].bind(this)}}[Co](){return g(this,fe,"f")}[Eo](){return g(this,sn,"f")}[xo](){return g(this,$e,"f")}[_o](){return g(this,bt,"f")}[So](){return g(this,Ft,"f")||{}}[ko](){return g(this,Y,"f")}[Ao](){return g(this,ce,"f")}[Un](){return!!g(this,Oe,"f")}[$o](){return g(this,Nn,"f")}[kt](e,t,n,i){if(n)return e;if(se(e))return e;if(!t)e=this[po](e);if(this[St]()["parse-positional-numbers"]||this[St]()["parse-positional-numbers"]===void 0)e=this[bo](e);if(i)e=mt(e,this,g(this,Re,"f").getMiddleware(),!1);return e}[Qs](e={}){L(this,J,g(this,J,"f")||{},"f");let t={};t.local=g(this,J,"f").local||[],t.configObjects=g(this,J,"f").configObjects||[];let n={};t.local.forEach((r)=>{n[r]=!0,(e[r]||[]).forEach((o)=>{n[o]=!0})}),Object.assign(g(this,Ct,"f"),Object.keys(g(this,Xe,"f")).reduce((r,o)=>{let a=g(this,Xe,"f")[o].filter((c)=>!(c in n));if(a.length>0)r[o]=a;return r},{})),L(this,Xe,{},"f");let i=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],s=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(i.forEach((r)=>{t[r]=(g(this,J,"f")[r]||[]).filter((o)=>!n[o])}),s.forEach((r)=>{t[r]=it(g(this,J,"f")[r],(o)=>!n[o])}),t.envPrefix=g(this,J,"f").envPrefix,L(this,J,t,"f"),L(this,Y,g(this,Y,"f")?g(this,Y,"f").reset(n):so(this,g(this,H,"f")),"f"),L(this,ce,g(this,ce,"f")?g(this,ce,"f").reset(n):lo(this,g(this,Y,"f"),g(this,H,"f")),"f"),L(this,fe,g(this,fe,"f")?g(this,fe,"f").reset():eo(g(this,Y,"f"),g(this,ce,"f"),g(this,Re,"f"),g(this,H,"f")),"f"),!g(this,Ee,"f"))L(this,Ee,ao(this,g(this,Y,"f"),g(this,fe,"f"),g(this,H,"f")),"f");return g(this,Re,"f").reset(),L(this,Ae,null,"f"),L(this,me,"","f"),L(this,ot,null,"f"),L(this,$e,!1,"f"),this.parsed=!1,this}[Oo](e,t){return g(this,H,"f").path.relative(e,t)}[rn](e,t,n,i=0,s=!1){var r,o,a,c;let u=!!n||s;e=e||g(this,at,"f"),g(this,J,"f").__=g(this,H,"f").y18n.__,g(this,J,"f").configuration=this[St]();let f=!!g(this,J,"f").configuration["populate--"],l=Object.assign({},g(this,J,"f").configuration,{"populate--":!0}),d=g(this,H,"f").Parser.detailed(e,Object.assign({},g(this,J,"f"),{configuration:{"parse-positional-numbers":!1,...l}})),p=Object.assign(d.argv,g(this,Ft,"f")),m=void 0,h=d.aliases,y=!1,C=!1;if(Object.keys(p).forEach((F)=>{if(F===g(this,Me,"f")&&p[F])y=!0;else if(F===g(this,Ge,"f")&&p[F])C=!0}),p.$0=this.$0,this.parsed=d,i===0)g(this,Y,"f").clearCachedHelpMessage();try{if(this[Hs](),t)return this[kt](p,f,!!n,!1);if(g(this,Me,"f")){if([g(this,Me,"f")].concat(h[g(this,Me,"f")]||[]).filter((A)=>A.length>1).includes(""+p._[p._.length-1]))p._.pop(),y=!0}L(this,Nn,!1,"f");let F=g(this,fe,"f").getCommands(),S=((r=g(this,Ee,"f"))===null||r===void 0?void 0:r.completionKey)?[(o=g(this,Ee,"f"))===null||o===void 0?void 0:o.completionKey,...(c=this.getAliases()[(a=g(this,Ee,"f"))===null||a===void 0?void 0:a.completionKey])!==null&&c!==void 0?c:[]].some((j)=>Object.prototype.hasOwnProperty.call(p,j)):!1,k=y||S||s;if(p._.length){if(F.length){let j;for(let A=i||0,M;p._[A]!==void 0;A++)if(M=String(p._[A]),F.includes(M)&&M!==g(this,Ae,"f")){let R=g(this,fe,"f").runCommand(M,this,d,A+1,s,y||C||s);return this[kt](R,f,!!n,!1)}else if(!j&&M!==g(this,Ae,"f")){j=M;break}if(!g(this,fe,"f").hasDefaultCommand()&&g(this,Ln,"f")&&j&&!k)g(this,ce,"f").recommendCommands(j,F)}if(g(this,Ae,"f")&&p._.includes(g(this,Ae,"f"))&&!S){if(g(this,Pe,"f"))rt(!0);this.showCompletionScript(),this.exit(0)}}if(g(this,fe,"f").hasDefaultCommand()&&!k){let j=g(this,fe,"f").runCommand(null,this,d,0,s,y||C||s);return this[kt](j,f,!!n,!1)}if(S){if(g(this,Pe,"f"))rt(!0);e=[].concat(e);let j=e.slice(e.indexOf(`--${g(this,Ee,"f").completionKey}`)+1);return g(this,Ee,"f").getCompletion(j,(A,M)=>{if(A)throw new le(A.message);(M||[]).forEach((R)=>{g(this,bt,"f").log(R)}),this.exit(0)}),this[kt](p,!f,!!n,!1)}if(!g(this,$e,"f")){if(y){if(g(this,Pe,"f"))rt(!0);u=!0,this.showHelp((j)=>{g(this,bt,"f").log(j),this.exit(0)})}else if(C){if(g(this,Pe,"f"))rt(!0);u=!0,g(this,Y,"f").showVersion("log"),this.exit(0)}}if(!u&&g(this,J,"f").skipValidation.length>0)u=Object.keys(p).some((j)=>g(this,J,"f").skipValidation.indexOf(j)>=0&&p[j]===!0);if(!u){if(d.error)throw new le(d.error.message);if(!S){let j=this[ei](h,{},d.error);if(!n)m=mt(p,this,g(this,Re,"f").getMiddleware(),!0);if(m=this[Fo](j,m!==null&&m!==void 0?m:p),se(m)&&!n)m=m.then(()=>mt(p,this,g(this,Re,"f").getMiddleware(),!1))}}}catch(F){if(F instanceof le)g(this,Y,"f").fail(F.message,F);else throw F}return this[kt](m!==null&&m!==void 0?m:p,f,!!n,!0)}[ei](e,t,n,i){let s={...this.getDemandedOptions()};return(r)=>{if(n)throw new le(n.message);g(this,ce,"f").nonOptionCount(r),g(this,ce,"f").requiredArguments(r,s);let o=!1;if(g(this,xt,"f"))o=g(this,ce,"f").unknownCommands(r);if(g(this,Et,"f")&&!o)g(this,ce,"f").unknownArguments(r,e,t,!!i);else if(g(this,_t,"f"))g(this,ce,"f").unknownArguments(r,e,{},!1,!1);g(this,ce,"f").limitedChoices(r),g(this,ce,"f").implications(r),g(this,ce,"f").conflicting(r)}}[Io](){L(this,$e,!0,"f")}[At](e){if(typeof e==="string")g(this,J,"f").key[e]=!0;else for(let t of e)g(this,J,"f").key[t]=!0}}function to(e){return!!e&&typeof e.getInternalMethods==="function"}var al=To(Ls),Ro=al;import{existsSync as Jn,readFileSync as si,writeFileSync as ti,mkdirSync as No}from"node:fs";import{homedir as cl}from"node:os";import{join as $t,dirname as ii}from"node:path";function ri(){return process.env.HOME||cl()}function vo(){return $t(ri(),".config","slack-cli","profiles.json")}function Kn(){return $t(process.cwd(),".slack-cli","workspace")}function zn(){return $t(ri(),".slack-cli","workspace")}function on(){let e=vo();if(!Jn(e))return{profiles:{}};return JSON.parse(si(e,"utf8"))}function ul(e){let t=vo();No(ii(t),{recursive:!0}),ti(t,JSON.stringify(e,null,2)+`
|
|
82
|
-
`)}function zt(e){if(!
|
|
83
|
-
`);
|
|
84
|
-
`)}function
|
|
85
|
-
`)){let i=n.trim();if(!i||i.startsWith("#"))continue;let s=i.indexOf("=");if(s===-1)continue;let r=i.slice(0,s).trim(),o=i.slice(s+1).trim();if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))o=o.slice(1,-1);t[r]=o}return t}function Bo(e){if(!
|
|
86
|
-
`+" Migrate to SLACK_TOKEN=... or remove from your shell config.")}}let r=
|
|
81
|
+
`,"f");L(this,me,g(this,me,"f")+e.join(" "),"f")}}}[Hs](e){Wt(g(this,K,"f")).forEach((t)=>{if(((i)=>i==="configObjects")(t))return;let n=g(this,K,"f")[t];if(Array.isArray(n)){if(n.includes(e))n.splice(n.indexOf(e),1)}else if(typeof n==="object")delete n[e]}),delete g(this,Y,"f").getDescriptions()[e]}[go](e,t,n){if(!g(this,Mn,"f")[n])g(this,H,"f").process.emitWarning(e,t),g(this,Mn,"f")[n]=!0}[mo](){g(this,Bn,"f").push({options:g(this,K,"f"),configObjects:g(this,K,"f").configObjects.slice(0),exitProcess:g(this,Te,"f"),groups:g(this,Xe,"f"),strict:g(this,Et,"f"),strictCommands:g(this,xt,"f"),strictOptions:g(this,_t,"f"),completionCommand:g(this,Ae,"f"),output:g(this,me,"f"),exitError:g(this,ot,"f"),hasOutput:g(this,$e,"f"),parsed:this.parsed,parseFn:g(this,Oe,"f"),parseContext:g(this,Ft,"f")}),g(this,Y,"f").freeze(),g(this,ce,"f").freeze(),g(this,fe,"f").freeze(),g(this,Re,"f").freeze()}[Do](){let e="",t;if(/\b(node|iojs|electron)(\.exe)?$/.test(g(this,H,"f").process.argv()[0]))t=g(this,H,"f").process.argv().slice(1,2);else t=g(this,H,"f").process.argv().slice(0,1);if(e=t.map((n)=>{let i=this[Oo](g(this,yt,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),g(this,H,"f").getEnv("_")&&g(this,H,"f").getProcessArgvBin()===g(this,H,"f").getEnv("_"))e=g(this,H,"f").getEnv("_").replace(`${g(this,H,"f").path.dirname(g(this,H,"f").process.execPath())}/`,"");return e}[St](){return g(this,jn,"f")}[yo](){return g(this,Wn,"f")}[qs](){if(!g(this,wt,"f"))return;let e=g(this,H,"f").getEnv("LC_ALL")||g(this,H,"f").getEnv("LC_MESSAGES")||g(this,H,"f").getEnv("LANG")||g(this,H,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[wo](){return this[Ys]().version||"unknown"}[bo](e){let t=e["--"]?e["--"]:e._;for(let n=0,i;(i=t[n])!==void 0;n++)if(g(this,H,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`))))t[n]=Number(i);return e}[Ys](e){let t=e||"*";if(g(this,Kt,"f")[t])return g(this,Kt,"f")[t];let n={};try{let i=e||g(this,H,"f").mainFilename;if(g(this,H,"f").path.extname(i))i=g(this,H,"f").path.dirname(i);let s=g(this,H,"f").findUp(i,(r,o)=>{if(o.includes("package.json"))return"package.json";else return});Fe(s,void 0,g(this,H,"f")),n=JSON.parse(g(this,H,"f").readFileSync(s,"utf8"))}catch(i){}return g(this,Kt,"f")[t]=n||{},g(this,Kt,"f")[t]}[ct](e,t){t=[].concat(t),t.forEach((n)=>{n=this[Vs](n),g(this,K,"f")[e].push(n)})}[Jt](e,t,n,i){this[Gs](e,t,n,i,(s,r,o)=>{g(this,K,"f")[s][r]=o})}[Xs](e,t,n,i){this[Gs](e,t,n,i,(s,r,o)=>{g(this,K,"f")[s][r]=(g(this,K,"f")[s][r]||[]).concat(o)})}[Gs](e,t,n,i,s){if(Array.isArray(n))n.forEach((r)=>{e(r,i)});else if(((r)=>typeof r==="object")(n))for(let r of Wt(n))e(r,n[r]);else s(t,this[Vs](n),i)}[Vs](e){if(e==="__proto__")return"___proto___";return e}[Zs](e,t){return this[Jt](this[Zs].bind(this),"key",e,t),this}[Qs](){var e,t,n,i,s,r,o,a,c,u,f,l;let d=g(this,Bn,"f").pop();Fe(d,void 0,g(this,H,"f"));let h;e=this,t=this,n=this,i=this,s=this,r=this,o=this,a=this,c=this,u=this,f=this,l=this,{options:{set value(m){L(e,K,m,"f")}}.value,configObjects:h,exitProcess:{set value(m){L(t,Te,m,"f")}}.value,groups:{set value(m){L(n,Xe,m,"f")}}.value,output:{set value(m){L(i,me,m,"f")}}.value,exitError:{set value(m){L(s,ot,m,"f")}}.value,hasOutput:{set value(m){L(r,$e,m,"f")}}.value,parsed:this.parsed,strict:{set value(m){L(o,Et,m,"f")}}.value,strictCommands:{set value(m){L(a,xt,m,"f")}}.value,strictOptions:{set value(m){L(c,_t,m,"f")}}.value,completionCommand:{set value(m){L(u,Ae,m,"f")}}.value,parseFn:{set value(m){L(f,Oe,m,"f")}}.value,parseContext:{set value(m){L(l,Ft,m,"f")}}.value}=d,g(this,K,"f").configObjects=h,g(this,Y,"f").unfreeze(),g(this,ce,"f").unfreeze(),g(this,fe,"f").unfreeze(),g(this,Re,"f").unfreeze()}[Fo](e,t){return Dt(t,(n)=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[Co].bind(this),getContext:this[Eo].bind(this),getHasOutput:this[xo].bind(this),getLoggerInstance:this[_o].bind(this),getParseContext:this[So].bind(this),getParserConfiguration:this[St].bind(this),getUsageConfiguration:this[yo].bind(this),getUsageInstance:this[ko].bind(this),getValidationInstance:this[Ao].bind(this),hasParseCallback:this[Un].bind(this),isGlobalContext:this[$o].bind(this),postProcess:this[kt].bind(this),reset:this[ei].bind(this),runValidation:this[ti].bind(this),runYargsParserAndExecuteCommands:this[rn].bind(this),setHasOutput:this[Io].bind(this)}}[Co](){return g(this,fe,"f")}[Eo](){return g(this,sn,"f")}[xo](){return g(this,$e,"f")}[_o](){return g(this,bt,"f")}[So](){return g(this,Ft,"f")||{}}[ko](){return g(this,Y,"f")}[Ao](){return g(this,ce,"f")}[Un](){return!!g(this,Oe,"f")}[$o](){return g(this,Nn,"f")}[kt](e,t,n,i){if(n)return e;if(se(e))return e;if(!t)e=this[po](e);if(this[St]()["parse-positional-numbers"]||this[St]()["parse-positional-numbers"]===void 0)e=this[bo](e);if(i)e=mt(e,this,g(this,Re,"f").getMiddleware(),!1);return e}[ei](e={}){L(this,K,g(this,K,"f")||{},"f");let t={};t.local=g(this,K,"f").local||[],t.configObjects=g(this,K,"f").configObjects||[];let n={};t.local.forEach((r)=>{n[r]=!0,(e[r]||[]).forEach((o)=>{n[o]=!0})}),Object.assign(g(this,Ct,"f"),Object.keys(g(this,Xe,"f")).reduce((r,o)=>{let a=g(this,Xe,"f")[o].filter((c)=>!(c in n));if(a.length>0)r[o]=a;return r},{})),L(this,Xe,{},"f");let i=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],s=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(i.forEach((r)=>{t[r]=(g(this,K,"f")[r]||[]).filter((o)=>!n[o])}),s.forEach((r)=>{t[r]=it(g(this,K,"f")[r],(o)=>!n[o])}),t.envPrefix=g(this,K,"f").envPrefix,L(this,K,t,"f"),L(this,Y,g(this,Y,"f")?g(this,Y,"f").reset(n):so(this,g(this,H,"f")),"f"),L(this,ce,g(this,ce,"f")?g(this,ce,"f").reset(n):lo(this,g(this,Y,"f"),g(this,H,"f")),"f"),L(this,fe,g(this,fe,"f")?g(this,fe,"f").reset():eo(g(this,Y,"f"),g(this,ce,"f"),g(this,Re,"f"),g(this,H,"f")),"f"),!g(this,Ee,"f"))L(this,Ee,ao(this,g(this,Y,"f"),g(this,fe,"f"),g(this,H,"f")),"f");return g(this,Re,"f").reset(),L(this,Ae,null,"f"),L(this,me,"","f"),L(this,ot,null,"f"),L(this,$e,!1,"f"),this.parsed=!1,this}[Oo](e,t){return g(this,H,"f").path.relative(e,t)}[rn](e,t,n,i=0,s=!1){var r,o,a,c;let u=!!n||s;e=e||g(this,at,"f"),g(this,K,"f").__=g(this,H,"f").y18n.__,g(this,K,"f").configuration=this[St]();let f=!!g(this,K,"f").configuration["populate--"],l=Object.assign({},g(this,K,"f").configuration,{"populate--":!0}),d=g(this,H,"f").Parser.detailed(e,Object.assign({},g(this,K,"f"),{configuration:{"parse-positional-numbers":!1,...l}})),h=Object.assign(d.argv,g(this,Ft,"f")),m=void 0,p=d.aliases,y=!1,C=!1;if(Object.keys(h).forEach((F)=>{if(F===g(this,Me,"f")&&h[F])y=!0;else if(F===g(this,Ge,"f")&&h[F])C=!0}),h.$0=this.$0,this.parsed=d,i===0)g(this,Y,"f").clearCachedHelpMessage();try{if(this[qs](),t)return this[kt](h,f,!!n,!1);if(g(this,Me,"f")){if([g(this,Me,"f")].concat(p[g(this,Me,"f")]||[]).filter((A)=>A.length>1).includes(""+h._[h._.length-1]))h._.pop(),y=!0}L(this,Nn,!1,"f");let F=g(this,fe,"f").getCommands(),S=((r=g(this,Ee,"f"))===null||r===void 0?void 0:r.completionKey)?[(o=g(this,Ee,"f"))===null||o===void 0?void 0:o.completionKey,...(c=this.getAliases()[(a=g(this,Ee,"f"))===null||a===void 0?void 0:a.completionKey])!==null&&c!==void 0?c:[]].some((j)=>Object.prototype.hasOwnProperty.call(h,j)):!1,k=y||S||s;if(h._.length){if(F.length){let j;for(let A=i||0,M;h._[A]!==void 0;A++)if(M=String(h._[A]),F.includes(M)&&M!==g(this,Ae,"f")){let R=g(this,fe,"f").runCommand(M,this,d,A+1,s,y||C||s);return this[kt](R,f,!!n,!1)}else if(!j&&M!==g(this,Ae,"f")){j=M;break}if(!g(this,fe,"f").hasDefaultCommand()&&g(this,Ln,"f")&&j&&!k)g(this,ce,"f").recommendCommands(j,F)}if(g(this,Ae,"f")&&h._.includes(g(this,Ae,"f"))&&!S){if(g(this,Te,"f"))rt(!0);this.showCompletionScript(),this.exit(0)}}if(g(this,fe,"f").hasDefaultCommand()&&!k){let j=g(this,fe,"f").runCommand(null,this,d,0,s,y||C||s);return this[kt](j,f,!!n,!1)}if(S){if(g(this,Te,"f"))rt(!0);e=[].concat(e);let j=e.slice(e.indexOf(`--${g(this,Ee,"f").completionKey}`)+1);return g(this,Ee,"f").getCompletion(j,(A,M)=>{if(A)throw new le(A.message);(M||[]).forEach((R)=>{g(this,bt,"f").log(R)}),this.exit(0)}),this[kt](h,!f,!!n,!1)}if(!g(this,$e,"f")){if(y){if(g(this,Te,"f"))rt(!0);u=!0,this.showHelp((j)=>{g(this,bt,"f").log(j),this.exit(0)})}else if(C){if(g(this,Te,"f"))rt(!0);u=!0,g(this,Y,"f").showVersion("log"),this.exit(0)}}if(!u&&g(this,K,"f").skipValidation.length>0)u=Object.keys(h).some((j)=>g(this,K,"f").skipValidation.indexOf(j)>=0&&h[j]===!0);if(!u){if(d.error)throw new le(d.error.message);if(!S){let j=this[ti](p,{},d.error);if(!n)m=mt(h,this,g(this,Re,"f").getMiddleware(),!0);if(m=this[Fo](j,m!==null&&m!==void 0?m:h),se(m)&&!n)m=m.then(()=>mt(h,this,g(this,Re,"f").getMiddleware(),!1))}}}catch(F){if(F instanceof le)g(this,Y,"f").fail(F.message,F);else throw F}return this[kt](m!==null&&m!==void 0?m:h,f,!!n,!0)}[ti](e,t,n,i){let s={...this.getDemandedOptions()};return(r)=>{if(n)throw new le(n.message);g(this,ce,"f").nonOptionCount(r),g(this,ce,"f").requiredArguments(r,s);let o=!1;if(g(this,xt,"f"))o=g(this,ce,"f").unknownCommands(r);if(g(this,Et,"f")&&!o)g(this,ce,"f").unknownArguments(r,e,t,!!i);else if(g(this,_t,"f"))g(this,ce,"f").unknownArguments(r,e,{},!1,!1);g(this,ce,"f").limitedChoices(r),g(this,ce,"f").implications(r),g(this,ce,"f").conflicting(r)}}[Io](){L(this,$e,!0,"f")}[At](e){if(typeof e==="string")g(this,K,"f").key[e]=!0;else for(let t of e)g(this,K,"f").key[t]=!0}}function to(e){return!!e&&typeof e.getInternalMethods==="function"}var ll=Po(Ws),Ro=ll;import{existsSync as Kn,readFileSync as ii,writeFileSync as ni,mkdirSync as No}from"node:fs";import{homedir as fl}from"node:os";import{join as $t,dirname as ri}from"node:path";function oi(){return process.env.HOME||fl()}function vo(){return $t(oi(),".config","slack-cli","profiles.json")}function Jn(){return $t(process.cwd(),".slack-cli","workspace")}function zn(){return $t(oi(),".slack-cli","workspace")}function on(){let e=vo();if(!Kn(e))return{profiles:{}};return JSON.parse(ii(e,"utf8"))}function dl(e){let t=vo();No(ri(t),{recursive:!0}),ni(t,JSON.stringify(e,null,2)+`
|
|
82
|
+
`)}function zt(e){if(!Kn(e))return;return ii(e,"utf8").trim()||void 0}function Mo(e,t){let n=ri(e);No(n,{recursive:!0});let i=$t(n,".gitignore");if(!Kn(i))ni(i,`*
|
|
83
|
+
`);ni(e,t+`
|
|
84
|
+
`)}function pl(e){let t={};for(let n of e.split(`
|
|
85
|
+
`)){let i=n.trim();if(!i||i.startsWith("#"))continue;let s=i.indexOf("=");if(s===-1)continue;let r=i.slice(0,s).trim(),o=i.slice(s+1).trim();if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))o=o.slice(1,-1);t[r]=o}return t}function Bo(e){if(!Kn(e))return{};try{return pl(ii(e,"utf8"))}catch{return{}}}function si(e,t){let n=oi(),i=e;while(!0){for(let o of[$t(i,".slack-term",".env.local"),$t(i,".env.local")]){let a=Bo(o);for(let c of t)if(a[c])return a[c]}if(i===n)break;let r=ri(i);if(r===i)break;i=r}let s=Bo($t(n,".slack-term",".env.local"));for(let r of t)if(s[r])return s[r];return}function ai(){let e=on(),t=zt(Jn()),n=zt(zn()),i=t??n;return Object.entries(e.profiles).map(([s,r])=>({name:s,profile:r,current:s===i}))}function jo(e){let t=on();if(!(e in t.profiles))throw Error(`Profile not found: ${e}`);delete t.profiles[e],dl(t)}function Lo(e,t=!1){let n=on();if(!(e in n.profiles))throw Error(`Profile not found: ${e}`);if(t)Mo(zn(),e);else Mo(Jn(),e)}function ci(e){let n=on().profiles,i=Object.keys(n);if(e){let u=n[e];if(!u)throw Error(`Workspace "${e}" not found. Available: ${i.join(", ")||"(none)"}`);return u.token}if(process.env.SLACK_TOKEN)return process.env.SLACK_TOKEN;let s=process.env.SLACK_BOT_TOKEN??process.env.SLACK_MCP_XOXP_TOKEN;if(s&&i.length===0)return s;if(s&&i.length>0){let u=si(process.cwd(),["SLACK_BOT_TOKEN","SLACK_MCP_XOXP_TOKEN"]);if(s!==u){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 r=si(process.cwd(),["SLACK_TOKEN"]);if(r)return r;let o=process.env.SLACK_WORKSPACE;if(o){let u=n[o];if(!u)throw Error(`Workspace "${o}" not found. Available: ${i.join(", ")||"(none)"}`);return u.token}let a=zt(Jn());if(a){let u=n[a];if(!u)throw Error(`Workspace "${a}" (from .slack-cli/workspace) not found in profiles.`);return u.token}let c=zt(zn());if(c){let u=n[c];if(!u)throw Error(`Workspace "${c}" (from ~/.slack-cli/workspace) not found in profiles.`);return u.token}if(i.length>0)throw Error(`Workspace not selected (${i.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 Ht(){let e=process.env.SLACK_BOT_TOKEN;return e&&e.startsWith("xoxb-")?e:void 0}function Wo(e){let n=on().profiles;if(e)return n[e]?.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(n).length===0)return process.env.SLACK_MCP_XOXD_COOKIE;let s=
|
|
93
|
+
`+" Or set SLACK_TOKEN=xoxp-... in .slack-term/.env.local")}function Ht(){let e=process.env.SLACK_BOT_TOKEN;return e&&e.startsWith("xoxb-")?e:void 0}function Wo(e){let n=on().profiles;if(e)return n[e]?.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(n).length===0)return process.env.SLACK_MCP_XOXD_COOKIE;let s=si(process.cwd(),["SLACK_COOKIE"]);if(s)return s;let r=process.env.SLACK_WORKSPACE;if(r)return n[r]?.cookie;let o=zt(Jn());if(o)return n[o]?.cookie;let a=zt(zn());if(a)return n[a]?.cookie;return}class Ve extends Error{retryAfter;constructor(e){super(`Slack rate limited — retry after ${e}s`);this.name="RateLimitError",this.retryAfter=e}}function ui(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function Ko(e,t,n,i){let s={};if(i)s.Cookie=`d=${i}`;let r=await fetch(`${ui()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(r.status===429){let a=parseInt(r.headers.get("retry-after")??"60",10);throw new Ve(isNaN(a)?60:a)}let o=await r.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new Ve(60);if(a==="invalid_auth"&&e.startsWith("xoxc-")&&!i)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((a==="missing_scope"||a==="cannot_dm_bot")&&e.startsWith("xoxb-"))throw Error(`Slack error on ${t}: ${a} — ${a==="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 ${t}: ${a}`)}return o}async function
|
|
99
|
+
Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${t}: ${a}`)}return o}async function hl(e,t,n,i){let s={};if(i)s.Cookie=`d=${i}`;let r=await fetch(`${ui()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(r.status===429){let a=parseInt(r.headers.get("retry-after")??"60",10);throw new Ve(isNaN(a)?60:a)}let o=await r.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new Ve(60);if((a==="invalid_auth"||a==="not_authed")&&!e.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
|
|
100
100
|
Import from Slack desktop: slack auth login`);if((a==="invalid_auth"||a==="not_authed")&&!i)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 ${t}: ${a}`)}return o}function
|
|
102
|
-
`)}function Zo(e){if(!
|
|
101
|
+
Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${t}: ${a}`)}return o}function gl(e,t,n={},i){let s=new URLSearchParams({token:e,...n});return hl(e,t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},i)}function we(e,t,n,i){let s=new URLSearchParams(n).toString();return Ko(e,`${t}?${s}`,{method:"GET"},i)}function li(e,t,n,i){return Ko(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},i)}async function qt(e,t){let n=await we(e,"auth.test",{},t);return{team:n.team??"",teamId:n.team_id??"",url:n.url??"",user:n.user??"",userId:n.user_id??""}}async function Jo(e,t){let n={Authorization:`Bearer ${e}`};if(t)n.Cookie=`d=${t}`;let i=await fetch(`${ui()}/auth.test`,{method:"GET",headers:n});if(i.status===429){let o=parseInt(i.headers.get("retry-after")??"60",10);throw new Ve(isNaN(o)?60:o)}let s=i.headers.get("x-oauth-scopes")??"",r=await i.json();if(r.ok!==!0)throw Error(`Slack error on auth.test: ${r.error??"unknown"}`);return{userId:r.user_id??"",user:r.user??"",botId:r.bot_id??"",team:r.team??"",url:r.url??"",scopes:s.split(",").map((o)=>o.trim()).filter(Boolean)}}async function zo(e,t,n){let i=await we(e,"bots.info",{bot:t},n);return{appId:i.bot?.app_id??"",userId:i.bot?.user_id??""}}async function cn(e,t,n=20,i,s,r,o){let a={channel:t,limit:String(n)};if(i!==void 0)a.oldest=i;if(s!==void 0)a.cursor=s;if(o)a.inclusive="true";return we(e,"conversations.history",a,r)}async function Ho(e,t,n,i=50,s){return we(e,"conversations.replies",{channel:t,ts:n,limit:String(i)},s)}async function Hn(e,t,n,i,s){await li(e,"reactions.add",{channel:t,timestamp:n,name:i},s)}async function qo(e,t,n,i){return((await we(e,"reactions.get",{channel:t,timestamp:n,full:"true"},i)).message?.reactions??[]).map((r)=>({name:String(r.name??""),users:Array.isArray(r.users)?r.users.map(String):[]}))}async function qn(e,t,n,i,s){await li(e,"reactions.remove",{channel:t,timestamp:n,name:i},s)}async function ml(e,t,n){let s=(await li(e,"conversations.open",{users:t},n)).channel?.id;if(!s)throw Error(`Failed to open DM with user ${t}`);return s}function an(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function fi(e){let t=e.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(!t)return;let n=t[1],i=t[2]&&t[3]?`${t[2]}.${t[3]}`:void 0,s=e.indexOf("?"),r=s>=0?new URLSearchParams(e.slice(s)):void 0,o=r?.get("thread_ts")??void 0,u={channel:r?.get("cid")??void 0??n};if(i)u.ts=i;if(o)u.threadTs=o;return u}function Dl(e){return fi(e)?.channel}function Uo(e){return/^[CDG][A-Z0-9]{8,}$/.test(e)}async function Yo(e,t,n){let i=Dl(t);if(i)return i;if(!t.startsWith("@")&&!t.startsWith("#")){if(Uo(t))return t;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${t}`)}if(t.startsWith("#")&&Uo(t.slice(1)))return t.slice(1);let s=t.startsWith("@"),r=t.slice(1),o=an(r);if(s){let u=await we(e,"auth.test",{},n);if(o==="you"||o==="me"||an(u.user??"")===o){let m=u.user_id;if(!m)throw Error("auth.test did not return user_id");let y=((await we(e,"conversations.list",{types:"im",limit:"200"},n)).channels??[]).find((C)=>C.user===m);if(y?.id)return String(y.id);return ml(e,m,n)}let l="",d="";while(!0){let m={limit:"200"};if(d)m.cursor=d;let p=await we(e,"users.list",m,n);for(let y of p.members??[]){let C=an(y.name??""),F=an(y.real_name??""),S=an(y.profile?.display_name??"");if(C===o||F===o||S&&S===o){l=y.id??"";break}}if(l)break;if(d=p.response_metadata?.next_cursor??"",!d)break}if(!l)throw Error(`User not found: ${t}`);let h="";while(!0){let m={types:"im",limit:"200"};if(h)m.cursor=h;let p=await we(e,"conversations.list",m,n);for(let y of p.channels??[])if(y.user===l)return String(y.id??"");if(h=p.response_metadata?.next_cursor??"",!h)break}throw Error(`No existing DM with ${t} (${l}). Open it once in Slack first.`)}let a=r.toLowerCase(),c="";while(!0){let u={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(c)u.cursor=c;let f=await we(e,"conversations.list",u,n);for(let l of f.channels??[])if(String(l.name??"").toLowerCase()===a)return String(l.id??"");if(c=f.response_metadata?.next_cursor??"",!c)break}throw Error(`channel not found: ${t}`)}async function Yn(e,t,n){try{let i=await we(e,"users.info",{user:t},n),s=i.user?.profile?.display_name,r=s&&s.length>0?s:i.user?.real_name??i.user?.name??t,o=i.user?.name??t;return[r,o]}catch{return[t,t]}}async function Xn(e,t,n){try{let i=await we(e,"users.info",{user:t},n),s=i.user?.profile?.display_name;if(s&&s.length>0)return s;return i.user?.real_name??i.user?.name??t}catch{return t}}async function Gn(e,t){let n=[],i="";while(!0){let s={limit:"200"};if(i)s.cursor=i;let r=await we(e,"users.list",s,t);if(n.push(...r.members??[]),i=r.response_metadata?.next_cursor??"",!i)break}return{members:n}}async function di(e,t,n){let i=[],s="";while(!0){let r={channel:t,limit:"200"};if(s)r.cursor=s;let o=await we(e,"conversations.members",r,n);if(i.push(...o.members??[]),s=o.response_metadata?.next_cursor??"",!s)break}return i}async function pi(e,t,n){return we(e,"users.info",{user:t},n)}async function Xo(e,t,n){return we(e,"conversations.info",{channel:t},n)}async function Go(e,t){let n=await gl(e,"client.boot",{},t),i=typeof n.url==="string"?n.url:void 0;if(!i){let r=Object.keys(n).join(", ");throw Error(`client.boot did not return a WebSocket URL. Keys: ${r}`)}let s=n.self&&typeof n.self==="object"&&!Array.isArray(n.self)?n.self:{};return{wsUrl:i,selfId:typeof s.id==="string"?s.id:""}}var yl=["chat:write","im:write"],wl=["im:history","im:read"];async function hi(e){let{userId:t,botId:n,team:i,scopes:s}=await Jo(e),r="";if(n)try{r=(await zo(e,n)).appId}catch{r=""}let o=(u)=>s.includes(u),a=yl.filter((u)=>!o(u)),c=wl.filter((u)=>!o(u));return{canSend:a.length===0,canReceiveReplies:c.length===0,ok:a.length===0&&c.length===0,botUserId:t,appId:r,team:i,grantedScopes:s,missingSendScopes:a,missingReplyScopes:c}}function Vo(e){return["",` Bot user: ${e.botUserId||"(unknown)"}`,` App ID: ${e.appId||"(unknown — bots.info unavailable)"}`,` Granted scopes: ${e.grantedScopes.join(", ")||"(none reported)"}`]}function gi(e,t=!1){let n=e.appId?`https://api.slack.com/apps/${e.appId}`:"https://api.slack.com/apps";if(e.ok){let s=["✓ 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:',` ${n} → App Home → "Messages Tab" ON + "Allow users to send messages".`];return t?s:[...s,...Vo(e)]}let i=[];if(!e.canSend)i.push(`⚠ This bot CANNOT send DMs — missing scope(s): ${e.missingSendScopes.join(", ")}.`);else i.push("⚠ This bot can send DMs, but the user's replies will NOT be readable.");return i.push(" Make escalation DMs two-way:"),i.push(` 1. ${n} → App Home → enable "Messages Tab" and check`),i.push(' "Allow users to send Slash commands and messages".'),i.push(` 2. OAuth & Permissions → add Bot Token Scopes: ${[...e.missingSendScopes,...e.missingReplyScopes].join(", ")}`),i.push(" 3. Reinstall the app to apply the new scopes."),t?i:[...i,...Vo(e)]}import{createInterface as It}from"node:readline/promises";import{join as Ci}from"node:path";import{homedir as Pl}from"node:os";import{existsSync as mi,readFileSync as Di,writeFileSync as Qo,mkdirSync as ea}from"node:fs";import{homedir as bl}from"node:os";import{join as yi,dirname as ta}from"node:path";function na(){return process.env.HOME||bl()}function sa(){return yi(na(),".config","slack-cli","profiles.json")}function Fl(){return yi(process.cwd(),".slack-cli","workspace")}function Cl(){return yi(na(),".slack-cli","workspace")}function wi(){let e=sa();if(!mi(e))return{profiles:{}};return JSON.parse(Di(e,"utf8"))}function ia(e){let t=sa();ea(ta(t),{recursive:!0}),Qo(t,JSON.stringify(e,null,2)+`
|
|
102
|
+
`)}function Zo(e){if(!mi(e))return;return Di(e,"utf8").trim()||void 0}function ra(e,t){ea(ta(e),{recursive:!0});let n=mi(e)?Di(e,"utf8"):"",i=n?n.split(`
|
|
103
103
|
`):[];for(let[s,r]of Object.entries(t)){let o=i.findIndex((c)=>{let u=c.trim();return u.startsWith(s+"=")||u.startsWith(s+" =")}),a=`${s}=${r}`;if(o!==-1)i[o]=a;else i.push(a)}Qo(e,i.join(`
|
|
104
104
|
`).trimEnd()+`
|
|
105
|
-
`)}function Vn(){let e=
|
|
105
|
+
`)}function Vn(){let e=wi(),t=Zo(Fl()),n=Zo(Cl()),i=t??n;return Object.entries(e.profiles).map(([s,r])=>({name:s,profile:r,current:s===i}))}function bi(e,t){let n=wi();n.profiles[e]=t,ia(n)}function Fi(e,t){let n=wi();if(!(e in n.profiles))throw Error(`Profile not found: ${e}`);n.profiles[e].cookie=t,ia(n)}import{readdirSync as Zn,readFileSync as un,existsSync as Ot,copyFileSync as oa,unlinkSync as aa}from"node:fs";import{homedir as Qn,tmpdir as ca}from"node:os";import{join as he,dirname as El}from"node:path";import{pbkdf2Sync as ua,createDecipheriv as la}from"node:crypto";import{execSync as fa}from"node:child_process";function xl(){let e=Qn();if(process.platform==="darwin")return he(e,"Library","Application Support","Slack","Local Storage","leveldb");if(process.platform==="linux")return he(e,".config","Slack","Local Storage","leveldb");if(process.platform==="win32"){let t=process.env.APPDATA??he(e,"AppData","Roaming");return he(t,"Slack","Local Storage","leveldb")}throw Error(`Unsupported platform: ${process.platform}`)}function _l(){let e=Qn();if(process.platform==="darwin")return he(e,"Library","Application Support","Slack","Cookies");return""}function Sl(e,t){if(e.length<35||e.slice(0,3).toString()!=="v10")throw Error("Not a v10 encrypted cookie");let n=e.slice(19,35),i=e.slice(35),s=la("aes-128-cbc",t,n);return s.setAutoPadding(!0),Buffer.concat([s.update(i),s.final()]).toString("utf8")}function kl(){if(process.platform!=="darwin")return;let e=_l();if(!Ot(e))return;let t;try{t=fa('security find-generic-password -w -s "Slack Safe Storage" -a "Slack Key"',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}let n=ua(t,"saltysalt",1003,16,"sha1");try{let{default:i}=Ye("bun:sqlite"),s=new i(e,{readonly:!0}),r=s.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(s.close(),!r)return;return Sl(Buffer.from(r.encrypted_value),n)}catch{return}}async function da(){let e=xl();if(!Ot(e))throw Error(`Slack desktop app LevelDB not found at:
|
|
106
106
|
${e}
|
|
107
|
-
Is Slack installed and opened at least once?`);let t=Zn(e).filter((a)=>a.endsWith(".ldb")||a.endsWith(".log"));if(t.length===0)throw Error(`No LevelDB data files found in ${e}`);let n=new Map;for(let a of t){let c;try{c=un(he(e,a),"latin1")}catch{continue}if(a.endsWith(".log"))for(let u of c.matchAll(/"token":"(xoxc-[^"]+)"/g)){let f=u[1],l=f.split("-")[1]??"";if(!l||f.length<40)continue;let d=Math.max(0,u.index-2000),
|
|
108
|
-
`)){let a=o.trim();if(a.startsWith("[")){s="",r="";continue}let c=a.indexOf("=");if(c===-1)continue;let u=a.slice(0,c).trim().toLowerCase(),f=a.slice(c+1).trim();if(u==="name")s=f;if(u==="path")r=f.split(/[\\/]/).pop()??f;if(s&&r)n[r]=s,s="",r=""}}catch{}return n}function ha(){let e=
|
|
107
|
+
Is Slack installed and opened at least once?`);let t=Zn(e).filter((a)=>a.endsWith(".ldb")||a.endsWith(".log"));if(t.length===0)throw Error(`No LevelDB data files found in ${e}`);let n=new Map;for(let a of t){let c;try{c=un(he(e,a),"latin1")}catch{continue}if(a.endsWith(".log"))for(let u of c.matchAll(/"token":"(xoxc-[^"]+)"/g)){let f=u[1],l=f.split("-")[1]??"";if(!l||f.length<40)continue;let d=Math.max(0,u.index-2000),h=Math.min(c.length,u.index+2000),m=c.slice(d,h),p=m.match(/"url":"(https:\/\/[a-z0-9-]+\.slack\.com\/)"/),y=m.match(/"(?:team_name|name)":"([^"]{2,60})"/),C=n.get(l);if(!C||f.length>C.token.length){let F={token:f,teamId:l},S=p?.[1]??C?.url,k=y?.[1]??C?.teamName;if(S)F.url=S;if(k)F.teamName=k;n.set(l,F)}}else for(let u of c.matchAll(/xoxc-(\d+)-(\d+)-(\d+)/g)){let f=u[1];if(n.has(f))continue;let l=u.index+u[0].length,d=Math.min(l+10,c.length);while(l<d&&(c.charCodeAt(l)<48||c.charCodeAt(l)>57))l++;let h="";while(l<c.length&&c.charCodeAt(l)>=48&&c.charCodeAt(l)<=57)h+=c[l++];if(c[l]!=="-")continue;l++;let m="";while(l<c.length){let y=c.charCodeAt(l);if(y>=48&&y<=57||y>=97&&y<=102)m+=c[l++];else break}if(m.length<20)continue;let p=`${u[0]}${h}-${m}`;n.set(f,{token:p,teamId:f})}}let s=Zn(e).filter((a)=>a.endsWith(".ldb")||a.endsWith(".log")).map((a)=>{try{return un(he(e,a),"latin1").replace(/[^\x20-\x7e]/g," ")}catch{return""}}).join(" ");for(let a of n.values()){if(a.teamName)continue;let c=s.indexOf(a.teamId);if(c!==-1){let u=Math.max(0,c-500),f=Math.min(s.length,c+500),d=s.slice(u,f).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(d?.[1]){a.teamName=d[1];continue}}if(!a.teamName&&a.url){let u=a.url.match(/https:\/\/([a-z0-9-]+)\.slack\.com\//)?.[1];if(u){let f=s.indexOf(u);if(f!==-1){let l=Math.max(0,f-500),d=Math.min(s.length,f+500),m=s.slice(l,d).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(m?.[1]){a.teamName=m[1];continue}}a.teamName=u.split("-").map((l)=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ")}}}let r=kl(),o=[...n.values()];if(r)for(let a of o)a.cookie=r;return o}function Al(e,t){let n=(i,s)=>{try{let r=la("aes-128-cbc",t,i);r.setAutoPadding(!0);let o=Buffer.concat([r.update(s),r.final()]).toString("utf8");return o.startsWith("xoxd-")?o:void 0}catch{return}};return n(Buffer.alloc(16,32),e.slice(3))??(e.length>=35?n(e.slice(19,35),e.slice(35)):void 0)}function $l(e,t){let n=(i,s)=>{if(i&&s)return`${i} (${s})`;return i||s||t};try{let s=JSON.parse(un(he(e,"Local State"),"utf8")).profile?.info_cache?.[t];if(s&&(s.name||s.user_name))return n(s.name??"",s.user_name??"")}catch{}try{let s=JSON.parse(un(he(e,t,"Preferences"),"utf8")).profile;return n(s?.name??"",s?.user_name??"")}catch{return t}}function pa(){if(process.platform!=="darwin")return{candidates:[],totalProfiles:0};let e=he(Qn(),"Library","Application Support","Google","Chrome");if(!Ot(e))return{candidates:[],totalProfiles:0};let t;try{t=fa('security find-generic-password -a Chrome -s "Chrome Safe Storage" -w',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return{candidates:[],totalProfiles:0}}if(!t)return{candidates:[],totalProfiles:0};let n=ua(t,"saltysalt",1003,16,"sha1"),i=["Default",...Zn(e).filter((r)=>r.startsWith("Profile "))],s=[];for(let r of i){let o=he(e,r,"Cookies");if(!Ot(o))continue;let a=he(ca(),`slack-chrome-cookies-${Date.now()}-${r}.db`);try{oa(o,a);let{default:c}=Ye("bun:sqlite"),u=new c(a,{readonly:!0}),f=u.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(u.close(),!f)continue;let l=Buffer.from(f.encrypted_value),d=l.slice(0,3).toString();if(d==="v10"){let h=Al(l,n);if(!h)continue;s.push({profileDir:r,profileName:$l(e,r),cookie:h})}else if(d==="v20")throw Error(`Chrome cookie uses v20 (app-bound AES-256-GCM) which is not supported yet. Prefix found: ${l.slice(0,4).toString("hex")}`);else throw Error(`Unknown cookie encryption prefix: ${l.slice(0,4).toString("hex")}`)}catch(c){if(c instanceof Error&&(c.message.includes("app-bound")||c.message.includes("Unknown cookie")))throw c}finally{try{aa(a)}catch{}}}return{candidates:s,totalProfiles:i.length}}function Ol(){let e=Qn();if(process.platform==="darwin")return he(e,"Library","Application Support","Firefox","Profiles");if(process.platform==="linux")return he(e,".mozilla","firefox");if(process.platform==="win32")return he(process.env.APPDATA??he(e,"AppData","Roaming"),"Mozilla","Firefox","Profiles");return""}function Il(e){let t=he(El(e),"profiles.ini"),n={};if(!Ot(t))return n;try{let i=un(t,"utf8"),s="",r="";for(let o of i.split(`
|
|
108
|
+
`)){let a=o.trim();if(a.startsWith("[")){s="",r="";continue}let c=a.indexOf("=");if(c===-1)continue;let u=a.slice(0,c).trim().toLowerCase(),f=a.slice(c+1).trim();if(u==="name")s=f;if(u==="path")r=f.split(/[\\/]/).pop()??f;if(s&&r)n[r]=s,s="",r=""}}catch{}return n}function ha(){let e=Ol();if(!e||!Ot(e))return[];let t=Il(e),n=[],i;try{i=Zn(e)}catch{return[]}for(let s of i){let r=he(e,s,"cookies.sqlite");if(!Ot(r))continue;let o=he(ca(),`slack-firefox-cookies-${Date.now()}-${s}.db`);try{oa(r,o);let{default:a}=Ye("bun:sqlite"),c=new a(o,{readonly:!0}),u=c.prepare("SELECT value FROM moz_cookies WHERE name='d' AND host LIKE '%slack%' LIMIT 1").get();if(c.close(),!u?.value||!u.value.startsWith("xoxd-"))continue;let f=t[s]??s;n.push({profileDir:s,profileName:f,cookie:u.value})}catch{}finally{try{aa(o)}catch{}}}return n}var Tl=["search:read","channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"],Rl=["channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"];function es(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Ml(){return JSON.stringify({display_information:{name:"slack-term"},oauth_config:{scopes:{user:Tl}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}function Bl(){return JSON.stringify({display_information:{name:"slack-term"},features:{bot_user:{display_name:"slack-term",always_online:!1}},oauth_config:{scopes:{bot:Rl}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}async function Pt(e,t){return(await e.question(t)).trim()}async function Tt(e,t,n,i){console.error("Verifying token...");let s=await qt(t),r=es(s.team),o;if(n)o=n;else if(e)o=await Pt(e,`Workspace name [${r}]: `)||r;else o=r;let a=null;if(e){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 c=await Pt(e,"Choice [1/2/3/4, Enter=1]: ");if(c==="2")a=Ci(process.cwd(),".slack-term",".env.local");else if(c==="3")a=Ci(Pl(),".slack-term",".env.local");else if(c==="4")a=null;else a=Ci(process.cwd(),".env.local")}if(a===null)if(bi(o,{token:t,...s,...i?{cookie:i}:{}}),console.log(`Saved workspace "${o}" to profiles.json: ${s.team} (${s.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 ${o}`);else{let c={SLACK_TOKEN:t};if(i)c.SLACK_COOKIE=i;ra(a,c),console.log(`Saved token to ${a}`),console.log(" SLACK_TOKEN will be picked up automatically in this directory tree.")}return o}async function Nl(e){console.error("Scanning Slack desktop app...");let t=await da();if(t.length===0)console.error("No sessions found. Make sure Slack is installed and you have signed in at least once."),process.exit(1);if(t.length===1&&e){let n=t[0],i=n.teamName??n.teamId;console.log(`Found workspace: ${i}${n.cookie?" (+ xoxd cookie)":""}`),await Tt(e,n.token,es(i),n.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 n of t){let i=n.teamName??n.teamId,s=es(i);bi(s,{token:n.token,team:i,teamId:n.teamId,url:n.url??"",user:"",...n.cookie?{cookie:n.cookie}:{}}),console.log(`Added workspace "${s}": ${i}${n.cookie?" + xoxd cookie":""}`)}if(console.log(""),t.length===1){let n=es(t[0].teamName??t[0].teamId);console.log(`Run: slack auth use -g ${n}`)}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 ga(e){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 n=await Pt(e,"Choice [1/2]: ")==="2"?"bot":"user",i=n==="user"?"xoxp-":"xoxb-",s=n==="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 "${s}" (starts with ${i})`),console.log("");let r=await Pt(e,"Paste your token: ");if(!r)console.error("No token provided."),process.exit(1);if(!r.startsWith(i))console.error(`Expected a ${i} token, got: ${r.slice(0,10)}...`),process.exit(1);await Tt(e,r)}async function ts(e,t){let n=t==="user"?Ml():Bl(),i=t==="user"?"User OAuth Token (xoxp-...)":"Bot User OAuth Token (xoxb-...)",s=t==="user"?"xoxp-":"xoxb-";if(t==="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(n),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 -> ${i}`),console.log("");let r=await Pt(e,"Paste your token: ");if(!r)console.error("No token provided."),process.exit(1);if(!r.startsWith(s))console.error(`Expected a ${s} token, got: ${r.slice(0,10)}...`),process.exit(1);await Tt(e,r)}async function ma(e={}){if(process.platform!=="darwin")console.error("Chrome cookie extraction is only supported on macOS."),process.exit(1);let t=Vn();if(t.length===0)console.error("No workspaces configured. Run: slack auth login"),process.exit(1);let n;if(e.workspace){if(!t.find((c)=>c.name===e.workspace))console.error(`Workspace "${e.workspace}" not found. Available: ${t.map((c)=>c.name).join(", ")}`),process.exit(1);n=e.workspace}else if(t.length===1)n=t[0].name;else{let a=t.find((c)=>c.current);if(a)n=a.name,console.log(`Using active workspace: ${n}`);else{console.log("Multiple workspaces found. Choose one:"),t.forEach((l,d)=>console.log(` ${d+1}) ${l.name} (${l.profile.team})`));let c=It({input:process.stdin,output:process.stdout}),u=(await c.question("Choice: ")).trim();c.close();let f=parseInt(u,10)-1;if(isNaN(f)||f<0||f>=t.length)console.error("Invalid choice."),process.exit(1);n=t[f].name}}if(t.find((a)=>a.name===n).profile.token.startsWith("xoxb-")){console.error(`
|
|
109
109
|
Workspace "${n}" 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 a=t.filter((c)=>c.profile.token.startsWith("xoxc-")||c.profile.token.startsWith("xoxp-"));if(a.length>0)console.error(` Target a user-token workspace instead: ${a.map((c)=>c.name).join(", ")}`),console.error(` slack auth chrome -w ${a[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 s,r;try{({candidates:s,totalProfiles:r}=pa())}catch(a){console.error(`Failed: ${a instanceof Error?a.message:String(a)}`),process.exit(1)}if(s.length===0)console.error(`No Slack session found in Chrome (scanned ${r} profile${r!==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 o;if(s.length===1&&r<=1)o=s[0].cookie,console.log(`Found session in Chrome profile: ${s[0].profileName}`);else{let a=s.length===1?`Found 1 Slack session across ${r} Chrome profiles:`:`Found ${s.length} Slack sessions across ${r} Chrome profiles:`;console.log(a),s.forEach((d,
|
|
111
|
+
`+"actions (tail @user, DMs, listing users) would still fail.");let a=t.filter((c)=>c.profile.token.startsWith("xoxc-")||c.profile.token.startsWith("xoxp-"));if(a.length>0)console.error(` Target a user-token workspace instead: ${a.map((c)=>c.name).join(", ")}`),console.error(` slack auth chrome -w ${a[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 s,r;try{({candidates:s,totalProfiles:r}=pa())}catch(a){console.error(`Failed: ${a instanceof Error?a.message:String(a)}`),process.exit(1)}if(s.length===0)console.error(`No Slack session found in Chrome (scanned ${r} profile${r!==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 o;if(s.length===1&&r<=1)o=s[0].cookie,console.log(`Found session in Chrome profile: ${s[0].profileName}`);else{let a=s.length===1?`Found 1 Slack session across ${r} Chrome profiles:`:`Found ${s.length} Slack sessions across ${r} Chrome profiles:`;console.log(a),s.forEach((d,h)=>console.log(` ${h+1}) ${d.profileName} [${d.profileDir}]`)),console.log("");let c=It({input:process.stdin,output:process.stdout}),u=s.length===1?" [Enter=1]":"",f=(await c.question(`Choice [1-${s.length}]${u}: `)).trim();c.close();let l=f===""&&s.length===1?0:parseInt(f,10)-1;if(isNaN(l)||l<0||l>=s.length)console.error("Invalid choice."),process.exit(1);o=s[l].cookie}Fi(n,o),console.log(`Saved xoxd cookie to workspace "${n}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function Da(e={}){let t=Vn();if(t.length===0)console.error("No workspaces configured. Run: slack auth token"),process.exit(1);let n;if(e.workspace){if(!t.find((o)=>o.name===e.workspace))console.error(`Workspace "${e.workspace}" not found. Available: ${t.map((o)=>o.name).join(", ")}`),process.exit(1);n=e.workspace}else if(t.length===1)n=t[0].name;else{let r=t.find((o)=>o.current);if(r)n=r.name,console.log(`Using active workspace: ${n}`);else{console.log("Multiple workspaces found. Choose one:"),t.forEach((u,f)=>console.log(` ${f+1}) ${u.name} (${u.profile.team})`));let o=It({input:process.stdin,output:process.stdout}),a=(await o.question("Choice: ")).trim();o.close();let c=parseInt(a,10)-1;if(isNaN(c)||c<0||c>=t.length)console.error("Invalid choice."),process.exit(1);n=t[c].name}}console.log("Scanning Firefox profiles for Slack session...");let i=ha();if(i.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 s;if(i.length===1)s=i[0].cookie,console.log(`Found session in Firefox profile: ${i[0].profileName}`);else{console.log("Multiple Firefox profiles have a Slack session. Choose one:"),i.forEach((c,u)=>console.log(` ${u+1}) ${c.profileName} [${c.profileDir}]`));let r=It({input:process.stdin,output:process.stdout}),o=(await r.question("Choice: ")).trim();r.close();let a=parseInt(o,10)-1;if(isNaN(a)||a<0||a>=i.length)console.error("Invalid choice."),process.exit(1);s=i[a].cookie}Fi(n,s),console.log(`Saved xoxd cookie to workspace "${n}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function ya(e={}){if(e.token){await Tt(null,e.token,e.name);return}if(!process.stdin.isTTY){let n=[];for await(let s of process.stdin)n.push(s);let i=Buffer.concat(n).toString("utf8").trim();if(!i)console.error("No token provided on stdin."),process.exit(1);await Tt(null,i,e.name);return}let t=It({input:process.stdin,output:process.stdout});try{await ga(t)}finally{t.close()}}async function wa(e={}){let t=It({input:process.stdin,output:process.stdout});try{if(e.bot!==void 0){await ts(t,e.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 n=await Pt(t,"Choice [1/2, Enter=1]: ");await ts(t,n==="2"?"bot":"user")}finally{t.close()}}async function ns(e={}){let t=Vn();if(t.length>0){console.log("Currently logged in:");for(let{name:i,profile:s,current:r}of t)console.log(` ${r?"*":" "} ${i} ${s.team} (${s.user||"unknown"})`);console.log(""),console.log("Adding another workspace:"),console.log("")}if(e.token){await Tt(null,e.token,e.name);return}if(!process.stdin.isTTY){let i=[];for await(let r of process.stdin)i.push(r);let s=Buffer.concat(i).toString("utf8").trim();if(!s)console.error("No token provided on stdin."),process.exit(1);await Tt(null,s,e.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 n=It({input:process.stdin,output:process.stdout});try{let i=await Pt(n,"Choice [1/2/3/4]: ");if(console.log(""),i==="1")await Nl(n);else if(i==="2")await ga(n);else if(i==="3")await ts(n,"user");else if(i==="4")await ts(n,"bot");else console.error(`Invalid choice: "${i}". Enter 1, 2, 3, or 4.`),process.exit(1)}finally{n.close()}}async function ss(e,t,n,i){let s=t,r=[],o=s,a=0;while(!0){let c=o.indexOf("<@U",a);if(c===-1)break;let u=o.slice(c+2),f=u.search(/[>|]/),l=f===-1?u:u.slice(0,f);if(l.length>=9)r.push(l);a=c+1}for(let c of r){if(!n.has(c))n.set(c,await Xn(e,c,i));let u=n.get(c)??c;s=s.replaceAll(`<@${c}>`,`@${u}`),s=s.replace(new RegExp(`<@${c}\\|[^>]*>`,"g"),`@${u}`)}return s}function is(e){return e.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(t,n,i)=>{let s=Number(n);if(!Number.isFinite(s))return i??"date";let r=new Date(s*1000);if(Number.isNaN(r.getTime()))return i??"date";let o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=o[r.getUTCDay()]??"",u=a[r.getUTCMonth()]??"";return`${c}, ${u} ${String(r.getUTCDate()).padStart(2,"0")}, ${r.getUTCFullYear()}`})}function Fa(e){let t=typeof e.ts==="string"?e.ts:"",n=typeof e.thread_ts==="string"?e.thread_ts:"";return n!==""&&n!==t}function vl(e){let[t,n="000000"]=e.split("."),i=new Date(Number(t)*1000),s=i.getUTCFullYear(),r=String(i.getUTCMonth()+1).padStart(2,"0"),o=String(i.getUTCDate()).padStart(2,"0"),a=String(i.getUTCHours()).padStart(2,"0"),c=String(i.getUTCMinutes()).padStart(2,"0"),u=String(i.getUTCSeconds()).padStart(2,"0"),f=n.padEnd(6,"0").slice(0,6);return`${s}-${r}-${o}T${a}:${c}:${u}.${f}`}async function jl(e,t,n){let i=typeof t.ts==="string"?t.ts:"0.000000",s=vl(i),r="?";if(typeof t.user==="string"){let l=t.user,d="@"+l;if(!n.has(d)){let[,h]=await Yn(e,l);n.set(d,h)}r=n.get(d)??l}else if(typeof t.username==="string")r=t.username;let o=typeof t.text==="string"?t.text:"",c=is(await ss(e,o,n)).split(`
|
|
112
112
|
`),u=c[0]+(c.length>1?`
|
|
113
113
|
`+c.slice(1).map((l)=>` ${l}`).join(`
|
|
114
|
-
`):""),f=Fa(t)?"↳ ":"";return`${s} ${f}@${r}: ${u}`}async function
|
|
115
|
-
`)}),u.addEventListener("close",()=>c()),u.addEventListener("error",()=>c()),u.addEventListener("message",(f)=>{(async()=>{try{let l;try{l=JSON.parse(String(f.data))}catch{return}let d=typeof l.type==="string"?l.type:"";if(d==="ping"){u.send(JSON.stringify({type:"pong",reply_to:l.id??0}));return}if(d!=="message")return;if((typeof l.channel==="string"?l.channel:"")!==i)return;let m=typeof l.ts==="string"?l.ts:"";if(!m||r.has(m))return;let
|
|
114
|
+
`):""),f=Fa(t)?"↳ ":"";return`${s} ${f}@${r}: ${u}`}async function Ll(e,t,n,i,s,r,o,a){if(a?.aborted)return;return new Promise((c)=>{let u=new e(n);a?.addEventListener("abort",()=>{u.close(),c()},{once:!0}),u.addEventListener("open",()=>{process.stderr.write(`Connected via RTM (experimental).
|
|
115
|
+
`)}),u.addEventListener("close",()=>c()),u.addEventListener("error",()=>c()),u.addEventListener("message",(f)=>{(async()=>{try{let l;try{l=JSON.parse(String(f.data))}catch{return}let d=typeof l.type==="string"?l.type:"";if(d==="ping"){u.send(JSON.stringify({type:"pong",reply_to:l.id??0}));return}if(d!=="message")return;if((typeof l.channel==="string"?l.channel:"")!==i)return;let m=typeof l.ts==="string"?l.ts:"";if(!m||r.has(m))return;let p=typeof l.subtype==="string"?l.subtype:"";if(p==="message_changed"||p==="message_deleted")return;if(s.thread){if((typeof l.thread_ts==="string"?l.thread_ts:m)!==s.thread&&m!==s.thread)return}if(s.watchThread&&Fa(l)){if((typeof l.thread_ts==="string"?l.thread_ts:"")!==s.watchThread)return}if(s.me&&s.myUserId){if(!(typeof l.text==="string"?l.text:"").includes(`<@${s.myUserId}>`))return}if(r.add(m),r.size>1000){let C=r.values().next().value;if(C!==void 0)r.delete(C)}let y=await jl(t,l,o);process.stdout.write(y+`
|
|
116
116
|
`)}catch(l){process.stderr.write(`RTM message error: ${l instanceof Error?l.message:String(l)}
|
|
117
|
-
`)}})()})})}var ba=3,
|
|
117
|
+
`)}})()})})}var ba=3,Wl=2000,Ei={sleep:(e)=>new Promise((t)=>setTimeout(t,e)),clientBoot:Go,getWebSocket:()=>{let e=globalThis.WebSocket;return typeof e==="function"?e:void 0}};async function Ca(e,t,n,i,s,r,o){let a=Ei.getWebSocket();if(!a)return;for(let c=0;c<ba;c++){if(o?.aborted)return;try{let{wsUrl:u}=await Ei.clientBoot(e,t);await Ll(a,e,u,n,i,s,r,o)}catch{}if(o?.aborted)return;if(c<ba-1)await Ei.sleep(Wl)}}function Ea(e){let t=e.match(/^(\d+(?:\.\d+)?)(s|m|h|d)$/);if(!t)throw Error(`Invalid --since format: "${e}" (expected e.g. 10m, 2h, 1d)`);let n=parseFloat(t[1]);switch(t[2]){case"s":return n;case"m":return n*60;case"h":return n*3600;case"d":return n*86400}}var Ke={sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now(),tailRTM:Ca};function tt(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function xi(e){return Array.isArray(e)?e:[]}function xa(e){return Number(e)||0}function _a(e){let t=typeof e.ts==="string"?e.ts:"",n=typeof e.thread_ts==="string"?e.thread_ts:"";return n!==""&&n!==t}function Ul(e){let[t,n="000000"]=e.split("."),i=new Date(Number(t)*1000),s=i.getUTCFullYear(),r=String(i.getUTCMonth()+1).padStart(2,"0"),o=String(i.getUTCDate()).padStart(2,"0"),a=String(i.getUTCHours()).padStart(2,"0"),c=String(i.getUTCMinutes()).padStart(2,"0"),u=String(i.getUTCSeconds()).padStart(2,"0"),f=n.padEnd(6,"0").slice(0,6);return`${s}-${r}-${o}T${a}:${c}:${u}.${f}`}async function Kl(e,t,n,i,s){let r=typeof t.ts==="string"?t.ts:"0.000000",o=Ul(r),a="?";if(typeof t.user==="string"){let m=t.user,p="@"+m;if(!n.has(p)){let[,y]=await Yn(e,m,s);n.set(p,y)}a=n.get(p)??m}else if(typeof t.username==="string")a=t.username;let c=typeof t.text==="string"?t.text:"",f=is(await ss(e,c,n,s)).split(`
|
|
118
118
|
`),l=f[0]+(f.length>1?`
|
|
119
119
|
`+f.slice(1).map((m)=>` ${m}`).join(`
|
|
120
|
-
`):""),d=_a(t)?"↳ ":"",
|
|
120
|
+
`):""),d=_a(t)?"↳ ":"",h=i?`${i} @${a}`:`@${a}`;return`${o} ${d}${h}: ${l}`}async function Jl(e,t,n,i,s,r,o){let a=tt(await cn(e,t,20,o?void 0:n||void 0,o,i.cookie)),c=xi(a.messages).map(tt).reverse(),u=tt(a.response_metadata),f=a.has_more===!0&&typeof u.next_cursor==="string"?u.next_cursor:void 0,l=[];if(i.watchThread&&!o){let y=tt(await Ho(e,t,i.watchThread,50,i.cookie));l=xi(y.messages).map(tt).filter((C)=>(typeof C.ts==="string"?C.ts:"")!==i.watchThread)}let d=[...c.map((y)=>({m:y,fromHistory:!0})),...l.map((y)=>({m:y,fromHistory:!1}))].sort((y,C)=>xa(typeof y.m.ts==="string"?y.m.ts:"")-xa(typeof C.m.ts==="string"?C.m.ts:"")),h=[],m=n,p=!1;for(let{m:y,fromHistory:C}of d){let F=typeof y.ts==="string"?y.ts:"";if(!F||s.has(F))continue;let S=typeof y.subtype==="string"?y.subtype:"";if(S==="message_changed"||S==="message_deleted")continue;if(i.thread){if((typeof y.thread_ts==="string"?y.thread_ts:F)!==i.thread&&F!==i.thread)continue}if(i.watchThread&&_a(y)){if((typeof y.thread_ts==="string"?y.thread_ts:"")!==i.watchThread)continue}if(i.me&&i.myUserId){if(!(typeof y.text==="string"?y.text:"").includes(`<@${i.myUserId}>`))continue}if(s.add(F),s.size>1000){let j=s.values().next().value;if(j!==void 0)s.delete(j)}if(h.push(await Kl(e,y,r,void 0,i.cookie)),C)m=F;let k=typeof y.user==="string"?y.user:"";if(!i.myUserId||k!==i.myUserId)p=!0}return{newCursor:m,lines:h,hasMore:a.has_more===!0,nextPageCursor:f,emittedOther:p}}function zl(e){if(e.includes("slack.com")){let t=fi(e),n=t?.threadTs??t?.ts;if(n)return n;throw Error(`--watch-thread: could not extract a timestamp from "${e}"`)}if(/^\d{10}\.\d{6}$/.test(e))return e;if(/^\d{16}$/.test(e))return`${e.slice(0,10)}.${e.slice(10)}`;throw Error(`--watch-thread: "${e}" is not a valid ts or permalink`)}async function Sa(e,t,n={},i){if(n.me&&!t)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(!t)console.error("Usage: slack tail <#channel|@user>\n Run `slack tail --help` for details."),process.exit(1);let s=await Yo(e,t),r=n.interval??60000,o=n.timeout?
|
|
122
|
+
Use: slack tail "#channel" --me`),process.exit(1);if(!t)console.error("Usage: slack tail <#channel|@user>\n Run `slack tail --help` for details."),process.exit(1);let s=await Yo(e,t),r=n.interval??60000,o=n.timeout?Ke.now()+Ea(n.timeout)*1000:1/0,a=new Map,c=new Set;try{let p=tt(await Xo(e,s,n.cookie));if(tt(p.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(p){let y=p instanceof Error?p.message:String(p);if(y.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(y.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(y.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: ${y}`)}let u="";if(n.since){let p=Ea(n.since);u=(Ke.now()/1000-p).toFixed(6)}else{let p=tt(await cn(e,s,1,void 0,void 0,n.cookie)),y=xi(p.messages).map(tt);if(y.length>0&&typeof y[0]?.ts==="string")u=y[0].ts,c.add(u);else u=(Ke.now()/1000).toFixed(6)}let f;if(n.me||n.exitOnMessage)f=(await qt(e,n.cookie)).userId||void 0;let l;if(n.watchThread!==void 0)try{l=zl(n.watchThread)}catch(p){console.error(p instanceof Error?p.message:String(p)),process.exit(1)}let d={...n.thread!==void 0?{thread:n.thread}:{},...l!==void 0?{watchThread:l}:{},...n.me!==void 0?{me:n.me}:{},...f!==void 0?{myUserId:f}:{},...n.cookie!==void 0?{cookie:n.cookie}:{}};if(e.startsWith("xoxc-")&&n.cookie!==void 0&&n.noRtm!==!0&&n.since===void 0&&n.timeout===void 0&&n.exitOnMessage!==!0){if(await Ke.tailRTM(e,n.cookie,s,d,c,a,i),i?.aborted)return;console.error("RTM unavailable — switching to polling.")}let h=!0,m=Ke.now();while(!i?.aborted){if(Ke.now()>=o)return;let p=!1;try{let F=Ke.now()-m,S=r>0&&F>r*5,k,j=!0;do{let{newCursor:A,lines:M,nextPageCursor:R,emittedOther:P}=await Jl(e,s,u,d,c,a,k);if(u=A,h&&j&&n.since&&M.length===0)process.stdout.write(`(no messages in the last ${n.since} — watching for new)
|
|
123
123
|
`);j=!1;for(let q of M)process.stdout.write(q+`
|
|
124
|
-
`);if(
|
|
124
|
+
`);if(P)p=!0;k=S?R:void 0}while(k);h=!1}catch(C){if(C instanceof Ve){console.error(`Warning: Slack rate limit hit — backing off for ${C.retryAfter}s`),await Ke.sleep(C.retryAfter*1000);continue}throw C}if(n.exitOnMessage&&p)return;m=Ke.now();let y=o-Ke.now();if(y<=0)return;await Ke.sleep(Math.min(r,y))}}var Be=[{name:"one",glyph:"1️⃣"},{name:"two",glyph:"2️⃣"},{name:"three",glyph:"3️⃣"},{name:"four",glyph:"4️⃣"},{name:"five",glyph:"5️⃣"},{name:"six",glyph:"6️⃣"},{name:"seven",glyph:"7️⃣"},{name:"eight",glyph:"8️⃣"},{name:"nine",glyph:"9️⃣"},{name:"keycap_ten",glyph:"\uD83D\uDD1F"}],os=Be.length,as="question";function _i(e){let t=e.split(`
|
|
125
125
|
`),n=t[t.length-2];if(n===void 0||!n.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")||!n.endsWith("_"))return[];return[...n.matchAll(/<@([UW][A-Z0-9]+)>/g)].map((i)=>i[1])}function Si(e,t){let n=e.split(`
|
|
126
126
|
`);if(n.length<2)return e;if(_i(e).length)n.splice(n.length-2,1);if(t.length)n.splice(n.length-1,0,`${"_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: "}${t.map((s)=>`<@${s}>`).join(", ")}_`);let i=n.join(`
|
|
127
|
-
`);return i===e?e:i}function
|
|
128
|
-
`)}function
|
|
127
|
+
`);return i===e?e:i}function Hl(e){return e!==void 0&&e.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")&&e.endsWith("_")}var ki="white_check_mark",rs=`:${ki}: `;function ka(e){return`:${Be[e].name}:`}function Aa(e,t){let n=Be[t];for(let i of[ka(t),n.glyph]){if(e.startsWith(`${i} `))return e.slice(i.length+1);if(e===i)return""}return null}function ql(e){return Be.some((t,n)=>Aa(e,n)!==null)}function ln(e){return e.replace(/\s*\n\s*/g," ")}function $a(e,t,n,i,s){let r=[`:question: *${e}*`];if(t)r.push("",t);if(n.length){if(r.push(""),r.push(...n.map((o,a)=>`${ka(a)} ${ln(o)}`)),i.length)r.push(""),r.push(...i.map((o,a)=>`(${a+11}) ${ln(o)}`)),r.push("_11 番目以降はリアクションがないので、返信で答えてください。_");r.push(""),r.push(s?"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージの *スレッド* で返信してください (チャンネルへの通常投稿は回答として拾いません)。_":"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージに返信してください。_")}else r.push(""),r.push(s?"_このメッセージの *スレッド* で返信してください。本文がそのまま回答になります (チャンネルへの通常投稿は回答として拾いません)。_":"_このメッセージに返信してください。本文がそのまま回答になります。_");return r.join(`
|
|
128
|
+
`)}function Oa(e,t,n){let i=t.answer.split(`
|
|
129
129
|
`).map((s)=>`> ${s}`).join(`
|
|
130
|
-
`);return`${
|
|
130
|
+
`);return`${rs}*${e}*
|
|
131
131
|
_${t.how}で回答済み${n?` (${n})`:""}_
|
|
132
132
|
|
|
133
|
-
${i}`}function
|
|
134
|
-
`);if(e.startsWith(
|
|
133
|
+
${i}`}function Ia(e){if(!e.trim())return"本文が空です (bot 投稿や添付のみのメッセージかもしれません)";let t=e.split(`
|
|
134
|
+
`),n=t[t.length-1]??"";if(e.startsWith(rs))return"回答済みマーク付きですが、引用された回答本文が見つかりません";if(!/_$/.test(n))return"末尾が `ask` の案内文ではありません — このメッセージは `slack ask` で投稿されたものではないか、本文が編集されています";if(!t[0].startsWith(":question: ")&&!t[0].startsWith("*"))return"先頭が質問文 (太字) ではありません — 本文が編集されている可能性があります";return"選択肢の並びを読み取れません — 番号が 1 から連番になっていないか、本文が編集されています"}function Pa(e){let t=e.split(`
|
|
135
|
+
`);if(e.startsWith(rs)){let l=t[0].slice(rs.length).replace(/^\*/,"").replace(/\*$/,""),d=t.filter((h)=>h.startsWith("> ")).map((h)=>h.slice(2)).join(`
|
|
135
136
|
`);if(!d)return{kind:"other"};return{kind:"resolved",question:l,answer:d}}let n=t[t.length-1]??"",i,s;switch(n){case"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージの *スレッド* で返信してください (チャンネルへの通常投稿は回答として拾いません)。_":i=!0,s=!0;break;case"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージに返信してください。_":i=!1,s=!0;break;case"_このメッセージの *スレッド* で返信してください。本文がそのまま回答になります (チャンネルへの通常投稿は回答として拾いません)。_":i=!0,s=!1;break;case"_このメッセージに返信してください。本文がそのまま回答になります。_":i=!1,s=!1;break;default:return{kind:"other"}}let r=t[0].startsWith(":question: ")?t[0].slice(11):t[0];if(t[0]=r,!t[0].startsWith("*"))return{kind:"other"};let o=0;while(o<t.length&&!(t[o].endsWith("*")&&(o>0||t[0].length>1)))o++;if(o>=t.length)return{kind:"other"};let a=t.slice(0,o+1).join(`
|
|
136
|
-
`).replace(/^\*/,"").replace(/\*$/,""),c=[],u=[];if(s){let f=t.length-2;if(
|
|
137
|
-
`),n=t[t.length-2];if(n===void 0||!n.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")||!n.endsWith("_"))return[];return[...n.matchAll(/<@([UW][A-Z0-9]+)>/g)].map((i)=>i[1])}function
|
|
137
|
+
`).replace(/^\*/,"").replace(/\*$/,""),c=[],u=[];if(s){let f=t.length-2;if(Hl(t[f]))f--;if(t[f]!=="")return{kind:"other"};if(f--,t[f]==="_11 番目以降はリアクションがないので、返信で答えてください。_"){f--;while(f>=0&&/^\(\d+\) /.test(t[f]))u.unshift(t[f].replace(/^\(\d+\) /,"")),f--;if(t[f]!=="")return{kind:"other"};f--}let l=[];while(f>=0){let d=t[f];if(!ql(d))break;l.unshift(d),f--}if(!l.length||l.length>os)return{kind:"other"};for(let d=0;d<l.length;d++){let h=Aa(l[d],d);if(h===null)return{kind:"other"};c.push(h)}if(t[f]!=="")return{kind:"other"};if(f<o+1)return{kind:"other"};for(let d=0;d<u.length;d++)if(!t.includes(`(${d+11}) ${u[d]}`))return{kind:"other"}}return{kind:"open",question:a,reactable:c,overflow:u,threadOnly:i}}var Ai=[{name:"one",glyph:"1️⃣"},{name:"two",glyph:"2️⃣"},{name:"three",glyph:"3️⃣"},{name:"four",glyph:"4️⃣"},{name:"five",glyph:"5️⃣"},{name:"six",glyph:"6️⃣"},{name:"seven",glyph:"7️⃣"},{name:"eight",glyph:"8️⃣"},{name:"nine",glyph:"9️⃣"},{name:"keycap_ten",glyph:"\uD83D\uDD1F"}],Bg=Ai.length;function $i(e){let t=e.split(`
|
|
138
|
+
`),n=t[t.length-2];if(n===void 0||!n.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")||!n.endsWith("_"))return[];return[...n.matchAll(/<@([UW][A-Z0-9]+)>/g)].map((i)=>i[1])}function Ta(e,t){let n=e.split(`
|
|
138
139
|
`);if(n.length<2)return e;if($i(e).length)n.splice(n.length-2,1);if(t.length)n.splice(n.length-1,0,`${"_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: "}${t.map((s)=>`<@${s}>`).join(", ")}_`);let i=n.join(`
|
|
139
|
-
`);return i===e?e:i}function
|
|
140
|
-
`),s?[]:o)}function
|
|
141
|
-
`)}function
|
|
142
|
-
`);if(e.startsWith(Ii)){let d=t[0].slice(Ii.length).replace(/^\*/,"").replace(/\*$/,""),
|
|
143
|
-
`).replace(/^\*/,"").replace(/\*$/,""),o=t.length-2,a=$i(e);if(
|
|
140
|
+
`);return i===e?e:i}function Ra(e){return e!==void 0&&e.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")&&e.endsWith("_")}var Yl="white_check_mark",Ng=`:${Yl}: `;var Ne=Ai,Yt=Ne.length,dn="ballot_box_with_ballot",Oi=`:${dn}: `,Ba="_下のリアクションで投票してください (1 人 1 票、押し直しで変更できます)。_",Na="_下のリアクションで投票してください (当てはまるものを *いくつでも* 押せます)。_",cs="_締切: ",us="_",Pi="bar_chart",Ii=`:${Pi}: `;function ls(e){return`:${Ne[e].name}:`}function Ma(e,t){for(let n of[ls(t),Ne[t].glyph])if(e.startsWith(`${n} `))return e.slice(n.length+1);return null}function Xl(e){return Ne.some((t,n)=>e.startsWith(`${ls(n)} `)||e.startsWith(`${t.glyph} `))}function fn(e){return e.replace(/\s*\n\s*/g," ")}function va(e,t,n,i={}){let s=!!i.multi,r=i.deadline??"",o=i.invalid??[];if(!n.length||n.length>Yt)throw Error(`poll needs 1..${Yt} choices, got ${n.length}`);let a=[`${Oi}*${e}*`];if(t)a.push("",t);if(a.push(""),a.push(...n.map((c,u)=>`${ls(u)} ${fn(c)}`)),a.push(""),r)a.push(`${cs}${fn(r)}${us}`);return a.push(s?Na:Ba),Ta(a.join(`
|
|
141
|
+
`),s?[]:o)}function ja(e,t){let n=t.reduce((s,r)=>s+r.count,0),i=[`${Ii}*${e}*`,`_投票終了 (計 ${n} 票)_`,""];return i.push(...t.map((s,r)=>`${ls(r)} ×${s.count} ${fn(s.choice)}`)),i.join(`
|
|
142
|
+
`)}function La(e){let t=e.split(`
|
|
143
|
+
`);if(e.startsWith(Ii)){let d=t[0].slice(Ii.length).replace(/^\*/,"").replace(/\*$/,""),h=[];for(let m=0;m<Ne.length;m++){let p=t.map((C)=>Ma(C,m)).find((C)=>C!==null&&C.startsWith("×"));if(p===void 0)break;let y=/^×(\d+) (.*)$/.exec(p);if(!y)return{kind:"other"};h.push({choice:y[2],count:Number(y[1])})}if(!h.length)return{kind:"other"};return{kind:"closed",question:d,tallies:h}}let n=t[t.length-1]??"",i;if(n===Ba)i=!1;else if(n===Na)i=!0;else return{kind:"other"};if(t[0].startsWith(Oi))t[0]=t[0].slice(Oi.length);if(!t[0].startsWith("*"))return{kind:"other"};let s=0;while(s<t.length&&!(t[s].endsWith("*")&&(s>0||t[0].length>1)))s++;if(s>=t.length)return{kind:"other"};let r=t.slice(0,s+1).join(`
|
|
144
|
+
`).replace(/^\*/,"").replace(/\*$/,""),o=t.length-2,a=$i(e);if(Ra(t[o]))o--;let c="",u=t[o];if(u!==void 0&&u.startsWith(cs)&&u.endsWith(us)&&u.length>cs.length+us.length)c=u.slice(cs.length,-us.length),o--;if(t[o]!=="")return{kind:"other"};o--;let f=[];while(o>=0){let d=t[o];if(!Xl(d))break;f.unshift(d),o--}if(!f.length||f.length>Yt)return{kind:"other"};let l=[];for(let d=0;d<f.length;d++){let h=Ma(f[d],d);if(h===null)return{kind:"other"};l.push(h)}if(t[o]!=="")return{kind:"other"};if(o<s+1)return{kind:"other"};return{kind:"open",question:r,choices:l,multi:i,deadline:c,invalid:a}}function Wa(e,t,n,i){let s=new Map(t.map((u)=>[u.name,u.users])),r=e.map((u,f)=>(s.get(Ne[f].name)??[]).filter((l)=>!n.has(l))),o=[];if(!i){let u=new Map;for(let f of r)for(let l of f)u.set(l,(u.get(l)??0)+1);for(let[f,l]of u)if(l>1)o.push(f)}let a=new Set(o),c=r.map((u)=>u.filter((f)=>!a.has(f)));return{tallies:e.map((u,f)=>({choice:u,count:c[f].length})),voters:c,ambiguous:o}}class Xt extends Error{retryAfter;constructor(e){super(`Slack rate limited — retry after ${e}s`);this.name="RateLimitError",this.retryAfter=e}}function Ti(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function Ka(e,t,n,i){let s={};if(i)s.Cookie=`d=${i}`;let r=await fetch(`${Ti()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(r.status===429){let a=parseInt(r.headers.get("retry-after")??"60",10);throw new Xt(isNaN(a)?60:a)}let o=await r.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new Xt(60);if(a==="invalid_auth"&&e.startsWith("xoxc-")&&!i)throw Error(`Desktop app token (xoxc-) needs its session cookie to be accepted by the public Slack API.
|
|
144
145
|
Attach it: slack auth chrome (macOS) or slack auth firefox
|
|
145
146
|
Or replace the token with an xoxp- user token:
|
|
146
147
|
slack auth token`);if((a==="missing_scope"||a==="cannot_dm_bot")&&e.startsWith("xoxb-"))throw Error(`Slack error on ${t}: ${a} — ${a==="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"}.
|
|
147
148
|
Tailing/DMing people and listing users need a user session, not a bot token.
|
|
148
149
|
Switch workspace: slack auth ls then slack auth use <name>
|
|
149
|
-
Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${t}: ${a}`)}return o}async function
|
|
150
|
+
Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${t}: ${a}`)}return o}async function Gl(e,t,n,i){let s={};if(i)s.Cookie=`d=${i}`;let r=await fetch(`${Ti()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(r.status===429){let a=parseInt(r.headers.get("retry-after")??"60",10);throw new Xt(isNaN(a)?60:a)}let o=await r.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new Xt(60);if((a==="invalid_auth"||a==="not_authed")&&!e.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
|
|
150
151
|
Import from Slack desktop: slack auth login`);if((a==="invalid_auth"||a==="not_authed")&&!i)throw Error(`drafts.list also requires the xoxd session cookie.
|
|
151
|
-
Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${t}: ${a}`)}return o}function Rt(e,t,n={},i){let s=new URLSearchParams({token:e,...n});return Hl(e,t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},i)}function re(e,t,n,i){let s=new URLSearchParams(n).toString();return La(e,`${t}?${s}`,{method:"GET"},i)}function Ke(e,t,n,i){return La(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},i)}async function Wa(e,t){let n=await re(e,"auth.test",{},t);return{team:n.team??"",teamId:n.team_id??"",url:n.url??"",user:n.user??"",userId:n.user_id??""}}async function Ua(e,t){let n={Authorization:`Bearer ${e}`};if(t)n.Cookie=`d=${t}`;let i=await fetch(`${Pi()}/auth.test`,{method:"GET",headers:n});if(i.status===429){let o=parseInt(i.headers.get("retry-after")??"60",10);throw new Xt(isNaN(o)?60:o)}let s=i.headers.get("x-oauth-scopes")??"",r=await i.json();if(r.ok!==!0)throw Error(`Slack error on auth.test: ${r.error??"unknown"}`);return{userId:r.user_id??"",user:r.user??"",botId:r.bot_id??"",team:r.team??"",url:r.url??"",scopes:s.split(",").map((o)=>o.trim()).filter(Boolean)}}async function Qe(e,t,n=20,i,s,r,o){let a={channel:t,limit:String(n)};if(i!==void 0)a.oldest=i;if(s!==void 0)a.cursor=s;if(o)a.inclusive="true";return re(e,"conversations.history",a,r)}async function ze(e,t,n,i=50,s){return re(e,"conversations.replies",{channel:t,ts:n,limit:String(i)},s)}async function Ja(e,t,n){return re(e,"files.info",{file:t},n)}async function Ka(e,t={},n){let i={count:String(Math.min(Math.max(t.count??100,1),200)),page:String(Math.max(t.page??1,1))};if(t.types)i.types=t.types;if(t.channel)i.channel=t.channel;if(t.user)i.user=t.user;return re(e,"files.list",i,n)}async function za(e,t,n={},i){let s={list_id:t};if(n.limit)s.limit=String(n.limit);if(n.cursor)s.cursor=n.cursor;return Rt(e,"lists.records.list",s,i)}async function Ha(e,t,n,i,s){return re(e,"search.messages",{query:t,sort:"timestamp",sort_dir:"desc",count:String(Math.min(Math.max(n,1),100)),page:String(Math.max(i,1))},s)}async function qa(e,t,n){return Ha(e,t,100,1,n)}async function Ri(e,t,n,i){let r=1,o=[],a={ok:!0,messages:{}};while(!0){let u=await Ha(e,t,100,r,i),f=pn(u,["messages","matches"]),l=Array.isArray(f)?f:[];o.push(...l);let d=Number(pn(u,["messages","paging","pages"])??1);if(a=u,l.length===0||r>=d||o.length>=n)break;r+=1}let c=a;if(!c.messages)c.messages={};return c.messages.matches=o.slice(0,n),c}async function ls(e,t,n,i,s,r,o){let a=o?{channel:t,text:n}:{channel:t,text:n,blocks:[{type:"markdown",text:n}]};if(i!==void 0)a.thread_ts=i;if(s&&i!==void 0)a.reply_broadcast=!0;return(await Ke(e,"chat.postMessage",a,r)).ts??""}async function Ya(e,t,n,i,s,r){let o={channel:t,text:n,post_at:i,blocks:[{type:"markdown",text:n}]};if(s!==void 0)o.thread_ts=s;return(await Ke(e,"chat.scheduleMessage",o,r)).scheduled_message_id??""}async function Xa(e,t,n){let i={};if(t)i.channel=t;return re(e,"chat.scheduledMessages.list",i,n)}async function Ga(e,t,n,i){await Ke(e,"chat.deleteScheduledMessage",{channel:t,scheduled_message_id:n},i)}async function hn(e,t,n,i){return(await re(e,"chat.getPermalink",{channel:t,message_ts:n},i)).permalink??""}async function Gt(e,t,n,i,s,r){return(await Ke(e,"chat.update",r?{channel:t,ts:n,text:i}:{channel:t,ts:n,text:i,blocks:[{type:"markdown",text:i}]},s)).ts??n}async function Va(e,t,n,i){await Ke(e,"chat.delete",{channel:t,ts:n},i)}async function ut(e,t,n,i,s){await Ke(e,"reactions.add",{channel:t,timestamp:n,name:i},s)}async function Za(e,t,n,i){return((await re(e,"reactions.get",{channel:t,timestamp:n,full:"true"},i)).message?.reactions??[]).map((r)=>({name:String(r.name??""),users:Array.isArray(r.users)?r.users.map(String):[]}))}async function gn(e,t,n,i,s){await Ke(e,"reactions.remove",{channel:t,timestamp:n,name:i},s)}async function Qa(e,t,n=!1,i){let s=await Ke(e,"conversations.create",{name:t,is_private:n},i);return{id:s.channel?.id??"",name:s.channel?.name??t}}async function ec(e,t,n,i){await Ke(e,"conversations.invite",{channel:t,users:n.join(",")},i)}async function mn(e,t){let n=[],i="";while(!0){let s={limit:"200",types:"public_channel,private_channel,im,mpim"};if(i)s.cursor=i;let r=await re(e,"conversations.list",s,t);if(n.push(...r.channels??[]),i=r.response_metadata?.next_cursor??"",!i)break}return{channels:n}}async function Mt(e,t,n){let s=(await Ke(e,"conversations.open",{users:t},n)).channel?.id;if(!s)throw Error(`Failed to open DM with user ${t}`);return s}function Ze(e){return e.toLowerCase().replace(/[-_\s]/g,"")}async function Dn(e,t,n){if(!t.startsWith("@")){if(/^[UW][A-Za-z0-9]{6,}$/.test(t))return t;throw Error(`Expected @user or a user ID, got: ${t}`)}let i=Ze(t.slice(1)),s=await re(e,"auth.test",{},n);if(i==="you"||i==="me"||Ze(s.user??"")===i){if(!s.user_id)throw Error("auth.test did not return user_id");return s.user_id}let r="";while(!0){let o={limit:"200"};if(r)o.cursor=r;let a=await re(e,"users.list",o,n);for(let c of a.members??[]){let u=Ze(c.name??""),f=Ze(c.real_name??""),l=Ze(c.profile?.display_name??"");if(u===i||f===i||l&&l===i)return c.id??""}if(r=a.response_metadata?.next_cursor??"",!r)break}throw Error(`User not found: ${t}`)}function Bt(e){let t=e.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(!t)return;let n=t[1],i=t[2]&&t[3]?`${t[2]}.${t[3]}`:void 0,s=e.indexOf("?"),r=s>=0?new URLSearchParams(e.slice(s)):void 0,o=r?.get("thread_ts")??void 0,u={channel:r?.get("cid")??void 0??n};if(i)u.ts=i;if(o)u.threadTs=o;return u}function ql(e){return Bt(e)?.channel}function ja(e){return/^[CDG][A-Z0-9]{8,}$/.test(e)}async function De(e,t,n){let i=ql(t);if(i)return i;if(!t.startsWith("@")&&!t.startsWith("#")){if(ja(t))return t;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${t}`)}if(t.startsWith("#")&&ja(t.slice(1)))return t.slice(1);let s=t.startsWith("@"),r=t.slice(1),o=Ze(r);if(s){let u=await re(e,"auth.test",{},n);if(o==="you"||o==="me"||Ze(u.user??"")===o){let m=u.user_id;if(!m)throw Error("auth.test did not return user_id");let y=((await re(e,"conversations.list",{types:"im",limit:"200"},n)).channels??[]).find((C)=>C.user===m);if(y?.id)return String(y.id);return Mt(e,m,n)}let l="",d="";while(!0){let m={limit:"200"};if(d)m.cursor=d;let h=await re(e,"users.list",m,n);for(let y of h.members??[]){let C=Ze(y.name??""),F=Ze(y.real_name??""),S=Ze(y.profile?.display_name??"");if(C===o||F===o||S&&S===o){l=y.id??"";break}}if(l)break;if(d=h.response_metadata?.next_cursor??"",!d)break}if(!l)throw Error(`User not found: ${t}`);let p="";while(!0){let m={types:"im",limit:"200"};if(p)m.cursor=p;let h=await re(e,"conversations.list",m,n);for(let y of h.channels??[])if(y.user===l)return String(y.id??"");if(p=h.response_metadata?.next_cursor??"",!p)break}throw Error(`No existing DM with ${t} (${l}). Open it once in Slack first.`)}let a=r.toLowerCase(),c="";while(!0){let u={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(c)u.cursor=c;let f=await re(e,"conversations.list",u,n);for(let l of f.channels??[])if(String(l.name??"").toLowerCase()===a)return String(l.id??"");if(c=f.response_metadata?.next_cursor??"",!c)break}throw Error(`channel not found: ${t}`)}async function yn(e,t,n){try{let i=await re(e,"users.info",{user:t},n),s=i.user?.profile?.display_name,r=s&&s.length>0?s:i.user?.real_name??i.user?.name??t,o=i.user?.name??t;return[r,o]}catch{return[t,t]}}async function He(e,t,n){try{let i=await re(e,"users.info",{user:t},n),s=i.user?.profile?.display_name;if(s&&s.length>0)return s;return i.user?.real_name??i.user?.name??t}catch{return t}}async function Mi(e,t){let n=[],i="";while(!0){let s={limit:"200"};if(i)s.cursor=i;let r=await re(e,"users.list",s,t);if(n.push(...r.members??[]),i=r.response_metadata?.next_cursor??"",!i)break}return{members:n}}async function tc(e,t,n){let i=[],s="";while(!0){let r={channel:t,limit:"200"};if(s)r.cursor=s;let o=await re(e,"conversations.members",r,n);if(i.push(...o.members??[]),s=o.response_metadata?.next_cursor??"",!s)break}return i}async function wn(e,t){return Rt(e,"drafts.list",{},t)}async function nc(e,t,n,i){let{randomUUID:s}=await import("node:crypto"),r=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:n}]}]}]);return Rt(e,"drafts.create",{client_msg_id:s(),destinations:JSON.stringify([{channel_id:t}]),blocks:r,file_ids:JSON.stringify([]),is_from_composer:"true"},i)}async function sc(e,t,n,i,s){let r=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:i}]}]}]),o=(Date.now()/1000).toFixed(6);return Rt(e,"drafts.update",{draft_id:t,client_last_updated_ts:o,destinations:JSON.stringify([{channel_id:n}]),blocks:r,file_ids:JSON.stringify([])},s)}async function ic(e,t,n){return Rt(e,"conversations.info",{channel:t},n)}async function bn(e,t,n){return re(e,"users.info",{user:t},n)}async function Fn(e,t,n){return re(e,"conversations.info",{channel:t},n)}async function rc(e,t,n){let i=(Date.now()/1000).toFixed(6);return Rt(e,"drafts.delete",{draft_id:t,client_last_updated_ts:i},n)}async function Bi(e,t){let n=await Rt(e,"auth.test",{},t);return{userId:String(n.user_id??""),teamId:String(n.team_id??"")}}async function oc(e,t,n,i={},s){let{statSync:r,readFileSync:o}=await import("node:fs"),{basename:a}=await import("node:path"),c=r(n),u=a(n),f=await re(e,"files.getUploadURLExternal",{filename:u,length:String(c.size)},s),l=f.upload_url,d=f.file_id;if(!l||!d)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let p=o(n),m=await fetch(l,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:p});if(!m.ok)throw Error(`Upload PUT failed: ${m.status} ${m.statusText}`);let h={files:[{id:d,title:i.title??u}],channel_id:t};if(i.threadTs)h.thread_ts=i.threadTs;if(i.initialComment)h.initial_comment=i.initialComment;let y=await Ke(e,"files.completeUploadExternal",h,s),C={fileId:d},F=y.files?.[0]?.permalink;if(F)C.permalink=F;return C}function pn(e,t){let n=e;for(let i of t){if(n===void 0||n===null)return;if(typeof i==="number"){if(!Array.isArray(n))return;n=n[i]??void 0}else{if(typeof n!=="object"||Array.isArray(n))return;n=n[i]}}return n}import{existsSync as sf,readFileSync as rf}from"node:fs";import{homedir as of}from"node:os";import{join as af}from"node:path";import{existsSync as Yl,mkdirSync as Xl,readFileSync as Gl,writeFileSync as Vl}from"node:fs";import{homedir as Zl}from"node:os";import{dirname as Ql,join as ef}from"node:path";var tf=3600000,fs={now:()=>Date.now(),path:()=>ef(process.env.HOME||Zl(),".config","slack-cli","cache.json")},ds=!0,lt;function ac(){return{channels:{},users:{}}}function Ni(){if(lt)return lt;if(lt=ac(),!ds)return lt;try{let e=fs.path();if(!Yl(e))return lt;let t=JSON.parse(Gl(e,"utf8"));for(let n of["channels","users"]){let i=t?.[n];if(!i||typeof i!=="object"||Array.isArray(i))continue;for(let[s,r]of Object.entries(i))if(r&&typeof r==="object"&&typeof r.value==="string"&&typeof r.expires==="number")lt[n][s]={value:r.value,expires:r.expires}}}catch{lt=ac()}return lt}function nf(e){if(!ds)return;try{let t=fs.path();Xl(Ql(t),{recursive:!0}),Vl(t,JSON.stringify(e,null,2)+`
|
|
152
|
-
`)}catch{}}function
|
|
153
|
-
`)[0]??"",emoji:F,keep:F[0]})}if(f=
|
|
154
|
-
`;case"t":return"\t";case"\\":case"¥":return n==="¥"?"¥":"\\";default:return t}})}function Nt(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function dt(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function
|
|
155
|
-
`)),r=await vt(e,t,n,i.cookie);for(let o of En(r.unresolved))s(`warn: ${o}`);return r.text}var
|
|
156
|
-
⚠ QUIET HOURS (${r}:00-${o}:00) — this will buzz a phone.${i?"":" Their local time may differ."} Send only for a production incident; otherwise hold it until morning.`}function
|
|
157
|
-
`)){let i=n.trim();if(!i||i.startsWith("#"))continue;let s=i.indexOf("=");if(s===-1)continue;let r=i.slice(0,s).trim(),o=i.slice(s+1).trim();if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))o=o.slice(1,-1);if(!(r in process.env))process.env[r]=o}}function
|
|
158
|
-
`)}function
|
|
152
|
+
Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${t}: ${a}`)}return o}function Rt(e,t,n={},i){let s=new URLSearchParams({token:e,...n});return Gl(e,t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},i)}function re(e,t,n,i){let s=new URLSearchParams(n).toString();return Ka(e,`${t}?${s}`,{method:"GET"},i)}function Je(e,t,n,i){return Ka(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},i)}async function Ja(e,t){let n=await re(e,"auth.test",{},t);return{team:n.team??"",teamId:n.team_id??"",url:n.url??"",user:n.user??"",userId:n.user_id??""}}async function za(e,t){let n={Authorization:`Bearer ${e}`};if(t)n.Cookie=`d=${t}`;let i=await fetch(`${Ti()}/auth.test`,{method:"GET",headers:n});if(i.status===429){let o=parseInt(i.headers.get("retry-after")??"60",10);throw new Xt(isNaN(o)?60:o)}let s=i.headers.get("x-oauth-scopes")??"",r=await i.json();if(r.ok!==!0)throw Error(`Slack error on auth.test: ${r.error??"unknown"}`);return{userId:r.user_id??"",user:r.user??"",botId:r.bot_id??"",team:r.team??"",url:r.url??"",scopes:s.split(",").map((o)=>o.trim()).filter(Boolean)}}async function Qe(e,t,n=20,i,s,r,o){let a={channel:t,limit:String(n)};if(i!==void 0)a.oldest=i;if(s!==void 0)a.cursor=s;if(o)a.inclusive="true";return re(e,"conversations.history",a,r)}async function ze(e,t,n,i=50,s){return re(e,"conversations.replies",{channel:t,ts:n,limit:String(i)},s)}async function Ha(e,t,n){return re(e,"files.info",{file:t},n)}async function qa(e,t={},n){let i={count:String(Math.min(Math.max(t.count??100,1),200)),page:String(Math.max(t.page??1,1))};if(t.types)i.types=t.types;if(t.channel)i.channel=t.channel;if(t.user)i.user=t.user;return re(e,"files.list",i,n)}async function Ya(e,t,n={},i){let s={list_id:t};if(n.limit)s.limit=String(n.limit);if(n.cursor)s.cursor=n.cursor;return Rt(e,"lists.records.list",s,i)}async function Xa(e,t,n,i,s){return re(e,"search.messages",{query:t,sort:"timestamp",sort_dir:"desc",count:String(Math.min(Math.max(n,1),100)),page:String(Math.max(i,1))},s)}async function Ga(e,t,n){return Xa(e,t,100,1,n)}async function Ri(e,t,n,i){let r=1,o=[],a={ok:!0,messages:{}};while(!0){let u=await Xa(e,t,100,r,i),f=pn(u,["messages","matches"]),l=Array.isArray(f)?f:[];o.push(...l);let d=Number(pn(u,["messages","paging","pages"])??1);if(a=u,l.length===0||r>=d||o.length>=n)break;r+=1}let c=a;if(!c.messages)c.messages={};return c.messages.matches=o.slice(0,n),c}async function fs(e,t,n,i,s,r,o){let a=o?{channel:t,text:n}:{channel:t,text:n,blocks:[{type:"markdown",text:n}]};if(i!==void 0)a.thread_ts=i;if(s&&i!==void 0)a.reply_broadcast=!0;return(await Je(e,"chat.postMessage",a,r)).ts??""}async function Va(e,t,n,i,s,r){let o={channel:t,text:n,post_at:i,blocks:[{type:"markdown",text:n}]};if(s!==void 0)o.thread_ts=s;return(await Je(e,"chat.scheduleMessage",o,r)).scheduled_message_id??""}async function Za(e,t,n){let i={};if(t)i.channel=t;return re(e,"chat.scheduledMessages.list",i,n)}async function Qa(e,t,n,i){await Je(e,"chat.deleteScheduledMessage",{channel:t,scheduled_message_id:n},i)}async function hn(e,t,n,i){return(await re(e,"chat.getPermalink",{channel:t,message_ts:n},i)).permalink??""}async function Gt(e,t,n,i,s,r){return(await Je(e,"chat.update",r?{channel:t,ts:n,text:i}:{channel:t,ts:n,text:i,blocks:[{type:"markdown",text:i}]},s)).ts??n}async function ec(e,t,n,i){await Je(e,"chat.delete",{channel:t,ts:n},i)}async function ut(e,t,n,i,s){await Je(e,"reactions.add",{channel:t,timestamp:n,name:i},s)}async function tc(e,t,n,i){return((await re(e,"reactions.get",{channel:t,timestamp:n,full:"true"},i)).message?.reactions??[]).map((r)=>({name:String(r.name??""),users:Array.isArray(r.users)?r.users.map(String):[]}))}async function gn(e,t,n,i,s){await Je(e,"reactions.remove",{channel:t,timestamp:n,name:i},s)}async function nc(e,t,n=!1,i){let s=await Je(e,"conversations.create",{name:t,is_private:n},i);return{id:s.channel?.id??"",name:s.channel?.name??t}}async function sc(e,t,n,i){await Je(e,"conversations.invite",{channel:t,users:n.join(",")},i)}async function mn(e,t){let n=[],i="";while(!0){let s={limit:"200",types:"public_channel,private_channel,im,mpim"};if(i)s.cursor=i;let r=await re(e,"conversations.list",s,t);if(n.push(...r.channels??[]),i=r.response_metadata?.next_cursor??"",!i)break}return{channels:n}}async function Mt(e,t,n){let s=(await Je(e,"conversations.open",{users:t},n)).channel?.id;if(!s)throw Error(`Failed to open DM with user ${t}`);return s}function Ze(e){return e.toLowerCase().replace(/[-_\s]/g,"")}async function Dn(e,t,n){if(!t.startsWith("@")){if(/^[UW][A-Za-z0-9]{6,}$/.test(t))return t;throw Error(`Expected @user or a user ID, got: ${t}`)}let i=Ze(t.slice(1)),s=await re(e,"auth.test",{},n);if(i==="you"||i==="me"||Ze(s.user??"")===i){if(!s.user_id)throw Error("auth.test did not return user_id");return s.user_id}let r="";while(!0){let o={limit:"200"};if(r)o.cursor=r;let a=await re(e,"users.list",o,n);for(let c of a.members??[]){let u=Ze(c.name??""),f=Ze(c.real_name??""),l=Ze(c.profile?.display_name??"");if(u===i||f===i||l&&l===i)return c.id??""}if(r=a.response_metadata?.next_cursor??"",!r)break}throw Error(`User not found: ${t}`)}function Bt(e){let t=e.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(!t)return;let n=t[1],i=t[2]&&t[3]?`${t[2]}.${t[3]}`:void 0,s=e.indexOf("?"),r=s>=0?new URLSearchParams(e.slice(s)):void 0,o=r?.get("thread_ts")??void 0,u={channel:r?.get("cid")??void 0??n};if(i)u.ts=i;if(o)u.threadTs=o;return u}function Vl(e){return Bt(e)?.channel}function Ua(e){return/^[CDG][A-Z0-9]{8,}$/.test(e)}async function De(e,t,n){let i=Vl(t);if(i)return i;if(!t.startsWith("@")&&!t.startsWith("#")){if(Ua(t))return t;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${t}`)}if(t.startsWith("#")&&Ua(t.slice(1)))return t.slice(1);let s=t.startsWith("@"),r=t.slice(1),o=Ze(r);if(s){let u=await re(e,"auth.test",{},n);if(o==="you"||o==="me"||Ze(u.user??"")===o){let m=u.user_id;if(!m)throw Error("auth.test did not return user_id");let y=((await re(e,"conversations.list",{types:"im",limit:"200"},n)).channels??[]).find((C)=>C.user===m);if(y?.id)return String(y.id);return Mt(e,m,n)}let l="",d="";while(!0){let m={limit:"200"};if(d)m.cursor=d;let p=await re(e,"users.list",m,n);for(let y of p.members??[]){let C=Ze(y.name??""),F=Ze(y.real_name??""),S=Ze(y.profile?.display_name??"");if(C===o||F===o||S&&S===o){l=y.id??"";break}}if(l)break;if(d=p.response_metadata?.next_cursor??"",!d)break}if(!l)throw Error(`User not found: ${t}`);let h="";while(!0){let m={types:"im",limit:"200"};if(h)m.cursor=h;let p=await re(e,"conversations.list",m,n);for(let y of p.channels??[])if(y.user===l)return String(y.id??"");if(h=p.response_metadata?.next_cursor??"",!h)break}throw Error(`No existing DM with ${t} (${l}). Open it once in Slack first.`)}let a=r.toLowerCase(),c="";while(!0){let u={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(c)u.cursor=c;let f=await re(e,"conversations.list",u,n);for(let l of f.channels??[])if(String(l.name??"").toLowerCase()===a)return String(l.id??"");if(c=f.response_metadata?.next_cursor??"",!c)break}throw Error(`channel not found: ${t}`)}async function yn(e,t,n){try{let i=await re(e,"users.info",{user:t},n),s=i.user?.profile?.display_name,r=s&&s.length>0?s:i.user?.real_name??i.user?.name??t,o=i.user?.name??t;return[r,o]}catch{return[t,t]}}async function He(e,t,n){try{let i=await re(e,"users.info",{user:t},n),s=i.user?.profile?.display_name;if(s&&s.length>0)return s;return i.user?.real_name??i.user?.name??t}catch{return t}}async function Mi(e,t){let n=[],i="";while(!0){let s={limit:"200"};if(i)s.cursor=i;let r=await re(e,"users.list",s,t);if(n.push(...r.members??[]),i=r.response_metadata?.next_cursor??"",!i)break}return{members:n}}async function ic(e,t,n){let i=[],s="";while(!0){let r={channel:t,limit:"200"};if(s)r.cursor=s;let o=await re(e,"conversations.members",r,n);if(i.push(...o.members??[]),s=o.response_metadata?.next_cursor??"",!s)break}return i}async function wn(e,t){return Rt(e,"drafts.list",{},t)}async function rc(e,t,n,i){let{randomUUID:s}=await import("node:crypto"),r=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:n}]}]}]);return Rt(e,"drafts.create",{client_msg_id:s(),destinations:JSON.stringify([{channel_id:t}]),blocks:r,file_ids:JSON.stringify([]),is_from_composer:"true"},i)}async function oc(e,t,n,i,s){let r=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:i}]}]}]),o=(Date.now()/1000).toFixed(6);return Rt(e,"drafts.update",{draft_id:t,client_last_updated_ts:o,destinations:JSON.stringify([{channel_id:n}]),blocks:r,file_ids:JSON.stringify([])},s)}async function ac(e,t,n){return Rt(e,"conversations.info",{channel:t},n)}async function bn(e,t,n){return re(e,"users.info",{user:t},n)}async function Fn(e,t,n){return re(e,"conversations.info",{channel:t},n)}async function cc(e,t,n){let i=(Date.now()/1000).toFixed(6);return Rt(e,"drafts.delete",{draft_id:t,client_last_updated_ts:i},n)}async function Bi(e,t){let n=await Rt(e,"auth.test",{},t);return{userId:String(n.user_id??""),teamId:String(n.team_id??"")}}async function uc(e,t,n,i={},s){let{statSync:r,readFileSync:o}=await import("node:fs"),{basename:a}=await import("node:path"),c=r(n),u=a(n),f=await re(e,"files.getUploadURLExternal",{filename:u,length:String(c.size)},s),l=f.upload_url,d=f.file_id;if(!l||!d)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let h=o(n),m=await fetch(l,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:h});if(!m.ok)throw Error(`Upload PUT failed: ${m.status} ${m.statusText}`);let p={files:[{id:d,title:i.title??u}],channel_id:t};if(i.threadTs)p.thread_ts=i.threadTs;if(i.initialComment)p.initial_comment=i.initialComment;let y=await Je(e,"files.completeUploadExternal",p,s),C={fileId:d},F=y.files?.[0]?.permalink;if(F)C.permalink=F;return C}function pn(e,t){let n=e;for(let i of t){if(n===void 0||n===null)return;if(typeof i==="number"){if(!Array.isArray(n))return;n=n[i]??void 0}else{if(typeof n!=="object"||Array.isArray(n))return;n=n[i]}}return n}import{existsSync as cf,readFileSync as uf}from"node:fs";import{homedir as lf}from"node:os";import{join as ff}from"node:path";import{existsSync as Zl,mkdirSync as Ql,readFileSync as ef,writeFileSync as tf}from"node:fs";import{homedir as nf}from"node:os";import{dirname as sf,join as rf}from"node:path";var of=3600000,ds={now:()=>Date.now(),path:()=>rf(process.env.HOME||nf(),".config","slack-cli","cache.json")},ps=!0,lt;function lc(){return{channels:{},users:{}}}function Ni(){if(lt)return lt;if(lt=lc(),!ps)return lt;try{let e=ds.path();if(!Zl(e))return lt;let t=JSON.parse(ef(e,"utf8"));for(let n of["channels","users"]){let i=t?.[n];if(!i||typeof i!=="object"||Array.isArray(i))continue;for(let[s,r]of Object.entries(i))if(r&&typeof r==="object"&&typeof r.value==="string"&&typeof r.expires==="number")lt[n][s]={value:r.value,expires:r.expires}}}catch{lt=lc()}return lt}function af(e){if(!ps)return;try{let t=ds.path();Ql(sf(t),{recursive:!0}),tf(t,JSON.stringify(e,null,2)+`
|
|
153
|
+
`)}catch{}}function fc(e,t){return e?`${e} ${t}`:void 0}function hs(e,t,n){if(!ps)return;let i=fc(t,n);if(!i)return;let s=Ni()[e][i];if(!s)return;if(s.expires<=ds.now()){delete Ni()[e][i];return}return s.value}function gs(e,t,n,i,s=of){if(!ps)return;let r=fc(t,n);if(!r)return;let o=Ni();o[e][r]={value:i,expires:ds.now()+s},af(o)}var vi={marker:"pushpin",progress:{done:"white_check_mark",dropped:"no_entry_sign",doing:"eyes",pending:"hourglass_flowing_sand"},flags:{alert:"exclamation","needs-discussion":"thinking_face",waiting:"speech_balloon",blocked:"lock"}},Vt=["done","dropped","doing","pending"],gc=["alert","needs-discussion","waiting","blocked"];function df(){return ff(process.env.HOME||lf(),".config","slack-cli","todo.json")}function ms(e){return e.replace(/^:+|:+$/g,"")}function Cn(e=df()){let t={marker:vi.marker,progress:{...vi.progress},flags:{...vi.flags}};try{if(!cf(e))return t;let n=JSON.parse(uf(e,"utf8"));if(typeof n.marker==="string"&&n.marker.trim())t.marker=ms(n.marker.trim());for(let i of Vt){let s=n.progress?.[i];if(typeof s==="string"&&s.trim())t.progress[i]=ms(s.trim())}for(let i of gc){let s=n.flags?.[i];if(typeof s==="string"&&s.trim())t.flags[i]=ms(s.trim())}}catch{}return t}function dc(e,t,n=!1){return`${n?"-":""}${t?"has":"hasmy"}::${ms(e)}:`}function mc(e,t,n={}){let i=n.shared===!0,s=(a)=>dc(a,i),r=(a)=>dc(a,i,!0),o=[];if(e==="untriaged")o.push(s(t.marker),...Vt.map((a)=>r(t.progress[a])));else if(e==="stuck")o.push(s(t.marker),r(t.progress.done),r(t.progress.dropped),`(${gc.map((a)=>s(t.flags[a])).join(" OR ")})`);else if(e==="open")o.push(s(t.marker),r(t.progress.done),r(t.progress.dropped));else{let a=Vt.indexOf(e);o.push(s(t.progress[e]));for(let c of Vt.slice(0,a))o.push(r(t.progress[c]))}if(n.in){let a=n.in.startsWith("#")||n.in.startsWith("@")?n.in:`#${n.in}`;o.push(`in:${a}`)}if(n.from){let a=n.from==="me"||n.from.startsWith("@")?n.from:`@${n.from}`;o.push(`from:${a}`)}return o.join(" ")}var pf=3,hf={sleep:(e)=>new Promise((t)=>setTimeout(t,e))};async function xe(e,t,n=pf){for(let i=0;;i++)try{return await t()}catch(s){if(!(s instanceof Ve))throw s;if(i>=n)throw Error(`Slack rate limit hit on ${e} — gave up after ${n} retries. Try again in a minute.`);console.error(`Warning: Slack rate limit hit on ${e} — backing off for ${s.retryAfter}s`),await hf.sleep(s.retryAfter*1000)}}var pc=new Map;async function Dc(e,t){let n=pc.get(e);if(n)return n;let i=await xe("auth.test",()=>qt(e,t)),s={userId:i.userId,teamId:i.teamId};return pc.set(e,s),s}async function yc(e,t){return(await Dc(e,t)).userId}async function ji(e,t){try{return(await Dc(e,t)).teamId}catch{return""}}async function Li(e,t,n,i){if(!t.startsWith("#"))return n(e,t,i);let s=await ji(e,i),r=hs("channels",s,t);if(r)return r;let o=await xe("resolveChannel",()=>n(e,t,i));return gs("channels",s,t,o),o}async function wc(e,t,n,i){let s=await ji(e,i),r=hs("users",s,t);if(r)return r;let o=await xe("users.info",()=>n(e,t,i));if(o&&o!==t)gs("users",s,t,o);return o}async function bc(e,t,n,i){let s=await ji(e,i),r=hs("users",s,`tz:${t}`);if(r)return r==="?"?null:r;let o=null;try{let a=await xe("users.info",()=>n(e,t,i));if(a?.user?.is_bot===!0||t==="USLACKBOT")return hc(s,t,null);let c=a?.user?.tz;o=typeof c==="string"&&c?c:null}catch{return null}return hc(s,t,o)}function hc(e,t,n){return gs("users",e,`tz:${t}`,n??"?"),n}async function Fc(e,t,n,i,s,r){let o=s.progress[i],a=await yc(e,r),c=await xe("reactions.get",()=>qo(e,t,n,r)),u=new Set(c.filter((h)=>h.users.includes(a)).map((h)=>h.name)),f=Vt.map((h)=>s.progress[h]).filter((h)=>u.has(h));if(f.length===1&&f[0]===o)return{noop:!0,removed:[],leftover:[]};if(!u.has(o))await xe("reactions.add",()=>Hn(e,t,n,o,r));let l=[],d=[];for(let h of f){if(h===o)continue;try{await xe("reactions.remove",()=>qn(e,t,n,h,r)),l.push(h)}catch{d.push(h)}}return{noop:!1,added:i,removed:l,leftover:d}}async function Cc(e,t,n,i,s,r,o){let a=s.flags[i];if(r)await xe("reactions.remove",()=>qn(e,t,n,a,o));else await xe("reactions.add",()=>Hn(e,t,n,a,o));return a}var Wi=1000;async function Ec(e,t,n,i={}){let s=i.limit??Wi,r=i.cookie,o=await yc(e,r),a=Vt.map((d)=>n.progress[d]),c=[],u=0,f,l=!1;while(u<s){let d=Math.min(200,s-u),h=await xe("conversations.history",()=>cn(e,t,d,void 0,f,r)),m=h.messages??[];u+=m.length;for(let p of m){let y=String(p.ts??"");if(!y)continue;let C=new Set((p.reactions??[]).filter((S)=>(S.users??[]).map(String).includes(o)).map((S)=>String(S.name??""))),F=a.filter((S)=>C.has(S));if(F.length<2)continue;c.push({ts:y,text:String(p.text??"").split(`
|
|
154
|
+
`)[0]??"",emoji:F,keep:F[0]})}if(f=h.response_metadata?.next_cursor||void 0,!f||m.length===0)break;if(u>=s){l=!0;break}}if(i.fix)for(let d of c)try{try{await xe("reactions.add",()=>Hn(e,t,d.ts,d.keep,r))}catch(h){if(!(h instanceof Error)||!/already_reacted/.test(h.message))throw h}for(let h of d.emoji){if(h===d.keep)continue;await xe("reactions.remove",()=>qn(e,t,d.ts,h,r))}d.fixed=!0}catch(h){d.fixed=!1,d.error=h instanceof Error?h.message:String(h)}return{scanned:u,findings:c,truncated:l}}var gf=!0,mf;function Ui(e){if(gf=e,!e)mf=void 0}function ft(e){return e.replace(new RegExp(`[${"\\\\¥"}](.)`,"gs"),(t,n)=>{switch(n){case"n":return`
|
|
155
|
+
`;case"t":return"\t";case"\\":case"¥":return n==="¥"?"¥":"\\";default:return t}})}function Nt(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function dt(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function Df(e,t){let n=Nt(t),i=dt(e.profile);for(let r of[e.name,e.real_name,i.display_name,i.real_name])if(typeof r==="string"&&r&&Nt(r)===n)return!0;let s=typeof i.email==="string"?i.email.toLowerCase():"";return s!==""&&s===t.toLowerCase()}function yf(e){let t=dt(e.profile),n=new Set;for(let i of[t.display_name,e.real_name,e.name,t.real_name])if(typeof i==="string"&&i){let s=Nt(i);if(s.length>=2)n.add(s)}return[...n]}function wf(e,t){let n=Nt(e),i,s=!1;for(let r of t){let o=typeof r.id==="string"?r.id:"";if(!o)continue;for(let a of yf(r)){let c=-1;if(n===a)c=e.length;else for(let u of _c)if(e.length>u.length&&e.endsWith(u)&&Nt(e.slice(0,e.length-u.length))===a){c=e.length-u.length;break}if(c<0)continue;if(!i||a.length>i.formLen)i={userId:o,matchLen:c,formLen:a.length,display:zi(r)},s=!1;else if(a.length===i.formLen&&i.userId!==o)s=!0}}if(!i)return;return s?"ambiguous":{userId:i.userId,matchLen:i.matchLen,display:i.display}}async function vt(e,t,n,i){let s=`[${Sc}ー]+`,r=`${s}(?:[._-]+${s})*`,o=new RegExp(`(?<![A-Za-z0-9._@<-])@(${r})`,"gu"),a=new Set;for(let F of t.matchAll(o))a.add(F[1]);if(a.size===0)return{text:t,resolved:[],unresolved:[]};let c=new Map;for(let F of a)c.set(F,{status:"pending"});let u=(F)=>{for(let S of a){if(c.get(S).status!=="pending")continue;if(Ji(S)){let k=wf(S,F);if(k==="ambiguous")c.set(S,{status:"ambiguous"});else if(k)c.set(S,{status:"resolved",userId:k.userId,matchLen:k.matchLen,display:k.display})}else{let k=F.filter((A)=>Df(A,S)),j=new Set(k.map((A)=>typeof A.id==="string"?A.id:"").filter(Boolean));if(j.size===1){let A=k.find((M)=>typeof M.id==="string");c.set(S,{status:"resolved",userId:A.id,matchLen:S.length,display:zi(A)})}else if(j.size>1)c.set(S,{status:"ambiguous"})}}},f=!1;try{let F=await Gn(e,i);u((F.members??[]).map(dt)),f=!0}catch{f=!1}let l=[...a].some((F)=>c.get(F).status==="pending"),d=!1,h=!0;if(l&&n){d=!0;try{let F=await di(e,n,i),S=[];for(let k of F){let j=dt(await pi(e,k,i)),A=dt(j.user);if(typeof A.id!=="string")A.id=k;S.push(A)}u(S)}catch{h=!1}}let m=f&&(n?d&&h:!0),p=[],y=[];for(let F of a){let S=c.get(F);if(S.status==="resolved")p.push({surface:`@${F.slice(0,S.matchLen)}`,display:S.display,userId:S.userId});else if(S.status==="ambiguous")y.push({surface:`@${F}`,reason:"ambiguous"});else y.push({surface:`@${F}`,reason:m?"no-match":"unavailable"})}return{text:t.replace(o,(F,S)=>{let k=c.get(S);if(k&&k.status==="resolved")return`<@${k.userId}>${S.slice(k.matchLen)}`;return F}),resolved:p,unresolved:y}}function En(e){let t=[],n=!1;for(let i of e)if(i.reason==="ambiguous")t.push(`${i.surface} matches multiple people — not tagged, sent as plain text (use <@USERID> to tag)`);else if(i.reason==="unavailable"){if(n)continue;t.push("could not fetch the user list (users:read missing or an API/connection error) — @mentions not tagged, sent as plain text"),n=!0}else t.push(`${i.surface} matched no one — not tagged, sent as plain text`);return t}async function xc(e,t,n,i={}){let s=i.warn??((o)=>process.stderr.write(`${o}
|
|
156
|
+
`)),r=await vt(e,t,n,i.cookie);for(let o of En(r.unresolved))s(`warn: ${o}`);return r.text}var _c=["さん","さま","様","君","くん","ちゃん","氏","先生","先輩","殿","老师","老師","兄","姐","哥","姐妹"],Sc="\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}A-Za-z0-9";function Ji(e){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u.test(e)}function bf(e){let t=[],n=new RegExp(`([${Sc}]{1,12})(${_c.join("|")})`,"gu");for(let i of e.matchAll(n))t.push({ref:i[1],honorific:i[2]});for(let i of e.matchAll(/\b(?:dear|hi|hello|hey)\b[ \t]+([A-Z][A-Za-z'’-]{1,20})/gi))t.push({ref:i[1],honorific:""});for(let i of e.matchAll(/(?:^|\n)[ \t]*([A-Z][A-Za-z'’-]{1,20}),/g))t.push({ref:i[1],honorific:""});return t}function Ff(e){let t=dt(e.profile),n=new Set;for(let i of[e.name,e.real_name,t.display_name,t.real_name]){if(typeof i!=="string"||!i)continue;for(let s of[i,...i.split(/\s+/)]){let r=Nt(s);if(r.length>=2)n.add(r)}}return[...n]}function Cf(e,t){let n=Nt(e);if(n.length<2)return;for(let i of t)if(n===i)return i;if(Ji(e)){for(let i of t)if(n.includes(i)||i.includes(n))return i}return}function zi(e){return[dt(e.profile).display_name,e.real_name,e.name].filter((i)=>typeof i==="string"&&i!=="")[0]??String(e.id??"?")}async function kc(e,t,n){let i=bf(t);if(i.length===0)return[];let s=new Set;for(let u of t.matchAll(/<@([A-Z0-9]+)(?:\|[^>]*)?>/g))s.add(u[1]);let o=((await Gn(e,n)).members??[]).map(dt).filter((u)=>u.deleted!==!0&&u.is_bot!==!0&&u.id!=="USLACKBOT").map((u)=>({id:typeof u.id==="string"?u.id:"",forms:Ff(u),display:zi(u)})).filter((u)=>u.id!==""),a=[],c=new Set;for(let{ref:u,honorific:f}of i)for(let l of o){let d=Cf(u,l.forms);if(!d)continue;if(s.has(l.id)||c.has(l.id))break;c.add(l.id),a.push({surface:Ji(u)?`${d}${f}`:u,display:l.display,userId:l.id});break}return a}async function Zt(e,t,n,i){let s=t,r=[],o=s,a=0;while(!0){let c=o.indexOf("<@U",a);if(c===-1)break;let u=o.slice(c+2),f=u.search(/[>|]/),l=f===-1?u:u.slice(0,f);if(l.length>=9)r.push(l);a=c+1}for(let c of r){if(!n.has(c))n.set(c,await Xn(e,c,i));let u=n.get(c)??c;s=s.replaceAll(`<@${c}>`,`@${u}`),s=s.replace(new RegExp(`<@${c}\\|[^>]*>`,"g"),`@${u}`)}return s}function xn(e){return e.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(t,n,i)=>{let s=Number(n);if(!Number.isFinite(s))return i??"date";let r=new Date(s*1000);if(Number.isNaN(r.getTime()))return i??"date";let o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=o[r.getUTCDay()]??"",u=a[r.getUTCMonth()]??"";return`${c}, ${u} ${String(r.getUTCDate()).padStart(2,"0")}, ${r.getUTCFullYear()}`})}function Ac(e,t=new Date){let n=new Date(e*1000),i=Ki(t),s=Ki(new Date(t.getTime()-86400000)),r=Ki(n);if(r===i)return"Today";if(r===s)return"Yesterday";let o=n.toLocaleDateString("en-US",{weekday:"long"}),a=n.toLocaleDateString("en-US",{month:"short"});return`${o}, ${a} ${String(n.getDate()).padStart(2,"0")}`}function Ki(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function $c(e){let t=new Date(e*1000),n=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),r=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return`${n}-${i}-${s} ${r}:${o}`}function Oc(e=new Date,t){let n=process.env.SLACK_QUIET_TZ??"Asia/Tokyo",i=!!t&&Ef(t),s=i?t:n,r=Number(process.env.SLACK_QUIET_START??23),o=Number(process.env.SLACK_QUIET_END??8),a,c;try{let h=new Intl.DateTimeFormat("en-GB",{timeZone:s,hour12:!1,weekday:"short",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});c=h.format(e),a=Number(h.formatToParts(e).find((m)=>m.type==="hour")?.value??"12")}catch{return null}let u=r>o?a>=r||a<o:a>=r&&a<o,f=i?`${s}, recipient`:`${s}, sender — recipient's timezone unknown`,l=`\uD83D\uDD50 ${c} (${f})`;if(!u)return l;return`${l}
|
|
157
|
+
⚠ QUIET HOURS (${r}:00-${o}:00) — this will buzz a phone.${i?"":" Their local time may differ."} Send only for a production incident; otherwise hold it until morning.`}function Ef(e){try{return new Intl.DateTimeFormat("en-GB",{timeZone:e}),!0}catch{return!1}}function _n(e){if(!Bc(e))return;let t=_f(e,"utf8");for(let n of t.split(`
|
|
158
|
+
`)){let i=n.trim();if(!i||i.startsWith("#"))continue;let s=i.indexOf("=");if(s===-1)continue;let r=i.slice(0,s).trim(),o=i.slice(s+1).trim();if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))o=o.slice(1,-1);if(!(r in process.env))process.env[r]=o}}function kf(e){Sf(e,{recursive:!0});let t=pt(e,".gitignore");if(!Bc(t))Nc(t,`*
|
|
159
|
+
`)}function Af(){_n(pt(Ic(),".slack-cli",".env.local")),_n(pt(Ic(),".config/slack-cli",".env")),_n(pt(process.cwd(),".slack-cli",".env.local")),_n(pt(process.cwd(),".env.local")),_n(pt(process.cwd(),".env"))}function $f(e){return xf("sha256").update(e).digest("hex")}function I(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function X(e){return Array.isArray(e)?e:[]}function Ds(e){return Number(e.ts??0)}async function vc(e,t,n){let i=t.user;if(typeof i==="string"){if(!n.has(i))n.set(i,await He(e,i));return n.get(i)??i}return typeof t.username==="string"?t.username:"bot"}function Hi(e){let t=new Date(e*1000),n=t.getUTCFullYear(),i=String(t.getUTCMonth()+1).padStart(2,"0"),s=String(t.getUTCDate()).padStart(2,"0"),r=String(t.getUTCHours()).padStart(2,"0"),o=String(t.getUTCMinutes()).padStart(2,"0"),a=String(t.getUTCSeconds()).padStart(2,"0");return`${n}-${i}-${s} ${r}:${o}:${a}`}function Yi(e){let[t,n="000000"]=e.split("."),i=Number(t),s=new Date(i*1000),r=s.getUTCFullYear(),o=String(s.getUTCMonth()+1).padStart(2,"0"),a=String(s.getUTCDate()).padStart(2,"0"),c=String(s.getUTCHours()).padStart(2,"0"),u=String(s.getUTCMinutes()).padStart(2,"0"),f=String(s.getUTCSeconds()).padStart(2,"0"),l=n.padEnd(6,"0").slice(0,6);return`${r}-${o}-${a}T${c}:${u}:${f}.${l}`}function Xi(e){let t=e.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\.(\d{6})$/);if(!t)throw Error(`Invalid message timestamp "${e}" \u2014 expected 2026-05-11T06:01:04.000100`);let n=Date.parse(t[1]+"Z");if(isNaN(n))throw Error(`Cannot parse date in "${e}"`);return`${Math.floor(n/1000)}.${t[2]}`}function Of(e){return/^\d{4}-\d{2}-\d{2}T/.test(e)?Xi(e):e}async function bs(e,t,n,i,s){let r=typeof t.ts==="string"?t.ts:`${Ds(t)}.000000`,o=Yi(r),a="?";if(typeof t.user==="string"){let F=t.user,S="@"+F;if(!n.has(S)){let k=await wc(e,F,async(j,A,M)=>(await yn(j,A,M))[1],s);n.set(S,k)}a=n.get(S)??F}else if(typeof t.username==="string")a=t.username;let c=typeof t.text==="string"?t.text:"",f=xn(await Zt(e,c,n,s)).split(`
|
|
159
160
|
`),l=f[0]+(f.length>1?`
|
|
160
161
|
`+f.slice(1).map((F)=>` ${F}`).join(`
|
|
161
|
-
`):""),d=i?`${i} @${a}`:`@${a}`,
|
|
162
|
-
\uD83D\uDCCE ${S}${k}${j}`}).join(""),
|
|
163
|
-
${
|
|
164
|
-
`)[0]??"",d=await Zt(e,l,i);console.log(` ${f}: ${d}`)}}}async function
|
|
165
|
-
`)[0]?.slice(0,60)}`:"";console.log(`${d}${u} ${c}${
|
|
162
|
+
`):""),d=i?`${i} @${a}`:`@${a}`,h=X(t.reactions).map(I).map((F)=>{let S=typeof F.name==="string"?F.name:"",k=Number(F.count??X(F.users).length??0);return S?`:${S}:\xD7${k}`:""}).filter(Boolean).join(" "),m=X(t.files).map(I).map((F)=>{let S=typeof F.name==="string"?F.name:typeof F.title==="string"?F.title:"(file)",k=typeof F.size==="number"?` (${Fs(F.size)})`:"",j=typeof F.id==="string"?` [${F.id}]`:"";return`
|
|
163
|
+
\uD83D\uDCCE ${S}${k}${j}`}).join(""),p=Number(t.reply_count??0),y=p>0?` [+${p} ${p===1?"reply":"replies"}]`:"",C=(h?`
|
|
164
|
+
${h}`:"")+m;return`${o} ${d}: ${l}${y}${C}`}function Fs(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function If(e){return X(e.files).map(I).map((t)=>({id:t.id??null,name:t.name??t.title??null,mimetype:t.mimetype??null,size:t.size??null,url_private_download:t.url_private_download??t.url_private??null,permalink:t.permalink??null}))}function jc(e){let t=If(e);return{ts:e.ts??null,user:e.user??null,username:e.username??null,bot_id:e.bot_id??null,thread_ts:e.thread_ts??null,text:typeof e.text==="string"?e.text:"",...Array.isArray(e.reactions)&&e.reactions.length?{reactions:X(e.reactions).map(I).map((n)=>({name:n.name??null,count:n.count??null,users:Array.isArray(n.users)?n.users:[]}))}:{},...e.reply_count!==void 0?{reply_count:e.reply_count}:{},...e.reply_users_count!==void 0?{reply_users_count:e.reply_users_count}:{},...e.latest_reply!==void 0?{latest_reply:e.latest_reply}:{},...t.length>0?{files:t}:{}}}async function Pf(e,t,n,i,s){let r=[];for(let o of n){let a=o;if(Number(o.reply_count??0)>0&&typeof o.ts==="string"){let c=await ze(e,t,o.ts,200,s),u=X(c.messages).map(I);a=u[u.length-1]??o}if(a.user!==i)r.push(o)}return r}async function Tf(e,t,n,i="text",s=!1,r){let o=Bt(t),a=await De(e,t,r),c=new Map,f=await(async()=>{if(o?.threadTs){let d=await ze(e,a,o.threadTs,n,r);return X(d.messages).map(I)}let l=await Qe(e,a,n,void 0,void 0,r);return X(l.messages).map(I).reverse()})();if(s){let{userId:l}=await Ja(e,r);f=await Pf(e,a,f,l,r)}if(i==="jsonl"){for(let l of f)console.log(JSON.stringify(jc(l)));return}for(let l of f)console.log(await bs(e,l,c,void 0,r))}async function Rf(e,t,n,i,s="text",r){let o=await De(e,t,r),a=await ze(e,o,Of(n),i,r),c=X(a.messages).map(I);if(s==="jsonl"){for(let f of c)console.log(JSON.stringify(jc(f)));return}let u=new Map;for(let f of c)console.log(await bs(e,f,u,void 0,r))}async function Mf(e){let t=await mn(e),n=X(t.channels).map(I).filter((s)=>s.is_member===!0).sort((s,r)=>Number(r.updated??0)-Number(s.updated??0)).slice(0,10),i=new Map;for(let s of n){let r=String(s.id??""),o=typeof s.name==="string"?s.name:typeof s.user==="string"?s.user:r,a=await Qe(e,r,5),c=X(a.messages).map(I).filter((u)=>u.subtype===void 0||u.subtype===null).filter((u)=>{let f=typeof u.text==="string"?u.text:"";return f.length>0&&!f.startsWith("<@")}).slice(0,3).reverse();if(c.length===0)continue;console.log(`-- #${o} --------------------------------`);for(let u of c){let f=await vc(e,u,i),l=(typeof u.text==="string"?u.text:"").split(`
|
|
165
|
+
`)[0]??"",d=await Zt(e,l,i);console.log(` ${f}: ${d}`)}}}async function Bf(e,t){let n=await Ga(e,"to:me"),i=X(pn(n,["messages","matches"])).map(I).slice(0,t),s=new Map,r=[];for(let o of i){let a=Ac(Ds(o)),c=r[r.length-1];if(c?.label===a)c.msgs.push(o);else r.push({label:a,msgs:[o]})}for(let o=0;o<r.length;o++){let{label:a,msgs:c}=r[o];if(o>0)console.log("");console.log(` ${a}`),console.log(" ----------------------------");for(let u of[...c].reverse()){let f=I(u.channel),l=f.is_im===!0,d=typeof f.name==="string"?f.name:"dm",h;if(l&&d.startsWith("U")){let m="@"+d;if(!s.has(m)){let[,p]=await yn(e,d);s.set(m,p)}h=`@${s.get(m)??d}`}else if(l)h=`@${d}`;else h=`#${d}`;console.log(await bs(e,u,s,h))}}}async function Nf(e,t,n,i,s="text"){let r=await mn(e),o=X(r.channels).map(I).filter((a)=>i||a.is_member===!0).filter((a)=>{if(!n)return!0;return(typeof a.name==="string"?a.name:"").toLowerCase().includes(n.toLowerCase())}).sort((a,c)=>Number(c.updated??0)-Number(a.updated??0)).slice(0,t);if(s==="jsonl"){for(let a of o)console.log(JSON.stringify(a));return}for(let a of o){let c=String(a.id??""),u=typeof a.name==="string"?a.name:typeof a.user==="string"?a.user:c,f=a.is_im===!0,l=a.is_mpim===!0,d=f||l?"@":"#",h=a.is_member===!0?"":" (not joined)",m=typeof I(a.purpose).value==="string"?String(I(a.purpose).value):"",p=m?` ${m.split(`
|
|
166
|
+
`)[0]?.slice(0,60)}`:"";console.log(`${d}${u} ${c}${h}${p}`)}}function vf(e){let t=(s)=>s.startsWith("xoxp-")||s.startsWith("xoxc-"),n=ai(),i=n.find((s)=>s.profile.token===e);if(!i)return;return n.find((s)=>t(s.profile.token)&&s.profile.teamId===i.profile.teamId)}async function Lc(e,t,n,i,s){let r=e,o=s,a;try{a=await Ri(r,t,n,o)}catch(f){let l=f instanceof Error?f.message:String(f);if(e.startsWith("xoxb-")&&l.includes("not_allowed_token_type")){let d=vf(e);if(d)console.error(`Note: search.messages needs a user token \u2014 the active profile is a bot token (xoxb-); falling back to profile "${d.name}".`),r=d.profile.token,o=d.profile.cookie,a=await Ri(r,t,n,o);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.
|
|
166
167
|
`+` Add a user-token profile: slack auth login (or slack auth token)
|
|
167
|
-
Then select it: slack auth use <name> (or pass --workspace <name>)`),process.exit(1)}else throw f}if(i){console.log(JSON.stringify(a,null,2));return}let c=X(pn(a,["messages","matches"])).map(
|
|
168
|
-
`);for(let
|
|
169
|
-
`).join(" \u21B5 ");console.log(`[${
|
|
170
|
-
`))console.log(` ${F}`)}}async function
|
|
171
|
-
`)).slice(0,4)}function
|
|
172
|
-
`)[0]??"",o=r.length>n?`${r.slice(0,n)}\u2026`:r,a=typeof t.ts==="string"?t.ts:"";return`${a?Yi(a).slice(0,16).replace("T"," "):""} @${s}${o?`: ${o}`:""}`}async function
|
|
168
|
+
Then select it: slack auth use <name> (or pass --workspace <name>)`),process.exit(1)}else throw f}if(i){console.log(JSON.stringify(a,null,2));return}let c=X(pn(a,["messages","matches"])).map(I),u=new Map;for(let f of c){let l=I(f.channel),d=l.is_im===!0,h=typeof l.name==="string"?l.name:"dm",m;if(d&&h.startsWith("U")){let p="@"+h;if(!u.has(p)){let[,y]=await yn(r,h,o);u.set(p,y)}m=`@${u.get(p)??h}`}else if(d)m=`@${h}`;else m=`#${h}`;console.log(await bs(r,f,u,m,o))}}async function Wc(e,t,n,i){let{ref:s,ts:r}=Cs(t);if(!r)console.error("Error: target must embed a message ts (e.g. #chan:1700000000.000100 or a Slack permalink URL)"),process.exit(2);return{channelId:n??await Li(e,s,De,i),ts:r}}async function jf(e,t){let n=Cn(),i={};if(!t.mine)i.shared=!0;if(t.in)i.in=t.in;if(t.from)i.from=t.from;let s=mc(t.state,n,i);if(!t.json){let r=await Qt(e,t.cookie),o=t.mine?"your reactions only [hasmy:]":"anyone's reactions [has:]";console.error(`(From: ${Kc(r)} \xB7 matching ${o})`),console.error(`(query: ${s})`)}await xe("search.messages",()=>Lc(e,s,t.count,t.json,t.cookie))}async function Lf(e,t){let n=Cn(),{channelId:i,ts:s}=await Wc(e,t.target,t.channelId,t.cookie),r=await Fc(e,i,s,t.state,n,t.cookie);if(r.noop){console.log(`= Already ${t.state} (ts: ${s})`);return}let o=r.removed.length?`, removed ${r.removed.map((a)=>`:${a}:`).join(" ")}`:"";if(console.log(`\u2713 ${t.state} :${n.progress[t.state]}: (ts: ${s})${o}`),r.leftover.length)console.error(`\u26A0 ${r.leftover.map((a)=>`:${a}:`).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 Wf(e,t){let n=Cn(),{channelId:i,ts:s}=await Wc(e,t.target,t.channelId,t.cookie),r=await Cc(e,i,s,t.flag,n,t.remove===!0,t.cookie);console.log(`\u2713 ${t.remove?"Cleared":"Flagged"} ${t.flag} :${r}: (ts: ${s})`)}async function Uf(e,t){let n=Cn(),i=t.channelId??await Li(e,t.channel,De,t.cookie),s={limit:t.limit};if(t.fix)s.fix=!0;if(t.cookie)s.cookie=t.cookie;let r=await Ec(e,i,n,s);if(r.findings.length===0)console.log(`\u2713 No multi-state tasks in ${r.scanned} message(s).`);else{for(let o of r.findings){let a=o.fixed===!0?"fixed":o.fixed===!1?`FAILED: ${o.error??"?"}`:"needs --fix";console.log(`${o.ts} ${o.emoji.map((c)=>`:${c}:`).join(" ")} \u2192 keep :${o.keep}: [${a}] ${te(o.text).slice(0,60)}`)}console.log(`${r.findings.length} multi-state task(s) in ${r.scanned} message(s).`)}if(r.truncated)console.error(`\u26A0 Scan limit reached (${t.limit} messages) \u2014 older history was NOT checked. Raise it with --limit N.`)}async function Kf(e,t,n,i){let s=Math.floor(Date.now()/1000)-t*86400,r=await mn(e),o=X(r.channels).map(I).filter((f)=>f.is_member===!0&&f.is_im!==!0&&f.is_mpim!==!0).filter((f)=>{if(!i)return!0;return(typeof f.name==="string"?f.name:"").toLowerCase().includes(i.toLowerCase())}).sort((f,l)=>Number(l.updated??0)-Number(f.updated??0)),a=new Map,c=0,u=0;for(let f of o){let l=String(f.id??""),d=typeof f.name==="string"?f.name:l,h;try{h=await Qe(e,l,n)}catch(p){console.error(` SKIP #${d}: ${p.message}`);continue}let m=X(h.messages).map(I).filter((p)=>(p.subtype===void 0||p.subtype===null)&&Ds(p)>=s);if(m.length===0)continue;u+=1,c+=m.length,console.log(`## #${d} (${m.length} msgs)
|
|
169
|
+
`);for(let p of[...m].reverse()){let y=await vc(e,p,a),C=typeof p.text==="string"?p.text:"",S=xn(await Zt(e,C,a)).split(`
|
|
170
|
+
`).join(" \u21B5 ");console.log(`[${$c(Ds(p))}] ${y}: ${S}`)}console.log("")}console.error(`Dumped ${c} messages across ${u} channels (cutoff: ${t}d)`)}function Jf(e){let t=[];function n(i){if(typeof i==="string"){t.push(i);return}if(Array.isArray(i)){for(let s of i)n(s);return}if(i&&typeof i==="object"){let s=i;if(typeof s.text==="string"){t.push(s.text);return}if(Array.isArray(s.elements))n(s.elements);else if(Array.isArray(s.content))n(s.content)}}for(let i of e)n(i);return t.join("").trim()}async function Uc(e,t,n){let i=new Map;return async(s)=>{if(!s)return"(unknown)";if(i.has(s))return i.get(s);try{let r=await ac(e,s,t),o=I(r.channel),a;if(o.is_im===!0){let c=typeof o.user==="string"?o.user:"";if(!c||c===n)a="@self";else{let[u]=await yn(e,c);a=`@${u}`}}else a=`#${typeof o.name==="string"?o.name:s}`;return i.set(s,a),a}catch{return s}}}function Gi(e){let t=I(X(e.destinations)[0]);return String(t.channel_id??e.channel_id??e.channel??"")}function ys(e){return Jf(X(e.blocks))||(typeof e.text==="string"?e.text:"(no text)")}async function zf(e,t,n=!1){let i=await wn(e,t),s=X(i.drafts??i.messages??[]).map(I).filter((u)=>u.is_deleted!==!0),r=n?s:s.filter((u)=>u.is_sent!==!0);if(r.length===0){console.log(n?"No drafts.":"No pending drafts. Run with --all to include sent.");return}let o="";try{({userId:o}=await Bi(e,t))}catch{}let a=await Uc(e,t,o),c=new Map;for(let u of r){let f=Gi(u),l=ys(u),d=Number(u.date_created??u.date_create??0),h=d?Hi(d):"?",m=await a(f),p=typeof u.id==="string"?u.id:"",y=u.is_sent===!0?" [SENT]":"",C=xn(await Zt(e,l,c));console.log(`-- ${p} ${m} [${h}]${y}`);for(let F of C.split(`
|
|
171
|
+
`))console.log(` ${F}`)}}async function Hf(e,t,n){let i=await wn(e,t),s=X(i.drafts).map(I).find((m)=>String(m.id)===n);if(!s)console.error(`Draft not found: ${n}`),process.exit(1);let r="";try{({userId:r}=await Bi(e,t))}catch{}let o=await Uc(e,t,r),a=Gi(s),c=ys(s),u=Number(s.date_created??0),f=String(s.last_updated_ts??"?"),l=await o(a),h=xn(await Zt(e,c,new Map));console.log(`id: ${s.id}`),console.log(`channel: ${l} (${a})`),console.log(`created: ${u?Hi(u):"?"}`),console.log(`updated: ${Hi(Number(f.split(".")[0]))}`),console.log(`status: ${s.is_sent===!0?"sent":"pending"}`),console.log("---"),console.log(h)}function qe(...e){return $f(e.join(`
|
|
172
|
+
`)).slice(0,4)}function te(e){return e.replace(/\x1b\[[0-9;:?]*[ -/]*[@-~]/g,"").replace(/[\x00-\x1f\x7f-\x9f]/g,"").replace(/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g,"")}var qf={"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 nt(e){let t=e instanceof Error?e.message:String(e),n=t.match(/Slack error on (\S+): (\w+)/);if(!n)return t;let[,i,s]=n;switch(s){case"missing_scope":return`Error: token lacks the ${qf[i]??"the required"} scope (needed for ${i}). 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 t}}async function Vi(e,t,n){if(!t.startsWith("D"))return null;try{let i=await xs(e,t,n);if(!i)return null;return await bc(e,i,bn,n)}catch{return null}}function je(e,t,n,i){for(let r of n)console.log(r);let s=Oc(new Date,i);if(s)console.log(s);if(e!==void 0)console.error(`Code mismatch (got ${e}, expected ${t})`);console.error(`Rerun with --code=${t}`),process.exit(1)}function Cs(e){let t=Bt(e);if(t)return t.ts?{ref:t.channel,ts:t.ts}:{ref:t.channel};if(e.startsWith("#")||e.startsWith("@")){let n=e.indexOf(":");if(n>0){let i=e.slice(n+1);if(/^\d{10}\.\d{6}$/.test(i))return{ref:e.slice(0,n),ts:i};if(/^\d{4}-\d{2}-\d{2}T/.test(i))return{ref:e.slice(0,n),ts:Xi(i)}}}return{ref:e}}function Sn(e,t=!0){let n=Bt(e);if(n){if(!t)return{ref:n.channel};let s=n.threadTs??n.ts;return s?{ref:n.channel,threadTs:s}:{ref:n.channel}}let i=e.indexOf(":");if(i>0){let s=e.slice(i+1);if(/^\d{10}\.\d{6}$/.test(s))return{ref:e.slice(0,i),threadTs:s};if(/^\d{4}-\d{2}-\d{2}T/.test(s))return{ref:e.slice(0,i),threadTs:Xi(s)}}return{ref:e}}async function Es(e,t,n,i){let s=n;if(/^#?[CDG][A-Z0-9]{8,}$/.test(n)||!n.startsWith("#")&&!n.startsWith("@"))try{let o=I(await Fn(e,t,i)),a=I(o.channel);if(a.is_im===!0){let c=typeof a.user==="string"?a.user:"";s=c?`@${await He(e,c,i)}`:t}else s=typeof a.name==="string"?`#${a.name}`:t}catch{s=t}return s===t?t:`${s} (${t})`}async function Qt(e,t){try{return await za(e,t)}catch{return null}}function jt(e,t){let n;return async()=>{if(n===void 0)n=await Qt(e,t);return n}}function Kc(e,t){let n=t?" [as bot]":"";if(!e)return`(unknown \u2014 auth.test failed)${n}`;let i=te(e.user||e.userId||"?"),s=e.userId?` (${e.userId})`:"",r=e.team?` \u2014 ${te(e.team)}`:"";return`@${i}${s}${r}${n}`}function Le(e,t={}){return` ${"From:".padEnd(t.pad??6)}${Kc(e,t.asBot)}`}async function qi(e,t,n=60,i){let s=typeof t.user==="string"?await He(e,t.user,i):typeof t.username==="string"?t.username:"?",r=(typeof t.text==="string"?t.text:"").split(`
|
|
173
|
+
`)[0]??"",o=r.length>n?`${r.slice(0,n)}\u2026`:r,a=typeof t.ts==="string"?t.ts:"";return`${a?Yi(a).slice(0,16).replace("T"," "):""} @${s}${o?`: ${o}`:""}`}async function Yf(e,t,n,i){let s=n.find((r)=>String(r.ts)===t)??n[0];if(!s)return t;return qi(e,s,40,i)}function Pc(e){return e.toLowerCase().replace(/<[@#!][^>]+>/g," ").replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function Xf(e,t){let n=Pc(e),i=Pc(t);if(!n||!i)return 0;if(n===i)return 1;let s=(u)=>{let f=new Map;for(let l=0;l<u.length-1;l++){let d=u.slice(l,l+2);f.set(d,(f.get(d)??0)+1)}return f},r=s(n),o=s(i);if(r.size===0||o.size===0)return 0;let a=0;for(let[u,f]of r){let l=o.get(u);if(l)a+=Math.min(f,l)}let c=Tc(r)+Tc(o);return c===0?0:2*a/c}function Tc(e){let t=0;for(let n of e.values())t+=n;return t}async function Gf(e,t){let n=jt(e,t.cookie),{ref:i,ts:s}=Cs(t.target);if(!s)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 r;if(t.channelId)r=t.channelId;else r=await De(e,i,t.cookie);let o=await ze(e,r,s,1,t.cookie),c=X(o.messages).map(I).find((m)=>String(m.ts)===s);if(!c)console.error(`Message not found at ts=${s} in channel ${r}`),process.exit(1);let u=typeof c.text==="string"?c.text:"",f=t.mentions?await xc(e,t.newText,r,t.cookie?{cookie:t.cookie}:{}):t.newText,l=await n(),d=qe(u,f,l?.userId??"");if(t.code!==d)je(t.code,d,["--- Editing as -------------------------------",Le(l),"--- Original message -------------------------",...u.split(`
|
|
173
174
|
`).map((m)=>` ${m}`),"--- Replacing with ---------------------------",...f.split(`
|
|
174
|
-
`).map((m)=>` ${m}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let
|
|
175
|
-
`).map((
|
|
176
|
-
`+` To reach yourself with a notification, send as the bot: slack send '${t.target}' '...' --as-bot`);let a=ft(t.message),c=a,u=null;if(t.mentions){u=await vt(t.mentionToken??e,a,o,t.mentionCookie),c=u.text;for(let A of En(u.unresolved))console.error(`\u26A0 ${
|
|
177
|
-
`)[0]?.slice(0,100)??"(empty)"}`,...f,"--- Sending ----------------------------------",M,` \u2192 ${A} \u2014 NEW top-level message`,` Message: ${c}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],F)}let k=await
|
|
178
|
-
`+` To reach yourself with a notification, ask as the bot: slack ask '${t.target}' '...' --as-bot`);let u=
|
|
175
|
+
`).map((m)=>` ${m}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let h=await Gt(e,r,s,f,t.cookie);console.log(`\u2713 Edited (ts: ${h})`)}async function Vf(e,t){let n=jt(e,t.cookie),{ref:i,ts:s}=Cs(t.target);if(!s)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 r;if(t.channelId)r=t.channelId;else r=await De(e,i,t.cookie);let o=await ze(e,r,s,1,t.cookie),c=X(o.messages).map(I).find((d)=>String(d.ts)===s);if(!c)console.error(`Message not found at ts=${s} in channel ${r}`),process.exit(1);let u=typeof c.text==="string"?c.text:"",f=await n(),l=qe(r,s,u,f?.userId??"");if(t.code!==l){let d=await Es(e,r,i,t.cookie);je(t.code,l,["--- Deleting message -------------------------",Le(f),` \u2192 ${d} at ${Yi(s)}`,...u.split(`
|
|
176
|
+
`).map((h)=>` ${h}`),"---------------------------------------------"])}await ec(e,r,s,t.cookie),console.log(`\u2713 Deleted (ts: ${s})`)}async function Zf(e,t){let{ref:n,ts:i}=Cs(t.target);if(!i)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 s=t.emoji.replace(/^:|:$/g,""),r;if(t.channelId)r=t.channelId;else r=await De(e,n,t.cookie);if(t.remove)await gn(e,r,i,s,t.cookie),console.log(`\u2713 Removed :${s}: (ts: ${i})`);else await ut(e,r,i,s,t.cookie),console.log(`\u2713 Reacted :${s}: (ts: ${i})`)}async function Zi(e,t,n,i){if(!n||!t.startsWith("D"))return!1;try{let s=I(await Fn(e,t,i)),r=I(s.channel);return r.is_im===!0&&r.user===n}catch{return!1}}async function Qf(e,t){let{ref:n,threadTs:i}=Sn(t.target),s=t.cookie,r=jt(e,s),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await Mt(e,t.userId,s);else o=await De(e,n,s);if(!t.asBot&&await Zi(e,o,(await r())?.userId,s))console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
|
|
177
|
+
`+` To reach yourself with a notification, send as the bot: slack send '${t.target}' '...' --as-bot`);let a=ft(t.message),c=a,u=null;if(t.mentions){u=await vt(t.mentionToken??e,a,o,t.mentionCookie),c=u.text;for(let A of En(u.unresolved))console.error(`\u26A0 ${te(A)}`)}try{for(let A of await kc(t.mentionToken??e,c,t.mentionCookie))console.error(`\u26A0 possible untagged mention: ${te(A.surface)} \u2014 @${te(A.display)} won't be notified (did you mean <@${A.userId}>?)`)}catch{}let f=[];if(u&&(u.resolved.length>0||u.unresolved.length>0)){f.push("--- Mentions ---------------------------------");for(let A of u.resolved)f.push(` \u2713 ${te(A.surface)} \u2192 @${te(A.display)} (${A.userId}) \u2014 will notify`);for(let A of u.unresolved){let M=A.reason==="ambiguous"?"ambiguous":A.reason==="unavailable"?"lookup unavailable":"no match";f.push(` \u26A0 ${te(A.surface)} \u2014 plain text, NOT notified (${M})`)}}let l="",d="?",h=[],m,p,y;if(i)try{let A=await ze(e,o,i,100,s);h=X(A.messages).map(I);let M=h[h.length-1];l=typeof M?.text==="string"?M.text:"",m=typeof M?.user==="string"?M.user:void 0,p=typeof M?.bot_id==="string"?M.bot_id:void 0,y=typeof M?.ts==="string"?M.ts:void 0}catch{}else try{let A=await Qe(e,o,1,void 0,void 0,s),M=X(A.messages).map(I),R=M.filter((q)=>q.subtype===void 0||q.subtype===null)[0];l=typeof R?.text==="string"?R.text:"",d=typeof R?.user==="string"?await He(e,R.user,s):typeof R?.username==="string"?R.username:"?";let P=M[0];m=typeof P?.user==="string"?P.user:void 0,p=typeof P?.bot_id==="string"?P.bot_id:void 0,y=typeof P?.ts==="string"?P.ts:void 0}catch{}if(process.env.SLACK_UNREPLIED_WARN!=="0"&&y&&(m||p))try{let A=await r();if(!!A&&(!!m&&!!A.userId&&A.userId===m||!!p&&!!A.botId&&A.botId===p)){let R=`slack edit "#${o}:${y}" "<\u65B0\u3057\u3044\u672C\u6587>" --channel-id ${o}`;try{let P=await hn(e,o,y,s);if(P)R=`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(` ${R}`),console.error(" \u3053\u306E\u307E\u307E\u9001\u4FE1\u3059\u308B\u5834\u5408\u306F --code=XXXX \u3067\u78BA\u5B9A\u3002")}}catch{}if(i&&h.length){let A={sim:0,msg:null};for(let M of h){let R=typeof M.text==="string"?M.text:"";if(!R)continue;let P=Xf(c,R);if(P>A.sim)A={sim:P,msg:M}}if(A.msg&&A.sim>=0.82){let M=Math.round(A.sim*100);console.error(`\u26A0 possible duplicate: ${M}% similar to an existing thread message \u2014 ${await qi(e,A.msg,60,s)}`)}}let C=await r(),F=await Vi(e,o,s),S=qe(o,i??"",l,c,C?.userId??"");if(t.code!==S){let A=await Es(e,o,n,s),M=Le(C,{asBot:t.asBot});if(i){let R=await Yf(e,i,h,s),P=h.slice(-3),q=P.length?await Promise.all(P.map(async(_)=>` ${await qi(e,_,60,s)}`)):[" (thread context unavailable)"];je(t.code,S,["--- Recent messages in thread ----------------",...q,...f,"--- Sending ----------------------------------",M,` \u2192 ${A} thread of ${R} \u2014 THREAD REPLY`,` Message: ${c}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],F)}else je(t.code,S,["--- Last message in channel ------------------",` ${d}: ${l.split(`
|
|
178
|
+
`)[0]?.slice(0,100)??"(empty)"}`,...f,"--- Sending ----------------------------------",M,` \u2192 ${A} \u2014 NEW top-level message`,` Message: ${c}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],F)}let k=await fs(e,o,c,i,t.broadcast,s),j="";try{j=await hn(e,o,k,s)}catch{}if(j)console.log(`\u2713 Sent: ${j}`);else console.log(`\u2713 Sent (ts: ${k})`);if(t.asBot&&o.startsWith("D"))try{let A=await hi(e);if(!A.ok)for(let M of gi(A,!0))console.error(M);else{let M=A.appId?`https://api.slack.com/apps/${A.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${t.target} can't reply (app messaging may be off), enable Messages Tab: ${M} \u2192 App Home.`)}}catch{}}var ed=2,Ce=3,td=1.618033988749895,nd=1000,sd=5000,Rc=8,id=(e)=>new Promise((t)=>setTimeout(t,e)),rd=new Set(["thread_broadcast"]),od=/(?<![A-Za-z0-9._@<-])@(here|channel|everyone)(?![A-Za-z0-9._-])/giu;function ws(e){let t=new Set;return{text:e.replace(od,(i,s)=>{let r=s.toLowerCase();return t.add(r),`<!${r}>`}),kinds:t}}async function xs(e,t,n){if(!t.startsWith("D"))return;try{let i=I(await Fn(e,t,n)),s=I(i.channel);return s.is_im===!0&&typeof s.user==="string"?s.user:void 0}catch{return}}async function Jc(e,t){let{channelId:n,ts:i,question:s,reactable:r,threadOnly:o,audience:a,broadcast:c,cookie:u,timeout:f,shown:l}=t,d=t.askerUserId,h=t.askerBotId,m=(R)=>typeof R==="string"&&!!R&&R!==d&&(c||a.has(R));function p(R){let P=X(R.reactions).map(I),q=[];for(let _=0;_<r.length;_++){let E=P.find((N)=>N.name===Be[_].name),O=E?X(E.users).filter(m):[];if(O.length)q.push({index:_,users:O})}return q}async function y(R,P){let q=typeof R.text==="string"?R.text:"";if(!q)return;let _=Si(q,P);if(_===q)return;try{await Gt(e,n,i,_,u,!0)}catch(E){console.error(` (\u8CEA\u554F\u6587\u306B\u6CE8\u610F\u66F8\u304D\u3092\u5165\u308C\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${E instanceof Error?E.message:String(E)})`)}}async function C(R){let P=p(R);if(P.length<=1&&_i(typeof R.text==="string"?R.text:"").length)await y(R,[]);if(!P.length)return null;if(P.length===1){let{index:E,users:O}=P[0];return{answer:r[E],how:`\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${Be[E].glyph}`,who:O[0]}}let q=P.map((E)=>Be[E.index].glyph).join(" / ");console.error(` (${q} \u304C\u540C\u6642\u306B\u9078\u3070\u308C\u3066\u3044\u307E\u3059\u30021 \u3064\u306B\u7D5E\u3063\u3066\u3082\u3089\u3046\u307E\u3067\u5F85\u3061\u307E\u3059)`);let _=[...new Set(P.flatMap((E)=>E.users))].sort();return await y(R,_),null}function F(R,P=1/0){let q=[...R].sort((_,E)=>Number(_.ts)-Number(E.ts));for(let _ of q){if(!(Number(_.ts)>Number(i)))continue;if(!m(_.user))continue;if(typeof _.subtype==="string"&&!rd.has(_.subtype))continue;if(Number(_.ts)>=P)break;let E=typeof _.text==="string"?_.text.trim():"";if(E)return{answer:E,how:"\u8FD4\u4FE1",who:_.user}}return null}async function S(){if(t.threadParentTs){let _=I(await ze(e,n,t.threadParentTs,100,u)),E=X(_.messages).map(I),O=E.find((N)=>N.ts===i);if(O){let N=await C(O);if(N)return N}return F(E)}let R=I(await Qe(e,n,30,i,void 0,u,!0)),P=X(R.messages).map(I),q=P.find((_)=>_.ts===i);if(q){let _=await C(q);if(_)return _}if(!o){let _=P.filter((O)=>Number(O.ts)>Number(i)&&(h&&O.bot_id===h||d&&O.user===d)).reduce((O,N)=>Math.min(O,Number(N.ts)),1/0),E=F(P,_);if(E)return E}if(q&&Number(q.reply_count)>0){let _=I(await ze(e,n,i,30,u)),E=F(X(_.messages).map(I));if(E)return E}return null}async function k(R){for(let q=0;q<r.length;q++)try{await gn(e,n,i,Be[q].name,u)}catch{}let P="";if(R.who)try{P=await He(e,R.who,u)}catch{P=R.who}if(P)console.error(` \u56DE\u7B54\u8005: ${te(P)}`);try{await Gt(e,n,i,Oa(s,R,P),u,!0);try{await ut(e,n,i,ki,u),await gn(e,n,i,as,u)}catch{}}catch(q){console.error(` (\u5143\u30E1\u30C3\u30BB\u30FC\u30B8\u306E\u66F4\u65B0\u306B\u5931\u6557: ${q instanceof Error?q.message:String(q)})`)}}let j=Date.now()+f*1000,A=0,M=nd;for(;;){let R=null;try{R=await S(),A=0}catch(P){if(A++,A>=Rc)console.error(`Error: Slack \u3078\u306E\u554F\u3044\u5408\u308F\u305B\u306B ${A} \u56DE\u9023\u7D9A\u3067\u5931\u6557\u3057\u307E\u3057\u305F: ${P instanceof Error?P.message:String(P)}`),process.exit(Ce);console.error(` (Slack \u30A8\u30E9\u30FC ${A}/${Rc}, \u518D\u8A66\u884C\u3057\u307E\u3059: ${P instanceof Error?P.message:String(P)})`)}if(R)await k(R),console.log(R.answer),process.exit(0);if(Date.now()>=j)break;await id(Math.min(M,Math.max(0,j-Date.now()))),M=Math.min(M*td,sd)}if(f===0)console.error(`\u307E\u3060\u56DE\u7B54\u304C\u3042\u308A\u307E\u305B\u3093: ${l}`);else console.error(`Error: ${f}s \u4EE5\u5185\u306B\u56DE\u7B54\u304C\u3042\u308A\u307E\u305B\u3093\u3067\u3057\u305F (\u30E1\u30C3\u30BB\u30FC\u30B8\u306F\u305D\u306E\u307E\u307E\u6B8B\u3063\u3066\u3044\u307E\u3059)`),console.error(` ${l}`),console.error(` \u3042\u3068\u3067\u56DE\u53CE\u3059\u308B: ${zc(l,t.asBot)}`);process.exit(ed)}function zc(e,t){return`slack ask --waitFor='${e}'${t?" --as-bot":""}`}async function ad(e,t){let{ref:n,threadTs:i}=Sn(t.target,!1),s=t.cookie,r=jt(e,s),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await Mt(e,t.userId,s);else o=await De(e,n,s);let a=(await r())?.userId??"",c=await xs(e,o,s);if(!t.asBot&&!!a&&c===a)console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
|
|
179
|
+
`+` To reach yourself with a notification, ask as the bot: slack ask '${t.target}' '...' --as-bot`);let u=ws(ft(t.question)),f=ws(ft(t.body??"")),l=new Set([...u.kinds,...f.kinds]),d=t.mentionToken??e,h=await vt(d,u.text,o,t.mentionCookie),m=f.text?await vt(d,f.text,o,t.mentionCookie):{text:"",resolved:[],unresolved:[]},p=h.text,y=m.text,C=[...h.resolved,...m.resolved],F=[...h.unresolved,...m.unresolved];for(let Z of En(F))console.error(`\u26A0 ${te(Z)}`);let S=l.size>0,k=new Set(C.map((Z)=>Z.userId).filter((Z)=>Z!==a)),j=new Map(C.map((Z)=>[Z.userId,Z.display])),A;if(S)A=`anyone in ${n} (${[...l].map((Z)=>`@${Z}`).join(", ")})`;else{if(!k.size&&c&&c!==a)k.add(c),j.set(c,await He(e,c,s));if(!k.size)console.error("Error: `ask` will not post a question nobody is addressed to \u2014 no one is tagged.\n"+(F.length?` (${F.map((Z)=>te(Z.surface)).join(", ")} matched no one, so it names nobody.)
|
|
179
180
|
`:"")+` Tag the person who should answer: slack ask '${t.target}' '@alice ${t.question}' ...
|
|
180
181
|
Or open it to the whole channel: slack ask '${t.target}' '@here ${t.question}' ...
|
|
181
|
-
(In a 1:1 DM the other person counts automatically.)`),process.exit(Ce);A=[...k].map((Z)=>`@${
|
|
182
|
-
`)[0]?.slice(0,100)??"(empty)"}`,...W,"--- Asking -----------------------------------",Le(N,{asBot:t.asBot}),` \u2192 ${Z}${i?" \u2014 THREAD REPLY":" \u2014 NEW top-level message"}`,` Question: ${
|
|
183
|
-
`+` Got: ${
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
`+`
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
`+"
|
|
190
|
-
|
|
191
|
-
|
|
182
|
+
(In a 1:1 DM the other person counts automatically.)`),process.exit(Ce);A=[...k].map((Z)=>`@${te(j.get(Z)??Z)} (${Z})`).join(", ")}let M=t.choices.map(ft),R=M.slice(0,os),P=M.slice(os),q=!o.startsWith("D")||!!i,_=$a(p,y,R,P,q),E="",O="?";try{let Z=await Qe(e,o,1,void 0,void 0,s),W=X(Z.messages).map(I).filter((Se)=>Se.subtype===void 0||Se.subtype===null)[0];E=typeof W?.text==="string"?W.text:"",O=typeof W?.user==="string"?await He(e,W.user,s):typeof W?.username==="string"?W.username:"?"}catch{}let N=await r(),Q=await Vi(e,o,s),oe=qe(o,i??"",E,_,N?.userId??"");if(t.code!==oe){let Z=await Es(e,o,n,s),W=R.length?["--- Choices (seeded as reactions) ------------",...R.map((Se,Lt)=>` ${Be[Lt].glyph} ${ln(Se)}`),...P.map((Se,Lt)=>` (${Lt+11}) ${ln(Se)} \u2014 text answer only`)]:["--- Choices ----------------------------------"," (none \u2014 free-text reply)"];je(t.code,oe,["--- Last message in channel ------------------",` ${O}: ${E.split(`
|
|
183
|
+
`)[0]?.slice(0,100)??"(empty)"}`,...W,"--- Asking -----------------------------------",Le(N,{asBot:t.asBot}),` \u2192 ${Z}${i?" \u2014 THREAD REPLY":" \u2014 NEW top-level message"}`,` Question: ${p}`,` Answerable by: ${A}`,` Via: ${q?"reactions or thread replies":"reactions or replies in this DM"}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],Q)}let V=await fs(e,o,_,i,!1,s,!0);try{await ut(e,o,V,as,s)}catch(Z){console.error(` (marker ${as} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${Z instanceof Error?Z.message:String(Z)})`)}for(let Z=0;Z<R.length;Z++)try{await ut(e,o,V,Be[Z].name,s)}catch(W){console.error(` (\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${Be[Z].name} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${W instanceof Error?W.message:String(W)})`)}let ae="";try{ae=await hn(e,o,V,s)}catch{}let Ie=ae||`${o}:${V}`;if(console.error(`\u2713 Asked: ${Ie}`),!t.wait){console.log(zc(Ie,!!t.asBot));return}let ee=t.timeout??3600;console.error(` \u56DE\u7B54\u3092\u5F85\u3063\u3066\u3044\u307E\u3059 (\u6700\u5927 ${ee}s)\u2026 Ctrl-C \u3067\u4E2D\u65AD`);let _e={channelId:o,ts:V,question:p,reactable:R,threadOnly:q,audience:k,broadcast:S,askerUserId:N?.userId??"",askerBotId:N?.botId??"",timeout:ee,shown:Ie,asBot:!!t.asBot};if(i)_e.threadParentTs=i;if(s)_e.cookie=s;await Jc(e,_e)}async function cd(e,t){let n=Bt(t.link),i,s,r;if(n?.ts)i=n.channel,s=n.ts,r=n.threadTs&&n.threadTs!==n.ts?n.threadTs:void 0;else{let m=t.link.match(/^([A-Za-z0-9]+):(\d{10}\.\d{6})$/);if(!m)console.error(`Error: --waitFor needs the permalink of a question (or 'C\u2026:1700000000.000100').
|
|
184
|
+
`+` Got: ${te(t.link)}`),process.exit(Ce);i=m[1],s=m[2]}let o;if(r){let m=I(await ze(e,i,r,100,t.cookie));o=X(m.messages).map(I).find((p)=>p.ts===s)}else{let m=I(await Qe(e,i,1,s,void 0,t.cookie,!0));o=X(m.messages).map(I).find((p)=>p.ts===s)}if(!o)console.error(`Error: \u305D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${te(t.link)}`),process.exit(Ce);let a=typeof o.text==="string"?o.text:"",c=Pa(a);if(c.kind==="other")console.error("Error: \u3053\u308C\u306F `slack ask` \u306E\u8CEA\u554F\u3068\u3057\u3066\u8AAD\u307F\u53D6\u308C\u307E\u305B\u3093\u3002\n"+` \u7406\u7531: ${Ia(a)}
|
|
185
|
+
${te(t.link)}
|
|
186
|
+
`+` (\u62BC\u3055\u308C\u305F\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3\u306F\u6B8B\u3063\u3066\u3044\u307E\u3059: slack read '${te(t.link)}' \u3067\u78BA\u8A8D\u3067\u304D\u307E\u3059)`),process.exit(Ce);if(c.kind==="resolved"){console.error(`\u2713 \u56DE\u7B54\u6E08\u307F: ${te(c.question)}`),console.log(c.answer);return}let u=typeof o.user==="string"?o.user:"",f=typeof o.bot_id==="string"?o.bot_id:"",l=/<!(here|channel|everyone)(\^[^>]*)?(\|[^>]*)?>/.test(a),d=new Set;for(let m of a.matchAll(/<@([UW][A-Z0-9]+)>/g))if(m[1]!==u)d.add(m[1]);if(!d.size&&!l){let m=await xs(e,i,t.cookie);if(m&&m!==u)d.add(m)}if(!d.size&&!l)console.error(`Error: \u3053\u306E\u8CEA\u554F\u306F\u8AB0\u306B\u3082\u5B9B\u3066\u3089\u308C\u3066\u3044\u306A\u3044\u305F\u3081\u3001\u6709\u52B9\u306A\u56DE\u7B54\u8005\u3092\u5224\u5B9A\u3067\u304D\u307E\u305B\u3093: ${te(t.link)}`),process.exit(Ce);if(t.timeout>0)console.error(` \u56DE\u7B54\u3092\u5F85\u3063\u3066\u3044\u307E\u3059 (\u6700\u5927 ${t.timeout}s)\u2026 Ctrl-C \u3067\u4E2D\u65AD`);let h={channelId:i,ts:s,question:c.question,reactable:c.reactable,threadOnly:c.threadOnly,audience:d,broadcast:l,askerUserId:u,askerBotId:f,timeout:t.timeout,shown:t.link,asBot:t.asBot};if(r)h.threadParentTs=r;if(t.cookie)h.cookie=t.cookie;await Jc(e,h)}var ve=3;function ud(e){return`slack poll --results='${e}'`}async function ld(e,t){let{ref:n,threadTs:i}=Sn(t.target,!1),s=t.cookie,r=jt(e,s),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await Mt(e,t.userId,s);else o=await De(e,n,s);let a=(await r())?.userId??"",c=await xs(e,o,s);if(!t.asBot&&!!a&&c===a)console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
|
|
187
|
+
`+` To reach yourself with a notification, post as the bot: slack poll '${t.target}' '...' --as-bot`);let u=ws(ft(t.question)),f=ws(ft(t.body??"")),l=t.mentionToken??e,d=await vt(l,u.text,o,t.mentionCookie),h=f.text?await vt(l,f.text,o,t.mentionCookie):{text:"",resolved:[],unresolved:[]},m=d.text,p=h.text;for(let E of En([...d.unresolved,...h.unresolved]))console.error(`\u26A0 ${te(E)}`);let y=t.choices.map(ft),C=!!t.multi,F=t.until??"",S=va(m,p,y,{multi:C,deadline:F}),k="",j="?";try{let E=await Qe(e,o,1,void 0,void 0,s),O=X(E.messages).map(I).filter((N)=>N.subtype===void 0||N.subtype===null)[0];k=typeof O?.text==="string"?O.text:"",j=typeof O?.user==="string"?await He(e,O.user,s):typeof O?.username==="string"?O.username:"?"}catch{}let A=await r(),M=await Vi(e,o,s),R=qe(o,i??"",k,S,A?.userId??"");if(t.code!==R){let E=await Es(e,o,n,s);je(t.code,R,["--- Last message in channel ------------------",` ${j}: ${k.split(`
|
|
188
|
+
`)[0]?.slice(0,100)??"(empty)"}`,"--- Ballot (seeded as reactions) -------------",...y.map((O,N)=>` ${Ne[N].glyph} ${fn(O)}`),"--- Posting ----------------------------------",Le(A,{asBot:t.asBot}),` \u2192 ${E}${i?" \u2014 THREAD REPLY":" \u2014 NEW top-level message"}`,` Question: ${m}`,` Rule: ${C?"1 \u4EBA \u4F55\u7968\u3067\u3082 (--multi)":"1 \u4EBA 1 \u7968"}${F?` \u2014 \u7DE0\u5207 ${F}`:""}`," Note: \u3042\u306A\u305F\u81EA\u8EAB\u306E\u7968\u306F\u6570\u3048\u307E\u305B\u3093 (\u30D4\u30EB\u306F\u3042\u306A\u305F\u304C\u4ED8\u3051\u305F\u7A2E\u306A\u306E\u3067\u533A\u5225\u3067\u304D\u307E\u305B\u3093)","--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],M)}let P=await fs(e,o,S,i,!1,s,!0);try{await ut(e,o,P,dn,s)}catch(E){console.error(` (marker ${dn} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${E instanceof Error?E.message:String(E)})`)}for(let E=0;E<y.length;E++)try{await ut(e,o,P,Ne[E].name,s)}catch(O){console.error(` (\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${Ne[E].name} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${O instanceof Error?O.message:String(O)})`)}let q="";try{q=await hn(e,o,P,s)}catch{}let _=q||`${o}:${P}`;console.error(`\u2713 Posted: ${_}`),console.log(ud(_)),console.error(` \u7DE0\u3081\u5207\u308B: slack poll --close='${_}'${t.asBot?" --as-bot":""}`)}async function fd(e,t,n){let i=Bt(t),s,r,o;if(i?.ts)s=i.channel,r=i.ts,o=i.threadTs&&i.threadTs!==i.ts?i.threadTs:void 0;else{let c=t.match(/^([A-Za-z0-9]+):(\d{10}\.\d{6})$/);if(!c)console.error(`Error: --results/--close needs the permalink of a poll (or 'C\u2026:1700000000.000100').
|
|
189
|
+
`+` Got: ${te(t)}`),process.exit(ve);s=c[1],r=c[2]}let a;if(o){let c=I(await ze(e,s,o,100,n));a=X(c.messages).map(I).find((u)=>u.ts===r)}else{let c=I(await Qe(e,s,1,r,void 0,n,!0));a=X(c.messages).map(I).find((u)=>u.ts===r)}if(!a)console.error(`Error: \u305D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${te(t)}`),process.exit(ve);return{channelId:s,ts:r,msg:a}}function Mc(e){let t=Math.max(1,...e.map((n)=>n.count));return e.map((n,i)=>`${Ne[i].glyph} ${String(n.count).padStart(3)} ${"\u2588".repeat(Math.round(n.count/t*20))}${n.count?" ":""}${n.choice}`)}async function dd(e,t){let{channelId:n,ts:i,msg:s}=await fd(e,t.link,t.cookie),r=typeof s.text==="string"?s.text:"",o=La(r);if(o.kind==="other")console.error("Error: \u3053\u308C\u306F `slack poll` \u306E\u6295\u7968\u3067\u306F\u3042\u308A\u307E\u305B\u3093 (\u7968\u306E\u6570\u3048\u65B9\u304C\u5206\u304B\u308A\u307E\u305B\u3093)\u3002\n"+` ${te(t.link)}`),process.exit(ve);if(o.kind==="closed"){console.error(`\u2713 \u6295\u7968\u7D42\u4E86: ${te(o.question)}`);for(let h of Mc(o.tallies))console.log(h);return}let a=new Set;if(typeof s.user==="string"&&s.user)a.add(s.user);let c=await tc(e,n,i,t.cookie),u=Wa(o.choices,c,a,o.multi);console.error(`${te(o.question)}${o.deadline?` (\u7DE0\u5207 ${o.deadline})`:""}`);for(let h of Mc(u.tallies))console.log(h);let f=u.tallies.reduce((h,m)=>h+m.count,0);if(console.error(` \u8A08 ${f} \u7968${o.multi?" (\u8907\u6570\u9078\u629E\u53EF)":""}`),t.names)for(let h=0;h<u.voters.length;h++){if(!u.voters[h].length)continue;let m=await Promise.all(u.voters[h].map((p)=>He(e,p,t.cookie)));console.error(` ${Ne[h].glyph} ${m.map((p)=>`@${te(p)}`).join(", ")}`)}let l=o.multi?[]:u.ambiguous,d=Si(r,l);if(d!==r&&!t.noNotify)try{await Gt(t.writeToken??e,n,i,d,t.writeToken?t.writeCookie:t.cookie,!0)}catch(h){console.error(` (\u6295\u7968\u6587\u306B\u6CE8\u610F\u66F8\u304D\u3092\u5165\u308C\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${h instanceof Error?h.message:String(h)})
|
|
190
|
+
`+" \u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u66F8\u304D\u63DB\u3048\u3089\u308C\u308B\u306E\u306F\u6295\u7A3F\u8005\u3060\u3051\u3067\u3059 \u2014 bot \u304C\u6295\u7A3F\u3057\u305F\u6295\u7968\u306A\u3089 --as-bot \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002")}if(u.ambiguous.length){let h=await Promise.all(u.ambiguous.map((m)=>He(e,m,t.cookie)));console.error(`\u26A0 1 \u4EBA 1 \u7968\u306A\u306E\u306B\u8907\u6570\u62BC\u3057\u3066\u3044\u308B\u4EBA\u304C\u3044\u307E\u3059 (\u7121\u52B9\u7968): ${h.map((m)=>`@${te(m)}`).join(", ")}`)}if(!t.close)return;await Gt(t.writeToken??e,n,i,ja(o.question,u.tallies),t.writeToken?t.writeCookie:t.cookie,!0);try{await ut(t.writeToken??e,n,i,Pi,t.writeToken?t.writeCookie:t.cookie),await gn(t.writeToken??e,n,i,dn,t.writeToken?t.writeCookie:t.cookie)}catch{}console.error(`\u2713 \u6295\u7968\u3092\u7DE0\u3081\u5207\u308A\u307E\u3057\u305F: ${te(t.link)}`)}async function pd(e){let t=await hi(e);for(let n of gi(t,!1))console.log(n);if(!t.ok)process.exit(1)}function hd(e){if(/^\d{10,}$/.test(e))return parseInt(e,10);let t=new Date(e.replace(" ","T"));if(isNaN(t.getTime()))throw Error(`Cannot parse time: ${e}`);return Math.floor(t.getTime()/1000)}function gd(e){let t=new Date(e*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(t).replace(/\u2212/g,"-")} (local) / ${t.toISOString()} (Unix: ${e})`}async function md(e,t){let n=jt(e,t.cookie),{ref:i,threadTs:s}=Sn(t.target),r;if(t.channelId)r=t.channelId;else if(t.userId)r=await Mt(e,t.userId,t.cookie);else r=await De(e,i,t.cookie);let o=hd(t.at),a=new Date(o*1000).toISOString(),c=await n();if(await Zi(e,r,c?.userId,t.cookie))console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you when this fires.`);let u=qe(r,t.message,String(o),c?.userId??"");if(t.code!==u)je(t.code,u,["--- Scheduling message -----------------------",Le(c,{pad:9}),` To: ${i}${s?` (thread ${s})`:""}`,` At: ${gd(o)}`,` Message: ${t.message}`,"---------------------------------------------"]);let f=await Va(e,r,t.message,o,s,t.cookie);console.log(`\u2713 Scheduled (id: ${f}, at: ${a})`)}async function Dd(e,t,n,i){let s;if(n)s=n;else if(t)s=await De(e,t,i);let o=(await Za(e,s,i)).scheduled_messages??[];if(o.length===0){console.log("(no scheduled messages)");return}for(let a of o){let c=new Date(a.post_at*1000).toISOString();console.log(`${a.id} ${c} [${a.channel_id}] ${a.text.split(`
|
|
191
|
+
`)[0]?.slice(0,80)??""}`)}}async function yd(e,t){let n;if(t.channelId)n=t.channelId;else n=await De(e,t.target,t.cookie);let i=await Qt(e,t.cookie),s=qe(n,t.id,i?.userId??"");if(t.code!==s)je(t.code,s,["--- Deleting scheduled message ---------------",Le(i,{pad:9}),` Channel: ${t.target}`,` ID: ${t.id}`,"---------------------------------------------"]);await Qa(e,n,t.id,t.cookie),console.log(`\u2713 Deleted scheduled message ${t.id}`)}async function wd(e,t){let n=jt(e,t.cookie),{statSync:i,existsSync:s}=await import("fs"),{basename:r}=await import("path");for(let m of t.filePaths)if(!s(m))console.error(`Error: file not found: ${m}`),process.exit(1);let{ref:o,threadTs:a}=Sn(t.target),c;if(t.channelId)c=t.channelId;else if(t.userId)c=await Mt(e,t.userId,t.cookie);else c=await De(e,o,t.cookie);if(await Zi(e,c,(await n())?.userId,t.cookie))console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own upload.`);let u=t.filePaths.length>1,f=t.filePaths.map((m)=>{let p=r(m),y=u?p:t.title??p;return{fp:m,filename:p,title:y,sizeFmt:Fs(i(m).size)}}),l=await n(),d=qe(c,...f.flatMap((m)=>[m.fp,m.title]),l?.userId??"");if(t.code!==d){let m=` To: ${o}${a?` (thread ${a})`:""}`,p=u?[`--- Uploading ${f.length} files ------------------------`,Le(l,{pad:7}),m,...f.map((y)=>` ${y.filename} (${y.sizeFmt})`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]:["--- Uploading file ---------------------------",Le(l,{pad:7}),m,` File: ${f[0].fp}`,` Title: ${f[0].title}`,` Size: ${f[0].sizeFmt}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];je(t.code,d,p)}let h=f.length;for(let m=0;m<h;m++){let p=f[m],y={title:p.title};if(a!==void 0)y.threadTs=a;if(t.comment!==void 0&&m===0)y.initialComment=t.comment;let{fileId:C,permalink:F}=await uc(e,c,p.fp,y,t.cookie),S=h>1?`[${m+1}/${h}] `:"";console.log(`${S}\u2713 Uploaded (file_id: ${C}${F?`, url: ${F}`:""})`)}}async function bd(e,t,n){let i=n.channel?await De(e,n.channel,t):void 0,s=[],r=1,o=1;do{let c={page:r,count:200};if(n.types)c.types=n.types;if(i)c.channel=i;if(n.user)c.user=n.user;let u=I(await qa(e,c,t));for(let f of X(u.files))s.push(I(f));o=Number(I(u.paging).pages??1),r++}while(s.length<n.limit&&r<=o);let a=s.slice(0,n.limit);if(n.format==="jsonl"){for(let c of a)console.log(JSON.stringify({id:c.id??null,name:c.name??c.title??null,filetype:c.filetype??null,size:c.size??null,user:c.user??null,created:c.created??null,permalink:c.permalink??null}));return}for(let c of a){let u=String(c.id??""),f=typeof c.name==="string"?c.name:typeof c.title==="string"?c.title:u,l=typeof c.filetype==="string"?c.filetype:"?",d=typeof c.size==="number"?Fs(c.size):"";console.log(`${u} ${l.padEnd(7)} ${d.padStart(9)} ${f}`)}}function Fd(e){if(/^F[A-Z0-9]+$/i.test(e))return e;return e.match(/\/lists\/[A-Za-z0-9]+\/(F[A-Za-z0-9]+)/i)?.[1]??e.match(/\/lists\/(F[A-Za-z0-9]+)/i)?.[1]}function Cd(e){if(typeof e.text==="string"&&e.text)return e.text;let t=e.value;if(typeof t==="string"||typeof t==="number"||typeof t==="boolean")return String(t);if(Array.isArray(t))return t.map((n)=>typeof n==="string"?n:String(I(n).text??I(n).name??I(n).value??"")).filter(Boolean).join(", ");for(let n of["rich_text","select","user","date","number","checkbox","email","phone"]){let i=e[n];if(i!=null)return typeof i==="object"?JSON.stringify(i):String(i)}return""}async function Ed(e,t,n,i){let s=Fd(n);if(!s)throw Error(`Not a list ID or list URL: ${n}
|
|
192
|
+
`+"Expected F\u2026 or https://<ws>.slack.com/lists/<TEAM>/<F-id>");let r=[],o;do{let c={limit:200};if(o)c.cursor=o;let u=I(await Ya(e,s,c,t));for(let l of X(u.items??u.records))r.push(I(l));let f=I(u.response_metadata).next_cursor;o=typeof f==="string"&&f?f:void 0}while(o&&r.length<i.limit);let a=r.slice(0,i.limit);if(i.format==="jsonl"){for(let c of a)console.log(JSON.stringify(c));return}for(let c of a){let u=String(c.id??""),f=X(c.fields).map(I).map((l)=>{let d=String(l.key??l.column_id??"?"),h=Cd(l);return h?`${d}=${h}`:""}).filter(Boolean);console.log(`${u} ${f.join(" | ")}`)}}function xd(e){if(/^F[A-Z0-9]+$/i.test(e))return e;return e.match(/\/files\/[A-Za-z0-9]+\/(F[A-Za-z0-9]+)/)?.[1]}async function _d(e,t,n,i){let s=xd(n);if(!s)throw Error(`Not a file ID or file permalink: ${n}
|
|
193
|
+
`+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let r=I(await Ha(e,s,t)),o=I(r.file),a=typeof o.name==="string"?o.name:typeof o.title==="string"?o.title:s,c=typeof o.url_private_download==="string"?o.url_private_download:typeof o.url_private==="string"?o.url_private:"";if(!c)throw Error(`files.info returned no download URL for ${s}`);let u={Authorization:`Bearer ${e}`};if(t)u.Cookie=`d=${t}`;let f=await fetch(c,{headers:u});if(!f.ok)throw Error(`Download failed: HTTP ${f.status} ${f.statusText}`);let l=Buffer.from(await f.arrayBuffer()),{statSync:d,existsSync:h}=await import("fs"),{basename:m}=await import("path"),p=i??a;if(i&&h(i)&&d(i).isDirectory())p=pt(i,m(a));Nc(p,l),console.log(`\u2713 Downloaded ${a} (${Fs(l.length)}) \u2192 ${p}`)}async function Sd(){Af();let e=(s)=>ci(s.workspace),t=(s)=>Wo(s.workspace),n={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}},i=async(s,r)=>{let o={state:s.state??"open",mine:r||s.mine===!0,count:s.n??50,json:s.json===!0};if(s.in)o.in=s.in;if(s.from)o.from=s.from;let a=t(s);if(a)o.cookie=a;await jf(e(s),o)};await Ro(js(process.argv)).scriptName("slack").showHelpOnFail(!1).fail((s,r,o)=>{if(r)console.error(r.message),process.exit(1);console.error(s),console.error(""),o.showHelp(),process.exit(1)}).option("workspace",{alias:"w",type:"string",describe:"Workspace name"}).middleware(async(s)=>{let r=String((s._??[])[0]??"");if(!r||r==="auth"||r==="login")return;try{ci(s.workspace)}catch(o){if((o instanceof Error?o.message:String(o)).startsWith("No profiles configured"))console.log(`No workspace configured. Let's set that up:
|
|
194
|
+
`),await ns(),process.exit(0);throw o}},!0).command(["read [target]","msgs [target]"],"Browse messages",(s)=>s.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(s)=>{let r=e(s),o=s.json?"jsonl":s.format;if(s.target)await Tf(r,s.target,s.limit,o,s.unreplied,t(s));else await Mf(r)}).command("thread <target> <ts>","Show thread messages",(s)=>s.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(s)=>{let r=s.json?"jsonl":s.format;await Rf(e(s),s.target,s.ts,s.limit,r,t(s))}).command(["channel","channels","ch"],"Channel commands",(s)=>s.command(["ls","list"],"List channels",(r)=>r.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(r)=>{await Nf(e(r),r.limit,r.filter,r.all,r.json?"jsonl":r.format)}).command("get <channel>","Show channel details",(r)=>r.positional("channel",{type:"string",demandOption:!0,describe:"#name or channel ID"}),async(r)=>{let o=e(r),a=t(r),c=r.channel,u=c.startsWith("#")||c.startsWith("@")||c.startsWith("C")||c.startsWith("G")||c.startsWith("D")?c:`#${c}`,f=await De(o,u,a),l=I(await Fn(o,f,a)),d=I(l.channel),h=typeof d.name==="string"?d.name:f,p=d.is_im===!0?"@":"#",y=String(I(d.purpose).value??""),C=String(I(d.topic).value??""),F=d.num_members??d.member_count??"";if(console.log(`${p}${h} ${f}`),C)console.log(`topic: ${C}`);if(y)console.log(`purpose: ${y}`);if(F)console.log(`members: ${F}`);console.log(`private: ${d.is_private===!0}`)}).command(["create <name>","new <name>"],"Create a channel (confirm-hash safety gate)",(r)=>r.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(r)=>{let o=e(r),a=t(r),c=r.name.replace(/^#/,"").toLowerCase(),u=r.private===!0,f=r.invite.filter(Boolean),l=await Qt(o,a),d=qe(c,String(u),f.join(","),l?.userId??"");if(r.code!==d)je(r.code,d,["--- Creating channel -------------------------",Le(l,{pad:9}),` name: ${u?"\uD83D\uDD12 ":"#"}${c}`,` private: ${u}`,...f.length?[` invite: ${f.join(", ")}`]:[],"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let h;try{h=await nc(o,c,u,a)}catch(m){console.error(m instanceof Error?m.message:String(m)),process.exit(1)}if(console.log(`\u2713 Created ${u?"\uD83D\uDD12 ":"#"}${h.name} (${h.id})`),f.length){let m=[];for(let p of f)try{m.push(p.startsWith("U")||p.startsWith("W")?p:await Dn(o,p,a))}catch(y){console.error(` ! could not resolve ${p}: ${y instanceof Error?y.message:String(y)}`)}for(let p of m)try{let y=I(await bn(o,p,a)),C=I(y.user);if(C.is_ultra_restricted===!0)console.error(`\u26A0 ${p} 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(C.is_restricted===!0)console.error(`\u26A0 ${p} is a multi-channel guest \u2014 double-check they were actually added (guest invites can silently no-op depending on workspace restrictions).`)}catch{}if(m.length)try{await sc(o,h.id,m,a),console.log(`\u2713 Invited ${m.length} member${m.length===1?"":"s"}`)}catch(p){console.error(` ! invite failed: ${p instanceof Error?p.message:String(p)}`)}}}).demandCommand(1,"").showHelpOnFail(!0)).command(["user","usr"],"User commands",(s)=>s.command(["ls","list"],"List workspace members",(r)=>r.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"}).option("external",{type:"boolean",default:!1,describe:"Also include people reachable only through Slack Connect shared channels \u2014 they are in ANOTHER workspace, so users.list never returns them (costs one API call per shared channel)"}),async(r)=>{let o=r.json?"jsonl":r.format,a=e(r),c=t(r),u=await Mi(a,c),f=r.filter?.toLowerCase(),l=X(u.members).map(I);if(r.external){let p=new Set(l.map((S)=>String(S.id))),y=I(await mn(a,c)),C=X(y.channels).map(I).filter((S)=>S.is_ext_shared===!0&&!!S.name),F=new Set;for(let S of C)try{for(let k of await ic(a,String(S.id),c))if(!p.has(k))F.add(k)}catch{}for(let S of F)try{let k=I(await bn(a,S,c)),j=I(k.user);if(j.id)l.push(j)}catch{}}let d=l.filter((p)=>p.deleted!==!0&&p.is_bot!==!0&&String(p.id)!=="USLACKBOT").filter((p)=>{if(!f)return!0;let y=String(p.name??"").toLowerCase(),C=String(I(p.profile).real_name??"").toLowerCase(),F=String(I(p.profile).email??"").toLowerCase();return y.includes(f)||C.includes(f)||F.includes(f)}).slice(0,r.limit);if(o==="jsonl"){for(let p of d)console.log(JSON.stringify(p));return}if(o==="yaml"){for(let p of d){let y=function(C,F=""){if(C===null)return"null";if(typeof C==="string")return C.includes(`
|
|
192
195
|
`)?`|
|
|
193
196
|
${C.split(`
|
|
194
197
|
`).join(`
|
|
195
198
|
`)}`:C;if(typeof C!=="object")return String(C);if(Array.isArray(C))return C.map((S)=>`
|
|
196
199
|
${F} - ${y(S,F+" ")}`).join("");return Object.entries(C).map(([S,k])=>`
|
|
197
|
-
${F} ${S}: ${y(k,F+" ")}`).join("")};console.log("---");for(let[C,F]of Object.entries(
|
|
200
|
+
${F} ${S}: ${y(k,F+" ")}`).join("")};console.log("---");for(let[C,F]of Object.entries(p))console.log(`${C}: ${y(F)}`)}return}let h=Intl.DateTimeFormat().resolvedOptions().timeZone,m=d.length?String(I(X(u.members).map(I)[0]??{}).team_id??""):"";for(let p of d){let y=I(p.profile),C=String(p.name??p.id),F=String(p.id??""),S=String(y.display_name||""),k=String(y.real_name||""),j=String(y.email||""),A=String(p.tz??""),R=[...new Set([S,k].filter((O)=>O&&O!==C))].join(" / "),P=A&&A!==h?A:"",q=String(p.team_id??""),_=p.is_stranger===!0||m&&q&&q!==m?`external:${q||"?"}`:p.is_ultra_restricted===!0?"single-channel guest":p.is_restricted===!0?"guest":"",E=[j,P].filter(Boolean).join(" ");console.log(`@${C} ${F} ${R}${E?" "+E:""}${_?` [${_}]`:""}`)}}).command("get <user>","Show user details",(r)=>r.positional("user",{type:"string",demandOption:!0,describe:"@handle or user ID"}),async(r)=>{let o=e(r),a=r.user.startsWith("@")?r.user.slice(1):r.user,c=a;if(!/^U[A-Z0-9]+$/.test(a)){let A=await Mi(o,t(r)),M=X(A.members).map(I).find((R)=>String(R.name??"")===a);if(!M)console.error(`User not found: @${a}`),process.exit(1);c=String(M.id)}let u=I(await bn(o,c)),f=I(u.user),l=I(f.profile),d=Intl.DateTimeFormat().resolvedOptions().timeZone,h=String(f.name??c),m=String(f.id??c),p=String(l.display_name||""),y=String(l.real_name||""),C=String(l.email||""),F=String(f.tz??""),S=String(l.phone||""),k=String(l.title||"");console.log(`@${h} ${m}`);let j=[...new Set([p,y].filter((A)=>A&&A!==h))];if(j.length)console.log(`name: ${j.join(" / ")}`);if(C)console.log(`email: ${C}`);if(S)console.log(`phone: ${S}`);if(k)console.log(`title: ${k}`);if(F&&F!==d)console.log(`tz: ${F}`)}).demandCommand(1,"").showHelpOnFail(!0)).command("news","Activity feed (mentions to you)",(s)=>s.option("limit",{alias:"l",type:"number",default:20}),async(s)=>{await Bf(e(s),s.limit)}).command("search <query>","Full-text search",(s)=>s.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(s)=>{await Lc(e(s),s.query,s.count,s.json,t(s))}).command("send <target> <message>","Send a message (confirm-hash safety gate)",(s)=>s.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(s)=>{let r={target:s.target,message:s.message};if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];if(s["user-id"])r.userId=s["user-id"];if(s.broadcast)r.broadcast=!0;if(s.mentions!==!1){r.mentions=!0,r.mentionToken=e(s);let a=t(s);if(a)r.mentionCookie=a}let o;if(s["as-bot"]){let a=Ht();if(!a)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
|
|
198
201
|
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);if(!r.channelId&&!r.userId&&r.target.startsWith("@"))try{r.userId=await Dn(e(s),r.target,t(s))}catch(c){console.error(`Error: could not resolve ${r.target} to a user for the bot DM.
|
|
199
202
|
${c instanceof Error?c.message:String(c)}
|
|
200
|
-
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}o=a,r.asBot=!0}else{o=e(s);let a=t(s);if(a)r.cookie=a}try{await
|
|
201
|
-
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(Ce);l=
|
|
203
|
+
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}o=a,r.asBot=!0}else{o=e(s);let a=t(s);if(a)r.cookie=a}try{await Qf(o,r)}catch(a){console.error(nt(a)),process.exit(1)}}).command("ask [target] [question] [choices..]","Ask a question with its choices pre-seeded as 1\uFE0F\u20E3..\uD83D\uDD1F reactions (confirm-hash safety gate)",(s)=>s.positional("target",{type:"string",describe:"#chan, @user, #chan:thread_ts, or permalink (omit with --waitFor)"}).positional("question",{type:"string",describe:"The question. Must @tag whoever may answer (@alice), or the whole channel (@here / @channel / @everyone) \u2014 only their answer counts. In a 1:1 DM the other party counts automatically."}).positional("choices",{type:"string",array:!0,describe:"Up to 10 choices, seeded as 1\uFE0F\u20E3..\uD83D\uDD1F reactions. Beyond 10 they are listed but answerable only by text. With none, the question asks for a free-text reply."}).option("code",{type:"string",describe:"Safety hash to confirm the ask"}).option("body",{type:"string",describe:"Extra context shown under the question"}).option("wait",{type:"boolean",default:!1,describe:"Block until answered; print ONLY the answer on stdout. Exit 0 = answered, 2 = timed out, 3 = transport failure."}).option("waitFor",{type:"string",describe:"Collect the answer to a question already posted: pass its permalink. Nothing is posted. Same stdout/exit contract as --wait; --timeout 0 checks once and exits 2 if still open."}).option("timeout",{type:"number",default:3600,describe:"Overall limit for --wait / --waitFor, in seconds (0 with --waitFor = check once)"}).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:"Ask via the bot token (xoxb / SLACK_BOT_TOKEN) so a DM notifies the recipient"}),async(s)=>{let r=s.waitFor?String(s.waitFor):"",o=Number(s.timeout);if(!Number.isFinite(o)||o<0||o===0&&!r)console.error("Error: --timeout must be a positive number of seconds"),process.exit(Ce);if(r){if(s.target||s.question||s.choices?.length)console.error("Error: --waitFor collects an existing question \u2014 do not also pass a target/question/choices."),process.exit(Ce);let l,d;if(s["as-bot"]){let h=Ht();if(!h)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
|
|
204
|
+
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(Ce);l=h}else l=e(s),d=t(s);try{let h={link:r,timeout:o,asBot:!!s["as-bot"]};if(d)h.cookie=d;await cd(l,h)}catch(h){console.error(nt(h)),process.exit(Ce)}return}if(!s.target)console.error("Error: target is required (or use --waitFor <permalink> to collect an answer)"),process.exit(Ce);let a=String(s.question??"").trim();if(!a)console.error("Error: question is empty"),process.exit(Ce);let c={target:s.target,question:a,choices:(s.choices??[]).map((l)=>String(l).trim()).filter(Boolean),timeout:o};if(s.code)c.code=s.code;if(s.body)c.body=s.body;if(s.wait)c.wait=!0;if(s["channel-id"])c.channelId=s["channel-id"];if(s["user-id"])c.userId=s["user-id"];c.mentionToken=e(s);let u=t(s);if(u)c.mentionCookie=u;let f;if(s["as-bot"]){let l=Ht();if(!l)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
|
|
202
205
|
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(Ce);if(!c.channelId&&!c.userId&&c.target.startsWith("@"))try{c.userId=await Dn(e(s),c.target,t(s))}catch(d){console.error(`Error: could not resolve ${c.target} to a user for the bot DM.
|
|
203
206
|
${d instanceof Error?d.message:String(d)}
|
|
204
|
-
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(Ce)}f=l,c.asBot=!0}else{f=e(s);let l=t(s);if(l)c.cookie=l}try{await
|
|
205
|
-
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(ve);return d};if(r){if(s.target||s.question||s.choices?.length)console.error("Error: --results/--close reads an existing poll \u2014 do not also pass a target/question/choices."),process.exit(ve);let d=e(s),
|
|
206
|
-
${
|
|
207
|
-
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(ve)}l=d,u.asBot=!0}else{l=e(s);let d=t(s);if(d)u.cookie=d}try{await
|
|
208
|
-
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await ud(s)}).command("schedule","Manage scheduled messages",(s)=>s.command("send <target> <message>","Schedule a message for later delivery",(r)=>r.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(r)=>{let o={target:r.target,message:r.message,at:r.at};if(r.code)o.code=r.code;if(r["channel-id"])o.channelId=r["channel-id"];if(r["user-id"])o.userId=r["user-id"];let a=t(r);if(a)o.cookie=a;await dd(e(r),o)}).command(["ls","list"],"List pending scheduled messages",(r)=>r.positional("target",{type:"string",describe:"#channel to filter by"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{await pd(e(r),r.target,r["channel-id"],t(r))}).command("rm <target> <id>","Delete a scheduled message",(r)=>r.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(r)=>{let o={target:r.target,id:r.id};if(r.code)o.code=r.code;let a=t(r);if(a)o.cookie=a;if(r["channel-id"])o.channelId=r["channel-id"];await hd(e(r),o)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("edit <target> <newText>","Edit a sent message",(s)=>s.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(s)=>{let r={target:s.target,newText:s.newText};if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];if(s.mentions!==!1)r.mentions=!0;let o=t(s);if(o)r.cookie=o;await Hf(e(s),r)}).command("delete <target>","Delete a sent message (confirm-hash safety gate)",(s)=>s.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(s)=>{let r={target:s.target};if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];let o=t(s);if(o)r.cookie=o;await qf(e(s),r)}).command("react <target> <emoji>","Add (or --remove) an emoji reaction \u2014 a lightweight ack that doesn't grow the thread",(s)=>s.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(s)=>{let r={target:s.target,emoji:s.emoji};if(s.remove)r.remove=!0;if(s["channel-id"])r.channelId=s["channel-id"];let o=t(s);if(o)r.cookie=o;try{await Yf(e(s),r)}catch(a){console.error(nt(a)),process.exit(1)}}).command("todo","Reaction-backed task tracking (:pushpin: marks a task, progress lives in a second reaction)",(s)=>s.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((r)=>{if(r.cache===!1)Ui(!1)}).command(["ls","list"],"List everyone's tasks (has: \u2014 read-only, one search per run)",(r)=>r.options(n).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(r)=>{await i(r,!1)}).command("set <target> <state>","Move a task to a progress state (adds the new reaction before removing the old one)",(r)=>r.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(r)=>{let o={target:r.target,state:r.state};if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;try{await Bf(e(r),o)}catch(c){console.error(nt(c)),process.exit(1)}}).command("flag <target> <flag>","Add (or --remove) a reason flag (alert | needs-discussion | waiting | blocked) \u2014 flags stack, independent of progress",(r)=>r.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(r)=>{let o={target:r.target,flag:r.flag};if(r.remove)o.remove=!0;if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;try{await Nf(e(r),o)}catch(c){console.error(nt(c)),process.exit(1)}}).command("doctor","Find messages carrying two or more progress reactions (--fix repairs them)",(r)=>r.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:Wi,describe:"Max messages to scan"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{let o={channel:r.in,limit:r.limit};if(r.fix)o.fix=!0;if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;await vf(e(r),o)}).demandCommand(1,"Specify a todo subcommand (ls, set, flag, doctor)"),()=>{}).command("mytodo","Tasks carrying YOUR reactions (hasmy:) \u2014 the my-only half of `todo`",(s)=>s.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((r)=>{if(r.cache===!1)Ui(!1)}).command(["ls","list"],"List tasks you have reacted to (hasmy: \u2014 read-only, one search per run)",(r)=>r.options(n),async(r)=>{await i(r,!0)}).demandCommand(1,"Specify a mytodo subcommand (ls)"),()=>{}).command("upload <target> <file..>","Upload one or more files to a channel or DM",(s)=>s.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(s)=>{let r={target:s.target,filePaths:s.file};if(s.title)r.title=s.title;if(s.comment)r.comment=s.comment;if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];if(s["user-id"])r.userId=s["user-id"];let o=t(s);if(o)r.cookie=o;await gd(e(s),r)}).command("files","File commands",(s)=>s.command(["ls","list"],"List files visible to you (files.list)",(r)=>r.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(r)=>{let o={limit:r.limit,format:r.json?"jsonl":r.format};if(r.type)o.types=r.type;if(r.channel)o.channel=r.channel;if(r.user)o.user=r.user;await md(e(r),t(r),o)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("lists <ref>","Read a Slack List's rows (by list URL or F-id) \u2014 read-only",(s)=>s.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(s)=>{let r=s.json?"jsonl":s.format;try{await wd(e(s),t(s),s.ref,{limit:s.limit,format:r})}catch(o){console.error(nt(o)),process.exit(1)}}).command("download <ref> [dest]","Download a file attachment (by file ID or file permalink) to disk",(s)=>s.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(s)=>{await Fd(e(s),t(s),s.ref,s.dest)}).command("dump","Bulk export channel history as markdown",(s)=>s.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(s)=>{await jf(e(s),s.days,s.limit,s.filter)}).command("drafts","Manage message drafts (requires xoxc desktop token)",(s)=>s.command(["$0","ls","list"],"List pending drafts",(r)=>r.option("all",{alias:"a",type:"boolean",default:!1,describe:"Include sent drafts"}),async(r)=>{await Wf(e(r),t(r),r.all)}).command(["new <channel> [text..]","save <channel> [text..]"],"Create a draft",(r)=>r.positional("channel",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}),async(r)=>{let o=e(r),a=t(r),c=r.text.join(" ");if(!c)console.error("Usage: slack drafts new <#channel|@user> <text>"),process.exit(2);let u=await De(o,r.channel,a),f=await nc(o,u,c,a);console.log(`\u2713 Draft created (id: ${P(f.draft).id??"?"})`)}).command("get <id>","Show a draft",(r)=>r.positional("id",{type:"string",demandOption:!0}),async(r)=>{await Uf(e(r),t(r),r.id)}).command(["edit <id> [text..]","update <id> [text..]"],"Edit a draft",(r)=>r.positional("id",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}).option("code",{type:"string"}),async(r)=>{let o=e(r),a=t(r),c=r.text.join(" ");if(!c)console.error("Usage: slack drafts edit <id> <new-text>"),process.exit(2);let u=await wn(o,a),f=X(u.drafts).map(P).find((h)=>String(h.id)===r.id);if(!f)console.error(`Draft not found: ${r.id}`),process.exit(1);let l=Ds(f),d=await Qt(o,a),p=qe(l,c,d?.userId??"");if(r.code!==p)je(r.code,p,["--- Editing draft as -------------------------",Le(d),"--- Current draft ----------------------------",...l.split(`
|
|
209
|
-
`).map((
|
|
210
|
-
`).map((
|
|
211
|
-
`).map((
|
|
207
|
+
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(Ce)}f=l,c.asBot=!0}else{f=e(s);let l=t(s);if(l)c.cookie=l}try{await ad(f,c)}catch(l){console.error(nt(l)),process.exit(Ce)}}).command(["poll [target] [question] [choices..]","vote [target] [question] [choices..]"],"Post a poll with its choices pre-seeded as 1\uFE0F\u20E3..\uD83D\uDD1F reactions, then count them (confirm-hash safety gate)",(s)=>s.positional("target",{type:"string",describe:"#chan, @user, #chan:thread_ts, or permalink (omit with --results/--close)"}).positional("question",{type:"string",describe:"The question. @tags are optional here \u2014 unlike `ask`, a poll needs no addressee: anyone who can see it may vote."}).positional("choices",{type:"string",array:!0,describe:"2..10 choices, seeded as 1\uFE0F\u20E3..\uD83D\uDD1F reactions for voters to click"}).option("multi",{type:"boolean",default:!1,describe:"Let one person pick several choices (default: 1 \u4EBA 1 \u7968)"}).option("until",{type:"string",describe:"Deadline shown in the message (display only \u2014 closing is still `--close`)"}).option("results",{type:"string",describe:"Count an existing poll: pass its permalink. Posts nothing; only edit is the invalid-ballot notice in the poll itself (--no-notify to suppress)."}).option("close",{type:"string",describe:"Count an existing poll AND freeze the tally into the message. Only the poster can do this."}).option("names",{type:"boolean",default:!1,describe:"Also list who voted for what (stderr)"}).option("no-notify",{type:"boolean",default:!1,describe:"With --results: do not write the invalid-ballot notice back into the message (keeps it strictly read-only)"}).option("code",{type:"string",describe:"Safety hash to confirm the post"}).option("body",{type:"string",describe:"Extra context shown under the question"}).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:"Post via the bot token (xoxb / SLACK_BOT_TOKEN) so a DM notifies the recipient \u2014 and so YOUR OWN vote counts, since the seeds are then the bot's"}),async(s)=>{let r=s.close?String(s.close):s.results?String(s.results):"";if(s.results&&s.close)console.error("Error: pass --results or --close, not both (--close counts as well)."),process.exit(ve);let o=()=>{let d=Ht();if(!d)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
|
|
208
|
+
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(ve);return d};if(r){if(s.target||s.question||s.choices?.length)console.error("Error: --results/--close reads an existing poll \u2014 do not also pass a target/question/choices."),process.exit(ve);let d=e(s),h=t(s);try{let m={link:r};if(s.close)m.close=!0;if(s.names)m.names=!0;if(s["no-notify"])m.noNotify=!0;if(h)m.cookie=h;if(s["as-bot"])m.writeToken=o();await dd(d,m)}catch(m){console.error(nt(m)),process.exit(ve)}return}if(!s.target)console.error("Error: target is required (or use --results <permalink> to count a poll)"),process.exit(ve);let a=String(s.question??"").trim();if(!a)console.error("Error: question is empty"),process.exit(ve);let c=(s.choices??[]).map((d)=>String(d).trim()).filter(Boolean);if(c.length<2||c.length>Yt)console.error(`Error: poll needs 2..${Yt} choices (got ${c.length}). For a free-text question use \`slack ask\`.`),process.exit(ve);let u={target:s.target,question:a,choices:c};if(s.multi)u.multi=!0;if(s.until)u.until=String(s.until);if(s.code)u.code=s.code;if(s.body)u.body=s.body;if(s["channel-id"])u.channelId=s["channel-id"];if(s["user-id"])u.userId=s["user-id"];u.mentionToken=e(s);let f=t(s);if(f)u.mentionCookie=f;let l;if(s["as-bot"]){let d=o();if(!u.channelId&&!u.userId&&u.target.startsWith("@"))try{u.userId=await Dn(e(s),u.target,t(s))}catch(h){console.error(`Error: could not resolve ${u.target} to a user for the bot DM.
|
|
209
|
+
${h instanceof Error?h.message:String(h)}
|
|
210
|
+
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(ve)}l=d,u.asBot=!0}else{l=e(s);let d=t(s);if(d)u.cookie=d}try{await ld(l,u)}catch(d){console.error(nt(d)),process.exit(ve)}}).command("doctor","Check the bot token (xoxb) can carry a two-way DM (scopes + Messages Tab)",(s)=>s,async()=>{let s=Ht();if(!s)console.error(`Error: slack doctor checks the bot token, but no xoxb- token was found.
|
|
211
|
+
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await pd(s)}).command("schedule","Manage scheduled messages",(s)=>s.command("send <target> <message>","Schedule a message for later delivery",(r)=>r.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(r)=>{let o={target:r.target,message:r.message,at:r.at};if(r.code)o.code=r.code;if(r["channel-id"])o.channelId=r["channel-id"];if(r["user-id"])o.userId=r["user-id"];let a=t(r);if(a)o.cookie=a;await md(e(r),o)}).command(["ls","list"],"List pending scheduled messages",(r)=>r.positional("target",{type:"string",describe:"#channel to filter by"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{await Dd(e(r),r.target,r["channel-id"],t(r))}).command("rm <target> <id>","Delete a scheduled message",(r)=>r.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(r)=>{let o={target:r.target,id:r.id};if(r.code)o.code=r.code;let a=t(r);if(a)o.cookie=a;if(r["channel-id"])o.channelId=r["channel-id"];await yd(e(r),o)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("edit <target> <newText>","Edit a sent message",(s)=>s.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(s)=>{let r={target:s.target,newText:s.newText};if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];if(s.mentions!==!1)r.mentions=!0;let o=t(s);if(o)r.cookie=o;await Gf(e(s),r)}).command("delete <target>","Delete a sent message (confirm-hash safety gate)",(s)=>s.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(s)=>{let r={target:s.target};if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];let o=t(s);if(o)r.cookie=o;await Vf(e(s),r)}).command("react <target> <emoji>","Add (or --remove) an emoji reaction \u2014 a lightweight ack that doesn't grow the thread",(s)=>s.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(s)=>{let r={target:s.target,emoji:s.emoji};if(s.remove)r.remove=!0;if(s["channel-id"])r.channelId=s["channel-id"];let o=t(s);if(o)r.cookie=o;try{await Zf(e(s),r)}catch(a){console.error(nt(a)),process.exit(1)}}).command("todo","Reaction-backed task tracking (:pushpin: marks a task, progress lives in a second reaction)",(s)=>s.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((r)=>{if(r.cache===!1)Ui(!1)}).command(["ls","list"],"List everyone's tasks (has: \u2014 read-only, one search per run)",(r)=>r.options(n).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(r)=>{await i(r,!1)}).command("set <target> <state>","Move a task to a progress state (adds the new reaction before removing the old one)",(r)=>r.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(r)=>{let o={target:r.target,state:r.state};if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;try{await Lf(e(r),o)}catch(c){console.error(nt(c)),process.exit(1)}}).command("flag <target> <flag>","Add (or --remove) a reason flag (alert | needs-discussion | waiting | blocked) \u2014 flags stack, independent of progress",(r)=>r.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(r)=>{let o={target:r.target,flag:r.flag};if(r.remove)o.remove=!0;if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;try{await Wf(e(r),o)}catch(c){console.error(nt(c)),process.exit(1)}}).command("doctor","Find messages carrying two or more progress reactions (--fix repairs them)",(r)=>r.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:Wi,describe:"Max messages to scan"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{let o={channel:r.in,limit:r.limit};if(r.fix)o.fix=!0;if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;await Uf(e(r),o)}).demandCommand(1,"Specify a todo subcommand (ls, set, flag, doctor)"),()=>{}).command("mytodo","Tasks carrying YOUR reactions (hasmy:) \u2014 the my-only half of `todo`",(s)=>s.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((r)=>{if(r.cache===!1)Ui(!1)}).command(["ls","list"],"List tasks you have reacted to (hasmy: \u2014 read-only, one search per run)",(r)=>r.options(n),async(r)=>{await i(r,!0)}).demandCommand(1,"Specify a mytodo subcommand (ls)"),()=>{}).command("upload <target> <file..>","Upload one or more files to a channel or DM",(s)=>s.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(s)=>{let r={target:s.target,filePaths:s.file};if(s.title)r.title=s.title;if(s.comment)r.comment=s.comment;if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];if(s["user-id"])r.userId=s["user-id"];let o=t(s);if(o)r.cookie=o;await wd(e(s),r)}).command("files","File commands",(s)=>s.command(["ls","list"],"List files visible to you (files.list)",(r)=>r.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(r)=>{let o={limit:r.limit,format:r.json?"jsonl":r.format};if(r.type)o.types=r.type;if(r.channel)o.channel=r.channel;if(r.user)o.user=r.user;await bd(e(r),t(r),o)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("lists <ref>","Read a Slack List's rows (by list URL or F-id) \u2014 read-only",(s)=>s.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(s)=>{let r=s.json?"jsonl":s.format;try{await Ed(e(s),t(s),s.ref,{limit:s.limit,format:r})}catch(o){console.error(nt(o)),process.exit(1)}}).command("download <ref> [dest]","Download a file attachment (by file ID or file permalink) to disk",(s)=>s.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(s)=>{await _d(e(s),t(s),s.ref,s.dest)}).command("dump","Bulk export channel history as markdown",(s)=>s.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(s)=>{await Kf(e(s),s.days,s.limit,s.filter)}).command("drafts","Manage message drafts (requires xoxc desktop token)",(s)=>s.command(["$0","ls","list"],"List pending drafts",(r)=>r.option("all",{alias:"a",type:"boolean",default:!1,describe:"Include sent drafts"}),async(r)=>{await zf(e(r),t(r),r.all)}).command(["new <channel> [text..]","save <channel> [text..]"],"Create a draft",(r)=>r.positional("channel",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}),async(r)=>{let o=e(r),a=t(r),c=r.text.join(" ");if(!c)console.error("Usage: slack drafts new <#channel|@user> <text>"),process.exit(2);let u=await De(o,r.channel,a),f=await rc(o,u,c,a);console.log(`\u2713 Draft created (id: ${I(f.draft).id??"?"})`)}).command("get <id>","Show a draft",(r)=>r.positional("id",{type:"string",demandOption:!0}),async(r)=>{await Hf(e(r),t(r),r.id)}).command(["edit <id> [text..]","update <id> [text..]"],"Edit a draft",(r)=>r.positional("id",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}).option("code",{type:"string"}),async(r)=>{let o=e(r),a=t(r),c=r.text.join(" ");if(!c)console.error("Usage: slack drafts edit <id> <new-text>"),process.exit(2);let u=await wn(o,a),f=X(u.drafts).map(I).find((p)=>String(p.id)===r.id);if(!f)console.error(`Draft not found: ${r.id}`),process.exit(1);let l=ys(f),d=await Qt(o,a),h=qe(l,c,d?.userId??"");if(r.code!==h)je(r.code,h,["--- Editing draft as -------------------------",Le(d),"--- Current draft ----------------------------",...l.split(`
|
|
212
|
+
`).map((p)=>` ${p}`),"--- Replacing with ---------------------------",...c.split(`
|
|
213
|
+
`).map((p)=>` ${p}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let m=await oc(o,r.id,Gi(f),c,a);console.log(`\u2713 Draft updated (id: ${I(m.draft).id??"?"})`)}).command(["delete <id>","rm <id>"],"Delete a draft",(r)=>r.positional("id",{type:"string",demandOption:!0}).option("code",{type:"string"}),async(r)=>{let o=e(r),a=t(r),c=await wn(o,a),u=X(c.drafts).map(I).find((h)=>String(h.id)===r.id);if(!u)console.error(`Draft not found: ${r.id}`),process.exit(1);let f=ys(u),l=await Qt(o,a),d=qe(r.id,f,l?.userId??"");if(r.code!==d)je(r.code,d,["\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",Le(l),` id: ${r.id}`,...f.split(`
|
|
214
|
+
`).map((h)=>` ${h}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await cc(o,r.id,a),console.log(`\u2713 Draft deleted (id: ${r.id})`)})).command("auth","Authentication and workspace management",(s)=>s.command("token","Add a workspace \u2014 paste an existing xoxp-/xoxb- token",(r)=>r.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(r)=>{await ya({...r.token!==void 0?{token:r.token}:{},...r.name!==void 0?{name:r.name}:{}})}).command("app","Create a new Slack app and obtain a token (guided wizard)",(r)=>r.option("bot",{type:"boolean",describe:"Create a bot token (xoxb-) instead of user (xoxp-)"}),async(r)=>{await wa({...r.bot!==void 0?{bot:r.bot}:{}})}).command("login","Interactive auth wizard (all auth methods: desktop app, token, new app)",(r)=>r.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(r)=>{await ns({...r.token!==void 0?{token:r.token}:{},...r.name!==void 0?{name:r.name}:{}})}).command(["ls","status"],"Show auth status",()=>{},()=>{let r=ai();if(r.length===0){console.log("No workspaces configured. Run: slack auth login");return}for(let{name:o,profile:a,current:c}of r)console.log(`${c?"* ":" "}${o} ${a.team} (${a.user}) ${a.url??""}`)}).command("use <name>","Switch active workspace",(r)=>r.positional("name",{type:"string",demandOption:!0}).option("g",{type:"boolean",default:!1,describe:"Write global lockfile (~/.slack-cli/workspace)"}),(r)=>{if(!r.g)kf(pt(process.cwd(),".slack-cli"));Lo(r.name,r.g),console.log(`Switched to workspace "${r.name}" ${r.g?"globally":"locally"}`)}).command(["logout <name>","rm <name>","remove <name>"],"Remove a workspace",(r)=>r.positional("name",{type:"string",demandOption:!0}),(r)=>{jo(r.name),console.log(`Removed workspace "${r.name}"`)}).command(["chrome","cookie"],"Attach Chrome browser xoxd cookie to a workspace (macOS, interactive)",(r)=>r.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(r)=>{await ma({...r.workspace!==void 0?{workspace:r.workspace}:{}})}).command("firefox","Attach Firefox browser xoxd cookie to a workspace (all platforms)",(r)=>r.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(r)=>{await Da({...r.workspace!==void 0?{workspace:r.workspace}:{}})}).command("$0",!1,()=>{},()=>{s.showHelp(),process.exit(0)})).command("tail [target]","Stream new messages in real time (like tail -f)",(s)=>s.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(s)=>{let r=e(s),o=t(s),a=new AbortController;process.on("SIGINT",()=>{a.abort(),process.exit(0)}),await Sa(r,s.target,{...s.since!==void 0?{since:s.since}:{},...s.thread!==void 0?{thread:s.thread}:{},...s["watch-thread"]!==void 0?{watchThread:s["watch-thread"]}:{},me:s.me,interval:s.interval,...s.timeout!==void 0?{timeout:s.timeout}:{},...s["exit-on-message"]===!0?{exitOnMessage:!0}:{},...o!==void 0?{cookie:o}:{},...s.rtm===!1?{noRtm:!0}:{}},a.signal)}).command("login",!1,(s)=>s.option("token",{type:"string"}).option("name",{type:"string"}),async(s)=>{await ns({...s.token!==void 0?{token:s.token}:{},...s.name!==void 0?{name:s.name}:{}})}).demandCommand(1,"Specify a command. Run with --help for usage.").strict().help().alias("help","h").parseAsync()}Sd().catch((e)=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)});
|