@arbidocs/blocks 0.4.111 → 0.4.113

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.
Files changed (98) hide show
  1. package/dist/{NativeDocxEditor-AQKRZBIU.cjs → NativeDocxEditor-AQZSUGET.cjs} +8 -8
  2. package/dist/{NativeDocxEditor-AQKRZBIU.cjs.map → NativeDocxEditor-AQZSUGET.cjs.map} +1 -1
  3. package/dist/{NativeDocxEditor-IN2HEO5I.js → NativeDocxEditor-MBCBXYDZ.js} +4 -4
  4. package/dist/{NativeDocxEditor-IN2HEO5I.js.map → NativeDocxEditor-MBCBXYDZ.js.map} +1 -1
  5. package/dist/chat/index.cjs +131 -131
  6. package/dist/chat/index.js +4 -4
  7. package/dist/{chunk-2C7TCVQZ.js → chunk-3OT37I24.js} +30 -297
  8. package/dist/chunk-3OT37I24.js.map +1 -0
  9. package/dist/{chunk-HBBJYRGI.cjs → chunk-5U4WY2VW.cjs} +9 -9
  10. package/dist/{chunk-HBBJYRGI.cjs.map → chunk-5U4WY2VW.cjs.map} +1 -1
  11. package/dist/{chunk-XKSFJYOD.cjs → chunk-5UHAWSEX.cjs} +4 -4
  12. package/dist/{chunk-XKSFJYOD.cjs.map → chunk-5UHAWSEX.cjs.map} +1 -1
  13. package/dist/{chunk-KZJAG7T3.js → chunk-7XF5SFJ2.js} +3 -3
  14. package/dist/{chunk-KZJAG7T3.js.map → chunk-7XF5SFJ2.js.map} +1 -1
  15. package/dist/{chunk-VGOFFCMT.cjs → chunk-B6MVQCXW.cjs} +3 -3
  16. package/dist/{chunk-VGOFFCMT.cjs.map → chunk-B6MVQCXW.cjs.map} +1 -1
  17. package/dist/{chunk-VLOPZHFH.js → chunk-D3N67Q4D.js} +3 -3
  18. package/dist/{chunk-VLOPZHFH.js.map → chunk-D3N67Q4D.js.map} +1 -1
  19. package/dist/{chunk-XIGWUDOD.cjs → chunk-ETBB5KMN.cjs} +61 -316
  20. package/dist/chunk-ETBB5KMN.cjs.map +1 -0
  21. package/dist/{chunk-Q6B77ZWZ.js → chunk-GIBRZ54P.js} +3 -3
  22. package/dist/{chunk-Q6B77ZWZ.js.map → chunk-GIBRZ54P.js.map} +1 -1
  23. package/dist/{chunk-2WO5L7YT.cjs → chunk-HF4PAYBM.cjs} +5 -5
  24. package/dist/{chunk-2WO5L7YT.cjs.map → chunk-HF4PAYBM.cjs.map} +1 -1
  25. package/dist/chunk-I2QSDQQV.cjs +126 -0
  26. package/dist/chunk-I2QSDQQV.cjs.map +1 -0
  27. package/dist/{chunk-BV7FEMSI.js → chunk-OKERRHLH.js} +3 -3
  28. package/dist/{chunk-BV7FEMSI.js.map → chunk-OKERRHLH.js.map} +1 -1
  29. package/dist/{chunk-CXZ7FPTQ.js → chunk-PKZYL2KU.js} +3 -3
  30. package/dist/{chunk-CXZ7FPTQ.js.map → chunk-PKZYL2KU.js.map} +1 -1
  31. package/dist/{chunk-NRUPUDWB.js → chunk-PXE5BNK6.js} +3 -3
  32. package/dist/{chunk-NRUPUDWB.js.map → chunk-PXE5BNK6.js.map} +1 -1
  33. package/dist/chunk-QXMR5YHC.js +80 -0
  34. package/dist/chunk-QXMR5YHC.js.map +1 -0
  35. package/dist/{chunk-TF47ATYS.cjs → chunk-RUFNJRLW.cjs} +4 -4
  36. package/dist/{chunk-TF47ATYS.cjs.map → chunk-RUFNJRLW.cjs.map} +1 -1
  37. package/dist/{chunk-HBF4BDRU.cjs → chunk-S6BOINC4.cjs} +7 -7
  38. package/dist/{chunk-HBF4BDRU.cjs.map → chunk-S6BOINC4.cjs.map} +1 -1
  39. package/dist/{chunk-6RHHMBZ5.js → chunk-TAXKPPNC.js} +5 -5
  40. package/dist/{chunk-6RHHMBZ5.js.map → chunk-TAXKPPNC.js.map} +1 -1
  41. package/dist/{chunk-WTM65ZNG.js → chunk-TKJSCHSX.js} +3 -3
  42. package/dist/{chunk-WTM65ZNG.js.map → chunk-TKJSCHSX.js.map} +1 -1
  43. package/dist/{chunk-2UAJVK3C.cjs → chunk-UAMZXRYJ.cjs} +4 -4
  44. package/dist/{chunk-2UAJVK3C.cjs.map → chunk-UAMZXRYJ.cjs.map} +1 -1
  45. package/dist/{chunk-WPVIOGDG.cjs → chunk-US5ASM4G.cjs} +22 -22
  46. package/dist/{chunk-WPVIOGDG.cjs.map → chunk-US5ASM4G.cjs.map} +1 -1
  47. package/dist/{chunk-CECWAIHL.js → chunk-XFZ7HNPG.js} +3 -3
  48. package/dist/{chunk-CECWAIHL.js.map → chunk-XFZ7HNPG.js.map} +1 -1
  49. package/dist/{chunk-VP4KJ4LK.cjs → chunk-XZB2QP76.cjs} +7 -7
  50. package/dist/{chunk-VP4KJ4LK.cjs.map → chunk-XZB2QP76.cjs.map} +1 -1
  51. package/dist/connect/docx.cjs +7 -7
  52. package/dist/connect/docx.js +5 -5
  53. package/dist/connect/index.cjs +29 -29
  54. package/dist/connect/index.js +11 -11
  55. package/dist/docx/definitions/commands.d.ts +3 -52
  56. package/dist/docx/definitions/fragment.d.ts +5 -31
  57. package/dist/docx/definitions/port.d.ts +2 -22
  58. package/dist/docx/index.cjs +47 -47
  59. package/dist/docx/index.js +4 -4
  60. package/dist/docx/references/commands.d.ts +3 -89
  61. package/dist/docx/references/port.d.ts +2 -11
  62. package/dist/index.cjs +386 -386
  63. package/dist/index.js +13 -13
  64. package/dist/settings/index.cjs +1 -1
  65. package/dist/settings/index.js +1 -1
  66. package/dist/shell/Shell.d.ts +5 -0
  67. package/dist/shell/index.cjs +60 -60
  68. package/dist/shell/index.js +3 -3
  69. package/dist/studio/index.cjs +4 -4
  70. package/dist/studio/index.js +3 -3
  71. package/dist/tags/definitions.d.ts +4 -25
  72. package/dist/tags/ooxml.d.ts +1 -19
  73. package/node_modules/@arbidocs/coedit/dist/commands.cjs +687 -0
  74. package/node_modules/@arbidocs/coedit/dist/commands.cjs.map +1 -1
  75. package/node_modules/@arbidocs/coedit/dist/commands.d.cts +263 -157
  76. package/node_modules/@arbidocs/coedit/dist/commands.d.ts +263 -157
  77. package/node_modules/@arbidocs/coedit/dist/commands.js +646 -2
  78. package/node_modules/@arbidocs/coedit/dist/commands.js.map +1 -1
  79. package/node_modules/@arbidocs/coedit/dist/port-ip7WByvH.d.cts +188 -0
  80. package/node_modules/@arbidocs/coedit/dist/port-ip7WByvH.d.ts +188 -0
  81. package/node_modules/@arbidocs/coedit/dist/server.cjs +675 -65
  82. package/node_modules/@arbidocs/coedit/dist/server.cjs.map +1 -1
  83. package/node_modules/@arbidocs/coedit/dist/server.d.cts +15 -4
  84. package/node_modules/@arbidocs/coedit/dist/server.d.ts +15 -4
  85. package/node_modules/@arbidocs/coedit/dist/server.js +676 -67
  86. package/node_modules/@arbidocs/coedit/dist/server.js.map +1 -1
  87. package/node_modules/@arbidocs/coedit/dist/template.d.cts +3 -17
  88. package/node_modules/@arbidocs/coedit/dist/template.d.ts +3 -17
  89. package/node_modules/@arbidocs/coedit/dist/track-eYC94jTp.d.cts +17 -0
  90. package/node_modules/@arbidocs/coedit/dist/track-eYC94jTp.d.ts +17 -0
  91. package/node_modules/@arbidocs/coedit/package.json +1 -1
  92. package/package.json +4 -4
  93. package/dist/chunk-2A4MDHJR.cjs +0 -198
  94. package/dist/chunk-2A4MDHJR.cjs.map +0 -1
  95. package/dist/chunk-2C7TCVQZ.js.map +0 -1
  96. package/dist/chunk-EPHGD4YV.js +0 -174
  97. package/dist/chunk-EPHGD4YV.js.map +0 -1
  98. package/dist/chunk-XIGWUDOD.cjs.map +0 -1
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  var chunk5FYU7ZIU_cjs = require('./chunk-5FYU7ZIU.cjs');
5
- var chunk2A4MDHJR_cjs = require('./chunk-2A4MDHJR.cjs');
5
+ var chunkI2QSDQQV_cjs = require('./chunk-I2QSDQQV.cjs');
6
6
  var chunk7UTB4PHM_cjs = require('./chunk-7UTB4PHM.cjs');
