@manuscripts/article-editor 1.9.4 → 1.9.5-LEAN-3083-2

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 (121) hide show
  1. package/dist/cjs/src/components/Sidebar/Sidebar.js +1 -2
  2. package/dist/cjs/src/components/Sidebar/Sidebar.js.map +1 -1
  3. package/dist/cjs/src/components/metadata/AuthorModalViews.js +7 -3
  4. package/dist/cjs/src/components/metadata/AuthorModalViews.js.map +1 -1
  5. package/dist/cjs/src/components/metadata/AuthorsPage.js +1 -11
  6. package/dist/cjs/src/components/metadata/AuthorsPage.js.map +1 -1
  7. package/dist/cjs/src/components/projects/ManuscriptPageContainer.js +0 -14
  8. package/dist/cjs/src/components/projects/ManuscriptPageContainer.js.map +1 -1
  9. package/dist/cjs/src/hooks/use-create-editor.js +2 -22
  10. package/dist/cjs/src/hooks/use-create-editor.js.map +1 -1
  11. package/dist/cjs/src/hooks/use-tracked-model-management.js +10 -0
  12. package/dist/cjs/src/hooks/use-tracked-model-management.js.map +1 -1
  13. package/dist/cjs/src/lib/authors.js +3 -1
  14. package/dist/cjs/src/lib/authors.js.map +1 -1
  15. package/dist/es/src/components/Sidebar/Sidebar.js +1 -2
  16. package/dist/es/src/components/Sidebar/Sidebar.js.map +1 -1
  17. package/dist/es/src/components/metadata/AuthorModalViews.js +7 -3
  18. package/dist/es/src/components/metadata/AuthorModalViews.js.map +1 -1
  19. package/dist/es/src/components/metadata/AuthorsPage.js +0 -9
  20. package/dist/es/src/components/metadata/AuthorsPage.js.map +1 -1
  21. package/dist/es/src/components/projects/ManuscriptPageContainer.js +0 -14
  22. package/dist/es/src/components/projects/ManuscriptPageContainer.js.map +1 -1
  23. package/dist/es/src/hooks/use-create-editor.js +2 -22
  24. package/dist/es/src/hooks/use-create-editor.js.map +1 -1
  25. package/dist/es/src/hooks/use-tracked-model-management.js +10 -0
  26. package/dist/es/src/hooks/use-tracked-model-management.js.map +1 -1
  27. package/dist/es/src/lib/authors.js +3 -1
  28. package/dist/es/src/lib/authors.js.map +1 -1
  29. package/dist/types/src/components/metadata/AuthorsPage.d.ts +0 -1
  30. package/dist/types/src/store/useStore.d.ts +1 -1
  31. package/package.json +5 -6
  32. package/dist/cjs/src/components/SelectField.js +0 -24
  33. package/dist/cjs/src/components/SelectField.js.map +0 -1
  34. package/dist/cjs/src/components/library/BibliographyImportButton.js +0 -149
  35. package/dist/cjs/src/components/library/BibliographyImportButton.js.map +0 -1
  36. package/dist/cjs/src/components/library/CitationEditor.js +0 -227
  37. package/dist/cjs/src/components/library/CitationEditor.js.map +0 -1
  38. package/dist/cjs/src/components/library/CitationModal.js +0 -262
  39. package/dist/cjs/src/components/library/CitationModal.js.map +0 -1
  40. package/dist/cjs/src/components/library/CitationSearch.js +0 -214
  41. package/dist/cjs/src/components/library/CitationSearch.js.map +0 -1
  42. package/dist/cjs/src/components/library/CitationSearchSection.js +0 -133
  43. package/dist/cjs/src/components/library/CitationSearchSection.js.map +0 -1
  44. package/dist/cjs/src/components/library/CitationViewer.js +0 -53
  45. package/dist/cjs/src/components/library/CitationViewer.js.map +0 -1
  46. package/dist/cjs/src/components/library/ReferenceForm.js +0 -419
  47. package/dist/cjs/src/components/library/ReferenceForm.js.map +0 -1
  48. package/dist/cjs/src/components/library/ReferencesEditor.js +0 -70
  49. package/dist/cjs/src/components/library/ReferencesEditor.js.map +0 -1
  50. package/dist/cjs/src/components/library/ReferencesViewer.js +0 -33
  51. package/dist/cjs/src/components/library/ReferencesViewer.js.map +0 -1
  52. package/dist/cjs/src/components/library/SearchResults.js +0 -126
  53. package/dist/cjs/src/components/library/SearchResults.js.map +0 -1
  54. package/dist/cjs/src/components/metadata/AuthorsInlineViewContainer.js +0 -94
  55. package/dist/cjs/src/components/metadata/AuthorsInlineViewContainer.js.map +0 -1
  56. package/dist/cjs/src/components/projects/icons/DeleteIcon.js +0 -27
  57. package/dist/cjs/src/components/projects/icons/DeleteIcon.js.map +0 -1
  58. package/dist/cjs/src/components/projects/icons/GroupIcon.js +0 -29
  59. package/dist/cjs/src/components/projects/icons/GroupIcon.js.map +0 -1
  60. package/dist/cjs/src/components/projects/icons/LinkIcon.js +0 -23
  61. package/dist/cjs/src/components/projects/icons/LinkIcon.js.map +0 -1
  62. package/dist/cjs/src/components/projects/icons/TemplateIcon.js +0 -23
  63. package/dist/cjs/src/components/projects/icons/TemplateIcon.js.map +0 -1
  64. package/dist/cjs/src/lib/select-styles.js +0 -40
  65. package/dist/cjs/src/lib/select-styles.js.map +0 -1
  66. package/dist/cjs/src/lib/sources.js +0 -36
  67. package/dist/cjs/src/lib/sources.js.map +0 -1
  68. package/dist/es/src/components/SelectField.js +0 -17
  69. package/dist/es/src/components/SelectField.js.map +0 -1
  70. package/dist/es/src/components/library/BibliographyImportButton.js +0 -120
  71. package/dist/es/src/components/library/BibliographyImportButton.js.map +0 -1
  72. package/dist/es/src/components/library/CitationEditor.js +0 -198
  73. package/dist/es/src/components/library/CitationEditor.js.map +0 -1
  74. package/dist/es/src/components/library/CitationModal.js +0 -232
  75. package/dist/es/src/components/library/CitationModal.js.map +0 -1
  76. package/dist/es/src/components/library/CitationSearch.js +0 -184
  77. package/dist/es/src/components/library/CitationSearch.js.map +0 -1
  78. package/dist/es/src/components/library/CitationSearchSection.js +0 -103
  79. package/dist/es/src/components/library/CitationSearchSection.js.map +0 -1
  80. package/dist/es/src/components/library/CitationViewer.js +0 -46
  81. package/dist/es/src/components/library/CitationViewer.js.map +0 -1
  82. package/dist/es/src/components/library/ReferenceForm.js +0 -389
  83. package/dist/es/src/components/library/ReferenceForm.js.map +0 -1
  84. package/dist/es/src/components/library/ReferencesEditor.js +0 -43
  85. package/dist/es/src/components/library/ReferencesEditor.js.map +0 -1
  86. package/dist/es/src/components/library/ReferencesViewer.js +0 -26
  87. package/dist/es/src/components/library/ReferencesViewer.js.map +0 -1
  88. package/dist/es/src/components/library/SearchResults.js +0 -119
  89. package/dist/es/src/components/library/SearchResults.js.map +0 -1
  90. package/dist/es/src/components/metadata/AuthorsInlineViewContainer.js +0 -65
  91. package/dist/es/src/components/metadata/AuthorsInlineViewContainer.js.map +0 -1
  92. package/dist/es/src/components/projects/icons/DeleteIcon.js +0 -20
  93. package/dist/es/src/components/projects/icons/DeleteIcon.js.map +0 -1
  94. package/dist/es/src/components/projects/icons/GroupIcon.js +0 -22
  95. package/dist/es/src/components/projects/icons/GroupIcon.js.map +0 -1
  96. package/dist/es/src/components/projects/icons/LinkIcon.js +0 -16
  97. package/dist/es/src/components/projects/icons/LinkIcon.js.map +0 -1
  98. package/dist/es/src/components/projects/icons/TemplateIcon.js +0 -16
  99. package/dist/es/src/components/projects/icons/TemplateIcon.js.map +0 -1
  100. package/dist/es/src/lib/select-styles.js +0 -37
  101. package/dist/es/src/lib/select-styles.js.map +0 -1
  102. package/dist/es/src/lib/sources.js +0 -33
  103. package/dist/es/src/lib/sources.js.map +0 -1
  104. package/dist/types/src/components/SelectField.d.ts +0 -23
  105. package/dist/types/src/components/library/BibliographyImportButton.d.ts +0 -23
  106. package/dist/types/src/components/library/CitationEditor.d.ts +0 -30
  107. package/dist/types/src/components/library/CitationModal.d.ts +0 -17
  108. package/dist/types/src/components/library/CitationSearch.d.ts +0 -22
  109. package/dist/types/src/components/library/CitationSearchSection.d.ts +0 -34
  110. package/dist/types/src/components/library/CitationViewer.d.ts +0 -18
  111. package/dist/types/src/components/library/ReferenceForm.d.ts +0 -51
  112. package/dist/types/src/components/library/ReferencesEditor.d.ts +0 -22
  113. package/dist/types/src/components/library/ReferencesViewer.d.ts +0 -9
  114. package/dist/types/src/components/library/SearchResults.d.ts +0 -26
  115. package/dist/types/src/components/metadata/AuthorsInlineViewContainer.d.ts +0 -23
  116. package/dist/types/src/components/projects/icons/DeleteIcon.d.ts +0 -13
  117. package/dist/types/src/components/projects/icons/GroupIcon.d.ts +0 -15
  118. package/dist/types/src/components/projects/icons/LinkIcon.d.ts +0 -13
  119. package/dist/types/src/components/projects/icons/TemplateIcon.d.ts +0 -13
  120. package/dist/types/src/lib/select-styles.d.ts +0 -13
  121. package/dist/types/src/lib/sources.d.ts +0 -25
