@redreplier/cli 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +14 -11
  2. package/dist/alert-ChEB-ZUO.js +1 -0
  3. package/dist/api-B3rh3sU0.js +3 -0
  4. package/dist/auth-DpNnCwwh.js +1 -0
  5. package/dist/cli.js +2 -2
  6. package/dist/{client-oUdubIcu.js → client-BWzucJSi.js} +1 -1
  7. package/dist/{completion-EvS24LbX.js → completion-B4zIAjmZ.js} +3 -3
  8. package/dist/config-BEGhiorY.js +1 -0
  9. package/dist/config-SzcelmNd.js +1 -0
  10. package/dist/config-eE6NRs2j.js +1 -0
  11. package/dist/doctor-B-Hso4GL.js +1 -0
  12. package/dist/{errors-D1qbI3dY.js → errors-CDuXb8cW.js} +1 -1
  13. package/dist/errors-DLtuFXHR.js +1 -0
  14. package/dist/exit-codes-CyB7Jo1I.js +1 -0
  15. package/dist/exit-codes-Dof7Nstu.js +1 -0
  16. package/dist/http-CbGjDmPT.js +2 -0
  17. package/dist/http-Dm3cTW8q.js +1 -0
  18. package/dist/keyword-Ct0Aue-0.js +1 -0
  19. package/dist/keyword-DhiBS_xU.js +1 -0
  20. package/dist/mcp-nN06w2tF.js +3 -0
  21. package/dist/mention-DZytkT4_.js +1 -0
  22. package/dist/open-BLS-D6GL.js +1 -0
  23. package/dist/{output-CDjsADAT.js → output-DNozQoTg.js} +1 -1
  24. package/dist/{output-Cye9q83I.js → output-DV-8Js8u.js} +1 -1
  25. package/dist/{prompt-BUh1Q_gg.js → prompt-4XL3T1kl.js} +1 -1
  26. package/dist/prompt-CdMTCvG1.js +1 -0
  27. package/dist/site-CZHkjUpC.js +1 -0
  28. package/dist/{time-DaUXqVz-.js → time-i2j8Fkgp.js} +1 -1
  29. package/dist/{types-BGk3hWyo.js → types-B3SaBx4C.js} +1 -1
  30. package/dist/update-check-BD7FZeHS.js +1 -0
  31. package/dist/update-check-OIfTu8xz.js +1 -0
  32. package/dist/{version-B0Ypbd8g.js → version-DUOAxI9S.js} +1 -1
  33. package/dist/version-YGhP26LK.js +1 -0
  34. package/package.json +1 -1
  35. package/dist/alert-WTyiaFxJ.js +0 -1
  36. package/dist/api-W7BP64iK.js +0 -3
  37. package/dist/auth-DqEbz2Jy.js +0 -1
  38. package/dist/config-53zPXLzs.js +0 -1
  39. package/dist/config-BEJ8cdXh.js +0 -1
  40. package/dist/config-nFtRCrru.js +0 -1
  41. package/dist/doctor-Dch8UtNo.js +0 -1
  42. package/dist/errors-DK8JR_St.js +0 -1
  43. package/dist/exit-codes-CEqGHMR7.js +0 -1
  44. package/dist/exit-codes-eYq58Sw_.js +0 -1
  45. package/dist/http-DAgILPv-.js +0 -2
  46. package/dist/http-DNUc-MW8.js +0 -1
  47. package/dist/keyword-BY2TX0l4.js +0 -1
  48. package/dist/keyword-CNU86Lta.js +0 -1
  49. package/dist/mcp-CBygu84l.js +0 -3
  50. package/dist/mention-CXKnBCsd.js +0 -1
  51. package/dist/open-r4fRMoJ3.js +0 -1
  52. package/dist/product-CXL7Ga4M.js +0 -1
  53. package/dist/prompt-BXyNKU0M.js +0 -1
  54. package/dist/site-QTLQZ_Fy.js +0 -1
  55. package/dist/update-check-9qIilkr0.js +0 -1
  56. package/dist/update-check-BvMnC6lH.js +0 -1
  57. package/dist/version-DY0tYOG7.js +0 -1
  58. /package/dist/{open-url-CovrlP9b.js → open-url-at-ONE2w.js} +0 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # RedReplier CLI
2
2
 
3
- Watch Reddit, Hacker News, X and Bluesky for your keywords, from your terminal.
3
+ Watch Reddit, Hacker News, X, Bluesky and Facebook for your keywords, from your terminal.
4
4
 
5
5
  `redreplier` talks to the RedReplier REST API and nothing else. It registers the sites you monitor, manages the keywords they listen for, lists and scores the lead mentions those keywords found, explains why a mention scored what it did, and tails new mentions into any script you want to run on them. Everything prints as a table for humans or as one JSON document for `jq`.
6
6
 
@@ -42,7 +42,7 @@ redreplier login
42
42
 
43
43
  The command opens the token page, reads the token from a hidden prompt, checks the `redreplier_` prefix locally, verifies it with one `GET /websites`, and writes it to `~/.config/redreplier/credentials.json` at mode 0600. Nothing is written if verification fails.
44
44
 
45
- Token creation is gated behind the `api_access` subscription feature. On the free plan the token page answers with an error instead of a token, which is a plan limit and not a CLI fault. Plans are at <https://redreplier.com/billing>.
45
+ Token creation is gated behind the `api_access` subscription feature. On the free plan the token page answers with an error instead of a token, which is a plan limit and not a CLI fault. A token minted on a paid plan stops working if the plan later loses `api_access`: every command then fails with 403 `subscription_required` and exit 9. Plans are at <https://redreplier.com/billing>.
46
46
 
47
47
  For CI, pipe the token in and skip the prompt:
48
48
 
@@ -79,9 +79,12 @@ $ redreplier site create --url https://acme.com -k "reddit monitoring" -k "lead
79
79
 
80
80
  ✓ Created ws_4f21… acme.com
81
81
  description generated (412 chars)
82
- keywords 2 active, 0 pending
82
+ keywords 2 pending
83
+ ℹ Some keywords are PENDING. Price an upgrade: redreplier keyword plan
83
84
  ```
84
85
 
86
+ Keywords passed to `site create` are stored `PENDING`. The next `site list` or `keyword activate-pending` promotes the ones that fit the plan's free slots, without charging.
87
+
85
88
  ```
86
89
  $ redreplier mention list --bucket HIGH --bucket VERY_HIGH --sort RELEVANCE --limit 5
87
90
  SCORE SOURCE WHEN KEYWORD TITLE
@@ -174,7 +177,7 @@ Grammar is noun then verb, space-separated. `ls` works wherever `list` does, `rm
174
177
  |---|---|---|
175
178
  | `site list` | | Every monitored site, its keyword counts and whether it has a description |
176
179
  | `site get <id>` | | The site plus its full keyword table with statuses |
177
- | `site create` | `--url`, `--name`, `-k/--keyword`, `--description`, `--no-analyze` | Without `--description` the server scrapes the URL and spends one AI generation, so it confirms first. `--description @file` reads a file and `-` reads stdin |
180
+ | `site create` | `--url`, `--name`, `-k/--keyword`, `--description`, `--no-analyze` | Without `--description` the server scrapes the URL and spends one AI generation, so it confirms first. `--description @file` reads a file and `-` reads stdin. Keywords land `PENDING` until `site list` or `keyword activate-pending` promotes them. `--no-analyze` sends `description: ""`, which skips the scrape and the AI generation. The site has no description, so its mentions stay unscored until `site update --description` adds one |
178
181
  | `site update <id>` | `--name`, `--description` | Existing mentions are not rescored |
179
182
  | `site delete <id>` | `--yes` | Deletes the site, its keywords and every mention they produced |
180
183
  | `site analyze` | `--url`, `--yes` | Generates a description. Human mode prints it to stdout alone; a pipe is machine mode and gets the JSON envelope, so pipe it with `REDREPLIER_FORCE_TTY=1` or read `.data.description` with `jq` |
@@ -202,10 +205,10 @@ Reading the site list promotes `PENDING` keywords that fit free headroom, which
202
205
  | `keyword add <siteId> <keyword...>` | | Trimmed, lowercased and de-duplicated before sending, so the preview matches what the server stores |
203
206
  | `keyword edit <id>` | `--value` | Free and unlimited, and it keeps the paid slot. A case-only change is a no-op |
204
207
  | `keyword disable <id>` | | Stops collecting, keeps the mentions, never charges |
205
- | `keyword enable <id>` | | Lands `PENDING` when no slot is free |
208
+ | `keyword enable <id>` | | Lands `PENDING` when no slot is free. Never charges |
206
209
  | `keyword delete <id>` | `--yes` | Deletes every mention the keyword produced. Type DELETE to confirm |
207
210
  | `keyword activate-pending` | | Promotes pending keywords into free slots. Overflow stays pending |
208
- | `keyword plan` | `--count` | `--count` is an account-wide total of active keywords, not an increment |
211
+ | `keyword plan` | `--count` | Read-only price preview. Without `--count` it prices activating every pending keyword in the workspace. `--count` is an account-wide total of active keywords, not an increment. Changing the plan happens in the web app |
209
212
  | `keyword usage` | | Keyword edits are unlimited on every current plan, and the output says that rather than drawing a meter |
210
213
 
211
214
  `keyword` also answers to `keywords` and `kw`.
@@ -261,7 +264,7 @@ $ redreplier alerts get
261
264
  | `logout` | `--profile`, `--all` | |
262
265
  | `whoami` | | Prints which source each of the token and the API URL came from |
263
266
  | `config list \| get \| set \| unset \| path` | | Reads and writes `config.json` |
264
- | `open [what] [id]` | | `dashboard`, `mentions`, `mention <id>`, `sites`, `site <id>`, `keywords`, `tokens`, `billing` |
267
+ | `open [what]` | | `dashboard`, `keywords`, `leads` (also `mentions`), `alerts`, `subreddits`, `seo`, `tokens`, `billing`, `settings`, `workspaces` |
265
268
  | `doctor` | `--json` | Node version, files, permissions, token, API reachability, rate limit |
266
269
  | `completion <shell>` | | `bash`, `zsh`, `fish`, `powershell` |
267
270
  | `mcp` | `--client`, `--local`, `--install` | Prints or names the file for the MCP client config |
@@ -296,7 +299,7 @@ Accepted at any position.
296
299
  | `--no-input` | auto | Never prompt; fail with exit 2 instead |
297
300
  | `--lang <code>` | unset | `en`, `fr`, `de`, `es`, `pt` |
298
301
  | `--full-ids` | false | Print identifiers in full instead of truncating |
299
- | `-V, --version` | | Prints `redreplier/1.3.2 node-v22.14.0 darwin-arm64` |
302
+ | `-V, --version` | | Prints `redreplier/0.2.0 node-v22.14.0 darwin-arm64` |
300
303
  | `-h, --help` | | `--help-all` adds the experimental commands |
301
304
 
302
305
  `--no-input` is implied when stdin is not a TTY.
@@ -340,14 +343,14 @@ Add `--json` to a list command and the available field names are printed to stde
340
343
  | 0 | Success |
341
344
  | 1 | Generic failure, including 5xx |
342
345
  | 2 | Usage error: bad flag, missing argument, unknown enum, prompt needed under `--no-input` |
343
- | 3 | Auth failure: 401, missing or malformed token |
346
+ | 3 | Auth failure: 401, missing or malformed token, or `token_issuer_lost_access` when the member who created the key has left the workspace or was deactivated |
344
347
  | 4 | Not found: 404, or a mention that is not visible in this workspace |
345
348
  | 5 | Validation or other 400 |
346
349
  | 6 | Conflict: 409 |
347
350
  | 7 | Rate limited: 429 after retries |
348
351
  | 8 | Network failure or timeout |
349
352
  | 9 | Quota or plan limit: 402, no AI generations left, 403 `subscription_required` |
350
- | 10 | Permission denied: 403, the token is valid but not allowed to do this |
353
+ | 10 | Permission denied: 403, the token is valid but not allowed to do this, including `workspace_access_denied` for a workspace the token does not belong to |
351
354
  | 130 | Interrupted with Ctrl-C |
352
355
 
353
356
  Exit 3 means get a working token. Exit 10 means the token works and someone with more access has to act; retrying from this machine changes nothing.
@@ -380,7 +383,7 @@ Base URL resolution, highest first: `--api-url`, `REDREPLIER_API_URL`, the profi
380
383
  | `defaultSite` | Default for `--site` |
381
384
  | `language` | Default `x-language` header |
382
385
  | `updateCheck` | Set false to turn off the daily version check |
383
- | `workspaceId` | The workspace this profile talks to |
386
+ | `workspaceId` | Stored, but not yet sent as the `X-Workspace-Id` header. An API token belongs to one workspace, so use one profile per workspace |
384
387
 
385
388
  ```bash
386
389
  redreplier config set defaultSite ws_4f21