7
7
  var fflate = require('fflate');
8
8
  var server = require('react-dom/server');
@@ -1010,7 +1010,7 @@ function DocxCommentActivity() {
1010
1010
  const thread = review.items.filter(
1011
1011
  (entry) => entry.kind === "comment" && (entry.item.id === commentId || entry.parentId === commentId)
1012
1012
  );
1013
- const statuses = Object.entries(activity).filter(([, run2]) => run2.commentId === commentId);
1013
+ const statuses = Object.entries(activity).filter(([, run]) => run.commentId === commentId);
1014
1014
  const labels = {
1015
1015
  delivering: "Delivering mention\u2026",
1016
1016
  queued: "Queued\u2026",
@@ -1022,18 +1022,18 @@ function DocxCommentActivity() {
1022
1022
  unknown: "Status unavailable"
1023
1023
  };
1024
1024
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-comment-extra", "data-review-selectable": "", children: [
1025
- statuses.map(([id, run2]) => /* @__PURE__ */ jsxRuntime.jsxs(
1025
+ statuses.map(([id, run]) => /* @__PURE__ */ jsxRuntime.jsxs(
1026
1026
  "div",
1027
1027
  {
1028
1028
  role: "status",
1029
1029
  "data-testid": "docx-comment-agent-status",
1030
- "data-status": run2.status,
1030
+ "data-status": run.status,
1031
1031
  className: "native-docx-comment-activity",
1032
1032
  children: [
1033
- ["delivering", "queued", "in_progress"].includes(run2.status) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-agent-spinner", "aria-hidden": "true" }),
1034
- run2.label,
1033
+ ["delivering", "queued", "in_progress"].includes(run.status) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-agent-spinner", "aria-hidden": "true" }),
1034
+ run.label,
1035
1035
  ": ",
1036
- labels[run2.status]
1036
+ labels[run.status]
1037
1037
  ]
1038
1038
  },
1039
1039
  id
@@ -1061,10 +1061,10 @@ function DocxCommentActivity() {
1061
1061
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: entry.author || "Reviewer" }),
1062
1062
  /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": "docx-full-comment-text", children: /* @__PURE__ */ jsxRuntime.jsx(ui.AiMarkdown, { allowHtml: false, children: commentText(entry) }) })
1063
1063
  ] }, entry.key)),
1064
- statuses.map(([id, run2]) => /* @__PURE__ */ jsxRuntime.jsxs("p", { role: "status", className: "text-sm", children: [
1065
- run2.label,
1064
+ statuses.map(([id, run]) => /* @__PURE__ */ jsxRuntime.jsxs("p", { role: "status", className: "text-sm", children: [
1065
+ run.label,
1066
1066
  ": ",
1067
- labels[run2.status]
1067
+ labels[run.status]
1068
1068
  ] }, id))
1069
1069
  ]
1070
1070
  }
@@ -1375,67 +1375,14 @@ function DocxMentions({
1375
1375
  }
1376
1376
  ) });
1377
1377
  }
