agent-afk 5.100.3 → 5.101.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 (44) hide show
  1. package/dist/agent/awareness/types.d.ts +1 -1
  2. package/dist/agent/facets/schema.d.ts +2 -0
  3. package/dist/agent/permissions-store.d.ts +1 -1
  4. package/dist/agent/session/session-identity.d.ts +1 -1
  5. package/dist/agent/session/session-registry.d.ts +1 -1
  6. package/dist/agent/tools/hooks/path-approval-hook.d.ts +1 -1
  7. package/dist/agent/trace/events.d.ts +3 -0
  8. package/dist/agent/trace/types.d.ts +1 -1
  9. package/dist/cli/commands/web.d.ts +2 -0
  10. package/dist/cli/json-date-replacer.d.ts +1 -0
  11. package/dist/cli/session-store.d.ts +2 -2
  12. package/dist/cli/web-options.d.ts +8 -0
  13. package/dist/cli.mjs +617 -612
  14. package/dist/config/env.d.ts +3 -0
  15. package/dist/index.mjs +73 -73
  16. package/dist/paths.d.ts +1 -0
  17. package/dist/telegram.mjs +10 -10
  18. package/dist/web-server/auth.d.ts +14 -0
  19. package/dist/web-server/elicitation-web.d.ts +22 -0
  20. package/dist/web-server/frontend/ansi-strip.d.ts +1 -0
  21. package/dist/web-server/frontend/app.d.ts +1 -0
  22. package/dist/web-server/frontend/chrome.d.ts +1 -0
  23. package/dist/web-server/frontend/ledger-adapter.d.ts +14 -0
  24. package/dist/web-server/frontend/markdown-dom.d.ts +1 -0
  25. package/dist/web-server/frontend/queue-panel.d.ts +21 -0
  26. package/dist/web-server/frontend/queue-reorder.d.ts +5 -0
  27. package/dist/web-server/frontend/render.d.ts +35 -0
  28. package/dist/web-server/frontend/scroll-pin.d.ts +7 -0
  29. package/dist/web-server/frontend/sse-client.d.ts +20 -0
  30. package/dist/web-server/frontend/view-model.d.ts +48 -0
  31. package/dist/web-server/frontend/web-token.d.ts +3 -0
  32. package/dist/web-server/handoff.d.ts +9 -0
  33. package/dist/web-server/routes.d.ts +22 -0
  34. package/dist/web-server/server.d.ts +24 -0
  35. package/dist/web-server/session-owner.d.ts +33 -0
  36. package/dist/web-server/session-source.d.ts +11 -0
  37. package/dist/web-server/sse-protocol.d.ts +20 -0
  38. package/dist/web-server/static-assets.d.ts +10 -0
  39. package/dist/web-server/stream-route.d.ts +2 -0
  40. package/dist/web-ui-assets/app.js +64 -0
  41. package/dist/web-ui-assets/chrome.js +1 -0
  42. package/dist/web-ui-assets/index.html +64 -0
  43. package/dist/web-ui-assets/styles.css +333 -0
  44. package/package.json +4 -3
