@paprize/react 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,802 +1,95 @@
1
- import { jsx as w, jsxs as X, Fragment as E } from "react/jsx-runtime";
2
- import me, { useInsertionEffect as Oe, useRef as x, createElement as We, createContext as ie, useReducer as Ve, useEffect as D, useDebugValue as Ue, useCallback as je, useContext as $, Children as Je, isValidElement as qe, useMemo as L, useState as we, useId as Se } from "react";
3
- import { paprize_isReady as Ge, getVisibleHeight as Z, logger as W, defaultPlugins as Ke, isDebugMode as be, Paginator as Ye, tempContainerClassName as Qe, pageBreakAttributeName as Xe, configToAttributeMap as Ze, paprize_readJsonDataFile as et } from "@paprize/core";
4
- import { createPortal as tt } from "react-dom";
5
- function re(e) {
6
- Oe(() => {
7
- const t = document.createElement("style");
8
- return t.textContent = e, document.head.appendChild(t), () => t.remove();
9
- }, [e]);
10
- }
11
- const B = "paprize-preview", nt = `
12
- :root {
13
- --paprize-page-background-color: #ffffff;
14
- --paprize-page-margin-bottom: 10px;
15
- --paprize-page-box-shadow: rgb(142 138 138) -1px 3px 5px 2px;
16
- --paprize-section-margin-bottom: 10px;
17
- --paprize-preview-background-color: rgb(218 220 224);
18
- --paprize-preview-padding: 30px 10px;
19
- }
20
-
21
- body {
22
- margin: 0;
23
- }
24
-
25
- @media screen {
26
- .${B} {
27
- min-height: 100vh;
28
- display: flex;
29
- flex-direction: column;
30
- align-items: center;
31
- background-color: var(--paprize-preview-background-color);
32
- padding: var(--paprize-preview-padding);
33
- }
34
-
35
- .paprize-page {
36
- box-shadow: var(--paprize-page-box-shadow);
37
- margin-bottom: var(--paprize-page-margin-bottom);
38
- background-color: var(--paprize-page-background-color);
39
- }
40
-
41
- .paprize-section {
42
- margin-bottom: var(--paprize-section-margin-bottom);
43
- }
44
- }
45
-
46
- @media print {
47
- html *:not(.${B}):not(.${B} *):not(:has(.${B})) {
48
- display: none !important;
49
- }
50
- }
51
- `;
52
- function on({ children: e }) {
53
- return re(nt), /* @__PURE__ */ w("div", { className: B, children: e });
54
- }
55
- const z = {};
56
- function ye(e, t) {
57
- return e.unstable_is ? e.unstable_is(t) : t === e;
58
- }
59
- function Ae(e) {
60
- return "init" in e;
61
- }
62
- function ee(e) {
63
- return !!e.write;
64
- }
65
- function de(e) {
66
- return "v" in e || "e" in e;
67
- }
68
- function U(e) {
69
- if ("e" in e)
70
- throw e.e;
71
- if ((z ? "production" : void 0) !== "production" && !("v" in e))
72
- throw new Error("[Bug] atom state is not initialized");
73
- return e.v;
74
- }
75
- const j = /* @__PURE__ */ new WeakMap();
76
- function Pe(e) {
77
- var t;
78
- return J(e) && !!((t = j.get(e)) != null && t[0]);
79
- }
80
- function ot(e) {
81
- const t = j.get(e);
82
- t?.[0] && (t[0] = !1, t[1].forEach((o) => o()));
83
- }
84
- function te(e, t) {
85
- let o = j.get(e);
86
- if (!o) {
87
- o = [!0, /* @__PURE__ */ new Set()], j.set(e, o);
88
- const n = () => {
89
- o[0] = !1;
90
- };
91
- e.then(n, n);
92
- }
93
- o[1].add(t);
94
- }
95
- function J(e) {
96
- return typeof e?.then == "function";
97
- }
98
- function _e(e, t, o) {
99
- if (!o.p.has(e)) {
100
- o.p.add(e);
101
- const n = () => o.p.delete(e);
102
- t.then(n, n);
103
- }
104
- }
105
- function ke(e, t, o) {
106
- var n;
107
- const i = /* @__PURE__ */ new Set();
108
- for (const r of ((n = o.get(e)) == null ? void 0 : n.t) || [])
109
- o.has(r) && i.add(r);
110
- for (const r of t.p)
111
- i.add(r);
112
- return i;
113
- }
114
- const it = (e, t, ...o) => t.read(...o), rt = (e, t, ...o) => t.write(...o), st = (e, t) => {
115
- var o;
116
- return (o = t.unstable_onInit) == null ? void 0 : o.call(t, e);
117
- }, at = (e, t, o) => {
118
- var n;
119
- return (n = t.onMount) == null ? void 0 : n.call(t, o);
120
- }, ct = (e, t) => {
121
- const o = _(e), n = o[0], i = o[9];
122
- if ((z ? "production" : void 0) !== "production" && !t)
123
- throw new Error("Atom is undefined or null");
124
- let r = n.get(t);
125
- return r || (r = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, n.set(t, r), i?.(e, t)), r;
126
- }, lt = (e) => {
127
- const t = _(e), o = t[1], n = t[3], i = t[4], r = t[5], s = t[6], f = t[13], p = [], c = (a) => {
128
- try {
129
- a();
130
- } catch (g) {
131
- p.push(g);
132
- }
133
- };
134
- do {
135
- s.f && c(s.f);
136
- const a = /* @__PURE__ */ new Set(), g = a.add.bind(a);
137
- n.forEach((h) => {
138
- var v;
139
- return (v = o.get(h)) == null ? void 0 : v.l.forEach(g);
140
- }), n.clear(), r.forEach(g), r.clear(), i.forEach(g), i.clear(), a.forEach(c), n.size && f(e);
141
- } while (n.size || r.size || i.size);
142
- if (p.length)
143
- throw new AggregateError(p);
144
- }, ut = (e) => {
145
- const t = _(e), o = t[1], n = t[2], i = t[3], r = t[11], s = t[14], f = t[17], p = [], c = /* @__PURE__ */ new WeakSet(), a = /* @__PURE__ */ new WeakSet(), g = Array.from(i);
146
- for (; g.length; ) {
147
- const h = g[g.length - 1], v = r(e, h);
148
- if (a.has(h)) {
149
- g.pop();
150
- continue;
151
- }
152
- if (c.has(h)) {
153
- if (n.get(h) === v.n)
154
- p.push([h, v]);
155
- else if ((z ? "production" : void 0) !== "production" && n.has(h))
156
- throw new Error("[Bug] invalidated atom exists");
157
- a.add(h), g.pop();
158
- continue;
159
- }
160
- c.add(h);
161
- for (const m of ke(h, v, o))
162
- c.has(m) || g.push(m);
163
- }
164
- for (let h = p.length - 1; h >= 0; --h) {
165
- const [v, m] = p[h];
166
- let l = !1;
167
- for (const d of m.d.keys())
168
- if (d !== v && i.has(d)) {
169
- l = !0;
170
- break;
171
- }
172
- l && (s(e, v), f(e, v)), n.delete(v);
173
- }
174
- }, dt = (e, t) => {
175
- var o;
176
- const n = _(e), i = n[1], r = n[2], s = n[3], f = n[6], p = n[7], c = n[11], a = n[12], g = n[13], h = n[14], v = n[16], m = n[17], l = c(e, t);
177
- if (de(l) && (i.has(t) && r.get(t) !== l.n || Array.from(l.d).every(
178
- ([b, R]) => (
179
- // Recursively, read the atom state of the dependency, and
180
- // check if the atom epoch number is unchanged
181
- h(e, b).n === R
182
- )
183
- )))
184
- return l;
185
- l.d.clear();
186
- let d = !0;
187
- function u() {
188
- i.has(t) && (m(e, t), g(e), a(e));
189
- }
190
- function y(b) {
191
- var R;
192
- if (ye(t, b)) {
193
- const T = c(e, b);
194
- if (!de(T))
195
- if (Ae(b))
196
- q(e, b, b.init);
197
- else
198
- throw new Error("no atom init");
199
- return U(T);
200
- }
201
- const C = h(e, b);
202
- try {
203
- return U(C);
204
- } finally {
205
- l.d.set(b, C.n), Pe(l.v) && _e(t, l.v, C), (R = i.get(b)) == null || R.t.add(t), d || u();
206
- }
207
- }
208
- let A, I;
209
- const k = {
210
- get signal() {
211
- return A || (A = new AbortController()), A.signal;
212
- },
213
- get setSelf() {
214
- return (z ? "production" : void 0) !== "production" && !ee(t) && console.warn("setSelf function cannot be used with read-only atom"), !I && ee(t) && (I = (...b) => {
215
- if ((z ? "production" : void 0) !== "production" && d && console.warn("setSelf function cannot be called in sync"), !d)
216
- try {
217
- return v(e, t, ...b);
218
- } finally {
219
- g(e), a(e);
220
- }
221
- }), I;
222
- }
223
- }, H = l.n;
224
- try {
225
- const b = p(e, t, y, k);
226
- return q(e, t, b), J(b) && (te(b, () => A?.abort()), b.then(u, u)), l;
227
- } catch (b) {
228
- return delete l.v, l.e = b, ++l.n, l;
229
- } finally {
230
- d = !1, H !== l.n && r.get(t) === H && (r.set(t, l.n), s.add(t), (o = f.c) == null || o.call(f, t));
231
- }
232
- }, ft = (e, t) => {
233
- const o = _(e), n = o[1], i = o[2], r = o[11], s = [t];
234
- for (; s.length; ) {
235
- const f = s.pop(), p = r(e, f);
236
- for (const c of ke(f, p, n)) {
237
- const a = r(e, c);
238
- i.set(c, a.n), s.push(c);
239
- }
240
- }
241
- }, Ie = (e, t, ...o) => {
242
- const n = _(e), i = n[3], r = n[6], s = n[8], f = n[11], p = n[12], c = n[13], a = n[14], g = n[15], h = n[17];
243
- let v = !0;
244
- const m = (d) => U(a(e, d)), l = (d, ...u) => {
245
- var y;
246
- const A = f(e, d);
247
- try {
248
- if (ye(t, d)) {
249
- if (!Ae(d))
250
- throw new Error("atom not writable");
251
- const I = A.n, k = u[0];
252
- q(e, d, k), h(e, d), I !== A.n && (i.add(d), (y = r.c) == null || y.call(r, d), g(e, d));
253
- return;
254
- } else
255
- return Ie(e, d, ...u);
256
- } finally {
257
- v || (c(e), p(e));
258
- }
259
- };
260
- try {
261
- return s(e, t, m, l, ...o);
262
- } finally {
263
- v = !1;
264
- }
265
- }, gt = (e, t) => {
266
- var o;
267
- const n = _(e), i = n[1], r = n[3], s = n[6], f = n[11], p = n[15], c = n[18], a = n[19], g = f(e, t), h = i.get(t);
268
- if (h && !Pe(g.v)) {
269
- for (const [v, m] of g.d)
270
- if (!h.d.has(v)) {
271
- const l = f(e, v);
272
- c(e, v).t.add(t), h.d.add(v), m !== l.n && (r.add(v), (o = s.c) == null || o.call(s, v), p(e, v));
273
- }
274
- for (const v of h.d || [])
275
- if (!g.d.has(v)) {
276
- h.d.delete(v);
277
- const m = a(e, v);
278
- m?.t.delete(t);
279
- }
280
- }
281
- }, Le = (e, t) => {
282
- var o;
283
- const n = _(e), i = n[1], r = n[4], s = n[6], f = n[10], p = n[11], c = n[12], a = n[13], g = n[14], h = n[16], v = p(e, t);
284
- let m = i.get(t);
285
- if (!m) {
286
- g(e, t);
287
- for (const l of v.d.keys())
288
- Le(e, l).t.add(t);
289
- if (m = {
290
- l: /* @__PURE__ */ new Set(),
291
- d: new Set(v.d.keys()),
292
- t: /* @__PURE__ */ new Set()
293
- }, i.set(t, m), (o = s.m) == null || o.call(s, t), ee(t)) {
294
- const l = () => {
295
- let d = !0;
296
- const u = (...y) => {
297
- try {
298
- return h(e, t, ...y);
299
- } finally {
300
- d || (a(e), c(e));
301
- }
302
- };
303
- try {
304
- const y = f(e, t, u);
305
- y && (m.u = () => {
306
- d = !0;
307
- try {
308
- y();
309
- } finally {
310
- d = !1;
311
- }
312
- });
313
- } finally {
314
- d = !1;
315
- }
316
- };
317
- r.add(l);
318
- }
319
- }
320
- return m;
321
- }, pt = (e, t) => {
322
- var o;
323
- const n = _(e), i = n[1], r = n[5], s = n[6], f = n[11], p = n[19], c = f(e, t);
324
- let a = i.get(t);
325
- if (a && !a.l.size && !Array.from(a.t).some((g) => {
326
- var h;
327
- return (h = i.get(g)) == null ? void 0 : h.d.has(t);
328
- })) {
329
- a.u && r.add(a.u), a = void 0, i.delete(t), (o = s.u) == null || o.call(s, t);
330
- for (const g of c.d.keys()) {
331
- const h = p(e, g);
332
- h?.t.delete(t);
333
- }
334
- return;
335
- }
336
- return a;
337
- }, q = (e, t, o) => {
338
- const n = _(e)[11], i = n(e, t), r = "v" in i, s = i.v;
339
- if (J(o))
340
- for (const f of i.d.keys())
341
- _e(
342
- t,
343
- o,
344
- n(e, f)
345
- );
346
- i.v = o, delete i.e, (!r || !Object.is(s, i.v)) && (++i.n, J(s) && ot(s));
347
- }, ht = (e, t) => {
348
- const o = _(e)[14];
349
- return U(o(e, t));
350
- }, vt = (e, t, ...o) => {
351
- const n = _(e), i = n[12], r = n[13], s = n[16];
352
- try {
353
- return s(e, t, ...o);
354
- } finally {
355
- r(e), i(e);
356
- }
357
- }, mt = (e, t, o) => {
358
- const n = _(e), i = n[12], r = n[18], s = n[19], p = r(e, t).l;
359
- return p.add(o), i(e), () => {
360
- p.delete(o), s(e, t), i(e);
361
- };
362
- }, Ce = /* @__PURE__ */ new WeakMap();
363
- function _(e) {
364
- const t = Ce.get(e);
365
- if ((z ? "production" : void 0) !== "production" && !t)
1
+ import { jsx as r, Fragment as f, jsxs as R } from "react/jsx-runtime";
2
+ import { previewClassName as V, ReportBuilder as z, reportStyles as i, pageClassName as A, pageMargin as O, adjustDimension as q, sectionClassName as G, pageBreakAttributeName as K, configToAttributeMap as Q, paprize_readJsonDataFile as E } from "@paprize/core";
3
+ import { createContext as h, useContext as g, useMemo as u, useEffect as S, useRef as c, Children as U, isValidElement as W, useState as X, useSyncExternalStore as H } from "react";
4
+ import { createPortal as Y } from "react-dom";
5
+ function fe({ children: e }) {
6
+ return /* @__PURE__ */ r("div", { className: V, children: e });
7
+ }
8
+ const B = h(null);
9
+ function w() {
10
+ const e = g(B);
11
+ if (!e)
366
12
  throw new Error(
367
- "Store must be created by buildStore to read its building blocks"
13
+ "ReportRoot is missing. Please wrap your component tree with ReportRoot component."
368
14
  );
369
- return t;
370
- }
371
- function wt(...e) {
372
- const t = {
373
- get(n) {
374
- const i = _(t)[21];
375
- return i(t, n);
376
- },
377
- set(n, ...i) {
378
- const r = _(t)[22];
379
- return r(t, n, ...i);
380
- },
381
- sub(n, i) {
382
- const r = _(t)[23];
383
- return r(t, n, i);
384
- }
385
- }, o = [
386
- // store state
387
- /* @__PURE__ */ new WeakMap(),
388
- // atomStateMap
389
- /* @__PURE__ */ new WeakMap(),
390
- // mountedMap
391
- /* @__PURE__ */ new WeakMap(),
392
- // invalidatedAtoms
393
- /* @__PURE__ */ new Set(),
394
- // changedAtoms
395
- /* @__PURE__ */ new Set(),
396
- // mountCallbacks
397
- /* @__PURE__ */ new Set(),
398
- // unmountCallbacks
399
- {},
400
- // storeHooks
401
- // atom interceptors
402
- it,
403
- rt,
404
- st,
405
- at,
406
- // building-block functions
407
- ct,
408
- lt,
409
- ut,
410
- dt,
411
- ft,
412
- Ie,
413
- gt,
414
- Le,
415
- pt,
416
- q,
417
- ht,
418
- vt,
419
- mt
420
- ].map((n, i) => e[i] || n);
421
- return Ce.set(t, Object.freeze(o)), t;
422
- }
423
- const Ee = {};
424
- let St = 0;
425
- function N(e, t) {
426
- const o = `atom${++St}`, n = {
427
- toString() {
428
- return (Ee ? "production" : void 0) !== "production" && this.debugLabel ? o + ":" + this.debugLabel : o;
429
- }
430
- };
431
- return typeof e == "function" ? n.read = e : (n.init = e, n.read = bt, n.write = yt), t && (n.write = t), n;
432
- }
433
- function bt(e) {
434
- return e(this);
435
- }
436
- function yt(e, t, o) {
437
- return t(
438
- this,
439
- typeof o == "function" ? o(e(this)) : o
440
- );
441
- }
442
- function se() {
443
- return wt();
444
- }
445
- let F;
446
- function At() {
447
- return F || (F = se(), (Ee ? "production" : void 0) !== "production" && (globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = F), globalThis.__JOTAI_DEFAULT_STORE__ !== F && console.warn(
448
- "Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
449
- ))), F;
450
- }
451
- const Pt = {}, Re = ie(
452
- void 0
453
- );
454
- function xe(e) {
455
- return $(Re) || At();
456
- }
457
- function _t({
458
- children: e,
459
- store: t
460
- }) {
461
- const o = x(void 0);
462
- return !t && !o.current && (o.current = se()), We(
463
- Re.Provider,
464
- {
465
- value: t || o.current
466
- },
467
- e
468
- );
469
- }
470
- const ne = (e) => typeof e?.then == "function", oe = (e) => {
471
- e.status || (e.status = "pending", e.then(
472
- (t) => {
473
- e.status = "fulfilled", e.value = t;
474
- },
475
- (t) => {
476
- e.status = "rejected", e.reason = t;
477
- }
478
- ));
479
- }, kt = me.use || // A shim for older React versions
480
- ((e) => {
481
- if (e.status === "pending")
482
- throw e;
483
- if (e.status === "fulfilled")
484
- return e.value;
485
- throw e.status === "rejected" ? e.reason : (oe(e), e);
486
- }), Y = /* @__PURE__ */ new WeakMap(), fe = (e, t) => {
487
- let o = Y.get(e);
488
- return o || (o = new Promise((n, i) => {
489
- let r = e;
490
- const s = (c) => (a) => {
491
- r === c && n(a);
492
- }, f = (c) => (a) => {
493
- r === c && i(a);
494
- }, p = () => {
495
- try {
496
- const c = t();
497
- ne(c) ? (Y.set(c, o), r = c, c.then(s(c), f(c)), te(c, p)) : n(c);
498
- } catch (c) {
499
- i(c);
500
- }
501
- };
502
- e.then(s(e), f(e)), te(e, p);
503
- }), Y.set(e, o)), o;
504
- };
505
- function G(e, t) {
506
- const { delay: o, unstable_promiseStatus: n = !me.use } = {}, i = xe(), [[r, s, f], p] = Ve(
507
- (a) => {
508
- const g = i.get(e);
509
- return Object.is(a[0], g) && a[1] === i && a[2] === e ? a : [g, i, e];
510
- },
511
- void 0,
512
- () => [i.get(e), i, e]
513
- );
514
- let c = r;
515
- if ((s !== i || f !== e) && (p(), c = i.get(e)), D(() => {
516
- const a = i.sub(e, () => {
517
- if (n)
518
- try {
519
- const g = i.get(e);
520
- ne(g) && oe(
521
- fe(g, () => i.get(e))
522
- );
523
- } catch {
524
- }
525
- if (typeof o == "number") {
526
- setTimeout(p, o);
527
- return;
15
+ return e;
16
+ }
17
+ function ge({ children: e }) {
18
+ const t = u(() => new z(), []);
19
+ return S(() => {
20
+ t.schedulePaginate();
21
+ }, [t]), /* @__PURE__ */ r(B, { value: t, children: e });
22
+ }
23
+ function N({ children: e }) {
24
+ const t = w(), o = c(!1);
25
+ return S(() => {
26
+ const n = t.monitor.addEventListener(
27
+ "paginationCycleCompleted",
28
+ () => {
29
+ o.current = !0;
528
30
  }
529
- p();
530
- });
531
- return p(), a;
532
- }, [i, e, o, n]), Ue(c), ne(c)) {
533
- const a = fe(c, () => i.get(e));
534
- return n && oe(a), kt(a);
535
- }
536
- return c;
537
- }
538
- function ae(e, t) {
539
- const o = xe();
540
- return je(
541
- (...i) => {
542
- if ((Pt ? "production" : void 0) !== "production" && !("write" in e))
543
- throw new Error("not writable atom");
544
- return o.set(e, ...i);
545
- },
546
- [o, e]
547
- );
548
- }
549
- const It = se(), Lt = {
550
- totalPages: 0,
551
- isPaginated: !1,
552
- pendingSuspensions: /* @__PURE__ */ new Set()
553
- }, M = N(/* @__PURE__ */ new Map());
554
- M.debugLabel = "sectionsAtom";
555
- const ce = N({
556
- totalSections: 0,
557
- isPaginated: !1
558
- });
559
- ce.debugLabel = "reportAtom";
560
- function Ct() {
561
- const e = ae(ce), t = G(M);
562
- return D(() => {
563
- const o = t.size, n = Array.from(t.values()).every(
564
- (i) => i.isPaginated
565
31
  );
566
- window[Ge] = n, e({
567
- isPaginated: n && o > 0,
568
- totalSections: o
569
- });
570
- }, [t, e]), null;
571
- }
572
- const Et = `
573
- html {
574
- box-sizing: border-box;
575
- }
576
-
577
- *,
578
- *:before,
579
- *:after {
580
- box-sizing: inherit;
581
- }
582
-
583
- .paprize-page-component {
584
- display: flex;
585
- flex-direction: column;
586
- }
587
- `;
588
- function rn({ children: e }) {
589
- return re(Et), /* @__PURE__ */ X(_t, { store: It, children: [
590
- e,
591
- /* @__PURE__ */ w(Ct, {})
592
- ] });
32
+ return () => n();
33
+ }, [t.monitor]), S(() => {
34
+ o.current && t.schedulePaginate();
35
+ }, [e, t]), /* @__PURE__ */ r(f, { children: e });
593
36
  }
594
- function ze({ children: e }) {
595
- return /* @__PURE__ */ w(E, { children: e });
37
+ function k({ children: e }) {
38
+ return /* @__PURE__ */ r(f, { children: e });
596
39
  }
597
- function Me({ children: e }) {
598
- return /* @__PURE__ */ w(E, { children: e });
40
+ function D({ children: e }) {
41
+ return /* @__PURE__ */ r(f, { children: e });
599
42
  }
600
- function Te({ children: e }) {
601
- return /* @__PURE__ */ w(E, { children: e });
43
+ function T({ children: e }) {
44
+ return /* @__PURE__ */ r(f, { children: e });
602
45
  }
603
- function Fe({ children: e }) {
604
- return /* @__PURE__ */ w(E, { children: e });
46
+ function j({ children: e }) {
47
+ return /* @__PURE__ */ r(f, { children: e });
605
48
  }
606
- function Be({ children: e }) {
607
- return /* @__PURE__ */ w(E, { children: e });
49
+ function L({ children: e }) {
50
+ return /* @__PURE__ */ r(f, { children: e });
608
51
  }
609
- function De({ children: e }) {
610
- return /* @__PURE__ */ w(E, { children: e });
611
- }
612
- function Rt(e) {
613
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
614
- }
615
- var V = { exports: {} }, xt = V.exports, ge;
616
- function zt() {
617
- return ge || (ge = 1, (function(e) {
618
- (function(t, o) {
619
- e.exports ? e.exports = o() : t.log = o();
620
- })(xt, function() {
621
- var t = function() {
622
- }, o = "undefined", n = typeof window !== o && typeof window.navigator !== o && /Trident\/|MSIE /.test(window.navigator.userAgent), i = [
623
- "trace",
624
- "debug",
625
- "info",
626
- "warn",
627
- "error"
628
- ], r = {}, s = null;
629
- function f(l, d) {
630
- var u = l[d];
631
- if (typeof u.bind == "function")
632
- return u.bind(l);
633
- try {
634
- return Function.prototype.bind.call(u, l);
635
- } catch {
636
- return function() {
637
- return Function.prototype.apply.apply(u, [l, arguments]);
638
- };
639
- }
640
- }
641
- function p() {
642
- console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
643
- }
644
- function c(l) {
645
- return l === "debug" && (l = "log"), typeof console === o ? !1 : l === "trace" && n ? p : console[l] !== void 0 ? f(console, l) : console.log !== void 0 ? f(console, "log") : t;
646
- }
647
- function a() {
648
- for (var l = this.getLevel(), d = 0; d < i.length; d++) {
649
- var u = i[d];
650
- this[u] = d < l ? t : this.methodFactory(u, l, this.name);
651
- }
652
- if (this.log = this.debug, typeof console === o && l < this.levels.SILENT)
653
- return "No console available for logging";
654
- }
655
- function g(l) {
656
- return function() {
657
- typeof console !== o && (a.call(this), this[l].apply(this, arguments));
658
- };
659
- }
660
- function h(l, d, u) {
661
- return c(l) || g.apply(this, arguments);
662
- }
663
- function v(l, d) {
664
- var u = this, y, A, I, k = "loglevel";
665
- typeof l == "string" ? k += ":" + l : typeof l == "symbol" && (k = void 0);
666
- function H(S) {
667
- var P = (i[S] || "silent").toUpperCase();
668
- if (!(typeof window === o || !k)) {
669
- try {
670
- window.localStorage[k] = P;
671
- return;
672
- } catch {
673
- }
674
- try {
675
- window.document.cookie = encodeURIComponent(k) + "=" + P + ";";
676
- } catch {
677
- }
678
- }
679
- }
680
- function b() {
681
- var S;
682
- if (!(typeof window === o || !k)) {
683
- try {
684
- S = window.localStorage[k];
685
- } catch {
686
- }
687
- if (typeof S === o)
688
- try {
689
- var P = window.document.cookie, O = encodeURIComponent(k), ue = P.indexOf(O + "=");
690
- ue !== -1 && (S = /^([^;]+)/.exec(
691
- P.slice(ue + O.length + 1)
692
- )[1]);
693
- } catch {
694
- }
695
- return u.levels[S] === void 0 && (S = void 0), S;
696
- }
697
- }
698
- function R() {
699
- if (!(typeof window === o || !k)) {
700
- try {
701
- window.localStorage.removeItem(k);
702
- } catch {
703
- }
704
- try {
705
- window.document.cookie = encodeURIComponent(k) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
706
- } catch {
707
- }
708
- }
709
- }
710
- function C(S) {
711
- var P = S;
712
- if (typeof P == "string" && u.levels[P.toUpperCase()] !== void 0 && (P = u.levels[P.toUpperCase()]), typeof P == "number" && P >= 0 && P <= u.levels.SILENT)
713
- return P;
714
- throw new TypeError("log.setLevel() called with invalid level: " + S);
715
- }
716
- u.name = l, u.levels = {
717
- TRACE: 0,
718
- DEBUG: 1,
719
- INFO: 2,
720
- WARN: 3,
721
- ERROR: 4,
722
- SILENT: 5
723
- }, u.methodFactory = d || h, u.getLevel = function() {
724
- return I ?? A ?? y;
725
- }, u.setLevel = function(S, P) {
726
- return I = C(S), P !== !1 && H(I), a.call(u);
727
- }, u.setDefaultLevel = function(S) {
728
- A = C(S), b() || u.setLevel(S, !1);
729
- }, u.resetLevel = function() {
730
- I = null, R(), a.call(u);
731
- }, u.enableAll = function(S) {
732
- u.setLevel(u.levels.TRACE, S);
733
- }, u.disableAll = function(S) {
734
- u.setLevel(u.levels.SILENT, S);
735
- }, u.rebuild = function() {
736
- if (s !== u && (y = C(s.getLevel())), a.call(u), s === u)
737
- for (var S in r)
738
- r[S].rebuild();
739
- }, y = C(
740
- s ? s.getLevel() : "WARN"
741
- );
742
- var T = b();
743
- T != null && (I = C(T)), a.call(u);
744
- }
745
- s = new v(), s.getLogger = function(d) {
746
- if (typeof d != "symbol" && typeof d != "string" || d === "")
747
- throw new TypeError("You must supply a name when creating a logger.");
748
- var u = r[d];
749
- return u || (u = r[d] = new v(
750
- d,
751
- s.methodFactory
752
- )), u;
753
- };
754
- var m = typeof window !== o ? window.log : void 0;
755
- return s.noConflict = function() {
756
- return typeof window !== o && window.log === s && (window.log = m), s;
757
- }, s.getLoggers = function() {
758
- return r;
759
- }, s.default = s, s;
760
- });
761
- })(V)), V.exports;
762
- }
763
- var Mt = zt();
764
- const Tt = /* @__PURE__ */ Rt(Mt), pe = [
765
- ze,
766
- Te,
767
- Me,
768
- De,
769
- Be,
770
- Fe
52
+ const F = [
53
+ N,
54
+ D,
55
+ k,
56
+ L,
57
+ j,
58
+ T
771
59
  ];
772
- function Ft(e) {
60
+ function Z(e) {
773
61
  let t = null;
774
62
  const o = {};
775
- if (Je.forEach(e, (n) => {
776
- if (!qe(n))
777
- throw Tt.error("Invalid React element found in children", { child: n }), new Error("Invalid React element found in children");
778
- const i = pe.find((r) => r === n.type);
779
- if (!i)
63
+ if (U.forEach(e, (n) => {
64
+ if (!W(n))
65
+ throw new Error(
66
+ `Invalid React element found in children: ${n}`,
67
+ {
68
+ cause: { child: n }
69
+ }
70
+ );
71
+ const s = F.find((a) => a === n.type);
72
+ if (!s)
780
73
  throw Error(
781
- `Component "${n.type}" is not valid as a child for Section, Expected one of: ${pe.map((r) => r.name).join(",")}`
74
+ `Component "${n.type}" is not valid as a child for Section, Expected one of: ${F.map((a) => a.name).join(",")}`
782
75
  );
783
- switch (i) {
784
- case Be:
76
+ switch (s) {
77
+ case j:
785
78
  o.sectionHeader = n;
786
79
  break;
787
- case Fe:
80
+ case T:
788
81
  o.sectionFooter = n;
789
82
  break;
790
- case ze:
83
+ case N:
791
84
  t = n;
792
85
  break;
793
- case Te:
86
+ case D:
794
87
  o.header = n;
795
88
  break;
796
- case Me:
89
+ case k:
797
90
  o.footer = n;
798
91
  break;
799
- case De:
92
+ case L:
800
93
  o.overlay = n;
801
94
  break;
802
95
  }
@@ -804,108 +97,57 @@ function Ft(e) {
804
97
  throw Error("PageContent component is a required child for Section");
805
98
  return { ...o, content: t };
806
99
  }
807
- function Bt(e, t) {
808
- return t === "landscape" ? { height: e.width, width: e.height } : e;
809
- }
810
- function Dt(e, t) {
811
- return `@page section-${e} {
812
- margin: none;
813
- size:${t.width} ${t.height};
814
- width:${t.width};
815
- height:${t.height};
816
- }`;
817
- }
818
- const $e = ie({
819
- pageNumber: 0,
100
+ const x = h(""), _ = h({
101
+ pageIndex: 0,
820
102
  totalPages: 0
821
103
  });
822
- function $t(e) {
823
- return e ? `${e.top} ${e.right} ${e.bottom} ${e.left}` : "0";
824
- }
825
- function Nt(e) {
826
- const t = e.getBoundingClientRect(), o = getComputedStyle(e), n = parseFloat(o.marginLeft) || 0, i = parseFloat(o.marginRight) || 0;
827
- return {
828
- height: Z(e),
829
- width: t.width + n + i
830
- };
831
- }
832
- const K = ie("");
833
- function he({
104
+ function b({
834
105
  elements: e,
835
- dimensions: t,
106
+ dimension: t,
836
107
  margin: o,
837
- pageNumber: n,
838
- totalPages: i,
839
- ref: r,
840
- sectionHeaderRef: s,
841
- sectionFooterRef: f,
842
- contentRef: p
108
+ pageIndex: n,
109
+ totalPages: s,
110
+ ref: a,
111
+ sectionHeaderRef: l,
112
+ sectionFooterRef: d,
113
+ pageHeaderRef: m,
114
+ pageFooterRef: y,
115
+ contentRef: P
843
116
  }) {
844
- const c = $(K), a = L(
845
- () => ({ pageNumber: n, totalPages: i }),
846
- [n, i]
117
+ const v = g(x), C = u(
118
+ () => ({ pageIndex: n, totalPages: s }),
119
+ [n, s]
847
120
  );
848
- return /* @__PURE__ */ w($e, { value: a, children: /* @__PURE__ */ X(
121
+ return /* @__PURE__ */ r(_, { value: C, children: /* @__PURE__ */ R(
849
122
  "div",
850
123
  {
851
- id: `${c}-${n}`,
852
- className: "paprize-page paprize-page-component",
853
- ref: r,
854
- style: {
855
- width: t.width,
856
- height: t.height,
857
- maxHeight: t.height,
858
- position: "relative",
859
- padding: $t(o),
860
- zIndex: 1
861
- },
124
+ id: `${v}-${n}`,
125
+ className: A,
126
+ ref: a,
127
+ style: i.page(t, o ?? O.None),
862
128
  children: [
863
- e.sectionHeader && n == 1 && /* @__PURE__ */ w(
864
- "div",
865
- {
866
- className: "paprize-page-component",
867
- ref: s,
868
- children: e.sectionHeader
869
- }
870
- ),
871
- e.header && /* @__PURE__ */ w("div", { className: "paprize-page-component", children: e.header }),
872
- /* @__PURE__ */ w(
873
- "div",
874
- {
875
- style: {
876
- overflow: "hidden",
877
- width: "100%",
878
- height: "100%"
879
- },
880
- ref: p,
881
- children: e.content
882
- }
883
- ),
884
- e.overlay && /* @__PURE__ */ w(
129
+ e.sectionHeader && n === 0 && /* @__PURE__ */ r("div", { style: i.component, ref: l, children: e.sectionHeader }),
130
+ e.header && /* @__PURE__ */ r("div", { style: i.component, ref: m, children: e.header }),
131
+ /* @__PURE__ */ r("div", { style: i.pageContent, ref: P, children: e.content }),
132
+ e.overlay && /* @__PURE__ */ r("div", { style: i.overlay, children: e.overlay }),
133
+ (e.footer || e.sectionFooter) && /* @__PURE__ */ R(
885
134
  "div",
886
135
  {
887
- style: {
888
- position: "absolute",
889
- width: "100%",
890
- height: "100%",
891
- left: 0,
892
- top: 0
893
- },
894
- children: e.overlay
895
- }
896
- ),
897
- (e.footer || e.sectionFooter) && /* @__PURE__ */ X(
898
- "div",
899
- {
900
- className: "paprize-page-component",
901
- style: { marginTop: "auto" },
136
+ style: { ...i.component, marginTop: "auto" },
902
137
  children: [
903
- e.footer && /* @__PURE__ */ w("div", { className: "paprize-page-component", children: e.footer }),
904
- e.sectionFooter && n == i && /* @__PURE__ */ w(
138
+ e.footer && /* @__PURE__ */ r(
905
139
  "div",
906
140
  {
907
- className: "paprize-page-component",
908
- ref: f,
141
+ style: i.component,
142
+ ref: y,
143
+ children: e.footer
144
+ }
145
+ ),
146
+ e.sectionFooter && n === s - 1 && /* @__PURE__ */ r(
147
+ "div",
148
+ {
149
+ style: i.component,
150
+ ref: d,
909
151
  children: e.sectionFooter
910
152
  }
911
153
  )
@@ -916,354 +158,285 @@ function he({
916
158
  }
917
159
  ) });
918
160
  }
919
- function Ht(e, t, o) {
920
- const { height: n, width: i } = Nt(e), r = t ? Z(t) : 0, s = o ? Z(o) : 0;
921
- return { height: n, width: i, sectionHeaderHeight: r, sectionFooterHeight: s };
922
- }
923
- function Ot(e, t, o) {
924
- return {
925
- name: "sectionPageHeight",
926
- order: 1,
927
- afterVisitNode: (n, i, r) => {
928
- !i.completed || o <= 0 || r.hasEmptySpace(o) || r.nextPage();
929
- },
930
- onNewPage: (n, i) => {
931
- const r = i.getPageState();
932
- r.pageIndex === 0 ? r.pageHeight = e + o : r.pageHeight = e + t + o;
933
- }
934
- };
935
- }
936
- function Wt(e, t) {
937
- const o = L(
938
- () => N(null, (n, i, ...r) => e(n, i, ...r)),
939
- [e]
940
- );
941
- return ae(o);
942
- }
943
- const Vt = {
944
- totalPages: 0,
945
- isPaginated: !1,
946
- pendingSuspensions: 0
947
- }, Ne = () => {
948
- const e = $(K), t = L(
949
- () => N((n) => {
950
- const i = n(M).get(e);
951
- return i ? {
952
- totalPages: i.totalPages,
953
- isPaginated: i.isPaginated,
954
- pendingSuspensions: i.pendingSuspensions.size
955
- } : Vt;
161
+ const $ = h({
162
+ addPlugin: () => {
163
+ throw new Error("addPlugin must be used within a Section");
164
+ },
165
+ addSuspense: () => {
166
+ throw new Error("addSuspense must be used within a Section");
167
+ }
168
+ });
169
+ function ee(e) {
170
+ const t = u(
171
+ () => ({
172
+ plugins: e ?? [],
173
+ suspense: []
956
174
  }),
957
175
  [e]
958
- ), o = G(t);
959
- return {
960
- sectionId: e,
961
- totalPages: o.totalPages
962
- };
963
- };
964
- function Ut(e) {
965
- return Ne(), Wt((o) => (o(M).get(e)?.pendingSuspensions?.size ?? 0) > 0);
966
- }
967
- const le = (e) => {
968
- const t = L(
969
- () => N(
970
- () => 0,
971
- (o, n, i) => {
972
- n(
973
- M,
974
- (r) => new Map(r).set(
975
- e,
976
- i(r.get(e) ?? Lt)
977
- )
978
- );
176
+ ), o = u(
177
+ () => ({
178
+ addPlugin: (n) => {
179
+ t.plugins.push(n);
180
+ },
181
+ addSuspense: (n) => {
182
+ t.suspense.push(n);
979
183
  }
980
- ),
981
- [e]
184
+ }),
185
+ [t]
982
186
  );
983
- return ae(t);
984
- }, Q = "\x1B[41mREACT\x1B[0m", ve = (e, t, o, n, i) => e?.dimensions === o && e?.margin === n && e?.elements === t && e?.config === i && e?.elements === t;
985
- function jt(e, t, o, n) {
986
- const i = $(K), r = Ut(i), s = le(i), f = x(null), [p, c] = we({
987
- results: null,
988
- isLoading: !0
989
- }), a = x(null), g = x(null), h = x(null), v = x(null);
990
- return D(() => {
991
- ve(
992
- f.current,
993
- e,
994
- t,
995
- o,
996
- n
997
- ) || c({
998
- results: null,
999
- isLoading: !0
1000
- });
1001
- }, [t, e, o, n]), D(() => {
1002
- if (!a.current || !v.current || ve(f.current, e, t, o, n))
1003
- return;
1004
- if (r()) {
1005
- W.info(Q, `Section "${i}" is suspended`);
1006
- return;
1007
- }
1008
- const { height: m, width: l, sectionFooterHeight: d, sectionHeaderHeight: u } = Ht(
1009
- v.current,
1010
- g.current,
1011
- h.current
1012
- ), y = [
1013
- ...n.plugins ?? Ke,
1014
- Ot(
1015
- m,
1016
- u,
1017
- d
1018
- )
1019
- ];
1020
- be() && (a.current.style.maxHeight = "none", a.current.style.height = "auto"), W.debug(Q, "Calling Paginator", {
1021
- sectionName: i,
1022
- height: m,
1023
- width: l,
1024
- sectionFooterHeight: d,
1025
- sectionHeaderHeight: u,
1026
- plugins: y
1027
- });
1028
- const A = Ye.paginate(
1029
- v.current,
1030
- { height: m, width: l },
1031
- { ...n, plugins: y }
1032
- );
1033
- W.debug(Q, "Paginator Result", {
1034
- sectionName: i,
1035
- paginatorResult: A
1036
- }), c({
1037
- results: A,
1038
- isLoading: !1
1039
- }), s((I) => ({
1040
- ...I,
1041
- totalPages: A.length,
1042
- isPaginated: !0
1043
- })), f.current = { elements: e, dimensions: t, margin: o, config: n };
1044
- }), {
1045
- ...p,
1046
- pageRef: a,
1047
- sectionHeaderRef: g,
1048
- sectionFooterRef: h,
1049
- contentRef: v
187
+ return {
188
+ controllerState: t,
189
+ controllerValue: o
1050
190
  };
1051
191
  }
1052
- function Jt({
192
+ function te({
1053
193
  elements: e,
1054
- dimensions: t,
194
+ dimension: t,
1055
195
  margin: o,
1056
196
  config: n
1057
197
  }) {
1058
- const { results: i, pageRef: r, sectionHeaderRef: s, sectionFooterRef: f, contentRef: p } = jt(e, t, o, n);
1059
- if (i !== null)
1060
- return /* @__PURE__ */ w(E, { children: i.map((a, g) => /* @__PURE__ */ w(
1061
- he,
198
+ const s = g(x), { controllerState: a, controllerValue: l } = ee(
199
+ n?.plugins
200
+ ), d = w(), m = c(null), y = c(null), P = c(null), v = c(null), C = c(null), I = c(null), [J, M] = X(
201
+ null
202
+ );
203
+ return S(() => {
204
+ if (I.current)
205
+ return d.tryAddSection(
206
+ {
207
+ ...n,
208
+ id: s,
209
+ dimension: t,
210
+ margin: o,
211
+ plugins: a.plugins,
212
+ suspense: a.suspense
213
+ },
214
+ {
215
+ pageContent: I.current,
216
+ sectionHeader: y.current,
217
+ sectionFooter: P.current,
218
+ pageFooter: C.current,
219
+ pageHeader: v.current
220
+ },
221
+ (p) => {
222
+ M(p);
223
+ }
224
+ ), () => {
225
+ d.removeSection(s);
226
+ };
227
+ }, [n, a, t, o, d, s]), /* @__PURE__ */ R($, { value: l, children: [
228
+ J?.map((p) => /* @__PURE__ */ r(
229
+ b,
1062
230
  {
1063
231
  elements: {
1064
232
  ...e,
1065
- content: /* @__PURE__ */ w(
233
+ content: /* @__PURE__ */ r(
1066
234
  "div",
1067
235
  {
1068
236
  style: { display: "contents" },
1069
237
  dangerouslySetInnerHTML: {
1070
- __html: a
238
+ __html: p.pageContentHtml
1071
239
  }
1072
240
  }
1073
241
  )
1074
242
  },
1075
- dimensions: t,
243
+ dimension: t,
1076
244
  margin: o,
1077
- pageNumber: g + 1,
1078
- totalPages: i.length
245
+ pageIndex: p.index,
246
+ totalPages: p.totalPages
1079
247
  },
1080
- g
1081
- )) });
1082
- const c = be() ? void 0 : {
1083
- visibility: "hidden",
1084
- position: "absolute",
1085
- left: "-9999px",
1086
- top: "-9999px"
1087
- };
1088
- return tt(
1089
- /* @__PURE__ */ w("div", { className: Qe, style: c, children: /* @__PURE__ */ w(
1090
- he,
1091
- {
1092
- elements: e,
1093
- dimensions: t,
1094
- margin: o,
1095
- pageNumber: 1,
1096
- totalPages: 1,
1097
- ref: r,
1098
- sectionHeaderRef: s,
1099
- sectionFooterRef: f,
1100
- contentRef: p
1101
- }
1102
- ) }),
1103
- document.body
1104
- );
248
+ p.index
249
+ )),
250
+ Y(
251
+ /* @__PURE__ */ r("div", { style: i.outOfScreen, children: /* @__PURE__ */ r(
252
+ b,
253
+ {
254
+ elements: e,
255
+ dimension: t,
256
+ margin: o,
257
+ pageIndex: 0,
258
+ totalPages: 1,
259
+ ref: m,
260
+ sectionHeaderRef: y,
261
+ sectionFooterRef: P,
262
+ pageHeaderRef: v,
263
+ pageFooterRef: C,
264
+ contentRef: I
265
+ }
266
+ ) }),
267
+ document.body
268
+ )
269
+ ] });
1105
270
  }
1106
- function sn({
271
+ let ne = 1;
272
+ function me({
1107
273
  children: e,
1108
- dimension: t,
1109
- orientation: o = "portrait",
1110
- margin: n,
1111
- config: i
274
+ id: t,
275
+ dimension: o,
276
+ orientation: n = "portrait",
277
+ margin: s,
278
+ config: a
1112
279
  }) {
1113
- const r = Se(), s = L(
1114
- () => ({ ...i, id: i?.id ?? r }),
1115
- [i, r]
1116
- ), f = s.id, p = le(f);
1117
- L(() => {
1118
- p((a) => ({ ...a, isPaginated: !1 }));
1119
- }, [p]);
1120
- const c = L(
1121
- () => ({
1122
- dimensions: Bt(t, o),
1123
- elements: Ft(e),
1124
- margin: n,
1125
- config: s
1126
- }),
1127
- [e, t, n, s, o]
280
+ const l = u(() => t ?? `__000${ne++}`, [t]), d = u(() => Z(e), [e]), m = u(
281
+ () => q(o, n),
282
+ [o, n]
1128
283
  );
1129
- return re(Dt(f, c.dimensions)), /* @__PURE__ */ w(
284
+ return /* @__PURE__ */ r(
1130
285
  "section",
1131
286
  {
1132
- className: "paprize-section",
1133
- id: `section-${f}`,
1134
- style: { page: `section-${f}` },
1135
- children: /* @__PURE__ */ w(K, { value: f, children: /* @__PURE__ */ w(
1136
- Jt,
287
+ className: G,
288
+ id: l,
289
+ style: i.section(l),
290
+ children: /* @__PURE__ */ r(x, { value: l, children: /* @__PURE__ */ r(
291
+ te,
1137
292
  {
1138
- elements: c.elements,
1139
- dimensions: c.dimensions,
1140
- margin: c.margin,
1141
- config: c.config
293
+ elements: d,
294
+ dimension: m,
295
+ margin: s,
296
+ config: a
1142
297
  }
1143
298
  ) })
1144
299
  }
1145
300
  );
1146
301
  }
1147
- function an() {
1148
- return /* @__PURE__ */ w("span", { [Xe]: "true" });
302
+ function Se() {
303
+ return /* @__PURE__ */ r("span", { [K]: "true" });
1149
304
  }
1150
- function cn({ children: e, ...t }) {
1151
- return /* @__PURE__ */ w(
305
+ function ye({ children: e, ...t }) {
306
+ return /* @__PURE__ */ r(
1152
307
  "div",
1153
308
  {
1154
309
  style: { display: "contents" },
1155
- ...Ze(t),
310
+ ...Q(t),
1156
311
  children: e
1157
312
  }
1158
313
  );
1159
314
  }
1160
- const ln = () => {
1161
- const e = $($e);
315
+ const Pe = () => {
316
+ const e = g(_);
1162
317
  return {
1163
- pageNumber: e.pageNumber,
318
+ pageIndex: e.pageIndex,
1164
319
  totalPages: e.totalPages
1165
320
  };
1166
- };
1167
- function un() {
1168
- const e = G(M), t = G(ce);
1169
- return L(
1170
- () => ({
1171
- totalSections: t.totalSections,
1172
- isPaginated: t.isPaginated,
1173
- isFirstPaginationCompleted: t.totalSections > 0,
1174
- sections: Array.from(e.entries()).map(
1175
- ([o, { totalPages: n, isPaginated: i }]) => ({
1176
- sectionId: o,
1177
- totalPages: n,
1178
- isPaginated: i
1179
- })
1180
- )
1181
- }),
1182
- [t.isPaginated, t.totalSections, e]
321
+ }, ve = () => {
322
+ const e = g(x), t = w(), o = c({
323
+ pages: [],
324
+ isPaginated: !1,
325
+ isSuspended: !1,
326
+ index: -1,
327
+ sectionId: e
328
+ }), n = H(
329
+ (s) => t.monitor.addEventListener(
330
+ "sectionCompleted",
331
+ (a) => {
332
+ a.sectionId === e && (o.current = a, s());
333
+ }
334
+ ),
335
+ () => o.current
1183
336
  );
337
+ return {
338
+ sectionId: e,
339
+ sectionIndex: n.index,
340
+ isSuspended: n.isSuspended,
341
+ isPaginated: n.isPaginated,
342
+ pages: n.pages.map((s) => ({
343
+ pageIndex: s.index,
344
+ totalPages: s.totalPages
345
+ }))
346
+ };
347
+ };
348
+ function oe(e) {
349
+ return {
350
+ pageIndex: e.index,
351
+ totalPages: e.totalPages
352
+ };
1184
353
  }
1185
- function qt(e, t = !0) {
1186
- const o = Se(), n = le(e);
1187
- return L(() => {
1188
- t && n((i) => ({
1189
- ...i,
1190
- pendingSuspensions: new Set(i.pendingSuspensions).add(o)
1191
- }));
1192
- }, [o, n, t]), L(() => ({
1193
- release: () => {
1194
- n((i) => {
1195
- const r = new Set(i.pendingSuspensions);
1196
- return r.delete(o), {
1197
- ...i,
1198
- pendingSuspensions: r
1199
- };
1200
- });
1201
- }
1202
- }), [o, n]);
354
+ function re(e) {
355
+ return {
356
+ sectionId: e.sectionId,
357
+ sectionIndex: e.index,
358
+ isPaginated: e.isPaginated,
359
+ isSuspended: e.isSuspended,
360
+ pages: e.pages.map(oe)
361
+ };
362
+ }
363
+ function se(e) {
364
+ return {
365
+ sections: e.sections.map(re)
366
+ };
1203
367
  }
1204
- function Gt(e, t) {
1205
- const { sectionId: o } = Ne(), { release: n } = qt(o), [i, r] = we({
1206
- state: "loading",
1207
- value: t
1208
- });
1209
- return L(() => {
1210
- e.then((s) => r({ state: "hasData", value: s })).catch((s) => {
1211
- r({ state: "hasError", value: s }), W.error("Error in useSuspenseForPromise", s);
368
+ function Ce() {
369
+ const e = w(), t = c({
370
+ sections: []
371
+ }), o = H(
372
+ (n) => e.monitor.addEventListener(
373
+ "paginationCycleCompleted",
374
+ (s) => {
375
+ t.current = s, n();
376
+ }
377
+ ),
378
+ () => t.current
379
+ );
380
+ return se(o);
381
+ }
382
+ function ae(e) {
383
+ const t = c(null), { addSuspense: o } = g($);
384
+ return S(() => {
385
+ if (t.current)
386
+ return;
387
+ const n = e ?? new Promise((s) => {
388
+ t.current = s;
1212
389
  });
1213
- }, [e]), D(() => {
1214
- i.state !== "loading" && n();
1215
- }, [i, n]), i.value;
390
+ t.current ||= () => {
391
+ }, o(n);
392
+ }, [o, e]), u(
393
+ () => ({
394
+ reset: () => {
395
+ t.current || o(
396
+ new Promise((n) => {
397
+ t.current = n;
398
+ })
399
+ );
400
+ },
401
+ release: () => {
402
+ t.current?.(), t.current = null;
403
+ }
404
+ }),
405
+ [o]
406
+ );
1216
407
  }
1217
- function Kt(e) {
408
+ function ie(e) {
1218
409
  let t = null;
1219
410
  return () => (t || (t = e()), t);
1220
411
  }
1221
- const Yt = Kt(async () => {
1222
- const e = await window[et]?.();
412
+ const ce = ie(async () => {
413
+ if (!(E in window))
414
+ throw new Error(
415
+ "The function paprize_readJsonDataFile is not available in the current environment."
416
+ );
417
+ const e = await window[E]?.();
1223
418
  return e ? JSON.parse(e) : null;
1224
419
  });
1225
- function dn(e) {
1226
- return Gt(Yt(), e);
420
+ function he(e) {
421
+ return ae(ce().catch(() => e));
1227
422
  }
1228
- const Qt = {
1229
- A1: { height: "841mm", width: "594mm" },
1230
- A2: { height: "594mm", width: "420mm" },
1231
- A3: { height: "420mm", width: "297mm" },
1232
- A4: { height: "297mm", width: "210mm" },
1233
- A5: { height: "210mm", width: "148mm" },
1234
- A6: { height: "148mm", width: "105mm" },
1235
- B3: { height: "500mm", width: "353mm" },
1236
- B4: { height: "353mm", width: "250mm" },
1237
- B5: { height: "250mm", width: "176mm" },
1238
- Letter: { height: "8.5in", width: "11in" },
1239
- Legal: { height: "11in", width: "8.5in" },
1240
- Tabloid: { height: "11in", width: "17in" }
1241
- }, Xt = {
1242
- Normal: { top: "1in", right: "1in", bottom: "1in", left: "1in" },
1243
- Narrow: { top: "0.4in", right: "0.6in", bottom: "0.6in", left: "0.6in" },
1244
- Wide: { top: "0.5in", right: "2in", bottom: "0.5in", left: "2in" },
1245
- None: { top: "0in", right: "0in", bottom: "0in", left: "0in" }
1246
- }, fn = Qt, gn = Xt;
1247
423
  export {
1248
- cn as Layout,
1249
- an as PageBreak,
1250
- ze as PageContent,
1251
- Me as PageFooter,
1252
- Te as PageHeader,
1253
- De as PageOverlay,
1254
- on as ReportPreview,
1255
- rn as ReportRoot,
1256
- sn as Section,
1257
- Fe as SectionFooter,
1258
- Be as SectionHeader,
1259
- Yt as jsonData,
1260
- gn as pageMargin,
1261
- fn as pageSize,
1262
- dn as useJsonData,
1263
- ln as usePageInfo,
1264
- un as useReportInfo,
1265
- Ne as useSectionInfo,
1266
- qt as useSectionSuspension,
1267
- Gt as useSuspenseForPromise
424
+ ye as Layout,
425
+ Se as PageBreak,
426
+ N as PageContent,
427
+ k as PageFooter,
428
+ D as PageHeader,
429
+ L as PageOverlay,
430
+ fe as ReportPreview,
431
+ ge as ReportRoot,
432
+ me as Section,
433
+ T as SectionFooter,
434
+ j as SectionHeader,
435
+ ce as jsonData,
436
+ he as useJsonData,
437
+ Pe as usePageInfo,
438
+ Ce as useReportInfo,
439
+ ve as useSectionInfo,
440
+ ae as useSectionSuspension
1268
441
  };
1269
442
  //# sourceMappingURL=paprize-react.js.map