@pi-outpost/embed 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,804 @@
1
+ import { _ as e, c as t, d as n, g as r, h as i, l as a, m as o, n as s, o as c, p as l, s as u, u as d, v as f, y as p } from "./conversationHistory-BDtVdjM-.js";
2
+ import { _ as m, h, i as g, n as _, r as v, t as ee, u as te } from "./lib-BgQYQRfw.js";
3
+ import { a as ne, i as re, n as ie, o as ae, r as oe } from "./loadReferencedImage-CUSqS4eN.js";
4
+ //#region ../node_modules/stringify-entities/lib/core.js
5
+ var se = /["&'<>`]/g, ce = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, y = /[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g, b = /[|\\{}()[\]^$+*?.]/g, x = /* @__PURE__ */ new WeakMap();
6
+ function le(e, t) {
7
+ if (e = e.replace(t.subset ? ue(t.subset) : se, r), t.subset || t.escapeOnly) return e;
8
+ return e.replace(ce, n).replace(y, r);
9
+ function n(e, n, r) {
10
+ return t.format((e.charCodeAt(0) - 55296) * 1024 + e.charCodeAt(1) - 56320 + 65536, r.charCodeAt(n + 2), t);
11
+ }
12
+ function r(e, n, r) {
13
+ return t.format(e.charCodeAt(0), r.charCodeAt(n + 1), t);
14
+ }
15
+ }
16
+ function ue(e) {
17
+ let t = x.get(e);
18
+ return t || (t = de(e), x.set(e, t)), t;
19
+ }
20
+ function de(e) {
21
+ let t = [], n = -1;
22
+ for (; ++n < e.length;) t.push(e[n].replace(b, "\\$&"));
23
+ return RegExp("(?:" + t.join("|") + ")", "g");
24
+ }
25
+ //#endregion
26
+ //#region ../node_modules/stringify-entities/lib/util/to-hexadecimal.js
27
+ var fe = /[\dA-Fa-f]/;
28
+ function pe(e, t, n) {
29
+ let r = "&#x" + e.toString(16).toUpperCase();
30
+ return n && t && !fe.test(String.fromCharCode(t)) ? r : r + ";";
31
+ }
32
+ //#endregion
33
+ //#region ../node_modules/stringify-entities/lib/util/to-decimal.js
34
+ var me = /\d/;
35
+ function he(e, t, n) {
36
+ let r = "&#" + String(e);
37
+ return n && t && !me.test(String.fromCharCode(t)) ? r : r + ";";
38
+ }
39
+ //#endregion
40
+ //#region ../node_modules/character-entities-legacy/index.js
41
+ var ge = /* @__PURE__ */ "AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml".split("."), S = {
42
+ nbsp: "\xA0",
43
+ iexcl: "¡",
44
+ cent: "¢",
45
+ pound: "£",
46
+ curren: "¤",
47
+ yen: "¥",
48
+ brvbar: "¦",
49
+ sect: "§",
50
+ uml: "¨",
51
+ copy: "©",
52
+ ordf: "ª",
53
+ laquo: "«",
54
+ not: "¬",
55
+ shy: "­",
56
+ reg: "®",
57
+ macr: "¯",
58
+ deg: "°",
59
+ plusmn: "±",
60
+ sup2: "²",
61
+ sup3: "³",
62
+ acute: "´",
63
+ micro: "µ",
64
+ para: "¶",
65
+ middot: "·",
66
+ cedil: "¸",
67
+ sup1: "¹",
68
+ ordm: "º",
69
+ raquo: "»",
70
+ frac14: "¼",
71
+ frac12: "½",
72
+ frac34: "¾",
73
+ iquest: "¿",
74
+ Agrave: "À",
75
+ Aacute: "Á",
76
+ Acirc: "Â",
77
+ Atilde: "Ã",
78
+ Auml: "Ä",
79
+ Aring: "Å",
80
+ AElig: "Æ",
81
+ Ccedil: "Ç",
82
+ Egrave: "È",
83
+ Eacute: "É",
84
+ Ecirc: "Ê",
85
+ Euml: "Ë",
86
+ Igrave: "Ì",
87
+ Iacute: "Í",
88
+ Icirc: "Î",
89
+ Iuml: "Ï",
90
+ ETH: "Ð",
91
+ Ntilde: "Ñ",
92
+ Ograve: "Ò",
93
+ Oacute: "Ó",
94
+ Ocirc: "Ô",
95
+ Otilde: "Õ",
96
+ Ouml: "Ö",
97
+ times: "×",
98
+ Oslash: "Ø",
99
+ Ugrave: "Ù",
100
+ Uacute: "Ú",
101
+ Ucirc: "Û",
102
+ Uuml: "Ü",
103
+ Yacute: "Ý",
104
+ THORN: "Þ",
105
+ szlig: "ß",
106
+ agrave: "à",
107
+ aacute: "á",
108
+ acirc: "â",
109
+ atilde: "ã",
110
+ auml: "ä",
111
+ aring: "å",
112
+ aelig: "æ",
113
+ ccedil: "ç",
114
+ egrave: "è",
115
+ eacute: "é",
116
+ ecirc: "ê",
117
+ euml: "ë",
118
+ igrave: "ì",
119
+ iacute: "í",
120
+ icirc: "î",
121
+ iuml: "ï",
122
+ eth: "ð",
123
+ ntilde: "ñ",
124
+ ograve: "ò",
125
+ oacute: "ó",
126
+ ocirc: "ô",
127
+ otilde: "õ",
128
+ ouml: "ö",
129
+ divide: "÷",
130
+ oslash: "ø",
131
+ ugrave: "ù",
132
+ uacute: "ú",
133
+ ucirc: "û",
134
+ uuml: "ü",
135
+ yacute: "ý",
136
+ thorn: "þ",
137
+ yuml: "ÿ",
138
+ fnof: "ƒ",
139
+ Alpha: "Α",
140
+ Beta: "Β",
141
+ Gamma: "Γ",
142
+ Delta: "Δ",
143
+ Epsilon: "Ε",
144
+ Zeta: "Ζ",
145
+ Eta: "Η",
146
+ Theta: "Θ",
147
+ Iota: "Ι",
148
+ Kappa: "Κ",
149
+ Lambda: "Λ",
150
+ Mu: "Μ",
151
+ Nu: "Ν",
152
+ Xi: "Ξ",
153
+ Omicron: "Ο",
154
+ Pi: "Π",
155
+ Rho: "Ρ",
156
+ Sigma: "Σ",
157
+ Tau: "Τ",
158
+ Upsilon: "Υ",
159
+ Phi: "Φ",
160
+ Chi: "Χ",
161
+ Psi: "Ψ",
162
+ Omega: "Ω",
163
+ alpha: "α",
164
+ beta: "β",
165
+ gamma: "γ",
166
+ delta: "δ",
167
+ epsilon: "ε",
168
+ zeta: "ζ",
169
+ eta: "η",
170
+ theta: "θ",
171
+ iota: "ι",
172
+ kappa: "κ",
173
+ lambda: "λ",
174
+ mu: "μ",
175
+ nu: "ν",
176
+ xi: "ξ",
177
+ omicron: "ο",
178
+ pi: "π",
179
+ rho: "ρ",
180
+ sigmaf: "ς",
181
+ sigma: "σ",
182
+ tau: "τ",
183
+ upsilon: "υ",
184
+ phi: "φ",
185
+ chi: "χ",
186
+ psi: "ψ",
187
+ omega: "ω",
188
+ thetasym: "ϑ",
189
+ upsih: "ϒ",
190
+ piv: "ϖ",
191
+ bull: "•",
192
+ hellip: "…",
193
+ prime: "′",
194
+ Prime: "″",
195
+ oline: "‾",
196
+ frasl: "⁄",
197
+ weierp: "℘",
198
+ image: "ℑ",
199
+ real: "ℜ",
200
+ trade: "™",
201
+ alefsym: "ℵ",
202
+ larr: "←",
203
+ uarr: "↑",
204
+ rarr: "→",
205
+ darr: "↓",
206
+ harr: "↔",
207
+ crarr: "↵",
208
+ lArr: "⇐",
209
+ uArr: "⇑",
210
+ rArr: "⇒",
211
+ dArr: "⇓",
212
+ hArr: "⇔",
213
+ forall: "∀",
214
+ part: "∂",
215
+ exist: "∃",
216
+ empty: "∅",
217
+ nabla: "∇",
218
+ isin: "∈",
219
+ notin: "∉",
220
+ ni: "∋",
221
+ prod: "∏",
222
+ sum: "∑",
223
+ minus: "−",
224
+ lowast: "∗",
225
+ radic: "√",
226
+ prop: "∝",
227
+ infin: "∞",
228
+ ang: "∠",
229
+ and: "∧",
230
+ or: "∨",
231
+ cap: "∩",
232
+ cup: "∪",
233
+ int: "∫",
234
+ there4: "∴",
235
+ sim: "∼",
236
+ cong: "≅",
237
+ asymp: "≈",
238
+ ne: "≠",
239
+ equiv: "≡",
240
+ le: "≤",
241
+ ge: "≥",
242
+ sub: "⊂",
243
+ sup: "⊃",
244
+ nsub: "⊄",
245
+ sube: "⊆",
246
+ supe: "⊇",
247
+ oplus: "⊕",
248
+ otimes: "⊗",
249
+ perp: "⊥",
250
+ sdot: "⋅",
251
+ lceil: "⌈",
252
+ rceil: "⌉",
253
+ lfloor: "⌊",
254
+ rfloor: "⌋",
255
+ lang: "〈",
256
+ rang: "〉",
257
+ loz: "◊",
258
+ spades: "♠",
259
+ clubs: "♣",
260
+ hearts: "♥",
261
+ diams: "♦",
262
+ quot: "\"",
263
+ amp: "&",
264
+ lt: "<",
265
+ gt: ">",
266
+ OElig: "Œ",
267
+ oelig: "œ",
268
+ Scaron: "Š",
269
+ scaron: "š",
270
+ Yuml: "Ÿ",
271
+ circ: "ˆ",
272
+ tilde: "˜",
273
+ ensp: " ",
274
+ emsp: " ",
275
+ thinsp: " ",
276
+ zwnj: "‌",
277
+ zwj: "‍",
278
+ lrm: "‎",
279
+ rlm: "‏",
280
+ ndash: "–",
281
+ mdash: "—",
282
+ lsquo: "‘",
283
+ rsquo: "’",
284
+ sbquo: "‚",
285
+ ldquo: "“",
286
+ rdquo: "”",
287
+ bdquo: "„",
288
+ dagger: "†",
289
+ Dagger: "‡",
290
+ permil: "‰",
291
+ lsaquo: "‹",
292
+ rsaquo: "›",
293
+ euro: "€"
294
+ }, C = [
295
+ "cent",
296
+ "copy",
297
+ "divide",
298
+ "gt",
299
+ "lt",
300
+ "not",
301
+ "para",
302
+ "times"
303
+ ], w = {}.hasOwnProperty, T = {}, E;
304
+ for (E in S) w.call(S, E) && (T[S[E]] = E);
305
+ var D = /[^\dA-Za-z]/;
306
+ function O(e, t, n, r) {
307
+ let i = String.fromCharCode(e);
308
+ if (w.call(T, i)) {
309
+ let e = T[i], a = "&" + e;
310
+ return n && ge.includes(e) && !C.includes(e) && (!r || t && t !== 61 && D.test(String.fromCharCode(t))) ? a : a + ";";
311
+ }
312
+ return "";
313
+ }
314
+ //#endregion
315
+ //#region ../node_modules/stringify-entities/lib/util/format-smart.js
316
+ function k(e, t, n) {
317
+ let r = pe(e, t, n.omitOptionalSemicolons), i;
318
+ if ((n.useNamedReferences || n.useShortestReferences) && (i = O(e, t, n.omitOptionalSemicolons, n.attribute)), (n.useShortestReferences || !i) && n.useShortestReferences) {
319
+ let i = he(e, t, n.omitOptionalSemicolons);
320
+ i.length < r.length && (r = i);
321
+ }
322
+ return i && (!n.useShortestReferences || i.length < r.length) ? i : r;
323
+ }
324
+ //#endregion
325
+ //#region ../node_modules/stringify-entities/lib/index.js
326
+ function A(e, t) {
327
+ return le(e, Object.assign({ format: k }, t));
328
+ }
329
+ //#endregion
330
+ //#region ../node_modules/hast-util-to-html/lib/handle/comment.js
331
+ var j = /^>|^->|<!--|-->|--!>|<!-$/g, M = [">"], N = ["<", ">"];
332
+ function P(e, t, n, r) {
333
+ return r.settings.bogusComments ? "<?" + A(e.value, Object.assign({}, r.settings.characterReferences, { subset: M })) + ">" : "<!--" + e.value.replace(j, i) + "-->";
334
+ function i(e) {
335
+ return A(e, Object.assign({}, r.settings.characterReferences, { subset: N }));
336
+ }
337
+ }
338
+ //#endregion
339
+ //#region ../node_modules/hast-util-to-html/lib/handle/doctype.js
340
+ function F(e, t, n, r) {
341
+ return "<!" + (r.settings.upperDoctype ? "DOCTYPE" : "doctype") + (r.settings.tightDoctype ? "" : " ") + "html>";
342
+ }
343
+ //#endregion
344
+ //#region ../node_modules/hast-util-to-html/lib/omission/util/siblings.js
345
+ var I = R(1), L = R(-1), _e = [];
346
+ function R(e) {
347
+ return t;
348
+ function t(t, n, r) {
349
+ let i = t ? t.children : _e, a = (n || 0) + e, o = i[a];
350
+ if (!r) for (; o && f(o);) a += e, o = i[a];
351
+ return o;
352
+ }
353
+ }
354
+ //#endregion
355
+ //#region ../node_modules/hast-util-to-html/lib/omission/omission.js
356
+ var ve = {}.hasOwnProperty;
357
+ function z(e) {
358
+ return t;
359
+ function t(t, n, r) {
360
+ return ve.call(e, t.tagName) && e[t.tagName](t, n, r);
361
+ }
362
+ }
363
+ //#endregion
364
+ //#region ../node_modules/hast-util-to-html/lib/omission/closing.js
365
+ var B = z({
366
+ body: be,
367
+ caption: V,
368
+ colgroup: V,
369
+ dd: we,
370
+ dt: Ce,
371
+ head: V,
372
+ html: ye,
373
+ li: Se,
374
+ optgroup: Te,
375
+ option: Ee,
376
+ p: xe,
377
+ rp: H,
378
+ rt: H,
379
+ tbody: Oe,
380
+ td: W,
381
+ tfoot: ke,
382
+ th: W,
383
+ thead: De,
384
+ tr: U
385
+ });
386
+ function V(e, t, n) {
387
+ let r = I(n, t, !0);
388
+ return !r || r.type !== "comment" && !(r.type === "text" && f(r.value.charAt(0)));
389
+ }
390
+ function ye(e, t, n) {
391
+ let r = I(n, t);
392
+ return !r || r.type !== "comment";
393
+ }
394
+ function be(e, t, n) {
395
+ let r = I(n, t);
396
+ return !r || r.type !== "comment";
397
+ }
398
+ function xe(e, t, n) {
399
+ let r = I(n, t);
400
+ return r ? r.type === "element" && (r.tagName === "address" || r.tagName === "article" || r.tagName === "aside" || r.tagName === "blockquote" || r.tagName === "details" || r.tagName === "div" || r.tagName === "dl" || r.tagName === "fieldset" || r.tagName === "figcaption" || r.tagName === "figure" || r.tagName === "footer" || r.tagName === "form" || r.tagName === "h1" || r.tagName === "h2" || r.tagName === "h3" || r.tagName === "h4" || r.tagName === "h5" || r.tagName === "h6" || r.tagName === "header" || r.tagName === "hgroup" || r.tagName === "hr" || r.tagName === "main" || r.tagName === "menu" || r.tagName === "nav" || r.tagName === "ol" || r.tagName === "p" || r.tagName === "pre" || r.tagName === "section" || r.tagName === "table" || r.tagName === "ul") : !n || n.type !== "element" || n.tagName !== "a" && n.tagName !== "audio" && n.tagName !== "del" && n.tagName !== "ins" && n.tagName !== "map" && n.tagName !== "noscript" && n.tagName !== "video";
401
+ }
402
+ function Se(e, t, n) {
403
+ let r = I(n, t);
404
+ return !r || r.type === "element" && r.tagName === "li";
405
+ }
406
+ function Ce(e, t, n) {
407
+ let r = I(n, t);
408
+ return !!(r && r.type === "element" && (r.tagName === "dt" || r.tagName === "dd"));
409
+ }
410
+ function we(e, t, n) {
411
+ let r = I(n, t);
412
+ return !r || r.type === "element" && (r.tagName === "dt" || r.tagName === "dd");
413
+ }
414
+ function H(e, t, n) {
415
+ let r = I(n, t);
416
+ return !r || r.type === "element" && (r.tagName === "rp" || r.tagName === "rt");
417
+ }
418
+ function Te(e, t, n) {
419
+ let r = I(n, t);
420
+ return !r || r.type === "element" && r.tagName === "optgroup";
421
+ }
422
+ function Ee(e, t, n) {
423
+ let r = I(n, t);
424
+ return !r || r.type === "element" && (r.tagName === "option" || r.tagName === "optgroup");
425
+ }
426
+ function De(e, t, n) {
427
+ let r = I(n, t);
428
+ return !!(r && r.type === "element" && (r.tagName === "tbody" || r.tagName === "tfoot"));
429
+ }
430
+ function Oe(e, t, n) {
431
+ let r = I(n, t);
432
+ return !r || r.type === "element" && (r.tagName === "tbody" || r.tagName === "tfoot");
433
+ }
434
+ function ke(e, t, n) {
435
+ return !I(n, t);
436
+ }
437
+ function U(e, t, n) {
438
+ let r = I(n, t);
439
+ return !r || r.type === "element" && r.tagName === "tr";
440
+ }
441
+ function W(e, t, n) {
442
+ let r = I(n, t);
443
+ return !r || r.type === "element" && (r.tagName === "td" || r.tagName === "th");
444
+ }
445
+ //#endregion
446
+ //#region ../node_modules/hast-util-to-html/lib/omission/opening.js
447
+ var Ae = z({
448
+ body: Ne,
449
+ colgroup: Pe,
450
+ head: Me,
451
+ html: je,
452
+ tbody: Fe
453
+ });
454
+ function je(e) {
455
+ let t = I(e, -1);
456
+ return !t || t.type !== "comment";
457
+ }
458
+ function Me(e) {
459
+ let t = /* @__PURE__ */ new Set();
460
+ for (let n of e.children) if (n.type === "element" && (n.tagName === "base" || n.tagName === "title")) {
461
+ if (t.has(n.tagName)) return !1;
462
+ t.add(n.tagName);
463
+ }
464
+ let n = e.children[0];
465
+ return !n || n.type === "element";
466
+ }
467
+ function Ne(e) {
468
+ let t = I(e, -1, !0);
469
+ return !t || t.type !== "comment" && !(t.type === "text" && f(t.value.charAt(0))) && (t.type !== "element" || t.tagName !== "meta" && t.tagName !== "link" && t.tagName !== "script" && t.tagName !== "style" && t.tagName !== "template");
470
+ }
471
+ function Pe(e, t, n) {
472
+ let r = L(n, t), i = I(e, -1, !0);
473
+ return n && r && r.type === "element" && r.tagName === "colgroup" && B(r, n.children.indexOf(r), n) ? !1 : !!(i && i.type === "element" && i.tagName === "col");
474
+ }
475
+ function Fe(e, t, n) {
476
+ let r = L(n, t), i = I(e, -1);
477
+ return n && r && r.type === "element" && (r.tagName === "thead" || r.tagName === "tbody") && B(r, n.children.indexOf(r), n) ? !1 : !!(i && i.type === "element" && i.tagName === "tr");
478
+ }
479
+ //#endregion
480
+ //#region ../node_modules/hast-util-to-html/lib/handle/element.js
481
+ var G = {
482
+ name: [[" \n\f\r &/=>".split(""), " \n\f\r \"&'/=>`".split("")], ["\0 \n\f\r \"&'/<=>".split(""), "\0 \n\f\r \"&'/<=>`".split("")]],
483
+ unquoted: [[" \n\f\r &>".split(""), "\0 \n\f\r \"&'<=>`".split("")], ["\0 \n\f\r \"&'<=>`".split(""), "\0 \n\f\r \"&'<=>`".split("")]],
484
+ single: [["&'".split(""), "\"&'`".split("")], ["\0&'".split(""), "\0\"&'`".split("")]],
485
+ double: [["\"&".split(""), "\"&'`".split("")], ["\0\"&".split(""), "\0\"&'`".split("")]]
486
+ };
487
+ function Ie(e, t, n, i) {
488
+ let a = i.schema, o = a.space !== "svg" && i.settings.omitOptionalTags, s = a.space === "svg" ? i.settings.closeEmptyElements : i.settings.voids.includes(e.tagName.toLowerCase()), c = [], l;
489
+ a.space === "html" && e.tagName === "svg" && (i.schema = r);
490
+ let u = Le(i, e.properties), d = i.all(a.space === "html" && e.tagName === "template" ? e.content : e);
491
+ return i.schema = a, d && (s = !1), (u || !o || !Ae(e, t, n)) && (c.push("<", e.tagName, u ? " " + u : ""), s && (a.space === "svg" || i.settings.closeSelfClosing) && (l = u.charAt(u.length - 1), (!i.settings.tightSelfClosing || l === "/" || l && l !== "\"" && l !== "'") && c.push(" "), c.push("/")), c.push(">")), c.push(d), !s && (!o || !B(e, t, n)) && c.push("</" + e.tagName + ">"), c.join("");
492
+ }
493
+ function Le(e, t) {
494
+ let n = [], r = -1, i;
495
+ if (t) {
496
+ for (i in t) if (t[i] !== null && t[i] !== void 0) {
497
+ let r = Re(e, i, t[i]);
498
+ r && n.push(r);
499
+ }
500
+ }
501
+ for (; ++r < n.length;) {
502
+ let t = e.settings.tightAttributes ? n[r].charAt(n[r].length - 1) : void 0;
503
+ r !== n.length - 1 && t !== "\"" && t !== "'" && (n[r] += " ");
504
+ }
505
+ return n.join("");
506
+ }
507
+ function Re(t, n, r) {
508
+ let i = e(t.schema, n), a = t.settings.allowParseErrors && t.schema.space === "html" ? 0 : 1, s = +!t.settings.allowDangerousCharacters, c = t.quote, l;
509
+ if (i.overloadedBoolean && (r === i.attribute || r === "") ? r = !0 : (i.boolean || i.overloadedBoolean) && (typeof r != "string" || r === i.attribute || r === "") && (r = !!r), r == null || r === !1 || typeof r == "number" && Number.isNaN(r)) return "";
510
+ let u = A(i.attribute, Object.assign({}, t.settings.characterReferences, { subset: G.name[a][s] }));
511
+ return r === !0 || (r = Array.isArray(r) ? (i.commaSeparated ? p : o)(r, { padLeft: !t.settings.tightCommaSeparatedLists }) : String(r), t.settings.collapseEmptyAttributes && !r) ? u : (t.settings.preferUnquoted && (l = A(r, Object.assign({}, t.settings.characterReferences, {
512
+ attribute: !0,
513
+ subset: G.unquoted[a][s]
514
+ }))), l !== r && (t.settings.quoteSmart && v(r, c) > v(r, t.alternative) && (c = t.alternative), l = c + A(r, Object.assign({}, t.settings.characterReferences, {
515
+ subset: (c === "'" ? G.single : G.double)[a][s],
516
+ attribute: !0
517
+ })) + c), u + (l && "=" + l));
518
+ }
519
+ //#endregion
520
+ //#region ../node_modules/hast-util-to-html/lib/handle/text.js
521
+ var ze = ["<", "&"];
522
+ function K(e, t, n, r) {
523
+ return n && n.type === "element" && (n.tagName === "script" || n.tagName === "style") ? e.value : A(e.value, Object.assign({}, r.settings.characterReferences, { subset: ze }));
524
+ }
525
+ //#endregion
526
+ //#region ../node_modules/hast-util-to-html/lib/handle/raw.js
527
+ function Be(e, t, n, r) {
528
+ return r.settings.allowDangerousHtml ? e.value : K(e, t, n, r);
529
+ }
530
+ //#endregion
531
+ //#region ../node_modules/hast-util-to-html/lib/handle/root.js
532
+ function Ve(e, t, n, r) {
533
+ return r.all(e);
534
+ }
535
+ //#endregion
536
+ //#region ../node_modules/hast-util-to-html/lib/handle/index.js
537
+ var He = d("type", {
538
+ invalid: Ue,
539
+ unknown: We,
540
+ handlers: {
541
+ comment: P,
542
+ doctype: F,
543
+ element: Ie,
544
+ raw: Be,
545
+ root: Ve,
546
+ text: K
547
+ }
548
+ });
549
+ function Ue(e) {
550
+ throw Error("Expected node, not `" + e + "`");
551
+ }
552
+ function We(e) {
553
+ throw Error("Cannot compile unknown node `" + e.type + "`");
554
+ }
555
+ //#endregion
556
+ //#region ../node_modules/hast-util-to-html/lib/index.js
557
+ var Ge = {}, Ke = {}, qe = [];
558
+ function Je(e, t) {
559
+ let n = t || Ge, o = n.quote || "\"", s = o === "\"" ? "'" : "\"";
560
+ if (o !== "\"" && o !== "'") throw Error("Invalid quote `" + o + "`, expected `'` or `\"`");
561
+ return {
562
+ one: Ye,
563
+ all: Xe,
564
+ settings: {
565
+ omitOptionalTags: n.omitOptionalTags || !1,
566
+ allowParseErrors: n.allowParseErrors || !1,
567
+ allowDangerousCharacters: n.allowDangerousCharacters || !1,
568
+ quoteSmart: n.quoteSmart || !1,
569
+ preferUnquoted: n.preferUnquoted || !1,
570
+ tightAttributes: n.tightAttributes || !1,
571
+ upperDoctype: n.upperDoctype || !1,
572
+ tightDoctype: n.tightDoctype || !1,
573
+ bogusComments: n.bogusComments || !1,
574
+ tightCommaSeparatedLists: n.tightCommaSeparatedLists || !1,
575
+ tightSelfClosing: n.tightSelfClosing || !1,
576
+ collapseEmptyAttributes: n.collapseEmptyAttributes || !1,
577
+ allowDangerousHtml: n.allowDangerousHtml || !1,
578
+ voids: n.voids || a,
579
+ characterReferences: n.characterReferences || Ke,
580
+ closeSelfClosing: n.closeSelfClosing || !1,
581
+ closeEmptyElements: n.closeEmptyElements || !1
582
+ },
583
+ schema: n.space === "svg" ? r : i,
584
+ quote: o,
585
+ alternative: s
586
+ }.one(Array.isArray(e) ? {
587
+ type: "root",
588
+ children: e
589
+ } : e, void 0, void 0);
590
+ }
591
+ function Ye(e, t, n) {
592
+ return He(e, t, n, this);
593
+ }
594
+ function Xe(e) {
595
+ let t = [], n = e && e.children || qe, r = -1;
596
+ for (; ++r < n.length;) t[r] = this.one(n[r], r, e);
597
+ return t.join("");
598
+ }
599
+ //#endregion
600
+ //#region ../ui/src/export/conversationHtml.ts
601
+ var Ze = class extends Error {
602
+ bytes;
603
+ budgetBytes;
604
+ constructor(e, t) {
605
+ super(`the conversation's images come to ${Math.round(e / 1024)} kB, over the ${Math.round(t / 1024)} kB this export embeds`), this.name = "ExportBudgetError", this.bytes = e, this.budgetBytes = t;
606
+ }
607
+ }, q = g().use(te).use(_).use(ee).use(l, { allowDangerousHtml: !0 }).use(t).use(u, c).use(n, { output: "mathml" });
608
+ function Qe(e) {
609
+ let t = e.properties?.className;
610
+ return (Array.isArray(t) ? t.map(String) : typeof t == "string" ? [t] : []).find((e) => e.startsWith("language-"))?.slice(9);
611
+ }
612
+ async function J(e, t, n) {
613
+ if (e.tagName === "img") {
614
+ let r = typeof e.properties?.src == "string" ? e.properties.src : "", i = r ? await t.loadImage(r) : void 0;
615
+ if (!i) return {
616
+ type: "element",
617
+ tagName: "em",
618
+ properties: {},
619
+ children: [{
620
+ type: "text",
621
+ value: `[image: ${typeof e.properties?.alt == "string" ? e.properties.alt : r}]`
622
+ }]
623
+ };
624
+ n.bytes += i.bytes;
625
+ let a = t.budgetBytes ?? 41943040;
626
+ if (n.bytes > a) throw new Ze(n.bytes, a);
627
+ return {
628
+ ...e,
629
+ properties: {
630
+ ...e.properties,
631
+ src: i.dataUrl,
632
+ loading: "lazy"
633
+ }
634
+ };
635
+ }
636
+ if (e.tagName === "pre" && e.children?.length === 1 && e.children[0].tagName === "code") {
637
+ let r = e.children[0];
638
+ if (Qe(r) === "mermaid" && t.renderDiagram) {
639
+ let e = Y(r);
640
+ n.diagrams += 1;
641
+ let i = await t.renderDiagram(e, `pi-export-diagram-${n.diagrams}`);
642
+ if (i) return {
643
+ type: "element",
644
+ tagName: "figure",
645
+ properties: { className: ["diagram"] },
646
+ children: [{
647
+ type: "raw",
648
+ value: i
649
+ }]
650
+ };
651
+ }
652
+ }
653
+ if (!e.children) return e;
654
+ let r = [];
655
+ for (let i of e.children) r.push(await J(i, t, n));
656
+ return {
657
+ ...e,
658
+ children: r
659
+ };
660
+ }
661
+ function Y(e) {
662
+ return e.type === "text" ? e.value ?? "" : (e.children ?? []).map(Y).join("");
663
+ }
664
+ async function X(e, t, n) {
665
+ return Je(await J(await q.run(q.parse(m(e))), t, n), { allowDangerousHtml: !0 });
666
+ }
667
+ function Z(e) {
668
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
669
+ }
670
+ var $e = ":root {\n --bg: #ffffff; --fg: #18181b; --muted: #71717a; --line: #e4e4e7;\n --user-bg: #eff6ff; --tool-bg: #fafafa; --mark-bg: #fffbeb; --mark-fg: #92400e;\n}\n@media (prefers-color-scheme: dark) {\n :root {\n --bg: #18181b; --fg: #e4e4e7; --muted: #a1a1aa; --line: #3f3f46;\n --user-bg: #1e293b; --tool-bg: #27272a; --mark-bg: #292524; --mark-fg: #fcd34d;\n }\n}\n* { box-sizing: border-box; }\nbody {\n margin: 0; padding: 2rem 1rem; background: var(--bg); color: var(--fg);\n font: 16px/1.6 -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;\n}\nmain { max-width: 46rem; margin: 0 auto; }\nheader.doc { border-bottom: 1px solid var(--line); padding-bottom: 1rem; margin-bottom: 2rem; }\nheader.doc h1 { font-size: 1.4rem; margin: 0 0 0.35rem; }\nheader.doc dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.15rem 0.75rem; margin: 0; font-size: 0.85rem; color: var(--muted); }\nheader.doc dt { font-weight: 600; }\nheader.doc dd { margin: 0; }\narticle { margin: 1.25rem 0; }\narticle > .who { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 0.3rem; }\narticle.user .body { background: var(--user-bg); border-radius: 0.6rem; padding: 0.6rem 0.9rem; }\narticle.reasoning .body { border-left: 2px solid var(--line); padding-left: 0.9rem; color: var(--muted); font-style: italic; }\ndetails.tool { background: var(--tool-bg); border: 1px solid var(--line); border-radius: 0.6rem; padding: 0.4rem 0.7rem; }\ndetails.tool > summary { cursor: pointer; font-size: 0.85rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }\ndetails.tool pre { white-space: pre-wrap; word-break: break-word; }\n.compaction { display: flex; align-items: center; gap: 0.6rem; margin: 2rem 0; color: var(--mark-fg); font-size: 0.8rem; }\n.compaction::before, .compaction::after { content: \"\"; flex: 1; height: 1px; background: currentColor; opacity: 0.4; }\n.compaction-summary { background: var(--mark-bg); color: var(--fg); border-radius: 0.6rem; padding: 0.6rem 0.9rem; font-size: 0.9rem; }\npre { background: var(--tool-bg); border-radius: 0.5rem; padding: 0.7rem; overflow-x: auto; }\ncode { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }\nimg, svg { max-width: 100%; height: auto; }\nfigure.diagram { margin: 1rem 0; overflow-x: auto; }\ntable { border-collapse: collapse; width: 100%; }\nth, td { border: 1px solid var(--line); padding: 0.3rem 0.5rem; text-align: left; }\nblockquote { margin: 0.8rem 0; padding-left: 0.9rem; border-left: 3px solid var(--line); color: var(--muted); }\nfooter.doc { margin-top: 3rem; border-top: 1px solid var(--line); padding-top: 0.8rem; font-size: 0.75rem; color: var(--muted); }", Q = {
671
+ user: "You",
672
+ assistant: "Agent"
673
+ };
674
+ async function et(e, t, n) {
675
+ switch (e.kind) {
676
+ case "user": {
677
+ let r = (e.images ?? []).map((e) => `<img src="data:${Z(e.mimeType)};base64,${e.data}" alt="attached image" />`).join("\n"), i = await X(e.text, t, n);
678
+ return `<article class="user"><p class="who">${Q.user}</p><div class="body">${i}${r}</div></article>`;
679
+ }
680
+ case "assistant": {
681
+ let r = [];
682
+ for (let i of e.blocks) {
683
+ let e = await X(i.text, t, n);
684
+ r.push(i.type === "thinking" ? `<div class="body"><p class="who">reasoning</p>${e}</div>` : `<div class="body">${e}</div>`);
685
+ }
686
+ let i = e.errorMessage ? `<p class="body"><em>${Z(e.errorMessage)}</em></p>` : "";
687
+ return `<article class="${e.blocks.every((e) => e.type === "thinking") ? "assistant reasoning" : "assistant"}"><p class="who">${Q.assistant}</p>${r.join("\n")}${i}</article>`;
688
+ }
689
+ case "tool": {
690
+ let t = typeof e.args == "string" ? e.args : JSON.stringify(e.args ?? {}, null, 2), n = e.isError ? " — failed" : "";
691
+ return [
692
+ "<article class=\"tool\"><details class=\"tool\">",
693
+ `<summary>${Z(e.toolName)}${n}</summary>`,
694
+ `<pre><code>${Z(t)}</code></pre>`,
695
+ `<pre><code>${Z(e.output)}</code></pre>`,
696
+ "</details></article>"
697
+ ].join("");
698
+ }
699
+ case "custom": return `<article class="custom"><p class="who">${Z(e.customType)}</p><div class="body"><pre><code>${Z(e.text)}</code></pre></div></article>`;
700
+ case "compaction": {
701
+ let r = e.tokensBefore ? ` — ${Math.round(e.tokensBefore / 1e3)}k tokens summarised` : "", i = e.summary ? `<div class="compaction-summary">${await X(e.summary, t, n)}</div>` : "";
702
+ return `<div class="compaction">conversation compacted here${Z(r)}</div>${i}`;
703
+ }
704
+ }
705
+ }
706
+ async function tt(e, t) {
707
+ let n = {
708
+ bytes: 0,
709
+ diagrams: 0
710
+ }, r = [];
711
+ for (let [i, a] of e.entries()) r.push(await et(a, t, n)), t.onProgress?.(i + 1, e.length);
712
+ let { meta: i } = t, a = i.project ? `${i.session} — ${i.project}` : i.session, o = [];
713
+ return i.project && o.push(`<dt>Project</dt><dd>${Z(i.project)}</dd>`), o.push(`<dt>Session</dt><dd>${Z(i.session)}</dd>`), i.model && o.push(`<dt>Model</dt><dd>${Z(i.model)}</dd>`), o.push(`<dt>Exported</dt><dd>${Z(i.exportedAt.toISOString().slice(0, 10))}</dd>`), o.push(`<dt>Messages</dt><dd>${e.length}</dd>`), `<!doctype html>
714
+ <html lang="en">
715
+ <head>
716
+ <meta charset="utf-8" />
717
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
718
+ <title>${Z(a)}</title>
719
+ <style>
720
+ ${$e}
721
+ </style>
722
+ </head>
723
+ <body>
724
+ <main>
725
+ <header class="doc">
726
+ <h1>${Z(a)}</h1>
727
+ <dl>${o.join("")}</dl>
728
+ </header>
729
+ ${r.join("\n")}
730
+ <footer class="doc">Exported from pi-outpost. This file is self-contained: it needs no network and no scripting.</footer>
731
+ </main>
732
+ </body>
733
+ </html>
734
+ `;
735
+ }
736
+ //#endregion
737
+ //#region ../ui/src/export/conversationExport.ts
738
+ var $ = class extends Error {
739
+ constructor(e) {
740
+ super(e), this.name = "ConversationExportError";
741
+ }
742
+ };
743
+ async function nt(e) {
744
+ let t = /* @__PURE__ */ new Map();
745
+ return async (n) => {
746
+ if (t.has(n)) return t.get(n);
747
+ let r = ie("", n, e.serverUrl, e.token), i;
748
+ if (r !== void 0) try {
749
+ let e = await fetch(r);
750
+ if (e.ok) {
751
+ let t = new Uint8Array(await e.arrayBuffer());
752
+ i = {
753
+ dataUrl: `data:${e.headers.get("content-type") ?? "application/octet-stream"};base64,${rt(t)}`,
754
+ bytes: t.byteLength
755
+ };
756
+ }
757
+ } catch {
758
+ i = void 0;
759
+ }
760
+ return t.set(n, i), i;
761
+ };
762
+ }
763
+ function rt(e) {
764
+ let t = "", n = 32768;
765
+ for (let r = 0; r < e.length; r += n) t += String.fromCharCode(...e.subarray(r, r + n));
766
+ return btoa(t);
767
+ }
768
+ async function it(e, t) {
769
+ try {
770
+ let { svg: n } = await re(e, t), { width: r, height: i } = ne(n);
771
+ return oe(ae(n, r, i));
772
+ } catch {
773
+ return;
774
+ }
775
+ }
776
+ function at(e, t) {
777
+ let n = e.normalize("NFKD").replace(/[^\p{L}\p{N}\s-]/gu, "").trim().replace(/\s+/g, "-").slice(0, 60), r = t.toISOString().slice(0, 10);
778
+ return `${n || "conversation"}-${r}.html`;
779
+ }
780
+ async function ot(e) {
781
+ if (e.items.length === 0) throw new $("there is no conversation to export yet");
782
+ let t = [];
783
+ if (e.olderItems > 0) {
784
+ if (!e.fetchOlderItems) throw new $("this conversation has been compacted and the agent runtime cannot read back what it removed, so it cannot be exported in full");
785
+ try {
786
+ t = await s(e.fetchOlderItems, (t) => e.onProgress?.("collecting", t, e.olderItems));
787
+ } catch (e) {
788
+ throw new $(`the earlier part of the conversation could not be read back, so nothing was exported: ${e instanceof Error ? e.message : String(e)}`);
789
+ }
790
+ }
791
+ return tt([...t, ...e.items], {
792
+ meta: e.meta,
793
+ loadImage: await nt(e.connection),
794
+ renderDiagram: it,
795
+ budgetBytes: e.budgetBytes ?? 41943040,
796
+ onProgress: (t, n) => e.onProgress?.("rendering", t, n)
797
+ });
798
+ }
799
+ async function st(e) {
800
+ let t = await ot(e);
801
+ h(new Blob([t], { type: "text/html;charset=utf-8" }), at(e.meta.session, e.meta.exportedAt));
802
+ }
803
+ //#endregion
804
+ export { st as exportConversation };