@forevka/wordcanvas 0.7.1 → 0.7.3

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.
Files changed (64) hide show
  1. package/dist-lib/assets/{worker-D8rUOKfg.js → worker-CqU4Popa.js} +10903 -10736
  2. package/dist-lib/assets/worker-Cw5cYW5z.js +2418 -0
  3. package/dist-lib/blockFactory-DDCRWDnA.js +91 -0
  4. package/dist-lib/browser-BUrsjziD.js +612 -0
  5. package/dist-lib/builder.js +13 -13
  6. package/dist-lib/editorApp-CB_ZArIF.js +9566 -0
  7. package/dist-lib/export.js +4507 -4456
  8. package/dist-lib/generate-toc.js +7 -7
  9. package/dist-lib/import.js +2 -2
  10. package/dist-lib/lists-DpmgbDyt.js +110 -0
  11. package/dist-lib/measure.js +2 -2
  12. package/dist-lib/{measureHost-CMiJKdlk.js → measureHost-BlukHGwx.js} +1 -1
  13. package/dist-lib/metrics-bvGO8KDK.js +96 -0
  14. package/dist-lib/paintStyle-vT6jtWbH.js +74 -0
  15. package/dist-lib/pipeline-UryP-u7Z.js +1850 -0
  16. package/dist-lib/recalc-docx.js +2 -2
  17. package/dist-lib/recalcToc-BfXlXZik.js +3985 -0
  18. package/dist-lib/styleProps-DhqDEfvc.js +149 -0
  19. package/dist-lib/stylesheet-LTBEGkvG.js +146 -0
  20. package/dist-lib/toc-D09f4PrI.js +939 -0
  21. package/dist-lib/{webmcp-6WxRNKCc.js → webmcp-K6UZgQJ0.js} +60 -68
  22. package/dist-lib/wordcanvas-DBx2ana_.js +734 -0
  23. package/dist-lib/wordcanvas.js +4 -2
  24. package/dist-node/{chunk-CDN6WU2P.js → chunk-373K2XRY.js} +40 -22
  25. package/dist-node/chunk-373K2XRY.js.map +7 -0
  26. package/dist-node/{chunk-22JHAERT.js → chunk-3PUV3BG6.js} +235 -39
  27. package/dist-node/chunk-3PUV3BG6.js.map +7 -0
  28. package/dist-node/{chunk-4ICCHZX4.js → chunk-5RX3IHWE.js} +39 -3
  29. package/dist-node/chunk-5RX3IHWE.js.map +7 -0
  30. package/dist-node/{chunk-4PDVRJF6.js → chunk-EMY2P524.js} +32 -2
  31. package/dist-node/chunk-EMY2P524.js.map +7 -0
  32. package/dist-node/{chunk-BRAPV465.js → chunk-HWQKGDS2.js} +2 -2
  33. package/dist-node/{chunk-6AJJMHKY.js → chunk-KJV7GJ3H.js} +1 -1
  34. package/dist-node/chunk-KJV7GJ3H.js.map +7 -0
  35. package/dist-node/{chunk-RNB336F3.js → chunk-ZLLSXOO2.js} +92 -14
  36. package/dist-node/{chunk-RNB336F3.js.map → chunk-ZLLSXOO2.js.map} +2 -2
  37. package/dist-node/{engine-5FGDJD2H.js → engine-LLA6PCS5.js} +4 -4
  38. package/dist-node/export.js +89 -24
  39. package/dist-node/export.js.map +2 -2
  40. package/dist-node/generate-toc.js +6 -6
  41. package/dist-node/import.js +3 -3
  42. package/dist-node/measure.js +2 -2
  43. package/dist-node/recalc-docx.js +4 -4
  44. package/package.json +1 -1
  45. package/types/model.d.ts +46 -0
  46. package/types/wordcanvas.d.ts +493 -1
  47. package/dist-lib/assets/worker-wXuuyshQ.js +0 -2258
  48. package/dist-lib/blockFactory-CUI4Rqiq.js +0 -186
  49. package/dist-lib/browser-DkKxreJM.js +0 -1305
  50. package/dist-lib/editorApp-DLXMmtu5.js +0 -8023
  51. package/dist-lib/lists-Sc5I40JO.js +0 -110
  52. package/dist-lib/metrics-CkAo4zh8.js +0 -143
  53. package/dist-lib/pipeline-CbxmCE84.js +0 -1705
  54. package/dist-lib/recalcToc-g1hFKSNs.js +0 -3935
  55. package/dist-lib/styleProps-Db5pEkG8.js +0 -127
  56. package/dist-lib/toc-B6VpkJge.js +0 -213
  57. package/dist-lib/wordcanvas-CFqpDK0k.js +0 -125
  58. package/dist-node/chunk-22JHAERT.js.map +0 -7
  59. package/dist-node/chunk-4ICCHZX4.js.map +0 -7
  60. package/dist-node/chunk-4PDVRJF6.js.map +0 -7
  61. package/dist-node/chunk-6AJJMHKY.js.map +0 -7
  62. package/dist-node/chunk-CDN6WU2P.js.map +0 -7
  63. /package/dist-node/{chunk-BRAPV465.js.map → chunk-HWQKGDS2.js.map} +0 -0
  64. /package/dist-node/{engine-5FGDJD2H.js.map → engine-LLA6PCS5.js.map} +0 -0