1378
- var CHARACTER_STYLES = {
1379
- [commands.DEFINED_TERM_STYLE]: `<w:style w:type="character" w:customStyle="1" w:styleId="${commands.DEFINED_TERM_STYLE}"><w:name w:val="Defined Term"/><w:rPr><w:u w:val="dotted" w:color="7F7F7F"/></w:rPr></w:style>`,
1380
- [commands.CROSS_REFERENCE_STYLE]: `<w:style w:type="character" w:customStyle="1" w:styleId="${commands.CROSS_REFERENCE_STYLE}"><w:name w:val="Cross Reference"/><w:rPr><w:color w:val="1F4E79"/><w:u w:val="dotted" w:color="8EA9C1"/></w:rPr></w:style>`,
1381
- [commands.BROKEN_CROSS_REFERENCE_STYLE]: `<w:style w:type="character" w:customStyle="1" w:styleId="${commands.BROKEN_CROSS_REFERENCE_STYLE}"><w:name w:val="Cross Reference Broken"/><w:basedOn w:val="${commands.CROSS_REFERENCE_STYLE}"/><w:rPr><w:color w:val="C00000"/><w:u w:val="wave" w:color="C00000"/></w:rPr></w:style>`
1382
- };
1383
- function stylesUsed(body) {
1384
- return [...new Set([...body.matchAll(/<w:rStyle w:val="([^"]+)"/g)].map((m) => m[1]))];
1385
- }
1386
- var fragmentStyles = (ids) => chunk2A4MDHJR_cjs.stylesXml(
1387
- "",
1388
- `<w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/><w:qFormat/></w:style>${ids.map((id) => CHARACTER_STYLES[id] ?? "").join("")}`
1389
- );
1390
- var textRun = (text, props = "") => `<w:r>${props ? `<w:rPr>${props}</w:rPr>` : ""}<w:t xml:space="preserve">${chunk2A4MDHJR_cjs.esc(text)}</w:t></w:r>`;
1391
- function definitionTooltip(definition) {
1392
- const line = `\u201C${definition.term}\u201D${definition.rest}`.replace(/\s+/g, " ").trim();
1393
- return line.length > 255 ? `${line.slice(0, 254)}\u2026` : line;
1394
- }
1395
- function definitionParagraphXml(definition, bookmark, id = 0) {
1396
- return `<w:p><w:bookmarkStart w:id="${id}" w:name="${chunk2A4MDHJR_cjs.esc(bookmark)}"/>${textRun("\u201C")}${textRun(
1397
- definition.term,
1398
- "<w:b/>"
1399
- )}${textRun("\u201D")}<w:bookmarkEnd w:id="${id}"/>${textRun(definition.rest)}</w:p>`;
1400
- }
1401
- function headingParagraphXml(text, styleId) {
1402
- return styleId ? `<w:p><w:pPr><w:pStyle w:val="${chunk2A4MDHJR_cjs.esc(styleId)}"/></w:pPr>${textRun(text)}</w:p>` : `<w:p><w:pPr><w:keepNext/></w:pPr>${textRun(text, "<w:b/>")}</w:p>`;
1403
- }
1404
- function termLinkXml(term, bookmark, tooltip) {
1405
- return `<w:p><w:hyperlink w:anchor="${chunk2A4MDHJR_cjs.esc(bookmark)}" w:tooltip="${chunk2A4MDHJR_cjs.esc(tooltip)}" w:history="1">${textRun(
1406
- term,
1407
- `<w:rStyle w:val="${commands.DEFINED_TERM_STYLE}"/>`
1408
- )}</w:hyperlink></w:p>`;
1409
- }
1410
1378
  function base64(bytes) {
1411
1379
  let binary = "";
1412
1380
  for (let i = 0; i < bytes.length; i += 32768)
1413
1381
  binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
1414
1382
  return btoa(binary);
1415
1383
  }
1416
- function fragmentHtml(body, covered2, {
1417
- revision,
1418
- relationships,
1419
- styles = stylesUsed(body)
1420
- } = {}) {
1421
- const untracked = chunk2A4MDHJR_cjs.docxPackage({
1422
- document: chunk2A4MDHJR_cjs.documentXml(body),
1423
- styles: fragmentStyles(styles),
1424
- title: "Defined terms",
1425
- relationships
1426
- });
1427
- const bytes = revision ? template.trackInsertion(untracked, revision, covered2) : untracked;
1428
- return `<div data-docx-fragment="${base64(bytes)}" data-docx-fragment-end="${covered2 ? "covered" : "open"}"></div>`;
1429
- }
1430
- var attr = (node, name) => node.attributes?.find((a) => a.localName === name)?.value;
1431
- function documentStyleIds(root) {
1432
- const ids = /* @__PURE__ */ new Set();
1433
- for (const style of root?.children ?? [])
1434
- if (style.localName === "style") {
1435
- const id = attr(style, "styleId");
1436
- if (id) ids.add(id);
1437
- }
1438
- return ids;
1384
+ function fragmentHtml(body, covered2, options = {}) {
1385
+ return `<div data-docx-fragment="${base64(commands.fragmentPackage(body, covered2, options))}" data-docx-fragment-end="${covered2 ? "covered" : "open"}"></div>`;
1439
1386
  }
1440
1387
  function editorPort(editor, revision) {
1441
1388
  const surface = () => {
@@ -1457,8 +1404,8 @@ function editorPort(editor, revision) {
1457
1404
  surface().deleteSelection();
1458
1405
  },
1459
1406
  paste: (body, text, covered2, relationships) => {
1460
- const defined = documentStyleIds(surface().session.stylesRoot());
1461
- const styles = stylesUsed(body).filter((id) => !defined.has(id));
1407
+ const defined = commands.documentStyleIds(surface().session.stylesRoot());
1408
+ const styles = commands.stylesUsed(body).filter((id) => !defined.has(id));
1462
1409
  return editor.exec({
1463
1410
  type: "paste",
1464
1411
  text,
@@ -1590,100 +1537,6 @@ function AgentUndo() {
1590
1537
  error && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "status", className: "native-docx-comment-activity", children: error })
1591
1538
  ] });
1592
1539
  }
1593
-
1594
- // src/docx/definitions/commands.ts
1595
- var DEFINITIONS_HEADING = "Definitions";
1596
- var SECTION_TITLE = /^(definitions?(\s*(and|&)\s*interpretations?)?|interpretations?(\s*(and|&)\s*definitions?)?|defined\s+terms|glossary)$/i;
1597
- var NUMBERING = /^(?:(?:clause|section|article|schedule|part)\s+)?(?:[0-9]+(?:\.[0-9]+)*|[A-Z]|[ivxlc]+)[.):]?\s+(?:[-–—]\s*)?/i;
1598
- function isDefinitionsTitle(paragraph) {
1599
- if (!paragraph.topLevel) return false;
1600
- const title = paragraph.text.trim().replace(NUMBERING, "").replace(/[.:]+$/, "").trim();
1601
- return SECTION_TITLE.test(title) && (paragraph.heading || title.length <= 40);
1602
- }
1603
- function findDefinitionsSection(paragraphs) {
1604
- const title = paragraphs.findIndex(isDefinitionsTitle);
1605
- if (title < 0) return null;
1606
- let end = title + 1;
1607
- while (end < paragraphs.length && paragraphs[end].topLevel && !paragraphs[end].heading) end++;
1608
- return { title, start: title + 1, end };
1609
- }
1610
- var termOf = (paragraph) => chunk2A4MDHJR_cjs.parseDefinition(paragraph.text)?.term ?? null;
1611
- function insertionIndex(paragraphs, section, term, skip = /* @__PURE__ */ new Set()) {
1612
- let afterLast = section.start;
1613
- for (let i = section.start; i < section.end; i++) {
1614
- if (skip.has(paragraphs[i].id)) continue;
1615
- const other = termOf(paragraphs[i]);
1616
- if (other === null) continue;
1617
- if (chunk2A4MDHJR_cjs.compareTerms(other, term) > 0) return i;
1618
- afterLast = i + 1;
1619
- }
1620
- return afterLast;
1621
- }
1622
- var headingStyle = (paragraphs) => paragraphs.find((p) => p.topLevel && p.heading && p.styleId)?.styleId;
1623
- function insertParagraphs(port, index, body, count, keep) {
1624
- const before = port.paragraphs();
1625
- const kept = keep ? before.findIndex((p) => p.id === keep.paragraphId) : -1;
1626
- if (index < before.length) {
1627
- port.setCaret({ paragraphId: before[index].id, offset: 0 });
1628
- } else {
1629
- const last = before[before.length - 1];
1630
- port.setCaret({ paragraphId: last.id, offset: last.text.length });
1631
- port.splitParagraph();
1632
- const opened = port.paragraphs();
1633
- port.setCaret({ paragraphId: opened[opened.length - 1].id, offset: 0 });
1634
- }
1635
- if (!port.paste(body, "", true)) throw new Error("The definition could not be added.");
1636
- if (!keep || kept < 0) return keep;
1637
- const after = port.paragraphs();
1638
- const moved = index <= kept ? kept + count : kept;
1639
- return { paragraphId: after[moved]?.id ?? keep.paragraphId, offset: keep.offset };
1640
- }
1641
- function addDefinition(port, definition, keep) {
1642
- const paragraphs = port.paragraphs();
1643
- const section = findDefinitionsSection(paragraphs);
1644
- const paragraph = definitionParagraphXml(definition, chunk2A4MDHJR_cjs.definitionBookmark(definition.id));
1645
- if (section)
1646
- return insertParagraphs(
1647
- port,
1648
- insertionIndex(paragraphs, section, definition.term),
1649
- paragraph,
1650
- 1,
1651
- keep
1652
- );
1653
- return insertParagraphs(
1654
- port,
1655
- paragraphs.length,
1656
- headingParagraphXml(DEFINITIONS_HEADING, headingStyle(paragraphs)) + paragraph,
1657
- 2,
1658
- keep
1659
- );
1660
- }
1661
- var hasBookmark = (paragraphs, name) => paragraphs.some((p) => p.bookmarks.includes(name));
1662
- function insertDefinedTerm(port, definition, options = {}) {
1663
- const start = port.caret();
1664
- if (!start) throw new Error("Place the cursor where the term should go.");
1665
- let caret = start;
1666
- if (options.replace) {
1667
- caret = { paragraphId: start.paragraphId, offset: Math.max(0, start.offset - options.replace) };
1668
- port.deleteRange(caret, start);
1669
- }
1670
- const bookmark = chunk2A4MDHJR_cjs.definitionBookmark(definition.id);
1671
- const addedDefinition = !hasBookmark(port.paragraphs(), bookmark);
1672
- if (addedDefinition) caret = addDefinition(port, definition, caret) ?? caret;
1673
- port.setCaret(caret);
1674
- if (!port.paste(
1675
- termLinkXml(definition.term, bookmark, definitionTooltip(definition)),
1676
- definition.term,
1677
- false
1678
- ))
1679
- throw new Error("The term could not be inserted.");
1680
- port.setCaret({ paragraphId: caret.paragraphId, offset: caret.offset + definition.term.length });
1681
- return { addedDefinition };
1682
- }
1683
- function definitionOfAnchor(anchor, definitions) {
1684
- const id = chunk2A4MDHJR_cjs.definitionIdOfBookmark(anchor.replace(/^#/, ""));
1685
- return id ? definitions.get(id) : void 0;
1686
- }
1687
1540
  function LinkHoverCard({
1688
1541
  root,
1689
1542
  matches,
@@ -1789,7 +1642,7 @@ function trackedOrNoted(port, { label, author, insert, inserted = Boolean }) {
1789
1642
  if (before && after && port.comment(before, after, label)) return { result, how: "noted" };
1790
1643
  return { result, how: "direct" };
1791
1644
  }
1792
- var attr2 = (node, name) => node.attributes?.find((a) => a.localName === name)?.value;
1645
+ var attr = (node, name) => node.attributes?.find((a) => a.localName === name)?.value;
1793
1646
  function structuralPort(editor) {
1794
1647
  return {
1795
1648
  mode: () => editor.getEditingMode(),
@@ -1804,7 +1657,7 @@ function structuralPort(editor) {
1804
1657
  const root = editor.surface?.session.part().root;
1805
1658
  let count = 0;
1806
1659
  const visit = (node) => {
1807
- if (node.localName === "ins" && attr2(node, "author") === author && attr2(node, "date") === date)
1660
+ if (node.localName === "ins" && attr(node, "author") === author && attr(node, "date") === date)
1808
1661
  count++;
1809
1662
  node.children?.forEach(visit);
1810
1663
  };
@@ -1897,14 +1750,14 @@ function DefinedTermsProvider({
1897
1750
  },
1898
1751
  [load, sources, notify]
1899
1752
  );
1900
- const all = React4.useMemo(() => chunk2A4MDHJR_cjs.groupDefinitions(sources ?? []).groups, [sources]);
1753
+ const all = React4.useMemo(() => chunkI2QSDQQV_cjs.groupDefinitions(sources ?? []).groups, [sources]);
1901
1754
  const byId = React4.useMemo(
1902
1755
  () => new Map(all.flatMap((g) => g.definitions).map((d) => [d.id, d])),
1903
1756
  [all]
1904
1757
  );
1905
- const agreements = React4.useMemo(() => chunk2A4MDHJR_cjs.definitionLabels(sources ?? []), [sources]);
1758
+ const agreements = React4.useMemo(() => chunkI2QSDQQV_cjs.definitionLabels(sources ?? []), [sources]);
1906
1759
  const groups = React4.useMemo(
1907
- () => picker ? chunk2A4MDHJR_cjs.filterTermGroups(chunk2A4MDHJR_cjs.groupDefinitions(sources ?? [], { labelId }).groups, picker.query).slice(
1760
+ () => picker ? chunkI2QSDQQV_cjs.filterTermGroups(chunkI2QSDQQV_cjs.groupDefinitions(sources ?? [], { labelId }).groups, picker.query).slice(
1908
1761
  0,
1909
1762
  MAX_GROUPS
1910
1763
  ) : [],
@@ -1930,7 +1783,7 @@ function DefinedTermsProvider({
1930
1783
  },
1931
1784
  [notify]
1932
1785
  );
1933
- const run2 = React4.useCallback(
1786
+ const run = React4.useCallback(
1934
1787
  (fn) => editor ? attempt(() => withDirectEditing(editor, fn)) : void 0,
1935
1788
  [editor, attempt]
1936
1789
  );
@@ -1945,7 +1798,7 @@ function DefinedTermsProvider({
1945
1798
  (row) => {
1946
1799
  if (!editor || !picker || !row) return;
1947
1800
  const port = editorPort(editor);
1948
- const placed = run2(() => {
1801
+ const placed = run(() => {
1949
1802
  if (picker.mode === "search" && picker.caret) port.setCaret(picker.caret);
1950
1803
  const caret = port.caret();
1951
1804
  if (!caret) throw new Error("Place the cursor where the term should go.");
@@ -1956,7 +1809,7 @@ function DefinedTermsProvider({
1956
1809
  const result = placed ? attempt(
1957
1810
  () => track({
1958
1811
  label: `Inserted defined term: ${row.definition.term}`,
1959
- insert: (revision) => insertDefinedTerm(editorPort(editor, revision), row.definition)
1812
+ insert: (revision) => commands.insertDefinedTerm(editorPort(editor, revision), row.definition)
1960
1813
  })?.result
1961
1814
  ) : void 0;
1962
1815
  setPicker(null);
@@ -1965,7 +1818,7 @@ function DefinedTermsProvider({
1965
1818
  if (result?.addedDefinition)
1966
1819
  notify?.(`\u201C${row.definition.term}\u201D added to the Definitions section.`, "success");
1967
1820
  },
1968
- [editor, picker, run2, attempt, track, notify]
1821
+ [editor, picker, run, attempt, track, notify]
1969
1822
  );
1970
1823
  const openPicker = React4.useCallback(
1971
1824
  (anchor) => {
@@ -2049,7 +1902,7 @@ function DefinedTermsProvider({
2049
1902
  root: viewer,
2050
1903
  matches: (href) => href.startsWith("#_dt_"),
2051
1904
  resolve: (href) => {
2052
- const definition = definitionOfAnchor(href, byId);
1905
+ const definition = commands.definitionOfAnchor(href, byId);
2053
1906
  return definition ? { title: definition.term, body: definition.meaning, footer: sourceOf(definition) } : null;
2054
1907
  },
2055
1908
  onFirstHover: firstHover,
@@ -2928,107 +2781,6 @@ function runBeforeSave(editor) {
2928
2781
  } catch {
2929
2782
  }
2930
2783
  }
2931
- function newRefBookmark(taken, random = Math.random) {
2932
- for (; ; ) {
2933
- const name = `${commands.REF_BOOKMARK_PREFIX}${String(Math.floor(random() * 9e8) + 1e8)}`;
2934
- if (!taken.has(name)) return name;
2935
- }
2936
- }
2937
- var styled = (style) => style ? `<w:rPr><w:rStyle w:val="${style}"/></w:rPr>` : "";
2938
- var run = (text, style) => `<w:r>${styled(style)}<w:t xml:space="preserve">${chunk2A4MDHJR_cjs.esc(text)}</w:t></w:r>`;
2939
- function refFieldXml(instruction, cached) {
2940
- const r = (inner) => `<w:r>${styled(commands.CROSS_REFERENCE_STYLE)}${inner}</w:r>`;
2941
- return `${r('<w:fldChar w:fldCharType="begin"/>')}${r(
2942
- `<w:instrText xml:space="preserve"> ${chunk2A4MDHJR_cjs.esc(instruction)} </w:instrText>`
2943
- )}${r('<w:fldChar w:fldCharType="separate"/>')}${run(cached, commands.CROSS_REFERENCE_STYLE)}${r(
2944
- '<w:fldChar w:fldCharType="end"/>'
2945
- )}`;
2946
- }
2947
- var refTooltip = (value, mode) => mode === "number" ? `Cross-reference to clause ${value}` : `Cross-reference to \u201C${value}\u201D`;
2948
- function crossReferenceXml(bookmark, mode, value) {
2949
- return `<w:hyperlink w:anchor="${chunk2A4MDHJR_cjs.esc(bookmark)}" w:tooltip="${chunk2A4MDHJR_cjs.esc(
2950
- refTooltip(value, mode)
2951
- )}" w:history="1">${refFieldXml(refInstruction(bookmark, mode), value)}</w:hyperlink>`;
2952
- }
2953
- var refInstruction = (bookmark, mode) => mode === "number" ? `REF ${bookmark} \\r \\h` : `REF ${bookmark} \\h`;
2954
- var refResult = (target, mode) => mode === "number" && target.number ? target.number : target.text;
2955
- var allBookmarks = (port) => new Set(port.paragraphs().flatMap((p) => p.bookmarks));
2956
- function ensureTargetBookmark(port, target, mode) {
2957
- const paragraph = port.paragraphs().find((p) => p.id === target.paragraphId);
2958
- if (!paragraph) throw new Error("That clause is no longer in the document.");
2959
- const existing = paragraph.bookmarks.find((b) => b.startsWith(commands.REF_BOOKMARK_PREFIX));
2960
- if (existing && mode === "number") return existing;
2961
- const name = newRefBookmark(allBookmarks(port));
2962
- const start = `<w:bookmarkStart w:id="0" w:name="${name}"/>`;
2963
- const end = '<w:bookmarkEnd w:id="0"/>';
2964
- if (mode === "number") {
2965
- port.setCaret({ paragraphId: paragraph.id, offset: 0 });
2966
- if (!port.paste(`<w:p>${start}${end}</w:p>`, "", false))
2967
- throw new Error("The cross-reference target could not be marked.");
2968
- return name;
2969
- }
2970
- const runs = port.runsXml(paragraph.id);
2971
- if (!runs) throw new Error("This heading cannot be referred to by its text; use its number.");
2972
- port.deleteRange(
2973
- { paragraphId: paragraph.id, offset: 0 },
2974
- { paragraphId: paragraph.id, offset: paragraph.text.length }
2975
- );
2976
- if (!port.paste(`<w:p>${start}${runs}${end}</w:p>`, paragraph.text, false))
2977
- throw new Error("The cross-reference target could not be marked.");
2978
- return name;
2979
- }
2980
- function pastePoint(port, caret) {
2981
- const paragraph = port.paragraphs().find((p) => p.id === caret.paragraphId);
2982
- if (paragraph?.text[caret.offset - 1] !== commands.FIELD_ATOM) return caret;
2983
- port.setCaret(caret);
2984
- port.typeText(" ");
2985
- return { paragraphId: caret.paragraphId, offset: caret.offset + 1 };
2986
- }
2987
- function markCrossReferenceTarget(port, target, mode) {
2988
- if (mode === "number" && !target.number) mode = "text";
2989
- const bookmark = ensureTargetBookmark(port, target, mode);
2990
- return { bookmark, mode, value: refResult(target, mode) };
2991
- }
2992
- function insertCrossReferenceField(port, { bookmark, mode, value }, caret) {
2993
- caret = pastePoint(port, caret);
2994
- port.setCaret(caret);
2995
- if (!port.paste(`<w:p>${crossReferenceXml(bookmark, mode, value)}</w:p>`, value, false))
2996
- throw new Error("The cross-reference could not be inserted.");
2997
- port.setCaret({ paragraphId: caret.paragraphId, offset: caret.offset + 1 });
2998
- return { bookmark };
2999
- }
3000
- function insertCrossReference(port, target, mode, caret) {
3001
- return insertCrossReferenceField(port, markCrossReferenceTarget(port, target, mode), caret);
3002
- }
3003
- var documentReferenceTooltip = (text, appName = "ARBI") => `Cross-reference: ${text} \u2014 opens in ${appName}`;
3004
- function insertDocumentReference(port, reference, caret) {
3005
- const text = reference.text.trim();
3006
- if (!text) throw new Error("Enter the reference text.");
3007
- const tooltip = documentReferenceTooltip(text, reference.appName).slice(0, 255);
3008
- caret = pastePoint(port, caret);
3009
- port.setCaret(caret);
3010
- const link = `<w:p><w:hyperlink r:id="rIdRef1"${tooltip ? ` w:tooltip="${chunk2A4MDHJR_cjs.esc(tooltip)}"` : ""} w:history="1">${run(text, commands.CROSS_REFERENCE_STYLE)}</w:hyperlink></w:p>`;
3011
- if (!port.paste(link, text, false, chunk2A4MDHJR_cjs.hyperlinkRelationship("rIdRef1", reference.url)))
3012
- throw new Error("The reference could not be inserted.");
3013
- port.setCaret({ paragraphId: caret.paragraphId, offset: caret.offset + text.length });
3014
- }
3015
- function refreshCrossReferences(port) {
3016
- const stale = commands.staleCrossReferences(port).sort(
3017
- (a, b) => a.paragraphId === b.paragraphId ? b.offset - a.offset : 0
3018
- );
3019
- let refreshed = 0;
3020
- for (const ref of stale) {
3021
- const paragraph = port.paragraphs().find((p) => p.id === ref.paragraphId);
3022
- if (!paragraph || paragraph.text[ref.offset - 1] === commands.FIELD_ATOM) continue;
3023
- const at = { paragraphId: ref.paragraphId, offset: ref.offset };
3024
- port.deleteRange(at, { paragraphId: ref.paragraphId, offset: ref.offset + 1 });
3025
- port.setCaret(at);
3026
- const text = ref.value ?? (ref.cached.trim() || ref.bookmark);
3027
- const body = ref.value === null ? run(text, commands.BROKEN_CROSS_REFERENCE_STYLE) : crossReferenceXml(ref.bookmark, ref.mode, ref.value);
3028
- if (port.paste(`<w:p>${body}</w:p>`, text, false) && ref.value !== null) refreshed++;
3029
- }
3030
- return { refreshed, broken: commands.brokenCrossReferences(port) };
3031
- }
3032
2784
 
3033
2785
  // src/docx/references/passages.ts
3034
2786
  function shortTitle(title) {
@@ -3058,25 +2810,6 @@ function filterPassages(passages, query) {
3058
2810
  const q = query.trim().toLowerCase();
3059
2811
  return q ? passages.filter((p) => p.text.toLowerCase().includes(q)) : [...passages];
3060
2812
  }
3061
- var RUN_PARTS = /* @__PURE__ */ new Set(["rPr", "t", "tab", "br", "lastRenderedPageBreak"]);
3062
- var SKIPPED = /* @__PURE__ */ new Set(["pPr", "bookmarkStart", "bookmarkEnd", "proofErr", "permStart", "permEnd"]);
3063
- function serialize(node) {
3064
- if (node.kind === "textValue") return chunk2A4MDHJR_cjs.esc(node.value ?? "");
3065
- const name = `${node.prefix ?? "w"}:${node.localName}`;
3066
- const attrs = (node.attributes ?? []).map((a) => ` ${a.prefix ? `${a.prefix}:` : ""}${a.localName}="${chunk2A4MDHJR_cjs.esc(a.value)}"`).join("");
3067
- const children = (node.children ?? []).map((c) => serialize(c)).join("");
3068
- return children ? `<${name}${attrs}>${children}</${name}>` : `<${name}${attrs}/>`;
3069
- }
3070
- function paragraphRunsXml(paragraph) {
3071
- const runs = [];
3072
- for (const child of paragraph.children ?? []) {
3073
- if (child.localName && SKIPPED.has(child.localName)) continue;
3074
- if (child.localName !== "r") return null;
3075
- if ((child.children ?? []).some((c) => !c.localName || !RUN_PARTS.has(c.localName))) return null;
3076
- runs.push(serialize(child));
3077
- }
3078
- return runs.length ? runs.join("") : null;
3079
- }
3080
2813
  function findNode2(node, id) {
3081
2814
  if (node.id === id) return node;
3082
2815
  for (const child of node.children ?? []) {
@@ -3105,7 +2838,7 @@ function referencesPort(editor, revision) {
3105
2838
  levelOf: numbering.levelOf,
3106
2839
  runsXml: (paragraphId) => {
3107
2840
  const node = findNode2(root(), paragraphId);
3108
- return node ? paragraphRunsXml(node) : null;
2841
+ return node ? commands.paragraphRunsXml(node) : null;
3109
2842
  }
3110
2843
  };
3111
2844
  }
@@ -3170,7 +2903,7 @@ function CrossReferencesProvider({
3170
2903
  notify?.(error instanceof Error ? error.message : "Could not read the document.", "error");
3171
2904
  }
3172
2905
  }, [editor, editable, notify]);
3173
- const run2 = React4.useCallback(
2906
+ const run = React4.useCallback(
3174
2907
  (label, prepare, insert) => {
3175
2908
  if (!editor) return;
3176
2909
  try {
@@ -3195,7 +2928,7 @@ function CrossReferencesProvider({
3195
2928
  try {
3196
2929
  const port = referencesPort(editor);
3197
2930
  if (!port.paragraphs().some((p) => p.fields?.length)) return;
3198
- preservingCaret(editor, () => withDirectEditing(editor, () => refreshCrossReferences(port)));
2931
+ preservingCaret(editor, () => withDirectEditing(editor, () => commands.refreshCrossReferences(port)));
3199
2932
  } catch {
3200
2933
  }
3201
2934
  };
@@ -3212,7 +2945,7 @@ function CrossReferencesProvider({
3212
2945
  try {
3213
2946
  const result = preservingCaret(
3214
2947
  editor,
3215
- () => withDirectEditing(editor, () => refreshCrossReferences(referencesPort(editor)))
2948
+ () => withDirectEditing(editor, () => commands.refreshCrossReferences(referencesPort(editor)))
3216
2949
  );
3217
2950
  setReport(result);
3218
2951
  } catch (error) {
@@ -3323,15 +3056,15 @@ function CrossReferencesProvider({
3323
3056
  labels: l,
3324
3057
  onCancel: () => setDialog(null),
3325
3058
  onClosed: () => editor?.surface?.focus(),
3326
- onInsertTarget: (target, mode) => run2(
3327
- `Inserted cross-reference: ${refResult(target, mode)}`,
3328
- () => markCrossReferenceTarget(referencesPort(editor), target, mode),
3329
- (marked, revision) => insertCrossReferenceField(referencesPort(editor, revision), marked, dialog.caret)
3059
+ onInsertTarget: (target, mode) => run(
3060
+ `Inserted cross-reference: ${commands.refResult(target, mode)}`,
3061
+ () => commands.markCrossReferenceTarget(referencesPort(editor), target, mode),
3062
+ (marked, revision) => commands.insertCrossReferenceField(referencesPort(editor, revision), marked, dialog.caret)
3330
3063
  ),
3331
- onInsertPassage: (target, text) => run2(
3064
+ onInsertPassage: (target, text) => run(
3332
3065
  `Inserted cross-reference: ${text}`,
3333
3066
  () => void 0,
3334
- (_, revision) => insertDocumentReference(
3067
+ (_, revision) => commands.insertDocumentReference(
3335
3068
  referencesPort(editor, revision),
3336
3069
  { text, url: references.linkFor(target), appName: references.appName },
3337
3070
  dialog.caret
@@ -3525,7 +3258,7 @@ function CrossReferenceDialog({
3525
3258
  {
3526
3259
  className: "ml-auto rounded bg-muted px-2 py-0.5",
3527
3260
  "data-testid": "docx-cross-reference-preview",
3528
- children: refResult(chosen, effectiveMode)
3261
+ children: commands.refResult(chosen, effectiveMode)
3529
3262
  }
3530
3263
  )
3531
3264
  ] })
@@ -4065,7 +3798,7 @@ function TableButtons() {
4065
3798
  ] });
4066
3799
  }
4067
3800
  var CAPTION_LABELS = ["Figure", "Table", "Equation"];
4068
- var CAPTION_STYLES = chunk2A4MDHJR_cjs.stylesXml(
3801
+ var CAPTION_STYLES = chunkI2QSDQQV_cjs.stylesXml(
4069
3802
  "",
4070
3803
  '<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="Caption"><w:name w:val="caption"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:uiPriority w:val="35"/><w:unhideWhenUsed/><w:qFormat/><w:pPr><w:spacing w:after="200" w:line="240" w:lineRule="auto"/></w:pPr><w:rPr><w:i/><w:iCs/><w:color w:val="44546A"/><w:sz w:val="18"/><w:szCs w:val="18"/></w:rPr></w:style>'
4071
3804
  );
@@ -4093,9 +3826,9 @@ function countSeqFields(root, label, throughId) {
4093
3826
  return count;
4094
3827
  }
4095
3828
  function captionParagraphXml(label, number, text) {
4096
- const run2 = (value) => `<w:r><w:t xml:space="preserve">${chunk2A4MDHJR_cjs.esc(value)}</w:t></w:r>`;
3829
+ const run = (value) => `<w:r><w:t xml:space="preserve">${chunkI2QSDQQV_cjs.esc(value)}</w:t></w:r>`;
4097
3830
  const rest = text.trim() ? `: ${text.trim()}` : "";
4098
- return `<w:p><w:pPr><w:pStyle w:val="Caption"/></w:pPr>${run2(`${label} `)}<w:fldSimple w:instr=" SEQ ${chunk2A4MDHJR_cjs.esc(label)} \\* ARABIC "><w:r><w:t>${number}</w:t></w:r></w:fldSimple>${rest ? run2(rest) : ""}</w:p>`;
3831
+ return `<w:p><w:pPr><w:pStyle w:val="Caption"/></w:pPr>${run(`${label} `)}<w:fldSimple w:instr=" SEQ ${chunkI2QSDQQV_cjs.esc(label)} \\* ARABIC "><w:r><w:t>${number}</w:t></w:r></w:fldSimple>${rest ? run(rest) : ""}</w:p>`;
4099
3832
  }
4100
3833
  function base642(bytes) {
4101
3834
  let binary = "";
@@ -4104,8 +3837,8 @@ function base642(bytes) {
4104
3837
  return btoa(binary);
4105
3838
  }
4106
3839
  function captionFragmentHtml(label, number, text, revision) {
4107
- const untracked = chunk2A4MDHJR_cjs.docxPackage({
4108
- document: chunk2A4MDHJR_cjs.documentXml(captionParagraphXml(label, number, text)),
3840
+ const untracked = chunkI2QSDQQV_cjs.docxPackage({
3841
+ document: chunkI2QSDQQV_cjs.documentXml(captionParagraphXml(label, number, text)),
4109
3842
  styles: CAPTION_STYLES,
4110
3843
  title: "Caption"
4111
3844
  });
@@ -4345,7 +4078,7 @@ function GenerateImageButton({ generation }) {
4345
4078
  });
4346
4079
  const editable = react.useEditorState((snapshot) => snapshot.editable);
4347
4080
  const generating = React4.useSyncExternalStore(subscribe, () => running > 0);
4348
- async function run2() {
4081
+ async function run() {
4349
4082
  if (!editor || !prompt.trim() || busy) return;
4350
4083
  const caret = rememberCaret(editor);
4351
4084
  const controller = new AbortController();
@@ -4391,7 +4124,7 @@ function GenerateImageButton({ generation }) {
4391
4124
  className: "native-docx-form native-docx-generate-image",
4392
4125
  onSubmit: (event) => {
4393
4126
  event.preventDefault();
4394
- void run2();
4127
+ void run();
4395
4128
  },
4396
4129
  children: [
4397
4130
  /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
@@ -4407,7 +4140,7 @@ function GenerateImageButton({ generation }) {
4407
4140
  "data-testid": "docx-generate-image-prompt",
4408
4141
  onChange: (event) => setPrompt(event.target.value),
4409
4142
  onKeyDown: (event) => {
4410
- if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) void run2();
4143
+ if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) void run();
4411
4144
  }
4412
4145
  }
4413
4146
  )
@@ -5231,6 +4964,22 @@ function NativeDocxEditor({
5231
4964
  );
5232
4965
  }
5233
4966
 
4967
+ Object.defineProperty(exports, "findDefinitionsSection", {
4968
+ enumerable: true,
4969
+ get: function () { return commands.findDefinitionsSection; }
4970
+ });
4971
+ Object.defineProperty(exports, "insertCrossReference", {
4972
+ enumerable: true,
4973
+ get: function () { return commands.insertCrossReference; }
4974
+ });
4975
+ Object.defineProperty(exports, "insertDefinedTerm", {
4976
+ enumerable: true,
4977
+ get: function () { return commands.insertDefinedTerm; }
4978
+ });
4979
+ Object.defineProperty(exports, "insertDocumentReference", {
4980
+ enumerable: true,
4981
+ get: function () { return commands.insertDocumentReference; }
4982
+ });
5234
4983
  Object.defineProperty(exports, "listTargets", {
5235
4984
  enumerable: true,
5236
4985
  get: function () { return commands.listTargets; }
@@ -5259,10 +5008,6 @@ exports.NativeDocxEditor = NativeDocxEditor;
5259
5008
  exports.builtinHouseTemplate = builtinHouseTemplate;
5260
5009
  exports.contentPath = contentPath;
5261
5010
  exports.editorPort = editorPort;
5262
- exports.findDefinitionsSection = findDefinitionsSection;
5263
- exports.insertCrossReference = insertCrossReference;
5264
- exports.insertDefinedTerm = insertDefinedTerm;
5265
- exports.insertDocumentReference = insertDocumentReference;
5266
5011
  exports.normalizeDocxExport = normalizeDocxExport;
5267
5012
  exports.referenceText = referenceText;
5268
5013
  exports.referencesPort = referencesPort;
@@ -5279,5 +5024,5 @@ exports.useReview = useReview;
5279
5024
  exports.useReviewItem = useReviewItem;
5280
5025
  exports.useTrackedOrNoted = useTrackedOrNoted;
5281
5026
  exports.withDirectEditing = withDirectEditing;
5282
- //# sourceMappingURL=chunk-XIGWUDOD.cjs.map
5283
- //# sourceMappingURL=chunk-XIGWUDOD.cjs.map
5027
+ //# sourceMappingURL=chunk-ETBB5KMN.cjs.map
5028
+ //# sourceMappingURL=chunk-ETBB5KMN.cjs.map