@soomo/react-text-annotator 3.1.0-staging.15 → 3.1.0-staging.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/TextAnnotationPopup/TextAnnotationPopup.d.ts +21 -0
- package/dist/TextAnnotationPopup/TextAnnotationPopup.d.ts.map +1 -0
- package/dist/TextAnnotationPopup/index.d.ts +2 -0
- package/dist/TextAnnotationPopup/index.d.ts.map +1 -0
- package/dist/TextAnnotationPopup/isMobile.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/react-text-annotator.es.js +2 -1
- package/dist/react-text-annotator.es11.js.map +1 -1
- package/dist/react-text-annotator.es12.js.map +1 -1
- package/dist/react-text-annotator.es13.js.map +1 -1
- package/dist/react-text-annotator.es14.js +116 -2
- package/dist/react-text-annotator.es14.js.map +1 -1
- package/dist/react-text-annotator.es15.js.map +1 -1
- package/dist/react-text-annotator.es17.js +37 -1
- package/dist/react-text-annotator.es17.js.map +1 -1
- package/dist/react-text-annotator.es18.js +3 -1
- package/dist/react-text-annotator.es18.js.map +1 -1
- package/dist/react-text-annotator.es2.js.map +1 -1
- package/dist/react-text-annotator.es21.js.map +1 -1
- package/dist/react-text-annotator.es24.js.map +1 -1
- package/dist/react-text-annotator.es25.js.map +1 -1
- package/dist/react-text-annotator.es26.js.map +1 -1
- package/dist/react-text-annotator.es27.js.map +1 -1
- package/dist/react-text-annotator.es28.js.map +1 -1
- package/dist/react-text-annotator.es29.js.map +1 -1
- package/dist/react-text-annotator.es3.js.map +1 -1
- package/dist/react-text-annotator.es30.js.map +1 -1
- package/dist/react-text-annotator.es31.js.map +1 -1
- package/dist/react-text-annotator.es32.js +63 -0
- package/dist/react-text-annotator.es32.js.map +1 -1
- package/dist/react-text-annotator.es4.js.map +1 -1
- package/dist/react-text-annotator.es5.js.map +1 -1
- package/dist/react-text-annotator.es6.js.map +1 -1
- package/dist/react-text-annotator.es7.js +24 -7
- package/dist/react-text-annotator.es7.js.map +1 -1
- package/dist/react-text-annotator.es8.js +197 -183
- package/dist/react-text-annotator.es8.js.map +1 -1
- package/dist/react-text-annotator.es9.js.map +1 -1
- package/package.json +7 -7
- package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts +0 -15
- package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts.map +0 -1
- package/dist/TextAnnotatorPopup/index.d.ts +0 -2
- package/dist/TextAnnotatorPopup/index.d.ts.map +0 -1
- package/dist/TextAnnotatorPopup/isMobile.d.ts.map +0 -1
- /package/dist/{TextAnnotatorPopup → TextAnnotationPopup}/isMobile.d.ts +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { j as jsxRuntimeExports } from "./react-text-annotator.es9.js";
|
|
2
|
-
import { useState, useCallback, useEffect, useMemo } from "react";
|
|
2
|
+
import { useState, useCallback, useEffect, useRef, useMemo } from "react";
|
|
3
3
|
import { useAnnotator, useSelection } from "@annotorious/react";
|
|
4
4
|
import { isRevived, denormalizeRectWithOffset, toDomRectList, NOT_ANNOTATABLE_CLASS } from "@soomo/text-annotator";
|
|
5
|
-
import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager } from "./react-text-annotator.es14.js";
|
|
5
|
+
import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager, FloatingArrow } from "./react-text-annotator.es14.js";
|
|
6
6
|
import { isMobile } from "./react-text-annotator.es15.js";
|
|
7
7
|
import { useAnnouncePopupNavigation } from "./react-text-annotator.es4.js";
|
|
8
8
|
import { useAnnotationTargetIdling } from "./react-text-annotator.es5.js";
|
|
9
9
|
/* empty css */
|
|
10
|
-
import {
|
|
10
|
+
import { inline, offset, flip, shift, arrow } from "./react-text-annotator.es17.js";
|
|
11
11
|
import { autoUpdate } from "./react-text-annotator.es18.js";
|
|
12
|
-
const
|
|
12
|
+
const TextAnnotationPopup = (props) => {
|
|
13
13
|
var _a, _b;
|
|
14
14
|
const { popup, ariaNavigationMessage } = props;
|
|
15
15
|
const r = useAnnotator();
|
|
@@ -24,6 +24,7 @@ const TextAnnotatorPopup = (props) => {
|
|
|
24
24
|
useEffect(() => {
|
|
25
25
|
if (!isOpen) handleBlur();
|
|
26
26
|
}, [isOpen, handleBlur]);
|
|
27
|
+
const arrowRef = useRef(null);
|
|
27
28
|
const { refs, floatingStyles, update, context } = useFloating({
|
|
28
29
|
placement: isMobile() ? "bottom" : "top",
|
|
29
30
|
open: isOpen,
|
|
@@ -34,10 +35,11 @@ const TextAnnotatorPopup = (props) => {
|
|
|
34
35
|
}
|
|
35
36
|
},
|
|
36
37
|
middleware: [
|
|
37
|
-
offset(10),
|
|
38
38
|
inline(),
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
offset(10),
|
|
40
|
+
flip({ crossAxis: true }),
|
|
41
|
+
shift({ crossAxis: true, padding: 10 }),
|
|
42
|
+
arrow({ element: arrowRef })
|
|
41
43
|
],
|
|
42
44
|
whileElementsMounted: autoUpdate
|
|
43
45
|
});
|
|
@@ -111,6 +113,14 @@ const TextAnnotatorPopup = (props) => {
|
|
|
111
113
|
editable: selected[0].editable,
|
|
112
114
|
event
|
|
113
115
|
}),
|
|
116
|
+
props.arrow && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
117
|
+
FloatingArrow,
|
|
118
|
+
{
|
|
119
|
+
ref: arrowRef,
|
|
120
|
+
context,
|
|
121
|
+
...props.arrowProps || {}
|
|
122
|
+
}
|
|
123
|
+
),
|
|
114
124
|
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "r6o-popup-sr-only", "aria-live": "assertive", onClick: handleClose, children: props.ariaCloseWarning || "Click or leave this dialog to close it." })
|
|
115
125
|
]
|
|
116
126
|
}
|
|
@@ -124,7 +134,14 @@ const getStopEventsPropagationProps = () => ({
|
|
|
124
134
|
onMouseDown: (event) => event.stopPropagation(),
|
|
125
135
|
onMouseUp: (event) => event.stopPropagation()
|
|
126
136
|
});
|
|
137
|
+
const TextAnnotatorPopup = (props) => {
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
console.warn("TextAnnotatorPopup is deprecated and will be removed in a future version. Please use TextAnnotationPopup instead.");
|
|
140
|
+
}, []);
|
|
141
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(TextAnnotationPopup, { ...props });
|
|
142
|
+
};
|
|
127
143
|
export {
|
|
144
|
+
TextAnnotationPopup,
|
|
128
145
|
TextAnnotatorPopup
|
|
129
146
|
};
|
|
130
147
|
//# sourceMappingURL=react-text-annotator.es7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-text-annotator.es7.js","sources":["../src/TextAnnotatorPopup/TextAnnotatorPopup.tsx"],"sourcesContent":["import { FC, PointerEvent, MouseEvent, ReactNode, useEffect, useMemo, useState, useCallback } from 'react';\n\nimport { useAnnotator, useSelection } from '@annotorious/react';\nimport {\n isRevived,\n denormalizeRectWithOffset,\n toDomRectList,\n NOT_ANNOTATABLE_CLASS,\n type TextAnnotation,\n type TextAnnotator\n} from '@soomo/text-annotator';\n\nimport {\n autoUpdate,\n flip,\n FloatingFocusManager,\n FloatingPortal,\n inline,\n offset,\n shift,\n useDismiss,\n useFloating,\n useInteractions,\n useRole\n} from '@floating-ui/react';\n\nimport { isMobile } from './isMobile';\nimport { useAnnouncePopupNavigation, useAnnotationTargetIdling } from '../hooks';\n\nimport './TextAnnotatorPopup.css';\n\ninterface TextAnnotationPopupProps {\n\n ariaNavigationMessage?: string;\n\n ariaCloseWarning?: string;\n\n popup(props: TextAnnotationPopupContentProps): ReactNode;\n\n}\n\nexport interface TextAnnotationPopupContentProps {\n\n annotation: TextAnnotation;\n\n editable?: boolean;\n\n event?: PointerEvent;\n\n}\n\nexport const TextAnnotatorPopup: FC<TextAnnotationPopupProps> = (props) => {\n\n const { popup, ariaNavigationMessage } = props;\n\n const r = useAnnotator<TextAnnotator>();\n\n const { selected, event } = useSelection<TextAnnotation>();\n const annotation = selected[0]?.annotation;\n\n const isAnnotationIdling = useAnnotationTargetIdling(annotation?.id);\n\n const [isOpen, setOpen] = useState(selected?.length > 0);\n const handleClose = () => r?.cancelSelected();\n\n const [isFocused, setFocused] = useState(false);\n const handleFocus = useCallback(() => setFocused(true), []);\n const handleBlur = useCallback(() => setFocused(false), []);\n useEffect(() => {\n if (!isOpen) handleBlur();\n }, [isOpen, handleBlur]);\n\n const { refs, floatingStyles, update, context } = useFloating({\n placement: isMobile() ? 'bottom' : 'top',\n open: isOpen,\n onOpenChange: (open, _event, reason) => {\n if (!open && (reason === 'escape-key' || reason === 'focus-out')) {\n setOpen(open);\n handleClose();\n }\n },\n middleware: [\n offset(10),\n inline(),\n flip(),\n shift({ mainAxis: false, crossAxis: true, padding: 10 })\n ],\n whileElementsMounted: autoUpdate\n });\n\n const dismiss = useDismiss(context);\n\n const role = useRole(context, { role: 'dialog' });\n\n const { getFloatingProps } = useInteractions([dismiss, role]);\n\n useEffect(() => {\n const annotationSelector = annotation?.target.selector;\n setOpen(isAnnotationIdling && annotationSelector?.length > 0 ? isRevived(annotationSelector) : false);\n }, [annotation?.target?.selector, isAnnotationIdling]);\n\n useEffect(() => {\n if (!r) return;\n\n if (isOpen && annotation?.id) {\n refs.setPositionReference({\n getBoundingClientRect: () => {\n const bounds = r.state.store.getAnnotationBounds(annotation.id);\n return bounds\n ? denormalizeRectWithOffset(bounds, r.element.getBoundingClientRect())\n : new DOMRect();\n },\n getClientRects: () => {\n const rects = r.state.store.getAnnotationRects(annotation.id);\n const denormalizedRects = rects.map((rect) =>\n denormalizeRectWithOffset(rect, r.element.getBoundingClientRect())\n );\n return toDomRectList(denormalizedRects);\n }\n });\n } else {\n refs.setPositionReference(null);\n }\n }, [isOpen, annotation?.id, annotation?.target, r]);\n\n useEffect(() => {\n const config: MutationObserverInit = { attributes: true, childList: true, subtree: true };\n\n const mutationObserver = new MutationObserver(() => update());\n mutationObserver.observe(document.body, config);\n\n window.document.addEventListener('scroll', update, true);\n\n return () => {\n mutationObserver.disconnect();\n window.document.removeEventListener('scroll', update, true);\n };\n }, [update]);\n\n // Don't shift focus to the floating element if selected via keyboard or on mobile.\n const initialFocus = useMemo(() => {\n return (event?.type === 'keyup' || event?.type === 'contextmenu' || isMobile()) ? -1 : 0;\n }, [event]);\n\n /**\n * Announce the navigation hint only on the keyboard selection,\n * because the focus isn't shifted to the popup automatically then\n */\n useAnnouncePopupNavigation({\n disabled: isFocused,\n floatingOpen: isOpen,\n message: ariaNavigationMessage,\n });\n\n return isOpen && annotation ? (\n <FloatingPortal>\n <FloatingFocusManager\n context={context}\n modal={false}\n closeOnFocusOut={true}\n returnFocus={false}\n initialFocus={initialFocus}>\n <div\n className={`a9s-popup r6o-popup annotation-popup r6o-text-popup ${NOT_ANNOTATABLE_CLASS}`}\n ref={refs.setFloating}\n style={floatingStyles}\n {...getFloatingProps({\n onFocus: handleFocus,\n onBlur: handleBlur,\n ...getStopEventsPropagationProps()\n })}>\n {popup({\n annotation: selected[0].annotation,\n editable: selected[0].editable,\n event\n })}\n <button className=\"r6o-popup-sr-only\" aria-live=\"assertive\" onClick={handleClose}>\n {props.ariaCloseWarning || 'Click or leave this dialog to close it.'}\n </button>\n </div>\n </FloatingFocusManager>\n </FloatingPortal>\n ) : null;\n\n};\n\n/**\n * Prevent text-annotator from handling the irrelevant events\n * triggered from the popup/toolbar/dialog\n */\nconst getStopEventsPropagationProps = <T extends HTMLElement = HTMLElement>() => ({\n onPointerUp: (event: PointerEvent<T>) => event.stopPropagation(),\n onPointerDown: (event: PointerEvent<T>) => event.stopPropagation(),\n onMouseDown: (event: MouseEvent<T>) => event.stopPropagation(),\n onMouseUp: (event: MouseEvent<T>) => event.stopPropagation()\n});\n"],"names":["jsx","jsxs"],"mappings":";;;;;;;;;;;AAmDa,MAAA,qBAAmD,CAAC,UAAU;;AAEnE,QAAA,EAAE,OAAO,sBAA0B,IAAA;AAEzC,QAAM,IAAI;AAEV,QAAM,EAAE,UAAU,MAAM,IAAI,aAA6B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;AAAA,MACC;AAAA,MACA,OAAO;AAAA,MACP,iBAAiB;AAAA,MACjB,aAAa;AAAA,MACb;AAAA,MACA,UAAAC,kCAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW,uDAAuD,qBAAqB;AAAA,UACvF,KAAK,KAAK;AAAA,UACV,OAAO;AAAA,UACN,GAAG,iBAAiB;AAAA,YACnB,SAAS;AAAA,YACT,QAAQ;AAAA,YACR,GAAG,8BAA8B;AAAA,UAAA,CAClC;AAAA,UACA,UAAA;AAAA,YAAM,MAAA;AAAA,cACL,YAAY,SAAS,CAAC,EAAE;AAAA,cACxB,UAAU,SAAS,CAAC,EAAE;AAAA,cACtB;AAAA,YAAA,CACD;AAAA,YACDD,kCAAAA,IAAC,UAAO,EAAA,WAAU,qBAAoB,aAAU,aAAY,SAAS,aAClE,UAAM,MAAA,oBAAoB,0CAC7B,CAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA,EAEJ,CAAA,IACE;AAEN;AAMA,MAAM,gCAAgC,OAA4C;AAAA,EAChF,aAAa,CAAC,UAA2B,MAAM,gBAAgB;AAAA,EAC/D,eAAe,CAAC,UAA2B,MAAM,gBAAgB;AAAA,EACjE,aAAa,CAAC,UAAyB,MAAM,gBAAgB;AAAA,EAC7D,WAAW,CAAC,UAAyB,MAAM,gBAAgB;AAC7D;"}
|
|
1
|
+
{"version":3,"file":"react-text-annotator.es7.js","sources":["../src/TextAnnotationPopup/TextAnnotationPopup.tsx"],"sourcesContent":["import React, { FC, ReactNode, useCallback, useRef, useEffect, useMemo, useState } from 'react';\nimport { useAnnotator, useSelection } from '@annotorious/react';\nimport {\n isRevived,\n NOT_ANNOTATABLE_CLASS,\n denormalizeRectWithOffset,\n toDomRectList,\n type TextAnnotation,\n type TextAnnotator\n} from '@soomo/text-annotator';\nimport {\n arrow,\n autoUpdate,\n flip,\n FloatingArrow,\n FloatingArrowProps,\n FloatingFocusManager,\n FloatingPortal,\n inline,\n offset,\n shift,\n useDismiss,\n useFloating,\n useInteractions,\n useRole\n} from '@floating-ui/react';\n\nimport { isMobile } from './isMobile';\nimport { useAnnouncePopupNavigation, useAnnotationTargetIdling } from '../hooks';\n\nimport './TextAnnotationPopup.css';\n\ninterface TextAnnotationPopupProps {\n\n ariaNavigationMessage?: string;\n\n ariaCloseWarning?: string;\n\n arrow?: boolean;\n\n arrowProps?: Omit<FloatingArrowProps, 'context' | 'ref'>;\n\n popup(props: TextAnnotationPopupContentProps): ReactNode;\n\n}\n\nexport interface TextAnnotationPopupContentProps {\n\n annotation: TextAnnotation;\n\n editable?: boolean;\n\n event?: PointerEvent | KeyboardEvent;\n\n}\n\nexport const TextAnnotationPopup: FC<TextAnnotationPopupProps> = (props) => {\n\n const { popup, ariaNavigationMessage } = props;\n\n const r = useAnnotator<TextAnnotator>();\n\n const { selected, event } = useSelection<TextAnnotation>();\n const annotation = selected[0]?.annotation;\n\n const isAnnotationIdling = useAnnotationTargetIdling(annotation?.id);\n\n const [isOpen, setOpen] = useState(selected?.length > 0);\n const handleClose = () => r?.cancelSelected();\n\n const [isFocused, setFocused] = useState(false);\n const handleFocus = useCallback(() => setFocused(true), []);\n const handleBlur = useCallback(() => setFocused(false), []);\n useEffect(() => {\n if (!isOpen) handleBlur();\n }, [isOpen, handleBlur]);\n\n const arrowRef = useRef(null);\n\n const { refs, floatingStyles, update, context } = useFloating({\n placement: isMobile() ? 'bottom' : 'top',\n open: isOpen,\n onOpenChange: (open, _event, reason) => {\n if (!open && (reason === 'escape-key' || reason === 'focus-out')) {\n setOpen(open);\n handleClose();\n }\n },\n middleware: [\n inline(),\n offset(10),\n flip({ crossAxis: true }),\n shift({ crossAxis: true, padding: 10 }),\n arrow({ element: arrowRef })\n ],\n whileElementsMounted: autoUpdate\n });\n\n const dismiss = useDismiss(context);\n\n const role = useRole(context, { role: 'dialog' });\n\n const { getFloatingProps } = useInteractions([dismiss, role]);\n\n useEffect(() => {\n const annotationSelector = annotation?.target.selector;\n setOpen(isAnnotationIdling && annotationSelector?.length > 0 ? isRevived(annotationSelector) : false);\n }, [annotation?.target?.selector, isAnnotationIdling]);\n\n useEffect(() => {\n if (!r) return;\n\n if (isOpen && annotation?.id) {\n refs.setPositionReference({\n getBoundingClientRect: () => {\n const bounds = r.state.store.getAnnotationBounds(annotation.id);\n return bounds\n ? denormalizeRectWithOffset(bounds, r.element.getBoundingClientRect())\n : new DOMRect();\n },\n getClientRects: () => {\n const rects = r.state.store.getAnnotationRects(annotation.id);\n const denormalizedRects = rects.map((rect) =>\n denormalizeRectWithOffset(rect, r.element.getBoundingClientRect())\n );\n return toDomRectList(denormalizedRects);\n }\n });\n } else {\n refs.setPositionReference(null);\n }\n }, [isOpen, annotation?.id, annotation?.target, r]);\n\n useEffect(() => {\n const config: MutationObserverInit = { attributes: true, childList: true, subtree: true };\n\n const mutationObserver = new MutationObserver(() => update());\n mutationObserver.observe(document.body, config);\n\n window.document.addEventListener('scroll', update, true);\n\n return () => {\n mutationObserver.disconnect();\n window.document.removeEventListener('scroll', update, true);\n };\n }, [update]);\n\n // Don't shift focus to the floating element if selected via keyboard or on mobile.\n const initialFocus = useMemo(() => {\n return (event?.type === 'keyup' || event?.type === 'contextmenu' || isMobile()) ? -1 : 0;\n }, [event]);\n\n /**\n * Announce the navigation hint only on the keyboard selection,\n * because the focus isn't shifted to the popup automatically then\n */\n useAnnouncePopupNavigation({\n disabled: isFocused,\n floatingOpen: isOpen,\n message: ariaNavigationMessage,\n });\n\n return isOpen && annotation ? (\n <FloatingPortal>\n <FloatingFocusManager\n context={context}\n modal={false}\n closeOnFocusOut={true}\n returnFocus={false}\n initialFocus={initialFocus}>\n <div\n className={`a9s-popup r6o-popup annotation-popup r6o-text-popup ${NOT_ANNOTATABLE_CLASS}`}\n ref={refs.setFloating}\n style={floatingStyles}\n {...getFloatingProps({\n onFocus: handleFocus,\n onBlur: handleBlur,\n ...getStopEventsPropagationProps()\n })}>\n {popup({\n annotation: selected[0].annotation,\n editable: selected[0].editable,\n event\n })}\n{props.arrow && (\n <FloatingArrow\n ref={arrowRef}\n context={context}\n {...(props.arrowProps || {})} />\n )}\n\n <button className=\"r6o-popup-sr-only\" aria-live=\"assertive\" onClick={handleClose}>\n {props.ariaCloseWarning || 'Click or leave this dialog to close it.'}\n </button>\n </div>\n </FloatingFocusManager>\n </FloatingPortal>\n ) : null;\n\n};\n\n/**\n * Prevent text-annotator from handling the irrelevant events\n * triggered from the popup/toolbar/dialog\n */\nconst getStopEventsPropagationProps = <T extends HTMLElement = HTMLElement>() => ({\n onPointerUp: (event: React.PointerEvent<T>) => event.stopPropagation(),\n onPointerDown: (event: React.PointerEvent<T>) => event.stopPropagation(),\n onMouseDown: (event: React.MouseEvent<T>) => event.stopPropagation(),\n onMouseUp: (event: React.MouseEvent<T>) => event.stopPropagation()\n});\n\n/** For backwards compatibility **/\n/** @deprecated Use TextAnnotationPopup instead */\nexport const TextAnnotatorPopup = (props: TextAnnotationPopupProps) => {\n\n useEffect(() => {\n console.warn('TextAnnotatorPopup is deprecated and will be removed in a future version. Please use TextAnnotationPopup instead.');\n }, []);\n\n return <TextAnnotationPopup {...props} />;\n};\n"],"names":["jsx","jsxs"],"mappings":";;;;;;;;;;;AAwDa,MAAA,sBAAoD,CAAC,UAAU;;AAEpE,QAAA,EAAE,OAAO,sBAAA,IAA0B;AAEzC,QAAM,IAAI,aAA4B;AAEtC,QAAM,EAAE,UAAU,MAAM,IAAI,aAA6B;AACnD,QAAA,cAAa,cAAS,CAAC,MAAV,mBAAa;AAE1B,QAAA,qBAAqB,0BAA0B,yCAAY,EAAE;AAEnE,QAAM,CAAC,QAAQ,OAAO,IAAI,UAAS,qCAAU,UAAS,CAAC;AACjD,QAAA,cAAc,MAAM,uBAAG;AAE7B,QAAM,CAAC,WAAW,UAAU,IAAI,SAAS,KAAK;AAC9C,QAAM,cAAc,YAAY,MAAM,WAAW,IAAI,GAAG,CAAA,CAAE;AAC1D,QAAM,aAAa,YAAY,MAAM,WAAW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