@forevka/wordcanvas 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +48 -1
  2. package/dist-lib/assets/{worker-BsOsK39A.js → worker-D8rUOKfg.js} +9603 -9451
  3. package/dist-lib/assets/worker-wXuuyshQ.js +2258 -0
  4. package/dist-lib/{blockFactory-Bcy0U40y.js → blockFactory-CUI4Rqiq.js} +50 -42
  5. package/dist-lib/{browser-5Sv4CuNy.js → browser-DkKxreJM.js} +404 -383
  6. package/dist-lib/builder.js +364 -109
  7. package/dist-lib/editorApp-DLXMmtu5.js +8023 -0
  8. package/dist-lib/export.js +3820 -3768
  9. package/dist-lib/generate-toc.js +4 -4
  10. package/dist-lib/import.js +4 -1538
  11. package/dist-lib/{lists-BegzmTmD.js → lists-Sc5I40JO.js} +2 -2
  12. package/dist-lib/pipeline-CbxmCE84.js +1705 -0
  13. package/dist-lib/recalc-docx.js +2 -2
  14. package/dist-lib/recalcToc-g1hFKSNs.js +3935 -0
  15. package/dist-lib/toc-B6VpkJge.js +213 -0
  16. package/dist-lib/{webmcp-B7Gvd58E.js → webmcp-6WxRNKCc.js} +2 -2
  17. package/dist-lib/{wordcanvas-BAxBeErX.js → wordcanvas-CFqpDK0k.js} +1 -1
  18. package/dist-lib/wordcanvas.js +1 -1
  19. package/dist-node/{chunk-GXFDF7UY.js → chunk-22JHAERT.js} +95 -23
  20. package/dist-node/chunk-22JHAERT.js.map +7 -0
  21. package/dist-node/{chunk-2RCPB7UZ.js → chunk-6AJJMHKY.js} +1 -1
  22. package/dist-node/chunk-6AJJMHKY.js.map +7 -0
  23. package/dist-node/{chunk-XDUDPPJW.js → chunk-CDN6WU2P.js} +89 -26
  24. package/dist-node/chunk-CDN6WU2P.js.map +7 -0
  25. package/dist-node/{chunk-TBSXA2I4.js → chunk-EGSAVPCC.js} +1 -1
  26. package/dist-node/chunk-EGSAVPCC.js.map +7 -0
  27. package/dist-node/{chunk-IJLL6IFJ.js → chunk-RNB336F3.js} +116 -5
  28. package/dist-node/{chunk-IJLL6IFJ.js.map → chunk-RNB336F3.js.map} +2 -2
  29. package/dist-node/{engine-FRCX7PXF.js → engine-5FGDJD2H.js} +3 -3
  30. package/dist-node/export.js +92 -31
  31. package/dist-node/export.js.map +2 -2
  32. package/dist-node/generate-toc.js +5 -5
  33. package/dist-node/import.js +3 -3
  34. package/dist-node/recalc-docx.js +4 -4
  35. package/dist-node/recalc-docx.js.map +1 -1
  36. package/package.json +1 -1
  37. package/types/model.d.ts +231 -225
  38. package/types/recalc-docx.d.ts +27 -27
  39. package/dist-lib/assets/worker-BbFAIxdy.js +0 -2163
  40. package/dist-lib/editorApp-DvjFPHiy.js +0 -7582
  41. package/dist-lib/recalcToc-uaLWt59L.js +0 -3835
  42. package/dist-lib/toc-CZel_Kk3.js +0 -127
  43. package/dist-node/chunk-2RCPB7UZ.js.map +0 -7
  44. package/dist-node/chunk-GXFDF7UY.js.map +0 -7
  45. package/dist-node/chunk-TBSXA2I4.js.map +0 -7
  46. package/dist-node/chunk-XDUDPPJW.js.map +0 -7
  47. /package/dist-node/{engine-FRCX7PXF.js.map → engine-5FGDJD2H.js.map} +0 -0
