@manuscripts/article-editor 4.0.2-LEAN-4533.1 → 4.0.3

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 (119) hide show
  1. package/dist/cjs/EditorApp.js +1 -8
  2. package/dist/cjs/EditorApp.js.map +1 -1
  3. package/dist/cjs/Main.js +3 -3
  4. package/dist/cjs/Main.js.map +1 -1
  5. package/dist/cjs/components/FileManager/FileManager.js +1 -1
  6. package/dist/cjs/components/Inspector.js +25 -7
  7. package/dist/cjs/components/Inspector.js.map +1 -1
  8. package/dist/cjs/components/VersionHistoryDropdown.js +2 -2
  9. package/dist/cjs/components/VersionHistoryDropdown.js.map +1 -1
  10. package/dist/cjs/components/inspector/InspectorTab.js +50 -0
  11. package/dist/cjs/components/inspector/InspectorTab.js.map +1 -0
  12. package/dist/cjs/components/inspector/SnapshotsList.js +2 -14
  13. package/dist/cjs/components/inspector/SnapshotsList.js.map +1 -1
  14. package/dist/cjs/components/inspector/TabLabel.js +55 -0
  15. package/dist/cjs/components/inspector/TabLabel.js.map +1 -0
  16. package/dist/cjs/components/projects/EditorElement.js +4 -5
  17. package/dist/cjs/components/projects/EditorElement.js.map +1 -1
  18. package/dist/cjs/components/projects/Inspector.js +9 -19
  19. package/dist/cjs/components/projects/Inspector.js.map +1 -1
  20. package/dist/cjs/components/projects/ManuscriptPageContainer.js +3 -4
  21. package/dist/cjs/components/projects/ManuscriptPageContainer.js.map +1 -1
  22. package/dist/cjs/components/track-changes/SortByDropdown.js +1 -1
  23. package/dist/cjs/components/track-changes/TrackChangesPanel.js +3 -16
  24. package/dist/cjs/components/track-changes/TrackChangesPanel.js.map +1 -1
  25. package/dist/cjs/components/track-changes/suggestion-list/Suggestion.js +3 -7
  26. package/dist/cjs/components/track-changes/suggestion-list/Suggestion.js.map +1 -1
  27. package/dist/cjs/components/track-changes/suggestion-list/SuggestionList.js +2 -6
  28. package/dist/cjs/components/track-changes/suggestion-list/SuggestionList.js.map +1 -1
  29. package/dist/cjs/hooks/use-create-editor.js +13 -30
  30. package/dist/cjs/hooks/use-create-editor.js.map +1 -1
  31. package/dist/{types/lib/comparison/distribute-nodes.d.ts → cjs/hooks/use-did-mount.js} +13 -8
  32. package/dist/cjs/hooks/use-did-mount.js.map +1 -0
  33. package/dist/cjs/index.js +3 -3
  34. package/dist/cjs/index.js.map +1 -1
  35. package/dist/cjs/store/Store.js +2 -7
  36. package/dist/cjs/store/Store.js.map +1 -1
  37. package/dist/es/EditorApp.js +1 -8
  38. package/dist/es/EditorApp.js.map +1 -1
  39. package/dist/es/Main.js +3 -3
  40. package/dist/es/Main.js.map +1 -1
  41. package/dist/es/components/FileManager/FileManager.js +1 -1
  42. package/dist/es/components/Inspector.js +24 -6
  43. package/dist/es/components/Inspector.js.map +1 -1
  44. package/dist/es/components/VersionHistoryDropdown.js +2 -2
  45. package/dist/es/components/VersionHistoryDropdown.js.map +1 -1
  46. package/dist/{types/hooks/use-compare-documents.d.ts → es/components/inspector/InspectorTab.js} +12 -13
  47. package/dist/es/components/inspector/InspectorTab.js.map +1 -0
  48. package/dist/es/components/inspector/SnapshotsList.js +3 -15
  49. package/dist/es/components/inspector/SnapshotsList.js.map +1 -1
  50. package/dist/{types/lib/comparison/compare-paragraph-like.d.ts → es/components/inspector/TabLabel.js} +16 -11
  51. package/dist/es/components/inspector/TabLabel.js.map +1 -0
  52. package/dist/es/components/projects/EditorElement.js +4 -5
  53. package/dist/es/components/projects/EditorElement.js.map +1 -1
  54. package/dist/es/components/projects/Inspector.js +11 -21
  55. package/dist/es/components/projects/Inspector.js.map +1 -1
  56. package/dist/es/components/projects/ManuscriptPageContainer.js +3 -4
  57. package/dist/es/components/projects/ManuscriptPageContainer.js.map +1 -1
  58. package/dist/es/components/track-changes/SortByDropdown.js +1 -1
  59. package/dist/es/components/track-changes/TrackChangesPanel.js +3 -16
  60. package/dist/es/components/track-changes/TrackChangesPanel.js.map +1 -1
  61. package/dist/es/components/track-changes/suggestion-list/Suggestion.js +3 -7
  62. package/dist/es/components/track-changes/suggestion-list/Suggestion.js.map +1 -1
  63. package/dist/es/components/track-changes/suggestion-list/SuggestionList.js +2 -6
  64. package/dist/es/components/track-changes/suggestion-list/SuggestionList.js.map +1 -1
  65. package/dist/es/hooks/use-create-editor.js +14 -31
  66. package/dist/es/hooks/use-create-editor.js.map +1 -1
  67. package/dist/{types/lib/comparison/create-dataTracked-attrs.d.ts → es/hooks/use-did-mount.js} +10 -5
  68. package/dist/es/hooks/use-did-mount.js.map +1 -0
  69. package/dist/es/index.js +3 -3
  70. package/dist/es/index.js.map +1 -1
  71. package/dist/es/store/Store.js +2 -7
  72. package/dist/es/store/Store.js.map +1 -1
  73. package/dist/types/EditorApp.d.ts +1 -2
  74. package/dist/types/Main.d.ts +1 -1
  75. package/dist/types/components/Inspector.d.ts +6 -1
  76. package/dist/types/components/inspector/InspectorTab.d.ts +7 -0
  77. package/dist/types/{lib/comparison/rebuild-nodes-tree.d.ts → components/inspector/TabLabel.d.ts} +5 -3
  78. package/dist/types/components/projects/ManuscriptPageContainer.d.ts +1 -1
  79. package/dist/types/components/track-changes/TrackChangesPanel.d.ts +1 -1
  80. package/dist/types/components/track-changes/suggestion-list/Suggestion.d.ts +1 -1
  81. package/dist/types/components/track-changes/suggestion-list/SuggestionList.d.ts +3 -3
  82. package/dist/types/{lib/comparison/compare-table-element.d.ts → hooks/use-did-mount.d.ts} +2 -11
  83. package/dist/types/index.d.ts +1 -1
  84. package/dist/types/store/Store.d.ts +1 -3
  85. package/package.json +5 -7
  86. package/dist/cjs/components/tools/CompareDocumentsModal.js +0 -170
  87. package/dist/cjs/components/tools/CompareDocumentsModal.js.map +0 -1
  88. package/dist/cjs/hooks/use-compare-documents.js +0 -69
  89. package/dist/cjs/hooks/use-compare-documents.js.map +0 -1
  90. package/dist/cjs/lib/comparison/compare-documents.js +0 -53
  91. package/dist/cjs/lib/comparison/compare-documents.js.map +0 -1
  92. package/dist/cjs/lib/comparison/compare-paragraph-like.js +0 -388
  93. package/dist/cjs/lib/comparison/compare-paragraph-like.js.map +0 -1
  94. package/dist/cjs/lib/comparison/compare-table-element.js +0 -567
  95. package/dist/cjs/lib/comparison/compare-table-element.js.map +0 -1
  96. package/dist/cjs/lib/comparison/create-dataTracked-attrs.js +0 -60
  97. package/dist/cjs/lib/comparison/create-dataTracked-attrs.js.map +0 -1
  98. package/dist/cjs/lib/comparison/distribute-nodes.js +0 -131
  99. package/dist/cjs/lib/comparison/distribute-nodes.js.map +0 -1
  100. package/dist/cjs/lib/comparison/rebuild-nodes-tree.js +0 -76
  101. package/dist/cjs/lib/comparison/rebuild-nodes-tree.js.map +0 -1
  102. package/dist/es/components/tools/CompareDocumentsModal.js +0 -140
  103. package/dist/es/components/tools/CompareDocumentsModal.js.map +0 -1
  104. package/dist/es/hooks/use-compare-documents.js +0 -65
  105. package/dist/es/hooks/use-compare-documents.js.map +0 -1
  106. package/dist/es/lib/comparison/compare-documents.js +0 -48
  107. package/dist/es/lib/comparison/compare-documents.js.map +0 -1
  108. package/dist/es/lib/comparison/compare-paragraph-like.js +0 -378
  109. package/dist/es/lib/comparison/compare-paragraph-like.js.map +0 -1
  110. package/dist/es/lib/comparison/compare-table-element.js +0 -559
  111. package/dist/es/lib/comparison/compare-table-element.js.map +0 -1
  112. package/dist/es/lib/comparison/create-dataTracked-attrs.js +0 -54
  113. package/dist/es/lib/comparison/create-dataTracked-attrs.js.map +0 -1
  114. package/dist/es/lib/comparison/distribute-nodes.js +0 -127
  115. package/dist/es/lib/comparison/distribute-nodes.js.map +0 -1
  116. package/dist/es/lib/comparison/rebuild-nodes-tree.js +0 -72
  117. package/dist/es/lib/comparison/rebuild-nodes-tree.js.map +0 -1
  118. package/dist/types/components/tools/CompareDocumentsModal.d.ts +0 -11
  119. package/dist/types/lib/comparison/compare-documents.d.ts +0 -16
