@dotit/editor 1.0.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.
package/dist/index.mjs ADDED
@@ -0,0 +1,3142 @@
1
+ import { jsxs as h, jsx as i, Fragment as he } from "react/jsx-runtime";
2
+ import { useState as B, useRef as P, useEffect as j, useCallback as R, useMemo as K, useLayoutEffect as be } from "react";
3
+ import { useEditor as ye, EditorContent as ke } from "@tiptap/react";
4
+ import Se from "@tiptap/starter-kit";
5
+ import we from "@tiptap/extension-placeholder";
6
+ import ve from "@tiptap/extension-underline";
7
+ import { TextStyle as Te } from "@tiptap/extension-text-style";
8
+ import xe from "@tiptap/extension-color";
9
+ import Ae from "@tiptap/extension-highlight";
10
+ import Ce from "@tiptap/extension-text-align";
11
+ import Le from "@tiptap/extension-font-family";
12
+ import $e from "@tiptap/extension-subscript";
13
+ import Ne from "@tiptap/extension-superscript";
14
+ import { Extension as vt, Node as E, mergeAttributes as z } from "@tiptap/core";
15
+ import { Plugin as Xt, PluginKey as te } from "@tiptap/pm/state";
16
+ import { DecorationSet as St, Decoration as $t } from "@tiptap/pm/view";
17
+ import { parseIntentText as tt, listBuiltinThemes as ze, renderPrint as Me, cssContentValue as _e, LANGUAGE_REGISTRY as He, getBuiltinTheme as Re, generateThemeCSS as Ee, verifyDocument as Be, documentStyleCSS as Pe } from "@dotit/core";
18
+ import Ie from "@tiptap/extension-paragraph";
19
+ import { Undo2 as Oe, Redo2 as De, Printer as Fe, FileCode2 as je, Droplets as We, ChevronDown as yt, Minus as Ge, Plus as Pt, Bold as Ue, Italic as Ye, Underline as Ke, Strikethrough as qe, Palette as Je, RemoveFormatting as It, Highlighter as Ve, Subscript as Qe, Superscript as Ze, Code as Xe, AlignLeft as tn, AlignCenter as en, AlignRight as nn, AlignJustify as rn, Rows3 as on, List as sn, ListOrdered as an, AlignHorizontalSpaceBetween as Ot, FileLock2 as cn, PenTool as ln, ShieldCheck as dn } from "lucide-react";
20
+ const un = vt.create({
21
+ name: "fontSize",
22
+ addOptions() {
23
+ return { types: ["textStyle"] };
24
+ },
25
+ addGlobalAttributes() {
26
+ return [
27
+ {
28
+ types: this.options.types,
29
+ attributes: {
30
+ fontSize: {
31
+ default: null,
32
+ parseHTML: (t) => t.style.fontSize?.replace(/['"]+/g, "") || null,
33
+ renderHTML: (t) => t.fontSize ? { style: `font-size: ${t.fontSize}` } : {}
34
+ }
35
+ }
36
+ }
37
+ ];
38
+ },
39
+ addCommands() {
40
+ return {
41
+ setFontSize: (t) => ({ chain: e }) => e().setMark("textStyle", { fontSize: t }).run(),
42
+ unsetFontSize: () => ({ chain: t }) => t().setMark("textStyle", { fontSize: null }).removeEmptyTextStyle().run()
43
+ };
44
+ }
45
+ }), X = 96 / 25.4, kt = {
46
+ A4: [210, 297],
47
+ A5: [148, 210],
48
+ A3: [297, 420],
49
+ Letter: [215.9, 279.4],
50
+ Legal: [215.9, 355.6],
51
+ Tabloid: [279.4, 431.8]
52
+ }, pn = 20, fn = 4, gn = 120;
53
+ function Nt(t) {
54
+ const e = /^(-?\d+(?:\.\d+)?)\s*(mm|cm|in|px|pt)?$/.exec(t.trim());
55
+ if (!e) return null;
56
+ const n = parseFloat(e[1]);
57
+ switch (e[2] || "mm") {
58
+ case "mm":
59
+ return n * X;
60
+ case "cm":
61
+ return n * 10 * X;
62
+ case "in":
63
+ return n * 96;
64
+ case "pt":
65
+ return n / 72 * 96;
66
+ case "px":
67
+ return n;
68
+ default:
69
+ return null;
70
+ }
71
+ }
72
+ function mn(t, e) {
73
+ const n = t.trim().split(/\s+/).map(Nt);
74
+ if (n.some((o) => o === null) || n.length === 0)
75
+ return [e, e, e, e];
76
+ const r = n;
77
+ return r.length === 1 ? [r[0], r[0], r[0], r[0]] : r.length === 2 ? [r[0], r[1], r[0], r[1]] : r.length === 3 ? [r[0], r[1], r[2], r[1]] : [r[0], r[1], r[2], r[3]];
78
+ }
79
+ function zt(t) {
80
+ let e = "A4", n, r = "", o = "";
81
+ try {
82
+ const T = tt(t), S = T.blocks.find((v) => v.type === "page")?.properties || {};
83
+ S.size && (e = String(S.size)), n = S.margin ?? S.margins, r = T.blocks.find((v) => v.type === "header")?.content || String(S.header || ""), o = T.blocks.find((v) => v.type === "footer")?.content || String(S.footer || "");
84
+ } catch {
85
+ }
86
+ let l = kt.A4[0] * X, a = kt.A4[1] * X, u = !1;
87
+ const c = kt[e] || kt[e.toUpperCase?.()];
88
+ if (c)
89
+ l = c[0] * X, a = c[1] * X;
90
+ else {
91
+ const T = e.trim().split(/\s+/), M = T[0] ? Nt(T[0]) : null;
92
+ if (M && (l = M), T[1] === "auto")
93
+ u = !0, a = 1 / 0;
94
+ else {
95
+ const S = T[1] ? Nt(T[1]) : null;
96
+ S && (a = S);
97
+ }
98
+ }
99
+ const g = (l <= gn * X ? fn : pn) * X, [p, b, f, k] = n ? mn(n, g) : [g, g, g, g];
100
+ return {
101
+ width: l,
102
+ height: a,
103
+ autoHeight: u,
104
+ marginTop: p,
105
+ marginRight: b,
106
+ marginBottom: f,
107
+ marginLeft: k,
108
+ contentHeight: u ? 1 / 0 : a - p - f,
109
+ header: r,
110
+ footer: o
111
+ };
112
+ }
113
+ function ee(t, e, n) {
114
+ return t.replace(/\{\{\s*page\s*\}\}/g, String(e)).replace(/\{\{\s*pages\s*\}\}/g, String(n));
115
+ }
116
+ const ft = new te("pagination");
117
+ function xt(t, e, n, r) {
118
+ const o = ee(e, n, r);
119
+ return `<div class="docs-pb-${t}">
120
+ <span class="docs-pb-text">${hn(o)}</span>
121
+ </div>`;
122
+ }
123
+ function hn(t) {
124
+ return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
125
+ }
126
+ const bn = vt.create({
127
+ name: "pagination",
128
+ addOptions() {
129
+ return {
130
+ geometry: () => ({
131
+ width: 794,
132
+ height: 1122.52,
133
+ autoHeight: !1,
134
+ marginTop: 75.59,
135
+ marginRight: 75.59,
136
+ marginBottom: 75.59,
137
+ marginLeft: 75.59,
138
+ contentHeight: 971.34,
139
+ header: "",
140
+ footer: ""
141
+ }),
142
+ gap: 28,
143
+ onPages: void 0
144
+ };
145
+ },
146
+ addProseMirrorPlugins() {
147
+ const t = this.options;
148
+ return [
149
+ new Xt({
150
+ key: ft,
151
+ state: {
152
+ init: () => St.empty,
153
+ apply(e, n) {
154
+ const r = e.getMeta(ft);
155
+ return r || n.map(e.mapping, e.doc);
156
+ }
157
+ },
158
+ props: {
159
+ decorations(e) {
160
+ return ft.getState(e);
161
+ }
162
+ },
163
+ view(e) {
164
+ let n = 0, r = "";
165
+ const o = (c, g, p, b) => {
166
+ const f = document.createElement("div");
167
+ return f.className = "docs-page-spacer", f.contentEditable = "false", f.setAttribute("data-it-spacer", ""), f.style.setProperty("--pb-mx-l", `${c.marginLeft}px`), f.style.setProperty("--pb-mx-r", `${c.marginRight}px`), f.innerHTML = `
168
+ <div class="docs-pb-fill" style="height:${g}px"></div>
169
+ <div class="docs-pb-margin docs-pb-margin-bottom" style="height:${c.marginBottom}px">
170
+ ${xt("footer", c.footer, p, b)}
171
+ </div>
172
+ <div class="docs-pb-gap" style="height:${t.gap}px"></div>
173
+ <div class="docs-pb-margin docs-pb-margin-top" style="height:${c.marginTop}px">
174
+ ${xt("header", c.header, p + 1, b)}
175
+ </div>`, f;
176
+ }, l = (c, g, p, b) => {
177
+ const f = document.createElement("div");
178
+ return f.className = "docs-page-spacer docs-page-tail", f.contentEditable = "false", f.setAttribute("data-it-spacer", ""), f.style.setProperty("--pb-mx-l", `${c.marginLeft}px`), f.style.setProperty("--pb-mx-r", `${c.marginRight}px`), f.innerHTML = `
179
+ <div class="docs-pb-fill" style="height:${g}px"></div>
180
+ <div class="docs-pb-margin docs-pb-margin-bottom" style="height:${c.marginBottom}px">
181
+ ${xt("footer", c.footer, p, b)}
182
+ </div>`, f;
183
+ }, a = () => {
184
+ const c = t.geometry(), g = e.dom, p = e.state.doc;
185
+ if (c.autoHeight) {
186
+ r !== "auto" && (r = "auto", e.dispatch(
187
+ e.state.tr.setMeta(ft, St.empty)
188
+ ), t.onPages?.(1));
189
+ return;
190
+ }
191
+ const b = g.getBoundingClientRect().top, f = Array.from(g.children), k = [];
192
+ let T = 0;
193
+ for (const N of f) {
194
+ if (N.hasAttribute?.("data-it-spacer")) {
195
+ T += N.offsetHeight;
196
+ continue;
197
+ }
198
+ const H = N.getBoundingClientRect();
199
+ k.push({
200
+ natTop: H.top - b - T,
201
+ natBottom: H.bottom - b - T
202
+ });
203
+ }
204
+ const M = [];
205
+ let S = 0, v = k.length ? k[0].natTop : 0, nt = v;
206
+ for (let N = 0; N < k.length && N < p.childCount; N++) {
207
+ const H = k[N], ot = p.child(N).nodeSize;
208
+ H.natTop > v && // never break before the page's first block
209
+ H.natBottom - v > c.contentHeight && (M.push({
210
+ pos: S,
211
+ rest: Math.max(0, c.contentHeight - (H.natTop - v))
212
+ }), v = H.natTop), nt = H.natBottom, S += ot;
213
+ }
214
+ const I = M.length + 1, G = Math.max(
215
+ 0,
216
+ c.contentHeight - (nt - v)
217
+ ), U = M.map((N) => `${N.pos}:${Math.round(N.rest)}`).join(",") + `|${Math.round(G)}|${I}|${c.header}|${c.footer}|${Math.round(c.contentHeight)}`;
218
+ if (U === r) return;
219
+ r = U;
220
+ const F = M.map(
221
+ (N, H) => $t.widget(
222
+ N.pos,
223
+ () => o(c, N.rest, H + 1, I),
224
+ { side: -1, key: `pb-${H + 1}-${Math.round(N.rest)}` }
225
+ )
226
+ );
227
+ F.push(
228
+ $t.widget(
229
+ p.content.size,
230
+ () => l(c, G, I, I),
231
+ { side: 1, key: `pb-tail-${I}-${Math.round(G)}` }
232
+ )
233
+ );
234
+ const rt = St.create(e.state.doc, F);
235
+ e.dispatch(e.state.tr.setMeta(ft, rt)), t.onPages?.(I);
236
+ }, u = () => {
237
+ cancelAnimationFrame(n), n = requestAnimationFrame(a);
238
+ };
239
+ return u(), {
240
+ update: u,
241
+ destroy: () => cancelAnimationFrame(n)
242
+ };
243
+ }
244
+ })
245
+ ];
246
+ }
247
+ }), Dt = /* @__PURE__ */ new Set(["tip", "info", "warning", "danger", "success"]), yn = /* @__PURE__ */ new Set([
248
+ "page",
249
+ "meta",
250
+ "font",
251
+ "header",
252
+ "footer",
253
+ "watermark"
254
+ ]), kn = /* @__PURE__ */ new Set([
255
+ "sign",
256
+ "seal",
257
+ "approve",
258
+ "freeze",
259
+ "amend",
260
+ "amendment"
261
+ ]), Ft = {
262
+ title: "itTitle",
263
+ section: "itSection",
264
+ sub: "itSub"
265
+ }, Sn = {
266
+ note: "text",
267
+ "body-text": "text"
268
+ }, wn = /* @__PURE__ */ new Set([
269
+ "weight",
270
+ "italic",
271
+ "underline",
272
+ "strike",
273
+ "color",
274
+ "family",
275
+ "size",
276
+ "bg",
277
+ "valign",
278
+ "align",
279
+ // legacy aliases
280
+ "style",
281
+ "font",
282
+ "bgcolor"
283
+ ]);
284
+ function vn(t) {
285
+ if (!t || t === "{}") return {};
286
+ try {
287
+ return typeof t == "string" ? JSON.parse(t) : t || {};
288
+ } catch {
289
+ return {};
290
+ }
291
+ }
292
+ function D(t, e) {
293
+ const n = Object.entries(t).filter(
294
+ ([r, o]) => o !== void 0 && o !== "" && (!e || !e.has(r))
295
+ );
296
+ return n.length === 0 ? "" : " | " + n.map(([r, o]) => `${r}: ${o}`).join(" | ");
297
+ }
298
+ function Mt(t) {
299
+ if (!t) return [];
300
+ const e = t.split("\\n"), n = [];
301
+ return e.forEach((r, o) => {
302
+ r && n.push({ type: "text", text: r }), o < e.length - 1 && n.push({ type: "hardBreak" });
303
+ }), n;
304
+ }
305
+ function Tn(t) {
306
+ switch (t.type) {
307
+ case "bold":
308
+ return [{ type: "bold" }];
309
+ case "italic":
310
+ return [{ type: "italic" }];
311
+ case "strike":
312
+ return [{ type: "strike" }];
313
+ case "code":
314
+ return [{ type: "code" }];
315
+ case "highlight":
316
+ return [{ type: "highlight" }];
317
+ case "styled": {
318
+ const e = t.props || {}, n = [], r = {};
319
+ return e.weight && e.weight !== "normal" && n.push({ type: "bold" }), e.italic === "true" && n.push({ type: "italic" }), e.underline === "true" && n.push({ type: "underline" }), e.strike === "true" && n.push({ type: "strike" }), e.color && (r.color = e.color), e.family && (r.fontFamily = e.family), e.size && (r.fontSize = e.size), Object.keys(r).length && n.push({ type: "textStyle", attrs: r }), e.bg && n.push({ type: "highlight", attrs: { color: e.bg } }), e.valign === "sub" && n.push({ type: "subscript" }), e.valign === "super" && n.push({ type: "superscript" }), n.length ? n : null;
320
+ }
321
+ default:
322
+ return null;
323
+ }
324
+ }
325
+ const xn = /* @__PURE__ */ new Set([
326
+ "text",
327
+ "bold",
328
+ "italic",
329
+ "strike",
330
+ "highlight",
331
+ "styled"
332
+ ]);
333
+ function An(t, e) {
334
+ if (!t || t.length === 0 || t.every((r) => r.type === "text") || !t.every((r) => xn.has(r.type)))
335
+ return Mt(e);
336
+ const n = [];
337
+ for (const r of t) {
338
+ const o = Tn(r), a = (r.value ?? "").split("\\n");
339
+ a.forEach((u, c) => {
340
+ u && n.push(o ? { type: "text", text: u, marks: o } : { type: "text", text: u }), c < a.length - 1 && n.push({ type: "hardBreak" });
341
+ });
342
+ }
343
+ return n.length ? n : Mt(e);
344
+ }
345
+ function Cn(t, e) {
346
+ if (!e || t.length === 0) return t;
347
+ const n = [], r = {}, o = e, l = o.family ?? o.font, a = o.bg ?? o.bgcolor;
348
+ return String(o.weight || "").toLowerCase() === "bold" && n.push({ type: "bold" }), (String(o.italic || "") === "true" || String(o.style || "").toLowerCase() === "italic") && n.push({ type: "italic" }), String(o.underline || "") === "true" && n.push({ type: "underline" }), String(o.strike || "") === "true" && n.push({ type: "strike" }), String(o.valign || "") === "sub" && n.push({ type: "subscript" }), String(o.valign || "") === "super" && n.push({ type: "superscript" }), o.color && (r.color = String(o.color)), l && (r.fontFamily = String(l)), o.size && (r.fontSize = String(o.size)), a && n.push({ type: "highlight", attrs: { color: String(a) } }), Object.keys(r).length > 0 && n.push({ type: "textStyle", attrs: r }), n.length === 0 ? t : t.map(
349
+ (u) => u.type === "text" ? { ...u, marks: [...u.marks || [], ...n] } : u
350
+ );
351
+ }
352
+ function ne(t) {
353
+ const e = {};
354
+ for (const n of t || [])
355
+ switch (n.type) {
356
+ case "bold":
357
+ e.weight = "bold";
358
+ break;
359
+ case "italic":
360
+ e.italic = "true";
361
+ break;
362
+ case "underline":
363
+ e.underline = "true";
364
+ break;
365
+ case "strike":
366
+ e.strike = "true";
367
+ break;
368
+ case "textStyle":
369
+ n.attrs?.color && (e.color = String(n.attrs.color)), n.attrs?.fontFamily && (e.family = String(n.attrs.fontFamily)), n.attrs?.fontSize && (e.size = String(n.attrs.fontSize));
370
+ break;
371
+ case "highlight":
372
+ n.attrs?.color && (e.bg = String(n.attrs.color));
373
+ break;
374
+ case "subscript":
375
+ e.valign = "sub";
376
+ break;
377
+ case "superscript":
378
+ e.valign = "super";
379
+ break;
380
+ }
381
+ return e;
382
+ }
383
+ function Ln(t) {
384
+ if (t.type === "hardBreak") return "\\n";
385
+ if (t.type !== "text") return Ht(t);
386
+ const e = t.text || "";
387
+ if (!e) return "";
388
+ const n = t.marks || [];
389
+ if (!n.length) return e;
390
+ const r = new Set(n.map((b) => b.type)), o = n.find((b) => b.type === "link");
391
+ if (o?.attrs?.href) return `[${e}](${o.attrs.href})`;
392
+ const l = n.find((b) => b.type === "textStyle")?.attrs || {}, a = n.find((b) => b.type === "highlight")?.attrs || {}, u = !!(l.color || l.fontFamily || l.fontSize || a.color), c = ["bold", "italic", "strike", "underline", "code"].filter(
393
+ (b) => r.has(b)
394
+ ).length;
395
+ if (!u && c === 1 && !r.has("underline")) {
396
+ if (r.has("bold")) return `*${e}*`;
397
+ if (r.has("italic")) return `_${e}_`;
398
+ if (r.has("strike")) return `~${e}~`;
399
+ if (r.has("code")) return `\`${e}\``;
400
+ }
401
+ if (!u && c === 0 && r.has("highlight") && !a.color)
402
+ return `^${e}^`;
403
+ const g = ne(n), p = [];
404
+ return g.color && p.push(`color: ${g.color}`), g.family && p.push(`family: ${g.family}`), g.size && p.push(`size: ${g.size}`), g.weight && p.push(`weight: ${g.weight}`), g.italic === "true" && p.push("italic: true"), g.underline && p.push("underline: true"), g.strike && p.push("strike: true"), g.bg && p.push(`bg: ${g.bg}`), g.valign && p.push(`valign: ${g.valign}`), p.length ? `[${e}]{ ${p.join("; ")} }` : e;
405
+ }
406
+ const $n = /* @__PURE__ */ new Set([
407
+ "bold",
408
+ "italic",
409
+ "underline",
410
+ "strike",
411
+ "code",
412
+ "highlight",
413
+ "textStyle",
414
+ "link",
415
+ "subscript",
416
+ "superscript"
417
+ ]);
418
+ function Nn(t) {
419
+ const e = /* @__PURE__ */ new Set(), n = (r) => {
420
+ for (const o of r.marks || [])
421
+ $n.has(o.type) || e.add(o.type);
422
+ for (const o of r.content || []) n(o);
423
+ };
424
+ return n(t), [...e].sort();
425
+ }
426
+ function _t(t) {
427
+ const e = t.content || [], n = t.attrs?.textAlign && t.attrs.textAlign !== "left" ? { align: String(t.attrs.textAlign) } : {};
428
+ return e.length === 1 && e[0].type === "text" ? {
429
+ text: e[0].text || "",
430
+ props: { ...ne(e[0].marks), ...n }
431
+ } : { text: e.map(Ln).join(""), props: { ...n } };
432
+ }
433
+ function Ht(t) {
434
+ return t.content ? t.content.map((e) => e.type === "text" ? e.text || "" : e.type === "hardBreak" ? "\\n" : Ht(e)).join("") : "";
435
+ }
436
+ function it(t, e, n) {
437
+ const r = vn(t);
438
+ for (const o of wn) delete r[o];
439
+ if (n) for (const o of n) delete r[o];
440
+ return { ...r, ...e };
441
+ }
442
+ function Rt(t) {
443
+ const e = t.toLowerCase();
444
+ return Sn[e] || e;
445
+ }
446
+ function jt(t) {
447
+ if (t === "---") return "divider";
448
+ const e = t.match(/^([a-zA-Z][\w-]*):/);
449
+ return e ? Rt(e[1]) : null;
450
+ }
451
+ function ct(t) {
452
+ return Rt(t);
453
+ }
454
+ function lt(t, e) {
455
+ return !!(t === e || t === "info" && ["tip", "warning", "danger", "success"].includes(e) || e === "info" && ["tip", "warning", "danger", "success"].includes(t));
456
+ }
457
+ function zn(t) {
458
+ if (!t) return { content: "", properties: {} };
459
+ const e = t.split(" | ");
460
+ let n = e[0] || "";
461
+ const r = {};
462
+ for (let o = 1; o < e.length; o++) {
463
+ const l = e[o], a = l.match(/^([a-zA-Z_][\w-]*)\s*:\s*(.*)$/);
464
+ if (!a) {
465
+ n += ` | ${l}`;
466
+ continue;
467
+ }
468
+ r[a[1]] = a[2];
469
+ }
470
+ return { content: n, properties: r };
471
+ }
472
+ function Wt(t) {
473
+ if (t === "---") return { type: "divider" };
474
+ const e = t.match(/^([a-zA-Z][\w-]*):\s*(.*)$/);
475
+ if (!e) return null;
476
+ const n = Rt(e[1]), r = e[2] || "", { content: o, properties: l } = zn(r);
477
+ let a;
478
+ try {
479
+ a = tt(`text: ${o}`).blocks[0]?.inline;
480
+ } catch {
481
+ a = void 0;
482
+ }
483
+ return { type: n, content: o, properties: l, inline: a };
484
+ }
485
+ function Gt(t) {
486
+ const e = t.match(/^[-*]\s+(.*)$/);
487
+ if (e) return { ordered: !1, text: e[1] };
488
+ const n = t.match(/^\d+\.\s+(.*)$/);
489
+ return n ? { ordered: !0, text: n[1] } : null;
490
+ }
491
+ function Mn(t) {
492
+ return {
493
+ type: "listItem",
494
+ content: [{ type: "paragraph", content: Mt(t) }]
495
+ };
496
+ }
497
+ function Ut(t) {
498
+ if (!t.trim())
499
+ return {
500
+ type: "doc",
501
+ content: [{ type: "paragraph" }]
502
+ };
503
+ const e = tt(t), n = [];
504
+ for (const a of e.blocks) {
505
+ const u = At(a);
506
+ u && n.push(u);
507
+ }
508
+ const r = t.split(`
509
+ `);
510
+ let o = 0;
511
+ const l = [];
512
+ for (let a = 0; a < r.length; a++) {
513
+ const c = r[a].trim();
514
+ if (!c) continue;
515
+ {
516
+ const f = jt(c);
517
+ if (f && yn.has(f)) {
518
+ l.push({ type: "itMeta", attrs: { raw: c } });
519
+ const k = e.blocks[o]?.type;
520
+ k && lt(f, ct(k)) && o++;
521
+ continue;
522
+ }
523
+ if (f && kn.has(f)) {
524
+ l.push({ type: "itTrust", attrs: { raw: c, keyword: f } });
525
+ const k = e.blocks[o]?.type;
526
+ k && lt(f, ct(k)) && o++;
527
+ continue;
528
+ }
529
+ if (f === "metric") {
530
+ l.push({ type: "itMetric", attrs: { raw: c } });
531
+ const k = e.blocks[o]?.type;
532
+ k && lt(f, ct(k)) && o++;
533
+ continue;
534
+ }
535
+ if (f === "style") {
536
+ l.push({ type: "itStyleRule", attrs: { raw: c } });
537
+ const k = e.blocks[o]?.type;
538
+ k && lt(f, ct(k)) && o++;
539
+ continue;
540
+ }
541
+ }
542
+ const g = Gt(c);
543
+ if (g) {
544
+ const f = g.ordered, k = [];
545
+ let T = a;
546
+ for (; T < r.length; ) {
547
+ const M = r[T].trim(), S = M ? Gt(M) : null;
548
+ if (!S || S.ordered !== f) break;
549
+ k.push(Mn(S.text));
550
+ const v = e.blocks[o]?.type;
551
+ (v === "list-item" || v === "step-item") && o++, T++;
552
+ }
553
+ l.push({
554
+ type: f ? "orderedList" : "bulletList",
555
+ content: k
556
+ }), a = T - 1;
557
+ continue;
558
+ }
559
+ if (c.startsWith("|") && c.endsWith("|") && (c.match(/\|/g) || []).length >= 3) {
560
+ const f = [];
561
+ let k = a;
562
+ for (; k < r.length; ) {
563
+ const T = r[k].trim();
564
+ if (!(T.startsWith("|") && T.endsWith("|"))) break;
565
+ f.push(
566
+ T.slice(1, -1).split("|").map((M) => M.trim())
567
+ ), k++;
568
+ }
569
+ l.push({ type: "itTable", attrs: { rows: JSON.stringify(f) } }), a = k - 1;
570
+ continue;
571
+ }
572
+ if (c.startsWith("//")) {
573
+ l.push({
574
+ type: "itComment",
575
+ content: c.slice(2).trim() ? [{ type: "text", text: c.slice(2).trim() }] : []
576
+ });
577
+ continue;
578
+ }
579
+ if (c.startsWith("```")) continue;
580
+ const p = jt(c);
581
+ if (p && (p === "text" || c.includes("{{"))) {
582
+ const f = Wt(c);
583
+ if (f) {
584
+ const k = At(f);
585
+ if (k && l.push(k), o < e.blocks.length) {
586
+ const T = ct(e.blocks[o].type);
587
+ lt(p, T) && o++;
588
+ }
589
+ continue;
590
+ }
591
+ }
592
+ if (o < n.length && p) {
593
+ const f = e.blocks[o], k = ct(f.type);
594
+ if (lt(p, k)) {
595
+ l.push(n[o]), o++;
596
+ continue;
597
+ }
598
+ }
599
+ const b = Wt(c);
600
+ if (b) {
601
+ const f = At(b);
602
+ f && l.push(f);
603
+ continue;
604
+ }
605
+ o < n.length && (l.push(n[o]), o++);
606
+ }
607
+ for (; o < n.length; )
608
+ l.push(n[o]), o++;
609
+ return {
610
+ type: "doc",
611
+ content: l.length > 0 ? l : [{ type: "paragraph" }]
612
+ };
613
+ }
614
+ function At(t) {
615
+ const { type: e, content: n, properties: r, inline: o } = t, l = n || "";
616
+ let a = An(o, l);
617
+ a = Cn(a, r);
618
+ const u = r ? JSON.stringify(
619
+ Object.fromEntries(
620
+ Object.entries(r).map(([p, b]) => [p, String(b)])
621
+ )
622
+ ) : "{}", c = r?.align ? String(r.align) : void 0;
623
+ if (e in Ft)
624
+ return {
625
+ type: Ft[e],
626
+ attrs: { props: u, ...c && { textAlign: c } },
627
+ content: a.length ? a : void 0
628
+ };
629
+ if (e === "summary")
630
+ return {
631
+ type: "itSummary",
632
+ attrs: { props: u, ...c && { textAlign: c } },
633
+ content: a.length ? a : void 0
634
+ };
635
+ if (e === "text" || e === "body-text") {
636
+ const p = {};
637
+ return c && (p.textAlign = c), r?.end && (p.end = String(r.end)), r?.leading && (p.leading = String(r.leading)), r?.["space-before"] && (p.spaceBefore = String(r["space-before"])), r?.["space-after"] && (p.spaceAfter = String(r["space-after"])), {
638
+ type: "paragraph",
639
+ ...Object.keys(p).length && { attrs: p },
640
+ content: a.length ? a : void 0
641
+ };
642
+ }
643
+ if (Dt.has(e)) {
644
+ const p = e === "info" ? String(r?.type || "info").toLowerCase() : e;
645
+ return {
646
+ type: "itCallout",
647
+ attrs: { variant: Dt.has(p) ? p : "info", props: u },
648
+ content: a.length ? a : void 0
649
+ };
650
+ }
651
+ if (e === "quote")
652
+ return {
653
+ type: "itQuote",
654
+ attrs: {
655
+ by: r?.by ? String(r.by) : "",
656
+ props: u,
657
+ ...c && { textAlign: c }
658
+ },
659
+ content: a.length ? a : void 0
660
+ };
661
+ if (e === "code")
662
+ return {
663
+ type: "itCode",
664
+ attrs: {
665
+ lang: r?.lang ? String(r.lang) : "",
666
+ props: u
667
+ },
668
+ content: l ? [{ type: "text", text: l }] : void 0
669
+ };
670
+ if (e === "divider")
671
+ return { type: "itDivider" };
672
+ if (e === "break")
673
+ return { type: "itBreak" };
674
+ const g = r ? Object.entries(r).filter(([, p]) => p !== void 0 && p !== "").map(([p, b]) => `${p}: ${b}`).join(" | ") : "";
675
+ return {
676
+ type: "itGenericBlock",
677
+ attrs: { keyword: e, properties: g, props: u },
678
+ content: a.length ? a : void 0
679
+ };
680
+ }
681
+ function _n(t) {
682
+ if (!t.content) return "";
683
+ const e = [];
684
+ for (const n of t.content)
685
+ e.push(...Hn(n));
686
+ return e.join(`
687
+ `);
688
+ }
689
+ function Hn(t) {
690
+ if (t.type === "bulletList" && t.content)
691
+ return t.content.flatMap((n) => n.content ? n.content.map((r) => {
692
+ const { text: o, props: l } = _t(r);
693
+ return `- ${o}${D(l)}`;
694
+ }) : []);
695
+ if (t.type === "orderedList" && t.content) {
696
+ let n = 1;
697
+ return t.content.flatMap((r) => r.content ? r.content.map((o) => {
698
+ const { text: l, props: a } = _t(o);
699
+ return `${n++}. ${l}${D(a)}`;
700
+ }) : []);
701
+ }
702
+ const e = Rn(t);
703
+ return e !== null ? [e] : [];
704
+ }
705
+ function Rn(t) {
706
+ const { text: e, props: n } = _t(t);
707
+ switch (t.type) {
708
+ case "itTitle": {
709
+ const r = it(t.attrs?.props, n);
710
+ return `title: ${e}${D(r)}`;
711
+ }
712
+ case "itSummary": {
713
+ const r = it(t.attrs?.props, n);
714
+ return `summary: ${e}${D(r)}`;
715
+ }
716
+ case "itSection": {
717
+ const r = it(t.attrs?.props, n);
718
+ return `section: ${e}${D(r)}`;
719
+ }
720
+ case "itSub": {
721
+ const r = it(t.attrs?.props, n);
722
+ return `sub: ${e}${D(r)}`;
723
+ }
724
+ case "paragraph": {
725
+ const r = t.attrs || {}, o = {};
726
+ return r.end && (o.end = String(r.end)), r.leading && (o.leading = String(r.leading)), r.spaceBefore && (o["space-before"] = String(r.spaceBefore)), r.spaceAfter && (o["space-after"] = String(r.spaceAfter)), `text: ${e}${D({ ...o, ...n })}`;
727
+ }
728
+ case "itCallout": {
729
+ const r = t.attrs?.variant || "tip", o = it(
730
+ t.attrs?.props,
731
+ n,
732
+ /* @__PURE__ */ new Set(["variant"])
733
+ );
734
+ return r === "info" ? `info: ${e}${D(o)}` : `info: ${e} | type: ${r}${D(o, /* @__PURE__ */ new Set(["type"]))}`;
735
+ }
736
+ case "itQuote": {
737
+ const r = t.attrs?.by, o = r ? ` | by: ${r}` : "", l = it(t.attrs?.props, n, /* @__PURE__ */ new Set(["by"]));
738
+ return `quote: ${e}${o}${D(l)}`;
739
+ }
740
+ case "itCode":
741
+ return `\`\`\`${t.attrs?.lang || ""}
742
+ ${Ht(t)}
743
+ \`\`\``;
744
+ case "itDivider":
745
+ return "divider:";
746
+ case "itTable": {
747
+ let r = [];
748
+ try {
749
+ r = JSON.parse(t.attrs?.rows || "[]");
750
+ } catch {
751
+ r = [];
752
+ }
753
+ return r.map((o) => `| ${o.join(" | ")} |`).join(`
754
+ `);
755
+ }
756
+ case "itMeta":
757
+ return t.attrs?.raw || "";
758
+ case "itTrust":
759
+ return t.attrs?.raw || "";
760
+ case "itMetric":
761
+ return t.attrs?.raw || "";
762
+ case "itStyleRule":
763
+ return t.attrs?.raw || "";
764
+ case "itBreak":
765
+ return "break:";
766
+ case "itComment":
767
+ return e ? `// ${e}` : "//";
768
+ case "itGenericBlock": {
769
+ const r = t.attrs?.keyword || "text", o = it(t.attrs?.props, n);
770
+ return `${r}: ${e}${D(o)}`;
771
+ }
772
+ default:
773
+ return e ? `text: ${e}${D(n)}` : null;
774
+ }
775
+ }
776
+ function s(t, e) {
777
+ return { property: t, css: e };
778
+ }
779
+ const En = [
780
+ s("align", "textAlign"),
781
+ s("color", "color"),
782
+ s("size", "fontSize"),
783
+ s("weight", "fontWeight"),
784
+ { property: "style", css: "fontStyle" },
785
+ s("bgcolor", "backgroundColor"),
786
+ s("padding", "padding"),
787
+ s("indent", "paddingLeft"),
788
+ s("opacity", "opacity")
789
+ ], gt = [
790
+ s("bgcolor", "backgroundColor"),
791
+ s("color", "color"),
792
+ s("border", "borderLeft")
793
+ ], L = [
794
+ s("color", "borderColor"),
795
+ s("bgcolor", "backgroundColor")
796
+ ], Bn = {
797
+ // ── Identity ──
798
+ title: [
799
+ s("align", "textAlign"),
800
+ s("color", "color"),
801
+ s("size", "fontSize"),
802
+ s("weight", "fontWeight"),
803
+ s("font", "fontFamily")
804
+ ],
805
+ summary: [
806
+ s("align", "textAlign"),
807
+ s("color", "color"),
808
+ s("size", "fontSize"),
809
+ { property: "style", css: "fontStyle" }
810
+ ],
811
+ // ── Structure ──
812
+ section: [
813
+ s("align", "textAlign"),
814
+ s("color", "color"),
815
+ s("size", "fontSize"),
816
+ s("weight", "fontWeight"),
817
+ s("border", "borderBottom"),
818
+ s("spacing", "marginTop")
819
+ ],
820
+ sub: [
821
+ s("align", "textAlign"),
822
+ s("color", "color"),
823
+ s("size", "fontSize"),
824
+ s("weight", "fontWeight")
825
+ ],
826
+ divider: [
827
+ { property: "style", css: "borderStyle" },
828
+ s("color", "borderColor"),
829
+ s("width", "borderTopWidth"),
830
+ s("spacing", "margin")
831
+ ],
832
+ // ── Content ──
833
+ text: [...En],
834
+ tip: [...gt],
835
+ info: [...gt],
836
+ warning: [...gt],
837
+ danger: [...gt],
838
+ success: [...gt],
839
+ quote: [
840
+ s("align", "textAlign"),
841
+ s("color", "color"),
842
+ s("size", "fontSize"),
843
+ { property: "style", css: "fontStyle" },
844
+ s("border", "borderLeft"),
845
+ s("padding", "paddingLeft"),
846
+ s("bgcolor", "backgroundColor")
847
+ ],
848
+ cite: [
849
+ s("align", "textAlign"),
850
+ s("color", "color"),
851
+ s("size", "fontSize"),
852
+ { property: "style", css: "fontStyle" }
853
+ ],
854
+ def: [
855
+ s("color", "color"),
856
+ s("bgcolor", "backgroundColor"),
857
+ s("border", "borderLeft"),
858
+ s("padding", "paddingLeft")
859
+ ],
860
+ caption: [
861
+ s("align", "textAlign"),
862
+ s("color", "color"),
863
+ s("size", "fontSize"),
864
+ { property: "style", css: "fontStyle" }
865
+ ],
866
+ footnote: [s("color", "color"), s("size", "fontSize")],
867
+ byline: [
868
+ s("align", "textAlign"),
869
+ s("color", "color"),
870
+ s("size", "fontSize"),
871
+ { property: "style", css: "fontStyle" },
872
+ s("weight", "fontWeight")
873
+ ],
874
+ epigraph: [
875
+ s("align", "textAlign"),
876
+ s("color", "color"),
877
+ s("size", "fontSize"),
878
+ { property: "style", css: "fontStyle" },
879
+ s("padding", "padding")
880
+ ],
881
+ dedication: [
882
+ s("align", "textAlign"),
883
+ s("color", "color"),
884
+ { property: "style", css: "fontStyle" },
885
+ s("padding", "padding")
886
+ ],
887
+ // ── Media ──
888
+ image: [
889
+ s("width", "width"),
890
+ s("height", "height"),
891
+ s("radius", "borderRadius"),
892
+ s("border", "border"),
893
+ s("opacity", "opacity"),
894
+ s("bgcolor", "backgroundColor"),
895
+ {
896
+ property: "shadow",
897
+ css: "boxShadow",
898
+ transform: () => "0 4px 12px rgba(0,0,0,0.15)"
899
+ }
900
+ ],
901
+ figure: [
902
+ s("width", "width"),
903
+ s("align", "textAlign"),
904
+ s("border", "border"),
905
+ s("padding", "padding"),
906
+ s("bgcolor", "backgroundColor"),
907
+ {
908
+ property: "shadow",
909
+ css: "boxShadow",
910
+ transform: () => "0 4px 12px rgba(0,0,0,0.15)"
911
+ }
912
+ ],
913
+ link: [s("color", "color"), s("weight", "fontWeight")],
914
+ ref: [s("color", "color"), { property: "style", css: "fontStyle" }],
915
+ embed: [
916
+ s("width", "width"),
917
+ s("height", "height"),
918
+ s("border", "border"),
919
+ s("radius", "borderRadius")
920
+ ],
921
+ // ── Data ──
922
+ metric: [
923
+ s("color", "color"),
924
+ s("size", "fontSize"),
925
+ s("align", "textAlign"),
926
+ s("bgcolor", "backgroundColor"),
927
+ s("border", "border"),
928
+ s("padding", "padding")
929
+ ],
930
+ columns: [
931
+ s("border", "border"),
932
+ s("bgcolor", "backgroundColor"),
933
+ s("padding", "padding"),
934
+ s("size", "fontSize"),
935
+ s("align", "textAlign")
936
+ ],
937
+ row: [
938
+ s("border", "border"),
939
+ s("bgcolor", "backgroundColor"),
940
+ s("padding", "padding"),
941
+ s("size", "fontSize"),
942
+ s("align", "textAlign")
943
+ ],
944
+ input: [
945
+ s("color", "color"),
946
+ s("bgcolor", "backgroundColor"),
947
+ s("border", "borderLeft"),
948
+ s("size", "fontSize")
949
+ ],
950
+ output: [
951
+ s("color", "color"),
952
+ s("bgcolor", "backgroundColor"),
953
+ s("border", "borderLeft"),
954
+ s("size", "fontSize")
955
+ ],
956
+ // ── Code ──
957
+ code: [
958
+ s("size", "fontSize"),
959
+ s("bgcolor", "backgroundColor"),
960
+ s("color", "color"),
961
+ s("padding", "padding"),
962
+ s("radius", "borderRadius"),
963
+ s("border", "border")
964
+ ],
965
+ // ── Contact ──
966
+ contact: [
967
+ s("color", "color"),
968
+ s("bgcolor", "backgroundColor"),
969
+ s("border", "border"),
970
+ s("padding", "padding"),
971
+ s("size", "fontSize")
972
+ ],
973
+ deadline: [
974
+ s("color", "color"),
975
+ s("bgcolor", "backgroundColor"),
976
+ s("weight", "fontWeight"),
977
+ s("size", "fontSize")
978
+ ],
979
+ // ── Agent workflow chips ──
980
+ step: [...L],
981
+ decision: [...L],
982
+ gate: [...L],
983
+ trigger: [...L],
984
+ loop: [...L],
985
+ parallel: [...L],
986
+ call: [...L],
987
+ wait: [...L],
988
+ checkpoint: [...L],
989
+ error: [...L],
990
+ result: [...L],
991
+ audit: [...L],
992
+ signal: [...L],
993
+ handoff: [...L],
994
+ retry: [...L],
995
+ progress: [...L],
996
+ tool: [...L],
997
+ prompt: [...L],
998
+ memory: [...L],
999
+ policy: [...L],
1000
+ context: [...L],
1001
+ // ── Trust badges ──
1002
+ track: [...L],
1003
+ approve: [...L],
1004
+ sign: [...L],
1005
+ freeze: [...L],
1006
+ revision: [...L],
1007
+ amendment: [...L],
1008
+ history: [s("color", "borderColor")],
1009
+ // ── v2.13 ──
1010
+ assert: [
1011
+ s("color", "borderColor"),
1012
+ s("bgcolor", "backgroundColor"),
1013
+ s("border", "borderLeft")
1014
+ ],
1015
+ secret: [
1016
+ s("color", "color"),
1017
+ s("bgcolor", "backgroundColor"),
1018
+ s("blur", "filter")
1019
+ ],
1020
+ // ── Layout ──
1021
+ watermark: [
1022
+ s("color", "color"),
1023
+ s("size", "fontSize"),
1024
+ s("opacity", "opacity")
1025
+ ],
1026
+ signline: [s("color", "color"), s("width", "width")]
1027
+ };
1028
+ function Pn(t, e) {
1029
+ const n = Bn[t];
1030
+ if (!n) return {};
1031
+ const r = {};
1032
+ for (const o of n) {
1033
+ const l = e[o.property];
1034
+ l && (o.transform ? r[o.css] = o.transform(l) : r[o.css] = l);
1035
+ }
1036
+ return r;
1037
+ }
1038
+ function q(t, e) {
1039
+ const n = Pn(t, e);
1040
+ return e.leading && (n.lineHeight = e.leading), e["space-before"] && (n.marginTop = e["space-before"]), e["space-after"] && (n.marginBottom = e["space-after"]), Object.entries(n).map(([r, o]) => `${r.replace(/([A-Z])/g, "-$1").toLowerCase()}:${o}`).join(";");
1041
+ }
1042
+ function Et(t) {
1043
+ return t.end ? { "data-it-end": t.end } : {};
1044
+ }
1045
+ const In = E.create({
1046
+ name: "itTitle",
1047
+ group: "block",
1048
+ content: "inline*",
1049
+ defining: !0,
1050
+ addAttributes() {
1051
+ return {
1052
+ props: {
1053
+ default: "{}",
1054
+ parseHTML: (t) => t.getAttribute("data-props") || "{}"
1055
+ }
1056
+ };
1057
+ },
1058
+ parseHTML() {
1059
+ return [{ tag: 'h1[data-it-type="title"]' }];
1060
+ },
1061
+ renderHTML({ HTMLAttributes: t, node: e }) {
1062
+ const n = et(e.attrs.props), r = z(t, {
1063
+ "data-it-type": "title",
1064
+ class: "it-doc-title",
1065
+ style: q("title", n),
1066
+ ...Et(n)
1067
+ });
1068
+ return n.end ? ["h1", r, ["span", { class: "it-split-main" }, 0]] : ["h1", r, 0];
1069
+ }
1070
+ }), On = E.create({
1071
+ name: "itSummary",
1072
+ group: "block",
1073
+ content: "inline*",
1074
+ defining: !0,
1075
+ addAttributes() {
1076
+ return {
1077
+ props: { default: "{}" }
1078
+ };
1079
+ },
1080
+ parseHTML() {
1081
+ return [{ tag: 'p[data-it-type="summary"]' }];
1082
+ },
1083
+ renderHTML({ HTMLAttributes: t, node: e }) {
1084
+ const n = et(e.attrs.props);
1085
+ return [
1086
+ "p",
1087
+ z(t, {
1088
+ "data-it-type": "summary",
1089
+ class: "it-doc-summary",
1090
+ style: q("summary", n)
1091
+ }),
1092
+ 0
1093
+ ];
1094
+ }
1095
+ }), Dn = E.create({
1096
+ name: "itSection",
1097
+ group: "block",
1098
+ content: "inline*",
1099
+ defining: !0,
1100
+ addAttributes() {
1101
+ return {
1102
+ props: { default: "{}" }
1103
+ };
1104
+ },
1105
+ parseHTML() {
1106
+ return [{ tag: 'h2[data-it-type="section"]' }];
1107
+ },
1108
+ renderHTML({ HTMLAttributes: t, node: e }) {
1109
+ const n = et(e.attrs.props), r = z(t, {
1110
+ "data-it-type": "section",
1111
+ class: "it-doc-section",
1112
+ style: q("section", n),
1113
+ ...Et(n)
1114
+ });
1115
+ return n.end ? ["h2", r, ["span", { class: "it-split-main" }, 0]] : ["h2", r, 0];
1116
+ }
1117
+ }), Fn = E.create({
1118
+ name: "itSub",
1119
+ group: "block",
1120
+ content: "inline*",
1121
+ defining: !0,
1122
+ addAttributes() {
1123
+ return {
1124
+ props: { default: "{}" }
1125
+ };
1126
+ },
1127
+ parseHTML() {
1128
+ return [{ tag: 'h3[data-it-type="sub"]' }];
1129
+ },
1130
+ renderHTML({ HTMLAttributes: t, node: e }) {
1131
+ const n = et(e.attrs.props), r = z(t, {
1132
+ "data-it-type": "sub",
1133
+ class: "it-doc-sub",
1134
+ style: q("sub", n),
1135
+ ...Et(n)
1136
+ });
1137
+ return n.end ? ["h3", r, ["span", { class: "it-split-main" }, 0]] : ["h3", r, 0];
1138
+ }
1139
+ }), jn = E.create({
1140
+ name: "itCallout",
1141
+ group: "block",
1142
+ content: "inline*",
1143
+ defining: !0,
1144
+ addAttributes() {
1145
+ return {
1146
+ variant: {
1147
+ default: "tip",
1148
+ parseHTML: (t) => t.getAttribute("data-variant") || "tip",
1149
+ renderHTML: (t) => ({ "data-variant": t.variant })
1150
+ },
1151
+ props: { default: "{}" }
1152
+ };
1153
+ },
1154
+ parseHTML() {
1155
+ return [{ tag: 'div[data-it-type="callout"]' }];
1156
+ },
1157
+ renderHTML({ HTMLAttributes: t, node: e }) {
1158
+ const n = e.attrs.variant || "tip", r = et(e.attrs.props), o = {
1159
+ tip: "tip",
1160
+ info: "info",
1161
+ warning: "warning",
1162
+ danger: "danger",
1163
+ success: "success"
1164
+ };
1165
+ return [
1166
+ "div",
1167
+ z(t, {
1168
+ "data-it-type": "callout",
1169
+ "data-variant": n,
1170
+ class: `it-doc-callout it-doc-callout-${n}`,
1171
+ style: q(n, r)
1172
+ }),
1173
+ [
1174
+ "span",
1175
+ {
1176
+ class: `it-doc-callout-icon it-doc-callout-icon-${o[n] || "tip"}`,
1177
+ contenteditable: "false"
1178
+ },
1179
+ ""
1180
+ ],
1181
+ ["span", { class: "it-doc-callout-text" }, 0]
1182
+ ];
1183
+ }
1184
+ }), Wn = E.create({
1185
+ name: "itQuote",
1186
+ group: "block",
1187
+ content: "inline*",
1188
+ defining: !0,
1189
+ addAttributes() {
1190
+ return {
1191
+ by: { default: "" },
1192
+ props: { default: "{}" }
1193
+ };
1194
+ },
1195
+ parseHTML() {
1196
+ return [{ tag: 'blockquote[data-it-type="quote"]' }];
1197
+ },
1198
+ renderHTML({ HTMLAttributes: t, node: e }) {
1199
+ const n = et(e.attrs.props);
1200
+ return [
1201
+ "blockquote",
1202
+ z(t, {
1203
+ "data-it-type": "quote",
1204
+ class: "it-doc-quote",
1205
+ style: q("quote", n)
1206
+ }),
1207
+ 0
1208
+ ];
1209
+ }
1210
+ }), Gn = E.create({
1211
+ name: "itCode",
1212
+ group: "block",
1213
+ content: "text*",
1214
+ marks: "",
1215
+ code: !0,
1216
+ defining: !0,
1217
+ addAttributes() {
1218
+ return {
1219
+ lang: { default: "" },
1220
+ props: { default: "{}" }
1221
+ };
1222
+ },
1223
+ parseHTML() {
1224
+ return [{ tag: "pre" }];
1225
+ },
1226
+ renderHTML({ HTMLAttributes: t, node: e }) {
1227
+ const n = et(e.attrs.props);
1228
+ return [
1229
+ "pre",
1230
+ z(t, {
1231
+ "data-it-type": "code",
1232
+ class: "it-doc-code",
1233
+ "data-lang": e.attrs.lang || "",
1234
+ style: q("code", n)
1235
+ }),
1236
+ ["code", 0]
1237
+ ];
1238
+ }
1239
+ }), Un = E.create({
1240
+ name: "itDivider",
1241
+ group: "block",
1242
+ atom: !0,
1243
+ parseHTML() {
1244
+ return [{ tag: "hr" }];
1245
+ },
1246
+ renderHTML({ HTMLAttributes: t }) {
1247
+ return ["hr", z(t, { class: "it-doc-divider" })];
1248
+ }
1249
+ }), Yn = E.create({
1250
+ name: "itMeta",
1251
+ group: "block",
1252
+ atom: !0,
1253
+ addAttributes() {
1254
+ return {
1255
+ raw: {
1256
+ default: "",
1257
+ parseHTML: (t) => t.getAttribute("data-raw") || "",
1258
+ renderHTML: (t) => ({ "data-raw": t.raw })
1259
+ }
1260
+ };
1261
+ },
1262
+ parseHTML() {
1263
+ return [{ tag: "div[data-it-meta]" }];
1264
+ },
1265
+ renderHTML({ HTMLAttributes: t, node: e }) {
1266
+ const n = String(e.attrs.raw || "").replace(/\s*\|\s*/g, " · ");
1267
+ return [
1268
+ "div",
1269
+ z(t, { "data-it-meta": "", class: "it-doc-meta" }),
1270
+ `⚙ ${n}`
1271
+ ];
1272
+ }
1273
+ }), Kn = E.create({
1274
+ name: "itTable",
1275
+ group: "block",
1276
+ atom: !0,
1277
+ addAttributes() {
1278
+ return {
1279
+ rows: {
1280
+ default: "[]",
1281
+ parseHTML: (t) => t.getAttribute("data-rows") || "[]",
1282
+ renderHTML: (t) => ({ "data-rows": t.rows })
1283
+ }
1284
+ };
1285
+ },
1286
+ parseHTML() {
1287
+ return [{ tag: "table[data-it-table]" }];
1288
+ },
1289
+ renderHTML({ HTMLAttributes: t, node: e }) {
1290
+ let n = [];
1291
+ try {
1292
+ n = JSON.parse(e.attrs.rows || "[]");
1293
+ } catch {
1294
+ n = [];
1295
+ }
1296
+ const r = n[0] || [], o = n.slice(1);
1297
+ return [
1298
+ "table",
1299
+ z(t, {
1300
+ "data-it-table": "",
1301
+ class: "it-doc-table"
1302
+ }),
1303
+ [
1304
+ "thead",
1305
+ ["tr", ...r.map((l) => ["th", Yt(l), String(l)])]
1306
+ ],
1307
+ [
1308
+ "tbody",
1309
+ ...o.map((l) => [
1310
+ "tr",
1311
+ ...l.map((a) => ["td", Yt(a), String(a)])
1312
+ ])
1313
+ ]
1314
+ ];
1315
+ }
1316
+ });
1317
+ function Yt(t) {
1318
+ return /\{\{[^}]+\}\}|^each:/.test(String(t).trim()) ? { class: "it-doc-var-cell" } : {};
1319
+ }
1320
+ function Bt(t) {
1321
+ const e = t.indexOf(":"), n = (e >= 0 ? t.slice(0, e) : t).trim().toLowerCase(), o = (e >= 0 ? t.slice(e + 1).trim() : "").split("|").map((u) => u.trim()), l = o.shift() || "", a = {};
1322
+ for (const u of o) {
1323
+ const c = u.indexOf(":");
1324
+ c > 0 && (a[u.slice(0, c).trim().toLowerCase()] = u.slice(c + 1).trim());
1325
+ }
1326
+ return { keyword: n, content: l, props: a };
1327
+ }
1328
+ const qn = E.create({
1329
+ name: "itTrust",
1330
+ group: "block",
1331
+ atom: !0,
1332
+ addAttributes() {
1333
+ return {
1334
+ raw: {
1335
+ default: "",
1336
+ parseHTML: (t) => t.getAttribute("data-raw") || "",
1337
+ renderHTML: (t) => ({ "data-raw": t.raw })
1338
+ },
1339
+ keyword: {
1340
+ default: "",
1341
+ parseHTML: (t) => t.getAttribute("data-trust") || "",
1342
+ renderHTML: (t) => ({ "data-trust": t.keyword })
1343
+ }
1344
+ };
1345
+ },
1346
+ parseHTML() {
1347
+ return [{ tag: "div[data-it-trust]" }];
1348
+ },
1349
+ renderHTML({ HTMLAttributes: t, node: e }) {
1350
+ const { keyword: n, content: r, props: o } = Bt(
1351
+ String(e.attrs.raw || "")
1352
+ ), l = o.role || o.title || "", a = o.at || o.date || o.time || "", u = [];
1353
+ if (n === "seal") {
1354
+ const c = r || o.hash || "", g = o.algo || "sha-256";
1355
+ u.push(
1356
+ ["span", { class: "it-doc-trust__icon" }, "🔒"],
1357
+ ["span", { class: "it-doc-trust__label" }, "Sealed"],
1358
+ ["span", { class: "it-doc-trust__meta" }, g],
1359
+ ...c ? [["code", { class: "it-doc-trust__hash" }, c.slice(0, 16) + "…"]] : []
1360
+ );
1361
+ } else if (n === "approve")
1362
+ u.push(
1363
+ ["span", { class: "it-doc-trust__icon" }, "✓"],
1364
+ ["span", { class: "it-doc-trust__label" }, "Approved"],
1365
+ ["span", { class: "it-doc-trust__name" }, r],
1366
+ ...l ? [["span", { class: "it-doc-trust__role" }, l]] : [],
1367
+ ...a ? [["span", { class: "it-doc-trust__date" }, a]] : []
1368
+ );
1369
+ else if (n === "freeze")
1370
+ u.push(
1371
+ ["span", { class: "it-doc-trust__icon" }, "❄"],
1372
+ ["span", { class: "it-doc-trust__label" }, "Frozen"],
1373
+ ...r ? [["span", { class: "it-doc-trust__name" }, r]] : [],
1374
+ ...a ? [["span", { class: "it-doc-trust__date" }, a]] : []
1375
+ );
1376
+ else if (n === "amend" || n === "amendment")
1377
+ u.push(
1378
+ ["span", { class: "it-doc-trust__icon" }, "✎"],
1379
+ ["span", { class: "it-doc-trust__label" }, "Amendment"],
1380
+ ["span", { class: "it-doc-trust__name" }, r],
1381
+ ...a ? [["span", { class: "it-doc-trust__date" }, a]] : []
1382
+ );
1383
+ else
1384
+ return [
1385
+ "div",
1386
+ z(t, {
1387
+ "data-it-trust": "",
1388
+ "data-trust": n,
1389
+ class: "it-doc-trust it-doc-sign"
1390
+ }),
1391
+ ["div", { class: "it-doc-sign__script" }, r || " "],
1392
+ ["div", { class: "it-doc-sign__rule" }],
1393
+ [
1394
+ "div",
1395
+ { class: "it-doc-sign__row" },
1396
+ ["span", { class: "it-doc-sign__name" }, r],
1397
+ ...l ? [["span", { class: "it-doc-sign__role" }, l]] : [],
1398
+ ...a ? [["span", { class: "it-doc-sign__date" }, a]] : []
1399
+ ]
1400
+ ];
1401
+ return [
1402
+ "div",
1403
+ z(t, {
1404
+ "data-it-trust": "",
1405
+ "data-trust": n,
1406
+ class: `it-doc-trust it-doc-trust--${n}`
1407
+ }),
1408
+ ...u
1409
+ ];
1410
+ }
1411
+ }), Jn = E.create({
1412
+ name: "itMetric",
1413
+ group: "block",
1414
+ atom: !0,
1415
+ addAttributes() {
1416
+ return {
1417
+ raw: {
1418
+ default: "",
1419
+ parseHTML: (t) => t.getAttribute("data-raw") || "",
1420
+ renderHTML: (t) => ({ "data-raw": t.raw })
1421
+ }
1422
+ };
1423
+ },
1424
+ parseHTML() {
1425
+ return [{ tag: "div[data-it-metric]" }];
1426
+ },
1427
+ renderHTML({ HTMLAttributes: t, node: e }) {
1428
+ const { content: n, props: r } = Bt(String(e.attrs.raw || "")), o = [r.value, r.unit].filter(Boolean).join(" "), l = /\b(total|balance due|amount due|grand)\b/i.test(n), a = /\{\{[^}]+\}\}/.test(o);
1429
+ return [
1430
+ "div",
1431
+ z(t, {
1432
+ "data-it-metric": "",
1433
+ class: `it-doc-metric${l ? " it-doc-metric--total" : ""}`
1434
+ }),
1435
+ ["span", { class: "it-doc-metric__label" }, n],
1436
+ [
1437
+ "span",
1438
+ { class: `it-doc-metric__value${a ? " it-doc-var" : ""}` },
1439
+ o
1440
+ ]
1441
+ ];
1442
+ }
1443
+ }), Vn = E.create({
1444
+ name: "itStyleRule",
1445
+ group: "block",
1446
+ atom: !0,
1447
+ addAttributes() {
1448
+ return {
1449
+ raw: {
1450
+ default: "",
1451
+ parseHTML: (t) => t.getAttribute("data-raw") || "",
1452
+ renderHTML: (t) => ({ "data-raw": t.raw })
1453
+ }
1454
+ };
1455
+ },
1456
+ parseHTML() {
1457
+ return [{ tag: "div[data-it-style-rule]" }];
1458
+ },
1459
+ renderHTML({ HTMLAttributes: t, node: e }) {
1460
+ const { content: n, props: r } = Bt(String(e.attrs.raw || "")), o = Object.entries(r).map(([l, a]) => `${l}: ${a}`).join(" · ");
1461
+ return [
1462
+ "div",
1463
+ z(t, {
1464
+ "data-it-style-rule": "",
1465
+ class: "it-doc-stylerule"
1466
+ }),
1467
+ ["span", { class: "it-doc-stylerule__icon" }, "🎨"],
1468
+ ["span", { class: "it-doc-stylerule__target" }, n || "?"],
1469
+ ["span", { class: "it-doc-stylerule__decl" }, o]
1470
+ ];
1471
+ }
1472
+ }), Qn = E.create({
1473
+ name: "itBreak",
1474
+ group: "block",
1475
+ atom: !0,
1476
+ parseHTML() {
1477
+ return [{ tag: 'div[data-it-type="break"]' }];
1478
+ },
1479
+ renderHTML({ HTMLAttributes: t }) {
1480
+ return [
1481
+ "div",
1482
+ z(t, {
1483
+ "data-it-type": "break",
1484
+ class: "it-doc-break"
1485
+ })
1486
+ ];
1487
+ }
1488
+ }), Zn = E.create({
1489
+ name: "itGenericBlock",
1490
+ group: "block",
1491
+ content: "inline*",
1492
+ defining: !0,
1493
+ addAttributes() {
1494
+ return {
1495
+ keyword: { default: "text" },
1496
+ properties: { default: "" },
1497
+ props: { default: "{}" }
1498
+ };
1499
+ },
1500
+ parseHTML() {
1501
+ return [{ tag: '[data-it-type="generic"]' }];
1502
+ },
1503
+ renderHTML({ HTMLAttributes: t, node: e }) {
1504
+ const n = e.attrs.keyword, r = et(e.attrs.props), o = String(
1505
+ r.to || r.url || r.href || r.file || ""
1506
+ ).trim();
1507
+ return (n === "link" || n === "ref") && o ? [
1508
+ "p",
1509
+ z(t, {
1510
+ "data-it-type": "generic",
1511
+ "data-keyword": n,
1512
+ class: `it-doc-generic it-doc-kw-${n}`,
1513
+ style: q(n, r)
1514
+ }),
1515
+ [
1516
+ "a",
1517
+ {
1518
+ class: "it-doc-inline-link",
1519
+ href: o,
1520
+ target: "_blank",
1521
+ rel: "noopener noreferrer"
1522
+ },
1523
+ 0
1524
+ ]
1525
+ ] : [
1526
+ "p",
1527
+ z(t, {
1528
+ "data-it-type": "generic",
1529
+ "data-keyword": n,
1530
+ class: `it-doc-generic it-doc-kw-${n}`,
1531
+ style: q(n, r)
1532
+ }),
1533
+ ["span", { class: "it-doc-generic-content" }, 0]
1534
+ ];
1535
+ }
1536
+ }), Xn = E.create({
1537
+ name: "itComment",
1538
+ group: "block",
1539
+ content: "inline*",
1540
+ defining: !0,
1541
+ parseHTML() {
1542
+ return [{ tag: 'p[data-it-type="comment"]' }];
1543
+ },
1544
+ renderHTML({ HTMLAttributes: t }) {
1545
+ return [
1546
+ "p",
1547
+ z(t, {
1548
+ "data-it-type": "comment",
1549
+ class: "it-doc-comment"
1550
+ }),
1551
+ 0
1552
+ ];
1553
+ }
1554
+ });
1555
+ function et(t) {
1556
+ try {
1557
+ return typeof t == "string" ? JSON.parse(t) : t || {};
1558
+ } catch {
1559
+ return {};
1560
+ }
1561
+ }
1562
+ const re = {
1563
+ leading: "leading",
1564
+ "space-before": "spaceBefore",
1565
+ "space-after": "spaceAfter",
1566
+ end: "end"
1567
+ }, tr = /* @__PURE__ */ new Set([
1568
+ "itTitle",
1569
+ "itSummary",
1570
+ "itSection",
1571
+ "itSub",
1572
+ "itQuote",
1573
+ "itCallout",
1574
+ "itGenericBlock"
1575
+ ]), er = /* @__PURE__ */ new Set(["itTitle", "itSection", "itSub"]);
1576
+ function oe(t) {
1577
+ try {
1578
+ return typeof t == "string" ? JSON.parse(t) : t || {};
1579
+ } catch {
1580
+ return {};
1581
+ }
1582
+ }
1583
+ function se(t, e) {
1584
+ return t === "paragraph" ? !0 : e === "end" ? er.has(t) : tr.has(t);
1585
+ }
1586
+ const nr = Ie.extend({
1587
+ addAttributes() {
1588
+ return {
1589
+ ...this.parent?.(),
1590
+ leading: {
1591
+ default: null,
1592
+ parseHTML: (t) => t.style.lineHeight || null,
1593
+ renderHTML: (t) => t.leading ? { style: `line-height: ${t.leading}` } : {}
1594
+ },
1595
+ spaceBefore: {
1596
+ default: null,
1597
+ parseHTML: (t) => t.style.marginTop || null,
1598
+ renderHTML: (t) => t.spaceBefore ? { style: `margin-top: ${t.spaceBefore}` } : {}
1599
+ },
1600
+ spaceAfter: {
1601
+ default: null,
1602
+ parseHTML: (t) => t.style.marginBottom || null,
1603
+ renderHTML: (t) => t.spaceAfter ? { style: `margin-bottom: ${t.spaceAfter}` } : {}
1604
+ },
1605
+ end: {
1606
+ default: null,
1607
+ parseHTML: (t) => t.getAttribute("data-it-end"),
1608
+ renderHTML: (t) => t.end ? { "data-it-end": t.end } : {}
1609
+ }
1610
+ };
1611
+ },
1612
+ renderHTML({ node: t, HTMLAttributes: e }) {
1613
+ return t.attrs.end ? [
1614
+ "p",
1615
+ z(e),
1616
+ ["span", { class: "it-split-main" }, 0]
1617
+ ] : ["p", z(e), 0];
1618
+ }
1619
+ }), rr = vt.create({
1620
+ name: "blockProps",
1621
+ addCommands() {
1622
+ return {
1623
+ setBlockProp: (t, e) => ({ state: n, tr: r, dispatch: o }) => {
1624
+ const { from: l, to: a } = n.selection;
1625
+ let u = !1;
1626
+ return n.doc.nodesBetween(l, a, (c, g) => {
1627
+ const p = c.type.name;
1628
+ if (p === "bulletList" || p === "orderedList" || !c.isBlock || c.isAtom) return !1;
1629
+ if (!se(p, t)) return !0;
1630
+ if (p === "paragraph")
1631
+ r.setNodeMarkup(g, void 0, {
1632
+ ...c.attrs,
1633
+ [re[t]]: e
1634
+ });
1635
+ else {
1636
+ const b = oe(c.attrs.props);
1637
+ e == null || e === "" ? delete b[t] : b[t] = e, r.setNodeMarkup(g, void 0, {
1638
+ ...c.attrs,
1639
+ props: JSON.stringify(b)
1640
+ });
1641
+ }
1642
+ return u = !0, !1;
1643
+ }), u && o && o(r), u;
1644
+ }
1645
+ };
1646
+ }
1647
+ });
1648
+ function Z(t, e) {
1649
+ if (!t) return null;
1650
+ const { state: n } = t, { from: r, to: o } = n.selection;
1651
+ let l = null;
1652
+ return n.doc.nodesBetween(r, o, (a) => {
1653
+ if (l !== null) return !1;
1654
+ const u = a.type.name;
1655
+ if (!se(u, e)) return !0;
1656
+ if (u === "paragraph") {
1657
+ const c = a.attrs[re[e]];
1658
+ l = c != null ? String(c) : "";
1659
+ } else
1660
+ l = oe(a.attrs.props)[e] ?? "";
1661
+ return !1;
1662
+ }), l;
1663
+ }
1664
+ const Kt = {
1665
+ identity: { label: "Identity", icon: "ID", color: "#3b82f6" },
1666
+ content: { label: "Content", icon: "Tx", color: "#6b7280" },
1667
+ structure: { label: "Structure", icon: "##", color: "#22c55e" },
1668
+ data: { label: "Data", icon: "Dt", color: "#a855f7" },
1669
+ agent: { label: "Agent", icon: "Ag", color: "#f97316" },
1670
+ trust: { label: "Trust", icon: "Tr", color: "#eab308" },
1671
+ layout: { label: "Layout", icon: "Pg", color: "#64748b" }
1672
+ };
1673
+ function or(t) {
1674
+ const e = document.createElement("iframe");
1675
+ e.setAttribute("aria-hidden", "true"), e.style.cssText = "position:fixed;right:0;bottom:0;width:210mm;height:297mm;border:0;visibility:hidden;", document.body.appendChild(e);
1676
+ let n = !1;
1677
+ const r = () => {
1678
+ if (!n) {
1679
+ n = !0;
1680
+ try {
1681
+ e.contentWindow.focus(), e.contentWindow.print();
1682
+ } finally {
1683
+ setTimeout(() => e.remove(), 1e3);
1684
+ }
1685
+ }
1686
+ };
1687
+ e.onload = () => window.setTimeout(r, 120);
1688
+ const o = e.contentWindow.document;
1689
+ o.open(), o.write(t), o.close(), o.readyState === "complete" && window.setTimeout(r, 250);
1690
+ }
1691
+ function sr(t, e) {
1692
+ return t.includes("</head>") ? t.replace("</head>", `<style>${e}</style></head>`) : t;
1693
+ }
1694
+ const ie = ".it-doc-callout{background:none!important;border:1px solid #ccc!important}", qt = _e;
1695
+ function ir(t, e) {
1696
+ const n = document.querySelector(".docs-page .tiptap");
1697
+ if (!n) return null;
1698
+ const r = n.cloneNode(!0);
1699
+ r.querySelectorAll("[data-it-spacer]").forEach((b) => b.remove());
1700
+ const o = r.innerHTML, l = Array.from(
1701
+ document.querySelectorAll('style, link[rel="stylesheet"]')
1702
+ ).map((b) => b.outerHTML).join(`
1703
+ `), a = zt(t), u = a.autoHeight ? `${a.width}px auto` : `${a.width}px ${a.height}px`, c = `${a.marginTop}px ${a.marginRight}px ${a.marginBottom}px ${a.marginLeft}px`;
1704
+ let g = `@page{size:${u};margin:${c};}`;
1705
+ a.header && (g += `@page{@top-center{content:${qt(a.header)};font:10px -apple-system,sans-serif;color:#9aa0a6;}}`), a.footer && (g += `@page{@bottom-center{content:${qt(a.footer)};font:10px -apple-system,sans-serif;color:#9aa0a6;}}`);
1706
+ const p = `
1707
+ html,body{margin:0;background:#fff;}
1708
+ .docs-page,.docs-page.docs-sheet{box-shadow:none;border-radius:0;margin:0;width:auto;min-height:0;padding:0;background:#fff;}
1709
+ .docs-page .tiptap{padding:0;}
1710
+ [data-it-spacer]{display:none!important;}
1711
+ ${e === "minimal-ink" ? ie : ""}
1712
+ `;
1713
+ return `<!doctype html><html><head><meta charset="utf-8">${l}<style>${g}${p}</style></head><body><div class="docs-page docs-sheet"><div class="tiptap">${o}</div></div></body></html>`;
1714
+ }
1715
+ function ar(t, e, n) {
1716
+ const r = new Blob([t], { type: n }), o = URL.createObjectURL(r), l = document.createElement("a");
1717
+ l.href = o, l.download = e, l.click(), URL.revokeObjectURL(o);
1718
+ }
1719
+ function ae(t, e, n) {
1720
+ let r = ir(t, n);
1721
+ if (!r) {
1722
+ const o = tt(t);
1723
+ r = Me(o, { theme: e }), n === "minimal-ink" && (r = sr(r, ie));
1724
+ }
1725
+ return r;
1726
+ }
1727
+ function cr(t, e, n = "normal") {
1728
+ try {
1729
+ or(ae(t, e, n));
1730
+ } catch {
1731
+ }
1732
+ }
1733
+ function lr(t, e, n = "normal") {
1734
+ try {
1735
+ ar(
1736
+ ae(t, e, n),
1737
+ "document.html",
1738
+ "text/html"
1739
+ );
1740
+ } catch {
1741
+ }
1742
+ }
1743
+ function dr() {
1744
+ return ze();
1745
+ }
1746
+ const Ct = [
1747
+ { label: "Normal text", node: "paragraph" },
1748
+ { label: "Title", node: "itTitle" },
1749
+ { label: "Section", node: "itSection" },
1750
+ { label: "Subsection", node: "itSub" },
1751
+ { label: "Summary", node: "itSummary" },
1752
+ { label: "Quote", node: "itQuote" }
1753
+ ], ur = /* @__PURE__ */ new Set([
1754
+ "history",
1755
+ "revision",
1756
+ "track",
1757
+ "freeze"
1758
+ ]), pr = /* @__PURE__ */ new Set([
1759
+ "agent",
1760
+ "model",
1761
+ "meta",
1762
+ "context",
1763
+ "history"
1764
+ ]), fr = [
1765
+ "identity",
1766
+ "structure",
1767
+ "content",
1768
+ "data",
1769
+ "trust",
1770
+ "layout"
1771
+ ], Jt = [
1772
+ { label: "Default", value: "" },
1773
+ { label: "Inter", value: "Inter" },
1774
+ { label: "Arial", value: "Arial" },
1775
+ { label: "Times New Roman", value: "Times New Roman" },
1776
+ { label: "Georgia", value: "Georgia" },
1777
+ { label: "Courier New", value: "Courier New" },
1778
+ { label: "Verdana", value: "Verdana" },
1779
+ { label: "Trebuchet MS", value: "Trebuchet MS" }
1780
+ ], gr = ["1", "1.15", "1.5", "2", "2.5", "3"], mr = "12px", hr = [
1781
+ "#000000",
1782
+ "#434343",
1783
+ "#666666",
1784
+ "#999999",
1785
+ "#b7b7b7",
1786
+ "#cccccc",
1787
+ "#d9d9d9",
1788
+ "#efefef",
1789
+ "#f3f3f3",
1790
+ "#ffffff",
1791
+ "#980000",
1792
+ "#ff0000",
1793
+ "#ff9900",
1794
+ "#ffff00",
1795
+ "#00ff00",
1796
+ "#00ffff",
1797
+ "#4a86e8",
1798
+ "#0000ff",
1799
+ "#9900ff",
1800
+ "#ff00ff",
1801
+ "#e6b8af",
1802
+ "#f4cccc",
1803
+ "#fce5cd",
1804
+ "#fff2cc",
1805
+ "#d9ead3",
1806
+ "#d0e0e3",
1807
+ "#c9daf8",
1808
+ "#cfe2f3",
1809
+ "#d9d2e9",
1810
+ "#ead1dc",
1811
+ "#dd7e6b",
1812
+ "#ea9999",
1813
+ "#f9cb9c",
1814
+ "#ffe599",
1815
+ "#b6d7a8",
1816
+ "#a2c4c9",
1817
+ "#a4c2f4",
1818
+ "#9fc5e8",
1819
+ "#b4a7d6",
1820
+ "#d5a6bd",
1821
+ "#cc4125",
1822
+ "#e06666",
1823
+ "#f6b26b",
1824
+ "#ffd966",
1825
+ "#93c47d",
1826
+ "#76a5af",
1827
+ "#6d9eeb",
1828
+ "#6fa8dc",
1829
+ "#8e7cc3",
1830
+ "#c27ba0"
1831
+ ], br = [
1832
+ "#ffffff",
1833
+ "#cfe2f3",
1834
+ "#d9ead3",
1835
+ "#fff2cc",
1836
+ "#fce5cd",
1837
+ "#f4cccc",
1838
+ "#d9d2e9",
1839
+ "#ead1dc",
1840
+ "#d0e0e3",
1841
+ "#e6b8af"
1842
+ ];
1843
+ function $({
1844
+ onClick: t,
1845
+ active: e,
1846
+ disabled: n,
1847
+ title: r,
1848
+ children: o
1849
+ }) {
1850
+ return /* @__PURE__ */ i(
1851
+ "button",
1852
+ {
1853
+ className: `docs-tb-btn${e ? " active" : ""}`,
1854
+ onClick: t,
1855
+ disabled: n,
1856
+ title: r,
1857
+ children: o
1858
+ }
1859
+ );
1860
+ }
1861
+ function dt({
1862
+ label: t,
1863
+ children: e,
1864
+ className: n = ""
1865
+ }) {
1866
+ return /* @__PURE__ */ h("div", { className: `ribbon-group ${n}`.trim(), children: [
1867
+ /* @__PURE__ */ i("div", { className: "ribbon-group-row", children: e }),
1868
+ /* @__PURE__ */ i("div", { className: "ribbon-group-label", children: t })
1869
+ ] });
1870
+ }
1871
+ function mt() {
1872
+ return /* @__PURE__ */ i("div", { className: "ribbon-sep" });
1873
+ }
1874
+ function yr({
1875
+ editor: t,
1876
+ isRtl: e = !1,
1877
+ onToggleRtl: n,
1878
+ content: r,
1879
+ theme: o,
1880
+ onThemeChange: l,
1881
+ onTrustAction: a,
1882
+ locked: u = !1
1883
+ }) {
1884
+ const [c, g] = B(!1), [p, b] = B(!1), [f, k] = B(!1), [T, M] = B(!1), [S, v] = B(!1), [nt, I] = B(!1), [G, U] = B(!1), F = P(null), rt = P(null), N = P(null), H = P(null), ot = P(null), Y = P(null);
1885
+ j(() => {
1886
+ const d = (A) => {
1887
+ const w = A.target;
1888
+ F.current && !F.current.contains(w) && g(!1), rt.current && !rt.current.contains(w) && b(!1), N.current && !N.current.contains(w) && k(!1), H.current && !H.current.contains(w) && M(!1), ot.current && !ot.current.contains(w) && v(!1), Y.current && !Y.current.contains(w) && I(!1);
1889
+ };
1890
+ return document.addEventListener("mousedown", d), () => document.removeEventListener("mousedown", d);
1891
+ }, []);
1892
+ const C = () => {
1893
+ g(!1), b(!1), k(!1), M(!1), v(!1), I(!1);
1894
+ }, st = R(() => {
1895
+ if (!t) return "Normal text";
1896
+ for (const d of Ct)
1897
+ if (d.node === "paragraph" && t.isActive("paragraph")) {
1898
+ if (!Ct.some(
1899
+ (w) => w.node !== "paragraph" && t.isActive(w.node)
1900
+ )) return d.label;
1901
+ } else if (t.isActive(d.node))
1902
+ return d.label;
1903
+ return "Normal text";
1904
+ }, [t]), ut = R(() => {
1905
+ if (!t) return "Default";
1906
+ const d = t.getAttributes("textStyle")?.fontFamily;
1907
+ if (!d) return "Default";
1908
+ const A = Jt.find((w) => w.value === d);
1909
+ return A ? A.label : "Default";
1910
+ }, [t]), [J, pt] = B(11), [, at] = B(0), m = K(() => {
1911
+ const d = /* @__PURE__ */ new Map();
1912
+ for (const w of He) {
1913
+ if (w.status !== "stable" || pr.has(w.canonical) || w.category === "agent") continue;
1914
+ const Q = w.category, bt = d.get(Q) || [];
1915
+ bt.push({
1916
+ label: w.canonical,
1917
+ keyword: w.canonical,
1918
+ category: Q,
1919
+ description: w.description,
1920
+ isReadOnly: ur.has(w.canonical)
1921
+ }), d.set(Q, bt);
1922
+ }
1923
+ const A = [];
1924
+ for (const w of fr) {
1925
+ const Q = d.get(w);
1926
+ !Q || Q.length === 0 || (Q.sort((bt, me) => bt.keyword.localeCompare(me.keyword)), A.push({
1927
+ category: Kt[w]?.label || w,
1928
+ items: Q
1929
+ }));
1930
+ }
1931
+ return A;
1932
+ }, []);
1933
+ j(() => {
1934
+ if (!t) return;
1935
+ const d = () => {
1936
+ const A = t.getAttributes("textStyle");
1937
+ if (A?.fontSize) {
1938
+ const w = parseInt(A.fontSize, 10);
1939
+ isNaN(w) || pt(w);
1940
+ }
1941
+ at((w) => w + 1);
1942
+ };
1943
+ return t.on("selectionUpdate", d), t.on("transaction", d), () => {
1944
+ t.off("selectionUpdate", d), t.off("transaction", d);
1945
+ };
1946
+ }, [t]);
1947
+ const y = R(
1948
+ (d) => {
1949
+ t && (d === "paragraph" ? t.chain().focus().setParagraph().run() : d === "itQuote" ? t.chain().focus().setNode("itQuote").run() : t.chain().focus().setNode(d).run(), C());
1950
+ },
1951
+ [t]
1952
+ ), x = R(
1953
+ (d) => {
1954
+ if (!t) return;
1955
+ const A = t.chain().focus();
1956
+ d === "divider" ? A.setNode("itDivider").run() : d === "break" ? A.setNode("itBreak").run() : d === "code" ? A.setNode("itCode", { lang: "" }).run() : ["tip", "info", "warning", "danger", "success"].includes(d) ? A.setNode("itCallout", { variant: d }).run() : A.setNode("itGenericBlock", { keyword: d, properties: "" }).run(), C();
1957
+ },
1958
+ [t]
1959
+ ), O = R(
1960
+ (d) => {
1961
+ const A = Math.min(96, Math.max(8, J + d));
1962
+ pt(A), t?.chain().focus().setFontSize(`${A}pt`).run();
1963
+ },
1964
+ [t, J]
1965
+ ), V = R(
1966
+ (d) => {
1967
+ t?.chain().focus().setBlockProp("leading", d).run(), C();
1968
+ },
1969
+ [t]
1970
+ ), W = R(
1971
+ (d) => {
1972
+ if (!t) return;
1973
+ const A = Z(t, d);
1974
+ t.chain().focus().setBlockProp(d, A ? null : mr).run(), C();
1975
+ },
1976
+ [t]
1977
+ ), ce = R(() => {
1978
+ if (!t) return;
1979
+ const d = window.prompt(
1980
+ "Space before block (e.g. 12px, 1em — empty for none):",
1981
+ Z(t, "space-before") || ""
1982
+ );
1983
+ if (d === null) return;
1984
+ const A = window.prompt(
1985
+ "Space after block (e.g. 12px, 1em — empty for none):",
1986
+ Z(t, "space-after") || ""
1987
+ );
1988
+ A !== null && (t.chain().focus().setBlockProp("space-before", d.trim() || null).setBlockProp("space-after", A.trim() || null).run(), C());
1989
+ }, [t]), le = R(() => {
1990
+ if (!t) return;
1991
+ const d = Z(t, "end"), A = window.prompt(
1992
+ "Line-end text (shown at the end of the line — empty to remove):",
1993
+ d || ""
1994
+ );
1995
+ A !== null && t.chain().focus().setBlockProp("end", A.trim() || null).run();
1996
+ }, [t]), de = R(() => {
1997
+ t && (t.chain().focus().insertContent({
1998
+ type: "paragraph",
1999
+ attrs: { end: "End text" },
2000
+ content: [{ type: "text", text: "Start text" }]
2001
+ }).run(), C());
2002
+ }, [t]), ue = K(() => dr(), []), ht = G ? "minimal-ink" : "normal", pe = R(
2003
+ () => cr(r, o, ht),
2004
+ [r, o, ht]
2005
+ ), fe = R(
2006
+ () => lr(r, o, ht),
2007
+ [r, o, ht]
2008
+ );
2009
+ if (!t) return null;
2010
+ const Tt = Z(t, "leading"), ge = !!Z(t, "end");
2011
+ return /* @__PURE__ */ h("div", { className: "docs-toolbar docs-ribbon", children: [
2012
+ /* @__PURE__ */ h(dt, { label: "Edit", children: [
2013
+ /* @__PURE__ */ i(
2014
+ $,
2015
+ {
2016
+ onClick: () => t.chain().focus().undo().run(),
2017
+ disabled: u || !t.can().undo(),
2018
+ title: "Undo (⌘Z)",
2019
+ children: /* @__PURE__ */ i(Oe, { size: 16 })
2020
+ }
2021
+ ),
2022
+ /* @__PURE__ */ i(
2023
+ $,
2024
+ {
2025
+ onClick: () => t.chain().focus().redo().run(),
2026
+ disabled: u || !t.can().redo(),
2027
+ title: "Redo (⌘⇧Z)",
2028
+ children: /* @__PURE__ */ i(De, { size: 16 })
2029
+ }
2030
+ )
2031
+ ] }),
2032
+ /* @__PURE__ */ i(mt, {}),
2033
+ /* @__PURE__ */ h(dt, { label: "File", children: [
2034
+ /* @__PURE__ */ h($, { onClick: pe, title: "Print / Export PDF (WYSIWYG)", children: [
2035
+ /* @__PURE__ */ i(Fe, { size: 16 }),
2036
+ /* @__PURE__ */ i("span", { className: "ribbon-btn-text", children: "PDF" })
2037
+ ] }),
2038
+ /* @__PURE__ */ h($, { onClick: fe, title: "Export HTML", children: [
2039
+ /* @__PURE__ */ i(je, { size: 16 }),
2040
+ /* @__PURE__ */ i("span", { className: "ribbon-btn-text", children: "HTML" })
2041
+ ] }),
2042
+ /* @__PURE__ */ i(
2043
+ $,
2044
+ {
2045
+ onClick: () => U((d) => !d),
2046
+ active: G,
2047
+ title: "Minimal ink mode (plain callouts when printing)",
2048
+ children: /* @__PURE__ */ i(We, { size: 16 })
2049
+ }
2050
+ ),
2051
+ /* @__PURE__ */ i(
2052
+ "select",
2053
+ {
2054
+ className: "ribbon-theme-select",
2055
+ value: o,
2056
+ onChange: (d) => l(d.target.value),
2057
+ title: "Document theme (used by print/export)",
2058
+ children: ue.map((d) => /* @__PURE__ */ i("option", { value: d, children: d.charAt(0).toUpperCase() + d.slice(1) }, d))
2059
+ }
2060
+ )
2061
+ ] }),
2062
+ /* @__PURE__ */ i(mt, {}),
2063
+ /* @__PURE__ */ h("div", { className: u ? "ribbon-locked" : "ribbon-editing", children: [
2064
+ /* @__PURE__ */ h(dt, { label: "Text", children: [
2065
+ /* @__PURE__ */ h("div", { className: "docs-tb-dropdown", ref: N, children: [
2066
+ /* @__PURE__ */ h(
2067
+ "button",
2068
+ {
2069
+ className: "docs-tb-select docs-tb-font-select",
2070
+ onClick: () => {
2071
+ C(), k(!f);
2072
+ },
2073
+ children: [
2074
+ /* @__PURE__ */ i("span", { className: "docs-tb-select-label", children: ut() }),
2075
+ /* @__PURE__ */ i(yt, { size: 14 })
2076
+ ]
2077
+ }
2078
+ ),
2079
+ f && /* @__PURE__ */ i("div", { className: "docs-tb-dropdown-menu docs-font-menu", children: Jt.map((d) => /* @__PURE__ */ i(
2080
+ "button",
2081
+ {
2082
+ className: `docs-tb-dropdown-item${ut() === d.label ? " active" : ""}`,
2083
+ style: { fontFamily: d.value || "inherit" },
2084
+ onClick: () => {
2085
+ d.value ? t.chain().focus().setFontFamily(d.value).run() : t.chain().focus().unsetFontFamily().run(), C();
2086
+ },
2087
+ children: d.label
2088
+ },
2089
+ d.value || "default"
2090
+ )) })
2091
+ ] }),
2092
+ /* @__PURE__ */ i($, { onClick: () => O(-1), title: "Decrease font size", children: /* @__PURE__ */ i(Ge, { size: 14 }) }),
2093
+ /* @__PURE__ */ i("span", { className: "docs-tb-fontsize", children: J }),
2094
+ /* @__PURE__ */ i($, { onClick: () => O(1), title: "Increase font size", children: /* @__PURE__ */ i(Pt, { size: 14 }) }),
2095
+ /* @__PURE__ */ i(
2096
+ $,
2097
+ {
2098
+ onClick: () => t.chain().focus().toggleBold().run(),
2099
+ active: t.isActive("bold"),
2100
+ title: "Bold (⌘B)",
2101
+ children: /* @__PURE__ */ i(Ue, { size: 16 })
2102
+ }
2103
+ ),
2104
+ /* @__PURE__ */ i(
2105
+ $,
2106
+ {
2107
+ onClick: () => t.chain().focus().toggleItalic().run(),
2108
+ active: t.isActive("italic"),
2109
+ title: "Italic (⌘I)",
2110
+ children: /* @__PURE__ */ i(Ye, { size: 16 })
2111
+ }
2112
+ ),
2113
+ /* @__PURE__ */ i(
2114
+ $,
2115
+ {
2116
+ onClick: () => t.chain().focus().toggleUnderline().run(),
2117
+ active: t.isActive("underline"),
2118
+ title: "Underline (⌘U)",
2119
+ children: /* @__PURE__ */ i(Ke, { size: 16 })
2120
+ }
2121
+ ),
2122
+ /* @__PURE__ */ i(
2123
+ $,
2124
+ {
2125
+ onClick: () => t.chain().focus().toggleStrike().run(),
2126
+ active: t.isActive("strike"),
2127
+ title: "Strikethrough (⌘⇧X)",
2128
+ children: /* @__PURE__ */ i(qe, { size: 16 })
2129
+ }
2130
+ ),
2131
+ /* @__PURE__ */ h(
2132
+ "div",
2133
+ {
2134
+ className: "docs-tb-dropdown docs-tb-color-dropdown",
2135
+ ref: H,
2136
+ children: [
2137
+ /* @__PURE__ */ h(
2138
+ "button",
2139
+ {
2140
+ className: "docs-tb-btn docs-tb-color-btn",
2141
+ onClick: () => {
2142
+ C(), M(!T);
2143
+ },
2144
+ title: "Text color",
2145
+ children: [
2146
+ /* @__PURE__ */ i(Je, { size: 16 }),
2147
+ /* @__PURE__ */ i(
2148
+ "span",
2149
+ {
2150
+ className: "docs-tb-color-indicator",
2151
+ style: {
2152
+ background: t.getAttributes("textStyle")?.color || "#000000"
2153
+ }
2154
+ }
2155
+ )
2156
+ ]
2157
+ }
2158
+ ),
2159
+ T && /* @__PURE__ */ h("div", { className: "docs-tb-dropdown-menu docs-color-grid-menu", children: [
2160
+ /* @__PURE__ */ i("div", { className: "docs-color-grid-label", children: "Text color" }),
2161
+ /* @__PURE__ */ i("div", { className: "docs-color-grid", children: hr.map((d) => /* @__PURE__ */ i(
2162
+ "button",
2163
+ {
2164
+ className: "docs-color-swatch",
2165
+ style: { background: d },
2166
+ title: d,
2167
+ onClick: () => {
2168
+ t.chain().focus().setColor(d).run(), C();
2169
+ }
2170
+ },
2171
+ d
2172
+ )) }),
2173
+ /* @__PURE__ */ h(
2174
+ "button",
2175
+ {
2176
+ className: "docs-tb-dropdown-item",
2177
+ onClick: () => {
2178
+ t.chain().focus().unsetColor().run(), C();
2179
+ },
2180
+ children: [
2181
+ /* @__PURE__ */ i(It, { size: 14 }),
2182
+ " Reset"
2183
+ ]
2184
+ }
2185
+ )
2186
+ ] })
2187
+ ]
2188
+ }
2189
+ ),
2190
+ /* @__PURE__ */ h(
2191
+ "div",
2192
+ {
2193
+ className: "docs-tb-dropdown docs-tb-color-dropdown",
2194
+ ref: ot,
2195
+ children: [
2196
+ /* @__PURE__ */ h(
2197
+ "button",
2198
+ {
2199
+ className: "docs-tb-btn docs-tb-color-btn",
2200
+ onClick: () => {
2201
+ C(), v(!S);
2202
+ },
2203
+ title: "Highlight color",
2204
+ children: [
2205
+ /* @__PURE__ */ i(Ve, { size: 16 }),
2206
+ /* @__PURE__ */ i(
2207
+ "span",
2208
+ {
2209
+ className: "docs-tb-color-indicator",
2210
+ style: {
2211
+ background: t.getAttributes("highlight")?.color || "transparent"
2212
+ }
2213
+ }
2214
+ )
2215
+ ]
2216
+ }
2217
+ ),
2218
+ S && /* @__PURE__ */ h("div", { className: "docs-tb-dropdown-menu docs-color-grid-menu", children: [
2219
+ /* @__PURE__ */ i("div", { className: "docs-color-grid-label", children: "Highlight color" }),
2220
+ /* @__PURE__ */ i("div", { className: "docs-color-grid docs-highlight-grid", children: br.map((d) => /* @__PURE__ */ i(
2221
+ "button",
2222
+ {
2223
+ className: "docs-color-swatch",
2224
+ style: { background: d },
2225
+ title: d,
2226
+ onClick: () => {
2227
+ d === "#ffffff" ? t.chain().focus().unsetHighlight().run() : t.chain().focus().toggleHighlight({ color: d }).run(), C();
2228
+ }
2229
+ },
2230
+ d
2231
+ )) })
2232
+ ] })
2233
+ ]
2234
+ }
2235
+ ),
2236
+ /* @__PURE__ */ i(
2237
+ $,
2238
+ {
2239
+ onClick: () => t.chain().focus().toggleSubscript().run(),
2240
+ active: t.isActive("subscript"),
2241
+ title: "Subscript",
2242
+ children: /* @__PURE__ */ i(Qe, { size: 16 })
2243
+ }
2244
+ ),
2245
+ /* @__PURE__ */ i(
2246
+ $,
2247
+ {
2248
+ onClick: () => t.chain().focus().toggleSuperscript().run(),
2249
+ active: t.isActive("superscript"),
2250
+ title: "Superscript",
2251
+ children: /* @__PURE__ */ i(Ze, { size: 16 })
2252
+ }
2253
+ ),
2254
+ /* @__PURE__ */ i(
2255
+ $,
2256
+ {
2257
+ onClick: () => t.chain().focus().toggleCode().run(),
2258
+ active: t.isActive("code"),
2259
+ title: "Inline code",
2260
+ children: /* @__PURE__ */ i(Xe, { size: 16 })
2261
+ }
2262
+ ),
2263
+ /* @__PURE__ */ i(
2264
+ $,
2265
+ {
2266
+ onClick: () => t.chain().focus().unsetAllMarks().clearNodes().run(),
2267
+ title: "Clear formatting",
2268
+ children: /* @__PURE__ */ i(It, { size: 16 })
2269
+ }
2270
+ )
2271
+ ] }),
2272
+ /* @__PURE__ */ i(mt, {}),
2273
+ /* @__PURE__ */ h(dt, { label: "Paragraph", children: [
2274
+ /* @__PURE__ */ h("div", { className: "docs-tb-dropdown", ref: F, children: [
2275
+ /* @__PURE__ */ h(
2276
+ "button",
2277
+ {
2278
+ className: "docs-tb-select docs-tb-paragraph-select",
2279
+ onClick: () => {
2280
+ C(), g(!c);
2281
+ },
2282
+ children: [
2283
+ /* @__PURE__ */ i("span", { className: "docs-tb-select-label", children: st() }),
2284
+ /* @__PURE__ */ i(yt, { size: 14 })
2285
+ ]
2286
+ }
2287
+ ),
2288
+ c && /* @__PURE__ */ i("div", { className: "docs-tb-dropdown-menu docs-style-menu", children: Ct.map((d) => /* @__PURE__ */ i(
2289
+ "button",
2290
+ {
2291
+ className: `docs-tb-dropdown-item${st() === d.label ? " active" : ""}`,
2292
+ onClick: () => y(d.node),
2293
+ children: /* @__PURE__ */ i(
2294
+ "span",
2295
+ {
2296
+ className: `docs-style-preview docs-style-${d.node}`,
2297
+ children: d.label
2298
+ }
2299
+ )
2300
+ },
2301
+ d.node
2302
+ )) })
2303
+ ] }),
2304
+ /* @__PURE__ */ i(
2305
+ $,
2306
+ {
2307
+ onClick: () => t.chain().focus().setTextAlign("left").run(),
2308
+ active: t.isActive({ textAlign: "left" }),
2309
+ title: "Align left",
2310
+ children: /* @__PURE__ */ i(tn, { size: 16 })
2311
+ }
2312
+ ),
2313
+ /* @__PURE__ */ i(
2314
+ $,
2315
+ {
2316
+ onClick: () => t.chain().focus().setTextAlign("center").run(),
2317
+ active: t.isActive({ textAlign: "center" }),
2318
+ title: "Align center",
2319
+ children: /* @__PURE__ */ i(en, { size: 16 })
2320
+ }
2321
+ ),
2322
+ /* @__PURE__ */ i(
2323
+ $,
2324
+ {
2325
+ onClick: () => t.chain().focus().setTextAlign("right").run(),
2326
+ active: t.isActive({ textAlign: "right" }),
2327
+ title: "Align right",
2328
+ children: /* @__PURE__ */ i(nn, { size: 16 })
2329
+ }
2330
+ ),
2331
+ /* @__PURE__ */ i(
2332
+ $,
2333
+ {
2334
+ onClick: () => t.chain().focus().setTextAlign("justify").run(),
2335
+ active: t.isActive({ textAlign: "justify" }),
2336
+ title: "Justify",
2337
+ children: /* @__PURE__ */ i(rn, { size: 16 })
2338
+ }
2339
+ ),
2340
+ /* @__PURE__ */ i(
2341
+ $,
2342
+ {
2343
+ onClick: () => n?.(),
2344
+ active: e,
2345
+ title: e ? "Switch to LTR (left-to-right)" : "Switch to RTL (right-to-left)",
2346
+ children: /* @__PURE__ */ i(
2347
+ "span",
2348
+ {
2349
+ style: {
2350
+ fontSize: 11,
2351
+ fontWeight: 700,
2352
+ letterSpacing: -0.5,
2353
+ lineHeight: 1
2354
+ },
2355
+ children: e ? "LTR" : "RTL"
2356
+ }
2357
+ )
2358
+ }
2359
+ ),
2360
+ /* @__PURE__ */ h("div", { className: "docs-tb-dropdown", ref: Y, children: [
2361
+ /* @__PURE__ */ h(
2362
+ "button",
2363
+ {
2364
+ className: `docs-tb-btn${Tt ? " active" : ""}`,
2365
+ onClick: () => {
2366
+ C(), I(!nt);
2367
+ },
2368
+ title: "Line & paragraph spacing",
2369
+ children: [
2370
+ /* @__PURE__ */ i(on, { size: 16 }),
2371
+ /* @__PURE__ */ i(yt, { size: 12 })
2372
+ ]
2373
+ }
2374
+ ),
2375
+ nt && /* @__PURE__ */ h("div", { className: "docs-tb-dropdown-menu docs-spacing-menu", children: [
2376
+ /* @__PURE__ */ i("div", { className: "docs-insert-category", children: "Line spacing" }),
2377
+ /* @__PURE__ */ i(
2378
+ "button",
2379
+ {
2380
+ className: `docs-tb-dropdown-item${Tt ? "" : " active"}`,
2381
+ onClick: () => V(null),
2382
+ children: "Default"
2383
+ }
2384
+ ),
2385
+ gr.map((d) => /* @__PURE__ */ i(
2386
+ "button",
2387
+ {
2388
+ className: `docs-tb-dropdown-item${Tt === d ? " active" : ""}`,
2389
+ onClick: () => V(d),
2390
+ children: d === "1" ? "Single" : d === "2" ? "Double" : d
2391
+ },
2392
+ d
2393
+ )),
2394
+ /* @__PURE__ */ i("div", { className: "docs-insert-divider" }),
2395
+ /* @__PURE__ */ i("div", { className: "docs-insert-category", children: "Paragraph spacing" }),
2396
+ /* @__PURE__ */ i(
2397
+ "button",
2398
+ {
2399
+ className: "docs-tb-dropdown-item",
2400
+ onClick: () => W("space-before"),
2401
+ children: Z(t, "space-before") ? "Remove space before block" : "Add space before block"
2402
+ }
2403
+ ),
2404
+ /* @__PURE__ */ i(
2405
+ "button",
2406
+ {
2407
+ className: "docs-tb-dropdown-item",
2408
+ onClick: () => W("space-after"),
2409
+ children: Z(t, "space-after") ? "Remove space after block" : "Add space after block"
2410
+ }
2411
+ ),
2412
+ /* @__PURE__ */ i(
2413
+ "button",
2414
+ {
2415
+ className: "docs-tb-dropdown-item",
2416
+ onClick: ce,
2417
+ children: "Custom spacing…"
2418
+ }
2419
+ )
2420
+ ] })
2421
+ ] }),
2422
+ /* @__PURE__ */ i(
2423
+ $,
2424
+ {
2425
+ onClick: () => t.chain().focus().toggleBulletList().run(),
2426
+ active: t.isActive("bulletList"),
2427
+ title: "Bullet list",
2428
+ children: /* @__PURE__ */ i(sn, { size: 16 })
2429
+ }
2430
+ ),
2431
+ /* @__PURE__ */ i(
2432
+ $,
2433
+ {
2434
+ onClick: () => t.chain().focus().toggleOrderedList().run(),
2435
+ active: t.isActive("orderedList"),
2436
+ title: "Numbered list",
2437
+ children: /* @__PURE__ */ i(an, { size: 16 })
2438
+ }
2439
+ )
2440
+ ] }),
2441
+ /* @__PURE__ */ i(mt, {}),
2442
+ /* @__PURE__ */ h(dt, { label: "Insert", children: [
2443
+ /* @__PURE__ */ h("div", { className: "docs-tb-dropdown", ref: rt, children: [
2444
+ /* @__PURE__ */ h(
2445
+ "button",
2446
+ {
2447
+ className: "docs-tb-select docs-tb-insert-select",
2448
+ onClick: () => {
2449
+ C(), b(!p);
2450
+ },
2451
+ children: [
2452
+ /* @__PURE__ */ i(Pt, { size: 15 }),
2453
+ /* @__PURE__ */ i("span", { children: "Insert" }),
2454
+ /* @__PURE__ */ i(yt, { size: 14 })
2455
+ ]
2456
+ }
2457
+ ),
2458
+ p && /* @__PURE__ */ h("div", { className: "docs-tb-dropdown-menu docs-insert-menu", children: [
2459
+ /* @__PURE__ */ h(
2460
+ "button",
2461
+ {
2462
+ className: "docs-tb-dropdown-item docs-insert-item",
2463
+ onClick: de,
2464
+ title: "Two-sided row — content at the line start, value at the line end (text: … | end: …)",
2465
+ children: [
2466
+ /* @__PURE__ */ i("span", { className: "docs-insert-icon", children: /* @__PURE__ */ i(Ot, { size: 13 }) }),
2467
+ /* @__PURE__ */ i("span", { className: "docs-insert-label", children: "two-sided row" }),
2468
+ /* @__PURE__ */ i("span", { className: "docs-insert-kw", children: "end:" })
2469
+ ]
2470
+ }
2471
+ ),
2472
+ /* @__PURE__ */ i("div", { className: "docs-insert-divider" }),
2473
+ m.map((d, A) => /* @__PURE__ */ h("div", { children: [
2474
+ A > 0 && /* @__PURE__ */ i("div", { className: "docs-insert-divider" }),
2475
+ /* @__PURE__ */ i("div", { className: "docs-insert-category", children: d.category }),
2476
+ d.items.map((w) => /* @__PURE__ */ h(
2477
+ "button",
2478
+ {
2479
+ className: "docs-tb-dropdown-item docs-insert-item",
2480
+ onClick: () => x(w.keyword),
2481
+ disabled: w.isReadOnly,
2482
+ title: w.description,
2483
+ children: [
2484
+ /* @__PURE__ */ i("span", { className: "docs-insert-icon", children: Kt[w.category]?.icon || "•" }),
2485
+ /* @__PURE__ */ i("span", { className: "docs-insert-label", children: w.label }),
2486
+ /* @__PURE__ */ i("span", { className: "docs-insert-kw", children: w.isReadOnly ? "locked" : `.${w.keyword}` })
2487
+ ]
2488
+ },
2489
+ w.keyword
2490
+ ))
2491
+ ] }, d.category))
2492
+ ] })
2493
+ ] }),
2494
+ /* @__PURE__ */ i(
2495
+ $,
2496
+ {
2497
+ onClick: le,
2498
+ active: ge,
2499
+ title: "Two-sided row — set the text shown at the END of this line (end: property)",
2500
+ children: /* @__PURE__ */ i(Ot, { size: 16 })
2501
+ }
2502
+ )
2503
+ ] })
2504
+ ] }),
2505
+ a && /* @__PURE__ */ h(he, { children: [
2506
+ /* @__PURE__ */ i(mt, {}),
2507
+ /* @__PURE__ */ h(dt, { label: "Trust", children: [
2508
+ /* @__PURE__ */ h(
2509
+ $,
2510
+ {
2511
+ onClick: () => a("seal"),
2512
+ disabled: u,
2513
+ title: u ? "Document is already sealed" : "Seal — freeze the document with a tamper-evident hash",
2514
+ children: [
2515
+ /* @__PURE__ */ i(cn, { size: 16 }),
2516
+ /* @__PURE__ */ i("span", { className: "ribbon-btn-text", children: "Seal" })
2517
+ ]
2518
+ }
2519
+ ),
2520
+ /* @__PURE__ */ h(
2521
+ $,
2522
+ {
2523
+ onClick: () => a("sign"),
2524
+ title: "Sign — add a signature",
2525
+ children: [
2526
+ /* @__PURE__ */ i(ln, { size: 16 }),
2527
+ /* @__PURE__ */ i("span", { className: "ribbon-btn-text", children: "Sign" })
2528
+ ]
2529
+ }
2530
+ ),
2531
+ /* @__PURE__ */ h(
2532
+ $,
2533
+ {
2534
+ onClick: () => a("verify"),
2535
+ title: "Verify — check the document hash and signatures",
2536
+ children: [
2537
+ /* @__PURE__ */ i(dn, { size: 16 }),
2538
+ /* @__PURE__ */ i("span", { className: "ribbon-btn-text", children: "Verify" })
2539
+ ]
2540
+ }
2541
+ )
2542
+ ] })
2543
+ ] })
2544
+ ] });
2545
+ }
2546
+ function Lt(t, e) {
2547
+ return e ? `${t} (${e})` : t;
2548
+ }
2549
+ function kr({ trust: t, intact: e }) {
2550
+ if (t.isSealed) {
2551
+ const n = t.sealedBy || "unknown", r = t.signatures[t.signatures.length - 1]?.role;
2552
+ return /* @__PURE__ */ h("div", { className: "docs-trust-banner docs-trust-banner--sealed", role: "status", children: [
2553
+ /* @__PURE__ */ i("span", { className: "docs-trust-banner__icon", children: "🔒" }),
2554
+ /* @__PURE__ */ i("span", { className: "docs-trust-banner__title", children: "Sealed" }),
2555
+ /* @__PURE__ */ h("span", { className: "docs-trust-banner__text", children: [
2556
+ "signed by ",
2557
+ Lt(n, r),
2558
+ t.sealedAt ? ` on ${t.sealedAt}` : "",
2559
+ " · read-only"
2560
+ ] }),
2561
+ e === !0 && /* @__PURE__ */ i("span", { className: "docs-trust-banner__verify docs-trust-banner__verify--ok", children: "hash verified ✓" }),
2562
+ e === !1 && /* @__PURE__ */ i("span", { className: "docs-trust-banner__verify docs-trust-banner__verify--bad", children: "⚠ hash mismatch — content changed after sealing" })
2563
+ ] });
2564
+ }
2565
+ return t.signatures.length > 0 ? /* @__PURE__ */ h("div", { className: "docs-trust-banner docs-trust-banner--signed", role: "status", children: [
2566
+ /* @__PURE__ */ i("span", { className: "docs-trust-banner__icon", children: "✍" }),
2567
+ /* @__PURE__ */ i("span", { className: "docs-trust-banner__title", children: "Signed" }),
2568
+ /* @__PURE__ */ h("span", { className: "docs-trust-banner__text", children: [
2569
+ "by",
2570
+ " ",
2571
+ t.signatures.map((n) => `${Lt(n.by, n.role)}${n.at ? ` on ${n.at}` : ""}`).join(" · ")
2572
+ ] })
2573
+ ] }) : t.approvals.length > 0 ? /* @__PURE__ */ h(
2574
+ "div",
2575
+ {
2576
+ className: "docs-trust-banner docs-trust-banner--approved",
2577
+ role: "status",
2578
+ children: [
2579
+ /* @__PURE__ */ i("span", { className: "docs-trust-banner__icon", children: "✓" }),
2580
+ /* @__PURE__ */ i("span", { className: "docs-trust-banner__title", children: "Approved" }),
2581
+ /* @__PURE__ */ h("span", { className: "docs-trust-banner__text", children: [
2582
+ "by",
2583
+ " ",
2584
+ t.approvals.map((n) => `${Lt(n.by, n.role)}${n.at ? ` on ${n.at}` : ""}`).join(" · ")
2585
+ ] })
2586
+ ]
2587
+ }
2588
+ ) : null;
2589
+ }
2590
+ function Sr(t) {
2591
+ let e;
2592
+ try {
2593
+ e = tt(t);
2594
+ } catch {
2595
+ return [];
2596
+ }
2597
+ const n = [], r = (o, l) => {
2598
+ const a = l == null ? "" : String(l).trim();
2599
+ a && n.push({ key: o, value: a });
2600
+ };
2601
+ for (const o of e.blocks)
2602
+ switch (o.type) {
2603
+ case "meta":
2604
+ for (const [l, a] of Object.entries(o.properties || {})) r(l, a);
2605
+ break;
2606
+ case "track":
2607
+ r("tracked", o.properties?.id ?? o.content);
2608
+ break;
2609
+ case "page": {
2610
+ const l = o.properties?.orientation;
2611
+ r(
2612
+ "page",
2613
+ [o.content, l].filter(Boolean).join(" · ")
2614
+ );
2615
+ break;
2616
+ }
2617
+ case "font":
2618
+ r(
2619
+ "font",
2620
+ [
2621
+ o.content || o.properties?.family,
2622
+ o.properties?.size
2623
+ ].filter(Boolean).join(" · ")
2624
+ );
2625
+ break;
2626
+ case "header":
2627
+ r("header", o.content);
2628
+ break;
2629
+ case "footer":
2630
+ r("footer", o.content);
2631
+ break;
2632
+ case "watermark":
2633
+ r("watermark", o.content);
2634
+ break;
2635
+ }
2636
+ return n;
2637
+ }
2638
+ function wr({ source: t }) {
2639
+ const [e, n] = B(!1), r = K(() => Sr(t), [t]);
2640
+ if (r.length === 0) return null;
2641
+ const o = r.slice(0, 4).map((l) => `${l.key}: ${l.value}`).join(" · ");
2642
+ return /* @__PURE__ */ h("div", { className: `docs-props-bar${e ? " open" : ""}`, children: [
2643
+ /* @__PURE__ */ h(
2644
+ "button",
2645
+ {
2646
+ className: "docs-props-toggle",
2647
+ onClick: () => n((l) => !l),
2648
+ title: e ? "Hide document properties" : "Show document properties",
2649
+ children: [
2650
+ /* @__PURE__ */ i("span", { className: "docs-props-caret", children: e ? "▾" : "▸" }),
2651
+ "Document properties",
2652
+ !e && /* @__PURE__ */ i("span", { className: "docs-props-summary", children: o })
2653
+ ]
2654
+ }
2655
+ ),
2656
+ e && /* @__PURE__ */ i("div", { className: "docs-props-chips", children: r.map((l, a) => /* @__PURE__ */ h("span", { className: "docs-props-chip", children: [
2657
+ /* @__PURE__ */ i("b", { children: l.key }),
2658
+ " ",
2659
+ l.value
2660
+ ] }, `${l.key}-${a}`)) })
2661
+ ] });
2662
+ }
2663
+ function _(t, e, n = "") {
2664
+ const r = t?.properties?.[e];
2665
+ return r != null ? String(r) : n;
2666
+ }
2667
+ function Vt(t) {
2668
+ const e = {
2669
+ lifecycle: "draft",
2670
+ isTracked: !1,
2671
+ trackBlock: null,
2672
+ approvals: [],
2673
+ signatures: [],
2674
+ isSealed: !1,
2675
+ sealedBy: null,
2676
+ sealedAt: null,
2677
+ sealHash: null,
2678
+ amendments: []
2679
+ };
2680
+ if (!t) return e;
2681
+ const n = t.blocks, r = n.find((c) => c.type === "track");
2682
+ r && (e.isTracked = !0, e.lifecycle = "tracked", e.trackBlock = {
2683
+ id: _(r, "id", r.content ?? ""),
2684
+ by: _(r, "by"),
2685
+ at: _(r, "at")
2686
+ });
2687
+ const o = n.filter((c) => c.type === "approve");
2688
+ for (const c of o)
2689
+ e.approvals.push({
2690
+ by: _(c, "by", c.content ?? ""),
2691
+ role: _(c, "role"),
2692
+ at: _(c, "at"),
2693
+ note: _(c, "note") || void 0
2694
+ });
2695
+ e.approvals.length > 0 && (e.lifecycle = "approved");
2696
+ const l = n.filter((c) => c.type === "sign");
2697
+ for (const c of l)
2698
+ e.signatures.push({
2699
+ by: _(c, "by", c.content ?? ""),
2700
+ role: _(c, "role"),
2701
+ at: _(c, "at")
2702
+ });
2703
+ e.signatures.length > 0 && (e.lifecycle = "signed");
2704
+ const a = n.find((c) => c.type === "freeze");
2705
+ if (a) {
2706
+ e.isSealed = !0, e.lifecycle = "sealed";
2707
+ const c = e.signatures[e.signatures.length - 1];
2708
+ e.sealedBy = c?.by || _(a, "by", a.content ?? ""), e.sealedAt = _(a, "at") || c?.at || "", e.sealHash = _(a, "hash");
2709
+ }
2710
+ const u = n.filter((c) => c.type === "amendment");
2711
+ for (const c of u)
2712
+ e.amendments.push({
2713
+ section: _(c, "section", c.content ?? ""),
2714
+ was: _(c, "was"),
2715
+ now: _(c, "now"),
2716
+ by: _(c, "by"),
2717
+ ref: _(c, "ref"),
2718
+ at: _(c, "at")
2719
+ });
2720
+ return e;
2721
+ }
2722
+ const Qt = new te("template-highlight"), wt = /\{\{[^}]+\}\}/g;
2723
+ function Zt(t) {
2724
+ const e = [];
2725
+ return t.descendants((n, r) => {
2726
+ if (!n.isText || !n.text) return;
2727
+ wt.lastIndex = 0;
2728
+ let o;
2729
+ for (; o = wt.exec(n.text); )
2730
+ e.push(
2731
+ $t.inline(r + o.index, r + o.index + o[0].length, {
2732
+ class: "it-doc-var"
2733
+ })
2734
+ );
2735
+ }), St.create(t, e);
2736
+ }
2737
+ const vr = vt.create({
2738
+ name: "templateHighlight",
2739
+ addProseMirrorPlugins() {
2740
+ return [
2741
+ new Xt({
2742
+ key: Qt,
2743
+ state: {
2744
+ init: (t, e) => Zt(e.doc),
2745
+ apply: (t, e) => t.docChanged ? Zt(t.doc) : e
2746
+ },
2747
+ props: {
2748
+ decorations(t) {
2749
+ return Qt.getState(t);
2750
+ }
2751
+ }
2752
+ })
2753
+ ];
2754
+ }
2755
+ });
2756
+ function Yr(t) {
2757
+ const e = /* @__PURE__ */ new Set(), n = [];
2758
+ wt.lastIndex = 0;
2759
+ let r;
2760
+ for (; r = wt.exec(t); ) {
2761
+ const o = r[0].slice(2, -2).trim();
2762
+ /^(page|pages|date|time|year)$/i.test(o) || e.has(o) || (e.add(o), n.push(o));
2763
+ }
2764
+ return n;
2765
+ }
2766
+ function Kr(t) {
2767
+ const e = {};
2768
+ for (const n of t) {
2769
+ const r = n.split(".");
2770
+ let o = e;
2771
+ for (let l = 0; l < r.length; l++) {
2772
+ const a = r[l];
2773
+ l === r.length - 1 ? a in o || (o[a] = "") : ((!(a in o) || typeof o[a] != "object" || o[a] === null) && (o[a] = {}), o = o[a]);
2774
+ }
2775
+ }
2776
+ return e;
2777
+ }
2778
+ const Tr = 28, xr = {
2779
+ title: [".it-doc-title"],
2780
+ summary: [".it-doc-summary"],
2781
+ section: [".it-doc-section"],
2782
+ sub: [".it-doc-sub"],
2783
+ text: ["p"],
2784
+ quote: [".it-doc-quote"],
2785
+ callout: [".it-doc-callout"],
2786
+ info: [".it-doc-callout"],
2787
+ table: [".it-doc-table th", ".it-doc-table td"],
2788
+ "table-header": [".it-doc-table th"],
2789
+ metric: [".it-doc-metric"],
2790
+ contact: ['.it-doc-generic[data-keyword="contact"]'],
2791
+ divider: [".it-doc-divider"]
2792
+ };
2793
+ function Ar({
2794
+ value: t,
2795
+ onChange: e,
2796
+ theme: n,
2797
+ onThemeChange: r,
2798
+ readOnly: o = !1,
2799
+ showRibbon: l = !0,
2800
+ showTrustBanner: a = !0,
2801
+ onTrustAction: u
2802
+ }) {
2803
+ const c = P(""), g = P(!1), p = P(!0), [b, f] = B([]), k = P(zt("")), [T, M] = B(1), S = ye({
2804
+ extensions: [
2805
+ bn.configure({
2806
+ geometry: () => k.current,
2807
+ gap: Tr,
2808
+ onPages: M
2809
+ }),
2810
+ Se.configure({
2811
+ heading: !1,
2812
+ codeBlock: !1,
2813
+ blockquote: !1,
2814
+ horizontalRule: !1,
2815
+ // Replaced by ITParagraph (core block props: end/leading/space-…).
2816
+ paragraph: !1
2817
+ }),
2818
+ nr,
2819
+ rr,
2820
+ we.configure({
2821
+ // Professional behavior: a new empty line shows just the cursor.
2822
+ // The hint appears only on a completely empty document.
2823
+ placeholder: ({ editor: m }) => m.isEmpty ? "Start typing..." : ""
2824
+ }),
2825
+ ve,
2826
+ Te,
2827
+ xe,
2828
+ Ae.configure({ multicolor: !0 }),
2829
+ Ce.configure({
2830
+ types: ["paragraph", "itTitle", "itSummary", "itSection", "itSub"]
2831
+ }),
2832
+ Le,
2833
+ un,
2834
+ $e,
2835
+ Ne,
2836
+ In,
2837
+ On,
2838
+ Dn,
2839
+ Fn,
2840
+ jn,
2841
+ Wn,
2842
+ Gn,
2843
+ Un,
2844
+ Kn,
2845
+ Yn,
2846
+ qn,
2847
+ Jn,
2848
+ Vn,
2849
+ Qn,
2850
+ Zn,
2851
+ Xn,
2852
+ vr
2853
+ ],
2854
+ content: Ut(t),
2855
+ onUpdate: ({ editor: m }) => {
2856
+ if (p.current) return;
2857
+ const y = m.getJSON(), x = _n(y);
2858
+ c.current = x, g.current = !0, f(Nn(y)), e(x);
2859
+ },
2860
+ editorProps: {
2861
+ attributes: {
2862
+ class: "docs-page-content",
2863
+ spellcheck: "true"
2864
+ }
2865
+ }
2866
+ });
2867
+ j(() => {
2868
+ const m = window.setTimeout(() => {
2869
+ p.current = !1, c.current = t;
2870
+ }, 0);
2871
+ return () => window.clearTimeout(m);
2872
+ }, []), j(() => {
2873
+ if (S) {
2874
+ if (g.current) {
2875
+ g.current = !1;
2876
+ return;
2877
+ }
2878
+ if (t !== c.current) {
2879
+ const m = Ut(t);
2880
+ S.commands.setContent(m), c.current = t;
2881
+ }
2882
+ }
2883
+ }, [t, S]), j(() => {
2884
+ if (!S) return;
2885
+ const m = (y) => {
2886
+ const x = y.detail;
2887
+ x && S.chain().focus().insertContent(x).run();
2888
+ };
2889
+ return window.addEventListener("it-insert-text", m), () => window.removeEventListener("it-insert-text", m);
2890
+ }, [S]);
2891
+ const v = K(() => zt(t), [t]);
2892
+ j(() => {
2893
+ k.current = v, S?.view.dispatch(S.state.tr);
2894
+ }, [v, S]);
2895
+ const nt = P(null), I = R(() => S ? S.storage.characterCount?.words?.() ?? S.getText().split(/\s+/).filter(Boolean).length : 0, [S]), G = K(() => {
2896
+ if (!n) return "";
2897
+ try {
2898
+ const m = Re(n);
2899
+ return m ? Ee(m).replace(/:root\{/, ".docs-page{") : "";
2900
+ } catch {
2901
+ return "";
2902
+ }
2903
+ }, [n]), U = K(() => {
2904
+ try {
2905
+ const m = tt(t), y = m.blocks.find((W) => W.type === "header")?.content || "", x = m.blocks.find((W) => W.type === "footer")?.content || "", O = m.blocks.find((W) => W.type === "meta"), V = String(O?.properties?.dir || "ltr").toLowerCase();
2906
+ return { header: y, footer: x, dir: V };
2907
+ } catch {
2908
+ return { header: "", footer: "", dir: "ltr" };
2909
+ }
2910
+ }, [t]), F = K(() => {
2911
+ try {
2912
+ return Vt(tt(t));
2913
+ } catch {
2914
+ return Vt(null);
2915
+ }
2916
+ }, [t]), rt = K(() => {
2917
+ if (!F.isSealed) return null;
2918
+ try {
2919
+ return Be(t).intact;
2920
+ } catch {
2921
+ return null;
2922
+ }
2923
+ }, [t, F.isSealed]), N = F.isSealed || o;
2924
+ j(() => {
2925
+ S && S.isEditable !== !N && S.setEditable(!N);
2926
+ }, [S, N]);
2927
+ const H = K(() => {
2928
+ try {
2929
+ return Pe(
2930
+ tt(t),
2931
+ xr,
2932
+ ".docs-page .tiptap "
2933
+ );
2934
+ } catch {
2935
+ return "";
2936
+ }
2937
+ }, [t]);
2938
+ j(() => {
2939
+ let m = document.getElementById(
2940
+ "it-doc-style-rules"
2941
+ );
2942
+ m || (m = document.createElement("style"), m.id = "it-doc-style-rules", document.head.appendChild(m)), m.textContent = H;
2943
+ }, [H]);
2944
+ const ot = R(() => {
2945
+ if (U.dir === "rtl") {
2946
+ const y = t.split(`
2947
+ `).map((x) => {
2948
+ if (/^meta:/i.test(x.trim())) {
2949
+ const O = x.replace(/\s*\|\s*dir:\s*rtl/gi, "").trim();
2950
+ return O === "meta:" ? null : O;
2951
+ }
2952
+ return x;
2953
+ }).filter((x) => x !== null).join(`
2954
+ `);
2955
+ e(y);
2956
+ } else {
2957
+ const y = /^meta:.*$/m.exec(t);
2958
+ y ? e(t.replace(/^meta:.*$/m, `${y[0]} | dir: rtl`)) : /^(title:|summary:)/m.test(t) ? e(
2959
+ t.replace(/^((?:title:|summary:).*)$/m, `$1
2960
+ meta: | dir: rtl`)
2961
+ ) : e(`meta: | dir: rtl
2962
+ ${t}`);
2963
+ }
2964
+ }, [t, e, U.dir]);
2965
+ j(() => {
2966
+ const m = "it-editor-theme-css";
2967
+ let y = document.getElementById(m);
2968
+ y || (y = document.createElement("style"), y.id = m, document.head.appendChild(y)), y.textContent = G;
2969
+ }, [G]);
2970
+ const Y = P(null), [C, st] = B(1), ut = P(C), J = P(null), pt = R(
2971
+ (m) => {
2972
+ const y = Y.current;
2973
+ if (!y) return;
2974
+ const x = y.getBoundingClientRect();
2975
+ J.current = {
2976
+ cx: y.scrollLeft + (m.clientX - x.left),
2977
+ cy: y.scrollTop + (m.clientY - x.top)
2978
+ };
2979
+ },
2980
+ []
2981
+ ), at = R(() => {
2982
+ const m = Y.current;
2983
+ m && (J.current = {
2984
+ cx: m.scrollLeft + m.clientWidth / 2,
2985
+ cy: m.scrollTop + m.clientHeight / 2
2986
+ });
2987
+ }, []);
2988
+ return be(() => {
2989
+ const m = Y.current, y = J.current, x = ut.current;
2990
+ if (!m || !y || x === C) return;
2991
+ const O = C / x;
2992
+ m.getBoundingClientRect();
2993
+ const V = y.cx - m.scrollLeft, W = y.cy - m.scrollTop;
2994
+ m.scrollLeft = y.cx * O - V, m.scrollTop = y.cy * O - W, J.current = null, ut.current = C;
2995
+ }, [C]), j(() => {
2996
+ const m = (y) => {
2997
+ (y.metaKey || y.ctrlKey) && (y.key === "=" || y.key === "+" ? (y.preventDefault(), at(), st((x) => Math.min(2, +(x + 0.1).toFixed(2)))) : y.key === "-" ? (y.preventDefault(), at(), st((x) => Math.max(0.25, +(x - 0.1).toFixed(2)))) : y.key === "0" && (y.preventDefault(), at(), st(1)));
2998
+ };
2999
+ return window.addEventListener("keydown", m), () => window.removeEventListener("keydown", m);
3000
+ }, [at]), j(() => {
3001
+ const m = Y.current;
3002
+ if (!m) return;
3003
+ const y = (x) => {
3004
+ if (x.ctrlKey || x.metaKey) {
3005
+ x.preventDefault();
3006
+ const O = x.deltaY > 0 ? -0.1 : 0.1;
3007
+ pt(x), st((V) => Math.min(2, Math.max(0.25, +(V + O).toFixed(2))));
3008
+ }
3009
+ };
3010
+ return m.addEventListener("wheel", y, { passive: !1 }), () => m.removeEventListener("wheel", y);
3011
+ }, [pt]), /* @__PURE__ */ h("div", { className: "docs-container", children: [
3012
+ l && /* @__PURE__ */ i(
3013
+ yr,
3014
+ {
3015
+ editor: S,
3016
+ isRtl: U.dir === "rtl",
3017
+ onToggleRtl: ot,
3018
+ content: t,
3019
+ theme: n,
3020
+ onThemeChange: r,
3021
+ onTrustAction: u,
3022
+ locked: N
3023
+ }
3024
+ ),
3025
+ a && /* @__PURE__ */ i(kr, { trust: F, intact: rt }),
3026
+ a && /* @__PURE__ */ i(wr, { source: t }),
3027
+ b.length > 0 && /* @__PURE__ */ h("div", { className: "docs-fidelity-warning", role: "status", children: [
3028
+ "⚠ Some formatting (",
3029
+ b.join(", "),
3030
+ ") can’t be saved to",
3031
+ " ",
3032
+ /* @__PURE__ */ i("code", { children: ".it" }),
3033
+ " and won’t appear when printed through the template — remove it or use the toolbar’s color/size/style controls instead."
3034
+ ] }),
3035
+ /* @__PURE__ */ h("div", { className: "docs-canvas", ref: Y, children: [
3036
+ /* @__PURE__ */ i(
3037
+ "div",
3038
+ {
3039
+ className: "docs-page-scaler",
3040
+ style: { width: v.width * C },
3041
+ children: /* @__PURE__ */ i(
3042
+ "div",
3043
+ {
3044
+ className: "docs-page-flow",
3045
+ dir: U.dir,
3046
+ style: {
3047
+ transform: C !== 1 ? `scale(${C})` : void 0,
3048
+ transformOrigin: "top left"
3049
+ },
3050
+ children: /* @__PURE__ */ h(
3051
+ "div",
3052
+ {
3053
+ className: "docs-page docs-sheet",
3054
+ ref: nt,
3055
+ style: {
3056
+ width: v.width,
3057
+ minHeight: v.autoHeight ? v.width : void 0,
3058
+ "--page-mx-l": `${v.marginLeft}px`,
3059
+ "--page-mx-r": `${v.marginRight}px`
3060
+ },
3061
+ children: [
3062
+ /* @__PURE__ */ i(
3063
+ "div",
3064
+ {
3065
+ className: "docs-sheet-header",
3066
+ "data-it-spacer": "",
3067
+ style: { height: v.autoHeight ? void 0 : v.marginTop },
3068
+ children: /* @__PURE__ */ i("div", { className: "docs-pb-header", children: /* @__PURE__ */ i("span", { className: "docs-pb-text", children: v.autoHeight ? "" : ee(v.header, 1, T) }) })
3069
+ }
3070
+ ),
3071
+ /* @__PURE__ */ i(ke, { editor: S })
3072
+ ]
3073
+ }
3074
+ )
3075
+ }
3076
+ )
3077
+ }
3078
+ ),
3079
+ /* @__PURE__ */ h("div", { className: "docs-page-footer", children: [
3080
+ T,
3081
+ " ",
3082
+ T === 1 ? "page" : "pages",
3083
+ " ·",
3084
+ " ",
3085
+ I(),
3086
+ " words",
3087
+ C !== 1 && /* @__PURE__ */ h("span", { className: "zoom-indicator", children: [
3088
+ " ",
3089
+ "· ",
3090
+ Math.round(C * 100),
3091
+ "%"
3092
+ ] })
3093
+ ] })
3094
+ ] })
3095
+ ] });
3096
+ }
3097
+ const Cr = "corporate";
3098
+ function qr({
3099
+ value: t,
3100
+ onChange: e,
3101
+ theme: n,
3102
+ onThemeChange: r,
3103
+ readOnly: o = !1,
3104
+ showRibbon: l = !0,
3105
+ showTrustBanner: a = !0,
3106
+ onTrustAction: u
3107
+ }) {
3108
+ const [c, g] = B(n ?? Cr), p = n ?? c, b = R(
3109
+ (f) => {
3110
+ g(f), r?.(f);
3111
+ },
3112
+ [r]
3113
+ );
3114
+ return /* @__PURE__ */ i(
3115
+ Ar,
3116
+ {
3117
+ value: t,
3118
+ onChange: e,
3119
+ theme: p,
3120
+ onThemeChange: b,
3121
+ readOnly: o,
3122
+ showRibbon: l,
3123
+ showTrustBanner: a,
3124
+ onTrustAction: u
3125
+ }
3126
+ );
3127
+ }
3128
+ export {
3129
+ qr as IntentTextEditor,
3130
+ Kr as buildSampleSkeleton,
3131
+ dr as builtinThemes,
3132
+ _n as docToSource,
3133
+ lr as exportDocumentHTML,
3134
+ cr as exportDocumentPDF,
3135
+ Yr as extractTemplateVariables,
3136
+ Vt as extractTrustState,
3137
+ zt as getPageGeometry,
3138
+ or as printHtmlViaIframe,
3139
+ ee as resolvePageTokens,
3140
+ Ut as sourceToDoc
3141
+ };
3142
+ //# sourceMappingURL=index.mjs.map