@@ -0,0 +1,3985 @@
1
+ import { C as kn, N as Dn, t as bn, s as Ln } from "./toc-D09f4PrI.js";
2
+ import { e as On, f as ye } from "./lists-DpmgbDyt.js";
3
+ import { a as ae, m as Pe, f as We } from "./metrics-bvGO8KDK.js";
4
+ const yn = [
5
+ "BN",
6
+ "BN",
7
+ "BN",
8
+ "BN",
9
+ "BN",
10
+ "BN",
11
+ "BN",
12
+ "BN",
13
+ "BN",
14
+ "S",
15
+ "B",
16
+ "S",
17
+ "WS",
18
+ "B",
19
+ "BN",
20
+ "BN",
21
+ "BN",
22
+ "BN",
23
+ "BN",
24
+ "BN",
25
+ "BN",
26
+ "BN",
27
+ "BN",
28
+ "BN",
29
+ "BN",
30
+ "BN",
31
+ "BN",
32
+ "BN",
33
+ "B",
34
+ "B",
35
+ "B",
36
+ "S",
37
+ "WS",
38
+ "ON",
39
+ "ON",
40
+ "ET",
41
+ "ET",
42
+ "ET",
43
+ "ON",
44
+ "ON",
45
+ "ON",
46
+ "ON",
47
+ "ON",
48
+ "ES",
49
+ "CS",
50
+ "ES",
51
+ "CS",
52
+ "CS",
53
+ "EN",
54
+ "EN",
55
+ "EN",
56
+ "EN",
57
+ "EN",
58
+ "EN",
59
+ "EN",
60
+ "EN",
61
+ "EN",
62
+ "EN",
63
+ "CS",
64
+ "ON",
65
+ "ON",
66
+ "ON",
67
+ "ON",
68
+ "ON",
69
+ "ON",
70
+ "L",
71
+ "L",
72
+ "L",
73
+ "L",
74
+ "L",
75
+ "L",
76
+ "L",
77
+ "L",
78
+ "L",
79
+ "L",
80
+ "L",
81
+ "L",
82
+ "L",
83
+ "L",
84
+ "L",
85
+ "L",
86
+ "L",
87
+ "L",
88
+ "L",
89
+ "L",
90
+ "L",
91
+ "L",
92
+ "L",
93
+ "L",
94
+ "L",
95
+ "L",
96
+ "ON",
97
+ "ON",
98
+ "ON",
99
+ "ON",
100
+ "ON",
101
+ "ON",
102
+ "L",
103
+ "L",
104
+ "L",
105
+ "L",
106
+ "L",
107
+ "L",
108
+ "L",
109
+ "L",
110
+ "L",
111
+ "L",
112
+ "L",
113
+ "L",
114
+ "L",
115
+ "L",
116
+ "L",
117
+ "L",
118
+ "L",
119
+ "L",
120
+ "L",
121
+ "L",
122
+ "L",
123
+ "L",
124
+ "L",
125
+ "L",
126
+ "L",
127
+ "L",
128
+ "ON",
129
+ "ON",
130
+ "ON",
131
+ "ON",
132
+ "BN",
133
+ "BN",
134
+ "BN",
135
+ "BN",
136
+ "BN",
137
+ "BN",
138
+ "B",
139
+ "BN",
140
+ "BN",
141
+ "BN",
142
+ "BN",
143
+ "BN",
144
+ "BN",
145
+ "BN",
146
+ "BN",
147
+ "BN",
148
+ "BN",
149
+ "BN",
150
+ "BN",
151
+ "BN",
152
+ "BN",
153
+ "BN",
154
+ "BN",
155
+ "BN",
156
+ "BN",
157
+ "BN",
158
+ "BN",
159
+ "BN",
160
+ "BN",
161
+ "BN",
162
+ "BN",
163
+ "BN",
164
+ "BN",
165
+ "CS",
166
+ "ON",
167
+ "ET",
168
+ "ET",
169
+ "ET",
170
+ "ET",
171
+ "ON",
172
+ "ON",
173
+ "ON",
174
+ "ON",
175
+ "L",
176
+ "ON",
177
+ "ON",
178
+ "BN",
179
+ "ON",
180
+ "ON",
181
+ "ET",
182
+ "ET",
183
+ "EN",
184
+ "EN",
185
+ "ON",
186
+ "L",
187
+ "ON",
188
+ "ON",
189
+ "ON",
190
+ "EN",
191
+ "L",
192
+ "ON",
193
+ "ON",
194
+ "ON",
195
+ "ON",
196
+ "ON",
197
+ "L",
198
+ "L",
199
+ "L",
200
+ "L",
201
+ "L",
202
+ "L",
203
+ "L",
204
+ "L",
205
+ "L",
206
+ "L",
207
+ "L",
208
+ "L",
209
+ "L",
210
+ "L",
211
+ "L",
212
+ "L",
213
+ "L",
214
+ "L",
215
+ "L",
216
+ "L",
217
+ "L",
218
+ "L",
219
+ "L",
220
+ "ON",
221
+ "L",
222
+ "L",
223
+ "L",
224
+ "L",
225
+ "L",
226
+ "L",
227
+ "L",
228
+ "L",
229
+ "L",
230
+ "L",
231
+ "L",
232
+ "L",
233
+ "L",
234
+ "L",
235
+ "L",
236
+ "L",
237
+ "L",
238
+ "L",
239
+ "L",
240
+ "L",
241
+ "L",
242
+ "L",
243
+ "L",
244
+ "L",
245
+ "L",
246
+ "L",
247
+ "L",
248
+ "L",
249
+ "L",
250
+ "L",
251
+ "L",
252
+ "ON",
253
+ "L",
254
+ "L",
255
+ "L",
256
+ "L",
257
+ "L",
258
+ "L",
259
+ "L",
260
+ "L"
261
+ ], Mt = [
262
+ [697, 698, "ON"],
263
+ [706, 719, "ON"],
264
+ [722, 735, "ON"],
265
+ [741, 749, "ON"],
266
+ [751, 767, "ON"],
267
+ [768, 879, "NSM"],
268
+ [884, 885, "ON"],
269
+ [894, 894, "ON"],
270
+ [900, 901, "ON"],
271
+ [903, 903, "ON"],
272
+ [1014, 1014, "ON"],
273
+ [1155, 1161, "NSM"],
274
+ [1418, 1418, "ON"],
275
+ [1421, 1422, "ON"],
276
+ [1423, 1423, "ET"],
277
+ [1424, 1424, "R"],
278
+ [1425, 1469, "NSM"],
279
+ [1470, 1470, "R"],
280
+ [1471, 1471, "NSM"],
281
+ [1472, 1472, "R"],
282
+ [1473, 1474, "NSM"],
283
+ [1475, 1475, "R"],
284
+ [1476, 1477, "NSM"],
285
+ [1478, 1478, "R"],
286
+ [1479, 1479, "NSM"],
287
+ [1480, 1535, "R"],
288
+ [1536, 1541, "AN"],
289
+ [1542, 1543, "ON"],
290
+ [1544, 1544, "AL"],
291
+ [1545, 1546, "ET"],
292
+ [1547, 1547, "AL"],
293
+ [1548, 1548, "CS"],
294
+ [1549, 1549, "AL"],
295
+ [1550, 1551, "ON"],
296
+ [1552, 1562, "NSM"],
297
+ [1563, 1610, "AL"],
298
+ [1611, 1631, "NSM"],
299
+ [1632, 1641, "AN"],
300
+ [1642, 1642, "ET"],
301
+ [1643, 1644, "AN"],
302
+ [1645, 1647, "AL"],
303
+ [1648, 1648, "NSM"],
304
+ [1649, 1749, "AL"],
305
+ [1750, 1756, "NSM"],
306
+ [1757, 1757, "AN"],
307
+ [1758, 1758, "ON"],
308
+ [1759, 1764, "NSM"],
309
+ [1765, 1766, "AL"],
310
+ [1767, 1768, "NSM"],
311
+ [1769, 1769, "ON"],
312
+ [1770, 1773, "NSM"],
313
+ [1774, 1775, "AL"],
314
+ [1776, 1785, "EN"],
315
+ [1786, 1808, "AL"],
316
+ [1809, 1809, "NSM"],
317
+ [1810, 1839, "AL"],
318
+ [1840, 1866, "NSM"],
319
+ [1867, 1957, "AL"],
320
+ [1958, 1968, "NSM"],
321
+ [1969, 1983, "AL"],
322
+ [1984, 2026, "R"],
323
+ [2027, 2035, "NSM"],
324
+ [2036, 2037, "R"],
325
+ [2038, 2041, "ON"],
326
+ [2042, 2044, "R"],
327
+ [2045, 2045, "NSM"],
328
+ [2046, 2069, "R"],
329
+ [2070, 2073, "NSM"],
330
+ [2074, 2074, "R"],
331
+ [2075, 2083, "NSM"],
332
+ [2084, 2084, "R"],
333
+ [2085, 2087, "NSM"],
334
+ [2088, 2088, "R"],
335
+ [2089, 2093, "NSM"],
336
+ [2094, 2136, "R"],
337
+ [2137, 2139, "NSM"],
338
+ [2140, 2143, "R"],
339
+ [2144, 2191, "AL"],
340
+ [2192, 2193, "AN"],
341
+ [2194, 2198, "AL"],
342
+ [2199, 2207, "NSM"],
343
+ [2208, 2249, "AL"],
344
+ [2250, 2273, "NSM"],
345
+ [2274, 2274, "AN"],
346
+ [2275, 2306, "NSM"],
347
+ [2362, 2362, "NSM"],
348
+ [2364, 2364, "NSM"],
349
+ [2369, 2376, "NSM"],
350
+ [2381, 2381, "NSM"],
351
+ [2385, 2391, "NSM"],
352
+ [2402, 2403, "NSM"],
353
+ [2433, 2433, "NSM"],
354
+ [2492, 2492, "NSM"],
355
+ [2497, 2500, "NSM"],
356
+ [2509, 2509, "NSM"],
357
+ [2530, 2531, "NSM"],
358
+ [2546, 2547, "ET"],
359
+ [2555, 2555, "ET"],
360
+ [2558, 2558, "NSM"],
361
+ [2561, 2562, "NSM"],
362
+ [2620, 2620, "NSM"],
363
+ [2625, 2626, "NSM"],
364
+ [2631, 2632, "NSM"],
365
+ [2635, 2637, "NSM"],
366
+ [2641, 2641, "NSM"],
367
+ [2672, 2673, "NSM"],
368
+ [2677, 2677, "NSM"],
369
+ [2689, 2690, "NSM"],
370
+ [2748, 2748, "NSM"],
371
+ [2753, 2757, "NSM"],
372
+ [2759, 2760, "NSM"],
373
+ [2765, 2765, "NSM"],
374
+ [2786, 2787, "NSM"],
375
+ [2801, 2801, "ET"],
376
+ [2810, 2815, "NSM"],
377
+ [2817, 2817, "NSM"],
378
+ [2876, 2876, "NSM"],
379
+ [2879, 2879, "NSM"],
380
+ [2881, 2884, "NSM"],
381
+ [2893, 2893, "NSM"],
382
+ [2901, 2902, "NSM"],
383
+ [2914, 2915, "NSM"],
384
+ [2946, 2946, "NSM"],
385
+ [3008, 3008, "NSM"],
386
+ [3021, 3021, "NSM"],
387
+ [3059, 3064, "ON"],
388
+ [3065, 3065, "ET"],
389
+ [3066, 3066, "ON"],
390
+ [3072, 3072, "NSM"],
391
+ [3076, 3076, "NSM"],
392
+ [3132, 3132, "NSM"],
393
+ [3134, 3136, "NSM"],
394
+ [3142, 3144, "NSM"],
395
+ [3146, 3149, "NSM"],
396
+ [3157, 3158, "NSM"],
397
+ [3170, 3171, "NSM"],
398
+ [3192, 3198, "ON"],
399
+ [3201, 3201, "NSM"],
400
+ [3260, 3260, "NSM"],
401
+ [3276, 3277, "NSM"],
402
+ [3298, 3299, "NSM"],
403
+ [3328, 3329, "NSM"],
404
+ [3387, 3388, "NSM"],
405
+ [3393, 3396, "NSM"],
406
+ [3405, 3405, "NSM"],
407
+ [3426, 3427, "NSM"],
408
+ [3457, 3457, "NSM"],
409
+ [3530, 3530, "NSM"],
410
+ [3538, 3540, "NSM"],
411
+ [3542, 3542, "NSM"],
412
+ [3633, 3633, "NSM"],
413
+ [3636, 3642, "NSM"],
414
+ [3647, 3647, "ET"],
415
+ [3655, 3662, "NSM"],
416
+ [3761, 3761, "NSM"],
417
+ [3764, 3772, "NSM"],
418
+ [3784, 3790, "NSM"],
419
+ [3864, 3865, "NSM"],
420
+ [3893, 3893, "NSM"],
421
+ [3895, 3895, "NSM"],
422
+ [3897, 3897, "NSM"],
423
+ [3898, 3901, "ON"],
424
+ [3953, 3966, "NSM"],
425
+ [3968, 3972, "NSM"],
426
+ [3974, 3975, "NSM"],
427
+ [3981, 3991, "NSM"],
428
+ [3993, 4028, "NSM"],
429
+ [4038, 4038, "NSM"],
430
+ [4141, 4144, "NSM"],
431
+ [4146, 4151, "NSM"],
432
+ [4153, 4154, "NSM"],
433
+ [4157, 4158, "NSM"],
434
+ [4184, 4185, "NSM"],
435
+ [4190, 4192, "NSM"],
436
+ [4209, 4212, "NSM"],
437
+ [4226, 4226, "NSM"],
438
+ [4229, 4230, "NSM"],
439
+ [4237, 4237, "NSM"],
440
+ [4253, 4253, "NSM"],
441
+ [4957, 4959, "NSM"],
442
+ [5008, 5017, "ON"],
443
+ [5120, 5120, "ON"],
444
+ [5760, 5760, "WS"],
445
+ [5787, 5788, "ON"],
446
+ [5906, 5908, "NSM"],
447
+ [5938, 5939, "NSM"],
448
+ [5970, 5971, "NSM"],
449
+ [6002, 6003, "NSM"],
450
+ [6068, 6069, "NSM"],
451
+ [6071, 6077, "NSM"],
452
+ [6086, 6086, "NSM"],
453
+ [6089, 6099, "NSM"],
454
+ [6107, 6107, "ET"],
455
+ [6109, 6109, "NSM"],
456
+ [6128, 6137, "ON"],
457
+ [6144, 6154, "ON"],
458
+ [6155, 6157, "NSM"],
459
+ [6158, 6158, "BN"],
460
+ [6159, 6159, "NSM"],
461
+ [6277, 6278, "NSM"],
462
+ [6313, 6313, "NSM"],
463
+ [6432, 6434, "NSM"],
464
+ [6439, 6440, "NSM"],
465
+ [6450, 6450, "NSM"],
466
+ [6457, 6459, "NSM"],
467
+ [6464, 6464, "ON"],
468
+ [6468, 6469, "ON"],
469
+ [6622, 6655, "ON"],
470
+ [6679, 6680, "NSM"],
471
+ [6683, 6683, "NSM"],
472
+ [6742, 6742, "NSM"],
473
+ [6744, 6750, "NSM"],
474
+ [6752, 6752, "NSM"],
475
+ [6754, 6754, "NSM"],
476
+ [6757, 6764, "NSM"],
477
+ [6771, 6780, "NSM"],
478
+ [6783, 6783, "NSM"],
479
+ [6832, 6877, "NSM"],
480
+ [6880, 6891, "NSM"],
481
+ [6912, 6915, "NSM"],
482
+ [6964, 6964, "NSM"],
483
+ [6966, 6970, "NSM"],
484
+ [6972, 6972, "NSM"],
485
+ [6978, 6978, "NSM"],
486
+ [7019, 7027, "NSM"],
487
+ [7040, 7041, "NSM"],
488
+ [7074, 7077, "NSM"],
489
+ [7080, 7081, "NSM"],
490
+ [7083, 7085, "NSM"],
491
+ [7142, 7142, "NSM"],
492
+ [7144, 7145, "NSM"],
493
+ [7149, 7149, "NSM"],
494
+ [7151, 7153, "NSM"],
495
+ [7212, 7219, "NSM"],
496
+ [7222, 7223, "NSM"],
497
+ [7376, 7378, "NSM"],
498
+ [7380, 7392, "NSM"],
499
+ [7394, 7400, "NSM"],
500
+ [7405, 7405, "NSM"],
501
+ [7412, 7412, "NSM"],
502
+ [7416, 7417, "NSM"],
503
+ [7616, 7679, "NSM"],
504
+ [8125, 8125, "ON"],
505
+ [8127, 8129, "ON"],
506
+ [8141, 8143, "ON"],
507
+ [8157, 8159, "ON"],
508
+ [8173, 8175, "ON"],
509
+ [8189, 8190, "ON"],
510
+ [8192, 8202, "WS"],
511
+ [8203, 8205, "BN"],
512
+ [8207, 8207, "R"],
513
+ [8208, 8231, "ON"],
514
+ [8232, 8232, "WS"],
515
+ [8233, 8233, "B"],
516
+ [8234, 8238, "BN"],
517
+ [8239, 8239, "CS"],
518
+ [8240, 8244, "ET"],
519
+ [8245, 8259, "ON"],
520
+ [8260, 8260, "CS"],
521
+ [8261, 8286, "ON"],
522
+ [8287, 8287, "WS"],
523
+ [8288, 8303, "BN"],
524
+ [8304, 8304, "EN"],
525
+ [8308, 8313, "EN"],
526
+ [8314, 8315, "ES"],
527
+ [8316, 8318, "ON"],
528
+ [8320, 8329, "EN"],
529
+ [8330, 8331, "ES"],
530
+ [8332, 8334, "ON"],
531
+ [8352, 8399, "ET"],
532
+ [8400, 8432, "NSM"],
533
+ [8448, 8449, "ON"],
534
+ [8451, 8454, "ON"],
535
+ [8456, 8457, "ON"],
536
+ [8468, 8468, "ON"],
537
+ [8470, 8472, "ON"],
538
+ [8478, 8483, "ON"],
539
+ [8485, 8485, "ON"],
540
+ [8487, 8487, "ON"],
541
+ [8489, 8489, "ON"],
542
+ [8494, 8494, "ET"],
543
+ [8506, 8507, "ON"],
544
+ [8512, 8516, "ON"],
545
+ [8522, 8525, "ON"],
546
+ [8528, 8543, "ON"],
547
+ [8585, 8587, "ON"],
548
+ [8592, 8721, "ON"],
549
+ [8722, 8722, "ES"],
550
+ [8723, 8723, "ET"],
551
+ [8724, 9013, "ON"],
552
+ [9083, 9108, "ON"],
553
+ [9110, 9257, "ON"],
554
+ [9280, 9290, "ON"],
555
+ [9312, 9351, "ON"],
556
+ [9352, 9371, "EN"],
557
+ [9450, 9899, "ON"],
558
+ [9901, 10239, "ON"],
559
+ [10496, 11123, "ON"],
560
+ [11126, 11263, "ON"],
561
+ [11493, 11498, "ON"],
562
+ [11503, 11505, "NSM"],
563
+ [11513, 11519, "ON"],
564
+ [11647, 11647, "NSM"],
565
+ [11744, 11775, "NSM"],
566
+ [11776, 11869, "ON"],
567
+ [11904, 11929, "ON"],
568
+ [11931, 12019, "ON"],
569
+ [12032, 12245, "ON"],
570
+ [12272, 12287, "ON"],
571
+ [12288, 12288, "WS"],
572
+ [12289, 12292, "ON"],
573
+ [12296, 12320, "ON"],
574
+ [12330, 12333, "NSM"],
575
+ [12336, 12336, "ON"],
576
+ [12342, 12343, "ON"],
577
+ [12349, 12351, "ON"],
578
+ [12441, 12442, "NSM"],
579
+ [12443, 12444, "ON"],
580
+ [12448, 12448, "ON"],
581
+ [12539, 12539, "ON"],
582
+ [12736, 12773, "ON"],
583
+ [12783, 12783, "ON"],
584
+ [12829, 12830, "ON"],
585
+ [12880, 12895, "ON"],
586
+ [12924, 12926, "ON"],
587
+ [12977, 12991, "ON"],
588
+ [13004, 13007, "ON"],
589
+ [13175, 13178, "ON"],
590
+ [13278, 13279, "ON"],
591
+ [13311, 13311, "ON"],
592
+ [19904, 19967, "ON"],
593
+ [42128, 42182, "ON"],
594
+ [42509, 42511, "ON"],
595
+ [42607, 42610, "NSM"],
596
+ [42611, 42611, "ON"],
597
+ [42612, 42621, "NSM"],
598
+ [42622, 42623, "ON"],
599
+ [42654, 42655, "NSM"],
600
+ [42736, 42737, "NSM"],
601
+ [42752, 42785, "ON"],
602
+ [42888, 42888, "ON"],
603
+ [43010, 43010, "NSM"],
604
+ [43014, 43014, "NSM"],
605
+ [43019, 43019, "NSM"],
606
+ [43045, 43046, "NSM"],
607
+ [43048, 43051, "ON"],
608
+ [43052, 43052, "NSM"],
609
+ [43064, 43065, "ET"],
610
+ [43124, 43127, "ON"],
611
+ [43204, 43205, "NSM"],
612
+ [43232, 43249, "NSM"],
613
+ [43263, 43263, "NSM"],
614
+ [43302, 43309, "NSM"],
615
+ [43335, 43345, "NSM"],
616
+ [43392, 43394, "NSM"],
617
+ [43443, 43443, "NSM"],
618
+ [43446, 43449, "NSM"],
619
+ [43452, 43453, "NSM"],
620
+ [43493, 43493, "NSM"],
621
+ [43561, 43566, "NSM"],
622
+ [43569, 43570, "NSM"],
623
+ [43573, 43574, "NSM"],
624
+ [43587, 43587, "NSM"],
625
+ [43596, 43596, "NSM"],
626
+ [43644, 43644, "NSM"],
627
+ [43696, 43696, "NSM"],
628
+ [43698, 43700, "NSM"],
629
+ [43703, 43704, "NSM"],
630
+ [43710, 43711, "NSM"],
631
+ [43713, 43713, "NSM"],
632
+ [43756, 43757, "NSM"],
633
+ [43766, 43766, "NSM"],
634
+ [43882, 43883, "ON"],
635
+ [44005, 44005, "NSM"],
636
+ [44008, 44008, "NSM"],
637
+ [44013, 44013, "NSM"],
638
+ [64285, 64285, "R"],
639
+ [64286, 64286, "NSM"],
640
+ [64287, 64296, "R"],
641
+ [64297, 64297, "ES"],
642
+ [64298, 64335, "R"],
643
+ [64336, 64450, "AL"],
644
+ [64451, 64466, "ON"],
645
+ [64467, 64829, "AL"],
646
+ [64830, 64847, "ON"],
647
+ [64848, 64911, "AL"],
648
+ [64912, 64913, "ON"],
649
+ [64914, 64967, "AL"],
650
+ [64968, 64975, "ON"],
651
+ [64976, 65007, "BN"],
652
+ [65008, 65020, "AL"],
653
+ [65021, 65023, "ON"],
654
+ [65024, 65039, "NSM"],
655
+ [65040, 65049, "ON"],
656
+ [65056, 65071, "NSM"],
657
+ [65072, 65103, "ON"],
658
+ [65104, 65104, "CS"],
659
+ [65105, 65105, "ON"],
660
+ [65106, 65106, "CS"],
661
+ [65108, 65108, "ON"],
662
+ [65109, 65109, "CS"],
663
+ [65110, 65118, "ON"],
664
+ [65119, 65119, "ET"],
665
+ [65120, 65121, "ON"],
666
+ [65122, 65123, "ES"],
667
+ [65124, 65126, "ON"],
668
+ [65128, 65128, "ON"],
669
+ [65129, 65130, "ET"],
670
+ [65131, 65131, "ON"],
671
+ [65136, 65278, "AL"],
672
+ [65279, 65279, "BN"],
673
+ [65281, 65282, "ON"],
674
+ [65283, 65285, "ET"],
675
+ [65286, 65290, "ON"],
676
+ [65291, 65291, "ES"],
677
+ [65292, 65292, "CS"],
678
+ [65293, 65293, "ES"],
679
+ [65294, 65295, "CS"],
680
+ [65296, 65305, "EN"],
681
+ [65306, 65306, "CS"],
682
+ [65307, 65312, "ON"],
683
+ [65339, 65344, "ON"],
684
+ [65371, 65381, "ON"],
685
+ [65504, 65505, "ET"],
686
+ [65506, 65508, "ON"],
687
+ [65509, 65510, "ET"],
688
+ [65512, 65518, "ON"],
689
+ [65520, 65528, "BN"],
690
+ [65529, 65533, "ON"],
691
+ [65534, 65535, "BN"],
692
+ [65793, 65793, "ON"],
693
+ [65856, 65932, "ON"],
694
+ [65936, 65948, "ON"],
695
+ [65952, 65952, "ON"],
696
+ [66045, 66045, "NSM"],
697
+ [66272, 66272, "NSM"],
698
+ [66273, 66299, "EN"],
699
+ [66422, 66426, "NSM"],
700
+ [67584, 67870, "R"],
701
+ [67871, 67871, "ON"],
702
+ [67872, 68096, "R"],
703
+ [68097, 68099, "NSM"],
704
+ [68100, 68100, "R"],
705
+ [68101, 68102, "NSM"],
706
+ [68103, 68107, "R"],
707
+ [68108, 68111, "NSM"],
708
+ [68112, 68151, "R"],
709
+ [68152, 68154, "NSM"],
710
+ [68155, 68158, "R"],
711
+ [68159, 68159, "NSM"],
712
+ [68160, 68324, "R"],
713
+ [68325, 68326, "NSM"],
714
+ [68327, 68408, "R"],
715
+ [68409, 68415, "ON"],
716
+ [68416, 68863, "R"],
717
+ [68864, 68899, "AL"],
718
+ [68900, 68903, "NSM"],
719
+ [68904, 68911, "AL"],
720
+ [68912, 68921, "AN"],
721
+ [68922, 68927, "AL"],
722
+ [68928, 68937, "AN"],
723
+ [68938, 68968, "R"],
724
+ [68969, 68973, "NSM"],
725
+ [68974, 68974, "ON"],
726
+ [68975, 69215, "R"],
727
+ [69216, 69246, "AN"],
728
+ [69247, 69290, "R"],
729
+ [69291, 69292, "NSM"],
730
+ [69293, 69311, "R"],
731
+ [69312, 69327, "AL"],
732
+ [69328, 69336, "ON"],
733
+ [69337, 69369, "AL"],
734
+ [69370, 69375, "NSM"],
735
+ [69376, 69423, "R"],
736
+ [69424, 69445, "AL"],
737
+ [69446, 69456, "NSM"],
738
+ [69457, 69487, "AL"],
739
+ [69488, 69505, "R"],
740
+ [69506, 69509, "NSM"],
741
+ [69510, 69631, "R"],
742
+ [69633, 69633, "NSM"],
743
+ [69688, 69702, "NSM"],
744
+ [69714, 69733, "ON"],
745
+ [69744, 69744, "NSM"],
746
+ [69747, 69748, "NSM"],
747
+ [69759, 69761, "NSM"],
748
+ [69811, 69814, "NSM"],
749
+ [69817, 69818, "NSM"],
750
+ [69826, 69826, "NSM"],
751
+ [69888, 69890, "NSM"],
752
+ [69927, 69931, "NSM"],
753
+ [69933, 69940, "NSM"],
754
+ [70003, 70003, "NSM"],
755
+ [70016, 70017, "NSM"],
756
+ [70070, 70078, "NSM"],
757
+ [70089, 70092, "NSM"],
758
+ [70095, 70095, "NSM"],
759
+ [70191, 70193, "NSM"],
760
+ [70196, 70196, "NSM"],
761
+ [70198, 70199, "NSM"],
762
+ [70206, 70206, "NSM"],
763
+ [70209, 70209, "NSM"],
764
+ [70367, 70367, "NSM"],
765
+ [70371, 70378, "NSM"],
766
+ [70400, 70401, "NSM"],
767
+ [70459, 70460, "NSM"],
768
+ [70464, 70464, "NSM"],
769
+ [70502, 70508, "NSM"],
770
+ [70512, 70516, "NSM"],
771
+ [70587, 70592, "NSM"],
772
+ [70606, 70606, "NSM"],
773
+ [70608, 70608, "NSM"],
774
+ [70610, 70610, "NSM"],
775
+ [70625, 70626, "NSM"],
776
+ [70712, 70719, "NSM"],
777
+ [70722, 70724, "NSM"],
778
+ [70726, 70726, "NSM"],
779
+ [70750, 70750, "NSM"],
780
+ [70835, 70840, "NSM"],
781
+ [70842, 70842, "NSM"],
782
+ [70847, 70848, "NSM"],
783
+ [70850, 70851, "NSM"],
784
+ [71090, 71093, "NSM"],
785
+ [71100, 71101, "NSM"],
786
+ [71103, 71104, "NSM"],
787
+ [71132, 71133, "NSM"],
788
+ [71219, 71226, "NSM"],
789
+ [71229, 71229, "NSM"],
790
+ [71231, 71232, "NSM"],
791
+ [71264, 71276, "ON"],
792
+ [71339, 71339, "NSM"],
793
+ [71341, 71341, "NSM"],
794
+ [71344, 71349, "NSM"],
795
+ [71351, 71351, "NSM"],
796
+ [71453, 71453, "NSM"],
797
+ [71455, 71455, "NSM"],
798
+ [71458, 71461, "NSM"],
799
+ [71463, 71467, "NSM"],
800
+ [71727, 71735, "NSM"],
801
+ [71737, 71738, "NSM"],
802
+ [71995, 71996, "NSM"],
803
+ [71998, 71998, "NSM"],
804
+ [72003, 72003, "NSM"],
805
+ [72148, 72151, "NSM"],
806
+ [72154, 72155, "NSM"],
807
+ [72160, 72160, "NSM"],
808
+ [72193, 72198, "NSM"],
809
+ [72201, 72202, "NSM"],
810
+ [72243, 72248, "NSM"],
811
+ [72251, 72254, "NSM"],
812
+ [72263, 72263, "NSM"],
813
+ [72273, 72278, "NSM"],
814
+ [72281, 72283, "NSM"],
815
+ [72330, 72342, "NSM"],
816
+ [72344, 72345, "NSM"],
817
+ [72544, 72544, "NSM"],
818
+ [72546, 72548, "NSM"],
819
+ [72550, 72550, "NSM"],
820
+ [72752, 72758, "NSM"],
821
+ [72760, 72765, "NSM"],
822
+ [72850, 72871, "NSM"],
823
+ [72874, 72880, "NSM"],
824
+ [72882, 72883, "NSM"],
825
+ [72885, 72886, "NSM"],
826
+ [73009, 73014, "NSM"],
827
+ [73018, 73018, "NSM"],
828
+ [73020, 73021, "NSM"],
829
+ [73023, 73029, "NSM"],
830
+ [73031, 73031, "NSM"],
831
+ [73104, 73105, "NSM"],
832
+ [73109, 73109, "NSM"],
833
+ [73111, 73111, "NSM"],
834
+ [73459, 73460, "NSM"],
835
+ [73472, 73473, "NSM"],
836
+ [73526, 73530, "NSM"],
837
+ [73536, 73536, "NSM"],
838
+ [73538, 73538, "NSM"],
839
+ [73562, 73562, "NSM"],
840
+ [73685, 73692, "ON"],
841
+ [73693, 73696, "ET"],
842
+ [73697, 73713, "ON"],
843
+ [78912, 78912, "NSM"],
844
+ [78919, 78933, "NSM"],
845
+ [90398, 90409, "NSM"],
846
+ [90413, 90415, "NSM"],
847
+ [92912, 92916, "NSM"],
848
+ [92976, 92982, "NSM"],
849
+ [94031, 94031, "NSM"],
850
+ [94095, 94098, "NSM"],
851
+ [94178, 94178, "ON"],
852
+ [94180, 94180, "NSM"],
853
+ [113821, 113822, "NSM"],
854
+ [113824, 113827, "BN"],
855
+ [117760, 117973, "ON"],
856
+ [118e3, 118009, "EN"],
857
+ [118010, 118012, "ON"],
858
+ [118016, 118451, "ON"],
859
+ [118458, 118480, "ON"],
860
+ [118496, 118512, "ON"],
861
+ [118528, 118573, "NSM"],
862
+ [118576, 118598, "NSM"],
863
+ [119143, 119145, "NSM"],
864
+ [119155, 119162, "BN"],
865
+ [119163, 119170, "NSM"],
866
+ [119173, 119179, "NSM"],
867
+ [119210, 119213, "NSM"],
868
+ [119273, 119274, "ON"],
869
+ [119296, 119361, "ON"],
870
+ [119362, 119364, "NSM"],
871
+ [119365, 119365, "ON"],
872
+ [119552, 119638, "ON"],
873
+ [120513, 120513, "ON"],
874
+ [120539, 120539, "ON"],
875
+ [120571, 120571, "ON"],
876
+ [120597, 120597, "ON"],
877
+ [120629, 120629, "ON"],
878
+ [120655, 120655, "ON"],
879
+ [120687, 120687, "ON"],
880
+ [120713, 120713, "ON"],
881
+ [120745, 120745, "ON"],
882
+ [120771, 120771, "ON"],
883
+ [120782, 120831, "EN"],
884
+ [121344, 121398, "NSM"],
885
+ [121403, 121452, "NSM"],
886
+ [121461, 121461, "NSM"],
887
+ [121476, 121476, "NSM"],
888
+ [121499, 121503, "NSM"],
889
+ [121505, 121519, "NSM"],
890
+ [122880, 122886, "NSM"],
891
+ [122888, 122904, "NSM"],
892
+ [122907, 122913, "NSM"],
893
+ [122915, 122916, "NSM"],
894
+ [122918, 122922, "NSM"],
895
+ [123023, 123023, "NSM"],
896
+ [123184, 123190, "NSM"],
897
+ [123566, 123566, "NSM"],
898
+ [123628, 123631, "NSM"],
899
+ [123647, 123647, "ET"],
900
+ [124140, 124143, "NSM"],
901
+ [124398, 124399, "NSM"],
902
+ [124643, 124643, "NSM"],
903
+ [124646, 124646, "NSM"],
904
+ [124654, 124655, "NSM"],
905
+ [124661, 124661, "NSM"],
906
+ [124928, 125135, "R"],
907
+ [125136, 125142, "NSM"],
908
+ [125143, 125251, "R"],
909
+ [125252, 125258, "NSM"],
910
+ [125259, 126063, "R"],
911
+ [126064, 126143, "AL"],
912
+ [126144, 126207, "R"],
913
+ [126208, 126287, "AL"],
914
+ [126288, 126463, "R"],
915
+ [126464, 126703, "AL"],
916
+ [126704, 126705, "ON"],
917
+ [126706, 126719, "AL"],
918
+ [126720, 126975, "R"],
919
+ [126976, 127019, "ON"],
920
+ [127024, 127123, "ON"],
921
+ [127136, 127150, "ON"],
922
+ [127153, 127167, "ON"],
923
+ [127169, 127183, "ON"],
924
+ [127185, 127221, "ON"],
925
+ [127232, 127242, "EN"],
926
+ [127243, 127247, "ON"],
927
+ [127279, 127279, "ON"],
928
+ [127338, 127343, "ON"],
929
+ [127405, 127405, "ON"],
930
+ [127584, 127589, "ON"],
931
+ [127744, 128728, "ON"],
932
+ [128732, 128748, "ON"],
933
+ [128752, 128764, "ON"],
934
+ [128768, 128985, "ON"],
935
+ [128992, 129003, "ON"],
936
+ [129008, 129008, "ON"],
937
+ [129024, 129035, "ON"],
938
+ [129040, 129095, "ON"],
939
+ [129104, 129113, "ON"],
940
+ [129120, 129159, "ON"],
941
+ [129168, 129197, "ON"],
942
+ [129200, 129211, "ON"],
943
+ [129216, 129217, "ON"],
944
+ [129232, 129240, "ON"],
945
+ [129280, 129623, "ON"],
946
+ [129632, 129645, "ON"],
947
+ [129648, 129660, "ON"],
948
+ [129664, 129674, "ON"],
949
+ [129678, 129734, "ON"],
950
+ [129736, 129736, "ON"],
951
+ [129741, 129756, "ON"],
952
+ [129759, 129770, "ON"],
953
+ [129775, 129784, "ON"],
954
+ [129792, 129938, "ON"],
955
+ [129940, 130031, "ON"],
956
+ [130032, 130041, "EN"],
957
+ [130042, 130042, "ON"],
958
+ [131070, 131071, "BN"],
959
+ [196606, 196607, "BN"],
960
+ [262142, 262143, "BN"],
961
+ [327678, 327679, "BN"],
962
+ [393214, 393215, "BN"],
963
+ [458750, 458751, "BN"],
964
+ [524286, 524287, "BN"],
965
+ [589822, 589823, "BN"],
966
+ [655358, 655359, "BN"],
967
+ [720894, 720895, "BN"],
968
+ [786430, 786431, "BN"],
969
+ [851966, 851967, "BN"],
970
+ [917502, 917759, "BN"],
971
+ [917760, 917999, "NSM"],
972
+ [918e3, 921599, "BN"],
973
+ [983038, 983039, "BN"],
974
+ [1048574, 1048575, "BN"],
975
+ [1114110, 1114111, "BN"]
976
+ ];
977
+ function In(e) {
978
+ if (e <= 255)
979
+ return yn[e];
980
+ let t = 0, n = Mt.length - 1;
981
+ for (; t <= n; ) {
982
+ const x = t + n >> 1, i = Mt[x];
983
+ if (e < i[0]) {
984
+ n = x - 1;
985
+ continue;
986
+ }
987
+ if (e > i[1]) {
988
+ t = x + 1;
989
+ continue;
990
+ }
991
+ return i[2];
992
+ }
993
+ return "L";
994
+ }
995
+ function wn(e) {
996
+ const t = e.length;
997
+ if (t === 0)
998
+ return null;
999
+ const n = new Array(t);
1000
+ let x = !1;
1001
+ for (let r = 0; r < t; ) {
1002
+ const l = e.charCodeAt(r);
1003
+ let f = l, h = 1;
1004
+ if (l >= 55296 && l <= 56319 && r + 1 < t) {
1005
+ const A = e.charCodeAt(r + 1);
1006
+ A >= 56320 && A <= 57343 && (f = (l - 55296 << 10) + (A - 56320) + 65536, h = 2);
1007
+ }
1008
+ const g = In(f);
1009
+ (g === "R" || g === "AL" || g === "AN") && (x = !0);
1010
+ for (let A = 0; A < h; A++)
1011
+ n[r + A] = g;
1012
+ r += h;
1013
+ }
1014
+ if (!x)
1015
+ return null;
1016
+ let i = 0;
1017
+ for (let r = 0; r < t; r++) {
1018
+ const l = n[r];
1019
+ if (l === "L") {
1020
+ i = 0;
1021
+ break;
1022
+ }
1023
+ if (l === "R" || l === "AL") {
1024
+ i = 1;
1025
+ break;
1026
+ }
1027
+ }
1028
+ const s = new Int8Array(t);
1029
+ for (let r = 0; r < t; r++)
1030
+ s[r] = i;
1031
+ const o = i & 1 ? "R" : "L", a = o;
1032
+ let c = a;
1033
+ for (let r = 0; r < t; r++)
1034
+ n[r] === "NSM" ? n[r] = c : c = n[r];
1035
+ c = a;
1036
+ for (let r = 0; r < t; r++) {
1037
+ const l = n[r];
1038
+ l === "EN" ? n[r] = c === "AL" ? "AN" : "EN" : (l === "R" || l === "L" || l === "AL") && (c = l);
1039
+ }
1040
+ for (let r = 0; r < t; r++)
1041
+ n[r] === "AL" && (n[r] = "R");
1042
+ for (let r = 1; r < t - 1; r++)
1043
+ 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]);
1044
+ for (let r = 0; r < t; r++) {
1045
+ if (n[r] !== "EN")
1046
+ continue;
1047
+ let l;
1048
+ for (l = r - 1; l >= 0 && n[l] === "ET"; l--)
1049
+ n[l] = "EN";
1050
+ for (l = r + 1; l < t && n[l] === "ET"; l++)
1051
+ n[l] = "EN";
1052
+ }
1053
+ for (let r = 0; r < t; r++) {
1054
+ const l = n[r];
1055
+ (l === "WS" || l === "ES" || l === "ET" || l === "CS") && (n[r] = "ON");
1056
+ }
1057
+ c = a;
1058
+ for (let r = 0; r < t; r++) {
1059
+ const l = n[r];
1060
+ l === "EN" ? n[r] = c === "L" ? "L" : "EN" : (l === "R" || l === "L") && (c = l);
1061
+ }
1062
+ for (let r = 0; r < t; r++) {
1063
+ if (n[r] !== "ON")
1064
+ continue;
1065
+ let l = r + 1;
1066
+ for (; l < t && n[l] === "ON"; )
1067
+ l++;
1068
+ const f = r > 0 ? n[r - 1] : a, h = l < t ? n[l] : a, g = f !== "L" ? "R" : "L";
1069
+ if (g === (h !== "L" ? "R" : "L"))
1070
+ for (let m = r; m < l; m++)
1071
+ n[m] = g;
1072
+ r = l - 1;
1073
+ }
1074
+ for (let r = 0; r < t; r++)
1075
+ n[r] === "ON" && (n[r] = o);
1076
+ for (let r = 0; r < t; r++) {
1077
+ const l = n[r];
1078
+ (s[r] & 1) === 0 ? l === "R" ? s[r]++ : (l === "AN" || l === "EN") && (s[r] += 2) : (l === "L" || l === "AN" || l === "EN") && s[r]++;
1079
+ }
1080
+ return s;
1081
+ }
1082
+ function Pn(e, t) {
1083
+ const n = wn(e);
1084
+ if (n === null)
1085
+ return null;
1086
+ const x = new Int8Array(t.length);
1087
+ for (let i = 0; i < t.length; i++)
1088
+ x[i] = n[t[i]];
1089
+ return x;
1090
+ }
1091
+ const Wn = /[ \t\n\r\f]+/g, vn = /[\t\n\r\f]| {2,}|^ | $/;
1092
+ function Rn(e) {
1093
+ const t = e ?? "normal";
1094
+ return t === "pre-wrap" ? { mode: t, preserveOrdinarySpaces: !0, preserveHardBreaks: !0 } : { mode: t, preserveOrdinarySpaces: !1, preserveHardBreaks: !1 };
1095
+ }
1096
+ function Tn(e) {
1097
+ if (!vn.test(e))
1098
+ return e;
1099
+ let t = e.replace(Wn, " ");
1100
+ return t.charCodeAt(0) === 32 && (t = t.slice(1)), t.length > 0 && t.charCodeAt(t.length - 1) === 32 && (t = t.slice(0, -1)), t;
1101
+ }
1102
+ function Gn(e) {
1103
+ return /[\r\f]/.test(e) ? e.replace(/\r\n/g, `
1104
+ `).replace(/[\r\f]/g, `
1105
+ `) : e;
1106
+ }
1107
+ let Ue = null, Hn;
1108
+ function _n() {
1109
+ return Ue === null && (Ue = new Intl.Segmenter(Hn, { granularity: "word" })), Ue;
1110
+ }
1111
+ const zn = /\p{Script=Arabic}/u, ge = /\p{M}/u, st = /\p{Nd}/u;
1112
+ function Ct(e) {
1113
+ return zn.test(e);
1114
+ }
1115
+ function kt(e) {
1116
+ 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;
1117
+ }
1118
+ function xe(e) {
1119
+ for (let t = 0; t < e.length; t++) {
1120
+ const n = e.charCodeAt(t);
1121
+ if (!(n < 12288)) {
1122
+ if (n >= 55296 && n <= 56319 && t + 1 < e.length) {
1123
+ const x = e.charCodeAt(t + 1);
1124
+ if (x >= 56320 && x <= 57343) {
1125
+ const i = (n - 55296 << 10) + (x - 56320) + 65536;
1126
+ if (kt(i))
1127
+ return !0;
1128
+ t++;
1129
+ continue;
1130
+ }
1131
+ }
1132
+ if (kt(n))
1133
+ return !0;
1134
+ }
1135
+ }
1136
+ return !1;
1137
+ }
1138
+ function jn(e) {
1139
+ const t = ke(e);
1140
+ return t !== null && (it.has(t) || Fe.has(t));
1141
+ }
1142
+ const Kn = /* @__PURE__ */ new Set([
1143
+ " ",
1144
+ " ",
1145
+ "⁠",
1146
+ "\uFEFF"
1147
+ ]), Un = /* @__PURE__ */ new Set([
1148
+ "-",
1149
+ "‐",
1150
+ "–",
1151
+ "—"
1152
+ ]);
1153
+ function Jn(e) {
1154
+ const t = ke(e);
1155
+ return t !== null && Kn.has(t);
1156
+ }
1157
+ function Qn(e) {
1158
+ const t = ke(e);
1159
+ return t !== null && Un.has(t);
1160
+ }
1161
+ function Jt(e, t) {
1162
+ return Jn(e) ? !1 : t ? !(jn(e) || Qn(e)) : !0;
1163
+ }
1164
+ const it = /* @__PURE__ */ new Set([
1165
+ ",",
1166
+ ".",
1167
+ "!",
1168
+ ":",
1169
+ ";",
1170
+ "?",
1171
+ "、",
1172
+ "。",
1173
+ "・",
1174
+ ")",
1175
+ "〕",
1176
+ "〉",
1177
+ "》",
1178
+ "」",
1179
+ "』",
1180
+ "】",
1181
+ "〗",
1182
+ "〙",
1183
+ "〛",
1184
+ "ー",
1185
+ "々",
1186
+ "〻",
1187
+ "ゝ",
1188
+ "ゞ",
1189
+ "ヽ",
1190
+ "ヾ"
1191
+ ]), Ge = /* @__PURE__ */ new Set([
1192
+ '"',
1193
+ "(",
1194
+ "[",
1195
+ "{",
1196
+ "¡",
1197
+ "¿",
1198
+ "“",
1199
+ "‘",
1200
+ "‚",
1201
+ "„",
1202
+ "«",
1203
+ "‹",
1204
+ "⸘",
1205
+ "(",
1206
+ "〔",
1207
+ "〈",
1208
+ "《",
1209
+ "「",
1210
+ "『",
1211
+ "【",
1212
+ "〖",
1213
+ "〘",
1214
+ "〚"
1215
+ ]), rt = /* @__PURE__ */ new Set([
1216
+ "'",
1217
+ "’"
1218
+ ]), Fe = /* @__PURE__ */ new Set([
1219
+ ".",
1220
+ ",",
1221
+ "!",
1222
+ "?",
1223
+ ":",
1224
+ ";",
1225
+ "،",
1226
+ "؛",
1227
+ "؟",
1228
+ "।",
1229
+ "॥",
1230
+ "၊",
1231
+ "။",
1232
+ "၌",
1233
+ "၍",
1234
+ "၏",
1235
+ ")",
1236
+ "]",
1237
+ "}",
1238
+ "%",
1239
+ '"',
1240
+ "”",
1241
+ "’",
1242
+ "»",
1243
+ "›",
1244
+ "…"
1245
+ ]), Yn = /* @__PURE__ */ new Set([
1246
+ ":",
1247
+ ".",
1248
+ "،",
1249
+ "؛"
1250
+ ]), $n = /* @__PURE__ */ new Set([
1251
+ "၏"
1252
+ ]), Xn = /* @__PURE__ */ new Set([
1253
+ "”",
1254
+ "’",
1255
+ "»",
1256
+ "›",
1257
+ "」",
1258
+ "』",
1259
+ "】",
1260
+ "》",
1261
+ "〉",
1262
+ "〕",
1263
+ ")"
1264
+ ]);
1265
+ function Vn(e) {
1266
+ if (xt(e))
1267
+ return !0;
1268
+ let t = !1;
1269
+ for (const n of e) {
1270
+ if (Fe.has(n) || _e(n)) {
1271
+ t = !0;
1272
+ continue;
1273
+ }
1274
+ if (!(t && ge.test(n)))
1275
+ return !1;
1276
+ }
1277
+ return t;
1278
+ }
1279
+ function qn(e) {
1280
+ for (const t of e)
1281
+ if (!it.has(t) && !Fe.has(t))
1282
+ return !1;
1283
+ return e.length > 0;
1284
+ }
1285
+ function Zn(e) {
1286
+ if (xt(e))
1287
+ return !0;
1288
+ for (const t of e)
1289
+ if (!Ge.has(t) && !rt.has(t) && !ge.test(t) && !_e(t))
1290
+ return !1;
1291
+ return e.length > 0;
1292
+ }
1293
+ function xt(e) {
1294
+ let t = !1;
1295
+ for (const n of e)
1296
+ if (!(n === "\\" || ge.test(n))) {
1297
+ if (Ge.has(n) || Fe.has(n) || rt.has(n)) {
1298
+ t = !0;
1299
+ continue;
1300
+ }
1301
+ return !1;
1302
+ }
1303
+ return t;
1304
+ }
1305
+ function He(e, t) {
1306
+ const n = t - 1;
1307
+ if (n <= 0)
1308
+ return Math.max(n, 0);
1309
+ const x = e.charCodeAt(n);
1310
+ if (x < 56320 || x > 57343)
1311
+ return n;
1312
+ const i = n - 1;
1313
+ if (i < 0)
1314
+ return n;
1315
+ const s = e.charCodeAt(i);
1316
+ return s >= 55296 && s <= 56319 ? i : n;
1317
+ }
1318
+ function ke(e) {
1319
+ if (e.length === 0)
1320
+ return null;
1321
+ const t = He(e, e.length);
1322
+ return e.slice(t);
1323
+ }
1324
+ function e0(e) {
1325
+ for (const t of e)
1326
+ if (!ge.test(t))
1327
+ return t;
1328
+ return null;
1329
+ }
1330
+ function t0(e) {
1331
+ for (let t = e.length; t > 0; ) {
1332
+ const n = He(e, t), x = e.slice(n, t);
1333
+ if (!ge.test(x))
1334
+ return x;
1335
+ t = n;
1336
+ }
1337
+ return null;
1338
+ }
1339
+ const n0 = [
1340
+ 36,
1341
+ 37,
1342
+ 43,
1343
+ 43,
1344
+ 92,
1345
+ 92,
1346
+ 162,
1347
+ 165,
1348
+ 176,
1349
+ 177,
1350
+ 1423,
1351
+ 1423,
1352
+ 1545,
1353
+ 1547,
1354
+ 1642,
1355
+ 1642,
1356
+ 2046,
1357
+ 2047,
1358
+ 2546,
1359
+ 2547,
1360
+ 2553,
1361
+ 2555,
1362
+ 2801,
1363
+ 2801,
1364
+ 3065,
1365
+ 3065,
1366
+ 3449,
1367
+ 3449,
1368
+ 3647,
1369
+ 3647,
1370
+ 6107,
1371
+ 6107,
1372
+ 8240,
1373
+ 8247,
1374
+ 8279,
1375
+ 8279,
1376
+ 8352,
1377
+ 8399,
1378
+ 8451,
1379
+ 8451,
1380
+ 8457,
1381
+ 8457,
1382
+ 8470,
1383
+ 8470,
1384
+ 8722,
1385
+ 8723,
1386
+ 43064,
1387
+ 43064,
1388
+ 65020,
1389
+ 65020,
1390
+ 65129,
1391
+ 65130,
1392
+ 65284,
1393
+ 65285,
1394
+ 65504,
1395
+ 65505,
1396
+ 65509,
1397
+ 65510,
1398
+ 73693,
1399
+ 73696,
1400
+ 123647,
1401
+ 123647,
1402
+ 126124,
1403
+ 126124,
1404
+ 126128,
1405
+ 126128
1406
+ ];
1407
+ function s0(e, t) {
1408
+ for (let n = 0; n < t.length; n += 2)
1409
+ if (e >= t[n] && e <= t[n + 1])
1410
+ return !0;
1411
+ return !1;
1412
+ }
1413
+ function _e(e) {
1414
+ const t = e.codePointAt(0);
1415
+ return t !== void 0 && s0(t, n0);
1416
+ }
1417
+ function i0(e) {
1418
+ const t = t0(e);
1419
+ return t !== null && _e(t);
1420
+ }
1421
+ function r0(e) {
1422
+ const t = e0(e);
1423
+ return t !== null && st.test(t);
1424
+ }
1425
+ function x0(e) {
1426
+ const t = Array.from(e);
1427
+ let n = t.length;
1428
+ for (; n > 0; ) {
1429
+ const x = t[n - 1];
1430
+ if (ge.test(x)) {
1431
+ n--;
1432
+ continue;
1433
+ }
1434
+ if (Ge.has(x) || rt.has(x)) {
1435
+ n--;
1436
+ continue;
1437
+ }
1438
+ break;
1439
+ }
1440
+ return n <= 0 || n === t.length ? null : {
1441
+ head: t.slice(0, n).join(""),
1442
+ tail: t.slice(n).join("")
1443
+ };
1444
+ }
1445
+ function o0(e, t, n) {
1446
+ return n === "text" && !t && e.length === 1 && e !== "-" && e !== "—" ? e : null;
1447
+ }
1448
+ function Dt(e, t, n, x) {
1449
+ const i = t[x], s = e[x];
1450
+ if (i == null)
1451
+ return s;
1452
+ const o = n[x];
1453
+ if (s.length === o)
1454
+ return s;
1455
+ const a = i.repeat(o);
1456
+ return e[x] = a, a;
1457
+ }
1458
+ function bt(e, t) {
1459
+ return e && t !== null && Yn.has(t);
1460
+ }
1461
+ function l0(e) {
1462
+ const t = ke(e);
1463
+ return t !== null && $n.has(t);
1464
+ }
1465
+ function c0(e) {
1466
+ if (e.length < 2 || e[0] !== " ")
1467
+ return null;
1468
+ const t = e.slice(1);
1469
+ return /^\p{M}+$/u.test(t) ? { space: " ", marks: t } : null;
1470
+ }
1471
+ function Ve(e) {
1472
+ let t = e.length;
1473
+ for (; t > 0; ) {
1474
+ const n = He(e, t), x = e.slice(n, t);
1475
+ if (Xn.has(x))
1476
+ return !0;
1477
+ if (!Fe.has(x))
1478
+ return !1;
1479
+ t = n;
1480
+ }
1481
+ return !1;
1482
+ }
1483
+ function a0(e, t) {
1484
+ if (t.preserveOrdinarySpaces || t.preserveHardBreaks) {
1485
+ if (e === " ")
1486
+ return "preserved-space";
1487
+ if (e === " ")
1488
+ return "tab";
1489
+ if (t.preserveHardBreaks && e === `
1490
+ `)
1491
+ return "hard-break";
1492
+ }
1493
+ return e === " " ? "space" : e === " " || e === " " || e === "⁠" || e === "\uFEFF" ? "glue" : e === "​" ? "zero-width-break" : e === "­" ? "soft-hyphen" : "text";
1494
+ }
1495
+ const f0 = /[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;
1496
+ function re(e) {
1497
+ return e.length === 1 ? e[0] : e.join("");
1498
+ }
1499
+ function u0(e, t) {
1500
+ const n = [];
1501
+ for (let x = e.length - 1; x >= 0; x--)
1502
+ n.push(e[x]);
1503
+ return n.push(t), re(n);
1504
+ }
1505
+ function h0(e, t, n, x) {
1506
+ if (!f0.test(e))
1507
+ return [{ text: e, isWordLike: t, kind: "text", start: n }];
1508
+ const i = [];
1509
+ let s = null, o = [], a = n, c = !1, r = 0;
1510
+ for (const l of e) {
1511
+ const f = a0(l, x), h = f === "text" && t;
1512
+ if (s !== null && f === s && h === c) {
1513
+ o.push(l), r += l.length;
1514
+ continue;
1515
+ }
1516
+ s !== null && i.push({
1517
+ text: re(o),
1518
+ isWordLike: c,
1519
+ kind: s,
1520
+ start: a
1521
+ }), s = f, o = [l], a = n + r, c = h, r += l.length;
1522
+ }
1523
+ return s !== null && i.push({
1524
+ text: re(o),
1525
+ isWordLike: c,
1526
+ kind: s,
1527
+ start: a
1528
+ }), i;
1529
+ }
1530
+ function qe(e) {
1531
+ return e === "space" || e === "preserved-space" || e === "zero-width-break" || e === "hard-break";
1532
+ }
1533
+ const d0 = /^[A-Za-z][A-Za-z0-9+.-]*:$/;
1534
+ function F0(e, t) {
1535
+ const n = e.texts[t];
1536
+ return n.startsWith("www.") ? !0 : d0.test(n) && t + 1 < e.len && e.kinds[t + 1] === "text" && e.texts[t + 1] === "//";
1537
+ }
1538
+ function g0(e) {
1539
+ return e.includes("?") && (e.includes("://") || e.startsWith("www."));
1540
+ }
1541
+ function N0(e) {
1542
+ const t = e.texts.slice(), n = e.isWordLike.slice(), x = e.kinds.slice(), i = e.starts.slice();
1543
+ for (let o = 0; o < e.len; o++) {
1544
+ if (x[o] !== "text" || !F0(e, o))
1545
+ continue;
1546
+ const a = [t[o]];
1547
+ let c = o + 1;
1548
+ for (; c < e.len && !qe(x[c]); ) {
1549
+ a.push(t[c]), n[o] = !0;
1550
+ const r = t[c].includes("?");
1551
+ if (x[c] = "text", t[c] = "", c++, r)
1552
+ break;
1553
+ }
1554
+ t[o] = re(a);
1555
+ }
1556
+ let s = 0;
1557
+ for (let o = 0; o < t.length; o++) {
1558
+ const a = t[o];
1559
+ a.length !== 0 && (s !== o && (t[s] = a, n[s] = n[o], x[s] = x[o], i[s] = i[o]), s++);
1560
+ }
1561
+ return t.length = s, n.length = s, x.length = s, i.length = s, {
1562
+ len: s,
1563
+ texts: t,
1564
+ isWordLike: n,
1565
+ kinds: x,
1566
+ starts: i
1567
+ };
1568
+ }
1569
+ function p0(e) {
1570
+ const t = [], n = [], x = [], i = [];
1571
+ for (let s = 0; s < e.len; s++) {
1572
+ const o = e.texts[s];
1573
+ if (t.push(o), n.push(e.isWordLike[s]), x.push(e.kinds[s]), i.push(e.starts[s]), !g0(o))
1574
+ continue;
1575
+ const a = s + 1;
1576
+ if (a >= e.len || qe(e.kinds[a]))
1577
+ continue;
1578
+ const c = [], r = e.starts[a];
1579
+ let l = a;
1580
+ for (; l < e.len && !qe(e.kinds[l]); )
1581
+ c.push(e.texts[l]), l++;
1582
+ c.length > 0 && (t.push(re(c)), n.push(!0), x.push("text"), i.push(r), s = l - 1);
1583
+ }
1584
+ return {
1585
+ len: t.length,
1586
+ texts: t,
1587
+ isWordLike: n,
1588
+ kinds: x,
1589
+ starts: i
1590
+ };
1591
+ }
1592
+ const S0 = /* @__PURE__ */ new Set([
1593
+ ":",
1594
+ "-",
1595
+ "/",
1596
+ "×",
1597
+ ",",
1598
+ ".",
1599
+ "+",
1600
+ "–",
1601
+ "—"
1602
+ ]), m0 = /* @__PURE__ */ new Set([".", ",", ":", ";"]);
1603
+ function Lt(e) {
1604
+ for (let t = e.length; t > 0; ) {
1605
+ const n = He(e, t), x = e.slice(n, t);
1606
+ if (ge.test(x)) {
1607
+ t = n;
1608
+ continue;
1609
+ }
1610
+ return m0.has(x) || _e(x);
1611
+ }
1612
+ return !1;
1613
+ }
1614
+ function A0(e, t) {
1615
+ return t && !xe(e);
1616
+ }
1617
+ function Qt(e) {
1618
+ for (const t of e)
1619
+ if (st.test(t))
1620
+ return !0;
1621
+ return !1;
1622
+ }
1623
+ function ve(e) {
1624
+ if (e.length === 0)
1625
+ return !1;
1626
+ for (const t of e)
1627
+ if (!(st.test(t) || S0.has(t)))
1628
+ return !1;
1629
+ return !0;
1630
+ }
1631
+ function E0(e) {
1632
+ const t = [], n = [], x = [], i = [];
1633
+ for (let s = 0; s < e.len; s++) {
1634
+ const o = e.texts[s], a = e.kinds[s];
1635
+ if (a === "text" && ve(o) && Qt(o)) {
1636
+ const c = [o];
1637
+ let r = s + 1;
1638
+ for (; r < e.len && e.kinds[r] === "text" && ve(e.texts[r]); )
1639
+ c.push(e.texts[r]), r++;
1640
+ t.push(re(c)), n.push(!0), x.push("text"), i.push(e.starts[s]), s = r - 1;
1641
+ continue;
1642
+ }
1643
+ t.push(o), n.push(e.isWordLike[s]), x.push(a), i.push(e.starts[s]);
1644
+ }
1645
+ return {
1646
+ len: t.length,
1647
+ texts: t,
1648
+ isWordLike: n,
1649
+ kinds: x,
1650
+ starts: i
1651
+ };
1652
+ }
1653
+ function B0(e) {
1654
+ const t = [], n = [], x = [], i = [];
1655
+ for (let s = 0; s < e.len; s++) {
1656
+ const o = e.texts[s], a = e.kinds[s], c = e.isWordLike[s];
1657
+ if (a === "text" && Lt(o) && (c || i0(o)) && !xe(o)) {
1658
+ const r = [o];
1659
+ let l = !0, f = s + 1;
1660
+ for (; l && f < e.len && e.kinds[f] === "text" && A0(e.texts[f], e.isWordLike[f]); ) {
1661
+ const h = e.texts[f];
1662
+ r.push(h), l = Lt(h), f++;
1663
+ }
1664
+ t.push(re(r)), n.push(!0), x.push("text"), i.push(e.starts[s]), s = f - 1;
1665
+ continue;
1666
+ }
1667
+ t.push(o), n.push(c), x.push(a), i.push(e.starts[s]);
1668
+ }
1669
+ return {
1670
+ len: t.length,
1671
+ texts: t,
1672
+ isWordLike: n,
1673
+ kinds: x,
1674
+ starts: i
1675
+ };
1676
+ }
1677
+ function M0(e) {
1678
+ const t = [], n = [], x = [], i = [];
1679
+ for (let s = 0; s < e.len; s++) {
1680
+ const o = e.texts[s];
1681
+ if (e.kinds[s] === "text" && o.includes("-")) {
1682
+ const a = o.split("-");
1683
+ let c = a.length > 1;
1684
+ for (let r = 0; r < a.length; r++) {
1685
+ const l = a[r];
1686
+ if (!c)
1687
+ break;
1688
+ (l.length === 0 || !Qt(l) || !ve(l)) && (c = !1);
1689
+ }
1690
+ if (c) {
1691
+ let r = 0;
1692
+ for (let l = 0; l < a.length; l++) {
1693
+ const f = a[l], h = l < a.length - 1 ? `${f}-` : f;
1694
+ t.push(h), n.push(!0), x.push("text"), i.push(e.starts[s] + r), r += h.length;
1695
+ }
1696
+ continue;
1697
+ }
1698
+ }
1699
+ t.push(o), n.push(e.isWordLike[s]), x.push(e.kinds[s]), i.push(e.starts[s]);
1700
+ }
1701
+ return {
1702
+ len: t.length,
1703
+ texts: t,
1704
+ isWordLike: n,
1705
+ kinds: x,
1706
+ starts: i
1707
+ };
1708
+ }
1709
+ function C0(e) {
1710
+ const t = [], n = [], x = [], i = [];
1711
+ let s = 0;
1712
+ for (; s < e.len; ) {
1713
+ const o = [e.texts[s]];
1714
+ let a = e.isWordLike[s], c = e.kinds[s], r = e.starts[s];
1715
+ if (c === "glue") {
1716
+ const l = [o[0]], f = r;
1717
+ for (s++; s < e.len && e.kinds[s] === "glue"; )
1718
+ l.push(e.texts[s]), s++;
1719
+ const h = re(l);
1720
+ if (s < e.len && e.kinds[s] === "text")
1721
+ o[0] = h, o.push(e.texts[s]), a = e.isWordLike[s], c = "text", r = f, s++;
1722
+ else {
1723
+ t.push(h), n.push(!1), x.push("glue"), i.push(f);
1724
+ continue;
1725
+ }
1726
+ } else
1727
+ s++;
1728
+ if (c === "text")
1729
+ for (; s < e.len && e.kinds[s] === "glue"; ) {
1730
+ const l = [];
1731
+ for (; s < e.len && e.kinds[s] === "glue"; )
1732
+ l.push(e.texts[s]), s++;
1733
+ const f = re(l);
1734
+ if (s < e.len && e.kinds[s] === "text") {
1735
+ o.push(f, e.texts[s]), a = a || e.isWordLike[s], s++;
1736
+ continue;
1737
+ }
1738
+ o.push(f);
1739
+ }
1740
+ t.push(re(o)), n.push(a), x.push(c), i.push(r);
1741
+ }
1742
+ return {
1743
+ len: t.length,
1744
+ texts: t,
1745
+ isWordLike: n,
1746
+ kinds: x,
1747
+ starts: i
1748
+ };
1749
+ }
1750
+ function k0(e) {
1751
+ const t = e.texts.slice(), n = e.isWordLike.slice(), x = e.kinds.slice(), i = e.starts.slice();
1752
+ for (let s = 0; s < t.length - 1; s++) {
1753
+ if (x[s] !== "text" || x[s + 1] !== "text" || !xe(t[s]) || !xe(t[s + 1]))
1754
+ continue;
1755
+ const o = x0(t[s]);
1756
+ o !== null && (t[s] = o.head, t[s + 1] = o.tail + t[s + 1], i[s + 1] = i[s] + o.head.length);
1757
+ }
1758
+ return {
1759
+ len: t.length,
1760
+ texts: t,
1761
+ isWordLike: n,
1762
+ kinds: x,
1763
+ starts: i
1764
+ };
1765
+ }
1766
+ function D0(e, t, n) {
1767
+ const x = _n();
1768
+ let i = 0;
1769
+ const s = [], o = [], a = [], c = [], r = [], l = [], f = [], h = [], g = [], A = [], m = [], B = [];
1770
+ for (const N of x.segment(e))
1771
+ for (const D of h0(N.segment, N.isWordLike ?? !1, N.index, n)) {
1772
+ let R = function() {
1773
+ l[S] !== null && (o[S] = [
1774
+ Dt(s, l, f, S)
1775
+ ], l[S] = null), o[S].push(D.text), a[S] = a[S] || D.isWordLike, h[S] = h[S] || G, g[S] = g[S] || w, A[S] = z, m[S] = b, B[S] = bt(g[S], j);
1776
+ };
1777
+ const k = D.kind === "text", T = o0(D.text, D.isWordLike, D.kind), G = xe(D.text), w = Ct(D.text), j = ke(D.text), z = Ve(D.text), b = l0(D.text), S = i - 1;
1778
+ t.carryCJKAfterClosingQuote && k && i > 0 && c[S] === "text" && G && h[S] && A[S] || k && i > 0 && c[S] === "text" && qn(D.text) && h[S] || k && i > 0 && c[S] === "text" && m[S] ? R() : k && i > 0 && c[S] === "text" && D.isWordLike && w && B[S] ? (R(), a[S] = !0) : T !== null && i > 0 && c[S] === "text" && l[S] === T ? f[S] = (f[S] ?? 1) + 1 : k && !D.isWordLike && i > 0 && c[S] === "text" && !h[S] && (Vn(D.text) || D.text === "-" && a[S]) ? R() : (s[i] = D.text, o[i] = [D.text], a[i] = D.isWordLike, c[i] = D.kind, r[i] = D.start, l[i] = T, f[i] = T === null ? 0 : 1, h[i] = G, g[i] = w, A[i] = z, m[i] = b, B[i] = bt(w, j), i++);
1779
+ }
1780
+ for (let N = 0; N < i; N++) {
1781
+ if (l[N] !== null) {
1782
+ s[N] = Dt(s, l, f, N);
1783
+ continue;
1784
+ }
1785
+ s[N] = re(o[N]);
1786
+ }
1787
+ for (let N = 1; N < i; N++)
1788
+ c[N] === "text" && !a[N] && xt(s[N]) && c[N - 1] === "text" && !h[N - 1] && (s[N - 1] += s[N], a[N - 1] = a[N - 1] || a[N], s[N] = "");
1789
+ const C = Array.from({ length: i }, () => null);
1790
+ let v = -1;
1791
+ for (let N = i - 1; N >= 0; N--) {
1792
+ const D = s[N];
1793
+ if (D.length !== 0) {
1794
+ if (c[N] === "text" && !a[N] && v >= 0 && c[v] === "text" && (Zn(D) || D === "-" && r0(s[v]))) {
1795
+ const k = C[v] ?? [];
1796
+ k.push(D), C[v] = k, r[v] = r[N], s[N] = "";
1797
+ continue;
1798
+ }
1799
+ v = N;
1800
+ }
1801
+ }
1802
+ for (let N = 0; N < i; N++) {
1803
+ const D = C[N];
1804
+ D != null && (s[N] = u0(D, s[N]));
1805
+ }
1806
+ let H = 0;
1807
+ for (let N = 0; N < i; N++) {
1808
+ const D = s[N];
1809
+ D.length !== 0 && (H !== N && (s[H] = D, a[H] = a[N], c[H] = c[N], r[H] = r[N]), H++);
1810
+ }
1811
+ s.length = H, a.length = H, c.length = H, r.length = H;
1812
+ const y = C0({
1813
+ len: H,
1814
+ texts: s,
1815
+ isWordLike: a,
1816
+ kinds: c,
1817
+ starts: r
1818
+ }), O = k0(B0(M0(E0(p0(N0(y))))));
1819
+ for (let N = 0; N < O.len - 1; N++) {
1820
+ const D = c0(O.texts[N]);
1821
+ D !== null && (O.kinds[N] !== "space" && O.kinds[N] !== "preserved-space" || O.kinds[N + 1] !== "text" || !Ct(O.texts[N + 1]) || (O.texts[N] = D.space, O.isWordLike[N] = !1, O.kinds[N] = O.kinds[N] === "preserved-space" ? "preserved-space" : "space", O.texts[N + 1] = D.marks + O.texts[N + 1], O.starts[N + 1] = O.starts[N] + D.space.length));
1822
+ }
1823
+ return O;
1824
+ }
1825
+ function b0(e, t) {
1826
+ if (e.len === 0)
1827
+ return [];
1828
+ if (!t.preserveHardBreaks)
1829
+ return [{
1830
+ startSegmentIndex: 0,
1831
+ endSegmentIndex: e.len,
1832
+ consumedEndSegmentIndex: e.len
1833
+ }];
1834
+ const n = [];
1835
+ let x = 0;
1836
+ for (let i = 0; i < e.len; i++)
1837
+ e.kinds[i] === "hard-break" && (n.push({
1838
+ startSegmentIndex: x,
1839
+ endSegmentIndex: i,
1840
+ consumedEndSegmentIndex: i + 1
1841
+ }), x = i + 1);
1842
+ return x < e.len && n.push({
1843
+ startSegmentIndex: x,
1844
+ endSegmentIndex: e.len,
1845
+ consumedEndSegmentIndex: e.len
1846
+ }), n;
1847
+ }
1848
+ function L0(e, t, n) {
1849
+ if (t.len <= 1)
1850
+ return t;
1851
+ const x = [], i = [], s = [], o = [];
1852
+ let a = -1, c = !1;
1853
+ function r(h) {
1854
+ x.push(t.texts[h]), i.push(t.isWordLike[h]), s.push("text"), o.push(t.starts[h]);
1855
+ }
1856
+ function l(h, g) {
1857
+ let A = !1;
1858
+ for (let C = h; C < g; C++)
1859
+ A = A || t.isWordLike[C];
1860
+ const m = t.starts[h], B = g < t.len ? t.starts[g] : e.length;
1861
+ x.push(e.slice(m, B)), i.push(A), s.push("text"), o.push(m);
1862
+ }
1863
+ function f(h) {
1864
+ if (!(a < 0)) {
1865
+ if (c)
1866
+ a + 1 === h ? r(a) : l(a, h);
1867
+ else
1868
+ for (let g = a; g < h; g++)
1869
+ r(g);
1870
+ a = -1, c = !1;
1871
+ }
1872
+ }
1873
+ for (let h = 0; h < t.len; h++) {
1874
+ const g = t.texts[h], A = t.kinds[h];
1875
+ if (A === "text") {
1876
+ a >= 0 && !Jt(t.texts[h - 1], n) && f(h), a < 0 && (a = h), c = c || xe(g);
1877
+ continue;
1878
+ }
1879
+ f(h), x.push(g), i.push(t.isWordLike[h]), s.push(A), o.push(t.starts[h]);
1880
+ }
1881
+ return f(t.len), {
1882
+ len: x.length,
1883
+ texts: x,
1884
+ isWordLike: i,
1885
+ kinds: s,
1886
+ starts: o
1887
+ };
1888
+ }
1889
+ function O0(e, t, n = "normal", x = "normal") {
1890
+ const i = Rn(n), s = i.mode === "pre-wrap" ? Gn(e) : Tn(e);
1891
+ if (s.length === 0)
1892
+ return {
1893
+ normalized: s,
1894
+ chunks: [],
1895
+ len: 0,
1896
+ texts: [],
1897
+ isWordLike: [],
1898
+ kinds: [],
1899
+ starts: []
1900
+ };
1901
+ const o = D0(s, t, i), a = x === "keep-all" ? L0(s, o, t.breakKeepAllAfterPunctuation) : o;
1902
+ return {
1903
+ normalized: s,
1904
+ chunks: b0(a, i),
1905
+ ...a
1906
+ };
1907
+ }
1908
+ let me = null;
1909
+ const Ot = /* @__PURE__ */ new Map();
1910
+ let Ae = null;
1911
+ const y0 = 96, I0 = /\p{Emoji_Presentation}/u, w0 = /[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;
1912
+ let Je = null;
1913
+ const yt = /* @__PURE__ */ new Map();
1914
+ function ot() {
1915
+ if (me !== null)
1916
+ return me;
1917
+ if (typeof OffscreenCanvas < "u")
1918
+ return me = new OffscreenCanvas(1, 1).getContext("2d"), me;
1919
+ if (typeof document < "u")
1920
+ return me = document.createElement("canvas").getContext("2d"), me;
1921
+ throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.");
1922
+ }
1923
+ function P0(e) {
1924
+ let t = Ot.get(e);
1925
+ return t || (t = /* @__PURE__ */ new Map(), Ot.set(e, t)), t;
1926
+ }
1927
+ function ue(e, t) {
1928
+ let n = t.get(e);
1929
+ return n === void 0 && (n = {
1930
+ width: ot().measureText(e).width,
1931
+ containsCJK: xe(e)
1932
+ }, t.set(e, n)), n;
1933
+ }
1934
+ function Ee() {
1935
+ if (Ae !== null)
1936
+ return Ae;
1937
+ if (typeof navigator > "u")
1938
+ return Ae = {
1939
+ lineFitEpsilon: 5e-3,
1940
+ carryCJKAfterClosingQuote: !1,
1941
+ breakKeepAllAfterPunctuation: !0,
1942
+ preferPrefixWidthsForBreakableRuns: !1,
1943
+ preferEarlySoftHyphenBreak: !1
1944
+ }, Ae;
1945
+ const e = navigator.userAgent, n = navigator.vendor === "Apple Computer, Inc." && e.includes("Safari/") && !e.includes("Chrome/") && !e.includes("Chromium/") && !e.includes("CriOS/") && !e.includes("FxiOS/") && !e.includes("EdgiOS/"), x = e.includes("Chrome/") || e.includes("Chromium/") || e.includes("CriOS/") || e.includes("Edg/");
1946
+ return Ae = {
1947
+ lineFitEpsilon: n ? 1 / 64 : 5e-3,
1948
+ carryCJKAfterClosingQuote: x,
1949
+ breakKeepAllAfterPunctuation: !n,
1950
+ preferPrefixWidthsForBreakableRuns: n,
1951
+ preferEarlySoftHyphenBreak: n
1952
+ }, Ae;
1953
+ }
1954
+ function W0(e) {
1955
+ const t = e.match(/(\d+(?:\.\d+)?)\s*px/);
1956
+ return t ? parseFloat(t[1]) : 16;
1957
+ }
1958
+ function Yt() {
1959
+ return Je === null && (Je = new Intl.Segmenter(void 0, { granularity: "grapheme" })), Je;
1960
+ }
1961
+ function v0(e) {
1962
+ return I0.test(e) || e.includes("️");
1963
+ }
1964
+ function R0(e) {
1965
+ return w0.test(e);
1966
+ }
1967
+ function T0(e, t) {
1968
+ let n = yt.get(e);
1969
+ if (n !== void 0)
1970
+ return n;
1971
+ const x = ot();
1972
+ x.font = e;
1973
+ const i = x.measureText("😀").width;
1974
+ if (n = 0, i > t + 0.5 && typeof document < "u" && document.body !== null) {
1975
+ const s = document.createElement("span");
1976
+ s.style.font = e, s.style.display = "inline-block", s.style.visibility = "hidden", s.style.position = "absolute", s.textContent = "😀", document.body.appendChild(s);
1977
+ const o = s.getBoundingClientRect().width;
1978
+ document.body.removeChild(s), i - o > 0.5 && (n = i - o);
1979
+ }
1980
+ return yt.set(e, n), n;
1981
+ }
1982
+ function G0(e) {
1983
+ let t = 0;
1984
+ const n = Yt();
1985
+ for (const x of n.segment(e))
1986
+ v0(x.segment) && t++;
1987
+ return t;
1988
+ }
1989
+ function H0(e, t) {
1990
+ return t.emojiCount === void 0 && (t.emojiCount = G0(e)), t.emojiCount;
1991
+ }
1992
+ function de(e, t, n) {
1993
+ return n === 0 ? t.width : t.width - H0(e, t) * n;
1994
+ }
1995
+ function _0(e, t, n, x, i) {
1996
+ if (t.breakableFitAdvances !== void 0 && t.breakableFitMode === i)
1997
+ return t.breakableFitAdvances;
1998
+ t.breakableFitMode = i;
1999
+ const s = Yt(), o = [];
2000
+ for (const l of s.segment(e))
2001
+ o.push(l.segment);
2002
+ if (o.length <= 1)
2003
+ return t.breakableFitAdvances = null, t.breakableFitAdvances;
2004
+ if (i === "sum-graphemes") {
2005
+ const l = [];
2006
+ for (const f of o) {
2007
+ const h = ue(f, n);
2008
+ l.push(de(f, h, x));
2009
+ }
2010
+ return t.breakableFitAdvances = l, t.breakableFitAdvances;
2011
+ }
2012
+ if (i === "pair-context" || o.length > y0) {
2013
+ const l = [];
2014
+ let f = null, h = 0;
2015
+ for (const g of o) {
2016
+ const A = ue(g, n), m = de(g, A, x);
2017
+ if (f === null)
2018
+ l.push(m);
2019
+ else {
2020
+ const B = f + g, C = ue(B, n);
2021
+ l.push(de(B, C, x) - h);
2022
+ }
2023
+ f = g, h = m;
2024
+ }
2025
+ return t.breakableFitAdvances = l, t.breakableFitAdvances;
2026
+ }
2027
+ const a = [];
2028
+ let c = "", r = 0;
2029
+ for (const l of o) {
2030
+ c += l;
2031
+ const f = ue(c, n), h = de(c, f, x);
2032
+ a.push(h - r), r = h;
2033
+ }
2034
+ return t.breakableFitAdvances = a, t.breakableFitAdvances;
2035
+ }
2036
+ function z0(e, t) {
2037
+ const n = ot();
2038
+ n.font = e;
2039
+ const x = P0(e), i = W0(e), s = t ? T0(e, i) : 0;
2040
+ return { cache: x, fontSize: i, emojiCorrection: s };
2041
+ }
2042
+ function j0(e) {
2043
+ return e === "space" || e === "zero-width-break" || e === "soft-hyphen";
2044
+ }
2045
+ function ze(e) {
2046
+ return e === "space" || e === "preserved-space" || e === "tab" || e === "zero-width-break" || e === "soft-hyphen";
2047
+ }
2048
+ function lt(e, t, n = e.widths.length) {
2049
+ for (; t < n; ) {
2050
+ const x = e.kinds[t];
2051
+ if (!j0(x))
2052
+ break;
2053
+ t++;
2054
+ }
2055
+ return t;
2056
+ }
2057
+ function $t(e, t) {
2058
+ if (t <= 0)
2059
+ return 0;
2060
+ const n = e % t;
2061
+ return Math.abs(n) <= 1e-6 ? t : t - n;
2062
+ }
2063
+ function Xt(e, t, n) {
2064
+ return e.letterSpacing !== 0 && t && e.spacingGraphemeCounts[n] > 0 ? e.letterSpacing : 0;
2065
+ }
2066
+ function ct(e, t) {
2067
+ return t === 0 ? 0 : e + t;
2068
+ }
2069
+ function K0(e, t) {
2070
+ return e.letterSpacing !== 0 && e.spacingGraphemeCounts[t] > 0 ? e.letterSpacing : 0;
2071
+ }
2072
+ function Vt(e, t, n, x, i) {
2073
+ const s = t === "tab" ? i + K0(e, n) : e.lineEndFitAdvances[n];
2074
+ return ct(x, s);
2075
+ }
2076
+ function Re(e, t, n, x) {
2077
+ const i = t === "tab" ? 0 : e.lineEndFitAdvances[n];
2078
+ return ct(x, i);
2079
+ }
2080
+ function Te(e, t, n, x, i) {
2081
+ const s = t === "tab" ? i : e.lineEndPaintAdvances[n];
2082
+ return ct(x, s);
2083
+ }
2084
+ function qt(e, t, n) {
2085
+ return e.letterSpacing !== 0 && t ? n + e.letterSpacing : n;
2086
+ }
2087
+ function Zt(e, t) {
2088
+ return e.letterSpacing === 0 ? t : t + e.letterSpacing;
2089
+ }
2090
+ function U0(e, t, n, x, i) {
2091
+ if (e.letterSpacing === 0)
2092
+ return 0;
2093
+ if (i > 0)
2094
+ return e.spacingGraphemeCounts[x] > 0 ? e.letterSpacing : 0;
2095
+ for (let s = x - 1; s >= t; s--) {
2096
+ const o = e.kinds[s];
2097
+ if (!(o === "space" || o === "zero-width-break" || o === "hard-break")) {
2098
+ if (o === "soft-hyphen") {
2099
+ if (s === x - 1)
2100
+ return 0;
2101
+ continue;
2102
+ }
2103
+ return s === t && n > 0 || e.spacingGraphemeCounts[s] > 0 ? e.letterSpacing : 0;
2104
+ }
2105
+ }
2106
+ return 0;
2107
+ }
2108
+ function en(e, t, n, x, i, s) {
2109
+ return t + U0(e, n, x, i, s);
2110
+ }
2111
+ function J0(e, t) {
2112
+ let n = 0, x = e.chunks.length;
2113
+ for (; n < x; ) {
2114
+ const i = Math.floor((n + x) / 2);
2115
+ t < e.chunks[i].consumedEndSegmentIndex ? x = i : n = i + 1;
2116
+ }
2117
+ return n < e.chunks.length ? n : -1;
2118
+ }
2119
+ function Q0(e, t, n) {
2120
+ let x = n.segmentIndex;
2121
+ if (n.graphemeIndex > 0)
2122
+ return t;
2123
+ const i = e.chunks[t];
2124
+ return i.startSegmentIndex === i.endSegmentIndex && x === i.startSegmentIndex || (x < i.startSegmentIndex && (x = i.startSegmentIndex), x = lt(e, x, i.endSegmentIndex), x < i.endSegmentIndex) ? (n.segmentIndex = x, n.graphemeIndex = 0, t) : i.consumedEndSegmentIndex >= e.widths.length ? -1 : (n.segmentIndex = i.consumedEndSegmentIndex, n.graphemeIndex = 0, t + 1);
2125
+ }
2126
+ function Y0(e, t) {
2127
+ if (t.segmentIndex >= e.widths.length)
2128
+ return -1;
2129
+ const n = J0(e, t.segmentIndex);
2130
+ return n < 0 ? -1 : Q0(e, n, t);
2131
+ }
2132
+ function $0(e, t, n) {
2133
+ const { widths: x, kinds: i, breakableFitAdvances: s } = e;
2134
+ if (x.length === 0)
2135
+ return 0;
2136
+ const a = Ee().lineFitEpsilon, c = t + a;
2137
+ let r = 0, l = 0, f = !1, h = 0, g = 0, A = 0, m = 0, B = -1, C = 0;
2138
+ function v() {
2139
+ B = -1, C = 0;
2140
+ }
2141
+ function H(T = A, G = m, w = l) {
2142
+ r++, n?.(w, h, g, T, G), l = 0, f = !1, v();
2143
+ }
2144
+ function y(T, G) {
2145
+ f = !0, h = T, g = 0, A = T + 1, m = 0, l = G;
2146
+ }
2147
+ function O(T, G, w) {
2148
+ f = !0, h = T, g = G, A = T, m = G + 1, l = w;
2149
+ }
2150
+ function N(T, G) {
2151
+ if (!f) {
2152
+ y(T, G);
2153
+ return;
2154
+ }
2155
+ l += G, A = T + 1, m = 0;
2156
+ }
2157
+ function D(T, G) {
2158
+ const w = s[T];
2159
+ for (let j = G; j < w.length; j++) {
2160
+ const z = w[j];
2161
+ f ? l + z > c ? (H(), O(T, j, z)) : (l += z, A = T, m = j + 1) : O(T, j, z);
2162
+ }
2163
+ f && A === T && m === w.length && (A = T + 1, m = 0);
2164
+ }
2165
+ let k = 0;
2166
+ for (; k < x.length && !(!f && (k = lt(e, k), k >= x.length)); ) {
2167
+ const T = x[k], G = i[k], w = ze(G);
2168
+ if (!f) {
2169
+ T > c && s[k] !== null ? D(k, 0) : y(k, T), w && (B = k + 1, C = l - T), k++;
2170
+ continue;
2171
+ }
2172
+ if (l + T > c) {
2173
+ if (w) {
2174
+ N(k, T), H(k + 1, 0, l - T), k++;
2175
+ continue;
2176
+ }
2177
+ if (B >= 0) {
2178
+ if (A > B || A === B && m > 0) {
2179
+ H();
2180
+ continue;
2181
+ }
2182
+ H(B, 0, C);
2183
+ continue;
2184
+ }
2185
+ if (T > c && s[k] !== null) {
2186
+ H(), D(k, 0), k++;
2187
+ continue;
2188
+ }
2189
+ H();
2190
+ continue;
2191
+ }
2192
+ N(k, T), w && (B = k + 1, C = l - T), k++;
2193
+ }
2194
+ return f && H(), r;
2195
+ }
2196
+ function X0(e, t, n) {
2197
+ if (e.simpleLineWalkFastPath)
2198
+ return $0(e, t, n);
2199
+ const { widths: x, kinds: i, breakableFitAdvances: s, discretionaryHyphenWidth: o, chunks: a } = e;
2200
+ if (x.length === 0 || a.length === 0)
2201
+ return 0;
2202
+ const c = Ee(), r = c.lineFitEpsilon, l = t + r;
2203
+ let f = 0, h = 0, g = !1, A = 0, m = 0, B = 0, C = 0, v = -1, H = 0, y = 0, O = null;
2204
+ function N() {
2205
+ v = -1, H = 0, y = 0, O = null;
2206
+ }
2207
+ function D() {
2208
+ return O === "soft-hyphen" && v === B && C === 0 ? y : h;
2209
+ }
2210
+ function k(S = B, R = C, L) {
2211
+ f++, n !== void 0 && n(en(e, L ?? D(), A, m, S, R), A, m, S, R), h = 0, g = !1, N();
2212
+ }
2213
+ function T(S, R) {
2214
+ g = !0, A = S, m = 0, B = S + 1, C = 0, h = R;
2215
+ }
2216
+ function G(S, R, L) {
2217
+ g = !0, A = S, m = R, B = S, C = R + 1, h = L;
2218
+ }
2219
+ function w(S, R) {
2220
+ if (!g) {
2221
+ T(S, R);
2222
+ return;
2223
+ }
2224
+ h += R, B = S + 1, C = 0;
2225
+ }
2226
+ function j(S, R, L, P, W, J) {
2227
+ if (!R)
2228
+ return;
2229
+ const X = Re(e, S, L, W), ne = Te(e, S, L, W, P);
2230
+ v = L + 1, H = h - J + X, y = h - J + ne, O = S;
2231
+ }
2232
+ function z(S, R) {
2233
+ const L = s[S];
2234
+ for (let P = R; P < L.length; P++) {
2235
+ const W = L[P];
2236
+ if (!g)
2237
+ G(S, P, W);
2238
+ else {
2239
+ const J = qt(e, !0, W), X = h + J;
2240
+ Zt(e, X) > l ? (k(), G(S, P, W)) : (h = X, B = S, C = P + 1);
2241
+ }
2242
+ }
2243
+ g && B === S && C === L.length && (B = S + 1, C = 0);
2244
+ }
2245
+ function b(S) {
2246
+ f++, n?.(0, S.startSegmentIndex, 0, S.consumedEndSegmentIndex, 0), N();
2247
+ }
2248
+ for (let S = 0; S < a.length; S++) {
2249
+ const R = a[S];
2250
+ if (R.startSegmentIndex === R.endSegmentIndex) {
2251
+ b(R);
2252
+ continue;
2253
+ }
2254
+ g = !1, h = 0, A = R.startSegmentIndex, m = 0, B = R.startSegmentIndex, C = 0, N();
2255
+ let L = R.startSegmentIndex;
2256
+ for (; L < R.endSegmentIndex && !(!g && (L = lt(e, L, R.endSegmentIndex), L >= R.endSegmentIndex)); ) {
2257
+ const P = i[L], W = ze(P), J = Xt(e, g, L), X = P === "tab" ? $t(h + J, e.tabStopAdvance) : x[L], ne = J + X, te = Vt(e, P, L, J, X);
2258
+ if (P === "soft-hyphen") {
2259
+ g && (B = L + 1, C = 0, v = L + 1, H = h + o, y = h + o, O = P), L++;
2260
+ continue;
2261
+ }
2262
+ if (!g) {
2263
+ te > l && s[L] !== null ? z(L, 0) : T(L, X), j(P, W, L, X, J, ne), L++;
2264
+ continue;
2265
+ }
2266
+ if (h + te > l) {
2267
+ const oe = h + Re(e, P, L, J), Z = h + Te(e, P, L, J, X);
2268
+ if (O === "soft-hyphen" && c.preferEarlySoftHyphenBreak && H <= l) {
2269
+ k(v, 0, y);
2270
+ continue;
2271
+ }
2272
+ if (W && oe <= l) {
2273
+ w(L, ne), k(L + 1, 0, Z), L++;
2274
+ continue;
2275
+ }
2276
+ if (v >= 0 && H <= l) {
2277
+ if (B > v || B === v && C > 0) {
2278
+ k();
2279
+ continue;
2280
+ }
2281
+ const le = v;
2282
+ k(le, 0, y), L = le;
2283
+ continue;
2284
+ }
2285
+ if (te > l && s[L] !== null) {
2286
+ k(), z(L, 0), L++;
2287
+ continue;
2288
+ }
2289
+ k();
2290
+ continue;
2291
+ }
2292
+ w(L, ne), j(P, W, L, X, J, ne), L++;
2293
+ }
2294
+ if (g) {
2295
+ const P = v === R.consumedEndSegmentIndex ? y : h;
2296
+ k(R.consumedEndSegmentIndex, 0, P);
2297
+ }
2298
+ }
2299
+ return f;
2300
+ }
2301
+ function V0(e, t, n, x) {
2302
+ const i = e.chunks[n];
2303
+ if (i.startSegmentIndex === i.endSegmentIndex)
2304
+ return t.segmentIndex = i.consumedEndSegmentIndex, t.graphemeIndex = 0, 0;
2305
+ const { widths: s, kinds: o, breakableFitAdvances: a, discretionaryHyphenWidth: c } = e, r = Ee(), l = r.lineFitEpsilon, f = x + l, h = t.segmentIndex, g = t.graphemeIndex;
2306
+ let A = 0, m = !1, B = t.segmentIndex, C = t.graphemeIndex, v = -1, H = 0, y = 0, O = null;
2307
+ function N() {
2308
+ return O === "soft-hyphen" && v === B && C === 0 ? y : A;
2309
+ }
2310
+ function D(b = B, S = C, R = N()) {
2311
+ return m ? (t.segmentIndex = b, t.graphemeIndex = S, en(e, R, h, g, b, S)) : null;
2312
+ }
2313
+ function k(b, S) {
2314
+ m = !0, B = b + 1, C = 0, A = S;
2315
+ }
2316
+ function T(b, S, R) {
2317
+ m = !0, B = b, C = S + 1, A = R;
2318
+ }
2319
+ function G(b, S) {
2320
+ if (!m) {
2321
+ k(b, S);
2322
+ return;
2323
+ }
2324
+ A += S, B = b + 1, C = 0;
2325
+ }
2326
+ function w(b, S, R, L, P, W) {
2327
+ if (!S)
2328
+ return;
2329
+ const J = Re(e, b, R, P), X = Te(e, b, R, P, L);
2330
+ v = R + 1, H = A - W + J, y = A - W + X, O = b;
2331
+ }
2332
+ function j(b, S) {
2333
+ const R = a[b];
2334
+ for (let L = S; L < R.length; L++) {
2335
+ const P = R[L];
2336
+ if (!m)
2337
+ T(b, L, P);
2338
+ else {
2339
+ const W = qt(e, !0, P), J = A + W;
2340
+ if (Zt(e, J) > f)
2341
+ return D();
2342
+ A = J, B = b, C = L + 1;
2343
+ }
2344
+ }
2345
+ return m && B === b && C === R.length && (B = b + 1, C = 0), null;
2346
+ }
2347
+ function z() {
2348
+ return O !== "soft-hyphen" || v < 0 ? null : H <= f ? D(v, 0, y) : null;
2349
+ }
2350
+ for (let b = t.segmentIndex; b < i.endSegmentIndex; b++) {
2351
+ const S = o[b], R = ze(S), L = b === t.segmentIndex ? t.graphemeIndex : 0, P = Xt(e, m, b), W = S === "tab" ? $t(A + P, e.tabStopAdvance) : s[b], J = P + W, X = Vt(e, S, b, P, W);
2352
+ if (S === "soft-hyphen" && L === 0) {
2353
+ m && (B = b + 1, C = 0, v = b + 1, H = A + c, y = A + c, O = S);
2354
+ continue;
2355
+ }
2356
+ if (!m) {
2357
+ if (L > 0) {
2358
+ const te = j(b, L);
2359
+ if (te !== null)
2360
+ return te;
2361
+ } else if (X > f && a[b] !== null) {
2362
+ const te = j(b, 0);
2363
+ if (te !== null)
2364
+ return te;
2365
+ } else
2366
+ k(b, W);
2367
+ w(S, R, b, W, P, J);
2368
+ continue;
2369
+ }
2370
+ if (A + X > f) {
2371
+ const te = A + Re(e, S, b, P), De = A + Te(e, S, b, P, W);
2372
+ if (O === "soft-hyphen" && r.preferEarlySoftHyphenBreak && H <= f)
2373
+ return D(v, 0, y);
2374
+ const oe = z();
2375
+ if (oe !== null)
2376
+ return oe;
2377
+ if (R && te <= f)
2378
+ return G(b, J), D(b + 1, 0, De);
2379
+ if (v >= 0 && H <= f)
2380
+ return B > v || B === v && C > 0 ? D() : D(v, 0, y);
2381
+ if (X > f && a[b] !== null) {
2382
+ const Z = D();
2383
+ if (Z !== null)
2384
+ return Z;
2385
+ const le = j(b, 0);
2386
+ if (le !== null)
2387
+ return le;
2388
+ }
2389
+ return D();
2390
+ }
2391
+ G(b, J), w(S, R, b, W, P, J);
2392
+ }
2393
+ return v === i.consumedEndSegmentIndex && C === 0 ? D(i.consumedEndSegmentIndex, 0, y) : D(i.consumedEndSegmentIndex, 0, A);
2394
+ }
2395
+ function q0(e, t, n) {
2396
+ const { widths: x, kinds: i, breakableFitAdvances: s } = e, a = Ee().lineFitEpsilon, c = n + a;
2397
+ let r = 0, l = !1, f = t.segmentIndex, h = t.graphemeIndex, g = -1, A = 0;
2398
+ for (let m = t.segmentIndex; m < x.length; m++) {
2399
+ const B = i[m], C = ze(B), v = m === t.segmentIndex ? t.graphemeIndex : 0, H = s[m], y = x[m];
2400
+ if (!l) {
2401
+ if (v > 0 || y > c && H !== null) {
2402
+ const O = H, N = O[v];
2403
+ l = !0, r = N, f = m, h = v + 1;
2404
+ for (let D = v + 1; D < O.length; D++) {
2405
+ const k = O[D];
2406
+ if (r + k > c)
2407
+ return t.segmentIndex = f, t.graphemeIndex = h, r;
2408
+ r += k, f = m, h = D + 1;
2409
+ }
2410
+ f === m && h === O.length && (f = m + 1, h = 0);
2411
+ } else
2412
+ l = !0, r = y, f = m + 1, h = 0;
2413
+ C && (g = m + 1, A = r - y);
2414
+ continue;
2415
+ }
2416
+ if (r + y > c)
2417
+ return C ? (t.segmentIndex = m + 1, t.graphemeIndex = 0, r) : g >= 0 ? f > g || f === g && h > 0 ? (t.segmentIndex = f, t.graphemeIndex = h, r) : (t.segmentIndex = g, t.graphemeIndex = 0, A) : (t.segmentIndex = f, t.graphemeIndex = h, r);
2418
+ r += y, f = m + 1, h = 0, C && (g = m + 1, A = r - y);
2419
+ }
2420
+ return l ? (t.segmentIndex = f, t.graphemeIndex = h, r) : null;
2421
+ }
2422
+ function Z0(e, t, n, x) {
2423
+ return e.simpleLineWalkFastPath ? q0(e, t, x) : V0(e, t, n, x);
2424
+ }
2425
+ function Ze(e, t, n) {
2426
+ const x = Y0(e, t);
2427
+ return x < 0 ? null : Z0(e, t, x, n);
2428
+ }
2429
+ let Qe = null, It = /* @__PURE__ */ new WeakMap();
2430
+ function es() {
2431
+ return Qe === null && (Qe = new Intl.Segmenter(void 0, { granularity: "grapheme" })), Qe;
2432
+ }
2433
+ function wt(e, t, n) {
2434
+ let x = n.get(e);
2435
+ if (x !== void 0)
2436
+ return x;
2437
+ x = [];
2438
+ const i = es();
2439
+ for (const s of i.segment(t[e]))
2440
+ x.push(s.segment);
2441
+ return n.set(e, x), x;
2442
+ }
2443
+ function ts(e, t, n) {
2444
+ return n > t && e[n - 1] === "soft-hyphen";
2445
+ }
2446
+ function Pt(e, t, n, x) {
2447
+ for (let i = n; i < x; i++)
2448
+ e += t[i];
2449
+ return e;
2450
+ }
2451
+ function ns(e) {
2452
+ let t = It.get(e);
2453
+ return t !== void 0 || (t = /* @__PURE__ */ new Map(), It.set(e, t)), t;
2454
+ }
2455
+ function ss(e, t, n, x, i, s) {
2456
+ let o = "";
2457
+ const a = ts(e.kinds, n, i);
2458
+ for (let c = n; c < i; c++)
2459
+ if (!(e.kinds[c] === "soft-hyphen" || e.kinds[c] === "hard-break"))
2460
+ if (c === n && x > 0) {
2461
+ const r = wt(c, e.segments, t);
2462
+ o = Pt(o, r, x, r.length);
2463
+ } else
2464
+ o += e.segments[c];
2465
+ if (s > 0) {
2466
+ a && (o += "-");
2467
+ const c = wt(i, e.segments, t);
2468
+ o = Pt(o, c, n === i ? x : 0, s);
2469
+ } else a && (o += "-");
2470
+ return o;
2471
+ }
2472
+ let Ye = null;
2473
+ function tn() {
2474
+ return Ye === null && (Ye = new Intl.Segmenter(void 0, { granularity: "grapheme" })), Ye;
2475
+ }
2476
+ function is(e) {
2477
+ return {
2478
+ widths: [],
2479
+ lineEndFitAdvances: [],
2480
+ lineEndPaintAdvances: [],
2481
+ kinds: [],
2482
+ simpleLineWalkFastPath: !0,
2483
+ segLevels: null,
2484
+ breakableFitAdvances: [],
2485
+ letterSpacing: 0,
2486
+ spacingGraphemeCounts: [],
2487
+ discretionaryHyphenWidth: 0,
2488
+ tabStopAdvance: 0,
2489
+ chunks: [],
2490
+ segments: []
2491
+ };
2492
+ }
2493
+ function rs(e, t) {
2494
+ const n = [];
2495
+ let x = [], i = 0, s = !1, o = !1, a = !1;
2496
+ function c() {
2497
+ x.length !== 0 && (n.push({
2498
+ text: x.length === 1 ? x[0] : x.join(""),
2499
+ start: i
2500
+ }), x = [], s = !1, o = !1, a = !1);
2501
+ }
2502
+ function r(f, h, g) {
2503
+ x = [f], i = h, s = g, o = Ve(f), a = Ge.has(f);
2504
+ }
2505
+ function l(f, h) {
2506
+ x.push(f), s = s || h;
2507
+ const g = Ve(f);
2508
+ f.length === 1 && Fe.has(f) ? o = o || g : o = g, a = !1;
2509
+ }
2510
+ for (const f of tn().segment(e)) {
2511
+ const h = f.segment, g = xe(h);
2512
+ if (x.length === 0) {
2513
+ r(h, f.index, g);
2514
+ continue;
2515
+ }
2516
+ if (a || it.has(h) || Fe.has(h) || t.carryCJKAfterClosingQuote && g && o) {
2517
+ l(h, g);
2518
+ continue;
2519
+ }
2520
+ if (!s && !g) {
2521
+ l(h, g);
2522
+ continue;
2523
+ }
2524
+ c(), r(h, f.index, g);
2525
+ }
2526
+ return c(), n;
2527
+ }
2528
+ function xs(e, t, n) {
2529
+ if (t.length <= 1)
2530
+ return t;
2531
+ const x = [];
2532
+ let i = -1, s = !1;
2533
+ function o(c, r) {
2534
+ const l = t[c].start, f = r < t.length ? t[r].start : e.length;
2535
+ x.push({
2536
+ text: e.slice(l, f),
2537
+ start: l
2538
+ });
2539
+ }
2540
+ function a(c) {
2541
+ if (!(i < 0)) {
2542
+ if (s)
2543
+ i + 1 === c ? x.push(t[i]) : o(i, c);
2544
+ else
2545
+ for (let r = i; r < c; r++)
2546
+ x.push(t[r]);
2547
+ i = -1, s = !1;
2548
+ }
2549
+ }
2550
+ for (let c = 0; c < t.length; c++) {
2551
+ const r = t[c];
2552
+ i >= 0 && !Jt(t[c - 1].text, n) && a(c), i < 0 && (i = c), s = s || xe(r.text);
2553
+ }
2554
+ return a(t.length), x;
2555
+ }
2556
+ function Wt(e, t) {
2557
+ if (t === "zero-width-break" || t === "soft-hyphen" || t === "hard-break")
2558
+ return 0;
2559
+ if (t === "tab")
2560
+ return 1;
2561
+ let n = 0;
2562
+ const x = tn();
2563
+ for (const i of x.segment(e))
2564
+ n++;
2565
+ return n;
2566
+ }
2567
+ function os(e, t, n) {
2568
+ return t > 1 ? e + (t - 1) * n : e;
2569
+ }
2570
+ function ls(e, t, n, x, i) {
2571
+ const s = Ee(), { cache: o, emojiCorrection: a } = z0(t, R0(e.normalized)), c = de("-", ue("-", o), a) + (i === 0 ? 0 : i * 2), l = de(" ", ue(" ", o), a) * 8, f = i !== 0;
2572
+ if (e.len === 0)
2573
+ return is();
2574
+ const h = [], g = [], A = [], m = [];
2575
+ let B = e.chunks.length <= 1 && !f;
2576
+ const C = n ? [] : null, v = [], H = [], y = n ? [] : null, O = Array.from({ length: e.len });
2577
+ function N(G, w, j, z, b, S, R, L) {
2578
+ b !== "text" && b !== "space" && b !== "zero-width-break" && (B = !1), h.push(w), g.push(j), A.push(z), m.push(b), C?.push(S), v.push(R), f && H.push(L), y !== null && y.push(G);
2579
+ }
2580
+ function D(G, w, j, z, b) {
2581
+ const S = ue(G, o), R = f ? Wt(G, w) : 0, L = os(de(G, S, a), R, i), P = w === "space" || w === "preserved-space" || w === "zero-width-break" ? 0 : L, W = P === 0 ? 0 : P + (R > 0 ? i : 0), J = w === "space" || w === "zero-width-break" ? 0 : L;
2582
+ if (b && z && G.length > 1) {
2583
+ let X = "sum-graphemes";
2584
+ i !== 0 ? X = "segment-prefixes" : ve(G) ? X = "pair-context" : s.preferPrefixWidthsForBreakableRuns && (X = "segment-prefixes");
2585
+ const ne = _0(G, S, o, a, X);
2586
+ N(G, L, W, J, w, j, ne, R);
2587
+ return;
2588
+ }
2589
+ N(G, L, W, J, w, j, null, R);
2590
+ }
2591
+ for (let G = 0; G < e.len; G++) {
2592
+ O[G] = h.length;
2593
+ const w = e.texts[G], j = e.isWordLike[G], z = e.kinds[G], b = e.starts[G];
2594
+ if (z === "soft-hyphen") {
2595
+ N(w, 0, c, c, z, b, null, 0);
2596
+ continue;
2597
+ }
2598
+ if (z === "hard-break") {
2599
+ N(w, 0, 0, 0, z, b, null, 0);
2600
+ continue;
2601
+ }
2602
+ if (z === "tab") {
2603
+ N(w, 0, 0, 0, z, b, null, f ? Wt(w, z) : 0);
2604
+ continue;
2605
+ }
2606
+ const S = ue(w, o);
2607
+ if (z === "text" && S.containsCJK) {
2608
+ const R = rs(w, s), L = x === "keep-all" ? xs(w, R, s.breakKeepAllAfterPunctuation) : R;
2609
+ for (let P = 0; P < L.length; P++) {
2610
+ const W = L[P];
2611
+ D(W.text, "text", b + W.start, j, x === "keep-all" || !xe(W.text));
2612
+ }
2613
+ continue;
2614
+ }
2615
+ D(w, z, b, j, !0);
2616
+ }
2617
+ const k = cs(e.chunks, O, h.length), T = C === null ? null : Pn(e.normalized, C);
2618
+ return y !== null ? {
2619
+ widths: h,
2620
+ lineEndFitAdvances: g,
2621
+ lineEndPaintAdvances: A,
2622
+ kinds: m,
2623
+ simpleLineWalkFastPath: B,
2624
+ segLevels: T,
2625
+ breakableFitAdvances: v,
2626
+ letterSpacing: i,
2627
+ spacingGraphemeCounts: H,
2628
+ discretionaryHyphenWidth: c,
2629
+ tabStopAdvance: l,
2630
+ chunks: k,
2631
+ segments: y
2632
+ } : {
2633
+ widths: h,
2634
+ lineEndFitAdvances: g,
2635
+ lineEndPaintAdvances: A,
2636
+ kinds: m,
2637
+ simpleLineWalkFastPath: B,
2638
+ segLevels: T,
2639
+ breakableFitAdvances: v,
2640
+ letterSpacing: i,
2641
+ spacingGraphemeCounts: H,
2642
+ discretionaryHyphenWidth: c,
2643
+ tabStopAdvance: l,
2644
+ chunks: k
2645
+ };
2646
+ }
2647
+ function cs(e, t, n) {
2648
+ const x = [];
2649
+ for (let i = 0; i < e.length; i++) {
2650
+ const s = e[i], o = s.startSegmentIndex < t.length ? t[s.startSegmentIndex] : n, a = s.endSegmentIndex < t.length ? t[s.endSegmentIndex] : n, c = s.consumedEndSegmentIndex < t.length ? t[s.consumedEndSegmentIndex] : n;
2651
+ x.push({
2652
+ startSegmentIndex: o,
2653
+ endSegmentIndex: a,
2654
+ consumedEndSegmentIndex: c
2655
+ });
2656
+ }
2657
+ return x;
2658
+ }
2659
+ function as(e, t, n, x) {
2660
+ const i = x?.wordBreak ?? "normal", s = x?.letterSpacing ?? 0, o = O0(e, Ee(), x?.whiteSpace, i);
2661
+ return ls(o, t, n, i, s);
2662
+ }
2663
+ function et(e, t, n) {
2664
+ return as(e, t, !0, n);
2665
+ }
2666
+ function vt(e) {
2667
+ let t = 0;
2668
+ return X0(e, Number.POSITIVE_INFINITY, (n) => {
2669
+ n > t && (t = n);
2670
+ }), t;
2671
+ }
2672
+ const fs = /[ \t\n\f\r]+/, Rt = /^[ \t\n\f\r]+/, Tt = /[ \t\n\f\r]+$/, Gt = { segmentIndex: 0, graphemeIndex: 0 }, us = {
2673
+ itemIndex: 0,
2674
+ segmentIndex: 0,
2675
+ graphemeIndex: 0
2676
+ };
2677
+ function $e(e) {
2678
+ return {
2679
+ segmentIndex: e.segmentIndex,
2680
+ graphemeIndex: e.graphemeIndex
2681
+ };
2682
+ }
2683
+ function Ht(e) {
2684
+ return e.segmentIndex === 0 && e.graphemeIndex === 0;
2685
+ }
2686
+ function Ie(e, t, n) {
2687
+ const x = `${e}\0${t}`, i = n.get(x);
2688
+ if (i !== void 0)
2689
+ return i;
2690
+ const s = t === 0 ? void 0 : { letterSpacing: t }, o = vt(et("A A", e, s)), a = vt(et("AA", e, s)), c = Math.max(0, o - a);
2691
+ return n.set(x, c), c;
2692
+ }
2693
+ function hs(e) {
2694
+ const t = { segmentIndex: 0, graphemeIndex: 0 }, n = Ze(e, t, Number.POSITIVE_INFINITY);
2695
+ return n === null ? null : {
2696
+ endGraphemeIndex: t.graphemeIndex,
2697
+ endSegmentIndex: t.segmentIndex,
2698
+ width: n
2699
+ };
2700
+ }
2701
+ function ds(e, t) {
2702
+ return e === 0 && t > 0;
2703
+ }
2704
+ function nn(e) {
2705
+ const t = [], n = Array.from({ length: e.length }), x = /* @__PURE__ */ new Map();
2706
+ let i = 0;
2707
+ for (let s = 0; s < e.length; s++) {
2708
+ const o = e[s], a = o.letterSpacing ?? 0, c = Rt.test(o.text), r = Tt.test(o.text), l = o.text.replace(Rt, "").replace(Tt, "");
2709
+ if (l.length === 0) {
2710
+ fs.test(o.text) && i === 0 && (i = Ie(o.font, a, x));
2711
+ continue;
2712
+ }
2713
+ const f = i > 0 ? i : c ? Ie(o.font, a, x) : 0, h = et(l, o.font, a === 0 ? void 0 : { letterSpacing: a }), g = hs(h);
2714
+ if (g === null) {
2715
+ i = r ? Ie(o.font, a, x) : 0;
2716
+ continue;
2717
+ }
2718
+ const A = {
2719
+ break: o.break ?? "normal",
2720
+ endGraphemeIndex: g.endGraphemeIndex,
2721
+ endSegmentIndex: g.endSegmentIndex,
2722
+ extraWidth: o.extraWidth ?? 0,
2723
+ gapBefore: f,
2724
+ naturalWidth: g.width,
2725
+ prepared: h,
2726
+ sourceItemIndex: s
2727
+ };
2728
+ t.push(A), n[s] = A, i = r ? Ie(o.font, a, x) : 0;
2729
+ }
2730
+ return {
2731
+ items: t,
2732
+ itemsBySourceItemIndex: n
2733
+ };
2734
+ }
2735
+ function Fs(e, t, n, x) {
2736
+ if (e.items.length === 0 || n.itemIndex >= e.items.length)
2737
+ return null;
2738
+ const i = Math.max(1, t);
2739
+ let s = 0, o = i, a = n.itemIndex;
2740
+ e: for (; a < e.items.length; ) {
2741
+ const c = e.items[a];
2742
+ if (!Ht(n) && n.segmentIndex === c.endSegmentIndex && n.graphemeIndex === c.endGraphemeIndex) {
2743
+ a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2744
+ continue;
2745
+ }
2746
+ const r = s === 0 ? 0 : c.gapBefore, l = Ht(n);
2747
+ if (c.break === "never") {
2748
+ if (!l) {
2749
+ a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2750
+ continue;
2751
+ }
2752
+ const C = c.naturalWidth + c.extraWidth, v = r + C;
2753
+ if (s > 0 && v > o)
2754
+ break e;
2755
+ x?.(c, r, C, $e(Gt), {
2756
+ segmentIndex: c.endSegmentIndex,
2757
+ graphemeIndex: c.endGraphemeIndex
2758
+ }), s += v, o = Math.max(0, i - s), a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2759
+ continue;
2760
+ }
2761
+ const f = r + c.extraWidth;
2762
+ if (s > 0 && f >= o)
2763
+ break e;
2764
+ if (l) {
2765
+ const C = f + c.naturalWidth;
2766
+ if (C <= o) {
2767
+ x?.(c, r, c.naturalWidth + c.extraWidth, $e(Gt), {
2768
+ segmentIndex: c.endSegmentIndex,
2769
+ graphemeIndex: c.endGraphemeIndex
2770
+ }), s += C, o = Math.max(0, i - s), a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2771
+ continue;
2772
+ }
2773
+ }
2774
+ const h = Math.max(1, o - f), g = {
2775
+ segmentIndex: n.segmentIndex,
2776
+ graphemeIndex: n.graphemeIndex
2777
+ }, A = Ze(c.prepared, g, h);
2778
+ if (A === null) {
2779
+ a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2780
+ continue;
2781
+ }
2782
+ if (n.segmentIndex === g.segmentIndex && n.graphemeIndex === g.graphemeIndex) {
2783
+ a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2784
+ continue;
2785
+ }
2786
+ const m = A + c.extraWidth, B = r + m;
2787
+ if (s > 0 && l && B > o)
2788
+ break e;
2789
+ if (s > 0 && l && r > 0 && ds(g.segmentIndex, g.graphemeIndex)) {
2790
+ const C = { segmentIndex: 0, graphemeIndex: 0 };
2791
+ if (Ze(c.prepared, C, Math.max(1, i - c.extraWidth)) !== null && (C.segmentIndex > g.segmentIndex || C.segmentIndex === g.segmentIndex && C.graphemeIndex > g.graphemeIndex))
2792
+ break e;
2793
+ }
2794
+ if (x?.(c, r, m, $e(n), {
2795
+ segmentIndex: g.segmentIndex,
2796
+ graphemeIndex: g.graphemeIndex
2797
+ }), s += B, o = Math.max(0, i - s), g.segmentIndex === c.endSegmentIndex && g.graphemeIndex === c.endGraphemeIndex) {
2798
+ a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2799
+ continue;
2800
+ }
2801
+ n.segmentIndex = g.segmentIndex, n.graphemeIndex = g.graphemeIndex;
2802
+ break;
2803
+ }
2804
+ return s === 0 ? null : (n.itemIndex = a, s);
2805
+ }
2806
+ function gs(e, t, n = us) {
2807
+ const x = e, i = {
2808
+ itemIndex: n.itemIndex,
2809
+ segmentIndex: n.segmentIndex,
2810
+ graphemeIndex: n.graphemeIndex
2811
+ }, s = [], o = Fs(x, t, i, (a, c, r, l, f) => {
2812
+ s.push({
2813
+ itemIndex: a.sourceItemIndex,
2814
+ gapBefore: c,
2815
+ occupiedWidth: r,
2816
+ start: l,
2817
+ end: f
2818
+ });
2819
+ });
2820
+ return o === null ? null : {
2821
+ fragments: s,
2822
+ width: o,
2823
+ end: i
2824
+ };
2825
+ }
2826
+ function Ns(e, t) {
2827
+ return ss(e.prepared, ns(e.prepared), t.start.segmentIndex, t.start.graphemeIndex, t.end.segmentIndex, t.end.graphemeIndex);
2828
+ }
2829
+ function ps(e, t) {
2830
+ const n = e, x = [];
2831
+ for (let i = 0; i < t.fragments.length; i++) {
2832
+ const s = t.fragments[i], o = n.itemsBySourceItemIndex[s.itemIndex];
2833
+ if (o === void 0)
2834
+ throw new Error("Missing rich-text inline item for fragment");
2835
+ x.push({
2836
+ itemIndex: s.itemIndex,
2837
+ text: Ns(o, s),
2838
+ gapBefore: s.gapBefore,
2839
+ occupiedWidth: s.occupiedWidth,
2840
+ start: s.start,
2841
+ end: s.end
2842
+ });
2843
+ }
2844
+ return {
2845
+ fragments: x,
2846
+ width: t.width,
2847
+ end: t.end
2848
+ };
2849
+ }
2850
+ function Ss(e) {
2851
+ const t = [];
2852
+ let n = [], x = 0, i = 0;
2853
+ for (const s of e) {
2854
+ let o = 0;
2855
+ for (; ; ) {
2856
+ const c = s.text.indexOf("\v", o);
2857
+ if (c < 0) break;
2858
+ const r = s.text.slice(o, c);
2859
+ r.length > 0 && n.push({ text: r, style: s.style }), i += c - o, t.push({ runs: n, startOffset: x }), i += 1, x = i, n = [], o = c + 1;
2860
+ }
2861
+ const a = s.text.slice(o);
2862
+ a.length > 0 && n.push({ text: a, style: s.style }), i += a.length;
2863
+ }
2864
+ return t.push({ runs: n, startOffset: x }), t;
2865
+ }
2866
+ function sn(e) {
2867
+ return e.map((t) => {
2868
+ const n = { text: t.style.hidden ? "" : t.text, font: ae(t.style) };
2869
+ return !t.style.hidden && t.style.letterSpacingPx !== void 0 && (n.letterSpacing = t.style.letterSpacingPx), n;
2870
+ });
2871
+ }
2872
+ function ms(e) {
2873
+ return nn(sn(e));
2874
+ }
2875
+ class tt {
2876
+ map = /* @__PURE__ */ new Map();
2877
+ get(t) {
2878
+ const n = this.map.get(t.id);
2879
+ if (n && n.revision === t.revision) return n.segments;
2880
+ const x = Ss(t.runs).map((i) => ({
2881
+ prepared: nn(sn(i.runs)),
2882
+ runs: i.runs,
2883
+ startOffset: i.startOffset
2884
+ }));
2885
+ return this.map.set(t.id, { revision: t.revision, segments: x }), x;
2886
+ }
2887
+ evict(t) {
2888
+ this.map.delete(t);
2889
+ }
2890
+ /** Drop every entry — used when the whole document is replaced (the importer
2891
+ * re-mints block ids from i0, so a stale entry at the same id+revision would
2892
+ * otherwise leak the previous document's prepared text into the new one). */
2893
+ clear() {
2894
+ this.map.clear();
2895
+ }
2896
+ /** Drop every entry whose id is NOT in `keep` (paragraphs no longer in the
2897
+ * document). Called after a full layout to bound the cache to live blocks. */
2898
+ retainOnly(t) {
2899
+ for (const n of this.map.keys()) t.has(n) || this.map.delete(n);
2900
+ }
2901
+ }
2902
+ const Xe = 48;
2903
+ function As() {
2904
+ const e = new tt(), t = /* @__PURE__ */ new Map();
2905
+ let n = null;
2906
+ const x = (i, s) => {
2907
+ n?.add(i.id);
2908
+ const o = t.get(i.id);
2909
+ if (o && o.revision === i.revision && o.width === s) return o.lines;
2910
+ const a = ln(i, s, e);
2911
+ return t.set(i.id, { revision: i.revision, width: s, lines: a }), a;
2912
+ };
2913
+ return {
2914
+ layout(i, s, o) {
2915
+ const a = o?.rawBand ?? null;
2916
+ n = a === null ? /* @__PURE__ */ new Set() : null;
2917
+ try {
2918
+ const c = Os(i, x, (r) => (n?.add(r.id), e.get(r)), a);
2919
+ if (n) {
2920
+ for (const r of t.keys()) n.has(r) || t.delete(r);
2921
+ e.retainOnly(n);
2922
+ }
2923
+ return c;
2924
+ } finally {
2925
+ n = null;
2926
+ }
2927
+ },
2928
+ evict(i) {
2929
+ e.evict(i), t.delete(i);
2930
+ },
2931
+ reset() {
2932
+ e.clear(), t.clear();
2933
+ }
2934
+ };
2935
+ }
2936
+ function Es(e) {
2937
+ let t = 0;
2938
+ for (let n = 0; n < e.length; n++) e.charCodeAt(n) === 32 && t++;
2939
+ return t;
2940
+ }
2941
+ const Bs = (e) => e === " " || e === " " || e === `
2942
+ ` || e === "\r";
2943
+ function Ms(e, t, n) {
2944
+ const x = e.indexOf(n, t);
2945
+ if (x >= 0) return { start: x, end: x + n.length };
2946
+ const i = [];
2947
+ let s = t, o = 0, a = -1;
2948
+ for (; o < n.length && s < e.length; ) {
2949
+ if (e[s] === n[o]) {
2950
+ a < 0 && (a = s), i.push(s - a), s++, o++;
2951
+ continue;
2952
+ }
2953
+ if (Bs(e[s])) {
2954
+ s++;
2955
+ continue;
2956
+ }
2957
+ a = -1;
2958
+ break;
2959
+ }
2960
+ return a >= 0 && o === n.length ? (i.push(s - a), s - a === n.length ? { start: a, end: s } : { start: a, end: s, map: i }) : { start: t, end: t + n.length };
2961
+ }
2962
+ function at(e, t) {
2963
+ const n = [];
2964
+ let x = t;
2965
+ for (const i of e)
2966
+ n.push(x), x += i.text.length;
2967
+ return n;
2968
+ }
2969
+ function Cs(e) {
2970
+ return kn(e) && !e.style.sectionBreak && !e.style.pageBreakBefore;
2971
+ }
2972
+ function rn(e) {
2973
+ const t = e.runs[0]?.style, n = t?.fontSizePx ?? 16, x = t ? We(ae(t)) : { ascent: n * 0.8, descent: n * 0.2 }, i = x.ascent + x.descent, s = Math.max(i, e.style.lineHeight * n);
2974
+ return { height: s, ascent: (s - i) / 2 + x.ascent };
2975
+ }
2976
+ function ft(e, t, n, x, i, s) {
2977
+ const o = gs(t.prepared, n, x);
2978
+ if (o === null) return null;
2979
+ const a = ps(t.prepared, o), c = [];
2980
+ let r = 0, l = 0, f = 0, h = 0;
2981
+ for (const B of a.fragments) {
2982
+ r += B.gapBefore;
2983
+ const C = t.runs[B.itemIndex], v = We(ae(C.style));
2984
+ if (l = Math.max(l, v.ascent), f = Math.max(f, v.descent), h = Math.max(h, C.style.fontSizePx), B.text.length > 0) {
2985
+ const H = Ms(C.text, s[B.itemIndex], B.text);
2986
+ s[B.itemIndex] = H.end;
2987
+ const y = {
2988
+ blockId: e.id,
2989
+ startOffset: i[B.itemIndex] + H.start,
2990
+ endOffset: i[B.itemIndex] + H.end,
2991
+ text: B.text,
2992
+ style: C.style,
2993
+ x: r,
2994
+ width: B.occupiedWidth
2995
+ };
2996
+ H.map && (y.offsetMap = H.map), c.push({ frag: y, hadGap: B.gapBefore > 0, spaces: Es(B.text) });
2997
+ }
2998
+ r += B.occupiedWidth;
2999
+ }
3000
+ if (h === 0) {
3001
+ const B = e.runs[0]?.style;
3002
+ if (B) {
3003
+ const C = We(ae(B));
3004
+ l = C.ascent, f = C.descent, h = B.fontSizePx;
3005
+ }
3006
+ }
3007
+ const g = l + f, A = Math.max(g, e.style.lineHeight * h), m = (A - g) / 2;
3008
+ return { frags: c, width: a.width, height: A, ascent: m + l, end: a.end };
3009
+ }
3010
+ function ks(e, t, n) {
3011
+ for (const i of t) if (i.posPx > e + 0.5) return i;
3012
+ let x = (Math.floor(e / Xe) + 1) * Xe;
3013
+ return x <= e && (x = e + Xe), { posPx: Math.min(x, Math.max(e + 1, n)), align: "left", leader: "none" };
3014
+ }
3015
+ function Ds(e) {
3016
+ const t = e.map((i) => i.text).join(""), n = ae(e[0]?.style ?? xn);
3017
+ let x = t.indexOf(".");
3018
+ return x < 0 && (x = t.indexOf(",")), Pe(x < 0 ? t : t.slice(0, x + 1), n);
3019
+ }
3020
+ const xn = { fontFamily: "Georgia, serif", fontSizePx: 16 };
3021
+ function bs(e, t, n, x, i) {
3022
+ const s = [];
3023
+ let o = [], a = n, c = n;
3024
+ for (const y of t) {
3025
+ let O = 0;
3026
+ for (; ; ) {
3027
+ const D = y.text.indexOf(" ", O);
3028
+ if (D < 0) break;
3029
+ const k = y.text.slice(O, D);
3030
+ k.length > 0 && o.push({ text: k, style: y.style }), c += D - O, s.push({ runs: o, start: a }), c += 1, a = c, o = [], O = D + 1;
3031
+ }
3032
+ const N = y.text.slice(O);
3033
+ N.length > 0 && o.push({ text: N, style: y.style }), c += N.length;
3034
+ }
3035
+ s.push({ runs: o, start: a });
3036
+ const r = (e.style.tabStops ?? []).slice().sort((y, O) => y.posPx - O.posPx), l = t.find((y) => y.text.length > 0)?.style ?? e.runs[0]?.style, f = [];
3037
+ let h = [], g = [], A = [], m = i, B = 0, C = 0, v = !1;
3038
+ const H = (y) => {
3039
+ if (B === 0 && l) {
3040
+ const O = We(ae(l));
3041
+ B = Math.max(O.ascent + O.descent, e.style.lineHeight * l.fontSizePx), C = (B - (O.ascent + O.descent)) / 2 + O.ascent;
3042
+ }
3043
+ f.push({
3044
+ frags: h,
3045
+ width: m,
3046
+ indent: 0,
3047
+ // fragment x is already absolute (tab/indent baked in)
3048
+ lineMaxWidth: x,
3049
+ height: B,
3050
+ ascent: C,
3051
+ // A tab-positioned line stays ragged (its manual x must not be re-justified);
3052
+ // pure wrapped continuation lines justify normally when the paragraph does.
3053
+ lastOfSegment: y || v,
3054
+ ...g.length > 0 ? { leaders: g } : {},
3055
+ ...A.length > 0 ? { tabArrows: A } : {}
3056
+ }), h = [], g = [], A = [], m = 0, B = 0, C = 0, v = !1;
3057
+ };
3058
+ return s.forEach((y, O) => {
3059
+ if (O > 0) {
3060
+ const w = ks(m, r, x), j = w.align ?? "left", z = Pe(y.runs.map((R) => R.text).join(""), ae(y.runs[0]?.style ?? l ?? xn)), b = m + z <= x;
3061
+ let S = w.posPx;
3062
+ b && j === "right" ? S = w.posPx - z : b && j === "center" ? S = w.posPx - z / 2 : b && j === "decimal" && (S = w.posPx - Ds(y.runs)), S < m && (S = m), (w.leader ?? "none") !== "none" && S > m + 1 && l && g.push({ x1: m, x2: S, kind: w.leader ?? "none", color: l.color, fontSizePx: l.fontSizePx }), A.push({ x1: m, x2: Math.max(S, m) }), m = S, v = !0;
3063
+ }
3064
+ if (y.runs.length === 0) return;
3065
+ const N = { prepared: ms(y.runs), runs: y.runs, startOffset: y.start }, D = at(y.runs, y.start), k = y.runs.map(() => 0);
3066
+ let T, G = !0;
3067
+ for (; ; ) {
3068
+ const w = Math.max(24, x - (G ? m : 0)), j = ft(e, N, w, T, D, k);
3069
+ if (j === null) break;
3070
+ G || H(!1);
3071
+ const z = G ? m : 0;
3072
+ for (const b of j.frags)
3073
+ b.frag.x += z, h.push(b);
3074
+ m = z + j.width, B = Math.max(B, j.height), C = Math.max(C, j.ascent), T = j.end, G = !1;
3075
+ }
3076
+ }), H(!0), f;
3077
+ }
3078
+ function on(e, t) {
3079
+ if (t <= 0) return;
3080
+ const n = e.reduce((s, o) => s + o.spaces + (o.hadGap ? 1 : 0), 0);
3081
+ if (n <= 0) return;
3082
+ const x = t / n;
3083
+ let i = 0;
3084
+ for (const s of e)
3085
+ s.hadGap && (i += x), s.frag.x += i, s.spaces > 0 && (s.frag.wordSpacingPx = x, s.frag.width += s.spaces * x, i += s.spaces * x);
3086
+ }
3087
+ function ln(e, t, n) {
3088
+ const x = n.get(e), i = [], s = [];
3089
+ let o = !0;
3090
+ const a = [];
3091
+ for (let r = 0; r < x.length; r++) {
3092
+ const l = x[r];
3093
+ if (l.runs.some((m) => m.text.includes(" "))) {
3094
+ s.push(...bs(e, l.runs, l.startOffset, t, o ? e.style.indentFirstLinePx : 0)), o = !1, a[r] = s.length - 1;
3095
+ continue;
3096
+ }
3097
+ const f = at(l.runs, l.startOffset), h = l.runs.map(() => 0);
3098
+ let g, A = !1;
3099
+ for (; ; ) {
3100
+ const m = o ? e.style.indentFirstLinePx : 0, B = t - m, C = ft(e, l, B, g, f, h);
3101
+ if (C === null) break;
3102
+ s.push({
3103
+ frags: C.frags,
3104
+ width: C.width,
3105
+ indent: m,
3106
+ lineMaxWidth: B,
3107
+ height: C.height,
3108
+ ascent: C.ascent,
3109
+ lastOfSegment: !1
3110
+ }), g = C.end, o = !1, A = !0;
3111
+ }
3112
+ if (A)
3113
+ s[s.length - 1].lastOfSegment = !0;
3114
+ else {
3115
+ const m = rn(e);
3116
+ s.push({
3117
+ frags: [],
3118
+ width: 0,
3119
+ indent: 0,
3120
+ lineMaxWidth: t,
3121
+ height: m.height,
3122
+ ascent: m.ascent,
3123
+ lastOfSegment: !0,
3124
+ emptyOffset: l.startOffset
3125
+ }), o = !1;
3126
+ }
3127
+ a[r] = s.length - 1;
3128
+ }
3129
+ for (let r = 0; r < a.length; r++) {
3130
+ const l = a[r];
3131
+ l !== void 0 && (r === x.length - 1 ? s[l].paragraphEnd = !0 : s[l].lineBreak = !0);
3132
+ }
3133
+ let c = 0;
3134
+ for (const r of s) {
3135
+ const l = r.lineMaxWidth - r.width;
3136
+ let f = r.indent;
3137
+ e.style.align === "center" ? f += l / 2 : e.style.align === "right" ? f += l : e.style.align === "justify" && !r.lastOfSegment && on(r.frags, l);
3138
+ for (const g of r.frags) g.frag.x += f;
3139
+ const h = { y: c, height: r.height, ascent: r.ascent, fragments: r.frags.map((g) => g.frag) };
3140
+ r.emptyOffset !== void 0 && (h.emptyOffset = r.emptyOffset), r.leaders && r.leaders.length > 0 && (h.leaders = r.leaders.map((g) => ({ ...g, x1: g.x1 + f, x2: g.x2 + f }))), r.tabArrows && r.tabArrows.length > 0 && (h.tabArrows = r.tabArrows.map((g) => ({ x1: g.x1 + f, x2: g.x2 + f }))), r.paragraphEnd && (h.paragraphEnd = !0), r.lineBreak && (h.lineBreak = !0), i.push(h), c += r.height;
3141
+ }
3142
+ return i;
3143
+ }
3144
+ const _t = 2, zt = 2, Ls = 48, cn = ["header", "footer", "headerFirst", "headerEven", "footerFirst", "footerEven"];
3145
+ function an(e, t) {
3146
+ const n = {
3147
+ pageWidthPx: t.pageWidthPx ?? e.pageWidthPx,
3148
+ pageHeightPx: t.pageHeightPx ?? e.pageHeightPx,
3149
+ marginPx: t.marginPx ?? e.marginPx
3150
+ }, x = t.columns === void 0 ? e.columns : t.columns ?? void 0;
3151
+ x && (n.columns = x), t.pageNumberStart !== void 0 && (n.pageNumberStart = t.pageNumberStart);
3152
+ const i = t.headerDistancePx ?? e.headerDistancePx;
3153
+ i !== void 0 && (n.headerDistancePx = i);
3154
+ const s = t.footerDistancePx ?? e.footerDistancePx;
3155
+ s !== void 0 && (n.footerDistancePx = s);
3156
+ const o = t.pageColorHex ?? e.pageColorHex;
3157
+ o !== void 0 && (n.pageColorHex = o);
3158
+ const a = t.pageBorders ?? e.pageBorders;
3159
+ a !== void 0 && (n.pageBorders = a);
3160
+ for (const c of cn) {
3161
+ const r = t[c] ?? e[c];
3162
+ r && (n[c] = r);
3163
+ }
3164
+ return n;
3165
+ }
3166
+ function jt(e, t) {
3167
+ return e.headerDistancePx !== void 0 ? e.headerDistancePx : Math.max(8, (e.marginPx.top - t) / 2);
3168
+ }
3169
+ function Kt(e, t) {
3170
+ return e.footerDistancePx !== void 0 ? e.pageHeightPx - e.footerDistancePx - t : e.pageHeightPx - Math.max(8, (e.marginPx.bottom - t) / 2) - t;
3171
+ }
3172
+ function fn(e) {
3173
+ const t = [];
3174
+ for (let n = 0; n < e.blocks.length; n++) {
3175
+ const x = e.blocks[n];
3176
+ x.kind === "paragraph" && x.style.sectionBreak && t.push({ props: an(e.section, x.style.sectionBreak.props), endBlock: n });
3177
+ }
3178
+ return t.push({ props: e.section, endBlock: e.blocks.length - 1 }), t;
3179
+ }
3180
+ function Os(e, t, n, x) {
3181
+ const s = /* @__PURE__ */ new Map();
3182
+ let o = null;
3183
+ const a = (u) => {
3184
+ const F = s.get(u);
3185
+ if (F) return F;
3186
+ let d = u.marginPx.top, p = u.pageHeightPx - u.marginPx.bottom;
3187
+ const M = [u.header, u.headerFirst, u.headerEven].filter((_) => !!_), E = [u.footer, u.footerFirst, u.footerEven].filter((_) => !!_);
3188
+ if (M.length > 0 || E.length > 0) {
3189
+ o ??= new tt();
3190
+ const _ = u.pageWidthPx - u.marginPx.left - u.marginPx.right, K = u.marginPx.left, Y = (q) => we(q, _, K, 999, 999, o, !1).height, U = (q) => {
3191
+ const ee = we(q, _, K, 999, 999, o, !1);
3192
+ for (const $ of ee.placed)
3193
+ if (!!$.table || !!$.image || $.lines.some((Be) => Be.fragments.some((fe) => fe.text.trim().length > 0))) return ee.height - $.y;
3194
+ return 0;
3195
+ }, Q = M.reduce((q, ee) => Math.max(q, Y(ee)), 0);
3196
+ if (Q > 0) {
3197
+ const q = jt(u, Q);
3198
+ d = Math.max(d, q + Q + 6);
3199
+ }
3200
+ const V = E.reduce((q, ee) => Math.max(q, Y(ee)), 0);
3201
+ if (V > 0)
3202
+ if (u.footerDistancePx !== void 0) {
3203
+ const q = u.pageHeightPx - u.footerDistancePx, ee = E.reduce(($, Se) => Math.max($, U(Se)), 0);
3204
+ p = Math.min(p, q - ee);
3205
+ } else
3206
+ p = Math.min(p, Kt(u, V) - 6);
3207
+ p = Math.max(p, d + 24);
3208
+ }
3209
+ const I = { top: d, bottom: p };
3210
+ return s.set(u, I), I;
3211
+ }, c = fn(e);
3212
+ let r = c[0].props, l = 0, f = 0, h = 0, g = 0, A = 1, m = 0, B = [], C = [];
3213
+ const v = (u) => {
3214
+ r = u;
3215
+ const F = a(r);
3216
+ l = r.marginPx.left, f = F.top, h = F.bottom, g = r.pageWidthPx - r.marginPx.left - r.marginPx.right, A = Math.max(1, r.columns?.count ?? 1);
3217
+ const d = r.columns?.gapPx ?? 24, p = r.columns?.cols;
3218
+ if (A > 1 && p && p.length === A) {
3219
+ let M = l;
3220
+ B = p.map((E, I) => {
3221
+ const _ = { x: M, width: E.widthPx };
3222
+ return M += E.widthPx + (I < A - 1 ? E.spaceAfterPx : 0), _;
3223
+ }), m = Math.min(...p.map((E) => E.widthPx));
3224
+ } else A > 1 ? (m = (g - (A - 1) * d) / A, B = Array.from({ length: A }, (M, E) => ({
3225
+ x: l + E * (m + d),
3226
+ width: m
3227
+ }))) : (m = g, B = [{ x: l, width: g }]);
3228
+ C = r.columns?.sep ? B.slice(0, -1).map((M, E) => (M.x + M.width + B[E + 1].x) / 2) : [];
3229
+ };
3230
+ v(r);
3231
+ const H = e.lists ?? {}, y = (u) => {
3232
+ const F = u.style.list;
3233
+ if (!F) return null;
3234
+ const d = H[F.listId];
3235
+ return d ? d.levels[Math.min(F.level, d.levels.length - 1)] ?? null : null;
3236
+ }, O = (u) => u.style.indentLeftPx + (y(u)?.indentLeftPx ?? 0), N = (u) => u.style.indentRightPx ?? 0, D = (u) => y(u)?.indentLeftPx ?? 0, k = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map(), G = (u) => {
3237
+ const F = u.style.list, d = y(u);
3238
+ if (!F || !d) return;
3239
+ const p = H[F.listId], M = k.get(F.listId) ?? [];
3240
+ M[F.level] = (M[F.level] ?? d.start - 1) + 1, M.length = F.level + 1, k.set(F.listId, M);
3241
+ const E = On(p, F.level, M);
3242
+ if (E.length === 0) return;
3243
+ const I = u.runs[0]?.style;
3244
+ I && T.set(u.id, {
3245
+ text: E,
3246
+ style: { ...I, ...d.markerStyle ?? {} },
3247
+ hangingPx: d.hangingPx
3248
+ });
3249
+ }, w = (u) => {
3250
+ for (const F of u)
3251
+ if (F.kind === "paragraph") G(F);
3252
+ else if (F.kind === "table") for (const d of F.rows) for (const p of d.cells) w(p.blocks);
3253
+ };
3254
+ w(e.blocks);
3255
+ const j = { indentOf: D, markers: T }, z = [];
3256
+ let b = 0;
3257
+ for (let u = 0; u < e.blocks.length; u++) {
3258
+ for (; u > c[b].endBlock; ) v(c[++b].props);
3259
+ const F = e.blocks[u];
3260
+ if (F.kind === "paragraph") {
3261
+ if (Cs(F)) continue;
3262
+ const d = F.style.tocEntry ? Ls : 0;
3263
+ z.push({
3264
+ kind: "para",
3265
+ block: F,
3266
+ lines: t(F, m - O(F) - N(F) - d)
3267
+ });
3268
+ } else if (F.kind === "image")
3269
+ z.push({ kind: "image", block: F, height: F.anchor ? 0 : F.heightPx });
3270
+ else {
3271
+ const d = ut(F, m, t, j);
3272
+ z.push({ kind: "table", block: F, ...d });
3273
+ }
3274
+ }
3275
+ b = 0, v(c[0].props);
3276
+ const S = [], R = () => {
3277
+ S.push(r);
3278
+ const u = {
3279
+ index: S.length - 1,
3280
+ number: S.length,
3281
+ // provisional; the post-pass sets the real value
3282
+ blocks: [],
3283
+ widthPx: r.pageWidthPx,
3284
+ heightPx: r.pageHeightPx,
3285
+ marginPx: r.marginPx,
3286
+ contentTopPx: f,
3287
+ contentBottomPx: h
3288
+ };
3289
+ return r.pageColorHex !== void 0 && (u.pageColorHex = r.pageColorHex), r.pageBorders !== void 0 && (u.pageBorders = r.pageBorders), C.length && (u.columnSeparatorsX = C.slice()), u;
3290
+ }, L = [R()];
3291
+ let P = L[0], W = f;
3292
+ const J = /* @__PURE__ */ new Map(), X = 14, ne = 18, te = e.footnotes ?? {}, De = Object.keys(te).length > 0;
3293
+ let oe = 0;
3294
+ const Z = () => h - oe, le = /* @__PURE__ */ new Set(), be = [[]], je = [0], Ft = /* @__PURE__ */ new Map(), gt = (u) => {
3295
+ const F = te[u];
3296
+ if (!F || F.length === 0) return null;
3297
+ const d = Math.max(40, g - ne);
3298
+ let p = 0;
3299
+ return { paras: F.map((E) => {
3300
+ const I = t(E, d);
3301
+ return p += E.style.spaceBeforePx + pe(I) + E.style.spaceAfterPx, { p: E, lines: I };
3302
+ }), height: p };
3303
+ }, dn = (u, F, d) => {
3304
+ const p = [];
3305
+ for (let M = F; M < F + d; M++)
3306
+ for (const E of u[M].fragments) {
3307
+ const I = E.style.footnoteRef;
3308
+ I && te[I] && !le.has(I) && !p.some(([_]) => _ === I) && p.push([I, E.text]);
3309
+ }
3310
+ return p;
3311
+ };
3312
+ let Ne = 0, Le = 0;
3313
+ const ce = () => B[Ne]?.x ?? l, se = () => P.blocks.length > Le, Ke = () => {
3314
+ Ne = 0, Le = 0, P = R(), L.push(P), be.push([]), je.push(0), oe = 0, W = f, he = [];
3315
+ }, ie = () => {
3316
+ Ne + 1 < A ? (Ne++, Le = P.blocks.length, W = f, he = []) : Ke();
3317
+ }, Fn = () => {
3318
+ P.blocks.length === 0 ? (P.widthPx = r.pageWidthPx, P.heightPx = r.pageHeightPx, P.marginPx = r.marginPx, P.contentTopPx = f, P.contentBottomPx = h, r.pageColorHex !== void 0 ? P.pageColorHex = r.pageColorHex : delete P.pageColorHex, r.pageBorders !== void 0 ? P.pageBorders = r.pageBorders : delete P.pageBorders, C.length ? P.columnSeparatorsX = C.slice() : delete P.columnSeparatorsX, S[P.index] = r, Ne = 0, Le = 0, W = f, he = []) : Ke();
3319
+ }, gn = (u, F, d, p) => {
3320
+ const M = {
3321
+ blockId: u.id,
3322
+ x: ce() + O(u),
3323
+ y: W,
3324
+ firstLineIndex: d,
3325
+ lines: []
3326
+ }, E = d === 0 ? T.get(u.id) : void 0;
3327
+ E && (M.marker = { text: E.text, style: E.style, x: M.x - E.hangingPx }), u.style.tocEntry && J.set(u.id, { chunk: M, rightEdge: ce() + m, para: u }), P.blocks.push(M);
3328
+ for (let I = d; I < d + p; I++) {
3329
+ const _ = F[I];
3330
+ M.lines.push({ ..._, y: W - M.y }), W += _.height;
3331
+ }
3332
+ }, Nn = (u, F) => {
3333
+ let d = 0, p = W;
3334
+ for (; F + d < u.length && p + u[F + d].height <= Z(); )
3335
+ p += u[F + d].height, d++;
3336
+ return d;
3337
+ }, Nt = (u) => {
3338
+ let F = be[P.index].length === 0 ? X : 0;
3339
+ const d = [];
3340
+ for (const [p, M] of u) {
3341
+ const E = gt(p);
3342
+ E && (F += E.height, d.push([p, M, E]));
3343
+ }
3344
+ return { H: F, measures: d };
3345
+ }, pt = (u, F) => {
3346
+ for (const [d, p] of u)
3347
+ le.add(d), be[P.index].push(d), Ft.set(d, p);
3348
+ oe += F, je[P.index] = oe;
3349
+ }, pn = (u) => {
3350
+ const F = [], d = (p) => {
3351
+ for (const M of p)
3352
+ if (M.kind === "paragraph") {
3353
+ let E = 0;
3354
+ for (const I of M.runs) {
3355
+ const _ = I.style.footnoteRef;
3356
+ _ && te[_] && !le.has(_) && !F.some(([K]) => K === _) && F.push([_, I.text]), E += I.text.length;
3357
+ }
3358
+ } else if (M.kind === "table")
3359
+ for (const E of M.rows) for (const I of E.cells) d(I.blocks);
3360
+ };
3361
+ for (const p of u) for (const M of p.cells) d(M.blocks);
3362
+ return F;
3363
+ }, Sn = (u, F, d) => {
3364
+ for (; ; ) {
3365
+ if (d <= 0) return d;
3366
+ const p = dn(u, F, d);
3367
+ if (p.length === 0) return d;
3368
+ const { H: M, measures: E } = Nt(p);
3369
+ if (E.length === 0) return d;
3370
+ let I = 0;
3371
+ for (let K = F; K < F + d; K++) I += u[K].height;
3372
+ if (W + I + M <= Z() || d === 1 && !se())
3373
+ return pt(E, M), d;
3374
+ d--;
3375
+ }
3376
+ }, mn = (u, F) => {
3377
+ if (u.style.keepLinesTogether === !0 && se()) {
3378
+ const p = pe(F);
3379
+ W + p > Z() && p <= h - f && ie();
3380
+ }
3381
+ let d = 0;
3382
+ for (; d < F.length; ) {
3383
+ const p = F.length - d, M = Nn(F, d);
3384
+ let E;
3385
+ if (M >= p ? E = p : (E = M, p - E === 1 && (E -= zt - 1), d === 0 && E > 0 && E < _t && (E = 0), E <= 0 && (E = se() ? 0 : Math.max(1, M))), E > 0 && De && (E = Sn(F, d, E)), E > 0 && (gn(u, F, d, E), d += E), d >= F.length) return;
3386
+ ie();
3387
+ }
3388
+ }, pe = (u) => {
3389
+ let F = 0;
3390
+ for (const d of u) F += d.height;
3391
+ return F;
3392
+ };
3393
+ let he = [];
3394
+ const St = 10, An = (u) => {
3395
+ let F = ce(), d = ce() + m;
3396
+ for (const p of he)
3397
+ u >= p.bottom || (p.side === "left" ? F = Math.max(F, p.right + St) : d = Math.min(d, p.left - St));
3398
+ return { x0: F, width: Math.max(40, d - F) };
3399
+ }, En = (u) => he.some((F) => F.bottom > u), Bn = (u) => {
3400
+ const F = u.anchor;
3401
+ let d;
3402
+ switch (F.relFromH) {
3403
+ case "page":
3404
+ case "leftMargin":
3405
+ d = 0;
3406
+ break;
3407
+ case "rightMargin":
3408
+ d = r.pageWidthPx - r.marginPx.right;
3409
+ break;
3410
+ case "column":
3411
+ d = ce();
3412
+ break;
3413
+ default:
3414
+ d = r.marginPx.left;
3415
+ break;
3416
+ }
3417
+ let p;
3418
+ switch (F.relFromV) {
3419
+ case "page":
3420
+ case "topMargin":
3421
+ p = 0;
3422
+ break;
3423
+ case "bottomMargin":
3424
+ p = r.pageHeightPx - r.marginPx.bottom;
3425
+ break;
3426
+ case "paragraph":
3427
+ case "line":
3428
+ p = W;
3429
+ break;
3430
+ // current flow position
3431
+ default:
3432
+ p = r.marginPx.top;
3433
+ break;
3434
+ }
3435
+ const M = { src: u.src, width: u.widthPx, height: u.heightPx, z: F.z ?? 0 };
3436
+ F.behind ? M.behind = !0 : M.front = !0, P.blocks.push({
3437
+ blockId: u.id,
3438
+ x: d + F.offsetXPx,
3439
+ y: p + F.offsetYPx,
3440
+ firstLineIndex: 0,
3441
+ lines: [],
3442
+ image: M
3443
+ });
3444
+ }, mt = (u) => {
3445
+ if (u.anchor) {
3446
+ Bn(u);
3447
+ return;
3448
+ }
3449
+ W + u.heightPx > Z() && se() && ie();
3450
+ const F = u.wrap === "square" && u.align !== "center", d = m - u.widthPx, p = ce() + (u.align === "center" ? d / 2 : u.align === "right" ? d : 0);
3451
+ P.blocks.push({
3452
+ blockId: u.id,
3453
+ x: p,
3454
+ y: W,
3455
+ firstLineIndex: 0,
3456
+ lines: [],
3457
+ image: { src: u.src, width: u.widthPx, height: u.heightPx }
3458
+ }), F ? he.push({ left: p, right: p + u.widthPx, bottom: W + u.heightPx, side: u.align === "right" ? "right" : "left" }) : W += u.heightPx;
3459
+ }, Mn = (u) => {
3460
+ const F = n(u);
3461
+ let d = !0, p = 0, M = null;
3462
+ const E = (I, _, K, Y) => {
3463
+ if (M === null) {
3464
+ M = { blockId: u.id, x: ce() + O(u), y: W, firstLineIndex: p, lines: [] };
3465
+ const Q = p === 0 ? T.get(u.id) : void 0;
3466
+ if (Q) {
3467
+ const V = I[0]?.frag.x ?? 0;
3468
+ M.marker = { text: Q.text, style: Q.style, x: M.x + V - Q.hangingPx };
3469
+ }
3470
+ P.blocks.push(M);
3471
+ }
3472
+ const U = { y: W - M.y, height: _, ascent: K, fragments: I.map((Q) => Q.frag) };
3473
+ Y !== void 0 && (U.emptyOffset = Y), M.lines.push(U), W += _, p++;
3474
+ };
3475
+ for (const I of F) {
3476
+ const _ = at(I.runs, I.startOffset), K = I.runs.map(() => 0);
3477
+ let Y, U = !1, Q = null;
3478
+ for (; ; ) {
3479
+ const V = K.slice(), q = An(W), ee = d ? u.style.indentFirstLinePx : 0, $ = ft(
3480
+ u,
3481
+ I,
3482
+ Math.max(24, q.width - O(u) - ee - N(u)),
3483
+ Y,
3484
+ _,
3485
+ K
3486
+ );
3487
+ if ($ === null) break;
3488
+ if (W + $.height > Z() && se()) {
3489
+ for (let fe = 0; fe < K.length; fe++) K[fe] = V[fe];
3490
+ ie(), M = null;
3491
+ continue;
3492
+ }
3493
+ const Se = q.width - ee - N(u) - $.width;
3494
+ let Be = q.x0 - ce() + ee;
3495
+ u.style.align === "center" ? Be += Se / 2 : u.style.align === "right" && (Be += Se);
3496
+ for (const fe of $.frags) fe.frag.x += Be;
3497
+ u.style.align === "justify" && (Q && on(Q.frags, Q.slack), Q = { frags: $.frags, slack: Se }), E($.frags, $.height, $.ascent), Y = $.end, d = !1, U = !0;
3498
+ }
3499
+ if (!U) {
3500
+ const V = rn(u);
3501
+ W + V.height > Z() && se() && (ie(), M = null), E([], V.height, V.ascent, I.startOffset), d = !1;
3502
+ }
3503
+ }
3504
+ }, Cn = (u) => {
3505
+ u.block.rows.some((p) => p.cells.some((M) => (M.rowSpan ?? 1) > 1)) && se() && W + u.height > Z() && u.height <= h - f && ie();
3506
+ let d = 0;
3507
+ for (; d < u.rows.length; ) {
3508
+ let p = 0, M = W;
3509
+ for (; d + p < u.rows.length && M + u.rows[d + p].height <= Z(); )
3510
+ M += u.rows[d + p].height, p++;
3511
+ if (p === 0) {
3512
+ if (se()) {
3513
+ ie();
3514
+ continue;
3515
+ }
3516
+ p = 1;
3517
+ }
3518
+ let E = [], I = 0;
3519
+ for (; ; ) {
3520
+ const K = pn(u.block.rows.slice(d, d + p));
3521
+ if (K.length === 0) break;
3522
+ const { H: Y, measures: U } = Nt(K);
3523
+ if (U.length === 0) break;
3524
+ let Q = 0;
3525
+ for (let V = d; V < d + p; V++) Q += u.rows[V].height;
3526
+ if (W + Q + Y <= Z() || p === 1 && !se()) {
3527
+ E = U, I = Y;
3528
+ break;
3529
+ }
3530
+ if (p--, p === 0) break;
3531
+ }
3532
+ if (p === 0) {
3533
+ ie();
3534
+ continue;
3535
+ }
3536
+ E.length > 0 && pt(E, I);
3537
+ const _ = u.rows.slice(d, d + p);
3538
+ P.blocks.push(dt(u.block, _, u.colWidths, ce(), W, m, d, j)), W += _.reduce((K, Y) => K + Y.height, 0), d += p, d < u.rows.length && ie();
3539
+ }
3540
+ };
3541
+ for (let u = 0; u < z.length; u++) {
3542
+ if (u > c[b].endBlock) {
3543
+ for (; u > c[b].endBlock; ) v(c[++b].props);
3544
+ Fn();
3545
+ }
3546
+ const F = z[u], d = (_) => _?.kind === "table" || _?.kind === "image" && _.block.anchor === void 0, p = d(z[u - 1]), M = d(z[u + 1]);
3547
+ if (F.kind === "image") {
3548
+ if (F.block.anchor) {
3549
+ mt(F.block);
3550
+ continue;
3551
+ }
3552
+ p || (W += Me), mt(F.block), !M && (F.block.wrap !== "square" || F.block.align === "center") && (W += Me);
3553
+ continue;
3554
+ }
3555
+ if (F.kind === "table") {
3556
+ p || (W += Me);
3557
+ for (const _ of he) _.bottom > W && (W = _.bottom);
3558
+ Cn(F), M || (W += Me);
3559
+ continue;
3560
+ }
3561
+ const { block: E, lines: I } = F;
3562
+ if (E.style.pageBreakBefore === !0 && (P.blocks.length > 0 || Ne > 0) ? Ke() : E.style.columnBreakBefore === !0 && se() && ie(), W += E.style.spaceBeforePx, W >= Z() && se() && ie(), En(W)) {
3563
+ Mn(E), W += E.style.spaceAfterPx;
3564
+ continue;
3565
+ }
3566
+ if (E.style.keepWithNext === !0 && z[u + 1] !== void 0 && se()) {
3567
+ let _ = W + pe(I) + E.style.spaceAfterPx, K = _ <= Z();
3568
+ for (let Y = u + 1; K; Y++) {
3569
+ const U = z[Y];
3570
+ if (U === void 0) break;
3571
+ if (U.kind !== "para") {
3572
+ const $ = U.kind === "table" ? U.rows[0]?.height ?? U.height : U.height;
3573
+ _ + Me + $ > Z() && (K = !1);
3574
+ break;
3575
+ }
3576
+ _ += U.block.style.spaceBeforePx;
3577
+ const Q = U.block.style.keepWithNext === !0 && z[Y + 1] !== void 0;
3578
+ if (Q || U.block.style.keepLinesTogether === !0) {
3579
+ const $ = pe(U.lines);
3580
+ if (_ + $ > Z()) {
3581
+ K = !1;
3582
+ break;
3583
+ }
3584
+ if (_ += $ + U.block.style.spaceAfterPx, !Q) break;
3585
+ continue;
3586
+ }
3587
+ if (z[Y + 1] !== void 0 && U.block.runs.every(($) => $.text.trim().length === 0)) {
3588
+ const $ = pe(U.lines);
3589
+ if (_ + $ > Z()) {
3590
+ K = !1;
3591
+ break;
3592
+ }
3593
+ _ += $ + U.block.style.spaceAfterPx;
3594
+ continue;
3595
+ }
3596
+ let V = 0, q = _;
3597
+ for (; V < U.lines.length && q + U.lines[V].height <= Z(); )
3598
+ q += U.lines[V].height, V++;
3599
+ let ee = V;
3600
+ V < U.lines.length && (U.lines.length - ee === 1 && (ee -= zt - 1), ee < _t && (ee = 0)), ee <= 0 && (K = !1);
3601
+ break;
3602
+ }
3603
+ K || ie();
3604
+ }
3605
+ mn(E, I), W += E.style.spaceAfterPx;
3606
+ }
3607
+ for (const u of L) {
3608
+ const F = be[u.index];
3609
+ if (!F || F.length === 0) continue;
3610
+ const d = S[u.index];
3611
+ v(d);
3612
+ let p = h - je[u.index];
3613
+ u.footnoteRuleY = p + 4, p += X;
3614
+ const M = d.marginPx.left;
3615
+ for (const E of F) {
3616
+ const I = gt(E);
3617
+ if (!I) continue;
3618
+ let _ = !0;
3619
+ for (const K of I.paras) {
3620
+ p += K.p.style.spaceBeforePx;
3621
+ const Y = {
3622
+ blockId: K.p.id,
3623
+ x: M + ne,
3624
+ y: p,
3625
+ firstLineIndex: 0,
3626
+ lines: K.lines
3627
+ };
3628
+ _ && K.p.runs[0] && (Y.marker = { text: `${Ft.get(E) ?? "•"}.`, style: K.p.runs[0].style, x: M }, _ = !1), u.blocks.push(Y), p += pe(K.lines) + K.p.style.spaceAfterPx;
3629
+ }
3630
+ }
3631
+ }
3632
+ const At = (u) => {
3633
+ for (const d of u)
3634
+ if (d.table) for (const p of d.table.rows) for (const M of p.cells) M.blocks = At(M.blocks);
3635
+ if (!u.some((d) => d.image?.behind || d.image?.front)) return u;
3636
+ const F = (d) => d.image?.behind ? 0 : d.image?.front ? 2 : 1;
3637
+ return u.map((d, p) => ({ b: d, i: p })).sort((d, p) => {
3638
+ const M = F(d.b) - F(p.b);
3639
+ if (M !== 0) return M;
3640
+ if (F(d.b) !== 1) {
3641
+ const E = (d.b.image.z ?? 0) - (p.b.image.z ?? 0);
3642
+ if (E !== 0) return E;
3643
+ }
3644
+ return d.i - p.i;
3645
+ }).map((d) => d.b);
3646
+ };
3647
+ for (const u of L) u.blocks = At(u.blocks);
3648
+ const Oe = [];
3649
+ {
3650
+ let u = 0;
3651
+ for (let F = 0; F < L.length; F++) {
3652
+ const d = S[F];
3653
+ (F === 0 || S[F - 1] !== d) && d.pageNumberStart !== void 0 ? u = d.pageNumberStart : u++, Oe.push(u), L[F].number = u;
3654
+ }
3655
+ }
3656
+ const Et = e.fields;
3657
+ if (Et) {
3658
+ const u = (p) => {
3659
+ if (p === void 0) return !1;
3660
+ const M = Et[p], E = M && M.kind === "builtin" ? M.spec?.type : void 0;
3661
+ return E === "PAGE" || E === "NUMPAGES";
3662
+ }, F = (p, M) => {
3663
+ let E = 0;
3664
+ for (const I of p.fragments) {
3665
+ if (E !== 0 && (I.x += E), !u(I.style.fieldId)) continue;
3666
+ const _ = un(I.text, M, L.length);
3667
+ if (_ === I.text) continue;
3668
+ const K = I.endOffset - I.startOffset, Y = I.width;
3669
+ I.text = _, I.width = Pe(_, ae(I.style)), I.offsetMap = Array.from({ length: _.length + 1 }, (U, Q) => Q === _.length ? K : 0), E += I.width - Y;
3670
+ }
3671
+ }, d = (p, M) => {
3672
+ for (const E of p.lines) F(E, M);
3673
+ if (p.table) for (const E of p.table.rows) for (const I of E.cells) for (const _ of I.blocks) d(_, M);
3674
+ };
3675
+ for (const p of L) for (const M of p.blocks) d(M, Oe[p.index]);
3676
+ }
3677
+ if (J.size > 0) {
3678
+ const u = /* @__PURE__ */ new Map(), F = (d, p) => {
3679
+ for (const M of d)
3680
+ if (u.has(M.blockId) || u.set(M.blockId, p), M.table) for (const E of M.table.rows) for (const I of E.cells) F(I.blocks, p);
3681
+ };
3682
+ for (const d of L) F(d.blocks, Oe[d.index]);
3683
+ for (const d of J.values()) {
3684
+ const p = d.para.style.tocEntry.targetId, M = u.get(p);
3685
+ if (M === void 0) continue;
3686
+ const E = d.para.runs[0]?.style;
3687
+ if (!E || d.chunk.lines.length === 0) continue;
3688
+ const I = String(M);
3689
+ d.chunk.toc = {
3690
+ numText: I,
3691
+ numX: d.rightEdge - Pe(I, ae(E)),
3692
+ lineIndex: d.chunk.lines.length - 1,
3693
+ style: E,
3694
+ targetId: p
3695
+ };
3696
+ }
3697
+ }
3698
+ const Bt = (u, F, d, p) => {
3699
+ const M = F === "header" ? u.headerFirst : u.footerFirst, E = F === "header" ? u.headerEven : u.footerEven;
3700
+ if (d && M) return { blocks: M, source: F === "header" ? "headerFirst" : "footerFirst" };
3701
+ if (p && E) return { blocks: E, source: F === "header" ? "headerEven" : "footerEven" };
3702
+ const I = u[F];
3703
+ return I ? { blocks: I, source: F } : null;
3704
+ };
3705
+ if (S.some((u) => cn.some((F) => u[F]))) {
3706
+ const u = new tt();
3707
+ for (const F of L) {
3708
+ const d = S[F.index], p = d.pageWidthPx - d.marginPx.left - d.marginPx.right, M = d.marginPx.left, E = F.index === 0 || S[F.index - 1] !== d, I = Oe[F.index], _ = I % 2 === 0, K = Bt(d, "header", E, _);
3709
+ if (K) {
3710
+ const U = x === "header", Q = we(K.blocks, p, M, I, L.length, u, U), V = jt(d, Q.height);
3711
+ F.header = Q.placed.map((q) => nt(q, V)), F.headerSource = K.source;
3712
+ }
3713
+ const Y = Bt(d, "footer", E, _);
3714
+ if (Y) {
3715
+ const U = x === "footer", Q = we(Y.blocks, p, M, I, L.length, u, U), V = Kt(d, Q.height);
3716
+ F.footer = Q.placed.map((q) => nt(q, V)), F.footerSource = Y.source;
3717
+ }
3718
+ }
3719
+ }
3720
+ return {
3721
+ pages: L,
3722
+ pageWidthPx: e.section.pageWidthPx,
3723
+ pageHeightPx: e.section.pageHeightPx,
3724
+ marginPx: e.section.marginPx
3725
+ };
3726
+ }
3727
+ function ys(e, t) {
3728
+ switch (t) {
3729
+ case "roman":
3730
+ return ye(e, "lowerRoman");
3731
+ case "Roman":
3732
+ return ye(e, "upperRoman");
3733
+ case "alpha":
3734
+ return ye(e, "lowerLetter");
3735
+ case "Alpha":
3736
+ return ye(e, "upperLetter");
3737
+ default:
3738
+ return String(e);
3739
+ }
3740
+ }
3741
+ function un(e, t, n) {
3742
+ return e.replace(/\{page(?::(roman|Roman|alpha|Alpha))?\}/g, (x, i) => ys(t, i)).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" }));
3743
+ }
3744
+ function Is(e, t, n) {
3745
+ const x = (i) => i.runs.some((s) => s.text.includes("{")) ? {
3746
+ ...i,
3747
+ id: `${i.id}@p${t}`,
3748
+ // per-page identity keeps the band prepare-cache honest
3749
+ runs: i.runs.map((s) => ({ ...s, text: un(s.text, t, n) }))
3750
+ } : i;
3751
+ return e.kind === "paragraph" ? x(e) : e.kind === "table" ? {
3752
+ ...e,
3753
+ rows: e.rows.map((i) => ({
3754
+ cells: i.cells.map((s) => ({
3755
+ ...s,
3756
+ blocks: s.blocks.map((o) => o.kind === "paragraph" ? x(o) : o)
3757
+ }))
3758
+ }))
3759
+ } : e;
3760
+ }
3761
+ function we(e, t, n, x, i, s, o) {
3762
+ const a = (l, f) => ln(l, f, s), c = [];
3763
+ let r = 0;
3764
+ for (const l of e) {
3765
+ const f = o ? l : Is(l, x, i);
3766
+ if (f.kind === "paragraph") {
3767
+ r += f.style.spaceBeforePx;
3768
+ const h = a(f, t);
3769
+ c.push({ blockId: f.id, x: n + f.style.indentLeftPx, y: r, firstLineIndex: 0, lines: h }), r += ht(h) + f.style.spaceAfterPx;
3770
+ } else if (f.kind === "image") {
3771
+ const h = t - f.widthPx, g = n + (f.align === "center" ? h / 2 : f.align === "right" ? h : 0);
3772
+ c.push({
3773
+ blockId: f.id,
3774
+ x: g,
3775
+ y: r,
3776
+ firstLineIndex: 0,
3777
+ lines: [],
3778
+ image: { src: f.src, width: f.widthPx, height: f.heightPx }
3779
+ }), r += f.heightPx;
3780
+ } else {
3781
+ const h = ut(f, t, a, Ut);
3782
+ c.push(dt(f, h.rows, h.colWidths, n, r, t, 0, Ut)), r += h.height;
3783
+ }
3784
+ }
3785
+ return { placed: c, height: r };
3786
+ }
3787
+ function nt(e, t) {
3788
+ const n = { ...e, y: e.y + t };
3789
+ return e.table && (n.table = {
3790
+ ...e.table,
3791
+ y: e.table.y + t,
3792
+ rows: e.table.rows.map((x) => ({
3793
+ ...x,
3794
+ y: x.y + t,
3795
+ cells: x.cells.map((i) => ({
3796
+ ...i,
3797
+ y: i.y + t,
3798
+ blocks: i.blocks.map((s) => nt(s, t))
3799
+ }))
3800
+ }))
3801
+ }), n;
3802
+ }
3803
+ const Me = 12, ws = { top: 0, right: 7.2, bottom: 0, left: 7.2 }, hn = (e) => e.margin ?? ws, Ce = 4, Ut = { indentOf: () => 0, markers: /* @__PURE__ */ new Map() };
3804
+ function ut(e, t, n, x) {
3805
+ const s = Dn(e).map((l) => l * t), o = s.length, a = new Array(o).fill(0), c = e.rows.map((l) => {
3806
+ let f = 0;
3807
+ const h = l.cells.map((g) => {
3808
+ for (; f < o && a[f] > 0; ) f++;
3809
+ const A = Math.max(1, g.colSpan ?? 1), m = Math.max(1, g.rowSpan ?? 1), B = f;
3810
+ let C = 0;
3811
+ for (let N = 0; N < A; N++) C += s[f + N] ?? s[o - 1] ?? 40;
3812
+ if (m > 1) for (let N = 0; N < A && f + N < o; N++) a[f + N] = m;
3813
+ f += A;
3814
+ const v = hn(g), H = Math.max(8, C - v.left - v.right);
3815
+ let y = 0;
3816
+ const O = g.blocks.map((N) => {
3817
+ if (N.kind === "paragraph") {
3818
+ const k = H - N.style.indentLeftPx - x.indentOf(N) - (N.style.indentRightPx ?? 0), T = n(N, Math.max(8, k));
3819
+ return y += N.style.spaceBeforePx + ht(T) + N.style.spaceAfterPx, { kind: "para", block: N, lines: T };
3820
+ }
3821
+ if (N.kind === "image") {
3822
+ if (N.anchor) return { kind: "image", block: N, width: N.widthPx, height: N.heightPx };
3823
+ const k = Math.min(1, H / Math.max(1, N.widthPx)), T = N.widthPx * k, G = N.heightPx * k;
3824
+ return y += G + Ce, { kind: "image", block: N, width: T, height: G };
3825
+ }
3826
+ const D = ut(N, H, n, x);
3827
+ return y += D.height + Ce, { kind: "table", block: N, ...D };
3828
+ });
3829
+ return { cell: g, items: O, height: y + v.top + v.bottom, width: C, colStart: B, rowSpan: m };
3830
+ });
3831
+ for (let g = 0; g < o; g++) a[g] > 0 && a[g]--;
3832
+ return { cells: h, height: 0 };
3833
+ }), r = c.map((l) => Math.max(0, ...l.cells.filter((f) => f.rowSpan === 1).map((f) => f.height)));
3834
+ return c.forEach((l, f) => {
3835
+ for (const h of l.cells) {
3836
+ if (h.rowSpan <= 1) continue;
3837
+ const g = Math.min(c.length - 1, f + h.rowSpan - 1);
3838
+ let A = 0;
3839
+ for (let m = f; m <= g; m++) A += r[m];
3840
+ h.height > A && (r[g] += h.height - A);
3841
+ }
3842
+ }), c.forEach((l, f) => l.height = r[f]), { rows: c, colWidths: s, height: r.reduce((l, f) => l + f, 0) };
3843
+ }
3844
+ function ht(e) {
3845
+ let t = 0;
3846
+ for (const n of e) t += n.height;
3847
+ return t;
3848
+ }
3849
+ function dt(e, t, n, x, i, s, o, a) {
3850
+ const c = [0];
3851
+ for (const h of n) c.push(c[c.length - 1] + h);
3852
+ const r = [i];
3853
+ for (const h of t) r.push(r[r.length - 1] + h.height);
3854
+ const l = [];
3855
+ for (let h = 0; h < t.length; h++) {
3856
+ const g = t[h], A = r[h], m = [];
3857
+ for (const B of g.cells) {
3858
+ const C = x + (c[B.colStart] ?? c[c.length - 1]), v = Math.min(t.length - 1, h + B.rowSpan - 1), H = r[v + 1] - A, y = [], O = hn(B.cell), N = B.width - O.left - O.right;
3859
+ let D = A + O.top;
3860
+ for (const k of B.items)
3861
+ if (k.kind === "para") {
3862
+ D += k.block.style.spaceBeforePx;
3863
+ const T = C + O.left + k.block.style.indentLeftPx + a.indentOf(k.block), G = {
3864
+ blockId: k.block.id,
3865
+ x: T,
3866
+ y: D,
3867
+ firstLineIndex: 0,
3868
+ lines: k.lines
3869
+ // line.y is already block-relative; coords stay consistent
3870
+ }, w = a.markers.get(k.block.id);
3871
+ w && (G.marker = { text: w.text, style: w.style, x: Math.max(C + 1, T - w.hangingPx) }), y.push(G), D += ht(k.lines) + k.block.style.spaceAfterPx;
3872
+ } else if (k.kind === "image") {
3873
+ const T = k.block.anchor;
3874
+ if (T) {
3875
+ const w = {
3876
+ src: k.block.src,
3877
+ width: k.block.widthPx,
3878
+ height: k.block.heightPx,
3879
+ z: T.z ?? 0
3880
+ };
3881
+ T.behind ? w.behind = !0 : w.front = !0, y.push({
3882
+ blockId: k.block.id,
3883
+ x: C + O.left + T.offsetXPx,
3884
+ y: A + O.top + T.offsetYPx,
3885
+ firstLineIndex: 0,
3886
+ lines: [],
3887
+ image: w
3888
+ });
3889
+ continue;
3890
+ }
3891
+ const G = H - O.top - O.bottom;
3892
+ if (B.items.length === 1 && G > k.height + 8) {
3893
+ const w = Math.max(N / k.block.widthPx, G / k.block.heightPx), j = k.block.widthPx * w, z = k.block.heightPx * w, b = C + O.left, S = A + O.top;
3894
+ y.push({
3895
+ blockId: k.block.id,
3896
+ x: b + (N - j) / 2,
3897
+ y: S + (G - z) / 2,
3898
+ firstLineIndex: 0,
3899
+ lines: [],
3900
+ image: { src: k.block.src, width: j, height: z, clip: { x: b, y: S, width: N, height: G } }
3901
+ }), D += k.height + Ce;
3902
+ } else {
3903
+ const w = N - k.width, j = C + O.left + (k.block.align === "center" ? w / 2 : k.block.align === "right" ? w : 0);
3904
+ y.push({
3905
+ blockId: k.block.id,
3906
+ x: j,
3907
+ y: D,
3908
+ firstLineIndex: 0,
3909
+ lines: [],
3910
+ image: { src: k.block.src, width: k.width, height: k.height }
3911
+ }), D += k.height + Ce;
3912
+ }
3913
+ } else
3914
+ y.push(dt(k.block, k.rows, k.colWidths, C + O.left, D, N, 0, a)), D += k.height + Ce;
3915
+ m.push({
3916
+ x: C,
3917
+ y: A,
3918
+ width: B.width,
3919
+ height: H,
3920
+ originRow: o + h,
3921
+ originCol: B.colStart,
3922
+ blocks: y,
3923
+ ...B.cell.shading !== void 0 ? { shading: B.cell.shading } : {},
3924
+ ...B.cell.borders !== void 0 ? { borders: B.cell.borders } : {},
3925
+ // Horizontal content band (full cell height): clips over-wide text to the
3926
+ // inner box so it never paints onto the border or into the next column.
3927
+ contentClip: { x: C + O.left, y: A, width: N, height: H }
3928
+ });
3929
+ }
3930
+ l.push({ y: A, height: g.height, cells: m });
3931
+ }
3932
+ const f = t.reduce((h, g) => h + g.height, 0);
3933
+ return {
3934
+ blockId: e.id,
3935
+ x,
3936
+ y: i,
3937
+ firstLineIndex: o,
3938
+ // for tables this is the chunk's first ROW index
3939
+ lines: [],
3940
+ table: { x, y: i, width: s, height: f, rows: l, colWidths: n }
3941
+ };
3942
+ }
3943
+ const Ts = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3944
+ __proto__: null,
3945
+ createLayoutEngine: As,
3946
+ effectiveSection: an,
3947
+ resolveSections: fn
3948
+ }, Symbol.toStringTag, { value: "Module" }));
3949
+ function Ps(e) {
3950
+ const t = /* @__PURE__ */ new Map(), n = (x, i) => {
3951
+ for (const s of x)
3952
+ if (t.has(s.blockId) || t.set(s.blockId, i), s.table) for (const o of s.table.rows) for (const a of o.cells) n(a.blocks, i);
3953
+ };
3954
+ for (const x of e.pages) n(x.blocks, x.number);
3955
+ return t;
3956
+ }
3957
+ function Gs(e, t) {
3958
+ const n = Ps(t), x = [];
3959
+ for (const i of e.blocks) {
3960
+ if (i.kind !== "paragraph") continue;
3961
+ const s = i.runs.find((f) => f.style.link?.startsWith("#"))?.style.link?.slice(1);
3962
+ if (!s) continue;
3963
+ const o = e.bookmarks?.[s]?.start.blockId;
3964
+ if (!o) continue;
3965
+ const a = n.get(o);
3966
+ if (a === void 0) continue;
3967
+ const c = bn(i.runs), r = c.match(/\t(\d+)(\s*)$/);
3968
+ if (!r || r[1] === String(a)) continue;
3969
+ const l = c.length - r[2].length - r[1].length;
3970
+ x.push({
3971
+ blockId: i.id,
3972
+ start: l,
3973
+ end: l + r[1].length,
3974
+ text: String(a),
3975
+ style: Ln(i.runs, l) ?? i.runs[0]?.style
3976
+ });
3977
+ }
3978
+ return x;
3979
+ }
3980
+ export {
3981
+ Gs as a,
3982
+ As as c,
3983
+ Ts as e,
3984
+ Ps as p
3985
+ };