slack-term 1.21.0 → 1.21.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 CHANGED
@@ -2,20 +2,20 @@
2
2
  // @bun
3
3
  import{createRequire as G3}from"node:module";var D3=Object.create;var{getPrototypeOf:u3,defineProperty:g0,getOwnPropertyNames:F3}=Object;var E3=Object.prototype.hasOwnProperty;function C3(D){return this[D]}var B3,$3,k0=(D,u,F)=>{var E=D!=null&&typeof D==="object";if(E){var C=u?B3??=new WeakMap:$3??=new WeakMap,B=C.get(D);if(B)return B}F=D!=null?D3(u3(D)):{};let $=u||!D||!D.__esModule?g0(F,"default",{value:D,enumerable:!0}):F;for(let G of F3(D))if(!E3.call($,G))g0($,G,{get:C3.bind(D,G),enumerable:!0});if(E)C.set(D,$);return $};var d0=(D,u)=>()=>(u||D((u={exports:{}}).exports,u),u.exports);var wD=G3(import.meta.url);var z2=d0((J9,G2)=>{G2.exports=()=>{return/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g}});var b2=d0((a9,I2)=>{I2.exports=function(u){if(u===void 0)u=2;if(u>=Error.stackTraceLimit)throw TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+u+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");var F=Error.prepareStackTrace;Error.prepareStackTrace=function(C,B){return B};var E=Error().stack;if(Error.prepareStackTrace=F,E!==null&&typeof E==="object")return E[u]?E[u].getFileName():void 0}});import{createHash as Z7}from"crypto";import{existsSync as t1,readFileSync as J7,mkdirSync as X7,writeFileSync as o1}from"fs";import{homedir as d1}from"os";import{join as tD}from"path";import{notStrictEqual as n3,strictEqual as l3}from"assert";var z3={right:X3,center:Q3};class n0{constructor(D){var u;this.width=D.width,this.wrap=(u=D.wrap)!==null&&u!==void 0?u:!0,this.rows=[]}span(...D){let u=this.div(...D);u.span=!0}resetOutput(){this.rows=[]}div(...D){if(D.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...D)&&typeof D[0]==="string")return this.applyLayoutDSL(D[0]);let u=D.map((F)=>{if(typeof F==="string")return this.colFromString(F);return F});return this.rows.push(u),u}shouldApplyLayoutDSL(...D){return D.length===1&&typeof D[0]==="string"&&/[\t\n]/.test(D[0])}applyLayoutDSL(D){let u=D.split(`
4
4
  `).map((E)=>E.split("\t")),F=0;return u.forEach((E)=>{if(E.length>1&&HD.stringWidth(E[0])>F)F=Math.min(Math.floor(this.width*0.5),HD.stringWidth(E[0]))}),u.forEach((E)=>{this.div(...E.map((C,B)=>{return{text:C.trim(),padding:this.measurePadding(C),width:B===0&&E.length>1?F:void 0}}))}),this.rows[this.rows.length-1]}colFromString(D){return{text:D,padding:this.measurePadding(D)}}measurePadding(D){let u=HD.stripAnsi(D);return[0,u.match(/\s*$/)[0].length,0,u.match(/^\s*/)[0].length]}toString(){let D=[];return this.rows.forEach((u)=>{this.rowToString(u,D)}),D.filter((u)=>!u.hidden).map((u)=>u.text).join(`
5
- `)}rowToString(D,u){return this.rasterize(D).forEach((F,E)=>{let C="";F.forEach((B,$)=>{let{width:G}=D[$],Z=this.negatePadding(D[$]),z=B;if(Z>HD.stringWidth(B))z+=" ".repeat(Z-HD.stringWidth(B));if(D[$].align&&D[$].align!=="left"&&this.wrap){let J=z3[D[$].align];if(z=J(z,Z),HD.stringWidth(z)<Z)z+=" ".repeat((G||0)-HD.stringWidth(z)-1)}let Y=D[$].padding||[0,0,0,0];if(Y[3])C+=" ".repeat(Y[3]);if(C+=i0(D[$],z,"| "),C+=z,C+=i0(D[$],z," |"),Y[1])C+=" ".repeat(Y[1]);if(E===0&&u.length>0)C=this.renderInline(C,u[u.length-1])}),u.push({text:C.replace(/ +$/,""),span:D.span})}),u}renderInline(D,u){let F=D.match(/^ */),E=F?F[0].length:0,C=u.text,B=HD.stringWidth(C.trimRight());if(!u.span)return D;if(!this.wrap)return u.hidden=!0,C+D;if(E<B)return D;return u.hidden=!0,C.trimRight()+" ".repeat(E-B)+D.trimLeft()}rasterize(D){let u=[],F=this.columnWidths(D),E;return D.forEach((C,B)=>{if(C.width=F[B],this.wrap)E=HD.wrap(C.text,this.negatePadding(C),{hard:!0}).split(`
5
+ `)}rowToString(D,u){return this.rasterize(D).forEach((F,E)=>{let C="";F.forEach((B,$)=>{let{width:G}=D[$],z=this.negatePadding(D[$]),Z=B;if(z>HD.stringWidth(B))Z+=" ".repeat(z-HD.stringWidth(B));if(D[$].align&&D[$].align!=="left"&&this.wrap){let J=z3[D[$].align];if(Z=J(Z,z),HD.stringWidth(Z)<z)Z+=" ".repeat((G||0)-HD.stringWidth(Z)-1)}let Y=D[$].padding||[0,0,0,0];if(Y[3])C+=" ".repeat(Y[3]);if(C+=i0(D[$],Z,"| "),C+=Z,C+=i0(D[$],Z," |"),Y[1])C+=" ".repeat(Y[1]);if(E===0&&u.length>0)C=this.renderInline(C,u[u.length-1])}),u.push({text:C.replace(/ +$/,""),span:D.span})}),u}renderInline(D,u){let F=D.match(/^ */),E=F?F[0].length:0,C=u.text,B=HD.stringWidth(C.trimRight());if(!u.span)return D;if(!this.wrap)return u.hidden=!0,C+D;if(E<B)return D;return u.hidden=!0,C.trimRight()+" ".repeat(E-B)+D.trimLeft()}rasterize(D){let u=[],F=this.columnWidths(D),E;return D.forEach((C,B)=>{if(C.width=F[B],this.wrap)E=HD.wrap(C.text,this.negatePadding(C),{hard:!0}).split(`
6
6
  `);else E=C.text.split(`
7
- `);if(C.border)E.unshift("."+"-".repeat(this.negatePadding(C)+2)+"."),E.push("'"+"-".repeat(this.negatePadding(C)+2)+"'");if(C.padding)E.unshift(...Array(C.padding[0]||0).fill("")),E.push(...Array(C.padding[2]||0).fill(""));E.forEach(($,G)=>{if(!u[G])u.push([]);let Z=u[G];for(let z=0;z<B;z++)if(Z[z]===void 0)Z.push("");Z.push($)})}),u}negatePadding(D){let u=D.width||0;if(D.padding)u-=(D.padding[3]||0)+(D.padding[1]||0);if(D.border)u-=4;return u}columnWidths(D){if(!this.wrap)return D.map((B)=>{return B.width||HD.stringWidth(B.text)});let u=D.length,F=this.width,E=D.map((B)=>{if(B.width)return u--,F-=B.width,B.width;return}),C=u?Math.floor(F/u):0;return E.map((B,$)=>{if(B===void 0)return Math.max(C,Z3(D[$]));return B})}}function i0(D,u,F){if(D.border){if(/[.']-+[.']/.test(u))return"";if(u.trim().length!==0)return F;return" "}return""}function Z3(D){let u=D.padding||[],F=1+(u[3]||0)+(u[1]||0);if(D.border)return F+4;return F}function J3(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function X3(D,u){D=D.trim();let F=HD.stringWidth(D);if(F<u)return" ".repeat(u-F)+D;return D}function Q3(D,u){D=D.trim();let F=HD.stringWidth(D);if(F>=u)return D;return" ".repeat(u-F>>1)+D}var HD;function l0(D,u){return HD=u,new n0({width:(D===null||D===void 0?void 0:D.width)||J3(),wrap:D===null||D===void 0?void 0:D.wrap})}function RF({onlyFirst:D=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",D?void 0:"g")}var Y3=RF();function sD(D){if(typeof D!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof D}\``);if(!D.includes("\x1B")&&!D.includes("›"))return D;return D.replace(Y3,"")}var t0=161,o0=1114109,s0=[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],r0=12288,a0=65510,e0=[12288,12288,65281,65376,65504,65510];var D2=4352,u2=262141,SF=[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 du=(D,u)=>{let F=0,E=Math.floor(D.length/2)-1;while(F<=E){let C=Math.floor((F+E)/2),B=C*2;if(u<D[B])E=C-1;else if(u>D[B+1])F=C+1;else return!0}return!1};var F2=19968,[W3,O3]=V3(SF);function V3(D){let u=D[0],F=D[1];for(let E=0;E<D.length;E+=2){let C=D[E],B=D[E+1];if(F2>=C&&F2<=B)return[C,B];if(B-C>F-u)u=C,F=B}return[u,F]}var E2=(D)=>{if(D<t0||D>o0)return!1;return du(s0,D)},C2=(D)=>{if(D<r0||D>a0)return!1;return du(e0,D)};var B2=(D)=>{if(D>=W3&&D<=O3)return!0;if(D<D2||D>u2)return!1;return du(SF,D)};function H3(D){if(!Number.isSafeInteger(D))throw TypeError(`Expected a code point, got \`${typeof D}\`.`)}function $2(D,{ambiguousAsWide:u=!1}={}){if(H3(D),C2(D)||B2(D)||u&&E2(D))return 2;return 1}var Z2=k0(z2(),1),q3=new Intl.Segmenter,U3=/^\p{Default_Ignorable_Code_Point}$/u;function TD(D,u={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:F=!0,countAnsiEscapeCodes:E=!1}=u;if(!E)D=sD(D);if(D.length===0)return 0;let C=0,B={ambiguousAsWide:!F};for(let{segment:$}of q3.segment(D)){let G=$.codePointAt(0);if(G<=31||G>=127&&G<=159)continue;if(G>=8203&&G<=8207||G===65279)continue;if(G>=768&&G<=879||G>=6832&&G<=6911||G>=7616&&G<=7679||G>=8400&&G<=8447||G>=65056&&G<=65071)continue;if(G>=55296&&G<=57343)continue;if(G>=65024&&G<=65039)continue;if(U3.test($))continue;if(Z2.default().test($)){C+=2;continue}C+=$2(G,B)}return C}var J2=(D=0)=>(u)=>`\x1B[${u+D}m`,X2=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,Q2=(D=0)=>(u,F,E)=>`\x1B[${38+D};2;${u};${F};${E}m`,a={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]}},W9=Object.keys(a.modifier),M3=Object.keys(a.color),K3=Object.keys(a.bgColor),O9=[...M3,...K3];function _3(){let D=new Map;for(let[u,F]of Object.entries(a)){for(let[E,C]of Object.entries(F))a[E]={open:`\x1B[${C[0]}m`,close:`\x1B[${C[1]}m`},F[E]=a[E],D.set(C[0],C[1]);Object.defineProperty(a,u,{value:F,enumerable:!1})}return Object.defineProperty(a,"codes",{value:D,enumerable:!1}),a.color.close="\x1B[39m",a.bgColor.close="\x1B[49m",a.color.ansi=J2(),a.color.ansi256=X2(),a.color.ansi16m=Q2(),a.bgColor.ansi=J2(10),a.bgColor.ansi256=X2(10),a.bgColor.ansi16m=Q2(10),Object.defineProperties(a,{rgbToAnsi256:{value(u,F,E){if(u===F&&F===E){if(u<8)return 16;if(u>248)return 231;return Math.round((u-8)/247*24)+232}return 16+36*Math.round(u/255*5)+6*Math.round(F/255*5)+Math.round(E/255*5)},enumerable:!1},hexToRgb:{value(u){let F=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!F)return[0,0,0];let[E]=F;if(E.length===3)E=[...E].map((B)=>B+B).join("");let C=Number.parseInt(E,16);return[C>>16&255,C>>8&255,C&255]},enumerable:!1},hexToAnsi256:{value:(u)=>a.rgbToAnsi256(...a.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value(u){if(u<8)return 30+u;if(u<16)return 90+(u-8);let F,E,C;if(u>=232)F=((u-232)*10+8)/255,E=F,C=F;else{u-=16;let G=u%36;F=Math.floor(u/36)/5,E=Math.floor(G/6)/5,C=G%6/5}let B=Math.max(F,E,C)*2;if(B===0)return 30;let $=30+(Math.round(C)<<2|Math.round(E)<<1|Math.round(F));if(B===2)$+=60;return $},enumerable:!1},rgbToAnsi:{value:(u,F,E)=>a.ansi256ToAnsi(a.rgbToAnsi256(u,F,E)),enumerable:!1},hexToAnsi:{value:(u)=>a.ansi256ToAnsi(a.hexToAnsi256(u)),enumerable:!1}}),a}var j3=_3(),Y2=j3;var nu=new Set(["\x1B","›"]),A3=39,wF="\x07",V2="[",L3="]",H2="m",iu=`${L3}8;;`,W2=(D)=>`${nu.values().next().value}${V2}${D}${H2}`,O2=(D)=>`${nu.values().next().value}${iu}${D}${wF}`,N3=(D)=>D.split(" ").map((u)=>TD(u)),PF=(D,u,F)=>{let E=[...u],C=!1,B=!1,$=TD(sD(D.at(-1)));for(let[G,Z]of E.entries()){let z=TD(Z);if($+z<=F)D[D.length-1]+=Z;else D.push(Z),$=0;if(nu.has(Z))C=!0,B=E.slice(G+1,G+1+iu.length).join("")===iu;if(C){if(B){if(Z===wF)C=!1,B=!1}else if(Z===H2)C=!1;continue}if($+=z,$===F&&G<E.length-1)D.push(""),$=0}if(!$&&D.at(-1).length>0&&D.length>1)D[D.length-2]+=D.pop()},T3=(D)=>{let u=D.split(" "),F=u.length;while(F>0){if(TD(u[F-1])>0)break;F--}if(F===u.length)return D;return u.slice(0,F).join(" ")+u.slice(F).join("")},R3=(D,u,F={})=>{if(F.trim!==!1&&D.trim()==="")return"";let E="",C,B,$=N3(D),G=[""];for(let[J,Q]of D.split(" ").entries()){if(F.trim!==!1)G[G.length-1]=G.at(-1).trimStart();let O=TD(G.at(-1));if(J!==0){if(O>=u&&(F.wordWrap===!1||F.trim===!1))G.push(""),O=0;if(O>0||F.trim===!1)G[G.length-1]+=" ",O++}if(F.hard&&$[J]>u){let V=u-O,W=1+Math.floor(($[J]-V-1)/u);if(Math.floor(($[J]-1)/u)<W)G.push("");PF(G,Q,u);continue}if(O+$[J]>u&&O>0&&$[J]>0){if(F.wordWrap===!1&&O<u){PF(G,Q,u);continue}G.push("")}if(O+$[J]>u&&F.wordWrap===!1){PF(G,Q,u);continue}G[G.length-1]+=Q}if(F.trim!==!1)G=G.map((J)=>T3(J));let Z=G.join(`
8
- `),z=[...Z],Y=0;for(let[J,Q]of z.entries()){if(E+=Q,nu.has(Q)){let{groups:V}=new RegExp(`(?:\\${V2}(?<code>\\d+)m|\\${iu}(?<uri>.*)${wF})`).exec(Z.slice(Y))||{groups:{}};if(V.code!==void 0){let W=Number.parseFloat(V.code);C=W===A3?void 0:W}else if(V.uri!==void 0)B=V.uri.length===0?void 0:V.uri}let O=Y2.codes.get(Number(C));if(z[J+1]===`
7
+ `);if(C.border)E.unshift("."+"-".repeat(this.negatePadding(C)+2)+"."),E.push("'"+"-".repeat(this.negatePadding(C)+2)+"'");if(C.padding)E.unshift(...Array(C.padding[0]||0).fill("")),E.push(...Array(C.padding[2]||0).fill(""));E.forEach(($,G)=>{if(!u[G])u.push([]);let z=u[G];for(let Z=0;Z<B;Z++)if(z[Z]===void 0)z.push("");z.push($)})}),u}negatePadding(D){let u=D.width||0;if(D.padding)u-=(D.padding[3]||0)+(D.padding[1]||0);if(D.border)u-=4;return u}columnWidths(D){if(!this.wrap)return D.map((B)=>{return B.width||HD.stringWidth(B.text)});let u=D.length,F=this.width,E=D.map((B)=>{if(B.width)return u--,F-=B.width,B.width;return}),C=u?Math.floor(F/u):0;return E.map((B,$)=>{if(B===void 0)return Math.max(C,Z3(D[$]));return B})}}function i0(D,u,F){if(D.border){if(/[.']-+[.']/.test(u))return"";if(u.trim().length!==0)return F;return" "}return""}function Z3(D){let u=D.padding||[],F=1+(u[3]||0)+(u[1]||0);if(D.border)return F+4;return F}function J3(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function X3(D,u){D=D.trim();let F=HD.stringWidth(D);if(F<u)return" ".repeat(u-F)+D;return D}function Q3(D,u){D=D.trim();let F=HD.stringWidth(D);if(F>=u)return D;return" ".repeat(u-F>>1)+D}var HD;function l0(D,u){return HD=u,new n0({width:(D===null||D===void 0?void 0:D.width)||J3(),wrap:D===null||D===void 0?void 0:D.wrap})}function RF({onlyFirst:D=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",D?void 0:"g")}var Y3=RF();function sD(D){if(typeof D!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof D}\``);if(!D.includes("\x1B")&&!D.includes("›"))return D;return D.replace(Y3,"")}var t0=161,o0=1114109,s0=[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],r0=12288,a0=65510,e0=[12288,12288,65281,65376,65504,65510];var D2=4352,u2=262141,SF=[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 iu=(D,u)=>{let F=0,E=Math.floor(D.length/2)-1;while(F<=E){let C=Math.floor((F+E)/2),B=C*2;if(u<D[B])E=C-1;else if(u>D[B+1])F=C+1;else return!0}return!1};var F2=19968,[W3,O3]=V3(SF);function V3(D){let u=D[0],F=D[1];for(let E=0;E<D.length;E+=2){let C=D[E],B=D[E+1];if(F2>=C&&F2<=B)return[C,B];if(B-C>F-u)u=C,F=B}return[u,F]}var E2=(D)=>{if(D<t0||D>o0)return!1;return iu(s0,D)},C2=(D)=>{if(D<r0||D>a0)return!1;return iu(e0,D)};var B2=(D)=>{if(D>=W3&&D<=O3)return!0;if(D<D2||D>u2)return!1;return iu(SF,D)};function H3(D){if(!Number.isSafeInteger(D))throw TypeError(`Expected a code point, got \`${typeof D}\`.`)}function $2(D,{ambiguousAsWide:u=!1}={}){if(H3(D),C2(D)||B2(D)||u&&E2(D))return 2;return 1}var Z2=k0(z2(),1),q3=new Intl.Segmenter,U3=/^\p{Default_Ignorable_Code_Point}$/u;function TD(D,u={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:F=!0,countAnsiEscapeCodes:E=!1}=u;if(!E)D=sD(D);if(D.length===0)return 0;let C=0,B={ambiguousAsWide:!F};for(let{segment:$}of q3.segment(D)){let G=$.codePointAt(0);if(G<=31||G>=127&&G<=159)continue;if(G>=8203&&G<=8207||G===65279)continue;if(G>=768&&G<=879||G>=6832&&G<=6911||G>=7616&&G<=7679||G>=8400&&G<=8447||G>=65056&&G<=65071)continue;if(G>=55296&&G<=57343)continue;if(G>=65024&&G<=65039)continue;if(U3.test($))continue;if(Z2.default().test($)){C+=2;continue}C+=$2(G,B)}return C}var J2=(D=0)=>(u)=>`\x1B[${u+D}m`,X2=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,Q2=(D=0)=>(u,F,E)=>`\x1B[${38+D};2;${u};${F};${E}m`,a={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]}},W9=Object.keys(a.modifier),M3=Object.keys(a.color),K3=Object.keys(a.bgColor),O9=[...M3,...K3];function _3(){let D=new Map;for(let[u,F]of Object.entries(a)){for(let[E,C]of Object.entries(F))a[E]={open:`\x1B[${C[0]}m`,close:`\x1B[${C[1]}m`},F[E]=a[E],D.set(C[0],C[1]);Object.defineProperty(a,u,{value:F,enumerable:!1})}return Object.defineProperty(a,"codes",{value:D,enumerable:!1}),a.color.close="\x1B[39m",a.bgColor.close="\x1B[49m",a.color.ansi=J2(),a.color.ansi256=X2(),a.color.ansi16m=Q2(),a.bgColor.ansi=J2(10),a.bgColor.ansi256=X2(10),a.bgColor.ansi16m=Q2(10),Object.defineProperties(a,{rgbToAnsi256:{value(u,F,E){if(u===F&&F===E){if(u<8)return 16;if(u>248)return 231;return Math.round((u-8)/247*24)+232}return 16+36*Math.round(u/255*5)+6*Math.round(F/255*5)+Math.round(E/255*5)},enumerable:!1},hexToRgb:{value(u){let F=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!F)return[0,0,0];let[E]=F;if(E.length===3)E=[...E].map((B)=>B+B).join("");let C=Number.parseInt(E,16);return[C>>16&255,C>>8&255,C&255]},enumerable:!1},hexToAnsi256:{value:(u)=>a.rgbToAnsi256(...a.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value(u){if(u<8)return 30+u;if(u<16)return 90+(u-8);let F,E,C;if(u>=232)F=((u-232)*10+8)/255,E=F,C=F;else{u-=16;let G=u%36;F=Math.floor(u/36)/5,E=Math.floor(G/6)/5,C=G%6/5}let B=Math.max(F,E,C)*2;if(B===0)return 30;let $=30+(Math.round(C)<<2|Math.round(E)<<1|Math.round(F));if(B===2)$+=60;return $},enumerable:!1},rgbToAnsi:{value:(u,F,E)=>a.ansi256ToAnsi(a.rgbToAnsi256(u,F,E)),enumerable:!1},hexToAnsi:{value:(u)=>a.ansi256ToAnsi(a.hexToAnsi256(u)),enumerable:!1}}),a}var j3=_3(),Y2=j3;var lu=new Set(["\x1B","›"]),A3=39,wF="\x07",V2="[",L3="]",H2="m",nu=`${L3}8;;`,W2=(D)=>`${lu.values().next().value}${V2}${D}${H2}`,O2=(D)=>`${lu.values().next().value}${nu}${D}${wF}`,N3=(D)=>D.split(" ").map((u)=>TD(u)),PF=(D,u,F)=>{let E=[...u],C=!1,B=!1,$=TD(sD(D.at(-1)));for(let[G,z]of E.entries()){let Z=TD(z);if($+Z<=F)D[D.length-1]+=z;else D.push(z),$=0;if(lu.has(z))C=!0,B=E.slice(G+1,G+1+nu.length).join("")===nu;if(C){if(B){if(z===wF)C=!1,B=!1}else if(z===H2)C=!1;continue}if($+=Z,$===F&&G<E.length-1)D.push(""),$=0}if(!$&&D.at(-1).length>0&&D.length>1)D[D.length-2]+=D.pop()},T3=(D)=>{let u=D.split(" "),F=u.length;while(F>0){if(TD(u[F-1])>0)break;F--}if(F===u.length)return D;return u.slice(0,F).join(" ")+u.slice(F).join("")},R3=(D,u,F={})=>{if(F.trim!==!1&&D.trim()==="")return"";let E="",C,B,$=N3(D),G=[""];for(let[J,Q]of D.split(" ").entries()){if(F.trim!==!1)G[G.length-1]=G.at(-1).trimStart();let O=TD(G.at(-1));if(J!==0){if(O>=u&&(F.wordWrap===!1||F.trim===!1))G.push(""),O=0;if(O>0||F.trim===!1)G[G.length-1]+=" ",O++}if(F.hard&&$[J]>u){let V=u-O,W=1+Math.floor(($[J]-V-1)/u);if(Math.floor(($[J]-1)/u)<W)G.push("");PF(G,Q,u);continue}if(O+$[J]>u&&O>0&&$[J]>0){if(F.wordWrap===!1&&O<u){PF(G,Q,u);continue}G.push("")}if(O+$[J]>u&&F.wordWrap===!1){PF(G,Q,u);continue}G[G.length-1]+=Q}if(F.trim!==!1)G=G.map((J)=>T3(J));let z=G.join(`
8
+ `),Z=[...z],Y=0;for(let[J,Q]of Z.entries()){if(E+=Q,lu.has(Q)){let{groups:V}=new RegExp(`(?:\\${V2}(?<code>\\d+)m|\\${nu}(?<uri>.*)${wF})`).exec(z.slice(Y))||{groups:{}};if(V.code!==void 0){let W=Number.parseFloat(V.code);C=W===A3?void 0:W}else if(V.uri!==void 0)B=V.uri.length===0?void 0:V.uri}let O=Y2.codes.get(Number(C));if(Z[J+1]===`
9
9
  `){if(B)E+=O2("");if(C&&O)E+=W2(O)}else if(Q===`
10
10
  `){if(C&&O)E+=W2(C);if(B)E+=O2(B)}Y+=Q.length}return E};function xF(D,u,F){return String(D).normalize().replaceAll(`\r
11
11
  `,`
12
12
  `).split(`
13
13
  `).map((E)=>R3(E,u,F)).join(`
14
- `)}function IF(D){return l0(D,{stringWidth:TD,stripAnsi:sD,wrap:xF})}import{dirname as q2,resolve as U2}from"path";import{readdirSync as S3,statSync as P3}from"fs";function bF(D,u){let F=U2(".",D),E;if(!P3(F).isDirectory())F=q2(F);while(!0){if(E=u(F,S3(F)),E)return U2(F,E);if(F=q2(E=F),E===F)break}}import{inspect as t3}from"util";import{fileURLToPath as h2}from"url";import{format as I3}from"util";import{normalize as b3,resolve as f3}from"path";function rD(D){if(!(D!==D.toLowerCase()&&D!==D.toUpperCase()))D=D.toLowerCase();if(D.indexOf("-")===-1&&D.indexOf("_")===-1)return D;else{let F="",E=!1,C=D.match(/^-+/);for(let B=C?C[0].length:0;B<D.length;B++){let $=D.charAt(B);if(E)E=!1,$=$.toUpperCase();if(B!==0&&($==="-"||$==="_"))E=!0;else if($!=="-"&&$!=="_")F+=$}return F}}function lu(D,u){let F=D.toLowerCase();u=u||"-";let E="";for(let C=0;C<D.length;C++){let B=F.charAt(C),$=D.charAt(C);if(B!==$&&C>0)E+=`${u}${F.charAt(C)}`;else E+=$}return E}function tu(D){if(D===null||D===void 0)return!1;if(typeof D==="number")return!0;if(/^0x[0-9a-f]+$/i.test(D))return!0;if(/^0[^.]/.test(D))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(D)}function M2(D){if(Array.isArray(D))return D.map(($)=>typeof $!=="string"?$+"":$);D=D.trim();let u=0,F=null,E=null,C=null,B=[];for(let $=0;$<D.length;$++){if(F=E,E=D.charAt($),E===" "&&!C){if(F!==" ")u++;continue}if(E===C)C=null;else if((E==="'"||E==='"')&&!C)C=E;if(!B[u])B[u]="";B[u]+=E}return B}var jD;(function(D){D.BOOLEAN="boolean",D.STRING="string",D.NUMBER="number",D.ARRAY="array"})(jD||(jD={}));var vD;class hF{constructor(D){vD=D}parse(D,u){let F=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},u),E=M2(D),C=typeof D==="string",B=w3(Object.assign(Object.create(null),F.alias)),$=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},F.configuration),G=Object.assign(Object.create(null),F.default),Z=F.configObjects||[],z=F.envPrefix,Y=$["populate--"],J=Y?"--":"_",Q=Object.create(null),O=Object.create(null),V=F.__||vD.format,W={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},M=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,_=new RegExp("^--"+$["negation-prefix"]+"(.+)");if([].concat(F.array||[]).filter(Boolean).forEach(function(H){let U=typeof H==="object"?H.key:H,j=Object.keys(H).map(function(K){return{boolean:"bools",string:"strings",number:"numbers"}[K]}).filter(Boolean).pop();if(j)W[j][U]=!0;W.arrays[U]=!0,W.keys.push(U)}),[].concat(F.boolean||[]).filter(Boolean).forEach(function(H){W.bools[H]=!0,W.keys.push(H)}),[].concat(F.string||[]).filter(Boolean).forEach(function(H){W.strings[H]=!0,W.keys.push(H)}),[].concat(F.number||[]).filter(Boolean).forEach(function(H){W.numbers[H]=!0,W.keys.push(H)}),[].concat(F.count||[]).filter(Boolean).forEach(function(H){W.counts[H]=!0,W.keys.push(H)}),[].concat(F.normalize||[]).filter(Boolean).forEach(function(H){W.normalize[H]=!0,W.keys.push(H)}),typeof F.narg==="object")Object.entries(F.narg).forEach(([H,U])=>{if(typeof U==="number")W.nargs[H]=U,W.keys.push(H)});if(typeof F.coerce==="object")Object.entries(F.coerce).forEach(([H,U])=>{if(typeof U==="function")W.coercions[H]=U,W.keys.push(H)});if(typeof F.config<"u"){if(Array.isArray(F.config)||typeof F.config==="string")[].concat(F.config).filter(Boolean).forEach(function(H){W.configs[H]=!0});else if(typeof F.config==="object")Object.entries(F.config).forEach(([H,U])=>{if(typeof U==="boolean"||typeof U==="function")W.configs[H]=U})}Nu(F.key,B,F.default,W.arrays),Object.keys(G).forEach(function(H){(W.aliases[H]||[]).forEach(function(U){G[U]=G[H]})});let N=null;TF();let k=[],w=Object.assign(Object.create(null),{_:[]}),c={};for(let H=0;H<E.length;H++){let U=E[H],j=U.replace(/^-{3,}/,"---"),K,q,S,L,b,ZD;if(U!=="--"&&/^-/.test(U)&&l(U))e(U);else if(j.match(/^---+(=|$)/)){e(U);continue}else if(U.match(/^--.+=/)||!$["short-option-groups"]&&U.match(/^-.+=/)){if(L=U.match(/^--?([^=]+)=([\s\S]*)$/),L!==null&&Array.isArray(L)&&L.length>=3)if(f(L[1],W.arrays))H=_D(H,L[1],E,L[2]);else if(f(L[1],W.nargs)!==!1)H=r(H,L[1],E,L[2]);else i(L[1],L[2],!0)}else if(U.match(_)&&$["boolean-negation"]){if(L=U.match(_),L!==null&&Array.isArray(L)&&L.length>=2)q=L[1],i(q,f(q,W.arrays)?[!1]:!1)}else if(U.match(/^--.+/)||!$["short-option-groups"]&&U.match(/^-[^-]+/)){if(L=U.match(/^--?(.+)/),L!==null&&Array.isArray(L)&&L.length>=2)if(q=L[1],f(q,W.arrays))H=_D(H,q,E);else if(f(q,W.nargs)!==!1)H=r(H,q,E);else if(b=E[H+1],b!==void 0&&(!b.match(/^-/)||b.match(M))&&!f(q,W.bools)&&!f(q,W.counts))i(q,b),H++;else if(/^(true|false)$/.test(b))i(q,b),H++;else i(q,g(q))}else if(U.match(/^-.\..+=/)){if(L=U.match(/^-([^=]+)=([\s\S]*)$/),L!==null&&Array.isArray(L)&&L.length>=3)i(L[1],L[2])}else if(U.match(/^-.\..+/)&&!U.match(M)){if(b=E[H+1],L=U.match(/^-(.\..+)/),L!==null&&Array.isArray(L)&&L.length>=2)if(q=L[1],b!==void 0&&!b.match(/^-/)&&!f(q,W.bools)&&!f(q,W.counts))i(q,b),H++;else i(q,g(q))}else if(U.match(/^-[^-]+/)&&!U.match(M)){S=U.slice(1,-1).split(""),K=!1;for(let YD=0;YD<S.length;YD++){if(b=U.slice(YD+2),S[YD+1]&&S[YD+1]==="="){if(ZD=U.slice(YD+3),q=S[YD],f(q,W.arrays))H=_D(H,q,E,ZD);else if(f(q,W.nargs)!==!1)H=r(H,q,E,ZD);else i(q,ZD);K=!0;break}if(b==="-"){i(S[YD],b);continue}if(/[A-Za-z]/.test(S[YD])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(b)&&f(b,W.bools)===!1){i(S[YD],b),K=!0;break}if(S[YD+1]&&S[YD+1].match(/\W/)){i(S[YD],b),K=!0;break}else i(S[YD],g(S[YD]))}if(q=U.slice(-1)[0],!K&&q!=="-")if(f(q,W.arrays))H=_D(H,q,E);else if(f(q,W.nargs)!==!1)H=r(H,q,E);else if(b=E[H+1],b!==void 0&&(!/^(-|--)[^-]/.test(b)||b.match(M))&&!f(q,W.bools)&&!f(q,W.counts))i(q,b),H++;else if(/^(true|false)$/.test(b))i(q,b),H++;else i(q,g(q))}else if(U.match(/^-[0-9]$/)&&U.match(M)&&f(U.slice(1),W.bools))q=U.slice(1),i(q,g(q));else if(U==="--"){k=E.slice(H+1);break}else if($["halt-at-non-option"]){k=E.slice(H);break}else e(U)}if(BD(w,!0),BD(w,!1),x(w),n(),yD(w,W.aliases,G,!0),d(w),$["set-placeholder-key"])$D(w);if(Object.keys(W.counts).forEach(function(H){if(!t(w,H.split(".")))i(H,0)}),Y&&k.length)w[J]=[];if(k.forEach(function(H){w[J].push(H)}),$["camel-case-expansion"]&&$["strip-dashed"])Object.keys(w).filter((H)=>H!=="--"&&H.includes("-")).forEach((H)=>{delete w[H]});if($["strip-aliased"])[].concat(...Object.keys(B).map((H)=>B[H])).forEach((H)=>{if($["camel-case-expansion"]&&H.includes("-"))delete w[H.split(".").map((U)=>rD(U)).join(".")];delete w[H]});function e(H){let U=A("_",H);if(typeof U==="string"||typeof U==="number")w._.push(U)}function r(H,U,j,K){let q,S=f(U,W.nargs);if(S=typeof S!=="number"||isNaN(S)?1:S,S===0){if(!zD(K))N=Error(V("Argument unexpected for: %s",U));return i(U,g(U)),H}let L=zD(K)?0:1;if($["nargs-eats-options"]){if(j.length-(H+1)+L<S)N=Error(V("Not enough arguments following: %s",U));L=S}else{for(q=H+1;q<j.length;q++)if(!j[q].match(/^-[^0-9]/)||j[q].match(M)||l(j[q]))L++;else break;if(L<S)N=Error(V("Not enough arguments following: %s",U))}let b=Math.min(L,S);if(!zD(K)&&b>0)i(U,K),b--;for(q=H+1;q<b+H+1;q++)i(U,j[q]);return H+b}function _D(H,U,j,K){let q=[],S=K||j[H+1],L=f(U,W.nargs);if(f(U,W.bools)&&!/^(true|false)$/.test(S))q.push(!0);else if(zD(S)||zD(K)&&/^-/.test(S)&&!M.test(S)&&!l(S)){if(G[U]!==void 0){let b=G[U];q=Array.isArray(b)?b:[b]}}else{if(!zD(K))q.push(P(U,K,!0));for(let b=H+1;b<j.length;b++){if(!$["greedy-arrays"]&&q.length>0||L&&typeof L==="number"&&q.length>=L)break;if(S=j[b],/^-/.test(S)&&!M.test(S)&&!l(S))break;H=b,q.push(P(U,S,C))}}if(typeof L==="number"&&(L&&q.length<L||isNaN(L)&&q.length===0))N=Error(V("Not enough arguments following: %s",U));return i(U,q),H}function i(H,U,j=C){if(/-/.test(H)&&$["camel-case-expansion"]){let S=H.split(".").map(function(L){return rD(L)}).join(".");oD(H,S)}let K=P(H,U,j),q=H.split(".");if(hD(w,q,K),W.aliases[H])W.aliases[H].forEach(function(S){let L=S.split(".");hD(w,L,K)});if(q.length>1&&$["dot-notation"])(W.aliases[q[0]]||[]).forEach(function(S){let L=S.split("."),b=[].concat(q);if(b.shift(),L=L.concat(b),!(W.aliases[H]||[]).includes(L.join(".")))hD(w,L,K)});if(f(H,W.normalize)&&!f(H,W.arrays))[H].concat(W.aliases[H]||[]).forEach(function(L){Object.defineProperty(c,L,{enumerable:!0,get(){return U},set(b){U=typeof b==="string"?vD.normalize(b):b}})})}function oD(H,U){if(!(W.aliases[H]&&W.aliases[H].length))W.aliases[H]=[U],Q[U]=!0;if(!(W.aliases[U]&&W.aliases[U].length))oD(U,H)}function P(H,U,j){if(j)U=x3(U);if(f(H,W.bools)||f(H,W.counts)){if(typeof U==="string")U=U==="true"}let K=Array.isArray(U)?U.map(function(q){return A(H,q)}):A(H,U);if(f(H,W.counts)&&(zD(K)||typeof K==="boolean"))K=fF();if(f(H,W.normalize)&&f(H,W.arrays))if(Array.isArray(U))K=U.map((q)=>{return vD.normalize(q)});else K=vD.normalize(U);return K}function A(H,U){if(!$["parse-positional-numbers"]&&H==="_")return U;if(!f(H,W.strings)&&!f(H,W.bools)&&!Array.isArray(U)){if(tu(U)&&$["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${U}`)))||!zD(U)&&f(H,W.numbers))U=Number(U)}return U}function x(H){let U=Object.create(null);yD(U,W.aliases,G),Object.keys(W.configs).forEach(function(j){let K=H[j]||U[j];if(K)try{let q=null,S=vD.resolve(vD.cwd(),K),L=W.configs[j];if(typeof L==="function"){try{q=L(S)}catch(b){q=b}if(q instanceof Error){N=q;return}}else q=vD.require(S);p(q)}catch(q){if(q.name==="PermissionDenied")N=q;else if(H[j])N=Error(V("Invalid JSON config file: %s",K))}})}function p(H,U){Object.keys(H).forEach(function(j){let K=H[j],q=U?U+"."+j:j;if(typeof K==="object"&&K!==null&&!Array.isArray(K)&&$["dot-notation"])p(K,q);else if(!t(w,q.split("."))||f(q,W.arrays)&&$["combine-arrays"])i(q,K)})}function n(){if(typeof Z<"u")Z.forEach(function(H){p(H)})}function BD(H,U){if(typeof z>"u")return;let j=typeof z==="string"?z:"",K=vD.env();Object.keys(K).forEach(function(q){if(j===""||q.lastIndexOf(j,0)===0){let S=q.split("__").map(function(L,b){if(b===0)L=L.substring(j.length);return rD(L)});if((U&&W.configs[S.join(".")]||!U)&&!t(H,S))i(S.join("."),K[q])}})}function d(H){let U,j=new Set;Object.keys(H).forEach(function(K){if(!j.has(K)){if(U=f(K,W.coercions),typeof U==="function")try{let q=A(K,U(H[K]));[].concat(W.aliases[K]||[],K).forEach((S)=>{j.add(S),H[S]=q})}catch(q){N=q}}})}function $D(H){return W.keys.forEach((U)=>{if(~U.indexOf("."))return;if(typeof H[U]>"u")H[U]=void 0}),H}function yD(H,U,j,K=!1){Object.keys(j).forEach(function(q){if(!t(H,q.split("."))){if(hD(H,q.split("."),j[q]),K)O[q]=!0;(U[q]||[]).forEach(function(S){if(t(H,S.split(".")))return;hD(H,S.split("."),j[q])})}})}function t(H,U){let j=H;if(!$["dot-notation"])U=[U.join(".")];U.slice(0,-1).forEach(function(q){j=j[q]||{}});let K=U[U.length-1];if(typeof j!=="object")return!1;else return K in j}function hD(H,U,j){let K=H;if(!$["dot-notation"])U=[U.join(".")];U.slice(0,-1).forEach(function(ZD){if(ZD=K2(ZD),typeof K==="object"&&K[ZD]===void 0)K[ZD]={};if(typeof K[ZD]!=="object"||Array.isArray(K[ZD])){if(Array.isArray(K[ZD]))K[ZD].push({});else K[ZD]=[K[ZD],{}];K=K[ZD][K[ZD].length-1]}else K=K[ZD]});let q=K2(U[U.length-1]),S=f(U.join("."),W.arrays),L=Array.isArray(j),b=$["duplicate-arguments-array"];if(!b&&f(q,W.nargs)){if(b=!0,!zD(K[q])&&W.nargs[q]===1||Array.isArray(K[q])&&K[q].length===W.nargs[q])K[q]=void 0}if(j===fF())K[q]=fF(K[q]);else if(Array.isArray(K[q]))if(b&&S&&L)K[q]=$["flatten-duplicate-arrays"]?K[q].concat(j):(Array.isArray(K[q][0])?K[q]:[K[q]]).concat([j]);else if(!b&&Boolean(S)===Boolean(L))K[q]=j;else K[q]=K[q].concat([j]);else if(K[q]===void 0&&S)K[q]=L?j:[j];else if(b&&!(K[q]===void 0||f(q,W.counts)||f(q,W.bools)))K[q]=[K[q],j];else K[q]=j}function Nu(...H){H.forEach(function(U){Object.keys(U||{}).forEach(function(j){if(W.aliases[j])return;W.aliases[j]=[].concat(B[j]||[]),W.aliases[j].concat(j).forEach(function(K){if(/-/.test(K)&&$["camel-case-expansion"]){let q=rD(K);if(q!==j&&W.aliases[j].indexOf(q)===-1)W.aliases[j].push(q),Q[q]=!0}}),W.aliases[j].concat(j).forEach(function(K){if(K.length>1&&/[A-Z]/.test(K)&&$["camel-case-expansion"]){let q=lu(K,"-");if(q!==j&&W.aliases[j].indexOf(q)===-1)W.aliases[j].push(q),Q[q]=!0}}),W.aliases[j].forEach(function(K){W.aliases[K]=[j].concat(W.aliases[j].filter(function(q){return K!==q}))})})})}function f(H,U){let j=[].concat(W.aliases[H]||[],H),K=Object.keys(U),q=j.find((S)=>K.includes(S));return q?U[q]:!1}function Hu(H){let U=Object.keys(W);return[].concat(U.map((K)=>W[K])).some(function(K){return Array.isArray(K)?K.includes(H):K[H]})}function c0(H,...U){return[].concat(...U).some(function(K){let q=H.match(K);return q&&Hu(q[1])})}function h(H){if(H.match(M)||!H.match(/^-[^-]+/))return!1;let U=!0,j,K=H.slice(1).split("");for(let q=0;q<K.length;q++){if(j=H.slice(q+2),!Hu(K[q])){U=!1;break}if(K[q+1]&&K[q+1]==="="||j==="-"||/[A-Za-z]/.test(K[q])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(j)||K[q+1]&&K[q+1].match(/\W/))break}return U}function l(H){return $["unknown-options-as-args"]&&GD(H)}function GD(H){if(H=H.replace(/^-{3,}/,"--"),H.match(M))return!1;if(h(H))return!1;return!c0(H,/^-+([^=]+?)=[\s\S]*$/,_,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function g(H){if(!f(H,W.bools)&&!f(H,W.counts)&&`${H}`in G)return G[H];else return QD(uD(H))}function QD(H){return{[jD.BOOLEAN]:!0,[jD.STRING]:"",[jD.NUMBER]:void 0,[jD.ARRAY]:[]}[H]}function uD(H){let U=jD.BOOLEAN;if(f(H,W.strings))U=jD.STRING;else if(f(H,W.numbers))U=jD.NUMBER;else if(f(H,W.bools))U=jD.BOOLEAN;else if(f(H,W.arrays))U=jD.ARRAY;return U}function zD(H){return H===void 0}function TF(){Object.keys(W.counts).find((H)=>{if(f(H,W.arrays))return N=Error(V("Invalid configuration: %s, opts.count excludes opts.array.",H)),!0;else if(f(H,W.nargs))return N=Error(V("Invalid configuration: %s, opts.count excludes opts.narg.",H)),!0;return!1})}return{aliases:Object.assign({},W.aliases),argv:Object.assign(c,w),configuration:$,defaulted:Object.assign({},O),error:N,newAliases:Object.assign({},Q)}}}function w3(D){let u=[],F=Object.create(null),E=!0;Object.keys(D).forEach(function(C){u.push([].concat(D[C],C))});while(E){E=!1;for(let C=0;C<u.length;C++)for(let B=C+1;B<u.length;B++)if(u[C].filter(function(G){return u[B].indexOf(G)!==-1}).length){u[C]=u[C].concat(u[B]),u.splice(B,1),E=!0;break}}return u.forEach(function(C){C=C.filter(function($,G,Z){return Z.indexOf($)===G});let B=C.pop();if(B!==void 0&&typeof B==="string")F[B]=C}),F}function fF(D){return D!==void 0?D+1:1}function K2(D){if(D==="__proto__")return"___proto___";return D}function x3(D){return typeof D==="string"&&(D[0]==="'"||D[0]==='"')&&D[D.length-1]===D[0]?D.substring(1,D.length-1):D}import{readFileSync as h3}from"fs";import{createRequire as _2}from"node:module";var vF,pF,mF,j2=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,A2=(pF=(vF=process===null||process===void 0?void 0:process.versions)===null||vF===void 0?void 0:vF.node)!==null&&pF!==void 0?pF:(mF=process===null||process===void 0?void 0:process.version)===null||mF===void 0?void 0:mF.slice(1);if(A2){if(Number(A2.match(/^([^.]+)/)[1])<j2)throw Error(`yargs parser supports a minimum Node.js version of ${j2}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var v3=process?process.env:{},L2=_2?_2(import.meta.url):void 0,N2=new hF({cwd:process.cwd,env:()=>{return v3},format:I3,normalize:b3,resolve:f3,require:(D)=>{if(typeof L2<"u")return L2(D);else if(D.match(/\.json$/))return JSON.parse(h3(D,"utf8"));else throw Error("only .json config files are supported in ESM")}}),Tu=function(u,F){return N2.parse(u.slice(),F).argv};Tu.detailed=function(D,u){return N2.parse(D.slice(),u)};Tu.camelCase=rD;Tu.decamelize=lu;Tu.looksLikeNumber=tu;var yF=Tu;import{basename as o3,dirname as s3,extname as r3,relative as a3,resolve as f2,join as e3}from"path";function T2(){if(p3())return 0;return 1}function p3(){return m3()&&!process.defaultApp}function m3(){return!!process.versions.electron}function cF(D){return D.slice(T2()+1)}function R2(){return process.argv[T2()]}import{readFileSync as y3,statSync as c3,writeFile as g3}from"fs";import{format as k3}from"util";import{resolve as d3}from"path";var S2={fs:{readFileSync:y3,writeFile:g3},format:k3,resolve:d3,exists:(D)=>{try{return c3(D).isFile()}catch(u){return!1}}};var RD;class P2{constructor(D){D=D||{},this.directory=D.directory||"./locales",this.updateFiles=typeof D.updateFiles==="boolean"?D.updateFiles:!0,this.locale=D.locale||"en",this.fallbackToLanguage=typeof D.fallbackToLanguage==="boolean"?D.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...D){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let u=D.shift(),F=function(){};if(typeof D[D.length-1]==="function")F=D.pop();if(F=F||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][u]&&this.updateFiles)this.cache[this.locale][u]=u,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:F});else F();return RD.format.apply(RD.format,[this.cache[this.locale][u]||u].concat(D))}__n(){let D=Array.prototype.slice.call(arguments),u=D.shift(),F=D.shift(),E=D.shift(),C=function(){};if(typeof D[D.length-1]==="function")C=D.pop();if(!this.cache[this.locale])this._readLocaleFile();let B=E===1?u:F;if(this.cache[this.locale][u])B=this.cache[this.locale][u][E===1?"one":"other"];if(!this.cache[this.locale][u]&&this.updateFiles)this.cache[this.locale][u]={one:u,other:F},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:C});else C();let $=[B];if(~B.indexOf("%d"))$.push(E);return RD.format.apply(RD.format,$.concat(D))}setLocale(D){this.locale=D}getLocale(){return this.locale}updateLocale(D){if(!this.cache[this.locale])this._readLocaleFile();for(let u in D)if(Object.prototype.hasOwnProperty.call(D,u))this.cache[this.locale][u]=D[u]}_taggedLiteral(D,...u){let F="";return D.forEach(function(E,C){let B=u[C+1];if(F+=E,typeof B<"u")F+="%s"}),this.__.apply(this,[F].concat([].slice.call(u,1)))}_enqueueWrite(D){if(this.writeQueue.push(D),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let D=this,u=this.writeQueue[0],F=u.directory,E=u.locale,C=u.cb,B=this._resolveLocaleFile(F,E),$=JSON.stringify(this.cache[E],null,2);RD.fs.writeFile(B,$,"utf-8",function(G){if(D.writeQueue.shift(),D.writeQueue.length>0)D._processWriteQueue();C(G)})}_readLocaleFile(){let D={},u=this._resolveLocaleFile(this.directory,this.locale);try{if(RD.fs.readFileSync)D=JSON.parse(RD.fs.readFileSync(u,"utf-8"))}catch(F){if(F instanceof SyntaxError)F.message="syntax error in "+u;if(F.code==="ENOENT")D={};else throw F}this.cache[this.locale]=D}_resolveLocaleFile(D,u){let F=RD.resolve(D,"./",u+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(F)&&~u.lastIndexOf("_")){let E=RD.resolve(D,"./",u.split("_")[0]+".json");if(this._fileExistsSync(E))F=E}return F}_fileExistsSync(D){return RD.exists(D)}}function w2(D,u){RD=u;let F=new P2(D);return{__:F.__.bind(F),__n:F.__n.bind(F),setLocale:F.setLocale.bind(F),getLocale:F.getLocale.bind(F),updateLocale:F.updateLocale.bind(F),locale:F.locale}}var i3=(D)=>{return w2(D,S2)},x2=i3;var v2=k0(b2(),1);import{createRequire as D6}from"node:module";import{readFileSync as u6,readdirSync as F6}from"node:fs";var gF=h2(import.meta.url),E6=gF.substring(0,gF.lastIndexOf("node_modules")),C6=D6(import.meta.url),kF={assert:{notStrictEqual:n3,strictEqual:l3},cliui:IF,findUp:bF,getEnv:(D)=>{return process.env[D]},inspect:t3,getProcessArgvBin:R2,mainFilename:E6||process.cwd(),Parser:yF,path:{basename:o3,dirname:s3,extname:r3,relative:a3,resolve:f2,join:e3},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(D,u)=>process.emitWarning(D,u),execPath:()=>process.execPath,exit:(D)=>{process.exit(D)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:u6,readdirSync:F6,require:C6,getCallerFile:()=>{let D=v2.default(3);return D.match(/^file:\/\//)?h2(D):D},stringWidth:TD,y18n:x2({directory:f2(gF,"../../../locales"),updateFiles:!1})};function WD(D,u,F,E){F.assert.notStrictEqual(D,u,E)}function dF(D,u){u.assert.strictEqual(typeof D,"string")}function qu(D){return Object.keys(D)}function s(D){return!!D&&!!D.then&&typeof D.then==="function"}class FD extends Error{constructor(D){super(D||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,FD)}}function cD(D){let F=D.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),E=/\.*[\][<>]/g,C=F.shift();if(!C)throw Error(`No command found in: ${D}`);let B={cmd:C.replace(E,""),demanded:[],optional:[]};return F.forEach(($,G)=>{let Z=!1;if($=$.replace(/\s/g,""),/\.+[\]>]/.test($)&&G===F.length-1)Z=!0;if(/^\[/.test($))B.optional.push({cmd:$.replace(E,"").split("|"),variadic:Z});else B.demanded.push({cmd:$.replace(E,"").split("|"),variadic:Z})}),B}var B6=["first","second","third","fourth","fifth","sixth"];function T(D,u,F){function E(){return typeof D==="object"?[{demanded:[],optional:[]},D,u]:[cD(`cmd ${D}`),u,F]}try{let C=0,[B,$,G]=E(),Z=[].slice.call($);while(Z.length&&Z[Z.length-1]===void 0)Z.pop();let z=G||Z.length;if(z<B.demanded.length)throw new FD(`Not enough arguments provided. Expected ${B.demanded.length} but received ${Z.length}.`);let Y=B.demanded.length+B.optional.length;if(z>Y)throw new FD(`Too many arguments provided. Expected max ${Y} but received ${z}.`);B.demanded.forEach((J)=>{let Q=Z.shift(),O=p2(Q);if(J.cmd.filter((W)=>W===O||W==="*").length===0)m2(O,J.cmd,C);C+=1}),B.optional.forEach((J)=>{if(Z.length===0)return;let Q=Z.shift(),O=p2(Q);if(J.cmd.filter((W)=>W===O||W==="*").length===0)m2(O,J.cmd,C);C+=1})}catch(C){console.warn(C.stack)}}function p2(D){if(Array.isArray(D))return"array";else if(D===null)return"null";return typeof D}function m2(D,u,F){throw new FD(`Invalid ${B6[F]||"manyith"} argument. Expected ${u.join(" or ")} but received ${D}.`)}class iF{constructor(D){this.globalMiddleware=[],this.frozens=[],this.yargs=D}addMiddleware(D,u,F=!0,E=!1){if(T("<array|function> [boolean] [boolean] [boolean]",[D,u,F],arguments.length),Array.isArray(D)){for(let C=0;C<D.length;C++){if(typeof D[C]!=="function")throw Error("middleware must be a function");let B=D[C];B.applyBeforeValidation=u,B.global=F}Array.prototype.push.apply(this.globalMiddleware,D)}else if(typeof D==="function"){let C=D;C.applyBeforeValidation=u,C.global=F,C.mutates=E,this.globalMiddleware.push(D)}return this.yargs}addCoerceMiddleware(D,u){let F=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((E)=>{let C=[...F[u]||[],u];if(!E.option)return!0;else return!C.includes(E.option)}),D.option=u,this.addMiddleware(D,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let D=this.frozens.pop();if(D!==void 0)this.globalMiddleware=D}reset(){this.globalMiddleware=this.globalMiddleware.filter((D)=>D.global)}}function y2(D){if(!D)return[];return D.map((u)=>{return u.applyBeforeValidation=!1,u})}function aD(D,u,F,E){return F.reduce((C,B)=>{if(B.applyBeforeValidation!==E)return C;if(B.mutates){if(B.applied)return C;B.applied=!0}if(s(C))return C.then(($)=>Promise.all([$,B($,u)])).then(([$,G])=>Object.assign($,G));else{let $=B(C,u);return s($)?$.then((G)=>Object.assign(C,G)):Object.assign(C,$)}},D)}function eD(D,u,F=(E)=>{throw E}){try{let E=$6(D)?D():D;return s(E)?E.then((C)=>u(C)):u(E)}catch(E){return F(E)}}function $6(D){return typeof D==="function"}var Uu=/(^\*)|(^\$0)/;class g2{constructor(D,u,F,E){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=E,this.usage=D,this.globalMiddleware=F,this.validation=u}addDirectory(D,u,F,E){E=E||{},this.requireCache.add(F);let C=this.shim.path.resolve(this.shim.path.dirname(F),D),B=this.shim.readdirSync(C,{recursive:E.recurse?!0:!1});if(!Array.isArray(E.extensions))E.extensions=["js"];let $=typeof E.visit==="function"?E.visit:(G)=>G;for(let G of B){let Z=G.toString();if(E.exclude){let Y=!1;if(typeof E.exclude==="function")Y=E.exclude(Z);else Y=E.exclude.test(Z);if(Y)continue}if(E.include){let Y=!1;if(typeof E.include==="function")Y=E.include(Z);else Y=E.include.test(Z);if(!Y)continue}let z=!1;for(let Y of E.extensions)if(Z.endsWith(Y))z=!0;if(z){let Y=this.shim.path.join(C,Z),J=u(Y),Q=Object.create(null,Object.getOwnPropertyDescriptors({...J}));if($(Q,Y,Z)){if(this.requireCache.has(Y))continue;else this.requireCache.add(Y);if(!Q.command)Q.command=this.shim.path.basename(Y,this.shim.path.extname(Y));this.addHandler(Q)}}}}addHandler(D,u,F,E,C,B){let $=[],G=y2(C);if(E=E||(()=>{}),Array.isArray(D))if(G6(D))[D,...$]=D;else for(let Z of D)this.addHandler(Z);else if(Z6(D)){let Z=Array.isArray(D.command)||typeof D.command==="string"?D.command:null;if(Z===null)throw Error(`No command name given for module: ${this.shim.inspect(D)}`);if(D.aliases)Z=[].concat(Z).concat(D.aliases);this.addHandler(Z,this.extractDesc(D),D.builder,D.handler,D.middlewares,D.deprecated);return}else if(c2(F)){this.addHandler([D].concat($),u,F.builder,F.handler,F.middlewares,F.deprecated);return}if(typeof D==="string"){let Z=cD(D);$=$.map((J)=>cD(J).cmd);let z=!1,Y=[Z.cmd].concat($).filter((J)=>{if(Uu.test(J))return z=!0,!1;return!0});if(Y.length===0&&z)Y.push("$0");if(z)Z.cmd=Y[0],$=Y.slice(1),D=D.replace(Uu,Z.cmd);if($.forEach((J)=>{this.aliasMap[J]=Z.cmd}),u!==!1)this.usage.command(D,u,z,$,B);if(this.handlers[Z.cmd]={original:D,description:u,handler:E,builder:F||{},middlewares:G,deprecated:B,demanded:Z.demanded,optional:Z.optional},z)this.defaultCommand=this.handlers[Z.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(D,u,F,E,C,B){let $=this.handlers[D]||this.handlers[this.aliasMap[D]]||this.defaultCommand,G=u.getInternalMethods().getContext(),Z=G.commands.slice(),z=!D;if(D)G.commands.push(D),G.fullCommands.push($.original);let Y=this.applyBuilderUpdateUsageAndParse(z,$,u,F.aliases,Z,E,C,B);return s(Y)?Y.then((J)=>this.applyMiddlewareAndGetResult(z,$,J.innerArgv,G,C,J.aliases,u)):this.applyMiddlewareAndGetResult(z,$,Y.innerArgv,G,C,Y.aliases,u)}applyBuilderUpdateUsageAndParse(D,u,F,E,C,B,$,G){let Z=u.builder,z=F;if(ou(Z)){F.getInternalMethods().getUsageInstance().freeze();let Y=Z(F.getInternalMethods().reset(E),G);if(s(Y))return Y.then((J)=>{return z=d2(J)?J:F,this.parseAndUpdateUsage(D,u,z,C,B,$)})}else if(z6(Z))F.getInternalMethods().getUsageInstance().freeze(),z=F.getInternalMethods().reset(E),Object.keys(u.builder).forEach((Y)=>{z.option(Y,Z[Y])});return this.parseAndUpdateUsage(D,u,z,C,B,$)}parseAndUpdateUsage(D,u,F,E,C,B){if(D)F.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(F))F.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(E,u),u.description);let $=F.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,C,B);return s($)?$.then((G)=>({aliases:F.parsed.aliases,innerArgv:G})):{aliases:F.parsed.aliases,innerArgv:$}}shouldUpdateUsage(D){return!D.getInternalMethods().getUsageInstance().getUsageDisabled()&&D.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(D,u){let F=Uu.test(u.original)?u.original.replace(Uu,"").trim():u.original,E=D.filter((C)=>{return!Uu.test(C)});return E.push(F),`$0 ${E.join(" ")}`}handleValidationAndGetResult(D,u,F,E,C,B,$,G){if(!B.getInternalMethods().getHasOutput()){let Z=B.getInternalMethods().runValidation(C,G,B.parsed.error,D);F=eD(F,(z)=>{return Z(z),z})}if(u.handler&&!B.getInternalMethods().getHasOutput()){B.getInternalMethods().setHasOutput();let Z=!!B.getOptions().configuration["populate--"];if(B.getInternalMethods().postProcess(F,Z,!1,!1),F=aD(F,B,$,!1),F=eD(F,(z)=>{let Y=u.handler(z);return s(Y)?Y.then(()=>z):z}),!D)B.getInternalMethods().getUsageInstance().cacheHelpMessage();if(s(F)&&!B.getInternalMethods().hasParseCallback())F.catch((z)=>{try{B.getInternalMethods().getUsageInstance().fail(null,z)}catch(Y){}})}if(!D)E.commands.pop(),E.fullCommands.pop();return F}applyMiddlewareAndGetResult(D,u,F,E,C,B,$){let G={};if(C)return F;if(!$.getInternalMethods().getHasOutput())G=this.populatePositionals(u,F,E,$);let Z=this.globalMiddleware.getMiddleware().slice(0).concat(u.middlewares),z=aD(F,$,Z,!0);return s(z)?z.then((Y)=>this.handleValidationAndGetResult(D,u,Y,E,B,$,Z,G)):this.handleValidationAndGetResult(D,u,z,E,B,$,Z,G)}populatePositionals(D,u,F,E){u._=u._.slice(F.commands.length);let C=D.demanded.slice(0),B=D.optional.slice(0),$={};this.validation.positionalCount(C.length,u._.length);while(C.length){let G=C.shift();this.populatePositional(G,u,$)}while(B.length){let G=B.shift();this.populatePositional(G,u,$)}return u._=F.commands.concat(u._.map((G)=>""+G)),this.postProcessPositionals(u,$,this.cmdToParseOptions(D.original),E),$}populatePositional(D,u,F){let E=D.cmd[0];if(D.variadic)F[E]=u._.splice(0).map(String);else if(u._.length)F[E]=[String(u._.shift())]}cmdToParseOptions(D){let u={array:[],default:{},alias:{},demand:{}},F=cD(D);return F.demanded.forEach((E)=>{let[C,...B]=E.cmd;if(E.variadic)u.array.push(C),u.default[C]=[];u.alias[C]=B,u.demand[C]=!0}),F.optional.forEach((E)=>{let[C,...B]=E.cmd;if(E.variadic)u.array.push(C),u.default[C]=[];u.alias[C]=B}),u}postProcessPositionals(D,u,F,E){let C=Object.assign({},E.getOptions());C.default=Object.assign(F.default,C.default);for(let Z of Object.keys(F.alias))C.alias[Z]=(C.alias[Z]||[]).concat(F.alias[Z]);C.array=C.array.concat(F.array),C.config={};let B=[];if(Object.keys(u).forEach((Z)=>{u[Z].map((z)=>{if(C.configuration["unknown-options-as-args"])C.key[Z]=!0;B.push(`--${Z}`),B.push(z)})}),!B.length)return;let $=Object.assign({},C.configuration,{"populate--":!1}),G=this.shim.Parser.detailed(B,Object.assign({},C,{configuration:$}));if(G.error)E.getInternalMethods().getUsageInstance().fail(G.error.message,G.error);else{let Z=Object.keys(u);Object.keys(u).forEach((z)=>{Z.push(...G.aliases[z])}),Object.keys(G.argv).forEach((z)=>{if(Z.includes(z)){if(!u[z])u[z]=G.argv[z];if(!this.isInConfigs(E,z)&&!this.isDefaulted(E,z)&&Object.prototype.hasOwnProperty.call(D,z)&&Object.prototype.hasOwnProperty.call(G.argv,z)&&(Array.isArray(D[z])||Array.isArray(G.argv[z])))D[z]=[].concat(D[z],G.argv[z]);else D[z]=G.argv[z]}})}}isDefaulted(D,u){let{default:F}=D.getOptions();return Object.prototype.hasOwnProperty.call(F,u)||Object.prototype.hasOwnProperty.call(F,this.shim.Parser.camelCase(u))}isInConfigs(D,u){let{configObjects:F}=D.getOptions();return F.some((E)=>Object.prototype.hasOwnProperty.call(E,u))||F.some((E)=>Object.prototype.hasOwnProperty.call(E,this.shim.Parser.camelCase(u)))}runDefaultBuilderOn(D){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(D)){let F=Uu.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");D.getInternalMethods().getUsageInstance().usage(F,this.defaultCommand.description)}let u=this.defaultCommand.builder;if(ou(u))return u(D,!0);else if(!c2(u))Object.keys(u).forEach((F)=>{D.option(F,u[F])});return}extractDesc({describe:D,description:u,desc:F}){for(let E of[D,u,F]){if(typeof E==="string"||E===!1)return E;WD(E,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let D=this.frozens.pop();WD(D,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=D}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function k2(D,u,F,E){return new g2(D,u,F,E)}function c2(D){return typeof D==="object"&&!!D.builder&&typeof D.handler==="function"}function G6(D){return D.every((u)=>typeof u==="string")}function ou(D){return typeof D==="function"}function z6(D){return typeof D==="object"}function Z6(D){return typeof D==="object"&&!Array.isArray(D)}function gD(D={},u=()=>!0){let F={};return qu(D).forEach((E)=>{if(u(E,D[E]))F[E]=D[E]}),F}function kD(D){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((u)=>{let F=u;if(F._handle&&F.isTTY&&typeof F._handle.setBlocking==="function")F._handle.setBlocking(D)})}function J6(D){return typeof D==="boolean"}function n2(D,u){let F=u.y18n.__,E={},C=[];E.failFn=function(A){C.push(A)};let B=null,$=null,G=!0;E.showHelpOnFail=function(A=!0,x){let[p,n]=typeof A==="string"?[!0,A]:[A,x];if(D.getInternalMethods().isGlobalContext())$=n;return B=n,G=p,E};let Z=!1;E.fail=function(A,x){let p=D.getInternalMethods().getLoggerInstance();if(C.length)for(let n=C.length-1;n>=0;--n){let BD=C[n];if(J6(BD)){if(x)throw x;else if(A)throw Error(A)}else BD(A,x,E)}else{if(D.getExitProcess())kD(!0);if(!Z){if(Z=!0,G)D.showHelp("error"),p.error();if(A||x)p.error(A||x);let n=B||$;if(n){if(A||x)p.error("");p.error(n)}}if(x=x||new FD(A),D.getExitProcess())return D.exit(1);else if(D.getInternalMethods().hasParseCallback())return D.exit(1,x);else throw x}};let z=[],Y=!1;E.usage=(P,A)=>{if(P===null)return Y=!0,z=[],E;return Y=!1,z.push([P,A||""]),E},E.getUsage=()=>{return z},E.getUsageDisabled=()=>{return Y},E.getPositionalGroupName=()=>{return F("Positionals:")};let J=[];E.example=(P,A)=>{J.push([P,A||""])};let Q=[];E.command=function(A,x,p,n,BD=!1){if(p)Q=Q.map((d)=>{return d[2]=!1,d});Q.push([A,x||"",p,n,BD])},E.getCommands=()=>Q;let O={};E.describe=function(A,x){if(Array.isArray(A))A.forEach((p)=>{E.describe(p,x)});else if(typeof A==="object")Object.keys(A).forEach((p)=>{E.describe(p,A[p])});else O[A]=x},E.getDescriptions=()=>O;let V=[];E.epilog=(P)=>{V.push(P)};let W=!1,M;E.wrap=(P)=>{W=!0,M=P},E.getWrap=()=>{if(u.getEnv("YARGS_DISABLE_WRAP"))return null;if(!W)M=_D(),W=!0;return M};let _="__yargsString__:";E.deferY18nLookup=(P)=>_+P,E.help=function(){if(w)return w;k();let A=D.customScriptName?D.$0:u.path.basename(D.$0),x=D.getDemandedOptions(),p=D.getDemandedCommands(),n=D.getDeprecatedOptions(),BD=D.getGroups(),d=D.getOptions(),$D=[];$D=$D.concat(Object.keys(O)),$D=$D.concat(Object.keys(x)),$D=$D.concat(Object.keys(p)),$D=$D.concat(Object.keys(d.default)),$D=$D.filter(e),$D=Object.keys($D.reduce((h,l)=>{if(l!=="_")h[l]=!0;return h},{}));let yD=E.getWrap(),t=u.cliui({width:yD,wrap:!!yD});if(!Y){if(z.length)z.forEach((h)=>{if(t.div({text:`${h[0].replace(/\$0/g,A)}`}),h[1])t.div({text:`${h[1]}`,padding:[1,0,0,0]})}),t.div();else if(Q.length){let h=null;if(p._)h=`${A} <${F("command")}>
14
+ `)}function IF(D){return l0(D,{stringWidth:TD,stripAnsi:sD,wrap:xF})}import{dirname as q2,resolve as U2}from"path";import{readdirSync as S3,statSync as P3}from"fs";function bF(D,u){let F=U2(".",D),E;if(!P3(F).isDirectory())F=q2(F);while(!0){if(E=u(F,S3(F)),E)return U2(F,E);if(F=q2(E=F),E===F)break}}import{inspect as t3}from"util";import{fileURLToPath as h2}from"url";import{format as I3}from"util";import{normalize as b3,resolve as f3}from"path";function rD(D){if(!(D!==D.toLowerCase()&&D!==D.toUpperCase()))D=D.toLowerCase();if(D.indexOf("-")===-1&&D.indexOf("_")===-1)return D;else{let F="",E=!1,C=D.match(/^-+/);for(let B=C?C[0].length:0;B<D.length;B++){let $=D.charAt(B);if(E)E=!1,$=$.toUpperCase();if(B!==0&&($==="-"||$==="_"))E=!0;else if($!=="-"&&$!=="_")F+=$}return F}}function tu(D,u){let F=D.toLowerCase();u=u||"-";let E="";for(let C=0;C<D.length;C++){let B=F.charAt(C),$=D.charAt(C);if(B!==$&&C>0)E+=`${u}${F.charAt(C)}`;else E+=$}return E}function ou(D){if(D===null||D===void 0)return!1;if(typeof D==="number")return!0;if(/^0x[0-9a-f]+$/i.test(D))return!0;if(/^0[^.]/.test(D))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(D)}function M2(D){if(Array.isArray(D))return D.map(($)=>typeof $!=="string"?$+"":$);D=D.trim();let u=0,F=null,E=null,C=null,B=[];for(let $=0;$<D.length;$++){if(F=E,E=D.charAt($),E===" "&&!C){if(F!==" ")u++;continue}if(E===C)C=null;else if((E==="'"||E==='"')&&!C)C=E;if(!B[u])B[u]="";B[u]+=E}return B}var jD;(function(D){D.BOOLEAN="boolean",D.STRING="string",D.NUMBER="number",D.ARRAY="array"})(jD||(jD={}));var vD;class hF{constructor(D){vD=D}parse(D,u){let F=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},u),E=M2(D),C=typeof D==="string",B=w3(Object.assign(Object.create(null),F.alias)),$=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},F.configuration),G=Object.assign(Object.create(null),F.default),z=F.configObjects||[],Z=F.envPrefix,Y=$["populate--"],J=Y?"--":"_",Q=Object.create(null),O=Object.create(null),V=F.__||vD.format,W={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},M=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,_=new RegExp("^--"+$["negation-prefix"]+"(.+)");if([].concat(F.array||[]).filter(Boolean).forEach(function(H){let U=typeof H==="object"?H.key:H,j=Object.keys(H).map(function(K){return{boolean:"bools",string:"strings",number:"numbers"}[K]}).filter(Boolean).pop();if(j)W[j][U]=!0;W.arrays[U]=!0,W.keys.push(U)}),[].concat(F.boolean||[]).filter(Boolean).forEach(function(H){W.bools[H]=!0,W.keys.push(H)}),[].concat(F.string||[]).filter(Boolean).forEach(function(H){W.strings[H]=!0,W.keys.push(H)}),[].concat(F.number||[]).filter(Boolean).forEach(function(H){W.numbers[H]=!0,W.keys.push(H)}),[].concat(F.count||[]).filter(Boolean).forEach(function(H){W.counts[H]=!0,W.keys.push(H)}),[].concat(F.normalize||[]).filter(Boolean).forEach(function(H){W.normalize[H]=!0,W.keys.push(H)}),typeof F.narg==="object")Object.entries(F.narg).forEach(([H,U])=>{if(typeof U==="number")W.nargs[H]=U,W.keys.push(H)});if(typeof F.coerce==="object")Object.entries(F.coerce).forEach(([H,U])=>{if(typeof U==="function")W.coercions[H]=U,W.keys.push(H)});if(typeof F.config<"u"){if(Array.isArray(F.config)||typeof F.config==="string")[].concat(F.config).filter(Boolean).forEach(function(H){W.configs[H]=!0});else if(typeof F.config==="object")Object.entries(F.config).forEach(([H,U])=>{if(typeof U==="boolean"||typeof U==="function")W.configs[H]=U})}Nu(F.key,B,F.default,W.arrays),Object.keys(G).forEach(function(H){(W.aliases[H]||[]).forEach(function(U){G[U]=G[H]})});let N=null;TF();let k=[],w=Object.assign(Object.create(null),{_:[]}),c={};for(let H=0;H<E.length;H++){let U=E[H],j=U.replace(/^-{3,}/,"---"),K,q,S,L,b,JD;if(U!=="--"&&/^-/.test(U)&&l(U))e(U);else if(j.match(/^---+(=|$)/)){e(U);continue}else if(U.match(/^--.+=/)||!$["short-option-groups"]&&U.match(/^-.+=/)){if(L=U.match(/^--?([^=]+)=([\s\S]*)$/),L!==null&&Array.isArray(L)&&L.length>=3)if(f(L[1],W.arrays))H=_D(H,L[1],E,L[2]);else if(f(L[1],W.nargs)!==!1)H=r(H,L[1],E,L[2]);else i(L[1],L[2],!0)}else if(U.match(_)&&$["boolean-negation"]){if(L=U.match(_),L!==null&&Array.isArray(L)&&L.length>=2)q=L[1],i(q,f(q,W.arrays)?[!1]:!1)}else if(U.match(/^--.+/)||!$["short-option-groups"]&&U.match(/^-[^-]+/)){if(L=U.match(/^--?(.+)/),L!==null&&Array.isArray(L)&&L.length>=2)if(q=L[1],f(q,W.arrays))H=_D(H,q,E);else if(f(q,W.nargs)!==!1)H=r(H,q,E);else if(b=E[H+1],b!==void 0&&(!b.match(/^-/)||b.match(M))&&!f(q,W.bools)&&!f(q,W.counts))i(q,b),H++;else if(/^(true|false)$/.test(b))i(q,b),H++;else i(q,g(q))}else if(U.match(/^-.\..+=/)){if(L=U.match(/^-([^=]+)=([\s\S]*)$/),L!==null&&Array.isArray(L)&&L.length>=3)i(L[1],L[2])}else if(U.match(/^-.\..+/)&&!U.match(M)){if(b=E[H+1],L=U.match(/^-(.\..+)/),L!==null&&Array.isArray(L)&&L.length>=2)if(q=L[1],b!==void 0&&!b.match(/^-/)&&!f(q,W.bools)&&!f(q,W.counts))i(q,b),H++;else i(q,g(q))}else if(U.match(/^-[^-]+/)&&!U.match(M)){S=U.slice(1,-1).split(""),K=!1;for(let YD=0;YD<S.length;YD++){if(b=U.slice(YD+2),S[YD+1]&&S[YD+1]==="="){if(JD=U.slice(YD+3),q=S[YD],f(q,W.arrays))H=_D(H,q,E,JD);else if(f(q,W.nargs)!==!1)H=r(H,q,E,JD);else i(q,JD);K=!0;break}if(b==="-"){i(S[YD],b);continue}if(/[A-Za-z]/.test(S[YD])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(b)&&f(b,W.bools)===!1){i(S[YD],b),K=!0;break}if(S[YD+1]&&S[YD+1].match(/\W/)){i(S[YD],b),K=!0;break}else i(S[YD],g(S[YD]))}if(q=U.slice(-1)[0],!K&&q!=="-")if(f(q,W.arrays))H=_D(H,q,E);else if(f(q,W.nargs)!==!1)H=r(H,q,E);else if(b=E[H+1],b!==void 0&&(!/^(-|--)[^-]/.test(b)||b.match(M))&&!f(q,W.bools)&&!f(q,W.counts))i(q,b),H++;else if(/^(true|false)$/.test(b))i(q,b),H++;else i(q,g(q))}else if(U.match(/^-[0-9]$/)&&U.match(M)&&f(U.slice(1),W.bools))q=U.slice(1),i(q,g(q));else if(U==="--"){k=E.slice(H+1);break}else if($["halt-at-non-option"]){k=E.slice(H);break}else e(U)}if(BD(w,!0),BD(w,!1),x(w),n(),mD(w,W.aliases,G,!0),d(w),$["set-placeholder-key"])$D(w);if(Object.keys(W.counts).forEach(function(H){if(!t(w,H.split(".")))i(H,0)}),Y&&k.length)w[J]=[];if(k.forEach(function(H){w[J].push(H)}),$["camel-case-expansion"]&&$["strip-dashed"])Object.keys(w).filter((H)=>H!=="--"&&H.includes("-")).forEach((H)=>{delete w[H]});if($["strip-aliased"])[].concat(...Object.keys(B).map((H)=>B[H])).forEach((H)=>{if($["camel-case-expansion"]&&H.includes("-"))delete w[H.split(".").map((U)=>rD(U)).join(".")];delete w[H]});function e(H){let U=A("_",H);if(typeof U==="string"||typeof U==="number")w._.push(U)}function r(H,U,j,K){let q,S=f(U,W.nargs);if(S=typeof S!=="number"||isNaN(S)?1:S,S===0){if(!zD(K))N=Error(V("Argument unexpected for: %s",U));return i(U,g(U)),H}let L=zD(K)?0:1;if($["nargs-eats-options"]){if(j.length-(H+1)+L<S)N=Error(V("Not enough arguments following: %s",U));L=S}else{for(q=H+1;q<j.length;q++)if(!j[q].match(/^-[^0-9]/)||j[q].match(M)||l(j[q]))L++;else break;if(L<S)N=Error(V("Not enough arguments following: %s",U))}let b=Math.min(L,S);if(!zD(K)&&b>0)i(U,K),b--;for(q=H+1;q<b+H+1;q++)i(U,j[q]);return H+b}function _D(H,U,j,K){let q=[],S=K||j[H+1],L=f(U,W.nargs);if(f(U,W.bools)&&!/^(true|false)$/.test(S))q.push(!0);else if(zD(S)||zD(K)&&/^-/.test(S)&&!M.test(S)&&!l(S)){if(G[U]!==void 0){let b=G[U];q=Array.isArray(b)?b:[b]}}else{if(!zD(K))q.push(P(U,K,!0));for(let b=H+1;b<j.length;b++){if(!$["greedy-arrays"]&&q.length>0||L&&typeof L==="number"&&q.length>=L)break;if(S=j[b],/^-/.test(S)&&!M.test(S)&&!l(S))break;H=b,q.push(P(U,S,C))}}if(typeof L==="number"&&(L&&q.length<L||isNaN(L)&&q.length===0))N=Error(V("Not enough arguments following: %s",U));return i(U,q),H}function i(H,U,j=C){if(/-/.test(H)&&$["camel-case-expansion"]){let S=H.split(".").map(function(L){return rD(L)}).join(".");oD(H,S)}let K=P(H,U,j),q=H.split(".");if(hD(w,q,K),W.aliases[H])W.aliases[H].forEach(function(S){let L=S.split(".");hD(w,L,K)});if(q.length>1&&$["dot-notation"])(W.aliases[q[0]]||[]).forEach(function(S){let L=S.split("."),b=[].concat(q);if(b.shift(),L=L.concat(b),!(W.aliases[H]||[]).includes(L.join(".")))hD(w,L,K)});if(f(H,W.normalize)&&!f(H,W.arrays))[H].concat(W.aliases[H]||[]).forEach(function(L){Object.defineProperty(c,L,{enumerable:!0,get(){return U},set(b){U=typeof b==="string"?vD.normalize(b):b}})})}function oD(H,U){if(!(W.aliases[H]&&W.aliases[H].length))W.aliases[H]=[U],Q[U]=!0;if(!(W.aliases[U]&&W.aliases[U].length))oD(U,H)}function P(H,U,j){if(j)U=x3(U);if(f(H,W.bools)||f(H,W.counts)){if(typeof U==="string")U=U==="true"}let K=Array.isArray(U)?U.map(function(q){return A(H,q)}):A(H,U);if(f(H,W.counts)&&(zD(K)||typeof K==="boolean"))K=fF();if(f(H,W.normalize)&&f(H,W.arrays))if(Array.isArray(U))K=U.map((q)=>{return vD.normalize(q)});else K=vD.normalize(U);return K}function A(H,U){if(!$["parse-positional-numbers"]&&H==="_")return U;if(!f(H,W.strings)&&!f(H,W.bools)&&!Array.isArray(U)){if(ou(U)&&$["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${U}`)))||!zD(U)&&f(H,W.numbers))U=Number(U)}return U}function x(H){let U=Object.create(null);mD(U,W.aliases,G),Object.keys(W.configs).forEach(function(j){let K=H[j]||U[j];if(K)try{let q=null,S=vD.resolve(vD.cwd(),K),L=W.configs[j];if(typeof L==="function"){try{q=L(S)}catch(b){q=b}if(q instanceof Error){N=q;return}}else q=vD.require(S);p(q)}catch(q){if(q.name==="PermissionDenied")N=q;else if(H[j])N=Error(V("Invalid JSON config file: %s",K))}})}function p(H,U){Object.keys(H).forEach(function(j){let K=H[j],q=U?U+"."+j:j;if(typeof K==="object"&&K!==null&&!Array.isArray(K)&&$["dot-notation"])p(K,q);else if(!t(w,q.split("."))||f(q,W.arrays)&&$["combine-arrays"])i(q,K)})}function n(){if(typeof z<"u")z.forEach(function(H){p(H)})}function BD(H,U){if(typeof Z>"u")return;let j=typeof Z==="string"?Z:"",K=vD.env();Object.keys(K).forEach(function(q){if(j===""||q.lastIndexOf(j,0)===0){let S=q.split("__").map(function(L,b){if(b===0)L=L.substring(j.length);return rD(L)});if((U&&W.configs[S.join(".")]||!U)&&!t(H,S))i(S.join("."),K[q])}})}function d(H){let U,j=new Set;Object.keys(H).forEach(function(K){if(!j.has(K)){if(U=f(K,W.coercions),typeof U==="function")try{let q=A(K,U(H[K]));[].concat(W.aliases[K]||[],K).forEach((S)=>{j.add(S),H[S]=q})}catch(q){N=q}}})}function $D(H){return W.keys.forEach((U)=>{if(~U.indexOf("."))return;if(typeof H[U]>"u")H[U]=void 0}),H}function mD(H,U,j,K=!1){Object.keys(j).forEach(function(q){if(!t(H,q.split("."))){if(hD(H,q.split("."),j[q]),K)O[q]=!0;(U[q]||[]).forEach(function(S){if(t(H,S.split(".")))return;hD(H,S.split("."),j[q])})}})}function t(H,U){let j=H;if(!$["dot-notation"])U=[U.join(".")];U.slice(0,-1).forEach(function(q){j=j[q]||{}});let K=U[U.length-1];if(typeof j!=="object")return!1;else return K in j}function hD(H,U,j){let K=H;if(!$["dot-notation"])U=[U.join(".")];U.slice(0,-1).forEach(function(JD){if(JD=K2(JD),typeof K==="object"&&K[JD]===void 0)K[JD]={};if(typeof K[JD]!=="object"||Array.isArray(K[JD])){if(Array.isArray(K[JD]))K[JD].push({});else K[JD]=[K[JD],{}];K=K[JD][K[JD].length-1]}else K=K[JD]});let q=K2(U[U.length-1]),S=f(U.join("."),W.arrays),L=Array.isArray(j),b=$["duplicate-arguments-array"];if(!b&&f(q,W.nargs)){if(b=!0,!zD(K[q])&&W.nargs[q]===1||Array.isArray(K[q])&&K[q].length===W.nargs[q])K[q]=void 0}if(j===fF())K[q]=fF(K[q]);else if(Array.isArray(K[q]))if(b&&S&&L)K[q]=$["flatten-duplicate-arrays"]?K[q].concat(j):(Array.isArray(K[q][0])?K[q]:[K[q]]).concat([j]);else if(!b&&Boolean(S)===Boolean(L))K[q]=j;else K[q]=K[q].concat([j]);else if(K[q]===void 0&&S)K[q]=L?j:[j];else if(b&&!(K[q]===void 0||f(q,W.counts)||f(q,W.bools)))K[q]=[K[q],j];else K[q]=j}function Nu(...H){H.forEach(function(U){Object.keys(U||{}).forEach(function(j){if(W.aliases[j])return;W.aliases[j]=[].concat(B[j]||[]),W.aliases[j].concat(j).forEach(function(K){if(/-/.test(K)&&$["camel-case-expansion"]){let q=rD(K);if(q!==j&&W.aliases[j].indexOf(q)===-1)W.aliases[j].push(q),Q[q]=!0}}),W.aliases[j].concat(j).forEach(function(K){if(K.length>1&&/[A-Z]/.test(K)&&$["camel-case-expansion"]){let q=tu(K,"-");if(q!==j&&W.aliases[j].indexOf(q)===-1)W.aliases[j].push(q),Q[q]=!0}}),W.aliases[j].forEach(function(K){W.aliases[K]=[j].concat(W.aliases[j].filter(function(q){return K!==q}))})})})}function f(H,U){let j=[].concat(W.aliases[H]||[],H),K=Object.keys(U),q=j.find((S)=>K.includes(S));return q?U[q]:!1}function Hu(H){let U=Object.keys(W);return[].concat(U.map((K)=>W[K])).some(function(K){return Array.isArray(K)?K.includes(H):K[H]})}function c0(H,...U){return[].concat(...U).some(function(K){let q=H.match(K);return q&&Hu(q[1])})}function h(H){if(H.match(M)||!H.match(/^-[^-]+/))return!1;let U=!0,j,K=H.slice(1).split("");for(let q=0;q<K.length;q++){if(j=H.slice(q+2),!Hu(K[q])){U=!1;break}if(K[q+1]&&K[q+1]==="="||j==="-"||/[A-Za-z]/.test(K[q])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(j)||K[q+1]&&K[q+1].match(/\W/))break}return U}function l(H){return $["unknown-options-as-args"]&&GD(H)}function GD(H){if(H=H.replace(/^-{3,}/,"--"),H.match(M))return!1;if(h(H))return!1;return!c0(H,/^-+([^=]+?)=[\s\S]*$/,_,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function g(H){if(!f(H,W.bools)&&!f(H,W.counts)&&`${H}`in G)return G[H];else return QD(uD(H))}function QD(H){return{[jD.BOOLEAN]:!0,[jD.STRING]:"",[jD.NUMBER]:void 0,[jD.ARRAY]:[]}[H]}function uD(H){let U=jD.BOOLEAN;if(f(H,W.strings))U=jD.STRING;else if(f(H,W.numbers))U=jD.NUMBER;else if(f(H,W.bools))U=jD.BOOLEAN;else if(f(H,W.arrays))U=jD.ARRAY;return U}function zD(H){return H===void 0}function TF(){Object.keys(W.counts).find((H)=>{if(f(H,W.arrays))return N=Error(V("Invalid configuration: %s, opts.count excludes opts.array.",H)),!0;else if(f(H,W.nargs))return N=Error(V("Invalid configuration: %s, opts.count excludes opts.narg.",H)),!0;return!1})}return{aliases:Object.assign({},W.aliases),argv:Object.assign(c,w),configuration:$,defaulted:Object.assign({},O),error:N,newAliases:Object.assign({},Q)}}}function w3(D){let u=[],F=Object.create(null),E=!0;Object.keys(D).forEach(function(C){u.push([].concat(D[C],C))});while(E){E=!1;for(let C=0;C<u.length;C++)for(let B=C+1;B<u.length;B++)if(u[C].filter(function(G){return u[B].indexOf(G)!==-1}).length){u[C]=u[C].concat(u[B]),u.splice(B,1),E=!0;break}}return u.forEach(function(C){C=C.filter(function($,G,z){return z.indexOf($)===G});let B=C.pop();if(B!==void 0&&typeof B==="string")F[B]=C}),F}function fF(D){return D!==void 0?D+1:1}function K2(D){if(D==="__proto__")return"___proto___";return D}function x3(D){return typeof D==="string"&&(D[0]==="'"||D[0]==='"')&&D[D.length-1]===D[0]?D.substring(1,D.length-1):D}import{readFileSync as h3}from"fs";import{createRequire as _2}from"node:module";var vF,pF,yF,j2=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,A2=(pF=(vF=process===null||process===void 0?void 0:process.versions)===null||vF===void 0?void 0:vF.node)!==null&&pF!==void 0?pF:(yF=process===null||process===void 0?void 0:process.version)===null||yF===void 0?void 0:yF.slice(1);if(A2){if(Number(A2.match(/^([^.]+)/)[1])<j2)throw Error(`yargs parser supports a minimum Node.js version of ${j2}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var v3=process?process.env:{},L2=_2?_2(import.meta.url):void 0,N2=new hF({cwd:process.cwd,env:()=>{return v3},format:I3,normalize:b3,resolve:f3,require:(D)=>{if(typeof L2<"u")return L2(D);else if(D.match(/\.json$/))return JSON.parse(h3(D,"utf8"));else throw Error("only .json config files are supported in ESM")}}),Tu=function(u,F){return N2.parse(u.slice(),F).argv};Tu.detailed=function(D,u){return N2.parse(D.slice(),u)};Tu.camelCase=rD;Tu.decamelize=tu;Tu.looksLikeNumber=ou;var mF=Tu;import{basename as o3,dirname as s3,extname as r3,relative as a3,resolve as f2,join as e3}from"path";function T2(){if(p3())return 0;return 1}function p3(){return y3()&&!process.defaultApp}function y3(){return!!process.versions.electron}function cF(D){return D.slice(T2()+1)}function R2(){return process.argv[T2()]}import{readFileSync as m3,statSync as c3,writeFile as g3}from"fs";import{format as k3}from"util";import{resolve as d3}from"path";var S2={fs:{readFileSync:m3,writeFile:g3},format:k3,resolve:d3,exists:(D)=>{try{return c3(D).isFile()}catch(u){return!1}}};var RD;class P2{constructor(D){D=D||{},this.directory=D.directory||"./locales",this.updateFiles=typeof D.updateFiles==="boolean"?D.updateFiles:!0,this.locale=D.locale||"en",this.fallbackToLanguage=typeof D.fallbackToLanguage==="boolean"?D.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...D){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let u=D.shift(),F=function(){};if(typeof D[D.length-1]==="function")F=D.pop();if(F=F||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][u]&&this.updateFiles)this.cache[this.locale][u]=u,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:F});else F();return RD.format.apply(RD.format,[this.cache[this.locale][u]||u].concat(D))}__n(){let D=Array.prototype.slice.call(arguments),u=D.shift(),F=D.shift(),E=D.shift(),C=function(){};if(typeof D[D.length-1]==="function")C=D.pop();if(!this.cache[this.locale])this._readLocaleFile();let B=E===1?u:F;if(this.cache[this.locale][u])B=this.cache[this.locale][u][E===1?"one":"other"];if(!this.cache[this.locale][u]&&this.updateFiles)this.cache[this.locale][u]={one:u,other:F},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:C});else C();let $=[B];if(~B.indexOf("%d"))$.push(E);return RD.format.apply(RD.format,$.concat(D))}setLocale(D){this.locale=D}getLocale(){return this.locale}updateLocale(D){if(!this.cache[this.locale])this._readLocaleFile();for(let u in D)if(Object.prototype.hasOwnProperty.call(D,u))this.cache[this.locale][u]=D[u]}_taggedLiteral(D,...u){let F="";return D.forEach(function(E,C){let B=u[C+1];if(F+=E,typeof B<"u")F+="%s"}),this.__.apply(this,[F].concat([].slice.call(u,1)))}_enqueueWrite(D){if(this.writeQueue.push(D),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let D=this,u=this.writeQueue[0],F=u.directory,E=u.locale,C=u.cb,B=this._resolveLocaleFile(F,E),$=JSON.stringify(this.cache[E],null,2);RD.fs.writeFile(B,$,"utf-8",function(G){if(D.writeQueue.shift(),D.writeQueue.length>0)D._processWriteQueue();C(G)})}_readLocaleFile(){let D={},u=this._resolveLocaleFile(this.directory,this.locale);try{if(RD.fs.readFileSync)D=JSON.parse(RD.fs.readFileSync(u,"utf-8"))}catch(F){if(F instanceof SyntaxError)F.message="syntax error in "+u;if(F.code==="ENOENT")D={};else throw F}this.cache[this.locale]=D}_resolveLocaleFile(D,u){let F=RD.resolve(D,"./",u+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(F)&&~u.lastIndexOf("_")){let E=RD.resolve(D,"./",u.split("_")[0]+".json");if(this._fileExistsSync(E))F=E}return F}_fileExistsSync(D){return RD.exists(D)}}function w2(D,u){RD=u;let F=new P2(D);return{__:F.__.bind(F),__n:F.__n.bind(F),setLocale:F.setLocale.bind(F),getLocale:F.getLocale.bind(F),updateLocale:F.updateLocale.bind(F),locale:F.locale}}var i3=(D)=>{return w2(D,S2)},x2=i3;var v2=k0(b2(),1);import{createRequire as D6}from"node:module";import{readFileSync as u6,readdirSync as F6}from"node:fs";var gF=h2(import.meta.url),E6=gF.substring(0,gF.lastIndexOf("node_modules")),C6=D6(import.meta.url),kF={assert:{notStrictEqual:n3,strictEqual:l3},cliui:IF,findUp:bF,getEnv:(D)=>{return process.env[D]},inspect:t3,getProcessArgvBin:R2,mainFilename:E6||process.cwd(),Parser:mF,path:{basename:o3,dirname:s3,extname:r3,relative:a3,resolve:f2,join:e3},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(D,u)=>process.emitWarning(D,u),execPath:()=>process.execPath,exit:(D)=>{process.exit(D)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:u6,readdirSync:F6,require:C6,getCallerFile:()=>{let D=v2.default(3);return D.match(/^file:\/\//)?h2(D):D},stringWidth:TD,y18n:x2({directory:f2(gF,"../../../locales"),updateFiles:!1})};function WD(D,u,F,E){F.assert.notStrictEqual(D,u,E)}function dF(D,u){u.assert.strictEqual(typeof D,"string")}function qu(D){return Object.keys(D)}function s(D){return!!D&&!!D.then&&typeof D.then==="function"}class FD extends Error{constructor(D){super(D||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,FD)}}function cD(D){let F=D.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),E=/\.*[\][<>]/g,C=F.shift();if(!C)throw Error(`No command found in: ${D}`);let B={cmd:C.replace(E,""),demanded:[],optional:[]};return F.forEach(($,G)=>{let z=!1;if($=$.replace(/\s/g,""),/\.+[\]>]/.test($)&&G===F.length-1)z=!0;if(/^\[/.test($))B.optional.push({cmd:$.replace(E,"").split("|"),variadic:z});else B.demanded.push({cmd:$.replace(E,"").split("|"),variadic:z})}),B}var B6=["first","second","third","fourth","fifth","sixth"];function T(D,u,F){function E(){return typeof D==="object"?[{demanded:[],optional:[]},D,u]:[cD(`cmd ${D}`),u,F]}try{let C=0,[B,$,G]=E(),z=[].slice.call($);while(z.length&&z[z.length-1]===void 0)z.pop();let Z=G||z.length;if(Z<B.demanded.length)throw new FD(`Not enough arguments provided. Expected ${B.demanded.length} but received ${z.length}.`);let Y=B.demanded.length+B.optional.length;if(Z>Y)throw new FD(`Too many arguments provided. Expected max ${Y} but received ${Z}.`);B.demanded.forEach((J)=>{let Q=z.shift(),O=p2(Q);if(J.cmd.filter((W)=>W===O||W==="*").length===0)y2(O,J.cmd,C);C+=1}),B.optional.forEach((J)=>{if(z.length===0)return;let Q=z.shift(),O=p2(Q);if(J.cmd.filter((W)=>W===O||W==="*").length===0)y2(O,J.cmd,C);C+=1})}catch(C){console.warn(C.stack)}}function p2(D){if(Array.isArray(D))return"array";else if(D===null)return"null";return typeof D}function y2(D,u,F){throw new FD(`Invalid ${B6[F]||"manyith"} argument. Expected ${u.join(" or ")} but received ${D}.`)}class iF{constructor(D){this.globalMiddleware=[],this.frozens=[],this.yargs=D}addMiddleware(D,u,F=!0,E=!1){if(T("<array|function> [boolean] [boolean] [boolean]",[D,u,F],arguments.length),Array.isArray(D)){for(let C=0;C<D.length;C++){if(typeof D[C]!=="function")throw Error("middleware must be a function");let B=D[C];B.applyBeforeValidation=u,B.global=F}Array.prototype.push.apply(this.globalMiddleware,D)}else if(typeof D==="function"){let C=D;C.applyBeforeValidation=u,C.global=F,C.mutates=E,this.globalMiddleware.push(D)}return this.yargs}addCoerceMiddleware(D,u){let F=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((E)=>{let C=[...F[u]||[],u];if(!E.option)return!0;else return!C.includes(E.option)}),D.option=u,this.addMiddleware(D,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let D=this.frozens.pop();if(D!==void 0)this.globalMiddleware=D}reset(){this.globalMiddleware=this.globalMiddleware.filter((D)=>D.global)}}function m2(D){if(!D)return[];return D.map((u)=>{return u.applyBeforeValidation=!1,u})}function aD(D,u,F,E){return F.reduce((C,B)=>{if(B.applyBeforeValidation!==E)return C;if(B.mutates){if(B.applied)return C;B.applied=!0}if(s(C))return C.then(($)=>Promise.all([$,B($,u)])).then(([$,G])=>Object.assign($,G));else{let $=B(C,u);return s($)?$.then((G)=>Object.assign(C,G)):Object.assign(C,$)}},D)}function eD(D,u,F=(E)=>{throw E}){try{let E=$6(D)?D():D;return s(E)?E.then((C)=>u(C)):u(E)}catch(E){return F(E)}}function $6(D){return typeof D==="function"}var Uu=/(^\*)|(^\$0)/;class g2{constructor(D,u,F,E){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=E,this.usage=D,this.globalMiddleware=F,this.validation=u}addDirectory(D,u,F,E){E=E||{},this.requireCache.add(F);let C=this.shim.path.resolve(this.shim.path.dirname(F),D),B=this.shim.readdirSync(C,{recursive:E.recurse?!0:!1});if(!Array.isArray(E.extensions))E.extensions=["js"];let $=typeof E.visit==="function"?E.visit:(G)=>G;for(let G of B){let z=G.toString();if(E.exclude){let Y=!1;if(typeof E.exclude==="function")Y=E.exclude(z);else Y=E.exclude.test(z);if(Y)continue}if(E.include){let Y=!1;if(typeof E.include==="function")Y=E.include(z);else Y=E.include.test(z);if(!Y)continue}let Z=!1;for(let Y of E.extensions)if(z.endsWith(Y))Z=!0;if(Z){let Y=this.shim.path.join(C,z),J=u(Y),Q=Object.create(null,Object.getOwnPropertyDescriptors({...J}));if($(Q,Y,z)){if(this.requireCache.has(Y))continue;else this.requireCache.add(Y);if(!Q.command)Q.command=this.shim.path.basename(Y,this.shim.path.extname(Y));this.addHandler(Q)}}}}addHandler(D,u,F,E,C,B){let $=[],G=m2(C);if(E=E||(()=>{}),Array.isArray(D))if(G6(D))[D,...$]=D;else for(let z of D)this.addHandler(z);else if(Z6(D)){let z=Array.isArray(D.command)||typeof D.command==="string"?D.command:null;if(z===null)throw Error(`No command name given for module: ${this.shim.inspect(D)}`);if(D.aliases)z=[].concat(z).concat(D.aliases);this.addHandler(z,this.extractDesc(D),D.builder,D.handler,D.middlewares,D.deprecated);return}else if(c2(F)){this.addHandler([D].concat($),u,F.builder,F.handler,F.middlewares,F.deprecated);return}if(typeof D==="string"){let z=cD(D);$=$.map((J)=>cD(J).cmd);let Z=!1,Y=[z.cmd].concat($).filter((J)=>{if(Uu.test(J))return Z=!0,!1;return!0});if(Y.length===0&&Z)Y.push("$0");if(Z)z.cmd=Y[0],$=Y.slice(1),D=D.replace(Uu,z.cmd);if($.forEach((J)=>{this.aliasMap[J]=z.cmd}),u!==!1)this.usage.command(D,u,Z,$,B);if(this.handlers[z.cmd]={original:D,description:u,handler:E,builder:F||{},middlewares:G,deprecated:B,demanded:z.demanded,optional:z.optional},Z)this.defaultCommand=this.handlers[z.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(D,u,F,E,C,B){let $=this.handlers[D]||this.handlers[this.aliasMap[D]]||this.defaultCommand,G=u.getInternalMethods().getContext(),z=G.commands.slice(),Z=!D;if(D)G.commands.push(D),G.fullCommands.push($.original);let Y=this.applyBuilderUpdateUsageAndParse(Z,$,u,F.aliases,z,E,C,B);return s(Y)?Y.then((J)=>this.applyMiddlewareAndGetResult(Z,$,J.innerArgv,G,C,J.aliases,u)):this.applyMiddlewareAndGetResult(Z,$,Y.innerArgv,G,C,Y.aliases,u)}applyBuilderUpdateUsageAndParse(D,u,F,E,C,B,$,G){let z=u.builder,Z=F;if(su(z)){F.getInternalMethods().getUsageInstance().freeze();let Y=z(F.getInternalMethods().reset(E),G);if(s(Y))return Y.then((J)=>{return Z=d2(J)?J:F,this.parseAndUpdateUsage(D,u,Z,C,B,$)})}else if(z6(z))F.getInternalMethods().getUsageInstance().freeze(),Z=F.getInternalMethods().reset(E),Object.keys(u.builder).forEach((Y)=>{Z.option(Y,z[Y])});return this.parseAndUpdateUsage(D,u,Z,C,B,$)}parseAndUpdateUsage(D,u,F,E,C,B){if(D)F.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(F))F.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(E,u),u.description);let $=F.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,C,B);return s($)?$.then((G)=>({aliases:F.parsed.aliases,innerArgv:G})):{aliases:F.parsed.aliases,innerArgv:$}}shouldUpdateUsage(D){return!D.getInternalMethods().getUsageInstance().getUsageDisabled()&&D.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(D,u){let F=Uu.test(u.original)?u.original.replace(Uu,"").trim():u.original,E=D.filter((C)=>{return!Uu.test(C)});return E.push(F),`$0 ${E.join(" ")}`}handleValidationAndGetResult(D,u,F,E,C,B,$,G){if(!B.getInternalMethods().getHasOutput()){let z=B.getInternalMethods().runValidation(C,G,B.parsed.error,D);F=eD(F,(Z)=>{return z(Z),Z})}if(u.handler&&!B.getInternalMethods().getHasOutput()){B.getInternalMethods().setHasOutput();let z=!!B.getOptions().configuration["populate--"];if(B.getInternalMethods().postProcess(F,z,!1,!1),F=aD(F,B,$,!1),F=eD(F,(Z)=>{let Y=u.handler(Z);return s(Y)?Y.then(()=>Z):Z}),!D)B.getInternalMethods().getUsageInstance().cacheHelpMessage();if(s(F)&&!B.getInternalMethods().hasParseCallback())F.catch((Z)=>{try{B.getInternalMethods().getUsageInstance().fail(null,Z)}catch(Y){}})}if(!D)E.commands.pop(),E.fullCommands.pop();return F}applyMiddlewareAndGetResult(D,u,F,E,C,B,$){let G={};if(C)return F;if(!$.getInternalMethods().getHasOutput())G=this.populatePositionals(u,F,E,$);let z=this.globalMiddleware.getMiddleware().slice(0).concat(u.middlewares),Z=aD(F,$,z,!0);return s(Z)?Z.then((Y)=>this.handleValidationAndGetResult(D,u,Y,E,B,$,z,G)):this.handleValidationAndGetResult(D,u,Z,E,B,$,z,G)}populatePositionals(D,u,F,E){u._=u._.slice(F.commands.length);let C=D.demanded.slice(0),B=D.optional.slice(0),$={};this.validation.positionalCount(C.length,u._.length);while(C.length){let G=C.shift();this.populatePositional(G,u,$)}while(B.length){let G=B.shift();this.populatePositional(G,u,$)}return u._=F.commands.concat(u._.map((G)=>""+G)),this.postProcessPositionals(u,$,this.cmdToParseOptions(D.original),E),$}populatePositional(D,u,F){let E=D.cmd[0];if(D.variadic)F[E]=u._.splice(0).map(String);else if(u._.length)F[E]=[String(u._.shift())]}cmdToParseOptions(D){let u={array:[],default:{},alias:{},demand:{}},F=cD(D);return F.demanded.forEach((E)=>{let[C,...B]=E.cmd;if(E.variadic)u.array.push(C),u.default[C]=[];u.alias[C]=B,u.demand[C]=!0}),F.optional.forEach((E)=>{let[C,...B]=E.cmd;if(E.variadic)u.array.push(C),u.default[C]=[];u.alias[C]=B}),u}postProcessPositionals(D,u,F,E){let C=Object.assign({},E.getOptions());C.default=Object.assign(F.default,C.default);for(let z of Object.keys(F.alias))C.alias[z]=(C.alias[z]||[]).concat(F.alias[z]);C.array=C.array.concat(F.array),C.config={};let B=[];if(Object.keys(u).forEach((z)=>{u[z].map((Z)=>{if(C.configuration["unknown-options-as-args"])C.key[z]=!0;B.push(`--${z}`),B.push(Z)})}),!B.length)return;let $=Object.assign({},C.configuration,{"populate--":!1}),G=this.shim.Parser.detailed(B,Object.assign({},C,{configuration:$}));if(G.error)E.getInternalMethods().getUsageInstance().fail(G.error.message,G.error);else{let z=Object.keys(u);Object.keys(u).forEach((Z)=>{z.push(...G.aliases[Z])}),Object.keys(G.argv).forEach((Z)=>{if(z.includes(Z)){if(!u[Z])u[Z]=G.argv[Z];if(!this.isInConfigs(E,Z)&&!this.isDefaulted(E,Z)&&Object.prototype.hasOwnProperty.call(D,Z)&&Object.prototype.hasOwnProperty.call(G.argv,Z)&&(Array.isArray(D[Z])||Array.isArray(G.argv[Z])))D[Z]=[].concat(D[Z],G.argv[Z]);else D[Z]=G.argv[Z]}})}}isDefaulted(D,u){let{default:F}=D.getOptions();return Object.prototype.hasOwnProperty.call(F,u)||Object.prototype.hasOwnProperty.call(F,this.shim.Parser.camelCase(u))}isInConfigs(D,u){let{configObjects:F}=D.getOptions();return F.some((E)=>Object.prototype.hasOwnProperty.call(E,u))||F.some((E)=>Object.prototype.hasOwnProperty.call(E,this.shim.Parser.camelCase(u)))}runDefaultBuilderOn(D){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(D)){let F=Uu.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");D.getInternalMethods().getUsageInstance().usage(F,this.defaultCommand.description)}let u=this.defaultCommand.builder;if(su(u))return u(D,!0);else if(!c2(u))Object.keys(u).forEach((F)=>{D.option(F,u[F])});return}extractDesc({describe:D,description:u,desc:F}){for(let E of[D,u,F]){if(typeof E==="string"||E===!1)return E;WD(E,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let D=this.frozens.pop();WD(D,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=D}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function k2(D,u,F,E){return new g2(D,u,F,E)}function c2(D){return typeof D==="object"&&!!D.builder&&typeof D.handler==="function"}function G6(D){return D.every((u)=>typeof u==="string")}function su(D){return typeof D==="function"}function z6(D){return typeof D==="object"}function Z6(D){return typeof D==="object"&&!Array.isArray(D)}function gD(D={},u=()=>!0){let F={};return qu(D).forEach((E)=>{if(u(E,D[E]))F[E]=D[E]}),F}function kD(D){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((u)=>{let F=u;if(F._handle&&F.isTTY&&typeof F._handle.setBlocking==="function")F._handle.setBlocking(D)})}function J6(D){return typeof D==="boolean"}function n2(D,u){let F=u.y18n.__,E={},C=[];E.failFn=function(A){C.push(A)};let B=null,$=null,G=!0;E.showHelpOnFail=function(A=!0,x){let[p,n]=typeof A==="string"?[!0,A]:[A,x];if(D.getInternalMethods().isGlobalContext())$=n;return B=n,G=p,E};let z=!1;E.fail=function(A,x){let p=D.getInternalMethods().getLoggerInstance();if(C.length)for(let n=C.length-1;n>=0;--n){let BD=C[n];if(J6(BD)){if(x)throw x;else if(A)throw Error(A)}else BD(A,x,E)}else{if(D.getExitProcess())kD(!0);if(!z){if(z=!0,G)D.showHelp("error"),p.error();if(A||x)p.error(A||x);let n=B||$;if(n){if(A||x)p.error("");p.error(n)}}if(x=x||new FD(A),D.getExitProcess())return D.exit(1);else if(D.getInternalMethods().hasParseCallback())return D.exit(1,x);else throw x}};let Z=[],Y=!1;E.usage=(P,A)=>{if(P===null)return Y=!0,Z=[],E;return Y=!1,Z.push([P,A||""]),E},E.getUsage=()=>{return Z},E.getUsageDisabled=()=>{return Y},E.getPositionalGroupName=()=>{return F("Positionals:")};let J=[];E.example=(P,A)=>{J.push([P,A||""])};let Q=[];E.command=function(A,x,p,n,BD=!1){if(p)Q=Q.map((d)=>{return d[2]=!1,d});Q.push([A,x||"",p,n,BD])},E.getCommands=()=>Q;let O={};E.describe=function(A,x){if(Array.isArray(A))A.forEach((p)=>{E.describe(p,x)});else if(typeof A==="object")Object.keys(A).forEach((p)=>{E.describe(p,A[p])});else O[A]=x},E.getDescriptions=()=>O;let V=[];E.epilog=(P)=>{V.push(P)};let W=!1,M;E.wrap=(P)=>{W=!0,M=P},E.getWrap=()=>{if(u.getEnv("YARGS_DISABLE_WRAP"))return null;if(!W)M=_D(),W=!0;return M};let _="__yargsString__:";E.deferY18nLookup=(P)=>_+P,E.help=function(){if(w)return w;k();let A=D.customScriptName?D.$0:u.path.basename(D.$0),x=D.getDemandedOptions(),p=D.getDemandedCommands(),n=D.getDeprecatedOptions(),BD=D.getGroups(),d=D.getOptions(),$D=[];$D=$D.concat(Object.keys(O)),$D=$D.concat(Object.keys(x)),$D=$D.concat(Object.keys(p)),$D=$D.concat(Object.keys(d.default)),$D=$D.filter(e),$D=Object.keys($D.reduce((h,l)=>{if(l!=="_")h[l]=!0;return h},{}));let mD=E.getWrap(),t=u.cliui({width:mD,wrap:!!mD});if(!Y){if(Z.length)Z.forEach((h)=>{if(t.div({text:`${h[0].replace(/\$0/g,A)}`}),h[1])t.div({text:`${h[1]}`,padding:[1,0,0,0]})}),t.div();else if(Q.length){let h=null;if(p._)h=`${A} <${F("command")}>
15
15
  `;else h=`${A} [${F("command")}]
16
- `;t.div(`${h}`)}}if(Q.length>1||Q.length===1&&!Q[0][2]){t.div(F("Commands:"));let h=D.getInternalMethods().getContext(),l=h.commands.length?`${h.commands.join(" ")} `:"";if(D.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)Q=Q.sort((g,QD)=>g[0].localeCompare(QD[0]));let GD=A?`${A} `:"";Q.forEach((g)=>{let QD=`${GD}${l}${g[0].replace(/^\$0 ?/,"")}`;t.span({text:QD,padding:[0,2,0,2],width:N(Q,yD,`${A}${l}`)+4},{text:g[1]});let uD=[];if(g[2])uD.push(`[${F("default")}]`);if(g[3]&&g[3].length)uD.push(`[${F("aliases:")} ${g[3].join(", ")}]`);if(g[4])if(typeof g[4]==="string")uD.push(`[${F("deprecated: %s",g[4])}]`);else uD.push(`[${F("deprecated")}]`);if(uD.length)t.div({text:uD.join(" "),padding:[0,0,0,2],align:"right"});else t.div()}),t.div()}let hD=(Object.keys(d.alias)||[]).concat(Object.keys(D.parsed.newAliases)||[]);$D=$D.filter((h)=>!D.parsed.newAliases[h]&&hD.every((l)=>(d.alias[l]||[]).indexOf(h)===-1));let Nu=F("Options:");if(!BD[Nu])BD[Nu]=[];c($D,d.alias,BD,Nu);let f=(h)=>/^--/.test(su(h)),Hu=Object.keys(BD).filter((h)=>BD[h].length>0).map((h)=>{let l=BD[h].filter(e).map((GD)=>{if(hD.includes(GD))return GD;for(let g=0,QD;(QD=hD[g])!==void 0;g++)if((d.alias[QD]||[]).includes(GD))return QD;return GD});return{groupName:h,normalizedKeys:l}}).filter(({normalizedKeys:h})=>h.length>0).map(({groupName:h,normalizedKeys:l})=>{let GD=l.reduce((g,QD)=>{return g[QD]=[QD].concat(d.alias[QD]||[]).map((uD)=>{if(h===E.getPositionalGroupName())return uD;else return(/^[0-9]$/.test(uD)?d.boolean.includes(QD)?"-":"--":uD.length>1?"--":"-")+uD}).sort((uD,zD)=>f(uD)===f(zD)?0:f(uD)?1:-1).join(", "),g},{});return{groupName:h,normalizedKeys:l,switches:GD}});if(Hu.filter(({groupName:h})=>h!==E.getPositionalGroupName()).some(({normalizedKeys:h,switches:l})=>!h.every((GD)=>f(l[GD]))))Hu.filter(({groupName:h})=>h!==E.getPositionalGroupName()).forEach(({normalizedKeys:h,switches:l})=>{h.forEach((GD)=>{if(f(l[GD]))l[GD]=X6(l[GD],4)})});if(Hu.forEach(({groupName:h,normalizedKeys:l,switches:GD})=>{t.div(h),l.forEach((g)=>{let QD=GD[g],uD=O[g]||"",zD=null;if(uD.includes(_))uD=F(uD.substring(_.length));if(d.boolean.includes(g))zD=`[${F("boolean")}]`;if(d.count.includes(g))zD=`[${F("count")}]`;if(d.string.includes(g))zD=`[${F("string")}]`;if(d.normalize.includes(g))zD=`[${F("string")}]`;if(d.array.includes(g))zD=`[${F("array")}]`;if(d.number.includes(g))zD=`[${F("number")}]`;let TF=(j)=>typeof j==="string"?`[${F("deprecated: %s",j)}]`:`[${F("deprecated")}]`,H=[g in n?TF(n[g]):null,zD,g in x?`[${F("required")}]`:null,d.choices&&d.choices[g]?`[${F("choices:")} ${E.stringifiedValues(d.choices[g])}]`:null,r(d.default[g],d.defaultDescription[g])].filter(Boolean).join(" ");t.span({text:su(QD),padding:[0,2,0,2+i2(QD)],width:N(GD,yD)+4},uD);let U=D.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(H&&!U)t.div({text:H,padding:[0,0,0,2],align:"right"});else t.div()}),t.div()}),J.length)t.div(F("Examples:")),J.forEach((h)=>{h[0]=h[0].replace(/\$0/g,A)}),J.forEach((h)=>{if(h[1]==="")t.div({text:h[0],padding:[0,2,0,2]});else t.div({text:h[0],padding:[0,2,0,2],width:N(J,yD)+4},{text:h[1]})}),t.div();if(V.length>0){let h=V.map((l)=>l.replace(/\$0/g,A)).join(`
16
+ `;t.div(`${h}`)}}if(Q.length>1||Q.length===1&&!Q[0][2]){t.div(F("Commands:"));let h=D.getInternalMethods().getContext(),l=h.commands.length?`${h.commands.join(" ")} `:"";if(D.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)Q=Q.sort((g,QD)=>g[0].localeCompare(QD[0]));let GD=A?`${A} `:"";Q.forEach((g)=>{let QD=`${GD}${l}${g[0].replace(/^\$0 ?/,"")}`;t.span({text:QD,padding:[0,2,0,2],width:N(Q,mD,`${A}${l}`)+4},{text:g[1]});let uD=[];if(g[2])uD.push(`[${F("default")}]`);if(g[3]&&g[3].length)uD.push(`[${F("aliases:")} ${g[3].join(", ")}]`);if(g[4])if(typeof g[4]==="string")uD.push(`[${F("deprecated: %s",g[4])}]`);else uD.push(`[${F("deprecated")}]`);if(uD.length)t.div({text:uD.join(" "),padding:[0,0,0,2],align:"right"});else t.div()}),t.div()}let hD=(Object.keys(d.alias)||[]).concat(Object.keys(D.parsed.newAliases)||[]);$D=$D.filter((h)=>!D.parsed.newAliases[h]&&hD.every((l)=>(d.alias[l]||[]).indexOf(h)===-1));let Nu=F("Options:");if(!BD[Nu])BD[Nu]=[];c($D,d.alias,BD,Nu);let f=(h)=>/^--/.test(ru(h)),Hu=Object.keys(BD).filter((h)=>BD[h].length>0).map((h)=>{let l=BD[h].filter(e).map((GD)=>{if(hD.includes(GD))return GD;for(let g=0,QD;(QD=hD[g])!==void 0;g++)if((d.alias[QD]||[]).includes(GD))return QD;return GD});return{groupName:h,normalizedKeys:l}}).filter(({normalizedKeys:h})=>h.length>0).map(({groupName:h,normalizedKeys:l})=>{let GD=l.reduce((g,QD)=>{return g[QD]=[QD].concat(d.alias[QD]||[]).map((uD)=>{if(h===E.getPositionalGroupName())return uD;else return(/^[0-9]$/.test(uD)?d.boolean.includes(QD)?"-":"--":uD.length>1?"--":"-")+uD}).sort((uD,zD)=>f(uD)===f(zD)?0:f(uD)?1:-1).join(", "),g},{});return{groupName:h,normalizedKeys:l,switches:GD}});if(Hu.filter(({groupName:h})=>h!==E.getPositionalGroupName()).some(({normalizedKeys:h,switches:l})=>!h.every((GD)=>f(l[GD]))))Hu.filter(({groupName:h})=>h!==E.getPositionalGroupName()).forEach(({normalizedKeys:h,switches:l})=>{h.forEach((GD)=>{if(f(l[GD]))l[GD]=X6(l[GD],4)})});if(Hu.forEach(({groupName:h,normalizedKeys:l,switches:GD})=>{t.div(h),l.forEach((g)=>{let QD=GD[g],uD=O[g]||"",zD=null;if(uD.includes(_))uD=F(uD.substring(_.length));if(d.boolean.includes(g))zD=`[${F("boolean")}]`;if(d.count.includes(g))zD=`[${F("count")}]`;if(d.string.includes(g))zD=`[${F("string")}]`;if(d.normalize.includes(g))zD=`[${F("string")}]`;if(d.array.includes(g))zD=`[${F("array")}]`;if(d.number.includes(g))zD=`[${F("number")}]`;let TF=(j)=>typeof j==="string"?`[${F("deprecated: %s",j)}]`:`[${F("deprecated")}]`,H=[g in n?TF(n[g]):null,zD,g in x?`[${F("required")}]`:null,d.choices&&d.choices[g]?`[${F("choices:")} ${E.stringifiedValues(d.choices[g])}]`:null,r(d.default[g],d.defaultDescription[g])].filter(Boolean).join(" ");t.span({text:ru(QD),padding:[0,2,0,2+i2(QD)],width:N(GD,mD)+4},uD);let U=D.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(H&&!U)t.div({text:H,padding:[0,0,0,2],align:"right"});else t.div()}),t.div()}),J.length)t.div(F("Examples:")),J.forEach((h)=>{h[0]=h[0].replace(/\$0/g,A)}),J.forEach((h)=>{if(h[1]==="")t.div({text:h[0],padding:[0,2,0,2]});else t.div({text:h[0],padding:[0,2,0,2],width:N(J,mD)+4},{text:h[1]})}),t.div();if(V.length>0){let h=V.map((l)=>l.replace(/\$0/g,A)).join(`
17
17
  `);t.div(`${h}
18
- `)}return t.toString().replace(/\s*$/,"")};function N(P,A,x){let p=0;if(!Array.isArray(P))P=Object.values(P).map((n)=>[n]);if(P.forEach((n)=>{p=Math.max(u.stringWidth(x?`${x} ${su(n[0])}`:su(n[0]))+i2(n[0]),p)}),A)p=Math.min(p,parseInt((A*0.5).toString(),10));return p}function k(){let P=D.getDemandedOptions(),A=D.getOptions();(Object.keys(A.alias)||[]).forEach((x)=>{A.alias[x].forEach((p)=>{if(O[p])E.describe(x,O[p]);if(p in P)D.demandOption(x,P[p]);if(A.boolean.includes(p))D.boolean(x);if(A.count.includes(p))D.count(x);if(A.string.includes(p))D.string(x);if(A.normalize.includes(p))D.normalize(x);if(A.array.includes(p))D.array(x);if(A.number.includes(p))D.number(x)})})}let w;E.cacheHelpMessage=function(){w=this.help()},E.clearCachedHelpMessage=function(){w=void 0},E.hasCachedHelpMessage=function(){return!!w};function c(P,A,x,p){let n=[],BD=null;return Object.keys(x).forEach((d)=>{n=n.concat(x[d])}),P.forEach((d)=>{if(BD=[d].concat(A[d]),!BD.some(($D)=>n.indexOf($D)!==-1))x[p].push(d)}),n}function e(P){return D.getOptions().hiddenOptions.indexOf(P)<0||D.parsed.argv[D.getOptions().showHiddenOpt]}E.showHelp=(P)=>{let A=D.getInternalMethods().getLoggerInstance();if(!P)P="error";(typeof P==="function"?P:A[P])(E.help())},E.functionDescription=(P)=>{return["(",P.name?u.Parser.decamelize(P.name,"-"):F("generated-value"),")"].join("")},E.stringifiedValues=function(A,x){let p="",n=x||", ",BD=[].concat(A);if(!A||!BD.length)return p;return BD.forEach((d)=>{if(p.length)p+=n;p+=JSON.stringify(d)}),p};function r(P,A){let x=`[${F("default:")} `;if(P===void 0&&!A)return null;if(A)x+=A;else switch(typeof P){case"string":x+=`"${P}"`;break;case"object":x+=JSON.stringify(P);break;default:x+=P}return`${x}]`}function _D(){if(u.process.stdColumns)return Math.min(80,u.process.stdColumns);else return 80}let i=null;E.version=(P)=>{i=P},E.showVersion=(P)=>{let A=D.getInternalMethods().getLoggerInstance();if(!P)P="error";(typeof P==="function"?P:A[P])(i)},E.reset=function(A){return B=null,Z=!1,z=[],Y=!1,V=[],J=[],Q=[],O=gD(O,(x)=>!A[x]),E};let oD=[];return E.freeze=function(){oD.push({failMessage:B,failureOutput:Z,usages:z,usageDisabled:Y,epilogs:V,examples:J,commands:Q,descriptions:O})},E.unfreeze=function(A=!1){let x=oD.pop();if(!x)return;if(A)O={...x.descriptions,...O},Q=[...x.commands,...Q],z=[...x.usages,...z],J=[...x.examples,...J],V=[...x.epilogs,...V];else({failMessage:B,failureOutput:Z,usages:z,usageDisabled:Y,epilogs:V,examples:J,commands:Q,descriptions:O}=x)},E}function nF(D){return typeof D==="object"}function X6(D,u){return nF(D)?{text:D.text,indentation:D.indentation+u}:{text:D,indentation:u}}function i2(D){return nF(D)?D.indentation:0}function su(D){return nF(D)?D.text:D}var l2=`###-begin-{{app_name}}-completions-###
18
+ `)}return t.toString().replace(/\s*$/,"")};function N(P,A,x){let p=0;if(!Array.isArray(P))P=Object.values(P).map((n)=>[n]);if(P.forEach((n)=>{p=Math.max(u.stringWidth(x?`${x} ${ru(n[0])}`:ru(n[0]))+i2(n[0]),p)}),A)p=Math.min(p,parseInt((A*0.5).toString(),10));return p}function k(){let P=D.getDemandedOptions(),A=D.getOptions();(Object.keys(A.alias)||[]).forEach((x)=>{A.alias[x].forEach((p)=>{if(O[p])E.describe(x,O[p]);if(p in P)D.demandOption(x,P[p]);if(A.boolean.includes(p))D.boolean(x);if(A.count.includes(p))D.count(x);if(A.string.includes(p))D.string(x);if(A.normalize.includes(p))D.normalize(x);if(A.array.includes(p))D.array(x);if(A.number.includes(p))D.number(x)})})}let w;E.cacheHelpMessage=function(){w=this.help()},E.clearCachedHelpMessage=function(){w=void 0},E.hasCachedHelpMessage=function(){return!!w};function c(P,A,x,p){let n=[],BD=null;return Object.keys(x).forEach((d)=>{n=n.concat(x[d])}),P.forEach((d)=>{if(BD=[d].concat(A[d]),!BD.some(($D)=>n.indexOf($D)!==-1))x[p].push(d)}),n}function e(P){return D.getOptions().hiddenOptions.indexOf(P)<0||D.parsed.argv[D.getOptions().showHiddenOpt]}E.showHelp=(P)=>{let A=D.getInternalMethods().getLoggerInstance();if(!P)P="error";(typeof P==="function"?P:A[P])(E.help())},E.functionDescription=(P)=>{return["(",P.name?u.Parser.decamelize(P.name,"-"):F("generated-value"),")"].join("")},E.stringifiedValues=function(A,x){let p="",n=x||", ",BD=[].concat(A);if(!A||!BD.length)return p;return BD.forEach((d)=>{if(p.length)p+=n;p+=JSON.stringify(d)}),p};function r(P,A){let x=`[${F("default:")} `;if(P===void 0&&!A)return null;if(A)x+=A;else switch(typeof P){case"string":x+=`"${P}"`;break;case"object":x+=JSON.stringify(P);break;default:x+=P}return`${x}]`}function _D(){if(u.process.stdColumns)return Math.min(80,u.process.stdColumns);else return 80}let i=null;E.version=(P)=>{i=P},E.showVersion=(P)=>{let A=D.getInternalMethods().getLoggerInstance();if(!P)P="error";(typeof P==="function"?P:A[P])(i)},E.reset=function(A){return B=null,z=!1,Z=[],Y=!1,V=[],J=[],Q=[],O=gD(O,(x)=>!A[x]),E};let oD=[];return E.freeze=function(){oD.push({failMessage:B,failureOutput:z,usages:Z,usageDisabled:Y,epilogs:V,examples:J,commands:Q,descriptions:O})},E.unfreeze=function(A=!1){let x=oD.pop();if(!x)return;if(A)O={...x.descriptions,...O},Q=[...x.commands,...Q],Z=[...x.usages,...Z],J=[...x.examples,...J],V=[...x.epilogs,...V];else({failMessage:B,failureOutput:z,usages:Z,usageDisabled:Y,epilogs:V,examples:J,commands:Q,descriptions:O}=x)},E}function nF(D){return typeof D==="object"}function X6(D,u){return nF(D)?{text:D.text,indentation:D.indentation+u}:{text:D,indentation:u}}function i2(D){return nF(D)?D.indentation:0}function ru(D){return nF(D)?D.text:D}var l2=`###-begin-{{app_name}}-completions-###
19
19
  #
20
20
  # yargs command completion script
21
21
  #
@@ -71,89 +71,96 @@ else
71
71
  compdef _{{app_name}}_yargs_completions {{app_name}}
72
72
  fi
73
73
  ###-end-{{app_name}}-completions-###
74
- `;class o2{constructor(D,u,F,E){var C,B,$;this.yargs=D,this.usage=u,this.command=F,this.shim=E,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=($=((C=this.shim.getEnv("SHELL"))===null||C===void 0?void 0:C.includes("zsh"))||((B=this.shim.getEnv("ZSH_NAME"))===null||B===void 0?void 0:B.includes("zsh")))!==null&&$!==void 0?$:!1}defaultCompletion(D,u,F,E){let C=this.command.getCommandHandlers();for(let $=0,G=D.length;$<G;++$)if(C[D[$]]&&C[D[$]].builder){let Z=C[D[$]].builder;if(ou(Z)){this.indexAfterLastReset=$+1;let z=this.yargs.getInternalMethods().reset();return Z(z,!0),z.argv}}let B=[];this.commandCompletions(B,D,F),this.optionCompletions(B,D,u,F),this.choicesFromOptionsCompletions(B,D,u,F),this.choicesFromPositionalsCompletions(B,D,u,F),E(null,B)}commandCompletions(D,u,F){let E=this.yargs.getInternalMethods().getContext().commands;if(!F.match(/^-/)&&E[E.length-1]!==F&&!this.previousArgHasChoices(u))this.usage.getCommands().forEach((C)=>{let B=cD(C[0]).cmd;if(u.indexOf(B)===-1)if(!this.zshShell)D.push(B);else{let $=C[1]||"";D.push(B.replace(/:/g,"\\:")+":"+$)}})}optionCompletions(D,u,F,E){if((E.match(/^-/)||E===""&&D.length===0)&&!this.previousArgHasChoices(u)){let C=this.yargs.getOptions(),B=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(C.key).forEach(($)=>{let G=!!C.configuration["boolean-negation"]&&C.boolean.includes($);if(!B.includes($)&&!C.hiddenOptions.includes($)&&!this.argsContainKey(u,$,G))this.completeOptionKey($,D,E,G&&!!C.default[$])})}}choicesFromOptionsCompletions(D,u,F,E){if(this.previousArgHasChoices(u)){let C=this.getPreviousArgChoices(u);if(C&&C.length>0)D.push(...C.map((B)=>B.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(D,u,F,E){if(E===""&&D.length>0&&this.previousArgHasChoices(u))return;let C=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],B=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),$=C[F._.length-B-1];if(!$)return;let G=this.yargs.getOptions().choices[$]||[];for(let Z of G)if(Z.startsWith(E))D.push(Z.replace(/:/g,"\\:"))}getPreviousArgChoices(D){if(D.length<1)return;let u=D[D.length-1],F="";if(!u.startsWith("-")&&D.length>1)F=u,u=D[D.length-2];if(!u.startsWith("-"))return;let E=u.replace(/^-+/,""),C=this.yargs.getOptions(),B=[E,...this.yargs.getAliases()[E]||[]],$;for(let G of B)if(Object.prototype.hasOwnProperty.call(C.key,G)&&Array.isArray(C.choices[G])){$=C.choices[G];break}if($)return $.filter((G)=>!F||G.startsWith(F))}previousArgHasChoices(D){let u=this.getPreviousArgChoices(D);return u!==void 0&&u.length>0}argsContainKey(D,u,F){let E=(C)=>D.indexOf((/^[^0-9]$/.test(C)?"-":"--")+C)!==-1;if(E(u))return!0;if(F&&E(`no-${u}`))return!0;if(this.aliases){for(let C of this.aliases[u])if(E(C))return!0}return!1}completeOptionKey(D,u,F,E){var C,B,$,G;let Z=D;if(this.zshShell){let Q=this.usage.getDescriptions(),O=(B=(C=this===null||this===void 0?void 0:this.aliases)===null||C===void 0?void 0:C[D])===null||B===void 0?void 0:B.find((M)=>{let _=Q[M];return typeof _==="string"&&_.length>0}),V=O?Q[O]:void 0,W=(G=($=Q[D])!==null&&$!==void 0?$:V)!==null&&G!==void 0?G:"";Z=`${D.replace(/:/g,"\\:")}:${W.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let z=(Q)=>/^--/.test(Q),Y=(Q)=>/^[^0-9]$/.test(Q),J=!z(F)&&Y(D)?"-":"--";if(u.push(J+Z),E)u.push(J+"no-"+Z)}customCompletion(D,u,F,E){if(WD(this.customCompletionFunction,null,this.shim),Y6(this.customCompletionFunction)){let C=this.customCompletionFunction(F,u);if(s(C))return C.then((B)=>{this.shim.process.nextTick(()=>{E(null,B)})}).catch((B)=>{this.shim.process.nextTick(()=>{E(B,void 0)})});return E(null,C)}else if(W6(this.customCompletionFunction))return this.customCompletionFunction(F,u,(C=E)=>this.defaultCompletion(D,u,F,C),(C)=>{E(null,C)});else return this.customCompletionFunction(F,u,(C)=>{E(null,C)})}getCompletion(D,u){let F=D.length?D[D.length-1]:"",E=this.yargs.parse(D,!0),C=this.customCompletionFunction?(B)=>this.customCompletion(D,B,F,u):(B)=>this.defaultCompletion(D,B,F,u);return s(E)?E.then(C):C(E)}generateCompletionScript(D,u){let F=this.zshShell?t2:l2,E=this.shim.path.basename(D);if(D.match(/\.js$/))D=`./${D}`;return F=F.replace(/{{app_name}}/g,E),F=F.replace(/{{completion_command}}/g,u),F.replace(/{{app_path}}/g,D)}registerFunction(D){this.customCompletionFunction=D}setParsed(D){this.aliases=D.aliases}}function s2(D,u,F,E){return new o2(D,u,F,E)}function Y6(D){return D.length<3}function W6(D){return D.length>3}function r2(D,u){if(D.length===0)return u.length;if(u.length===0)return D.length;let F=[],E;for(E=0;E<=u.length;E++)F[E]=[E];let C;for(C=0;C<=D.length;C++)F[0][C]=C;for(E=1;E<=u.length;E++)for(C=1;C<=D.length;C++)if(u.charAt(E-1)===D.charAt(C-1))F[E][C]=F[E-1][C-1];else if(E>1&&C>1&&u.charAt(E-2)===D.charAt(C-1)&&u.charAt(E-1)===D.charAt(C-2))F[E][C]=F[E-2][C-2]+1;else F[E][C]=Math.min(F[E-1][C-1]+1,Math.min(F[E][C-1]+1,F[E-1][C]+1));return F[u.length][D.length]}var a2=["$0","--","_"];function e2(D,u,F){let E=F.y18n.__,C=F.y18n.__n,B={};B.nonOptionCount=function(J){let Q=D.getDemandedCommands(),V=J._.length+(J["--"]?J["--"].length:0)-D.getInternalMethods().getContext().commands.length;if(Q._&&(V<Q._.min||V>Q._.max)){if(V<Q._.min)if(Q._.minMsg!==void 0)u.fail(Q._.minMsg?Q._.minMsg.replace(/\$0/g,V.toString()).replace(/\$1/,Q._.min.toString()):null);else u.fail(C("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",V,V.toString(),Q._.min.toString()));else if(V>Q._.max)if(Q._.maxMsg!==void 0)u.fail(Q._.maxMsg?Q._.maxMsg.replace(/\$0/g,V.toString()).replace(/\$1/,Q._.max.toString()):null);else u.fail(C("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",V,V.toString(),Q._.max.toString()))}},B.positionalCount=function(J,Q){if(Q<J)u.fail(C("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",Q,Q+"",J+""))},B.requiredArguments=function(J,Q){let O=null;for(let V of Object.keys(Q))if(!Object.prototype.hasOwnProperty.call(J,V)||typeof J[V]>"u")O=O||{},O[V]=Q[V];if(O){let V=[];for(let M of Object.keys(O)){let _=O[M];if(_&&V.indexOf(_)<0)V.push(_)}let W=V.length?`
74
+ `;class o2{constructor(D,u,F,E){var C,B,$;this.yargs=D,this.usage=u,this.command=F,this.shim=E,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=($=((C=this.shim.getEnv("SHELL"))===null||C===void 0?void 0:C.includes("zsh"))||((B=this.shim.getEnv("ZSH_NAME"))===null||B===void 0?void 0:B.includes("zsh")))!==null&&$!==void 0?$:!1}defaultCompletion(D,u,F,E){let C=this.command.getCommandHandlers();for(let $=0,G=D.length;$<G;++$)if(C[D[$]]&&C[D[$]].builder){let z=C[D[$]].builder;if(su(z)){this.indexAfterLastReset=$+1;let Z=this.yargs.getInternalMethods().reset();return z(Z,!0),Z.argv}}let B=[];this.commandCompletions(B,D,F),this.optionCompletions(B,D,u,F),this.choicesFromOptionsCompletions(B,D,u,F),this.choicesFromPositionalsCompletions(B,D,u,F),E(null,B)}commandCompletions(D,u,F){let E=this.yargs.getInternalMethods().getContext().commands;if(!F.match(/^-/)&&E[E.length-1]!==F&&!this.previousArgHasChoices(u))this.usage.getCommands().forEach((C)=>{let B=cD(C[0]).cmd;if(u.indexOf(B)===-1)if(!this.zshShell)D.push(B);else{let $=C[1]||"";D.push(B.replace(/:/g,"\\:")+":"+$)}})}optionCompletions(D,u,F,E){if((E.match(/^-/)||E===""&&D.length===0)&&!this.previousArgHasChoices(u)){let C=this.yargs.getOptions(),B=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(C.key).forEach(($)=>{let G=!!C.configuration["boolean-negation"]&&C.boolean.includes($);if(!B.includes($)&&!C.hiddenOptions.includes($)&&!this.argsContainKey(u,$,G))this.completeOptionKey($,D,E,G&&!!C.default[$])})}}choicesFromOptionsCompletions(D,u,F,E){if(this.previousArgHasChoices(u)){let C=this.getPreviousArgChoices(u);if(C&&C.length>0)D.push(...C.map((B)=>B.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(D,u,F,E){if(E===""&&D.length>0&&this.previousArgHasChoices(u))return;let C=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],B=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),$=C[F._.length-B-1];if(!$)return;let G=this.yargs.getOptions().choices[$]||[];for(let z of G)if(z.startsWith(E))D.push(z.replace(/:/g,"\\:"))}getPreviousArgChoices(D){if(D.length<1)return;let u=D[D.length-1],F="";if(!u.startsWith("-")&&D.length>1)F=u,u=D[D.length-2];if(!u.startsWith("-"))return;let E=u.replace(/^-+/,""),C=this.yargs.getOptions(),B=[E,...this.yargs.getAliases()[E]||[]],$;for(let G of B)if(Object.prototype.hasOwnProperty.call(C.key,G)&&Array.isArray(C.choices[G])){$=C.choices[G];break}if($)return $.filter((G)=>!F||G.startsWith(F))}previousArgHasChoices(D){let u=this.getPreviousArgChoices(D);return u!==void 0&&u.length>0}argsContainKey(D,u,F){let E=(C)=>D.indexOf((/^[^0-9]$/.test(C)?"-":"--")+C)!==-1;if(E(u))return!0;if(F&&E(`no-${u}`))return!0;if(this.aliases){for(let C of this.aliases[u])if(E(C))return!0}return!1}completeOptionKey(D,u,F,E){var C,B,$,G;let z=D;if(this.zshShell){let Q=this.usage.getDescriptions(),O=(B=(C=this===null||this===void 0?void 0:this.aliases)===null||C===void 0?void 0:C[D])===null||B===void 0?void 0:B.find((M)=>{let _=Q[M];return typeof _==="string"&&_.length>0}),V=O?Q[O]:void 0,W=(G=($=Q[D])!==null&&$!==void 0?$:V)!==null&&G!==void 0?G:"";z=`${D.replace(/:/g,"\\:")}:${W.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let Z=(Q)=>/^--/.test(Q),Y=(Q)=>/^[^0-9]$/.test(Q),J=!Z(F)&&Y(D)?"-":"--";if(u.push(J+z),E)u.push(J+"no-"+z)}customCompletion(D,u,F,E){if(WD(this.customCompletionFunction,null,this.shim),Y6(this.customCompletionFunction)){let C=this.customCompletionFunction(F,u);if(s(C))return C.then((B)=>{this.shim.process.nextTick(()=>{E(null,B)})}).catch((B)=>{this.shim.process.nextTick(()=>{E(B,void 0)})});return E(null,C)}else if(W6(this.customCompletionFunction))return this.customCompletionFunction(F,u,(C=E)=>this.defaultCompletion(D,u,F,C),(C)=>{E(null,C)});else return this.customCompletionFunction(F,u,(C)=>{E(null,C)})}getCompletion(D,u){let F=D.length?D[D.length-1]:"",E=this.yargs.parse(D,!0),C=this.customCompletionFunction?(B)=>this.customCompletion(D,B,F,u):(B)=>this.defaultCompletion(D,B,F,u);return s(E)?E.then(C):C(E)}generateCompletionScript(D,u){let F=this.zshShell?t2:l2,E=this.shim.path.basename(D);if(D.match(/\.js$/))D=`./${D}`;return F=F.replace(/{{app_name}}/g,E),F=F.replace(/{{completion_command}}/g,u),F.replace(/{{app_path}}/g,D)}registerFunction(D){this.customCompletionFunction=D}setParsed(D){this.aliases=D.aliases}}function s2(D,u,F,E){return new o2(D,u,F,E)}function Y6(D){return D.length<3}function W6(D){return D.length>3}function r2(D,u){if(D.length===0)return u.length;if(u.length===0)return D.length;let F=[],E;for(E=0;E<=u.length;E++)F[E]=[E];let C;for(C=0;C<=D.length;C++)F[0][C]=C;for(E=1;E<=u.length;E++)for(C=1;C<=D.length;C++)if(u.charAt(E-1)===D.charAt(C-1))F[E][C]=F[E-1][C-1];else if(E>1&&C>1&&u.charAt(E-2)===D.charAt(C-1)&&u.charAt(E-1)===D.charAt(C-2))F[E][C]=F[E-2][C-2]+1;else F[E][C]=Math.min(F[E-1][C-1]+1,Math.min(F[E][C-1]+1,F[E-1][C]+1));return F[u.length][D.length]}var a2=["$0","--","_"];function e2(D,u,F){let E=F.y18n.__,C=F.y18n.__n,B={};B.nonOptionCount=function(J){let Q=D.getDemandedCommands(),V=J._.length+(J["--"]?J["--"].length:0)-D.getInternalMethods().getContext().commands.length;if(Q._&&(V<Q._.min||V>Q._.max)){if(V<Q._.min)if(Q._.minMsg!==void 0)u.fail(Q._.minMsg?Q._.minMsg.replace(/\$0/g,V.toString()).replace(/\$1/,Q._.min.toString()):null);else u.fail(C("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",V,V.toString(),Q._.min.toString()));else if(V>Q._.max)if(Q._.maxMsg!==void 0)u.fail(Q._.maxMsg?Q._.maxMsg.replace(/\$0/g,V.toString()).replace(/\$1/,Q._.max.toString()):null);else u.fail(C("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",V,V.toString(),Q._.max.toString()))}},B.positionalCount=function(J,Q){if(Q<J)u.fail(C("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",Q,Q+"",J+""))},B.requiredArguments=function(J,Q){let O=null;for(let V of Object.keys(Q))if(!Object.prototype.hasOwnProperty.call(J,V)||typeof J[V]>"u")O=O||{},O[V]=Q[V];if(O){let V=[];for(let M of Object.keys(O)){let _=O[M];if(_&&V.indexOf(_)<0)V.push(_)}let W=V.length?`
75
75
  ${V.join(`
76
76
  `)}`:"";u.fail(C("Missing required argument: %s","Missing required arguments: %s",Object.keys(O).length,Object.keys(O).join(", ")+W))}},B.unknownArguments=function(J,Q,O,V,W=!0){var M;let _=D.getInternalMethods().getCommandInstance().getCommands(),N=[],k=D.getInternalMethods().getContext();if(Object.keys(J).forEach((w)=>{if(!a2.includes(w)&&!Object.prototype.hasOwnProperty.call(O,w)&&!Object.prototype.hasOwnProperty.call(D.getInternalMethods().getParseContext(),w)&&!B.isValidAndSomeAliasIsNotNew(w,Q))N.push(w)}),W&&(k.commands.length>0||_.length>0||V))J._.slice(k.commands.length).forEach((w)=>{if(!_.includes(""+w))N.push(""+w)});if(W){let c=((M=D.getDemandedCommands()._)===null||M===void 0?void 0:M.max)||0,e=k.commands.length+c;if(e<J._.length)J._.slice(e).forEach((r)=>{if(r=String(r),!k.commands.includes(r)&&!N.includes(r))N.push(r)})}if(N.length)u.fail(C("Unknown argument: %s","Unknown arguments: %s",N.length,N.map((w)=>w.trim()?w:`"${w}"`).join(", ")))},B.unknownCommands=function(J){let Q=D.getInternalMethods().getCommandInstance().getCommands(),O=[],V=D.getInternalMethods().getContext();if(V.commands.length>0||Q.length>0)J._.slice(V.commands.length).forEach((W)=>{if(!Q.includes(""+W))O.push(""+W)});if(O.length>0)return u.fail(C("Unknown command: %s","Unknown commands: %s",O.length,O.join(", "))),!0;else return!1},B.isValidAndSomeAliasIsNotNew=function(J,Q){if(!Object.prototype.hasOwnProperty.call(Q,J))return!1;let O=D.parsed.newAliases;return[J,...Q[J]].some((V)=>!Object.prototype.hasOwnProperty.call(O,V)||!O[J])},B.limitedChoices=function(J){let Q=D.getOptions(),O={};if(!Object.keys(Q.choices).length)return;Object.keys(J).forEach((M)=>{if(a2.indexOf(M)===-1&&Object.prototype.hasOwnProperty.call(Q.choices,M))[].concat(J[M]).forEach((_)=>{if(Q.choices[M].indexOf(_)===-1&&_!==void 0)O[M]=(O[M]||[]).concat(_)})});let V=Object.keys(O);if(!V.length)return;let W=E("Invalid values:");V.forEach((M)=>{W+=`
77
77
  ${E("Argument: %s, Given: %s, Choices: %s",M,u.stringifiedValues(O[M]),u.stringifiedValues(Q.choices[M]))}`}),u.fail(W)};let $={};B.implies=function(J,Q){if(T("<string|object> [array|number|string]",[J,Q],arguments.length),typeof J==="object")Object.keys(J).forEach((O)=>{B.implies(O,J[O])});else{if(D.global(J),!$[J])$[J]=[];if(Array.isArray(Q))Q.forEach((O)=>B.implies(J,O));else WD(Q,void 0,F),$[J].push(Q)}},B.getImplied=function(){return $};function G(Y,J){let Q=Number(J);if(J=isNaN(Q)?J:Q,typeof J==="number")J=Y._.length>=J;else if(J.match(/^--no-.+/))J=J.match(/^--no-(.+)/)[1],J=!Object.prototype.hasOwnProperty.call(Y,J);else J=Object.prototype.hasOwnProperty.call(Y,J);return J}B.implications=function(J){let Q=[];if(Object.keys($).forEach((O)=>{let V=O;($[O]||[]).forEach((W)=>{let M=V,_=W;if(M=G(J,M),W=G(J,W),M&&!W)Q.push(` ${V} -> ${_}`)})}),Q.length){let O=`${E("Implications failed:")}
78
- `;Q.forEach((V)=>{O+=V}),u.fail(O)}};let Z={};B.conflicts=function(J,Q){if(T("<string|object> [array|string]",[J,Q],arguments.length),typeof J==="object")Object.keys(J).forEach((O)=>{B.conflicts(O,J[O])});else{if(D.global(J),!Z[J])Z[J]=[];if(Array.isArray(Q))Q.forEach((O)=>B.conflicts(J,O));else Z[J].push(Q)}},B.getConflicting=()=>Z,B.conflicting=function(J){if(Object.keys(J).forEach((Q)=>{if(Z[Q])Z[Q].forEach((O)=>{if(O&&J[Q]!==void 0&&J[O]!==void 0)u.fail(E("Arguments %s and %s are mutually exclusive",Q,O))})}),D.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(Z).forEach((Q)=>{Z[Q].forEach((O)=>{if(O&&J[F.Parser.camelCase(Q)]!==void 0&&J[F.Parser.camelCase(O)]!==void 0)u.fail(E("Arguments %s and %s are mutually exclusive",Q,O))})})},B.recommendCommands=function(J,Q){Q=Q.sort((M,_)=>_.length-M.length);let V=null,W=1/0;for(let M=0,_;(_=Q[M])!==void 0;M++){let N=r2(J,_);if(N<=3&&N<W)W=N,V=_}if(V)u.fail(E("Did you mean %s?",V))},B.reset=function(J){return $=gD($,(Q)=>!J[Q]),Z=gD(Z,(Q)=>!J[Q]),B};let z=[];return B.freeze=function(){z.push({implied:$,conflicting:Z})},B.unfreeze=function(){let J=z.pop();WD(J,void 0,F),{implied:$,conflicting:Z}=J},B}var lF=[],Ru;function Su(D,u,F,E){Ru=E;let C={};if(Object.prototype.hasOwnProperty.call(D,"extends")){if(typeof D.extends!=="string")return C;let B=/\.json|\..*rc$/.test(D.extends),$=null;if(!B)try{$=import.meta.resolve(D.extends)}catch(G){return D}else $=V6(u,D.extends);O6($),lF.push($),C=B?JSON.parse(Ru.readFileSync($,"utf8")):E.require(D.extends),delete D.extends,C=Su(C,Ru.path.dirname($),F,Ru)}return lF=[],F?D8(C,D):Object.assign({},C,D)}function O6(D){if(lF.indexOf(D)>-1)throw new FD(`Circular extended configurations: '${D}'.`)}function V6(D,u){return Ru.path.resolve(D,u)}function D8(D,u){let F={};function E(C){return C&&typeof C==="object"&&!Array.isArray(C)}Object.assign(F,D);for(let C of Object.keys(u))if(E(u[C])&&E(F[C]))F[C]=D8(D[C],u[C]);else F[C]=u[C];return F}var R=function(D,u,F,E,C){if(E==="m")throw TypeError("Private method is not writable");if(E==="a"&&!C)throw TypeError("Private accessor was defined without a setter");if(typeof u==="function"?D!==u||!C:!u.has(D))throw TypeError("Cannot write private member to an object whose class did not declare it");return E==="a"?C.call(D,F):C?C.value=F:u.set(D,F),F},X=function(D,u,F,E){if(F==="a"&&!E)throw TypeError("Private accessor was defined without a getter");if(typeof u==="function"?D!==u||!E:!u.has(D))throw TypeError("Cannot read private member from an object whose class did not declare it");return F==="m"?E:F==="a"?E.call(D):E?E.value:u.get(D)},ED,Du,Pu,VD,qD,ru,dD,uu,au,AD,eu,LD,xD,UD,ND,DF,Fu,JD,I,uF,FF,MD,Eu,Mu,Cu,iD,EF,v,Bu,$u,Gu,m,CF,ID,DD;function M8(D){return(u=[],F=D.process.cwd(),E)=>{let C=new K8(u,F,E,D);return Object.defineProperty(C,"argv",{get:()=>{return C.parse()},enumerable:!0}),C.help(),C.version(),C}}var u8=Symbol("copyDoubleDash"),F8=Symbol("copyDoubleDash"),tF=Symbol("deleteFromParserHintObject"),E8=Symbol("emitWarning"),C8=Symbol("freeze"),B8=Symbol("getDollarZero"),zu=Symbol("getParserConfiguration"),$8=Symbol("getUsageConfiguration"),oF=Symbol("guessLocale"),G8=Symbol("guessVersion"),z8=Symbol("parsePositionalNumbers"),sF=Symbol("pkgUp"),nD=Symbol("populateParserHintArray"),Ku=Symbol("populateParserHintSingleValueDictionary"),rF=Symbol("populateParserHintArrayDictionary"),aF=Symbol("populateParserHintDictionary"),eF=Symbol("sanitizeKey"),D0=Symbol("setKey"),u0=Symbol("unfreeze"),Z8=Symbol("validateAsync"),J8=Symbol("getCommandInstance"),X8=Symbol("getContext"),Q8=Symbol("getHasOutput"),Y8=Symbol("getLoggerInstance"),W8=Symbol("getParseContext"),O8=Symbol("getUsageInstance"),V8=Symbol("getValidationInstance"),BF=Symbol("hasParseCallback"),H8=Symbol("isGlobalContext"),Zu=Symbol("postProcess"),q8=Symbol("rebase"),F0=Symbol("reset"),wu=Symbol("runYargsParserAndExecuteCommands"),E0=Symbol("runValidation"),U8=Symbol("setHasOutput"),Ju=Symbol("kTrackManuallySetKeys"),H6="en_US";class K8{constructor(D=[],u,F,E){this.customScriptName=!1,this.parsed=!1,ED.set(this,void 0),Du.set(this,void 0),Pu.set(this,{commands:[],fullCommands:[]}),VD.set(this,null),qD.set(this,null),ru.set(this,"show-hidden"),dD.set(this,null),uu.set(this,!0),au.set(this,{}),AD.set(this,!0),eu.set(this,[]),LD.set(this,void 0),xD.set(this,{}),UD.set(this,!1),ND.set(this,null),DF.set(this,!0),Fu.set(this,void 0),JD.set(this,""),I.set(this,void 0),uF.set(this,void 0),FF.set(this,{}),MD.set(this,null),Eu.set(this,null),Mu.set(this,{}),Cu.set(this,{}),iD.set(this,void 0),EF.set(this,!1),v.set(this,void 0),Bu.set(this,!1),$u.set(this,!1),Gu.set(this,!1),m.set(this,void 0),CF.set(this,{}),ID.set(this,null),DD.set(this,void 0),R(this,v,E,"f"),R(this,iD,D,"f"),R(this,Du,u,"f"),R(this,uF,F,"f"),R(this,LD,new iF(this),"f"),this.$0=this[B8](),this[F0](),R(this,ED,X(this,ED,"f"),"f"),R(this,m,X(this,m,"f"),"f"),R(this,DD,X(this,DD,"f"),"f"),R(this,I,X(this,I,"f"),"f"),X(this,I,"f").showHiddenOpt=X(this,ru,"f"),R(this,Fu,this[F8](),"f"),X(this,v,"f").y18n.setLocale(H6)}addHelpOpt(D,u){if(T("[string|boolean] [string]",[D,u],arguments.length),X(this,ND,"f"))this[tF](X(this,ND,"f")),R(this,ND,null,"f");if(D===!1&&u===void 0)return this;return R(this,ND,typeof D==="string"?D:"help","f"),this.boolean(X(this,ND,"f")),this.describe(X(this,ND,"f"),u||X(this,m,"f").deferY18nLookup("Show help")),this}help(D,u){return this.addHelpOpt(D,u)}addShowHiddenOpt(D,u){if(T("[string|boolean] [string]",[D,u],arguments.length),D===!1&&u===void 0)return this;let F=typeof D==="string"?D:X(this,ru,"f");return this.boolean(F),this.describe(F,u||X(this,m,"f").deferY18nLookup("Show hidden options")),X(this,I,"f").showHiddenOpt=F,this}showHidden(D,u){return this.addShowHiddenOpt(D,u)}alias(D,u){return T("<object|string|array> [string|array]",[D,u],arguments.length),this[rF](this.alias.bind(this),"alias",D,u),this}array(D){return T("<array|string>",[D],arguments.length),this[nD]("array",D),this[Ju](D),this}boolean(D){return T("<array|string>",[D],arguments.length),this[nD]("boolean",D),this[Ju](D),this}check(D,u){return T("<function> [boolean]",[D,u],arguments.length),this.middleware((F,E)=>{return eD(()=>{return D(F,E.getOptions())},(C)=>{if(!C)X(this,m,"f").fail(X(this,v,"f").y18n.__("Argument check failed: %s",D.toString()));else if(typeof C==="string"||C instanceof Error)X(this,m,"f").fail(C.toString(),C);return F},(C)=>{return X(this,m,"f").fail(C.message?C.message:C.toString(),C),F})},!1,u),this}choices(D,u){return T("<object|string|array> [string|array]",[D,u],arguments.length),this[rF](this.choices.bind(this),"choices",D,u),this}coerce(D,u){if(T("<object|string|array> [function]",[D,u],arguments.length),Array.isArray(D)){if(!u)throw new FD("coerce callback must be provided");for(let E of D)this.coerce(E,u);return this}else if(typeof D==="object"){for(let E of Object.keys(D))this.coerce(E,D[E]);return this}if(!u)throw new FD("coerce callback must be provided");let F=D;return X(this,I,"f").key[F]=!0,X(this,LD,"f").addCoerceMiddleware((E,C)=>{var B;let $=(B=C.getAliases()[F])!==null&&B!==void 0?B:[],G=[F,...$].filter((Z)=>Object.prototype.hasOwnProperty.call(E,Z));if(G.length===0)return E;return eD(()=>{return u(E[G[0]])},(Z)=>{return G.forEach((z)=>{E[z]=Z}),E},(Z)=>{throw new FD(Z.message)})},F),this}conflicts(D,u){return T("<string|object> [string|array]",[D,u],arguments.length),X(this,DD,"f").conflicts(D,u),this}config(D="config",u,F){if(T("[object|string] [string|function] [function]",[D,u,F],arguments.length),typeof D==="object"&&!Array.isArray(D))return D=Su(D,X(this,Du,"f"),this[zu]()["deep-merge-config"]||!1,X(this,v,"f")),X(this,I,"f").configObjects=(X(this,I,"f").configObjects||[]).concat(D),this;if(typeof u==="function")F=u,u=void 0;return this.describe(D,u||X(this,m,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(D)?D:[D]).forEach((E)=>{X(this,I,"f").config[E]=F||!0}),this}completion(D,u,F){if(T("[string] [string|boolean|function] [function]",[D,u,F],arguments.length),typeof u==="function")F=u,u=void 0;if(R(this,qD,D||X(this,qD,"f")||"completion","f"),!u&&u!==!1)u="generate completion script";if(this.command(X(this,qD,"f"),u),F)X(this,VD,"f").registerFunction(F);return this}command(D,u,F,E,C,B){return T("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[D,u,F,E,C,B],arguments.length),X(this,ED,"f").addHandler(D,u,F,E,C,B),this}commands(D,u,F,E,C,B){return this.command(D,u,F,E,C,B)}commandDir(D,u){T("<string> [object]",[D,u],arguments.length);let F=X(this,uF,"f")||X(this,v,"f").require;return X(this,ED,"f").addDirectory(D,F,X(this,v,"f").getCallerFile(),u),this}count(D){return T("<array|string>",[D],arguments.length),this[nD]("count",D),this[Ju](D),this}default(D,u,F){if(T("<object|string|array> [*] [string]",[D,u,F],arguments.length),F)dF(D,X(this,v,"f")),X(this,I,"f").defaultDescription[D]=F;if(typeof u==="function"){if(dF(D,X(this,v,"f")),!X(this,I,"f").defaultDescription[D])X(this,I,"f").defaultDescription[D]=X(this,m,"f").functionDescription(u);u=u.call()}return this[Ku](this.default.bind(this),"default",D,u),this}defaults(D,u,F){return this.default(D,u,F)}demandCommand(D=1,u,F,E){if(T("[number] [number|string] [string|null|undefined] [string|null|undefined]",[D,u,F,E],arguments.length),typeof u!=="number")F=u,u=1/0;return this.global("_",!1),X(this,I,"f").demandedCommands._={min:D,max:u,minMsg:F,maxMsg:E},this}demand(D,u,F){if(Array.isArray(u))u.forEach((E)=>{WD(F,!0,X(this,v,"f")),this.demandOption(E,F)}),u=1/0;else if(typeof u!=="number")F=u,u=1/0;if(typeof D==="number")WD(F,!0,X(this,v,"f")),this.demandCommand(D,u,F,F);else if(Array.isArray(D))D.forEach((E)=>{WD(F,!0,X(this,v,"f")),this.demandOption(E,F)});else if(typeof F==="string")this.demandOption(D,F);else if(F===!0||typeof F>"u")this.demandOption(D);return this}demandOption(D,u){return T("<object|string|array> [string]",[D,u],arguments.length),this[Ku](this.demandOption.bind(this),"demandedOptions",D,u),this}deprecateOption(D,u){return T("<string> [string|boolean]",[D,u],arguments.length),X(this,I,"f").deprecatedOptions[D]=u,this}describe(D,u){return T("<object|string|array> [string]",[D,u],arguments.length),this[D0](D,!0),X(this,m,"f").describe(D,u),this}detectLocale(D){return T("<boolean>",[D],arguments.length),R(this,uu,D,"f"),this}env(D){if(T("[string|boolean]",[D],arguments.length),D===!1)delete X(this,I,"f").envPrefix;else X(this,I,"f").envPrefix=D||"";return this}epilogue(D){return T("<string>",[D],arguments.length),X(this,m,"f").epilog(D),this}epilog(D){return this.epilogue(D)}example(D,u){if(T("<string|array> [string]",[D,u],arguments.length),Array.isArray(D))D.forEach((F)=>this.example(...F));else X(this,m,"f").example(D,u);return this}exit(D,u){if(R(this,UD,!0,"f"),R(this,dD,u,"f"),X(this,AD,"f"))X(this,v,"f").process.exit(D)}exitProcess(D=!0){return T("[boolean]",[D],arguments.length),R(this,AD,D,"f"),this}fail(D){if(T("<function|boolean>",[D],arguments.length),typeof D==="boolean"&&D!==!1)throw new FD("Invalid first argument. Expected function or boolean 'false'");return X(this,m,"f").failFn(D),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(D,u){if(T("<array> [function]",[D,u],arguments.length),!u)return new Promise((F,E)=>{X(this,VD,"f").getCompletion(D,(C,B)=>{if(C)E(C);else F(B)})});else return X(this,VD,"f").getCompletion(D,u)}getDemandedOptions(){return T([],0),X(this,I,"f").demandedOptions}getDemandedCommands(){return T([],0),X(this,I,"f").demandedCommands}getDeprecatedOptions(){return T([],0),X(this,I,"f").deprecatedOptions}getDetectLocale(){return X(this,uu,"f")}getExitProcess(){return X(this,AD,"f")}getGroups(){return Object.assign({},X(this,xD,"f"),X(this,Cu,"f"))}getHelp(){if(R(this,UD,!0,"f"),!X(this,m,"f").hasCachedHelpMessage()){if(!this.parsed){let u=this[wu](X(this,iD,"f"),void 0,void 0,0,!0);if(s(u))return u.then(()=>{return X(this,m,"f").help()})}let D=X(this,ED,"f").runDefaultBuilderOn(this);if(s(D))return D.then(()=>{return X(this,m,"f").help()})}return Promise.resolve(X(this,m,"f").help())}getOptions(){return X(this,I,"f")}getStrict(){return X(this,Bu,"f")}getStrictCommands(){return X(this,$u,"f")}getStrictOptions(){return X(this,Gu,"f")}global(D,u){if(T("<string|array> [boolean]",[D,u],arguments.length),D=[].concat(D),u!==!1)X(this,I,"f").local=X(this,I,"f").local.filter((F)=>D.indexOf(F)===-1);else D.forEach((F)=>{if(!X(this,I,"f").local.includes(F))X(this,I,"f").local.push(F)});return this}group(D,u){T("<string|array> <string>",[D,u],arguments.length);let F=X(this,Cu,"f")[u]||X(this,xD,"f")[u];if(X(this,Cu,"f")[u])delete X(this,Cu,"f")[u];let E={};return X(this,xD,"f")[u]=(F||[]).concat(D).filter((C)=>{if(E[C])return!1;return E[C]=!0}),this}hide(D){return T("<string>",[D],arguments.length),X(this,I,"f").hiddenOptions.push(D),this}implies(D,u){return T("<string|object> [number|string|array]",[D,u],arguments.length),X(this,DD,"f").implies(D,u),this}locale(D){if(T("[string]",[D],arguments.length),D===void 0)return this[oF](),X(this,v,"f").y18n.getLocale();return R(this,uu,!1,"f"),X(this,v,"f").y18n.setLocale(D),this}middleware(D,u,F){return X(this,LD,"f").addMiddleware(D,!!u,F)}nargs(D,u){return T("<string|object|array> [number]",[D,u],arguments.length),this[Ku](this.nargs.bind(this),"narg",D,u),this}normalize(D){return T("<array|string>",[D],arguments.length),this[nD]("normalize",D),this}number(D){return T("<array|string>",[D],arguments.length),this[nD]("number",D),this[Ju](D),this}option(D,u){if(T("<string|object> [object]",[D,u],arguments.length),typeof D==="object")Object.keys(D).forEach((F)=>{this.options(F,D[F])});else{if(typeof u!=="object")u={};if(this[Ju](D),X(this,ID,"f")&&(D==="version"||(u===null||u===void 0?void 0:u.alias)==="version"))this[E8](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
79
- `),void 0,"versionWarning");if(X(this,I,"f").key[D]=!0,u.alias)this.alias(D,u.alias);let F=u.deprecate||u.deprecated;if(F)this.deprecateOption(D,F);let E=u.demand||u.required||u.require;if(E)this.demand(D,E);if(u.demandOption)this.demandOption(D,typeof u.demandOption==="string"?u.demandOption:void 0);if(u.conflicts)this.conflicts(D,u.conflicts);if("default"in u)this.default(D,u.default);if(u.implies!==void 0)this.implies(D,u.implies);if(u.nargs!==void 0)this.nargs(D,u.nargs);if(u.config)this.config(D,u.configParser);if(u.normalize)this.normalize(D);if(u.choices)this.choices(D,u.choices);if(u.coerce)this.coerce(D,u.coerce);if(u.group)this.group(D,u.group);if(u.boolean||u.type==="boolean"){if(this.boolean(D),u.alias)this.boolean(u.alias)}if(u.array||u.type==="array"){if(this.array(D),u.alias)this.array(u.alias)}if(u.number||u.type==="number"){if(this.number(D),u.alias)this.number(u.alias)}if(u.string||u.type==="string"){if(this.string(D),u.alias)this.string(u.alias)}if(u.count||u.type==="count")this.count(D);if(typeof u.global==="boolean")this.global(D,u.global);if(u.defaultDescription)X(this,I,"f").defaultDescription[D]=u.defaultDescription;if(u.skipValidation)this.skipValidation(D);let C=u.describe||u.description||u.desc,B=X(this,m,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(B,D)||typeof C==="string")this.describe(D,C);if(u.hidden)this.hide(D);if(u.requiresArg)this.requiresArg(D)}return this}options(D,u){return this.option(D,u)}parse(D,u,F){if(T("[string|array] [function|boolean|object] [function]",[D,u,F],arguments.length),this[C8](),typeof D>"u")D=X(this,iD,"f");if(typeof u==="object")R(this,Eu,u,"f"),u=F;if(typeof u==="function")R(this,MD,u,"f"),u=!1;if(!u)R(this,iD,D,"f");if(X(this,MD,"f"))R(this,AD,!1,"f");let E=this[wu](D,!!u),C=this.parsed;if(X(this,VD,"f").setParsed(this.parsed),s(E))return E.then((B)=>{if(X(this,MD,"f"))X(this,MD,"f").call(this,X(this,dD,"f"),B,X(this,JD,"f"));return B}).catch((B)=>{if(X(this,MD,"f"))X(this,MD,"f")(B,this.parsed.argv,X(this,JD,"f"));throw B}).finally(()=>{this[u0](),this.parsed=C});else{if(X(this,MD,"f"))X(this,MD,"f").call(this,X(this,dD,"f"),E,X(this,JD,"f"));this[u0](),this.parsed=C}return E}parseAsync(D,u,F){let E=this.parse(D,u,F);return!s(E)?Promise.resolve(E):E}parseSync(D,u,F){let E=this.parse(D,u,F);if(s(E))throw new FD(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return E}parserConfiguration(D){return T("<object>",[D],arguments.length),R(this,FF,D,"f"),this}pkgConf(D,u){T("<string> [string]",[D,u],arguments.length);let F=null,E=this[sF](u||X(this,Du,"f"));if(E[D]&&typeof E[D]==="object")F=Su(E[D],u||X(this,Du,"f"),this[zu]()["deep-merge-config"]||!1,X(this,v,"f")),X(this,I,"f").configObjects=(X(this,I,"f").configObjects||[]).concat(F);return this}positional(D,u){T("<string> <object>",[D,u],arguments.length);let F=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];u=gD(u,(B,$)=>{if(B==="type"&&!["string","number","boolean"].includes($))return!1;return F.includes(B)});let E=X(this,Pu,"f").fullCommands[X(this,Pu,"f").fullCommands.length-1],C=E?X(this,ED,"f").cmdToParseOptions(E):{array:[],alias:{},default:{},demand:{}};return qu(C).forEach((B)=>{let $=C[B];if(Array.isArray($)){if($.indexOf(D)!==-1)u[B]=!0}else if($[D]&&!(B in u))u[B]=$[D]}),this.group(D,X(this,m,"f").getPositionalGroupName()),this.option(D,u)}recommendCommands(D=!0){return T("[boolean]",[D],arguments.length),R(this,EF,D,"f"),this}required(D,u,F){return this.demand(D,u,F)}require(D,u,F){return this.demand(D,u,F)}requiresArg(D){if(T("<array|string|object> [number]",[D],arguments.length),typeof D==="string"&&X(this,I,"f").narg[D])return this;else this[Ku](this.requiresArg.bind(this),"narg",D,NaN);return this}showCompletionScript(D,u){return T("[string] [string]",[D,u],arguments.length),D=D||this.$0,X(this,Fu,"f").log(X(this,VD,"f").generateCompletionScript(D,u||X(this,qD,"f")||"completion")),this}showHelp(D){if(T("[string|function]",[D],arguments.length),R(this,UD,!0,"f"),!X(this,m,"f").hasCachedHelpMessage()){if(!this.parsed){let F=this[wu](X(this,iD,"f"),void 0,void 0,0,!0);if(s(F))return F.then(()=>{X(this,m,"f").showHelp(D)}),this}let u=X(this,ED,"f").runDefaultBuilderOn(this);if(s(u))return u.then(()=>{X(this,m,"f").showHelp(D)}),this}return X(this,m,"f").showHelp(D),this}scriptName(D){return this.customScriptName=!0,this.$0=D,this}showHelpOnFail(D,u){return T("[boolean|string] [string]",[D,u],arguments.length),X(this,m,"f").showHelpOnFail(D,u),this}showVersion(D){return T("[string|function]",[D],arguments.length),X(this,m,"f").showVersion(D),this}skipValidation(D){return T("<array|string>",[D],arguments.length),this[nD]("skipValidation",D),this}strict(D){return T("[boolean]",[D],arguments.length),R(this,Bu,D!==!1,"f"),this}strictCommands(D){return T("[boolean]",[D],arguments.length),R(this,$u,D!==!1,"f"),this}strictOptions(D){return T("[boolean]",[D],arguments.length),R(this,Gu,D!==!1,"f"),this}string(D){return T("<array|string>",[D],arguments.length),this[nD]("string",D),this[Ju](D),this}terminalWidth(){return T([],0),X(this,v,"f").process.stdColumns}updateLocale(D){return this.updateStrings(D)}updateStrings(D){return T("<object>",[D],arguments.length),R(this,uu,!1,"f"),X(this,v,"f").y18n.updateLocale(D),this}usage(D,u,F,E){if(T("<string|null|undefined> [string|boolean] [function|object] [function]",[D,u,F,E],arguments.length),u!==void 0)if(WD(D,null,X(this,v,"f")),(D||"").match(/^\$0( |$)/))return this.command(D,u,F,E);else throw new FD(".usage() description must start with $0 if being used as alias for .command()");else return X(this,m,"f").usage(D),this}usageConfiguration(D){return T("<object>",[D],arguments.length),R(this,CF,D,"f"),this}version(D,u,F){if(T("[boolean|string] [string] [string]",[D,u,F],arguments.length),X(this,ID,"f"))this[tF](X(this,ID,"f")),X(this,m,"f").version(void 0),R(this,ID,null,"f");if(arguments.length===0)F=this[G8](),D="version";else if(arguments.length===1){if(D===!1)return this;F=D,D="version"}else if(arguments.length===2)F=u,u=void 0;return R(this,ID,typeof D==="string"?D:"version","f"),u=u||X(this,m,"f").deferY18nLookup("Show version number"),X(this,m,"f").version(F||void 0),this.boolean(X(this,ID,"f")),this.describe(X(this,ID,"f"),u),this}wrap(D){return T("<number|null|undefined>",[D],arguments.length),X(this,m,"f").wrap(D),this}[(ED=new WeakMap,Du=new WeakMap,Pu=new WeakMap,VD=new WeakMap,qD=new WeakMap,ru=new WeakMap,dD=new WeakMap,uu=new WeakMap,au=new WeakMap,AD=new WeakMap,eu=new WeakMap,LD=new WeakMap,xD=new WeakMap,UD=new WeakMap,ND=new WeakMap,DF=new WeakMap,Fu=new WeakMap,JD=new WeakMap,I=new WeakMap,uF=new WeakMap,FF=new WeakMap,MD=new WeakMap,Eu=new WeakMap,Mu=new WeakMap,Cu=new WeakMap,iD=new WeakMap,EF=new WeakMap,v=new WeakMap,Bu=new WeakMap,$u=new WeakMap,Gu=new WeakMap,m=new WeakMap,CF=new WeakMap,ID=new WeakMap,DD=new WeakMap,u8)](D){if(!D._||!D["--"])return D;D._.push.apply(D._,D["--"]);try{delete D["--"]}catch(u){}return D}[F8](){return{log:(...D)=>{if(!this[BF]())console.log(...D);if(R(this,UD,!0,"f"),X(this,JD,"f").length)R(this,JD,X(this,JD,"f")+`
80
- `,"f");R(this,JD,X(this,JD,"f")+D.join(" "),"f")},error:(...D)=>{if(!this[BF]())console.error(...D);if(R(this,UD,!0,"f"),X(this,JD,"f").length)R(this,JD,X(this,JD,"f")+`
81
- `,"f");R(this,JD,X(this,JD,"f")+D.join(" "),"f")}}}[tF](D){qu(X(this,I,"f")).forEach((u)=>{if(((E)=>E==="configObjects")(u))return;let F=X(this,I,"f")[u];if(Array.isArray(F)){if(F.includes(D))F.splice(F.indexOf(D),1)}else if(typeof F==="object")delete F[D]}),delete X(this,m,"f").getDescriptions()[D]}[E8](D,u,F){if(!X(this,au,"f")[F])X(this,v,"f").process.emitWarning(D,u),X(this,au,"f")[F]=!0}[C8](){X(this,eu,"f").push({options:X(this,I,"f"),configObjects:X(this,I,"f").configObjects.slice(0),exitProcess:X(this,AD,"f"),groups:X(this,xD,"f"),strict:X(this,Bu,"f"),strictCommands:X(this,$u,"f"),strictOptions:X(this,Gu,"f"),completionCommand:X(this,qD,"f"),output:X(this,JD,"f"),exitError:X(this,dD,"f"),hasOutput:X(this,UD,"f"),parsed:this.parsed,parseFn:X(this,MD,"f"),parseContext:X(this,Eu,"f")}),X(this,m,"f").freeze(),X(this,DD,"f").freeze(),X(this,ED,"f").freeze(),X(this,LD,"f").freeze()}[B8](){let D="",u;if(/\b(node|iojs|electron)(\.exe)?$/.test(X(this,v,"f").process.argv()[0]))u=X(this,v,"f").process.argv().slice(1,2);else u=X(this,v,"f").process.argv().slice(0,1);if(D=u.map((F)=>{let E=this[q8](X(this,Du,"f"),F);return F.match(/^(\/|([a-zA-Z]:)?\\)/)&&E.length<F.length?E:F}).join(" ").trim(),X(this,v,"f").getEnv("_")&&X(this,v,"f").getProcessArgvBin()===X(this,v,"f").getEnv("_"))D=X(this,v,"f").getEnv("_").replace(`${X(this,v,"f").path.dirname(X(this,v,"f").process.execPath())}/`,"");return D}[zu](){return X(this,FF,"f")}[$8](){return X(this,CF,"f")}[oF](){if(!X(this,uu,"f"))return;let D=X(this,v,"f").getEnv("LC_ALL")||X(this,v,"f").getEnv("LC_MESSAGES")||X(this,v,"f").getEnv("LANG")||X(this,v,"f").getEnv("LANGUAGE")||"en_US";this.locale(D.replace(/[.:].*/,""))}[G8](){return this[sF]().version||"unknown"}[z8](D){let u=D["--"]?D["--"]:D._;for(let F=0,E;(E=u[F])!==void 0;F++)if(X(this,v,"f").Parser.looksLikeNumber(E)&&Number.isSafeInteger(Math.floor(parseFloat(`${E}`))))u[F]=Number(E);return D}[sF](D){let u=D||"*";if(X(this,Mu,"f")[u])return X(this,Mu,"f")[u];let F={};try{let E=D||X(this,v,"f").mainFilename;if(X(this,v,"f").path.extname(E))E=X(this,v,"f").path.dirname(E);let C=X(this,v,"f").findUp(E,(B,$)=>{if($.includes("package.json"))return"package.json";else return});WD(C,void 0,X(this,v,"f")),F=JSON.parse(X(this,v,"f").readFileSync(C,"utf8"))}catch(E){}return X(this,Mu,"f")[u]=F||{},X(this,Mu,"f")[u]}[nD](D,u){u=[].concat(u),u.forEach((F)=>{F=this[eF](F),X(this,I,"f")[D].push(F)})}[Ku](D,u,F,E){this[aF](D,u,F,E,(C,B,$)=>{X(this,I,"f")[C][B]=$})}[rF](D,u,F,E){this[aF](D,u,F,E,(C,B,$)=>{X(this,I,"f")[C][B]=(X(this,I,"f")[C][B]||[]).concat($)})}[aF](D,u,F,E,C){if(Array.isArray(F))F.forEach((B)=>{D(B,E)});else if(((B)=>typeof B==="object")(F))for(let B of qu(F))D(B,F[B]);else C(u,this[eF](F),E)}[eF](D){if(D==="__proto__")return"___proto___";return D}[D0](D,u){return this[Ku](this[D0].bind(this),"key",D,u),this}[u0](){var D,u,F,E,C,B,$,G,Z,z,Y,J;let Q=X(this,eu,"f").pop();WD(Q,void 0,X(this,v,"f"));let O;D=this,u=this,F=this,E=this,C=this,B=this,$=this,G=this,Z=this,z=this,Y=this,J=this,{options:{set value(V){R(D,I,V,"f")}}.value,configObjects:O,exitProcess:{set value(V){R(u,AD,V,"f")}}.value,groups:{set value(V){R(F,xD,V,"f")}}.value,output:{set value(V){R(E,JD,V,"f")}}.value,exitError:{set value(V){R(C,dD,V,"f")}}.value,hasOutput:{set value(V){R(B,UD,V,"f")}}.value,parsed:this.parsed,strict:{set value(V){R($,Bu,V,"f")}}.value,strictCommands:{set value(V){R(G,$u,V,"f")}}.value,strictOptions:{set value(V){R(Z,Gu,V,"f")}}.value,completionCommand:{set value(V){R(z,qD,V,"f")}}.value,parseFn:{set value(V){R(Y,MD,V,"f")}}.value,parseContext:{set value(V){R(J,Eu,V,"f")}}.value}=Q,X(this,I,"f").configObjects=O,X(this,m,"f").unfreeze(),X(this,DD,"f").unfreeze(),X(this,ED,"f").unfreeze(),X(this,LD,"f").unfreeze()}[Z8](D,u){return eD(u,(F)=>{return D(F),F})}getInternalMethods(){return{getCommandInstance:this[J8].bind(this),getContext:this[X8].bind(this),getHasOutput:this[Q8].bind(this),getLoggerInstance:this[Y8].bind(this),getParseContext:this[W8].bind(this),getParserConfiguration:this[zu].bind(this),getUsageConfiguration:this[$8].bind(this),getUsageInstance:this[O8].bind(this),getValidationInstance:this[V8].bind(this),hasParseCallback:this[BF].bind(this),isGlobalContext:this[H8].bind(this),postProcess:this[Zu].bind(this),reset:this[F0].bind(this),runValidation:this[E0].bind(this),runYargsParserAndExecuteCommands:this[wu].bind(this),setHasOutput:this[U8].bind(this)}}[J8](){return X(this,ED,"f")}[X8](){return X(this,Pu,"f")}[Q8](){return X(this,UD,"f")}[Y8](){return X(this,Fu,"f")}[W8](){return X(this,Eu,"f")||{}}[O8](){return X(this,m,"f")}[V8](){return X(this,DD,"f")}[BF](){return!!X(this,MD,"f")}[H8](){return X(this,DF,"f")}[Zu](D,u,F,E){if(F)return D;if(s(D))return D;if(!u)D=this[u8](D);if(this[zu]()["parse-positional-numbers"]||this[zu]()["parse-positional-numbers"]===void 0)D=this[z8](D);if(E)D=aD(D,this,X(this,LD,"f").getMiddleware(),!1);return D}[F0](D={}){R(this,I,X(this,I,"f")||{},"f");let u={};u.local=X(this,I,"f").local||[],u.configObjects=X(this,I,"f").configObjects||[];let F={};u.local.forEach((B)=>{F[B]=!0,(D[B]||[]).forEach(($)=>{F[$]=!0})}),Object.assign(X(this,Cu,"f"),Object.keys(X(this,xD,"f")).reduce((B,$)=>{let G=X(this,xD,"f")[$].filter((Z)=>!(Z in F));if(G.length>0)B[$]=G;return B},{})),R(this,xD,{},"f");let E=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],C=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(E.forEach((B)=>{u[B]=(X(this,I,"f")[B]||[]).filter(($)=>!F[$])}),C.forEach((B)=>{u[B]=gD(X(this,I,"f")[B],($)=>!F[$])}),u.envPrefix=X(this,I,"f").envPrefix,R(this,I,u,"f"),R(this,m,X(this,m,"f")?X(this,m,"f").reset(F):n2(this,X(this,v,"f")),"f"),R(this,DD,X(this,DD,"f")?X(this,DD,"f").reset(F):e2(this,X(this,m,"f"),X(this,v,"f")),"f"),R(this,ED,X(this,ED,"f")?X(this,ED,"f").reset():k2(X(this,m,"f"),X(this,DD,"f"),X(this,LD,"f"),X(this,v,"f")),"f"),!X(this,VD,"f"))R(this,VD,s2(this,X(this,m,"f"),X(this,ED,"f"),X(this,v,"f")),"f");return X(this,LD,"f").reset(),R(this,qD,null,"f"),R(this,JD,"","f"),R(this,dD,null,"f"),R(this,UD,!1,"f"),this.parsed=!1,this}[q8](D,u){return X(this,v,"f").path.relative(D,u)}[wu](D,u,F,E=0,C=!1){var B,$,G,Z;let z=!!F||C;D=D||X(this,iD,"f"),X(this,I,"f").__=X(this,v,"f").y18n.__,X(this,I,"f").configuration=this[zu]();let Y=!!X(this,I,"f").configuration["populate--"],J=Object.assign({},X(this,I,"f").configuration,{"populate--":!0}),Q=X(this,v,"f").Parser.detailed(D,Object.assign({},X(this,I,"f"),{configuration:{"parse-positional-numbers":!1,...J}})),O=Object.assign(Q.argv,X(this,Eu,"f")),V=void 0,W=Q.aliases,M=!1,_=!1;if(Object.keys(O).forEach((N)=>{if(N===X(this,ND,"f")&&O[N])M=!0;else if(N===X(this,ID,"f")&&O[N])_=!0}),O.$0=this.$0,this.parsed=Q,E===0)X(this,m,"f").clearCachedHelpMessage();try{if(this[oF](),u)return this[Zu](O,Y,!!F,!1);if(X(this,ND,"f")){if([X(this,ND,"f")].concat(W[X(this,ND,"f")]||[]).filter((e)=>e.length>1).includes(""+O._[O._.length-1]))O._.pop(),M=!0}R(this,DF,!1,"f");let N=X(this,ED,"f").getCommands(),k=((B=X(this,VD,"f"))===null||B===void 0?void 0:B.completionKey)?[($=X(this,VD,"f"))===null||$===void 0?void 0:$.completionKey,...(Z=this.getAliases()[(G=X(this,VD,"f"))===null||G===void 0?void 0:G.completionKey])!==null&&Z!==void 0?Z:[]].some((c)=>Object.prototype.hasOwnProperty.call(O,c)):!1,w=M||k||C;if(O._.length){if(N.length){let c;for(let e=E||0,r;O._[e]!==void 0;e++)if(r=String(O._[e]),N.includes(r)&&r!==X(this,qD,"f")){let _D=X(this,ED,"f").runCommand(r,this,Q,e+1,C,M||_||C);return this[Zu](_D,Y,!!F,!1)}else if(!c&&r!==X(this,qD,"f")){c=r;break}if(!X(this,ED,"f").hasDefaultCommand()&&X(this,EF,"f")&&c&&!w)X(this,DD,"f").recommendCommands(c,N)}if(X(this,qD,"f")&&O._.includes(X(this,qD,"f"))&&!k){if(X(this,AD,"f"))kD(!0);this.showCompletionScript(),this.exit(0)}}if(X(this,ED,"f").hasDefaultCommand()&&!w){let c=X(this,ED,"f").runCommand(null,this,Q,0,C,M||_||C);return this[Zu](c,Y,!!F,!1)}if(k){if(X(this,AD,"f"))kD(!0);D=[].concat(D);let c=D.slice(D.indexOf(`--${X(this,VD,"f").completionKey}`)+1);return X(this,VD,"f").getCompletion(c,(e,r)=>{if(e)throw new FD(e.message);(r||[]).forEach((_D)=>{X(this,Fu,"f").log(_D)}),this.exit(0)}),this[Zu](O,!Y,!!F,!1)}if(!X(this,UD,"f")){if(M){if(X(this,AD,"f"))kD(!0);z=!0,this.showHelp((c)=>{X(this,Fu,"f").log(c),this.exit(0)})}else if(_){if(X(this,AD,"f"))kD(!0);z=!0,X(this,m,"f").showVersion("log"),this.exit(0)}}if(!z&&X(this,I,"f").skipValidation.length>0)z=Object.keys(O).some((c)=>X(this,I,"f").skipValidation.indexOf(c)>=0&&O[c]===!0);if(!z){if(Q.error)throw new FD(Q.error.message);if(!k){let c=this[E0](W,{},Q.error);if(!F)V=aD(O,this,X(this,LD,"f").getMiddleware(),!0);if(V=this[Z8](c,V!==null&&V!==void 0?V:O),s(V)&&!F)V=V.then(()=>{return aD(O,this,X(this,LD,"f").getMiddleware(),!1)})}}}catch(N){if(N instanceof FD)X(this,m,"f").fail(N.message,N);else throw N}return this[Zu](V!==null&&V!==void 0?V:O,Y,!!F,!0)}[E0](D,u,F,E){let C={...this.getDemandedOptions()};return(B)=>{if(F)throw new FD(F.message);X(this,DD,"f").nonOptionCount(B),X(this,DD,"f").requiredArguments(B,C);let $=!1;if(X(this,$u,"f"))$=X(this,DD,"f").unknownCommands(B);if(X(this,Bu,"f")&&!$)X(this,DD,"f").unknownArguments(B,D,u,!!E);else if(X(this,Gu,"f"))X(this,DD,"f").unknownArguments(B,D,{},!1,!1);X(this,DD,"f").limitedChoices(B),X(this,DD,"f").implications(B),X(this,DD,"f").conflicting(B)}}[U8](){R(this,UD,!0,"f")}[Ju](D){if(typeof D==="string")X(this,I,"f").key[D]=!0;else for(let u of D)X(this,I,"f").key[u]=!0}}function d2(D){return!!D&&typeof D.getInternalMethods==="function"}var q6=M8(kF),_8=q6;import{existsSync as $F,readFileSync as $0,writeFileSync as C0,mkdirSync as L8}from"node:fs";import{homedir as U6}from"node:os";import{join as Xu,dirname as G0}from"node:path";function z0(){return process.env.HOME||U6()}function N8(){return Xu(z0(),".config","slack-cli","profiles.json")}function GF(){return Xu(process.cwd(),".slack-cli","workspace")}function zF(){return Xu(z0(),".slack-cli","workspace")}function xu(){let D=N8();if(!$F(D))return{profiles:{}};return JSON.parse($0(D,"utf8"))}function M6(D){let u=N8();L8(G0(u),{recursive:!0}),C0(u,JSON.stringify(D,null,2)+`
82
- `)}function _u(D){if(!$F(D))return;return $0(D,"utf8").trim()||void 0}function j8(D,u){let F=G0(D);L8(F,{recursive:!0});let E=Xu(F,".gitignore");if(!$F(E))C0(E,`*
78
+ `;Q.forEach((V)=>{O+=V}),u.fail(O)}};let z={};B.conflicts=function(J,Q){if(T("<string|object> [array|string]",[J,Q],arguments.length),typeof J==="object")Object.keys(J).forEach((O)=>{B.conflicts(O,J[O])});else{if(D.global(J),!z[J])z[J]=[];if(Array.isArray(Q))Q.forEach((O)=>B.conflicts(J,O));else z[J].push(Q)}},B.getConflicting=()=>z,B.conflicting=function(J){if(Object.keys(J).forEach((Q)=>{if(z[Q])z[Q].forEach((O)=>{if(O&&J[Q]!==void 0&&J[O]!==void 0)u.fail(E("Arguments %s and %s are mutually exclusive",Q,O))})}),D.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(z).forEach((Q)=>{z[Q].forEach((O)=>{if(O&&J[F.Parser.camelCase(Q)]!==void 0&&J[F.Parser.camelCase(O)]!==void 0)u.fail(E("Arguments %s and %s are mutually exclusive",Q,O))})})},B.recommendCommands=function(J,Q){Q=Q.sort((M,_)=>_.length-M.length);let V=null,W=1/0;for(let M=0,_;(_=Q[M])!==void 0;M++){let N=r2(J,_);if(N<=3&&N<W)W=N,V=_}if(V)u.fail(E("Did you mean %s?",V))},B.reset=function(J){return $=gD($,(Q)=>!J[Q]),z=gD(z,(Q)=>!J[Q]),B};let Z=[];return B.freeze=function(){Z.push({implied:$,conflicting:z})},B.unfreeze=function(){let J=Z.pop();WD(J,void 0,F),{implied:$,conflicting:z}=J},B}var lF=[],Ru;function Su(D,u,F,E){Ru=E;let C={};if(Object.prototype.hasOwnProperty.call(D,"extends")){if(typeof D.extends!=="string")return C;let B=/\.json|\..*rc$/.test(D.extends),$=null;if(!B)try{$=import.meta.resolve(D.extends)}catch(G){return D}else $=V6(u,D.extends);O6($),lF.push($),C=B?JSON.parse(Ru.readFileSync($,"utf8")):E.require(D.extends),delete D.extends,C=Su(C,Ru.path.dirname($),F,Ru)}return lF=[],F?D8(C,D):Object.assign({},C,D)}function O6(D){if(lF.indexOf(D)>-1)throw new FD(`Circular extended configurations: '${D}'.`)}function V6(D,u){return Ru.path.resolve(D,u)}function D8(D,u){let F={};function E(C){return C&&typeof C==="object"&&!Array.isArray(C)}Object.assign(F,D);for(let C of Object.keys(u))if(E(u[C])&&E(F[C]))F[C]=D8(D[C],u[C]);else F[C]=u[C];return F}var R=function(D,u,F,E,C){if(E==="m")throw TypeError("Private method is not writable");if(E==="a"&&!C)throw TypeError("Private accessor was defined without a setter");if(typeof u==="function"?D!==u||!C:!u.has(D))throw TypeError("Cannot write private member to an object whose class did not declare it");return E==="a"?C.call(D,F):C?C.value=F:u.set(D,F),F},X=function(D,u,F,E){if(F==="a"&&!E)throw TypeError("Private accessor was defined without a getter");if(typeof u==="function"?D!==u||!E:!u.has(D))throw TypeError("Cannot read private member from an object whose class did not declare it");return F==="m"?E:F==="a"?E.call(D):E?E.value:u.get(D)},ED,Du,Pu,VD,qD,au,dD,uu,eu,AD,DF,LD,xD,UD,ND,uF,Fu,XD,I,FF,EF,MD,Eu,Mu,Cu,iD,CF,v,Bu,$u,Gu,y,BF,ID,DD;function M8(D){return(u=[],F=D.process.cwd(),E)=>{let C=new K8(u,F,E,D);return Object.defineProperty(C,"argv",{get:()=>{return C.parse()},enumerable:!0}),C.help(),C.version(),C}}var u8=Symbol("copyDoubleDash"),F8=Symbol("copyDoubleDash"),tF=Symbol("deleteFromParserHintObject"),E8=Symbol("emitWarning"),C8=Symbol("freeze"),B8=Symbol("getDollarZero"),zu=Symbol("getParserConfiguration"),$8=Symbol("getUsageConfiguration"),oF=Symbol("guessLocale"),G8=Symbol("guessVersion"),z8=Symbol("parsePositionalNumbers"),sF=Symbol("pkgUp"),nD=Symbol("populateParserHintArray"),Ku=Symbol("populateParserHintSingleValueDictionary"),rF=Symbol("populateParserHintArrayDictionary"),aF=Symbol("populateParserHintDictionary"),eF=Symbol("sanitizeKey"),D0=Symbol("setKey"),u0=Symbol("unfreeze"),Z8=Symbol("validateAsync"),J8=Symbol("getCommandInstance"),X8=Symbol("getContext"),Q8=Symbol("getHasOutput"),Y8=Symbol("getLoggerInstance"),W8=Symbol("getParseContext"),O8=Symbol("getUsageInstance"),V8=Symbol("getValidationInstance"),$F=Symbol("hasParseCallback"),H8=Symbol("isGlobalContext"),Zu=Symbol("postProcess"),q8=Symbol("rebase"),F0=Symbol("reset"),wu=Symbol("runYargsParserAndExecuteCommands"),E0=Symbol("runValidation"),U8=Symbol("setHasOutput"),Ju=Symbol("kTrackManuallySetKeys"),H6="en_US";class K8{constructor(D=[],u,F,E){this.customScriptName=!1,this.parsed=!1,ED.set(this,void 0),Du.set(this,void 0),Pu.set(this,{commands:[],fullCommands:[]}),VD.set(this,null),qD.set(this,null),au.set(this,"show-hidden"),dD.set(this,null),uu.set(this,!0),eu.set(this,{}),AD.set(this,!0),DF.set(this,[]),LD.set(this,void 0),xD.set(this,{}),UD.set(this,!1),ND.set(this,null),uF.set(this,!0),Fu.set(this,void 0),XD.set(this,""),I.set(this,void 0),FF.set(this,void 0),EF.set(this,{}),MD.set(this,null),Eu.set(this,null),Mu.set(this,{}),Cu.set(this,{}),iD.set(this,void 0),CF.set(this,!1),v.set(this,void 0),Bu.set(this,!1),$u.set(this,!1),Gu.set(this,!1),y.set(this,void 0),BF.set(this,{}),ID.set(this,null),DD.set(this,void 0),R(this,v,E,"f"),R(this,iD,D,"f"),R(this,Du,u,"f"),R(this,FF,F,"f"),R(this,LD,new iF(this),"f"),this.$0=this[B8](),this[F0](),R(this,ED,X(this,ED,"f"),"f"),R(this,y,X(this,y,"f"),"f"),R(this,DD,X(this,DD,"f"),"f"),R(this,I,X(this,I,"f"),"f"),X(this,I,"f").showHiddenOpt=X(this,au,"f"),R(this,Fu,this[F8](),"f"),X(this,v,"f").y18n.setLocale(H6)}addHelpOpt(D,u){if(T("[string|boolean] [string]",[D,u],arguments.length),X(this,ND,"f"))this[tF](X(this,ND,"f")),R(this,ND,null,"f");if(D===!1&&u===void 0)return this;return R(this,ND,typeof D==="string"?D:"help","f"),this.boolean(X(this,ND,"f")),this.describe(X(this,ND,"f"),u||X(this,y,"f").deferY18nLookup("Show help")),this}help(D,u){return this.addHelpOpt(D,u)}addShowHiddenOpt(D,u){if(T("[string|boolean] [string]",[D,u],arguments.length),D===!1&&u===void 0)return this;let F=typeof D==="string"?D:X(this,au,"f");return this.boolean(F),this.describe(F,u||X(this,y,"f").deferY18nLookup("Show hidden options")),X(this,I,"f").showHiddenOpt=F,this}showHidden(D,u){return this.addShowHiddenOpt(D,u)}alias(D,u){return T("<object|string|array> [string|array]",[D,u],arguments.length),this[rF](this.alias.bind(this),"alias",D,u),this}array(D){return T("<array|string>",[D],arguments.length),this[nD]("array",D),this[Ju](D),this}boolean(D){return T("<array|string>",[D],arguments.length),this[nD]("boolean",D),this[Ju](D),this}check(D,u){return T("<function> [boolean]",[D,u],arguments.length),this.middleware((F,E)=>{return eD(()=>{return D(F,E.getOptions())},(C)=>{if(!C)X(this,y,"f").fail(X(this,v,"f").y18n.__("Argument check failed: %s",D.toString()));else if(typeof C==="string"||C instanceof Error)X(this,y,"f").fail(C.toString(),C);return F},(C)=>{return X(this,y,"f").fail(C.message?C.message:C.toString(),C),F})},!1,u),this}choices(D,u){return T("<object|string|array> [string|array]",[D,u],arguments.length),this[rF](this.choices.bind(this),"choices",D,u),this}coerce(D,u){if(T("<object|string|array> [function]",[D,u],arguments.length),Array.isArray(D)){if(!u)throw new FD("coerce callback must be provided");for(let E of D)this.coerce(E,u);return this}else if(typeof D==="object"){for(let E of Object.keys(D))this.coerce(E,D[E]);return this}if(!u)throw new FD("coerce callback must be provided");let F=D;return X(this,I,"f").key[F]=!0,X(this,LD,"f").addCoerceMiddleware((E,C)=>{var B;let $=(B=C.getAliases()[F])!==null&&B!==void 0?B:[],G=[F,...$].filter((z)=>Object.prototype.hasOwnProperty.call(E,z));if(G.length===0)return E;return eD(()=>{return u(E[G[0]])},(z)=>{return G.forEach((Z)=>{E[Z]=z}),E},(z)=>{throw new FD(z.message)})},F),this}conflicts(D,u){return T("<string|object> [string|array]",[D,u],arguments.length),X(this,DD,"f").conflicts(D,u),this}config(D="config",u,F){if(T("[object|string] [string|function] [function]",[D,u,F],arguments.length),typeof D==="object"&&!Array.isArray(D))return D=Su(D,X(this,Du,"f"),this[zu]()["deep-merge-config"]||!1,X(this,v,"f")),X(this,I,"f").configObjects=(X(this,I,"f").configObjects||[]).concat(D),this;if(typeof u==="function")F=u,u=void 0;return this.describe(D,u||X(this,y,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(D)?D:[D]).forEach((E)=>{X(this,I,"f").config[E]=F||!0}),this}completion(D,u,F){if(T("[string] [string|boolean|function] [function]",[D,u,F],arguments.length),typeof u==="function")F=u,u=void 0;if(R(this,qD,D||X(this,qD,"f")||"completion","f"),!u&&u!==!1)u="generate completion script";if(this.command(X(this,qD,"f"),u),F)X(this,VD,"f").registerFunction(F);return this}command(D,u,F,E,C,B){return T("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[D,u,F,E,C,B],arguments.length),X(this,ED,"f").addHandler(D,u,F,E,C,B),this}commands(D,u,F,E,C,B){return this.command(D,u,F,E,C,B)}commandDir(D,u){T("<string> [object]",[D,u],arguments.length);let F=X(this,FF,"f")||X(this,v,"f").require;return X(this,ED,"f").addDirectory(D,F,X(this,v,"f").getCallerFile(),u),this}count(D){return T("<array|string>",[D],arguments.length),this[nD]("count",D),this[Ju](D),this}default(D,u,F){if(T("<object|string|array> [*] [string]",[D,u,F],arguments.length),F)dF(D,X(this,v,"f")),X(this,I,"f").defaultDescription[D]=F;if(typeof u==="function"){if(dF(D,X(this,v,"f")),!X(this,I,"f").defaultDescription[D])X(this,I,"f").defaultDescription[D]=X(this,y,"f").functionDescription(u);u=u.call()}return this[Ku](this.default.bind(this),"default",D,u),this}defaults(D,u,F){return this.default(D,u,F)}demandCommand(D=1,u,F,E){if(T("[number] [number|string] [string|null|undefined] [string|null|undefined]",[D,u,F,E],arguments.length),typeof u!=="number")F=u,u=1/0;return this.global("_",!1),X(this,I,"f").demandedCommands._={min:D,max:u,minMsg:F,maxMsg:E},this}demand(D,u,F){if(Array.isArray(u))u.forEach((E)=>{WD(F,!0,X(this,v,"f")),this.demandOption(E,F)}),u=1/0;else if(typeof u!=="number")F=u,u=1/0;if(typeof D==="number")WD(F,!0,X(this,v,"f")),this.demandCommand(D,u,F,F);else if(Array.isArray(D))D.forEach((E)=>{WD(F,!0,X(this,v,"f")),this.demandOption(E,F)});else if(typeof F==="string")this.demandOption(D,F);else if(F===!0||typeof F>"u")this.demandOption(D);return this}demandOption(D,u){return T("<object|string|array> [string]",[D,u],arguments.length),this[Ku](this.demandOption.bind(this),"demandedOptions",D,u),this}deprecateOption(D,u){return T("<string> [string|boolean]",[D,u],arguments.length),X(this,I,"f").deprecatedOptions[D]=u,this}describe(D,u){return T("<object|string|array> [string]",[D,u],arguments.length),this[D0](D,!0),X(this,y,"f").describe(D,u),this}detectLocale(D){return T("<boolean>",[D],arguments.length),R(this,uu,D,"f"),this}env(D){if(T("[string|boolean]",[D],arguments.length),D===!1)delete X(this,I,"f").envPrefix;else X(this,I,"f").envPrefix=D||"";return this}epilogue(D){return T("<string>",[D],arguments.length),X(this,y,"f").epilog(D),this}epilog(D){return this.epilogue(D)}example(D,u){if(T("<string|array> [string]",[D,u],arguments.length),Array.isArray(D))D.forEach((F)=>this.example(...F));else X(this,y,"f").example(D,u);return this}exit(D,u){if(R(this,UD,!0,"f"),R(this,dD,u,"f"),X(this,AD,"f"))X(this,v,"f").process.exit(D)}exitProcess(D=!0){return T("[boolean]",[D],arguments.length),R(this,AD,D,"f"),this}fail(D){if(T("<function|boolean>",[D],arguments.length),typeof D==="boolean"&&D!==!1)throw new FD("Invalid first argument. Expected function or boolean 'false'");return X(this,y,"f").failFn(D),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(D,u){if(T("<array> [function]",[D,u],arguments.length),!u)return new Promise((F,E)=>{X(this,VD,"f").getCompletion(D,(C,B)=>{if(C)E(C);else F(B)})});else return X(this,VD,"f").getCompletion(D,u)}getDemandedOptions(){return T([],0),X(this,I,"f").demandedOptions}getDemandedCommands(){return T([],0),X(this,I,"f").demandedCommands}getDeprecatedOptions(){return T([],0),X(this,I,"f").deprecatedOptions}getDetectLocale(){return X(this,uu,"f")}getExitProcess(){return X(this,AD,"f")}getGroups(){return Object.assign({},X(this,xD,"f"),X(this,Cu,"f"))}getHelp(){if(R(this,UD,!0,"f"),!X(this,y,"f").hasCachedHelpMessage()){if(!this.parsed){let u=this[wu](X(this,iD,"f"),void 0,void 0,0,!0);if(s(u))return u.then(()=>{return X(this,y,"f").help()})}let D=X(this,ED,"f").runDefaultBuilderOn(this);if(s(D))return D.then(()=>{return X(this,y,"f").help()})}return Promise.resolve(X(this,y,"f").help())}getOptions(){return X(this,I,"f")}getStrict(){return X(this,Bu,"f")}getStrictCommands(){return X(this,$u,"f")}getStrictOptions(){return X(this,Gu,"f")}global(D,u){if(T("<string|array> [boolean]",[D,u],arguments.length),D=[].concat(D),u!==!1)X(this,I,"f").local=X(this,I,"f").local.filter((F)=>D.indexOf(F)===-1);else D.forEach((F)=>{if(!X(this,I,"f").local.includes(F))X(this,I,"f").local.push(F)});return this}group(D,u){T("<string|array> <string>",[D,u],arguments.length);let F=X(this,Cu,"f")[u]||X(this,xD,"f")[u];if(X(this,Cu,"f")[u])delete X(this,Cu,"f")[u];let E={};return X(this,xD,"f")[u]=(F||[]).concat(D).filter((C)=>{if(E[C])return!1;return E[C]=!0}),this}hide(D){return T("<string>",[D],arguments.length),X(this,I,"f").hiddenOptions.push(D),this}implies(D,u){return T("<string|object> [number|string|array]",[D,u],arguments.length),X(this,DD,"f").implies(D,u),this}locale(D){if(T("[string]",[D],arguments.length),D===void 0)return this[oF](),X(this,v,"f").y18n.getLocale();return R(this,uu,!1,"f"),X(this,v,"f").y18n.setLocale(D),this}middleware(D,u,F){return X(this,LD,"f").addMiddleware(D,!!u,F)}nargs(D,u){return T("<string|object|array> [number]",[D,u],arguments.length),this[Ku](this.nargs.bind(this),"narg",D,u),this}normalize(D){return T("<array|string>",[D],arguments.length),this[nD]("normalize",D),this}number(D){return T("<array|string>",[D],arguments.length),this[nD]("number",D),this[Ju](D),this}option(D,u){if(T("<string|object> [object]",[D,u],arguments.length),typeof D==="object")Object.keys(D).forEach((F)=>{this.options(F,D[F])});else{if(typeof u!=="object")u={};if(this[Ju](D),X(this,ID,"f")&&(D==="version"||(u===null||u===void 0?void 0:u.alias)==="version"))this[E8](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
79
+ `),void 0,"versionWarning");if(X(this,I,"f").key[D]=!0,u.alias)this.alias(D,u.alias);let F=u.deprecate||u.deprecated;if(F)this.deprecateOption(D,F);let E=u.demand||u.required||u.require;if(E)this.demand(D,E);if(u.demandOption)this.demandOption(D,typeof u.demandOption==="string"?u.demandOption:void 0);if(u.conflicts)this.conflicts(D,u.conflicts);if("default"in u)this.default(D,u.default);if(u.implies!==void 0)this.implies(D,u.implies);if(u.nargs!==void 0)this.nargs(D,u.nargs);if(u.config)this.config(D,u.configParser);if(u.normalize)this.normalize(D);if(u.choices)this.choices(D,u.choices);if(u.coerce)this.coerce(D,u.coerce);if(u.group)this.group(D,u.group);if(u.boolean||u.type==="boolean"){if(this.boolean(D),u.alias)this.boolean(u.alias)}if(u.array||u.type==="array"){if(this.array(D),u.alias)this.array(u.alias)}if(u.number||u.type==="number"){if(this.number(D),u.alias)this.number(u.alias)}if(u.string||u.type==="string"){if(this.string(D),u.alias)this.string(u.alias)}if(u.count||u.type==="count")this.count(D);if(typeof u.global==="boolean")this.global(D,u.global);if(u.defaultDescription)X(this,I,"f").defaultDescription[D]=u.defaultDescription;if(u.skipValidation)this.skipValidation(D);let C=u.describe||u.description||u.desc,B=X(this,y,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(B,D)||typeof C==="string")this.describe(D,C);if(u.hidden)this.hide(D);if(u.requiresArg)this.requiresArg(D)}return this}options(D,u){return this.option(D,u)}parse(D,u,F){if(T("[string|array] [function|boolean|object] [function]",[D,u,F],arguments.length),this[C8](),typeof D>"u")D=X(this,iD,"f");if(typeof u==="object")R(this,Eu,u,"f"),u=F;if(typeof u==="function")R(this,MD,u,"f"),u=!1;if(!u)R(this,iD,D,"f");if(X(this,MD,"f"))R(this,AD,!1,"f");let E=this[wu](D,!!u),C=this.parsed;if(X(this,VD,"f").setParsed(this.parsed),s(E))return E.then((B)=>{if(X(this,MD,"f"))X(this,MD,"f").call(this,X(this,dD,"f"),B,X(this,XD,"f"));return B}).catch((B)=>{if(X(this,MD,"f"))X(this,MD,"f")(B,this.parsed.argv,X(this,XD,"f"));throw B}).finally(()=>{this[u0](),this.parsed=C});else{if(X(this,MD,"f"))X(this,MD,"f").call(this,X(this,dD,"f"),E,X(this,XD,"f"));this[u0](),this.parsed=C}return E}parseAsync(D,u,F){let E=this.parse(D,u,F);return!s(E)?Promise.resolve(E):E}parseSync(D,u,F){let E=this.parse(D,u,F);if(s(E))throw new FD(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return E}parserConfiguration(D){return T("<object>",[D],arguments.length),R(this,EF,D,"f"),this}pkgConf(D,u){T("<string> [string]",[D,u],arguments.length);let F=null,E=this[sF](u||X(this,Du,"f"));if(E[D]&&typeof E[D]==="object")F=Su(E[D],u||X(this,Du,"f"),this[zu]()["deep-merge-config"]||!1,X(this,v,"f")),X(this,I,"f").configObjects=(X(this,I,"f").configObjects||[]).concat(F);return this}positional(D,u){T("<string> <object>",[D,u],arguments.length);let F=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];u=gD(u,(B,$)=>{if(B==="type"&&!["string","number","boolean"].includes($))return!1;return F.includes(B)});let E=X(this,Pu,"f").fullCommands[X(this,Pu,"f").fullCommands.length-1],C=E?X(this,ED,"f").cmdToParseOptions(E):{array:[],alias:{},default:{},demand:{}};return qu(C).forEach((B)=>{let $=C[B];if(Array.isArray($)){if($.indexOf(D)!==-1)u[B]=!0}else if($[D]&&!(B in u))u[B]=$[D]}),this.group(D,X(this,y,"f").getPositionalGroupName()),this.option(D,u)}recommendCommands(D=!0){return T("[boolean]",[D],arguments.length),R(this,CF,D,"f"),this}required(D,u,F){return this.demand(D,u,F)}require(D,u,F){return this.demand(D,u,F)}requiresArg(D){if(T("<array|string|object> [number]",[D],arguments.length),typeof D==="string"&&X(this,I,"f").narg[D])return this;else this[Ku](this.requiresArg.bind(this),"narg",D,NaN);return this}showCompletionScript(D,u){return T("[string] [string]",[D,u],arguments.length),D=D||this.$0,X(this,Fu,"f").log(X(this,VD,"f").generateCompletionScript(D,u||X(this,qD,"f")||"completion")),this}showHelp(D){if(T("[string|function]",[D],arguments.length),R(this,UD,!0,"f"),!X(this,y,"f").hasCachedHelpMessage()){if(!this.parsed){let F=this[wu](X(this,iD,"f"),void 0,void 0,0,!0);if(s(F))return F.then(()=>{X(this,y,"f").showHelp(D)}),this}let u=X(this,ED,"f").runDefaultBuilderOn(this);if(s(u))return u.then(()=>{X(this,y,"f").showHelp(D)}),this}return X(this,y,"f").showHelp(D),this}scriptName(D){return this.customScriptName=!0,this.$0=D,this}showHelpOnFail(D,u){return T("[boolean|string] [string]",[D,u],arguments.length),X(this,y,"f").showHelpOnFail(D,u),this}showVersion(D){return T("[string|function]",[D],arguments.length),X(this,y,"f").showVersion(D),this}skipValidation(D){return T("<array|string>",[D],arguments.length),this[nD]("skipValidation",D),this}strict(D){return T("[boolean]",[D],arguments.length),R(this,Bu,D!==!1,"f"),this}strictCommands(D){return T("[boolean]",[D],arguments.length),R(this,$u,D!==!1,"f"),this}strictOptions(D){return T("[boolean]",[D],arguments.length),R(this,Gu,D!==!1,"f"),this}string(D){return T("<array|string>",[D],arguments.length),this[nD]("string",D),this[Ju](D),this}terminalWidth(){return T([],0),X(this,v,"f").process.stdColumns}updateLocale(D){return this.updateStrings(D)}updateStrings(D){return T("<object>",[D],arguments.length),R(this,uu,!1,"f"),X(this,v,"f").y18n.updateLocale(D),this}usage(D,u,F,E){if(T("<string|null|undefined> [string|boolean] [function|object] [function]",[D,u,F,E],arguments.length),u!==void 0)if(WD(D,null,X(this,v,"f")),(D||"").match(/^\$0( |$)/))return this.command(D,u,F,E);else throw new FD(".usage() description must start with $0 if being used as alias for .command()");else return X(this,y,"f").usage(D),this}usageConfiguration(D){return T("<object>",[D],arguments.length),R(this,BF,D,"f"),this}version(D,u,F){if(T("[boolean|string] [string] [string]",[D,u,F],arguments.length),X(this,ID,"f"))this[tF](X(this,ID,"f")),X(this,y,"f").version(void 0),R(this,ID,null,"f");if(arguments.length===0)F=this[G8](),D="version";else if(arguments.length===1){if(D===!1)return this;F=D,D="version"}else if(arguments.length===2)F=u,u=void 0;return R(this,ID,typeof D==="string"?D:"version","f"),u=u||X(this,y,"f").deferY18nLookup("Show version number"),X(this,y,"f").version(F||void 0),this.boolean(X(this,ID,"f")),this.describe(X(this,ID,"f"),u),this}wrap(D){return T("<number|null|undefined>",[D],arguments.length),X(this,y,"f").wrap(D),this}[(ED=new WeakMap,Du=new WeakMap,Pu=new WeakMap,VD=new WeakMap,qD=new WeakMap,au=new WeakMap,dD=new WeakMap,uu=new WeakMap,eu=new WeakMap,AD=new WeakMap,DF=new WeakMap,LD=new WeakMap,xD=new WeakMap,UD=new WeakMap,ND=new WeakMap,uF=new WeakMap,Fu=new WeakMap,XD=new WeakMap,I=new WeakMap,FF=new WeakMap,EF=new WeakMap,MD=new WeakMap,Eu=new WeakMap,Mu=new WeakMap,Cu=new WeakMap,iD=new WeakMap,CF=new WeakMap,v=new WeakMap,Bu=new WeakMap,$u=new WeakMap,Gu=new WeakMap,y=new WeakMap,BF=new WeakMap,ID=new WeakMap,DD=new WeakMap,u8)](D){if(!D._||!D["--"])return D;D._.push.apply(D._,D["--"]);try{delete D["--"]}catch(u){}return D}[F8](){return{log:(...D)=>{if(!this[$F]())console.log(...D);if(R(this,UD,!0,"f"),X(this,XD,"f").length)R(this,XD,X(this,XD,"f")+`
80
+ `,"f");R(this,XD,X(this,XD,"f")+D.join(" "),"f")},error:(...D)=>{if(!this[$F]())console.error(...D);if(R(this,UD,!0,"f"),X(this,XD,"f").length)R(this,XD,X(this,XD,"f")+`
81
+ `,"f");R(this,XD,X(this,XD,"f")+D.join(" "),"f")}}}[tF](D){qu(X(this,I,"f")).forEach((u)=>{if(((E)=>E==="configObjects")(u))return;let F=X(this,I,"f")[u];if(Array.isArray(F)){if(F.includes(D))F.splice(F.indexOf(D),1)}else if(typeof F==="object")delete F[D]}),delete X(this,y,"f").getDescriptions()[D]}[E8](D,u,F){if(!X(this,eu,"f")[F])X(this,v,"f").process.emitWarning(D,u),X(this,eu,"f")[F]=!0}[C8](){X(this,DF,"f").push({options:X(this,I,"f"),configObjects:X(this,I,"f").configObjects.slice(0),exitProcess:X(this,AD,"f"),groups:X(this,xD,"f"),strict:X(this,Bu,"f"),strictCommands:X(this,$u,"f"),strictOptions:X(this,Gu,"f"),completionCommand:X(this,qD,"f"),output:X(this,XD,"f"),exitError:X(this,dD,"f"),hasOutput:X(this,UD,"f"),parsed:this.parsed,parseFn:X(this,MD,"f"),parseContext:X(this,Eu,"f")}),X(this,y,"f").freeze(),X(this,DD,"f").freeze(),X(this,ED,"f").freeze(),X(this,LD,"f").freeze()}[B8](){let D="",u;if(/\b(node|iojs|electron)(\.exe)?$/.test(X(this,v,"f").process.argv()[0]))u=X(this,v,"f").process.argv().slice(1,2);else u=X(this,v,"f").process.argv().slice(0,1);if(D=u.map((F)=>{let E=this[q8](X(this,Du,"f"),F);return F.match(/^(\/|([a-zA-Z]:)?\\)/)&&E.length<F.length?E:F}).join(" ").trim(),X(this,v,"f").getEnv("_")&&X(this,v,"f").getProcessArgvBin()===X(this,v,"f").getEnv("_"))D=X(this,v,"f").getEnv("_").replace(`${X(this,v,"f").path.dirname(X(this,v,"f").process.execPath())}/`,"");return D}[zu](){return X(this,EF,"f")}[$8](){return X(this,BF,"f")}[oF](){if(!X(this,uu,"f"))return;let D=X(this,v,"f").getEnv("LC_ALL")||X(this,v,"f").getEnv("LC_MESSAGES")||X(this,v,"f").getEnv("LANG")||X(this,v,"f").getEnv("LANGUAGE")||"en_US";this.locale(D.replace(/[.:].*/,""))}[G8](){return this[sF]().version||"unknown"}[z8](D){let u=D["--"]?D["--"]:D._;for(let F=0,E;(E=u[F])!==void 0;F++)if(X(this,v,"f").Parser.looksLikeNumber(E)&&Number.isSafeInteger(Math.floor(parseFloat(`${E}`))))u[F]=Number(E);return D}[sF](D){let u=D||"*";if(X(this,Mu,"f")[u])return X(this,Mu,"f")[u];let F={};try{let E=D||X(this,v,"f").mainFilename;if(X(this,v,"f").path.extname(E))E=X(this,v,"f").path.dirname(E);let C=X(this,v,"f").findUp(E,(B,$)=>{if($.includes("package.json"))return"package.json";else return});WD(C,void 0,X(this,v,"f")),F=JSON.parse(X(this,v,"f").readFileSync(C,"utf8"))}catch(E){}return X(this,Mu,"f")[u]=F||{},X(this,Mu,"f")[u]}[nD](D,u){u=[].concat(u),u.forEach((F)=>{F=this[eF](F),X(this,I,"f")[D].push(F)})}[Ku](D,u,F,E){this[aF](D,u,F,E,(C,B,$)=>{X(this,I,"f")[C][B]=$})}[rF](D,u,F,E){this[aF](D,u,F,E,(C,B,$)=>{X(this,I,"f")[C][B]=(X(this,I,"f")[C][B]||[]).concat($)})}[aF](D,u,F,E,C){if(Array.isArray(F))F.forEach((B)=>{D(B,E)});else if(((B)=>typeof B==="object")(F))for(let B of qu(F))D(B,F[B]);else C(u,this[eF](F),E)}[eF](D){if(D==="__proto__")return"___proto___";return D}[D0](D,u){return this[Ku](this[D0].bind(this),"key",D,u),this}[u0](){var D,u,F,E,C,B,$,G,z,Z,Y,J;let Q=X(this,DF,"f").pop();WD(Q,void 0,X(this,v,"f"));let O;D=this,u=this,F=this,E=this,C=this,B=this,$=this,G=this,z=this,Z=this,Y=this,J=this,{options:{set value(V){R(D,I,V,"f")}}.value,configObjects:O,exitProcess:{set value(V){R(u,AD,V,"f")}}.value,groups:{set value(V){R(F,xD,V,"f")}}.value,output:{set value(V){R(E,XD,V,"f")}}.value,exitError:{set value(V){R(C,dD,V,"f")}}.value,hasOutput:{set value(V){R(B,UD,V,"f")}}.value,parsed:this.parsed,strict:{set value(V){R($,Bu,V,"f")}}.value,strictCommands:{set value(V){R(G,$u,V,"f")}}.value,strictOptions:{set value(V){R(z,Gu,V,"f")}}.value,completionCommand:{set value(V){R(Z,qD,V,"f")}}.value,parseFn:{set value(V){R(Y,MD,V,"f")}}.value,parseContext:{set value(V){R(J,Eu,V,"f")}}.value}=Q,X(this,I,"f").configObjects=O,X(this,y,"f").unfreeze(),X(this,DD,"f").unfreeze(),X(this,ED,"f").unfreeze(),X(this,LD,"f").unfreeze()}[Z8](D,u){return eD(u,(F)=>{return D(F),F})}getInternalMethods(){return{getCommandInstance:this[J8].bind(this),getContext:this[X8].bind(this),getHasOutput:this[Q8].bind(this),getLoggerInstance:this[Y8].bind(this),getParseContext:this[W8].bind(this),getParserConfiguration:this[zu].bind(this),getUsageConfiguration:this[$8].bind(this),getUsageInstance:this[O8].bind(this),getValidationInstance:this[V8].bind(this),hasParseCallback:this[$F].bind(this),isGlobalContext:this[H8].bind(this),postProcess:this[Zu].bind(this),reset:this[F0].bind(this),runValidation:this[E0].bind(this),runYargsParserAndExecuteCommands:this[wu].bind(this),setHasOutput:this[U8].bind(this)}}[J8](){return X(this,ED,"f")}[X8](){return X(this,Pu,"f")}[Q8](){return X(this,UD,"f")}[Y8](){return X(this,Fu,"f")}[W8](){return X(this,Eu,"f")||{}}[O8](){return X(this,y,"f")}[V8](){return X(this,DD,"f")}[$F](){return!!X(this,MD,"f")}[H8](){return X(this,uF,"f")}[Zu](D,u,F,E){if(F)return D;if(s(D))return D;if(!u)D=this[u8](D);if(this[zu]()["parse-positional-numbers"]||this[zu]()["parse-positional-numbers"]===void 0)D=this[z8](D);if(E)D=aD(D,this,X(this,LD,"f").getMiddleware(),!1);return D}[F0](D={}){R(this,I,X(this,I,"f")||{},"f");let u={};u.local=X(this,I,"f").local||[],u.configObjects=X(this,I,"f").configObjects||[];let F={};u.local.forEach((B)=>{F[B]=!0,(D[B]||[]).forEach(($)=>{F[$]=!0})}),Object.assign(X(this,Cu,"f"),Object.keys(X(this,xD,"f")).reduce((B,$)=>{let G=X(this,xD,"f")[$].filter((z)=>!(z in F));if(G.length>0)B[$]=G;return B},{})),R(this,xD,{},"f");let E=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],C=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(E.forEach((B)=>{u[B]=(X(this,I,"f")[B]||[]).filter(($)=>!F[$])}),C.forEach((B)=>{u[B]=gD(X(this,I,"f")[B],($)=>!F[$])}),u.envPrefix=X(this,I,"f").envPrefix,R(this,I,u,"f"),R(this,y,X(this,y,"f")?X(this,y,"f").reset(F):n2(this,X(this,v,"f")),"f"),R(this,DD,X(this,DD,"f")?X(this,DD,"f").reset(F):e2(this,X(this,y,"f"),X(this,v,"f")),"f"),R(this,ED,X(this,ED,"f")?X(this,ED,"f").reset():k2(X(this,y,"f"),X(this,DD,"f"),X(this,LD,"f"),X(this,v,"f")),"f"),!X(this,VD,"f"))R(this,VD,s2(this,X(this,y,"f"),X(this,ED,"f"),X(this,v,"f")),"f");return X(this,LD,"f").reset(),R(this,qD,null,"f"),R(this,XD,"","f"),R(this,dD,null,"f"),R(this,UD,!1,"f"),this.parsed=!1,this}[q8](D,u){return X(this,v,"f").path.relative(D,u)}[wu](D,u,F,E=0,C=!1){var B,$,G,z;let Z=!!F||C;D=D||X(this,iD,"f"),X(this,I,"f").__=X(this,v,"f").y18n.__,X(this,I,"f").configuration=this[zu]();let Y=!!X(this,I,"f").configuration["populate--"],J=Object.assign({},X(this,I,"f").configuration,{"populate--":!0}),Q=X(this,v,"f").Parser.detailed(D,Object.assign({},X(this,I,"f"),{configuration:{"parse-positional-numbers":!1,...J}})),O=Object.assign(Q.argv,X(this,Eu,"f")),V=void 0,W=Q.aliases,M=!1,_=!1;if(Object.keys(O).forEach((N)=>{if(N===X(this,ND,"f")&&O[N])M=!0;else if(N===X(this,ID,"f")&&O[N])_=!0}),O.$0=this.$0,this.parsed=Q,E===0)X(this,y,"f").clearCachedHelpMessage();try{if(this[oF](),u)return this[Zu](O,Y,!!F,!1);if(X(this,ND,"f")){if([X(this,ND,"f")].concat(W[X(this,ND,"f")]||[]).filter((e)=>e.length>1).includes(""+O._[O._.length-1]))O._.pop(),M=!0}R(this,uF,!1,"f");let N=X(this,ED,"f").getCommands(),k=((B=X(this,VD,"f"))===null||B===void 0?void 0:B.completionKey)?[($=X(this,VD,"f"))===null||$===void 0?void 0:$.completionKey,...(z=this.getAliases()[(G=X(this,VD,"f"))===null||G===void 0?void 0:G.completionKey])!==null&&z!==void 0?z:[]].some((c)=>Object.prototype.hasOwnProperty.call(O,c)):!1,w=M||k||C;if(O._.length){if(N.length){let c;for(let e=E||0,r;O._[e]!==void 0;e++)if(r=String(O._[e]),N.includes(r)&&r!==X(this,qD,"f")){let _D=X(this,ED,"f").runCommand(r,this,Q,e+1,C,M||_||C);return this[Zu](_D,Y,!!F,!1)}else if(!c&&r!==X(this,qD,"f")){c=r;break}if(!X(this,ED,"f").hasDefaultCommand()&&X(this,CF,"f")&&c&&!w)X(this,DD,"f").recommendCommands(c,N)}if(X(this,qD,"f")&&O._.includes(X(this,qD,"f"))&&!k){if(X(this,AD,"f"))kD(!0);this.showCompletionScript(),this.exit(0)}}if(X(this,ED,"f").hasDefaultCommand()&&!w){let c=X(this,ED,"f").runCommand(null,this,Q,0,C,M||_||C);return this[Zu](c,Y,!!F,!1)}if(k){if(X(this,AD,"f"))kD(!0);D=[].concat(D);let c=D.slice(D.indexOf(`--${X(this,VD,"f").completionKey}`)+1);return X(this,VD,"f").getCompletion(c,(e,r)=>{if(e)throw new FD(e.message);(r||[]).forEach((_D)=>{X(this,Fu,"f").log(_D)}),this.exit(0)}),this[Zu](O,!Y,!!F,!1)}if(!X(this,UD,"f")){if(M){if(X(this,AD,"f"))kD(!0);Z=!0,this.showHelp((c)=>{X(this,Fu,"f").log(c),this.exit(0)})}else if(_){if(X(this,AD,"f"))kD(!0);Z=!0,X(this,y,"f").showVersion("log"),this.exit(0)}}if(!Z&&X(this,I,"f").skipValidation.length>0)Z=Object.keys(O).some((c)=>X(this,I,"f").skipValidation.indexOf(c)>=0&&O[c]===!0);if(!Z){if(Q.error)throw new FD(Q.error.message);if(!k){let c=this[E0](W,{},Q.error);if(!F)V=aD(O,this,X(this,LD,"f").getMiddleware(),!0);if(V=this[Z8](c,V!==null&&V!==void 0?V:O),s(V)&&!F)V=V.then(()=>{return aD(O,this,X(this,LD,"f").getMiddleware(),!1)})}}}catch(N){if(N instanceof FD)X(this,y,"f").fail(N.message,N);else throw N}return this[Zu](V!==null&&V!==void 0?V:O,Y,!!F,!0)}[E0](D,u,F,E){let C={...this.getDemandedOptions()};return(B)=>{if(F)throw new FD(F.message);X(this,DD,"f").nonOptionCount(B),X(this,DD,"f").requiredArguments(B,C);let $=!1;if(X(this,$u,"f"))$=X(this,DD,"f").unknownCommands(B);if(X(this,Bu,"f")&&!$)X(this,DD,"f").unknownArguments(B,D,u,!!E);else if(X(this,Gu,"f"))X(this,DD,"f").unknownArguments(B,D,{},!1,!1);X(this,DD,"f").limitedChoices(B),X(this,DD,"f").implications(B),X(this,DD,"f").conflicting(B)}}[U8](){R(this,UD,!0,"f")}[Ju](D){if(typeof D==="string")X(this,I,"f").key[D]=!0;else for(let u of D)X(this,I,"f").key[u]=!0}}function d2(D){return!!D&&typeof D.getInternalMethods==="function"}var q6=M8(kF),_8=q6;import{existsSync as GF,readFileSync as $0,writeFileSync as C0,mkdirSync as L8}from"node:fs";import{homedir as U6}from"node:os";import{join as Xu,dirname as G0}from"node:path";function z0(){return process.env.HOME||U6()}function N8(){return Xu(z0(),".config","slack-cli","profiles.json")}function zF(){return Xu(process.cwd(),".slack-cli","workspace")}function ZF(){return Xu(z0(),".slack-cli","workspace")}function xu(){let D=N8();if(!GF(D))return{profiles:{}};return JSON.parse($0(D,"utf8"))}function M6(D){let u=N8();L8(G0(u),{recursive:!0}),C0(u,JSON.stringify(D,null,2)+`
82
+ `)}function _u(D){if(!GF(D))return;return $0(D,"utf8").trim()||void 0}function j8(D,u){let F=G0(D);L8(F,{recursive:!0});let E=Xu(F,".gitignore");if(!GF(E))C0(E,`*
83
83
  `);C0(D,u+`
84
84
  `)}function K6(D){let u={};for(let F of D.split(`
85
- `)){let E=F.trim();if(!E||E.startsWith("#"))continue;let C=E.indexOf("=");if(C===-1)continue;let B=E.slice(0,C).trim(),$=E.slice(C+1).trim();if($.startsWith('"')&&$.endsWith('"')||$.startsWith("'")&&$.endsWith("'"))$=$.slice(1,-1);u[B]=$}return u}function A8(D){if(!$F(D))return{};try{return K6($0(D,"utf8"))}catch{return{}}}function B0(D,u){let F=z0(),E=D;while(!0){for(let $ of[Xu(E,".slack-term",".env.local"),Xu(E,".env.local")]){let G=A8($);for(let Z of u)if(G[Z])return G[Z]}if(E===F)break;let B=G0(E);if(B===E)break;E=B}let C=A8(Xu(F,".slack-term",".env.local"));for(let B of u)if(C[B])return C[B];return}function T8(){let D=xu(),u=_u(GF()),F=_u(zF()),E=u??F;return Object.entries(D.profiles).map(([C,B])=>({name:C,profile:B,current:C===E}))}function R8(D){let u=xu();if(!(D in u.profiles))throw Error(`Profile not found: ${D}`);delete u.profiles[D],M6(u)}function S8(D,u=!1){let F=xu();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);if(u)j8(zF(),D);else j8(GF(),D)}function Z0(D){let F=xu().profiles,E=Object.keys(F);if(D){let z=F[D];if(!z)throw Error(`Workspace "${D}" not found. Available: ${E.join(", ")||"(none)"}`);return z.token}if(process.env.SLACK_TOKEN)return process.env.SLACK_TOKEN;let C=process.env.SLACK_BOT_TOKEN??process.env.SLACK_MCP_XOXP_TOKEN;if(C&&E.length===0)return C;if(C&&E.length>0){let z=B0(process.cwd(),["SLACK_BOT_TOKEN","SLACK_MCP_XOXP_TOKEN"]);if(C!==z){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 B=B0(process.cwd(),["SLACK_TOKEN"]);if(B)return B;let $=process.env.SLACK_WORKSPACE;if($){let z=F[$];if(!z)throw Error(`Workspace "${$}" not found. Available: ${E.join(", ")||"(none)"}`);return z.token}let G=_u(GF());if(G){let z=F[G];if(!z)throw Error(`Workspace "${G}" (from .slack-cli/workspace) not found in profiles.`);return z.token}let Z=_u(zF());if(Z){let z=F[Z];if(!z)throw Error(`Workspace "${Z}" (from ~/.slack-cli/workspace) not found in profiles.`);return z.token}if(E.length>0)throw Error(`Workspace not selected (${E.join(", ")} available).
87
- Select locally: slack workspace use <name> (writes .slack-cli/workspace)
88
- Select globally: slack workspace use -g <name> (writes ~/.slack-cli/workspace)`);throw Error(`No Slack token found.
85
+ `)){let E=F.trim();if(!E||E.startsWith("#"))continue;let C=E.indexOf("=");if(C===-1)continue;let B=E.slice(0,C).trim(),$=E.slice(C+1).trim();if($.startsWith('"')&&$.endsWith('"')||$.startsWith("'")&&$.endsWith("'"))$=$.slice(1,-1);u[B]=$}return u}function A8(D){if(!GF(D))return{};try{return K6($0(D,"utf8"))}catch{return{}}}function B0(D,u){let F=z0(),E=D;while(!0){for(let $ of[Xu(E,".slack-term",".env.local"),Xu(E,".env.local")]){let G=A8($);for(let z of u)if(G[z])return G[z]}if(E===F)break;let B=G0(E);if(B===E)break;E=B}let C=A8(Xu(F,".slack-term",".env.local"));for(let B of u)if(C[B])return C[B];return}function T8(){let D=xu(),u=_u(zF()),F=_u(ZF()),E=u??F;return Object.entries(D.profiles).map(([C,B])=>({name:C,profile:B,current:C===E}))}function R8(D){let u=xu();if(!(D in u.profiles))throw Error(`Profile not found: ${D}`);delete u.profiles[D],M6(u)}function S8(D,u=!1){let F=xu();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);if(u)j8(ZF(),D);else j8(zF(),D)}function Z0(D){let F=xu().profiles,E=Object.keys(F);if(D){let Z=F[D];if(!Z)throw Error(`Workspace "${D}" not found. Available: ${E.join(", ")||"(none)"}`);return Z.token}if(process.env.SLACK_TOKEN)return process.env.SLACK_TOKEN;let C=process.env.SLACK_BOT_TOKEN??process.env.SLACK_MCP_XOXP_TOKEN;if(C&&E.length===0)return C;if(C&&E.length>0){let Z=B0(process.cwd(),["SLACK_BOT_TOKEN","SLACK_MCP_XOXP_TOKEN"]);if(C!==Z){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 B=B0(process.cwd(),["SLACK_TOKEN"]);if(B)return B;let $=process.env.SLACK_WORKSPACE;if($){let Z=F[$];if(!Z)throw Error(`Workspace "${$}" not found. Available: ${E.join(", ")||"(none)"}`);return Z.token}let G=_u(zF());if(G){let Z=F[G];if(!Z)throw Error(`Workspace "${G}" (from .slack-cli/workspace) not found in profiles.`);return Z.token}let z=_u(ZF());if(z){let Z=F[z];if(!Z)throw Error(`Workspace "${z}" (from ~/.slack-cli/workspace) not found in profiles.`);return Z.token}if(E.length>0)throw Error(`Workspace not selected (${E.join(", ")} available).
87
+ Select locally: slack auth use <name> (writes .slack-cli/workspace)
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 J0(){let D=process.env.SLACK_BOT_TOKEN;return D&&D.startsWith("xoxb-")?D:void 0}function P8(D){let F=xu().profiles;if(D)return F[D]?.cookie;if(process.env.SLACK_COOKIE)return process.env.SLACK_COOKIE;if(process.env.SLACK_MCP_XOXD_COOKIE)return process.env.SLACK_MCP_XOXD_COOKIE;if(process.env.SLACK_MCP_XOXP_TOKEN&&Object.keys(F).length===0)return process.env.SLACK_MCP_XOXD_COOKIE;let C=B0(process.cwd(),["SLACK_COOKIE"]);if(C)return C;let B=process.env.SLACK_WORKSPACE;if(B)return F[B]?.cookie;let $=_u(GF());if($)return F[$]?.cookie;let G=_u(zF());if(G)return F[G]?.cookie;return}class lD extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function X0(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function w8(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${X0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let G=parseInt(B.headers.get("retry-after")??"60",10);throw new lD(isNaN(G)?60:G)}let $=await B.json();if($.ok!==!0){let G=$.error??"unknown";if(G==="ratelimited")throw new lD(60);if(G==="invalid_auth"&&D.startsWith("xoxc-")&&!E)throw Error(`Desktop app token (xoxc-) is not accepted by the public Slack API.
93
+ `+" Or set SLACK_TOKEN=xoxp-... in .slack-term/.env.local")}function J0(){let D=process.env.SLACK_BOT_TOKEN;return D&&D.startsWith("xoxb-")?D:void 0}function P8(D){let F=xu().profiles;if(D)return F[D]?.cookie;if(process.env.SLACK_COOKIE)return process.env.SLACK_COOKIE;if(process.env.SLACK_MCP_XOXD_COOKIE)return process.env.SLACK_MCP_XOXD_COOKIE;if(process.env.SLACK_MCP_XOXP_TOKEN&&Object.keys(F).length===0)return process.env.SLACK_MCP_XOXD_COOKIE;let C=B0(process.cwd(),["SLACK_COOKIE"]);if(C)return C;let B=process.env.SLACK_WORKSPACE;if(B)return F[B]?.cookie;let $=_u(zF());if($)return F[$]?.cookie;let G=_u(ZF());if(G)return F[G]?.cookie;return}class lD extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function X0(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function w8(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${X0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let G=parseInt(B.headers.get("retry-after")??"60",10);throw new lD(isNaN(G)?60:G)}let $=await B.json();if($.ok!==!0){let G=$.error??"unknown";if(G==="ratelimited")throw new lD(60);if(G==="invalid_auth"&&D.startsWith("xoxc-")&&!E)throw Error(`Desktop app token (xoxc-) is not accepted by the public Slack API.
94
94
  Replace it with an xoxp- user token:
95
- slack workspace set-token <name> <xoxp-token>`);throw Error(`Slack error on ${u}: ${G}`)}return $}async function _6(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${X0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let G=parseInt(B.headers.get("retry-after")??"60",10);throw new lD(isNaN(G)?60:G)}let $=await B.json();if($.ok!==!0){let G=$.error??"unknown";if(G==="ratelimited")throw new lD(60);if((G==="invalid_auth"||G==="not_authed")&&!D.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
96
- Import from Slack desktop: slack workspace import`);if((G==="invalid_auth"||G==="not_authed")&&!E)throw Error(`drafts.list also requires the xoxd session cookie.
97
- Set it with: slack workspace set-cookie <workspace-name> <xoxd-value>
98
- `+"Get xoxd from browser: DevTools → Application → Cookies → slack.com d");throw Error(`Slack error on ${u}: ${G}`)}return $}function j6(D,u,F={},E){let C=new URLSearchParams({token:D,...F});return _6(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:C.toString()},E)}function OD(D,u,F,E){let C=new URLSearchParams(F).toString();return w8(D,`${u}?${C}`,{method:"GET"},E)}function A6(D,u,F){return w8(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)})}async function ZF(D){let u=await OD(D,"auth.test",{});return{team:u.team??"",teamId:u.team_id??"",url:u.url??"",user:u.user??"",userId:u.user_id??""}}async function x8(D){let u=await fetch(`${X0()}/auth.test`,{method:"GET",headers:{Authorization:`Bearer ${D}`}});if(u.status===429){let C=parseInt(u.headers.get("retry-after")??"60",10);throw new lD(isNaN(C)?60:C)}let F=u.headers.get("x-oauth-scopes")??"",E=await u.json();if(E.ok!==!0)throw Error(`Slack error on auth.test: ${E.error??"unknown"}`);return{userId:E.user_id??"",botId:E.bot_id??"",team:E.team??"",url:E.url??"",scopes:F.split(",").map((C)=>C.trim()).filter(Boolean)}}async function I8(D,u){let F=await OD(D,"bots.info",{bot:u});return{appId:F.bot?.app_id??"",userId:F.bot?.user_id??""}}async function Q0(D,u,F=20,E,C){let B={channel:u,limit:String(F)};if(E!==void 0)B.oldest=E;if(C!==void 0)B.cursor=C;return OD(D,"conversations.history",B)}async function b8(D,u,F,E=50){return OD(D,"conversations.replies",{channel:u,ts:F,limit:String(E)})}async function L6(D,u){let E=(await A6(D,"conversations.open",{users:u})).channel?.id;if(!E)throw Error(`Failed to open DM with user ${u}`);return E}function Iu(D){return D.toLowerCase().replace(/[-_\s]/g,"")}function Y0(D){let u=D.match(/(?:app\.slack\.com\/client\/T[A-Za-z0-9]+|[A-Za-z0-9-]+\.slack\.com\/archives)\/([A-Za-z0-9]+)(?:\/p(\d{10})(\d{6}))?/);if(!u)return;let F=u[1],E=u[2]&&u[3]?`${u[2]}.${u[3]}`:void 0,C=D.indexOf("?"),B=C>=0?new URLSearchParams(D.slice(C)):void 0,$=B?.get("thread_ts")??void 0,z={channel:B?.get("cid")??void 0??F};if(E)z.ts=E;if($)z.threadTs=$;return z}function N6(D){return Y0(D)?.channel}async function f8(D,u,F){let E=N6(u);if(E)return E;if(!u.startsWith("@")&&!u.startsWith("#")){if(/^[A-Za-z0-9]{9,}$/.test(u))return u;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${u}`)}let C=u.startsWith("@"),B=u.slice(1),$=Iu(B);if(C){let z=await OD(D,"auth.test",{},F);if($==="you"||$==="me"||Iu(z.user??"")===$){let V=z.user_id;if(!V)throw Error("auth.test did not return user_id");let M=((await OD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((_)=>_.user===V);if(M?.id)return String(M.id);return L6(D,V)}let J="",Q="";while(!0){let V={limit:"200"};if(Q)V.cursor=Q;let W=await OD(D,"users.list",V,F);for(let M of W.members??[]){let _=Iu(M.name??""),N=Iu(M.real_name??""),k=Iu(M.profile?.display_name??"");if(_===$||N===$||k&&k===$){J=M.id??"";break}}if(J)break;if(Q=W.response_metadata?.next_cursor??"",!Q)break}if(!J)throw Error(`User not found: ${u}`);let O="";while(!0){let V={types:"im",limit:"200"};if(O)V.cursor=O;let W=await OD(D,"conversations.list",V,F);for(let M of W.channels??[])if(M.user===J)return String(M.id??"");if(O=W.response_metadata?.next_cursor??"",!O)break}throw Error(`No existing DM with ${u} (${J}). Open it once in Slack first.`)}let G=B.toLowerCase(),Z="";while(!0){let z={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(Z)z.cursor=Z;let Y=await OD(D,"conversations.list",z,F);for(let J of Y.channels??[])if(String(J.name??"").toLowerCase()===G)return String(J.id??"");if(Z=Y.response_metadata?.next_cursor??"",!Z)break}throw Error(`channel not found: ${u}`)}async function JF(D,u){try{let F=await OD(D,"users.info",{user:u}),E=F.user?.profile?.display_name,C=E&&E.length>0?E:F.user?.real_name??F.user?.name??u,B=F.user?.name??u;return[C,B]}catch{return[u,u]}}async function XF(D,u){try{let F=await OD(D,"users.info",{user:u}),E=F.user?.profile?.display_name;if(E&&E.length>0)return E;return F.user?.real_name??F.user?.name??u}catch{return u}}async function QF(D){let u=[],F="";while(!0){let E={limit:"200"};if(F)E.cursor=F;let C=await OD(D,"users.list",E);if(u.push(...C.members??[]),F=C.response_metadata?.next_cursor??"",!F)break}return{members:u}}async function W0(D,u){let F=[],E="";while(!0){let C={channel:u,limit:"200"};if(E)C.cursor=E;let B=await OD(D,"conversations.members",C);if(F.push(...B.members??[]),E=B.response_metadata?.next_cursor??"",!E)break}return F}async function O0(D,u){return OD(D,"users.info",{user:u})}async function h8(D,u){return OD(D,"conversations.info",{channel:u})}async function v8(D,u){let F=await j6(D,"client.boot",{},u),E=typeof F.url==="string"?F.url:void 0;if(!E){let B=Object.keys(F).join(", ");throw Error(`client.boot did not return a WebSocket URL. Keys: ${B}`)}let C=F.self&&typeof F.self==="object"&&!Array.isArray(F.self)?F.self:{};return{wsUrl:E,selfId:typeof C.id==="string"?C.id:""}}var T6=["chat:write","im:write"],R6=["im:history","im:read"];async function V0(D){let{userId:u,botId:F,team:E,scopes:C}=await x8(D),B="";if(F)try{B=(await I8(D,F)).appId}catch{B=""}let $=(z)=>C.includes(z),G=T6.filter((z)=>!$(z)),Z=R6.filter((z)=>!$(z));return{canSend:G.length===0,canReceiveReplies:Z.length===0,ok:G.length===0&&Z.length===0,botUserId:u,appId:B,team:E,grantedScopes:C,missingSendScopes:G,missingReplyScopes:Z}}function p8(D){return["",` Bot user: ${D.botUserId||"(unknown)"}`,` App ID: ${D.appId||"(unknown — bots.info unavailable)"}`,` Granted scopes: ${D.grantedScopes.join(", ")||"(none reported)"}`]}function H0(D,u=!1){let F=D.appId?`https://api.slack.com/apps/${D.appId}`:"https://api.slack.com/apps";if(D.ok){let C=["✓ Bot DM scopes are complete (send + read replies)."," Two-way replies also require the Messages Tab, which is not API-detectable.",' If recipients see "Sending messages to this app is turned off", enable it:',` ${F} → App Home → "Messages Tab" ON + "Allow users to send messages".`];return u?C:[...C,...p8(D)]}let E=[];if(!D.canSend)E.push(`⚠ This bot CANNOT send DMs — missing scope(s): ${D.missingSendScopes.join(", ")}.`);else E.push("⚠ This bot can send DMs, but the user's replies will NOT be readable.");return E.push(" Make escalation DMs two-way:"),E.push(` 1. ${F} → App Home → enable "Messages Tab" and check`),E.push(' "Allow users to send Slash commands and messages".'),E.push(` 2. OAuth & Permissions → add Bot Token Scopes: ${[...D.missingSendScopes,...D.missingReplyScopes].join(", ")}`),E.push(" 3. Reinstall the app to apply the new scopes."),u?E:[...E,...p8(D)]}import{createInterface as Yu}from"node:readline/promises";import{join as A0}from"node:path";import{homedir as c6}from"node:os";import{existsSync as q0,readFileSync as U0,writeFileSync as y8,mkdirSync as c8}from"node:fs";import{homedir as S6}from"node:os";import{join as M0,dirname as g8}from"node:path";function k8(){return process.env.HOME||S6()}function d8(){return M0(k8(),".config","slack-cli","profiles.json")}function P6(){return M0(process.cwd(),".slack-cli","workspace")}function w6(){return M0(k8(),".slack-cli","workspace")}function K0(){let D=d8();if(!q0(D))return{profiles:{}};return JSON.parse(U0(D,"utf8"))}function i8(D){let u=d8();c8(g8(u),{recursive:!0}),y8(u,JSON.stringify(D,null,2)+`
99
- `)}function m8(D){if(!q0(D))return;return U0(D,"utf8").trim()||void 0}function n8(D,u){c8(g8(D),{recursive:!0});let F=q0(D)?U0(D,"utf8"):"",E=F?F.split(`
100
- `):[];for(let[C,B]of Object.entries(u)){let $=E.findIndex((Z)=>{let z=Z.trim();return z.startsWith(C+"=")||z.startsWith(C+" =")}),G=`${C}=${B}`;if($!==-1)E[$]=G;else E.push(G)}y8(D,E.join(`
95
+ slack auth token`);if((G==="missing_scope"||G==="cannot_dm_bot")&&D.startsWith("xoxb-"))throw Error(`Slack error on ${u}: ${G} ${G==="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"}.
96
+ Tailing/DMing people and listing users need a user session, not a bot token.
97
+ Switch workspace: slack auth ls then slack auth use <name>
98
+ Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${u}: ${G}`)}return $}async function _6(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${X0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let G=parseInt(B.headers.get("retry-after")??"60",10);throw new lD(isNaN(G)?60:G)}let $=await B.json();if($.ok!==!0){let G=$.error??"unknown";if(G==="ratelimited")throw new lD(60);if((G==="invalid_auth"||G==="not_authed")&&!D.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
99
+ Import from Slack desktop: slack auth login`);if((G==="invalid_auth"||G==="not_authed")&&!E)throw Error(`drafts.list also requires the xoxd session cookie.
100
+ Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${u}: ${G}`)}return $}function j6(D,u,F={},E){let C=new URLSearchParams({token:D,...F});return _6(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:C.toString()},E)}function OD(D,u,F,E){let C=new URLSearchParams(F).toString();return w8(D,`${u}?${C}`,{method:"GET"},E)}function A6(D,u,F){return w8(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)})}async function JF(D){let u=await OD(D,"auth.test",{});return{team:u.team??"",teamId:u.team_id??"",url:u.url??"",user:u.user??"",userId:u.user_id??""}}async function x8(D){let u=await fetch(`${X0()}/auth.test`,{method:"GET",headers:{Authorization:`Bearer ${D}`}});if(u.status===429){let C=parseInt(u.headers.get("retry-after")??"60",10);throw new lD(isNaN(C)?60:C)}let F=u.headers.get("x-oauth-scopes")??"",E=await u.json();if(E.ok!==!0)throw Error(`Slack error on auth.test: ${E.error??"unknown"}`);return{userId:E.user_id??"",botId:E.bot_id??"",team:E.team??"",url:E.url??"",scopes:F.split(",").map((C)=>C.trim()).filter(Boolean)}}async function I8(D,u){let F=await OD(D,"bots.info",{bot:u});return{appId:F.bot?.app_id??"",userId:F.bot?.user_id??""}}async function Q0(D,u,F=20,E,C){let B={channel:u,limit:String(F)};if(E!==void 0)B.oldest=E;if(C!==void 0)B.cursor=C;return OD(D,"conversations.history",B)}async function b8(D,u,F,E=50){return OD(D,"conversations.replies",{channel:u,ts:F,limit:String(E)})}async function L6(D,u){let E=(await A6(D,"conversations.open",{users:u})).channel?.id;if(!E)throw Error(`Failed to open DM with user ${u}`);return E}function Iu(D){return D.toLowerCase().replace(/[-_\s]/g,"")}function Y0(D){let u=D.match(/(?:app\.slack\.com\/client\/T[A-Za-z0-9]+|[A-Za-z0-9-]+\.slack\.com\/archives)\/([A-Za-z0-9]+)(?:\/p(\d{10})(\d{6}))?/);if(!u)return;let F=u[1],E=u[2]&&u[3]?`${u[2]}.${u[3]}`:void 0,C=D.indexOf("?"),B=C>=0?new URLSearchParams(D.slice(C)):void 0,$=B?.get("thread_ts")??void 0,Z={channel:B?.get("cid")??void 0??F};if(E)Z.ts=E;if($)Z.threadTs=$;return Z}function N6(D){return Y0(D)?.channel}async function f8(D,u,F){let E=N6(u);if(E)return E;if(!u.startsWith("@")&&!u.startsWith("#")){if(/^[A-Za-z0-9]{9,}$/.test(u))return u;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${u}`)}let C=u.startsWith("@"),B=u.slice(1),$=Iu(B);if(C){let Z=await OD(D,"auth.test",{},F);if($==="you"||$==="me"||Iu(Z.user??"")===$){let V=Z.user_id;if(!V)throw Error("auth.test did not return user_id");let M=((await OD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((_)=>_.user===V);if(M?.id)return String(M.id);return L6(D,V)}let J="",Q="";while(!0){let V={limit:"200"};if(Q)V.cursor=Q;let W=await OD(D,"users.list",V,F);for(let M of W.members??[]){let _=Iu(M.name??""),N=Iu(M.real_name??""),k=Iu(M.profile?.display_name??"");if(_===$||N===$||k&&k===$){J=M.id??"";break}}if(J)break;if(Q=W.response_metadata?.next_cursor??"",!Q)break}if(!J)throw Error(`User not found: ${u}`);let O="";while(!0){let V={types:"im",limit:"200"};if(O)V.cursor=O;let W=await OD(D,"conversations.list",V,F);for(let M of W.channels??[])if(M.user===J)return String(M.id??"");if(O=W.response_metadata?.next_cursor??"",!O)break}throw Error(`No existing DM with ${u} (${J}). Open it once in Slack first.`)}let G=B.toLowerCase(),z="";while(!0){let Z={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(z)Z.cursor=z;let Y=await OD(D,"conversations.list",Z,F);for(let J of Y.channels??[])if(String(J.name??"").toLowerCase()===G)return String(J.id??"");if(z=Y.response_metadata?.next_cursor??"",!z)break}throw Error(`channel not found: ${u}`)}async function XF(D,u){try{let F=await OD(D,"users.info",{user:u}),E=F.user?.profile?.display_name,C=E&&E.length>0?E:F.user?.real_name??F.user?.name??u,B=F.user?.name??u;return[C,B]}catch{return[u,u]}}async function QF(D,u){try{let F=await OD(D,"users.info",{user:u}),E=F.user?.profile?.display_name;if(E&&E.length>0)return E;return F.user?.real_name??F.user?.name??u}catch{return u}}async function YF(D){let u=[],F="";while(!0){let E={limit:"200"};if(F)E.cursor=F;let C=await OD(D,"users.list",E);if(u.push(...C.members??[]),F=C.response_metadata?.next_cursor??"",!F)break}return{members:u}}async function W0(D,u){let F=[],E="";while(!0){let C={channel:u,limit:"200"};if(E)C.cursor=E;let B=await OD(D,"conversations.members",C);if(F.push(...B.members??[]),E=B.response_metadata?.next_cursor??"",!E)break}return F}async function O0(D,u){return OD(D,"users.info",{user:u})}async function h8(D,u){return OD(D,"conversations.info",{channel:u})}async function v8(D,u){let F=await j6(D,"client.boot",{},u),E=typeof F.url==="string"?F.url:void 0;if(!E){let B=Object.keys(F).join(", ");throw Error(`client.boot did not return a WebSocket URL. Keys: ${B}`)}let C=F.self&&typeof F.self==="object"&&!Array.isArray(F.self)?F.self:{};return{wsUrl:E,selfId:typeof C.id==="string"?C.id:""}}var T6=["chat:write","im:write"],R6=["im:history","im:read"];async function V0(D){let{userId:u,botId:F,team:E,scopes:C}=await x8(D),B="";if(F)try{B=(await I8(D,F)).appId}catch{B=""}let $=(Z)=>C.includes(Z),G=T6.filter((Z)=>!$(Z)),z=R6.filter((Z)=>!$(Z));return{canSend:G.length===0,canReceiveReplies:z.length===0,ok:G.length===0&&z.length===0,botUserId:u,appId:B,team:E,grantedScopes:C,missingSendScopes:G,missingReplyScopes:z}}function p8(D){return["",` Bot user: ${D.botUserId||"(unknown)"}`,` App ID: ${D.appId||"(unknown — bots.info unavailable)"}`,` Granted scopes: ${D.grantedScopes.join(", ")||"(none reported)"}`]}function H0(D,u=!1){let F=D.appId?`https://api.slack.com/apps/${D.appId}`:"https://api.slack.com/apps";if(D.ok){let C=["✓ Bot DM scopes are complete (send + read replies)."," Two-way replies also require the Messages Tab, which is not API-detectable.",' If recipients see "Sending messages to this app is turned off", enable it:',` ${F} → App Home → "Messages Tab" ON + "Allow users to send messages".`];return u?C:[...C,...p8(D)]}let E=[];if(!D.canSend)E.push(`⚠ This bot CANNOT send DMs — missing scope(s): ${D.missingSendScopes.join(", ")}.`);else E.push("⚠ This bot can send DMs, but the user's replies will NOT be readable.");return E.push(" Make escalation DMs two-way:"),E.push(` 1. ${F} → App Home → enable "Messages Tab" and check`),E.push(' "Allow users to send Slash commands and messages".'),E.push(` 2. OAuth & Permissions → add Bot Token Scopes: ${[...D.missingSendScopes,...D.missingReplyScopes].join(", ")}`),E.push(" 3. Reinstall the app to apply the new scopes."),u?E:[...E,...p8(D)]}import{createInterface as Yu}from"node:readline/promises";import{join as A0}from"node:path";import{homedir as c6}from"node:os";import{existsSync as q0,readFileSync as U0,writeFileSync as m8,mkdirSync as c8}from"node:fs";import{homedir as S6}from"node:os";import{join as M0,dirname as g8}from"node:path";function k8(){return process.env.HOME||S6()}function d8(){return M0(k8(),".config","slack-cli","profiles.json")}function P6(){return M0(process.cwd(),".slack-cli","workspace")}function w6(){return M0(k8(),".slack-cli","workspace")}function K0(){let D=d8();if(!q0(D))return{profiles:{}};return JSON.parse(U0(D,"utf8"))}function i8(D){let u=d8();c8(g8(u),{recursive:!0}),m8(u,JSON.stringify(D,null,2)+`
101
+ `)}function y8(D){if(!q0(D))return;return U0(D,"utf8").trim()||void 0}function n8(D,u){c8(g8(D),{recursive:!0});let F=q0(D)?U0(D,"utf8"):"",E=F?F.split(`
102
+ `):[];for(let[C,B]of Object.entries(u)){let $=E.findIndex((z)=>{let Z=z.trim();return Z.startsWith(C+"=")||Z.startsWith(C+" =")}),G=`${C}=${B}`;if($!==-1)E[$]=G;else E.push(G)}m8(D,E.join(`
101
103
  `).trimEnd()+`
102
- `)}function YF(){let D=K0(),u=m8(P6()),F=m8(w6()),E=u??F;return Object.entries(D.profiles).map(([C,B])=>({name:C,profile:B,current:C===E}))}function _0(D,u){let F=K0();F.profiles[D]=u,i8(F)}function j0(D,u){let F=K0();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);F.profiles[D].cookie=u,i8(F)}import{readdirSync as WF,readFileSync as OF,existsSync as Qu,copyFileSync as l8,unlinkSync as t8}from"node:fs";import{homedir as VF,tmpdir as o8}from"node:os";import{join as XD,dirname as x6}from"node:path";import{pbkdf2Sync as s8,createDecipheriv as r8}from"node:crypto";import{execSync as a8}from"node:child_process";function I6(){let D=VF();if(process.platform==="darwin")return XD(D,"Library","Application Support","Slack","Local Storage","leveldb");if(process.platform==="linux")return XD(D,".config","Slack","Local Storage","leveldb");if(process.platform==="win32"){let u=process.env.APPDATA??XD(D,"AppData","Roaming");return XD(u,"Slack","Local Storage","leveldb")}throw Error(`Unsupported platform: ${process.platform}`)}function b6(){let D=VF();if(process.platform==="darwin")return XD(D,"Library","Application Support","Slack","Cookies");return""}function f6(D,u){if(D.length<35||D.slice(0,3).toString()!=="v10")throw Error("Not a v10 encrypted cookie");let F=D.slice(19,35),E=D.slice(35),C=r8("aes-128-cbc",u,F);return C.setAutoPadding(!0),Buffer.concat([C.update(E),C.final()]).toString("utf8")}function h6(){if(process.platform!=="darwin")return;let D=b6();if(!Qu(D))return;let u;try{u=a8('security find-generic-password -w -s "Slack Safe Storage" -a "Slack Key"',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}let F=s8(u,"saltysalt",1003,16,"sha1");try{let{default:E}=wD("bun:sqlite"),C=new E(D,{readonly:!0}),B=C.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(C.close(),!B)return;return f6(Buffer.from(B.encrypted_value),F)}catch{return}}async function e8(){let D=I6();if(!Qu(D))throw Error(`Slack desktop app LevelDB not found at:
104
+ `)}function WF(){let D=K0(),u=y8(P6()),F=y8(w6()),E=u??F;return Object.entries(D.profiles).map(([C,B])=>({name:C,profile:B,current:C===E}))}function _0(D,u){let F=K0();F.profiles[D]=u,i8(F)}function j0(D,u){let F=K0();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);F.profiles[D].cookie=u,i8(F)}import{readdirSync as OF,readFileSync as bu,existsSync as Qu,copyFileSync as l8,unlinkSync as t8}from"node:fs";import{homedir as VF,tmpdir as o8}from"node:os";import{join as ZD,dirname as x6}from"node:path";import{pbkdf2Sync as s8,createDecipheriv as r8}from"node:crypto";import{execSync as a8}from"node:child_process";function I6(){let D=VF();if(process.platform==="darwin")return ZD(D,"Library","Application Support","Slack","Local Storage","leveldb");if(process.platform==="linux")return ZD(D,".config","Slack","Local Storage","leveldb");if(process.platform==="win32"){let u=process.env.APPDATA??ZD(D,"AppData","Roaming");return ZD(u,"Slack","Local Storage","leveldb")}throw Error(`Unsupported platform: ${process.platform}`)}function b6(){let D=VF();if(process.platform==="darwin")return ZD(D,"Library","Application Support","Slack","Cookies");return""}function f6(D,u){if(D.length<35||D.slice(0,3).toString()!=="v10")throw Error("Not a v10 encrypted cookie");let F=D.slice(19,35),E=D.slice(35),C=r8("aes-128-cbc",u,F);return C.setAutoPadding(!0),Buffer.concat([C.update(E),C.final()]).toString("utf8")}function h6(){if(process.platform!=="darwin")return;let D=b6();if(!Qu(D))return;let u;try{u=a8('security find-generic-password -w -s "Slack Safe Storage" -a "Slack Key"',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}let F=s8(u,"saltysalt",1003,16,"sha1");try{let{default:E}=wD("bun:sqlite"),C=new E(D,{readonly:!0}),B=C.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(C.close(),!B)return;return f6(Buffer.from(B.encrypted_value),F)}catch{return}}async function e8(){let D=I6();if(!Qu(D))throw Error(`Slack desktop app LevelDB not found at:
103
105
  ${D}
104
- Is Slack installed and opened at least once?`);let u=WF(D).filter((G)=>G.endsWith(".ldb")||G.endsWith(".log"));if(u.length===0)throw Error(`No LevelDB data files found in ${D}`);let F=new Map;for(let G of u){let Z;try{Z=OF(XD(D,G),"latin1")}catch{continue}if(G.endsWith(".log"))for(let z of Z.matchAll(/"token":"(xoxc-[^"]+)"/g)){let Y=z[1],J=Y.split("-")[1]??"";if(!J||Y.length<40)continue;let Q=Math.max(0,z.index-2000),O=Math.min(Z.length,z.index+2000),V=Z.slice(Q,O),W=V.match(/"url":"(https:\/\/[a-z0-9-]+\.slack\.com\/)"/),M=V.match(/"(?:team_name|name)":"([^"]{2,60})"/),_=F.get(J);if(!_||Y.length>_.token.length){let N={token:Y,teamId:J},k=W?.[1]??_?.url,w=M?.[1]??_?.teamName;if(k)N.url=k;if(w)N.teamName=w;F.set(J,N)}}else for(let z of Z.matchAll(/xoxc-(\d+)-(\d+)-(\d+)/g)){let Y=z[1];if(F.has(Y))continue;let J=z.index+z[0].length,Q=Math.min(J+10,Z.length);while(J<Q&&(Z.charCodeAt(J)<48||Z.charCodeAt(J)>57))J++;let O="";while(J<Z.length&&Z.charCodeAt(J)>=48&&Z.charCodeAt(J)<=57)O+=Z[J++];if(Z[J]!=="-")continue;J++;let V="";while(J<Z.length){let M=Z.charCodeAt(J);if(M>=48&&M<=57||M>=97&&M<=102)V+=Z[J++];else break}if(V.length<20)continue;let W=`${z[0]}${O}-${V}`;F.set(Y,{token:W,teamId:Y})}}let C=WF(D).filter((G)=>G.endsWith(".ldb")||G.endsWith(".log")).map((G)=>{try{return OF(XD(D,G),"latin1").replace(/[^\x20-\x7e]/g," ")}catch{return""}}).join(" ");for(let G of F.values()){if(G.teamName)continue;let Z=C.indexOf(G.teamId);if(Z!==-1){let z=Math.max(0,Z-500),Y=Math.min(C.length,Z+500),Q=C.slice(z,Y).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(Q?.[1]){G.teamName=Q[1];continue}}if(!G.teamName&&G.url){let z=G.url.match(/https:\/\/([a-z0-9-]+)\.slack\.com\//)?.[1];if(z){let Y=C.indexOf(z);if(Y!==-1){let J=Math.max(0,Y-500),Q=Math.min(C.length,Y+500),V=C.slice(J,Q).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(V?.[1]){G.teamName=V[1];continue}}G.teamName=z.split("-").map((J)=>J.charAt(0).toUpperCase()+J.slice(1)).join(" ")}}}let B=h6(),$=[...F.values()];if(B)for(let G of $)G.cookie=B;return $}function v6(D,u){let F=(E,C)=>{try{let B=r8("aes-128-cbc",u,E);B.setAutoPadding(!0);let $=Buffer.concat([B.update(C),B.final()]).toString("utf8");return $.startsWith("xoxd-")?$:void 0}catch{return}};return F(Buffer.alloc(16,32),D.slice(3))??(D.length>=35?F(D.slice(19,35),D.slice(35)):void 0)}function p6(D,u){try{let E=JSON.parse(OF(XD(D,u,"Preferences"),"utf8")).profile,C=E?.name??"",B=E?.user_name??"";return B?`${C} (${B})`:C||u}catch{return u}}function D1(){if(process.platform!=="darwin")return{candidates:[],totalProfiles:0};let D=XD(VF(),"Library","Application Support","Google","Chrome");if(!Qu(D))return{candidates:[],totalProfiles:0};let u;try{u=a8('security find-generic-password -a Chrome -s "Chrome Safe Storage" -w',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return{candidates:[],totalProfiles:0}}if(!u)return{candidates:[],totalProfiles:0};let F=s8(u,"saltysalt",1003,16,"sha1"),E=["Default",...WF(D).filter((B)=>B.startsWith("Profile "))],C=[];for(let B of E){let $=XD(D,B,"Cookies");if(!Qu($))continue;let G=XD(o8(),`slack-chrome-cookies-${Date.now()}-${B}.db`);try{l8($,G);let{default:Z}=wD("bun:sqlite"),z=new Z(G,{readonly:!0}),Y=z.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(z.close(),!Y)continue;let J=Buffer.from(Y.encrypted_value),Q=J.slice(0,3).toString();if(Q==="v10"){let O=v6(J,F);if(!O)continue;C.push({profileDir:B,profileName:p6(D,B),cookie:O})}else if(Q==="v20")throw Error(`Chrome cookie uses v20 (app-bound AES-256-GCM) which is not supported yet. Prefix found: ${J.slice(0,4).toString("hex")}`);else throw Error(`Unknown cookie encryption prefix: ${J.slice(0,4).toString("hex")}`)}catch(Z){if(Z instanceof Error&&(Z.message.includes("app-bound")||Z.message.includes("Unknown cookie")))throw Z}finally{try{t8(G)}catch{}}}return{candidates:C,totalProfiles:E.length}}function m6(){let D=VF();if(process.platform==="darwin")return XD(D,"Library","Application Support","Firefox","Profiles");if(process.platform==="linux")return XD(D,".mozilla","firefox");if(process.platform==="win32")return XD(process.env.APPDATA??XD(D,"AppData","Roaming"),"Mozilla","Firefox","Profiles");return""}function y6(D){let u=XD(x6(D),"profiles.ini"),F={};if(!Qu(u))return F;try{let E=OF(u,"utf8"),C="",B="";for(let $ of E.split(`
105
- `)){let G=$.trim();if(G.startsWith("[")){C="",B="";continue}let Z=G.indexOf("=");if(Z===-1)continue;let z=G.slice(0,Z).trim().toLowerCase(),Y=G.slice(Z+1).trim();if(z==="name")C=Y;if(z==="path")B=Y.split(/[\\/]/).pop()??Y;if(C&&B)F[B]=C,C="",B=""}}catch{}return F}function u1(){let D=m6();if(!D||!Qu(D))return[];let u=y6(D),F=[],E;try{E=WF(D)}catch{return[]}for(let C of E){let B=XD(D,C,"cookies.sqlite");if(!Qu(B))continue;let $=XD(o8(),`slack-firefox-cookies-${Date.now()}-${C}.db`);try{l8(B,$);let{default:G}=wD("bun:sqlite"),Z=new G($,{readonly:!0}),z=Z.prepare("SELECT value FROM moz_cookies WHERE name='d' AND host LIKE '%slack%' LIMIT 1").get();if(Z.close(),!z?.value||!z.value.startsWith("xoxd-"))continue;let Y=u[C]??C;F.push({profileDir:C,profileName:Y,cookie:z.value})}catch{}finally{try{t8($)}catch{}}}return F}var g6=["search:read","channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"],k6=["channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"];function HF(D){return D.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function d6(){return JSON.stringify({display_information:{name:"slack-term"},oauth_config:{scopes:{user:g6}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}function i6(){return JSON.stringify({display_information:{name:"slack-term"},features:{bot_user:{display_name:"slack-term",always_online:!1}},oauth_config:{scopes:{bot:k6}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}async function Wu(D,u){return(await D.question(u)).trim()}async function Ou(D,u,F,E){console.error("Verifying token...");let C=await ZF(u),B=HF(C.team),$;if(F)$=F;else if(D)$=await Wu(D,`Workspace name [${B}]: `)||B;else $=B;let G=null;if(D){console.log(""),console.log("Where to save the token?"),console.log(" 1) ./.env.local (current directory) [default]"),console.log(" 2) ./.slack-term/.env.local (current directory, slack-specific)"),console.log(" 3) ~/.slack-term/.env.local (global, available everywhere)"),console.log(" 4) profiles.json (multi-workspace: slack auth use)"),console.log("");let Z=await Wu(D,"Choice [1/2/3/4, Enter=1]: ");if(Z==="2")G=A0(process.cwd(),".slack-term",".env.local");else if(Z==="3")G=A0(c6(),".slack-term",".env.local");else if(Z==="4")G=null;else G=A0(process.cwd(),".env.local")}if(G===null)if(_0($,{token:u,...C,...E?{cookie:E}:{}}),console.log(`Saved workspace "${$}" to profiles.json: ${C.team} (${C.user})`),process.env.SLACK_MCP_XOXP_TOKEN)console.log(""),console.log("Warning: SLACK_MCP_XOXP_TOKEN is set — it conflicts with profiles."),console.log(" Unset it: unset SLACK_MCP_XOXP_TOKEN (and remove from ~/.zshrc / ~/.bashrc)");else console.log(` Run: slack auth use -g ${$}`);else{let Z={SLACK_TOKEN:u};if(E)Z.SLACK_COOKIE=E;n8(G,Z),console.log(`Saved token to ${G}`),console.log(" SLACK_TOKEN will be picked up automatically in this directory tree.")}return $}async function n6(D){console.error("Scanning Slack desktop app...");let u=await e8();if(u.length===0)console.error("No sessions found. Make sure Slack is installed and you have signed in at least once."),process.exit(1);if(u.length===1&&D){let F=u[0],E=F.teamName??F.teamId;console.log(`Found workspace: ${E}${F.cookie?" (+ xoxd cookie)":""}`),await Ou(D,F.token,HF(E),F.cookie),console.log(""),console.log("Note: desktop app tokens (xoxc-) are internal Slack tokens."),console.log("If API calls fail, replace with an xoxp- token: slack auth login");return}for(let F of u){let E=F.teamName??F.teamId,C=HF(E);_0(C,{token:F.token,team:E,teamId:F.teamId,url:F.url??"",user:"",...F.cookie?{cookie:F.cookie}:{}}),console.log(`Added workspace "${C}": ${E}${F.cookie?" + xoxd cookie":""}`)}if(console.log(""),u.length===1){let F=HF(u[0].teamName??u[0].teamId);console.log(`Run: slack auth use -g ${F}`)}else console.log("Run: slack auth ls then: slack auth use -g <name>");console.log(""),console.log("Note: desktop app tokens (xoxc-) are internal Slack tokens."),console.log("If API calls fail, replace with an xoxp- user token by re-running: slack auth login")}async function F1(D){console.log("Which token type does your app use?"),console.log(""),console.log(" 1) User token (xoxp-) -full access including search [recommended]"),console.log(" 2) Bot token (xoxb-) -search and news unavailable"),console.log("");let F=await Wu(D,"Choice [1/2]: ")==="2"?"bot":"user",E=F==="user"?"xoxp-":"xoxb-",C=F==="user"?"User OAuth Token":"Bot User OAuth Token";console.log(""),console.log("Find your token here:"),console.log(" https://api.slack.com/apps"),console.log(" -> Select your app -> OAuth & Permissions"),console.log(` -> Copy the "${C}" (starts with ${E})`),console.log("");let B=await Wu(D,"Paste your token: ");if(!B)console.error("No token provided."),process.exit(1);if(!B.startsWith(E))console.error(`Expected a ${E} token, got: ${B.slice(0,10)}...`),process.exit(1);await Ou(D,B)}async function qF(D,u){let F=u==="user"?d6():i6(),E=u==="user"?"User OAuth Token (xoxp-...)":"Bot User OAuth Token (xoxb-...)",C=u==="user"?"xoxp-":"xoxb-";if(u==="bot")console.log("Note: bot tokens cannot use search:read (user-only scope)."),console.log(" The news and search commands will not work with a bot token."),console.log("");console.log("Step 1 -Create your Slack app:"),console.log(" Open: https://api.slack.com/apps"),console.log(' Click "Create New App" -> "From a manifest" -> select your workspace'),console.log(" Paste this manifest (JSON tab):"),console.log(""),console.log("-------------------------------------------------------------"),console.log(F),console.log("-------------------------------------------------------------"),console.log(""),console.log('Step 2 -Install: "Install App" -> "Install to Workspace" -> Authorize'),console.log(""),console.log("Step 3 -Copy your token:"),console.log(` OAuth & Permissions -> ${E}`),console.log("");let B=await Wu(D,"Paste your token: ");if(!B)console.error("No token provided."),process.exit(1);if(!B.startsWith(C))console.error(`Expected a ${C} token, got: ${B.slice(0,10)}...`),process.exit(1);await Ou(D,B)}async function E1(D={}){if(process.platform!=="darwin")console.error("Chrome cookie extraction is only supported on macOS."),process.exit(1);let u=YF();if(u.length===0)console.error("No workspaces configured. Run: slack auth login"),process.exit(1);let F;if(D.workspace){if(!u.find((G)=>G.name===D.workspace))console.error(`Workspace "${D.workspace}" not found. Available: ${u.map((G)=>G.name).join(", ")}`),process.exit(1);F=D.workspace}else if(u.length===1)F=u[0].name;else{let $=u.find((G)=>G.current);if($)F=$.name,console.log(`Using active workspace: ${F}`);else{console.log("Multiple workspaces found. Choose one:"),u.forEach((Y,J)=>console.log(` ${J+1}) ${Y.name} (${Y.profile.team})`));let G=Yu({input:process.stdin,output:process.stdout}),Z=(await G.question("Choice: ")).trim();G.close();let z=parseInt(Z,10)-1;if(isNaN(z)||z<0||z>=u.length)console.error("Invalid choice."),process.exit(1);F=u[z].name}}console.log("Scanning Chrome profiles for Slack session..."),console.log("macOS may show a dialog asking for your login password — click Allow.");let E,C;try{({candidates:E,totalProfiles:C}=D1())}catch($){console.error(`Failed: ${$ instanceof Error?$.message:String($)}`),process.exit(1)}if(E.length===0)console.error(`No Slack session found in Chrome (scanned ${C} profile${C!==1?"s":""}). Possible reasons:`),console.error(" - You denied the keychain dialog (try running again and click Allow)"),console.error(" - Chrome is not installed or has no Slack session"),console.error(" - You're not logged in to Slack in Chrome"),process.exit(1);let B;if(E.length===1&&C<=1)B=E[0].cookie,console.log(`Found session in Chrome profile: ${E[0].profileName}`);else{let $=E.length===1?`Found 1 Slack session across ${C} Chrome profiles:`:`Found ${E.length} Slack sessions across ${C} Chrome profiles:`;console.log($),E.forEach((J,Q)=>console.log(` ${Q+1}) ${J.profileName} [${J.profileDir}]`)),console.log("");let G=Yu({input:process.stdin,output:process.stdout}),Z=E.length===1?" [Enter=1]":"",z=(await G.question(`Choice [1-${E.length}]${Z}: `)).trim();G.close();let Y=z===""&&E.length===1?0:parseInt(z,10)-1;if(isNaN(Y)||Y<0||Y>=E.length)console.error("Invalid choice."),process.exit(1);B=E[Y].cookie}j0(F,B),console.log(`Saved xoxd cookie to workspace "${F}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function C1(D={}){let u=YF();if(u.length===0)console.error("No workspaces configured. Run: slack auth token"),process.exit(1);let F;if(D.workspace){if(!u.find(($)=>$.name===D.workspace))console.error(`Workspace "${D.workspace}" not found. Available: ${u.map(($)=>$.name).join(", ")}`),process.exit(1);F=D.workspace}else if(u.length===1)F=u[0].name;else{let B=u.find(($)=>$.current);if(B)F=B.name,console.log(`Using active workspace: ${F}`);else{console.log("Multiple workspaces found. Choose one:"),u.forEach((z,Y)=>console.log(` ${Y+1}) ${z.name} (${z.profile.team})`));let $=Yu({input:process.stdin,output:process.stdout}),G=(await $.question("Choice: ")).trim();$.close();let Z=parseInt(G,10)-1;if(isNaN(Z)||Z<0||Z>=u.length)console.error("Invalid choice."),process.exit(1);F=u[Z].name}}console.log("Scanning Firefox profiles for Slack session...");let E=u1();if(E.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 C;if(E.length===1)C=E[0].cookie,console.log(`Found session in Firefox profile: ${E[0].profileName}`);else{console.log("Multiple Firefox profiles have a Slack session. Choose one:"),E.forEach((Z,z)=>console.log(` ${z+1}) ${Z.profileName} [${Z.profileDir}]`));let B=Yu({input:process.stdin,output:process.stdout}),$=(await B.question("Choice: ")).trim();B.close();let G=parseInt($,10)-1;if(isNaN(G)||G<0||G>=E.length)console.error("Invalid choice."),process.exit(1);C=E[G].cookie}j0(F,C),console.log(`Saved xoxd cookie to workspace "${F}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function B1(D={}){if(D.token){await Ou(null,D.token,D.name);return}if(!process.stdin.isTTY){let F=[];for await(let C of process.stdin)F.push(C);let E=Buffer.concat(F).toString("utf8").trim();if(!E)console.error("No token provided on stdin."),process.exit(1);await Ou(null,E,D.name);return}let u=Yu({input:process.stdin,output:process.stdout});try{await F1(u)}finally{u.close()}}async function $1(D={}){let u=Yu({input:process.stdin,output:process.stdout});try{if(D.bot!==void 0){await qF(u,D.bot?"bot":"user");return}console.log("Which token type?"),console.log(" 1) User token (xoxp-) -full access including search [default]"),console.log(" 2) Bot token (xoxb-) -search and news unavailable"),console.log("");let F=await Wu(u,"Choice [1/2, Enter=1]: ");await qF(u,F==="2"?"bot":"user")}finally{u.close()}}async function UF(D={}){let u=YF();if(u.length>0){console.log("Currently logged in:");for(let{name:E,profile:C,current:B}of u)console.log(` ${B?"*":" "} ${E} ${C.team} (${C.user||"unknown"})`);console.log(""),console.log("Adding another workspace:"),console.log("")}if(D.token){await Ou(null,D.token,D.name);return}if(!process.stdin.isTTY){let E=[];for await(let B of process.stdin)E.push(B);let C=Buffer.concat(E).toString("utf8").trim();if(!C)console.error("No token provided on stdin."),process.exit(1);await Ou(null,C,D.name);return}console.log("How would you like to authenticate with Slack?"),console.log(""),console.log(" 1) Slack desktop app - import session token"),console.log(" Reads the xoxc- token directly from the installed app."),console.log(" Token: all platforms | xoxd cookie: macOS only"),console.log(""),console.log(" 2) Connect existing Slack app [recommended if you have one]"),console.log(" Paste a token from an app you already created."),console.log(""),console.log(" 3) Create new Slack app - user token (xoxp-)"),console.log(" Guided setup with manifest. Full access including search."),console.log(""),console.log(" 4) Create new Slack app - bot token (xoxb-)"),console.log(" Bot is invited to channels. Search and news unavailable."),console.log("");let F=Yu({input:process.stdin,output:process.stdout});try{let E=await Wu(F,"Choice [1/2/3/4]: ");if(console.log(""),E==="1")await n6(F);else if(E==="2")await F1(F);else if(E==="3")await qF(F,"user");else if(E==="4")await qF(F,"bot");else console.error(`Invalid choice: "${E}". Enter 1, 2, 3, or 4.`),process.exit(1)}finally{F.close()}}async function MF(D,u,F){let E=u,C=[],B=E,$=0;while(!0){let G=B.indexOf("<@U",$);if(G===-1)break;let Z=B.slice(G+2),z=Z.search(/[>|]/),Y=z===-1?Z:Z.slice(0,z);if(Y.length>=9)C.push(Y);$=G+1}for(let G of C){if(!F.has(G))F.set(G,await XF(D,G));let Z=F.get(G)??G;E=E.replaceAll(`<@${G}>`,`@${Z}`),E=E.replace(new RegExp(`<@${G}\\|[^>]*>`,"g"),`@${Z}`)}return E}function KF(D){return D.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(u,F,E)=>{let C=Number(F);if(!Number.isFinite(C))return E??"date";let B=new Date(C*1000);if(Number.isNaN(B.getTime()))return E??"date";let $=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],G=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Z=$[B.getUTCDay()]??"",z=G[B.getUTCMonth()]??"";return`${Z}, ${z} ${String(B.getUTCDate()).padStart(2,"0")}, ${B.getUTCFullYear()}`})}function z1(D){let u=typeof D.ts==="string"?D.ts:"",F=typeof D.thread_ts==="string"?D.thread_ts:"";return F!==""&&F!==u}function l6(D){let[u,F="000000"]=D.split("."),E=new Date(Number(u)*1000),C=E.getUTCFullYear(),B=String(E.getUTCMonth()+1).padStart(2,"0"),$=String(E.getUTCDate()).padStart(2,"0"),G=String(E.getUTCHours()).padStart(2,"0"),Z=String(E.getUTCMinutes()).padStart(2,"0"),z=String(E.getUTCSeconds()).padStart(2,"0"),Y=F.padEnd(6,"0").slice(0,6);return`${C}-${B}-${$}T${G}:${Z}:${z}.${Y}`}async function t6(D,u,F){let E=typeof u.ts==="string"?u.ts:"0.000000",C=l6(E),B="?";if(typeof u.user==="string"){let J=u.user,Q="@"+J;if(!F.has(Q)){let[,O]=await JF(D,J);F.set(Q,O)}B=F.get(Q)??J}else if(typeof u.username==="string")B=u.username;let $=typeof u.text==="string"?u.text:"",Z=KF(await MF(D,$,F)).split(`
106
- `),z=Z[0]+(Z.length>1?`
107
- `+Z.slice(1).map((J)=>` ${J}`).join(`
108
- `):""),Y=z1(u)?"↳ ":"";return`${C} ${Y}@${B}: ${z}`}async function o6(D,u,F,E,C,B,$,G){if(G?.aborted)return;return new Promise((Z)=>{let z=new D(F);G?.addEventListener("abort",()=>{z.close(),Z()},{once:!0}),z.addEventListener("open",()=>{process.stderr.write(`Connected via RTM (experimental).
109
- `)}),z.addEventListener("close",()=>Z()),z.addEventListener("error",()=>Z()),z.addEventListener("message",(Y)=>{(async()=>{try{let J;try{J=JSON.parse(String(Y.data))}catch{return}let Q=typeof J.type==="string"?J.type:"";if(Q==="ping"){z.send(JSON.stringify({type:"pong",reply_to:J.id??0}));return}if(Q!=="message")return;if((typeof J.channel==="string"?J.channel:"")!==E)return;let V=typeof J.ts==="string"?J.ts:"";if(!V||B.has(V))return;let W=typeof J.subtype==="string"?J.subtype:"";if(W==="message_changed"||W==="message_deleted")return;if(C.thread){if((typeof J.thread_ts==="string"?J.thread_ts:V)!==C.thread&&V!==C.thread)return}if(C.watchThread&&z1(J)){if((typeof J.thread_ts==="string"?J.thread_ts:"")!==C.watchThread)return}if(C.me&&C.myUserId){if(!(typeof J.text==="string"?J.text:"").includes(`<@${C.myUserId}>`))return}if(B.add(V),B.size>1000){let _=B.values().next().value;if(_!==void 0)B.delete(_)}let M=await t6(u,J,$);process.stdout.write(M+`
106
+ Is Slack installed and opened at least once?`);let u=OF(D).filter((G)=>G.endsWith(".ldb")||G.endsWith(".log"));if(u.length===0)throw Error(`No LevelDB data files found in ${D}`);let F=new Map;for(let G of u){let z;try{z=bu(ZD(D,G),"latin1")}catch{continue}if(G.endsWith(".log"))for(let Z of z.matchAll(/"token":"(xoxc-[^"]+)"/g)){let Y=Z[1],J=Y.split("-")[1]??"";if(!J||Y.length<40)continue;let Q=Math.max(0,Z.index-2000),O=Math.min(z.length,Z.index+2000),V=z.slice(Q,O),W=V.match(/"url":"(https:\/\/[a-z0-9-]+\.slack\.com\/)"/),M=V.match(/"(?:team_name|name)":"([^"]{2,60})"/),_=F.get(J);if(!_||Y.length>_.token.length){let N={token:Y,teamId:J},k=W?.[1]??_?.url,w=M?.[1]??_?.teamName;if(k)N.url=k;if(w)N.teamName=w;F.set(J,N)}}else for(let Z of z.matchAll(/xoxc-(\d+)-(\d+)-(\d+)/g)){let Y=Z[1];if(F.has(Y))continue;let J=Z.index+Z[0].length,Q=Math.min(J+10,z.length);while(J<Q&&(z.charCodeAt(J)<48||z.charCodeAt(J)>57))J++;let O="";while(J<z.length&&z.charCodeAt(J)>=48&&z.charCodeAt(J)<=57)O+=z[J++];if(z[J]!=="-")continue;J++;let V="";while(J<z.length){let M=z.charCodeAt(J);if(M>=48&&M<=57||M>=97&&M<=102)V+=z[J++];else break}if(V.length<20)continue;let W=`${Z[0]}${O}-${V}`;F.set(Y,{token:W,teamId:Y})}}let C=OF(D).filter((G)=>G.endsWith(".ldb")||G.endsWith(".log")).map((G)=>{try{return bu(ZD(D,G),"latin1").replace(/[^\x20-\x7e]/g," ")}catch{return""}}).join(" ");for(let G of F.values()){if(G.teamName)continue;let z=C.indexOf(G.teamId);if(z!==-1){let Z=Math.max(0,z-500),Y=Math.min(C.length,z+500),Q=C.slice(Z,Y).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(Q?.[1]){G.teamName=Q[1];continue}}if(!G.teamName&&G.url){let Z=G.url.match(/https:\/\/([a-z0-9-]+)\.slack\.com\//)?.[1];if(Z){let Y=C.indexOf(Z);if(Y!==-1){let J=Math.max(0,Y-500),Q=Math.min(C.length,Y+500),V=C.slice(J,Q).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(V?.[1]){G.teamName=V[1];continue}}G.teamName=Z.split("-").map((J)=>J.charAt(0).toUpperCase()+J.slice(1)).join(" ")}}}let B=h6(),$=[...F.values()];if(B)for(let G of $)G.cookie=B;return $}function v6(D,u){let F=(E,C)=>{try{let B=r8("aes-128-cbc",u,E);B.setAutoPadding(!0);let $=Buffer.concat([B.update(C),B.final()]).toString("utf8");return $.startsWith("xoxd-")?$:void 0}catch{return}};return F(Buffer.alloc(16,32),D.slice(3))??(D.length>=35?F(D.slice(19,35),D.slice(35)):void 0)}function p6(D,u){let F=(E,C)=>{if(E&&C)return`${E} (${C})`;return E||C||u};try{let C=JSON.parse(bu(ZD(D,"Local State"),"utf8")).profile?.info_cache?.[u];if(C&&(C.name||C.user_name))return F(C.name??"",C.user_name??"")}catch{}try{let C=JSON.parse(bu(ZD(D,u,"Preferences"),"utf8")).profile;return F(C?.name??"",C?.user_name??"")}catch{return u}}function D1(){if(process.platform!=="darwin")return{candidates:[],totalProfiles:0};let D=ZD(VF(),"Library","Application Support","Google","Chrome");if(!Qu(D))return{candidates:[],totalProfiles:0};let u;try{u=a8('security find-generic-password -a Chrome -s "Chrome Safe Storage" -w',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return{candidates:[],totalProfiles:0}}if(!u)return{candidates:[],totalProfiles:0};let F=s8(u,"saltysalt",1003,16,"sha1"),E=["Default",...OF(D).filter((B)=>B.startsWith("Profile "))],C=[];for(let B of E){let $=ZD(D,B,"Cookies");if(!Qu($))continue;let G=ZD(o8(),`slack-chrome-cookies-${Date.now()}-${B}.db`);try{l8($,G);let{default:z}=wD("bun:sqlite"),Z=new z(G,{readonly:!0}),Y=Z.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(Z.close(),!Y)continue;let J=Buffer.from(Y.encrypted_value),Q=J.slice(0,3).toString();if(Q==="v10"){let O=v6(J,F);if(!O)continue;C.push({profileDir:B,profileName:p6(D,B),cookie:O})}else if(Q==="v20")throw Error(`Chrome cookie uses v20 (app-bound AES-256-GCM) which is not supported yet. Prefix found: ${J.slice(0,4).toString("hex")}`);else throw Error(`Unknown cookie encryption prefix: ${J.slice(0,4).toString("hex")}`)}catch(z){if(z instanceof Error&&(z.message.includes("app-bound")||z.message.includes("Unknown cookie")))throw z}finally{try{t8(G)}catch{}}}return{candidates:C,totalProfiles:E.length}}function y6(){let D=VF();if(process.platform==="darwin")return ZD(D,"Library","Application Support","Firefox","Profiles");if(process.platform==="linux")return ZD(D,".mozilla","firefox");if(process.platform==="win32")return ZD(process.env.APPDATA??ZD(D,"AppData","Roaming"),"Mozilla","Firefox","Profiles");return""}function m6(D){let u=ZD(x6(D),"profiles.ini"),F={};if(!Qu(u))return F;try{let E=bu(u,"utf8"),C="",B="";for(let $ of E.split(`
107
+ `)){let G=$.trim();if(G.startsWith("[")){C="",B="";continue}let z=G.indexOf("=");if(z===-1)continue;let Z=G.slice(0,z).trim().toLowerCase(),Y=G.slice(z+1).trim();if(Z==="name")C=Y;if(Z==="path")B=Y.split(/[\\/]/).pop()??Y;if(C&&B)F[B]=C,C="",B=""}}catch{}return F}function u1(){let D=y6();if(!D||!Qu(D))return[];let u=m6(D),F=[],E;try{E=OF(D)}catch{return[]}for(let C of E){let B=ZD(D,C,"cookies.sqlite");if(!Qu(B))continue;let $=ZD(o8(),`slack-firefox-cookies-${Date.now()}-${C}.db`);try{l8(B,$);let{default:G}=wD("bun:sqlite"),z=new G($,{readonly:!0}),Z=z.prepare("SELECT value FROM moz_cookies WHERE name='d' AND host LIKE '%slack%' LIMIT 1").get();if(z.close(),!Z?.value||!Z.value.startsWith("xoxd-"))continue;let Y=u[C]??C;F.push({profileDir:C,profileName:Y,cookie:Z.value})}catch{}finally{try{t8($)}catch{}}}return F}var g6=["search:read","channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"],k6=["channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"];function HF(D){return D.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function d6(){return JSON.stringify({display_information:{name:"slack-term"},oauth_config:{scopes:{user:g6}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}function i6(){return JSON.stringify({display_information:{name:"slack-term"},features:{bot_user:{display_name:"slack-term",always_online:!1}},oauth_config:{scopes:{bot:k6}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}async function Wu(D,u){return(await D.question(u)).trim()}async function Ou(D,u,F,E){console.error("Verifying token...");let C=await JF(u),B=HF(C.team),$;if(F)$=F;else if(D)$=await Wu(D,`Workspace name [${B}]: `)||B;else $=B;let G=null;if(D){console.log(""),console.log("Where to save the token?"),console.log(" 1) ./.env.local (current directory) [default]"),console.log(" 2) ./.slack-term/.env.local (current directory, slack-specific)"),console.log(" 3) ~/.slack-term/.env.local (global, available everywhere)"),console.log(" 4) profiles.json (multi-workspace: slack auth use)"),console.log("");let z=await Wu(D,"Choice [1/2/3/4, Enter=1]: ");if(z==="2")G=A0(process.cwd(),".slack-term",".env.local");else if(z==="3")G=A0(c6(),".slack-term",".env.local");else if(z==="4")G=null;else G=A0(process.cwd(),".env.local")}if(G===null)if(_0($,{token:u,...C,...E?{cookie:E}:{}}),console.log(`Saved workspace "${$}" to profiles.json: ${C.team} (${C.user})`),process.env.SLACK_MCP_XOXP_TOKEN)console.log(""),console.log("Warning: SLACK_MCP_XOXP_TOKEN is set — it conflicts with profiles."),console.log(" Unset it: unset SLACK_MCP_XOXP_TOKEN (and remove from ~/.zshrc / ~/.bashrc)");else console.log(` Run: slack auth use -g ${$}`);else{let z={SLACK_TOKEN:u};if(E)z.SLACK_COOKIE=E;n8(G,z),console.log(`Saved token to ${G}`),console.log(" SLACK_TOKEN will be picked up automatically in this directory tree.")}return $}async function n6(D){console.error("Scanning Slack desktop app...");let u=await e8();if(u.length===0)console.error("No sessions found. Make sure Slack is installed and you have signed in at least once."),process.exit(1);if(u.length===1&&D){let F=u[0],E=F.teamName??F.teamId;console.log(`Found workspace: ${E}${F.cookie?" (+ xoxd cookie)":""}`),await Ou(D,F.token,HF(E),F.cookie),console.log(""),console.log("Note: desktop app tokens (xoxc-) are internal Slack tokens."),console.log("If API calls fail, replace with an xoxp- token: slack auth login");return}for(let F of u){let E=F.teamName??F.teamId,C=HF(E);_0(C,{token:F.token,team:E,teamId:F.teamId,url:F.url??"",user:"",...F.cookie?{cookie:F.cookie}:{}}),console.log(`Added workspace "${C}": ${E}${F.cookie?" + xoxd cookie":""}`)}if(console.log(""),u.length===1){let F=HF(u[0].teamName??u[0].teamId);console.log(`Run: slack auth use -g ${F}`)}else console.log("Run: slack auth ls then: slack auth use -g <name>");console.log(""),console.log("Note: desktop app tokens (xoxc-) are internal Slack tokens."),console.log("If API calls fail, replace with an xoxp- user token by re-running: slack auth login")}async function F1(D){console.log("Which token type does your app use?"),console.log(""),console.log(" 1) User token (xoxp-) -full access including search [recommended]"),console.log(" 2) Bot token (xoxb-) -search and news unavailable"),console.log("");let F=await Wu(D,"Choice [1/2]: ")==="2"?"bot":"user",E=F==="user"?"xoxp-":"xoxb-",C=F==="user"?"User OAuth Token":"Bot User OAuth Token";console.log(""),console.log("Find your token here:"),console.log(" https://api.slack.com/apps"),console.log(" -> Select your app -> OAuth & Permissions"),console.log(` -> Copy the "${C}" (starts with ${E})`),console.log("");let B=await Wu(D,"Paste your token: ");if(!B)console.error("No token provided."),process.exit(1);if(!B.startsWith(E))console.error(`Expected a ${E} token, got: ${B.slice(0,10)}...`),process.exit(1);await Ou(D,B)}async function qF(D,u){let F=u==="user"?d6():i6(),E=u==="user"?"User OAuth Token (xoxp-...)":"Bot User OAuth Token (xoxb-...)",C=u==="user"?"xoxp-":"xoxb-";if(u==="bot")console.log("Note: bot tokens cannot use search:read (user-only scope)."),console.log(" The news and search commands will not work with a bot token."),console.log("");console.log("Step 1 -Create your Slack app:"),console.log(" Open: https://api.slack.com/apps"),console.log(' Click "Create New App" -> "From a manifest" -> select your workspace'),console.log(" Paste this manifest (JSON tab):"),console.log(""),console.log("-------------------------------------------------------------"),console.log(F),console.log("-------------------------------------------------------------"),console.log(""),console.log('Step 2 -Install: "Install App" -> "Install to Workspace" -> Authorize'),console.log(""),console.log("Step 3 -Copy your token:"),console.log(` OAuth & Permissions -> ${E}`),console.log("");let B=await Wu(D,"Paste your token: ");if(!B)console.error("No token provided."),process.exit(1);if(!B.startsWith(C))console.error(`Expected a ${C} token, got: ${B.slice(0,10)}...`),process.exit(1);await Ou(D,B)}async function E1(D={}){if(process.platform!=="darwin")console.error("Chrome cookie extraction is only supported on macOS."),process.exit(1);let u=WF();if(u.length===0)console.error("No workspaces configured. Run: slack auth login"),process.exit(1);let F;if(D.workspace){if(!u.find((z)=>z.name===D.workspace))console.error(`Workspace "${D.workspace}" not found. Available: ${u.map((z)=>z.name).join(", ")}`),process.exit(1);F=D.workspace}else if(u.length===1)F=u[0].name;else{let G=u.find((z)=>z.current);if(G)F=G.name,console.log(`Using active workspace: ${F}`);else{console.log("Multiple workspaces found. Choose one:"),u.forEach((J,Q)=>console.log(` ${Q+1}) ${J.name} (${J.profile.team})`));let z=Yu({input:process.stdin,output:process.stdout}),Z=(await z.question("Choice: ")).trim();z.close();let Y=parseInt(Z,10)-1;if(isNaN(Y)||Y<0||Y>=u.length)console.error("Invalid choice."),process.exit(1);F=u[Y].name}}if(u.find((G)=>G.name===F).profile.token.startsWith("xoxb-")){console.error(`
108
+ Workspace "${F}" uses a bot token (xoxb-). A Chrome session cookie only
109
+ `+`augments a user session token (xoxc-) — it has no effect on a bot token, so user-level
110
+ `+"actions (tail @user, DMs, listing users) would still fail.");let G=u.filter((z)=>z.profile.token.startsWith("xoxc-")||z.profile.token.startsWith("xoxp-"));if(G.length>0)console.error(` Target a user-token workspace instead: ${G.map((z)=>z.name).join(", ")}`),console.error(` slack auth chrome -w ${G[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 C,B;try{({candidates:C,totalProfiles:B}=D1())}catch(G){console.error(`Failed: ${G instanceof Error?G.message:String(G)}`),process.exit(1)}if(C.length===0)console.error(`No Slack session found in Chrome (scanned ${B} profile${B!==1?"s":""}). Possible reasons:`),console.error(" - You denied the keychain dialog (try running again and click Allow)"),console.error(" - Chrome is not installed or has no Slack session"),console.error(" - You're not logged in to Slack in Chrome"),process.exit(1);let $;if(C.length===1&&B<=1)$=C[0].cookie,console.log(`Found session in Chrome profile: ${C[0].profileName}`);else{let G=C.length===1?`Found 1 Slack session across ${B} Chrome profiles:`:`Found ${C.length} Slack sessions across ${B} Chrome profiles:`;console.log(G),C.forEach((Q,O)=>console.log(` ${O+1}) ${Q.profileName} [${Q.profileDir}]`)),console.log("");let z=Yu({input:process.stdin,output:process.stdout}),Z=C.length===1?" [Enter=1]":"",Y=(await z.question(`Choice [1-${C.length}]${Z}: `)).trim();z.close();let J=Y===""&&C.length===1?0:parseInt(Y,10)-1;if(isNaN(J)||J<0||J>=C.length)console.error("Invalid choice."),process.exit(1);$=C[J].cookie}j0(F,$),console.log(`Saved xoxd cookie to workspace "${F}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function C1(D={}){let u=WF();if(u.length===0)console.error("No workspaces configured. Run: slack auth token"),process.exit(1);let F;if(D.workspace){if(!u.find(($)=>$.name===D.workspace))console.error(`Workspace "${D.workspace}" not found. Available: ${u.map(($)=>$.name).join(", ")}`),process.exit(1);F=D.workspace}else if(u.length===1)F=u[0].name;else{let B=u.find(($)=>$.current);if(B)F=B.name,console.log(`Using active workspace: ${F}`);else{console.log("Multiple workspaces found. Choose one:"),u.forEach((Z,Y)=>console.log(` ${Y+1}) ${Z.name} (${Z.profile.team})`));let $=Yu({input:process.stdin,output:process.stdout}),G=(await $.question("Choice: ")).trim();$.close();let z=parseInt(G,10)-1;if(isNaN(z)||z<0||z>=u.length)console.error("Invalid choice."),process.exit(1);F=u[z].name}}console.log("Scanning Firefox profiles for Slack session...");let E=u1();if(E.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 C;if(E.length===1)C=E[0].cookie,console.log(`Found session in Firefox profile: ${E[0].profileName}`);else{console.log("Multiple Firefox profiles have a Slack session. Choose one:"),E.forEach((z,Z)=>console.log(` ${Z+1}) ${z.profileName} [${z.profileDir}]`));let B=Yu({input:process.stdin,output:process.stdout}),$=(await B.question("Choice: ")).trim();B.close();let G=parseInt($,10)-1;if(isNaN(G)||G<0||G>=E.length)console.error("Invalid choice."),process.exit(1);C=E[G].cookie}j0(F,C),console.log(`Saved xoxd cookie to workspace "${F}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function B1(D={}){if(D.token){await Ou(null,D.token,D.name);return}if(!process.stdin.isTTY){let F=[];for await(let C of process.stdin)F.push(C);let E=Buffer.concat(F).toString("utf8").trim();if(!E)console.error("No token provided on stdin."),process.exit(1);await Ou(null,E,D.name);return}let u=Yu({input:process.stdin,output:process.stdout});try{await F1(u)}finally{u.close()}}async function $1(D={}){let u=Yu({input:process.stdin,output:process.stdout});try{if(D.bot!==void 0){await qF(u,D.bot?"bot":"user");return}console.log("Which token type?"),console.log(" 1) User token (xoxp-) -full access including search [default]"),console.log(" 2) Bot token (xoxb-) -search and news unavailable"),console.log("");let F=await Wu(u,"Choice [1/2, Enter=1]: ");await qF(u,F==="2"?"bot":"user")}finally{u.close()}}async function UF(D={}){let u=WF();if(u.length>0){console.log("Currently logged in:");for(let{name:E,profile:C,current:B}of u)console.log(` ${B?"*":" "} ${E} ${C.team} (${C.user||"unknown"})`);console.log(""),console.log("Adding another workspace:"),console.log("")}if(D.token){await Ou(null,D.token,D.name);return}if(!process.stdin.isTTY){let E=[];for await(let B of process.stdin)E.push(B);let C=Buffer.concat(E).toString("utf8").trim();if(!C)console.error("No token provided on stdin."),process.exit(1);await Ou(null,C,D.name);return}console.log("How would you like to authenticate with Slack?"),console.log(""),console.log(" 1) Slack desktop app - import session token"),console.log(" Reads the xoxc- token directly from the installed app."),console.log(" Token: all platforms | xoxd cookie: macOS only"),console.log(""),console.log(" 2) Connect existing Slack app [recommended if you have one]"),console.log(" Paste a token from an app you already created."),console.log(""),console.log(" 3) Create new Slack app - user token (xoxp-)"),console.log(" Guided setup with manifest. Full access including search."),console.log(""),console.log(" 4) Create new Slack app - bot token (xoxb-)"),console.log(" Bot is invited to channels. Search and news unavailable."),console.log("");let F=Yu({input:process.stdin,output:process.stdout});try{let E=await Wu(F,"Choice [1/2/3/4]: ");if(console.log(""),E==="1")await n6(F);else if(E==="2")await F1(F);else if(E==="3")await qF(F,"user");else if(E==="4")await qF(F,"bot");else console.error(`Invalid choice: "${E}". Enter 1, 2, 3, or 4.`),process.exit(1)}finally{F.close()}}async function MF(D,u,F){let E=u,C=[],B=E,$=0;while(!0){let G=B.indexOf("<@U",$);if(G===-1)break;let z=B.slice(G+2),Z=z.search(/[>|]/),Y=Z===-1?z:z.slice(0,Z);if(Y.length>=9)C.push(Y);$=G+1}for(let G of C){if(!F.has(G))F.set(G,await QF(D,G));let z=F.get(G)??G;E=E.replaceAll(`<@${G}>`,`@${z}`),E=E.replace(new RegExp(`<@${G}\\|[^>]*>`,"g"),`@${z}`)}return E}function KF(D){return D.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(u,F,E)=>{let C=Number(F);if(!Number.isFinite(C))return E??"date";let B=new Date(C*1000);if(Number.isNaN(B.getTime()))return E??"date";let $=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],G=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],z=$[B.getUTCDay()]??"",Z=G[B.getUTCMonth()]??"";return`${z}, ${Z} ${String(B.getUTCDate()).padStart(2,"0")}, ${B.getUTCFullYear()}`})}function z1(D){let u=typeof D.ts==="string"?D.ts:"",F=typeof D.thread_ts==="string"?D.thread_ts:"";return F!==""&&F!==u}function l6(D){let[u,F="000000"]=D.split("."),E=new Date(Number(u)*1000),C=E.getUTCFullYear(),B=String(E.getUTCMonth()+1).padStart(2,"0"),$=String(E.getUTCDate()).padStart(2,"0"),G=String(E.getUTCHours()).padStart(2,"0"),z=String(E.getUTCMinutes()).padStart(2,"0"),Z=String(E.getUTCSeconds()).padStart(2,"0"),Y=F.padEnd(6,"0").slice(0,6);return`${C}-${B}-${$}T${G}:${z}:${Z}.${Y}`}async function t6(D,u,F){let E=typeof u.ts==="string"?u.ts:"0.000000",C=l6(E),B="?";if(typeof u.user==="string"){let J=u.user,Q="@"+J;if(!F.has(Q)){let[,O]=await XF(D,J);F.set(Q,O)}B=F.get(Q)??J}else if(typeof u.username==="string")B=u.username;let $=typeof u.text==="string"?u.text:"",z=KF(await MF(D,$,F)).split(`
111
+ `),Z=z[0]+(z.length>1?`
112
+ `+z.slice(1).map((J)=>` ${J}`).join(`
113
+ `):""),Y=z1(u)?"↳ ":"";return`${C} ${Y}@${B}: ${Z}`}async function o6(D,u,F,E,C,B,$,G){if(G?.aborted)return;return new Promise((z)=>{let Z=new D(F);G?.addEventListener("abort",()=>{Z.close(),z()},{once:!0}),Z.addEventListener("open",()=>{process.stderr.write(`Connected via RTM (experimental).
114
+ `)}),Z.addEventListener("close",()=>z()),Z.addEventListener("error",()=>z()),Z.addEventListener("message",(Y)=>{(async()=>{try{let J;try{J=JSON.parse(String(Y.data))}catch{return}let Q=typeof J.type==="string"?J.type:"";if(Q==="ping"){Z.send(JSON.stringify({type:"pong",reply_to:J.id??0}));return}if(Q!=="message")return;if((typeof J.channel==="string"?J.channel:"")!==E)return;let V=typeof J.ts==="string"?J.ts:"";if(!V||B.has(V))return;let W=typeof J.subtype==="string"?J.subtype:"";if(W==="message_changed"||W==="message_deleted")return;if(C.thread){if((typeof J.thread_ts==="string"?J.thread_ts:V)!==C.thread&&V!==C.thread)return}if(C.watchThread&&z1(J)){if((typeof J.thread_ts==="string"?J.thread_ts:"")!==C.watchThread)return}if(C.me&&C.myUserId){if(!(typeof J.text==="string"?J.text:"").includes(`<@${C.myUserId}>`))return}if(B.add(V),B.size>1000){let _=B.values().next().value;if(_!==void 0)B.delete(_)}let M=await t6(u,J,$);process.stdout.write(M+`
110
115
  `)}catch(J){process.stderr.write(`RTM message error: ${J instanceof Error?J.message:String(J)}
111
- `)}})()})})}var G1=3,s6=2000,L0={sleep:(D)=>new Promise((u)=>setTimeout(u,D)),clientBoot:v8,getWebSocket:()=>{let D=globalThis.WebSocket;return typeof D==="function"?D:void 0}};async function Z1(D,u,F,E,C,B,$){let G=L0.getWebSocket();if(!G)return;for(let Z=0;Z<G1;Z++){if($?.aborted)return;try{let{wsUrl:z}=await L0.clientBoot(D,u);await o6(G,D,z,F,E,C,B,$)}catch{}if($?.aborted)return;if(Z<G1-1)await L0.sleep(s6)}}function J1(D){let u=D.match(/^(\d+(?:\.\d+)?)(s|m|h|d)$/);if(!u)throw Error(`Invalid --since format: "${D}" (expected e.g. 10m, 2h, 1d)`);let F=parseFloat(u[1]);switch(u[2]){case"s":return F;case"m":return F*60;case"h":return F*3600;case"d":return F*86400}}var SD={sleep:(D)=>new Promise((u)=>setTimeout(u,D)),now:()=>Date.now(),tailRTM:Z1};function pD(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function N0(D){return Array.isArray(D)?D:[]}function X1(D){return Number(D)||0}function Q1(D){let u=typeof D.ts==="string"?D.ts:"",F=typeof D.thread_ts==="string"?D.thread_ts:"";return F!==""&&F!==u}function r6(D){let[u,F="000000"]=D.split("."),E=new Date(Number(u)*1000),C=E.getUTCFullYear(),B=String(E.getUTCMonth()+1).padStart(2,"0"),$=String(E.getUTCDate()).padStart(2,"0"),G=String(E.getUTCHours()).padStart(2,"0"),Z=String(E.getUTCMinutes()).padStart(2,"0"),z=String(E.getUTCSeconds()).padStart(2,"0"),Y=F.padEnd(6,"0").slice(0,6);return`${C}-${B}-${$}T${G}:${Z}:${z}.${Y}`}async function a6(D,u,F,E){let C=typeof u.ts==="string"?u.ts:"0.000000",B=r6(C),$="?";if(typeof u.user==="string"){let O=u.user,V="@"+O;if(!F.has(V)){let[,W]=await JF(D,O);F.set(V,W)}$=F.get(V)??O}else if(typeof u.username==="string")$=u.username;let G=typeof u.text==="string"?u.text:"",z=KF(await MF(D,G,F)).split(`
112
- `),Y=z[0]+(z.length>1?`
113
- `+z.slice(1).map((O)=>` ${O}`).join(`
114
- `):""),J=Q1(u)?"↳ ":"",Q=E?`${E} @${$}`:`@${$}`;return`${B} ${J}${Q}: ${Y}`}async function e6(D,u,F,E,C,B,$){let G=pD(await Q0(D,u,20,$?void 0:F||void 0,$)),Z=N0(G.messages).map(pD).reverse(),z=pD(G.response_metadata),Y=G.has_more===!0&&typeof z.next_cursor==="string"?z.next_cursor:void 0,J=[];if(E.watchThread&&!$){let M=pD(await b8(D,u,E.watchThread,50));J=N0(M.messages).map(pD).filter((_)=>(typeof _.ts==="string"?_.ts:"")!==E.watchThread)}let Q=[...Z.map((M)=>({m:M,fromHistory:!0})),...J.map((M)=>({m:M,fromHistory:!1}))].sort((M,_)=>X1(typeof M.m.ts==="string"?M.m.ts:"")-X1(typeof _.m.ts==="string"?_.m.ts:"")),O=[],V=F,W=!1;for(let{m:M,fromHistory:_}of Q){let N=typeof M.ts==="string"?M.ts:"";if(!N||C.has(N))continue;let k=typeof M.subtype==="string"?M.subtype:"";if(k==="message_changed"||k==="message_deleted")continue;if(E.thread){if((typeof M.thread_ts==="string"?M.thread_ts:N)!==E.thread&&N!==E.thread)continue}if(E.watchThread&&Q1(M)){if((typeof M.thread_ts==="string"?M.thread_ts:"")!==E.watchThread)continue}if(E.me&&E.myUserId){if(!(typeof M.text==="string"?M.text:"").includes(`<@${E.myUserId}>`))continue}if(C.add(N),C.size>1000){let c=C.values().next().value;if(c!==void 0)C.delete(c)}if(O.push(await a6(D,M,B)),_)V=N;let w=typeof M.user==="string"?M.user:"";if(!E.myUserId||w!==E.myUserId)W=!0}return{newCursor:V,lines:O,hasMore:G.has_more===!0,nextPageCursor:Y,emittedOther:W}}function D7(D){if(D.includes("slack.com")){let u=Y0(D),F=u?.threadTs??u?.ts;if(F)return F;throw Error(`--watch-thread: could not extract a timestamp from "${D}"`)}if(/^\d{10}\.\d{6}$/.test(D))return D;if(/^\d{16}$/.test(D))return`${D.slice(0,10)}.${D.slice(10)}`;throw Error(`--watch-thread: "${D}" is not a valid ts or permalink`)}async function Y1(D,u,F={},E){if(F.me&&!u)console.error(`slack tail --me requires a <target> channel.
116
+ `)}})()})})}var G1=3,s6=2000,L0={sleep:(D)=>new Promise((u)=>setTimeout(u,D)),clientBoot:v8,getWebSocket:()=>{let D=globalThis.WebSocket;return typeof D==="function"?D:void 0}};async function Z1(D,u,F,E,C,B,$){let G=L0.getWebSocket();if(!G)return;for(let z=0;z<G1;z++){if($?.aborted)return;try{let{wsUrl:Z}=await L0.clientBoot(D,u);await o6(G,D,Z,F,E,C,B,$)}catch{}if($?.aborted)return;if(z<G1-1)await L0.sleep(s6)}}function J1(D){let u=D.match(/^(\d+(?:\.\d+)?)(s|m|h|d)$/);if(!u)throw Error(`Invalid --since format: "${D}" (expected e.g. 10m, 2h, 1d)`);let F=parseFloat(u[1]);switch(u[2]){case"s":return F;case"m":return F*60;case"h":return F*3600;case"d":return F*86400}}var SD={sleep:(D)=>new Promise((u)=>setTimeout(u,D)),now:()=>Date.now(),tailRTM:Z1};function pD(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function N0(D){return Array.isArray(D)?D:[]}function X1(D){return Number(D)||0}function Q1(D){let u=typeof D.ts==="string"?D.ts:"",F=typeof D.thread_ts==="string"?D.thread_ts:"";return F!==""&&F!==u}function r6(D){let[u,F="000000"]=D.split("."),E=new Date(Number(u)*1000),C=E.getUTCFullYear(),B=String(E.getUTCMonth()+1).padStart(2,"0"),$=String(E.getUTCDate()).padStart(2,"0"),G=String(E.getUTCHours()).padStart(2,"0"),z=String(E.getUTCMinutes()).padStart(2,"0"),Z=String(E.getUTCSeconds()).padStart(2,"0"),Y=F.padEnd(6,"0").slice(0,6);return`${C}-${B}-${$}T${G}:${z}:${Z}.${Y}`}async function a6(D,u,F,E){let C=typeof u.ts==="string"?u.ts:"0.000000",B=r6(C),$="?";if(typeof u.user==="string"){let O=u.user,V="@"+O;if(!F.has(V)){let[,W]=await XF(D,O);F.set(V,W)}$=F.get(V)??O}else if(typeof u.username==="string")$=u.username;let G=typeof u.text==="string"?u.text:"",Z=KF(await MF(D,G,F)).split(`
117
+ `),Y=Z[0]+(Z.length>1?`
118
+ `+Z.slice(1).map((O)=>` ${O}`).join(`
119
+ `):""),J=Q1(u)?"↳ ":"",Q=E?`${E} @${$}`:`@${$}`;return`${B} ${J}${Q}: ${Y}`}async function e6(D,u,F,E,C,B,$){let G=pD(await Q0(D,u,20,$?void 0:F||void 0,$)),z=N0(G.messages).map(pD).reverse(),Z=pD(G.response_metadata),Y=G.has_more===!0&&typeof Z.next_cursor==="string"?Z.next_cursor:void 0,J=[];if(E.watchThread&&!$){let M=pD(await b8(D,u,E.watchThread,50));J=N0(M.messages).map(pD).filter((_)=>(typeof _.ts==="string"?_.ts:"")!==E.watchThread)}let Q=[...z.map((M)=>({m:M,fromHistory:!0})),...J.map((M)=>({m:M,fromHistory:!1}))].sort((M,_)=>X1(typeof M.m.ts==="string"?M.m.ts:"")-X1(typeof _.m.ts==="string"?_.m.ts:"")),O=[],V=F,W=!1;for(let{m:M,fromHistory:_}of Q){let N=typeof M.ts==="string"?M.ts:"";if(!N||C.has(N))continue;let k=typeof M.subtype==="string"?M.subtype:"";if(k==="message_changed"||k==="message_deleted")continue;if(E.thread){if((typeof M.thread_ts==="string"?M.thread_ts:N)!==E.thread&&N!==E.thread)continue}if(E.watchThread&&Q1(M)){if((typeof M.thread_ts==="string"?M.thread_ts:"")!==E.watchThread)continue}if(E.me&&E.myUserId){if(!(typeof M.text==="string"?M.text:"").includes(`<@${E.myUserId}>`))continue}if(C.add(N),C.size>1000){let c=C.values().next().value;if(c!==void 0)C.delete(c)}if(O.push(await a6(D,M,B)),_)V=N;let w=typeof M.user==="string"?M.user:"";if(!E.myUserId||w!==E.myUserId)W=!0}return{newCursor:V,lines:O,hasMore:G.has_more===!0,nextPageCursor:Y,emittedOther:W}}function D7(D){if(D.includes("slack.com")){let u=Y0(D),F=u?.threadTs??u?.ts;if(F)return F;throw Error(`--watch-thread: could not extract a timestamp from "${D}"`)}if(/^\d{10}\.\d{6}$/.test(D))return D;if(/^\d{16}$/.test(D))return`${D.slice(0,10)}.${D.slice(10)}`;throw Error(`--watch-thread: "${D}" is not a valid ts or permalink`)}async function Y1(D,u,F={},E){if(F.me&&!u)console.error(`slack tail --me requires a <target> channel.
115
120
  Cross-channel mention streaming is not yet supported.
116
- Use: slack tail "#channel" --me`),process.exit(1);if(!u)console.error("Usage: slack tail <#channel|@user>\n Run `slack tail --help` for details."),process.exit(1);let C=await f8(D,u),B=F.interval??60000,$=F.timeout?SD.now()+J1(F.timeout)*1000:1/0,G=new Map,Z=new Set;try{let W=pD(await h8(D,C));if(pD(W.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(W){let M=W instanceof Error?W.message:String(W);if(M.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(M.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(M.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: ${M}`)}let z="";if(F.since){let W=J1(F.since);z=(SD.now()/1000-W).toFixed(6)}else{let W=pD(await Q0(D,C,1)),M=N0(W.messages).map(pD);if(M.length>0&&typeof M[0]?.ts==="string")z=M[0].ts,Z.add(z);else z=(SD.now()/1000).toFixed(6)}let Y;if(F.me||F.exitOnMessage)Y=(await ZF(D)).userId||void 0;let J;if(F.watchThread!==void 0)try{J=D7(F.watchThread)}catch(W){console.error(W instanceof Error?W.message:String(W)),process.exit(1)}let Q={...F.thread!==void 0?{thread:F.thread}:{},...J!==void 0?{watchThread:J}:{},...F.me!==void 0?{me:F.me}:{},...Y!==void 0?{myUserId:Y}:{}};if(D.startsWith("xoxc-")&&F.cookie!==void 0&&F.noRtm!==!0&&F.since===void 0&&F.timeout===void 0&&F.exitOnMessage!==!0){if(await SD.tailRTM(D,F.cookie,C,Q,Z,G,E),E?.aborted)return;console.error("RTM unavailable — switching to polling.")}let O=!0,V=SD.now();while(!E?.aborted){if(SD.now()>=$)return;let W=!1;try{let N=SD.now()-V,k=B>0&&N>B*5,w,c=!0;do{let{newCursor:e,lines:r,nextPageCursor:_D,emittedOther:i}=await e6(D,C,z,Q,Z,G,w);if(z=e,O&&c&&F.since&&r.length===0)process.stdout.write(`(no messages in the last ${F.since} — watching for new)
121
+ Use: slack tail "#channel" --me`),process.exit(1);if(!u)console.error("Usage: slack tail <#channel|@user>\n Run `slack tail --help` for details."),process.exit(1);let C=await f8(D,u),B=F.interval??60000,$=F.timeout?SD.now()+J1(F.timeout)*1000:1/0,G=new Map,z=new Set;try{let W=pD(await h8(D,C));if(pD(W.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(W){let M=W instanceof Error?W.message:String(W);if(M.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(M.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(M.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: ${M}`)}let Z="";if(F.since){let W=J1(F.since);Z=(SD.now()/1000-W).toFixed(6)}else{let W=pD(await Q0(D,C,1)),M=N0(W.messages).map(pD);if(M.length>0&&typeof M[0]?.ts==="string")Z=M[0].ts,z.add(Z);else Z=(SD.now()/1000).toFixed(6)}let Y;if(F.me||F.exitOnMessage)Y=(await JF(D)).userId||void 0;let J;if(F.watchThread!==void 0)try{J=D7(F.watchThread)}catch(W){console.error(W instanceof Error?W.message:String(W)),process.exit(1)}let Q={...F.thread!==void 0?{thread:F.thread}:{},...J!==void 0?{watchThread:J}:{},...F.me!==void 0?{me:F.me}:{},...Y!==void 0?{myUserId:Y}:{}};if(D.startsWith("xoxc-")&&F.cookie!==void 0&&F.noRtm!==!0&&F.since===void 0&&F.timeout===void 0&&F.exitOnMessage!==!0){if(await SD.tailRTM(D,F.cookie,C,Q,z,G,E),E?.aborted)return;console.error("RTM unavailable — switching to polling.")}let O=!0,V=SD.now();while(!E?.aborted){if(SD.now()>=$)return;let W=!1;try{let N=SD.now()-V,k=B>0&&N>B*5,w,c=!0;do{let{newCursor:e,lines:r,nextPageCursor:_D,emittedOther:i}=await e6(D,C,Z,Q,z,G,w);if(Z=e,O&&c&&F.since&&r.length===0)process.stdout.write(`(no messages in the last ${F.since} — watching for new)
117
122
  `);c=!1;for(let oD of r)process.stdout.write(oD+`
118
- `);if(i)W=!0;w=k?_D:void 0}while(w);O=!1}catch(_){if(_ instanceof lD){console.error(`Warning: Slack rate limit hit — backing off for ${_.retryAfter}s`),await SD.sleep(_.retryAfter*1000);continue}throw _}if(F.exitOnMessage&&W)return;V=SD.now();let M=$-SD.now();if(M<=0)return;await SD.sleep(Math.min(B,M))}}class bu extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function W1(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function O1(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${W1()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let G=parseInt(B.headers.get("retry-after")??"60",10);throw new bu(isNaN(G)?60:G)}let $=await B.json();if($.ok!==!0){let G=$.error??"unknown";if(G==="ratelimited")throw new bu(60);if(G==="invalid_auth"&&D.startsWith("xoxc-")&&!E)throw Error(`Desktop app token (xoxc-) is not accepted by the public Slack API.
123
+ `);if(i)W=!0;w=k?_D:void 0}while(w);O=!1}catch(_){if(_ instanceof lD){console.error(`Warning: Slack rate limit hit — backing off for ${_.retryAfter}s`),await SD.sleep(_.retryAfter*1000);continue}throw _}if(F.exitOnMessage&&W)return;V=SD.now();let M=$-SD.now();if(M<=0)return;await SD.sleep(Math.min(B,M))}}class fu extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function W1(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function O1(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${W1()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let G=parseInt(B.headers.get("retry-after")??"60",10);throw new fu(isNaN(G)?60:G)}let $=await B.json();if($.ok!==!0){let G=$.error??"unknown";if(G==="ratelimited")throw new fu(60);if(G==="invalid_auth"&&D.startsWith("xoxc-")&&!E)throw Error(`Desktop app token (xoxc-) is not accepted by the public Slack API.
119
124
  Replace it with an xoxp- user token:
120
- slack workspace set-token <name> <xoxp-token>`);throw Error(`Slack error on ${u}: ${G}`)}return $}async function u7(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${W1()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let G=parseInt(B.headers.get("retry-after")??"60",10);throw new bu(isNaN(G)?60:G)}let $=await B.json();if($.ok!==!0){let G=$.error??"unknown";if(G==="ratelimited")throw new bu(60);if((G==="invalid_auth"||G==="not_authed")&&!D.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
121
- Import from Slack desktop: slack workspace import`);if((G==="invalid_auth"||G==="not_authed")&&!E)throw Error(`drafts.list also requires the xoxd session cookie.
122
- Set it with: slack workspace set-cookie <workspace-name> <xoxd-value>
123
- `+"Get xoxd from browser: DevTools → Application → Cookies → slack.com d");throw Error(`Slack error on ${u}: ${G}`)}return $}function ju(D,u,F={},E){let C=new URLSearchParams({token:D,...F});return u7(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:C.toString()},E)}function CD(D,u,F,E){let C=new URLSearchParams(F).toString();return O1(D,`${u}?${C}`,{method:"GET"},E)}function PD(D,u,F){return O1(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)})}async function V1(D){let u=await CD(D,"auth.test",{});return{team:u.team??"",teamId:u.team_id??"",url:u.url??"",user:u.user??"",userId:u.user_id??""}}async function hu(D,u,F=20,E,C){let B={channel:u,limit:String(F)};if(E!==void 0)B.oldest=E;if(C!==void 0)B.cursor=C;return CD(D,"conversations.history",B)}async function Au(D,u,F,E=50){return CD(D,"conversations.replies",{channel:u,ts:F,limit:String(E)})}async function H1(D,u,F){return CD(D,"files.info",{file:u},F)}async function q1(D,u,F,E){return CD(D,"search.messages",{query:u,sort:"timestamp",sort_dir:"desc",count:String(Math.min(Math.max(F,1),100)),page:String(Math.max(E,1))})}async function U1(D,u){return q1(D,u,100,1)}async function M1(D,u,F){let C=1,B=[],$={ok:!0,messages:{}};while(!0){let Z=await q1(D,u,100,C),z=fu(Z,["messages","matches"]),Y=Array.isArray(z)?z:[];B.push(...Y);let J=Number(fu(Z,["messages","paging","pages"])??1);if($=Z,Y.length===0||C>=J||B.length>=F)break;C+=1}let G=$;if(!G.messages)G.messages={};return G.messages.matches=B.slice(0,F),G}async function K1(D,u,F,E,C){let B={channel:u,text:F,blocks:[{type:"markdown",text:F}]};if(E!==void 0)B.thread_ts=E;if(C&&E!==void 0)B.reply_broadcast=!0;return(await PD(D,"chat.postMessage",B)).ts??""}async function _1(D,u,F,E,C){let B={channel:u,text:F,post_at:E,blocks:[{type:"markdown",text:F}]};if(C!==void 0)B.thread_ts=C;return(await PD(D,"chat.scheduleMessage",B)).scheduled_message_id??""}async function j1(D,u){let F={};if(u)F.channel=u;return CD(D,"chat.scheduledMessages.list",F)}async function A1(D,u,F){await PD(D,"chat.deleteScheduledMessage",{channel:u,scheduled_message_id:F})}async function L1(D,u,F){return(await CD(D,"chat.getPermalink",{channel:u,message_ts:F})).permalink??""}async function N1(D,u,F,E){return(await PD(D,"chat.update",{channel:u,ts:F,text:E,blocks:[{type:"markdown",text:E}]})).ts??F}async function T1(D,u,F){await PD(D,"chat.delete",{channel:u,ts:F})}async function R1(D,u,F,E){await PD(D,"reactions.add",{channel:u,timestamp:F,name:E})}async function S1(D,u,F,E){await PD(D,"reactions.remove",{channel:u,timestamp:F,name:E})}async function P1(D,u,F=!1){let E=await PD(D,"conversations.create",{name:u,is_private:F});return{id:E.channel?.id??"",name:E.channel?.name??u}}async function w1(D,u,F){await PD(D,"conversations.invite",{channel:u,users:F.join(",")})}async function _F(D){let u=[],F="";while(!0){let E={limit:"200",types:"public_channel,private_channel,im,mpim"};if(F)E.cursor=F;let C=await CD(D,"conversations.list",E);if(u.push(...C.channels??[]),F=C.response_metadata?.next_cursor??"",!F)break}return{channels:u}}async function vu(D,u){let E=(await PD(D,"conversations.open",{users:u})).channel?.id;if(!E)throw Error(`Failed to open DM with user ${u}`);return E}function bD(D){return D.toLowerCase().replace(/[-_\s]/g,"")}async function T0(D,u,F){if(!u.startsWith("@")){if(/^[UW][A-Za-z0-9]{6,}$/.test(u))return u;throw Error(`Expected @user or a user ID, got: ${u}`)}let E=bD(u.slice(1)),C=await CD(D,"auth.test",{},F);if(E==="you"||E==="me"||bD(C.user??"")===E){if(!C.user_id)throw Error("auth.test did not return user_id");return C.user_id}let B="";while(!0){let $={limit:"200"};if(B)$.cursor=B;let G=await CD(D,"users.list",$,F);for(let Z of G.members??[]){let z=bD(Z.name??""),Y=bD(Z.real_name??""),J=bD(Z.profile?.display_name??"");if(z===E||Y===E||J&&J===E)return Z.id??""}if(B=G.response_metadata?.next_cursor??"",!B)break}throw Error(`User not found: ${u}`)}function pu(D){let u=D.match(/(?:app\.slack\.com\/client\/T[A-Za-z0-9]+|[A-Za-z0-9-]+\.slack\.com\/archives)\/([A-Za-z0-9]+)(?:\/p(\d{10})(\d{6}))?/);if(!u)return;let F=u[1],E=u[2]&&u[3]?`${u[2]}.${u[3]}`:void 0,C=D.indexOf("?"),B=C>=0?new URLSearchParams(D.slice(C)):void 0,$=B?.get("thread_ts")??void 0,z={channel:B?.get("cid")??void 0??F};if(E)z.ts=E;if($)z.threadTs=$;return z}function F7(D){return pu(D)?.channel}async function KD(D,u,F){let E=F7(u);if(E)return E;if(!u.startsWith("@")&&!u.startsWith("#")){if(/^[A-Za-z0-9]{9,}$/.test(u))return u;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${u}`)}let C=u.startsWith("@"),B=u.slice(1),$=bD(B);if(C){let z=await CD(D,"auth.test",{},F);if($==="you"||$==="me"||bD(z.user??"")===$){let V=z.user_id;if(!V)throw Error("auth.test did not return user_id");let M=((await CD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((_)=>_.user===V);if(M?.id)return String(M.id);return vu(D,V)}let J="",Q="";while(!0){let V={limit:"200"};if(Q)V.cursor=Q;let W=await CD(D,"users.list",V,F);for(let M of W.members??[]){let _=bD(M.name??""),N=bD(M.real_name??""),k=bD(M.profile?.display_name??"");if(_===$||N===$||k&&k===$){J=M.id??"";break}}if(J)break;if(Q=W.response_metadata?.next_cursor??"",!Q)break}if(!J)throw Error(`User not found: ${u}`);let O="";while(!0){let V={types:"im",limit:"200"};if(O)V.cursor=O;let W=await CD(D,"conversations.list",V,F);for(let M of W.channels??[])if(M.user===J)return String(M.id??"");if(O=W.response_metadata?.next_cursor??"",!O)break}throw Error(`No existing DM with ${u} (${J}). Open it once in Slack first.`)}let G=B.toLowerCase(),Z="";while(!0){let z={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(Z)z.cursor=Z;let Y=await CD(D,"conversations.list",z,F);for(let J of Y.channels??[])if(String(J.name??"").toLowerCase()===G)return String(J.id??"");if(Z=Y.response_metadata?.next_cursor??"",!Z)break}throw Error(`channel not found: ${u}`)}async function mu(D,u){try{let F=await CD(D,"users.info",{user:u}),E=F.user?.profile?.display_name,C=E&&E.length>0?E:F.user?.real_name??F.user?.name??u,B=F.user?.name??u;return[C,B]}catch{return[u,u]}}async function yu(D,u){try{let F=await CD(D,"users.info",{user:u}),E=F.user?.profile?.display_name;if(E&&E.length>0)return E;return F.user?.real_name??F.user?.name??u}catch{return u}}async function R0(D){let u=[],F="";while(!0){let E={limit:"200"};if(F)E.cursor=F;let C=await CD(D,"users.list",E);if(u.push(...C.members??[]),F=C.response_metadata?.next_cursor??"",!F)break}return{members:u}}async function cu(D,u){return ju(D,"drafts.list",{},u)}async function x1(D,u,F,E){let{randomUUID:C}=await import("node:crypto"),B=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:F}]}]}]);return ju(D,"drafts.create",{client_msg_id:C(),destinations:JSON.stringify([{channel_id:u}]),blocks:B,file_ids:JSON.stringify([]),is_from_composer:"true"},E)}async function I1(D,u,F,E,C){let B=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:E}]}]}]),$=(Date.now()/1000).toFixed(6);return ju(D,"drafts.update",{draft_id:u,client_last_updated_ts:$,destinations:JSON.stringify([{channel_id:F}]),blocks:B,file_ids:JSON.stringify([])},C)}async function b1(D,u,F){return ju(D,"conversations.info",{channel:u},F)}async function f1(D,u){return CD(D,"users.info",{user:u})}async function S0(D,u){return CD(D,"conversations.info",{channel:u})}async function h1(D,u,F){let E=(Date.now()/1000).toFixed(6);return ju(D,"drafts.delete",{draft_id:u,client_last_updated_ts:E},F)}async function P0(D,u){let F=await ju(D,"auth.test",{},u);return{userId:String(F.user_id??""),teamId:String(F.team_id??"")}}async function v1(D,u,F,E={}){let{statSync:C,readFileSync:B}=await import("node:fs"),{basename:$}=await import("node:path"),G=C(F),Z=$(F),z=await CD(D,"files.getUploadURLExternal",{filename:Z,length:String(G.size)}),Y=z.upload_url,J=z.file_id;if(!Y||!J)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let Q=B(F),O=await fetch(Y,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:Q});if(!O.ok)throw Error(`Upload PUT failed: ${O.status} ${O.statusText}`);let V={files:[{id:J,title:E.title??Z}],channel_id:u};if(E.threadTs)V.thread_ts=E.threadTs;if(E.initialComment)V.initial_comment=E.initialComment;let W=await PD(D,"files.completeUploadExternal",V),M={fileId:J},_=W.files?.[0]?.permalink;if(_)M.permalink=_;return M}function fu(D,u){let F=D;for(let E of u){if(F===void 0||F===null)return;if(typeof E==="number"){if(!Array.isArray(F))return;F=F[E]??void 0}else{if(typeof F!=="object"||Array.isArray(F))return;F=F[E]}}return F}function p1(){return/(?<![A-Za-z0-9._@<-])@([A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*)/g}function jF(D){return D.toLowerCase().replace(/[-_\s]/g,"")}function Vu(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function m1(D,u){let F=jF(u),E=Vu(D.profile);for(let B of[D.name,D.real_name,E.display_name,E.real_name])if(typeof B==="string"&&B&&jF(B)===F)return!0;let C=typeof E.email==="string"?E.email.toLowerCase():"";return C!==""&&C===u.toLowerCase()}async function x0(D,u,F,E={}){let C=E.warn??((Y)=>process.stderr.write(`${Y}
124
- `)),B=new Set;for(let Y of u.matchAll(p1()))B.add(Y[1]);if(B.size===0)return u;let $=new Map,Z=((await QF(D)).members??[]).map(Vu),z=[];for(let Y of B){let J=Z.find((O)=>m1(O,Y)),Q=J&&typeof J.id==="string"?J.id:"";if(Q)$.set(Y,Q);else z.push(Y)}if(z.length>0&&F){let Y=await W0(D,F),J=[];for(let Q of Y){let O=Vu(await O0(D,Q)),V=Vu(O.user);if(typeof V.id!=="string")V.id=Q;J.push(V)}for(let Q of z){let O=J.find((W)=>m1(W,Q)),V=O&&typeof O.id==="string"?O.id:"";if(V)$.set(Q,V)}}for(let Y of B)if(!$.has(Y))C(`warn: unresolved mention @${Y} (left as text)`);return u.replace(p1(),(Y,J)=>{let Q=$.get(J);return Q?`<@${Q}>`:Y})}var E7=["さん","さま","様","君","くん","ちゃん","氏","先生","先輩","殿","老师","老師","兄","姐","哥","姐妹"],C7="\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}A-Za-z0-9";function y1(D){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u.test(D)}function B7(D){let u=[],F=new RegExp(`([${C7}]{1,12})(${E7.join("|")})`,"gu");for(let E of D.matchAll(F))u.push({ref:E[1],honorific:E[2]});for(let E of D.matchAll(/\b(?:dear|hi|hello|hey)\b[ \t]+([A-Z][A-Za-z'’-]{1,20})/gi))u.push({ref:E[1],honorific:""});for(let E of D.matchAll(/(?:^|\n)[ \t]*([A-Z][A-Za-z'’-]{1,20}),/g))u.push({ref:E[1],honorific:""});return u}function $7(D){let u=Vu(D.profile),F=new Set;for(let E of[D.name,D.real_name,u.display_name,u.real_name]){if(typeof E!=="string"||!E)continue;for(let C of[E,...E.split(/\s+/)]){let B=jF(C);if(B.length>=2)F.add(B)}}return[...F]}function G7(D,u){let F=jF(D);if(F.length<2)return;for(let E of u)if(F===E)return E;if(y1(D)){for(let E of u)if(F.includes(E)||E.includes(F))return E}return}function z7(D){return[Vu(D.profile).display_name,D.real_name,D.name].filter((E)=>typeof E==="string"&&E!=="")[0]??String(D.id??"?")}async function c1(D,u){let F=B7(u);if(F.length===0)return[];let E=new Set;for(let Z of u.matchAll(/<@([A-Z0-9]+)(?:\|[^>]*)?>/g))E.add(Z[1]);let B=((await QF(D)).members??[]).map(Vu).filter((Z)=>Z.deleted!==!0&&Z.is_bot!==!0&&Z.id!=="USLACKBOT").map((Z)=>({id:typeof Z.id==="string"?Z.id:"",forms:$7(Z),display:z7(Z)})).filter((Z)=>Z.id!==""),$=[],G=new Set;for(let{ref:Z,honorific:z}of F)for(let Y of B){let J=G7(Z,Y.forms);if(!J)continue;if(E.has(Y.id)||G.has(Y.id))break;G.add(Y.id),$.push({surface:y1(Z)?`${J}${z}`:Z,display:Y.display,userId:Y.id});break}return $}async function Lu(D,u,F){let E=u,C=[],B=E,$=0;while(!0){let G=B.indexOf("<@U",$);if(G===-1)break;let Z=B.slice(G+2),z=Z.search(/[>|]/),Y=z===-1?Z:Z.slice(0,z);if(Y.length>=9)C.push(Y);$=G+1}for(let G of C){if(!F.has(G))F.set(G,await XF(D,G));let Z=F.get(G)??G;E=E.replaceAll(`<@${G}>`,`@${Z}`),E=E.replace(new RegExp(`<@${G}\\|[^>]*>`,"g"),`@${Z}`)}return E}function gu(D){return D.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(u,F,E)=>{let C=Number(F);if(!Number.isFinite(C))return E??"date";let B=new Date(C*1000);if(Number.isNaN(B.getTime()))return E??"date";let $=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],G=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Z=$[B.getUTCDay()]??"",z=G[B.getUTCMonth()]??"";return`${Z}, ${z} ${String(B.getUTCDate()).padStart(2,"0")}, ${B.getUTCFullYear()}`})}function g1(D,u=new Date){let F=new Date(D*1000),E=w0(u),C=w0(new Date(u.getTime()-86400000)),B=w0(F);if(B===E)return"Today";if(B===C)return"Yesterday";let $=F.toLocaleDateString("en-US",{weekday:"long"}),G=F.toLocaleDateString("en-US",{month:"short"});return`${$}, ${G} ${String(F.getDate()).padStart(2,"0")}`}function w0(D){return`${D.getFullYear()}-${D.getMonth()}-${D.getDate()}`}function k1(D){let u=new Date(D*1000),F=u.getFullYear(),E=String(u.getMonth()+1).padStart(2,"0"),C=String(u.getDate()).padStart(2,"0"),B=String(u.getHours()).padStart(2,"0"),$=String(u.getMinutes()).padStart(2,"0");return`${F}-${E}-${C} ${B}:${$}`}function ku(D){if(!t1(D))return;let u=J7(D,"utf8");for(let F of u.split(`
125
+ slack auth token`);if((G==="missing_scope"||G==="cannot_dm_bot")&&D.startsWith("xoxb-"))throw Error(`Slack error on ${u}: ${G} ${G==="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"}.
126
+ Tailing/DMing people and listing users need a user session, not a bot token.
127
+ Switch workspace: slack auth ls then slack auth use <name>
128
+ Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${u}: ${G}`)}return $}async function u7(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${W1()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let G=parseInt(B.headers.get("retry-after")??"60",10);throw new fu(isNaN(G)?60:G)}let $=await B.json();if($.ok!==!0){let G=$.error??"unknown";if(G==="ratelimited")throw new fu(60);if((G==="invalid_auth"||G==="not_authed")&&!D.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
129
+ Import from Slack desktop: slack auth login`);if((G==="invalid_auth"||G==="not_authed")&&!E)throw Error(`drafts.list also requires the xoxd session cookie.
130
+ Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${u}: ${G}`)}return $}function ju(D,u,F={},E){let C=new URLSearchParams({token:D,...F});return u7(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:C.toString()},E)}function CD(D,u,F,E){let C=new URLSearchParams(F).toString();return O1(D,`${u}?${C}`,{method:"GET"},E)}function PD(D,u,F){return O1(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)})}async function V1(D){let u=await CD(D,"auth.test",{});return{team:u.team??"",teamId:u.team_id??"",url:u.url??"",user:u.user??"",userId:u.user_id??""}}async function vu(D,u,F=20,E,C){let B={channel:u,limit:String(F)};if(E!==void 0)B.oldest=E;if(C!==void 0)B.cursor=C;return CD(D,"conversations.history",B)}async function Au(D,u,F,E=50){return CD(D,"conversations.replies",{channel:u,ts:F,limit:String(E)})}async function H1(D,u,F){return CD(D,"files.info",{file:u},F)}async function q1(D,u,F,E){return CD(D,"search.messages",{query:u,sort:"timestamp",sort_dir:"desc",count:String(Math.min(Math.max(F,1),100)),page:String(Math.max(E,1))})}async function U1(D,u){return q1(D,u,100,1)}async function M1(D,u,F){let C=1,B=[],$={ok:!0,messages:{}};while(!0){let z=await q1(D,u,100,C),Z=hu(z,["messages","matches"]),Y=Array.isArray(Z)?Z:[];B.push(...Y);let J=Number(hu(z,["messages","paging","pages"])??1);if($=z,Y.length===0||C>=J||B.length>=F)break;C+=1}let G=$;if(!G.messages)G.messages={};return G.messages.matches=B.slice(0,F),G}async function K1(D,u,F,E,C){let B={channel:u,text:F,blocks:[{type:"markdown",text:F}]};if(E!==void 0)B.thread_ts=E;if(C&&E!==void 0)B.reply_broadcast=!0;return(await PD(D,"chat.postMessage",B)).ts??""}async function _1(D,u,F,E,C){let B={channel:u,text:F,post_at:E,blocks:[{type:"markdown",text:F}]};if(C!==void 0)B.thread_ts=C;return(await PD(D,"chat.scheduleMessage",B)).scheduled_message_id??""}async function j1(D,u){let F={};if(u)F.channel=u;return CD(D,"chat.scheduledMessages.list",F)}async function A1(D,u,F){await PD(D,"chat.deleteScheduledMessage",{channel:u,scheduled_message_id:F})}async function L1(D,u,F){return(await CD(D,"chat.getPermalink",{channel:u,message_ts:F})).permalink??""}async function N1(D,u,F,E){return(await PD(D,"chat.update",{channel:u,ts:F,text:E,blocks:[{type:"markdown",text:E}]})).ts??F}async function T1(D,u,F){await PD(D,"chat.delete",{channel:u,ts:F})}async function R1(D,u,F,E){await PD(D,"reactions.add",{channel:u,timestamp:F,name:E})}async function S1(D,u,F,E){await PD(D,"reactions.remove",{channel:u,timestamp:F,name:E})}async function P1(D,u,F=!1){let E=await PD(D,"conversations.create",{name:u,is_private:F});return{id:E.channel?.id??"",name:E.channel?.name??u}}async function w1(D,u,F){await PD(D,"conversations.invite",{channel:u,users:F.join(",")})}async function _F(D){let u=[],F="";while(!0){let E={limit:"200",types:"public_channel,private_channel,im,mpim"};if(F)E.cursor=F;let C=await CD(D,"conversations.list",E);if(u.push(...C.channels??[]),F=C.response_metadata?.next_cursor??"",!F)break}return{channels:u}}async function pu(D,u){let E=(await PD(D,"conversations.open",{users:u})).channel?.id;if(!E)throw Error(`Failed to open DM with user ${u}`);return E}function bD(D){return D.toLowerCase().replace(/[-_\s]/g,"")}async function T0(D,u,F){if(!u.startsWith("@")){if(/^[UW][A-Za-z0-9]{6,}$/.test(u))return u;throw Error(`Expected @user or a user ID, got: ${u}`)}let E=bD(u.slice(1)),C=await CD(D,"auth.test",{},F);if(E==="you"||E==="me"||bD(C.user??"")===E){if(!C.user_id)throw Error("auth.test did not return user_id");return C.user_id}let B="";while(!0){let $={limit:"200"};if(B)$.cursor=B;let G=await CD(D,"users.list",$,F);for(let z of G.members??[]){let Z=bD(z.name??""),Y=bD(z.real_name??""),J=bD(z.profile?.display_name??"");if(Z===E||Y===E||J&&J===E)return z.id??""}if(B=G.response_metadata?.next_cursor??"",!B)break}throw Error(`User not found: ${u}`)}function yu(D){let u=D.match(/(?:app\.slack\.com\/client\/T[A-Za-z0-9]+|[A-Za-z0-9-]+\.slack\.com\/archives)\/([A-Za-z0-9]+)(?:\/p(\d{10})(\d{6}))?/);if(!u)return;let F=u[1],E=u[2]&&u[3]?`${u[2]}.${u[3]}`:void 0,C=D.indexOf("?"),B=C>=0?new URLSearchParams(D.slice(C)):void 0,$=B?.get("thread_ts")??void 0,Z={channel:B?.get("cid")??void 0??F};if(E)Z.ts=E;if($)Z.threadTs=$;return Z}function F7(D){return yu(D)?.channel}async function KD(D,u,F){let E=F7(u);if(E)return E;if(!u.startsWith("@")&&!u.startsWith("#")){if(/^[A-Za-z0-9]{9,}$/.test(u))return u;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${u}`)}let C=u.startsWith("@"),B=u.slice(1),$=bD(B);if(C){let Z=await CD(D,"auth.test",{},F);if($==="you"||$==="me"||bD(Z.user??"")===$){let V=Z.user_id;if(!V)throw Error("auth.test did not return user_id");let M=((await CD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((_)=>_.user===V);if(M?.id)return String(M.id);return pu(D,V)}let J="",Q="";while(!0){let V={limit:"200"};if(Q)V.cursor=Q;let W=await CD(D,"users.list",V,F);for(let M of W.members??[]){let _=bD(M.name??""),N=bD(M.real_name??""),k=bD(M.profile?.display_name??"");if(_===$||N===$||k&&k===$){J=M.id??"";break}}if(J)break;if(Q=W.response_metadata?.next_cursor??"",!Q)break}if(!J)throw Error(`User not found: ${u}`);let O="";while(!0){let V={types:"im",limit:"200"};if(O)V.cursor=O;let W=await CD(D,"conversations.list",V,F);for(let M of W.channels??[])if(M.user===J)return String(M.id??"");if(O=W.response_metadata?.next_cursor??"",!O)break}throw Error(`No existing DM with ${u} (${J}). Open it once in Slack first.`)}let G=B.toLowerCase(),z="";while(!0){let Z={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(z)Z.cursor=z;let Y=await CD(D,"conversations.list",Z,F);for(let J of Y.channels??[])if(String(J.name??"").toLowerCase()===G)return String(J.id??"");if(z=Y.response_metadata?.next_cursor??"",!z)break}throw Error(`channel not found: ${u}`)}async function mu(D,u){try{let F=await CD(D,"users.info",{user:u}),E=F.user?.profile?.display_name,C=E&&E.length>0?E:F.user?.real_name??F.user?.name??u,B=F.user?.name??u;return[C,B]}catch{return[u,u]}}async function cu(D,u){try{let F=await CD(D,"users.info",{user:u}),E=F.user?.profile?.display_name;if(E&&E.length>0)return E;return F.user?.real_name??F.user?.name??u}catch{return u}}async function R0(D){let u=[],F="";while(!0){let E={limit:"200"};if(F)E.cursor=F;let C=await CD(D,"users.list",E);if(u.push(...C.members??[]),F=C.response_metadata?.next_cursor??"",!F)break}return{members:u}}async function gu(D,u){return ju(D,"drafts.list",{},u)}async function x1(D,u,F,E){let{randomUUID:C}=await import("node:crypto"),B=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:F}]}]}]);return ju(D,"drafts.create",{client_msg_id:C(),destinations:JSON.stringify([{channel_id:u}]),blocks:B,file_ids:JSON.stringify([]),is_from_composer:"true"},E)}async function I1(D,u,F,E,C){let B=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:E}]}]}]),$=(Date.now()/1000).toFixed(6);return ju(D,"drafts.update",{draft_id:u,client_last_updated_ts:$,destinations:JSON.stringify([{channel_id:F}]),blocks:B,file_ids:JSON.stringify([])},C)}async function b1(D,u,F){return ju(D,"conversations.info",{channel:u},F)}async function f1(D,u){return CD(D,"users.info",{user:u})}async function S0(D,u){return CD(D,"conversations.info",{channel:u})}async function h1(D,u,F){let E=(Date.now()/1000).toFixed(6);return ju(D,"drafts.delete",{draft_id:u,client_last_updated_ts:E},F)}async function P0(D,u){let F=await ju(D,"auth.test",{},u);return{userId:String(F.user_id??""),teamId:String(F.team_id??"")}}async function v1(D,u,F,E={}){let{statSync:C,readFileSync:B}=await import("node:fs"),{basename:$}=await import("node:path"),G=C(F),z=$(F),Z=await CD(D,"files.getUploadURLExternal",{filename:z,length:String(G.size)}),Y=Z.upload_url,J=Z.file_id;if(!Y||!J)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let Q=B(F),O=await fetch(Y,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:Q});if(!O.ok)throw Error(`Upload PUT failed: ${O.status} ${O.statusText}`);let V={files:[{id:J,title:E.title??z}],channel_id:u};if(E.threadTs)V.thread_ts=E.threadTs;if(E.initialComment)V.initial_comment=E.initialComment;let W=await PD(D,"files.completeUploadExternal",V),M={fileId:J},_=W.files?.[0]?.permalink;if(_)M.permalink=_;return M}function hu(D,u){let F=D;for(let E of u){if(F===void 0||F===null)return;if(typeof E==="number"){if(!Array.isArray(F))return;F=F[E]??void 0}else{if(typeof F!=="object"||Array.isArray(F))return;F=F[E]}}return F}function p1(){return/(?<![A-Za-z0-9._@<-])@([A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*)/g}function jF(D){return D.toLowerCase().replace(/[-_\s]/g,"")}function Vu(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function y1(D,u){let F=jF(u),E=Vu(D.profile);for(let B of[D.name,D.real_name,E.display_name,E.real_name])if(typeof B==="string"&&B&&jF(B)===F)return!0;let C=typeof E.email==="string"?E.email.toLowerCase():"";return C!==""&&C===u.toLowerCase()}async function x0(D,u,F,E={}){let C=E.warn??((Y)=>process.stderr.write(`${Y}
131
+ `)),B=new Set;for(let Y of u.matchAll(p1()))B.add(Y[1]);if(B.size===0)return u;let $=new Map,z=((await YF(D)).members??[]).map(Vu),Z=[];for(let Y of B){let J=z.find((O)=>y1(O,Y)),Q=J&&typeof J.id==="string"?J.id:"";if(Q)$.set(Y,Q);else Z.push(Y)}if(Z.length>0&&F){let Y=await W0(D,F),J=[];for(let Q of Y){let O=Vu(await O0(D,Q)),V=Vu(O.user);if(typeof V.id!=="string")V.id=Q;J.push(V)}for(let Q of Z){let O=J.find((W)=>y1(W,Q)),V=O&&typeof O.id==="string"?O.id:"";if(V)$.set(Q,V)}}for(let Y of B)if(!$.has(Y))C(`warn: unresolved mention @${Y} (left as text)`);return u.replace(p1(),(Y,J)=>{let Q=$.get(J);return Q?`<@${Q}>`:Y})}var E7=["さん","さま","様","君","くん","ちゃん","氏","先生","先輩","殿","老师","老師","兄","姐","哥","姐妹"],C7="\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}A-Za-z0-9";function m1(D){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u.test(D)}function B7(D){let u=[],F=new RegExp(`([${C7}]{1,12})(${E7.join("|")})`,"gu");for(let E of D.matchAll(F))u.push({ref:E[1],honorific:E[2]});for(let E of D.matchAll(/\b(?:dear|hi|hello|hey)\b[ \t]+([A-Z][A-Za-z'’-]{1,20})/gi))u.push({ref:E[1],honorific:""});for(let E of D.matchAll(/(?:^|\n)[ \t]*([A-Z][A-Za-z'’-]{1,20}),/g))u.push({ref:E[1],honorific:""});return u}function $7(D){let u=Vu(D.profile),F=new Set;for(let E of[D.name,D.real_name,u.display_name,u.real_name]){if(typeof E!=="string"||!E)continue;for(let C of[E,...E.split(/\s+/)]){let B=jF(C);if(B.length>=2)F.add(B)}}return[...F]}function G7(D,u){let F=jF(D);if(F.length<2)return;for(let E of u)if(F===E)return E;if(m1(D)){for(let E of u)if(F.includes(E)||E.includes(F))return E}return}function z7(D){return[Vu(D.profile).display_name,D.real_name,D.name].filter((E)=>typeof E==="string"&&E!=="")[0]??String(D.id??"?")}async function c1(D,u){let F=B7(u);if(F.length===0)return[];let E=new Set;for(let z of u.matchAll(/<@([A-Z0-9]+)(?:\|[^>]*)?>/g))E.add(z[1]);let B=((await YF(D)).members??[]).map(Vu).filter((z)=>z.deleted!==!0&&z.is_bot!==!0&&z.id!=="USLACKBOT").map((z)=>({id:typeof z.id==="string"?z.id:"",forms:$7(z),display:z7(z)})).filter((z)=>z.id!==""),$=[],G=new Set;for(let{ref:z,honorific:Z}of F)for(let Y of B){let J=G7(z,Y.forms);if(!J)continue;if(E.has(Y.id)||G.has(Y.id))break;G.add(Y.id),$.push({surface:m1(z)?`${J}${Z}`:z,display:Y.display,userId:Y.id});break}return $}async function Lu(D,u,F){let E=u,C=[],B=E,$=0;while(!0){let G=B.indexOf("<@U",$);if(G===-1)break;let z=B.slice(G+2),Z=z.search(/[>|]/),Y=Z===-1?z:z.slice(0,Z);if(Y.length>=9)C.push(Y);$=G+1}for(let G of C){if(!F.has(G))F.set(G,await QF(D,G));let z=F.get(G)??G;E=E.replaceAll(`<@${G}>`,`@${z}`),E=E.replace(new RegExp(`<@${G}\\|[^>]*>`,"g"),`@${z}`)}return E}function ku(D){return D.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(u,F,E)=>{let C=Number(F);if(!Number.isFinite(C))return E??"date";let B=new Date(C*1000);if(Number.isNaN(B.getTime()))return E??"date";let $=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],G=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],z=$[B.getUTCDay()]??"",Z=G[B.getUTCMonth()]??"";return`${z}, ${Z} ${String(B.getUTCDate()).padStart(2,"0")}, ${B.getUTCFullYear()}`})}function g1(D,u=new Date){let F=new Date(D*1000),E=w0(u),C=w0(new Date(u.getTime()-86400000)),B=w0(F);if(B===E)return"Today";if(B===C)return"Yesterday";let $=F.toLocaleDateString("en-US",{weekday:"long"}),G=F.toLocaleDateString("en-US",{month:"short"});return`${$}, ${G} ${String(F.getDate()).padStart(2,"0")}`}function w0(D){return`${D.getFullYear()}-${D.getMonth()}-${D.getDate()}`}function k1(D){let u=new Date(D*1000),F=u.getFullYear(),E=String(u.getMonth()+1).padStart(2,"0"),C=String(u.getDate()).padStart(2,"0"),B=String(u.getHours()).padStart(2,"0"),$=String(u.getMinutes()).padStart(2,"0");return`${F}-${E}-${C} ${B}:${$}`}function du(D){if(!t1(D))return;let u=J7(D,"utf8");for(let F of u.split(`
125
132
  `)){let E=F.trim();if(!E||E.startsWith("#"))continue;let C=E.indexOf("=");if(C===-1)continue;let B=E.slice(0,C).trim(),$=E.slice(C+1).trim();if($.startsWith('"')&&$.endsWith('"')||$.startsWith("'")&&$.endsWith("'"))$=$.slice(1,-1);if(!(B in process.env))process.env[B]=$}}function Q7(D){X7(D,{recursive:!0});let u=tD(D,".gitignore");if(!t1(u))o1(u,`*
126
- `)}function Y7(){ku(tD(d1(),".slack-cli",".env.local")),ku(tD(d1(),".config/slack-cli",".env")),ku(tD(process.cwd(),".slack-cli",".env.local")),ku(tD(process.cwd(),".env.local")),ku(tD(process.cwd(),".env"))}function W7(D){return Z7("sha256").update(D).digest("hex")}function y(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function o(D){return Array.isArray(D)?D:[]}function AF(D){return Number(D.ts??0)}async function s1(D,u,F){let E=u.user;if(typeof E==="string"){if(!F.has(E))F.set(E,await yu(D,E));return F.get(E)??E}return typeof u.username==="string"?u.username:"bot"}function I0(D){let u=new Date(D*1000),F=u.getUTCFullYear(),E=String(u.getUTCMonth()+1).padStart(2,"0"),C=String(u.getUTCDate()).padStart(2,"0"),B=String(u.getUTCHours()).padStart(2,"0"),$=String(u.getUTCMinutes()).padStart(2,"0"),G=String(u.getUTCSeconds()).padStart(2,"0");return`${F}-${E}-${C} ${B}:${$}:${G}`}function f0(D){let[u,F="000000"]=D.split("."),E=Number(u),C=new Date(E*1000),B=C.getUTCFullYear(),$=String(C.getUTCMonth()+1).padStart(2,"0"),G=String(C.getUTCDate()).padStart(2,"0"),Z=String(C.getUTCHours()).padStart(2,"0"),z=String(C.getUTCMinutes()).padStart(2,"0"),Y=String(C.getUTCSeconds()).padStart(2,"0"),J=F.padEnd(6,"0").slice(0,6);return`${B}-${$}-${G}T${Z}:${z}:${Y}.${J}`}function h0(D){let u=D.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\.(\d{6})$/);if(!u)throw Error(`Invalid message timestamp "${D}" \u2014 expected 2026-05-11T06:01:04.000100`);let F=Date.parse(u[1]+"Z");if(isNaN(F))throw Error(`Cannot parse date in "${D}"`);return`${Math.floor(F/1000)}.${u[2]}`}function O7(D){return/^\d{4}-\d{2}-\d{2}T/.test(D)?h0(D):D}async function NF(D,u,F,E){let C=typeof u.ts==="string"?u.ts:`${AF(u)}.000000`,B=f0(C),$="?";if(typeof u.user==="string"){let W=u.user,M="@"+W;if(!F.has(M)){let[,_]=await mu(D,W);F.set(M,_)}$=F.get(M)??W}else if(typeof u.username==="string")$=u.username;let G=typeof u.text==="string"?u.text:"",z=gu(await Lu(D,G,F)).split(`
127
- `),Y=z[0]+(z.length>1?`
128
- `+z.slice(1).map((W)=>` ${W}`).join(`
129
- `):""),J=E?`${E} @${$}`:`@${$}`,Q=o(u.reactions).map(y).map((W)=>{let M=typeof W.name==="string"?W.name:"",_=Number(W.count??o(W.users).length??0);return M?`:${M}:\xD7${_}`:""}).filter(Boolean).join(" "),O=o(u.files).map(y).map((W)=>{let M=typeof W.name==="string"?W.name:typeof W.title==="string"?W.title:"(file)",_=typeof W.size==="number"?` (${v0(W.size)})`:"",N=typeof W.id==="string"?` [${W.id}]`:"";return`
133
+ `)}function Y7(){du(tD(d1(),".slack-cli",".env.local")),du(tD(d1(),".config/slack-cli",".env")),du(tD(process.cwd(),".slack-cli",".env.local")),du(tD(process.cwd(),".env.local")),du(tD(process.cwd(),".env"))}function W7(D){return Z7("sha256").update(D).digest("hex")}function m(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function o(D){return Array.isArray(D)?D:[]}function AF(D){return Number(D.ts??0)}async function s1(D,u,F){let E=u.user;if(typeof E==="string"){if(!F.has(E))F.set(E,await cu(D,E));return F.get(E)??E}return typeof u.username==="string"?u.username:"bot"}function I0(D){let u=new Date(D*1000),F=u.getUTCFullYear(),E=String(u.getUTCMonth()+1).padStart(2,"0"),C=String(u.getUTCDate()).padStart(2,"0"),B=String(u.getUTCHours()).padStart(2,"0"),$=String(u.getUTCMinutes()).padStart(2,"0"),G=String(u.getUTCSeconds()).padStart(2,"0");return`${F}-${E}-${C} ${B}:${$}:${G}`}function f0(D){let[u,F="000000"]=D.split("."),E=Number(u),C=new Date(E*1000),B=C.getUTCFullYear(),$=String(C.getUTCMonth()+1).padStart(2,"0"),G=String(C.getUTCDate()).padStart(2,"0"),z=String(C.getUTCHours()).padStart(2,"0"),Z=String(C.getUTCMinutes()).padStart(2,"0"),Y=String(C.getUTCSeconds()).padStart(2,"0"),J=F.padEnd(6,"0").slice(0,6);return`${B}-${$}-${G}T${z}:${Z}:${Y}.${J}`}function h0(D){let u=D.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\.(\d{6})$/);if(!u)throw Error(`Invalid message timestamp "${D}" \u2014 expected 2026-05-11T06:01:04.000100`);let F=Date.parse(u[1]+"Z");if(isNaN(F))throw Error(`Cannot parse date in "${D}"`);return`${Math.floor(F/1000)}.${u[2]}`}function O7(D){return/^\d{4}-\d{2}-\d{2}T/.test(D)?h0(D):D}async function NF(D,u,F,E){let C=typeof u.ts==="string"?u.ts:`${AF(u)}.000000`,B=f0(C),$="?";if(typeof u.user==="string"){let W=u.user,M="@"+W;if(!F.has(M)){let[,_]=await mu(D,W);F.set(M,_)}$=F.get(M)??W}else if(typeof u.username==="string")$=u.username;let G=typeof u.text==="string"?u.text:"",Z=ku(await Lu(D,G,F)).split(`
134
+ `),Y=Z[0]+(Z.length>1?`
135
+ `+Z.slice(1).map((W)=>` ${W}`).join(`
136
+ `):""),J=E?`${E} @${$}`:`@${$}`,Q=o(u.reactions).map(m).map((W)=>{let M=typeof W.name==="string"?W.name:"",_=Number(W.count??o(W.users).length??0);return M?`:${M}:\xD7${_}`:""}).filter(Boolean).join(" "),O=o(u.files).map(m).map((W)=>{let M=typeof W.name==="string"?W.name:typeof W.title==="string"?W.title:"(file)",_=typeof W.size==="number"?` (${v0(W.size)})`:"",N=typeof W.id==="string"?` [${W.id}]`:"";return`
130
137
  \uD83D\uDCCE ${M}${_}${N}`}).join(""),V=(Q?`
131
- ${Q}`:"")+O;return`${B} ${J}: ${Y}${V}`}function v0(D){return D<1024?`${D} B`:D<1048576?`${(D/1024).toFixed(1)} KB`:`${(D/1048576).toFixed(1)} MB`}function V7(D){return o(D.files).map(y).map((u)=>({id:u.id??null,name:u.name??u.title??null,mimetype:u.mimetype??null,size:u.size??null,url_private_download:u.url_private_download??u.url_private??null,permalink:u.permalink??null}))}function r1(D){let u=V7(D);return{ts:D.ts??null,user:D.user??null,username:D.username??null,bot_id:D.bot_id??null,thread_ts:D.thread_ts??null,text:typeof D.text==="string"?D.text:"",...u.length>0?{files:u}:{}}}async function H7(D,u,F,E="text"){let C=pu(u),B=await KD(D,u),$=new Map,Z=await(async()=>{if(C?.threadTs){let Y=await Au(D,B,C.threadTs,F);return o(Y.messages).map(y)}let z=await hu(D,B,F);return o(z.messages).map(y).reverse()})();if(E==="jsonl"){for(let z of Z)console.log(JSON.stringify(r1(z)));return}for(let z of Z)console.log(await NF(D,z,$))}async function q7(D,u,F,E,C="text"){let B=await KD(D,u),$=await Au(D,B,O7(F),E),G=o($.messages).map(y);if(C==="jsonl"){for(let z of G)console.log(JSON.stringify(r1(z)));return}let Z=new Map;for(let z of G)console.log(await NF(D,z,Z))}async function U7(D){let u=await _F(D),F=o(u.channels).map(y).filter((C)=>C.is_member===!0).sort((C,B)=>Number(B.updated??0)-Number(C.updated??0)).slice(0,10),E=new Map;for(let C of F){let B=String(C.id??""),$=typeof C.name==="string"?C.name:typeof C.user==="string"?C.user:B,G=await hu(D,B,5),Z=o(G.messages).map(y).filter((z)=>z.subtype===void 0||z.subtype===null).filter((z)=>{let Y=typeof z.text==="string"?z.text:"";return Y.length>0&&!Y.startsWith("<@")}).slice(0,3).reverse();if(Z.length===0)continue;console.log(`-- #${$} --------------------------------`);for(let z of Z){let Y=await s1(D,z,E),J=(typeof z.text==="string"?z.text:"").split(`
132
- `)[0]??"",Q=await Lu(D,J,E);console.log(` ${Y}: ${Q}`)}}}async function M7(D,u){let F=await U1(D,"to:me"),E=o(fu(F,["messages","matches"])).map(y).slice(0,u),C=new Map,B=[];for(let $ of E){let G=g1(AF($)),Z=B[B.length-1];if(Z?.label===G)Z.msgs.push($);else B.push({label:G,msgs:[$]})}for(let $=0;$<B.length;$++){let{label:G,msgs:Z}=B[$];if($>0)console.log("");console.log(` ${G}`),console.log(" ----------------------------");for(let z of[...Z].reverse()){let Y=y(z.channel),J=Y.is_im===!0,Q=typeof Y.name==="string"?Y.name:"dm",O;if(J&&Q.startsWith("U")){let V="@"+Q;if(!C.has(V)){let[,W]=await mu(D,Q);C.set(V,W)}O=`@${C.get(V)??Q}`}else if(J)O=`@${Q}`;else O=`#${Q}`;console.log(await NF(D,z,C,O))}}}async function K7(D,u,F,E,C="text"){let B=await _F(D),$=o(B.channels).map(y).filter((G)=>E||G.is_member===!0).filter((G)=>{if(!F)return!0;return(typeof G.name==="string"?G.name:"").toLowerCase().includes(F.toLowerCase())}).sort((G,Z)=>Number(Z.updated??0)-Number(G.updated??0)).slice(0,u);if(C==="jsonl"){for(let G of $)console.log(JSON.stringify(G));return}for(let G of $){let Z=String(G.id??""),z=typeof G.name==="string"?G.name:typeof G.user==="string"?G.user:Z,Y=G.is_im===!0,J=G.is_mpim===!0,Q=Y||J?"@":"#",O=G.is_member===!0?"":" (not joined)",V=typeof y(G.purpose).value==="string"?String(y(G.purpose).value):"",W=V?` ${V.split(`
133
- `)[0]?.slice(0,60)}`:"";console.log(`${Q}${z} ${Z}${O}${W}`)}}async function _7(D,u,F,E){let C=await M1(D,u,F);if(E){console.log(JSON.stringify(C,null,2));return}let B=o(fu(C,["messages","matches"])).map(y),$=new Map;for(let G of B){let Z=y(G.channel),z=Z.is_im===!0,Y=typeof Z.name==="string"?Z.name:"dm",J;if(z&&Y.startsWith("U")){let Q="@"+Y;if(!$.has(Q)){let[,O]=await mu(D,Y);$.set(Q,O)}J=`@${$.get(Q)??Y}`}else if(z)J=`@${Y}`;else J=`#${Y}`;console.log(await NF(D,G,$,J))}}async function j7(D,u,F,E){let C=Math.floor(Date.now()/1000)-u*86400,B=await _F(D),$=o(B.channels).map(y).filter((Y)=>Y.is_member===!0&&Y.is_im!==!0&&Y.is_mpim!==!0).filter((Y)=>{if(!E)return!0;return(typeof Y.name==="string"?Y.name:"").toLowerCase().includes(E.toLowerCase())}).sort((Y,J)=>Number(J.updated??0)-Number(Y.updated??0)),G=new Map,Z=0,z=0;for(let Y of $){let J=String(Y.id??""),Q=typeof Y.name==="string"?Y.name:J,O;try{O=await hu(D,J,F)}catch(W){console.error(` SKIP #${Q}: ${W.message}`);continue}let V=o(O.messages).map(y).filter((W)=>(W.subtype===void 0||W.subtype===null)&&AF(W)>=C);if(V.length===0)continue;z+=1,Z+=V.length,console.log(`## #${Q} (${V.length} msgs)
134
- `);for(let W of[...V].reverse()){let M=await s1(D,W,G),_=typeof W.text==="string"?W.text:"",k=gu(await Lu(D,_,G)).split(`
135
- `).join(" \u21B5 ");console.log(`[${k1(AF(W))}] ${M}: ${k}`)}console.log("")}console.error(`Dumped ${Z} messages across ${z} channels (cutoff: ${u}d)`)}function A7(D){let u=[];function F(E){if(typeof E==="string"){u.push(E);return}if(Array.isArray(E)){for(let C of E)F(C);return}if(E&&typeof E==="object"){let C=E;if(typeof C.text==="string"){u.push(C.text);return}if(Array.isArray(C.elements))F(C.elements);else if(Array.isArray(C.content))F(C.content)}}for(let E of D)F(E);return u.join("").trim()}async function a1(D,u,F){let E=new Map;return async(C)=>{if(!C)return"(unknown)";if(E.has(C))return E.get(C);try{let B=await b1(D,C,u),$=y(B.channel),G;if($.is_im===!0){let Z=typeof $.user==="string"?$.user:"";if(!Z||Z===F)G="@self";else{let[z]=await mu(D,Z);G=`@${z}`}}else G=`#${typeof $.name==="string"?$.name:C}`;return E.set(C,G),G}catch{return C}}}function p0(D){let u=y(o(D.destinations)[0]);return String(u.channel_id??D.channel_id??D.channel??"")}function LF(D){return A7(o(D.blocks))||(typeof D.text==="string"?D.text:"(no text)")}async function L7(D,u,F=!1){let E=await cu(D,u),C=o(E.drafts??E.messages??[]).map(y).filter((z)=>z.is_deleted!==!0),B=F?C:C.filter((z)=>z.is_sent!==!0);if(B.length===0){console.log(F?"No drafts.":"No pending drafts. Run with --all to include sent.");return}let $="";try{({userId:$}=await P0(D,u))}catch{}let G=await a1(D,u,$),Z=new Map;for(let z of B){let Y=p0(z),J=LF(z),Q=Number(z.date_created??z.date_create??0),O=Q?I0(Q):"?",V=await G(Y),W=typeof z.id==="string"?z.id:"",M=z.is_sent===!0?" [SENT]":"",_=gu(await Lu(D,J,Z));console.log(`-- ${W} ${V} [${O}]${M}`);for(let N of _.split(`
136
- `))console.log(` ${N}`)}}async function N7(D,u,F){let E=await cu(D,u),C=o(E.drafts).map(y).find((V)=>String(V.id)===F);if(!C)console.error(`Draft not found: ${F}`),process.exit(1);let B="";try{({userId:B}=await P0(D,u))}catch{}let $=await a1(D,u,B),G=p0(C),Z=LF(C),z=Number(C.date_created??0),Y=String(C.last_updated_ts??"?"),J=await $(G),O=gu(await Lu(D,Z,new Map));console.log(`id: ${C.id}`),console.log(`channel: ${J} (${G})`),console.log(`created: ${z?I0(z):"?"}`),console.log(`updated: ${I0(Number(Y.split(".")[0]))}`),console.log(`status: ${C.is_sent===!0?"sent":"pending"}`),console.log("---"),console.log(O)}function mD(...D){return W7(D.join(`
137
- `)).slice(0,4)}var T7={"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 i1(D){let u=D instanceof Error?D.message:String(D),F=u.match(/Slack error on (\S+): (\w+)/);if(!F)return u;let[,E,C]=F;switch(C){case"missing_scope":return`Error: token lacks the ${T7[E]??"the required"} scope (needed for ${E}). Add it to your Slack App's User Token Scopes (or Bot Token Scopes if you use a bot token / --as-bot) \u2014 it must be on the token type the CLI actually uses \u2014 then reinstall to the workspace.`;case"invalid_name":return"Error: not a valid emoji shortcode \u2014 use the name without colons (e.g. white_check_mark), and make sure it exists in the workspace.";case"already_reacted":return"Error: you've already added that reaction to the message.";case"no_reaction":return"Error: that reaction isn't on the message \u2014 nothing to remove.";case"message_not_found":return"Error: no message found at that timestamp in the channel \u2014 check the target ts/permalink.";case"channel_not_found":return"Error: channel not found \u2014 check the target.";default:return u}}function fD(D,u,F){for(let E of F)console.log(E);if(D!==void 0)console.error(`Code mismatch (got ${D}, expected ${u})`);console.error(`Rerun with --code=${u}`),process.exit(1)}function m0(D){let u=pu(D);if(u)return u.ts?{ref:u.channel,ts:u.ts}:{ref:u.channel};if(D.startsWith("#")||D.startsWith("@")){let F=D.indexOf(":");if(F>0){let E=D.slice(F+1);if(/^\d{10}\.\d{6}$/.test(E))return{ref:D.slice(0,F),ts:E};if(/^\d{4}-\d{2}-\d{2}T/.test(E))return{ref:D.slice(0,F),ts:h0(E)}}}return{ref:D}}function y0(D){let u=pu(D);if(u){let E=u.threadTs??u.ts;return E?{ref:u.channel,threadTs:E}:{ref:u.channel}}let F=D.indexOf(":");if(F>0){let E=D.slice(F+1);if(/^\d{10}\.\d{6}$/.test(E))return{ref:D.slice(0,F),threadTs:E};if(/^\d{4}-\d{2}-\d{2}T/.test(E))return{ref:D.slice(0,F),threadTs:h0(E)}}return{ref:D}}async function e1(D,u,F){let E=F;if(!F.startsWith("#")&&!F.startsWith("@"))try{let C=y(await S0(D,u)),B=y(C.channel);if(B.is_im===!0){let $=typeof B.user==="string"?B.user:"";E=$?`@${await yu(D,$)}`:u}else E=typeof B.name==="string"?`#${B.name}`:u}catch{E=u}return E===u?u:`${E} (${u})`}async function b0(D,u,F=60){let E=typeof u.user==="string"?await yu(D,u.user):typeof u.username==="string"?u.username:"?",C=(typeof u.text==="string"?u.text:"").split(`
138
- `)[0]??"",B=C.length>F?`${C.slice(0,F)}\u2026`:C,$=typeof u.ts==="string"?u.ts:"";return`${$?f0($).slice(0,16).replace("T"," "):""} @${E}${B?`: ${B}`:""}`}async function R7(D,u,F){let E=F.find((C)=>String(C.ts)===u)??F[0];if(!E)return u;return b0(D,E,40)}function n1(D){return D.toLowerCase().replace(/<[@#!][^>]+>/g," ").replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function S7(D,u){let F=n1(D),E=n1(u);if(!F||!E)return 0;if(F===E)return 1;let C=(z)=>{let Y=new Map;for(let J=0;J<z.length-1;J++){let Q=z.slice(J,J+2);Y.set(Q,(Y.get(Q)??0)+1)}return Y},B=C(F),$=C(E);if(B.size===0||$.size===0)return 0;let G=0;for(let[z,Y]of B){let J=$.get(z);if(J)G+=Math.min(Y,J)}let Z=l1(B)+l1($);return Z===0?0:2*G/Z}function l1(D){let u=0;for(let F of D.values())u+=F;return u}async function P7(D,u){let{ref:F,ts:E}=m0(u.target);if(!E)console.error("Error: target must embed a message ts (e.g. #chan:2026-05-11T06:01:04.000100 or a Slack permalink URL)"),process.exit(2);let C;if(u.channelId)C=u.channelId;else C=await KD(D,F);let B=await Au(D,C,E,1),G=o(B.messages).map(y).find((Q)=>String(Q.ts)===E);if(!G)console.error(`Message not found at ts=${E} in channel ${C}`),process.exit(1);let Z=typeof G.text==="string"?G.text:"",z=u.mentions?await x0(D,u.newText,C):u.newText,Y=mD(Z,z);if(u.code!==Y)fD(u.code,Y,["--- Original message -------------------------",...Z.split(`
139
- `).map((Q)=>` ${Q}`),"--- Replacing with ---------------------------",...z.split(`
140
- `).map((Q)=>` ${Q}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let J=await N1(D,C,E,z);console.log(`\u2713 Edited (ts: ${J})`)}async function w7(D,u){let{ref:F,ts:E}=m0(u.target);if(!E)console.error("Error: target must embed a message ts (e.g. #chan:2026-05-11T06:01:04.000100 or a Slack permalink URL)"),process.exit(2);let C;if(u.channelId)C=u.channelId;else C=await KD(D,F);let B=await Au(D,C,E,1),G=o(B.messages).map(y).find((Y)=>String(Y.ts)===E);if(!G)console.error(`Message not found at ts=${E} in channel ${C}`),process.exit(1);let Z=typeof G.text==="string"?G.text:"",z=mD(C,E,Z);if(u.code!==z){let Y=await e1(D,C,F);fD(u.code,z,["--- Deleting message -------------------------",` \u2192 ${Y} at ${f0(E)}`,...Z.split(`
141
- `).map((J)=>` ${J}`),"---------------------------------------------"])}await T1(D,C,E),console.log(`\u2713 Deleted (ts: ${E})`)}async function x7(D,u){let{ref:F,ts:E}=m0(u.target);if(!E)console.error("Error: target must embed a message ts (e.g. #chan:2026-05-11T06:01:04.000100 or a Slack permalink URL)"),process.exit(2);let C=u.emoji.replace(/^:|:$/g,""),B;if(u.channelId)B=u.channelId;else B=await KD(D,F);if(u.remove)await S1(D,B,E,C),console.log(`\u2713 Removed :${C}: (ts: ${E})`);else await R1(D,B,E,C),console.log(`\u2713 Reacted :${C}: (ts: ${E})`)}async function I7(D,u){if(!u.startsWith("@"))return!1;let F=u.slice(1).toLowerCase().replace(/[^a-z0-9]/g,"");if(F==="me"||F==="you")return!0;try{let C=((await V1(D)).user??"").toLowerCase().replace(/[^a-z0-9]/g,"");return C!==""&&C===F}catch{return!1}}async function b7(D,u){let{ref:F,threadTs:E}=y0(u.target);if(!u.asBot&&!u.channelId&&!u.userId&&await I7(D,F))console.error(`Warning: "${F}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
142
- `+` To reach yourself with a notification, send as the bot: slack send '${F}' '...' --as-bot`);let C;if(u.channelId)C=u.channelId;else if(u.userId)C=await vu(D,u.userId);else C=await KD(D,F);let B=u.mentions?await x0(u.mentionToken??D,u.message,C):u.message;try{for(let Q of await c1(u.mentionToken??D,B))console.error(`\u26A0 possible untagged mention: ${Q.surface} \u2014 @${Q.display} won't be notified (did you mean <@${Q.userId}>?)`)}catch{}let $="",G="?",Z=[];if(E)try{let Q=await Au(D,C,E,100);Z=o(Q.messages).map(y);let O=Z[Z.length-1];$=typeof O?.text==="string"?O.text:""}catch{}else try{let Q=await hu(D,C,1),O=o(Q.messages).map(y).filter((V)=>V.subtype===void 0||V.subtype===null)[0];$=typeof O?.text==="string"?O.text:"",G=typeof O?.user==="string"?await yu(D,O.user):typeof O?.username==="string"?O.username:"?"}catch{}if(E&&Z.length){let Q={sim:0,msg:null};for(let O of Z){let V=typeof O.text==="string"?O.text:"";if(!V)continue;let W=S7(B,V);if(W>Q.sim)Q={sim:W,msg:O}}if(Q.msg&&Q.sim>=0.82){let O=Math.round(Q.sim*100);console.error(`\u26A0 possible duplicate: ${O}% similar to an existing thread message \u2014 ${await b0(D,Q.msg)}`)}}let z=mD(C,E??"",$,B);if(u.code!==z){let Q=await e1(D,C,F);if(E){let O=await R7(D,E,Z),V=Z.slice(-3),W=V.length?await Promise.all(V.map(async(M)=>` ${await b0(D,M)}`)):[" (thread context unavailable)"];fD(u.code,z,["--- Recent messages in thread ----------------",...W,"--- Sending ----------------------------------",` \u2192 ${Q} thread of ${O} \u2014 THREAD REPLY`,` Message: ${B}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}else fD(u.code,z,["--- Last message in channel ------------------",` ${G}: ${$.split(`
143
- `)[0]?.slice(0,100)??"(empty)"}`,"--- Sending ----------------------------------",` \u2192 ${Q} \u2014 NEW top-level message`,` Message: ${B}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}let Y=await K1(D,C,B,E,u.broadcast),J="";try{J=await L1(D,C,Y)}catch{}if(J)console.log(`\u2713 Sent: ${J}`);else console.log(`\u2713 Sent (ts: ${Y})`);if(u.asBot&&C.startsWith("D"))try{let Q=await V0(D);if(!Q.ok)for(let O of H0(Q,!0))console.error(O);else{let O=Q.appId?`https://api.slack.com/apps/${Q.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${u.target} can't reply (app messaging may be off), enable Messages Tab: ${O} \u2192 App Home.`)}}catch{}}async function f7(D){let u=await V0(D);for(let F of H0(u,!1))console.log(F);if(!u.ok)process.exit(1)}function h7(D){if(/^\d{10,}$/.test(D))return parseInt(D,10);let u=new Date(D.replace(" ","T"));if(isNaN(u.getTime()))throw Error(`Cannot parse time: ${D}`);return Math.floor(u.getTime()/1000)}async function v7(D,u){let{ref:F,threadTs:E}=y0(u.target),C;if(u.channelId)C=u.channelId;else if(u.userId)C=await vu(D,u.userId);else C=await KD(D,F);let B=h7(u.at),$=new Date(B*1000).toISOString(),G=mD(C,u.message,String(B));if(u.code!==G)fD(u.code,G,["--- Scheduling message -----------------------",` To: ${F}${E?` (thread ${E})`:""}`,` At: ${$} (Unix: ${B})`,` Message: ${u.message}`,"---------------------------------------------"]);let Z=await _1(D,C,u.message,B,E);console.log(`\u2713 Scheduled (id: ${Z}, at: ${$})`)}async function p7(D,u,F){let E;if(F)E=F;else if(u)E=await KD(D,u);let B=(await j1(D,E)).scheduled_messages??[];if(B.length===0){console.log("(no scheduled messages)");return}for(let $ of B){let G=new Date($.post_at*1000).toISOString();console.log(`${$.id} ${G} [${$.channel_id}] ${$.text.split(`
144
- `)[0]?.slice(0,80)??""}`)}}async function m7(D,u){let F;if(u.channelId)F=u.channelId;else F=await KD(D,u.target);let E=mD(F,u.id);if(u.code!==E)fD(u.code,E,["--- Deleting scheduled message ---------------",` Channel: ${u.target}`,` ID: ${u.id}`,"---------------------------------------------"]);await A1(D,F,u.id),console.log(`\u2713 Deleted scheduled message ${u.id}`)}async function y7(D,u){let{statSync:F,existsSync:E}=await import("fs"),{basename:C}=await import("path");for(let Q of u.filePaths)if(!E(Q))console.error(`Error: file not found: ${Q}`),process.exit(1);let{ref:B,threadTs:$}=y0(u.target),G;if(u.channelId)G=u.channelId;else if(u.userId)G=await vu(D,u.userId);else G=await KD(D,B);let Z=u.filePaths.length>1,z=u.filePaths.map((Q)=>{let O=C(Q),V=Z?O:u.title??O;return{fp:Q,filename:O,title:V,sizeFmt:v0(F(Q).size)}}),Y=mD(G,...z.flatMap((Q)=>[Q.fp,Q.title]));if(u.code!==Y){let Q=` To: ${B}${$?` (thread ${$})`:""}`,O=Z?[`--- Uploading ${z.length} files ------------------------`,Q,...z.map((V)=>` ${V.filename} (${V.sizeFmt})`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]:["--- Uploading file ---------------------------",Q,` File: ${z[0].fp}`,` Title: ${z[0].title}`,` Size: ${z[0].sizeFmt}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];fD(u.code,Y,O)}let J=z.length;for(let Q=0;Q<J;Q++){let O=z[Q],V={title:O.title};if($!==void 0)V.threadTs=$;if(u.comment!==void 0&&Q===0)V.initialComment=u.comment;let{fileId:W,permalink:M}=await v1(D,G,O.fp,V),_=J>1?`[${Q+1}/${J}] `:"";console.log(`${_}\u2713 Uploaded (file_id: ${W}${M?`, url: ${M}`:""})`)}}function c7(D){if(/^F[A-Z0-9]+$/i.test(D))return D;return D.match(/\/files\/[A-Za-z0-9]+\/(F[A-Za-z0-9]+)/)?.[1]}async function g7(D,u,F,E){let C=c7(F);if(!C)throw Error(`Not a file ID or file permalink: ${F}
145
- `+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let B=y(await H1(D,C,u)),$=y(B.file),G=typeof $.name==="string"?$.name:typeof $.title==="string"?$.title:C,Z=typeof $.url_private_download==="string"?$.url_private_download:typeof $.url_private==="string"?$.url_private:"";if(!Z)throw Error(`files.info returned no download URL for ${C}`);let z={Authorization:`Bearer ${D}`};if(u)z.Cookie=`d=${u}`;let Y=await fetch(Z,{headers:z});if(!Y.ok)throw Error(`Download failed: HTTP ${Y.status} ${Y.statusText}`);let J=Buffer.from(await Y.arrayBuffer()),{statSync:Q,existsSync:O}=await import("fs"),{basename:V}=await import("path"),W=E??G;if(E&&O(E)&&Q(E).isDirectory())W=tD(E,V(G));o1(W,J),console.log(`\u2713 Downloaded ${G} (${v0(J.length)}) \u2192 ${W}`)}async function k7(){Y7();let D=(F)=>Z0(F.workspace),u=(F)=>P8(F.workspace);await _8(cF(process.argv)).scriptName("slack").option("workspace",{alias:"w",type:"string",describe:"Workspace name"}).middleware(async(F)=>{let E=String((F._??[])[0]??"");if(!E||E==="auth"||E==="login")return;try{Z0(F.workspace)}catch(C){if((C instanceof Error?C.message:String(C)).startsWith("No profiles configured"))console.log(`No workspace configured. Let's set that up:
146
- `),await UF(),process.exit(0);throw C}},!0).command(["read [target]","msgs [target]"],"Browse messages",(F)=>F.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"}),async(F)=>{let E=D(F),C=F.json?"jsonl":F.format;if(F.target)await H7(E,F.target,F.limit,C);else await U7(E)}).command("thread <target> <ts>","Show thread messages",(F)=>F.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(F)=>{let E=F.json?"jsonl":F.format;await q7(D(F),F.target,F.ts,F.limit,E)}).command(["channel","channels","ch"],"Channel commands",(F)=>F.command(["ls","list"],"List channels",(E)=>E.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(E)=>{await K7(D(E),E.limit,E.filter,E.all,E.json?"jsonl":E.format)}).command("get <channel>","Show channel details",(E)=>E.positional("channel",{type:"string",demandOption:!0,describe:"#name or channel ID"}),async(E)=>{let C=D(E),B=E.channel,$=B.startsWith("#")||B.startsWith("@")||B.startsWith("C")||B.startsWith("G")||B.startsWith("D")?B:`#${B}`,G=await KD(C,$),Z=y(await S0(C,G)),z=y(Z.channel),Y=typeof z.name==="string"?z.name:G,Q=z.is_im===!0?"@":"#",O=String(y(z.purpose).value??""),V=String(y(z.topic).value??""),W=z.num_members??z.member_count??"";if(console.log(`${Q}${Y} ${G}`),V)console.log(`topic: ${V}`);if(O)console.log(`purpose: ${O}`);if(W)console.log(`members: ${W}`);console.log(`private: ${z.is_private===!0}`)}).command(["create <name>","new <name>"],"Create a channel (confirm-hash safety gate)",(E)=>E.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(E)=>{let C=D(E),B=E.name.replace(/^#/,"").toLowerCase(),$=E.private===!0,G=E.invite.filter(Boolean),Z=mD(B,String($),G.join(","));if(E.code!==Z)fD(E.code,Z,["--- Creating channel -------------------------",` name: ${$?"\uD83D\uDD12 ":"#"}${B}`,` private: ${$}`,...G.length?[` invite: ${G.join(", ")}`]:[],"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let z;try{z=await P1(C,B,$)}catch(Y){console.error(Y instanceof Error?Y.message:String(Y)),process.exit(1)}if(console.log(`\u2713 Created ${$?"\uD83D\uDD12 ":"#"}${z.name} (${z.id})`),G.length){let Y=[];for(let J of G)try{Y.push(J.startsWith("U")||J.startsWith("W")?J:await T0(C,J))}catch(Q){console.error(` ! could not resolve ${J}: ${Q instanceof Error?Q.message:String(Q)}`)}if(Y.length)try{await w1(C,z.id,Y),console.log(`\u2713 Invited ${Y.length} member${Y.length===1?"":"s"}`)}catch(J){console.error(` ! invite failed: ${J instanceof Error?J.message:String(J)}`)}}}).demandCommand(1,"").showHelpOnFail(!0)).command(["user","usr"],"User commands",(F)=>F.command(["ls","list"],"List workspace members",(E)=>E.option("limit",{alias:"n",type:"number",default:200}).option("filter",{alias:"f",type:"string"}).option("format",{type:"string",choices:["text","jsonl","yaml"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(E)=>{let C=E.json?"jsonl":E.format,B=await R0(D(E)),$=E.filter?.toLowerCase(),G=o(B.members).map(y).filter((z)=>z.deleted!==!0&&z.is_bot!==!0&&String(z.id)!=="USLACKBOT").filter((z)=>{if(!$)return!0;let Y=String(z.name??"").toLowerCase(),J=String(y(z.profile).real_name??"").toLowerCase(),Q=String(y(z.profile).email??"").toLowerCase();return Y.includes($)||J.includes($)||Q.includes($)}).slice(0,E.limit);if(C==="jsonl"){for(let z of G)console.log(JSON.stringify(z));return}if(C==="yaml"){for(let z of G){let Y=function(J,Q=""){if(J===null)return"null";if(typeof J==="string")return J.includes(`
138
+ ${Q}`:"")+O;return`${B} ${J}: ${Y}${V}`}function v0(D){return D<1024?`${D} B`:D<1048576?`${(D/1024).toFixed(1)} KB`:`${(D/1048576).toFixed(1)} MB`}function V7(D){return o(D.files).map(m).map((u)=>({id:u.id??null,name:u.name??u.title??null,mimetype:u.mimetype??null,size:u.size??null,url_private_download:u.url_private_download??u.url_private??null,permalink:u.permalink??null}))}function r1(D){let u=V7(D);return{ts:D.ts??null,user:D.user??null,username:D.username??null,bot_id:D.bot_id??null,thread_ts:D.thread_ts??null,text:typeof D.text==="string"?D.text:"",...u.length>0?{files:u}:{}}}async function H7(D,u,F,E="text"){let C=yu(u),B=await KD(D,u),$=new Map,z=await(async()=>{if(C?.threadTs){let Y=await Au(D,B,C.threadTs,F);return o(Y.messages).map(m)}let Z=await vu(D,B,F);return o(Z.messages).map(m).reverse()})();if(E==="jsonl"){for(let Z of z)console.log(JSON.stringify(r1(Z)));return}for(let Z of z)console.log(await NF(D,Z,$))}async function q7(D,u,F,E,C="text"){let B=await KD(D,u),$=await Au(D,B,O7(F),E),G=o($.messages).map(m);if(C==="jsonl"){for(let Z of G)console.log(JSON.stringify(r1(Z)));return}let z=new Map;for(let Z of G)console.log(await NF(D,Z,z))}async function U7(D){let u=await _F(D),F=o(u.channels).map(m).filter((C)=>C.is_member===!0).sort((C,B)=>Number(B.updated??0)-Number(C.updated??0)).slice(0,10),E=new Map;for(let C of F){let B=String(C.id??""),$=typeof C.name==="string"?C.name:typeof C.user==="string"?C.user:B,G=await vu(D,B,5),z=o(G.messages).map(m).filter((Z)=>Z.subtype===void 0||Z.subtype===null).filter((Z)=>{let Y=typeof Z.text==="string"?Z.text:"";return Y.length>0&&!Y.startsWith("<@")}).slice(0,3).reverse();if(z.length===0)continue;console.log(`-- #${$} --------------------------------`);for(let Z of z){let Y=await s1(D,Z,E),J=(typeof Z.text==="string"?Z.text:"").split(`
139
+ `)[0]??"",Q=await Lu(D,J,E);console.log(` ${Y}: ${Q}`)}}}async function M7(D,u){let F=await U1(D,"to:me"),E=o(hu(F,["messages","matches"])).map(m).slice(0,u),C=new Map,B=[];for(let $ of E){let G=g1(AF($)),z=B[B.length-1];if(z?.label===G)z.msgs.push($);else B.push({label:G,msgs:[$]})}for(let $=0;$<B.length;$++){let{label:G,msgs:z}=B[$];if($>0)console.log("");console.log(` ${G}`),console.log(" ----------------------------");for(let Z of[...z].reverse()){let Y=m(Z.channel),J=Y.is_im===!0,Q=typeof Y.name==="string"?Y.name:"dm",O;if(J&&Q.startsWith("U")){let V="@"+Q;if(!C.has(V)){let[,W]=await mu(D,Q);C.set(V,W)}O=`@${C.get(V)??Q}`}else if(J)O=`@${Q}`;else O=`#${Q}`;console.log(await NF(D,Z,C,O))}}}async function K7(D,u,F,E,C="text"){let B=await _F(D),$=o(B.channels).map(m).filter((G)=>E||G.is_member===!0).filter((G)=>{if(!F)return!0;return(typeof G.name==="string"?G.name:"").toLowerCase().includes(F.toLowerCase())}).sort((G,z)=>Number(z.updated??0)-Number(G.updated??0)).slice(0,u);if(C==="jsonl"){for(let G of $)console.log(JSON.stringify(G));return}for(let G of $){let z=String(G.id??""),Z=typeof G.name==="string"?G.name:typeof G.user==="string"?G.user:z,Y=G.is_im===!0,J=G.is_mpim===!0,Q=Y||J?"@":"#",O=G.is_member===!0?"":" (not joined)",V=typeof m(G.purpose).value==="string"?String(m(G.purpose).value):"",W=V?` ${V.split(`
140
+ `)[0]?.slice(0,60)}`:"";console.log(`${Q}${Z} ${z}${O}${W}`)}}async function _7(D,u,F,E){let C=await M1(D,u,F);if(E){console.log(JSON.stringify(C,null,2));return}let B=o(hu(C,["messages","matches"])).map(m),$=new Map;for(let G of B){let z=m(G.channel),Z=z.is_im===!0,Y=typeof z.name==="string"?z.name:"dm",J;if(Z&&Y.startsWith("U")){let Q="@"+Y;if(!$.has(Q)){let[,O]=await mu(D,Y);$.set(Q,O)}J=`@${$.get(Q)??Y}`}else if(Z)J=`@${Y}`;else J=`#${Y}`;console.log(await NF(D,G,$,J))}}async function j7(D,u,F,E){let C=Math.floor(Date.now()/1000)-u*86400,B=await _F(D),$=o(B.channels).map(m).filter((Y)=>Y.is_member===!0&&Y.is_im!==!0&&Y.is_mpim!==!0).filter((Y)=>{if(!E)return!0;return(typeof Y.name==="string"?Y.name:"").toLowerCase().includes(E.toLowerCase())}).sort((Y,J)=>Number(J.updated??0)-Number(Y.updated??0)),G=new Map,z=0,Z=0;for(let Y of $){let J=String(Y.id??""),Q=typeof Y.name==="string"?Y.name:J,O;try{O=await vu(D,J,F)}catch(W){console.error(` SKIP #${Q}: ${W.message}`);continue}let V=o(O.messages).map(m).filter((W)=>(W.subtype===void 0||W.subtype===null)&&AF(W)>=C);if(V.length===0)continue;Z+=1,z+=V.length,console.log(`## #${Q} (${V.length} msgs)
141
+ `);for(let W of[...V].reverse()){let M=await s1(D,W,G),_=typeof W.text==="string"?W.text:"",k=ku(await Lu(D,_,G)).split(`
142
+ `).join(" \u21B5 ");console.log(`[${k1(AF(W))}] ${M}: ${k}`)}console.log("")}console.error(`Dumped ${z} messages across ${Z} channels (cutoff: ${u}d)`)}function A7(D){let u=[];function F(E){if(typeof E==="string"){u.push(E);return}if(Array.isArray(E)){for(let C of E)F(C);return}if(E&&typeof E==="object"){let C=E;if(typeof C.text==="string"){u.push(C.text);return}if(Array.isArray(C.elements))F(C.elements);else if(Array.isArray(C.content))F(C.content)}}for(let E of D)F(E);return u.join("").trim()}async function a1(D,u,F){let E=new Map;return async(C)=>{if(!C)return"(unknown)";if(E.has(C))return E.get(C);try{let B=await b1(D,C,u),$=m(B.channel),G;if($.is_im===!0){let z=typeof $.user==="string"?$.user:"";if(!z||z===F)G="@self";else{let[Z]=await mu(D,z);G=`@${Z}`}}else G=`#${typeof $.name==="string"?$.name:C}`;return E.set(C,G),G}catch{return C}}}function p0(D){let u=m(o(D.destinations)[0]);return String(u.channel_id??D.channel_id??D.channel??"")}function LF(D){return A7(o(D.blocks))||(typeof D.text==="string"?D.text:"(no text)")}async function L7(D,u,F=!1){let E=await gu(D,u),C=o(E.drafts??E.messages??[]).map(m).filter((Z)=>Z.is_deleted!==!0),B=F?C:C.filter((Z)=>Z.is_sent!==!0);if(B.length===0){console.log(F?"No drafts.":"No pending drafts. Run with --all to include sent.");return}let $="";try{({userId:$}=await P0(D,u))}catch{}let G=await a1(D,u,$),z=new Map;for(let Z of B){let Y=p0(Z),J=LF(Z),Q=Number(Z.date_created??Z.date_create??0),O=Q?I0(Q):"?",V=await G(Y),W=typeof Z.id==="string"?Z.id:"",M=Z.is_sent===!0?" [SENT]":"",_=ku(await Lu(D,J,z));console.log(`-- ${W} ${V} [${O}]${M}`);for(let N of _.split(`
143
+ `))console.log(` ${N}`)}}async function N7(D,u,F){let E=await gu(D,u),C=o(E.drafts).map(m).find((V)=>String(V.id)===F);if(!C)console.error(`Draft not found: ${F}`),process.exit(1);let B="";try{({userId:B}=await P0(D,u))}catch{}let $=await a1(D,u,B),G=p0(C),z=LF(C),Z=Number(C.date_created??0),Y=String(C.last_updated_ts??"?"),J=await $(G),O=ku(await Lu(D,z,new Map));console.log(`id: ${C.id}`),console.log(`channel: ${J} (${G})`),console.log(`created: ${Z?I0(Z):"?"}`),console.log(`updated: ${I0(Number(Y.split(".")[0]))}`),console.log(`status: ${C.is_sent===!0?"sent":"pending"}`),console.log("---"),console.log(O)}function yD(...D){return W7(D.join(`
144
+ `)).slice(0,4)}var T7={"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 i1(D){let u=D instanceof Error?D.message:String(D),F=u.match(/Slack error on (\S+): (\w+)/);if(!F)return u;let[,E,C]=F;switch(C){case"missing_scope":return`Error: token lacks the ${T7[E]??"the required"} scope (needed for ${E}). Add it to your Slack App's User Token Scopes (or Bot Token Scopes if you use a bot token / --as-bot) \u2014 it must be on the token type the CLI actually uses \u2014 then reinstall to the workspace.`;case"invalid_name":return"Error: not a valid emoji shortcode \u2014 use the name without colons (e.g. white_check_mark), and make sure it exists in the workspace.";case"already_reacted":return"Error: you've already added that reaction to the message.";case"no_reaction":return"Error: that reaction isn't on the message \u2014 nothing to remove.";case"message_not_found":return"Error: no message found at that timestamp in the channel \u2014 check the target ts/permalink.";case"channel_not_found":return"Error: channel not found \u2014 check the target.";default:return u}}function fD(D,u,F){for(let E of F)console.log(E);if(D!==void 0)console.error(`Code mismatch (got ${D}, expected ${u})`);console.error(`Rerun with --code=${u}`),process.exit(1)}function y0(D){let u=yu(D);if(u)return u.ts?{ref:u.channel,ts:u.ts}:{ref:u.channel};if(D.startsWith("#")||D.startsWith("@")){let F=D.indexOf(":");if(F>0){let E=D.slice(F+1);if(/^\d{10}\.\d{6}$/.test(E))return{ref:D.slice(0,F),ts:E};if(/^\d{4}-\d{2}-\d{2}T/.test(E))return{ref:D.slice(0,F),ts:h0(E)}}}return{ref:D}}function m0(D){let u=yu(D);if(u){let E=u.threadTs??u.ts;return E?{ref:u.channel,threadTs:E}:{ref:u.channel}}let F=D.indexOf(":");if(F>0){let E=D.slice(F+1);if(/^\d{10}\.\d{6}$/.test(E))return{ref:D.slice(0,F),threadTs:E};if(/^\d{4}-\d{2}-\d{2}T/.test(E))return{ref:D.slice(0,F),threadTs:h0(E)}}return{ref:D}}async function e1(D,u,F){let E=F;if(!F.startsWith("#")&&!F.startsWith("@"))try{let C=m(await S0(D,u)),B=m(C.channel);if(B.is_im===!0){let $=typeof B.user==="string"?B.user:"";E=$?`@${await cu(D,$)}`:u}else E=typeof B.name==="string"?`#${B.name}`:u}catch{E=u}return E===u?u:`${E} (${u})`}async function b0(D,u,F=60){let E=typeof u.user==="string"?await cu(D,u.user):typeof u.username==="string"?u.username:"?",C=(typeof u.text==="string"?u.text:"").split(`
145
+ `)[0]??"",B=C.length>F?`${C.slice(0,F)}\u2026`:C,$=typeof u.ts==="string"?u.ts:"";return`${$?f0($).slice(0,16).replace("T"," "):""} @${E}${B?`: ${B}`:""}`}async function R7(D,u,F){let E=F.find((C)=>String(C.ts)===u)??F[0];if(!E)return u;return b0(D,E,40)}function n1(D){return D.toLowerCase().replace(/<[@#!][^>]+>/g," ").replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function S7(D,u){let F=n1(D),E=n1(u);if(!F||!E)return 0;if(F===E)return 1;let C=(Z)=>{let Y=new Map;for(let J=0;J<Z.length-1;J++){let Q=Z.slice(J,J+2);Y.set(Q,(Y.get(Q)??0)+1)}return Y},B=C(F),$=C(E);if(B.size===0||$.size===0)return 0;let G=0;for(let[Z,Y]of B){let J=$.get(Z);if(J)G+=Math.min(Y,J)}let z=l1(B)+l1($);return z===0?0:2*G/z}function l1(D){let u=0;for(let F of D.values())u+=F;return u}async function P7(D,u){let{ref:F,ts:E}=y0(u.target);if(!E)console.error("Error: target must embed a message ts (e.g. #chan:2026-05-11T06:01:04.000100 or a Slack permalink URL)"),process.exit(2);let C;if(u.channelId)C=u.channelId;else C=await KD(D,F);let B=await Au(D,C,E,1),G=o(B.messages).map(m).find((Q)=>String(Q.ts)===E);if(!G)console.error(`Message not found at ts=${E} in channel ${C}`),process.exit(1);let z=typeof G.text==="string"?G.text:"",Z=u.mentions?await x0(D,u.newText,C):u.newText,Y=yD(z,Z);if(u.code!==Y)fD(u.code,Y,["--- Original message -------------------------",...z.split(`
146
+ `).map((Q)=>` ${Q}`),"--- Replacing with ---------------------------",...Z.split(`
147
+ `).map((Q)=>` ${Q}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let J=await N1(D,C,E,Z);console.log(`\u2713 Edited (ts: ${J})`)}async function w7(D,u){let{ref:F,ts:E}=y0(u.target);if(!E)console.error("Error: target must embed a message ts (e.g. #chan:2026-05-11T06:01:04.000100 or a Slack permalink URL)"),process.exit(2);let C;if(u.channelId)C=u.channelId;else C=await KD(D,F);let B=await Au(D,C,E,1),G=o(B.messages).map(m).find((Y)=>String(Y.ts)===E);if(!G)console.error(`Message not found at ts=${E} in channel ${C}`),process.exit(1);let z=typeof G.text==="string"?G.text:"",Z=yD(C,E,z);if(u.code!==Z){let Y=await e1(D,C,F);fD(u.code,Z,["--- Deleting message -------------------------",` \u2192 ${Y} at ${f0(E)}`,...z.split(`
148
+ `).map((J)=>` ${J}`),"---------------------------------------------"])}await T1(D,C,E),console.log(`\u2713 Deleted (ts: ${E})`)}async function x7(D,u){let{ref:F,ts:E}=y0(u.target);if(!E)console.error("Error: target must embed a message ts (e.g. #chan:2026-05-11T06:01:04.000100 or a Slack permalink URL)"),process.exit(2);let C=u.emoji.replace(/^:|:$/g,""),B;if(u.channelId)B=u.channelId;else B=await KD(D,F);if(u.remove)await S1(D,B,E,C),console.log(`\u2713 Removed :${C}: (ts: ${E})`);else await R1(D,B,E,C),console.log(`\u2713 Reacted :${C}: (ts: ${E})`)}async function I7(D,u){if(!u.startsWith("@"))return!1;let F=u.slice(1).toLowerCase().replace(/[^a-z0-9]/g,"");if(F==="me"||F==="you")return!0;try{let C=((await V1(D)).user??"").toLowerCase().replace(/[^a-z0-9]/g,"");return C!==""&&C===F}catch{return!1}}async function b7(D,u){let{ref:F,threadTs:E}=m0(u.target);if(!u.asBot&&!u.channelId&&!u.userId&&await I7(D,F))console.error(`Warning: "${F}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
149
+ `+` To reach yourself with a notification, send as the bot: slack send '${F}' '...' --as-bot`);let C;if(u.channelId)C=u.channelId;else if(u.userId)C=await pu(D,u.userId);else C=await KD(D,F);let B=u.mentions?await x0(u.mentionToken??D,u.message,C):u.message;try{for(let Q of await c1(u.mentionToken??D,B))console.error(`\u26A0 possible untagged mention: ${Q.surface} \u2014 @${Q.display} won't be notified (did you mean <@${Q.userId}>?)`)}catch{}let $="",G="?",z=[];if(E)try{let Q=await Au(D,C,E,100);z=o(Q.messages).map(m);let O=z[z.length-1];$=typeof O?.text==="string"?O.text:""}catch{}else try{let Q=await vu(D,C,1),O=o(Q.messages).map(m).filter((V)=>V.subtype===void 0||V.subtype===null)[0];$=typeof O?.text==="string"?O.text:"",G=typeof O?.user==="string"?await cu(D,O.user):typeof O?.username==="string"?O.username:"?"}catch{}if(E&&z.length){let Q={sim:0,msg:null};for(let O of z){let V=typeof O.text==="string"?O.text:"";if(!V)continue;let W=S7(B,V);if(W>Q.sim)Q={sim:W,msg:O}}if(Q.msg&&Q.sim>=0.82){let O=Math.round(Q.sim*100);console.error(`\u26A0 possible duplicate: ${O}% similar to an existing thread message \u2014 ${await b0(D,Q.msg)}`)}}let Z=yD(C,E??"",$,B);if(u.code!==Z){let Q=await e1(D,C,F);if(E){let O=await R7(D,E,z),V=z.slice(-3),W=V.length?await Promise.all(V.map(async(M)=>` ${await b0(D,M)}`)):[" (thread context unavailable)"];fD(u.code,Z,["--- Recent messages in thread ----------------",...W,"--- Sending ----------------------------------",` \u2192 ${Q} thread of ${O} \u2014 THREAD REPLY`,` Message: ${B}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}else fD(u.code,Z,["--- Last message in channel ------------------",` ${G}: ${$.split(`
150
+ `)[0]?.slice(0,100)??"(empty)"}`,"--- Sending ----------------------------------",` \u2192 ${Q} \u2014 NEW top-level message`,` Message: ${B}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}let Y=await K1(D,C,B,E,u.broadcast),J="";try{J=await L1(D,C,Y)}catch{}if(J)console.log(`\u2713 Sent: ${J}`);else console.log(`\u2713 Sent (ts: ${Y})`);if(u.asBot&&C.startsWith("D"))try{let Q=await V0(D);if(!Q.ok)for(let O of H0(Q,!0))console.error(O);else{let O=Q.appId?`https://api.slack.com/apps/${Q.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${u.target} can't reply (app messaging may be off), enable Messages Tab: ${O} \u2192 App Home.`)}}catch{}}async function f7(D){let u=await V0(D);for(let F of H0(u,!1))console.log(F);if(!u.ok)process.exit(1)}function h7(D){if(/^\d{10,}$/.test(D))return parseInt(D,10);let u=new Date(D.replace(" ","T"));if(isNaN(u.getTime()))throw Error(`Cannot parse time: ${D}`);return Math.floor(u.getTime()/1000)}async function v7(D,u){let{ref:F,threadTs:E}=m0(u.target),C;if(u.channelId)C=u.channelId;else if(u.userId)C=await pu(D,u.userId);else C=await KD(D,F);let B=h7(u.at),$=new Date(B*1000).toISOString(),G=yD(C,u.message,String(B));if(u.code!==G)fD(u.code,G,["--- Scheduling message -----------------------",` To: ${F}${E?` (thread ${E})`:""}`,` At: ${$} (Unix: ${B})`,` Message: ${u.message}`,"---------------------------------------------"]);let z=await _1(D,C,u.message,B,E);console.log(`\u2713 Scheduled (id: ${z}, at: ${$})`)}async function p7(D,u,F){let E;if(F)E=F;else if(u)E=await KD(D,u);let B=(await j1(D,E)).scheduled_messages??[];if(B.length===0){console.log("(no scheduled messages)");return}for(let $ of B){let G=new Date($.post_at*1000).toISOString();console.log(`${$.id} ${G} [${$.channel_id}] ${$.text.split(`
151
+ `)[0]?.slice(0,80)??""}`)}}async function y7(D,u){let F;if(u.channelId)F=u.channelId;else F=await KD(D,u.target);let E=yD(F,u.id);if(u.code!==E)fD(u.code,E,["--- Deleting scheduled message ---------------",` Channel: ${u.target}`,` ID: ${u.id}`,"---------------------------------------------"]);await A1(D,F,u.id),console.log(`\u2713 Deleted scheduled message ${u.id}`)}async function m7(D,u){let{statSync:F,existsSync:E}=await import("fs"),{basename:C}=await import("path");for(let Q of u.filePaths)if(!E(Q))console.error(`Error: file not found: ${Q}`),process.exit(1);let{ref:B,threadTs:$}=m0(u.target),G;if(u.channelId)G=u.channelId;else if(u.userId)G=await pu(D,u.userId);else G=await KD(D,B);let z=u.filePaths.length>1,Z=u.filePaths.map((Q)=>{let O=C(Q),V=z?O:u.title??O;return{fp:Q,filename:O,title:V,sizeFmt:v0(F(Q).size)}}),Y=yD(G,...Z.flatMap((Q)=>[Q.fp,Q.title]));if(u.code!==Y){let Q=` To: ${B}${$?` (thread ${$})`:""}`,O=z?[`--- Uploading ${Z.length} files ------------------------`,Q,...Z.map((V)=>` ${V.filename} (${V.sizeFmt})`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]:["--- Uploading file ---------------------------",Q,` File: ${Z[0].fp}`,` Title: ${Z[0].title}`,` Size: ${Z[0].sizeFmt}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];fD(u.code,Y,O)}let J=Z.length;for(let Q=0;Q<J;Q++){let O=Z[Q],V={title:O.title};if($!==void 0)V.threadTs=$;if(u.comment!==void 0&&Q===0)V.initialComment=u.comment;let{fileId:W,permalink:M}=await v1(D,G,O.fp,V),_=J>1?`[${Q+1}/${J}] `:"";console.log(`${_}\u2713 Uploaded (file_id: ${W}${M?`, url: ${M}`:""})`)}}function c7(D){if(/^F[A-Z0-9]+$/i.test(D))return D;return D.match(/\/files\/[A-Za-z0-9]+\/(F[A-Za-z0-9]+)/)?.[1]}async function g7(D,u,F,E){let C=c7(F);if(!C)throw Error(`Not a file ID or file permalink: ${F}
152
+ `+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let B=m(await H1(D,C,u)),$=m(B.file),G=typeof $.name==="string"?$.name:typeof $.title==="string"?$.title:C,z=typeof $.url_private_download==="string"?$.url_private_download:typeof $.url_private==="string"?$.url_private:"";if(!z)throw Error(`files.info returned no download URL for ${C}`);let Z={Authorization:`Bearer ${D}`};if(u)Z.Cookie=`d=${u}`;let Y=await fetch(z,{headers:Z});if(!Y.ok)throw Error(`Download failed: HTTP ${Y.status} ${Y.statusText}`);let J=Buffer.from(await Y.arrayBuffer()),{statSync:Q,existsSync:O}=await import("fs"),{basename:V}=await import("path"),W=E??G;if(E&&O(E)&&Q(E).isDirectory())W=tD(E,V(G));o1(W,J),console.log(`\u2713 Downloaded ${G} (${v0(J.length)}) \u2192 ${W}`)}async function k7(){Y7();let D=(F)=>Z0(F.workspace),u=(F)=>P8(F.workspace);await _8(cF(process.argv)).scriptName("slack").showHelpOnFail(!1).fail((F,E,C)=>{if(E)console.error(E.message),process.exit(1);console.error(F),console.error(""),C.showHelp(),process.exit(1)}).option("workspace",{alias:"w",type:"string",describe:"Workspace name"}).middleware(async(F)=>{let E=String((F._??[])[0]??"");if(!E||E==="auth"||E==="login")return;try{Z0(F.workspace)}catch(C){if((C instanceof Error?C.message:String(C)).startsWith("No profiles configured"))console.log(`No workspace configured. Let's set that up:
153
+ `),await UF(),process.exit(0);throw C}},!0).command(["read [target]","msgs [target]"],"Browse messages",(F)=>F.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"}),async(F)=>{let E=D(F),C=F.json?"jsonl":F.format;if(F.target)await H7(E,F.target,F.limit,C);else await U7(E)}).command("thread <target> <ts>","Show thread messages",(F)=>F.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(F)=>{let E=F.json?"jsonl":F.format;await q7(D(F),F.target,F.ts,F.limit,E)}).command(["channel","channels","ch"],"Channel commands",(F)=>F.command(["ls","list"],"List channels",(E)=>E.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(E)=>{await K7(D(E),E.limit,E.filter,E.all,E.json?"jsonl":E.format)}).command("get <channel>","Show channel details",(E)=>E.positional("channel",{type:"string",demandOption:!0,describe:"#name or channel ID"}),async(E)=>{let C=D(E),B=E.channel,$=B.startsWith("#")||B.startsWith("@")||B.startsWith("C")||B.startsWith("G")||B.startsWith("D")?B:`#${B}`,G=await KD(C,$),z=m(await S0(C,G)),Z=m(z.channel),Y=typeof Z.name==="string"?Z.name:G,Q=Z.is_im===!0?"@":"#",O=String(m(Z.purpose).value??""),V=String(m(Z.topic).value??""),W=Z.num_members??Z.member_count??"";if(console.log(`${Q}${Y} ${G}`),V)console.log(`topic: ${V}`);if(O)console.log(`purpose: ${O}`);if(W)console.log(`members: ${W}`);console.log(`private: ${Z.is_private===!0}`)}).command(["create <name>","new <name>"],"Create a channel (confirm-hash safety gate)",(E)=>E.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(E)=>{let C=D(E),B=E.name.replace(/^#/,"").toLowerCase(),$=E.private===!0,G=E.invite.filter(Boolean),z=yD(B,String($),G.join(","));if(E.code!==z)fD(E.code,z,["--- Creating channel -------------------------",` name: ${$?"\uD83D\uDD12 ":"#"}${B}`,` private: ${$}`,...G.length?[` invite: ${G.join(", ")}`]:[],"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let Z;try{Z=await P1(C,B,$)}catch(Y){console.error(Y instanceof Error?Y.message:String(Y)),process.exit(1)}if(console.log(`\u2713 Created ${$?"\uD83D\uDD12 ":"#"}${Z.name} (${Z.id})`),G.length){let Y=[];for(let J of G)try{Y.push(J.startsWith("U")||J.startsWith("W")?J:await T0(C,J))}catch(Q){console.error(` ! could not resolve ${J}: ${Q instanceof Error?Q.message:String(Q)}`)}if(Y.length)try{await w1(C,Z.id,Y),console.log(`\u2713 Invited ${Y.length} member${Y.length===1?"":"s"}`)}catch(J){console.error(` ! invite failed: ${J instanceof Error?J.message:String(J)}`)}}}).demandCommand(1,"").showHelpOnFail(!0)).command(["user","usr"],"User commands",(F)=>F.command(["ls","list"],"List workspace members",(E)=>E.option("limit",{alias:"n",type:"number",default:200}).option("filter",{alias:"f",type:"string"}).option("format",{type:"string",choices:["text","jsonl","yaml"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(E)=>{let C=E.json?"jsonl":E.format,B=await R0(D(E)),$=E.filter?.toLowerCase(),G=o(B.members).map(m).filter((Z)=>Z.deleted!==!0&&Z.is_bot!==!0&&String(Z.id)!=="USLACKBOT").filter((Z)=>{if(!$)return!0;let Y=String(Z.name??"").toLowerCase(),J=String(m(Z.profile).real_name??"").toLowerCase(),Q=String(m(Z.profile).email??"").toLowerCase();return Y.includes($)||J.includes($)||Q.includes($)}).slice(0,E.limit);if(C==="jsonl"){for(let Z of G)console.log(JSON.stringify(Z));return}if(C==="yaml"){for(let Z of G){let Y=function(J,Q=""){if(J===null)return"null";if(typeof J==="string")return J.includes(`
147
154
  `)?`|
148
155
  ${J.split(`
149
156
  `).join(`
150
157
  `)}`:J;if(typeof J!=="object")return String(J);if(Array.isArray(J))return J.map((O)=>`
151
158
  ${Q} - ${Y(O,Q+" ")}`).join("");return Object.entries(J).map(([O,V])=>`
152
- ${Q} ${O}: ${Y(V,Q+" ")}`).join("")};console.log("---");for(let[J,Q]of Object.entries(z))console.log(`${J}: ${Y(Q)}`)}return}let Z=Intl.DateTimeFormat().resolvedOptions().timeZone;for(let z of G){let Y=y(z.profile),J=String(z.name??z.id),Q=String(z.id??""),O=String(Y.display_name||""),V=String(Y.real_name||""),W=String(Y.email||""),M=String(z.tz??""),N=[...new Set([O,V].filter((c)=>c&&c!==J))].join(" / "),w=[W,M&&M!==Z?M:""].filter(Boolean).join(" ");console.log(`@${J} ${Q} ${N}${w?" "+w:""}`)}}).command("get <user>","Show user details",(E)=>E.positional("user",{type:"string",demandOption:!0,describe:"@handle or user ID"}),async(E)=>{let C=D(E),B=E.user.startsWith("@")?E.user.slice(1):E.user,$=B;if(!/^U[A-Z0-9]+$/.test(B)){let w=await R0(C),c=o(w.members).map(y).find((e)=>String(e.name??"")===B);if(!c)console.error(`User not found: @${B}`),process.exit(1);$=String(c.id)}let G=y(await f1(C,$)),Z=y(G.user),z=y(Z.profile),Y=Intl.DateTimeFormat().resolvedOptions().timeZone,J=String(Z.name??$),Q=String(Z.id??$),O=String(z.display_name||""),V=String(z.real_name||""),W=String(z.email||""),M=String(Z.tz??""),_=String(z.phone||""),N=String(z.title||"");console.log(`@${J} ${Q}`);let k=[...new Set([O,V].filter((w)=>w&&w!==J))];if(k.length)console.log(`name: ${k.join(" / ")}`);if(W)console.log(`email: ${W}`);if(_)console.log(`phone: ${_}`);if(N)console.log(`title: ${N}`);if(M&&M!==Y)console.log(`tz: ${M}`)}).demandCommand(1,"").showHelpOnFail(!0)).command("news","Activity feed (mentions to you)",(F)=>F.option("limit",{alias:"l",type:"number",default:20}),async(F)=>{await M7(D(F),F.limit)}).command("search <query>","Full-text search",(F)=>F.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(F)=>{await _7(D(F),F.query,F.count,F.json)}).command("send <target> <message>","Send a message (confirm-hash safety gate)",(F)=>F.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(F)=>{let E={target:F.target,message:F.message};if(F.code)E.code=F.code;if(F["channel-id"])E.channelId=F["channel-id"];if(F["user-id"])E.userId=F["user-id"];if(F.broadcast)E.broadcast=!0;if(F.mentions!==!1)E.mentions=!0,E.mentionToken=D(F);let C;if(F["as-bot"]){let B=J0();if(!B)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
159
+ ${Q} ${O}: ${Y(V,Q+" ")}`).join("")};console.log("---");for(let[J,Q]of Object.entries(Z))console.log(`${J}: ${Y(Q)}`)}return}let z=Intl.DateTimeFormat().resolvedOptions().timeZone;for(let Z of G){let Y=m(Z.profile),J=String(Z.name??Z.id),Q=String(Z.id??""),O=String(Y.display_name||""),V=String(Y.real_name||""),W=String(Y.email||""),M=String(Z.tz??""),N=[...new Set([O,V].filter((c)=>c&&c!==J))].join(" / "),w=[W,M&&M!==z?M:""].filter(Boolean).join(" ");console.log(`@${J} ${Q} ${N}${w?" "+w:""}`)}}).command("get <user>","Show user details",(E)=>E.positional("user",{type:"string",demandOption:!0,describe:"@handle or user ID"}),async(E)=>{let C=D(E),B=E.user.startsWith("@")?E.user.slice(1):E.user,$=B;if(!/^U[A-Z0-9]+$/.test(B)){let w=await R0(C),c=o(w.members).map(m).find((e)=>String(e.name??"")===B);if(!c)console.error(`User not found: @${B}`),process.exit(1);$=String(c.id)}let G=m(await f1(C,$)),z=m(G.user),Z=m(z.profile),Y=Intl.DateTimeFormat().resolvedOptions().timeZone,J=String(z.name??$),Q=String(z.id??$),O=String(Z.display_name||""),V=String(Z.real_name||""),W=String(Z.email||""),M=String(z.tz??""),_=String(Z.phone||""),N=String(Z.title||"");console.log(`@${J} ${Q}`);let k=[...new Set([O,V].filter((w)=>w&&w!==J))];if(k.length)console.log(`name: ${k.join(" / ")}`);if(W)console.log(`email: ${W}`);if(_)console.log(`phone: ${_}`);if(N)console.log(`title: ${N}`);if(M&&M!==Y)console.log(`tz: ${M}`)}).demandCommand(1,"").showHelpOnFail(!0)).command("news","Activity feed (mentions to you)",(F)=>F.option("limit",{alias:"l",type:"number",default:20}),async(F)=>{await M7(D(F),F.limit)}).command("search <query>","Full-text search",(F)=>F.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(F)=>{await _7(D(F),F.query,F.count,F.json)}).command("send <target> <message>","Send a message (confirm-hash safety gate)",(F)=>F.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(F)=>{let E={target:F.target,message:F.message};if(F.code)E.code=F.code;if(F["channel-id"])E.channelId=F["channel-id"];if(F["user-id"])E.userId=F["user-id"];if(F.broadcast)E.broadcast=!0;if(F.mentions!==!1)E.mentions=!0,E.mentionToken=D(F);let C;if(F["as-bot"]){let B=J0();if(!B)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
153
160
  Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);if(!E.channelId&&!E.userId&&E.target.startsWith("@"))try{E.userId=await T0(D(F),E.target)}catch($){console.error(`Error: could not resolve ${E.target} to a user for the bot DM.
154
161
  ${$ instanceof Error?$.message:String($)}
155
162
  Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}C=B,E.asBot=!0}else C=D(F);try{await b7(C,E)}catch(B){console.error(i1(B)),process.exit(1)}}).command("doctor","Check the bot token (xoxb) can carry a two-way DM (scopes + Messages Tab)",(F)=>F,async()=>{let F=J0();if(!F)console.error(`Error: slack doctor checks the bot token, but no xoxb- token was found.
156
- Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await f7(F)}).command("schedule","Manage scheduled messages",(F)=>F.command("send <target> <message>","Schedule a message for later delivery",(E)=>E.positional("target",{type:"string",demandOption:!0,describe:"#chan, @user, #chan:thread_ts, or permalink (a message permalink replies in its thread)"}).positional("message",{type:"string",demandOption:!0}).option("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(E)=>{let C={target:E.target,message:E.message,at:E.at};if(E.code)C.code=E.code;if(E["channel-id"])C.channelId=E["channel-id"];if(E["user-id"])C.userId=E["user-id"];await v7(D(E),C)}).command(["ls","list"],"List pending scheduled messages",(E)=>E.positional("target",{type:"string",describe:"#channel to filter by"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(E)=>{await p7(D(E),E.target,E["channel-id"])}).command("rm <target> <id>","Delete a scheduled message",(E)=>E.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(E)=>{let C={target:E.target,id:E.id};if(E.code)C.code=E.code;if(E["channel-id"])C.channelId=E["channel-id"];await m7(D(E),C)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("edit <target> <newText>","Edit a sent message",(F)=>F.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(F)=>{let E={target:F.target,newText:F.newText};if(F.code)E.code=F.code;if(F["channel-id"])E.channelId=F["channel-id"];if(F.mentions!==!1)E.mentions=!0;await P7(D(F),E)}).command("delete <target>","Delete a sent message (confirm-hash safety gate)",(F)=>F.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(F)=>{let E={target:F.target};if(F.code)E.code=F.code;if(F["channel-id"])E.channelId=F["channel-id"];await w7(D(F),E)}).command("react <target> <emoji>","Add (or --remove) an emoji reaction \u2014 a lightweight ack that doesn't grow the thread",(F)=>F.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(F)=>{let E={target:F.target,emoji:F.emoji};if(F.remove)E.remove=!0;if(F["channel-id"])E.channelId=F["channel-id"];try{await x7(D(F),E)}catch(C){console.error(i1(C)),process.exit(1)}}).command("upload <target> <file..>","Upload one or more files to a channel or DM",(F)=>F.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(F)=>{let E={target:F.target,filePaths:F.file};if(F.title)E.title=F.title;if(F.comment)E.comment=F.comment;if(F.code)E.code=F.code;if(F["channel-id"])E.channelId=F["channel-id"];if(F["user-id"])E.userId=F["user-id"];await y7(D(F),E)}).command("download <ref> [dest]","Download a file attachment (by file ID or file permalink) to disk",(F)=>F.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(F)=>{await g7(D(F),u(F),F.ref,F.dest)}).command("dump","Bulk export channel history as markdown",(F)=>F.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(F)=>{await j7(D(F),F.days,F.limit,F.filter)}).command("drafts","Manage message drafts (requires xoxc desktop token)",(F)=>F.command(["$0","ls","list"],"List pending drafts",(E)=>E.option("all",{alias:"a",type:"boolean",default:!1,describe:"Include sent drafts"}),async(E)=>{await L7(D(E),u(E),E.all)}).command(["new <channel> [text..]","save <channel> [text..]"],"Create a draft",(E)=>E.positional("channel",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}),async(E)=>{let C=D(E),B=u(E),$=E.text.join(" ");if(!$)console.error("Usage: slack drafts new <#channel|@user> <text>"),process.exit(2);let G=await KD(C,E.channel,B),Z=await x1(C,G,$,B);console.log(`\u2713 Draft created (id: ${y(Z.draft).id??"?"})`)}).command("get <id>","Show a draft",(E)=>E.positional("id",{type:"string",demandOption:!0}),async(E)=>{await N7(D(E),u(E),E.id)}).command(["edit <id> [text..]","update <id> [text..]"],"Edit a draft",(E)=>E.positional("id",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}).option("code",{type:"string"}),async(E)=>{let C=D(E),B=u(E),$=E.text.join(" ");if(!$)console.error("Usage: slack drafts edit <id> <new-text>"),process.exit(2);let G=await cu(C,B),Z=o(G.drafts).map(y).find((Q)=>String(Q.id)===E.id);if(!Z)console.error(`Draft not found: ${E.id}`),process.exit(1);let z=LF(Z),Y=mD(z,$);if(E.code!==Y)fD(E.code,Y,["--- Current draft ----------------------------",...z.split(`
163
+ Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await f7(F)}).command("schedule","Manage scheduled messages",(F)=>F.command("send <target> <message>","Schedule a message for later delivery",(E)=>E.positional("target",{type:"string",demandOption:!0,describe:"#chan, @user, #chan:thread_ts, or permalink (a message permalink replies in its thread)"}).positional("message",{type:"string",demandOption:!0}).option("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(E)=>{let C={target:E.target,message:E.message,at:E.at};if(E.code)C.code=E.code;if(E["channel-id"])C.channelId=E["channel-id"];if(E["user-id"])C.userId=E["user-id"];await v7(D(E),C)}).command(["ls","list"],"List pending scheduled messages",(E)=>E.positional("target",{type:"string",describe:"#channel to filter by"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(E)=>{await p7(D(E),E.target,E["channel-id"])}).command("rm <target> <id>","Delete a scheduled message",(E)=>E.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(E)=>{let C={target:E.target,id:E.id};if(E.code)C.code=E.code;if(E["channel-id"])C.channelId=E["channel-id"];await y7(D(E),C)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("edit <target> <newText>","Edit a sent message",(F)=>F.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(F)=>{let E={target:F.target,newText:F.newText};if(F.code)E.code=F.code;if(F["channel-id"])E.channelId=F["channel-id"];if(F.mentions!==!1)E.mentions=!0;await P7(D(F),E)}).command("delete <target>","Delete a sent message (confirm-hash safety gate)",(F)=>F.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(F)=>{let E={target:F.target};if(F.code)E.code=F.code;if(F["channel-id"])E.channelId=F["channel-id"];await w7(D(F),E)}).command("react <target> <emoji>","Add (or --remove) an emoji reaction \u2014 a lightweight ack that doesn't grow the thread",(F)=>F.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(F)=>{let E={target:F.target,emoji:F.emoji};if(F.remove)E.remove=!0;if(F["channel-id"])E.channelId=F["channel-id"];try{await x7(D(F),E)}catch(C){console.error(i1(C)),process.exit(1)}}).command("upload <target> <file..>","Upload one or more files to a channel or DM",(F)=>F.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(F)=>{let E={target:F.target,filePaths:F.file};if(F.title)E.title=F.title;if(F.comment)E.comment=F.comment;if(F.code)E.code=F.code;if(F["channel-id"])E.channelId=F["channel-id"];if(F["user-id"])E.userId=F["user-id"];await m7(D(F),E)}).command("download <ref> [dest]","Download a file attachment (by file ID or file permalink) to disk",(F)=>F.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(F)=>{await g7(D(F),u(F),F.ref,F.dest)}).command("dump","Bulk export channel history as markdown",(F)=>F.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(F)=>{await j7(D(F),F.days,F.limit,F.filter)}).command("drafts","Manage message drafts (requires xoxc desktop token)",(F)=>F.command(["$0","ls","list"],"List pending drafts",(E)=>E.option("all",{alias:"a",type:"boolean",default:!1,describe:"Include sent drafts"}),async(E)=>{await L7(D(E),u(E),E.all)}).command(["new <channel> [text..]","save <channel> [text..]"],"Create a draft",(E)=>E.positional("channel",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}),async(E)=>{let C=D(E),B=u(E),$=E.text.join(" ");if(!$)console.error("Usage: slack drafts new <#channel|@user> <text>"),process.exit(2);let G=await KD(C,E.channel,B),z=await x1(C,G,$,B);console.log(`\u2713 Draft created (id: ${m(z.draft).id??"?"})`)}).command("get <id>","Show a draft",(E)=>E.positional("id",{type:"string",demandOption:!0}),async(E)=>{await N7(D(E),u(E),E.id)}).command(["edit <id> [text..]","update <id> [text..]"],"Edit a draft",(E)=>E.positional("id",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}).option("code",{type:"string"}),async(E)=>{let C=D(E),B=u(E),$=E.text.join(" ");if(!$)console.error("Usage: slack drafts edit <id> <new-text>"),process.exit(2);let G=await gu(C,B),z=o(G.drafts).map(m).find((Q)=>String(Q.id)===E.id);if(!z)console.error(`Draft not found: ${E.id}`),process.exit(1);let Z=LF(z),Y=yD(Z,$);if(E.code!==Y)fD(E.code,Y,["--- Current draft ----------------------------",...Z.split(`
157
164
  `).map((Q)=>` ${Q}`),"--- Replacing with ---------------------------",...$.split(`
158
- `).map((Q)=>` ${Q}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let J=await I1(C,E.id,p0(Z),$,B);console.log(`\u2713 Draft updated (id: ${y(J.draft).id??"?"})`)}).command(["delete <id>","rm <id>"],"Delete a draft",(E)=>E.positional("id",{type:"string",demandOption:!0}).option("code",{type:"string"}),async(E)=>{let C=D(E),B=u(E),$=await cu(C,B),G=o($.drafts).map(y).find((Y)=>String(Y.id)===E.id);if(!G)console.error(`Draft not found: ${E.id}`),process.exit(1);let Z=LF(G),z=mD(E.id,Z);if(E.code!==z)fD(E.code,z,["\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",` id: ${E.id}`,...Z.split(`
165
+ `).map((Q)=>` ${Q}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let J=await I1(C,E.id,p0(z),$,B);console.log(`\u2713 Draft updated (id: ${m(J.draft).id??"?"})`)}).command(["delete <id>","rm <id>"],"Delete a draft",(E)=>E.positional("id",{type:"string",demandOption:!0}).option("code",{type:"string"}),async(E)=>{let C=D(E),B=u(E),$=await gu(C,B),G=o($.drafts).map(m).find((Y)=>String(Y.id)===E.id);if(!G)console.error(`Draft not found: ${E.id}`),process.exit(1);let z=LF(G),Z=yD(E.id,z);if(E.code!==Z)fD(E.code,Z,["\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",` id: ${E.id}`,...z.split(`
159
166
  `).map((Y)=>` ${Y}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await h1(C,E.id,B),console.log(`\u2713 Draft deleted (id: ${E.id})`)})).command("auth","Authentication and workspace management",(F)=>F.command("token","Add a workspace \u2014 paste an existing xoxp-/xoxb- token",(E)=>E.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(E)=>{await B1({...E.token!==void 0?{token:E.token}:{},...E.name!==void 0?{name:E.name}:{}})}).command("app","Create a new Slack app and obtain a token (guided wizard)",(E)=>E.option("bot",{type:"boolean",describe:"Create a bot token (xoxb-) instead of user (xoxp-)"}),async(E)=>{await $1({...E.bot!==void 0?{bot:E.bot}:{}})}).command("login","Interactive auth wizard (all auth methods: desktop app, token, new app)",(E)=>E.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(E)=>{await UF({...E.token!==void 0?{token:E.token}:{},...E.name!==void 0?{name:E.name}:{}})}).command(["ls","status"],"Show auth status",()=>{},()=>{let E=T8();if(E.length===0){console.log("No workspaces configured. Run: slack auth login");return}for(let{name:C,profile:B,current:$}of E)console.log(`${$?"* ":" "}${C} ${B.team} (${B.user}) ${B.url??""}`)}).command("use <name>","Switch active workspace",(E)=>E.positional("name",{type:"string",demandOption:!0}).option("g",{type:"boolean",default:!1,describe:"Write global lockfile (~/.slack-cli/workspace)"}),(E)=>{if(!E.g)Q7(tD(process.cwd(),".slack-cli"));S8(E.name,E.g),console.log(`Switched to workspace "${E.name}" ${E.g?"globally":"locally"}`)}).command(["logout <name>","rm <name>","remove <name>"],"Remove a workspace",(E)=>E.positional("name",{type:"string",demandOption:!0}),(E)=>{R8(E.name),console.log(`Removed workspace "${E.name}"`)}).command(["chrome","cookie"],"Attach Chrome browser xoxd cookie to a workspace (macOS, interactive)",(E)=>E.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(E)=>{await E1({...E.workspace!==void 0?{workspace:E.workspace}:{}})}).command("firefox","Attach Firefox browser xoxd cookie to a workspace (all platforms)",(E)=>E.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(E)=>{await C1({...E.workspace!==void 0?{workspace:E.workspace}:{}})}).command("$0",!1,()=>{},()=>{F.showHelp(),process.exit(0)})).command("tail [target]","Stream new messages in real time (like tail -f)",(F)=>F.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(F)=>{let E=D(F),C=u(F),B=new AbortController;process.on("SIGINT",()=>{B.abort(),process.exit(0)}),await Y1(E,F.target,{...F.since!==void 0?{since:F.since}:{},...F.thread!==void 0?{thread:F.thread}:{},...F["watch-thread"]!==void 0?{watchThread:F["watch-thread"]}:{},me:F.me,interval:F.interval,...F.timeout!==void 0?{timeout:F.timeout}:{},...F["exit-on-message"]===!0?{exitOnMessage:!0}:{},...C!==void 0?{cookie:C}:{},...F.rtm===!1?{noRtm:!0}:{}},B.signal)}).command("login",!1,(F)=>F.option("token",{type:"string"}).option("name",{type:"string"}),async(F)=>{await UF({...F.token!==void 0?{token:F.token}:{},...F.name!==void 0?{name:F.name}:{}})}).demandCommand(1,"Specify a command. Run with --help for usage.").strict().help().alias("help","h").parseAsync()}k7().catch((D)=>{console.error(D instanceof Error?D.message:String(D)),process.exit(1)});