@compn3rd/pi-web-code-review 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3277 @@
1
+ //#region node_modules/@lit/reactive-element/css-tag.js
2
+ var e = globalThis, t = e.ShadowRoot && (e.ShadyCSS === void 0 || e.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, n = Symbol(), r = /* @__PURE__ */ new WeakMap(), i = class {
3
+ constructor(e, t, r) {
4
+ if (this._$cssResult$ = !0, r !== n) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
5
+ this.cssText = e, this.t = t;
6
+ }
7
+ get styleSheet() {
8
+ let e = this.o, n = this.t;
9
+ if (t && e === void 0) {
10
+ let t = n !== void 0 && n.length === 1;
11
+ t && (e = r.get(n)), e === void 0 && ((this.o = e = new CSSStyleSheet()).replaceSync(this.cssText), t && r.set(n, e));
12
+ }
13
+ return e;
14
+ }
15
+ toString() {
16
+ return this.cssText;
17
+ }
18
+ }, a = (e) => new i(typeof e == "string" ? e : e + "", void 0, n), o = (e, ...t) => new i(e.length === 1 ? e[0] : t.reduce((t, n, r) => t + ((e) => {
19
+ if (!0 === e._$cssResult$) return e.cssText;
20
+ if (typeof e == "number") return e;
21
+ throw Error("Value passed to 'css' function must be a 'css' function result: " + e + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
22
+ })(n) + e[r + 1], e[0]), e, n), s = (n, r) => {
23
+ if (t) n.adoptedStyleSheets = r.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
24
+ else for (let t of r) {
25
+ let r = document.createElement("style"), i = e.litNonce;
26
+ i !== void 0 && r.setAttribute("nonce", i), r.textContent = t.cssText, n.appendChild(r);
27
+ }
28
+ }, c = t ? (e) => e : (e) => e instanceof CSSStyleSheet ? ((e) => {
29
+ let t = "";
30
+ for (let n of e.cssRules) t += n.cssText;
31
+ return a(t);
32
+ })(e) : e, { is: l, defineProperty: u, getOwnPropertyDescriptor: d, getOwnPropertyNames: f, getOwnPropertySymbols: p, getPrototypeOf: m } = Object, h = globalThis, g = h.trustedTypes, ee = g ? g.emptyScript : "", te = h.reactiveElementPolyfillSupport, _ = (e, t) => e, ne = {
33
+ toAttribute(e, t) {
34
+ switch (t) {
35
+ case Boolean:
36
+ e = e ? ee : null;
37
+ break;
38
+ case Object:
39
+ case Array: e = e == null ? e : JSON.stringify(e);
40
+ }
41
+ return e;
42
+ },
43
+ fromAttribute(e, t) {
44
+ let n = e;
45
+ switch (t) {
46
+ case Boolean:
47
+ n = e !== null;
48
+ break;
49
+ case Number:
50
+ n = e === null ? null : Number(e);
51
+ break;
52
+ case Object:
53
+ case Array: try {
54
+ n = JSON.parse(e);
55
+ } catch {
56
+ n = null;
57
+ }
58
+ }
59
+ return n;
60
+ }
61
+ }, re = (e, t) => !l(e, t), ie = {
62
+ attribute: !0,
63
+ type: String,
64
+ converter: ne,
65
+ reflect: !1,
66
+ useDefault: !1,
67
+ hasChanged: re
68
+ };
69
+ Symbol.metadata ??= Symbol("metadata"), h.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
70
+ var v = class extends HTMLElement {
71
+ static addInitializer(e) {
72
+ this._$Ei(), (this.l ??= []).push(e);
73
+ }
74
+ static get observedAttributes() {
75
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
76
+ }
77
+ static createProperty(e, t = ie) {
78
+ if (t.state && (t.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(e) && ((t = Object.create(t)).wrapped = !0), this.elementProperties.set(e, t), !t.noAccessor) {
79
+ let n = Symbol(), r = this.getPropertyDescriptor(e, n, t);
80
+ r !== void 0 && u(this.prototype, e, r);
81
+ }
82
+ }
83
+ static getPropertyDescriptor(e, t, n) {
84
+ let { get: r, set: i } = d(this.prototype, e) ?? {
85
+ get() {
86
+ return this[t];
87
+ },
88
+ set(e) {
89
+ this[t] = e;
90
+ }
91
+ };
92
+ return {
93
+ get: r,
94
+ set(t) {
95
+ let a = r?.call(this);
96
+ i?.call(this, t), this.requestUpdate(e, a, n);
97
+ },
98
+ configurable: !0,
99
+ enumerable: !0
100
+ };
101
+ }
102
+ static getPropertyOptions(e) {
103
+ return this.elementProperties.get(e) ?? ie;
104
+ }
105
+ static _$Ei() {
106
+ if (this.hasOwnProperty(_("elementProperties"))) return;
107
+ let e = m(this);
108
+ e.finalize(), e.l !== void 0 && (this.l = [...e.l]), this.elementProperties = new Map(e.elementProperties);
109
+ }
110
+ static finalize() {
111
+ if (this.hasOwnProperty(_("finalized"))) return;
112
+ if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(_("properties"))) {
113
+ let e = this.properties, t = [...f(e), ...p(e)];
114
+ for (let n of t) this.createProperty(n, e[n]);
115
+ }
116
+ let e = this[Symbol.metadata];
117
+ if (e !== null) {
118
+ let t = litPropertyMetadata.get(e);
119
+ if (t !== void 0) for (let [e, n] of t) this.elementProperties.set(e, n);
120
+ }
121
+ this._$Eh = /* @__PURE__ */ new Map();
122
+ for (let [e, t] of this.elementProperties) {
123
+ let n = this._$Eu(e, t);
124
+ n !== void 0 && this._$Eh.set(n, e);
125
+ }
126
+ this.elementStyles = this.finalizeStyles(this.styles);
127
+ }
128
+ static finalizeStyles(e) {
129
+ let t = [];
130
+ if (Array.isArray(e)) {
131
+ let n = new Set(e.flat(1 / 0).reverse());
132
+ for (let e of n) t.unshift(c(e));
133
+ } else e !== void 0 && t.push(c(e));
134
+ return t;
135
+ }
136
+ static _$Eu(e, t) {
137
+ let n = t.attribute;
138
+ return !1 === n ? void 0 : typeof n == "string" ? n : typeof e == "string" ? e.toLowerCase() : void 0;
139
+ }
140
+ constructor() {
141
+ super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
142
+ }
143
+ _$Ev() {
144
+ this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach((e) => e(this));
145
+ }
146
+ addController(e) {
147
+ (this._$EO ??= /* @__PURE__ */ new Set()).add(e), this.renderRoot !== void 0 && this.isConnected && e.hostConnected?.();
148
+ }
149
+ removeController(e) {
150
+ this._$EO?.delete(e);
151
+ }
152
+ _$E_() {
153
+ let e = /* @__PURE__ */ new Map(), t = this.constructor.elementProperties;
154
+ for (let n of t.keys()) this.hasOwnProperty(n) && (e.set(n, this[n]), delete this[n]);
155
+ e.size > 0 && (this._$Ep = e);
156
+ }
157
+ createRenderRoot() {
158
+ let e = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
159
+ return s(e, this.constructor.elementStyles), e;
160
+ }
161
+ connectedCallback() {
162
+ this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(!0), this._$EO?.forEach((e) => e.hostConnected?.());
163
+ }
164
+ enableUpdating(e) {}
165
+ disconnectedCallback() {
166
+ this._$EO?.forEach((e) => e.hostDisconnected?.());
167
+ }
168
+ attributeChangedCallback(e, t, n) {
169
+ this._$AK(e, n);
170
+ }
171
+ _$ET(e, t) {
172
+ let n = this.constructor.elementProperties.get(e), r = this.constructor._$Eu(e, n);
173
+ if (r !== void 0 && !0 === n.reflect) {
174
+ let i = (n.converter?.toAttribute === void 0 ? ne : n.converter).toAttribute(t, n.type);
175
+ this._$Em = e, i == null ? this.removeAttribute(r) : this.setAttribute(r, i), this._$Em = null;
176
+ }
177
+ }
178
+ _$AK(e, t) {
179
+ let n = this.constructor, r = n._$Eh.get(e);
180
+ if (r !== void 0 && this._$Em !== r) {
181
+ let e = n.getPropertyOptions(r), i = typeof e.converter == "function" ? { fromAttribute: e.converter } : e.converter?.fromAttribute === void 0 ? ne : e.converter;
182
+ this._$Em = r;
183
+ let a = i.fromAttribute(t, e.type);
184
+ this[r] = a ?? this._$Ej?.get(r) ?? a, this._$Em = null;
185
+ }
186
+ }
187
+ requestUpdate(e, t, n, r = !1, i) {
188
+ if (e !== void 0) {
189
+ let a = this.constructor;
190
+ if (!1 === r && (i = this[e]), n ??= a.getPropertyOptions(e), !((n.hasChanged ?? re)(i, t) || n.useDefault && n.reflect && i === this._$Ej?.get(e) && !this.hasAttribute(a._$Eu(e, n)))) return;
191
+ this.C(e, t, n);
192
+ }
193
+ !1 === this.isUpdatePending && (this._$ES = this._$EP());
194
+ }
195
+ C(e, t, { useDefault: n, reflect: r, wrapped: i }, a) {
196
+ n && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(e) && (this._$Ej.set(e, a ?? t ?? this[e]), !0 !== i || a !== void 0) || (this._$AL.has(e) || (this.hasUpdated || n || (t = void 0), this._$AL.set(e, t)), !0 === r && this._$Em !== e && (this._$Eq ??= /* @__PURE__ */ new Set()).add(e));
197
+ }
198
+ async _$EP() {
199
+ this.isUpdatePending = !0;
200
+ try {
201
+ await this._$ES;
202
+ } catch (e) {
203
+ Promise.reject(e);
204
+ }
205
+ let e = this.scheduleUpdate();
206
+ return e != null && await e, !this.isUpdatePending;
207
+ }
208
+ scheduleUpdate() {
209
+ return this.performUpdate();
210
+ }
211
+ performUpdate() {
212
+ if (!this.isUpdatePending) return;
213
+ if (!this.hasUpdated) {
214
+ if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
215
+ for (let [e, t] of this._$Ep) this[e] = t;
216
+ this._$Ep = void 0;
217
+ }
218
+ let e = this.constructor.elementProperties;
219
+ if (e.size > 0) for (let [t, n] of e) {
220
+ let { wrapped: e } = n, r = this[t];
221
+ !0 !== e || this._$AL.has(t) || r === void 0 || this.C(t, void 0, n, r);
222
+ }
223
+ }
224
+ let e = !1, t = this._$AL;
225
+ try {
226
+ e = this.shouldUpdate(t), e ? (this.willUpdate(t), this._$EO?.forEach((e) => e.hostUpdate?.()), this.update(t)) : this._$EM();
227
+ } catch (t) {
228
+ throw e = !1, this._$EM(), t;
229
+ }
230
+ e && this._$AE(t);
231
+ }
232
+ willUpdate(e) {}
233
+ _$AE(e) {
234
+ this._$EO?.forEach((e) => e.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(e)), this.updated(e);
235
+ }
236
+ _$EM() {
237
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
238
+ }
239
+ get updateComplete() {
240
+ return this.getUpdateComplete();
241
+ }
242
+ getUpdateComplete() {
243
+ return this._$ES;
244
+ }
245
+ shouldUpdate(e) {
246
+ return !0;
247
+ }
248
+ update(e) {
249
+ this._$Eq &&= this._$Eq.forEach((e) => this._$ET(e, this[e])), this._$EM();
250
+ }
251
+ updated(e) {}
252
+ firstUpdated(e) {}
253
+ };
254
+ v.elementStyles = [], v.shadowRootOptions = { mode: "open" }, v[_("elementProperties")] = /* @__PURE__ */ new Map(), v[_("finalized")] = /* @__PURE__ */ new Map(), te?.({ ReactiveElement: v }), (h.reactiveElementVersions ??= []).push("2.1.2");
255
+ //#endregion
256
+ //#region node_modules/lit-html/lit-html.js
257
+ var ae = globalThis, oe = (e) => e, se = ae.trustedTypes, ce = se ? se.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, le = "$lit$", y = `lit$${Math.random().toFixed(9).slice(2)}$`, ue = "?" + y, de = `<${ue}>`, b = document, x = () => b.createComment(""), S = (e) => e === null || typeof e != "object" && typeof e != "function", fe = Array.isArray, pe = (e) => fe(e) || typeof e?.[Symbol.iterator] == "function", me = "[ \n\f\r]", C = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, he = /-->/g, ge = />/g, w = RegExp(`>|${me}(?:([^\\s"'>=/]+)(${me}*=${me}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`, "g"), _e = /'/g, ve = /"/g, ye = /^(?:script|style|textarea|title)$/i, T = ((e) => (t, ...n) => ({
258
+ _$litType$: e,
259
+ strings: t,
260
+ values: n
261
+ }))(1), E = Symbol.for("lit-noChange"), D = Symbol.for("lit-nothing"), be = /* @__PURE__ */ new WeakMap(), O = b.createTreeWalker(b, 129);
262
+ function xe(e, t) {
263
+ if (!fe(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array");
264
+ return ce === void 0 ? t : ce.createHTML(t);
265
+ }
266
+ var Se = (e, t) => {
267
+ let n = e.length - 1, r = [], i, a = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", o = C;
268
+ for (let t = 0; t < n; t++) {
269
+ let n = e[t], s, c, l = -1, u = 0;
270
+ for (; u < n.length && (o.lastIndex = u, c = o.exec(n), c !== null);) u = o.lastIndex, o === C ? c[1] === "!--" ? o = he : c[1] === void 0 ? c[2] === void 0 ? c[3] !== void 0 && (o = w) : (ye.test(c[2]) && (i = RegExp("</" + c[2], "g")), o = w) : o = ge : o === w ? c[0] === ">" ? (o = i ?? C, l = -1) : c[1] === void 0 ? l = -2 : (l = o.lastIndex - c[2].length, s = c[1], o = c[3] === void 0 ? w : c[3] === "\"" ? ve : _e) : o === ve || o === _e ? o = w : o === he || o === ge ? o = C : (o = w, i = void 0);
271
+ let d = o === w && e[t + 1].startsWith("/>") ? " " : "";
272
+ a += o === C ? n + de : l >= 0 ? (r.push(s), n.slice(0, l) + le + n.slice(l) + y + d) : n + y + (l === -2 ? t : d);
273
+ }
274
+ return [xe(e, a + (e[n] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), r];
275
+ }, Ce = class e {
276
+ constructor({ strings: t, _$litType$: n }, r) {
277
+ let i;
278
+ this.parts = [];
279
+ let a = 0, o = 0, s = t.length - 1, c = this.parts, [l, u] = Se(t, n);
280
+ if (this.el = e.createElement(l, r), O.currentNode = this.el.content, n === 2 || n === 3) {
281
+ let e = this.el.content.firstChild;
282
+ e.replaceWith(...e.childNodes);
283
+ }
284
+ for (; (i = O.nextNode()) !== null && c.length < s;) {
285
+ if (i.nodeType === 1) {
286
+ if (i.hasAttributes()) for (let e of i.getAttributeNames()) if (e.endsWith(le)) {
287
+ let t = u[o++], n = i.getAttribute(e).split(y), r = /([.?@])?(.*)/.exec(t);
288
+ c.push({
289
+ type: 1,
290
+ index: a,
291
+ name: r[2],
292
+ strings: n,
293
+ ctor: r[1] === "." ? De : r[1] === "?" ? Oe : r[1] === "@" ? ke : Ee
294
+ }), i.removeAttribute(e);
295
+ } else e.startsWith(y) && (c.push({
296
+ type: 6,
297
+ index: a
298
+ }), i.removeAttribute(e));
299
+ if (ye.test(i.tagName)) {
300
+ let e = i.textContent.split(y), t = e.length - 1;
301
+ if (t > 0) {
302
+ i.textContent = se ? se.emptyScript : "";
303
+ for (let n = 0; n < t; n++) i.append(e[n], x()), O.nextNode(), c.push({
304
+ type: 2,
305
+ index: ++a
306
+ });
307
+ i.append(e[t], x());
308
+ }
309
+ }
310
+ } else if (i.nodeType === 8) {
311
+ if (i.data === ue) c.push({
312
+ type: 2,
313
+ index: a
314
+ });
315
+ else {
316
+ let e = -1;
317
+ for (; (e = i.data.indexOf(y, e + 1)) !== -1;) c.push({
318
+ type: 7,
319
+ index: a
320
+ }), e += y.length - 1;
321
+ }
322
+ }
323
+ a++;
324
+ }
325
+ }
326
+ static createElement(e, t) {
327
+ let n = b.createElement("template");
328
+ return n.innerHTML = e, n;
329
+ }
330
+ };
331
+ function k(e, t, n = e, r) {
332
+ if (t === E) return t;
333
+ let i = r === void 0 ? n._$Cl : n._$Co?.[r], a = S(t) ? void 0 : t._$litDirective$;
334
+ return i?.constructor !== a && (i?._$AO?.(!1), a === void 0 ? i = void 0 : (i = new a(e), i._$AT(e, n, r)), r === void 0 ? n._$Cl = i : (n._$Co ??= [])[r] = i), i !== void 0 && (t = k(e, i._$AS(e, t.values), i, r)), t;
335
+ }
336
+ var we = class {
337
+ constructor(e, t) {
338
+ this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = t;
339
+ }
340
+ get parentNode() {
341
+ return this._$AM.parentNode;
342
+ }
343
+ get _$AU() {
344
+ return this._$AM._$AU;
345
+ }
346
+ u(e) {
347
+ let { el: { content: t }, parts: n } = this._$AD, r = (e?.creationScope ?? b).importNode(t, !0);
348
+ O.currentNode = r;
349
+ let i = O.nextNode(), a = 0, o = 0, s = n[0];
350
+ for (; s !== void 0;) {
351
+ if (a === s.index) {
352
+ let t;
353
+ s.type === 2 ? t = new Te(i, i.nextSibling, this, e) : s.type === 1 ? t = new s.ctor(i, s.name, s.strings, this, e) : s.type === 6 && (t = new Ae(i, this, e)), this._$AV.push(t), s = n[++o];
354
+ }
355
+ a !== s?.index && (i = O.nextNode(), a++);
356
+ }
357
+ return O.currentNode = b, r;
358
+ }
359
+ p(e) {
360
+ let t = 0;
361
+ for (let n of this._$AV) n !== void 0 && (n.strings === void 0 ? n._$AI(e[t]) : (n._$AI(e, n, t), t += n.strings.length - 2)), t++;
362
+ }
363
+ }, Te = class e {
364
+ get _$AU() {
365
+ return this._$AM?._$AU ?? this._$Cv;
366
+ }
367
+ constructor(e, t, n, r) {
368
+ this.type = 2, this._$AH = D, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = n, this.options = r, this._$Cv = r?.isConnected ?? !0;
369
+ }
370
+ get parentNode() {
371
+ let e = this._$AA.parentNode, t = this._$AM;
372
+ return t !== void 0 && e?.nodeType === 11 && (e = t.parentNode), e;
373
+ }
374
+ get startNode() {
375
+ return this._$AA;
376
+ }
377
+ get endNode() {
378
+ return this._$AB;
379
+ }
380
+ _$AI(e, t = this) {
381
+ e = k(this, e, t), S(e) ? e === D || e == null || e === "" ? (this._$AH !== D && this._$AR(), this._$AH = D) : e !== this._$AH && e !== E && this._(e) : e._$litType$ === void 0 ? e.nodeType === void 0 ? pe(e) ? this.k(e) : this._(e) : this.T(e) : this.$(e);
382
+ }
383
+ O(e) {
384
+ return this._$AA.parentNode.insertBefore(e, this._$AB);
385
+ }
386
+ T(e) {
387
+ this._$AH !== e && (this._$AR(), this._$AH = this.O(e));
388
+ }
389
+ _(e) {
390
+ this._$AH !== D && S(this._$AH) ? this._$AA.nextSibling.data = e : this.T(b.createTextNode(e)), this._$AH = e;
391
+ }
392
+ $(e) {
393
+ let { values: t, _$litType$: n } = e, r = typeof n == "number" ? this._$AC(e) : (n.el === void 0 && (n.el = Ce.createElement(xe(n.h, n.h[0]), this.options)), n);
394
+ if (this._$AH?._$AD === r) this._$AH.p(t);
395
+ else {
396
+ let e = new we(r, this), n = e.u(this.options);
397
+ e.p(t), this.T(n), this._$AH = e;
398
+ }
399
+ }
400
+ _$AC(e) {
401
+ let t = be.get(e.strings);
402
+ return t === void 0 && be.set(e.strings, t = new Ce(e)), t;
403
+ }
404
+ k(t) {
405
+ fe(this._$AH) || (this._$AH = [], this._$AR());
406
+ let n = this._$AH, r, i = 0;
407
+ for (let a of t) i === n.length ? n.push(r = new e(this.O(x()), this.O(x()), this, this.options)) : r = n[i], r._$AI(a), i++;
408
+ i < n.length && (this._$AR(r && r._$AB.nextSibling, i), n.length = i);
409
+ }
410
+ _$AR(e = this._$AA.nextSibling, t) {
411
+ for (this._$AP?.(!1, !0, t); e !== this._$AB;) {
412
+ let t = oe(e).nextSibling;
413
+ oe(e).remove(), e = t;
414
+ }
415
+ }
416
+ setConnected(e) {
417
+ this._$AM === void 0 && (this._$Cv = e, this._$AP?.(e));
418
+ }
419
+ }, Ee = class {
420
+ get tagName() {
421
+ return this.element.tagName;
422
+ }
423
+ get _$AU() {
424
+ return this._$AM._$AU;
425
+ }
426
+ constructor(e, t, n, r, i) {
427
+ this.type = 1, this._$AH = D, this._$AN = void 0, this.element = e, this.name = t, this._$AM = r, this.options = i, n.length > 2 || n[0] !== "" || n[1] !== "" ? (this._$AH = Array(n.length - 1).fill(/* @__PURE__ */ new String()), this.strings = n) : this._$AH = D;
428
+ }
429
+ _$AI(e, t = this, n, r) {
430
+ let i = this.strings, a = !1;
431
+ if (i === void 0) e = k(this, e, t, 0), a = !S(e) || e !== this._$AH && e !== E, a && (this._$AH = e);
432
+ else {
433
+ let r = e, o, s;
434
+ for (e = i[0], o = 0; o < i.length - 1; o++) s = k(this, r[n + o], t, o), s === E && (s = this._$AH[o]), a ||= !S(s) || s !== this._$AH[o], s === D ? e = D : e !== D && (e += (s ?? "") + i[o + 1]), this._$AH[o] = s;
435
+ }
436
+ a && !r && this.j(e);
437
+ }
438
+ j(e) {
439
+ e === D ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
440
+ }
441
+ }, De = class extends Ee {
442
+ constructor() {
443
+ super(...arguments), this.type = 3;
444
+ }
445
+ j(e) {
446
+ this.element[this.name] = e === D ? void 0 : e;
447
+ }
448
+ }, Oe = class extends Ee {
449
+ constructor() {
450
+ super(...arguments), this.type = 4;
451
+ }
452
+ j(e) {
453
+ this.element.toggleAttribute(this.name, !!e && e !== D);
454
+ }
455
+ }, ke = class extends Ee {
456
+ constructor(e, t, n, r, i) {
457
+ super(e, t, n, r, i), this.type = 5;
458
+ }
459
+ _$AI(e, t = this) {
460
+ if ((e = k(this, e, t, 0) ?? D) === E) return;
461
+ let n = this._$AH, r = e === D && n !== D || e.capture !== n.capture || e.once !== n.once || e.passive !== n.passive, i = e !== D && (n === D || r);
462
+ r && this.element.removeEventListener(this.name, this, n), i && this.element.addEventListener(this.name, this, e), this._$AH = e;
463
+ }
464
+ handleEvent(e) {
465
+ typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, e) : this._$AH.handleEvent(e);
466
+ }
467
+ }, Ae = class {
468
+ constructor(e, t, n) {
469
+ this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = n;
470
+ }
471
+ get _$AU() {
472
+ return this._$AM._$AU;
473
+ }
474
+ _$AI(e) {
475
+ k(this, e);
476
+ }
477
+ }, je = ae.litHtmlPolyfillSupport;
478
+ je?.(Ce, Te), (ae.litHtmlVersions ??= []).push("3.3.3");
479
+ var Me = (e, t, n) => {
480
+ let r = n?.renderBefore ?? t, i = r._$litPart$;
481
+ if (i === void 0) {
482
+ let e = n?.renderBefore ?? null;
483
+ r._$litPart$ = i = new Te(t.insertBefore(x(), e), e, void 0, n ?? {});
484
+ }
485
+ return i._$AI(e), i;
486
+ }, Ne = globalThis, A = class extends v {
487
+ constructor() {
488
+ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
489
+ }
490
+ createRenderRoot() {
491
+ let e = super.createRenderRoot();
492
+ return this.renderOptions.renderBefore ??= e.firstChild, e;
493
+ }
494
+ update(e) {
495
+ let t = this.render();
496
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(e), this._$Do = Me(t, this.renderRoot, this.renderOptions);
497
+ }
498
+ connectedCallback() {
499
+ super.connectedCallback(), this._$Do?.setConnected(!0);
500
+ }
501
+ disconnectedCallback() {
502
+ super.disconnectedCallback(), this._$Do?.setConnected(!1);
503
+ }
504
+ render() {
505
+ return E;
506
+ }
507
+ };
508
+ A._$litElement$ = !0, A.finalized = !0, Ne.litElementHydrateSupport?.({ LitElement: A });
509
+ var Pe = Ne.litElementPolyfillSupport;
510
+ Pe?.({ LitElement: A }), (Ne.litElementVersions ??= []).push("4.2.2");
511
+ //#endregion
512
+ //#region node_modules/marked/lib/marked.esm.js
513
+ function Fe() {
514
+ return {
515
+ async: !1,
516
+ breaks: !1,
517
+ extensions: null,
518
+ gfm: !0,
519
+ hooks: null,
520
+ pedantic: !1,
521
+ renderer: null,
522
+ silent: !1,
523
+ tokenizer: null,
524
+ walkTokens: null
525
+ };
526
+ }
527
+ var j = Fe();
528
+ function Ie(e) {
529
+ j = e;
530
+ }
531
+ var M = { exec: () => null };
532
+ function N(e) {
533
+ let t = [];
534
+ return (n) => {
535
+ let r = Math.max(0, Math.min(3, n - 1)), i = t[r];
536
+ return i || (i = e(r), t[r] = i), i;
537
+ };
538
+ }
539
+ function P(e, t = "") {
540
+ let n = typeof e == "string" ? e : e.source, r = {
541
+ replace: (e, t) => {
542
+ let i = typeof t == "string" ? t : t.source;
543
+ return i = i.replace(F.caret, "$1"), n = n.replace(e, i), r;
544
+ },
545
+ getRegex: () => new RegExp(n, t)
546
+ };
547
+ return r;
548
+ }
549
+ var Le = ((e = "") => {
550
+ try {
551
+ return !!RegExp("(?<=1)(?<!1)" + e);
552
+ } catch {
553
+ return !1;
554
+ }
555
+ })(), F = {
556
+ codeRemoveIndent: /^(?: {0,3}\t| {1,4})/gm,
557
+ outputLinkReplace: /\\([\[\]])/g,
558
+ indentCodeCompensation: /^(\s+)(?:```)/,
559
+ beginningSpace: /^\s+/,
560
+ endingHash: /#$/,
561
+ startingSpaceChar: /^ /,
562
+ endingSpaceChar: / $/,
563
+ endingSpaceTabChar: /[ \t]$/,
564
+ nonSpaceChar: /[^ ]/,
565
+ newLineCharGlobal: /\n/g,
566
+ tabCharGlobal: /\t/g,
567
+ leadingSpaceTab: /^[ \t]+/,
568
+ multipleSpaceGlobal: /\s+/g,
569
+ blankLine: /^[ \t]*$/,
570
+ doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
571
+ blockquoteStart: /^ {0,3}>/,
572
+ blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
573
+ blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
574
+ listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
575
+ listIsTask: /^\[[ xX]\] +\S/,
576
+ listReplaceTask: /^\[[ xX]\] +/,
577
+ listTaskCheckbox: /\[[ xX]\]/,
578
+ anyLine: /\n.*\n/,
579
+ hrefBrackets: /^<(.*)>$/,
580
+ tableDelimiter: /[:|]/,
581
+ tableAlignChars: /^\||\| *$/g,
582
+ tableRowBlankLine: /\n[ \t]*$/,
583
+ tableAlignRight: /^ *-+: *$/,
584
+ tableAlignCenter: /^ *:-+: *$/,
585
+ tableAlignLeft: /^ *:-+ *$/,
586
+ startATag: /^<a /i,
587
+ endATag: /^<\/a>/i,
588
+ startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
589
+ endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
590
+ startAngleBracket: /^</,
591
+ endAngleBracket: />$/,
592
+ pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
593
+ unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
594
+ numericCharacterReference: /&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,
595
+ numericCharacterReferenceOrAmpersand: /&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
596
+ escapeTest: /[&<>"']/,
597
+ escapeReplace: /[&<>"']/g,
598
+ escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
599
+ escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
600
+ caret: /(^|[^\[])\^/g,
601
+ percentDecode: /%25/g,
602
+ findPipe: /\|/g,
603
+ splitPipe: / \|/,
604
+ slashPipe: /\\\|/g,
605
+ carriageReturn: /\r\n|\r/g,
606
+ spaceLine: /^ +$/gm,
607
+ notSpaceStart: /^\S*/,
608
+ endingNewline: /\n$/,
609
+ listItemRegex: (e) => RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),
610
+ nextBulletRegex: N((e) => RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),
611
+ hrRegex: N((e) => RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),
612
+ fencesBeginRegex: N((e) => RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),
613
+ headingBeginRegex: N((e) => RegExp(`^ {0,${e}}#`)),
614
+ htmlBeginRegex: N((e) => RegExp(`^ {0,${e}}(?:</?(?:${L})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`, "i")),
615
+ blockquoteBeginRegex: N((e) => RegExp(`^ {0,${e}}>`))
616
+ }, Re = /^(?:[ \t]*(?:\n|$))+/, ze = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, Be = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, I = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Ve = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, He = / {0,3}(?:[*+-]|\d{1,9}[.)])/, Ue = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, We = P(Ue).replace(/bull/g, He).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(), Ge = P(Ue).replace(/bull/g, He).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(), Ke = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/, qe = /^[^\n]+/, Je = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, Ye = P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Je).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Xe = P(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, He).getRegex(), L = "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", Ze = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Qe = P("^ {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", Ze).replace("tag", L).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), $e = (e) => P(Ke).replace("hr", I).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", L).getRegex(), et = $e(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/), tt = $e(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/), nt = {
617
+ blockquote: P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", tt).getRegex(),
618
+ code: ze,
619
+ def: Ye,
620
+ fences: Be,
621
+ heading: Ve,
622
+ hr: I,
623
+ html: Qe,
624
+ lheading: We,
625
+ list: Xe,
626
+ newline: Re,
627
+ paragraph: et,
628
+ table: M,
629
+ text: qe
630
+ }, rt = P("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", I).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", L).getRegex(), it = {
631
+ ...nt,
632
+ lheading: Ge,
633
+ table: rt,
634
+ paragraph: P(Ke).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", rt).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", L).getRegex()
635
+ }, at = {
636
+ ...nt,
637
+ html: P("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment", Ze).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(),
638
+ def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
639
+ heading: /^(#{1,6})(.*)(?:\n+|$)/,
640
+ fences: M,
641
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
642
+ paragraph: P(Ke).replace("hr", I).replace("heading", " *#{1,6} *[^\n]").replace("lheading", We).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
643
+ }, ot = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, st = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, ct = /^( {2,}|\\)\n(?!\s*$)[ \t]*/, lt = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, R = /[\p{P}\p{S}]/u, z = /[\s\p{P}\p{S}]/u, B = /[^\s\p{P}\p{S}]/u, ut = P(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, z).getRegex(), dt = /[\p{Pi}\p{Ps}"']/u, ft = /(?!~)[\p{P}\p{S}]/u, pt = /(?!~)[\s\p{P}\p{S}]/u, mt = /(?:[^\s\p{P}\p{S}]|~)/u, ht = P(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Le ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(), gt = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/, _t = P(gt, "u").replace(/punct/g, R).getRegex(), vt = P(gt, "u").replace(/punct/g, ft).getRegex(), yt = P(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/, "u").replace(/openQuote/g, dt).replace(/punct/g, R).getRegex(), bt = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", xt = P(bt, "gu").replace(/notPunctSpace/g, B).replace(/punctSpace/g, z).replace(/punct/g, R).getRegex(), St = P(bt, "gu").replace(/notPunctSpace/g, mt).replace(/punctSpace/g, pt).replace(/punct/g, ft).getRegex(), Ct = P("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, B).replace(/punctSpace/g, z).replace(/punct/g, R).getRegex(), wt = P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, B).replace(/punctSpace/g, z).replace(/punct/g, R).getRegex(), Tt = P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, B).replace(/punctSpace/g, z).replace(/punct/g, R).getRegex(), Et = P(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, R).getRegex(), Dt = P("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, B).replace(/punctSpace/g, z).replace(/punct/g, R).getRegex(), Ot = P(/\\(punct)/, "gu").replace(/punct/g, R).getRegex(), kt = P(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/, "gu").replace(/punct/g, R).getRegex(), At = P(/^<(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(), jt = P(Ze).replace("(?:-->|$)", "-->").getRegex(), Mt = P("^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", jt).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), Nt = /\[(?:\\[\s\S]|[^\[\]\\])*\]/, Pt = P(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets", Nt).getRegex(), Ft = P(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace("label", Pt).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), It = P(/^!?\[(label)\]\[(ref)\]/).replace("label", Pt).replace("ref", Je).getRegex(), Lt = P(/^!?\[(ref)\](?:\[\])?/).replace("ref", Je).getRegex(), Rt = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/, zt = P(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets", Nt).getRegex(), Bt = P("reflink|nolink(?!\\()", "g").replace("reflink", P(/^!?\[(label)\]\[(ref)\]/).replace("label", zt).replace("ref", Rt).getRegex()).replace("nolink", P(/^!?\[(ref)\](?:\[\])?/).replace("ref", Rt).getRegex()).getRegex(), Vt = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, Ht = P(/(?: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(), Ut = {
644
+ _backpedal: M,
645
+ anyPunctuation: Ot,
646
+ anyPunctuationOutsideCode: kt,
647
+ autolink: At,
648
+ blockSkip: ht,
649
+ br: ct,
650
+ code: st,
651
+ del: M,
652
+ delLDelim: M,
653
+ delRDelim: M,
654
+ emStrongLDelim: _t,
655
+ emStrongRDelimAst: xt,
656
+ emStrongRDelimUnd: wt,
657
+ escape: ot,
658
+ link: Ft,
659
+ nolink: Lt,
660
+ punctuation: ut,
661
+ reflink: It,
662
+ reflinkSearch: Bt,
663
+ tag: Mt,
664
+ text: lt,
665
+ url: M
666
+ }, Wt = {
667
+ ...Ut,
668
+ emStrongLDelim: yt,
669
+ emStrongRDelimAst: Ct,
670
+ emStrongRDelimUnd: Tt,
671
+ link: P(/^!?\[(label)\]\((.*?)\)/).replace("label", Pt).getRegex(),
672
+ reflink: P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", Pt).getRegex()
673
+ }, Gt = {
674
+ ...Ut,
675
+ emStrongRDelimAst: St,
676
+ emStrongLDelim: vt,
677
+ delLDelim: Et,
678
+ delRDelim: Dt,
679
+ url: P(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol", Ht).replace("protocol", Vt).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),
680
+ _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
681
+ del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,
682
+ text: P(/^(?:[^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", Vt).replace(/emailProtocol/g, /(?:mailto|xmpp):/).getRegex()
683
+ }, Kt = {
684
+ ...Gt,
685
+ br: P(ct).replace("{2,}", "*").getRegex(),
686
+ text: P(Gt.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
687
+ }, V = {
688
+ normal: nt,
689
+ gfm: it,
690
+ pedantic: at
691
+ }, H = {
692
+ normal: Ut,
693
+ gfm: Gt,
694
+ breaks: Kt,
695
+ pedantic: Wt
696
+ }, qt = {
697
+ "&": "&amp;",
698
+ "<": "&lt;",
699
+ ">": "&gt;",
700
+ "\"": "&quot;",
701
+ "'": "&#39;"
702
+ }, Jt = (e) => qt[e];
703
+ function U(e, t) {
704
+ if (t) {
705
+ if (F.escapeTest.test(e)) return e.replace(F.escapeReplace, Jt);
706
+ } else if (F.escapeTestNoEncode.test(e)) return e.replace(F.escapeReplaceNoEncode, Jt);
707
+ return e;
708
+ }
709
+ function Yt(e) {
710
+ return F.numericCharacterReference.test(e) ? e.replace(F.numericCharacterReferenceOrAmpersand, (e, t, n) => {
711
+ if (t === void 0 && n === void 0) return "&amp;";
712
+ let r = t === void 0 ? Number.parseInt(n, 16) : Number.parseInt(t, 10);
713
+ return r === 0 || r > 1114111 || r >= 55296 && r <= 57343 ? "�" : r === 38 ? "&amp;" : String.fromCodePoint(r);
714
+ }) : e;
715
+ }
716
+ function Xt(e) {
717
+ try {
718
+ e = encodeURI(e).replace(F.percentDecode, "%");
719
+ } catch {
720
+ return null;
721
+ }
722
+ return e;
723
+ }
724
+ function Zt(e, t) {
725
+ let n = e.replace(F.findPipe, (e, t, n) => {
726
+ let r = !1, i = t;
727
+ for (; --i >= 0 && n[i] === "\\";) r = !r;
728
+ return r ? "|" : " |";
729
+ }).split(F.splitPipe), r = 0;
730
+ if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), t) {
731
+ if (n.length > t) n.splice(t);
732
+ else for (; n.length < t;) n.push("");
733
+ }
734
+ for (; r < n.length; r++) n[r] = n[r].trim().replace(F.slashPipe, "|");
735
+ return n;
736
+ }
737
+ function W(e, t, n) {
738
+ let r = e.length;
739
+ if (r === 0) return "";
740
+ let i = 0;
741
+ for (; i < r;) {
742
+ let a = e.charAt(r - i - 1);
743
+ if (a === t && !n) i++;
744
+ else if (a !== t && n) i++;
745
+ else break;
746
+ }
747
+ return e.slice(0, r - i);
748
+ }
749
+ function Qt(e) {
750
+ let t = e.split("\n"), n = t.length - 1;
751
+ for (; n >= 0 && F.blankLine.test(t[n]);) n--;
752
+ return t.length - n <= 2 ? e : t.slice(0, n + 1).join("\n");
753
+ }
754
+ function $t(e) {
755
+ return e.trim().toLowerCase().toUpperCase().toLowerCase();
756
+ }
757
+ function en(e, t) {
758
+ if (e.indexOf(t[0]) === -1 && e.indexOf(t[1]) === -1) return -1;
759
+ let n = 0;
760
+ for (let r = 0; r < e.length; r++) if (e[r] === "\\") r++;
761
+ else if (e[r] === t[0]) n++;
762
+ else if (e[r] === t[1] && (n--, n < 0)) return r;
763
+ return n > 0 ? -2 : -1;
764
+ }
765
+ function tn(e, t = 0) {
766
+ let n = t, r = "";
767
+ for (let t of e) if (t === " ") {
768
+ let e = 4 - n % 4;
769
+ r += " ".repeat(e), n += e;
770
+ } else r += t, n++;
771
+ return r;
772
+ }
773
+ function nn(e, t, n, r, i) {
774
+ 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;
775
+ r.state.inLink = !0, r.state.linkEmitted = !1;
776
+ let f = r.inlineTokens(s), p = r.state.linkEmitted;
777
+ if (r.state.linkEmitted = u, r.state.inLink = l, !c) {
778
+ if (p) {
779
+ r.state.inRawBlock = d;
780
+ return;
781
+ }
782
+ r.state.linkEmitted = !0;
783
+ }
784
+ return {
785
+ type: c ? "image" : "link",
786
+ raw: n,
787
+ href: a,
788
+ title: o,
789
+ text: s,
790
+ tokens: f
791
+ };
792
+ }
793
+ function rn(e, t, n) {
794
+ let r = e.match(n.other.indentCodeCompensation);
795
+ if (r === null) return t;
796
+ let i = r[1];
797
+ return t.split("\n").map((e) => {
798
+ let t = e.match(n.other.beginningSpace);
799
+ if (t === null) return e;
800
+ let [r] = t;
801
+ return e.slice(Math.min(r.length, i.length));
802
+ }).join("\n");
803
+ }
804
+ function an(e, t, n, r) {
805
+ if (!t.includes("<")) return !1;
806
+ for (let i = 0; i < t.length; i++) {
807
+ if (t[i] === "\\") {
808
+ i++;
809
+ continue;
810
+ }
811
+ if (t[i] === "`") {
812
+ let e = r.inline.code.exec(t.slice(i));
813
+ if (e) {
814
+ i += e[0].length - 1;
815
+ continue;
816
+ }
817
+ }
818
+ if (t[i] !== "<") continue;
819
+ let a = e.slice(n + i), o = r.inline.tag.exec(a) || r.inline.autolink.exec(a);
820
+ if (o) {
821
+ if (o[0].length > t.length - i) return !0;
822
+ i += o[0].length - 1;
823
+ }
824
+ }
825
+ return !1;
826
+ }
827
+ var on = class {
828
+ options;
829
+ rules;
830
+ lexer;
831
+ constructor(e) {
832
+ this.options = e || j;
833
+ }
834
+ space(e) {
835
+ let t = this.rules.block.newline.exec(e);
836
+ if (t && t[0].length > 0) return {
837
+ type: "space",
838
+ raw: t[0]
839
+ };
840
+ }
841
+ code(e) {
842
+ let t = this.rules.block.code.exec(e);
843
+ if (t) {
844
+ let e = this.options.pedantic ? t[0] : Qt(t[0]);
845
+ return {
846
+ type: "code",
847
+ raw: e,
848
+ codeBlockStyle: "indented",
849
+ text: e.replace(this.rules.other.codeRemoveIndent, "")
850
+ };
851
+ }
852
+ }
853
+ fences(e) {
854
+ let t = this.rules.block.fences.exec(e);
855
+ if (t) {
856
+ let e = t[0], n = rn(e, t[3] || "", this.rules);
857
+ return {
858
+ type: "code",
859
+ raw: e,
860
+ lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2],
861
+ text: n
862
+ };
863
+ }
864
+ }
865
+ heading(e) {
866
+ let t = this.rules.block.heading.exec(e);
867
+ if (t) {
868
+ let e = t[2].trim();
869
+ if (this.rules.other.endingHash.test(e)) {
870
+ let t = W(e, "#");
871
+ (this.options.pedantic || !t || this.rules.other.endingSpaceTabChar.test(t)) && (e = t.trim());
872
+ }
873
+ return {
874
+ type: "heading",
875
+ raw: W(t[0], "\n"),
876
+ depth: t[1].length,
877
+ text: e,
878
+ tokens: this.lexer.inline(e)
879
+ };
880
+ }
881
+ }
882
+ hr(e) {
883
+ let t = this.rules.block.hr.exec(e);
884
+ if (t) return {
885
+ type: "hr",
886
+ raw: W(t[0], "\n")
887
+ };
888
+ }
889
+ blockquote(e) {
890
+ let t = this.rules.block.blockquote.exec(e);
891
+ if (t) {
892
+ let e = W(t[0], "\n").split("\n"), n = "", r = "", i = [];
893
+ for (; e.length > 0;) {
894
+ let t = !1, a = [], o = 0;
895
+ for (; o < e.length; o++) if (this.rules.other.blockquoteStart.test(e[o])) a.push(e[o]), t = !0;
896
+ else if (!t) a.push(e[o]);
897
+ else break;
898
+ e = e.slice(o);
899
+ let s = a.join("\n"), c = s.replace(this.rules.other.blockquoteSetextReplace, "\n $1").replace(this.rules.other.blockquoteSetextReplace2, "");
900
+ n = n ? `${n}
901
+ ${s}` : s, r = r ? `${r}
902
+ ${c}` : c;
903
+ let l = this.lexer.state.top;
904
+ if (this.lexer.state.top = !0, this.lexer.blockTokens(c, i, !0), this.lexer.state.top = l, e.length === 0) break;
905
+ let u = i.at(-1);
906
+ if (u?.type === "code" || u?.type === "heading" || u?.type === "hr" || u?.type === "html") break;
907
+ if (u?.type === "blockquote") {
908
+ let t = u, a = e.join("\n"), o = t.raw + "\n" + a.replace(this.rules.other.blockquoteSetextReplace2, ""), s = this.blockquote(o);
909
+ i[i.length - 1] = s;
910
+ let c = o.substring(s.raw.length).replace(/^\n/, ""), l = c ? c.split("\n").length : 0, d = l ? e.slice(0, -l) : e;
911
+ d.length > 0 && (n = `${n}
912
+ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
913
+ break;
914
+ }
915
+ if (u?.type === "list") {
916
+ let t = u, a = t.raw + "\n" + e.join("\n"), o = this.list(a);
917
+ 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("\n");
918
+ continue;
919
+ }
920
+ }
921
+ return {
922
+ type: "blockquote",
923
+ raw: n,
924
+ tokens: i,
925
+ text: r
926
+ };
927
+ }
928
+ }
929
+ list(e) {
930
+ let t = this.rules.block.list.exec(e);
931
+ if (t) {
932
+ let n = e, r = () => n.length - e.length, i = t[1].trim(), a = i.length > 1, o = {
933
+ type: "list",
934
+ raw: "",
935
+ ordered: a,
936
+ start: a ? +i.slice(0, -1) : "",
937
+ loose: !1,
938
+ items: []
939
+ };
940
+ i = a ? `\\d{1,9}\\${i.slice(-1)}` : `\\${i}`, this.options.pedantic && (i = a ? i : "[*+-]");
941
+ let s = this.rules.other.listItemRegex(i), c = !1;
942
+ for (; e;) {
943
+ let i = !1, a = "";
944
+ if (!(t = s.exec(e)) || this.rules.block.hr.test(e)) break;
945
+ let l = r();
946
+ e = e.substring(t[0].length);
947
+ let u = t[2].split("\n", 1)[0], d = t[1].length, f = this.options.pedantic ? tn(u, d) : u.replace(this.rules.other.leadingSpaceTab, (e) => tn(e, d)), p = e.split("\n", 1)[0], m = !f.trim(), h = 0;
948
+ 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) {
949
+ 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);
950
+ for (; e;) {
951
+ let c = e.split("\n", 1)[0], l;
952
+ if (p = c, this.options.pedantic ? (p = p.replace(this.rules.other.listReplaceNesting, " "), l = p) : l = p.replace(this.rules.other.leadingSpaceTab, (e) => tn(e)), r.test(p) || i.test(p) || o.test(p) || s.test(p) || t.test(p) || n.test(p)) break;
953
+ if (l.search(this.rules.other.nonSpaceChar) >= h || !p.trim()) a += "\n" + l.slice(h);
954
+ else {
955
+ if (m || f.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || r.test(f) || i.test(f) || n.test(f)) break;
956
+ a += "\n" + p;
957
+ }
958
+ m = !p.trim(), e = e.substring(c.length + 1), f = l.slice(h);
959
+ }
960
+ }
961
+ let g = n.slice(l, r());
962
+ o.loose || (c ? o.loose = !0 : this.rules.other.doubleBlankLine.test(g) && (c = !0)), o.items.push({
963
+ type: "list_item",
964
+ raw: g,
965
+ task: !!this.options.gfm && this.rules.other.listIsTask.test(a),
966
+ loose: !1,
967
+ text: a,
968
+ tokens: []
969
+ });
970
+ }
971
+ let l = o.items.at(-1);
972
+ if (l) l.raw = l.raw.trimEnd(), l.text = l.text.trimEnd();
973
+ else return;
974
+ o.raw = n.slice(0, r()).trimEnd();
975
+ for (let e of o.items) if (this.lexer.state.top = !1, e.tokens = this.lexer.blockTokens(e.text, []), !o.loose) {
976
+ let t = e.tokens.filter((e) => e.type === "space");
977
+ o.loose = t.length > 0 && t.some((e) => this.rules.other.anyLine.test(e.raw));
978
+ }
979
+ for (let e of o.items) {
980
+ let t = e.tokens[0];
981
+ if (e.task && (t?.type === "text" || t?.type === "paragraph")) {
982
+ 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, "");
983
+ for (let e = this.lexer.inlineQueue.length - 1; e >= 0; e--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)) {
984
+ this.lexer.inlineQueue[e].src = this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask, "");
985
+ break;
986
+ }
987
+ let n = this.rules.other.listTaskCheckbox.exec(e.raw);
988
+ if (n) {
989
+ let t = {
990
+ type: "checkbox",
991
+ raw: n[0] + " ",
992
+ checked: n[0] !== "[ ]"
993
+ };
994
+ 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({
995
+ type: "paragraph",
996
+ raw: t.raw,
997
+ text: t.raw,
998
+ tokens: [t]
999
+ }) : e.tokens.unshift(t);
1000
+ }
1001
+ } else e.task &&= !1;
1002
+ }
1003
+ if (o.loose) for (let e of o.items) {
1004
+ e.loose = !0;
1005
+ for (let t of e.tokens) t.type === "text" && (t.type = "paragraph");
1006
+ }
1007
+ return o;
1008
+ }
1009
+ }
1010
+ html(e) {
1011
+ let t = this.rules.block.html.exec(e);
1012
+ if (t) {
1013
+ let e = Qt(t[0]);
1014
+ return {
1015
+ type: "html",
1016
+ block: !0,
1017
+ raw: e,
1018
+ pre: t[1] === "pre" || t[1] === "script" || t[1] === "style",
1019
+ text: e
1020
+ };
1021
+ }
1022
+ }
1023
+ def(e) {
1024
+ let t = this.rules.block.def.exec(e);
1025
+ if (t) {
1026
+ if (!this.rules.other.startAngleBracket.test(t[2]) && en(t[2], "()") !== -1) return;
1027
+ let e = $t(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];
1028
+ return {
1029
+ type: "def",
1030
+ tag: e,
1031
+ raw: W(t[0], "\n"),
1032
+ href: n,
1033
+ title: r
1034
+ };
1035
+ }
1036
+ }
1037
+ table(e) {
1038
+ let t = this.rules.block.table.exec(e);
1039
+ if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
1040
+ let n = Zt(t[1]), r = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), i = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [], a = {
1041
+ type: "table",
1042
+ raw: W(t[0], "\n"),
1043
+ header: [],
1044
+ align: [],
1045
+ rows: []
1046
+ };
1047
+ if (n.length === r.length) {
1048
+ 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);
1049
+ for (let e = 0; e < n.length; e++) a.header.push({
1050
+ text: n[e],
1051
+ tokens: this.lexer.inline(n[e]),
1052
+ header: !0,
1053
+ align: a.align[e]
1054
+ });
1055
+ for (let e of i) a.rows.push(Zt(e, a.header.length).map((e, t) => ({
1056
+ text: e,
1057
+ tokens: this.lexer.inline(e),
1058
+ header: !1,
1059
+ align: a.align[t]
1060
+ })));
1061
+ return a;
1062
+ }
1063
+ }
1064
+ lheading(e) {
1065
+ let t = this.rules.block.lheading.exec(e);
1066
+ if (t) {
1067
+ let e = t[1].trim();
1068
+ return {
1069
+ type: "heading",
1070
+ raw: W(t[0], "\n"),
1071
+ depth: t[2].charAt(0) === "=" ? 1 : 2,
1072
+ text: e,
1073
+ tokens: this.lexer.inline(e)
1074
+ };
1075
+ }
1076
+ }
1077
+ paragraph(e) {
1078
+ let t = this.rules.block.paragraph.exec(e);
1079
+ if (t) {
1080
+ let e = t[1].charAt(t[1].length - 1) === "\n" ? t[1].slice(0, -1) : t[1];
1081
+ return {
1082
+ type: "paragraph",
1083
+ raw: t[0],
1084
+ text: e,
1085
+ tokens: this.lexer.inline(e)
1086
+ };
1087
+ }
1088
+ }
1089
+ text(e) {
1090
+ let t = this.rules.block.text.exec(e);
1091
+ if (t) return {
1092
+ type: "text",
1093
+ raw: t[0],
1094
+ text: t[0],
1095
+ tokens: this.lexer.inline(t[0])
1096
+ };
1097
+ }
1098
+ escape(e) {
1099
+ let t = this.rules.inline.escape.exec(e);
1100
+ if (t) return {
1101
+ type: "escape",
1102
+ raw: t[0],
1103
+ text: t[1]
1104
+ };
1105
+ }
1106
+ tag(e) {
1107
+ let t = this.rules.inline.tag.exec(e);
1108
+ 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), {
1109
+ type: "html",
1110
+ raw: t[0],
1111
+ inLink: this.lexer.state.inLink,
1112
+ inRawBlock: this.lexer.state.inRawBlock,
1113
+ block: !1,
1114
+ text: t[0]
1115
+ };
1116
+ }
1117
+ link(e) {
1118
+ if (this.lexer.state.linkParenPossible === !1) return;
1119
+ let t = this.rules.inline.link.exec(e);
1120
+ if (t) {
1121
+ let n = t[0].charAt(0) === "!" ? 2 : 1;
1122
+ if (!this.options.pedantic && an(e, t[1], n, this.rules)) return;
1123
+ let r = t[2].trim();
1124
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(r)) {
1125
+ if (!this.rules.other.endAngleBracket.test(r)) return;
1126
+ let e = W(r.slice(0, -1), "\\");
1127
+ if ((r.length - e.length) % 2 == 0) return;
1128
+ } else {
1129
+ let e = en(t[2], "()");
1130
+ if (e === -2) return;
1131
+ if (e > -1) {
1132
+ let n = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + e;
1133
+ t[2] = t[2].substring(0, e), t[0] = t[0].substring(0, n).trim(), t[3] = "";
1134
+ }
1135
+ }
1136
+ let i = t[2], a = "";
1137
+ if (this.options.pedantic) {
1138
+ let e = this.rules.other.pedanticHrefTitle.exec(i);
1139
+ e && (i = e[1], a = e[3]);
1140
+ } else a = t[3] ? t[3].slice(1, -1) : "";
1141
+ 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)), nn(t, {
1142
+ href: i && i.replace(this.rules.inline.anyPunctuation, "$1"),
1143
+ title: a && a.replace(this.rules.inline.anyPunctuation, "$1")
1144
+ }, t[0], this.lexer, this.rules);
1145
+ }
1146
+ }
1147
+ reflink(e, t) {
1148
+ let n;
1149
+ if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
1150
+ let r = n[0].charAt(0) === "!" ? 2 : 1;
1151
+ if (!this.options.pedantic && an(e, n[1], r, this.rules)) return;
1152
+ let i = t[$t((n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "))];
1153
+ if (!i) {
1154
+ let e = n[0].charAt(0);
1155
+ return {
1156
+ type: "text",
1157
+ raw: e,
1158
+ text: e
1159
+ };
1160
+ }
1161
+ return nn(n, i, n[0], this.lexer, this.rules);
1162
+ }
1163
+ }
1164
+ emStrong(e, t, n = "") {
1165
+ let r = this.rules.inline.emStrongLDelim.exec(e);
1166
+ 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))) {
1167
+ 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;
1168
+ for (d.lastIndex = 0, t = t.slice(-1 * e.length + i); (r = d.exec(t)) !== null;) {
1169
+ if (a = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !a) continue;
1170
+ if (o = [...a].length, r[3] || r[4]) {
1171
+ s += o;
1172
+ continue;
1173
+ }
1174
+ if (r[5] || r[6]) {
1175
+ if (i % 3 && !((i + o) % 3)) {
1176
+ c += o;
1177
+ continue;
1178
+ }
1179
+ if (u) break;
1180
+ }
1181
+ if (s -= o, s > 0) continue;
1182
+ o = Math.min(o, o + s + c);
1183
+ let t = [...r[0]][0].length, n = e.slice(0, i + r.index + t + o);
1184
+ if (Math.min(i, o) % 2) {
1185
+ let e = n.slice(1, -1);
1186
+ return {
1187
+ type: "em",
1188
+ raw: n,
1189
+ text: e,
1190
+ tokens: this.lexer.inlineTokens(e)
1191
+ };
1192
+ }
1193
+ let l = n.slice(2, -2);
1194
+ return {
1195
+ type: "strong",
1196
+ raw: n,
1197
+ text: l,
1198
+ tokens: this.lexer.inlineTokens(l)
1199
+ };
1200
+ }
1201
+ }
1202
+ }
1203
+ codespan(e) {
1204
+ let t = this.rules.inline.code.exec(e);
1205
+ if (t) {
1206
+ 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);
1207
+ return n && r && (e = e.substring(1, e.length - 1)), {
1208
+ type: "codespan",
1209
+ raw: t[0],
1210
+ text: e
1211
+ };
1212
+ }
1213
+ }
1214
+ br(e) {
1215
+ let t = this.rules.inline.br.exec(e);
1216
+ if (t) return {
1217
+ type: "br",
1218
+ raw: t[0]
1219
+ };
1220
+ }
1221
+ del(e, t, n = "") {
1222
+ let r = this.rules.inline.delLDelim.exec(e);
1223
+ if (r && (!r[1] || !n || this.rules.inline.punctuation.exec(n))) {
1224
+ let n = [...r[0]].length - 1, i, a, o = n, s = this.rules.inline.delRDelim;
1225
+ for (s.lastIndex = 0, t = t.slice(-1 * e.length + n); (r = s.exec(t)) !== null;) {
1226
+ if (i = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !i || (a = [...i].length, a !== n)) continue;
1227
+ if (r[3] || r[4]) {
1228
+ o += a;
1229
+ continue;
1230
+ }
1231
+ if (o -= a, o > 0) continue;
1232
+ a = Math.min(a, a + o);
1233
+ let t = [...r[0]][0].length, s = e.slice(0, n + r.index + t + a), c = s.slice(n, -n);
1234
+ return {
1235
+ type: "del",
1236
+ raw: s,
1237
+ text: c,
1238
+ tokens: this.lexer.inlineTokens(c)
1239
+ };
1240
+ }
1241
+ }
1242
+ }
1243
+ autolink(e) {
1244
+ let t = this.rules.inline.autolink.exec(e);
1245
+ if (t) {
1246
+ let e, n;
1247
+ return t[2] === "@" ? (e = t[1], n = "mailto:" + e) : (e = t[1], n = e), {
1248
+ type: "link",
1249
+ raw: t[0],
1250
+ text: e,
1251
+ href: n,
1252
+ autolink: !0,
1253
+ tokens: [{
1254
+ type: "text",
1255
+ raw: e,
1256
+ text: e
1257
+ }]
1258
+ };
1259
+ }
1260
+ }
1261
+ url(e) {
1262
+ let t;
1263
+ if (t = this.rules.inline.url.exec(e)) {
1264
+ let e, n;
1265
+ if (t[2] === "@") e = t[0], n = "mailto:" + e;
1266
+ else {
1267
+ let r;
1268
+ do
1269
+ r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
1270
+ while (r !== t[0]);
1271
+ e = t[0], n = t[1] === "www." ? "http://" + t[0] : t[0];
1272
+ }
1273
+ return {
1274
+ type: "link",
1275
+ raw: t[0],
1276
+ text: e,
1277
+ href: n,
1278
+ autolink: !0,
1279
+ tokens: [{
1280
+ type: "text",
1281
+ raw: e,
1282
+ text: e
1283
+ }]
1284
+ };
1285
+ }
1286
+ }
1287
+ inlineText(e) {
1288
+ let t = this.rules.inline.text.exec(e);
1289
+ if (t) {
1290
+ let e = this.lexer.state.inRawBlock;
1291
+ return {
1292
+ type: "text",
1293
+ raw: t[0],
1294
+ text: e ? t[0] : Yt(t[0]),
1295
+ escaped: e
1296
+ };
1297
+ }
1298
+ }
1299
+ }, G = class e {
1300
+ tokens;
1301
+ options;
1302
+ state;
1303
+ inlineQueue;
1304
+ tokenizer;
1305
+ constructor(e) {
1306
+ this.tokens = [], this.tokens.links = Object.create(null), this.options = e || j, this.options.tokenizer = this.options.tokenizer || new on(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
1307
+ inLink: !1,
1308
+ inRawBlock: !1,
1309
+ linkEmitted: !1,
1310
+ linkParenPossible: !0,
1311
+ top: !0
1312
+ };
1313
+ let t = {
1314
+ other: F,
1315
+ block: V.normal,
1316
+ inline: H.normal
1317
+ };
1318
+ this.options.pedantic ? (t.block = V.pedantic, t.inline = H.pedantic) : this.options.gfm && (t.block = V.gfm, t.inline = this.options.breaks ? H.breaks : H.gfm), this.tokenizer.rules = t;
1319
+ }
1320
+ static get rules() {
1321
+ return {
1322
+ block: V,
1323
+ inline: H
1324
+ };
1325
+ }
1326
+ static lex(t, n) {
1327
+ return new e(n).lex(t);
1328
+ }
1329
+ static lexInline(t, n) {
1330
+ return new e(n).inlineTokens(t);
1331
+ }
1332
+ lex(e) {
1333
+ e = e.replace(F.carriageReturn, "\n"), this.blockTokens(e, this.tokens);
1334
+ for (let e = 0; e < this.inlineQueue.length; e++) {
1335
+ let t = this.inlineQueue[e];
1336
+ this.inlineTokens(t.src, t.tokens);
1337
+ }
1338
+ return this.inlineQueue = [], this.tokens;
1339
+ }
1340
+ blockTokens(e, t = [], n = !1) {
1341
+ this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(F.tabCharGlobal, " ").replace(F.spaceLine, ""));
1342
+ let r = 1 / 0;
1343
+ for (; e;) {
1344
+ if (e.length < r) r = e.length;
1345
+ else {
1346
+ this.infiniteLoopError(e.charCodeAt(0));
1347
+ break;
1348
+ }
1349
+ let i;
1350
+ 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;
1351
+ if (i = this.tokenizer.space(e)) {
1352
+ e = e.substring(i.raw.length);
1353
+ let n = t.at(-1);
1354
+ i.raw.length === 1 && n !== void 0 ? n.raw += "\n" : t.push(i);
1355
+ continue;
1356
+ }
1357
+ if (i = this.tokenizer.code(e)) {
1358
+ e = e.substring(i.raw.length);
1359
+ let n = t.at(-1);
1360
+ n?.type === "paragraph" || n?.type === "text" ? (n.raw += (n.raw.endsWith("\n") ? "" : "\n") + i.raw, n.text += "\n" + i.text, this.inlineQueue.at(-1).src = n.text) : t.push(i);
1361
+ continue;
1362
+ }
1363
+ if (i = this.tokenizer.fences(e)) {
1364
+ e = e.substring(i.raw.length), t.push(i);
1365
+ continue;
1366
+ }
1367
+ if (i = this.tokenizer.heading(e)) {
1368
+ e = e.substring(i.raw.length), t.push(i);
1369
+ continue;
1370
+ }
1371
+ if (i = this.tokenizer.hr(e)) {
1372
+ e = e.substring(i.raw.length), t.push(i);
1373
+ continue;
1374
+ }
1375
+ if (i = this.tokenizer.blockquote(e)) {
1376
+ e = e.substring(i.raw.length), t.push(i);
1377
+ continue;
1378
+ }
1379
+ if (i = this.tokenizer.list(e)) {
1380
+ e = e.substring(i.raw.length), t.push(i);
1381
+ continue;
1382
+ }
1383
+ if (i = this.tokenizer.html(e)) {
1384
+ e = e.substring(i.raw.length), t.push(i);
1385
+ continue;
1386
+ }
1387
+ if (i = this.tokenizer.def(e)) {
1388
+ e = e.substring(i.raw.length);
1389
+ let n = t.at(-1);
1390
+ n?.type === "paragraph" || n?.type === "text" ? (n.raw += (n.raw.endsWith("\n") ? "" : "\n") + i.raw, n.text += "\n" + i.raw, this.inlineQueue.at(-1).src = n.text) : this.tokens.links[i.tag] || (this.tokens.links[i.tag] = {
1391
+ href: i.href,
1392
+ title: i.title
1393
+ }, t.push(i));
1394
+ continue;
1395
+ }
1396
+ if (i = this.tokenizer.table(e)) {
1397
+ e = e.substring(i.raw.length), t.push(i);
1398
+ continue;
1399
+ }
1400
+ if (i = this.tokenizer.lheading(e)) {
1401
+ e = e.substring(i.raw.length), t.push(i);
1402
+ continue;
1403
+ }
1404
+ let a = e;
1405
+ if (this.options.extensions?.startBlock) {
1406
+ let t = 1 / 0, n = e.slice(1), r;
1407
+ this.options.extensions.startBlock.forEach((e) => {
1408
+ r = e.call({ lexer: this }, n), typeof r == "number" && r >= 0 && (t = Math.min(t, r));
1409
+ }), t < 1 / 0 && t >= 0 && (a = e.substring(0, t + 1));
1410
+ }
1411
+ if (this.state.top && (i = this.tokenizer.paragraph(a))) {
1412
+ let r = t.at(-1);
1413
+ n && r?.type === "paragraph" ? (r.raw += (r.raw.endsWith("\n") ? "" : "\n") + i.raw, r.text += "\n" + 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);
1414
+ continue;
1415
+ }
1416
+ if (i = this.tokenizer.text(e)) {
1417
+ e = e.substring(i.raw.length);
1418
+ let n = t.at(-1);
1419
+ n?.type === "text" ? (n.raw += (n.raw.endsWith("\n") ? "" : "\n") + i.raw, n.text += "\n" + i.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = n.text) : t.push(i);
1420
+ continue;
1421
+ }
1422
+ if (e) {
1423
+ this.infiniteLoopError(e.charCodeAt(0));
1424
+ break;
1425
+ }
1426
+ }
1427
+ return this.state.top = !0, t;
1428
+ }
1429
+ inline(e, t = []) {
1430
+ return this.inlineQueue.push({
1431
+ src: e,
1432
+ tokens: t
1433
+ }), t;
1434
+ }
1435
+ linkInText(e) {
1436
+ if (!e.includes("[")) return !1;
1437
+ let t = this.tokenizer.rules.inline.link;
1438
+ for (let n of e.matchAll(this.tokenizer.rules.inline.blockSkip)) if (t.test(n[0]) && e.charAt(n.index - 1) !== "!") return !0;
1439
+ for (let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)) {
1440
+ let e = t[0], n = e.lastIndexOf("[");
1441
+ if (e.charAt(0) !== "!" && Object.hasOwn(this.tokens.links, $t(e.slice(n + 1, -1))) && !(n > 1 && this.linkInText(e.slice(1, n - 1)))) return !0;
1442
+ }
1443
+ return !1;
1444
+ }
1445
+ inlineTokens(e, t = []) {
1446
+ this.tokenizer.lexer = this;
1447
+ let n = this.state.linkParenPossible;
1448
+ this.state.linkParenPossible = n && e.includes(")");
1449
+ try {
1450
+ return this.#e(e, t);
1451
+ } finally {
1452
+ this.state.linkParenPossible = n;
1453
+ }
1454
+ }
1455
+ #e(e, t) {
1456
+ let n = e;
1457
+ if (this.tokens.links && e.includes("[")) {
1458
+ let e = this.tokenizer.rules.inline.reflinkSearch, t = (n) => {
1459
+ let r = n.lastIndexOf("[");
1460
+ if (!Object.hasOwn(this.tokens.links, $t(n.slice(r + 1, -1)))) return n;
1461
+ if (r > 1 && n.charAt(0) !== "!") {
1462
+ let i = n.slice(1, r - 1);
1463
+ if (this.linkInText(i)) return "[" + i.replace(e, t) + "][" + "a".repeat(n.length - r - 2) + "]";
1464
+ }
1465
+ return "[" + "a".repeat(n.length - 2) + "]";
1466
+ };
1467
+ n = n.replace(e, t);
1468
+ }
1469
+ 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) => {
1470
+ let r = n ? n.length : 0;
1471
+ return e.slice(0, r) + "[" + "a".repeat(e.length - r - 2) + "]";
1472
+ }), n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
1473
+ let r = !1, i = "", a = 1 / 0;
1474
+ for (; e;) {
1475
+ if (e.length < a) a = e.length;
1476
+ else {
1477
+ this.infiniteLoopError(e.charCodeAt(0));
1478
+ break;
1479
+ }
1480
+ r || (i = ""), r = !1;
1481
+ let o;
1482
+ 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;
1483
+ if (o = this.tokenizer.escape(e)) {
1484
+ e = e.substring(o.raw.length), t.push(o);
1485
+ continue;
1486
+ }
1487
+ if (o = this.tokenizer.tag(e)) {
1488
+ e = e.substring(o.raw.length), t.push(o);
1489
+ continue;
1490
+ }
1491
+ if (o = this.tokenizer.link(e)) {
1492
+ e = e.substring(o.raw.length), t.push(o);
1493
+ continue;
1494
+ }
1495
+ if (o = this.tokenizer.reflink(e, this.tokens.links)) {
1496
+ e = e.substring(o.raw.length);
1497
+ let n = t.at(-1);
1498
+ o.type === "text" && n?.type === "text" ? (n.raw += o.raw, n.text += o.text) : t.push(o);
1499
+ continue;
1500
+ }
1501
+ if (o = this.tokenizer.emStrong(e, n, i)) {
1502
+ e = e.substring(o.raw.length), t.push(o);
1503
+ continue;
1504
+ }
1505
+ if (o = this.tokenizer.codespan(e)) {
1506
+ e = e.substring(o.raw.length), t.push(o);
1507
+ continue;
1508
+ }
1509
+ if (o = this.tokenizer.br(e)) {
1510
+ e = e.substring(o.raw.length), t.push(o);
1511
+ continue;
1512
+ }
1513
+ if (o = this.tokenizer.del(e, n, i)) {
1514
+ e = e.substring(o.raw.length), t.push(o);
1515
+ continue;
1516
+ }
1517
+ if (o = this.tokenizer.autolink(e)) {
1518
+ e = e.substring(o.raw.length), t.push(o);
1519
+ continue;
1520
+ }
1521
+ if (!this.state.inLink && (o = this.tokenizer.url(e))) {
1522
+ e = e.substring(o.raw.length), t.push(o);
1523
+ continue;
1524
+ }
1525
+ let s = e;
1526
+ if (this.options.extensions?.startInline) {
1527
+ let t = 1 / 0, n = e.slice(1), r;
1528
+ this.options.extensions.startInline.forEach((e) => {
1529
+ r = e.call({ lexer: this }, n), typeof r == "number" && r >= 0 && (t = Math.min(t, r));
1530
+ }), t < 1 / 0 && t >= 0 && (s = e.substring(0, t + 1));
1531
+ }
1532
+ if (o = this.tokenizer.inlineText(s)) {
1533
+ e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (i = o.raw.slice(-1)), r = !0;
1534
+ let n = t.at(-1);
1535
+ n?.type === "text" ? (n.raw += o.raw, n.text += o.text) : t.push(o);
1536
+ continue;
1537
+ }
1538
+ if (e) {
1539
+ this.infiniteLoopError(e.charCodeAt(0));
1540
+ break;
1541
+ }
1542
+ }
1543
+ return t;
1544
+ }
1545
+ infiniteLoopError(e) {
1546
+ let t = "Infinite loop on byte: " + e;
1547
+ if (this.options.silent) console.error(t);
1548
+ else throw Error(t);
1549
+ }
1550
+ }, sn = class {
1551
+ options;
1552
+ parser;
1553
+ constructor(e) {
1554
+ this.options = e || j;
1555
+ }
1556
+ space(e) {
1557
+ return "";
1558
+ }
1559
+ code({ text: e, lang: t, escaped: n }) {
1560
+ let r = (t || "").match(F.notSpaceStart)?.[0], i = e ? e.replace(F.endingNewline, "") + "\n" : "";
1561
+ return r ? "<pre><code class=\"language-" + U(r) + "\">" + (n ? i : U(i, !0)) + "</code></pre>\n" : "<pre><code>" + (n ? i : U(i, !0)) + "</code></pre>\n";
1562
+ }
1563
+ blockquote({ tokens: e }) {
1564
+ return `<blockquote>
1565
+ ${this.parser.parse(e)}</blockquote>
1566
+ `;
1567
+ }
1568
+ html({ text: e }) {
1569
+ return e;
1570
+ }
1571
+ def(e) {
1572
+ return "";
1573
+ }
1574
+ heading({ tokens: e, depth: t }) {
1575
+ return `<h${t}>${this.parser.parseInline(e)}</h${t}>
1576
+ `;
1577
+ }
1578
+ hr(e) {
1579
+ return "<hr>\n";
1580
+ }
1581
+ list(e) {
1582
+ let t = e.ordered, n = e.start, r = "";
1583
+ for (let t = 0; t < e.items.length; t++) {
1584
+ let n = e.items[t];
1585
+ r += this.listitem(n);
1586
+ }
1587
+ let i = t ? "ol" : "ul", a = t && n !== 1 ? " start=\"" + n + "\"" : "";
1588
+ return "<" + i + a + ">\n" + r + "</" + i + ">\n";
1589
+ }
1590
+ listitem(e) {
1591
+ return `<li>${this.parser.parse(e.tokens)}</li>
1592
+ `;
1593
+ }
1594
+ checkbox({ checked: e }) {
1595
+ return "<input " + (e ? "checked=\"\" " : "") + "disabled=\"\" type=\"checkbox\"> ";
1596
+ }
1597
+ paragraph({ tokens: e }) {
1598
+ return `<p>${this.parser.parseInline(e)}</p>
1599
+ `;
1600
+ }
1601
+ table(e) {
1602
+ let t = "", n = "";
1603
+ for (let t = 0; t < e.header.length; t++) n += this.tablecell(e.header[t]);
1604
+ t += this.tablerow({ text: n });
1605
+ let r = "";
1606
+ for (let t = 0; t < e.rows.length; t++) {
1607
+ let i = e.rows[t];
1608
+ n = "";
1609
+ for (let e = 0; e < i.length; e++) n += this.tablecell(i[e]);
1610
+ r += this.tablerow({ text: n });
1611
+ }
1612
+ return r &&= `<tbody>${r}</tbody>`, "<table>\n<thead>\n" + t + "</thead>\n" + r + "</table>\n";
1613
+ }
1614
+ tablerow({ text: e }) {
1615
+ return `<tr>
1616
+ ${e}</tr>
1617
+ `;
1618
+ }
1619
+ tablecell(e) {
1620
+ let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
1621
+ return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
1622
+ `;
1623
+ }
1624
+ strong({ tokens: e }) {
1625
+ return `<strong>${this.parser.parseInline(e)}</strong>`;
1626
+ }
1627
+ em({ tokens: e }) {
1628
+ return `<em>${this.parser.parseInline(e)}</em>`;
1629
+ }
1630
+ codespan({ text: e }) {
1631
+ return `<code>${U(e, !0)}</code>`;
1632
+ }
1633
+ br(e) {
1634
+ return "<br>";
1635
+ }
1636
+ del({ tokens: e }) {
1637
+ return `<del>${this.parser.parseInline(e)}</del>`;
1638
+ }
1639
+ link({ href: e, title: t, text: n, tokens: r, autolink: i }) {
1640
+ let a = i ? U(n, !0) : this.parser.parseInline(r), o = Xt(e);
1641
+ if (o === null) return a;
1642
+ e = U(o, i);
1643
+ let s = "<a href=\"" + e + "\"";
1644
+ return t && (s += " title=\"" + U(t) + "\""), s += ">" + a + "</a>", s;
1645
+ }
1646
+ image({ href: e, title: t, text: n, tokens: r }) {
1647
+ r && (n = this.parser.parseInline(r, this.parser.textRenderer));
1648
+ let i = Xt(e);
1649
+ if (i === null) return U(n);
1650
+ e = i;
1651
+ let a = `<img src="${U(e)}" alt="${U(n)}"`;
1652
+ return t && (a += ` title="${U(t)}"`), a += ">", a;
1653
+ }
1654
+ text(e) {
1655
+ return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : U(e.text);
1656
+ }
1657
+ }, cn = class {
1658
+ strong({ text: e }) {
1659
+ return e;
1660
+ }
1661
+ em({ text: e }) {
1662
+ return e;
1663
+ }
1664
+ codespan({ text: e }) {
1665
+ return e;
1666
+ }
1667
+ del({ text: e }) {
1668
+ return e;
1669
+ }
1670
+ html({ text: e }) {
1671
+ return e;
1672
+ }
1673
+ text({ text: e }) {
1674
+ return e;
1675
+ }
1676
+ link({ text: e }) {
1677
+ return "" + e;
1678
+ }
1679
+ image({ text: e }) {
1680
+ return "" + e;
1681
+ }
1682
+ br() {
1683
+ return "";
1684
+ }
1685
+ checkbox({ raw: e }) {
1686
+ return e;
1687
+ }
1688
+ }, K = class e {
1689
+ options;
1690
+ renderer;
1691
+ textRenderer;
1692
+ constructor(e) {
1693
+ this.options = e || j, this.options.renderer = this.options.renderer || new sn(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new cn();
1694
+ }
1695
+ static parse(t, n) {
1696
+ return new e(n).parse(t);
1697
+ }
1698
+ static parseInline(t, n) {
1699
+ return new e(n).parseInline(t);
1700
+ }
1701
+ parse(e) {
1702
+ this.renderer.parser = this;
1703
+ let t = "";
1704
+ for (let n = 0; n < e.length; n++) {
1705
+ let r = e[n];
1706
+ if (this.options.extensions?.renderers?.[r.type]) {
1707
+ let e = r, n = this.options.extensions.renderers[e.type].call({ parser: this }, e);
1708
+ if (n !== !1 || ![
1709
+ "space",
1710
+ "hr",
1711
+ "heading",
1712
+ "code",
1713
+ "table",
1714
+ "blockquote",
1715
+ "list",
1716
+ "checkbox",
1717
+ "html",
1718
+ "def",
1719
+ "paragraph",
1720
+ "text"
1721
+ ].includes(e.type)) {
1722
+ t += n || "";
1723
+ continue;
1724
+ }
1725
+ }
1726
+ let i = r;
1727
+ switch (i.type) {
1728
+ case "space":
1729
+ t += this.renderer.space(i);
1730
+ break;
1731
+ case "hr":
1732
+ t += this.renderer.hr(i);
1733
+ break;
1734
+ case "heading":
1735
+ t += this.renderer.heading(i);
1736
+ break;
1737
+ case "code":
1738
+ t += this.renderer.code(i);
1739
+ break;
1740
+ case "table":
1741
+ t += this.renderer.table(i);
1742
+ break;
1743
+ case "blockquote":
1744
+ t += this.renderer.blockquote(i);
1745
+ break;
1746
+ case "list":
1747
+ t += this.renderer.list(i);
1748
+ break;
1749
+ case "checkbox":
1750
+ t += this.renderer.checkbox(i);
1751
+ break;
1752
+ case "html":
1753
+ t += this.renderer.html(i);
1754
+ break;
1755
+ case "def":
1756
+ t += this.renderer.def(i);
1757
+ break;
1758
+ case "paragraph":
1759
+ t += this.renderer.paragraph(i);
1760
+ break;
1761
+ case "text":
1762
+ t += this.renderer.text(i);
1763
+ break;
1764
+ default: {
1765
+ let e = "Token with \"" + i.type + "\" type was not found.";
1766
+ if (this.options.silent) return console.error(e), "";
1767
+ throw Error(e);
1768
+ }
1769
+ }
1770
+ }
1771
+ return t;
1772
+ }
1773
+ parseInline(e, t = this.renderer) {
1774
+ this.renderer.parser = this;
1775
+ let n = "";
1776
+ for (let r = 0; r < e.length; r++) {
1777
+ let i = e[r];
1778
+ if (this.options.extensions?.renderers?.[i.type]) {
1779
+ let e = this.options.extensions.renderers[i.type].call({ parser: this }, i);
1780
+ if (e !== !1 || ![
1781
+ "escape",
1782
+ "html",
1783
+ "link",
1784
+ "image",
1785
+ "checkbox",
1786
+ "strong",
1787
+ "em",
1788
+ "codespan",
1789
+ "br",
1790
+ "del",
1791
+ "text"
1792
+ ].includes(i.type)) {
1793
+ n += e || "";
1794
+ continue;
1795
+ }
1796
+ }
1797
+ let a = i;
1798
+ switch (a.type) {
1799
+ case "escape":
1800
+ n += t.text(a);
1801
+ break;
1802
+ case "html":
1803
+ n += t.html(a);
1804
+ break;
1805
+ case "link":
1806
+ n += t.link(a);
1807
+ break;
1808
+ case "image":
1809
+ n += t.image(a);
1810
+ break;
1811
+ case "checkbox":
1812
+ n += t.checkbox(a);
1813
+ break;
1814
+ case "strong":
1815
+ n += t.strong(a);
1816
+ break;
1817
+ case "em":
1818
+ n += t.em(a);
1819
+ break;
1820
+ case "codespan":
1821
+ n += t.codespan(a);
1822
+ break;
1823
+ case "br":
1824
+ n += t.br(a);
1825
+ break;
1826
+ case "del":
1827
+ n += t.del(a);
1828
+ break;
1829
+ case "text":
1830
+ n += t.text(a);
1831
+ break;
1832
+ default: {
1833
+ let e = "Token with \"" + a.type + "\" type was not found.";
1834
+ if (this.options.silent) return console.error(e), "";
1835
+ throw Error(e);
1836
+ }
1837
+ }
1838
+ }
1839
+ return n;
1840
+ }
1841
+ }, q = class {
1842
+ options;
1843
+ block;
1844
+ constructor(e) {
1845
+ this.options = e || j;
1846
+ }
1847
+ static passThroughHooks = /* @__PURE__ */ new Set([
1848
+ "preprocess",
1849
+ "postprocess",
1850
+ "processAllTokens",
1851
+ "emStrongMask"
1852
+ ]);
1853
+ static passThroughHooksRespectAsync = /* @__PURE__ */ new Set([
1854
+ "preprocess",
1855
+ "postprocess",
1856
+ "processAllTokens"
1857
+ ]);
1858
+ preprocess(e) {
1859
+ return e;
1860
+ }
1861
+ postprocess(e) {
1862
+ return e;
1863
+ }
1864
+ processAllTokens(e) {
1865
+ return e;
1866
+ }
1867
+ emStrongMask(e) {
1868
+ return e;
1869
+ }
1870
+ provideLexer(e = this.block) {
1871
+ return e ? G.lex : G.lexInline;
1872
+ }
1873
+ provideParser(e = this.block) {
1874
+ return e ? K.parse : K.parseInline;
1875
+ }
1876
+ };
1877
+ function J(e, t) {
1878
+ if (Array.isArray(t)) for (let n = 0; n < t.length; n++) e.push(t[n]);
1879
+ else e.push(t);
1880
+ }
1881
+ var Y = new class {
1882
+ defaults = Fe();
1883
+ options = this.setOptions;
1884
+ parse = this.parseMarkdown(!0);
1885
+ parseInline = this.parseMarkdown(!1);
1886
+ Parser = K;
1887
+ Renderer = sn;
1888
+ TextRenderer = cn;
1889
+ Lexer = G;
1890
+ Tokenizer = on;
1891
+ Hooks = q;
1892
+ constructor(...e) {
1893
+ this.use(...e);
1894
+ }
1895
+ walkTokens(e, t) {
1896
+ let n = [];
1897
+ for (let r of e) switch (J(n, t.call(this, r)), r.type) {
1898
+ case "table": {
1899
+ let e = r;
1900
+ for (let r of e.header) J(n, this.walkTokens(r.tokens, t));
1901
+ for (let r of e.rows) for (let e of r) J(n, this.walkTokens(e.tokens, t));
1902
+ break;
1903
+ }
1904
+ case "list": {
1905
+ let e = r;
1906
+ J(n, this.walkTokens(e.items, t));
1907
+ break;
1908
+ }
1909
+ default: {
1910
+ let e = r;
1911
+ this.defaults.extensions?.childTokens?.[e.type] ? this.defaults.extensions.childTokens[e.type].forEach((r) => {
1912
+ let i = e[r].flat(1 / 0);
1913
+ J(n, this.walkTokens(i, t));
1914
+ }) : e.tokens && J(n, this.walkTokens(e.tokens, t));
1915
+ }
1916
+ }
1917
+ return n;
1918
+ }
1919
+ use(...e) {
1920
+ let t = this.defaults.extensions || {
1921
+ renderers: {},
1922
+ childTokens: {}
1923
+ };
1924
+ return e.forEach((e) => {
1925
+ let n = { ...e };
1926
+ if (n.async = this.defaults.async || n.async || !1, e.extensions && (e.extensions.forEach((e) => {
1927
+ if (!e.name) throw Error("extension name required");
1928
+ if ("renderer" in e) {
1929
+ let n = t.renderers[e.name];
1930
+ n ? t.renderers[e.name] = function(...t) {
1931
+ let r = e.renderer.apply(this, t);
1932
+ return r === !1 && (r = n.apply(this, t)), r;
1933
+ } : t.renderers[e.name] = e.renderer;
1934
+ }
1935
+ if ("tokenizer" in e) {
1936
+ if (!e.level || e.level !== "block" && e.level !== "inline") throw Error("extension level must be 'block' or 'inline'");
1937
+ let n = t[e.level];
1938
+ 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]));
1939
+ }
1940
+ "childTokens" in e && e.childTokens && (t.childTokens[e.name] = e.childTokens);
1941
+ }), n.extensions = t), e.renderer) {
1942
+ let t = this.defaults.renderer || new sn(this.defaults);
1943
+ for (let n in e.renderer) {
1944
+ if (!(n in t)) throw Error(`renderer '${n}' does not exist`);
1945
+ if (["options", "parser"].includes(n)) continue;
1946
+ let r = n, i = e.renderer[r], a = t[r];
1947
+ t[r] = (...e) => {
1948
+ let n = i.apply(t, e);
1949
+ return n === !1 && (n = a.apply(t, e)), n || "";
1950
+ };
1951
+ }
1952
+ n.renderer = t;
1953
+ }
1954
+ if (e.tokenizer) {
1955
+ let t = this.defaults.tokenizer || new on(this.defaults);
1956
+ for (let n in e.tokenizer) {
1957
+ if (!(n in t)) throw Error(`tokenizer '${n}' does not exist`);
1958
+ if ([
1959
+ "options",
1960
+ "rules",
1961
+ "lexer"
1962
+ ].includes(n)) continue;
1963
+ let r = n, i = e.tokenizer[r], a = t[r];
1964
+ t[r] = (...e) => {
1965
+ let n = i.apply(t, e);
1966
+ return n === !1 && (n = a.apply(t, e)), n;
1967
+ };
1968
+ }
1969
+ n.tokenizer = t;
1970
+ }
1971
+ if (e.hooks) {
1972
+ let t = this.defaults.hooks || new q();
1973
+ for (let n in e.hooks) {
1974
+ if (!(n in t)) throw Error(`hook '${n}' does not exist`);
1975
+ if (["options", "block"].includes(n)) continue;
1976
+ let r = n, i = e.hooks[r], a = t[r];
1977
+ t[r] = q.passThroughHooks.has(n) ? (e) => {
1978
+ if (this.defaults.async && q.passThroughHooksRespectAsync.has(n)) return (async () => {
1979
+ let n = await i.call(t, e);
1980
+ return a.call(t, n);
1981
+ })();
1982
+ let r = i.call(t, e);
1983
+ return a.call(t, r);
1984
+ } : (...e) => {
1985
+ if (this.defaults.async) return (async () => {
1986
+ let n = await i.apply(t, e);
1987
+ return n === !1 && (n = await a.apply(t, e)), n;
1988
+ })();
1989
+ let n = i.apply(t, e);
1990
+ return n === !1 && (n = a.apply(t, e)), n;
1991
+ };
1992
+ }
1993
+ n.hooks = t;
1994
+ }
1995
+ if (e.walkTokens) {
1996
+ let t = this.defaults.walkTokens, r = e.walkTokens;
1997
+ n.walkTokens = function(e) {
1998
+ let n = [];
1999
+ return n.push(r.call(this, e)), t && J(n, t.call(this, e)), n;
2000
+ };
2001
+ }
2002
+ this.defaults = {
2003
+ ...this.defaults,
2004
+ ...n
2005
+ };
2006
+ }), this;
2007
+ }
2008
+ setOptions(e) {
2009
+ return this.defaults = {
2010
+ ...this.defaults,
2011
+ ...e
2012
+ }, this;
2013
+ }
2014
+ lexer(e, t) {
2015
+ return G.lex(e, t ?? this.defaults);
2016
+ }
2017
+ parser(e, t) {
2018
+ return K.parse(e, t ?? this.defaults);
2019
+ }
2020
+ parseMarkdown(e) {
2021
+ return (t, n) => {
2022
+ let r = { ...n }, i = {
2023
+ ...this.defaults,
2024
+ ...r
2025
+ }, a = this.onError(!!i.silent, !!i.async);
2026
+ if (this.defaults.async === !0 && r.async === !1) return a(/* @__PURE__ */ Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
2027
+ if (typeof t > "u" || t === null) return a(/* @__PURE__ */ Error("marked(): input parameter is undefined or null"));
2028
+ if (typeof t != "string") return a(/* @__PURE__ */ Error("marked(): input parameter is of type " + Object.prototype.toString.call(t) + ", string expected"));
2029
+ if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async) return (async () => {
2030
+ let n = i.hooks ? await i.hooks.preprocess(t) : t, r = await (i.hooks ? await i.hooks.provideLexer(e) : e ? G.lex : G.lexInline)(n, i), a = i.hooks ? await i.hooks.processAllTokens(r) : r;
2031
+ i.walkTokens && await Promise.all(this.walkTokens(a, i.walkTokens));
2032
+ let o = await (i.hooks ? await i.hooks.provideParser(e) : e ? K.parse : K.parseInline)(a, i);
2033
+ return i.hooks ? await i.hooks.postprocess(o) : o;
2034
+ })().catch(a);
2035
+ try {
2036
+ i.hooks && (t = i.hooks.preprocess(t));
2037
+ let n = (i.hooks ? i.hooks.provideLexer(e) : e ? G.lex : G.lexInline)(t, i);
2038
+ i.hooks && (n = i.hooks.processAllTokens(n)), i.walkTokens && this.walkTokens(n, i.walkTokens);
2039
+ let r = (i.hooks ? i.hooks.provideParser(e) : e ? K.parse : K.parseInline)(n, i);
2040
+ return i.hooks && (r = i.hooks.postprocess(r)), r;
2041
+ } catch (e) {
2042
+ return a(e);
2043
+ }
2044
+ };
2045
+ }
2046
+ onError(e, t) {
2047
+ return (n) => {
2048
+ if (n.message += "\nPlease report this to https://github.com/markedjs/marked.", e) {
2049
+ let e = "<p>An error occurred:</p><pre>" + U(n.message + "", !0) + "</pre>";
2050
+ return t ? Promise.resolve(e) : e;
2051
+ }
2052
+ if (t) return Promise.reject(n);
2053
+ throw n;
2054
+ };
2055
+ }
2056
+ }();
2057
+ function X(e, t) {
2058
+ return Y.parse(e, t);
2059
+ }
2060
+ X.options = X.setOptions = function(e) {
2061
+ return Y.setOptions(e), X.defaults = Y.defaults, Ie(X.defaults), X;
2062
+ }, X.getDefaults = Fe, X.defaults = j;
2063
+ function ln(...e) {
2064
+ return Y.use(...e), X.defaults = Y.defaults, Ie(X.defaults), X;
2065
+ }
2066
+ X.use = ln, X.walkTokens = function(e, t) {
2067
+ return Y.walkTokens(e, t);
2068
+ }, X.parseInline = Y.parseInline, X.Parser = K, X.parser = K.parse, X.Renderer = sn, X.TextRenderer = cn, X.Lexer = G, X.lexer = G.lex, X.Tokenizer = on, X.Hooks = q, X.parse = X, X.options, X.setOptions, X.walkTokens, X.parseInline, K.parse, G.lex;
2069
+ //#endregion
2070
+ //#region src/browser/markdown.ts
2071
+ function un(e) {
2072
+ return [
2073
+ "space",
2074
+ "def",
2075
+ "heading",
2076
+ "paragraph",
2077
+ "text",
2078
+ "escape",
2079
+ "html",
2080
+ "strong",
2081
+ "em",
2082
+ "del",
2083
+ "codespan",
2084
+ "code",
2085
+ "blockquote",
2086
+ "br",
2087
+ "hr",
2088
+ "list",
2089
+ "list_item",
2090
+ "checkbox",
2091
+ "link",
2092
+ "image",
2093
+ "table"
2094
+ ].includes(e.type);
2095
+ }
2096
+ function dn(e) {
2097
+ try {
2098
+ let t = new URL(e);
2099
+ return t.protocol === "https:" || t.protocol === "http:" ? t.href : void 0;
2100
+ } catch {
2101
+ return;
2102
+ }
2103
+ }
2104
+ function fn(e, t) {
2105
+ let n = (e) => e.map(r);
2106
+ function r(t) {
2107
+ if (!un(t)) return t.raw;
2108
+ let r = t;
2109
+ switch (r.type) {
2110
+ case "space":
2111
+ case "def": return null;
2112
+ case "heading": {
2113
+ let t = n(r.tokens);
2114
+ switch (r.depth) {
2115
+ case 1: return e`<h1>${t}</h1>`;
2116
+ case 2: return e`<h2>${t}</h2>`;
2117
+ case 3: return e`<h3>${t}</h3>`;
2118
+ case 4: return e`<h4>${t}</h4>`;
2119
+ case 5: return e`<h5>${t}</h5>`;
2120
+ default: return e`<h6>${t}</h6>`;
2121
+ }
2122
+ }
2123
+ case "paragraph": return e`<p>${n(r.tokens)}</p>`;
2124
+ case "text": return r.tokens ? n(r.tokens) : r.text;
2125
+ case "escape": return r.text;
2126
+ case "html": return r.raw;
2127
+ case "strong": return e`<strong>${n(r.tokens)}</strong>`;
2128
+ case "em": return e`<em>${n(r.tokens)}</em>`;
2129
+ case "del": return e`<del>${n(r.tokens)}</del>`;
2130
+ case "codespan": return e`<code>${r.text}</code>`;
2131
+ case "code": return e`<pre><code>${r.text}</code></pre>`;
2132
+ case "blockquote": return e`<blockquote>${n(r.tokens)}</blockquote>`;
2133
+ case "br": return e`<br>`;
2134
+ case "hr": return e`<hr>`;
2135
+ case "list": return r.ordered ? e`<ol start=${r.start}>${n(r.items)}</ol>` : e`<ul>${n(r.items)}</ul>`;
2136
+ case "list_item": return e`<li>${n(r.tokens)}</li>`;
2137
+ case "checkbox": return e`<input type="checkbox" disabled ?checked=${r.checked} aria-label="Task completed">`;
2138
+ case "link": {
2139
+ let t = dn(r.href), i = n(r.tokens);
2140
+ return t === void 0 ? i : e`<a href=${t} target="_blank" rel="noreferrer noopener">${i}</a>`;
2141
+ }
2142
+ case "image": return r.text;
2143
+ case "table": return e`<div class="review-table-scroll"><table><thead><tr>${r.header.map((t) => e`<th scope="col">${n(t.tokens)}</th>`)}</tr></thead><tbody>${r.rows.map((t) => e`<tr>${t.map((t) => e`<td>${n(t.tokens)}</td>`)}</tr>`)}</tbody></table></div>`;
2144
+ default: return t.raw;
2145
+ }
2146
+ }
2147
+ return n(new G({ gfm: !0 }).lex(t));
2148
+ }
2149
+ //#endregion
2150
+ //#region src/protocol.ts
2151
+ function pn(e) {
2152
+ return typeof e == "string" && /^[a-z0-9_][a-z0-9_./~^@{}-]{0,255}$/iu.test(e) && !e.includes("..");
2153
+ }
2154
+ function mn(e) {
2155
+ return typeof e == "string" && /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(e);
2156
+ }
2157
+ function hn(e) {
2158
+ return bn(e) && pn(e.baseRef) && pn(e.headRef) && (e.mode === "merge-base" || e.mode === "direct") && mn(e.base) && mn(e.head);
2159
+ }
2160
+ function gn(e) {
2161
+ if (!hn(e)) throw Error("Invalid Git comparison");
2162
+ return e;
2163
+ }
2164
+ function _n(e) {
2165
+ return e === void 0 ? "" : JSON.stringify([
2166
+ e.baseRef,
2167
+ e.headRef,
2168
+ e.mode,
2169
+ e.base,
2170
+ e.head
2171
+ ]);
2172
+ }
2173
+ function vn(e) {
2174
+ return e === "git-staged" || e === "git-unstaged" || e === "git-compare";
2175
+ }
2176
+ function yn(e) {
2177
+ return typeof e == "string" && e.length > 0 && e.length <= 4096 && !/^[a-z]:/iu.test(e) && !e.startsWith("/") && !e.includes("\\") && !/[\u0000-\u001f\u007f]/u.test(e) && e.split("/").every((e) => e !== "" && e !== "." && e !== "..");
2178
+ }
2179
+ function bn(e) {
2180
+ return typeof e == "object" && !!e && !Array.isArray(e);
2181
+ }
2182
+ function xn(e) {
2183
+ if (!Array.isArray(e) || e.length > 2e3 || !e.every(yn)) throw Error("Invalid or oversized Git file list");
2184
+ return e;
2185
+ }
2186
+ function Sn(e) {
2187
+ if (typeof e != "string" || e.length > 2e5) throw Error("Invalid or oversized Git diff");
2188
+ return e;
2189
+ }
2190
+ //#endregion
2191
+ //#region node_modules/@noble/hashes/_u64.js
2192
+ var Cn = (e) => e / 2 ** 32 | 0, wn = (e) => e >>> 0;
2193
+ function Tn(e, t, n, r) {
2194
+ let i = Cn(n), a = wn(n);
2195
+ e.setUint32(t, r ? a : i, r), e.setUint32(t + 4, r ? i : a, r);
2196
+ }
2197
+ //#endregion
2198
+ //#region node_modules/@noble/hashes/utils.js
2199
+ function En(e) {
2200
+ return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in e && e.BYTES_PER_ELEMENT === 1;
2201
+ }
2202
+ var Dn = (e) => e ? `"${e}" ` : "";
2203
+ function On(e, t = "") {
2204
+ if (typeof e != "number") throw TypeError(Dn(t) + "expected number, got " + typeof e);
2205
+ if (!Number.isSafeInteger(e) || e < 0) throw RangeError(Dn(t) + "expected integer >= 0, got " + e);
2206
+ return e;
2207
+ }
2208
+ function kn(e, t, n = "") {
2209
+ if (En(e) && (t === void 0 || e.length === t)) return e;
2210
+ t !== void 0 && On(t, "length");
2211
+ let r = En(e), i = t === void 0 ? "" : ` of length ${t}`, a = r ? `length=${e.length}` : `type=${typeof e}`, o = Dn(n) + "expected Uint8Array" + i + ", got " + a;
2212
+ throw r ? RangeError(o) : TypeError(o);
2213
+ }
2214
+ var An = (e, t) => {
2215
+ if (typeof e != "object" || !e || Array.isArray(e)) throw TypeError((t === "object" ? "" : `"${t}" `) + "expected object, got type=" + typeof e);
2216
+ }, jn = (e, t) => {
2217
+ An(e, t);
2218
+ let n = Object.getPrototypeOf(e);
2219
+ if (n !== Object.prototype && n !== null) throw TypeError(`"${t}" expected plain object`);
2220
+ if (Object.hasOwn(e, "__proto__")) throw TypeError(`"${t}.__proto__" is not allowed`);
2221
+ };
2222
+ function Mn(e, t = !0) {
2223
+ if (e.destroyed) throw Error("hash was destroyed");
2224
+ if (t && e.finished) throw Error("digest() was already called");
2225
+ }
2226
+ function Nn(e, t) {
2227
+ kn(e, void 0, "output");
2228
+ let n = t.outputLen;
2229
+ if (!(e.length >= n)) throw RangeError("\"output\" expected length >= " + n);
2230
+ }
2231
+ function Pn(...e) {
2232
+ for (let t = 0; t < e.length; t++) e[t].fill(0);
2233
+ }
2234
+ function Fn(e) {
2235
+ return new DataView(e.buffer, e.byteOffset, e.byteLength);
2236
+ }
2237
+ function Z(e, t) {
2238
+ return e << 32 - t | e >>> t;
2239
+ }
2240
+ function In(e, t, n = "opts") {
2241
+ return jn(e, "defaults"), t !== void 0 && jn(t, n), Object.assign(Object.create(null), e, t);
2242
+ }
2243
+ function Ln(e, t = {}) {
2244
+ if (typeof e != "function") throw TypeError("\"hashCons\" expected function, got type=" + typeof e);
2245
+ t = In({}, t, "info");
2246
+ let n = (t, n) => e(n).update(t).digest(), r = e(void 0);
2247
+ return n.outputLen = r.outputLen, n.blockLen = r.blockLen, n.canXOF = r.canXOF, n.create = (t) => e(t), Object.assign(n, t), Object.freeze(n);
2248
+ }
2249
+ var Rn = (e) => ({ oid: Uint8Array.from([
2250
+ 6,
2251
+ 9,
2252
+ 96,
2253
+ 134,
2254
+ 72,
2255
+ 1,
2256
+ 101,
2257
+ 3,
2258
+ 4,
2259
+ 2,
2260
+ e
2261
+ ]) });
2262
+ //#endregion
2263
+ //#region node_modules/@noble/hashes/_md.js
2264
+ function zn(e, t, n) {
2265
+ return e & t ^ ~e & n;
2266
+ }
2267
+ function Bn(e, t, n) {
2268
+ return e & t ^ e & n ^ t & n;
2269
+ }
2270
+ var Vn = class {
2271
+ blockLen;
2272
+ outputLen;
2273
+ canXOF = !1;
2274
+ padOffset;
2275
+ isLE;
2276
+ buffer;
2277
+ view;
2278
+ finished = !1;
2279
+ length = 0;
2280
+ pos = 0;
2281
+ destroyed = !1;
2282
+ constructor(e, t, n, r) {
2283
+ this.blockLen = e, this.outputLen = t, this.padOffset = n, this.isLE = r, this.buffer = new Uint8Array(e), this.view = Fn(this.buffer);
2284
+ }
2285
+ update(e) {
2286
+ Mn(this), kn(e);
2287
+ let { view: t, buffer: n, blockLen: r } = this, i = e.length, a = !1;
2288
+ for (let o = 0; o < i;) {
2289
+ let s = Math.min(r - this.pos, i - o);
2290
+ if (s === r) {
2291
+ let t = Fn(e);
2292
+ for (; r <= i - o; o += r) this.process(t, o);
2293
+ a = !0;
2294
+ continue;
2295
+ }
2296
+ n.set(o === 0 && s === i ? e : e.subarray(o, o + s), this.pos), this.pos += s, o += s, this.pos === r && (this.process(t, 0), this.pos = 0, a = !0);
2297
+ }
2298
+ return this.length += e.length, a && this.roundClean(), this;
2299
+ }
2300
+ digestInto(e) {
2301
+ Mn(this), Nn(e, this), this.finished = !0;
2302
+ let { buffer: t, view: n, blockLen: r, isLE: i } = this, { pos: a } = this;
2303
+ t[a++] = 128, t.fill(0, a), this.padOffset > r - a && (this.process(n, 0), t.fill(0)), Tn(n, r - 8, this.length * 8, i), this.process(n, 0), this.roundClean();
2304
+ let o = e === t ? n : Fn(e), s = this.outputLen, c = s / 4, l = this.get();
2305
+ if (s % 4 || c > l.length) throw Error("invalid outputLen");
2306
+ for (let e = 0; e < c; e++) o.setUint32(4 * e, l[e], i);
2307
+ }
2308
+ digest() {
2309
+ let { buffer: e, outputLen: t } = this;
2310
+ this.digestInto(e);
2311
+ let n = e.slice(0, t);
2312
+ return this.destroy(), n;
2313
+ }
2314
+ _cloneIntoMeta(e) {
2315
+ let { buffer: t, length: n, finished: r, destroyed: i, pos: a } = this;
2316
+ return e.destroyed = i, e.finished = r, e.length = n, e.pos = a, a && e.buffer.set(t), e;
2317
+ }
2318
+ clone() {
2319
+ return this._cloneInto();
2320
+ }
2321
+ }, Hn = /* @__PURE__ */ Uint32Array.from([
2322
+ 1779033703,
2323
+ 3144134277,
2324
+ 1013904242,
2325
+ 2773480762,
2326
+ 1359893119,
2327
+ 2600822924,
2328
+ 528734635,
2329
+ 1541459225
2330
+ ]), Un = /* @__PURE__ */ Uint32Array.from([
2331
+ 1116352408,
2332
+ 1899447441,
2333
+ 3049323471,
2334
+ 3921009573,
2335
+ 961987163,
2336
+ 1508970993,
2337
+ 2453635748,
2338
+ 2870763221,
2339
+ 3624381080,
2340
+ 310598401,
2341
+ 607225278,
2342
+ 1426881987,
2343
+ 1925078388,
2344
+ 2162078206,
2345
+ 2614888103,
2346
+ 3248222580,
2347
+ 3835390401,
2348
+ 4022224774,
2349
+ 264347078,
2350
+ 604807628,
2351
+ 770255983,
2352
+ 1249150122,
2353
+ 1555081692,
2354
+ 1996064986,
2355
+ 2554220882,
2356
+ 2821834349,
2357
+ 2952996808,
2358
+ 3210313671,
2359
+ 3336571891,
2360
+ 3584528711,
2361
+ 113926993,
2362
+ 338241895,
2363
+ 666307205,
2364
+ 773529912,
2365
+ 1294757372,
2366
+ 1396182291,
2367
+ 1695183700,
2368
+ 1986661051,
2369
+ 2177026350,
2370
+ 2456956037,
2371
+ 2730485921,
2372
+ 2820302411,
2373
+ 3259730800,
2374
+ 3345764771,
2375
+ 3516065817,
2376
+ 3600352804,
2377
+ 4094571909,
2378
+ 275423344,
2379
+ 430227734,
2380
+ 506948616,
2381
+ 659060556,
2382
+ 883997877,
2383
+ 958139571,
2384
+ 1322822218,
2385
+ 1537002063,
2386
+ 1747873779,
2387
+ 1955562222,
2388
+ 2024104815,
2389
+ 2227730452,
2390
+ 2361852424,
2391
+ 2428436474,
2392
+ 2756734187,
2393
+ 3204031479,
2394
+ 3329325298
2395
+ ]), Q = /* @__PURE__ */ new Uint32Array(64), Wn = class extends Vn {
2396
+ A = 0;
2397
+ B = 0;
2398
+ C = 0;
2399
+ D = 0;
2400
+ E = 0;
2401
+ F = 0;
2402
+ G = 0;
2403
+ H = 0;
2404
+ constructor(e, t) {
2405
+ super(64, e, 8, !1), this.A = t[0] | 0, this.B = t[1] | 0, this.C = t[2] | 0, this.D = t[3] | 0, this.E = t[4] | 0, this.F = t[5] | 0, this.G = t[6] | 0, this.H = t[7] | 0;
2406
+ }
2407
+ get() {
2408
+ let { A: e, B: t, C: n, D: r, E: i, F: a, G: o, H: s } = this;
2409
+ return [
2410
+ e,
2411
+ t,
2412
+ n,
2413
+ r,
2414
+ i,
2415
+ a,
2416
+ o,
2417
+ s
2418
+ ];
2419
+ }
2420
+ set(e, t, n, r, i, a, o, s) {
2421
+ this.A = e | 0, this.B = t | 0, this.C = n | 0, this.D = r | 0, this.E = i | 0, this.F = a | 0, this.G = o | 0, this.H = s | 0;
2422
+ }
2423
+ _cloneInto(e) {
2424
+ return (e ||= new this.constructor()).set(...this.get()), this._cloneIntoMeta(e);
2425
+ }
2426
+ process(e, t) {
2427
+ for (let n = 0; n < 16; n++, t += 4) Q[n] = e.getUint32(t, !1);
2428
+ for (let e = 16; e < 64; e++) {
2429
+ let t = Q[e - 15], n = Q[e - 2], r = Z(t, 7) ^ Z(t, 18) ^ t >>> 3, i = Z(n, 17) ^ Z(n, 19) ^ n >>> 10;
2430
+ Q[e] = i + Q[e - 7] + r + Q[e - 16] | 0;
2431
+ }
2432
+ let { A: n, B: r, C: i, D: a, E: o, F: s, G: c, H: l } = this;
2433
+ for (let e = 0; e < 64; e++) {
2434
+ let t = Z(o, 6) ^ Z(o, 11) ^ Z(o, 25), u = l + t + zn(o, s, c) + Un[e] + Q[e] | 0, d = (Z(n, 2) ^ Z(n, 13) ^ Z(n, 22)) + Bn(n, r, i) | 0;
2435
+ l = c, c = s, s = o, o = a + u | 0, a = i, i = r, r = n, n = u + d | 0;
2436
+ }
2437
+ n = n + this.A | 0, r = r + this.B | 0, i = i + this.C | 0, a = a + this.D | 0, o = o + this.E | 0, s = s + this.F | 0, c = c + this.G | 0, l = l + this.H | 0, this.set(n, r, i, a, o, s, c, l);
2438
+ }
2439
+ roundClean() {
2440
+ Pn(Q);
2441
+ }
2442
+ destroy() {
2443
+ this.destroyed = !0, this.set(0, 0, 0, 0, 0, 0, 0, 0), Pn(this.buffer);
2444
+ }
2445
+ }, Gn = class extends Wn {
2446
+ constructor() {
2447
+ super(32, Hn);
2448
+ }
2449
+ }, Kn = /* @__PURE__ */ Ln(() => new Gn(), /* @__PURE__ */ Rn(1)), qn = "pi-web-code-review:v1:";
2450
+ function $(e) {
2451
+ return JSON.stringify([
2452
+ e.machine.id,
2453
+ e.workspace.projectId,
2454
+ e.workspace.id
2455
+ ]);
2456
+ }
2457
+ function Jn(e) {
2458
+ return yn(e.path) && (e.source === "files" || vn(e.source)) && (e.source === "git-compare" ? hn(e.comparison) : e.comparison === void 0) && (e.side === "new" || e.source !== "files") && Number.isSafeInteger(e.start) && Number.isSafeInteger(e.end) && e.start > 0 && e.end >= e.start;
2459
+ }
2460
+ function Yn(e) {
2461
+ if (!bn(e)) return !1;
2462
+ let { path: t, source: n, side: r, start: i, end: a, id: o, body: s, hash: c, createdAt: l, comparison: u } = e;
2463
+ return u !== void 0 && !hn(u) ? !1 : typeof t == "string" && (n === "files" || vn(n)) && (r === "old" || r === "new") && typeof i == "number" && typeof a == "number" && Jn({
2464
+ path: t,
2465
+ source: n,
2466
+ side: r,
2467
+ start: i,
2468
+ end: a,
2469
+ ...u === void 0 ? {} : { comparison: u }
2470
+ }) && typeof o == "string" && o !== "" && typeof s == "string" && s.trim() !== "" && typeof c == "string" && /^[a-f0-9]{64}$/u.test(c) && typeof l == "number" && Number.isFinite(l);
2471
+ }
2472
+ var Xn = class {
2473
+ storage;
2474
+ legacy;
2475
+ constructor(e, t) {
2476
+ this.storage = e, this.legacy = t;
2477
+ }
2478
+ change(e, t) {
2479
+ return this.storage.transact(e, (n) => {
2480
+ let r = n;
2481
+ if (r === void 0) {
2482
+ let t = this.legacy.getItem(qn + e);
2483
+ r = t === null ? {
2484
+ version: 1,
2485
+ comments: []
2486
+ } : JSON.parse(t);
2487
+ }
2488
+ if (!bn(r) || r.version !== 1 || !Array.isArray(r.comments)) throw Error("Unrecognized review storage; existing data was retained");
2489
+ let i = r.comments;
2490
+ if (!i.every(Yn) || new Set(i.map((e) => e.id)).size !== i.length) throw Error("Invalid review storage; existing data was retained");
2491
+ let a = t(i);
2492
+ return {
2493
+ value: {
2494
+ version: 1,
2495
+ comments: a
2496
+ },
2497
+ result: a
2498
+ };
2499
+ });
2500
+ }
2501
+ load(e) {
2502
+ return this.change(e, (e) => e);
2503
+ }
2504
+ add(e, t) {
2505
+ return this.change(e, (e) => {
2506
+ if (!Yn(t)) throw Error("Invalid review comment");
2507
+ if (e.some((e) => e.id === t.id)) throw Error("Duplicate review comment");
2508
+ return [...e, t];
2509
+ });
2510
+ }
2511
+ update(e, t) {
2512
+ return this.change(e, (e) => {
2513
+ if (!Yn(t)) throw Error("Invalid review comment");
2514
+ if (!e.some((e) => e.id === t.id)) throw Error("This comment was removed in another tab");
2515
+ return e.map((e) => e.id === t.id ? t : e);
2516
+ });
2517
+ }
2518
+ remove(e, t) {
2519
+ return this.change(e, (e) => e.filter((e) => e.id !== t));
2520
+ }
2521
+ removeUnchanged(e, t, n = () => !0) {
2522
+ let r = new Map(t.map((e) => [e.id, Zn(e)]));
2523
+ return this.change(e, (e) => n() ? e.filter((e) => r.get(e.id) !== Zn(e)) : e);
2524
+ }
2525
+ };
2526
+ function Zn(e) {
2527
+ return JSON.stringify([
2528
+ e.id,
2529
+ e.path,
2530
+ e.source,
2531
+ e.side,
2532
+ e.start,
2533
+ e.end,
2534
+ e.body,
2535
+ e.hash,
2536
+ e.createdAt,
2537
+ _n(e.comparison)
2538
+ ]);
2539
+ }
2540
+ function Qn(e, t) {
2541
+ return e === "files" ? "File" : e === "git-staged" ? "Git staged" : e === "git-unstaged" ? "Git unstaged" : t === void 0 ? "Git comparison" : `Git ${`${t.baseRef}${t.mode === "merge-base" ? "..." : ".."}${t.headRef}`} (${t.base.slice(0, 12)}..${t.head.slice(0, 12)})`;
2542
+ }
2543
+ function $n(e) {
2544
+ return `${e.path}:${String(e.start)}${e.end === e.start ? "" : `-${String(e.end)}`} (${Qn(e.source, e.comparison)}${e.side === "old" ? ", deleted" : ""})`;
2545
+ }
2546
+ function er(e) {
2547
+ if (e.length === 0) return "";
2548
+ let t = [...e].sort((e, t) => e.path < t.path ? -1 : e.path > t.path ? 1 : e.start - t.start || e.createdAt - t.createdAt);
2549
+ return [`### Code review comments (${String(t.length)})`, ...t.map((e, t) => {
2550
+ let n = `C${String(t + 1)}`;
2551
+ return `---\n\n#### ${n}: ${$n(e).replace(/[\\`*_{}[\]<>()#!|]/gu, "\\$&")}\n\n${e.body.trim()}\n\n*-- end of ${n} --*`;
2552
+ })].join("\n\n");
2553
+ }
2554
+ function tr() {
2555
+ return [...crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(4))].map((e) => e.toString(16).padStart(8, "0")).join("");
2556
+ }
2557
+ function nr(e, t, n, r) {
2558
+ if (t === "git-compare" ? !hn(r) : r !== void 0) throw Error("Invalid snapshot comparison");
2559
+ let i = r === void 0 ? {} : { comparison: r }, a = [...Kn(new TextEncoder().encode(r === void 0 ? n : `${_n(r)}\n${n}`))].map((e) => e.toString(16).padStart(2, "0")).join(""), o = n.replaceAll("\r\n", "\n").split("\n");
2560
+ if (o.at(-1) === "" && o.pop(), o.length > 5e3) throw Error("Source has too many lines to review inline (limit: 5,000)");
2561
+ if (t === "files") return {
2562
+ path: e,
2563
+ source: t,
2564
+ hash: a,
2565
+ rows: o.map((e, t) => ({
2566
+ text: e,
2567
+ kind: "context",
2568
+ side: "new",
2569
+ line: t + 1
2570
+ }))
2571
+ };
2572
+ let s, c, l = 0, u = 0, d = o.map((e) => {
2573
+ let t = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/u.exec(e);
2574
+ if (t !== null) s = Number(t[1]), c = Number(t[3]), l = Number(t[2] ?? 1), u = Number(t[4] ?? 1);
2575
+ else if (s !== void 0 && c !== void 0) {
2576
+ if (e.startsWith("-") && l > 0) return l--, {
2577
+ text: e,
2578
+ kind: "remove",
2579
+ side: "old",
2580
+ line: s++
2581
+ };
2582
+ if (e.startsWith("+") && u > 0) return u--, {
2583
+ text: e,
2584
+ kind: "add",
2585
+ side: "new",
2586
+ line: c++
2587
+ };
2588
+ if (e.startsWith(" ") && l > 0 && u > 0) return l--, u--, s++, {
2589
+ text: e,
2590
+ kind: "context",
2591
+ side: "new",
2592
+ line: c++
2593
+ };
2594
+ e.startsWith("\\") || (s = void 0, c = void 0);
2595
+ }
2596
+ return {
2597
+ text: e,
2598
+ kind: "meta"
2599
+ };
2600
+ });
2601
+ return {
2602
+ path: e,
2603
+ source: t,
2604
+ ...i,
2605
+ hash: a,
2606
+ rows: d
2607
+ };
2608
+ }
2609
+ function rr(e, t) {
2610
+ if (!Jn(e) || e.path !== t.path || e.source !== t.source || _n(e.comparison) !== _n(t.comparison)) return !1;
2611
+ let n = new Set(t.rows.filter((t) => t.side === e.side).map((e) => e.line));
2612
+ if (e.end - e.start >= n.size) return !1;
2613
+ for (let t = e.start; t <= e.end; t++) if (!n.has(t)) return !1;
2614
+ return !0;
2615
+ }
2616
+ //#endregion
2617
+ //#region src/browser/panel.ts
2618
+ function ir(e) {
2619
+ let t = e.state?.selectedSession;
2620
+ return JSON.stringify([
2621
+ $(e),
2622
+ e.workspace.path,
2623
+ e.state?.selectedMachine?.id,
2624
+ t?.id,
2625
+ t?.cwd,
2626
+ t?.pending,
2627
+ t?.archived
2628
+ ]);
2629
+ }
2630
+ var ar = class extends A {
2631
+ static properties = {
2632
+ context: { attribute: !1 },
2633
+ revision: { type: Number }
2634
+ };
2635
+ chips;
2636
+ store;
2637
+ lifetime;
2638
+ source = "files";
2639
+ baseRef = "main";
2640
+ headRef = "HEAD";
2641
+ comparisonMode = "merge-base";
2642
+ comparison;
2643
+ comparing;
2644
+ directory = "";
2645
+ entries = [];
2646
+ view;
2647
+ editor;
2648
+ comments = [];
2649
+ error = "";
2650
+ feedbackErrors = {
2651
+ acceptance: "",
2652
+ action: "",
2653
+ read: ""
2654
+ };
2655
+ onFeedbackError;
2656
+ selection = "";
2657
+ selectionRevision = 0;
2658
+ feedbackRead = 0;
2659
+ connection = 0;
2660
+ saving = !1;
2661
+ focusEditor = !1;
2662
+ notice = "";
2663
+ listLoading = !1;
2664
+ viewLoading = !1;
2665
+ listing;
2666
+ reading;
2667
+ connectedCallback() {
2668
+ super.connectedCallback(), this.connection++, this.loadComments(), this.refresh();
2669
+ }
2670
+ disconnectedCallback() {
2671
+ this.connection++, this.feedbackRead++, this.listing?.abort(), this.reading?.abort(), this.comparing?.abort(), super.disconnectedCallback();
2672
+ }
2673
+ updated(e) {
2674
+ if (e.has("revision") && e.get("revision") !== void 0 && this.refresh(), this.focusEditor) {
2675
+ let e = this.renderRoot.querySelector(".editor textarea");
2676
+ e !== null && (this.focusEditor = !1, e.focus({ preventScroll: !0 }), e.closest(".editor")?.scrollIntoView({ block: "nearest" }));
2677
+ }
2678
+ }
2679
+ updateContext(e) {
2680
+ let t = ir(e);
2681
+ t !== this.selection && (this.selection = t, this.selectionRevision++), this.context = e;
2682
+ }
2683
+ refreshFeedback(e) {
2684
+ this.loadComments(), e !== void 0 && (this.notice = e), this.requestUpdate();
2685
+ }
2686
+ requireChips() {
2687
+ if (this.chips === void 0) throw Error("Composer integration is unavailable");
2688
+ return this.chips;
2689
+ }
2690
+ fail(e) {
2691
+ this.error = e instanceof Error ? e.message : String(e), this.requestUpdate();
2692
+ }
2693
+ setFeedbackError(e, t = "action") {
2694
+ this.feedbackErrors[t] = e, this.requestUpdate();
2695
+ }
2696
+ reportFeedbackError(e, t) {
2697
+ this.setFeedbackError(e, t), this.onFeedbackError?.(e, t);
2698
+ }
2699
+ feedbackFailed(e, t = "action") {
2700
+ this.reportFeedbackError(e instanceof Error ? e.message : String(e), t);
2701
+ }
2702
+ async loadComments() {
2703
+ let e = ++this.feedbackRead, t = $(this.context);
2704
+ try {
2705
+ let n = await this.requireStore().load(t);
2706
+ if (e !== this.feedbackRead || !this.isConnected || this.lifetime?.aborted === !0 || t !== $(this.context)) return;
2707
+ this.comments = n, this.requestUpdate();
2708
+ } catch (t) {
2709
+ e === this.feedbackRead && this.lifetime?.aborted !== !0 && this.feedbackFailed(t, "read");
2710
+ }
2711
+ }
2712
+ requireStore() {
2713
+ if (this.store === void 0) throw Error("Review storage is unavailable");
2714
+ return this.store;
2715
+ }
2716
+ signal(e) {
2717
+ return this.lifetime === void 0 ? e.signal : AbortSignal.any([e.signal, this.lifetime]);
2718
+ }
2719
+ async applyComparison() {
2720
+ this.comparing?.abort(), this.listing?.abort(), this.reading?.abort();
2721
+ let e = new AbortController();
2722
+ this.comparing = e;
2723
+ let t = this.signal(e);
2724
+ this.comparison = void 0, this.view = void 0, this.entries = [], this.listLoading = !1, this.viewLoading = !1, this.error = "", this.requestUpdate();
2725
+ try {
2726
+ let e = this.context.peer;
2727
+ if (e?.request === void 0) throw Error("Git review backend unavailable");
2728
+ let n = gn(await e.request("compare", {
2729
+ source: "git-compare",
2730
+ baseRef: this.baseRef.trim(),
2731
+ headRef: this.headRef.trim(),
2732
+ mode: this.comparisonMode
2733
+ }, { signal: t }));
2734
+ if (t.aborted) return;
2735
+ this.comparison = n, await this.loadList();
2736
+ } catch (e) {
2737
+ t.aborted || this.fail(e);
2738
+ } finally {
2739
+ this.comparing === e && (this.comparing = void 0, this.requestUpdate());
2740
+ }
2741
+ }
2742
+ async refresh() {
2743
+ if (this.source === "git-compare") {
2744
+ await this.applyComparison();
2745
+ return;
2746
+ }
2747
+ let e = this.view?.path;
2748
+ await Promise.all([this.loadList(), e === void 0 ? Promise.resolve() : this.openFile(e)]);
2749
+ }
2750
+ async loadList() {
2751
+ if (this.listing?.abort(), this.source === "git-compare" && this.comparison === void 0) return;
2752
+ let e = new AbortController();
2753
+ this.listing = e;
2754
+ let t = this.signal(e);
2755
+ this.listLoading = !0, this.error = "", this.requestUpdate();
2756
+ try {
2757
+ let e;
2758
+ if (this.source === "files") {
2759
+ let n = this.context.files.capabilityVersion === 1 ? await this.context.files.listFiles(this.directory, { signal: t }) : await this.context.files.listFiles(this.directory);
2760
+ if (n.truncated || n.entries.length > 2e3) throw Error("Directory is too large; enter a narrower directory");
2761
+ e = n.entries.filter((e) => yn(e.path));
2762
+ } else {
2763
+ let n = this.context.peer;
2764
+ if (n?.request === void 0) throw Error("Git review backend is unavailable. Enable the plugin on this machine and restart its session daemon");
2765
+ e = xn(await n.request("changes", {
2766
+ source: this.source,
2767
+ ...this.comparison === void 0 ? {} : { comparison: { ...this.comparison } }
2768
+ }, { signal: t })).map((e) => ({
2769
+ path: e,
2770
+ name: e,
2771
+ type: "file"
2772
+ }));
2773
+ }
2774
+ if (t.aborted) return;
2775
+ this.entries = e;
2776
+ } catch (e) {
2777
+ t.aborted || this.fail(e);
2778
+ } finally {
2779
+ this.listing === e && (this.listLoading = !1, this.requestUpdate());
2780
+ }
2781
+ }
2782
+ async openFile(e) {
2783
+ this.reading?.abort();
2784
+ let t = new AbortController();
2785
+ this.reading = t;
2786
+ let n = this.signal(t), r = this.source, i = this.comparison;
2787
+ this.viewLoading = !0, this.error = "", this.requestUpdate();
2788
+ try {
2789
+ if (!yn(e)) throw Error("Enter a workspace-relative file path");
2790
+ let t;
2791
+ if (r === "files") {
2792
+ let r = this.context.files.capabilityVersion === 1 ? await this.context.files.readFile(e, { signal: n }) : await this.context.files.readFile(e);
2793
+ if (r.binary || r.truncated || r.content.length > 2e5) throw Error("Binary, truncated, or oversized files cannot be reviewed inline");
2794
+ t = r.content;
2795
+ } else {
2796
+ let a = this.context.peer;
2797
+ if (a?.request === void 0) throw Error("Git review backend unavailable");
2798
+ t = Sn(await a.request("diff", {
2799
+ source: r,
2800
+ path: e,
2801
+ ...i === void 0 ? {} : { comparison: { ...i } }
2802
+ }, { signal: n }));
2803
+ }
2804
+ let a = nr(e, r, t, i);
2805
+ if (n.aborted) return;
2806
+ this.view = a, this.editor !== void 0 && (this.focusEditor = !0), this.editor !== void 0 && (this.editor.path !== e || this.editor.source !== r || this.editor.hash !== a.hash) && (this.notice = "The source changed. Your unfinished comment remains in the draft editor, but cannot be saved against this snapshot. Copy its text before cancelling.");
2807
+ } catch (e) {
2808
+ n.aborted || (this.view = void 0, this.fail(e));
2809
+ } finally {
2810
+ this.reading === t && (this.viewLoading = !1, this.requestUpdate());
2811
+ }
2812
+ }
2813
+ selectSource(e) {
2814
+ (e === "files" || vn(e)) && (this.comparing?.abort(), this.comparing = void 0, this.listing?.abort(), this.listLoading = !1, this.source = e, this.comparison = void 0, this.view = void 0, this.entries = [], this.reading?.abort(), this.reading = void 0, this.viewLoading = !1, e === "git-compare" ? this.applyComparison() : this.loadList());
2815
+ }
2816
+ selectLine(e, t) {
2817
+ let n = this.view;
2818
+ this.saving || n === void 0 || this.viewLoading || e.line === void 0 || e.side === void 0 || (t && this.editor !== void 0 && this.editor.id === void 0 && this.editor.path === n.path && this.editor.source === n.source && this.editor.side === e.side && this.editor.hash === n.hash ? this.editor = {
2819
+ ...this.editor,
2820
+ start: Math.min(this.editor.start, e.line),
2821
+ end: Math.max(this.editor.start, e.line)
2822
+ } : this.editor === void 0 ? this.editor = {
2823
+ path: n.path,
2824
+ source: n.source,
2825
+ side: e.side,
2826
+ start: e.line,
2827
+ end: e.line,
2828
+ hash: n.hash,
2829
+ body: "",
2830
+ ...n.comparison === void 0 ? {} : { comparison: n.comparison }
2831
+ } : this.notice = "Save or cancel the current comment first. Shift-click extends a range on the same side.", this.focusEditor = !0, this.requestUpdate());
2832
+ }
2833
+ async saveEditor() {
2834
+ let e = this.editor;
2835
+ if (this.saving || e === void 0 || e.body.trim() === "" || this.viewLoading || e.hash !== this.view?.hash || !rr(e, this.view)) return;
2836
+ let t = this.context, n = $(t), r = this.connection;
2837
+ this.saving = !0, this.feedbackRead++, this.requestUpdate();
2838
+ try {
2839
+ let i = {
2840
+ ...e,
2841
+ id: e.id ?? tr(),
2842
+ createdAt: e.createdAt ?? Date.now()
2843
+ }, a = this.requireStore();
2844
+ if (this.requireChips().withdrawWorkspace(n), await (e.id === void 0 ? a.add(n, i) : a.update(n, i)), this.editor === e && (this.editor = void 0), r !== this.connection || !this.isConnected || this.lifetime?.aborted === !0) return;
2845
+ this.notice = "Comment saved. Attach the updated review when ready.", await this.loadComments(), t.host.requestRender();
2846
+ } catch (e) {
2847
+ this.lifetime?.aborted !== !0 && this.feedbackFailed(e);
2848
+ } finally {
2849
+ this.saving = !1, this.requestUpdate();
2850
+ }
2851
+ }
2852
+ async removeComment(e) {
2853
+ if (this.saving) return;
2854
+ let t = this.context, n = $(t), r = this.connection;
2855
+ this.saving = !0, this.feedbackRead++, this.requestUpdate();
2856
+ try {
2857
+ if (this.requireChips().withdrawWorkspace(n), await this.requireStore().remove(n, e.id), this.editor?.id === e.id && (this.editor = void 0), r !== this.connection || !this.isConnected || this.lifetime?.aborted === !0) return;
2858
+ this.notice = "Comment removed. Attach any remaining feedback again before sending.", await this.loadComments(), t.host.requestRender();
2859
+ } catch (e) {
2860
+ this.lifetime?.aborted !== !0 && this.feedbackFailed(e);
2861
+ } finally {
2862
+ this.saving = !1, this.requestUpdate();
2863
+ }
2864
+ }
2865
+ editComment(e) {
2866
+ if (!this.saving) {
2867
+ if (this.editor !== void 0) {
2868
+ this.notice = "Save or cancel the current comment first.", this.requestUpdate();
2869
+ return;
2870
+ }
2871
+ this.editor = { ...e }, this.focusEditor = !0, this.comparing?.abort(), this.comparing = void 0, this.source = e.source, this.comparison = e.comparison, this.view = void 0, this.entries = [], e.comparison !== void 0 && (this.baseRef = e.comparison.baseRef, this.headRef = e.comparison.headRef, this.comparisonMode = e.comparison.mode), this.loadList(), this.openFile(e.path);
2872
+ }
2873
+ }
2874
+ async attachReview() {
2875
+ if (this.saving) return;
2876
+ let e = this.context, t = this.connection, n = ir(e), r = this.selectionRevision, i = () => this.isConnected && this.connection === t && this.selectionRevision === r && ir(this.context) === n && !this.saving && this.lifetime?.aborted !== !0;
2877
+ try {
2878
+ await this.requireChips().attach(e, i);
2879
+ } catch (e) {
2880
+ i() && this.feedbackFailed(e);
2881
+ }
2882
+ }
2883
+ changeEditor(e, t) {
2884
+ !this.saving && this.editor !== void 0 && (t.target instanceof HTMLInputElement || t.target instanceof HTMLTextAreaElement) && (this.editor = {
2885
+ ...this.editor,
2886
+ [e]: e === "body" ? t.target.value : Number(t.target.value)
2887
+ }, this.requestUpdate());
2888
+ }
2889
+ renderEditor() {
2890
+ let e = this.editor;
2891
+ if (e === void 0) return null;
2892
+ let t = !this.viewLoading && e.hash === this.view?.hash && rr(e, this.view);
2893
+ return T`<section class="editor" aria-label="Comment editor">
2894
+ <strong>${$n(e)}</strong>
2895
+ <div class="toolbar"><label>Start line <input ?disabled=${this.saving} type="number" min="1" step="1" .value=${String(e.start)} @input=${(e) => {
2896
+ this.changeEditor("start", e);
2897
+ }}></label>
2898
+ <label>End line <input ?disabled=${this.saving} type="number" min="1" step="1" .value=${String(e.end)} @input=${(e) => {
2899
+ this.changeEditor("end", e);
2900
+ }}></label></div>
2901
+ ${t ? null : T`<p role="alert">Choose a valid range in the current snapshot on one side. Omitted diff lines cannot be selected. Changed snapshots cannot be re-anchored automatically.</p>`}
2902
+ <label>Comment (Markdown)<textarea ?disabled=${this.saving} rows="4" .value=${e.body} @input=${(e) => {
2903
+ this.changeEditor("body", e);
2904
+ }} @keydown=${(e) => {
2905
+ e.key === "Enter" && (e.ctrlKey || e.metaKey) && !e.isComposing && (e.preventDefault(), this.saveEditor());
2906
+ }}></textarea></label>
2907
+ <div class="toolbar"><button class="primary" ?disabled=${this.saving || !t || e.body.trim() === ""} @click=${() => {
2908
+ this.saveEditor();
2909
+ }}>Save comment</button>
2910
+ <button ?disabled=${this.saving} @click=${() => {
2911
+ this.editor = void 0, this.notice = "", this.requestUpdate();
2912
+ }}>Cancel edit</button><span class="hint">Ctrl / ⌘ + Enter to save</span></div>
2913
+ </section>`;
2914
+ }
2915
+ render() {
2916
+ let e = this.view, t = this.editor !== void 0 && this.editor.hash === e?.hash && rr(this.editor, e);
2917
+ return T`<section class="review-panel" aria-label="Code Review">
2918
+ <header class="review-header"><div><h2>Code Review</h2><p class="hint">Review files. Comment in context. Share when ready.</p></div>
2919
+ <div class="review-actions"><span>${this.comments.length} saved · ${this.editor === void 0 ? "No draft" : "1 unsaved draft"}</span>
2920
+ <button class="primary" ?disabled=${this.saving || this.comments.length === 0} @click=${() => {
2921
+ this.attachReview();
2922
+ }}>Attach review to composer</button>
2923
+ <span class="hint">Saved comments only · send from the conversation</span></div>
2924
+ </header>
2925
+ <div class="source-controls"><div class="toolbar"><label>Source <select .value=${this.source} @change=${(e) => {
2926
+ e.target instanceof HTMLSelectElement && this.selectSource(e.target.value);
2927
+ }}>
2928
+ <option value="files">Files (including untracked)</option><option value="git-unstaged">Git unstaged</option><option value="git-staged">Git staged</option><option value="git-compare">Compare revisions</option>
2929
+ </select></label><button @click=${() => {
2930
+ this.refresh();
2931
+ }}>Refresh</button></div>
2932
+ ${this.source === "files" ? T`<form class="toolbar" @submit=${(e) => {
2933
+ e.preventDefault();
2934
+ let t = e.currentTarget;
2935
+ if (t instanceof HTMLFormElement) {
2936
+ let e = new FormData(t).get("path");
2937
+ typeof e == "string" && this.openFile(e);
2938
+ }
2939
+ }}><label>File path <input name="path" placeholder="src/example.ts"></label><button>Open file</button></form>` : null}
2940
+ ${this.source === "git-compare" ? T`<form class="toolbar" aria-label="Compare revisions" @submit=${(e) => {
2941
+ e.preventDefault(), this.applyComparison();
2942
+ }}>
2943
+ <label>Base revision <input name="base" required maxlength="256" .value=${this.baseRef} placeholder="main" @input=${(e) => {
2944
+ e.target instanceof HTMLInputElement && (this.baseRef = e.target.value);
2945
+ }}></label>
2946
+ <label>Target revision <input name="head" required maxlength="256" .value=${this.headRef} placeholder="HEAD" @input=${(e) => {
2947
+ e.target instanceof HTMLInputElement && (this.headRef = e.target.value);
2948
+ }}></label>
2949
+ <label>Comparison <select name="mode" .value=${this.comparisonMode} @change=${(e) => {
2950
+ e.target instanceof HTMLSelectElement && (e.target.value === "merge-base" || e.target.value === "direct") && (this.comparisonMode = e.target.value);
2951
+ }}><option value="merge-base">Branch changes since merge base (A...B)</option><option value="direct">Between revisions (A..B)</option></select></label>
2952
+ <button>Compare</button>
2953
+ </form><p>Compare committed work only. Use main → HEAD with merge base for a branch review, or a commit → HEAD with between revisions for accumulated work. Branch names, tags, commit IDs, and HEAD~3 are supported. Compare or Refresh resolves revisions again; opening files uses the frozen commits shown below.</p>` : null}
2954
+ </div>
2955
+ ${this.error === "" ? null : T`<p role="alert">${this.error}</p>`}
2956
+ ${Object.values(this.feedbackErrors).every((e) => e === "") ? null : T`
2957
+ ${Object.values(this.feedbackErrors).filter(Boolean).map((e) => T`<p role="alert">${e}</p>`)}
2958
+ <button @click=${() => {
2959
+ this.reportFeedbackError("", "acceptance"), this.reportFeedbackError("", "action"), this.reportFeedbackError("", "read");
2960
+ }}>Dismiss feedback warning</button>`}
2961
+ <p role="status" aria-live="polite">${this.listLoading || this.viewLoading || this.comparing !== void 0 ? "Loading…" : this.notice}</p>
2962
+ <div class="review-workspace"><nav aria-label="Review files"><details class="file-list" open><summary>${this.source === "files" ? this.directory || "Workspace files" : `${Qn(this.source, this.comparison)} files`}</summary>
2963
+ ${this.source === "files" && this.directory !== "" ? T`<button @click=${() => {
2964
+ this.directory = this.directory.split("/").slice(0, -1).join("/"), this.loadList();
2965
+ }}>Parent directory</button>` : null}
2966
+ ${this.entries.map((t) => T`<button aria-current=${t.path === e?.path ? "page" : "false"} ?disabled=${this.listLoading} @click=${() => {
2967
+ t.type === "directory" ? (this.directory = t.path, this.loadList()) : this.openFile(t.path);
2968
+ }}>${t.type === "directory" ? "📁 " : ""}${t.name}</button>`)}
2969
+ ${!this.listLoading && this.comparing === void 0 && this.entries.length === 0 ? T`<p>No files in this view.</p>` : null}
2970
+ </details></nav><main class="viewer">
2971
+ ${e === void 0 ? T`<div class="empty-state"><h3>${this.viewLoading ? "Opening file…" : "Choose a file to start reviewing"}</h3><p>Select a file from the list or open a workspace-relative path above.</p></div>` : T`<div class="file-heading"><h3>${e.path}</h3><span class="hint">${Qn(e.source, e.comparison)}</span><p class="hint">Click a line number to comment. Shift-click to extend the range, or use the editor’s line fields.</p></div>
2972
+ <div class="code" aria-label="Review source" aria-busy=${String(this.viewLoading)}>${e.rows.map((n) => {
2973
+ let r = n.line === void 0 || n.side === void 0 ? void 0 : {
2974
+ path: e.path,
2975
+ source: e.source,
2976
+ side: n.side,
2977
+ start: n.line,
2978
+ end: n.line
2979
+ }, i = r !== void 0 && this.editor?.path === e.path && this.editor.source === e.source && this.editor.hash === e.hash && this.editor.side === n.side && r.start >= this.editor.start && r.start <= this.editor.end, a = r === void 0 ? [] : this.comments.filter((t) => t.path === e.path && t.source === e.source && t.hash === e.hash && t.side === n.side && t.start === n.line);
2980
+ return T`<div class=${`row ${n.kind}${i ? " selected" : ""}`}>
2981
+ ${r === void 0 ? T`<span class="line"></span>` : T`<button class="line" aria-label=${`${n.side === "old" ? "Deleted" : "Current"} line ${String(n.line)}`} aria-pressed=${String(i)} ?disabled=${this.viewLoading} @click=${(e) => {
2982
+ this.selectLine(n, e.shiftKey);
2983
+ }}>${n.line}</button>`}
2984
+ <code>${n.text || " "}</code></div>${t && this.editor?.side === n.side && this.editor?.start === n.line ? this.renderEditor() : null}${a.map((e) => T`<div class="inline-comment">${fn(T, e.body)}</div>`)}`;
2985
+ })}</div>${e.rows.length === 0 ? T`<p>No text lines to review.</p>` : null}`}
2986
+ ${t ? null : this.renderEditor()}
2987
+ </main></div>
2988
+ <section class="saved-review" aria-label="Saved review"><h3>Saved comments (${this.comments.length})</h3>
2989
+ <p class="hint">Saved locally until sent. Failed sends retain feedback; acceptance clears unchanged submitted comments.</p>
2990
+ ${this.comments.length === 0 ? T`<p class="hint">No comments yet. Click a line number in the file viewer to add one.</p>` : null}
2991
+ ${this.comments.map((t) => T`<article><strong>${$n(t)}</strong>
2992
+ ${t.path === e?.path && t.source === e.source && t.hash !== e.hash ? T`<p class="stale">Source changed since this comment was saved. Verify its coordinates before sending.</p>` : null}
2993
+ <div class="markdown">${fn(T, t.body)}</div>
2994
+ <div class="toolbar"><button ?disabled=${this.saving} @click=${() => {
2995
+ this.editComment(t);
2996
+ }}>Edit comment</button><button ?disabled=${this.saving} @click=${() => {
2997
+ this.removeComment(t);
2998
+ }}>Remove comment</button></div>
2999
+ </article>`)}
3000
+ <details><summary>Feedback Markdown</summary><textarea aria-label="Feedback Markdown" readonly rows="8" .value=${er(this.comments)}></textarea></details>
3001
+ </section></section>`;
3002
+ }
3003
+ static styles = o`
3004
+ :host { display: block; color: var(--pi-text, #ddd); font: 14px system-ui, sans-serif; }
3005
+ * { box-sizing: border-box; }
3006
+ :host { container-type: inline-size; width: 100%; min-width: 0; }
3007
+ .review-panel { padding: 16px; } h2, h3 { margin: 0; } p { line-height: 1.5; }
3008
+ .hint { color: var(--pi-muted, #aaa); font-size: 12px; }
3009
+ .review-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--pi-border, #666); padding-bottom: 16px; }
3010
+ .review-header p { margin: 6px 0 0; }
3011
+ .review-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
3012
+ .source-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 20px; padding: 8px 0; }
3013
+ .source-controls form { flex: 1; } .source-controls label { flex: 1; min-width: 140px; }
3014
+ .source-controls > p { flex-basis: 100%; margin: 0; font-size: 12px; color: var(--pi-muted, #aaa); }
3015
+ .review-workspace { display: grid; grid-template-columns: minmax(160px, 22%) minmax(0, 1fr); border: 1px solid var(--pi-border, #666); border-radius: 8px; overflow: hidden; }
3016
+ nav { background: var(--pi-surface, #222); border-right: 1px solid var(--pi-border, #666); min-width: 0; padding: 12px; }
3017
+ .viewer { min-width: 0; }
3018
+ .file-heading { padding: 12px 16px; overflow-wrap: anywhere; } .file-heading p { margin-bottom: 0; }
3019
+ .empty-state { padding: 48px 24px; text-align: center; color: var(--pi-muted, #aaa); }
3020
+ .saved-review { margin-top: 24px; } summary { cursor: pointer; overflow-wrap: anywhere; }
3021
+ [role=status]:empty { display: none; }
3022
+ @container (max-width: 640px) {
3023
+ .review-panel { padding: 10px; } .review-workspace { grid-template-columns: minmax(0, 1fr); }
3024
+ nav { border-right: 0; border-bottom: 1px solid var(--pi-border, #666); }
3025
+ .review-actions { align-items: flex-start; } .file-list { max-height: 150px !important; }
3026
+ }
3027
+ .toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin: 8px 0; }
3028
+ label { display: flex; flex-direction: column; gap: 4px; }
3029
+ button, select, input, textarea { color: inherit; background: var(--pi-surface, #222); border: 1px solid var(--pi-border, #666); border-radius: 4px; padding: 6px; font: inherit; }
3030
+ button { cursor: pointer; } button:hover:not(:disabled) { border-color: var(--pi-accent, #6cf); }
3031
+ .primary { background: var(--pi-accent, #6cf); color: var(--pi-surface, #222); border-color: transparent; font-weight: 600; }
3032
+ :is(button, input, select, textarea):focus-visible { outline: 2px solid var(--pi-accent, #6cf); outline-offset: 2px; }
3033
+ button:disabled { opacity: .5; cursor: default; } button:focus-visible { outline: 2px solid var(--pi-accent, #6cf); }
3034
+ textarea { box-sizing: border-box; width: 100%; resize: vertical; } input[type=number] { width: 6em; }
3035
+ .file-list { max-height: 65vh; overflow: auto; } .file-list button { display: block; width: 100%; text-align: left; margin: 4px 0; overflow-wrap: anywhere; border-color: transparent; background: transparent; }
3036
+ .file-list button[aria-current=page] { background: var(--pi-selection-bg, #336699); border-color: var(--pi-accent, #6cf); }
3037
+ .code { max-height: 65vh; overflow: auto; border-top: 1px solid var(--pi-border, #666); }
3038
+ .code .editor, .code .inline-comment { position: sticky; left: 0; width: calc(100% - 24px); margin: 10px 12px; background: var(--pi-surface, #222); }
3039
+ .editor { border-left: 3px solid var(--pi-accent, #6cf) !important; }
3040
+ .editor strong { display: block; margin-bottom: 8px; }
3041
+ .row { display: flex; min-width: max-content; } .row code { white-space: pre; padding: 2px 8px; font: 12px ui-monospace, monospace; }
3042
+ .line { flex: 0 0 4em; border-radius: 0; padding: 2px; font: 12px ui-monospace, monospace; text-align: right; }
3043
+ .add { background: #22883325; } .remove { background: #bb222225; } .meta { color: var(--pi-muted, #999); }
3044
+ .selected { background: var(--pi-selection-bg, #336699); } .inline-comment, article, .editor { padding: 10px; margin: 8px 0; border: 1px solid var(--pi-border, #666); border-radius: 6px; white-space: normal; overflow-wrap: anywhere; }
3045
+ .inline-comment { max-width: 75ch; } [role=alert], .stale { color: var(--pi-warning, #ecb65b); }
3046
+ .markdown pre, .inline-comment pre { overflow: auto; } a { color: var(--pi-accent, #6cf); }
3047
+ `;
3048
+ }, or = class {
3049
+ store;
3050
+ notify;
3051
+ attachments = /* @__PURE__ */ new Map();
3052
+ pending = /* @__PURE__ */ new Map();
3053
+ epochs = /* @__PURE__ */ new Map();
3054
+ disposed = !1;
3055
+ constructor(e, t) {
3056
+ this.store = e, this.notify = t;
3057
+ }
3058
+ async attach(e, t = () => !0) {
3059
+ let { state: n, prompt: r } = e, i = n?.selectedSession;
3060
+ if (i === void 0 || i.pending || i.archived || i.cwd !== e.workspace.path || n?.selectedMachine?.id !== e.machine.id) throw Error("Select a ready, unarchived conversation in this workspace before attaching review feedback");
3061
+ if (r.setChip === void 0 || r.removeChip === void 0) throw Error("Code Review requires the PI WEB release containing main's composer-chip API");
3062
+ let a = $(e), o = JSON.stringify([a, i.id]), s = {};
3063
+ this.pending.set(o, s);
3064
+ let c = this.epochs.get(a), l, u;
3065
+ try {
3066
+ l = (await this.store.load(a)).map((e) => ({ ...e })), u = this.pending.get(o) === s;
3067
+ } finally {
3068
+ this.pending.get(o) === s && this.pending.delete(o);
3069
+ }
3070
+ if (this.disposed || !t() || !u || this.epochs.get(a) !== c || $(e) !== a || e.state?.selectedSession?.id !== i.id || e.state.selectedSession.pending || e.state.selectedSession.archived || e.state.selectedMachine?.id !== e.machine.id) return;
3071
+ if (l.length === 0) throw Error("There are no saved comments to attach");
3072
+ let d = {
3073
+ workspace: a,
3074
+ target: o,
3075
+ id: `review:${a}`,
3076
+ prompt: r,
3077
+ comments: l
3078
+ }, f = {
3079
+ id: d.id,
3080
+ label: `Review (${String(l.length)})`,
3081
+ text: er(l),
3082
+ onRemove: (e) => this.settle(d, e)
3083
+ };
3084
+ r.setChip(f), this.attachments.set(d.target, d), this.notify(a, "Review attached to this conversation. Send normally; failed sends retain it.");
3085
+ }
3086
+ withdrawWorkspace(e) {
3087
+ this.epochs.set(e, (this.epochs.get(e) ?? 0) + 1);
3088
+ for (let [t, n] of this.attachments) if (n.workspace === e) {
3089
+ if (n.prompt.removeChip === void 0) throw Error("Composer-chip withdrawal is unavailable");
3090
+ n.prompt.removeChip(n.id), this.attachments.delete(t);
3091
+ }
3092
+ }
3093
+ storageChanged(e) {
3094
+ let t = e === void 0 ? new Set([...this.attachments.values()].map((e) => e.workspace)) : /* @__PURE__ */ new Set([e]);
3095
+ for (let e of t) try {
3096
+ this.withdrawWorkspace(e), this.notify(e, "Saved feedback changed in another tab. Attach it again before sending.");
3097
+ } catch (t) {
3098
+ this.notify(e, "Could not withdraw changed feedback. Remove its composer chip before sending.", t);
3099
+ }
3100
+ }
3101
+ dispose() {
3102
+ this.disposed = !0, this.pending.clear();
3103
+ for (let e of new Set([...this.attachments.values()].map((e) => e.workspace))) try {
3104
+ this.withdrawWorkspace(e);
3105
+ } catch (t) {
3106
+ this.notify(e, "Could not withdraw review chips during plugin shutdown.", t);
3107
+ }
3108
+ this.attachments.clear();
3109
+ }
3110
+ async settle(e, t) {
3111
+ let n = () => this.disposed, r = { replaced: !1 };
3112
+ if (!n()) try {
3113
+ if (t === "submitted" && await this.store.removeUnchanged(e.workspace, e.comments, () => {
3114
+ let t = this.attachments.get(e.target);
3115
+ return r.replaced = t !== void 0 && t !== e, !n() && !r.replaced;
3116
+ }), n()) return;
3117
+ this.attachments.get(e.target) === e && this.attachments.delete(e.target), this.notify(e.workspace, t === "submitted" ? r.replaced ? "An earlier review was accepted. The newer attached review and saved comments were retained." : "Review accepted by the server. Unchanged submitted comments were cleared; later edits were retained." : "Review detached from the composer. Saved comments were retained.");
3118
+ } catch (t) {
3119
+ throw n() || this.notify(e.workspace, "The review was accepted, but saved feedback could not be cleared. Check the conversation before attaching it again.", t, "acceptance"), t;
3120
+ }
3121
+ }
3122
+ }, sr = class {
3123
+ factory;
3124
+ committed;
3125
+ name;
3126
+ database;
3127
+ disposed = !1;
3128
+ constructor(e, t = () => {}, n = "pi-web-code-review") {
3129
+ this.factory = e, this.committed = t, this.name = n;
3130
+ }
3131
+ open() {
3132
+ if (this.disposed) return Promise.reject(/* @__PURE__ */ Error("Review storage is closed"));
3133
+ if (this.database !== void 0) return this.database;
3134
+ let e = new Promise((e, t) => {
3135
+ let n = this.factory.open(this.name, 1), r = !1, i = (e) => {
3136
+ r = !0, t(e);
3137
+ };
3138
+ n.onupgradeneeded = () => {
3139
+ if (r || this.disposed) {
3140
+ n.transaction?.abort();
3141
+ return;
3142
+ }
3143
+ n.result.createObjectStore("workspaces");
3144
+ }, n.onerror = () => {
3145
+ i(n.error ?? /* @__PURE__ */ Error("Could not open review storage"));
3146
+ }, n.onblocked = () => {
3147
+ i(/* @__PURE__ */ Error("Review storage upgrade is blocked; close older review tabs and retry"));
3148
+ }, n.onsuccess = () => {
3149
+ let i = n.result;
3150
+ if (r || this.disposed) {
3151
+ i.close(), t(/* @__PURE__ */ Error("Review storage is closed"));
3152
+ return;
3153
+ }
3154
+ i.onversionchange = () => {
3155
+ i.close(), this.database = void 0;
3156
+ }, e(i);
3157
+ };
3158
+ });
3159
+ return this.database = e, e.catch(() => {
3160
+ this.database === e && (this.database = void 0);
3161
+ }), e;
3162
+ }
3163
+ async transact(e, t) {
3164
+ let n = await this.open();
3165
+ if (this.disposed) throw Error("Review storage is closed");
3166
+ return new Promise((r, i) => {
3167
+ let a = n.transaction("workspaces", "readwrite"), o = a.objectStore("workspaces"), s, c, l = !1;
3168
+ a.onabort = () => {
3169
+ i(c ?? a.error ?? /* @__PURE__ */ Error("Review storage transaction aborted"));
3170
+ }, a.oncomplete = () => {
3171
+ if (l) try {
3172
+ this.committed(e);
3173
+ } catch (e) {
3174
+ console.error("[Code Review] Could not notify other tabs of saved feedback", e);
3175
+ }
3176
+ r(s);
3177
+ };
3178
+ let u = o.get(e);
3179
+ u.onsuccess = () => {
3180
+ try {
3181
+ let n = u.result, r = t(n);
3182
+ s = r.result, JSON.stringify(n) !== JSON.stringify(r.value) && (o.put(r.value, e), l = !0);
3183
+ } catch (e) {
3184
+ c = e instanceof Error ? e : Error("Review storage mutation failed", { cause: e }), a.abort();
3185
+ }
3186
+ };
3187
+ });
3188
+ }
3189
+ dispose() {
3190
+ this.disposed = !0, this.database?.then((e) => {
3191
+ e.close();
3192
+ }, () => {});
3193
+ }
3194
+ }, cr = {
3195
+ apiVersion: 4,
3196
+ name: "Code Review",
3197
+ activate({ html: e, runtimePluginId: t, lifetimeSignal: n }) {
3198
+ class r extends ar {}
3199
+ customElements.define(`pi-web-code-review-${tr()}`, r);
3200
+ let i, a, o = !1, s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = (e, t, r) => {
3201
+ if (o || n.aborted) return;
3202
+ let s = {
3203
+ ...c.get(e) ?? {
3204
+ acceptance: "",
3205
+ action: "",
3206
+ read: ""
3207
+ },
3208
+ [r]: t
3209
+ };
3210
+ s.acceptance === "" && s.action === "" && s.read === "" ? c.delete(e) : c.set(e, s), a === e && i?.setFeedbackError(t, r);
3211
+ }, u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), p;
3212
+ try {
3213
+ p = new BroadcastChannel("pi-web-code-review:commits");
3214
+ } catch (e) {
3215
+ console.error("[Code Review] Cross-tab notifications unavailable", e);
3216
+ }
3217
+ let m = (e) => {
3218
+ if (o || n.aborted) return;
3219
+ let t = {};
3220
+ d.set(e, t), g.load(e).then((r) => {
3221
+ n.aborted || d.get(e) !== t || (u.set(e, r.length || void 0), f.get(e)?.());
3222
+ }, () => {
3223
+ n.aborted || d.get(e) !== t || (u.set(e, "!"), f.get(e)?.());
3224
+ });
3225
+ }, h = new sr(globalThis.indexedDB, (e) => {
3226
+ o || n.aborted || (m(e), p?.postMessage(e));
3227
+ }), g = new Xn(h, { getItem: (e) => localStorage.getItem(e) }), ee = new or(g, (e, t, r, c = "action") => {
3228
+ r !== void 0 && console.error(`[Code Review] ${t}`, r), !(o || n.aborted) && (r === void 0 ? s.set(e, t) : (s.delete(e), l(e, t, c)), a === e && i?.refreshFeedback(r === void 0 ? t : void 0), m(e), i?.context.host.requestRender());
3229
+ });
3230
+ p !== void 0 && (p.onmessage = (e) => {
3231
+ typeof e.data != "string" || n.aborted || (ee.storageChanged(e.data), a === e.data && i?.refreshFeedback(), m(e.data));
3232
+ });
3233
+ let te = () => {
3234
+ p?.close(), p = void 0;
3235
+ };
3236
+ return n.addEventListener("abort", te, { once: !0 }), {
3237
+ contributions: {
3238
+ actions: [{
3239
+ id: "open",
3240
+ title: "Open Code Review",
3241
+ group: "Workspace",
3242
+ enabled: ({ state: e }) => e.selectedWorkspace !== void 0,
3243
+ run: (e) => {
3244
+ e.selectWorkspaceTool(`${t}:review`);
3245
+ }
3246
+ }],
3247
+ workspacePanels: [{
3248
+ id: "review",
3249
+ title: "Review",
3250
+ order: 35,
3251
+ icon: e`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="10.5" cy="10.5" r="7.5"></circle><path d="m16 16 5 5"></path></svg>`,
3252
+ invalidationResources: ["workspace.files"],
3253
+ badge: (e) => {
3254
+ let t = $(e);
3255
+ return f.set(t, () => {
3256
+ e.host.requestRender();
3257
+ }), u.has(t) || (u.set(t, void 0), m(t)), u.get(t);
3258
+ },
3259
+ onInvalidate: (e) => {
3260
+ i !== void 0 && a === $(e) && i.revision++;
3261
+ },
3262
+ render: (t) => {
3263
+ let o = $(t);
3264
+ return (i === void 0 || a !== o) && (i?.remove(), i = new r(), a = o, i.store = g, i.chips = ee, i.lifetime = n, i.revision = 0, i.updateContext(t), i.onFeedbackError = (e, t) => {
3265
+ l(o, e, t);
3266
+ }, i.setFeedbackError(c.get(o)?.acceptance ?? "", "acceptance"), i.setFeedbackError(c.get(o)?.action ?? "", "action"), i.setFeedbackError(c.get(o)?.read ?? "", "read"), i.refreshFeedback(s.get(o))), i.updateContext(t), e`${i}`;
3267
+ }
3268
+ }]
3269
+ },
3270
+ dispose() {
3271
+ o = !0, te(), n.removeEventListener("abort", te), ee.dispose(), h.dispose(), s.clear(), c.clear(), d.clear(), f.clear(), i?.remove(), i = void 0;
3272
+ }
3273
+ };
3274
+ }
3275
+ };
3276
+ //#endregion
3277
+ export { cr as default };