modern-idoc 0.8.4 → 0.8.5
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/index.cjs +111 -43
- package/dist/index.d.cts +54 -26
- package/dist/index.d.mts +54 -26
- package/dist/index.d.ts +54 -26
- package/dist/index.js +2 -2
- package/dist/index.mjs +108 -43
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -138,6 +138,15 @@ function pick(obj, keys) {
|
|
|
138
138
|
return result;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
function isEqualObject(a, b) {
|
|
142
|
+
if (a === b)
|
|
143
|
+
return true;
|
|
144
|
+
if (a && b && typeof a === "object" && typeof b === "object") {
|
|
145
|
+
const keys = Array.from(/* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]));
|
|
146
|
+
return !keys.length || keys.every((key) => a[key] === b[key]);
|
|
147
|
+
}
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
141
150
|
function getNestedValue(obj, path, fallback) {
|
|
142
151
|
const last = path.length - 1;
|
|
143
152
|
if (last < 0)
|
|
@@ -952,14 +961,15 @@ function isPresetFill(fill) {
|
|
|
952
961
|
return typeof fill === "string" ? false : isPresetFillObject(fill);
|
|
953
962
|
}
|
|
954
963
|
function normalizeFill(fill) {
|
|
964
|
+
const enabled = fill && typeof fill === "object" ? fill.enabled : void 0;
|
|
955
965
|
if (isColorFill(fill)) {
|
|
956
|
-
return normalizeColorFill(fill);
|
|
966
|
+
return clearUndef({ enabled, ...normalizeColorFill(fill) });
|
|
957
967
|
} else if (isGradientFill(fill)) {
|
|
958
|
-
return normalizeGradientFill(fill);
|
|
968
|
+
return clearUndef({ enabled, ...normalizeGradientFill(fill) });
|
|
959
969
|
} else if (isImageFill(fill)) {
|
|
960
|
-
return normalizeImageFill(fill);
|
|
970
|
+
return clearUndef({ enabled, ...normalizeImageFill(fill) });
|
|
961
971
|
} else if (isPresetFill(fill)) {
|
|
962
|
-
return normalizePresetFill(fill);
|
|
972
|
+
return clearUndef({ enabled, ...normalizePresetFill(fill) });
|
|
963
973
|
}
|
|
964
974
|
return {};
|
|
965
975
|
}
|
|
@@ -1403,51 +1413,60 @@ function isCRLF(char) {
|
|
|
1403
1413
|
function normalizeCRLF(content) {
|
|
1404
1414
|
return content.replace(NORMALIZE_CRLF_RE, NORMALIZED_CRLF);
|
|
1405
1415
|
}
|
|
1406
|
-
function isEqualStyle(style1, style2) {
|
|
1407
|
-
const keys = Array.from(/* @__PURE__ */ new Set([...Object.keys(style1), ...Object.keys(style2)]));
|
|
1408
|
-
return !keys.length || keys.every((key) => style1[key] === style2[key]);
|
|
1409
|
-
}
|
|
1410
1416
|
function normalizeTextContent(value) {
|
|
1411
1417
|
const paragraphs = [];
|
|
1412
1418
|
function lastParagraph() {
|
|
1413
1419
|
return paragraphs[paragraphs.length - 1];
|
|
1414
1420
|
}
|
|
1415
|
-
function addParagraph(
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1421
|
+
function addParagraph(styleOption, fillOption, outlineOption) {
|
|
1422
|
+
const style = styleOption ? normalizeStyle(styleOption) : {};
|
|
1423
|
+
const fill = fillOption ? normalizeFill(fillOption) : void 0;
|
|
1424
|
+
const outline = outlineOption ? normalizeOutline(outlineOption) : void 0;
|
|
1425
|
+
const paragraph = clearUndef({
|
|
1426
|
+
...style,
|
|
1427
|
+
fill,
|
|
1428
|
+
outline,
|
|
1429
|
+
fragments: []
|
|
1430
|
+
});
|
|
1431
|
+
if (paragraphs[paragraphs.length - 1]?.fragments.length === 0) {
|
|
1419
1432
|
paragraphs[paragraphs.length - 1] = paragraph;
|
|
1420
1433
|
} else {
|
|
1421
|
-
paragraph = { ...style, fragments: [] };
|
|
1422
1434
|
paragraphs.push(paragraph);
|
|
1423
1435
|
}
|
|
1424
1436
|
return paragraph;
|
|
1425
1437
|
}
|
|
1426
|
-
function addFragment(content = "",
|
|
1438
|
+
function addFragment(content = "", styleOption, fillOption, outlineOption) {
|
|
1439
|
+
const style = styleOption ? normalizeStyle(styleOption) : {};
|
|
1440
|
+
const fill = fillOption ? normalizeFill(fillOption) : void 0;
|
|
1441
|
+
const outline = outlineOption ? normalizeOutline(outlineOption) : void 0;
|
|
1427
1442
|
Array.from(content).forEach((c) => {
|
|
1428
1443
|
if (isCRLF(c)) {
|
|
1429
|
-
const { fragments, ...pStyle } = lastParagraph() || addParagraph();
|
|
1444
|
+
const { fragments, fill: pFill, outline: pOutline, ...pStyle } = lastParagraph() || addParagraph();
|
|
1430
1445
|
if (!fragments.length) {
|
|
1431
|
-
fragments.push({
|
|
1446
|
+
fragments.push(clearUndef({
|
|
1432
1447
|
...style,
|
|
1448
|
+
fill,
|
|
1449
|
+
outline,
|
|
1433
1450
|
content: NORMALIZED_CRLF
|
|
1434
|
-
});
|
|
1451
|
+
}));
|
|
1435
1452
|
}
|
|
1436
|
-
addParagraph(pStyle);
|
|
1453
|
+
addParagraph(pStyle, pFill, pOutline);
|
|
1437
1454
|
} else {
|
|
1438
1455
|
const paragraph = lastParagraph() || addParagraph();
|
|
1439
1456
|
const fragment = paragraph.fragments[paragraph.fragments.length - 1];
|
|
1440
1457
|
if (fragment) {
|
|
1441
|
-
const { content: content2, ...fStyle } = fragment;
|
|
1442
|
-
if (
|
|
1458
|
+
const { content: content2, fill: fFill, outline: fOutline, ...fStyle } = fragment;
|
|
1459
|
+
if (isEqualObject(fill, fFill) && isEqualObject(outline, fOutline) && isEqualObject(style, fStyle)) {
|
|
1443
1460
|
fragment.content = `${content2}${c}`;
|
|
1444
1461
|
return;
|
|
1445
1462
|
}
|
|
1446
1463
|
}
|
|
1447
|
-
paragraph.fragments.push({
|
|
1464
|
+
paragraph.fragments.push(clearUndef({
|
|
1448
1465
|
...style,
|
|
1466
|
+
fill,
|
|
1467
|
+
outline,
|
|
1449
1468
|
content: c
|
|
1450
|
-
});
|
|
1469
|
+
}));
|
|
1451
1470
|
}
|
|
1452
1471
|
});
|
|
1453
1472
|
}
|
|
@@ -1456,25 +1475,25 @@ function normalizeTextContent(value) {
|
|
|
1456
1475
|
if (typeof p === "string") {
|
|
1457
1476
|
addParagraph();
|
|
1458
1477
|
addFragment(p);
|
|
1459
|
-
} else if (
|
|
1460
|
-
const { content, ...
|
|
1461
|
-
addParagraph(
|
|
1478
|
+
} else if (isFragmentObject(p)) {
|
|
1479
|
+
const { content, fill: fFill, outline: fOutline, ...fStyle } = p;
|
|
1480
|
+
addParagraph(fStyle, fFill, fOutline);
|
|
1462
1481
|
addFragment(content);
|
|
1463
|
-
} else if (
|
|
1464
|
-
const { fragments, ...pStyle } = p;
|
|
1465
|
-
addParagraph(
|
|
1482
|
+
} else if (isParagraphObject(p)) {
|
|
1483
|
+
const { fragments, fill: pFill, outline: pOutline, ...pStyle } = p;
|
|
1484
|
+
addParagraph(pStyle, pFill, pOutline);
|
|
1466
1485
|
fragments.forEach((f) => {
|
|
1467
|
-
const { content, ...fStyle } = f;
|
|
1468
|
-
addFragment(content,
|
|
1486
|
+
const { content, fill: fFill, outline: fOutline, ...fStyle } = f;
|
|
1487
|
+
addFragment(content, fStyle, fFill, fOutline);
|
|
1469
1488
|
});
|
|
1470
1489
|
} else if (Array.isArray(p)) {
|
|
1471
1490
|
addParagraph();
|
|
1472
1491
|
p.forEach((f) => {
|
|
1473
1492
|
if (typeof f === "string") {
|
|
1474
1493
|
addFragment(f);
|
|
1475
|
-
} else {
|
|
1476
|
-
const { content, ...fStyle } = f;
|
|
1477
|
-
addFragment(content,
|
|
1494
|
+
} else if (isFragmentObject(f)) {
|
|
1495
|
+
const { content, fill: fFill, outline: fOutline, ...fStyle } = f;
|
|
1496
|
+
addFragment(content, fStyle, fFill, fOutline);
|
|
1478
1497
|
}
|
|
1479
1498
|
});
|
|
1480
1499
|
} else {
|
|
@@ -1489,20 +1508,28 @@ function normalizeTextContent(value) {
|
|
|
1489
1508
|
}
|
|
1490
1509
|
return paragraphs;
|
|
1491
1510
|
}
|
|
1511
|
+
function isParagraphObject(value) {
|
|
1512
|
+
return value && typeof value === "object" && "fragments" in value && Array.isArray(value.fragments);
|
|
1513
|
+
}
|
|
1514
|
+
function isFragmentObject(value) {
|
|
1515
|
+
return value && typeof value === "object" && "content" in value && typeof value.content === "string";
|
|
1516
|
+
}
|
|
1492
1517
|
function normalizeText(value) {
|
|
1493
|
-
if (typeof value === "string") {
|
|
1518
|
+
if (typeof value === "string" || Array.isArray(value)) {
|
|
1494
1519
|
return {
|
|
1495
1520
|
content: normalizeTextContent(value)
|
|
1496
1521
|
};
|
|
1497
|
-
} else if ("content" in value) {
|
|
1498
|
-
return {
|
|
1499
|
-
...value,
|
|
1500
|
-
content: normalizeTextContent(value.content)
|
|
1501
|
-
};
|
|
1502
1522
|
} else {
|
|
1503
|
-
return {
|
|
1504
|
-
|
|
1505
|
-
|
|
1523
|
+
return clearUndef({
|
|
1524
|
+
...value,
|
|
1525
|
+
content: normalizeTextContent(value.content ?? ""),
|
|
1526
|
+
style: value.style ? normalizeStyle(value.style) : void 0,
|
|
1527
|
+
effects: value.effects ? value.effects.map((v) => normalizeStyle(v)) : void 0,
|
|
1528
|
+
measureDom: value.measureDom,
|
|
1529
|
+
fonts: value.fonts,
|
|
1530
|
+
fill: value.fill ? normalizeFill(value.fill) : void 0,
|
|
1531
|
+
outline: value.outline ? normalizeOutline(value.outline) : void 0
|
|
1532
|
+
});
|
|
1506
1533
|
}
|
|
1507
1534
|
}
|
|
1508
1535
|
function textContentToString(value) {
|
|
@@ -1560,12 +1587,51 @@ function normalizeFlatDocument(doc) {
|
|
|
1560
1587
|
children
|
|
1561
1588
|
};
|
|
1562
1589
|
}
|
|
1590
|
+
function flatDocumentToDocument(flatDoc) {
|
|
1591
|
+
const { children, ...restProps } = flatDoc;
|
|
1592
|
+
function toElement(flatElement) {
|
|
1593
|
+
const { parentId, childrenIds, ...element } = flatElement;
|
|
1594
|
+
return {
|
|
1595
|
+
...element,
|
|
1596
|
+
children: []
|
|
1597
|
+
};
|
|
1598
|
+
}
|
|
1599
|
+
const docElementMap = {};
|
|
1600
|
+
const docChildren = [];
|
|
1601
|
+
const doc = { ...restProps, children: docChildren };
|
|
1602
|
+
for (const id in children) {
|
|
1603
|
+
if (docElementMap[id]) {
|
|
1604
|
+
continue;
|
|
1605
|
+
}
|
|
1606
|
+
const flatElement = children[id];
|
|
1607
|
+
const element = toElement(flatElement);
|
|
1608
|
+
docElementMap[id] = element;
|
|
1609
|
+
const parentId = flatElement.parentId;
|
|
1610
|
+
if (parentId) {
|
|
1611
|
+
const flatParnet = children[parentId];
|
|
1612
|
+
let parnet = docElementMap[parentId];
|
|
1613
|
+
if (!parnet) {
|
|
1614
|
+
if (children[parentId]) {
|
|
1615
|
+
parnet = toElement(children[parentId]);
|
|
1616
|
+
docElementMap[parentId] = parnet;
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
if (flatParnet?.childrenIds && parnet?.children) {
|
|
1620
|
+
parnet.children.splice(flatParnet.childrenIds.indexOf(id), 0, element);
|
|
1621
|
+
}
|
|
1622
|
+
} else {
|
|
1623
|
+
docChildren.push(element);
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
return doc;
|
|
1627
|
+
}
|
|
1563
1628
|
|
|
1564
1629
|
exports.EventEmitter = EventEmitter;
|
|
1565
1630
|
exports.RawWeakMap = RawWeakMap;
|
|
1566
1631
|
exports.clearUndef = clearUndef;
|
|
1567
1632
|
exports.defaultColor = defaultColor;
|
|
1568
1633
|
exports.defineProperty = defineProperty;
|
|
1634
|
+
exports.flatDocumentToDocument = flatDocumentToDocument;
|
|
1569
1635
|
exports.getDeclarations = getDeclarations;
|
|
1570
1636
|
exports.getDefaultElementStyle = getDefaultElementStyle;
|
|
1571
1637
|
exports.getDefaultHighlightStyle = getDefaultHighlightStyle;
|
|
@@ -1588,13 +1654,15 @@ exports.isCRLF = isCRLF;
|
|
|
1588
1654
|
exports.isColor = isColor;
|
|
1589
1655
|
exports.isColorFill = isColorFill;
|
|
1590
1656
|
exports.isColorFillObject = isColorFillObject;
|
|
1591
|
-
exports.
|
|
1657
|
+
exports.isEqualObject = isEqualObject;
|
|
1658
|
+
exports.isFragmentObject = isFragmentObject;
|
|
1592
1659
|
exports.isGradient = isGradient;
|
|
1593
1660
|
exports.isGradientFill = isGradientFill;
|
|
1594
1661
|
exports.isGradientFillObject = isGradientFillObject;
|
|
1595
1662
|
exports.isImageFill = isImageFill;
|
|
1596
1663
|
exports.isImageFillObject = isImageFillObject;
|
|
1597
1664
|
exports.isNone = isNone;
|
|
1665
|
+
exports.isParagraphObject = isParagraphObject;
|
|
1598
1666
|
exports.isPresetFill = isPresetFill;
|
|
1599
1667
|
exports.isPresetFillObject = isPresetFillObject;
|
|
1600
1668
|
exports.nanoid = nanoid;
|
package/dist/index.d.cts
CHANGED
|
@@ -294,9 +294,13 @@ interface NormalizedPresetFill extends PresetFillObject {
|
|
|
294
294
|
}
|
|
295
295
|
declare function normalizePresetFill(fill: PresetFill): NormalizedPresetFill;
|
|
296
296
|
|
|
297
|
-
type FillObject =
|
|
297
|
+
type FillObject = {
|
|
298
|
+
enabled?: boolean;
|
|
299
|
+
} & Partial<ColorFillObject> & Partial<GradientFillObject> & Partial<ImageFillObject> & Partial<PresetFillObject>;
|
|
298
300
|
type Fill = string | FillObject;
|
|
299
|
-
type NormalizedFill =
|
|
301
|
+
type NormalizedFill = {
|
|
302
|
+
enabled?: boolean;
|
|
303
|
+
} & Partial<NormalizedColorFill> & Partial<NormalizedGradientFill> & Partial<NormalizedImageFill> & Partial<NormalizedPresetFill>;
|
|
300
304
|
declare function isColorFillObject(fill: FillObject): fill is ColorFillObject;
|
|
301
305
|
declare function isColorFill(fill: Fill): fill is ColorFill;
|
|
302
306
|
declare function isGradientFillObject(fill: FillObject): fill is GradientFillObject;
|
|
@@ -666,47 +670,69 @@ interface NormalizedTextDrawStyle {
|
|
|
666
670
|
type NormalizedTextStyle = NormalizedTextLineStyle & NormalizedTextInlineStyle & NormalizedTextDrawStyle;
|
|
667
671
|
declare function getDefaultTextStyle(): Required<NormalizedTextStyle>;
|
|
668
672
|
|
|
669
|
-
type
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
};
|
|
673
|
-
type StyleObject = Partial<NormalizedStyle> & {
|
|
673
|
+
type FullStyle = NormalizedTextStyle & NormalizedElementStyle;
|
|
674
|
+
type NormalizedStyle = Partial<FullStyle>;
|
|
675
|
+
type StyleObject = NormalizedStyle & {
|
|
674
676
|
color?: WithStyleNone<Color>;
|
|
675
677
|
backgroundColor?: WithStyleNone<Color>;
|
|
676
678
|
borderColor?: WithStyleNone<Color>;
|
|
677
679
|
outlineColor?: WithStyleNone<Color>;
|
|
678
680
|
shadowColor?: WithStyleNone<Color>;
|
|
679
|
-
fill?: Fill;
|
|
680
|
-
outline?: Outline;
|
|
681
681
|
};
|
|
682
682
|
type Style = StyleObject;
|
|
683
|
-
declare function normalizeStyle(style: Style):
|
|
684
|
-
declare function getDefaultStyle():
|
|
683
|
+
declare function normalizeStyle(style: Style): NormalizedStyle;
|
|
684
|
+
declare function getDefaultStyle(): FullStyle;
|
|
685
685
|
|
|
686
686
|
interface FragmentObject extends StyleObject {
|
|
687
687
|
content: string;
|
|
688
|
+
fill?: Fill;
|
|
689
|
+
outline?: Outline;
|
|
690
|
+
}
|
|
691
|
+
interface NormalizedFragment extends NormalizedStyle {
|
|
692
|
+
content: string;
|
|
693
|
+
fill?: NormalizedFill;
|
|
694
|
+
outline?: NormalizedOutline;
|
|
688
695
|
}
|
|
689
696
|
interface ParagraphObject extends StyleObject {
|
|
690
697
|
fragments: FragmentObject[];
|
|
698
|
+
fill?: Fill;
|
|
699
|
+
outline?: Outline;
|
|
700
|
+
}
|
|
701
|
+
interface NormalizedParagraph extends NormalizedStyle {
|
|
702
|
+
fragments: NormalizedFragment[];
|
|
703
|
+
fill?: NormalizedFill;
|
|
704
|
+
outline?: NormalizedOutline;
|
|
691
705
|
}
|
|
692
706
|
type FlatTextContent = string | FragmentObject | ParagraphObject | (string | FragmentObject)[];
|
|
693
707
|
type TextContent = FlatTextContent | FlatTextContent[];
|
|
694
|
-
type NormalizedTextContent =
|
|
708
|
+
type NormalizedTextContent = NormalizedParagraph[];
|
|
709
|
+
interface TextObject {
|
|
710
|
+
content?: TextContent;
|
|
711
|
+
enabled?: boolean;
|
|
712
|
+
style?: Style;
|
|
713
|
+
effects?: Style[];
|
|
714
|
+
measureDom?: any;
|
|
715
|
+
fonts?: any;
|
|
716
|
+
fill?: Fill;
|
|
717
|
+
outline?: Outline;
|
|
718
|
+
}
|
|
695
719
|
interface NormalizedText {
|
|
696
720
|
content: NormalizedTextContent;
|
|
697
|
-
|
|
698
|
-
|
|
721
|
+
enabled?: boolean;
|
|
722
|
+
style?: NormalizedStyle;
|
|
723
|
+
effects?: NormalizedStyle[];
|
|
699
724
|
measureDom?: any;
|
|
700
725
|
fonts?: any;
|
|
726
|
+
fill?: NormalizedFill;
|
|
727
|
+
outline?: NormalizedOutline;
|
|
701
728
|
}
|
|
702
|
-
type Text = string |
|
|
703
|
-
content: TextContent;
|
|
704
|
-
});
|
|
729
|
+
type Text = string | FlatTextContent[] | TextObject;
|
|
705
730
|
declare function hasCRLF(content: string): boolean;
|
|
706
731
|
declare function isCRLF(char: string): boolean;
|
|
707
732
|
declare function normalizeCRLF(content: string): string;
|
|
708
|
-
declare function isEqualStyle(style1: Record<string, any>, style2: Record<string, any>): boolean;
|
|
709
733
|
declare function normalizeTextContent(value: TextContent): NormalizedTextContent;
|
|
734
|
+
declare function isParagraphObject(value: any): value is ParagraphObject;
|
|
735
|
+
declare function isFragmentObject(value: any): value is FragmentObject;
|
|
710
736
|
declare function normalizeText(value: Text): NormalizedText;
|
|
711
737
|
declare function textContentToString(value: TextContent): string;
|
|
712
738
|
|
|
@@ -733,7 +759,7 @@ interface Element<T = Meta> extends Omit<Node<T>, 'children'> {
|
|
|
733
759
|
}
|
|
734
760
|
interface NormalizedElement<T = Meta> extends Omit<Node<T>, 'children'> {
|
|
735
761
|
id: string;
|
|
736
|
-
style?:
|
|
762
|
+
style?: NormalizedStyle;
|
|
737
763
|
text?: NormalizedText;
|
|
738
764
|
background?: NormalizedBackground;
|
|
739
765
|
shape?: NormalizedShape;
|
|
@@ -756,23 +782,24 @@ interface NormalizedDocument extends NormalizedElement {
|
|
|
756
782
|
}
|
|
757
783
|
declare function normalizeDocument(doc: Document): NormalizedDocument;
|
|
758
784
|
|
|
759
|
-
|
|
785
|
+
interface FlatElement extends Omit<Element, 'children'> {
|
|
760
786
|
parentId?: string;
|
|
761
787
|
childrenIds?: string[];
|
|
762
|
-
}
|
|
763
|
-
interface FlatDocument {
|
|
788
|
+
}
|
|
789
|
+
interface FlatDocument extends Omit<Element, 'children'> {
|
|
764
790
|
fonts?: any;
|
|
765
791
|
children: Record<string, FlatElement>;
|
|
766
792
|
}
|
|
767
|
-
|
|
793
|
+
interface NormalizedFlatElement extends Omit<NormalizedElement, 'children'> {
|
|
768
794
|
parentId?: string;
|
|
769
795
|
childrenIds?: string[];
|
|
770
|
-
}
|
|
796
|
+
}
|
|
771
797
|
interface NormalizedFlatDocument {
|
|
772
798
|
fonts?: any;
|
|
773
799
|
children: Record<string, NormalizedFlatElement>;
|
|
774
800
|
}
|
|
775
801
|
declare function normalizeFlatDocument(doc: FlatDocument): NormalizedFlatDocument;
|
|
802
|
+
declare function flatDocumentToDocument(flatDoc: FlatDocument): Document;
|
|
776
803
|
|
|
777
804
|
type IdGenerator = () => string;
|
|
778
805
|
declare const nanoid: IdGenerator;
|
|
@@ -804,6 +831,7 @@ declare function round(number: number, digits?: number, base?: number): number;
|
|
|
804
831
|
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
805
832
|
declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
806
833
|
|
|
834
|
+
declare function isEqualObject(a: any, b: any): boolean;
|
|
807
835
|
declare function getNestedValue(obj: any, path: (string | number)[], fallback?: any): any;
|
|
808
836
|
declare function setNestedValue(obj: any, path: (string | number)[], value: any): void;
|
|
809
837
|
declare function getObjectValueByPath(obj: any, path: string, fallback?: any): any;
|
|
@@ -832,5 +860,5 @@ declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
|
|
|
832
860
|
set(key: K, value: V): this;
|
|
833
861
|
}
|
|
834
862
|
|
|
835
|
-
export { EventEmitter, RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject,
|
|
836
|
-
export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, EventListener, EventListenerOptions, EventListenerValue, ExtentKeywordNode, Fill, FillObject, FillRule, FlatDocument, FlatElement, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, IdGenerator, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, LinearGradientWithType, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedBaseOutline, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedFlatDocument, NormalizedFlatElement, NormalizedForeground, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedPresetFill, NormalizedShadow, NormalizedShadowStyle, NormalizedShape, NormalizedSoftEdge, NormalizedStyle, NormalizedText, NormalizedTextContent, NormalizedTextDrawStyle, NormalizedTextInlineStyle, NormalizedTextLineStyle, NormalizedTextStyle, NormalizedTransformStyle, NormalizedVideo, ObjectColor, OuterShadow, OuterShadowObject, Outline, OutlineObject, OutlineStyle, Overflow, ParagraphObject, PercentNode, PointerEvents, Position, PositionKeywordNode, PositionNode, PresetFill, PresetFillObject, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, ReactiveObject, ReactiveObjectPropertyAccessorContext, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextDecoration, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
|
|
863
|
+
export { EventEmitter, RawWeakMap, clearUndef, defaultColor, defineProperty, flatDocumentToDocument, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualObject, isFragmentObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isParagraphObject, isPresetFill, isPresetFillObject, nanoid, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeFlatDocument, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, property2, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
|
|
864
|
+
export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, EventListener, EventListenerOptions, EventListenerValue, ExtentKeywordNode, Fill, FillObject, FillRule, FlatDocument, FlatElement, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, FullStyle, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, IdGenerator, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, LinearGradientWithType, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedBaseOutline, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedFlatDocument, NormalizedFlatElement, NormalizedForeground, NormalizedFragment, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedParagraph, NormalizedPresetFill, NormalizedShadow, NormalizedShadowStyle, NormalizedShape, NormalizedSoftEdge, NormalizedStyle, NormalizedText, NormalizedTextContent, NormalizedTextDrawStyle, NormalizedTextInlineStyle, NormalizedTextLineStyle, NormalizedTextStyle, NormalizedTransformStyle, NormalizedVideo, ObjectColor, OuterShadow, OuterShadowObject, Outline, OutlineObject, OutlineStyle, Overflow, ParagraphObject, PercentNode, PointerEvents, Position, PositionKeywordNode, PositionNode, PresetFill, PresetFillObject, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, ReactiveObject, ReactiveObjectPropertyAccessorContext, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextDecoration, TextObject, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
|
package/dist/index.d.mts
CHANGED
|
@@ -294,9 +294,13 @@ interface NormalizedPresetFill extends PresetFillObject {
|
|
|
294
294
|
}
|
|
295
295
|
declare function normalizePresetFill(fill: PresetFill): NormalizedPresetFill;
|
|
296
296
|
|
|
297
|
-
type FillObject =
|
|
297
|
+
type FillObject = {
|
|
298
|
+
enabled?: boolean;
|
|
299
|
+
} & Partial<ColorFillObject> & Partial<GradientFillObject> & Partial<ImageFillObject> & Partial<PresetFillObject>;
|
|
298
300
|
type Fill = string | FillObject;
|
|
299
|
-
type NormalizedFill =
|
|
301
|
+
type NormalizedFill = {
|
|
302
|
+
enabled?: boolean;
|
|
303
|
+
} & Partial<NormalizedColorFill> & Partial<NormalizedGradientFill> & Partial<NormalizedImageFill> & Partial<NormalizedPresetFill>;
|
|
300
304
|
declare function isColorFillObject(fill: FillObject): fill is ColorFillObject;
|
|
301
305
|
declare function isColorFill(fill: Fill): fill is ColorFill;
|
|
302
306
|
declare function isGradientFillObject(fill: FillObject): fill is GradientFillObject;
|
|
@@ -666,47 +670,69 @@ interface NormalizedTextDrawStyle {
|
|
|
666
670
|
type NormalizedTextStyle = NormalizedTextLineStyle & NormalizedTextInlineStyle & NormalizedTextDrawStyle;
|
|
667
671
|
declare function getDefaultTextStyle(): Required<NormalizedTextStyle>;
|
|
668
672
|
|
|
669
|
-
type
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
};
|
|
673
|
-
type StyleObject = Partial<NormalizedStyle> & {
|
|
673
|
+
type FullStyle = NormalizedTextStyle & NormalizedElementStyle;
|
|
674
|
+
type NormalizedStyle = Partial<FullStyle>;
|
|
675
|
+
type StyleObject = NormalizedStyle & {
|
|
674
676
|
color?: WithStyleNone<Color>;
|
|
675
677
|
backgroundColor?: WithStyleNone<Color>;
|
|
676
678
|
borderColor?: WithStyleNone<Color>;
|
|
677
679
|
outlineColor?: WithStyleNone<Color>;
|
|
678
680
|
shadowColor?: WithStyleNone<Color>;
|
|
679
|
-
fill?: Fill;
|
|
680
|
-
outline?: Outline;
|
|
681
681
|
};
|
|
682
682
|
type Style = StyleObject;
|
|
683
|
-
declare function normalizeStyle(style: Style):
|
|
684
|
-
declare function getDefaultStyle():
|
|
683
|
+
declare function normalizeStyle(style: Style): NormalizedStyle;
|
|
684
|
+
declare function getDefaultStyle(): FullStyle;
|
|
685
685
|
|
|
686
686
|
interface FragmentObject extends StyleObject {
|
|
687
687
|
content: string;
|
|
688
|
+
fill?: Fill;
|
|
689
|
+
outline?: Outline;
|
|
690
|
+
}
|
|
691
|
+
interface NormalizedFragment extends NormalizedStyle {
|
|
692
|
+
content: string;
|
|
693
|
+
fill?: NormalizedFill;
|
|
694
|
+
outline?: NormalizedOutline;
|
|
688
695
|
}
|
|
689
696
|
interface ParagraphObject extends StyleObject {
|
|
690
697
|
fragments: FragmentObject[];
|
|
698
|
+
fill?: Fill;
|
|
699
|
+
outline?: Outline;
|
|
700
|
+
}
|
|
701
|
+
interface NormalizedParagraph extends NormalizedStyle {
|
|
702
|
+
fragments: NormalizedFragment[];
|
|
703
|
+
fill?: NormalizedFill;
|
|
704
|
+
outline?: NormalizedOutline;
|
|
691
705
|
}
|
|
692
706
|
type FlatTextContent = string | FragmentObject | ParagraphObject | (string | FragmentObject)[];
|
|
693
707
|
type TextContent = FlatTextContent | FlatTextContent[];
|
|
694
|
-
type NormalizedTextContent =
|
|
708
|
+
type NormalizedTextContent = NormalizedParagraph[];
|
|
709
|
+
interface TextObject {
|
|
710
|
+
content?: TextContent;
|
|
711
|
+
enabled?: boolean;
|
|
712
|
+
style?: Style;
|
|
713
|
+
effects?: Style[];
|
|
714
|
+
measureDom?: any;
|
|
715
|
+
fonts?: any;
|
|
716
|
+
fill?: Fill;
|
|
717
|
+
outline?: Outline;
|
|
718
|
+
}
|
|
695
719
|
interface NormalizedText {
|
|
696
720
|
content: NormalizedTextContent;
|
|
697
|
-
|
|
698
|
-
|
|
721
|
+
enabled?: boolean;
|
|
722
|
+
style?: NormalizedStyle;
|
|
723
|
+
effects?: NormalizedStyle[];
|
|
699
724
|
measureDom?: any;
|
|
700
725
|
fonts?: any;
|
|
726
|
+
fill?: NormalizedFill;
|
|
727
|
+
outline?: NormalizedOutline;
|
|
701
728
|
}
|
|
702
|
-
type Text = string |
|
|
703
|
-
content: TextContent;
|
|
704
|
-
});
|
|
729
|
+
type Text = string | FlatTextContent[] | TextObject;
|
|
705
730
|
declare function hasCRLF(content: string): boolean;
|
|
706
731
|
declare function isCRLF(char: string): boolean;
|
|
707
732
|
declare function normalizeCRLF(content: string): string;
|
|
708
|
-
declare function isEqualStyle(style1: Record<string, any>, style2: Record<string, any>): boolean;
|
|
709
733
|
declare function normalizeTextContent(value: TextContent): NormalizedTextContent;
|
|
734
|
+
declare function isParagraphObject(value: any): value is ParagraphObject;
|
|
735
|
+
declare function isFragmentObject(value: any): value is FragmentObject;
|
|
710
736
|
declare function normalizeText(value: Text): NormalizedText;
|
|
711
737
|
declare function textContentToString(value: TextContent): string;
|
|
712
738
|
|
|
@@ -733,7 +759,7 @@ interface Element<T = Meta> extends Omit<Node<T>, 'children'> {
|
|
|
733
759
|
}
|
|
734
760
|
interface NormalizedElement<T = Meta> extends Omit<Node<T>, 'children'> {
|
|
735
761
|
id: string;
|
|
736
|
-
style?:
|
|
762
|
+
style?: NormalizedStyle;
|
|
737
763
|
text?: NormalizedText;
|
|
738
764
|
background?: NormalizedBackground;
|
|
739
765
|
shape?: NormalizedShape;
|
|
@@ -756,23 +782,24 @@ interface NormalizedDocument extends NormalizedElement {
|
|
|
756
782
|
}
|
|
757
783
|
declare function normalizeDocument(doc: Document): NormalizedDocument;
|
|
758
784
|
|
|
759
|
-
|
|
785
|
+
interface FlatElement extends Omit<Element, 'children'> {
|
|
760
786
|
parentId?: string;
|
|
761
787
|
childrenIds?: string[];
|
|
762
|
-
}
|
|
763
|
-
interface FlatDocument {
|
|
788
|
+
}
|
|
789
|
+
interface FlatDocument extends Omit<Element, 'children'> {
|
|
764
790
|
fonts?: any;
|
|
765
791
|
children: Record<string, FlatElement>;
|
|
766
792
|
}
|
|
767
|
-
|
|
793
|
+
interface NormalizedFlatElement extends Omit<NormalizedElement, 'children'> {
|
|
768
794
|
parentId?: string;
|
|
769
795
|
childrenIds?: string[];
|
|
770
|
-
}
|
|
796
|
+
}
|
|
771
797
|
interface NormalizedFlatDocument {
|
|
772
798
|
fonts?: any;
|
|
773
799
|
children: Record<string, NormalizedFlatElement>;
|
|
774
800
|
}
|
|
775
801
|
declare function normalizeFlatDocument(doc: FlatDocument): NormalizedFlatDocument;
|
|
802
|
+
declare function flatDocumentToDocument(flatDoc: FlatDocument): Document;
|
|
776
803
|
|
|
777
804
|
type IdGenerator = () => string;
|
|
778
805
|
declare const nanoid: IdGenerator;
|
|
@@ -804,6 +831,7 @@ declare function round(number: number, digits?: number, base?: number): number;
|
|
|
804
831
|
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
805
832
|
declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
806
833
|
|
|
834
|
+
declare function isEqualObject(a: any, b: any): boolean;
|
|
807
835
|
declare function getNestedValue(obj: any, path: (string | number)[], fallback?: any): any;
|
|
808
836
|
declare function setNestedValue(obj: any, path: (string | number)[], value: any): void;
|
|
809
837
|
declare function getObjectValueByPath(obj: any, path: string, fallback?: any): any;
|
|
@@ -832,5 +860,5 @@ declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
|
|
|
832
860
|
set(key: K, value: V): this;
|
|
833
861
|
}
|
|
834
862
|
|
|
835
|
-
export { EventEmitter, RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject,
|
|
836
|
-
export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, EventListener, EventListenerOptions, EventListenerValue, ExtentKeywordNode, Fill, FillObject, FillRule, FlatDocument, FlatElement, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, IdGenerator, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, LinearGradientWithType, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedBaseOutline, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedFlatDocument, NormalizedFlatElement, NormalizedForeground, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedPresetFill, NormalizedShadow, NormalizedShadowStyle, NormalizedShape, NormalizedSoftEdge, NormalizedStyle, NormalizedText, NormalizedTextContent, NormalizedTextDrawStyle, NormalizedTextInlineStyle, NormalizedTextLineStyle, NormalizedTextStyle, NormalizedTransformStyle, NormalizedVideo, ObjectColor, OuterShadow, OuterShadowObject, Outline, OutlineObject, OutlineStyle, Overflow, ParagraphObject, PercentNode, PointerEvents, Position, PositionKeywordNode, PositionNode, PresetFill, PresetFillObject, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, ReactiveObject, ReactiveObjectPropertyAccessorContext, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextDecoration, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
|
|
863
|
+
export { EventEmitter, RawWeakMap, clearUndef, defaultColor, defineProperty, flatDocumentToDocument, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualObject, isFragmentObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isParagraphObject, isPresetFill, isPresetFillObject, nanoid, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeFlatDocument, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, property2, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
|
|
864
|
+
export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, EventListener, EventListenerOptions, EventListenerValue, ExtentKeywordNode, Fill, FillObject, FillRule, FlatDocument, FlatElement, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, FullStyle, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, IdGenerator, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, LinearGradientWithType, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedBaseOutline, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedFlatDocument, NormalizedFlatElement, NormalizedForeground, NormalizedFragment, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedParagraph, NormalizedPresetFill, NormalizedShadow, NormalizedShadowStyle, NormalizedShape, NormalizedSoftEdge, NormalizedStyle, NormalizedText, NormalizedTextContent, NormalizedTextDrawStyle, NormalizedTextInlineStyle, NormalizedTextLineStyle, NormalizedTextStyle, NormalizedTransformStyle, NormalizedVideo, ObjectColor, OuterShadow, OuterShadowObject, Outline, OutlineObject, OutlineStyle, Overflow, ParagraphObject, PercentNode, PointerEvents, Position, PositionKeywordNode, PositionNode, PresetFill, PresetFillObject, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, ReactiveObject, ReactiveObjectPropertyAccessorContext, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextDecoration, TextObject, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
|
package/dist/index.d.ts
CHANGED
|
@@ -294,9 +294,13 @@ interface NormalizedPresetFill extends PresetFillObject {
|
|
|
294
294
|
}
|
|
295
295
|
declare function normalizePresetFill(fill: PresetFill): NormalizedPresetFill;
|
|
296
296
|
|
|
297
|
-
type FillObject =
|
|
297
|
+
type FillObject = {
|
|
298
|
+
enabled?: boolean;
|
|
299
|
+
} & Partial<ColorFillObject> & Partial<GradientFillObject> & Partial<ImageFillObject> & Partial<PresetFillObject>;
|
|
298
300
|
type Fill = string | FillObject;
|
|
299
|
-
type NormalizedFill =
|
|
301
|
+
type NormalizedFill = {
|
|
302
|
+
enabled?: boolean;
|
|
303
|
+
} & Partial<NormalizedColorFill> & Partial<NormalizedGradientFill> & Partial<NormalizedImageFill> & Partial<NormalizedPresetFill>;
|
|
300
304
|
declare function isColorFillObject(fill: FillObject): fill is ColorFillObject;
|
|
301
305
|
declare function isColorFill(fill: Fill): fill is ColorFill;
|
|
302
306
|
declare function isGradientFillObject(fill: FillObject): fill is GradientFillObject;
|
|
@@ -666,47 +670,69 @@ interface NormalizedTextDrawStyle {
|
|
|
666
670
|
type NormalizedTextStyle = NormalizedTextLineStyle & NormalizedTextInlineStyle & NormalizedTextDrawStyle;
|
|
667
671
|
declare function getDefaultTextStyle(): Required<NormalizedTextStyle>;
|
|
668
672
|
|
|
669
|
-
type
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
};
|
|
673
|
-
type StyleObject = Partial<NormalizedStyle> & {
|
|
673
|
+
type FullStyle = NormalizedTextStyle & NormalizedElementStyle;
|
|
674
|
+
type NormalizedStyle = Partial<FullStyle>;
|
|
675
|
+
type StyleObject = NormalizedStyle & {
|
|
674
676
|
color?: WithStyleNone<Color>;
|
|
675
677
|
backgroundColor?: WithStyleNone<Color>;
|
|
676
678
|
borderColor?: WithStyleNone<Color>;
|
|
677
679
|
outlineColor?: WithStyleNone<Color>;
|
|
678
680
|
shadowColor?: WithStyleNone<Color>;
|
|
679
|
-
fill?: Fill;
|
|
680
|
-
outline?: Outline;
|
|
681
681
|
};
|
|
682
682
|
type Style = StyleObject;
|
|
683
|
-
declare function normalizeStyle(style: Style):
|
|
684
|
-
declare function getDefaultStyle():
|
|
683
|
+
declare function normalizeStyle(style: Style): NormalizedStyle;
|
|
684
|
+
declare function getDefaultStyle(): FullStyle;
|
|
685
685
|
|
|
686
686
|
interface FragmentObject extends StyleObject {
|
|
687
687
|
content: string;
|
|
688
|
+
fill?: Fill;
|
|
689
|
+
outline?: Outline;
|
|
690
|
+
}
|
|
691
|
+
interface NormalizedFragment extends NormalizedStyle {
|
|
692
|
+
content: string;
|
|
693
|
+
fill?: NormalizedFill;
|
|
694
|
+
outline?: NormalizedOutline;
|
|
688
695
|
}
|
|
689
696
|
interface ParagraphObject extends StyleObject {
|
|
690
697
|
fragments: FragmentObject[];
|
|
698
|
+
fill?: Fill;
|
|
699
|
+
outline?: Outline;
|
|
700
|
+
}
|
|
701
|
+
interface NormalizedParagraph extends NormalizedStyle {
|
|
702
|
+
fragments: NormalizedFragment[];
|
|
703
|
+
fill?: NormalizedFill;
|
|
704
|
+
outline?: NormalizedOutline;
|
|
691
705
|
}
|
|
692
706
|
type FlatTextContent = string | FragmentObject | ParagraphObject | (string | FragmentObject)[];
|
|
693
707
|
type TextContent = FlatTextContent | FlatTextContent[];
|
|
694
|
-
type NormalizedTextContent =
|
|
708
|
+
type NormalizedTextContent = NormalizedParagraph[];
|
|
709
|
+
interface TextObject {
|
|
710
|
+
content?: TextContent;
|
|
711
|
+
enabled?: boolean;
|
|
712
|
+
style?: Style;
|
|
713
|
+
effects?: Style[];
|
|
714
|
+
measureDom?: any;
|
|
715
|
+
fonts?: any;
|
|
716
|
+
fill?: Fill;
|
|
717
|
+
outline?: Outline;
|
|
718
|
+
}
|
|
695
719
|
interface NormalizedText {
|
|
696
720
|
content: NormalizedTextContent;
|
|
697
|
-
|
|
698
|
-
|
|
721
|
+
enabled?: boolean;
|
|
722
|
+
style?: NormalizedStyle;
|
|
723
|
+
effects?: NormalizedStyle[];
|
|
699
724
|
measureDom?: any;
|
|
700
725
|
fonts?: any;
|
|
726
|
+
fill?: NormalizedFill;
|
|
727
|
+
outline?: NormalizedOutline;
|
|
701
728
|
}
|
|
702
|
-
type Text = string |
|
|
703
|
-
content: TextContent;
|
|
704
|
-
});
|
|
729
|
+
type Text = string | FlatTextContent[] | TextObject;
|
|
705
730
|
declare function hasCRLF(content: string): boolean;
|
|
706
731
|
declare function isCRLF(char: string): boolean;
|
|
707
732
|
declare function normalizeCRLF(content: string): string;
|
|
708
|
-
declare function isEqualStyle(style1: Record<string, any>, style2: Record<string, any>): boolean;
|
|
709
733
|
declare function normalizeTextContent(value: TextContent): NormalizedTextContent;
|
|
734
|
+
declare function isParagraphObject(value: any): value is ParagraphObject;
|
|
735
|
+
declare function isFragmentObject(value: any): value is FragmentObject;
|
|
710
736
|
declare function normalizeText(value: Text): NormalizedText;
|
|
711
737
|
declare function textContentToString(value: TextContent): string;
|
|
712
738
|
|
|
@@ -733,7 +759,7 @@ interface Element<T = Meta> extends Omit<Node<T>, 'children'> {
|
|
|
733
759
|
}
|
|
734
760
|
interface NormalizedElement<T = Meta> extends Omit<Node<T>, 'children'> {
|
|
735
761
|
id: string;
|
|
736
|
-
style?:
|
|
762
|
+
style?: NormalizedStyle;
|
|
737
763
|
text?: NormalizedText;
|
|
738
764
|
background?: NormalizedBackground;
|
|
739
765
|
shape?: NormalizedShape;
|
|
@@ -756,23 +782,24 @@ interface NormalizedDocument extends NormalizedElement {
|
|
|
756
782
|
}
|
|
757
783
|
declare function normalizeDocument(doc: Document): NormalizedDocument;
|
|
758
784
|
|
|
759
|
-
|
|
785
|
+
interface FlatElement extends Omit<Element, 'children'> {
|
|
760
786
|
parentId?: string;
|
|
761
787
|
childrenIds?: string[];
|
|
762
|
-
}
|
|
763
|
-
interface FlatDocument {
|
|
788
|
+
}
|
|
789
|
+
interface FlatDocument extends Omit<Element, 'children'> {
|
|
764
790
|
fonts?: any;
|
|
765
791
|
children: Record<string, FlatElement>;
|
|
766
792
|
}
|
|
767
|
-
|
|
793
|
+
interface NormalizedFlatElement extends Omit<NormalizedElement, 'children'> {
|
|
768
794
|
parentId?: string;
|
|
769
795
|
childrenIds?: string[];
|
|
770
|
-
}
|
|
796
|
+
}
|
|
771
797
|
interface NormalizedFlatDocument {
|
|
772
798
|
fonts?: any;
|
|
773
799
|
children: Record<string, NormalizedFlatElement>;
|
|
774
800
|
}
|
|
775
801
|
declare function normalizeFlatDocument(doc: FlatDocument): NormalizedFlatDocument;
|
|
802
|
+
declare function flatDocumentToDocument(flatDoc: FlatDocument): Document;
|
|
776
803
|
|
|
777
804
|
type IdGenerator = () => string;
|
|
778
805
|
declare const nanoid: IdGenerator;
|
|
@@ -804,6 +831,7 @@ declare function round(number: number, digits?: number, base?: number): number;
|
|
|
804
831
|
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
805
832
|
declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
806
833
|
|
|
834
|
+
declare function isEqualObject(a: any, b: any): boolean;
|
|
807
835
|
declare function getNestedValue(obj: any, path: (string | number)[], fallback?: any): any;
|
|
808
836
|
declare function setNestedValue(obj: any, path: (string | number)[], value: any): void;
|
|
809
837
|
declare function getObjectValueByPath(obj: any, path: string, fallback?: any): any;
|
|
@@ -832,5 +860,5 @@ declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
|
|
|
832
860
|
set(key: K, value: V): this;
|
|
833
861
|
}
|
|
834
862
|
|
|
835
|
-
export { EventEmitter, RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject,
|
|
836
|
-
export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, EventListener, EventListenerOptions, EventListenerValue, ExtentKeywordNode, Fill, FillObject, FillRule, FlatDocument, FlatElement, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, IdGenerator, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, LinearGradientWithType, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedBaseOutline, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedFlatDocument, NormalizedFlatElement, NormalizedForeground, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedPresetFill, NormalizedShadow, NormalizedShadowStyle, NormalizedShape, NormalizedSoftEdge, NormalizedStyle, NormalizedText, NormalizedTextContent, NormalizedTextDrawStyle, NormalizedTextInlineStyle, NormalizedTextLineStyle, NormalizedTextStyle, NormalizedTransformStyle, NormalizedVideo, ObjectColor, OuterShadow, OuterShadowObject, Outline, OutlineObject, OutlineStyle, Overflow, ParagraphObject, PercentNode, PointerEvents, Position, PositionKeywordNode, PositionNode, PresetFill, PresetFillObject, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, ReactiveObject, ReactiveObjectPropertyAccessorContext, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextDecoration, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
|
|
863
|
+
export { EventEmitter, RawWeakMap, clearUndef, defaultColor, defineProperty, flatDocumentToDocument, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualObject, isFragmentObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isParagraphObject, isPresetFill, isPresetFillObject, nanoid, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeFlatDocument, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, property2, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
|
|
864
|
+
export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, EventListener, EventListenerOptions, EventListenerValue, ExtentKeywordNode, Fill, FillObject, FillRule, FlatDocument, FlatElement, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, FullStyle, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, IdGenerator, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, LinearGradientWithType, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedBaseOutline, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedFlatDocument, NormalizedFlatElement, NormalizedForeground, NormalizedFragment, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedParagraph, NormalizedPresetFill, NormalizedShadow, NormalizedShadowStyle, NormalizedShape, NormalizedSoftEdge, NormalizedStyle, NormalizedText, NormalizedTextContent, NormalizedTextDrawStyle, NormalizedTextInlineStyle, NormalizedTextLineStyle, NormalizedTextStyle, NormalizedTransformStyle, NormalizedVideo, ObjectColor, OuterShadow, OuterShadowObject, Outline, OutlineObject, OutlineStyle, Overflow, ParagraphObject, PercentNode, PointerEvents, Position, PositionKeywordNode, PositionNode, PresetFill, PresetFillObject, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, ReactiveObject, ReactiveObjectPropertyAccessorContext, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextDecoration, TextObject, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(o,D){typeof exports=="object"&&typeof module<"u"?D(exports):typeof define=="function"&&define.amd?define(["exports"],D):(o=typeof globalThis<"u"?globalThis:o||self,D(o.modernIdoc={}))})(this,function(o){"use strict";function D(t){return typeof t=="string"?{src:t}:t}var de={grad:.9,turn:360,rad:360/(2*Math.PI)},L=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},p=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},_=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},lt=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},st=function(t){return{r:_(t.r,0,255),g:_(t.g,0,255),b:_(t.b,0,255),a:_(t.a)}},X=function(t){return{r:p(t.r),g:p(t.g),b:p(t.b),a:p(t.a,3)}},ge=/^#([0-9a-f]{3,8})$/i,T=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},ct=function(t){var e=t.r,n=t.g,r=t.b,i=t.a,a=Math.max(e,n,r),l=a-Math.min(e,n,r),c=l?a===e?(n-r)/l:a===n?2+(r-e)/l:4+(e-n)/l:0;return{h:60*(c<0?c+6:c),s:a?l/a*100:0,v:a/255*100,a:i}},ft=function(t){var e=t.h,n=t.s,r=t.v,i=t.a;e=e/360*6,n/=100,r/=100;var a=Math.floor(e),l=r*(1-n),c=r*(1-(e-a)*n),d=r*(1-(1-e+a)*n),m=a%6;return{r:255*[r,c,l,l,d,r][m],g:255*[d,r,r,c,l,l][m],b:255*[l,l,d,r,r,c][m],a:i}},dt=function(t){return{h:lt(t.h),s:_(t.s,0,100),l:_(t.l,0,100),a:_(t.a)}},gt=function(t){return{h:p(t.h),s:p(t.s),l:p(t.l),a:p(t.a,3)}},ht=function(t){return ft((n=(e=t).s,{h:e.h,s:(n*=((r=e.l)<50?r:100-r)/100)>0?2*n/(r+n)*100:0,v:r+n,a:e.a}));var e,n,r},G=function(t){return{h:(e=ct(t)).h,s:(i=(200-(n=e.s))*(r=e.v)/100)>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,n,r,i},he=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ve=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,pe=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,me=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,vt={string:[[function(t){var e=ge.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?p(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?p(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=pe.exec(t)||me.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:st({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=he.exec(t)||ve.exec(t);if(!e)return null;var n,r,i=dt({h:(n=e[1],r=e[2],r===void 0&&(r="deg"),Number(n)*(de[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return ht(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,r=t.b,i=t.a,a=i===void 0?1:i;return L(e)&&L(n)&&L(r)?st({r:Number(e),g:Number(n),b:Number(r),a:Number(a)}):null},"rgb"],[function(t){var e=t.h,n=t.s,r=t.l,i=t.a,a=i===void 0?1:i;if(!L(e)||!L(n)||!L(r))return null;var l=dt({h:Number(e),s:Number(n),l:Number(r),a:Number(a)});return ht(l)},"hsl"],[function(t){var e=t.h,n=t.s,r=t.v,i=t.a,a=i===void 0?1:i;if(!L(e)||!L(n)||!L(r))return null;var l=function(c){return{h:lt(c.h),s:_(c.s,0,100),v:_(c.v,0,100),a:_(c.a)}}({h:Number(e),s:Number(n),v:Number(r),a:Number(a)});return ft(l)},"hsv"]]},pt=function(t,e){for(var n=0;n<e.length;n++){var r=e[n][0](t);if(r)return[r,e[n][1]]}return[null,void 0]},ye=function(t){return typeof t=="string"?pt(t.trim(),vt.string):typeof t=="object"&&t!==null?pt(t,vt.object):[null,void 0]},Y=function(t,e){var n=G(t);return{h:n.h,s:_(n.s+100*e,0,100),l:n.l,a:n.a}},q=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},mt=function(t,e){var n=G(t);return{h:n.h,s:n.s,l:_(n.l+100*e,0,100),a:n.a}},yt=function(){function t(e){this.parsed=ye(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return p(q(this.rgba),2)},t.prototype.isDark=function(){return q(this.rgba)<.5},t.prototype.isLight=function(){return q(this.rgba)>=.5},t.prototype.toHex=function(){return e=X(this.rgba),n=e.r,r=e.g,i=e.b,l=(a=e.a)<1?T(p(255*a)):"","#"+T(n)+T(r)+T(i)+l;var e,n,r,i,a,l},t.prototype.toRgb=function(){return X(this.rgba)},t.prototype.toRgbString=function(){return e=X(this.rgba),n=e.r,r=e.g,i=e.b,(a=e.a)<1?"rgba("+n+", "+r+", "+i+", "+a+")":"rgb("+n+", "+r+", "+i+")";var e,n,r,i,a},t.prototype.toHsl=function(){return gt(G(this.rgba))},t.prototype.toHslString=function(){return e=gt(G(this.rgba)),n=e.h,r=e.s,i=e.l,(a=e.a)<1?"hsla("+n+", "+r+"%, "+i+"%, "+a+")":"hsl("+n+", "+r+"%, "+i+"%)";var e,n,r,i,a},t.prototype.toHsv=function(){return e=ct(this.rgba),{h:p(e.h),s:p(e.s),v:p(e.v),a:p(e.a,3)};var e},t.prototype.invert=function(){return z({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},t.prototype.saturate=function(e){return e===void 0&&(e=.1),z(Y(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),z(Y(this.rgba,-e))},t.prototype.grayscale=function(){return z(Y(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),z(mt(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),z(mt(this.rgba,-e))},t.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},t.prototype.alpha=function(e){return typeof e=="number"?z({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):p(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=G(this.rgba);return typeof e=="number"?z({h:e,s:n.s,l:n.l,a:n.a}):p(n.h)},t.prototype.isEqual=function(e){return this.toHex()===z(e).toHex()},t}(),z=function(t){return t instanceof yt?t:new yt(t)};class be{eventListeners=new Map;addEventListener(e,n,r){const i={value:n,options:r},a=this.eventListeners.get(e);return a?Array.isArray(a)?a.push(i):this.eventListeners.set(e,[a,i]):this.eventListeners.set(e,i),this}removeEventListener(e,n,r){if(!n)return this.eventListeners.delete(e),this;const i=this.eventListeners.get(e);if(!i)return this;if(Array.isArray(i)){const a=[];for(let l=0,c=i.length;l<c;l++){const d=i[l];(d.value!==n||typeof r=="object"&&r?.once&&(typeof d.options=="boolean"||!d.options?.once))&&a.push(d)}a.length?this.eventListeners.set(e,a.length===1?a[0]:a):this.eventListeners.delete(e)}else i.value===n&&(typeof r=="boolean"||!r?.once||typeof i.options=="boolean"||i.options?.once)&&this.eventListeners.delete(e);return this}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(e){return this.eventListeners.has(e)}dispatchEvent(e,...n){const r=this.eventListeners.get(e);if(r){if(Array.isArray(r))for(let i=r.length,a=0;a<i;a++){const l=r[a];typeof l.options=="object"&&l.options?.once&&this.off(e,l.value,l.options),l.value.apply(this,n)}else typeof r.options=="object"&&r.options?.once&&this.off(e,r.value,r.options),r.value.apply(this,n);return!0}else return!1}on(e,n,r){return this.addEventListener(e,n,r)}once(e,n){return this.addEventListener(e,n,{once:!0})}off(e,n,r){return this.removeEventListener(e,n,r)}emit(e,...n){this.dispatchEvent(e,...n)}}function g(t){return t==null||t==="none"}function F(t,e=0,n=10**e){return Math.round(n*t)/n+0}function N(t,e=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return e?t.map(r=>N(r,e)):t;const n={};for(const r in t){const i=t[r];i!=null&&(e?n[r]=N(i,e):n[r]=i)}return n}function M(t,e){const n={};return e.forEach(r=>{r in t&&(n[r]=t[r])}),n}function bt(t,e,n){const r=e.length-1;if(r<0)return t===void 0?n:t;for(let i=0;i<r;i++){if(t==null)return n;t=t[e[i]]}return t==null||t[e[r]]===void 0?n:t[e[r]]}function St(t,e,n){const r=e.length-1;for(let i=0;i<r;i++)typeof t[e[i]]!="object"&&(t[e[i]]={}),t=t[e[i]];t[e[r]]=n}function Ct(t,e,n){return t==null||!e||typeof e!="string"?n:t[e]!==void 0?t[e]:(e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),bt(t,e.split("."),n))}function wt(t,e,n){if(!(typeof t!="object"||!e))return e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),St(t,e.split("."),n)}class Se{_map=new WeakMap;_toRaw(e){if(e&&typeof e=="object"){const n=e.__v_raw;n&&(e=this._toRaw(n))}return e}delete(e){return this._map.delete(this._toRaw(e))}get(e){return this._map.get(this._toRaw(e))}has(e){return this._map.has(this._toRaw(e))}set(e,n){return this._map.set(this._toRaw(e),this._toRaw(n)),this}}function Z(t){let e;return typeof t=="number"?e={r:t>>24&255,g:t>>16&255,b:t>>8&255,a:(t&255)/255}:e=t,z(e)}function Ce(t){return{r:F(t.r),g:F(t.g),b:F(t.b),a:F(t.a,3)}}function $(t){const e=t.toString(16);return e.length<2?`0${e}`:e}const A="#000000FF";function _t(t){return Z(t).isValid()}function b(t,e=!1){const n=Z(t);if(!n.isValid()){if(typeof t=="string")return t;const c=`Failed to normalizeColor ${t}`;if(e)throw new Error(c);return console.warn(c),A}const{r,g:i,b:a,a:l}=Ce(n.rgba);return`#${$(r)}${$(i)}${$(a)}${$(F(l*255))}`}var j=j||{};j.parse=function(){const t={linearGradient:/^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,repeatingLinearGradient:/^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,radialGradient:/^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,repeatingRadialGradient:/^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?((\d*\.\d+)|(\d+\.?)))px/,percentageValue:/^(-?((\d*\.\d+)|(\d+\.?)))%/,emValue:/^(-?((\d*\.\d+)|(\d+\.?)))em/,angleValue:/^(-?((\d*\.\d+)|(\d+\.?)))deg/,radianValue:/^(-?((\d*\.\d+)|(\d+\.?)))rad/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^#([0-9a-f]+)/i,literalColor:/^([a-z]+)/i,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-z0-9-,\s#]+)/i,number:/^((\d*\.\d+)|(\d+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i};let e="";function n(u){const s=new Error(`${e}: ${u}`);throw s.source=e,s}function r(){const u=i();return e.length>0&&n("Invalid input not EOF"),u}function i(){return K(a)}function a(){return l("linear-gradient",t.linearGradient,d)||l("repeating-linear-gradient",t.repeatingLinearGradient,d)||l("radial-gradient",t.radialGradient,w)||l("repeating-radial-gradient",t.repeatingRadialGradient,w)}function l(u,s,f){return c(s,y=>{const R=f();return R&&(v(t.comma)||n("Missing comma before color stops")),{type:u,orientation:R,colorStops:K(Pe)}})}function c(u,s){const f=v(u);if(f){v(t.startCall)||n("Missing (");const y=s(f);return v(t.endCall)||n("Missing )"),y}}function d(){const u=m();if(u)return u;const s=C("position-keyword",t.positionKeywords,1);return s?{type:"directional",value:s.value}:S()}function m(){return C("directional",t.sideOrCorner,1)}function S(){return C("angular",t.angleValue,1)||C("angular",t.radianValue,1)}function w(){let u,s=h(),f;return s&&(u=[],u.push(s),f=e,v(t.comma)&&(s=h(),s?u.push(s):e=f)),u}function h(){let u=O()||Ie();if(u)u.at=ot();else{const s=it();if(s){u=s;const f=ot();f&&(u.at=f)}else{const f=ot();if(f)u={type:"default-radial",at:f};else{const y=at();y&&(u={type:"default-radial",at:y})}}}return u}function O(){const u=C("shape",/^(circle)/i,0);return u&&(u.style=fe()||it()),u}function Ie(){const u=C("shape",/^(ellipse)/i,0);return u&&(u.style=at()||U()||it()),u}function it(){return C("extent-keyword",t.extentKeywords,1)}function ot(){if(C("position",/^at/,0)){const u=at();return u||n("Missing positioning value"),u}}function at(){const u=Ve();if(u.x||u.y)return{type:"position",value:u}}function Ve(){return{x:U(),y:U()}}function K(u){let s=u();const f=[];if(s)for(f.push(s);v(t.comma);)s=u(),s?f.push(s):n("One extra comma");return f}function Pe(){const u=Te();return u||n("Expected color definition"),u.length=U(),u}function Te(){return $e()||xe()||Be()||He()||je()||We()||Me()}function Me(){return C("literal",t.literalColor,0)}function $e(){return C("hex",t.hexColor,1)}function je(){return c(t.rgbColor,()=>({type:"rgb",value:K(P)}))}function He(){return c(t.rgbaColor,()=>({type:"rgba",value:K(P)}))}function We(){return c(t.varColor,()=>({type:"var",value:Ke()}))}function Be(){return c(t.hslColor,()=>{v(t.percentageValue)&&n("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const s=P();v(t.comma);let f=v(t.percentageValue);const y=f?f[1]:null;v(t.comma),f=v(t.percentageValue);const R=f?f[1]:null;return(!y||!R)&&n("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[s,y,R]}})}function xe(){return c(t.hslaColor,()=>{const u=P();v(t.comma);let s=v(t.percentageValue);const f=s?s[1]:null;v(t.comma),s=v(t.percentageValue);const y=s?s[1]:null;v(t.comma);const R=P();return(!f||!y)&&n("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[u,f,y,R]}})}function Ke(){return v(t.variableName)[1]}function P(){return v(t.number)[1]}function U(){return C("%",t.percentageValue,1)||Ue()||Xe()||fe()}function Ue(){return C("position-keyword",t.positionKeywords,1)}function Xe(){return c(t.calcValue,()=>{let u=1,s=0;for(;u>0&&s<e.length;){const y=e.charAt(s);y==="("?u++:y===")"&&u--,s++}u>0&&n("Missing closing parenthesis in calc() expression");const f=e.substring(0,s-1);return ut(s-1),{type:"calc",value:f}})}function fe(){return C("px",t.pixelValue,1)||C("em",t.emValue,1)}function C(u,s,f){const y=v(s);if(y)return{type:u,value:y[f]}}function v(u){let s,f;return f=/^\s+/.exec(e),f&&ut(f[0].length),s=u.exec(e),s&&ut(s[0].length),s}function ut(u){e=e.substr(u)}return function(u){return e=u.toString().trim(),e.endsWith(";")&&(e=e.slice(0,-1)),r()}}();const zt=j.parse.bind(j);var H=H||{};H.stringify=function(){var t={"visit_linear-gradient":function(e){return t.visit_gradient(e)},"visit_repeating-linear-gradient":function(e){return t.visit_gradient(e)},"visit_radial-gradient":function(e){return t.visit_gradient(e)},"visit_repeating-radial-gradient":function(e){return t.visit_gradient(e)},visit_gradient:function(e){var n=t.visit(e.orientation);return n&&(n+=", "),e.type+"("+n+t.visit(e.colorStops)+")"},visit_shape:function(e){var n=e.value,r=t.visit(e.at),i=t.visit(e.style);return i&&(n+=" "+i),r&&(n+=" at "+r),n},"visit_default-radial":function(e){var n="",r=t.visit(e.at);return r&&(n+=r),n},"visit_extent-keyword":function(e){var n=e.value,r=t.visit(e.at);return r&&(n+=" at "+r),n},"visit_position-keyword":function(e){return e.value},visit_position:function(e){return t.visit(e.value.x)+" "+t.visit(e.value.y)},"visit_%":function(e){return e.value+"%"},visit_em:function(e){return e.value+"em"},visit_px:function(e){return e.value+"px"},visit_calc:function(e){return"calc("+e.value+")"},visit_literal:function(e){return t.visit_color(e.value,e)},visit_hex:function(e){return t.visit_color("#"+e.value,e)},visit_rgb:function(e){return t.visit_color("rgb("+e.value.join(", ")+")",e)},visit_rgba:function(e){return t.visit_color("rgba("+e.value.join(", ")+")",e)},visit_hsl:function(e){return t.visit_color("hsl("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%)",e)},visit_hsla:function(e){return t.visit_color("hsla("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%, "+e.value[3]+")",e)},visit_var:function(e){return t.visit_color("var("+e.value+")",e)},visit_color:function(e,n){var r=e,i=t.visit(n.length);return i&&(r+=" "+i),r},visit_angular:function(e){return e.value+"deg"},visit_directional:function(e){return"to "+e.value},visit_array:function(e){var n="",r=e.length;return e.forEach(function(i,a){n+=t.visit(i),a<r-1&&(n+=", ")}),n},visit_object:function(e){return e.width&&e.height?t.visit(e.width)+" "+t.visit(e.height):""},visit:function(e){if(!e)return"";if(e instanceof Array)return t.visit_array(e);if(typeof e=="object"&&!e.type)return t.visit_object(e);if(e.type){var n=t["visit_"+e.type];if(n)return n(e);throw Error("Missing visitor visit_"+e.type)}else throw Error("Invalid node.")}};return function(e){return t.visit(e)}}();const we=H.stringify.bind(H);function Lt(t){const e=t.length-1;return t.map((n,r)=>{const i=n.value;let a=F(r/e,3),l="#00000000";switch(n.type){case"rgb":l=b({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":l=b({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":l=b(n.value);break;case"hex":l=b(`#${n.value}`);break}switch(n.length?.type){case"%":a=Number(n.length.value)/100;break}return{offset:a,color:l}})}function Et(t){let e=0;switch(t.orientation?.type){case"angular":e=Number(t.orientation.value);break}return{type:"linear-gradient",angle:e,stops:Lt(t.colorStops)}}function Ft(t){return t.orientation?.map(e=>{switch(e?.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:Lt(t.colorStops)}}function I(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function Nt(t){return zt(t).map(e=>{switch(e?.type){case"linear-gradient":return Et(e);case"repeating-linear-gradient":return{...Et(e),repeat:!0};case"radial-gradient":return Ft(e);case"repeating-radial-gradient":return{...Ft(e),repeat:!0};default:return}}).filter(Boolean)}function Ot(t){let e;return typeof t=="string"?e={color:t}:e=t,{color:b(e.color)}}function Rt(t){let e;if(typeof t=="string"?e={image:t}:e=t,e.image){const{type:n,...r}=Nt(e.image)[0]??{};switch(n){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return e}function Dt(t){let e;return typeof t=="string"?e={image:t}:e=t,e}function kt(t){let e;return typeof t=="string"?e={preset:t}:e=t,{preset:e.preset,foregroundColor:g(e.foregroundColor)?void 0:b(e.foregroundColor),backgroundColor:g(e.backgroundColor)?void 0:b(e.backgroundColor)}}function Gt(t){return!g(t.color)}function At(t){return typeof t=="string"?_t(t):Gt(t)}function It(t){return!g(t.image)&&I(t.image)||!!t.linearGradient||!!t.radialGradient}function Vt(t){return typeof t=="string"?I(t):It(t)}function Pt(t){return!g(t.image)&&!I(t.image)}function Tt(t){return typeof t=="string"?!I(t):Pt(t)}function Mt(t){return!g(t.preset)}function $t(t){return typeof t=="string"?!1:Mt(t)}function E(t){return At(t)?Ot(t):Vt(t)?Rt(t):Tt(t)?Dt(t):$t(t)?kt(t):{}}function jt(t){return typeof t=="string"?{...E(t)}:{...E(t),...M(t,["fillWithShape"])}}const J=Symbol("properties");function W(t){let e;if(Object.hasOwn(t,J))e=t[J];else{const n=Object.getPrototypeOf(t);e=new Map(n?W(n):void 0),t[J]=e}return e}function Q(t,e={}){const n=Symbol.for(t),{default:r,fallback:i,alias:a}=e,l={declaration:e,internalKey:n},c=()=>typeof r=="function"?r():r,d=()=>typeof i=="function"?i():i;let m=!0;function S(){let h;if(a&&a!==t?h=Ct(this,a):typeof this.getter<"u"?h=this.getter(t,l):h=this[n],h=h??d(),h===void 0&&m){m=!1;const O=c();O!==void 0&&(w.call(this,O),h=O)}return h}function w(h){a&&a!==t?wt(this,a,h):typeof this.setter<"u"?this.setter(t,h,l):this[n]=h}return{get:S,set:w}}function Ht(t,e,n={}){W(t).set(e,n);const r=Q(e,n);Object.defineProperty(t.prototype,e,{get(){return r.get.call(this)},set(i){const a=r.get.call(this);r.set.call(this,i),this.onUpdateProperty?.(e,i,a,n)},configurable:!0,enumerable:!0})}function _e(t){return function(e,n){if(typeof n!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");Ht(e.constructor,n,t)}}function ze(t={}){return function(e,n){const r=n.name;if(typeof r!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");const i=Q(r,t);return{init(a){return W(this.constructor).set(r,t),i.set.call(this,a),a},get(){return i.get.call(this)},set(a){const l=i.get?.call(this);i.set.call(this,a),this.onUpdateProperty?.(r,a,l,t)}}}}function tt(){return{color:A,offsetX:0,offsetY:0,blurRadius:1}}function et(t){return{...tt(),...N({...t,color:g(t.color)?A:b(t.color)})}}function Wt(){return{...tt(),scaleX:1,scaleY:1}}function Bt(t){return{...Wt(),...et(t)}}function Le(t){return t}function xt(t){return N({...t,softEdge:g(t.softEdge)?void 0:t.softEdge,outerShadow:g(t.outerShadow)?void 0:Bt(t.outerShadow),innerShadow:g(t.innerShadow)?void 0:et(t.innerShadow)})}function Kt(t){return typeof t=="string"?{...E(t)}:{...E(t),...M(t,["fillWithShape"])}}const Ee="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Fe=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=Ee[n[t]&63];return e};const Ut=()=>Fe(10),Xt=Ut;function Yt(t){return typeof t=="string"?{...E(t)}:{...E(t),...M(t,["width","style","headEnd","tailEnd"])}}function qt(t){return typeof t=="string"?{color:b(t)}:{...t,color:g(t.color)?A:b(t.color)}}function Zt(){return{boxShadow:"none"}}function Jt(t){return typeof t=="string"?t.startsWith("<svg")?{svg:t}:{paths:[{data:t}]}:Array.isArray(t)?{paths:t.map(e=>typeof e=="string"?{data:e}:e)}:t}function Qt(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function te(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function ee(){return{...Qt(),...te(),...Zt(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function ne(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function re(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function ie(){return{...ne(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function oe(){return{...re(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function ae(){return{...oe(),...ie(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function k(t){return N({...t,color:g(t.color)?void 0:b(t.color),backgroundColor:g(t.backgroundColor)?void 0:b(t.backgroundColor),borderColor:g(t.borderColor)?void 0:b(t.borderColor),outlineColor:g(t.outlineColor)?void 0:b(t.outlineColor),shadowColor:g(t.shadowColor)?void 0:b(t.shadowColor)})}function Ne(){return{...ee(),...ae()}}const nt=/\r\n|\n\r|\n|\r/,Oe=new RegExp(`${nt.source}|<br\\/>`,"g"),Re=new RegExp(`^(${nt.source})$`),B=`
|
|
2
|
-
`;function
|
|
1
|
+
(function(o,G){typeof exports=="object"&&typeof module<"u"?G(exports):typeof define=="function"&&define.amd?define(["exports"],G):(o=typeof globalThis<"u"?globalThis:o||self,G(o.modernIdoc={}))})(this,function(o){"use strict";function G(t){return typeof t=="string"?{src:t}:t}var me={grad:.9,turn:360,rad:360/(2*Math.PI)},N=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},b=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},F=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},ht=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},vt=function(t){return{r:F(t.r,0,255),g:F(t.g,0,255),b:F(t.b,0,255),a:F(t.a)}},et=function(t){return{r:b(t.r),g:b(t.g),b:b(t.b),a:b(t.a,3)}},ye=/^#([0-9a-f]{3,8})$/i,B=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},pt=function(t){var e=t.r,n=t.g,r=t.b,i=t.a,a=Math.max(e,n,r),u=a-Math.min(e,n,r),s=u?a===e?(n-r)/u:a===n?2+(r-e)/u:4+(e-n)/u:0;return{h:60*(s<0?s+6:s),s:a?u/a*100:0,v:a/255*100,a:i}},mt=function(t){var e=t.h,n=t.s,r=t.v,i=t.a;e=e/360*6,n/=100,r/=100;var a=Math.floor(e),u=r*(1-n),s=r*(1-(e-a)*n),d=r*(1-(1-e+a)*n),v=a%6;return{r:255*[r,s,u,u,d,r][v],g:255*[d,r,r,s,u,u][v],b:255*[u,u,d,r,r,s][v],a:i}},yt=function(t){return{h:ht(t.h),s:F(t.s,0,100),l:F(t.l,0,100),a:F(t.a)}},bt=function(t){return{h:b(t.h),s:b(t.s),l:b(t.l),a:b(t.a,3)}},St=function(t){return mt((n=(e=t).s,{h:e.h,s:(n*=((r=e.l)<50?r:100-r)/100)>0?2*n/(r+n)*100:0,v:r+n,a:e.a}));var e,n,r},j=function(t){return{h:(e=pt(t)).h,s:(i=(200-(n=e.s))*(r=e.v)/100)>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,n,r,i},be=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Se=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ce=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,we=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ct={string:[[function(t){var e=ye.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?b(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?b(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=Ce.exec(t)||we.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:vt({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=be.exec(t)||Se.exec(t);if(!e)return null;var n,r,i=yt({h:(n=e[1],r=e[2],r===void 0&&(r="deg"),Number(n)*(me[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return St(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,r=t.b,i=t.a,a=i===void 0?1:i;return N(e)&&N(n)&&N(r)?vt({r:Number(e),g:Number(n),b:Number(r),a:Number(a)}):null},"rgb"],[function(t){var e=t.h,n=t.s,r=t.l,i=t.a,a=i===void 0?1:i;if(!N(e)||!N(n)||!N(r))return null;var u=yt({h:Number(e),s:Number(n),l:Number(r),a:Number(a)});return St(u)},"hsl"],[function(t){var e=t.h,n=t.s,r=t.v,i=t.a,a=i===void 0?1:i;if(!N(e)||!N(n)||!N(r))return null;var u=function(s){return{h:ht(s.h),s:F(s.s,0,100),v:F(s.v,0,100),a:F(s.a)}}({h:Number(e),s:Number(n),v:Number(r),a:Number(a)});return mt(u)},"hsv"]]},wt=function(t,e){for(var n=0;n<e.length;n++){var r=e[n][0](t);if(r)return[r,e[n][1]]}return[null,void 0]},_e=function(t){return typeof t=="string"?wt(t.trim(),Ct.string):typeof t=="object"&&t!==null?wt(t,Ct.object):[null,void 0]},nt=function(t,e){var n=j(t);return{h:n.h,s:F(n.s+100*e,0,100),l:n.l,a:n.a}},rt=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},_t=function(t,e){var n=j(t);return{h:n.h,s:n.s,l:F(n.l+100*e,0,100),a:n.a}},zt=function(){function t(e){this.parsed=_e(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return b(rt(this.rgba),2)},t.prototype.isDark=function(){return rt(this.rgba)<.5},t.prototype.isLight=function(){return rt(this.rgba)>=.5},t.prototype.toHex=function(){return e=et(this.rgba),n=e.r,r=e.g,i=e.b,u=(a=e.a)<1?B(b(255*a)):"","#"+B(n)+B(r)+B(i)+u;var e,n,r,i,a,u},t.prototype.toRgb=function(){return et(this.rgba)},t.prototype.toRgbString=function(){return e=et(this.rgba),n=e.r,r=e.g,i=e.b,(a=e.a)<1?"rgba("+n+", "+r+", "+i+", "+a+")":"rgb("+n+", "+r+", "+i+")";var e,n,r,i,a},t.prototype.toHsl=function(){return bt(j(this.rgba))},t.prototype.toHslString=function(){return e=bt(j(this.rgba)),n=e.h,r=e.s,i=e.l,(a=e.a)<1?"hsla("+n+", "+r+"%, "+i+"%, "+a+")":"hsl("+n+", "+r+"%, "+i+"%)";var e,n,r,i,a},t.prototype.toHsv=function(){return e=pt(this.rgba),{h:b(e.h),s:b(e.s),v:b(e.v),a:b(e.a,3)};var e},t.prototype.invert=function(){return D({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},t.prototype.saturate=function(e){return e===void 0&&(e=.1),D(nt(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),D(nt(this.rgba,-e))},t.prototype.grayscale=function(){return D(nt(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),D(_t(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),D(_t(this.rgba,-e))},t.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},t.prototype.alpha=function(e){return typeof e=="number"?D({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):b(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=j(this.rgba);return typeof e=="number"?D({h:e,s:n.s,l:n.l,a:n.a}):b(n.h)},t.prototype.isEqual=function(e){return this.toHex()===D(e).toHex()},t}(),D=function(t){return t instanceof zt?t:new zt(t)};class ze{eventListeners=new Map;addEventListener(e,n,r){const i={value:n,options:r},a=this.eventListeners.get(e);return a?Array.isArray(a)?a.push(i):this.eventListeners.set(e,[a,i]):this.eventListeners.set(e,i),this}removeEventListener(e,n,r){if(!n)return this.eventListeners.delete(e),this;const i=this.eventListeners.get(e);if(!i)return this;if(Array.isArray(i)){const a=[];for(let u=0,s=i.length;u<s;u++){const d=i[u];(d.value!==n||typeof r=="object"&&r?.once&&(typeof d.options=="boolean"||!d.options?.once))&&a.push(d)}a.length?this.eventListeners.set(e,a.length===1?a[0]:a):this.eventListeners.delete(e)}else i.value===n&&(typeof r=="boolean"||!r?.once||typeof i.options=="boolean"||i.options?.once)&&this.eventListeners.delete(e);return this}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(e){return this.eventListeners.has(e)}dispatchEvent(e,...n){const r=this.eventListeners.get(e);if(r){if(Array.isArray(r))for(let i=r.length,a=0;a<i;a++){const u=r[a];typeof u.options=="object"&&u.options?.once&&this.off(e,u.value,u.options),u.value.apply(this,n)}else typeof r.options=="object"&&r.options?.once&&this.off(e,r.value,r.options),r.value.apply(this,n);return!0}else return!1}on(e,n,r){return this.addEventListener(e,n,r)}once(e,n){return this.addEventListener(e,n,{once:!0})}off(e,n,r){return this.removeEventListener(e,n,r)}emit(e,...n){this.dispatchEvent(e,...n)}}function h(t){return t==null||t==="none"}function R(t,e=0,n=10**e){return Math.round(n*t)/n+0}function w(t,e=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return e?t.map(r=>w(r,e)):t;const n={};for(const r in t){const i=t[r];i!=null&&(e?n[r]=w(i,e):n[r]=i)}return n}function K(t,e){const n={};return e.forEach(r=>{r in t&&(n[r]=t[r])}),n}function x(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){const n=Array.from(new Set([...Object.keys(t),...Object.keys(e)]));return!n.length||n.every(r=>t[r]===e[r])}return!1}function Ft(t,e,n){const r=e.length-1;if(r<0)return t===void 0?n:t;for(let i=0;i<r;i++){if(t==null)return n;t=t[e[i]]}return t==null||t[e[r]]===void 0?n:t[e[r]]}function Et(t,e,n){const r=e.length-1;for(let i=0;i<r;i++)typeof t[e[i]]!="object"&&(t[e[i]]={}),t=t[e[i]];t[e[r]]=n}function Lt(t,e,n){return t==null||!e||typeof e!="string"?n:t[e]!==void 0?t[e]:(e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),Ft(t,e.split("."),n))}function Ot(t,e,n){if(!(typeof t!="object"||!e))return e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),Et(t,e.split("."),n)}class Fe{_map=new WeakMap;_toRaw(e){if(e&&typeof e=="object"){const n=e.__v_raw;n&&(e=this._toRaw(n))}return e}delete(e){return this._map.delete(this._toRaw(e))}get(e){return this._map.get(this._toRaw(e))}has(e){return this._map.has(this._toRaw(e))}set(e,n){return this._map.set(this._toRaw(e),this._toRaw(n)),this}}function it(t){let e;return typeof t=="number"?e={r:t>>24&255,g:t>>16&255,b:t>>8&255,a:(t&255)/255}:e=t,D(e)}function Ee(t){return{r:R(t.r),g:R(t.g),b:R(t.b),a:R(t.a,3)}}function U(t){const e=t.toString(16);return e.length<2?`0${e}`:e}const T="#000000FF";function Dt(t){return it(t).isValid()}function C(t,e=!1){const n=it(t);if(!n.isValid()){if(typeof t=="string")return t;const s=`Failed to normalizeColor ${t}`;if(e)throw new Error(s);return console.warn(s),T}const{r,g:i,b:a,a:u}=Ee(n.rgba);return`#${U(r)}${U(i)}${U(a)}${U(R(u*255))}`}var X=X||{};X.parse=function(){const t={linearGradient:/^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,repeatingLinearGradient:/^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,radialGradient:/^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,repeatingRadialGradient:/^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?((\d*\.\d+)|(\d+\.?)))px/,percentageValue:/^(-?((\d*\.\d+)|(\d+\.?)))%/,emValue:/^(-?((\d*\.\d+)|(\d+\.?)))em/,angleValue:/^(-?((\d*\.\d+)|(\d+\.?)))deg/,radianValue:/^(-?((\d*\.\d+)|(\d+\.?)))rad/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^#([0-9a-f]+)/i,literalColor:/^([a-z]+)/i,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-z0-9-,\s#]+)/i,number:/^((\d*\.\d+)|(\d+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i};let e="";function n(l){const c=new Error(`${e}: ${l}`);throw c.source=e,c}function r(){const l=i();return e.length>0&&n("Invalid input not EOF"),l}function i(){return V(a)}function a(){return u("linear-gradient",t.linearGradient,d)||u("repeating-linear-gradient",t.repeatingLinearGradient,d)||u("radial-gradient",t.radialGradient,m)||u("repeating-radial-gradient",t.repeatingRadialGradient,m)}function u(l,c,f){return s(c,S=>{const A=f();return A&&(y(t.comma)||n("Missing comma before color stops")),{type:l,orientation:A,colorStops:V(dt)}})}function s(l,c){const f=y(l);if(f){y(t.startCall)||n("Missing (");const S=c(f);return y(t.endCall)||n("Missing )"),S}}function d(){const l=v();if(l)return l;const c=z("position-keyword",t.positionKeywords,1);return c?{type:"directional",value:c.value}:p()}function v(){return z("directional",t.sideOrCorner,1)}function p(){return z("angular",t.angleValue,1)||z("angular",t.radianValue,1)}function m(){let l,c=g(),f;return c&&(l=[],l.push(c),f=e,y(t.comma)&&(c=g(),c?l.push(c):e=f)),l}function g(){let l=_()||k();if(l)l.at=O();else{const c=E();if(c){l=c;const f=O();f&&(l.at=f)}else{const f=O();if(f)l={type:"default-radial",at:f};else{const S=I();S&&(l={type:"default-radial",at:S})}}}return l}function _(){const l=z("shape",/^(circle)/i,0);return l&&(l.style=pe()||E()),l}function k(){const l=z("shape",/^(ellipse)/i,0);return l&&(l.style=I()||tt()||E()),l}function E(){return z("extent-keyword",t.extentKeywords,1)}function O(){if(z("position",/^at/,0)){const l=I();return l||n("Missing positioning value"),l}}function I(){const l=H();if(l.x||l.y)return{type:"position",value:l}}function H(){return{x:tt(),y:tt()}}function V(l){let c=l();const f=[];if(c)for(f.push(c);y(t.comma);)c=l(),c?f.push(c):n("One extra comma");return f}function dt(){const l=$e();return l||n("Expected color definition"),l.length=tt(),l}function $e(){return We()||Xe()||Ue()||Ke()||Be()||xe()||He()}function He(){return z("literal",t.literalColor,0)}function We(){return z("hex",t.hexColor,1)}function Be(){return s(t.rgbColor,()=>({type:"rgb",value:V(W)}))}function Ke(){return s(t.rgbaColor,()=>({type:"rgba",value:V(W)}))}function xe(){return s(t.varColor,()=>({type:"var",value:Ye()}))}function Ue(){return s(t.hslColor,()=>{y(t.percentageValue)&&n("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const c=W();y(t.comma);let f=y(t.percentageValue);const S=f?f[1]:null;y(t.comma),f=y(t.percentageValue);const A=f?f[1]:null;return(!S||!A)&&n("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[c,S,A]}})}function Xe(){return s(t.hslaColor,()=>{const l=W();y(t.comma);let c=y(t.percentageValue);const f=c?c[1]:null;y(t.comma),c=y(t.percentageValue);const S=c?c[1]:null;y(t.comma);const A=W();return(!f||!S)&&n("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[l,f,S,A]}})}function Ye(){return y(t.variableName)[1]}function W(){return y(t.number)[1]}function tt(){return z("%",t.percentageValue,1)||qe()||Ze()||pe()}function qe(){return z("position-keyword",t.positionKeywords,1)}function Ze(){return s(t.calcValue,()=>{let l=1,c=0;for(;l>0&&c<e.length;){const S=e.charAt(c);S==="("?l++:S===")"&&l--,c++}l>0&&n("Missing closing parenthesis in calc() expression");const f=e.substring(0,c-1);return gt(c-1),{type:"calc",value:f}})}function pe(){return z("px",t.pixelValue,1)||z("em",t.emValue,1)}function z(l,c,f){const S=y(c);if(S)return{type:l,value:S[f]}}function y(l){let c,f;return f=/^\s+/.exec(e),f&>(f[0].length),c=l.exec(e),c&>(c[0].length),c}function gt(l){e=e.substr(l)}return function(l){return e=l.toString().trim(),e.endsWith(";")&&(e=e.slice(0,-1)),r()}}();const Nt=X.parse.bind(X);var Y=Y||{};Y.stringify=function(){var t={"visit_linear-gradient":function(e){return t.visit_gradient(e)},"visit_repeating-linear-gradient":function(e){return t.visit_gradient(e)},"visit_radial-gradient":function(e){return t.visit_gradient(e)},"visit_repeating-radial-gradient":function(e){return t.visit_gradient(e)},visit_gradient:function(e){var n=t.visit(e.orientation);return n&&(n+=", "),e.type+"("+n+t.visit(e.colorStops)+")"},visit_shape:function(e){var n=e.value,r=t.visit(e.at),i=t.visit(e.style);return i&&(n+=" "+i),r&&(n+=" at "+r),n},"visit_default-radial":function(e){var n="",r=t.visit(e.at);return r&&(n+=r),n},"visit_extent-keyword":function(e){var n=e.value,r=t.visit(e.at);return r&&(n+=" at "+r),n},"visit_position-keyword":function(e){return e.value},visit_position:function(e){return t.visit(e.value.x)+" "+t.visit(e.value.y)},"visit_%":function(e){return e.value+"%"},visit_em:function(e){return e.value+"em"},visit_px:function(e){return e.value+"px"},visit_calc:function(e){return"calc("+e.value+")"},visit_literal:function(e){return t.visit_color(e.value,e)},visit_hex:function(e){return t.visit_color("#"+e.value,e)},visit_rgb:function(e){return t.visit_color("rgb("+e.value.join(", ")+")",e)},visit_rgba:function(e){return t.visit_color("rgba("+e.value.join(", ")+")",e)},visit_hsl:function(e){return t.visit_color("hsl("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%)",e)},visit_hsla:function(e){return t.visit_color("hsla("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%, "+e.value[3]+")",e)},visit_var:function(e){return t.visit_color("var("+e.value+")",e)},visit_color:function(e,n){var r=e,i=t.visit(n.length);return i&&(r+=" "+i),r},visit_angular:function(e){return e.value+"deg"},visit_directional:function(e){return"to "+e.value},visit_array:function(e){var n="",r=e.length;return e.forEach(function(i,a){n+=t.visit(i),a<r-1&&(n+=", ")}),n},visit_object:function(e){return e.width&&e.height?t.visit(e.width)+" "+t.visit(e.height):""},visit:function(e){if(!e)return"";if(e instanceof Array)return t.visit_array(e);if(typeof e=="object"&&!e.type)return t.visit_object(e);if(e.type){var n=t["visit_"+e.type];if(n)return n(e);throw Error("Missing visitor visit_"+e.type)}else throw Error("Invalid node.")}};return function(e){return t.visit(e)}}();const Le=Y.stringify.bind(Y);function Rt(t){const e=t.length-1;return t.map((n,r)=>{const i=n.value;let a=R(r/e,3),u="#00000000";switch(n.type){case"rgb":u=C({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":u=C({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":u=C(n.value);break;case"hex":u=C(`#${n.value}`);break}switch(n.length?.type){case"%":a=Number(n.length.value)/100;break}return{offset:a,color:u}})}function kt(t){let e=0;switch(t.orientation?.type){case"angular":e=Number(t.orientation.value);break}return{type:"linear-gradient",angle:e,stops:Rt(t.colorStops)}}function It(t){return t.orientation?.map(e=>{switch(e?.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:Rt(t.colorStops)}}function M(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function At(t){return Nt(t).map(e=>{switch(e?.type){case"linear-gradient":return kt(e);case"repeating-linear-gradient":return{...kt(e),repeat:!0};case"radial-gradient":return It(e);case"repeating-radial-gradient":return{...It(e),repeat:!0};default:return}}).filter(Boolean)}function Gt(t){let e;return typeof t=="string"?e={color:t}:e=t,{color:C(e.color)}}function Pt(t){let e;if(typeof t=="string"?e={image:t}:e=t,e.image){const{type:n,...r}=At(e.image)[0]??{};switch(n){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return e}function Vt(t){let e;return typeof t=="string"?e={image:t}:e=t,e}function jt(t){let e;return typeof t=="string"?e={preset:t}:e=t,{preset:e.preset,foregroundColor:h(e.foregroundColor)?void 0:C(e.foregroundColor),backgroundColor:h(e.backgroundColor)?void 0:C(e.backgroundColor)}}function Tt(t){return!h(t.color)}function Mt(t){return typeof t=="string"?Dt(t):Tt(t)}function $t(t){return!h(t.image)&&M(t.image)||!!t.linearGradient||!!t.radialGradient}function Ht(t){return typeof t=="string"?M(t):$t(t)}function Wt(t){return!h(t.image)&&!M(t.image)}function Bt(t){return typeof t=="string"?!M(t):Wt(t)}function Kt(t){return!h(t.preset)}function xt(t){return typeof t=="string"?!1:Kt(t)}function L(t){const e=t&&typeof t=="object"?t.enabled:void 0;return Mt(t)?w({enabled:e,...Gt(t)}):Ht(t)?w({enabled:e,...Pt(t)}):Bt(t)?w({enabled:e,...Vt(t)}):xt(t)?w({enabled:e,...jt(t)}):{}}function Ut(t){return typeof t=="string"?{...L(t)}:{...L(t),...K(t,["fillWithShape"])}}const ot=Symbol("properties");function q(t){let e;if(Object.hasOwn(t,ot))e=t[ot];else{const n=Object.getPrototypeOf(t);e=new Map(n?q(n):void 0),t[ot]=e}return e}function at(t,e={}){const n=Symbol.for(t),{default:r,fallback:i,alias:a}=e,u={declaration:e,internalKey:n},s=()=>typeof r=="function"?r():r,d=()=>typeof i=="function"?i():i;let v=!0;function p(){let g;if(a&&a!==t?g=Lt(this,a):typeof this.getter<"u"?g=this.getter(t,u):g=this[n],g=g??d(),g===void 0&&v){v=!1;const _=s();_!==void 0&&(m.call(this,_),g=_)}return g}function m(g){a&&a!==t?Ot(this,a,g):typeof this.setter<"u"?this.setter(t,g,u):this[n]=g}return{get:p,set:m}}function Xt(t,e,n={}){q(t).set(e,n);const r=at(e,n);Object.defineProperty(t.prototype,e,{get(){return r.get.call(this)},set(i){const a=r.get.call(this);r.set.call(this,i),this.onUpdateProperty?.(e,i,a,n)},configurable:!0,enumerable:!0})}function Oe(t){return function(e,n){if(typeof n!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");Xt(e.constructor,n,t)}}function De(t={}){return function(e,n){const r=n.name;if(typeof r!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");const i=at(r,t);return{init(a){return q(this.constructor).set(r,t),i.set.call(this,a),a},get(){return i.get.call(this)},set(a){const u=i.get?.call(this);i.set.call(this,a),this.onUpdateProperty?.(r,a,u,t)}}}}function lt(){return{color:T,offsetX:0,offsetY:0,blurRadius:1}}function ut(t){return{...lt(),...w({...t,color:h(t.color)?T:C(t.color)})}}function Yt(){return{...lt(),scaleX:1,scaleY:1}}function qt(t){return{...Yt(),...ut(t)}}function Ne(t){return t}function Zt(t){return w({...t,softEdge:h(t.softEdge)?void 0:t.softEdge,outerShadow:h(t.outerShadow)?void 0:qt(t.outerShadow),innerShadow:h(t.innerShadow)?void 0:ut(t.innerShadow)})}function Jt(t){return typeof t=="string"?{...L(t)}:{...L(t),...K(t,["fillWithShape"])}}const Re="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ke=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=Re[n[t]&63];return e};const Qt=()=>ke(10),te=Qt;function $(t){return typeof t=="string"?{...L(t)}:{...L(t),...K(t,["width","style","headEnd","tailEnd"])}}function ee(t){return typeof t=="string"?{color:C(t)}:{...t,color:h(t.color)?T:C(t.color)}}function ne(){return{boxShadow:"none"}}function re(t){return typeof t=="string"?t.startsWith("<svg")?{svg:t}:{paths:[{data:t}]}:Array.isArray(t)?{paths:t.map(e=>typeof e=="string"?{data:e}:e)}:t}function ie(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function oe(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function ae(){return{...ie(),...oe(),...ne(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function le(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function ue(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function se(){return{...le(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function ce(){return{...ue(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function fe(){return{...ce(),...se(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function P(t){return w({...t,color:h(t.color)?void 0:C(t.color),backgroundColor:h(t.backgroundColor)?void 0:C(t.backgroundColor),borderColor:h(t.borderColor)?void 0:C(t.borderColor),outlineColor:h(t.outlineColor)?void 0:C(t.outlineColor),shadowColor:h(t.shadowColor)?void 0:C(t.shadowColor)})}function Ie(){return{...ae(),...fe()}}const st=/\r\n|\n\r|\n|\r/,Ae=new RegExp(`${st.source}|<br\\/>`,"g"),Ge=new RegExp(`^(${st.source})$`),Z=`
|
|
2
|
+
`;function Pe(t){return st.test(t)}function ct(t){return Ge.test(t)}function de(t){return t.replace(Ae,Z)}function J(t){const e=[];function n(){return e[e.length-1]}function r(s,d,v){const p=s?P(s):{},m=d?L(d):void 0,g=v?$(v):void 0,_=w({...p,fill:m,outline:g,fragments:[]});return e[e.length-1]?.fragments.length===0?e[e.length-1]=_:e.push(_),_}function i(s="",d,v,p){const m=d?P(d):{},g=v?L(v):void 0,_=p?$(p):void 0;Array.from(s).forEach(k=>{if(ct(k)){const{fragments:E,fill:O,outline:I,...H}=n()||r();E.length||E.push(w({...m,fill:g,outline:_,content:Z})),r(H,O,I)}else{const E=n()||r(),O=E.fragments[E.fragments.length-1];if(O){const{content:I,fill:H,outline:V,...dt}=O;if(x(g,H)&&x(_,V)&&x(m,dt)){O.content=`${I}${k}`;return}}E.fragments.push(w({...m,fill:g,outline:_,content:k}))}})}(Array.isArray(t)?t:[t]).forEach(s=>{if(typeof s=="string")r(),i(s);else if(ft(s)){const{content:d,fill:v,outline:p,...m}=s;r(m,v,p),i(d)}else if(ge(s)){const{fragments:d,fill:v,outline:p,...m}=s;r(m,v,p),d.forEach(g=>{const{content:_,fill:k,outline:E,...O}=g;i(_,O,k,E)})}else Array.isArray(s)?(r(),s.forEach(d=>{if(typeof d=="string")i(d);else if(ft(d)){const{content:v,fill:p,outline:m,...g}=d;i(v,g,p,m)}})):console.warn("Failed to parse text content",s)});const u=n();return u&&!u.fragments.length&&u.fragments.push({content:Z}),e}function ge(t){return t&&typeof t=="object"&&"fragments"in t&&Array.isArray(t.fragments)}function ft(t){return t&&typeof t=="object"&&"content"in t&&typeof t.content=="string"}function he(t){return typeof t=="string"||Array.isArray(t)?{content:J(t)}:w({...t,content:J(t.content??""),style:t.style?P(t.style):void 0,effects:t.effects?t.effects.map(e=>P(e)):void 0,measureDom:t.measureDom,fonts:t.fonts,fill:t.fill?L(t.fill):void 0,outline:t.outline?$(t.outline):void 0})}function Ve(t){return J(t).map(e=>{const n=de(e.fragments.flatMap(r=>r.content).join(""));return ct(n)?"":n}).join(Z)}function ve(t){return typeof t=="string"?{src:t}:t}function Q(t){return w({...t,id:t.id??te(),style:h(t.style)?void 0:P(t.style),text:h(t.text)?void 0:he(t.text),background:h(t.background)?void 0:Ut(t.background),shape:h(t.shape)?void 0:re(t.shape),fill:h(t.fill)?void 0:L(t.fill),outline:h(t.outline)?void 0:$(t.outline),foreground:h(t.foreground)?void 0:Jt(t.foreground),shadow:h(t.shadow)?void 0:ee(t.shadow),video:h(t.video)?void 0:ve(t.video),audio:h(t.audio)?void 0:G(t.audio),effect:h(t.effect)?void 0:Zt(t.effect),children:t.children?.map(e=>Q(e))})}function je(t){return Q(t)}function Te(t){const e={};for(const n in t.children){const r=Q(t.children[n]);delete r.children,e[n]=r}return{...t,children:e}}function Me(t){const{children:e,...n}=t;function r(s){const{parentId:d,childrenIds:v,...p}=s;return{...p,children:[]}}const i={},a=[],u={...n,children:a};for(const s in e){if(i[s])continue;const d=e[s],v=r(d);i[s]=v;const p=d.parentId;if(p){const m=e[p];let g=i[p];g||e[p]&&(g=r(e[p]),i[p]=g),m?.childrenIds&&g?.children&&g.children.splice(m.childrenIds.indexOf(s),0,v)}else a.push(v)}return u}o.EventEmitter=ze,o.RawWeakMap=Fe,o.clearUndef=w,o.defaultColor=T,o.defineProperty=Xt,o.flatDocumentToDocument=Me,o.getDeclarations=q,o.getDefaultElementStyle=ae,o.getDefaultHighlightStyle=le,o.getDefaultInnerShadow=lt,o.getDefaultLayoutStyle=ie,o.getDefaultListStyleStyle=ue,o.getDefaultOuterShadow=Yt,o.getDefaultShadowStyle=ne,o.getDefaultStyle=Ie,o.getDefaultTextInlineStyle=se,o.getDefaultTextLineStyle=ce,o.getDefaultTextStyle=fe,o.getDefaultTransformStyle=oe,o.getNestedValue=Ft,o.getObjectValueByPath=Lt,o.getPropertyDescriptor=at,o.hasCRLF=Pe,o.idGenerator=te,o.isCRLF=ct,o.isColor=Dt,o.isColorFill=Mt,o.isColorFillObject=Tt,o.isEqualObject=x,o.isFragmentObject=ft,o.isGradient=M,o.isGradientFill=Ht,o.isGradientFillObject=$t,o.isImageFill=Bt,o.isImageFillObject=Wt,o.isNone=h,o.isParagraphObject=ge,o.isPresetFill=xt,o.isPresetFillObject=Kt,o.nanoid=Qt,o.normalizeAudio=G,o.normalizeBackground=Ut,o.normalizeCRLF=de,o.normalizeColor=C,o.normalizeColorFill=Gt,o.normalizeDocument=je,o.normalizeEffect=Zt,o.normalizeElement=Q,o.normalizeFill=L,o.normalizeFlatDocument=Te,o.normalizeForeground=Jt,o.normalizeGradient=At,o.normalizeGradientFill=Pt,o.normalizeImageFill=Vt,o.normalizeInnerShadow=ut,o.normalizeOuterShadow=qt,o.normalizeOutline=$,o.normalizePresetFill=jt,o.normalizeShadow=ee,o.normalizeShape=re,o.normalizeSoftEdge=Ne,o.normalizeStyle=P,o.normalizeText=he,o.normalizeTextContent=J,o.normalizeVideo=ve,o.parseColor=it,o.parseGradient=Nt,o.pick=K,o.property=Oe,o.property2=De,o.round=R,o.setNestedValue=Et,o.setObjectValueByPath=Ot,o.stringifyGradient=Le,o.textContentToString=Ve,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED
|
@@ -136,6 +136,15 @@ function pick(obj, keys) {
|
|
|
136
136
|
return result;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
function isEqualObject(a, b) {
|
|
140
|
+
if (a === b)
|
|
141
|
+
return true;
|
|
142
|
+
if (a && b && typeof a === "object" && typeof b === "object") {
|
|
143
|
+
const keys = Array.from(/* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]));
|
|
144
|
+
return !keys.length || keys.every((key) => a[key] === b[key]);
|
|
145
|
+
}
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
139
148
|
function getNestedValue(obj, path, fallback) {
|
|
140
149
|
const last = path.length - 1;
|
|
141
150
|
if (last < 0)
|
|
@@ -950,14 +959,15 @@ function isPresetFill(fill) {
|
|
|
950
959
|
return typeof fill === "string" ? false : isPresetFillObject(fill);
|
|
951
960
|
}
|
|
952
961
|
function normalizeFill(fill) {
|
|
962
|
+
const enabled = fill && typeof fill === "object" ? fill.enabled : void 0;
|
|
953
963
|
if (isColorFill(fill)) {
|
|
954
|
-
return normalizeColorFill(fill);
|
|
964
|
+
return clearUndef({ enabled, ...normalizeColorFill(fill) });
|
|
955
965
|
} else if (isGradientFill(fill)) {
|
|
956
|
-
return normalizeGradientFill(fill);
|
|
966
|
+
return clearUndef({ enabled, ...normalizeGradientFill(fill) });
|
|
957
967
|
} else if (isImageFill(fill)) {
|
|
958
|
-
return normalizeImageFill(fill);
|
|
968
|
+
return clearUndef({ enabled, ...normalizeImageFill(fill) });
|
|
959
969
|
} else if (isPresetFill(fill)) {
|
|
960
|
-
return normalizePresetFill(fill);
|
|
970
|
+
return clearUndef({ enabled, ...normalizePresetFill(fill) });
|
|
961
971
|
}
|
|
962
972
|
return {};
|
|
963
973
|
}
|
|
@@ -1401,51 +1411,60 @@ function isCRLF(char) {
|
|
|
1401
1411
|
function normalizeCRLF(content) {
|
|
1402
1412
|
return content.replace(NORMALIZE_CRLF_RE, NORMALIZED_CRLF);
|
|
1403
1413
|
}
|
|
1404
|
-
function isEqualStyle(style1, style2) {
|
|
1405
|
-
const keys = Array.from(/* @__PURE__ */ new Set([...Object.keys(style1), ...Object.keys(style2)]));
|
|
1406
|
-
return !keys.length || keys.every((key) => style1[key] === style2[key]);
|
|
1407
|
-
}
|
|
1408
1414
|
function normalizeTextContent(value) {
|
|
1409
1415
|
const paragraphs = [];
|
|
1410
1416
|
function lastParagraph() {
|
|
1411
1417
|
return paragraphs[paragraphs.length - 1];
|
|
1412
1418
|
}
|
|
1413
|
-
function addParagraph(
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1419
|
+
function addParagraph(styleOption, fillOption, outlineOption) {
|
|
1420
|
+
const style = styleOption ? normalizeStyle(styleOption) : {};
|
|
1421
|
+
const fill = fillOption ? normalizeFill(fillOption) : void 0;
|
|
1422
|
+
const outline = outlineOption ? normalizeOutline(outlineOption) : void 0;
|
|
1423
|
+
const paragraph = clearUndef({
|
|
1424
|
+
...style,
|
|
1425
|
+
fill,
|
|
1426
|
+
outline,
|
|
1427
|
+
fragments: []
|
|
1428
|
+
});
|
|
1429
|
+
if (paragraphs[paragraphs.length - 1]?.fragments.length === 0) {
|
|
1417
1430
|
paragraphs[paragraphs.length - 1] = paragraph;
|
|
1418
1431
|
} else {
|
|
1419
|
-
paragraph = { ...style, fragments: [] };
|
|
1420
1432
|
paragraphs.push(paragraph);
|
|
1421
1433
|
}
|
|
1422
1434
|
return paragraph;
|
|
1423
1435
|
}
|
|
1424
|
-
function addFragment(content = "",
|
|
1436
|
+
function addFragment(content = "", styleOption, fillOption, outlineOption) {
|
|
1437
|
+
const style = styleOption ? normalizeStyle(styleOption) : {};
|
|
1438
|
+
const fill = fillOption ? normalizeFill(fillOption) : void 0;
|
|
1439
|
+
const outline = outlineOption ? normalizeOutline(outlineOption) : void 0;
|
|
1425
1440
|
Array.from(content).forEach((c) => {
|
|
1426
1441
|
if (isCRLF(c)) {
|
|
1427
|
-
const { fragments, ...pStyle } = lastParagraph() || addParagraph();
|
|
1442
|
+
const { fragments, fill: pFill, outline: pOutline, ...pStyle } = lastParagraph() || addParagraph();
|
|
1428
1443
|
if (!fragments.length) {
|
|
1429
|
-
fragments.push({
|
|
1444
|
+
fragments.push(clearUndef({
|
|
1430
1445
|
...style,
|
|
1446
|
+
fill,
|
|
1447
|
+
outline,
|
|
1431
1448
|
content: NORMALIZED_CRLF
|
|
1432
|
-
});
|
|
1449
|
+
}));
|
|
1433
1450
|
}
|
|
1434
|
-
addParagraph(pStyle);
|
|
1451
|
+
addParagraph(pStyle, pFill, pOutline);
|
|
1435
1452
|
} else {
|
|
1436
1453
|
const paragraph = lastParagraph() || addParagraph();
|
|
1437
1454
|
const fragment = paragraph.fragments[paragraph.fragments.length - 1];
|
|
1438
1455
|
if (fragment) {
|
|
1439
|
-
const { content: content2, ...fStyle } = fragment;
|
|
1440
|
-
if (
|
|
1456
|
+
const { content: content2, fill: fFill, outline: fOutline, ...fStyle } = fragment;
|
|
1457
|
+
if (isEqualObject(fill, fFill) && isEqualObject(outline, fOutline) && isEqualObject(style, fStyle)) {
|
|
1441
1458
|
fragment.content = `${content2}${c}`;
|
|
1442
1459
|
return;
|
|
1443
1460
|
}
|
|
1444
1461
|
}
|
|
1445
|
-
paragraph.fragments.push({
|
|
1462
|
+
paragraph.fragments.push(clearUndef({
|
|
1446
1463
|
...style,
|
|
1464
|
+
fill,
|
|
1465
|
+
outline,
|
|
1447
1466
|
content: c
|
|
1448
|
-
});
|
|
1467
|
+
}));
|
|
1449
1468
|
}
|
|
1450
1469
|
});
|
|
1451
1470
|
}
|
|
@@ -1454,25 +1473,25 @@ function normalizeTextContent(value) {
|
|
|
1454
1473
|
if (typeof p === "string") {
|
|
1455
1474
|
addParagraph();
|
|
1456
1475
|
addFragment(p);
|
|
1457
|
-
} else if (
|
|
1458
|
-
const { content, ...
|
|
1459
|
-
addParagraph(
|
|
1476
|
+
} else if (isFragmentObject(p)) {
|
|
1477
|
+
const { content, fill: fFill, outline: fOutline, ...fStyle } = p;
|
|
1478
|
+
addParagraph(fStyle, fFill, fOutline);
|
|
1460
1479
|
addFragment(content);
|
|
1461
|
-
} else if (
|
|
1462
|
-
const { fragments, ...pStyle } = p;
|
|
1463
|
-
addParagraph(
|
|
1480
|
+
} else if (isParagraphObject(p)) {
|
|
1481
|
+
const { fragments, fill: pFill, outline: pOutline, ...pStyle } = p;
|
|
1482
|
+
addParagraph(pStyle, pFill, pOutline);
|
|
1464
1483
|
fragments.forEach((f) => {
|
|
1465
|
-
const { content, ...fStyle } = f;
|
|
1466
|
-
addFragment(content,
|
|
1484
|
+
const { content, fill: fFill, outline: fOutline, ...fStyle } = f;
|
|
1485
|
+
addFragment(content, fStyle, fFill, fOutline);
|
|
1467
1486
|
});
|
|
1468
1487
|
} else if (Array.isArray(p)) {
|
|
1469
1488
|
addParagraph();
|
|
1470
1489
|
p.forEach((f) => {
|
|
1471
1490
|
if (typeof f === "string") {
|
|
1472
1491
|
addFragment(f);
|
|
1473
|
-
} else {
|
|
1474
|
-
const { content, ...fStyle } = f;
|
|
1475
|
-
addFragment(content,
|
|
1492
|
+
} else if (isFragmentObject(f)) {
|
|
1493
|
+
const { content, fill: fFill, outline: fOutline, ...fStyle } = f;
|
|
1494
|
+
addFragment(content, fStyle, fFill, fOutline);
|
|
1476
1495
|
}
|
|
1477
1496
|
});
|
|
1478
1497
|
} else {
|
|
@@ -1487,20 +1506,28 @@ function normalizeTextContent(value) {
|
|
|
1487
1506
|
}
|
|
1488
1507
|
return paragraphs;
|
|
1489
1508
|
}
|
|
1509
|
+
function isParagraphObject(value) {
|
|
1510
|
+
return value && typeof value === "object" && "fragments" in value && Array.isArray(value.fragments);
|
|
1511
|
+
}
|
|
1512
|
+
function isFragmentObject(value) {
|
|
1513
|
+
return value && typeof value === "object" && "content" in value && typeof value.content === "string";
|
|
1514
|
+
}
|
|
1490
1515
|
function normalizeText(value) {
|
|
1491
|
-
if (typeof value === "string") {
|
|
1516
|
+
if (typeof value === "string" || Array.isArray(value)) {
|
|
1492
1517
|
return {
|
|
1493
1518
|
content: normalizeTextContent(value)
|
|
1494
1519
|
};
|
|
1495
|
-
} else if ("content" in value) {
|
|
1496
|
-
return {
|
|
1497
|
-
...value,
|
|
1498
|
-
content: normalizeTextContent(value.content)
|
|
1499
|
-
};
|
|
1500
1520
|
} else {
|
|
1501
|
-
return {
|
|
1502
|
-
|
|
1503
|
-
|
|
1521
|
+
return clearUndef({
|
|
1522
|
+
...value,
|
|
1523
|
+
content: normalizeTextContent(value.content ?? ""),
|
|
1524
|
+
style: value.style ? normalizeStyle(value.style) : void 0,
|
|
1525
|
+
effects: value.effects ? value.effects.map((v) => normalizeStyle(v)) : void 0,
|
|
1526
|
+
measureDom: value.measureDom,
|
|
1527
|
+
fonts: value.fonts,
|
|
1528
|
+
fill: value.fill ? normalizeFill(value.fill) : void 0,
|
|
1529
|
+
outline: value.outline ? normalizeOutline(value.outline) : void 0
|
|
1530
|
+
});
|
|
1504
1531
|
}
|
|
1505
1532
|
}
|
|
1506
1533
|
function textContentToString(value) {
|
|
@@ -1558,5 +1585,43 @@ function normalizeFlatDocument(doc) {
|
|
|
1558
1585
|
children
|
|
1559
1586
|
};
|
|
1560
1587
|
}
|
|
1588
|
+
function flatDocumentToDocument(flatDoc) {
|
|
1589
|
+
const { children, ...restProps } = flatDoc;
|
|
1590
|
+
function toElement(flatElement) {
|
|
1591
|
+
const { parentId, childrenIds, ...element } = flatElement;
|
|
1592
|
+
return {
|
|
1593
|
+
...element,
|
|
1594
|
+
children: []
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1597
|
+
const docElementMap = {};
|
|
1598
|
+
const docChildren = [];
|
|
1599
|
+
const doc = { ...restProps, children: docChildren };
|
|
1600
|
+
for (const id in children) {
|
|
1601
|
+
if (docElementMap[id]) {
|
|
1602
|
+
continue;
|
|
1603
|
+
}
|
|
1604
|
+
const flatElement = children[id];
|
|
1605
|
+
const element = toElement(flatElement);
|
|
1606
|
+
docElementMap[id] = element;
|
|
1607
|
+
const parentId = flatElement.parentId;
|
|
1608
|
+
if (parentId) {
|
|
1609
|
+
const flatParnet = children[parentId];
|
|
1610
|
+
let parnet = docElementMap[parentId];
|
|
1611
|
+
if (!parnet) {
|
|
1612
|
+
if (children[parentId]) {
|
|
1613
|
+
parnet = toElement(children[parentId]);
|
|
1614
|
+
docElementMap[parentId] = parnet;
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
if (flatParnet?.childrenIds && parnet?.children) {
|
|
1618
|
+
parnet.children.splice(flatParnet.childrenIds.indexOf(id), 0, element);
|
|
1619
|
+
}
|
|
1620
|
+
} else {
|
|
1621
|
+
docChildren.push(element);
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
return doc;
|
|
1625
|
+
}
|
|
1561
1626
|
|
|
1562
|
-
export { EventEmitter, RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject,
|
|
1627
|
+
export { EventEmitter, RawWeakMap, clearUndef, defaultColor, defineProperty, flatDocumentToDocument, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualObject, isFragmentObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isParagraphObject, isPresetFill, isPresetFillObject, nanoid, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeFlatDocument, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, property2, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
|