@@ -0,0 +1,14 @@
1
+ export declare function mintToken(): string;
2
+ export declare function tokensMatch(expected: string, provided: string | undefined): boolean;
3
+ export declare function bearerFromHeader(header: string | undefined): string | undefined;
4
+ export declare function tokenFromQuery(rawUrl: string): string | undefined;
5
+ export declare function nonceFromQuery(rawUrl: string): string | undefined;
6
+ export declare const DOC_COOKIE_NAME = "afk_web_doc";
7
+ export declare function docKeyFromCookie(header: string | undefined): string | undefined;
8
+ export declare function originAllowed(origin: string | undefined, host: string, port: number): boolean;
9
+ export declare function allowedOrigins(host: string, port: number): string[];
10
+ export interface BindCheck {
11
+ ok: boolean;
12
+ reason?: string;
13
+ }
14
+ export declare function checkBind(host: string, tokenExplicit: boolean): BindCheck;
@@ -0,0 +1,22 @@
1
+ import type { ElicitationRequest } from '../agent/types/sdk-types.js';
2
+ export interface PendingElicitation {
3
+ id: string;
4
+ request: ElicitationRequest;
5
+ sessionId?: string;
6
+ createdAt: string;
7
+ }
8
+ export type PendingListener = (pending: PendingElicitation[]) => void;
9
+ export declare class WebElicitationBridge {
10
+ private readonly waiters;
11
+ private readonly listeners;
12
+ private counter;
13
+ private installed;
14
+ install(): void;
15
+ uninstall(): void;
16
+ list(): PendingElicitation[];
17
+ onChange(listener: PendingListener): () => void;
18
+ resolve(id: string, response: unknown): boolean;
19
+ private enqueue;
20
+ private settle;
21
+ private emit;
22
+ }
@@ -0,0 +1 @@
1
+ export declare function stripAnsi(s: string): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { TranscriptItem } from './view-model.js';
2
+ export interface LedgerRecordLike {
3
+ v?: number;
4
+ ts?: number;
5
+ kind?: string;
6
+ [key: string]: unknown;
7
+ }
8
+ export declare function ledgerRecordToItem(record: LedgerRecordLike): TranscriptItem | undefined;
9
+ export interface SessionTotals {
10
+ costUsd: number;
11
+ durationMs: number;
12
+ turns: number;
13
+ }
14
+ export declare function accumulateTotals(totals: SessionTotals, record: LedgerRecordLike): SessionTotals;
@@ -0,0 +1 @@
1
+ export declare function renderMarkdown(source: string, className?: string): HTMLElement;
@@ -0,0 +1,21 @@
1
+ export interface QueuePanelDeps {
2
+ container: HTMLElement;
3
+ input: HTMLTextAreaElement;
4
+ send: HTMLElement;
5
+ submit: (text: string) => Promise<void>;
6
+ isLive: () => boolean;
7
+ isTurnActive: () => boolean;
8
+ onAccepted: () => void;
9
+ onError: (message: string) => void;
10
+ }
11
+ export declare class QueuePanel {
12
+ private readonly deps;
13
+ private queue;
14
+ private flushing;
15
+ constructor(deps: QueuePanelDeps);
16
+ entries(): readonly string[];
17
+ clear(): void;
18
+ wire(): void;
19
+ render(): void;
20
+ flush(): Promise<void>;
21
+ }
@@ -0,0 +1,5 @@
1
+ export declare function moveUp<T>(list: readonly T[], index: number): T[];
2
+ export declare function moveDown<T>(list: readonly T[], index: number): T[];
3
+ export declare function removeAt<T>(list: readonly T[], index: number): T[];
4
+ export declare function editAt<T>(list: readonly T[], index: number, value: T): T[];
5
+ export declare function insert<T>(list: readonly T[], index: number, value: T): T[];
@@ -0,0 +1,35 @@
1
+ import type { TranscriptItem } from './view-model.js';
2
+ export interface SessionSummary {
3
+ id: string;
4
+ mode: 'live' | 'readonly';
5
+ cwd?: string;
6
+ surface?: string;
7
+ updatedAt?: string;
8
+ title?: string;
9
+ alive?: boolean;
10
+ }
11
+ export declare function renderSidebar(container: HTMLElement, sessions: SessionSummary[], activeId: string | undefined, onSelect: (id: string) => void): void;
12
+ export declare function renderTranscript(container: HTMLElement, items: TranscriptItem[]): void;
13
+ export declare function relativeTime(iso: string): string;
14
+ export interface PendingApproval {
15
+ id: string;
16
+ sessionId?: string;
17
+ createdAt?: string;
18
+ request: {
19
+ message?: string;
20
+ title?: string;
21
+ description?: string;
22
+ serverName?: string;
23
+ origin?: string;
24
+ type?: 'text' | 'confirm' | 'choice' | 'multi_choice' | 'number';
25
+ choices?: string[];
26
+ questionDefault?: string | boolean | number;
27
+ };
28
+ }
29
+ export type ApprovalAnswer = {
30
+ action: 'accept';
31
+ content?: Record<string, unknown>;
32
+ } | {
33
+ action: 'decline';
34
+ };
35
+ export declare function renderApprovals(container: HTMLElement, pending: PendingApproval[], onAnswer: (id: string, answer: ApprovalAnswer) => void): void;
@@ -0,0 +1,7 @@
1
+ export declare const PIN_TOLERANCE_PX = 80;
2
+ export interface ScrollMetrics {
3
+ scrollTop: number;
4
+ scrollHeight: number;
5
+ clientHeight: number;
6
+ }
7
+ export declare function isPinnedToBottom(m: ScrollMetrics, tolerance?: number): boolean;
@@ -0,0 +1,20 @@
1
+ export type StreamStatus = 'connecting' | 'open' | 'reconnecting' | 'closed' | 'ended';
2
+ export interface StreamHandlers {
3
+ onEvent: (data: unknown, meta: {
4
+ id?: string;
5
+ }) => void;
6
+ onStatus?: (status: StreamStatus) => void;
7
+ }
8
+ export declare class SessionStream {
9
+ private readonly sessionId;
10
+ private readonly token;
11
+ private readonly handlers;
12
+ private controller;
13
+ private lastEventId;
14
+ private attempt;
15
+ private stopped;
16
+ constructor(sessionId: string, token: string, handlers: StreamHandlers);
17
+ start(): void;
18
+ stop(): void;
19
+ private connect;
20
+ }
@@ -0,0 +1,48 @@
1
+ import type { OutputEvent } from '../../agent/types/session-types.js';
2
+ import type { ToolDiffChunk } from '../../agent/types/message-types.js';
3
+ export interface UserMessageItem {
4
+ kind: 'user';
5
+ id: string;
6
+ text: string;
7
+ timestamp?: Date;
8
+ }
9
+ export interface AssistantTextItem {
10
+ kind: 'assistant';
11
+ id: string;
12
+ text: string;
13
+ }
14
+ export interface ThinkingItem {
15
+ kind: 'thinking';
16
+ id: string;
17
+ text: string;
18
+ }
19
+ export type ToolCallStatus = 'running' | 'ok' | 'error';
20
+ export interface ToolCallItem {
21
+ kind: 'tool';
22
+ id: string;
23
+ name: string;
24
+ inputPreview: string;
25
+ status: ToolCallStatus;
26
+ output?: string;
27
+ outputUnavailable?: boolean;
28
+ diff?: ToolDiffChunk['diff'];
29
+ }
30
+ export interface ErrorItem {
31
+ kind: 'error';
32
+ id: string;
33
+ message: string;
34
+ }
35
+ export interface NoticeItem {
36
+ kind: 'notice';
37
+ id: string;
38
+ text: string;
39
+ }
40
+ export type TranscriptItem = UserMessageItem | AssistantTextItem | ThinkingItem | ToolCallItem | ErrorItem | NoticeItem;
41
+ export interface ApplyOptions {
42
+ replay?: boolean;
43
+ }
44
+ export interface TranscriptModel {
45
+ apply(event: OutputEvent, opts?: ApplyOptions): void;
46
+ getItems(): TranscriptItem[];
47
+ }
48
+ export declare function createTranscriptModel(): TranscriptModel;
@@ -0,0 +1,3 @@
1
+ export declare const TOKEN_PLACEHOLDER = "__AFK_WEB_TOKEN__";
2
+ export declare function readAndScrubToken(): string;
3
+ export declare function readMetaToken(): string;
@@ -0,0 +1,9 @@
1
+ export declare const HANDOFF_TTL_MS = 60000;
2
+ export declare class HandoffNonces {
3
+ private readonly now;
4
+ private readonly issued;
5
+ constructor(now?: () => number);
6
+ mint(): string;
7
+ redeem(nonce: string | undefined): boolean;
8
+ private sweep;
9
+ }
@@ -0,0 +1,22 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ import { SECURITY_HEADERS } from './static-assets.js';
3
+ import type { WebElicitationBridge } from './elicitation-web.js';
4
+ import type { CreateSessionRequest, OwnedSessionInfo } from './session-owner.js';
5
+ export { SECURITY_HEADERS };
6
+ export interface RouteContext {
7
+ owned: Set<string>;
8
+ bridge: WebElicitationBridge;
9
+ submitPrompt: (sessionId: string, text: string) => Promise<void>;
10
+ isBusy: (sessionId: string) => boolean;
11
+ createSession?: (request: CreateSessionRequest) => Promise<OwnedSessionInfo>;
12
+ interrupt?: (sessionId: string) => Promise<void>;
13
+ }
14
+ export declare function sendJson(res: ServerResponse, status: number, body: unknown): void;
15
+ export declare function requireValidSessionId(res: ServerResponse, id: string): boolean;
16
+ export declare function handleListSessions(ctx: RouteContext, res: ServerResponse): Promise<void>;
17
+ export declare function handlePrompt(ctx: RouteContext, res: ServerResponse, sessionId: string, body: unknown): Promise<void>;
18
+ export declare function handleApprove(ctx: RouteContext, res: ServerResponse, sessionId: string, body: unknown): void;
19
+ export declare function handleApproveByRequestId(ctx: RouteContext, res: ServerResponse, body: unknown): void;
20
+ export declare function header(req: IncomingMessage, name: string): string | undefined;
21
+ export declare function handleCreateSession(ctx: RouteContext, res: ServerResponse, body: unknown): Promise<void>;
22
+ export declare function handleInterrupt(ctx: RouteContext, res: ServerResponse, sessionId: string): Promise<void>;
@@ -0,0 +1,24 @@
1
+ import { WebElicitationBridge } from './elicitation-web.js';
2
+ import type { SessionOwner } from './session-owner.js';
3
+ export declare const DEFAULT_WEB_PORT = 4141;
4
+ export declare const DEFAULT_WEB_HOST = "127.0.0.1";
5
+ export interface WebServerOptions {
6
+ port?: number;
7
+ host?: string;
8
+ token?: string;
9
+ tokenExplicit?: boolean;
10
+ owned?: Set<string>;
11
+ submitPrompt?: (sessionId: string, text: string) => Promise<void>;
12
+ isBusy?: (sessionId: string) => boolean;
13
+ owner?: SessionOwner;
14
+ }
15
+ export interface WebServerHandle {
16
+ port: number;
17
+ host: string;
18
+ token: string;
19
+ url: string;
20
+ openUrl: string;
21
+ bridge: WebElicitationBridge;
22
+ stop: () => Promise<void>;
23
+ }
24
+ export declare function startWebServer(options?: WebServerOptions): Promise<WebServerHandle>;
@@ -0,0 +1,33 @@
1
+ import type { PermissionMode } from '../agent/types/sdk-types.js';
2
+ export interface CreateSessionRequest {
3
+ cwd?: string;
4
+ model?: string;
5
+ }
6
+ export interface OwnedSessionInfo {
7
+ id: string;
8
+ cwd: string;
9
+ model: string;
10
+ createdAt: string;
11
+ }
12
+ export interface SessionOwnerOptions {
13
+ cwd?: string;
14
+ model: string;
15
+ permissionMode?: PermissionMode;
16
+ allowArbitraryCwd?: boolean;
17
+ }
18
+ export declare class SessionOwner {
19
+ private readonly options;
20
+ readonly owned: Set<string>;
21
+ private readonly sessions;
22
+ private readonly info;
23
+ private readonly turns;
24
+ private readonly pending;
25
+ constructor(options: SessionOwnerOptions);
26
+ private get baseCwd();
27
+ create(request?: CreateSessionRequest): Promise<OwnedSessionInfo>;
28
+ submitPrompt(sessionId: string, text: string): Promise<void>;
29
+ isBusy(sessionId: string): boolean;
30
+ interrupt(sessionId: string): Promise<void>;
31
+ list(): OwnedSessionInfo[];
32
+ closeAll(): Promise<void>;
33
+ }
@@ -0,0 +1,11 @@
1
+ export interface WebSessionSummary {
2
+ id: string;
3
+ mode: 'live' | 'readonly';
4
+ cwd?: string;
5
+ surface?: string;
6
+ updatedAt?: string;
7
+ title?: string;
8
+ alive?: boolean;
9
+ }
10
+ export declare const DEFAULT_SESSION_LIMIT = 100;
11
+ export declare function listWebSessions(owned: Set<string>, limit?: number): Promise<WebSessionSummary[]>;
@@ -0,0 +1,20 @@
1
+ export interface SseFrame {
2
+ id?: string;
3
+ data: unknown;
4
+ }
5
+ export interface ParsedSseEvent {
6
+ id: string | undefined;
7
+ data: string;
8
+ }
9
+ export declare function formatSseFrame(frame: SseFrame): string;
10
+ export interface SseEndFrame {
11
+ end: true;
12
+ reason: string;
13
+ }
14
+ export declare const SSE_END_FRAME: SseEndFrame;
15
+ export declare function isSseEndFrame(payload: unknown): payload is SseEndFrame;
16
+ export interface ParseSseChunkResult {
17
+ events: ParsedSseEvent[];
18
+ remainder: string;
19
+ }
20
+ export declare function parseSseChunk(buffer: string): ParseSseChunkResult;
@@ -0,0 +1,10 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ import type { HandoffNonces } from './handoff.js';
3
+ export interface StaticAuth {
4
+ token: string;
5
+ docKey: string;
6
+ nonces: HandoffNonces;
7
+ }
8
+ export declare const SECURITY_HEADERS: Readonly<Record<string, string>>;
9
+ export declare const TOKEN_PLACEHOLDER = "__AFK_WEB_TOKEN__";
10
+ export declare function serveStatic(req: IncomingMessage, res: ServerResponse, path: string, rawUrl: string, auth: StaticAuth): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ export declare function handleStream(req: IncomingMessage, res: ServerResponse, sessionId: string, streams?: Set<AbortController>): Promise<void>;
@@ -0,0 +1,64 @@
1
+ var ut="__AFK_WEB_TOKEN__",Ee="afk_web_token",Ae="";function Le(){let t=new URLSearchParams(location.search);(t.get("token")||t.get("k"))&&history.replaceState(null,"",location.pathname);let e=dt();return e?(ht(e),e):gt()}function dt(){let t=document.querySelector('meta[name="afk-token"]')?.getAttribute("content");return!t||t===ut?"":t}function ht(t){Ae=t;try{sessionStorage.setItem(Ee,t)}catch{}}function gt(){try{let t=sessionStorage.getItem(Ee);if(t)return t}catch{}return Ae}var $n=Object.freeze({end:!0,reason:"session_closed"});function Pe(t){return typeof t=="object"&&t!==null&&t.end===!0}function Ie(t){let n=t.replace(/\r\n/g,`
2
+ `).split(`
3
+
4
+ `),s=n.pop()??"",r=[];for(let i of n){if(i.trim()==="")continue;let o,l;for(let a of i.split(`
5
+ `))a.startsWith("id: ")?o=a.slice(4):a.startsWith("id:")?o=a.slice(3).trimStart():a.startsWith("data: ")?l=a.slice(6):a.startsWith("data:")&&(l=a.slice(5).trimStart());l!==void 0&&r.push({id:o,data:l})}return{events:r,remainder:s}}var ft=15e3,kt=500,U=class{constructor(e,n,s){this.sessionId=e;this.token=n;this.handlers=s}sessionId;token;handlers;controller;lastEventId;attempt=0;stopped=!1;start(){this.stopped=!1,this.connect()}stop(){this.stopped=!0,this.controller?.abort(),this.handlers.onStatus?.("closed")}async connect(){if(this.stopped)return;this.handlers.onStatus?.(this.attempt===0?"connecting":"reconnecting");let e=!1;this.controller=new AbortController;let n={authorization:`Bearer ${this.token}`};this.lastEventId!==void 0&&(n["last-event-id"]=this.lastEventId);try{let r=await fetch(`/api/sessions/${encodeURIComponent(this.sessionId)}/stream`,{headers:n,signal:this.controller.signal});if(!r.ok||r.body===null)throw new Error(`stream failed: ${r.status}`);this.attempt=0,this.handlers.onStatus?.("open");let i=r.body.getReader(),o=new TextDecoder,l="";e:for(;;){let{done:a,value:p}=await i.read();if(a)break;l+=o.decode(p,{stream:!0});let{events:c,remainder:h}=Ie(l);l=h;for(let d of c){if(d.id!==void 0&&(this.lastEventId=d.id),d.data===void 0)continue;let x;try{x=JSON.parse(d.data)}catch{continue}if(Pe(x)){e=!0,this.stopped=!0;break e}this.handlers.onEvent(x,{id:d.id})}}}catch{}if(this.stopped){e&&this.handlers.onStatus?.("ended");return}this.attempt+=1;let s=Math.min(kt*2**(this.attempt-1),ft);setTimeout(()=>{this.connect()},s)}};var mt=/\x1B\][^\x07\x1B]*(?:\x07|\x1B\\)|\x1B[P^_X][^\x1B]*\x1B\\|\x1B\[[0-?]*[ -/]*[@-~]|\x9B[0-?]*[ -/]*[@-~]|\x1B[@-_]/g;function _e(t){return t.replace(mt,"")}function j(t){return _e(t)}function ie(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var P=ie();function De(t){P=t}var A={exec:()=>null};function g(t,e=""){let n=typeof t=="string"?t:t.source,s={replace:(r,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(w.caret,"$1"),n=n.replace(r,o),s},getRegex:()=>new RegExp(n,e)};return s}var xt=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),w={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},bt=/^(?:[ \t]*(?:\n|$))+/,wt=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,yt=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,F=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,vt=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,oe=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Oe=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Fe=g(Oe).replace(/bull/g,oe).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Tt=g(Oe).replace(/bull/g,oe).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ae=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,St=/^[^\n]+/,le=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Ct=g(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",le).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Rt=g(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,oe).getRegex(),G="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ce=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,$t=g("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",ce).replace("tag",G).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ue=g(ae).replace("hr",F).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",G).getRegex(),Et=g(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ue).getRegex(),pe={blockquote:Et,code:wt,def:Ct,fences:yt,heading:vt,hr:F,html:$t,lheading:Fe,list:Rt,newline:bt,paragraph:Ue,table:A,text:St},ze=g("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",F).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",G).getRegex(),At={...pe,lheading:Tt,table:ze,paragraph:g(ae).replace("hr",F).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ze).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",G).getRegex()},Lt={...pe,html:g(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ce).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:A,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:g(ae).replace("hr",F).replace("heading",` *#{1,6} *[^
6
+ ]`).replace("lheading",Fe).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Pt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,It=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,je=/^( {2,}|\\)\n(?!\s*$)/,_t=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,z=/[\p{P}\p{S}]/u,X=/[\s\p{P}\p{S}]/u,ue=/[^\s\p{P}\p{S}]/u,zt=g(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,X).getRegex(),Ze=/(?!~)[\p{P}\p{S}]/u,Mt=/(?!~)[\s\p{P}\p{S}]/u,qt=/(?:[^\s\p{P}\p{S}]|~)/u,Bt=g(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",xt?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Qe=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Ht=g(Qe,"u").replace(/punct/g,z).getRegex(),Nt=g(Qe,"u").replace(/punct/g,Ze).getRegex(),Ke="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Dt=g(Ke,"gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,X).replace(/punct/g,z).getRegex(),Ot=g(Ke,"gu").replace(/notPunctSpace/g,qt).replace(/punctSpace/g,Mt).replace(/punct/g,Ze).getRegex(),Ft=g("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,X).replace(/punct/g,z).getRegex(),Ut=g(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,z).getRegex(),jt="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Zt=g(jt,"gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,X).replace(/punct/g,z).getRegex(),Qt=g(/\\(punct)/,"gu").replace(/punct/g,z).getRegex(),Kt=g(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Wt=g(ce).replace("(?:-->|$)","-->").getRegex(),Gt=g("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Wt).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Q=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Xt=g(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Q).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),We=g(/^!?\[(label)\]\[(ref)\]/).replace("label",Q).replace("ref",le).getRegex(),Ge=g(/^!?\[(ref)\](?:\[\])?/).replace("ref",le).getRegex(),Jt=g("reflink|nolink(?!\\()","g").replace("reflink",We).replace("nolink",Ge).getRegex(),Me=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,de={_backpedal:A,anyPunctuation:Qt,autolink:Kt,blockSkip:Bt,br:je,code:It,del:A,delLDelim:A,delRDelim:A,emStrongLDelim:Ht,emStrongRDelimAst:Dt,emStrongRDelimUnd:Ft,escape:Pt,link:Xt,nolink:Ge,punctuation:zt,reflink:We,reflinkSearch:Jt,tag:Gt,text:_t,url:A},Vt={...de,link:g(/^!?\[(label)\]\((.*?)\)/).replace("label",Q).getRegex(),reflink:g(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Q).getRegex()},ne={...de,emStrongRDelimAst:Ot,emStrongLDelim:Nt,delLDelim:Ut,delRDelim:Zt,url:g(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Me).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:g(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Me).getRegex()},Yt={...ne,br:g(je).replace("{2,}","*").getRegex(),text:g(ne.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Z={normal:pe,gfm:At,pedantic:Lt},N={normal:de,gfm:ne,breaks:Yt,pedantic:Vt},en={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},qe=t=>en[t];function S(t,e){if(e){if(w.escapeTest.test(t))return t.replace(w.escapeReplace,qe)}else if(w.escapeTestNoEncode.test(t))return t.replace(w.escapeReplaceNoEncode,qe);return t}function Be(t){try{t=encodeURI(t).replace(w.percentDecode,"%")}catch{return null}return t}function He(t,e){let n=t.replace(w.findPipe,(i,o,l)=>{let a=!1,p=o;for(;--p>=0&&l[p]==="\\";)a=!a;return a?"|":" |"}),s=n.split(w.splitPipe),r=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;r<s.length;r++)s[r]=s[r].trim().replace(w.slashPipe,"|");return s}function D(t,e,n){let s=t.length;if(s===0)return"";let r=0;for(;r<s;){let i=t.charAt(s-r-1);if(i===e&&!n)r++;else if(i!==e&&n)r++;else break}return t.slice(0,s-r)}function tn(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let s=0;s<t.length;s++)if(t[s]==="\\")s++;else if(t[s]===e[0])n++;else if(t[s]===e[1]&&(n--,n<0))return s;return n>0?-2:-1}function nn(t,e=0){let n=e,s="";for(let r of t)if(r===" "){let i=4-n%4;s+=" ".repeat(i),n+=i}else s+=r,n++;return s}function Ne(t,e,n,s,r){let i=e.href,o=e.title||null,l=t[1].replace(r.other.outputLinkReplace,"$1");s.state.inLink=!0;let a={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:o,text:l,tokens:s.inlineTokens(l)};return s.state.inLink=!1,a}function rn(t,e,n){let s=t.match(n.other.indentCodeCompensation);if(s===null)return e;let r=s[1];return e.split(`
7
+ `).map(i=>{let o=i.match(n.other.beginningSpace);if(o===null)return i;let[l]=o;return l.length>=r.length?i.slice(r.length):i}).join(`
8
+ `)}var K=class{options;rules;lexer;constructor(t){this.options=t||P}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:D(n,`
9
+ `)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],s=rn(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let s=D(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:D(e[0],`
10
+ `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=D(e[0],`
11
+ `).split(`
12
+ `),s="",r="",i=[];for(;n.length>0;){let o=!1,l=[],a;for(a=0;a<n.length;a++)if(this.rules.other.blockquoteStart.test(n[a]))l.push(n[a]),o=!0;else if(!o)l.push(n[a]);else break;n=n.slice(a);let p=l.join(`
13
+ `),c=p.replace(this.rules.other.blockquoteSetextReplace,`
14
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
15
+ ${p}`:p,r=r?`${r}
16
+ ${c}`:c;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=h,n.length===0)break;let d=i.at(-1);if(d?.type==="code")break;if(d?.type==="blockquote"){let x=d,b=x.raw+`
17
+ `+n.join(`
18
+ `),C=this.blockquote(b);i[i.length-1]=C,s=s.substring(0,s.length-x.raw.length)+C.raw,r=r.substring(0,r.length-x.text.length)+C.text;break}else if(d?.type==="list"){let x=d,b=x.raw+`
19
+ `+n.join(`
20
+ `),C=this.list(b);i[i.length-1]=C,s=s.substring(0,s.length-d.raw.length)+C.raw,r=r.substring(0,r.length-x.raw.length)+C.raw,n=b.substring(i.at(-1).raw.length).split(`
21
+ `);continue}}return{type:"blockquote",raw:s,tokens:i,text:r}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),s=n.length>1,r={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let i=this.rules.other.listItemRegex(n),o=!1;for(;t;){let a=!1,p="",c="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;p=e[0],t=t.substring(p.length);let h=nn(e[2].split(`
22
+ `,1)[0],e[1].length),d=t.split(`
23
+ `,1)[0],x=!h.trim(),b=0;if(this.options.pedantic?(b=2,c=h.trimStart()):x?b=e[1].length+1:(b=h.search(this.rules.other.nonSpaceChar),b=b>4?1:b,c=h.slice(b),b+=e[1].length),x&&this.rules.other.blankLine.test(d)&&(p+=d+`
24
+ `,t=t.substring(d.length+1),a=!0),!a){let C=this.rules.other.nextBulletRegex(b),Ce=this.rules.other.hrRegex(b),Re=this.rules.other.fencesBeginRegex(b),$e=this.rules.other.headingBeginRegex(b),ct=this.rules.other.htmlBeginRegex(b),pt=this.rules.other.blockquoteBeginRegex(b);for(;t;){let te=t.split(`
25
+ `,1)[0],H;if(d=te,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),H=d):H=d.replace(this.rules.other.tabCharGlobal," "),Re.test(d)||$e.test(d)||ct.test(d)||pt.test(d)||C.test(d)||Ce.test(d))break;if(H.search(this.rules.other.nonSpaceChar)>=b||!d.trim())c+=`
26
+ `+H.slice(b);else{if(x||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||Re.test(h)||$e.test(h)||Ce.test(h))break;c+=`
27
+ `+d}x=!d.trim(),p+=te+`
28
+ `,t=t.substring(te.length+1),h=H.slice(b)}}r.loose||(o?r.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(o=!0)),r.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]}),r.raw+=p}let l=r.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let a of r.items){if(this.lexer.state.top=!1,a.tokens=this.lexer.blockTokens(a.text,[]),a.task){if(a.text=a.text.replace(this.rules.other.listReplaceTask,""),a.tokens[0]?.type==="text"||a.tokens[0]?.type==="paragraph"){a.tokens[0].raw=a.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),a.tokens[0].text=a.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let c=this.lexer.inlineQueue.length-1;c>=0;c--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[c].src)){this.lexer.inlineQueue[c].src=this.lexer.inlineQueue[c].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(a.raw);if(p){let c={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};a.checked=c.checked,r.loose?a.tokens[0]&&["paragraph","text"].includes(a.tokens[0].type)&&"tokens"in a.tokens[0]&&a.tokens[0].tokens?(a.tokens[0].raw=c.raw+a.tokens[0].raw,a.tokens[0].text=c.raw+a.tokens[0].text,a.tokens[0].tokens.unshift(c)):a.tokens.unshift({type:"paragraph",raw:c.raw,text:c.raw,tokens:[c]}):a.tokens.unshift(c)}}if(!r.loose){let p=a.tokens.filter(h=>h.type==="space"),c=p.length>0&&p.some(h=>this.rules.other.anyLine.test(h.raw));r.loose=c}}if(r.loose)for(let a of r.items){a.loose=!0;for(let p of a.tokens)p.type==="text"&&(p.type="paragraph")}return r}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:s,title:r}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=He(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
29
+ `):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let o of s)this.rules.other.tableAlignRight.test(o)?i.align.push("right"):this.rules.other.tableAlignCenter.test(o)?i.align.push("center"):this.rules.other.tableAlignLeft.test(o)?i.align.push("left"):i.align.push(null);for(let o=0;o<n.length;o++)i.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:i.align[o]});for(let o of r)i.rows.push(He(o,i.header.length).map((l,a)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[a]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
30
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=D(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=tn(e[2],"()");if(i===-2)return;if(i>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let s=e[2],r="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(s);i&&(s=i[1],r=i[3])}else r=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),Ne(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=e[s.toLowerCase()];if(!r){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return Ne(n,r,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let s=this.rules.inline.emStrongLDelim.exec(t);if(!(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[3])||!n||this.rules.inline.punctuation.exec(n))){let r=[...s[0]].length-1,i,o,l=r,a=0,p=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,e=e.slice(-1*t.length+r);(s=p.exec(e))!=null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i)continue;if(o=[...i].length,s[3]||s[4]){l+=o;continue}else if((s[5]||s[6])&&r%3&&!((r+o)%3)){a+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l+a);let c=[...s[0]][0].length,h=t.slice(0,r+s.index+c+o);if(Math.min(r,o)%2){let x=h.slice(1,-1);return{type:"em",raw:h,text:x,tokens:this.lexer.inlineTokens(x)}}let d=h.slice(2,-2);return{type:"strong",raw:h,text:d,tokens:this.lexer.inlineTokens(d)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),r=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&r&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let s=this.rules.inline.delLDelim.exec(t);if(s&&(!s[1]||!n||this.rules.inline.punctuation.exec(n))){let r=[...s[0]].length-1,i,o,l=r,a=this.rules.inline.delRDelim;for(a.lastIndex=0,e=e.slice(-1*t.length+r);(s=a.exec(e))!=null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i||(o=[...i].length,o!==r))continue;if(s[3]||s[4]){l+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l);let p=[...s[0]][0].length,c=t.slice(0,r+s.index+p+o),h=c.slice(r,-r);return{type:"del",raw:c,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,s;return e[2]==="@"?(n=e[1],s="mailto:"+n):(n=e[1],s=n),{type:"link",raw:e[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,s;if(e[2]==="@")n=e[0],s="mailto:"+n;else{let r;do r=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(r!==e[0]);n=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},y=class re{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||P,this.options.tokenizer=this.options.tokenizer||new K,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:w,block:Z.normal,inline:N.normal};this.options.pedantic?(n.block=Z.pedantic,n.inline=N.pedantic):this.options.gfm&&(n.block=Z.gfm,this.options.breaks?n.inline=N.breaks:n.inline=N.gfm),this.tokenizer.rules=n}static get rules(){return{block:Z,inline:N}}static lex(e,n){return new re(n).lex(e)}static lexInline(e,n){return new re(n).inlineTokens(e)}lex(e){e=e.replace(w.carriageReturn,`
31
+ `),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],s=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(w.tabCharGlobal," ").replace(w.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(o=>(r=o.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let o=n.at(-1);r.raw.length===1&&o!==void 0?o.raw+=`
32
+ `:n.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
33
+ `)?"":`
34
+ `)+r.raw,o.text+=`
35
+ `+r.text,this.inlineQueue.at(-1).src=o.text):n.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
36
+ `)?"":`
37
+ `)+r.raw,o.text+=`
38
+ `+r.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},n.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),n.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let o=1/0,l=e.slice(1),a;this.options.extensions.startBlock.forEach(p=>{a=p.call({lexer:this},l),typeof a=="number"&&a>=0&&(o=Math.min(o,a))}),o<1/0&&o>=0&&(i=e.substring(0,o+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let o=n.at(-1);s&&o?.type==="paragraph"?(o.raw+=(o.raw.endsWith(`
39
+ `)?"":`
40
+ `)+r.raw,o.text+=`
41
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(r),s=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let o=n.at(-1);o?.type==="text"?(o.raw+=(o.raw.endsWith(`
42
+ `)?"":`
43
+ `)+r.raw,o.text+=`
44
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(r);continue}if(e){let o="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let s=e,r=null;if(this.tokens.links){let a=Object.keys(this.tokens.links);if(a.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)a.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,r.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)i=r[2]?r[2].length:0,s=s.slice(0,r.index+i)+"["+"a".repeat(r[0].length-i-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let o=!1,l="";for(;e;){o||(l=""),o=!1;let a;if(this.options.extensions?.inline?.some(c=>(a=c.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let c=n.at(-1);a.type==="text"&&c?.type==="text"?(c.raw+=a.raw,c.text+=a.text):n.push(a);continue}if(a=this.tokenizer.emStrong(e,s,l)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.del(e,s,l)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),n.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),n.push(a);continue}let p=e;if(this.options.extensions?.startInline){let c=1/0,h=e.slice(1),d;this.options.extensions.startInline.forEach(x=>{d=x.call({lexer:this},h),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(p=e.substring(0,c+1))}if(a=this.tokenizer.inlineText(p)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(l=a.raw.slice(-1)),o=!0;let c=n.at(-1);c?.type==="text"?(c.raw+=a.raw,c.text+=a.text):n.push(a);continue}if(e){let c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return n}},W=class{options;parser;constructor(t){this.options=t||P}space(t){return""}code({text:t,lang:e,escaped:n}){let s=(e||"").match(w.notSpaceStart)?.[0],r=t.replace(w.endingNewline,"")+`
45
+ `;return s?'<pre><code class="language-'+S(s)+'">'+(n?r:S(r,!0))+`</code></pre>
46
+ `:"<pre><code>"+(n?r:S(r,!0))+`</code></pre>
47
+ `}blockquote({tokens:t}){return`<blockquote>
48
+ ${this.parser.parse(t)}</blockquote>
49
+ `}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
50
+ `}hr(t){return`<hr>
51
+ `}list(t){let e=t.ordered,n=t.start,s="";for(let o=0;o<t.items.length;o++){let l=t.items[o];s+=this.listitem(l)}let r=e?"ol":"ul",i=e&&n!==1?' start="'+n+'"':"";return"<"+r+i+`>
52
+ `+s+"</"+r+`>
53
+ `}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
54
+ `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
55
+ `}table(t){let e="",n="";for(let r=0;r<t.header.length;r++)n+=this.tablecell(t.header[r]);e+=this.tablerow({text:n});let s="";for(let r=0;r<t.rows.length;r++){let i=t.rows[r];n="";for(let o=0;o<i.length;o++)n+=this.tablecell(i[o]);s+=this.tablerow({text:n})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
56
+ <thead>
57
+ `+e+`</thead>
58
+ `+s+`</table>
59
+ `}tablerow({text:t}){return`<tr>
60
+ ${t}</tr>
61
+ `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
62
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${S(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let s=this.parser.parseInline(n),r=Be(t);if(r===null)return s;t=r;let i='<a href="'+t+'"';return e&&(i+=' title="'+S(e)+'"'),i+=">"+s+"</a>",i}image({href:t,title:e,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let r=Be(t);if(r===null)return S(n);t=r;let i=`<img src="${t}" alt="${S(n)}"`;return e&&(i+=` title="${S(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:S(t.text)}},he=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},v=class se{options;renderer;textRenderer;constructor(e){this.options=e||P,this.options.renderer=this.options.renderer||new W,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new he}static parse(e,n){return new se(n).parse(e)}static parseInline(e,n){return new se(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let s=0;s<e.length;s++){let r=e[s];if(this.options.extensions?.renderers?.[r.type]){let o=r,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=l||"";continue}}let i=r;switch(i.type){case"space":{n+=this.renderer.space(i);break}case"hr":{n+=this.renderer.hr(i);break}case"heading":{n+=this.renderer.heading(i);break}case"code":{n+=this.renderer.code(i);break}case"table":{n+=this.renderer.table(i);break}case"blockquote":{n+=this.renderer.blockquote(i);break}case"list":{n+=this.renderer.list(i);break}case"checkbox":{n+=this.renderer.checkbox(i);break}case"html":{n+=this.renderer.html(i);break}case"def":{n+=this.renderer.def(i);break}case"paragraph":{n+=this.renderer.paragraph(i);break}case"text":{n+=this.renderer.text(i);break}default:{let o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let s="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){s+=l||"";continue}}let o=i;switch(o.type){case"escape":{s+=n.text(o);break}case"html":{s+=n.html(o);break}case"link":{s+=n.link(o);break}case"image":{s+=n.image(o);break}case"checkbox":{s+=n.checkbox(o);break}case"strong":{s+=n.strong(o);break}case"em":{s+=n.em(o);break}case"codespan":{s+=n.codespan(o);break}case"br":{s+=n.br(o);break}case"del":{s+=n.del(o);break}case"text":{s+=n.text(o);break}default:{let l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return s}},O=class{options;block;constructor(t){this.options=t||P}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?y.lex:y.lexInline}provideParser(){return this.block?v.parse:v.parseInline}},sn=class{defaults=ie();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=v;Renderer=W;TextRenderer=he;Lexer=y;Tokenizer=K;Hooks=O;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let s of t)switch(n=n.concat(e.call(this,s)),s.type){case"table":{let r=s;for(let i of r.header)n=n.concat(this.walkTokens(i.tokens,e));for(let i of r.rows)for(let o of i)n=n.concat(this.walkTokens(o.tokens,e));break}case"list":{let r=s;n=n.concat(this.walkTokens(r.items,e));break}default:{let r=s;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(i=>{let o=r[i].flat(1/0);n=n.concat(this.walkTokens(o,e))}):r.tokens&&(n=n.concat(this.walkTokens(r.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let i=e.renderers[r.name];i?e.renderers[r.name]=function(...o){let l=r.renderer.apply(this,o);return l===!1&&(l=i.apply(this,o)),l}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[r.level];i?i.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),s.extensions=e),n.renderer){let r=this.defaults.renderer||new W(this.defaults);for(let i in n.renderer){if(!(i in r))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let o=i,l=n.renderer[o],a=r[o];r[o]=(...p)=>{let c=l.apply(r,p);return c===!1&&(c=a.apply(r,p)),c||""}}s.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new K(this.defaults);for(let i in n.tokenizer){if(!(i in r))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let o=i,l=n.tokenizer[o],a=r[o];r[o]=(...p)=>{let c=l.apply(r,p);return c===!1&&(c=a.apply(r,p)),c}}s.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new O;for(let i in n.hooks){if(!(i in r))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let o=i,l=n.hooks[o],a=r[o];O.passThroughHooks.has(i)?r[o]=p=>{if(this.defaults.async&&O.passThroughHooksRespectAsync.has(i))return(async()=>{let h=await l.call(r,p);return a.call(r,h)})();let c=l.call(r,p);return a.call(r,c)}:r[o]=(...p)=>{if(this.defaults.async)return(async()=>{let h=await l.apply(r,p);return h===!1&&(h=await a.apply(r,p)),h})();let c=l.apply(r,p);return c===!1&&(c=a.apply(r,p)),c}}s.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,i=n.walkTokens;s.walkTokens=function(o){let l=[];return l.push(i.call(this,o)),r&&(l=l.concat(r.call(this,o))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return y.lex(t,e??this.defaults)}parser(t,e){return v.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let s={...n},r={...this.defaults,...s},i=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&s.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=t),r.async)return(async()=>{let o=r.hooks?await r.hooks.preprocess(e):e,l=await(r.hooks?await r.hooks.provideLexer():t?y.lex:y.lexInline)(o,r),a=r.hooks?await r.hooks.processAllTokens(l):l;r.walkTokens&&await Promise.all(this.walkTokens(a,r.walkTokens));let p=await(r.hooks?await r.hooks.provideParser():t?v.parse:v.parseInline)(a,r);return r.hooks?await r.hooks.postprocess(p):p})().catch(i);try{r.hooks&&(e=r.hooks.preprocess(e));let o=(r.hooks?r.hooks.provideLexer():t?y.lex:y.lexInline)(e,r);r.hooks&&(o=r.hooks.processAllTokens(o)),r.walkTokens&&this.walkTokens(o,r.walkTokens);let l=(r.hooks?r.hooks.provideParser():t?v.parse:v.parseInline)(o,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(o){return i(o)}}}onError(t,e){return n=>{if(n.message+=`
63
+ Please report this to https://github.com/markedjs/marked.`,t){let s="<p>An error occurred:</p><pre>"+S(n.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(n);throw n}}},L=new sn;function k(t,e){return L.parse(t,e)}k.options=k.setOptions=function(t){return L.setOptions(t),k.defaults=L.defaults,De(k.defaults),k};k.getDefaults=ie;k.defaults=P;k.use=function(...t){return L.use(...t),k.defaults=L.defaults,De(k.defaults),k};k.walkTokens=function(t,e){return L.walkTokens(t,e)};k.parseInline=L.parseInline;k.Parser=v;k.parser=v.parse;k.Renderer=W;k.TextRenderer=he;k.Lexer=y;k.lexer=y.lex;k.Tokenizer=K;k.Hooks=O;k.parse=k;var zn=k.options,Mn=k.setOptions,qn=k.use,Bn=k.walkTokens,Hn=k.parseInline;var Nn=v.parse,Dn=y.lex;var on=["http:","https:","mailto:"];function an(t){try{let e=new URL(t);return on.includes(e.protocol)?e.href:void 0}catch{return}}function f(t,e){let n=document.createElement(t);return e&&(n.className=e),n}function T(t,e){if(e)for(let n of e)switch(n.type){case"strong":{let s=f("strong");T(s,n.tokens),t.appendChild(s);break}case"em":{let s=f("em");T(s,n.tokens),t.appendChild(s);break}case"del":{let s=f("s");T(s,n.tokens),t.appendChild(s);break}case"codespan":{let s=f("code","md-code-inline");s.textContent=n.text,t.appendChild(s);break}case"link":{let s=n,r=an(s.href);if(r===void 0){let o=f("span");T(o,s.tokens),t.appendChild(o);break}let i=f("a","md-link");i.href=r,i.target="_blank",i.rel="noopener noreferrer",T(i,s.tokens),t.appendChild(i);break}case"image":{let s=f("span","md-image");s.textContent=`[image: ${n.text||"untitled"}]`,t.appendChild(s);break}case"br":t.appendChild(f("br"));break;default:{let s=n.text??"",r=n.tokens;r&&r.length>0&&n.type==="text"?T(t,r):s&&t.appendChild(document.createTextNode(s));break}}}function ln(t){let e=t.ordered?f("ol","md-list"):f("ul","md-list");t.ordered&&typeof t.start=="number"&&t.start>1&&(e.start=t.start);for(let n of t.items){let s=f("li");if(n.task){let r=f("input","md-task");r.type="checkbox",r.checked=!!n.checked,r.disabled=!0,s.appendChild(r)}ge(s,n.tokens),e.appendChild(s)}return e}function cn(t){let e=f("pre","md-pre"),n=f("code");return t.lang&&(n.className=`md-lang-${t.lang.split(/\s+/)[0]??""}`),n.textContent=t.text,e.appendChild(n),e}function pn(t){let e=f("table","md-table"),n=f("thead"),s=f("tr");for(let i of t.header){let o=f("th");T(o,i.tokens),s.appendChild(o)}n.appendChild(s),e.appendChild(n);let r=f("tbody");for(let i of t.rows){let o=f("tr");for(let l of i){let a=f("td");T(a,l.tokens),o.appendChild(a)}r.appendChild(o)}return e.appendChild(r),e}function ge(t,e){for(let n of e)switch(n.type){case"heading":{let s=Math.min(Math.max(n.depth,1),6),r=f(`h${s}`,"md-heading");T(r,n.tokens),t.appendChild(r);break}case"paragraph":{let s=f("p","md-p");T(s,n.tokens),t.appendChild(s);break}case"code":t.appendChild(cn(n));break;case"list":t.appendChild(ln(n));break;case"blockquote":{let s=f("blockquote","md-quote");ge(s,n.tokens),t.appendChild(s);break}case"table":t.appendChild(pn(n));break;case"hr":t.appendChild(f("hr","md-hr"));break;case"space":break;case"html":{let s=f("p","md-p");s.textContent=n.text,t.appendChild(s);break}default:{let s=n.tokens;if(s&&s.length>0){let i=f("p","md-p");T(i,s),t.appendChild(i);break}let r=n.text??"";if(r.trim()){let i=f("p","md-p");i.textContent=r,t.appendChild(i)}break}}}function Xe(t,e="md"){let n=f("div",e);try{ge(n,new y().lex(t))}catch{n.textContent=t}return n}var Je=2e3;function u(t,e,n){let s=document.createElement(t);return e&&(s.className=e),n!==void 0&&(s.textContent=n),s}function un(t){if(!t)return;let e=t.split("/").filter(Boolean);return e.length>0?e[e.length-1]:void 0}function dn(t){return(t.title??"").replace(/^\s*\[[^\]]{0,80}\]\s*/,"").trim()||t.title||t.id.slice(0,8)}function fe(t,e,n,s){t.textContent="";for(let r of e){let i=u("button","session-row");r.id===n&&i.classList.add("is-active");let o=u("span","session-title",dn(r));i.appendChild(o);let l=u("span","session-meta"),a=un(r.cwd);a&&l.appendChild(u("span","session-cwd",a));let p=u("span",r.mode==="live"?"badge badge-live":"badge badge-readonly");p.textContent=r.mode==="live"?"live":"read-only",l.appendChild(p),r.alive&&l.appendChild(u("span","badge badge-alive","running")),r.updatedAt&&l.appendChild(u("span","session-time",kn(r.updatedAt))),i.appendChild(l),i.addEventListener("click",()=>s(r.id)),t.appendChild(i)}e.length===0&&t.appendChild(u("div","empty","No sessions found."))}function ke(t,e){t.textContent="";for(let n of e)t.appendChild(hn(n))}function hn(t){switch(t.kind){case"user":{let e=u("div","msg msg-user");return e.appendChild(u("div","msg-role","you")),e.appendChild(u("div","msg-body",t.text)),e}case"assistant":{let e=u("div","msg msg-assistant");e.appendChild(u("div","msg-role","agent"));let n=u("div","msg-body md-body");return n.appendChild(Xe(t.text)),e.appendChild(n),e}case"thinking":{let e=u("details","msg msg-thinking");return e.appendChild(u("summary","msg-role","thinking")),e.appendChild(u("div","msg-body",t.text)),e}case"error":{let e=u("div","msg msg-error");return e.appendChild(u("div","msg-role","error")),e.appendChild(u("div","msg-body",t.message)),e}case"notice":return u("div","notice",t.text);case"tool":return gn(t)}}function gn(t){let e=u("details",`tool tool-${t.status}`),n=u("summary","tool-summary");n.appendChild(u("span",`tool-dot tool-dot-${t.status}`,"")),n.appendChild(u("span","tool-name",t.name)),t.inputPreview&&n.appendChild(u("span","tool-target",fn(t.inputPreview,90))),e.appendChild(n);let s=u("div","tool-body");if(t.inputPreview&&(s.appendChild(u("div","tool-label","input")),s.appendChild(u("pre","tool-pre",j(t.inputPreview)))),t.outputUnavailable===!0)s.appendChild(u("div","tool-unavailable","Result not available after refresh \u2014 successful tool output is not persisted to the session ledger."));else if(t.output!==void 0&&t.output!==""){s.appendChild(u("div","tool-label","output"));let r=j(t.output);if(r.length>Je){let i=u("pre","tool-pre",r.slice(0,Je));s.appendChild(i);let o=u("button","tool-more",`Show full output (${r.length.toLocaleString()} chars)`);o.addEventListener("click",()=>{i.textContent=r,o.remove()}),s.appendChild(o)}else s.appendChild(u("pre","tool-pre",r))}return t.diff!==void 0&&(s.appendChild(u("div","tool-label","diff")),s.appendChild(u("pre","tool-pre",j(String(t.diff))))),e.appendChild(s),e}function fn(t,e){let n=t.replace(/\s+/g," ").trim();return n.length<=e?n:`${n.slice(0,e-1)}\u2026`}function kn(t){let e=Date.parse(t);if(Number.isNaN(e))return"";let n=Math.max(0,(Date.now()-e)/1e3);return n<60?"just now":n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:`${Math.floor(n/86400)}d ago`}function me(t,e,n){t.textContent="",t.classList.toggle("has-pending",e.length>0);for(let s of e){let r=s.request??{},i=u("div","approval-card"),o=u("div","approval-head");o.appendChild(u("span","approval-badge",r.origin==="agent"?"question":"approval")),r.serverName&&o.appendChild(u("span","approval-source",r.serverName)),i.appendChild(o);let l=r.title??r.message??"The agent is waiting for a response.";i.appendChild(u("div","approval-title",l)),r.description&&r.description!==l&&i.appendChild(u("div","approval-desc",r.description));let a=u("div","approval-actions");if(r.type==="choice"&&Array.isArray(r.choices)&&r.choices.length>0)for(let c of r.choices){let h=u("button","approval-btn",c);h.addEventListener("click",()=>n(s.id,{action:"accept",content:{value:c}})),a.appendChild(h)}else if(r.type==="text"||r.type==="number"){let c=document.createElement("input");c.className="approval-input",c.type=r.type==="number"?"number":"text",r.questionDefault!==void 0&&(c.value=String(r.questionDefault));let h=()=>n(s.id,{action:"accept",content:{value:r.type==="number"?Number(c.value):c.value}});c.addEventListener("keydown",x=>{x.key==="Enter"&&h()}),i.appendChild(c);let d=u("button","approval-btn approval-primary","Submit");d.addEventListener("click",h),a.appendChild(d)}else{let c=u("button","approval-btn approval-primary","Approve");c.addEventListener("click",()=>n(s.id,{action:"accept",content:{value:!0}})),a.appendChild(c)}let p=u("button","approval-btn approval-danger","Deny");p.addEventListener("click",()=>n(s.id,{action:"decline"})),a.appendChild(p),i.appendChild(a),t.appendChild(i)}}var Ve=0;function $(t){return Ve+=1,`${t}_${Ve}`}function I(t){return typeof t=="string"?t:void 0}function Ye(t){let e=t;if(typeof e.kind=="string")switch(e.kind){case"user":return{kind:"user",id:$("u"),text:I(e.text)??""};case"assistant":return{kind:"assistant",id:$("a"),text:I(e.text)??""};case"tool":{let n=I(e.input)??"";return n.trim()==="\u2026"?void 0:{kind:"tool",id:$("t"),name:I(e.toolName)??"tool",inputPreview:n,status:"ok",outputUnavailable:!0}}case"tool_error":{let n=I(e.content)??"",s=n.split(`
64
+ `,1)[0]??"";return{kind:"tool",id:$("t"),name:I(e.toolName)??"error",inputPreview:s,status:"error",output:n}}case"error":return{kind:"error",id:$("e"),message:I(e.message)??"error"};case"done":{let n=e.costUsd,s=e.durationMs,r=[];return typeof n=="number"&&r.push(`$${n.toFixed(4)}`),typeof s=="number"&&r.push(`${(s/1e3).toFixed(1)}s`),{kind:"notice",id:$("n"),text:r.length?`turn complete \xB7 ${r.join(" \xB7 ")}`:"turn complete"}}case"paused":return{kind:"notice",id:$("n"),text:"paused \u2014 usage limit"};case"resumed":return{kind:"notice",id:$("n"),text:"resumed"};default:return}}function et(t,e){let n=e;if(n.kind!=="done")return t;let s=n.costUsd,r=n.durationMs;return{costUsd:t.costUsd+(typeof s=="number"?s:0),durationMs:t.durationMs+(typeof r=="number"?r:0),turns:t.turns+1}}function xe(t,e){return Number.isInteger(e)&&e>=0&&e<t.length}function tt(t,e){if(!xe(t,e)||e===0)return t.slice();let n=t.slice(),s=n[e-1],r=n[e];return s===void 0||r===void 0?t.slice():(n[e-1]=r,n[e]=s,n)}function nt(t,e){if(!xe(t,e)||e===t.length-1)return t.slice();let n=t.slice(),s=n[e+1],r=n[e];return s===void 0||r===void 0?t.slice():(n[e+1]=r,n[e]=s,n)}function rt(t,e){if(!xe(t,e))return t.slice();let n=t.slice();return n.splice(e,1),n}var J=class{constructor(e){this.deps=e}deps;queue=[];flushing=!1;entries(){return[...this.queue]}clear(){this.queue=[],this.render()}wire(){let e=()=>{let n=this.deps.input.value.trim();n&&(this.queue=[...this.queue,n],this.deps.input.value="",this.render(),this.flush())};this.deps.send.addEventListener("click",e),this.deps.input.addEventListener("keydown",n=>{n.key==="Enter"&&(n.metaKey||n.ctrlKey)&&e()})}render(){let e=this.deps.container;e.textContent="",this.queue.forEach((n,s)=>{let r=document.createElement("div");r.className="queue-row";let i=document.createElement("span");i.className="queue-text",i.textContent=n,r.appendChild(i);for(let[o,l]of[["\u2191",()=>{this.queue=tt(this.queue,s)}],["\u2193",()=>{this.queue=nt(this.queue,s)}],["\u2715",()=>{this.queue=rt(this.queue,s)}]]){let a=document.createElement("button");a.className="queue-btn",a.textContent=o,a.addEventListener("click",()=>{l(),this.render()}),r.appendChild(a)}e.appendChild(r)})}async flush(){if(this.flushing||!this.deps.isLive()||this.deps.isTurnActive())return;let e=this.queue[0];if(e!==void 0){this.flushing=!0;try{await this.deps.submit(e),this.queue=this.queue.slice(1),this.render(),this.deps.onAccepted()}catch(n){this.deps.onError(n instanceof Error?n.message:"send failed")}finally{this.flushing=!1}}}};function st(t,e=80){return t.scrollHeight-t.scrollTop-t.clientHeight<=e}var ot=Le(),M=[],R,V=[],E={costUsd:0,durationMs:0,turns:0},be,_=[],we,q=!1;function m(t){let e=document.getElementById(t);if(!e)throw new Error(`missing #${t}`);return e}var ye;function ve(){return ye||(ye=new J({container:m("queue"),input:m("prompt"),send:m("send"),submit:async t=>{if(R===void 0)throw new Error("no active session");await B(`/api/sessions/${encodeURIComponent(R)}/prompt`,{method:"POST",body:JSON.stringify({text:t})})},isLive:Se,isTurnActive:()=>q,onAccepted:()=>{q=!0,Y()},onError:t=>{m("status").textContent=t}})),ye}async function B(t,e){let n=await fetch(t,{...e,headers:{authorization:`Bearer ${ot}`,"content-type":"application/json",...e?.headers??{}}});if(n.status===401)throw new Error("Session credential missing \u2014 reopen the URL printed by `afk web`. A new tab does not inherit the credential from the first one.");if(!n.ok)throw new Error(`${n.status} ${await n.text()}`);return await n.json()}function mn(t){t.scrollTop=t.scrollHeight}function xn(){return M.find(t=>t.id===R)}function Se(){return xn()?.mode==="live"}async function Te(){if(M=(await B("/api/sessions")).sessions,R===void 0&&M.length>0){let e=M[0];e&&ee(e.id)}fe(m("sessions"),M,R,ee)}function ee(t){R=t,V=[],ve().clear(),E={costUsd:0,durationMs:0,turns:0},be?.stop(),q=!1,fe(m("sessions"),M,R,ee),ke(m("transcript"),V),bn(),Y(),be=new U(t,ot,{onEvent:e=>{let s=e.record;if(!s)return;(s.kind==="done"||s.kind==="error")&&(q=!1,Y(),ve().flush());let r=Ye(s);if(E=et(E,s),r){V.push(r);let i=st(m("transcript"));ke(m("transcript"),V),i&&mn(m("transcript"))}at()},onStatus:e=>{let n=m("status");n.textContent=e==="ended"?"session ended":e,n.className=`status status-${e}`,e==="ended"&&(q=!1),Y()}}),be.start()}function at(){let t=[`${E.turns} turns`];E.costUsd>0&&t.push(`$${E.costUsd.toFixed(4)}`),E.durationMs>0&&t.push(`${(E.durationMs/1e3).toFixed(1)}s`),m("meter").textContent=t.join(" \xB7 ")}function bn(){let t=Se(),e=m("prompt"),n=m("send");e.disabled=!t,n.disabled=!t,e.placeholder=t?"Message the agent\u2026 (queues while it works)":"Read-only \u2014 this session runs in another process",m("composer").classList.toggle("is-readonly",!t)}function Y(){m("stop").hidden=!(q&&Se())}async function wn(){let t=m("new-session");t.disabled=!0,t.textContent="starting\u2026";try{let{session:e}=await B("/api/sessions",{method:"POST",body:JSON.stringify({})});await Te(),ee(e.id)}catch(e){m("status").textContent=e instanceof Error?e.message:"could not start session"}finally{t.disabled=!1,t.textContent="+ New"}}async function it(){let t=await B("/api/pending"),e=t.pending.length!==_.length||t.pending.some((n,s)=>n.id!==_[s]?.id);_=t.pending,e&&me(m("approvals"),_,lt)}function lt(t,e){_=_.filter(n=>n.id!==t),me(m("approvals"),_,lt),B("/api/approve",{method:"POST",body:JSON.stringify({requestId:t,response:e})}).catch(n=>{m("status").textContent=n instanceof Error?n.message:"approval failed"})}async function yn(){R!==void 0&&await B(`/api/sessions/${encodeURIComponent(R)}/interrupt`,{method:"POST",body:JSON.stringify({})})}async function vn(){ve().wire(),m("new-session").addEventListener("click",()=>{wn()}),m("stop").addEventListener("click",()=>{yn().catch(t=>{m("status").textContent=t instanceof Error?t.message:"stop failed"})}),at(),await Te(),setInterval(()=>{Te().catch(()=>{})},1e4),we=setInterval(()=>{it().catch(()=>{})},1e3),it().catch(()=>{}),window.addEventListener("beforeunload",()=>{we&&clearInterval(we)})}vn().catch(t=>{m("status").textContent=t instanceof Error?t.message:String(t)});
@@ -0,0 +1 @@
1
+ var e=document.getElementById("menu-toggle");e?.addEventListener("click",()=>{document.getElementById("sidebar")?.classList.toggle("is-open")});