react-vector-pdf 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,70 +1,70 @@
1
- import $, { createContext as ct, useContext as ft, useState as lt } from "react";
2
- import { jsPDF as et } from "jspdf";
3
- var K = { exports: {} }, Q = {};
4
- var rt;
5
- function ht() {
6
- if (rt) return Q;
7
- rt = 1;
1
+ import z, { useRef as Ot, createContext as At, useContext as jt, useId as Ct, useState as Yt } from "react";
2
+ import { jsPDF as Ft } from "jspdf";
3
+ var xt = { exports: {} }, bt = {};
4
+ var Et;
5
+ function Ht() {
6
+ if (Et) return bt;
7
+ Et = 1;
8
8
  var n = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
9
- function r(a, i, s) {
10
- var e = null;
11
- if (s !== void 0 && (e = "" + s), i.key !== void 0 && (e = "" + i.key), "key" in i) {
9
+ function r(i, e, s) {
10
+ var u = null;
11
+ if (s !== void 0 && (u = "" + s), e.key !== void 0 && (u = "" + e.key), "key" in e) {
12
12
  s = {};
13
- for (var f in i)
14
- f !== "key" && (s[f] = i[f]);
15
- } else s = i;
16
- return i = s.ref, {
13
+ for (var c in e)
14
+ c !== "key" && (s[c] = e[c]);
15
+ } else s = e;
16
+ return e = s.ref, {
17
17
  $$typeof: n,
18
- type: a,
19
- key: e,
20
- ref: i !== void 0 ? i : null,
18
+ type: i,
19
+ key: u,
20
+ ref: e !== void 0 ? e : null,
21
21
  props: s
22
22
  };
23
23
  }
24
- return Q.Fragment = t, Q.jsx = r, Q.jsxs = r, Q;
24
+ return bt.Fragment = t, bt.jsx = r, bt.jsxs = r, bt;
25
25
  }
26
- var Z = {};
27
- var ot;
28
- function ut() {
29
- return ot || (ot = 1, process.env.NODE_ENV !== "production" && (function() {
26
+ var vt = {};
27
+ var kt;
28
+ function Lt() {
29
+ return kt || (kt = 1, process.env.NODE_ENV !== "production" && (function() {
30
30
  function n(o) {
31
31
  if (o == null) return null;
32
32
  if (typeof o == "function")
33
- return o.$$typeof === E ? null : o.displayName || o.name || null;
33
+ return o.$$typeof === U ? null : o.displayName || o.name || null;
34
34
  if (typeof o == "string") return o;
35
35
  switch (o) {
36
- case d:
36
+ case l:
37
37
  return "Fragment";
38
- case L:
38
+ case v:
39
39
  return "Profiler";
40
- case P:
40
+ case m:
41
41
  return "StrictMode";
42
- case X:
42
+ case _:
43
43
  return "Suspense";
44
- case M:
44
+ case W:
45
45
  return "SuspenseList";
46
- case A:
46
+ case F:
47
47
  return "Activity";
48
48
  }
49
49
  if (typeof o == "object")
50
50
  switch (typeof o.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
  ), o.$$typeof) {
53
- case w:
53
+ case d:
54
54
  return "Portal";
55
- case j:
55
+ case x:
56
56
  return o.displayName || "Context";
57
- case y:
57
+ case C:
58
58
  return (o._context.displayName || "Context") + ".Consumer";
59
- case I:
60
- var c = o.render;
61
- return o = o.displayName, o || (o = c.displayName || c.name || "", o = o !== "" ? "ForwardRef(" + o + ")" : "ForwardRef"), o;
62
- case J:
63
- return c = o.displayName || null, c !== null ? c : n(o.type) || "Memo";
64
- case S:
65
- c = o._payload, o = o._init;
59
+ case g:
60
+ var w = o.render;
61
+ return o = o.displayName, o || (o = w.displayName || w.name || "", o = o !== "" ? "ForwardRef(" + o + ")" : "ForwardRef"), o;
62
+ case H:
63
+ return w = o.displayName || null, w !== null ? w : n(o.type) || "Memo";
64
+ case O:
65
+ w = o._payload, o = o._init;
66
66
  try {
67
- return n(o(c));
67
+ return n(o(w));
68
68
  } catch {
69
69
  }
70
70
  }
@@ -76,74 +76,74 @@ function ut() {
76
76
  function r(o) {
77
77
  try {
78
78
  t(o);
79
- var c = !1;
79
+ var w = !1;
80
80
  } catch {
81
- c = !0;
81
+ w = !0;
82
82
  }
83
- if (c) {
84
- c = console;
85
- var b = c.error, C = typeof Symbol == "function" && Symbol.toStringTag && o[Symbol.toStringTag] || o.constructor.name || "Object";
86
- return b.call(
87
- c,
83
+ if (w) {
84
+ w = console;
85
+ var T = w.error, Y = typeof Symbol == "function" && Symbol.toStringTag && o[Symbol.toStringTag] || o.constructor.name || "Object";
86
+ return T.call(
87
+ w,
88
88
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
89
- C
89
+ Y
90
90
  ), t(o);
91
91
  }
92
92
  }
93
- function a(o) {
94
- if (o === d) return "<>";
95
- if (typeof o == "object" && o !== null && o.$$typeof === S)
93
+ function i(o) {
94
+ if (o === l) return "<>";
95
+ if (typeof o == "object" && o !== null && o.$$typeof === O)
96
96
  return "<...>";
97
97
  try {
98
- var c = n(o);
99
- return c ? "<" + c + ">" : "<...>";
98
+ var w = n(o);
99
+ return w ? "<" + w + ">" : "<...>";
100
100
  } catch {
101
101
  return "<...>";
102
102
  }
103
103
  }
104
- function i() {
105
- var o = Y.A;
104
+ function e() {
105
+ var o = q.A;
106
106
  return o === null ? null : o.getOwner();
107
107
  }
108
108
  function s() {
109
109
  return Error("react-stack-top-frame");
110
110
  }
111
- function e(o) {
112
- if (z.call(o, "key")) {
113
- var c = Object.getOwnPropertyDescriptor(o, "key").get;
114
- if (c && c.isReactWarning) return !1;
111
+ function u(o) {
112
+ if (L.call(o, "key")) {
113
+ var w = Object.getOwnPropertyDescriptor(o, "key").get;
114
+ if (w && w.isReactWarning) return !1;
115
115
  }
116
116
  return o.key !== void 0;
117
117
  }
118
- function f(o, c) {
119
- function b() {
120
- D || (D = !0, console.error(
118
+ function c(o, w) {
119
+ function T() {
120
+ E || (E = !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
+ w
123
123
  ));
124
124
  }
125
- b.isReactWarning = !0, Object.defineProperty(o, "key", {
126
- get: b,
125
+ T.isReactWarning = !0, Object.defineProperty(o, "key", {
126
+ get: T,
127
127
  configurable: !0
128
128
  });
129
129
  }
130
- function u() {
130
+ function a() {
131
131
  var o = n(this.type);
132
- return k[o] || (k[o] = !0, console.error(
132
+ return M[o] || (M[o] = !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
  )), o = this.props.ref, o !== void 0 ? o : null;
135
135
  }
136
- function p(o, c, b, C, F, N) {
137
- var T = b.ref;
136
+ function y(o, w, T, Y, Z, ut) {
137
+ var $ = T.ref;
138
138
  return o = {
139
- $$typeof: m,
139
+ $$typeof: b,
140
140
  type: o,
141
- key: c,
142
- props: b,
143
- _owner: C
144
- }, (T !== void 0 ? T : null) !== null ? Object.defineProperty(o, "ref", {
141
+ key: w,
142
+ props: T,
143
+ _owner: Y
144
+ }, ($ !== void 0 ? $ : null) !== null ? Object.defineProperty(o, "ref", {
145
145
  enumerable: !1,
146
- get: u
146
+ get: a
147
147
  }) : Object.defineProperty(o, "ref", { enumerable: !1, value: null }), o._store = {}, Object.defineProperty(o._store, "validated", {
148
148
  configurable: !1,
149
149
  enumerable: !1,
@@ -158,109 +158,214 @@ function ut() {
158
158
  configurable: !1,
159
159
  enumerable: !1,
160
160
  writable: !0,
161
- value: F
161
+ value: Z
162
162
  }), Object.defineProperty(o, "_debugTask", {
163
163
  configurable: !1,
164
164
  enumerable: !1,
165
165
  writable: !0,
166
- value: N
166
+ value: ut
167
167
  }), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
168
168
  }
169
- function l(o, c, b, C, F, N) {
170
- var T = c.children;
171
- if (T !== void 0)
172
- if (C)
173
- if (v(T)) {
174
- for (C = 0; C < T.length; C++)
175
- x(T[C]);
176
- Object.freeze && Object.freeze(T);
169
+ function f(o, w, T, Y, Z, ut) {
170
+ var $ = w.children;
171
+ if ($ !== void 0)
172
+ if (Y)
173
+ if (R($)) {
174
+ for (Y = 0; Y < $.length; Y++)
175
+ P($[Y]);
176
+ Object.freeze && Object.freeze($);
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 x(T);
182
- if (z.call(c, "key")) {
183
- T = n(o);
184
- var B = Object.keys(c).filter(function(O) {
185
- return O !== "key";
181
+ else P($);
182
+ if (L.call(w, "key")) {
183
+ $ = n(o);
184
+ var lt = Object.keys(w).filter(function(X) {
185
+ return X !== "key";
186
186
  });
187
- C = 0 < B.length ? "{key: someKey, " + B.join(": ..., ") + ": ...}" : "{key: someKey}", R[T + C] || (B = 0 < B.length ? "{" + B.join(": ..., ") + ": ...}" : "{}", console.error(
187
+ Y = 0 < lt.length ? "{key: someKey, " + lt.join(": ..., ") + ": ...}" : "{key: someKey}", S[$ + Y] || (lt = 0 < lt.length ? "{" + lt.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
- C,
195
- T,
196
- B,
197
- T
198
- ), R[T + C] = !0);
194
+ Y,
195
+ $,
196
+ lt,
197
+ $
198
+ ), S[$ + Y] = !0);
199
199
  }
200
- if (T = null, b !== void 0 && (r(b), T = "" + b), e(c) && (r(c.key), T = "" + c.key), "key" in c) {
201
- b = {};
202
- for (var G in c)
203
- G !== "key" && (b[G] = c[G]);
204
- } else b = c;
205
- return T && f(
206
- b,
200
+ if ($ = null, T !== void 0 && (r(T), $ = "" + T), u(w) && (r(w.key), $ = "" + w.key), "key" in w) {
201
+ T = {};
202
+ for (var I in w)
203
+ I !== "key" && (T[I] = w[I]);
204
+ } else T = w;
205
+ return $ && c(
206
+ T,
207
207
  typeof o == "function" ? o.displayName || o.name || "Unknown" : o
208
- ), p(
208
+ ), y(
209
209
  o,
210
+ $,
210
211
  T,
211
- b,
212
- i(),
213
- F,
214
- N
212
+ e(),
213
+ Z,
214
+ ut
215
215
  );
216
216
  }
217
- function x(o) {
218
- h(o) ? o._store && (o._store.validated = 1) : typeof o == "object" && o !== null && o.$$typeof === S && (o._payload.status === "fulfilled" ? h(o._payload.value) && o._payload.value._store && (o._payload.value._store.validated = 1) : o._store && (o._store.validated = 1));
217
+ function P(o) {
218
+ h(o) ? o._store && (o._store.validated = 1) : typeof o == "object" && o !== null && o.$$typeof === O && (o._payload.status === "fulfilled" ? h(o._payload.value) && o._payload.value._store && (o._payload.value._store.validated = 1) : o._store && (o._store.validated = 1));
219
219
  }
220
220
  function h(o) {
221
- return typeof o == "object" && o !== null && o.$$typeof === m;
221
+ return typeof o == "object" && o !== null && o.$$typeof === b;
222
222
  }
223
- var g = $, m = /* @__PURE__ */ Symbol.for("react.transitional.element"), w = /* @__PURE__ */ Symbol.for("react.portal"), d = /* @__PURE__ */ Symbol.for("react.fragment"), P = /* @__PURE__ */ Symbol.for("react.strict_mode"), L = /* @__PURE__ */ Symbol.for("react.profiler"), y = /* @__PURE__ */ Symbol.for("react.consumer"), j = /* @__PURE__ */ Symbol.for("react.context"), I = /* @__PURE__ */ Symbol.for("react.forward_ref"), X = /* @__PURE__ */ Symbol.for("react.suspense"), M = /* @__PURE__ */ Symbol.for("react.suspense_list"), J = /* @__PURE__ */ Symbol.for("react.memo"), S = /* @__PURE__ */ Symbol.for("react.lazy"), A = /* @__PURE__ */ Symbol.for("react.activity"), E = /* @__PURE__ */ Symbol.for("react.client.reference"), Y = g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, z = Object.prototype.hasOwnProperty, v = Array.isArray, W = console.createTask ? console.createTask : function() {
223
+ var p = z, b = /* @__PURE__ */ Symbol.for("react.transitional.element"), d = /* @__PURE__ */ Symbol.for("react.portal"), l = /* @__PURE__ */ Symbol.for("react.fragment"), m = /* @__PURE__ */ Symbol.for("react.strict_mode"), v = /* @__PURE__ */ Symbol.for("react.profiler"), C = /* @__PURE__ */ Symbol.for("react.consumer"), x = /* @__PURE__ */ Symbol.for("react.context"), g = /* @__PURE__ */ Symbol.for("react.forward_ref"), _ = /* @__PURE__ */ Symbol.for("react.suspense"), W = /* @__PURE__ */ Symbol.for("react.suspense_list"), H = /* @__PURE__ */ Symbol.for("react.memo"), O = /* @__PURE__ */ Symbol.for("react.lazy"), F = /* @__PURE__ */ Symbol.for("react.activity"), U = /* @__PURE__ */ Symbol.for("react.client.reference"), q = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, L = Object.prototype.hasOwnProperty, R = Array.isArray, at = console.createTask ? console.createTask : function() {
224
224
  return null;
225
225
  };
226
- g = {
226
+ p = {
227
227
  react_stack_bottom_frame: function(o) {
228
228
  return o();
229
229
  }
230
230
  };
231
- var D, k = {}, H = g.react_stack_bottom_frame.bind(
232
- g,
231
+ var E, M = {}, ft = p.react_stack_bottom_frame.bind(
232
+ p,
233
233
  s
234
- )(), _ = W(a(s)), R = {};
235
- Z.Fragment = d, Z.jsx = function(o, c, b) {
236
- var C = 1e4 > Y.recentlyCreatedOwnerStacks++;
237
- return l(
234
+ )(), st = at(i(s)), S = {};
235
+ vt.Fragment = l, vt.jsx = function(o, w, T) {
236
+ var Y = 1e4 > q.recentlyCreatedOwnerStacks++;
237
+ return f(
238
238
  o,
239
- c,
240
- b,
239
+ w,
240
+ T,
241
241
  !1,
242
- C ? Error("react-stack-top-frame") : H,
243
- C ? W(a(o)) : _
242
+ Y ? Error("react-stack-top-frame") : ft,
243
+ Y ? at(i(o)) : st
244
244
  );
245
- }, Z.jsxs = function(o, c, b) {
246
- var C = 1e4 > Y.recentlyCreatedOwnerStacks++;
247
- return l(
245
+ }, vt.jsxs = function(o, w, T) {
246
+ var Y = 1e4 > q.recentlyCreatedOwnerStacks++;
247
+ return f(
248
248
  o,
249
- c,
250
- b,
249
+ w,
250
+ T,
251
251
  !0,
252
- C ? Error("react-stack-top-frame") : H,
253
- C ? W(a(o)) : _
252
+ Y ? Error("react-stack-top-frame") : ft,
253
+ Y ? at(i(o)) : st
254
254
  );
255
255
  };
256
- })()), Z;
256
+ })()), vt;
257
+ }
258
+ var _t;
259
+ function Dt() {
260
+ return _t || (_t = 1, process.env.NODE_ENV === "production" ? xt.exports = Ht() : xt.exports = Lt()), xt.exports;
261
+ }
262
+ var tt = Dt();
263
+ const Wt = 96, Mt = 25.4, zt = Mt / Wt, Xt = 72 / Wt, Bt = [
264
+ "boxShadow",
265
+ "textShadow",
266
+ // "opacity", // Ignored silently
267
+ "zIndex",
268
+ // "display", // Ignored silently
269
+ // "position", // Ignored silently
270
+ "float",
271
+ "overflow",
272
+ "cursor",
273
+ // "transition", // Ignored silently
274
+ "transform"
275
+ // "animation", // Ignored silently
276
+ ], Nt = "block", Ut = "inline";
277
+ function it(n) {
278
+ if (!n || !n.endsWith("px")) return;
279
+ const t = parseFloat(n);
280
+ return isNaN(t) ? void 0 : t * zt;
281
+ }
282
+ function qt(n) {
283
+ if (!n || !n.endsWith("px")) return;
284
+ const t = parseFloat(n);
285
+ return isNaN(t) ? void 0 : t * Xt;
286
+ }
287
+ function Rt(n) {
288
+ if (!(!n || n === "rgba(0, 0, 0, 0)" || n === "transparent"))
289
+ return n;
290
+ }
291
+ function Vt(n) {
292
+ if (n === "left" || n === "center" || n === "right" || n === "justify")
293
+ return n;
294
+ }
295
+ function Gt(n) {
296
+ const t = it(n.paddingTop), r = it(n.paddingRight), i = it(n.paddingBottom), e = it(n.paddingLeft);
297
+ if (!(t === void 0 && r === void 0 && i === void 0 && e === void 0))
298
+ return {
299
+ top: t ?? 0,
300
+ right: r ?? 0,
301
+ bottom: i ?? 0,
302
+ left: e ?? 0
303
+ };
304
+ }
305
+ function Jt(n) {
306
+ const t = it(n.marginTop), r = it(n.marginRight), i = it(n.marginBottom), e = it(n.marginLeft);
307
+ if (!(t === void 0 && r === void 0 && i === void 0 && e === void 0))
308
+ return {
309
+ top: t ?? 0,
310
+ right: r ?? 0,
311
+ bottom: i ?? 0,
312
+ left: e ?? 0
313
+ };
257
314
  }
258
- var nt;
259
- function dt() {
260
- return nt || (nt = 1, process.env.NODE_ENV === "production" ? K.exports = ht() : K.exports = ut()), K.exports;
315
+ function wt(n, t) {
316
+ const r = Ot(null);
317
+ return { ref: r, computeStyle: () => {
318
+ if (!r.current) return {};
319
+ const e = window.getComputedStyle(r.current);
320
+ Bt.forEach((x) => {
321
+ const g = e[x];
322
+ if (g && g !== "none" && g !== "auto" && g !== "0px" && g !== "normal" && g !== "visible" && g !== "static") {
323
+ if (x === "display" && (g === Nt || g === Ut))
324
+ return;
325
+ console.warn(
326
+ `react-vector-pdf: CSS property '${x}' with value '${g}' is not supported and will be ignored.`
327
+ );
328
+ }
329
+ });
330
+ const s = {}, u = qt(e.fontSize);
331
+ u && (s.fontSize = u);
332
+ const c = e.fontWeight;
333
+ e.fontStyle === "italic" ? c === "bold" || c === "700" || parseInt(c) >= 700 ? s.fontStyle = "bolditalic" : s.fontStyle = "italic" : c === "bold" || c === "700" || parseInt(c) >= 700 ? s.fontStyle = "bold" : s.fontStyle = "normal";
334
+ const y = Rt(e.color);
335
+ y && (s.color = y);
336
+ const f = Vt(e.textAlign);
337
+ f && (s.align = f);
338
+ const h = (() => {
339
+ if (e.lineHeight === "normal") return;
340
+ const x = parseFloat(e.lineHeight), g = parseFloat(e.fontSize);
341
+ if (!isNaN(x) && !isNaN(g) && g > 0)
342
+ return x / g;
343
+ })();
344
+ h && (s.lineHeight = h);
345
+ const p = Rt(e.backgroundColor);
346
+ p && (s.fillColor = p);
347
+ const b = Rt(e.borderColor);
348
+ b && (s.borderColor = b);
349
+ const d = it(e.borderTopWidth);
350
+ d && (s.borderWidth = d);
351
+ const l = Gt(e);
352
+ l && (s.padding = l);
353
+ const m = Jt(e);
354
+ if (m && (s.margin = m), e.width && e.width !== "auto") {
355
+ const x = it(e.width);
356
+ x && x > 0 && (s.width = x);
357
+ }
358
+ if (e.height && e.height !== "auto") {
359
+ const x = it(e.height);
360
+ x && x > 0 && (s.height = x);
361
+ }
362
+ const v = it(e.gap) ?? it(e.rowGap);
363
+ v && (s.gap = v);
364
+ const C = it(e.borderRadius);
365
+ return C && (s.radius = C), s;
366
+ } };
261
367
  }
262
- var U = dt();
263
- function tt(n) {
368
+ function St(n) {
264
369
  return !n && n !== 0 ? { top: 0, right: 0, bottom: 0, left: 0 } : typeof n == "number" ? { top: n, right: n, bottom: n, left: n } : {
265
370
  top: n.top ?? 0,
266
371
  right: n.right ?? 0,
@@ -268,33 +373,33 @@ function tt(n) {
268
373
  left: n.left ?? 0
269
374
  };
270
375
  }
271
- function q(n) {
376
+ function gt(n) {
272
377
  if (!n) return null;
273
378
  if (n.startsWith("#")) {
274
379
  const r = n.replace("#", "");
275
380
  if (r.length === 3) {
276
- const a = parseInt(r[0] + r[0], 16), i = parseInt(r[1] + r[1], 16), s = parseInt(r[2] + r[2], 16);
277
- return [a, i, s, 1];
381
+ const i = parseInt(r[0] + r[0], 16), e = parseInt(r[1] + r[1], 16), s = parseInt(r[2] + r[2], 16);
382
+ return [i, e, s, 1];
278
383
  }
279
384
  if (r.length === 6) {
280
- const a = parseInt(r.slice(0, 2), 16), i = parseInt(r.slice(2, 4), 16), s = parseInt(r.slice(4, 6), 16);
281
- return [a, i, s, 1];
385
+ const i = parseInt(r.slice(0, 2), 16), e = parseInt(r.slice(2, 4), 16), s = parseInt(r.slice(4, 6), 16);
386
+ return [i, e, s, 1];
282
387
  }
283
388
  if (r.length === 8) {
284
- const a = parseInt(r.slice(0, 2), 16), i = parseInt(r.slice(2, 4), 16), s = parseInt(r.slice(4, 6), 16), e = parseInt(r.slice(6, 8), 16) / 255;
285
- return [a, i, s, e];
389
+ const i = parseInt(r.slice(0, 2), 16), e = parseInt(r.slice(2, 4), 16), s = parseInt(r.slice(4, 6), 16), u = parseInt(r.slice(6, 8), 16) / 255;
390
+ return [i, e, s, u];
286
391
  }
287
392
  }
288
393
  const t = n.match(
289
394
  /rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/
290
395
  );
291
396
  if (t) {
292
- const r = parseInt(t[1], 10), a = parseInt(t[2], 10), i = parseInt(t[3], 10), s = t[4] !== void 0 ? parseFloat(t[4]) : 1;
293
- return [r, a, i, s];
397
+ const r = parseInt(t[1], 10), i = parseInt(t[2], 10), e = parseInt(t[3], 10), s = t[4] !== void 0 ? parseFloat(t[4]) : 1;
398
+ return [r, i, e, s];
294
399
  }
295
400
  return null;
296
401
  }
297
- function it(n, t = !0) {
402
+ function It(n, t = !0) {
298
403
  if (n <= 0) return String(n);
299
404
  const r = [
300
405
  [1e3, "M"],
@@ -311,34 +416,31 @@ function it(n, t = !0) {
311
416
  [4, "IV"],
312
417
  [1, "I"]
313
418
  ];
314
- let a = n, i = "";
315
- for (const [s, e] of r)
316
- for (; a >= s; )
317
- i += e, a -= s;
318
- return t ? i : i.toLowerCase();
419
+ let i = n, e = "";
420
+ for (const [s, u] of r)
421
+ for (; i >= s; )
422
+ e += u, i -= s;
423
+ return t ? e : e.toLowerCase();
319
424
  }
320
- function st(n, t) {
425
+ function Pt(n, t) {
321
426
  return !t || t === "all" ? !0 : t === "first-only" ? n === 1 : t === "except-first" ? n > 1 : Array.isArray(t) ? t.includes(n) : !0;
322
427
  }
323
- class gt {
428
+ class Qt {
324
429
  constructor(t = {}) {
325
430
  this.cursorX = 0, this.cursorY = 0, this.contentWidth = 0, this.reservedBottomHeight = 0, this.margin = { top: 15, right: 15, bottom: 15, left: 15 }, this.defaultFont = {
326
431
  name: void 0,
327
432
  style: "normal",
328
433
  size: 12
329
- }, this.defaultColor = "#111827", this.defaultLineHeight = 1.25, this.pendingTasks = /* @__PURE__ */ new Set(), this.opQueue = Promise.resolve(), this.generation = 0, this.recordingStack = [], this.recurringItems = [], this.indentStack = [], this.currentIndent = { left: 0, right: 0 }, this.options = t, this.margin = t.margin ?? this.margin, this.defaultFont = {
434
+ }, this.defaultColor = "#111827", this.defaultLineHeight = 1.25, this.pendingTasks = /* @__PURE__ */ new Set(), this.opQueue = Promise.resolve(), this.generation = 0, this.recordingStack = [], this.recurringItems = [], this.indentStack = [], this.currentIndent = { left: 0, right: 0 }, this.verticalPaddingStack = [], this.options = t, this.margin = t.margin ?? this.margin, this.defaultFont = {
330
435
  name: t.font?.name,
331
436
  style: t.font?.style ?? "normal",
332
437
  size: t.font?.size ?? 12
333
- }, this.defaultColor = t.color ?? this.defaultColor, this.defaultLineHeight = t.lineHeight ?? this.defaultLineHeight, this.pdf = new et({
438
+ }, this.defaultColor = t.color ?? this.defaultColor, this.defaultLineHeight = t.lineHeight ?? this.defaultLineHeight, this.pdf = new Ft({
334
439
  unit: t.unit ?? "mm",
335
440
  format: t.format ?? "a4",
336
441
  orientation: t.orientation ?? "p"
337
442
  }), this.pageWidth = this.pdf.internal.pageSize.getWidth(), this.pageHeight = this.pdf.internal.pageSize.getHeight(), this.resetFlowCursor(), this.applyBaseFont();
338
443
  }
339
- // ... getters ...
340
- // (Keeping getters omitted for brevity in replace block if possible, but replace_file_content needs context)
341
- // I will target the variable declaration area specifically.
342
444
  // Implementation of Stack Methods
343
445
  startRecording() {
344
446
  this.recordingStack.push([]);
@@ -368,10 +470,30 @@ class gt {
368
470
  return this.pageWidth - this.margin.right;
369
471
  }
370
472
  get contentTop() {
371
- return this.margin.top;
473
+ return this.margin.top + this.currentVerticalPadding.top;
372
474
  }
373
475
  get contentBottom() {
374
- return this.pageHeight - this.margin.bottom - this.reservedBottomHeight;
476
+ return this.pageHeight - this.margin.bottom - this.currentVerticalPadding.bottom;
477
+ }
478
+ pushIndent(t, r) {
479
+ this.indentStack.push({ ...this.currentIndent }), this.currentIndent.left += t, this.currentIndent.right += r, this.cursorX += t, this.contentWidth = this.pageWidth - this.margin.left - this.margin.right - this.currentIndent.left - this.currentIndent.right;
480
+ }
481
+ popIndent() {
482
+ const t = this.indentStack.pop();
483
+ t && (this.currentIndent = t, this.contentWidth = this.pageWidth - this.margin.left - this.margin.right - this.currentIndent.left - this.currentIndent.right);
484
+ }
485
+ /**
486
+ * Returns the top Y position for content on a given page, accounting for recurring items.
487
+ * This is useful for drawing background boxes that shouldn't overlap headers.
488
+ */
489
+ getSafeContentTop(t) {
490
+ let r = this.margin.top;
491
+ for (const i of this.recurringItems)
492
+ if (Pt(t, i.scope) && i.y <= r + 10) {
493
+ const e = i.y + i.height;
494
+ e > r && (r = e);
495
+ }
496
+ return r;
375
497
  }
376
498
  get contentHeight() {
377
499
  return this.contentBottom - this.contentTop;
@@ -385,26 +507,33 @@ class gt {
385
507
  get baseLineHeight() {
386
508
  return this.defaultLineHeight;
387
509
  }
388
- setReservedHeight(t) {
389
- this.reservedBottomHeight = t;
510
+ pushVerticalPadding(t, r) {
511
+ this.verticalPaddingStack.push({ top: t, bottom: r }), this.cursorY += t;
390
512
  }
391
- pushIndent(t, r) {
392
- this.indentStack.push({ ...this.currentIndent }), this.currentIndent.left += t, this.currentIndent.right += r, this.cursorX += t, this.contentWidth = this.pageWidth - this.margin.left - this.margin.right - this.currentIndent.left - this.currentIndent.right;
513
+ popVerticalPadding() {
514
+ const t = this.verticalPaddingStack.pop();
515
+ t && (this.cursorY += t.bottom);
393
516
  }
394
- popIndent() {
395
- const t = this.indentStack.pop();
396
- t && (this.currentIndent.left - t.left, this.currentIndent = t, this.contentWidth = this.pageWidth - this.margin.left - this.margin.right - this.currentIndent.left - this.currentIndent.right);
517
+ get currentVerticalPadding() {
518
+ let t = 0, r = 0;
519
+ for (const i of this.verticalPaddingStack)
520
+ t += i.top, r += i.bottom;
521
+ return { top: t, bottom: r };
397
522
  }
523
+ // Legacy support or override if needed, but we prefer stack
524
+ setReservedHeight(t) {
525
+ }
526
+ // ...
398
527
  resetFlowCursor() {
399
- this.cursorX = this.margin.left + this.currentIndent.left, this.cursorY = this.margin.top, this.contentWidth = this.pageWidth - this.margin.left - this.margin.right - this.currentIndent.left - this.currentIndent.right;
528
+ this.cursorX = this.margin.left + this.currentIndent.left, this.cursorY = this.margin.top + this.currentVerticalPadding.top, this.contentWidth = this.pageWidth - this.margin.left - this.margin.right - this.currentIndent.left - this.currentIndent.right;
400
529
  }
401
530
  reset() {
402
- if (this.pdf = new et({
531
+ if (this.pdf = new Ft({
403
532
  unit: this.options.unit ?? "mm",
404
533
  format: this.options.format ?? "a4",
405
534
  orientation: this.options.orientation ?? "p"
406
- }), this.generation++, this.cursorX = 0, this.cursorY = 0, this.pendingTasks = /* @__PURE__ */ new Set(), this.opQueue = Promise.resolve(), this.resetFlowCursor(), this.applyBaseFont(), this.options.color) {
407
- const t = q(this.options.color);
535
+ }), this.generation++, this.cursorX = 0, this.cursorY = 0, this.verticalPaddingStack = [], this.pendingTasks = /* @__PURE__ */ new Set(), this.opQueue = Promise.resolve(), this.indentStack = [], this.currentIndent = { left: 0, right: 0 }, this.recordingStack = [], this.resetFlowCursor(), this.applyBaseFont(), this.options.color) {
536
+ const t = gt(this.options.color);
408
537
  t && this.pdf.setTextColor(...t);
409
538
  }
410
539
  this.recurringItems = [];
@@ -413,20 +542,22 @@ class gt {
413
542
  this.headerDrawer = t, this.footerDrawer = r;
414
543
  }
415
544
  applyBaseFont() {
416
- const t = this.defaultFont.name ?? this.pdf.getFont().fontName, r = this.defaultFont.style, a = this.defaultFont.size, i = this.defaultColor;
545
+ const t = this.defaultFont.name ?? this.pdf.getFont().fontName, r = this.defaultFont.style, i = this.defaultFont.size, e = this.defaultColor;
417
546
  this.drawOp(() => {
418
- this.pdf.setFont(t, r), this.pdf.setFontSize(a);
419
- const s = q(i);
547
+ this.pdf.setFont(t, r), this.pdf.setFontSize(i);
548
+ const s = gt(e);
420
549
  s && this.pdf.setTextColor(...s);
421
550
  });
422
551
  }
423
552
  addPage() {
553
+ const t = this.margin.left + this.currentIndent.left;
424
554
  this.drawOp(() => {
425
555
  this.pdf.addPage();
426
556
  }), this.resetFlowCursor();
427
- const t = this.getPageCount();
428
- for (const r of this.recurringItems)
429
- st(t, r.scope) && (r.draw(), r.y + r.height > this.cursorY && (this.cursorY = r.y + r.height));
557
+ const r = this.getPageCount();
558
+ for (const i of this.recurringItems)
559
+ Pt(r, i.scope) && (i.draw(), i.y + i.height > this.cursorY && (this.cursorY = i.y + i.height));
560
+ this.cursorX = t;
430
561
  }
431
562
  ensureSpace(t) {
432
563
  if (this.cursorY + t > this.contentBottom) {
@@ -434,11 +565,11 @@ class gt {
434
565
  return;
435
566
  }
436
567
  const r = this.getPageCount();
437
- let a = !0;
438
- for (; a; ) {
439
- a = !1;
440
- for (const i of this.recurringItems)
441
- if (st(r, i.scope) && this.cursorY < i.y + i.height && this.cursorY + t > i.y && (this.cursorY = i.y + i.height, a = !0, this.cursorY + t > this.contentBottom)) {
568
+ let i = !0;
569
+ for (; i; ) {
570
+ i = !1;
571
+ for (const e of this.recurringItems)
572
+ if (Pt(r, e.scope) && this.cursorY < e.y + e.height && this.cursorY + t > e.y && (this.cursorY = e.y + e.height, i = !0, this.cursorY + t > this.contentBottom)) {
442
573
  this.addPage();
443
574
  return;
444
575
  }
@@ -446,89 +577,100 @@ class gt {
446
577
  }
447
578
  setTextStyle(t) {
448
579
  if (!t) return;
449
- const r = t.fontSize, a = t.fontStyle, i = t.color;
580
+ const r = t.fontSize, i = t.fontStyle, e = t.color;
450
581
  this.drawOp(() => {
451
- if (r && this.pdf.setFontSize(r), a) {
582
+ if (r && this.pdf.setFontSize(r), i) {
452
583
  const s = this.pdf.getFont().fontName;
453
- this.pdf.setFont(s, a);
584
+ this.pdf.setFont(s, i);
454
585
  }
455
- if (i) {
456
- const s = q(i);
586
+ if (e) {
587
+ const s = gt(e);
457
588
  s && (this.pdf.setTextColor(s[0], s[1], s[2]), s[3] !== void 0 ? this.pdf.setGState(
458
589
  new this.pdf.GState({ opacity: s[3] })
459
590
  ) : this.pdf.setGState(new this.pdf.GState({ opacity: 1 })));
460
591
  }
461
592
  });
462
593
  }
463
- textRaw(t, r, a, i, s, e = "left") {
464
- this.setTextStyle(i);
465
- const f = { align: e };
466
- typeof s == "number" && (f.maxWidth = s), this.drawOp(() => {
467
- this.pdf.text(t, r, a, f);
594
+ textRaw(t, r, i, e, s, u = "left") {
595
+ this.setTextStyle(e);
596
+ const c = { align: u };
597
+ typeof s == "number" && (c.maxWidth = s), this.drawOp(() => {
598
+ this.pdf.text(t, r, i, c);
468
599
  }), this.applyBaseFont();
469
600
  }
470
- box(t, r, a, i, s) {
471
- const e = s ?? {};
601
+ box(t, r, i, e, s) {
602
+ const u = s ?? {};
472
603
  this.drawOp(() => {
473
- if (e.borderWidth || e.borderColor || e.fillColor) {
474
- if (e.fillColor) {
475
- const u = q(e.fillColor);
476
- u && (u[3] !== void 0 && this.pdf.setGState(
477
- new this.pdf.GState({ opacity: u[3] })
478
- ), this.pdf.setFillColor(u[0], u[1], u[2]));
604
+ if (u.borderWidth || u.borderColor || u.fillColor) {
605
+ if (u.fillColor) {
606
+ const a = gt(u.fillColor);
607
+ a && (a[3] !== void 0 && this.pdf.setGState(
608
+ new this.pdf.GState({ opacity: a[3] })
609
+ ), this.pdf.setFillColor(a[0], a[1], a[2]));
479
610
  }
480
- if ((e.borderWidth || e.borderColor) && (e.borderWidth && this.pdf.setLineWidth(e.borderWidth), e.borderColor)) {
481
- const u = q(e.borderColor);
482
- u && (u[3] !== void 0 && this.pdf.setGState(
483
- new this.pdf.GState({ opacity: u[3] })
484
- ), this.pdf.setDrawColor(u[0], u[1], u[2]));
611
+ if ((u.borderWidth || u.borderColor) && (u.borderWidth && this.pdf.setLineWidth(u.borderWidth), u.borderColor)) {
612
+ const a = gt(u.borderColor);
613
+ a && (a[3] !== void 0 && this.pdf.setGState(
614
+ new this.pdf.GState({ opacity: a[3] })
615
+ ), this.pdf.setDrawColor(a[0], a[1], a[2]));
485
616
  }
486
- let f = "";
487
- e.fillColor && (f += "F"), (e.borderWidth || e.borderColor) && (f += "D"), f && (e.radius ? this.pdf.roundedRect(t, r, a, i, e.radius, e.radius, f) : this.pdf.rect(t, r, a, i, f)), this.pdf.setLineWidth(0.2), this.pdf.setDrawColor(0, 0, 0), this.pdf.setGState(new this.pdf.GState({ opacity: 1 }));
617
+ let c = "";
618
+ u.fillColor && (c += "F"), (u.borderWidth || u.borderColor) && (c += "D"), c && (u.radius ? this.pdf.roundedRect(t, r, i, e, u.radius, u.radius, c) : this.pdf.rect(t, r, i, e, c)), this.pdf.setLineWidth(0.2), this.pdf.setDrawColor(0, 0, 0), this.pdf.setGState(new this.pdf.GState({ opacity: 1 }));
488
619
  }
489
620
  });
490
621
  }
491
- line(t, r, a, i) {
622
+ line(t, r, i, e) {
492
623
  this.drawOp(() => {
493
- this.pdf.line(t, r, a, i);
624
+ this.pdf.line(t, r, i, e);
494
625
  });
495
626
  }
496
627
  async imageFromUrl(t, r = {}) {
497
- const a = (async () => {
628
+ const i = (async () => {
498
629
  try {
499
- const { dataUrl: i, width: s, height: e } = await this.loadImageAsDataURL(t), f = 0.264583, u = s * f, p = e * f;
500
- let l = r.w, x = r.h;
501
- l === void 0 && x === void 0 ? (l = u, x = p) : l === void 0 && x !== void 0 ? l = x * (u / p) : x === void 0 && l !== void 0 && (x = l * (p / u));
502
- const h = l ?? u, g = x ?? p;
503
- let m = r.x, w = r.y ?? this.cursorY;
504
- if (r.y === void 0 && w + g > this.contentBottom && (this.addPage(), w = this.cursorY), m === void 0) {
505
- const d = r.align ?? "left";
506
- d === "left" ? m = this.contentLeft : d === "center" ? m = (this.contentLeft + this.contentRight) / 2 - h / 2 : d === "right" && (m = this.contentRight - h);
630
+ const { dataUrl: e, width: s, height: u } = await this.loadImageAsDataURL(t), c = 0.264583, a = s * c, y = u * c;
631
+ let f = r.w, P = r.h;
632
+ f === void 0 && P === void 0 ? (f = a, P = y) : f === void 0 && P !== void 0 ? f = P * (a / y) : P === void 0 && f !== void 0 && (P = f * (y / a));
633
+ const h = f ?? a, p = P ?? y;
634
+ let b = r.x, d = r.y ?? this.cursorY;
635
+ if (r.y === void 0 && d + p > this.contentBottom && (this.addPage(), d = this.cursorY), b === void 0) {
636
+ const l = r.align ?? "left";
637
+ l === "left" ? b = this.contentLeft : l === "center" ? b = (this.contentLeft + this.contentRight) / 2 - h / 2 : l === "right" && (b = this.contentRight - h);
638
+ }
639
+ if (r.radius && r.radius > 0) {
640
+ const l = r.radius, m = b, v = d, C = h, x = p, _ = l * 0.551784;
641
+ this.pdf.saveGraphicsState(), this.pdf.moveTo(m + l, v), this.pdf.lineTo(m + C - l, v), this.pdf.curveTo(m + C - l + _, v, m + C, v + l - _, m + C, v + l), this.pdf.lineTo(m + C, v + x - l), this.pdf.curveTo(
642
+ m + C,
643
+ v + x - l + _,
644
+ m + C - l + _,
645
+ v + x,
646
+ m + C - l,
647
+ v + x
648
+ ), this.pdf.lineTo(m + l, v + x), this.pdf.curveTo(m + l - _, v + x, m, v + x - l + _, m, v + x - l), this.pdf.lineTo(m, v + l), this.pdf.curveTo(m, v + l - _, m + l - _, v, m + l, v), this.pdf.clip();
507
649
  }
508
650
  return this.pdf.addImage(
509
- i,
651
+ e,
510
652
  r.mime ?? "PNG",
511
- m,
512
- w,
653
+ b,
654
+ d,
513
655
  h,
514
- g
515
- ), { width: h, height: g, x: m, y: w };
516
- } catch (i) {
517
- return console.error("Failed to load image", t, i), { width: 0, height: 0, x: 0, y: 0 };
656
+ p
657
+ ), r.radius && r.radius > 0 && this.pdf.restoreGraphicsState(), { width: h, height: p, x: b, y: d };
658
+ } catch (e) {
659
+ return console.error("Failed to load image", t, e), { width: 0, height: 0, x: 0, y: 0 };
518
660
  }
519
661
  })();
520
- return this.registerTask(a), a;
662
+ return this.registerTask(i), i;
521
663
  }
522
664
  queueOperation(t) {
523
- const r = this.generation, a = this.opQueue.then(async () => {
665
+ const r = this.generation, i = this.opQueue.then(async () => {
524
666
  if (this.generation === r)
525
667
  try {
526
668
  await t();
527
- } catch (i) {
528
- console.error("Operation failed", i);
669
+ } catch (e) {
670
+ console.error("Operation failed", e);
529
671
  }
530
672
  });
531
- this.opQueue = a, this.registerTask(a);
673
+ this.opQueue = i, this.registerTask(i);
532
674
  }
533
675
  registerTask(t) {
534
676
  this.pendingTasks.add(t), t.finally(() => {
@@ -539,34 +681,34 @@ class gt {
539
681
  await Promise.all(this.pendingTasks), await this.opQueue;
540
682
  }
541
683
  loadImageAsDataURL(t) {
542
- return new Promise((r, a) => {
543
- const i = new Image();
544
- i.crossOrigin = "anonymous", i.onload = () => {
684
+ return new Promise((r, i) => {
685
+ const e = new Image();
686
+ e.crossOrigin = "anonymous", e.onload = () => {
545
687
  const s = document.createElement("canvas");
546
- s.width = i.width, s.height = i.height;
547
- const e = s.getContext("2d");
548
- if (!e) return a(new Error("Canvas 2D context not available"));
549
- e.drawImage(i, 0, 0), r({
688
+ s.width = e.width, s.height = e.height;
689
+ const u = s.getContext("2d");
690
+ if (!u) return i(new Error("Canvas 2D context not available"));
691
+ u.drawImage(e, 0, 0), r({
550
692
  dataUrl: s.toDataURL("image/png"),
551
- width: i.width,
552
- height: i.height
693
+ width: e.width,
694
+ height: e.height
553
695
  });
554
- }, i.onerror = (s) => a(s), i.src = t;
696
+ }, e.onerror = (s) => i(s), e.src = t;
555
697
  });
556
698
  }
557
- paragraph(t, r, a) {
558
- const i = a ?? this.contentWidth;
699
+ paragraph(t, r, i) {
700
+ const e = i ?? this.contentWidth;
559
701
  this.setTextStyle(r);
560
- const s = r?.lineHeight ?? this.defaultLineHeight, e = r?.fontSize ?? this.defaultFont.size, f = e * s * 0.3528, u = this.pdf.splitTextToSize(t, i), p = r?.align ?? "left";
561
- let l = 0;
562
- return u.forEach((x) => {
563
- this.cursorY + f > this.contentBottom && this.addPage();
564
- const h = this.cursorY + e * 0.3528;
565
- let g = this.cursorX;
566
- p === "center" ? g = this.cursorX + i / 2 : p === "right" && (g = this.cursorX + i), this.drawOp(() => {
567
- this.pdf.text(x, g, h, { align: p, maxWidth: i });
568
- }), this.cursorY += f, l += f;
569
- }), this.cursorY += 1, this.applyBaseFont(), l;
702
+ const s = r?.lineHeight ?? this.defaultLineHeight, u = r?.fontSize ?? this.defaultFont.size, c = u * s * 0.3528, a = this.pdf.splitTextToSize(t, e), y = r?.align ?? "left";
703
+ let f = 0;
704
+ return a.forEach((P) => {
705
+ this.cursorY + c > this.contentBottom && this.addPage();
706
+ const h = u * 0.3528, p = (c - h) / 2, b = this.cursorY + h + p;
707
+ let d = this.cursorX;
708
+ y === "center" ? d = this.cursorX + e / 2 : y === "right" && (d = this.cursorX + e), this.drawOp(() => {
709
+ this.pdf.text(P, d, b, { align: y, maxWidth: e });
710
+ }), this.cursorY += c, f += c;
711
+ }), this.applyBaseFont(), f;
570
712
  }
571
713
  moveCursor(t, r) {
572
714
  this.cursorX += t, this.cursorY += r;
@@ -591,24 +733,26 @@ class gt {
591
733
  this.pdf.setPage(t);
592
734
  }
593
735
  }
594
- measureText(t, r, a) {
736
+ measureText(t, r, i) {
595
737
  this.setTextStyle(r);
596
- const i = r?.fontSize ?? this.defaultFont.size, s = r?.lineHeight ?? this.defaultLineHeight, e = i * s * 0.3528;
597
- if (a) {
598
- const f = this.pdf.splitTextToSize(t, a);
738
+ const e = r?.fontSize ?? this.defaultFont.size, s = r?.lineHeight ?? this.defaultLineHeight, u = e * s * 0.3528;
739
+ if (i) {
740
+ const c = this.pdf.splitTextToSize(t, i);
599
741
  return {
600
- width: a,
601
- height: f.length * e
742
+ width: i,
743
+ height: c.length * u
602
744
  };
603
745
  } else {
604
- const f = this.pdf.getTextDimensions(t);
605
- return { width: f.w, height: f.h };
746
+ const c = this.pdf.getTextDimensions(t);
747
+ return { width: c.w, height: c.h };
606
748
  }
607
749
  }
608
750
  setMetadata(t) {
609
- t.title && this.pdf.setDocumentProperties({ title: t.title }), t.author && this.pdf.setDocumentProperties({ author: t.author }), t.subject && this.pdf.setDocumentProperties({ subject: t.subject }), t.keywords && this.pdf.setDocumentProperties({
751
+ t.title && this.pdf.setDocumentProperties({ title: t.title }), t.author && this.pdf.setDocumentProperties({ author: t.author }), t.subject && this.pdf.setDocumentProperties({ subject: t.subject }), t.keywords && (Array.isArray(t.keywords) ? this.pdf.setDocumentProperties({
610
752
  keywords: t.keywords.join(", ")
611
- });
753
+ }) : this.pdf.setDocumentProperties({
754
+ keywords: String(t.keywords)
755
+ }));
612
756
  }
613
757
  save(t) {
614
758
  this.applyHeaderFooter(), this.pdf.save(t);
@@ -620,488 +764,697 @@ class gt {
620
764
  * Injects a filled rectangle at the beginning of the page stream.
621
765
  * This ensures the background is drawn BEHIND all other content on the page.
622
766
  */
623
- injectFill(t, r, a) {
624
- const s = this.pdf.internal.pages[t];
625
- if (!s) return;
626
- const e = this.pdf.internal.scaleFactor, f = this.pdf.internal.pageSize.getHeight(), u = r.x * e, p = r.h * e, l = r.w * e, x = (f - (r.y + r.h)) * e, h = q(a);
627
- if (!h) return;
628
- const g = ["q"];
629
- g.push(
630
- `${(h[0] / 255).toFixed(3)} ${(h[1] / 255).toFixed(3)} ${(h[2] / 255).toFixed(3)} rg`
631
- ), g.push(
632
- `${u.toFixed(2)} ${x.toFixed(2)} ${l.toFixed(2)} ${p.toFixed(2)} re f`
633
- ), g.push("Q"), s && Array.isArray(s) && s.unshift(g.join(" "));
767
+ injectFill(t, r, i, e) {
768
+ const s = this.pdf.internal.pages;
769
+ let u = s[t];
770
+ if (!u && s[t - 1] && (u = s[t - 1]), !u) return;
771
+ const c = this.pdf.internal.scaleFactor, a = this.pdf.internal.pageSize.getHeight(), y = r.x * c, f = r.h * c, P = r.w * c, h = (a - (r.y + r.h)) * c, p = gt(i);
772
+ if (!p) return;
773
+ const b = ["q"];
774
+ b.push(
775
+ `${(p[0] / 255).toFixed(3)} ${(p[1] / 255).toFixed(3)} ${(p[2] / 255).toFixed(3)} rg`
776
+ );
777
+ let d = !1, l = 0, m = 0, v = 0, C = 0;
778
+ if (typeof e == "number" && e > 0 ? (d = !0, l = m = v = C = e * c) : typeof e == "object" && (e.tl || e.tr || e.br || e.bl) && (d = !0, l = (e.tl ?? 0) * c, m = (e.tr ?? 0) * c, v = (e.br ?? 0) * c, C = (e.bl ?? 0) * c), d) {
779
+ const g = y, _ = y + P, W = h, H = h + f;
780
+ if (b.push(`${(g + l).toFixed(2)} ${H.toFixed(2)} m`), b.push(`${(_ - m).toFixed(2)} ${H.toFixed(2)} l`), m > 0) {
781
+ const O = m * 0.551784;
782
+ b.push(
783
+ `${(_ - m + O).toFixed(2)} ${H.toFixed(2)} ${_.toFixed(
784
+ 2
785
+ )} ${(H - m + O).toFixed(2)} ${_.toFixed(2)} ${(H - m).toFixed(2)} c`
786
+ );
787
+ }
788
+ if (b.push(`${_.toFixed(2)} ${(W + v).toFixed(2)} l`), v > 0) {
789
+ const O = v * 0.551784;
790
+ b.push(
791
+ `${_.toFixed(2)} ${(W + v - O).toFixed(2)} ${(_ - v + O).toFixed(2)} ${W.toFixed(2)} ${(_ - v).toFixed(
792
+ 2
793
+ )} ${W.toFixed(2)} c`
794
+ );
795
+ }
796
+ if (b.push(`${(g + C).toFixed(2)} ${W.toFixed(2)} l`), C > 0) {
797
+ const O = C * 0.551784;
798
+ b.push(
799
+ `${(g + C - O).toFixed(2)} ${W.toFixed(2)} ${g.toFixed(
800
+ 2
801
+ )} ${(W + C - O).toFixed(2)} ${g.toFixed(2)} ${(W + C).toFixed(2)} c`
802
+ );
803
+ }
804
+ if (b.push(`${g.toFixed(2)} ${(H - l).toFixed(2)} l`), l > 0) {
805
+ const O = l * 0.551784;
806
+ b.push(
807
+ `${g.toFixed(2)} ${(H - l + O).toFixed(2)} ${(g + l - O).toFixed(2)} ${H.toFixed(2)} ${(g + l).toFixed(
808
+ 2
809
+ )} ${H.toFixed(2)} c`
810
+ );
811
+ }
812
+ b.push("f");
813
+ } else
814
+ b.push(
815
+ `${y.toFixed(2)} ${h.toFixed(2)} ${P.toFixed(2)} ${f.toFixed(2)} re f`
816
+ );
817
+ b.push("Q"), u && Array.isArray(u) && u.unshift(b.join(" "));
634
818
  }
635
819
  }
636
- const at = ct(null), V = () => {
637
- const n = ft(at);
820
+ const $t = At(null), pt = () => {
821
+ const n = jt($t);
638
822
  if (!n) throw new Error("usePdf must be used within <PdfDocument>");
639
823
  return n;
640
- }, pt = ({
824
+ }, Kt = ({
641
825
  options: n,
642
826
  header: t,
643
827
  footer: r,
644
- pageNumbers: a,
645
- centerLabel: i,
828
+ pageNumbers: i,
829
+ centerLabel: e,
646
830
  metadata: s,
647
- children: e,
648
- onReady: f,
649
- filename: u,
650
- autoSave: p = !1
831
+ children: u,
832
+ onReady: c,
833
+ filename: a,
834
+ autoSave: y = !1
651
835
  }) => {
652
- const l = $.useMemo(() => new gt(n), [n]);
653
- return $.useEffect(() => {
654
- s && l.setMetadata(s);
655
- }, [l, s]), $.useEffect(() => {
656
- const x = (w, d) => !d || d === "all" ? !0 : d === "first-only" ? w === 1 : d === "except-first" ? w > 1 : Array.isArray(d) ? d.includes(w) : !0, h = (w, d) => d === "roman-upper" ? it(w, !0) : d === "roman-lower" ? it(w, !1) : String(w), g = (w, d, P) => {
657
- if (!a?.enabled || !x(d, a.scope)) return;
658
- const L = a.preset ?? "page-slash-total", j = (a.template ?? (L === "page-slash-total" ? "Page {page}/{total}" : L === "page-of-total" ? "Page {page} of {total}" : "{page}/{total}")).replace("{page}", h(d, a.format)).replace("{total}", h(P, a.format)), I = a.align ?? "right", X = I === "left" ? l.contentLeft + (a.offsetX ?? 0) : I === "right" ? l.contentRight - (a.offsetX ?? 0) : (l.contentLeft + l.contentRight) / 2 + (a.offsetX ?? 0), M = w === "header" ? 10 : l.height - 7, J = typeof a.y == "number" ? a.y : M;
659
- l.textRaw(j, X, J, a.style, void 0, I);
660
- }, m = (w, d, P) => {
661
- if (!i?.enabled || !x(d, i.scope)) return;
662
- const L = "center", y = (l.contentLeft + l.contentRight) / 2 + (i.offsetX ?? 0), j = w === "header" ? 10 : l.height - 7, I = typeof i.y == "number" ? i.y : j;
663
- l.textRaw(
664
- i.text,
665
- y,
666
- I,
667
- i.style,
836
+ const f = z.useMemo(() => new Qt(n), [n]);
837
+ return f.reset(), z.useEffect(() => {
838
+ s && f.setMetadata(s);
839
+ }, [f, s]), z.useEffect(() => {
840
+ const P = (d, l) => !l || l === "all" ? !0 : l === "first-only" ? d === 1 : l === "except-first" ? d > 1 : Array.isArray(l) ? l.includes(d) : !0, h = (d, l) => l === "roman-upper" ? It(d, !0) : l === "roman-lower" ? It(d, !1) : String(d), p = (d, l, m) => {
841
+ if (!i?.enabled || !P(l, i.scope)) return;
842
+ const v = i.preset ?? "page-slash-total", x = (i.template ?? (v === "page-slash-total" ? "Page {page}/{total}" : v === "page-of-total" ? "Page {page} of {total}" : "{page}/{total}")).replace("{page}", h(l, i.format)).replace("{total}", h(m, i.format)), g = i.align ?? "right", _ = g === "left" ? f.contentLeft + (i.offsetX ?? 0) : g === "right" ? f.contentRight - (i.offsetX ?? 0) : (f.contentLeft + f.contentRight) / 2 + (i.offsetX ?? 0), W = d === "header" ? 10 : f.height - 7, H = typeof i.y == "number" ? i.y : W;
843
+ f.textRaw(x, _, H, i.style, void 0, g);
844
+ }, b = (d, l, m) => {
845
+ if (!e?.enabled || !P(l, e.scope)) return;
846
+ const v = "center", C = (f.contentLeft + f.contentRight) / 2 + (e.offsetX ?? 0), x = d === "header" ? 10 : f.height - 7, g = typeof e.y == "number" ? e.y : x;
847
+ f.textRaw(
848
+ e.text,
849
+ C,
850
+ g,
851
+ e.style,
668
852
  void 0,
669
- L
853
+ v
670
854
  );
671
855
  };
672
- return l.setHeaderFooter(
673
- (w, d, P) => {
674
- t && t(l, d, P), a?.position === "header" && g("header", d, P), i?.position === "header" && m("header", d);
856
+ return f.setHeaderFooter(
857
+ (d, l, m) => {
858
+ t && t(f, l, m), i?.position === "header" && p("header", l, m), e?.position === "header" && b("header", l);
675
859
  },
676
- (w, d, P) => {
677
- a?.position === "footer" && g("footer", d, P), r && r(l, d, P), i?.position === "footer" && m("footer", d);
860
+ (d, l, m) => {
861
+ i?.position === "footer" && p("footer", l, m), r && r(f, l, m), e?.position === "footer" && b("footer", l);
678
862
  }
679
- ), l.waitForTasks().then(() => {
680
- f?.(l);
863
+ ), f.waitForTasks().then(() => {
864
+ c?.(f);
681
865
  }), () => {
682
- l.reset();
866
+ f.reset();
683
867
  };
684
- }, [l]), $.useEffect(() => {
685
- p && u && l.save(u);
686
- }, [p, u]), /* @__PURE__ */ U.jsx(at.Provider, { value: l, children: e });
687
- }, Rt = ({
868
+ }, [f]), z.useEffect(() => {
869
+ y && a && f.save(a);
870
+ }, [y, a]), /* @__PURE__ */ tt.jsx($t.Provider, { value: f, children: u });
871
+ }, Zt = At(null), Tt = () => jt(Zt), se = ({
688
872
  src: n,
689
873
  x: t,
690
874
  y: r,
691
- w: a,
692
- h: i,
875
+ w: i,
876
+ h: e,
693
877
  mime: s = "PNG",
694
- flow: e,
695
- layout: f,
696
- sizing: u,
697
- align: p = "left",
698
- showInAllPages: l,
699
- scope: x
878
+ flow: u,
879
+ layout: c,
880
+ sizing: a,
881
+ align: y = "left",
882
+ showInAllPages: f,
883
+ scope: P,
884
+ className: h,
885
+ style: p
700
886
  }) => {
701
- const h = V();
702
- return $.useLayoutEffect(() => {
703
- const g = f === "flow" || e === !0 || t === void 0 && r === void 0 && f !== "fixed";
704
- let m = a;
705
- u === "fill" && (m = h.contentAreaWidth);
706
- const w = t, d = r;
707
- h.queueOperation(async () => {
708
- const P = h.getCursor(), y = await (async (j, I) => {
709
- const X = w, M = d;
710
- return await h.imageFromUrl(n, {
711
- x: X,
712
- y: M,
713
- w: m,
714
- h: i,
887
+ const b = pt(), d = Tt(), l = Ct(), { ref: m, computeStyle: v } = wt(), C = z.useRef(null);
888
+ return z.useLayoutEffect(() => {
889
+ if (C.current?.pdf === b && C.current?.gen === b.generation)
890
+ return;
891
+ C.current = { pdf: b, gen: b.generation };
892
+ const x = v(), g = i ?? (typeof x.width == "number" ? x.width : void 0), _ = e ?? (typeof x.height == "number" ? x.height : void 0), W = x.margin, H = (typeof W == "number" ? W : W?.bottom) ?? 2, O = c === "flow" || u === !0 || t === void 0 && r === void 0 && c !== "fixed";
893
+ let F = g;
894
+ a === "fill" && (F = b.contentAreaWidth);
895
+ const U = t, q = r, L = async () => {
896
+ const R = b.getCursor(), E = await (async (M, ft) => {
897
+ const st = U, S = q;
898
+ return await b.imageFromUrl(n, {
899
+ x: st,
900
+ y: S,
901
+ w: F,
902
+ h: _,
715
903
  mime: s,
716
- align: p
904
+ align: y,
905
+ radius: x.radius
717
906
  });
718
907
  })();
719
- g && y && h.moveCursor(0, y.height + 2), l && y && h.registerRecurringItem({
908
+ O && E && b.moveCursor(0, E.height + H), f && E && b.registerRecurringItem({
720
909
  draw: () => {
721
- h.queueOperation(async () => {
722
- g && h.setCursor(P.x, P.y), await h.imageFromUrl(n, {
723
- x: w,
724
- y: g ? P.y : d,
725
- w: m,
726
- h: i,
910
+ b.queueOperation(async () => {
911
+ O && b.setCursor(R.x, R.y), await b.imageFromUrl(n, {
912
+ x: U,
913
+ y: O ? R.y : q,
914
+ w: F,
915
+ h: _,
727
916
  mime: s,
728
- align: p
917
+ align: y,
918
+ radius: x.radius
729
919
  });
730
920
  });
731
921
  },
732
- scope: x ?? "all",
733
- y: g ? P.y : d ?? 0,
734
- height: y.height + 2
922
+ scope: P ?? "all",
923
+ y: O ? R.y : q ?? 0,
924
+ height: E.height + H
735
925
  });
736
- });
926
+ };
927
+ if (d)
928
+ return d.registerOperation(l, L), () => d.unregisterOperation(l);
929
+ b.queueOperation(L);
737
930
  }, [
738
- h,
931
+ b,
739
932
  n,
740
933
  t,
741
934
  r,
742
- a,
743
935
  i,
744
- s,
745
936
  e,
746
- f,
937
+ s,
747
938
  u,
748
- p,
749
- l,
750
- x
751
- ]), null;
752
- }, St = ({
939
+ c,
940
+ a,
941
+ y,
942
+ f,
943
+ P,
944
+ h
945
+ ]), /* @__PURE__ */ tt.jsx(
946
+ "div",
947
+ {
948
+ ref: m,
949
+ className: h,
950
+ style: {
951
+ ...p,
952
+ position: "absolute",
953
+ visibility: "hidden",
954
+ pointerEvents: "none"
955
+ }
956
+ }
957
+ );
958
+ }, ae = ({
753
959
  items: n,
754
960
  ordered: t = !1,
755
961
  style: r,
756
- indent: a = 5,
757
- markerWidth: i = 5,
758
- spacing: s = 2
962
+ indent: i = 5,
963
+ markerWidth: e = 5,
964
+ spacing: s = 2,
965
+ className: u
759
966
  }) => {
760
- const e = V();
761
- return $.useLayoutEffect(() => {
762
- e.queueOperation(() => {
763
- n.forEach((f, u) => {
764
- const p = t ? `${u + 1}.` : "•", l = r?.fontSize ?? e.baseFont.size, x = l * 1.2 * 0.3528;
765
- e.getCursor().y + x > e.contentBottom && e.addPage();
766
- const g = e.getCursor().y, m = e.getCursor().x, w = m + a + i, d = g + l * 0.3528;
767
- e.textRaw(
768
- p,
769
- m + a,
770
- d,
771
- r,
772
- i,
967
+ const c = pt(), a = Tt(), y = Ct(), { ref: f, computeStyle: P } = wt(), h = z.useRef(null);
968
+ return z.useLayoutEffect(() => {
969
+ if (h.current?.pdf === c && h.current?.gen === c.generation)
970
+ return;
971
+ h.current = { pdf: c, gen: c.generation };
972
+ const p = P(), b = {
973
+ ...p,
974
+ ...r
975
+ }, d = async () => {
976
+ const l = typeof p.margin == "number" ? p.margin : p.margin?.top;
977
+ l && c.moveCursor(0, l), n.forEach((v, C) => {
978
+ const x = t ? `${C + 1}.` : "•", g = b.fontSize ?? c.baseFont.size, _ = g * 1.2 * 0.3528;
979
+ c.getCursor().y + _ > c.contentBottom && c.addPage();
980
+ const H = c.getCursor().y, O = c.getCursor().x, F = O + i + e, U = H + g * 0.3528;
981
+ c.textRaw(
982
+ x,
983
+ O + i,
984
+ U,
985
+ b,
986
+ e,
773
987
  "right"
774
- ), e.setCursor(w, g);
775
- const P = e.contentRight - w;
776
- e.paragraph(f, r, P);
777
- const L = e.getCursor().y;
778
- e.setCursor(m, L + s);
988
+ ), c.setCursor(F, H);
989
+ const q = c.contentRight - F;
990
+ c.paragraph(v, b, q);
991
+ const L = c.getCursor().y;
992
+ c.setCursor(O, L + s);
779
993
  });
780
- });
781
- }, [e, n, t, r, a, i, s]), null;
782
- }, Tt = ({
994
+ const m = typeof p.margin == "number" ? p.margin : p.margin?.bottom;
995
+ m && c.moveCursor(0, m);
996
+ };
997
+ if (a)
998
+ return a.registerOperation(y, d), () => a.unregisterOperation(y);
999
+ c.queueOperation(d);
1000
+ }, [
1001
+ c,
1002
+ a,
1003
+ y,
1004
+ n,
1005
+ t,
1006
+ r,
1007
+ i,
1008
+ e,
1009
+ s,
1010
+ u
1011
+ ]), /* @__PURE__ */ tt.jsx(
1012
+ "div",
1013
+ {
1014
+ ref: f,
1015
+ className: u,
1016
+ style: {
1017
+ position: "absolute",
1018
+ visibility: "hidden",
1019
+ pointerEvents: "none"
1020
+ }
1021
+ }
1022
+ );
1023
+ }, ce = ({
783
1024
  width: n = "inherit",
784
1025
  height: t = "inherit",
785
1026
  className: r,
786
- style: a,
787
- iframeClassName: i,
1027
+ style: i,
1028
+ iframeClassName: e,
788
1029
  iframeStyle: s,
789
- ...e
1030
+ ...u
790
1031
  }) => {
791
- const [f, u] = lt(null), p = (l) => {
792
- const x = l.getBlobUrl();
793
- u(x.toString());
1032
+ const [c, a] = Yt(null), y = (f) => {
1033
+ const P = f.getBlobUrl();
1034
+ a(P.toString());
794
1035
  };
795
- return /* @__PURE__ */ U.jsxs("div", { className: r, style: { width: n, height: t, ...a }, children: [
796
- /* @__PURE__ */ U.jsx("div", { style: { display: "none" }, children: /* @__PURE__ */ U.jsx(pt, { ...e, onReady: p, autoSave: !1, children: e.children }) }),
797
- f ? /* @__PURE__ */ U.jsx(
798
- "iframe",
799
- {
800
- src: f,
801
- width: "100%",
802
- height: "100%",
803
- className: i,
804
- style: { border: "none", ...s },
805
- title: "PDF Preview"
806
- }
807
- ) : /* @__PURE__ */ U.jsx(
808
- "div",
809
- {
810
- style: {
811
- width: "100%",
812
- height: "100%",
813
- display: "flex",
814
- alignItems: "center",
815
- justifyContent: "center",
816
- backgroundColor: "#f3f4f6",
817
- color: "#6b7280"
818
- },
819
- children: "Generating Preview..."
820
- }
821
- )
822
- ] });
823
- }, Pt = ({
1036
+ return /* @__PURE__ */ tt.jsxs(
1037
+ "div",
1038
+ {
1039
+ className: `pdf-preview-container ${r || ""}`,
1040
+ style: { width: n, height: t, ...i },
1041
+ children: [
1042
+ /* @__PURE__ */ tt.jsx("div", { className: "pdf-preview-hidden", children: /* @__PURE__ */ tt.jsx(Kt, { ...u, onReady: y, autoSave: !1, children: u.children }) }),
1043
+ c ? /* @__PURE__ */ tt.jsx(
1044
+ "iframe",
1045
+ {
1046
+ src: c,
1047
+ width: "100%",
1048
+ height: "100%",
1049
+ className: `pdf-preview-iframe ${e || ""}`,
1050
+ style: s,
1051
+ title: "PDF Preview"
1052
+ }
1053
+ ) : /* @__PURE__ */ tt.jsx("div", { className: "pdf-preview-placeholder", children: "Generating Preview..." })
1054
+ ]
1055
+ }
1056
+ );
1057
+ }, fe = ({
824
1058
  data: n,
825
1059
  columns: t,
826
1060
  width: r = "100%",
827
- borderWidth: a = 0.1,
828
- borderColor: i = "#000000",
1061
+ borderWidth: i = 0.1,
1062
+ borderColor: e = "#000000",
829
1063
  cellPadding: s = 2,
830
- headerStyle: e,
831
- rowStyle: f,
832
- alternateRowStyle: u,
833
- headerHeight: p,
834
- repeatHeader: l = !0,
835
- striped: x = !1
1064
+ headerStyle: u,
1065
+ rowStyle: c,
1066
+ alternateRowStyle: a,
1067
+ headerHeight: y,
1068
+ repeatHeader: f = !0,
1069
+ striped: P = !1,
1070
+ stripeColor: h = "#E5E7EB",
1071
+ className: p,
1072
+ style: b
836
1073
  }) => {
837
- const h = V();
838
- return $.useLayoutEffect(() => {
839
- h.queueOperation(() => {
840
- const g = typeof r == "number" ? r : parseFloat(r) / 100 * h.contentAreaWidth, m = t.map((S) => typeof S.width == "number" ? S.width : typeof S.width == "string" && S.width.endsWith("%") ? parseFloat(S.width) / 100 * g : 0), w = m.reduce((S, A) => S + A, 0), d = Math.max(0, g - w), P = m.filter((S) => S === 0).length;
841
- if (P > 0) {
842
- const S = d / P;
843
- for (let A = 0; A < m.length; A++)
844
- m[A] === 0 && (m[A] = S);
1074
+ const d = pt(), l = Tt(), m = Ct(), { ref: v, computeStyle: C } = wt(), x = z.useRef(null);
1075
+ return z.useLayoutEffect(() => {
1076
+ if (x.current?.pdf === d && x.current?.gen === d.generation)
1077
+ return;
1078
+ x.current = { pdf: d, gen: d.generation };
1079
+ const g = C(), _ = r === "100%" && g.width ? g.width : r, W = g.borderColor ?? e, H = g.borderWidth ?? i, F = (!!p || !!b) && g.padding ? g.padding : s, U = {
1080
+ color: g.color,
1081
+ fontSize: g.fontSize,
1082
+ fontStyle: g.fontStyle,
1083
+ align: g.align,
1084
+ fillColor: g.fillColor
1085
+ }, q = { ...U, ...c }, L = { ...U, ...u };
1086
+ u?.fontStyle || (L.fontStyle = u?.fontStyle ?? "bold");
1087
+ const R = async () => {
1088
+ const at = typeof g.margin == "number" ? g.margin : g.margin?.top;
1089
+ at && d.moveCursor(0, at);
1090
+ const E = typeof _ == "number" ? _ : parseFloat(_) / 100 * d.contentAreaWidth, M = t.map((I) => typeof I.width == "number" ? I.width : typeof I.width == "string" && I.width.endsWith("%") ? parseFloat(I.width) / 100 * E : 0), ft = M.reduce((I, X) => I + X, 0), st = Math.max(0, E - ft), S = M.filter((I) => I === 0).length;
1091
+ if (S > 0) {
1092
+ const I = st / S;
1093
+ for (let X = 0; X < M.length; X++)
1094
+ M[X] === 0 && (M[X] = I);
845
1095
  }
846
- const L = (S, A, E, Y, z, v, W = "left", D = !0) => {
847
- D && h.box(A, E, Y, z, {
848
- borderColor: v.borderColor ?? i,
849
- borderWidth: v.borderWidth ?? a,
850
- fillColor: v.fillColor
1096
+ const o = (I, X, B, et, ct, k, ot = "left", nt = !0) => {
1097
+ nt && d.box(X, B, et, ct, {
1098
+ borderColor: k.borderColor ?? W,
1099
+ borderWidth: k.borderWidth ?? H,
1100
+ fillColor: k.fillColor,
1101
+ radius: k.radius
851
1102
  });
852
- const k = tt(v.padding ?? s), H = {
853
- top: v.paddingTop ?? k.top,
854
- right: v.paddingRight ?? k.right,
855
- bottom: v.paddingBottom ?? k.bottom,
856
- left: v.paddingLeft ?? k.left
857
- }, _ = Y - H.left - H.right, R = h.instance.splitTextToSize(S, _, v), o = (v.fontSize ?? h.baseFont.size) * (v.lineHeight ?? h.baseLineHeight) * 0.3528, c = (v.fontSize ?? h.baseFont.size) * 0.3528, b = R.length * o, C = z - H.top - H.bottom;
858
- let F = 0;
859
- v.verticalAlign === "middle" ? F = Math.max(0, (C - b) / 2) : v.verticalAlign === "bottom" && (F = Math.max(0, C - b));
860
- let N = E + H.top + F + c;
861
- const T = v.align ?? W, B = h.getCursor();
862
- R.forEach((G) => {
863
- let O = A + H.left;
864
- T === "center" ? O = A + Y / 2 : T === "right" && (O = A + Y - H.right), h.textRaw(G, O, N, v, void 0, T), N += o;
865
- }), h.setCursor(B.x, B.y);
1103
+ const V = St(k.padding ?? F), rt = {
1104
+ top: k.paddingTop ?? V.top,
1105
+ right: k.paddingRight ?? V.right,
1106
+ bottom: k.paddingBottom ?? V.bottom,
1107
+ left: k.paddingLeft ?? V.left
1108
+ }, G = et - rt.left - rt.right, j = d.instance.splitTextToSize(I, G, k), D = (k.fontSize ?? d.baseFont.size) * (k.lineHeight ?? d.baseLineHeight) * 0.3528, A = (k.fontSize ?? d.baseFont.size) * 0.3528, N = j.length * D, Q = ct - rt.top - rt.bottom;
1109
+ let K = 0;
1110
+ k.verticalAlign === "middle" ? K = Math.max(0, (Q - N) / 2) : k.verticalAlign === "bottom" && (K = Math.max(0, Q - N));
1111
+ let dt = B + rt.top + K + A;
1112
+ const ht = k.align ?? ot, mt = d.getCursor();
1113
+ j.forEach((yt) => {
1114
+ let J = X + rt.left;
1115
+ ht === "center" ? J = X + et / 2 : ht === "right" && (J = X + et - rt.right), d.textRaw(yt, J, dt, k, void 0, ht), dt += D;
1116
+ }), d.setCursor(mt.x, mt.y);
866
1117
  };
867
- let y = h.getCursor().y;
868
- const j = h.getCursor().x, I = p ?? 10;
869
- y + I > h.contentBottom && (h.addPage(), y = h.getCursor().y);
870
- let X = j;
871
- t.forEach((S, A) => {
872
- const E = m[A];
873
- L(
874
- S.header ?? "",
875
- X,
876
- y,
877
- E,
878
- I,
879
- e ?? { fontStyle: "bold" },
880
- S.align ?? "left"
881
- ), X += E;
882
- }), y += I, h.setCursor(j, y);
883
- const M = (S, A, E) => {
884
- const Y = tt(s), z = {
885
- top: E.paddingTop ?? Y.top,
886
- right: E.paddingRight ?? Y.right,
887
- bottom: E.paddingBottom ?? Y.bottom,
888
- left: E.paddingLeft ?? Y.left
889
- }, v = A - z.left - z.right;
890
- return h.measureText(S, E, v).height + z.top + z.bottom;
1118
+ let w = d.getCursor().y;
1119
+ const T = d.getCursor().x, Y = y ?? 10;
1120
+ w + Y > d.contentBottom && (d.addPage(), w = d.getCursor().y);
1121
+ let Z = T;
1122
+ t.forEach((I, X) => {
1123
+ const B = M[X];
1124
+ o(
1125
+ I.header ?? "",
1126
+ Z,
1127
+ w,
1128
+ B,
1129
+ Y,
1130
+ L,
1131
+ I.align ?? "left"
1132
+ ), Z += B;
1133
+ }), w += Y, d.setCursor(T, w);
1134
+ const ut = (I, X, B) => {
1135
+ const et = St(F), ct = {
1136
+ top: B.paddingTop ?? et.top,
1137
+ right: B.paddingRight ?? et.right,
1138
+ bottom: B.paddingBottom ?? et.bottom,
1139
+ left: B.paddingLeft ?? et.left
1140
+ }, k = X - ct.left - ct.right;
1141
+ return d.measureText(I, B, k).height + ct.top + ct.bottom;
891
1142
  };
892
1143
  new Array(t.length).fill(0), (() => {
893
- const S = new Array(n.length).fill(0), A = [];
894
- for (let v = 0; v < n.length; v++) {
895
- const W = n[v];
896
- let D = 0;
897
- for (let k = 0; k < t.length; k++) {
898
- const H = t[k], _ = typeof H.accessor == "function" ? H.accessor(W) : W[H.accessor];
899
- let R = "", o = f, c = 1, b = 1;
900
- _ && typeof _ == "object" && _.content !== void 0 ? (R = String(_.content), _.style && (o = _.style), _.colSpan && (c = _.colSpan), _.rowSpan && (b = _.rowSpan)) : R = String(_ ?? "");
901
- let C = m[k];
902
- for (let N = 1; N < c; N++)
903
- k + N < m.length && (C += m[k + N]);
904
- if (b > 1) {
905
- A.push({
906
- ri: v,
907
- rSpan: b,
908
- content: R,
909
- width: C,
910
- style: o ?? {}
911
- }), k += c - 1;
1144
+ const I = new Array(n.length).fill(0), X = [];
1145
+ for (let k = 0; k < n.length; k++) {
1146
+ const ot = n[k];
1147
+ let nt = 0;
1148
+ for (let V = 0; V < t.length; V++) {
1149
+ const rt = t[V], G = typeof rt.accessor == "function" ? rt.accessor(ot) : ot[rt.accessor];
1150
+ let j = "", D = q, A = 1, N = 1;
1151
+ G && typeof G == "object" && G.content !== void 0 ? (j = String(G.content), G.style && (D = { ...D, ...G.style }), G.colSpan && (A = G.colSpan), G.rowSpan && (N = G.rowSpan)) : j = String(G ?? "");
1152
+ let Q = M[V];
1153
+ for (let dt = 1; dt < A; dt++)
1154
+ V + dt < M.length && (Q += M[V + dt]);
1155
+ if (N > 1) {
1156
+ X.push({
1157
+ ri: k,
1158
+ rSpan: N,
1159
+ content: j,
1160
+ width: Q,
1161
+ style: D ?? {}
1162
+ }), V += A - 1;
912
1163
  continue;
913
1164
  }
914
- const F = M(R, C, o ?? {});
915
- F > D && (D = F), k += c - 1;
1165
+ const K = ut(j, Q, D ?? {});
1166
+ K > nt && (nt = K), V += A - 1;
916
1167
  }
917
- D < 8 && (D = 8), S[v] = D;
1168
+ nt < 8 && (nt = 8), I[k] = nt;
918
1169
  }
919
- A.forEach((v) => {
920
- const { ri: W, rSpan: D, content: k, width: H, style: _ } = v, R = M(k, H, _);
921
- let o = 0;
922
- for (let c = 0; c < D; c++)
923
- W + c < S.length && (o += S[W + c]);
924
- if (R > o) {
925
- const c = R - o, b = Math.min(W + D - 1, S.length - 1);
926
- S[b] += c;
1170
+ X.forEach((k) => {
1171
+ const { ri: ot, rSpan: nt, content: V, width: rt, style: G } = k, j = ut(V, rt, G);
1172
+ let D = 0;
1173
+ for (let A = 0; A < nt; A++)
1174
+ ot + A < I.length && (D += I[ot + A]);
1175
+ if (j > D) {
1176
+ const A = j - D, N = Math.min(ot + nt - 1, I.length - 1);
1177
+ I[N] += A;
927
1178
  }
928
1179
  });
929
- let E = y;
930
- const Y = new Array(t.length).fill(0), z = h.getCursor().x;
931
- for (let v = 0; v < n.length; v++) {
932
- const W = n[v], D = S[v];
933
- let k = D;
934
- for (let R = 0; R < t.length; R++) {
935
- const o = t[R], c = typeof o.accessor == "function" ? o.accessor(W) : W[o.accessor];
936
- let b = 1;
937
- if (c && typeof c == "object" && c.rowSpan && (b = c.rowSpan), b > 1) {
938
- let C = 0;
939
- for (let F = 0; F < b; F++)
940
- v + F < S.length && (C += S[v + F]);
941
- C > k && (k = C);
1180
+ let B = w;
1181
+ const et = new Array(t.length).fill(0), ct = d.getCursor().x;
1182
+ for (let k = 0; k < n.length; k++) {
1183
+ const ot = n[k], nt = I[k];
1184
+ let V = nt;
1185
+ for (let j = 0; j < t.length; j++) {
1186
+ const D = t[j], A = typeof D.accessor == "function" ? D.accessor(ot) : ot[D.accessor];
1187
+ let N = 1;
1188
+ if (A && typeof A == "object" && A.rowSpan && (N = A.rowSpan), N > 1) {
1189
+ let Q = 0;
1190
+ for (let K = 0; K < N; K++)
1191
+ k + K < I.length && (Q += I[k + K]);
1192
+ Q > V && (V = Q);
942
1193
  }
943
1194
  }
944
- const H = Math.abs(E - (h.contentTop + (p ?? 10))) < 1;
945
- if (E + k > h.contentBottom && !H && (h.addPage(), E = h.getCursor().y, l && (p ?? 10) !== 0)) {
946
- let R = z;
947
- t.forEach((o, c) => {
948
- const b = m[c];
949
- L(
950
- o.header ?? "",
951
- R,
952
- E,
953
- b,
954
- p ?? 10,
955
- e ?? { fontStyle: "bold" },
956
- o.align ?? "left"
957
- ), R += b;
958
- }), E += p ?? 10;
1195
+ const rt = Math.abs(B - (d.contentTop + (y ?? 10))) < 1;
1196
+ if (B + V > d.contentBottom && !rt && (d.addPage(), B = d.getCursor().y, f && (y ?? 10) !== 0)) {
1197
+ let j = ct;
1198
+ t.forEach((D, A) => {
1199
+ const N = M[A];
1200
+ o(
1201
+ D.header ?? "",
1202
+ j,
1203
+ B,
1204
+ N,
1205
+ y ?? 10,
1206
+ L,
1207
+ D.align ?? "left"
1208
+ ), j += N;
1209
+ }), B += y ?? 10;
959
1210
  }
960
- let _ = z;
961
- for (let R = 0; R < t.length; R++) {
962
- if (Y[R] > 0) {
963
- Y[R]--, _ += m[R];
1211
+ let G = ct;
1212
+ for (let j = 0; j < t.length; j++) {
1213
+ if (et[j] > 0) {
1214
+ et[j]--, G += M[j];
964
1215
  continue;
965
1216
  }
966
- const o = t[R], c = typeof o.accessor == "function" ? o.accessor(W) : W[o.accessor];
967
- let b = 1, C = 1, F = f;
968
- v % 2 === 1 && (u ? F = u : x && (F = { ...f, fillColor: "#E5E7EB" }));
969
- let T = "";
970
- c && typeof c == "object" && c.content !== void 0 ? (T = String(c.content), c.colSpan && (b = c.colSpan), c.rowSpan && (C = c.rowSpan), c.style && (F = { ...F, ...c.style })) : T = String(c ?? "");
971
- let B = m[R];
972
- for (let O = 1; O < b; O++)
973
- R + O < m.length && (B += m[R + O]);
974
- let G = D;
975
- if (C > 1)
976
- for (let O = 1; O < C; O++)
977
- v + O < S.length && (G += S[v + O]);
978
- if (L(
979
- T,
980
- _,
981
- E,
982
- B,
1217
+ const D = t[j], A = typeof D.accessor == "function" ? D.accessor(ot) : ot[D.accessor];
1218
+ let N = 1, Q = 1, K = q;
1219
+ k % 2 === 1 && (a ? K = a : P && (K = { ...q, fillColor: h }));
1220
+ let ht = "";
1221
+ A && typeof A == "object" && A.content !== void 0 ? (ht = String(A.content), A.colSpan && (N = A.colSpan), A.rowSpan && (Q = A.rowSpan), A.style && (K = { ...K, ...A.style })) : ht = String(A ?? "");
1222
+ let mt = M[j];
1223
+ for (let J = 1; J < N; J++)
1224
+ j + J < M.length && (mt += M[j + J]);
1225
+ let yt = nt;
1226
+ if (Q > 1)
1227
+ for (let J = 1; J < Q; J++)
1228
+ k + J < I.length && (yt += I[k + J]);
1229
+ if (o(
1230
+ ht,
983
1231
  G,
984
- F ?? {},
985
- o.align ?? "left",
1232
+ B,
1233
+ mt,
1234
+ yt,
1235
+ K ?? {},
1236
+ D.align ?? "left",
986
1237
  !0
987
- ), C > 1) {
988
- Y[R] = C - 1;
989
- for (let O = 1; O < b; O++)
990
- R + O < Y.length && (Y[R + O] = C - 1);
1238
+ ), Q > 1) {
1239
+ et[j] = Q - 1;
1240
+ for (let J = 1; J < N; J++)
1241
+ j + J < et.length && (et[j + J] = Q - 1);
991
1242
  }
992
- _ += B, R += b - 1;
1243
+ G += mt, j += N - 1;
993
1244
  }
994
- E += D;
1245
+ B += nt;
995
1246
  }
996
- h.setCursor(z, E);
1247
+ d.setCursor(ct, B);
997
1248
  })();
998
- });
999
- }, [h, n, t, r]), null;
1000
- }, yt = ({
1249
+ const lt = typeof g.margin == "number" ? g.margin : g.margin?.bottom;
1250
+ lt && d.moveCursor(0, lt);
1251
+ };
1252
+ if (l)
1253
+ return l.registerOperation(m, R), () => l.unregisterOperation(m);
1254
+ d.queueOperation(R);
1255
+ }, [d, n, t, r, p]), /* @__PURE__ */ tt.jsx(
1256
+ "div",
1257
+ {
1258
+ ref: v,
1259
+ className: p,
1260
+ style: {
1261
+ ...b,
1262
+ position: "absolute",
1263
+ visibility: "hidden",
1264
+ pointerEvents: "none"
1265
+ }
1266
+ }
1267
+ );
1268
+ }, le = ({
1001
1269
  children: n,
1002
1270
  x: t,
1003
1271
  y: r,
1004
- maxWidth: a,
1005
- spacingBelow: i = 2,
1006
- ...s
1272
+ maxWidth: i,
1273
+ spacingBelow: e = 2,
1274
+ className: s,
1275
+ style: u,
1276
+ ...c
1007
1277
  }) => {
1008
- const e = V();
1009
- return $.useLayoutEffect(() => {
1010
- e.queueOperation(() => {
1011
- const f = e.getCursor();
1012
- let u = 0;
1013
- const p = () => {
1278
+ const a = pt(), y = Tt(), f = Ct(), { ref: P, computeStyle: h } = wt(), p = z.useRef(null);
1279
+ return z.useLayoutEffect(() => {
1280
+ if (p.current?.pdf === a && p.current?.gen === a.generation)
1281
+ return;
1282
+ p.current = { pdf: a, gen: a.generation };
1283
+ const d = {
1284
+ ...h(),
1285
+ ...c
1286
+ }, l = async () => {
1287
+ const m = a.getCursor();
1288
+ let v = 0;
1289
+ const C = () => {
1014
1290
  if (typeof t == "number" && typeof r == "number")
1015
- e.textRaw(n, t, r, s, a, s.align);
1291
+ a.textRaw(n, t, r, d, i, d.align);
1016
1292
  else {
1017
- e.setCursor(f.x, f.y), u = e.paragraph(n, s, a);
1018
- const l = e.getCursor();
1019
- e.setCursor(l.x, l.y + i);
1293
+ a.setCursor(m.x, m.y), v = a.paragraph(n, d, i);
1294
+ const x = a.getCursor();
1295
+ e > 0 && a.setCursor(x.x, x.y + e);
1020
1296
  }
1021
1297
  };
1022
- p(), s.showInAllPages && e.registerRecurringItem({
1023
- draw: p,
1024
- scope: s.scope ?? "all",
1025
- y: f.y,
1026
- height: u + i
1298
+ C(), d.showInAllPages && a.registerRecurringItem({
1299
+ draw: C,
1300
+ scope: d.scope ?? "all",
1301
+ y: m.y,
1302
+ height: v + e
1027
1303
  });
1028
- });
1304
+ };
1305
+ if (y)
1306
+ return y.registerOperation(f, l), () => y.unregisterOperation(f);
1307
+ a.queueOperation(l);
1029
1308
  }, [
1030
- e,
1309
+ a,
1310
+ y,
1311
+ // Add context dependency
1312
+ f,
1031
1313
  n,
1032
1314
  t,
1033
1315
  r,
1034
- a,
1035
1316
  i,
1036
- s.fontSize,
1037
- s.align
1038
- ]), null;
1039
- }, mt = ({
1317
+ e,
1318
+ s,
1319
+ c.fontSize,
1320
+ c.color,
1321
+ c.align
1322
+ ]), /* @__PURE__ */ tt.jsx(
1323
+ "div",
1324
+ {
1325
+ ref: P,
1326
+ className: s,
1327
+ style: {
1328
+ ...u,
1329
+ position: "absolute",
1330
+ visibility: "hidden",
1331
+ pointerEvents: "none"
1332
+ }
1333
+ }
1334
+ );
1335
+ }, te = ({
1040
1336
  viewState: n,
1041
1337
  style: t,
1042
- pad: r,
1043
- margin: a,
1044
- w: i,
1045
- h: s
1338
+ className: r,
1339
+ computeStyle: i,
1340
+ w: e,
1341
+ h: s,
1342
+ showInAllPages: u,
1343
+ scope: c
1046
1344
  }) => {
1047
- const e = V();
1048
- return $.useLayoutEffect(() => {
1049
- e.queueOperation(() => {
1345
+ const a = pt(), y = z.useRef(null);
1346
+ return z.useLayoutEffect(() => {
1347
+ y.current?.pdf === a && y.current?.gen === a.generation || (y.current = { pdf: a, gen: a.generation }, a.queueOperation(() => {
1050
1348
  const f = n.start;
1051
1349
  if (!f) return;
1052
- const u = e.stopRecording();
1053
- let p = i ?? e.contentAreaWidth;
1054
- typeof t.width == "number" && (p = t.width), e.playback(u);
1055
- const l = e.getPageCount(), x = e.getCursor(), h = n.start.page ?? l;
1056
- for (let g = h; g <= l; g++) {
1057
- e.instance.setPage(g);
1058
- let m = e.contentTop, w;
1059
- if (g === h)
1060
- m = f.y, g === l ? t.height ? w = t.height : w = x.y - f.y + r.bottom : w = e.height - e.margin.bottom - f.y;
1061
- else if (g === l) {
1062
- m = e.contentTop, t.height, w = x.y - e.contentTop + r.bottom;
1063
- const d = e.height - e.margin.bottom;
1064
- w = Math.min(w, d - e.contentTop);
1350
+ let h = { ...i(), ...t };
1351
+ const p = !!h.fillColor, b = !!h.borderColor || (h.borderWidth ?? 0) > 0, d = t.padding !== void 0 || t.paddingTop !== void 0 || t.paddingRight !== void 0 || t.paddingBottom !== void 0 || t.paddingLeft !== void 0;
1352
+ (p || b) && !d && !r && (h.padding = 4), u !== void 0 && (h.showInAllPages = u), c !== void 0 && (h.scope = c);
1353
+ const l = St(h.padding), m = {
1354
+ top: h.paddingTop ?? l.top,
1355
+ right: h.paddingRight ?? l.right,
1356
+ bottom: h.paddingBottom ?? l.bottom,
1357
+ left: h.paddingLeft ?? l.left
1358
+ }, C = ((F) => typeof F == "number" ? { top: F, right: F, bottom: F, left: F } : {
1359
+ top: F?.top ?? 0,
1360
+ right: F?.right ?? 0,
1361
+ bottom: F?.bottom ?? 0,
1362
+ left: F?.left ?? 0
1363
+ })(h.margin), x = {
1364
+ top: h.marginTop ?? C.top,
1365
+ right: h.marginRight ?? C.right,
1366
+ bottom: h.marginBottom ?? C.bottom,
1367
+ left: h.marginLeft ?? C.left
1368
+ };
1369
+ let g = e ?? a.contentAreaWidth;
1370
+ typeof h.width == "number" && (g = h.width);
1371
+ const _ = g + m.left + m.right, W = a.getPageCount(), H = a.getCursor(), O = n.start.page ?? W;
1372
+ for (let F = O; F <= W; F++) {
1373
+ a.instance.setPage(F);
1374
+ const U = a.getSafeContentTop ? a.getSafeContentTop(F) : a.contentTop;
1375
+ let q = U, L;
1376
+ if (F === O)
1377
+ q = f.y, F === W ? h.height ? L = h.height : L = H.y - f.y + m.bottom : L = a.height - a.margin.bottom - f.y;
1378
+ else if (F === W) {
1379
+ q = U, h.height, L = H.y - U + m.bottom;
1380
+ const E = a.height - a.margin.bottom;
1381
+ L = Math.min(L, E - U);
1065
1382
  } else
1066
- m = e.contentTop, w = e.height - e.margin.bottom - e.contentTop;
1067
- if (t.fillColor) {
1068
- const d = g === h ? f.x : e.contentLeft, P = m, L = p, y = w;
1069
- e.injectFill && e.injectFill(
1070
- g,
1071
- { x: d, y: P, w: L, h: y },
1072
- t.fillColor
1073
- );
1383
+ q = U, L = a.height - a.margin.bottom - U;
1384
+ if (L < 0.5 || isNaN(L)) continue;
1385
+ const R = h.radius ?? 0, at = O === W;
1386
+ if (h.borderWidth && h.borderWidth > 0) {
1387
+ const E = a.instance, M = h.borderWidth, ft = h.borderColor ?? "#000000";
1388
+ E.setLineWidth(M);
1389
+ const st = gt(ft);
1390
+ st && E.setDrawColor(st[0], st[1], st[2]);
1391
+ const S = Math.max(f.x, a.margin.left), o = q, w = _, T = L;
1392
+ if (R > 0 && at)
1393
+ E.roundedRect(S, o, w, T, R, R);
1394
+ else if (R > 0 && !at) {
1395
+ const Y = (Z) => {
1396
+ const $ = R * 0.551784;
1397
+ Z[0] ? (E.moveTo(S, o + R), E.curveTo(S, o + R - $, S + R - $, o, S + R, o)) : E.moveTo(S, o), E.lineTo(S + w - (Z[1] ? R : 0), o), Z[1] ? E.curveTo(
1398
+ S + w - R + $,
1399
+ o,
1400
+ S + w,
1401
+ o + R - $,
1402
+ S + w,
1403
+ o + R
1404
+ ) : E.lineTo(S + w, o), E.lineTo(S + w, o + T - (Z[2] ? R : 0)), Z[2] ? E.curveTo(
1405
+ S + w,
1406
+ o + T - R + $,
1407
+ S + w - R + $,
1408
+ o + T,
1409
+ S + w - R,
1410
+ o + T
1411
+ ) : E.lineTo(S + w, o + T), E.lineTo(S + (Z[3] ? R : 0), o + T), Z[3] ? E.curveTo(
1412
+ S + R - $,
1413
+ o + T,
1414
+ S,
1415
+ o + T - R + $,
1416
+ S,
1417
+ o + T - R
1418
+ ) : E.lineTo(S, o + T), Z[0] ? E.lineTo(S, o + R) : E.lineTo(S, o), E.stroke();
1419
+ };
1420
+ Y(F === O ? [!0, !0, !1, !1] : F === W ? [!1, !1, !0, !0] : [!1, !1, !1, !1]);
1421
+ } else
1422
+ E.line(S, o, S, o + T), E.line(S + w, o, S + w, o + T), F === O && E.line(S, o, S + w, o), F === W && E.line(S, o + T, S + w, o + T);
1074
1423
  }
1075
- if (t.borderColor || t.borderWidth) {
1076
- const d = e.instance, P = t.borderWidth ?? 0.1, L = t.borderColor ?? "#000000";
1077
- d.setLineWidth(P);
1078
- const y = q(L);
1079
- y && d.setDrawColor(y[0], y[1], y[2]);
1080
- const j = g === h ? f.x : e.contentLeft, I = m, X = p, M = w;
1081
- d.line(j, I, j, I + M), d.line(j + X, I, j + X, I + M), g === h && d.line(j, I, j + X, I), g === l && d.line(j, I + M, j + X, I + M);
1424
+ if (h.fillColor) {
1425
+ const E = Math.max(f.x, a.margin.left), M = q, ft = _, st = L;
1426
+ try {
1427
+ if (a.injectFill) {
1428
+ let S = 0;
1429
+ R > 0 && at ? S = R : R > 0 && (F === O ? S = { tl: R, tr: R, br: 0, bl: 0 } : F === W ? S = { tl: 0, tr: 0, br: R, bl: R } : S = 0), a.injectFill(
1430
+ F,
1431
+ { x: E, y: M, w: ft, h: st },
1432
+ h.fillColor,
1433
+ S
1434
+ );
1435
+ }
1436
+ } catch (S) {
1437
+ console.warn("Background injection failed", S);
1438
+ }
1082
1439
  }
1083
1440
  }
1084
- if (e.instance.setPage(l), t.showInAllPages) {
1085
- const g = () => {
1086
- const m = t.height ?? 20;
1087
- e.box(f.x, f.y, p, m, t);
1441
+ if (a.instance.setPage(W), h.showInAllPages) {
1442
+ const F = () => {
1443
+ const U = h.height ?? 20;
1444
+ a.box(f.x, f.y, g, U, h);
1088
1445
  };
1089
- e.registerRecurringItem({
1090
- draw: g,
1091
- scope: t.scope ?? "all",
1446
+ a.registerRecurringItem({
1447
+ draw: F,
1448
+ scope: h.scope ?? "all",
1092
1449
  y: f.y,
1093
- height: t.height ?? 0
1450
+ height: h.height ?? 0
1094
1451
  });
1095
1452
  }
1096
- if (!n.isAbsolute) {
1097
- const g = x.y + r.bottom + a.bottom;
1098
- e.setCursor(f.x, g);
1099
- }
1100
- e.setReservedHeight(0), e.popIndent && e.popIndent();
1101
- });
1102
- }, [e, t.showInAllPages, t.scope, i, s]), null;
1453
+ n.isAbsolute || (a.setCursor(f.x, H.y), a.popVerticalPadding ? a.popVerticalPadding() : (a.moveCursor(0, m.bottom), a.setReservedHeight(0)), x.bottom > 0 && a.moveCursor(0, x.bottom)), n.hasIndent && a.popIndent && a.popIndent();
1454
+ }));
1455
+ }, [a, t, e, s, u, c]), null;
1103
1456
  };
1104
- function bt(n) {
1457
+ function ee(n) {
1105
1458
  return typeof n == "number" ? { top: n, right: n, bottom: n, left: n } : {
1106
1459
  top: n?.top ?? 0,
1107
1460
  right: n?.right ?? 0,
@@ -1109,100 +1462,123 @@ function bt(n) {
1109
1462
  left: n?.left ?? 0
1110
1463
  };
1111
1464
  }
1112
- const wt = ({
1465
+ const re = ({
1113
1466
  style: n,
1114
- x: t,
1115
- y: r,
1116
- w: a,
1117
- h: i,
1118
- viewState: s
1467
+ className: t,
1468
+ computeStyle: r,
1469
+ x: i,
1470
+ y: e,
1471
+ w: s,
1472
+ h: u,
1473
+ showInAllPages: c,
1474
+ scope: a,
1475
+ viewState: y
1119
1476
  }) => {
1120
- const e = V(), f = tt(n.padding), u = {
1121
- top: n.paddingTop ?? f.top,
1122
- right: n.paddingRight ?? f.right,
1123
- bottom: n.paddingBottom ?? f.bottom,
1124
- left: n.paddingLeft ?? f.left
1125
- }, p = bt(n.margin), l = {
1126
- top: n.marginTop ?? p.top,
1127
- right: n.marginRight ?? p.right,
1128
- bottom: n.marginBottom ?? p.bottom,
1129
- left: n.marginLeft ?? p.left
1130
- };
1131
- return $.useLayoutEffect(() => {
1132
- e.queueOperation(() => {
1133
- if (typeof t == "number" && typeof r == "number" && typeof a == "number" && typeof i == "number") {
1134
- s.isAbsolute = !0;
1135
- const x = e.getPageCount();
1136
- s.start = { x: t, y: r, page: x }, e.setCursor(t + u.left, r + u.top);
1477
+ const f = pt(), P = z.useRef(null);
1478
+ return z.useLayoutEffect(() => {
1479
+ P.current?.pdf === f && P.current?.gen === f.generation || (P.current = { pdf: f, gen: f.generation }, f.queueOperation(() => {
1480
+ let p = { ...r(), ...n };
1481
+ const b = !!p.fillColor, d = !!p.borderColor || (p.borderWidth ?? 0) > 0, l = n.padding !== void 0 || n.paddingTop !== void 0 || n.paddingRight !== void 0 || n.paddingBottom !== void 0 || n.paddingLeft !== void 0;
1482
+ (b || d) && !l && !t && (p.padding = 4), c !== void 0 && (p.showInAllPages = c), a !== void 0 && (p.scope = a);
1483
+ const m = St(p.padding), v = {
1484
+ top: p.paddingTop ?? m.top,
1485
+ right: p.paddingRight ?? m.right,
1486
+ bottom: p.paddingBottom ?? m.bottom,
1487
+ left: p.paddingLeft ?? m.left
1488
+ }, C = ee(p.margin), x = {
1489
+ top: p.marginTop ?? C.top,
1490
+ right: p.marginRight ?? C.right,
1491
+ bottom: p.marginBottom ?? C.bottom,
1492
+ left: p.marginLeft ?? C.left
1493
+ };
1494
+ if (typeof i == "number" && typeof e == "number" && typeof s == "number" && typeof u == "number") {
1495
+ y.isAbsolute = !0;
1496
+ const g = f.getPageCount();
1497
+ y.start = { x: i, y: e, page: g }, f.setCursor(i + v.left, e + v.top);
1137
1498
  } else {
1138
- s.isAbsolute = !1, l.top > 0 && e.moveCursor(0, l.top), e.startRecording();
1139
- const x = e.getCursor(), h = e.getPageCount();
1140
- s.start = { ...x, page: h }, e.pushIndent ? (e.pushIndent(u.left, u.right), u.top > 0 && e.moveCursor(0, u.top)) : e.setCursor(x.x + u.left, x.y + u.top), e.setReservedHeight(u.bottom);
1499
+ y.isAbsolute = !1, x.top > 0 && f.moveCursor(0, x.top), typeof p.height == "number" && p.height > 0 && f.moveCursor(0, p.height);
1500
+ const g = f.getCursor(), _ = f.getPageCount();
1501
+ y.start = { ...g, page: _ }, f.pushIndent ? ((v.left > 0 || v.right > 0) && (f.pushIndent(v.left, v.right), y.hasIndent = !0), f.pushVerticalPadding ? f.pushVerticalPadding(v.top, v.bottom) : (v.top > 0 && f.moveCursor(0, v.top), f.setReservedHeight(v.bottom))) : (f.setCursor(g.x + v.left, g.y + v.top), f.setReservedHeight(v.bottom));
1141
1502
  }
1142
- });
1143
- }, [e, t, r, a, i]), null;
1144
- };
1145
- function vt(n) {
1146
- return typeof n == "number" ? { top: n, right: n, bottom: n, left: n } : {
1147
- top: n?.top ?? 0,
1148
- right: n?.right ?? 0,
1149
- bottom: n?.bottom ?? 0,
1150
- left: n?.left ?? 0
1151
- };
1152
- }
1153
- const Et = ({
1503
+ }));
1504
+ }, [f, n, i, e, s, u, c, a]), null;
1505
+ }, de = ({
1154
1506
  style: n = {},
1155
- children: t,
1156
- x: r,
1157
- y: a,
1158
- w: i,
1159
- h: s
1507
+ className: t,
1508
+ style: r,
1509
+ children: i,
1510
+ x: e,
1511
+ y: s,
1512
+ w: u,
1513
+ h: c,
1514
+ showInAllPages: a,
1515
+ scope: y
1160
1516
  }) => {
1161
- V();
1162
- const e = tt(n.padding), f = {
1163
- top: n.paddingTop ?? e.top,
1164
- right: n.paddingRight ?? e.right,
1165
- bottom: n.paddingBottom ?? e.bottom,
1166
- left: n.paddingLeft ?? e.left
1167
- }, u = vt(n.margin), p = {
1168
- top: n.marginTop ?? u.top,
1169
- right: n.marginRight ?? u.right,
1170
- bottom: n.marginBottom ?? u.bottom,
1171
- left: n.marginLeft ?? u.left
1172
- }, l = $.useRef({}).current;
1173
- return l.radius = n.radius, /* @__PURE__ */ U.jsxs($.Fragment, { children: [
1174
- /* @__PURE__ */ U.jsx(
1175
- wt,
1517
+ const { ref: f, computeStyle: P } = wt(), h = Ot({}).current;
1518
+ return /* @__PURE__ */ tt.jsxs(z.Fragment, { children: [
1519
+ /* @__PURE__ */ tt.jsx(
1520
+ "div",
1521
+ {
1522
+ ref: f,
1523
+ className: t,
1524
+ style: {
1525
+ ...r,
1526
+ position: "absolute",
1527
+ visibility: "hidden",
1528
+ pointerEvents: "none"
1529
+ }
1530
+ }
1531
+ ),
1532
+ /* @__PURE__ */ tt.jsx(
1533
+ re,
1176
1534
  {
1177
1535
  style: n,
1178
- x: r,
1179
- y: a,
1180
- w: i,
1181
- h: s,
1182
- viewState: l
1536
+ className: t,
1537
+ computeStyle: P,
1538
+ x: e,
1539
+ y: s,
1540
+ w: u,
1541
+ h: c,
1542
+ showInAllPages: a,
1543
+ scope: y,
1544
+ viewState: h
1183
1545
  }
1184
1546
  ),
1185
- t,
1186
- /* @__PURE__ */ U.jsx(
1187
- mt,
1547
+ n.gap ? z.Children.map(i, (p, b) => /* @__PURE__ */ tt.jsxs(z.Fragment, { children: [
1548
+ b > 0 && /* @__PURE__ */ tt.jsx(oe, { height: n.gap }),
1549
+ p
1550
+ ] })) : i,
1551
+ /* @__PURE__ */ tt.jsx(
1552
+ te,
1188
1553
  {
1189
- viewState: l,
1554
+ viewState: h,
1190
1555
  style: n,
1191
- pad: f,
1192
- margin: p,
1193
- w: i,
1194
- h: s
1556
+ className: t,
1557
+ computeStyle: P,
1558
+ x: e,
1559
+ y: s,
1560
+ w: u,
1561
+ h: c,
1562
+ showInAllPages: a,
1563
+ scope: y
1195
1564
  }
1196
1565
  )
1197
1566
  ] });
1567
+ }, oe = ({ height: n }) => {
1568
+ const t = pt(), r = z.useRef(null);
1569
+ return z.useLayoutEffect(() => {
1570
+ n && (r.current?.pdf === t && r.current?.gen === t.generation || (r.current = { pdf: t, gen: t.generation }, t.queueOperation(() => {
1571
+ t.moveCursor(0, n);
1572
+ })));
1573
+ }, [n, t]), null;
1198
1574
  };
1199
1575
  export {
1200
- pt as PdfDocument,
1201
- Rt as PdfImage,
1202
- St as PdfList,
1203
- Tt as PdfPreview,
1204
- gt as PdfRenderer,
1205
- Pt as PdfTable,
1206
- yt as PdfText,
1207
- Et as PdfView
1576
+ Kt as PdfDocument,
1577
+ se as PdfImage,
1578
+ ae as PdfList,
1579
+ ce as PdfPreview,
1580
+ Qt as PdfRenderer,
1581
+ fe as PdfTable,
1582
+ le as PdfText,
1583
+ de as PdfView
1208
1584
  };