react-vector-pdf 0.3.4 → 0.3.6

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,22 +1,22 @@
1
- import A, { createContext as st, useContext as at } from "react";
2
- import { jsPDF as ft } from "jspdf";
3
- var J = { exports: {} }, $ = {};
4
- var tt;
5
- function ct() {
6
- if (tt) return $;
7
- tt = 1;
1
+ import A, { createContext as at, useContext as ft, useState as ct } from "react";
2
+ import { jsPDF as tt } from "jspdf";
3
+ var Q = { exports: {} }, $ = {};
4
+ var et;
5
+ function lt() {
6
+ if (et) return $;
7
+ et = 1;
8
8
  var i = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
9
9
  function r(n, o, s) {
10
- var f = null;
11
- if (s !== void 0 && (f = "" + s), o.key !== void 0 && (f = "" + o.key), "key" in o) {
10
+ var a = null;
11
+ if (s !== void 0 && (a = "" + s), o.key !== void 0 && (a = "" + o.key), "key" in o) {
12
12
  s = {};
13
- for (var l in o)
14
- l !== "key" && (s[l] = o[l]);
13
+ for (var c in o)
14
+ c !== "key" && (s[c] = o[c]);
15
15
  } else s = o;
16
16
  return o = s.ref, {
17
17
  $$typeof: i,
18
18
  type: n,
19
- key: f,
19
+ key: a,
20
20
  ref: o !== void 0 ? o : null,
21
21
  props: s
22
22
  };
@@ -24,24 +24,24 @@ function ct() {
24
24
  return $.Fragment = t, $.jsx = r, $.jsxs = r, $;
25
25
  }
26
26
  var V = {};
27
- var et;
28
- function lt() {
29
- return et || (et = 1, process.env.NODE_ENV !== "production" && (function() {
27
+ var rt;
28
+ function ut() {
29
+ return rt || (rt = 1, process.env.NODE_ENV !== "production" && (function() {
30
30
  function i(e) {
31
31
  if (e == null) return null;
32
32
  if (typeof e == "function")
33
33
  return e.$$typeof === S ? null : e.displayName || e.name || null;
34
34
  if (typeof e == "string") return e;
35
35
  switch (e) {
36
- case u:
36
+ case h:
37
37
  return "Fragment";
38
- case M:
38
+ case X:
39
39
  return "Profiler";
40
40
  case O:
41
41
  return "StrictMode";
42
- case G:
42
+ case J:
43
43
  return "Suspense";
44
- case m:
44
+ case b:
45
45
  return "SuspenseList";
46
46
  case W:
47
47
  return "Activity";
@@ -50,21 +50,21 @@ function lt() {
50
50
  switch (typeof e.tag == "number" && console.error(
51
51
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
52
52
  ), e.$$typeof) {
53
- case C:
53
+ case E:
54
54
  return "Portal";
55
- case B:
55
+ case U:
56
56
  return e.displayName || "Context";
57
57
  case N:
58
58
  return (e._context.displayName || "Context") + ".Consumer";
59
- case X:
60
- var c = e.render;
61
- return e = e.displayName, e || (e = c.displayName || c.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
62
- case v:
63
- return c = e.displayName || null, c !== null ? c : i(e.type) || "Memo";
59
+ case B:
60
+ var l = e.render;
61
+ return e = e.displayName, e || (e = l.displayName || l.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
62
+ case R:
63
+ return l = e.displayName || null, l !== null ? l : i(e.type) || "Memo";
64
64
  case P:
65
- c = e._payload, e = e._init;
65
+ l = e._payload, e = e._init;
66
66
  try {
67
- return i(e(c));
67
+ return i(e(l));
68
68
  } catch {
69
69
  }
70
70
  }
@@ -76,27 +76,27 @@ function lt() {
76
76
  function r(e) {
77
77
  try {
78
78
  t(e);
79
- var c = !1;
79
+ var l = !1;
80
80
  } catch {
81
- c = !0;
81
+ l = !0;
82
82
  }
83
- if (c) {
84
- c = console;
85
- var d = c.error, T = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
86
- return d.call(
87
- c,
83
+ if (l) {
84
+ l = console;
85
+ var g = l.error, C = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
86
+ return g.call(
87
+ l,
88
88
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
89
- T
89
+ C
90
90
  ), t(e);
91
91
  }
92
92
  }
93
93
  function n(e) {
94
- if (e === u) return "<>";
94
+ if (e === h) return "<>";
95
95
  if (typeof e == "object" && e !== null && e.$$typeof === P)
96
96
  return "<...>";
97
97
  try {
98
- var c = i(e);
99
- return c ? "<" + c + ">" : "<...>";
98
+ var l = i(e);
99
+ return l ? "<" + l + ">" : "<...>";
100
100
  } catch {
101
101
  return "<...>";
102
102
  }
@@ -108,42 +108,42 @@ function lt() {
108
108
  function s() {
109
109
  return Error("react-stack-top-frame");
110
110
  }
111
- function f(e) {
111
+ function a(e) {
112
112
  if (D.call(e, "key")) {
113
- var c = Object.getOwnPropertyDescriptor(e, "key").get;
114
- if (c && c.isReactWarning) return !1;
113
+ var l = Object.getOwnPropertyDescriptor(e, "key").get;
114
+ if (l && l.isReactWarning) return !1;
115
115
  }
116
116
  return e.key !== void 0;
117
117
  }
118
- function l(e, c) {
119
- function d() {
120
- E || (E = !0, console.error(
118
+ function c(e, l) {
119
+ function g() {
120
+ T || (T = !0, console.error(
121
121
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
122
- c
122
+ l
123
123
  ));
124
124
  }
125
- d.isReactWarning = !0, Object.defineProperty(e, "key", {
126
- get: d,
125
+ g.isReactWarning = !0, Object.defineProperty(e, "key", {
126
+ get: g,
127
127
  configurable: !0
128
128
  });
129
129
  }
130
- function g() {
130
+ function u() {
131
131
  var e = i(this.type);
132
- return b[e] || (b[e] = !0, console.error(
132
+ return w[e] || (w[e] = !0, console.error(
133
133
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
134
134
  )), e = this.props.ref, e !== void 0 ? e : null;
135
135
  }
136
- function x(e, c, d, T, L, _) {
137
- var k = d.ref;
136
+ function m(e, l, g, C, L, _) {
137
+ var y = g.ref;
138
138
  return e = {
139
139
  $$typeof: j,
140
140
  type: e,
141
- key: c,
142
- props: d,
143
- _owner: T
144
- }, (k !== void 0 ? k : null) !== null ? Object.defineProperty(e, "ref", {
141
+ key: l,
142
+ props: g,
143
+ _owner: C
144
+ }, (y !== void 0 ? y : null) !== null ? Object.defineProperty(e, "ref", {
145
145
  enumerable: !1,
146
- get: g
146
+ get: u
147
147
  }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
148
148
  configurable: !1,
149
149
  enumerable: !1,
@@ -166,61 +166,61 @@ function lt() {
166
166
  value: _
167
167
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
168
168
  }
169
- function a(e, c, d, T, L, _) {
170
- var k = c.children;
171
- if (k !== void 0)
172
- if (T)
173
- if (Y(k)) {
174
- for (T = 0; T < k.length; T++)
175
- R(k[T]);
176
- Object.freeze && Object.freeze(k);
169
+ function f(e, l, g, C, L, _) {
170
+ var y = l.children;
171
+ if (y !== void 0)
172
+ if (C)
173
+ if (Y(y)) {
174
+ for (C = 0; C < y.length; C++)
175
+ x(y[C]);
176
+ Object.freeze && Object.freeze(y);
177
177
  } else
178
178
  console.error(
179
179
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
180
180
  );
181
- else R(k);
182
- if (D.call(c, "key")) {
183
- k = i(e);
184
- var I = Object.keys(c).filter(function(it) {
185
- return it !== "key";
181
+ else x(y);
182
+ if (D.call(l, "key")) {
183
+ y = i(e);
184
+ var M = Object.keys(l).filter(function(st) {
185
+ return st !== "key";
186
186
  });
187
- T = 0 < I.length ? "{key: someKey, " + I.join(": ..., ") + ": ...}" : "{key: someKey}", F[k + T] || (I = 0 < I.length ? "{" + I.join(": ..., ") + ": ...}" : "{}", console.error(
187
+ C = 0 < M.length ? "{key: someKey, " + M.join(": ..., ") + ": ...}" : "{key: someKey}", F[y + C] || (M = 0 < M.length ? "{" + M.join(": ..., ") + ": ...}" : "{}", console.error(
188
188
  `A props object containing a "key" prop is being spread into JSX:
189
189
  let props = %s;
190
190
  <%s {...props} />
191
191
  React keys must be passed directly to JSX without using spread:
192
192
  let props = %s;
193
193
  <%s key={someKey} {...props} />`,
194
- T,
195
- k,
196
- I,
197
- k
198
- ), F[k + T] = !0);
194
+ C,
195
+ y,
196
+ M,
197
+ y
198
+ ), F[y + C] = !0);
199
199
  }
200
- if (k = null, d !== void 0 && (r(d), k = "" + d), f(c) && (r(c.key), k = "" + c.key), "key" in c) {
201
- d = {};
202
- for (var K in c)
203
- K !== "key" && (d[K] = c[K]);
204
- } else d = c;
205
- return k && l(
206
- d,
200
+ if (y = null, g !== void 0 && (r(g), y = "" + g), a(l) && (r(l.key), y = "" + l.key), "key" in l) {
201
+ g = {};
202
+ for (var K in l)
203
+ K !== "key" && (g[K] = l[K]);
204
+ } else g = l;
205
+ return y && c(
206
+ g,
207
207
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
208
- ), x(
208
+ ), m(
209
209
  e,
210
- k,
211
- d,
210
+ y,
211
+ g,
212
212
  o(),
213
213
  L,
214
214
  _
215
215
  );
216
216
  }
217
- function R(e) {
218
- h(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === P && (e._payload.status === "fulfilled" ? h(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
217
+ function x(e) {
218
+ d(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === P && (e._payload.status === "fulfilled" ? d(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
219
219
  }
220
- function h(e) {
220
+ function d(e) {
221
221
  return typeof e == "object" && e !== null && e.$$typeof === j;
222
222
  }
223
- var H = A, j = /* @__PURE__ */ Symbol.for("react.transitional.element"), C = /* @__PURE__ */ Symbol.for("react.portal"), u = /* @__PURE__ */ Symbol.for("react.fragment"), O = /* @__PURE__ */ Symbol.for("react.strict_mode"), M = /* @__PURE__ */ Symbol.for("react.profiler"), N = /* @__PURE__ */ Symbol.for("react.consumer"), B = /* @__PURE__ */ Symbol.for("react.context"), X = /* @__PURE__ */ Symbol.for("react.forward_ref"), G = /* @__PURE__ */ Symbol.for("react.suspense"), m = /* @__PURE__ */ Symbol.for("react.suspense_list"), v = /* @__PURE__ */ Symbol.for("react.memo"), P = /* @__PURE__ */ Symbol.for("react.lazy"), W = /* @__PURE__ */ Symbol.for("react.activity"), S = /* @__PURE__ */ Symbol.for("react.client.reference"), p = H.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, D = Object.prototype.hasOwnProperty, Y = Array.isArray, z = console.createTask ? console.createTask : function() {
223
+ var H = A, j = /* @__PURE__ */ Symbol.for("react.transitional.element"), E = /* @__PURE__ */ Symbol.for("react.portal"), h = /* @__PURE__ */ Symbol.for("react.fragment"), O = /* @__PURE__ */ Symbol.for("react.strict_mode"), X = /* @__PURE__ */ Symbol.for("react.profiler"), N = /* @__PURE__ */ Symbol.for("react.consumer"), U = /* @__PURE__ */ Symbol.for("react.context"), B = /* @__PURE__ */ Symbol.for("react.forward_ref"), J = /* @__PURE__ */ Symbol.for("react.suspense"), b = /* @__PURE__ */ Symbol.for("react.suspense_list"), R = /* @__PURE__ */ Symbol.for("react.memo"), P = /* @__PURE__ */ Symbol.for("react.lazy"), W = /* @__PURE__ */ Symbol.for("react.activity"), S = /* @__PURE__ */ Symbol.for("react.client.reference"), p = H.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, D = Object.prototype.hasOwnProperty, Y = Array.isArray, z = console.createTask ? console.createTask : function() {
224
224
  return null;
225
225
  };
226
226
  H = {
@@ -228,42 +228,42 @@ React keys must be passed directly to JSX without using spread:
228
228
  return e();
229
229
  }
230
230
  };
231
- var E, b = {}, y = H.react_stack_bottom_frame.bind(
231
+ var T, w = {}, k = H.react_stack_bottom_frame.bind(
232
232
  H,
233
233
  s
234
- )(), w = z(n(s)), F = {};
235
- V.Fragment = u, V.jsx = function(e, c, d) {
236
- var T = 1e4 > p.recentlyCreatedOwnerStacks++;
237
- return a(
234
+ )(), v = z(n(s)), F = {};
235
+ V.Fragment = h, V.jsx = function(e, l, g) {
236
+ var C = 1e4 > p.recentlyCreatedOwnerStacks++;
237
+ return f(
238
238
  e,
239
- c,
240
- d,
239
+ l,
240
+ g,
241
241
  !1,
242
- T ? Error("react-stack-top-frame") : y,
243
- T ? z(n(e)) : w
242
+ C ? Error("react-stack-top-frame") : k,
243
+ C ? z(n(e)) : v
244
244
  );
245
- }, V.jsxs = function(e, c, d) {
246
- var T = 1e4 > p.recentlyCreatedOwnerStacks++;
247
- return a(
245
+ }, V.jsxs = function(e, l, g) {
246
+ var C = 1e4 > p.recentlyCreatedOwnerStacks++;
247
+ return f(
248
248
  e,
249
- c,
250
- d,
249
+ l,
250
+ g,
251
251
  !0,
252
- T ? Error("react-stack-top-frame") : y,
253
- T ? z(n(e)) : w
252
+ C ? Error("react-stack-top-frame") : k,
253
+ C ? z(n(e)) : v
254
254
  );
255
255
  };
256
256
  })()), V;
257
257
  }
258
- var rt;
259
- function ut() {
260
- return rt || (rt = 1, process.env.NODE_ENV === "production" ? J.exports = ct() : J.exports = lt()), J.exports;
258
+ var ot;
259
+ function ht() {
260
+ return ot || (ot = 1, process.env.NODE_ENV === "production" ? Q.exports = lt() : Q.exports = ut()), Q.exports;
261
261
  }
262
- var U = ut();
262
+ var I = ht();
263
263
  function Z(i) {
264
264
  return !i && i !== 0 ? { top: 0, right: 0, bottom: 0, left: 0 } : typeof i == "number" ? { top: i, right: i, bottom: i, left: i } : { top: i.top ?? 0, right: i.right ?? 0, bottom: i.bottom ?? 0, left: i.left ?? 0 };
265
265
  }
266
- function Q(i) {
266
+ function G(i) {
267
267
  const t = i.replace("#", "");
268
268
  if (t.length === 3) {
269
269
  const r = parseInt(t[0] + t[0], 16), n = parseInt(t[1] + t[1], 16), o = parseInt(t[2] + t[2], 16);
@@ -275,7 +275,7 @@ function Q(i) {
275
275
  }
276
276
  return null;
277
277
  }
278
- function ot(i, t = !0) {
278
+ function nt(i, t = !0) {
279
279
  if (i <= 0) return String(i);
280
280
  const r = [
281
281
  [1e3, "M"],
@@ -293,22 +293,22 @@ function ot(i, t = !0) {
293
293
  [1, "I"]
294
294
  ];
295
295
  let n = i, o = "";
296
- for (const [s, f] of r)
296
+ for (const [s, a] of r)
297
297
  for (; n >= s; )
298
- o += f, n -= s;
298
+ o += a, n -= s;
299
299
  return t ? o : o.toLowerCase();
300
300
  }
301
- class ht {
301
+ class dt {
302
302
  constructor(t = {}) {
303
303
  this.cursorX = 0, this.cursorY = 0, this.contentWidth = 0, this.margin = { top: 15, right: 15, bottom: 15, left: 15 }, this.defaultFont = {
304
304
  name: void 0,
305
305
  style: "normal",
306
306
  size: 12
307
- }, this.defaultColor = "#111827", this.defaultLineHeight = 1.25, this.pendingTasks = /* @__PURE__ */ new Set(), this.opQueue = Promise.resolve(), this.margin = t.margin ?? this.margin, this.defaultFont = {
307
+ }, this.defaultColor = "#111827", this.defaultLineHeight = 1.25, this.pendingTasks = /* @__PURE__ */ new Set(), this.opQueue = Promise.resolve(), this.generation = 0, this.options = t, this.margin = t.margin ?? this.margin, this.defaultFont = {
308
308
  name: t.font?.name,
309
309
  style: t.font?.style ?? "normal",
310
310
  size: t.font?.size ?? 12
311
- }, this.defaultColor = t.color ?? this.defaultColor, this.defaultLineHeight = t.lineHeight ?? this.defaultLineHeight, this.pdf = new ft({
311
+ }, this.defaultColor = t.color ?? this.defaultColor, this.defaultLineHeight = t.lineHeight ?? this.defaultLineHeight, this.pdf = new tt({
312
312
  unit: t.unit ?? "mm",
313
313
  format: t.format ?? "a4",
314
314
  orientation: t.orientation ?? "p"
@@ -350,13 +350,23 @@ class ht {
350
350
  resetFlowCursor() {
351
351
  this.cursorX = this.margin.left, this.cursorY = this.margin.top, this.contentWidth = this.pageWidth - this.margin.left - this.margin.right;
352
352
  }
353
+ reset() {
354
+ if (this.pdf = new tt({
355
+ unit: this.options.unit ?? "mm",
356
+ format: this.options.format ?? "a4",
357
+ orientation: this.options.orientation ?? "p"
358
+ }), this.generation++, this.cursorX = 0, this.cursorY = 0, this.pendingTasks = /* @__PURE__ */ new Set(), this.opQueue = Promise.resolve(), this.resetFlowCursor(), this.applyBaseFont(), this.options.color) {
359
+ const t = G(this.options.color);
360
+ t && this.pdf.setTextColor(...t);
361
+ }
362
+ }
353
363
  setHeaderFooter(t, r) {
354
364
  this.headerDrawer = t, this.footerDrawer = r;
355
365
  }
356
366
  applyBaseFont() {
357
367
  const t = this.defaultFont.name ?? this.pdf.getFont().fontName;
358
368
  this.pdf.setFont(t, this.defaultFont.style), this.pdf.setFontSize(this.defaultFont.size);
359
- const r = Q(this.defaultColor);
369
+ const r = G(this.defaultColor);
360
370
  r && this.pdf.setTextColor(...r);
361
371
  }
362
372
  addPage() {
@@ -372,26 +382,26 @@ class ht {
372
382
  this.pdf.setFont(r, t.fontStyle);
373
383
  }
374
384
  if (t.color) {
375
- const r = Q(t.color);
385
+ const r = G(t.color);
376
386
  r && this.pdf.setTextColor(...r);
377
387
  }
378
388
  }
379
389
  }
380
- textRaw(t, r, n, o, s, f = "left") {
390
+ textRaw(t, r, n, o, s, a = "left") {
381
391
  this.setTextStyle(o);
382
- const l = { align: f };
383
- typeof s == "number" && (l.maxWidth = s), this.pdf.text(t, r, n, l), this.applyBaseFont();
392
+ const c = { align: a };
393
+ typeof s == "number" && (c.maxWidth = s), this.pdf.text(t, r, n, c), this.applyBaseFont();
384
394
  }
385
395
  box(t, r, n, o, s) {
386
- const f = s ?? {};
387
- if (f.fillColor) {
388
- const l = Q(f.fillColor);
389
- l && this.pdf.setFillColor(...l), this.pdf.rect(t, r, n, o, "F");
396
+ const a = s ?? {};
397
+ if (a.fillColor) {
398
+ const c = G(a.fillColor);
399
+ c && this.pdf.setFillColor(...c), this.pdf.rect(t, r, n, o, "F");
390
400
  }
391
- if (f.borderWidth || f.borderColor) {
392
- if (f.borderWidth && this.pdf.setLineWidth(f.borderWidth), f.borderColor) {
393
- const l = Q(f.borderColor);
394
- l && this.pdf.setDrawColor(...l);
401
+ if (a.borderWidth || a.borderColor) {
402
+ if (a.borderWidth && this.pdf.setLineWidth(a.borderWidth), a.borderColor) {
403
+ const c = G(a.borderColor);
404
+ c && this.pdf.setDrawColor(...c);
395
405
  }
396
406
  this.pdf.rect(t, r, n, o), this.pdf.setLineWidth(0.2), this.pdf.setDrawColor(0, 0, 0);
397
407
  }
@@ -402,23 +412,23 @@ class ht {
402
412
  async imageFromUrl(t, r = {}) {
403
413
  const n = (async () => {
404
414
  try {
405
- const { dataUrl: o, width: s, height: f } = await this.loadImageAsDataURL(t), l = 0.264583, g = s * l, x = f * l;
406
- let a = r.w, R = r.h;
407
- a === void 0 && R === void 0 ? (a = g, R = x) : a === void 0 && R !== void 0 ? a = R * (g / x) : R === void 0 && a !== void 0 && (R = a * (x / g));
408
- const h = a ?? g, H = R ?? x;
409
- let j = r.x, C = r.y ?? this.cursorY;
410
- if (r.y === void 0 && C + H > this.contentBottom && (this.addPage(), C = this.cursorY), j === void 0) {
411
- const u = r.align ?? "left";
412
- u === "left" ? j = this.contentLeft : u === "center" ? j = (this.contentLeft + this.contentRight) / 2 - h / 2 : u === "right" && (j = this.contentRight - h);
415
+ const { dataUrl: o, width: s, height: a } = await this.loadImageAsDataURL(t), c = 0.264583, u = s * c, m = a * c;
416
+ let f = r.w, x = r.h;
417
+ f === void 0 && x === void 0 ? (f = u, x = m) : f === void 0 && x !== void 0 ? f = x * (u / m) : x === void 0 && f !== void 0 && (x = f * (m / u));
418
+ const d = f ?? u, H = x ?? m;
419
+ let j = r.x, E = r.y ?? this.cursorY;
420
+ if (r.y === void 0 && E + H > this.contentBottom && (this.addPage(), E = this.cursorY), j === void 0) {
421
+ const h = r.align ?? "left";
422
+ h === "left" ? j = this.contentLeft : h === "center" ? j = (this.contentLeft + this.contentRight) / 2 - d / 2 : h === "right" && (j = this.contentRight - d);
413
423
  }
414
424
  return this.pdf.addImage(
415
425
  o,
416
426
  r.mime ?? "PNG",
417
427
  j,
418
- C,
419
- h,
428
+ E,
429
+ d,
420
430
  H
421
- ), { width: h, height: H, x: j, y: C };
431
+ ), { width: d, height: H, x: j, y: E };
422
432
  } catch (o) {
423
433
  return console.error("Failed to load image", t, o), { width: 0, height: 0, x: 0, y: 0 };
424
434
  }
@@ -426,14 +436,15 @@ class ht {
426
436
  return this.registerTask(n), n;
427
437
  }
428
438
  queueOperation(t) {
429
- const r = this.opQueue.then(async () => {
430
- try {
431
- await t();
432
- } catch (n) {
433
- console.error("Operation failed", n);
434
- }
439
+ const r = this.generation, n = this.opQueue.then(async () => {
440
+ if (this.generation === r)
441
+ try {
442
+ await t();
443
+ } catch (o) {
444
+ console.error("Operation failed", o);
445
+ }
435
446
  });
436
- this.opQueue = r, this.registerTask(r);
447
+ this.opQueue = n, this.registerTask(n);
437
448
  }
438
449
  registerTask(t) {
439
450
  this.pendingTasks.add(t), t.finally(() => {
@@ -449,9 +460,9 @@ class ht {
449
460
  o.crossOrigin = "anonymous", o.onload = () => {
450
461
  const s = document.createElement("canvas");
451
462
  s.width = o.width, s.height = o.height;
452
- const f = s.getContext("2d");
453
- if (!f) return n(new Error("Canvas 2D context not available"));
454
- f.drawImage(o, 0, 0), r({
463
+ const a = s.getContext("2d");
464
+ if (!a) return n(new Error("Canvas 2D context not available"));
465
+ a.drawImage(o, 0, 0), r({
455
466
  dataUrl: s.toDataURL("image/png"),
456
467
  width: o.width,
457
468
  height: o.height
@@ -462,13 +473,13 @@ class ht {
462
473
  paragraph(t, r, n) {
463
474
  const o = n ?? this.contentWidth;
464
475
  this.setTextStyle(r);
465
- const s = r?.lineHeight ?? this.defaultLineHeight, f = r?.fontSize ?? this.defaultFont.size, l = f * s * 0.3528, g = this.pdf.splitTextToSize(t, o), x = r?.align ?? "left";
466
- let a = 0;
467
- return g.forEach((R) => {
468
- this.cursorY + l > this.contentBottom && this.addPage();
469
- const h = this.cursorY + f * 0.3528;
470
- this.pdf.text(R, this.cursorX, h, { align: x, maxWidth: o }), this.cursorY += l, a += l;
471
- }), this.cursorY += 1, this.applyBaseFont(), a;
476
+ const s = r?.lineHeight ?? this.defaultLineHeight, a = r?.fontSize ?? this.defaultFont.size, c = a * s * 0.3528, u = this.pdf.splitTextToSize(t, o), m = r?.align ?? "left";
477
+ let f = 0;
478
+ return u.forEach((x) => {
479
+ this.cursorY + c > this.contentBottom && this.addPage();
480
+ const d = this.cursorY + a * 0.3528;
481
+ this.pdf.text(x, this.cursorX, d, { align: m, maxWidth: o }), this.cursorY += c, f += c;
482
+ }), this.cursorY += 1, this.applyBaseFont(), f;
472
483
  }
473
484
  moveCursor(t, r) {
474
485
  this.cursorX += t, this.cursorY += r;
@@ -492,16 +503,16 @@ class ht {
492
503
  }
493
504
  measureText(t, r, n) {
494
505
  this.setTextStyle(r);
495
- const o = r?.fontSize ?? this.defaultFont.size, s = r?.lineHeight ?? this.defaultLineHeight, f = o * s * 0.3528;
506
+ const o = r?.fontSize ?? this.defaultFont.size, s = r?.lineHeight ?? this.defaultLineHeight, a = o * s * 0.3528;
496
507
  if (n) {
497
- const l = this.pdf.splitTextToSize(t, n);
508
+ const c = this.pdf.splitTextToSize(t, n);
498
509
  return {
499
510
  width: n,
500
- height: l.length * f
511
+ height: c.length * a
501
512
  };
502
513
  } else {
503
- const l = this.pdf.getTextDimensions(t);
504
- return { width: l.w, height: l.h };
514
+ const c = this.pdf.getTextDimensions(t);
515
+ return { width: c.w, height: c.h };
505
516
  }
506
517
  }
507
518
  setMetadata(t) {
@@ -512,57 +523,62 @@ class ht {
512
523
  save(t) {
513
524
  this.applyHeaderFooter(), this.pdf.save(t);
514
525
  }
526
+ getBlobUrl() {
527
+ return this.applyHeaderFooter(), this.pdf.output("bloburl");
528
+ }
515
529
  }
516
- const nt = st(null), q = () => {
517
- const i = at(nt);
530
+ const it = at(null), q = () => {
531
+ const i = ft(it);
518
532
  if (!i) throw new Error("usePdf must be used within <PdfDocument>");
519
533
  return i;
520
- }, wt = ({
534
+ }, gt = ({
521
535
  options: i,
522
536
  header: t,
523
537
  footer: r,
524
538
  pageNumbers: n,
525
539
  centerLabel: o,
526
540
  metadata: s,
527
- children: f,
528
- onReady: l,
529
- filename: g,
530
- autoSave: x = !1
541
+ children: a,
542
+ onReady: c,
543
+ filename: u,
544
+ autoSave: m = !1
531
545
  }) => {
532
- const [a] = A.useState(() => new ht(i));
546
+ const f = A.useMemo(() => new dt(i), [i]);
533
547
  return A.useEffect(() => {
534
- s && a.setMetadata(s);
535
- }, [a, s]), A.useEffect(() => {
536
- const R = (C, u) => !u || u === "all" ? !0 : u === "first-only" ? C === 1 : u === "except-first" ? C > 1 : Array.isArray(u) ? u.includes(C) : !0, h = (C, u) => u === "roman-upper" ? ot(C, !0) : u === "roman-lower" ? ot(C, !1) : String(C), H = (C, u, O) => {
537
- if (!n?.enabled || !R(u, n.scope)) return;
538
- const M = n.preset ?? "page-slash-total", B = (n.template ?? (M === "page-slash-total" ? "Page {page}/{total}" : M === "page-of-total" ? "Page {page} of {total}" : "{page}/{total}")).replace("{page}", h(u, n.format)).replace("{total}", h(O, n.format)), X = n.align ?? "right", G = X === "left" ? a.contentLeft + (n.offsetX ?? 0) : X === "right" ? a.contentRight - (n.offsetX ?? 0) : (a.contentLeft + a.contentRight) / 2 + (n.offsetX ?? 0), m = C === "header" ? 10 : a.height - 7, v = typeof n.y == "number" ? n.y : m;
539
- a.textRaw(B, G, v, n.style, void 0, X);
540
- }, j = (C, u, O) => {
541
- if (!o?.enabled || !R(u, o.scope)) return;
542
- const M = "center", N = (a.contentLeft + a.contentRight) / 2 + (o.offsetX ?? 0), B = C === "header" ? 10 : a.height - 7, X = typeof o.y == "number" ? o.y : B;
543
- a.textRaw(
548
+ s && f.setMetadata(s);
549
+ }, [f, s]), A.useEffect(() => {
550
+ const x = (E, h) => !h || h === "all" ? !0 : h === "first-only" ? E === 1 : h === "except-first" ? E > 1 : Array.isArray(h) ? h.includes(E) : !0, d = (E, h) => h === "roman-upper" ? nt(E, !0) : h === "roman-lower" ? nt(E, !1) : String(E), H = (E, h, O) => {
551
+ if (!n?.enabled || !x(h, n.scope)) return;
552
+ const X = n.preset ?? "page-slash-total", U = (n.template ?? (X === "page-slash-total" ? "Page {page}/{total}" : X === "page-of-total" ? "Page {page} of {total}" : "{page}/{total}")).replace("{page}", d(h, n.format)).replace("{total}", d(O, n.format)), B = n.align ?? "right", J = B === "left" ? f.contentLeft + (n.offsetX ?? 0) : B === "right" ? f.contentRight - (n.offsetX ?? 0) : (f.contentLeft + f.contentRight) / 2 + (n.offsetX ?? 0), b = E === "header" ? 10 : f.height - 7, R = typeof n.y == "number" ? n.y : b;
553
+ f.textRaw(U, J, R, n.style, void 0, B);
554
+ }, j = (E, h, O) => {
555
+ if (!o?.enabled || !x(h, o.scope)) return;
556
+ const X = "center", N = (f.contentLeft + f.contentRight) / 2 + (o.offsetX ?? 0), U = E === "header" ? 10 : f.height - 7, B = typeof o.y == "number" ? o.y : U;
557
+ f.textRaw(
544
558
  o.text,
545
559
  N,
546
- X,
560
+ B,
547
561
  o.style,
548
562
  void 0,
549
- M
563
+ X
550
564
  );
551
565
  };
552
- a.setHeaderFooter(
553
- (C, u, O) => {
554
- t && t(a, u, O), n?.position === "header" && H("header", u, O), o?.position === "header" && j("header", u);
566
+ return f.setHeaderFooter(
567
+ (E, h, O) => {
568
+ t && t(f, h, O), n?.position === "header" && H("header", h, O), o?.position === "header" && j("header", h);
555
569
  },
556
- (C, u, O) => {
557
- n?.position === "footer" && H("footer", u, O), r && r(a, u, O), o?.position === "footer" && j("footer", u);
570
+ (E, h, O) => {
571
+ n?.position === "footer" && H("footer", h, O), r && r(f, h, O), o?.position === "footer" && j("footer", h);
558
572
  }
559
- ), a.waitForTasks().then(() => {
560
- l?.(a);
561
- });
562
- }, []), A.useEffect(() => {
563
- x && g && a.save(g);
564
- }, [x, g]), /* @__PURE__ */ U.jsx(nt.Provider, { value: a, children: f });
565
- }, vt = ({
573
+ ), f.waitForTasks().then(() => {
574
+ c?.(f);
575
+ }), () => {
576
+ f.reset();
577
+ };
578
+ }, [f]), A.useEffect(() => {
579
+ m && u && f.save(u);
580
+ }, [m, u]), /* @__PURE__ */ I.jsx(it.Provider, { value: f, children: a });
581
+ }, xt = ({
566
582
  x: i,
567
583
  y: t,
568
584
  w: r,
@@ -570,65 +586,65 @@ const nt = st(null), q = () => {
570
586
  children: o,
571
587
  ...s
572
588
  }) => {
573
- const f = q(), l = Z(s.padding), g = {
574
- top: s.paddingTop ?? l.top,
575
- right: s.paddingRight ?? l.right,
576
- bottom: s.paddingBottom ?? l.bottom,
577
- left: s.paddingLeft ?? l.left
578
- }, x = A.useRef(
589
+ const a = q(), c = Z(s.padding), u = {
590
+ top: s.paddingTop ?? c.top,
591
+ right: s.paddingRight ?? c.right,
592
+ bottom: s.paddingBottom ?? c.bottom,
593
+ left: s.paddingLeft ?? c.left
594
+ }, m = A.useRef(
579
595
  {}
580
596
  ).current;
581
597
  return typeof i == "number" && typeof t == "number" && typeof r == "number" && typeof n == "number" ? (A.useEffect(() => {
582
- f.queueOperation(() => {
583
- f.box(i, t, r, n, s);
598
+ a.queueOperation(() => {
599
+ a.box(i, t, r, n, s);
584
600
  });
585
- }, [i, t, r, n]), /* @__PURE__ */ U.jsx(A.Fragment, { children: o })) : (A.useEffect(() => {
586
- f.queueOperation(() => {
587
- const a = f.getCursor();
588
- x.start = { ...a };
589
- const R = a.x + g.left, h = a.y + g.top;
590
- f.setCursor(R, h);
601
+ }, [a, i, t, r, n]), /* @__PURE__ */ I.jsx(A.Fragment, { children: o })) : (A.useEffect(() => {
602
+ a.queueOperation(() => {
603
+ const f = a.getCursor();
604
+ m.start = { ...f };
605
+ const x = f.x + u.left, d = f.y + u.top;
606
+ a.setCursor(x, d);
591
607
  });
592
- }, []), /* @__PURE__ */ U.jsxs(A.Fragment, { children: [
608
+ }, [a]), /* @__PURE__ */ I.jsxs(A.Fragment, { children: [
593
609
  o,
594
- /* @__PURE__ */ U.jsx(dt, { boxState: x, pad: g, style: s })
610
+ /* @__PURE__ */ I.jsx(pt, { boxState: m, pad: u, style: s })
595
611
  ] }));
596
- }, dt = ({ boxState: i, style: t, pad: r }) => {
612
+ }, pt = ({ boxState: i, style: t, pad: r }) => {
597
613
  const n = q();
598
614
  return A.useEffect(() => {
599
615
  n.queueOperation(() => {
600
616
  const o = i.start;
601
617
  if (!o) return;
602
- const s = n.getCursor(), l = Math.max(s.y - o.y - r.top, 0) + r.top + r.bottom;
603
- n.box(o.x, o.y, n.contentAreaWidth, l, t), n.setCursor(o.x, o.y + l);
618
+ const s = n.getCursor(), c = Math.max(s.y - o.y - r.top, 0) + r.top + r.bottom;
619
+ n.box(o.x, o.y, n.contentAreaWidth, c, t), n.setCursor(o.x, o.y + c);
604
620
  });
605
- }, []), null;
606
- }, xt = ({
621
+ }, [n]), null;
622
+ }, Rt = ({
607
623
  src: i,
608
624
  x: t,
609
625
  y: r,
610
626
  w: n,
611
627
  h: o,
612
628
  mime: s = "PNG",
613
- flow: f,
614
- align: l = "left"
629
+ flow: a,
630
+ align: c = "left"
615
631
  }) => {
616
- const g = q();
632
+ const u = q();
617
633
  return A.useEffect(() => {
618
- const x = f === !0 || t === void 0 && r === void 0, a = t, R = r;
619
- g.queueOperation(async () => {
620
- const h = await g.imageFromUrl(i, {
621
- x: a,
622
- y: R,
634
+ const m = a === !0 || t === void 0 && r === void 0, f = t, x = r;
635
+ u.queueOperation(async () => {
636
+ const d = await u.imageFromUrl(i, {
637
+ x: f,
638
+ y: x,
623
639
  w: n,
624
640
  h: o,
625
641
  mime: s,
626
- align: l
642
+ align: c
627
643
  });
628
- x && h && g.moveCursor(0, h.height + 2);
644
+ m && d && u.moveCursor(0, d.height + 2);
629
645
  });
630
- }, [i, t, r, n, o, s, f, l]), null;
631
- }, Rt = ({
646
+ }, [u, i, t, r, n, o, s, a, c]), null;
647
+ }, Tt = ({
632
648
  items: i,
633
649
  ordered: t = !1,
634
650
  style: r,
@@ -636,26 +652,67 @@ const nt = st(null), q = () => {
636
652
  markerWidth: o = 5,
637
653
  spacing: s = 2
638
654
  }) => {
639
- const f = q();
655
+ const a = q();
640
656
  return A.useEffect(() => {
641
- f.queueOperation(() => {
642
- i.forEach((l, g) => {
643
- const x = t ? `${g + 1}.` : "•", a = f.getCursor().y, R = f.getCursor().x, h = R + n + o, H = r?.fontSize ?? f.baseFont.size, j = a + H * 0.3528;
644
- f.textRaw(
645
- x,
646
- R + n,
657
+ a.queueOperation(() => {
658
+ i.forEach((c, u) => {
659
+ const m = t ? `${u + 1}.` : "•", f = a.getCursor().y, x = a.getCursor().x, d = x + n + o, H = r?.fontSize ?? a.baseFont.size, j = f + H * 0.3528;
660
+ a.textRaw(
661
+ m,
662
+ x + n,
647
663
  j,
648
664
  r,
649
665
  o,
650
666
  "right"
651
- ), f.setCursor(h, a);
652
- const C = f.contentRight - h;
653
- f.paragraph(l, r, C);
654
- const u = f.getCursor().y;
655
- f.setCursor(R, u + s);
667
+ ), a.setCursor(d, f);
668
+ const E = a.contentRight - d;
669
+ a.paragraph(c, r, E);
670
+ const h = a.getCursor().y;
671
+ a.setCursor(x, h + s);
656
672
  });
657
673
  });
658
- }, [i, t, r, n, o, s]), null;
674
+ }, [a, i, t, r, n, o, s]), null;
675
+ }, Ct = ({
676
+ width: i = "100%",
677
+ height: t = "500px",
678
+ className: r,
679
+ style: n,
680
+ iframeClassName: o,
681
+ iframeStyle: s,
682
+ ...a
683
+ }) => {
684
+ const [c, u] = ct(null), m = (f) => {
685
+ const x = f.getBlobUrl();
686
+ u(x.toString());
687
+ };
688
+ return /* @__PURE__ */ I.jsxs("div", { className: r, style: { width: i, height: t, ...n }, children: [
689
+ /* @__PURE__ */ I.jsx("div", { style: { display: "none" }, children: /* @__PURE__ */ I.jsx(gt, { ...a, onReady: m, autoSave: !1, children: a.children }) }),
690
+ c ? /* @__PURE__ */ I.jsx(
691
+ "iframe",
692
+ {
693
+ src: c,
694
+ width: "100%",
695
+ height: "100%",
696
+ className: o,
697
+ style: { border: "none", ...s },
698
+ title: "PDF Preview"
699
+ }
700
+ ) : /* @__PURE__ */ I.jsx(
701
+ "div",
702
+ {
703
+ style: {
704
+ width: "100%",
705
+ height: "100%",
706
+ display: "flex",
707
+ alignItems: "center",
708
+ justifyContent: "center",
709
+ backgroundColor: "#f3f4f6",
710
+ color: "#6b7280"
711
+ },
712
+ children: "Generating Preview..."
713
+ }
714
+ )
715
+ ] });
659
716
  }, Et = ({
660
717
  data: i,
661
718
  columns: t,
@@ -663,156 +720,156 @@ const nt = st(null), q = () => {
663
720
  borderWidth: n = 0.1,
664
721
  borderColor: o = "#000000",
665
722
  cellPadding: s = 2,
666
- headerStyle: f,
667
- rowStyle: l,
668
- alternateRowStyle: g,
669
- headerHeight: x
723
+ headerStyle: a,
724
+ rowStyle: c,
725
+ alternateRowStyle: u,
726
+ headerHeight: m
670
727
  }) => {
671
- const a = q();
728
+ const f = q();
672
729
  return A.useEffect(() => {
673
- a.queueOperation(() => {
674
- const R = typeof r == "number" ? r : parseFloat(r) / 100 * a.contentAreaWidth, h = t.map((m) => typeof m.width == "number" ? m.width : typeof m.width == "string" && m.width.endsWith("%") ? parseFloat(m.width) / 100 * R : 0), H = h.reduce((m, v) => m + v, 0), j = Math.max(0, R - H), C = h.filter((m) => m === 0).length;
675
- if (C > 0) {
676
- const m = j / C;
677
- for (let v = 0; v < h.length; v++)
678
- h[v] === 0 && (h[v] = m);
730
+ f.queueOperation(() => {
731
+ const x = typeof r == "number" ? r : parseFloat(r) / 100 * f.contentAreaWidth, d = t.map((b) => typeof b.width == "number" ? b.width : typeof b.width == "string" && b.width.endsWith("%") ? parseFloat(b.width) / 100 * x : 0), H = d.reduce((b, R) => b + R, 0), j = Math.max(0, x - H), E = d.filter((b) => b === 0).length;
732
+ if (E > 0) {
733
+ const b = j / E;
734
+ for (let R = 0; R < d.length; R++)
735
+ d[R] === 0 && (d[R] = b);
679
736
  }
680
- const u = (m, v, P, W, S, p, D = "left", Y = !0) => {
681
- Y && a.box(v, P, W, S, {
737
+ const h = (b, R, P, W, S, p, D = "left", Y = !0) => {
738
+ Y && f.box(R, P, W, S, {
682
739
  borderColor: p.borderColor ?? o,
683
740
  borderWidth: p.borderWidth ?? n,
684
741
  fillColor: p.fillColor
685
742
  });
686
- const z = Z(p.padding ?? s), E = {
743
+ const z = Z(p.padding ?? s), T = {
687
744
  top: p.paddingTop ?? z.top,
688
745
  right: p.paddingRight ?? z.right,
689
746
  bottom: p.paddingBottom ?? z.bottom,
690
747
  left: p.paddingLeft ?? z.left
691
- }, b = W - E.left - E.right, y = a.instance.splitTextToSize(m, b, p), w = (p.fontSize ?? a.baseFont.size) * (p.lineHeight ?? a.baseLineHeight) * 0.3528, F = (p.fontSize ?? a.baseFont.size) * 0.3528, e = y.length * w, c = S - E.top - E.bottom;
692
- let d = 0;
693
- p.verticalAlign === "middle" ? d = Math.max(0, (c - e) / 2) : p.verticalAlign === "bottom" && (d = Math.max(0, c - e));
694
- let T = P + E.top + d + F;
695
- const L = p.align ?? D, _ = a.getCursor();
696
- y.forEach((k) => {
697
- let I = v + E.left;
698
- L === "center" ? I = v + W / 2 : L === "right" && (I = v + W - E.right), a.textRaw(k, I, T, p, void 0, L), T += w;
699
- }), a.setCursor(_.x, _.y);
748
+ }, w = W - T.left - T.right, k = f.instance.splitTextToSize(b, w, p), v = (p.fontSize ?? f.baseFont.size) * (p.lineHeight ?? f.baseLineHeight) * 0.3528, F = (p.fontSize ?? f.baseFont.size) * 0.3528, e = k.length * v, l = S - T.top - T.bottom;
749
+ let g = 0;
750
+ p.verticalAlign === "middle" ? g = Math.max(0, (l - e) / 2) : p.verticalAlign === "bottom" && (g = Math.max(0, l - e));
751
+ let C = P + T.top + g + F;
752
+ const L = p.align ?? D, _ = f.getCursor();
753
+ k.forEach((y) => {
754
+ let M = R + T.left;
755
+ L === "center" ? M = R + W / 2 : L === "right" && (M = R + W - T.right), f.textRaw(y, M, C, p, void 0, L), C += v;
756
+ }), f.setCursor(_.x, _.y);
700
757
  };
701
- let O = a.getCursor().y;
702
- const M = a.getCursor().x, N = x ?? 10;
703
- O + N > a.contentBottom && (a.addPage(), O = a.getCursor().y);
704
- let B = M;
705
- t.forEach((m, v) => {
706
- const P = h[v];
707
- u(
708
- m.header ?? "",
709
- B,
758
+ let O = f.getCursor().y;
759
+ const X = f.getCursor().x, N = m ?? 10;
760
+ O + N > f.contentBottom && (f.addPage(), O = f.getCursor().y);
761
+ let U = X;
762
+ t.forEach((b, R) => {
763
+ const P = d[R];
764
+ h(
765
+ b.header ?? "",
766
+ U,
710
767
  O,
711
768
  P,
712
769
  N,
713
- f ?? { fontStyle: "bold" },
714
- m.align ?? "left"
715
- ), B += P;
716
- }), O += N, a.setCursor(M, O);
717
- const X = (m, v, P) => {
770
+ a ?? { fontStyle: "bold" },
771
+ b.align ?? "left"
772
+ ), U += P;
773
+ }), O += N, f.setCursor(X, O);
774
+ const B = (b, R, P) => {
718
775
  const W = Z(s), S = {
719
776
  top: P.paddingTop ?? W.top,
720
777
  right: P.paddingRight ?? W.right,
721
778
  bottom: P.paddingBottom ?? W.bottom,
722
779
  left: P.paddingLeft ?? W.left
723
- }, p = v - S.left - S.right;
724
- return a.measureText(m, P, p).height + S.top + S.bottom;
780
+ }, p = R - S.left - S.right;
781
+ return f.measureText(b, P, p).height + S.top + S.bottom;
725
782
  };
726
783
  new Array(t.length).fill(0), (() => {
727
- const m = new Array(i.length).fill(0);
784
+ const b = new Array(i.length).fill(0);
728
785
  for (let S = 0; S < i.length; S++) {
729
786
  const p = i[S];
730
787
  let D = 0;
731
788
  for (let Y = 0; Y < t.length; Y++) {
732
- const z = t[Y], E = typeof z.accessor == "function" ? z.accessor(p) : p[z.accessor];
733
- let b = "", y = l, w = 1, F = 1;
734
- if (E && typeof E == "object" && E.content !== void 0 ? (b = String(E.content), E.style && (y = E.style), E.colSpan && (w = E.colSpan), E.rowSpan && (F = E.rowSpan)) : b = String(E ?? ""), F > 1) {
735
- Y += w - 1;
789
+ const z = t[Y], T = typeof z.accessor == "function" ? z.accessor(p) : p[z.accessor];
790
+ let w = "", k = c, v = 1, F = 1;
791
+ if (T && typeof T == "object" && T.content !== void 0 ? (w = String(T.content), T.style && (k = T.style), T.colSpan && (v = T.colSpan), T.rowSpan && (F = T.rowSpan)) : w = String(T ?? ""), F > 1) {
792
+ Y += v - 1;
736
793
  continue;
737
794
  }
738
- let e = h[Y];
739
- for (let d = 1; d < w; d++)
740
- Y + d < h.length && (e += h[Y + d]);
741
- const c = X(b, e, y ?? {});
742
- c > D && (D = c), Y += w - 1;
795
+ let e = d[Y];
796
+ for (let g = 1; g < v; g++)
797
+ Y + g < d.length && (e += d[Y + g]);
798
+ const l = B(w, e, k ?? {});
799
+ l > D && (D = l), Y += v - 1;
743
800
  }
744
- D < 8 && (D = 8), m[S] = D;
801
+ D < 8 && (D = 8), b[S] = D;
745
802
  }
746
- let v = O;
747
- const P = new Array(t.length).fill(0), W = a.getCursor().x;
803
+ let R = O;
804
+ const P = new Array(t.length).fill(0), W = f.getCursor().x;
748
805
  for (let S = 0; S < i.length; S++) {
749
- const p = i[S], D = m[S];
806
+ const p = i[S], D = b[S];
750
807
  let Y = D;
751
- for (let b = 0; b < t.length; b++) {
752
- const y = t[b], w = typeof y.accessor == "function" ? y.accessor(p) : p[y.accessor];
808
+ for (let w = 0; w < t.length; w++) {
809
+ const k = t[w], v = typeof k.accessor == "function" ? k.accessor(p) : p[k.accessor];
753
810
  let F = 1;
754
- if (w && typeof w == "object" && w.rowSpan && (F = w.rowSpan), F > 1) {
811
+ if (v && typeof v == "object" && v.rowSpan && (F = v.rowSpan), F > 1) {
755
812
  let e = 0;
756
- for (let c = 0; c < F; c++)
757
- S + c < m.length && (e += m[S + c]);
813
+ for (let l = 0; l < F; l++)
814
+ S + l < b.length && (e += b[S + l]);
758
815
  e > Y && (Y = e);
759
816
  }
760
817
  }
761
- const z = Math.abs(v - (a.contentTop + (x ?? 10))) < 1;
762
- if (v + Y > a.contentBottom && !z && (a.addPage(), v = a.getCursor().y, x !== 0)) {
763
- let b = W;
764
- t.forEach((y, w) => {
765
- const F = h[w];
766
- u(
767
- y.header ?? "",
768
- b,
769
- v,
818
+ const z = Math.abs(R - (f.contentTop + (m ?? 10))) < 1;
819
+ if (R + Y > f.contentBottom && !z && (f.addPage(), R = f.getCursor().y, m !== 0)) {
820
+ let w = W;
821
+ t.forEach((k, v) => {
822
+ const F = d[v];
823
+ h(
824
+ k.header ?? "",
825
+ w,
826
+ R,
770
827
  F,
771
- x ?? 10,
772
- f ?? { fontStyle: "bold" },
773
- y.align ?? "left"
774
- ), b += F;
775
- }), v += x ?? 10;
828
+ m ?? 10,
829
+ a ?? { fontStyle: "bold" },
830
+ k.align ?? "left"
831
+ ), w += F;
832
+ }), R += m ?? 10;
776
833
  }
777
- let E = W;
778
- for (let b = 0; b < t.length; b++) {
779
- if (P[b] > 0) {
780
- P[b]--, E += h[b];
834
+ let T = W;
835
+ for (let w = 0; w < t.length; w++) {
836
+ if (P[w] > 0) {
837
+ P[w]--, T += d[w];
781
838
  continue;
782
839
  }
783
- const y = t[b], w = typeof y.accessor == "function" ? y.accessor(p) : p[y.accessor];
784
- let F = 1, e = 1, c = S % 2 === 1 && g ? g : l, d = "";
785
- w && typeof w == "object" && w.content !== void 0 ? (d = String(w.content), w.colSpan && (F = w.colSpan), w.rowSpan && (e = w.rowSpan), w.style && (c = { ...c, ...w.style })) : d = String(w ?? "");
786
- let T = h[b];
840
+ const k = t[w], v = typeof k.accessor == "function" ? k.accessor(p) : p[k.accessor];
841
+ let F = 1, e = 1, l = S % 2 === 1 && u ? u : c, g = "";
842
+ v && typeof v == "object" && v.content !== void 0 ? (g = String(v.content), v.colSpan && (F = v.colSpan), v.rowSpan && (e = v.rowSpan), v.style && (l = { ...l, ...v.style })) : g = String(v ?? "");
843
+ let C = d[w];
787
844
  for (let _ = 1; _ < F; _++)
788
- b + _ < h.length && (T += h[b + _]);
845
+ w + _ < d.length && (C += d[w + _]);
789
846
  let L = D;
790
847
  if (e > 1)
791
848
  for (let _ = 1; _ < e; _++)
792
- S + _ < m.length && (L += m[S + _]);
793
- if (u(
794
- d,
795
- E,
796
- v,
849
+ S + _ < b.length && (L += b[S + _]);
850
+ if (h(
851
+ g,
797
852
  T,
853
+ R,
854
+ C,
798
855
  L,
799
- c ?? {},
800
- y.align ?? "left",
856
+ l ?? {},
857
+ k.align ?? "left",
801
858
  !0
802
859
  ), e > 1) {
803
- P[b] = e - 1;
860
+ P[w] = e - 1;
804
861
  for (let _ = 1; _ < F; _++)
805
- b + _ < P.length && (P[b + _] = e - 1);
862
+ w + _ < P.length && (P[w + _] = e - 1);
806
863
  }
807
- E += T, b += F - 1;
864
+ T += C, w += F - 1;
808
865
  }
809
- v += D;
866
+ R += D;
810
867
  }
811
- a.setCursor(W, v);
868
+ f.setCursor(W, R);
812
869
  })();
813
870
  });
814
- }, [i, t, r]), null;
815
- }, Tt = ({
871
+ }, [f, i, t, r]), null;
872
+ }, St = ({
816
873
  children: i,
817
874
  x: t,
818
875
  y: r,
@@ -820,20 +877,29 @@ const nt = st(null), q = () => {
820
877
  spacingBelow: o = 2,
821
878
  ...s
822
879
  }) => {
823
- const f = q();
880
+ const a = q();
824
881
  return A.useEffect(() => {
825
- f.queueOperation(() => {
882
+ a.queueOperation(() => {
826
883
  if (typeof t == "number" && typeof r == "number")
827
- f.textRaw(i, t, r, s, n, s.align);
884
+ a.textRaw(i, t, r, s, n, s.align);
828
885
  else {
829
- f.paragraph(i, s, n);
830
- const l = f.getCursor();
831
- f.setCursor(l.x, l.y + o);
886
+ a.paragraph(i, s, n);
887
+ const c = a.getCursor();
888
+ a.setCursor(c.x, c.y + o);
832
889
  }
833
890
  });
834
- }, [i, t, r, n, o, s.fontSize, s.align]), null;
891
+ }, [
892
+ a,
893
+ i,
894
+ t,
895
+ r,
896
+ n,
897
+ o,
898
+ s.fontSize,
899
+ s.align
900
+ ]), null;
835
901
  };
836
- function gt(i) {
902
+ function mt(i) {
837
903
  return typeof i == "number" ? { top: i, right: i, bottom: i, left: i } : {
838
904
  top: i?.top ?? 0,
839
905
  right: i?.right ?? 0,
@@ -841,61 +907,62 @@ function gt(i) {
841
907
  left: i?.left ?? 0
842
908
  };
843
909
  }
844
- const Ct = ({ style: i = {}, children: t }) => {
910
+ const Pt = ({ style: i = {}, children: t }) => {
845
911
  const r = q(), n = Z(i.padding), o = {
846
912
  top: i.paddingTop ?? n.top,
847
913
  right: i.paddingRight ?? n.right,
848
914
  bottom: i.paddingBottom ?? n.bottom,
849
915
  left: i.paddingLeft ?? n.left
850
- }, s = gt(i.margin), f = {
916
+ }, s = mt(i.margin), a = {
851
917
  top: i.marginTop ?? s.top,
852
918
  right: i.marginRight ?? s.right,
853
919
  bottom: i.marginBottom ?? s.bottom,
854
920
  left: i.marginLeft ?? s.left
855
- }, l = A.useRef(
921
+ }, c = A.useRef(
856
922
  {}
857
923
  ).current;
858
924
  return A.useEffect(() => {
859
925
  r.queueOperation(() => {
860
- f.top > 0 && r.moveCursor(0, f.top);
861
- const g = r.getCursor();
862
- l.start = { ...g }, r.setCursor(g.x + o.left, g.y + o.top);
926
+ a.top > 0 && r.moveCursor(0, a.top);
927
+ const u = r.getCursor();
928
+ c.start = { ...u }, r.setCursor(u.x + o.left, u.y + o.top);
863
929
  });
864
- }, []), /* @__PURE__ */ U.jsxs(A.Fragment, { children: [
930
+ }, [r]), /* @__PURE__ */ I.jsxs(A.Fragment, { children: [
865
931
  t,
866
- /* @__PURE__ */ U.jsx(
867
- pt,
932
+ /* @__PURE__ */ I.jsx(
933
+ bt,
868
934
  {
869
- viewState: l,
935
+ viewState: c,
870
936
  style: i,
871
937
  pad: o,
872
- margin: f
938
+ margin: a
873
939
  }
874
940
  )
875
941
  ] });
876
- }, pt = ({ viewState: i, style: t, pad: r, margin: n }) => {
942
+ }, bt = ({ viewState: i, style: t, pad: r, margin: n }) => {
877
943
  const o = q();
878
944
  return A.useEffect(() => {
879
945
  o.queueOperation(() => {
880
946
  const s = i.start;
881
947
  if (!s) return;
882
- const f = o.getCursor();
883
- let g = Math.max(f.y - s.y - r.top, 0) + r.top + r.bottom;
884
- t.height && (g = t.height);
885
- let x = o.contentAreaWidth;
886
- typeof t.width == "number" && (x = t.width), (t.borderColor || t.fillColor || t.borderWidth) && o.box(s.x, s.y, x, g, t);
887
- const a = s.y + g + n.bottom;
888
- o.setCursor(s.x, a);
948
+ const a = o.getCursor();
949
+ let u = Math.max(a.y - s.y - r.top, 0) + r.top + r.bottom;
950
+ t.height && (u = t.height);
951
+ let m = o.contentAreaWidth;
952
+ typeof t.width == "number" && (m = t.width), (t.borderColor || t.fillColor || t.borderWidth) && o.box(s.x, s.y, m, u, t);
953
+ const f = s.y + u + n.bottom;
954
+ o.setCursor(s.x, f);
889
955
  });
890
- }, []), null;
956
+ }, [o]), null;
891
957
  };
892
958
  export {
893
- vt as PdfBox,
894
- wt as PdfDocument,
895
- xt as PdfImage,
896
- Rt as PdfList,
897
- ht as PdfRenderer,
959
+ xt as PdfBox,
960
+ gt as PdfDocument,
961
+ Rt as PdfImage,
962
+ Tt as PdfList,
963
+ Ct as PdfPreview,
964
+ dt as PdfRenderer,
898
965
  Et as PdfTable,
899
- Tt as PdfText,
900
- Ct as PdfView
966
+ St as PdfText,
967
+ Pt as PdfView
901
968
  };