@forevka/wordcanvas 0.2.0 → 0.3.1

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.
@@ -1,5 +1,5 @@
1
- import { c as fe, m as et, f as Ie } from "./worker-DL4Rxrg-.js";
2
- const mn = [
1
+ import { c as fe, m as tt, f as ye } from "./worker-C35TK5Ee.js";
2
+ const An = [
3
3
  "BN",
4
4
  "BN",
5
5
  "BN",
@@ -256,7 +256,7 @@ const mn = [
256
256
  "L",
257
257
  "L",
258
258
  "L"
259
- ], pt = [
259
+ ], mt = [
260
260
  [697, 698, "ON"],
261
261
  [706, 719, "ON"],
262
262
  [722, 735, "ON"],
@@ -972,145 +972,145 @@ const mn = [
972
972
  [1048574, 1048575, "BN"],
973
973
  [1114110, 1114111, "BN"]
974
974
  ];
975
- function An(e) {
975
+ function En(e) {
976
976
  if (e <= 255)
977
- return mn[e];
978
- let t = 0, n = pt.length - 1;
977
+ return An[e];
978
+ let t = 0, n = mt.length - 1;
979
979
  for (; t <= n; ) {
980
- const i = t + n >> 1, x = pt[i];
981
- if (e < x[0]) {
980
+ const i = t + n >> 1, r = mt[i];
981
+ if (e < r[0]) {
982
982
  n = i - 1;
983
983
  continue;
984
984
  }
985
- if (e > x[1]) {
985
+ if (e > r[1]) {
986
986
  t = i + 1;
987
987
  continue;
988
988
  }
989
- return x[2];
989
+ return r[2];
990
990
  }
991
991
  return "L";
992
992
  }
993
- function En(e) {
993
+ function Bn(e) {
994
994
  const t = e.length;
995
995
  if (t === 0)
996
996
  return null;
997
997
  const n = new Array(t);
998
998
  let i = !1;
999
- for (let r = 0; r < t; ) {
1000
- const c = e.charCodeAt(r);
1001
- let a = c, u = 1;
1002
- if (c >= 55296 && c <= 56319 && r + 1 < t) {
1003
- const S = e.charCodeAt(r + 1);
1004
- S >= 56320 && S <= 57343 && (a = (c - 55296 << 10) + (S - 56320) + 65536, u = 2);
1005
- }
1006
- const d = An(a);
999
+ for (let x = 0; x < t; ) {
1000
+ const c = e.charCodeAt(x);
1001
+ let a = c, f = 1;
1002
+ if (c >= 55296 && c <= 56319 && x + 1 < t) {
1003
+ const S = e.charCodeAt(x + 1);
1004
+ S >= 56320 && S <= 57343 && (a = (c - 55296 << 10) + (S - 56320) + 65536, f = 2);
1005
+ }
1006
+ const d = En(a);
1007
1007
  (d === "R" || d === "AL" || d === "AN") && (i = !0);
1008
- for (let S = 0; S < u; S++)
1009
- n[r + S] = d;
1010
- r += u;
1008
+ for (let S = 0; S < f; S++)
1009
+ n[x + S] = d;
1010
+ x += f;
1011
1011
  }
1012
1012
  if (!i)
1013
1013
  return null;
1014
- let x = 0;
1015
- for (let r = 0; r < t; r++) {
1016
- const c = n[r];
1014
+ let r = 0;
1015
+ for (let x = 0; x < t; x++) {
1016
+ const c = n[x];
1017
1017
  if (c === "L") {
1018
- x = 0;
1018
+ r = 0;
1019
1019
  break;
1020
1020
  }
1021
1021
  if (c === "R" || c === "AL") {
1022
- x = 1;
1022
+ r = 1;
1023
1023
  break;
1024
1024
  }
1025
1025
  }
1026
1026
  const s = new Int8Array(t);
1027
- for (let r = 0; r < t; r++)
1028
- s[r] = x;
1029
- const l = x & 1 ? "R" : "L", f = l;
1030
- let o = f;
1031
- for (let r = 0; r < t; r++)
1032
- n[r] === "NSM" ? n[r] = o : o = n[r];
1033
- o = f;
1034
- for (let r = 0; r < t; r++) {
1035
- const c = n[r];
1036
- c === "EN" ? n[r] = o === "AL" ? "AN" : "EN" : (c === "R" || c === "L" || c === "AL") && (o = c);
1037
- }
1038
- for (let r = 0; r < t; r++)
1039
- n[r] === "AL" && (n[r] = "R");
1040
- for (let r = 1; r < t - 1; r++)
1041
- n[r] === "ES" && n[r - 1] === "EN" && n[r + 1] === "EN" && (n[r] = "EN"), n[r] === "CS" && (n[r - 1] === "EN" || n[r - 1] === "AN") && n[r + 1] === n[r - 1] && (n[r] = n[r - 1]);
1042
- for (let r = 0; r < t; r++) {
1043
- if (n[r] !== "EN")
1027
+ for (let x = 0; x < t; x++)
1028
+ s[x] = r;
1029
+ const l = r & 1 ? "R" : "L", u = l;
1030
+ let o = u;
1031
+ for (let x = 0; x < t; x++)
1032
+ n[x] === "NSM" ? n[x] = o : o = n[x];
1033
+ o = u;
1034
+ for (let x = 0; x < t; x++) {
1035
+ const c = n[x];
1036
+ c === "EN" ? n[x] = o === "AL" ? "AN" : "EN" : (c === "R" || c === "L" || c === "AL") && (o = c);
1037
+ }
1038
+ for (let x = 0; x < t; x++)
1039
+ n[x] === "AL" && (n[x] = "R");
1040
+ for (let x = 1; x < t - 1; x++)
1041
+ n[x] === "ES" && n[x - 1] === "EN" && n[x + 1] === "EN" && (n[x] = "EN"), n[x] === "CS" && (n[x - 1] === "EN" || n[x - 1] === "AN") && n[x + 1] === n[x - 1] && (n[x] = n[x - 1]);
1042
+ for (let x = 0; x < t; x++) {
1043
+ if (n[x] !== "EN")
1044
1044
  continue;
1045
1045
  let c;
1046
- for (c = r - 1; c >= 0 && n[c] === "ET"; c--)
1046
+ for (c = x - 1; c >= 0 && n[c] === "ET"; c--)
1047
1047
  n[c] = "EN";
1048
- for (c = r + 1; c < t && n[c] === "ET"; c++)
1048
+ for (c = x + 1; c < t && n[c] === "ET"; c++)
1049
1049
  n[c] = "EN";
1050
1050
  }
1051
- for (let r = 0; r < t; r++) {
1052
- const c = n[r];
1053
- (c === "WS" || c === "ES" || c === "ET" || c === "CS") && (n[r] = "ON");
1051
+ for (let x = 0; x < t; x++) {
1052
+ const c = n[x];
1053
+ (c === "WS" || c === "ES" || c === "ET" || c === "CS") && (n[x] = "ON");
1054
1054
  }
1055
- o = f;
1056
- for (let r = 0; r < t; r++) {
1057
- const c = n[r];
1058
- c === "EN" ? n[r] = o === "L" ? "L" : "EN" : (c === "R" || c === "L") && (o = c);
1055
+ o = u;
1056
+ for (let x = 0; x < t; x++) {
1057
+ const c = n[x];
1058
+ c === "EN" ? n[x] = o === "L" ? "L" : "EN" : (c === "R" || c === "L") && (o = c);
1059
1059
  }
1060
- for (let r = 0; r < t; r++) {
1061
- if (n[r] !== "ON")
1060
+ for (let x = 0; x < t; x++) {
1061
+ if (n[x] !== "ON")
1062
1062
  continue;
1063
- let c = r + 1;
1063
+ let c = x + 1;
1064
1064
  for (; c < t && n[c] === "ON"; )
1065
1065
  c++;
1066
- const a = r > 0 ? n[r - 1] : f, u = c < t ? n[c] : f, d = a !== "L" ? "R" : "L";
1067
- if (d === (u !== "L" ? "R" : "L"))
1068
- for (let p = r; p < c; p++)
1069
- n[p] = d;
1070
- r = c - 1;
1071
- }
1072
- for (let r = 0; r < t; r++)
1073
- n[r] === "ON" && (n[r] = l);
1074
- for (let r = 0; r < t; r++) {
1075
- const c = n[r];
1076
- (s[r] & 1) === 0 ? c === "R" ? s[r]++ : (c === "AN" || c === "EN") && (s[r] += 2) : (c === "L" || c === "AN" || c === "EN") && s[r]++;
1066
+ const a = x > 0 ? n[x - 1] : u, f = c < t ? n[c] : u, d = a !== "L" ? "R" : "L";
1067
+ if (d === (f !== "L" ? "R" : "L"))
1068
+ for (let A = x; A < c; A++)
1069
+ n[A] = d;
1070
+ x = c - 1;
1071
+ }
1072
+ for (let x = 0; x < t; x++)
1073
+ n[x] === "ON" && (n[x] = l);
1074
+ for (let x = 0; x < t; x++) {
1075
+ const c = n[x];
1076
+ (s[x] & 1) === 0 ? c === "R" ? s[x]++ : (c === "AN" || c === "EN") && (s[x] += 2) : (c === "L" || c === "AN" || c === "EN") && s[x]++;
1077
1077
  }
1078
1078
  return s;
1079
1079
  }
1080
- function Bn(e, t) {
1081
- const n = En(e);
1080
+ function Mn(e, t) {
1081
+ const n = Bn(e);
1082
1082
  if (n === null)
1083
1083
  return null;
1084
1084
  const i = new Int8Array(t.length);
1085
- for (let x = 0; x < t.length; x++)
1086
- i[x] = n[t[x]];
1085
+ for (let r = 0; r < t.length; r++)
1086
+ i[r] = n[t[r]];
1087
1087
  return i;
1088
1088
  }
1089
- const Mn = /[ \t\n\r\f]+/g, Cn = /[\t\n\r\f]| {2,}|^ | $/;
1090
- function kn(e) {
1089
+ const Cn = /[ \t\n\r\f]+/g, kn = /[\t\n\r\f]| {2,}|^ | $/;
1090
+ function Dn(e) {
1091
1091
  const t = e ?? "normal";
1092
1092
  return t === "pre-wrap" ? { mode: t, preserveOrdinarySpaces: !0, preserveHardBreaks: !0 } : { mode: t, preserveOrdinarySpaces: !1, preserveHardBreaks: !1 };
1093
1093
  }
1094
- function Dn(e) {
1095
- if (!Cn.test(e))
1094
+ function Ln(e) {
1095
+ if (!kn.test(e))
1096
1096
  return e;
1097
- let t = e.replace(Mn, " ");
1097
+ let t = e.replace(Cn, " ");
1098
1098
  return t.charCodeAt(0) === 32 && (t = t.slice(1)), t.length > 0 && t.charCodeAt(t.length - 1) === 32 && (t = t.slice(0, -1)), t;
1099
1099
  }
1100
- function Ln(e) {
1100
+ function On(e) {
1101
1101
  return /[\r\f]/.test(e) ? e.replace(/\r\n/g, `
1102
1102
  `).replace(/[\r\f]/g, `
1103
1103
  `) : e;
1104
1104
  }
1105
- let ze = null, On;
1106
- function bn() {
1107
- return ze === null && (ze = new Intl.Segmenter(On, { granularity: "word" })), ze;
1108
- }
1109
- const In = /\p{Script=Arabic}/u, ge = /\p{M}/u, tt = /\p{Nd}/u;
1110
- function mt(e) {
1111
- return In.test(e);
1105
+ let je = null, bn;
1106
+ function In() {
1107
+ return je === null && (je = new Intl.Segmenter(bn, { granularity: "word" })), je;
1112
1108
  }
1109
+ const yn = /\p{Script=Arabic}/u, Ne = /\p{M}/u, nt = /\p{Nd}/u;
1113
1110
  function At(e) {
1111
+ return yn.test(e);
1112
+ }
1113
+ function Et(e) {
1114
1114
  return e >= 19968 && e <= 40959 || e >= 13312 && e <= 19903 || e >= 131072 && e <= 173791 || e >= 173824 && e <= 177983 || e >= 177984 && e <= 178207 || e >= 178208 && e <= 183983 || e >= 183984 && e <= 191471 || e >= 191472 && e <= 192093 || e >= 194560 && e <= 195103 || e >= 196608 && e <= 201551 || e >= 201552 && e <= 205743 || e >= 205744 && e <= 210041 || e >= 63744 && e <= 64255 || e >= 12288 && e <= 12351 || e >= 12352 && e <= 12447 || e >= 12448 && e <= 12543 || e >= 12592 && e <= 12687 || e >= 44032 && e <= 55215 || e >= 65280 && e <= 65519;
1115
1115
  }
1116
1116
  function oe(e) {
@@ -1120,46 +1120,46 @@ function oe(e) {
1120
1120
  if (n >= 55296 && n <= 56319 && t + 1 < e.length) {
1121
1121
  const i = e.charCodeAt(t + 1);
1122
1122
  if (i >= 56320 && i <= 57343) {
1123
- const x = (n - 55296 << 10) + (i - 56320) + 65536;
1124
- if (At(x))
1123
+ const r = (n - 55296 << 10) + (i - 56320) + 65536;
1124
+ if (Et(r))
1125
1125
  return !0;
1126
1126
  t++;
1127
1127
  continue;
1128
1128
  }
1129
1129
  }
1130
- if (At(n))
1130
+ if (Et(n))
1131
1131
  return !0;
1132
1132
  }
1133
1133
  }
1134
1134
  return !1;
1135
1135
  }
1136
- function yn(e) {
1137
- const t = De(e);
1138
- return t !== null && (nt.has(t) || Fe.has(t));
1136
+ function wn(e) {
1137
+ const t = Le(e);
1138
+ return t !== null && (st.has(t) || ge.has(t));
1139
1139
  }
1140
- const wn = /* @__PURE__ */ new Set([
1140
+ const Pn = /* @__PURE__ */ new Set([
1141
1141
  " ",
1142
1142
  " ",
1143
1143
  "⁠",
1144
1144
  "\uFEFF"
1145
- ]), Pn = /* @__PURE__ */ new Set([
1145
+ ]), Wn = /* @__PURE__ */ new Set([
1146
1146
  "-",
1147
1147
  "‐",
1148
1148
  "–",
1149
1149
  "—"
1150
1150
  ]);
1151
- function Wn(e) {
1152
- const t = De(e);
1153
- return t !== null && wn.has(t);
1154
- }
1155
1151
  function vn(e) {
1156
- const t = De(e);
1152
+ const t = Le(e);
1157
1153
  return t !== null && Pn.has(t);
1158
1154
  }
1155
+ function Rn(e) {
1156
+ const t = Le(e);
1157
+ return t !== null && Wn.has(t);
1158
+ }
1159
1159
  function Kt(e, t) {
1160
- return Wn(e) ? !1 : t ? !(yn(e) || vn(e)) : !0;
1160
+ return vn(e) ? !1 : t ? !(wn(e) || Rn(e)) : !0;
1161
1161
  }
1162
- const nt = /* @__PURE__ */ new Set([
1162
+ const st = /* @__PURE__ */ new Set([
1163
1163
  ",",
1164
1164
  ".",
1165
1165
  "!",
@@ -1186,7 +1186,7 @@ const nt = /* @__PURE__ */ new Set([
1186
1186
  "ゞ",
1187
1187
  "ヽ",
1188
1188
  "ヾ"
1189
- ]), We = /* @__PURE__ */ new Set([
1189
+ ]), ve = /* @__PURE__ */ new Set([
1190
1190
  '"',
1191
1191
  "(",
1192
1192
  "[",
@@ -1210,10 +1210,10 @@ const nt = /* @__PURE__ */ new Set([
1210
1210
  "〖",
1211
1211
  "〘",
1212
1212
  "〚"
1213
- ]), st = /* @__PURE__ */ new Set([
1213
+ ]), it = /* @__PURE__ */ new Set([
1214
1214
  "'",
1215
1215
  "’"
1216
- ]), Fe = /* @__PURE__ */ new Set([
1216
+ ]), ge = /* @__PURE__ */ new Set([
1217
1217
  ".",
1218
1218
  ",",
1219
1219
  "!",
@@ -1240,14 +1240,14 @@ const nt = /* @__PURE__ */ new Set([
1240
1240
  "»",
1241
1241
  "›",
1242
1242
  "…"
1243
- ]), Rn = /* @__PURE__ */ new Set([
1243
+ ]), Tn = /* @__PURE__ */ new Set([
1244
1244
  ":",
1245
1245
  ".",
1246
1246
  "،",
1247
1247
  "؛"
1248
- ]), Tn = /* @__PURE__ */ new Set([
1249
- "၏"
1250
1248
  ]), Gn = /* @__PURE__ */ new Set([
1249
+ "၏"
1250
+ ]), Hn = /* @__PURE__ */ new Set([
1251
1251
  "”",
1252
1252
  "’",
1253
1253
  "»",
@@ -1260,39 +1260,39 @@ const nt = /* @__PURE__ */ new Set([
1260
1260
  "〕",
1261
1261
  ")"
1262
1262
  ]);
1263
- function Hn(e) {
1264
- if (it(e))
1263
+ function _n(e) {
1264
+ if (rt(e))
1265
1265
  return !0;
1266
1266
  let t = !1;
1267
1267
  for (const n of e) {
1268
- if (Fe.has(n) || Re(n)) {
1268
+ if (ge.has(n) || Te(n)) {
1269
1269
  t = !0;
1270
1270
  continue;
1271
1271
  }
1272
- if (!(t && ge.test(n)))
1272
+ if (!(t && Ne.test(n)))
1273
1273
  return !1;
1274
1274
  }
1275
1275
  return t;
1276
1276
  }
1277
- function _n(e) {
1277
+ function zn(e) {
1278
1278
  for (const t of e)
1279
- if (!nt.has(t) && !Fe.has(t))
1279
+ if (!st.has(t) && !ge.has(t))
1280
1280
  return !1;
1281
1281
  return e.length > 0;
1282
1282
  }
1283
- function zn(e) {
1284
- if (it(e))
1283
+ function jn(e) {
1284
+ if (rt(e))
1285
1285
  return !0;
1286
1286
  for (const t of e)
1287
- if (!We.has(t) && !st.has(t) && !ge.test(t) && !Re(t))
1287
+ if (!ve.has(t) && !it.has(t) && !Ne.test(t) && !Te(t))
1288
1288
  return !1;
1289
1289
  return e.length > 0;
1290
1290
  }
1291
- function it(e) {
1291
+ function rt(e) {
1292
1292
  let t = !1;
1293
1293
  for (const n of e)
1294
- if (!(n === "\\" || ge.test(n))) {
1295
- if (We.has(n) || Fe.has(n) || st.has(n)) {
1294
+ if (!(n === "\\" || Ne.test(n))) {
1295
+ if (ve.has(n) || ge.has(n) || it.has(n)) {
1296
1296
  t = !0;
1297
1297
  continue;
1298
1298
  }
@@ -1300,41 +1300,41 @@ function it(e) {
1300
1300
  }
1301
1301
  return t;
1302
1302
  }
1303
- function ve(e, t) {
1303
+ function Re(e, t) {
1304
1304
  const n = t - 1;
1305
1305
  if (n <= 0)
1306
1306
  return Math.max(n, 0);
1307
1307
  const i = e.charCodeAt(n);
1308
1308
  if (i < 56320 || i > 57343)
1309
1309
  return n;
1310
- const x = n - 1;
1311
- if (x < 0)
1310
+ const r = n - 1;
1311
+ if (r < 0)
1312
1312
  return n;
1313
- const s = e.charCodeAt(x);
1314
- return s >= 55296 && s <= 56319 ? x : n;
1313
+ const s = e.charCodeAt(r);
1314
+ return s >= 55296 && s <= 56319 ? r : n;
1315
1315
  }
1316
- function De(e) {
1316
+ function Le(e) {
1317
1317
  if (e.length === 0)
1318
1318
  return null;
1319
- const t = ve(e, e.length);
1319
+ const t = Re(e, e.length);
1320
1320
  return e.slice(t);
1321
1321
  }
1322
1322
  function Kn(e) {
1323
1323
  for (const t of e)
1324
- if (!ge.test(t))
1324
+ if (!Ne.test(t))
1325
1325
  return t;
1326
1326
  return null;
1327
1327
  }
1328
- function jn(e) {
1328
+ function Un(e) {
1329
1329
  for (let t = e.length; t > 0; ) {
1330
- const n = ve(e, t), i = e.slice(n, t);
1331
- if (!ge.test(i))
1330
+ const n = Re(e, t), i = e.slice(n, t);
1331
+ if (!Ne.test(i))
1332
1332
  return i;
1333
1333
  t = n;
1334
1334
  }
1335
1335
  return null;
1336
1336
  }
1337
- const Un = [
1337
+ const Jn = [
1338
1338
  36,
1339
1339
  37,
1340
1340
  43,
@@ -1402,34 +1402,34 @@ const Un = [
1402
1402
  126128,
1403
1403
  126128
1404
1404
  ];
1405
- function Jn(e, t) {
1405
+ function Qn(e, t) {
1406
1406
  for (let n = 0; n < t.length; n += 2)
1407
1407
  if (e >= t[n] && e <= t[n + 1])
1408
1408
  return !0;
1409
1409
  return !1;
1410
1410
  }
1411
- function Re(e) {
1411
+ function Te(e) {
1412
1412
  const t = e.codePointAt(0);
1413
- return t !== void 0 && Jn(t, Un);
1414
- }
1415
- function Qn(e) {
1416
- const t = jn(e);
1417
- return t !== null && Re(t);
1413
+ return t !== void 0 && Qn(t, Jn);
1418
1414
  }
1419
1415
  function $n(e) {
1420
- const t = Kn(e);
1421
- return t !== null && tt.test(t);
1416
+ const t = Un(e);
1417
+ return t !== null && Te(t);
1422
1418
  }
1423
1419
  function Yn(e) {
1420
+ const t = Kn(e);
1421
+ return t !== null && nt.test(t);
1422
+ }
1423
+ function Xn(e) {
1424
1424
  const t = Array.from(e);
1425
1425
  let n = t.length;
1426
1426
  for (; n > 0; ) {
1427
1427
  const i = t[n - 1];
1428
- if (ge.test(i)) {
1428
+ if (Ne.test(i)) {
1429
1429
  n--;
1430
1430
  continue;
1431
1431
  }
1432
- if (We.has(i) || st.has(i)) {
1432
+ if (ve.has(i) || it.has(i)) {
1433
1433
  n--;
1434
1434
  continue;
1435
1435
  }
@@ -1440,45 +1440,45 @@ function Yn(e) {
1440
1440
  tail: t.slice(n).join("")
1441
1441
  };
1442
1442
  }
1443
- function Xn(e, t, n) {
1443
+ function qn(e, t, n) {
1444
1444
  return n === "text" && !t && e.length === 1 && e !== "-" && e !== "—" ? e : null;
1445
1445
  }
1446
- function Et(e, t, n, i) {
1447
- const x = t[i], s = e[i];
1448
- if (x == null)
1446
+ function Bt(e, t, n, i) {
1447
+ const r = t[i], s = e[i];
1448
+ if (r == null)
1449
1449
  return s;
1450
1450
  const l = n[i];
1451
1451
  if (s.length === l)
1452
1452
  return s;
1453
- const f = x.repeat(l);
1454
- return e[i] = f, f;
1455
- }
1456
- function Bt(e, t) {
1457
- return e && t !== null && Rn.has(t);
1453
+ const u = r.repeat(l);
1454
+ return e[i] = u, u;
1458
1455
  }
1459
- function qn(e) {
1460
- const t = De(e);
1461
- return t !== null && Tn.has(t);
1456
+ function Mt(e, t) {
1457
+ return e && t !== null && Tn.has(t);
1462
1458
  }
1463
1459
  function Vn(e) {
1460
+ const t = Le(e);
1461
+ return t !== null && Gn.has(t);
1462
+ }
1463
+ function Zn(e) {
1464
1464
  if (e.length < 2 || e[0] !== " ")
1465
1465
  return null;
1466
1466
  const t = e.slice(1);
1467
1467
  return /^\p{M}+$/u.test(t) ? { space: " ", marks: t } : null;
1468
1468
  }
1469
- function $e(e) {
1469
+ function Ye(e) {
1470
1470
  let t = e.length;
1471
1471
  for (; t > 0; ) {
1472
- const n = ve(e, t), i = e.slice(n, t);
1473
- if (Gn.has(i))
1472
+ const n = Re(e, t), i = e.slice(n, t);
1473
+ if (Hn.has(i))
1474
1474
  return !0;
1475
- if (!Fe.has(i))
1475
+ if (!ge.has(i))
1476
1476
  return !1;
1477
1477
  t = n;
1478
1478
  }
1479
1479
  return !1;
1480
1480
  }
1481
- function Zn(e, t) {
1481
+ function e0(e, t) {
1482
1482
  if (t.preserveOrdinarySpaces || t.preserveHardBreaks) {
1483
1483
  if (e === " ")
1484
1484
  return "preserved-space";
@@ -1490,104 +1490,104 @@ function Zn(e, t) {
1490
1490
  }
1491
1491
  return e === " " ? "space" : e === " " || e === " " || e === "⁠" || e === "\uFEFF" ? "glue" : e === "​" ? "zero-width-break" : e === "­" ? "soft-hyphen" : "text";
1492
1492
  }
1493
- const e0 = /[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;
1494
- function xe(e) {
1493
+ const t0 = /[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;
1494
+ function re(e) {
1495
1495
  return e.length === 1 ? e[0] : e.join("");
1496
1496
  }
1497
- function t0(e, t) {
1497
+ function n0(e, t) {
1498
1498
  const n = [];
1499
1499
  for (let i = e.length - 1; i >= 0; i--)
1500
1500
  n.push(e[i]);
1501
- return n.push(t), xe(n);
1501
+ return n.push(t), re(n);
1502
1502
  }
1503
- function n0(e, t, n, i) {
1504
- if (!e0.test(e))
1503
+ function s0(e, t, n, i) {
1504
+ if (!t0.test(e))
1505
1505
  return [{ text: e, isWordLike: t, kind: "text", start: n }];
1506
- const x = [];
1507
- let s = null, l = [], f = n, o = !1, r = 0;
1506
+ const r = [];
1507
+ let s = null, l = [], u = n, o = !1, x = 0;
1508
1508
  for (const c of e) {
1509
- const a = Zn(c, i), u = a === "text" && t;
1510
- if (s !== null && a === s && u === o) {
1511
- l.push(c), r += c.length;
1509
+ const a = e0(c, i), f = a === "text" && t;
1510
+ if (s !== null && a === s && f === o) {
1511
+ l.push(c), x += c.length;
1512
1512
  continue;
1513
1513
  }
1514
- s !== null && x.push({
1515
- text: xe(l),
1514
+ s !== null && r.push({
1515
+ text: re(l),
1516
1516
  isWordLike: o,
1517
1517
  kind: s,
1518
- start: f
1519
- }), s = a, l = [c], f = n + r, o = u, r += c.length;
1518
+ start: u
1519
+ }), s = a, l = [c], u = n + x, o = f, x += c.length;
1520
1520
  }
1521
- return s !== null && x.push({
1522
- text: xe(l),
1521
+ return s !== null && r.push({
1522
+ text: re(l),
1523
1523
  isWordLike: o,
1524
1524
  kind: s,
1525
- start: f
1526
- }), x;
1525
+ start: u
1526
+ }), r;
1527
1527
  }
1528
- function Ye(e) {
1528
+ function Xe(e) {
1529
1529
  return e === "space" || e === "preserved-space" || e === "zero-width-break" || e === "hard-break";
1530
1530
  }
1531
- const s0 = /^[A-Za-z][A-Za-z0-9+.-]*:$/;
1532
- function i0(e, t) {
1531
+ const i0 = /^[A-Za-z][A-Za-z0-9+.-]*:$/;
1532
+ function r0(e, t) {
1533
1533
  const n = e.texts[t];
1534
- return n.startsWith("www.") ? !0 : s0.test(n) && t + 1 < e.len && e.kinds[t + 1] === "text" && e.texts[t + 1] === "//";
1534
+ return n.startsWith("www.") ? !0 : i0.test(n) && t + 1 < e.len && e.kinds[t + 1] === "text" && e.texts[t + 1] === "//";
1535
1535
  }
1536
1536
  function x0(e) {
1537
1537
  return e.includes("?") && (e.includes("://") || e.startsWith("www."));
1538
1538
  }
1539
- function r0(e) {
1540
- const t = e.texts.slice(), n = e.isWordLike.slice(), i = e.kinds.slice(), x = e.starts.slice();
1539
+ function o0(e) {
1540
+ const t = e.texts.slice(), n = e.isWordLike.slice(), i = e.kinds.slice(), r = e.starts.slice();
1541
1541
  for (let l = 0; l < e.len; l++) {
1542
- if (i[l] !== "text" || !i0(e, l))
1542
+ if (i[l] !== "text" || !r0(e, l))
1543
1543
  continue;
1544
- const f = [t[l]];
1544
+ const u = [t[l]];
1545
1545
  let o = l + 1;
1546
- for (; o < e.len && !Ye(i[o]); ) {
1547
- f.push(t[o]), n[l] = !0;
1548
- const r = t[o].includes("?");
1549
- if (i[o] = "text", t[o] = "", o++, r)
1546
+ for (; o < e.len && !Xe(i[o]); ) {
1547
+ u.push(t[o]), n[l] = !0;
1548
+ const x = t[o].includes("?");
1549
+ if (i[o] = "text", t[o] = "", o++, x)
1550
1550
  break;
1551
1551
  }
1552
- t[l] = xe(f);
1552
+ t[l] = re(u);
1553
1553
  }
1554
1554
  let s = 0;
1555
1555
  for (let l = 0; l < t.length; l++) {
1556
- const f = t[l];
1557
- f.length !== 0 && (s !== l && (t[s] = f, n[s] = n[l], i[s] = i[l], x[s] = x[l]), s++);
1556
+ const u = t[l];
1557
+ u.length !== 0 && (s !== l && (t[s] = u, n[s] = n[l], i[s] = i[l], r[s] = r[l]), s++);
1558
1558
  }
1559
- return t.length = s, n.length = s, i.length = s, x.length = s, {
1559
+ return t.length = s, n.length = s, i.length = s, r.length = s, {
1560
1560
  len: s,
1561
1561
  texts: t,
1562
1562
  isWordLike: n,
1563
1563
  kinds: i,
1564
- starts: x
1564
+ starts: r
1565
1565
  };
1566
1566
  }
1567
- function o0(e) {
1568
- const t = [], n = [], i = [], x = [];
1567
+ function l0(e) {
1568
+ const t = [], n = [], i = [], r = [];
1569
1569
  for (let s = 0; s < e.len; s++) {
1570
1570
  const l = e.texts[s];
1571
- if (t.push(l), n.push(e.isWordLike[s]), i.push(e.kinds[s]), x.push(e.starts[s]), !x0(l))
1571
+ if (t.push(l), n.push(e.isWordLike[s]), i.push(e.kinds[s]), r.push(e.starts[s]), !x0(l))
1572
1572
  continue;
1573
- const f = s + 1;
1574
- if (f >= e.len || Ye(e.kinds[f]))
1573
+ const u = s + 1;
1574
+ if (u >= e.len || Xe(e.kinds[u]))
1575
1575
  continue;
1576
- const o = [], r = e.starts[f];
1577
- let c = f;
1578
- for (; c < e.len && !Ye(e.kinds[c]); )
1576
+ const o = [], x = e.starts[u];
1577
+ let c = u;
1578
+ for (; c < e.len && !Xe(e.kinds[c]); )
1579
1579
  o.push(e.texts[c]), c++;
1580
- o.length > 0 && (t.push(xe(o)), n.push(!0), i.push("text"), x.push(r), s = c - 1);
1580
+ o.length > 0 && (t.push(re(o)), n.push(!0), i.push("text"), r.push(x), s = c - 1);
1581
1581
  }
1582
1582
  return {
1583
1583
  len: t.length,
1584
1584
  texts: t,
1585
1585
  isWordLike: n,
1586
1586
  kinds: i,
1587
- starts: x
1587
+ starts: r
1588
1588
  };
1589
1589
  }
1590
- const l0 = /* @__PURE__ */ new Set([
1590
+ const c0 = /* @__PURE__ */ new Set([
1591
1591
  ":",
1592
1592
  "-",
1593
1593
  "/",
@@ -1597,128 +1597,128 @@ const l0 = /* @__PURE__ */ new Set([
1597
1597
  "+",
1598
1598
  "–",
1599
1599
  "—"
1600
- ]), c0 = /* @__PURE__ */ new Set([".", ",", ":", ";"]);
1601
- function Mt(e) {
1600
+ ]), a0 = /* @__PURE__ */ new Set([".", ",", ":", ";"]);
1601
+ function Ct(e) {
1602
1602
  for (let t = e.length; t > 0; ) {
1603
- const n = ve(e, t), i = e.slice(n, t);
1604
- if (ge.test(i)) {
1603
+ const n = Re(e, t), i = e.slice(n, t);
1604
+ if (Ne.test(i)) {
1605
1605
  t = n;
1606
1606
  continue;
1607
1607
  }
1608
- return c0.has(i) || Re(i);
1608
+ return a0.has(i) || Te(i);
1609
1609
  }
1610
1610
  return !1;
1611
1611
  }
1612
- function a0(e, t) {
1612
+ function u0(e, t) {
1613
1613
  return t && !oe(e);
1614
1614
  }
1615
- function jt(e) {
1615
+ function Ut(e) {
1616
1616
  for (const t of e)
1617
- if (tt.test(t))
1617
+ if (nt.test(t))
1618
1618
  return !0;
1619
1619
  return !1;
1620
1620
  }
1621
- function ye(e) {
1621
+ function we(e) {
1622
1622
  if (e.length === 0)
1623
1623
  return !1;
1624
1624
  for (const t of e)
1625
- if (!(tt.test(t) || l0.has(t)))
1625
+ if (!(nt.test(t) || c0.has(t)))
1626
1626
  return !1;
1627
1627
  return !0;
1628
1628
  }
1629
- function u0(e) {
1630
- const t = [], n = [], i = [], x = [];
1629
+ function f0(e) {
1630
+ const t = [], n = [], i = [], r = [];
1631
1631
  for (let s = 0; s < e.len; s++) {
1632
- const l = e.texts[s], f = e.kinds[s];
1633
- if (f === "text" && ye(l) && jt(l)) {
1632
+ const l = e.texts[s], u = e.kinds[s];
1633
+ if (u === "text" && we(l) && Ut(l)) {
1634
1634
  const o = [l];
1635
- let r = s + 1;
1636
- for (; r < e.len && e.kinds[r] === "text" && ye(e.texts[r]); )
1637
- o.push(e.texts[r]), r++;
1638
- t.push(xe(o)), n.push(!0), i.push("text"), x.push(e.starts[s]), s = r - 1;
1635
+ let x = s + 1;
1636
+ for (; x < e.len && e.kinds[x] === "text" && we(e.texts[x]); )
1637
+ o.push(e.texts[x]), x++;
1638
+ t.push(re(o)), n.push(!0), i.push("text"), r.push(e.starts[s]), s = x - 1;
1639
1639
  continue;
1640
1640
  }
1641
- t.push(l), n.push(e.isWordLike[s]), i.push(f), x.push(e.starts[s]);
1641
+ t.push(l), n.push(e.isWordLike[s]), i.push(u), r.push(e.starts[s]);
1642
1642
  }
1643
1643
  return {
1644
1644
  len: t.length,
1645
1645
  texts: t,
1646
1646
  isWordLike: n,
1647
1647
  kinds: i,
1648
- starts: x
1648
+ starts: r
1649
1649
  };
1650
1650
  }
1651
- function f0(e) {
1652
- const t = [], n = [], i = [], x = [];
1651
+ function h0(e) {
1652
+ const t = [], n = [], i = [], r = [];
1653
1653
  for (let s = 0; s < e.len; s++) {
1654
- const l = e.texts[s], f = e.kinds[s], o = e.isWordLike[s];
1655
- if (f === "text" && Mt(l) && (o || Qn(l)) && !oe(l)) {
1656
- const r = [l];
1654
+ const l = e.texts[s], u = e.kinds[s], o = e.isWordLike[s];
1655
+ if (u === "text" && Ct(l) && (o || $n(l)) && !oe(l)) {
1656
+ const x = [l];
1657
1657
  let c = !0, a = s + 1;
1658
- for (; c && a < e.len && e.kinds[a] === "text" && a0(e.texts[a], e.isWordLike[a]); ) {
1659
- const u = e.texts[a];
1660
- r.push(u), c = Mt(u), a++;
1658
+ for (; c && a < e.len && e.kinds[a] === "text" && u0(e.texts[a], e.isWordLike[a]); ) {
1659
+ const f = e.texts[a];
1660
+ x.push(f), c = Ct(f), a++;
1661
1661
  }
1662
- t.push(xe(r)), n.push(!0), i.push("text"), x.push(e.starts[s]), s = a - 1;
1662
+ t.push(re(x)), n.push(!0), i.push("text"), r.push(e.starts[s]), s = a - 1;
1663
1663
  continue;
1664
1664
  }
1665
- t.push(l), n.push(o), i.push(f), x.push(e.starts[s]);
1665
+ t.push(l), n.push(o), i.push(u), r.push(e.starts[s]);
1666
1666
  }
1667
1667
  return {
1668
1668
  len: t.length,
1669
1669
  texts: t,
1670
1670
  isWordLike: n,
1671
1671
  kinds: i,
1672
- starts: x
1672
+ starts: r
1673
1673
  };
1674
1674
  }
1675
- function h0(e) {
1676
- const t = [], n = [], i = [], x = [];
1675
+ function d0(e) {
1676
+ const t = [], n = [], i = [], r = [];
1677
1677
  for (let s = 0; s < e.len; s++) {
1678
1678
  const l = e.texts[s];
1679
1679
  if (e.kinds[s] === "text" && l.includes("-")) {
1680
- const f = l.split("-");
1681
- let o = f.length > 1;
1682
- for (let r = 0; r < f.length; r++) {
1683
- const c = f[r];
1680
+ const u = l.split("-");
1681
+ let o = u.length > 1;
1682
+ for (let x = 0; x < u.length; x++) {
1683
+ const c = u[x];
1684
1684
  if (!o)
1685
1685
  break;
1686
- (c.length === 0 || !jt(c) || !ye(c)) && (o = !1);
1686
+ (c.length === 0 || !Ut(c) || !we(c)) && (o = !1);
1687
1687
  }
1688
1688
  if (o) {
1689
- let r = 0;
1690
- for (let c = 0; c < f.length; c++) {
1691
- const a = f[c], u = c < f.length - 1 ? `${a}-` : a;
1692
- t.push(u), n.push(!0), i.push("text"), x.push(e.starts[s] + r), r += u.length;
1689
+ let x = 0;
1690
+ for (let c = 0; c < u.length; c++) {
1691
+ const a = u[c], f = c < u.length - 1 ? `${a}-` : a;
1692
+ t.push(f), n.push(!0), i.push("text"), r.push(e.starts[s] + x), x += f.length;
1693
1693
  }
1694
1694
  continue;
1695
1695
  }
1696
1696
  }
1697
- t.push(l), n.push(e.isWordLike[s]), i.push(e.kinds[s]), x.push(e.starts[s]);
1697
+ t.push(l), n.push(e.isWordLike[s]), i.push(e.kinds[s]), r.push(e.starts[s]);
1698
1698
  }
1699
1699
  return {
1700
1700
  len: t.length,
1701
1701
  texts: t,
1702
1702
  isWordLike: n,
1703
1703
  kinds: i,
1704
- starts: x
1704
+ starts: r
1705
1705
  };
1706
1706
  }
1707
- function d0(e) {
1708
- const t = [], n = [], i = [], x = [];
1707
+ function F0(e) {
1708
+ const t = [], n = [], i = [], r = [];
1709
1709
  let s = 0;
1710
1710
  for (; s < e.len; ) {
1711
1711
  const l = [e.texts[s]];
1712
- let f = e.isWordLike[s], o = e.kinds[s], r = e.starts[s];
1712
+ let u = e.isWordLike[s], o = e.kinds[s], x = e.starts[s];
1713
1713
  if (o === "glue") {
1714
- const c = [l[0]], a = r;
1714
+ const c = [l[0]], a = x;
1715
1715
  for (s++; s < e.len && e.kinds[s] === "glue"; )
1716
1716
  c.push(e.texts[s]), s++;
1717
- const u = xe(c);
1717
+ const f = re(c);
1718
1718
  if (s < e.len && e.kinds[s] === "text")
1719
- l[0] = u, l.push(e.texts[s]), f = e.isWordLike[s], o = "text", r = a, s++;
1719
+ l[0] = f, l.push(e.texts[s]), u = e.isWordLike[s], o = "text", x = a, s++;
1720
1720
  else {
1721
- t.push(u), n.push(!1), i.push("glue"), x.push(a);
1721
+ t.push(f), n.push(!1), i.push("glue"), r.push(a);
1722
1722
  continue;
1723
1723
  }
1724
1724
  } else
@@ -1728,99 +1728,99 @@ function d0(e) {
1728
1728
  const c = [];
1729
1729
  for (; s < e.len && e.kinds[s] === "glue"; )
1730
1730
  c.push(e.texts[s]), s++;
1731
- const a = xe(c);
1731
+ const a = re(c);
1732
1732
  if (s < e.len && e.kinds[s] === "text") {
1733
- l.push(a, e.texts[s]), f = f || e.isWordLike[s], s++;
1733
+ l.push(a, e.texts[s]), u = u || e.isWordLike[s], s++;
1734
1734
  continue;
1735
1735
  }
1736
1736
  l.push(a);
1737
1737
  }
1738
- t.push(xe(l)), n.push(f), i.push(o), x.push(r);
1738
+ t.push(re(l)), n.push(u), i.push(o), r.push(x);
1739
1739
  }
1740
1740
  return {
1741
1741
  len: t.length,
1742
1742
  texts: t,
1743
1743
  isWordLike: n,
1744
1744
  kinds: i,
1745
- starts: x
1745
+ starts: r
1746
1746
  };
1747
1747
  }
1748
- function F0(e) {
1749
- const t = e.texts.slice(), n = e.isWordLike.slice(), i = e.kinds.slice(), x = e.starts.slice();
1748
+ function g0(e) {
1749
+ const t = e.texts.slice(), n = e.isWordLike.slice(), i = e.kinds.slice(), r = e.starts.slice();
1750
1750
  for (let s = 0; s < t.length - 1; s++) {
1751
1751
  if (i[s] !== "text" || i[s + 1] !== "text" || !oe(t[s]) || !oe(t[s + 1]))
1752
1752
  continue;
1753
- const l = Yn(t[s]);
1754
- l !== null && (t[s] = l.head, t[s + 1] = l.tail + t[s + 1], x[s + 1] = x[s] + l.head.length);
1753
+ const l = Xn(t[s]);
1754
+ l !== null && (t[s] = l.head, t[s + 1] = l.tail + t[s + 1], r[s + 1] = r[s] + l.head.length);
1755
1755
  }
1756
1756
  return {
1757
1757
  len: t.length,
1758
1758
  texts: t,
1759
1759
  isWordLike: n,
1760
1760
  kinds: i,
1761
- starts: x
1761
+ starts: r
1762
1762
  };
1763
1763
  }
1764
- function g0(e, t, n) {
1765
- const i = bn();
1766
- let x = 0;
1767
- const s = [], l = [], f = [], o = [], r = [], c = [], a = [], u = [], d = [], S = [], p = [], A = [];
1764
+ function N0(e, t, n) {
1765
+ const i = In();
1766
+ let r = 0;
1767
+ const s = [], l = [], u = [], o = [], x = [], c = [], a = [], f = [], d = [], S = [], A = [], m = [];
1768
1768
  for (const N of i.segment(e))
1769
- for (const D of n0(N.segment, N.isWordLike ?? !1, N.index, n)) {
1769
+ for (const D of s0(N.segment, N.isWordLike ?? !1, N.index, n)) {
1770
1770
  let y = function() {
1771
- c[m] !== null && (l[m] = [
1772
- Et(s, c, a, m)
1773
- ], c[m] = null), l[m].push(D.text), f[m] = f[m] || D.isWordLike, u[m] = u[m] || P, d[m] = d[m] || W, S[m] = z, p[m] = C, A[m] = Bt(d[m], H);
1771
+ c[p] !== null && (l[p] = [
1772
+ Bt(s, c, a, p)
1773
+ ], c[p] = null), l[p].push(D.text), u[p] = u[p] || D.isWordLike, f[p] = f[p] || P, d[p] = d[p] || W, S[p] = z, A[p] = C, m[p] = Mt(d[p], H);
1774
1774
  };
1775
- const E = D.kind === "text", T = Xn(D.text, D.isWordLike, D.kind), P = oe(D.text), W = mt(D.text), H = De(D.text), z = $e(D.text), C = qn(D.text), m = x - 1;
1776
- t.carryCJKAfterClosingQuote && E && x > 0 && o[m] === "text" && P && u[m] && S[m] || E && x > 0 && o[m] === "text" && _n(D.text) && u[m] || E && x > 0 && o[m] === "text" && p[m] ? y() : E && x > 0 && o[m] === "text" && D.isWordLike && W && A[m] ? (y(), f[m] = !0) : T !== null && x > 0 && o[m] === "text" && c[m] === T ? a[m] = (a[m] ?? 1) + 1 : E && !D.isWordLike && x > 0 && o[m] === "text" && !u[m] && (Hn(D.text) || D.text === "-" && f[m]) ? y() : (s[x] = D.text, l[x] = [D.text], f[x] = D.isWordLike, o[x] = D.kind, r[x] = D.start, c[x] = T, a[x] = T === null ? 0 : 1, u[x] = P, d[x] = W, S[x] = z, p[x] = C, A[x] = Bt(W, H), x++);
1775
+ const E = D.kind === "text", T = qn(D.text, D.isWordLike, D.kind), P = oe(D.text), W = At(D.text), H = Le(D.text), z = Ye(D.text), C = Vn(D.text), p = r - 1;
1776
+ t.carryCJKAfterClosingQuote && E && r > 0 && o[p] === "text" && P && f[p] && S[p] || E && r > 0 && o[p] === "text" && zn(D.text) && f[p] || E && r > 0 && o[p] === "text" && A[p] ? y() : E && r > 0 && o[p] === "text" && D.isWordLike && W && m[p] ? (y(), u[p] = !0) : T !== null && r > 0 && o[p] === "text" && c[p] === T ? a[p] = (a[p] ?? 1) + 1 : E && !D.isWordLike && r > 0 && o[p] === "text" && !f[p] && (_n(D.text) || D.text === "-" && u[p]) ? y() : (s[r] = D.text, l[r] = [D.text], u[r] = D.isWordLike, o[r] = D.kind, x[r] = D.start, c[r] = T, a[r] = T === null ? 0 : 1, f[r] = P, d[r] = W, S[r] = z, A[r] = C, m[r] = Mt(W, H), r++);
1777
1777
  }
1778
- for (let N = 0; N < x; N++) {
1778
+ for (let N = 0; N < r; N++) {
1779
1779
  if (c[N] !== null) {
1780
- s[N] = Et(s, c, a, N);
1780
+ s[N] = Bt(s, c, a, N);
1781
1781
  continue;
1782
1782
  }
1783
- s[N] = xe(l[N]);
1783
+ s[N] = re(l[N]);
1784
1784
  }
1785
- for (let N = 1; N < x; N++)
1786
- o[N] === "text" && !f[N] && it(s[N]) && o[N - 1] === "text" && !u[N - 1] && (s[N - 1] += s[N], f[N - 1] = f[N - 1] || f[N], s[N] = "");
1787
- const M = Array.from({ length: x }, () => null);
1785
+ for (let N = 1; N < r; N++)
1786
+ o[N] === "text" && !u[N] && rt(s[N]) && o[N - 1] === "text" && !f[N - 1] && (s[N - 1] += s[N], u[N - 1] = u[N - 1] || u[N], s[N] = "");
1787
+ const M = Array.from({ length: r }, () => null);
1788
1788
  let v = -1;
1789
- for (let N = x - 1; N >= 0; N--) {
1789
+ for (let N = r - 1; N >= 0; N--) {
1790
1790
  const D = s[N];
1791
1791
  if (D.length !== 0) {
1792
- if (o[N] === "text" && !f[N] && v >= 0 && o[v] === "text" && (zn(D) || D === "-" && $n(s[v]))) {
1792
+ if (o[N] === "text" && !u[N] && v >= 0 && o[v] === "text" && (jn(D) || D === "-" && Yn(s[v]))) {
1793
1793
  const E = M[v] ?? [];
1794
- E.push(D), M[v] = E, r[v] = r[N], s[N] = "";
1794
+ E.push(D), M[v] = E, x[v] = x[N], s[N] = "";
1795
1795
  continue;
1796
1796
  }
1797
1797
  v = N;
1798
1798
  }
1799
1799
  }
1800
- for (let N = 0; N < x; N++) {
1800
+ for (let N = 0; N < r; N++) {
1801
1801
  const D = M[N];
1802
- D != null && (s[N] = t0(D, s[N]));
1802
+ D != null && (s[N] = n0(D, s[N]));
1803
1803
  }
1804
1804
  let L = 0;
1805
- for (let N = 0; N < x; N++) {
1805
+ for (let N = 0; N < r; N++) {
1806
1806
  const D = s[N];
1807
- D.length !== 0 && (L !== N && (s[L] = D, f[L] = f[N], o[L] = o[N], r[L] = r[N]), L++);
1807
+ D.length !== 0 && (L !== N && (s[L] = D, u[L] = u[N], o[L] = o[N], x[L] = x[N]), L++);
1808
1808
  }
1809
- s.length = L, f.length = L, o.length = L, r.length = L;
1810
- const w = d0({
1809
+ s.length = L, u.length = L, o.length = L, x.length = L;
1810
+ const w = F0({
1811
1811
  len: L,
1812
1812
  texts: s,
1813
- isWordLike: f,
1813
+ isWordLike: u,
1814
1814
  kinds: o,
1815
- starts: r
1816
- }), R = F0(f0(h0(u0(o0(r0(w))))));
1815
+ starts: x
1816
+ }), R = g0(h0(d0(f0(l0(o0(w))))));
1817
1817
  for (let N = 0; N < R.len - 1; N++) {
1818
- const D = Vn(R.texts[N]);
1819
- D !== null && (R.kinds[N] !== "space" && R.kinds[N] !== "preserved-space" || R.kinds[N + 1] !== "text" || !mt(R.texts[N + 1]) || (R.texts[N] = D.space, R.isWordLike[N] = !1, R.kinds[N] = R.kinds[N] === "preserved-space" ? "preserved-space" : "space", R.texts[N + 1] = D.marks + R.texts[N + 1], R.starts[N + 1] = R.starts[N] + D.space.length));
1818
+ const D = Zn(R.texts[N]);
1819
+ D !== null && (R.kinds[N] !== "space" && R.kinds[N] !== "preserved-space" || R.kinds[N + 1] !== "text" || !At(R.texts[N + 1]) || (R.texts[N] = D.space, R.isWordLike[N] = !1, R.kinds[N] = R.kinds[N] === "preserved-space" ? "preserved-space" : "space", R.texts[N + 1] = D.marks + R.texts[N + 1], R.starts[N + 1] = R.starts[N] + D.space.length));
1820
1820
  }
1821
1821
  return R;
1822
1822
  }
1823
- function N0(e, t) {
1823
+ function S0(e, t) {
1824
1824
  if (e.len === 0)
1825
1825
  return [];
1826
1826
  if (!t.preserveHardBreaks)
@@ -1831,61 +1831,61 @@ function N0(e, t) {
1831
1831
  }];
1832
1832
  const n = [];
1833
1833
  let i = 0;
1834
- for (let x = 0; x < e.len; x++)
1835
- e.kinds[x] === "hard-break" && (n.push({
1834
+ for (let r = 0; r < e.len; r++)
1835
+ e.kinds[r] === "hard-break" && (n.push({
1836
1836
  startSegmentIndex: i,
1837
- endSegmentIndex: x,
1838
- consumedEndSegmentIndex: x + 1
1839
- }), i = x + 1);
1837
+ endSegmentIndex: r,
1838
+ consumedEndSegmentIndex: r + 1
1839
+ }), i = r + 1);
1840
1840
  return i < e.len && n.push({
1841
1841
  startSegmentIndex: i,
1842
1842
  endSegmentIndex: e.len,
1843
1843
  consumedEndSegmentIndex: e.len
1844
1844
  }), n;
1845
1845
  }
1846
- function S0(e, t, n) {
1846
+ function p0(e, t, n) {
1847
1847
  if (t.len <= 1)
1848
1848
  return t;
1849
- const i = [], x = [], s = [], l = [];
1850
- let f = -1, o = !1;
1851
- function r(u) {
1852
- i.push(t.texts[u]), x.push(t.isWordLike[u]), s.push("text"), l.push(t.starts[u]);
1849
+ const i = [], r = [], s = [], l = [];
1850
+ let u = -1, o = !1;
1851
+ function x(f) {
1852
+ i.push(t.texts[f]), r.push(t.isWordLike[f]), s.push("text"), l.push(t.starts[f]);
1853
1853
  }
1854
- function c(u, d) {
1854
+ function c(f, d) {
1855
1855
  let S = !1;
1856
- for (let M = u; M < d; M++)
1856
+ for (let M = f; M < d; M++)
1857
1857
  S = S || t.isWordLike[M];
1858
- const p = t.starts[u], A = d < t.len ? t.starts[d] : e.length;
1859
- i.push(e.slice(p, A)), x.push(S), s.push("text"), l.push(p);
1858
+ const A = t.starts[f], m = d < t.len ? t.starts[d] : e.length;
1859
+ i.push(e.slice(A, m)), r.push(S), s.push("text"), l.push(A);
1860
1860
  }
1861
- function a(u) {
1862
- if (!(f < 0)) {
1861
+ function a(f) {
1862
+ if (!(u < 0)) {
1863
1863
  if (o)
1864
- f + 1 === u ? r(f) : c(f, u);
1864
+ u + 1 === f ? x(u) : c(u, f);
1865
1865
  else
1866
- for (let d = f; d < u; d++)
1867
- r(d);
1868
- f = -1, o = !1;
1866
+ for (let d = u; d < f; d++)
1867
+ x(d);
1868
+ u = -1, o = !1;
1869
1869
  }
1870
1870
  }
1871
- for (let u = 0; u < t.len; u++) {
1872
- const d = t.texts[u], S = t.kinds[u];
1871
+ for (let f = 0; f < t.len; f++) {
1872
+ const d = t.texts[f], S = t.kinds[f];
1873
1873
  if (S === "text") {
1874
- f >= 0 && !Kt(t.texts[u - 1], n) && a(u), f < 0 && (f = u), o = o || oe(d);
1874
+ u >= 0 && !Kt(t.texts[f - 1], n) && a(f), u < 0 && (u = f), o = o || oe(d);
1875
1875
  continue;
1876
1876
  }
1877
- a(u), i.push(d), x.push(t.isWordLike[u]), s.push(S), l.push(t.starts[u]);
1877
+ a(f), i.push(d), r.push(t.isWordLike[f]), s.push(S), l.push(t.starts[f]);
1878
1878
  }
1879
1879
  return a(t.len), {
1880
1880
  len: i.length,
1881
1881
  texts: i,
1882
- isWordLike: x,
1882
+ isWordLike: r,
1883
1883
  kinds: s,
1884
1884
  starts: l
1885
1885
  };
1886
1886
  }
1887
- function p0(e, t, n = "normal", i = "normal") {
1888
- const x = kn(n), s = x.mode === "pre-wrap" ? Ln(e) : Dn(e);
1887
+ function m0(e, t, n = "normal", i = "normal") {
1888
+ const r = Dn(n), s = r.mode === "pre-wrap" ? On(e) : Ln(e);
1889
1889
  if (s.length === 0)
1890
1890
  return {
1891
1891
  normalized: s,
@@ -1896,19 +1896,19 @@ function p0(e, t, n = "normal", i = "normal") {
1896
1896
  kinds: [],
1897
1897
  starts: []
1898
1898
  };
1899
- const l = g0(s, t, x), f = i === "keep-all" ? S0(s, l, t.breakKeepAllAfterPunctuation) : l;
1899
+ const l = N0(s, t, r), u = i === "keep-all" ? p0(s, l, t.breakKeepAllAfterPunctuation) : l;
1900
1900
  return {
1901
1901
  normalized: s,
1902
- chunks: N0(f, x),
1903
- ...f
1902
+ chunks: S0(u, r),
1903
+ ...u
1904
1904
  };
1905
1905
  }
1906
1906
  let Ae = null;
1907
- const Ct = /* @__PURE__ */ new Map();
1907
+ const kt = /* @__PURE__ */ new Map();
1908
1908
  let Ee = null;
1909
- const m0 = 96, A0 = /\p{Emoji_Presentation}/u, E0 = /[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;
1909
+ const A0 = 96, E0 = /\p{Emoji_Presentation}/u, B0 = /[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;
1910
1910
  let Ke = null;
1911
- const kt = /* @__PURE__ */ new Map();
1911
+ const Dt = /* @__PURE__ */ new Map();
1912
1912
  function xt() {
1913
1913
  if (Ae !== null)
1914
1914
  return Ae;
@@ -1918,9 +1918,9 @@ function xt() {
1918
1918
  return Ae = document.createElement("canvas").getContext("2d"), Ae;
1919
1919
  throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.");
1920
1920
  }
1921
- function B0(e) {
1922
- let t = Ct.get(e);
1923
- return t || (t = /* @__PURE__ */ new Map(), Ct.set(e, t)), t;
1921
+ function M0(e) {
1922
+ let t = kt.get(e);
1923
+ return t || (t = /* @__PURE__ */ new Map(), kt.set(e, t)), t;
1924
1924
  }
1925
1925
  function ue(e, t) {
1926
1926
  let n = t.get(e);
@@ -1949,146 +1949,146 @@ function Be() {
1949
1949
  preferEarlySoftHyphenBreak: n
1950
1950
  }, Ee;
1951
1951
  }
1952
- function M0(e) {
1952
+ function C0(e) {
1953
1953
  const t = e.match(/(\d+(?:\.\d+)?)\s*px/);
1954
1954
  return t ? parseFloat(t[1]) : 16;
1955
1955
  }
1956
- function Ut() {
1956
+ function Jt() {
1957
1957
  return Ke === null && (Ke = new Intl.Segmenter(void 0, { granularity: "grapheme" })), Ke;
1958
1958
  }
1959
- function C0(e) {
1960
- return A0.test(e) || e.includes("️");
1961
- }
1962
1959
  function k0(e) {
1963
- return E0.test(e);
1960
+ return E0.test(e) || e.includes("️");
1964
1961
  }
1965
- function D0(e, t) {
1966
- let n = kt.get(e);
1962
+ function D0(e) {
1963
+ return B0.test(e);
1964
+ }
1965
+ function L0(e, t) {
1966
+ let n = Dt.get(e);
1967
1967
  if (n !== void 0)
1968
1968
  return n;
1969
1969
  const i = xt();
1970
1970
  i.font = e;
1971
- const x = i.measureText("😀").width;
1972
- if (n = 0, x > t + 0.5 && typeof document < "u" && document.body !== null) {
1971
+ const r = i.measureText("😀").width;
1972
+ if (n = 0, r > t + 0.5 && typeof document < "u" && document.body !== null) {
1973
1973
  const s = document.createElement("span");
1974
1974
  s.style.font = e, s.style.display = "inline-block", s.style.visibility = "hidden", s.style.position = "absolute", s.textContent = "😀", document.body.appendChild(s);
1975
1975
  const l = s.getBoundingClientRect().width;
1976
- document.body.removeChild(s), x - l > 0.5 && (n = x - l);
1976
+ document.body.removeChild(s), r - l > 0.5 && (n = r - l);
1977
1977
  }
1978
- return kt.set(e, n), n;
1978
+ return Dt.set(e, n), n;
1979
1979
  }
1980
- function L0(e) {
1980
+ function O0(e) {
1981
1981
  let t = 0;
1982
- const n = Ut();
1982
+ const n = Jt();
1983
1983
  for (const i of n.segment(e))
1984
- C0(i.segment) && t++;
1984
+ k0(i.segment) && t++;
1985
1985
  return t;
1986
1986
  }
1987
- function O0(e, t) {
1988
- return t.emojiCount === void 0 && (t.emojiCount = L0(e)), t.emojiCount;
1987
+ function b0(e, t) {
1988
+ return t.emojiCount === void 0 && (t.emojiCount = O0(e)), t.emojiCount;
1989
1989
  }
1990
- function de(e, t, n) {
1991
- return n === 0 ? t.width : t.width - O0(e, t) * n;
1990
+ function Fe(e, t, n) {
1991
+ return n === 0 ? t.width : t.width - b0(e, t) * n;
1992
1992
  }
1993
- function b0(e, t, n, i, x) {
1994
- if (t.breakableFitAdvances !== void 0 && t.breakableFitMode === x)
1993
+ function I0(e, t, n, i, r) {
1994
+ if (t.breakableFitAdvances !== void 0 && t.breakableFitMode === r)
1995
1995
  return t.breakableFitAdvances;
1996
- t.breakableFitMode = x;
1997
- const s = Ut(), l = [];
1996
+ t.breakableFitMode = r;
1997
+ const s = Jt(), l = [];
1998
1998
  for (const c of s.segment(e))
1999
1999
  l.push(c.segment);
2000
2000
  if (l.length <= 1)
2001
2001
  return t.breakableFitAdvances = null, t.breakableFitAdvances;
2002
- if (x === "sum-graphemes") {
2002
+ if (r === "sum-graphemes") {
2003
2003
  const c = [];
2004
2004
  for (const a of l) {
2005
- const u = ue(a, n);
2006
- c.push(de(a, u, i));
2005
+ const f = ue(a, n);
2006
+ c.push(Fe(a, f, i));
2007
2007
  }
2008
2008
  return t.breakableFitAdvances = c, t.breakableFitAdvances;
2009
2009
  }
2010
- if (x === "pair-context" || l.length > m0) {
2010
+ if (r === "pair-context" || l.length > A0) {
2011
2011
  const c = [];
2012
- let a = null, u = 0;
2012
+ let a = null, f = 0;
2013
2013
  for (const d of l) {
2014
- const S = ue(d, n), p = de(d, S, i);
2014
+ const S = ue(d, n), A = Fe(d, S, i);
2015
2015
  if (a === null)
2016
- c.push(p);
2016
+ c.push(A);
2017
2017
  else {
2018
- const A = a + d, M = ue(A, n);
2019
- c.push(de(A, M, i) - u);
2018
+ const m = a + d, M = ue(m, n);
2019
+ c.push(Fe(m, M, i) - f);
2020
2020
  }
2021
- a = d, u = p;
2021
+ a = d, f = A;
2022
2022
  }
2023
2023
  return t.breakableFitAdvances = c, t.breakableFitAdvances;
2024
2024
  }
2025
- const f = [];
2026
- let o = "", r = 0;
2025
+ const u = [];
2026
+ let o = "", x = 0;
2027
2027
  for (const c of l) {
2028
2028
  o += c;
2029
- const a = ue(o, n), u = de(o, a, i);
2030
- f.push(u - r), r = u;
2029
+ const a = ue(o, n), f = Fe(o, a, i);
2030
+ u.push(f - x), x = f;
2031
2031
  }
2032
- return t.breakableFitAdvances = f, t.breakableFitAdvances;
2032
+ return t.breakableFitAdvances = u, t.breakableFitAdvances;
2033
2033
  }
2034
- function I0(e, t) {
2034
+ function y0(e, t) {
2035
2035
  const n = xt();
2036
2036
  n.font = e;
2037
- const i = B0(e), x = M0(e), s = t ? D0(e, x) : 0;
2038
- return { cache: i, fontSize: x, emojiCorrection: s };
2037
+ const i = M0(e), r = C0(e), s = t ? L0(e, r) : 0;
2038
+ return { cache: i, fontSize: r, emojiCorrection: s };
2039
2039
  }
2040
- function y0(e) {
2040
+ function w0(e) {
2041
2041
  return e === "space" || e === "zero-width-break" || e === "soft-hyphen";
2042
2042
  }
2043
- function Te(e) {
2043
+ function Ge(e) {
2044
2044
  return e === "space" || e === "preserved-space" || e === "tab" || e === "zero-width-break" || e === "soft-hyphen";
2045
2045
  }
2046
- function rt(e, t, n = e.widths.length) {
2046
+ function ot(e, t, n = e.widths.length) {
2047
2047
  for (; t < n; ) {
2048
2048
  const i = e.kinds[t];
2049
- if (!y0(i))
2049
+ if (!w0(i))
2050
2050
  break;
2051
2051
  t++;
2052
2052
  }
2053
2053
  return t;
2054
2054
  }
2055
- function Jt(e, t) {
2055
+ function Qt(e, t) {
2056
2056
  if (t <= 0)
2057
2057
  return 0;
2058
2058
  const n = e % t;
2059
2059
  return Math.abs(n) <= 1e-6 ? t : t - n;
2060
2060
  }
2061
- function Qt(e, t, n) {
2061
+ function $t(e, t, n) {
2062
2062
  return e.letterSpacing !== 0 && t && e.spacingGraphemeCounts[n] > 0 ? e.letterSpacing : 0;
2063
2063
  }
2064
- function ot(e, t) {
2064
+ function lt(e, t) {
2065
2065
  return t === 0 ? 0 : e + t;
2066
2066
  }
2067
- function w0(e, t) {
2067
+ function P0(e, t) {
2068
2068
  return e.letterSpacing !== 0 && e.spacingGraphemeCounts[t] > 0 ? e.letterSpacing : 0;
2069
2069
  }
2070
- function $t(e, t, n, i, x) {
2071
- const s = t === "tab" ? x + w0(e, n) : e.lineEndFitAdvances[n];
2072
- return ot(i, s);
2070
+ function Yt(e, t, n, i, r) {
2071
+ const s = t === "tab" ? r + P0(e, n) : e.lineEndFitAdvances[n];
2072
+ return lt(i, s);
2073
2073
  }
2074
- function we(e, t, n, i) {
2075
- const x = t === "tab" ? 0 : e.lineEndFitAdvances[n];
2076
- return ot(i, x);
2074
+ function Pe(e, t, n, i) {
2075
+ const r = t === "tab" ? 0 : e.lineEndFitAdvances[n];
2076
+ return lt(i, r);
2077
2077
  }
2078
- function Pe(e, t, n, i, x) {
2079
- const s = t === "tab" ? x : e.lineEndPaintAdvances[n];
2080
- return ot(i, s);
2078
+ function We(e, t, n, i, r) {
2079
+ const s = t === "tab" ? r : e.lineEndPaintAdvances[n];
2080
+ return lt(i, s);
2081
2081
  }
2082
- function Yt(e, t, n) {
2082
+ function Xt(e, t, n) {
2083
2083
  return e.letterSpacing !== 0 && t ? n + e.letterSpacing : n;
2084
2084
  }
2085
- function Xt(e, t) {
2085
+ function qt(e, t) {
2086
2086
  return e.letterSpacing === 0 ? t : t + e.letterSpacing;
2087
2087
  }
2088
- function P0(e, t, n, i, x) {
2088
+ function W0(e, t, n, i, r) {
2089
2089
  if (e.letterSpacing === 0)
2090
2090
  return 0;
2091
- if (x > 0)
2091
+ if (r > 0)
2092
2092
  return e.spacingGraphemeCounts[i] > 0 ? e.letterSpacing : 0;
2093
2093
  for (let s = i - 1; s >= t; s--) {
2094
2094
  const l = e.kinds[s];
@@ -2103,68 +2103,68 @@ function P0(e, t, n, i, x) {
2103
2103
  }
2104
2104
  return 0;
2105
2105
  }
2106
- function qt(e, t, n, i, x, s) {
2107
- return t + P0(e, n, i, x, s);
2106
+ function Vt(e, t, n, i, r, s) {
2107
+ return t + W0(e, n, i, r, s);
2108
2108
  }
2109
- function W0(e, t) {
2109
+ function v0(e, t) {
2110
2110
  let n = 0, i = e.chunks.length;
2111
2111
  for (; n < i; ) {
2112
- const x = Math.floor((n + i) / 2);
2113
- t < e.chunks[x].consumedEndSegmentIndex ? i = x : n = x + 1;
2112
+ const r = Math.floor((n + i) / 2);
2113
+ t < e.chunks[r].consumedEndSegmentIndex ? i = r : n = r + 1;
2114
2114
  }
2115
2115
  return n < e.chunks.length ? n : -1;
2116
2116
  }
2117
- function v0(e, t, n) {
2117
+ function R0(e, t, n) {
2118
2118
  let i = n.segmentIndex;
2119
2119
  if (n.graphemeIndex > 0)
2120
2120
  return t;
2121
- const x = e.chunks[t];
2122
- return x.startSegmentIndex === x.endSegmentIndex && i === x.startSegmentIndex || (i < x.startSegmentIndex && (i = x.startSegmentIndex), i = rt(e, i, x.endSegmentIndex), i < x.endSegmentIndex) ? (n.segmentIndex = i, n.graphemeIndex = 0, t) : x.consumedEndSegmentIndex >= e.widths.length ? -1 : (n.segmentIndex = x.consumedEndSegmentIndex, n.graphemeIndex = 0, t + 1);
2121
+ const r = e.chunks[t];
2122
+ return r.startSegmentIndex === r.endSegmentIndex && i === r.startSegmentIndex || (i < r.startSegmentIndex && (i = r.startSegmentIndex), i = ot(e, i, r.endSegmentIndex), i < r.endSegmentIndex) ? (n.segmentIndex = i, n.graphemeIndex = 0, t) : r.consumedEndSegmentIndex >= e.widths.length ? -1 : (n.segmentIndex = r.consumedEndSegmentIndex, n.graphemeIndex = 0, t + 1);
2123
2123
  }
2124
- function R0(e, t) {
2124
+ function T0(e, t) {
2125
2125
  if (t.segmentIndex >= e.widths.length)
2126
2126
  return -1;
2127
- const n = W0(e, t.segmentIndex);
2128
- return n < 0 ? -1 : v0(e, n, t);
2127
+ const n = v0(e, t.segmentIndex);
2128
+ return n < 0 ? -1 : R0(e, n, t);
2129
2129
  }
2130
- function T0(e, t, n) {
2131
- const { widths: i, kinds: x, breakableFitAdvances: s } = e;
2130
+ function G0(e, t, n) {
2131
+ const { widths: i, kinds: r, breakableFitAdvances: s } = e;
2132
2132
  if (i.length === 0)
2133
2133
  return 0;
2134
- const f = Be().lineFitEpsilon, o = t + f;
2135
- let r = 0, c = 0, a = !1, u = 0, d = 0, S = 0, p = 0, A = -1, M = 0;
2134
+ const u = Be().lineFitEpsilon, o = t + u;
2135
+ let x = 0, c = 0, a = !1, f = 0, d = 0, S = 0, A = 0, m = -1, M = 0;
2136
2136
  function v() {
2137
- A = -1, M = 0;
2137
+ m = -1, M = 0;
2138
2138
  }
2139
- function L(T = S, P = p, W = c) {
2140
- r++, n?.(W, u, d, T, P), c = 0, a = !1, v();
2139
+ function L(T = S, P = A, W = c) {
2140
+ x++, n?.(W, f, d, T, P), c = 0, a = !1, v();
2141
2141
  }
2142
2142
  function w(T, P) {
2143
- a = !0, u = T, d = 0, S = T + 1, p = 0, c = P;
2143
+ a = !0, f = T, d = 0, S = T + 1, A = 0, c = P;
2144
2144
  }
2145
2145
  function R(T, P, W) {
2146
- a = !0, u = T, d = P, S = T, p = P + 1, c = W;
2146
+ a = !0, f = T, d = P, S = T, A = P + 1, c = W;
2147
2147
  }
2148
2148
  function N(T, P) {
2149
2149
  if (!a) {
2150
2150
  w(T, P);
2151
2151
  return;
2152
2152
  }
2153
- c += P, S = T + 1, p = 0;
2153
+ c += P, S = T + 1, A = 0;
2154
2154
  }
2155
2155
  function D(T, P) {
2156
2156
  const W = s[T];
2157
2157
  for (let H = P; H < W.length; H++) {
2158
2158
  const z = W[H];
2159
- a ? c + z > o ? (L(), R(T, H, z)) : (c += z, S = T, p = H + 1) : R(T, H, z);
2159
+ a ? c + z > o ? (L(), R(T, H, z)) : (c += z, S = T, A = H + 1) : R(T, H, z);
2160
2160
  }
2161
- a && S === T && p === W.length && (S = T + 1, p = 0);
2161
+ a && S === T && A === W.length && (S = T + 1, A = 0);
2162
2162
  }
2163
2163
  let E = 0;
2164
- for (; E < i.length && !(!a && (E = rt(e, E), E >= i.length)); ) {
2165
- const T = i[E], P = x[E], W = Te(P);
2164
+ for (; E < i.length && !(!a && (E = ot(e, E), E >= i.length)); ) {
2165
+ const T = i[E], P = r[E], W = Ge(P);
2166
2166
  if (!a) {
2167
- T > o && s[E] !== null ? D(E, 0) : w(E, T), W && (A = E + 1, M = c - T), E++;
2167
+ T > o && s[E] !== null ? D(E, 0) : w(E, T), W && (m = E + 1, M = c - T), E++;
2168
2168
  continue;
2169
2169
  }
2170
2170
  if (c + T > o) {
@@ -2172,12 +2172,12 @@ function T0(e, t, n) {
2172
2172
  N(E, T), L(E + 1, 0, c - T), E++;
2173
2173
  continue;
2174
2174
  }
2175
- if (A >= 0) {
2176
- if (S > A || S === A && p > 0) {
2175
+ if (m >= 0) {
2176
+ if (S > m || S === m && A > 0) {
2177
2177
  L();
2178
2178
  continue;
2179
2179
  }
2180
- L(A, 0, M);
2180
+ L(m, 0, M);
2181
2181
  continue;
2182
2182
  }
2183
2183
  if (T > o && s[E] !== null) {
@@ -2187,82 +2187,82 @@ function T0(e, t, n) {
2187
2187
  L();
2188
2188
  continue;
2189
2189
  }
2190
- N(E, T), W && (A = E + 1, M = c - T), E++;
2190
+ N(E, T), W && (m = E + 1, M = c - T), E++;
2191
2191
  }
2192
- return a && L(), r;
2192
+ return a && L(), x;
2193
2193
  }
2194
- function G0(e, t, n) {
2194
+ function H0(e, t, n) {
2195
2195
  if (e.simpleLineWalkFastPath)
2196
- return T0(e, t, n);
2197
- const { widths: i, kinds: x, breakableFitAdvances: s, discretionaryHyphenWidth: l, chunks: f } = e;
2198
- if (i.length === 0 || f.length === 0)
2196
+ return G0(e, t, n);
2197
+ const { widths: i, kinds: r, breakableFitAdvances: s, discretionaryHyphenWidth: l, chunks: u } = e;
2198
+ if (i.length === 0 || u.length === 0)
2199
2199
  return 0;
2200
- const o = Be(), r = o.lineFitEpsilon, c = t + r;
2201
- let a = 0, u = 0, d = !1, S = 0, p = 0, A = 0, M = 0, v = -1, L = 0, w = 0, R = null;
2200
+ const o = Be(), x = o.lineFitEpsilon, c = t + x;
2201
+ let a = 0, f = 0, d = !1, S = 0, A = 0, m = 0, M = 0, v = -1, L = 0, w = 0, R = null;
2202
2202
  function N() {
2203
2203
  v = -1, L = 0, w = 0, R = null;
2204
2204
  }
2205
2205
  function D() {
2206
- return R === "soft-hyphen" && v === A && M === 0 ? w : u;
2206
+ return R === "soft-hyphen" && v === m && M === 0 ? w : f;
2207
2207
  }
2208
- function E(m = A, y = M, k) {
2209
- a++, n !== void 0 && n(qt(e, k ?? D(), S, p, m, y), S, p, m, y), u = 0, d = !1, N();
2208
+ function E(p = m, y = M, k) {
2209
+ a++, n !== void 0 && n(Vt(e, k ?? D(), S, A, p, y), S, A, p, y), f = 0, d = !1, N();
2210
2210
  }
2211
- function T(m, y) {
2212
- d = !0, S = m, p = 0, A = m + 1, M = 0, u = y;
2211
+ function T(p, y) {
2212
+ d = !0, S = p, A = 0, m = p + 1, M = 0, f = y;
2213
2213
  }
2214
- function P(m, y, k) {
2215
- d = !0, S = m, p = y, A = m, M = y + 1, u = k;
2214
+ function P(p, y, k) {
2215
+ d = !0, S = p, A = y, m = p, M = y + 1, f = k;
2216
2216
  }
2217
- function W(m, y) {
2217
+ function W(p, y) {
2218
2218
  if (!d) {
2219
- T(m, y);
2219
+ T(p, y);
2220
2220
  return;
2221
2221
  }
2222
- u += y, A = m + 1, M = 0;
2222
+ f += y, m = p + 1, M = 0;
2223
2223
  }
2224
- function H(m, y, k, b, U, J) {
2224
+ function H(p, y, k, O, U, J) {
2225
2225
  if (!y)
2226
2226
  return;
2227
- const $ = we(e, m, k, U), te = Pe(e, m, k, U, b);
2228
- v = k + 1, L = u - J + $, w = u - J + te, R = m;
2227
+ const Y = Pe(e, p, k, U), te = We(e, p, k, U, O);
2228
+ v = k + 1, L = f - J + Y, w = f - J + te, R = p;
2229
2229
  }
2230
- function z(m, y) {
2231
- const k = s[m];
2232
- for (let b = y; b < k.length; b++) {
2233
- const U = k[b];
2230
+ function z(p, y) {
2231
+ const k = s[p];
2232
+ for (let O = y; O < k.length; O++) {
2233
+ const U = k[O];
2234
2234
  if (!d)
2235
- P(m, b, U);
2235
+ P(p, O, U);
2236
2236
  else {
2237
- const J = Yt(e, !0, U), $ = u + J;
2238
- Xt(e, $) > c ? (E(), P(m, b, U)) : (u = $, A = m, M = b + 1);
2237
+ const J = Xt(e, !0, U), Y = f + J;
2238
+ qt(e, Y) > c ? (E(), P(p, O, U)) : (f = Y, m = p, M = O + 1);
2239
2239
  }
2240
2240
  }
2241
- d && A === m && M === k.length && (A = m + 1, M = 0);
2241
+ d && m === p && M === k.length && (m = p + 1, M = 0);
2242
2242
  }
2243
- function C(m) {
2244
- a++, n?.(0, m.startSegmentIndex, 0, m.consumedEndSegmentIndex, 0), N();
2243
+ function C(p) {
2244
+ a++, n?.(0, p.startSegmentIndex, 0, p.consumedEndSegmentIndex, 0), N();
2245
2245
  }
2246
- for (let m = 0; m < f.length; m++) {
2247
- const y = f[m];
2246
+ for (let p = 0; p < u.length; p++) {
2247
+ const y = u[p];
2248
2248
  if (y.startSegmentIndex === y.endSegmentIndex) {
2249
2249
  C(y);
2250
2250
  continue;
2251
2251
  }
2252
- d = !1, u = 0, S = y.startSegmentIndex, p = 0, A = y.startSegmentIndex, M = 0, N();
2252
+ d = !1, f = 0, S = y.startSegmentIndex, A = 0, m = y.startSegmentIndex, M = 0, N();
2253
2253
  let k = y.startSegmentIndex;
2254
- for (; k < y.endSegmentIndex && !(!d && (k = rt(e, k, y.endSegmentIndex), k >= y.endSegmentIndex)); ) {
2255
- const b = x[k], U = Te(b), J = Qt(e, d, k), $ = b === "tab" ? Jt(u + J, e.tabStopAdvance) : i[k], te = J + $, ne = $t(e, b, k, J, $);
2256
- if (b === "soft-hyphen") {
2257
- d && (A = k + 1, M = 0, v = k + 1, L = u + l, w = u + l, R = b), k++;
2254
+ for (; k < y.endSegmentIndex && !(!d && (k = ot(e, k, y.endSegmentIndex), k >= y.endSegmentIndex)); ) {
2255
+ const O = r[k], U = Ge(O), J = $t(e, d, k), Y = O === "tab" ? Qt(f + J, e.tabStopAdvance) : i[k], te = J + Y, ne = Yt(e, O, k, J, Y);
2256
+ if (O === "soft-hyphen") {
2257
+ d && (m = k + 1, M = 0, v = k + 1, L = f + l, w = f + l, R = O), k++;
2258
2258
  continue;
2259
2259
  }
2260
2260
  if (!d) {
2261
- ne > c && s[k] !== null ? z(k, 0) : T(k, $), H(b, U, k, $, J, te), k++;
2261
+ ne > c && s[k] !== null ? z(k, 0) : T(k, Y), H(O, U, k, Y, J, te), k++;
2262
2262
  continue;
2263
2263
  }
2264
- if (u + ne > c) {
2265
- const Z = u + we(e, b, k, J), le = u + Pe(e, b, k, J, $);
2264
+ if (f + ne > c) {
2265
+ const Z = f + Pe(e, O, k, J), le = f + We(e, O, k, J, Y);
2266
2266
  if (R === "soft-hyphen" && o.preferEarlySoftHyphenBreak && L <= c) {
2267
2267
  E(v, 0, w);
2268
2268
  continue;
@@ -2272,12 +2272,12 @@ function G0(e, t, n) {
2272
2272
  continue;
2273
2273
  }
2274
2274
  if (v >= 0 && L <= c) {
2275
- if (A > v || A === v && M > 0) {
2275
+ if (m > v || m === v && M > 0) {
2276
2276
  E();
2277
2277
  continue;
2278
2278
  }
2279
- const re = v;
2280
- E(re, 0, w), k = re;
2279
+ const xe = v;
2280
+ E(xe, 0, w), k = xe;
2281
2281
  continue;
2282
2282
  }
2283
2283
  if (ne > c && s[k] !== null) {
@@ -2287,87 +2287,87 @@ function G0(e, t, n) {
2287
2287
  E();
2288
2288
  continue;
2289
2289
  }
2290
- W(k, te), H(b, U, k, $, J, te), k++;
2290
+ W(k, te), H(O, U, k, Y, J, te), k++;
2291
2291
  }
2292
2292
  if (d) {
2293
- const b = v === y.consumedEndSegmentIndex ? w : u;
2294
- E(y.consumedEndSegmentIndex, 0, b);
2293
+ const O = v === y.consumedEndSegmentIndex ? w : f;
2294
+ E(y.consumedEndSegmentIndex, 0, O);
2295
2295
  }
2296
2296
  }
2297
2297
  return a;
2298
2298
  }
2299
- function H0(e, t, n, i) {
2300
- const x = e.chunks[n];
2301
- if (x.startSegmentIndex === x.endSegmentIndex)
2302
- return t.segmentIndex = x.consumedEndSegmentIndex, t.graphemeIndex = 0, 0;
2303
- const { widths: s, kinds: l, breakableFitAdvances: f, discretionaryHyphenWidth: o } = e, r = Be(), c = r.lineFitEpsilon, a = i + c, u = t.segmentIndex, d = t.graphemeIndex;
2304
- let S = 0, p = !1, A = t.segmentIndex, M = t.graphemeIndex, v = -1, L = 0, w = 0, R = null;
2299
+ function _0(e, t, n, i) {
2300
+ const r = e.chunks[n];
2301
+ if (r.startSegmentIndex === r.endSegmentIndex)
2302
+ return t.segmentIndex = r.consumedEndSegmentIndex, t.graphemeIndex = 0, 0;
2303
+ const { widths: s, kinds: l, breakableFitAdvances: u, discretionaryHyphenWidth: o } = e, x = Be(), c = x.lineFitEpsilon, a = i + c, f = t.segmentIndex, d = t.graphemeIndex;
2304
+ let S = 0, A = !1, m = t.segmentIndex, M = t.graphemeIndex, v = -1, L = 0, w = 0, R = null;
2305
2305
  function N() {
2306
- return R === "soft-hyphen" && v === A && M === 0 ? w : S;
2306
+ return R === "soft-hyphen" && v === m && M === 0 ? w : S;
2307
2307
  }
2308
- function D(C = A, m = M, y = N()) {
2309
- return p ? (t.segmentIndex = C, t.graphemeIndex = m, qt(e, y, u, d, C, m)) : null;
2308
+ function D(C = m, p = M, y = N()) {
2309
+ return A ? (t.segmentIndex = C, t.graphemeIndex = p, Vt(e, y, f, d, C, p)) : null;
2310
2310
  }
2311
- function E(C, m) {
2312
- p = !0, A = C + 1, M = 0, S = m;
2311
+ function E(C, p) {
2312
+ A = !0, m = C + 1, M = 0, S = p;
2313
2313
  }
2314
- function T(C, m, y) {
2315
- p = !0, A = C, M = m + 1, S = y;
2314
+ function T(C, p, y) {
2315
+ A = !0, m = C, M = p + 1, S = y;
2316
2316
  }
2317
- function P(C, m) {
2318
- if (!p) {
2319
- E(C, m);
2317
+ function P(C, p) {
2318
+ if (!A) {
2319
+ E(C, p);
2320
2320
  return;
2321
2321
  }
2322
- S += m, A = C + 1, M = 0;
2322
+ S += p, m = C + 1, M = 0;
2323
2323
  }
2324
- function W(C, m, y, k, b, U) {
2325
- if (!m)
2324
+ function W(C, p, y, k, O, U) {
2325
+ if (!p)
2326
2326
  return;
2327
- const J = we(e, C, y, b), $ = Pe(e, C, y, b, k);
2328
- v = y + 1, L = S - U + J, w = S - U + $, R = C;
2329
- }
2330
- function H(C, m) {
2331
- const y = f[C];
2332
- for (let k = m; k < y.length; k++) {
2333
- const b = y[k];
2334
- if (!p)
2335
- T(C, k, b);
2327
+ const J = Pe(e, C, y, O), Y = We(e, C, y, O, k);
2328
+ v = y + 1, L = S - U + J, w = S - U + Y, R = C;
2329
+ }
2330
+ function H(C, p) {
2331
+ const y = u[C];
2332
+ for (let k = p; k < y.length; k++) {
2333
+ const O = y[k];
2334
+ if (!A)
2335
+ T(C, k, O);
2336
2336
  else {
2337
- const U = Yt(e, !0, b), J = S + U;
2338
- if (Xt(e, J) > a)
2337
+ const U = Xt(e, !0, O), J = S + U;
2338
+ if (qt(e, J) > a)
2339
2339
  return D();
2340
- S = J, A = C, M = k + 1;
2340
+ S = J, m = C, M = k + 1;
2341
2341
  }
2342
2342
  }
2343
- return p && A === C && M === y.length && (A = C + 1, M = 0), null;
2343
+ return A && m === C && M === y.length && (m = C + 1, M = 0), null;
2344
2344
  }
2345
2345
  function z() {
2346
2346
  return R !== "soft-hyphen" || v < 0 ? null : L <= a ? D(v, 0, w) : null;
2347
2347
  }
2348
- for (let C = t.segmentIndex; C < x.endSegmentIndex; C++) {
2349
- const m = l[C], y = Te(m), k = C === t.segmentIndex ? t.graphemeIndex : 0, b = Qt(e, p, C), U = m === "tab" ? Jt(S + b, e.tabStopAdvance) : s[C], J = b + U, $ = $t(e, m, C, b, U);
2350
- if (m === "soft-hyphen" && k === 0) {
2351
- p && (A = C + 1, M = 0, v = C + 1, L = S + o, w = S + o, R = m);
2348
+ for (let C = t.segmentIndex; C < r.endSegmentIndex; C++) {
2349
+ const p = l[C], y = Ge(p), k = C === t.segmentIndex ? t.graphemeIndex : 0, O = $t(e, A, C), U = p === "tab" ? Qt(S + O, e.tabStopAdvance) : s[C], J = O + U, Y = Yt(e, p, C, O, U);
2350
+ if (p === "soft-hyphen" && k === 0) {
2351
+ A && (m = C + 1, M = 0, v = C + 1, L = S + o, w = S + o, R = p);
2352
2352
  continue;
2353
2353
  }
2354
- if (!p) {
2354
+ if (!A) {
2355
2355
  if (k > 0) {
2356
2356
  const ne = H(C, k);
2357
2357
  if (ne !== null)
2358
2358
  return ne;
2359
- } else if ($ > a && f[C] !== null) {
2359
+ } else if (Y > a && u[C] !== null) {
2360
2360
  const ne = H(C, 0);
2361
2361
  if (ne !== null)
2362
2362
  return ne;
2363
2363
  } else
2364
2364
  E(C, U);
2365
- W(m, y, C, U, b, J);
2365
+ W(p, y, C, U, O, J);
2366
2366
  continue;
2367
2367
  }
2368
- if (S + $ > a) {
2369
- const ne = S + we(e, m, C, b), he = S + Pe(e, m, C, b, U);
2370
- if (R === "soft-hyphen" && r.preferEarlySoftHyphenBreak && L <= a)
2368
+ if (S + Y > a) {
2369
+ const ne = S + Pe(e, p, C, O), he = S + We(e, p, C, O, U);
2370
+ if (R === "soft-hyphen" && x.preferEarlySoftHyphenBreak && L <= a)
2371
2371
  return D(v, 0, w);
2372
2372
  const Z = z();
2373
2373
  if (Z !== null)
@@ -2375,103 +2375,103 @@ function H0(e, t, n, i) {
2375
2375
  if (y && ne <= a)
2376
2376
  return P(C, J), D(C + 1, 0, he);
2377
2377
  if (v >= 0 && L <= a)
2378
- return A > v || A === v && M > 0 ? D() : D(v, 0, w);
2379
- if ($ > a && f[C] !== null) {
2378
+ return m > v || m === v && M > 0 ? D() : D(v, 0, w);
2379
+ if (Y > a && u[C] !== null) {
2380
2380
  const le = D();
2381
2381
  if (le !== null)
2382
2382
  return le;
2383
- const re = H(C, 0);
2384
- if (re !== null)
2385
- return re;
2383
+ const xe = H(C, 0);
2384
+ if (xe !== null)
2385
+ return xe;
2386
2386
  }
2387
2387
  return D();
2388
2388
  }
2389
- P(C, J), W(m, y, C, U, b, J);
2389
+ P(C, J), W(p, y, C, U, O, J);
2390
2390
  }
2391
- return v === x.consumedEndSegmentIndex && M === 0 ? D(x.consumedEndSegmentIndex, 0, w) : D(x.consumedEndSegmentIndex, 0, S);
2391
+ return v === r.consumedEndSegmentIndex && M === 0 ? D(r.consumedEndSegmentIndex, 0, w) : D(r.consumedEndSegmentIndex, 0, S);
2392
2392
  }
2393
- function _0(e, t, n) {
2394
- const { widths: i, kinds: x, breakableFitAdvances: s } = e, f = Be().lineFitEpsilon, o = n + f;
2395
- let r = 0, c = !1, a = t.segmentIndex, u = t.graphemeIndex, d = -1, S = 0;
2396
- for (let p = t.segmentIndex; p < i.length; p++) {
2397
- const A = x[p], M = Te(A), v = p === t.segmentIndex ? t.graphemeIndex : 0, L = s[p], w = i[p];
2393
+ function z0(e, t, n) {
2394
+ const { widths: i, kinds: r, breakableFitAdvances: s } = e, u = Be().lineFitEpsilon, o = n + u;
2395
+ let x = 0, c = !1, a = t.segmentIndex, f = t.graphemeIndex, d = -1, S = 0;
2396
+ for (let A = t.segmentIndex; A < i.length; A++) {
2397
+ const m = r[A], M = Ge(m), v = A === t.segmentIndex ? t.graphemeIndex : 0, L = s[A], w = i[A];
2398
2398
  if (!c) {
2399
2399
  if (v > 0 || w > o && L !== null) {
2400
2400
  const R = L, N = R[v];
2401
- c = !0, r = N, a = p, u = v + 1;
2401
+ c = !0, x = N, a = A, f = v + 1;
2402
2402
  for (let D = v + 1; D < R.length; D++) {
2403
2403
  const E = R[D];
2404
- if (r + E > o)
2405
- return t.segmentIndex = a, t.graphemeIndex = u, r;
2406
- r += E, a = p, u = D + 1;
2404
+ if (x + E > o)
2405
+ return t.segmentIndex = a, t.graphemeIndex = f, x;
2406
+ x += E, a = A, f = D + 1;
2407
2407
  }
2408
- a === p && u === R.length && (a = p + 1, u = 0);
2408
+ a === A && f === R.length && (a = A + 1, f = 0);
2409
2409
  } else
2410
- c = !0, r = w, a = p + 1, u = 0;
2411
- M && (d = p + 1, S = r - w);
2410
+ c = !0, x = w, a = A + 1, f = 0;
2411
+ M && (d = A + 1, S = x - w);
2412
2412
  continue;
2413
2413
  }
2414
- if (r + w > o)
2415
- return M ? (t.segmentIndex = p + 1, t.graphemeIndex = 0, r) : d >= 0 ? a > d || a === d && u > 0 ? (t.segmentIndex = a, t.graphemeIndex = u, r) : (t.segmentIndex = d, t.graphemeIndex = 0, S) : (t.segmentIndex = a, t.graphemeIndex = u, r);
2416
- r += w, a = p + 1, u = 0, M && (d = p + 1, S = r - w);
2414
+ if (x + w > o)
2415
+ return M ? (t.segmentIndex = A + 1, t.graphemeIndex = 0, x) : d >= 0 ? a > d || a === d && f > 0 ? (t.segmentIndex = a, t.graphemeIndex = f, x) : (t.segmentIndex = d, t.graphemeIndex = 0, S) : (t.segmentIndex = a, t.graphemeIndex = f, x);
2416
+ x += w, a = A + 1, f = 0, M && (d = A + 1, S = x - w);
2417
2417
  }
2418
- return c ? (t.segmentIndex = a, t.graphemeIndex = u, r) : null;
2418
+ return c ? (t.segmentIndex = a, t.graphemeIndex = f, x) : null;
2419
2419
  }
2420
- function z0(e, t, n, i) {
2421
- return e.simpleLineWalkFastPath ? _0(e, t, i) : H0(e, t, n, i);
2420
+ function j0(e, t, n, i) {
2421
+ return e.simpleLineWalkFastPath ? z0(e, t, i) : _0(e, t, n, i);
2422
2422
  }
2423
- function Xe(e, t, n) {
2424
- const i = R0(e, t);
2425
- return i < 0 ? null : z0(e, t, i, n);
2423
+ function qe(e, t, n) {
2424
+ const i = T0(e, t);
2425
+ return i < 0 ? null : j0(e, t, i, n);
2426
2426
  }
2427
- let je = null, Dt = /* @__PURE__ */ new WeakMap();
2427
+ let Ue = null, Lt = /* @__PURE__ */ new WeakMap();
2428
2428
  function K0() {
2429
- return je === null && (je = new Intl.Segmenter(void 0, { granularity: "grapheme" })), je;
2429
+ return Ue === null && (Ue = new Intl.Segmenter(void 0, { granularity: "grapheme" })), Ue;
2430
2430
  }
2431
- function Lt(e, t, n) {
2431
+ function Ot(e, t, n) {
2432
2432
  let i = n.get(e);
2433
2433
  if (i !== void 0)
2434
2434
  return i;
2435
2435
  i = [];
2436
- const x = K0();
2437
- for (const s of x.segment(t[e]))
2436
+ const r = K0();
2437
+ for (const s of r.segment(t[e]))
2438
2438
  i.push(s.segment);
2439
2439
  return n.set(e, i), i;
2440
2440
  }
2441
- function j0(e, t, n) {
2441
+ function U0(e, t, n) {
2442
2442
  return n > t && e[n - 1] === "soft-hyphen";
2443
2443
  }
2444
- function Ot(e, t, n, i) {
2445
- for (let x = n; x < i; x++)
2446
- e += t[x];
2444
+ function bt(e, t, n, i) {
2445
+ for (let r = n; r < i; r++)
2446
+ e += t[r];
2447
2447
  return e;
2448
2448
  }
2449
- function U0(e) {
2450
- let t = Dt.get(e);
2451
- return t !== void 0 || (t = /* @__PURE__ */ new Map(), Dt.set(e, t)), t;
2449
+ function J0(e) {
2450
+ let t = Lt.get(e);
2451
+ return t !== void 0 || (t = /* @__PURE__ */ new Map(), Lt.set(e, t)), t;
2452
2452
  }
2453
- function J0(e, t, n, i, x, s) {
2453
+ function Q0(e, t, n, i, r, s) {
2454
2454
  let l = "";
2455
- const f = j0(e.kinds, n, x);
2456
- for (let o = n; o < x; o++)
2455
+ const u = U0(e.kinds, n, r);
2456
+ for (let o = n; o < r; o++)
2457
2457
  if (!(e.kinds[o] === "soft-hyphen" || e.kinds[o] === "hard-break"))
2458
2458
  if (o === n && i > 0) {
2459
- const r = Lt(o, e.segments, t);
2460
- l = Ot(l, r, i, r.length);
2459
+ const x = Ot(o, e.segments, t);
2460
+ l = bt(l, x, i, x.length);
2461
2461
  } else
2462
2462
  l += e.segments[o];
2463
2463
  if (s > 0) {
2464
- f && (l += "-");
2465
- const o = Lt(x, e.segments, t);
2466
- l = Ot(l, o, n === x ? i : 0, s);
2467
- } else f && (l += "-");
2464
+ u && (l += "-");
2465
+ const o = Ot(r, e.segments, t);
2466
+ l = bt(l, o, n === r ? i : 0, s);
2467
+ } else u && (l += "-");
2468
2468
  return l;
2469
2469
  }
2470
- let Ue = null;
2471
- function Vt() {
2472
- return Ue === null && (Ue = new Intl.Segmenter(void 0, { granularity: "grapheme" })), Ue;
2470
+ let Je = null;
2471
+ function Zt() {
2472
+ return Je === null && (Je = new Intl.Segmenter(void 0, { granularity: "grapheme" })), Je;
2473
2473
  }
2474
- function Q0(e) {
2474
+ function $0(e) {
2475
2475
  return {
2476
2476
  widths: [],
2477
2477
  lineEndFitAdvances: [],
@@ -2488,106 +2488,106 @@ function Q0(e) {
2488
2488
  segments: []
2489
2489
  };
2490
2490
  }
2491
- function $0(e, t) {
2491
+ function Y0(e, t) {
2492
2492
  const n = [];
2493
- let i = [], x = 0, s = !1, l = !1, f = !1;
2493
+ let i = [], r = 0, s = !1, l = !1, u = !1;
2494
2494
  function o() {
2495
2495
  i.length !== 0 && (n.push({
2496
2496
  text: i.length === 1 ? i[0] : i.join(""),
2497
- start: x
2498
- }), i = [], s = !1, l = !1, f = !1);
2497
+ start: r
2498
+ }), i = [], s = !1, l = !1, u = !1);
2499
2499
  }
2500
- function r(a, u, d) {
2501
- i = [a], x = u, s = d, l = $e(a), f = We.has(a);
2500
+ function x(a, f, d) {
2501
+ i = [a], r = f, s = d, l = Ye(a), u = ve.has(a);
2502
2502
  }
2503
- function c(a, u) {
2504
- i.push(a), s = s || u;
2505
- const d = $e(a);
2506
- a.length === 1 && Fe.has(a) ? l = l || d : l = d, f = !1;
2503
+ function c(a, f) {
2504
+ i.push(a), s = s || f;
2505
+ const d = Ye(a);
2506
+ a.length === 1 && ge.has(a) ? l = l || d : l = d, u = !1;
2507
2507
  }
2508
- for (const a of Vt().segment(e)) {
2509
- const u = a.segment, d = oe(u);
2508
+ for (const a of Zt().segment(e)) {
2509
+ const f = a.segment, d = oe(f);
2510
2510
  if (i.length === 0) {
2511
- r(u, a.index, d);
2511
+ x(f, a.index, d);
2512
2512
  continue;
2513
2513
  }
2514
- if (f || nt.has(u) || Fe.has(u) || t.carryCJKAfterClosingQuote && d && l) {
2515
- c(u, d);
2514
+ if (u || st.has(f) || ge.has(f) || t.carryCJKAfterClosingQuote && d && l) {
2515
+ c(f, d);
2516
2516
  continue;
2517
2517
  }
2518
2518
  if (!s && !d) {
2519
- c(u, d);
2519
+ c(f, d);
2520
2520
  continue;
2521
2521
  }
2522
- o(), r(u, a.index, d);
2522
+ o(), x(f, a.index, d);
2523
2523
  }
2524
2524
  return o(), n;
2525
2525
  }
2526
- function Y0(e, t, n) {
2526
+ function X0(e, t, n) {
2527
2527
  if (t.length <= 1)
2528
2528
  return t;
2529
2529
  const i = [];
2530
- let x = -1, s = !1;
2531
- function l(o, r) {
2532
- const c = t[o].start, a = r < t.length ? t[r].start : e.length;
2530
+ let r = -1, s = !1;
2531
+ function l(o, x) {
2532
+ const c = t[o].start, a = x < t.length ? t[x].start : e.length;
2533
2533
  i.push({
2534
2534
  text: e.slice(c, a),
2535
2535
  start: c
2536
2536
  });
2537
2537
  }
2538
- function f(o) {
2539
- if (!(x < 0)) {
2538
+ function u(o) {
2539
+ if (!(r < 0)) {
2540
2540
  if (s)
2541
- x + 1 === o ? i.push(t[x]) : l(x, o);
2541
+ r + 1 === o ? i.push(t[r]) : l(r, o);
2542
2542
  else
2543
- for (let r = x; r < o; r++)
2544
- i.push(t[r]);
2545
- x = -1, s = !1;
2543
+ for (let x = r; x < o; x++)
2544
+ i.push(t[x]);
2545
+ r = -1, s = !1;
2546
2546
  }
2547
2547
  }
2548
2548
  for (let o = 0; o < t.length; o++) {
2549
- const r = t[o];
2550
- x >= 0 && !Kt(t[o - 1].text, n) && f(o), x < 0 && (x = o), s = s || oe(r.text);
2549
+ const x = t[o];
2550
+ r >= 0 && !Kt(t[o - 1].text, n) && u(o), r < 0 && (r = o), s = s || oe(x.text);
2551
2551
  }
2552
- return f(t.length), i;
2552
+ return u(t.length), i;
2553
2553
  }
2554
- function bt(e, t) {
2554
+ function It(e, t) {
2555
2555
  if (t === "zero-width-break" || t === "soft-hyphen" || t === "hard-break")
2556
2556
  return 0;
2557
2557
  if (t === "tab")
2558
2558
  return 1;
2559
2559
  let n = 0;
2560
- const i = Vt();
2561
- for (const x of i.segment(e))
2560
+ const i = Zt();
2561
+ for (const r of i.segment(e))
2562
2562
  n++;
2563
2563
  return n;
2564
2564
  }
2565
- function X0(e, t, n) {
2565
+ function q0(e, t, n) {
2566
2566
  return t > 1 ? e + (t - 1) * n : e;
2567
2567
  }
2568
- function q0(e, t, n, i, x) {
2569
- const s = Be(), { cache: l, emojiCorrection: f } = I0(t, k0(e.normalized)), o = de("-", ue("-", l), f) + (x === 0 ? 0 : x * 2), c = de(" ", ue(" ", l), f) * 8, a = x !== 0;
2568
+ function V0(e, t, n, i, r) {
2569
+ const s = Be(), { cache: l, emojiCorrection: u } = y0(t, D0(e.normalized)), o = Fe("-", ue("-", l), u) + (r === 0 ? 0 : r * 2), c = Fe(" ", ue(" ", l), u) * 8, a = r !== 0;
2570
2570
  if (e.len === 0)
2571
- return Q0();
2572
- const u = [], d = [], S = [], p = [];
2573
- let A = e.chunks.length <= 1 && !a;
2571
+ return $0();
2572
+ const f = [], d = [], S = [], A = [];
2573
+ let m = e.chunks.length <= 1 && !a;
2574
2574
  const M = n ? [] : null, v = [], L = [], w = n ? [] : null, R = Array.from({ length: e.len });
2575
- function N(P, W, H, z, C, m, y, k) {
2576
- C !== "text" && C !== "space" && C !== "zero-width-break" && (A = !1), u.push(W), d.push(H), S.push(z), p.push(C), M?.push(m), v.push(y), a && L.push(k), w !== null && w.push(P);
2575
+ function N(P, W, H, z, C, p, y, k) {
2576
+ C !== "text" && C !== "space" && C !== "zero-width-break" && (m = !1), f.push(W), d.push(H), S.push(z), A.push(C), M?.push(p), v.push(y), a && L.push(k), w !== null && w.push(P);
2577
2577
  }
2578
2578
  function D(P, W, H, z, C) {
2579
- const m = ue(P, l), y = a ? bt(P, W) : 0, k = X0(de(P, m, f), y, x), b = W === "space" || W === "preserved-space" || W === "zero-width-break" ? 0 : k, U = b === 0 ? 0 : b + (y > 0 ? x : 0), J = W === "space" || W === "zero-width-break" ? 0 : k;
2579
+ const p = ue(P, l), y = a ? It(P, W) : 0, k = q0(Fe(P, p, u), y, r), O = W === "space" || W === "preserved-space" || W === "zero-width-break" ? 0 : k, U = O === 0 ? 0 : O + (y > 0 ? r : 0), J = W === "space" || W === "zero-width-break" ? 0 : k;
2580
2580
  if (C && z && P.length > 1) {
2581
- let $ = "sum-graphemes";
2582
- x !== 0 ? $ = "segment-prefixes" : ye(P) ? $ = "pair-context" : s.preferPrefixWidthsForBreakableRuns && ($ = "segment-prefixes");
2583
- const te = b0(P, m, l, f, $);
2581
+ let Y = "sum-graphemes";
2582
+ r !== 0 ? Y = "segment-prefixes" : we(P) ? Y = "pair-context" : s.preferPrefixWidthsForBreakableRuns && (Y = "segment-prefixes");
2583
+ const te = I0(P, p, l, u, Y);
2584
2584
  N(P, k, U, J, W, H, te, y);
2585
2585
  return;
2586
2586
  }
2587
2587
  N(P, k, U, J, W, H, null, y);
2588
2588
  }
2589
2589
  for (let P = 0; P < e.len; P++) {
2590
- R[P] = u.length;
2590
+ R[P] = f.length;
2591
2591
  const W = e.texts[P], H = e.isWordLike[P], z = e.kinds[P], C = e.starts[P];
2592
2592
  if (z === "soft-hyphen") {
2593
2593
  N(W, 0, o, o, z, C, null, 0);
@@ -2598,119 +2598,119 @@ function q0(e, t, n, i, x) {
2598
2598
  continue;
2599
2599
  }
2600
2600
  if (z === "tab") {
2601
- N(W, 0, 0, 0, z, C, null, a ? bt(W, z) : 0);
2601
+ N(W, 0, 0, 0, z, C, null, a ? It(W, z) : 0);
2602
2602
  continue;
2603
2603
  }
2604
- const m = ue(W, l);
2605
- if (z === "text" && m.containsCJK) {
2606
- const y = $0(W, s), k = i === "keep-all" ? Y0(W, y, s.breakKeepAllAfterPunctuation) : y;
2607
- for (let b = 0; b < k.length; b++) {
2608
- const U = k[b];
2604
+ const p = ue(W, l);
2605
+ if (z === "text" && p.containsCJK) {
2606
+ const y = Y0(W, s), k = i === "keep-all" ? X0(W, y, s.breakKeepAllAfterPunctuation) : y;
2607
+ for (let O = 0; O < k.length; O++) {
2608
+ const U = k[O];
2609
2609
  D(U.text, "text", C + U.start, H, i === "keep-all" || !oe(U.text));
2610
2610
  }
2611
2611
  continue;
2612
2612
  }
2613
2613
  D(W, z, C, H, !0);
2614
2614
  }
2615
- const E = V0(e.chunks, R, u.length), T = M === null ? null : Bn(e.normalized, M);
2615
+ const E = Z0(e.chunks, R, f.length), T = M === null ? null : Mn(e.normalized, M);
2616
2616
  return w !== null ? {
2617
- widths: u,
2617
+ widths: f,
2618
2618
  lineEndFitAdvances: d,
2619
2619
  lineEndPaintAdvances: S,
2620
- kinds: p,
2621
- simpleLineWalkFastPath: A,
2620
+ kinds: A,
2621
+ simpleLineWalkFastPath: m,
2622
2622
  segLevels: T,
2623
2623
  breakableFitAdvances: v,
2624
- letterSpacing: x,
2624
+ letterSpacing: r,
2625
2625
  spacingGraphemeCounts: L,
2626
2626
  discretionaryHyphenWidth: o,
2627
2627
  tabStopAdvance: c,
2628
2628
  chunks: E,
2629
2629
  segments: w
2630
2630
  } : {
2631
- widths: u,
2631
+ widths: f,
2632
2632
  lineEndFitAdvances: d,
2633
2633
  lineEndPaintAdvances: S,
2634
- kinds: p,
2635
- simpleLineWalkFastPath: A,
2634
+ kinds: A,
2635
+ simpleLineWalkFastPath: m,
2636
2636
  segLevels: T,
2637
2637
  breakableFitAdvances: v,
2638
- letterSpacing: x,
2638
+ letterSpacing: r,
2639
2639
  spacingGraphemeCounts: L,
2640
2640
  discretionaryHyphenWidth: o,
2641
2641
  tabStopAdvance: c,
2642
2642
  chunks: E
2643
2643
  };
2644
2644
  }
2645
- function V0(e, t, n) {
2645
+ function Z0(e, t, n) {
2646
2646
  const i = [];
2647
- for (let x = 0; x < e.length; x++) {
2648
- const s = e[x], l = s.startSegmentIndex < t.length ? t[s.startSegmentIndex] : n, f = s.endSegmentIndex < t.length ? t[s.endSegmentIndex] : n, o = s.consumedEndSegmentIndex < t.length ? t[s.consumedEndSegmentIndex] : n;
2647
+ for (let r = 0; r < e.length; r++) {
2648
+ const s = e[r], l = s.startSegmentIndex < t.length ? t[s.startSegmentIndex] : n, u = s.endSegmentIndex < t.length ? t[s.endSegmentIndex] : n, o = s.consumedEndSegmentIndex < t.length ? t[s.consumedEndSegmentIndex] : n;
2649
2649
  i.push({
2650
2650
  startSegmentIndex: l,
2651
- endSegmentIndex: f,
2651
+ endSegmentIndex: u,
2652
2652
  consumedEndSegmentIndex: o
2653
2653
  });
2654
2654
  }
2655
2655
  return i;
2656
2656
  }
2657
- function Z0(e, t, n, i) {
2658
- const x = i?.wordBreak ?? "normal", s = i?.letterSpacing ?? 0, l = p0(e, Be(), i?.whiteSpace, x);
2659
- return q0(l, t, n, x, s);
2657
+ function es(e, t, n, i) {
2658
+ const r = i?.wordBreak ?? "normal", s = i?.letterSpacing ?? 0, l = m0(e, Be(), i?.whiteSpace, r);
2659
+ return V0(l, t, n, r, s);
2660
2660
  }
2661
- function qe(e, t, n) {
2662
- return Z0(e, t, !0, n);
2661
+ function Ve(e, t, n) {
2662
+ return es(e, t, !0, n);
2663
2663
  }
2664
- function It(e) {
2664
+ function yt(e) {
2665
2665
  let t = 0;
2666
- return G0(e, Number.POSITIVE_INFINITY, (n) => {
2666
+ return H0(e, Number.POSITIVE_INFINITY, (n) => {
2667
2667
  n > t && (t = n);
2668
2668
  }), t;
2669
2669
  }
2670
- const es = /[ \t\n\f\r]+/, yt = /^[ \t\n\f\r]+/, wt = /[ \t\n\f\r]+$/, Pt = { segmentIndex: 0, graphemeIndex: 0 }, ts = {
2670
+ const ts = /[ \t\n\f\r]+/, wt = /^[ \t\n\f\r]+/, Pt = /[ \t\n\f\r]+$/, Wt = { segmentIndex: 0, graphemeIndex: 0 }, ns = {
2671
2671
  itemIndex: 0,
2672
2672
  segmentIndex: 0,
2673
2673
  graphemeIndex: 0
2674
2674
  };
2675
- function Je(e) {
2675
+ function Qe(e) {
2676
2676
  return {
2677
2677
  segmentIndex: e.segmentIndex,
2678
2678
  graphemeIndex: e.graphemeIndex
2679
2679
  };
2680
2680
  }
2681
- function Wt(e) {
2681
+ function vt(e) {
2682
2682
  return e.segmentIndex === 0 && e.graphemeIndex === 0;
2683
2683
  }
2684
- function Oe(e, t, n) {
2685
- const i = `${e}\0${t}`, x = n.get(i);
2686
- if (x !== void 0)
2687
- return x;
2688
- const s = t === 0 ? void 0 : { letterSpacing: t }, l = It(qe("A A", e, s)), f = It(qe("AA", e, s)), o = Math.max(0, l - f);
2684
+ function be(e, t, n) {
2685
+ const i = `${e}\0${t}`, r = n.get(i);
2686
+ if (r !== void 0)
2687
+ return r;
2688
+ const s = t === 0 ? void 0 : { letterSpacing: t }, l = yt(Ve("A A", e, s)), u = yt(Ve("AA", e, s)), o = Math.max(0, l - u);
2689
2689
  return n.set(i, o), o;
2690
2690
  }
2691
- function ns(e) {
2692
- const t = { segmentIndex: 0, graphemeIndex: 0 }, n = Xe(e, t, Number.POSITIVE_INFINITY);
2691
+ function ss(e) {
2692
+ const t = { segmentIndex: 0, graphemeIndex: 0 }, n = qe(e, t, Number.POSITIVE_INFINITY);
2693
2693
  return n === null ? null : {
2694
2694
  endGraphemeIndex: t.graphemeIndex,
2695
2695
  endSegmentIndex: t.segmentIndex,
2696
2696
  width: n
2697
2697
  };
2698
2698
  }
2699
- function ss(e, t) {
2699
+ function is(e, t) {
2700
2700
  return e === 0 && t > 0;
2701
2701
  }
2702
- function Zt(e) {
2702
+ function en(e) {
2703
2703
  const t = [], n = Array.from({ length: e.length }), i = /* @__PURE__ */ new Map();
2704
- let x = 0;
2704
+ let r = 0;
2705
2705
  for (let s = 0; s < e.length; s++) {
2706
- const l = e[s], f = l.letterSpacing ?? 0, o = yt.test(l.text), r = wt.test(l.text), c = l.text.replace(yt, "").replace(wt, "");
2706
+ const l = e[s], u = l.letterSpacing ?? 0, o = wt.test(l.text), x = Pt.test(l.text), c = l.text.replace(wt, "").replace(Pt, "");
2707
2707
  if (c.length === 0) {
2708
- es.test(l.text) && x === 0 && (x = Oe(l.font, f, i));
2708
+ ts.test(l.text) && r === 0 && (r = be(l.font, u, i));
2709
2709
  continue;
2710
2710
  }
2711
- const a = x > 0 ? x : o ? Oe(l.font, f, i) : 0, u = qe(c, l.font, f === 0 ? void 0 : { letterSpacing: f }), d = ns(u);
2711
+ const a = r > 0 ? r : o ? be(l.font, u, i) : 0, f = Ve(c, l.font, u === 0 ? void 0 : { letterSpacing: u }), d = ss(f);
2712
2712
  if (d === null) {
2713
- x = r ? Oe(l.font, f, i) : 0;
2713
+ r = x ? be(l.font, u, i) : 0;
2714
2714
  continue;
2715
2715
  }
2716
2716
  const S = {
@@ -2720,97 +2720,97 @@ function Zt(e) {
2720
2720
  extraWidth: l.extraWidth ?? 0,
2721
2721
  gapBefore: a,
2722
2722
  naturalWidth: d.width,
2723
- prepared: u,
2723
+ prepared: f,
2724
2724
  sourceItemIndex: s
2725
2725
  };
2726
- t.push(S), n[s] = S, x = r ? Oe(l.font, f, i) : 0;
2726
+ t.push(S), n[s] = S, r = x ? be(l.font, u, i) : 0;
2727
2727
  }
2728
2728
  return {
2729
2729
  items: t,
2730
2730
  itemsBySourceItemIndex: n
2731
2731
  };
2732
2732
  }
2733
- function is(e, t, n, i) {
2733
+ function rs(e, t, n, i) {
2734
2734
  if (e.items.length === 0 || n.itemIndex >= e.items.length)
2735
2735
  return null;
2736
- const x = Math.max(1, t);
2737
- let s = 0, l = x, f = n.itemIndex;
2738
- e: for (; f < e.items.length; ) {
2739
- const o = e.items[f];
2740
- if (!Wt(n) && n.segmentIndex === o.endSegmentIndex && n.graphemeIndex === o.endGraphemeIndex) {
2741
- f++, n.segmentIndex = 0, n.graphemeIndex = 0;
2736
+ const r = Math.max(1, t);
2737
+ let s = 0, l = r, u = n.itemIndex;
2738
+ e: for (; u < e.items.length; ) {
2739
+ const o = e.items[u];
2740
+ if (!vt(n) && n.segmentIndex === o.endSegmentIndex && n.graphemeIndex === o.endGraphemeIndex) {
2741
+ u++, n.segmentIndex = 0, n.graphemeIndex = 0;
2742
2742
  continue;
2743
2743
  }
2744
- const r = s === 0 ? 0 : o.gapBefore, c = Wt(n);
2744
+ const x = s === 0 ? 0 : o.gapBefore, c = vt(n);
2745
2745
  if (o.break === "never") {
2746
2746
  if (!c) {
2747
- f++, n.segmentIndex = 0, n.graphemeIndex = 0;
2747
+ u++, n.segmentIndex = 0, n.graphemeIndex = 0;
2748
2748
  continue;
2749
2749
  }
2750
- const M = o.naturalWidth + o.extraWidth, v = r + M;
2750
+ const M = o.naturalWidth + o.extraWidth, v = x + M;
2751
2751
  if (s > 0 && v > l)
2752
2752
  break e;
2753
- i?.(o, r, M, Je(Pt), {
2753
+ i?.(o, x, M, Qe(Wt), {
2754
2754
  segmentIndex: o.endSegmentIndex,
2755
2755
  graphemeIndex: o.endGraphemeIndex
2756
- }), s += v, l = Math.max(0, x - s), f++, n.segmentIndex = 0, n.graphemeIndex = 0;
2756
+ }), s += v, l = Math.max(0, r - s), u++, n.segmentIndex = 0, n.graphemeIndex = 0;
2757
2757
  continue;
2758
2758
  }
2759
- const a = r + o.extraWidth;
2759
+ const a = x + o.extraWidth;
2760
2760
  if (s > 0 && a >= l)
2761
2761
  break e;
2762
2762
  if (c) {
2763
2763
  const M = a + o.naturalWidth;
2764
2764
  if (M <= l) {
2765
- i?.(o, r, o.naturalWidth + o.extraWidth, Je(Pt), {
2765
+ i?.(o, x, o.naturalWidth + o.extraWidth, Qe(Wt), {
2766
2766
  segmentIndex: o.endSegmentIndex,
2767
2767
  graphemeIndex: o.endGraphemeIndex
2768
- }), s += M, l = Math.max(0, x - s), f++, n.segmentIndex = 0, n.graphemeIndex = 0;
2768
+ }), s += M, l = Math.max(0, r - s), u++, n.segmentIndex = 0, n.graphemeIndex = 0;
2769
2769
  continue;
2770
2770
  }
2771
2771
  }
2772
- const u = Math.max(1, l - a), d = {
2772
+ const f = Math.max(1, l - a), d = {
2773
2773
  segmentIndex: n.segmentIndex,
2774
2774
  graphemeIndex: n.graphemeIndex
2775
- }, S = Xe(o.prepared, d, u);
2775
+ }, S = qe(o.prepared, d, f);
2776
2776
  if (S === null) {
2777
- f++, n.segmentIndex = 0, n.graphemeIndex = 0;
2777
+ u++, n.segmentIndex = 0, n.graphemeIndex = 0;
2778
2778
  continue;
2779
2779
  }
2780
2780
  if (n.segmentIndex === d.segmentIndex && n.graphemeIndex === d.graphemeIndex) {
2781
- f++, n.segmentIndex = 0, n.graphemeIndex = 0;
2781
+ u++, n.segmentIndex = 0, n.graphemeIndex = 0;
2782
2782
  continue;
2783
2783
  }
2784
- const p = S + o.extraWidth, A = r + p;
2785
- if (s > 0 && c && A > l)
2784
+ const A = S + o.extraWidth, m = x + A;
2785
+ if (s > 0 && c && m > l)
2786
2786
  break e;
2787
- if (s > 0 && c && r > 0 && ss(d.segmentIndex, d.graphemeIndex)) {
2787
+ if (s > 0 && c && x > 0 && is(d.segmentIndex, d.graphemeIndex)) {
2788
2788
  const M = { segmentIndex: 0, graphemeIndex: 0 };
2789
- if (Xe(o.prepared, M, Math.max(1, x - o.extraWidth)) !== null && (M.segmentIndex > d.segmentIndex || M.segmentIndex === d.segmentIndex && M.graphemeIndex > d.graphemeIndex))
2789
+ if (qe(o.prepared, M, Math.max(1, r - o.extraWidth)) !== null && (M.segmentIndex > d.segmentIndex || M.segmentIndex === d.segmentIndex && M.graphemeIndex > d.graphemeIndex))
2790
2790
  break e;
2791
2791
  }
2792
- if (i?.(o, r, p, Je(n), {
2792
+ if (i?.(o, x, A, Qe(n), {
2793
2793
  segmentIndex: d.segmentIndex,
2794
2794
  graphemeIndex: d.graphemeIndex
2795
- }), s += A, l = Math.max(0, x - s), d.segmentIndex === o.endSegmentIndex && d.graphemeIndex === o.endGraphemeIndex) {
2796
- f++, n.segmentIndex = 0, n.graphemeIndex = 0;
2795
+ }), s += m, l = Math.max(0, r - s), d.segmentIndex === o.endSegmentIndex && d.graphemeIndex === o.endGraphemeIndex) {
2796
+ u++, n.segmentIndex = 0, n.graphemeIndex = 0;
2797
2797
  continue;
2798
2798
  }
2799
2799
  n.segmentIndex = d.segmentIndex, n.graphemeIndex = d.graphemeIndex;
2800
2800
  break;
2801
2801
  }
2802
- return s === 0 ? null : (n.itemIndex = f, s);
2802
+ return s === 0 ? null : (n.itemIndex = u, s);
2803
2803
  }
2804
- function xs(e, t, n = ts) {
2805
- const i = e, x = {
2804
+ function xs(e, t, n = ns) {
2805
+ const i = e, r = {
2806
2806
  itemIndex: n.itemIndex,
2807
2807
  segmentIndex: n.segmentIndex,
2808
2808
  graphemeIndex: n.graphemeIndex
2809
- }, s = [], l = is(i, t, x, (f, o, r, c, a) => {
2809
+ }, s = [], l = rs(i, t, r, (u, o, x, c, a) => {
2810
2810
  s.push({
2811
- itemIndex: f.sourceItemIndex,
2811
+ itemIndex: u.sourceItemIndex,
2812
2812
  gapBefore: o,
2813
- occupiedWidth: r,
2813
+ occupiedWidth: x,
2814
2814
  start: c,
2815
2815
  end: a
2816
2816
  });
@@ -2818,21 +2818,21 @@ function xs(e, t, n = ts) {
2818
2818
  return l === null ? null : {
2819
2819
  fragments: s,
2820
2820
  width: l,
2821
- end: x
2821
+ end: r
2822
2822
  };
2823
2823
  }
2824
- function rs(e, t) {
2825
- return J0(e.prepared, U0(e.prepared), t.start.segmentIndex, t.start.graphemeIndex, t.end.segmentIndex, t.end.graphemeIndex);
2826
- }
2827
2824
  function os(e, t) {
2825
+ return Q0(e.prepared, J0(e.prepared), t.start.segmentIndex, t.start.graphemeIndex, t.end.segmentIndex, t.end.graphemeIndex);
2826
+ }
2827
+ function ls(e, t) {
2828
2828
  const n = e, i = [];
2829
- for (let x = 0; x < t.fragments.length; x++) {
2830
- const s = t.fragments[x], l = n.itemsBySourceItemIndex[s.itemIndex];
2829
+ for (let r = 0; r < t.fragments.length; r++) {
2830
+ const s = t.fragments[r], l = n.itemsBySourceItemIndex[s.itemIndex];
2831
2831
  if (l === void 0)
2832
2832
  throw new Error("Missing rich-text inline item for fragment");
2833
2833
  i.push({
2834
2834
  itemIndex: s.itemIndex,
2835
- text: rs(l, s),
2835
+ text: os(l, s),
2836
2836
  gapBefore: s.gapBefore,
2837
2837
  occupiedWidth: s.occupiedWidth,
2838
2838
  start: s.start,
@@ -2845,7 +2845,7 @@ function os(e, t) {
2845
2845
  end: t.end
2846
2846
  };
2847
2847
  }
2848
- const ls = (e) => e.runs.some((t) => t.text.length > 0) && e.runs.every((t) => t.text.length === 0 || t.style.hidden === !0), cs = [
2848
+ const cs = (e) => e.runs.some((t) => t.text.length > 0) && e.runs.every((t) => t.text.length === 0 || t.style.hidden === !0), as = [
2849
2849
  [1e3, "m"],
2850
2850
  [900, "cm"],
2851
2851
  [500, "d"],
@@ -2860,96 +2860,96 @@ const ls = (e) => e.runs.some((t) => t.text.length > 0) && e.runs.every((t) => t
2860
2860
  [4, "iv"],
2861
2861
  [1, "i"]
2862
2862
  ];
2863
- function vt(e) {
2863
+ function Rt(e) {
2864
2864
  let t = "", n = Math.max(1, e);
2865
- for (const [i, x] of cs)
2865
+ for (const [i, r] of as)
2866
2866
  for (; n >= i; )
2867
- t += x, n -= i;
2867
+ t += r, n -= i;
2868
2868
  return t;
2869
2869
  }
2870
- function Rt(e) {
2870
+ function Tt(e) {
2871
2871
  let t = "", n = Math.max(1, e);
2872
2872
  for (; n > 0; )
2873
2873
  n -= 1, t = String.fromCharCode(97 + n % 26) + t, n = Math.floor(n / 26);
2874
2874
  return t;
2875
2875
  }
2876
- function Ce(e, t) {
2876
+ function ke(e, t) {
2877
2877
  switch (t) {
2878
2878
  case "decimal":
2879
2879
  return String(e);
2880
2880
  case "lowerLetter":
2881
- return Rt(e);
2881
+ return Tt(e);
2882
2882
  case "upperLetter":
2883
- return Rt(e).toUpperCase();
2883
+ return Tt(e).toUpperCase();
2884
2884
  case "lowerRoman":
2885
- return vt(e);
2885
+ return Rt(e);
2886
2886
  case "upperRoman":
2887
- return vt(e).toUpperCase();
2887
+ return Rt(e).toUpperCase();
2888
2888
  case "bullet":
2889
2889
  return "";
2890
2890
  }
2891
2891
  }
2892
- function as(e, t, n) {
2892
+ function us(e, t, n) {
2893
2893
  const i = e.levels[Math.min(t, e.levels.length - 1)];
2894
- return i ? i.format === "bullet" ? i.bulletChar ?? "•" : i.text.replace(/%(\d)/g, (x, s) => {
2895
- const l = Number(s) - 1, f = e.levels[Math.min(l, e.levels.length - 1)], o = n[l] ?? f?.start ?? 1;
2896
- return Ce(o, f?.format ?? "decimal");
2894
+ return i ? i.format === "bullet" ? i.bulletChar ?? "•" : i.text.replace(/%(\d)/g, (r, s) => {
2895
+ const l = Number(s) - 1, u = e.levels[Math.min(l, e.levels.length - 1)], o = n[l] ?? u?.start ?? 1;
2896
+ return ke(o, u?.format ?? "decimal");
2897
2897
  }) : "";
2898
2898
  }
2899
- function us(e) {
2899
+ function fs(e) {
2900
2900
  let t = 1;
2901
2901
  const n = [];
2902
2902
  for (const i of e.rows) {
2903
- let x = 0;
2903
+ let r = 0;
2904
2904
  for (const s of i.cells) {
2905
- for (; (n[x] ?? 0) > 0; ) x++;
2906
- const l = Math.max(1, s.colSpan ?? 1), f = Math.max(1, s.rowSpan ?? 1);
2907
- if (f > 1) for (let o = 0; o < l; o++) n[x + o] = f;
2908
- x += l;
2905
+ for (; (n[r] ?? 0) > 0; ) r++;
2906
+ const l = Math.max(1, s.colSpan ?? 1), u = Math.max(1, s.rowSpan ?? 1);
2907
+ if (u > 1) for (let o = 0; o < l; o++) n[r + o] = u;
2908
+ r += l;
2909
2909
  }
2910
- t = Math.max(t, x);
2910
+ t = Math.max(t, r);
2911
2911
  for (let s = 0; s < n.length; s++) n[s] > 0 && n[s]--;
2912
2912
  }
2913
2913
  return t;
2914
2914
  }
2915
- function fs(e) {
2916
- const t = us(e);
2915
+ function hs(e) {
2916
+ const t = fs(e);
2917
2917
  return e.colFractions && e.colFractions.length === t ? e.colFractions : Array.from({ length: t }, () => 1 / t);
2918
2918
  }
2919
- function hs(e) {
2919
+ function ds(e) {
2920
2920
  const t = [];
2921
- let n = [], i = 0, x = 0;
2921
+ let n = [], i = 0, r = 0;
2922
2922
  for (const s of e) {
2923
2923
  let l = 0;
2924
2924
  for (; ; ) {
2925
2925
  const o = s.text.indexOf("\v", l);
2926
2926
  if (o < 0) break;
2927
- const r = s.text.slice(l, o);
2928
- r.length > 0 && n.push({ text: r, style: s.style }), x += o - l, t.push({ runs: n, startOffset: i }), x += 1, i = x, n = [], l = o + 1;
2927
+ const x = s.text.slice(l, o);
2928
+ x.length > 0 && n.push({ text: x, style: s.style }), r += o - l, t.push({ runs: n, startOffset: i }), r += 1, i = r, n = [], l = o + 1;
2929
2929
  }
2930
- const f = s.text.slice(l);
2931
- f.length > 0 && n.push({ text: f, style: s.style }), x += f.length;
2930
+ const u = s.text.slice(l);
2931
+ u.length > 0 && n.push({ text: u, style: s.style }), r += u.length;
2932
2932
  }
2933
2933
  return t.push({ runs: n, startOffset: i }), t;
2934
2934
  }
2935
- function en(e) {
2935
+ function tn(e) {
2936
2936
  return e.map((t) => {
2937
2937
  const n = { text: t.style.hidden ? "" : t.text, font: fe(t.style) };
2938
2938
  return !t.style.hidden && t.style.letterSpacingPx !== void 0 && (n.letterSpacing = t.style.letterSpacingPx), n;
2939
2939
  });
2940
2940
  }
2941
- function ds(e) {
2942
- return Zt(en(e));
2941
+ function Fs(e) {
2942
+ return en(tn(e));
2943
2943
  }
2944
- class Ve {
2944
+ class Ze {
2945
2945
  map = /* @__PURE__ */ new Map();
2946
2946
  get(t) {
2947
2947
  const n = this.map.get(t.id);
2948
2948
  if (n && n.revision === t.revision) return n.segments;
2949
- const i = hs(t.runs).map((x) => ({
2950
- prepared: Zt(en(x.runs)),
2951
- runs: x.runs,
2952
- startOffset: x.startOffset
2949
+ const i = ds(t.runs).map((r) => ({
2950
+ prepared: en(tn(r.runs)),
2951
+ runs: r.runs,
2952
+ startOffset: r.startOffset
2953
2953
  }));
2954
2954
  return this.map.set(t.id, { revision: t.revision, segments: i }), i;
2955
2955
  }
@@ -2957,191 +2957,200 @@ class Ve {
2957
2957
  this.map.delete(t);
2958
2958
  }
2959
2959
  }
2960
- const Qe = 48;
2961
- function Is() {
2962
- const e = new Ve(), t = /* @__PURE__ */ new Map(), n = (i, x) => {
2960
+ const $e = 48;
2961
+ function ys() {
2962
+ const e = new Ze(), t = /* @__PURE__ */ new Map(), n = (i, r) => {
2963
2963
  const s = t.get(i.id);
2964
- if (s && s.revision === i.revision && s.width === x) return s.lines;
2965
- const l = sn(i, x, e);
2966
- return t.set(i.id, { revision: i.revision, width: x, lines: l }), l;
2964
+ if (s && s.revision === i.revision && s.width === r) return s.lines;
2965
+ const l = xn(i, r, e);
2966
+ return t.set(i.id, { revision: i.revision, width: r, lines: l }), l;
2967
2967
  };
2968
2968
  return {
2969
- layout(i, x, s) {
2970
- return Cs(i, n, (l) => e.get(l), s?.rawBand ?? null);
2969
+ layout(i, r, s) {
2970
+ return ks(i, n, (l) => e.get(l), s?.rawBand ?? null);
2971
2971
  },
2972
2972
  evict(i) {
2973
2973
  e.evict(i), t.delete(i);
2974
2974
  }
2975
2975
  };
2976
2976
  }
2977
- function Fs(e) {
2977
+ function gs(e) {
2978
2978
  let t = 0;
2979
2979
  for (let n = 0; n < e.length; n++) e.charCodeAt(n) === 32 && t++;
2980
2980
  return t;
2981
2981
  }
2982
- const gs = (e) => e === " " || e === " " || e === `
2982
+ const Ns = (e) => e === " " || e === " " || e === `
2983
2983
  ` || e === "\r";
2984
- function Ns(e, t, n) {
2984
+ function Ss(e, t, n) {
2985
2985
  const i = e.indexOf(n, t);
2986
2986
  if (i >= 0) return { start: i, end: i + n.length };
2987
- const x = [];
2988
- let s = t, l = 0, f = -1;
2987
+ const r = [];
2988
+ let s = t, l = 0, u = -1;
2989
2989
  for (; l < n.length && s < e.length; ) {
2990
2990
  if (e[s] === n[l]) {
2991
- f < 0 && (f = s), x.push(s - f), s++, l++;
2991
+ u < 0 && (u = s), r.push(s - u), s++, l++;
2992
2992
  continue;
2993
2993
  }
2994
- if (gs(e[s])) {
2994
+ if (Ns(e[s])) {
2995
2995
  s++;
2996
2996
  continue;
2997
2997
  }
2998
- f = -1;
2998
+ u = -1;
2999
2999
  break;
3000
3000
  }
3001
- return f >= 0 && l === n.length ? (x.push(s - f), s - f === n.length ? { start: f, end: s } : { start: f, end: s, map: x }) : { start: t, end: t + n.length };
3001
+ return u >= 0 && l === n.length ? (r.push(s - u), s - u === n.length ? { start: u, end: s } : { start: u, end: s, map: r }) : { start: t, end: t + n.length };
3002
3002
  }
3003
- function lt(e, t) {
3003
+ function ct(e, t) {
3004
3004
  const n = [];
3005
3005
  let i = t;
3006
- for (const x of e)
3007
- n.push(i), i += x.text.length;
3006
+ for (const r of e)
3007
+ n.push(i), i += r.text.length;
3008
3008
  return n;
3009
3009
  }
3010
- function Ss(e) {
3011
- return ls(e) && !e.style.sectionBreak && !e.style.pageBreakBefore;
3010
+ function ps(e) {
3011
+ return cs(e) && !e.style.sectionBreak && !e.style.pageBreakBefore;
3012
3012
  }
3013
- function tn(e) {
3014
- const t = e.runs[0]?.style, n = t?.fontSizePx ?? 16, i = t ? Ie(fe(t)) : { ascent: n * 0.8, descent: n * 0.2 }, x = i.ascent + i.descent, s = Math.max(x, e.style.lineHeight * n);
3015
- return { height: s, ascent: (s - x) / 2 + i.ascent };
3013
+ function nn(e) {
3014
+ const t = e.runs[0]?.style, n = t?.fontSizePx ?? 16, i = t ? ye(fe(t)) : { ascent: n * 0.8, descent: n * 0.2 }, r = i.ascent + i.descent, s = Math.max(r, e.style.lineHeight * n);
3015
+ return { height: s, ascent: (s - r) / 2 + i.ascent };
3016
3016
  }
3017
- function ct(e, t, n, i, x, s) {
3017
+ function at(e, t, n, i, r, s) {
3018
3018
  const l = xs(t.prepared, n, i);
3019
3019
  if (l === null) return null;
3020
- const f = os(t.prepared, l), o = [];
3021
- let r = 0, c = 0, a = 0, u = 0;
3022
- for (const A of f.fragments) {
3023
- r += A.gapBefore;
3024
- const M = t.runs[A.itemIndex], v = Ie(fe(M.style));
3025
- if (c = Math.max(c, v.ascent), a = Math.max(a, v.descent), u = Math.max(u, M.style.fontSizePx), A.text.length > 0) {
3026
- const L = Ns(M.text, s[A.itemIndex], A.text);
3027
- s[A.itemIndex] = L.end;
3020
+ const u = ls(t.prepared, l), o = [];
3021
+ let x = 0, c = 0, a = 0, f = 0;
3022
+ for (const m of u.fragments) {
3023
+ x += m.gapBefore;
3024
+ const M = t.runs[m.itemIndex], v = ye(fe(M.style));
3025
+ if (c = Math.max(c, v.ascent), a = Math.max(a, v.descent), f = Math.max(f, M.style.fontSizePx), m.text.length > 0) {
3026
+ const L = Ss(M.text, s[m.itemIndex], m.text);
3027
+ s[m.itemIndex] = L.end;
3028
3028
  const w = {
3029
3029
  blockId: e.id,
3030
- startOffset: x[A.itemIndex] + L.start,
3031
- endOffset: x[A.itemIndex] + L.end,
3032
- text: A.text,
3030
+ startOffset: r[m.itemIndex] + L.start,
3031
+ endOffset: r[m.itemIndex] + L.end,
3032
+ text: m.text,
3033
3033
  style: M.style,
3034
- x: r,
3035
- width: A.occupiedWidth
3034
+ x,
3035
+ width: m.occupiedWidth
3036
3036
  };
3037
- L.map && (w.offsetMap = L.map), o.push({ frag: w, hadGap: A.gapBefore > 0, spaces: Fs(A.text) });
3037
+ L.map && (w.offsetMap = L.map), o.push({ frag: w, hadGap: m.gapBefore > 0, spaces: gs(m.text) });
3038
3038
  }
3039
- r += A.occupiedWidth;
3039
+ x += m.occupiedWidth;
3040
3040
  }
3041
- if (u === 0) {
3042
- const A = e.runs[0]?.style;
3043
- if (A) {
3044
- const M = Ie(fe(A));
3045
- c = M.ascent, a = M.descent, u = A.fontSizePx;
3041
+ if (f === 0) {
3042
+ const m = e.runs[0]?.style;
3043
+ if (m) {
3044
+ const M = ye(fe(m));
3045
+ c = M.ascent, a = M.descent, f = m.fontSizePx;
3046
3046
  }
3047
3047
  }
3048
- const d = c + a, S = Math.max(d, e.style.lineHeight * u), p = (S - d) / 2;
3049
- return { frags: o, width: f.width, height: S, ascent: p + c, end: f.end };
3048
+ const d = c + a, S = Math.max(d, e.style.lineHeight * f), A = (S - d) / 2;
3049
+ return { frags: o, width: u.width, height: S, ascent: A + c, end: u.end };
3050
3050
  }
3051
- function ps(e, t, n) {
3052
- for (const x of t) if (x.posPx > e + 0.5) return x;
3053
- let i = (Math.floor(e / Qe) + 1) * Qe;
3054
- return i <= e && (i = e + Qe), { posPx: Math.min(i, Math.max(e + 1, n)), align: "left", leader: "none" };
3051
+ function ms(e, t, n) {
3052
+ for (const r of t) if (r.posPx > e + 0.5) return r;
3053
+ let i = (Math.floor(e / $e) + 1) * $e;
3054
+ return i <= e && (i = e + $e), { posPx: Math.min(i, Math.max(e + 1, n)), align: "left", leader: "none" };
3055
3055
  }
3056
- function ms(e) {
3057
- const t = e.map((x) => x.text).join(""), n = fe(e[0]?.style ?? nn);
3056
+ function As(e) {
3057
+ const t = e.map((r) => r.text).join(""), n = fe(e[0]?.style ?? sn);
3058
3058
  let i = t.indexOf(".");
3059
- return i < 0 && (i = t.indexOf(",")), et(i < 0 ? t : t.slice(0, i + 1), n);
3059
+ return i < 0 && (i = t.indexOf(",")), tt(i < 0 ? t : t.slice(0, i + 1), n);
3060
3060
  }
3061
- const nn = { fontFamily: "Georgia, serif", fontSizePx: 16 };
3062
- function As(e, t, n, i, x) {
3061
+ const sn = { fontFamily: "Georgia, serif", fontSizePx: 16 };
3062
+ function Es(e, t, n, i, r) {
3063
3063
  const s = [];
3064
- let l = [], f = n, o = n;
3064
+ let l = [], u = n, o = n;
3065
3065
  for (const L of t) {
3066
3066
  let w = 0;
3067
3067
  for (; ; ) {
3068
3068
  const N = L.text.indexOf(" ", w);
3069
3069
  if (N < 0) break;
3070
3070
  const D = L.text.slice(w, N);
3071
- D.length > 0 && l.push({ text: D, style: L.style }), o += N - w, s.push({ runs: l, start: f }), o += 1, f = o, l = [], w = N + 1;
3071
+ D.length > 0 && l.push({ text: D, style: L.style }), o += N - w, s.push({ runs: l, start: u }), o += 1, u = o, l = [], w = N + 1;
3072
3072
  }
3073
3073
  const R = L.text.slice(w);
3074
3074
  R.length > 0 && l.push({ text: R, style: L.style }), o += R.length;
3075
3075
  }
3076
- s.push({ runs: l, start: f });
3077
- const r = (e.style.tabStops ?? []).slice().sort((L, w) => L.posPx - w.posPx), c = t.find((L) => L.text.length > 0)?.style ?? e.runs[0]?.style, a = [];
3078
- let u = [], d = [], S = x, p = 0, A = 0, M = !1;
3076
+ s.push({ runs: l, start: u });
3077
+ const x = (e.style.tabStops ?? []).slice().sort((L, w) => L.posPx - w.posPx), c = t.find((L) => L.text.length > 0)?.style ?? e.runs[0]?.style, a = [];
3078
+ let f = [], d = [], S = r, A = 0, m = 0, M = !1;
3079
3079
  const v = (L) => {
3080
- if (p === 0 && c) {
3081
- const w = Ie(fe(c));
3082
- p = Math.max(w.ascent + w.descent, e.style.lineHeight * c.fontSizePx), A = (p - (w.ascent + w.descent)) / 2 + w.ascent;
3080
+ if (A === 0 && c) {
3081
+ const w = ye(fe(c));
3082
+ A = Math.max(w.ascent + w.descent, e.style.lineHeight * c.fontSizePx), m = (A - (w.ascent + w.descent)) / 2 + w.ascent;
3083
3083
  }
3084
3084
  a.push({
3085
- frags: u,
3085
+ frags: f,
3086
3086
  width: S,
3087
3087
  indent: 0,
3088
3088
  // fragment x is already absolute (tab/indent baked in)
3089
3089
  lineMaxWidth: i,
3090
- height: p,
3091
- ascent: A,
3090
+ height: A,
3091
+ ascent: m,
3092
3092
  // A tab-positioned line stays ragged (its manual x must not be re-justified);
3093
3093
  // pure wrapped continuation lines justify normally when the paragraph does.
3094
3094
  lastOfSegment: L || M,
3095
3095
  ...d.length > 0 ? { leaders: d } : {}
3096
- }), u = [], d = [], S = 0, p = 0, A = 0, M = !1;
3096
+ }), f = [], d = [], S = 0, A = 0, m = 0, M = !1;
3097
3097
  };
3098
3098
  return s.forEach((L, w) => {
3099
3099
  if (w > 0) {
3100
- const P = ps(S, r, i), W = P.align ?? "left", H = et(L.runs.map((m) => m.text).join(""), fe(L.runs[0]?.style ?? c ?? nn)), z = S + H <= i;
3100
+ const P = ms(S, x, i), W = P.align ?? "left", H = tt(L.runs.map((p) => p.text).join(""), fe(L.runs[0]?.style ?? c ?? sn)), z = S + H <= i;
3101
3101
  let C = P.posPx;
3102
- z && W === "right" ? C = P.posPx - H : z && W === "center" ? C = P.posPx - H / 2 : z && W === "decimal" && (C = P.posPx - ms(L.runs)), C < S && (C = S), (P.leader ?? "none") !== "none" && C > S + 1 && c && d.push({ x1: S, x2: C, kind: P.leader ?? "none", color: c.color, fontSizePx: c.fontSizePx }), S = C, M = !0;
3102
+ z && W === "right" ? C = P.posPx - H : z && W === "center" ? C = P.posPx - H / 2 : z && W === "decimal" && (C = P.posPx - As(L.runs)), C < S && (C = S), (P.leader ?? "none") !== "none" && C > S + 1 && c && d.push({ x1: S, x2: C, kind: P.leader ?? "none", color: c.color, fontSizePx: c.fontSizePx }), S = C, M = !0;
3103
3103
  }
3104
3104
  if (L.runs.length === 0) return;
3105
- const R = { prepared: ds(L.runs), runs: L.runs, startOffset: L.start }, N = lt(L.runs, L.start), D = L.runs.map(() => 0);
3105
+ const R = { prepared: Fs(L.runs), runs: L.runs, startOffset: L.start }, N = ct(L.runs, L.start), D = L.runs.map(() => 0);
3106
3106
  let E, T = !0;
3107
3107
  for (; ; ) {
3108
- const P = Math.max(24, i - (T ? S : 0)), W = ct(e, R, P, E, N, D);
3108
+ const P = Math.max(24, i - (T ? S : 0)), W = at(e, R, P, E, N, D);
3109
3109
  if (W === null) break;
3110
3110
  T || v(!1);
3111
3111
  const H = T ? S : 0;
3112
3112
  for (const z of W.frags)
3113
- z.frag.x += H, u.push(z);
3114
- S = H + W.width, p = Math.max(p, W.height), A = Math.max(A, W.ascent), E = W.end, T = !1;
3113
+ z.frag.x += H, f.push(z);
3114
+ S = H + W.width, A = Math.max(A, W.height), m = Math.max(m, W.ascent), E = W.end, T = !1;
3115
3115
  }
3116
3116
  }), v(!0), a;
3117
3117
  }
3118
- function sn(e, t, n) {
3119
- const i = n.get(e), x = [], s = [];
3118
+ function rn(e, t) {
3119
+ if (t <= 0) return;
3120
+ const n = e.reduce((s, l) => s + l.spaces + (l.hadGap ? 1 : 0), 0);
3121
+ if (n <= 0) return;
3122
+ const i = t / n;
3123
+ let r = 0;
3124
+ for (const s of e)
3125
+ s.hadGap && (r += i), s.frag.x += r, s.spaces > 0 && (s.frag.wordSpacingPx = i, s.frag.width += s.spaces * i, r += s.spaces * i);
3126
+ }
3127
+ function xn(e, t, n) {
3128
+ const i = n.get(e), r = [], s = [];
3120
3129
  let l = !0;
3121
3130
  for (const o of i) {
3122
3131
  if (o.runs.some((d) => d.text.includes(" "))) {
3123
- s.push(...As(e, o.runs, o.startOffset, t, l ? e.style.indentFirstLinePx : 0)), l = !1;
3132
+ s.push(...Es(e, o.runs, o.startOffset, t, l ? e.style.indentFirstLinePx : 0)), l = !1;
3124
3133
  continue;
3125
3134
  }
3126
- const r = lt(o.runs, o.startOffset), c = o.runs.map(() => 0);
3127
- let a, u = !1;
3135
+ const x = ct(o.runs, o.startOffset), c = o.runs.map(() => 0);
3136
+ let a, f = !1;
3128
3137
  for (; ; ) {
3129
- const d = l ? e.style.indentFirstLinePx : 0, S = t - d, p = ct(e, o, S, a, r, c);
3130
- if (p === null) break;
3138
+ const d = l ? e.style.indentFirstLinePx : 0, S = t - d, A = at(e, o, S, a, x, c);
3139
+ if (A === null) break;
3131
3140
  s.push({
3132
- frags: p.frags,
3133
- width: p.width,
3141
+ frags: A.frags,
3142
+ width: A.width,
3134
3143
  indent: d,
3135
3144
  lineMaxWidth: S,
3136
- height: p.height,
3137
- ascent: p.ascent,
3145
+ height: A.height,
3146
+ ascent: A.ascent,
3138
3147
  lastOfSegment: !1
3139
- }), a = p.end, l = !1, u = !0;
3148
+ }), a = A.end, l = !1, f = !0;
3140
3149
  }
3141
- if (u)
3150
+ if (f)
3142
3151
  s[s.length - 1].lastOfSegment = !0;
3143
3152
  else {
3144
- const d = tn(e);
3153
+ const d = nn(e);
3145
3154
  s.push({
3146
3155
  frags: [],
3147
3156
  width: 0,
@@ -3154,98 +3163,88 @@ function sn(e, t, n) {
3154
3163
  }), l = !1;
3155
3164
  }
3156
3165
  }
3157
- let f = 0;
3166
+ let u = 0;
3158
3167
  for (const o of s) {
3159
- const r = o.lineMaxWidth - o.width;
3168
+ const x = o.lineMaxWidth - o.width;
3160
3169
  let c = o.indent;
3161
- if (e.style.align === "center") c += r / 2;
3162
- else if (e.style.align === "right") c += r;
3163
- else if (e.style.align === "justify" && !o.lastOfSegment && r > 0) {
3164
- const u = o.frags.reduce((d, S) => d + S.spaces + (S.hadGap ? 1 : 0), 0);
3165
- if (u > 0) {
3166
- const d = r / u;
3167
- let S = 0;
3168
- for (const p of o.frags)
3169
- p.hadGap && (S += d), p.frag.x += S, p.spaces > 0 && (p.frag.wordSpacingPx = d, p.frag.width += p.spaces * d, S += p.spaces * d);
3170
- }
3171
- }
3172
- for (const u of o.frags) u.frag.x += c;
3173
- const a = { y: f, height: o.height, ascent: o.ascent, fragments: o.frags.map((u) => u.frag) };
3174
- o.emptyOffset !== void 0 && (a.emptyOffset = o.emptyOffset), o.leaders && o.leaders.length > 0 && (a.leaders = o.leaders.map((u) => ({ ...u, x1: u.x1 + c, x2: u.x2 + c }))), x.push(a), f += o.height;
3170
+ e.style.align === "center" ? c += x / 2 : e.style.align === "right" ? c += x : e.style.align === "justify" && !o.lastOfSegment && rn(o.frags, x);
3171
+ for (const f of o.frags) f.frag.x += c;
3172
+ const a = { y: u, height: o.height, ascent: o.ascent, fragments: o.frags.map((f) => f.frag) };
3173
+ o.emptyOffset !== void 0 && (a.emptyOffset = o.emptyOffset), o.leaders && o.leaders.length > 0 && (a.leaders = o.leaders.map((f) => ({ ...f, x1: f.x1 + c, x2: f.x2 + c }))), r.push(a), u += o.height;
3175
3174
  }
3176
- return x;
3175
+ return r;
3177
3176
  }
3178
- const Tt = 2, Gt = 2, Es = 48, xn = ["header", "footer", "headerFirst", "headerEven", "footerFirst", "footerEven"];
3179
- function Bs(e, t) {
3177
+ const Gt = 2, Ht = 2, Bs = 48, on = ["header", "footer", "headerFirst", "headerEven", "footerFirst", "footerEven"];
3178
+ function Ms(e, t) {
3180
3179
  const n = {
3181
3180
  pageWidthPx: t.pageWidthPx ?? e.pageWidthPx,
3182
3181
  pageHeightPx: t.pageHeightPx ?? e.pageHeightPx,
3183
3182
  marginPx: t.marginPx ?? e.marginPx
3184
3183
  }, i = t.columns === void 0 ? e.columns : t.columns ?? void 0;
3185
3184
  i && (n.columns = i), t.pageNumberStart !== void 0 && (n.pageNumberStart = t.pageNumberStart);
3186
- const x = t.headerDistancePx ?? e.headerDistancePx;
3187
- x !== void 0 && (n.headerDistancePx = x);
3185
+ const r = t.headerDistancePx ?? e.headerDistancePx;
3186
+ r !== void 0 && (n.headerDistancePx = r);
3188
3187
  const s = t.footerDistancePx ?? e.footerDistancePx;
3189
3188
  s !== void 0 && (n.footerDistancePx = s);
3190
- for (const l of xn) {
3191
- const f = t[l] ?? e[l];
3192
- f && (n[l] = f);
3189
+ for (const l of on) {
3190
+ const u = t[l] ?? e[l];
3191
+ u && (n[l] = u);
3193
3192
  }
3194
3193
  return n;
3195
3194
  }
3196
- function Ht(e, t) {
3195
+ function _t(e, t) {
3197
3196
  return e.headerDistancePx !== void 0 ? e.headerDistancePx : Math.max(8, (e.marginPx.top - t) / 2);
3198
3197
  }
3199
- function _t(e, t) {
3198
+ function zt(e, t) {
3200
3199
  return e.footerDistancePx !== void 0 ? e.pageHeightPx - e.footerDistancePx - t : e.pageHeightPx - Math.max(8, (e.marginPx.bottom - t) / 2) - t;
3201
3200
  }
3202
- function Ms(e) {
3201
+ function Cs(e) {
3203
3202
  const t = [];
3204
3203
  for (let n = 0; n < e.blocks.length; n++) {
3205
3204
  const i = e.blocks[n];
3206
- i.kind === "paragraph" && i.style.sectionBreak && t.push({ props: Bs(e.section, i.style.sectionBreak.props), endBlock: n });
3205
+ i.kind === "paragraph" && i.style.sectionBreak && t.push({ props: Ms(e.section, i.style.sectionBreak.props), endBlock: n });
3207
3206
  }
3208
3207
  return t.push({ props: e.section, endBlock: e.blocks.length - 1 }), t;
3209
3208
  }
3210
- function Cs(e, t, n, i) {
3209
+ function ks(e, t, n, i) {
3211
3210
  const s = /* @__PURE__ */ new Map();
3212
3211
  let l = null;
3213
- const f = (h) => {
3212
+ const u = (h) => {
3214
3213
  const F = s.get(h);
3215
3214
  if (F) return F;
3216
3215
  let g = h.marginPx.top, B = h.pageHeightPx - h.marginPx.bottom;
3217
- const I = [h.header, h.headerFirst, h.headerEven].filter((_) => !!_), O = [h.footer, h.footerFirst, h.footerEven].filter((_) => !!_);
3218
- if (I.length > 0 || O.length > 0) {
3219
- l ??= new Ve();
3220
- const _ = h.pageWidthPx - h.marginPx.left - h.marginPx.right, K = h.marginPx.left, Y = (q) => be(q, _, K, 999, 999, l, !1).height, j = (q) => {
3221
- const X = be(q, _, K, 999, 999, l, !1);
3222
- for (const ee of X.placed)
3223
- if (!!ee.table || !!ee.image || ee.lines.some((ae) => ae.fragments.some((pn) => pn.text.trim().length > 0))) return X.height - ee.y;
3216
+ const I = [h.header, h.headerFirst, h.headerEven].filter((_) => !!_), b = [h.footer, h.footerFirst, h.footerEven].filter((_) => !!_);
3217
+ if (I.length > 0 || b.length > 0) {
3218
+ l ??= new Ze();
3219
+ const _ = h.pageWidthPx - h.marginPx.left - h.marginPx.right, j = h.marginPx.left, X = (V) => Ie(V, _, j, 999, 999, l, !1).height, K = (V) => {
3220
+ const ee = Ie(V, _, j, 999, 999, l, !1);
3221
+ for (const $ of ee.placed)
3222
+ if (!!$.table || !!$.image || $.lines.some((Me) => Me.fragments.some((ae) => ae.text.trim().length > 0))) return ee.height - $.y;
3224
3223
  return 0;
3225
- }, Q = I.reduce((q, X) => Math.max(q, Y(X)), 0);
3224
+ }, Q = I.reduce((V, ee) => Math.max(V, X(ee)), 0);
3226
3225
  if (Q > 0) {
3227
- const q = Ht(h, Q);
3228
- g = Math.max(g, q + Q + 6);
3226
+ const V = _t(h, Q);
3227
+ g = Math.max(g, V + Q + 6);
3229
3228
  }
3230
- const V = O.reduce((q, X) => Math.max(q, Y(X)), 0);
3231
- if (V > 0)
3229
+ const q = b.reduce((V, ee) => Math.max(V, X(ee)), 0);
3230
+ if (q > 0)
3232
3231
  if (h.footerDistancePx !== void 0) {
3233
- const q = h.pageHeightPx - h.footerDistancePx, X = O.reduce((ee, me) => Math.max(ee, j(me)), 0);
3234
- B = Math.min(B, q - X);
3232
+ const V = h.pageHeightPx - h.footerDistancePx, ee = b.reduce(($, me) => Math.max($, K(me)), 0);
3233
+ B = Math.min(B, V - ee);
3235
3234
  } else
3236
- B = Math.min(B, _t(h, V) - 6);
3235
+ B = Math.min(B, zt(h, q) - 6);
3237
3236
  B = Math.max(B, g + 24);
3238
3237
  }
3239
3238
  const G = { top: g, bottom: B };
3240
3239
  return s.set(h, G), G;
3241
- }, o = Ms(e);
3242
- let r = o[0].props, c = 0, a = 0, u = 0, d = 0, S = 1, p = 0, A = 0;
3240
+ }, o = Cs(e);
3241
+ let x = o[0].props, c = 0, a = 0, f = 0, d = 0, S = 1, A = 0, m = 0;
3243
3242
  const M = (h) => {
3244
- r = h;
3245
- const F = f(r);
3246
- c = r.marginPx.left, a = F.top, u = F.bottom, d = r.pageWidthPx - r.marginPx.left - r.marginPx.right, S = Math.max(1, r.columns?.count ?? 1), p = r.columns?.gapPx ?? 24, A = S > 1 ? (d - (S - 1) * p) / S : d;
3243
+ x = h;
3244
+ const F = u(x);
3245
+ c = x.marginPx.left, a = F.top, f = F.bottom, d = x.pageWidthPx - x.marginPx.left - x.marginPx.right, S = Math.max(1, x.columns?.count ?? 1), A = x.columns?.gapPx ?? 24, m = S > 1 ? (d - (S - 1) * A) / S : d;
3247
3246
  };
3248
- M(r);
3247
+ M(x);
3249
3248
  const v = e.lists ?? {}, L = (h) => {
3250
3249
  const F = h.style.list;
3251
3250
  if (!F) return null;
@@ -3256,11 +3255,11 @@ function Cs(e, t, n, i) {
3256
3255
  if (!F || !g) return;
3257
3256
  const B = v[F.listId], I = D.get(F.listId) ?? [];
3258
3257
  I[F.level] = (I[F.level] ?? g.start - 1) + 1, I.length = F.level + 1, D.set(F.listId, I);
3259
- const O = as(B, F.level, I);
3260
- if (O.length === 0) return;
3258
+ const b = us(B, F.level, I);
3259
+ if (b.length === 0) return;
3261
3260
  const G = h.runs[0]?.style;
3262
3261
  G && E.set(h.id, {
3263
- text: O,
3262
+ text: b,
3264
3263
  style: { ...G, ...g.markerStyle ?? {} },
3265
3264
  hangingPx: g.hangingPx
3266
3265
  });
@@ -3276,197 +3275,197 @@ function Cs(e, t, n, i) {
3276
3275
  for (; h > o[z].endBlock; ) M(o[++z].props);
3277
3276
  const F = e.blocks[h];
3278
3277
  if (F.kind === "paragraph") {
3279
- if (Ss(F)) continue;
3280
- const g = F.style.tocEntry ? Es : 0;
3278
+ if (ps(F)) continue;
3279
+ const g = F.style.tocEntry ? Bs : 0;
3281
3280
  H.push({
3282
3281
  kind: "para",
3283
3282
  block: F,
3284
- lines: t(F, A - w(F) - R(F) - g)
3283
+ lines: t(F, m - w(F) - R(F) - g)
3285
3284
  });
3286
3285
  } else if (F.kind === "image")
3287
3286
  H.push({ kind: "image", block: F, height: F.heightPx });
3288
3287
  else {
3289
- const g = at(F, A, t, W);
3288
+ const g = ut(F, m, t, W);
3290
3289
  H.push({ kind: "table", block: F, ...g });
3291
3290
  }
3292
3291
  }
3293
3292
  z = 0, M(o[0].props);
3294
- const C = [], m = () => (C.push(r), {
3293
+ const C = [], p = () => (C.push(x), {
3295
3294
  index: C.length - 1,
3296
3295
  number: C.length,
3297
3296
  // provisional; the post-pass sets the real value
3298
3297
  blocks: [],
3299
- widthPx: r.pageWidthPx,
3300
- heightPx: r.pageHeightPx,
3301
- marginPx: r.marginPx,
3298
+ widthPx: x.pageWidthPx,
3299
+ heightPx: x.pageHeightPx,
3300
+ marginPx: x.marginPx,
3302
3301
  contentTopPx: a,
3303
- contentBottomPx: u
3304
- }), y = [m()];
3305
- let k = y[0], b = a;
3306
- const U = /* @__PURE__ */ new Map(), J = 14, $ = 18, te = e.footnotes ?? {}, ne = Object.keys(te).length > 0;
3302
+ contentBottomPx: f
3303
+ }), y = [p()];
3304
+ let k = y[0], O = a;
3305
+ const U = /* @__PURE__ */ new Map(), J = 14, Y = 18, te = e.footnotes ?? {}, ne = Object.keys(te).length > 0;
3307
3306
  let he = 0;
3308
- const Z = () => u - he, le = /* @__PURE__ */ new Set(), re = [[]], Ge = [0], ht = /* @__PURE__ */ new Map(), dt = (h) => {
3307
+ const Z = () => f - he, le = /* @__PURE__ */ new Set(), xe = [[]], He = [0], dt = /* @__PURE__ */ new Map(), Ft = (h) => {
3309
3308
  const F = te[h];
3310
3309
  if (!F || F.length === 0) return null;
3311
- const g = Math.max(40, d - $);
3310
+ const g = Math.max(40, d - Y);
3312
3311
  let B = 0;
3313
- return { paras: F.map((O) => {
3314
- const G = t(O, g);
3315
- return B += O.style.spaceBeforePx + Se(G) + O.style.spaceAfterPx, { p: O, lines: G };
3312
+ return { paras: F.map((b) => {
3313
+ const G = t(b, g);
3314
+ return B += b.style.spaceBeforePx + pe(G) + b.style.spaceAfterPx, { p: b, lines: G };
3316
3315
  }), height: B };
3317
- }, on = (h, F, g) => {
3316
+ }, cn = (h, F, g) => {
3318
3317
  const B = [];
3319
3318
  for (let I = F; I < F + g; I++)
3320
- for (const O of h[I].fragments) {
3321
- const G = O.style.footnoteRef;
3322
- G && te[G] && !le.has(G) && !B.some(([_]) => _ === G) && B.push([G, O.text]);
3319
+ for (const b of h[I].fragments) {
3320
+ const G = b.style.footnoteRef;
3321
+ G && te[G] && !le.has(G) && !B.some(([_]) => _ === G) && B.push([G, b.text]);
3323
3322
  }
3324
3323
  return B;
3325
3324
  };
3326
- let Ne = 0, Le = 0;
3327
- const ce = () => c + Ne * (A + p), se = () => k.blocks.length > Le, He = () => {
3328
- Ne = 0, Le = 0, k = m(), y.push(k), re.push([]), Ge.push(0), he = 0, b = a, pe = [];
3325
+ let Se = 0, Oe = 0;
3326
+ const ce = () => c + Se * (m + A), se = () => k.blocks.length > Oe, _e = () => {
3327
+ Se = 0, Oe = 0, k = p(), y.push(k), xe.push([]), He.push(0), he = 0, O = a, de = [];
3329
3328
  }, ie = () => {
3330
- Ne + 1 < S ? (Ne++, Le = k.blocks.length, b = a, pe = []) : He();
3331
- }, ln = () => {
3332
- k.blocks.length === 0 ? (k.widthPx = r.pageWidthPx, k.heightPx = r.pageHeightPx, k.marginPx = r.marginPx, k.contentTopPx = a, k.contentBottomPx = u, C[k.index] = r, Ne = 0, Le = 0, b = a, pe = []) : He();
3333
- }, cn = (h, F, g, B) => {
3329
+ Se + 1 < S ? (Se++, Oe = k.blocks.length, O = a, de = []) : _e();
3330
+ }, an = () => {
3331
+ k.blocks.length === 0 ? (k.widthPx = x.pageWidthPx, k.heightPx = x.pageHeightPx, k.marginPx = x.marginPx, k.contentTopPx = a, k.contentBottomPx = f, C[k.index] = x, Se = 0, Oe = 0, O = a, de = []) : _e();
3332
+ }, un = (h, F, g, B) => {
3334
3333
  const I = {
3335
3334
  blockId: h.id,
3336
3335
  x: ce() + w(h),
3337
- y: b,
3336
+ y: O,
3338
3337
  firstLineIndex: g,
3339
3338
  lines: []
3340
- }, O = g === 0 ? E.get(h.id) : void 0;
3341
- O && (I.marker = { text: O.text, style: O.style, x: I.x - O.hangingPx }), h.style.tocEntry && U.set(h.id, { chunk: I, rightEdge: ce() + A, para: h }), k.blocks.push(I);
3339
+ }, b = g === 0 ? E.get(h.id) : void 0;
3340
+ b && (I.marker = { text: b.text, style: b.style, x: I.x - b.hangingPx }), h.style.tocEntry && U.set(h.id, { chunk: I, rightEdge: ce() + m, para: h }), k.blocks.push(I);
3342
3341
  for (let G = g; G < g + B; G++) {
3343
3342
  const _ = F[G];
3344
- I.lines.push({ ..._, y: b - I.y }), b += _.height;
3343
+ I.lines.push({ ..._, y: O - I.y }), O += _.height;
3345
3344
  }
3346
- }, an = (h, F) => {
3347
- let g = 0, B = b;
3345
+ }, fn = (h, F) => {
3346
+ let g = 0, B = O;
3348
3347
  for (; F + g < h.length && B + h[F + g].height <= Z(); )
3349
3348
  B += h[F + g].height, g++;
3350
3349
  return g;
3351
- }, Ft = (h) => {
3352
- let F = re[k.index].length === 0 ? J : 0;
3350
+ }, gt = (h) => {
3351
+ let F = xe[k.index].length === 0 ? J : 0;
3353
3352
  const g = [];
3354
3353
  for (const [B, I] of h) {
3355
- const O = dt(B);
3356
- O && (F += O.height, g.push([B, I, O]));
3354
+ const b = Ft(B);
3355
+ b && (F += b.height, g.push([B, I, b]));
3357
3356
  }
3358
3357
  return { H: F, measures: g };
3359
- }, gt = (h, F) => {
3358
+ }, Nt = (h, F) => {
3360
3359
  for (const [g, B] of h)
3361
- le.add(g), re[k.index].push(g), ht.set(g, B);
3362
- he += F, Ge[k.index] = he;
3363
- }, un = (h) => {
3360
+ le.add(g), xe[k.index].push(g), dt.set(g, B);
3361
+ he += F, He[k.index] = he;
3362
+ }, hn = (h) => {
3364
3363
  const F = [], g = (B) => {
3365
3364
  for (const I of B)
3366
3365
  if (I.kind === "paragraph") {
3367
- let O = 0;
3366
+ let b = 0;
3368
3367
  for (const G of I.runs) {
3369
3368
  const _ = G.style.footnoteRef;
3370
- _ && te[_] && !le.has(_) && !F.some(([K]) => K === _) && F.push([_, G.text]), O += G.text.length;
3369
+ _ && te[_] && !le.has(_) && !F.some(([j]) => j === _) && F.push([_, G.text]), b += G.text.length;
3371
3370
  }
3372
3371
  } else if (I.kind === "table")
3373
- for (const O of I.rows) for (const G of O.cells) g(G.blocks);
3372
+ for (const b of I.rows) for (const G of b.cells) g(G.blocks);
3374
3373
  };
3375
3374
  for (const B of h) for (const I of B.cells) g(I.blocks);
3376
3375
  return F;
3377
- }, fn = (h, F, g) => {
3376
+ }, dn = (h, F, g) => {
3378
3377
  for (; ; ) {
3379
3378
  if (g <= 0) return g;
3380
- const B = on(h, F, g);
3379
+ const B = cn(h, F, g);
3381
3380
  if (B.length === 0) return g;
3382
- const { H: I, measures: O } = Ft(B);
3383
- if (O.length === 0) return g;
3381
+ const { H: I, measures: b } = gt(B);
3382
+ if (b.length === 0) return g;
3384
3383
  let G = 0;
3385
- for (let K = F; K < F + g; K++) G += h[K].height;
3386
- if (b + G + I <= Z() || g === 1 && !se())
3387
- return gt(O, I), g;
3384
+ for (let j = F; j < F + g; j++) G += h[j].height;
3385
+ if (O + G + I <= Z() || g === 1 && !se())
3386
+ return Nt(b, I), g;
3388
3387
  g--;
3389
3388
  }
3390
- }, hn = (h, F) => {
3389
+ }, Fn = (h, F) => {
3391
3390
  if (h.style.keepLinesTogether === !0 && se()) {
3392
- const B = Se(F);
3393
- b + B > Z() && B <= u - a && ie();
3391
+ const B = pe(F);
3392
+ O + B > Z() && B <= f - a && ie();
3394
3393
  }
3395
3394
  let g = 0;
3396
3395
  for (; g < F.length; ) {
3397
- const B = F.length - g, I = an(F, g);
3398
- let O;
3399
- if (I >= B ? O = B : (O = I, B - O === 1 && (O -= Gt - 1), g === 0 && O > 0 && O < Tt && (O = 0), O <= 0 && (O = se() ? 0 : Math.max(1, I))), O > 0 && ne && (O = fn(F, g, O)), O > 0 && (cn(h, F, g, O), g += O), g >= F.length) return;
3396
+ const B = F.length - g, I = fn(F, g);
3397
+ let b;
3398
+ if (I >= B ? b = B : (b = I, B - b === 1 && (b -= Ht - 1), g === 0 && b > 0 && b < Gt && (b = 0), b <= 0 && (b = se() ? 0 : Math.max(1, I))), b > 0 && ne && (b = dn(F, g, b)), b > 0 && (un(h, F, g, b), g += b), g >= F.length) return;
3400
3399
  ie();
3401
3400
  }
3402
- }, Se = (h) => {
3401
+ }, pe = (h) => {
3403
3402
  let F = 0;
3404
3403
  for (const g of h) F += g.height;
3405
3404
  return F;
3406
3405
  };
3407
- let pe = [];
3408
- const Nt = 10, dn = (h) => {
3409
- let F = ce(), g = ce() + A;
3410
- for (const B of pe)
3411
- h >= B.bottom || (B.side === "left" ? F = Math.max(F, B.right + Nt) : g = Math.min(g, B.left - Nt));
3406
+ let de = [];
3407
+ const St = 10, gn = (h) => {
3408
+ let F = ce(), g = ce() + m;
3409
+ for (const B of de)
3410
+ h >= B.bottom || (B.side === "left" ? F = Math.max(F, B.right + St) : g = Math.min(g, B.left - St));
3412
3411
  return { x0: F, width: Math.max(40, g - F) };
3413
- }, Fn = (h) => pe.some((F) => F.bottom > h), gn = (h) => {
3414
- b + h.heightPx > Z() && se() && ie();
3415
- const F = h.wrap === "square" && h.align !== "center", g = A - h.widthPx, B = ce() + (h.align === "center" ? g / 2 : h.align === "right" ? g : 0);
3412
+ }, Nn = (h) => de.some((F) => F.bottom > h), Sn = (h) => {
3413
+ O + h.heightPx > Z() && se() && ie();
3414
+ const F = h.wrap === "square" && h.align !== "center", g = m - h.widthPx, B = ce() + (h.align === "center" ? g / 2 : h.align === "right" ? g : 0);
3416
3415
  k.blocks.push({
3417
3416
  blockId: h.id,
3418
3417
  x: B,
3419
- y: b,
3418
+ y: O,
3420
3419
  firstLineIndex: 0,
3421
3420
  lines: [],
3422
3421
  image: { src: h.src, width: h.widthPx, height: h.heightPx }
3423
- }), F ? pe.push({ left: B, right: B + h.widthPx, bottom: b + h.heightPx, side: h.align === "right" ? "right" : "left" }) : b += h.heightPx;
3424
- }, Nn = (h) => {
3422
+ }), F ? de.push({ left: B, right: B + h.widthPx, bottom: O + h.heightPx, side: h.align === "right" ? "right" : "left" }) : O += h.heightPx;
3423
+ }, pn = (h) => {
3425
3424
  const F = n(h);
3426
3425
  let g = !0, B = 0, I = null;
3427
- const O = (G, _, K, Y) => {
3426
+ const b = (G, _, j, X) => {
3428
3427
  if (I === null) {
3429
- I = { blockId: h.id, x: ce() + w(h), y: b, firstLineIndex: B, lines: [] };
3428
+ I = { blockId: h.id, x: ce() + w(h), y: O, firstLineIndex: B, lines: [] };
3430
3429
  const Q = B === 0 ? E.get(h.id) : void 0;
3431
3430
  Q && (I.marker = { text: Q.text, style: Q.style, x: I.x - Q.hangingPx }), k.blocks.push(I);
3432
3431
  }
3433
- const j = { y: b - I.y, height: _, ascent: K, fragments: G.map((Q) => Q.frag) };
3434
- Y !== void 0 && (j.emptyOffset = Y), I.lines.push(j), b += _, B++;
3432
+ const K = { y: O - I.y, height: _, ascent: j, fragments: G.map((Q) => Q.frag) };
3433
+ X !== void 0 && (K.emptyOffset = X), I.lines.push(K), O += _, B++;
3435
3434
  };
3436
3435
  for (const G of F) {
3437
- const _ = lt(G.runs, G.startOffset), K = G.runs.map(() => 0);
3438
- let Y, j = !1;
3436
+ const _ = ct(G.runs, G.startOffset), j = G.runs.map(() => 0);
3437
+ let X, K = !1, Q = null;
3439
3438
  for (; ; ) {
3440
- const Q = K.slice(), V = dn(b), q = g ? h.style.indentFirstLinePx : 0, X = ct(
3439
+ const q = j.slice(), V = gn(O), ee = g ? h.style.indentFirstLinePx : 0, $ = at(
3441
3440
  h,
3442
3441
  G,
3443
- Math.max(24, V.width - w(h) - q - R(h)),
3444
- Y,
3442
+ Math.max(24, V.width - w(h) - ee - R(h)),
3443
+ X,
3445
3444
  _,
3446
- K
3445
+ j
3447
3446
  );
3448
- if (X === null) break;
3449
- if (b + X.height > Z() && se()) {
3450
- for (let ae = 0; ae < K.length; ae++) K[ae] = Q[ae];
3447
+ if ($ === null) break;
3448
+ if (O + $.height > Z() && se()) {
3449
+ for (let ae = 0; ae < j.length; ae++) j[ae] = q[ae];
3451
3450
  ie(), I = null;
3452
3451
  continue;
3453
3452
  }
3454
- const ee = V.width - q - R(h) - X.width;
3455
- let me = V.x0 - ce() + q;
3456
- h.style.align === "center" ? me += ee / 2 : h.style.align === "right" && (me += ee);
3457
- for (const ae of X.frags) ae.frag.x += me;
3458
- O(X.frags, X.height, X.ascent), Y = X.end, g = !1, j = !0;
3453
+ const me = V.width - ee - R(h) - $.width;
3454
+ let Me = V.x0 - ce() + ee;
3455
+ h.style.align === "center" ? Me += me / 2 : h.style.align === "right" && (Me += me);
3456
+ for (const ae of $.frags) ae.frag.x += Me;
3457
+ h.style.align === "justify" && (Q && rn(Q.frags, Q.slack), Q = { frags: $.frags, slack: me }), b($.frags, $.height, $.ascent), X = $.end, g = !1, K = !0;
3459
3458
  }
3460
- if (!j) {
3461
- const Q = tn(h);
3462
- b + Q.height > Z() && se() && (ie(), I = null), O([], Q.height, Q.ascent, G.startOffset), g = !1;
3459
+ if (!K) {
3460
+ const q = nn(h);
3461
+ O + q.height > Z() && se() && (ie(), I = null), b([], q.height, q.ascent, G.startOffset), g = !1;
3463
3462
  }
3464
3463
  }
3465
- }, Sn = (h) => {
3466
- h.block.rows.some((B) => B.cells.some((I) => (I.rowSpan ?? 1) > 1)) && se() && b + h.height > Z() && h.height <= u - a && ie();
3464
+ }, mn = (h) => {
3465
+ h.block.rows.some((B) => B.cells.some((I) => (I.rowSpan ?? 1) > 1)) && se() && O + h.height > Z() && h.height <= f - a && ie();
3467
3466
  let g = 0;
3468
3467
  for (; g < h.rows.length; ) {
3469
- let B = 0, I = b;
3468
+ let B = 0, I = O;
3470
3469
  for (; g + B < h.rows.length && I + h.rows[g + B].height <= Z(); )
3471
3470
  I += h.rows[g + B].height, B++;
3472
3471
  if (B === 0) {
@@ -3476,16 +3475,16 @@ function Cs(e, t, n, i) {
3476
3475
  }
3477
3476
  B = 1;
3478
3477
  }
3479
- let O = [], G = 0;
3478
+ let b = [], G = 0;
3480
3479
  for (; ; ) {
3481
- const K = un(h.block.rows.slice(g, g + B));
3482
- if (K.length === 0) break;
3483
- const { H: Y, measures: j } = Ft(K);
3480
+ const j = hn(h.block.rows.slice(g, g + B));
3484
3481
  if (j.length === 0) break;
3482
+ const { H: X, measures: K } = gt(j);
3483
+ if (K.length === 0) break;
3485
3484
  let Q = 0;
3486
- for (let V = g; V < g + B; V++) Q += h.rows[V].height;
3487
- if (b + Q + Y <= Z() || B === 1 && !se()) {
3488
- O = j, G = Y;
3485
+ for (let q = g; q < g + B; q++) Q += h.rows[q].height;
3486
+ if (O + Q + X <= Z() || B === 1 && !se()) {
3487
+ b = K, G = X;
3489
3488
  break;
3490
3489
  }
3491
3490
  if (B--, B === 0) break;
@@ -3494,143 +3493,145 @@ function Cs(e, t, n, i) {
3494
3493
  ie();
3495
3494
  continue;
3496
3495
  }
3497
- O.length > 0 && gt(O, G);
3496
+ b.length > 0 && Nt(b, G);
3498
3497
  const _ = h.rows.slice(g, g + B);
3499
- k.blocks.push(ft(h.block, _, h.colWidths, ce(), b, A, g, W)), b += _.reduce((K, Y) => K + Y.height, 0), g += B, g < h.rows.length && ie();
3498
+ k.blocks.push(ht(h.block, _, h.colWidths, ce(), O, m, g, W)), O += _.reduce((j, X) => j + X.height, 0), g += B, g < h.rows.length && ie();
3500
3499
  }
3501
3500
  };
3502
3501
  for (let h = 0; h < H.length; h++) {
3503
3502
  if (h > o[z].endBlock) {
3504
3503
  for (; h > o[z].endBlock; ) M(o[++z].props);
3505
- ln();
3504
+ an();
3506
3505
  }
3507
3506
  const F = H[h], g = (_) => _?.kind === "table" || _?.kind === "image", B = g(H[h - 1]), I = g(H[h + 1]);
3508
3507
  if (F.kind === "image") {
3509
- B || (b += Me), gn(F.block), !I && (F.block.wrap !== "square" || F.block.align === "center") && (b += Me);
3508
+ B || (O += Ce), Sn(F.block), !I && (F.block.wrap !== "square" || F.block.align === "center") && (O += Ce);
3510
3509
  continue;
3511
3510
  }
3512
3511
  if (F.kind === "table") {
3513
- B || (b += Me), Sn(F), I || (b += Me);
3512
+ B || (O += Ce);
3513
+ for (const _ of de) _.bottom > O && (O = _.bottom);
3514
+ mn(F), I || (O += Ce);
3514
3515
  continue;
3515
3516
  }
3516
- const { block: O, lines: G } = F;
3517
- if (O.style.pageBreakBefore === !0 && (k.blocks.length > 0 || Ne > 0) ? He() : O.style.columnBreakBefore === !0 && se() && ie(), b += O.style.spaceBeforePx, b >= Z() && se() && ie(), Fn(b)) {
3518
- Nn(O), b += O.style.spaceAfterPx;
3517
+ const { block: b, lines: G } = F;
3518
+ if (b.style.pageBreakBefore === !0 && (k.blocks.length > 0 || Se > 0) ? _e() : b.style.columnBreakBefore === !0 && se() && ie(), O += b.style.spaceBeforePx, O >= Z() && se() && ie(), Nn(O)) {
3519
+ pn(b), O += b.style.spaceAfterPx;
3519
3520
  continue;
3520
3521
  }
3521
- if (O.style.keepWithNext === !0 && H[h + 1] !== void 0 && se()) {
3522
- let _ = b + Se(G) + O.style.spaceAfterPx, K = _ <= Z();
3523
- for (let Y = h + 1; K; Y++) {
3524
- const j = H[Y];
3525
- if (j === void 0) break;
3526
- if (j.kind !== "para") {
3527
- const ee = j.kind === "table" ? j.rows[0]?.height ?? j.height : j.height;
3528
- _ + Me + ee > Z() && (K = !1);
3522
+ if (b.style.keepWithNext === !0 && H[h + 1] !== void 0 && se()) {
3523
+ let _ = O + pe(G) + b.style.spaceAfterPx, j = _ <= Z();
3524
+ for (let X = h + 1; j; X++) {
3525
+ const K = H[X];
3526
+ if (K === void 0) break;
3527
+ if (K.kind !== "para") {
3528
+ const $ = K.kind === "table" ? K.rows[0]?.height ?? K.height : K.height;
3529
+ _ + Ce + $ > Z() && (j = !1);
3529
3530
  break;
3530
3531
  }
3531
- _ += j.block.style.spaceBeforePx;
3532
- const Q = j.block.style.keepWithNext === !0 && H[Y + 1] !== void 0;
3533
- if (Q || j.block.style.keepLinesTogether === !0) {
3534
- const ee = Se(j.lines);
3535
- if (_ + ee > Z()) {
3536
- K = !1;
3532
+ _ += K.block.style.spaceBeforePx;
3533
+ const Q = K.block.style.keepWithNext === !0 && H[X + 1] !== void 0;
3534
+ if (Q || K.block.style.keepLinesTogether === !0) {
3535
+ const $ = pe(K.lines);
3536
+ if (_ + $ > Z()) {
3537
+ j = !1;
3537
3538
  break;
3538
3539
  }
3539
- if (_ += ee + j.block.style.spaceAfterPx, !Q) break;
3540
+ if (_ += $ + K.block.style.spaceAfterPx, !Q) break;
3540
3541
  continue;
3541
3542
  }
3542
- if (H[Y + 1] !== void 0 && j.block.runs.every((ee) => ee.text.trim().length === 0)) {
3543
- const ee = Se(j.lines);
3544
- if (_ + ee > Z()) {
3545
- K = !1;
3543
+ if (H[X + 1] !== void 0 && K.block.runs.every(($) => $.text.trim().length === 0)) {
3544
+ const $ = pe(K.lines);
3545
+ if (_ + $ > Z()) {
3546
+ j = !1;
3546
3547
  break;
3547
3548
  }
3548
- _ += ee + j.block.style.spaceAfterPx;
3549
+ _ += $ + K.block.style.spaceAfterPx;
3549
3550
  continue;
3550
3551
  }
3551
- let V = 0, q = _;
3552
- for (; V < j.lines.length && q + j.lines[V].height <= Z(); )
3553
- q += j.lines[V].height, V++;
3554
- let X = V;
3555
- V < j.lines.length && (j.lines.length - X === 1 && (X -= Gt - 1), X < Tt && (X = 0)), X <= 0 && (K = !1);
3552
+ let q = 0, V = _;
3553
+ for (; q < K.lines.length && V + K.lines[q].height <= Z(); )
3554
+ V += K.lines[q].height, q++;
3555
+ let ee = q;
3556
+ q < K.lines.length && (K.lines.length - ee === 1 && (ee -= Ht - 1), ee < Gt && (ee = 0)), ee <= 0 && (j = !1);
3556
3557
  break;
3557
3558
  }
3558
- K || ie();
3559
+ j || ie();
3559
3560
  }
3560
- hn(O, G), b += O.style.spaceAfterPx;
3561
+ Fn(b, G), O += b.style.spaceAfterPx;
3561
3562
  }
3562
3563
  for (const h of y) {
3563
- const F = re[h.index];
3564
+ const F = xe[h.index];
3564
3565
  if (!F || F.length === 0) continue;
3565
3566
  const g = C[h.index];
3566
3567
  M(g);
3567
- let B = u - Ge[h.index];
3568
+ let B = f - He[h.index];
3568
3569
  h.footnoteRuleY = B + 4, B += J;
3569
3570
  const I = g.marginPx.left;
3570
- for (const O of F) {
3571
- const G = dt(O);
3571
+ for (const b of F) {
3572
+ const G = Ft(b);
3572
3573
  if (!G) continue;
3573
3574
  let _ = !0;
3574
- for (const K of G.paras) {
3575
- B += K.p.style.spaceBeforePx;
3576
- const Y = {
3577
- blockId: K.p.id,
3578
- x: I + $,
3575
+ for (const j of G.paras) {
3576
+ B += j.p.style.spaceBeforePx;
3577
+ const X = {
3578
+ blockId: j.p.id,
3579
+ x: I + Y,
3579
3580
  y: B,
3580
3581
  firstLineIndex: 0,
3581
- lines: K.lines
3582
+ lines: j.lines
3582
3583
  };
3583
- _ && K.p.runs[0] && (Y.marker = { text: `${ht.get(O) ?? "•"}.`, style: K.p.runs[0].style, x: I }, _ = !1), h.blocks.push(Y), B += Se(K.lines) + K.p.style.spaceAfterPx;
3584
+ _ && j.p.runs[0] && (X.marker = { text: `${dt.get(b) ?? "•"}.`, style: j.p.runs[0].style, x: I }, _ = !1), h.blocks.push(X), B += pe(j.lines) + j.p.style.spaceAfterPx;
3584
3585
  }
3585
3586
  }
3586
3587
  }
3587
- const _e = [];
3588
+ const ze = [];
3588
3589
  {
3589
3590
  let h = 0;
3590
3591
  for (let F = 0; F < y.length; F++) {
3591
3592
  const g = C[F];
3592
- (F === 0 || C[F - 1] !== g) && g.pageNumberStart !== void 0 ? h = g.pageNumberStart : h++, _e.push(h), y[F].number = h;
3593
+ (F === 0 || C[F - 1] !== g) && g.pageNumberStart !== void 0 ? h = g.pageNumberStart : h++, ze.push(h), y[F].number = h;
3593
3594
  }
3594
3595
  }
3595
3596
  if (U.size > 0) {
3596
3597
  const h = /* @__PURE__ */ new Map(), F = (g, B) => {
3597
3598
  for (const I of g)
3598
- if (h.has(I.blockId) || h.set(I.blockId, B), I.table) for (const O of I.table.rows) for (const G of O.cells) F(G.blocks, B);
3599
+ if (h.has(I.blockId) || h.set(I.blockId, B), I.table) for (const b of I.table.rows) for (const G of b.cells) F(G.blocks, B);
3599
3600
  };
3600
- for (const g of y) F(g.blocks, _e[g.index]);
3601
+ for (const g of y) F(g.blocks, ze[g.index]);
3601
3602
  for (const g of U.values()) {
3602
3603
  const B = g.para.style.tocEntry.targetId, I = h.get(B);
3603
3604
  if (I === void 0) continue;
3604
- const O = g.para.runs[0]?.style;
3605
- if (!O || g.chunk.lines.length === 0) continue;
3605
+ const b = g.para.runs[0]?.style;
3606
+ if (!b || g.chunk.lines.length === 0) continue;
3606
3607
  const G = String(I);
3607
3608
  g.chunk.toc = {
3608
3609
  numText: G,
3609
- numX: g.rightEdge - et(G, fe(O)),
3610
+ numX: g.rightEdge - tt(G, fe(b)),
3610
3611
  lineIndex: g.chunk.lines.length - 1,
3611
- style: O
3612
+ style: b
3612
3613
  };
3613
3614
  }
3614
3615
  }
3615
- const St = (h, F, g, B) => {
3616
- const I = F === "header" ? h.headerFirst : h.footerFirst, O = F === "header" ? h.headerEven : h.footerEven;
3616
+ const pt = (h, F, g, B) => {
3617
+ const I = F === "header" ? h.headerFirst : h.footerFirst, b = F === "header" ? h.headerEven : h.footerEven;
3617
3618
  if (g && I) return { blocks: I, source: F === "header" ? "headerFirst" : "footerFirst" };
3618
- if (B && O) return { blocks: O, source: F === "header" ? "headerEven" : "footerEven" };
3619
+ if (B && b) return { blocks: b, source: F === "header" ? "headerEven" : "footerEven" };
3619
3620
  const G = h[F];
3620
3621
  return G ? { blocks: G, source: F } : null;
3621
3622
  };
3622
- if (C.some((h) => xn.some((F) => h[F]))) {
3623
- const h = new Ve();
3623
+ if (C.some((h) => on.some((F) => h[F]))) {
3624
+ const h = new Ze();
3624
3625
  for (const F of y) {
3625
- const g = C[F.index], B = g.pageWidthPx - g.marginPx.left - g.marginPx.right, I = g.marginPx.left, O = F.index === 0 || C[F.index - 1] !== g, G = _e[F.index], _ = G % 2 === 0, K = St(g, "header", O, _);
3626
- if (K) {
3627
- const j = i === "header", Q = be(K.blocks, B, I, G, y.length, h, j), V = Ht(g, Q.height);
3628
- F.header = Q.placed.map((q) => Ze(q, V)), F.headerSource = K.source;
3626
+ const g = C[F.index], B = g.pageWidthPx - g.marginPx.left - g.marginPx.right, I = g.marginPx.left, b = F.index === 0 || C[F.index - 1] !== g, G = ze[F.index], _ = G % 2 === 0, j = pt(g, "header", b, _);
3627
+ if (j) {
3628
+ const K = i === "header", Q = Ie(j.blocks, B, I, G, y.length, h, K), q = _t(g, Q.height);
3629
+ F.header = Q.placed.map((V) => et(V, q)), F.headerSource = j.source;
3629
3630
  }
3630
- const Y = St(g, "footer", O, _);
3631
- if (Y) {
3632
- const j = i === "footer", Q = be(Y.blocks, B, I, G, y.length, h, j), V = _t(g, Q.height);
3633
- F.footer = Q.placed.map((q) => Ze(q, V)), F.footerSource = Y.source;
3631
+ const X = pt(g, "footer", b, _);
3632
+ if (X) {
3633
+ const K = i === "footer", Q = Ie(X.blocks, B, I, G, y.length, h, K), q = zt(g, Q.height);
3634
+ F.footer = Q.placed.map((V) => et(V, q)), F.footerSource = X.source;
3634
3635
  }
3635
3636
  }
3636
3637
  }
@@ -3641,67 +3642,67 @@ function Cs(e, t, n, i) {
3641
3642
  marginPx: e.section.marginPx
3642
3643
  };
3643
3644
  }
3644
- function ks(e, t) {
3645
+ function Ds(e, t) {
3645
3646
  switch (t) {
3646
3647
  case "roman":
3647
- return Ce(e, "lowerRoman");
3648
+ return ke(e, "lowerRoman");
3648
3649
  case "Roman":
3649
- return Ce(e, "upperRoman");
3650
+ return ke(e, "upperRoman");
3650
3651
  case "alpha":
3651
- return Ce(e, "lowerLetter");
3652
+ return ke(e, "lowerLetter");
3652
3653
  case "Alpha":
3653
- return Ce(e, "upperLetter");
3654
+ return ke(e, "upperLetter");
3654
3655
  default:
3655
3656
  return String(e);
3656
3657
  }
3657
3658
  }
3658
- function Ds(e, t, n) {
3659
- return e.replace(/\{page(?::(roman|Roman|alpha|Alpha))?\}/g, (i, x) => ks(t, x)).replace(/\{pages\}/g, String(n)).replace(/\{date\}/g, () => (/* @__PURE__ */ new Date()).toLocaleDateString()).replace(/\{time\}/g, () => (/* @__PURE__ */ new Date()).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }));
3660
- }
3661
3659
  function Ls(e, t, n) {
3662
- const i = (x) => x.runs.some((s) => s.text.includes("{")) ? {
3663
- ...x,
3664
- id: `${x.id}@p${t}`,
3660
+ return e.replace(/\{page(?::(roman|Roman|alpha|Alpha))?\}/g, (i, r) => Ds(t, r)).replace(/\{pages\}/g, String(n)).replace(/\{date\}/g, () => (/* @__PURE__ */ new Date()).toLocaleDateString()).replace(/\{time\}/g, () => (/* @__PURE__ */ new Date()).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }));
3661
+ }
3662
+ function Os(e, t, n) {
3663
+ const i = (r) => r.runs.some((s) => s.text.includes("{")) ? {
3664
+ ...r,
3665
+ id: `${r.id}@p${t}`,
3665
3666
  // per-page identity keeps the band prepare-cache honest
3666
- runs: x.runs.map((s) => ({ ...s, text: Ds(s.text, t, n) }))
3667
- } : x;
3667
+ runs: r.runs.map((s) => ({ ...s, text: Ls(s.text, t, n) }))
3668
+ } : r;
3668
3669
  return e.kind === "paragraph" ? i(e) : e.kind === "table" ? {
3669
3670
  ...e,
3670
- rows: e.rows.map((x) => ({
3671
- cells: x.cells.map((s) => ({
3671
+ rows: e.rows.map((r) => ({
3672
+ cells: r.cells.map((s) => ({
3672
3673
  ...s,
3673
3674
  blocks: s.blocks.map((l) => l.kind === "paragraph" ? i(l) : l)
3674
3675
  }))
3675
3676
  }))
3676
3677
  } : e;
3677
3678
  }
3678
- function be(e, t, n, i, x, s, l) {
3679
- const f = (c, a) => sn(c, a, s), o = [];
3680
- let r = 0;
3679
+ function Ie(e, t, n, i, r, s, l) {
3680
+ const u = (c, a) => xn(c, a, s), o = [];
3681
+ let x = 0;
3681
3682
  for (const c of e) {
3682
- const a = l ? c : Ls(c, i, x);
3683
+ const a = l ? c : Os(c, i, r);
3683
3684
  if (a.kind === "paragraph") {
3684
- r += a.style.spaceBeforePx;
3685
- const u = f(a, t);
3686
- o.push({ blockId: a.id, x: n + a.style.indentLeftPx, y: r, firstLineIndex: 0, lines: u }), r += ut(u) + a.style.spaceAfterPx;
3685
+ x += a.style.spaceBeforePx;
3686
+ const f = u(a, t);
3687
+ o.push({ blockId: a.id, x: n + a.style.indentLeftPx, y: x, firstLineIndex: 0, lines: f }), x += ft(f) + a.style.spaceAfterPx;
3687
3688
  } else if (a.kind === "image") {
3688
- const u = t - a.widthPx, d = n + (a.align === "center" ? u / 2 : a.align === "right" ? u : 0);
3689
+ const f = t - a.widthPx, d = n + (a.align === "center" ? f / 2 : a.align === "right" ? f : 0);
3689
3690
  o.push({
3690
3691
  blockId: a.id,
3691
3692
  x: d,
3692
- y: r,
3693
+ y: x,
3693
3694
  firstLineIndex: 0,
3694
3695
  lines: [],
3695
3696
  image: { src: a.src, width: a.widthPx, height: a.heightPx }
3696
- }), r += a.heightPx;
3697
+ }), x += a.heightPx;
3697
3698
  } else {
3698
- const u = at(a, t, f, zt);
3699
- o.push(ft(a, u.rows, u.colWidths, n, r, t, 0, zt)), r += u.height;
3699
+ const f = ut(a, t, u, jt);
3700
+ o.push(ht(a, f.rows, f.colWidths, n, x, t, 0, jt)), x += f.height;
3700
3701
  }
3701
3702
  }
3702
- return { placed: o, height: r };
3703
+ return { placed: o, height: x };
3703
3704
  }
3704
- function Ze(e, t) {
3705
+ function et(e, t) {
3705
3706
  const n = { ...e, y: e.y + t };
3706
3707
  return e.table && (n.table = {
3707
3708
  ...e.table,
@@ -3709,85 +3710,85 @@ function Ze(e, t) {
3709
3710
  rows: e.table.rows.map((i) => ({
3710
3711
  ...i,
3711
3712
  y: i.y + t,
3712
- cells: i.cells.map((x) => ({
3713
- ...x,
3714
- y: x.y + t,
3715
- blocks: x.blocks.map((s) => Ze(s, t))
3713
+ cells: i.cells.map((r) => ({
3714
+ ...r,
3715
+ y: r.y + t,
3716
+ blocks: r.blocks.map((s) => et(s, t))
3716
3717
  }))
3717
3718
  }))
3718
3719
  }), n;
3719
3720
  }
3720
- const Me = 12, Os = { top: 0, right: 7.2, bottom: 0, left: 7.2 }, rn = (e) => e.margin ?? Os, ke = 4, zt = { indentOf: () => 0, markers: /* @__PURE__ */ new Map() };
3721
- function at(e, t, n, i) {
3722
- const s = fs(e).map((c) => c * t), l = s.length, f = new Array(l).fill(0), o = e.rows.map((c) => {
3721
+ const Ce = 12, bs = { top: 0, right: 7.2, bottom: 0, left: 7.2 }, ln = (e) => e.margin ?? bs, De = 4, jt = { indentOf: () => 0, markers: /* @__PURE__ */ new Map() };
3722
+ function ut(e, t, n, i) {
3723
+ const s = hs(e).map((c) => c * t), l = s.length, u = new Array(l).fill(0), o = e.rows.map((c) => {
3723
3724
  let a = 0;
3724
- const u = c.cells.map((d) => {
3725
- for (; a < l && f[a] > 0; ) a++;
3726
- const S = Math.max(1, d.colSpan ?? 1), p = Math.max(1, d.rowSpan ?? 1), A = a;
3725
+ const f = c.cells.map((d) => {
3726
+ for (; a < l && u[a] > 0; ) a++;
3727
+ const S = Math.max(1, d.colSpan ?? 1), A = Math.max(1, d.rowSpan ?? 1), m = a;
3727
3728
  let M = 0;
3728
3729
  for (let N = 0; N < S; N++) M += s[a + N] ?? s[l - 1] ?? 40;
3729
- if (p > 1) for (let N = 0; N < S && a + N < l; N++) f[a + N] = p;
3730
+ if (A > 1) for (let N = 0; N < S && a + N < l; N++) u[a + N] = A;
3730
3731
  a += S;
3731
- const v = rn(d), L = Math.max(8, M - v.left - v.right);
3732
+ const v = ln(d), L = Math.max(8, M - v.left - v.right);
3732
3733
  let w = 0;
3733
3734
  const R = d.blocks.map((N) => {
3734
3735
  if (N.kind === "paragraph") {
3735
3736
  const E = n(N, Math.max(8, L - i.indentOf(N)));
3736
- return w += N.style.spaceBeforePx + ut(E) + N.style.spaceAfterPx, { kind: "para", block: N, lines: E };
3737
+ return w += N.style.spaceBeforePx + ft(E) + N.style.spaceAfterPx, { kind: "para", block: N, lines: E };
3737
3738
  }
3738
3739
  if (N.kind === "image") {
3739
3740
  const E = Math.min(1, L / Math.max(1, N.widthPx)), T = N.widthPx * E, P = N.heightPx * E;
3740
- return w += P + ke, { kind: "image", block: N, width: T, height: P };
3741
+ return w += P + De, { kind: "image", block: N, width: T, height: P };
3741
3742
  }
3742
- const D = at(N, L, n, i);
3743
- return w += D.height + ke, { kind: "table", block: N, ...D };
3743
+ const D = ut(N, L, n, i);
3744
+ return w += D.height + De, { kind: "table", block: N, ...D };
3744
3745
  });
3745
- return { cell: d, items: R, height: w + v.top + v.bottom, width: M, colStart: A, rowSpan: p };
3746
+ return { cell: d, items: R, height: w + v.top + v.bottom, width: M, colStart: m, rowSpan: A };
3746
3747
  });
3747
- for (let d = 0; d < l; d++) f[d] > 0 && f[d]--;
3748
- return { cells: u, height: 0 };
3749
- }), r = o.map((c) => Math.max(0, ...c.cells.filter((a) => a.rowSpan === 1).map((a) => a.height)));
3748
+ for (let d = 0; d < l; d++) u[d] > 0 && u[d]--;
3749
+ return { cells: f, height: 0 };
3750
+ }), x = o.map((c) => Math.max(0, ...c.cells.filter((a) => a.rowSpan === 1).map((a) => a.height)));
3750
3751
  return o.forEach((c, a) => {
3751
- for (const u of c.cells) {
3752
- if (u.rowSpan <= 1) continue;
3753
- const d = Math.min(o.length - 1, a + u.rowSpan - 1);
3752
+ for (const f of c.cells) {
3753
+ if (f.rowSpan <= 1) continue;
3754
+ const d = Math.min(o.length - 1, a + f.rowSpan - 1);
3754
3755
  let S = 0;
3755
- for (let p = a; p <= d; p++) S += r[p];
3756
- u.height > S && (r[d] += u.height - S);
3756
+ for (let A = a; A <= d; A++) S += x[A];
3757
+ f.height > S && (x[d] += f.height - S);
3757
3758
  }
3758
- }), o.forEach((c, a) => c.height = r[a]), { rows: o, colWidths: s, height: r.reduce((c, a) => c + a, 0) };
3759
+ }), o.forEach((c, a) => c.height = x[a]), { rows: o, colWidths: s, height: x.reduce((c, a) => c + a, 0) };
3759
3760
  }
3760
- function ut(e) {
3761
+ function ft(e) {
3761
3762
  let t = 0;
3762
3763
  for (const n of e) t += n.height;
3763
3764
  return t;
3764
3765
  }
3765
- function ft(e, t, n, i, x, s, l, f) {
3766
+ function ht(e, t, n, i, r, s, l, u) {
3766
3767
  const o = [0];
3767
- for (const u of n) o.push(o[o.length - 1] + u);
3768
- const r = [x];
3769
- for (const u of t) r.push(r[r.length - 1] + u.height);
3768
+ for (const f of n) o.push(o[o.length - 1] + f);
3769
+ const x = [r];
3770
+ for (const f of t) x.push(x[x.length - 1] + f.height);
3770
3771
  const c = [];
3771
- for (let u = 0; u < t.length; u++) {
3772
- const d = t[u], S = r[u], p = [];
3773
- for (const A of d.cells) {
3774
- const M = i + (o[A.colStart] ?? o[o.length - 1]), v = Math.min(t.length - 1, u + A.rowSpan - 1), L = r[v + 1] - S, w = [], R = rn(A.cell), N = A.width - R.left - R.right;
3772
+ for (let f = 0; f < t.length; f++) {
3773
+ const d = t[f], S = x[f], A = [];
3774
+ for (const m of d.cells) {
3775
+ const M = i + (o[m.colStart] ?? o[o.length - 1]), v = Math.min(t.length - 1, f + m.rowSpan - 1), L = x[v + 1] - S, w = [], R = ln(m.cell), N = m.width - R.left - R.right;
3775
3776
  let D = S + R.top;
3776
- for (const E of A.items)
3777
+ for (const E of m.items)
3777
3778
  if (E.kind === "para") {
3778
3779
  D += E.block.style.spaceBeforePx;
3779
- const T = M + R.left + E.block.style.indentLeftPx + f.indentOf(E.block), P = {
3780
+ const T = M + R.left + E.block.style.indentLeftPx + u.indentOf(E.block), P = {
3780
3781
  blockId: E.block.id,
3781
3782
  x: T,
3782
3783
  y: D,
3783
3784
  firstLineIndex: 0,
3784
3785
  lines: E.lines
3785
3786
  // line.y is already block-relative; coords stay consistent
3786
- }, W = f.markers.get(E.block.id);
3787
- W && (P.marker = { text: W.text, style: W.style, x: Math.max(M + 1, T - W.hangingPx) }), w.push(P), D += ut(E.lines) + E.block.style.spaceAfterPx;
3787
+ }, W = u.markers.get(E.block.id);
3788
+ W && (P.marker = { text: W.text, style: W.style, x: Math.max(M + 1, T - W.hangingPx) }), w.push(P), D += ft(E.lines) + E.block.style.spaceAfterPx;
3788
3789
  } else if (E.kind === "image") {
3789
3790
  const T = L - R.top - R.bottom;
3790
- if (A.items.length === 1 && T > E.height + 8) {
3791
+ if (m.items.length === 1 && T > E.height + 8) {
3791
3792
  const P = Math.max(N / E.block.widthPx, T / E.block.heightPx), W = E.block.widthPx * P, H = E.block.heightPx * P, z = M + R.left, C = S + R.top;
3792
3793
  w.push({
3793
3794
  blockId: E.block.id,
@@ -3796,7 +3797,7 @@ function ft(e, t, n, i, x, s, l, f) {
3796
3797
  firstLineIndex: 0,
3797
3798
  lines: [],
3798
3799
  image: { src: E.block.src, width: W, height: H, clip: { x: z, y: C, width: N, height: T } }
3799
- }), D += E.height + ke;
3800
+ }), D += E.height + De;
3800
3801
  } else {
3801
3802
  const P = N - E.width, W = M + R.left + (E.block.align === "center" ? P / 2 : E.block.align === "right" ? P : 0);
3802
3803
  w.push({
@@ -3806,35 +3807,35 @@ function ft(e, t, n, i, x, s, l, f) {
3806
3807
  firstLineIndex: 0,
3807
3808
  lines: [],
3808
3809
  image: { src: E.block.src, width: E.width, height: E.height }
3809
- }), D += E.height + ke;
3810
+ }), D += E.height + De;
3810
3811
  }
3811
3812
  } else
3812
- w.push(ft(E.block, E.rows, E.colWidths, M + R.left, D, N, 0, f)), D += E.height + ke;
3813
- p.push({
3813
+ w.push(ht(E.block, E.rows, E.colWidths, M + R.left, D, N, 0, u)), D += E.height + De;
3814
+ A.push({
3814
3815
  x: M,
3815
3816
  y: S,
3816
- width: A.width,
3817
+ width: m.width,
3817
3818
  height: L,
3818
3819
  blocks: w,
3819
- ...A.cell.shading !== void 0 ? { shading: A.cell.shading } : {},
3820
- ...A.cell.borders !== void 0 ? { borders: A.cell.borders } : {}
3820
+ ...m.cell.shading !== void 0 ? { shading: m.cell.shading } : {},
3821
+ ...m.cell.borders !== void 0 ? { borders: m.cell.borders } : {}
3821
3822
  });
3822
3823
  }
3823
- c.push({ y: S, height: d.height, cells: p });
3824
+ c.push({ y: S, height: d.height, cells: A });
3824
3825
  }
3825
- const a = t.reduce((u, d) => u + d.height, 0);
3826
+ const a = t.reduce((f, d) => f + d.height, 0);
3826
3827
  return {
3827
3828
  blockId: e.id,
3828
3829
  x: i,
3829
- y: x,
3830
+ y: r,
3830
3831
  firstLineIndex: l,
3831
3832
  // for tables this is the chunk's first ROW index
3832
3833
  lines: [],
3833
- table: { x: i, y: x, width: s, height: a, rows: c, colWidths: n }
3834
+ table: { x: i, y: r, width: s, height: a, rows: c, colWidths: n }
3834
3835
  };
3835
3836
  }
3836
3837
  export {
3837
- Is as createLayoutEngine,
3838
- Bs as effectiveSection,
3839
- Ms as resolveSections
3838
+ ys as createLayoutEngine,
3839
+ Ms as effectiveSection,
3840
+ Cs as resolveSections
3840
3841
  };