@@ -1,262 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.Fieldset = exports.Container = exports.Label = exports.Fields = exports.Legend = exports.CitationModal = void 0;
30
- /*!
31
- * 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.
32
- *
33
- * 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.
34
- *
35
- * The Original Code is manuscripts-frontend.
36
- *
37
- * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
38
- *
39
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2022 Atypon Systems LLC. All Rights Reserved.
40
- */
41
- const ReferenceLibraryIcon_1 = __importDefault(require("@manuscripts/assets/react/ReferenceLibraryIcon"));
42
- const json_schema_1 = require("@manuscripts/json-schema");
43
- const library_1 = require("@manuscripts/library");
44
- const style_guide_1 = require("@manuscripts/style-guide");
45
- const transform_1 = require("@manuscripts/transform");
46
- const lodash_es_1 = require("lodash-es");
47
- const react_1 = __importStar(require("react"));
48
- const react_tooltip_1 = __importDefault(require("react-tooltip"));
49
- const styled_components_1 = __importStar(require("styled-components"));
50
- const use_scroll_detection_1 = require("../../hooks/use-scroll-detection");
51
- const AuthorsModals_1 = require("../metadata/AuthorsModals");
52
- const GroupIcon_1 = require("../projects/icons/GroupIcon");
53
- const Sidebar_1 = require("../Sidebar");
54
- const CitationEditor_1 = require("./CitationEditor");
55
- const ReferenceForm_1 = __importStar(require("./ReferenceForm"));
56
- const CitationModal = ({ editCitation, modelMap, saveCallback, selectedItem, setSelectedItem, setShowEditModel, deleteCallback, }) => {
57
- const stopEditing = (0, react_1.useCallback)(() => setShowEditModel(false), [setShowEditModel]);
58
- const formMikRef = (0, react_1.useRef)(null);
59
- const [{ referenceCount, references }, setReferences] = (0, react_1.useState)({
60
- referenceCount: new Map(),
61
- references: [],
62
- });
63
- const [showPendingChangeDialog, setShowPendingChangeDialog] = (0, react_1.useState)(false);
64
- const onSelectReference = (0, react_1.useCallback)((e) => {
65
- const other = formMikRef.current?.values;
66
- if (!selectedItem || (0, lodash_es_1.isEqual)((0, ReferenceForm_1.buildInitialValues)(selectedItem), other)) {
67
- setSelectedItem(references.find(({ _id }) => _id === e.currentTarget.id));
68
- }
69
- else {
70
- setShowPendingChangeDialog(true);
71
- }
72
- }, [references, selectedItem, setSelectedItem]);
73
- (0, react_1.useEffect)(() => {
74
- if (editCitation) {
75
- const references = (0, transform_1.getModelsByType)(modelMap, json_schema_1.ObjectTypes.BibliographyItem);
76
- const referenceCount = new Map();
77
- (0, transform_1.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Citation).map(({ embeddedCitationItems }) => embeddedCitationItems.map(({ bibliographyItem }) => {
78
- let value = referenceCount.get(bibliographyItem);
79
- referenceCount.set(bibliographyItem, (value && ++value) || 1);
80
- }));
81
- setReferences({ references, referenceCount });
82
- }
83
- }, [editCitation, modelMap]);
84
- const modelDeleteCallback = (0, react_1.useCallback)(() => {
85
- deleteCallback();
86
- setReferences({
87
- referenceCount,
88
- references: [
89
- ...references.filter(({ _id }) => _id !== selectedItem?._id),
90
- ],
91
- });
92
- }, [deleteCallback, referenceCount, references, selectedItem?._id]);
93
- const modelSaveCallback = (0, react_1.useCallback)((item) => {
94
- saveCallback(item);
95
- setSelectedItem(item);
96
- setReferences({
97
- referenceCount,
98
- references: [
99
- ...references.map((ref) => (ref._id === item?._id ? item : ref)),
100
- ],
101
- });
102
- }, [referenceCount, references, saveCallback, setSelectedItem]);
103
- const disableDelete = ((selectedItem?._id && referenceCount.get(selectedItem._id)) || 0) > 0;
104
- const selectedReferenceNode = (0, react_1.useRef)(null);
105
- const selectedIndex = (0, react_1.useMemo)(() => selectedItem
106
- ? references.findIndex((i) => selectedItem?._id == i._id)
107
- : 0, [selectedItem, references]);
108
- (0, react_1.useEffect)(() => {
109
- setTimeout(() => {
110
- selectedReferenceNode.current?.scrollIntoView({
111
- block: 'center',
112
- behavior: 'auto',
113
- });
114
- }, 100);
115
- }, [selectedIndex]);
116
- const selectedItemTopOffset = 10; // to be able to place the selected item in the middle and allow for some scroll at the top
117
- const pageItemsCount = 12;
118
- const topTrigger = 0.2; // says: notify when x% of the offsetHeight remains hidden at the top
119
- const bottomTrigger = 0.8; // says: notify when x% of the offsetHeight remains hidden at the bottom
120
- const dropLimit = pageItemsCount * 3; // basically maximum amount of items that can exist at the same time
121
- const { ref, triggers } = (0, use_scroll_detection_1.useScrollDetection)(topTrigger, bottomTrigger);
122
- const [firstDisplayIndex, setFirstDisplayIndex] = (0, react_1.useState)(Math.max(0, selectedIndex - selectedItemTopOffset));
123
- const [lastDisplayIndex, setLastDisplayIndex] = (0, react_1.useState)(pageItemsCount);
124
- (0, react_1.useEffect)(() => {
125
- const base = Math.max(0, selectedIndex - selectedItemTopOffset);
126
- setFirstDisplayIndex(base);
127
- setLastDisplayIndex(Math.min(references.length - 1, base + pageItemsCount));
128
- // eslint-disable-next-line react-hooks/exhaustive-deps
129
- }, [references.length]); // this has to run only on start and never on selection change
130
- (0, react_1.useEffect)(() => {
131
- if (triggers.top) {
132
- const newFirst = Math.max(0, firstDisplayIndex - pageItemsCount);
133
- setFirstDisplayIndex(newFirst);
134
- setLastDisplayIndex(Math.min(newFirst + dropLimit, lastDisplayIndex));
135
- }
136
- if (triggers.bottom) {
137
- const newLast = Math.min(references.length - 1, lastDisplayIndex + pageItemsCount);
138
- setLastDisplayIndex(newLast);
139
- setFirstDisplayIndex(Math.max(newLast - dropLimit, firstDisplayIndex));
140
- }
141
- // eslint-disable-next-line react-hooks/exhaustive-deps
142
- }, [dropLimit, pageItemsCount, triggers, references]);
143
- const displayableRefs = (0, react_1.useMemo)(() => {
144
- const refs = new Map();
145
- if (references.length) {
146
- for (let i = firstDisplayIndex; i <= lastDisplayIndex; i++) {
147
- references[i] && refs.set(i, references[i]);
148
- }
149
- }
150
- return refs;
151
- }, [firstDisplayIndex, lastDisplayIndex, references]);
152
- if (references.length <= 0) {
153
- return react_1.default.createElement(react_1.default.Fragment, null);
154
- }
155
- return (react_1.default.createElement(style_guide_1.StyledModal, { "data-cy": "citations-modal", isOpen: editCitation, onRequestClose: stopEditing, shouldCloseOnOverlayClick: true },
156
- react_1.default.createElement(style_guide_1.Dialog, { isOpen: showPendingChangeDialog, category: style_guide_1.Category.confirmation, header: "You've made changes to this option", message: "Would you like to save or discard your changes?", actions: {
157
- secondary: {
158
- action: () => {
159
- formMikRef.current?.resetForm();
160
- setShowPendingChangeDialog(false);
161
- },
162
- title: 'Discard',
163
- },
164
- primary: {
165
- action: () => {
166
- modelSaveCallback(formMikRef.current?.values);
167
- setShowPendingChangeDialog(false);
168
- },
169
- title: 'Save',
170
- },
171
- } }),
172
- react_1.default.createElement(style_guide_1.ModalContainer, null,
173
- react_1.default.createElement(style_guide_1.ModalHeader, null,
174
- react_1.default.createElement(style_guide_1.CloseButton, { onClick: stopEditing })),
175
- react_1.default.createElement(Sidebar_1.ModalBody, null,
176
- react_1.default.createElement(ReferencesSidebar, null,
177
- react_1.default.createElement(Sidebar_1.SidebarHeader, { title: 'References' }),
178
- react_1.default.createElement(ReferencesSidebarContent, { ref: ref },
179
- react_1.default.createElement(ReferencesInnerWrapper, { "data-cy": "references-list", style: { paddingTop: '0px' } }, [...displayableRefs.entries()].map(([index, item]) => (react_1.default.createElement(ReferenceButton, { key: index, id: item._id, onClick: onSelectReference, selected: selectedItem?._id === item._id, ref: selectedItem?._id === item._id
180
- ? selectedReferenceNode
181
- : null },
182
- react_1.default.createElement(IconContainer, { "data-tip": true, "data-for": 'group-icon' },
183
- react_1.default.createElement(ReferenceLibraryIcon_1.default, null),
184
- react_1.default.createElement(GroupIcon_1.GroupIcon, { numberOfCitations: referenceCount.get(item._id) || 0 }),
185
- react_1.default.createElement(react_tooltip_1.default, { disable: (referenceCount.get(item._id) || 0) < 1, id: 'group-icon', place: "bottom", effect: "solid", offset: { top: 40 }, className: "tooltip" }, "Number of times used in the document")),
186
- react_1.default.createElement(Grid, null,
187
- react_1.default.createElement(CitationEditor_1.CitedItemTitle, { value: item.title || 'Untitled', withOverflow: true }),
188
- react_1.default.createElement(CitationEditor_1.CitedItemMetadata, null, (0, library_1.shortLibraryItemMetadata)(item))))))))),
189
- react_1.default.createElement(AuthorsModals_1.ScrollableModalMain, null, selectedItem && (react_1.default.createElement(ReferenceForm_1.default, { item: selectedItem, formMikRef: formMikRef, disableDelete: disableDelete, deleteCallback: modelDeleteCallback, handleCancel: stopEditing, saveCallback: modelSaveCallback })))))));
190
- };
191
- exports.CitationModal = CitationModal;
192
- const ReferencesInnerWrapper = styled_components_1.default.div `
193
- width: 100%;
194
- `;
195
- const ReferencesSidebar = (0, styled_components_1.default)(Sidebar_1.ModalSidebar) `
196
- width: 70%;
197
- `;
198
- const ReferencesSidebarContent = (0, styled_components_1.default)(Sidebar_1.SidebarContent) `
199
- overflow-y: auto;
200
- `;
201
- const Grid = styled_components_1.default.div `
202
- display: grid;
203
- `;
204
- exports.Legend = styled_components_1.default.legend `
205
- font: ${(props) => props.theme.font.weight.normal}
206
- ${(props) => props.theme.font.size.xlarge} /
207
- ${(props) => props.theme.font.lineHeight.large}
208
- ${(props) => props.theme.font.family.sans};
209
- letter-spacing: -0.4px;
210
- color: ${(props) => props.theme.colors.text.secondary};
211
- `;
212
- exports.Fields = styled_components_1.default.div `
213
- padding: 16px;
214
- `;
215
- exports.Label = styled_components_1.default.label `
216
- display: flex;
217
- flex-direction: column;
218
- margin-bottom: 10px;
219
- `;
220
- exports.Container = styled_components_1.default.div `
221
- display: flex;
222
- justify-content: space-between;
223
- `;
224
- exports.Fieldset = styled_components_1.default.fieldset `
225
- border: none;
226
-
227
- &:not(:last-child) {
228
- margin-bottom: 16px;
229
- }
230
- `;
231
- const selectedReferenceStyle = (0, styled_components_1.css) `
232
- background: ${(props) => props.theme.colors.background.info};
233
- border-top: 1px solid #bce7f6;
234
- border-bottom: 1px solid #bce7f6;
235
- `;
236
- const ReferenceButton = styled_components_1.default.div `
237
- cursor: pointer;
238
- display: flex;
239
- justify-content: flex-start;
240
- padding: ${(props) => props.theme.grid.unit * 4}px 0;
241
-
242
- path {
243
- fill: #c9c9c9;
244
- }
245
-
246
- :hover {
247
- background: ${(props) => props.theme.colors.background.info};
248
- }
249
-
250
- ${(props) => props.selected && selectedReferenceStyle}
251
-
252
- .tooltip {
253
- max-width: ${(props) => props.theme.grid.unit * 25}px;
254
- padding: ${(props) => props.theme.grid.unit * 2}px;
255
- border-radius: 6px;
256
- }
257
- `;
258
- const IconContainer = styled_components_1.default.div `
259
- padding-right: ${(props) => props.theme.grid.unit * 5}px;
260
- position: relative;
261
- `;
262
- //# sourceMappingURL=CitationModal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CitationModal.js","sourceRoot":"","sources":["../../../../../src/components/library/CitationModal.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;GAUG;AACH,0GAAiF;AACjF,0DAKiC;AACjC,kDAA+D;AAC/D,0DAOiC;AACjC,sDAAwD;AAExD,yCAAmC;AACnC,+CAAgF;AAChF,kEAAwC;AACxC,uEAA+C;AAE/C,2EAAqE;AACrE,6DAA+D;AAC/D,2DAAuD;AACvD,wCAKmB;AACnB,qDAAoE;AACpE,iEAGwB;AAEjB,MAAM,aAAa,GAQrB,CAAC,EACJ,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,cAAc,GACf,EAAE,EAAE;IACH,MAAM,WAAW,GAAG,IAAA,mBAAW,EAC7B,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAC7B,CAAC,gBAAgB,CAAC,CACnB,CAAA;IAED,MAAM,UAAU,GAAG,IAAA,cAAM,EAAmC,IAAI,CAAC,CAAA;IAEjE,MAAM,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAG7D;QACD,cAAc,EAAE,IAAI,GAAG,EAAE;QACzB,UAAU,EAAE,EAAE;KACf,CAAC,CAAA;IACF,MAAM,CAAC,uBAAuB,EAAE,0BAA0B,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAA;IAE7E,MAAM,iBAAiB,GAAG,IAAA,mBAAW,EACnC,CAAC,CAAC,EAAE,EAAE;QACJ,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,MAAM,CAAA;QACx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AAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI;;;IAG3D,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,IAAI,sBAAsB;;;iBAGtC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE;eACvC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;;;CAGlD,CAAA;AAED,MAAM,aAAa,GAAG,2BAAM,CAAC,GAAG,CAAA;mBACb,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;;CAEtD,CAAA"}
@@ -1,214 +0,0 @@
1
- "use strict";
2
- /*!
3
- * 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.
4
- *
5
- * 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.
6
- *
7
- * The Original Code is manuscripts-frontend.
8
- *
9
- * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
10
- *
11
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
12
- */
13
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- var desc = Object.getOwnPropertyDescriptor(m, k);
16
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
- desc = { enumerable: true, get: function() { return m[k]; } };
18
- }
19
- Object.defineProperty(o, k2, desc);
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
- Object.defineProperty(o, "default", { enumerable: true, value: v });
26
- }) : function(o, v) {
27
- o["default"] = v;
28
- });
29
- var __importStar = (this && this.__importStar) || function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
- __setModuleDefault(result, mod);
34
- return result;
35
- };
36
- var __importDefault = (this && this.__importDefault) || function (mod) {
37
- return (mod && mod.__esModule) ? mod : { "default": mod };
38
- };
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.CitationSearch = void 0;
41
- const body_editor_1 = require("@manuscripts/body-editor");
42
- const library_1 = require("@manuscripts/library");
43
- const style_guide_1 = require("@manuscripts/style-guide");
44
- const transform_1 = require("@manuscripts/transform");
45
- const axios_1 = __importDefault(require("axios"));
46
- const lodash_es_1 = require("lodash-es");
47
- const react_1 = __importStar(require("react"));
48
- const styled_components_1 = __importDefault(require("styled-components"));
49
- const search_library_1 = require("../../lib/search-library");
50
- const TemplateIcon_1 = require("../projects/icons/TemplateIcon");
51
- const Search_1 = __importStar(require("../Search"));
52
- const BibliographyImportButton_1 = require("./BibliographyImportButton");
53
- const CitationSearchSection_1 = require("./CitationSearchSection");
54
- const Results = styled_components_1.default.div `
55
- max-height: 400px;
56
- overflow-y: auto;
57
- `;
58
- const Actions = (0, styled_components_1.default)(style_guide_1.ButtonGroup) `
59
- align-items: center;
60
- box-shadow: 0 -2px 12px 0 rgba(216, 216, 216, 0.26);
61
- display: flex;
62
- justify-content: space-between;
63
- padding: ${(props) => props.theme.grid.unit * 4}px;
64
- `;
65
- const Container = styled_components_1.default.div `
66
- flex: 1;
67
- font-family: ${(props) => props.theme.font.family.sans};
68
- `;
69
- const ImportButton = ({ importItems, importing, }) => (react_1.default.createElement(style_guide_1.IconTextButton, { onClick: importItems },
70
- react_1.default.createElement(style_guide_1.Tip, { title: 'Import bibliography data from a BibTeX or RIS file', placement: 'top' }, importing ? ('Importing…') : (react_1.default.createElement(react_1.default.Fragment, null,
71
- react_1.default.createElement(style_guide_1.UploadIcon, null),
72
- "Import from file")))));
73
- const CitationSearch = ({ bibliographyItems, handleCite, addCitation, importItems: _importItems, query: initialQuery, handleCancel, }) => {
74
- const [error, setError] = (0, react_1.useState)();
75
- const [selectedSource, setSelectedSource] = (0, react_1.useState)();
76
- const [query, setQuery] = (0, react_1.useState)(initialQuery);
77
- const [selected, setSelected] = (0, react_1.useState)(new Map());
78
- const [fetching, setFetching] = (0, react_1.useState)(new Set());
79
- const [sources, setSources] = (0, react_1.useState)();
80
- const [updated, setUpdated] = (0, react_1.useState)(Date.now());
81
- const searchLibrary = (0, react_1.useCallback)((query, params) => {
82
- return (0, search_library_1.filterLibrary)(bibliographyItems, query).then((items) => ({
83
- items: items.slice(0, params.rows),
84
- total: items.length,
85
- }));
86
- }, [bibliographyItems]);
87
- const [cancelTokenSource, setCancelTokenSource] = (0, react_1.useState)();
88
- const apiSearchCallback = (0, react_1.useCallback)((query, params, mailto) => {
89
- cancelTokenSource?.cancel();
90
- const sourceToken = axios_1.default.CancelToken.source();
91
- setCancelTokenSource(sourceToken);
92
- return body_editor_1.crossref.search(query, params.rows, mailto, sourceToken.token);
93
- }, [cancelTokenSource]);
94
- (0, react_1.useEffect)(() => {
95
- const sources = [
96
- {
97
- id: 'library',
98
- title: 'Document',
99
- search: searchLibrary,
100
- },
101
- ];
102
- if (query.trim().length > 2) {
103
- sources.push({
104
- id: 'crossref',
105
- title: 'External sources',
106
- search: apiSearchCallback,
107
- });
108
- }
109
- setSources(sources);
110
- }, [apiSearchCallback, query, searchLibrary]);
111
- const addToSelection = (0, react_1.useCallback)((id, data) => {
112
- if (selected.has(id)) {
113
- selected.delete(id); // remove item
114
- setSelected(new Map([...selected]));
115
- }
116
- else if (data._id) {
117
- selected.set(id, data); // re-use existing data model
118
- setSelected(new Map([...selected]));
119
- }
120
- else {
121
- setFetching((fetching) => {
122
- fetching.add(id);
123
- return new Set([...fetching]);
124
- });
125
- // fetch Citeproc JSON
126
- body_editor_1.crossref
127
- .fetch(data)
128
- .then((result) => {
129
- // remove DOI URLs
130
- if (result.URL &&
131
- result.URL.match(/^https?:\/\/(dx\.)?doi\.org\//)) {
132
- delete result.URL;
133
- }
134
- setSelected((selected) => {
135
- selected.set(id, (0, transform_1.buildBibliographyItem)({
136
- ...result,
137
- type: result.type == 'journal-article'
138
- ? 'article-journal'
139
- : result.type,
140
- }));
141
- return new Map([...selected]);
142
- });
143
- window.setTimeout(() => {
144
- setFetching((fetching) => {
145
- fetching.delete(id);
146
- return new Set([...fetching]);
147
- });
148
- }, 100);
149
- })
150
- .catch((error) => {
151
- setError(error.message);
152
- });
153
- }
154
- }, [selected]);
155
- const handleCiteClick = (0, react_1.useCallback)(() => {
156
- const items = Array.from(selected.values());
157
- return handleCite(items);
158
- }, [handleCite, selected]);
159
- const debouncedCallback = (0, lodash_es_1.debounce)((value) => setQuery(value.trim()), 800);
160
- const debouncedSetQuery = (0, react_1.useCallback)((event) => debouncedCallback(event.target.value), [debouncedCallback]);
161
- const importItems = (0, react_1.useCallback)((items) => {
162
- return _importItems(items).then((newItems) => {
163
- setSelected((selected) => {
164
- // if there's a single new imported item, select it
165
- if (newItems.length === 1) {
166
- const [newItem] = newItems;
167
- const estimatedID = (0, library_1.estimateID)(newItem);
168
- selected.set(estimatedID, newItem);
169
- }
170
- return new Map([...selected]);
171
- });
172
- // clear the query after importing items
173
- setQuery('');
174
- // ensure that the filters re-run
175
- setUpdated(Date.now());
176
- return newItems;
177
- });
178
- }, [_importItems]);
179
- if (!sources) {
180
- return null;
181
- }
182
- return (react_1.default.createElement(Container, null,
183
- react_1.default.createElement(Search_1.SearchWrapper, null,
184
- react_1.default.createElement(Search_1.default, { autoComplete: 'off', handleSearchChange: debouncedSetQuery, placeholder: 'Search', defaultValue: initialQuery, type: 'search' })),
185
- react_1.default.createElement(Results, null,
186
- error && react_1.default.createElement("div", null, error),
187
- sources.map((source) => (react_1.default.createElement(CitationSearchSection_1.CitationSearchSection, { key: `${source.id}-${updated}`, source: source, addToSelection: addToSelection, selectSource: () => setSelectedSource(source.id), selected: selected, fetching: fetching, query: query, rows: selectedSource === source.id ? 25 : 3 })))),
188
- react_1.default.createElement(Actions, null,
189
- react_1.default.createElement(AddCitationActions, null,
190
- react_1.default.createElement(BibliographyImportButton_1.BibliographyImportButton, { importItems: importItems, component: ImportButton }),
191
- react_1.default.createElement(style_guide_1.IconTextButton, { onClick: addCitation },
192
- react_1.default.createElement(TemplateIcon_1.TemplateIcon, null),
193
- "Add new")),
194
- react_1.default.createElement(style_guide_1.ButtonGroup, null,
195
- react_1.default.createElement(style_guide_1.SecondaryButton, { onClick: handleCancel }, "Close"),
196
- react_1.default.createElement(style_guide_1.PrimaryButton, { onClick: handleCiteClick, disabled: selected.size === 0 }, "Cite")))));
197
- };
198
- exports.CitationSearch = CitationSearch;
199
- const AddCitationActions = (0, styled_components_1.default)(style_guide_1.ButtonGroup) `
200
- button {
201
- margin-right: ${(props) => props.theme.grid.unit * 8}px;
202
- }
203
-
204
- button:hover,
205
- button:active {
206
- path {
207
- stroke: ${(props) => props.theme.colors.brand.medium};
208
- }
209
- rect {
210
- stroke: ${(props) => props.theme.colors.brand.medium};
211
- }
212
- }
213
- `;
214
- //# sourceMappingURL=CitationSearch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CitationSearch.js","sourceRoot":"","sources":["../../../../../src/components/library/CitationSearch.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,0DAAmD;AAEnD,kDAAiD;AACjD,0DAOiC;AACjC,sDAAqE;AACrE,kDAAgD;AAChD,yCAAoC;AACpC,+CAA4E;AAC5E,0EAA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,MAAM,CAAC,KAAK,CAAC,MAAM;;;gBAG1C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM;;;CAGzD,CAAA"}
@@ -1,133 +0,0 @@
1
- "use strict";
2
- /*!
3
- * 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.
4
- *
5
- * 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.
6
- *
7
- * The Original Code is manuscripts-frontend.
8
- *
9
- * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
10
- *
11
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
12
- */
13
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- var desc = Object.getOwnPropertyDescriptor(m, k);
16
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
- desc = { enumerable: true, get: function() { return m[k]; } };
18
- }
19
- Object.defineProperty(o, k2, desc);
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
- Object.defineProperty(o, "default", { enumerable: true, value: v });
26
- }) : function(o, v) {
27
- o["default"] = v;
28
- });
29
- var __importStar = (this && this.__importStar) || function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
- __setModuleDefault(result, mod);
34
- return result;
35
- };
36
- var __importDefault = (this && this.__importDefault) || function (mod) {
37
- return (mod && mod.__esModule) ? mod : { "default": mod };
38
- };
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.SearchingLabel = exports.CitationSearchSection = void 0;
41
- const ArrowDownBlack_1 = __importDefault(require("@manuscripts/assets/react/ArrowDownBlack"));
42
- const style_guide_1 = require("@manuscripts/style-guide");
43
- const react_1 = __importStar(require("react"));
44
- const styled_components_1 = __importDefault(require("styled-components"));
45
- const config_1 = __importDefault(require("../../config"));
46
- const SearchResults_1 = require("./SearchResults");
47
- const ResultsSection = styled_components_1.default.div `
48
- margin: ${(props) => props.theme.grid.unit * 2}px 0;
49
- `;
50
- const SearchSource = styled_components_1.default.div `
51
- margin: 0 ${(props) => props.theme.grid.unit * 4}px
52
- ${(props) => props.theme.grid.unit * 2}px;
53
- color: ${(props) => props.theme.colors.text.secondary};
54
- cursor: pointer;
55
-
56
- &:hover {
57
- color: ${(props) => props.theme.colors.text.muted};
58
- }
59
- `;
60
- const MoreButton = (0, styled_components_1.default)(style_guide_1.SecondaryButton) `
61
- font-size: inherit;
62
- text-transform: none;
63
- text-decoration: underline;
64
- border: none;
65
- margin-left: ${(props) => props.theme.grid.unit * 4}px;
66
- color: ${(props) => props.theme.colors.button.default.color.default};
67
- `;
68
- const DropdownChevron = (0, styled_components_1.default)(ArrowDownBlack_1.default) `
69
- margin-right: ${(props) => props.theme.grid.unit * 4}px;
70
- width: ${(props) => props.theme.grid.unit * 6}px;
71
- `;
72
- const CitationSearchSection = ({ query, source, addToSelection, selectSource, rows, selected, fetching, }) => {
73
- const [error, setError] = (0, react_1.useState)();
74
- const [expanded, setExpanded] = (0, react_1.useState)(true);
75
- const [searching, setSearching] = (0, react_1.useState)(false);
76
- const [showMoreSearching, setShowMoreSearching] = (0, react_1.useState)(false);
77
- const [results, setResults] = (0, react_1.useState)();
78
- (0, react_1.useEffect)(() => {
79
- setError(undefined);
80
- setResults(undefined);
81
- setShowMoreSearching(false);
82
- setSearching(query !== '');
83
- }, [query]);
84
- const handleSearchResults = (0, react_1.useCallback)((searchQuery, results) => {
85
- if (searchQuery === query) {
86
- setError(undefined);
87
- setSearching(false);
88
- setShowMoreSearching(false);
89
- setResults(results);
90
- }
91
- }, [query]);
92
- (0, react_1.useEffect)(() => {
93
- if (!expanded) {
94
- return;
95
- }
96
- if (source.id !== 'library' && !query) {
97
- return;
98
- }
99
- source
100
- .search(query, { rows }, config_1.default.support.email)
101
- .then((results) => {
102
- handleSearchResults(query, results);
103
- })
104
- .catch((error) => {
105
- setError(error.message);
106
- });
107
- // eslint-disable-next-line react-hooks/exhaustive-deps
108
- }, [query, expanded, handleSearchResults, rows]);
109
- const toggleExpanded = (0, react_1.useCallback)(() => {
110
- setExpanded((value) => !value);
111
- }, []);
112
- const showMoreCallback = (0, react_1.useCallback)(() => {
113
- selectSource(source.id);
114
- setSearching(true);
115
- setShowMoreSearching(true);
116
- }, [selectSource, source.id]);
117
- return (react_1.default.createElement(ResultsSection, null,
118
- react_1.default.createElement(SearchSource, { onClick: toggleExpanded },
119
- react_1.default.createElement(DropdownChevron, { style: {
120
- transform: expanded ? 'rotate(0)' : 'rotate(-90deg)',
121
- } }),
122
- source.title),
123
- expanded && (react_1.default.createElement(SearchResults_1.SearchResults, { error: error, results: results, searching: searching, showMoreSearching: showMoreSearching, handleSelect: addToSelection, selected: selected, fetching: fetching })),
124
- showMoreSearching && react_1.default.createElement(exports.SearchingLabel, null, "Searching...."),
125
- expanded && results && results.total > rows && rows < 25 && (react_1.default.createElement(MoreButton, { onClick: showMoreCallback, "data-cy": 'more-button' }, "Show more"))));
126
- };
127
- exports.CitationSearchSection = CitationSearchSection;
128
- exports.SearchingLabel = styled_components_1.default.div `
129
- color: ${(props) => props.theme.colors.text.secondary};
130
- margin: ${(props) => props.theme.grid.unit * 4}px
131
- ${(props) => props.theme.grid.unit * 5}px;
132
- `;
133
- //# sourceMappingURL=CitationSearchSection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CitationSearchSection.js","sourceRoot":"","sources":["../../../../../src/components/library/CitationSearchSection.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8FAAqE;AAErE,0DAA0D;AAE1D,+CAA+D;AAC/D,0EAAsC;AAEtC,0DAAiC;AACjC,mDAA+C;AAE/C,MAAM,cAAc,GAAG,2BAAM,CAAC,GAAG,CAAA;YACrB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;CAC/C,CAAA;AAED,MAAM,YAAY,GAAG,2BAAM,CAAC,GAAG,CAAA;cACjB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;MAC5C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;WAC/B,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;;;;aAI1C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK;;CAEpD,CAAA;AAED,MAAM,UAAU,GAAG,IAAA,2BAAM,EAAC,6BAAe,CAAC,CAAA;;;;;iBAKzB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;WAC1C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO;CACpE,CAAA;AAED,MAAM,eAAe,GAAG,IAAA,2BAAM,EAAC,wBAAc,CAAC,CAAA;kBAC5B,CAAC,KAAK,EAAE,EA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