@pdfme/ui 5.5.7-dev.3 → 5.5.7-dev.4
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.es.js +126 -197
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
- package/src/components/Preview.tsx +13 -5
package/dist/index.es.js
CHANGED
|
@@ -8568,192 +8568,117 @@ ${u.join(`
|
|
|
8568
8568
|
typeof a == "object" && a !== null && "template" in a && migrateTemplate(a.template), checkProps(a, UIProps);
|
|
8569
8569
|
}, checkTemplate = (a) => {
|
|
8570
8570
|
migrateTemplate(a), checkProps(a, Template);
|
|
8571
|
-
};
|
|
8572
|
-
|
|
8573
|
-
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
8596
|
-
|
|
8597
|
-
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
}
|
|
8623
|
-
setPadding(s) {
|
|
8624
|
-
this.padding = s;
|
|
8625
|
-
}
|
|
8626
|
-
setPosition(s) {
|
|
8627
|
-
this.position = s;
|
|
8628
|
-
}
|
|
8629
|
-
insertChild(s) {
|
|
8630
|
-
const c = this.getChildCount();
|
|
8631
|
-
s.setIndex(c), this.children.splice(c, 0, s);
|
|
8632
|
-
}
|
|
8633
|
-
getChildCount() {
|
|
8634
|
-
return this.children.length;
|
|
8635
|
-
}
|
|
8636
|
-
getChild(s) {
|
|
8637
|
-
return this.children[s];
|
|
8571
|
+
}, EPSILON = 0.01, getContentHeight = (a) => a.height - a.padding[0] - a.padding[2], getSchemaValue = (a, s) => (a.readOnly ? a.content : s?.[a.name]) || "";
|
|
8572
|
+
function normalizePageSchemas(a, s) {
|
|
8573
|
+
const c = [], u = /* @__PURE__ */ new Map();
|
|
8574
|
+
return a.forEach((d, p) => {
|
|
8575
|
+
const v = d.position.y - s;
|
|
8576
|
+
c.push({
|
|
8577
|
+
schema: cloneDeep$1(d),
|
|
8578
|
+
baseY: v,
|
|
8579
|
+
height: d.height,
|
|
8580
|
+
dynamicHeights: [d.height]
|
|
8581
|
+
// Will be updated later
|
|
8582
|
+
}), u.set(d.name, p);
|
|
8583
|
+
}), c.sort((d, p) => Math.abs(d.baseY - p.baseY) > EPSILON ? d.baseY - p.baseY : (u.get(d.schema.name) ?? 0) - (u.get(p.schema.name) ?? 0)), { items: c, orderMap: u };
|
|
8584
|
+
}
|
|
8585
|
+
function placeRowsOnPages(a, s, c, u, d, p) {
|
|
8586
|
+
let v = 0, A = Math.floor(c / u), x = c % u;
|
|
8587
|
+
x < 0 && (x = 0);
|
|
8588
|
+
let g = 0;
|
|
8589
|
+
const b = s.length > 1;
|
|
8590
|
+
for (; v < s.length; ) {
|
|
8591
|
+
for (; p.length <= A; )
|
|
8592
|
+
p.push([]);
|
|
8593
|
+
const y = u - x;
|
|
8594
|
+
if (s[v] > y + EPSILON && !(Math.abs(y - u) <= EPSILON)) {
|
|
8595
|
+
A++, x = 0;
|
|
8596
|
+
continue;
|
|
8597
|
+
}
|
|
8598
|
+
let m = 0;
|
|
8599
|
+
const E = v;
|
|
8600
|
+
for (; v < s.length; ) {
|
|
8601
|
+
const $ = s[v];
|
|
8602
|
+
if (x + m + $ <= u + EPSILON)
|
|
8603
|
+
m += $, v++;
|
|
8604
|
+
else
|
|
8605
|
+
break;
|
|
8606
|
+
}
|
|
8607
|
+
const w = x <= EPSILON;
|
|
8608
|
+
if (b && E === 0 && v === 1 && s.length > 1 && !w) {
|
|
8609
|
+
v = 0, A++, x = 0;
|
|
8610
|
+
continue;
|
|
8611
|
+
}
|
|
8612
|
+
v === E && (m += s[v], v++);
|
|
8613
|
+
const S = {
|
|
8614
|
+
...a,
|
|
8615
|
+
height: m,
|
|
8616
|
+
position: { ...a.position, y: x + d }
|
|
8617
|
+
};
|
|
8618
|
+
b && (S.__bodyRange = {
|
|
8619
|
+
start: E === 0 ? 0 : E - 1,
|
|
8620
|
+
end: v - 1
|
|
8621
|
+
}, S.__isSplit = E > 0), p[A].push(S), x += m, x >= u - EPSILON && (A++, x = 0), g = A * u + x;
|
|
8638
8622
|
}
|
|
8623
|
+
return g;
|
|
8639
8624
|
}
|
|
8640
|
-
function
|
|
8641
|
-
|
|
8642
|
-
|
|
8625
|
+
function sortPagesByOrder(a, s) {
|
|
8626
|
+
a.forEach((c) => {
|
|
8627
|
+
c.sort((u, d) => (s.get(u.name) ?? 0) - (s.get(d.name) ?? 0));
|
|
8628
|
+
});
|
|
8643
8629
|
}
|
|
8644
|
-
function
|
|
8645
|
-
|
|
8646
|
-
|
|
8630
|
+
function removeTrailingEmptyPages(a) {
|
|
8631
|
+
for (; a.length > 1 && a[a.length - 1].length === 0; )
|
|
8632
|
+
a.pop();
|
|
8647
8633
|
}
|
|
8648
|
-
function
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
}).map((c, u) => (c.setIndex(u), c));
|
|
8655
|
-
}
|
|
8656
|
-
async function createOnePage(a) {
|
|
8657
|
-
const { basePdf: s, schemaPage: c, orderMap: u, input: d, options: p, _cache: v, getDynamicHeights: A } = a, x = createPage(s), g = [], b = cloneDeep$1(c).sort((m, E) => m.position.y - E.position.y), y = /* @__PURE__ */ new Map();
|
|
8658
|
-
for (const m of b) {
|
|
8659
|
-
const { position: E, width: w } = m, S = { schema: m, basePdf: s, options: p, _cache: v }, $ = (m.readOnly ? m.content : d?.[m.name]) || "", R = await A($, S), I = R.reduce((C, P) => C + P, 0), _ = m.height;
|
|
8660
|
-
I !== _ && y.set(E.y + _, I - _), R.forEach((C, P) => {
|
|
8661
|
-
let O = m.position.y + R.reduce((B, F, D) => D < P ? B + F : B, 0);
|
|
8662
|
-
for (const [B, F] of y.entries())
|
|
8663
|
-
B <= m.position.y && (O += F);
|
|
8664
|
-
const L = createNode({ schema: m, position: { ...E, y: O }, width: w, height: C });
|
|
8665
|
-
g.push(O + C + s.padding[2]), x.insertChild(L);
|
|
8666
|
-
});
|
|
8634
|
+
function processDynamicPage(a, s, c, u) {
|
|
8635
|
+
const d = [];
|
|
8636
|
+
let p = 0;
|
|
8637
|
+
for (const v of a) {
|
|
8638
|
+
const A = v.baseY + p, x = placeRowsOnPages(v.schema, v.dynamicHeights, A, c, u, d), g = v.baseY + v.height;
|
|
8639
|
+
p = x - g;
|
|
8667
8640
|
}
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
|
|
8676
|
-
|
|
8677
|
-
|
|
8678
|
-
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8684
|
-
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8641
|
+
return sortPagesByOrder(d, s), removeTrailingEmptyPages(d), d;
|
|
8642
|
+
}
|
|
8643
|
+
const getDynamicTemplate = async (a) => {
|
|
8644
|
+
const { template: s, input: c, options: u, _cache: d, getDynamicHeights: p } = a, v = s.basePdf;
|
|
8645
|
+
if (!isBlankPdf(v))
|
|
8646
|
+
return s;
|
|
8647
|
+
const A = getContentHeight(v), x = v.padding[0], g = [], b = 10;
|
|
8648
|
+
for (let y = 0; y < s.schemas.length; y++) {
|
|
8649
|
+
const f = s.schemas[y], { items: m, orderMap: E } = normalizePageSchemas(f, x);
|
|
8650
|
+
for (let S = 0; S < m.length; S += b) {
|
|
8651
|
+
const $ = m.slice(S, S + b), R = await Promise.all($.map((I) => {
|
|
8652
|
+
const _ = getSchemaValue(I.schema, c);
|
|
8653
|
+
return p(_, {
|
|
8654
|
+
schema: I.schema,
|
|
8655
|
+
basePdf: v,
|
|
8656
|
+
options: u,
|
|
8657
|
+
_cache: d
|
|
8658
|
+
}).then((C) => C.length === 0 ? [0] : C);
|
|
8659
|
+
}));
|
|
8660
|
+
for (let I = 0; I < R.length; I++)
|
|
8661
|
+
m[S + I].dynamicHeights = R[I];
|
|
8662
|
+
}
|
|
8663
|
+
const w = processDynamicPage(m, E, A, x);
|
|
8664
|
+
g.push(...w);
|
|
8665
|
+
}
|
|
8666
|
+
if (removeTrailingEmptyPages(g), g.length === s.schemas.length) {
|
|
8667
|
+
let y = !0;
|
|
8668
|
+
for (let f = 0; f < g.length && y; f++) {
|
|
8669
|
+
if (g[f].length !== s.schemas[f].length) {
|
|
8670
|
+
y = !1;
|
|
8696
8671
|
break;
|
|
8697
8672
|
}
|
|
8698
|
-
|
|
8673
|
+
for (let m = 0; m < g[f].length && y; m++) {
|
|
8674
|
+
const E = s.schemas[f][m], w = g[f][m];
|
|
8675
|
+
(Math.abs(E.height - w.height) > EPSILON || Math.abs(E.position.y - w.position.y) > EPSILON) && (y = !1);
|
|
8676
|
+
}
|
|
8699
8677
|
}
|
|
8700
|
-
if (
|
|
8701
|
-
|
|
8702
|
-
const P = createNode({ schema: E, position: { x: I, y: C }, width: $, height: S });
|
|
8703
|
-
d[_].insertChild(P);
|
|
8678
|
+
if (y)
|
|
8679
|
+
return s;
|
|
8704
8680
|
}
|
|
8705
|
-
return
|
|
8706
|
-
}
|
|
8707
|
-
function createNewTemplate(a, s) {
|
|
8708
|
-
const c = {
|
|
8709
|
-
schemas: Array.from({ length: a.length }, () => []),
|
|
8710
|
-
basePdf: s
|
|
8711
|
-
}, u = /* @__PURE__ */ new Map();
|
|
8712
|
-
return cloneDeep$1(a).forEach((d, p) => {
|
|
8713
|
-
d.children.forEach((v) => {
|
|
8714
|
-
const { schema: A } = v;
|
|
8715
|
-
if (!A)
|
|
8716
|
-
throw new Error("[@pdfme/common] schema is undefined");
|
|
8717
|
-
const x = A.name;
|
|
8718
|
-
u.has(x) || u.set(x, []), u.get(x).push(v);
|
|
8719
|
-
const g = d.children.filter((y) => y.schema?.name === x), b = u.get(x).length - g.length;
|
|
8720
|
-
if (g.length > 0) {
|
|
8721
|
-
if (!g[0].schema)
|
|
8722
|
-
throw new Error("[@pdfme/common] schema is undefined");
|
|
8723
|
-
const y = g[0].schema, f = g.reduce((S, $) => S + $.height, 0), m = g[0].position;
|
|
8724
|
-
y.__bodyRange = {
|
|
8725
|
-
start: Math.max(b - 1, 0),
|
|
8726
|
-
end: b + g.length - 1
|
|
8727
|
-
}, y.__isSplit = b > 0;
|
|
8728
|
-
const E = Object.assign({}, y, { position: m, height: f }), w = c.schemas[p].findIndex((S) => S.name === x);
|
|
8729
|
-
w !== -1 ? c.schemas[p][w] = E : c.schemas[p].push(E);
|
|
8730
|
-
}
|
|
8731
|
-
});
|
|
8732
|
-
}), c;
|
|
8733
|
-
}
|
|
8734
|
-
function flattenSchemasWithOffset(a, s) {
|
|
8735
|
-
const c = [], u = /* @__PURE__ */ new Map();
|
|
8736
|
-
let d = 0;
|
|
8737
|
-
const [p, , v] = s.padding, A = (g) => s.height - v - (g > 0 ? p : 0);
|
|
8738
|
-
let x = 0;
|
|
8739
|
-
return a.forEach((g, b) => {
|
|
8740
|
-
b > 0 && (x += A(b - 1)), g.forEach((y) => {
|
|
8741
|
-
const f = cloneDeep$1(y);
|
|
8742
|
-
f.position = { ...f.position, y: f.position.y + x }, c.push(f), u.has(y.name) || u.set(y.name, d++);
|
|
8743
|
-
});
|
|
8744
|
-
}), { flatSchemas: c, orderMap: u };
|
|
8745
|
-
}
|
|
8746
|
-
const getDynamicTemplate = async (a) => {
|
|
8747
|
-
const { template: s, ...c } = a, u = s.basePdf;
|
|
8748
|
-
if (!isBlankPdf(u))
|
|
8749
|
-
return s;
|
|
8750
|
-
const { flatSchemas: d, orderMap: p } = flattenSchemasWithOffset(s.schemas, u), v = await createOnePage({
|
|
8751
|
-
basePdf: u,
|
|
8752
|
-
schemaPage: d,
|
|
8753
|
-
orderMap: p,
|
|
8754
|
-
...c
|
|
8755
|
-
}), A = breakIntoPages({ longPage: v, basePdf: u, orderMap: p });
|
|
8756
|
-
return createNewTemplate(A, u);
|
|
8681
|
+
return { basePdf: v, schemas: g };
|
|
8757
8682
|
};
|
|
8758
8683
|
var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 7, 9, 32, 4, 318, 1, 80, 3, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 68, 8, 2, 0, 3, 0, 2, 3, 2, 4, 2, 0, 15, 1, 83, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 7, 19, 58, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 343, 9, 54, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 10, 5350, 0, 7, 14, 11465, 27, 2343, 9, 87, 9, 39, 4, 60, 6, 26, 9, 535, 9, 470, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4178, 9, 519, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 245, 1, 2, 9, 726, 6, 110, 6, 6, 9, 4759, 9, 787719, 239], astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 4, 51, 13, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 39, 27, 10, 22, 251, 41, 7, 1, 17, 2, 60, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 31, 9, 2, 0, 3, 0, 2, 37, 2, 0, 26, 0, 2, 0, 45, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 200, 32, 32, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 26, 3994, 6, 582, 6842, 29, 1763, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 433, 44, 212, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 42, 9, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 229, 29, 3, 0, 496, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 4191], nonASCIIidentifierChars = "·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・", nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ꟑꟑꟓꟕ-ꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ", reservedWords = {
|
|
8759
8684
|
3: "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",
|
|
@@ -159164,24 +159089,24 @@ const { Text } = Typography, icons = {
|
|
|
159164
159089
|
size: c,
|
|
159165
159090
|
zoomLevel: w,
|
|
159166
159091
|
maxZoom: x
|
|
159167
|
-
}), L = !!u, B = s[y], F = (j) => {
|
|
159092
|
+
}), L = !!u, B = s[y], F = (j, G) => {
|
|
159168
159093
|
getDynamicTemplate({
|
|
159169
159094
|
template: j,
|
|
159170
|
-
input: B,
|
|
159095
|
+
input: G ?? B,
|
|
159171
159096
|
options: { font: v },
|
|
159172
159097
|
_cache,
|
|
159173
|
-
getDynamicHeights: (
|
|
159174
|
-
switch (
|
|
159098
|
+
getDynamicHeights: (N, T) => {
|
|
159099
|
+
switch (T.schema.type) {
|
|
159175
159100
|
case "table":
|
|
159176
|
-
return getDynamicHeightsForTable(
|
|
159101
|
+
return getDynamicHeightsForTable(N, T);
|
|
159177
159102
|
default:
|
|
159178
|
-
return Promise.resolve([
|
|
159103
|
+
return Promise.resolve([T.schema.height]);
|
|
159179
159104
|
}
|
|
159180
159105
|
}
|
|
159181
|
-
}).then(async (
|
|
159182
|
-
const
|
|
159183
|
-
R(
|
|
159184
|
-
}).catch((
|
|
159106
|
+
}).then(async (N) => {
|
|
159107
|
+
const T = await template2SchemasList(N);
|
|
159108
|
+
R(T), await O(N);
|
|
159109
|
+
}).catch((N) => console.error("[@pdfme/ui] ", N));
|
|
159185
159110
|
};
|
|
159186
159111
|
reactExports.useEffect(() => {
|
|
159187
159112
|
typeof A.zoomLevel == "number" && A.zoomLevel !== w && S(A.zoomLevel);
|
|
@@ -159197,18 +159122,22 @@ const { Text } = Typography, icons = {
|
|
|
159197
159122
|
}
|
|
159198
159123
|
});
|
|
159199
159124
|
const D = ({ name: j, value: G }) => u && u({ index: y, name: j, value: G }), V = (j, G) => {
|
|
159200
|
-
let U = !1;
|
|
159201
|
-
j.forEach(({ key:
|
|
159202
|
-
if (
|
|
159203
|
-
const
|
|
159204
|
-
if (
|
|
159205
|
-
D({ name: G.name, value:
|
|
159125
|
+
let U = !1, M;
|
|
159126
|
+
if (j.forEach(({ key: N, value: T }) => {
|
|
159127
|
+
if (N === "content") {
|
|
159128
|
+
const k = T, H = B?.[G.name] || "";
|
|
159129
|
+
if (k === H) return;
|
|
159130
|
+
D({ name: G.name, value: k }), G.type === "table" && (U = !0, M = k);
|
|
159206
159131
|
} else {
|
|
159207
|
-
const
|
|
159208
|
-
if (!
|
|
159209
|
-
|
|
159132
|
+
const k = $[m].find((H) => H.id === G.id);
|
|
159133
|
+
if (!k) return;
|
|
159134
|
+
k[N] = T;
|
|
159210
159135
|
}
|
|
159211
|
-
}), U &&
|
|
159136
|
+
}), U && M !== void 0) {
|
|
159137
|
+
const N = { ...B, [G.name]: M };
|
|
159138
|
+
F(a, N);
|
|
159139
|
+
}
|
|
159140
|
+
R([...$]);
|
|
159212
159141
|
};
|
|
159213
159142
|
return P ? /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorScreen, { size: c, error: P }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(Root$1, { size: c, scale: C, children: [
|
|
159214
159143
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
package/dist/index.umd.js
CHANGED
|
@@ -29,7 +29,7 @@ ERROR MESSAGE: ${d.message}
|
|
|
29
29
|
--------------------------`);throw Error(`[@pdfme/common] Invalid argument:
|
|
30
30
|
--------------------------
|
|
31
31
|
${u.join(`
|
|
32
|
-
`)}`)}else throw Error(`[@pdfme/common] Unexpected parsing error: ${c instanceof Error?c.message:String(c)}`)}if(a&&typeof a=="object"&&"template"in a&&"options"in a){const{template:c,options:u}=a;u&&u.font&&checkFont({font:u.font,template:c})}if(a&&typeof a=="object"&&"template"in a&&"plugins"in a){const{template:c,plugins:u}=a;u&&checkPlugins({plugins:u,template:c})}},checkInputs=a=>checkProps(a,Inputs),checkUIOptions=a=>checkProps(a,UIOptions),checkPreviewProps=a=>checkProps(a,PreviewProps),checkDesignerProps=a=>checkProps(a,DesignerProps),checkUIProps=a=>{typeof a=="object"&&a!==null&&"template"in a&&migrateTemplate(a.template),checkProps(a,UIProps)},checkTemplate=a=>{migrateTemplate(a),checkProps(a,Template)};class LayoutNode{constructor({width:s=0,height:c=0}={}){Object.defineProperty(this,"index",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"children",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"width",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"height",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"padding",{enumerable:!0,configurable:!0,writable:!0,value:[0,0,0,0]}),Object.defineProperty(this,"position",{enumerable:!0,configurable:!0,writable:!0,value:{x:0,y:0}}),this.width=s,this.height=c}setIndex(s){this.index=s}setSchema(s){this.schema=s}setWidth(s){this.width=s}setHeight(s){this.height=s}setPadding(s){this.padding=s}setPosition(s){this.position=s}insertChild(s){const c=this.getChildCount();s.setIndex(c),this.children.splice(c,0,s)}getChildCount(){return this.children.length}getChild(s){return this.children[s]}}function createPage(a){const s=new LayoutNode({...a});return s.setPadding(a.padding),s}function createNode(a){const{position:s,width:c,height:u,schema:d}=a,p=new LayoutNode({width:c,height:u});return p.setPosition(s),p.setSchema(d),p}function resortChildren(a,s){a.children=a.children.sort((c,u)=>{const d=s.get(c.schema?.name??""),p=s.get(u.schema?.name??"");if(d===void 0||p===void 0)throw new Error("[@pdfme/common] order is not defined");return d-p}).map((c,u)=>(c.setIndex(u),c))}async function createOnePage(a){const{basePdf:s,schemaPage:c,orderMap:u,input:d,options:p,_cache:v,getDynamicHeights:A}=a,x=createPage(s),g=[],b=cloneDeep$1(c).sort((m,E)=>m.position.y-E.position.y),y=new Map;for(const m of b){const{position:E,width:w}=m,S={schema:m,basePdf:s,options:p,_cache:v},$=(m.readOnly?m.content:d?.[m.name])||"",T=await A($,S),I=T.reduce((C,P)=>C+P,0),_=m.height;I!==_&&y.set(E.y+_,I-_),T.forEach((C,P)=>{let O=m.position.y+T.reduce((B,F,D)=>D<P?B+F:B,0);for(const[B,F]of y.entries())B<=m.position.y&&(O+=F);const L=createNode({schema:m,position:{...E,y:O},width:w,height:C});g.push(O+C+s.padding[2]),x.insertChild(L)})}const f=Math.max(...g,s.height-s.padding[2]);return x.setHeight(f),resortChildren(x,u),x}function breakIntoPages(a){const{longPage:s,orderMap:c,basePdf:u}=a,d=[createPage(u)],[p,,v]=u.padding,A=[],x=m=>u.height-v-(m>0?p:0),g=(m,E)=>{const w=m-E*(u.height-p-v);for(;d.length<=E;)d[E]||(d.push(createPage(u)),A.push({page:E,value:(w-p)*-1}));return w+(A.find(S=>S.page===E)?.value||0)},b=m=>{let E=0,w=0;for(;;){const S=x(w);if(m<=E+S)return w;E+=S,w++}},y=s.children.sort((m,E)=>m.position.y-E.position.y);let f=0;for(let m=0;m<y.length;m++){const{schema:E,position:w,height:S,width:$}=y[m],{y:T,x:I}=w;let _=b(T);_<f&&(_=f);let C=g(T,_);for(;C+S>u.height-v;){const O=x(_+1);if(S>O){_++,C=g(T,_);break}_++,C=g(T,_)}if(f=_,!E)throw new Error("[@pdfme/common] schema is undefined");const P=createNode({schema:E,position:{x:I,y:C},width:$,height:S});d[_].insertChild(P)}return d.forEach(m=>resortChildren(m,c)),d}function createNewTemplate(a,s){const c={schemas:Array.from({length:a.length},()=>[]),basePdf:s},u=new Map;return cloneDeep$1(a).forEach((d,p)=>{d.children.forEach(v=>{const{schema:A}=v;if(!A)throw new Error("[@pdfme/common] schema is undefined");const x=A.name;u.has(x)||u.set(x,[]),u.get(x).push(v);const g=d.children.filter(y=>y.schema?.name===x),b=u.get(x).length-g.length;if(g.length>0){if(!g[0].schema)throw new Error("[@pdfme/common] schema is undefined");const y=g[0].schema,f=g.reduce((S,$)=>S+$.height,0),m=g[0].position;y.__bodyRange={start:Math.max(b-1,0),end:b+g.length-1},y.__isSplit=b>0;const E=Object.assign({},y,{position:m,height:f}),w=c.schemas[p].findIndex(S=>S.name===x);w!==-1?c.schemas[p][w]=E:c.schemas[p].push(E)}})}),c}function flattenSchemasWithOffset(a,s){const c=[],u=new Map;let d=0;const[p,,v]=s.padding,A=g=>s.height-v-(g>0?p:0);let x=0;return a.forEach((g,b)=>{b>0&&(x+=A(b-1)),g.forEach(y=>{const f=cloneDeep$1(y);f.position={...f.position,y:f.position.y+x},c.push(f),u.has(y.name)||u.set(y.name,d++)})}),{flatSchemas:c,orderMap:u}}const getDynamicTemplate=async a=>{const{template:s,...c}=a,u=s.basePdf;if(!isBlankPdf(u))return s;const{flatSchemas:d,orderMap:p}=flattenSchemasWithOffset(s.schemas,u),v=await createOnePage({basePdf:u,schemaPage:d,orderMap:p,...c}),A=breakIntoPages({longPage:v,basePdf:u,orderMap:p});return createNewTemplate(A,u)};var astralIdentifierCodes=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],astralIdentifierStartCodes=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],nonASCIIidentifierChars="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",nonASCIIidentifierStartChars="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ꟑꟑꟓꟕ-ꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",reservedWords={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},ecma5AndLessKeywords="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",keywords$1={5:ecma5AndLessKeywords,"5module":ecma5AndLessKeywords+" export import",6:ecma5AndLessKeywords+" const class extends export import super"},keywordRelationalOperator=/^in(stanceof)?$/,nonASCIIidentifierStart=new RegExp("["+nonASCIIidentifierStartChars+"]"),nonASCIIidentifier=new RegExp("["+nonASCIIidentifierStartChars+nonASCIIidentifierChars+"]");function isInAstralSet(a,s){for(var c=65536,u=0;u<s.length;u+=2){if(c+=s[u],c>a)return!1;if(c+=s[u+1],c>=a)return!0}return!1}function isIdentifierStart(a,s){return a<65?a===36:a<91?!0:a<97?a===95:a<123?!0:a<=65535?a>=170&&nonASCIIidentifierStart.test(String.fromCharCode(a)):s===!1?!1:isInAstralSet(a,astralIdentifierStartCodes)}function isIdentifierChar(a,s){return a<48?a===36:a<58?!0:a<65?!1:a<91?!0:a<97?a===95:a<123?!0:a<=65535?a>=170&&nonASCIIidentifier.test(String.fromCharCode(a)):s===!1?!1:isInAstralSet(a,astralIdentifierStartCodes)||isInAstralSet(a,astralIdentifierCodes)}var TokenType=function(s,c){c===void 0&&(c={}),this.label=s,this.keyword=c.keyword,this.beforeExpr=!!c.beforeExpr,this.startsExpr=!!c.startsExpr,this.isLoop=!!c.isLoop,this.isAssign=!!c.isAssign,this.prefix=!!c.prefix,this.postfix=!!c.postfix,this.binop=c.binop||null,this.updateContext=null};function binop(a,s){return new TokenType(a,{beforeExpr:!0,binop:s})}var beforeExpr={beforeExpr:!0},startsExpr={startsExpr:!0},keywords={};function kw(a,s){return s===void 0&&(s={}),s.keyword=a,keywords[a]=new TokenType(a,s)}var types$1={num:new TokenType("num",startsExpr),regexp:new TokenType("regexp",startsExpr),string:new TokenType("string",startsExpr),name:new TokenType("name",startsExpr),privateId:new TokenType("privateId",startsExpr),eof:new TokenType("eof"),bracketL:new TokenType("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new TokenType("]"),braceL:new TokenType("{",{beforeExpr:!0,startsExpr:!0}),braceR:new TokenType("}"),parenL:new TokenType("(",{beforeExpr:!0,startsExpr:!0}),parenR:new TokenType(")"),comma:new TokenType(",",beforeExpr),semi:new TokenType(";",beforeExpr),colon:new TokenType(":",beforeExpr),dot:new TokenType("."),question:new TokenType("?",beforeExpr),questionDot:new TokenType("?."),arrow:new TokenType("=>",beforeExpr),template:new TokenType("template"),invalidTemplate:new TokenType("invalidTemplate"),ellipsis:new TokenType("...",beforeExpr),backQuote:new TokenType("`",startsExpr),dollarBraceL:new TokenType("${",{beforeExpr:!0,startsExpr:!0}),eq:new TokenType("=",{beforeExpr:!0,isAssign:!0}),assign:new TokenType("_=",{beforeExpr:!0,isAssign:!0}),incDec:new TokenType("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new TokenType("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:binop("||",1),logicalAND:binop("&&",2),bitwiseOR:binop("|",3),bitwiseXOR:binop("^",4),bitwiseAND:binop("&",5),equality:binop("==/!=/===/!==",6),relational:binop("</>/<=/>=",7),bitShift:binop("<</>>/>>>",8),plusMin:new TokenType("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:binop("%",10),star:binop("*",10),slash:binop("/",10),starstar:new TokenType("**",{beforeExpr:!0}),coalesce:binop("??",1),_break:kw("break"),_case:kw("case",beforeExpr),_catch:kw("catch"),_continue:kw("continue"),_debugger:kw("debugger"),_default:kw("default",beforeExpr),_do:kw("do",{isLoop:!0,beforeExpr:!0}),_else:kw("else",beforeExpr),_finally:kw("finally"),_for:kw("for",{isLoop:!0}),_function:kw("function",startsExpr),_if:kw("if"),_return:kw("return",beforeExpr),_switch:kw("switch"),_throw:kw("throw",beforeExpr),_try:kw("try"),_var:kw("var"),_const:kw("const"),_while:kw("while",{isLoop:!0}),_with:kw("with"),_new:kw("new",{beforeExpr:!0,startsExpr:!0}),_this:kw("this",startsExpr),_super:kw("super",startsExpr),_class:kw("class",startsExpr),_extends:kw("extends",beforeExpr),_export:kw("export"),_import:kw("import",startsExpr),_null:kw("null",startsExpr),_true:kw("true",startsExpr),_false:kw("false",startsExpr),_in:kw("in",{beforeExpr:!0,binop:7}),_instanceof:kw("instanceof",{beforeExpr:!0,binop:7}),_typeof:kw("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:kw("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:kw("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},lineBreak=/\r\n?|\n|\u2028|\u2029/,lineBreakG=new RegExp(lineBreak.source,"g");function isNewLine(a){return a===10||a===13||a===8232||a===8233}function nextLineBreak(a,s,c){c===void 0&&(c=a.length);for(var u=s;u<c;u++){var d=a.charCodeAt(u);if(isNewLine(d))return u<c-1&&d===13&&a.charCodeAt(u+1)===10?u+2:u+1}return-1}var nonASCIIwhitespace=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,skipWhiteSpace=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ref$1=Object.prototype,hasOwnProperty$e=ref$1.hasOwnProperty,toString$1=ref$1.toString,hasOwn=Object.hasOwn||(function(a,s){return hasOwnProperty$e.call(a,s)}),isArray$3=Array.isArray||(function(a){return toString$1.call(a)==="[object Array]"}),regexpCache=Object.create(null);function wordsRegexp(a){return regexpCache[a]||(regexpCache[a]=new RegExp("^(?:"+a.replace(/ /g,"|")+")$"))}function codePointToString(a){return a<=65535?String.fromCharCode(a):(a-=65536,String.fromCharCode((a>>10)+55296,(a&1023)+56320))}var loneSurrogate=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Position=function(s,c){this.line=s,this.column=c};Position.prototype.offset=function(s){return new Position(this.line,this.column+s)};var SourceLocation=function(s,c,u){this.start=c,this.end=u,s.sourceFile!==null&&(this.source=s.sourceFile)};function getLineInfo(a,s){for(var c=1,u=0;;){var d=nextLineBreak(a,u,s);if(d<0)return new Position(c,s-u);++c,u=d}}var defaultOptions$1={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},warnedAboutEcmaVersion=!1;function getOptions(a){var s={};for(var c in defaultOptions$1)s[c]=a&&hasOwn(a,c)?a[c]:defaultOptions$1[c];if(s.ecmaVersion==="latest"?s.ecmaVersion=1e8:s.ecmaVersion==null?(!warnedAboutEcmaVersion&&typeof console=="object"&&console.warn&&(warnedAboutEcmaVersion=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
32
|
+
`)}`)}else throw Error(`[@pdfme/common] Unexpected parsing error: ${c instanceof Error?c.message:String(c)}`)}if(a&&typeof a=="object"&&"template"in a&&"options"in a){const{template:c,options:u}=a;u&&u.font&&checkFont({font:u.font,template:c})}if(a&&typeof a=="object"&&"template"in a&&"plugins"in a){const{template:c,plugins:u}=a;u&&checkPlugins({plugins:u,template:c})}},checkInputs=a=>checkProps(a,Inputs),checkUIOptions=a=>checkProps(a,UIOptions),checkPreviewProps=a=>checkProps(a,PreviewProps),checkDesignerProps=a=>checkProps(a,DesignerProps),checkUIProps=a=>{typeof a=="object"&&a!==null&&"template"in a&&migrateTemplate(a.template),checkProps(a,UIProps)},checkTemplate=a=>{migrateTemplate(a),checkProps(a,Template)},EPSILON=.01,getContentHeight=a=>a.height-a.padding[0]-a.padding[2],getSchemaValue=(a,s)=>(a.readOnly?a.content:s?.[a.name])||"";function normalizePageSchemas(a,s){const c=[],u=new Map;return a.forEach((d,p)=>{const v=d.position.y-s;c.push({schema:cloneDeep$1(d),baseY:v,height:d.height,dynamicHeights:[d.height]}),u.set(d.name,p)}),c.sort((d,p)=>Math.abs(d.baseY-p.baseY)>EPSILON?d.baseY-p.baseY:(u.get(d.schema.name)??0)-(u.get(p.schema.name)??0)),{items:c,orderMap:u}}function placeRowsOnPages(a,s,c,u,d,p){let v=0,A=Math.floor(c/u),x=c%u;x<0&&(x=0);let g=0;const b=s.length>1;for(;v<s.length;){for(;p.length<=A;)p.push([]);const y=u-x;if(s[v]>y+EPSILON&&!(Math.abs(y-u)<=EPSILON)){A++,x=0;continue}let m=0;const E=v;for(;v<s.length;){const $=s[v];if(x+m+$<=u+EPSILON)m+=$,v++;else break}const w=x<=EPSILON;if(b&&E===0&&v===1&&s.length>1&&!w){v=0,A++,x=0;continue}v===E&&(m+=s[v],v++);const S={...a,height:m,position:{...a.position,y:x+d}};b&&(S.__bodyRange={start:E===0?0:E-1,end:v-1},S.__isSplit=E>0),p[A].push(S),x+=m,x>=u-EPSILON&&(A++,x=0),g=A*u+x}return g}function sortPagesByOrder(a,s){a.forEach(c=>{c.sort((u,d)=>(s.get(u.name)??0)-(s.get(d.name)??0))})}function removeTrailingEmptyPages(a){for(;a.length>1&&a[a.length-1].length===0;)a.pop()}function processDynamicPage(a,s,c,u){const d=[];let p=0;for(const v of a){const A=v.baseY+p,x=placeRowsOnPages(v.schema,v.dynamicHeights,A,c,u,d),g=v.baseY+v.height;p=x-g}return sortPagesByOrder(d,s),removeTrailingEmptyPages(d),d}const getDynamicTemplate=async a=>{const{template:s,input:c,options:u,_cache:d,getDynamicHeights:p}=a,v=s.basePdf;if(!isBlankPdf(v))return s;const A=getContentHeight(v),x=v.padding[0],g=[],b=10;for(let y=0;y<s.schemas.length;y++){const f=s.schemas[y],{items:m,orderMap:E}=normalizePageSchemas(f,x);for(let S=0;S<m.length;S+=b){const $=m.slice(S,S+b),T=await Promise.all($.map(I=>{const _=getSchemaValue(I.schema,c);return p(_,{schema:I.schema,basePdf:v,options:u,_cache:d}).then(C=>C.length===0?[0]:C)}));for(let I=0;I<T.length;I++)m[S+I].dynamicHeights=T[I]}const w=processDynamicPage(m,E,A,x);g.push(...w)}if(removeTrailingEmptyPages(g),g.length===s.schemas.length){let y=!0;for(let f=0;f<g.length&&y;f++){if(g[f].length!==s.schemas[f].length){y=!1;break}for(let m=0;m<g[f].length&&y;m++){const E=s.schemas[f][m],w=g[f][m];(Math.abs(E.height-w.height)>EPSILON||Math.abs(E.position.y-w.position.y)>EPSILON)&&(y=!1)}}if(y)return s}return{basePdf:v,schemas:g}};var astralIdentifierCodes=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],astralIdentifierStartCodes=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],nonASCIIidentifierChars="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",nonASCIIidentifierStartChars="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ꟑꟑꟓꟕ-ꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",reservedWords={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},ecma5AndLessKeywords="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",keywords$1={5:ecma5AndLessKeywords,"5module":ecma5AndLessKeywords+" export import",6:ecma5AndLessKeywords+" const class extends export import super"},keywordRelationalOperator=/^in(stanceof)?$/,nonASCIIidentifierStart=new RegExp("["+nonASCIIidentifierStartChars+"]"),nonASCIIidentifier=new RegExp("["+nonASCIIidentifierStartChars+nonASCIIidentifierChars+"]");function isInAstralSet(a,s){for(var c=65536,u=0;u<s.length;u+=2){if(c+=s[u],c>a)return!1;if(c+=s[u+1],c>=a)return!0}return!1}function isIdentifierStart(a,s){return a<65?a===36:a<91?!0:a<97?a===95:a<123?!0:a<=65535?a>=170&&nonASCIIidentifierStart.test(String.fromCharCode(a)):s===!1?!1:isInAstralSet(a,astralIdentifierStartCodes)}function isIdentifierChar(a,s){return a<48?a===36:a<58?!0:a<65?!1:a<91?!0:a<97?a===95:a<123?!0:a<=65535?a>=170&&nonASCIIidentifier.test(String.fromCharCode(a)):s===!1?!1:isInAstralSet(a,astralIdentifierStartCodes)||isInAstralSet(a,astralIdentifierCodes)}var TokenType=function(s,c){c===void 0&&(c={}),this.label=s,this.keyword=c.keyword,this.beforeExpr=!!c.beforeExpr,this.startsExpr=!!c.startsExpr,this.isLoop=!!c.isLoop,this.isAssign=!!c.isAssign,this.prefix=!!c.prefix,this.postfix=!!c.postfix,this.binop=c.binop||null,this.updateContext=null};function binop(a,s){return new TokenType(a,{beforeExpr:!0,binop:s})}var beforeExpr={beforeExpr:!0},startsExpr={startsExpr:!0},keywords={};function kw(a,s){return s===void 0&&(s={}),s.keyword=a,keywords[a]=new TokenType(a,s)}var types$1={num:new TokenType("num",startsExpr),regexp:new TokenType("regexp",startsExpr),string:new TokenType("string",startsExpr),name:new TokenType("name",startsExpr),privateId:new TokenType("privateId",startsExpr),eof:new TokenType("eof"),bracketL:new TokenType("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new TokenType("]"),braceL:new TokenType("{",{beforeExpr:!0,startsExpr:!0}),braceR:new TokenType("}"),parenL:new TokenType("(",{beforeExpr:!0,startsExpr:!0}),parenR:new TokenType(")"),comma:new TokenType(",",beforeExpr),semi:new TokenType(";",beforeExpr),colon:new TokenType(":",beforeExpr),dot:new TokenType("."),question:new TokenType("?",beforeExpr),questionDot:new TokenType("?."),arrow:new TokenType("=>",beforeExpr),template:new TokenType("template"),invalidTemplate:new TokenType("invalidTemplate"),ellipsis:new TokenType("...",beforeExpr),backQuote:new TokenType("`",startsExpr),dollarBraceL:new TokenType("${",{beforeExpr:!0,startsExpr:!0}),eq:new TokenType("=",{beforeExpr:!0,isAssign:!0}),assign:new TokenType("_=",{beforeExpr:!0,isAssign:!0}),incDec:new TokenType("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new TokenType("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:binop("||",1),logicalAND:binop("&&",2),bitwiseOR:binop("|",3),bitwiseXOR:binop("^",4),bitwiseAND:binop("&",5),equality:binop("==/!=/===/!==",6),relational:binop("</>/<=/>=",7),bitShift:binop("<</>>/>>>",8),plusMin:new TokenType("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:binop("%",10),star:binop("*",10),slash:binop("/",10),starstar:new TokenType("**",{beforeExpr:!0}),coalesce:binop("??",1),_break:kw("break"),_case:kw("case",beforeExpr),_catch:kw("catch"),_continue:kw("continue"),_debugger:kw("debugger"),_default:kw("default",beforeExpr),_do:kw("do",{isLoop:!0,beforeExpr:!0}),_else:kw("else",beforeExpr),_finally:kw("finally"),_for:kw("for",{isLoop:!0}),_function:kw("function",startsExpr),_if:kw("if"),_return:kw("return",beforeExpr),_switch:kw("switch"),_throw:kw("throw",beforeExpr),_try:kw("try"),_var:kw("var"),_const:kw("const"),_while:kw("while",{isLoop:!0}),_with:kw("with"),_new:kw("new",{beforeExpr:!0,startsExpr:!0}),_this:kw("this",startsExpr),_super:kw("super",startsExpr),_class:kw("class",startsExpr),_extends:kw("extends",beforeExpr),_export:kw("export"),_import:kw("import",startsExpr),_null:kw("null",startsExpr),_true:kw("true",startsExpr),_false:kw("false",startsExpr),_in:kw("in",{beforeExpr:!0,binop:7}),_instanceof:kw("instanceof",{beforeExpr:!0,binop:7}),_typeof:kw("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:kw("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:kw("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},lineBreak=/\r\n?|\n|\u2028|\u2029/,lineBreakG=new RegExp(lineBreak.source,"g");function isNewLine(a){return a===10||a===13||a===8232||a===8233}function nextLineBreak(a,s,c){c===void 0&&(c=a.length);for(var u=s;u<c;u++){var d=a.charCodeAt(u);if(isNewLine(d))return u<c-1&&d===13&&a.charCodeAt(u+1)===10?u+2:u+1}return-1}var nonASCIIwhitespace=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,skipWhiteSpace=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ref$1=Object.prototype,hasOwnProperty$e=ref$1.hasOwnProperty,toString$1=ref$1.toString,hasOwn=Object.hasOwn||(function(a,s){return hasOwnProperty$e.call(a,s)}),isArray$3=Array.isArray||(function(a){return toString$1.call(a)==="[object Array]"}),regexpCache=Object.create(null);function wordsRegexp(a){return regexpCache[a]||(regexpCache[a]=new RegExp("^(?:"+a.replace(/ /g,"|")+")$"))}function codePointToString(a){return a<=65535?String.fromCharCode(a):(a-=65536,String.fromCharCode((a>>10)+55296,(a&1023)+56320))}var loneSurrogate=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Position=function(s,c){this.line=s,this.column=c};Position.prototype.offset=function(s){return new Position(this.line,this.column+s)};var SourceLocation=function(s,c,u){this.start=c,this.end=u,s.sourceFile!==null&&(this.source=s.sourceFile)};function getLineInfo(a,s){for(var c=1,u=0;;){var d=nextLineBreak(a,u,s);if(d<0)return new Position(c,s-u);++c,u=d}}var defaultOptions$1={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},warnedAboutEcmaVersion=!1;function getOptions(a){var s={};for(var c in defaultOptions$1)s[c]=a&&hasOwn(a,c)?a[c]:defaultOptions$1[c];if(s.ecmaVersion==="latest"?s.ecmaVersion=1e8:s.ecmaVersion==null?(!warnedAboutEcmaVersion&&typeof console=="object"&&console.warn&&(warnedAboutEcmaVersion=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
33
33
|
Defaulting to 2020, but this will stop working in the future.`)),s.ecmaVersion=11):s.ecmaVersion>=2015&&(s.ecmaVersion-=2009),s.allowReserved==null&&(s.allowReserved=s.ecmaVersion<5),(!a||a.allowHashBang==null)&&(s.allowHashBang=s.ecmaVersion>=14),isArray$3(s.onToken)){var u=s.onToken;s.onToken=function(d){return u.push(d)}}return isArray$3(s.onComment)&&(s.onComment=pushComment(s,s.onComment)),s}function pushComment(a,s){return function(c,u,d,p,v,A){var x={type:c?"Block":"Line",value:u,start:d,end:p};a.locations&&(x.loc=new SourceLocation(this,v,A)),a.ranges&&(x.range=[d,p]),s.push(x)}}var SCOPE_TOP=1,SCOPE_FUNCTION=2,SCOPE_ASYNC=4,SCOPE_GENERATOR=8,SCOPE_ARROW=16,SCOPE_SIMPLE_CATCH=32,SCOPE_SUPER=64,SCOPE_DIRECT_SUPER=128,SCOPE_CLASS_STATIC_BLOCK=256,SCOPE_CLASS_FIELD_INIT=512,SCOPE_VAR=SCOPE_TOP|SCOPE_FUNCTION|SCOPE_CLASS_STATIC_BLOCK;function functionFlags(a,s){return SCOPE_FUNCTION|(a?SCOPE_ASYNC:0)|(s?SCOPE_GENERATOR:0)}var BIND_NONE=0,BIND_VAR=1,BIND_LEXICAL=2,BIND_FUNCTION=3,BIND_SIMPLE_CATCH=4,BIND_OUTSIDE=5,Parser=function(s,c,u){this.options=s=getOptions(s),this.sourceFile=s.sourceFile,this.keywords=wordsRegexp(keywords$1[s.ecmaVersion>=6?6:s.sourceType==="module"?"5module":5]);var d="";s.allowReserved!==!0&&(d=reservedWords[s.ecmaVersion>=6?6:s.ecmaVersion===5?5:3],s.sourceType==="module"&&(d+=" await")),this.reservedWords=wordsRegexp(d);var p=(d?d+" ":"")+reservedWords.strict;this.reservedWordsStrict=wordsRegexp(p),this.reservedWordsStrictBind=wordsRegexp(p+" "+reservedWords.strictBind),this.input=String(c),this.containsEsc=!1,u?(this.pos=u,this.lineStart=this.input.lastIndexOf(`
|
|
34
34
|
`,u-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(lineBreak).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=types$1.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=s.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&s.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(SCOPE_TOP),this.regexpState=null,this.privateNameStack=[]},prototypeAccessors={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};Parser.prototype.parse=function(){var s=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(s)},prototypeAccessors.inFunction.get=function(){return(this.currentVarScope().flags&SCOPE_FUNCTION)>0},prototypeAccessors.inGenerator.get=function(){return(this.currentVarScope().flags&SCOPE_GENERATOR)>0},prototypeAccessors.inAsync.get=function(){return(this.currentVarScope().flags&SCOPE_ASYNC)>0},prototypeAccessors.canAwait.get=function(){for(var a=this.scopeStack.length-1;a>=0;a--){var s=this.scopeStack[a],c=s.flags;if(c&(SCOPE_CLASS_STATIC_BLOCK|SCOPE_CLASS_FIELD_INIT))return!1;if(c&SCOPE_FUNCTION)return(c&SCOPE_ASYNC)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},prototypeAccessors.allowSuper.get=function(){var a=this.currentThisScope(),s=a.flags;return(s&SCOPE_SUPER)>0||this.options.allowSuperOutsideMethod},prototypeAccessors.allowDirectSuper.get=function(){return(this.currentThisScope().flags&SCOPE_DIRECT_SUPER)>0},prototypeAccessors.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},prototypeAccessors.allowNewDotTarget.get=function(){for(var a=this.scopeStack.length-1;a>=0;a--){var s=this.scopeStack[a],c=s.flags;if(c&(SCOPE_CLASS_STATIC_BLOCK|SCOPE_CLASS_FIELD_INIT)||c&SCOPE_FUNCTION&&!(c&SCOPE_ARROW))return!0}return!1},prototypeAccessors.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&SCOPE_CLASS_STATIC_BLOCK)>0},Parser.extend=function(){for(var s=[],c=arguments.length;c--;)s[c]=arguments[c];for(var u=this,d=0;d<s.length;d++)u=s[d](u);return u},Parser.parse=function(s,c){return new this(c,s).parse()},Parser.parseExpressionAt=function(s,c,u){var d=new this(u,s,c);return d.nextToken(),d.parseExpression()},Parser.tokenizer=function(s,c){return new this(c,s)},Object.defineProperties(Parser.prototype,prototypeAccessors);var pp$9=Parser.prototype,literal=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;pp$9.strictDirective=function(a){if(this.options.ecmaVersion<5)return!1;for(;;){skipWhiteSpace.lastIndex=a,a+=skipWhiteSpace.exec(this.input)[0].length;var s=literal.exec(this.input.slice(a));if(!s)return!1;if((s[1]||s[2])==="use strict"){skipWhiteSpace.lastIndex=a+s[0].length;var c=skipWhiteSpace.exec(this.input),u=c.index+c[0].length,d=this.input.charAt(u);return d===";"||d==="}"||lineBreak.test(c[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(d)||d==="!"&&this.input.charAt(u+1)==="=")}a+=s[0].length,skipWhiteSpace.lastIndex=a,a+=skipWhiteSpace.exec(this.input)[0].length,this.input[a]===";"&&a++}},pp$9.eat=function(a){return this.type===a?(this.next(),!0):!1},pp$9.isContextual=function(a){return this.type===types$1.name&&this.value===a&&!this.containsEsc},pp$9.eatContextual=function(a){return this.isContextual(a)?(this.next(),!0):!1},pp$9.expectContextual=function(a){this.eatContextual(a)||this.unexpected()},pp$9.canInsertSemicolon=function(){return this.type===types$1.eof||this.type===types$1.braceR||lineBreak.test(this.input.slice(this.lastTokEnd,this.start))},pp$9.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},pp$9.semicolon=function(){!this.eat(types$1.semi)&&!this.insertSemicolon()&&this.unexpected()},pp$9.afterTrailingComma=function(a,s){if(this.type===a)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),s||this.next(),!0},pp$9.expect=function(a){this.eat(a)||this.unexpected()},pp$9.unexpected=function(a){this.raise(a??this.start,"Unexpected token")};var DestructuringErrors=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};pp$9.checkPatternErrors=function(a,s){if(a){a.trailingComma>-1&&this.raiseRecoverable(a.trailingComma,"Comma is not permitted after the rest element");var c=s?a.parenthesizedAssign:a.parenthesizedBind;c>-1&&this.raiseRecoverable(c,s?"Assigning to rvalue":"Parenthesized pattern")}},pp$9.checkExpressionErrors=function(a,s){if(!a)return!1;var c=a.shorthandAssign,u=a.doubleProto;if(!s)return c>=0||u>=0;c>=0&&this.raise(c,"Shorthand property assignments are valid only in destructuring patterns"),u>=0&&this.raiseRecoverable(u,"Redefinition of __proto__ property")},pp$9.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")},pp$9.isSimpleAssignTarget=function(a){return a.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(a.expression):a.type==="Identifier"||a.type==="MemberExpression"};var pp$8=Parser.prototype;pp$8.parseTopLevel=function(a){var s=Object.create(null);for(a.body||(a.body=[]);this.type!==types$1.eof;){var c=this.parseStatement(null,!0,s);a.body.push(c)}if(this.inModule)for(var u=0,d=Object.keys(this.undefinedExports);u<d.length;u+=1){var p=d[u];this.raiseRecoverable(this.undefinedExports[p].start,"Export '"+p+"' is not defined")}return this.adaptDirectivePrologue(a.body),this.next(),a.sourceType=this.options.sourceType,this.finishNode(a,"Program")};var loopLabel={kind:"loop"},switchLabel={kind:"switch"};pp$8.isLet=function(a){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;skipWhiteSpace.lastIndex=this.pos;var s=skipWhiteSpace.exec(this.input),c=this.pos+s[0].length,u=this.input.charCodeAt(c);if(u===91||u===92)return!0;if(a)return!1;if(u===123||u>55295&&u<56320)return!0;if(isIdentifierStart(u,!0)){for(var d=c+1;isIdentifierChar(u=this.input.charCodeAt(d),!0);)++d;if(u===92||u>55295&&u<56320)return!0;var p=this.input.slice(c,d);if(!keywordRelationalOperator.test(p))return!0}return!1},pp$8.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;skipWhiteSpace.lastIndex=this.pos;var a=skipWhiteSpace.exec(this.input),s=this.pos+a[0].length,c;return!lineBreak.test(this.input.slice(this.pos,s))&&this.input.slice(s,s+8)==="function"&&(s+8===this.input.length||!(isIdentifierChar(c=this.input.charCodeAt(s+8))||c>55295&&c<56320))},pp$8.isUsingKeyword=function(a,s){if(this.options.ecmaVersion<17||!this.isContextual(a?"await":"using"))return!1;skipWhiteSpace.lastIndex=this.pos;var c=skipWhiteSpace.exec(this.input),u=this.pos+c[0].length;if(lineBreak.test(this.input.slice(this.pos,u)))return!1;if(a){var d=u+5,p;if(this.input.slice(u,d)!=="using"||d===this.input.length||isIdentifierChar(p=this.input.charCodeAt(d))||p>55295&&p<56320)return!1;skipWhiteSpace.lastIndex=d;var v=skipWhiteSpace.exec(this.input);if(v&&lineBreak.test(this.input.slice(d,d+v[0].length)))return!1}if(s){var A=u+2,x;if(this.input.slice(u,A)==="of"&&(A===this.input.length||!isIdentifierChar(x=this.input.charCodeAt(A))&&!(x>55295&&x<56320)))return!1}var g=this.input.charCodeAt(u);return isIdentifierStart(g,!0)||g===92},pp$8.isAwaitUsing=function(a){return this.isUsingKeyword(!0,a)},pp$8.isUsing=function(a){return this.isUsingKeyword(!1,a)},pp$8.parseStatement=function(a,s,c){var u=this.type,d=this.startNode(),p;switch(this.isLet(a)&&(u=types$1._var,p="let"),u){case types$1._break:case types$1._continue:return this.parseBreakContinueStatement(d,u.keyword);case types$1._debugger:return this.parseDebuggerStatement(d);case types$1._do:return this.parseDoStatement(d);case types$1._for:return this.parseForStatement(d);case types$1._function:return a&&(this.strict||a!=="if"&&a!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(d,!1,!a);case types$1._class:return a&&this.unexpected(),this.parseClass(d,!0);case types$1._if:return this.parseIfStatement(d);case types$1._return:return this.parseReturnStatement(d);case types$1._switch:return this.parseSwitchStatement(d);case types$1._throw:return this.parseThrowStatement(d);case types$1._try:return this.parseTryStatement(d);case types$1._const:case types$1._var:return p=p||this.value,a&&p!=="var"&&this.unexpected(),this.parseVarStatement(d,p);case types$1._while:return this.parseWhileStatement(d);case types$1._with:return this.parseWithStatement(d);case types$1.braceL:return this.parseBlock(!0,d);case types$1.semi:return this.parseEmptyStatement(d);case types$1._export:case types$1._import:if(this.options.ecmaVersion>10&&u===types$1._import){skipWhiteSpace.lastIndex=this.pos;var v=skipWhiteSpace.exec(this.input),A=this.pos+v[0].length,x=this.input.charCodeAt(A);if(x===40||x===46)return this.parseExpressionStatement(d,this.parseExpression())}return this.options.allowImportExportEverywhere||(s||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),u===types$1._import?this.parseImport(d):this.parseExport(d,c);default:if(this.isAsyncFunction())return a&&this.unexpected(),this.next(),this.parseFunctionStatement(d,!0,!a);var g=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(g)return s&&this.options.sourceType==="script"&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),g==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(d,!1,g),this.semicolon(),this.finishNode(d,"VariableDeclaration");var b=this.value,y=this.parseExpression();return u===types$1.name&&y.type==="Identifier"&&this.eat(types$1.colon)?this.parseLabeledStatement(d,b,y,a):this.parseExpressionStatement(d,y)}},pp$8.parseBreakContinueStatement=function(a,s){var c=s==="break";this.next(),this.eat(types$1.semi)||this.insertSemicolon()?a.label=null:this.type!==types$1.name?this.unexpected():(a.label=this.parseIdent(),this.semicolon());for(var u=0;u<this.labels.length;++u){var d=this.labels[u];if((a.label==null||d.name===a.label.name)&&(d.kind!=null&&(c||d.kind==="loop")||a.label&&c))break}return u===this.labels.length&&this.raise(a.start,"Unsyntactic "+s),this.finishNode(a,c?"BreakStatement":"ContinueStatement")},pp$8.parseDebuggerStatement=function(a){return this.next(),this.semicolon(),this.finishNode(a,"DebuggerStatement")},pp$8.parseDoStatement=function(a){return this.next(),this.labels.push(loopLabel),a.body=this.parseStatement("do"),this.labels.pop(),this.expect(types$1._while),a.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(types$1.semi):this.semicolon(),this.finishNode(a,"DoWhileStatement")},pp$8.parseForStatement=function(a){this.next();var s=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(loopLabel),this.enterScope(0),this.expect(types$1.parenL),this.type===types$1.semi)return s>-1&&this.unexpected(s),this.parseFor(a,null);var c=this.isLet();if(this.type===types$1._var||this.type===types$1._const||c){var u=this.startNode(),d=c?"let":this.value;return this.next(),this.parseVar(u,!0,d),this.finishNode(u,"VariableDeclaration"),this.parseForAfterInit(a,u,s)}var p=this.isContextual("let"),v=!1,A=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(A){var x=this.startNode();return this.next(),A==="await using"&&this.next(),this.parseVar(x,!0,A),this.finishNode(x,"VariableDeclaration"),this.parseForAfterInit(a,x,s)}var g=this.containsEsc,b=new DestructuringErrors,y=this.start,f=s>-1?this.parseExprSubscripts(b,"await"):this.parseExpression(!0,b);return this.type===types$1._in||(v=this.options.ecmaVersion>=6&&this.isContextual("of"))?(s>-1?(this.type===types$1._in&&this.unexpected(s),a.await=!0):v&&this.options.ecmaVersion>=8&&(f.start===y&&!g&&f.type==="Identifier"&&f.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(a.await=!1)),p&&v&&this.raise(f.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(f,!1,b),this.checkLValPattern(f),this.parseForIn(a,f)):(this.checkExpressionErrors(b,!0),s>-1&&this.unexpected(s),this.parseFor(a,f))},pp$8.parseForAfterInit=function(a,s,c){return(this.type===types$1._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&s.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===types$1._in?c>-1&&this.unexpected(c):a.await=c>-1),this.parseForIn(a,s)):(c>-1&&this.unexpected(c),this.parseFor(a,s))},pp$8.parseFunctionStatement=function(a,s,c){return this.next(),this.parseFunction(a,FUNC_STATEMENT|(c?0:FUNC_HANGING_STATEMENT),!1,s)},pp$8.parseIfStatement=function(a){return this.next(),a.test=this.parseParenExpression(),a.consequent=this.parseStatement("if"),a.alternate=this.eat(types$1._else)?this.parseStatement("if"):null,this.finishNode(a,"IfStatement")},pp$8.parseReturnStatement=function(a){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(types$1.semi)||this.insertSemicolon()?a.argument=null:(a.argument=this.parseExpression(),this.semicolon()),this.finishNode(a,"ReturnStatement")},pp$8.parseSwitchStatement=function(a){this.next(),a.discriminant=this.parseParenExpression(),a.cases=[],this.expect(types$1.braceL),this.labels.push(switchLabel),this.enterScope(0);for(var s,c=!1;this.type!==types$1.braceR;)if(this.type===types$1._case||this.type===types$1._default){var u=this.type===types$1._case;s&&this.finishNode(s,"SwitchCase"),a.cases.push(s=this.startNode()),s.consequent=[],this.next(),u?s.test=this.parseExpression():(c&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),c=!0,s.test=null),this.expect(types$1.colon)}else s||this.unexpected(),s.consequent.push(this.parseStatement(null));return this.exitScope(),s&&this.finishNode(s,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(a,"SwitchStatement")},pp$8.parseThrowStatement=function(a){return this.next(),lineBreak.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),a.argument=this.parseExpression(),this.semicolon(),this.finishNode(a,"ThrowStatement")};var empty$1=[];pp$8.parseCatchClauseParam=function(){var a=this.parseBindingAtom(),s=a.type==="Identifier";return this.enterScope(s?SCOPE_SIMPLE_CATCH:0),this.checkLValPattern(a,s?BIND_SIMPLE_CATCH:BIND_LEXICAL),this.expect(types$1.parenR),a},pp$8.parseTryStatement=function(a){if(this.next(),a.block=this.parseBlock(),a.handler=null,this.type===types$1._catch){var s=this.startNode();this.next(),this.eat(types$1.parenL)?s.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),s.param=null,this.enterScope(0)),s.body=this.parseBlock(!1),this.exitScope(),a.handler=this.finishNode(s,"CatchClause")}return a.finalizer=this.eat(types$1._finally)?this.parseBlock():null,!a.handler&&!a.finalizer&&this.raise(a.start,"Missing catch or finally clause"),this.finishNode(a,"TryStatement")},pp$8.parseVarStatement=function(a,s,c){return this.next(),this.parseVar(a,!1,s,c),this.semicolon(),this.finishNode(a,"VariableDeclaration")},pp$8.parseWhileStatement=function(a){return this.next(),a.test=this.parseParenExpression(),this.labels.push(loopLabel),a.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(a,"WhileStatement")},pp$8.parseWithStatement=function(a){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),a.object=this.parseParenExpression(),a.body=this.parseStatement("with"),this.finishNode(a,"WithStatement")},pp$8.parseEmptyStatement=function(a){return this.next(),this.finishNode(a,"EmptyStatement")},pp$8.parseLabeledStatement=function(a,s,c,u){for(var d=0,p=this.labels;d<p.length;d+=1){var v=p[d];v.name===s&&this.raise(c.start,"Label '"+s+"' is already declared")}for(var A=this.type.isLoop?"loop":this.type===types$1._switch?"switch":null,x=this.labels.length-1;x>=0;x--){var g=this.labels[x];if(g.statementStart===a.start)g.statementStart=this.start,g.kind=A;else break}return this.labels.push({name:s,kind:A,statementStart:this.start}),a.body=this.parseStatement(u?u.indexOf("label")===-1?u+"label":u:"label"),this.labels.pop(),a.label=c,this.finishNode(a,"LabeledStatement")},pp$8.parseExpressionStatement=function(a,s){return a.expression=s,this.semicolon(),this.finishNode(a,"ExpressionStatement")},pp$8.parseBlock=function(a,s,c){for(a===void 0&&(a=!0),s===void 0&&(s=this.startNode()),s.body=[],this.expect(types$1.braceL),a&&this.enterScope(0);this.type!==types$1.braceR;){var u=this.parseStatement(null);s.body.push(u)}return c&&(this.strict=!1),this.next(),a&&this.exitScope(),this.finishNode(s,"BlockStatement")},pp$8.parseFor=function(a,s){return a.init=s,this.expect(types$1.semi),a.test=this.type===types$1.semi?null:this.parseExpression(),this.expect(types$1.semi),a.update=this.type===types$1.parenR?null:this.parseExpression(),this.expect(types$1.parenR),a.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(a,"ForStatement")},pp$8.parseForIn=function(a,s){var c=this.type===types$1._in;return this.next(),s.type==="VariableDeclaration"&&s.declarations[0].init!=null&&(!c||this.options.ecmaVersion<8||this.strict||s.kind!=="var"||s.declarations[0].id.type!=="Identifier")&&this.raise(s.start,(c?"for-in":"for-of")+" loop variable declaration may not have an initializer"),a.left=s,a.right=c?this.parseExpression():this.parseMaybeAssign(),this.expect(types$1.parenR),a.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(a,c?"ForInStatement":"ForOfStatement")},pp$8.parseVar=function(a,s,c,u){for(a.declarations=[],a.kind=c;;){var d=this.startNode();if(this.parseVarId(d,c),this.eat(types$1.eq)?d.init=this.parseMaybeAssign(s):!u&&c==="const"&&!(this.type===types$1._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!u&&(c==="using"||c==="await using")&&this.options.ecmaVersion>=17&&this.type!==types$1._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+c+" declaration"):!u&&d.id.type!=="Identifier"&&!(s&&(this.type===types$1._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):d.init=null,a.declarations.push(this.finishNode(d,"VariableDeclarator")),!this.eat(types$1.comma))break}return a},pp$8.parseVarId=function(a,s){a.id=s==="using"||s==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(a.id,s==="var"?BIND_VAR:BIND_LEXICAL,!1)};var FUNC_STATEMENT=1,FUNC_HANGING_STATEMENT=2,FUNC_NULLABLE_ID=4;pp$8.parseFunction=function(a,s,c,u,d){this.initFunction(a),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!u)&&(this.type===types$1.star&&s&FUNC_HANGING_STATEMENT&&this.unexpected(),a.generator=this.eat(types$1.star)),this.options.ecmaVersion>=8&&(a.async=!!u),s&FUNC_STATEMENT&&(a.id=s&FUNC_NULLABLE_ID&&this.type!==types$1.name?null:this.parseIdent(),a.id&&!(s&FUNC_HANGING_STATEMENT)&&this.checkLValSimple(a.id,this.strict||a.generator||a.async?this.treatFunctionsAsVar?BIND_VAR:BIND_LEXICAL:BIND_FUNCTION));var p=this.yieldPos,v=this.awaitPos,A=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(functionFlags(a.async,a.generator)),s&FUNC_STATEMENT||(a.id=this.type===types$1.name?this.parseIdent():null),this.parseFunctionParams(a),this.parseFunctionBody(a,c,!1,d),this.yieldPos=p,this.awaitPos=v,this.awaitIdentPos=A,this.finishNode(a,s&FUNC_STATEMENT?"FunctionDeclaration":"FunctionExpression")},pp$8.parseFunctionParams=function(a){this.expect(types$1.parenL),a.params=this.parseBindingList(types$1.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},pp$8.parseClass=function(a,s){this.next();var c=this.strict;this.strict=!0,this.parseClassId(a,s),this.parseClassSuper(a);var u=this.enterClassBody(),d=this.startNode(),p=!1;for(d.body=[],this.expect(types$1.braceL);this.type!==types$1.braceR;){var v=this.parseClassElement(a.superClass!==null);v&&(d.body.push(v),v.type==="MethodDefinition"&&v.kind==="constructor"?(p&&this.raiseRecoverable(v.start,"Duplicate constructor in the same class"),p=!0):v.key&&v.key.type==="PrivateIdentifier"&&isPrivateNameConflicted(u,v)&&this.raiseRecoverable(v.key.start,"Identifier '#"+v.key.name+"' has already been declared"))}return this.strict=c,this.next(),a.body=this.finishNode(d,"ClassBody"),this.exitClassBody(),this.finishNode(a,s?"ClassDeclaration":"ClassExpression")},pp$8.parseClassElement=function(a){if(this.eat(types$1.semi))return null;var s=this.options.ecmaVersion,c=this.startNode(),u="",d=!1,p=!1,v="method",A=!1;if(this.eatContextual("static")){if(s>=13&&this.eat(types$1.braceL))return this.parseClassStaticBlock(c),c;this.isClassElementNameStart()||this.type===types$1.star?A=!0:u="static"}if(c.static=A,!u&&s>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===types$1.star)&&!this.canInsertSemicolon()?p=!0:u="async"),!u&&(s>=9||!p)&&this.eat(types$1.star)&&(d=!0),!u&&!p&&!d){var x=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?v=x:u=x)}if(u?(c.computed=!1,c.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),c.key.name=u,this.finishNode(c.key,"Identifier")):this.parseClassElementName(c),s<13||this.type===types$1.parenL||v!=="method"||d||p){var g=!c.static&&checkKeyName(c,"constructor"),b=g&&a;g&&v!=="method"&&this.raise(c.key.start,"Constructor can't have get/set modifier"),c.kind=g?"constructor":v,this.parseClassMethod(c,d,p,b)}else this.parseClassField(c);return c},pp$8.isClassElementNameStart=function(){return this.type===types$1.name||this.type===types$1.privateId||this.type===types$1.num||this.type===types$1.string||this.type===types$1.bracketL||this.type.keyword},pp$8.parseClassElementName=function(a){this.type===types$1.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),a.computed=!1,a.key=this.parsePrivateIdent()):this.parsePropertyName(a)},pp$8.parseClassMethod=function(a,s,c,u){var d=a.key;a.kind==="constructor"?(s&&this.raise(d.start,"Constructor can't be a generator"),c&&this.raise(d.start,"Constructor can't be an async method")):a.static&&checkKeyName(a,"prototype")&&this.raise(d.start,"Classes may not have a static property named prototype");var p=a.value=this.parseMethod(s,c,u);return a.kind==="get"&&p.params.length!==0&&this.raiseRecoverable(p.start,"getter should have no params"),a.kind==="set"&&p.params.length!==1&&this.raiseRecoverable(p.start,"setter should have exactly one param"),a.kind==="set"&&p.params[0].type==="RestElement"&&this.raiseRecoverable(p.params[0].start,"Setter cannot use rest params"),this.finishNode(a,"MethodDefinition")},pp$8.parseClassField=function(a){return checkKeyName(a,"constructor")?this.raise(a.key.start,"Classes can't have a field named 'constructor'"):a.static&&checkKeyName(a,"prototype")&&this.raise(a.key.start,"Classes can't have a static field named 'prototype'"),this.eat(types$1.eq)?(this.enterScope(SCOPE_CLASS_FIELD_INIT|SCOPE_SUPER),a.value=this.parseMaybeAssign(),this.exitScope()):a.value=null,this.semicolon(),this.finishNode(a,"PropertyDefinition")},pp$8.parseClassStaticBlock=function(a){a.body=[];var s=this.labels;for(this.labels=[],this.enterScope(SCOPE_CLASS_STATIC_BLOCK|SCOPE_SUPER);this.type!==types$1.braceR;){var c=this.parseStatement(null);a.body.push(c)}return this.next(),this.exitScope(),this.labels=s,this.finishNode(a,"StaticBlock")},pp$8.parseClassId=function(a,s){this.type===types$1.name?(a.id=this.parseIdent(),s&&this.checkLValSimple(a.id,BIND_LEXICAL,!1)):(s===!0&&this.unexpected(),a.id=null)},pp$8.parseClassSuper=function(a){a.superClass=this.eat(types$1._extends)?this.parseExprSubscripts(null,!1):null},pp$8.enterClassBody=function(){var a={declared:Object.create(null),used:[]};return this.privateNameStack.push(a),a.declared},pp$8.exitClassBody=function(){var a=this.privateNameStack.pop(),s=a.declared,c=a.used;if(this.options.checkPrivateFields)for(var u=this.privateNameStack.length,d=u===0?null:this.privateNameStack[u-1],p=0;p<c.length;++p){var v=c[p];hasOwn(s,v.name)||(d?d.used.push(v):this.raiseRecoverable(v.start,"Private field '#"+v.name+"' must be declared in an enclosing class"))}};function isPrivateNameConflicted(a,s){var c=s.key.name,u=a[c],d="true";return s.type==="MethodDefinition"&&(s.kind==="get"||s.kind==="set")&&(d=(s.static?"s":"i")+s.kind),u==="iget"&&d==="iset"||u==="iset"&&d==="iget"||u==="sget"&&d==="sset"||u==="sset"&&d==="sget"?(a[c]="true",!1):u?!0:(a[c]=d,!1)}function checkKeyName(a,s){var c=a.computed,u=a.key;return!c&&(u.type==="Identifier"&&u.name===s||u.type==="Literal"&&u.value===s)}pp$8.parseExportAllDeclaration=function(a,s){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(a.exported=this.parseModuleExportName(),this.checkExport(s,a.exported,this.lastTokStart)):a.exported=null),this.expectContextual("from"),this.type!==types$1.string&&this.unexpected(),a.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(a.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(a,"ExportAllDeclaration")},pp$8.parseExport=function(a,s){if(this.next(),this.eat(types$1.star))return this.parseExportAllDeclaration(a,s);if(this.eat(types$1._default))return this.checkExport(s,"default",this.lastTokStart),a.declaration=this.parseExportDefaultDeclaration(),this.finishNode(a,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())a.declaration=this.parseExportDeclaration(a),a.declaration.type==="VariableDeclaration"?this.checkVariableExport(s,a.declaration.declarations):this.checkExport(s,a.declaration.id,a.declaration.id.start),a.specifiers=[],a.source=null,this.options.ecmaVersion>=16&&(a.attributes=[]);else{if(a.declaration=null,a.specifiers=this.parseExportSpecifiers(s),this.eatContextual("from"))this.type!==types$1.string&&this.unexpected(),a.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(a.attributes=this.parseWithClause());else{for(var c=0,u=a.specifiers;c<u.length;c+=1){var d=u[c];this.checkUnreserved(d.local),this.checkLocalExport(d.local),d.local.type==="Literal"&&this.raise(d.local.start,"A string literal cannot be used as an exported binding without `from`.")}a.source=null,this.options.ecmaVersion>=16&&(a.attributes=[])}this.semicolon()}return this.finishNode(a,"ExportNamedDeclaration")},pp$8.parseExportDeclaration=function(a){return this.parseStatement(null)},pp$8.parseExportDefaultDeclaration=function(){var a;if(this.type===types$1._function||(a=this.isAsyncFunction())){var s=this.startNode();return this.next(),a&&this.next(),this.parseFunction(s,FUNC_STATEMENT|FUNC_NULLABLE_ID,!1,a)}else if(this.type===types$1._class){var c=this.startNode();return this.parseClass(c,"nullableID")}else{var u=this.parseMaybeAssign();return this.semicolon(),u}},pp$8.checkExport=function(a,s,c){a&&(typeof s!="string"&&(s=s.type==="Identifier"?s.name:s.value),hasOwn(a,s)&&this.raiseRecoverable(c,"Duplicate export '"+s+"'"),a[s]=!0)},pp$8.checkPatternExport=function(a,s){var c=s.type;if(c==="Identifier")this.checkExport(a,s,s.start);else if(c==="ObjectPattern")for(var u=0,d=s.properties;u<d.length;u+=1){var p=d[u];this.checkPatternExport(a,p)}else if(c==="ArrayPattern")for(var v=0,A=s.elements;v<A.length;v+=1){var x=A[v];x&&this.checkPatternExport(a,x)}else c==="Property"?this.checkPatternExport(a,s.value):c==="AssignmentPattern"?this.checkPatternExport(a,s.left):c==="RestElement"&&this.checkPatternExport(a,s.argument)},pp$8.checkVariableExport=function(a,s){if(a)for(var c=0,u=s;c<u.length;c+=1){var d=u[c];this.checkPatternExport(a,d.id)}},pp$8.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()},pp$8.parseExportSpecifier=function(a){var s=this.startNode();return s.local=this.parseModuleExportName(),s.exported=this.eatContextual("as")?this.parseModuleExportName():s.local,this.checkExport(a,s.exported,s.exported.start),this.finishNode(s,"ExportSpecifier")},pp$8.parseExportSpecifiers=function(a){var s=[],c=!0;for(this.expect(types$1.braceL);!this.eat(types$1.braceR);){if(c)c=!1;else if(this.expect(types$1.comma),this.afterTrailingComma(types$1.braceR))break;s.push(this.parseExportSpecifier(a))}return s},pp$8.parseImport=function(a){return this.next(),this.type===types$1.string?(a.specifiers=empty$1,a.source=this.parseExprAtom()):(a.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),a.source=this.type===types$1.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(a.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(a,"ImportDeclaration")},pp$8.parseImportSpecifier=function(){var a=this.startNode();return a.imported=this.parseModuleExportName(),this.eatContextual("as")?a.local=this.parseIdent():(this.checkUnreserved(a.imported),a.local=a.imported),this.checkLValSimple(a.local,BIND_LEXICAL),this.finishNode(a,"ImportSpecifier")},pp$8.parseImportDefaultSpecifier=function(){var a=this.startNode();return a.local=this.parseIdent(),this.checkLValSimple(a.local,BIND_LEXICAL),this.finishNode(a,"ImportDefaultSpecifier")},pp$8.parseImportNamespaceSpecifier=function(){var a=this.startNode();return this.next(),this.expectContextual("as"),a.local=this.parseIdent(),this.checkLValSimple(a.local,BIND_LEXICAL),this.finishNode(a,"ImportNamespaceSpecifier")},pp$8.parseImportSpecifiers=function(){var a=[],s=!0;if(this.type===types$1.name&&(a.push(this.parseImportDefaultSpecifier()),!this.eat(types$1.comma)))return a;if(this.type===types$1.star)return a.push(this.parseImportNamespaceSpecifier()),a;for(this.expect(types$1.braceL);!this.eat(types$1.braceR);){if(s)s=!1;else if(this.expect(types$1.comma),this.afterTrailingComma(types$1.braceR))break;a.push(this.parseImportSpecifier())}return a},pp$8.parseWithClause=function(){var a=[];if(!this.eat(types$1._with))return a;this.expect(types$1.braceL);for(var s={},c=!0;!this.eat(types$1.braceR);){if(c)c=!1;else if(this.expect(types$1.comma),this.afterTrailingComma(types$1.braceR))break;var u=this.parseImportAttribute(),d=u.key.type==="Identifier"?u.key.name:u.key.value;hasOwn(s,d)&&this.raiseRecoverable(u.key.start,"Duplicate attribute key '"+d+"'"),s[d]=!0,a.push(u)}return a},pp$8.parseImportAttribute=function(){var a=this.startNode();return a.key=this.type===types$1.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(types$1.colon),this.type!==types$1.string&&this.unexpected(),a.value=this.parseExprAtom(),this.finishNode(a,"ImportAttribute")},pp$8.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===types$1.string){var a=this.parseLiteral(this.value);return loneSurrogate.test(a.value)&&this.raise(a.start,"An export name cannot include a lone surrogate."),a}return this.parseIdent(!0)},pp$8.adaptDirectivePrologue=function(a){for(var s=0;s<a.length&&this.isDirectiveCandidate(a[s]);++s)a[s].directive=a[s].expression.raw.slice(1,-1)},pp$8.isDirectiveCandidate=function(a){return this.options.ecmaVersion>=5&&a.type==="ExpressionStatement"&&a.expression.type==="Literal"&&typeof a.expression.value=="string"&&(this.input[a.start]==='"'||this.input[a.start]==="'")};var pp$7=Parser.prototype;pp$7.toAssignable=function(a,s,c){if(this.options.ecmaVersion>=6&&a)switch(a.type){case"Identifier":this.inAsync&&a.name==="await"&&this.raise(a.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":a.type="ObjectPattern",c&&this.checkPatternErrors(c,!0);for(var u=0,d=a.properties;u<d.length;u+=1){var p=d[u];this.toAssignable(p,s),p.type==="RestElement"&&(p.argument.type==="ArrayPattern"||p.argument.type==="ObjectPattern")&&this.raise(p.argument.start,"Unexpected token")}break;case"Property":a.kind!=="init"&&this.raise(a.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(a.value,s);break;case"ArrayExpression":a.type="ArrayPattern",c&&this.checkPatternErrors(c,!0),this.toAssignableList(a.elements,s);break;case"SpreadElement":a.type="RestElement",this.toAssignable(a.argument,s),a.argument.type==="AssignmentPattern"&&this.raise(a.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":a.operator!=="="&&this.raise(a.left.end,"Only '=' operator can be used for specifying default value."),a.type="AssignmentPattern",delete a.operator,this.toAssignable(a.left,s);break;case"ParenthesizedExpression":this.toAssignable(a.expression,s,c);break;case"ChainExpression":this.raiseRecoverable(a.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!s)break;default:this.raise(a.start,"Assigning to rvalue")}else c&&this.checkPatternErrors(c,!0);return a},pp$7.toAssignableList=function(a,s){for(var c=a.length,u=0;u<c;u++){var d=a[u];d&&this.toAssignable(d,s)}if(c){var p=a[c-1];this.options.ecmaVersion===6&&s&&p&&p.type==="RestElement"&&p.argument.type!=="Identifier"&&this.unexpected(p.argument.start)}return a},pp$7.parseSpread=function(a){var s=this.startNode();return this.next(),s.argument=this.parseMaybeAssign(!1,a),this.finishNode(s,"SpreadElement")},pp$7.parseRestBinding=function(){var a=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==types$1.name&&this.unexpected(),a.argument=this.parseBindingAtom(),this.finishNode(a,"RestElement")},pp$7.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case types$1.bracketL:var a=this.startNode();return this.next(),a.elements=this.parseBindingList(types$1.bracketR,!0,!0),this.finishNode(a,"ArrayPattern");case types$1.braceL:return this.parseObj(!0)}return this.parseIdent()},pp$7.parseBindingList=function(a,s,c,u){for(var d=[],p=!0;!this.eat(a);)if(p?p=!1:this.expect(types$1.comma),s&&this.type===types$1.comma)d.push(null);else{if(c&&this.afterTrailingComma(a))break;if(this.type===types$1.ellipsis){var v=this.parseRestBinding();this.parseBindingListItem(v),d.push(v),this.type===types$1.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(a);break}else d.push(this.parseAssignableListItem(u))}return d},pp$7.parseAssignableListItem=function(a){var s=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(s),s},pp$7.parseBindingListItem=function(a){return a},pp$7.parseMaybeDefault=function(a,s,c){if(c=c||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(types$1.eq))return c;var u=this.startNodeAt(a,s);return u.left=c,u.right=this.parseMaybeAssign(),this.finishNode(u,"AssignmentPattern")},pp$7.checkLValSimple=function(a,s,c){s===void 0&&(s=BIND_NONE);var u=s!==BIND_NONE;switch(a.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(a.name)&&this.raiseRecoverable(a.start,(u?"Binding ":"Assigning to ")+a.name+" in strict mode"),u&&(s===BIND_LEXICAL&&a.name==="let"&&this.raiseRecoverable(a.start,"let is disallowed as a lexically bound name"),c&&(hasOwn(c,a.name)&&this.raiseRecoverable(a.start,"Argument name clash"),c[a.name]=!0),s!==BIND_OUTSIDE&&this.declareName(a.name,s,a.start));break;case"ChainExpression":this.raiseRecoverable(a.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":u&&this.raiseRecoverable(a.start,"Binding member expression");break;case"ParenthesizedExpression":return u&&this.raiseRecoverable(a.start,"Binding parenthesized expression"),this.checkLValSimple(a.expression,s,c);default:this.raise(a.start,(u?"Binding":"Assigning to")+" rvalue")}},pp$7.checkLValPattern=function(a,s,c){switch(s===void 0&&(s=BIND_NONE),a.type){case"ObjectPattern":for(var u=0,d=a.properties;u<d.length;u+=1){var p=d[u];this.checkLValInnerPattern(p,s,c)}break;case"ArrayPattern":for(var v=0,A=a.elements;v<A.length;v+=1){var x=A[v];x&&this.checkLValInnerPattern(x,s,c)}break;default:this.checkLValSimple(a,s,c)}},pp$7.checkLValInnerPattern=function(a,s,c){switch(s===void 0&&(s=BIND_NONE),a.type){case"Property":this.checkLValInnerPattern(a.value,s,c);break;case"AssignmentPattern":this.checkLValPattern(a.left,s,c);break;case"RestElement":this.checkLValPattern(a.argument,s,c);break;default:this.checkLValPattern(a,s,c)}};var TokContext=function(s,c,u,d,p){this.token=s,this.isExpr=!!c,this.preserveSpace=!!u,this.override=d,this.generator=!!p},types$2={b_stat:new TokContext("{",!1),b_expr:new TokContext("{",!0),b_tmpl:new TokContext("${",!1),p_stat:new TokContext("(",!1),p_expr:new TokContext("(",!0),q_tmpl:new TokContext("`",!0,!0,function(a){return a.tryReadTemplateToken()}),f_stat:new TokContext("function",!1),f_expr:new TokContext("function",!0),f_expr_gen:new TokContext("function",!0,!1,null,!0),f_gen:new TokContext("function",!1,!1,null,!0)},pp$6=Parser.prototype;pp$6.initialContext=function(){return[types$2.b_stat]},pp$6.curContext=function(){return this.context[this.context.length-1]},pp$6.braceIsBlock=function(a){var s=this.curContext();return s===types$2.f_expr||s===types$2.f_stat?!0:a===types$1.colon&&(s===types$2.b_stat||s===types$2.b_expr)?!s.isExpr:a===types$1._return||a===types$1.name&&this.exprAllowed?lineBreak.test(this.input.slice(this.lastTokEnd,this.start)):a===types$1._else||a===types$1.semi||a===types$1.eof||a===types$1.parenR||a===types$1.arrow?!0:a===types$1.braceL?s===types$2.b_stat:a===types$1._var||a===types$1._const||a===types$1.name?!1:!this.exprAllowed},pp$6.inGeneratorContext=function(){for(var a=this.context.length-1;a>=1;a--){var s=this.context[a];if(s.token==="function")return s.generator}return!1},pp$6.updateContext=function(a){var s,c=this.type;c.keyword&&a===types$1.dot?this.exprAllowed=!1:(s=c.updateContext)?s.call(this,a):this.exprAllowed=c.beforeExpr},pp$6.overrideContext=function(a){this.curContext()!==a&&(this.context[this.context.length-1]=a)},types$1.parenR.updateContext=types$1.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var a=this.context.pop();a===types$2.b_stat&&this.curContext().token==="function"&&(a=this.context.pop()),this.exprAllowed=!a.isExpr},types$1.braceL.updateContext=function(a){this.context.push(this.braceIsBlock(a)?types$2.b_stat:types$2.b_expr),this.exprAllowed=!0},types$1.dollarBraceL.updateContext=function(){this.context.push(types$2.b_tmpl),this.exprAllowed=!0},types$1.parenL.updateContext=function(a){var s=a===types$1._if||a===types$1._for||a===types$1._with||a===types$1._while;this.context.push(s?types$2.p_stat:types$2.p_expr),this.exprAllowed=!0},types$1.incDec.updateContext=function(){},types$1._function.updateContext=types$1._class.updateContext=function(a){a.beforeExpr&&a!==types$1._else&&!(a===types$1.semi&&this.curContext()!==types$2.p_stat)&&!(a===types$1._return&&lineBreak.test(this.input.slice(this.lastTokEnd,this.start)))&&!((a===types$1.colon||a===types$1.braceL)&&this.curContext()===types$2.b_stat)?this.context.push(types$2.f_expr):this.context.push(types$2.f_stat),this.exprAllowed=!1},types$1.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0},types$1.backQuote.updateContext=function(){this.curContext()===types$2.q_tmpl?this.context.pop():this.context.push(types$2.q_tmpl),this.exprAllowed=!1},types$1.star.updateContext=function(a){if(a===types$1._function){var s=this.context.length-1;this.context[s]===types$2.f_expr?this.context[s]=types$2.f_expr_gen:this.context[s]=types$2.f_gen}this.exprAllowed=!0},types$1.name.updateContext=function(a){var s=!1;this.options.ecmaVersion>=6&&a!==types$1.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(s=!0),this.exprAllowed=s};var pp$5=Parser.prototype;pp$5.checkPropClash=function(a,s,c){if(!(this.options.ecmaVersion>=9&&a.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(a.computed||a.method||a.shorthand))){var u=a.key,d;switch(u.type){case"Identifier":d=u.name;break;case"Literal":d=String(u.value);break;default:return}var p=a.kind;if(this.options.ecmaVersion>=6){d==="__proto__"&&p==="init"&&(s.proto&&(c?c.doubleProto<0&&(c.doubleProto=u.start):this.raiseRecoverable(u.start,"Redefinition of __proto__ property")),s.proto=!0);return}d="$"+d;var v=s[d];if(v){var A;p==="init"?A=this.strict&&v.init||v.get||v.set:A=v.init||v[p],A&&this.raiseRecoverable(u.start,"Redefinition of property")}else v=s[d]={init:!1,get:!1,set:!1};v[p]=!0}},pp$5.parseExpression=function(a,s){var c=this.start,u=this.startLoc,d=this.parseMaybeAssign(a,s);if(this.type===types$1.comma){var p=this.startNodeAt(c,u);for(p.expressions=[d];this.eat(types$1.comma);)p.expressions.push(this.parseMaybeAssign(a,s));return this.finishNode(p,"SequenceExpression")}return d},pp$5.parseMaybeAssign=function(a,s,c){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(a);this.exprAllowed=!1}var u=!1,d=-1,p=-1,v=-1;s?(d=s.parenthesizedAssign,p=s.trailingComma,v=s.doubleProto,s.parenthesizedAssign=s.trailingComma=-1):(s=new DestructuringErrors,u=!0);var A=this.start,x=this.startLoc;(this.type===types$1.parenL||this.type===types$1.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=a==="await");var g=this.parseMaybeConditional(a,s);if(c&&(g=c.call(this,g,A,x)),this.type.isAssign){var b=this.startNodeAt(A,x);return b.operator=this.value,this.type===types$1.eq&&(g=this.toAssignable(g,!1,s)),u||(s.parenthesizedAssign=s.trailingComma=s.doubleProto=-1),s.shorthandAssign>=g.start&&(s.shorthandAssign=-1),this.type===types$1.eq?this.checkLValPattern(g):this.checkLValSimple(g),b.left=g,this.next(),b.right=this.parseMaybeAssign(a),v>-1&&(s.doubleProto=v),this.finishNode(b,"AssignmentExpression")}else u&&this.checkExpressionErrors(s,!0);return d>-1&&(s.parenthesizedAssign=d),p>-1&&(s.trailingComma=p),g},pp$5.parseMaybeConditional=function(a,s){var c=this.start,u=this.startLoc,d=this.parseExprOps(a,s);if(this.checkExpressionErrors(s))return d;if(this.eat(types$1.question)){var p=this.startNodeAt(c,u);return p.test=d,p.consequent=this.parseMaybeAssign(),this.expect(types$1.colon),p.alternate=this.parseMaybeAssign(a),this.finishNode(p,"ConditionalExpression")}return d},pp$5.parseExprOps=function(a,s){var c=this.start,u=this.startLoc,d=this.parseMaybeUnary(s,!1,!1,a);return this.checkExpressionErrors(s)||d.start===c&&d.type==="ArrowFunctionExpression"?d:this.parseExprOp(d,c,u,-1,a)},pp$5.parseExprOp=function(a,s,c,u,d){var p=this.type.binop;if(p!=null&&(!d||this.type!==types$1._in)&&p>u){var v=this.type===types$1.logicalOR||this.type===types$1.logicalAND,A=this.type===types$1.coalesce;A&&(p=types$1.logicalAND.binop);var x=this.value;this.next();var g=this.start,b=this.startLoc,y=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,d),g,b,p,d),f=this.buildBinary(s,c,a,y,x,v||A);return(v&&this.type===types$1.coalesce||A&&(this.type===types$1.logicalOR||this.type===types$1.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(f,s,c,u,d)}return a},pp$5.buildBinary=function(a,s,c,u,d,p){u.type==="PrivateIdentifier"&&this.raise(u.start,"Private identifier can only be left side of binary expression");var v=this.startNodeAt(a,s);return v.left=c,v.operator=d,v.right=u,this.finishNode(v,p?"LogicalExpression":"BinaryExpression")},pp$5.parseMaybeUnary=function(a,s,c,u){var d=this.start,p=this.startLoc,v;if(this.isContextual("await")&&this.canAwait)v=this.parseAwait(u),s=!0;else if(this.type.prefix){var A=this.startNode(),x=this.type===types$1.incDec;A.operator=this.value,A.prefix=!0,this.next(),A.argument=this.parseMaybeUnary(null,!0,x,u),this.checkExpressionErrors(a,!0),x?this.checkLValSimple(A.argument):this.strict&&A.operator==="delete"&&isLocalVariableAccess(A.argument)?this.raiseRecoverable(A.start,"Deleting local variable in strict mode"):A.operator==="delete"&&isPrivateFieldAccess(A.argument)?this.raiseRecoverable(A.start,"Private fields can not be deleted"):s=!0,v=this.finishNode(A,x?"UpdateExpression":"UnaryExpression")}else if(!s&&this.type===types$1.privateId)(u||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),v=this.parsePrivateIdent(),this.type!==types$1._in&&this.unexpected();else{if(v=this.parseExprSubscripts(a,u),this.checkExpressionErrors(a))return v;for(;this.type.postfix&&!this.canInsertSemicolon();){var g=this.startNodeAt(d,p);g.operator=this.value,g.prefix=!1,g.argument=v,this.checkLValSimple(v),this.next(),v=this.finishNode(g,"UpdateExpression")}}if(!c&&this.eat(types$1.starstar))if(s)this.unexpected(this.lastTokStart);else return this.buildBinary(d,p,v,this.parseMaybeUnary(null,!1,!1,u),"**",!1);else return v};function isLocalVariableAccess(a){return a.type==="Identifier"||a.type==="ParenthesizedExpression"&&isLocalVariableAccess(a.expression)}function isPrivateFieldAccess(a){return a.type==="MemberExpression"&&a.property.type==="PrivateIdentifier"||a.type==="ChainExpression"&&isPrivateFieldAccess(a.expression)||a.type==="ParenthesizedExpression"&&isPrivateFieldAccess(a.expression)}pp$5.parseExprSubscripts=function(a,s){var c=this.start,u=this.startLoc,d=this.parseExprAtom(a,s);if(d.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return d;var p=this.parseSubscripts(d,c,u,!1,s);return a&&p.type==="MemberExpression"&&(a.parenthesizedAssign>=p.start&&(a.parenthesizedAssign=-1),a.parenthesizedBind>=p.start&&(a.parenthesizedBind=-1),a.trailingComma>=p.start&&(a.trailingComma=-1)),p},pp$5.parseSubscripts=function(a,s,c,u,d){for(var p=this.options.ecmaVersion>=8&&a.type==="Identifier"&&a.name==="async"&&this.lastTokEnd===a.end&&!this.canInsertSemicolon()&&a.end-a.start===5&&this.potentialArrowAt===a.start,v=!1;;){var A=this.parseSubscript(a,s,c,u,p,v,d);if(A.optional&&(v=!0),A===a||A.type==="ArrowFunctionExpression"){if(v){var x=this.startNodeAt(s,c);x.expression=A,A=this.finishNode(x,"ChainExpression")}return A}a=A}},pp$5.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(types$1.arrow)},pp$5.parseSubscriptAsyncArrow=function(a,s,c,u){return this.parseArrowExpression(this.startNodeAt(a,s),c,!0,u)},pp$5.parseSubscript=function(a,s,c,u,d,p,v){var A=this.options.ecmaVersion>=11,x=A&&this.eat(types$1.questionDot);u&&x&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var g=this.eat(types$1.bracketL);if(g||x&&this.type!==types$1.parenL&&this.type!==types$1.backQuote||this.eat(types$1.dot)){var b=this.startNodeAt(s,c);b.object=a,g?(b.property=this.parseExpression(),this.expect(types$1.bracketR)):this.type===types$1.privateId&&a.type!=="Super"?b.property=this.parsePrivateIdent():b.property=this.parseIdent(this.options.allowReserved!=="never"),b.computed=!!g,A&&(b.optional=x),a=this.finishNode(b,"MemberExpression")}else if(!u&&this.eat(types$1.parenL)){var y=new DestructuringErrors,f=this.yieldPos,m=this.awaitPos,E=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var w=this.parseExprList(types$1.parenR,this.options.ecmaVersion>=8,!1,y);if(d&&!x&&this.shouldParseAsyncArrow())return this.checkPatternErrors(y,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=f,this.awaitPos=m,this.awaitIdentPos=E,this.parseSubscriptAsyncArrow(s,c,w,v);this.checkExpressionErrors(y,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=m||this.awaitPos,this.awaitIdentPos=E||this.awaitIdentPos;var S=this.startNodeAt(s,c);S.callee=a,S.arguments=w,A&&(S.optional=x),a=this.finishNode(S,"CallExpression")}else if(this.type===types$1.backQuote){(x||p)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var $=this.startNodeAt(s,c);$.tag=a,$.quasi=this.parseTemplate({isTagged:!0}),a=this.finishNode($,"TaggedTemplateExpression")}return a},pp$5.parseExprAtom=function(a,s,c){this.type===types$1.slash&&this.readRegexp();var u,d=this.potentialArrowAt===this.start;switch(this.type){case types$1._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),u=this.startNode(),this.next(),this.type===types$1.parenL&&!this.allowDirectSuper&&this.raise(u.start,"super() call outside constructor of a subclass"),this.type!==types$1.dot&&this.type!==types$1.bracketL&&this.type!==types$1.parenL&&this.unexpected(),this.finishNode(u,"Super");case types$1._this:return u=this.startNode(),this.next(),this.finishNode(u,"ThisExpression");case types$1.name:var p=this.start,v=this.startLoc,A=this.containsEsc,x=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!A&&x.name==="async"&&!this.canInsertSemicolon()&&this.eat(types$1._function))return this.overrideContext(types$2.f_expr),this.parseFunction(this.startNodeAt(p,v),0,!1,!0,s);if(d&&!this.canInsertSemicolon()){if(this.eat(types$1.arrow))return this.parseArrowExpression(this.startNodeAt(p,v),[x],!1,s);if(this.options.ecmaVersion>=8&&x.name==="async"&&this.type===types$1.name&&!A&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return x=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(types$1.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(p,v),[x],!0,s)}return x;case types$1.regexp:var g=this.value;return u=this.parseLiteral(g.value),u.regex={pattern:g.pattern,flags:g.flags},u;case types$1.num:case types$1.string:return this.parseLiteral(this.value);case types$1._null:case types$1._true:case types$1._false:return u=this.startNode(),u.value=this.type===types$1._null?null:this.type===types$1._true,u.raw=this.type.keyword,this.next(),this.finishNode(u,"Literal");case types$1.parenL:var b=this.start,y=this.parseParenAndDistinguishExpression(d,s);return a&&(a.parenthesizedAssign<0&&!this.isSimpleAssignTarget(y)&&(a.parenthesizedAssign=b),a.parenthesizedBind<0&&(a.parenthesizedBind=b)),y;case types$1.bracketL:return u=this.startNode(),this.next(),u.elements=this.parseExprList(types$1.bracketR,!0,!0,a),this.finishNode(u,"ArrayExpression");case types$1.braceL:return this.overrideContext(types$2.b_expr),this.parseObj(!1,a);case types$1._function:return u=this.startNode(),this.next(),this.parseFunction(u,0);case types$1._class:return this.parseClass(this.startNode(),!1);case types$1._new:return this.parseNew();case types$1.backQuote:return this.parseTemplate();case types$1._import:return this.options.ecmaVersion>=11?this.parseExprImport(c):this.unexpected();default:return this.parseExprAtomDefault()}},pp$5.parseExprAtomDefault=function(){this.unexpected()},pp$5.parseExprImport=function(a){var s=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===types$1.parenL&&!a)return this.parseDynamicImport(s);if(this.type===types$1.dot){var c=this.startNodeAt(s.start,s.loc&&s.loc.start);return c.name="import",s.meta=this.finishNode(c,"Identifier"),this.parseImportMeta(s)}else this.unexpected()},pp$5.parseDynamicImport=function(a){if(this.next(),a.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(types$1.parenR)?a.options=null:(this.expect(types$1.comma),this.afterTrailingComma(types$1.parenR)?a.options=null:(a.options=this.parseMaybeAssign(),this.eat(types$1.parenR)||(this.expect(types$1.comma),this.afterTrailingComma(types$1.parenR)||this.unexpected())));else if(!this.eat(types$1.parenR)){var s=this.start;this.eat(types$1.comma)&&this.eat(types$1.parenR)?this.raiseRecoverable(s,"Trailing comma is not allowed in import()"):this.unexpected(s)}return this.finishNode(a,"ImportExpression")},pp$5.parseImportMeta=function(a){this.next();var s=this.containsEsc;return a.property=this.parseIdent(!0),a.property.name!=="meta"&&this.raiseRecoverable(a.property.start,"The only valid meta property for import is 'import.meta'"),s&&this.raiseRecoverable(a.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(a.start,"Cannot use 'import.meta' outside a module"),this.finishNode(a,"MetaProperty")},pp$5.parseLiteral=function(a){var s=this.startNode();return s.value=a,s.raw=this.input.slice(this.start,this.end),s.raw.charCodeAt(s.raw.length-1)===110&&(s.bigint=s.value!=null?s.value.toString():s.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(s,"Literal")},pp$5.parseParenExpression=function(){this.expect(types$1.parenL);var a=this.parseExpression();return this.expect(types$1.parenR),a},pp$5.shouldParseArrow=function(a){return!this.canInsertSemicolon()},pp$5.parseParenAndDistinguishExpression=function(a,s){var c=this.start,u=this.startLoc,d,p=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var v=this.start,A=this.startLoc,x=[],g=!0,b=!1,y=new DestructuringErrors,f=this.yieldPos,m=this.awaitPos,E;for(this.yieldPos=0,this.awaitPos=0;this.type!==types$1.parenR;)if(g?g=!1:this.expect(types$1.comma),p&&this.afterTrailingComma(types$1.parenR,!0)){b=!0;break}else if(this.type===types$1.ellipsis){E=this.start,x.push(this.parseParenItem(this.parseRestBinding())),this.type===types$1.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else x.push(this.parseMaybeAssign(!1,y,this.parseParenItem));var w=this.lastTokEnd,S=this.lastTokEndLoc;if(this.expect(types$1.parenR),a&&this.shouldParseArrow(x)&&this.eat(types$1.arrow))return this.checkPatternErrors(y,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=m,this.parseParenArrowList(c,u,x,s);(!x.length||b)&&this.unexpected(this.lastTokStart),E&&this.unexpected(E),this.checkExpressionErrors(y,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=m||this.awaitPos,x.length>1?(d=this.startNodeAt(v,A),d.expressions=x,this.finishNodeAt(d,"SequenceExpression",w,S)):d=x[0]}else d=this.parseParenExpression();if(this.options.preserveParens){var $=this.startNodeAt(c,u);return $.expression=d,this.finishNode($,"ParenthesizedExpression")}else return d},pp$5.parseParenItem=function(a){return a},pp$5.parseParenArrowList=function(a,s,c,u){return this.parseArrowExpression(this.startNodeAt(a,s),c,!1,u)};var empty$2=[];pp$5.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var a=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===types$1.dot){var s=this.startNodeAt(a.start,a.loc&&a.loc.start);s.name="new",a.meta=this.finishNode(s,"Identifier"),this.next();var c=this.containsEsc;return a.property=this.parseIdent(!0),a.property.name!=="target"&&this.raiseRecoverable(a.property.start,"The only valid meta property for new is 'new.target'"),c&&this.raiseRecoverable(a.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(a.start,"'new.target' can only be used in functions and class static block"),this.finishNode(a,"MetaProperty")}var u=this.start,d=this.startLoc;return a.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),u,d,!0,!1),this.eat(types$1.parenL)?a.arguments=this.parseExprList(types$1.parenR,this.options.ecmaVersion>=8,!1):a.arguments=empty$2,this.finishNode(a,"NewExpression")},pp$5.parseTemplateElement=function(a){var s=a.isTagged,c=this.startNode();return this.type===types$1.invalidTemplate?(s||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),c.value={raw:this.value.replace(/\r\n?/g,`
|
|
35
35
|
`),cooked:null}):c.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
|
@@ -1038,4 +1038,4 @@ canvas {
|
|
|
1038
1038
|
transform: rotate(360deg);
|
|
1039
1039
|
}
|
|
1040
1040
|
}
|
|
1041
|
-
`}),jsxRuntimeExports.jsx("div",{style:s,children:jsxRuntimeExports.jsx(LoaderCircle,{size:50,style:c})})]})},Root$1=({size:a,scale:s,children:c},u)=>{const d=reactExports.useContext(FontContext);return reactExports.useEffect(()=>{if(!document||!document.fonts)return;const v=Object.entries(d).map(([A,{data:x}])=>new FontFace(A,typeof x=="string"?`url(${x})`:x,{display:"swap"})).filter(A=>!document.fonts.has(A));Promise.allSettled(v.map(A=>A.load())).then(A=>{A.forEach(x=>{x.status==="fulfilled"&&document.fonts.add(x.value)})})},[d]),jsxRuntimeExports.jsx("div",{className:DESIGNER_CLASSNAME+"root",ref:u,style:{position:"relative",background:BACKGROUND_COLOR,...a},children:jsxRuntimeExports.jsx("div",{className:DESIGNER_CLASSNAME+"background",style:{margin:"0 auto",...a},children:s===0?jsxRuntimeExports.jsx(Spinner,{}):c})})},Root=reactExports.forwardRef(Root$1),ErrorScreen=({size:a,error:s})=>{const c=reactExports.useContext(I18nContext),{token:u}=theme.useToken();return jsxRuntimeExports.jsx("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",background:BACKGROUND_COLOR,...a},children:jsxRuntimeExports.jsx("div",{style:{width:300,margin:"0 auto",background:u.colorBgLayout},children:jsxRuntimeExports.jsx(Result$1,{icon:null,title:"ERROR",subTitle:c("errorOccurred"),extra:jsxRuntimeExports.jsx("span",{children:s.message})})})})},{Text:Text$1}=Typography,Zoom=({zoomLevel:a,setZoomLevel:s,style:c})=>{const d=useMaxZoom(),p=.25,v=a-.25,A=a+.25;return jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(Button$1,{className:UI_CLASSNAME+"zoom-out",type:"text",disabled:p>=v,onClick:()=>s(v),icon:jsxRuntimeExports.jsx(Minus,{size:16,color:c.textStyle.color})}),jsxRuntimeExports.jsxs(Text$1,{strong:!0,style:c.textStyle,children:[Math.round(a*100),"%"]}),jsxRuntimeExports.jsx(Button$1,{className:UI_CLASSNAME+"zoom-in",type:"text",disabled:d<A,onClick:()=>s(A),icon:jsxRuntimeExports.jsx(Plus,{size:16,color:c.textStyle.color})})]})},Pager=({pageCursor:a,pageNum:s,setPageCursor:c,style:u})=>jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(Button$1,{className:UI_CLASSNAME+"page-prev",type:"text",disabled:a<=0,onClick:()=>c(a-1),children:jsxRuntimeExports.jsx(ChevronLeft,{size:16,color:u.textStyle.color})}),jsxRuntimeExports.jsxs(Text$1,{strong:!0,style:u.textStyle,children:[a+1,"/",s]}),jsxRuntimeExports.jsx(Button$1,{className:UI_CLASSNAME+"page-next",type:"text",disabled:a+1>=s,onClick:()=>c(a+1),children:jsxRuntimeExports.jsx(ChevronRight,{size:16,color:u.textStyle.color})})]}),ContextMenu=({items:a,style:s})=>jsxRuntimeExports.jsx(Dropdown,{menu:{items:a},placement:"top",arrow:!0,trigger:["click"],children:jsxRuntimeExports.jsx(Button$1,{className:UI_CLASSNAME+"context-menu",type:"text",children:jsxRuntimeExports.jsx(Ellipsis,{size:16,color:s.textStyle.color})})}),CtlBar=a=>{const{token:s}=theme.useToken(),c=reactExports.useContext(I18nContext),{size:u,pageCursor:d,pageNum:p,setPageCursor:v,zoomLevel:A,setZoomLevel:x,addPageAfter:g,removePage:b}=a,y=[];g&&y.push({key:"1",label:jsxRuntimeExports.jsx("div",{onClick:g,children:c("addPageAfter")})}),b&&p>1&&d!==0&&y.push({key:"2",label:jsxRuntimeExports.jsx("div",{onClick:b,children:c("removePage")})});const f=300,m=y.length>0?50:0,E=(p>1?f:f/2)+m,w={color:s.colorWhite,fontSize:s.fontSize,margin:s.marginXS};return jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:"auto",bottom:"6%",width:u.width},children:jsxRuntimeExports.jsxs("div",{className:UI_CLASSNAME+"control-bar",style:{display:"flex",alignItems:"center",justifyContent:"space-evenly",position:"relative",zIndex:1,left:`calc(50% - ${E/2}px)`,width:E,height:40,boxSizing:"border-box",padding:s.paddingSM,borderRadius:s.borderRadius,backgroundColor:s.colorBgMask},children:[p>1&&jsxRuntimeExports.jsx("div",{className:UI_CLASSNAME+"pager",children:jsxRuntimeExports.jsx(Pager,{style:{textStyle:w},pageCursor:d,pageNum:p,setPageCursor:v})}),jsxRuntimeExports.jsx("div",{className:UI_CLASSNAME+"zoom",children:jsxRuntimeExports.jsx(Zoom,{style:{textStyle:w},zoomLevel:A,setZoomLevel:x})}),y.length>0&&jsxRuntimeExports.jsx(ContextMenu,{items:y,style:{textStyle:w}})]})})},scaleDragPosAdjustment=(a,s)=>s>1?a*(s-1):s<1?a*-(1-s):0,TemplateEditor=({template:a,size:s,onSaveTemplate:c,onChangeTemplate:u,onPageCursorChange:d})=>{const p=reactExports.useRef([]),v=reactExports.useRef([]),A=reactExports.useRef(null),x=reactExports.useRef([]),g=reactExports.useContext(I18nContext),b=reactExports.useContext(PluginsRegistry),y=reactExports.useContext(OptionsContext),f=useMaxZoom(),[m,E]=reactExports.useState(null),[w,S]=reactExports.useState([]),[$,T]=reactExports.useState([[]]),[I,_]=reactExports.useState(0),[C,P]=reactExports.useState(y.zoomLevel??1),[O,L]=reactExports.useState(y.sidebarOpen??!0),[B,F]=reactExports.useState(null),{backgrounds:D,pageSizes:V,scale:j,error:G,refresh:U}=useUIPreProcessor({template:a,size:s,zoomLevel:C,maxZoom:f}),M=ae=>{S(ae),E(null)},N=()=>{S([]),E(null)};reactExports.useEffect(()=>{typeof y.zoomLevel=="number"&&y.zoomLevel!==C&&P(y.zoomLevel),typeof y.sidebarOpen=="boolean"&&y.sidebarOpen!==O&&L(y.sidebarOpen)},[y]),useScrollPageCursor({ref:A,pageSizes:V,scale:j,pageCursor:I,onChangePageCursor:ae=>{_(ae),d(ae,$.length),N()}});const R=reactExports.useCallback(ae=>{v.current=[],p.current.push(cloneDeep$1($[I]));const oe=cloneDeep$1($);oe[I]=ae,T(oe),u(schemasList2template(oe,a.basePdf))},[a,$,I,u]),k=reactExports.useCallback(ae=>{R($[I].filter(oe=>!ae.includes(oe.id))),N()},[$,I,R]),H=reactExports.useCallback(ae=>{changeSchemas({objs:ae,schemas:$[I],basePdf:a.basePdf,pluginsRegistry:b,pageSize:V[I],commitSchemas:R})},[R,I,$,b,V,a.basePdf]);useInitEvents({pageCursor:I,pageSizes:V,activeElements:w,template:a,schemasList:$,changeSchemas:H,commitSchemas:R,removeSchemas:k,onSaveTemplate:c,past:p,future:v,setSchemasList:T,onEdit:M,onEditEnd:N});const W=reactExports.useCallback(async ae=>{const oe=await template2SchemasList(ae);T(oe),N(),_(0),A.current?.scroll&&A.current.scroll({top:0,behavior:"smooth"})},[]),J=ae=>{const[oe,se,fe,pe]=isBlankPdf(a.basePdf)?a.basePdf.padding:[0,0,0,0],ge=V[I],me=ve=>{let he=$.reduce((Ee,xe)=>Ee+xe.length,1),ye=ve+he;for(;$.some(Ee=>Ee.find(xe=>xe.name===ye));)he++,ye=ve+he;return ye},be=(ve,he,ye)=>Math.min(Math.max(ve,he),ye),le={id:uuid$6(),...ae,name:me(g("field")),position:{x:be(pe,ae.position.x,ge.width-se-ae.width),y:be(oe,ae.position.y,ge.height-fe-ae.height)},required:ae.readOnly?!1:y.requiredByDefault||ae.required||!1};if(ae.position.y===0){const ve=x.current[I],he=ve?ve.getBoundingClientRect().top:0;le.position.y=he>0?oe:V[I].height/2}R($[I].concat(le)),setTimeout(()=>M([document.getElementById(le.id)]))},re=ae=>{R(ae)},K=ae=>{E(ae)},q=async(ae,oe)=>{_(oe);const se=schemasList2template(ae,a.basePdf);u(se),await W(se),U(se),d(oe,ae.length),setTimeout(()=>{A.current&&(A.current.scrollTop=getPagesScrollTopByIndex(V,oe,j))},0)},Q=()=>{if(I===0||!window.confirm(g("removePageConfirm")))return;const ae=cloneDeep$1($);ae.splice(I,1),q(ae,I-1)},ee=()=>{const ae=cloneDeep$1($);ae.splice(I+1,0,[]),q(ae,I+1)};B!==a&&(F(a),W(a));const Y=s.width-LEFT_SIDEBAR_WIDTH,Z={width:O?Y-RIGHT_SIDEBAR_WIDTH:Y,height:s.height};if(G)return jsxRuntimeExports.jsx(ErrorScreen,{size:s,error:G});const te=isBlankPdf(a.basePdf)?{addPageAfter:ee,removePage:Q}:{};return jsxRuntimeExports.jsx(Root,{size:s,scale:j,children:jsxRuntimeExports.jsxs(DndContext,{onDragEnd:ae=>{if(!ae.active)return;const oe=ae.active,se=x.current[I].getBoundingClientRect(),fe=oe.rect.current.initial?.left||0,pe=oe.rect.current.initial?.top||0,ge=se.left-fe+scaleDragPosAdjustment(20,j),me=se.top-pe,be=(ae.delta.y-me)/j,le=(ae.delta.x-ge)/j,ve={x:round$1(px2mm(Math.max(0,le)),2),y:round$1(px2mm(Math.max(0,be)),2)};J({...oe.data.current,position:ve})},onDragStart:N,children:[jsxRuntimeExports.jsx(LeftSidebar,{height:A.current?A.current.clientHeight:0,scale:j,basePdf:a.basePdf}),jsxRuntimeExports.jsxs("div",{style:{position:"absolute",width:Y,marginLeft:LEFT_SIDEBAR_WIDTH},children:[jsxRuntimeExports.jsx(CtlBar,{size:Z,pageCursor:I,pageNum:$.length,setPageCursor:ae=>{A.current&&(A.current.scrollTop=getPagesScrollTopByIndex(V,ae,j),_(ae),d(ae,$.length),N())},zoomLevel:C,setZoomLevel:P,...te}),jsxRuntimeExports.jsx(Sidebar,{hoveringSchemaId:m,onChangeHoveringSchemaId:K,height:A.current?A.current.clientHeight:0,size:s,pageSize:V[I]??[],basePdf:a.basePdf,activeElements:w,schemasList:$,schemas:$[I]??[],changeSchemas:H,onSortEnd:re,onEdit:ae=>{const oe=document.getElementById(ae);oe&&M([oe])},onEditEnd:N,deselectSchema:N,sidebarOpen:O,setSidebarOpen:L}),jsxRuntimeExports.jsx(Canvas,{ref:A,paperRefs:x,basePdf:a.basePdf,hoveringSchemaId:m,onChangeHoveringSchemaId:K,height:s.height-RULER_HEIGHT*ZOOM,pageCursor:I,scale:j,size:Z,pageSizes:V,backgrounds:D,activeElements:w,schemasList:$,changeSchemas:H,removeSchemas:k,sidebarOpen:O,onEdit:M})]})]})})},defaultTheme={token:{colorPrimary:"#38a0ff"},components:{Form:{fontSize:12,margin:8,marginLG:12,marginXS:4,padding:8,paddingLG:12,paddingXS:4,itemMarginBottom:4,verticalLabelPadding:"0 0 2px"}}},isObject=a=>!!a&&typeof a=="object"&&!Array.isArray(a),deepMerge=(a,s)=>{let c={...a};return isObject(a)&&isObject(s)&&Object.keys(s).forEach(u=>{const d=s[u];if(isObject(d))if(!(u in a))Object.assign(c,{[u]:d});else{const p=a[u];isObject(p)?c[u]=deepMerge(p,d):Object.assign(c,{[u]:d})}else Object.assign(c,{[u]:d})}),c},AppContextProvider=({children:a,lang:s,font:c,plugins:u,options:d})=>{let p=defaultTheme;d.theme&&(p=deepMerge(p,d.theme));let v=getDict(s);return d.labels&&(v=deepMerge(v,d.labels)),jsxRuntimeExports.jsx(ConfigProvider,{theme:p,children:jsxRuntimeExports.jsx(I18nContext.Provider,{value:A=>i18n(A,v),children:jsxRuntimeExports.jsx(FontContext.Provider,{value:c,children:jsxRuntimeExports.jsx(PluginsRegistry.Provider,{value:u,children:jsxRuntimeExports.jsx(OptionsContext.Provider,{value:d,children:a})})})})})};class Designer extends BaseUIClass{constructor(s){super(s),this.pageCursor=0,checkDesignerProps(s)}saveTemplate(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.onSaveTemplateCallback&&this.onSaveTemplateCallback(this.template)}updateTemplate(s){if(checkTemplate(s),!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.template=cloneDeep$1(s),this.onChangeTemplateCallback&&this.onChangeTemplateCallback(s),this.render()}onSaveTemplate(s){this.onSaveTemplateCallback=s}onChangeTemplate(s){this.onChangeTemplateCallback=s}onPageChange(s){this.onPageChangeCallback=s}getPageCursor(){return this.pageCursor}getTotalPages(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.template.schemas.length}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(TemplateEditor,{template:this.template,onSaveTemplate:s=>{this.template=s,this.template.pdfmeVersion=PDFME_VERSION,this.onSaveTemplateCallback&&this.onSaveTemplateCallback(s)},onChangeTemplate:s=>{this.template=s,this.template.pdfmeVersion=PDFME_VERSION,this.onChangeTemplateCallback&&this.onChangeTemplateCallback(s)},onPageCursorChange:(s,c)=>{this.pageCursor=s,this.onPageChangeCallback&&this.onPageChangeCallback({currentPage:s,totalPages:c})},size:this.size})}),this.domContainer)}}const{Text}=Typography,icons={left:ChevronLeft,right:ChevronRight,doubleLeft:ChevronsLeft,doubleRight:ChevronsRight},UnitButton=({type:a,onClick:s,disabled:c,textStyle:u})=>{const d=icons[a];return jsxRuntimeExports.jsx(Button$1,{type:"text",onClick:s,disabled:c,children:jsxRuntimeExports.jsx(d,{style:{color:u.color}})})},UnitPager=({size:a,unitCursor:s,unitNum:c,setUnitCursor:u})=>{if(c<=1)return null;const{token:d}=theme.useToken(),p={pointerEvents:"initial",position:"sticky",zIndex:1,display:"flex",alignItems:"center",boxSizing:"border-box",height:40,padding:d.paddingSM,borderRadius:d.borderRadius,backgroundColor:d.colorBgMask},v={color:d.colorWhite,fontSize:d.fontSize,margin:d.marginXS};return jsxRuntimeExports.jsx("div",{style:{position:"absolute",...a},children:jsxRuntimeExports.jsxs("div",{style:{position:"sticky",width:"100%",zIndex:1,top:`calc(50% - ${p.height/2}px)`,display:"flex",alignItems:"center"},children:[s>0&&jsxRuntimeExports.jsxs("div",{style:{left:"1rem",marginLeft:"1rem",...p},children:[jsxRuntimeExports.jsx(UnitButton,{type:"doubleLeft",onClick:()=>u(0),disabled:s<=0,textStyle:v}),jsxRuntimeExports.jsx(UnitButton,{type:"left",onClick:()=>u(s-1),disabled:s<=0,textStyle:v}),jsxRuntimeExports.jsxs(Text,{strong:!0,style:v,children:[s+1,"/",c]})]}),s+1<c&&jsxRuntimeExports.jsxs("div",{style:{right:"1rem",marginLeft:"auto",marginRight:"1rem",...p},children:[jsxRuntimeExports.jsxs(Text,{strong:!0,style:v,children:[s+1,"/",c]}),jsxRuntimeExports.jsx(UnitButton,{type:"right",onClick:()=>u(s+1),disabled:s+1>=c,textStyle:v}),jsxRuntimeExports.jsx(UnitButton,{type:"doubleRight",onClick:()=>u(c-1),disabled:s+1>=c,textStyle:v})]})]})})},_cache=new Map,Preview=({template:a,inputs:s,size:c,onChangeInput:u,onPageChange:d})=>{const{token:p}=theme.useToken(),v=reactExports.useContext(FontContext),A=reactExports.useContext(OptionsContext),x=useMaxZoom(),g=reactExports.useRef(null),b=reactExports.useRef([]),[y,f]=reactExports.useState(0),[m,E]=reactExports.useState(0),[w,S]=reactExports.useState(A.zoomLevel??1),[$,T]=reactExports.useState([[]]),{backgrounds:I,pageSizes:_,scale:C,error:P,refresh:O}=useUIPreProcessor({template:a,size:c,zoomLevel:w,maxZoom:x}),L=!!u,B=s[y],F=j=>{getDynamicTemplate({template:j,input:B,options:{font:v},_cache,getDynamicHeights:(U,M)=>{switch(M.schema.type){case"table":return getDynamicHeightsForTable(U,M);default:return Promise.resolve([M.schema.height])}}}).then(async U=>{const M=await template2SchemasList(U);T(M),await O(U)}).catch(U=>console.error("[@pdfme/ui] ",U))};reactExports.useEffect(()=>{typeof A.zoomLevel=="number"&&A.zoomLevel!==w&&S(A.zoomLevel)},[A]),reactExports.useEffect(()=>{y>s.length-1&&f(s.length-1),F(a)},[a,s,c]),useScrollPageCursor({ref:g,pageSizes:_,scale:C,pageCursor:m,onChangePageCursor:j=>{E(j),d&&d({currentPage:j,totalPages:$.length})}});const D=({name:j,value:G})=>u&&u({index:y,name:j,value:G}),V=(j,G)=>{let U=!1;j.forEach(({key:M,value:N})=>{if(M==="content"){const R=N,k=B?.[G.name]||"";if(R===k)return;D({name:G.name,value:R}),G.type==="table"&&(U=!0)}else{const R=$[m].find(k=>k.id===G.id);if(!R)return;R[M]=N}}),U&&F(a),T([...$])};return P?jsxRuntimeExports.jsx(ErrorScreen,{size:c,error:P}):jsxRuntimeExports.jsxs(Root,{size:c,scale:C,children:[jsxRuntimeExports.jsx(CtlBar,{size:c,pageCursor:m,pageNum:$.length,setPageCursor:j=>{g.current&&(g.current.scrollTop=getPagesScrollTopByIndex(_,j,C),E(j),d&&d({currentPage:j,totalPages:$.length}))},zoomLevel:w,setZoomLevel:S}),jsxRuntimeExports.jsx(UnitPager,{size:c,unitCursor:y,unitNum:s.length,setUnitCursor:f}),jsxRuntimeExports.jsx("div",{ref:g,style:{...c,position:"relative",overflow:"auto"},children:jsxRuntimeExports.jsx(Paper,{paperRefs:b,scale:C,size:c,schemasList:$,pageSizes:_,backgrounds:I,renderSchema:({schema:j,index:G})=>{const U=j.readOnly?replacePlaceholders({content:j.content||"",variables:{...B,totalPages:$.length,currentPage:G+1},schemas:$}):String(B&&B[j.name]||"");return jsxRuntimeExports.jsx(Renderer,{schema:j,basePdf:a.basePdf,value:U,mode:L?"form":"viewer",placeholder:j.content,tabIndex:G+100,onChange:M=>{const N=Array.isArray(M)?M:[M];V(N,j)},outline:L&&!j.readOnly?`1px dashed ${p.colorPrimary}`:"transparent",scale:C},j.id)},renderPaper:({index:j})=>jsxRuntimeExports.jsx(StaticSchema,{template:a,scale:C,input:B,totalPages:$.length,currentPage:j+1})})})]})};class Form extends PreviewUI{constructor(s){super(s),this.pageCursor=0}onChangeInput(s){this.onChangeInputCallback=s}onPageChange(s){this.onPageChangeCallback=s}getPageCursor(){return this.pageCursor}getTotalPages(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.template.schemas.length}setInputs(s){const c=this.getInputs();super.setInputs(s);const u=[];s.forEach((d,p)=>{const v=c[p]||{};new Set([...Object.keys(d),...Object.keys(v)]).forEach(x=>{const g=d[x],b=v[x];g!==b&&u.push({index:p,name:x,value:g})})}),u.forEach(d=>{this.onChangeInputCallback&&this.onChangeInputCallback(d)})}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(Preview,{template:this.template,size:this.size,inputs:this.inputs,onChangeInput:s=>{const{index:c,value:u,name:d}=s;this.onChangeInputCallback&&this.onChangeInputCallback({index:c,value:u,name:d}),this.inputs&&this.inputs[c]&&this.inputs[c][d]!==u&&(this.inputs[c][d]=u,this.render())},onPageChange:s=>{this.pageCursor=s.currentPage,this.onPageChangeCallback&&this.onPageChangeCallback(s)}})}),this.domContainer)}}class Viewer extends PreviewUI{constructor(s){super(s),this.pageCursor=0,console.warn("[@pdfme/ui] Viewer component is deprecated and will be removed in a future version.")}onPageChange(s){this.onPageChangeCallback=s}getPageCursor(){return this.pageCursor}getTotalPages(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.template.schemas.length}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(Preview,{template:this.template,size:this.size,inputs:this.inputs,onPageChange:s=>{this.pageCursor=s.currentPage,this.onPageChangeCallback&&this.onPageChangeCallback(s)}})}),this.domContainer)}}exports.Designer=Designer,exports.Form=Form,exports.Viewer=Viewer,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})}));
|
|
1041
|
+
`}),jsxRuntimeExports.jsx("div",{style:s,children:jsxRuntimeExports.jsx(LoaderCircle,{size:50,style:c})})]})},Root$1=({size:a,scale:s,children:c},u)=>{const d=reactExports.useContext(FontContext);return reactExports.useEffect(()=>{if(!document||!document.fonts)return;const v=Object.entries(d).map(([A,{data:x}])=>new FontFace(A,typeof x=="string"?`url(${x})`:x,{display:"swap"})).filter(A=>!document.fonts.has(A));Promise.allSettled(v.map(A=>A.load())).then(A=>{A.forEach(x=>{x.status==="fulfilled"&&document.fonts.add(x.value)})})},[d]),jsxRuntimeExports.jsx("div",{className:DESIGNER_CLASSNAME+"root",ref:u,style:{position:"relative",background:BACKGROUND_COLOR,...a},children:jsxRuntimeExports.jsx("div",{className:DESIGNER_CLASSNAME+"background",style:{margin:"0 auto",...a},children:s===0?jsxRuntimeExports.jsx(Spinner,{}):c})})},Root=reactExports.forwardRef(Root$1),ErrorScreen=({size:a,error:s})=>{const c=reactExports.useContext(I18nContext),{token:u}=theme.useToken();return jsxRuntimeExports.jsx("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",background:BACKGROUND_COLOR,...a},children:jsxRuntimeExports.jsx("div",{style:{width:300,margin:"0 auto",background:u.colorBgLayout},children:jsxRuntimeExports.jsx(Result$1,{icon:null,title:"ERROR",subTitle:c("errorOccurred"),extra:jsxRuntimeExports.jsx("span",{children:s.message})})})})},{Text:Text$1}=Typography,Zoom=({zoomLevel:a,setZoomLevel:s,style:c})=>{const d=useMaxZoom(),p=.25,v=a-.25,A=a+.25;return jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(Button$1,{className:UI_CLASSNAME+"zoom-out",type:"text",disabled:p>=v,onClick:()=>s(v),icon:jsxRuntimeExports.jsx(Minus,{size:16,color:c.textStyle.color})}),jsxRuntimeExports.jsxs(Text$1,{strong:!0,style:c.textStyle,children:[Math.round(a*100),"%"]}),jsxRuntimeExports.jsx(Button$1,{className:UI_CLASSNAME+"zoom-in",type:"text",disabled:d<A,onClick:()=>s(A),icon:jsxRuntimeExports.jsx(Plus,{size:16,color:c.textStyle.color})})]})},Pager=({pageCursor:a,pageNum:s,setPageCursor:c,style:u})=>jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(Button$1,{className:UI_CLASSNAME+"page-prev",type:"text",disabled:a<=0,onClick:()=>c(a-1),children:jsxRuntimeExports.jsx(ChevronLeft,{size:16,color:u.textStyle.color})}),jsxRuntimeExports.jsxs(Text$1,{strong:!0,style:u.textStyle,children:[a+1,"/",s]}),jsxRuntimeExports.jsx(Button$1,{className:UI_CLASSNAME+"page-next",type:"text",disabled:a+1>=s,onClick:()=>c(a+1),children:jsxRuntimeExports.jsx(ChevronRight,{size:16,color:u.textStyle.color})})]}),ContextMenu=({items:a,style:s})=>jsxRuntimeExports.jsx(Dropdown,{menu:{items:a},placement:"top",arrow:!0,trigger:["click"],children:jsxRuntimeExports.jsx(Button$1,{className:UI_CLASSNAME+"context-menu",type:"text",children:jsxRuntimeExports.jsx(Ellipsis,{size:16,color:s.textStyle.color})})}),CtlBar=a=>{const{token:s}=theme.useToken(),c=reactExports.useContext(I18nContext),{size:u,pageCursor:d,pageNum:p,setPageCursor:v,zoomLevel:A,setZoomLevel:x,addPageAfter:g,removePage:b}=a,y=[];g&&y.push({key:"1",label:jsxRuntimeExports.jsx("div",{onClick:g,children:c("addPageAfter")})}),b&&p>1&&d!==0&&y.push({key:"2",label:jsxRuntimeExports.jsx("div",{onClick:b,children:c("removePage")})});const f=300,m=y.length>0?50:0,E=(p>1?f:f/2)+m,w={color:s.colorWhite,fontSize:s.fontSize,margin:s.marginXS};return jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:"auto",bottom:"6%",width:u.width},children:jsxRuntimeExports.jsxs("div",{className:UI_CLASSNAME+"control-bar",style:{display:"flex",alignItems:"center",justifyContent:"space-evenly",position:"relative",zIndex:1,left:`calc(50% - ${E/2}px)`,width:E,height:40,boxSizing:"border-box",padding:s.paddingSM,borderRadius:s.borderRadius,backgroundColor:s.colorBgMask},children:[p>1&&jsxRuntimeExports.jsx("div",{className:UI_CLASSNAME+"pager",children:jsxRuntimeExports.jsx(Pager,{style:{textStyle:w},pageCursor:d,pageNum:p,setPageCursor:v})}),jsxRuntimeExports.jsx("div",{className:UI_CLASSNAME+"zoom",children:jsxRuntimeExports.jsx(Zoom,{style:{textStyle:w},zoomLevel:A,setZoomLevel:x})}),y.length>0&&jsxRuntimeExports.jsx(ContextMenu,{items:y,style:{textStyle:w}})]})})},scaleDragPosAdjustment=(a,s)=>s>1?a*(s-1):s<1?a*-(1-s):0,TemplateEditor=({template:a,size:s,onSaveTemplate:c,onChangeTemplate:u,onPageCursorChange:d})=>{const p=reactExports.useRef([]),v=reactExports.useRef([]),A=reactExports.useRef(null),x=reactExports.useRef([]),g=reactExports.useContext(I18nContext),b=reactExports.useContext(PluginsRegistry),y=reactExports.useContext(OptionsContext),f=useMaxZoom(),[m,E]=reactExports.useState(null),[w,S]=reactExports.useState([]),[$,T]=reactExports.useState([[]]),[I,_]=reactExports.useState(0),[C,P]=reactExports.useState(y.zoomLevel??1),[O,L]=reactExports.useState(y.sidebarOpen??!0),[B,F]=reactExports.useState(null),{backgrounds:D,pageSizes:V,scale:j,error:G,refresh:U}=useUIPreProcessor({template:a,size:s,zoomLevel:C,maxZoom:f}),M=ae=>{S(ae),E(null)},N=()=>{S([]),E(null)};reactExports.useEffect(()=>{typeof y.zoomLevel=="number"&&y.zoomLevel!==C&&P(y.zoomLevel),typeof y.sidebarOpen=="boolean"&&y.sidebarOpen!==O&&L(y.sidebarOpen)},[y]),useScrollPageCursor({ref:A,pageSizes:V,scale:j,pageCursor:I,onChangePageCursor:ae=>{_(ae),d(ae,$.length),N()}});const R=reactExports.useCallback(ae=>{v.current=[],p.current.push(cloneDeep$1($[I]));const oe=cloneDeep$1($);oe[I]=ae,T(oe),u(schemasList2template(oe,a.basePdf))},[a,$,I,u]),k=reactExports.useCallback(ae=>{R($[I].filter(oe=>!ae.includes(oe.id))),N()},[$,I,R]),H=reactExports.useCallback(ae=>{changeSchemas({objs:ae,schemas:$[I],basePdf:a.basePdf,pluginsRegistry:b,pageSize:V[I],commitSchemas:R})},[R,I,$,b,V,a.basePdf]);useInitEvents({pageCursor:I,pageSizes:V,activeElements:w,template:a,schemasList:$,changeSchemas:H,commitSchemas:R,removeSchemas:k,onSaveTemplate:c,past:p,future:v,setSchemasList:T,onEdit:M,onEditEnd:N});const W=reactExports.useCallback(async ae=>{const oe=await template2SchemasList(ae);T(oe),N(),_(0),A.current?.scroll&&A.current.scroll({top:0,behavior:"smooth"})},[]),J=ae=>{const[oe,se,fe,pe]=isBlankPdf(a.basePdf)?a.basePdf.padding:[0,0,0,0],ge=V[I],me=ve=>{let he=$.reduce((Ee,xe)=>Ee+xe.length,1),ye=ve+he;for(;$.some(Ee=>Ee.find(xe=>xe.name===ye));)he++,ye=ve+he;return ye},be=(ve,he,ye)=>Math.min(Math.max(ve,he),ye),le={id:uuid$6(),...ae,name:me(g("field")),position:{x:be(pe,ae.position.x,ge.width-se-ae.width),y:be(oe,ae.position.y,ge.height-fe-ae.height)},required:ae.readOnly?!1:y.requiredByDefault||ae.required||!1};if(ae.position.y===0){const ve=x.current[I],he=ve?ve.getBoundingClientRect().top:0;le.position.y=he>0?oe:V[I].height/2}R($[I].concat(le)),setTimeout(()=>M([document.getElementById(le.id)]))},re=ae=>{R(ae)},K=ae=>{E(ae)},q=async(ae,oe)=>{_(oe);const se=schemasList2template(ae,a.basePdf);u(se),await W(se),U(se),d(oe,ae.length),setTimeout(()=>{A.current&&(A.current.scrollTop=getPagesScrollTopByIndex(V,oe,j))},0)},Q=()=>{if(I===0||!window.confirm(g("removePageConfirm")))return;const ae=cloneDeep$1($);ae.splice(I,1),q(ae,I-1)},ee=()=>{const ae=cloneDeep$1($);ae.splice(I+1,0,[]),q(ae,I+1)};B!==a&&(F(a),W(a));const Y=s.width-LEFT_SIDEBAR_WIDTH,Z={width:O?Y-RIGHT_SIDEBAR_WIDTH:Y,height:s.height};if(G)return jsxRuntimeExports.jsx(ErrorScreen,{size:s,error:G});const te=isBlankPdf(a.basePdf)?{addPageAfter:ee,removePage:Q}:{};return jsxRuntimeExports.jsx(Root,{size:s,scale:j,children:jsxRuntimeExports.jsxs(DndContext,{onDragEnd:ae=>{if(!ae.active)return;const oe=ae.active,se=x.current[I].getBoundingClientRect(),fe=oe.rect.current.initial?.left||0,pe=oe.rect.current.initial?.top||0,ge=se.left-fe+scaleDragPosAdjustment(20,j),me=se.top-pe,be=(ae.delta.y-me)/j,le=(ae.delta.x-ge)/j,ve={x:round$1(px2mm(Math.max(0,le)),2),y:round$1(px2mm(Math.max(0,be)),2)};J({...oe.data.current,position:ve})},onDragStart:N,children:[jsxRuntimeExports.jsx(LeftSidebar,{height:A.current?A.current.clientHeight:0,scale:j,basePdf:a.basePdf}),jsxRuntimeExports.jsxs("div",{style:{position:"absolute",width:Y,marginLeft:LEFT_SIDEBAR_WIDTH},children:[jsxRuntimeExports.jsx(CtlBar,{size:Z,pageCursor:I,pageNum:$.length,setPageCursor:ae=>{A.current&&(A.current.scrollTop=getPagesScrollTopByIndex(V,ae,j),_(ae),d(ae,$.length),N())},zoomLevel:C,setZoomLevel:P,...te}),jsxRuntimeExports.jsx(Sidebar,{hoveringSchemaId:m,onChangeHoveringSchemaId:K,height:A.current?A.current.clientHeight:0,size:s,pageSize:V[I]??[],basePdf:a.basePdf,activeElements:w,schemasList:$,schemas:$[I]??[],changeSchemas:H,onSortEnd:re,onEdit:ae=>{const oe=document.getElementById(ae);oe&&M([oe])},onEditEnd:N,deselectSchema:N,sidebarOpen:O,setSidebarOpen:L}),jsxRuntimeExports.jsx(Canvas,{ref:A,paperRefs:x,basePdf:a.basePdf,hoveringSchemaId:m,onChangeHoveringSchemaId:K,height:s.height-RULER_HEIGHT*ZOOM,pageCursor:I,scale:j,size:Z,pageSizes:V,backgrounds:D,activeElements:w,schemasList:$,changeSchemas:H,removeSchemas:k,sidebarOpen:O,onEdit:M})]})]})})},defaultTheme={token:{colorPrimary:"#38a0ff"},components:{Form:{fontSize:12,margin:8,marginLG:12,marginXS:4,padding:8,paddingLG:12,paddingXS:4,itemMarginBottom:4,verticalLabelPadding:"0 0 2px"}}},isObject=a=>!!a&&typeof a=="object"&&!Array.isArray(a),deepMerge=(a,s)=>{let c={...a};return isObject(a)&&isObject(s)&&Object.keys(s).forEach(u=>{const d=s[u];if(isObject(d))if(!(u in a))Object.assign(c,{[u]:d});else{const p=a[u];isObject(p)?c[u]=deepMerge(p,d):Object.assign(c,{[u]:d})}else Object.assign(c,{[u]:d})}),c},AppContextProvider=({children:a,lang:s,font:c,plugins:u,options:d})=>{let p=defaultTheme;d.theme&&(p=deepMerge(p,d.theme));let v=getDict(s);return d.labels&&(v=deepMerge(v,d.labels)),jsxRuntimeExports.jsx(ConfigProvider,{theme:p,children:jsxRuntimeExports.jsx(I18nContext.Provider,{value:A=>i18n(A,v),children:jsxRuntimeExports.jsx(FontContext.Provider,{value:c,children:jsxRuntimeExports.jsx(PluginsRegistry.Provider,{value:u,children:jsxRuntimeExports.jsx(OptionsContext.Provider,{value:d,children:a})})})})})};class Designer extends BaseUIClass{constructor(s){super(s),this.pageCursor=0,checkDesignerProps(s)}saveTemplate(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.onSaveTemplateCallback&&this.onSaveTemplateCallback(this.template)}updateTemplate(s){if(checkTemplate(s),!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.template=cloneDeep$1(s),this.onChangeTemplateCallback&&this.onChangeTemplateCallback(s),this.render()}onSaveTemplate(s){this.onSaveTemplateCallback=s}onChangeTemplate(s){this.onChangeTemplateCallback=s}onPageChange(s){this.onPageChangeCallback=s}getPageCursor(){return this.pageCursor}getTotalPages(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.template.schemas.length}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(TemplateEditor,{template:this.template,onSaveTemplate:s=>{this.template=s,this.template.pdfmeVersion=PDFME_VERSION,this.onSaveTemplateCallback&&this.onSaveTemplateCallback(s)},onChangeTemplate:s=>{this.template=s,this.template.pdfmeVersion=PDFME_VERSION,this.onChangeTemplateCallback&&this.onChangeTemplateCallback(s)},onPageCursorChange:(s,c)=>{this.pageCursor=s,this.onPageChangeCallback&&this.onPageChangeCallback({currentPage:s,totalPages:c})},size:this.size})}),this.domContainer)}}const{Text}=Typography,icons={left:ChevronLeft,right:ChevronRight,doubleLeft:ChevronsLeft,doubleRight:ChevronsRight},UnitButton=({type:a,onClick:s,disabled:c,textStyle:u})=>{const d=icons[a];return jsxRuntimeExports.jsx(Button$1,{type:"text",onClick:s,disabled:c,children:jsxRuntimeExports.jsx(d,{style:{color:u.color}})})},UnitPager=({size:a,unitCursor:s,unitNum:c,setUnitCursor:u})=>{if(c<=1)return null;const{token:d}=theme.useToken(),p={pointerEvents:"initial",position:"sticky",zIndex:1,display:"flex",alignItems:"center",boxSizing:"border-box",height:40,padding:d.paddingSM,borderRadius:d.borderRadius,backgroundColor:d.colorBgMask},v={color:d.colorWhite,fontSize:d.fontSize,margin:d.marginXS};return jsxRuntimeExports.jsx("div",{style:{position:"absolute",...a},children:jsxRuntimeExports.jsxs("div",{style:{position:"sticky",width:"100%",zIndex:1,top:`calc(50% - ${p.height/2}px)`,display:"flex",alignItems:"center"},children:[s>0&&jsxRuntimeExports.jsxs("div",{style:{left:"1rem",marginLeft:"1rem",...p},children:[jsxRuntimeExports.jsx(UnitButton,{type:"doubleLeft",onClick:()=>u(0),disabled:s<=0,textStyle:v}),jsxRuntimeExports.jsx(UnitButton,{type:"left",onClick:()=>u(s-1),disabled:s<=0,textStyle:v}),jsxRuntimeExports.jsxs(Text,{strong:!0,style:v,children:[s+1,"/",c]})]}),s+1<c&&jsxRuntimeExports.jsxs("div",{style:{right:"1rem",marginLeft:"auto",marginRight:"1rem",...p},children:[jsxRuntimeExports.jsxs(Text,{strong:!0,style:v,children:[s+1,"/",c]}),jsxRuntimeExports.jsx(UnitButton,{type:"right",onClick:()=>u(s+1),disabled:s+1>=c,textStyle:v}),jsxRuntimeExports.jsx(UnitButton,{type:"doubleRight",onClick:()=>u(c-1),disabled:s+1>=c,textStyle:v})]})]})})},_cache=new Map,Preview=({template:a,inputs:s,size:c,onChangeInput:u,onPageChange:d})=>{const{token:p}=theme.useToken(),v=reactExports.useContext(FontContext),A=reactExports.useContext(OptionsContext),x=useMaxZoom(),g=reactExports.useRef(null),b=reactExports.useRef([]),[y,f]=reactExports.useState(0),[m,E]=reactExports.useState(0),[w,S]=reactExports.useState(A.zoomLevel??1),[$,T]=reactExports.useState([[]]),{backgrounds:I,pageSizes:_,scale:C,error:P,refresh:O}=useUIPreProcessor({template:a,size:c,zoomLevel:w,maxZoom:x}),L=!!u,B=s[y],F=(j,G)=>{getDynamicTemplate({template:j,input:G??B,options:{font:v},_cache,getDynamicHeights:(N,R)=>{switch(R.schema.type){case"table":return getDynamicHeightsForTable(N,R);default:return Promise.resolve([R.schema.height])}}}).then(async N=>{const R=await template2SchemasList(N);T(R),await O(N)}).catch(N=>console.error("[@pdfme/ui] ",N))};reactExports.useEffect(()=>{typeof A.zoomLevel=="number"&&A.zoomLevel!==w&&S(A.zoomLevel)},[A]),reactExports.useEffect(()=>{y>s.length-1&&f(s.length-1),F(a)},[a,s,c]),useScrollPageCursor({ref:g,pageSizes:_,scale:C,pageCursor:m,onChangePageCursor:j=>{E(j),d&&d({currentPage:j,totalPages:$.length})}});const D=({name:j,value:G})=>u&&u({index:y,name:j,value:G}),V=(j,G)=>{let U=!1,M;if(j.forEach(({key:N,value:R})=>{if(N==="content"){const k=R,H=B?.[G.name]||"";if(k===H)return;D({name:G.name,value:k}),G.type==="table"&&(U=!0,M=k)}else{const k=$[m].find(H=>H.id===G.id);if(!k)return;k[N]=R}}),U&&M!==void 0){const N={...B,[G.name]:M};F(a,N)}T([...$])};return P?jsxRuntimeExports.jsx(ErrorScreen,{size:c,error:P}):jsxRuntimeExports.jsxs(Root,{size:c,scale:C,children:[jsxRuntimeExports.jsx(CtlBar,{size:c,pageCursor:m,pageNum:$.length,setPageCursor:j=>{g.current&&(g.current.scrollTop=getPagesScrollTopByIndex(_,j,C),E(j),d&&d({currentPage:j,totalPages:$.length}))},zoomLevel:w,setZoomLevel:S}),jsxRuntimeExports.jsx(UnitPager,{size:c,unitCursor:y,unitNum:s.length,setUnitCursor:f}),jsxRuntimeExports.jsx("div",{ref:g,style:{...c,position:"relative",overflow:"auto"},children:jsxRuntimeExports.jsx(Paper,{paperRefs:b,scale:C,size:c,schemasList:$,pageSizes:_,backgrounds:I,renderSchema:({schema:j,index:G})=>{const U=j.readOnly?replacePlaceholders({content:j.content||"",variables:{...B,totalPages:$.length,currentPage:G+1},schemas:$}):String(B&&B[j.name]||"");return jsxRuntimeExports.jsx(Renderer,{schema:j,basePdf:a.basePdf,value:U,mode:L?"form":"viewer",placeholder:j.content,tabIndex:G+100,onChange:M=>{const N=Array.isArray(M)?M:[M];V(N,j)},outline:L&&!j.readOnly?`1px dashed ${p.colorPrimary}`:"transparent",scale:C},j.id)},renderPaper:({index:j})=>jsxRuntimeExports.jsx(StaticSchema,{template:a,scale:C,input:B,totalPages:$.length,currentPage:j+1})})})]})};class Form extends PreviewUI{constructor(s){super(s),this.pageCursor=0}onChangeInput(s){this.onChangeInputCallback=s}onPageChange(s){this.onPageChangeCallback=s}getPageCursor(){return this.pageCursor}getTotalPages(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.template.schemas.length}setInputs(s){const c=this.getInputs();super.setInputs(s);const u=[];s.forEach((d,p)=>{const v=c[p]||{};new Set([...Object.keys(d),...Object.keys(v)]).forEach(x=>{const g=d[x],b=v[x];g!==b&&u.push({index:p,name:x,value:g})})}),u.forEach(d=>{this.onChangeInputCallback&&this.onChangeInputCallback(d)})}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(Preview,{template:this.template,size:this.size,inputs:this.inputs,onChangeInput:s=>{const{index:c,value:u,name:d}=s;this.onChangeInputCallback&&this.onChangeInputCallback({index:c,value:u,name:d}),this.inputs&&this.inputs[c]&&this.inputs[c][d]!==u&&(this.inputs[c][d]=u,this.render())},onPageChange:s=>{this.pageCursor=s.currentPage,this.onPageChangeCallback&&this.onPageChangeCallback(s)}})}),this.domContainer)}}class Viewer extends PreviewUI{constructor(s){super(s),this.pageCursor=0,console.warn("[@pdfme/ui] Viewer component is deprecated and will be removed in a future version.")}onPageChange(s){this.onPageChangeCallback=s}getPageCursor(){return this.pageCursor}getTotalPages(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.template.schemas.length}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(Preview,{template:this.template,size:this.size,inputs:this.inputs,onPageChange:s=>{this.pageCursor=s.currentPage,this.onPageChangeCallback&&this.onPageChangeCallback(s)}})}),this.domContainer)}}exports.Designer=Designer,exports.Form=Form,exports.Viewer=Viewer,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -58,11 +58,12 @@ const Preview = ({
|
|
|
58
58
|
|
|
59
59
|
const input = inputs[unitCursor];
|
|
60
60
|
|
|
61
|
-
const init = (template: Template) => {
|
|
61
|
+
const init = (template: Template, inputOverride?: Record<string, string>) => {
|
|
62
|
+
const currentInput = inputOverride ?? input;
|
|
62
63
|
const options = { font };
|
|
63
64
|
getDynamicTemplate({
|
|
64
65
|
template,
|
|
65
|
-
input,
|
|
66
|
+
input: currentInput,
|
|
66
67
|
options,
|
|
67
68
|
_cache,
|
|
68
69
|
getDynamicHeights: (value, args) => {
|
|
@@ -117,6 +118,8 @@ const Preview = ({
|
|
|
117
118
|
|
|
118
119
|
const handleOnChangeRenderer = (args: { key: string; value: unknown }[], schema: SchemaForUI) => {
|
|
119
120
|
let isNeedInit = false;
|
|
121
|
+
let newInputValue: string | undefined;
|
|
122
|
+
|
|
120
123
|
args.forEach(({ key: _key, value }) => {
|
|
121
124
|
if (_key === 'content') {
|
|
122
125
|
const newValue = value as string;
|
|
@@ -124,7 +127,10 @@ const Preview = ({
|
|
|
124
127
|
if (newValue === oldValue) return;
|
|
125
128
|
handleChangeInput({ name: schema.name, value: newValue });
|
|
126
129
|
// TODO Improve this to allow schema types to determine whether the execution of getDynamicTemplate is required.
|
|
127
|
-
if (schema.type === 'table')
|
|
130
|
+
if (schema.type === 'table') {
|
|
131
|
+
isNeedInit = true;
|
|
132
|
+
newInputValue = newValue;
|
|
133
|
+
}
|
|
128
134
|
} else {
|
|
129
135
|
const targetSchema = schemasList[pageCursor].find((s) => s.id === schema.id) as SchemaForUI;
|
|
130
136
|
if (!targetSchema) return;
|
|
@@ -133,8 +139,10 @@ const Preview = ({
|
|
|
133
139
|
targetSchema[_key] = value as string;
|
|
134
140
|
}
|
|
135
141
|
});
|
|
136
|
-
if (isNeedInit) {
|
|
137
|
-
|
|
142
|
+
if (isNeedInit && newInputValue !== undefined) {
|
|
143
|
+
// Pass the updated input directly to recalculate with new value
|
|
144
|
+
const updatedInput = { ...input, [schema.name]: newInputValue };
|
|
145
|
+
init(template, updatedInput);
|
|
138
146
|
}
|
|
139
147
|
setSchemasList([...schemasList]);
|
|
140
148
|
};
|