bmad-kanban 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/cli.js +52 -11
- package/dist/readers/detect.js +1 -1
- package/dist/readers/v7Script.js +6 -6
- package/dist/registry.js +8 -2
- package/dist/server/app.js +19 -18
- package/dist/web/assets/index-CXy4n_jL.js +67 -0
- package/dist/web/index.html +1 -1
- package/package.json +2 -2
- package/dist/web/assets/index-EWYUrDTL.js +0 -67
package/README.md
CHANGED
|
@@ -23,13 +23,16 @@ npx bmad-kanban ~/code/my-project
|
|
|
23
23
|
Options (`bmad-kanban --help`):
|
|
24
24
|
|
|
25
25
|
- `--port N`: port to listen on (default 4310)
|
|
26
|
-
- `--
|
|
26
|
+
- `--browser NAME`: open the board in this browser: `chrome`, `brave`, `firefox`, `edge`, `safari`, `orca` (a tab in Orca's built-in browser, in the workspace Orca is showing), or any installed app name (e.g. `Arc`). Set `BMAD_KANBAN_BROWSER` to make it your default; the flag wins over the variable.
|
|
27
|
+
- `--no-open`: do not open a browser; the address to open is printed instead
|
|
27
28
|
- `--no-scripts`: never run the project's own BMAD scripts; v7 boards are read from the files directly
|
|
28
29
|
- `[path]`: project folder (default: current directory)
|
|
29
30
|
|
|
30
31
|
If a board is already running, the new project is added to it instead of starting a second server. `--no-scripts` refuses to use a running board that runs scripts; stop that one first.
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
Once the board is running, open http://localhost:4310 in any browser. It only listens on your own machine, and websites you visit cannot use it.
|
|
34
|
+
|
|
35
|
+
Projects you add with the `bmad-kanban` command are *trusted*: for v7 they run the project's own script. Projects added from the board's sidebar in a browser are read from their files only and never run a script, so nothing on your machine can make the board run code from a folder you didn't choose. Run `bmad-kanban <path>` once to trust such a project. (The command proves itself to the board with a token kept in the config directory, readable only by you.)
|
|
33
36
|
|
|
34
37
|
Requirements: Node 22 or newer. `uv` is needed for full BMAD v7 fidelity (the board calls v7's own scripts through it). Without `uv` the board falls back to reading the files directly and shows a "reduced fidelity" notice.
|
|
35
38
|
|
package/dist/cli.js
CHANGED
|
@@ -1,29 +1,60 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { execFile } from 'node:child_process';
|
|
2
3
|
import fs from 'node:fs';
|
|
3
4
|
import path from 'node:path';
|
|
4
5
|
import { fileURLToPath } from 'node:url';
|
|
5
6
|
import { parseArgs } from 'node:util';
|
|
6
|
-
import openBrowser from 'open';
|
|
7
|
+
import openBrowser, { apps } from 'open';
|
|
7
8
|
import { findProjectRoot } from './bmad/config.js';
|
|
8
9
|
import { findRunning, loadToken, removeLock, writeLock } from './instance.js';
|
|
9
10
|
import { configDir, Registry } from './registry.js';
|
|
10
11
|
import { startServer } from './server/app.js';
|
|
12
|
+
/** Browser names that `open` resolves per platform; any other name is passed to the OS as an app name. */
|
|
13
|
+
const KNOWN_BROWSERS = ['chrome', 'brave', 'firefox', 'edge', 'safari'];
|
|
14
|
+
const browserApp = (browser) => KNOWN_BROWSERS.includes(browser.toLowerCase()) ? apps[browser.toLowerCase()] : browser;
|
|
15
|
+
/** Orca's CLI; on Linux a bare `orca` is usually the GNOME screen reader. */
|
|
16
|
+
const orcaCommand = () => process.env.ORCA_CLI_COMMAND || (process.platform === 'linux' ? 'orca-ide' : 'orca');
|
|
17
|
+
/** Open `url` in a tab of Orca's built-in browser, in the workspace shown in Orca. */
|
|
18
|
+
const openInOrca = (url) => new Promise((resolve, reject) => {
|
|
19
|
+
execFile(orcaCommand(), ['tab', 'create', '--url', url, '--worktree', 'active', '--json'], { timeout: 15_000 }, (err, _out, stderr) => {
|
|
20
|
+
if (err === null)
|
|
21
|
+
return resolve();
|
|
22
|
+
const why = stderr.trim().split('\n').pop() || err.message;
|
|
23
|
+
reject(new Error(err.code === 'ENOENT' ? `${orcaCommand()} command not found` : why));
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
/** Open `url` in `browser`; rejects when that browser is not installed. */
|
|
27
|
+
export async function launch(url, browser) {
|
|
28
|
+
if (browser === undefined)
|
|
29
|
+
return void (await openBrowser(url));
|
|
30
|
+
if (browser.toLowerCase() === 'orca')
|
|
31
|
+
return openInOrca(url);
|
|
32
|
+
const child = await openBrowser(url, { app: { name: browserApp(browser) } });
|
|
33
|
+
// open() resolves even for a missing app, but its launcher fails at once, so give it a moment
|
|
34
|
+
await new Promise((resolve, reject) => {
|
|
35
|
+
const done = setTimeout(resolve, 1500);
|
|
36
|
+
child.once('error', (e) => (clearTimeout(done), reject(e)));
|
|
37
|
+
child.once('exit', (code) => (clearTimeout(done), code ? reject(new Error(`not found (exit code ${code})`)) : resolve()));
|
|
38
|
+
});
|
|
39
|
+
}
|
|
11
40
|
const defaultDeps = {
|
|
12
|
-
open:
|
|
41
|
+
open: launch,
|
|
13
42
|
startServer,
|
|
14
43
|
stdout: (s) => void process.stdout.write(s),
|
|
15
44
|
stderr: (s) => void process.stderr.write(s),
|
|
16
45
|
};
|
|
17
|
-
const HELP = `Usage: bmad-kanban [path] [--port N] [--no-open] [--no-scripts]
|
|
46
|
+
const HELP = `Usage: bmad-kanban [path] [--port N] [--browser NAME] [--no-open] [--no-scripts]
|
|
18
47
|
|
|
19
48
|
Read-only Kanban board for BMAD Method projects.
|
|
20
49
|
|
|
21
|
-
path
|
|
22
|
-
--port N
|
|
23
|
-
--
|
|
24
|
-
|
|
25
|
-
--
|
|
26
|
-
--
|
|
50
|
+
path project folder (default: current directory)
|
|
51
|
+
--port N port to listen on (default: 4310)
|
|
52
|
+
--browser NAME browser to open: chrome, brave, firefox, edge, safari, orca or any
|
|
53
|
+
app name (default: $BMAD_KANBAN_BROWSER, else the system browser)
|
|
54
|
+
--no-open do not open a browser
|
|
55
|
+
--no-scripts never run the project's own BMAD scripts (read the files only)
|
|
56
|
+
--help show this help
|
|
57
|
+
--version show the version
|
|
27
58
|
`;
|
|
28
59
|
function version() {
|
|
29
60
|
const pkg = new URL('../package.json', import.meta.url);
|
|
@@ -38,6 +69,7 @@ export async function main(argv, deps = {}) {
|
|
|
38
69
|
allowPositionals: true,
|
|
39
70
|
options: {
|
|
40
71
|
port: { type: 'string' },
|
|
72
|
+
browser: { type: 'string' },
|
|
41
73
|
'no-open': { type: 'boolean' },
|
|
42
74
|
'no-scripts': { type: 'boolean' },
|
|
43
75
|
help: { type: 'boolean' },
|
|
@@ -112,13 +144,22 @@ export async function main(argv, deps = {}) {
|
|
|
112
144
|
d.stderr(`Could not add project: ${body.error ?? res.statusText}\n`);
|
|
113
145
|
return 1;
|
|
114
146
|
}
|
|
147
|
+
if (body.trusted === false)
|
|
148
|
+
d.stderr(`${root} is not trusted by the running board, so its scripts will not run.\n`);
|
|
115
149
|
url = `${base}?project=${body.id}`;
|
|
116
150
|
name = body.name ?? path.basename(root);
|
|
117
151
|
}
|
|
118
152
|
// the token rides in the fragment, which the browser never sends to the server
|
|
119
153
|
url += `#token=${token}`;
|
|
120
|
-
if (!values['no-open'])
|
|
121
|
-
|
|
154
|
+
if (!values['no-open']) {
|
|
155
|
+
const browser = values.browser || process.env.BMAD_KANBAN_BROWSER || undefined;
|
|
156
|
+
try {
|
|
157
|
+
await d.open(url, browser);
|
|
158
|
+
}
|
|
159
|
+
catch (e) {
|
|
160
|
+
d.stderr(`Could not open ${browser ?? 'a browser'}: ${e.message}. Open the address below yourself.\n`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
122
163
|
if (reuse) {
|
|
123
164
|
d.stdout(`Opened ${name ? `${name} in` : ''}${name ? ' ' : ''}the running board at ${url}\n`);
|
|
124
165
|
if (!running.scripts && scripts)
|
package/dist/readers/detect.js
CHANGED
|
@@ -68,7 +68,7 @@ async function loadBoard(cfg, t, opts) {
|
|
|
68
68
|
return readV6Sprint(cfg, t.id);
|
|
69
69
|
if (t.type === 'v6-spec')
|
|
70
70
|
return readV6Spec(t.path, t.id);
|
|
71
|
-
return readV7(cfg, t.path, t.folderKind, t.id, opts.scripts === false ? null : undefined);
|
|
71
|
+
return readV7(cfg, t.path, t.folderKind, t.id, opts.scripts === false ? null : undefined, opts.offNotice);
|
|
72
72
|
}
|
|
73
73
|
function refFor(t, board) {
|
|
74
74
|
const ref = {
|
package/dist/readers/v7Script.js
CHANGED
|
@@ -9,9 +9,9 @@ const present = (v) => v !== null && v !== undefined && String(v) !== '';
|
|
|
9
9
|
const text = (v) => (v === null || v === undefined ? '' : String(v));
|
|
10
10
|
const SCRIPTS_OFF = 'Read directly from the ticket files: scripts are turned off (--no-scripts), so prerequisites, "next" ordering and tracker status are not applied.';
|
|
11
11
|
/** The file reader's notices, reworded for a board whose scripts were turned off rather than missing. */
|
|
12
|
-
function scriptsOff(b) {
|
|
13
|
-
b.notices = b.notices.map((n) => (n.text === REDUCED ? { ...n, text
|
|
14
|
-
b.children?.forEach(scriptsOff);
|
|
12
|
+
function scriptsOff(b, text) {
|
|
13
|
+
b.notices = b.notices.map((n) => (n.text === REDUCED ? { ...n, text } : n));
|
|
14
|
+
b.children?.forEach((c) => scriptsOff(c, text));
|
|
15
15
|
return b;
|
|
16
16
|
}
|
|
17
17
|
export const runScript = (cmd, args, cwd, timeoutMs) => new Promise((resolve, reject) => {
|
|
@@ -122,10 +122,10 @@ async function toParent(cfg, doc, folder, sourceId, run) {
|
|
|
122
122
|
}
|
|
123
123
|
return { sourceId, kind: 'v7-parent', label: name, epics: [], stories: [], notices, children };
|
|
124
124
|
}
|
|
125
|
-
export async function readV7(cfg, folder, kind, sourceId, run = runScript) {
|
|
126
|
-
// null: the project's scripts must not run
|
|
125
|
+
export async function readV7(cfg, folder, kind, sourceId, run = runScript, offNotice = SCRIPTS_OFF) {
|
|
126
|
+
// null: the project's scripts must not run; `offNotice` says why
|
|
127
127
|
if (run === null)
|
|
128
|
-
return scriptsOff(readV7Tree(folder, kind, sourceId));
|
|
128
|
+
return scriptsOff(readV7Tree(folder, kind, sourceId), offNotice);
|
|
129
129
|
const script = path.join(cfg.root, '_bmad', 'method', 'scripts', 'tickets.py');
|
|
130
130
|
if (!fs.existsSync(script))
|
|
131
131
|
return readV7Tree(folder, kind, sourceId);
|
package/dist/registry.js
CHANGED
|
@@ -31,7 +31,8 @@ export class Registry {
|
|
|
31
31
|
const p = this.projects.find((x) => x.id === id);
|
|
32
32
|
return p && copy(p);
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
/** Adding again with `trusted` trusts an existing project; adding untrusted never untrusts one. */
|
|
35
|
+
add(input, trusted = true) {
|
|
35
36
|
const resolved = path.resolve(input);
|
|
36
37
|
const root = fs.existsSync(resolved) ? findProjectRoot(resolved) : null;
|
|
37
38
|
if (!root)
|
|
@@ -39,10 +40,14 @@ export class Registry {
|
|
|
39
40
|
const id = createHash('sha1').update(root).digest('hex').slice(0, 12);
|
|
40
41
|
let p = this.projects.find((x) => x.id === id);
|
|
41
42
|
if (!p) {
|
|
42
|
-
p = { id, path: root, name: path.basename(root), prefs: defaultPrefs() };
|
|
43
|
+
p = { id, path: root, name: path.basename(root), prefs: defaultPrefs(), trusted };
|
|
43
44
|
this.projects.push(p);
|
|
44
45
|
this.save();
|
|
45
46
|
}
|
|
47
|
+
else if (trusted && !p.trusted) {
|
|
48
|
+
p.trusted = true;
|
|
49
|
+
this.save();
|
|
50
|
+
}
|
|
46
51
|
return copy(p);
|
|
47
52
|
}
|
|
48
53
|
remove(id) {
|
|
@@ -84,6 +89,7 @@ export class Registry {
|
|
|
84
89
|
path: p.path,
|
|
85
90
|
name: p.name,
|
|
86
91
|
prefs: { ...defaultPrefs(), ...p.prefs },
|
|
92
|
+
trusted: p.trusted !== false, // projects listed before trust existed were added by the command
|
|
87
93
|
}));
|
|
88
94
|
this.lastViewed = typeof data.lastViewed === 'string' ? data.lastViewed : null;
|
|
89
95
|
}
|
package/dist/server/app.js
CHANGED
|
@@ -23,7 +23,7 @@ const TYPES = {
|
|
|
23
23
|
};
|
|
24
24
|
const isMissing = (p) => !fs.existsSync(path.join(p.path, '_bmad'));
|
|
25
25
|
async function summarize(p, read) {
|
|
26
|
-
const base = { id: p.id, name: p.name, path: p.path, prefs: { ...p.prefs } };
|
|
26
|
+
const base = { id: p.id, name: p.name, path: p.path, prefs: { ...p.prefs }, trusted: p.trusted };
|
|
27
27
|
if (isMissing(p)) {
|
|
28
28
|
return { ...base, missing: true, sources: [], tags: [], version: null, defaultSourceId: null };
|
|
29
29
|
}
|
|
@@ -38,7 +38,14 @@ async function summarize(p, read) {
|
|
|
38
38
|
export function startServer(opts) {
|
|
39
39
|
const { registry, webRoot } = opts;
|
|
40
40
|
const token = opts.token ?? newToken();
|
|
41
|
-
const
|
|
41
|
+
const scripts = opts.scripts !== false;
|
|
42
|
+
// an untrusted project (added from a browser) is read from its files only
|
|
43
|
+
const readFor = (p) => !scripts || p.trusted
|
|
44
|
+
? { scripts }
|
|
45
|
+
: {
|
|
46
|
+
scripts: false,
|
|
47
|
+
offNotice: `Read directly from the ticket files: this project was added from the browser, so its scripts are not run. Run \`bmad-kanban ${p.path}\` once to trust it.`,
|
|
48
|
+
};
|
|
42
49
|
const watchers = new Map();
|
|
43
50
|
const clients = new Set();
|
|
44
51
|
let actualPort = 0;
|
|
@@ -156,23 +163,17 @@ export function startServer(opts) {
|
|
|
156
163
|
throw new HttpError(405, 'Method not allowed');
|
|
157
164
|
return serveStatic(urlPath, res);
|
|
158
165
|
}
|
|
159
|
-
//
|
|
166
|
+
// proves this board holds the token without revealing it
|
|
160
167
|
if (seg[1] === 'hello' && seg.length === 2 && method === 'GET') {
|
|
161
168
|
const nonce = new URLSearchParams(query).get('nonce') ?? '';
|
|
162
169
|
if (!/^[0-9a-f]{32,128}$/.test(nonce))
|
|
163
170
|
throw new HttpError(400, 'nonce must be 32 to 128 hex characters');
|
|
164
171
|
return sendJson(res, 200, { proof: proof(token, nonce) });
|
|
165
172
|
}
|
|
166
|
-
//
|
|
173
|
+
// The API is open to any browser on this machine, like a dev server. The token only
|
|
174
|
+
// decides whether a project being added is trusted to run its own scripts.
|
|
167
175
|
const auth = req.headers.authorization;
|
|
168
|
-
const
|
|
169
|
-
? auth.slice('Bearer '.length)
|
|
170
|
-
: seg[1] === 'events'
|
|
171
|
-
? new URLSearchParams(query).get('token')
|
|
172
|
-
: null;
|
|
173
|
-
if (given === null || !sameSecret(given, token)) {
|
|
174
|
-
throw new HttpError(401, 'Missing or wrong access token: open the board with the bmad-kanban command');
|
|
175
|
-
}
|
|
176
|
+
const withToken = auth?.startsWith('Bearer ') === true && sameSecret(auth.slice('Bearer '.length), token);
|
|
176
177
|
if (seg[1] === 'events' && seg.length === 2 && method === 'GET') {
|
|
177
178
|
res.writeHead(200, { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache', Connection: 'keep-alive' });
|
|
178
179
|
res.write(': connected\n\n');
|
|
@@ -197,15 +198,15 @@ export function startServer(opts) {
|
|
|
197
198
|
if (seg[1] === 'projects') {
|
|
198
199
|
if (seg.length === 2 && method === 'GET') {
|
|
199
200
|
await watchAll(); // picks up projects whose folder came back
|
|
200
|
-
return sendJson(res, 200, await Promise.all(registry.list().map((p) => summarize(p,
|
|
201
|
+
return sendJson(res, 200, await Promise.all(registry.list().map((p) => summarize(p, readFor(p)))));
|
|
201
202
|
}
|
|
202
203
|
if (seg.length === 2 && method === 'POST') {
|
|
203
204
|
const body = await readJson(req);
|
|
204
205
|
if (typeof body.path !== 'string' || body.path === '')
|
|
205
206
|
throw new HttpError(400, 'path is required');
|
|
206
|
-
const added = registry.add(body.path);
|
|
207
|
+
const added = registry.add(body.path, withToken);
|
|
207
208
|
await ensureWatcher(added);
|
|
208
|
-
const summary = await summarize(added,
|
|
209
|
+
const summary = await summarize(added, readFor(added));
|
|
209
210
|
broadcast('projects', {});
|
|
210
211
|
return sendJson(res, 201, summary);
|
|
211
212
|
}
|
|
@@ -238,9 +239,9 @@ export function startServer(opts) {
|
|
|
238
239
|
}
|
|
239
240
|
await ensureWatcher(p);
|
|
240
241
|
if (seg.length === 5)
|
|
241
|
-
return sendJson(res, 200, await readBoard(p.path, seg[4],
|
|
242
|
+
return sendJson(res, 200, await readBoard(p.path, seg[4], readFor(p)));
|
|
242
243
|
if (seg.length === 7 && seg[5] === 'stories') {
|
|
243
|
-
return sendJson(res, 200, await getStoryDetail(p.path, seg[4], seg[6],
|
|
244
|
+
return sendJson(res, 200, await getStoryDetail(p.path, seg[4], seg[6], readFor(p)));
|
|
244
245
|
}
|
|
245
246
|
}
|
|
246
247
|
}
|
|
@@ -290,7 +291,7 @@ export function startServer(opts) {
|
|
|
290
291
|
return {
|
|
291
292
|
port: actualPort,
|
|
292
293
|
token,
|
|
293
|
-
scripts
|
|
294
|
+
scripts,
|
|
294
295
|
close: () => new Promise((resolve) => {
|
|
295
296
|
for (const id of [...watchers.keys()])
|
|
296
297
|
stopWatcher(id);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e,t,n,r,i,a,o,s,c,l,u={},d=[],f=/^m(i|n|o|s|text|space)$/,p=Array.isArray,m=d.slice,h=Object.assign;function g(e){e&&e.parentNode&&e.remove()}function _(n,r,i,a,o){var s={type:n,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o||++t,__i:-1,__u:0};return!o&&e.vnode&&e.vnode(s),s}function v(e){return e.children}function y(e,t){this.props=e,this.context=t,this.__g=0}function b(e,t){if(t==null)return e.__&&b(e.__,e.__i+1);for(var n;t<e.__k.length;t++)if((n=e.__k[t])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:b(e)}function x(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),x(e)}function S(t){(8&t.__g||(t.__g|=8,n.push(t),i++))&&r==e.debounceRendering||((r=e.debounceRendering)||queueMicrotask)(C)}function C(){var t,o,s,c,l,u,d,f,p;try{for(o=1;n.length;)n.length>o&&n.sort(a),t=n.shift(),o=n.length,8&t.__g&&(c=void 0,l=void 0,u=(l=(s=t).__v).__e,d=[],f=[],(p=s.__P)&&((c=h({constructor:void 0},l)).__v=l.__v+1,e.vnode&&e.vnode(c),A(p,c,l,s.__n,p.namespaceURI,32&l.__u?[u]:null,d,u||b(l),32&l.__u,f),c.__v=l.__v,c.__.__k[c.__i]=c,re(d,c,f),l.__=l.__e=null,c.__e!=u&&x(c)))}finally{(i=n.length)&&(r||queueMicrotask)(C)}}function ee(e,t,n,r,i,a,o,s,c,l,f){var p,m,h,g,_,v,y=r.__k||d,b=t.length;for(c=w(n,t,y,c,b),p=0;p<b;p++)(h=n.__k[p])!=null&&(m=~h.__i&&y[h.__i]||u,h.__i=p,v=A(e,h,m,i,a,o,s,c,l,f),g=h.__e,(m.ref!=h.ref||8&m.__u)&&(m.ref&&j(m.ref,null,h,m),h.ref&&f.push(h.ref,h.__c||g,h)),_||=g,4&h.__u?(c=T(h,c,e,!m.__v),m.__e&&(m.__e=null)):typeof h.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),h.__u&=-21);return n.__e=_,c}function w(e,t,n,r,i){var a,o,s,c,l,u,d,f,m,h=n.length,g=h,y=0,x=0,S=e.__k=Array(i);for(a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o!=`object`||o.constructor==String?o=S[a]=_(null,o):p(o)?o=S[a]=_(v,{children:o}):o.constructor===void 0&&o.__b?o=S[a]=_(o.type,o.props,o.key,o.ref,o.__v):S[a]=o,c=a+y,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=E(o,n,c,g))&&(g--,(s=n[l])&&(s.__u|=2)),s&&s.__v?(o.__u|=16,l==c-1?y--:l==c+1?y++:l!=c&&(l>c?y--:y++,x=1)):(~l||(i>h?y--:i<h&&y++),typeof o.type!=`function`&&(o.__u|=4))):S[a]=null;if(x){for(u=[],d=[],a=0;a<i;a++)if((o=S[a])&&16&o.__u){for(y=0,f=u.length;y<f;)u[m=y+f>>1]<o.__i?y=m+1:f=m;u[y]=o.__i,d[a]=y+1}for(y=u.length;a--;)d[a]&&(d[a]==y?y--:S[a].__u|=4)}if(g)for(a=0;a<h;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=b(s)),ae(s,s));return r}function T(e,t,n,r){var i,a,o,s;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=T(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=b(e))&&!t.parentNode&&(t=null),o=e.__e,s=t;s&&s.nodeType==8;)s=s.nextSibling;for(o!=s&&(!r&&n.moveBefore&&o.parentNode?n.moveBefore(o,t):n.insertBefore(o,t||null)),t=o;(t&&=t.nextSibling)&&t.nodeType==8&&!t.data.startsWith(`$s`););return t}function E(e,t,n,r){var i,a=e.key,o=e.type,s=t[n],c=s&&!(2&s.__u);if(s===null&&a==null||c&&a==s.key&&o==s.type)return n;if(r>+!!c){for(i=n-1;i>=0;i--)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i;for(i=n+1;i<t.length;i++)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i}return-1}function D(e,t,n){n??=``,t[0]==`-`?e.setProperty(t,n):e[t]=n}function O(e,t,n,r,i){var a,o;if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||D(e.style,t);if(n)for(t in n)r&&n[t]==r[t]||D(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)(e.__e||={})[t]=n,n&&r||(o=l[t]||(l[t]=k(t)),(e.__a||={})[t]=c,a=t!=(t=t.replace(s,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),n?e.addEventListener(t,o,a):e.removeEventListener(t,o,a));else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;return}catch{}if(typeof n==`function`)return;n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n)}}function k(t){return function(n){var r=this.__e;if(r){if(r=r[t],n[o]==null)n[o]=c++;else if(n[o]<this.__a[t])return;return r(e.event?e.event(n):n)}}}function A(t,n,r,i,a,o,s,c,l,u){var f,m,_,x,S,C,w,T,E,D,O,k,A,re,j,se,M,N,P=n.type;if(n.constructor!==void 0)return null;128&r.__u&&(l=32&r.__u,f=r.__c.__z)&&(n.__u|=l,m=o=[],f.nodeType==8?c=te(f,o):o.push(f),c=o[0]||c),(f=e.__b)&&f(n);n:if(typeof P==`function`){_=s.length;try{if(T=n.props,E=(f=P.prototype)&&f.render,D=(f=P.contextType)&&i[f.__c],O=f?D?D.props.value:f.__:i,(x=r.__c)?(n.__c=x,2&x.__g&&(x.__g|=1)):(E?n.__c=x=new P(T,O):(n.__c=x=new y(T,O),x.constructor=P,x.render=oe),D&&D.sub(x),x.state||(x.state={}),x.__n=i,x.__g|=8,x.__h=[],x.__k=[]),E&&(x.__s||(x.__s=x.state),P.getDerivedStateFromProps&&(x.__s==x.state&&(x.__s=h({},x.__s)),h(x.__s,P.getDerivedStateFromProps(T,x.__s)))),S=x.props,C=x.state,x.__v=n,r.__c){if(T!==S&&E&&!P.getDerivedStateFromProps&&x.componentWillReceiveProps&&x.componentWillReceiveProps(T,O),n.__v==r.__v&&!(8&x.__g)||!(4&x.__g)&&x.shouldComponentUpdate&&!1===x.shouldComponentUpdate(T,x.__s,O)){n.__v!=r.__v&&(x.props=T,x.state=x.__s,x.__g&=-9),n.__e=r.__e,n.__k=r.__k,n.__k.some(function(e){e&&(e.__=n)}),d.push.apply(x.__h,x.__k),x.__k=[],x.__h.length&&s.push(x),c=b(r);break n}x.componentWillUpdate&&x.componentWillUpdate(T,x.__s,O),E&&x.componentDidUpdate&&x.__h.push(function(){x.componentDidUpdate(S,C,w)})}else E&&!P.getDerivedStateFromProps&&x.componentWillMount&&x.componentWillMount(),E&&x.componentDidMount&&x.__h.push(x.componentDidMount);if(x.context=O,x.props=T,x.__P=t,x.__g&=-5,k=e.__r,A=0,E)x.state=x.__s,x.__g&=-9,k&&k(n),f=x.render(x.props,x.state,x.context),d.push.apply(x.__h,x.__k),x.__k=[];else do x.__g&=-9,k&&k(n),f=x.render(x.props,x.state,x.context),x.state=x.__s;while(8&x.__g&&++A<25);x.state=x.__s,x.getChildContext&&(i=h({},i,x.getChildContext())),E&&r.__c&&x.getSnapshotBeforeUpdate&&(w=x.getSnapshotBeforeUpdate(S,C)),re=f&&f.type===v&&f.key==null?f.props.children:f,T.__P&&(f=c,a=(t=T.__P).namespaceURI,l=o=null,r.props&&r.props.__P!=t&&(r.__k.some(function(e){e&&ae(e,e)}),r.__k=null),c=r.__k?b(r,0):null),c=ee(t,p(re)?re:[re],n,r,i,a,o,s,c,l,u),T.__P&&(n.__e=null,c=f),n.__u&=-161,m&&m.some(g),x.__h.length&&s.push(x),1&x.__g&&(x.__g&=-4)}catch(t){if(s.length=_,n.__v=null,l||o){if(t.then){if(j=0,n.__u|=128|l,o){for(~(M=o.indexOf(c||void 0))||(M=o.length);(N=o[M-1])&&N.nodeType==8;)M--;for(;M<o.length;M++)if(N=o[M]){if(o[M]=null,N.nodeType==8){if(N.data.startsWith(`$s`))j++||(se=N);else if(j&&N.data.startsWith(`/$s`)&&!--j)break}else if(!j)break}}if(!se){for(;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;se=c}(f=te(se=n.__c.__z||(n.__c.__z=se)))?(n.__e=se,c=f):n.__e=c,c&&=c.nextSibling}else o&&o.some(g)}else n.__e=r.__e;n.__k||=r.__k||[],t.then||ne(n),e.__e(t,n,r)}}else c=n.__e=ie(r.__e,n,r,i,a,o,s,l,u,t);return(f=e.diffed)&&f(n),c}function te(e,t){if(e&&e.nodeType==8&&e.data.startsWith(`$s`))for(var n=1;e=e.nextSibling;){if(e.nodeType==8){if(e.data.startsWith(`$s`))n++;else if(e.data.startsWith(`/$s`)&&!--n)return e}t&&t.push(e)}}function ne(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(ne))}function re(t,n,r){for(var i=0;i<r.length;)j(r[i++],r[i++],r[i++]);e.__c&&e.__c(n,t),t.some(function(n){try{t=n.__h,n.__h=[],t.some(function(e){e.call(n)})}catch(t){e.__e(t,n.__v)}})}function ie(t,n,r,i,a,o,s,c,l,d){var h,_,v,y,x,S,C,w,T,E=r.props||u,D=n.props,k=n.type;if(k==`svg`?a=`http://www.w3.org/2000/svg`:k==`math`?a=`http://www.w3.org/1998/Math/MathML`:a||=`http://www.w3.org/1999/xhtml`,o){for(h=0;h<o.length;h++)if((x=o[h])&&(k?x.localName==k:x.nodeType==3)){t=x,o[h]=null;break}}if(!t){if(w=d.ownerDocument||document,!k)return w.createTextNode(D);t=w.createElementNS(a,k,D.is&&D),c&&=(e.__m&&e.__m(n,o),!1),o=null}if(k){if(d=k==`template`?t.content:t,o=k==`textarea`&&D.defaultValue!=null?null:o&&m.call(d.childNodes),!c&&o)for(E={},h=0;h<t.attributes.length;h++)E[(x=t.attributes[h]).name]=x.value;for(h in E)x=E[h],h==`dangerouslySetInnerHTML`?v=x:h==`children`||h in D||h==`value`&&`defaultValue`in D||h==`checked`&&`defaultChecked`in D||O(t,h,null,x,a);for(h in T=1&r.__u,D)x=D[h],h==`children`?y=x:h==`dangerouslySetInnerHTML`?_=x:h==`value`?S=x:h==`checked`?C=x:c&&typeof x!=`function`||!(E[h]!==x||T&&x!=null)||O(t,h,x,E[h],a);_?(c||v&&(_.__html==v.__html||_.__html==t.innerHTML)||(t.innerHTML=_.__html),n.__k=[]):(v&&(t.textContent=``),(k==`foreignObject`||a==`http://www.w3.org/1998/Math/MathML`&&f.test(k))&&(a=`http://www.w3.org/1999/xhtml`),ee(d,p(y)?y:[y],n,r,i,a,o,s,o?o[0]:r.__k&&b(r,0),c,l),o&&o.some(g)),c&&k!=`textarea`||(h=`value`,k==`progress`&&S==null?t.removeAttribute(h):S==null||S===t[h]&&(k!=`progress`||S)||O(t,h,S,E[h],a),h=`checked`,C!=null&&C!=t[h]&&O(t,h,C,E[h],a))}else E===D||c&&t.data==D||(t.data=D);return t}function j(t,n,r,i){try{typeof t==`function`?n?n.__x=t(n)||1:(i&&=i.__c||i.__e)&&(n=i.__x)&&(i.__x=null,typeof n==`function`?n():t(null)):t.current=n}catch(t){e.__e(t,r)}}function ae(t,n,r){var i,a,o,s;if(e.unmount&&e.unmount(t),!(i=t.ref)||i.current&&i.current!=t.__e||j(i,null,n,t),i=t.__c){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(t){e.__e(t,n)}i.__P=i.__n=null}if(i=t.__k)for(s=0;s<i.length;s++)i[s]&&ae(i[s],n,typeof t.type!=`function`||r&&!t.props.__P);!r&&(i=t.__c)&&(i=i.__z)&&(a=te(i,o=[]))&&(i==t.__e&&o.some(g),g(a),g(i)),(i=t.__e)&&(r||g(i),i.__e&&(i.__e=null)),t.__e=t.__c=t.__=null}function oe(e,t,n){return this.constructor(e,n)}function se(t,n){var r,i,a,o;e.__&&e.__(t,n),n.nodeType==9&&(n=n.documentElement),i=(r=t&&32&t.__u)?null:n.__k,n.__k=_(v,{children:[t]}),a=[],o=[],A(n,n.__k,i||u,u,n.namespaceURI,i?null:n.firstChild?m.call(n.childNodes):null,a,i?i.__e:n.firstChild,r,o),re(a,n.__k,o),n.__k.props.children=null}e={__e:function(e,t,n,r){for(var a,o,s;t=t.__;)if((a=t.__c)&&!(1&a.__g)){a.__g|=4;try{if((s=(o=a.constructor)&&o.getDerivedStateFromError)&&a.setState(o.getDerivedStateFromError(e)),a.componentDidCatch&&(a.componentDidCatch(e,r||{}),s=1),s&&8&a.__g)return void(a.__g|=2)}catch(t){e=t}}throw i=0,e}},t=0,y.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=h({},this.state)),typeof e==`function`&&(e=e(h({},n),this.props)),e&&(h(n,e),this.__v&&(t&&this.__k.push(t),S(this)))},y.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),S(this))},y.prototype.render=v,n=[],i=0,a=function(e,t){return e.__v.__b-t.__v.__b},o=Symbol(),s=/(PointerCapture)$|Capture$/i,c=0,l={};var M,N,P,ce,le=Object.is,ue=0,de=[],fe=[],F=e,pe=F.__b,me=F.__r,he=F.diffed,I=F.__c,ge=F.unmount,L=F.__;function _e(e,t){F.__h&&F.__h(N,e,ue||t),ue=0;var n=N.__H||(N.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function R(e){return ue=1,ve(ke,e)}function ve(e,t,n){var r=_e(M++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ke(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);le(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=N,!N.__f)){N.__f=!0;var i=N.shouldComponentUpdate;N.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,le(e.__[0],e.__N[0])||(o=!0))}),i){var s=i.call(this,e,t,n);return a?s||o:s}return!a||o}}return r.__}function ye(e,t){var n=_e(M++,3);!F.__s&&Oe(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,N.__H.__h.push(n))}function z(e){return ue=5,be(function(){return{current:e}},[])}function be(e,t){var n=_e(M++,7);return Oe(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function xe(e,t){return ue=8,be(function(){return e},t)}function Se(){var e;do{for(;e=fe.shift();)try{Ee(e)}catch(t){F.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=de.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Ee),t.__h.some(De),t.__h=[]}catch(n){t.__h=[],F.__e(n,e.__v)}}}while(fe.length)}F.__b=function(e){N=null,pe&&pe(e)},F.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),L&&L(e,t)},F.__r=function(e){me&&me(e),M=0;var t=(N=e.__c).__H;t&&(P==N?N.__h=[]:(t.__h.some(Ee),t.__h.some(De),M=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),P=N},F.diffed=function(e){he&&he(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&Te(de.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),P=N=null},F.__c=function(e,t){t.some(function(e){try{e.__h.some(Ee),e.__h=e.__h.filter(function(e){return!e.__||De(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],F.__e(n,e.__v)}}),I&&I(e,t)},F.unmount=function(e){ge&&ge(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n&&=n.__c}r.__P=n,Te(fe.push(r))}else Ee(r)}catch(e){t=e}}),r.__H=void 0,t&&F.__e(t,r.__v))};var Ce=typeof requestAnimationFrame==`function`;function we(e){var t,n=function(){clearTimeout(r),Ce&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ce&&(t=requestAnimationFrame(n))}function Te(e){e!=1&&ce==F.requestAnimationFrame||((ce=F.requestAnimationFrame)||we)(Se)}function Ee(e){var t=N,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),N=t}function De(e){var t=N;e.__c=e.__(),N=t}function Oe(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!le(t,e[n])})}function ke(e,t){return typeof t==`function`?t(e):t}var Ae=class extends Error{status;constructor(e,t){super(t),this.status=e}},B=encodeURIComponent,je={"Content-Type":`application/json`},Me=`bmad-kanban-token`;function Ne(){let e=new URLSearchParams(location.hash.slice(1)).get(`token`);if(e!==null){history.replaceState(null,``,location.pathname+location.search);try{sessionStorage.setItem(Me,e)}catch{}return e}try{return sessionStorage.getItem(Me)??``}catch{return``}}var Pe=Ne();async function Fe(e,t={}){let n=await fetch(e,Pe===``?t:{...t,headers:{...t.headers,Authorization:`Bearer ${Pe}`}});if(!n.ok){let e=`${n.status} ${n.statusText}`;try{let t=await n.json();typeof t.error==`string`&&(e=t.error)}catch{}throw new Ae(n.status,e)}return n.status===204?void 0:await n.json()}var Ie=(e,t)=>({method:e,headers:je,body:JSON.stringify(t)}),Le={projects:()=>Fe(`/api/projects`),addProject:e=>Fe(`/api/projects`,Ie(`POST`,{path:e})),removeProject:e=>Fe(`/api/projects/${B(e)}`,{method:`DELETE`}),setPrefs:(e,t)=>Fe(`/api/projects/${B(e)}/prefs`,Ie(`PUT`,t)),board:(e,t)=>Fe(`/api/projects/${B(e)}/boards/${B(t)}`),story:(e,t,n)=>Fe(`/api/projects/${B(e)}/boards/${B(t)}/stories/${B(n)}`),state:()=>Fe(`/api/state`),setLastViewed:e=>Fe(`/api/state`,Ie(`PUT`,{lastViewed:e}))},Re=[`backlog`,`ready`,`in-progress`,`review`,`done`,`dropped`],ze={backlog:`Backlog`,ready:`Ready`,"in-progress":`In progress`,review:`Review`,done:`Done`,dropped:`Dropped`},Be=()=>({backlog:[],ready:[],"in-progress":[],review:[],done:[],dropped:[]});function Ve(e,t,n){let r=Be();for(let i of e)i.column===`dropped`&&!t||n!==null&&i.epicId!==n||r[i.column].push(i);return r}function He(e,t){let n=new Set(e.epics.map(e=>e.id)),r=(e,n)=>({epic:e,done:n.filter(e=>e.column===`done`).length,total:n.filter(e=>e.column!==`dropped`).length,cells:Ve(n,t,null)}),i=e.epics.map(t=>r(t,e.stories.filter(e=>e.epicId===t.id))),a=e.stories.filter(e=>e.epicId===null||!n.has(e.epicId));return a.filter(e=>t||e.column!==`dropped`).length>0&&i.push(r(null,a)),i}var Ue=[`#3b82f6`,`#a855f7`,`#f59e0b`,`#10b981`,`#ef4444`,`#06b6d4`,`#ec4899`,`#84cc16`];function We(e){let t=Ue.length;return Ue[(e%t+t)%t]}function Ge(e){let t=e.title.trim();return t===e.key?t:`${e.id} ${t}`}var Ke=0;Array.isArray;function V(t,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l&&typeof t!=`function`)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:t,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ke,__i:-1,__u:0};return(a||o)&&(u.__source=a,u.__self=o),e.vnode&&e.vnode(u),u}function qe({info:e}){let{epic:t,index:n}=e,r=t.retrospective===`done`;return V(`span`,{class:`chip`,style:{background:We(n)},title:`Epic ${t.id}: ${t.title}${r?` (retrospective done)`:``}`,children:[t.id,r&&V(`span`,{class:`retro`,"aria-label":`retrospective done`,children:`✓`})]})}function Je(){return V(`svg`,{class:`card-file`,viewBox:`0 0 16 16`,width:`13`,height:`13`,role:`img`,"aria-label":`has story file`,children:[V(`title`,{children:`Has a story file`}),V(`path`,{d:`M4 1.5h5L12.5 5v9.5h-8.5z M9 1.5V5h3.5`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`,"stroke-linejoin":`round`})]})}function Ye({story:e}){let[t,n]=R(`idle`),r=z(void 0);ye(()=>()=>clearTimeout(r.current),[]);let i=async()=>{try{await navigator.clipboard.writeText(Ge(e)),n(`copied`)}catch{n(`failed`)}clearTimeout(r.current),r.current=setTimeout(()=>n(`idle`),1500)},a=t===`copied`?`Copied`:t===`failed`?`Copy failed`:`Copy`;return V(`button`,{type:`button`,class:`card-copy${t===`idle`?``:` ${t}`}`,onClick:i,"aria-label":`Copy title`,title:`Copy "${Ge(e)}"`,children:V(`span`,{"aria-live":`polite`,children:a})})}function Xe(e){let{story:t,epic:n}=e,r=`card${t.column===`dropped`?` dropped`:``}${t.noFile?` no-file`:``}`,i=V(v,{children:[V(`span`,{class:`card-top`,children:[e.showEpic&&n&&V(qe,{info:n}),V(`span`,{class:`card-id`,children:t.id}),!t.noFile&&V(Je,{}),t.blocked&&V(`span`,{class:`badge blocked`,children:`blocked`}),(t.type===`spike`||t.type===`bug`)&&V(`span`,{class:`badge type-${t.type}`,children:t.type})]}),V(`span`,{class:`card-title`,children:t.title}),t.unknownStatus!==void 0&&V(`span`,{class:`badge unknown`,children:[`unknown status: `,t.unknownStatus]})]});return V(`div`,{class:`card-wrap`,children:[t.noFile?V(`div`,{class:r,children:i}):V(`button`,{type:`button`,class:r,onClick:()=>e.onOpen(t),children:i}),V(Ye,{story:t})]})}function Ze(e,t){this.v=e,this.k=t}function Qe(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function $e(e){if(Array.isArray(e))return e}function et(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function tt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nt(e,t){return $e(e)||et(e,t)||rt(e,t)||tt()}function rt(e,t){if(e){if(typeof e==`string`)return Qe(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Qe(e,t):void 0}}function it(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof Ze;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}it.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},it.prototype.next=function(e){return this._invoke(`next`,e)},it.prototype.throw=function(e){return this._invoke(`throw`,e)},it.prototype.return=function(e){return this._invoke(`return`,e)};var at=Object.entries,H=Object.setPrototypeOf,ot=Object.isFrozen,st=Object.getPrototypeOf,ct=Object.getOwnPropertyDescriptor,U=Object.freeze,W=Object.seal,lt=Object.create,ut=typeof Reflect<`u`&&Reflect,dt=ut.apply,ft=ut.construct;U||=function(e){return e},W||=function(e){return e},dt||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},ft||=function(e){return new e(...[...arguments].slice(1))};var pt=q(Array.prototype.forEach);Array.prototype.indexOf;var mt=q(Array.prototype.lastIndexOf),ht=q(Array.prototype.pop),gt=q(Array.prototype.push),_t=q(Array.prototype.slice),vt=q(Array.prototype.splice),yt=Array.isArray,bt=Ft(Set),xt=q(Set.prototype.add),St=q(Set.prototype.has),Ct=q(String.prototype.toLowerCase),wt=q(String.prototype.toString),Tt=q(String.prototype.match),Et=q(String.prototype.replace),Dt=q(String.prototype.indexOf),Ot=q(String.prototype.trim),kt=q(Number.prototype.toString),At=q(Boolean.prototype.toString),jt=typeof BigInt>`u`?null:q(BigInt.prototype.toString),Mt=typeof Symbol>`u`?null:q(Symbol.prototype.toString),G=q(Object.prototype.hasOwnProperty),Nt=q(Object.prototype.toString),K=q(RegExp.prototype.test),Pt=Ft(TypeError);function q(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return dt(e,t,n)}}function Ft(e){return function(){return ft(e,[...arguments])}}function J(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ct;if(H&&H(e,null),!yt(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(ot(t)||(t[r]=e),i=e)}e[i]=!0}return e}function It(e){for(let t=0;t<e.length;t++)G(e,t)||(e[t]=null);return e}function Y(e){let t=lt(null);for(let r of at(e)){var n=nt(r,2);let i=n[0],a=n[1];G(e,i)&&(t[i]=yt(a)?It(a):a&&typeof a==`object`&&a.constructor===Object?Y(a):a)}return t}function Lt(e){switch(typeof e){case`string`:return e;case`number`:return kt(e);case`boolean`:return At(e);case`bigint`:return jt?jt(e):`0`;case`symbol`:return Mt?Mt(e):`Symbol()`;case`undefined`:return Nt(e);case`function`:case`object`:{if(e===null)return Nt(e);let t=e,n=Rt(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Nt(e)}return Nt(e)}default:return Nt(e)}}function Rt(e,t){for(;e!==null;){let n=ct(e,t);if(n){if(n.get)return q(n.get);if(typeof n.value==`function`)return q(n.value)}e=st(e)}function n(){return null}return n}function zt(e,t){for(;e!==null;){let n=ct(e,t);if(n)return n.get?q(n.get):null;e=st(e)}return null}function Bt(e){try{return K(e,``),!0}catch{return!1}}var Vt=U(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Ht=U(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),Ut=U([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Wt=U([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Gt=U(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),Kt=U([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),qt=U([`#text`]),Jt=U(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Yt=U(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Xt=U(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Zt=U([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Qt=W(/{{[\w\W]*|^[\w\W]*}}/g),$t=W(/<%[\w\W]*|^[\w\W]*%>/g),en=W(/\${[\w\W]*/g),tn=W(/^data-[\-\w.\u00B7-\uFFFF]+$/),nn=W(/^aria-[\-\w]+$/),rn=W(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),an=W(/^(?:\w+script|data):/i),on=W(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),sn=W(/^html$/i),cn=W(/^[a-z][.\w]*(-[.\w]+)+$/i),ln=W(/<[/\w!]/g),un=W(/<[/\w]/g),dn=W(/<\/no(script|embed|frames)/i),fn=W(/\/>/i),X={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},pn=U(J({},[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`])),mn=function(){return typeof window>`u`?null:window},hn=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},gn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},_n=function(e,t,n,r){return G(e,t)&&yt(e[t])?J(r.base?Y(r.base):{},e[t],r.transform):n},vn=function(e,t,n){let r=G(e,t)?e[t]:void 0;return r&&typeof r==`object`?Y(r):n()};function yn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:mn(),t=e=>yn(e);if(t.version=`3.4.17`,t.removed=[],!e||!e.document||e.document.nodeType!==X.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=Rt(d,`cloneNode`),p=Rt(d,`remove`),m=Rt(d,`removeAttributeNode`),h=Rt(d,`nextSibling`),g=Rt(d,`childNodes`),_=Rt(d,`parentNode`),v=Rt(d,`shadowRoot`),y=Rt(d,`attributes`),b=o&&o.prototype?Rt(o.prototype,`nodeType`):null,x=o&&o.prototype?Rt(o.prototype,`nodeName`):null,S=o&&o.prototype?Rt(o.prototype,`ownerDocument`):null,C=function(e){return b?b(e):e.nodeType},ee=function(e){return x?x(e):e.nodeName},w=zt(d,`namespaceURI`),T=function(e){return w?w(e):e.namespaceURI};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let E,D=``,O,k=!1,A=0,te=function(){if(A>0)throw Pt(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},ne=function(e){te(),A++;try{return E.createHTML(e)}finally{A--}},re=function(e){te(),A++;try{return E.createScriptURL(e)}finally{A--}},ie=function(){return k||=(O=hn(u,i),!0),O},j=n,ae=j.implementation,oe=j.createNodeIterator,se=j.createDocumentFragment,M=j.getElementsByTagName,N=r.importNode,P=gn();t.isSupported=typeof at==`function`&&typeof _==`function`&&ae&&ae.createHTMLDocument!==void 0;let ce=Qt,le=$t,ue=en,de=tn,fe=nn,F=an,pe=on,me=cn,he=rn,I=null,ge=J({},[...Vt,...Ht,...Ut,...Gt,...qt]),L=null,_e=J({},[...Jt,...Yt,...Xt,...Zt]),R=Object.seal(lt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ve=null,ye=null,z=Object.seal(lt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),be=!0,xe=!0,Se=!1,Ce=!0,we=!1,Te=!0,Ee=!1,De=!1,Oe=null,ke=null,Ae=!1,B=!1,je=!1,Me=!1,Ne=!0,Pe=!1,Fe=`user-content-`,Ie=!0,Le=!1,Re=null,ze={},Be=null,Ve=J({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),He=null,Ue=J({},[`audio`,`video`,`img`,`source`,`image`,`track`]),We=null,Ge=J({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ke=`http://www.w3.org/1998/Math/MathML`,V=`http://www.w3.org/2000/svg`,qe=`http://www.w3.org/1999/xhtml`,Je=qe,Ye=!1,Xe=null,Ze=J({},[Ke,V,qe],wt),Qe=U([`mi`,`mo`,`mn`,`ms`,`mtext`]),$e=J({},Qe),et=U([`annotation-xml`]),tt=J({},et),nt=J({},[`title`,`style`,`font`,`a`,`script`]),rt=null,it=[`application/xhtml+xml`,`text/html`],H=null,ot=null,st=n.createElement(`form`),ct=function(e){return e instanceof RegExp||e instanceof Function},ut=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ot&&ot===e)return;e&&typeof e==`object`||(e={}),e=Y(e),rt=it.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,H=rt===`application/xhtml+xml`?wt:Ct,I=_n(e,`ALLOWED_TAGS`,ge,{transform:H}),L=_n(e,`ALLOWED_ATTR`,_e,{transform:H}),Xe=_n(e,`ALLOWED_NAMESPACES`,Ze,{transform:wt}),We=_n(e,`ADD_URI_SAFE_ATTR`,Ge,{transform:H,base:Ge}),He=_n(e,`ADD_DATA_URI_TAGS`,Ue,{transform:H,base:Ue}),Be=_n(e,`FORBID_CONTENTS`,Ve,{transform:H}),ve=_n(e,`FORBID_TAGS`,Y({}),{transform:H}),ye=_n(e,`FORBID_ATTR`,Y({}),{transform:H}),ze=G(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Y(e.USE_PROFILES):e.USE_PROFILES:!1,be=e.ALLOW_ARIA_ATTR!==!1,xe=e.ALLOW_DATA_ATTR!==!1,Se=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ce=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,we=e.SAFE_FOR_TEMPLATES||!1,Te=e.SAFE_FOR_XML!==!1,Ee=e.WHOLE_DOCUMENT||!1,B=e.RETURN_DOM||!1,je=e.RETURN_DOM_FRAGMENT||!1,Me=e.RETURN_TRUSTED_TYPE||!1,Ae=e.FORCE_BODY||!1,Ne=e.SANITIZE_DOM!==!1,Pe=e.SANITIZE_NAMED_PROPS||!1,Ie=e.KEEP_CONTENT!==!1,Le=e.IN_PLACE||!1,he=Bt(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:rn,Je=typeof e.NAMESPACE==`string`?e.NAMESPACE:qe,$e=vn(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>J({},Qe)),tt=vn(e,`HTML_INTEGRATION_POINTS`,()=>J({},et));let t=vn(e,`CUSTOM_ELEMENT_HANDLING`,()=>lt(null));if(R=lt(null),G(t,`tagNameCheck`)&&ct(t.tagNameCheck)&&(R.tagNameCheck=t.tagNameCheck),G(t,`attributeNameCheck`)&&ct(t.attributeNameCheck)&&(R.attributeNameCheck=t.attributeNameCheck),G(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(R.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),W(R),we&&(xe=!1),je&&(B=!0),ze&&(I=J({},qt),L=lt(null),ze.html===!0&&(J(I,Vt),J(L,Jt)),ze.svg===!0&&(J(I,Ht),J(L,Yt),J(L,Zt)),ze.svgFilters===!0&&(J(I,Ut),J(L,Yt),J(L,Zt)),ze.mathMl===!0&&(J(I,Gt),J(L,Xt),J(L,Zt))),z.tagCheck=null,z.attributeCheck=null,G(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?z.tagCheck=e.ADD_TAGS:yt(e.ADD_TAGS)&&(I===ge&&(I=Y(I)),J(I,e.ADD_TAGS,H))),G(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?z.attributeCheck=e.ADD_ATTR:yt(e.ADD_ATTR)&&(L===_e&&(L=Y(L)),J(L,e.ADD_ATTR,H))),G(e,`ADD_FORBID_CONTENTS`)&&yt(e.ADD_FORBID_CONTENTS)&&(Be===Ve&&(Be=Y(Be)),J(Be,e.ADD_FORBID_CONTENTS,H)),Ie&&(I[`#text`]=!0),Ee&&J(I,[`html`,`head`,`body`]),I.table&&(J(I,[`tbody`]),delete ve.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Pt(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Pt(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=E;E=e.TRUSTED_TYPES_POLICY;try{D=ne(``)}catch(e){throw E=t,e}}else e.TRUSTED_TYPES_POLICY===null?(E=void 0,D=``):(E===void 0&&(E=ie()),E&&typeof D==`string`&&(D=ne(``)));U&&U(e),ot=e},dt=J({},[...Ht,...Ut,...Wt]),ft=J({},[...Gt,...Kt]),kt=function(e,t,n){return t.namespaceURI===qe?e===`svg`:t.namespaceURI===Ke?e===`svg`&&(n===`annotation-xml`||$e[n]):!!dt[e]},At=function(e,t,n){return t.namespaceURI===qe?e===`math`:t.namespaceURI===V?e===`math`&&tt[n]:!!ft[e]},jt=function(e,t,n){return t.namespaceURI===V&&!tt[n]||t.namespaceURI===Ke&&!$e[n]?!1:!ft[e]&&(nt[e]||!dt[e])},Mt=function(e){let t=T(e),n=Ct(ee(e)),r=_(e),i,a;return r&&C(r)===X.element?(i={namespaceURI:T(r)},a=Ct(ee(r))):(i={namespaceURI:Je},a=`template`),Xe[t]?t===V?kt(n,i,a):t===Ke?At(n,i,a):t===qe?jt(n,i,a):!!(rt===`application/xhtml+xml`&&Xe[t]):!1},Nt=function(e){gt(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw Pt(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},q=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},Ft=function(e){Sn(e);let t=g(e);t&&pt(_t(t),e=>{try{p(e)}catch{}});let n=C(e)===X.element?y(e):null;if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&q(e,r,i)}},It=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}gt(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(B||je)try{Nt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},bn=function(e){let t=y(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||L[H(i)]||q(e,r,i)}},xn=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=[e];for(;r.length>0;){let e=r.pop();if(t(e)===!1)continue;if(n&&C(e)===X.element){let t=v(e);Fn(t)&&r.push(t)}let i=g(e);if(i)for(let e=i.length-1;e>=0;--e)r.push(i[e])}},Sn=function(e){xn(e,e=>{C(e)===X.element&&bn(e)})},Cn=function(e){let t=[];return xn(e,e=>{t.push(e)},!0),t},wn=function(e,t){let n=bt();pt(Cn(e),e=>{C(e)===X.element&&xt(n,e)}),pt(t,e=>{C(e)===X.element&&!St(n,e)&&bn(e)})},Tn=function(e,n){let r=!1;return pt(t.removed,t=>{t.element&&(r||=t.element===e,Sn(t.element))}),wn(e,n),r},Z=function(e,t){let n=Re,r=null,i=()=>(r||(r=bt(),pt(t,e=>{xt(r,e)})),r);for(let t=0;;t++){let r=Cn(e),a=[e],o=!1;if(pt(r,e=>{C(e)===X.documentFragment?gt(a,e):!o&&!St(n,e)&&(o=St(i(),e))}),!o)return;if(t>=8)throw Pt(`the tree kept changing during in-place sanitization; refusing to return it`);pt(a,(t,n)=>{En(t,n>0,e,i())})}},En=function(e,t,n,r){let i=An(e),a;for(;a=i.nextNode();)St(r,a)&&!St(Re,a)&&(t&&Ln(P.uponSanitizeShadowNode,a,null),Un(a,n),Xn(a,n),Fn(a.content)&&Zn(a.content))},Q=function(e){Re&&xt(Re,e)},Dn=function(e,t){return Te?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},On=function(e){Te&&xn(e,e=>{let t=C(e);if(t===X.processingInstruction||t===X.comment&&K(un,e.data)){try{p(e)}catch{}return!1}if(t===X.element){let t=e,n=H(ee(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Dn(`for`,n)&&t.removeAttribute(`for`)}catch{}}return!0})},kn=function(e){let t=null,r=null;if(Ae)e=`<remove></remove>`+e;else{let t=Tt(e,/^[\r\n\t ]+/);r=t&&t[0]}rt===`application/xhtml+xml`&&Je===qe&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=E?ne(e):e;if(Je===qe)try{t=new l().parseFromString(i,rt)}catch{}if(!t||!t.documentElement){t=ae.createDocument(Je,`template`,null);try{t.documentElement.innerHTML=Ye?D:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Je===qe?M.call(t,Ee?`html`:`body`)[0]:Ee?t.documentElement:a},An=function(e){let t=S?S(e):e.ownerDocument;return oe.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},jn=function(e){return e=Et(e,ce,` `),e=Et(e,le,` `),e=Et(e,ue,` `),e},Mn=function(e){Nn(e);let t=e.querySelectorAll?.call(e,`template`);t&&pt(t,e=>{Fn(e.content)&&Mn(e.content)})},Nn=function(e){e.normalize();let t=S?S(e):e.ownerDocument,n=oe.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=jn(r.data),r=n.nextNode()},Pn=function(e){let t=x?x(e):null;return typeof t!=`string`||H(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==y(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==b(e)||e.childNodes!==g(e)},Fn=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return b(e)===X.documentFragment}catch{return!1}},In=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return typeof b(e)==`number`}catch{return!1}};function Ln(e,n,r){e.length!==0&&pt(e,e=>{e.call(t,n,r,ot)})}let Rn=function(e,t){return!!(Te&&e.hasChildNodes()&&!In(e.firstElementChild)&&K(ln,e.textContent)&&K(ln,e.innerHTML)||Te&&pn[t]&&C(e)===X.element&&T(e)===qe&&(In(e.firstElementChild)||typeof e.textContent==`string`&&K(ln,e.textContent))||e.nodeType===X.processingInstruction||Te&&e.nodeType===X.comment&&K(un,e.data))},zn=function(e,t){return e instanceof RegExp?K(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Bn=function(e,t,n){if(!ve[t]&&Kn(t)&&zn(R.tagNameCheck,t))return!1;if(Ie&&!Be[t]&&!Be[Ct(t)]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,h(e))}}}return Nt(e),!0},Vn=function(e,t,n,r){return e.length===0?t:t===n||t===r?Y(t):t},Hn=function(e,t){return e===t||_(e)!==null?!1:(Le&&Sn(e),!0)},Un=function(e,n){if(Q(e),Ln(P.beforeSanitizeElements,e,null),Hn(e,n))return!0;if(Pn(e))return Nt(e),!0;let r=H(ee(e));if(I=Vn(P.uponSanitizeElement,I,ge,Oe),Ln(P.uponSanitizeElement,e,{tagName:r,allowedTags:I}),Hn(e,n))return!0;if(Rn(e,r))return Nt(e),!0;if(ve[r]||!(z.tagCheck instanceof Function&&z.tagCheck(r))&&!I[r]){let t=Bn(e,r,n);return t===!1&&(Ln(P.afterSanitizeElements,e,null),Hn(e,n))?!0:t}if(C(e)===X.element&&!Mt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&K(dn,e.innerHTML))return Nt(e),!0;if(we&&e.nodeType===X.text){let n=jn(e.textContent);e.textContent!==n&&(gt(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Ln(P.afterSanitizeElements,e,null),Hn(e,n)},Wn=function(e,t,r){if(ye[t]||Dn(t,e)||Ne&&(t===`id`||t===`name`)&&(r in n||r in st))return!1;let i=L[t]||z.attributeCheck instanceof Function&&z.attributeCheck(t,e);return xe&&K(de,t)||be&&K(fe,t)?!0:i?We[t]||K(he,Et(r,pe,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Dt(r,`data:`)===0&&He[e]||Se&&!K(F,Et(r,pe,``))?!0:!r:Kn(e)&&zn(R.tagNameCheck,e)&&zn(R.attributeNameCheck,t,e)||t===`is`&&R.allowCustomizedBuiltInElements&&zn(R.tagNameCheck,r)},Gn=J({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Kn=function(e){return!Gn[Ct(e)]&&K(me,e)},qn=function(e,t,n,r){if(E&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ne(r);case`TrustedScriptURL`:return re(r)}return r},Jn=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!Pn(e)||(Nt(e),!1)}catch{return It(t,e),!1}},Yn=function(e,t){return Te&&K(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,t)?!0:Ct(e)===`attributename`&&Tt(t,`href`)!==null},Xn=function(e,n){if(Ln(P.beforeSanitizeAttributes,e,null),Hn(e,n))return;let r=e.attributes;if(!r||Pn(e))return;L=Vn(P.uponSanitizeAttribute,L,_e,ke);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:L,forceKeepAttr:void 0},a=r.length,o=H(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=H(s),d=l,f=s===`value`?d:Ot(d),p=!1;i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Ln(P.uponSanitizeAttribute,e,i),f=i.attrValue,Pe&&(u===`id`||u===`name`)&&Dt(f,Fe)!==0&&(It(s,e,n),f=Fe+f,p=!0),Yn(s,f)?It(s,e,n):i.forceKeepAttr||(i.keepAttr?!Ce&&K(fn,f)?It(s,e,n):(we&&(f=jn(f)),Wn(o,u,f)?(f=qn(o,u,c,f),f!==d&&Jn(e,s,c,f)&&p&&ht(t.removed)):It(s,e,n)):It(s,e,n))}Ln(P.afterSanitizeAttributes,e,null),Hn(e,n)},Zn=function(e){let t=null,n=An(e);for(Ln(P.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Ln(P.uponSanitizeShadowNode,t,null),Un(t,e),Xn(t,e),Fn(t.content)&&Zn(t.content),C(t)===X.element){let e=v(t);Fn(e)&&(Qn(e),Zn(e))}we&&Nn(e),Ln(P.afterSanitizeShadowDOM,e,null)},Qn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Zn(e.shadow);continue}let n=e.node,r=C(n)===X.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=x?x(n):null;if(typeof e==`string`&&H(e)===`template`){let e=n.content;Fn(e)&&t.push({node:e,shadow:null})}}if(r){let e=v(n);Fn(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Ye=!e,Ye&&(e=`<!-->`),typeof e!=`string`&&!In(e)&&(e=Lt(e),typeof e!=`string`))throw Pt(`dirty is not a string, aborting`);if(!t.isSupported)return e;De?(I=Oe,L=ke):ut(n),(P.uponSanitizeElement.length>0||P.uponSanitizeAttribute.length>0)&&(I=Y(I)),P.uponSanitizeAttribute.length>0&&(L=Y(L)),t.removed=[];let c=Le&&typeof e!=`string`&&In(e),l=[],u=Re;if(c){On(e);let t=ee(e);if(typeof t==`string`){let n=H(t);if(!I[n]||ve[n])throw Ft(e),Pt(`root node is forbidden and cannot be sanitized in-place`)}if(Pn(e))throw Ft(e),Pt(`root node is clobbered and cannot be sanitized in-place`);l=Cn(e),Re=bt()}else if(In(e))i=kn(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===X.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Qn(i);else{if(!B&&!we&&!Ee&&e.indexOf(`<`)===-1)return E&&Me?ne(e):e;if(i=kn(e),!i)return B?null:Me?D:``}i&&Ae&&Nt(i.firstChild);let d=c?e:i;try{c&&Qn(e);let t=An(d);for(;o=t.nextNode();)Un(o,d),Xn(o,d),Fn(o.content)&&Zn(o.content);c&&Z(e,l)}catch(t){throw c&&(Ft(e),Tn(e,l)),t}finally{Re=u}if(c){if(Tn(e,l))throw Pt(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return we&&Mn(e),e}if(B){if(we&&Mn(i),je)for(s=se.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(L.shadowroot||L.shadowrootmode)&&(s=N.call(r,s,!0)),s}let f=Ee?i.outerHTML:i.innerHTML;return Ee&&I[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&K(sn,i.ownerDocument.doctype.name)&&(f=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
3
|
+
`+f),we&&(f=jn(f)),E&&Me?ne(f):f},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ut(e),De=!0,Oe=I,ke=L},t.clearConfig=function(){ot=null,De=!1,Oe=null,ke=null,E=O,D=``},t.isValidAttribute=function(e,t,n){ot||ut({});let r=H(e),i=H(t);return typeof n==`string`&&(Yn(t,n)||!Ce&&K(fn,n))?!1:Wn(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&G(P,e)&>(P[e],t)},t.removeHook=function(e,t){if(G(P,e)){if(t!==void 0){let n=mt(P[e],t);return n===-1?void 0:vt(P[e],n,1)[0]}return ht(P[e])}},t.removeHooks=function(e){G(P,e)&&(P[e]=[])},t.removeAllHooks=function(){P=gn()},t}var bn=yn();function xn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Sn=xn();function Cn(e){Sn=e}var wn={exec:()=>null};function Tn(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function Z(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(Q.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var En=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),Q={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,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,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,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:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Tn(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Tn(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:Tn(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Tn(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Tn(e=>RegExp(`^ {0,${e}}(?:</?(?:${Vn})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,`i`)),blockquoteBeginRegex:Tn(e=>RegExp(`^ {0,${e}}>`))},Dn=/^(?:[ \t]*(?:\n|$))+/,On=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,kn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,An=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,jn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Mn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Nn=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Pn=Z(Nn).replace(/bull/g,Mn).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}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Fn=Z(Nn).replace(/bull/g,Mn).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}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),In=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Ln=/^[^\n]+/,Rn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,zn=Z(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Rn).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Bn=Z(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Mn).getRegex(),Vn=`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`,Hn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Un=Z(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Hn).replace(`tag`,Vn).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Wn=e=>Z(In).replace(`hr`,An).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Vn).getRegex(),Gn=Wn(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Kn=Wn(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),qn={blockquote:Z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Kn).getRegex(),code:On,def:zn,fences:kn,heading:jn,hr:An,html:Un,lheading:Pn,list:Bn,newline:Dn,paragraph:Gn,table:wn,text:Ln},Jn=Z(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,An).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Vn).getRegex(),Yn={...qn,lheading:Fn,table:Jn,paragraph:Z(In).replace(`hr`,An).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Jn).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Vn).getRegex()},Xn={...qn,html:Z(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Hn).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:wn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Z(In).replace(`hr`,An).replace(`heading`,` *#{1,6} *[^
|
|
4
|
+
]`).replace(`lheading`,Pn).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Zn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Qn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$n=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,er=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,tr=/[\p{P}\p{S}]/u,nr=/[\s\p{P}\p{S}]/u,rr=/[^\s\p{P}\p{S}]/u,ir=Z(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,nr).getRegex(),ar=/[\p{Pi}\p{Ps}"']/u,or=/(?!~)[\p{P}\p{S}]/u,sr=/(?!~)[\s\p{P}\p{S}]/u,cr=/(?:[^\s\p{P}\p{S}]|~)/u,lr=Z(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,En?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),ur=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,dr=Z(ur,`u`).replace(/punct/g,tr).getRegex(),fr=Z(ur,`u`).replace(/punct/g,or).getRegex(),pr=Z(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,ar).replace(/punct/g,tr).getRegex(),mr=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,hr=Z(mr,`gu`).replace(/notPunctSpace/g,rr).replace(/punctSpace/g,nr).replace(/punct/g,tr).getRegex(),gr=Z(mr,`gu`).replace(/notPunctSpace/g,cr).replace(/punctSpace/g,sr).replace(/punct/g,or).getRegex(),_r=Z(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,rr).replace(/punctSpace/g,nr).replace(/punct/g,tr).getRegex(),vr=Z(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,rr).replace(/punctSpace/g,nr).replace(/punct/g,tr).getRegex(),yr=Z(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,rr).replace(/punctSpace/g,nr).replace(/punct/g,tr).getRegex(),br=Z(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,tr).getRegex(),xr=Z(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,rr).replace(/punctSpace/g,nr).replace(/punct/g,tr).getRegex(),Sr=Z(/\\(punct)/,`gu`).replace(/punct/g,tr).getRegex(),Cr=Z(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,`gu`).replace(/punct/g,tr).getRegex(),wr=Z(/^<(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(),Tr=Z(Hn).replace(`(?:-->|$)`,`-->`).getRegex(),Er=Z(`^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,Tr).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Dr=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,Or=Z(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,Dr).getRegex(),kr=Z(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace(`label`,Or).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ar=Z(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Or).replace(`ref`,Rn).getRegex(),jr=Z(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Rn).getRegex(),Mr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,Nr=Z(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,Dr).getRegex(),Pr=Z(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Z(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Nr).replace(`ref`,Mr).getRegex()).replace(`nolink`,Z(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Mr).getRegex()).getRegex(),Fr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ir=Z(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),Lr={_backpedal:wn,anyPunctuation:Sr,anyPunctuationOutsideCode:Cr,autolink:wr,blockSkip:lr,br:$n,code:Qn,del:wn,delLDelim:wn,delRDelim:wn,emStrongLDelim:dr,emStrongRDelimAst:hr,emStrongRDelimUnd:vr,escape:Zn,link:kr,nolink:jr,punctuation:ir,reflink:Ar,reflinkSearch:Pr,tag:Er,text:er,url:wn},Rr={...Lr,emStrongLDelim:pr,emStrongRDelimAst:_r,emStrongRDelimUnd:yr,link:Z(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Or).getRegex(),reflink:Z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Or).getRegex()},zr={...Lr,emStrongRDelimAst:gr,emStrongLDelim:fr,delLDelim:br,delRDelim:xr,url:Z(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,Ir).replace(`protocol`,Fr).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Z(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace(`protocol`,Fr).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},Br={...zr,br:Z($n).replace(`{2,}`,`*`).getRegex(),text:Z(zr.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Vr={normal:qn,gfm:Yn,pedantic:Xn},Hr={normal:Lr,gfm:zr,breaks:Br,pedantic:Rr},Ur={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Wr=e=>Ur[e];function Gr(e,t){if(t){if(Q.escapeTest.test(e))return e.replace(Q.escapeReplace,Wr)}else if(Q.escapeTestNoEncode.test(e))return e.replace(Q.escapeReplaceNoEncode,Wr);return e}function Kr(e){return Q.numericCharacterReference.test(e)?e.replace(Q.numericCharacterReferenceOrAmpersand,(e,t,n)=>{if(t===void 0&&n===void 0)return`&`;let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:r===38?`&`:String.fromCodePoint(r)}):e}function qr(e){try{e=encodeURI(e).replace(Q.percentDecode,`%`)}catch{return null}return e}function Jr(e,t){let n=e.replace(Q.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Q.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(Q.slashPipe,`|`);return n}function Yr(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Xr(e){let t=e.split(`
|
|
5
|
+
`),n=t.length-1;for(;n>=0&&Q.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
6
|
+
`)}function Zr(e){return e.trim().toLowerCase().toUpperCase().toLowerCase()}function Qr(e,t){if(e.indexOf(t[0])===-1&&e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function $r(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function ei(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`),c=e[0].charAt(0)===`!`,l=r.state.inLink,u=r.state.linkEmitted,d=r.state.inRawBlock;r.state.inLink=!0,r.state.linkEmitted=!1;let f=r.inlineTokens(s),p=r.state.linkEmitted;if(r.state.linkEmitted=u,r.state.inLink=l,!c){if(p){r.state.inRawBlock=d;return}r.state.linkEmitted=!0}return{type:c?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:f}}function ti(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
7
|
+
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return e.slice(Math.min(r.length,i.length))}).join(`
|
|
8
|
+
`)}function ni(e,t,n,r){if(!t.includes(`<`))return!1;for(let i=0;i<t.length;i++){if(t[i]===`\\`){i++;continue}if(t[i]==="`"){let e=r.inline.code.exec(t.slice(i));if(e){i+=e[0].length-1;continue}}if(t[i]!==`<`)continue;let a=e.slice(n+i),o=r.inline.tag.exec(a)||r.inline.autolink.exec(a);if(o){if(o[0].length>t.length-i)return!0;i+=o[0].length-1}}return!1}var ri=class{options;rules;lexer;constructor(e){this.options=e||Sn}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:Xr(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=ti(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Yr(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceTabChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:Yr(t[0],`
|
|
9
|
+
`),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:Yr(t[0],`
|
|
10
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Yr(t[0],`
|
|
11
|
+
`).split(`
|
|
12
|
+
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o=0;for(;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
13
|
+
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
14
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
15
|
+
${s}`:s,r=r?`${r}
|
|
16
|
+
${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`||u?.type===`heading`||u?.type===`hr`||u?.type===`html`)break;if(u?.type===`blockquote`){let t=u,a=e.join(`
|
|
17
|
+
`),o=t.raw+`
|
|
18
|
+
`+a.replace(this.rules.other.blockquoteSetextReplace2,``),s=this.blockquote(o);i[i.length-1]=s;let c=o.substring(s.raw.length).replace(/^\n/,``),l=c?c.split(`
|
|
19
|
+
`).length:0,d=l?e.slice(0,-l):e;d.length>0&&(n=`${n}
|
|
20
|
+
${d.join(`
|
|
21
|
+
`)}`),r=r.substring(0,r.length-t.text.length)+s.text;break}if(u?.type===`list`){let t=u,a=t.raw+`
|
|
22
|
+
`+e.join(`
|
|
23
|
+
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
|
|
24
|
+
`)}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=e,r=()=>n.length-e.length,i=t[1].trim(),a=i.length>1,o={type:`list`,raw:``,ordered:a,start:a?+i.slice(0,-1):``,loose:!1,items:[]};i=a?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=a?i:`[*+-]`);let s=this.rules.other.listItemRegex(i),c=!1;for(;e;){let i=!1,a=``;if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;let l=r();e=e.substring(t[0].length);let u=t[2].split(`
|
|
25
|
+
`,1)[0],d=t[1].length,f=this.options.pedantic?$r(u,d):u.replace(this.rules.other.leadingSpaceTab,e=>$r(e,d)),p=e.split(`
|
|
26
|
+
`,1)[0],m=!f.trim(),h=0;if(this.options.pedantic?(h=2,a=f.trimStart()):m?h=d+1:(h=f.search(this.rules.other.nonSpaceChar),h=h>4?1:h,a=f.slice(h),h+=d),m&&this.rules.other.blankLine.test(p)&&(e=e.substring(p.length+1),i=!0),!i){let t=this.rules.other.nextBulletRegex(h),n=this.rules.other.hrRegex(h),r=this.rules.other.fencesBeginRegex(h),i=this.rules.other.headingBeginRegex(h),o=this.rules.other.htmlBeginRegex(h),s=this.rules.other.blockquoteBeginRegex(h);for(;e;){let c=e.split(`
|
|
27
|
+
`,1)[0],l;if(p=c,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting,` `),l=p):l=p.replace(this.rules.other.leadingSpaceTab,e=>$r(e)),r.test(p)||i.test(p)||o.test(p)||s.test(p)||t.test(p)||n.test(p))break;if(l.search(this.rules.other.nonSpaceChar)>=h||!p.trim())a+=`
|
|
28
|
+
`+l.slice(h);else{if(m||f.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||r.test(f)||i.test(f)||n.test(f))break;a+=`
|
|
29
|
+
`+p}m=!p.trim(),e=e.substring(c.length+1),f=l.slice(h)}}let g=n.slice(l,r());o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(g)&&(c=!0)),o.items.push({type:`list_item`,raw:g,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]})}let l=o.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;o.raw=n.slice(0,r()).trimEnd();for(let e of o.items)if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),!o.loose){let t=e.tokens.filter(e=>e.type===`space`);o.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}for(let e of o.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,o.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1}if(o.loose)for(let e of o.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=Xr(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){if(!this.rules.other.startAngleBracket.test(t[2])&&Qr(t[2],`()`)!==-1)return;let e=Zr(t[1]).replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:Yr(t[0],`
|
|
30
|
+
`),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Jr(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
31
|
+
`):[],a={type:`table`,raw:Yr(t[0],`
|
|
32
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Jr(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:Yr(t[0],`
|
|
33
|
+
`),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
34
|
+
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){if(this.lexer.state.linkParenPossible===!1)return;let t=this.rules.inline.link.exec(e);if(t){let n=t[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&ni(e,t[1],n,this.rules))return;let r=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let e=Yr(r.slice(0,-1),`\\`);if((r.length-e.length)%2==0)return}else{let e=Qr(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let i=t[2],a=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(i);e&&(i=e[1],a=e[3])}else a=t[3]?t[3].slice(1,-1):``;return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(i=this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i.slice(1):i.slice(1,-1)),ei(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,`$1`),title:a&&a.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=n[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&ni(e,n[1],r,this.rules))return;let i=t[Zr((n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `))];if(!i){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return ei(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,a,o,s=i,c=0,l=r[0][0],u=n===l,d=l===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(o=[...a].length,r[3]||r[4]){s+=o;continue}if(r[5]||r[6]){if(i%3&&!((i+o)%3)){c+=o;continue}if(u)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+c);let t=[...r[0]][0].length,n=e.slice(0,i+r.index+t+o);if(Math.min(i,o)%2){let e=n.slice(1,-1);return{type:`em`,raw:n,text:e,tokens:this.lexer.inlineTokens(e)}}let l=n.slice(2,-2);return{type:`strong`,raw:n,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:e?t[0]:Kr(t[0]),escaped:e}}}},ii=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Sn,this.options.tokenizer=this.options.tokenizer||new ri,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,linkParenPossible:!0,top:!0};let t={other:Q,block:Vr.normal,inline:Hr.normal};this.options.pedantic?(t.block=Vr.pedantic,t.inline=Hr.pedantic):this.options.gfm&&(t.block=Vr.gfm,t.inline=this.options.breaks?Hr.breaks:Hr.gfm),this.tokenizer.rules=t}static get rules(){return{block:Vr,inline:Hr}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(Q.carriageReturn,`
|
|
35
|
+
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Q.tabCharGlobal,` `).replace(Q.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
|
|
36
|
+
`:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
37
|
+
`)?``:`
|
|
38
|
+
`)+i.raw,n.text+=`
|
|
39
|
+
`+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if((i=this.tokenizer.fences(e))||(i=this.tokenizer.heading(e))||(i=this.tokenizer.hr(e))||(i=this.tokenizer.blockquote(e))||(i=this.tokenizer.list(e))||(i=this.tokenizer.html(e))){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
40
|
+
`)?``:`
|
|
41
|
+
`)+i.raw,n.text+=`
|
|
42
|
+
`+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if((i=this.tokenizer.table(e))||(i=this.tokenizer.lheading(e))){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let r=t.at(-1);n&&r?.type===`paragraph`?(r.raw+=(r.raw.endsWith(`
|
|
43
|
+
`)?``:`
|
|
44
|
+
`)+i.raw,r.text+=`
|
|
45
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length)}else if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
46
|
+
`)?``:`
|
|
47
|
+
`)+i.raw,n.text+=`
|
|
48
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i)}else if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(e.charAt(0)!==`!`&&Object.hasOwn(this.tokens.links,Zr(e.slice(n+1,-1)))&&!(n>1&&this.linkInText(e.slice(1,n-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=this.state.linkParenPossible;this.state.linkParenPossible=n&&e.includes(`)`);try{return this.#e(e,t)}finally{this.state.linkParenPossible=n}}#e(e,t){let n=e;if(this.tokens.links&&e.includes(`[`)){let e=this.tokenizer.rules.inline.reflinkSearch,t=n=>{let r=n.lastIndexOf(`[`);if(!Object.hasOwn(this.tokens.links,Zr(n.slice(r+1,-1))))return n;if(r>1&&n.charAt(0)!==`!`){let i=n.slice(1,r-1);if(this.linkInText(i))return`[`+i.replace(e,t)+`][`+`a`.repeat(n.length-r-2)+`]`}return`[`+`a`.repeat(n.length-2)+`]`};n=n.replace(e,t)}n=n.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode,(e,t,n)=>n?`+`.repeat(e.length):t?t+e.slice(t.length,-t.length).replace(/`/g,`+`)+t:e),n=n.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+`[`+`a`.repeat(e.length-r-2)+`]`}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let r=!1,i=``,a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=``),r=!1;let o;if(this.options.extensions?.inline?.some(n=>(o=n.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if((o=this.tokenizer.escape(e))||(o=this.tokenizer.tag(e))||(o=this.tokenizer.link(e))){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let n=t.at(-1);o.type===`text`&&n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if((o=this.tokenizer.emStrong(e,n,i))||(o=this.tokenizer.codespan(e))||(o=this.tokenizer.br(e))||(o=this.tokenizer.del(e,n,i))||(o=this.tokenizer.autolink(e))||!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let s=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(s)){e=e.substring(o.raw.length),o.raw.slice(-1)!==`_`&&(i=o.raw.slice(-1)),r=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o)}else if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},ai=class{options;parser;constructor(e){this.options=e||Sn}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(Q.notSpaceStart)?.[0],i=e?e.replace(Q.endingNewline,``)+`
|
|
49
|
+
`:``;return r?`<pre><code class="language-`+Gr(r)+`">`+(n?i:Gr(i,!0))+`</code></pre>
|
|
50
|
+
`:`<pre><code>`+(n?i:Gr(i,!0))+`</code></pre>
|
|
51
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
52
|
+
${this.parser.parse(e)}</blockquote>
|
|
53
|
+
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
54
|
+
`}hr(e){return`<hr>
|
|
55
|
+
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
|
|
56
|
+
`+r+`</`+i+`>
|
|
57
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
58
|
+
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
59
|
+
`}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
|
|
60
|
+
<thead>
|
|
61
|
+
`+t+`</thead>
|
|
62
|
+
`+r+`</table>
|
|
63
|
+
`}tablerow({text:e}){return`<tr>
|
|
64
|
+
${e}</tr>
|
|
65
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
66
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Gr(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?Gr(n,!0):this.parser.parseInline(r),o=qr(e);if(o===null)return a;e=Gr(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+Gr(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=qr(e);if(i===null)return Gr(n);e=i;let a=`<img src="${Gr(e)}" alt="${Gr(n)}"`;return t&&(a+=` title="${Gr(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Gr(e.text)}},oi=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},si=class e{options;renderer;textRenderer;constructor(e){this.options=e||Sn,this.options.renderer=this.options.renderer||new ai,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new oi}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},ci=class{options;block;constructor(e){this.options=e||Sn}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?ii.lex:ii.lexInline}provideParser(e=this.block){return e?si.parse:si.parseInline}};function li(e,t){if(Array.isArray(t))for(let n=0;n<t.length;n++)e.push(t[n]);else e.push(t)}var ui=new class{defaults=xn();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=si;Renderer=ai;TextRenderer=oi;Lexer=ii;Tokenizer=ri;Hooks=ci;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(li(n,t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)li(n,this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)li(n,this.walkTokens(e.tokens,t));break}case`list`:{let e=r;li(n,this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);li(n,this.walkTokens(i,t))}):e.tokens&&li(n,this.walkTokens(e.tokens,t))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new ai(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new ri(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new ci;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=ci.passThroughHooks.has(n)?e=>{if(this.defaults.async&&ci.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&li(n,t.call(this,e)),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ii.lex(e,t??this.defaults)}parser(e,t){return si.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(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 t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?ii.lex:ii.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?si.parse:si.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?ii.lex:ii.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?si.parse:si.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
67
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Gr(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function $(e,t){return ui.parse(e,t)}$.options=$.setOptions=function(e){return ui.setOptions(e),$.defaults=ui.defaults,Cn($.defaults),$},$.getDefaults=xn,$.defaults=Sn;function di(...e){return ui.use(...e),$.defaults=ui.defaults,Cn($.defaults),$}$.use=di,$.walkTokens=function(e,t){return ui.walkTokens(e,t)},$.parseInline=ui.parseInline,$.Parser=si,$.parser=si.parse,$.Renderer=ai,$.TextRenderer=oi,$.Lexer=ii,$.lexer=ii.lex,$.Tokenizer=ri,$.Hooks=ci,$.parse=$,$.options,$.setOptions,$.walkTokens,$.parseInline,si.parse,ii.lex;function fi(e){let t=/^\uFEFF?---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(e);return t?{frontmatter:t[1],body:e.slice(t[0].length)}:{frontmatter:null,body:e}}function pi(e){let{projectId:t,sourceId:n,story:r,onClose:i}=e,[a,o]=R(null),[s,c]=R(null),[l,u]=R(!1),d=z(null),f=z(null);ye(()=>{let e=!0;return o(null),c(null),Le.story(t,n,r.key).then(t=>e&&o(t),t=>e&&c(t instanceof Error?t.message:String(t))),()=>{e=!1}},[t,n,r.key]),ye(()=>{let e=document.activeElement;f.current?.focus();let t=e=>{if(e.key===`Escape`)e.preventDefault(),i();else if(e.key===`Tab`&&d.current){let t=[...d.current.querySelectorAll(`button, a[href], [tabindex]:not([tabindex="-1"])`)];if(t.length===0)return;let n=t[0],r=t[t.length-1];d.current.contains(document.activeElement)?e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus()):(e.preventDefault(),n.focus())}};return document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`keydown`,t),e?.focus()}},[i]);let p=async()=>{if(a?.path)try{await navigator.clipboard.writeText(a.path),u(!0),setTimeout(()=>u(!1),1500)}catch{u(!1)}},m=a?fi(a.markdown):null,h=m?bn.sanitize($.parse(m.body,{async:!1})):``;return V(`div`,{class:`backdrop`,onClick:e=>e.target===e.currentTarget&&i(),children:V(`div`,{class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`detail-title`,ref:d,children:[V(`header`,{class:`modal-head`,children:[V(`h2`,{id:`detail-title`,children:[V(`span`,{class:`card-id`,children:r.id}),` `,r.title]}),V(`button`,{type:`button`,class:`icon-btn`,ref:f,onClick:i,"aria-label":`Close`,children:`×`})]}),V(`div`,{class:`modal-path`,children:a===null?null:a.path===null?V(`span`,{class:`muted`,children:`No file yet`}):V(v,{children:[V(`code`,{title:a.path,children:a.path}),V(`button`,{type:`button`,class:`small-btn`,onClick:p,children:l?`Copied`:`Copy path`})]})}),V(`div`,{class:`modal-body`,children:[s!==null&&V(`p`,{class:`notice error`,children:s}),a===null&&s===null&&V(`p`,{class:`muted`,children:`Loading…`}),m?.frontmatter&&V(`pre`,{class:`frontmatter`,children:m.frontmatter}),a!==null&&V(`div`,{class:`markdown`,dangerouslySetInnerHTML:{__html:h}})]})]})})}var mi=e=>new Map(e.epics.map((e,t)=>[e.id,{epic:e,index:t}])),hi=e=>Re.filter(t=>e||t!==`dropped`);function gi(e){let{board:t}=e,n=Ve(t.stories,e.showDropped,e.epicFilter),r=mi(t);return V(`div`,{class:`columns`,children:hi(e.showDropped).map(i=>V(`section`,{class:`column col-${i}`,"aria-label":ze[i],children:[V(`h3`,{class:`col-head`,children:[ze[i],` · `,n[i].length]}),n[i].map(n=>V(Xe,{story:n,showEpic:!0,epic:n.epicId===null?null:r.get(n.epicId)??null,onOpen:n=>e.onOpen(n,t.sourceId)},n.key))]},i))})}var _i=e=>e.sources.length>1||e.sources.some(e=>(e.children?.length??0)>0);function vi({onAdded:e}){let[t,n]=R(!1),[r,i]=R(``),[a,o]=R(null),[s,c]=R(!1),l=()=>{n(!1),i(``),o(null)};return t?V(`form`,{class:`add-form`,onSubmit:async t=>{if(t.preventDefault(),r.trim()!==``){c(!0),o(null);try{let t=await Le.addProject(r.trim());l(),e(t)}catch(e){o(e instanceof Error?e.message:String(e))}finally{c(!1)}}},children:[V(`label`,{for:`add-path`,class:`sr-only`,children:`Project folder path`}),V(`input`,{id:`add-path`,type:`text`,placeholder:`/path/to/project`,value:r,autoFocus:!0,onInput:e=>i(e.target.value),onKeyDown:e=>e.key===`Escape`&&l()}),V(`div`,{class:`add-actions`,children:[V(`button`,{type:`submit`,class:`small-btn primary`,disabled:s,children:`Add`}),V(`button`,{type:`button`,class:`small-btn`,onClick:l,children:`Cancel`})]}),a!==null&&V(`p`,{class:`add-error`,role:`alert`,children:a})]}):V(`button`,{type:`button`,class:`add-btn`,onClick:()=>n(!0),children:`+ Add project`})}function yi(e){let{project:t,source:n,selected:r}=e;return V(`li`,{children:[V(`button`,{type:`button`,class:`source${r===n.id?` on`:``}`,"aria-current":r===n.id?`true`:void 0,onClick:()=>e.onSelect(t.id,n.id),children:[V(`span`,{class:`source-label`,children:n.label}),V(`span`,{class:`count`,children:n.count})]}),n.children&&n.children.length>0&&V(`ul`,{class:`sources nested`,children:n.children.map(n=>V(yi,{project:t,source:n,selected:r,onSelect:e.onSelect},n.id))})]})}function bi(e){return V(`nav`,{class:`sidebar`,"aria-label":`Projects`,children:[V(`div`,{class:`sidebar-head`,children:V(`span`,{class:`brand`,children:`BMAD Kanban`})}),V(vi,{onAdded:e.onAdded}),V(`ul`,{class:`projects`,children:e.projects.map(t=>{let n=t.id===e.selectedId;return V(`li`,{class:`project${n?` on`:``}${t.missing?` missing`:``}`,children:[V(`div`,{class:`project-row`,children:[V(`button`,{type:`button`,class:`project-btn`,"aria-current":n?`true`:void 0,title:t.path,onClick:()=>e.onSelectProject(t.id),children:[V(`span`,{class:`project-name`,children:t.name}),t.tags.map(e=>V(`span`,{class:`tag`,children:e},e))]}),V(`button`,{type:`button`,class:`icon-btn remove`,"aria-label":`Remove ${t.name} from the list`,title:`Remove from list`,onClick:()=>e.onRemove(t),children:`×`})]}),t.missing&&V(`div`,{class:`project-note`,children:`folder not found`}),t.error!==void 0&&V(`div`,{class:`project-note error`,title:t.error,children:[`config error: `,t.error]}),!t.missing&&_i(t)&&V(`ul`,{class:`sources`,children:t.sources.map(r=>V(yi,{project:t,source:r,selected:n?e.sourceId:null,onSelect:e.onSelectSource},r.id))})]},t.id)})}),e.projects.length===0&&V(`p`,{class:`muted empty`,children:`No projects yet.`})]})}function xi(e){let{board:t}=e,n=hi(e.showDropped),r=He(t,e.showDropped),i=mi(t);return V(`div`,{class:`lanes`,style:{gridTemplateColumns:`minmax(140px, 180px) repeat(${n.length}, minmax(140px, 1fr))`},children:[V(`div`,{class:`lane-corner`}),n.map(e=>V(`h3`,{class:`col-head`,children:ze[e]},e)),r.map(r=>{let a=r.epic?i.get(r.epic.id):void 0,o=r.total===0?0:Math.round(r.done/r.total*100);return[V(`div`,{class:`lane-head`,style:{borderLeftColor:a?We(a.index):`var(--muted)`},children:[V(`div`,{class:`lane-title`,children:r.epic?V(v,{children:[r.epic.id,` `,r.epic.title]}):`No epic`}),V(`div`,{class:`lane-meta`,children:[r.epic?.status&&V(`span`,{children:r.epic.status}),r.epic?.retrospective===`done`&&V(`span`,{class:`retro-tag`,children:`✓ retro`}),V(`span`,{children:[r.done,`/`,r.total,` done`]})]}),V(`div`,{class:`bar`,role:`progressbar`,"aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${r.done} of ${r.total} done`,children:V(`i`,{style:{width:`${o}%`}})})]},`h-${r.epic?.id??`-`}`),...n.map(n=>V(`div`,{class:`cell`,children:r.cells[n].map(n=>V(Xe,{story:n,showEpic:!1,epic:a??null,onOpen:n=>e.onOpen(n,t.sourceId)},n.key))},`${r.epic?.id??`-`}-${n}`))]})]})}var Si=e=>e.flatMap(e=>[e,...Si(e.children??[])]);function Ci(e,t){let n=new Set(Si(e.sources).map(e=>e.id));for(let r of[t,e.prefs?.sourceId,e.defaultSourceId])if(r&&n.has(r))return r;return e.sources[0]?.id??null}var wi=e=>e.children&&e.children.length>0?e.children:[e],Ti=e=>[e,...e.children??[]].some(e=>e.stories.some(e=>e.column===`dropped`)),Ei=e=>e instanceof Error?e.message:String(e);function Di(e){let{board:t,view:n}=e,r=t=>V(v,{children:[t.notices.map((e,t)=>V(`div`,{class:`notice ${e.level}`,role:e.level===`error`?`alert`:void 0,children:e.text},t)),t.stories.length===0?V(`p`,{class:`muted empty`,children:`No stories in this board yet.`}):n===`columns`?V(gi,{board:t,showDropped:e.showDropped,epicFilter:e.epicFilter,onOpen:e.onOpen}):V(xi,{board:t,showDropped:e.showDropped,onOpen:e.onOpen})]});return!t.children||t.children.length===0?r(t):V(v,{children:[t.notices.map((e,t)=>V(`div`,{class:`notice ${e.level}`,children:e.text},t)),t.children.map(e=>V(`section`,{class:`child-board`,"aria-label":e.label,children:[V(`h2`,{class:`child-title`,children:e.label}),r(e)]},e.sourceId))]})}function Oi(){let[e,t]=R(null),[n,r]=R(null),[i,a]=R(null),[o,s]=R(null),[c,l]=R(`columns`),[u,d]=R(!1),[f,p]=R(null),[m,h]=R(null),[g,_]=R(0),[y,b]=R(null),x=z(null);x.current=i;let S=z(!1),C=e?.find(e=>e.id===i)??null,ee=xe(()=>b(null),[]),w=xe((e,t)=>{a(e.id),s(Ci(e,t)),l(e.prefs?.view??`columns`),d(e.prefs?.showDropped??!1),p(null),b(null);let n=new URL(location.href);n.searchParams.set(`project`,e.id),history.replaceState(null,``,n),Le.setLastViewed(e.id).catch(()=>{})},[]),T=xe((e,n)=>{t(t=>t&&t.map(t=>t.id===e?{...t,prefs:{...t.prefs??{view:`columns`,showDropped:!1,sourceId:null},...n}}:t)),Le.setPrefs(e,n).catch(()=>{})},[]),E=xe(async()=>{try{let e=await Le.projects();t(e),r(null);let n=e.find(e=>e.id===x.current);S.current&&(n?s(e=>Ci(n,e)):e.length>0?w(e[0]):(a(null),s(null)))}catch(e){r(Ei(e))}},[w]);ye(()=>{(async()=>{try{let[e,n]=await Promise.all([Le.projects(),Le.state().catch(()=>({lastViewed:null}))]);t(e);let r=[new URLSearchParams(location.search).get(`project`),n.lastViewed].map(t=>e.find(e=>e.id===t)).find(e=>e!==void 0)??e[0];S.current=!0,r&&w(r)}catch(e){S.current=!0,r(Ei(e))}})()},[w]),ye(()=>{let e=new EventSource(`/api/events`);e.addEventListener(`change`,e=>{try{let{projectId:t}=JSON.parse(e.data);if(t!==x.current)return}catch{return}_(e=>e+1),E()}),e.addEventListener(`projects`,()=>void E());let t=!1;return e.addEventListener(`open`,()=>{t&&(_(e=>e+1),E()),t=!0}),()=>e.close()},[E]);let D=C?.missing??!1,O=i&&o?`${i}\u0000${o}`:null;ye(()=>{if(!i||!o||!O||D)return;let e=!0;return Le.board(i,o).then(t=>e&&h({key:O,board:t,error:null}),t=>{e&&(t instanceof Ae&&t.status===410&&E(),h({key:O,board:null,error:Ei(t)}))}),()=>{e=!1}},[i,o,O,D,g,E]);let k=m!==null&&m.key===O?m:null,A=k?.board??null,te=k?.error??null,ne=t=>{let n=e?.find(e=>e.id===t);n&&t!==i&&w(n)},re=(t,n)=>{let r=e?.find(e=>e.id===t);r&&(t===i?(s(n),p(null)):w(r,n),T(t,{sourceId:n}))},ie=e=>{t(t=>t?[...t.filter(t=>t.id!==e.id),e]:[e]),w(e)},j=async e=>{if(confirm(`Remove "${e.name}" from the list? The folder is not touched.`)){try{await Le.removeProject(e.id)}catch{}await E()}},ae=e=>{l(e),i&&T(i,{view:e})},oe=e=>{d(e),i&&T(i,{showDropped:e})},se=A?wi(A):[],M=[],N=new Set;for(let e of se)e.epics.forEach((e,t)=>{N.has(e.id)||(N.add(e.id),M.push({epic:e,index:t}))});let P=f!==null&&N.has(f)?f:null,ce=A?Ti(A):!1,le=C?Si(C.sources).find(e=>e.id===o):void 0;return V(`div`,{class:`app`,children:[V(bi,{projects:e??[],selectedId:i,sourceId:o,onSelectProject:ne,onSelectSource:re,onAdded:ie,onRemove:j}),V(`main`,{class:`main`,children:[n!==null&&V(`div`,{class:`notice error`,role:`alert`,children:[`Could not reach the server: `,n]}),e!==null&&e.length===0&&V(`div`,{class:`placeholder`,children:[V(`h1`,{children:`No projects yet`}),V(`p`,{children:[`Add a BMAD project folder with “+ Add project”, or run `,V(`code`,{children:`npx bmad-kanban`}),` inside one.`]})]}),C&&V(v,{children:[V(`header`,{class:`board-head`,children:[V(`h1`,{class:`board-title`,children:[C.name,(A?.label??le?.label)&&V(`span`,{class:`board-source`,children:[` / `,A?.label??le?.label]})]}),!C.missing&&A&&V(`div`,{class:`controls`,children:[V(`div`,{class:`toggle`,role:`group`,"aria-label":`Board view`,children:[V(`button`,{type:`button`,"aria-pressed":c===`columns`,class:c===`columns`?`on`:``,onClick:()=>ae(`columns`),children:`Columns`}),V(`button`,{type:`button`,"aria-pressed":c===`swimlanes`,class:c===`swimlanes`?`on`:``,onClick:()=>ae(`swimlanes`),children:`Swimlanes`})]}),ce&&V(`label`,{class:`switch`,children:[V(`input`,{type:`checkbox`,checked:u,onChange:e=>oe(e.target.checked)}),V(`span`,{children:`Show dropped`})]})]})]}),c===`columns`&&A&&M.length>0&&V(`div`,{class:`filters`,role:`group`,"aria-label":`Filter by epic`,children:[V(`span`,{class:`filters-label`,children:`Epics:`}),V(`button`,{type:`button`,class:`filter${P===null?` on`:``}`,"aria-pressed":P===null,onClick:()=>p(null),children:`All`}),M.map(e=>V(`button`,{type:`button`,class:`filter${P===e.epic.id?` on`:``}`,"aria-pressed":P===e.epic.id,onClick:()=>p(e.epic.id),children:[V(qe,{info:e}),` `,e.epic.title]},e.epic.id))]}),V(`div`,{class:`board`,children:C.missing?V(`div`,{class:`placeholder`,children:[V(`h2`,{children:`Folder not found`}),V(`p`,{children:[V(`code`,{children:C.path}),` no longer exists.`]})]}):C.error!==void 0&&C.sources.length===0?V(`div`,{class:`notice error`,children:[`Could not read this project's BMAD config: `,C.error]}):o===null?V(`p`,{class:`muted empty`,children:`No boards found in this project yet.`}):te===null?A===null?V(`p`,{class:`muted empty`,children:`Loading…`}):V(Di,{board:A,view:c,showDropped:u&&ce,epicFilter:P,onOpen:(e,t)=>b({story:e,sourceId:t})}):V(`div`,{class:`notice error`,role:`alert`,children:te})})]})]}),y&&C&&V(pi,{projectId:C.id,sourceId:y.sourceId,story:y.story,onClose:ee})]})}se(V(Oi,{}),document.getElementById(`app`));
|
package/dist/web/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<meta name="color-scheme" content="light dark" />
|
|
7
7
|
<title>BMAD Kanban</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-CXy4n_jL.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-ivqvYtzo.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bmad-kanban",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Read-only local Kanban board for BMAD Method projects (v6 and v7 layouts)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\" && tsc -p . && vite build",
|
|
17
|
+
"build": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\" && tsc -p . && node -e \"fs.chmodSync('dist/cli.js',0o755)\" && vite build",
|
|
18
18
|
"test": "vitest run",
|
|
19
19
|
"test:e2e": "playwright test",
|
|
20
20
|
"typecheck": "tsc -p . --noEmit && tsc -p web",
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e,t,n,r,i,a,o,s,c,l,u={},d=[],f=/^m(i|n|o|s|text|space)$/,p=Array.isArray,m=d.slice,h=Object.assign;function g(e){e&&e.parentNode&&e.remove()}function _(n,r,i,a,o){var s={type:n,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o||++t,__i:-1,__u:0};return!o&&e.vnode&&e.vnode(s),s}function v(e){return e.children}function y(e,t){this.props=e,this.context=t,this.__g=0}function b(e,t){if(t==null)return e.__&&b(e.__,e.__i+1);for(var n;t<e.__k.length;t++)if((n=e.__k[t])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:b(e)}function x(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),x(e)}function S(t){(8&t.__g||(t.__g|=8,n.push(t),i++))&&r==e.debounceRendering||((r=e.debounceRendering)||queueMicrotask)(C)}function C(){var t,o,s,c,l,u,d,f,p;try{for(o=1;n.length;)n.length>o&&n.sort(a),t=n.shift(),o=n.length,8&t.__g&&(c=void 0,l=void 0,u=(l=(s=t).__v).__e,d=[],f=[],(p=s.__P)&&((c=h({constructor:void 0},l)).__v=l.__v+1,e.vnode&&e.vnode(c),A(p,c,l,s.__n,p.namespaceURI,32&l.__u?[u]:null,d,u||b(l),32&l.__u,f),c.__v=l.__v,c.__.__k[c.__i]=c,re(d,c,f),l.__=l.__e=null,c.__e!=u&&x(c)))}finally{(i=n.length)&&(r||queueMicrotask)(C)}}function ee(e,t,n,r,i,a,o,s,c,l,f){var p,m,h,g,_,v,y=r.__k||d,b=t.length;for(c=w(n,t,y,c,b),p=0;p<b;p++)(h=n.__k[p])!=null&&(m=~h.__i&&y[h.__i]||u,h.__i=p,v=A(e,h,m,i,a,o,s,c,l,f),g=h.__e,(m.ref!=h.ref||8&m.__u)&&(m.ref&&j(m.ref,null,h,m),h.ref&&f.push(h.ref,h.__c||g,h)),_||=g,4&h.__u?(c=T(h,c,e,!m.__v),m.__e&&(m.__e=null)):typeof h.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),h.__u&=-21);return n.__e=_,c}function w(e,t,n,r,i){var a,o,s,c,l,u,d,f,m,h=n.length,g=h,y=0,x=0,S=e.__k=Array(i);for(a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o!=`object`||o.constructor==String?o=S[a]=_(null,o):p(o)?o=S[a]=_(v,{children:o}):o.constructor===void 0&&o.__b?o=S[a]=_(o.type,o.props,o.key,o.ref,o.__v):S[a]=o,c=a+y,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=E(o,n,c,g))&&(g--,(s=n[l])&&(s.__u|=2)),s&&s.__v?(o.__u|=16,l==c-1?y--:l==c+1?y++:l!=c&&(l>c?y--:y++,x=1)):(~l||(i>h?y--:i<h&&y++),typeof o.type!=`function`&&(o.__u|=4))):S[a]=null;if(x){for(u=[],d=[],a=0;a<i;a++)if((o=S[a])&&16&o.__u){for(y=0,f=u.length;y<f;)u[m=y+f>>1]<o.__i?y=m+1:f=m;u[y]=o.__i,d[a]=y+1}for(y=u.length;a--;)d[a]&&(d[a]==y?y--:S[a].__u|=4)}if(g)for(a=0;a<h;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=b(s)),ae(s,s));return r}function T(e,t,n,r){var i,a,o,s;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=T(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=b(e))&&!t.parentNode&&(t=null),o=e.__e,s=t;s&&s.nodeType==8;)s=s.nextSibling;for(o!=s&&(!r&&n.moveBefore&&o.parentNode?n.moveBefore(o,t):n.insertBefore(o,t||null)),t=o;(t&&=t.nextSibling)&&t.nodeType==8&&!t.data.startsWith(`$s`););return t}function E(e,t,n,r){var i,a=e.key,o=e.type,s=t[n],c=s&&!(2&s.__u);if(s===null&&a==null||c&&a==s.key&&o==s.type)return n;if(r>+!!c){for(i=n-1;i>=0;i--)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i;for(i=n+1;i<t.length;i++)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i}return-1}function D(e,t,n){n??=``,t[0]==`-`?e.setProperty(t,n):e[t]=n}function O(e,t,n,r,i){var a,o;if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||D(e.style,t);if(n)for(t in n)r&&n[t]==r[t]||D(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)(e.__e||={})[t]=n,n&&r||(o=l[t]||(l[t]=k(t)),(e.__a||={})[t]=c,a=t!=(t=t.replace(s,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),n?e.addEventListener(t,o,a):e.removeEventListener(t,o,a));else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;return}catch{}if(typeof n==`function`)return;n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n)}}function k(t){return function(n){var r=this.__e;if(r){if(r=r[t],n[o]==null)n[o]=c++;else if(n[o]<this.__a[t])return;return r(e.event?e.event(n):n)}}}function A(t,n,r,i,a,o,s,c,l,u){var f,m,_,x,S,C,w,T,E,D,O,k,A,re,j,se,M,N,P=n.type;if(n.constructor!==void 0)return null;128&r.__u&&(l=32&r.__u,f=r.__c.__z)&&(n.__u|=l,m=o=[],f.nodeType==8?c=te(f,o):o.push(f),c=o[0]||c),(f=e.__b)&&f(n);n:if(typeof P==`function`){_=s.length;try{if(T=n.props,E=(f=P.prototype)&&f.render,D=(f=P.contextType)&&i[f.__c],O=f?D?D.props.value:f.__:i,(x=r.__c)?(n.__c=x,2&x.__g&&(x.__g|=1)):(E?n.__c=x=new P(T,O):(n.__c=x=new y(T,O),x.constructor=P,x.render=oe),D&&D.sub(x),x.state||(x.state={}),x.__n=i,x.__g|=8,x.__h=[],x.__k=[]),E&&(x.__s||(x.__s=x.state),P.getDerivedStateFromProps&&(x.__s==x.state&&(x.__s=h({},x.__s)),h(x.__s,P.getDerivedStateFromProps(T,x.__s)))),S=x.props,C=x.state,x.__v=n,r.__c){if(T!==S&&E&&!P.getDerivedStateFromProps&&x.componentWillReceiveProps&&x.componentWillReceiveProps(T,O),n.__v==r.__v&&!(8&x.__g)||!(4&x.__g)&&x.shouldComponentUpdate&&!1===x.shouldComponentUpdate(T,x.__s,O)){n.__v!=r.__v&&(x.props=T,x.state=x.__s,x.__g&=-9),n.__e=r.__e,n.__k=r.__k,n.__k.some(function(e){e&&(e.__=n)}),d.push.apply(x.__h,x.__k),x.__k=[],x.__h.length&&s.push(x),c=b(r);break n}x.componentWillUpdate&&x.componentWillUpdate(T,x.__s,O),E&&x.componentDidUpdate&&x.__h.push(function(){x.componentDidUpdate(S,C,w)})}else E&&!P.getDerivedStateFromProps&&x.componentWillMount&&x.componentWillMount(),E&&x.componentDidMount&&x.__h.push(x.componentDidMount);if(x.context=O,x.props=T,x.__P=t,x.__g&=-5,k=e.__r,A=0,E)x.state=x.__s,x.__g&=-9,k&&k(n),f=x.render(x.props,x.state,x.context),d.push.apply(x.__h,x.__k),x.__k=[];else do x.__g&=-9,k&&k(n),f=x.render(x.props,x.state,x.context),x.state=x.__s;while(8&x.__g&&++A<25);x.state=x.__s,x.getChildContext&&(i=h({},i,x.getChildContext())),E&&r.__c&&x.getSnapshotBeforeUpdate&&(w=x.getSnapshotBeforeUpdate(S,C)),re=f&&f.type===v&&f.key==null?f.props.children:f,T.__P&&(f=c,a=(t=T.__P).namespaceURI,l=o=null,r.props&&r.props.__P!=t&&(r.__k.some(function(e){e&&ae(e,e)}),r.__k=null),c=r.__k?b(r,0):null),c=ee(t,p(re)?re:[re],n,r,i,a,o,s,c,l,u),T.__P&&(n.__e=null,c=f),n.__u&=-161,m&&m.some(g),x.__h.length&&s.push(x),1&x.__g&&(x.__g&=-4)}catch(t){if(s.length=_,n.__v=null,l||o){if(t.then){if(j=0,n.__u|=128|l,o){for(~(M=o.indexOf(c||void 0))||(M=o.length);(N=o[M-1])&&N.nodeType==8;)M--;for(;M<o.length;M++)if(N=o[M]){if(o[M]=null,N.nodeType==8){if(N.data.startsWith(`$s`))j++||(se=N);else if(j&&N.data.startsWith(`/$s`)&&!--j)break}else if(!j)break}}if(!se){for(;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;se=c}(f=te(se=n.__c.__z||(n.__c.__z=se)))?(n.__e=se,c=f):n.__e=c,c&&=c.nextSibling}else o&&o.some(g)}else n.__e=r.__e;n.__k||=r.__k||[],t.then||ne(n),e.__e(t,n,r)}}else c=n.__e=ie(r.__e,n,r,i,a,o,s,l,u,t);return(f=e.diffed)&&f(n),c}function te(e,t){if(e&&e.nodeType==8&&e.data.startsWith(`$s`))for(var n=1;e=e.nextSibling;){if(e.nodeType==8){if(e.data.startsWith(`$s`))n++;else if(e.data.startsWith(`/$s`)&&!--n)return e}t&&t.push(e)}}function ne(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(ne))}function re(t,n,r){for(var i=0;i<r.length;)j(r[i++],r[i++],r[i++]);e.__c&&e.__c(n,t),t.some(function(n){try{t=n.__h,n.__h=[],t.some(function(e){e.call(n)})}catch(t){e.__e(t,n.__v)}})}function ie(t,n,r,i,a,o,s,c,l,d){var h,_,v,y,x,S,C,w,T,E=r.props||u,D=n.props,k=n.type;if(k==`svg`?a=`http://www.w3.org/2000/svg`:k==`math`?a=`http://www.w3.org/1998/Math/MathML`:a||=`http://www.w3.org/1999/xhtml`,o){for(h=0;h<o.length;h++)if((x=o[h])&&(k?x.localName==k:x.nodeType==3)){t=x,o[h]=null;break}}if(!t){if(w=d.ownerDocument||document,!k)return w.createTextNode(D);t=w.createElementNS(a,k,D.is&&D),c&&=(e.__m&&e.__m(n,o),!1),o=null}if(k){if(d=k==`template`?t.content:t,o=k==`textarea`&&D.defaultValue!=null?null:o&&m.call(d.childNodes),!c&&o)for(E={},h=0;h<t.attributes.length;h++)E[(x=t.attributes[h]).name]=x.value;for(h in E)x=E[h],h==`dangerouslySetInnerHTML`?v=x:h==`children`||h in D||h==`value`&&`defaultValue`in D||h==`checked`&&`defaultChecked`in D||O(t,h,null,x,a);for(h in T=1&r.__u,D)x=D[h],h==`children`?y=x:h==`dangerouslySetInnerHTML`?_=x:h==`value`?S=x:h==`checked`?C=x:c&&typeof x!=`function`||!(E[h]!==x||T&&x!=null)||O(t,h,x,E[h],a);_?(c||v&&(_.__html==v.__html||_.__html==t.innerHTML)||(t.innerHTML=_.__html),n.__k=[]):(v&&(t.textContent=``),(k==`foreignObject`||a==`http://www.w3.org/1998/Math/MathML`&&f.test(k))&&(a=`http://www.w3.org/1999/xhtml`),ee(d,p(y)?y:[y],n,r,i,a,o,s,o?o[0]:r.__k&&b(r,0),c,l),o&&o.some(g)),c&&k!=`textarea`||(h=`value`,k==`progress`&&S==null?t.removeAttribute(h):S==null||S===t[h]&&(k!=`progress`||S)||O(t,h,S,E[h],a),h=`checked`,C!=null&&C!=t[h]&&O(t,h,C,E[h],a))}else E===D||c&&t.data==D||(t.data=D);return t}function j(t,n,r,i){try{typeof t==`function`?n?n.__x=t(n)||1:(i&&=i.__c||i.__e)&&(n=i.__x)&&(i.__x=null,typeof n==`function`?n():t(null)):t.current=n}catch(t){e.__e(t,r)}}function ae(t,n,r){var i,a,o,s;if(e.unmount&&e.unmount(t),!(i=t.ref)||i.current&&i.current!=t.__e||j(i,null,n,t),i=t.__c){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(t){e.__e(t,n)}i.__P=i.__n=null}if(i=t.__k)for(s=0;s<i.length;s++)i[s]&&ae(i[s],n,typeof t.type!=`function`||r&&!t.props.__P);!r&&(i=t.__c)&&(i=i.__z)&&(a=te(i,o=[]))&&(i==t.__e&&o.some(g),g(a),g(i)),(i=t.__e)&&(r||g(i),i.__e&&(i.__e=null)),t.__e=t.__c=t.__=null}function oe(e,t,n){return this.constructor(e,n)}function se(t,n){var r,i,a,o;e.__&&e.__(t,n),n.nodeType==9&&(n=n.documentElement),i=(r=t&&32&t.__u)?null:n.__k,n.__k=_(v,{children:[t]}),a=[],o=[],A(n,n.__k,i||u,u,n.namespaceURI,i?null:n.firstChild?m.call(n.childNodes):null,a,i?i.__e:n.firstChild,r,o),re(a,n.__k,o),n.__k.props.children=null}e={__e:function(e,t,n,r){for(var a,o,s;t=t.__;)if((a=t.__c)&&!(1&a.__g)){a.__g|=4;try{if((s=(o=a.constructor)&&o.getDerivedStateFromError)&&a.setState(o.getDerivedStateFromError(e)),a.componentDidCatch&&(a.componentDidCatch(e,r||{}),s=1),s&&8&a.__g)return void(a.__g|=2)}catch(t){e=t}}throw i=0,e}},t=0,y.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=h({},this.state)),typeof e==`function`&&(e=e(h({},n),this.props)),e&&(h(n,e),this.__v&&(t&&this.__k.push(t),S(this)))},y.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),S(this))},y.prototype.render=v,n=[],i=0,a=function(e,t){return e.__v.__b-t.__v.__b},o=Symbol(),s=/(PointerCapture)$|Capture$/i,c=0,l={};var M,N,P,ce,le=Object.is,ue=0,de=[],fe=[],F=e,pe=F.__b,me=F.__r,he=F.diffed,I=F.__c,ge=F.unmount,L=F.__;function _e(e,t){F.__h&&F.__h(N,e,ue||t),ue=0;var n=N.__H||(N.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function R(e){return ue=1,ve(Ae,e)}function ve(e,t,n){var r=_e(M++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ae(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);le(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=N,!N.__f)){N.__f=!0;var i=N.shouldComponentUpdate;N.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,le(e.__[0],e.__N[0])||(o=!0))}),i){var s=i.call(this,e,t,n);return a?s||o:s}return!a||o}}return r.__}function ye(e,t){var n=_e(M++,3);!F.__s&&ke(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,N.__H.__h.push(n))}function be(e){return ue=5,xe(function(){return{current:e}},[])}function xe(e,t){var n=_e(M++,7);return ke(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function Se(e,t){return ue=8,xe(function(){return e},t)}function Ce(){var e;do{for(;e=fe.shift();)try{De(e)}catch(t){F.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=de.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(De),t.__h.some(Oe),t.__h=[]}catch(n){t.__h=[],F.__e(n,e.__v)}}}while(fe.length)}F.__b=function(e){N=null,pe&&pe(e)},F.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),L&&L(e,t)},F.__r=function(e){me&&me(e),M=0;var t=(N=e.__c).__H;t&&(P==N?N.__h=[]:(t.__h.some(De),t.__h.some(Oe),M=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),P=N},F.diffed=function(e){he&&he(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&Ee(de.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),P=N=null},F.__c=function(e,t){t.some(function(e){try{e.__h.some(De),e.__h=e.__h.filter(function(e){return!e.__||Oe(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],F.__e(n,e.__v)}}),I&&I(e,t)},F.unmount=function(e){ge&&ge(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n&&=n.__c}r.__P=n,Ee(fe.push(r))}else De(r)}catch(e){t=e}}),r.__H=void 0,t&&F.__e(t,r.__v))};var we=typeof requestAnimationFrame==`function`;function Te(e){var t,n=function(){clearTimeout(r),we&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);we&&(t=requestAnimationFrame(n))}function Ee(e){e!=1&&ce==F.requestAnimationFrame||((ce=F.requestAnimationFrame)||Te)(Ce)}function De(e){var t=N,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),N=t}function Oe(e){var t=N;e.__c=e.__(),N=t}function ke(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!le(t,e[n])})}function Ae(e,t){return typeof t==`function`?t(e):t}var je=class extends Error{status;constructor(e,t){super(t),this.status=e}},z=encodeURIComponent,Me={"Content-Type":`application/json`},Ne=`bmad-kanban-token`;function Pe(){let e=new URLSearchParams(location.hash.slice(1)).get(`token`);if(e!==null){history.replaceState(null,``,location.pathname+location.search);try{sessionStorage.setItem(Ne,e)}catch{}return e}try{return sessionStorage.getItem(Ne)??``}catch{return``}}var Fe=Pe(),Ie=`/api/events?token=${encodeURIComponent(Fe)}`;async function Le(e,t={}){let n=await fetch(e,{...t,headers:{...t.headers,Authorization:`Bearer ${Fe}`}});if(!n.ok){let e=`${n.status} ${n.statusText}`;try{let t=await n.json();typeof t.error==`string`&&(e=t.error)}catch{}throw new je(n.status,e)}return n.status===204?void 0:await n.json()}var Re=(e,t)=>({method:e,headers:Me,body:JSON.stringify(t)}),B={projects:()=>Le(`/api/projects`),addProject:e=>Le(`/api/projects`,Re(`POST`,{path:e})),removeProject:e=>Le(`/api/projects/${z(e)}`,{method:`DELETE`}),setPrefs:(e,t)=>Le(`/api/projects/${z(e)}/prefs`,Re(`PUT`,t)),board:(e,t)=>Le(`/api/projects/${z(e)}/boards/${z(t)}`),story:(e,t,n)=>Le(`/api/projects/${z(e)}/boards/${z(t)}/stories/${z(n)}`),state:()=>Le(`/api/state`),setLastViewed:e=>Le(`/api/state`,Re(`PUT`,{lastViewed:e}))},ze=[`backlog`,`ready`,`in-progress`,`review`,`done`,`dropped`],Be={backlog:`Backlog`,ready:`Ready`,"in-progress":`In progress`,review:`Review`,done:`Done`,dropped:`Dropped`},Ve=()=>({backlog:[],ready:[],"in-progress":[],review:[],done:[],dropped:[]});function He(e,t,n){let r=Ve();for(let i of e)i.column===`dropped`&&!t||n!==null&&i.epicId!==n||r[i.column].push(i);return r}function Ue(e,t){let n=new Set(e.epics.map(e=>e.id)),r=(e,n)=>({epic:e,done:n.filter(e=>e.column===`done`).length,total:n.filter(e=>e.column!==`dropped`).length,cells:He(n,t,null)}),i=e.epics.map(t=>r(t,e.stories.filter(e=>e.epicId===t.id))),a=e.stories.filter(e=>e.epicId===null||!n.has(e.epicId));return a.filter(e=>t||e.column!==`dropped`).length>0&&i.push(r(null,a)),i}var We=[`#3b82f6`,`#a855f7`,`#f59e0b`,`#10b981`,`#ef4444`,`#06b6d4`,`#ec4899`,`#84cc16`];function Ge(e){let t=We.length;return We[(e%t+t)%t]}function Ke(e){let t=e.title.trim();return t===e.key?t:`${e.id} ${t}`}var qe=0;Array.isArray;function V(t,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l&&typeof t!=`function`)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:t,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--qe,__i:-1,__u:0};return(a||o)&&(u.__source=a,u.__self=o),e.vnode&&e.vnode(u),u}function Je({info:e}){let{epic:t,index:n}=e,r=t.retrospective===`done`;return V(`span`,{class:`chip`,style:{background:Ge(n)},title:`Epic ${t.id}: ${t.title}${r?` (retrospective done)`:``}`,children:[t.id,r&&V(`span`,{class:`retro`,"aria-label":`retrospective done`,children:`✓`})]})}function Ye(){return V(`svg`,{class:`card-file`,viewBox:`0 0 16 16`,width:`13`,height:`13`,role:`img`,"aria-label":`has story file`,children:[V(`title`,{children:`Has a story file`}),V(`path`,{d:`M4 1.5h5L12.5 5v9.5h-8.5z M9 1.5V5h3.5`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`,"stroke-linejoin":`round`})]})}function Xe({story:e}){let[t,n]=R(`idle`),r=be(void 0);ye(()=>()=>clearTimeout(r.current),[]);let i=async()=>{try{await navigator.clipboard.writeText(Ke(e)),n(`copied`)}catch{n(`failed`)}clearTimeout(r.current),r.current=setTimeout(()=>n(`idle`),1500)},a=t===`copied`?`Copied`:t===`failed`?`Copy failed`:`Copy`;return V(`button`,{type:`button`,class:`card-copy${t===`idle`?``:` ${t}`}`,onClick:i,"aria-label":`Copy title`,title:`Copy "${Ke(e)}"`,children:V(`span`,{"aria-live":`polite`,children:a})})}function Ze(e){let{story:t,epic:n}=e,r=`card${t.column===`dropped`?` dropped`:``}${t.noFile?` no-file`:``}`,i=V(v,{children:[V(`span`,{class:`card-top`,children:[e.showEpic&&n&&V(Je,{info:n}),V(`span`,{class:`card-id`,children:t.id}),!t.noFile&&V(Ye,{}),t.blocked&&V(`span`,{class:`badge blocked`,children:`blocked`}),(t.type===`spike`||t.type===`bug`)&&V(`span`,{class:`badge type-${t.type}`,children:t.type})]}),V(`span`,{class:`card-title`,children:t.title}),t.unknownStatus!==void 0&&V(`span`,{class:`badge unknown`,children:[`unknown status: `,t.unknownStatus]})]});return V(`div`,{class:`card-wrap`,children:[t.noFile?V(`div`,{class:r,children:i}):V(`button`,{type:`button`,class:r,onClick:()=>e.onOpen(t),children:i}),V(Xe,{story:t})]})}function Qe(e,t){this.v=e,this.k=t}function $e(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function et(e){if(Array.isArray(e))return e}function tt(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function nt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rt(e,t){return et(e)||tt(e,t)||it(e,t)||nt()}function it(e,t){if(e){if(typeof e==`string`)return $e(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$e(e,t):void 0}}function H(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof Qe;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}H.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},H.prototype.next=function(e){return this._invoke(`next`,e)},H.prototype.throw=function(e){return this._invoke(`throw`,e)},H.prototype.return=function(e){return this._invoke(`return`,e)};var at=Object.entries,ot=Object.setPrototypeOf,st=Object.isFrozen,ct=Object.getPrototypeOf,lt=Object.getOwnPropertyDescriptor,U=Object.freeze,W=Object.seal,ut=Object.create,dt=typeof Reflect<`u`&&Reflect,ft=dt.apply,pt=dt.construct;U||=function(e){return e},W||=function(e){return e},ft||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},pt||=function(e){return new e(...[...arguments].slice(1))};var mt=q(Array.prototype.forEach);Array.prototype.indexOf;var ht=q(Array.prototype.lastIndexOf),gt=q(Array.prototype.pop),_t=q(Array.prototype.push),vt=q(Array.prototype.slice),yt=q(Array.prototype.splice),bt=Array.isArray,xt=It(Set),St=q(Set.prototype.add),Ct=q(Set.prototype.has),wt=q(String.prototype.toLowerCase),Tt=q(String.prototype.toString),Et=q(String.prototype.match),Dt=q(String.prototype.replace),Ot=q(String.prototype.indexOf),kt=q(String.prototype.trim),At=q(Number.prototype.toString),jt=q(Boolean.prototype.toString),Mt=typeof BigInt>`u`?null:q(BigInt.prototype.toString),Nt=typeof Symbol>`u`?null:q(Symbol.prototype.toString),G=q(Object.prototype.hasOwnProperty),Pt=q(Object.prototype.toString),K=q(RegExp.prototype.test),Ft=It(TypeError);function q(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return ft(e,t,n)}}function It(e){return function(){return pt(e,[...arguments])}}function J(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:wt;if(ot&&ot(e,null),!bt(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(st(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Lt(e){for(let t=0;t<e.length;t++)G(e,t)||(e[t]=null);return e}function Rt(e){let t=ut(null);for(let r of at(e)){var n=rt(r,2);let i=n[0],a=n[1];G(e,i)&&(t[i]=bt(a)?Lt(a):a&&typeof a==`object`&&a.constructor===Object?Rt(a):a)}return t}function zt(e){switch(typeof e){case`string`:return e;case`number`:return At(e);case`boolean`:return jt(e);case`bigint`:return Mt?Mt(e):`0`;case`symbol`:return Nt?Nt(e):`Symbol()`;case`undefined`:return Pt(e);case`function`:case`object`:{if(e===null)return Pt(e);let t=e,n=Bt(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Pt(e)}return Pt(e)}default:return Pt(e)}}function Bt(e,t){for(;e!==null;){let n=lt(e,t);if(n){if(n.get)return q(n.get);if(typeof n.value==`function`)return q(n.value)}e=ct(e)}function n(){return null}return n}function Vt(e,t){for(;e!==null;){let n=lt(e,t);if(n)return n.get?q(n.get):null;e=ct(e)}return null}function Ht(e){try{return K(e,``),!0}catch{return!1}}var Ut=U(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Wt=U(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),Gt=U([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Kt=U([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),qt=U(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),Jt=U([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Yt=U([`#text`]),Xt=U(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Zt=U(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Qt=U(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),$t=U([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),en=W(/{{[\w\W]*|^[\w\W]*}}/g),tn=W(/<%[\w\W]*|^[\w\W]*%>/g),nn=W(/\${[\w\W]*/g),rn=W(/^data-[\-\w.\u00B7-\uFFFF]+$/),an=W(/^aria-[\-\w]+$/),on=W(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),sn=W(/^(?:\w+script|data):/i),cn=W(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ln=W(/^html$/i),un=W(/^[a-z][.\w]*(-[.\w]+)+$/i),dn=W(/<[/\w!]/g),fn=W(/<[/\w]/g),pn=W(/<\/no(script|embed|frames)/i),mn=W(/\/>/i),Y={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},hn=U(J({},[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`])),gn=function(){return typeof window>`u`?null:window},_n=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},vn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},yn=function(e,t,n,r){return G(e,t)&&bt(e[t])?J(r.base?Rt(r.base):{},e[t],r.transform):n},bn=function(e,t,n){let r=G(e,t)?e[t]:void 0;return r&&typeof r==`object`?Rt(r):n()};function xn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:gn(),t=e=>xn(e);if(t.version=`3.4.17`,t.removed=[],!e||!e.document||e.document.nodeType!==Y.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=Bt(d,`cloneNode`),p=Bt(d,`remove`),m=Bt(d,`removeAttributeNode`),h=Bt(d,`nextSibling`),g=Bt(d,`childNodes`),_=Bt(d,`parentNode`),v=Bt(d,`shadowRoot`),y=Bt(d,`attributes`),b=o&&o.prototype?Bt(o.prototype,`nodeType`):null,x=o&&o.prototype?Bt(o.prototype,`nodeName`):null,S=o&&o.prototype?Bt(o.prototype,`ownerDocument`):null,C=function(e){return b?b(e):e.nodeType},ee=function(e){return x?x(e):e.nodeName},w=Vt(d,`namespaceURI`),T=function(e){return w?w(e):e.namespaceURI};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let E,D=``,O,k=!1,A=0,te=function(){if(A>0)throw Ft(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},ne=function(e){te(),A++;try{return E.createHTML(e)}finally{A--}},re=function(e){te(),A++;try{return E.createScriptURL(e)}finally{A--}},ie=function(){return k||=(O=_n(u,i),!0),O},j=n,ae=j.implementation,oe=j.createNodeIterator,se=j.createDocumentFragment,M=j.getElementsByTagName,N=r.importNode,P=vn();t.isSupported=typeof at==`function`&&typeof _==`function`&&ae&&ae.createHTMLDocument!==void 0;let ce=en,le=tn,ue=nn,de=rn,fe=an,F=sn,pe=cn,me=un,he=on,I=null,ge=J({},[...Ut,...Wt,...Gt,...qt,...Yt]),L=null,_e=J({},[...Xt,...Zt,...Qt,...$t]),R=Object.seal(ut(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ve=null,ye=null,be=Object.seal(ut(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),xe=!0,Se=!0,Ce=!1,we=!0,Te=!1,Ee=!0,De=!1,Oe=!1,ke=null,Ae=null,je=!1,z=!1,Me=!1,Ne=!1,Pe=!0,Fe=!1,Ie=`user-content-`,Le=!0,Re=!1,B=null,ze={},Be=null,Ve=J({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),He=null,Ue=J({},[`audio`,`video`,`img`,`source`,`image`,`track`]),We=null,Ge=J({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ke=`http://www.w3.org/1998/Math/MathML`,qe=`http://www.w3.org/2000/svg`,V=`http://www.w3.org/1999/xhtml`,Je=V,Ye=!1,Xe=null,Ze=J({},[Ke,qe,V],Tt),Qe=U([`mi`,`mo`,`mn`,`ms`,`mtext`]),$e=J({},Qe),et=U([`annotation-xml`]),tt=J({},et),nt=J({},[`title`,`style`,`font`,`a`,`script`]),rt=null,it=[`application/xhtml+xml`,`text/html`],H=null,ot=null,st=n.createElement(`form`),ct=function(e){return e instanceof RegExp||e instanceof Function},lt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ot&&ot===e)return;e&&typeof e==`object`||(e={}),e=Rt(e),rt=it.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,H=rt===`application/xhtml+xml`?Tt:wt,I=yn(e,`ALLOWED_TAGS`,ge,{transform:H}),L=yn(e,`ALLOWED_ATTR`,_e,{transform:H}),Xe=yn(e,`ALLOWED_NAMESPACES`,Ze,{transform:Tt}),We=yn(e,`ADD_URI_SAFE_ATTR`,Ge,{transform:H,base:Ge}),He=yn(e,`ADD_DATA_URI_TAGS`,Ue,{transform:H,base:Ue}),Be=yn(e,`FORBID_CONTENTS`,Ve,{transform:H}),ve=yn(e,`FORBID_TAGS`,Rt({}),{transform:H}),ye=yn(e,`FORBID_ATTR`,Rt({}),{transform:H}),ze=G(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Rt(e.USE_PROFILES):e.USE_PROFILES:!1,xe=e.ALLOW_ARIA_ATTR!==!1,Se=e.ALLOW_DATA_ATTR!==!1,Ce=e.ALLOW_UNKNOWN_PROTOCOLS||!1,we=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Te=e.SAFE_FOR_TEMPLATES||!1,Ee=e.SAFE_FOR_XML!==!1,De=e.WHOLE_DOCUMENT||!1,z=e.RETURN_DOM||!1,Me=e.RETURN_DOM_FRAGMENT||!1,Ne=e.RETURN_TRUSTED_TYPE||!1,je=e.FORCE_BODY||!1,Pe=e.SANITIZE_DOM!==!1,Fe=e.SANITIZE_NAMED_PROPS||!1,Le=e.KEEP_CONTENT!==!1,Re=e.IN_PLACE||!1,he=Ht(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:on,Je=typeof e.NAMESPACE==`string`?e.NAMESPACE:V,$e=bn(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>J({},Qe)),tt=bn(e,`HTML_INTEGRATION_POINTS`,()=>J({},et));let t=bn(e,`CUSTOM_ELEMENT_HANDLING`,()=>ut(null));if(R=ut(null),G(t,`tagNameCheck`)&&ct(t.tagNameCheck)&&(R.tagNameCheck=t.tagNameCheck),G(t,`attributeNameCheck`)&&ct(t.attributeNameCheck)&&(R.attributeNameCheck=t.attributeNameCheck),G(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(R.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),W(R),Te&&(Se=!1),Me&&(z=!0),ze&&(I=J({},Yt),L=ut(null),ze.html===!0&&(J(I,Ut),J(L,Xt)),ze.svg===!0&&(J(I,Wt),J(L,Zt),J(L,$t)),ze.svgFilters===!0&&(J(I,Gt),J(L,Zt),J(L,$t)),ze.mathMl===!0&&(J(I,qt),J(L,Qt),J(L,$t))),be.tagCheck=null,be.attributeCheck=null,G(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?be.tagCheck=e.ADD_TAGS:bt(e.ADD_TAGS)&&(I===ge&&(I=Rt(I)),J(I,e.ADD_TAGS,H))),G(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?be.attributeCheck=e.ADD_ATTR:bt(e.ADD_ATTR)&&(L===_e&&(L=Rt(L)),J(L,e.ADD_ATTR,H))),G(e,`ADD_FORBID_CONTENTS`)&&bt(e.ADD_FORBID_CONTENTS)&&(Be===Ve&&(Be=Rt(Be)),J(Be,e.ADD_FORBID_CONTENTS,H)),Le&&(I[`#text`]=!0),De&&J(I,[`html`,`head`,`body`]),I.table&&(J(I,[`tbody`]),delete ve.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Ft(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Ft(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=E;E=e.TRUSTED_TYPES_POLICY;try{D=ne(``)}catch(e){throw E=t,e}}else e.TRUSTED_TYPES_POLICY===null?(E=void 0,D=``):(E===void 0&&(E=ie()),E&&typeof D==`string`&&(D=ne(``)));U&&U(e),ot=e},dt=J({},[...Wt,...Gt,...Kt]),ft=J({},[...qt,...Jt]),pt=function(e,t,n){return t.namespaceURI===V?e===`svg`:t.namespaceURI===Ke?e===`svg`&&(n===`annotation-xml`||$e[n]):!!dt[e]},At=function(e,t,n){return t.namespaceURI===V?e===`math`:t.namespaceURI===qe?e===`math`&&tt[n]:!!ft[e]},jt=function(e,t,n){return t.namespaceURI===qe&&!tt[n]||t.namespaceURI===Ke&&!$e[n]?!1:!ft[e]&&(nt[e]||!dt[e])},Mt=function(e){let t=T(e),n=wt(ee(e)),r=_(e),i,a;return r&&C(r)===Y.element?(i={namespaceURI:T(r)},a=wt(ee(r))):(i={namespaceURI:Je},a=`template`),Xe[t]?t===qe?pt(n,i,a):t===Ke?At(n,i,a):t===V?jt(n,i,a):!!(rt===`application/xhtml+xml`&&Xe[t]):!1},Nt=function(e){_t(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw Ft(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},Pt=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},q=function(e){Cn(e);let t=g(e);t&&mt(vt(t),e=>{try{p(e)}catch{}});let n=C(e)===Y.element?y(e):null;if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&Pt(e,r,i)}},It=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}_t(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(z||Me)try{Nt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},Lt=function(e){let t=y(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||L[H(i)]||Pt(e,r,i)}},Sn=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=[e];for(;r.length>0;){let e=r.pop();if(t(e)===!1)continue;if(n&&C(e)===Y.element){let t=v(e);In(t)&&r.push(t)}let i=g(e);if(i)for(let e=i.length-1;e>=0;--e)r.push(i[e])}},Cn=function(e){Sn(e,e=>{C(e)===Y.element&&Lt(e)})},wn=function(e){let t=[];return Sn(e,e=>{t.push(e)},!0),t},Tn=function(e,t){let n=xt();mt(wn(e),e=>{C(e)===Y.element&&St(n,e)}),mt(t,e=>{C(e)===Y.element&&!Ct(n,e)&&Lt(e)})},En=function(e,n){let r=!1;return mt(t.removed,t=>{t.element&&(r||=t.element===e,Cn(t.element))}),Tn(e,n),r},Dn=function(e,t){let n=B,r=null,i=()=>(r||(r=xt(),mt(t,e=>{St(r,e)})),r);for(let t=0;;t++){let r=wn(e),a=[e],o=!1;if(mt(r,e=>{C(e)===Y.documentFragment?_t(a,e):!o&&!Ct(n,e)&&(o=Ct(i(),e))}),!o)return;if(t>=8)throw Ft(`the tree kept changing during in-place sanitization; refusing to return it`);mt(a,(t,n)=>{X(t,n>0,e,i())})}},X=function(e,t,n,r){let i=jn(e),a;for(;a=i.nextNode();)Ct(r,a)&&!Ct(B,a)&&(t&&Q(P.uponSanitizeShadowNode,a,null),Un(a,n),Xn(a,n),In(a.content)&&Zn(a.content))},On=function(e){B&&St(B,e)},Z=function(e,t){return Ee?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},kn=function(e){Ee&&Sn(e,e=>{let t=C(e);if(t===Y.processingInstruction||t===Y.comment&&K(fn,e.data)){try{p(e)}catch{}return!1}if(t===Y.element){let t=e,n=H(ee(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Z(`for`,n)&&t.removeAttribute(`for`)}catch{}}return!0})},An=function(e){let t=null,r=null;if(je)e=`<remove></remove>`+e;else{let t=Et(e,/^[\r\n\t ]+/);r=t&&t[0]}rt===`application/xhtml+xml`&&Je===V&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=E?ne(e):e;if(Je===V)try{t=new l().parseFromString(i,rt)}catch{}if(!t||!t.documentElement){t=ae.createDocument(Je,`template`,null);try{t.documentElement.innerHTML=Ye?D:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Je===V?M.call(t,De?`html`:`body`)[0]:De?t.documentElement:a},jn=function(e){let t=S?S(e):e.ownerDocument;return oe.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Mn=function(e){return e=Dt(e,ce,` `),e=Dt(e,le,` `),e=Dt(e,ue,` `),e},Nn=function(e){Pn(e);let t=e.querySelectorAll?.call(e,`template`);t&&mt(t,e=>{In(e.content)&&Nn(e.content)})},Pn=function(e){e.normalize();let t=S?S(e):e.ownerDocument,n=oe.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=Mn(r.data),r=n.nextNode()},Fn=function(e){let t=x?x(e):null;return typeof t!=`string`||H(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==y(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==b(e)||e.childNodes!==g(e)},In=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return b(e)===Y.documentFragment}catch{return!1}},Ln=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return typeof b(e)==`number`}catch{return!1}};function Q(e,n,r){e.length!==0&&mt(e,e=>{e.call(t,n,r,ot)})}let Rn=function(e,t){return!!(Ee&&e.hasChildNodes()&&!Ln(e.firstElementChild)&&K(dn,e.textContent)&&K(dn,e.innerHTML)||Ee&&hn[t]&&C(e)===Y.element&&T(e)===V&&(Ln(e.firstElementChild)||typeof e.textContent==`string`&&K(dn,e.textContent))||e.nodeType===Y.processingInstruction||Ee&&e.nodeType===Y.comment&&K(fn,e.data))},zn=function(e,t){return e instanceof RegExp?K(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Bn=function(e,t,n){if(!ve[t]&&Kn(t)&&zn(R.tagNameCheck,t))return!1;if(Le&&!Be[t]&&!Be[wt(t)]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,h(e))}}}return Nt(e),!0},Vn=function(e,t,n,r){return e.length===0?t:t===n||t===r?Rt(t):t},Hn=function(e,t){return e===t||_(e)!==null?!1:(Re&&Cn(e),!0)},Un=function(e,n){if(On(e),Q(P.beforeSanitizeElements,e,null),Hn(e,n))return!0;if(Fn(e))return Nt(e),!0;let r=H(ee(e));if(I=Vn(P.uponSanitizeElement,I,ge,ke),Q(P.uponSanitizeElement,e,{tagName:r,allowedTags:I}),Hn(e,n))return!0;if(Rn(e,r))return Nt(e),!0;if(ve[r]||!(be.tagCheck instanceof Function&&be.tagCheck(r))&&!I[r]){let t=Bn(e,r,n);return t===!1&&(Q(P.afterSanitizeElements,e,null),Hn(e,n))?!0:t}if(C(e)===Y.element&&!Mt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&K(pn,e.innerHTML))return Nt(e),!0;if(Te&&e.nodeType===Y.text){let n=Mn(e.textContent);e.textContent!==n&&(_t(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Q(P.afterSanitizeElements,e,null),Hn(e,n)},Wn=function(e,t,r){if(ye[t]||Z(t,e)||Pe&&(t===`id`||t===`name`)&&(r in n||r in st))return!1;let i=L[t]||be.attributeCheck instanceof Function&&be.attributeCheck(t,e);return Se&&K(de,t)||xe&&K(fe,t)?!0:i?We[t]||K(he,Dt(r,pe,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Ot(r,`data:`)===0&&He[e]||Ce&&!K(F,Dt(r,pe,``))?!0:!r:Kn(e)&&zn(R.tagNameCheck,e)&&zn(R.attributeNameCheck,t,e)||t===`is`&&R.allowCustomizedBuiltInElements&&zn(R.tagNameCheck,r)},Gn=J({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Kn=function(e){return!Gn[wt(e)]&&K(me,e)},qn=function(e,t,n,r){if(E&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ne(r);case`TrustedScriptURL`:return re(r)}return r},Jn=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!Fn(e)||(Nt(e),!1)}catch{return It(t,e),!1}},Yn=function(e,t){return Ee&&K(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,t)?!0:wt(e)===`attributename`&&Et(t,`href`)!==null},Xn=function(e,n){if(Q(P.beforeSanitizeAttributes,e,null),Hn(e,n))return;let r=e.attributes;if(!r||Fn(e))return;L=Vn(P.uponSanitizeAttribute,L,_e,Ae);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:L,forceKeepAttr:void 0},a=r.length,o=H(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=H(s),d=l,f=s===`value`?d:kt(d),p=!1;i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Q(P.uponSanitizeAttribute,e,i),f=i.attrValue,Fe&&(u===`id`||u===`name`)&&Ot(f,Ie)!==0&&(It(s,e,n),f=Ie+f,p=!0),Yn(s,f)?It(s,e,n):i.forceKeepAttr||(i.keepAttr?!we&&K(mn,f)?It(s,e,n):(Te&&(f=Mn(f)),Wn(o,u,f)?(f=qn(o,u,c,f),f!==d&&Jn(e,s,c,f)&&p&>(t.removed)):It(s,e,n)):It(s,e,n))}Q(P.afterSanitizeAttributes,e,null),Hn(e,n)},Zn=function(e){let t=null,n=jn(e);for(Q(P.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Q(P.uponSanitizeShadowNode,t,null),Un(t,e),Xn(t,e),In(t.content)&&Zn(t.content),C(t)===Y.element){let e=v(t);In(e)&&(Qn(e),Zn(e))}Te&&Pn(e),Q(P.afterSanitizeShadowDOM,e,null)},Qn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Zn(e.shadow);continue}let n=e.node,r=C(n)===Y.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=x?x(n):null;if(typeof e==`string`&&H(e)===`template`){let e=n.content;In(e)&&t.push({node:e,shadow:null})}}if(r){let e=v(n);In(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Ye=!e,Ye&&(e=`<!-->`),typeof e!=`string`&&!Ln(e)&&(e=zt(e),typeof e!=`string`))throw Ft(`dirty is not a string, aborting`);if(!t.isSupported)return e;Oe?(I=ke,L=Ae):lt(n),(P.uponSanitizeElement.length>0||P.uponSanitizeAttribute.length>0)&&(I=Rt(I)),P.uponSanitizeAttribute.length>0&&(L=Rt(L)),t.removed=[];let c=Re&&typeof e!=`string`&&Ln(e),l=[],u=B;if(c){kn(e);let t=ee(e);if(typeof t==`string`){let n=H(t);if(!I[n]||ve[n])throw q(e),Ft(`root node is forbidden and cannot be sanitized in-place`)}if(Fn(e))throw q(e),Ft(`root node is clobbered and cannot be sanitized in-place`);l=wn(e),B=xt()}else if(Ln(e))i=An(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===Y.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Qn(i);else{if(!z&&!Te&&!De&&e.indexOf(`<`)===-1)return E&&Ne?ne(e):e;if(i=An(e),!i)return z?null:Ne?D:``}i&&je&&Nt(i.firstChild);let d=c?e:i;try{c&&Qn(e);let t=jn(d);for(;o=t.nextNode();)Un(o,d),Xn(o,d),In(o.content)&&Zn(o.content);c&&Dn(e,l)}catch(t){throw c&&(q(e),En(e,l)),t}finally{B=u}if(c){if(En(e,l))throw Ft(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return Te&&Nn(e),e}if(z){if(Te&&Nn(i),Me)for(s=se.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(L.shadowroot||L.shadowrootmode)&&(s=N.call(r,s,!0)),s}let f=De?i.outerHTML:i.innerHTML;return De&&I[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&K(ln,i.ownerDocument.doctype.name)&&(f=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
3
|
-
`+f),Te&&(f=Mn(f)),E&&Ne?ne(f):f},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};lt(e),Oe=!0,ke=I,Ae=L},t.clearConfig=function(){ot=null,Oe=!1,ke=null,Ae=null,E=O,D=``},t.isValidAttribute=function(e,t,n){ot||lt({});let r=H(e),i=H(t);return typeof n==`string`&&(Yn(t,n)||!we&&K(mn,n))?!1:Wn(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&G(P,e)&&_t(P[e],t)},t.removeHook=function(e,t){if(G(P,e)){if(t!==void 0){let n=ht(P[e],t);return n===-1?void 0:yt(P[e],n,1)[0]}return gt(P[e])}},t.removeHooks=function(e){G(P,e)&&(P[e]=[])},t.removeAllHooks=function(){P=vn()},t}var Sn=xn();function Cn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var wn=Cn();function Tn(e){wn=e}var En={exec:()=>null};function Dn(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function X(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(Z.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var On=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),Z={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,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,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,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:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Dn(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Dn(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:Dn(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Dn(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Dn(e=>RegExp(`^ {0,${e}}(?:</?(?:${Hn})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,`i`)),blockquoteBeginRegex:Dn(e=>RegExp(`^ {0,${e}}>`))},kn=/^(?:[ \t]*(?:\n|$))+/,An=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,jn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Mn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Nn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Pn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Fn=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,In=X(Fn).replace(/bull/g,Pn).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}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Ln=X(Fn).replace(/bull/g,Pn).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}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Q=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Rn=/^[^\n]+/,zn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Bn=X(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,zn).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Vn=X(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Pn).getRegex(),Hn=`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`,Un=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Wn=X(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Un).replace(`tag`,Hn).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Gn=e=>X(Q).replace(`hr`,Mn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Hn).getRegex(),Kn=Gn(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),qn=Gn(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Jn={blockquote:X(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,qn).getRegex(),code:An,def:Bn,fences:jn,heading:Nn,hr:Mn,html:Wn,lheading:In,list:Vn,newline:kn,paragraph:Kn,table:En,text:Rn},Yn=X(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Mn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Hn).getRegex(),Xn={...Jn,lheading:Ln,table:Yn,paragraph:X(Q).replace(`hr`,Mn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Yn).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Hn).getRegex()},Zn={...Jn,html:X(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Un).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:En,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:X(Q).replace(`hr`,Mn).replace(`heading`,` *#{1,6} *[^
|
|
4
|
-
]`).replace(`lheading`,In).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Qn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,$n=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,er=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,tr=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,nr=/[\p{P}\p{S}]/u,rr=/[\s\p{P}\p{S}]/u,ir=/[^\s\p{P}\p{S}]/u,ar=X(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,rr).getRegex(),or=/[\p{Pi}\p{Ps}"']/u,sr=/(?!~)[\p{P}\p{S}]/u,cr=/(?!~)[\s\p{P}\p{S}]/u,lr=/(?:[^\s\p{P}\p{S}]|~)/u,ur=X(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,On?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),dr=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,fr=X(dr,`u`).replace(/punct/g,nr).getRegex(),pr=X(dr,`u`).replace(/punct/g,sr).getRegex(),mr=X(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,or).replace(/punct/g,nr).getRegex(),hr=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,gr=X(hr,`gu`).replace(/notPunctSpace/g,ir).replace(/punctSpace/g,rr).replace(/punct/g,nr).getRegex(),_r=X(hr,`gu`).replace(/notPunctSpace/g,lr).replace(/punctSpace/g,cr).replace(/punct/g,sr).getRegex(),vr=X(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,ir).replace(/punctSpace/g,rr).replace(/punct/g,nr).getRegex(),yr=X(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,ir).replace(/punctSpace/g,rr).replace(/punct/g,nr).getRegex(),br=X(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,ir).replace(/punctSpace/g,rr).replace(/punct/g,nr).getRegex(),xr=X(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,nr).getRegex(),Sr=X(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,ir).replace(/punctSpace/g,rr).replace(/punct/g,nr).getRegex(),Cr=X(/\\(punct)/,`gu`).replace(/punct/g,nr).getRegex(),wr=X(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,`gu`).replace(/punct/g,nr).getRegex(),Tr=X(/^<(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(),Er=X(Un).replace(`(?:-->|$)`,`-->`).getRegex(),Dr=X(`^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,Er).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Or=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,kr=X(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,Or).getRegex(),Ar=X(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace(`label`,kr).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),jr=X(/^!?\[(label)\]\[(ref)\]/).replace(`label`,kr).replace(`ref`,zn).getRegex(),Mr=X(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,zn).getRegex(),Nr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,Pr=X(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,Or).getRegex(),Fr=X(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,X(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Pr).replace(`ref`,Nr).getRegex()).replace(`nolink`,X(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Nr).getRegex()).getRegex(),Ir=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Lr=X(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),Rr={_backpedal:En,anyPunctuation:Cr,anyPunctuationOutsideCode:wr,autolink:Tr,blockSkip:ur,br:er,code:$n,del:En,delLDelim:En,delRDelim:En,emStrongLDelim:fr,emStrongRDelimAst:gr,emStrongRDelimUnd:yr,escape:Qn,link:Ar,nolink:Mr,punctuation:ar,reflink:jr,reflinkSearch:Fr,tag:Dr,text:tr,url:En},zr={...Rr,emStrongLDelim:mr,emStrongRDelimAst:vr,emStrongRDelimUnd:br,link:X(/^!?\[(label)\]\((.*?)\)/).replace(`label`,kr).getRegex(),reflink:X(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,kr).getRegex()},Br={...Rr,emStrongRDelimAst:_r,emStrongLDelim:pr,delLDelim:xr,delRDelim:Sr,url:X(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,Lr).replace(`protocol`,Ir).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:X(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace(`protocol`,Ir).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},Vr={...Br,br:X(er).replace(`{2,}`,`*`).getRegex(),text:X(Br.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Hr={normal:Jn,gfm:Xn,pedantic:Zn},Ur={normal:Rr,gfm:Br,breaks:Vr,pedantic:zr},Wr={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Gr=e=>Wr[e];function Kr(e,t){if(t){if(Z.escapeTest.test(e))return e.replace(Z.escapeReplace,Gr)}else if(Z.escapeTestNoEncode.test(e))return e.replace(Z.escapeReplaceNoEncode,Gr);return e}function qr(e){return Z.numericCharacterReference.test(e)?e.replace(Z.numericCharacterReferenceOrAmpersand,(e,t,n)=>{if(t===void 0&&n===void 0)return`&`;let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:r===38?`&`:String.fromCodePoint(r)}):e}function Jr(e){try{e=encodeURI(e).replace(Z.percentDecode,`%`)}catch{return null}return e}function Yr(e,t){let n=e.replace(Z.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Z.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(Z.slashPipe,`|`);return n}function Xr(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Zr(e){let t=e.split(`
|
|
5
|
-
`),n=t.length-1;for(;n>=0&&Z.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
6
|
-
`)}function Qr(e){return e.trim().toLowerCase().toUpperCase().toLowerCase()}function $r(e,t){if(e.indexOf(t[0])===-1&&e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function ei(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function ti(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`),c=e[0].charAt(0)===`!`,l=r.state.inLink,u=r.state.linkEmitted,d=r.state.inRawBlock;r.state.inLink=!0,r.state.linkEmitted=!1;let f=r.inlineTokens(s),p=r.state.linkEmitted;if(r.state.linkEmitted=u,r.state.inLink=l,!c){if(p){r.state.inRawBlock=d;return}r.state.linkEmitted=!0}return{type:c?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:f}}function ni(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
7
|
-
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return e.slice(Math.min(r.length,i.length))}).join(`
|
|
8
|
-
`)}function ri(e,t,n,r){if(!t.includes(`<`))return!1;for(let i=0;i<t.length;i++){if(t[i]===`\\`){i++;continue}if(t[i]==="`"){let e=r.inline.code.exec(t.slice(i));if(e){i+=e[0].length-1;continue}}if(t[i]!==`<`)continue;let a=e.slice(n+i),o=r.inline.tag.exec(a)||r.inline.autolink.exec(a);if(o){if(o[0].length>t.length-i)return!0;i+=o[0].length-1}}return!1}var ii=class{options;rules;lexer;constructor(e){this.options=e||wn}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:Zr(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=ni(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Xr(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceTabChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:Xr(t[0],`
|
|
9
|
-
`),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:Xr(t[0],`
|
|
10
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Xr(t[0],`
|
|
11
|
-
`).split(`
|
|
12
|
-
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o=0;for(;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
13
|
-
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
14
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
15
|
-
${s}`:s,r=r?`${r}
|
|
16
|
-
${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`||u?.type===`heading`||u?.type===`hr`||u?.type===`html`)break;if(u?.type===`blockquote`){let t=u,a=e.join(`
|
|
17
|
-
`),o=t.raw+`
|
|
18
|
-
`+a.replace(this.rules.other.blockquoteSetextReplace2,``),s=this.blockquote(o);i[i.length-1]=s;let c=o.substring(s.raw.length).replace(/^\n/,``),l=c?c.split(`
|
|
19
|
-
`).length:0,d=l?e.slice(0,-l):e;d.length>0&&(n=`${n}
|
|
20
|
-
${d.join(`
|
|
21
|
-
`)}`),r=r.substring(0,r.length-t.text.length)+s.text;break}if(u?.type===`list`){let t=u,a=t.raw+`
|
|
22
|
-
`+e.join(`
|
|
23
|
-
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
|
|
24
|
-
`)}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=e,r=()=>n.length-e.length,i=t[1].trim(),a=i.length>1,o={type:`list`,raw:``,ordered:a,start:a?+i.slice(0,-1):``,loose:!1,items:[]};i=a?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=a?i:`[*+-]`);let s=this.rules.other.listItemRegex(i),c=!1;for(;e;){let i=!1,a=``;if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;let l=r();e=e.substring(t[0].length);let u=t[2].split(`
|
|
25
|
-
`,1)[0],d=t[1].length,f=this.options.pedantic?ei(u,d):u.replace(this.rules.other.leadingSpaceTab,e=>ei(e,d)),p=e.split(`
|
|
26
|
-
`,1)[0],m=!f.trim(),h=0;if(this.options.pedantic?(h=2,a=f.trimStart()):m?h=d+1:(h=f.search(this.rules.other.nonSpaceChar),h=h>4?1:h,a=f.slice(h),h+=d),m&&this.rules.other.blankLine.test(p)&&(e=e.substring(p.length+1),i=!0),!i){let t=this.rules.other.nextBulletRegex(h),n=this.rules.other.hrRegex(h),r=this.rules.other.fencesBeginRegex(h),i=this.rules.other.headingBeginRegex(h),o=this.rules.other.htmlBeginRegex(h),s=this.rules.other.blockquoteBeginRegex(h);for(;e;){let c=e.split(`
|
|
27
|
-
`,1)[0],l;if(p=c,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting,` `),l=p):l=p.replace(this.rules.other.leadingSpaceTab,e=>ei(e)),r.test(p)||i.test(p)||o.test(p)||s.test(p)||t.test(p)||n.test(p))break;if(l.search(this.rules.other.nonSpaceChar)>=h||!p.trim())a+=`
|
|
28
|
-
`+l.slice(h);else{if(m||f.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||r.test(f)||i.test(f)||n.test(f))break;a+=`
|
|
29
|
-
`+p}m=!p.trim(),e=e.substring(c.length+1),f=l.slice(h)}}let g=n.slice(l,r());o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(g)&&(c=!0)),o.items.push({type:`list_item`,raw:g,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]})}let l=o.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;o.raw=n.slice(0,r()).trimEnd();for(let e of o.items)if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),!o.loose){let t=e.tokens.filter(e=>e.type===`space`);o.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}for(let e of o.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,o.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1}if(o.loose)for(let e of o.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=Zr(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){if(!this.rules.other.startAngleBracket.test(t[2])&&$r(t[2],`()`)!==-1)return;let e=Qr(t[1]).replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:Xr(t[0],`
|
|
30
|
-
`),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Yr(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
31
|
-
`):[],a={type:`table`,raw:Xr(t[0],`
|
|
32
|
-
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Yr(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:Xr(t[0],`
|
|
33
|
-
`),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
34
|
-
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){if(this.lexer.state.linkParenPossible===!1)return;let t=this.rules.inline.link.exec(e);if(t){let n=t[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&ri(e,t[1],n,this.rules))return;let r=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let e=Xr(r.slice(0,-1),`\\`);if((r.length-e.length)%2==0)return}else{let e=$r(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let i=t[2],a=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(i);e&&(i=e[1],a=e[3])}else a=t[3]?t[3].slice(1,-1):``;return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(i=this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i.slice(1):i.slice(1,-1)),ti(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,`$1`),title:a&&a.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=n[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&ri(e,n[1],r,this.rules))return;let i=t[Qr((n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `))];if(!i){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return ti(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,a,o,s=i,c=0,l=r[0][0],u=n===l,d=l===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(o=[...a].length,r[3]||r[4]){s+=o;continue}if(r[5]||r[6]){if(i%3&&!((i+o)%3)){c+=o;continue}if(u)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+c);let t=[...r[0]][0].length,n=e.slice(0,i+r.index+t+o);if(Math.min(i,o)%2){let e=n.slice(1,-1);return{type:`em`,raw:n,text:e,tokens:this.lexer.inlineTokens(e)}}let l=n.slice(2,-2);return{type:`strong`,raw:n,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:e?t[0]:qr(t[0]),escaped:e}}}},ai=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||wn,this.options.tokenizer=this.options.tokenizer||new ii,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,linkParenPossible:!0,top:!0};let t={other:Z,block:Hr.normal,inline:Ur.normal};this.options.pedantic?(t.block=Hr.pedantic,t.inline=Ur.pedantic):this.options.gfm&&(t.block=Hr.gfm,t.inline=this.options.breaks?Ur.breaks:Ur.gfm),this.tokenizer.rules=t}static get rules(){return{block:Hr,inline:Ur}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(Z.carriageReturn,`
|
|
35
|
-
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Z.tabCharGlobal,` `).replace(Z.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
|
|
36
|
-
`:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
37
|
-
`)?``:`
|
|
38
|
-
`)+i.raw,n.text+=`
|
|
39
|
-
`+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if((i=this.tokenizer.fences(e))||(i=this.tokenizer.heading(e))||(i=this.tokenizer.hr(e))||(i=this.tokenizer.blockquote(e))||(i=this.tokenizer.list(e))||(i=this.tokenizer.html(e))){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
40
|
-
`)?``:`
|
|
41
|
-
`)+i.raw,n.text+=`
|
|
42
|
-
`+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if((i=this.tokenizer.table(e))||(i=this.tokenizer.lheading(e))){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let r=t.at(-1);n&&r?.type===`paragraph`?(r.raw+=(r.raw.endsWith(`
|
|
43
|
-
`)?``:`
|
|
44
|
-
`)+i.raw,r.text+=`
|
|
45
|
-
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length)}else if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
46
|
-
`)?``:`
|
|
47
|
-
`)+i.raw,n.text+=`
|
|
48
|
-
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i)}else if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(e.charAt(0)!==`!`&&Object.hasOwn(this.tokens.links,Qr(e.slice(n+1,-1)))&&!(n>1&&this.linkInText(e.slice(1,n-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=this.state.linkParenPossible;this.state.linkParenPossible=n&&e.includes(`)`);try{return this.#e(e,t)}finally{this.state.linkParenPossible=n}}#e(e,t){let n=e;if(this.tokens.links&&e.includes(`[`)){let e=this.tokenizer.rules.inline.reflinkSearch,t=n=>{let r=n.lastIndexOf(`[`);if(!Object.hasOwn(this.tokens.links,Qr(n.slice(r+1,-1))))return n;if(r>1&&n.charAt(0)!==`!`){let i=n.slice(1,r-1);if(this.linkInText(i))return`[`+i.replace(e,t)+`][`+`a`.repeat(n.length-r-2)+`]`}return`[`+`a`.repeat(n.length-2)+`]`};n=n.replace(e,t)}n=n.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode,(e,t,n)=>n?`+`.repeat(e.length):t?t+e.slice(t.length,-t.length).replace(/`/g,`+`)+t:e),n=n.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+`[`+`a`.repeat(e.length-r-2)+`]`}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let r=!1,i=``,a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=``),r=!1;let o;if(this.options.extensions?.inline?.some(n=>(o=n.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if((o=this.tokenizer.escape(e))||(o=this.tokenizer.tag(e))||(o=this.tokenizer.link(e))){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let n=t.at(-1);o.type===`text`&&n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if((o=this.tokenizer.emStrong(e,n,i))||(o=this.tokenizer.codespan(e))||(o=this.tokenizer.br(e))||(o=this.tokenizer.del(e,n,i))||(o=this.tokenizer.autolink(e))||!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let s=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(s)){e=e.substring(o.raw.length),o.raw.slice(-1)!==`_`&&(i=o.raw.slice(-1)),r=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o)}else if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},oi=class{options;parser;constructor(e){this.options=e||wn}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(Z.notSpaceStart)?.[0],i=e?e.replace(Z.endingNewline,``)+`
|
|
49
|
-
`:``;return r?`<pre><code class="language-`+Kr(r)+`">`+(n?i:Kr(i,!0))+`</code></pre>
|
|
50
|
-
`:`<pre><code>`+(n?i:Kr(i,!0))+`</code></pre>
|
|
51
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
52
|
-
${this.parser.parse(e)}</blockquote>
|
|
53
|
-
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
54
|
-
`}hr(e){return`<hr>
|
|
55
|
-
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
|
|
56
|
-
`+r+`</`+i+`>
|
|
57
|
-
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
58
|
-
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
59
|
-
`}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
|
|
60
|
-
<thead>
|
|
61
|
-
`+t+`</thead>
|
|
62
|
-
`+r+`</table>
|
|
63
|
-
`}tablerow({text:e}){return`<tr>
|
|
64
|
-
${e}</tr>
|
|
65
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
66
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Kr(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?Kr(n,!0):this.parser.parseInline(r),o=Jr(e);if(o===null)return a;e=Kr(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+Kr(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Jr(e);if(i===null)return Kr(n);e=i;let a=`<img src="${Kr(e)}" alt="${Kr(n)}"`;return t&&(a+=` title="${Kr(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Kr(e.text)}},si=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},ci=class e{options;renderer;textRenderer;constructor(e){this.options=e||wn,this.options.renderer=this.options.renderer||new oi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new si}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},li=class{options;block;constructor(e){this.options=e||wn}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?ai.lex:ai.lexInline}provideParser(e=this.block){return e?ci.parse:ci.parseInline}};function ui(e,t){if(Array.isArray(t))for(let n=0;n<t.length;n++)e.push(t[n]);else e.push(t)}var di=new class{defaults=Cn();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ci;Renderer=oi;TextRenderer=si;Lexer=ai;Tokenizer=ii;Hooks=li;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(ui(n,t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)ui(n,this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)ui(n,this.walkTokens(e.tokens,t));break}case`list`:{let e=r;ui(n,this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);ui(n,this.walkTokens(i,t))}):e.tokens&&ui(n,this.walkTokens(e.tokens,t))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new oi(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new ii(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new li;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=li.passThroughHooks.has(n)?e=>{if(this.defaults.async&&li.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&ui(n,t.call(this,e)),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ai.lex(e,t??this.defaults)}parser(e,t){return ci.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(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 t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?ai.lex:ai.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?ci.parse:ci.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?ai.lex:ai.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?ci.parse:ci.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
67
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Kr(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function $(e,t){return di.parse(e,t)}$.options=$.setOptions=function(e){return di.setOptions(e),$.defaults=di.defaults,Tn($.defaults),$},$.getDefaults=Cn,$.defaults=wn;function fi(...e){return di.use(...e),$.defaults=di.defaults,Tn($.defaults),$}$.use=fi,$.walkTokens=function(e,t){return di.walkTokens(e,t)},$.parseInline=di.parseInline,$.Parser=ci,$.parser=ci.parse,$.Renderer=oi,$.TextRenderer=si,$.Lexer=ai,$.lexer=ai.lex,$.Tokenizer=ii,$.Hooks=li,$.parse=$,$.options,$.setOptions,$.walkTokens,$.parseInline,ci.parse,ai.lex;function pi(e){let t=/^\uFEFF?---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(e);return t?{frontmatter:t[1],body:e.slice(t[0].length)}:{frontmatter:null,body:e}}function mi(e){let{projectId:t,sourceId:n,story:r,onClose:i}=e,[a,o]=R(null),[s,c]=R(null),[l,u]=R(!1),d=be(null),f=be(null);ye(()=>{let e=!0;return o(null),c(null),B.story(t,n,r.key).then(t=>e&&o(t),t=>e&&c(t instanceof Error?t.message:String(t))),()=>{e=!1}},[t,n,r.key]),ye(()=>{let e=document.activeElement;f.current?.focus();let t=e=>{if(e.key===`Escape`)e.preventDefault(),i();else if(e.key===`Tab`&&d.current){let t=[...d.current.querySelectorAll(`button, a[href], [tabindex]:not([tabindex="-1"])`)];if(t.length===0)return;let n=t[0],r=t[t.length-1];d.current.contains(document.activeElement)?e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus()):(e.preventDefault(),n.focus())}};return document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`keydown`,t),e?.focus()}},[i]);let p=async()=>{if(a?.path)try{await navigator.clipboard.writeText(a.path),u(!0),setTimeout(()=>u(!1),1500)}catch{u(!1)}},m=a?pi(a.markdown):null,h=m?Sn.sanitize($.parse(m.body,{async:!1})):``;return V(`div`,{class:`backdrop`,onClick:e=>e.target===e.currentTarget&&i(),children:V(`div`,{class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`detail-title`,ref:d,children:[V(`header`,{class:`modal-head`,children:[V(`h2`,{id:`detail-title`,children:[V(`span`,{class:`card-id`,children:r.id}),` `,r.title]}),V(`button`,{type:`button`,class:`icon-btn`,ref:f,onClick:i,"aria-label":`Close`,children:`×`})]}),V(`div`,{class:`modal-path`,children:a===null?null:a.path===null?V(`span`,{class:`muted`,children:`No file yet`}):V(v,{children:[V(`code`,{title:a.path,children:a.path}),V(`button`,{type:`button`,class:`small-btn`,onClick:p,children:l?`Copied`:`Copy path`})]})}),V(`div`,{class:`modal-body`,children:[s!==null&&V(`p`,{class:`notice error`,children:s}),a===null&&s===null&&V(`p`,{class:`muted`,children:`Loading…`}),m?.frontmatter&&V(`pre`,{class:`frontmatter`,children:m.frontmatter}),a!==null&&V(`div`,{class:`markdown`,dangerouslySetInnerHTML:{__html:h}})]})]})})}var hi=e=>new Map(e.epics.map((e,t)=>[e.id,{epic:e,index:t}])),gi=e=>ze.filter(t=>e||t!==`dropped`);function _i(e){let{board:t}=e,n=He(t.stories,e.showDropped,e.epicFilter),r=hi(t);return V(`div`,{class:`columns`,children:gi(e.showDropped).map(i=>V(`section`,{class:`column col-${i}`,"aria-label":Be[i],children:[V(`h3`,{class:`col-head`,children:[Be[i],` · `,n[i].length]}),n[i].map(n=>V(Ze,{story:n,showEpic:!0,epic:n.epicId===null?null:r.get(n.epicId)??null,onOpen:n=>e.onOpen(n,t.sourceId)},n.key))]},i))})}var vi=e=>e.sources.length>1||e.sources.some(e=>(e.children?.length??0)>0);function yi({onAdded:e}){let[t,n]=R(!1),[r,i]=R(``),[a,o]=R(null),[s,c]=R(!1),l=()=>{n(!1),i(``),o(null)};return t?V(`form`,{class:`add-form`,onSubmit:async t=>{if(t.preventDefault(),r.trim()!==``){c(!0),o(null);try{let t=await B.addProject(r.trim());l(),e(t)}catch(e){o(e instanceof Error?e.message:String(e))}finally{c(!1)}}},children:[V(`label`,{for:`add-path`,class:`sr-only`,children:`Project folder path`}),V(`input`,{id:`add-path`,type:`text`,placeholder:`/path/to/project`,value:r,autoFocus:!0,onInput:e=>i(e.target.value),onKeyDown:e=>e.key===`Escape`&&l()}),V(`div`,{class:`add-actions`,children:[V(`button`,{type:`submit`,class:`small-btn primary`,disabled:s,children:`Add`}),V(`button`,{type:`button`,class:`small-btn`,onClick:l,children:`Cancel`})]}),a!==null&&V(`p`,{class:`add-error`,role:`alert`,children:a})]}):V(`button`,{type:`button`,class:`add-btn`,onClick:()=>n(!0),children:`+ Add project`})}function bi(e){let{project:t,source:n,selected:r}=e;return V(`li`,{children:[V(`button`,{type:`button`,class:`source${r===n.id?` on`:``}`,"aria-current":r===n.id?`true`:void 0,onClick:()=>e.onSelect(t.id,n.id),children:[V(`span`,{class:`source-label`,children:n.label}),V(`span`,{class:`count`,children:n.count})]}),n.children&&n.children.length>0&&V(`ul`,{class:`sources nested`,children:n.children.map(n=>V(bi,{project:t,source:n,selected:r,onSelect:e.onSelect},n.id))})]})}function xi(e){return V(`nav`,{class:`sidebar`,"aria-label":`Projects`,children:[V(`div`,{class:`sidebar-head`,children:V(`span`,{class:`brand`,children:`BMAD Kanban`})}),V(yi,{onAdded:e.onAdded}),V(`ul`,{class:`projects`,children:e.projects.map(t=>{let n=t.id===e.selectedId;return V(`li`,{class:`project${n?` on`:``}${t.missing?` missing`:``}`,children:[V(`div`,{class:`project-row`,children:[V(`button`,{type:`button`,class:`project-btn`,"aria-current":n?`true`:void 0,title:t.path,onClick:()=>e.onSelectProject(t.id),children:[V(`span`,{class:`project-name`,children:t.name}),t.tags.map(e=>V(`span`,{class:`tag`,children:e},e))]}),V(`button`,{type:`button`,class:`icon-btn remove`,"aria-label":`Remove ${t.name} from the list`,title:`Remove from list`,onClick:()=>e.onRemove(t),children:`×`})]}),t.missing&&V(`div`,{class:`project-note`,children:`folder not found`}),t.error!==void 0&&V(`div`,{class:`project-note error`,title:t.error,children:[`config error: `,t.error]}),!t.missing&&vi(t)&&V(`ul`,{class:`sources`,children:t.sources.map(r=>V(bi,{project:t,source:r,selected:n?e.sourceId:null,onSelect:e.onSelectSource},r.id))})]},t.id)})}),e.projects.length===0&&V(`p`,{class:`muted empty`,children:`No projects yet.`})]})}function Si(e){let{board:t}=e,n=gi(e.showDropped),r=Ue(t,e.showDropped),i=hi(t);return V(`div`,{class:`lanes`,style:{gridTemplateColumns:`minmax(140px, 180px) repeat(${n.length}, minmax(140px, 1fr))`},children:[V(`div`,{class:`lane-corner`}),n.map(e=>V(`h3`,{class:`col-head`,children:Be[e]},e)),r.map(r=>{let a=r.epic?i.get(r.epic.id):void 0,o=r.total===0?0:Math.round(r.done/r.total*100);return[V(`div`,{class:`lane-head`,style:{borderLeftColor:a?Ge(a.index):`var(--muted)`},children:[V(`div`,{class:`lane-title`,children:r.epic?V(v,{children:[r.epic.id,` `,r.epic.title]}):`No epic`}),V(`div`,{class:`lane-meta`,children:[r.epic?.status&&V(`span`,{children:r.epic.status}),r.epic?.retrospective===`done`&&V(`span`,{class:`retro-tag`,children:`✓ retro`}),V(`span`,{children:[r.done,`/`,r.total,` done`]})]}),V(`div`,{class:`bar`,role:`progressbar`,"aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${r.done} of ${r.total} done`,children:V(`i`,{style:{width:`${o}%`}})})]},`h-${r.epic?.id??`-`}`),...n.map(n=>V(`div`,{class:`cell`,children:r.cells[n].map(n=>V(Ze,{story:n,showEpic:!1,epic:a??null,onOpen:n=>e.onOpen(n,t.sourceId)},n.key))},`${r.epic?.id??`-`}-${n}`))]})]})}var Ci=e=>e.flatMap(e=>[e,...Ci(e.children??[])]);function wi(e,t){let n=new Set(Ci(e.sources).map(e=>e.id));for(let r of[t,e.prefs?.sourceId,e.defaultSourceId])if(r&&n.has(r))return r;return e.sources[0]?.id??null}var Ti=e=>e.children&&e.children.length>0?e.children:[e],Ei=e=>[e,...e.children??[]].some(e=>e.stories.some(e=>e.column===`dropped`)),Di=e=>e instanceof Error?e.message:String(e);function Oi(e){let{board:t,view:n}=e,r=t=>V(v,{children:[t.notices.map((e,t)=>V(`div`,{class:`notice ${e.level}`,role:e.level===`error`?`alert`:void 0,children:e.text},t)),t.stories.length===0?V(`p`,{class:`muted empty`,children:`No stories in this board yet.`}):n===`columns`?V(_i,{board:t,showDropped:e.showDropped,epicFilter:e.epicFilter,onOpen:e.onOpen}):V(Si,{board:t,showDropped:e.showDropped,onOpen:e.onOpen})]});return!t.children||t.children.length===0?r(t):V(v,{children:[t.notices.map((e,t)=>V(`div`,{class:`notice ${e.level}`,children:e.text},t)),t.children.map(e=>V(`section`,{class:`child-board`,"aria-label":e.label,children:[V(`h2`,{class:`child-title`,children:e.label}),r(e)]},e.sourceId))]})}function ki(){let[e,t]=R(null),[n,r]=R(null),[i,a]=R(null),[o,s]=R(null),[c,l]=R(`columns`),[u,d]=R(!1),[f,p]=R(null),[m,h]=R(null),[g,_]=R(0),[y,b]=R(null),x=be(null);x.current=i;let S=be(!1),C=e?.find(e=>e.id===i)??null,ee=Se(()=>b(null),[]),w=Se((e,t)=>{a(e.id),s(wi(e,t)),l(e.prefs?.view??`columns`),d(e.prefs?.showDropped??!1),p(null),b(null);let n=new URL(location.href);n.searchParams.set(`project`,e.id),history.replaceState(null,``,n),B.setLastViewed(e.id).catch(()=>{})},[]),T=Se((e,n)=>{t(t=>t&&t.map(t=>t.id===e?{...t,prefs:{...t.prefs??{view:`columns`,showDropped:!1,sourceId:null},...n}}:t)),B.setPrefs(e,n).catch(()=>{})},[]),E=Se(async()=>{try{let e=await B.projects();t(e),r(null);let n=e.find(e=>e.id===x.current);S.current&&(n?s(e=>wi(n,e)):e.length>0?w(e[0]):(a(null),s(null)))}catch(e){r(Di(e))}},[w]);ye(()=>{(async()=>{try{let[e,n]=await Promise.all([B.projects(),B.state().catch(()=>({lastViewed:null}))]);t(e);let r=[new URLSearchParams(location.search).get(`project`),n.lastViewed].map(t=>e.find(e=>e.id===t)).find(e=>e!==void 0)??e[0];S.current=!0,r&&w(r)}catch(e){S.current=!0,r(Di(e))}})()},[w]),ye(()=>{let e=new EventSource(Ie);e.addEventListener(`change`,e=>{try{let{projectId:t}=JSON.parse(e.data);if(t!==x.current)return}catch{return}_(e=>e+1),E()}),e.addEventListener(`projects`,()=>void E());let t=!1;return e.addEventListener(`open`,()=>{t&&(_(e=>e+1),E()),t=!0}),()=>e.close()},[E]);let D=C?.missing??!1,O=i&&o?`${i}\u0000${o}`:null;ye(()=>{if(!i||!o||!O||D)return;let e=!0;return B.board(i,o).then(t=>e&&h({key:O,board:t,error:null}),t=>{e&&(t instanceof je&&t.status===410&&E(),h({key:O,board:null,error:Di(t)}))}),()=>{e=!1}},[i,o,O,D,g,E]);let k=m!==null&&m.key===O?m:null,A=k?.board??null,te=k?.error??null,ne=t=>{let n=e?.find(e=>e.id===t);n&&t!==i&&w(n)},re=(t,n)=>{let r=e?.find(e=>e.id===t);r&&(t===i?(s(n),p(null)):w(r,n),T(t,{sourceId:n}))},ie=e=>{t(t=>t?[...t.filter(t=>t.id!==e.id),e]:[e]),w(e)},j=async e=>{if(confirm(`Remove "${e.name}" from the list? The folder is not touched.`)){try{await B.removeProject(e.id)}catch{}await E()}},ae=e=>{l(e),i&&T(i,{view:e})},oe=e=>{d(e),i&&T(i,{showDropped:e})},se=A?Ti(A):[],M=[],N=new Set;for(let e of se)e.epics.forEach((e,t)=>{N.has(e.id)||(N.add(e.id),M.push({epic:e,index:t}))});let P=f!==null&&N.has(f)?f:null,ce=A?Ei(A):!1,le=C?Ci(C.sources).find(e=>e.id===o):void 0;return V(`div`,{class:`app`,children:[V(xi,{projects:e??[],selectedId:i,sourceId:o,onSelectProject:ne,onSelectSource:re,onAdded:ie,onRemove:j}),V(`main`,{class:`main`,children:[n!==null&&V(`div`,{class:`notice error`,role:`alert`,children:[`Could not reach the server: `,n]}),e!==null&&e.length===0&&V(`div`,{class:`placeholder`,children:[V(`h1`,{children:`No projects yet`}),V(`p`,{children:[`Add a BMAD project folder with “+ Add project”, or run `,V(`code`,{children:`npx bmad-kanban`}),` inside one.`]})]}),C&&V(v,{children:[V(`header`,{class:`board-head`,children:[V(`h1`,{class:`board-title`,children:[C.name,(A?.label??le?.label)&&V(`span`,{class:`board-source`,children:[` / `,A?.label??le?.label]})]}),!C.missing&&A&&V(`div`,{class:`controls`,children:[V(`div`,{class:`toggle`,role:`group`,"aria-label":`Board view`,children:[V(`button`,{type:`button`,"aria-pressed":c===`columns`,class:c===`columns`?`on`:``,onClick:()=>ae(`columns`),children:`Columns`}),V(`button`,{type:`button`,"aria-pressed":c===`swimlanes`,class:c===`swimlanes`?`on`:``,onClick:()=>ae(`swimlanes`),children:`Swimlanes`})]}),ce&&V(`label`,{class:`switch`,children:[V(`input`,{type:`checkbox`,checked:u,onChange:e=>oe(e.target.checked)}),V(`span`,{children:`Show dropped`})]})]})]}),c===`columns`&&A&&M.length>0&&V(`div`,{class:`filters`,role:`group`,"aria-label":`Filter by epic`,children:[V(`span`,{class:`filters-label`,children:`Epics:`}),V(`button`,{type:`button`,class:`filter${P===null?` on`:``}`,"aria-pressed":P===null,onClick:()=>p(null),children:`All`}),M.map(e=>V(`button`,{type:`button`,class:`filter${P===e.epic.id?` on`:``}`,"aria-pressed":P===e.epic.id,onClick:()=>p(e.epic.id),children:[V(Je,{info:e}),` `,e.epic.title]},e.epic.id))]}),V(`div`,{class:`board`,children:C.missing?V(`div`,{class:`placeholder`,children:[V(`h2`,{children:`Folder not found`}),V(`p`,{children:[V(`code`,{children:C.path}),` no longer exists.`]})]}):C.error!==void 0&&C.sources.length===0?V(`div`,{class:`notice error`,children:[`Could not read this project's BMAD config: `,C.error]}):o===null?V(`p`,{class:`muted empty`,children:`No boards found in this project yet.`}):te===null?A===null?V(`p`,{class:`muted empty`,children:`Loading…`}):V(Oi,{board:A,view:c,showDropped:u&&ce,epicFilter:P,onOpen:(e,t)=>b({story:e,sourceId:t})}):V(`div`,{class:`notice error`,role:`alert`,children:te})})]})]}),y&&C&&V(mi,{projectId:C.id,sourceId:y.sourceId,story:y.story,onClose:ee})]})}se(V(ki,{}),document.getElementById(`app`));
|