@paprize/core 0.1.0 → 0.3.0

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.
@@ -8,7 +8,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
8
8
  }, c = (n, r, a) => (a = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule ? t(a, "default", {
9
9
  value: n,
10
10
  enumerable: !0
11
- }) : a, n)), l = "paprize", u = "pz-temp-container", d = "pz-current-element", f = "pz-current-text", p = "pz-ignored-element", m = "pz-ignored-text", h = "paprize-global-style", g = "pz-page", _ = "pz-section", v = "pz-preview", y = "data-pz-", b = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
11
+ }) : a, n)), l = "paprize", u = "pz-temp-container", d = "pz-current-element", f = "pz-current-text", p = "pz-ignored-element", m = "pz-ignored-text", h = "paprize-global-style", g = "pz-page", _ = "pz-section", v = "pz-preview", y = "data-pz-", b = (/* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
12
12
  (function(e, n) {
13
13
  typeof define == "function" && define.amd ? define(n) : typeof t == "object" && t.exports ? t.exports = n() : e.log = n();
14
14
  })(e, function() {
@@ -131,124 +131,136 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
131
131
  return i;
132
132
  }, a.default = a, a;
133
133
  });
134
- })))(), 1), x = b.default.getLogger(l);
135
- x.setDefaultLevel("info");
134
+ })))(), 1)).default.getLogger(l);
135
+ b.setDefaultLevel("info");
136
136
  //#endregion
137
137
  //#region src/debugUtilities/debugMode.ts
138
- var S = !1, ee = () => {
139
- x.setLevel("debug"), S = !0;
140
- }, C = () => S;
138
+ var ee = !1, te = () => {
139
+ b.setLevel("debug"), ee = !0;
140
+ }, x = () => ee;
141
141
  //#endregion
142
142
  //#region src/paginate/domUtilities.ts
143
- function w(e) {
143
+ function S(e) {
144
144
  return e.nodeType === Node.ELEMENT_NODE;
145
145
  }
146
- function te(e) {
146
+ function ne(e) {
147
147
  return e.nodeType === Node.TEXT_NODE;
148
148
  }
149
- function T(e) {
149
+ function C(e) {
150
150
  let t = e.getBoundingClientRect(), n = getComputedStyle(e), r = parseFloat(n.marginTop) || 0, i = parseFloat(n.marginBottom) || 0;
151
151
  return t.height + r + i;
152
152
  }
153
- function ne(e) {
153
+ function re(e) {
154
154
  e.style.visibility = "hidden", e.style.position = "absolute", e.style.left = "-9999px", e.style.top = "-9999px";
155
155
  }
156
156
  //#endregion
157
157
  //#region src/paginate/LayoutOptions.ts
158
- var E = {
158
+ var w = {
159
159
  hyphen: "-",
160
160
  keepOnSamePage: !1,
161
161
  hyphenationDisabled: !1
162
- }, D = `${y}hyphen`, O = `${y}keep-on-same-page`, k = `${y}hyphenation-disabled`, re = {
162
+ }, T = `${y}hyphen`, E = `${y}keep-on-same-page`, D = `${y}hyphenation-disabled`, O = {
163
163
  hyphen: {
164
- key: D,
164
+ key: T,
165
165
  reader: (e) => String(e)
166
166
  },
167
167
  keepOnSamePage: {
168
- key: O,
169
- reader: (e) => e === "true"
168
+ key: E,
169
+ reader: (e) => {
170
+ switch (e) {
171
+ case "true": return !0;
172
+ case "false": return !1;
173
+ case "prefer": return "prefer";
174
+ default: return w.keepOnSamePage;
175
+ }
176
+ }
170
177
  },
171
178
  hyphenationDisabled: {
172
- key: k,
179
+ key: D,
173
180
  reader: (e) => e === "true"
174
181
  }
175
182
  };
176
183
  function ie(e) {
177
184
  let t = {};
178
185
  for (let [n, r] of Object.entries(e)) {
179
- let e = re[n];
186
+ let e = O[n];
180
187
  e !== void 0 && r !== void 0 && (t[e.key] = String(r));
181
188
  }
182
189
  return t;
183
190
  }
184
- var A = /* @__PURE__ */ new WeakMap();
191
+ var k = /* @__PURE__ */ new WeakMap();
185
192
  function ae(e, t, n, r) {
186
193
  n != null && (r[e] = t(n));
187
194
  }
188
- function j(e) {
195
+ function A(e) {
189
196
  if (!e) return {};
190
- if (!(e instanceof Element)) return j(e?.parentNode);
197
+ if (!(e instanceof Element)) return A(e?.parentNode);
191
198
  let t = {};
192
- for (let n of Object.keys(E)) {
193
- let r = n, i = re[r], a = e.getAttribute(i.key);
199
+ for (let n of Object.keys(w)) {
200
+ let r = n, i = O[r], a = e.getAttribute(i.key);
194
201
  ae(r, i.reader, a, t);
195
202
  }
196
203
  let n = {
197
- ...e.parentNode ? A.get(e.parentNode) : void 0,
204
+ ...e.parentNode ? k.get(e.parentNode) : void 0,
198
205
  ...t
199
206
  };
200
- return A.set(e, n), n;
207
+ return k.set(e, n), n;
201
208
  }
202
209
  //#endregion
203
210
  //#region src/paginate/PaginationOptions.ts
204
- var M = {
211
+ var oe = {
205
212
  id: "default",
206
213
  plugins: [],
207
- ...E
214
+ ...w
208
215
  };
209
- function oe(e, t) {
210
- let n = j(e);
216
+ function se(e, t) {
217
+ let n = A(e);
211
218
  return {
212
- ...M,
219
+ ...oe,
213
220
  ...t,
214
221
  ...n
215
222
  };
216
223
  }
217
224
  //#endregion
218
225
  //#region src/paginate/PaginationPlugin.ts
219
- var N = "\x1B[46mPLUGIN\x1B[0m";
220
- function P(e, t, ...n) {
226
+ var j = "\x1B[46mPLUGIN\x1B[0m";
227
+ function M(e, t, ...n) {
221
228
  e.sort((e, t) => e.order - t.order).forEach((e) => {
222
229
  let r = e[t];
223
230
  if (r) {
224
- x.debug(N, `executing plugin ${e.name}:${String(t)} ()`, n);
231
+ b.debug(j, `executing plugin ${e.name}:${String(t)} ()`, n);
225
232
  try {
226
- r(...n), x.debug(N, `plugin ${e.name}:${String(t)} executed`, n);
233
+ r(...n), b.debug(j, `plugin ${e.name}:${String(t)} executed`, n);
227
234
  } catch (n) {
228
- x.debug(N, `plugin ${e.name}:${String(t)} failed`, n);
235
+ b.debug(j, `plugin ${e.name}:${String(t)} failed`, n);
229
236
  }
230
237
  }
231
238
  });
232
239
  }
233
240
  //#endregion
234
241
  //#region src/paginate/PageNodes.ts
235
- var F = {
242
+ var N = {
236
243
  Element: "element",
237
244
  Text: "text"
238
- }, I = class e {
245
+ }, P = class e {
239
246
  _node;
240
247
  config;
241
- type = F.Element;
248
+ type = N.Element;
242
249
  transaction;
243
- clonedFrom;
244
- cloneCount;
250
+ clonedData;
245
251
  constructor(e, t, n, r) {
246
- this._node = e, this.transaction = t, this.config = n, this.clonedFrom = r, this.cloneCount = r ? r.cloneCount + 1 : 0;
252
+ this._node = e, this.transaction = t, this.config = n, this.clonedData = r ? {
253
+ clonedFrom: r,
254
+ cloneCount: r.clonedData.cloneCount + 1
255
+ } : {
256
+ clonedFrom: void 0,
257
+ cloneCount: 0
258
+ };
247
259
  }
248
260
  getOriginalNode() {
249
- let e = this.clonedFrom;
250
- for (; e?.clonedFrom;) e = e.clonedFrom;
251
- return e?._node;
261
+ let e = this.clonedData.clonedFrom;
262
+ for (; e?.clonedData.clonedFrom;) e = e.clonedData.clonedFrom;
263
+ return e?._node ?? this._node;
252
264
  }
253
265
  appendChild(e) {
254
266
  this.transaction.isActive && this.transaction.addRollbackCallback(() => {
@@ -257,10 +269,10 @@ var F = {
257
269
  }
258
270
  clone(t) {
259
271
  let n = new e(this._node.cloneNode(t), this.transaction, this.config, this);
260
- return P(this.config.plugins, "onClone", this.config.id, this._node, n), n;
272
+ return M(this.config.plugins, "onClone", this.config.id, this._node, n), n;
261
273
  }
262
274
  getHeight() {
263
- return T(this._node);
275
+ return C(this._node);
264
276
  }
265
277
  remove() {
266
278
  this.transaction.addCommitCallback(() => {
@@ -276,9 +288,9 @@ var F = {
276
288
  getNode() {
277
289
  return this._node;
278
290
  }
279
- }, se = class {
291
+ }, ce = class {
280
292
  _node;
281
- type = F.Text;
293
+ type = N.Text;
282
294
  transaction;
283
295
  config;
284
296
  constructor(e, t, n) {
@@ -299,25 +311,25 @@ var F = {
299
311
  return this._node;
300
312
  }
301
313
  };
302
- function L(e, t, n) {
303
- if (te(e)) return new se(e, t, n);
304
- if (w(e)) return new I(e, t, n);
314
+ function F(e, t, n) {
315
+ if (ne(e)) return new ce(e, t, n);
316
+ if (S(e)) return new P(e, t, n);
305
317
  throw Error("Unsupported node type");
306
318
  }
307
319
  //#endregion
308
320
  //#region src/debugUtilities/pageNodeMarker.ts
309
- function ce(e) {
310
- C() && (e && e.type == F.Element ? e.getNode().classList.add(p) : e && e.type == F.Text && e.getNode().parentElement?.classList.add(m));
311
- }
312
321
  function le(e) {
313
- C() && (e && e.type == F.Element ? e.getNode().classList.add(d) : e && e.type == F.Text && e.getNode().parentElement?.classList.add(f));
322
+ x() && (e && e.type == N.Element ? e.getNode().classList.add(p) : e && e.type == N.Text && e.getNode().parentElement?.classList.add(m));
314
323
  }
315
- function R(e) {
316
- C() && (e && e.type == F.Element ? e.getNode().classList.remove(d) : e && e.type == F.Text && e.getNode().parentElement?.classList.remove(f));
324
+ function ue(e) {
325
+ x() && (e && e.type == N.Element ? e.getNode().classList.add(d) : e && e.type == N.Text && e.getNode().parentElement?.classList.add(f));
326
+ }
327
+ function I(e) {
328
+ x() && (e && e.type == N.Element ? e.getNode().classList.remove(d) : e && e.type == N.Text && e.getNode().parentElement?.classList.remove(f));
317
329
  }
318
330
  //#endregion
319
331
  //#region src/paginate/DomState.ts
320
- var z = "\x1B[106mDOM\x1B[0m", ue = class {
332
+ var L = "\x1B[106mDOM\x1B[0m", de = class {
321
333
  _transaction;
322
334
  _treeWalker;
323
335
  _config;
@@ -337,27 +349,27 @@ var z = "\x1B[106mDOM\x1B[0m", ue = class {
337
349
  return this._previousNode;
338
350
  }
339
351
  goToNextNode() {
340
- this._treeWalker.nextNode() || (this._completed = !0), x.debug(z, "moving to next node"), this.setState();
352
+ this._treeWalker.nextNode() || (this._completed = !0), b.debug(L, "moving to next node"), this.setState();
341
353
  }
342
354
  goToNextSiblingOrParentSibling() {
343
355
  let e = 0;
344
- if (this._treeWalker.nextSibling()) return x.debug(z, "moving to next sibling node"), this.setState(), { parentsTraversed: e };
345
- for (; this._treeWalker.parentNode();) if (e++, this._treeWalker.nextSibling()) return x.debug(z, "moving to parent sibling node, traversed:", e), this.setState(), { parentsTraversed: e };
356
+ if (this._treeWalker.nextSibling()) return b.debug(L, "moving to next sibling node"), this.setState(), { parentsTraversed: e };
357
+ for (; this._treeWalker.parentNode();) if (e++, this._treeWalker.nextSibling()) return b.debug(L, "moving to parent sibling node, traversed:", e), this.setState(), { parentsTraversed: e };
346
358
  return this._completed = !0, { parentsTraversed: e };
347
359
  }
348
360
  goToFirstChildOrNextNode() {
349
- return this._treeWalker.firstChild() ? (x.debug(z, "moving to first child node"), this.setState(), { parentsTraversed: 1 }) : (this.goToNextNode(), { parentsTraversed: 0 });
361
+ return this._treeWalker.firstChild() ? (b.debug(L, "moving to first child node"), this.setState(), { parentsTraversed: 1 }) : (this.goToNextNode(), { parentsTraversed: 0 });
350
362
  }
351
363
  setState() {
352
- this._previousNode = this._currentNode, this._currentNode = L(this._treeWalker.currentNode, this._transaction, oe(this._treeWalker.currentNode, this._config));
353
- DEV: le(this._currentNode);
354
- DEV: R(this._previousNode);
355
- x.debug(z, "moved to node", {
364
+ this._previousNode = this._currentNode, this._currentNode = F(this._treeWalker.currentNode, this._transaction, se(this._treeWalker.currentNode, this._config));
365
+ DEV: ue(this._currentNode);
366
+ DEV: I(this._previousNode);
367
+ b.debug(L, "moved to node", {
356
368
  currentNode: this._currentNode,
357
369
  previousNode: this._previousNode
358
370
  });
359
371
  }
360
- }, de = class {
372
+ }, fe = class {
361
373
  _onRollback;
362
374
  _onCommit;
363
375
  isActive;
@@ -384,22 +396,21 @@ var z = "\x1B[106mDOM\x1B[0m", ue = class {
384
396
  commit = () => {
385
397
  this.isActive && (this.isActive = !1, this._onCommit.forEach((e) => e()));
386
398
  };
387
- }, B = "\x1B[102mPAGE\x1B[0m", V = class e {
399
+ }, R = "\x1B[102mPAGE\x1B[0m", z = class e {
388
400
  currentPage;
389
401
  activeElement;
390
402
  currentElement;
391
403
  parentStack;
392
- pageIsFull;
393
404
  pageIndex;
394
405
  pageHeight;
395
- constructor(e, t, n, r, i, a, o) {
396
- this.currentPage = e, this.activeElement = t, this.currentElement = n, this.parentStack = r, this.pageIsFull = i, this.pageIndex = a, this.pageHeight = o;
406
+ constructor(e, t, n, r, i, a) {
407
+ this.currentPage = e, this.activeElement = t, this.currentElement = n, this.parentStack = r, this.pageIndex = i, this.pageHeight = a;
397
408
  }
398
409
  static create(t, n, r, i) {
399
- return new e(t, null, t, n, !1, r, i);
410
+ return new e(t, null, t, n, r, i);
400
411
  }
401
- clone = () => new e(this.currentPage, this.activeElement, this.currentElement, [...this.parentStack], this.pageIsFull, this.pageIndex, this.pageHeight);
402
- }, fe = class e {
412
+ clone = () => new e(this.currentPage, this.activeElement, this.currentElement, [...this.parentStack], this.pageIndex, this.pageHeight);
413
+ }, pe = class e {
403
414
  _pageState;
404
415
  _transaction;
405
416
  _tempContainer;
@@ -407,11 +418,11 @@ var z = "\x1B[106mDOM\x1B[0m", ue = class {
407
418
  constructor(t, n, r, i) {
408
419
  this._tempContainer = t, this._config = i, this._transaction = r;
409
420
  let a = e.createPageHtmlElement(n.width), o = this.createNewPage(a);
410
- this._pageState = V.create(o, [], 0, n.height), P(this._config.plugins, "onNewPage", i.id, this);
421
+ this._pageState = z.create(o, [], 0, n.height), M(this._config.plugins, "onNewPage", i.id, this);
411
422
  }
412
423
  nextPage() {
413
- let e = this.createNewPage(this._pageState.currentPage.getNode().cloneNode(!1)), t = V.create(e, [], this._pageState.pageIndex + 1, this._pageState.pageHeight);
414
- this.cloneParentStackToNewPage(t), this.cleanupEmptyParent(), this._pageState = t, P(this._config.plugins, "onNewPage", this._config.id, this);
424
+ let e = this.createNewPage(this._pageState.currentPage.getNode().cloneNode(!1)), t = z.create(e, [], this._pageState.pageIndex + 1, this._pageState.pageHeight);
425
+ this.cloneParentStackToNewPage(t), this.cleanupEmptyParent(), this._pageState = t, M(this._config.plugins, "onNewPage", this._config.id, this);
415
426
  }
416
427
  cloneParentStackToNewPage(e) {
417
428
  for (let t of this._pageState.parentStack) {
@@ -429,13 +440,13 @@ var z = "\x1B[106mDOM\x1B[0m", ue = class {
429
440
  });
430
441
  }
431
442
  enterElement() {
432
- if (!this._pageState.activeElement || this._pageState.activeElement.type !== F.Element) throw Error("Invalid state: activeElement is not an Element");
433
- x.debug(B, "entering an element", this._pageState.activeElement), this._pageState.currentElement = this._pageState.activeElement, this._pageState.parentStack.push(this._pageState.activeElement);
443
+ if (!this._pageState.activeElement || this._pageState.activeElement.type !== N.Element) throw Error("Invalid state: activeElement is not an Element");
444
+ b.debug(R, "entering an element", this._pageState.activeElement), this._pageState.currentElement = this._pageState.activeElement, this._pageState.parentStack.push(this._pageState.activeElement);
434
445
  }
435
446
  leaveElement() {
436
447
  this._pageState.activeElement = null;
437
448
  let e = this._pageState.parentStack.pop();
438
- x.debug(B, "leaving a parent element", e);
449
+ b.debug(R, "leaving a parent element", e);
439
450
  let t = this._pageState.parentStack.at(-1);
440
451
  this._pageState.currentElement = t ?? this._pageState.currentPage;
441
452
  }
@@ -444,9 +455,9 @@ var z = "\x1B[106mDOM\x1B[0m", ue = class {
444
455
  return t.style.width = `${e}px`, t.style.maxWidth = `${e}px`, t.className = g, t;
445
456
  }
446
457
  createNewPage(e) {
447
- return x.debug(B, "creating new page"), this._tempContainer.appendChild(e), this._transaction.isActive && this._transaction.addRollbackCallback(() => {
458
+ return b.debug(R, "creating new page"), this._tempContainer.appendChild(e), this._transaction.isActive && this._transaction.addRollbackCallback(() => {
448
459
  this._tempContainer.removeChild(e);
449
- }), L(e, this._transaction, this._config);
460
+ }), F(e, this._transaction, this._config);
450
461
  }
451
462
  startTransaction() {
452
463
  this._transaction.start();
@@ -456,95 +467,113 @@ var z = "\x1B[106mDOM\x1B[0m", ue = class {
456
467
  }), this._transaction;
457
468
  }
458
469
  hasEmptySpace(e) {
459
- return !this._pageState.pageIsFull && this._pageState.currentPage.getHeight() + (e || 1e-4) <= this._pageState.pageHeight;
470
+ return this._pageState.currentPage.getHeight() + (e || 1e-4) <= this._pageState.pageHeight;
460
471
  }
461
472
  isOverFlow() {
462
- return this._pageState.pageIsFull || this._pageState.currentPage.getHeight() > this._pageState.pageHeight;
463
- }
464
- markPageAsFull() {
465
- x.debug(B, "marking page as full", this._pageState.activeElement), this._pageState.pageIsFull = !0;
473
+ return this._pageState.currentPage.getHeight() > this._pageState.pageHeight;
466
474
  }
467
475
  appendChild(e, t) {
468
476
  let n = e.clone(t);
469
- DEV: R(n);
477
+ DEV: I(n);
470
478
  return this._pageState.currentElement.appendChild(n), this._pageState.activeElement = n, n;
471
479
  }
472
480
  addTextNode(e) {
473
- if (this._pageState.activeElement?.type === F.Text) return this._pageState.activeElement;
474
- let t = L(document.createTextNode(e), this._transaction, this._config);
481
+ if (this._pageState.activeElement?.type === N.Text) return this._pageState.activeElement;
482
+ let t = F(document.createTextNode(e), this._transaction, this._config);
475
483
  return this._pageState.currentElement.appendChild(t), this._pageState.activeElement = t, t;
476
484
  }
477
485
  getPageState() {
478
486
  return this._pageState;
479
487
  }
480
- }, H = {
488
+ }, B = {
481
489
  None: 0,
482
490
  FullNodePlaced: 1,
483
491
  SplitChildren: 2
484
492
  };
485
493
  //#endregion
486
494
  //#region src/paginate/paginateElement.ts
487
- function pe(e, t) {
488
- let n = U(e, t);
489
- if (n !== H.None) return n;
495
+ function me(e, t) {
496
+ let n = V(e, t);
497
+ if (n !== B.None) return n;
490
498
  let { rollback: r, commit: i } = t.startTransaction();
491
499
  t.nextPage();
492
- let a = U(e, t);
493
- return a === H.None ? (r(), x.error("Element is too big to fit on a page", e), H.None) : (i(), a);
500
+ let a = V(e, t);
501
+ return a === B.None ? (r(), e.config.keepOnSamePage === "prefer" ? H(e, t) : B.None) : (i(), a);
494
502
  }
495
- function U(e, t) {
503
+ function V(e, t) {
496
504
  if (t.hasEmptySpace(e.getHeight())) {
497
505
  let n = t.appendChild(e, !0);
498
506
  if (t.isOverFlow()) n.remove();
499
- else return H.FullNodePlaced;
507
+ else return B.FullNodePlaced;
500
508
  }
501
- if (e.config.keepOnSamePage || e.getChildrenCount() === 0) return H.None;
509
+ return e.config.keepOnSamePage === !1 ? H(e, t) : B.None;
510
+ }
511
+ function H(e, t) {
512
+ if (e.getChildrenCount() === 0) return B.None;
502
513
  let n = t.appendChild(e, !1);
503
- return t.isOverFlow() ? (n.remove(), H.None) : H.SplitChildren;
514
+ return t.isOverFlow() ? (n.remove(), B.None) : B.SplitChildren;
504
515
  }
505
516
  //#endregion
506
517
  //#region src/paginate/paginateText.ts
507
- function me(e, t) {
508
- let n = H.FullNodePlaced, r = e.textContent.split(/(\s+)/).filter((e) => e !== ""), i, a = 0;
518
+ function he(e, t) {
519
+ let n = B.FullNodePlaced, r = e.textContent.split(/(\s+)/).filter((e) => e !== ""), i, a = 0;
509
520
  for (; i || a < r.length;) {
510
- let o = he(i ?? r[a], t, e.config);
511
- o.completed || (n = H.None), o.pendingToken ? i = o.pendingToken : (i = void 0, a++);
521
+ let o = ge(i ?? r[a], t, e.config);
522
+ o.completed || (n = B.None), o.pendingToken ? i = o.pendingToken : (i = void 0, a++);
512
523
  }
513
524
  return n;
514
525
  }
515
- function he(e, t, n) {
526
+ function ge(e, t, n) {
516
527
  let r = t.addTextNode(""), i = r.textContent;
517
528
  if (r.textContent += e, !t.isOverFlow()) return { completed: !0 };
518
529
  r.textContent = i;
519
- let a = ge(e, t, n);
530
+ let a = _e(e, t, n);
520
531
  return {
521
532
  pendingToken: a.leftovers,
522
533
  completed: a.completed
523
534
  };
524
535
  }
525
- function ge(e, t, n) {
536
+ function _e(e, t, n) {
526
537
  let { rollback: r, commit: i } = t.startTransaction();
527
538
  if (t.nextPage(), t.addTextNode(e), !t.isOverFlow()) return i(), { completed: !0 };
528
- if (r(), n.hyphenationDisabled) return x.warn("Hyphenation disabled, skipping oversized token:", e), { completed: !1 };
539
+ if (r(), n.hyphenationDisabled) return b.warn("Hyphenation disabled, skipping oversized token:", e), { completed: !1 };
529
540
  t.hasEmptySpace() || t.nextPage();
530
- let a = _e(e, n.hyphen, t);
541
+ let a = ve(e, n.hyphen, t);
531
542
  return {
532
543
  completed: !0,
533
544
  leftovers: a && a.length > 0 ? a : void 0
534
545
  };
535
546
  }
536
- function _e(e, t, n) {
547
+ function ve(e, t, n) {
537
548
  let r = n.addTextNode(""), i = "";
538
549
  for (let a = 0; a < e.length; a++) {
539
550
  let o = e[a], s = i + o;
540
- if (r.textContent = s + t, !n.hasEmptySpace()) return r.textContent = i ? i + t : "", n.markPageAsFull(), e.slice(a);
551
+ if (r.textContent = s + t, !n.hasEmptySpace()) return r.textContent = i ? i + t : "", n.nextPage(), e.slice(a);
541
552
  i = s;
542
553
  }
543
554
  return null;
544
555
  }
545
556
  //#endregion
557
+ //#region src/utils.ts
558
+ function ye(e, t) {
559
+ return `${e}-${t + 1}`;
560
+ }
561
+ function U(e, t) {
562
+ return t === "landscape" ? {
563
+ height: e.width,
564
+ width: e.height
565
+ } : e;
566
+ }
567
+ function W(e) {
568
+ if (!e) return "undefined";
569
+ let t = e.getNode();
570
+ if (!(t instanceof Element)) return String(t).slice(0, 100);
571
+ let n = t.id ? `#${t.id}` : "", r = t.classList.length ? `.${Array.from(t.classList).join(".")}` : "";
572
+ return `<${t.tagName.toLowerCase()}${n}${r}>`;
573
+ }
574
+ //#endregion
546
575
  //#region src/paginate/Paginator.ts
547
- var W = "\x1B[103mPAGINATOR\x1B[0m", G = class e {
576
+ var G = "\x1B[103mPAGINATOR\x1B[0m", K = class e {
548
577
  _domState;
549
578
  _pageManager;
550
579
  _transaction;
@@ -552,66 +581,66 @@ var W = "\x1B[103mPAGINATOR\x1B[0m", G = class e {
552
581
  _config;
553
582
  constructor(t, n, r) {
554
583
  this._config = {
555
- ...M,
584
+ ...oe,
556
585
  ...r
557
- }, this._tempContainer = e.createTempContainer(this._config.id), this._transaction = new de(), this._domState = new ue(t, this._transaction, this._config), this._pageManager = new fe(this._tempContainer, n, this._transaction, this._config);
586
+ }, this._tempContainer = e.createTempContainer(this._config.id), this._transaction = new fe(), this._domState = new de(t, this._transaction, this._config), this._pageManager = new pe(this._tempContainer, n, this._transaction, this._config);
558
587
  }
559
588
  static createTempContainer(e) {
560
589
  let t = document.createElement("div");
561
- return t.style.display = "flex", t.style.flexDirection = "column", t.style.gap = "20px", t.setAttribute(`${y}-section-id`, e), t.classList.add(u), C() || ne(t), document.body.appendChild(t), t;
590
+ return t.style.display = "flex", t.style.flexDirection = "column", t.style.gap = "20px", t.setAttribute(`${y}-section-id`, e), t.classList.add(u), x() || re(t), document.body.appendChild(t), t;
562
591
  }
563
592
  static paginate(t, n, r) {
564
593
  let i = new e(t, n, r);
565
594
  i.processAllNodes();
566
- let a = Array.from(i._tempContainer.childNodes).filter((e) => w(e)).map((e) => e.innerHTML);
567
- return C() ? Array.from(i._tempContainer.childNodes).forEach((e) => {
595
+ let a = Array.from(i._tempContainer.childNodes).filter((e) => S(e)).map((e) => e.innerHTML);
596
+ return x() ? Array.from(i._tempContainer.childNodes).forEach((e) => {
568
597
  let t = e;
569
598
  t.style.height = `${n.height}px`, t.style.width = `${n.width}px`;
570
599
  }) : i._tempContainer.remove(), a;
571
600
  }
572
601
  processAllNodes() {
573
- P(this._config.plugins, "beforePagination", this._config.id, this._domState, this._pageManager), this._domState.goToNextNode();
602
+ M(this._config.plugins, "beforePagination", this._config.id, this._domState, this._pageManager), this._domState.goToNextNode();
574
603
  do {
575
- b.default.debug(W, "paginating node", this._domState.currentNode);
604
+ b.debug(G, "paginating node", this._domState.currentNode);
576
605
  let e = this.processCurrentNode();
577
- switch (P(this._config.plugins, "afterVisitNode", this._config.id, e, this._domState, this._pageManager), e) {
578
- case H.None:
606
+ switch (M(this._config.plugins, "afterVisitNode", this._config.id, e, this._domState, this._pageManager), e) {
607
+ case B.None:
579
608
  this.handleNodeSkipped();
580
609
  break;
581
- case H.FullNodePlaced:
610
+ case B.FullNodePlaced:
582
611
  this.handleFullNodePlaced();
583
612
  break;
584
- case H.SplitChildren:
613
+ case B.SplitChildren:
585
614
  this.handleChildrenSplit();
586
615
  break;
587
616
  }
588
617
  } while (this._domState.completed === !1);
589
- P(this._config.plugins, "afterPagination", this._config.id, this._domState, this._pageManager), b.default.debug(W, "pagination completed");
618
+ M(this._config.plugins, "afterPagination", this._config.id, this._domState, this._pageManager), b.debug(G, "pagination completed");
590
619
  }
591
620
  handleNodeSkipped() {
592
- b.default.debug(W, "node skipped - couldn't paginate");
593
- DEV: ce(this._domState.currentNode);
621
+ b.error("Node is too big to fit on a page. Skipping node:", W(this._domState.currentNode), this._domState.currentNode);
622
+ DEV: le(this._domState.currentNode);
594
623
  this._domState.goToNextSiblingOrParentSibling();
595
624
  }
596
625
  handleFullNodePlaced() {
597
- b.default.debug(W, "node fully paginated");
626
+ b.debug(G, "node fully paginated");
598
627
  let { parentsTraversed: e } = this._domState.goToNextSiblingOrParentSibling();
599
628
  for (let t = 0; t < e; t++) this._pageManager.leaveElement();
600
629
  }
601
630
  handleChildrenSplit() {
602
- b.default.debug(W, "node partially paginated - splitting children"), this._domState.goToFirstChildOrNextNode().parentsTraversed === 1 && this._domState.previousNode?.type === F.Element && this._pageManager.enterElement();
631
+ b.debug(G, "node partially paginated - splitting children"), this._domState.goToFirstChildOrNextNode().parentsTraversed === 1 && this._domState.previousNode?.type === N.Element && this._pageManager.enterElement();
603
632
  }
604
633
  processCurrentNode() {
605
- if (!this._domState.currentNode) return H.None;
606
- if (this._domState.currentNode.type === F.Element) {
634
+ if (!this._domState.currentNode) return B.None;
635
+ if (this._domState.currentNode.type === N.Element) {
607
636
  let e = {};
608
- return P(this._config.plugins, "onVisitElement", this._config.id, this._domState, this._pageManager, e), e.result === void 0 ? pe(this._domState.currentNode, this._pageManager) : e.result;
637
+ return M(this._config.plugins, "onVisitElement", this._config.id, this._domState, this._pageManager, e), e.result === void 0 ? me(this._domState.currentNode, this._pageManager) : e.result;
609
638
  } else {
610
639
  let e = {};
611
- return P(this._config.plugins, "onVisitText", this._config.id, this._domState, this._pageManager, e), e.result === void 0 ? me(this._domState.currentNode, this._pageManager) : e.result;
640
+ return M(this._config.plugins, "onVisitText", this._config.id, this._domState, this._pageManager, e), e.result === void 0 ? he(this._domState.currentNode, this._pageManager) : e.result;
612
641
  }
613
642
  }
614
- }, K = class {
643
+ }, q = class {
615
644
  registry = /* @__PURE__ */ new Map();
616
645
  addEventListener(e, t) {
617
646
  let { registry: n } = this, r = new Set(n.get(e));
@@ -625,7 +654,7 @@ var W = "\x1B[103mPAGINATOR\x1B[0m", G = class e {
625
654
  let { registry: n } = this, r = n.get(e);
626
655
  if (r) for (let e of r) await e(...t);
627
656
  }
628
- }, ve = {
657
+ }, be = {
629
658
  A1: {
630
659
  height: "841mm",
631
660
  width: "594mm"
@@ -674,7 +703,7 @@ var W = "\x1B[103mPAGINATOR\x1B[0m", G = class e {
674
703
  height: "11in",
675
704
  width: "17in"
676
705
  }
677
- }, q = {
706
+ }, xe = {
678
707
  Normal: {
679
708
  top: "1in",
680
709
  right: "1in",
@@ -699,26 +728,26 @@ var W = "\x1B[103mPAGINATOR\x1B[0m", G = class e {
699
728
  bottom: "0in",
700
729
  left: "0in"
701
730
  }
702
- }, J = "__PAPRIZE_IS_INITIALIZED", Y = "__PAPRIZE_IS_READY", ye = "__PAPRIZE_READ_JSON_DATA_FILE";
731
+ }, J = "__PAPRIZE_IS_INITIALIZED", Y = "__PAPRIZE_IS_READY", Se = "__PAPRIZE_READ_JSON_DATA_FILE";
703
732
  //#endregion
704
733
  //#region src/report/utils.ts
705
- function be(e) {
734
+ function Ce(e) {
706
735
  let t = e.getBoundingClientRect(), n = getComputedStyle(e), r = parseFloat(n.marginLeft) || 0, i = parseFloat(n.marginRight) || 0;
707
736
  return {
708
- height: T(e),
737
+ height: C(e),
709
738
  width: t.width + r + i
710
739
  };
711
740
  }
712
- function xe(e, t, n) {
713
- let { height: r, width: i } = be(e);
741
+ function we(e, t, n) {
742
+ let { height: r, width: i } = Ce(e);
714
743
  return {
715
744
  height: r,
716
745
  width: i,
717
- sectionHeaderHeight: t ? T(t) : 0,
718
- sectionFooterHeight: n ? T(n) : 0
746
+ sectionHeaderHeight: t ? C(t) : 0,
747
+ sectionFooterHeight: n ? C(n) : 0
719
748
  };
720
749
  }
721
- function Se(e, t, n) {
750
+ function Te(e, t, n) {
722
751
  return {
723
752
  name: "sectionPageHeight",
724
753
  order: 1,
@@ -731,21 +760,21 @@ function Se(e, t, n) {
731
760
  }
732
761
  };
733
762
  }
734
- function Ce(e) {
763
+ function Ee(e) {
735
764
  return e ? `${e.top} ${e.right} ${e.bottom} ${e.left}` : "0";
736
765
  }
737
- function we(e) {
766
+ function De(e) {
738
767
  let t = null;
739
768
  return () => (t ||= e(), t);
740
769
  }
741
- async function Te() {
770
+ async function Oe() {
742
771
  if (!("__PAPRIZE_READ_JSON_DATA_FILE" in window)) return null;
743
- let e = await window[ye]?.();
772
+ let e = await window[Se]?.();
744
773
  return e ? JSON.parse(e) : null;
745
774
  }
746
775
  //#endregion
747
776
  //#region src/report/reportStyles.ts
748
- var Ee = `
777
+ var ke = `
749
778
  html {
750
779
  box-sizing: border-box;
751
780
  }
@@ -793,35 +822,35 @@ var Ee = `
793
822
  display: none !important;
794
823
  }
795
824
  }
796
- `, De = {
825
+ `, Ae = {
797
826
  display: "flex",
798
827
  flexDirection: "column"
799
- }, Oe = {
828
+ }, je = {
800
829
  position: "absolute",
801
830
  left: "-9999px",
802
831
  top: "-9999px",
803
832
  visibility: "hidden"
804
- }, ke = (e, t) => ({
833
+ }, Me = (e, t) => ({
805
834
  display: "flex",
806
835
  flexDirection: "column",
807
836
  width: e.width,
808
837
  height: e.height,
809
838
  maxHeight: e.height,
810
839
  position: "relative",
811
- padding: Ce(t),
840
+ padding: Ee(t),
812
841
  zIndex: "1"
813
- }), Ae = {
842
+ }), Ne = {
814
843
  overflow: "hidden",
815
844
  width: "100%",
816
845
  height: "100%"
817
- }, je = {
846
+ }, Pe = {
818
847
  position: "absolute",
819
848
  width: "100%",
820
849
  height: "100%",
821
850
  left: 0,
822
851
  top: 0
823
- }, Me = (e) => ({ page: `section-${e}` });
824
- function Ne(e, t) {
852
+ }, Fe = (e) => ({ page: `section-${e}` });
853
+ function Ie(e, t) {
825
854
  return `@page section-${e} {
826
855
  margin: none;
827
856
  size:${t.width} ${t.height};
@@ -830,21 +859,21 @@ function Ne(e, t) {
830
859
  }`;
831
860
  }
832
861
  var X = {
833
- globalStyle: Ee,
834
- component: De,
835
- outOfScreen: Oe,
836
- page: ke,
837
- overlay: je,
838
- pageContent: Ae,
839
- sectionPageMedia: Ne,
840
- section: Me
862
+ globalStyle: ke,
863
+ component: Ae,
864
+ outOfScreen: je,
865
+ page: Me,
866
+ overlay: Pe,
867
+ pageContent: Ne,
868
+ sectionPageMedia: Ie,
869
+ section: Fe
841
870
  };
842
871
  //#endregion
843
872
  //#region src/report/sectionComponents.ts
844
873
  function Z(e) {
845
874
  return e?.cloneNode(!0) ?? null;
846
875
  }
847
- function Pe(e) {
876
+ function Le(e) {
848
877
  return {
849
878
  sectionHeader: Z(e.sectionHeader),
850
879
  sectionFooter: Z(e.sectionFooter),
@@ -854,15 +883,56 @@ function Pe(e) {
854
883
  };
855
884
  }
856
885
  //#endregion
857
- //#region src/plugins/PageBreakPlugin.ts
858
- var Fe = `${y}page-break`, Ie = class {
886
+ //#region src/plugins/OrderedListPlugin.ts
887
+ var Re = class {
888
+ _originalItemCount = /* @__PURE__ */ new Map();
889
+ name = "orderedList";
890
+ order = 1;
891
+ onClone = (e, t, n) => {
892
+ if (!this._isListItem(t) || !(n.clonedData.cloneCount > 1)) return;
893
+ let r = n.getNode();
894
+ r.style.listStyleType = "none";
895
+ let i = n.clonedData.clonedFrom?.getNode().parentElement, a = n.getOriginalNode().parentElement;
896
+ if (!i || !a || !this._isOrderedList(i) || !this._isOrderedList(a)) return;
897
+ let o = this._readRenderedItemCount(a, (e) => e === i);
898
+ this._setListItemCount(a, i, o - 1);
899
+ };
900
+ afterVisitNode = (e, t, n, r) => {
901
+ let i = r.getPageState().currentElement, a = i.getNode();
902
+ if (!this._isOrderedList(a)) return;
903
+ let o = i.getOriginalNode(), s = this._readRenderedItemCount(o, (e) => e !== a);
904
+ a.start = o.start + s;
905
+ let c = this._getListItemCount(a);
906
+ this._setListItemCount(o, a, c);
907
+ };
908
+ beforePagination = () => {
909
+ this._originalItemCount.clear();
910
+ };
911
+ _isListItem(e) {
912
+ return e.tagName === "LI";
913
+ }
914
+ _isOrderedList(e) {
915
+ return e.tagName === "OL";
916
+ }
917
+ _setListItemCount(e, t, n) {
918
+ let r = this._originalItemCount.get(e) ?? /* @__PURE__ */ new Map();
919
+ r.set(t, n), this._originalItemCount.set(e, r);
920
+ }
921
+ _readRenderedItemCount(e, t) {
922
+ let n = this._originalItemCount.get(e);
923
+ return n ? [...n.entries()].filter((e) => t(e[0])).reduce((e, t) => e + t[1], 0) : 0;
924
+ }
925
+ _getListItemCount(e) {
926
+ return [...e.children].filter((e) => this._isListItem(e)).length;
927
+ }
928
+ }, Q = `${y}page-break`, ze = class {
859
929
  name = "pageBreak";
860
930
  order = 1;
861
931
  onVisitElement = (e, t, n, r) => {
862
- let i = t.currentNode.getNode().getAttribute(Fe);
863
- (i === "true" || i === "") && (n.markPageAsFull(), r.result = H.FullNodePlaced);
932
+ let i = t.currentNode.getNode().getAttribute(Q);
933
+ (i === "true" || i === "") && (n.nextPage(), r.result = B.FullNodePlaced);
864
934
  };
865
- }, Le = class {
935
+ }, Be = class {
866
936
  _options = {};
867
937
  name = "table";
868
938
  order = 1;
@@ -872,31 +942,31 @@ var Fe = `${y}page-break`, Ie = class {
872
942
  onNewPage = (e, t) => {
873
943
  if (this._options.includeHeaderOnlyTables) return;
874
944
  let n = t.getPageState().parentStack.find((e) => this._isTable(e.getNode()));
875
- if (!n || !n.clonedFrom) return;
876
- let r = n.clonedFrom, i = r.getNode(), a = i.tHead;
945
+ if (!n || !n.clonedData.clonedFrom) return;
946
+ let r = n.clonedData.clonedFrom, i = r.getNode(), a = i.tHead;
877
947
  if (a === null) return;
878
948
  let o = i.tBodies;
879
949
  if (this._isTableBodyEmpty(o) && (r.remove(), n.getNode().tHead === null)) {
880
- let e = L(a.cloneNode(!0), n.transaction, n.config);
950
+ let e = F(a.cloneNode(!0), n.transaction, n.config);
881
951
  n.appendChild(e);
882
952
  }
883
953
  };
884
954
  onVisitElement = (e, t, n, r) => {
885
955
  let i = t.currentNode.getNode();
886
- i.tagName === "TR" ? t.currentNode.config.keepOnSamePage = !0 : (i.tagName === "TFOOT" && this._options.cloneFooter || i.tagName === "THEAD" && this._options.cloneHeader) && (r.result = H.FullNodePlaced);
956
+ i.tagName === "TR" ? t.currentNode.config.keepOnSamePage = "prefer" : (i.tagName === "TFOOT" && this._options.cloneFooter || i.tagName === "THEAD" && this._options.cloneHeader) && (r.result = B.FullNodePlaced);
887
957
  };
888
958
  onClone = (e, t, n) => {
889
- if (!this._isTable(t) || !n.clonedFrom) return;
959
+ if (!this._isTable(t) || !n.clonedData.clonedFrom) return;
890
960
  let r = n.getNode();
891
961
  if (r.tHead || r.tFoot) return;
892
962
  let i = n.getOriginalNode(), a = i.tHead;
893
963
  if (a && this._options.cloneHeader === !0) {
894
- let e = new I(a.cloneNode(!0), n.transaction, n.config);
964
+ let e = new P(a.cloneNode(!0), n.transaction, n.config);
895
965
  n.appendChild(e);
896
966
  }
897
967
  let o = i.tFoot;
898
968
  if (o && this._options.cloneFooter === !0) {
899
- let e = new I(o.cloneNode(!0), n.transaction, n.config);
969
+ let e = new P(o.cloneNode(!0), n.transaction, n.config);
900
970
  n.appendChild(e);
901
971
  }
902
972
  };
@@ -911,15 +981,19 @@ var Fe = `${y}page-break`, Ie = class {
911
981
  let n = t.rows[0];
912
982
  return n.cells.length === 0 ? !0 : n.cells.length > 1 ? !1 : n.cells[0].textContent?.trim().length === 0;
913
983
  }
914
- }, Re = [new Ie(), new Le()], ze = {
984
+ }, Ve = [
985
+ new ze(),
986
+ new Be(),
987
+ new Re()
988
+ ], He = {
915
989
  name: "debug",
916
990
  order: 2 ** 53 - 1,
917
991
  onNewPage: (e, t) => {
918
992
  let n = t.getPageState().currentPage.getNode();
919
993
  n.classList.contains("pz-page") || n.classList.add(g), n.setAttribute(`${y}-element`, "page"), n.setAttribute(`${y}-height`, t.getPageState().pageHeight.toString());
920
994
  }
921
- }, Be = "sectionToc", Ve = class {
922
- name = Be;
995
+ }, Ue = "sectionToc", We = class {
996
+ name = Ue;
923
997
  order = 1;
924
998
  _state = /* @__PURE__ */ new Map();
925
999
  getContentList = () => Array.from(this._state.values()).flat();
@@ -943,11 +1017,11 @@ var Fe = `${y}page-break`, Ie = class {
943
1017
  let t = e.tagName;
944
1018
  return /^H[1-6]$/.test(t) ? parseInt(t.charAt(1), 10) : null;
945
1019
  }
946
- }, He = class e {
1020
+ }, Ge = class e {
947
1021
  _promises;
948
1022
  monitor;
949
1023
  constructor() {
950
- this._promises = [], this.monitor = new K();
1024
+ this._promises = [], this.monitor = new q();
951
1025
  }
952
1026
  toPromise() {
953
1027
  return this._promises.length > 0 ? Promise.allSettled(this._promises.map((e) => e.promise)).then((e) => {
@@ -985,28 +1059,14 @@ var Fe = `${y}page-break`, Ie = class {
985
1059
  getPending() {
986
1060
  return Array.from(this._promises.values()).filter((e) => e.status === "pending");
987
1061
  }
988
- };
989
- //#endregion
990
- //#region src/utils.ts
991
- function Ue(e, t) {
992
- return `${e}-${t + 1}`;
993
- }
994
- function We(e, t) {
995
- return t === "landscape" ? {
996
- height: e.width,
997
- width: e.height
998
- } : e;
999
- }
1000
- //#endregion
1001
- //#region src/report/ReportBuilder.ts
1002
- var Q = "\x1B[43mREPORT\x1B[0m", Ge = class {
1062
+ }, $ = "\x1B[43mREPORT\x1B[0m", Ke = class {
1003
1063
  _sections;
1004
1064
  _monitor;
1005
1065
  _paginationInProgress;
1006
1066
  _pendingPaginateResolvers;
1007
1067
  _currentAbortController;
1008
1068
  constructor() {
1009
- this._sections = /* @__PURE__ */ new Map(), this._monitor = new K(), this._paginationInProgress = !1, this._pendingPaginateResolvers = [], this._currentAbortController = null, window[J] = !0, this._injectStyle(X.globalStyle);
1069
+ this._sections = /* @__PURE__ */ new Map(), this._monitor = new q(), this._paginationInProgress = !1, this._pendingPaginateResolvers = [], this._currentAbortController = null, window[J] = !0, this._injectStyle(X.globalStyle);
1010
1070
  }
1011
1071
  get monitor() {
1012
1072
  return this._monitor;
@@ -1024,7 +1084,7 @@ var Q = "\x1B[43mREPORT\x1B[0m", Ge = class {
1024
1084
  pages: [],
1025
1085
  options: {
1026
1086
  ...e,
1027
- size: We(e.size, e.orientation ?? "portrait")
1087
+ size: U(e.size, e.orientation ?? "portrait")
1028
1088
  },
1029
1089
  components: t
1030
1090
  };
@@ -1037,7 +1097,7 @@ var Q = "\x1B[43mREPORT\x1B[0m", Ge = class {
1037
1097
  return this._sections.size === 0 ? (window[Y] = !0, {
1038
1098
  sections: [],
1039
1099
  suspension: Promise.resolve()
1040
- }) : (this._paginationInProgress && this._currentAbortController && (x.debug(Q, "Cancelling previous pagination operation."), this._currentAbortController.abort("Cancelled by new paginate call")), this._paginationInProgress ? new Promise((e, t) => {
1100
+ }) : (this._paginationInProgress && this._currentAbortController && (b.debug($, "Cancelling previous pagination operation."), this._currentAbortController.abort("Cancelled by new paginate call")), this._paginationInProgress ? new Promise((e, t) => {
1041
1101
  this._pendingPaginateResolvers.push({
1042
1102
  resolve: e,
1043
1103
  reject: t
@@ -1047,12 +1107,12 @@ var Q = "\x1B[43mREPORT\x1B[0m", Ge = class {
1047
1107
  async getJsonData(e) {
1048
1108
  return await this._lazyJsonDataReader().catch(() => e) ?? e ?? null;
1049
1109
  }
1050
- _lazyJsonDataReader = we(Te);
1110
+ _lazyJsonDataReader = De(Oe);
1051
1111
  async _executePagination() {
1052
1112
  this._paginationInProgress = !0, this._currentAbortController = new AbortController();
1053
1113
  let e = this._currentAbortController.signal;
1054
1114
  try {
1055
- if (x.debug(Q, "Schedule paginate."), await document.fonts.ready, e.aborted) return new Promise((e, t) => {
1115
+ if (b.debug($, "Schedule paginate."), await document.fonts.ready, e.aborted) return new Promise((e, t) => {
1056
1116
  this._pendingPaginateResolvers.push({
1057
1117
  resolve: e,
1058
1118
  reject: t
@@ -1061,16 +1121,16 @@ var Q = "\x1B[43mREPORT\x1B[0m", Ge = class {
1061
1121
  let t = [];
1062
1122
  for (let n of this._sections.values()) {
1063
1123
  n.context.isPaginated = !1;
1064
- let r = new He();
1124
+ let r = new Ge();
1065
1125
  await r.add(n.context.options.suspense), r.monitor.addEventListener("onChange", (e) => {
1066
- x.debug(Q, `${e} pending promises in section '${n.context.sectionId}'.`);
1126
+ b.debug($, `${e} pending promises in section '${n.context.sectionId}'.`);
1067
1127
  }), r.then(async () => {
1068
- e.aborted || (x.debug(Q, `Start paginating section '${n.context.sectionId}'.`), n.context.isSuspended = !1, await this._paginateSection(n));
1128
+ e.aborted || (b.debug($, `Start paginating section '${n.context.sectionId}'.`), n.context.isSuspended = !1, await this._paginateSection(n));
1069
1129
  }), t.push(r);
1070
1130
  }
1071
- let n = new He();
1131
+ let n = new Ge();
1072
1132
  return n.monitor.addEventListener("onChange", async () => {
1073
- x.debug(Q, "Report pagination completed."), await this._monitor.dispatch("paginationCycleCompleted", { sections: [...this._sections.values()].map((e) => e.context) });
1133
+ b.debug($, "Report pagination completed."), await this._monitor.dispatch("paginationCycleCompleted", { sections: [...this._sections.values()].map((e) => e.context) });
1074
1134
  }), e.aborted ? new Promise((e, t) => {
1075
1135
  this._pendingPaginateResolvers.push({
1076
1136
  resolve: e,
@@ -1088,7 +1148,7 @@ var Q = "\x1B[43mREPORT\x1B[0m", Ge = class {
1088
1148
  }
1089
1149
  async _processPendingPagination() {
1090
1150
  if (this._pendingPaginateResolvers.length === 0) return;
1091
- x.debug(Q, `Processing ${this._pendingPaginateResolvers.length} pending paginate calls.`);
1151
+ b.debug($, `Processing ${this._pendingPaginateResolvers.length} pending paginate calls.`);
1092
1152
  let e = [...this._pendingPaginateResolvers];
1093
1153
  this._pendingPaginateResolvers = [];
1094
1154
  let t = await this._executePagination();
@@ -1101,17 +1161,17 @@ var Q = "\x1B[43mREPORT\x1B[0m", Ge = class {
1101
1161
  async _paginateSection(e) {
1102
1162
  let t = document.createElement("div");
1103
1163
  /* v8 ignore if -- @preserve */
1104
- Object.assign(t.style, X.page(e.context.options.size, e.context.options.margin ?? q.None)), C() || Object.assign(t.style, X.outOfScreen);
1105
- let n = Pe(e.context.components);
1164
+ Object.assign(t.style, X.page(e.context.options.size, e.context.options.margin ?? xe.None)), x() || Object.assign(t.style, X.outOfScreen);
1165
+ let n = Le(e.context.components);
1106
1166
  n.sectionHeader && (Object.assign(n.sectionHeader.style, X.component), t.appendChild(n.sectionHeader)), n.pageHeader && (Object.assign(n.pageHeader.style, X.component), t.appendChild(n.pageHeader)), Object.assign(n.pageContent.style, X.pageContent), t.appendChild(n.pageContent), n.pageFooter && (Object.assign(n.pageFooter.style, X.component), t.appendChild(n.pageFooter)), n.sectionFooter && (Object.assign(n.sectionFooter.style, X.component), t.appendChild(n.sectionFooter)), document.body.appendChild(t);
1107
- let { height: r, width: i, sectionHeaderHeight: a, sectionFooterHeight: o } = xe(n.pageContent, n.sectionHeader, n.sectionFooter);
1108
- if (r === 0) throw x.error(`Pagination failed for section '${e.context.sectionId}': insufficient space for page content or content is empty. Ensure that the section has content and that the header and footer do not occupy all available space.`), t.remove(), Error(`Pagination failed: no available space for content in section '${e.context.sectionId}'.`);
1109
- let s = G.paginate(n.pageContent, {
1167
+ let { height: r, width: i, sectionHeaderHeight: a, sectionFooterHeight: o } = we(n.pageContent, n.sectionHeader, n.sectionFooter);
1168
+ if (r === 0) throw b.error(`Pagination failed for section '${e.context.sectionId}': insufficient space for page content or content is empty. Ensure that the section has content and that the header and footer do not occupy all available space.`), t.remove(), Error(`Pagination failed: no available space for content in section '${e.context.sectionId}'.`);
1169
+ let s = K.paginate(n.pageContent, {
1110
1170
  height: r,
1111
1171
  width: i
1112
1172
  }, {
1113
1173
  id: e.context.sectionId,
1114
- plugins: [...e.context.options.plugins ?? Re, Se(r, a, o)]
1174
+ plugins: [...e.context.options.plugins ?? Ve, Te(r, a, o)]
1115
1175
  });
1116
1176
  t.remove();
1117
1177
  let c = s.map((t, n) => ({
@@ -1132,17 +1192,17 @@ var Q = "\x1B[43mREPORT\x1B[0m", Ge = class {
1132
1192
  for (let e of c) await this._monitor.dispatch("pageCompleted", e);
1133
1193
  await this._monitor.dispatch("sectionCompleted", l);
1134
1194
  }
1135
- }, $ = /* @__PURE__ */ "ad.adipisicing.aliqua.aliquip.amet.anim.aute.cillum.commodo.consectetur.consequat.culpa.cupidatat.deserunt.do.dolor.dolore.duis.ea.eiusmod.elit.enim.esse.est.et.eu.ex.excepteur.exercitation.fugiat.id.in.incididunt.ipsum.irure.labore.laboris.laborum.Lorem.magna.minim.mollit.nisi.non.nostrud.nulla.occaecat.officia.pariatur.proident.qui.quis.reprehenderit.sint.sit.sunt.tempor.ullamco.ut.velit.veniam.voluptate".split(".");
1136
- function Ke(e, t) {
1195
+ }, qe = /* @__PURE__ */ "ad.adipisicing.aliqua.aliquip.amet.anim.aute.cillum.commodo.consectetur.consequat.culpa.cupidatat.deserunt.do.dolor.dolore.duis.ea.eiusmod.elit.enim.esse.est.et.eu.ex.excepteur.exercitation.fugiat.id.in.incididunt.ipsum.irure.labore.laboris.laborum.Lorem.magna.minim.mollit.nisi.non.nostrud.nulla.occaecat.officia.pariatur.proident.qui.quis.reprehenderit.sint.sit.sunt.tempor.ullamco.ut.velit.veniam.voluptate".split(".");
1196
+ function Je(e, t) {
1137
1197
  if (e <= 0) return "";
1138
1198
  let n = [], r = Math.floor(t * 982451653);
1139
1199
  for (let t = 0; t < e; t++) {
1140
- let e = (r + t * 2654435761) % 2 ** 32, i = Math.floor(e / 2 ** 32 * $.length);
1141
- n.push($[i]);
1200
+ let e = (r + t * 2654435761) % 2 ** 32, i = Math.floor(e / 2 ** 32 * qe.length);
1201
+ n.push(qe[i]);
1142
1202
  }
1143
1203
  return n.length > 0 && (n[0] = n[0].charAt(0).toUpperCase() + n[0].slice(1)), n.join(" ") + ".";
1144
1204
  }
1145
1205
  //#endregion
1146
- export { K as EventDispatcher, Ie as PageBreakPlugin, G as Paginator, Ge as ReportBuilder, Ve as SectionTocPlugin, H as SplitResult, Le as TablePlugin, We as adjustPageSize, y as attributePrefix, Ue as buildPageId, Pe as cloneComponents, Ke as createLoremIpsumParagraph, d as currentElementClassName, f as currentTextClassName, ze as debugPlugin, Re as defaultPlugins, ee as enableDebugMode, j as getNodeLayoutOptionsFromAttribute, T as getVisibleHeight, Ee as globalStyle, h as globalStyleId, p as ignoredElementClassName, m as ignoredTextClassName, C as isDebugMode, w as isElement, te as isTextNode, D as layoutOptionHyphenAttribute, k as layoutOptionHyphenationDisabledAttribute, O as layoutOptionKeepOnSamePageAttribute, ie as layoutOptionsToAttributes, x as logger, l as loggerName, ne as moveOffscreen, Fe as pageBreakAttributeName, g as pageClassName, q as pageMargin, ve as pageSize, J as paprize_isInitialized, Y as paprize_isReady, ye as paprize_readJsonDataFile, v as previewClassName, X as reportStyles, _ as sectionClassName, Be as sectionTocName, u as tempContainerClassName };
1206
+ export { q as EventDispatcher, Re as OrderedListPlugin, ze as PageBreakPlugin, K as Paginator, Ke as ReportBuilder, We as SectionTocPlugin, B as SplitResult, Be as TablePlugin, U as adjustPageSize, y as attributePrefix, ye as buildPageId, Le as cloneComponents, Je as createLoremIpsumParagraph, d as currentElementClassName, f as currentTextClassName, He as debugPlugin, Ve as defaultPlugins, te as enableDebugMode, A as getNodeLayoutOptionsFromAttribute, C as getVisibleHeight, ke as globalStyle, h as globalStyleId, p as ignoredElementClassName, m as ignoredTextClassName, x as isDebugMode, S as isElement, ne as isTextNode, T as layoutOptionHyphenAttribute, D as layoutOptionHyphenationDisabledAttribute, E as layoutOptionKeepOnSamePageAttribute, ie as layoutOptionsToAttributes, b as logger, l as loggerName, re as moveOffscreen, Q as pageBreakAttributeName, g as pageClassName, xe as pageMargin, W as pageNodeToString, be as pageSize, J as paprize_isInitialized, Y as paprize_isReady, Se as paprize_readJsonDataFile, v as previewClassName, X as reportStyles, _ as sectionClassName, Ue as sectionTocName, u as tempContainerClassName };
1147
1207
 
1148
1208
  //# sourceMappingURL=paprize-core.js.map