@@ -0,0 +1 @@
1
+ import"./exit-codes-Dof7Nstu.js";import{h as e,m as t}from"./errors-DLtuFXHR.js";import"./version-DUOAxI9S.js";import"./color-BbAK7_Y7.js";import{c as n,f as r,g as i,i as a,o,p as s,r as c,s as l,v as u}from"./output-DNozQoTg.js";import"./config-eE6NRs2j.js";import"./http-CbGjDmPT.js";import{a as d,f,i as p,t as m}from"./types-B3SaBx4C.js";import{C as h,S as g,f as _,m as v,v as y,x as b}from"./client-BWzucJSi.js";const x=`experimental, undocumented API`;function S(e){return e%1440==0?`${e/1440}d`:e%60==0?`${e/60}h`:`${e}m`}function C(e){let n=Number(e);if(!Number.isInteger(n)||!m.includes(n))throw t(`--cadence must be one of ${m.join(`, `)} minutes, got "${e}"`,`the server rejects anything else with a generic 400`);return n}function w(e){let n=Number(e);if(!Number.isInteger(n)||n<d||n>p)throw t(`--min-score must be a whole number between ${d} and ${p}, got "${e}"`);return n}async function T(e,t){let n=l()||o()?null:f(e);try{return await t()}finally{n?.stop()}}function E(e){r([[`enabled`,e.enabled?`yes`:`no`],[`cadence`,S(e.cadenceMinutes)],[`fastest`,`${S(e.minIntervalMinutes)} on this plan`],[`options`,e.availableCadences.join(`, `)]])}async function D(){let e=await T(`Reading alert settings…`,_);if(o()){s(`alerts.get`,e);return}E(e),a(`the full server list is ${m.join(`, `)}; yours is what the plan allows`)}async function O(n){if(n.on===!0&&n.off===!0)throw t(`Pass either --on or --off, not both`);if(n.on!==!0&&n.off!==!0)throw t(`Pass --on or --off`,`${e.binName} alerts set --on --cadence 60`);let r=n.cadence===void 0?void 0:C(n.cadence),c=await T(`Reading alert settings…`,_);r!==void 0&&!c.availableCadences.includes(r)&&u(`${S(r)} is not in this plan's cadences (${c.availableCadences.join(`, `)}), so the server may refuse it.`);let l=r??c.cadenceMinutes,d=await T(`Saving alert settings…`,()=>g({enabled:n.on===!0,cadenceMinutes:l}));if(o()){s(`alerts.set`,d);return}i(d.enabled?`Alerts on every ${S(d.cadenceMinutes)}`:`Alerts off (cadence ${r===void 0?`kept at`:`set to`} ${S(d.cadenceMinutes)})`),r===void 0&&a(`PUT /alert-settings is a full replace, so the current cadence was read and resent.`)}function k(e){let t=e.command(`alerts`).alias(`alert`).description(`email alert cadence for new mentions`);t.command(`get`).alias(`list`).description(`show the alert settings`).action(async()=>{await D()}),t.command(`set`).description(`turn alerts on or off and choose the cadence`).option(`--on`,`enable alerts`).option(`--off`,`disable alerts`).option(`--cadence <minutes>`,`one of ${m.join(`, `)}`).action(async e=>{await O(e)})}function A(e){r([[`enabled`,e.enabled?`yes`:`no`],[`min score`,String(e.minScore)],[`site`,e.websiteId===null?`every site`:c(e.websiteId)],[`profanity`,e.profanity?`yes`:`no`]])}async function j(){let e=await T(`Reading mean marketer config…`,v);if(o()){s(`mean-marketer.config`,e,{experimental:!0});return}A(e),a(x)}async function M(e){if(e.on===!0&&e.off===!0)throw t(`Pass either --on or --off, not both`);let n={};if(e.on===!0&&(n.enabled=!0),e.off===!0&&(n.enabled=!1),e.minScore!==void 0&&(n.minScore=w(e.minScore)),e.site!==void 0){let t=e.site.trim();n.websiteId=t===``||t.toLowerCase()===`none`?null:t}if(e.profanity!==void 0&&(n.profanity=e.profanity),Object.keys(n).length===0)throw t(`Nothing to change.`,`Pass at least one of --on, --off, --min-score, --site, --profanity or --no-profanity`);let r=await T(`Saving mean marketer config…`,()=>h(n));if(o()){s(`mean-marketer.config.set`,r,{experimental:!0});return}i(`Saved`),A(r),a(x)}function N(e){r([[`enabled`,e.enabled?`yes`:`no`],[`min score`,String(e.minScore)],[`mood`,e.beMean?`mean, tier ${e.tier}`:`civil, tier ${e.tier}`],[`strikes`,String(e.strikes)]]),e.previous&&(n(``),n(`previous opportunity`),r([[`id`,e.previous.id],[`status`,e.previous.status],[`triaged`,e.previous.triaged?`yes`:`no`],[`outstanding`,`${e.previous.hoursOutstanding}h`]],` `)),e.opportunity?(n(``),n(`new opportunity`),r([[`id`,e.opportunity.id],[`title`,e.opportunity.title??`—`],[`source`,e.opportunity.subreddit?`r/${e.opportunity.subreddit}`:e.opportunity.source],[`keyword`,e.opportunity.keyword??`—`],[`score`,e.opportunity.relevanceScore===null?`—`:String(e.opportunity.relevanceScore)],[`url`,e.opportunity.url??`—`]],` `),e.opportunity.relevanceReason&&(n(``),n(` ${e.opportunity.relevanceReason}`))):e.noNewOpportunity&&(n(``),n(`No new opportunity above the minimum score.`)),e.message&&(n(``),n(e.message))}async function P(){let e=await T(`Polling…`,y);if(o()){s(`mean-marketer.poll`,e,{experimental:!0});return}N(e),a(`${x}; this call advances the strike state`)}async function F(){let e=await T(`Resetting…`,b);if(o()){s(`mean-marketer.reset`,e,{experimental:!0});return}e.reset?i(`Strike state reset`):n(`Nothing to reset.`),a(x)}function I(e){let t=e.command(`mean-marketer`,{hidden:!0}).alias(`mm`).description(`nag yourself into replying (${x})`);t.command(`config`).description(`show the mean marketer config`).action(async()=>{await j()}).command(`set`).description(`change the mean marketer config`).option(`--on`,`enable it`).option(`--off`,`disable it`).option(`--min-score <n>`,`only nag about mentions scoring this or higher, ${d} to ${p}`).option(`--site <id>`,`restrict it to one site, or "none" for every site`).option(`--profanity`,`allow profanity`).option(`--no-profanity`,`keep it clean`).action(async e=>{await M(e)}),t.command(`poll`).description(`ask for the next opportunity and advance the strike state`).action(async()=>{await P()}),t.command(`reset`).description(`clear the strike state`).action(async()=>{await F()})}export{C as assertCadence,w as assertMinScore,S as formatCadence,k as registerAlertCommands,I as registerMeanMarketerCommands};
@@ -0,0 +1,3 @@
1
+ import{o as e,s as t}from"./exit-codes-Dof7Nstu.js";import{h as n,m as r,n as i}from"./errors-DLtuFXHR.js";import{i as a}from"./version-DUOAxI9S.js";import{S as o,x as s}from"./config-eE6NRs2j.js";import{readFile as c}from"node:fs/promises";const l=[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`,`HEAD`],u=(e,t)=>[...t,e];async function d(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString(`utf8`)}function f(e){let t=new URLSearchParams;for(let i of e){let e=i.indexOf(`=`);if(e<=0)throw r(`--query expects key=value, got "${i}".`,`${n.binName} api /mentions --query limit=5 --query statuses=NEW`);t.append(i.slice(0,e),i.slice(e+1))}return t}function p(e){let t={};for(let n of e){let e=n.indexOf(`:`);if(e<=0)throw r(`--header expects "Name: value", got "${n}".`);let i=n.slice(0,e).trim();if(i.toLowerCase()===`authorization`)throw r(`Authorization comes from the resolved profile and cannot be overridden.`,`Use --token or --profile to change which token is sent.`);t[i]=n.slice(e+1).trim()}return t}async function m(e,t,n){if(e!==void 0&&t!==void 0)throw r(`Pass either --data or --data-file, not both.`);let i;if(t!==void 0)i=t===`-`?await d():await c(t,`utf8`);else if(e!==void 0)i=e===`@-`?await d():e.startsWith(`@`)?await c(e.slice(1),`utf8`):e;else if(n!==`GET`&&n!==`HEAD`&&!process.stdin.isTTY){let e=await d();i=e.trim()===``?void 0:e}if(i!==void 0){try{JSON.parse(i)}catch{throw r(`The request body is not valid JSON.`)}return i}}function h(c){c.command(`api`).argument(`<path>`,`API path such as /mentions, or an HTTP method when a path follows`).argument(`[pathAfterMethod]`,`API path, when the first argument is an HTTP method`).description(`send an authenticated request to the ${n.displayName} API`).option(`-X, --method <method>`,`HTTP method`,`GET`).option(`-q, --query <key=value>`,`query parameter, repeat the key for arrays`,u,[]).option(`-d, --data <json|@file>`,`request body, @- reads stdin`).option(`--data-file <path>`,`request body read from a file, - reads stdin`).option(`-H, --header <name:value>`,`extra request header, repeatable`,u,[]).option(`-i, --include`,`print the status and response headers to stderr`).action(async(c,u,d)=>{let h=d.method.toUpperCase(),g=c;if(u!==void 0){if(!l.includes(c.toUpperCase()))throw r(`"${c}" is not an HTTP method.`,`Methods: ${l.join(`, `)}`);h=c.toUpperCase(),g=u}if(!l.includes(h))throw r(`"${d.method}" is not an HTTP method.`,`Methods: ${l.join(`, `)}`);if(/^[a-z][a-z0-9+.-]*:\/\//i.test(g))throw r(`api takes a path, not a URL.`,`This CLI only ever talks to the resolved API host. Try: ${n.binName} api /mentions`);let _=o(),v=f(d.query).toString(),y=`${_.apiUrl}${g.startsWith(`/`)?g:`/${g}`}${v?`?${v}`:``}`,b=await m(d.data,d.dataFile,h),x=s(),S={Accept:`application/json`,"User-Agent":a(n.id),..._.workspaceId?{"X-Workspace-Id":_.workspaceId}:{},...p(d.header),Authorization:`Bearer ${_.token}`};b!==void 0&&(S[`Content-Type`]=`application/json`),x&&(S[`x-language`]=x);let C;try{C=await fetch(y,{method:h,headers:S,body:b,signal:AbortSignal.timeout(12e4)})}catch(t){throw new i(`Could not reach ${_.apiUrl}: ${t instanceof Error?t.message:String(t)}`,{exitCode:e.NETWORK,cause:t})}if(d.include){process.stderr.write(`HTTP ${C.status} ${C.statusText}\n`);for(let[e,t]of[...C.headers].sort())process.stderr.write(`${e}: ${t}\n`);process.stderr.write(`
2
+ `)}let w=await C.text();if(!C.ok){let e=`${h} ${g} failed with ${C.status}`,n=null;try{let t=JSON.parse(w);n=t,Array.isArray(t.message)?e=t.message.join(`; `):typeof t.message==`string`&&(e=t.message)}catch{w.trim()!==``&&(e=w.trim())}throw new i(e,{exitCode:t(C.status),details:n})}if(w===``)return;let T=w;if(process.stdout.isTTY)try{T=JSON.stringify(JSON.parse(w),null,2)}catch{T=w}process.stdout.write(T.endsWith(`
3
+ `)?T:`${T}\n`)})}export{h as registerApiCommand};
@@ -0,0 +1 @@
1
+ import{o as e}from"./exit-codes-Dof7Nstu.js";import{h as t,n}from"./errors-DLtuFXHR.js";import"./version-DUOAxI9S.js";import"./color-BbAK7_Y7.js";import{c as r,f as i,g as a,i as o,p as s}from"./output-DNozQoTg.js";import{C as c,F as l,I as u,L as d,M as f,N as p,P as m,S as h,b as g,l as _,m as v,p as y,s as b,v as x,x as S}from"./config-eE6NRs2j.js";import{c as C,l as w}from"./http-CbGjDmPT.js";import{n as T,r as E}from"./prompt-4XL3T1kl.js";import{t as D}from"./open-url-at-ONE2w.js";import{_ as O}from"./client-BWzucJSi.js";const k=t.tokenPrefixes[0];function A(e){return e.map(e=>e.domain).sort()}function j(e){return e.reduce((e,t)=>e+t.keywords.filter(e=>e.status===`ACTIVE`).length,0)}async function M(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString(`utf8`)}function N(r){if(t.tokenPrefixes.some(e=>r.startsWith(e)))return;if(r.split(`.`).length===3)throw new n(`That looks like an OAuth JWT, not an API token.`,{exitCode:e.AUTH,code:`unsupported_token`,hint:`OAuth login is not supported yet. Create an API token at ${t.tokensUrl}`});let i=r.indexOf(`_`),a=i>0?r.slice(0,i+1):``;throw new n(a?`That token starts with ${a}. ${t.binName} expects ${k}.`:`That does not look like a ${t.displayName} API token, which starts with ${k}.`,{exitCode:e.AUTH,code:`wrong_token_prefix`,hint:`Create one at ${t.tokensUrl}`})}async function P(r,i){if(r){let r=(await M()).trim();if(r===``)throw new n(`Nothing arrived on stdin.`,{exitCode:e.USAGE,code:`empty_stdin`,hint:`echo "$${t.envPrefix}_API_TOKEN" | ${t.binName} login --token-stdin`});return r}return i.token&&i.token.trim()!==``?i.token.trim():(await E(`Token (starts with ${k})`,{hint:`Pass --token-stdin and pipe the token in, or set ${t.envPrefix}_API_TOKEN`})).trim()}function F(E){E.command(`login`).description(`store a ${t.displayName} API token on this machine`).option(`--token-stdin`,`read the token from stdin instead of prompting`).option(`--name <label>`,`human label stored with the profile`).action(async e=>{let n=y(),r=c(),l=g(n,m(r)?.apiUrl).url;!e.tokenStdin&&!n.token&&(o(`Opening ${t.tokensUrl} in your browser.`),o(`Create a token, then paste it here.`),o(`API tokens need a plan with API access, so the token page errors on the free plan.`),D(t.tokensUrl));let f=await P(!!e.tokenStdin,n);N(f),C({profile:{name:r,token:f,tokenSource:`flag`,apiUrl:l,defaults:x(r)},debug:v(),language:S(),quiet:n.quiet===!0});let{websites:p}=await O(),h=A(p),_=j(p);d(r,{token:f,apiUrl:l,label:e.name},{makeCurrent:!0}),s(`login`,{profile:r,apiUrl:l,tokenPrefix:u(f),label:e.name??null,sites:p.length,domains:h,activeKeywords:_,credentialsPath:b()}),a(`Token valid`),i([[`profile`,r],...e.name?[[`label`,e.name]]:[],[`api`,l],[`sites`,`${p.length} monitored`],...h.length>0?[[`domains`,h.join(`, `)]]:[],[`keywords`,`${_} active`],[`stored in`,`${b()} (0600)`]])}),E.command(`logout`).description(`remove a stored token`).option(`--all`,`remove every profile`).action(async i=>{let a=y(),o=l();if(o.length===0)throw new n(`There are no stored profiles to remove.`,{exitCode:e.NOT_FOUND,code:`no_profiles`,hint:`${t.binName} login`});let u=c(),d=i.all?o.map(e=>e.name):[u];if(!i.all&&!o.some(e=>e.name===u))throw new n(`No profile named "${u}".`,{exitCode:e.NOT_FOUND,code:`unknown_profile`,hint:`Stored profiles: ${o.map(e=>e.name).join(`, `)}`});if(!await T(i.all?`Remove all ${d.length} profiles?`:`Remove profile "${u}"?`,{assumeYes:a.yes===!0,initialValue:!1})){r(`Nothing removed.`);return}i.all?f():p(u),s(`logout`,{removed:d}),r(i.all?`Removed all ${d.length} profiles.`:`Removed profile "${u}".`),r(`The token is still valid, revoke it at ${t.tokensUrl}`)}),E.command(`whoami`).description(`show which token is in use and what it can see`).action(async()=>{let e=h(),{websites:t}=await O(),n=A(t),r=j(t),a=w();s(`whoami`,{profile:e.name,tokenPrefix:u(e.token),tokenSource:e.tokenSource,apiUrl:e.apiUrl,sites:t.length,domains:n,activeKeywords:r},a?.limit!==void 0&&a.remaining!==void 0?{rateLimit:{limit:a.limit,remaining:a.remaining,resetSeconds:a.reset??0}}:void 0),i([[`profile`,e.name],[`token`,`${u(e.token)} (from ${_(e.tokenSource)})`],[`api`,e.apiUrl],[`sites`,`${t.length} ${t.length===1?`site`:`sites`}${n.length>0?` (${n.join(`, `)})`:``}`],[`keywords`,`${r} active`],...typeof e.defaults.defaultSite==`string`?[[`default site`,`${e.defaults.defaultSite} (from config.json)`]]:[],...a?.remaining!==void 0&&a.limit!==void 0?[[`limits`,`${a.remaining} of ${a.limit} requests left this minute`]]:[]]),o(`There is no /me endpoint, so this is read back from your monitored sites.`)})}export{N as assertTokenShape,F as registerAuthCommands};
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  const e=`22.12.0`;function t(e,t){let n=e.split(`.`),r=t.split(`.`);for(let e=0;e<3;e+=1){let t=Number.parseInt(n[e]??`0`,10)||0,i=Number.parseInt(r[e]??`0`,10)||0;if(t!==i)return t<i}return!1}t(process.versions.node,e)&&(process.stderr.write(`redreplier needs Node ${e} or newer, this is Node ${process.versions.node}. Install a current Node from https://nodejs.org and try again.
3
- `),process.exit(2));const{Command:n,Option:r}=await import(`./esm-CIPTesEn.js`),{ExitCode:i}=await import(`./exit-codes-CEqGHMR7.js`),{PRODUCT:a,setGlobalOptions:o}=await import(`./config-BEJ8cdXh.js`),{versionLine:s}=await import(`./version-DY0tYOG7.js`),c=[[`-p, --profile <name>`,`credential profile to use`],[`--json`,`force machine-readable JSON output`],[`-q, --quiet`,`suppress spinners, hints and notices`],[`--no-color`,`strip ANSI colour from the output`],[`--debug`,`log every request to stderr`],[`--api-url <url>`,`override the API base URL`],[`--token <token>`,`use this token for one invocation`],[`-y, --yes`,`answer yes to every confirmation`],[`--no-input`,`never prompt, fail with exit 2 instead`],[`--lang <code>`,`language for the x-language header: en, fr, de, es, pt`],[`--full-ids`,`print identifiers in full instead of truncating`]],l=[`profile`,`json`,`quiet`,`color`,`debug`,`apiUrl`,`token`,`yes`,`input`,`lang`,`fullIds`],u=new Set([`-p`,`--profile`,`--api-url`,`--token`,`--lang`]),d=`--help-all`,f=[{names:[`login`,`logout`,`whoami`],load:async()=>(await import(`./auth-DqEbz2Jy.js`)).registerAuthCommands},{names:[`config`],load:async()=>(await import(`./config-53zPXLzs.js`)).registerConfigCommands},{names:[`doctor`],load:async()=>(await import(`./doctor-Dch8UtNo.js`)).registerDoctorCommand},{names:[`completion`],load:async()=>(await import(`./completion-EvS24LbX.js`)).registerCompletionCommand},{names:[`mcp`],load:async()=>(await import(`./mcp-CBygu84l.js`)).registerMcpCommand},{names:[`api`],load:async()=>(await import(`./api-W7BP64iK.js`)).registerApiCommand},{names:[`open`],load:async()=>(await import(`./open-r4fRMoJ3.js`)).registerOpenCommand},{names:[`site`,`sites`],load:async()=>(await import(`./site-QTLQZ_Fy.js`)).registerSiteCommands},{names:[`keyword`,`keywords`,`kw`],load:async()=>(await import(`./keyword-BY2TX0l4.js`)).registerKeywordCommands},{names:[`mention`,`mentions`],load:async()=>(await import(`./mention-CXKnBCsd.js`)).registerMentionCommands},{names:[`alerts`,`alert`],load:async()=>(await import(`./alert-WTyiaFxJ.js`)).registerAlertCommands},{names:[`mean-marketer`,`mm`],load:async()=>(await import(`./alert-WTyiaFxJ.js`)).registerMeanMarketerCommands}];function p(e){for(let t=2;t<e.length;t+=1){let n=e[t];if(n===`--`)return;if(n.startsWith(`-`)){!n.includes(`=`)&&u.has(n)&&(t+=1);continue}return n}}function m(e,t){let n=e.slice(2);return n.includes(`-h`)||n.includes(`--help`)||n.includes(d)?!0:t===void 0?!n.includes(`-V`)&&!n.includes(`--version`):t===`help`||t===`completion`?!0:!f.some(e=>e.names.includes(t))}async function h(e,t){let n=p(t),r=m(t,n)?f:f.filter(e=>e.names.includes(n));for(let t of r)(await t.load())(e)}function g(e,t){for(let n of e.options)if(n.attributeName()===t.attributeName()||t.short&&(n.short===t.short||n.long===t.short)||t.long&&(n.long===t.long||n.short===t.long))return!0;return!1}function _(e){for(let[t,n]of c){let i=new r(t,n).hideHelp(e.parent!==null);g(e,i)||e.addOption(i)}for(let t of e.commands)_(t)}function v(e){let t=[];for(let n=e;n;n=n.parent)t.unshift(n);let n={};for(let e of t)for(let t of l){let r=e.getOptionValueSource(t);(r===`cli`||r===`env`)&&(n[t]=e.getOptionValue(t))}return n.color===void 0&&(n.color=!0),n.input===void 0&&(n.input=!!process.stdin.isTTY),n}function y(e){let t=[];for(let n=e;n&&n.parent;n=n.parent)t.unshift(n.name());return t.join(`.`)||e.name()}let b=a.binName,x={},S=``;function C(e){if(!(e instanceof Error))return!1;let t=e.code;return typeof t==`string`&&t.startsWith(`commander.`)}async function w(e){let{isMachine:t,printError:n}=await import(`./output-Cye9q83I.js`);if(C(e)){if(e.code===`commander.version`||e.code===`commander.helpDisplayed`)return process.stdout.write(S),i.OK;if(e.code===`commander.help`)return process.stderr.write(S),i.USAGE;if(t()){let{usageError:t}=await import(`./errors-D1qbI3dY.js`);return n(t(S.trim()||e.message),b)}return process.stderr.write(S),i.USAGE}return process.stderr.write(S),n(e,b)}process.on(`SIGINT`,()=>{process.stderr.write(`
4
- `),process.exit(i.CANCELLED)});const T=new n;T.name(a.binName).description(`${a.displayName} from your terminal`).version(s(a.binName),`-V, --version`,`print the version, node and platform`).helpOption(`-h, --help`,`show help for a command`).showSuggestionAfterError(!0).enablePositionalOptions().exitOverride().configureOutput({writeErr:e=>{S+=e},writeOut:e=>{S+=e}}),T.hook(`preAction`,async(e,t)=>{let n=v(t),r=y(t);b=r,x=n,o(n);let{detectColorEnabled:i,setColorEnabled:s}=await import(`./color-D6__4GPX.js`),{setInteractive:c}=await import(`./prompt-BXyNKU0M.js`),{configureHttp:l}=await import(`./http-DNUc-MW8.js`);s(i({noColor:n.color===!1})),E({json:n.json,quiet:n.quiet,fullIds:n.fullIds,command:r,envPrefix:a.envPrefix}),c(n.input!==!1),l(n)});for(let[e,t]of c)T.addOption(new r(e,t));T.addOption(new r(d,`show help including the experimental commands`)),await h(T,process.argv),_(T);const{initOutput:E}=await import(`./output-Cye9q83I.js`);E({json:process.argv.includes(`--json`),envPrefix:a.envPrefix}),process.argv.includes(d)&&(T.configureHelp({visibleCommands:e=>[...e.commands]}),process.stdout.write(T.helpInformation()),process.exit(i.OK));try{await T.parseAsync(process.argv),process.stdout.write(S),S=``;let{runUpdateCheck:e}=await import(`./update-check-BvMnC6lH.js`);await e({quiet:x.quiet===!0}),process.exitCode===void 0&&(process.exitCode=i.OK)}catch(e){process.exitCode=await w(e)}export{};
3
+ `),process.exit(2));const{Command:n,Option:r}=await import(`./esm-CIPTesEn.js`),{ExitCode:i}=await import(`./exit-codes-CyB7Jo1I.js`),{PRODUCT:a,setGlobalOptions:o}=await import(`./config-SzcelmNd.js`),{versionLine:s}=await import(`./version-YGhP26LK.js`),c=[[`-p, --profile <name>`,`credential profile to use`],[`--json`,`force machine-readable JSON output`],[`-q, --quiet`,`suppress spinners, hints and notices`],[`--no-color`,`strip ANSI colour from the output`],[`--debug`,`log every request to stderr`],[`--api-url <url>`,`override the API base URL`],[`--token <token>`,`use this token for one invocation`],[`-y, --yes`,`answer yes to every confirmation`],[`--no-input`,`never prompt, fail with exit 2 instead`],[`--lang <code>`,`language for the x-language header: en, fr, de, es, pt`],[`--full-ids`,`print identifiers in full instead of truncating`]],l=[`profile`,`json`,`quiet`,`color`,`debug`,`apiUrl`,`token`,`yes`,`input`,`lang`,`fullIds`],u=new Set([`-p`,`--profile`,`--api-url`,`--token`,`--lang`]),d=`--help-all`,f=[{names:[`login`,`logout`,`whoami`],load:async()=>(await import(`./auth-DpNnCwwh.js`)).registerAuthCommands},{names:[`config`],load:async()=>(await import(`./config-BEGhiorY.js`)).registerConfigCommands},{names:[`doctor`],load:async()=>(await import(`./doctor-B-Hso4GL.js`)).registerDoctorCommand},{names:[`completion`],load:async()=>(await import(`./completion-B4zIAjmZ.js`)).registerCompletionCommand},{names:[`mcp`],load:async()=>(await import(`./mcp-nN06w2tF.js`)).registerMcpCommand},{names:[`api`],load:async()=>(await import(`./api-B3rh3sU0.js`)).registerApiCommand},{names:[`open`],load:async()=>(await import(`./open-BLS-D6GL.js`)).registerOpenCommand},{names:[`site`,`sites`],load:async()=>(await import(`./site-CZHkjUpC.js`)).registerSiteCommands},{names:[`keyword`,`keywords`,`kw`],load:async()=>(await import(`./keyword-Ct0Aue-0.js`)).registerKeywordCommands},{names:[`mention`,`mentions`],load:async()=>(await import(`./mention-DZytkT4_.js`)).registerMentionCommands},{names:[`alerts`,`alert`],load:async()=>(await import(`./alert-ChEB-ZUO.js`)).registerAlertCommands},{names:[`mean-marketer`,`mm`],load:async()=>(await import(`./alert-ChEB-ZUO.js`)).registerMeanMarketerCommands}];function p(e){for(let t=2;t<e.length;t+=1){let n=e[t];if(n===`--`)return;if(n.startsWith(`-`)){!n.includes(`=`)&&u.has(n)&&(t+=1);continue}return n}}function m(e,t){let n=e.slice(2);return n.includes(`-h`)||n.includes(`--help`)||n.includes(d)?!0:t===void 0?!n.includes(`-V`)&&!n.includes(`--version`):t===`help`||t===`completion`?!0:!f.some(e=>e.names.includes(t))}async function h(e,t){let n=p(t),r=m(t,n)?f:f.filter(e=>e.names.includes(n));for(let t of r)(await t.load())(e)}function g(e,t){for(let n of e.options)if(n.attributeName()===t.attributeName()||t.short&&(n.short===t.short||n.long===t.short)||t.long&&(n.long===t.long||n.short===t.long))return!0;return!1}function _(e){for(let[t,n]of c){let i=new r(t,n).hideHelp(e.parent!==null);g(e,i)||e.addOption(i)}for(let t of e.commands)_(t)}function v(e){let t=[];for(let n=e;n;n=n.parent)t.unshift(n);let n={};for(let e of t)for(let t of l){let r=e.getOptionValueSource(t);(r===`cli`||r===`env`)&&(n[t]=e.getOptionValue(t))}return n.color===void 0&&(n.color=!0),n.input===void 0&&(n.input=!!process.stdin.isTTY),n}function y(e){let t=[];for(let n=e;n&&n.parent;n=n.parent)t.unshift(n.name());return t.join(`.`)||e.name()}let b=a.binName,x={},S=``;function C(e){if(!(e instanceof Error))return!1;let t=e.code;return typeof t==`string`&&t.startsWith(`commander.`)}async function w(e){let{isMachine:t,printError:n}=await import(`./output-DV-8Js8u.js`);if(C(e)){if(e.code===`commander.version`||e.code===`commander.helpDisplayed`)return process.stdout.write(S),i.OK;if(e.code===`commander.help`)return process.stderr.write(S),i.USAGE;if(t()){let{usageError:t}=await import(`./errors-CDuXb8cW.js`);return n(t(S.trim()||e.message),b)}return process.stderr.write(S),i.USAGE}return process.stderr.write(S),n(e,b)}process.on(`SIGINT`,()=>{process.stderr.write(`
4
+ `),process.exit(i.CANCELLED)});const T=new n;T.name(a.binName).description(`${a.displayName} from your terminal`).version(s(a.binName),`-V, --version`,`print the version, node and platform`).helpOption(`-h, --help`,`show help for a command`).showSuggestionAfterError(!0).enablePositionalOptions().exitOverride().configureOutput({writeErr:e=>{S+=e},writeOut:e=>{S+=e}}),T.hook(`preAction`,async(e,t)=>{let n=v(t),r=y(t);b=r,x=n,o(n);let{detectColorEnabled:i,setColorEnabled:s}=await import(`./color-D6__4GPX.js`),{setInteractive:c}=await import(`./prompt-CdMTCvG1.js`),{configureHttp:l}=await import(`./http-Dm3cTW8q.js`);s(i({noColor:n.color===!1})),E({json:n.json,quiet:n.quiet,fullIds:n.fullIds,command:r,envPrefix:a.envPrefix}),c(n.input!==!1),l(n)});for(let[e,t]of c)T.addOption(new r(e,t));T.addOption(new r(d,`show help including the experimental commands`)),await h(T,process.argv),_(T);const{initOutput:E}=await import(`./output-DV-8Js8u.js`);E({json:process.argv.includes(`--json`),envPrefix:a.envPrefix}),process.argv.includes(d)&&(T.configureHelp({visibleCommands:e=>[...e.commands]}),process.stdout.write(T.helpInformation()),process.exit(i.OK));try{await T.parseAsync(process.argv),process.stdout.write(S),S=``;let{runUpdateCheck:e}=await import(`./update-check-OIfTu8xz.js`);await e({quiet:x.quiet===!0}),process.exitCode===void 0&&(process.exitCode=i.OK)}catch(e){process.exitCode=await w(e)}export{};
@@ -1 +1 @@
1
- import{d as e}from"./http-DAgILPv-.js";const t=e=>encodeURIComponent(e),n=()=>e({method:`GET`,path:`/websites`}),r=n=>e({method:`GET`,path:`/websites/${t(n)}`}),i=t=>e({method:`POST`,path:`/websites`,body:t}),a=(n,r)=>e({method:`PATCH`,path:`/websites/${t(n)}`,body:r}),o=n=>e({method:`DELETE`,path:`/websites/${t(n)}`}),s=t=>e({method:`POST`,path:`/websites/analyze-description`,body:t}),c=(n,r)=>e({method:`POST`,path:`/websites/${t(n)}/keywords`,body:r}),l=(n,r)=>e({method:`PATCH`,path:`/keywords/${t(n)}`,body:r}),u=n=>e({method:`POST`,path:`/keywords/${t(n)}/disable`,idempotent:!0}),d=n=>e({method:`POST`,path:`/keywords/${t(n)}/enable`,idempotent:!0}),f=n=>e({method:`DELETE`,path:`/keywords/${t(n)}`}),p=()=>e({method:`POST`,path:`/keywords/activate-pending`,idempotent:!0}),m=()=>e({method:`GET`,path:`/keywords/activate-pending/preview`}),h=t=>e({method:`GET`,path:`/keywords/billing-preview`,query:t}),g=()=>e({method:`GET`,path:`/keywords/change-usage`}),_=(t={})=>e({method:`GET`,path:`/mentions`,query:t}),v=(t={})=>e({method:`GET`,path:`/mentions/count`,query:t}),y=(n,r)=>e({method:`PATCH`,path:`/mentions/${t(n)}/status`,body:r}),b=n=>e({method:`POST`,path:`/mentions/${t(n)}/explain`,idempotent:!0}),x=()=>e({method:`GET`,path:`/alert-settings`}),S=t=>e({method:`PUT`,path:`/alert-settings`,body:t}),C=()=>e({method:`GET`,path:`/mean-marketer/config`}),w=t=>e({method:`PUT`,path:`/mean-marketer/config`,body:t}),T=()=>e({method:`POST`,path:`/mean-marketer/poll`}),E=()=>e({method:`POST`,path:`/mean-marketer/reset`,idempotent:!0});export{w as C,S,a as T,n as _,i as a,h as b,u as c,b as d,x as f,_ as g,r as h,v as i,l,C as m,c as n,f as o,g as p,s as r,o as s,p as t,d as u,T as v,y as w,E as x,m as y};
1
+ import{d as e}from"./http-CbGjDmPT.js";const t=e=>encodeURIComponent(e),n=()=>e({method:`GET`,path:`/websites`}),r=n=>e({method:`GET`,path:`/websites/${t(n)}`}),i=t=>e({method:`POST`,path:`/websites`,body:t}),a=(n,r)=>e({method:`PATCH`,path:`/websites/${t(n)}`,body:r}),o=n=>e({method:`DELETE`,path:`/websites/${t(n)}`}),s=t=>e({method:`POST`,path:`/websites/analyze-description`,body:t}),c=(n,r)=>e({method:`POST`,path:`/websites/${t(n)}/keywords`,body:r}),l=(n,r)=>e({method:`PATCH`,path:`/keywords/${t(n)}`,body:r}),u=n=>e({method:`POST`,path:`/keywords/${t(n)}/disable`,idempotent:!0}),d=n=>e({method:`POST`,path:`/keywords/${t(n)}/enable`,idempotent:!0}),f=n=>e({method:`DELETE`,path:`/keywords/${t(n)}`}),p=()=>e({method:`POST`,path:`/keywords/activate-pending`,idempotent:!0}),m=()=>e({method:`GET`,path:`/keywords/activate-pending/preview`}),h=t=>e({method:`GET`,path:`/keywords/billing-preview`,query:t}),g=()=>e({method:`GET`,path:`/keywords/change-usage`}),_=(t={})=>e({method:`GET`,path:`/mentions`,query:t}),v=(t={})=>e({method:`GET`,path:`/mentions/count`,query:t}),y=(n,r)=>e({method:`PATCH`,path:`/mentions/${t(n)}/status`,body:r}),b=n=>e({method:`POST`,path:`/mentions/${t(n)}/explain`,idempotent:!0}),x=()=>e({method:`GET`,path:`/alert-settings`}),S=t=>e({method:`PUT`,path:`/alert-settings`,body:t}),C=()=>e({method:`GET`,path:`/mean-marketer/config`}),w=t=>e({method:`PUT`,path:`/mean-marketer/config`,body:t}),T=()=>e({method:`POST`,path:`/mean-marketer/poll`}),E=()=>e({method:`POST`,path:`/mean-marketer/reset`,idempotent:!0});export{w as C,S,a as T,n as _,i as a,h as b,u as c,b as d,x as f,_ as g,r as h,v as i,l,C as m,c as n,f as o,g as p,s as r,o as s,p as t,d as u,T as v,y as w,E as x,m as y};
@@ -1,4 +1,4 @@
1
- import"./exit-codes-eYq58Sw_.js";import{m as e}from"./errors-DK8JR_St.js";import"./color-BbAK7_Y7.js";import{c as t,p as n}from"./output-CDjsADAT.js";import{t as r}from"./product-CXL7Ga4M.js";const i=[`bash`,`zsh`,`fish`,`powershell`];function a(e){return i.includes(e)}function o(t){if(!a(t))throw e(`Unknown shell "${t}".`,`Supported shells: ${i.join(`, `)}.`);return t}function s(e,t={}){return u(e,[t.name??e.name()],e)}function c(t,n,r={}){let i=s(t,r);switch(n){case`bash`:return _(i);case`zsh`:return v(i);case`fish`:return y(i);case`powershell`:return b(i);default:throw e(`Unknown shell "${String(n)}".`)}}function l(e,t){switch(e){case`bash`:return[`# Load ${t} completions for the current shell:`,`# eval "$(${t} completion bash)"`,`# Or install them permanently:`,`# ${t} completion bash > /etc/bash_completion.d/${t}`].join(`
1
+ import"./exit-codes-Dof7Nstu.js";import{h as e,m as t}from"./errors-DLtuFXHR.js";import"./color-BbAK7_Y7.js";import{c as n,p as r}from"./output-DNozQoTg.js";const i=[`bash`,`zsh`,`fish`,`powershell`];function a(e){return i.includes(e)}function o(e){if(!a(e))throw t(`Unknown shell "${e}".`,`Supported shells: ${i.join(`, `)}.`);return e}function s(e,t={}){return u(e,[t.name??e.name()],e)}function c(e,n,r={}){let i=s(e,r);switch(n){case`bash`:return _(i);case`zsh`:return v(i);case`fish`:return y(i);case`powershell`:return b(i);default:throw t(`Unknown shell "${String(n)}".`)}}function l(e,t){switch(e){case`bash`:return[`# Load ${t} completions for the current shell:`,`# eval "$(${t} completion bash)"`,`# Or install them permanently:`,`# ${t} completion bash > /etc/bash_completion.d/${t}`].join(`
2
2
  `);case`zsh`:return[`# Load ${t} completions for the current shell:`,`# eval "$(${t} completion zsh)"`,`# Or install them permanently:`,`# ${t} completion zsh > "\${fpath[1]}/_${t}"`].join(`
3
3
  `);case`fish`:return[`# Load ${t} completions for the current shell:`,`# ${t} completion fish | source`,`# Or install them permanently:`,`# ${t} completion fish > ~/.config/fish/completions/${t}.fish`].join(`
4
4
  `);case`powershell`:return[`# Load ${t} completions for the current session:`,`# ${t} completion powershell | Out-String | Invoke-Expression`,`# Or append that line to $PROFILE.`].join(`
@@ -77,5 +77,5 @@ Register-ArgumentCompleter -Native -CommandName ${e.name} -ScriptBlock {
77
77
  [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
78
78
  }
79
79
  }
80
- `}function x(e){e.command(`completion`).argument(`[shell]`,`one of ${i.join(`, `)}`).description(`print the shell completion script`).action((a,s,u)=>{let d=u.parent??e;if(a===void 0){let e=Object.fromEntries(i.map(e=>[e,l(e,r.binName)]));n(`completion`,{shells:[...i],instructions:e}),t(`Pick a shell: ${r.binName} completion <shell>`),t(``);for(let e of i){t(` ${e}`);for(let n of l(e,r.binName).split(`
81
- `))t(` ${n}`);t(``)}return}let f=o(a.toLowerCase());process.stdout.write(`${c(d,f,{name:r.binName}).trimEnd()}\n`),process.stderr.write(`${l(f,r.binName)}\n`)})}export{x as registerCompletionCommand};
80
+ `}function x(t){t.command(`completion`).argument(`[shell]`,`one of ${i.join(`, `)}`).description(`print the shell completion script`).action((a,s,u)=>{let d=u.parent??t;if(a===void 0){let t=Object.fromEntries(i.map(t=>[t,l(t,e.binName)]));r(`completion`,{shells:[...i],instructions:t}),n(`Pick a shell: ${e.binName} completion <shell>`),n(``);for(let t of i){n(` ${t}`);for(let r of l(t,e.binName).split(`
81
+ `))n(` ${r}`);n(``)}return}let f=o(a.toLowerCase());process.stdout.write(`${c(d,f,{name:e.binName}).trimEnd()}\n`),process.stderr.write(`${l(f,e.binName)}\n`)})}export{x as registerCompletionCommand};
@@ -0,0 +1 @@
1
+ import"./exit-codes-Dof7Nstu.js";import{d as e,h as t}from"./errors-DLtuFXHR.js";import{r as n}from"./color-BbAK7_Y7.js";import{c as r,f as i,g as a,i as o,p as s}from"./output-DNozQoTg.js";import{C as c,E as l,a as u,f as d,h as f,o as p,s as m,t as h,w as g}from"./config-eE6NRs2j.js";const _=()=>c();function v(c){let v=c.command(`config`).description(`read and write CLI preferences`);v.command(`list`).alias(`ls`).description(`show every key and its value`).action(()=>{let e=_(),{entries:t}=f(e);s(`config.list`,{profile:e,entries:t}),r(` profile: ${e}`),i(t.map(e=>[e.key,e.value===void 0||e.value===null?n(`unset`):u(e.key).format(e.value)]))}),v.command(`get`).argument(`<key>`,`one of ${Object.keys(h).join(`, `)}`).description(`print one value`).action(n=>{let i=u(n),a=_(),o=d(n,a);if(o==null)throw e(`"${n}" is not set for profile "${a}".`,`${t.binName} config set ${n} <value>`);s(`config.get`,{key:n,value:o}),r(i.format(o))}),v.command(`set`).argument(`<key>`,`one of ${Object.keys(h).join(`, `)}`).argument(`<value>`,`new value`).description(`write one value`).action((e,t)=>{let n=u(e),r=_(),i=g(e,t,r);s(`config.set`,{key:e,value:i,scope:n.scope,profile:r}),a(`${e} = ${n.format(i)}`)}),v.command(`unset`).argument(`<key>`,`one of ${Object.keys(h).join(`, `)}`).description(`remove one value`).action(e=>{let t=_(),n=l(e,t);s(`config.unset`,{key:e,removed:n,profile:t}),n?a(`${e} removed`):o(`${e} was not set, nothing changed.`)}),v.command(`path`).description(`print the config and credentials file paths`).action(()=>{let e=p(),t=m();s(`config.path`,{config:e,credentials:t}),i([[`config`,e],[`credentials`,t]])})}export{v as registerConfigCommands};
@@ -0,0 +1 @@
1
+ import"./exit-codes-Dof7Nstu.js";import{h as e}from"./errors-DLtuFXHR.js";import{C as t,D as n,E as r,O as i,S as a,T as o,_ as s,a as c,b as l,c as u,d,f,g as p,h as m,i as h,k as g,l as _,m as v,n as y,o as b,p as x,r as S,s as C,t as w,u as T,v as E,w as D,x as O,y as k}from"./config-eE6NRs2j.js";export{w as CONFIG_KEYS,y as CONFIG_VERSION,S as LANGUAGES,e as PRODUCT,h as configDir,c as configKey,b as configPath,C as credentialsPath,u as describeApiUrlSource,_ as describeTokenSource,T as ensureConfigDir,d as envVar,f as getConfigValue,x as getGlobalOptions,v as isDebugEnabled,m as listConfigValues,p as normalizeApiUrl,s as productConfigKeys,E as profileDefaults,k as readConfig,l as resolveApiUrl,O as resolveLanguage,a as resolveProfile,t as resolveProfileName,D as setConfigValue,o as setGlobalOptions,r as unsetConfigValue,n as updateConfig,i as writeConfig,g as writeFileAtomic};
@@ -0,0 +1 @@
1
+ import{o as e}from"./exit-codes-Dof7Nstu.js";import{h as t,n}from"./errors-DLtuFXHR.js";import{basename as r,dirname as i,join as a}from"node:path";import{chmodSync as o,existsSync as s,mkdirSync as c,readFileSync as l,renameSync as u,rmSync as d,statSync as f,writeFileSync as ee}from"node:fs";import{randomBytes as te}from"node:crypto";import{homedir as p}from"node:os";function m(e){let t=e.trim();if(t===``)return``;let n=t.lastIndexOf(`_`),r=n>=0?n+1:0;return t.slice(0,Math.min(t.length,r+4))}function h(e){if(!e)return`…`;let t=m(e);return t.length>=e.length?t:`${t}…`}function g(){return{version:1,current:`default`,profiles:{}}}function _(){return s(N())}function v(){let e=N();if(s(e))return f(e).mode&511}function y(){if(process.platform===`win32`)return;let t=v();if(t===void 0||!(t&63))return;let r=N();throw new n(`${r} is readable by other users (mode ${t.toString(8).padStart(4,`0`)})`,{exitCode:e.AUTH,hint:`chmod 600 ${r}`})}function b(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=typeof t.token==`string`?t.token:void 0;if(!n)return;let r={token:n,tokenPrefix:typeof t.tokenPrefix==`string`?t.tokenPrefix:m(n),...typeof t.apiUrl==`string`?{apiUrl:t.apiUrl}:{},...typeof t.label==`string`?{label:t.label}:{},...typeof t.createdAt==`string`?{createdAt:t.createdAt}:{}};return t.type===`oauth`?{...r,type:`oauth`,refreshToken:typeof t.refreshToken==`string`?t.refreshToken:``,expiresAt:typeof t.expiresAt==`string`?t.expiresAt:``,authkitDomain:typeof t.authkitDomain==`string`?t.authkitDomain:``}:{...r,type:`token`}}function x(){let t=N();if(!s(t))return g();y();let r;try{r=JSON.parse(l(t,`utf8`))}catch(r){throw new n(`${t} is not valid JSON`,{exitCode:e.GENERIC,hint:`Fix the file, or start over with: rm ${t}`,cause:r})}if(!r||typeof r!=`object`||Array.isArray(r))return g();let i=r,a={};for(let[e,t]of Object.entries(i.profiles??{})){let n=b(t);n&&(a[e]=n)}return{version:typeof i.version==`number`?i.version:1,current:typeof i.current==`string`&&i.current!==``?i.current:`default`,profiles:a}}function S(e){P(),F(N(),`${JSON.stringify(e,null,2)}\n`,384)}function C(e){return x().profiles[e]}function w(){let e=x();return Object.entries(e.profiles).map(([t,n])=>({name:t,current:t===e.current,profile:n}))}function ne(e,t,n={}){let r=x(),i=r.profiles[e],a={token:t.token,tokenPrefix:m(t.token),...t.apiUrl?{apiUrl:t.apiUrl}:i?.apiUrl?{apiUrl:i.apiUrl}:{},...t.label?{label:t.label}:i?.label?{label:i.label}:{},createdAt:i?.createdAt??new Date().toISOString()},o=t.type===`oauth`?{...a,type:`oauth`,refreshToken:t.refreshToken??``,expiresAt:t.expiresAt??``,authkitDomain:t.authkitDomain??``}:{...a,type:`token`};return r.profiles[e]=o,n.makeCurrent!==!1&&(r.current=e),S(r),o}function re(e){let t=x();return t.profiles[e]?(delete t.profiles[e],t.current===e&&(t.current=Object.keys(t.profiles)[0]??`default`),S(t),!0):!1}function ie(){let e=x(),t=Object.keys(e.profiles).length;return S(g()),t}const ae=1,T=[`en`,`fr`,`de`,`es`,`pt`];let E={};function D(e){E={...e}}function O(){return E}function k(e){return`${t.envPrefix}_${e}`}function A(e){let t=process.env[k(e)];if(t===void 0)return;let n=t.trim();return n===``?void 0:n}function j(){if(process.platform===`win32`){let e=process.env.APPDATA?.trim();if(e)return a(e,t.displayName)}let e=process.env.XDG_CONFIG_HOME?.trim();return a(e&&e!==``?e:a(p(),`.config`),t.id)}function M(){return a(j(),`config.json`)}function N(){return a(j(),`credentials.json`)}function P(){let e=j();return c(e,{recursive:!0,mode:448}),e}function F(t,s,l){let f=i(t);c(f,{recursive:!0,mode:448});let p=a(f,`.${r(t)}.${process.pid}.${te(6).toString(`hex`)}.tmp`);try{ee(p,s,{mode:l}),o(p,l),u(p,t)}catch(r){throw d(p,{force:!0}),new n(`Could not write ${t}: ${r.message}`,{exitCode:e.GENERIC,cause:r})}}function I(){return{version:1,profiles:{}}}function L(){let t=M();if(!s(t))return I();let r;try{r=JSON.parse(l(t,`utf8`))}catch(r){throw new n(`${t} is not valid JSON`,{exitCode:e.GENERIC,hint:`Fix the file or delete it: rm ${t}`,cause:r})}if(!r||typeof r!=`object`||Array.isArray(r))return I();let i=r,a=i.profiles&&typeof i.profiles==`object`?i.profiles:{};return{...i,version:i.version??1,profiles:a}}function R(e){P(),F(M(),`${JSON.stringify(e,null,2)}\n`,420)}function z(e){let t=L();return e(t),R(t),t}function B(t){return r=>{let i=r.trim().toLowerCase();if([`true`,`1`,`yes`,`on`].includes(i))return!0;if([`false`,`0`,`no`,`off`].includes(i))return!1;throw new n(`${t} must be true or false, got "${r}"`,{exitCode:e.USAGE})}}function V(t){let r=t.trim();try{new Intl.DateTimeFormat(`en-US`,{timeZone:r})}catch{throw new n(`"${r}" is not an IANA timezone`,{exitCode:e.USAGE,hint:`Use a name such as Europe/Berlin or America/New_York`})}return r}function H(e){return e.split(`,`).map(e=>e.trim().toUpperCase()).filter(e=>e!==``)}function U(t){return r=>{let i=r.trim();if(i===``)throw new n(`${t} cannot be empty`,{exitCode:e.USAGE});return i}}function W(e){return e==null?``:Array.isArray(e)?e.join(`,`):String(e)}const G={updateCheck:{key:`updateCheck`,scope:`global`,products:`all`,description:`Check npm for a newer CLI once a day`,parse:B(`updateCheck`),format:W},language:{key:`language`,scope:`global`,products:`all`,description:`Value of the x-language header (${T.join(` `)})`,parse:t=>{let r=t.trim().toLowerCase();if(!T.includes(r))throw new n(`language must be one of ${T.join(`, `)}, got "${t}"`,{exitCode:e.USAGE});return r},format:W},timezone:{key:`timezone`,scope:`profile`,products:[`adaptlypost`],description:`Default value for --timezone`,parse:V,format:W},defaultPlatforms:{key:`defaultPlatforms`,scope:`profile`,products:[`adaptlypost`],description:`Default value for --platform, comma separated`,parse:H,format:W},defaultSite:{key:`defaultSite`,scope:`profile`,products:[`redreplier`],description:`Default value for --site`,parse:U(`defaultSite`),format:W},defaultWebsite:{key:`defaultWebsite`,scope:`profile`,products:[`flowsery`],description:`Default website for reporting commands`,parse:U(`defaultWebsite`),format:W},workspaceId:{key:`workspaceId`,scope:`profile`,products:`all`,description:`Workspace this profile talks to, sent as the X-Workspace-Id header`,parse:U(`workspaceId`),format:W}};function K(e){return e.products===`all`||e.products.includes(t.id)}function q(){return Object.values(G).filter(K)}function J(t){let r=G[t];if(!r||!K(r))throw new n(`Unknown config key "${t}"`,{exitCode:e.USAGE,hint:`Known keys: ${q().map(e=>e.key).join(`, `)}`});return r}function oe(e,t){let n=J(e),r=L();if(n.scope===`global`)return r[n.key];let i=t??Z();return r.profiles[i]?.[n.key]}function Y(e,t,n){let r=J(e),i=r.parse(t),a=n??Z();return z(e=>{if(r.scope===`global`){e[r.key]=i;return}let t=e.profiles[a]??{};t[r.key]=i,e.profiles[a]=t}),i}function se(e,t){let n=J(e),r=t??Z(),i=!1;return z(e=>{if(n.scope===`global`){i=e[n.key]!==void 0,delete e[n.key];return}let t=e.profiles[r];t&&(i=t[n.key]!==void 0,delete t[n.key])}),i}function ce(e){let t=e??Z(),n=L();return{profile:t,entries:q().map(e=>({key:e.key,scope:e.scope,description:e.description,value:e.scope===`global`?n[e.key]:n.profiles[t]?.[e.key]}))}}function X(e){let t=e??Z();return L().profiles[t]??{}}function Z(e=E){let t=e.profile?.trim();if(t)return t;let n=A(`PROFILE`);if(n)return n;let r=x(),i=r.current?.trim();return i&&r.profiles[i]?i:i||`default`}function Q(e=E,n){let r=e.apiUrl?.trim();if(r)return{url:$(r,`--api-url`),source:`flag`};let i=A(`API_URL`);if(i)return{url:$(i,k(`API_URL`)),source:`env`};let a=n?.trim();return a?{url:$(a,`credentials.json apiUrl`),source:`credentials`}:{url:t.defaultApiUrl,source:`default`}}function $(t,r){let i;try{i=new URL(t)}catch{throw new n(`${r} is not a valid URL: ${t}`,{exitCode:e.USAGE})}if(i.protocol!==`https:`&&i.protocol!==`http:`)throw new n(`${r} must be an http or https URL: ${t}`,{exitCode:e.USAGE});return i.toString().replace(/\/+$/,``)}function le(e){switch(e){case`flag`:return`--token flag`;case`env-token`:return k(`API_TOKEN`);case`env-key`:return k(`API_KEY`);case`credentials`:return`credentials file`}}function ue(e){switch(e){case`flag`:return`--api-url flag`;case`env`:return k(`API_URL`);case`credentials`:return`credentials file`;case`default`:return`product default`}}function de(r=E){let i=Z(r),a=x().profiles[i],o=X(i),s=r.token?.trim(),c=A(`API_TOKEN`),l=A(`API_KEY`),u,d;if(s?(u=s,d=`flag`):c?(u=c,d=`env-token`):l?(u=l,d=`env-key`):(u=a?.token,d=`credentials`),!u)throw new n(`No API token for profile "${i}"`,{exitCode:e.AUTH,hint:`Run ${t.binName} login, or set ${k(`API_TOKEN`)}`});let f=A(`WORKSPACE_ID`)??(typeof o.workspaceId==`string`?o.workspaceId:void 0);return{name:i,token:u,tokenSource:d,apiUrl:Q(r,a?.apiUrl).url,...f?{workspaceId:f}:{},defaults:o}}function fe(t=E.lang){let r=t?.trim()??L().language;if(!r)return;let i=r.toLowerCase();if(!T.includes(i))throw new n(`--lang must be one of ${T.join(`, `)}, got "${r}"`,{exitCode:e.USAGE});return i}function pe(e=E.debug){if(e)return!0;let t=A(`DEBUG`);return t!==void 0&&t!==`0`&&t.toLowerCase()!==`false`}export{_ as A,Z as C,z as D,se as E,w as F,h as I,ne as L,ie as M,re as N,R as O,C as P,de as S,D as T,q as _,J as a,Q as b,ue as c,k as d,oe as f,$ as g,ce as h,j as i,v as j,F as k,le as l,pe as m,ae as n,M as o,O as p,T as r,N as s,G as t,P as u,X as v,Y as w,fe as x,L as y};
@@ -0,0 +1 @@
1
+ import{o as e}from"./exit-codes-Dof7Nstu.js";import{h as t}from"./errors-DLtuFXHR.js";import{i as n,r}from"./version-DUOAxI9S.js";import{a as i,c as a,i as o,r as s}from"./color-BbAK7_Y7.js";import{c,d as l,o as u}from"./output-DNozQoTg.js";import{A as d,I as f,S as p,b as m,c as h,i as g,j as _,l as v,o as y,p as b,s as x}from"./config-eE6NRs2j.js";import{a as S,o as C}from"./update-check-BD7FZeHS.js";import{statSync as w}from"node:fs";const T=`22.12.0`,E=(e,t,n,r=null)=>({id:e,status:t,detail:n,fix:r});function D(){let e=process.versions.node;return S(e,T)>=0?E(`node`,`pass`,`v${e} (>= ${T})`):E(`node`,`fail`,`v${e} is below ${T}`,`Install Node 22.12 or newer from https://nodejs.org`)}async function O(){let e;try{e=await C()}catch{return E(`cli`,`warn`,`${r} (could not reach the npm registry)`)}return e?S(e,r)>0?E(`cli`,`warn`,`${r} (${e} is published)`,`npm i -g ${t.npmPackage}`):E(`cli`,`pass`,`${r} (latest)`):E(`cli`,`warn`,`${r} (no published release to compare against)`)}function k(e){try{return w(e).mode&511}catch{return}}function A(){let e=g(),n=k(e);if(n===void 0)return E(`config dir`,`warn`,`${e} does not exist yet`,`${t.binName} login`);let r=n.toString(8).padStart(4,`0`);return process.platform!==`win32`&&n&63?E(`config dir`,`warn`,`${e} is mode ${r}`,`chmod 700 ${e}`):E(`config dir`,`pass`,`${e} (${r})`)}function j(){let e=y(),t=k(e);return t===void 0?E(`config file`,`warn`,`${e} does not exist yet`):E(`config file`,`pass`,`${e} (${t.toString(8).padStart(4,`0`)})`)}function M(){let e=x();if(!d())return E(`credentials`,`warn`,`${e} does not exist yet`,`${t.binName} login`);let n=_()??0,r=n.toString(8).padStart(4,`0`);return process.platform!==`win32`&&n&63?E(`credentials`,`fail`,`${e} is mode ${r}, other users can read your token`,`chmod 600 ${e}`):E(`credentials`,`pass`,`${e} (${r})`)}function N(){for(let e of[`HTTPS_PROXY`,`https_proxy`,`HTTP_PROXY`,`http_proxy`]){let t=process.env[e];if(t)return E(`proxy`,`warn`,`${e} is set to ${t}`)}return null}async function P(e,r){if(!r)return[E(`api`,`warn`,`skipped, no token to authenticate with`,`${t.binName} login`)];let i=Date.now(),a;try{a=await fetch(`${e}${t.verifyPath}`,{headers:{Authorization:`Bearer ${r}`,Accept:`application/json`,"User-Agent":n(t.id)},signal:AbortSignal.timeout(15e3)})}catch(t){return[E(`api`,`fail`,`${e} unreachable: ${t instanceof Error?t.message:String(t)}`,`Check your network, a proxy, or --api-url`)]}let o=Date.now()-i,s=[];a.status===401||a.status===403?s.push(E(`api`,`fail`,`${e} answered ${a.status}, the token was rejected`,`${t.binName} login`)):a.ok?s.push(E(`api`,`pass`,`${e} ${o} ms`)):s.push(E(`api`,`fail`,`${e} answered ${a.status}`));let c=Number(a.headers.get(`ratelimit-limit`)),l=Number(a.headers.get(`ratelimit-remaining`)),u=Number(a.headers.get(`ratelimit-reset`));if(a.headers.has(`ratelimit-limit`)&&Number.isFinite(c)&&Number.isFinite(l)){let e=Number.isFinite(u)?`, resets in ${u}s`:``;s.push(E(`rate limit`,l<=20?`warn`:`pass`,`${l} of ${c} left${e}`))}else s.push(E(`rate limit`,`warn`,`the API sent no RateLimit headers`));let d=a.headers.get(`date`);if(d){let e=Math.round((Date.now()-Date.parse(d))/1e3),t=Math.abs(e);s.push(t>60?E(`clock`,`fail`,`this machine is ${t}s ${e>0?`ahead of`:`behind`} the server`,`Turn on network time sync on this machine`):E(`clock`,`pass`,`${t}s from the server clock`))}else s.push(E(`clock`,`warn`,`the API sent no Date header`));return await a.arrayBuffer().catch(()=>void 0),s}async function F(e){try{let t=await fetch(`${e}/openapi.json`,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(1e4)});return t.ok?E(`openapi`,`pass`,`reachable, version ${(await t.json()).info?.version??`unknown`}`):E(`openapi`,`warn`,`answered ${t.status}`)}catch{return E(`openapi`,`warn`,`not reachable`)}}const I={pass:`✓`,warn:`⚠`,fail:`✗`};function L(e,t){return e===`pass`?o(t):e===`warn`?a(t):i(t)}function R(n){n.command(`doctor`).description(`check this machine, the config files and the API`).action(async()=>{let n=b(),r=[D(),await O(),A(),j(),M()],i,a=m().url,o=`default`;try{let e=p();i=e.token,a=e.apiUrl,o=e.name,r.push(E(`token`,`pass`,`${f(e.token)} from ${v(e.tokenSource)}`))}catch(e){o=n.profile??o,r.push(E(`token`,`fail`,e instanceof Error?e.message:String(e),`${t.binName} login`))}r.push(E(`api url`,`pass`,`${a} (from ${h(m().source)})`)),r.push(...await P(a,i)),r.push(await F(a));let d=N();d&&r.push(d);let g=r.filter(e=>e.status===`fail`);if(u()){l({ok:g.length===0,command:`doctor`,data:{profile:o,checks:r}}),g.length>0&&(process.exitCode=e.GENERIC);return}let _=Math.max(...r.map(e=>e.id.length));for(let e of r)c(` ${L(e.status,I[e.status])} ${e.id.padEnd(_)} ${e.detail}`),e.fix&&c(` ${` `.repeat(_)} ${s(`fix: ${e.fix}`)}`);c(``),c(g.length===0?`No problems found.`:`${g.length} ${g.length===1?`problem`:`problems`} found.`),g.length>0&&(process.exitCode=e.GENERIC)})}export{R as registerDoctorCommand};
@@ -1 +1 @@
1
- import"./exit-codes-eYq58Sw_.js";import{a as e,c as t,d as n,f as r,i,l as a,m as o,n as s,o as c,p as l,r as u,s as d,t as f,u as p}from"./errors-DK8JR_St.js";export{f as ApiError,s as CliError,u as accessHintFor,i as exitCodeFor,e as flattenApiMessage,c as hintFor,d as isApiError,t as isCliError,a as messageFor,p as networkError,n as notFoundError,r as readAccessDenial,l as toErrorPayload,o as usageError};
1
+ import"./exit-codes-Dof7Nstu.js";import{a as e,c as t,d as n,f as r,i,l as a,m as o,n as s,o as c,p as l,r as u,s as d,t as f,u as p}from"./errors-DLtuFXHR.js";export{f as ApiError,s as CliError,u as accessHintFor,i as exitCodeFor,e as flattenApiMessage,c as hintFor,d as isApiError,t as isCliError,a as messageFor,p as networkError,n as notFoundError,r as readAccessDenial,l as toErrorPayload,o as usageError};
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./exit-codes-Dof7Nstu.js";const s={id:`redreplier`,displayName:`RedReplier`,binName:`redreplier`,altBinName:`rr`,npmPackage:`@redreplier/cli`,envPrefix:`REDREPLIER`,defaultApiUrl:`https://ai.redreplier.com/ai-app/api/v1`,appUrl:`https://redreplier.com`,tokensUrl:`https://redreplier.com/api-tokens`,tokenPrefixes:[`redreplier_`],verifyPath:`/websites`},c={0:`ok`,1:`error`,2:`usage_error`,3:`auth_error`,4:`not_found`,5:`validation_error`,6:`conflict`,7:`rate_limited`,8:`network_error`,9:`quota_exceeded`,10:n,130:`cancelled`};var l=class extends Error{exitCode;code;hint;details;constructor(e,t={}){super(e,t.cause===void 0?void 0:{cause:t.cause}),this.name=`CliError`,this.exitCode=t.exitCode??r.GENERIC,this.code=t.code??c[this.exitCode],this.hint=t.hint,this.details=t.details}},u=class extends Error{status;code;requestId;body;details;method;path;hint;exitCode;constructor(e){let t=h(e.body);super(e.message??t.message??`HTTP ${e.status}`,e.cause===void 0?void 0:{cause:e.cause}),this.name=`ApiError`,this.status=e.status,this.code=e.code??T(e.body)??k(e.status),this.requestId=e.requestId??D(e.body),this.body=e.body??null,this.details=t.details,this.method=e.method,this.path=e.path,this.hint=e.hint??m(e.status,this.code,e.body),this.exitCode=a(e.status,this.code)}};function d(e){if(!j(e))return{};let t=t=>{let n=e[t];return typeof n==`string`&&n.trim()!==``?n.trim():void 0};return{requiredPermission:t(`requiredPermission`),role:t(`role`),keyRole:t(`keyRole`),issuerRole:t(`issuerRole`),tokenType:t(`tokenType`)}}function f(e){return e.tokenType!==`oauth`&&e.keyRole!==void 0&&e.role!==void 0&&e.keyRole!==e.role}function p(e){let{requiredPermission:t,role:n,keyRole:r,issuerRole:i,tokenType:a}=e,o=t===void 0?``:` and this needs the ${t} permission`;if(f(e))return`This key was issued as ${r}, but the member who created it is now ${i??n}, so the key acts as ${n}${o}.`;let s=a===`oauth`?`Your role`:`This key's role`,c=a===`oauth`?n:r??n;return c!==void 0&&t!==void 0?`${s} is ${c}${o}.`:t===void 0?c===void 0?`${s} does not allow this.`:`${s} is ${c}, which does not allow this.`:`This needs the ${t} permission, which ${s.toLowerCase()} does not have.`}function m(r,a,c){if(r===401&&a===t)return`The member who created this key no longer has access to the workspace, so the key stopped working. Ask a workspace admin for a new key.`;if(r===401&&a===o)return`The login behind this token has no ${s.displayName} account. Connect again with the email you use on ${s.displayName}, or use an API key from ${s.tokensUrl}.`;if(r!==403)return;if(a===i)return`The workspace plan does not cover this. A workspace admin can change the plan in the dashboard.`;if(a===e)return`The X-Workspace-Id header names a workspace this token cannot act in. An API key only works in its own workspace. Clear the setting with "${s.binName} config unset workspaceId" and unset ${s.envPrefix}_WORKSPACE_ID, or use a key created in that workspace.`;if(a!==n)return;let l=d(c),u=l.tokenType===`oauth`?`Ask a workspace admin to change your role.`:f(l)?`A key never does more than its creator. Ask a workspace admin to restore the creator's role, or for a key from a member whose role has it.`:`Ask a workspace admin for a key issued under a role that has it. Retrying or swapping keys of the same role will not help.`;return`${p(l)} ${u}`}function h(e){if(typeof e==`string`){let t=e.trim();return{message:t===``?null:t,details:null}}if(!j(e))return{message:null,details:null};let t=e.message??e.error_description??e.detail;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`&&e.trim()!==``);if(e.length>0)return{message:e.join(`; `),details:e}}if(typeof t==`string`&&t.trim()!==``)return{message:t.trim(),details:null};if(j(e.error)){let t=e.error.message;if(typeof t==`string`&&t.trim()!==``)return{message:t.trim(),details:null}}return typeof e.error==`string`&&e.error.trim()!==``?{message:e.error.trim(),details:null}:{message:null,details:null}}function g(e){return e instanceof l}function _(e){return e instanceof u}function v(e){return _(e)||g(e)?e.exitCode:A(e)||e instanceof TypeError&&/fetch failed|network|ENOTFOUND|ECONNREFUSED/i.test(e.message)?r.NETWORK:r.GENERIC}function y(e){if(g(e)||_(e))return e.hint}function b(e){return e instanceof Error&&e.message.trim()!==``?e.message:typeof e==`string`&&e.trim()!==``?e:`Unexpected error`}function x(e){return _(e)?{code:e.code,status:e.status,message:e.message,details:e.details??null}:g(e)?{code:e.code,status:null,message:e.message,details:e.details??null}:{code:c[v(e)],status:null,message:b(e),details:null}}function S(e,t){return new l(e,{exitCode:r.USAGE,hint:t})}function C(e,t){return new l(e,{exitCode:r.NOT_FOUND,hint:t})}function w(e,t,n){return new l(e,{exitCode:r.NETWORK,cause:t,hint:n})}function T(e){if(j(e)){if(typeof e.code==`string`&&e.code.trim()!==``)return e.code.trim();if(j(e.error)&&typeof e.error.code==`string`&&e.error.code.trim()!==``)return e.error.code.trim();if(typeof e.error==`string`){let t=E(e.error);if(t!==``)return t}}}function E(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).slice(0,64)}function D(e){if(!j(e))return;let t=e.requestId??e.request_id??e.traceId;return typeof t==`string`&&t.trim()!==``?t.trim():void 0}const O={400:`bad_request`,401:`unauthorized`,402:`payment_required`,403:`forbidden`,404:`not_found`,405:`method_not_allowed`,408:`request_timeout`,409:`conflict`,410:`gone`,413:`payload_too_large`,415:`unsupported_media_type`,422:`unprocessable_entity`,429:`too_many_requests`,500:`internal_server_error`,502:`bad_gateway`,503:`service_unavailable`,504:`gateway_timeout`};function k(e){return O[e]??`http_${e}`}function A(e){return e instanceof Error?e.name===`AbortError`||e.name===`TimeoutError`:!1}function j(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{h as a,g as c,C as d,d as f,s as h,v as i,b as l,S as m,l as n,y as o,x as p,m as r,_ as s,u as t,w as u};
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./exit-codes-Dof7Nstu.js";export{o as API_CODE_OAUTH_ACCOUNT_NOT_FOUND,n as API_CODE_PERMISSION_DENIED,i as API_CODE_SUBSCRIPTION_REQUIRED,t as API_CODE_TOKEN_ISSUER_LOST_ACCESS,e as API_CODE_WORKSPACE_ACCESS_DENIED,r as ExitCode,a as httpStatusToExitCode};
@@ -0,0 +1 @@
1
+ const e={OK:0,GENERIC:1,USAGE:2,AUTH:3,NOT_FOUND:4,VALIDATION:5,CONFLICT:6,RATE_LIMITED:7,NETWORK:8,QUOTA:9,FORBIDDEN:10,CANCELLED:130},t=`permission_denied`,n=`subscription_required`,r=`token_issuer_lost_access`,i=`workspace_access_denied`,a=`oauth_account_not_found`;function o(t,r){if(t>=200&&t<400)return e.OK;switch(t){case 401:return e.AUTH;case 403:return r===n?e.QUOTA:e.FORBIDDEN;case 402:return e.QUOTA;case 404:return e.NOT_FOUND;case 409:return e.CONFLICT;case 429:return e.RATE_LIMITED;default:break}return t>=500?e.GENERIC:t>=400?e.VALIDATION:e.GENERIC}export{i as a,r as i,t as n,e as o,n as r,o as s,a as t};
@@ -0,0 +1,2 @@
1
+ import{o as e}from"./exit-codes-Dof7Nstu.js";import{h as t,n,t as r,u as i}from"./errors-DLtuFXHR.js";import{i as a}from"./version-DUOAxI9S.js";import{r as o}from"./color-BbAK7_Y7.js";import{s}from"./output-DNozQoTg.js";import{I as c,S as l,m as u,p as d,x as f}from"./config-eE6NRs2j.js";const p=3e4,m=12e4,h=3,g=1e3,_=6e4,v=20,y=[/^\/ai\//,/^\/mentions\/[^/]+\/explain$/];let b={},x,S,C,w=!1;function T(e){let t=e;return typeof t.profile==`object`||t.globals!==void 0||t.sleep!==void 0}function E(e=d()){b=T(e)?{...e}:{globals:e},x=b.profile,S=void 0,w=!1}function D(){return x||=l(b.globals??d()),x}function O(){return b.language===void 0?(S===void 0&&(S=f(b.globals?.lang)??``),S===``?void 0:S):String(b.language)}function k(){return u(b.debug??b.globals?.debug)}function A(){return b.quiet??b.globals?.quiet??s()}function j(){return C}function M(e,t,n){let r=e.replace(/\/+$/,``),i=t.startsWith(`/`)?t:`/${t}`,a=new URL(`${r}${i}`);for(let[e,t]of Object.entries(n??{}))if(t!=null){if(Array.isArray(t)){for(let n of t)n!=null&&a.searchParams.append(e,String(n));continue}a.searchParams.append(e,String(t))}return a.toString()}function N(e,t){return e===`POST`&&y.some(e=>e.test(t))?m:p}function P(e,t=Date.now()){if(!e)return;let n=e.trim();if(n===``)return;if(/^\d+$/.test(n))return Number(n)*1e3;let r=Date.parse(n);if(!Number.isNaN(r))return Math.max(0,r-t)}function F(e){let t=g*2**(e-1);return Math.round(t*(.75+Math.random()*.5))}function I(e){if(e===null)return;let t=Number(e.trim());return Number.isFinite(t)?t:void 0}function L(e){let t=I(e.get(`ratelimit-limit`)??e.get(`x-ratelimit-limit`)),n=I(e.get(`ratelimit-remaining`)??e.get(`x-ratelimit-remaining`)),r=I(e.get(`ratelimit-reset`)??e.get(`x-ratelimit-reset`)),i=e.get(`ratelimit-policy`)??void 0;t===void 0&&n===void 0&&r===void 0&&i===void 0||(C={limit:t,remaining:n,reset:r,...i?{policy:i}:{}},R())}function R(){if(w||!C)return;let{limit:e,remaining:t,reset:n}=C;if(t===void 0||t>20||A()||!process.stdout.isTTY)return;w=!0;let r=e===void 0?`the`:String(e),i=n===void 0?``:`, resets in ${Math.max(0,Math.round(n))}s`;process.stderr.write(o(`rate limit: ${t} of ${r} left${i}\n`))}function z(e){let t={};for(let[n,r]of Object.entries(e))t[n]=n.toLowerCase()===`authorization`?`Bearer ${c(r.replace(/^Bearer\s+/i,``))}`:r;return t}function B(e){process.stderr.write(o(e.endsWith(`
2
+ `)?e:`${e}\n`))}function V(e){return e.get(`x-request-id`)??e.get(`x-requestid`)??e.get(`request-id`)??void 0}async function H(e){if(e.status===204)return;let t=await e.text();if(t!==``){if((e.headers.get(`content-type`)??``).includes(`json`))try{return JSON.parse(t)}catch{return t}return t}}function U(e){return new Promise(t=>{setTimeout(t,e).unref?.()})}function W(e,t,n){return e instanceof Error&&(e.name===`TimeoutError`||e.name===`AbortError`)?i(`Request to ${t} timed out after ${Math.round(n/1e3)}s`,e):i(`Could not reach ${t}: ${e.message}`,e,`Check your network connection, a proxy, or --api-url`)}async function G(i){if(/^https?:/i.test(i.path))throw new n(`path must be relative to the API base URL, got "${i.path}"`,{exitCode:e.USAGE});let o=D(),s=k(),c=O(),l=b.sleep??U,u=i.idempotent??i.method===`GET`,d=i.timeoutMs??N(i.method,i.path),f=M(o.apiUrl,i.path,i.query),p={authorization:`Bearer ${o.token}`,accept:`application/json`,"user-agent":a(t.id),...c?{"x-language":c}:{},...o.workspaceId?{"x-workspace-id":o.workspaceId}:{},...i.headers},m=i.body!==void 0&&i.method!==`GET`;m&&(p[`content-type`]=`application/json`);let h;for(let e=1;e<=3;e+=1){let t=Date.now();s&&(B(`→ ${i.method} ${f} (attempt ${e}/3, timeout ${d}ms)`),B(` headers ${JSON.stringify(z(p))}`),m&&B(` body ${JSON.stringify(i.body)}`));let n;try{n=await fetch(f,{method:i.method,headers:p,...m?{body:JSON.stringify(i.body)}:{},signal:AbortSignal.timeout(d)})}catch(n){if(h=W(n,f,d),s&&B(`← network error after ${Date.now()-t}ms: ${n.message}`),e<3){await l(F(e));continue}throw h}L(n.headers);let a=await H(n);if(s&&(B(`← ${n.status} ${n.statusText} in ${Date.now()-t}ms`),B(` rateLimit ${JSON.stringify(C??{})}`)),n.ok)return a;let o=new r({status:n.status,body:a,requestId:V(n.headers),method:i.method,path:i.path});if(!(n.status===429?u:n.status===502||n.status===503||n.status===504)||e===3)throw o;let c=P(n.headers.get(`retry-after`))??F(e);if(c>_)throw o;await l(c),h=o}throw h??new n(`Request failed`,{exitCode:e.GENERIC})}export{v as a,E as c,G as d,N as f,_ as i,j as l,m as n,g as o,h as r,M as s,p as t,P as u};
@@ -0,0 +1 @@
1
+ import"./exit-codes-Dof7Nstu.js";import"./errors-DLtuFXHR.js";import"./version-DUOAxI9S.js";import"./color-BbAK7_Y7.js";import"./output-DNozQoTg.js";import"./config-eE6NRs2j.js";import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./http-CbGjDmPT.js";export{u as DEFAULT_TIMEOUT_MS,o as LONG_TIMEOUT_MS,c as MAX_ATTEMPTS,i as MAX_RETRY_AFTER_MS,e as RATE_LIMIT_WARN_THRESHOLD,s as RETRY_BASE_MS,l as buildUrl,t as configureHttp,a as getLastRateLimit,d as parseRetryAfter,n as request,r as timeoutForRequest};
@@ -0,0 +1 @@
1
+ import"./exit-codes-Dof7Nstu.js";import"./errors-DLtuFXHR.js";import"./version-DUOAxI9S.js";import"./color-BbAK7_Y7.js";import"./output-DNozQoTg.js";import"./config-eE6NRs2j.js";import"./http-CbGjDmPT.js";import"./types-B3SaBx4C.js";import"./prompt-4XL3T1kl.js";import"./client-BWzucJSi.js";import{a as e,i as t,n,o as r,r as i,t as a}from"./keyword-DhiBS_xU.js";export{a as collectKeyword,n as findKeyword,i as formatMoney,t as normalizeKeyword,e as normalizeKeywords,r as registerKeywordCommands};
@@ -0,0 +1 @@
1
+ import{o as e}from"./exit-codes-Dof7Nstu.js";import{d as t,h as n,m as r,n as i}from"./errors-DLtuFXHR.js";import{c as a,f as o,g as s,h as c,i as l,m as u,o as d,p as f,r as p,s as m,v as h}from"./output-DNozQoTg.js";import{f as g,n as _,u as v}from"./types-B3SaBx4C.js";import{i as y}from"./prompt-4XL3T1kl.js";import{_ as b,b as x,c as S,i as C,l as w,n as T,o as E,p as D,t as O,u as k,y as A}from"./client-BWzucJSi.js";const j=`${n.appUrl}/billing`;function M(e){let t=e.trim().toLowerCase();if(t===``)throw r(`A keyword cannot be empty`);if(t.length>_)throw r(`"${t.slice(0,32)}…" is ${t.length} characters, the limit is ${_}`);return t}function N(e){return[...new Set(e.map(M))]}const P=(e,t=[])=>[...t,M(e)];function F(e){return`$${e.toFixed(2)}`}function I(e,t){for(let n of e){let e=n.keywords.find(e=>e.id===t);if(e)return{website:n,keyword:e}}}const L=[{header:`ID`,value:e=>p(e.id)},{header:`KEYWORD`,value:e=>e.value},{header:`STATUS`,value:e=>e.status},{header:`NOTE`,value:e=>e.status===`PENDING`?`no free slot on this plan`:`—`}];async function R(e,t){let n=m()||d()?null:g(e);try{return await t()}finally{n?.stop()}}async function z(e){let{websites:r}=await R(`Loading keywords…`,b),i=I(r,e);if(!i)throw t(`No keyword with id "${e}" in this workspace`,`list them with: ${n.binName} site list`);return i}function B(e){let t=e.keywords.filter(e=>e.status===`PENDING`).length;t!==0&&(a(``),a(`${t} pending on this site. Price activating every pending keyword in the workspace: ${n.binName} keyword plan`))}async function V(e,t){let n=N(t);if(n.length===0)throw r(`Pass at least one keyword`);let i=await R(`Adding keywords…`,()=>T(e,{keywords:n}));if(d()){f(`keyword.add`,i);return}let o=i.keywords.filter(e=>n.includes(e.value)),l=i.keywords.filter(e=>e.status===`ACTIVE`).length;s(`${i.domain} now has ${i.keywords.length} keywords (${l} active)`),o.length>0&&(a(``),c(o,L)),B(i)}async function H(e,t){let n=M(t.value),{keyword:r}=await z(e);if(r.value===n){if(d()){f(`keyword.edit`,r);return}a(`No change (case-only edit).`);return}let i=await R(`Renaming keyword…`,()=>w(e,{value:n}));if(d()){f(`keyword.edit`,i);return}s(`${r.value} → ${i.value}`),o([[`status`,i.status],[`slot`,`kept, editing is free and unlimited`]])}async function U(e){let t=await R(`Disabling keyword…`,()=>S(e));if(d()){f(`keyword.disable`,t);return}s(`"${t.value}" is ${t.status}`),a(`Its mentions are kept and it no longer occupies a paid slot. Nothing was charged.`)}async function W(e){let t=await R(`Enabling keyword…`,()=>k(e));if(d()){f(`keyword.enable`,t);return}if(t.status===`PENDING`){s(`"${t.value}" is PENDING`),a(`No free slot on this plan, so it is not collecting yet. Nothing was charged.`),l(`price an upgrade: ${n.binName} keyword plan`);return}s(`"${t.value}" is ${t.status}`),a(`Nothing was charged.`)}async function G(t,r){let{website:a,keyword:o}=await z(t),{total:c}=await C({websiteId:a.id,keywords:[o.value],statuses:[...v],includeLowRelevance:!0});if(r.yes!==!0&&(h(`Deleting "${o.value}" also deletes the ${c} mention${c===1?``:`s`} it produced. There is no undo and no refund.`),l(`To pause instead, keeping the mentions: ${n.binName} keyword disable ${o.id}`),(await y(`Type DELETE to confirm`,{hint:`Pass --yes to delete without typing DELETE`})).trim()!==`DELETE`))throw new i(`That is not DELETE, nothing was deleted.`,{exitCode:e.CANCELLED});let u=await E(o.id);if(d()){f(`keyword.delete`,u);return}s(`Deleted`)}async function K(){let{websites:e}=await R(`Activating pending keywords…`,O);if(d()){f(`keyword.activate-pending`,e,{total:e.length,hasMore:!1});return}let t=e.reduce((e,t)=>e+t.keywords.filter(e=>e.status===`ACTIVE`).length,0),r=e.reduce((e,t)=>e+t.keywords.filter(e=>e.status===`PENDING`).length,0);s(`${t} active keyword${t===1?``:`s`} across ${e.length} site${e.length===1?``:`s`}`),a(r===0?`Nothing left pending. This never charges.`:`${r} still pending, there was no free slot. This never charges.`),r>0&&l(`price an upgrade: ${n.binName} keyword plan`)}function q(e){u([`CURRENT`,`TARGET`],[[`${e.currentPlanName??`no plan`} ${F(e.currentMonthlyPrice)}/mo`,`${e.targetPlanName??`no plan`} ${F(e.targetMonthlyPrice)}/mo (${e.targetKeywords} keywords)`]]),a(``),o([[`upgrade`,e.isUpgrade?`yes`:e.isDowngrade?`no, downgrade`:`no change`],[`charged now`,`${F(e.immediateCharge)}${e.isUpgrade?` (prorated)`:``}`],[`payment needed`,e.requiresImmediatePayment?`yes`:`no`]]),a(``),a(`Plans change in the ${n.displayName} app: ${j}`)}async function J(e){let t;if(e.count===void 0)t=await R(`Pricing your pending keywords…`,A);else{let n=Number(e.count);if(!Number.isInteger(n)||n<1)throw r(`--count must be a whole number of 1 or more, got "${e.count}"`,`--count is the account-wide total of active keywords you want, not how many to add`);t=await R(`Pricing that keyword count…`,()=>x({desiredKeywordCount:n}))}if(d()){f(`keyword.plan`,t);return}q(t)}async function Y(){let e=await R(`Reading keyword edit usage…`,D);if(d()){f(`keyword.usage`,e);return}if(e.unlimited){a(`Keyword edits: unlimited (this plan does not meter them).`);return}o([[`used`,String(e.used)],[`limit`,String(e.limit)],[`remaining`,String(e.remaining)]])}function X(e){let t=e.command(`keyword`).alias(`keywords`).alias(`kw`).description(`keywords a site listens for`);t.command(`add <siteId> <keyword...>`).description(`add keywords to a site`).action(async(e,t)=>{await V(e,t)}),t.command(`edit <id>`).description(`rename a keyword, free and unlimited`).requiredOption(`--value <keyword>`,`the new keyword`).action(async(e,t)=>{await H(e,t)}),t.command(`disable <id>`).description(`stop collecting for a keyword, keeping its mentions`).action(async e=>{await U(e)}),t.command(`enable <id>`).description(`start collecting for a disabled keyword`).action(async e=>{await W(e)}),t.command(`delete <id>`).alias(`rm`).description(`delete a keyword and every mention it produced`).action(async(e,t,n)=>{await G(e,n.optsWithGlobals())}),t.command(`activate-pending`).description(`promote pending keywords into any free slots`).action(async()=>{await K()}),t.command(`plan`).description(`price the plan a keyword count needs`).option(`--count <n>`,`account-wide total of active keywords you want, not an increment`).action(async e=>{await J(e)}),t.command(`usage`).description(`how many keyword edits this plan allows`).action(async()=>{await Y()})}export{N as a,M as i,I as n,X as o,F as r,P as t};
@@ -0,0 +1,3 @@
1
+ import"./exit-codes-Dof7Nstu.js";import{h as e,m as t}from"./errors-DLtuFXHR.js";import{r as n}from"./color-BbAK7_Y7.js";import{c as r,i,p as a}from"./output-DNozQoTg.js";import{I as o,S as s}from"./config-eE6NRs2j.js";import{join as c}from"node:path";import{homedir as l}from"node:os";const u=e.id,d=`https://mcp.redreplier.com/mcp`,f=`@redreplier/mcp-server`,p=`${e.envPrefix}_API_TOKEN`,m=[`claude`,`cursor`,`vscode`,`windsurf`,`codex`,`json`],h={claude:c(l(),`.claude.json`),cursor:c(l(),`.cursor`,`mcp.json`),vscode:c(`.vscode`,`mcp.json`),windsurf:c(l(),`.codeium`,`windsurf`,`mcp_config.json`),codex:c(l(),`.codex`,`config.toml`),json:c(l(),`.${u}-mcp.json`)};function g(e,t){return t?{command:`npx`,args:[`-y`,f],env:{[p]:e}}:{type:`http`,url:d,headers:{Authorization:`Bearer ${e}`}}}function _(e,t,n){if(e===`codex`){let e=[`[mcp_servers.${u}]`];return n?e.push(`command = "npx"`,`args = ["-y", "${f}"]`,`env = { ${p} = "${t}" }`):e.push(`url = "${d}"`,`http_headers = { Authorization = "Bearer ${t}" }`),e.join(`
2
+ `)}let r=e===`vscode`?`servers`:`mcpServers`;return JSON.stringify({[r]:{[u]:g(t,n)}},null,2)}function v(e,t){return t?`claude mcp add ${u} --env ${p}=${e} -- npx -y ${f}`:`claude mcp add --transport http ${u} ${d} --header "Authorization: Bearer ${e}"`}function y(c){c.command(`mcp`).description(`print the ${e.displayName} MCP server config for your editor`).option(`--client <client>`,`one of ${m.join(`, `)}`,`claude`).option(`--local`,`use the stdio server from npm instead of the hosted one`).option(`--write`,`name the file this config belongs in, without touching it`).option(`--install`,`alias of --write`).action(c=>{let l=c.client.toLowerCase();if(!m.includes(l))throw t(`Unknown MCP client "${c.client}".`,`Supported clients: ${m.join(`, `)}`);let u,g=`default`;try{let e=s();u=e.token,g=e.name}catch{u=void 0}let y=!!c.local,b=!!(c.write||c.install),x=b||!process.stdout.isTTY,S=`\${${p}}`,C=u??S,w=u&&!x?o(u):C,T=h[l];a(`mcp`,{client:l,transport:y?`stdio`:`http`,url:y?null:d,package:y?f:null,configFile:T,config:l===`codex`?_(l,C,y):JSON.parse(_(l,C,y))}),l===`claude`?(r(`Add the ${e.displayName} MCP server to Claude Code:`),r(``),r(` ${v(w,y)}`),r(``),r(`Or paste this into your MCP config:`)):r(`Paste this into ${T}:`),r(``);for(let e of _(l,w,y).split(`
3
+ `))r(` ${e}`);r(``),u?x||i(`The token is redacted on screen. Re-run with --write, or pipe this command, to get it in full.`):i(`Profile "${g}" has no token, the config above carries a placeholder. Run: ${e.binName} login`),b&&(r(`${n(`config file`)} ${T}`),i(`Nothing was written. Merge the block above into that file yourself, it may already hold other servers.`))})}export{y as registerMcpCommand};
@@ -0,0 +1 @@
1
+ import{o as e}from"./exit-codes-Dof7Nstu.js";import{d as t,h as n,m as r}from"./errors-DLtuFXHR.js";import"./version-DUOAxI9S.js";import{r as i}from"./color-BbAK7_Y7.js";import{_ as a,c as o,f as s,g as c,h as l,i as u,o as d,p as f,r as p,s as m,u as h,v as g}from"./output-DNozQoTg.js";import{a as _,i as v,n as y,r as b,t as x}from"./time-i2j8Fkgp.js";import{v as ee}from"./config-eE6NRs2j.js";import"./http-CbGjDmPT.js";import{c as S,d as C,f as te,l as w,o as T,s as E,u as D}from"./types-B3SaBx4C.js";import{d as O,g as k,i as A,w as j}from"./client-BWzucJSi.js";import{spawn as ne}from"node:child_process";function re(e,t,n,i=`--limit`){if(e===void 0)return n;let a=typeof e==`number`?e:Number(e);if(!Number.isInteger(a)||a<t||a>n)throw r(`${i} must be an integer between ${t} and ${n}`);return a}function ie(e,t=`--offset`){if(e===void 0)return 0;let n=typeof e==`number`?e:Number(e);if(!Number.isInteger(n)||n<0)throw r(`${t} must be an integer of 0 or more`);return n}async function ae(e){let t=e.maxPages??50,n=e.collect!==!1,r=[],i=e.offset??0,a=0,o=0,s,c=!1;for(;a<t;){let l=await e.fetchPage({limit:e.pageSize,offset:i});if(a+=1,o+=l.items.length,l.total!==void 0&&(s=l.total),n&&r.push(...l.items),await e.onPage?.(l.items,{index:a-1,offset:i,total:l.total}),i+=l.items.length,l.items.length===0||l.hasMore===!1||l.hasMore===void 0&&(l.items.length<e.pageSize||s!==void 0&&i>=s))break;if(a>=t){c=!0;break}}return c&&!e.quiet&&g(`stopped after ${t} requests (${o} items). Continue with --offset ${i}`),{items:r,total:s,pages:a,fetched:o,truncated:c}}const M=5e3;var oe=class{keys=new Map;constructor(e){this.limit=e}has(e){return this.keys.has(e)?(this.keys.delete(e),this.keys.set(e,!0),!0):!1}add(e){for(this.keys.has(e)&&this.keys.delete(e),this.keys.set(e,!0);this.keys.size>this.limit;){let e=this.keys.keys().next();if(e.done)break;this.keys.delete(e.value)}}get size(){return this.keys.size}};function se(e){return new Promise(t=>{setTimeout(t,e).unref?.()})}function ce(e){if(!e||typeof e!=`object`)return;let t=e;if(t.status!==429)return;let n=[t.retryAfterMs,t.retryAfterSeconds,t.retryAfter];for(let[e,t]of n.entries())if(typeof t==`number`&&Number.isFinite(t))return e===0?t:t*1e3;let r=t.body;if(r&&typeof r==`object`){let e=r.retryAfter;if(typeof e==`number`&&Number.isFinite(e))return e*1e3}return M}function le(e){let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?r===0?`${n}m`:`${n}m${r}s`:`${Math.floor(n/60)}h${n%60}m`}async function ue(t){let n=Math.max(M,t.intervalMs),r=Math.max(n,t.maxIntervalMs??6e4),a=t.sleep??se,o=t.onExit??(e=>process.exit(e)),s=new oe(1e4),c=Date.now(),l=n,u=t.cursor,d=0,f=0,p,m=!1,h,g=()=>{m=!0,h?.()};process.on(`SIGINT`,g);let _=async e=>{m||await new Promise(t=>{let n=!1,r=()=>{n||(n=!0,h=void 0,t())};h=r,a(e).then(r)})},v=e=>({emitted:d,polls:f,reason:e,cursor:u,last:p});try{for(;;){let e;try{e=await t.fetchPage(u)}catch(e){let t=ce(e);if(t===void 0)throw e;if(await _(Math.min(t,r)),m)break;continue}f+=1,u=e.cursor;let i=0,a=!1;for(let n of e.items){let e=t.key(n);if(!s.has(e)&&(s.add(e),i+=1,p=n,await t.onItem(n),d+=1,t.until?.(n))){a=!0;break}}if(a)return v(`until`);if(m)break;if(l=i>0?n:Math.min(r,Math.round(l*1.5)),t.timeoutMs!==void 0&&Date.now()-c>=t.timeoutMs)return v(`timeout`);if(await _(l),m)break;if(t.timeoutMs!==void 0&&Date.now()-c>=t.timeoutMs)return v(`timeout`)}}finally{process.removeListener(`SIGINT`,g)}let y=t.label??`items`;return process.stderr.write(i(`\nstopped. ${d} ${y} in ${le(Date.now()-c)}, ${f} polls\n`)),o(e.CANCELLED),v(`interrupted`)}const de=[[75,`VERY_HIGH`],[50,`HIGH`],[30,`MEDIUM`],[10,`LOW`],[0,`VERY_LOW`]];function N(e){if(e===null||!Number.isFinite(e))return null;for(let[t,n]of de)if(e>=t)return n;return`VERY_LOW`}function P(e){let t=e.trim().toUpperCase();if(!D.includes(t))throw r(`Unknown status "${e}"`,`valid statuses: ${D.join(`, `)}`);return t}function F(e){let t=e.trim().toUpperCase().replace(/-/g,`_`);if(!C.includes(t))throw r(`Unknown bucket "${e}"`,`valid buckets: ${C.join(`, `)}`);return t}function I(e){let t=e.trim().toUpperCase().replace(/-/g,`_`);if(!w.includes(t))throw r(`Unknown source "${e}"`,`valid sources: ${w.join(`, `)}`);return t}function L(e){let t=e.trim().toUpperCase();if(!S.includes(t))throw r(`Unknown sort "${e}"`,`valid sorts: ${S.join(`, `)}`);return t}const fe=(e,t=[])=>[...t,e],R=(e,t=[])=>[...t,P(e)],z=(e,t=[])=>[...t,F(e)],B=(e,t=[])=>[...t,I(e)];function V(e){let t={};e.site!==void 0&&e.site!==``&&(t.websiteId=e.site),e.status&&e.status.length>0&&(t.statuses=e.status),e.bucket&&e.bucket.length>0&&(t.scoreBuckets=e.bucket),e.includeLow===!0&&(t.includeLowRelevance=!0);let n=Z(e.minScore);return n!==void 0&&(t.minScore=n),e.keyword&&e.keyword.length>0&&(t.keywords=e.keyword),e.source&&e.source.length>0&&(t.sources=e.source),e.from!==void 0&&(t.from=_(b(e.from))),e.to!==void 0&&(t.to=_(b(e.to))),t}function H(e){if(e!==void 0&&e!==``)return e;let t=ee().defaultSite;return typeof t==`string`&&t!==``?t:void 0}function U(e){return e.subreddit?e.source===`REDDIT_POST`||e.source===`REDDIT_COMMENT`?`r/${e.subreddit}`:e.source===`FACEBOOK_GROUP`?`fb group ${e.subreddit}`:e.source:e.source}function W(e){return e.author?e.source===`REDDIT_POST`||e.source===`REDDIT_COMMENT`?e.author.startsWith(`u/`)?e.author:`u/${e.author}`:e.author:`—`}function G(e){let t=e.publishedAt??e.ingestedAt??e.createdAt;if(t===null)return null;let n=new Date(t);return Number.isNaN(n.getTime())?null:n}const pe=e=>{let t=G(e);return t===null?`—`:y(t)},K=e=>(e??``).replace(/\s+/g,` `).trim()||`—`,me=[{header:`SCORE`,value:e=>e.relevanceScore??`—`,align:`right`},{header:`SOURCE`,value:U},{header:`WHEN`,value:pe},{header:`KEYWORD`,value:e=>e.keyword||`—`},{header:`TITLE`,value:e=>K(e.title??e.contentText)}];async function q(e,t){let n=m()||d()?null:te(e);try{return await t()}finally{n?.stop()}}function he(e,t,n){let r=e.replace(/\s+/g,` `).trim().split(` `),i=[],a=``;for(let e of r){if(a===``){a=e;continue}if(`${a} ${e}`.length+n.length>t){i.push(`${n}${a}`),a=e;continue}a=`${a} ${e}`}return a!==``&&i.push(`${n}${a}`),i}function J(e,t=` `){for(let n of he(e,Math.max(40,a()-2),t))o(n)}async function ge(e,t){try{let{total:n}=await A({...e,includeLowRelevance:!0});return Math.max(0,n-t)}catch{return 0}}async function _e(e){let t=V({...e,site:H(e.site)}),r=e.limit===void 0?50:re(e.limit,E,T),i=ie(e.offset),a=e.sort,s,c,p=!1;if(e.all){let n=await ae({pageSize:T,offset:i,quiet:e.quiet===!0||m(),fetchPage:async e=>{let n=await k({...t,sort:a,limit:e.limit,offset:e.offset});return{items:n.mentions,total:n.total,hasMore:n.offset+n.mentions.length<n.total}}});s=n.items,c=n.total}else{let e=await q(`Loading mentions…`,()=>k({...t,sort:a,limit:r,offset:i}));s=e.mentions,c=e.total,p=e.offset+e.mentions.length<e.total}if(d()){f(`mention.list`,s,{total:c,limit:e.all?void 0:r,offset:e.all?void 0:i,hasMore:p}),h(s);return}if(s.length===0?o(`No mentions match those filters.`):(l(s,me),o(``),o(`${s.length} of ${c??s.length} · open: ${n.binName} mention show <id>`),p&&o(`next: --offset ${i+s.length}`)),t.statuses?.includes(`REJECTED`)||u(`REJECTED mentions are hidden unless you pass --status REJECTED.`),e.includeLow!==!0){let e=await ge(t,c??s.length);e>0&&u(`${e} mention${e===1?``:`s`} below the site’s minimum score ${e===1?`is`:`are`} hidden. Add --include-low.`)}}async function ve(e){let t=V({...e,site:H(e.site)}),n=await q(`Counting mentions…`,()=>A(t));if(d()){f(`mention.count`,n);return}o(`${n.total} mention${n.total===1?``:`s`} match`)}async function ye(e,t){let n={...t,statuses:t.statuses??[...D],includeLowRelevance:!0};for(let t=0;t<20;t+=1){let r=t*T,i=await k({...n,sort:`RECENT`,limit:T,offset:r}),a=i.mentions.find(t=>t.id===e||t.id.startsWith(e));if(a)return a;if(i.mentions.length===0||r+i.mentions.length>=i.total)return}}function Y(e){let t=G(e),r=N(e.relevanceScore);o([U(e),t===null?`unknown time`:y(t),e.relevanceScore===null?`unscored`:`score ${e.relevanceScore}${r===null?``:` (${r})`}`,e.status].join(` · `)),s([[`id`,e.id],[`keyword`,e.keyword||`—`],[`author`,W(e)],[`url`,e.url??`—`],...t===null?[]:[[`posted`,x(t,{timezone:v()})]],...e.tags.length>0?[[`tags`,e.tags.join(`, `)]]:[]]),e.title&&(o(``),J(e.title)),e.contentText&&(o(``),J(e.contentText)),e.relevanceReason&&(o(``),o(i(e.relevanceScore===null?`why it was scored`:`why it scored ${e.relevanceScore}`)),J(e.relevanceReason,` `)),e.aiReplySuggestion&&(o(``),o(i(`suggested reply`)),J(e.aiReplySuggestion,` `)),o(``),o(`approve: ${n.binName} mention status ${e.id} APPROVED`)}async function be(e,r){let i=r.explain?await q(`Explaining mention…`,()=>O(e)):await q(`Searching mentions…`,()=>ye(e,V({...r,site:H(r.site)})));if(!i)throw t(`Mention not found in this workspace`,r.explain?`drop --explain to page through /mentions instead`:`${n.binName} mention list --limit 20`);if(d()){f(`mention.show`,i);return}Y(i)}async function xe(e,t){let r=P(t),i=await q(`Updating status…`,()=>j(e,{status:r}));if(d()){f(`mention.status`,i);return}c(`${p(i.id)} is ${i.status}`),o(`Reversible: ${n.binName} mention status ${i.id} NEW`)}async function Se(e){u(`The first call runs generation and can take up to two minutes. Later calls are instant reads.`);let r=await q(`Explaining mention…`,()=>O(e));if(!r)throw t(`Mention not found in this workspace`,`${n.binName} mention list --limit 20`);if(d()){f(`mention.explain`,r);return}Y(r)}function X(e){if(e===void 0)return 60;let t=Number(e);if(!Number.isInteger(t)||t<30)throw r(`--interval must be a whole number of 30 seconds or more, got "${e}"`,`every poll spends from the 600 requests per minute budget`);return t}function Z(e){if(e===void 0)return;let t=Number(e);if(!Number.isInteger(t)||t<0||t>100)throw r(`--min-score must be a whole number between 0 and 100, got "${e}"`);return t}function Ce(e){return{RR_ID:e.id,RR_SCORE:e.relevanceScore===null?``:String(e.relevanceScore),RR_URL:e.url??``,RR_SOURCE:e.source,RR_KEYWORD:e.keyword??``,RR_TITLE:e.title??``}}async function we(e,t){return new Promise(n=>{let r=ne(e,{shell:!0,stdio:[`pipe`,`pipe`,`pipe`],env:{...process.env,...Ce(t)}});r.stdout?.on(`data`,e=>process.stderr.write(e)),r.stderr?.on(`data`,e=>process.stderr.write(e)),r.on(`error`,e=>{process.stderr.write(`${e.message}\n`),n(1)}),r.on(`close`,e=>n(e??1)),r.stdin?.end(`${JSON.stringify(t)}\n`)})}async function Q(e){let t=X(e.interval),n=e.since===void 0?new Date:b(e.since),r=v(),i=V({...e,site:H(e.site),from:void 0}),a={...i,from:_(n),sort:`RECENT`,limit:50};d()||o(`Tailing new mentions ${i.websiteId===void 0?`for every site`:`for site ${p(i.websiteId)}`}${i.minScore===void 0?``:`, score ≥ ${i.minScore}`}, every ${t}s. Ctrl-C to stop.`),await ue({intervalMs:t*1e3,maxIntervalMs:3e5,label:`mentions`,key:e=>e.id,fetchPage:async e=>({items:[...(await k(a)).mentions].reverse(),cursor:e}),onItem:async t=>{if(d()?process.stdout.write(`${JSON.stringify(t)}\n`):o([x(G(t)??new Date,{timezone:r,seconds:!0,withZone:!1}).slice(11),String(t.relevanceScore??`—`).padStart(3),U(t).padEnd(12),K(t.title??t.contentText)].join(` `)),e.exec===void 0)return;let n=await we(e.exec,t);if(n!==0){g(`--exec exited ${n} for ${t.id}, the tail continues`);return}if(e.approveOnExecSuccess===!0)try{await j(t.id,{status:`APPROVED`})}catch(e){g(`could not approve ${t.id}: ${e instanceof Error?e.message:String(e)}`)}}})}const $=e=>e.option(`--site <id>`,`only this site`).option(`--status <status>`,`filter by status, repeatable: ${D.join(`, `)}`,R,[]).option(`--bucket <bucket>`,`filter by score bucket, repeatable: ${C.join(`, `)}`,z,[]).option(`--include-low`,`include mentions below the site’s minimum score`).option(`--min-score <n>`,`only mentions scoring at least this, 0 to 100; unscored ones are left out`).option(`--keyword <keyword>`,`filter by keyword, repeatable`,fe,[]).option(`--source <source>`,`filter by source, repeatable: ${w.join(`, `)}`,B,[]).option(`--from <date>`,`lower bound on ingestion time`).option(`--to <date>`,`upper bound on ingestion time`);function Te(e){let t=e.command(`mention`).alias(`mentions`).description(`lead mentions found across Reddit, Hacker News, X and Bluesky`);$(t.command(`list`,{isDefault:!0})).alias(`ls`).description(`list mentions`).option(`--sort <order>`,`${S.join(` or `)}`,L).option(`--limit <n>`,`mentions per page, ${E} to ${T}`).option(`--offset <n>`,`mentions to skip`).option(`--all`,`page until the server runs out`).action(async(e,t)=>{await _e(t.optsWithGlobals())}),$(t.command(`count`)).description(`count the mentions matching the filters`).action(async e=>{await ve(e)}),$(t.command(`show <id>`)).alias(`get`).description(`show one mention, its score reason and its suggested reply`).option(`--explain`,`fetch it through /mentions/{id}/explain instead of paging /mentions`).action(async(e,t)=>{await be(e,t)}),t.command(`status <id> <status>`).description(`set a mention's status: ${D.join(`, `)}`).action(async(e,t)=>{await xe(e,t)}),t.command(`explain <id>`).description(`generate, then read, why a mention scored as it did`).action(async e=>{await Se(e)}),$(t.command(`tail`)).description(`follow new mentions as they arrive`).option(`--interval <seconds>`,`poll every N seconds, floor 30`).option(`--since <date>`,`start from this time instead of now`).option(`--exec <command>`,`run this command once per mention, JSON on its stdin`).option(`--approve-on-exec-success`,`approve a mention when --exec exits 0`).action(async(e,t)=>{await Q(t.optsWithGlobals())})}export{W as authorLabel,V as buildFilterQuery,G as mentionDate,F as normalizeBucket,L as normalizeSort,I as normalizeSource,P as normalizeStatus,Z as parseMinScore,X as parseTailInterval,Te as registerMentionCommands,N as relevanceBucketOf,H as resolveSite,U as sourceLabel};
@@ -0,0 +1 @@
1
+ import"./exit-codes-Dof7Nstu.js";import{h as e,m as t}from"./errors-DLtuFXHR.js";import"./color-BbAK7_Y7.js";import{c as n,p as r}from"./output-DNozQoTg.js";import{p as i}from"./config-eE6NRs2j.js";import{t as a}from"./open-url-at-ONE2w.js";const o={dashboard:{path:()=>`/dashboard`,needsId:!1},keywords:{path:()=>`/keywords`,needsId:!1},leads:{path:()=>`/leads`,needsId:!1},alerts:{path:()=>`/alerts`,needsId:!1},subreddits:{path:()=>`/subreddits`,needsId:!1},seo:{path:()=>`/seo`,needsId:!1},tokens:{path:()=>`/api-tokens`,needsId:!1},billing:{path:()=>`/billing`,needsId:!1},settings:{path:()=>`/settings/general`,needsId:!1},workspaces:{path:()=>`/workspaces`,needsId:!1}},s={home:`dashboard`,keyword:`keywords`,lead:`leads`,mention:`leads`,mentions:`leads`,alert:`alerts`,subreddit:`subreddits`,token:`tokens`,"api-tokens":`tokens`,workspace:`workspaces`};function c(c){c.command(`open`).argument(`[what]`,`one of ${Object.keys(o).join(`, `)}`,`dashboard`).argument(`[id]`,`identifier, for the targets that need one`).description(`open the ${e.displayName} web app in your browser`).action((c,l)=>{let u=s[c.toLowerCase()]??c.toLowerCase(),d=o[u];if(!d)throw t(`There is nothing to open called "${c}".`,`Targets: ${Object.keys(o).join(`, `)}`);if(d.needsId&&l===void 0)throw t(`open ${u} needs an id.`,`${e.binName} open ${u} <id>`);let f=`${e.appUrl}${d.path(l)}`;if(r(`open`,{target:u,url:f}),i().input===!1){n(f);return}n(a(f)?`Opening ${f}`:f)})}export{c as registerOpenCommand};
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,p as n}from"./errors-DK8JR_St.js";import{a as r,c as i,i as a,r as o,s}from"./color-BbAK7_Y7.js";const c=/^[-+]?[$€£]?\d[\d,]*(\.\d+)?%?$/;function l(e){return s(e).length}function u(e,t){if(t<=0)return``;let n=s(e);return n.length<=t?e:t===1?`…`:`${n.slice(0,t-1)}…`}function d(e,t,n={}){let r=e.map((e,n)=>t.map(t=>_(t.value(e,n)))),i=t.map((e,t)=>e.align??g(r.map(e=>e[t]??``)));return f(t.map(e=>e.header),r,{...n,align:i})}function f(e,t,n={}){if(t.length===0)return``;let r=n.gap??2,i=n.width??100,a=n.header!==!1,s=Math.max(e.length,...t.map(e=>e.length));if(s===0)return``;let c=Array.from({length:s},(t,n)=>(e[n]??``).toUpperCase()),u=Array.from({length:s},(e,r)=>n.align?.[r]??g(t.map(e=>e[r]??``))),d=Array.from({length:s},(e,n)=>{let r=a?l(c[n]):0;return t.reduce((e,t)=>Math.max(e,l(t[n]??``)),r)});p(d,i,r);let f=[];a&&f.push(o(m(c,d,u,r)));for(let e of t){let t=Array.from({length:s},(t,n)=>e[n]??``);f.push(m(t,d,u,r))}return f.join(`
1
+ import{i as e,o as t,p as n}from"./errors-DLtuFXHR.js";import{a as r,c as i,i as a,r as o,s}from"./color-BbAK7_Y7.js";const c=/^[-+]?[$€£]?\d[\d,]*(\.\d+)?%?$/;function l(e){return s(e).length}function u(e,t){if(t<=0)return``;let n=s(e);return n.length<=t?e:t===1?`…`:`${n.slice(0,t-1)}…`}function d(e,t,n={}){let r=e.map((e,n)=>t.map(t=>_(t.value(e,n)))),i=t.map((e,t)=>e.align??g(r.map(e=>e[t]??``)));return f(t.map(e=>e.header),r,{...n,align:i})}function f(e,t,n={}){if(t.length===0)return``;let r=n.gap??2,i=n.width??100,a=n.header!==!1,s=Math.max(e.length,...t.map(e=>e.length));if(s===0)return``;let c=Array.from({length:s},(t,n)=>(e[n]??``).toUpperCase()),u=Array.from({length:s},(e,r)=>n.align?.[r]??g(t.map(e=>e[r]??``))),d=Array.from({length:s},(e,n)=>{let r=a?l(c[n]):0;return t.reduce((e,t)=>Math.max(e,l(t[n]??``)),r)});p(d,i,r);let f=[];a&&f.push(o(m(c,d,u,r)));for(let e of t){let t=Array.from({length:s},(t,n)=>e[n]??``);f.push(m(t,d,u,r))}return f.join(`
2
2
  `)}function p(e,t,n){let r=n*Math.max(0,e.length-1),i=e.reduce((e,t)=>e+t,0)+r-t;if(!(i<=0))for(let t=e.length-1;t>=0&&i>0;--t){let n=Math.min(e[t],3),r=e[t]-n,a=Math.min(r,i);e[t]-=a,i-=a}}function m(e,t,n,r){return e.map((e,r)=>h(u(e,t[r]),t[r],n[r])).join(` `.repeat(r)).replace(/\s+$/,``)}function h(e,t,n){let r=` `.repeat(Math.max(0,t-l(e)));return n===`right`?r+e:e+r}function g(e){let t=e.map(e=>s(e).trim()).filter(e=>e!==``);return t.length===0?`left`:t.every(e=>c.test(e))?`right`:`left`}function _(e){return e==null?``:typeof e==`number`?String(e):e}let v=`human`,y=!1,b=!1,x=``;function S(e={}){let t=e.env??process.env,n=e.envPrefix;return e.json===!0||n!==void 0&&H(t[`${n}_JSON`])?`machine`:n!==void 0&&H(t[`${n}_FORCE_TTY`])||H(t.FORCE_TTY)?`human`:H(t.CI)?`machine`:e.isTTY??!!process.stdout.isTTY?`human`:`machine`}function C(e={}){return v=S(e),y=e.quiet===!0,b=e.fullIds===!0,e.command!==void 0&&(x=e.command),v}function w(){return v===`machine`}function T(){return y}function E(){let e=process.stdout.columns;return typeof e==`number`&&e>0?e:100}function D(e=``){v===`human`&&B(`${e}\n`)}function O(e,t,n={}){if(v!==`human`||e.length===0)return;let r=d(e,t,{...n,width:n.width??E()});r!==``&&B(`${r}\n`)}function k(e,t,n={}){if(v!==`human`||t.length===0)return;let r=f(e,t,{...n,width:n.width??E()});r!==``&&B(`${r}\n`)}function A(e,t=` `){if(v!==`human`||e.length===0)return;let n=e.reduce((e,[t])=>Math.max(e,t.length),0);B(`${e.map(([e,r])=>`${t}${e.padEnd(n)} ${r}`).join(`
3
3
  `)}\n`)}function j(e){B(`${JSON.stringify(e,null,2)}\n`)}function M(e,t,n){if(v!==`machine`)return;x=e;let r={ok:!0,command:e,data:t===void 0?null:t};n!==void 0&&(r.meta=n),j(r)}function N(e){if(y)return;let t=Array.isArray(e)?e[0]:e;if(typeof t!=`object`||!t)return;let n=Object.keys(t);n.length!==0&&V(`${o(`fields: ${n.join(` `)}`)}\n`)}function P(e){y||V(`${o(e)}\n`)}function F(e){y||V(`${i(`⚠`)} ${e}\n`)}function I(e){v===`human`&&B(`${a(`✓`)} ${e}\n`)}function L(e){v===`human`&&B(`${r(`✗`)} ${e}\n`)}function R(i,a=x){let s=e(i),c=n(i);if(v===`machine`)return V(`${JSON.stringify({ok:!1,command:a||`unknown`,error:c},null,2)}\n`),s;V(`${r(`✗`)} ${c.message}\n`);let l=Array.isArray(c.details)?c.details:null;if(l!==null&&l.length>1)for(let e of l)V(` ${o(`·`)} ${e}\n`);let u=t(i);if(u!==void 0&&u.trim()!==``){V(`
4
4
  `);for(let e of u.split(`
@@ -1 +1 @@
1
- import"./exit-codes-eYq58Sw_.js";import"./errors-DK8JR_St.js";import"./color-BbAK7_Y7.js";import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,v as _}from"./output-CDjsADAT.js";export{h as detectOutputMode,u as failure,p as formatId,s as hint,t as initOutput,d as isMachine,m as isQuiet,n as print,c as printError,g as printFieldHints,r as printJson,i as printKeyValues,f as printResult,l as printRows,o as printTable,a as success,e as terminalWidth,_ as warn};
1
+ import"./exit-codes-Dof7Nstu.js";import"./errors-DLtuFXHR.js";import"./color-BbAK7_Y7.js";import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,v as _}from"./output-DNozQoTg.js";export{h as detectOutputMode,u as failure,p as formatId,s as hint,t as initOutput,d as isMachine,m as isQuiet,n as print,c as printError,g as printFieldHints,r as printJson,i as printKeyValues,f as printResult,l as printRows,o as printTable,a as success,e as terminalWidth,_ as warn};
@@ -1,4 +1,4 @@
1
- import{r as e,t}from"./chunk-B_5Rb6Gi.js";import{i as n}from"./exit-codes-eYq58Sw_.js";import{m as r}from"./errors-DK8JR_St.js";import{l as i,r as a}from"./color-BbAK7_Y7.js";import o,{stdin as s,stdout as c}from"node:process";import{stripVTControlCharacters as l}from"node:util";import*as u from"node:readline";import d from"node:readline";import{Writable as ee}from"node:stream";var f=t(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),p=e(f(),1),m=e(i(),1);function te({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}const ne=te();function h(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(ne,``)}function g(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var _={exports:{}};(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-(u==2?1:0))if(o+u<=i)a+=l;else break;o+=u}return a}})(_);var re=_.exports;const ie=g(re),ae=g(function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\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|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\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]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\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-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g});function v(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=h(e),e.length===0))return 0;e=e.replace(ae(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(ie.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}const y=(e=0)=>t=>`\x1B[${t+e}m`,b=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,x=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,S={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]}};Object.keys(S.modifier);const oe=Object.keys(S.color),se=Object.keys(S.bgColor);[...oe,...se];function ce(){let e=new Map;for(let[t,n]of Object.entries(S)){for(let[t,r]of Object.entries(n))S[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=S[t],e.set(r[0],r[1]);Object.defineProperty(S,t,{value:n,enumerable:!1})}return Object.defineProperty(S,`codes`,{value:e,enumerable:!1}),S.color.close=`\x1B[39m`,S.bgColor.close=`\x1B[49m`,S.color.ansi=y(),S.color.ansi256=b(),S.color.ansi16m=x(),S.bgColor.ansi=y(10),S.bgColor.ansi256=b(10),S.bgColor.ansi16m=x(10),Object.defineProperties(S,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>S.rgbToAnsi256(...S.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>S.ansi256ToAnsi(S.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>S.ansi256ToAnsi(S.hexToAnsi256(e)),enumerable:!1}}),S}const le=ce(),C=new Set([`\x1B`,`›`]),w=`]8;;`,T=e=>`${C.values().next().value}[${e}m`,E=e=>`${C.values().next().value}${w}${e}`,ue=e=>e.split(` `).map(e=>v(e)),D=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=v(h(e[e.length-1]));for(let[t,s]of r.entries()){let c=v(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),C.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(w)),i){a?s===`\x07`&&(i=!1,a=!1):s===`m`&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},de=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(v(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},fe=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=ue(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=v(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),D(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){D(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){D(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>de(e)));let c=[...s.join(`
1
+ import{r as e,t}from"./chunk-B_5Rb6Gi.js";import{o as n}from"./exit-codes-Dof7Nstu.js";import{m as r}from"./errors-DLtuFXHR.js";import{l as i,r as a}from"./color-BbAK7_Y7.js";import o,{stdin as s,stdout as c}from"node:process";import{stripVTControlCharacters as l}from"node:util";import*as u from"node:readline";import d from"node:readline";import{Writable as ee}from"node:stream";var f=t(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),p=e(f(),1),m=e(i(),1);function te({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}const ne=te();function h(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(ne,``)}function g(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var _={exports:{}};(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-(u==2?1:0))if(o+u<=i)a+=l;else break;o+=u}return a}})(_);var re=_.exports;const ie=g(re),ae=g(function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\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|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\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]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\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-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g});function v(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=h(e),e.length===0))return 0;e=e.replace(ae(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(ie.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}const y=(e=0)=>t=>`\x1B[${t+e}m`,b=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,x=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,S={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]}};Object.keys(S.modifier);const oe=Object.keys(S.color),se=Object.keys(S.bgColor);[...oe,...se];function ce(){let e=new Map;for(let[t,n]of Object.entries(S)){for(let[t,r]of Object.entries(n))S[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=S[t],e.set(r[0],r[1]);Object.defineProperty(S,t,{value:n,enumerable:!1})}return Object.defineProperty(S,`codes`,{value:e,enumerable:!1}),S.color.close=`\x1B[39m`,S.bgColor.close=`\x1B[49m`,S.color.ansi=y(),S.color.ansi256=b(),S.color.ansi16m=x(),S.bgColor.ansi=y(10),S.bgColor.ansi256=b(10),S.bgColor.ansi16m=x(10),Object.defineProperties(S,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>S.rgbToAnsi256(...S.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>S.ansi256ToAnsi(S.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>S.ansi256ToAnsi(S.hexToAnsi256(e)),enumerable:!1}}),S}const le=ce(),C=new Set([`\x1B`,`›`]),w=`]8;;`,T=e=>`${C.values().next().value}[${e}m`,E=e=>`${C.values().next().value}${w}${e}`,ue=e=>e.split(` `).map(e=>v(e)),D=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=v(h(e[e.length-1]));for(let[t,s]of r.entries()){let c=v(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),C.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(w)),i){a?s===`\x07`&&(i=!1,a=!1):s===`m`&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},de=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(v(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},fe=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=ue(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=v(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),D(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){D(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){D(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>de(e)));let c=[...s.join(`
2
2
  `)];for(let[e,t]of c.entries()){if(r+=t,C.has(t)){let{groups:t}=RegExp(`(?:\\[(?<code>\\d+)m|\\${w}(?<uri>.*))`).exec(c.slice(e).join(``))||{groups:{}};if(t.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}let n=le.codes.get(Number(i));c[e+1]===`
3
3
  `?(a&&(r+=E(``)),i&&n&&(r+=T(n))):t===`
4
4
  `&&(i&&n&&(r+=T(i)),a&&(r+=E(a)))}return r};function O(e,t,n){return String(e).normalize().replace(/\r\n/g,`
@@ -0,0 +1 @@
1
+ import"./exit-codes-Dof7Nstu.js";import"./errors-DLtuFXHR.js";import"./color-BbAK7_Y7.js";import{a as e,i as t,n,r,t as i}from"./prompt-4XL3T1kl.js";export{i as isInteractive,n as promptConfirm,r as promptHidden,t as promptText,e as setInteractive};
@@ -0,0 +1 @@
1
+ import{o as e}from"./exit-codes-Dof7Nstu.js";import{h as t,m as n,n as r}from"./errors-DLtuFXHR.js";import"./version-DUOAxI9S.js";import"./color-BbAK7_Y7.js";import{c as i,f as a,g as o,h as s,i as c,n as l,o as u,p as d,r as f,s as p,u as m,v as h}from"./output-DNozQoTg.js";import{n as g,t as _}from"./time-i2j8Fkgp.js";import{d as v}from"./config-eE6NRs2j.js";import"./http-CbGjDmPT.js";import{f as y,r as b,u as x}from"./types-B3SaBx4C.js";import{i as S,n as C}from"./prompt-4XL3T1kl.js";import{T as w,_ as T,a as E,h as D,i as O,r as k,s as A}from"./client-BWzucJSi.js";import{a as j,t as M}from"./keyword-DhiBS_xU.js";import{resolve as N}from"node:path";import{readFile as P}from"node:fs/promises";const F=[`ACTIVE`,`PENDING`,`DISABLED`,`SUSPENDED`];function I(e){let t={ACTIVE:0,PENDING:0,DISABLED:0,SUSPENDED:0};for(let n of e.keywords)t[n.status]+=1;return t}function L(e){let t=I(e),n=F.filter(e=>t[e]>0).map(e=>`${t[e]} ${e.toLowerCase()}`);return n.length===0?`none`:n.join(`, `)}function R(e,r=`--url`){let i=e.trim(),a;try{a=new URL(i)}catch{throw n(`${r} must be a full URL, got "${e}"`,`${t.binName} site create --url https://acme.com`)}if(a.protocol!==`https:`&&a.protocol!==`http:`)throw n(`${r} must be an http or https URL, got "${e}"`);return i}async function z(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString(`utf8`)}async function B(e){let t=(e===`-`?await z():e.startsWith(`@`)?await V(e.slice(1)):e).trim();if(t.length>b)throw n(`--description is ${t.length} characters, the limit is ${b}`);return t}async function V(t){try{return await P(N(t),`utf8`)}catch(n){throw new r(`Cannot read ${t}: ${n.message}`,{exitCode:e.USAGE,cause:n})}}const H=[{header:`ID`,value:e=>f(e.id)},{header:`DOMAIN`,value:e=>e.domain},{header:`NAME`,value:e=>e.name||`—`},{header:`KEYWORDS`,value:e=>L(e)},{header:`DESCRIPTION`,value:e=>e.description?`yes`:`missing`}],U=[{header:`ID`,value:e=>f(e.id)},{header:`KEYWORD`,value:e=>e.value},{header:`STATUS`,value:e=>e.status},{header:`ADDED`,value:e=>e.createdAt?g(new Date(e.createdAt)):`—`}];async function W(e,t){let n=p()||u()?null:y(e);try{return await t()}finally{n?.stop()}}async function G(){let{websites:e}=await W(`Loading sites…`,T);if(u()){d(`site.list`,e,{total:e.length,hasMore:!1}),m(e);return}if(e.length===0){i(`No sites yet.`),c(`add one: ${t.binName} site create --url https://acme.com -k "your keyword"`);return}s(e,H),i(``),i(`${e.length} ${e.length===1?`site`:`sites`}`);for(let n of e)n.description||(h(`${n.domain} has no description. Its mentions are not scored.`),c(` fix: ${t.binName} site analyze --url ${n.url}`));let n=e.reduce((e,t)=>e+I(t).PENDING,0);c(`Listing sites activates any PENDING keyword that fits your plan’s free headroom.`),n>0&&c(`${n} keyword${n===1?``:`s`} still PENDING, there was no free slot. Price an upgrade: ${t.binName} keyword plan`)}async function K(e){let n=await W(`Loading site…`,()=>D(e));if(u()){d(`site.get`,n);return}i(n.id),a([[`domain`,n.domain],[`url`,n.url],[`name`,n.name||`—`],[`description`,n.description?`${n.description.length} characters`:`missing, mentions are not scored`],[`keywords`,L(n)],[`created`,n.createdAt?_(new Date(n.createdAt),{timezone:`UTC`}):`—`]]),n.keywords.length>0&&(i(``),s(n.keywords,U)),n.description||(i(``),c(`fix: ${t.binName} site analyze --url ${n.url}`))}async function q(n){let s=R(n.url),p=j(n.keyword),m=n.description===void 0?void 0:await B(n.description),g;if(m!==void 0)g={url:s,keywords:p,description:m,...n.name?{name:n.name}:{}};else if(n.analyze===!1)g={url:s,keywords:p,description:``,...n.name?{name:n.name}:{}},h(`--no-analyze skips the paid AI analysis. Mentions stay unscored until you add a description with site update.`);else{let t=new URL(s).hostname;if(h(`No --description given. The server will scrape ${t} and spend one AI generation from this month’s quota.`),!u()&&!await C(`Continue?`,{assumeYes:n.yes===!0,initialValue:!0}))throw new r(`Cancelled.`,{exitCode:e.CANCELLED});g={url:s,keywords:p,...n.name?{name:n.name}:{}}}let _=await W(`Creating site…`,()=>E(g));if(u()){d(`site.create`,_);return}o(`Created ${f(_.id)} ${_.domain}`),a([[`description`,_.description?`${m===void 0?`generated`:`stored`} (${_.description.length} chars)`:`missing`],[`keywords`,L(_)]]),!_.description&&n.analyze!==!1&&(i(``),l(`Description generation failed. Mentions will be unscored ("Scoring skipped: website description missing").`),c(`retry: ${t.binName} site analyze --url ${_.url}`)),I(_).PENDING>0&&c(`Some keywords are PENDING. Price an upgrade: ${t.binName} keyword plan`)}async function J(e,t){let r={};if(t.name!==void 0&&(r.name=t.name),t.description!==void 0&&(r.description=await B(t.description)),Object.keys(r).length===0)throw n(`Nothing to update.`,`Pass --name, --description, or both`);let s=await W(`Updating site…`,()=>w(e,r));if(u()){d(`site.update`,s);return}o(`Updated ${f(s.id)} ${s.domain}`),a([[`name`,s.name||`—`],[`description`,s.description?`${s.description.length} characters`:`missing`]]),i(`Existing mentions are not rescored.`)}async function Y(t,n){let a=await W(`Loading site…`,()=>D(t)),{total:s}=await O({websiteId:a.id,statuses:[...x],includeLowRelevance:!0});if(n.yes!==!0&&(i(`This deletes ${a.domain}, its ${a.keywords.length} keyword${a.keywords.length===1?``:`s`} and ${s} collected mention${s===1?``:`s`}.`),(await S(`Type the domain to confirm`,{hint:`Pass --yes to delete without typing the domain`})).trim()!==a.domain))throw new r(`That is not "${a.domain}", nothing was deleted.`,{exitCode:e.CANCELLED});let c=await A(a.id);if(u()){d(`site.delete`,c);return}o(`Deleted`)}async function X(n){let i=R(n.url);if(h(`This spends one AI generation from this month’s quota unless a precomputed description exists for the domain. A failed generation is refunded.`),!u()&&!await C(`Continue?`,{assumeYes:n.yes===!0,initialValue:!0}))throw new r(`Cancelled.`,{exitCode:e.CANCELLED});let{description:a}=await W(`Analysing…`,()=>k({url:i}));if(u()){d(`site.analyze`,{description:a});return}process.stdout.write(`${a}\n`),c(`store it: ${v(`FORCE_TTY`)}=1 ${t.binName} site analyze --url ${i} | ${t.binName} site update <id> --description -`)}function Z(e){let t=e.command(`site`).alias(`sites`).description(`monitored websites and their keywords`);t.command(`list`).alias(`ls`).description(`list every monitored site`).action(async()=>{await G()}),t.command(`get <id>`).alias(`view`).description(`show one site with its full keyword table`).action(async e=>{await K(e)}),t.command(`create`).description(`start monitoring a website`).requiredOption(`--url <url>`,`the website to monitor`).option(`--name <name>`,`label for the site`).option(`-k, --keyword <keyword>`,`keyword to watch, repeatable`,M,[]).option(`--description <text>`,`what the site does; @file reads a file, - reads stdin`).option(`--no-analyze`,`skip the paid AI analysis; the site has no description until you add one`).action(async(e,t)=>{await q(t.optsWithGlobals())}),t.command(`update <id>`).description(`rename a site or replace its description`).option(`--name <name>`,`new label for the site`).option(`--description <text>`,`new description; @file reads a file, - reads stdin`).action(async(e,t)=>{await J(e,t)}),t.command(`delete <id>`).alias(`rm`).description(`delete a site, its keywords and every mention they produced`).action(async(e,t,n)=>{await Y(e,n.optsWithGlobals())}),t.command(`analyze`).description(`generate a site description from its URL`).requiredOption(`--url <url>`,`the website to read`).action(async(e,t)=>{await X(t.optsWithGlobals())})}export{R as assertWebsiteUrl,L as describeKeywords,I as keywordCounts,B as readDescription,Z as registerSiteCommands};
@@ -1 +1 @@
1
- import{m as e}from"./errors-DK8JR_St.js";const t=1e3,n=60*t,r=60*n,i=24*r,a=7*i,o={ms:1,milliseconds:1,s:t,sec:t,secs:t,second:t,seconds:t,m:n,min:n,mins:n,minute:n,minutes:n,h:r,hr:r,hrs:r,hour:r,hours:r,d:i,day:i,days:i,w:a,week:a,weeks:a},s=/(\d+(?:\.\d+)?)\s*([a-z]+)/g,c=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})$/i,l=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{1,2}):(\d{2})(?::(\d{2}))?)?$/,u=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/,d=/^(today|tomorrow|yesterday)(?:\s+(.+))?$/;function f(e){if(typeof e!=`string`||e.trim()===``)return!1;try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e}),!0}catch{return!1}}function p(t){if(!f(t))throw e(`"${t}" is not a valid IANA time zone.`,`Use a zone name such as "Europe/Berlin" or "UTC".`);return t}function m(){return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}function h(e){let t=e.trim().toLowerCase();if(t===``)return null;let n=t.startsWith(`-`)?-1:1,r=(t.startsWith(`+`)||t.startsWith(`-`)?t.slice(1):t).replace(/\s+/g,``);if(r===``)return null;s.lastIndex=0;let i=0,a=0,c;for(;(c=s.exec(r))!==null;){let e=o[c[2]];if(e===void 0)return null;i+=Number(c[1])*e,a+=c[0].length}return a===0||a!==r.length?null:n*i}function g(e,t={}){let n=t.now??new Date,r=t.timezone??`UTC`,i=e.trim();if(i===``)throw k(e);let a=i.toLowerCase();if(a===`now`)return new Date(n.getTime());if(c.test(i)){let t=new Date(i.replace(` `,`T`));if(Number.isNaN(t.getTime()))throw k(e);return t}if(i.startsWith(`+`)||i.startsWith(`-`)){let t=h(i);if(t===null)throw k(e);return new Date(n.getTime()+t)}let o=d.exec(a);if(o!==null){let t=o[1]===`tomorrow`?1:o[1]===`yesterday`?-1:0,i=x(o[2]);if(i===null)throw k(e);return w({...C(S(n,r),t),...i},r)}let s=l.exec(i);if(s!==null)return w({year:Number(s[1]),month:Number(s[2]),day:Number(s[3]),hour:s[4]===void 0?0:Number(s[4]),minute:s[5]===void 0?0:Number(s[5]),second:s[6]===void 0?0:Number(s[6])},r);if(/^\d/.test(a)){let e=h(a);if(e!==null)return new Date(n.getTime()+e)}throw k(e)}function _(e){return e.toISOString()}function v(e,t={}){let n=t.timezone??`UTC`,r=S(e,n),i=`${O(r.year,4)}-${O(r.month,2)}-${O(r.day,2)} ${O(r.hour,2)}:${O(r.minute,2)}`+(t.seconds===!0?`:${O(r.second,2)}`:``);return t.withZone===!1?i:`${i} ${n}`}function y(e,n={}){let r=n.now??new Date,i=e.getTime()-r.getTime(),a=Math.abs(i);if(a<t)return`now`;let o=b(a);return i<0?`${o} ago`:`in ${o}`}function b(e){return e<n?`${Math.max(1,Math.floor(e/t))}s`:e<r?`${Math.floor(e/n)}m`:e<i?`${Math.floor(e/r)}h`:e<30*i?`${Math.floor(e/i)}d`:e<365*i?`${Math.floor(e/(30*i))}mo`:`${Math.floor(e/(365*i))}y`}function x(e){if(e===void 0||e.trim()===``)return{hour:0,minute:0,second:0};let t=u.exec(e.trim());if(t===null)return null;let n=Number(t[1]),r=Number(t[2]),i=t[3]===void 0?0:Number(t[3]);return n>23||r>59||i>59?null:{hour:n,minute:r,second:i}}function S(e,t){let n=D(t).formatToParts(e),r=e=>{let t=n.find(t=>t.type===e);return t===void 0?0:Number(t.value)},i=r(`hour`);return{year:r(`year`),month:r(`month`),day:r(`day`),hour:i===24?0:i,minute:r(`minute`),second:r(`second`)}}function C(e,t){let n=new Date(Date.UTC(e.year,e.month-1,e.day+t));return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:e.hour,minute:e.minute,second:e.second}}function w(e,t){p(t);let n=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second),r=n-T(new Date(n),t);return r=n-T(new Date(r),t),new Date(r)}function T(e,t){let n=S(e,t);return Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)-(e.getTime()-e.getUTCMilliseconds())}const E=new Map;function D(e){let t=E.get(e);if(t!==void 0)return t;let n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`});return E.set(e,n),n}function O(e,t){return String(e).padStart(t,`0`)}function k(t){return e(`Could not read "${t}" as a date.`,`Use ISO 8601 (2026-09-20T09:00:00Z), an offset (+2h), a duration (30m), or "tomorrow 09:00".`)}export{_ as a,m as i,y as n,g as r,v as t};
1
+ import{m as e}from"./errors-DLtuFXHR.js";const t=1e3,n=60*t,r=60*n,i=24*r,a=7*i,o={ms:1,milliseconds:1,s:t,sec:t,secs:t,second:t,seconds:t,m:n,min:n,mins:n,minute:n,minutes:n,h:r,hr:r,hrs:r,hour:r,hours:r,d:i,day:i,days:i,w:a,week:a,weeks:a},s=/(\d+(?:\.\d+)?)\s*([a-z]+)/g,c=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})$/i,l=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{1,2}):(\d{2})(?::(\d{2}))?)?$/,u=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/,d=/^(today|tomorrow|yesterday)(?:\s+(.+))?$/;function f(e){if(typeof e!=`string`||e.trim()===``)return!1;try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e}),!0}catch{return!1}}function p(t){if(!f(t))throw e(`"${t}" is not a valid IANA time zone.`,`Use a zone name such as "Europe/Berlin" or "UTC".`);return t}function m(){return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}function h(e){let t=e.trim().toLowerCase();if(t===``)return null;let n=t.startsWith(`-`)?-1:1,r=(t.startsWith(`+`)||t.startsWith(`-`)?t.slice(1):t).replace(/\s+/g,``);if(r===``)return null;s.lastIndex=0;let i=0,a=0,c;for(;(c=s.exec(r))!==null;){let e=o[c[2]];if(e===void 0)return null;i+=Number(c[1])*e,a+=c[0].length}return a===0||a!==r.length?null:n*i}function g(e,t={}){let n=t.now??new Date,r=t.timezone??`UTC`,i=e.trim();if(i===``)throw k(e);let a=i.toLowerCase();if(a===`now`)return new Date(n.getTime());if(c.test(i)){let t=new Date(i.replace(` `,`T`));if(Number.isNaN(t.getTime()))throw k(e);return t}if(i.startsWith(`+`)||i.startsWith(`-`)){let t=h(i);if(t===null)throw k(e);return new Date(n.getTime()+t)}let o=d.exec(a);if(o!==null){let t=o[1]===`tomorrow`?1:o[1]===`yesterday`?-1:0,i=x(o[2]);if(i===null)throw k(e);return w({...C(S(n,r),t),...i},r)}let s=l.exec(i);if(s!==null)return w({year:Number(s[1]),month:Number(s[2]),day:Number(s[3]),hour:s[4]===void 0?0:Number(s[4]),minute:s[5]===void 0?0:Number(s[5]),second:s[6]===void 0?0:Number(s[6])},r);if(/^\d/.test(a)){let e=h(a);if(e!==null)return new Date(n.getTime()+e)}throw k(e)}function _(e){return e.toISOString()}function v(e,t={}){let n=t.timezone??`UTC`,r=S(e,n),i=`${O(r.year,4)}-${O(r.month,2)}-${O(r.day,2)} ${O(r.hour,2)}:${O(r.minute,2)}`+(t.seconds===!0?`:${O(r.second,2)}`:``);return t.withZone===!1?i:`${i} ${n}`}function y(e,n={}){let r=n.now??new Date,i=e.getTime()-r.getTime(),a=Math.abs(i);if(a<t)return`now`;let o=b(a);return i<0?`${o} ago`:`in ${o}`}function b(e){return e<n?`${Math.max(1,Math.floor(e/t))}s`:e<r?`${Math.floor(e/n)}m`:e<i?`${Math.floor(e/r)}h`:e<30*i?`${Math.floor(e/i)}d`:e<365*i?`${Math.floor(e/(30*i))}mo`:`${Math.floor(e/(365*i))}y`}function x(e){if(e===void 0||e.trim()===``)return{hour:0,minute:0,second:0};let t=u.exec(e.trim());if(t===null)return null;let n=Number(t[1]),r=Number(t[2]),i=t[3]===void 0?0:Number(t[3]);return n>23||r>59||i>59?null:{hour:n,minute:r,second:i}}function S(e,t){let n=D(t).formatToParts(e),r=e=>{let t=n.find(t=>t.type===e);return t===void 0?0:Number(t.value)},i=r(`hour`);return{year:r(`year`),month:r(`month`),day:r(`day`),hour:i===24?0:i,minute:r(`minute`),second:r(`second`)}}function C(e,t){let n=new Date(Date.UTC(e.year,e.month-1,e.day+t));return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:e.hour,minute:e.minute,second:e.second}}function w(e,t){p(t);let n=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second),r=n-T(new Date(n),t);return r=n-T(new Date(r),t),new Date(r)}function T(e,t){let n=S(e,t);return Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)-(e.getTime()-e.getUTCMilliseconds())}const E=new Map;function D(e){let t=E.get(e);if(t!==void 0)return t;let n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`});return E.set(e,n),n}function O(e,t){return String(e).padStart(t,`0`)}function k(t){return e(`Could not read "${t}" as a date.`,`Use ISO 8601 (2026-09-20T09:00:00Z), an offset (+2h), a duration (30m), or "tomorrow 09:00".`)}export{_ as a,m as i,y as n,g as r,v as t};
@@ -1 +1 @@
1
- import{a as e,i as t,t as n}from"./color-BbAK7_Y7.js";import{o as r,s as i}from"./output-CDjsADAT.js";const a=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function o(){return!!process.stderr.isTTY&&!process.env.CI&&!i()&&!r()}function s(r){let i=r,s=0,c=o(),l=()=>{process.stderr.write(`\r\u001b[2K${n(a[s++%a.length])} ${i}`)},u=c?setInterval(l,80):void 0;u?.unref?.(),c&&l();let d=()=>{c&&(clearInterval(u),process.stderr.write(`\r\x1B[2K`))};return{update(e){return i=e,this},stop(e){d(),c&&e&&process.stderr.write(`${e}\n`)},succeed(e){this.stop(t(`✓ ${e??i}`))},fail(t){this.stop(e(`✗ ${t??i}`))}}}const c=[`REDDIT_POST`,`REDDIT_COMMENT`,`TWITTER`,`BLUESKY`,`HACKERNEWS`,`FACEBOOK`,`FACEBOOK_GROUP`],l=[`NEW`,`APPROVED`,`REJECTED`],u=[`VERY_LOW`,`LOW`,`MEDIUM`,`HIGH`,`VERY_HIGH`],d=[`RELEVANCE`,`RECENT`],f=[15,30,60,120,180,240,720,1440],p=255,m=5e3,h=1,g=500,_=50,v=100;export{_ as a,d as c,u as d,s as f,v as i,c as l,p as n,g as o,m as r,h as s,f as t,l as u};
1
+ import{a as e,i as t,t as n}from"./color-BbAK7_Y7.js";import{o as r,s as i}from"./output-DNozQoTg.js";const a=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function o(){return!!process.stderr.isTTY&&!process.env.CI&&!i()&&!r()}function s(r){let i=r,s=0,c=o(),l=()=>{process.stderr.write(`\r\u001b[2K${n(a[s++%a.length])} ${i}`)},u=c?setInterval(l,80):void 0;u?.unref?.(),c&&l();let d=()=>{c&&(clearInterval(u),process.stderr.write(`\r\x1B[2K`))};return{update(e){return i=e,this},stop(e){d(),c&&e&&process.stderr.write(`${e}\n`)},succeed(e){this.stop(t(`✓ ${e??i}`))},fail(t){this.stop(e(`✗ ${t??i}`))}}}const c=[`REDDIT_POST`,`REDDIT_COMMENT`,`TWITTER`,`BLUESKY`,`HACKERNEWS`,`FACEBOOK`,`FACEBOOK_GROUP`],l=[`NEW`,`APPROVED`,`REJECTED`],u=[`VERY_LOW`,`LOW`,`MEDIUM`,`HIGH`,`VERY_HIGH`],d=[`RELEVANCE`,`RECENT`],f=[15,30,60,120,180,240,720,1440],p=255,m=5e3,h=1,g=500,_=50,v=100;export{_ as a,d as c,u as d,s as f,v as i,c as l,p as n,g as o,m as r,h as s,f as t,l as u};
@@ -0,0 +1 @@
1
+ import{h as e}from"./errors-DLtuFXHR.js";import{r as t}from"./version-DUOAxI9S.js";import{c as n,r}from"./color-BbAK7_Y7.js";import{D as i,d as a,y as o}from"./config-eE6NRs2j.js";const s=1440*60*1e3,c=2e3,l=`https://registry.npmjs.org`;function u(e,t){let n=e=>{let[t,n]=e.replace(/^v/,``).split(`-`,2);return{parts:t.split(`.`).map(e=>Number.parseInt(e,10)||0),pre:n??``}},r=n(e),i=n(t);for(let e=0;e<3;e+=1){let t=(r.parts[e]??0)-(i.parts[e]??0);if(t!==0)return t<0?-1:1}return r.pre===i.pre?0:r.pre===``?1:i.pre===``||r.pre<i.pre?-1:1}async function d(t=e.npmPackage,n=c){let r=await fetch(`${l}/${t.replace(`/`,`%2f`)}/latest`,{headers:{accept:`application/vnd.npm.install-v1+json, application/json`},signal:AbortSignal.timeout(n)});if(!r.ok)return;let i=await r.json();return typeof i.version==`string`?i.version:void 0}function f(e){return e.quiet||process.env.CI||process.env[a(`NO_UPDATE_CHECK`)]?!0:e.force?!1:!process.stdout.isTTY}async function p(e={}){if(f(e))return;let n=e.now??Date.now(),r;try{r=o()}catch{return}if(r.updateCheck===!1)return;let a=r.lastUpdateCheck,c=a?.checked?Date.parse(a.checked):NaN,l=!e.force&&Number.isFinite(c)&&n-c<s,p=l?a?.latest:void 0;if(!l){let e;try{e=await d()}catch{return}if(!e)return;p=e;let t={checked:new Date(n).toISOString(),latest:e};try{i(e=>{e.lastUpdateCheck=t})}catch{return}}if(p&&!(u(p,t)<=0))return{current:t,latest:p}}function m(t){process.stderr.write(`${n(`A new version of ${e.binName} is available: ${t.latest}`)} ${r(`(you have ${t.current})`)}\n`),process.stderr.write(r(`Update: npm i -g ${e.npmPackage} · disable: ${e.binName} config set updateCheck false\n`))}async function h(e={}){try{let t=await p(e);t&&m(t)}catch{return}}export{u as a,h as c,p as i,s as n,d as o,c as r,m as s,l as t};
@@ -0,0 +1 @@
1
+ import"./exit-codes-Dof7Nstu.js";import"./errors-DLtuFXHR.js";import"./version-DUOAxI9S.js";import"./color-BbAK7_Y7.js";import"./config-eE6NRs2j.js";import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./update-check-BD7FZeHS.js";export{s as REGISTRY_URL,r as UPDATE_CHECK_INTERVAL_MS,a as UPDATE_CHECK_TIMEOUT_MS,n as checkForUpdate,e as compareSemver,i as fetchLatestVersion,o as printUpdateNotice,t as runUpdateCheck};
@@ -1 +1 @@
1
- const e=`0.2.0`,t=process.versions.node,n=`${process.platform}-${process.arch}`;function r(r){return`${r}/${e} node-v${t} ${n}`}function i(r){return`${r}-cli/${e} node/${t} ${n}`}export{r as a,i,n,e as r,t};
1
+ const e=`0.3.0`,t=process.versions.node,n=`${process.platform}-${process.arch}`;function r(r){return`${r}/${e} node-v${t} ${n}`}function i(r){return`${r}-cli/${e} node/${t} ${n}`}export{r as a,i,n,e as r,t};
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n,r,t as i}from"./version-DUOAxI9S.js";export{i as NODE_VERSION,n as PLATFORM,r as VERSION,t as userAgent,e as versionLine};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redreplier/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "RedReplier from your terminal",
5
5
  "keywords": [
6
6
  "cli",
@@ -1 +0,0 @@
1
- import"./exit-codes-eYq58Sw_.js";import{m as e}from"./errors-DK8JR_St.js";import"./version-B0Ypbd8g.js";import"./color-BbAK7_Y7.js";import{c as t,f as n,g as r,i,o as a,p as o,r as s,s as c,v as l}from"./output-CDjsADAT.js";import"./config-nFtRCrru.js";import{t as u}from"./product-CXL7Ga4M.js";import"./http-DAgILPv-.js";import{a as d,f,i as p,t as m}from"./types-BGk3hWyo.js";import{C as h,S as g,f as _,m as v,v as y,x as b}from"./client-oUdubIcu.js";const x=`experimental, undocumented API`;function S(e){return e%1440==0?`${e/1440}d`:e%60==0?`${e/60}h`:`${e}m`}function C(t){let n=Number(t);if(!Number.isInteger(n)||!m.includes(n))throw e(`--cadence must be one of ${m.join(`, `)} minutes, got "${t}"`,`the server rejects anything else with a generic 400`);return n}function w(t){let n=Number(t);if(!Number.isInteger(n)||n<d||n>p)throw e(`--min-score must be a whole number between ${d} and ${p}, got "${t}"`);return n}async function T(e,t){let n=c()||a()?null:f(e);try{return await t()}finally{n?.stop()}}function E(e){n([[`enabled`,e.enabled?`yes`:`no`],[`cadence`,S(e.cadenceMinutes)],[`fastest`,`${S(e.minIntervalMinutes)} on this plan`],[`options`,e.availableCadences.join(`, `)]])}async function D(){let e=await T(`Reading alert settings…`,_);if(a()){o(`alerts.get`,e);return}E(e),i(`the full server list is ${m.join(`, `)}; yours is what the plan allows`)}async function O(t){if(t.on===!0&&t.off===!0)throw e(`Pass either --on or --off, not both`);if(t.on!==!0&&t.off!==!0)throw e(`Pass --on or --off`,`${u.binName} alerts set --on --cadence 60`);let n=t.cadence===void 0?void 0:C(t.cadence),s=await T(`Reading alert settings…`,_);n!==void 0&&!s.availableCadences.includes(n)&&l(`${S(n)} is not in this plan's cadences (${s.availableCadences.join(`, `)}), so the server may refuse it.`);let c=n??s.cadenceMinutes,d=await T(`Saving alert settings…`,()=>g({enabled:t.on===!0,cadenceMinutes:c}));if(a()){o(`alerts.set`,d);return}r(d.enabled?`Alerts on every ${S(d.cadenceMinutes)}`:`Alerts off (cadence ${n===void 0?`kept at`:`set to`} ${S(d.cadenceMinutes)})`),n===void 0&&i(`PUT /alert-settings is a full replace, so the current cadence was read and resent.`)}function k(e){let t=e.command(`alerts`).alias(`alert`).description(`email alert cadence for new mentions`);t.command(`get`).alias(`list`).description(`show the alert settings`).action(async()=>{await D()}),t.command(`set`).description(`turn alerts on or off and choose the cadence`).option(`--on`,`enable alerts`).option(`--off`,`disable alerts`).option(`--cadence <minutes>`,`one of ${m.join(`, `)}`).action(async e=>{await O(e)})}function A(e){n([[`enabled`,e.enabled?`yes`:`no`],[`min score`,String(e.minScore)],[`site`,e.websiteId===null?`every site`:s(e.websiteId)],[`profanity`,e.profanity?`yes`:`no`]])}async function j(){let e=await T(`Reading mean marketer config…`,v);if(a()){o(`mean-marketer.config`,e,{experimental:!0});return}A(e),i(x)}async function M(t){if(t.on===!0&&t.off===!0)throw e(`Pass either --on or --off, not both`);let n={};if(t.on===!0&&(n.enabled=!0),t.off===!0&&(n.enabled=!1),t.minScore!==void 0&&(n.minScore=w(t.minScore)),t.site!==void 0){let e=t.site.trim();n.websiteId=e===``||e.toLowerCase()===`none`?null:e}if(t.profanity!==void 0&&(n.profanity=t.profanity),Object.keys(n).length===0)throw e(`Nothing to change.`,`Pass at least one of --on, --off, --min-score, --site, --profanity or --no-profanity`);let s=await T(`Saving mean marketer config…`,()=>h(n));if(a()){o(`mean-marketer.config.set`,s,{experimental:!0});return}r(`Saved`),A(s),i(x)}function N(e){n([[`enabled`,e.enabled?`yes`:`no`],[`min score`,String(e.minScore)],[`mood`,e.beMean?`mean, tier ${e.tier}`:`civil, tier ${e.tier}`],[`strikes`,String(e.strikes)]]),e.previous&&(t(``),t(`previous opportunity`),n([[`id`,e.previous.id],[`status`,e.previous.status],[`triaged`,e.previous.triaged?`yes`:`no`],[`outstanding`,`${e.previous.hoursOutstanding}h`]],` `)),e.opportunity?(t(``),t(`new opportunity`),n([[`id`,e.opportunity.id],[`title`,e.opportunity.title??`—`],[`source`,e.opportunity.subreddit?`r/${e.opportunity.subreddit}`:e.opportunity.source],[`keyword`,e.opportunity.keyword??`—`],[`score`,e.opportunity.relevanceScore===null?`—`:String(e.opportunity.relevanceScore)],[`url`,e.opportunity.url??`—`]],` `),e.opportunity.relevanceReason&&(t(``),t(` ${e.opportunity.relevanceReason}`))):e.noNewOpportunity&&(t(``),t(`No new opportunity above the minimum score.`)),e.message&&(t(``),t(e.message))}async function P(){let e=await T(`Polling…`,y);if(a()){o(`mean-marketer.poll`,e,{experimental:!0});return}N(e),i(`${x}; this call advances the strike state`)}async function F(){let e=await T(`Resetting…`,b);if(a()){o(`mean-marketer.reset`,e,{experimental:!0});return}e.reset?r(`Strike state reset`):t(`Nothing to reset.`),i(x)}function I(e){let t=e.command(`mean-marketer`,{hidden:!0}).alias(`mm`).description(`nag yourself into replying (${x})`);t.command(`config`).description(`show the mean marketer config`).action(async()=>{await j()}).command(`set`).description(`change the mean marketer config`).option(`--on`,`enable it`).option(`--off`,`disable it`).option(`--min-score <n>`,`only nag about mentions scoring this or higher, ${d} to ${p}`).option(`--site <id>`,`restrict it to one site, or "none" for every site`).option(`--profanity`,`allow profanity`).option(`--no-profanity`,`keep it clean`).action(async e=>{await M(e)}),t.command(`poll`).description(`ask for the next opportunity and advance the strike state`).action(async()=>{await P()}),t.command(`reset`).description(`clear the strike state`).action(async()=>{await F()})}export{C as assertCadence,w as assertMinScore,S as formatCadence,k as registerAlertCommands,I as registerMeanMarketerCommands};
@@ -1,3 +0,0 @@
1
- import{a as e,i as t}from"./exit-codes-eYq58Sw_.js";import{m as n,n as r}from"./errors-DK8JR_St.js";import{i}from"./version-B0Ypbd8g.js";import{S as a,x as o}from"./config-nFtRCrru.js";import{t as s}from"./product-CXL7Ga4M.js";import{readFile as c}from"node:fs/promises";const l=[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`,`HEAD`],u=(e,t)=>[...t,e];async function d(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString(`utf8`)}function f(e){let t=new URLSearchParams;for(let r of e){let e=r.indexOf(`=`);if(e<=0)throw n(`--query expects key=value, got "${r}".`,`${s.binName} api /mentions --query limit=5 --query statuses=NEW`);t.append(r.slice(0,e),r.slice(e+1))}return t}function p(e){let t={};for(let r of e){let e=r.indexOf(`:`);if(e<=0)throw n(`--header expects "Name: value", got "${r}".`);let i=r.slice(0,e).trim();if(i.toLowerCase()===`authorization`)throw n(`Authorization comes from the resolved profile and cannot be overridden.`,`Use --token or --profile to change which token is sent.`);t[i]=r.slice(e+1).trim()}return t}async function m(e,t,r){if(e!==void 0&&t!==void 0)throw n(`Pass either --data or --data-file, not both.`);let i;if(t!==void 0)i=t===`-`?await d():await c(t,`utf8`);else if(e!==void 0)i=e===`@-`?await d():e.startsWith(`@`)?await c(e.slice(1),`utf8`):e;else if(r!==`GET`&&r!==`HEAD`&&!process.stdin.isTTY){let e=await d();i=e.trim()===``?void 0:e}if(i!==void 0){try{JSON.parse(i)}catch{throw n(`The request body is not valid JSON.`)}return i}}function h(c){c.command(`api`).argument(`<path>`,`API path such as /mentions, or an HTTP method when a path follows`).argument(`[pathAfterMethod]`,`API path, when the first argument is an HTTP method`).description(`send an authenticated request to the ${s.displayName} API`).option(`-X, --method <method>`,`HTTP method`,`GET`).option(`-q, --query <key=value>`,`query parameter, repeat the key for arrays`,u,[]).option(`-d, --data <json|@file>`,`request body, @- reads stdin`).option(`--data-file <path>`,`request body read from a file, - reads stdin`).option(`-H, --header <name:value>`,`extra request header, repeatable`,u,[]).option(`-i, --include`,`print the status and response headers to stderr`).action(async(c,u,d)=>{let h=d.method.toUpperCase(),g=c;if(u!==void 0){if(!l.includes(c.toUpperCase()))throw n(`"${c}" is not an HTTP method.`,`Methods: ${l.join(`, `)}`);h=c.toUpperCase(),g=u}if(!l.includes(h))throw n(`"${d.method}" is not an HTTP method.`,`Methods: ${l.join(`, `)}`);if(/^[a-z][a-z0-9+.-]*:\/\//i.test(g))throw n(`api takes a path, not a URL.`,`This CLI only ever talks to the resolved API host. Try: ${s.binName} api /mentions`);let _=a(),v=f(d.query).toString(),y=`${_.apiUrl}${g.startsWith(`/`)?g:`/${g}`}${v?`?${v}`:``}`,b=await m(d.data,d.dataFile,h),x=o(),S={Accept:`application/json`,"User-Agent":i(s.id),...p(d.header),Authorization:`Bearer ${_.token}`};b!==void 0&&(S[`Content-Type`]=`application/json`),x&&(S[`x-language`]=x);let C;try{C=await fetch(y,{method:h,headers:S,body:b,signal:AbortSignal.timeout(12e4)})}catch(e){throw new r(`Could not reach ${_.apiUrl}: ${e instanceof Error?e.message:String(e)}`,{exitCode:t.NETWORK,cause:e})}if(d.include){process.stderr.write(`HTTP ${C.status} ${C.statusText}\n`);for(let[e,t]of[...C.headers].sort())process.stderr.write(`${e}: ${t}\n`);process.stderr.write(`
2
- `)}let w=await C.text();if(!C.ok){let t=`${h} ${g} failed with ${C.status}`,n=null;try{let e=JSON.parse(w);n=e,Array.isArray(e.message)?t=e.message.join(`; `):typeof e.message==`string`&&(t=e.message)}catch{w.trim()!==``&&(t=w.trim())}throw new r(t,{exitCode:e(C.status),details:n})}if(w===``)return;let T=w;if(process.stdout.isTTY)try{T=JSON.stringify(JSON.parse(w),null,2)}catch{T=w}process.stdout.write(T.endsWith(`
3
- `)?T:`${T}\n`)})}export{h as registerApiCommand};
@@ -1 +0,0 @@
1
- import{i as e}from"./exit-codes-eYq58Sw_.js";import{n as t}from"./errors-DK8JR_St.js";import"./version-B0Ypbd8g.js";import"./color-BbAK7_Y7.js";import{c as n,f as r,g as i,i as a,p as o}from"./output-CDjsADAT.js";import{C as s,F as c,I as l,L as u,M as d,N as f,P as p,S as m,b as h,l as g,m as _,p as v,s as y,v as b,x}from"./config-nFtRCrru.js";import{t as S}from"./product-CXL7Ga4M.js";import{c as C,l as w}from"./http-DAgILPv-.js";import{n as T,r as E}from"./prompt-BUh1Q_gg.js";import{t as D}from"./open-url-CovrlP9b.js";import{_ as O}from"./client-oUdubIcu.js";const k=S.tokenPrefixes[0];function A(e){return e.map(e=>e.domain).sort()}function j(e){return e.reduce((e,t)=>e+t.keywords.filter(e=>e.status===`ACTIVE`).length,0)}async function M(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString(`utf8`)}function N(n){if(S.tokenPrefixes.some(e=>n.startsWith(e)))return;if(n.split(`.`).length===3)throw new t(`That looks like an OAuth JWT, not an API token.`,{exitCode:e.AUTH,code:`unsupported_token`,hint:`OAuth login is not supported yet. Create an API token at ${S.tokensUrl}`});let r=n.indexOf(`_`),i=r>0?n.slice(0,r+1):``;throw new t(i?`That token starts with ${i}. ${S.binName} expects ${k}.`:`That does not look like a ${S.displayName} API token, which starts with ${k}.`,{exitCode:e.AUTH,code:`wrong_token_prefix`,hint:`Create one at ${S.tokensUrl}`})}async function P(n,r){if(n){let n=(await M()).trim();if(n===``)throw new t(`Nothing arrived on stdin.`,{exitCode:e.USAGE,code:`empty_stdin`,hint:`echo "$${S.envPrefix}_API_TOKEN" | ${S.binName} login --token-stdin`});return n}return r.token&&r.token.trim()!==``?r.token.trim():(await E(`Token (starts with ${k})`,{hint:`Pass --token-stdin and pipe the token in, or set ${S.envPrefix}_API_TOKEN`})).trim()}function F(E){E.command(`login`).description(`store a ${S.displayName} API token on this machine`).option(`--token-stdin`,`read the token from stdin instead of prompting`).option(`--name <label>`,`human label stored with the profile`).action(async e=>{let t=v(),n=s(),c=h(t,p(n)?.apiUrl).url;!e.tokenStdin&&!t.token&&(a(`Opening ${S.tokensUrl} in your browser.`),a(`Create a token, then paste it here.`),a(`API tokens need a plan with API access, so the token page errors on the free plan.`),D(S.tokensUrl));let d=await P(!!e.tokenStdin,t);N(d),C({profile:{name:n,token:d,tokenSource:`flag`,apiUrl:c,defaults:b(n)},debug:_(),language:x(),quiet:t.quiet===!0});let{websites:f}=await O(),m=A(f),g=j(f);u(n,{token:d,apiUrl:c,label:e.name},{makeCurrent:!0}),o(`login`,{profile:n,apiUrl:c,tokenPrefix:l(d),label:e.name??null,sites:f.length,domains:m,activeKeywords:g,credentialsPath:y()}),i(`Token valid`),r([[`profile`,n],...e.name?[[`label`,e.name]]:[],[`api`,c],[`sites`,`${f.length} monitored`],...m.length>0?[[`domains`,m.join(`, `)]]:[],[`keywords`,`${g} active`],[`stored in`,`${y()} (0600)`]])}),E.command(`logout`).description(`remove a stored token`).option(`--all`,`remove every profile`).action(async r=>{let i=v(),a=c();if(a.length===0)throw new t(`There are no stored profiles to remove.`,{exitCode:e.NOT_FOUND,code:`no_profiles`,hint:`${S.binName} login`});let l=s(),u=r.all?a.map(e=>e.name):[l];if(!r.all&&!a.some(e=>e.name===l))throw new t(`No profile named "${l}".`,{exitCode:e.NOT_FOUND,code:`unknown_profile`,hint:`Stored profiles: ${a.map(e=>e.name).join(`, `)}`});if(!await T(r.all?`Remove all ${u.length} profiles?`:`Remove profile "${l}"?`,{assumeYes:i.yes===!0,initialValue:!1})){n(`Nothing removed.`);return}r.all?d():f(l),o(`logout`,{removed:u}),n(r.all?`Removed all ${u.length} profiles.`:`Removed profile "${l}".`),n(`The token is still valid, revoke it at ${S.tokensUrl}`)}),E.command(`whoami`).description(`show which token is in use and what it can see`).action(async()=>{let e=m(),{websites:t}=await O(),n=A(t),i=j(t),s=w();o(`whoami`,{profile:e.name,tokenPrefix:l(e.token),tokenSource:e.tokenSource,apiUrl:e.apiUrl,sites:t.length,domains:n,activeKeywords:i},s?.limit!==void 0&&s.remaining!==void 0?{rateLimit:{limit:s.limit,remaining:s.remaining,resetSeconds:s.reset??0}}:void 0),r([[`profile`,e.name],[`token`,`${l(e.token)} (from ${g(e.tokenSource)})`],[`api`,e.apiUrl],[`sites`,`${t.length} ${t.length===1?`site`:`sites`}${n.length>0?` (${n.join(`, `)})`:``}`],[`keywords`,`${i} active`],...typeof e.defaults.defaultSite==`string`?[[`default site`,`${e.defaults.defaultSite} (from config.json)`]]:[],...s?.remaining!==void 0&&s.limit!==void 0?[[`limits`,`${s.remaining} of ${s.limit} requests left this minute`]]:[]]),a(`There is no /me endpoint, so this is read back from your monitored sites.`)})}export{N as assertTokenShape,F as registerAuthCommands};
@@ -1 +0,0 @@
1
- import"./exit-codes-eYq58Sw_.js";import{d as e}from"./errors-DK8JR_St.js";import{r as t}from"./color-BbAK7_Y7.js";import{c as n,f as r,g as i,i as a,p as o}from"./output-CDjsADAT.js";import{C as s,E as c,a as l,f as u,h as d,o as f,s as p,t as m,w as h}from"./config-nFtRCrru.js";import{t as g}from"./product-CXL7Ga4M.js";const _=()=>s();function v(s){let v=s.command(`config`).description(`read and write CLI preferences`);v.command(`list`).alias(`ls`).description(`show every key and its value`).action(()=>{let e=_(),{entries:i}=d(e);o(`config.list`,{profile:e,entries:i}),n(` profile: ${e}`),r(i.map(e=>[e.key,e.value===void 0||e.value===null?t(`unset`):l(e.key).format(e.value)]))}),v.command(`get`).argument(`<key>`,`one of ${Object.keys(m).join(`, `)}`).description(`print one value`).action(t=>{let r=l(t),i=_(),a=u(t,i);if(a==null)throw e(`"${t}" is not set for profile "${i}".`,`${g.binName} config set ${t} <value>`);o(`config.get`,{key:t,value:a}),n(r.format(a))}),v.command(`set`).argument(`<key>`,`one of ${Object.keys(m).join(`, `)}`).argument(`<value>`,`new value`).description(`write one value`).action((e,t)=>{let n=l(e),r=_(),a=h(e,t,r);o(`config.set`,{key:e,value:a,scope:n.scope,profile:r}),i(`${e} = ${n.format(a)}`)}),v.command(`unset`).argument(`<key>`,`one of ${Object.keys(m).join(`, `)}`).description(`remove one value`).action(e=>{let t=_(),n=c(e,t);o(`config.unset`,{key:e,removed:n,profile:t}),n?i(`${e} removed`):a(`${e} was not set, nothing changed.`)}),v.command(`path`).description(`print the config and credentials file paths`).action(()=>{let e=f(),t=p();o(`config.path`,{config:e,credentials:t}),r([[`config`,e],[`credentials`,t]])})}export{v as registerConfigCommands};
@@ -1 +0,0 @@
1
- import"./exit-codes-eYq58Sw_.js";import"./errors-DK8JR_St.js";import{C as e,D as t,E as n,O as r,S as i,T as a,_ as o,a as s,b as c,c as l,d as u,f as d,g as f,h as p,i as m,k as h,l as g,m as _,n as v,o as y,p as b,r as x,s as S,t as C,u as w,v as T,w as E,x as D,y as O}from"./config-nFtRCrru.js";import{t as k}from"./product-CXL7Ga4M.js";export{C as CONFIG_KEYS,v as CONFIG_VERSION,x as LANGUAGES,k as PRODUCT,m as configDir,s as configKey,y as configPath,S as credentialsPath,l as describeApiUrlSource,g as describeTokenSource,w as ensureConfigDir,u as envVar,d as getConfigValue,b as getGlobalOptions,_ as isDebugEnabled,p as listConfigValues,f as normalizeApiUrl,o as productConfigKeys,T as profileDefaults,O as readConfig,c as resolveApiUrl,D as resolveLanguage,i as resolveProfile,e as resolveProfileName,E as setConfigValue,a as setGlobalOptions,n as unsetConfigValue,t as updateConfig,r as writeConfig,h as writeFileAtomic};
@@ -1 +0,0 @@
1
- import{i as e}from"./exit-codes-eYq58Sw_.js";import{n as t}from"./errors-DK8JR_St.js";import{t as n}from"./product-CXL7Ga4M.js";import{basename as r,dirname as i,join as a}from"node:path";import{chmodSync as o,existsSync as s,mkdirSync as c,readFileSync as l,renameSync as u,rmSync as d,statSync as f,writeFileSync as ee}from"node:fs";import{randomBytes as te}from"node:crypto";import{homedir as p}from"node:os";function m(e){let t=e.trim();if(t===``)return``;let n=t.lastIndexOf(`_`),r=n>=0?n+1:0;return t.slice(0,Math.min(t.length,r+4))}function h(e){if(!e)return`…`;let t=m(e);return t.length>=e.length?t:`${t}…`}function g(){return{version:1,current:`default`,profiles:{}}}function _(){return s(N())}function v(){let e=N();if(s(e))return f(e).mode&511}function y(){if(process.platform===`win32`)return;let n=v();if(n===void 0||!(n&63))return;let r=N();throw new t(`${r} is readable by other users (mode ${n.toString(8).padStart(4,`0`)})`,{exitCode:e.AUTH,hint:`chmod 600 ${r}`})}function b(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=typeof t.token==`string`?t.token:void 0;if(!n)return;let r={token:n,tokenPrefix:typeof t.tokenPrefix==`string`?t.tokenPrefix:m(n),...typeof t.apiUrl==`string`?{apiUrl:t.apiUrl}:{},...typeof t.label==`string`?{label:t.label}:{},...typeof t.createdAt==`string`?{createdAt:t.createdAt}:{}};return t.type===`oauth`?{...r,type:`oauth`,refreshToken:typeof t.refreshToken==`string`?t.refreshToken:``,expiresAt:typeof t.expiresAt==`string`?t.expiresAt:``,authkitDomain:typeof t.authkitDomain==`string`?t.authkitDomain:``}:{...r,type:`token`}}function x(){let n=N();if(!s(n))return g();y();let r;try{r=JSON.parse(l(n,`utf8`))}catch(r){throw new t(`${n} is not valid JSON`,{exitCode:e.GENERIC,hint:`Fix the file, or start over with: rm ${n}`,cause:r})}if(!r||typeof r!=`object`||Array.isArray(r))return g();let i=r,a={};for(let[e,t]of Object.entries(i.profiles??{})){let n=b(t);n&&(a[e]=n)}return{version:typeof i.version==`number`?i.version:1,current:typeof i.current==`string`&&i.current!==``?i.current:`default`,profiles:a}}function S(e){P(),F(N(),`${JSON.stringify(e,null,2)}\n`,384)}function C(e){return x().profiles[e]}function w(){let e=x();return Object.entries(e.profiles).map(([t,n])=>({name:t,current:t===e.current,profile:n}))}function ne(e,t,n={}){let r=x(),i=r.profiles[e],a={token:t.token,tokenPrefix:m(t.token),...t.apiUrl?{apiUrl:t.apiUrl}:i?.apiUrl?{apiUrl:i.apiUrl}:{},...t.label?{label:t.label}:i?.label?{label:i.label}:{},createdAt:i?.createdAt??new Date().toISOString()},o=t.type===`oauth`?{...a,type:`oauth`,refreshToken:t.refreshToken??``,expiresAt:t.expiresAt??``,authkitDomain:t.authkitDomain??``}:{...a,type:`token`};return r.profiles[e]=o,n.makeCurrent!==!1&&(r.current=e),S(r),o}function re(e){let t=x();return t.profiles[e]?(delete t.profiles[e],t.current===e&&(t.current=Object.keys(t.profiles)[0]??`default`),S(t),!0):!1}function ie(){let e=x(),t=Object.keys(e.profiles).length;return S(g()),t}const ae=1,T=[`en`,`fr`,`de`,`es`,`pt`];let E={};function D(e){E={...e}}function O(){return E}function k(e){return`${n.envPrefix}_${e}`}function A(e){let t=process.env[k(e)];if(t===void 0)return;let n=t.trim();return n===``?void 0:n}function j(){if(process.platform===`win32`){let e=process.env.APPDATA?.trim();if(e)return a(e,n.displayName)}let e=process.env.XDG_CONFIG_HOME?.trim();return a(e&&e!==``?e:a(p(),`.config`),n.id)}function M(){return a(j(),`config.json`)}function N(){return a(j(),`credentials.json`)}function P(){let e=j();return c(e,{recursive:!0,mode:448}),e}function F(n,s,l){let f=i(n);c(f,{recursive:!0,mode:448});let p=a(f,`.${r(n)}.${process.pid}.${te(6).toString(`hex`)}.tmp`);try{ee(p,s,{mode:l}),o(p,l),u(p,n)}catch(r){throw d(p,{force:!0}),new t(`Could not write ${n}: ${r.message}`,{exitCode:e.GENERIC,cause:r})}}function I(){return{version:1,profiles:{}}}function L(){let n=M();if(!s(n))return I();let r;try{r=JSON.parse(l(n,`utf8`))}catch(r){throw new t(`${n} is not valid JSON`,{exitCode:e.GENERIC,hint:`Fix the file or delete it: rm ${n}`,cause:r})}if(!r||typeof r!=`object`||Array.isArray(r))return I();let i=r,a=i.profiles&&typeof i.profiles==`object`?i.profiles:{};return{...i,version:i.version??1,profiles:a}}function R(e){P(),F(M(),`${JSON.stringify(e,null,2)}\n`,420)}function z(e){let t=L();return e(t),R(t),t}function B(n){return r=>{let i=r.trim().toLowerCase();if([`true`,`1`,`yes`,`on`].includes(i))return!0;if([`false`,`0`,`no`,`off`].includes(i))return!1;throw new t(`${n} must be true or false, got "${r}"`,{exitCode:e.USAGE})}}function V(n){let r=n.trim();try{new Intl.DateTimeFormat(`en-US`,{timeZone:r})}catch{throw new t(`"${r}" is not an IANA timezone`,{exitCode:e.USAGE,hint:`Use a name such as Europe/Berlin or America/New_York`})}return r}function H(e){return e.split(`,`).map(e=>e.trim().toUpperCase()).filter(e=>e!==``)}function U(n){return r=>{let i=r.trim();if(i===``)throw new t(`${n} cannot be empty`,{exitCode:e.USAGE});return i}}function W(e){return e==null?``:Array.isArray(e)?e.join(`,`):String(e)}const G={updateCheck:{key:`updateCheck`,scope:`global`,products:`all`,description:`Check npm for a newer CLI once a day`,parse:B(`updateCheck`),format:W},language:{key:`language`,scope:`global`,products:`all`,description:`Value of the x-language header (${T.join(` `)})`,parse:n=>{let r=n.trim().toLowerCase();if(!T.includes(r))throw new t(`language must be one of ${T.join(`, `)}, got "${n}"`,{exitCode:e.USAGE});return r},format:W},timezone:{key:`timezone`,scope:`profile`,products:[`adaptlypost`],description:`Default value for --timezone`,parse:V,format:W},defaultPlatforms:{key:`defaultPlatforms`,scope:`profile`,products:[`adaptlypost`],description:`Default value for --platform, comma separated`,parse:H,format:W},defaultSite:{key:`defaultSite`,scope:`profile`,products:[`redreplier`],description:`Default value for --site`,parse:U(`defaultSite`),format:W},defaultWebsite:{key:`defaultWebsite`,scope:`profile`,products:[`flowsery`],description:`Default website for reporting commands`,parse:U(`defaultWebsite`),format:W},workspaceId:{key:`workspaceId`,scope:`profile`,products:`all`,description:`Workspace this profile talks to`,parse:U(`workspaceId`),format:W}};function K(e){return e.products===`all`||e.products.includes(n.id)}function q(){return Object.values(G).filter(K)}function J(n){let r=G[n];if(!r||!K(r))throw new t(`Unknown config key "${n}"`,{exitCode:e.USAGE,hint:`Known keys: ${q().map(e=>e.key).join(`, `)}`});return r}function oe(e,t){let n=J(e),r=L();if(n.scope===`global`)return r[n.key];let i=t??Z();return r.profiles[i]?.[n.key]}function Y(e,t,n){let r=J(e),i=r.parse(t),a=n??Z();return z(e=>{if(r.scope===`global`){e[r.key]=i;return}let t=e.profiles[a]??{};t[r.key]=i,e.profiles[a]=t}),i}function se(e,t){let n=J(e),r=t??Z(),i=!1;return z(e=>{if(n.scope===`global`){i=e[n.key]!==void 0,delete e[n.key];return}let t=e.profiles[r];t&&(i=t[n.key]!==void 0,delete t[n.key])}),i}function ce(e){let t=e??Z(),n=L();return{profile:t,entries:q().map(e=>({key:e.key,scope:e.scope,description:e.description,value:e.scope===`global`?n[e.key]:n.profiles[t]?.[e.key]}))}}function X(e){let t=e??Z();return L().profiles[t]??{}}function Z(e=E){let t=e.profile?.trim();if(t)return t;let n=A(`PROFILE`);if(n)return n;let r=x(),i=r.current?.trim();return i&&r.profiles[i]?i:i||`default`}function Q(e=E,t){let r=e.apiUrl?.trim();if(r)return{url:$(r,`--api-url`),source:`flag`};let i=A(`API_URL`);if(i)return{url:$(i,k(`API_URL`)),source:`env`};let a=t?.trim();return a?{url:$(a,`credentials.json apiUrl`),source:`credentials`}:{url:n.defaultApiUrl,source:`default`}}function $(n,r){let i;try{i=new URL(n)}catch{throw new t(`${r} is not a valid URL: ${n}`,{exitCode:e.USAGE})}if(i.protocol!==`https:`&&i.protocol!==`http:`)throw new t(`${r} must be an http or https URL: ${n}`,{exitCode:e.USAGE});return i.toString().replace(/\/+$/,``)}function le(e){switch(e){case`flag`:return`--token flag`;case`env-token`:return k(`API_TOKEN`);case`env-key`:return k(`API_KEY`);case`credentials`:return`credentials file`}}function ue(e){switch(e){case`flag`:return`--api-url flag`;case`env`:return k(`API_URL`);case`credentials`:return`credentials file`;case`default`:return`product default`}}function de(r=E){let i=Z(r),a=x().profiles[i],o=X(i),s=r.token?.trim(),c=A(`API_TOKEN`),l=A(`API_KEY`),u,d;if(s?(u=s,d=`flag`):c?(u=c,d=`env-token`):l?(u=l,d=`env-key`):(u=a?.token,d=`credentials`),!u)throw new t(`No API token for profile "${i}"`,{exitCode:e.AUTH,hint:`Run ${n.binName} login, or set ${k(`API_TOKEN`)}`});let f=A(`WORKSPACE_ID`)??(typeof o.workspaceId==`string`?o.workspaceId:void 0);return{name:i,token:u,tokenSource:d,apiUrl:Q(r,a?.apiUrl).url,...f?{workspaceId:f}:{},defaults:o}}function fe(n=E.lang){let r=n?.trim()??L().language;if(!r)return;let i=r.toLowerCase();if(!T.includes(i))throw new t(`--lang must be one of ${T.join(`, `)}, got "${r}"`,{exitCode:e.USAGE});return i}function pe(e=E.debug){if(e)return!0;let t=A(`DEBUG`);return t!==void 0&&t!==`0`&&t.toLowerCase()!==`false`}export{_ as A,Z as C,z as D,se as E,w as F,h as I,ne as L,ie as M,re as N,R as O,C as P,de as S,D as T,q as _,J as a,Q as b,ue as c,k as d,oe as f,$ as g,ce as h,j as i,v as j,F as k,le as l,pe as m,ae as n,M as o,O as p,T as r,N as s,G as t,P as u,X as v,Y as w,fe as x,L as y};
@@ -1 +0,0 @@
1
- import{i as e}from"./exit-codes-eYq58Sw_.js";import"./errors-DK8JR_St.js";import{i as t,r as n}from"./version-B0Ypbd8g.js";import{a as r,c as i,i as a,r as o}from"./color-BbAK7_Y7.js";import{c as s,d as c,o as l}from"./output-CDjsADAT.js";import{A as u,I as d,S as f,b as p,c as m,i as h,j as g,l as _,o as v,p as y,s as b}from"./config-nFtRCrru.js";import{t as x}from"./product-CXL7Ga4M.js";import{a as S,o as C}from"./update-check-9qIilkr0.js";import{statSync as w}from"node:fs";const T=`22.12.0`,E=(e,t,n,r=null)=>({id:e,status:t,detail:n,fix:r});function D(){let e=process.versions.node;return S(e,T)>=0?E(`node`,`pass`,`v${e} (>= ${T})`):E(`node`,`fail`,`v${e} is below ${T}`,`Install Node 22.12 or newer from https://nodejs.org`)}async function O(){let e;try{e=await C()}catch{return E(`cli`,`warn`,`${n} (could not reach the npm registry)`)}return e?S(e,n)>0?E(`cli`,`warn`,`${n} (${e} is published)`,`npm i -g ${x.npmPackage}`):E(`cli`,`pass`,`${n} (latest)`):E(`cli`,`warn`,`${n} (no published release to compare against)`)}function k(e){try{return w(e).mode&511}catch{return}}function A(){let e=h(),t=k(e);if(t===void 0)return E(`config dir`,`warn`,`${e} does not exist yet`,`${x.binName} login`);let n=t.toString(8).padStart(4,`0`);return process.platform!==`win32`&&t&63?E(`config dir`,`warn`,`${e} is mode ${n}`,`chmod 700 ${e}`):E(`config dir`,`pass`,`${e} (${n})`)}function j(){let e=v(),t=k(e);return t===void 0?E(`config file`,`warn`,`${e} does not exist yet`):E(`config file`,`pass`,`${e} (${t.toString(8).padStart(4,`0`)})`)}function M(){let e=b();if(!u())return E(`credentials`,`warn`,`${e} does not exist yet`,`${x.binName} login`);let t=g()??0,n=t.toString(8).padStart(4,`0`);return process.platform!==`win32`&&t&63?E(`credentials`,`fail`,`${e} is mode ${n}, other users can read your token`,`chmod 600 ${e}`):E(`credentials`,`pass`,`${e} (${n})`)}function N(){for(let e of[`HTTPS_PROXY`,`https_proxy`,`HTTP_PROXY`,`http_proxy`]){let t=process.env[e];if(t)return E(`proxy`,`warn`,`${e} is set to ${t}`)}return null}async function P(e,n){if(!n)return[E(`api`,`warn`,`skipped, no token to authenticate with`,`${x.binName} login`)];let r=Date.now(),i;try{i=await fetch(`${e}${x.verifyPath}`,{headers:{Authorization:`Bearer ${n}`,Accept:`application/json`,"User-Agent":t(x.id)},signal:AbortSignal.timeout(15e3)})}catch(t){return[E(`api`,`fail`,`${e} unreachable: ${t instanceof Error?t.message:String(t)}`,`Check your network, a proxy, or --api-url`)]}let a=Date.now()-r,o=[];i.status===401||i.status===403?o.push(E(`api`,`fail`,`${e} answered ${i.status}, the token was rejected`,`${x.binName} login`)):i.ok?o.push(E(`api`,`pass`,`${e} ${a} ms`)):o.push(E(`api`,`fail`,`${e} answered ${i.status}`));let s=Number(i.headers.get(`ratelimit-limit`)),c=Number(i.headers.get(`ratelimit-remaining`)),l=Number(i.headers.get(`ratelimit-reset`));if(i.headers.has(`ratelimit-limit`)&&Number.isFinite(s)&&Number.isFinite(c)){let e=Number.isFinite(l)?`, resets in ${l}s`:``;o.push(E(`rate limit`,c<=20?`warn`:`pass`,`${c} of ${s} left${e}`))}else o.push(E(`rate limit`,`warn`,`the API sent no RateLimit headers`));let u=i.headers.get(`date`);if(u){let e=Math.round((Date.now()-Date.parse(u))/1e3),t=Math.abs(e);o.push(t>60?E(`clock`,`fail`,`this machine is ${t}s ${e>0?`ahead of`:`behind`} the server`,`Turn on network time sync on this machine`):E(`clock`,`pass`,`${t}s from the server clock`))}else o.push(E(`clock`,`warn`,`the API sent no Date header`));return await i.arrayBuffer().catch(()=>void 0),o}async function F(e){try{let t=await fetch(`${e}/openapi.json`,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(1e4)});return t.ok?E(`openapi`,`pass`,`reachable, version ${(await t.json()).info?.version??`unknown`}`):E(`openapi`,`warn`,`answered ${t.status}`)}catch{return E(`openapi`,`warn`,`not reachable`)}}const I={pass:`✓`,warn:`⚠`,fail:`✗`};function L(e,t){return e===`pass`?a(t):e===`warn`?i(t):r(t)}function R(t){t.command(`doctor`).description(`check this machine, the config files and the API`).action(async()=>{let t=y(),n=[D(),await O(),A(),j(),M()],r,i=p().url,a=`default`;try{let e=f();r=e.token,i=e.apiUrl,a=e.name,n.push(E(`token`,`pass`,`${d(e.token)} from ${_(e.tokenSource)}`))}catch(e){a=t.profile??a,n.push(E(`token`,`fail`,e instanceof Error?e.message:String(e),`${x.binName} login`))}n.push(E(`api url`,`pass`,`${i} (from ${m(p().source)})`)),n.push(...await P(i,r)),n.push(await F(i));let u=N();u&&n.push(u);let h=n.filter(e=>e.status===`fail`);if(l()){c({ok:h.length===0,command:`doctor`,data:{profile:a,checks:n}}),h.length>0&&(process.exitCode=e.GENERIC);return}let g=Math.max(...n.map(e=>e.id.length));for(let e of n)s(` ${L(e.status,I[e.status])} ${e.id.padEnd(g)} ${e.detail}`),e.fix&&s(` ${` `.repeat(g)} ${o(`fix: ${e.fix}`)}`);s(``),s(h.length===0?`No problems found.`:`${h.length} ${h.length===1?`problem`:`problems`} found.`),h.length>0&&(process.exitCode=e.GENERIC)})}export{R as registerDoctorCommand};
@@ -1 +0,0 @@
1
- import{a as e,i as t,n,r,t as i}from"./exit-codes-eYq58Sw_.js";const a={0:`ok`,1:`error`,2:`usage_error`,3:`auth_error`,4:`not_found`,5:`validation_error`,6:`conflict`,7:`rate_limited`,8:`network_error`,9:`quota_exceeded`,10:i,130:`cancelled`};var o=class extends Error{exitCode;code;hint;details;constructor(e,n={}){super(e,n.cause===void 0?void 0:{cause:n.cause}),this.name=`CliError`,this.exitCode=n.exitCode??t.GENERIC,this.code=n.code??a[this.exitCode],this.hint=n.hint,this.details=n.details}},s=class extends Error{status;code;requestId;body;details;method;path;hint;exitCode;constructor(t){let n=u(t.body);super(t.message??n.message??`HTTP ${t.status}`,t.cause===void 0?void 0:{cause:t.cause}),this.name=`ApiError`,this.status=t.status,this.code=t.code??b(t.body)??w(t.status),this.requestId=t.requestId??S(t.body),this.body=t.body??null,this.details=n.details,this.method=t.method,this.path=t.path,this.hint=t.hint??l(t.status,this.code,t.body),this.exitCode=e(t.status,this.code)}};function c(e){if(!E(e))return{};let t=t=>{let n=e[t];return typeof n==`string`&&n.trim()!==``?n.trim():void 0};return{requiredPermission:t(`requiredPermission`),role:t(`role`),tokenType:t(`tokenType`)}}function l(e,t,a){if(e===401&&t===r)return`The member who created this key no longer has access to the workspace, so the key stopped working. Ask a workspace admin for a new key.`;if(e!==403)return;if(t===n)return`The workspace plan does not cover this. A workspace admin can change the plan in the dashboard.`;if(t!==i)return;let{requiredPermission:o,role:s,tokenType:l}=c(a),u=l===`oauth`?`Your role`:`This key's role`;return`${s!==void 0&&o!==void 0?`${u} is ${s} and this needs the ${o} permission.`:o===void 0?s===void 0?`${u} does not allow this.`:`${u} is ${s}, which does not allow this.`:`This needs the ${o} permission, which ${u.toLowerCase()} does not have.`} ${l===`oauth`?`Ask a workspace admin to change your role.`:`Ask a workspace admin for a key issued under a role that has it. Retrying or swapping keys of the same role will not help.`}`}function u(e){if(typeof e==`string`){let t=e.trim();return{message:t===``?null:t,details:null}}if(!E(e))return{message:null,details:null};let t=e.message??e.error_description??e.detail;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`&&e.trim()!==``);if(e.length>0)return{message:e.join(`; `),details:e}}if(typeof t==`string`&&t.trim()!==``)return{message:t.trim(),details:null};if(E(e.error)){let t=e.error.message;if(typeof t==`string`&&t.trim()!==``)return{message:t.trim(),details:null}}return typeof e.error==`string`&&e.error.trim()!==``?{message:e.error.trim(),details:null}:{message:null,details:null}}function d(e){return e instanceof o}function f(e){return e instanceof s}function p(e){return f(e)||d(e)?e.exitCode:T(e)||e instanceof TypeError&&/fetch failed|network|ENOTFOUND|ECONNREFUSED/i.test(e.message)?t.NETWORK:t.GENERIC}function m(e){if(d(e)||f(e))return e.hint}function h(e){return e instanceof Error&&e.message.trim()!==``?e.message:typeof e==`string`&&e.trim()!==``?e:`Unexpected error`}function g(e){return f(e)?{code:e.code,status:e.status,message:e.message,details:e.details??null}:d(e)?{code:e.code,status:null,message:e.message,details:e.details??null}:{code:a[p(e)],status:null,message:h(e),details:null}}function _(e,n){return new o(e,{exitCode:t.USAGE,hint:n})}function v(e,n){return new o(e,{exitCode:t.NOT_FOUND,hint:n})}function y(e,n,r){return new o(e,{exitCode:t.NETWORK,cause:n,hint:r})}function b(e){if(E(e)){if(typeof e.code==`string`&&e.code.trim()!==``)return e.code.trim();if(E(e.error)&&typeof e.error.code==`string`&&e.error.code.trim()!==``)return e.error.code.trim();if(typeof e.error==`string`){let t=x(e.error);if(t!==``)return t}}}function x(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).slice(0,64)}function S(e){if(!E(e))return;let t=e.requestId??e.request_id??e.traceId;return typeof t==`string`&&t.trim()!==``?t.trim():void 0}const C={400:`bad_request`,401:`unauthorized`,402:`payment_required`,403:`forbidden`,404:`not_found`,405:`method_not_allowed`,408:`request_timeout`,409:`conflict`,410:`gone`,413:`payload_too_large`,415:`unsupported_media_type`,422:`unprocessable_entity`,429:`too_many_requests`,500:`internal_server_error`,502:`bad_gateway`,503:`service_unavailable`,504:`gateway_timeout`};function w(e){return C[e]??`http_${e}`}function T(e){return e instanceof Error?e.name===`AbortError`||e.name===`TimeoutError`:!1}function E(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{u as a,d as c,v as d,c as f,p as i,h as l,_ as m,o as n,m as o,g as p,l as r,f as s,s as t,y as u};
@@ -1 +0,0 @@
1
- import{a as e,i as t,n,r,t as i}from"./exit-codes-eYq58Sw_.js";export{i as API_CODE_PERMISSION_DENIED,n as API_CODE_SUBSCRIPTION_REQUIRED,r as API_CODE_TOKEN_ISSUER_LOST_ACCESS,t as ExitCode,e as httpStatusToExitCode};
@@ -1 +0,0 @@
1
- const e={OK:0,GENERIC:1,USAGE:2,AUTH:3,NOT_FOUND:4,VALIDATION:5,CONFLICT:6,RATE_LIMITED:7,NETWORK:8,QUOTA:9,FORBIDDEN:10,CANCELLED:130},t=`permission_denied`,n=`subscription_required`,r=`token_issuer_lost_access`;function i(t,r){if(t>=200&&t<400)return e.OK;switch(t){case 401:return e.AUTH;case 403:return r===n?e.QUOTA:e.FORBIDDEN;case 402:return e.QUOTA;case 404:return e.NOT_FOUND;case 409:return e.CONFLICT;case 429:return e.RATE_LIMITED;default:break}return t>=500?e.GENERIC:t>=400?e.VALIDATION:e.GENERIC}export{i as a,e as i,n,r,t};
@@ -1,2 +0,0 @@
1
- import{i as e}from"./exit-codes-eYq58Sw_.js";import{n as t,t as n,u as r}from"./errors-DK8JR_St.js";import{i}from"./version-B0Ypbd8g.js";import{r as a}from"./color-BbAK7_Y7.js";import{s as o}from"./output-CDjsADAT.js";import{I as s,S as c,m as l,p as u,x as d}from"./config-nFtRCrru.js";import{t as f}from"./product-CXL7Ga4M.js";const p=3e4,m=12e4,h=3,g=1e3,_=6e4,v=20,y=[/^\/ai\//,/^\/mentions\/[^/]+\/explain$/];let b={},x,S,C,w=!1;function T(e){let t=e;return typeof t.profile==`object`||t.globals!==void 0||t.sleep!==void 0}function E(e=u()){b=T(e)?{...e}:{globals:e},x=b.profile,S=void 0,w=!1}function D(){return x||=c(b.globals??u()),x}function O(){return b.language===void 0?(S===void 0&&(S=d(b.globals?.lang)??``),S===``?void 0:S):String(b.language)}function k(){return l(b.debug??b.globals?.debug)}function A(){return b.quiet??b.globals?.quiet??o()}function j(){return C}function M(e,t,n){let r=e.replace(/\/+$/,``),i=t.startsWith(`/`)?t:`/${t}`,a=new URL(`${r}${i}`);for(let[e,t]of Object.entries(n??{}))if(t!=null){if(Array.isArray(t)){for(let n of t)n!=null&&a.searchParams.append(e,String(n));continue}a.searchParams.append(e,String(t))}return a.toString()}function N(e,t){return e===`POST`&&y.some(e=>e.test(t))?m:p}function P(e,t=Date.now()){if(!e)return;let n=e.trim();if(n===``)return;if(/^\d+$/.test(n))return Number(n)*1e3;let r=Date.parse(n);if(!Number.isNaN(r))return Math.max(0,r-t)}function F(e){let t=g*2**(e-1);return Math.round(t*(.75+Math.random()*.5))}function I(e){if(e===null)return;let t=Number(e.trim());return Number.isFinite(t)?t:void 0}function L(e){let t=I(e.get(`ratelimit-limit`)??e.get(`x-ratelimit-limit`)),n=I(e.get(`ratelimit-remaining`)??e.get(`x-ratelimit-remaining`)),r=I(e.get(`ratelimit-reset`)??e.get(`x-ratelimit-reset`)),i=e.get(`ratelimit-policy`)??void 0;t===void 0&&n===void 0&&r===void 0&&i===void 0||(C={limit:t,remaining:n,reset:r,...i?{policy:i}:{}},R())}function R(){if(w||!C)return;let{limit:e,remaining:t,reset:n}=C;if(t===void 0||t>20||A()||!process.stdout.isTTY)return;w=!0;let r=e===void 0?`the`:String(e),i=n===void 0?``:`, resets in ${Math.max(0,Math.round(n))}s`;process.stderr.write(a(`rate limit: ${t} of ${r} left${i}\n`))}function z(e){let t={};for(let[n,r]of Object.entries(e))t[n]=n.toLowerCase()===`authorization`?`Bearer ${s(r.replace(/^Bearer\s+/i,``))}`:r;return t}function B(e){process.stderr.write(a(e.endsWith(`
2
- `)?e:`${e}\n`))}function V(e){return e.get(`x-request-id`)??e.get(`x-requestid`)??e.get(`request-id`)??void 0}async function H(e){if(e.status===204)return;let t=await e.text();if(t!==``){if((e.headers.get(`content-type`)??``).includes(`json`))try{return JSON.parse(t)}catch{return t}return t}}function U(e){return new Promise(t=>{setTimeout(t,e).unref?.()})}function W(e,t,n){return e instanceof Error&&(e.name===`TimeoutError`||e.name===`AbortError`)?r(`Request to ${t} timed out after ${Math.round(n/1e3)}s`,e):r(`Could not reach ${t}: ${e.message}`,e,`Check your network connection, a proxy, or --api-url`)}async function G(r){if(/^https?:/i.test(r.path))throw new t(`path must be relative to the API base URL, got "${r.path}"`,{exitCode:e.USAGE});let a=D(),o=k(),s=O(),c=b.sleep??U,l=r.idempotent??r.method===`GET`,u=r.timeoutMs??N(r.method,r.path),d=M(a.apiUrl,r.path,r.query),p={authorization:`Bearer ${a.token}`,accept:`application/json`,"user-agent":i(f.id),...s?{"x-language":s}:{},...r.headers},m=r.body!==void 0&&r.method!==`GET`;m&&(p[`content-type`]=`application/json`);let h;for(let e=1;e<=3;e+=1){let t=Date.now();o&&(B(`→ ${r.method} ${d} (attempt ${e}/3, timeout ${u}ms)`),B(` headers ${JSON.stringify(z(p))}`),m&&B(` body ${JSON.stringify(r.body)}`));let i;try{i=await fetch(d,{method:r.method,headers:p,...m?{body:JSON.stringify(r.body)}:{},signal:AbortSignal.timeout(u)})}catch(n){if(h=W(n,d,u),o&&B(`← network error after ${Date.now()-t}ms: ${n.message}`),e<3){await c(F(e));continue}throw h}L(i.headers);let a=await H(i);if(o&&(B(`← ${i.status} ${i.statusText} in ${Date.now()-t}ms`),B(` rateLimit ${JSON.stringify(C??{})}`)),i.ok)return a;let s=new n({status:i.status,body:a,requestId:V(i.headers),method:r.method,path:r.path});if(!(i.status===429?l:i.status===502||i.status===503||i.status===504)||e===3)throw s;let f=P(i.headers.get(`retry-after`))??F(e);if(f>_)throw s;await c(f),h=s}throw h??new t(`Request failed`,{exitCode:e.GENERIC})}export{v as a,E as c,G as d,N as f,_ as i,j as l,m as n,g as o,h as r,M as s,p as t,P as u};
@@ -1 +0,0 @@
1
- import"./exit-codes-eYq58Sw_.js";import"./errors-DK8JR_St.js";import"./version-B0Ypbd8g.js";import"./color-BbAK7_Y7.js";import"./output-CDjsADAT.js";import"./config-nFtRCrru.js";import"./product-CXL7Ga4M.js";import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./http-DAgILPv-.js";export{u as DEFAULT_TIMEOUT_MS,o as LONG_TIMEOUT_MS,c as MAX_ATTEMPTS,i as MAX_RETRY_AFTER_MS,e as RATE_LIMIT_WARN_THRESHOLD,s as RETRY_BASE_MS,l as buildUrl,t as configureHttp,a as getLastRateLimit,d as parseRetryAfter,n as request,r as timeoutForRequest};
@@ -1 +0,0 @@
1
- import"./exit-codes-eYq58Sw_.js";import"./errors-DK8JR_St.js";import"./version-B0Ypbd8g.js";import"./color-BbAK7_Y7.js";import"./output-CDjsADAT.js";import"./config-nFtRCrru.js";import"./product-CXL7Ga4M.js";import"./http-DAgILPv-.js";import"./types-BGk3hWyo.js";import"./prompt-BUh1Q_gg.js";import"./client-oUdubIcu.js";import{a as e,i as t,n,o as r,r as i,t as a}from"./keyword-CNU86Lta.js";export{a as collectKeyword,n as findKeyword,i as formatMoney,t as normalizeKeyword,e as normalizeKeywords,r as registerKeywordCommands};
@@ -1 +0,0 @@
1
- import{i as e}from"./exit-codes-eYq58Sw_.js";import{d as t,m as n,n as r}from"./errors-DK8JR_St.js";import{c as i,f as a,g as o,h as s,i as c,m as l,o as u,p as d,r as f,s as p,v as m}from"./output-CDjsADAT.js";import{t as h}from"./product-CXL7Ga4M.js";import{f as g,n as _,u as v}from"./types-BGk3hWyo.js";import{i as y}from"./prompt-BUh1Q_gg.js";import{_ as b,b as x,c as S,i as C,l as w,n as T,o as E,p as D,t as O,u as k,y as A}from"./client-oUdubIcu.js";const j=`${h.appUrl}/billing`;function M(e){let t=e.trim().toLowerCase();if(t===``)throw n(`A keyword cannot be empty`);if(t.length>_)throw n(`"${t.slice(0,32)}…" is ${t.length} characters, the limit is ${_}`);return t}function N(e){return[...new Set(e.map(M))]}const P=(e,t=[])=>[...t,M(e)];function F(e){return`$${e.toFixed(2)}`}function I(e,t){for(let n of e){let e=n.keywords.find(e=>e.id===t);if(e)return{website:n,keyword:e}}}const L=[{header:`ID`,value:e=>f(e.id)},{header:`KEYWORD`,value:e=>e.value},{header:`STATUS`,value:e=>e.status},{header:`NOTE`,value:e=>e.status===`PENDING`?`no free slot on this plan`:`—`}];async function R(e,t){let n=p()||u()?null:g(e);try{return await t()}finally{n?.stop()}}async function z(e){let{websites:n}=await R(`Loading keywords…`,b),r=I(n,e);if(!r)throw t(`No keyword with id "${e}" in this workspace`,`list them with: ${h.binName} site list`);return r}function B(e){let t=e.keywords.filter(e=>e.status===`PENDING`).length;t!==0&&(i(``),i(`${t} pending. Price an upgrade: ${h.binName} keyword plan --count ${e.keywords.filter(e=>e.status!==`DISABLED`).length}`))}async function V(e,t){let r=N(t);if(r.length===0)throw n(`Pass at least one keyword`);let a=await R(`Adding keywords…`,()=>T(e,{keywords:r}));if(u()){d(`keyword.add`,a);return}let c=a.keywords.filter(e=>r.includes(e.value)),l=a.keywords.filter(e=>e.status===`ACTIVE`).length;o(`${a.domain} now has ${a.keywords.length} keywords (${l} active)`),c.length>0&&(i(``),s(c,L)),B(a)}async function H(e,t){let n=M(t.value),{keyword:r}=await z(e);if(r.value===n){if(u()){d(`keyword.edit`,r);return}i(`No change (case-only edit).`);return}let s=await R(`Renaming keyword…`,()=>w(e,{value:n}));if(u()){d(`keyword.edit`,s);return}o(`${r.value} → ${s.value}`),a([[`status`,s.status],[`slot`,`kept, editing is free and unlimited`]])}async function U(e){let t=await R(`Disabling keyword…`,()=>S(e));if(u()){d(`keyword.disable`,t);return}o(`"${t.value}" is ${t.status}`),i(`Its mentions are kept and it no longer occupies a paid slot. Nothing was charged.`)}async function W(e){let t=await R(`Enabling keyword…`,()=>k(e));if(u()){d(`keyword.enable`,t);return}if(t.status===`PENDING`){o(`"${t.value}" is PENDING`),i(`No free slot on this plan, so it is not collecting yet. Nothing was charged.`),c(`price an upgrade: ${h.binName} keyword plan`);return}o(`"${t.value}" is ${t.status}`),i(`Nothing was charged.`)}async function G(t,n){let{website:i,keyword:a}=await z(t),{total:s}=await C({websiteId:i.id,keywords:[a.value],statuses:[...v],includeLowRelevance:!0});if(n.yes!==!0&&(m(`Deleting "${a.value}" also deletes the ${s} mention${s===1?``:`s`} it produced. There is no undo and no refund.`),c(`To pause instead, keeping the mentions: ${h.binName} keyword disable ${a.id}`),(await y(`Type DELETE to confirm`,{hint:`Pass --yes to delete without typing DELETE`})).trim()!==`DELETE`))throw new r(`That is not DELETE, nothing was deleted.`,{exitCode:e.CANCELLED});let l=await E(a.id);if(u()){d(`keyword.delete`,l);return}o(`Deleted`)}async function K(){let{websites:e}=await R(`Activating pending keywords…`,O);if(u()){d(`keyword.activate-pending`,e,{total:e.length,hasMore:!1});return}let t=e.reduce((e,t)=>e+t.keywords.filter(e=>e.status===`ACTIVE`).length,0),n=e.reduce((e,t)=>e+t.keywords.filter(e=>e.status===`PENDING`).length,0);o(`${t} active keyword${t===1?``:`s`} across ${e.length} site${e.length===1?``:`s`}`),i(n===0?`Nothing left pending. This never charges.`:`${n} still pending, there was no free slot. This never charges.`),n>0&&c(`price an upgrade: ${h.binName} keyword plan --count ${t+n}`)}function q(e){l([`CURRENT`,`TARGET`],[[`${e.currentPlanName??`no plan`} ${F(e.currentMonthlyPrice)}/mo`,`${e.targetPlanName??`no plan`} ${F(e.targetMonthlyPrice)}/mo (${e.targetKeywords} keywords)`]]),i(``),a([[`upgrade`,e.isUpgrade?`yes`:e.isDowngrade?`no, downgrade`:`no change`],[`charged now`,`${F(e.immediateCharge)}${e.isUpgrade?` (prorated)`:``}`],[`payment needed`,e.requiresImmediatePayment?`yes`:`no`]]),i(``),i(`Plans change in the ${h.displayName} app: ${j}`)}async function J(e){let t;if(e.count===void 0)t=await R(`Pricing your pending keywords…`,A);else{let r=Number(e.count);if(!Number.isInteger(r)||r<1)throw n(`--count must be a whole number of 1 or more, got "${e.count}"`,`--count is the account-wide total of active keywords you want, not how many to add`);t=await R(`Pricing that keyword count…`,()=>x({desiredKeywordCount:r}))}if(u()){d(`keyword.plan`,t);return}q(t)}async function Y(){let e=await R(`Reading keyword edit usage…`,D);if(u()){d(`keyword.usage`,e);return}if(e.unlimited){i(`Keyword edits: unlimited (this plan does not meter them).`);return}a([[`used`,String(e.used)],[`limit`,String(e.limit)],[`remaining`,String(e.remaining)]])}function X(e){let t=e.command(`keyword`).alias(`keywords`).alias(`kw`).description(`keywords a site listens for`);t.command(`add <siteId> <keyword...>`).description(`add keywords to a site`).action(async(e,t)=>{await V(e,t)}),t.command(`edit <id>`).description(`rename a keyword, free and unlimited`).requiredOption(`--value <keyword>`,`the new keyword`).action(async(e,t)=>{await H(e,t)}),t.command(`disable <id>`).description(`stop collecting for a keyword, keeping its mentions`).action(async e=>{await U(e)}),t.command(`enable <id>`).description(`start collecting for a disabled keyword`).action(async e=>{await W(e)}),t.command(`delete <id>`).alias(`rm`).description(`delete a keyword and every mention it produced`).action(async(e,t,n)=>{await G(e,n.optsWithGlobals())}),t.command(`activate-pending`).description(`promote pending keywords into any free slots`).action(async()=>{await K()}),t.command(`plan`).description(`price the plan a keyword count needs`).option(`--count <n>`,`account-wide total of active keywords you want, not an increment`).action(async e=>{await J(e)}),t.command(`usage`).description(`how many keyword edits this plan allows`).action(async()=>{await Y()})}export{N as a,M as i,I as n,X as o,F as r,P as t};
@@ -1,3 +0,0 @@
1
- import"./exit-codes-eYq58Sw_.js";import{m as e}from"./errors-DK8JR_St.js";import{r as t}from"./color-BbAK7_Y7.js";import{c as n,i as r,p as i}from"./output-CDjsADAT.js";import{I as a,S as o}from"./config-nFtRCrru.js";import{t as s}from"./product-CXL7Ga4M.js";import{join as c}from"node:path";import{homedir as l}from"node:os";const u=s.id,d=`https://mcp.redreplier.com/mcp`,f=`@redreplier/mcp-server`,p=`${s.envPrefix}_API_TOKEN`,m=[`claude`,`cursor`,`vscode`,`windsurf`,`codex`,`json`],h={claude:c(l(),`.claude.json`),cursor:c(l(),`.cursor`,`mcp.json`),vscode:c(`.vscode`,`mcp.json`),windsurf:c(l(),`.codeium`,`windsurf`,`mcp_config.json`),codex:c(l(),`.codex`,`config.toml`),json:c(l(),`.${u}-mcp.json`)};function g(e,t){return t?{command:`npx`,args:[`-y`,f],env:{[p]:e}}:{type:`http`,url:d,headers:{Authorization:`Bearer ${e}`}}}function _(e,t,n){if(e===`codex`){let e=[`[mcp_servers.${u}]`];return n?e.push(`command = "npx"`,`args = ["-y", "${f}"]`,`env = { ${p} = "${t}" }`):e.push(`url = "${d}"`,`http_headers = { Authorization = "Bearer ${t}" }`),e.join(`
2
- `)}let r=e===`vscode`?`servers`:`mcpServers`;return JSON.stringify({[r]:{[u]:g(t,n)}},null,2)}function v(e,t){return t?`claude mcp add ${u} --env ${p}=${e} -- npx -y ${f}`:`claude mcp add --transport http ${u} ${d} --header "Authorization: Bearer ${e}"`}function y(c){c.command(`mcp`).description(`print the ${s.displayName} MCP server config for your editor`).option(`--client <client>`,`one of ${m.join(`, `)}`,`claude`).option(`--local`,`use the stdio server from npm instead of the hosted one`).option(`--write`,`name the file this config belongs in, without touching it`).option(`--install`,`alias of --write`).action(c=>{let l=c.client.toLowerCase();if(!m.includes(l))throw e(`Unknown MCP client "${c.client}".`,`Supported clients: ${m.join(`, `)}`);let u,g=`default`;try{let e=o();u=e.token,g=e.name}catch{u=void 0}let y=!!c.local,b=!!(c.write||c.install),x=b||!process.stdout.isTTY,S=`\${${p}}`,C=u??S,w=u&&!x?a(u):C,T=h[l];i(`mcp`,{client:l,transport:y?`stdio`:`http`,url:y?null:d,package:y?f:null,configFile:T,config:l===`codex`?_(l,C,y):JSON.parse(_(l,C,y))}),l===`claude`?(n(`Add the ${s.displayName} MCP server to Claude Code:`),n(``),n(` ${v(w,y)}`),n(``),n(`Or paste this into your MCP config:`)):n(`Paste this into ${T}:`),n(``);for(let e of _(l,w,y).split(`
3
- `))n(` ${e}`);n(``),u?x||r(`The token is redacted on screen. Re-run with --write, or pipe this command, to get it in full.`):r(`Profile "${g}" has no token, the config above carries a placeholder. Run: ${s.binName} login`),b&&(n(`${t(`config file`)} ${T}`),r(`Nothing was written. Merge the block above into that file yourself, it may already hold other servers.`))})}export{y as registerMcpCommand};
@@ -1 +0,0 @@
1
- import{i as e}from"./exit-codes-eYq58Sw_.js";import{d as t,m as n}from"./errors-DK8JR_St.js";import"./version-B0Ypbd8g.js";import{r}from"./color-BbAK7_Y7.js";import{_ as i,c as a,f as o,g as s,h as c,i as l,o as u,p as d,r as f,s as p,u as m,v as h}from"./output-CDjsADAT.js";import{a as g,i as _,n as v,r as y,t as b}from"./time-DaUXqVz-.js";import{v as ee}from"./config-nFtRCrru.js";import{t as x}from"./product-CXL7Ga4M.js";import"./http-DAgILPv-.js";import{c as S,d as C,f as te,l as w,o as T,s as E,u as D}from"./types-BGk3hWyo.js";import{d as O,g as k,i as A,w as j}from"./client-oUdubIcu.js";import{spawn as ne}from"node:child_process";function re(e,t,r,i=`--limit`){if(e===void 0)return r;let a=typeof e==`number`?e:Number(e);if(!Number.isInteger(a)||a<t||a>r)throw n(`${i} must be an integer between ${t} and ${r}`);return a}function ie(e,t=`--offset`){if(e===void 0)return 0;let r=typeof e==`number`?e:Number(e);if(!Number.isInteger(r)||r<0)throw n(`${t} must be an integer of 0 or more`);return r}async function ae(e){let t=e.maxPages??50,n=e.collect!==!1,r=[],i=e.offset??0,a=0,o=0,s,c=!1;for(;a<t;){let l=await e.fetchPage({limit:e.pageSize,offset:i});if(a+=1,o+=l.items.length,l.total!==void 0&&(s=l.total),n&&r.push(...l.items),await e.onPage?.(l.items,{index:a-1,offset:i,total:l.total}),i+=l.items.length,l.items.length===0||l.hasMore===!1||l.hasMore===void 0&&(l.items.length<e.pageSize||s!==void 0&&i>=s))break;if(a>=t){c=!0;break}}return c&&!e.quiet&&h(`stopped after ${t} requests (${o} items). Continue with --offset ${i}`),{items:r,total:s,pages:a,fetched:o,truncated:c}}const M=5e3;var oe=class{keys=new Map;constructor(e){this.limit=e}has(e){return this.keys.has(e)?(this.keys.delete(e),this.keys.set(e,!0),!0):!1}add(e){for(this.keys.has(e)&&this.keys.delete(e),this.keys.set(e,!0);this.keys.size>this.limit;){let e=this.keys.keys().next();if(e.done)break;this.keys.delete(e.value)}}get size(){return this.keys.size}};function se(e){return new Promise(t=>{setTimeout(t,e).unref?.()})}function ce(e){if(!e||typeof e!=`object`)return;let t=e;if(t.status!==429)return;let n=[t.retryAfterMs,t.retryAfterSeconds,t.retryAfter];for(let[e,t]of n.entries())if(typeof t==`number`&&Number.isFinite(t))return e===0?t:t*1e3;let r=t.body;if(r&&typeof r==`object`){let e=r.retryAfter;if(typeof e==`number`&&Number.isFinite(e))return e*1e3}return M}function le(e){let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?r===0?`${n}m`:`${n}m${r}s`:`${Math.floor(n/60)}h${n%60}m`}async function ue(t){let n=Math.max(M,t.intervalMs),i=Math.max(n,t.maxIntervalMs??6e4),a=t.sleep??se,o=t.onExit??(e=>process.exit(e)),s=new oe(1e4),c=Date.now(),l=n,u=t.cursor,d=0,f=0,p,m=!1,h,g=()=>{m=!0,h?.()};process.on(`SIGINT`,g);let _=async e=>{m||await new Promise(t=>{let n=!1,r=()=>{n||(n=!0,h=void 0,t())};h=r,a(e).then(r)})},v=e=>({emitted:d,polls:f,reason:e,cursor:u,last:p});try{for(;;){let e;try{e=await t.fetchPage(u)}catch(e){let t=ce(e);if(t===void 0)throw e;if(await _(Math.min(t,i)),m)break;continue}f+=1,u=e.cursor;let r=0,a=!1;for(let n of e.items){let e=t.key(n);if(!s.has(e)&&(s.add(e),r+=1,p=n,await t.onItem(n),d+=1,t.until?.(n))){a=!0;break}}if(a)return v(`until`);if(m)break;if(l=r>0?n:Math.min(i,Math.round(l*1.5)),t.timeoutMs!==void 0&&Date.now()-c>=t.timeoutMs)return v(`timeout`);if(await _(l),m)break;if(t.timeoutMs!==void 0&&Date.now()-c>=t.timeoutMs)return v(`timeout`)}}finally{process.removeListener(`SIGINT`,g)}let y=t.label??`items`;return process.stderr.write(r(`\nstopped. ${d} ${y} in ${le(Date.now()-c)}, ${f} polls\n`)),o(e.CANCELLED),v(`interrupted`)}const de=[[75,`VERY_HIGH`],[50,`HIGH`],[30,`MEDIUM`],[10,`LOW`],[0,`VERY_LOW`]];function N(e){if(e===null||!Number.isFinite(e))return null;for(let[t,n]of de)if(e>=t)return n;return`VERY_LOW`}function P(e){let t=e.trim().toUpperCase();if(!D.includes(t))throw n(`Unknown status "${e}"`,`valid statuses: ${D.join(`, `)}`);return t}function F(e){let t=e.trim().toUpperCase().replace(/-/g,`_`);if(!C.includes(t))throw n(`Unknown bucket "${e}"`,`valid buckets: ${C.join(`, `)}`);return t}function I(e){let t=e.trim().toUpperCase().replace(/-/g,`_`);if(!w.includes(t))throw n(`Unknown source "${e}"`,`valid sources: ${w.join(`, `)}`);return t}function L(e){let t=e.trim().toUpperCase();if(!S.includes(t))throw n(`Unknown sort "${e}"`,`valid sorts: ${S.join(`, `)}`);return t}const fe=(e,t=[])=>[...t,e],R=(e,t=[])=>[...t,P(e)],z=(e,t=[])=>[...t,F(e)],B=(e,t=[])=>[...t,I(e)];function V(e){let t={};e.site!==void 0&&e.site!==``&&(t.websiteId=e.site),e.status&&e.status.length>0&&(t.statuses=e.status),e.bucket&&e.bucket.length>0&&(t.scoreBuckets=e.bucket),e.includeLow===!0&&(t.includeLowRelevance=!0);let n=Z(e.minScore);return n!==void 0&&(t.minScore=n),e.keyword&&e.keyword.length>0&&(t.keywords=e.keyword),e.source&&e.source.length>0&&(t.sources=e.source),e.from!==void 0&&(t.from=g(y(e.from))),e.to!==void 0&&(t.to=g(y(e.to))),t}function H(e){if(e!==void 0&&e!==``)return e;let t=ee().defaultSite;return typeof t==`string`&&t!==``?t:void 0}function U(e){return e.subreddit?`r/${e.subreddit}`:e.source}function W(e){return e.author?e.source===`REDDIT_POST`||e.source===`REDDIT_COMMENT`?e.author.startsWith(`u/`)?e.author:`u/${e.author}`:e.author:`—`}function G(e){let t=e.publishedAt??e.ingestedAt??e.createdAt;if(t===null)return null;let n=new Date(t);return Number.isNaN(n.getTime())?null:n}const pe=e=>{let t=G(e);return t===null?`—`:v(t)},K=e=>(e??``).replace(/\s+/g,` `).trim()||`—`,me=[{header:`SCORE`,value:e=>e.relevanceScore??`—`,align:`right`},{header:`SOURCE`,value:U},{header:`WHEN`,value:pe},{header:`KEYWORD`,value:e=>e.keyword||`—`},{header:`TITLE`,value:e=>K(e.title??e.contentText)}];async function q(e,t){let n=p()||u()?null:te(e);try{return await t()}finally{n?.stop()}}function he(e,t,n){let r=e.replace(/\s+/g,` `).trim().split(` `),i=[],a=``;for(let e of r){if(a===``){a=e;continue}if(`${a} ${e}`.length+n.length>t){i.push(`${n}${a}`),a=e;continue}a=`${a} ${e}`}return a!==``&&i.push(`${n}${a}`),i}function J(e,t=` `){for(let n of he(e,Math.max(40,i()-2),t))a(n)}async function ge(e,t){try{let{total:n}=await A({...e,includeLowRelevance:!0});return Math.max(0,n-t)}catch{return 0}}async function _e(e){let t=V({...e,site:H(e.site)}),n=e.limit===void 0?50:re(e.limit,E,T),r=ie(e.offset),i=e.sort,o,s,f=!1;if(e.all){let n=await ae({pageSize:T,offset:r,quiet:e.quiet===!0||p(),fetchPage:async e=>{let n=await k({...t,sort:i,limit:e.limit,offset:e.offset});return{items:n.mentions,total:n.total,hasMore:n.offset+n.mentions.length<n.total}}});o=n.items,s=n.total}else{let e=await q(`Loading mentions…`,()=>k({...t,sort:i,limit:n,offset:r}));o=e.mentions,s=e.total,f=e.offset+e.mentions.length<e.total}if(u()){d(`mention.list`,o,{total:s,limit:e.all?void 0:n,offset:e.all?void 0:r,hasMore:f}),m(o);return}if(o.length===0?a(`No mentions match those filters.`):(c(o,me),a(``),a(`${o.length} of ${s??o.length} · open: ${x.binName} mention show <id>`),f&&a(`next: --offset ${r+o.length}`)),t.statuses?.includes(`REJECTED`)||l(`REJECTED mentions are hidden unless you pass --status REJECTED.`),e.includeLow!==!0){let e=await ge(t,s??o.length);e>0&&l(`${e} mention${e===1?``:`s`} below the site’s minimum score ${e===1?`is`:`are`} hidden. Add --include-low.`)}}async function ve(e){let t=V({...e,site:H(e.site)}),n=await q(`Counting mentions…`,()=>A(t));if(u()){d(`mention.count`,n);return}a(`${n.total} mention${n.total===1?``:`s`} match`)}async function ye(e,t){let n={...t,statuses:t.statuses??[...D],includeLowRelevance:!0};for(let t=0;t<20;t+=1){let r=t*T,i=await k({...n,sort:`RECENT`,limit:T,offset:r}),a=i.mentions.find(t=>t.id===e||t.id.startsWith(e));if(a)return a;if(i.mentions.length===0||r+i.mentions.length>=i.total)return}}function Y(e){let t=G(e),n=N(e.relevanceScore);a([U(e),t===null?`unknown time`:v(t),e.relevanceScore===null?`unscored`:`score ${e.relevanceScore}${n===null?``:` (${n})`}`,e.status].join(` · `)),o([[`id`,e.id],[`keyword`,e.keyword||`—`],[`author`,W(e)],[`url`,e.url],...t===null?[]:[[`posted`,b(t,{timezone:_()})]],...e.tags.length>0?[[`tags`,e.tags.join(`, `)]]:[]]),e.title&&(a(``),J(e.title)),e.contentText&&(a(``),J(e.contentText)),e.relevanceReason&&(a(``),a(r(e.relevanceScore===null?`why it was scored`:`why it scored ${e.relevanceScore}`)),J(e.relevanceReason,` `)),e.aiReplySuggestion&&(a(``),a(r(`suggested reply`)),J(e.aiReplySuggestion,` `)),a(``),a(`approve: ${x.binName} mention status ${e.id} APPROVED`)}async function be(e,n){let r=n.explain?await q(`Explaining mention…`,()=>O(e)):await q(`Searching mentions…`,()=>ye(e,V({...n,site:H(n.site)})));if(!r)throw t(`Mention not found in this workspace`,n.explain?`drop --explain to page through /mentions instead`:`${x.binName} mention list --limit 20`);if(u()){d(`mention.show`,r);return}Y(r)}async function xe(e,t){let n=P(t),r=await q(`Updating status…`,()=>j(e,{status:n}));if(u()){d(`mention.status`,r);return}s(`${f(r.id)} is ${r.status}`),a(`Reversible: ${x.binName} mention status ${r.id} NEW`)}async function Se(e){l(`The first call runs generation and can take up to two minutes. Later calls are instant reads.`);let n=await q(`Explaining mention…`,()=>O(e));if(!n)throw t(`Mention not found in this workspace`,`${x.binName} mention list --limit 20`);if(u()){d(`mention.explain`,n);return}Y(n)}function X(e){if(e===void 0)return 60;let t=Number(e);if(!Number.isInteger(t)||t<30)throw n(`--interval must be a whole number of 30 seconds or more, got "${e}"`,`every poll spends from the 600 requests per minute budget`);return t}function Z(e){if(e===void 0)return;let t=Number(e);if(!Number.isInteger(t)||t<0||t>100)throw n(`--min-score must be a whole number between 0 and 100, got "${e}"`);return t}function Ce(e){return{RR_ID:e.id,RR_SCORE:e.relevanceScore===null?``:String(e.relevanceScore),RR_URL:e.url,RR_SOURCE:e.source,RR_KEYWORD:e.keyword??``,RR_TITLE:e.title??``}}async function we(e,t){return new Promise(n=>{let r=ne(e,{shell:!0,stdio:[`pipe`,`pipe`,`pipe`],env:{...process.env,...Ce(t)}});r.stdout?.on(`data`,e=>process.stderr.write(e)),r.stderr?.on(`data`,e=>process.stderr.write(e)),r.on(`error`,e=>{process.stderr.write(`${e.message}\n`),n(1)}),r.on(`close`,e=>n(e??1)),r.stdin?.end(`${JSON.stringify(t)}\n`)})}async function Q(e){let t=X(e.interval),n=e.since===void 0?new Date:y(e.since),r=_(),i=V({...e,site:H(e.site),from:void 0}),o={...i,from:g(n),sort:`RECENT`,limit:50};u()||a(`Tailing new mentions ${i.websiteId===void 0?`for every site`:`for site ${f(i.websiteId)}`}${i.minScore===void 0?``:`, score ≥ ${i.minScore}`}, every ${t}s. Ctrl-C to stop.`),await ue({intervalMs:t*1e3,maxIntervalMs:3e5,label:`mentions`,key:e=>e.id,fetchPage:async e=>({items:[...(await k(o)).mentions].reverse(),cursor:e}),onItem:async t=>{if(u()?process.stdout.write(`${JSON.stringify(t)}\n`):a([b(G(t)??new Date,{timezone:r,seconds:!0,withZone:!1}).slice(11),String(t.relevanceScore??`—`).padStart(3),U(t).padEnd(12),K(t.title??t.contentText)].join(` `)),e.exec===void 0)return;let n=await we(e.exec,t);if(n!==0){h(`--exec exited ${n} for ${t.id}, the tail continues`);return}if(e.approveOnExecSuccess===!0)try{await j(t.id,{status:`APPROVED`})}catch(e){h(`could not approve ${t.id}: ${e instanceof Error?e.message:String(e)}`)}}})}const $=e=>e.option(`--site <id>`,`only this site`).option(`--status <status>`,`filter by status, repeatable: ${D.join(`, `)}`,R,[]).option(`--bucket <bucket>`,`filter by score bucket, repeatable: ${C.join(`, `)}`,z,[]).option(`--include-low`,`include mentions below the site’s minimum score`).option(`--min-score <n>`,`only mentions scoring at least this, 0 to 100; unscored ones are left out`).option(`--keyword <keyword>`,`filter by keyword, repeatable`,fe,[]).option(`--source <source>`,`filter by source, repeatable: ${w.join(`, `)}`,B,[]).option(`--from <date>`,`lower bound on ingestion time`).option(`--to <date>`,`upper bound on ingestion time`);function Te(e){let t=e.command(`mention`).alias(`mentions`).description(`lead mentions found across Reddit, Hacker News, X and Bluesky`);$(t.command(`list`,{isDefault:!0})).alias(`ls`).description(`list mentions`).option(`--sort <order>`,`${S.join(` or `)}`,L).option(`--limit <n>`,`mentions per page, ${E} to ${T}`).option(`--offset <n>`,`mentions to skip`).option(`--all`,`page until the server runs out`).action(async(e,t)=>{await _e(t.optsWithGlobals())}),$(t.command(`count`)).description(`count the mentions matching the filters`).action(async e=>{await ve(e)}),$(t.command(`show <id>`)).alias(`get`).description(`show one mention, its score reason and its suggested reply`).option(`--explain`,`fetch it through /mentions/{id}/explain instead of paging /mentions`).action(async(e,t)=>{await be(e,t)}),t.command(`status <id> <status>`).description(`set a mention's status: ${D.join(`, `)}`).action(async(e,t)=>{await xe(e,t)}),t.command(`explain <id>`).description(`generate, then read, why a mention scored as it did`).action(async e=>{await Se(e)}),$(t.command(`tail`)).description(`follow new mentions as they arrive`).option(`--interval <seconds>`,`poll every N seconds, floor 30`).option(`--since <date>`,`start from this time instead of now`).option(`--exec <command>`,`run this command once per mention, JSON on its stdin`).option(`--approve-on-exec-success`,`approve a mention when --exec exits 0`).action(async(e,t)=>{await Q(t.optsWithGlobals())})}export{W as authorLabel,V as buildFilterQuery,G as mentionDate,F as normalizeBucket,L as normalizeSort,I as normalizeSource,P as normalizeStatus,Z as parseMinScore,X as parseTailInterval,Te as registerMentionCommands,N as relevanceBucketOf,H as resolveSite,U as sourceLabel};
@@ -1 +0,0 @@
1
- import"./exit-codes-eYq58Sw_.js";import{m as e}from"./errors-DK8JR_St.js";import"./color-BbAK7_Y7.js";import{c as t,p as n}from"./output-CDjsADAT.js";import{p as r}from"./config-nFtRCrru.js";import{t as i}from"./product-CXL7Ga4M.js";import{t as a}from"./open-url-CovrlP9b.js";const o={dashboard:{path:()=>`/dashboard`,needsId:!1},keywords:{path:()=>`/keywords`,needsId:!1},leads:{path:()=>`/leads`,needsId:!1},alerts:{path:()=>`/alerts`,needsId:!1},subreddits:{path:()=>`/subreddits`,needsId:!1},seo:{path:()=>`/seo`,needsId:!1},tokens:{path:()=>`/api-tokens`,needsId:!1},billing:{path:()=>`/billing`,needsId:!1},settings:{path:()=>`/settings/general`,needsId:!1},workspaces:{path:()=>`/workspaces`,needsId:!1}},s={home:`dashboard`,keyword:`keywords`,lead:`leads`,mention:`leads`,mentions:`leads`,alert:`alerts`,subreddit:`subreddits`,token:`tokens`,"api-tokens":`tokens`,workspace:`workspaces`};function c(c){c.command(`open`).argument(`[what]`,`one of ${Object.keys(o).join(`, `)}`,`dashboard`).argument(`[id]`,`identifier, for the targets that need one`).description(`open the ${i.displayName} web app in your browser`).action((c,l)=>{let u=s[c.toLowerCase()]??c.toLowerCase(),d=o[u];if(!d)throw e(`There is nothing to open called "${c}".`,`Targets: ${Object.keys(o).join(`, `)}`);if(d.needsId&&l===void 0)throw e(`open ${u} needs an id.`,`${i.binName} open ${u} <id>`);let f=`${i.appUrl}${d.path(l)}`;if(n(`open`,{target:u,url:f}),r().input===!1){t(f);return}t(a(f)?`Opening ${f}`:f)})}export{c as registerOpenCommand};
@@ -1 +0,0 @@
1
- const e={id:`redreplier`,displayName:`RedReplier`,binName:`redreplier`,altBinName:`rr`,npmPackage:`@redreplier/cli`,envPrefix:`REDREPLIER`,defaultApiUrl:`https://ai.redreplier.com/ai-app/api/v1`,appUrl:`https://redreplier.com`,tokensUrl:`https://redreplier.com/api-tokens`,tokenPrefixes:[`redreplier_`],verifyPath:`/websites`};export{e as t};
@@ -1 +0,0 @@
1
- import"./exit-codes-eYq58Sw_.js";import"./errors-DK8JR_St.js";import"./color-BbAK7_Y7.js";import{a as e,i as t,n,r,t as i}from"./prompt-BUh1Q_gg.js";export{i as isInteractive,n as promptConfirm,r as promptHidden,t as promptText,e as setInteractive};
@@ -1 +0,0 @@
1
- import{i as e}from"./exit-codes-eYq58Sw_.js";import{m as t,n}from"./errors-DK8JR_St.js";import"./version-B0Ypbd8g.js";import"./color-BbAK7_Y7.js";import{c as r,f as i,g as a,h as o,i as s,n as c,o as l,p as u,r as d,s as f,u as p,v as m}from"./output-CDjsADAT.js";import{n as h,t as g}from"./time-DaUXqVz-.js";import{d as _}from"./config-nFtRCrru.js";import{t as v}from"./product-CXL7Ga4M.js";import"./http-DAgILPv-.js";import{f as y,r as b,u as x}from"./types-BGk3hWyo.js";import{i as S,n as C}from"./prompt-BUh1Q_gg.js";import{T as w,_ as T,a as E,h as D,i as O,r as k,s as A}from"./client-oUdubIcu.js";import{a as j,t as M}from"./keyword-CNU86Lta.js";import{resolve as N}from"node:path";import{readFile as P}from"node:fs/promises";const F=[`ACTIVE`,`PENDING`,`DISABLED`,`SUSPENDED`];function I(e){let t={ACTIVE:0,PENDING:0,DISABLED:0,SUSPENDED:0};for(let n of e.keywords)t[n.status]+=1;return t}function L(e){let t=I(e),n=F.filter(e=>t[e]>0).map(e=>`${t[e]} ${e.toLowerCase()}`);return n.length===0?`none`:n.join(`, `)}function R(e,n=`--url`){let r=e.trim(),i;try{i=new URL(r)}catch{throw t(`${n} must be a full URL, got "${e}"`,`${v.binName} site create --url https://acme.com`)}if(i.protocol!==`https:`&&i.protocol!==`http:`)throw t(`${n} must be an http or https URL, got "${e}"`);return r}async function z(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString(`utf8`)}async function B(e){let n=(e===`-`?await z():e.startsWith(`@`)?await V(e.slice(1)):e).trim();if(n.length>b)throw t(`--description is ${n.length} characters, the limit is ${b}`);return n}async function V(t){try{return await P(N(t),`utf8`)}catch(r){throw new n(`Cannot read ${t}: ${r.message}`,{exitCode:e.USAGE,cause:r})}}const H=[{header:`ID`,value:e=>d(e.id)},{header:`DOMAIN`,value:e=>e.domain},{header:`NAME`,value:e=>e.name||`—`},{header:`KEYWORDS`,value:e=>L(e)},{header:`DESCRIPTION`,value:e=>e.description?`yes`:`missing`}],U=[{header:`ID`,value:e=>d(e.id)},{header:`KEYWORD`,value:e=>e.value},{header:`STATUS`,value:e=>e.status},{header:`ADDED`,value:e=>e.createdAt?h(new Date(e.createdAt)):`—`}];async function W(e,t){let n=f()||l()?null:y(e);try{return await t()}finally{n?.stop()}}async function G(){let{websites:e}=await W(`Loading sites…`,T);if(l()){u(`site.list`,e,{total:e.length,hasMore:!1}),p(e);return}if(e.length===0){r(`No sites yet.`),s(`add one: ${v.binName} site create --url https://acme.com -k "your keyword"`);return}o(e,H),r(``),r(`${e.length} ${e.length===1?`site`:`sites`}`);for(let t of e)t.description||(m(`${t.domain} has no description. Its mentions are not scored.`),s(` fix: ${v.binName} site analyze --url ${t.url}`));let t=e.reduce((e,t)=>e+I(t).PENDING,0);s(`Listing sites activates any PENDING keyword that fits your plan’s free headroom.`),t>0&&s(`${t} keyword${t===1?``:`s`} still PENDING, there was no free slot. Price an upgrade: ${v.binName} keyword plan`)}async function K(e){let t=await W(`Loading site…`,()=>D(e));if(l()){u(`site.get`,t);return}r(t.id),i([[`domain`,t.domain],[`url`,t.url],[`name`,t.name||`—`],[`description`,t.description?`${t.description.length} characters`:`missing, mentions are not scored`],[`keywords`,L(t)],[`created`,t.createdAt?g(new Date(t.createdAt),{timezone:`UTC`}):`—`]]),t.keywords.length>0&&(r(``),o(t.keywords,U)),t.description||(r(``),s(`fix: ${v.binName} site analyze --url ${t.url}`))}async function q(t){let o=R(t.url),f=j(t.keyword),p=t.description===void 0?void 0:await B(t.description),h;if(p!==void 0)h={url:o,keywords:f,description:p,...t.name?{name:t.name}:{}};else if(t.analyze===!1)h={url:o,keywords:f,description:``,...t.name?{name:t.name}:{}},m(`--no-analyze sends an empty description, so nothing this site collects will be scored.`);else{let r=new URL(o).hostname;if(m(`No --description given. The server will scrape ${r} and spend one AI generation from this month’s quota.`),!l()&&!await C(`Continue?`,{assumeYes:t.yes===!0,initialValue:!0}))throw new n(`Cancelled.`,{exitCode:e.CANCELLED});h={url:o,keywords:f,...t.name?{name:t.name}:{}}}let g=await W(`Creating site…`,()=>E(h));if(l()){u(`site.create`,g);return}a(`Created ${d(g.id)} ${g.domain}`),i([[`description`,g.description?`${p===void 0?`generated`:`stored`} (${g.description.length} chars)`:`missing`],[`keywords`,L(g)]]),!g.description&&t.analyze!==!1&&(r(``),c(`Description generation failed. Mentions will be unscored ("Scoring skipped: website description missing").`),s(`retry: ${v.binName} site analyze --url ${g.url}`)),I(g).PENDING>0&&s(`Some keywords are PENDING. Price an upgrade: ${v.binName} keyword plan`)}async function J(e,n){let o={};if(n.name!==void 0&&(o.name=n.name),n.description!==void 0&&(o.description=await B(n.description)),Object.keys(o).length===0)throw t(`Nothing to update.`,`Pass --name, --description, or both`);let s=await W(`Updating site…`,()=>w(e,o));if(l()){u(`site.update`,s);return}a(`Updated ${d(s.id)} ${s.domain}`),i([[`name`,s.name||`—`],[`description`,s.description?`${s.description.length} characters`:`missing`]]),r(`Existing mentions are not rescored.`)}async function Y(t,i){let o=await W(`Loading site…`,()=>D(t)),{total:s}=await O({websiteId:o.id,statuses:[...x],includeLowRelevance:!0});if(i.yes!==!0&&(r(`This deletes ${o.domain}, its ${o.keywords.length} keyword${o.keywords.length===1?``:`s`} and ${s} collected mention${s===1?``:`s`}.`),(await S(`Type the domain to confirm`,{hint:`Pass --yes to delete without typing the domain`})).trim()!==o.domain))throw new n(`That is not "${o.domain}", nothing was deleted.`,{exitCode:e.CANCELLED});let c=await A(o.id);if(l()){u(`site.delete`,c);return}a(`Deleted`)}async function X(t){let r=R(t.url);if(m(`This spends one AI generation from this month’s quota unless a precomputed description exists for the domain. A failed generation is refunded.`),!l()&&!await C(`Continue?`,{assumeYes:t.yes===!0,initialValue:!0}))throw new n(`Cancelled.`,{exitCode:e.CANCELLED});let{description:i}=await W(`Analysing…`,()=>k({url:r}));if(l()){u(`site.analyze`,{description:i});return}process.stdout.write(`${i}\n`),s(`store it: ${_(`FORCE_TTY`)}=1 ${v.binName} site analyze --url ${r} | ${v.binName} site update <id> --description -`)}function Z(e){let t=e.command(`site`).alias(`sites`).description(`monitored websites and their keywords`);t.command(`list`).alias(`ls`).description(`list every monitored site`).action(async()=>{await G()}),t.command(`get <id>`).alias(`view`).description(`show one site with its full keyword table`).action(async e=>{await K(e)}),t.command(`create`).description(`start monitoring a website`).requiredOption(`--url <url>`,`the website to monitor`).option(`--name <name>`,`label for the site`).option(`-k, --keyword <keyword>`,`keyword to watch, repeatable`,M,[]).option(`--description <text>`,`what the site does; @file reads a file, - reads stdin`).option(`--no-analyze`,`send an empty description and skip the paid scrape`).action(async(e,t)=>{await q(t.optsWithGlobals())}),t.command(`update <id>`).description(`rename a site or replace its description`).option(`--name <name>`,`new label for the site`).option(`--description <text>`,`new description; @file reads a file, - reads stdin`).action(async(e,t)=>{await J(e,t)}),t.command(`delete <id>`).alias(`rm`).description(`delete a site, its keywords and every mention they produced`).action(async(e,t,n)=>{await Y(e,n.optsWithGlobals())}),t.command(`analyze`).description(`generate a site description from its URL`).requiredOption(`--url <url>`,`the website to read`).action(async(e,t)=>{await X(t.optsWithGlobals())})}export{R as assertWebsiteUrl,L as describeKeywords,I as keywordCounts,B as readDescription,Z as registerSiteCommands};
@@ -1 +0,0 @@
1
- import{r as e}from"./version-B0Ypbd8g.js";import{c as t,r as n}from"./color-BbAK7_Y7.js";import{D as r,d as i,y as a}from"./config-nFtRCrru.js";import{t as o}from"./product-CXL7Ga4M.js";const s=1440*60*1e3,c=2e3,l=`https://registry.npmjs.org`;function u(e,t){let n=e=>{let[t,n]=e.replace(/^v/,``).split(`-`,2);return{parts:t.split(`.`).map(e=>Number.parseInt(e,10)||0),pre:n??``}},r=n(e),i=n(t);for(let e=0;e<3;e+=1){let t=(r.parts[e]??0)-(i.parts[e]??0);if(t!==0)return t<0?-1:1}return r.pre===i.pre?0:r.pre===``?1:i.pre===``||r.pre<i.pre?-1:1}async function d(e=o.npmPackage,t=c){let n=await fetch(`${l}/${e.replace(`/`,`%2f`)}/latest`,{headers:{accept:`application/vnd.npm.install-v1+json, application/json`},signal:AbortSignal.timeout(t)});if(!n.ok)return;let r=await n.json();return typeof r.version==`string`?r.version:void 0}function f(e){return e.quiet||process.env.CI||process.env[i(`NO_UPDATE_CHECK`)]?!0:e.force?!1:!process.stdout.isTTY}async function p(t={}){if(f(t))return;let n=t.now??Date.now(),i;try{i=a()}catch{return}if(i.updateCheck===!1)return;let o=i.lastUpdateCheck,c=o?.checked?Date.parse(o.checked):NaN,l=!t.force&&Number.isFinite(c)&&n-c<s,p=l?o?.latest:void 0;if(!l){let e;try{e=await d()}catch{return}if(!e)return;p=e;let t={checked:new Date(n).toISOString(),latest:e};try{r(e=>{e.lastUpdateCheck=t})}catch{return}}if(p&&!(u(p,e)<=0))return{current:e,latest:p}}function m(e){process.stderr.write(`${t(`A new version of ${o.binName} is available: ${e.latest}`)} ${n(`(you have ${e.current})`)}\n`),process.stderr.write(n(`Update: npm i -g ${o.npmPackage} · disable: ${o.binName} config set updateCheck false\n`))}async function h(e={}){try{let t=await p(e);t&&m(t)}catch{return}}export{u as a,h as c,p as i,s as n,d as o,c as r,m as s,l as t};
@@ -1 +0,0 @@
1
- import"./exit-codes-eYq58Sw_.js";import"./errors-DK8JR_St.js";import"./version-B0Ypbd8g.js";import"./color-BbAK7_Y7.js";import"./config-nFtRCrru.js";import"./product-CXL7Ga4M.js";import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./update-check-9qIilkr0.js";export{s as REGISTRY_URL,r as UPDATE_CHECK_INTERVAL_MS,a as UPDATE_CHECK_TIMEOUT_MS,n as checkForUpdate,e as compareSemver,i as fetchLatestVersion,o as printUpdateNotice,t as runUpdateCheck};
@@ -1 +0,0 @@
1
- import{a as e,i as t,n,r,t as i}from"./version-B0Ypbd8g.js";export{i as NODE_VERSION,n as PLATFORM,r as VERSION,t as userAgent,e as versionLine};