@plait/core 0.1.9 → 0.2.0-next.11
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/board/board.component.d.ts +4 -3
- package/core/children/children.component.d.ts +17 -0
- package/core/children/effect.d.ts +2 -0
- package/core/element/context-change.d.ts +10 -0
- package/core/element/context.d.ts +6 -4
- package/core/element/element.component.d.ts +10 -13
- package/core/element/plugin-element.d.ts +13 -12
- package/esm2020/board/board.component.mjs +15 -23
- package/esm2020/core/children/children.component.mjs +58 -0
- package/esm2020/core/children/effect.mjs +2 -0
- package/esm2020/core/element/context-change.mjs +13 -0
- package/esm2020/core/element/context.mjs +1 -1
- package/esm2020/core/element/element.component.mjs +47 -37
- package/esm2020/core/element/plugin-element.mjs +37 -28
- package/esm2020/interfaces/board.mjs +33 -2
- package/esm2020/interfaces/element.mjs +15 -4
- package/esm2020/interfaces/node.mjs +23 -3
- package/esm2020/interfaces/operation.mjs +1 -1
- package/esm2020/interfaces/path.mjs +43 -1
- package/esm2020/interfaces/rectangle-client.mjs +18 -3
- package/esm2020/plait.module.mjs +4 -3
- package/esm2020/plugins/create-board.mjs +2 -1
- package/esm2020/plugins/with-moving.mjs +5 -5
- package/esm2020/plugins/with-selection.mjs +11 -6
- package/esm2020/public-api.mjs +3 -3
- package/esm2020/utils/dom/common.mjs +22 -0
- package/esm2020/utils/dom/foreign.mjs +19 -0
- package/esm2020/utils/draw/circle.mjs +4 -0
- package/esm2020/utils/draw/line.mjs +4 -0
- package/esm2020/utils/draw/rectangle.mjs +43 -1
- package/esm2020/utils/element.mjs +2 -2
- package/esm2020/utils/index.mjs +5 -2
- package/esm2020/utils/selected-element.mjs +14 -4
- package/esm2020/utils/tree.mjs +7 -5
- package/esm2020/utils/viewport.mjs +2 -2
- package/esm2020/utils/weak-maps.mjs +4 -1
- package/fesm2015/plait-core.mjs +459 -190
- package/fesm2015/plait-core.mjs.map +1 -1
- package/fesm2020/plait-core.mjs +458 -188
- package/fesm2020/plait-core.mjs.map +1 -1
- package/interfaces/board.d.ts +5 -0
- package/interfaces/element.d.ts +7 -3
- package/interfaces/node.d.ts +17 -9
- package/interfaces/operation.d.ts +1 -1
- package/interfaces/path.d.ts +19 -0
- package/interfaces/rectangle-client.d.ts +8 -1
- package/package.json +1 -1
- package/plait.module.d.ts +5 -4
- package/public-api.d.ts +2 -2
- package/styles/styles.scss +5 -1
- package/utils/{dom.d.ts → dom/common.d.ts} +1 -1
- package/utils/dom/foreign.d.ts +2 -0
- package/utils/draw/circle.d.ts +4 -0
- package/utils/draw/line.d.ts +4 -0
- package/utils/draw/rectangle.d.ts +1 -0
- package/utils/index.d.ts +4 -1
- package/utils/selected-element.d.ts +3 -2
- package/utils/tree.d.ts +1 -1
- package/utils/weak-maps.d.ts +4 -0
- package/core/base/detector.d.ts +0 -7
- package/core/element/before-context-change.d.ts +0 -6
- package/esm2020/core/base/detector.mjs +0 -2
- package/esm2020/core/element/before-context-change.mjs +0 -7
- package/esm2020/utils/dom.mjs +0 -22
package/interfaces/board.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ import { RoughSVG } from 'roughjs/bin/svg';
|
|
|
10
10
|
import { BoardComponentInterface } from '../board/board.component.interface';
|
|
11
11
|
import { Point } from './point';
|
|
12
12
|
import { RectangleClient } from './rectangle-client';
|
|
13
|
+
import { Path } from './path';
|
|
14
|
+
import { PlaitNode } from './node';
|
|
13
15
|
export interface PlaitBoard {
|
|
14
16
|
viewport: Viewport;
|
|
15
17
|
children: PlaitElement[];
|
|
@@ -37,6 +39,7 @@ export interface PlaitBoard {
|
|
|
37
39
|
redrawElement: (context: PlaitPluginElementContext, previousContext?: PlaitPluginElementContext) => SVGGElement[] | void;
|
|
38
40
|
destroyElement: (context: PlaitPluginElementContext) => void;
|
|
39
41
|
isHitSelection: (element: PlaitElement, range: Range) => boolean;
|
|
42
|
+
isRecursion: (element: PlaitElement) => boolean;
|
|
40
43
|
isMovable: (element: PlaitElement) => boolean;
|
|
41
44
|
getRectangle: (element: PlaitElement) => RectangleClient | null;
|
|
42
45
|
isWithinSelection: (element: PlaitElement) => boolean;
|
|
@@ -56,6 +59,8 @@ export interface PlaitBoardMove {
|
|
|
56
59
|
y: number;
|
|
57
60
|
}
|
|
58
61
|
export declare const PlaitBoard: {
|
|
62
|
+
isBoard(value: any): value is PlaitBoard;
|
|
63
|
+
findPath(board: PlaitBoard, node: PlaitNode): Path;
|
|
59
64
|
getHost(board: PlaitBoard): SVGSVGElement;
|
|
60
65
|
getElementHost(board: PlaitBoard): SVGGElement;
|
|
61
66
|
getRoughSVG(board: PlaitBoard): RoughSVG;
|
package/interfaces/element.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlaitPluginElementComponent } from '../core/element/plugin-element';
|
|
2
|
+
import { PlaitBoard } from './board';
|
|
2
3
|
import { Point } from './point';
|
|
3
|
-
export interface PlaitElement
|
|
4
|
+
export interface PlaitElement {
|
|
5
|
+
[key: string]: any;
|
|
4
6
|
id: string;
|
|
7
|
+
children?: PlaitElement[];
|
|
5
8
|
points?: Point[];
|
|
6
9
|
type?: string;
|
|
7
10
|
}
|
|
8
11
|
export declare const PlaitElement: {
|
|
9
|
-
|
|
12
|
+
isRootElement(value: PlaitElement): boolean;
|
|
13
|
+
getComponent(value: PlaitElement): PlaitPluginElementComponent<PlaitElement, PlaitBoard>;
|
|
10
14
|
};
|
|
11
15
|
export interface ComponentType<T> {
|
|
12
16
|
new (...args: any[]): T;
|
package/interfaces/node.d.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
import { PlaitElement } from './element';
|
|
1
2
|
import { PlaitBoard } from './board';
|
|
2
3
|
import { Path } from './path';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export type PlaitNode = PlaitElement;
|
|
5
|
+
export type Ancestor = PlaitBoard | PlaitElement;
|
|
6
|
+
export interface NodeParentsOptions {
|
|
7
|
+
reverse?: boolean;
|
|
6
8
|
}
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export declare const PlaitNode: {
|
|
10
|
+
parent: (board: PlaitBoard, path: Path) => PlaitElement;
|
|
11
|
+
/**
|
|
12
|
+
* Return a generator of all the ancestor nodes above a specific path.
|
|
13
|
+
*
|
|
14
|
+
* By default the order is top-down, from highest to lowest ancestor in
|
|
15
|
+
* the tree, but you can pass the `reverse: true` option to go bottom-up.
|
|
16
|
+
*/
|
|
17
|
+
parents(root: PlaitBoard, path: Path, options?: NodeParentsOptions): Generator<PlaitNode, void, undefined>;
|
|
18
|
+
get(root: PlaitBoard, path: Path): PlaitNode;
|
|
19
|
+
last(board: PlaitBoard, path: Path): PlaitElement;
|
|
20
|
+
};
|
package/interfaces/path.d.ts
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
import { PlaitOperation } from './operation';
|
|
2
|
+
export interface PathLevelsOptions {
|
|
3
|
+
reverse?: boolean;
|
|
4
|
+
}
|
|
2
5
|
export type Path = number[];
|
|
3
6
|
export declare const Path: {
|
|
7
|
+
/**
|
|
8
|
+
* Get a list of ancestor paths for a given path.
|
|
9
|
+
*
|
|
10
|
+
* The paths are sorted from shallowest to deepest ancestor. However, if the
|
|
11
|
+
* `reverse: true` option is passed, they are reversed.
|
|
12
|
+
*/
|
|
13
|
+
ancestors(path: Path, options?: PathLevelsOptions): Path[];
|
|
14
|
+
/**
|
|
15
|
+
* Get a list of paths at every level down to a path. Note: this is the same
|
|
16
|
+
* as `Path.ancestors`, but including the path itself.
|
|
17
|
+
*
|
|
18
|
+
* The paths are sorted from shallowest to deepest. However, if the `reverse:
|
|
19
|
+
* true` option is passed, they are reversed.
|
|
20
|
+
*/
|
|
21
|
+
levels(path: Path, options?: PathLevelsOptions): Path[];
|
|
4
22
|
parent(path: Path): Path;
|
|
5
23
|
next(path: Path): Path;
|
|
24
|
+
previous(path: Path): Path;
|
|
6
25
|
/**
|
|
7
26
|
* Check if a path is an ancestor of another.
|
|
8
27
|
*/
|
|
@@ -6,11 +6,18 @@ export interface RectangleClient {
|
|
|
6
6
|
height: number;
|
|
7
7
|
}
|
|
8
8
|
export declare const RectangleClient: {
|
|
9
|
-
|
|
9
|
+
isHit: (origin: RectangleClient, target: RectangleClient) => boolean;
|
|
10
10
|
toRectangleClient: (points: [Point, Point]) => {
|
|
11
11
|
x: number;
|
|
12
12
|
y: number;
|
|
13
13
|
width: number;
|
|
14
14
|
height: number;
|
|
15
15
|
};
|
|
16
|
+
getOutlineRectangle: (rectangle: RectangleClient, offset: number) => {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
22
|
+
isEqual: (rectangle: RectangleClient, otherRectangle: RectangleClient) => boolean;
|
|
16
23
|
};
|
package/package.json
CHANGED
package/plait.module.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
2
|
import * as i1 from "./board/board.component";
|
|
3
|
-
import * as i2 from "./core/
|
|
4
|
-
import * as i3 from "./core/
|
|
5
|
-
import * as i4 from "
|
|
3
|
+
import * as i2 from "./core/children/children.component";
|
|
4
|
+
import * as i3 from "./core/element/element.component";
|
|
5
|
+
import * as i4 from "./core/toolbar/toolbar.component";
|
|
6
|
+
import * as i5 from "@angular/platform-browser";
|
|
6
7
|
export declare class PlaitModule {
|
|
7
8
|
static ɵfac: i0.ɵɵFactoryDeclaration<PlaitModule, never>;
|
|
8
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<PlaitModule, [typeof i1.PlaitBoardComponent, typeof i2.
|
|
9
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<PlaitModule, [typeof i1.PlaitBoardComponent, typeof i2.PlaitChildrenElement, typeof i3.PlaitElementComponent, typeof i4.PlaitToolbarComponent], [typeof i5.BrowserModule], [typeof i1.PlaitBoardComponent, typeof i2.PlaitChildrenElement, typeof i3.PlaitElementComponent, typeof i4.PlaitToolbarComponent]>;
|
|
9
10
|
static ɵinj: i0.ɵɵInjectorDeclaration<PlaitModule>;
|
|
10
11
|
}
|
package/public-api.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export * from './board/board.component';
|
|
2
2
|
export * from './constants';
|
|
3
|
-
export * from './core/base/detector';
|
|
4
3
|
export * from './core/element/plugin-element';
|
|
5
4
|
export * from './core/element/element.component';
|
|
6
|
-
export * from './core/
|
|
5
|
+
export * from './core/children/children.component';
|
|
6
|
+
export * from './core/element/context-change';
|
|
7
7
|
export * from './core/toolbar/toolbar.component';
|
|
8
8
|
export * from './interfaces';
|
|
9
9
|
export * from './plait.module';
|
package/styles/styles.scss
CHANGED
|
@@ -20,9 +20,13 @@
|
|
|
20
20
|
// https://stackoverflow.com/questions/51313873/svg-foreignobject-not-working-properly-on-safari
|
|
21
21
|
.plait-richtext-container {
|
|
22
22
|
// chrome show position is not correct, safari not working when don't assigned position property
|
|
23
|
-
// can not assign absolute, because safari can not show correctly position
|
|
23
|
+
// can not assign absolute, because safari can not show correctly position
|
|
24
24
|
position: initial;
|
|
25
25
|
&[readonly='true'] {
|
|
26
|
+
::-moz-selection {
|
|
27
|
+
/* Code for Firefox */
|
|
28
|
+
background: none;
|
|
29
|
+
}
|
|
26
30
|
::selection {
|
|
27
31
|
background: none;
|
|
28
32
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Point } from '
|
|
1
|
+
import { Point } from '../../interfaces/point';
|
|
2
2
|
export declare const NS = "http://www.w3.org/2000/svg";
|
|
3
3
|
export declare function toPoint(x: number, y: number, container: SVGElement): Point;
|
|
4
4
|
export declare function createG(): SVGGElement;
|
|
@@ -4,3 +4,4 @@ import { RoughSVG } from 'roughjs/bin/svg';
|
|
|
4
4
|
* drawRoundRectangle
|
|
5
5
|
*/
|
|
6
6
|
export declare function drawRoundRectangle(rs: RoughSVG, x1: number, y1: number, x2: number, y2: number, options: Options, outline?: boolean, borderRadius?: number): SVGGElement;
|
|
7
|
+
export declare function drawAbstractRoundRectangle(rs: RoughSVG, x1: number, y1: number, x2: number, y2: number, isHorizontal: boolean, options: Options): SVGGElement;
|
package/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './board';
|
|
2
|
-
export * from './dom';
|
|
2
|
+
export * from './dom/common';
|
|
3
|
+
export * from './dom/foreign';
|
|
3
4
|
export * from './environment';
|
|
4
5
|
export * from './helper';
|
|
5
6
|
export * from './history';
|
|
@@ -10,6 +11,8 @@ export * from './weak-maps';
|
|
|
10
11
|
export * from './selected-element';
|
|
11
12
|
export * from './draw/rectangle';
|
|
12
13
|
export * from './draw/arrow';
|
|
14
|
+
export * from './draw/circle';
|
|
15
|
+
export * from './draw/line';
|
|
13
16
|
export * from './tree';
|
|
14
17
|
export * from './element';
|
|
15
18
|
export * from './viewport';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { PlaitBoard } from '../interfaces/board';
|
|
2
|
-
import { PlaitElement } from '../interfaces/element';
|
|
3
2
|
import { Range } from '../interfaces/selection';
|
|
4
|
-
|
|
3
|
+
import { PlaitElement } from '../interfaces/element';
|
|
4
|
+
export declare const getHitElements: (board: PlaitBoard) => PlaitElement[];
|
|
5
5
|
export declare const isIntersectionElements: (board: PlaitBoard, elements: PlaitElement[], ranges: Range[]) => boolean;
|
|
6
6
|
export declare const cacheSelectedElements: (board: PlaitBoard, selectedElements: PlaitElement[]) => void;
|
|
7
7
|
export declare const getSelectedElements: (board: PlaitBoard) => PlaitElement[];
|
|
8
8
|
export declare const addSelectedElement: (board: PlaitBoard, element: PlaitElement) => void;
|
|
9
9
|
export declare const removeSelectedElement: (board: PlaitBoard, element: PlaitElement) => void;
|
|
10
|
+
export declare const clearSelectedElement: (board: PlaitBoard) => void;
|
|
10
11
|
export declare const isSelectedElement: (board: PlaitBoard, element: PlaitElement) => boolean;
|
package/utils/tree.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function depthFirstRecursion<T extends TreeNode = TreeNode>(node: T, callback: (node: T) => void): void;
|
|
1
|
+
export declare function depthFirstRecursion<T extends TreeNode = TreeNode>(node: T, callback: (node: T) => void, recursion?: (node: T) => boolean): void;
|
|
2
2
|
export interface TreeNode {
|
|
3
3
|
children?: TreeNode[];
|
|
4
4
|
}
|
package/utils/weak-maps.d.ts
CHANGED
|
@@ -3,7 +3,11 @@ import { BoardComponentInterface } from '../board/board.component.interface';
|
|
|
3
3
|
import { PlaitElement } from '../interfaces/element';
|
|
4
4
|
import { PlaitBoard } from '../interfaces/board';
|
|
5
5
|
import { Point } from '../interfaces/point';
|
|
6
|
+
import { Ancestor } from '../interfaces/node';
|
|
7
|
+
export declare const IS_BOARD_CACHE: WeakMap<Object, boolean>;
|
|
6
8
|
export declare const FLUSHING: WeakMap<PlaitBoard, boolean>;
|
|
9
|
+
export declare const NODE_TO_INDEX: WeakMap<PlaitElement, number>;
|
|
10
|
+
export declare const NODE_TO_PARENT: WeakMap<PlaitElement, Ancestor>;
|
|
7
11
|
export declare const IS_TEXT_EDITABLE: WeakMap<PlaitBoard, boolean>;
|
|
8
12
|
export declare const BOARD_TO_ON_CHANGE: WeakMap<PlaitBoard, () => void>;
|
|
9
13
|
export declare const BOARD_TO_COMPONENT: WeakMap<PlaitBoard, BoardComponentInterface>;
|
package/core/base/detector.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Point } from '../../interfaces/point';
|
|
2
|
-
import { PlaitElement } from '../../interfaces/element';
|
|
3
|
-
import { Selection } from '../../interfaces/selection';
|
|
4
|
-
export interface BaseDetector {
|
|
5
|
-
contian: (selection: Selection, element: PlaitElement) => boolean;
|
|
6
|
-
hit: (point: Point, element: PlaitElement) => boolean;
|
|
7
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { PlaitElement } from "../../interfaces";
|
|
2
|
-
import { PlaitPluginElementContext } from "./context";
|
|
3
|
-
export interface BeforeContextChange<T extends PlaitElement = PlaitElement> {
|
|
4
|
-
beforeContextChange: (value: PlaitPluginElementContext<T>) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare function hasBeforeContextChange<T extends PlaitElement = PlaitElement>(value: any): value is BeforeContextChange<T>;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGV0ZWN0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9wbGFpdC9zcmMvY29yZS9iYXNlL2RldGVjdG9yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBQb2ludCB9IGZyb20gJy4uLy4uL2ludGVyZmFjZXMvcG9pbnQnO1xuaW1wb3J0IHsgUGxhaXRFbGVtZW50IH0gZnJvbSAnLi4vLi4vaW50ZXJmYWNlcy9lbGVtZW50JztcbmltcG9ydCB7IFNlbGVjdGlvbiB9IGZyb20gJy4uLy4uL2ludGVyZmFjZXMvc2VsZWN0aW9uJztcblxuZXhwb3J0IGludGVyZmFjZSBCYXNlRGV0ZWN0b3Ige1xuICAgIGNvbnRpYW46IChzZWxlY3Rpb246IFNlbGVjdGlvbiwgZWxlbWVudDogUGxhaXRFbGVtZW50KSA9PiBib29sZWFuOyAvLyDmoYbpgIlcbiAgICBoaXQ6IChwb2ludDogUG9pbnQsIGVsZW1lbnQ6IFBsYWl0RWxlbWVudCkgPT4gYm9vbGVhbjtcbn1cbiJdfQ==
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export function hasBeforeContextChange(value) {
|
|
2
|
-
if (value.beforeContextChange) {
|
|
3
|
-
return true;
|
|
4
|
-
}
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7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ybiBmYWxzZTtcbn1cbiJdfQ==
|
package/esm2020/utils/dom.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export const NS = 'http://www.w3.org/2000/svg';
|
|
2
|
-
export function toPoint(x, y, container) {
|
|
3
|
-
const rect = container.getBoundingClientRect();
|
|
4
|
-
return [x - rect.x, y - rect.y];
|
|
5
|
-
}
|
|
6
|
-
export function createG() {
|
|
7
|
-
const newG = document.createElementNS(NS, 'g');
|
|
8
|
-
return newG;
|
|
9
|
-
}
|
|
10
|
-
export function createSVG() {
|
|
11
|
-
const svg = document.createElementNS(NS, 'svg');
|
|
12
|
-
return svg;
|
|
13
|
-
}
|
|
14
|
-
export function createText(x, y, fill, textContent) {
|
|
15
|
-
var text = document.createElementNS(NS, 'text');
|
|
16
|
-
text.setAttribute('x', `${x}`);
|
|
17
|
-
text.setAttribute('y', `${y}`);
|
|
18
|
-
text.setAttribute('fill', fill);
|
|
19
|
-
text.textContent = textContent;
|
|
20
|
-
return text;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZG9tLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcGFja2FnZXMvcGxhaXQvc3JjL3V0aWxzL2RvbS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxNQUFNLENBQUMsTUFBTSxFQUFFLEdBQUcsNEJBQTRCLENBQUM7QUFFL0MsTUFBTSxVQUFVLE9BQU8sQ0FBQyxDQUFTLEVBQUUsQ0FBUyxFQUFFLFNBQXFCO0lBQy9ELE1BQU0sSUFBSSxHQUFHLFNBQVMsQ0FBQyxxQkFBcUIsRUFBRSxDQUFDO0lBQy9DLE9BQU8sQ0FBQyxDQUFDLEdBQUcsSUFBSSxDQUFDLENBQUMsRUFBRSxDQUFDLEdBQUcsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDO0FBQ3B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