@w100n/documents 0.15.0 → 0.16.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.cjs CHANGED
@@ -37,11 +37,11 @@ function rove(e) {
37
37
  if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(e.key) || e.altKey || e.metaKey || e.ctrlKey || target.closest('input, textarea, select, [contenteditable="true"]')) return;
38
38
  const pop = target.closest(pops);
39
39
  const list = [...(pop ?? e.currentTarget).querySelectorAll("button:not(:disabled)")].filter((el) => el.closest(pops) === pop);
40
- const at = list.indexOf(target);
41
- if (at < 0) return;
40
+ const at2 = list.indexOf(target);
41
+ if (at2 < 0) return;
42
42
  e.preventDefault();
43
43
  e.stopPropagation();
44
- list[e.key === "Home" ? 0 : e.key === "End" ? list.length - 1 : (at + (e.key === "ArrowRight" ? 1 : -1) + list.length) % list.length].focus();
44
+ list[e.key === "Home" ? 0 : e.key === "End" ? list.length - 1 : (at2 + (e.key === "ArrowRight" ? 1 : -1) + list.length) % list.length].focus();
45
45
  }
46
46
  function useRestore(open) {
47
47
  (0, import_react.useLayoutEffect)(() => {
@@ -98,8 +98,17 @@ var init_text = __esm({
98
98
  retry: "Try again",
99
99
  loading: "Loading",
100
100
  unsupported: "This file cannot be shown yet",
101
+ printLayout: "Print layout",
102
+ cut: "Cut",
103
+ paste: "Paste",
104
+ spellCheck: "Spell check",
105
+ spellHint: "Spelling: right-click again",
101
106
  restore: "Restore this version",
102
107
  restoreFailed: "Could not restore",
108
+ showChanges: "What changed",
109
+ hideChanges: "Back to the version",
110
+ noChanges: "Same text as now",
111
+ changeCount: "Since this version, paragraphs: {added} added, {edited} changed, {removed} removed",
103
112
  allProjects: "All projects",
104
113
  closePanel: "Hide the panel",
105
114
  openPanel: "Show the panel",
@@ -204,7 +213,6 @@ var init_text = __esm({
204
213
  footnote: "Footnote",
205
214
  footnoteText: "Footnote text",
206
215
  formula: "Formula",
207
- formulaHint: "Saved as a Word equation",
208
216
  symbols: "Special characters",
209
217
  symbolSearch: "Search, for example arrow",
210
218
  update: "Update",
@@ -424,8 +432,17 @@ var init_text = __esm({
424
432
  retry: "Spr\xF3buj ponownie",
425
433
  loading: "Wczytywanie",
426
434
  unsupported: "Tego pliku nie da si\u0119 jeszcze pokaza\u0107",
435
+ printLayout: "Uk\u0142ad wydruku",
436
+ cut: "Wytnij",
437
+ paste: "Wklej",
438
+ spellCheck: "Sprawdzanie pisowni",
439
+ spellHint: "Pisownia: kliknij prawym jeszcze raz",
427
440
  restore: "Przywr\xF3\u0107 t\u0119 wersj\u0119",
428
441
  restoreFailed: "Nie uda\u0142o si\u0119 przywr\xF3ci\u0107",
442
+ showChanges: "Co si\u0119 zmieni\u0142o",
443
+ hideChanges: "Wr\xF3\u0107 do wersji",
444
+ noChanges: "Tekst taki sam jak teraz",
445
+ changeCount: "Od tej wersji, akapity: {added} dodane, {edited} zmienione, {removed} usuni\u0119te",
429
446
  allProjects: "Wszystkie projekty",
430
447
  closePanel: "Ukryj panel",
431
448
  openPanel: "Poka\u017C panel",
@@ -530,7 +547,6 @@ var init_text = __esm({
530
547
  footnote: "Przypis",
531
548
  footnoteText: "Tekst przypisu",
532
549
  formula: "Wz\xF3r",
533
- formulaHint: "Zapisany jako r\xF3wnanie Word",
534
550
  symbols: "Znaki specjalne",
535
551
  symbolSearch: "Szukaj, na przyk\u0142ad strza\u0142ka",
536
552
  update: "Zmie\u0144",
@@ -750,8 +766,17 @@ var init_text = __esm({
750
766
  retry: "\u0421\u043F\u0440\u043E\u0431\u0443\u0432\u0430\u0442\u0438 \u0449\u0435",
751
767
  loading: "\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0435\u043D\u043D\u044F",
752
768
  unsupported: "\u0426\u0435\u0439 \u0444\u0430\u0439\u043B \u043F\u043E\u043A\u0438 \u043D\u0435 \u043C\u043E\u0436\u043D\u0430 \u043F\u043E\u043A\u0430\u0437\u0430\u0442\u0438",
769
+ printLayout: "\u0420\u043E\u0437\u043C\u0456\u0442\u043A\u0430 \u0441\u0442\u043E\u0440\u0456\u043D\u043A\u0438",
770
+ cut: "\u0412\u0438\u0440\u0456\u0437\u0430\u0442\u0438",
771
+ paste: "\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u0438",
772
+ spellCheck: "\u041F\u0435\u0440\u0435\u0432\u0456\u0440\u043A\u0430 \u043F\u0440\u0430\u0432\u043E\u043F\u0438\u0441\u0443",
773
+ spellHint: "\u041F\u0440\u0430\u0432\u043E\u043F\u0438\u0441: \u043A\u043B\u0430\u0446\u043D\u0456\u0442\u044C \u043F\u0440\u0430\u0432\u043E\u044E \u0449\u0435 \u0440\u0430\u0437",
753
774
  restore: "\u0412\u0456\u0434\u043D\u043E\u0432\u0438\u0442\u0438 \u0446\u044E \u0432\u0435\u0440\u0441\u0456\u044E",
754
775
  restoreFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u0432\u0456\u0434\u043D\u043E\u0432\u0438\u0442\u0438",
776
+ showChanges: "\u0429\u043E \u0437\u043C\u0456\u043D\u0438\u043B\u043E\u0441\u044C",
777
+ hideChanges: "\u041D\u0430\u0437\u0430\u0434 \u0434\u043E \u0432\u0435\u0440\u0441\u0456\u0457",
778
+ noChanges: "\u0422\u0435\u043A\u0441\u0442 \u0442\u0430\u043A\u0438\u0439 \u0441\u0430\u043C\u0438\u0439, \u044F\u043A \u0437\u0430\u0440\u0430\u0437",
779
+ changeCount: "\u0412\u0456\u0434\u0442\u043E\u0434\u0456 \u0430\u0431\u0437\u0430\u0446\u0456\u0432: {added} \u0434\u043E\u0434\u0430\u043D\u043E, {edited} \u0437\u043C\u0456\u043D\u0435\u043D\u043E, {removed} \u0432\u0438\u0434\u0430\u043B\u0435\u043D\u043E",
755
780
  allProjects: "\u0423\u0441\u0456 \u043F\u0440\u043E\u0454\u043A\u0442\u0438",
756
781
  closePanel: "\u0421\u0445\u043E\u0432\u0430\u0442\u0438 \u043F\u0430\u043D\u0435\u043B\u044C",
757
782
  openPanel: "\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u0438 \u043F\u0430\u043D\u0435\u043B\u044C",
@@ -855,7 +880,6 @@ var init_text = __esm({
855
880
  footnote: "\u0412\u0438\u043D\u043E\u0441\u043A\u0430",
856
881
  footnoteText: "\u0422\u0435\u043A\u0441\u0442 \u0432\u0438\u043D\u043E\u0441\u043A\u0438",
857
882
  formula: "\u0424\u043E\u0440\u043C\u0443\u043B\u0430",
858
- formulaHint: "\u0417\u0431\u0435\u0440\u0456\u0433\u0430\u0454\u0442\u044C\u0441\u044F \u044F\u043A \u0440\u0456\u0432\u043D\u044F\u043D\u043D\u044F Word",
859
883
  symbols: "\u0421\u043F\u0435\u0446\u0441\u0438\u043C\u0432\u043E\u043B\u0438",
860
884
  symbolSearch: "\u041F\u043E\u0448\u0443\u043A, \u043D\u0430\u043F\u0440\u0438\u043A\u043B\u0430\u0434 \u0441\u0442\u0440\u0456\u043B\u043A\u0430",
861
885
  update: "\u0417\u043C\u0456\u043D\u0438\u0442\u0438",
@@ -1296,35 +1320,35 @@ function unzip(buf) {
1296
1320
  while (eocd >= 0 && view.getUint32(eocd, true) !== 101010256) eocd--;
1297
1321
  if (eocd < 0) throw new Error("Not a DOCX file");
1298
1322
  const count = view.getUint16(eocd + 10, true);
1299
- let at = view.getUint32(eocd + 16, true);
1300
- if (count === 65535 || at === 4294967295) throw new Error("ZIP64 DOCX files are not supported");
1323
+ let at2 = view.getUint32(eocd + 16, true);
1324
+ if (count === 65535 || at2 === 4294967295) throw new Error("ZIP64 DOCX files are not supported");
1301
1325
  const names2 = new TextDecoder();
1302
1326
  const out = [];
1303
1327
  for (let n = 0; n < count; n++) {
1304
- if (view.getUint32(at, true) !== 33639248) throw new Error("Broken DOCX file");
1305
- const length = view.getUint16(at + 28, true);
1306
- const extra = view.getUint16(at + 30, true);
1307
- const note = view.getUint16(at + 32, true);
1308
- const local2 = view.getUint32(at + 42, true);
1309
- const csize = view.getUint32(at + 20, true);
1310
- const path = buf.subarray(at + 46, at + 46 + length);
1328
+ if (view.getUint32(at2, true) !== 33639248) throw new Error("Broken DOCX file");
1329
+ const length = view.getUint16(at2 + 28, true);
1330
+ const extra = view.getUint16(at2 + 30, true);
1331
+ const note = view.getUint16(at2 + 32, true);
1332
+ const local2 = view.getUint32(at2 + 42, true);
1333
+ const csize = view.getUint32(at2 + 20, true);
1334
+ const path = buf.subarray(at2 + 46, at2 + 46 + length);
1311
1335
  const begin = local2 + 30 + view.getUint16(local2 + 26, true) + view.getUint16(local2 + 28, true);
1312
1336
  out.push({
1313
1337
  name: names2.decode(path),
1314
1338
  path,
1315
- made: view.getUint16(at + 4, true),
1316
- version: view.getUint16(at + 6, true),
1317
- flags: view.getUint16(at + 8, true),
1318
- method: view.getUint16(at + 10, true),
1319
- time: view.getUint16(at + 12, true),
1320
- date: view.getUint16(at + 14, true),
1321
- crc: view.getUint32(at + 16, true),
1322
- size: view.getUint32(at + 24, true),
1323
- inner: view.getUint16(at + 36, true),
1324
- outer: view.getUint32(at + 38, true),
1339
+ made: view.getUint16(at2 + 4, true),
1340
+ version: view.getUint16(at2 + 6, true),
1341
+ flags: view.getUint16(at2 + 8, true),
1342
+ method: view.getUint16(at2 + 10, true),
1343
+ time: view.getUint16(at2 + 12, true),
1344
+ date: view.getUint16(at2 + 14, true),
1345
+ crc: view.getUint32(at2 + 16, true),
1346
+ size: view.getUint32(at2 + 24, true),
1347
+ inner: view.getUint16(at2 + 36, true),
1348
+ outer: view.getUint32(at2 + 38, true),
1325
1349
  raw: buf.subarray(begin, begin + csize)
1326
1350
  });
1327
- at += 46 + length + extra + note;
1351
+ at2 += 46 + length + extra + note;
1328
1352
  }
1329
1353
  return out;
1330
1354
  }
@@ -1348,49 +1372,49 @@ function zip(entries2) {
1348
1372
  const buf = new Uint8Array(total);
1349
1373
  const view = new DataView(buf.buffer);
1350
1374
  const offsets = [];
1351
- let at = 0;
1375
+ let at2 = 0;
1352
1376
  for (const e of entries2) {
1353
- offsets.push(at);
1354
- view.setUint32(at, 67324752, true);
1355
- view.setUint16(at + 4, e.version, true);
1356
- view.setUint16(at + 6, e.flags & ~8, true);
1357
- view.setUint16(at + 8, e.method, true);
1358
- view.setUint16(at + 10, e.time, true);
1359
- view.setUint16(at + 12, e.date, true);
1360
- view.setUint32(at + 14, e.crc, true);
1361
- view.setUint32(at + 18, e.raw.length, true);
1362
- view.setUint32(at + 22, e.size, true);
1363
- view.setUint16(at + 26, e.path.length, true);
1364
- view.setUint16(at + 28, 0, true);
1365
- buf.set(e.path, at + 30);
1366
- buf.set(e.raw, at + 30 + e.path.length);
1367
- at += 30 + e.path.length + e.raw.length;
1368
- }
1369
- const start = at;
1377
+ offsets.push(at2);
1378
+ view.setUint32(at2, 67324752, true);
1379
+ view.setUint16(at2 + 4, e.version, true);
1380
+ view.setUint16(at2 + 6, e.flags & ~8, true);
1381
+ view.setUint16(at2 + 8, e.method, true);
1382
+ view.setUint16(at2 + 10, e.time, true);
1383
+ view.setUint16(at2 + 12, e.date, true);
1384
+ view.setUint32(at2 + 14, e.crc, true);
1385
+ view.setUint32(at2 + 18, e.raw.length, true);
1386
+ view.setUint32(at2 + 22, e.size, true);
1387
+ view.setUint16(at2 + 26, e.path.length, true);
1388
+ view.setUint16(at2 + 28, 0, true);
1389
+ buf.set(e.path, at2 + 30);
1390
+ buf.set(e.raw, at2 + 30 + e.path.length);
1391
+ at2 += 30 + e.path.length + e.raw.length;
1392
+ }
1393
+ const start = at2;
1370
1394
  entries2.forEach((e, n) => {
1371
- view.setUint32(at, 33639248, true);
1372
- view.setUint16(at + 4, e.made, true);
1373
- view.setUint16(at + 6, e.version, true);
1374
- view.setUint16(at + 8, e.flags & ~8, true);
1375
- view.setUint16(at + 10, e.method, true);
1376
- view.setUint16(at + 12, e.time, true);
1377
- view.setUint16(at + 14, e.date, true);
1378
- view.setUint32(at + 16, e.crc, true);
1379
- view.setUint32(at + 20, e.raw.length, true);
1380
- view.setUint32(at + 24, e.size, true);
1381
- view.setUint16(at + 28, e.path.length, true);
1382
- view.setUint16(at + 36, e.inner, true);
1383
- view.setUint32(at + 38, e.outer, true);
1384
- view.setUint32(at + 42, offsets[n], true);
1385
- buf.set(e.path, at + 46);
1386
- at += 46 + e.path.length;
1395
+ view.setUint32(at2, 33639248, true);
1396
+ view.setUint16(at2 + 4, e.made, true);
1397
+ view.setUint16(at2 + 6, e.version, true);
1398
+ view.setUint16(at2 + 8, e.flags & ~8, true);
1399
+ view.setUint16(at2 + 10, e.method, true);
1400
+ view.setUint16(at2 + 12, e.time, true);
1401
+ view.setUint16(at2 + 14, e.date, true);
1402
+ view.setUint32(at2 + 16, e.crc, true);
1403
+ view.setUint32(at2 + 20, e.raw.length, true);
1404
+ view.setUint32(at2 + 24, e.size, true);
1405
+ view.setUint16(at2 + 28, e.path.length, true);
1406
+ view.setUint16(at2 + 36, e.inner, true);
1407
+ view.setUint32(at2 + 38, e.outer, true);
1408
+ view.setUint32(at2 + 42, offsets[n], true);
1409
+ buf.set(e.path, at2 + 46);
1410
+ at2 += 46 + e.path.length;
1387
1411
  });
1388
- view.setUint32(at, 101010256, true);
1389
- view.setUint16(at + 8, entries2.length, true);
1390
- view.setUint16(at + 10, entries2.length, true);
1391
- view.setUint32(at + 12, at - start, true);
1392
- view.setUint32(at + 16, start, true);
1393
- return buf.subarray(0, at + 22);
1412
+ view.setUint32(at2, 101010256, true);
1413
+ view.setUint16(at2 + 8, entries2.length, true);
1414
+ view.setUint16(at2 + 10, entries2.length, true);
1415
+ view.setUint32(at2 + 12, at2 - start, true);
1416
+ view.setUint32(at2 + 16, start, true);
1417
+ return buf.subarray(0, at2 + 22);
1394
1418
  }
1395
1419
  var import_fflate, table;
1396
1420
  var init_zip = __esm({
@@ -2432,21 +2456,21 @@ var init_read = __esm({
2432
2456
  out.push({ text: null, raw: s.slice(k.start, k.end), run: null, ctx, span: null, box: true });
2433
2457
  } else {
2434
2458
  const content = kid(k, "w:sdtContent");
2435
- const inside = [];
2436
- if (content) this.walk(content.kids, ctx, content, inside, { lock: null, task: false, box: false });
2437
- this.span(s.slice(k.start, k.end), inside, out, ctx, null);
2459
+ const inside2 = [];
2460
+ if (content) this.walk(content.kids, ctx, content, inside2, { lock: null, task: false, box: false });
2461
+ this.span(s.slice(k.start, k.end), inside2, out, ctx, null);
2438
2462
  }
2439
2463
  } else if (name === "w:fldSimple") {
2440
- const inside = [];
2441
- this.walk(k.kids, ctx, k, inside, { lock: null, task: false, box: false });
2442
- this.span(s.slice(k.start, k.end), inside, out, ctx, hyperlink(attr(s, k, "w:instr") ?? ""));
2464
+ const inside2 = [];
2465
+ this.walk(k.kids, ctx, k, inside2, { lock: null, task: false, box: false });
2466
+ this.span(s.slice(k.start, k.end), inside2, out, ctx, hyperlink(attr(s, k, "w:instr") ?? ""));
2443
2467
  } else if (name === "m:oMath") out.push({ text: "\uE000", raw: s.slice(k.start, k.end), run: null, ctx, span: null, math: latexOf(s.slice(k.start, k.end)) });
2444
2468
  else if (name === "m:oMathPara") st.lock = "Equation";
2445
2469
  else out.push({ text: null, raw: s.slice(k.start, k.end), run: null, ctx, span: null });
2446
2470
  }
2447
2471
  }
2448
- span(xml, inside, out, ctx, link) {
2449
- const shown = inside.filter((p) => p.text !== null);
2472
+ span(xml, inside2, out, ctx, link) {
2473
+ const shown = inside2.filter((p) => p.text !== null);
2450
2474
  if (!shown.length) {
2451
2475
  out.push({ text: null, raw: xml, run: null, ctx, span: null });
2452
2476
  return;
@@ -2623,13 +2647,13 @@ var init_read = __esm({
2623
2647
  let vm = vmEl ? vmVal === "restart" ? "restart" : "continue" : null;
2624
2648
  if (vm === "continue" && !open[col]) vm = null;
2625
2649
  const cref = this.ref();
2626
- const inside = this.blocks(tc);
2627
- const cell2 = { ref: cref, el: tc, lead: s.slice(last2, tc.start), col, span: span2, vm, blocks: inside.list, tail: s.slice(inside.tail, tc.close), node: null };
2650
+ const inside2 = this.blocks(tc);
2651
+ const cell2 = { ref: cref, el: tc, lead: s.slice(last2, tc.start), col, span: span2, vm, blocks: inside2.list, tail: s.slice(inside2.tail, tc.close), node: null };
2628
2652
  last2 = tc.end;
2629
2653
  this.refs.set(cref, cell2);
2630
2654
  if (vm === "continue") open[col].attrs.rowspan++;
2631
2655
  else {
2632
- const content = assemble(inside.list);
2656
+ const content = assemble(inside2.list);
2633
2657
  const own = widths.slice(col, col + span2);
2634
2658
  const shd = tcPr && kid(tcPr, "w:shd");
2635
2659
  const fill3 = shd ? attr(s, shd, "w:fill") : null;
@@ -2681,10 +2705,10 @@ function diff(a, b) {
2681
2705
  if (x >= n && y >= m) {
2682
2706
  for (let e = d; e > 0; e--) {
2683
2707
  const t = trace[e];
2684
- const at = (j) => t[j + e + 1];
2685
- const down2 = k === -e || k !== e && at(k - 1) < at(k + 1);
2708
+ const at2 = (j) => t[j + e + 1];
2709
+ const down2 = k === -e || k !== e && at2(k - 1) < at2(k + 1);
2686
2710
  const pk = down2 ? k + 1 : k - 1;
2687
- const px2 = at(pk);
2711
+ const px2 = at2(pk);
2688
2712
  const py = px2 - pk;
2689
2713
  while (x > px2 && y > py) map[p + --y] = p + --x;
2690
2714
  x = px2;
@@ -2838,10 +2862,10 @@ function checked(xml, on2) {
2838
2862
  const no = /w14:uncheckedState\b[^>]*w14:val="([0-9A-Fa-f]+)"/.exec(xml)?.[1] ?? "2610";
2839
2863
  const [from, to] = on2 ? [no, yes] : [yes, no];
2840
2864
  let out = /<w14:checked\b/.test(xml) ? xml.replace(/(<w14:checked\b[^>]*w14:val=")[^"]*"/, `$1${on2 ? 1 : 0}"`) : xml.replace(/(<w14:checkbox\b[^>]*>)/, `$1<w14:checked w14:val="${on2 ? 1 : 0}"/>`);
2841
- const at = out.indexOf("<w:sdtContent");
2842
- if (at === -1) return out;
2843
- const tail = out.slice(at).replace(new RegExp(`w:char="${from}"`, "i"), `w:char="${to}"`).replace(`>${String.fromCharCode(parseInt(from, 16))}<`, `>${String.fromCharCode(parseInt(to, 16))}<`);
2844
- out = out.slice(0, at) + tail;
2865
+ const at2 = out.indexOf("<w:sdtContent");
2866
+ if (at2 === -1) return out;
2867
+ const tail = out.slice(at2).replace(new RegExp(`w:char="${from}"`, "i"), `w:char="${to}"`).replace(`>${String.fromCharCode(parseInt(from, 16))}<`, `>${String.fromCharCode(parseInt(to, 16))}<`);
2868
+ out = out.slice(0, at2) + tail;
2845
2869
  return out;
2846
2870
  }
2847
2871
  async function fetched(src) {
@@ -2952,9 +2976,9 @@ var init_write = __esm({
2952
2976
  <w:numbering xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"></w:numbering>`;
2953
2977
  this.types.add(`<Override PartName="/${path}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"/>`);
2954
2978
  }
2955
- const at = n.search(/<w:num\b[\s>]/);
2979
+ const at2 = n.search(/<w:num\b[\s>]/);
2956
2980
  const abs = this.numbering.abs.join("");
2957
- n = at === -1 ? n.replace(/(<w:numIdMacAtCleanup\b|<\/w:numbering>)/, abs + "$1") : n.slice(0, at) + abs + n.slice(at);
2981
+ n = at2 === -1 ? n.replace(/(<w:numIdMacAtCleanup\b|<\/w:numbering>)/, abs + "$1") : n.slice(0, at2) + abs + n.slice(at2);
2958
2982
  n = n.replace(/(<w:numIdMacAtCleanup\b|<\/w:numbering>)/, this.numbering.nums.join("") + "$1");
2959
2983
  changed2.set(path, n);
2960
2984
  if (!rel) {
@@ -2967,8 +2991,8 @@ var init_write = __esm({
2967
2991
  const settings = this.tocs && this.pkg.byType("/settings");
2968
2992
  const listed2 = settings && this.pkg.text(settings.target);
2969
2993
  if (settings && listed2 && !/<w:updateFields\b/.test(listed2)) {
2970
- const at = listed2.search(/<(?:w:hdrShapeDefaults|w:footnotePr|w:endnotePr|w:compat|w:docVars|w:rsids|m:mathPr|w:attachedSchema|w:themeFontLang|w:clrSchemeMapping|w:doNotIncludeSubdocsInStats|w:doNotAutoCompressPictures|w:forceUpgrade|w:captions|w:readModeInkLockDown|w:smartTagType|sl:schemaLibrary|w:shapeDefaults|w:doNotEmbedSmartTags|w:decimalSymbol|w:listSeparator)\b|<\/w:settings>/);
2971
- changed2.set(settings.target, listed2.slice(0, at) + '<w:updateFields w:val="true"/>' + listed2.slice(at));
2994
+ const at2 = listed2.search(/<(?:w:hdrShapeDefaults|w:footnotePr|w:endnotePr|w:compat|w:docVars|w:rsids|m:mathPr|w:attachedSchema|w:themeFontLang|w:clrSchemeMapping|w:doNotIncludeSubdocsInStats|w:doNotAutoCompressPictures|w:forceUpgrade|w:captions|w:readModeInkLockDown|w:smartTagType|sl:schemaLibrary|w:shapeDefaults|w:doNotEmbedSmartTags|w:decimalSymbol|w:listSeparator)\b|<\/w:settings>/);
2995
+ changed2.set(settings.target, listed2.slice(0, at2) + '<w:updateFields w:val="true"/>' + listed2.slice(at2));
2972
2996
  }
2973
2997
  if (this.styleXml.length) {
2974
2998
  const rel = this.pkg.byType("/styles");
@@ -3068,20 +3092,20 @@ var init_write = __esm({
3068
3092
  return ++this.lastNote;
3069
3093
  }
3070
3094
  footnotes(doc, changed2) {
3071
- const notes2 = [];
3095
+ const notes3 = [];
3072
3096
  const walk = (n) => {
3073
- if (n.type === "footnote" && n.attrs?.id) notes2.push({ id: String(n.attrs.id), text: String(n.attrs.text ?? "") });
3097
+ if (n.type === "footnote" && n.attrs?.id) notes3.push({ id: String(n.attrs.id), text: String(n.attrs.text ?? "") });
3074
3098
  n.content?.forEach(walk);
3075
3099
  };
3076
3100
  walk(doc);
3077
3101
  const rel = this.pkg.byType("/footnotes");
3078
3102
  const old = rel ? this.pkg.text(rel.target) : null;
3079
- if (!notes2.length) return;
3103
+ if (!notes3.length) return;
3080
3104
  const path = rel ? rel.target : "word/footnotes.xml";
3081
3105
  let xml = old ?? `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3082
3106
  <w:footnotes xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="${REL}"><w:footnote w:type="separator" w:id="-1"><w:p><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:r><w:separator/></w:r></w:p></w:footnote><w:footnote w:type="continuationSeparator" w:id="0"><w:p><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:r><w:continuationSeparator/></w:r></w:p></w:footnote></w:footnotes>`;
3083
- const fresh2 = (id, words2) => `<w:footnote w:id="${id}"><w:p><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:r><w:rPr><w:vertAlign w:val="superscript"/></w:rPr><w:footnoteRef/></w:r><w:r><w:rPr><w:sz w:val="20"/></w:rPr><w:t xml:space="preserve"> ${escape2(words2)}</w:t></w:r></w:p></w:footnote>`;
3084
- for (const n of notes2) {
3107
+ const fresh2 = (id, words3) => `<w:footnote w:id="${id}"><w:p><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:r><w:rPr><w:vertAlign w:val="superscript"/></w:rPr><w:footnoteRef/></w:r><w:r><w:rPr><w:sz w:val="20"/></w:rPr><w:t xml:space="preserve"> ${escape2(words3)}</w:t></w:r></w:p></w:footnote>`;
3108
+ for (const n of notes3) {
3085
3109
  const found = new RegExp(`<w:footnote\\b[^>]*\\bw:id="${n.id}"[^>]*>([\\s\\S]*?)</w:footnote>`).exec(xml);
3086
3110
  if (found && noteText(found[1]) === n.text) continue;
3087
3111
  xml = found ? xml.replace(found[0], fresh2(n.id, n.text)) : xml.replace(/<\/w:footnotes>\s*$/, fresh2(n.id, n.text) + "</w:footnotes>");
@@ -3128,8 +3152,8 @@ var init_write = __esm({
3128
3152
  sec = sec.replace(re, xml);
3129
3153
  return;
3130
3154
  }
3131
- const at = before.map((b) => sec.search(new RegExp(`<${b}[\\s>/]`))).filter((i2) => i2 >= 0);
3132
- const i = at.length ? Math.min(...at) : sec.lastIndexOf("</w:sectPr>");
3155
+ const at2 = before.map((b) => sec.search(new RegExp(`<${b}[\\s>/]`))).filter((i2) => i2 >= 0);
3156
+ const i = at2.length ? Math.min(...at2) : sec.lastIndexOf("</w:sectPr>");
3133
3157
  sec = sec.slice(0, i) + xml + sec.slice(i);
3134
3158
  };
3135
3159
  const tw = (px2) => Math.round(px2 * 15);
@@ -3155,11 +3179,11 @@ var init_write = __esm({
3155
3179
  const open = sec.indexOf(">") + 1;
3156
3180
  sec = sec.slice(0, open) + `<w:${kind}Reference w:type="default" r:id="${id}"/>` + sec.slice(open);
3157
3181
  };
3158
- const line = (words2, page) => {
3182
+ const line = (words3, page) => {
3159
3183
  const field = '<w:r><w:fldChar w:fldCharType="begin"/></w:r><w:r><w:instrText xml:space="preserve"> PAGE </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate"/></w:r><w:r><w:t>1</w:t></w:r><w:r><w:fldChar w:fldCharType="end"/></w:r>';
3160
- const run3 = words2 ? `<w:r><w:t xml:space="preserve">${escape2(words2)}</w:t></w:r>` : "";
3161
- if (!words2 && !page) return "";
3162
- return `<w:p><w:pPr>${page && words2 ? `<w:tabs><w:tab w:val="right" w:pos="${this.textWidth()}"/></w:tabs>` : page ? '<w:jc w:val="right"/>' : ""}</w:pPr>${run3}${page && words2 ? "<w:r><w:tab/></w:r>" : ""}${page ? field : ""}</w:p>`;
3184
+ const run3 = words3 ? `<w:r><w:t xml:space="preserve">${escape2(words3)}</w:t></w:r>` : "";
3185
+ if (!words3 && !page) return "";
3186
+ return `<w:p><w:pPr>${page && words3 ? `<w:tabs><w:tab w:val="right" w:pos="${this.textWidth()}"/></w:tabs>` : page ? '<w:jc w:val="right"/>' : ""}</w:pPr>${run3}${page && words3 ? "<w:r><w:tab/></w:r>" : ""}${page ? field : ""}</w:p>`;
3163
3187
  };
3164
3188
  if (setup.header !== void 0) part("header", line(setup.header, false));
3165
3189
  if (setup.footer !== void 0 || setup.numbers !== void 0) part("footer", line(setup.footer ?? "", !!setup.numbers));
@@ -3394,11 +3418,11 @@ var init_write = __esm({
3394
3418
  }
3395
3419
  const slot = new Int32Array(A.length + 1);
3396
3420
  for (let k = 1; k <= A.length; k++) slot[k] = back[k - 1] >= 0 ? back[k - 1] + 1 : slot[k - 1];
3397
- const at = Array.from({ length: B.length + 1 }, () => []);
3421
+ const at2 = Array.from({ length: B.length + 1 }, () => []);
3398
3422
  let chars = 0;
3399
3423
  for (const u of units) {
3400
3424
  if (u.ch !== null) chars++;
3401
- else if (!u.box || o.task !== null) at[slot[chars]].push(u);
3425
+ else if (!u.box || o.task !== null) at2[slot[chars]].push(u);
3402
3426
  }
3403
3427
  const paraBase = b ? this.markRun(b) : this.firstRun(src);
3404
3428
  const out = [];
@@ -3412,7 +3436,7 @@ var init_write = __esm({
3412
3436
  const next = new Int32Array(B.length + 1).fill(-1);
3413
3437
  for (let k = B.length - 1; k >= 0; k--) next[k] = map[k] >= 0 ? map[k] : next[k + 1];
3414
3438
  for (let j = 0; j <= B.length; j++) {
3415
- for (const u of at[j]) out.push({ ch: null, raw: u.box && !u.run && b && b.task !== o.task ? checked(u.raw, !!o.task) : u.raw, run: u.run, ctx: u.ctx, u, fmt: u.fmt });
3439
+ for (const u of at2[j]) out.push({ ch: null, raw: u.box && !u.run && b && b.task !== o.task ? checked(u.raw, !!o.task) : u.raw, run: u.run, ctx: u.ctx, u, fmt: u.fmt });
3416
3440
  if (j === B.length) break;
3417
3441
  const i = map[j];
3418
3442
  const want = B[j];
@@ -3431,8 +3455,10 @@ var init_write = __esm({
3431
3455
  }
3432
3456
  if (want.note) {
3433
3457
  const u = i >= 0 ? A[i] : null;
3434
- if (u?.note && u.note.id === want.note.id) out.push({ ch: u.ch, raw: u.raw, run: u.run, ctx: u.ctx, u, fmt: u.fmt });
3435
- else {
3458
+ if (u?.note && (u.note.id === want.note.id || !want.note.id)) {
3459
+ want.note.id = u.note.id;
3460
+ out.push({ ch: u.ch, raw: u.raw, run: u.run, ctx: u.ctx, u, fmt: u.fmt });
3461
+ } else {
3436
3462
  want.note.id = typeof want.note.id === "string" && want.note.id ? want.note.id : String(this.noteId());
3437
3463
  out.push({ ch: want.ch, raw: `<w:footnoteReference w:id="${want.note.id}"/>`, run: { open: "<w:r>", rPr: '<w:rPr><w:vertAlign w:val="superscript"/></w:rPr>', fmt: plain, el: null, parent: null }, ctx: [], u: null, fmt: plain });
3438
3464
  }
@@ -3511,8 +3537,8 @@ var init_write = __esm({
3511
3537
  wrap = { open: tag, close: "</w:hyperlink>", link, ins: false };
3512
3538
  this.wraps.set(link, wrap);
3513
3539
  }
3514
- const at = out.findIndex((w) => w.ins);
3515
- return at === -1 ? [...out, wrap] : [...out.slice(0, at), wrap, ...out.slice(at)];
3540
+ const at2 = out.findIndex((w) => w.ins);
3541
+ return at2 === -1 ? [...out, wrap] : [...out.slice(0, at2), wrap, ...out.slice(at2)];
3516
3542
  }
3517
3543
  revised(ctx, rev) {
3518
3544
  const out = ctx.filter((w) => !w.rev || w.rev === rev);
@@ -3711,8 +3737,8 @@ var init_write = __esm({
3711
3737
  head2 = opened(s, b.el) + s.slice(b.el.open, first ? first.el.start - first.lead.length : b.el.close);
3712
3738
  if (last2) tail = s.slice(last2.el.end, b.el.close);
3713
3739
  if (b.cols && cols !== b.cols) {
3714
- head2 = head2.replace(/(<w:tblGrid\b[^>]*>)([\s\S]*?)(<\/w:tblGrid>)/, (_, open, inside, close) => {
3715
- const list = [...inside.match(/<w:gridCol\b[^>]*\/>/g) ?? []];
3740
+ head2 = head2.replace(/(<w:tblGrid\b[^>]*>)([\s\S]*?)(<\/w:tblGrid>)/, (_, open, inside2, close) => {
3741
+ const list = [...inside2.match(/<w:gridCol\b[^>]*\/>/g) ?? []];
3716
3742
  while (list.length < cols) list.push(list[list.length - 1] ?? "<w:gridCol/>");
3717
3743
  return open + list.slice(0, cols).join("") + close;
3718
3744
  });
@@ -3791,9 +3817,9 @@ var init_write = __esm({
3791
3817
  continue;
3792
3818
  }
3793
3819
  const fallback = srcCell?.blocks.find((x) => x.kind === "p") ?? null;
3794
- let inside = this.container(flatten(sl.cell.content ?? []), C ? C.blocks : [], fallback) + (C ? this.left.get(C) ?? "" : "");
3795
- if (!this.last || this.last === "tbl") inside += "<w:p/>";
3796
- xml += (C ? C.lead + opened(s, C.el) : "<w:tc>") + this.tcPr(srcCell, sl.span, vm, width, !C, own(sl.col, sl.span), value("background", sl.cell.attrs?.background)) + inside + (C ? C.tail : "") + "</w:tc>";
3820
+ let inside2 = this.container(flatten(sl.cell.content ?? []), C ? C.blocks : [], fallback) + (C ? this.left.get(C) ?? "" : "");
3821
+ if (!this.last || this.last === "tbl") inside2 += "<w:p/>";
3822
+ xml += (C ? C.lead + opened(s, C.el) : "<w:tc>") + this.tcPr(srcCell, sl.span, vm, width, !C, own(sl.col, sl.span), value("background", sl.cell.attrs?.background)) + inside2 + (C ? C.tail : "") + "</w:tc>";
3797
3823
  }
3798
3824
  const lastCell = R2?.cells[R2.cells.length - 1];
3799
3825
  xml += (R2 && lastCell ? s.slice(lastCell.el.end, R2.el.close) : "") + "</w:tr>";
@@ -3833,14 +3859,14 @@ async function readDocx(bytes) {
3833
3859
  const size2 = sect && kid(sect, "w:pgSz");
3834
3860
  const mar = sect && kid(sect, "w:pgMar");
3835
3861
  const px2 = (el, name, fallback) => Math.round(Math.abs(+((el && attr(s, el, name)) ?? fallback)) / 15 * 100) / 100;
3836
- const words2 = (kind) => {
3862
+ const words3 = (kind) => {
3837
3863
  const ref = sect?.kids.find((k) => k.name === `w:${kind}Reference` && attr(s, k, "w:type") === "default");
3838
3864
  const part = ref && pkg.rels.get(attr(s, ref, "r:id") ?? "");
3839
3865
  const xml = part ? pkg.text(part.target) ?? "" : "";
3840
3866
  return { text: [...xml.matchAll(/<w:t(?:\s[^>]*)?>([^<]*)<\/w:t>/g)].map((m) => m[1]).join("").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").trim(), page: /\bPAGE\b/.test(xml) };
3841
3867
  };
3842
- const head2 = words2("header");
3843
- const foot = words2("footer");
3868
+ const head2 = words3("header");
3869
+ const foot = words3("footer");
3844
3870
  return {
3845
3871
  marginal: { header: head2.text, footer: foot.page ? foot.text.replace(/\s*\d+$/, "") : foot.text, numbers: foot.page },
3846
3872
  doc: { type: "doc", content: content.length ? content : [{ type: "paragraph", attrs: { align: null, indent: 0, ref: null } }] },
@@ -3933,7 +3959,7 @@ function measure(view) {
3933
3959
  const gaps = [];
3934
3960
  const line = page.width - page.margins[1] - page.margins[3];
3935
3961
  const area = (list) => list.length ? 14 + list.reduce((h, text) => h + 15 * Math.max(1, Math.ceil(text.length * 5.6 / line)), 0) : 0;
3936
- let notes2 = [];
3962
+ let notes3 = [];
3937
3963
  let count = 0;
3938
3964
  let i = 0;
3939
3965
  let shift = 0;
@@ -3953,20 +3979,20 @@ function measure(view) {
3953
3979
  if (d.type.name === "footnote") mine.push(`${count + mine.length + 1} ${d.attrs.text}`);
3954
3980
  });
3955
3981
  if (node.type.name === "pageBreak") {
3956
- gaps.push({ pos: offset + node.nodeSize, height: start + room - end + bottom + 24 + top, page: gaps.length + 1, notes: notes2 });
3957
- notes2 = [];
3982
+ gaps.push({ pos: offset + node.nodeSize, height: start + room - end + bottom + 24 + top, page: gaps.length + 1, notes: notes3 });
3983
+ notes3 = [];
3958
3984
  start = end;
3959
- } else if (end > start + room - area([...notes2, ...mine]) && y > start) {
3960
- gaps.push({ pos: offset, height: start + room - y + bottom + 24 + top, page: gaps.length + 1, notes: notes2 });
3961
- notes2 = [];
3985
+ } else if (end > start + room - area([...notes3, ...mine]) && y > start) {
3986
+ gaps.push({ pos: offset, height: start + room - y + bottom + 24 + top, page: gaps.length + 1, notes: notes3 });
3987
+ notes3 = [];
3962
3988
  start = y;
3963
3989
  }
3964
- notes2.push(...mine);
3990
+ notes3.push(...mine);
3965
3991
  count += mine.length;
3966
3992
  while (end > start + room) start += room;
3967
3993
  last2 = end;
3968
3994
  });
3969
- gaps.push({ pos: view.state.doc.content.size, height: Math.max(0, start + room - last2), page: gaps.length + 1, end: true, notes: notes2 });
3995
+ gaps.push({ pos: view.state.doc.content.size, height: Math.max(0, start + room - last2), page: gaps.length + 1, end: true, notes: notes3 });
3970
3996
  return gaps.map((g) => ({ ...g, height: Math.max(0, Math.round(g.height)) }));
3971
3997
  }
3972
3998
  var import_core, import_state, import_view, a4, letter, paging, skip2, Pager;
@@ -3985,10 +4011,10 @@ var init_pager = __esm({
3985
4011
  addProseMirrorPlugins: () => [new import_state.Plugin({
3986
4012
  key: paging,
3987
4013
  state: {
3988
- init: () => ({ set: import_view.DecorationSet.empty, page: a4, marks: { header: "", footer: "" } }),
4014
+ init: () => ({ set: import_view.DecorationSet.empty, page: a4, marks: { header: "", footer: "" }, flow: false }),
3989
4015
  apply(tr, value3) {
3990
4016
  const next = tr.getMeta(paging);
3991
- return { set: next?.set ?? value3.set.map(tr.mapping, tr.doc), page: next?.page ?? value3.page, marks: next?.marks ?? value3.marks };
4017
+ return { set: next?.set ?? value3.set.map(tr.mapping, tr.doc), page: next?.page ?? value3.page, marks: next?.marks ?? value3.marks, flow: next?.flow ?? value3.flow };
3992
4018
  }
3993
4019
  },
3994
4020
  props: { decorations: (state) => paging.getState(state).set },
@@ -3997,8 +4023,13 @@ var init_pager = __esm({
3997
4023
  let sig2 = "";
3998
4024
  const run3 = () => {
3999
4025
  if (!view.dom.isConnected) return;
4026
+ const { marks: marks2, flow } = paging.getState(view.state);
4027
+ if (flow) {
4028
+ if (sig2 !== "flow") view.dispatch(view.state.tr.setMeta(paging, { set: import_view.DecorationSet.empty }).setMeta("addToHistory", false));
4029
+ sig2 = "flow";
4030
+ return;
4031
+ }
4000
4032
  const gaps = measure(view);
4001
- const { marks: marks2 } = paging.getState(view.state);
4002
4033
  const next = gaps.map((g) => `${g.pos}:${g.height}:${g.notes.join("\n")}`).join() + `|${marks2.header}|${marks2.footer}`;
4003
4034
  if (next === sig2) return;
4004
4035
  sig2 = next;
@@ -4049,7 +4080,8 @@ var init_pager = __esm({
4049
4080
  later(0);
4050
4081
  return {
4051
4082
  update: (next, prev) => {
4052
- if (paging.getState(next.state).page !== paging.getState(prev).page || paging.getState(next.state).marks !== paging.getState(prev).marks) later(0);
4083
+ const now = paging.getState(next.state), was = paging.getState(prev);
4084
+ if (now.page !== was.page || now.marks !== was.marks || now.flow !== was.flow) later(0);
4053
4085
  else if (next.state.doc !== prev.doc) later(400);
4054
4086
  },
4055
4087
  destroy: () => {
@@ -4118,7 +4150,10 @@ function kit(kind, t, live) {
4118
4150
  Toc.configure({ relative: kind === "markdown", label: t.toc, empty: t.tocEmpty }),
4119
4151
  Note,
4120
4152
  Notes,
4121
- ...kind === "docx" ? [Formula, Footnote, Pager, Locks.configure({ label: t.locked }), revision("insertion", "ins"), revision("deletion", "del"), Suggest] : [],
4153
+ Formula,
4154
+ Footnote,
4155
+ EndNotes,
4156
+ ...kind === "docx" ? [Pager, Locks.configure({ label: t.locked }), revision("insertion", "ins"), revision("deletion", "del"), Suggest] : [],
4122
4157
  ...live ? [import_extension_collaboration.default.configure({ document: live.doc }), import_extension_collaboration_caret.default.configure({ provider: live.link, user: live.user })] : []
4123
4158
  ];
4124
4159
  }
@@ -4141,8 +4176,8 @@ function locate(doc, list) {
4141
4176
  if (line) doc.descendants((node, pos) => {
4142
4177
  if (hit) return false;
4143
4178
  if (!node.isTextblock) return true;
4144
- const at = node.textBetween(0, node.content.size, void 0, "\uFFFC").indexOf(line);
4145
- if (at >= 0) hit = { from: pos + 1 + at, to: pos + 1 + at + line.length };
4179
+ const at2 = node.textBetween(0, node.content.size, void 0, "\uFFFC").indexOf(line);
4180
+ if (at2 >= 0) hit = { from: pos + 1 + at2, to: pos + 1 + at2 + line.length };
4146
4181
  return false;
4147
4182
  });
4148
4183
  return hit;
@@ -4161,7 +4196,7 @@ function locate(doc, list) {
4161
4196
  return range ? [{ id: c.id, from: range.from, to: range.to }] : [];
4162
4197
  });
4163
4198
  }
4164
- var import_core2, import_extension_collaboration, import_extension_collaboration_caret, import_extension_highlight, import_extension_image, import_extension_list, import_extension_table, import_extension_text_style, import_state2, import_transform, import_view2, import_starter_kit, import_y_tiptap, notes, blocks, changed, Cells, searching, lookup, Search2, replace, cleanPaste, Blocks, PageBreak, Formula, Footnote, headings, Toc, revision, seen, suggesting, Suggest, Note, locks, locked, scan, Locks, paint, remap, Notes, script, textblocks, align2, spacing, indent, clear;
4199
+ var import_core2, import_extension_collaboration, import_extension_collaboration_caret, import_extension_highlight, import_extension_image, import_extension_list, import_extension_table, import_extension_text_style, import_state2, import_transform, import_view2, import_starter_kit, import_y_tiptap, notes, blocks, changed, Cells, searching, lookup, Search2, replace, cleanPaste, Blocks, PageBreak, Formula, Footnote, EndNotes, headings, Toc, revision, seen, suggesting, Suggest, Note, locks, locked, scan, Locks, paint, remap, Notes, script, textblocks, align2, spacing, indent, clear;
4165
4200
  var init_extensions = __esm({
4166
4201
  "src/editor/extensions.ts"() {
4167
4202
  "use strict";
@@ -4225,14 +4260,14 @@ var init_extensions = __esm({
4225
4260
  doc.descendants((node, pos) => {
4226
4261
  if (!node.isTextblock) return true;
4227
4262
  let text = "";
4228
- const at = [];
4263
+ const at2 = [];
4229
4264
  node.forEach((child, offset) => {
4230
4265
  const part = child.isText ? child.text : "\uFFFC";
4231
- for (let i = 0; i < part.length; i++) at.push(pos + 1 + offset + i);
4266
+ for (let i = 0; i < part.length; i++) at2.push(pos + 1 + offset + i);
4232
4267
  text += part;
4233
4268
  });
4234
4269
  const hay = matchCase ? text : text.toLowerCase();
4235
- for (let i = hay.indexOf(needle); i >= 0; i = hay.indexOf(needle, i + needle.length)) hits.push({ from: at[i], to: at[i + needle.length - 1] + 1 });
4270
+ for (let i = hay.indexOf(needle); i >= 0; i = hay.indexOf(needle, i + needle.length)) hits.push({ from: at2[i], to: at2[i + needle.length - 1] + 1 });
4236
4271
  return false;
4237
4272
  });
4238
4273
  return hits;
@@ -4248,18 +4283,18 @@ var init_extensions = __esm({
4248
4283
  if (!meta2 && !tr.docChanged) return value3;
4249
4284
  const next = { ...value3, ...meta2 };
4250
4285
  const hits = lookup(tr.doc, next.query, next.matchCase);
4251
- const at = hits.length ? (next.at % hits.length + hits.length) % hits.length : 0;
4252
- return { ...next, hits, at, set: import_view2.DecorationSet.create(tr.doc, hits.map((h, i) => import_view2.Decoration.inline(h.from, h.to, { class: i === at ? "w100n-found is-current" : "w100n-found" }))) };
4286
+ const at2 = hits.length ? (next.at % hits.length + hits.length) % hits.length : 0;
4287
+ return { ...next, hits, at: at2, set: import_view2.DecorationSet.create(tr.doc, hits.map((h, i) => import_view2.Decoration.inline(h.from, h.to, { class: i === at2 ? "w100n-found is-current" : "w100n-found" }))) };
4253
4288
  }
4254
4289
  },
4255
4290
  props: { decorations: (state) => searching.getState(state).set }
4256
4291
  })]
4257
4292
  });
4258
4293
  replace = (editor, text, all) => {
4259
- const { hits, at } = searching.getState(editor.state);
4294
+ const { hits, at: at2 } = searching.getState(editor.state);
4260
4295
  if (!hits.length) return 0;
4261
4296
  const tr = editor.state.tr;
4262
- for (const hit of all ? [...hits].reverse() : [hits[at]]) tr.insertText(text, hit.from, hit.to);
4297
+ for (const hit of all ? [...hits].reverse() : [hits[at2]]) tr.insertText(text, hit.from, hit.to);
4263
4298
  editor.view.dispatch(tr);
4264
4299
  return all ? hits.length : 1;
4265
4300
  };
@@ -4306,12 +4341,12 @@ var init_extensions = __esm({
4306
4341
  for (let i = start; i < end; i++) {
4307
4342
  const top = state.doc.child(i);
4308
4343
  visit(top, pos);
4309
- top.descendants((node, at) => visit(node, pos + 1 + at));
4344
+ top.descendants((node, at2) => visit(node, pos + 1 + at2));
4310
4345
  pos += top.nodeSize;
4311
4346
  }
4312
4347
  if (!drop2.length) return null;
4313
4348
  const tr = state.tr;
4314
- for (const at of drop2) tr.setNodeAttribute(at, "ref", null);
4349
+ for (const at2 of drop2) tr.setNodeAttribute(at2, "ref", null);
4315
4350
  return tr;
4316
4351
  }
4317
4352
  })]
@@ -4358,6 +4393,31 @@ var init_extensions = __esm({
4358
4393
  parseHTML: () => [{ tag: "sup[data-footnote]" }],
4359
4394
  renderHTML: ({ node }) => ["sup", { "data-footnote": "", "data-note-id": node.attrs.id ?? void 0, title: node.attrs.text, class: "w100n-fn", contenteditable: "false" }]
4360
4395
  });
4396
+ EndNotes = import_core2.Extension.create({
4397
+ name: "endNotes",
4398
+ addProseMirrorPlugins: () => [new import_state2.Plugin({
4399
+ props: {
4400
+ decorations(state) {
4401
+ const notes3 = [];
4402
+ state.doc.descendants((n) => {
4403
+ if (n.type.name === "footnote") notes3.push(n.attrs.text);
4404
+ });
4405
+ if (!notes3.length) return null;
4406
+ return import_view2.DecorationSet.create(state.doc, [import_view2.Decoration.widget(state.doc.content.size, () => {
4407
+ const list = document.createElement("div");
4408
+ list.className = "w100n-text-endnotes";
4409
+ list.contentEditable = "false";
4410
+ notes3.forEach((text, i) => {
4411
+ const p = list.appendChild(document.createElement("p"));
4412
+ p.appendChild(document.createElement("sup")).textContent = String(i + 1);
4413
+ p.append(text);
4414
+ });
4415
+ return list;
4416
+ }, { key: notes3.join("\n"), side: 1, ignoreSelection: true })]);
4417
+ }
4418
+ }
4419
+ })]
4420
+ });
4361
4421
  headings = (doc, after) => {
4362
4422
  const found = [];
4363
4423
  doc.descendants((node, pos) => {
@@ -4383,8 +4443,8 @@ var init_extensions = __esm({
4383
4443
  dom.className = "w100n-text-toc";
4384
4444
  dom.contentEditable = "false";
4385
4445
  const paint2 = () => {
4386
- const at = getPos() ?? 0;
4387
- const list = entries(editor.state.doc, this.options.relative, at);
4446
+ const at2 = getPos() ?? 0;
4447
+ const list = entries(editor.state.doc, this.options.relative, at2);
4388
4448
  const head2 = document.createElement("b");
4389
4449
  head2.textContent = this.options.label;
4390
4450
  const items = list.map(([level, text], i) => {
@@ -4419,13 +4479,13 @@ var init_extensions = __esm({
4419
4479
  return [new import_state2.Plugin({
4420
4480
  appendTransaction(trs, _old, state) {
4421
4481
  if (!trs.some((tr2) => tr2.docChanged && !tr2.getMeta(import_y_tiptap.ySyncPluginKey))) return null;
4422
- const at = [];
4482
+ const at2 = [];
4423
4483
  state.doc.forEach((node, pos) => {
4424
- if (node.type.name === "toc") at.push(pos);
4484
+ if (node.type.name === "toc") at2.push(pos);
4425
4485
  });
4426
- if (!at.length) return null;
4486
+ if (!at2.length) return null;
4427
4487
  const tr = state.tr;
4428
- for (const pos of at) {
4488
+ for (const pos of at2) {
4429
4489
  const fresh2 = JSON.stringify(entries(state.doc, relative2, pos));
4430
4490
  if (state.doc.nodeAt(pos).attrs.entries !== fresh2) tr.setNodeAttribute(pos, "entries", fresh2);
4431
4491
  }
@@ -4469,10 +4529,10 @@ var init_extensions = __esm({
4469
4529
  const { state } = view;
4470
4530
  const tr = state.tr;
4471
4531
  if (to > from) strike(tr, state, from, to);
4472
- const at = tr.mapping.map(to);
4532
+ const at2 = tr.mapping.map(to);
4473
4533
  const kept = (state.storedMarks ?? state.doc.resolve(from).marks()).filter((m) => m.type.name !== "insertion" && m.type.name !== "deletion");
4474
- tr.insert(at, state.schema.text(text, [...kept, stamp(state, "insertion", from, to)]));
4475
- tr.setSelection(import_state2.TextSelection.create(tr.doc, at + text.length));
4534
+ tr.insert(at2, state.schema.text(text, [...kept, stamp(state, "insertion", from, to)]));
4535
+ tr.setSelection(import_state2.TextSelection.create(tr.doc, at2 + text.length));
4476
4536
  view.dispatch(tr.scrollIntoView());
4477
4537
  return true;
4478
4538
  };
@@ -4496,16 +4556,16 @@ var init_extensions = __esm({
4496
4556
  if (!suggesting.getState(state).on || event.key !== "Backspace" && event.key !== "Delete" || event.metaKey || event.ctrlKey || event.altKey) return false;
4497
4557
  const { from, to, empty, $from } = state.selection;
4498
4558
  const back = event.key === "Backspace";
4499
- let at = from;
4559
+ let at2 = from;
4500
4560
  if (empty) {
4501
4561
  const skip3 = (pos) => state.doc.resolve(pos)[back ? "nodeBefore" : "nodeAfter"]?.marks.some((m) => m.type.name === "deletion");
4502
- while (skip3(at)) at += back ? -1 : 1;
4503
- if (back ? at <= $from.start() : at >= $from.end()) return false;
4562
+ while (skip3(at2)) at2 += back ? -1 : 1;
4563
+ if (back ? at2 <= $from.start() : at2 >= $from.end()) return false;
4504
4564
  }
4505
4565
  const tr = state.tr;
4506
- if (empty) strike(tr, state, back ? at - 1 : at, back ? at : at + 1);
4566
+ if (empty) strike(tr, state, back ? at2 - 1 : at2, back ? at2 : at2 + 1);
4507
4567
  else strike(tr, state, from, to);
4508
- const caret = empty ? tr.mapping.map(back ? at - 1 : at + 1, back ? -1 : 1) : tr.mapping.map(back ? from : to);
4568
+ const caret = empty ? tr.mapping.map(back ? at2 - 1 : at2 + 1, back ? -1 : 1) : tr.mapping.map(back ? from : to);
4509
4569
  tr.setSelection(import_state2.TextSelection.create(tr.doc, caret));
4510
4570
  view.dispatch(tr.scrollIntoView());
4511
4571
  return true;
@@ -4577,10 +4637,10 @@ var init_extensions = __esm({
4577
4637
  const { $from, empty } = view.state.selection;
4578
4638
  if (!back && event.key !== "Delete" || !empty || $from.depth < 1) return false;
4579
4639
  if (back ? $from.parentOffset !== 0 : $from.parentOffset !== $from.parent.content.size) return false;
4580
- const at = back ? $from.before() : $from.after();
4581
- const node = back ? view.state.doc.resolve(at).nodeBefore : view.state.doc.resolve(at).nodeAfter;
4640
+ const at2 = back ? $from.before() : $from.after();
4641
+ const node = back ? view.state.doc.resolve(at2).nodeBefore : view.state.doc.resolve(at2).nodeAfter;
4582
4642
  if (!node || !locked(node)) return false;
4583
- view.dispatch(view.state.tr.delete(back ? at - node.nodeSize : at, back ? at : at + node.nodeSize));
4643
+ view.dispatch(view.state.tr.delete(back ? at2 - node.nodeSize : at2, back ? at2 : at2 + node.nodeSize));
4584
4644
  return true;
4585
4645
  }
4586
4646
  }
@@ -4654,7 +4714,7 @@ var init_extensions = __esm({
4654
4714
  var version;
4655
4715
  var init_package = __esm({
4656
4716
  "package.json"() {
4657
- version = "0.15.0";
4717
+ version = "0.16.0";
4658
4718
  }
4659
4719
  });
4660
4720
 
@@ -4679,6 +4739,8 @@ function inline3(tokens = [], outer = []) {
4679
4739
  else if (token2.type === "del") wrap(token2.tokens, { type: "strike" });
4680
4740
  else if (token2.type === "codespan") text(token2.text, [{ type: "code" }]);
4681
4741
  else if (token2.type === "br") out.push({ type: "hardBreak" });
4742
+ else if (token2.type === "math") out.push({ type: "math", attrs: { latex: token2.text } });
4743
+ else if (token2.type === "footnoteRef") out.push({ type: "footnote", attrs: { id: token2.id, text: notes2.get(token2.id) ?? "" } });
4682
4744
  else if (token2.type === "link") wrap(token2.tokens, { type: "link", attrs: { href: token2.href } });
4683
4745
  else if (token2.type === "image") out.push({ type: "image", attrs: { src: token2.href, alt: token2.text || null, title: token2.title || null }, ...marks2().length ? { marks: marks2() } : {} });
4684
4746
  else if (token2.type === "html") {
@@ -4701,7 +4763,15 @@ function block(token2, hints) {
4701
4763
  case "space":
4702
4764
  case "def":
4703
4765
  case "checkbox":
4766
+ case "footnoteDef":
4704
4767
  return [];
4768
+ case "html": {
4769
+ const m = /^\s*<(p|h[1-6])\s+align="(center|right|justify)"\s*>([\s\S]*?)<\/\1>\s*$/i.exec(token2.raw);
4770
+ if (!m) return [{ type: "codeBlock", attrs: { language: "html" }, content: [{ type: "text", text: token2.raw.replace(/\n+$/, "") }] }];
4771
+ const content = inline3(marked.Lexer.lexInline(m[3].trim(), marked.defaults));
4772
+ const level = Number(m[1][1]);
4773
+ return [level ? { type: "heading", attrs: { level, align: m[2] }, content } : { type: "paragraph", attrs: { align: m[2] }, content }];
4774
+ }
4705
4775
  case "heading":
4706
4776
  return [{ type: "heading", attrs: { level: token2.depth }, content: inline3(token2.tokens) }];
4707
4777
  case "paragraph":
@@ -4713,8 +4783,6 @@ function block(token2, hints) {
4713
4783
  const fence = /^ {0,3}(`{3,}|~{3,})/.exec(token2.raw)?.[1][0];
4714
4784
  return [{ type: "codeBlock", attrs: { language: token2.lang || null, ref: fence ? ref({ fence: fence.repeat(3) }) : null }, content: token2.text ? [{ type: "text", text: token2.text }] : [] }];
4715
4785
  }
4716
- case "html":
4717
- return [{ type: "codeBlock", attrs: { language: "html" }, content: [{ type: "text", text: token2.raw.replace(/\n+$/, "") }] }];
4718
4786
  case "hr":
4719
4787
  return [{ type: "horizontalRule" }];
4720
4788
  case "list": {
@@ -4744,6 +4812,21 @@ function block(token2, hints) {
4744
4812
  return [{ type: "paragraph", content: inline3([{ type: "text", raw: token2.raw, text: token2.raw }]) }];
4745
4813
  }
4746
4814
  }
4815
+ function aligned(tokens, i, hints) {
4816
+ const m = tokens[i].type === "html" ? /^\s*<div\s+align="(center|right|justify)"\s*>\s*$/i.exec(tokens[i].raw) : null;
4817
+ if (!m) return null;
4818
+ let j = i + 1;
4819
+ const skip3 = () => {
4820
+ while (tokens[j]?.type === "space") j++;
4821
+ };
4822
+ skip3();
4823
+ const inner2 = tokens[j]?.type === "paragraph" || tokens[j]?.type === "heading" ? tokens[j++] : null;
4824
+ skip3();
4825
+ if (!inner2 || tokens[j]?.type !== "html" || !/^\s*<\/div>\s*$/i.test(tokens[j].raw)) return null;
4826
+ const made2 = block(inner2, hints);
4827
+ made2[0].attrs = { ...made2[0].attrs, align: m[1] };
4828
+ return { end: j, made: made2 };
4829
+ }
4747
4830
  function contents2(tokens, i) {
4748
4831
  if (tokens[i].type !== "html" || !opens.test(tokens[i].raw)) return null;
4749
4832
  let j = i + 1;
@@ -4768,7 +4851,7 @@ function sniff(tokens) {
4768
4851
  style[key2] = value3;
4769
4852
  };
4770
4853
  let loose = 0;
4771
- import_marked.marked.walkTokens(tokens, (token2) => {
4854
+ marked.walkTokens(tokens, (token2) => {
4772
4855
  if (token2.type === "list") {
4773
4856
  const marker = /^\s*(?:([-*+])|\d+([.)]))/.exec(token2.raw);
4774
4857
  if (token2.ordered) note("delim", marker?.[2] ?? ".");
@@ -4785,7 +4868,11 @@ function sniff(tokens) {
4785
4868
  function fromMarkdown(source) {
4786
4869
  const bom = source.startsWith("\uFEFF");
4787
4870
  const crlf = source.includes("\r\n");
4788
- const tokens = import_marked.marked.lexer(source.slice(bom ? 1 : 0).replace(/\r\n?/g, "\n"));
4871
+ const tokens = marked.lexer(source.slice(bom ? 1 : 0).replace(/\r\n?/g, "\n"));
4872
+ notes2 = /* @__PURE__ */ new Map();
4873
+ marked.walkTokens(tokens, (token2) => {
4874
+ if (token2.type === "footnoteDef") notes2.set(token2.id, token2.text);
4875
+ });
4789
4876
  const hints = {};
4790
4877
  const content = [];
4791
4878
  const raws2 = [];
@@ -4793,8 +4880,8 @@ function fromMarkdown(source) {
4793
4880
  let gap = "";
4794
4881
  for (let i = 0; i < tokens.length; i++) {
4795
4882
  const token2 = tokens[i];
4796
- const toc = contents2(tokens, i);
4797
- const made2 = toc ? [{ type: "toc", attrs: { entries: JSON.stringify(toc.entries) } }] : block(token2, hints);
4883
+ const toc = contents2(tokens, i) ?? aligned(tokens, i, hints);
4884
+ const made2 = toc ? "made" in toc ? toc.made : [{ type: "toc", attrs: { entries: JSON.stringify(toc.entries) } }] : block(token2, hints);
4798
4885
  if (!made2.length) {
4799
4886
  gap += token2.raw;
4800
4887
  continue;
@@ -4833,17 +4920,36 @@ function serializer(style, hints, before, cell2 = false) {
4833
4920
  const bullet = hint(node).bullet ?? (run3(parent, index, ["bulletList", "taskList"]) ? style.bullet === "-" ? "*" : "-" : style.bullet);
4834
4921
  tight(state, node, () => state.renderList(node, " ", () => `${bullet} `));
4835
4922
  };
4923
+ const aligned2 = (state, node, render) => {
4924
+ const side2 = cell2 ? null : node.attrs.align;
4925
+ if (side2 && side2 !== "left") {
4926
+ state.write(`<div align="${side2}">`);
4927
+ state.closeBlock(node);
4928
+ }
4929
+ render();
4930
+ state.closeBlock(node);
4931
+ if (side2 && side2 !== "left") {
4932
+ state.write("</div>");
4933
+ state.closeBlock(node);
4934
+ }
4935
+ };
4836
4936
  const blank6 = { open: "", close: "", mixable: true };
4837
4937
  const wrap = (open, close = open) => ({ open, close, mixable: true, expelEnclosingWhitespace: true });
4838
4938
  return new import_prosemirror_markdown.MarkdownSerializer({
4839
4939
  paragraph(state, node) {
4840
- state.renderInline(node);
4841
- state.closeBlock(node);
4940
+ aligned2(state, node, () => state.renderInline(node));
4842
4941
  },
4843
4942
  heading(state, node) {
4844
- state.write(`${"#".repeat(node.attrs.level)} `);
4845
- state.renderInline(node, false);
4846
- state.closeBlock(node);
4943
+ aligned2(state, node, () => {
4944
+ state.write(`${"#".repeat(node.attrs.level)} `);
4945
+ state.renderInline(node, false);
4946
+ });
4947
+ },
4948
+ math(state, node, parent) {
4949
+ state.write(parent.childCount === 1 ? `$$${node.attrs.latex}$$` : `$${node.attrs.latex}$`);
4950
+ },
4951
+ footnote(state, node) {
4952
+ state.write(`[^${node.attrs.id}]`);
4847
4953
  },
4848
4954
  blockquote(state, node) {
4849
4955
  state.wrapBlock("> ", null, node, () => state.renderContent(node));
@@ -4963,31 +5069,66 @@ function toMarkdown(doc, base) {
4963
5069
  nodes.push(node);
4964
5070
  found.push(k);
4965
5071
  });
4966
- let out = base.head;
5072
+ const now = refs(nodes), was = refs(base.nodes);
5073
+ const seen2 = /* @__PURE__ */ new Set();
5074
+ const fix = (text2) => now.size || was.size ? text2.replace(defs, (all, id, note) => {
5075
+ if (!now.has(id)) return was.has(id) ? "" : all;
5076
+ seen2.add(id);
5077
+ return noteOf(note) === now.get(id) ? all : `[^${id}]: ${now.get(id).replace(/\n/g, "\n ")}
5078
+ `;
5079
+ }) : text2;
5080
+ const kept = new Set(found);
5081
+ const lost = base.raws.filter((_, m) => !kept.has(m)).flatMap((raw) => marked.lexer(raw).filter((t) => t.type === "def" || t.type === "footnoteDef").map((t) => t.raw.replace(/\n*$/, "\n"))).join("");
5082
+ let out = fix(base.head);
4967
5083
  const starts = [];
4968
5084
  nodes.forEach((node, i) => {
4969
5085
  const k = found[i];
4970
5086
  if (i && !(k >= 0 && found[i - 1] === k - 1)) out = out.replace(/\n*$/, "\n\n");
4971
5087
  starts.push(out.length);
4972
- out += k >= 0 ? base.raws[k] : one(node, i ? nodes[i - 1] : null, base);
5088
+ out += k >= 0 ? fix(base.raws[k]) : one(node, i ? nodes[i - 1] : null, base);
4973
5089
  });
4974
5090
  const last2 = found[found.length - 1];
4975
5091
  const end = last2 >= 0 && last2 === base.nodes.length - 1;
4976
5092
  if (!end) out = out.replace(/\n*$/, "\n");
4977
5093
  const cut = out.length;
4978
- out += end ? base.tail : base.tail.trim() ? `
4979
- ${base.tail.replace(/^\n+/, "")}` : "";
4980
- const at = starts.map((s) => Math.min(s, cut));
4981
- const raws2 = at.map((s, i) => out.slice(s, i + 1 < at.length ? at[i + 1] : cut));
5094
+ out += fix(end ? base.tail : base.tail.trim() ? `
5095
+ ${base.tail.replace(/^\n+/, "")}` : "");
5096
+ const extra = fix(lost) + [...now].filter(([id]) => !seen2.has(id)).map(([id, note]) => `[^${id}]: ${note.replace(/\n/g, "\n ")}
5097
+ `).join("");
5098
+ if (extra) out = `${out.replace(/\n*$/, "\n\n")}${extra}`;
5099
+ const at2 = starts.map((s) => Math.min(s, cut));
5100
+ const raws2 = at2.map((s, i) => out.slice(s, i + 1 < at2.length ? at2[i + 1] : cut));
4982
5101
  const text = base.crlf ? out.replace(/\n/g, "\r\n") : out;
4983
5102
  return { text: base.bom ? `\uFEFF${text}` : text, base: { ...base, nodes, raws: raws2, tail: out.slice(cut) } };
4984
5103
  }
4985
- var import_marked, import_prosemirror_markdown, tags, decode2, unique, fill, opens, shuts, row, slug, track, ticks, plain2, one;
5104
+ var import_marked, import_prosemirror_markdown, def, defs, noteOf, at, marked, notes2, tags, decode2, unique, fill, opens, shuts, row, slug, track, ticks, plain2, one, refs;
4986
5105
  var init_markdown = __esm({
4987
5106
  "src/editor/markdown.ts"() {
4988
5107
  "use strict";
4989
5108
  import_marked = require("marked");
4990
5109
  import_prosemirror_markdown = require("prosemirror-markdown");
5110
+ def = /^\[\^([^\]\s]+)\]:[ \t]*([^\n]*(?:\n {4}[^\n]*)*)(?:\n|$)/;
5111
+ defs = new RegExp(def.source.slice(1), "gm");
5112
+ noteOf = (text) => text.replace(/\n {4}/g, "\n").trim();
5113
+ at = (src, find3) => {
5114
+ const i = src.search(find3);
5115
+ return i < 0 ? void 0 : i;
5116
+ };
5117
+ marked = new import_marked.Marked({ extensions: [
5118
+ { name: "footnoteDef", level: "block", start: (src) => at(src, /^\[\^/m), tokenizer(src) {
5119
+ const m = def.exec(src);
5120
+ return m ? { type: "footnoteDef", raw: m[0], id: m[1], text: noteOf(m[2]) } : void 0;
5121
+ } },
5122
+ { name: "footnoteRef", level: "inline", start: (src) => at(src, /\[\^/), tokenizer(src) {
5123
+ const m = /^\[\^([^\]\s]+)\]/.exec(src);
5124
+ return m ? { type: "footnoteRef", raw: m[0], id: m[1] } : void 0;
5125
+ } },
5126
+ { name: "math", level: "inline", start: (src) => at(src, /\$/), tokenizer(src) {
5127
+ const m = /^\$\$([^$]+?)\$\$|^\$(?![\s$])((?:\\.|[^$\\\n])*?[^\s\\])\$(?!\d)/.exec(src);
5128
+ return m ? { type: "math", raw: m[0], text: (m[1] ?? m[2]).trim() } : void 0;
5129
+ } }
5130
+ ] });
5131
+ notes2 = /* @__PURE__ */ new Map();
4991
5132
  tags = { u: "underline", ins: "underline", mark: "highlight", s: "strike", del: "strike", b: "bold", strong: "bold", i: "italic", em: "italic" };
4992
5133
  decode2 = (text) => text.includes("&") ? new DOMParser().parseFromString(`<p>${text.replace(/</g, "&lt;")}</p>`, "text/html").body.textContent ?? text : text;
4993
5134
  unique = (marks2) => [...new Map(marks2.map((m) => [m.type, m])).values()];
@@ -5023,12 +5164,19 @@ var init_markdown = __esm({
5023
5164
  return /^[\s(*_~]?$/.test(left) && /^([\s)]|[.,:;!?]+(\s|$)|$)/.test(right) ? "bare" : text === href || href.startsWith("mailto:") ? "angle" : null;
5024
5165
  };
5025
5166
  one = (node, before, base) => serializer(base.style, base.hints, before).serialize(node.type.schema.topNodeType.create(null, node)).replace(/\n+$/, "");
5167
+ refs = (nodes) => {
5168
+ const found = /* @__PURE__ */ new Map();
5169
+ nodes.forEach((n) => n.descendants((d) => {
5170
+ if (d.type.name === "footnote" && d.attrs.id) found.set(d.attrs.id, d.attrs.text);
5171
+ }));
5172
+ return found;
5173
+ };
5026
5174
  }
5027
5175
  });
5028
5176
 
5029
5177
  // src/sheets/model.ts
5030
- function insert(list, at, count, prefix) {
5031
- list.splice(at, 0, ...Array.from({ length: count }, () => fresh(prefix)));
5178
+ function insert(list, at2, count, prefix) {
5179
+ list.splice(at2, 0, ...Array.from({ length: count }, () => fresh(prefix)));
5032
5180
  }
5033
5181
  function move(list, from, count, to) {
5034
5182
  const taken = list.splice(from, count);
@@ -5094,12 +5242,12 @@ function encode(text, encoding, bom) {
5094
5242
  if (encoding === "utf-16le" || encoding === "utf-16be") {
5095
5243
  const out2 = new Uint8Array(text.length * 2 + (bom ? 2 : 0));
5096
5244
  const view = new DataView(out2.buffer);
5097
- let at = 0;
5245
+ let at2 = 0;
5098
5246
  if (bom) {
5099
5247
  view.setUint16(0, 65279, encoding === "utf-16le");
5100
- at = 2;
5248
+ at2 = 2;
5101
5249
  }
5102
- for (let i = 0; i < text.length; i++) view.setUint16(at + i * 2, text.charCodeAt(i), encoding === "utf-16le");
5250
+ for (let i = 0; i < text.length; i++) view.setUint16(at2 + i * 2, text.charCodeAt(i), encoding === "utf-16le");
5103
5251
  return out2;
5104
5252
  }
5105
5253
  const table3 = /* @__PURE__ */ new Map();
@@ -5385,7 +5533,7 @@ function squeeze(b, rows, cols) {
5385
5533
  const r = edge(b.startRow, b.endRow, rows, MAX_ROW), c = edge(b.startColumn, b.endColumn, cols, MAX_COL);
5386
5534
  return r && c ? { startRow: r[0], endRow: r[1], startColumn: c[0], endColumn: c[1] } : null;
5387
5535
  }
5388
- function refs(formula, visit) {
5536
+ function refs2(formula, visit) {
5389
5537
  let sheet2 = null;
5390
5538
  let outside = false;
5391
5539
  let last2 = 0;
@@ -5417,7 +5565,7 @@ function refs(formula, visit) {
5417
5565
  return out + formula.slice(last2);
5418
5566
  }
5419
5567
  function shifted(formula, dr, dc) {
5420
- return refs(formula, (p) => {
5568
+ return refs2(formula, (p) => {
5421
5569
  const ends = p.text.split(":").map(side);
5422
5570
  if (ends.some((e) => !e)) return p.text;
5423
5571
  for (const e of ends) {
@@ -5429,7 +5577,7 @@ function shifted(formula, dr, dc) {
5429
5577
  });
5430
5578
  }
5431
5579
  function remapped(formula, mine, rows, cols) {
5432
- return refs(formula, (p) => {
5580
+ return refs2(formula, (p) => {
5433
5581
  if (!mine(p.sheet)) return p.text;
5434
5582
  const b = box(p.text);
5435
5583
  const ends = p.text.split(":").map(side);
@@ -5831,8 +5979,8 @@ var init_styles = __esm({
5831
5979
  return index;
5832
5980
  }
5833
5981
  add(list, xml) {
5834
- const at = this[list].indexOf(xml);
5835
- if (at >= 0) return at;
5982
+ const at2 = this[list].indexOf(xml);
5983
+ if (at2 >= 0) return at2;
5836
5984
  this[list].push(xml);
5837
5985
  this.added = true;
5838
5986
  return this[list].length - 1;
@@ -5911,8 +6059,8 @@ var init_styles = __esm({
5911
6059
  edits2.push([el.start, el.end, `${open} count="${lists[name].length}">${lists[name].join("")}</${el.name}>`]);
5912
6060
  } else {
5913
6061
  const after = root.kids.find((k) => order2.indexOf(this.bare(k.name)) > order2.indexOf(name));
5914
- const at = after ? after.start : root.close;
5915
- edits2.push([at, at, `<${p}${name} count="${lists[name].length}">${lists[name].join("")}</${p}${name}>`]);
6062
+ const at2 = after ? after.start : root.close;
6063
+ edits2.push([at2, at2, `<${p}${name} count="${lists[name].length}">${lists[name].join("")}</${p}${name}>`]);
5916
6064
  }
5917
6065
  }
5918
6066
  edits2.sort((x, y) => y[0] - x[0]);
@@ -5974,7 +6122,7 @@ function load2(bytes) {
5974
6122
  defaultStyle: styles2.looks[0]
5975
6123
  };
5976
6124
  if (date1904) book.dateSystem = "date1904";
5977
- const notes2 = {};
6125
+ const notes3 = {};
5978
6126
  const validations = {};
5979
6127
  const filters = {};
5980
6128
  const model = { book, lines: {}, origin: { sheets: {}, lines: {} } };
@@ -6038,13 +6186,13 @@ function load2(bytes) {
6038
6186
  let maxRow = -1, maxCol = -1;
6039
6187
  if (open && open.close > open.open) {
6040
6188
  const end = open.close;
6041
- let at = open.open, row2 = -1, col = -1;
6042
- while (at < end) {
6043
- const lt = sxml.indexOf("<", at);
6189
+ let at2 = open.open, row2 = -1, col = -1;
6190
+ while (at2 < end) {
6191
+ const lt = sxml.indexOf("<", at2);
6044
6192
  if (lt < 0 || lt >= end) break;
6045
6193
  const gt = sxml.indexOf(">", lt);
6046
6194
  if (sxml.charCodeAt(lt + 1) === 47) {
6047
- at = gt + 1;
6195
+ at2 = gt + 1;
6048
6196
  continue;
6049
6197
  }
6050
6198
  let j = lt + 1;
@@ -6072,11 +6220,11 @@ function load2(bytes) {
6072
6220
  }
6073
6221
  if (Object.keys(rd).length) rowData[row2] = rd;
6074
6222
  if (rd.h !== void 0 || rd.hd || rd.s) maxRow = Math.max(maxRow, row2);
6075
- at = gt + 1;
6223
+ at2 = gt + 1;
6076
6224
  continue;
6077
6225
  }
6078
6226
  if (name !== "c") {
6079
- at = gt + 1;
6227
+ at2 = gt + 1;
6080
6228
  continue;
6081
6229
  }
6082
6230
  const ref = attr2(tag, "r");
@@ -6140,7 +6288,7 @@ function load2(bytes) {
6140
6288
  }
6141
6289
  }
6142
6290
  cells.set(key(row2, col), { start: lt, end: stop, shared });
6143
- at = stop;
6291
+ at2 = stop;
6144
6292
  }
6145
6293
  }
6146
6294
  for (const [r, c, si] of children) {
@@ -6188,7 +6336,7 @@ function load2(bytes) {
6188
6336
  sheetNotes.push(note);
6189
6337
  const [r, c] = cell(ref);
6190
6338
  if (r < 0) continue;
6191
- ((_b = notes2[sid] ?? (notes2[sid] = {}))[r] ?? (_b[r] = {}))[c] = { note: note.text, width: 160, height: 72, show: false, id: `n${sheetNotes.length - 1}`, row: r, col: c };
6339
+ ((_b = notes3[sid] ?? (notes3[sid] = {}))[r] ?? (_b[r] = {}))[c] = { note: note.text, width: 160, height: 72, show: false, id: `n${sheetNotes.length - 1}`, row: r, col: c };
6192
6340
  maxRow = Math.max(maxRow, r);
6193
6341
  maxCol = Math.max(maxCol, c);
6194
6342
  }
@@ -6245,7 +6393,7 @@ function load2(bytes) {
6245
6393
  }
6246
6394
  const resources = book.resources;
6247
6395
  if (Object.keys(names2).length) resources.push({ name: "SHEET_DEFINED_NAME_PLUGIN", data: JSON.stringify(names2) });
6248
- if (Object.keys(notes2).length) resources.push({ name: "SHEET_NOTE_PLUGIN", data: JSON.stringify(notes2) });
6396
+ if (Object.keys(notes3).length) resources.push({ name: "SHEET_NOTE_PLUGIN", data: JSON.stringify(notes3) });
6249
6397
  if (Object.keys(validations).length) resources.push({ name: "SHEET_DATA_VALIDATION_PLUGIN", data: JSON.stringify(validations) });
6250
6398
  if (Object.keys(filters).length) resources.push({ name: "SHEET_FILTER_PLUGIN", data: JSON.stringify(filters) });
6251
6399
  const shown = entries2[active];
@@ -6373,14 +6521,14 @@ function place(xml, name, value3) {
6373
6521
  if (found) return xml.slice(0, found.start) + (value3 ?? "") + xml.slice(found.end);
6374
6522
  if (value3 === null) return xml;
6375
6523
  const rank = order.indexOf(name);
6376
- let at = -1;
6524
+ let at2 = -1;
6377
6525
  for (const later of order.slice(rank + 1)) {
6378
6526
  const f = find2(xml, later);
6379
- if (f && (at < 0 || f.start < at)) at = f.start;
6527
+ if (f && (at2 < 0 || f.start < at2)) at2 = f.start;
6380
6528
  }
6381
- if (at < 0) at = xml.search(/<\/(?:\w+:)?worksheet>\s*$/);
6382
- if (at < 0) at = xml.length;
6383
- return xml.slice(0, at) + value3 + xml.slice(at);
6529
+ if (at2 < 0) at2 = xml.search(/<\/(?:\w+:)?worksheet>\s*$/);
6530
+ if (at2 < 0) at2 = xml.length;
6531
+ return xml.slice(0, at2) + value3 + xml.slice(at2);
6384
6532
  }
6385
6533
  function remapZone(xml, mine, rows, cols) {
6386
6534
  const ranges = (sqref) => boxes2(sqref).map((b) => squeeze(b, rows.map, cols.map)).filter((b) => b !== null).map(span).join(" ");
@@ -6631,12 +6779,12 @@ function writeXlsx(original, model) {
6631
6779
  tail = place(tail, "autoFilter", filter?.ref ? filterXml(p, filter.ref, filter.filterColumns ?? []) : null);
6632
6780
  filterNames.set(entry2.sheetId, filter?.ref ? `${quoted(sheet2.name)}!${span(filter.ref).split(":").map((s) => s.replace(/([A-Z]+)(\d+)/, "$$$1$$$2")).join(":")}` : null);
6633
6781
  }
6634
- const notes2 = Object.values(curNotes?.[sid] ?? {}).flatMap((line) => Object.values(line ?? {})).filter((n) => n && !blank3(n.note));
6782
+ const notes3 = Object.values(curNotes?.[sid] ?? {}).flatMap((line) => Object.values(line ?? {})).filter((n) => n && !blank3(n.note));
6635
6783
  const oldNotes = (rec?.notes ?? []).map((n) => ({ ref: n.ref, text: n.text }));
6636
- const nowNotes = notes2.map((n) => ({ ref: a1(n.row, n.col), text: n.note })).sort((a, b) => a.ref.localeCompare(b.ref));
6784
+ const nowNotes = notes3.map((n) => ({ ref: a1(n.row, n.col), text: n.note })).sort((a, b) => a.ref.localeCompare(b.ref));
6637
6785
  if (curNotes && !same2(nowNotes, [...oldNotes].sort((a, b) => a.ref.localeCompare(b.ref)))) {
6638
6786
  changed2 = true;
6639
- tail = writeNotes(book, entry2, tail, p, notes2, rows, cols, types2, defaultsNeeded, fresh2);
6787
+ tail = writeNotes(book, entry2, tail, p, notes3, rows, cols, types2, defaultsNeeded, fresh2);
6640
6788
  }
6641
6789
  const rename = (s) => names2.size ? s.replace(/<(xm:f|(?:\w+:)?formula\d?)>([\s\S]*?)<\/\1>/g, (_, n, f) => `<${n}>${escape2([...names2].reduce((g, [from, to]) => renamed(g, from, to), unescape(f)))}</${n}>`) : s;
6642
6790
  if (!changed2) {
@@ -6726,9 +6874,9 @@ function writeXlsx(original, model) {
6726
6874
  listed2.push({ xml: tag, sheetId: s.sheetId, oldIndex: s.rec ? indexOf.get(s.sheetId) : -1 });
6727
6875
  }
6728
6876
  for (const { e, i } of nonSheets) {
6729
- let at = listed2.findIndex((x) => x.oldIndex > i);
6730
- if (at < 0) at = listed2.length;
6731
- listed2.splice(at, 0, { xml: e.xml, sheetId: e.sheetId, oldIndex: i });
6877
+ let at2 = listed2.findIndex((x) => x.oldIndex > i);
6878
+ if (at2 < 0) at2 = listed2.length;
6879
+ listed2.splice(at2, 0, { xml: e.xml, sheetId: e.sheetId, oldIndex: i });
6732
6880
  }
6733
6881
  wb = wb.replace(/(<(?:\w+:)?sheets\b[^>]*>)[\s\S]*?(<\/(?:\w+:)?sheets>)/, (_, a, b) => a + listed2.map((x) => x.xml).join("") + b);
6734
6882
  const newIndex = new Map(listed2.map((x, i) => [x.oldIndex, i]));
@@ -6756,8 +6904,8 @@ function writeXlsx(original, model) {
6756
6904
  });
6757
6905
  for (const [sheetId, f] of filterNames) {
6758
6906
  if (!f) continue;
6759
- const def = `<${wp}definedName name="_xlnm._FilterDatabase" localSheetId="${sheetIndex.get(sheetId)}" hidden="1">${escape2(f)}</${wp}definedName>`;
6760
- wb = /<(?:\w+:)?definedNames\b/.test(wb) ? wb.replace(/<\/(?:\w+:)?definedNames>/, (end) => def + end) : wb.replace(/<\/(?:\w+:)?sheets>/, (end) => `${end}<${wp}definedNames>${def}</${wp}definedNames>`);
6907
+ const def2 = `<${wp}definedName name="_xlnm._FilterDatabase" localSheetId="${sheetIndex.get(sheetId)}" hidden="1">${escape2(f)}</${wp}definedName>`;
6908
+ wb = /<(?:\w+:)?definedNames\b/.test(wb) ? wb.replace(/<\/(?:\w+:)?definedNames>/, (end) => def2 + end) : wb.replace(/<\/(?:\w+:)?sheets>/, (end) => `${end}<${wp}definedNames>${def2}</${wp}definedNames>`);
6761
6909
  }
6762
6910
  wb = wb.replace(/<((?:\w+:)?)definedNames>\s*<\/\1definedNames>/, "");
6763
6911
  wb = wb.replace(/<(?:\w+:)?workbookView\b[^>]*>/g, (tag) => {
@@ -6945,7 +7093,7 @@ function filterXml(p, ref, columns2) {
6945
7093
  }).join("");
6946
7094
  return body ? `<${p}autoFilter ref="${span(ref)}">${body}</${p}autoFilter>` : `<${p}autoFilter ref="${span(ref)}"/>`;
6947
7095
  }
6948
- function writeNotes(book, entry2, tail, p, notes2, rows, cols, types2, defaults, fresh2) {
7096
+ function writeNotes(book, entry2, tail, p, notes3, rows, cols, types2, defaults, fresh2) {
6949
7097
  const { pack } = book;
6950
7098
  const rec = entry2.rec;
6951
7099
  const relsPart = relsOf(entry2.part);
@@ -6972,7 +7120,7 @@ function writeNotes(book, entry2, tail, p, notes2, rows, cols, types2, defaults,
6972
7120
  const [r, c] = cell(n.ref);
6973
7121
  return [a1(rows.map(r), cols.map(c)), n];
6974
7122
  }));
6975
- const list = [...notes2].sort((a, b) => a.row - b.row || a.col - b.col).map((n) => {
7123
+ const list = [...notes3].sort((a, b) => a.row - b.row || a.col - b.col).map((n) => {
6976
7124
  const ref = a1(n.row, n.col);
6977
7125
  const was = byOld.get(ref);
6978
7126
  if (was && was.text === n.note) return setAttr(was.xml.slice(0, was.xml.indexOf(">") + 1), "ref", ref) + was.xml.slice(was.xml.indexOf(">") + 1);
@@ -6993,7 +7141,7 @@ function writeNotes(book, entry2, tail, p, notes2, rows, cols, types2, defaults,
6993
7141
  return "";
6994
7142
  });
6995
7143
  let id = Math.max(1024, ...[...vml2.matchAll(/_x0000_s(\d+)/g)].map((m) => Number(m[1])));
6996
- const out = notes2.map((n) => {
7144
+ const out = notes3.map((n) => {
6997
7145
  const ref = a1(n.row, n.col);
6998
7146
  const was = shapes.get(ref);
6999
7147
  if (was) return was.replace(/<x:Row>\d+<\/x:Row>/, `<x:Row>${n.row}</x:Row>`).replace(/<x:Column>\d+<\/x:Column>/, `<x:Column>${n.col}</x:Column>`).replace(/<x:Anchor>([^<]*)<\/x:Anchor>/, `<x:Anchor>${n.col + 1}, 15, ${n.row}, 2, ${n.col + 3}, 15, ${n.row + 4}, 16</x:Anchor>`);
@@ -7130,7 +7278,7 @@ function made(config, lines2) {
7130
7278
  function fill2(doc, model) {
7131
7279
  const { book: wb, lines: lines2 } = model;
7132
7280
  const book = doc.getMap("book");
7133
- const notes2 = JSON.parse(wb.resources?.find((r) => r.name === "SHEET_NOTE_PLUGIN")?.data ?? "{}");
7281
+ const notes3 = JSON.parse(wb.resources?.find((r) => r.name === "SHEET_NOTE_PLUGIN")?.data ?? "{}");
7134
7282
  doc.transact(() => {
7135
7283
  book.set("head", strip({ id: wb.id, name: wb.name, appVersion: wb.appVersion, locale: wb.locale, defaultStyle: wb.defaultStyle, dateSystem: wb.dateSystem }));
7136
7284
  book.set("extras", (wb.resources ?? []).filter((r) => r.name !== "SHEET_NOTE_PLUGIN"));
@@ -7148,23 +7296,23 @@ function fill2(doc, model) {
7148
7296
  const { cells, rowData, colData, merges, notes: kept } = pieces(sheets.get(sid));
7149
7297
  for (const [r, line] of Object.entries(sheet2.cellData ?? {})) for (const [c, x] of Object.entries(line ?? {})) {
7150
7298
  if (!x) continue;
7151
- const at = spot2(l.rows[+r], l.cols[+c]);
7299
+ const at2 = spot2(l.rows[+r], l.cols[+c]);
7152
7300
  const out = {};
7153
7301
  if (x.f) {
7154
7302
  out.f = x.f;
7155
- values.set(`${sid}:${at}`, { v: x.v ?? null, t: x.t ?? null });
7303
+ values.set(`${sid}:${at2}`, { v: x.v ?? null, t: x.t ?? null });
7156
7304
  } else {
7157
7305
  if (x.v !== void 0 && x.v !== null) out.v = x.v;
7158
7306
  if (x.t) out.t = x.t;
7159
7307
  }
7160
7308
  if (x.p) out.p = x.p;
7161
7309
  if (typeof x.s === "string") out.s = x.s;
7162
- cells.set(at, out);
7310
+ cells.set(at2, out);
7163
7311
  }
7164
7312
  for (const [r, rd] of Object.entries(sheet2.rowData ?? {})) if (rd) rowData.set(l.rows[+r], strip({ h: rd.h, hd: rd.hd, ia: rd.ia, s: typeof rd.s === "string" ? rd.s : void 0 }));
7165
7313
  for (const [c, cd] of Object.entries(sheet2.columnData ?? {})) if (cd) colData.set(l.cols[+c], strip({ w: cd.w, hd: cd.hd, s: typeof cd.s === "string" ? cd.s : void 0 }));
7166
7314
  for (const b of sheet2.mergeData ?? []) merges.set([l.rows[b.startRow], l.cols[b.startColumn], l.rows[b.endRow], l.cols[b.endColumn]].join(":"), 1);
7167
- for (const [r, line] of Object.entries(notes2[sid] ?? {})) for (const [c, n] of Object.entries(line)) kept.set(spot2(l.rows[+r], l.cols[+c]), { note: n.note, width: n.width, height: n.height });
7315
+ for (const [r, line] of Object.entries(notes3[sid] ?? {})) for (const [c, n] of Object.entries(line)) kept.set(spot2(l.rows[+r], l.cols[+c]), { note: n.note, width: n.width, height: n.height });
7168
7316
  }
7169
7317
  });
7170
7318
  }
@@ -7174,11 +7322,11 @@ function sheetOf(doc, sid, l) {
7174
7322
  const { cells, rowData, colData, merges } = pieces(m);
7175
7323
  const rows = new Map(l.rows.map((id, i) => [id, i])), cols = new Map(l.cols.map((id, i) => [id, i]));
7176
7324
  const cellData = {};
7177
- for (const [at, x] of cells) {
7178
- const [row2, col] = at.split(":");
7325
+ for (const [at2, x] of cells) {
7326
+ const [row2, col] = at2.split(":");
7179
7327
  const r = rows.get(row2), c = cols.get(col);
7180
7328
  if (r === void 0 || c === void 0) continue;
7181
- const kept = x.f ? values.get(`${sid}:${at}`) : void 0;
7329
+ const kept = x.f ? values.get(`${sid}:${at2}`) : void 0;
7182
7330
  (cellData[r] ?? (cellData[r] = {}))[c] = kept ? { ...x, v: kept.v, t: kept.t } : { ...x };
7183
7331
  }
7184
7332
  const rowsOut = {}, colsOut = {};
@@ -7194,7 +7342,7 @@ function build(doc) {
7194
7342
  const sheetOrder = [...new Set(order2.toArray())].filter((sid) => sheets.has(sid));
7195
7343
  const wb = { ...book.get("head"), styles: styles2.toJSON(), sheetOrder, sheets: {}, resources: [] };
7196
7344
  const model = { book: wb, lines: {}, origin: { sheets: {}, lines: {} } };
7197
- const notes2 = {};
7345
+ const notes3 = {};
7198
7346
  for (const sid of sheetOrder) {
7199
7347
  const { rows, cols } = pieces(sheets.get(sid));
7200
7348
  const l = { rows: rows.toArray(), cols: cols.toArray() };
@@ -7202,14 +7350,14 @@ function build(doc) {
7202
7350
  wb.sheets[sid] = sheetOf(doc, sid, l);
7203
7351
  notesOf2(sheets.get(sid), l).forEach((n, i) => {
7204
7352
  var _a, _b;
7205
- ((_a = notes2[sid] ?? (notes2[sid] = {}))[_b = n.row] ?? (_a[_b] = {}))[n.col] = { ...n, show: false, id: `n${i}` };
7353
+ ((_a = notes3[sid] ?? (notes3[sid] = {}))[_b = n.row] ?? (_a[_b] = {}))[n.col] = { ...n, show: false, id: `n${i}` };
7206
7354
  });
7207
7355
  const o = origin.get(sid);
7208
7356
  if (!o) continue;
7209
7357
  model.origin.sheets[sid] = o.id;
7210
7358
  model.origin.lines[sid] = { rows: typeof o.rows === "number" ? numbered("r", o.rows) : o.rows, cols: typeof o.cols === "number" ? numbered("c", o.cols) : o.cols };
7211
7359
  }
7212
- wb.resources.push({ name: "SHEET_NOTE_PLUGIN", data: JSON.stringify(notes2) });
7360
+ wb.resources.push({ name: "SHEET_NOTE_PLUGIN", data: JSON.stringify(notes3) });
7213
7361
  const active = book.get("active");
7214
7362
  if (active && sheetOrder.includes(active)) model.active = active;
7215
7363
  return model;
@@ -7291,7 +7439,7 @@ var init_shared = __esm({
7291
7439
  });
7292
7440
  notesOf2 = (m, l) => {
7293
7441
  const rows = new Map(l.rows.map((id, i) => [id, i])), cols = new Map(l.cols.map((id, i) => [id, i]));
7294
- return [...pieces(m).notes].map(([at, n]) => ({ ...n, row: rows.get(at.split(":")[0]), col: cols.get(at.split(":")[1]) })).filter((n) => n.row !== void 0 && n.col !== void 0);
7442
+ return [...pieces(m).notes].map(([at2, n]) => ({ ...n, row: rows.get(at2.split(":")[0]), col: cols.get(at2.split(":")[1]) })).filter((n) => n.row !== void 0 && n.col !== void 0);
7295
7443
  };
7296
7444
  }
7297
7445
  });
@@ -7571,13 +7719,13 @@ async function save(doc, kind, base, put, load3, note) {
7571
7719
  const bytes = await write3(kind, base, node, load3, doc.getMap("setup").size ? doc.getMap("setup").toJSON() : void 0);
7572
7720
  const changed2 = !same3(bytes, base);
7573
7721
  const id = changed2 ? await put(bytes, note ?? named2((texts[who[0].language] ?? texts.en).editedNote, who)) : null;
7574
- const refs2 = [];
7722
+ const refs3 = [];
7575
7723
  if (changed2) schema.nodeFromJSON(await parse4(kind, bytes)).descendants((n) => {
7576
- if (n.isBlock) refs2.push([n.type.name, n.attrs.ref ?? null]);
7724
+ if (n.isBlock) refs3.push([n.type.name, n.attrs.ref ?? null]);
7577
7725
  });
7578
7726
  doc.transact(() => {
7579
- if (refs2.length === list.length && list.every((el, i) => el.nodeName === refs2[i][0])) list.forEach((el, i) => {
7580
- const ref = refs2[i][1];
7727
+ if (refs3.length === list.length && list.every((el, i) => el.nodeName === refs3[i][0])) list.forEach((el, i) => {
7728
+ const ref = refs3[i][1];
7581
7729
  if ((el.getAttribute("ref") ?? null) === ref) return;
7582
7730
  if (ref === null) el.removeAttribute("ref");
7583
7731
  else el.setAttribute("ref", ref);
@@ -7873,12 +8021,17 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
7873
8021
  const scroller = (0, import_react10.useRef)(null);
7874
8022
  const root = (0, import_react10.useRef)(null);
7875
8023
  const [pop, setPop] = (0, import_react10.useState)(null);
8024
+ const [spot3, setSpot] = (0, import_react10.useState)({ x: 0, y: 0 });
8025
+ const touch = (0, import_react10.useRef)(false);
8026
+ const [spell, setSpell] = (0, import_react10.useState)(() => typeof localStorage === "undefined" || localStorage.getItem("w100n-docs-spell") !== "0");
7876
8027
  const [dialog, setDialog] = (0, import_react10.useState)(null);
7877
8028
  const field = (0, import_react10.useRef)(null);
7878
8029
  const [more, setMore] = (0, import_react10.useState)(() => typeof localStorage !== "undefined" && localStorage.getItem("w100n-docs-more") === "1");
7879
8030
  const [zoom, setZoom] = (0, import_react10.useState)(null);
7880
8031
  const [layout2, setLayout] = (0, import_react10.useState)(null);
7881
8032
  const [room, setRoom] = (0, import_react10.useState)(0);
8033
+ const [printed, setPrinted] = (0, import_react10.useState)(null);
8034
+ const flow = docx2 && !(printed ?? !(room > 0 && room < 640));
7882
8035
  const [saving, setSaving] = (0, import_react10.useState)("idle");
7883
8036
  const [href, setHref] = (0, import_react10.useState)("");
7884
8037
  const [grid3, setGrid] = (0, import_react10.useState)({ rows: 0, cols: 0 });
@@ -7909,7 +8062,7 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
7909
8062
  editable: can.edit && (!live || !!shared),
7910
8063
  immediatelyRender: true,
7911
8064
  shouldRerenderOnTransaction: false,
7912
- editorProps: { attributes: { class: "w100n-docs-prose w100n-text-body", "aria-label": t.documentText }, transformPastedHTML: cleanPaste },
8065
+ editorProps: { attributes: { class: "w100n-docs-prose w100n-text-body", "aria-label": t.documentText, spellcheck: String(spell), lang: language }, transformPastedHTML: cleanPaste },
7913
8066
  onCreate: ({ editor: made2 }) => {
7914
8067
  if (source.data && !live) baseline.current = { bytes, doc: made2.state.doc, base: source.data.md && track(source.data.md, made2.state.doc) };
7915
8068
  }
@@ -7948,13 +8101,13 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
7948
8101
  redo: e.can().redo(),
7949
8102
  empty,
7950
8103
  toc: (() => {
7951
- let at = -1;
8104
+ let at2 = -1;
7952
8105
  e.state.doc.forEach((node, pos) => {
7953
- if (at < 0 && node.type.name === "toc") at = pos;
8106
+ if (at2 < 0 && node.type.name === "toc") at2 = pos;
7954
8107
  });
7955
- return at;
8108
+ return at2;
7956
8109
  })(),
7957
- find: (({ at, hits }) => `${at}/${hits.length}`)(searching.getState(e.state)),
8110
+ find: (({ at: at2, hits }) => `${at2}/${hits.length}`)(searching.getState(e.state)),
7958
8111
  suggest: !!suggesting.getState(e.state)?.on,
7959
8112
  revs: docx2 ? changes(e.state.doc) : [],
7960
8113
  dirty: !!baseline.current && !e.state.doc.eq(baseline.current.doc)
@@ -7985,8 +8138,8 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
7985
8138
  };
7986
8139
  const marginal = marg ?? (source.data && "marginal" in source.data ? source.data.marginal : null) ?? { header: "", footer: "", numbers: false };
7987
8140
  (0, import_react10.useEffect)(() => {
7988
- if (editor && docx2 && source.data) editor.view.dispatch(editor.state.tr.setMeta(paging, { page, marks: { header: marginal.header, footer: marginal.footer } }));
7989
- }, [editor, source.data, page, marginal.header, marginal.footer]);
8141
+ if (editor && docx2 && source.data) editor.view.dispatch(editor.state.tr.setMeta(paging, { page, marks: { header: marginal.header, footer: marginal.footer }, flow }));
8142
+ }, [editor, source.data, page, marginal.header, marginal.footer, flow]);
7990
8143
  (0, import_react10.useEffect)(() => {
7991
8144
  if (!shared || !docx2) return;
7992
8145
  const map = shared.doc.getMap("setup");
@@ -8100,6 +8253,18 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8100
8253
  watch.observe(el);
8101
8254
  return () => watch.disconnect();
8102
8255
  }, [editor, source.data]);
8256
+ (0, import_react10.useEffect)(() => {
8257
+ const view = window.visualViewport;
8258
+ const el = root.current;
8259
+ if (!view || !el) return;
8260
+ const lift = () => el.style.setProperty("--kb", `${Math.max(0, innerHeight - view.height - view.offsetTop)}px`);
8261
+ view.addEventListener("resize", lift);
8262
+ view.addEventListener("scroll", lift);
8263
+ return () => {
8264
+ view.removeEventListener("resize", lift);
8265
+ view.removeEventListener("scroll", lift);
8266
+ };
8267
+ }, [editor, source.data]);
8103
8268
  (0, import_react10.useEffect)(() => {
8104
8269
  const el = root.current;
8105
8270
  if (!el) return;
@@ -8129,8 +8294,17 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8129
8294
  const close = (e) => {
8130
8295
  if (!e.target.closest(".w100n-text-pop, [data-pop]")) setPop(null);
8131
8296
  };
8297
+ const off = (e) => {
8298
+ if (pop === "context" && (e.type === "scroll" || e.key === "Escape")) setPop(null);
8299
+ };
8132
8300
  document.addEventListener("pointerdown", close);
8133
- return () => document.removeEventListener("pointerdown", close);
8301
+ window.addEventListener("keydown", off);
8302
+ window.addEventListener("scroll", off, true);
8303
+ return () => {
8304
+ document.removeEventListener("pointerdown", close);
8305
+ window.removeEventListener("keydown", off);
8306
+ window.removeEventListener("scroll", off, true);
8307
+ };
8134
8308
  }, [pop]);
8135
8309
  if (source.error) return docx2 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-docs-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DocxView, { bytes, onOutline, failed: t.failed }) }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-docs-empty", children: t.failed });
8136
8310
  if (!source.data || !editor || !state || live && !live.ready && !live.late && !live.denied) return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-docs-empty", children: t.loading });
@@ -8165,18 +8339,18 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8165
8339
  }
8166
8340
  };
8167
8341
  const renew = (fresh2) => {
8168
- const at = [];
8169
- const refs2 = [];
8342
+ const at2 = [];
8343
+ const refs3 = [];
8170
8344
  editor.state.doc.descendants((node, pos) => {
8171
- if (node.isBlock) at.push(pos);
8345
+ if (node.isBlock) at2.push(pos);
8172
8346
  });
8173
8347
  editor.schema.nodeFromJSON(fresh2).descendants((node) => {
8174
- if (node.isBlock) refs2.push(node.type.name, node.attrs.ref);
8348
+ if (node.isBlock) refs3.push(node.type.name, node.attrs.ref);
8175
8349
  });
8176
- if (refs2.length !== at.length * 2 || at.some((pos, i) => editor.state.doc.nodeAt(pos).type.name !== refs2[i * 2])) return false;
8350
+ if (refs3.length !== at2.length * 2 || at2.some((pos, i) => editor.state.doc.nodeAt(pos).type.name !== refs3[i * 2])) return false;
8177
8351
  const tr = editor.state.tr.setMeta("addToHistory", false);
8178
- at.forEach((pos, i) => {
8179
- if (tr.doc.nodeAt(pos).attrs.ref !== refs2[i * 2 + 1]) tr.setNodeAttribute(pos, "ref", refs2[i * 2 + 1]);
8352
+ at2.forEach((pos, i) => {
8353
+ if (tr.doc.nodeAt(pos).attrs.ref !== refs3[i * 2 + 1]) tr.setNodeAttribute(pos, "ref", refs3[i * 2 + 1]);
8180
8354
  });
8181
8355
  editor.view.dispatch(tr);
8182
8356
  return true;
@@ -8263,10 +8437,10 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8263
8437
  const drops = (c) => mine(c) || c.author.id.startsWith("guest:") && !!rights?.edit;
8264
8438
  const show = (c) => {
8265
8439
  setActive(c.id);
8266
- const spot3 = notes.getState(editor.state).spots.find((s) => s.id === c.id);
8267
- if (!spot3) return;
8268
- const at = editor.view.domAtPos(spot3.from).node;
8269
- (at instanceof HTMLElement ? at : at.parentElement)?.scrollIntoView({ behavior: "smooth", block: "center" });
8440
+ const spot4 = notes.getState(editor.state).spots.find((s) => s.id === c.id);
8441
+ if (!spot4) return;
8442
+ const at2 = editor.view.domAtPos(spot4.from).node;
8443
+ (at2 instanceof HTMLElement ? at2 : at2.parentElement)?.scrollIntoView({ behavior: "smooth", block: "center" });
8270
8444
  };
8271
8445
  const suggested = [...state.revs.reduce((all2, c) => {
8272
8446
  const key2 = `${c.kind}:${c.id}`;
@@ -8274,11 +8448,11 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8274
8448
  all2.set(key2, was ? { ...was, text: `${was.text} ${c.text}` } : c);
8275
8449
  return all2;
8276
8450
  }, /* @__PURE__ */ new Map()).values()];
8277
- const jump = (at) => {
8278
- const dom = editor.view.domAtPos(at).node;
8451
+ const jump = (at2) => {
8452
+ const dom = editor.view.domAtPos(at2).node;
8279
8453
  (dom instanceof HTMLElement ? dom : dom.parentElement)?.scrollIntoView({ behavior: "smooth", block: "center" });
8280
8454
  };
8281
- const percent = zoom ?? (docx2 && room ? Math.max(10, Math.min(100, Math.floor((room - 24) / page.width * 100))) : 100);
8455
+ const percent = zoom ?? (docx2 && room && !flow ? Math.max(10, Math.min(100, Math.floor((room - 24) / page.width * 100))) : 100);
8282
8456
  const zoomBy = (d) => setZoom(Math.min(200, Math.max(30, percent + d)));
8283
8457
  const keys2 = (e) => {
8284
8458
  if (e.defaultPrevented) return;
@@ -8304,7 +8478,7 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8304
8478
  else if (key2 === "]" || key2 === "[") act(() => indent(editor, key2 === "]" ? 1 : -1));
8305
8479
  else if (key2 === "\\") act(() => clear(editor));
8306
8480
  else if (key2 === "enter" && docx2) act(() => editor.chain().focus().insertContent({ type: "pageBreak" }).run());
8307
- else if (e.shiftKey && docx2 && ["l", "e", "r", "j"].includes(key2)) act(() => align2(editor, { l: "left", e: "center", r: "right", j: "justify" }[key2]));
8481
+ else if (e.shiftKey && ["l", "e", "r", "j"].includes(key2)) act(() => align2(editor, { l: "left", e: "center", r: "right", j: "justify" }[key2]));
8308
8482
  };
8309
8483
  const tool = (icon, label, run3, pressed, disabled) => {
8310
8484
  const Icon = icon;
@@ -8351,7 +8525,7 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8351
8525
  }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Trash2, { "aria-hidden": true }) })
8352
8526
  ] })
8353
8527
  ] });
8354
- const words2 = (c) => editing?.id === c.id ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-reply w100n-text-edit", onClick: (e) => e.stopPropagation(), children: [
8528
+ const words3 = (c) => editing?.id === c.id ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-reply w100n-text-edit", onClick: (e) => e.stopPropagation(), children: [
8355
8529
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8356
8530
  "textarea",
8357
8531
  {
@@ -8395,8 +8569,8 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8395
8569
  const mod = /Mac|iPhone|iPad/.test(navigator.platform) ? "\u2318" : "Ctrl+";
8396
8570
  const item = (label, run3, more2 = {}) => ({ label, run: run3, ...more2 });
8397
8571
  const insertToc = () => {
8398
- const at = editor.state.selection.$from.before(1);
8399
- editor.chain().focus().insertContentAt(at, { type: "toc", attrs: { entries: JSON.stringify(entries(editor.state.doc, !docx2, at - 1)) } }).run();
8572
+ const at2 = editor.state.selection.$from.before(1);
8573
+ editor.chain().focus().insertContentAt(at2, { type: "toc", attrs: { entries: JSON.stringify(entries(editor.state.doc, !docx2, at2 - 1)) } }).run();
8400
8574
  };
8401
8575
  const suggest = () => editor.view.dispatch(editor.state.tr.setMeta(suggesting, { on: !state.suggest, me: host?.me.name ?? "" }));
8402
8576
  const aligns = [[import_lucide_react5.AlignLeft, t.alignLeft, "left"], [import_lucide_react5.AlignCenter, t.alignCenter, "center"], [import_lucide_react5.AlignRight, t.alignRight, "right"], [import_lucide_react5.AlignJustify, t.justify, "justify"]];
@@ -8422,9 +8596,13 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8422
8596
  item(t.clearFormat, () => clear(editor), { keys: `${mod}\\` })
8423
8597
  ] : []],
8424
8598
  ["view", t.viewTab, [
8599
+ docx2 && item(t.printLayout, () => {
8600
+ setPrinted(flow);
8601
+ setZoom(null);
8602
+ }, { on: !flow }),
8425
8603
  item(t.zoomIn, () => zoomBy(10)),
8426
8604
  item(t.zoomOut, () => zoomBy(-10)),
8427
- docx2 && item(t.fitWidth, () => setZoom(null), { on: zoom === null }),
8605
+ docx2 && !flow && item(t.fitWidth, () => setZoom(null), { on: zoom === null }),
8428
8606
  item(t.fit, () => setZoom(100)),
8429
8607
  "-",
8430
8608
  item(t.outline, () => onPanel?.("outline")),
@@ -8446,8 +8624,8 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8446
8624
  can.comment && item(t.addComment, begin, { off: state.empty, keys: `${mod}\u2325M` }),
8447
8625
  "-",
8448
8626
  item(t.symbols, () => setDialog({ kind: "symbol", query: "" })),
8449
- docx2 && item(t.formula, () => setDialog({ kind: "formula", latex: "", at: null })),
8450
- docx2 && item(t.footnote, () => setDialog({ kind: "note", text: "", at: null }))
8627
+ item(t.formula, () => setDialog({ kind: "formula", latex: "", at: null })),
8628
+ item(t.footnote, () => setDialog({ kind: "note", text: "", at: null }))
8451
8629
  ] : []],
8452
8630
  ["format", t.menuFormat, can.edit ? [
8453
8631
  ...styles2.map(([key2, label, run3]) => item(label, run3, { on: state.style === key2 })),
@@ -8458,12 +8636,9 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8458
8636
  item(t.strike, () => editor.chain().focus().toggleStrike().run(), { on: state.strike }),
8459
8637
  docx2 && item(t.superscript, () => editor.chain().focus().toggleMark("superscript").run(), { on: state.sup, keys: `${mod}.` }),
8460
8638
  docx2 && item(t.subscript, () => editor.chain().focus().toggleMark("subscript").run(), { on: state.sub, keys: `${mod},` }),
8461
- ...docx2 ? [
8462
- "-",
8463
- ...aligns.map(([, label, value3]) => item(label, () => align2(editor, value3), { on: state.align === value3 })),
8464
- "-",
8465
- ...lines2.map(([v, label]) => item(`${t.lineSpacing}: ${label}`, () => spacing(editor, { line: v }), { on: state.line === v }))
8466
- ] : [],
8639
+ "-",
8640
+ ...aligns.map(([, label, value3]) => item(label, () => align2(editor, value3), { on: state.align === value3 })),
8641
+ ...docx2 ? ["-", ...lines2.map(([v, label]) => item(`${t.lineSpacing}: ${label}`, () => spacing(editor, { line: v }), { on: state.line === v }))] : [],
8467
8642
  "-",
8468
8643
  item(t.bullets, () => editor.chain().focus().toggleBulletList().run(), { on: state.bullets }),
8469
8644
  item(t.numbers, () => editor.chain().focus().toggleOrderedList().run(), { on: state.numbers }),
@@ -8476,19 +8651,55 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8476
8651
  docx2 && can.edit && item(t.suggest, suggest, { on: state.suggest }),
8477
8652
  docx2 && can.edit && state.revs.length > 0 && item(t.acceptAll, () => decide(editor, true)),
8478
8653
  docx2 && can.edit && state.revs.length > 0 && item(t.rejectAll, () => decide(editor, false)),
8479
- !!host?.comments && (can.comment || open.length > 0) && item(t.comments, () => onPanel?.("comments"))
8654
+ !!host?.comments && (can.comment || open.length > 0) && item(t.comments, () => onPanel?.("comments")),
8655
+ can.edit && item(t.spellCheck, () => {
8656
+ editor.view.dom.spellcheck = !spell;
8657
+ localStorage.setItem("w100n-docs-spell", spell ? "0" : "1");
8658
+ setSpell(!spell);
8659
+ }, { on: spell })
8480
8660
  ]]
8481
8661
  ];
8662
+ const clip = (kind2) => {
8663
+ editor.view.focus();
8664
+ document.execCommand(kind2);
8665
+ };
8666
+ const paste = async () => {
8667
+ const found2 = await navigator.clipboard.read().catch(() => []);
8668
+ const html = found2.find((c) => c.types.includes("text/html"));
8669
+ if (html) return editor.view.pasteHTML(await (await html.getType("text/html")).text());
8670
+ const plain4 = found2.find((c) => c.types.includes("text/plain"));
8671
+ if (plain4) editor.view.pasteText(await (await plain4.getType("text/plain")).text());
8672
+ };
8673
+ const table3 = editor.isActive("table");
8674
+ const near = [
8675
+ can.edit && item(t.cut, () => clip("cut"), { off: state.empty, keys: `${mod}X` }),
8676
+ item(t.copy, () => clip("copy"), { off: state.empty, keys: `${mod}C` }),
8677
+ can.edit && !!navigator.clipboard?.read && item(t.paste, () => void paste(), { keys: `${mod}V` }),
8678
+ "-",
8679
+ can.comment && item(t.addComment, begin, { off: state.empty, keys: `${mod}\u2325M` }),
8680
+ can.edit && item(t.link, linkUp, { keys: `${mod}K` }),
8681
+ can.edit && item(t.clearFormat, () => clear(editor), { keys: `${mod}\\` }),
8682
+ ...can.edit && table3 ? [
8683
+ "-",
8684
+ item(t.rowAbove, () => editor.chain().focus().addRowBefore().run()),
8685
+ item(t.rowBelow, () => editor.chain().focus().addRowAfter().run()),
8686
+ item(t.columnLeft, () => editor.chain().focus().addColumnBefore().run()),
8687
+ item(t.columnRight, () => editor.chain().focus().addColumnAfter().run()),
8688
+ item(t.deleteRow, () => editor.chain().focus().deleteRow().run()),
8689
+ item(t.deleteColumn, () => editor.chain().focus().deleteColumn().run())
8690
+ ] : []
8691
+ ];
8692
+ const rows = (list) => list.filter((x) => x !== false).filter((x, i, all2) => x !== "-" || i > 0 && all2[i - 1] !== "-" && i < all2.length - 1).map((x, i) => x === "-" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("hr", {}, i) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", role: x.on === void 0 ? "menuitem" : "menuitemcheckbox", "aria-checked": x.on, disabled: x.off, onClick: () => {
8693
+ setPop(null);
8694
+ x.run();
8695
+ }, children: [
8696
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Check, { "aria-hidden": true }),
8697
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: x.label }),
8698
+ x.keys && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("kbd", { children: x.keys })
8699
+ ] }, i));
8482
8700
  const menu = ([key2, label, list]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
8483
8701
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "w100n-text-menu-button", "data-pop": true, "aria-haspopup": "menu", "aria-expanded": pop === key2, onClick: () => pick(key2), children: label }),
8484
- pop === key2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-text-pop w100n-text-menu", role: "menu", "aria-label": label, children: list.filter((x) => x !== false).map((x, i) => x === "-" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("hr", {}, i) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", role: x.on === void 0 ? "menuitem" : "menuitemcheckbox", "aria-checked": x.on, disabled: x.off, onClick: () => {
8485
- setPop(null);
8486
- x.run();
8487
- }, children: [
8488
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Check, { "aria-hidden": true }),
8489
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: x.label }),
8490
- x.keys && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("kbd", { children: x.keys })
8491
- ] }, i)) })
8702
+ pop === key2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-text-pop w100n-text-menu", role: "menu", "aria-label": label, children: rows(list) })
8492
8703
  ] }, key2);
8493
8704
  const seek = (next) => {
8494
8705
  editor.view.dispatch(editor.state.tr.setMeta(searching, next));
@@ -8695,7 +8906,7 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8695
8906
  pop === "color" && swatches(inks, state.color, (c) => c ? editor.chain().focus().setColor(c).run() : editor.chain().focus().unsetColor().run(), t.automatic)
8696
8907
  ] }),
8697
8908
  gap,
8698
- docx2 && aligner,
8909
+ aligner,
8699
8910
  tool(import_lucide_react5.List, t.bullets, () => editor.chain().focus().toggleBulletList().run(), state.bullets),
8700
8911
  tool(import_lucide_react5.ListOrdered, t.numbers, () => editor.chain().focus().toggleOrderedList().run(), state.numbers),
8701
8912
  !docx2 && tool(import_lucide_react5.ListChecks, t.tasks, () => editor.chain().focus().toggleTaskList().run(), state.tasks),
@@ -8772,17 +8983,17 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8772
8983
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "data-pop": true, "aria-expanded": pop === "table", "aria-label": t.table, title: t.table, onClick: () => pick("table"), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Table, { "aria-hidden": true }) }),
8773
8984
  pop === "table" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-pop w100n-text-grid", role: "group", "aria-label": t.table, onPointerLeave: () => setGrid({ rows: 0, cols: 0 }), children: [
8774
8985
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: Array.from({ length: 48 }, (_, i) => {
8775
- const rows = Math.floor(i / 8) + 1;
8986
+ const rows2 = Math.floor(i / 8) + 1;
8776
8987
  const cols = i % 8 + 1;
8777
8988
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8778
8989
  "button",
8779
8990
  {
8780
8991
  type: "button",
8781
- "aria-label": `${rows} \xD7 ${cols}`,
8782
- "data-on": rows <= grid3.rows && cols <= grid3.cols,
8783
- onPointerEnter: () => setGrid({ rows, cols }),
8992
+ "aria-label": `${rows2} \xD7 ${cols}`,
8993
+ "data-on": rows2 <= grid3.rows && cols <= grid3.cols,
8994
+ onPointerEnter: () => setGrid({ rows: rows2, cols }),
8784
8995
  onClick: () => {
8785
- editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run();
8996
+ editor.chain().focus().insertTable({ rows: rows2, cols, withHeaderRow: true }).run();
8786
8997
  setPop(null);
8787
8998
  }
8788
8999
  },
@@ -8884,20 +9095,34 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8884
9095
  menubar,
8885
9096
  status
8886
9097
  ] }),
8887
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: scroller, className: "w100n-text-scroll", "data-paint": !!paint2, onMouseUp: lay, onClick: (e) => {
9098
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: scroller, className: "w100n-text-scroll", "data-paint": !!paint2, onMouseUp: lay, onPointerDown: (e) => {
9099
+ touch.current = e.pointerType === "touch";
9100
+ }, onContextMenu: (e) => {
9101
+ if (touch.current || e.shiftKey || pop === "context" || !e.target.closest(".ProseMirror")) return setPop(null);
9102
+ e.preventDefault();
9103
+ const at2 = editor.view.posAtCoords({ left: e.clientX, top: e.clientY });
9104
+ const { from, to } = editor.state.selection;
9105
+ if (at2 && (at2.pos < from || at2.pos > to)) editor.commands.setTextSelection(at2.pos);
9106
+ setSpot({ x: Math.min(e.clientX, innerWidth - 260), y: Math.min(e.clientY, innerHeight - 360) });
9107
+ setPop("context");
9108
+ }, onClick: (e) => {
8888
9109
  const atom = can.edit ? e.target.closest(".w100n-math, sup[data-footnote]") : null;
8889
9110
  if (atom) {
8890
- const at = editor.view.posAtDOM(atom, 0);
8891
- const node = editor.state.doc.nodeAt(at);
8892
- if (node?.type.name === "math") setDialog({ kind: "formula", latex: node.attrs.latex, at });
8893
- if (node?.type.name === "footnote") setDialog({ kind: "note", text: node.attrs.text, at });
9111
+ const at2 = editor.view.posAtDOM(atom, 0);
9112
+ const node = editor.state.doc.nodeAt(at2);
9113
+ if (node?.type.name === "math") setDialog({ kind: "formula", latex: node.attrs.latex, at: at2 });
9114
+ if (node?.type.name === "footnote") setDialog({ kind: "note", text: node.attrs.text, at: at2 });
8894
9115
  return;
8895
9116
  }
8896
9117
  const id = e.target.closest("[data-note]")?.getAttribute("data-note");
8897
9118
  if (!id) return;
8898
9119
  setActive(id);
8899
9120
  onPanel?.("comments");
8900
- }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-text-zoomed", style: { zoom: percent / 100 }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: docx2 ? "w100n-text-sheet" : "w100n-docs-page w100n-text-column", style: sheet2, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react9.EditorContent, { editor }) }) }) }),
9121
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-text-zoomed", style: { zoom: percent / 100 }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: docx2 ? `w100n-text-sheet${flow ? " is-flow" : ""}` : "w100n-docs-page w100n-text-column", style: sheet2, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react9.EditorContent, { editor }) }) }) }),
9122
+ pop === "context" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-pop w100n-text-menu w100n-text-context", role: "menu", "aria-label": t.textTools, style: { left: spot3.x, top: spot3.y }, onPointerDown: keep, children: [
9123
+ rows(near),
9124
+ spell && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("small", { className: "w100n-text-hint", children: t.spellHint })
9125
+ ] }),
8901
9126
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-text-ribbon w100n-text-corner", "data-side": "left", onPointerDown: keep, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-tools", role: "group", "aria-label": t.zoom, children: [
8902
9127
  tool(import_lucide_react5.Minus, t.zoomOut, () => zoomBy(-10)),
8903
9128
  zoomer,
@@ -8949,16 +9174,15 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8949
9174
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-new-head", children: [
8950
9175
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-new-tile", "data-tone": "blue", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Sigma, { "aria-hidden": true }) }),
8951
9176
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("b", { className: "w100n-pdf-dialog-title", children: t.formula }),
8952
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-docs-badge", children: t.formulaHint }),
8953
9177
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "w100n-docs-close", onClick: () => setDialog(null), "aria-label": t.close, title: t.close, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.X, { "aria-hidden": true }) })
8954
9178
  ] }),
8955
9179
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { ref: field, autoFocus: true, className: "w100n-insert-latex", value: dialog.latex, "aria-label": t.formula, placeholder: "F = 900 + 12 \\\\cdot n", onChange: (e) => setDialog({ ...dialog, latex: e.target.value }) }),
8956
9180
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-insert-tools", role: "group", "aria-label": t.formula, children: helpers.map(([label, code]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", onClick: () => {
8957
9181
  const el = field.current;
8958
- const at = el.selectionStart ?? dialog.latex.length;
8959
- const latex = dialog.latex.slice(0, at) + code + dialog.latex.slice(el.selectionEnd ?? at);
9182
+ const at2 = el.selectionStart ?? dialog.latex.length;
9183
+ const latex = dialog.latex.slice(0, at2) + code + dialog.latex.slice(el.selectionEnd ?? at2);
8960
9184
  setDialog({ ...dialog, latex });
8961
- const caret = at + (code.indexOf("{}") >= 0 ? code.indexOf("{}") + 1 : code.length);
9185
+ const caret = at2 + (code.indexOf("{}") >= 0 ? code.indexOf("{}") + 1 : code.length);
8962
9186
  requestAnimationFrame(() => {
8963
9187
  el.focus();
8964
9188
  el.setSelectionRange(caret, caret);
@@ -8980,7 +9204,13 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8980
9204
  tr.setNodeAttribute(dialog.at, "text", text);
8981
9205
  return true;
8982
9206
  }).run();
8983
- else editor.chain().focus().insertContent({ type: "footnote", attrs: { id: null, text } }).run();
9207
+ else {
9208
+ let id = 0;
9209
+ editor.state.doc.descendants((n) => {
9210
+ if (n.type.name === "footnote") id = Math.max(id, Number(n.attrs.id) || 0);
9211
+ });
9212
+ editor.chain().focus().insertContent({ type: "footnote", attrs: { id: docx2 ? null : String(id + 1), text } }).run();
9213
+ }
8984
9214
  setDialog(null);
8985
9215
  }, children: [
8986
9216
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-new-head", children: [
@@ -9153,10 +9383,10 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
9153
9383
  threads.map((c) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("article", { className: "w100n-text-card", "aria-current": active === c.id, "data-resolved": c.resolved, onClick: () => show(c), children: [
9154
9384
  person(c),
9155
9385
  c.quote && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("blockquote", { children: c.quote }),
9156
- words2(c),
9386
+ words3(c),
9157
9387
  all.filter((r) => r.replyTo === c.id).map((r) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-reply", children: [
9158
9388
  person(r),
9159
- words2(r)
9389
+ words3(r)
9160
9390
  ] }, r.id)),
9161
9391
  reply?.id === c.id && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-reply", onClick: (e) => e.stopPropagation(), children: [
9162
9392
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
@@ -9353,8 +9583,8 @@ function bind(api, injector, doc, model, edit) {
9353
9583
  const commands = injector.get(import_core4.ICommandService);
9354
9584
  const run3 = (id, params) => commands.hasCommand(id) && commands.syncExecuteCommand(id, { unitId: unit, ...params }, { fromCollab: true });
9355
9585
  const ws = (sid) => wb.getSheetBySheetId(sid);
9356
- const at = /* @__PURE__ */ new Map();
9357
- const index = (sid) => at.get(sid) ?? at.set(sid, { rows: new Map(lines2[sid].rows.map((id, i) => [id, i])), cols: new Map(lines2[sid].cols.map((id, i) => [id, i])) }).get(sid);
9586
+ const at2 = /* @__PURE__ */ new Map();
9587
+ const index = (sid) => at2.get(sid) ?? at2.set(sid, { rows: new Map(lines2[sid].rows.map((id, i) => [id, i])), cols: new Map(lines2[sid].cols.map((id, i) => [id, i])) }).get(sid);
9358
9588
  const live = (sid) => !!sid && !!lines2[sid] && sheets.has(sid) && !!wb.getSheetBySheetId(sid);
9359
9589
  const look = (s) => {
9360
9590
  const style = typeof s === "string" ? looks.get(s) : s;
@@ -9414,7 +9644,7 @@ function bind(api, injector, doc, model, edit) {
9414
9644
  for (const k of [...kept.keys()]) if (!want.has(k)) kept.delete(k);
9415
9645
  for (const k of want) if (!kept.has(k)) kept.set(k, 1);
9416
9646
  };
9417
- const notes2 = (sid) => {
9647
+ const notes3 = (sid) => {
9418
9648
  const l = lines2[sid];
9419
9649
  const { notes: kept } = pieces(sheets.get(sid));
9420
9650
  const want = new Map(api.getWorkbook(unit).getSheetBySheetId(sid).getNotes().map((n) => [spot2(l.rows[n.row], l.cols[n.col]), { note: n.note, width: n.width, height: n.height }]));
@@ -9446,7 +9676,7 @@ function bind(api, injector, doc, model, edit) {
9446
9676
  l.rows.forEach((_, r) => putRow(sid, r));
9447
9677
  l.cols.forEach((_, c) => putCol(sid, c));
9448
9678
  merges(sid);
9449
- notes2(sid);
9679
+ notes3(sid);
9450
9680
  props2.forEach((name) => prop(sid, name));
9451
9681
  };
9452
9682
  const write4 = (id, p) => {
@@ -9458,7 +9688,7 @@ function bind(api, injector, doc, model, edit) {
9458
9688
  return resync(added);
9459
9689
  }
9460
9690
  if (id === "sheet.mutation.remove-sheet" && sid) {
9461
- at.delete(sid);
9691
+ at2.delete(sid);
9462
9692
  sheets.delete(sid);
9463
9693
  const i = order2.toArray().indexOf(sid);
9464
9694
  if (i >= 0) order2.delete(i, 1);
@@ -9482,7 +9712,7 @@ function bind(api, injector, doc, model, edit) {
9482
9712
  const ids = list.slice(from, from + n);
9483
9713
  list.delete(from, n);
9484
9714
  list.insert(to > from ? to - n : to, ids);
9485
- at.delete(sid);
9715
+ at2.delete(sid);
9486
9716
  };
9487
9717
  switch (id) {
9488
9718
  case "sheet.mutation.set-range-values":
@@ -9492,29 +9722,29 @@ function bind(api, injector, doc, model, edit) {
9492
9722
  return;
9493
9723
  case "sheet.mutation.insert-row":
9494
9724
  rows.insert(p.range.startRow, l.rows.slice(p.range.startRow, p.range.endRow + 1));
9495
- at.delete(sid);
9725
+ at2.delete(sid);
9496
9726
  for (let r = p.range.startRow; r <= p.range.endRow; r++) putRow(sid, r);
9497
9727
  return;
9498
9728
  case "sheet.mutation.insert-col":
9499
9729
  cols.insert(p.range.startColumn, l.cols.slice(p.range.startColumn, p.range.endColumn + 1));
9500
- at.delete(sid);
9730
+ at2.delete(sid);
9501
9731
  for (let c = p.range.startColumn; c <= p.range.endColumn; c++) putCol(sid, c);
9502
9732
  return;
9503
9733
  case "sheet.mutation.remove-rows":
9504
- at.delete(sid);
9734
+ at2.delete(sid);
9505
9735
  return rows.delete(p.range.startRow, count(p.range, true));
9506
9736
  case "sheet.mutation.remove-col":
9507
- at.delete(sid);
9737
+ at2.delete(sid);
9508
9738
  return cols.delete(p.range.startColumn, count(p.range, false));
9509
9739
  case "sheet.mutation.move-rows":
9510
9740
  return shift(rows, p.sourceRange.startRow, count(p.sourceRange, true), p.targetRange.startRow);
9511
9741
  case "sheet.mutation.move-columns":
9512
9742
  return shift(cols, p.sourceRange.startColumn, count(p.sourceRange, false), p.targetRange.startColumn);
9513
9743
  case "sheet.mutation.set-worksheet-row-count":
9514
- at.delete(sid);
9744
+ at2.delete(sid);
9515
9745
  return fit(rows, l.rows);
9516
9746
  case "sheet.mutation.set-worksheet-column-count":
9517
- at.delete(sid);
9747
+ at2.delete(sid);
9518
9748
  return fit(cols, l.cols);
9519
9749
  case "sheet.mutation.set-worksheet-row-height":
9520
9750
  case "sheet.mutation.set-worksheet-row-is-auto-height":
@@ -9537,7 +9767,7 @@ function bind(api, injector, doc, model, edit) {
9537
9767
  case "sheet.mutation.update-note":
9538
9768
  case "sheet.mutation.remove-note":
9539
9769
  case "sheet.mutation.update-note-position":
9540
- return notes2(sid);
9770
+ return notes3(sid);
9541
9771
  default: {
9542
9772
  const setter = setters.find((x) => x[1] === id);
9543
9773
  if (setter) prop(sid, setter[0]);
@@ -9643,7 +9873,7 @@ function bind(api, injector, doc, model, edit) {
9643
9873
  }
9644
9874
  run3("sheet.mutation.remove-sheet", { subUnitId: sid });
9645
9875
  delete lines2[sid];
9646
- at.delete(sid);
9876
+ at2.delete(sid);
9647
9877
  }
9648
9878
  want.forEach((sid, i) => {
9649
9879
  if (wb.getSheetBySheetId(sid)) return;
@@ -9680,7 +9910,7 @@ function bind(api, injector, doc, model, edit) {
9680
9910
  i += ids.length;
9681
9911
  }
9682
9912
  }
9683
- at.delete(sid);
9913
+ at2.delete(sid);
9684
9914
  return added;
9685
9915
  };
9686
9916
  const remote = (events, tr) => {
@@ -9901,7 +10131,7 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
9901
10131
  const [pop, setPop] = (0, import_react11.useState)(null);
9902
10132
  const [look, setLook] = (0, import_react11.useState)(null);
9903
10133
  const edit = rights.edit && !!onSaveRequest && (!room || !!shared && !room.readonly);
9904
- const notes2 = !edit && rights.comment && !!onSaveRequest && !room;
10134
+ const notes3 = !edit && rights.comment && !!onSaveRequest && !room;
9905
10135
  (0, import_react11.useEffect)(() => {
9906
10136
  if (waiting2) return;
9907
10137
  let gone = false;
@@ -9936,7 +10166,7 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
9936
10166
  if (model.active) wb.setActiveSheet(model.active);
9937
10167
  if (!edit) wb.setEditable(false);
9938
10168
  const state = { api: api2, model, original: bytes, changes: 0 };
9939
- const untrack = track2(api2, model, { view: true, comment: notes2, edit }, () => {
10169
+ const untrack = track2(api2, model, { view: true, comment: notes3, edit }, () => {
9940
10170
  state.changes++;
9941
10171
  if (state.changes === 1 && !shared) {
9942
10172
  setDirty(true);
@@ -10063,7 +10293,7 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
10063
10293
  if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "s") {
10064
10294
  e.preventDefault();
10065
10295
  e.stopPropagation();
10066
- if (edit || notes2) void save2();
10296
+ if (edit || notes3) void save2();
10067
10297
  }
10068
10298
  if (e.key === "Escape" && pop) {
10069
10299
  e.stopPropagation();
@@ -10236,7 +10466,7 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
10236
10466
  !room && tool(import_lucide_react6.Funnel, t.filter, () => run3("sheet.command.smart-toggle-filter")),
10237
10467
  gap
10238
10468
  ] }),
10239
- (edit || notes2) && tool(import_lucide_react6.StickyNote, t.note, () => run3("sheet.operation.add-note-popup")),
10469
+ (edit || notes3) && tool(import_lucide_react6.StickyNote, t.note, () => run3("sheet.operation.add-note-popup")),
10240
10470
  tool(import_lucide_react6.Search, t.find, () => run3("ui.operation.open-find-dialog"))
10241
10471
  ] }),
10242
10472
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "w100n-sheet-end", children: [
@@ -10245,9 +10475,9 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
10245
10475
  room.denied ? t.liveOff : t.offline
10246
10476
  ] }),
10247
10477
  room && room.people.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "w100n-text-people", role: "group", "aria-label": t.people, children: room.people.map((p) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "w100n-text-face", title: p.me ? `${p.name} (${t.you})` : p.name, style: { "--face": p.color }, children: p.avatarUrl ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("img", { src: p.avatarUrl, alt: "" }) : p.name.split(/\s+/).map((w) => w[0]).join("").slice(0, 2).toUpperCase() }, p.id)) }),
10248
- !edit && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "w100n-docs-badge", children: notes2 ? t.notesOnly : t.viewOnly }),
10478
+ !edit && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "w100n-docs-badge", children: notes3 ? t.notesOnly : t.viewOnly }),
10249
10479
  saving === "failed" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "w100n-sheet-muted", role: "alert", children: refusal ? t.refused[refusal.code].replace("{sheet}", refusal.sheet) : t.saveFailed }),
10250
- (edit || notes2) && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("button", { type: "button", className: "w100n-docs-action", disabled: !pending2 || saving === "busy" || phase !== "ready" || !!room && !room.online, onClick: () => void save2(), children: [
10480
+ (edit || notes3) && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("button", { type: "button", className: "w100n-docs-action", disabled: !pending2 || saving === "busy" || phase !== "ready" || !!room && !room.online, onClick: () => void save2(), children: [
10251
10481
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react6.Save, { "aria-hidden": true }),
10252
10482
  saving === "busy" ? t.saving : !pending2 && saving === "done" ? t.saved : t.save
10253
10483
  ] })
@@ -10295,6 +10525,101 @@ var init_SheetView = __esm({
10295
10525
  }
10296
10526
  });
10297
10527
 
10528
+ // src/Compare.tsx
10529
+ var Compare_exports = {};
10530
+ __export(Compare_exports, {
10531
+ changes: () => changes2,
10532
+ default: () => Compare,
10533
+ textOf: () => textOf2
10534
+ });
10535
+ function blocks3(node, out = []) {
10536
+ if (node.type === "paragraph" || node.type === "heading") {
10537
+ const text = (node.content ?? []).map((n) => n.type === "text" ? n.text : n.type === "hardBreak" ? "\n" : n.type === "math" ? ` ${n.attrs?.latex} ` : "").join("").trim();
10538
+ if (text) out.push(text);
10539
+ } else node.content?.forEach((n) => blocks3(n, out));
10540
+ return out;
10541
+ }
10542
+ async function textOf2(kind, bytes) {
10543
+ return blocks3(kind === "docx" ? (await readDocx(bytes)).doc : fromMarkdown(new TextDecoder().decode(bytes)).doc);
10544
+ }
10545
+ function inside(a, b) {
10546
+ const x = words2(a), y = words2(b);
10547
+ const map = diff(x, y);
10548
+ const out = [];
10549
+ const push = (text, op) => {
10550
+ const last2 = out[out.length - 1];
10551
+ if (last2?.op === op) last2.text += text;
10552
+ else out.push({ text, op });
10553
+ };
10554
+ let i = 0;
10555
+ map.forEach((from, j) => {
10556
+ if (from < 0) {
10557
+ const next = map.findIndex((n, at2) => at2 > j && n >= 0);
10558
+ while (i < (next < 0 ? x.length : map[next])) push(x[i++], "-");
10559
+ return push(y[j], "+");
10560
+ }
10561
+ while (i < from) push(x[i++], "-");
10562
+ push(y[j], "=");
10563
+ i = from + 1;
10564
+ });
10565
+ while (i < x.length) push(x[i++], "-");
10566
+ return out;
10567
+ }
10568
+ function changes2(before, after) {
10569
+ const map = diff(before, after);
10570
+ const rows = [];
10571
+ let gone = [];
10572
+ const drop2 = (n) => {
10573
+ gone.slice(0, n).forEach((text) => rows.push({ op: "-", parts: [{ text, op: "-" }] }));
10574
+ gone = gone.slice(n);
10575
+ };
10576
+ let i = 0;
10577
+ map.forEach((from, j) => {
10578
+ if (from >= 0) {
10579
+ while (i < from) gone.push(before[i++]);
10580
+ drop2(gone.length);
10581
+ rows.push({ op: "=", parts: [{ text: after[j], op: "=" }] });
10582
+ i = from + 1;
10583
+ return;
10584
+ }
10585
+ const next = map.findIndex((n, at2) => at2 > j && n >= 0);
10586
+ while (i < (next < 0 ? before.length : map[next])) gone.push(before[i++]);
10587
+ const k = gone.findIndex((old) => alike(old, after[j]) >= 0.4);
10588
+ if (k < 0) return rows.push({ op: "+", parts: [{ text: after[j], op: "+" }] });
10589
+ drop2(k);
10590
+ rows.push({ op: "~", parts: inside(gone.shift(), after[j]) });
10591
+ });
10592
+ while (i < before.length) gone.push(before[i++]);
10593
+ drop2(gone.length);
10594
+ return rows;
10595
+ }
10596
+ function Compare({ host, documentId, kind, older, t }) {
10597
+ const rows = useLoad(async (signal) => changes2(await textOf2(kind, older), await textOf2(kind, await host.content(documentId, null, { signal }))), [host, documentId, older]);
10598
+ if (rows.error) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-empty", children: t.failed });
10599
+ if (!rows.data) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-empty", children: t.loading });
10600
+ const added = rows.data.filter((r) => r.op === "+").length, removed = rows.data.filter((r) => r.op === "-").length, edited = rows.data.filter((r) => r.op === "~").length;
10601
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-page w100n-compare", children: [
10602
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "w100n-compare-sum", children: added + removed + edited ? t.changeCount.replace("{added}", String(added)).replace("{edited}", String(edited)).replace("{removed}", String(removed)) : t.noChanges }),
10603
+ rows.data.map((r, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { "data-op": r.op, children: r.parts.map((p, k) => p.op === "=" ? p.text : p.op === "+" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("ins", { children: p.text }, k) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("del", { children: p.text }, k)) }, i))
10604
+ ] }) });
10605
+ }
10606
+ var import_jsx_runtime12, words2, alike;
10607
+ var init_Compare = __esm({
10608
+ "src/Compare.tsx"() {
10609
+ "use strict";
10610
+ init_docx();
10611
+ init_diff();
10612
+ init_markdown();
10613
+ init_useLoad();
10614
+ import_jsx_runtime12 = require("react/jsx-runtime");
10615
+ words2 = (text) => text.split(/(\s+)/).filter(Boolean);
10616
+ alike = (a, b) => {
10617
+ const x = a.split(/\s+/).filter(Boolean), y = b.split(/\s+/).filter(Boolean);
10618
+ return diff(x, y).filter((n) => n >= 0).length / Math.max(x.length, y.length, 1);
10619
+ };
10620
+ }
10621
+ });
10622
+
10298
10623
  // src/index.ts
10299
10624
  var index_exports = {};
10300
10625
  __export(index_exports, {
@@ -10352,8 +10677,8 @@ function readable(name, mimeType) {
10352
10677
  return kind !== "sheet" || /\.(xlsx|csv)$/i.test(name) || /spreadsheetml|text\/csv/.test(mimeType ?? "") ? kind : null;
10353
10678
  }
10354
10679
  function matches(doc, query, picked) {
10355
- const words2 = query.toLocaleLowerCase().split(/\s+/).filter(Boolean);
10356
- return (!picked.length || picked.includes(doc.kind)) && words2.every((word) => doc.name.toLocaleLowerCase().includes(word));
10680
+ const words3 = query.toLocaleLowerCase().split(/\s+/).filter(Boolean);
10681
+ return (!picked.length || picked.includes(doc.kind)) && words3.every((word) => doc.name.toLocaleLowerCase().includes(word));
10357
10682
  }
10358
10683
 
10359
10684
  // src/slides/SlidesView.tsx
@@ -10445,8 +10770,8 @@ var tagName = /<([a-zA-Z][^\s/>]*)/y;
10445
10770
  var endTag = /<\/([a-zA-Z][^\s/>]*)[^>]*>/y;
10446
10771
  var attrName = /[^\s/>=]+/y;
10447
10772
  var bare = /[^\s>]*/y;
10448
- var sticky = (re, s, at) => {
10449
- re.lastIndex = at;
10773
+ var sticky = (re, s, at2) => {
10774
+ re.lastIndex = at2;
10450
10775
  return re.exec(s);
10451
10776
  };
10452
10777
  function parse(html) {
@@ -10458,9 +10783,9 @@ function parse(html) {
10458
10783
  const text = (start, end) => {
10459
10784
  if (end > start) top().children.push({ text: true, start, end });
10460
10785
  };
10461
- const shut = (k, at, end) => {
10462
- for (let i2 = stack.length - 1; i2 > k; i2--) stack[i2].close = stack[i2].end = at;
10463
- stack[k].close = at;
10786
+ const shut = (k, at2, end) => {
10787
+ for (let i2 = stack.length - 1; i2 > k; i2--) stack[i2].close = stack[i2].end = at2;
10788
+ stack[k].close = at2;
10464
10789
  stack[k].end = end;
10465
10790
  for (let i2 = stack.length - 1; i2 >= k; i2--) if (stack[i2].tag === "svg" || stack[i2].tag === "math") foreign--;
10466
10791
  stack.length = k;
@@ -10527,24 +10852,24 @@ function parse(html) {
10527
10852
  j += n[0].length;
10528
10853
  while (j < len && /\s/.test(html[j])) j++;
10529
10854
  let value3 = "";
10530
- let at = null;
10855
+ let at2 = null;
10531
10856
  if (html[j] === "=") {
10532
10857
  j++;
10533
10858
  while (j < len && /\s/.test(html[j])) j++;
10534
10859
  const q = html[j];
10535
10860
  if (q === '"' || q === "'") {
10536
10861
  const e = html.indexOf(q, j + 1);
10537
- at = [j + 1, e < 0 ? len : e];
10862
+ at2 = [j + 1, e < 0 ? len : e];
10538
10863
  j = e < 0 ? len : e + 1;
10539
10864
  } else {
10540
10865
  const v = sticky(bare, html, j);
10541
- at = [j, j + v[0].length];
10866
+ at2 = [j, j + v[0].length];
10542
10867
  j += v[0].length;
10543
10868
  }
10544
- value3 = decode(html.slice(at[0], at[1]));
10869
+ value3 = decode(html.slice(at2[0], at2[1]));
10545
10870
  }
10546
10871
  const key2 = n[0].toLowerCase();
10547
- if (!attrs2.has(key2)) attrs2.set(key2, { value: value3, at });
10872
+ if (!attrs2.has(key2)) attrs2.set(key2, { value: value3, at: at2 });
10548
10873
  }
10549
10874
  if (breaks.has(tag)) {
10550
10875
  const k = seek(["p"], fences);
@@ -10663,12 +10988,12 @@ var flat = (el, html) => {
10663
10988
  });
10664
10989
  return visit(el) && (text || boxes.has(el.tag));
10665
10990
  };
10666
- var blocksOf = (el, html, notes2) => {
10991
+ var blocksOf = (el, html, notes3) => {
10667
10992
  if (flat(el, html)) return [el];
10668
10993
  const out = [];
10669
10994
  const walk = (e) => {
10670
10995
  for (const part of e.children) {
10671
- if (part.text || part === notes2 || skip.has(part.tag) || part.attrs.get("contenteditable")?.value === "false") continue;
10996
+ if (part.text || part === notes3 || skip.has(part.tag) || part.attrs.get("contenteditable")?.value === "false") continue;
10672
10997
  if (flat(part, html)) out.push(part);
10673
10998
  else walk(part);
10674
10999
  }
@@ -10685,8 +11010,8 @@ var notesHtml = (text) => escape(text).split("\n").join("<br>\n");
10685
11010
  var sizeOf = (html, kind, scripts, styles2, marks2) => {
10686
11011
  if (kind === "reveal") {
10687
11012
  const code = scripts.map((s) => html.slice(s.open, s.close)).join("\n");
10688
- const at = code.search(/Reveal\.initialize\s*\(/);
10689
- const init2 = at < 0 ? "" : code.slice(at, at + 4e3);
11013
+ const at2 = code.search(/Reveal\.initialize\s*\(/);
11014
+ const init2 = at2 < 0 ? "" : code.slice(at2, at2 + 4e3);
10690
11015
  const width = Number(/\bwidth\s*:\s*['"]?(\d+)/.exec(init2)?.[1] ?? 960);
10691
11016
  const height = Number(/\bheight\s*:\s*['"]?(\d+)/.exec(init2)?.[1] ?? 700);
10692
11017
  return { width, height, center: !/\bcenter\s*:\s*false/.test(init2) };
@@ -10716,14 +11041,14 @@ function shape(html) {
10716
11041
  const outer = all.find((el) => el.tag === "html");
10717
11042
  const body = all.find((el) => el.tag === "body") ?? null;
10718
11043
  const doctype = /^\s*<!doctype[^>]*>/i.exec(html);
10719
- const at = head2 ? head2.open : outer ? outer.open : doctype ? doctype[0].length : 0;
11044
+ const at2 = head2 ? head2.open : outer ? outer.open : doctype ? doctype[0].length : 0;
10720
11045
  const reveal = all.find((el) => classes(el).includes("reveal")) ?? null;
10721
11046
  const box2 = reveal && all.find((el) => classes(el).includes("slides") && under(el, (up) => up === reveal));
10722
11047
  const spots = [];
10723
11048
  const stacks = [];
10724
11049
  const spot3 = (el, stack) => {
10725
- const notes2 = notesOf(el);
10726
- spots.push({ el, stack, notes: notes2, attr: notes2 ? null : el.attrs.get("data-notes") ?? null, blocks: blocksOf(el, html, notes2) });
11050
+ const notes3 = notesOf(el);
11051
+ spots.push({ el, stack, notes: notes3, attr: notes3 ? null : el.attrs.get("data-notes") ?? null, blocks: blocksOf(el, html, notes3) });
10727
11052
  };
10728
11053
  let kind;
10729
11054
  let units;
@@ -10757,7 +11082,7 @@ function shape(html) {
10757
11082
  for (const unit of units) spot3(unit, null);
10758
11083
  }
10759
11084
  const size2 = sizeOf(html, kind, scripts, styles2, [container, ...body ? [body] : [], ...outer ? [outer] : []]);
10760
- return { kind, ...size2, root, box: container, units, stacks, spots, scripts, refresh, head: at, body };
11085
+ return { kind, ...size2, root, box: container, units, stacks, spots, scripts, refresh, head: at2, body };
10761
11086
  }
10762
11087
  var titleOf = (html, s) => {
10763
11088
  const heading = elements(s.el).find((el2) => /^h[1-6]$/.test(el2.tag) && !(s.notes && under(el2, (up) => up === s.notes)));
@@ -10800,8 +11125,8 @@ function cuts(html, s, slide, stamp) {
10800
11125
  const lead = /^\s*/.exec(inner2)[0];
10801
11126
  const tail = /\s*$/.exec(inner2)[0];
10802
11127
  const indent2 = lead.includes("\n") ? lead.slice(lead.lastIndexOf("\n")) : "";
10803
- const at = Math.max(s.el.open, s.el.close - tail.length);
10804
- out.push([at, at, `${indent2}<aside class="notes">${notesHtml(slide.notes)}</aside>`]);
11128
+ const at2 = Math.max(s.el.open, s.el.close - tail.length);
11129
+ out.push([at2, at2, `${indent2}<aside class="notes">${notesHtml(slide.notes)}</aside>`]);
10805
11130
  }
10806
11131
  }
10807
11132
  return out;
@@ -10809,13 +11134,13 @@ function cuts(html, s, slide, stamp) {
10809
11134
  function apply(html, from, to, list) {
10810
11135
  const sorted = [...list].sort((a, b) => a[0] - b[0] || a[1] - b[1]);
10811
11136
  const out = [];
10812
- let at = from;
11137
+ let at2 = from;
10813
11138
  for (const [start, end, put] of sorted) {
10814
- if (start < at || end > to) continue;
10815
- out.push(html.slice(at, start), put);
10816
- at = end;
11139
+ if (start < at2 || end > to) continue;
11140
+ out.push(html.slice(at2, start), put);
11141
+ at2 = end;
10817
11142
  }
10818
- out.push(html.slice(at, to));
11143
+ out.push(html.slice(at2, to));
10819
11144
  return out.join("");
10820
11145
  }
10821
11146
  var blank = (s) => !/\S/.test(s);
@@ -10860,15 +11185,15 @@ function writeDeck(original, deck, known) {
10860
11185
  function moveSlide(deck, from, to) {
10861
11186
  const slide = deck.slides[from];
10862
11187
  const rest = deck.slides.filter((_, i) => i !== from);
10863
- let at = Math.max(0, Math.min(rest.length, to));
11188
+ let at2 = Math.max(0, Math.min(rest.length, to));
10864
11189
  const run3 = rest.flatMap((other, i) => slide.stack !== null && other.stack === slide.stack ? [i] : []);
10865
- if (run3.length) at = Math.max(run3[0], Math.min(run3[run3.length - 1] + 1, at));
10866
- else if (at > 0 && at < rest.length && rest[at].stack !== null && rest[at - 1].stack === rest[at].stack) {
10867
- let end = at;
10868
- while (end < rest.length && rest[end].stack === rest[at].stack) end++;
10869
- at = to > from ? end : rest.findIndex((other) => other.stack === rest[at].stack);
11190
+ if (run3.length) at2 = Math.max(run3[0], Math.min(run3[run3.length - 1] + 1, at2));
11191
+ else if (at2 > 0 && at2 < rest.length && rest[at2].stack !== null && rest[at2 - 1].stack === rest[at2].stack) {
11192
+ let end = at2;
11193
+ while (end < rest.length && rest[end].stack === rest[at2].stack) end++;
11194
+ at2 = to > from ? end : rest.findIndex((other) => other.stack === rest[at2].stack);
10870
11195
  }
10871
- return { ...deck, slides: [...rest.slice(0, at), slide, ...rest.slice(at)] };
11196
+ return { ...deck, slides: [...rest.slice(0, at2), slide, ...rest.slice(at2)] };
10872
11197
  }
10873
11198
  var duplicateSlide = (deck, i, key2) => ({ ...deck, slides: [...deck.slides.slice(0, i + 1), { ...deck.slides[i], key: key2 }, ...deck.slides.slice(i + 1)] });
10874
11199
  var deleteSlide = (deck, i) => ({ ...deck, slides: deck.slides.filter((_, k) => k !== i) });
@@ -11145,7 +11470,7 @@ function SlidesView({ html, name, rights, language = "en", theme = "light", base
11145
11470
  const live = (0, import_react2.useRef)(state);
11146
11471
  const [saved, setSaved] = (0, import_react2.useState)({ html, deck: source.deck });
11147
11472
  const [prop, setProp] = (0, import_react2.useState)(html);
11148
- const [at, setAt] = (0, import_react2.useState)(0);
11473
+ const [at2, setAt] = (0, import_react2.useState)(0);
11149
11474
  if (html !== prop) {
11150
11475
  setProp(html);
11151
11476
  if (html !== saved.html) {
@@ -11163,7 +11488,7 @@ function SlidesView({ html, name, rights, language = "en", theme = "light", base
11163
11488
  };
11164
11489
  const { deck, epoch } = state;
11165
11490
  const count = deck.slides.length;
11166
- const index = Math.min(at, count - 1);
11491
+ const index = Math.min(at2, count - 1);
11167
11492
  const slide = deck.slides[index];
11168
11493
  const can = rights.edit && !!onSaveRequest;
11169
11494
  const movable = can && deck.kind !== "page";
@@ -11704,7 +12029,7 @@ var same = (a, b) => !!b && a.page === b.page && a.start === b.start;
11704
12029
  var spot = (b, size2) => ({ left: pct(b.x / size2.w), top: pct(b.y / size2.h), width: pct(b.w / size2.w), height: pct(b.h / size2.h) });
11705
12030
  function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
11706
12031
  const paint2 = (0, import_react5.useRef)(null);
11707
- const words2 = (0, import_react5.useRef)(null);
12032
+ const words3 = (0, import_react5.useRef)(null);
11708
12033
  const forms = (0, import_react5.useRef)(null);
11709
12034
  const focus = (0, import_react5.useRef)(null);
11710
12035
  const rubbed = (0, import_react5.useRef)(null);
@@ -11716,7 +12041,7 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
11716
12041
  const hitKey = layers ? layers.hits.map((hit) => `${hit.start}:${hit.end}`).join() : "";
11717
12042
  (0, import_react5.useEffect)(() => {
11718
12043
  if (!live) return;
11719
- const holders = [paint2, words2, forms].flatMap((ref) => ref.current ? [ref.current] : []);
12044
+ const holders = [paint2, words3, forms].flatMap((ref) => ref.current ? [ref.current] : []);
11720
12045
  return () => {
11721
12046
  for (const holder of holders) {
11722
12047
  for (const canvas of holder.querySelectorAll("canvas")) {
@@ -11801,7 +12126,7 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
11801
12126
  const end = document.createElement("div");
11802
12127
  end.className = "endOfContent";
11803
12128
  layer.append(end);
11804
- words2.current.replaceChildren(layer);
12129
+ words3.current.replaceChildren(layer);
11805
12130
  const annotations = await page.getAnnotations();
11806
12131
  for (const a of annotations) {
11807
12132
  if (!a.fieldName || a.pushButton || !["Tx", "Btn", "Ch"].includes(a.fieldType)) continue;
@@ -11837,7 +12162,7 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
11837
12162
  };
11838
12163
  }, [pdf, n, live, fill3]);
11839
12164
  (0, import_react5.useLayoutEffect)(() => {
11840
- const layer = words2.current?.firstElementChild;
12165
+ const layer = words3.current?.firstElementChild;
11841
12166
  if (!layers || !layer || !hitKey) {
11842
12167
  setBoxes([]);
11843
12168
  return;
@@ -11845,13 +12170,13 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
11845
12170
  const frame = layer.getBoundingClientRect();
11846
12171
  const k = frame.width ? size2.w / frame.width : 1 / scale;
11847
12172
  const parts2 = [];
11848
- let at2 = 0;
12173
+ let at3 = 0;
11849
12174
  const walk = document.createTreeWalker(layer, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT);
11850
12175
  for (let node = walk.nextNode(); node; node = walk.nextNode()) {
11851
12176
  if (node.nodeType === Node.TEXT_NODE) {
11852
- parts2.push({ node, start: at2 });
11853
- at2 += node.length;
11854
- } else if (node.nodeName === "BR") at2 += 1;
12177
+ parts2.push({ node, start: at3 });
12178
+ at3 += node.length;
12179
+ } else if (node.nodeName === "BR") at3 += 1;
11855
12180
  }
11856
12181
  setBoxes(layers.hits.flatMap((hit) => parts2.flatMap(({ node, start }) => {
11857
12182
  const from = Math.max(hit.start, start);
@@ -11875,13 +12200,13 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
11875
12200
  if (!layers) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "w100n-pdf-page", "data-n": n, style, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: paint2, className: "w100n-pdf-paint" }) });
11876
12201
  const { tool, marks: marks2, act, t, open } = layers;
11877
12202
  const first = boxes3.findIndex((b) => same(b.hit, layers.active));
11878
- const at = (e) => {
12203
+ const at2 = (e) => {
11879
12204
  const r = e.currentTarget.closest(".w100n-pdf-page").getBoundingClientRect();
11880
12205
  return { x: (e.clientX - r.left) / scale, y: (e.clientY - r.top) / scale };
11881
12206
  };
11882
12207
  const line = (points) => points.map((p, i) => `${i ? "L" : "M"}${p.x.toFixed(1)} ${p.y.toFixed(1)}`).join(" ");
11883
12208
  const down2 = (e) => {
11884
- const p = at(e);
12209
+ const p = at2(e);
11885
12210
  if (tool === "note" || tool === "place") {
11886
12211
  e.preventDefault();
11887
12212
  if (tool === "note") act.note(n, p);
@@ -11897,7 +12222,7 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
11897
12222
  };
11898
12223
  const move2 = (e) => {
11899
12224
  if (!e.buttons) return;
11900
- const p = at(e);
12225
+ const p = at2(e);
11901
12226
  if (stroke) {
11902
12227
  const last2 = stroke[stroke.length - 1];
11903
12228
  if (Math.hypot(p.x - last2.x, p.y - last2.y) > 0.8) setStroke([...stroke, p]);
@@ -11912,11 +12237,11 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
11912
12237
  e.stopPropagation();
11913
12238
  e.currentTarget.setPointerCapture(e.pointerId);
11914
12239
  act.open(mark.id);
11915
- setDrag({ id: mark.id, from: at(e), start: mark.box, box: mark.box, resize: resize2 });
12240
+ setDrag({ id: mark.id, from: at2(e), start: mark.box, box: mark.box, resize: resize2 });
11916
12241
  };
11917
12242
  const pull = (e) => {
11918
12243
  if (!drag) return;
11919
- const p = at(e);
12244
+ const p = at2(e);
11920
12245
  const dx = p.x - drag.from.x;
11921
12246
  const { start } = drag;
11922
12247
  if (drag.resize) {
@@ -11932,7 +12257,7 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
11932
12257
  };
11933
12258
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "w100n-pdf-page", id, "data-n": n, style, children: [
11934
12259
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: paint2, className: "w100n-pdf-paint" }),
11935
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: words2, className: "w100n-pdf-words" }),
12260
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: words3, className: "w100n-pdf-words" }),
11936
12261
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: forms, className: "w100n-pdf-forms" }),
11937
12262
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { className: "w100n-pdf-marks", viewBox: `0 0 ${size2.w} ${size2.h}`, preserveAspectRatio: "none", "aria-hidden": true, children: [
11938
12263
  marks2.map((mark) => {
@@ -12032,11 +12357,11 @@ var dist = (p, a, b) => {
12032
12357
  return Math.hypot(p.x - a.x - k * dx, p.y - a.y - k * dy);
12033
12358
  };
12034
12359
  var touches = (m, p) => {
12035
- const inside = (b) => p.x >= b.x - 2 && p.x <= b.x + b.w + 2 && p.y >= b.y - 2 && p.y <= b.y + b.h + 2;
12036
- if (m.kind === "note") return inside({ ...m.spot, w: 20, h: 20 });
12037
- if (m.kind === "sign") return inside(m.box);
12360
+ const inside2 = (b) => p.x >= b.x - 2 && p.x <= b.x + b.w + 2 && p.y >= b.y - 2 && p.y <= b.y + b.h + 2;
12361
+ if (m.kind === "note") return inside2({ ...m.spot, w: 20, h: 20 });
12362
+ if (m.kind === "sign") return inside2(m.box);
12038
12363
  if (m.kind === "ink") return m.lines.some((line) => line.some((q, i) => dist(p, line[Math.max(0, i - 1)], q) < m.width / 2 + 4));
12039
- return m.rects.some(inside);
12364
+ return m.rects.some(inside2);
12040
12365
  };
12041
12366
  function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved, onOutline, guard }) {
12042
12367
  const prefix = (0, import_react6.useId)();
@@ -12048,7 +12373,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
12048
12373
  const pad = (0, import_react6.useRef)(null);
12049
12374
  const inked = (0, import_react6.useRef)(null);
12050
12375
  const widgets = (0, import_react6.useRef)(/* @__PURE__ */ new Map());
12051
- const words2 = (0, import_react6.useRef)(/* @__PURE__ */ new Map());
12376
+ const words3 = (0, import_react6.useRef)(/* @__PURE__ */ new Map());
12052
12377
  const anchor = (0, import_react6.useRef)({ scale: 0, page: 0, frac: 0 });
12053
12378
  const [pdf, setPdf] = (0, import_react6.useState)(null);
12054
12379
  const [sizes2, setSizes] = (0, import_react6.useState)([]);
@@ -12062,7 +12387,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
12062
12387
  const [typed, setTyped] = (0, import_react6.useState)(null);
12063
12388
  const [query, setQuery] = (0, import_react6.useState)(null);
12064
12389
  const [hits, setHits] = (0, import_react6.useState)({ list: [], done: true });
12065
- const [at, setAt] = (0, import_react6.useState)(0);
12390
+ const [at2, setAt] = (0, import_react6.useState)(0);
12066
12391
  const [tool, setTool] = (0, import_react6.useState)("select");
12067
12392
  const [pen, setPen] = (0, import_react6.useState)({ highlight: "#facc15", line: "#dc2626", ink: "#2563eb", width: 2 });
12068
12393
  const [palette2, setPalette] = (0, import_react6.useState)(false);
@@ -12090,7 +12415,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
12090
12415
  setFilled(false);
12091
12416
  setOpen(null);
12092
12417
  widgets.current = /* @__PURE__ */ new Map();
12093
- words2.current = /* @__PURE__ */ new Map();
12418
+ words3.current = /* @__PURE__ */ new Map();
12094
12419
  (async () => {
12095
12420
  var _a;
12096
12421
  const pdfjs = await import("pdfjs-dist");
@@ -12215,11 +12540,11 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
12215
12540
  const timer = setTimeout(async () => {
12216
12541
  const found = [];
12217
12542
  for (let n = 1; n <= pdf.numPages && !stop; n++) {
12218
- let text = words2.current.get(n);
12543
+ let text = words3.current.get(n);
12219
12544
  if (text === void 0) {
12220
12545
  const content = await (await pdf.getPage(n)).getTextContent();
12221
12546
  text = content.items.map((piece) => "str" in piece ? piece.str + (piece.hasEOL ? " " : "") : "").join("").toLowerCase();
12222
- words2.current.set(n, text);
12547
+ words3.current.set(n, text);
12223
12548
  }
12224
12549
  for (let i = text.indexOf(needle); i >= 0; i = text.indexOf(needle, i + needle.length)) found.push({ page: n, start: i, end: i + needle.length });
12225
12550
  if (!stop && (n % 20 === 0 || n === pdf.numPages)) setHits({ list: [...found], done: n === pdf.numPages });
@@ -12263,7 +12588,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
12263
12588
  };
12264
12589
  const step = (d) => {
12265
12590
  if (!hits.list.length) return;
12266
- const next = (at + d + hits.list.length) % hits.list.length;
12591
+ const next = (at2 + d + hits.list.length) % hits.list.length;
12267
12592
  setAt(next);
12268
12593
  const n = hits.list[next].page;
12269
12594
  if (tops[n - 1] + sizes2[n - 1].h * scale < top || tops[n - 1] > top + box2.h) go(n);
@@ -12518,7 +12843,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
12518
12843
  { key: "find", at: 0, Icon: import_lucide_react4.Search, label: t.find, run: () => setQuery(query === null ? "" : null), pressed: query !== null },
12519
12844
  ...can.mark ? [
12520
12845
  { key: "g3", at: 2, node: gap },
12521
- ...tools.filter(([, , , shown]) => shown).map(([key2, Icon, label, , at2]) => ({ key: key2, at: at2, Icon, label, run: () => pick(key2), pressed: tool === key2 })),
12846
+ ...tools.filter(([, , , shown]) => shown).map(([key2, Icon, label, , at3]) => ({ key: key2, at: at3, Icon, label, run: () => pick(key2), pressed: tool === key2 })),
12522
12847
  ...can.edit ? [{ key: "sign", at: 2, Icon: import_lucide_react4.Signature, label: t.sign, run: () => setSigning({ tab: "typed", name: me, image: null, drawn: false }), pressed: tool === "place" || signing !== null }] : [],
12523
12848
  { key: "colour", at: 0, node: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "w100n-pdf-palette", children: [
12524
12849
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", "aria-expanded": palette2, onClick: () => {
@@ -12605,7 +12930,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
12605
12930
  }
12606
12931
  }
12607
12932
  ),
12608
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-live": "polite", children: hits.list.length ? `${Math.min(at + 1, hits.list.length)} / ${hits.list.length}` : query.trim() ? hits.done ? t.noHits : t.searching : "" }),
12933
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-live": "polite", children: hits.list.length ? `${Math.min(at2 + 1, hits.list.length)} / ${hits.list.length}` : query.trim() ? hits.done ? t.noHits : t.searching : "" }),
12609
12934
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", disabled: !hits.list.length, onClick: () => step(-1), "aria-label": t.previous, title: t.previous, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react4.ChevronUp, { "aria-hidden": true }) }),
12610
12935
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", disabled: !hits.list.length, onClick: () => step(1), "aria-label": t.next, title: t.next, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react4.ChevronDown, { "aria-hidden": true }) }),
12611
12936
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", onClick: () => setQuery(null), "aria-label": t.close, title: t.close, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react4.X, { "aria-hidden": true }) })
@@ -12650,7 +12975,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
12650
12975
  tool,
12651
12976
  marks: byPage.get(i + 1) ?? [],
12652
12977
  hits: hitsBy.get(i + 1) ?? [],
12653
- active: hits.list[at],
12978
+ active: hits.list[at2],
12654
12979
  open,
12655
12980
  pen: { color: pen.ink, width: pen.width },
12656
12981
  widgets: widgets.current,
@@ -12902,8 +13227,8 @@ var table2 = (rows) => {
12902
13227
  return `<w:tbl><w:tblPr><w:tblW w:w="5000" w:type="pct"/><w:tblBorders>${["top", "left", "bottom", "right", "insideH", "insideV"].map(border).join("")}</w:tblBorders></w:tblPr><w:tblGrid>${rows[0].map(() => `<w:gridCol w:w="${width}"/>`).join("")}</w:tblGrid>` + rows.map((row2, r) => `<w:tr>${row2.map((cell2) => `<w:tc><w:tcPr><w:tcW w:w="${width}" w:type="dxa"/></w:tcPr><w:p>${r === 0 ? `<w:r><w:rPr><w:b/></w:rPr><w:t xml:space="preserve">${escape2(cell2)}</w:t></w:r>` : run2(cell2)}</w:p></w:tc>`).join("")}</w:tr>`).join("") + "</w:tbl><w:p/>";
12903
13228
  };
12904
13229
  var styles = `${head}<w:styles xmlns:w="${W}"><w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:eastAsia="Arial" w:cs="Arial"/><w:sz w:val="22"/><w:szCs w:val="22"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr><w:spacing w:after="120" w:line="276" w:lineRule="auto"/></w:pPr></w:pPrDefault></w:docDefaults><w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/><w:qFormat/></w:style><w:style w:type="paragraph" w:styleId="Title"><w:name w:val="Title"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:qFormat/><w:pPr><w:spacing w:after="80"/></w:pPr><w:rPr><w:b/><w:sz w:val="48"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Heading1"><w:name w:val="heading 1"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:qFormat/><w:pPr><w:keepNext/><w:spacing w:before="360" w:after="120"/><w:outlineLvl w:val="0"/></w:pPr><w:rPr><w:b/><w:sz w:val="32"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Heading2"><w:name w:val="heading 2"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:qFormat/><w:pPr><w:keepNext/><w:spacing w:before="240" w:after="80"/><w:outlineLvl w:val="1"/></w:pPr><w:rPr><w:b/><w:sz w:val="26"/></w:rPr></w:style></w:styles>`;
12905
- function docx(blocks3) {
12906
- const body = blocks3.map((block2) => typeof block2[0] === "string" || block2[0] === null ? para(block2) : table2(block2)).join("") || "<w:p/>";
13230
+ function docx(blocks4) {
13231
+ const body = blocks4.map((block2) => typeof block2[0] === "string" || block2[0] === null ? para(block2) : table2(block2)).join("") || "<w:p/>";
12907
13232
  return (0, import_fflate2.zipSync)({
12908
13233
  "[Content_Types].xml": (0, import_fflate2.strToU8)(`${head}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/></Types>`),
12909
13234
  "_rels/.rels": (0, import_fflate2.strToU8)(`${head}<Relationships xmlns="${PKG}"><Relationship Id="rId1" Type="${REL3}/officeDocument" Target="word/document.xml"/></Relationships>`),
@@ -12912,7 +13237,7 @@ function docx(blocks3) {
12912
13237
  "word/document.xml": (0, import_fflate2.strToU8)(`${head}<w:document xmlns:w="${W}" xmlns:r="${REL3}"><w:body>${body}<w:sectPr><w:pgSz w:w="11906" w:h="16838"/><w:pgMar w:top="1417" w:right="1134" w:bottom="1417" w:left="1134" w:header="708" w:footer="708" w:gutter="0"/></w:sectPr></w:body></w:document>`)
12913
13238
  });
12914
13239
  }
12915
- function markdown(blocks3) {
13240
+ function markdown(blocks4) {
12916
13241
  const line = (block2) => {
12917
13242
  if (typeof block2[0] === "string" || block2[0] === null) {
12918
13243
  const [style, text] = block2;
@@ -12921,7 +13246,7 @@ function markdown(blocks3) {
12921
13246
  const rows = block2;
12922
13247
  return [rows[0], rows[0].map(() => "---"), ...rows.slice(1)].map((row2) => `| ${row2.join(" | ")} |`).join("\n");
12923
13248
  };
12924
- return (0, import_fflate2.strToU8)(blocks3.map(line).join("\n\n").replace(/\n{3,}/g, "\n\n") + "\n");
13249
+ return (0, import_fflate2.strToU8)(blocks4.map(line).join("\n\n").replace(/\n{3,}/g, "\n\n") + "\n");
12925
13250
  }
12926
13251
  var S = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
12927
13252
  function sheet() {
@@ -12954,8 +13279,8 @@ var slides = (name) => (0, import_fflate2.strToU8)(`<!DOCTYPE html>
12954
13279
  </html>
12955
13280
  `);
12956
13281
  function blank4(kind, name, template = "blank") {
12957
- const blocks3 = template === "blank" ? [] : templates[template](name);
12958
- const bytes = kind === "docx" ? docx(blocks3) : kind === "markdown" ? markdown(blocks3.length ? blocks3 : [["Title", name]]) : kind === "sheet" ? sheet() : slides(name);
13282
+ const blocks4 = template === "blank" ? [] : templates[template](name);
13283
+ const bytes = kind === "docx" ? docx(blocks4) : kind === "markdown" ? markdown(blocks4.length ? blocks4 : [["Title", name]]) : kind === "sheet" ? sheet() : slides(name);
12959
13284
  return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
12960
13285
  }
12961
13286
 
@@ -13048,8 +13373,8 @@ init_useLoad();
13048
13373
  var import_jsx_runtime10 = require("react/jsx-runtime");
13049
13374
  var blank5 = { id: null, comment: false, download: false, askName: true, works: "30", day: "", password: false, secret: "", had: false };
13050
13375
  var local = (iso) => {
13051
- const at = new Date(iso);
13052
- return `${at.getFullYear()}-${String(at.getMonth() + 1).padStart(2, "0")}-${String(at.getDate()).padStart(2, "0")}`;
13376
+ const at2 = new Date(iso);
13377
+ return `${at2.getFullYear()}-${String(at2.getMonth() + 1).padStart(2, "0")}-${String(at2.getDate()).padStart(2, "0")}`;
13053
13378
  };
13054
13379
  function Sharing({ host, doc, t, language, team }) {
13055
13380
  const links = useLoad((signal) => host.links(doc.id, { signal }), [host, doc.id]);
@@ -13392,9 +13717,10 @@ function Thumb({ host, item, label }) {
13392
13717
 
13393
13718
  // src/DocumentsWorkspace.tsx
13394
13719
  init_useLoad();
13395
- var import_jsx_runtime12 = require("react/jsx-runtime");
13720
+ var import_jsx_runtime13 = require("react/jsx-runtime");
13396
13721
  var TextEditor3 = (0, import_react16.lazy)(() => Promise.resolve().then(() => (init_TextEditor(), TextEditor_exports)));
13397
13722
  var SheetView3 = (0, import_react16.lazy)(() => Promise.resolve().then(() => (init_SheetView(), SheetView_exports)));
13723
+ var Compare2 = (0, import_react16.lazy)(() => Promise.resolve().then(() => (init_Compare(), Compare_exports)));
13398
13724
  var icons3 = { docx: import_lucide_react10.FileText, markdown: import_lucide_react10.FileType, pdf: import_lucide_react10.Files, sheet: import_lucide_react10.FileSpreadsheet, slides: import_lucide_react10.Presentation };
13399
13725
  function DocumentsWorkspace({ host, language = "en", theme = "light", place: place2, onPlace, start, end, aside, actions }) {
13400
13726
  const t = texts[language];
@@ -13471,6 +13797,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13471
13797
  const [fold, setFold] = (0, import_react16.useState)({});
13472
13798
  const [version2, setVersion] = (0, import_react16.useState)({ documentId: null, id: null });
13473
13799
  const versionId = version2.documentId === here.documentId ? version2.id : null;
13800
+ const [comparing, setComparing] = (0, import_react16.useState)(false);
13474
13801
  const [restoring, setRestoring] = (0, import_react16.useState)("idle");
13475
13802
  const [exporting, setExporting] = (0, import_react16.useState)("idle");
13476
13803
  const [copying, setCopying] = (0, import_react16.useState)("idle");
@@ -13528,9 +13855,9 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13528
13855
  return new Intl.DateTimeFormat(language, { day: "numeric", month: "short", year: "numeric" }).format(new Date(iso));
13529
13856
  };
13530
13857
  const size2 = (bytes) => bytes < 1024 ? `${bytes} B` : bytes < 1048576 ? `${(bytes / 1024).toFixed(0)} KB` : `${(bytes / 1048576).toFixed(1)} MB`;
13531
- const failed = (retry) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-note", children: [
13858
+ const failed = (retry) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-note", children: [
13532
13859
  t.failed,
13533
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", onClick: retry, children: t.retry })
13860
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", onClick: retry, children: t.retry })
13534
13861
  ] });
13535
13862
  const { ask, dialog } = useUnsaved(guard, t);
13536
13863
  const side2 = (which, open2) => {
@@ -13567,6 +13894,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13567
13894
  if (id === versionId) return;
13568
13895
  ask(() => {
13569
13896
  setRestoring("idle");
13897
+ setComparing(false);
13570
13898
  setVersion({ documentId: here.documentId, id });
13571
13899
  });
13572
13900
  };
@@ -13648,8 +13976,8 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13648
13976
  setSending("failed");
13649
13977
  }
13650
13978
  };
13651
- let stage = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-empty", children: [
13652
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.FileText, { "aria-hidden": true }),
13979
+ let stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-empty", children: [
13980
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.FileText, { "aria-hidden": true }),
13653
13981
  t.pick
13654
13982
  ] });
13655
13983
  if (here.documentId) {
@@ -13657,8 +13985,9 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13657
13985
  doc.retry();
13658
13986
  content.retry();
13659
13987
  });
13660
- else if (!doc.data || !content.data) stage = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-empty", children: t.loading });
13661
- else if (doc.data.kind === "markdown" || doc.data.kind === "docx") stage = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react16.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-empty", children: t.loading }), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
13988
+ else if (!doc.data || !content.data) stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-empty", children: t.loading });
13989
+ else if (comparing && versionId && (doc.data.kind === "markdown" || doc.data.kind === "docx")) stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react16.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-empty", children: t.loading }), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Compare2, { host, documentId: doc.data.id, kind: doc.data.kind, older: content.data, t }, versionId) });
13990
+ else if (doc.data.kind === "markdown" || doc.data.kind === "docx") stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react16.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-empty", children: t.loading }), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
13662
13991
  TextEditor3,
13663
13992
  {
13664
13993
  kind: doc.data.kind,
@@ -13693,7 +14022,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13693
14022
  },
13694
14023
  doc.data.id
13695
14024
  ) });
13696
- else if (doc.data.kind === "pdf") stage = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
14025
+ else if (doc.data.kind === "pdf") stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
13697
14026
  PdfView,
13698
14027
  {
13699
14028
  bytes: content.data,
@@ -13715,7 +14044,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13715
14044
  },
13716
14045
  `${doc.data.id}:${versionId ?? ""}`
13717
14046
  );
13718
- else if (doc.data.kind === "slides") stage = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
14047
+ else if (doc.data.kind === "slides") stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
13719
14048
  SlidesView,
13720
14049
  {
13721
14050
  html: new TextDecoder().decode(content.data),
@@ -13734,7 +14063,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13734
14063
  },
13735
14064
  doc.data.id
13736
14065
  );
13737
- else if (doc.data.kind === "sheet") stage = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react16.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-empty", children: t.loading }), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
14066
+ else if (doc.data.kind === "sheet") stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react16.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-empty", children: t.loading }), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
13738
14067
  SheetView3,
13739
14068
  {
13740
14069
  bytes: content.data,
@@ -13761,7 +14090,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13761
14090
  },
13762
14091
  `${doc.data.id}:${versionId ?? ""}`
13763
14092
  ) });
13764
- else stage = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-empty", children: t.unsupported });
14093
+ else stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-empty", children: t.unsupported });
13765
14094
  }
13766
14095
  const Kind = doc.data ? icons3[doc.data.kind] : import_lucide_react10.FileText;
13767
14096
  const top = Math.min(...outline2.map((h) => h.level));
@@ -13772,8 +14101,8 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13772
14101
  }, []);
13773
14102
  const now = reading?.documentId === here.documentId ? reading : null;
13774
14103
  const reached = now ? chapters.findIndex((c) => c.head.id === now.id || c.subs.some((s) => s.id === now.id)) : -1;
13775
- const words2 = hunt.toLocaleLowerCase().split(/\s+/).filter(Boolean);
13776
- const hit = (h) => words2.every((w) => h.text.toLocaleLowerCase().includes(w));
14104
+ const words3 = hunt.toLocaleLowerCase().split(/\s+/).filter(Boolean);
14105
+ const hit = (h) => words3.every((w) => h.text.toLocaleLowerCase().includes(w));
13777
14106
  const reach = (h) => h.go ? h.go() : document.getElementById(h.id)?.scrollIntoView({ behavior: "smooth", block: "start" });
13778
14107
  const crumbs = doc.data ? [names2.get(doc.data.spaceId), doc.data.folder].filter(Boolean) : space ? [space.name] : [];
13779
14108
  const panelTabs = [["outline", import_lucide_react10.ListTree, t.outline], ["versions", import_lucide_react10.History, t.versions], ["details", import_lucide_react10.Info, t.details]];
@@ -13781,7 +14110,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13781
14110
  if (text && host.comments && !versionId) panelTabs.push(["comments", import_lucide_react10.MessagesSquare, t.comments]);
13782
14111
  const sharing = !!host.links && !!doc.data?.rights.edit && !versionId;
13783
14112
  if (sharing) panelTabs.push(["sharing", import_lucide_react10.Share2, t.sharing]);
13784
- const listToggle = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
14113
+ const listToggle = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
13785
14114
  "button",
13786
14115
  {
13787
14116
  ref: listButton,
@@ -13791,10 +14120,10 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13791
14120
  onClick: () => side2("list", !listOpen),
13792
14121
  "aria-label": listOpen ? t.closeList : t.openList,
13793
14122
  title: listOpen ? t.closeList : t.openList,
13794
- children: listOpen ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.PanelLeftClose, { "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.PanelLeftOpen, { "aria-hidden": true })
14123
+ children: listOpen ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.PanelLeftClose, { "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.PanelLeftOpen, { "aria-hidden": true })
13795
14124
  }
13796
14125
  );
13797
- const panelToggle = doc.data && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
14126
+ const panelToggle = doc.data && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
13798
14127
  "button",
13799
14128
  {
13800
14129
  ref: panelButton,
@@ -13804,16 +14133,16 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13804
14133
  onClick: () => side2("panel", !panelOpen),
13805
14134
  "aria-label": panelOpen ? t.closePanel : t.openPanel,
13806
14135
  title: panelOpen ? t.closePanel : t.openPanel,
13807
- children: panelOpen ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.PanelRightClose, { "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.PanelRightOpen, { "aria-hidden": true })
14136
+ children: panelOpen ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.PanelRightClose, { "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.PanelRightOpen, { "aria-hidden": true })
13808
14137
  }
13809
14138
  );
13810
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs", "data-theme": theme, children: [
13811
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("header", { className: "w100n-docs-bar", children: [
13812
- start && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-start w100n-docs-slot", children: slot(start) }),
14139
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs", "data-theme": theme, children: [
14140
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("header", { className: "w100n-docs-bar", children: [
14141
+ start && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-start w100n-docs-slot", children: slot(start) }),
13813
14142
  narrow && listToggle,
13814
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-tile", "data-kind": doc.data?.kind, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Kind, { "aria-hidden": true }) }),
13815
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-heading", children: [
13816
- renaming !== null && doc.data ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
14143
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-tile", "data-kind": doc.data?.kind, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Kind, { "aria-hidden": true }) }),
14144
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-heading", children: [
14145
+ renaming !== null && doc.data ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
13817
14146
  "input",
13818
14147
  {
13819
14148
  className: "w100n-docs-title w100n-docs-rename",
@@ -13831,7 +14160,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13831
14160
  }
13832
14161
  }
13833
14162
  }
13834
- ) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
14163
+ ) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
13835
14164
  "strong",
13836
14165
  {
13837
14166
  className: "w100n-docs-title",
@@ -13840,205 +14169,209 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13840
14169
  children: doc.data?.name ?? t.documents
13841
14170
  }
13842
14171
  ),
13843
- docbar ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref: setMenusAt, className: "w100n-docs-menus" }) : crumbs.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-crumbs", children: crumbs.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { children: [
13844
- i > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.ChevronRight, { "aria-hidden": true }),
14172
+ docbar ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { ref: setMenusAt, className: "w100n-docs-menus" }) : crumbs.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-crumbs", children: crumbs.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { children: [
14173
+ i > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.ChevronRight, { "aria-hidden": true }),
13845
14174
  item
13846
- ] }, i)) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-hint", children: t.hint })
14175
+ ] }, i)) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-hint", children: t.hint })
14176
+ ] }),
14177
+ versionId && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-badge", children: versions.data?.find((v) => v.id === versionId) && date(versions.data.find((v) => v.id === versionId).createdAt) }),
14178
+ versionId && text && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-action", "data-tone": "blue", "aria-pressed": comparing, onClick: () => setComparing(!comparing), children: [
14179
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.FileDiff, { "aria-hidden": true }),
14180
+ comparing ? t.hideChanges : t.showChanges
13847
14181
  ] }),
13848
- versionId && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-badge", children: versions.data?.find((v) => v.id === versionId) && date(versions.data.find((v) => v.id === versionId).createdAt) }),
13849
- versionId && here.documentId && host.restore && doc.data?.rights.edit && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: "w100n-docs-action", disabled: restoring === "busy", onClick: () => void restore(here.documentId, versionId), children: [
13850
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.RotateCcw, { "aria-hidden": true }),
14182
+ versionId && here.documentId && host.restore && doc.data?.rights.edit && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-action", disabled: restoring === "busy", onClick: () => void restore(here.documentId, versionId), children: [
14183
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.RotateCcw, { "aria-hidden": true }),
13851
14184
  t.restore
13852
14185
  ] }),
13853
- restoring === "failed" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-muted", children: t.restoreFailed }),
13854
- doc.data?.convert && host.copyAs && !versionId && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: "w100n-docs-action", "data-tone": "green", disabled: copying === "busy", onClick: () => void copyAs(doc.data), children: [
13855
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.FileSpreadsheet, { "aria-hidden": true }),
14186
+ restoring === "failed" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-muted", children: t.restoreFailed }),
14187
+ doc.data?.convert && host.copyAs && !versionId && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-action", "data-tone": "green", disabled: copying === "busy", onClick: () => void copyAs(doc.data), children: [
14188
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.FileSpreadsheet, { "aria-hidden": true }),
13856
14189
  t.copyAs
13857
14190
  ] }),
13858
- copying === "failed" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-muted", children: t.copyFailed }),
13859
- renamed2 === "failed" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-muted", children: t.renameFailed }),
13860
- docbar && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { ref: setStatusAt, className: "w100n-docs-status" }),
13861
- sharing && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: "w100n-docs-action", "aria-label": t.share, title: t.share, onClick: () => {
14191
+ copying === "failed" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-muted", children: t.copyFailed }),
14192
+ renamed2 === "failed" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-muted", children: t.renameFailed }),
14193
+ docbar && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { ref: setStatusAt, className: "w100n-docs-status" }),
14194
+ sharing && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-action", "aria-label": t.share, title: t.share, onClick: () => {
13862
14195
  setTab("sharing");
13863
14196
  side2("panel", true);
13864
14197
  }, children: [
13865
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Share2, { "aria-hidden": true }),
13866
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: t.share })
14198
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Share2, { "aria-hidden": true }),
14199
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: t.share })
13867
14200
  ] }),
13868
14201
  doc.data && !versionId && actions?.(doc.data),
13869
14202
  narrow && panelToggle,
13870
- end && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-end w100n-docs-slot", children: slot(end) })
14203
+ end && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-end w100n-docs-slot", children: slot(end) })
13871
14204
  ] }),
13872
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { ref: body, className: "w100n-docs-body", children: [
13873
- listOpen && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("aside", { className: "w100n-docs-side w100n-docs-list", "aria-label": t.documents, children: [
13874
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-head", children: [
13875
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-row", children: [
13876
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "w100n-docs-caption", children: [
13877
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Files, { "aria-hidden": true }),
14205
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { ref: body, className: "w100n-docs-body", children: [
14206
+ listOpen && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("aside", { className: "w100n-docs-side w100n-docs-list", "aria-label": t.documents, children: [
14207
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-head", children: [
14208
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-row", children: [
14209
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: "w100n-docs-caption", children: [
14210
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Files, { "aria-hidden": true }),
13878
14211
  t.documents,
13879
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: all.length })
14212
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: all.length })
13880
14213
  ] }),
13881
- host.create && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-new", onKeyDown: (e) => {
14214
+ host.create && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-new", onKeyDown: (e) => {
13882
14215
  if (e.key === "Escape" && adding) {
13883
14216
  e.stopPropagation();
13884
14217
  setAdding(false);
13885
14218
  }
13886
14219
  }, children: [
13887
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: "w100n-docs-action", "aria-haspopup": "menu", "aria-expanded": adding, disabled: sending === "busy", onClick: () => setAdding(!adding), children: [
13888
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Plus, { "aria-hidden": true }),
13889
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: sending === "busy" ? t.uploading : t.create }),
13890
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.ChevronDown, { "aria-hidden": true })
14220
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-action", "aria-haspopup": "menu", "aria-expanded": adding, disabled: sending === "busy", onClick: () => setAdding(!adding), children: [
14221
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Plus, { "aria-hidden": true }),
14222
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: sending === "busy" ? t.uploading : t.create }),
14223
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.ChevronDown, { "aria-hidden": true })
13891
14224
  ] }),
13892
- adding && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { role: "menu", className: "w100n-docs-menu", children: [
13893
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
14225
+ adding && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { role: "menu", className: "w100n-docs-menu", children: [
14226
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
13894
14227
  setAdding(false);
13895
14228
  setMaking(true);
13896
14229
  }, children: [
13897
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-all", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.FilePlus, { "aria-hidden": true }) }),
13898
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("b", { children: t.newTitle })
14230
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-all", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.FilePlus, { "aria-hidden": true }) }),
14231
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: t.newTitle })
13899
14232
  ] }),
13900
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
14233
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
13901
14234
  setAdding(false);
13902
14235
  upload.current.click();
13903
14236
  }, children: [
13904
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-all", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Upload, { "aria-hidden": true }) }),
13905
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("b", { children: t.uploadFile })
14237
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-all", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Upload, { "aria-hidden": true }) }),
14238
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: t.uploadFile })
13906
14239
  ] })
13907
14240
  ] }),
13908
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { ref: upload, type: "file", hidden: true, "aria-label": t.uploadFile, accept: ".docx,.md,.markdown,.pdf,.xlsx,.csv,.html,.htm", onChange: (e) => {
14241
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { ref: upload, type: "file", hidden: true, "aria-label": t.uploadFile, accept: ".docx,.md,.markdown,.pdf,.xlsx,.csv,.html,.htm", onChange: (e) => {
13909
14242
  const file = e.target.files?.[0];
13910
14243
  e.target.value = "";
13911
14244
  if (file) void send(file);
13912
14245
  } })
13913
14246
  ] }),
13914
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { ref: listClose, type: "button", className: "w100n-docs-close", onClick: () => side2("list", false), "aria-label": t.closeList, title: t.closeList, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.X, { "aria-hidden": true }) })
14247
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { ref: listClose, type: "button", className: "w100n-docs-close", onClick: () => side2("list", false), "aria-label": t.closeList, title: t.closeList, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.X, { "aria-hidden": true }) })
13915
14248
  ] }),
13916
- (spaces.data?.length ?? 0) > 1 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-picker", onKeyDown: (e) => {
14249
+ (spaces.data?.length ?? 0) > 1 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-picker", onKeyDown: (e) => {
13917
14250
  if (e.key !== "Escape" || !picking) return;
13918
14251
  e.stopPropagation();
13919
14252
  setPicking(false);
13920
14253
  e.currentTarget.querySelector("button").focus();
13921
14254
  }, children: [
13922
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: "w100n-docs-field", "aria-haspopup": "listbox", "aria-expanded": picking, onClick: () => setPicking(!picking), children: [
13923
- space ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-dot", style: { background: space.color ?? void 0 } }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-all", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.LayoutGrid, { "aria-hidden": true }) }),
13924
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("b", { children: space?.name ?? t.allProjects }),
13925
- !space && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-count", children: all.length }),
13926
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.ChevronDown, { "aria-hidden": true })
14255
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-field", "aria-haspopup": "listbox", "aria-expanded": picking, onClick: () => setPicking(!picking), children: [
14256
+ space ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-dot", style: { background: space.color ?? void 0 } }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-all", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.LayoutGrid, { "aria-hidden": true }) }),
14257
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: space?.name ?? t.allProjects }),
14258
+ !space && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-count", children: all.length }),
14259
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.ChevronDown, { "aria-hidden": true })
13927
14260
  ] }),
13928
- picking && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { role: "listbox", className: "w100n-docs-menu", children: [
13929
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", role: "option", "aria-selected": !spaceId, onClick: () => pick(null), children: [
13930
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-all", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.LayoutGrid, { "aria-hidden": true }) }),
13931
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("b", { children: t.allProjects }),
13932
- !spaceId && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Check, { "aria-hidden": true })
14261
+ picking && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { role: "listbox", className: "w100n-docs-menu", children: [
14262
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", role: "option", "aria-selected": !spaceId, onClick: () => pick(null), children: [
14263
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-all", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.LayoutGrid, { "aria-hidden": true }) }),
14264
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: t.allProjects }),
14265
+ !spaceId && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Check, { "aria-hidden": true })
13933
14266
  ] }),
13934
- groups2.map((group) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { role: "group", "aria-label": group || void 0, children: [
13935
- group && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "w100n-docs-menu-caption", children: group }),
13936
- (spaces.data ?? []).filter((item) => (item.group ?? "") === group).map((item) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", role: "option", "aria-selected": item.id === spaceId, onClick: () => pick(item.id), children: [
13937
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-dot", style: { background: item.color ?? void 0 } }),
13938
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("b", { children: item.name }),
13939
- !spaceId && counts.get(item.id) ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-count", children: counts.get(item.id) }) : null,
13940
- item.id === spaceId && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Check, { "aria-hidden": true })
14267
+ groups2.map((group) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { role: "group", "aria-label": group || void 0, children: [
14268
+ group && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-menu-caption", children: group }),
14269
+ (spaces.data ?? []).filter((item) => (item.group ?? "") === group).map((item) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", role: "option", "aria-selected": item.id === spaceId, onClick: () => pick(item.id), children: [
14270
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-dot", style: { background: item.color ?? void 0 } }),
14271
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: item.name }),
14272
+ !spaceId && counts.get(item.id) ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-count", children: counts.get(item.id) }) : null,
14273
+ item.id === spaceId && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Check, { "aria-hidden": true })
13941
14274
  ] }, item.id))
13942
14275
  ] }, group))
13943
14276
  ] })
13944
14277
  ] }),
13945
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-filters", children: [
13946
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "w100n-docs-field w100n-docs-search", children: [
13947
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Search, { "aria-hidden": true }),
13948
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { value: query, onChange: (event) => setQuery(event.target.value), placeholder: t.search, "aria-label": t.search })
14278
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-filters", children: [
14279
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "w100n-docs-field w100n-docs-search", children: [
14280
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Search, { "aria-hidden": true }),
14281
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { value: query, onChange: (event) => setQuery(event.target.value), placeholder: t.search, "aria-label": t.search })
13949
14282
  ] }),
13950
- present.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-types", onKeyDown: (e) => {
14283
+ present.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-types", onKeyDown: (e) => {
13951
14284
  if (e.key !== "Escape" || !typing) return;
13952
14285
  e.stopPropagation();
13953
14286
  setTyping(false);
13954
14287
  e.currentTarget.querySelector("button").focus();
13955
14288
  }, children: [
13956
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: "w100n-docs-field", "aria-haspopup": "listbox", "aria-expanded": typing, "data-on": picked.length > 0, onClick: () => setTyping(!typing), children: [
13957
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.ListFilter, { "aria-hidden": true }),
13958
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("b", { children: t.typeFilter }),
13959
- picked.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-badge", children: picked.length }),
13960
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.ChevronDown, { "aria-hidden": true })
14289
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-field", "aria-haspopup": "listbox", "aria-expanded": typing, "data-on": picked.length > 0, onClick: () => setTyping(!typing), children: [
14290
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.ListFilter, { "aria-hidden": true }),
14291
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: t.typeFilter }),
14292
+ picked.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-badge", children: picked.length }),
14293
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.ChevronDown, { "aria-hidden": true })
13961
14294
  ] }),
13962
- typing && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { role: "listbox", "aria-multiselectable": true, "aria-label": t.kind, className: "w100n-docs-menu", children: [
14295
+ typing && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { role: "listbox", "aria-multiselectable": true, "aria-label": t.kind, className: "w100n-docs-menu", children: [
13963
14296
  present.map((item) => {
13964
14297
  const Icon = icons3[item];
13965
14298
  const on2 = picked.includes(item);
13966
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", role: "option", "aria-selected": on2, onClick: () => setPicked(on2 ? picked.filter((k) => k !== item) : [...picked, item]), children: [
13967
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-box", children: on2 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Check, { "aria-hidden": true }) }),
13968
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-tile", "data-kind": item, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { "aria-hidden": true }) }),
13969
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("b", { children: t.kinds[item] }),
13970
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-count", children: all.filter((doc2) => doc2.kind === item).length })
14299
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", role: "option", "aria-selected": on2, onClick: () => setPicked(on2 ? picked.filter((k) => k !== item) : [...picked, item]), children: [
14300
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-box", children: on2 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Check, { "aria-hidden": true }) }),
14301
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-tile", "data-kind": item, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { "aria-hidden": true }) }),
14302
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: t.kinds[item] }),
14303
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-count", children: all.filter((doc2) => doc2.kind === item).length })
13971
14304
  ] }, item);
13972
14305
  }),
13973
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-menu-foot", children: [
13974
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", onClick: () => setPicked(present), children: t.selectAll }),
13975
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", onClick: () => setPicked([]), children: t.clearPick })
14306
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-menu-foot", children: [
14307
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", onClick: () => setPicked(present), children: t.selectAll }),
14308
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", onClick: () => setPicked([]), children: t.clearPick })
13976
14309
  ] })
13977
14310
  ] })
13978
14311
  ] })
13979
14312
  ] }),
13980
- picked.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-chips", role: "group", "aria-label": t.kind, children: picked.map((item) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", "aria-pressed": true, "aria-label": `${t.clearPick}: ${t.kinds[item]}`, onClick: () => setPicked(picked.filter((k) => k !== item)), children: [
14313
+ picked.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-chips", role: "group", "aria-label": t.kind, children: picked.map((item) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", "aria-pressed": true, "aria-label": `${t.clearPick}: ${t.kinds[item]}`, onClick: () => setPicked(picked.filter((k) => k !== item)), children: [
13981
14314
  t.kinds[item],
13982
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.X, { "aria-hidden": true })
14315
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.X, { "aria-hidden": true })
13983
14316
  ] }, item)) })
13984
14317
  ] }),
13985
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-cards", children: [
13986
- sending === "failed" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "w100n-docs-muted", role: "alert", children: t.uploadFailed }),
14318
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-cards", children: [
14319
+ sending === "failed" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-muted", role: "alert", children: t.uploadFailed }),
13987
14320
  list.error && failed(list.retry),
13988
- list.loading && !list.data && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "w100n-docs-muted", children: t.loading }),
13989
- list.data && !shown.length && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "w100n-docs-muted", children: all.length ? t.nothing : t.empty }),
13990
- folders.map((folder2) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-folder", role: "group", "aria-label": folder2 || t.loose, children: [
13991
- folders.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "w100n-docs-group", children: folder2 || t.loose }),
13992
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-grid", children: shown.filter((item) => !spaceId || (item.folder ?? "") === folder2).map((item) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: "w100n-docs-card", "aria-current": item.id === here.documentId, onClick: () => open(item), title: item.name, children: [
13993
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Thumb, { host, item, label: t.kinds[item.kind] }),
13994
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "w100n-docs-card-text", children: [
13995
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("b", { children: item.name }),
13996
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("small", { children: [!spaceId && names2.get(item.spaceId), ago(item.updatedAt)].filter(Boolean).join(" \xB7 ") })
14321
+ list.loading && !list.data && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-muted", children: t.loading }),
14322
+ list.data && !shown.length && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-muted", children: all.length ? t.nothing : t.empty }),
14323
+ folders.map((folder2) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-folder", role: "group", "aria-label": folder2 || t.loose, children: [
14324
+ folders.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-group", children: folder2 || t.loose }),
14325
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-grid", children: shown.filter((item) => !spaceId || (item.folder ?? "") === folder2).map((item) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-card", "aria-current": item.id === here.documentId, onClick: () => open(item), title: item.name, children: [
14326
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Thumb, { host, item, label: t.kinds[item.kind] }),
14327
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "w100n-docs-card-text", children: [
14328
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: item.name }),
14329
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("small", { children: [!spaceId && names2.get(item.spaceId), ago(item.updatedAt)].filter(Boolean).join(" \xB7 ") })
13997
14330
  ] })
13998
14331
  ] }, item.id)) })
13999
14332
  ] }, folder2))
14000
14333
  ] })
14001
14334
  ] }),
14002
14335
  !narrow && !listOpen && listToggle,
14003
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("main", { className: "w100n-docs-stage", children: [
14336
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("main", { className: "w100n-docs-stage", children: [
14004
14337
  !narrow && !panelOpen && panelToggle,
14005
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-bare", children: stage })
14338
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-bare", children: stage })
14006
14339
  ] }),
14007
- doc.data && panelOpen && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("aside", { ref: panel, className: "w100n-docs-side w100n-docs-panel", "aria-label": t.details, children: [
14008
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-head", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-row", children: [
14009
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-tabs", role: "tablist", "aria-label": t.details, "data-compact": panelTabs.length > 3, onKeyDown: rove, children: panelTabs.map(([key2, Icon, label]) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", role: "tab", "aria-selected": tab === key2, tabIndex: tab === key2 ? 0 : -1, "aria-label": label, title: label, onClick: () => setTab(key2), children: [
14010
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { "aria-hidden": true }),
14011
- (panelTabs.length < 4 || tab === key2 && panelTabs.length < 5) && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: label })
14340
+ doc.data && panelOpen && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("aside", { ref: panel, className: "w100n-docs-side w100n-docs-panel", "aria-label": t.details, children: [
14341
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-head", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-row", children: [
14342
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-tabs", role: "tablist", "aria-label": t.details, "data-compact": panelTabs.length > 3, onKeyDown: rove, children: panelTabs.map(([key2, Icon, label]) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", role: "tab", "aria-selected": tab === key2, tabIndex: tab === key2 ? 0 : -1, "aria-label": label, title: label, onClick: () => setTab(key2), children: [
14343
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { "aria-hidden": true }),
14344
+ (panelTabs.length < 4 || tab === key2 && panelTabs.length < 5) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: label })
14012
14345
  ] }, key2)) }),
14013
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "w100n-docs-close", onClick: () => side2("panel", false), "aria-label": t.closePanel, title: t.closePanel, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.X, { "aria-hidden": true }) })
14346
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: "w100n-docs-close", onClick: () => side2("panel", false), "aria-label": t.closePanel, title: t.closePanel, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.X, { "aria-hidden": true }) })
14014
14347
  ] }) }),
14015
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-panel-body", role: "tabpanel", "aria-label": panelTabs.find(([key2]) => key2 === tab)?.[2], children: [
14016
- tab === "outline" && (outline2.length ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("nav", { className: "w100n-docs-outline", "aria-label": t.outline, children: [
14017
- now && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-reading", children: [
14018
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("i", { style: { width: `${Math.round(now.progress * 100)}%` } }) }),
14019
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("small", { children: [
14348
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-panel-body", role: "tabpanel", "aria-label": panelTabs.find(([key2]) => key2 === tab)?.[2], children: [
14349
+ tab === "outline" && (outline2.length ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("nav", { className: "w100n-docs-outline", "aria-label": t.outline, children: [
14350
+ now && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-reading", children: [
14351
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("i", { style: { width: `${Math.round(now.progress * 100)}%` } }) }),
14352
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("small", { children: [
14020
14353
  Math.round(now.progress * 100),
14021
14354
  "% ",
14022
14355
  t.read
14023
14356
  ] })
14024
14357
  ] }),
14025
- outline2.length > 8 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "w100n-docs-field w100n-docs-search", children: [
14026
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Search, { "aria-hidden": true }),
14027
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { value: hunt, onChange: (e) => setHunt(e.target.value), placeholder: t.findHeading, "aria-label": t.findHeading })
14358
+ outline2.length > 8 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "w100n-docs-field w100n-docs-search", children: [
14359
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Search, { "aria-hidden": true }),
14360
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { value: hunt, onChange: (e) => setHunt(e.target.value), placeholder: t.findHeading, "aria-label": t.findHeading })
14028
14361
  ] }),
14029
14362
  chapters.map((c, i) => {
14030
- const subs = words2.length ? c.subs.filter(hit) : c.subs;
14031
- if (words2.length && !hit(c.head) && !subs.length) return null;
14032
- const opened3 = words2.length > 0 || (fold[c.head.id] ?? i === reached);
14363
+ const subs = words3.length ? c.subs.filter(hit) : c.subs;
14364
+ if (words3.length && !hit(c.head) && !subs.length) return null;
14365
+ const opened3 = words3.length > 0 || (fold[c.head.id] ?? i === reached);
14033
14366
  const named3 = /^(\d+)[.)]?\s+(.+)$/.exec(c.head.text);
14034
14367
  const mark = c.subs.findIndex((s) => s.id === now?.id);
14035
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-chapter", "data-state": reached < 0 ? void 0 : i < reached ? "done" : i === reached ? "now" : void 0, children: [
14036
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-chapter-row", children: [
14037
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: "w100n-docs-chapter-go", "aria-label": c.head.text, "aria-current": now?.id === c.head.id ? "location" : void 0, onClick: () => reach(c.head), children: [
14038
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-chapter-num", children: named3 ? named3[1] : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Bookmark, { "aria-hidden": true }) }),
14039
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("b", { children: named3 ? named3[2] : c.head.text })
14368
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-chapter", "data-state": reached < 0 ? void 0 : i < reached ? "done" : i === reached ? "now" : void 0, children: [
14369
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-chapter-row", children: [
14370
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-chapter-go", "aria-label": c.head.text, "aria-current": now?.id === c.head.id ? "location" : void 0, onClick: () => reach(c.head), children: [
14371
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-chapter-num", children: named3 ? named3[1] : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Bookmark, { "aria-hidden": true }) }),
14372
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: named3 ? named3[2] : c.head.text })
14040
14373
  ] }),
14041
- c.subs.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
14374
+ c.subs.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
14042
14375
  "button",
14043
14376
  {
14044
14377
  type: "button",
@@ -14048,13 +14381,13 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
14048
14381
  title: opened3 ? t.hideSections : t.showSections,
14049
14382
  onClick: () => setFold({ ...fold, [c.head.id]: !opened3 }),
14050
14383
  children: [
14051
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("small", { children: c.subs.length }),
14052
- opened3 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.ChevronDown, { "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.ChevronRight, { "aria-hidden": true })
14384
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("small", { children: c.subs.length }),
14385
+ opened3 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.ChevronDown, { "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.ChevronRight, { "aria-hidden": true })
14053
14386
  ]
14054
14387
  }
14055
14388
  )
14056
14389
  ] }),
14057
- opened3 && subs.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-sections", children: subs.map((s) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
14390
+ opened3 && subs.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-sections", children: subs.map((s) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
14058
14391
  "button",
14059
14392
  {
14060
14393
  type: "button",
@@ -14063,7 +14396,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
14063
14396
  "data-state": i < reached || i === reached && c.subs.indexOf(s) < mark ? "done" : void 0,
14064
14397
  "aria-current": now?.id === s.id ? "location" : void 0,
14065
14398
  children: [
14066
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("i", { "aria-hidden": true }),
14399
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("i", { "aria-hidden": true }),
14067
14400
  s.text
14068
14401
  ]
14069
14402
  },
@@ -14071,46 +14404,46 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
14071
14404
  )) })
14072
14405
  ] }, c.head.id);
14073
14406
  })
14074
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "w100n-docs-muted", children: t.noOutline })),
14075
- tab === "versions" && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-versions", children: [
14407
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-muted", children: t.noOutline })),
14408
+ tab === "versions" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-versions", children: [
14076
14409
  versions.error && failed(versions.retry),
14077
- (versions.data ?? []).map((item) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
14410
+ (versions.data ?? []).map((item) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
14078
14411
  "button",
14079
14412
  {
14080
14413
  type: "button",
14081
14414
  "aria-pressed": (versionId ?? "current") === item.id || !versionId && item.current,
14082
14415
  onClick: () => view(item.current ? null : item.id),
14083
14416
  children: [
14084
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("b", { children: [
14417
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("b", { children: [
14085
14418
  date(item.createdAt),
14086
- item.current && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-badge", children: t.current })
14419
+ item.current && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-badge", children: t.current })
14087
14420
  ] }),
14088
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("small", { children: [item.author?.name, size2(item.size), item.note].filter(Boolean).join(" \xB7 ") })
14421
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("small", { children: [item.author?.name, size2(item.size), item.note].filter(Boolean).join(" \xB7 ") })
14089
14422
  ]
14090
14423
  },
14091
14424
  item.id
14092
14425
  ))
14093
14426
  ] }),
14094
- tab === "details" && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("dl", { className: "w100n-docs-details", children: [
14095
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t.kind }),
14096
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: t.kinds[doc.data.kind] }),
14097
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t.size }),
14098
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: size2(doc.data.size) }),
14099
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t.updated }),
14100
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: date(doc.data.updatedAt) }),
14101
- doc.data.updatedBy && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
14102
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t.by }),
14103
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: doc.data.updatedBy.name })
14427
+ tab === "details" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("dl", { className: "w100n-docs-details", children: [
14428
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t.kind }),
14429
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: t.kinds[doc.data.kind] }),
14430
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t.size }),
14431
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: size2(doc.data.size) }),
14432
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t.updated }),
14433
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: date(doc.data.updatedAt) }),
14434
+ doc.data.updatedBy && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
14435
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t.by }),
14436
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: doc.data.updatedBy.name })
14104
14437
  ] }),
14105
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t.rights }),
14106
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: [doc.data.rights.view && t.view, doc.data.rights.comment && t.comment, doc.data.rights.edit && t.edit].filter(Boolean).join(", ") })
14438
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t.rights }),
14439
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: [doc.data.rights.view && t.view, doc.data.rights.comment && t.comment, doc.data.rights.edit && t.edit].filter(Boolean).join(", ") })
14107
14440
  ] }),
14108
- tab === "details" && host.exportAs && !!doc.data.exports?.length && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-about", children: [
14109
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "w100n-docs-caption", children: [
14110
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.FileDown, { "aria-hidden": true }),
14441
+ tab === "details" && host.exportAs && !!doc.data.exports?.length && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-about", children: [
14442
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: "w100n-docs-caption", children: [
14443
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.FileDown, { "aria-hidden": true }),
14111
14444
  t.exportAs
14112
14445
  ] }),
14113
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-chips", children: doc.data.exports.map((format) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
14446
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-chips", children: doc.data.exports.map((format) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
14114
14447
  "button",
14115
14448
  {
14116
14449
  type: "button",
@@ -14118,22 +14451,22 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
14118
14451
  disabled: exporting === "busy",
14119
14452
  onClick: () => void exportAs(doc.data, format),
14120
14453
  children: [
14121
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.FileDown, { "aria-hidden": true }),
14454
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.FileDown, { "aria-hidden": true }),
14122
14455
  format.toUpperCase()
14123
14456
  ]
14124
14457
  },
14125
14458
  format
14126
14459
  )) }),
14127
- exporting === "failed" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "w100n-docs-muted", children: t.exportFailed })
14460
+ exporting === "failed" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-muted", children: t.exportFailed })
14128
14461
  ] }),
14129
- tab === "comments" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref: setBox }),
14130
- tab === "sharing" && sharing && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Sharing, { host, doc: doc.data, t, language, team: names2.get(doc.data.spaceId) }),
14131
- tab === "signatures" && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-versions", children: [
14462
+ tab === "comments" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { ref: setBox }),
14463
+ tab === "sharing" && sharing && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Sharing, { host, doc: doc.data, t, language, team: names2.get(doc.data.spaceId) }),
14464
+ tab === "signatures" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-versions", children: [
14132
14465
  signatures.error && failed(signatures.retry),
14133
- signatures.data?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "w100n-docs-muted", children: t.noSignatures }),
14466
+ signatures.data?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-muted", children: t.noSignatures }),
14134
14467
  (signatures.data ?? []).map((entry2) => {
14135
14468
  const signed = versions.data?.find((v) => v.id === entry2.versionId);
14136
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
14469
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
14137
14470
  "button",
14138
14471
  {
14139
14472
  type: "button",
@@ -14141,15 +14474,15 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
14141
14474
  "aria-pressed": !!signed && (versionId ?? versions.data?.find((v) => v.current)?.id) === signed.id,
14142
14475
  onClick: () => view(signed.current ? null : signed.id),
14143
14476
  children: [
14144
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("b", { children: [
14477
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("b", { children: [
14145
14478
  entry2.signer.name,
14146
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "w100n-docs-badge", children: [
14479
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "w100n-docs-badge", children: [
14147
14480
  t.page,
14148
14481
  " ",
14149
14482
  entry2.page
14150
14483
  ] })
14151
14484
  ] }),
14152
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("small", { children: [date(entry2.signedAt), t.methods[entry2.method], signed && (signed.current ? t.current : `${t.version} ${date(signed.createdAt)}`)].filter(Boolean).join(" \xB7 ") })
14485
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("small", { children: [date(entry2.signedAt), t.methods[entry2.method], signed && (signed.current ? t.current : `${t.version} ${date(signed.createdAt)}`)].filter(Boolean).join(" \xB7 ") })
14153
14486
  ]
14154
14487
  },
14155
14488
  entry2.id
@@ -14160,7 +14493,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
14160
14493
  ] })
14161
14494
  ] })
14162
14495
  ] }),
14163
- making && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(NewDocument, { host, t, onClose: () => setMaking(false), onMade: (made2) => {
14496
+ making && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(NewDocument, { host, t, onClose: () => setMaking(false), onMade: (made2) => {
14164
14497
  setMaking(false);
14165
14498
  opened2(made2);
14166
14499
  } }),
@@ -14173,7 +14506,7 @@ var import_react17 = require("react");
14173
14506
  var import_lucide_react11 = require("lucide-react");
14174
14507
  init_text();
14175
14508
  init_useLoad();
14176
- var import_jsx_runtime13 = require("react/jsx-runtime");
14509
+ var import_jsx_runtime14 = require("react/jsx-runtime");
14177
14510
  var TextEditor4 = (0, import_react17.lazy)(() => Promise.resolve().then(() => (init_TextEditor(), TextEditor_exports)));
14178
14511
  var SheetView4 = (0, import_react17.lazy)(() => Promise.resolve().then(() => (init_SheetView(), SheetView_exports)));
14179
14512
  var icons4 = { docx: import_lucide_react11.FileText, markdown: import_lucide_react11.FileType, pdf: import_lucide_react11.Files, sheet: import_lucide_react11.FileSpreadsheet, slides: import_lucide_react11.Presentation };
@@ -14208,7 +14541,7 @@ function GuestDocument({ host, language = "en", theme = "light", brand }) {
14208
14541
  const [slot, setSlot] = (0, import_react17.useState)(null);
14209
14542
  const [saving, setSaving] = (0, import_react17.useState)("idle");
14210
14543
  const opened2 = useLoad((signal) => host.open(ask, { signal }), [host, ask]);
14211
- const [notes2] = (0, import_react17.useState)(() => ({
14544
+ const [notes3] = (0, import_react17.useState)(() => ({
14212
14545
  me: { id: "", name: "" },
14213
14546
  spaces: async () => [],
14214
14547
  documents: async () => [],
@@ -14235,17 +14568,17 @@ function GuestDocument({ host, language = "en", theme = "light", brand }) {
14235
14568
  const top = (file2, badge) => {
14236
14569
  const kind2 = file2 ? kindOf(file2.name, file2.mimeType) : null;
14237
14570
  const Kind = kind2 ? icons4[kind2] : import_lucide_react11.FileText;
14238
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("header", { className: "w100n-docs-bar w100n-guest-bar", children: [
14239
- brand && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-guest-brand", children: brand }),
14240
- file2 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
14241
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-tile", "data-kind": kind2, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Kind, { "aria-hidden": true }) }),
14242
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-heading", children: [
14243
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("strong", { className: "w100n-docs-title", children: file2.name }),
14244
- file2.sharedBy && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-crumbs", children: t.sharedBy.replace("{name}", file2.sharedBy) })
14571
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("header", { className: "w100n-docs-bar w100n-guest-bar", children: [
14572
+ brand && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "w100n-guest-brand", children: brand }),
14573
+ file2 && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
14574
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "w100n-docs-tile", "data-kind": kind2, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Kind, { "aria-hidden": true }) }),
14575
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs-heading", children: [
14576
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("strong", { className: "w100n-docs-title", children: file2.name }),
14577
+ file2.sharedBy && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "w100n-docs-crumbs", children: t.sharedBy.replace("{name}", file2.sharedBy) })
14245
14578
  ] }),
14246
- badge && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-badge", "data-kind": kind2, children: badge }),
14247
- file2.download && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-end", children: [
14248
- (kind2 === "docx" || kind2 === "markdown" || kind2 === "sheet" || kind2 === "slides") && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
14579
+ badge && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "w100n-docs-badge", "data-kind": kind2, children: badge }),
14580
+ file2.download && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs-end", children: [
14581
+ (kind2 === "docx" || kind2 === "markdown" || kind2 === "sheet" || kind2 === "slides") && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
14249
14582
  "button",
14250
14583
  {
14251
14584
  type: "button",
@@ -14256,25 +14589,25 @@ function GuestDocument({ host, language = "en", theme = "light", brand }) {
14256
14589
  "aria-label": t.pdfCopy,
14257
14590
  title: t.pdfCopy,
14258
14591
  children: [
14259
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react11.FileDown, { "aria-hidden": true }),
14260
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: t.pdfCopy })
14592
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react11.FileDown, { "aria-hidden": true }),
14593
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: t.pdfCopy })
14261
14594
  ]
14262
14595
  }
14263
14596
  ),
14264
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-action", "data-tone": "blue", disabled: saving === "busy", onClick: () => void download("file"), "aria-label": t.download, title: t.download, children: [
14265
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react11.Download, { "aria-hidden": true }),
14266
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: t.download })
14597
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "button", className: "w100n-docs-action", "data-tone": "blue", disabled: saving === "busy", onClick: () => void download("file"), "aria-label": t.download, title: t.download, children: [
14598
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react11.Download, { "aria-hidden": true }),
14599
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: t.download })
14267
14600
  ] })
14268
14601
  ] })
14269
14602
  ] })
14270
14603
  ] });
14271
14604
  };
14272
- const gate = (tone, Icon, title, body, form) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs w100n-guest", "data-theme": theme, children: [
14605
+ const gate = (tone, Icon, title, body, form) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs w100n-guest", "data-theme": theme, children: [
14273
14606
  top(null, null),
14274
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-guest-gate", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-guest-card", children: [
14275
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-share-tile", "data-tone": tone, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { "aria-hidden": true }) }),
14276
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h2", { children: title }),
14277
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: body }),
14607
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "w100n-guest-gate", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-guest-card", children: [
14608
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "w100n-share-tile", "data-tone": tone, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { "aria-hidden": true }) }),
14609
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h2", { children: title }),
14610
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { children: body }),
14278
14611
  form
14279
14612
  ] }) })
14280
14613
  ] });
@@ -14290,7 +14623,7 @@ function GuestDocument({ host, language = "en", theme = "light", brand }) {
14290
14623
  password ? import_lucide_react11.Lock : import_lucide_react11.UserRound,
14291
14624
  refused.file || t.documents,
14292
14625
  shared + (password ? t.passwordAsk : t.nameAsk),
14293
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("form", { className: "w100n-guest-form", onSubmit: (e) => {
14626
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("form", { className: "w100n-guest-form", onSubmit: (e) => {
14294
14627
  e.preventDefault();
14295
14628
  if (!typed.trim()) return;
14296
14629
  if (password) setAsk({ ...ask, password: typed });
@@ -14300,7 +14633,7 @@ function GuestDocument({ host, language = "en", theme = "light", brand }) {
14300
14633
  }
14301
14634
  setTyped("");
14302
14635
  }, children: [
14303
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
14636
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
14304
14637
  "input",
14305
14638
  {
14306
14639
  className: "w100n-share-input",
@@ -14313,21 +14646,21 @@ function GuestDocument({ host, language = "en", theme = "light", brand }) {
14313
14646
  onChange: (e) => setTyped(e.target.value)
14314
14647
  }
14315
14648
  ),
14316
- refused.reason === "wrong" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-muted", role: "alert", children: t.wrongPassword }),
14317
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "submit", className: "w100n-docs-action", disabled: !typed.trim(), children: [
14318
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react11.Eye, { "aria-hidden": true }),
14649
+ refused.reason === "wrong" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "w100n-docs-muted", role: "alert", children: t.wrongPassword }),
14650
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "submit", className: "w100n-docs-action", disabled: !typed.trim(), children: [
14651
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react11.Eye, { "aria-hidden": true }),
14319
14652
  t.openDoc
14320
14653
  ] })
14321
14654
  ] })
14322
14655
  );
14323
14656
  }
14324
14657
  if (refused?.reason === "busy") return gate("slate", import_lucide_react11.Ban, t.failed, t.tooMany);
14325
- return gate("slate", import_lucide_react11.Ban, t.failed, "", /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: "w100n-docs-action", onClick: opened2.retry, children: t.retry }));
14658
+ return gate("slate", import_lucide_react11.Ban, t.failed, "", /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: "w100n-docs-action", onClick: opened2.retry, children: t.retry }));
14326
14659
  }
14327
14660
  const file = opened2.data;
14328
- if (!file) return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs w100n-guest", "data-theme": theme, children: [
14661
+ if (!file) return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs w100n-guest", "data-theme": theme, children: [
14329
14662
  top(null, null),
14330
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-empty", children: t.loading })
14663
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "w100n-docs-empty", children: t.loading })
14331
14664
  ] });
14332
14665
  const kind = kindOf(file.name, file.mimeType);
14333
14666
  const text = kind === "docx" || kind === "markdown";
@@ -14335,23 +14668,23 @@ function GuestDocument({ host, language = "en", theme = "light", brand }) {
14335
14668
  const rights = { view: true, comment: talk, edit: false };
14336
14669
  const quiet3 = () => {
14337
14670
  };
14338
- let stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-empty", children: t.unsupported });
14339
- if (text) stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react17.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-empty", children: t.loading }), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TextEditor4, { kind, bytes: file.bytes, t, language, rights, host: talk ? notes2 : void 0, documentId: file.id, onOutline: quiet3, slot: talk ? slot : null }) });
14340
- else if (kind === "pdf") stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(PdfView, { bytes: file.bytes, t, language, worker: host.pdfWorker, rights, documentId: file.id, onOutline: quiet3 });
14341
- else if (kind === "slides") stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SlidesView, { html: new TextDecoder().decode(file.bytes), name: file.name, rights, language, theme, onOutline: quiet3 });
14342
- else if (kind === "sheet") stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react17.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-empty", children: t.loading }), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SheetView4, { bytes: file.bytes, name: file.name, kind: /\.csv$/i.test(file.name) || file.mimeType === "text/csv" ? "csv" : "xlsx", rights, language, theme, documentId: file.id }) });
14343
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs w100n-guest", "data-theme": theme, children: [
14671
+ let stage = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "w100n-docs-empty", children: t.unsupported });
14672
+ if (text) stage = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react17.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "w100n-docs-empty", children: t.loading }), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TextEditor4, { kind, bytes: file.bytes, t, language, rights, host: talk ? notes3 : void 0, documentId: file.id, onOutline: quiet3, slot: talk ? slot : null }) });
14673
+ else if (kind === "pdf") stage = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(PdfView, { bytes: file.bytes, t, language, worker: host.pdfWorker, rights, documentId: file.id, onOutline: quiet3 });
14674
+ else if (kind === "slides") stage = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SlidesView, { html: new TextDecoder().decode(file.bytes), name: file.name, rights, language, theme, onOutline: quiet3 });
14675
+ else if (kind === "sheet") stage = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react17.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "w100n-docs-empty", children: t.loading }), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SheetView4, { bytes: file.bytes, name: file.name, kind: /\.csv$/i.test(file.name) || file.mimeType === "text/csv" ? "csv" : "xlsx", rights, language, theme, documentId: file.id }) });
14676
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs w100n-guest", "data-theme": theme, children: [
14344
14677
  top(file, talk ? t.badgeComment : t.badgeRead),
14345
- saving === "failed" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-muted w100n-guest-note", role: "alert", children: t.exportFailed }),
14346
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-body w100n-guest-body", children: [
14347
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("main", { className: "w100n-docs-stage", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-bare", children: stage }) }),
14348
- talk && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("aside", { className: "w100n-docs-side w100n-docs-panel w100n-guest-panel", "aria-label": t.comments, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-panel-body", children: [
14349
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "w100n-share-field", children: [
14350
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: t.yourName }),
14351
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { className: "w100n-share-input", value: name, autoComplete: "name", placeholder: t.yourName, onChange: (e) => typeName(e.target.value) })
14678
+ saving === "failed" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "w100n-docs-muted w100n-guest-note", role: "alert", children: t.exportFailed }),
14679
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs-body w100n-guest-body", children: [
14680
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("main", { className: "w100n-docs-stage", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "w100n-docs-bare", children: stage }) }),
14681
+ talk && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("aside", { className: "w100n-docs-side w100n-docs-panel w100n-guest-panel", "aria-label": t.comments, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs-panel-body", children: [
14682
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "w100n-share-field", children: [
14683
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: t.yourName }),
14684
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { className: "w100n-share-input", value: name, autoComplete: "name", placeholder: t.yourName, onChange: (e) => typeName(e.target.value) })
14352
14685
  ] }),
14353
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-muted", children: name.trim() ? t.nameHint : t.nameNeeded }),
14354
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { ref: setSlot })
14686
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "w100n-docs-muted", children: name.trim() ? t.nameHint : t.nameNeeded }),
14687
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ref: setSlot })
14355
14688
  ] }) })
14356
14689
  ] })
14357
14690
  ] });