@@ -0,0 +1,3935 @@
1
+ import { r as Mn, F as Cn, t as kn, f as Dn } from "./browser-DkKxreJM.js";
2
+ import { e as Ln, f as Oe } from "./lists-Sc5I40JO.js";
3
+ import { m as ce, q as Pe, t as we } from "./metrics-CkAo4zh8.js";
4
+ const bn = [
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
+ ], Et = [
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 On(e) {
978
+ if (e <= 255)
979
+ return bn[e];
980
+ let t = 0, n = Et.length - 1;
981
+ for (; t <= n; ) {
982
+ const r = t + n >> 1, i = Et[r];
983
+ if (e < i[0]) {
984
+ n = r - 1;
985
+ continue;
986
+ }
987
+ if (e > i[1]) {
988
+ t = r + 1;
989
+ continue;
990
+ }
991
+ return i[2];
992
+ }
993
+ return "L";
994
+ }
995
+ function yn(e) {
996
+ const t = e.length;
997
+ if (t === 0)
998
+ return null;
999
+ const n = new Array(t);
1000
+ let r = !1;
1001
+ for (let x = 0; x < t; ) {
1002
+ const c = e.charCodeAt(x);
1003
+ let f = c, u = 1;
1004
+ if (c >= 55296 && c <= 56319 && x + 1 < t) {
1005
+ const S = e.charCodeAt(x + 1);
1006
+ S >= 56320 && S <= 57343 && (f = (c - 55296 << 10) + (S - 56320) + 65536, u = 2);
1007
+ }
1008
+ const g = On(f);
1009
+ (g === "R" || g === "AL" || g === "AN") && (r = !0);
1010
+ for (let S = 0; S < u; S++)
1011
+ n[x + S] = g;
1012
+ x += u;
1013
+ }
1014
+ if (!r)
1015
+ return null;
1016
+ let i = 0;
1017
+ for (let x = 0; x < t; x++) {
1018
+ const c = n[x];
1019
+ if (c === "L") {
1020
+ i = 0;
1021
+ break;
1022
+ }
1023
+ if (c === "R" || c === "AL") {
1024
+ i = 1;
1025
+ break;
1026
+ }
1027
+ }
1028
+ const s = new Int8Array(t);
1029
+ for (let x = 0; x < t; x++)
1030
+ s[x] = i;
1031
+ const o = i & 1 ? "R" : "L", a = o;
1032
+ let l = a;
1033
+ for (let x = 0; x < t; x++)
1034
+ n[x] === "NSM" ? n[x] = l : l = n[x];
1035
+ l = a;
1036
+ for (let x = 0; x < t; x++) {
1037
+ const c = n[x];
1038
+ c === "EN" ? n[x] = l === "AL" ? "AN" : "EN" : (c === "R" || c === "L" || c === "AL") && (l = c);
1039
+ }
1040
+ for (let x = 0; x < t; x++)
1041
+ n[x] === "AL" && (n[x] = "R");
1042
+ for (let x = 1; x < t - 1; x++)
1043
+ n[x] === "ES" && n[x - 1] === "EN" && n[x + 1] === "EN" && (n[x] = "EN"), n[x] === "CS" && (n[x - 1] === "EN" || n[x - 1] === "AN") && n[x + 1] === n[x - 1] && (n[x] = n[x - 1]);
1044
+ for (let x = 0; x < t; x++) {
1045
+ if (n[x] !== "EN")
1046
+ continue;
1047
+ let c;
1048
+ for (c = x - 1; c >= 0 && n[c] === "ET"; c--)
1049
+ n[c] = "EN";
1050
+ for (c = x + 1; c < t && n[c] === "ET"; c++)
1051
+ n[c] = "EN";
1052
+ }
1053
+ for (let x = 0; x < t; x++) {
1054
+ const c = n[x];
1055
+ (c === "WS" || c === "ES" || c === "ET" || c === "CS") && (n[x] = "ON");
1056
+ }
1057
+ l = a;
1058
+ for (let x = 0; x < t; x++) {
1059
+ const c = n[x];
1060
+ c === "EN" ? n[x] = l === "L" ? "L" : "EN" : (c === "R" || c === "L") && (l = c);
1061
+ }
1062
+ for (let x = 0; x < t; x++) {
1063
+ if (n[x] !== "ON")
1064
+ continue;
1065
+ let c = x + 1;
1066
+ for (; c < t && n[c] === "ON"; )
1067
+ c++;
1068
+ const f = x > 0 ? n[x - 1] : a, u = c < t ? n[c] : a, g = f !== "L" ? "R" : "L";
1069
+ if (g === (u !== "L" ? "R" : "L"))
1070
+ for (let E = x; E < c; E++)
1071
+ n[E] = g;
1072
+ x = c - 1;
1073
+ }
1074
+ for (let x = 0; x < t; x++)
1075
+ n[x] === "ON" && (n[x] = o);
1076
+ for (let x = 0; x < t; x++) {
1077
+ const c = n[x];
1078
+ (s[x] & 1) === 0 ? c === "R" ? s[x]++ : (c === "AN" || c === "EN") && (s[x] += 2) : (c === "L" || c === "AN" || c === "EN") && s[x]++;
1079
+ }
1080
+ return s;
1081
+ }
1082
+ function In(e, t) {
1083
+ const n = yn(e);
1084
+ if (n === null)
1085
+ return null;
1086
+ const r = new Int8Array(t.length);
1087
+ for (let i = 0; i < t.length; i++)
1088
+ r[i] = n[t[i]];
1089
+ return r;
1090
+ }
1091
+ const Pn = /[ \t\n\r\f]+/g, wn = /[\t\n\r\f]| {2,}|^ | $/;
1092
+ function Wn(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 vn(e) {
1097
+ if (!wn.test(e))
1098
+ return e;
1099
+ let t = e.replace(Pn, " ");
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 Rn(e) {
1103
+ return /[\r\f]/.test(e) ? e.replace(/\r\n/g, `
1104
+ `).replace(/[\r\f]/g, `
1105
+ `) : e;
1106
+ }
1107
+ let Ke = null, Tn;
1108
+ function Gn() {
1109
+ return Ke === null && (Ke = new Intl.Segmenter(Tn, { granularity: "word" })), Ke;
1110
+ }
1111
+ const Hn = /\p{Script=Arabic}/u, Ne = /\p{M}/u, nt = /\p{Nd}/u;
1112
+ function Bt(e) {
1113
+ return Hn.test(e);
1114
+ }
1115
+ function Mt(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 oe(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 r = e.charCodeAt(t + 1);
1124
+ if (r >= 56320 && r <= 57343) {
1125
+ const i = (n - 55296 << 10) + (r - 56320) + 65536;
1126
+ if (Mt(i))
1127
+ return !0;
1128
+ t++;
1129
+ continue;
1130
+ }
1131
+ }
1132
+ if (Mt(n))
1133
+ return !0;
1134
+ }
1135
+ }
1136
+ return !1;
1137
+ }
1138
+ function _n(e) {
1139
+ const t = De(e);
1140
+ return t !== null && (st.has(t) || ge.has(t));
1141
+ }
1142
+ const zn = /* @__PURE__ */ new Set([
1143
+ " ",
1144
+ " ",
1145
+ "⁠",
1146
+ "\uFEFF"
1147
+ ]), jn = /* @__PURE__ */ new Set([
1148
+ "-",
1149
+ "‐",
1150
+ "–",
1151
+ "—"
1152
+ ]);
1153
+ function Kn(e) {
1154
+ const t = De(e);
1155
+ return t !== null && zn.has(t);
1156
+ }
1157
+ function Un(e) {
1158
+ const t = De(e);
1159
+ return t !== null && jn.has(t);
1160
+ }
1161
+ function Kt(e, t) {
1162
+ return Kn(e) ? !1 : t ? !(_n(e) || Un(e)) : !0;
1163
+ }
1164
+ const st = /* @__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
+ ]), Te = /* @__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
+ ]), it = /* @__PURE__ */ new Set([
1216
+ "'",
1217
+ "’"
1218
+ ]), ge = /* @__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
+ ]), Jn = /* @__PURE__ */ new Set([
1246
+ ":",
1247
+ ".",
1248
+ "،",
1249
+ "؛"
1250
+ ]), Qn = /* @__PURE__ */ new Set([
1251
+ "၏"
1252
+ ]), $n = /* @__PURE__ */ new Set([
1253
+ "”",
1254
+ "’",
1255
+ "»",
1256
+ "›",
1257
+ "」",
1258
+ "』",
1259
+ "】",
1260
+ "》",
1261
+ "〉",
1262
+ "〕",
1263
+ ")"
1264
+ ]);
1265
+ function Yn(e) {
1266
+ if (rt(e))
1267
+ return !0;
1268
+ let t = !1;
1269
+ for (const n of e) {
1270
+ if (ge.has(n) || He(n)) {
1271
+ t = !0;
1272
+ continue;
1273
+ }
1274
+ if (!(t && Ne.test(n)))
1275
+ return !1;
1276
+ }
1277
+ return t;
1278
+ }
1279
+ function Xn(e) {
1280
+ for (const t of e)
1281
+ if (!st.has(t) && !ge.has(t))
1282
+ return !1;
1283
+ return e.length > 0;
1284
+ }
1285
+ function qn(e) {
1286
+ if (rt(e))
1287
+ return !0;
1288
+ for (const t of e)
1289
+ if (!Te.has(t) && !it.has(t) && !Ne.test(t) && !He(t))
1290
+ return !1;
1291
+ return e.length > 0;
1292
+ }
1293
+ function rt(e) {
1294
+ let t = !1;
1295
+ for (const n of e)
1296
+ if (!(n === "\\" || Ne.test(n))) {
1297
+ if (Te.has(n) || ge.has(n) || it.has(n)) {
1298
+ t = !0;
1299
+ continue;
1300
+ }
1301
+ return !1;
1302
+ }
1303
+ return t;
1304
+ }
1305
+ function Ge(e, t) {
1306
+ const n = t - 1;
1307
+ if (n <= 0)
1308
+ return Math.max(n, 0);
1309
+ const r = e.charCodeAt(n);
1310
+ if (r < 56320 || r > 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 De(e) {
1319
+ if (e.length === 0)
1320
+ return null;
1321
+ const t = Ge(e, e.length);
1322
+ return e.slice(t);
1323
+ }
1324
+ function Vn(e) {
1325
+ for (const t of e)
1326
+ if (!Ne.test(t))
1327
+ return t;
1328
+ return null;
1329
+ }
1330
+ function Zn(e) {
1331
+ for (let t = e.length; t > 0; ) {
1332
+ const n = Ge(e, t), r = e.slice(n, t);
1333
+ if (!Ne.test(r))
1334
+ return r;
1335
+ t = n;
1336
+ }
1337
+ return null;
1338
+ }
1339
+ const e0 = [
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 t0(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 He(e) {
1414
+ const t = e.codePointAt(0);
1415
+ return t !== void 0 && t0(t, e0);
1416
+ }
1417
+ function n0(e) {
1418
+ const t = Zn(e);
1419
+ return t !== null && He(t);
1420
+ }
1421
+ function s0(e) {
1422
+ const t = Vn(e);
1423
+ return t !== null && nt.test(t);
1424
+ }
1425
+ function i0(e) {
1426
+ const t = Array.from(e);
1427
+ let n = t.length;
1428
+ for (; n > 0; ) {
1429
+ const r = t[n - 1];
1430
+ if (Ne.test(r)) {
1431
+ n--;
1432
+ continue;
1433
+ }
1434
+ if (Te.has(r) || it.has(r)) {
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 r0(e, t, n) {
1446
+ return n === "text" && !t && e.length === 1 && e !== "-" && e !== "—" ? e : null;
1447
+ }
1448
+ function Ct(e, t, n, r) {
1449
+ const i = t[r], s = e[r];
1450
+ if (i == null)
1451
+ return s;
1452
+ const o = n[r];
1453
+ if (s.length === o)
1454
+ return s;
1455
+ const a = i.repeat(o);
1456
+ return e[r] = a, a;
1457
+ }
1458
+ function kt(e, t) {
1459
+ return e && t !== null && Jn.has(t);
1460
+ }
1461
+ function x0(e) {
1462
+ const t = De(e);
1463
+ return t !== null && Qn.has(t);
1464
+ }
1465
+ function o0(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 Xe(e) {
1472
+ let t = e.length;
1473
+ for (; t > 0; ) {
1474
+ const n = Ge(e, t), r = e.slice(n, t);
1475
+ if ($n.has(r))
1476
+ return !0;
1477
+ if (!ge.has(r))
1478
+ return !1;
1479
+ t = n;
1480
+ }
1481
+ return !1;
1482
+ }
1483
+ function l0(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 c0 = /[\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 a0(e, t) {
1500
+ const n = [];
1501
+ for (let r = e.length - 1; r >= 0; r--)
1502
+ n.push(e[r]);
1503
+ return n.push(t), re(n);
1504
+ }
1505
+ function f0(e, t, n, r) {
1506
+ if (!c0.test(e))
1507
+ return [{ text: e, isWordLike: t, kind: "text", start: n }];
1508
+ const i = [];
1509
+ let s = null, o = [], a = n, l = !1, x = 0;
1510
+ for (const c of e) {
1511
+ const f = l0(c, r), u = f === "text" && t;
1512
+ if (s !== null && f === s && u === l) {
1513
+ o.push(c), x += c.length;
1514
+ continue;
1515
+ }
1516
+ s !== null && i.push({
1517
+ text: re(o),
1518
+ isWordLike: l,
1519
+ kind: s,
1520
+ start: a
1521
+ }), s = f, o = [c], a = n + x, l = u, x += c.length;
1522
+ }
1523
+ return s !== null && i.push({
1524
+ text: re(o),
1525
+ isWordLike: l,
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 u0 = /^[A-Za-z][A-Za-z0-9+.-]*:$/;
1534
+ function h0(e, t) {
1535
+ const n = e.texts[t];
1536
+ return n.startsWith("www.") ? !0 : u0.test(n) && t + 1 < e.len && e.kinds[t + 1] === "text" && e.texts[t + 1] === "//";
1537
+ }
1538
+ function d0(e) {
1539
+ return e.includes("?") && (e.includes("://") || e.startsWith("www."));
1540
+ }
1541
+ function F0(e) {
1542
+ const t = e.texts.slice(), n = e.isWordLike.slice(), r = e.kinds.slice(), i = e.starts.slice();
1543
+ for (let o = 0; o < e.len; o++) {
1544
+ if (r[o] !== "text" || !h0(e, o))
1545
+ continue;
1546
+ const a = [t[o]];
1547
+ let l = o + 1;
1548
+ for (; l < e.len && !qe(r[l]); ) {
1549
+ a.push(t[l]), n[o] = !0;
1550
+ const x = t[l].includes("?");
1551
+ if (r[l] = "text", t[l] = "", l++, x)
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], r[s] = r[o], i[s] = i[o]), s++);
1560
+ }
1561
+ return t.length = s, n.length = s, r.length = s, i.length = s, {
1562
+ len: s,
1563
+ texts: t,
1564
+ isWordLike: n,
1565
+ kinds: r,
1566
+ starts: i
1567
+ };
1568
+ }
1569
+ function g0(e) {
1570
+ const t = [], n = [], r = [], 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]), r.push(e.kinds[s]), i.push(e.starts[s]), !d0(o))
1574
+ continue;
1575
+ const a = s + 1;
1576
+ if (a >= e.len || qe(e.kinds[a]))
1577
+ continue;
1578
+ const l = [], x = e.starts[a];
1579
+ let c = a;
1580
+ for (; c < e.len && !qe(e.kinds[c]); )
1581
+ l.push(e.texts[c]), c++;
1582
+ l.length > 0 && (t.push(re(l)), n.push(!0), r.push("text"), i.push(x), s = c - 1);
1583
+ }
1584
+ return {
1585
+ len: t.length,
1586
+ texts: t,
1587
+ isWordLike: n,
1588
+ kinds: r,
1589
+ starts: i
1590
+ };
1591
+ }
1592
+ const N0 = /* @__PURE__ */ new Set([
1593
+ ":",
1594
+ "-",
1595
+ "/",
1596
+ "×",
1597
+ ",",
1598
+ ".",
1599
+ "+",
1600
+ "–",
1601
+ "—"
1602
+ ]), p0 = /* @__PURE__ */ new Set([".", ",", ":", ";"]);
1603
+ function Dt(e) {
1604
+ for (let t = e.length; t > 0; ) {
1605
+ const n = Ge(e, t), r = e.slice(n, t);
1606
+ if (Ne.test(r)) {
1607
+ t = n;
1608
+ continue;
1609
+ }
1610
+ return p0.has(r) || He(r);
1611
+ }
1612
+ return !1;
1613
+ }
1614
+ function S0(e, t) {
1615
+ return t && !oe(e);
1616
+ }
1617
+ function Ut(e) {
1618
+ for (const t of e)
1619
+ if (nt.test(t))
1620
+ return !0;
1621
+ return !1;
1622
+ }
1623
+ function We(e) {
1624
+ if (e.length === 0)
1625
+ return !1;
1626
+ for (const t of e)
1627
+ if (!(nt.test(t) || N0.has(t)))
1628
+ return !1;
1629
+ return !0;
1630
+ }
1631
+ function m0(e) {
1632
+ const t = [], n = [], r = [], i = [];
1633
+ for (let s = 0; s < e.len; s++) {
1634
+ const o = e.texts[s], a = e.kinds[s];
1635
+ if (a === "text" && We(o) && Ut(o)) {
1636
+ const l = [o];
1637
+ let x = s + 1;
1638
+ for (; x < e.len && e.kinds[x] === "text" && We(e.texts[x]); )
1639
+ l.push(e.texts[x]), x++;
1640
+ t.push(re(l)), n.push(!0), r.push("text"), i.push(e.starts[s]), s = x - 1;
1641
+ continue;
1642
+ }
1643
+ t.push(o), n.push(e.isWordLike[s]), r.push(a), i.push(e.starts[s]);
1644
+ }
1645
+ return {
1646
+ len: t.length,
1647
+ texts: t,
1648
+ isWordLike: n,
1649
+ kinds: r,
1650
+ starts: i
1651
+ };
1652
+ }
1653
+ function A0(e) {
1654
+ const t = [], n = [], r = [], i = [];
1655
+ for (let s = 0; s < e.len; s++) {
1656
+ const o = e.texts[s], a = e.kinds[s], l = e.isWordLike[s];
1657
+ if (a === "text" && Dt(o) && (l || n0(o)) && !oe(o)) {
1658
+ const x = [o];
1659
+ let c = !0, f = s + 1;
1660
+ for (; c && f < e.len && e.kinds[f] === "text" && S0(e.texts[f], e.isWordLike[f]); ) {
1661
+ const u = e.texts[f];
1662
+ x.push(u), c = Dt(u), f++;
1663
+ }
1664
+ t.push(re(x)), n.push(!0), r.push("text"), i.push(e.starts[s]), s = f - 1;
1665
+ continue;
1666
+ }
1667
+ t.push(o), n.push(l), r.push(a), i.push(e.starts[s]);
1668
+ }
1669
+ return {
1670
+ len: t.length,
1671
+ texts: t,
1672
+ isWordLike: n,
1673
+ kinds: r,
1674
+ starts: i
1675
+ };
1676
+ }
1677
+ function E0(e) {
1678
+ const t = [], n = [], r = [], 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 l = a.length > 1;
1684
+ for (let x = 0; x < a.length; x++) {
1685
+ const c = a[x];
1686
+ if (!l)
1687
+ break;
1688
+ (c.length === 0 || !Ut(c) || !We(c)) && (l = !1);
1689
+ }
1690
+ if (l) {
1691
+ let x = 0;
1692
+ for (let c = 0; c < a.length; c++) {
1693
+ const f = a[c], u = c < a.length - 1 ? `${f}-` : f;
1694
+ t.push(u), n.push(!0), r.push("text"), i.push(e.starts[s] + x), x += u.length;
1695
+ }
1696
+ continue;
1697
+ }
1698
+ }
1699
+ t.push(o), n.push(e.isWordLike[s]), r.push(e.kinds[s]), i.push(e.starts[s]);
1700
+ }
1701
+ return {
1702
+ len: t.length,
1703
+ texts: t,
1704
+ isWordLike: n,
1705
+ kinds: r,
1706
+ starts: i
1707
+ };
1708
+ }
1709
+ function B0(e) {
1710
+ const t = [], n = [], r = [], i = [];
1711
+ let s = 0;
1712
+ for (; s < e.len; ) {
1713
+ const o = [e.texts[s]];
1714
+ let a = e.isWordLike[s], l = e.kinds[s], x = e.starts[s];
1715
+ if (l === "glue") {
1716
+ const c = [o[0]], f = x;
1717
+ for (s++; s < e.len && e.kinds[s] === "glue"; )
1718
+ c.push(e.texts[s]), s++;
1719
+ const u = re(c);
1720
+ if (s < e.len && e.kinds[s] === "text")
1721
+ o[0] = u, o.push(e.texts[s]), a = e.isWordLike[s], l = "text", x = f, s++;
1722
+ else {
1723
+ t.push(u), n.push(!1), r.push("glue"), i.push(f);
1724
+ continue;
1725
+ }
1726
+ } else
1727
+ s++;
1728
+ if (l === "text")
1729
+ for (; s < e.len && e.kinds[s] === "glue"; ) {
1730
+ const c = [];
1731
+ for (; s < e.len && e.kinds[s] === "glue"; )
1732
+ c.push(e.texts[s]), s++;
1733
+ const f = re(c);
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), r.push(l), i.push(x);
1741
+ }
1742
+ return {
1743
+ len: t.length,
1744
+ texts: t,
1745
+ isWordLike: n,
1746
+ kinds: r,
1747
+ starts: i
1748
+ };
1749
+ }
1750
+ function M0(e) {
1751
+ const t = e.texts.slice(), n = e.isWordLike.slice(), r = e.kinds.slice(), i = e.starts.slice();
1752
+ for (let s = 0; s < t.length - 1; s++) {
1753
+ if (r[s] !== "text" || r[s + 1] !== "text" || !oe(t[s]) || !oe(t[s + 1]))
1754
+ continue;
1755
+ const o = i0(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: r,
1763
+ starts: i
1764
+ };
1765
+ }
1766
+ function C0(e, t, n) {
1767
+ const r = Gn();
1768
+ let i = 0;
1769
+ const s = [], o = [], a = [], l = [], x = [], c = [], f = [], u = [], g = [], S = [], E = [], m = [];
1770
+ for (const N of r.segment(e))
1771
+ for (const b of f0(N.segment, N.isWordLike ?? !1, N.index, n)) {
1772
+ let I = function() {
1773
+ c[A] !== null && (o[A] = [
1774
+ Ct(s, c, f, A)
1775
+ ], c[A] = null), o[A].push(b.text), a[A] = a[A] || b.isWordLike, u[A] = u[A] || W, g[A] = g[A] || v, S[A] = z, E[A] = D, m[A] = kt(g[A], _);
1776
+ };
1777
+ const M = b.kind === "text", G = r0(b.text, b.isWordLike, b.kind), W = oe(b.text), v = Bt(b.text), _ = De(b.text), z = Xe(b.text), D = x0(b.text), A = i - 1;
1778
+ t.carryCJKAfterClosingQuote && M && i > 0 && l[A] === "text" && W && u[A] && S[A] || M && i > 0 && l[A] === "text" && Xn(b.text) && u[A] || M && i > 0 && l[A] === "text" && E[A] ? I() : M && i > 0 && l[A] === "text" && b.isWordLike && v && m[A] ? (I(), a[A] = !0) : G !== null && i > 0 && l[A] === "text" && c[A] === G ? f[A] = (f[A] ?? 1) + 1 : M && !b.isWordLike && i > 0 && l[A] === "text" && !u[A] && (Yn(b.text) || b.text === "-" && a[A]) ? I() : (s[i] = b.text, o[i] = [b.text], a[i] = b.isWordLike, l[i] = b.kind, x[i] = b.start, c[i] = G, f[i] = G === null ? 0 : 1, u[i] = W, g[i] = v, S[i] = z, E[i] = D, m[i] = kt(v, _), i++);
1779
+ }
1780
+ for (let N = 0; N < i; N++) {
1781
+ if (c[N] !== null) {
1782
+ s[N] = Ct(s, c, f, N);
1783
+ continue;
1784
+ }
1785
+ s[N] = re(o[N]);
1786
+ }
1787
+ for (let N = 1; N < i; N++)
1788
+ l[N] === "text" && !a[N] && rt(s[N]) && l[N - 1] === "text" && !u[N - 1] && (s[N - 1] += s[N], a[N - 1] = a[N - 1] || a[N], s[N] = "");
1789
+ const k = Array.from({ length: i }, () => null);
1790
+ let T = -1;
1791
+ for (let N = i - 1; N >= 0; N--) {
1792
+ const b = s[N];
1793
+ if (b.length !== 0) {
1794
+ if (l[N] === "text" && !a[N] && T >= 0 && l[T] === "text" && (qn(b) || b === "-" && s0(s[T]))) {
1795
+ const M = k[T] ?? [];
1796
+ M.push(b), k[T] = M, x[T] = x[N], s[N] = "";
1797
+ continue;
1798
+ }
1799
+ T = N;
1800
+ }
1801
+ }
1802
+ for (let N = 0; N < i; N++) {
1803
+ const b = k[N];
1804
+ b != null && (s[N] = a0(b, s[N]));
1805
+ }
1806
+ let O = 0;
1807
+ for (let N = 0; N < i; N++) {
1808
+ const b = s[N];
1809
+ b.length !== 0 && (O !== N && (s[O] = b, a[O] = a[N], l[O] = l[N], x[O] = x[N]), O++);
1810
+ }
1811
+ s.length = O, a.length = O, l.length = O, x.length = O;
1812
+ const w = B0({
1813
+ len: O,
1814
+ texts: s,
1815
+ isWordLike: a,
1816
+ kinds: l,
1817
+ starts: x
1818
+ }), R = M0(A0(E0(m0(g0(F0(w))))));
1819
+ for (let N = 0; N < R.len - 1; N++) {
1820
+ const b = o0(R.texts[N]);
1821
+ b !== null && (R.kinds[N] !== "space" && R.kinds[N] !== "preserved-space" || R.kinds[N + 1] !== "text" || !Bt(R.texts[N + 1]) || (R.texts[N] = b.space, R.isWordLike[N] = !1, R.kinds[N] = R.kinds[N] === "preserved-space" ? "preserved-space" : "space", R.texts[N + 1] = b.marks + R.texts[N + 1], R.starts[N + 1] = R.starts[N] + b.space.length));
1822
+ }
1823
+ return R;
1824
+ }
1825
+ function k0(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 r = 0;
1836
+ for (let i = 0; i < e.len; i++)
1837
+ e.kinds[i] === "hard-break" && (n.push({
1838
+ startSegmentIndex: r,
1839
+ endSegmentIndex: i,
1840
+ consumedEndSegmentIndex: i + 1
1841
+ }), r = i + 1);
1842
+ return r < e.len && n.push({
1843
+ startSegmentIndex: r,
1844
+ endSegmentIndex: e.len,
1845
+ consumedEndSegmentIndex: e.len
1846
+ }), n;
1847
+ }
1848
+ function D0(e, t, n) {
1849
+ if (t.len <= 1)
1850
+ return t;
1851
+ const r = [], i = [], s = [], o = [];
1852
+ let a = -1, l = !1;
1853
+ function x(u) {
1854
+ r.push(t.texts[u]), i.push(t.isWordLike[u]), s.push("text"), o.push(t.starts[u]);
1855
+ }
1856
+ function c(u, g) {
1857
+ let S = !1;
1858
+ for (let k = u; k < g; k++)
1859
+ S = S || t.isWordLike[k];
1860
+ const E = t.starts[u], m = g < t.len ? t.starts[g] : e.length;
1861
+ r.push(e.slice(E, m)), i.push(S), s.push("text"), o.push(E);
1862
+ }
1863
+ function f(u) {
1864
+ if (!(a < 0)) {
1865
+ if (l)
1866
+ a + 1 === u ? x(a) : c(a, u);
1867
+ else
1868
+ for (let g = a; g < u; g++)
1869
+ x(g);
1870
+ a = -1, l = !1;
1871
+ }
1872
+ }
1873
+ for (let u = 0; u < t.len; u++) {
1874
+ const g = t.texts[u], S = t.kinds[u];
1875
+ if (S === "text") {
1876
+ a >= 0 && !Kt(t.texts[u - 1], n) && f(u), a < 0 && (a = u), l = l || oe(g);
1877
+ continue;
1878
+ }
1879
+ f(u), r.push(g), i.push(t.isWordLike[u]), s.push(S), o.push(t.starts[u]);
1880
+ }
1881
+ return f(t.len), {
1882
+ len: r.length,
1883
+ texts: r,
1884
+ isWordLike: i,
1885
+ kinds: s,
1886
+ starts: o
1887
+ };
1888
+ }
1889
+ function L0(e, t, n = "normal", r = "normal") {
1890
+ const i = Wn(n), s = i.mode === "pre-wrap" ? Rn(e) : vn(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 = C0(s, t, i), a = r === "keep-all" ? D0(s, o, t.breakKeepAllAfterPunctuation) : o;
1902
+ return {
1903
+ normalized: s,
1904
+ chunks: k0(a, i),
1905
+ ...a
1906
+ };
1907
+ }
1908
+ let Ae = null;
1909
+ const Lt = /* @__PURE__ */ new Map();
1910
+ let Ee = null;
1911
+ const b0 = 96, O0 = /\p{Emoji_Presentation}/u, y0 = /[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;
1912
+ let Ue = null;
1913
+ const bt = /* @__PURE__ */ new Map();
1914
+ function xt() {
1915
+ if (Ae !== null)
1916
+ return Ae;
1917
+ if (typeof OffscreenCanvas < "u")
1918
+ return Ae = new OffscreenCanvas(1, 1).getContext("2d"), Ae;
1919
+ if (typeof document < "u")
1920
+ return Ae = document.createElement("canvas").getContext("2d"), Ae;
1921
+ throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.");
1922
+ }
1923
+ function I0(e) {
1924
+ let t = Lt.get(e);
1925
+ return t || (t = /* @__PURE__ */ new Map(), Lt.set(e, t)), t;
1926
+ }
1927
+ function ue(e, t) {
1928
+ let n = t.get(e);
1929
+ return n === void 0 && (n = {
1930
+ width: xt().measureText(e).width,
1931
+ containsCJK: oe(e)
1932
+ }, t.set(e, n)), n;
1933
+ }
1934
+ function Be() {
1935
+ if (Ee !== null)
1936
+ return Ee;
1937
+ if (typeof navigator > "u")
1938
+ return Ee = {
1939
+ lineFitEpsilon: 5e-3,
1940
+ carryCJKAfterClosingQuote: !1,
1941
+ breakKeepAllAfterPunctuation: !0,
1942
+ preferPrefixWidthsForBreakableRuns: !1,
1943
+ preferEarlySoftHyphenBreak: !1
1944
+ }, Ee;
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/"), r = e.includes("Chrome/") || e.includes("Chromium/") || e.includes("CriOS/") || e.includes("Edg/");
1946
+ return Ee = {
1947
+ lineFitEpsilon: n ? 1 / 64 : 5e-3,
1948
+ carryCJKAfterClosingQuote: r,
1949
+ breakKeepAllAfterPunctuation: !n,
1950
+ preferPrefixWidthsForBreakableRuns: n,
1951
+ preferEarlySoftHyphenBreak: n
1952
+ }, Ee;
1953
+ }
1954
+ function P0(e) {
1955
+ const t = e.match(/(\d+(?:\.\d+)?)\s*px/);
1956
+ return t ? parseFloat(t[1]) : 16;
1957
+ }
1958
+ function Jt() {
1959
+ return Ue === null && (Ue = new Intl.Segmenter(void 0, { granularity: "grapheme" })), Ue;
1960
+ }
1961
+ function w0(e) {
1962
+ return O0.test(e) || e.includes("️");
1963
+ }
1964
+ function W0(e) {
1965
+ return y0.test(e);
1966
+ }
1967
+ function v0(e, t) {
1968
+ let n = bt.get(e);
1969
+ if (n !== void 0)
1970
+ return n;
1971
+ const r = xt();
1972
+ r.font = e;
1973
+ const i = r.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 bt.set(e, n), n;
1981
+ }
1982
+ function R0(e) {
1983
+ let t = 0;
1984
+ const n = Jt();
1985
+ for (const r of n.segment(e))
1986
+ w0(r.segment) && t++;
1987
+ return t;
1988
+ }
1989
+ function T0(e, t) {
1990
+ return t.emojiCount === void 0 && (t.emojiCount = R0(e)), t.emojiCount;
1991
+ }
1992
+ function Fe(e, t, n) {
1993
+ return n === 0 ? t.width : t.width - T0(e, t) * n;
1994
+ }
1995
+ function G0(e, t, n, r, i) {
1996
+ if (t.breakableFitAdvances !== void 0 && t.breakableFitMode === i)
1997
+ return t.breakableFitAdvances;
1998
+ t.breakableFitMode = i;
1999
+ const s = Jt(), o = [];
2000
+ for (const c of s.segment(e))
2001
+ o.push(c.segment);
2002
+ if (o.length <= 1)
2003
+ return t.breakableFitAdvances = null, t.breakableFitAdvances;
2004
+ if (i === "sum-graphemes") {
2005
+ const c = [];
2006
+ for (const f of o) {
2007
+ const u = ue(f, n);
2008
+ c.push(Fe(f, u, r));
2009
+ }
2010
+ return t.breakableFitAdvances = c, t.breakableFitAdvances;
2011
+ }
2012
+ if (i === "pair-context" || o.length > b0) {
2013
+ const c = [];
2014
+ let f = null, u = 0;
2015
+ for (const g of o) {
2016
+ const S = ue(g, n), E = Fe(g, S, r);
2017
+ if (f === null)
2018
+ c.push(E);
2019
+ else {
2020
+ const m = f + g, k = ue(m, n);
2021
+ c.push(Fe(m, k, r) - u);
2022
+ }
2023
+ f = g, u = E;
2024
+ }
2025
+ return t.breakableFitAdvances = c, t.breakableFitAdvances;
2026
+ }
2027
+ const a = [];
2028
+ let l = "", x = 0;
2029
+ for (const c of o) {
2030
+ l += c;
2031
+ const f = ue(l, n), u = Fe(l, f, r);
2032
+ a.push(u - x), x = u;
2033
+ }
2034
+ return t.breakableFitAdvances = a, t.breakableFitAdvances;
2035
+ }
2036
+ function H0(e, t) {
2037
+ const n = xt();
2038
+ n.font = e;
2039
+ const r = I0(e), i = P0(e), s = t ? v0(e, i) : 0;
2040
+ return { cache: r, fontSize: i, emojiCorrection: s };
2041
+ }
2042
+ function _0(e) {
2043
+ return e === "space" || e === "zero-width-break" || e === "soft-hyphen";
2044
+ }
2045
+ function _e(e) {
2046
+ return e === "space" || e === "preserved-space" || e === "tab" || e === "zero-width-break" || e === "soft-hyphen";
2047
+ }
2048
+ function ot(e, t, n = e.widths.length) {
2049
+ for (; t < n; ) {
2050
+ const r = e.kinds[t];
2051
+ if (!_0(r))
2052
+ break;
2053
+ t++;
2054
+ }
2055
+ return t;
2056
+ }
2057
+ function Qt(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 $t(e, t, n) {
2064
+ return e.letterSpacing !== 0 && t && e.spacingGraphemeCounts[n] > 0 ? e.letterSpacing : 0;
2065
+ }
2066
+ function lt(e, t) {
2067
+ return t === 0 ? 0 : e + t;
2068
+ }
2069
+ function z0(e, t) {
2070
+ return e.letterSpacing !== 0 && e.spacingGraphemeCounts[t] > 0 ? e.letterSpacing : 0;
2071
+ }
2072
+ function Yt(e, t, n, r, i) {
2073
+ const s = t === "tab" ? i + z0(e, n) : e.lineEndFitAdvances[n];
2074
+ return lt(r, s);
2075
+ }
2076
+ function ve(e, t, n, r) {
2077
+ const i = t === "tab" ? 0 : e.lineEndFitAdvances[n];
2078
+ return lt(r, i);
2079
+ }
2080
+ function Re(e, t, n, r, i) {
2081
+ const s = t === "tab" ? i : e.lineEndPaintAdvances[n];
2082
+ return lt(r, s);
2083
+ }
2084
+ function Xt(e, t, n) {
2085
+ return e.letterSpacing !== 0 && t ? n + e.letterSpacing : n;
2086
+ }
2087
+ function qt(e, t) {
2088
+ return e.letterSpacing === 0 ? t : t + e.letterSpacing;
2089
+ }
2090
+ function j0(e, t, n, r, i) {
2091
+ if (e.letterSpacing === 0)
2092
+ return 0;
2093
+ if (i > 0)
2094
+ return e.spacingGraphemeCounts[r] > 0 ? e.letterSpacing : 0;
2095
+ for (let s = r - 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 === r - 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 Vt(e, t, n, r, i, s) {
2109
+ return t + j0(e, n, r, i, s);
2110
+ }
2111
+ function K0(e, t) {
2112
+ let n = 0, r = e.chunks.length;
2113
+ for (; n < r; ) {
2114
+ const i = Math.floor((n + r) / 2);
2115
+ t < e.chunks[i].consumedEndSegmentIndex ? r = i : n = i + 1;
2116
+ }
2117
+ return n < e.chunks.length ? n : -1;
2118
+ }
2119
+ function U0(e, t, n) {
2120
+ let r = n.segmentIndex;
2121
+ if (n.graphemeIndex > 0)
2122
+ return t;
2123
+ const i = e.chunks[t];
2124
+ return i.startSegmentIndex === i.endSegmentIndex && r === i.startSegmentIndex || (r < i.startSegmentIndex && (r = i.startSegmentIndex), r = ot(e, r, i.endSegmentIndex), r < i.endSegmentIndex) ? (n.segmentIndex = r, n.graphemeIndex = 0, t) : i.consumedEndSegmentIndex >= e.widths.length ? -1 : (n.segmentIndex = i.consumedEndSegmentIndex, n.graphemeIndex = 0, t + 1);
2125
+ }
2126
+ function J0(e, t) {
2127
+ if (t.segmentIndex >= e.widths.length)
2128
+ return -1;
2129
+ const n = K0(e, t.segmentIndex);
2130
+ return n < 0 ? -1 : U0(e, n, t);
2131
+ }
2132
+ function Q0(e, t, n) {
2133
+ const { widths: r, kinds: i, breakableFitAdvances: s } = e;
2134
+ if (r.length === 0)
2135
+ return 0;
2136
+ const a = Be().lineFitEpsilon, l = t + a;
2137
+ let x = 0, c = 0, f = !1, u = 0, g = 0, S = 0, E = 0, m = -1, k = 0;
2138
+ function T() {
2139
+ m = -1, k = 0;
2140
+ }
2141
+ function O(G = S, W = E, v = c) {
2142
+ x++, n?.(v, u, g, G, W), c = 0, f = !1, T();
2143
+ }
2144
+ function w(G, W) {
2145
+ f = !0, u = G, g = 0, S = G + 1, E = 0, c = W;
2146
+ }
2147
+ function R(G, W, v) {
2148
+ f = !0, u = G, g = W, S = G, E = W + 1, c = v;
2149
+ }
2150
+ function N(G, W) {
2151
+ if (!f) {
2152
+ w(G, W);
2153
+ return;
2154
+ }
2155
+ c += W, S = G + 1, E = 0;
2156
+ }
2157
+ function b(G, W) {
2158
+ const v = s[G];
2159
+ for (let _ = W; _ < v.length; _++) {
2160
+ const z = v[_];
2161
+ f ? c + z > l ? (O(), R(G, _, z)) : (c += z, S = G, E = _ + 1) : R(G, _, z);
2162
+ }
2163
+ f && S === G && E === v.length && (S = G + 1, E = 0);
2164
+ }
2165
+ let M = 0;
2166
+ for (; M < r.length && !(!f && (M = ot(e, M), M >= r.length)); ) {
2167
+ const G = r[M], W = i[M], v = _e(W);
2168
+ if (!f) {
2169
+ G > l && s[M] !== null ? b(M, 0) : w(M, G), v && (m = M + 1, k = c - G), M++;
2170
+ continue;
2171
+ }
2172
+ if (c + G > l) {
2173
+ if (v) {
2174
+ N(M, G), O(M + 1, 0, c - G), M++;
2175
+ continue;
2176
+ }
2177
+ if (m >= 0) {
2178
+ if (S > m || S === m && E > 0) {
2179
+ O();
2180
+ continue;
2181
+ }
2182
+ O(m, 0, k);
2183
+ continue;
2184
+ }
2185
+ if (G > l && s[M] !== null) {
2186
+ O(), b(M, 0), M++;
2187
+ continue;
2188
+ }
2189
+ O();
2190
+ continue;
2191
+ }
2192
+ N(M, G), v && (m = M + 1, k = c - G), M++;
2193
+ }
2194
+ return f && O(), x;
2195
+ }
2196
+ function $0(e, t, n) {
2197
+ if (e.simpleLineWalkFastPath)
2198
+ return Q0(e, t, n);
2199
+ const { widths: r, kinds: i, breakableFitAdvances: s, discretionaryHyphenWidth: o, chunks: a } = e;
2200
+ if (r.length === 0 || a.length === 0)
2201
+ return 0;
2202
+ const l = Be(), x = l.lineFitEpsilon, c = t + x;
2203
+ let f = 0, u = 0, g = !1, S = 0, E = 0, m = 0, k = 0, T = -1, O = 0, w = 0, R = null;
2204
+ function N() {
2205
+ T = -1, O = 0, w = 0, R = null;
2206
+ }
2207
+ function b() {
2208
+ return R === "soft-hyphen" && T === m && k === 0 ? w : u;
2209
+ }
2210
+ function M(A = m, I = k, L) {
2211
+ f++, n !== void 0 && n(Vt(e, L ?? b(), S, E, A, I), S, E, A, I), u = 0, g = !1, N();
2212
+ }
2213
+ function G(A, I) {
2214
+ g = !0, S = A, E = 0, m = A + 1, k = 0, u = I;
2215
+ }
2216
+ function W(A, I, L) {
2217
+ g = !0, S = A, E = I, m = A, k = I + 1, u = L;
2218
+ }
2219
+ function v(A, I) {
2220
+ if (!g) {
2221
+ G(A, I);
2222
+ return;
2223
+ }
2224
+ u += I, m = A + 1, k = 0;
2225
+ }
2226
+ function _(A, I, L, y, U, Q) {
2227
+ if (!I)
2228
+ return;
2229
+ const X = ve(e, A, L, U), te = Re(e, A, L, U, y);
2230
+ T = L + 1, O = u - Q + X, w = u - Q + te, R = A;
2231
+ }
2232
+ function z(A, I) {
2233
+ const L = s[A];
2234
+ for (let y = I; y < L.length; y++) {
2235
+ const U = L[y];
2236
+ if (!g)
2237
+ W(A, y, U);
2238
+ else {
2239
+ const Q = Xt(e, !0, U), X = u + Q;
2240
+ qt(e, X) > c ? (M(), W(A, y, U)) : (u = X, m = A, k = y + 1);
2241
+ }
2242
+ }
2243
+ g && m === A && k === L.length && (m = A + 1, k = 0);
2244
+ }
2245
+ function D(A) {
2246
+ f++, n?.(0, A.startSegmentIndex, 0, A.consumedEndSegmentIndex, 0), N();
2247
+ }
2248
+ for (let A = 0; A < a.length; A++) {
2249
+ const I = a[A];
2250
+ if (I.startSegmentIndex === I.endSegmentIndex) {
2251
+ D(I);
2252
+ continue;
2253
+ }
2254
+ g = !1, u = 0, S = I.startSegmentIndex, E = 0, m = I.startSegmentIndex, k = 0, N();
2255
+ let L = I.startSegmentIndex;
2256
+ for (; L < I.endSegmentIndex && !(!g && (L = ot(e, L, I.endSegmentIndex), L >= I.endSegmentIndex)); ) {
2257
+ const y = i[L], U = _e(y), Q = $t(e, g, L), X = y === "tab" ? Qt(u + Q, e.tabStopAdvance) : r[L], te = Q + X, ne = Yt(e, y, L, Q, X);
2258
+ if (y === "soft-hyphen") {
2259
+ g && (m = L + 1, k = 0, T = L + 1, O = u + o, w = u + o, R = y), L++;
2260
+ continue;
2261
+ }
2262
+ if (!g) {
2263
+ ne > c && s[L] !== null ? z(L, 0) : G(L, X), _(y, U, L, X, Q, te), L++;
2264
+ continue;
2265
+ }
2266
+ if (u + ne > c) {
2267
+ const Z = u + ve(e, y, L, Q), ae = u + Re(e, y, L, Q, X);
2268
+ if (R === "soft-hyphen" && l.preferEarlySoftHyphenBreak && O <= c) {
2269
+ M(T, 0, w);
2270
+ continue;
2271
+ }
2272
+ if (U && Z <= c) {
2273
+ v(L, te), M(L + 1, 0, ae), L++;
2274
+ continue;
2275
+ }
2276
+ if (T >= 0 && O <= c) {
2277
+ if (m > T || m === T && k > 0) {
2278
+ M();
2279
+ continue;
2280
+ }
2281
+ const xe = T;
2282
+ M(xe, 0, w), L = xe;
2283
+ continue;
2284
+ }
2285
+ if (ne > c && s[L] !== null) {
2286
+ M(), z(L, 0), L++;
2287
+ continue;
2288
+ }
2289
+ M();
2290
+ continue;
2291
+ }
2292
+ v(L, te), _(y, U, L, X, Q, te), L++;
2293
+ }
2294
+ if (g) {
2295
+ const y = T === I.consumedEndSegmentIndex ? w : u;
2296
+ M(I.consumedEndSegmentIndex, 0, y);
2297
+ }
2298
+ }
2299
+ return f;
2300
+ }
2301
+ function Y0(e, t, n, r) {
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: l } = e, x = Be(), c = x.lineFitEpsilon, f = r + c, u = t.segmentIndex, g = t.graphemeIndex;
2306
+ let S = 0, E = !1, m = t.segmentIndex, k = t.graphemeIndex, T = -1, O = 0, w = 0, R = null;
2307
+ function N() {
2308
+ return R === "soft-hyphen" && T === m && k === 0 ? w : S;
2309
+ }
2310
+ function b(D = m, A = k, I = N()) {
2311
+ return E ? (t.segmentIndex = D, t.graphemeIndex = A, Vt(e, I, u, g, D, A)) : null;
2312
+ }
2313
+ function M(D, A) {
2314
+ E = !0, m = D + 1, k = 0, S = A;
2315
+ }
2316
+ function G(D, A, I) {
2317
+ E = !0, m = D, k = A + 1, S = I;
2318
+ }
2319
+ function W(D, A) {
2320
+ if (!E) {
2321
+ M(D, A);
2322
+ return;
2323
+ }
2324
+ S += A, m = D + 1, k = 0;
2325
+ }
2326
+ function v(D, A, I, L, y, U) {
2327
+ if (!A)
2328
+ return;
2329
+ const Q = ve(e, D, I, y), X = Re(e, D, I, y, L);
2330
+ T = I + 1, O = S - U + Q, w = S - U + X, R = D;
2331
+ }
2332
+ function _(D, A) {
2333
+ const I = a[D];
2334
+ for (let L = A; L < I.length; L++) {
2335
+ const y = I[L];
2336
+ if (!E)
2337
+ G(D, L, y);
2338
+ else {
2339
+ const U = Xt(e, !0, y), Q = S + U;
2340
+ if (qt(e, Q) > f)
2341
+ return b();
2342
+ S = Q, m = D, k = L + 1;
2343
+ }
2344
+ }
2345
+ return E && m === D && k === I.length && (m = D + 1, k = 0), null;
2346
+ }
2347
+ function z() {
2348
+ return R !== "soft-hyphen" || T < 0 ? null : O <= f ? b(T, 0, w) : null;
2349
+ }
2350
+ for (let D = t.segmentIndex; D < i.endSegmentIndex; D++) {
2351
+ const A = o[D], I = _e(A), L = D === t.segmentIndex ? t.graphemeIndex : 0, y = $t(e, E, D), U = A === "tab" ? Qt(S + y, e.tabStopAdvance) : s[D], Q = y + U, X = Yt(e, A, D, y, U);
2352
+ if (A === "soft-hyphen" && L === 0) {
2353
+ E && (m = D + 1, k = 0, T = D + 1, O = S + l, w = S + l, R = A);
2354
+ continue;
2355
+ }
2356
+ if (!E) {
2357
+ if (L > 0) {
2358
+ const ne = _(D, L);
2359
+ if (ne !== null)
2360
+ return ne;
2361
+ } else if (X > f && a[D] !== null) {
2362
+ const ne = _(D, 0);
2363
+ if (ne !== null)
2364
+ return ne;
2365
+ } else
2366
+ M(D, U);
2367
+ v(A, I, D, U, y, Q);
2368
+ continue;
2369
+ }
2370
+ if (S + X > f) {
2371
+ const ne = S + ve(e, A, D, y), he = S + Re(e, A, D, y, U);
2372
+ if (R === "soft-hyphen" && x.preferEarlySoftHyphenBreak && O <= f)
2373
+ return b(T, 0, w);
2374
+ const Z = z();
2375
+ if (Z !== null)
2376
+ return Z;
2377
+ if (I && ne <= f)
2378
+ return W(D, Q), b(D + 1, 0, he);
2379
+ if (T >= 0 && O <= f)
2380
+ return m > T || m === T && k > 0 ? b() : b(T, 0, w);
2381
+ if (X > f && a[D] !== null) {
2382
+ const ae = b();
2383
+ if (ae !== null)
2384
+ return ae;
2385
+ const xe = _(D, 0);
2386
+ if (xe !== null)
2387
+ return xe;
2388
+ }
2389
+ return b();
2390
+ }
2391
+ W(D, Q), v(A, I, D, U, y, Q);
2392
+ }
2393
+ return T === i.consumedEndSegmentIndex && k === 0 ? b(i.consumedEndSegmentIndex, 0, w) : b(i.consumedEndSegmentIndex, 0, S);
2394
+ }
2395
+ function X0(e, t, n) {
2396
+ const { widths: r, kinds: i, breakableFitAdvances: s } = e, a = Be().lineFitEpsilon, l = n + a;
2397
+ let x = 0, c = !1, f = t.segmentIndex, u = t.graphemeIndex, g = -1, S = 0;
2398
+ for (let E = t.segmentIndex; E < r.length; E++) {
2399
+ const m = i[E], k = _e(m), T = E === t.segmentIndex ? t.graphemeIndex : 0, O = s[E], w = r[E];
2400
+ if (!c) {
2401
+ if (T > 0 || w > l && O !== null) {
2402
+ const R = O, N = R[T];
2403
+ c = !0, x = N, f = E, u = T + 1;
2404
+ for (let b = T + 1; b < R.length; b++) {
2405
+ const M = R[b];
2406
+ if (x + M > l)
2407
+ return t.segmentIndex = f, t.graphemeIndex = u, x;
2408
+ x += M, f = E, u = b + 1;
2409
+ }
2410
+ f === E && u === R.length && (f = E + 1, u = 0);
2411
+ } else
2412
+ c = !0, x = w, f = E + 1, u = 0;
2413
+ k && (g = E + 1, S = x - w);
2414
+ continue;
2415
+ }
2416
+ if (x + w > l)
2417
+ return k ? (t.segmentIndex = E + 1, t.graphemeIndex = 0, x) : g >= 0 ? f > g || f === g && u > 0 ? (t.segmentIndex = f, t.graphemeIndex = u, x) : (t.segmentIndex = g, t.graphemeIndex = 0, S) : (t.segmentIndex = f, t.graphemeIndex = u, x);
2418
+ x += w, f = E + 1, u = 0, k && (g = E + 1, S = x - w);
2419
+ }
2420
+ return c ? (t.segmentIndex = f, t.graphemeIndex = u, x) : null;
2421
+ }
2422
+ function q0(e, t, n, r) {
2423
+ return e.simpleLineWalkFastPath ? X0(e, t, r) : Y0(e, t, n, r);
2424
+ }
2425
+ function Ve(e, t, n) {
2426
+ const r = J0(e, t);
2427
+ return r < 0 ? null : q0(e, t, r, n);
2428
+ }
2429
+ let Je = null, Ot = /* @__PURE__ */ new WeakMap();
2430
+ function V0() {
2431
+ return Je === null && (Je = new Intl.Segmenter(void 0, { granularity: "grapheme" })), Je;
2432
+ }
2433
+ function yt(e, t, n) {
2434
+ let r = n.get(e);
2435
+ if (r !== void 0)
2436
+ return r;
2437
+ r = [];
2438
+ const i = V0();
2439
+ for (const s of i.segment(t[e]))
2440
+ r.push(s.segment);
2441
+ return n.set(e, r), r;
2442
+ }
2443
+ function Z0(e, t, n) {
2444
+ return n > t && e[n - 1] === "soft-hyphen";
2445
+ }
2446
+ function It(e, t, n, r) {
2447
+ for (let i = n; i < r; i++)
2448
+ e += t[i];
2449
+ return e;
2450
+ }
2451
+ function es(e) {
2452
+ let t = Ot.get(e);
2453
+ return t !== void 0 || (t = /* @__PURE__ */ new Map(), Ot.set(e, t)), t;
2454
+ }
2455
+ function ts(e, t, n, r, i, s) {
2456
+ let o = "";
2457
+ const a = Z0(e.kinds, n, i);
2458
+ for (let l = n; l < i; l++)
2459
+ if (!(e.kinds[l] === "soft-hyphen" || e.kinds[l] === "hard-break"))
2460
+ if (l === n && r > 0) {
2461
+ const x = yt(l, e.segments, t);
2462
+ o = It(o, x, r, x.length);
2463
+ } else
2464
+ o += e.segments[l];
2465
+ if (s > 0) {
2466
+ a && (o += "-");
2467
+ const l = yt(i, e.segments, t);
2468
+ o = It(o, l, n === i ? r : 0, s);
2469
+ } else a && (o += "-");
2470
+ return o;
2471
+ }
2472
+ let Qe = null;
2473
+ function Zt() {
2474
+ return Qe === null && (Qe = new Intl.Segmenter(void 0, { granularity: "grapheme" })), Qe;
2475
+ }
2476
+ function ns(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 ss(e, t) {
2494
+ const n = [];
2495
+ let r = [], i = 0, s = !1, o = !1, a = !1;
2496
+ function l() {
2497
+ r.length !== 0 && (n.push({
2498
+ text: r.length === 1 ? r[0] : r.join(""),
2499
+ start: i
2500
+ }), r = [], s = !1, o = !1, a = !1);
2501
+ }
2502
+ function x(f, u, g) {
2503
+ r = [f], i = u, s = g, o = Xe(f), a = Te.has(f);
2504
+ }
2505
+ function c(f, u) {
2506
+ r.push(f), s = s || u;
2507
+ const g = Xe(f);
2508
+ f.length === 1 && ge.has(f) ? o = o || g : o = g, a = !1;
2509
+ }
2510
+ for (const f of Zt().segment(e)) {
2511
+ const u = f.segment, g = oe(u);
2512
+ if (r.length === 0) {
2513
+ x(u, f.index, g);
2514
+ continue;
2515
+ }
2516
+ if (a || st.has(u) || ge.has(u) || t.carryCJKAfterClosingQuote && g && o) {
2517
+ c(u, g);
2518
+ continue;
2519
+ }
2520
+ if (!s && !g) {
2521
+ c(u, g);
2522
+ continue;
2523
+ }
2524
+ l(), x(u, f.index, g);
2525
+ }
2526
+ return l(), n;
2527
+ }
2528
+ function is(e, t, n) {
2529
+ if (t.length <= 1)
2530
+ return t;
2531
+ const r = [];
2532
+ let i = -1, s = !1;
2533
+ function o(l, x) {
2534
+ const c = t[l].start, f = x < t.length ? t[x].start : e.length;
2535
+ r.push({
2536
+ text: e.slice(c, f),
2537
+ start: c
2538
+ });
2539
+ }
2540
+ function a(l) {
2541
+ if (!(i < 0)) {
2542
+ if (s)
2543
+ i + 1 === l ? r.push(t[i]) : o(i, l);
2544
+ else
2545
+ for (let x = i; x < l; x++)
2546
+ r.push(t[x]);
2547
+ i = -1, s = !1;
2548
+ }
2549
+ }
2550
+ for (let l = 0; l < t.length; l++) {
2551
+ const x = t[l];
2552
+ i >= 0 && !Kt(t[l - 1].text, n) && a(l), i < 0 && (i = l), s = s || oe(x.text);
2553
+ }
2554
+ return a(t.length), r;
2555
+ }
2556
+ function Pt(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 r = Zt();
2563
+ for (const i of r.segment(e))
2564
+ n++;
2565
+ return n;
2566
+ }
2567
+ function rs(e, t, n) {
2568
+ return t > 1 ? e + (t - 1) * n : e;
2569
+ }
2570
+ function xs(e, t, n, r, i) {
2571
+ const s = Be(), { cache: o, emojiCorrection: a } = H0(t, W0(e.normalized)), l = Fe("-", ue("-", o), a) + (i === 0 ? 0 : i * 2), c = Fe(" ", ue(" ", o), a) * 8, f = i !== 0;
2572
+ if (e.len === 0)
2573
+ return ns();
2574
+ const u = [], g = [], S = [], E = [];
2575
+ let m = e.chunks.length <= 1 && !f;
2576
+ const k = n ? [] : null, T = [], O = [], w = n ? [] : null, R = Array.from({ length: e.len });
2577
+ function N(W, v, _, z, D, A, I, L) {
2578
+ D !== "text" && D !== "space" && D !== "zero-width-break" && (m = !1), u.push(v), g.push(_), S.push(z), E.push(D), k?.push(A), T.push(I), f && O.push(L), w !== null && w.push(W);
2579
+ }
2580
+ function b(W, v, _, z, D) {
2581
+ const A = ue(W, o), I = f ? Pt(W, v) : 0, L = rs(Fe(W, A, a), I, i), y = v === "space" || v === "preserved-space" || v === "zero-width-break" ? 0 : L, U = y === 0 ? 0 : y + (I > 0 ? i : 0), Q = v === "space" || v === "zero-width-break" ? 0 : L;
2582
+ if (D && z && W.length > 1) {
2583
+ let X = "sum-graphemes";
2584
+ i !== 0 ? X = "segment-prefixes" : We(W) ? X = "pair-context" : s.preferPrefixWidthsForBreakableRuns && (X = "segment-prefixes");
2585
+ const te = G0(W, A, o, a, X);
2586
+ N(W, L, U, Q, v, _, te, I);
2587
+ return;
2588
+ }
2589
+ N(W, L, U, Q, v, _, null, I);
2590
+ }
2591
+ for (let W = 0; W < e.len; W++) {
2592
+ R[W] = u.length;
2593
+ const v = e.texts[W], _ = e.isWordLike[W], z = e.kinds[W], D = e.starts[W];
2594
+ if (z === "soft-hyphen") {
2595
+ N(v, 0, l, l, z, D, null, 0);
2596
+ continue;
2597
+ }
2598
+ if (z === "hard-break") {
2599
+ N(v, 0, 0, 0, z, D, null, 0);
2600
+ continue;
2601
+ }
2602
+ if (z === "tab") {
2603
+ N(v, 0, 0, 0, z, D, null, f ? Pt(v, z) : 0);
2604
+ continue;
2605
+ }
2606
+ const A = ue(v, o);
2607
+ if (z === "text" && A.containsCJK) {
2608
+ const I = ss(v, s), L = r === "keep-all" ? is(v, I, s.breakKeepAllAfterPunctuation) : I;
2609
+ for (let y = 0; y < L.length; y++) {
2610
+ const U = L[y];
2611
+ b(U.text, "text", D + U.start, _, r === "keep-all" || !oe(U.text));
2612
+ }
2613
+ continue;
2614
+ }
2615
+ b(v, z, D, _, !0);
2616
+ }
2617
+ const M = os(e.chunks, R, u.length), G = k === null ? null : In(e.normalized, k);
2618
+ return w !== null ? {
2619
+ widths: u,
2620
+ lineEndFitAdvances: g,
2621
+ lineEndPaintAdvances: S,
2622
+ kinds: E,
2623
+ simpleLineWalkFastPath: m,
2624
+ segLevels: G,
2625
+ breakableFitAdvances: T,
2626
+ letterSpacing: i,
2627
+ spacingGraphemeCounts: O,
2628
+ discretionaryHyphenWidth: l,
2629
+ tabStopAdvance: c,
2630
+ chunks: M,
2631
+ segments: w
2632
+ } : {
2633
+ widths: u,
2634
+ lineEndFitAdvances: g,
2635
+ lineEndPaintAdvances: S,
2636
+ kinds: E,
2637
+ simpleLineWalkFastPath: m,
2638
+ segLevels: G,
2639
+ breakableFitAdvances: T,
2640
+ letterSpacing: i,
2641
+ spacingGraphemeCounts: O,
2642
+ discretionaryHyphenWidth: l,
2643
+ tabStopAdvance: c,
2644
+ chunks: M
2645
+ };
2646
+ }
2647
+ function os(e, t, n) {
2648
+ const r = [];
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, l = s.consumedEndSegmentIndex < t.length ? t[s.consumedEndSegmentIndex] : n;
2651
+ r.push({
2652
+ startSegmentIndex: o,
2653
+ endSegmentIndex: a,
2654
+ consumedEndSegmentIndex: l
2655
+ });
2656
+ }
2657
+ return r;
2658
+ }
2659
+ function ls(e, t, n, r) {
2660
+ const i = r?.wordBreak ?? "normal", s = r?.letterSpacing ?? 0, o = L0(e, Be(), r?.whiteSpace, i);
2661
+ return xs(o, t, n, i, s);
2662
+ }
2663
+ function Ze(e, t, n) {
2664
+ return ls(e, t, !0, n);
2665
+ }
2666
+ function wt(e) {
2667
+ let t = 0;
2668
+ return $0(e, Number.POSITIVE_INFINITY, (n) => {
2669
+ n > t && (t = n);
2670
+ }), t;
2671
+ }
2672
+ const cs = /[ \t\n\f\r]+/, Wt = /^[ \t\n\f\r]+/, vt = /[ \t\n\f\r]+$/, Rt = { segmentIndex: 0, graphemeIndex: 0 }, as = {
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 Tt(e) {
2684
+ return e.segmentIndex === 0 && e.graphemeIndex === 0;
2685
+ }
2686
+ function ye(e, t, n) {
2687
+ const r = `${e}\0${t}`, i = n.get(r);
2688
+ if (i !== void 0)
2689
+ return i;
2690
+ const s = t === 0 ? void 0 : { letterSpacing: t }, o = wt(Ze("A A", e, s)), a = wt(Ze("AA", e, s)), l = Math.max(0, o - a);
2691
+ return n.set(r, l), l;
2692
+ }
2693
+ function fs(e) {
2694
+ const t = { segmentIndex: 0, graphemeIndex: 0 }, n = Ve(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 us(e, t) {
2702
+ return e === 0 && t > 0;
2703
+ }
2704
+ function en(e) {
2705
+ const t = [], n = Array.from({ length: e.length }), r = /* @__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, l = Wt.test(o.text), x = vt.test(o.text), c = o.text.replace(Wt, "").replace(vt, "");
2709
+ if (c.length === 0) {
2710
+ cs.test(o.text) && i === 0 && (i = ye(o.font, a, r));
2711
+ continue;
2712
+ }
2713
+ const f = i > 0 ? i : l ? ye(o.font, a, r) : 0, u = Ze(c, o.font, a === 0 ? void 0 : { letterSpacing: a }), g = fs(u);
2714
+ if (g === null) {
2715
+ i = x ? ye(o.font, a, r) : 0;
2716
+ continue;
2717
+ }
2718
+ const S = {
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: u,
2726
+ sourceItemIndex: s
2727
+ };
2728
+ t.push(S), n[s] = S, i = x ? ye(o.font, a, r) : 0;
2729
+ }
2730
+ return {
2731
+ items: t,
2732
+ itemsBySourceItemIndex: n
2733
+ };
2734
+ }
2735
+ function hs(e, t, n, r) {
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 l = e.items[a];
2742
+ if (!Tt(n) && n.segmentIndex === l.endSegmentIndex && n.graphemeIndex === l.endGraphemeIndex) {
2743
+ a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2744
+ continue;
2745
+ }
2746
+ const x = s === 0 ? 0 : l.gapBefore, c = Tt(n);
2747
+ if (l.break === "never") {
2748
+ if (!c) {
2749
+ a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2750
+ continue;
2751
+ }
2752
+ const k = l.naturalWidth + l.extraWidth, T = x + k;
2753
+ if (s > 0 && T > o)
2754
+ break e;
2755
+ r?.(l, x, k, $e(Rt), {
2756
+ segmentIndex: l.endSegmentIndex,
2757
+ graphemeIndex: l.endGraphemeIndex
2758
+ }), s += T, o = Math.max(0, i - s), a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2759
+ continue;
2760
+ }
2761
+ const f = x + l.extraWidth;
2762
+ if (s > 0 && f >= o)
2763
+ break e;
2764
+ if (c) {
2765
+ const k = f + l.naturalWidth;
2766
+ if (k <= o) {
2767
+ r?.(l, x, l.naturalWidth + l.extraWidth, $e(Rt), {
2768
+ segmentIndex: l.endSegmentIndex,
2769
+ graphemeIndex: l.endGraphemeIndex
2770
+ }), s += k, o = Math.max(0, i - s), a++, n.segmentIndex = 0, n.graphemeIndex = 0;
2771
+ continue;
2772
+ }
2773
+ }
2774
+ const u = Math.max(1, o - f), g = {
2775
+ segmentIndex: n.segmentIndex,
2776
+ graphemeIndex: n.graphemeIndex
2777
+ }, S = Ve(l.prepared, g, u);
2778
+ if (S === 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 E = S + l.extraWidth, m = x + E;
2787
+ if (s > 0 && c && m > o)
2788
+ break e;
2789
+ if (s > 0 && c && x > 0 && us(g.segmentIndex, g.graphemeIndex)) {
2790
+ const k = { segmentIndex: 0, graphemeIndex: 0 };
2791
+ if (Ve(l.prepared, k, Math.max(1, i - l.extraWidth)) !== null && (k.segmentIndex > g.segmentIndex || k.segmentIndex === g.segmentIndex && k.graphemeIndex > g.graphemeIndex))
2792
+ break e;
2793
+ }
2794
+ if (r?.(l, x, E, $e(n), {
2795
+ segmentIndex: g.segmentIndex,
2796
+ graphemeIndex: g.graphemeIndex
2797
+ }), s += m, o = Math.max(0, i - s), g.segmentIndex === l.endSegmentIndex && g.graphemeIndex === l.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 ds(e, t, n = as) {
2807
+ const r = e, i = {
2808
+ itemIndex: n.itemIndex,
2809
+ segmentIndex: n.segmentIndex,
2810
+ graphemeIndex: n.graphemeIndex
2811
+ }, s = [], o = hs(r, t, i, (a, l, x, c, f) => {
2812
+ s.push({
2813
+ itemIndex: a.sourceItemIndex,
2814
+ gapBefore: l,
2815
+ occupiedWidth: x,
2816
+ start: c,
2817
+ end: f
2818
+ });
2819
+ });
2820
+ return o === null ? null : {
2821
+ fragments: s,
2822
+ width: o,
2823
+ end: i
2824
+ };
2825
+ }
2826
+ function Fs(e, t) {
2827
+ return ts(e.prepared, es(e.prepared), t.start.segmentIndex, t.start.graphemeIndex, t.end.segmentIndex, t.end.graphemeIndex);
2828
+ }
2829
+ function gs(e, t) {
2830
+ const n = e, r = [];
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
+ r.push({
2836
+ itemIndex: s.itemIndex,
2837
+ text: Fs(o, s),
2838
+ gapBefore: s.gapBefore,
2839
+ occupiedWidth: s.occupiedWidth,
2840
+ start: s.start,
2841
+ end: s.end
2842
+ });
2843
+ }
2844
+ return {
2845
+ fragments: r,
2846
+ width: t.width,
2847
+ end: t.end
2848
+ };
2849
+ }
2850
+ function Ns(e) {
2851
+ const t = [];
2852
+ let n = [], r = 0, i = 0;
2853
+ for (const s of e) {
2854
+ let o = 0;
2855
+ for (; ; ) {
2856
+ const l = s.text.indexOf("\v", o);
2857
+ if (l < 0) break;
2858
+ const x = s.text.slice(o, l);
2859
+ x.length > 0 && n.push({ text: x, style: s.style }), i += l - o, t.push({ runs: n, startOffset: r }), i += 1, r = i, n = [], o = l + 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: r }), t;
2865
+ }
2866
+ function tn(e) {
2867
+ return e.map((t) => {
2868
+ const n = { text: t.style.hidden ? "" : t.text, font: ce(t.style) };
2869
+ return !t.style.hidden && t.style.letterSpacingPx !== void 0 && (n.letterSpacing = t.style.letterSpacingPx), n;
2870
+ });
2871
+ }
2872
+ function ps(e) {
2873
+ return en(tn(e));
2874
+ }
2875
+ class et {
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 r = Ns(t.runs).map((i) => ({
2881
+ prepared: en(tn(i.runs)),
2882
+ runs: i.runs,
2883
+ startOffset: i.startOffset
2884
+ }));
2885
+ return this.map.set(t.id, { revision: t.revision, segments: r }), r;
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 Ye = 48;
2903
+ function Ss() {
2904
+ const e = new et(), t = /* @__PURE__ */ new Map();
2905
+ let n = null;
2906
+ const r = (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 = xn(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 l = Ls(i, r, (x) => (n?.add(x.id), e.get(x)), a);
2919
+ if (n) {
2920
+ for (const x of t.keys()) n.has(x) || t.delete(x);
2921
+ e.retainOnly(n);
2922
+ }
2923
+ return l;
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 ms(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 As = (e) => e === " " || e === " " || e === `
2942
+ ` || e === "\r";
2943
+ function Es(e, t, n) {
2944
+ const r = e.indexOf(n, t);
2945
+ if (r >= 0) return { start: r, end: r + 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 (As(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 ct(e, t) {
2963
+ const n = [];
2964
+ let r = t;
2965
+ for (const i of e)
2966
+ n.push(r), r += i.text.length;
2967
+ return n;
2968
+ }
2969
+ function Bs(e) {
2970
+ return Mn(e) && !e.style.sectionBreak && !e.style.pageBreakBefore;
2971
+ }
2972
+ function nn(e) {
2973
+ const t = e.runs[0]?.style, n = t?.fontSizePx ?? 16, r = t ? we(ce(t)) : { ascent: n * 0.8, descent: n * 0.2 }, i = r.ascent + r.descent, s = Math.max(i, e.style.lineHeight * n);
2974
+ return { height: s, ascent: (s - i) / 2 + r.ascent };
2975
+ }
2976
+ function at(e, t, n, r, i, s) {
2977
+ const o = ds(t.prepared, n, r);
2978
+ if (o === null) return null;
2979
+ const a = gs(t.prepared, o), l = [];
2980
+ let x = 0, c = 0, f = 0, u = 0;
2981
+ for (const m of a.fragments) {
2982
+ x += m.gapBefore;
2983
+ const k = t.runs[m.itemIndex], T = we(ce(k.style));
2984
+ if (c = Math.max(c, T.ascent), f = Math.max(f, T.descent), u = Math.max(u, k.style.fontSizePx), m.text.length > 0) {
2985
+ const O = Es(k.text, s[m.itemIndex], m.text);
2986
+ s[m.itemIndex] = O.end;
2987
+ const w = {
2988
+ blockId: e.id,
2989
+ startOffset: i[m.itemIndex] + O.start,
2990
+ endOffset: i[m.itemIndex] + O.end,
2991
+ text: m.text,
2992
+ style: k.style,
2993
+ x,
2994
+ width: m.occupiedWidth
2995
+ };
2996
+ O.map && (w.offsetMap = O.map), l.push({ frag: w, hadGap: m.gapBefore > 0, spaces: ms(m.text) });
2997
+ }
2998
+ x += m.occupiedWidth;
2999
+ }
3000
+ if (u === 0) {
3001
+ const m = e.runs[0]?.style;
3002
+ if (m) {
3003
+ const k = we(ce(m));
3004
+ c = k.ascent, f = k.descent, u = m.fontSizePx;
3005
+ }
3006
+ }
3007
+ const g = c + f, S = Math.max(g, e.style.lineHeight * u), E = (S - g) / 2;
3008
+ return { frags: l, width: a.width, height: S, ascent: E + c, end: a.end };
3009
+ }
3010
+ function Ms(e, t, n) {
3011
+ for (const i of t) if (i.posPx > e + 0.5) return i;
3012
+ let r = (Math.floor(e / Ye) + 1) * Ye;
3013
+ return r <= e && (r = e + Ye), { posPx: Math.min(r, Math.max(e + 1, n)), align: "left", leader: "none" };
3014
+ }
3015
+ function Cs(e) {
3016
+ const t = e.map((i) => i.text).join(""), n = ce(e[0]?.style ?? sn);
3017
+ let r = t.indexOf(".");
3018
+ return r < 0 && (r = t.indexOf(",")), Pe(r < 0 ? t : t.slice(0, r + 1), n);
3019
+ }
3020
+ const sn = { fontFamily: "Georgia, serif", fontSizePx: 16 };
3021
+ function ks(e, t, n, r, i) {
3022
+ const s = [];
3023
+ let o = [], a = n, l = n;
3024
+ for (const O of t) {
3025
+ let w = 0;
3026
+ for (; ; ) {
3027
+ const N = O.text.indexOf(" ", w);
3028
+ if (N < 0) break;
3029
+ const b = O.text.slice(w, N);
3030
+ b.length > 0 && o.push({ text: b, style: O.style }), l += N - w, s.push({ runs: o, start: a }), l += 1, a = l, o = [], w = N + 1;
3031
+ }
3032
+ const R = O.text.slice(w);
3033
+ R.length > 0 && o.push({ text: R, style: O.style }), l += R.length;
3034
+ }
3035
+ s.push({ runs: o, start: a });
3036
+ const x = (e.style.tabStops ?? []).slice().sort((O, w) => O.posPx - w.posPx), c = t.find((O) => O.text.length > 0)?.style ?? e.runs[0]?.style, f = [];
3037
+ let u = [], g = [], S = i, E = 0, m = 0, k = !1;
3038
+ const T = (O) => {
3039
+ if (E === 0 && c) {
3040
+ const w = we(ce(c));
3041
+ E = Math.max(w.ascent + w.descent, e.style.lineHeight * c.fontSizePx), m = (E - (w.ascent + w.descent)) / 2 + w.ascent;
3042
+ }
3043
+ f.push({
3044
+ frags: u,
3045
+ width: S,
3046
+ indent: 0,
3047
+ // fragment x is already absolute (tab/indent baked in)
3048
+ lineMaxWidth: r,
3049
+ height: E,
3050
+ ascent: m,
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: O || k,
3054
+ ...g.length > 0 ? { leaders: g } : {}
3055
+ }), u = [], g = [], S = 0, E = 0, m = 0, k = !1;
3056
+ };
3057
+ return s.forEach((O, w) => {
3058
+ if (w > 0) {
3059
+ const W = Ms(S, x, r), v = W.align ?? "left", _ = Pe(O.runs.map((A) => A.text).join(""), ce(O.runs[0]?.style ?? c ?? sn)), z = S + _ <= r;
3060
+ let D = W.posPx;
3061
+ z && v === "right" ? D = W.posPx - _ : z && v === "center" ? D = W.posPx - _ / 2 : z && v === "decimal" && (D = W.posPx - Cs(O.runs)), D < S && (D = S), (W.leader ?? "none") !== "none" && D > S + 1 && c && g.push({ x1: S, x2: D, kind: W.leader ?? "none", color: c.color, fontSizePx: c.fontSizePx }), S = D, k = !0;
3062
+ }
3063
+ if (O.runs.length === 0) return;
3064
+ const R = { prepared: ps(O.runs), runs: O.runs, startOffset: O.start }, N = ct(O.runs, O.start), b = O.runs.map(() => 0);
3065
+ let M, G = !0;
3066
+ for (; ; ) {
3067
+ const W = Math.max(24, r - (G ? S : 0)), v = at(e, R, W, M, N, b);
3068
+ if (v === null) break;
3069
+ G || T(!1);
3070
+ const _ = G ? S : 0;
3071
+ for (const z of v.frags)
3072
+ z.frag.x += _, u.push(z);
3073
+ S = _ + v.width, E = Math.max(E, v.height), m = Math.max(m, v.ascent), M = v.end, G = !1;
3074
+ }
3075
+ }), T(!0), f;
3076
+ }
3077
+ function rn(e, t) {
3078
+ if (t <= 0) return;
3079
+ const n = e.reduce((s, o) => s + o.spaces + (o.hadGap ? 1 : 0), 0);
3080
+ if (n <= 0) return;
3081
+ const r = t / n;
3082
+ let i = 0;
3083
+ for (const s of e)
3084
+ s.hadGap && (i += r), s.frag.x += i, s.spaces > 0 && (s.frag.wordSpacingPx = r, s.frag.width += s.spaces * r, i += s.spaces * r);
3085
+ }
3086
+ function xn(e, t, n) {
3087
+ const r = n.get(e), i = [], s = [];
3088
+ let o = !0;
3089
+ for (const l of r) {
3090
+ if (l.runs.some((g) => g.text.includes(" "))) {
3091
+ s.push(...ks(e, l.runs, l.startOffset, t, o ? e.style.indentFirstLinePx : 0)), o = !1;
3092
+ continue;
3093
+ }
3094
+ const x = ct(l.runs, l.startOffset), c = l.runs.map(() => 0);
3095
+ let f, u = !1;
3096
+ for (; ; ) {
3097
+ const g = o ? e.style.indentFirstLinePx : 0, S = t - g, E = at(e, l, S, f, x, c);
3098
+ if (E === null) break;
3099
+ s.push({
3100
+ frags: E.frags,
3101
+ width: E.width,
3102
+ indent: g,
3103
+ lineMaxWidth: S,
3104
+ height: E.height,
3105
+ ascent: E.ascent,
3106
+ lastOfSegment: !1
3107
+ }), f = E.end, o = !1, u = !0;
3108
+ }
3109
+ if (u)
3110
+ s[s.length - 1].lastOfSegment = !0;
3111
+ else {
3112
+ const g = nn(e);
3113
+ s.push({
3114
+ frags: [],
3115
+ width: 0,
3116
+ indent: 0,
3117
+ lineMaxWidth: t,
3118
+ height: g.height,
3119
+ ascent: g.ascent,
3120
+ lastOfSegment: !0,
3121
+ emptyOffset: l.startOffset
3122
+ }), o = !1;
3123
+ }
3124
+ }
3125
+ let a = 0;
3126
+ for (const l of s) {
3127
+ const x = l.lineMaxWidth - l.width;
3128
+ let c = l.indent;
3129
+ e.style.align === "center" ? c += x / 2 : e.style.align === "right" ? c += x : e.style.align === "justify" && !l.lastOfSegment && rn(l.frags, x);
3130
+ for (const u of l.frags) u.frag.x += c;
3131
+ const f = { y: a, height: l.height, ascent: l.ascent, fragments: l.frags.map((u) => u.frag) };
3132
+ l.emptyOffset !== void 0 && (f.emptyOffset = l.emptyOffset), l.leaders && l.leaders.length > 0 && (f.leaders = l.leaders.map((u) => ({ ...u, x1: u.x1 + c, x2: u.x2 + c }))), i.push(f), a += l.height;
3133
+ }
3134
+ return i;
3135
+ }
3136
+ const Gt = 2, Ht = 2, Ds = 48, on = ["header", "footer", "headerFirst", "headerEven", "footerFirst", "footerEven"];
3137
+ function ln(e, t) {
3138
+ const n = {
3139
+ pageWidthPx: t.pageWidthPx ?? e.pageWidthPx,
3140
+ pageHeightPx: t.pageHeightPx ?? e.pageHeightPx,
3141
+ marginPx: t.marginPx ?? e.marginPx
3142
+ }, r = t.columns === void 0 ? e.columns : t.columns ?? void 0;
3143
+ r && (n.columns = r), t.pageNumberStart !== void 0 && (n.pageNumberStart = t.pageNumberStart);
3144
+ const i = t.headerDistancePx ?? e.headerDistancePx;
3145
+ i !== void 0 && (n.headerDistancePx = i);
3146
+ const s = t.footerDistancePx ?? e.footerDistancePx;
3147
+ s !== void 0 && (n.footerDistancePx = s);
3148
+ for (const o of on) {
3149
+ const a = t[o] ?? e[o];
3150
+ a && (n[o] = a);
3151
+ }
3152
+ return n;
3153
+ }
3154
+ function _t(e, t) {
3155
+ return e.headerDistancePx !== void 0 ? e.headerDistancePx : Math.max(8, (e.marginPx.top - t) / 2);
3156
+ }
3157
+ function zt(e, t) {
3158
+ return e.footerDistancePx !== void 0 ? e.pageHeightPx - e.footerDistancePx - t : e.pageHeightPx - Math.max(8, (e.marginPx.bottom - t) / 2) - t;
3159
+ }
3160
+ function cn(e) {
3161
+ const t = [];
3162
+ for (let n = 0; n < e.blocks.length; n++) {
3163
+ const r = e.blocks[n];
3164
+ r.kind === "paragraph" && r.style.sectionBreak && t.push({ props: ln(e.section, r.style.sectionBreak.props), endBlock: n });
3165
+ }
3166
+ return t.push({ props: e.section, endBlock: e.blocks.length - 1 }), t;
3167
+ }
3168
+ function Ls(e, t, n, r) {
3169
+ const s = /* @__PURE__ */ new Map();
3170
+ let o = null;
3171
+ const a = (h) => {
3172
+ const F = s.get(h);
3173
+ if (F) return F;
3174
+ let d = h.marginPx.top, p = h.pageHeightPx - h.marginPx.bottom;
3175
+ const C = [h.header, h.headerFirst, h.headerEven].filter((H) => !!H), B = [h.footer, h.footerFirst, h.footerEven].filter((H) => !!H);
3176
+ if (C.length > 0 || B.length > 0) {
3177
+ o ??= new et();
3178
+ const H = h.pageWidthPx - h.marginPx.left - h.marginPx.right, j = h.marginPx.left, $ = (V) => Ie(V, H, j, 999, 999, o, !1).height, K = (V) => {
3179
+ const ee = Ie(V, H, j, 999, 999, o, !1);
3180
+ for (const Y of ee.placed)
3181
+ if (!!Y.table || !!Y.image || Y.lines.some((Me) => Me.fragments.some((fe) => fe.text.trim().length > 0))) return ee.height - Y.y;
3182
+ return 0;
3183
+ }, J = C.reduce((V, ee) => Math.max(V, $(ee)), 0);
3184
+ if (J > 0) {
3185
+ const V = _t(h, J);
3186
+ d = Math.max(d, V + J + 6);
3187
+ }
3188
+ const q = B.reduce((V, ee) => Math.max(V, $(ee)), 0);
3189
+ if (q > 0)
3190
+ if (h.footerDistancePx !== void 0) {
3191
+ const V = h.pageHeightPx - h.footerDistancePx, ee = B.reduce((Y, me) => Math.max(Y, K(me)), 0);
3192
+ p = Math.min(p, V - ee);
3193
+ } else
3194
+ p = Math.min(p, zt(h, q) - 6);
3195
+ p = Math.max(p, d + 24);
3196
+ }
3197
+ const P = { top: d, bottom: p };
3198
+ return s.set(h, P), P;
3199
+ }, l = cn(e);
3200
+ let x = l[0].props, c = 0, f = 0, u = 0, g = 0, S = 1, E = 0, m = 0;
3201
+ const k = (h) => {
3202
+ x = h;
3203
+ const F = a(x);
3204
+ c = x.marginPx.left, f = F.top, u = F.bottom, g = x.pageWidthPx - x.marginPx.left - x.marginPx.right, S = Math.max(1, x.columns?.count ?? 1), E = x.columns?.gapPx ?? 24, m = S > 1 ? (g - (S - 1) * E) / S : g;
3205
+ };
3206
+ k(x);
3207
+ const T = e.lists ?? {}, O = (h) => {
3208
+ const F = h.style.list;
3209
+ if (!F) return null;
3210
+ const d = T[F.listId];
3211
+ return d ? d.levels[Math.min(F.level, d.levels.length - 1)] ?? null : null;
3212
+ }, w = (h) => h.style.indentLeftPx + (O(h)?.indentLeftPx ?? 0), R = (h) => h.style.indentRightPx ?? 0, N = (h) => O(h)?.indentLeftPx ?? 0, b = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map(), G = (h) => {
3213
+ const F = h.style.list, d = O(h);
3214
+ if (!F || !d) return;
3215
+ const p = T[F.listId], C = b.get(F.listId) ?? [];
3216
+ C[F.level] = (C[F.level] ?? d.start - 1) + 1, C.length = F.level + 1, b.set(F.listId, C);
3217
+ const B = Ln(p, F.level, C);
3218
+ if (B.length === 0) return;
3219
+ const P = h.runs[0]?.style;
3220
+ P && M.set(h.id, {
3221
+ text: B,
3222
+ style: { ...P, ...d.markerStyle ?? {} },
3223
+ hangingPx: d.hangingPx
3224
+ });
3225
+ }, W = (h) => {
3226
+ for (const F of h)
3227
+ if (F.kind === "paragraph") G(F);
3228
+ else if (F.kind === "table") for (const d of F.rows) for (const p of d.cells) W(p.blocks);
3229
+ };
3230
+ W(e.blocks);
3231
+ const v = { indentOf: N, markers: M }, _ = [];
3232
+ let z = 0;
3233
+ for (let h = 0; h < e.blocks.length; h++) {
3234
+ for (; h > l[z].endBlock; ) k(l[++z].props);
3235
+ const F = e.blocks[h];
3236
+ if (F.kind === "paragraph") {
3237
+ if (Bs(F)) continue;
3238
+ const d = F.style.tocEntry ? Ds : 0;
3239
+ _.push({
3240
+ kind: "para",
3241
+ block: F,
3242
+ lines: t(F, m - w(F) - R(F) - d)
3243
+ });
3244
+ } else if (F.kind === "image")
3245
+ _.push({ kind: "image", block: F, height: F.anchor ? 0 : F.heightPx });
3246
+ else {
3247
+ const d = ft(F, m, t, v);
3248
+ _.push({ kind: "table", block: F, ...d });
3249
+ }
3250
+ }
3251
+ z = 0, k(l[0].props);
3252
+ const D = [], A = () => (D.push(x), {
3253
+ index: D.length - 1,
3254
+ number: D.length,
3255
+ // provisional; the post-pass sets the real value
3256
+ blocks: [],
3257
+ widthPx: x.pageWidthPx,
3258
+ heightPx: x.pageHeightPx,
3259
+ marginPx: x.marginPx,
3260
+ contentTopPx: f,
3261
+ contentBottomPx: u
3262
+ }), I = [A()];
3263
+ let L = I[0], y = f;
3264
+ const U = /* @__PURE__ */ new Map(), Q = 14, X = 18, te = e.footnotes ?? {}, ne = Object.keys(te).length > 0;
3265
+ let he = 0;
3266
+ const Z = () => u - he, ae = /* @__PURE__ */ new Set(), xe = [[]], ze = [0], dt = /* @__PURE__ */ new Map(), Ft = (h) => {
3267
+ const F = te[h];
3268
+ if (!F || F.length === 0) return null;
3269
+ const d = Math.max(40, g - X);
3270
+ let p = 0;
3271
+ return { paras: F.map((B) => {
3272
+ const P = t(B, d);
3273
+ return p += B.style.spaceBeforePx + Se(P) + B.style.spaceAfterPx, { p: B, lines: P };
3274
+ }), height: p };
3275
+ }, un = (h, F, d) => {
3276
+ const p = [];
3277
+ for (let C = F; C < F + d; C++)
3278
+ for (const B of h[C].fragments) {
3279
+ const P = B.style.footnoteRef;
3280
+ P && te[P] && !ae.has(P) && !p.some(([H]) => H === P) && p.push([P, B.text]);
3281
+ }
3282
+ return p;
3283
+ };
3284
+ let pe = 0, Le = 0;
3285
+ const le = () => c + pe * (m + E), se = () => L.blocks.length > Le, je = () => {
3286
+ pe = 0, Le = 0, L = A(), I.push(L), xe.push([]), ze.push(0), he = 0, y = f, de = [];
3287
+ }, ie = () => {
3288
+ pe + 1 < S ? (pe++, Le = L.blocks.length, y = f, de = []) : je();
3289
+ }, hn = () => {
3290
+ L.blocks.length === 0 ? (L.widthPx = x.pageWidthPx, L.heightPx = x.pageHeightPx, L.marginPx = x.marginPx, L.contentTopPx = f, L.contentBottomPx = u, D[L.index] = x, pe = 0, Le = 0, y = f, de = []) : je();
3291
+ }, dn = (h, F, d, p) => {
3292
+ const C = {
3293
+ blockId: h.id,
3294
+ x: le() + w(h),
3295
+ y,
3296
+ firstLineIndex: d,
3297
+ lines: []
3298
+ }, B = d === 0 ? M.get(h.id) : void 0;
3299
+ B && (C.marker = { text: B.text, style: B.style, x: C.x - B.hangingPx }), h.style.tocEntry && U.set(h.id, { chunk: C, rightEdge: le() + m, para: h }), L.blocks.push(C);
3300
+ for (let P = d; P < d + p; P++) {
3301
+ const H = F[P];
3302
+ C.lines.push({ ...H, y: y - C.y }), y += H.height;
3303
+ }
3304
+ }, Fn = (h, F) => {
3305
+ let d = 0, p = y;
3306
+ for (; F + d < h.length && p + h[F + d].height <= Z(); )
3307
+ p += h[F + d].height, d++;
3308
+ return d;
3309
+ }, gt = (h) => {
3310
+ let F = xe[L.index].length === 0 ? Q : 0;
3311
+ const d = [];
3312
+ for (const [p, C] of h) {
3313
+ const B = Ft(p);
3314
+ B && (F += B.height, d.push([p, C, B]));
3315
+ }
3316
+ return { H: F, measures: d };
3317
+ }, Nt = (h, F) => {
3318
+ for (const [d, p] of h)
3319
+ ae.add(d), xe[L.index].push(d), dt.set(d, p);
3320
+ he += F, ze[L.index] = he;
3321
+ }, gn = (h) => {
3322
+ const F = [], d = (p) => {
3323
+ for (const C of p)
3324
+ if (C.kind === "paragraph") {
3325
+ let B = 0;
3326
+ for (const P of C.runs) {
3327
+ const H = P.style.footnoteRef;
3328
+ H && te[H] && !ae.has(H) && !F.some(([j]) => j === H) && F.push([H, P.text]), B += P.text.length;
3329
+ }
3330
+ } else if (C.kind === "table")
3331
+ for (const B of C.rows) for (const P of B.cells) d(P.blocks);
3332
+ };
3333
+ for (const p of h) for (const C of p.cells) d(C.blocks);
3334
+ return F;
3335
+ }, Nn = (h, F, d) => {
3336
+ for (; ; ) {
3337
+ if (d <= 0) return d;
3338
+ const p = un(h, F, d);
3339
+ if (p.length === 0) return d;
3340
+ const { H: C, measures: B } = gt(p);
3341
+ if (B.length === 0) return d;
3342
+ let P = 0;
3343
+ for (let j = F; j < F + d; j++) P += h[j].height;
3344
+ if (y + P + C <= Z() || d === 1 && !se())
3345
+ return Nt(B, C), d;
3346
+ d--;
3347
+ }
3348
+ }, pn = (h, F) => {
3349
+ if (h.style.keepLinesTogether === !0 && se()) {
3350
+ const p = Se(F);
3351
+ y + p > Z() && p <= u - f && ie();
3352
+ }
3353
+ let d = 0;
3354
+ for (; d < F.length; ) {
3355
+ const p = F.length - d, C = Fn(F, d);
3356
+ let B;
3357
+ if (C >= p ? B = p : (B = C, p - B === 1 && (B -= Ht - 1), d === 0 && B > 0 && B < Gt && (B = 0), B <= 0 && (B = se() ? 0 : Math.max(1, C))), B > 0 && ne && (B = Nn(F, d, B)), B > 0 && (dn(h, F, d, B), d += B), d >= F.length) return;
3358
+ ie();
3359
+ }
3360
+ }, Se = (h) => {
3361
+ let F = 0;
3362
+ for (const d of h) F += d.height;
3363
+ return F;
3364
+ };
3365
+ let de = [];
3366
+ const pt = 10, Sn = (h) => {
3367
+ let F = le(), d = le() + m;
3368
+ for (const p of de)
3369
+ h >= p.bottom || (p.side === "left" ? F = Math.max(F, p.right + pt) : d = Math.min(d, p.left - pt));
3370
+ return { x0: F, width: Math.max(40, d - F) };
3371
+ }, mn = (h) => de.some((F) => F.bottom > h), An = (h) => {
3372
+ const F = h.anchor;
3373
+ let d;
3374
+ switch (F.relFromH) {
3375
+ case "page":
3376
+ case "leftMargin":
3377
+ d = 0;
3378
+ break;
3379
+ case "rightMargin":
3380
+ d = x.pageWidthPx - x.marginPx.right;
3381
+ break;
3382
+ case "column":
3383
+ d = le();
3384
+ break;
3385
+ default:
3386
+ d = x.marginPx.left;
3387
+ break;
3388
+ }
3389
+ let p;
3390
+ switch (F.relFromV) {
3391
+ case "page":
3392
+ case "topMargin":
3393
+ p = 0;
3394
+ break;
3395
+ case "bottomMargin":
3396
+ p = x.pageHeightPx - x.marginPx.bottom;
3397
+ break;
3398
+ case "paragraph":
3399
+ case "line":
3400
+ p = y;
3401
+ break;
3402
+ // current flow position
3403
+ default:
3404
+ p = x.marginPx.top;
3405
+ break;
3406
+ }
3407
+ const C = { src: h.src, width: h.widthPx, height: h.heightPx, z: F.z ?? 0 };
3408
+ F.behind ? C.behind = !0 : C.front = !0, L.blocks.push({
3409
+ blockId: h.id,
3410
+ x: d + F.offsetXPx,
3411
+ y: p + F.offsetYPx,
3412
+ firstLineIndex: 0,
3413
+ lines: [],
3414
+ image: C
3415
+ });
3416
+ }, St = (h) => {
3417
+ if (h.anchor) {
3418
+ An(h);
3419
+ return;
3420
+ }
3421
+ y + h.heightPx > Z() && se() && ie();
3422
+ const F = h.wrap === "square" && h.align !== "center", d = m - h.widthPx, p = le() + (h.align === "center" ? d / 2 : h.align === "right" ? d : 0);
3423
+ L.blocks.push({
3424
+ blockId: h.id,
3425
+ x: p,
3426
+ y,
3427
+ firstLineIndex: 0,
3428
+ lines: [],
3429
+ image: { src: h.src, width: h.widthPx, height: h.heightPx }
3430
+ }), F ? de.push({ left: p, right: p + h.widthPx, bottom: y + h.heightPx, side: h.align === "right" ? "right" : "left" }) : y += h.heightPx;
3431
+ }, En = (h) => {
3432
+ const F = n(h);
3433
+ let d = !0, p = 0, C = null;
3434
+ const B = (P, H, j, $) => {
3435
+ if (C === null) {
3436
+ C = { blockId: h.id, x: le() + w(h), y, firstLineIndex: p, lines: [] };
3437
+ const J = p === 0 ? M.get(h.id) : void 0;
3438
+ if (J) {
3439
+ const q = P[0]?.frag.x ?? 0;
3440
+ C.marker = { text: J.text, style: J.style, x: C.x + q - J.hangingPx };
3441
+ }
3442
+ L.blocks.push(C);
3443
+ }
3444
+ const K = { y: y - C.y, height: H, ascent: j, fragments: P.map((J) => J.frag) };
3445
+ $ !== void 0 && (K.emptyOffset = $), C.lines.push(K), y += H, p++;
3446
+ };
3447
+ for (const P of F) {
3448
+ const H = ct(P.runs, P.startOffset), j = P.runs.map(() => 0);
3449
+ let $, K = !1, J = null;
3450
+ for (; ; ) {
3451
+ const q = j.slice(), V = Sn(y), ee = d ? h.style.indentFirstLinePx : 0, Y = at(
3452
+ h,
3453
+ P,
3454
+ Math.max(24, V.width - w(h) - ee - R(h)),
3455
+ $,
3456
+ H,
3457
+ j
3458
+ );
3459
+ if (Y === null) break;
3460
+ if (y + Y.height > Z() && se()) {
3461
+ for (let fe = 0; fe < j.length; fe++) j[fe] = q[fe];
3462
+ ie(), C = null;
3463
+ continue;
3464
+ }
3465
+ const me = V.width - ee - R(h) - Y.width;
3466
+ let Me = V.x0 - le() + ee;
3467
+ h.style.align === "center" ? Me += me / 2 : h.style.align === "right" && (Me += me);
3468
+ for (const fe of Y.frags) fe.frag.x += Me;
3469
+ h.style.align === "justify" && (J && rn(J.frags, J.slack), J = { frags: Y.frags, slack: me }), B(Y.frags, Y.height, Y.ascent), $ = Y.end, d = !1, K = !0;
3470
+ }
3471
+ if (!K) {
3472
+ const q = nn(h);
3473
+ y + q.height > Z() && se() && (ie(), C = null), B([], q.height, q.ascent, P.startOffset), d = !1;
3474
+ }
3475
+ }
3476
+ }, Bn = (h) => {
3477
+ h.block.rows.some((p) => p.cells.some((C) => (C.rowSpan ?? 1) > 1)) && se() && y + h.height > Z() && h.height <= u - f && ie();
3478
+ let d = 0;
3479
+ for (; d < h.rows.length; ) {
3480
+ let p = 0, C = y;
3481
+ for (; d + p < h.rows.length && C + h.rows[d + p].height <= Z(); )
3482
+ C += h.rows[d + p].height, p++;
3483
+ if (p === 0) {
3484
+ if (se()) {
3485
+ ie();
3486
+ continue;
3487
+ }
3488
+ p = 1;
3489
+ }
3490
+ let B = [], P = 0;
3491
+ for (; ; ) {
3492
+ const j = gn(h.block.rows.slice(d, d + p));
3493
+ if (j.length === 0) break;
3494
+ const { H: $, measures: K } = gt(j);
3495
+ if (K.length === 0) break;
3496
+ let J = 0;
3497
+ for (let q = d; q < d + p; q++) J += h.rows[q].height;
3498
+ if (y + J + $ <= Z() || p === 1 && !se()) {
3499
+ B = K, P = $;
3500
+ break;
3501
+ }
3502
+ if (p--, p === 0) break;
3503
+ }
3504
+ if (p === 0) {
3505
+ ie();
3506
+ continue;
3507
+ }
3508
+ B.length > 0 && Nt(B, P);
3509
+ const H = h.rows.slice(d, d + p);
3510
+ L.blocks.push(ht(h.block, H, h.colWidths, le(), y, m, d, v)), y += H.reduce((j, $) => j + $.height, 0), d += p, d < h.rows.length && ie();
3511
+ }
3512
+ };
3513
+ for (let h = 0; h < _.length; h++) {
3514
+ if (h > l[z].endBlock) {
3515
+ for (; h > l[z].endBlock; ) k(l[++z].props);
3516
+ hn();
3517
+ }
3518
+ const F = _[h], d = (H) => H?.kind === "table" || H?.kind === "image" && H.block.anchor === void 0, p = d(_[h - 1]), C = d(_[h + 1]);
3519
+ if (F.kind === "image") {
3520
+ if (F.block.anchor) {
3521
+ St(F.block);
3522
+ continue;
3523
+ }
3524
+ p || (y += Ce), St(F.block), !C && (F.block.wrap !== "square" || F.block.align === "center") && (y += Ce);
3525
+ continue;
3526
+ }
3527
+ if (F.kind === "table") {
3528
+ p || (y += Ce);
3529
+ for (const H of de) H.bottom > y && (y = H.bottom);
3530
+ Bn(F), C || (y += Ce);
3531
+ continue;
3532
+ }
3533
+ const { block: B, lines: P } = F;
3534
+ if (B.style.pageBreakBefore === !0 && (L.blocks.length > 0 || pe > 0) ? je() : B.style.columnBreakBefore === !0 && se() && ie(), y += B.style.spaceBeforePx, y >= Z() && se() && ie(), mn(y)) {
3535
+ En(B), y += B.style.spaceAfterPx;
3536
+ continue;
3537
+ }
3538
+ if (B.style.keepWithNext === !0 && _[h + 1] !== void 0 && se()) {
3539
+ let H = y + Se(P) + B.style.spaceAfterPx, j = H <= Z();
3540
+ for (let $ = h + 1; j; $++) {
3541
+ const K = _[$];
3542
+ if (K === void 0) break;
3543
+ if (K.kind !== "para") {
3544
+ const Y = K.kind === "table" ? K.rows[0]?.height ?? K.height : K.height;
3545
+ H + Ce + Y > Z() && (j = !1);
3546
+ break;
3547
+ }
3548
+ H += K.block.style.spaceBeforePx;
3549
+ const J = K.block.style.keepWithNext === !0 && _[$ + 1] !== void 0;
3550
+ if (J || K.block.style.keepLinesTogether === !0) {
3551
+ const Y = Se(K.lines);
3552
+ if (H + Y > Z()) {
3553
+ j = !1;
3554
+ break;
3555
+ }
3556
+ if (H += Y + K.block.style.spaceAfterPx, !J) break;
3557
+ continue;
3558
+ }
3559
+ if (_[$ + 1] !== void 0 && K.block.runs.every((Y) => Y.text.trim().length === 0)) {
3560
+ const Y = Se(K.lines);
3561
+ if (H + Y > Z()) {
3562
+ j = !1;
3563
+ break;
3564
+ }
3565
+ H += Y + K.block.style.spaceAfterPx;
3566
+ continue;
3567
+ }
3568
+ let q = 0, V = H;
3569
+ for (; q < K.lines.length && V + K.lines[q].height <= Z(); )
3570
+ V += K.lines[q].height, q++;
3571
+ let ee = q;
3572
+ q < K.lines.length && (K.lines.length - ee === 1 && (ee -= Ht - 1), ee < Gt && (ee = 0)), ee <= 0 && (j = !1);
3573
+ break;
3574
+ }
3575
+ j || ie();
3576
+ }
3577
+ pn(B, P), y += B.style.spaceAfterPx;
3578
+ }
3579
+ for (const h of I) {
3580
+ const F = xe[h.index];
3581
+ if (!F || F.length === 0) continue;
3582
+ const d = D[h.index];
3583
+ k(d);
3584
+ let p = u - ze[h.index];
3585
+ h.footnoteRuleY = p + 4, p += Q;
3586
+ const C = d.marginPx.left;
3587
+ for (const B of F) {
3588
+ const P = Ft(B);
3589
+ if (!P) continue;
3590
+ let H = !0;
3591
+ for (const j of P.paras) {
3592
+ p += j.p.style.spaceBeforePx;
3593
+ const $ = {
3594
+ blockId: j.p.id,
3595
+ x: C + X,
3596
+ y: p,
3597
+ firstLineIndex: 0,
3598
+ lines: j.lines
3599
+ };
3600
+ H && j.p.runs[0] && ($.marker = { text: `${dt.get(B) ?? "•"}.`, style: j.p.runs[0].style, x: C }, H = !1), h.blocks.push($), p += Se(j.lines) + j.p.style.spaceAfterPx;
3601
+ }
3602
+ }
3603
+ }
3604
+ for (const h of I) {
3605
+ if (!h.blocks.some((d) => d.image?.behind || d.image?.front)) continue;
3606
+ const F = (d) => d.image?.behind ? 0 : d.image?.front ? 2 : 1;
3607
+ h.blocks = h.blocks.map((d, p) => ({ b: d, i: p })).sort((d, p) => {
3608
+ const C = F(d.b) - F(p.b);
3609
+ if (C !== 0) return C;
3610
+ if (F(d.b) !== 1) {
3611
+ const B = (d.b.image.z ?? 0) - (p.b.image.z ?? 0);
3612
+ if (B !== 0) return B;
3613
+ }
3614
+ return d.i - p.i;
3615
+ }).map((d) => d.b);
3616
+ }
3617
+ const be = [];
3618
+ {
3619
+ let h = 0;
3620
+ for (let F = 0; F < I.length; F++) {
3621
+ const d = D[F];
3622
+ (F === 0 || D[F - 1] !== d) && d.pageNumberStart !== void 0 ? h = d.pageNumberStart : h++, be.push(h), I[F].number = h;
3623
+ }
3624
+ }
3625
+ const mt = e.fields;
3626
+ if (mt) {
3627
+ const h = (p) => {
3628
+ if (p === void 0) return !1;
3629
+ const C = mt[p], B = C && C.kind === "builtin" ? C.spec?.type : void 0;
3630
+ return B === "PAGE" || B === "NUMPAGES";
3631
+ }, F = (p, C) => {
3632
+ let B = 0;
3633
+ for (const P of p.fragments) {
3634
+ if (B !== 0 && (P.x += B), !h(P.style.fieldId)) continue;
3635
+ const H = an(P.text, C, I.length);
3636
+ if (H === P.text) continue;
3637
+ const j = P.endOffset - P.startOffset, $ = P.width;
3638
+ P.text = H, P.width = Pe(H, ce(P.style)), P.offsetMap = Array.from({ length: H.length + 1 }, (K, J) => J === H.length ? j : 0), B += P.width - $;
3639
+ }
3640
+ }, d = (p, C) => {
3641
+ for (const B of p.lines) F(B, C);
3642
+ if (p.table) for (const B of p.table.rows) for (const P of B.cells) for (const H of P.blocks) d(H, C);
3643
+ };
3644
+ for (const p of I) for (const C of p.blocks) d(C, be[p.index]);
3645
+ }
3646
+ if (U.size > 0) {
3647
+ const h = /* @__PURE__ */ new Map(), F = (d, p) => {
3648
+ for (const C of d)
3649
+ if (h.has(C.blockId) || h.set(C.blockId, p), C.table) for (const B of C.table.rows) for (const P of B.cells) F(P.blocks, p);
3650
+ };
3651
+ for (const d of I) F(d.blocks, be[d.index]);
3652
+ for (const d of U.values()) {
3653
+ const p = d.para.style.tocEntry.targetId, C = h.get(p);
3654
+ if (C === void 0) continue;
3655
+ const B = d.para.runs[0]?.style;
3656
+ if (!B || d.chunk.lines.length === 0) continue;
3657
+ const P = String(C);
3658
+ d.chunk.toc = {
3659
+ numText: P,
3660
+ numX: d.rightEdge - Pe(P, ce(B)),
3661
+ lineIndex: d.chunk.lines.length - 1,
3662
+ style: B,
3663
+ targetId: p
3664
+ };
3665
+ }
3666
+ }
3667
+ const At = (h, F, d, p) => {
3668
+ const C = F === "header" ? h.headerFirst : h.footerFirst, B = F === "header" ? h.headerEven : h.footerEven;
3669
+ if (d && C) return { blocks: C, source: F === "header" ? "headerFirst" : "footerFirst" };
3670
+ if (p && B) return { blocks: B, source: F === "header" ? "headerEven" : "footerEven" };
3671
+ const P = h[F];
3672
+ return P ? { blocks: P, source: F } : null;
3673
+ };
3674
+ if (D.some((h) => on.some((F) => h[F]))) {
3675
+ const h = new et();
3676
+ for (const F of I) {
3677
+ const d = D[F.index], p = d.pageWidthPx - d.marginPx.left - d.marginPx.right, C = d.marginPx.left, B = F.index === 0 || D[F.index - 1] !== d, P = be[F.index], H = P % 2 === 0, j = At(d, "header", B, H);
3678
+ if (j) {
3679
+ const K = r === "header", J = Ie(j.blocks, p, C, P, I.length, h, K), q = _t(d, J.height);
3680
+ F.header = J.placed.map((V) => tt(V, q)), F.headerSource = j.source;
3681
+ }
3682
+ const $ = At(d, "footer", B, H);
3683
+ if ($) {
3684
+ const K = r === "footer", J = Ie($.blocks, p, C, P, I.length, h, K), q = zt(d, J.height);
3685
+ F.footer = J.placed.map((V) => tt(V, q)), F.footerSource = $.source;
3686
+ }
3687
+ }
3688
+ }
3689
+ return {
3690
+ pages: I,
3691
+ pageWidthPx: e.section.pageWidthPx,
3692
+ pageHeightPx: e.section.pageHeightPx,
3693
+ marginPx: e.section.marginPx
3694
+ };
3695
+ }
3696
+ function bs(e, t) {
3697
+ switch (t) {
3698
+ case "roman":
3699
+ return Oe(e, "lowerRoman");
3700
+ case "Roman":
3701
+ return Oe(e, "upperRoman");
3702
+ case "alpha":
3703
+ return Oe(e, "lowerLetter");
3704
+ case "Alpha":
3705
+ return Oe(e, "upperLetter");
3706
+ default:
3707
+ return String(e);
3708
+ }
3709
+ }
3710
+ function an(e, t, n) {
3711
+ return e.replace(/\{page(?::(roman|Roman|alpha|Alpha))?\}/g, (r, i) => bs(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" }));
3712
+ }
3713
+ function Os(e, t, n) {
3714
+ const r = (i) => i.runs.some((s) => s.text.includes("{")) ? {
3715
+ ...i,
3716
+ id: `${i.id}@p${t}`,
3717
+ // per-page identity keeps the band prepare-cache honest
3718
+ runs: i.runs.map((s) => ({ ...s, text: an(s.text, t, n) }))
3719
+ } : i;
3720
+ return e.kind === "paragraph" ? r(e) : e.kind === "table" ? {
3721
+ ...e,
3722
+ rows: e.rows.map((i) => ({
3723
+ cells: i.cells.map((s) => ({
3724
+ ...s,
3725
+ blocks: s.blocks.map((o) => o.kind === "paragraph" ? r(o) : o)
3726
+ }))
3727
+ }))
3728
+ } : e;
3729
+ }
3730
+ function Ie(e, t, n, r, i, s, o) {
3731
+ const a = (c, f) => xn(c, f, s), l = [];
3732
+ let x = 0;
3733
+ for (const c of e) {
3734
+ const f = o ? c : Os(c, r, i);
3735
+ if (f.kind === "paragraph") {
3736
+ x += f.style.spaceBeforePx;
3737
+ const u = a(f, t);
3738
+ l.push({ blockId: f.id, x: n + f.style.indentLeftPx, y: x, firstLineIndex: 0, lines: u }), x += ut(u) + f.style.spaceAfterPx;
3739
+ } else if (f.kind === "image") {
3740
+ const u = t - f.widthPx, g = n + (f.align === "center" ? u / 2 : f.align === "right" ? u : 0);
3741
+ l.push({
3742
+ blockId: f.id,
3743
+ x: g,
3744
+ y: x,
3745
+ firstLineIndex: 0,
3746
+ lines: [],
3747
+ image: { src: f.src, width: f.widthPx, height: f.heightPx }
3748
+ }), x += f.heightPx;
3749
+ } else {
3750
+ const u = ft(f, t, a, jt);
3751
+ l.push(ht(f, u.rows, u.colWidths, n, x, t, 0, jt)), x += u.height;
3752
+ }
3753
+ }
3754
+ return { placed: l, height: x };
3755
+ }
3756
+ function tt(e, t) {
3757
+ const n = { ...e, y: e.y + t };
3758
+ return e.table && (n.table = {
3759
+ ...e.table,
3760
+ y: e.table.y + t,
3761
+ rows: e.table.rows.map((r) => ({
3762
+ ...r,
3763
+ y: r.y + t,
3764
+ cells: r.cells.map((i) => ({
3765
+ ...i,
3766
+ y: i.y + t,
3767
+ blocks: i.blocks.map((s) => tt(s, t))
3768
+ }))
3769
+ }))
3770
+ }), n;
3771
+ }
3772
+ const Ce = 12, ys = { top: 0, right: 7.2, bottom: 0, left: 7.2 }, fn = (e) => e.margin ?? ys, ke = 4, jt = { indentOf: () => 0, markers: /* @__PURE__ */ new Map() };
3773
+ function ft(e, t, n, r) {
3774
+ const s = Cn(e).map((c) => c * t), o = s.length, a = new Array(o).fill(0), l = e.rows.map((c) => {
3775
+ let f = 0;
3776
+ const u = c.cells.map((g) => {
3777
+ for (; f < o && a[f] > 0; ) f++;
3778
+ const S = Math.max(1, g.colSpan ?? 1), E = Math.max(1, g.rowSpan ?? 1), m = f;
3779
+ let k = 0;
3780
+ for (let N = 0; N < S; N++) k += s[f + N] ?? s[o - 1] ?? 40;
3781
+ if (E > 1) for (let N = 0; N < S && f + N < o; N++) a[f + N] = E;
3782
+ f += S;
3783
+ const T = fn(g), O = Math.max(8, k - T.left - T.right);
3784
+ let w = 0;
3785
+ const R = g.blocks.map((N) => {
3786
+ if (N.kind === "paragraph") {
3787
+ const M = O - N.style.indentLeftPx - r.indentOf(N) - (N.style.indentRightPx ?? 0), G = n(N, Math.max(8, M));
3788
+ return w += N.style.spaceBeforePx + ut(G) + N.style.spaceAfterPx, { kind: "para", block: N, lines: G };
3789
+ }
3790
+ if (N.kind === "image") {
3791
+ const M = Math.min(1, O / Math.max(1, N.widthPx)), G = N.widthPx * M, W = N.heightPx * M;
3792
+ return w += W + ke, { kind: "image", block: N, width: G, height: W };
3793
+ }
3794
+ const b = ft(N, O, n, r);
3795
+ return w += b.height + ke, { kind: "table", block: N, ...b };
3796
+ });
3797
+ return { cell: g, items: R, height: w + T.top + T.bottom, width: k, colStart: m, rowSpan: E };
3798
+ });
3799
+ for (let g = 0; g < o; g++) a[g] > 0 && a[g]--;
3800
+ return { cells: u, height: 0 };
3801
+ }), x = l.map((c) => Math.max(0, ...c.cells.filter((f) => f.rowSpan === 1).map((f) => f.height)));
3802
+ return l.forEach((c, f) => {
3803
+ for (const u of c.cells) {
3804
+ if (u.rowSpan <= 1) continue;
3805
+ const g = Math.min(l.length - 1, f + u.rowSpan - 1);
3806
+ let S = 0;
3807
+ for (let E = f; E <= g; E++) S += x[E];
3808
+ u.height > S && (x[g] += u.height - S);
3809
+ }
3810
+ }), l.forEach((c, f) => c.height = x[f]), { rows: l, colWidths: s, height: x.reduce((c, f) => c + f, 0) };
3811
+ }
3812
+ function ut(e) {
3813
+ let t = 0;
3814
+ for (const n of e) t += n.height;
3815
+ return t;
3816
+ }
3817
+ function ht(e, t, n, r, i, s, o, a) {
3818
+ const l = [0];
3819
+ for (const u of n) l.push(l[l.length - 1] + u);
3820
+ const x = [i];
3821
+ for (const u of t) x.push(x[x.length - 1] + u.height);
3822
+ const c = [];
3823
+ for (let u = 0; u < t.length; u++) {
3824
+ const g = t[u], S = x[u], E = [];
3825
+ for (const m of g.cells) {
3826
+ const k = r + (l[m.colStart] ?? l[l.length - 1]), T = Math.min(t.length - 1, u + m.rowSpan - 1), O = x[T + 1] - S, w = [], R = fn(m.cell), N = m.width - R.left - R.right;
3827
+ let b = S + R.top;
3828
+ for (const M of m.items)
3829
+ if (M.kind === "para") {
3830
+ b += M.block.style.spaceBeforePx;
3831
+ const G = k + R.left + M.block.style.indentLeftPx + a.indentOf(M.block), W = {
3832
+ blockId: M.block.id,
3833
+ x: G,
3834
+ y: b,
3835
+ firstLineIndex: 0,
3836
+ lines: M.lines
3837
+ // line.y is already block-relative; coords stay consistent
3838
+ }, v = a.markers.get(M.block.id);
3839
+ v && (W.marker = { text: v.text, style: v.style, x: Math.max(k + 1, G - v.hangingPx) }), w.push(W), b += ut(M.lines) + M.block.style.spaceAfterPx;
3840
+ } else if (M.kind === "image") {
3841
+ const G = O - R.top - R.bottom;
3842
+ if (m.items.length === 1 && G > M.height + 8) {
3843
+ const W = Math.max(N / M.block.widthPx, G / M.block.heightPx), v = M.block.widthPx * W, _ = M.block.heightPx * W, z = k + R.left, D = S + R.top;
3844
+ w.push({
3845
+ blockId: M.block.id,
3846
+ x: z + (N - v) / 2,
3847
+ y: D + (G - _) / 2,
3848
+ firstLineIndex: 0,
3849
+ lines: [],
3850
+ image: { src: M.block.src, width: v, height: _, clip: { x: z, y: D, width: N, height: G } }
3851
+ }), b += M.height + ke;
3852
+ } else {
3853
+ const W = N - M.width, v = k + R.left + (M.block.align === "center" ? W / 2 : M.block.align === "right" ? W : 0);
3854
+ w.push({
3855
+ blockId: M.block.id,
3856
+ x: v,
3857
+ y: b,
3858
+ firstLineIndex: 0,
3859
+ lines: [],
3860
+ image: { src: M.block.src, width: M.width, height: M.height }
3861
+ }), b += M.height + ke;
3862
+ }
3863
+ } else
3864
+ w.push(ht(M.block, M.rows, M.colWidths, k + R.left, b, N, 0, a)), b += M.height + ke;
3865
+ E.push({
3866
+ x: k,
3867
+ y: S,
3868
+ width: m.width,
3869
+ height: O,
3870
+ originRow: o + u,
3871
+ originCol: m.colStart,
3872
+ blocks: w,
3873
+ ...m.cell.shading !== void 0 ? { shading: m.cell.shading } : {},
3874
+ ...m.cell.borders !== void 0 ? { borders: m.cell.borders } : {},
3875
+ // Horizontal content band (full cell height): clips over-wide text to the
3876
+ // inner box so it never paints onto the border or into the next column.
3877
+ contentClip: { x: k + R.left, y: S, width: N, height: O }
3878
+ });
3879
+ }
3880
+ c.push({ y: S, height: g.height, cells: E });
3881
+ }
3882
+ const f = t.reduce((u, g) => u + g.height, 0);
3883
+ return {
3884
+ blockId: e.id,
3885
+ x: r,
3886
+ y: i,
3887
+ firstLineIndex: o,
3888
+ // for tables this is the chunk's first ROW index
3889
+ lines: [],
3890
+ table: { x: r, y: i, width: s, height: f, rows: c, colWidths: n }
3891
+ };
3892
+ }
3893
+ const vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3894
+ __proto__: null,
3895
+ createLayoutEngine: Ss,
3896
+ effectiveSection: ln,
3897
+ resolveSections: cn
3898
+ }, Symbol.toStringTag, { value: "Module" }));
3899
+ function Is(e) {
3900
+ const t = /* @__PURE__ */ new Map(), n = (r, i) => {
3901
+ for (const s of r)
3902
+ 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);
3903
+ };
3904
+ for (const r of e.pages) n(r.blocks, r.number);
3905
+ return t;
3906
+ }
3907
+ function Rs(e, t) {
3908
+ const n = Is(t), r = [];
3909
+ for (const i of e.blocks) {
3910
+ if (i.kind !== "paragraph") continue;
3911
+ const s = i.runs.find((f) => f.style.link?.startsWith("#"))?.style.link?.slice(1);
3912
+ if (!s) continue;
3913
+ const o = e.bookmarks?.[s]?.start.blockId;
3914
+ if (!o) continue;
3915
+ const a = n.get(o);
3916
+ if (a === void 0) continue;
3917
+ const l = kn(i.runs), x = l.match(/\t(\d+)(\s*)$/);
3918
+ if (!x || x[1] === String(a)) continue;
3919
+ const c = l.length - x[2].length - x[1].length;
3920
+ r.push({
3921
+ blockId: i.id,
3922
+ start: c,
3923
+ end: c + x[1].length,
3924
+ text: String(a),
3925
+ style: Dn(i.runs, c) ?? i.runs[0]?.style
3926
+ });
3927
+ }
3928
+ return r;
3929
+ }
3930
+ export {
3931
+ Rs as a,
3932
+ Ss as c,
3933
+ vs as e,
3934
+ Is as p
3935
+ };