@@ -1,131 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.distributeNodesForComparison = void 0;
4
- // Creates a unique key for a node
5
- const createNodeKey = (node, index = 0) => {
6
- const id = node.attrs.id || node.attrs.objectId;
7
- if (id) {
8
- return `${node.type.name}:${id}`;
9
- }
10
- return `${node.type.name}:${index}`;
11
- };
12
- // Distributes the nodes for comparison
13
- // It creates a map of nodes with their original and comparison nodes
14
- // Add status to the nodes to indicate if they are deleted, inserted or unchanged, and children nodes
15
- // Status helps to prevent unnecessary calculations
16
- const distributeNodesForComparison = (originalNodes, comparisonNodes) => {
17
- const distributedMap = new Map();
18
- const processChildNodes = (node, isOriginal, parentMap, orderMap) => {
19
- if (node.content && node.content.childCount > 0) {
20
- // Create an ordered array to track position
21
- const childKeys = [];
22
- let count = 0;
23
- node.content.forEach((childNode, index) => {
24
- const key = createNodeKey(childNode, count++);
25
- childKeys.push(key);
26
- // Store the position in the order map
27
- if (!isOriginal) {
28
- orderMap.set(key, index);
29
- }
30
- if (!parentMap.has(key)) {
31
- parentMap.set(key, {
32
- originalNode: isOriginal ? childNode : undefined,
33
- comparisonNode: isOriginal ? undefined : childNode,
34
- children: new Map(),
35
- status: isOriginal ? 'deleted' : 'inserted',
36
- });
37
- }
38
- else {
39
- const existingEntry = parentMap.get(key);
40
- if (isOriginal) {
41
- existingEntry.originalNode = childNode;
42
- }
43
- else {
44
- existingEntry.comparisonNode = childNode;
45
- }
46
- if (existingEntry.originalNode && existingEntry.comparisonNode) {
47
- existingEntry.status = 'unchanged';
48
- }
49
- if (!existingEntry.children) {
50
- existingEntry.children = new Map();
51
- }
52
- }
53
- // Recursively process children of this node
54
- const childOrderMap = new Map();
55
- processChildNodes(childNode, isOriginal, parentMap.get(key).children, childOrderMap);
56
- });
57
- // When processing the comparison document, reorder the map based on the order of nodes
58
- if (!isOriginal) {
59
- const orderedMap = new Map();
60
- const sortedKeys = [...parentMap.keys()].sort((a, b) => {
61
- const posA = orderMap.get(a) ?? Number.MAX_VALUE;
62
- const posB = orderMap.get(b) ?? Number.MAX_VALUE;
63
- return posA - posB;
64
- });
65
- // Rebuild the map in correct order
66
- for (const key of sortedKeys) {
67
- orderedMap.set(key, parentMap.get(key));
68
- }
69
- // Clear the original map and replace with ordered entries
70
- parentMap.clear();
71
- for (const [key, value] of orderedMap.entries()) {
72
- parentMap.set(key, value);
73
- }
74
- }
75
- }
76
- };
77
- // First pass: original nodes
78
- const topLevelOrderMap = new Map();
79
- originalNodes.forEach((node, index) => {
80
- const key = createNodeKey(node);
81
- distributedMap.set(key, {
82
- originalNode: node,
83
- children: new Map(),
84
- status: 'deleted', // Initially marked as deleted until we find a match
85
- });
86
- // Store original order
87
- topLevelOrderMap.set(key, index);
88
- const childOrderMap = new Map();
89
- processChildNodes(node, true, distributedMap.get(key).children, childOrderMap);
90
- });
91
- // Second pass: comparison nodes
92
- const comparisonOrderMap = new Map();
93
- comparisonNodes.forEach((node, index) => {
94
- const key = createNodeKey(node);
95
- comparisonOrderMap.set(key, index);
96
- if (distributedMap.has(key)) {
97
- const existingEntry = distributedMap.get(key);
98
- existingEntry.comparisonNode = node;
99
- existingEntry.status = 'unchanged';
100
- if (!existingEntry.children) {
101
- existingEntry.children = new Map();
102
- }
103
- }
104
- else {
105
- distributedMap.set(key, {
106
- comparisonNode: node,
107
- children: new Map(),
108
- status: 'inserted',
109
- });
110
- }
111
- // Process children for body and backmatter nodes
112
- const childOrderMap = new Map();
113
- processChildNodes(node, false, distributedMap.get(key).children, childOrderMap);
114
- });
115
- // Final step: reorder the top-level map based on the comparison document
116
- const finalOrderedMap = new Map();
117
- // Sort keys based on their position in the comparison document
118
- const sortedKeys = [...distributedMap.keys()].sort((a, b) => {
119
- // Use the position from comparison document, or fallback to original if not in comparison
120
- const posA = comparisonOrderMap.get(a) ?? topLevelOrderMap.get(a) ?? Number.MAX_VALUE;
121
- const posB = comparisonOrderMap.get(b) ?? topLevelOrderMap.get(b) ?? Number.MAX_VALUE;
122
- return posA - posB;
123
- });
124
- // Rebuild the map in sorted order
125
- for (const key of sortedKeys) {
126
- finalOrderedMap.set(key, distributedMap.get(key));
127
- }
128
- return finalOrderedMap;
129
- };
130
- exports.distributeNodesForComparison = distributeNodesForComparison;
131
- //# sourceMappingURL=distribute-nodes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"distribute-nodes.js","sourceRoot":"","sources":["../../../../src/lib/comparison/distribute-nodes.ts"],"names":[],"mappings":";;;AAoBA,kCAAkC;AAClC,MAAM,aAAa,GAAG,CAAC,IAAoB,EAAE,KAAK,GAAG,CAAC,EAAU,EAAE;IAChE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAA;IAC/C,IAAI,EAAE,EAAE;QACN,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,EAAE,CAAA;KACjC;IACD,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE,CAAA;AACrC,CAAC,CAAA;AAED,uCAAuC;AACvC,qEAAqE;AACrE,qGAAqG;AACrG,mDAAmD;AAC5C,MAAM,4BAA4B,GAAG,CAC1C,aAA6B,EAC7B,eAA+B,EACF,EAAE;IAC/B,MAAM,cAAc,GAAG,IAAI,GAAG,EAA0B,CAAA;IAExD,MAAM,iBAAiB,GAAG,CACxB,IAAoB,EACpB,UAAmB,EACnB,SAAsC,EACtC,QAA6B,EAC7B,EAAE;QACF,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,CAAC,EAAE;YAC/C,4CAA4C;YAC5C,MAAM,SAAS,GAAa,EAAE,CAAA;YAE9B,IAAI,KAAK,GAAG,CAAC,CAAA;YACb,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE;gBACxC,MAAM,GAAG,GAAG,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,CAAA;gBAC7C,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBAE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CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1D,0FAA0F;QAC1F,MAAM,IAAI,GACR,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,SAAS,CAAA;QAC1E,MAAM,IAAI,GACR,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,SAAS,CAAA;QAC1E,OAAO,IAAI,GAAG,IAAI,CAAA;IACpB,CAAC,CAAC,CAAA;IAEF,kCAAkC;IAClC,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;QAC5B,eAAe,CAAC,GAAG,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC,CAAA;KACnD;IAED,OAAO,eAAe,CAAA;AACxB,CAAC,CAAA;AA9JY,QAAA,4BAA4B,gCA8JxC"}
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rebuildDocNodeTree = void 0;
4
- /*!
5
- * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
6
- *
7
- * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
8
- *
9
- * The Original Code is manuscripts-frontend.
10
- *
11
- * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
12
- *
13
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
14
- */
15
- const transform_1 = require("@manuscripts/transform");
16
- const compare_documents_1 = require("./compare-documents");
17
- const compare_paragraph_like_1 = require("./compare-paragraph-like");
18
- const compare_table_element_1 = require("./compare-table-element");
19
- const create_dataTracked_attrs_1 = require("./create-dataTracked-attrs");
20
- // Rebuilds the nodes tree from the distributed nodes, and applies the changes to the nodes
21
- const rebuildDocNodeTree = (nodeId, nodeMap) => {
22
- const entry = nodeMap.get(nodeId);
23
- if (!entry) {
24
- throw new Error(`Node with ID "${nodeId}" not found`);
25
- }
26
- const baseNode = entry.comparisonNode ?? entry.originalNode;
27
- if (!baseNode) {
28
- throw new Error(`No node available for "${nodeId}"`);
29
- }
30
- const rebuiltChildren = [];
31
- if (entry.children && !baseNode?.isTextblock) {
32
- for (const childId of entry.children.keys()) {
33
- const childNode = (0, exports.rebuildDocNodeTree)(childId, entry.children);
34
- rebuiltChildren.push(childNode);
35
- }
36
- }
37
- if (entry.status === 'deleted' &&
38
- !entry.comparisonNode?.isText &&
39
- !entry.originalNode?.isText) {
40
- const finalAttrs = {
41
- ...baseNode.attrs,
42
- dataTracked: [(0, create_dataTracked_attrs_1.createComparisonDeleteAttrsDataTracked)('')],
43
- };
44
- return baseNode.type.create(finalAttrs, rebuiltChildren.length > 0 ? rebuiltChildren : baseNode.content);
45
- }
46
- else if (entry.status === 'inserted' &&
47
- !entry.comparisonNode?.isText &&
48
- !entry.originalNode?.isText) {
49
- const finalAttrs = {
50
- ...baseNode.attrs,
51
- dataTracked: [(0, create_dataTracked_attrs_1.createComparisonInsertAttrsDataTracked)('')],
52
- };
53
- return baseNode.type.create(finalAttrs, rebuiltChildren.length > 0 ? rebuiltChildren : baseNode.content);
54
- }
55
- else if (entry.comparisonNode?.type == transform_1.schema.nodes.table_element &&
56
- entry.originalNode?.type == transform_1.schema.nodes.table_element) {
57
- // TODO: find more generic way to handle this
58
- return (0, compare_table_element_1.compareTableElement)(entry.originalNode, entry.comparisonNode);
59
- }
60
- else if (entry.comparisonNode?.isAtom &&
61
- entry.comparisonNode?.isBlock &&
62
- entry.originalNode?.isAtom &&
63
- entry.originalNode?.isBlock) {
64
- return (0, compare_documents_1.compareSingleNodeAttrs)(entry.originalNode, entry.comparisonNode, baseNode.type, rebuiltChildren);
65
- }
66
- else if (entry.comparisonNode?.isTextblock &&
67
- entry.originalNode?.isTextblock) {
68
- return (0, compare_paragraph_like_1.compareParagraphLike)(entry.originalNode, entry.comparisonNode);
69
- }
70
- else if (entry.comparisonNode?.isBlock && entry.originalNode?.isBlock) {
71
- return (0, compare_documents_1.compareSingleNodeAttrs)(entry.originalNode, entry.comparisonNode, baseNode.type, rebuiltChildren);
72
- }
73
- return baseNode.type.create({ ...baseNode.attrs }, rebuiltChildren.length > 0 ? rebuiltChildren : baseNode.content);
74
- };
75
- exports.rebuildDocNodeTree = rebuildDocNodeTree;
76
- //# sourceMappingURL=rebuild-nodes-tree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rebuild-nodes-tree.js","sourceRoot":"","sources":["../../../../src/lib/comparison/rebuild-nodes-tree.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,sDAA+D;AAE/D,2DAA4D;AAC5D,qEAA+D;AAC/D,mEAA6D;AAC7D,yEAGmC;AAGnC,2FAA2F;AACpF,MAAM,kBAAkB,GAAG,CAChC,MAAc,EACd,OAAoC,EACpB,EAAE;IAClB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IACjC,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,iBAAiB,MAAM,aAAa,CAAC,CAAA;KACtD;IAED,MAAM,QAAQ,GAAG,KAAK,CAAC,cAAc,IAAI,KAAK,CAAC,YAAY,CAAA;IAC3D,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CAAC,0BAA0B,MAAM,GAAG,CAAC,CAAA;KACrD;IACD,MAAM,eAAe,GAAqB,EAAE,CAAA;IAC5C,IAAI,KAAK,CAAC,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,EAAE,IAAI,IAAI,kBAAM,CAAC,KAAK,CAAC,aAAa,EACtD;QACA,6CAA6C;QAC7C,OAAO,IAAA,2CAAmB,EAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,CAAA;KACrE;SAAM,IACL,KAAK,CAAC,cAAc,EAAE,MAAM;QAC5B,KAAK,CAAC,cAAc,EAAE,OAAO;QAC7B,KAAK,CAAC,YAAY,EAAE,MAAM;QAC1B,KAAK,CAAC,YAAY,EAAE,OAAO,EAC3B;QACA,OAAO,IAAA,0CAAsB,EAC3B,KAAK,CAAC,YAAY,EAClB,KAAK,CAAC,cAAc,EACpB,QAAQ,CAAC,IAAI,EACb,eAAe,CAChB,CAAA;KACF;SAAM,IACL,KAAK,CAAC,cAAc,EAAE,WAAW;QACjC,KAAK,CAAC,YAAY,EAAE,WAAW,EAC/B;QACA,OAAO,IAAA,6CAAoB,EAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,CAAA;KACtE;SAAM,IAAI,KAAK,CAAC,cAAc,EAAE,OAAO,IAAI,KAAK,CAAC,YAAY,EAAE,OAAO,EAAE;QACvE,OAAO,IAAA,0CAAsB,EAC3B,KAAK,CAAC,YAAY,EAClB,KAAK,CAAC,cAAc,EACpB,QAAQ,CAAC,IAAI,EACb,eAAe,CAChB,CAAA;KACF;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CACzB,EAAE,GAAG,QAAQ,CAAC,KAAK,EAAE,EACrB,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAChE,CAAA;AACH,CAAC,CAAA;AAlFY,QAAA,kBAAkB,sBAkF9B"}
@@ -1,140 +0,0 @@
1
- /*!
2
- * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
3
- *
4
- * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
5
- *
6
- * The Original Code is manuscripts-frontend.
7
- *
8
- * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
- *
10
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
- */
12
- import { CloseButton, ModalBody, ModalContainer, ModalHeader, PrimaryButton, SecondaryButton, StyledModal, } from '@manuscripts/style-guide';
13
- import React, { useState } from 'react';
14
- import styled from 'styled-components';
15
- export const CompareDocumentsModal = ({ snapshots, loading = false, error = null, onCancel, submissionID, }) => {
16
- const [isOpen, setOpen] = useState(true);
17
- const [originalDocId, setOriginalDocId] = useState('');
18
- const [comparisonDocId, setComparisonDocId] = useState('');
19
- const handleCompare = () => {
20
- setOpen(false);
21
- window.open(`/editor/${submissionID}/compare/${originalDocId}/${comparisonDocId}`, '_blank');
22
- handleClose();
23
- };
24
- const handleClose = () => {
25
- setOpen(false);
26
- onCancel();
27
- };
28
- return (React.createElement(StyledModal, { isOpen: isOpen, onRequestClose: handleClose, shouldCloseOnOverlayClick: true },
29
- React.createElement(StyledModalContainer, null,
30
- React.createElement(StyledModalHeader, null,
31
- React.createElement(ModalTitle, null, "Compare Documents"),
32
- React.createElement(CloseButton, { onClick: handleClose })),
33
- React.createElement(StyledModalBody, null, loading ? (React.createElement(LoadingContainer, null,
34
- React.createElement(LoadingText, null, "Loading snapshots..."))) : error ? (React.createElement(ErrorMessage, null, error)) : (React.createElement(React.Fragment, null,
35
- React.createElement(DocumentSelectContainer, null,
36
- React.createElement(SelectContainer, null,
37
- React.createElement(InputLabel, { htmlFor: "original-document" }, "Original Version"),
38
- React.createElement(Select, { id: "original-document", value: originalDocId, onChange: (e) => setOriginalDocId(e.target.value) },
39
- React.createElement("option", { value: "" }, "Select a version"),
40
- snapshots.map((snapshot) => (React.createElement("option", { key: snapshot.id, value: snapshot.id, disabled: snapshot.id === comparisonDocId },
41
- snapshot.name,
42
- " (",
43
- snapshot.createdAt,
44
- ")"))))),
45
- React.createElement(SelectContainer, null,
46
- React.createElement(InputLabel, { htmlFor: "comparison-document" }, "Version to Compare"),
47
- React.createElement(Select, { id: "comparison-document", value: comparisonDocId, onChange: (e) => setComparisonDocId(e.target.value) },
48
- React.createElement("option", { value: "" }, "Select a version"),
49
- snapshots.map((snapshot) => (React.createElement("option", { key: snapshot.id, value: snapshot.id, disabled: snapshot.id === originalDocId },
50
- snapshot.name,
51
- " (",
52
- snapshot.createdAt,
53
- ")")))))),
54
- React.createElement(ButtonContainer, null,
55
- React.createElement(SecondaryButton, { onClick: handleClose }, "Cancel"),
56
- React.createElement(PrimaryButton, { onClick: handleCompare, disabled: !originalDocId ||
57
- !comparisonDocId ||
58
- originalDocId === comparisonDocId }, "Compare"))))))));
59
- };
60
- const DocumentSelectContainer = styled.div `
61
- display: flex;
62
- flex-direction: column;
63
- gap: ${(props) => props.theme.grid.unit * 2}px;
64
- `;
65
- const SelectContainer = styled.div `
66
- display: flex;
67
- flex-direction: column;
68
- gap: ${(props) => props.theme.grid.unit}px;
69
- margin-bottom: ${(props) => props.theme.grid.unit * 2}px;
70
- `;
71
- const InputLabel = styled.label `
72
- font-size: ${(props) => props.theme.font.size.normal};
73
- font-weight: ${(props) => props.theme.font.weight.medium};
74
- color: ${(props) => props.theme.colors.text.primary};
75
- margin-bottom: ${(props) => props.theme.grid.unit}px;
76
- `;
77
- const Select = styled.select `
78
- width: 100%;
79
- height: 36px;
80
- padding: 0 ${(props) => props.theme.grid.unit * 2}px;
81
- border: 1px solid ${(props) => props.theme.colors.border.secondary};
82
- border-radius: ${(props) => props.theme.grid.radius.small};
83
- background-color: ${(props) => props.theme.colors.background.primary};
84
- font-size: ${(props) => props.theme.font.size.normal};
85
- color: ${(props) => props.theme.colors.text.primary};
86
- appearance: none;
87
- background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='12' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 6L0 0h12z' fill='%23666'/%3E%3C/svg%3E");
88
- background-repeat: no-repeat;
89
- background-position: right ${(props) => props.theme.grid.unit * 2}px center;
90
- `;
91
- const ButtonContainer = styled.div `
92
- display: flex;
93
- justify-content: flex-end;
94
- gap: ${(props) => props.theme.grid.unit * 2}px;
95
- padding-top: ${(props) => props.theme.grid.unit * 2}px;
96
- border-top: 1px solid ${(props) => props.theme.colors.border.tertiary};
97
- `;
98
- const StyledModalBody = styled(ModalBody) `
99
- width: 400px;
100
- padding: ${(props) => props.theme.grid.unit * 3}px;
101
- flex-direction: column;
102
- height: 250px;
103
- justify-content: end;
104
- margin-bottom: 15px;
105
- `;
106
- const StyledModalContainer = styled(ModalContainer) `
107
- margin: auto;
108
- position: relative;
109
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
110
- `;
111
- const ModalTitle = styled.h2 `
112
- font-size: ${(props) => props.theme.font.size.medium};
113
- font-weight: ${(props) => props.theme.font.weight.bold};
114
- color: ${(props) => props.theme.colors.text.primary};
115
- margin-left: ${(props) => props.theme.grid.unit * 2}px;
116
- `;
117
- const StyledModalHeader = styled(ModalHeader) `
118
- width: 100%;
119
- display: flex;
120
- justify-content: space-between;
121
- align-items: center;
122
- border-bottom: 1px solid ${(props) => props.theme.colors.border.tertiary};
123
- `;
124
- const LoadingContainer = styled.div `
125
- display: flex;
126
- justify-content: center;
127
- align-items: center;
128
- height: 60px;
129
- `;
130
- const LoadingText = styled.div `
131
- font-size: ${(props) => props.theme.font.size.normal};
132
- color: ${(props) => props.theme.colors.text.secondary};
133
- text-align: center;
134
- `;
135
- const ErrorMessage = styled.div `
136
- color: ${(props) => props.theme.colors.text.error};
137
- margin: ${(props) => props.theme.grid.unit * 2}px 0;
138
- text-align: center;
139
- `;
140
- //# sourceMappingURL=CompareDocumentsModal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CompareDocumentsModal.js","sourceRoot":"","sources":["../../../../src/components/tools/CompareDocumentsModal.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,WAAW,EACX,SAAS,EACT,cAAc,EACd,WAAW,EACX,aAAa,EACb,eAAe,EACf,WAAW,GACZ,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAYtC,MAAM,CAAC,MAAM,qBAAqB,GAAyC,CAAC,EAC1E,SAAS,EACT,OAAO,GAAG,KAAK,EACf,KAAK,GAAG,IAAI,EACZ,QAAQ,EACR,YAAY,GACb,EAAE,EAAE;IACH,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;IACxC,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAA;IAC9D,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAA;IAElE,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,OAAO,CAAC,KAAK,CAAC,CAAA;QACd,MAAM,CAAC,IAAI,CACT,WAAW,YAAY,YAAY,aAAa,IAAI,eAAe,EAAE,EACrE,QAAQ,CACT,CAAA;QACD,WAAW,EAAE,CAAA;IACf,CAAC,CAAA;IAED,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,OAAO,CAAC,KAAK,CAAC,CAAA;QACd,QAAQ,EAAE,CAAA;IACZ,CAAC,CAAA;IAED,OAAO,CACL,oBAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,WAAW,EAC3B,yBAAyB,EAAE,IAAI;QAE/B,oBAAC,oBAAoB;YAC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,GAAG,CAAC;;CAE/C,CAAA"}
@@ -1,65 +0,0 @@
1
- /*!
2
- * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
3
- *
4
- * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
5
- *
6
- * The Original Code is manuscripts-frontend.
7
- *
8
- * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
- *
10
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
- */
12
- import { useEffect, useState } from 'react';
13
- import { compareDocuments } from '../lib/comparison/compare-documents';
14
- export const useCompareDocuments = ({ originalId, comparisonId, getSnapshot, }) => {
15
- const [comparedDoc, setComparedDoc] = useState(null);
16
- const [isLoading, setIsLoading] = useState(false);
17
- const [error, setError] = useState(null);
18
- const isComparingMode = Boolean(originalId && comparisonId);
19
- useEffect(() => {
20
- const fetchAndCompareDocuments = async () => {
21
- if (!originalId || !comparisonId) {
22
- setComparedDoc(null);
23
- setError(null);
24
- return;
25
- }
26
- setIsLoading(true);
27
- setError(null);
28
- try {
29
- const [originalSnapshot, comparisonSnapshot] = await Promise.all([
30
- getSnapshot(originalId),
31
- getSnapshot(comparisonId),
32
- ]);
33
- if (!originalSnapshot || !comparisonSnapshot) {
34
- throw new Error('Failed to fetch one or both snapshots');
35
- }
36
- const comparedDocument = compareDocuments(originalSnapshot, comparisonSnapshot);
37
- setComparedDoc(comparedDocument);
38
- }
39
- catch (err) {
40
- console.error('Error comparing documents:', err);
41
- setError(err instanceof Error ? err.message : 'Unknown error occurred');
42
- setComparedDoc(null);
43
- }
44
- finally {
45
- setIsLoading(false);
46
- }
47
- };
48
- fetchAndCompareDocuments();
49
- }, [originalId, comparisonId, getSnapshot]);
50
- // Reset state when exiting comparison mode
51
- useEffect(() => {
52
- if (!isComparingMode) {
53
- setComparedDoc(null);
54
- setError(null);
55
- setIsLoading(false);
56
- }
57
- }, [isComparingMode]);
58
- return {
59
- comparedDoc,
60
- isComparingMode,
61
- isLoading,
62
- error,
63
- };
64
- };
65
- //# sourceMappingURL=use-compare-documents.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-compare-documents.js","sourceRoot":"","sources":["../../../src/hooks/use-compare-documents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAA;AAStE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAClC,UAAU,EACV,YAAY,EACZ,WAAW,GACc,EAAE,EAAE;IAC7B,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAwB,IAAI,CAAC,CAAA;IAC3E,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IACjD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAA;IAEvD,MAAM,eAAe,GAAG,OAAO,CAAC,UAAU,IAAI,YAAY,CAAC,CAAA;IAE3D,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,wBAAwB,GAAG,KAAK,IAAI,EAAE;YAC1C,IAAI,CAAC,UAAU,IAAI,CAAC,YAAY,EAAE;gBAChC,cAAc,CAAC,IAAI,CAAC,CAAA;gBACpB,QAAQ,CAAC,IAAI,CAAC,CAAA;gBACd,OAAM;aACP;YAED,YAAY,CAAC,IAAI,CAAC,CAAA;YAClB,QAAQ,CAAC,IAAI,CAAC,CAAA;YAEd,IAAI;gBACF,MAAM,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;oBAC/D,WAAW,CAAC,UAAU,CAAC;oBACvB,WAAW,CAAC,YAAY,CAAC;iBAC1B,CAAC,CAAA;gBAEF,IAAI,CAAC,gBAAgB,IAAI,CAAC,kBAAkB,EAAE;oBAC5C,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAA;iBACzD;gBAED,MAAM,gBAAgB,GAAG,gBAAgB,CACvC,gBAAgB,EAChB,kBAAkB,CACnB,CAAA;gBACD,cAAc,CAAC,gBAAgB,CAAC,CAAA;aACjC;YAAC,OAAO,GAAG,EAAE;gBACZ,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAA;gBAChD,QAAQ,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAA;gBACvE,cAAc,CAAC,IAAI,CAAC,CAAA;aACrB;oBAAS;gBACR,YAAY,CAAC,KAAK,CAAC,CAAA;aACpB;QACH,CAAC,CAAA;QAED,wBAAwB,EAAE,CAAA;IAC5B,CAAC,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC,CAAA;IAE3C,2CAA2C;IAC3C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,eAAe,EAAE;YACpB,cAAc,CAAC,IAAI,CAAC,CAAA;YACpB,QAAQ,CAAC,IAAI,CAAC,CAAA;YACd,YAAY,CAAC,KAAK,CAAC,CAAA;SACpB;IACH,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAA;IAErB,OAAO;QACL,WAAW;QACX,eAAe;QACf,SAAS;QACT,KAAK;KACN,CAAA;AACH,CAAC,CAAA"}
@@ -1,48 +0,0 @@
1
- /*!
2
- * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
3
- *
4
- * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
5
- *
6
- * The Original Code is manuscripts-frontend.
7
- *
8
- * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
- *
10
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
- */
12
- import { schema } from '@manuscripts/transform';
13
- import { isEqual } from 'lodash';
14
- import { createComparisonSetAttrsDataTracked } from './create-dataTracked-attrs';
15
- import { distributeNodesForComparison } from './distribute-nodes';
16
- import { rebuildDocNodeTree } from './rebuild-nodes-tree';
17
- // The entry point for the comparison mode, which is used to compare two ManuscriptNode trees
18
- // It distributes the nodes, rebuilds the nodes tree and then creates a new ManuscriptNode tree
19
- export const compareDocuments = (originalSnapshot, comparisonSnapshot) => {
20
- const originalDocument = schema.nodeFromJSON(originalSnapshot.snapshot);
21
- const comparisonDocument = schema.nodeFromJSON(comparisonSnapshot.snapshot);
22
- const distributedNodes = distributeNodesForComparison(originalDocument, comparisonDocument);
23
- const distributedNodesArray = [];
24
- distributedNodes.forEach((_, key) => {
25
- distributedNodesArray.push(rebuildDocNodeTree(key, distributedNodes));
26
- });
27
- const manuscript = schema.nodes.manuscript.create(comparisonDocument.attrs, distributedNodesArray);
28
- return manuscript;
29
- };
30
- // Compares the attributes of two nodes and returns a new node with the updated attributes
31
- export const compareSingleNodeAttrs = (originalNode, comparisonNode, nodeType, rebuiltChildren) => {
32
- const originalAttrs = originalNode?.attrs || {};
33
- const comparisonAttrs = comparisonNode?.attrs || {};
34
- if (!isEqual(originalAttrs, comparisonAttrs)) {
35
- return nodeType.create({
36
- ...comparisonAttrs,
37
- dataTracked: [createComparisonSetAttrsDataTracked('', originalAttrs)],
38
- }, rebuiltChildren.length > 0
39
- ? rebuiltChildren
40
- : comparisonNode?.content || null);
41
- }
42
- else {
43
- return nodeType.create(comparisonAttrs, rebuiltChildren.length > 0
44
- ? rebuiltChildren
45
- : comparisonNode?.content || null);
46
- }
47
- };
48
- //# sourceMappingURL=compare-documents.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compare-documents.js","sourceRoot":"","sources":["../../../../src/lib/comparison/compare-documents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAkB,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAIhC,OAAO,EAAE,mCAAmC,EAAE,MAAM,4BAA4B,CAAA;AAChF,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD,6FAA6F;AAC7F,+FAA+F;AAC/F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,gBAAoC,EACpC,kBAAsC,EACtC,EAAE;IACF,MAAM,gBAAgB,GAAG,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IACvE,MAAM,kBAAkB,GAAG,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAA;IAE3E,MAAM,gBAAgB,GAAG,4BAA4B,CACnD,gBAAgB,EAChB,kBAAkB,CACnB,CAAA;IACD,MAAM,qBAAqB,GAAqB,EAAE,CAAA;IAClD,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE;QAClC,qBAAqB,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAA;IACvE,CAAC,CAAC,CAAA;IAEF,MAAM,UAA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