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